[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] old/wcm/inc/class.bosite.inc.php, 1.1
From: |
nomail |
Subject: |
[Phpgroupware-cvs] old/wcm/inc/class.bosite.inc.php, 1.1 |
Date: |
Thu, 30 Dec 2004 09:13:57 +0100 |
Update of /old/wcm/inc
Added Files:
Branch:
class.bosite.inc.php
date: 2004/12/30 08:13:57; author: skwashd; state: Exp;
Log Message:
keep historic record for wcm
=====================================================================
<?php
/**************************************************************************\
* phpGroupWare - WCM *
* http://www.phpgroupware.org *
* Written by Miles Lott <address@hidden> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id: class.bosite.inc.php,v 1.1 2004/12/30 08:13:57 skwashd Exp $ */
class bosite
{
var $public_functions = array(
'list_sites' => True,
'read' => True,
'edit' => True,
'delete' => True
);
var $xml_functions = array();
var $soap_functions = array();
var $debug = False;
var $so = '';
var $start = 0;
var $limit = 0;
var $query = '';
var $sort = '';
var $order = '';
var $total = 0;
var $use_session = False;
var $security_types = array(
'' => 'standard',
'ssl' => 'ssl'
);
var $publish_types = array(
'ftp' => 'ftp',
'http' => 'http',
'scp' => 'scp',
'local' => 'local'
);
var $site = array();
function bosite($session=False)
{
$this->so = CreateObject('wcm.sosite');
if($session)
{
$this->read_sessiondata();
$this->use_session = True;
}
$start = get_var('start', array('POST','GET'));
$query = get_var('query', array('POST','GET'));
$sort = get_var('sort', array('POST','GET'));
$order = get_var('order', array('POST','GET'));
$this->start = (!empty($start) || ($start == '0')) ?
$start : $this->start;
$this->query = (empty($query) && !empty($this->query))
|| !empty($query) ? $query : $this->query;
}
function save_sessiondata($data)
{
if ($this->use_session)
{
if($this->debug) { echo '<br>Save:';
_debug_array($data); }
$GLOBALS['phpgw']->session->appsession('session_data','wcm_sites',$data);
}
}
function read_sessiondata()
{
$data =
$GLOBALS['phpgw']->session->appsession('session_data','wcm_sites');
if($this->debug) { echo '<br>Read:';
_debug_array($data); }
$this->start = $data['start'];
$this->limit = $data['limit'];
$this->query = $data['query'];
$this->sort = $data['sort'];
$this->order = $data['order'];
}
function list_sites()
{
return
$this->so->list_sites(array($this->start,$this->sort,$this->order,$this->query,$this->limit),$this->total);
}
function read($id,$full=False)
{
if(is_array($id))
{
$id = $id['site_id'];
}
return $this->so->read($id,$full);
}
function edit($site_info)
{
if(!is_array($site_info))
{
return False;
}
$site_info['site_version'] =
$this->version($site_info['site_version']);
if($site_info['site_id'])
{
return $this->so->update($site_info);
}
else
{
$id = $this->so->add($site_info);
return $this->so->read($id);
}
}
function delete($id)
{
if(is_array($id))
{
$id = $id['site_id'];
}
return $this->so->delete($id);
}
function name2id($site_name='')
{
return $this->so->name2id($site_name);
}
function id2name($siteid='')
{
return $this->so->id2name($siteid);
}
function version($oldversion='',$major=False,$minor=False)
{
if(!$oldversion)
{
$newversion = '0.0.1';
}
else
{
list($maj,$min,$inc) = split("\.",$oldversion);
$maj = intval($maj);
$min = intval($min);
$inc = intval($inc);
if($major)
{
$maj++;
}
if($minor)
{
$min++;
}
if(!($major || $minor))
{
$inc++;
}
if($inc > 9)
{
$inc = 0;
$min++;
}
if($min > 9)
{
$min = 0;
$maj++;
}
if($maj > 9)
{
$maj = 9;
}
$newversion = $maj . '.' . $min . '.' . $inc;
}
return $newversion;
}
function publish($siteid='',$pageid='')
{
$cfg = CreateObject('phpgwapi.config','wcm');
$cfg->read_repository();
$acctid = intval($cfg->config_data['website_account']);
$acct = $GLOBALS['phpgw']->accounts->id2name($acctid);
$pass = $cfg->config_data['website_account_passwd'];
if(!$siteid)
{
return False;
}
$this->site = $this->read($siteid,True);
/* allow limiting to one page */
if($pageid)
{
while(list(,$page) =
each($this->site['site_pages']))
{
if($page['page_id'] = $pageid)
{
$tmp[] = $page;
}
}
$this->site['site_pages'] = $tmp;
unset($tmp);
}
$elements = CreateObject('wcm.boelement');
$SITE_ROOT = PHPGW_SERVER_ROOT . SEP . 'wcm' . SEP .
'website' . SEP . 'templates';
define('PHPGW_TEMPLATE_DIR',
ExecMethod('phpgwapi.phpgw.common.get_tpl_dir', 'phpgwapi'));
$tpl = CreateObject('phpgwapi.Template',$SITE_ROOT);
$tpl->set_file(array('frame' => 'frame.tpl'));
$tpl->set_block('frame','framing_table_start','framing_table_start');
$tpl->set_block('frame','framing_table_end','framing_table_end');
$tpl->set_block('frame','left_start','left_start');
$tpl->set_block('frame','left_end','left_end');
$tpl->set_block('frame','top_start','top_start');
$tpl->set_block('frame','top_end','top_end');
$tpl->set_block('frame','mid_start','mid_start');
$tpl->set_block('frame','mid_end','mid_end');
$tpl->set_block('frame','right_start','right_start');
$tpl->set_block('frame','right_end','right_end');
$tpl->set_block('frame','bottom_start','bottom_start');
$tpl->set_block('frame','bottom_end','bottom_end');
$tpl->set_block('frame','php_code','php_code');
$tpl->set_var('anonusername',$acct ? $acct : 'demo');
$tpl->set_var('anonpassword',$pass ? $pass : 'guest');
$tpl->set_var('phpgwdir',PHPGW_SERVER_ROOT . SEP);
if(@$this->site['site_bgcolor'])
{
$tpl->set_var('bgcolor',
$this->site['site_bgcolor']);
}
else
{
$tpl->set_var('bgcolor', '#FFFFFF');
}
while(list(,$page) = each($this->site['site_pages']))
{
$outfile = $page['page_url'];
$page['page_expire'] = $page['page_expire'] ?
$page['page_expire'] : '0';
/* Can this page override pane widths defined
by the site? */
$site_left = $this->site['site_paneo'] ?
$page['page_left'] : $this->site['site_left'];
$site_mid = $this->site['site_paneo'] ?
$page['page_mid'] : $this->site['site_mid'];
$site_right = $this->site['site_paneo'] ?
$page['page_right'] : $this->site['site_right'];
$tpl->set_var('left_width', $site_left ?
$site_left : '120');
$tpl->set_var('mid_width', $site_mid ?
$site_mid : '*');
$tpl->set_var('mid_img_width', $site_mid ?
$site_mid : '350');
$tpl->set_var('right_width', $site_right ?
$site_right : '130');
if(@$page['page_bgcolor'])
{
$tpl->set_var('bgcolor',
$page['page_bgcolor']);
}
$out = "<?php
\$GLOBALS['phpgw_info']['user']['account_id'] = $acctid; "
. "settype(\$site,'string'); \$page =
array(); \$ele = array(); \$site = '"
. $this->site['site_name'] . "'; "
. "\$page = array('name' => '" .
$page['page_name'] . "', "
. "'version' => '" .
$page['page_version'] . "', "
. "'date' => '" . time() . "', "
. "'expire' => '" .
$page['page_expire'] . "'); ?>" . "\n";
/* Read and parse page header */
$header_data =
$elements->read($page['page_header']);
$header = $header_data['element_source'];
$tpl->set_var('header',$header ? $header :
'<html><head></head><body>');
/* Start of page body */
$out .= $tpl->fp('out','framing_table_start');
/* Now parse each top, left, middle, right, and
bottom element */
$_list =
array('top','left','mid','right','bottom');
while(list(,$section) = each($_list))
{
$working = '';
while(list($key,$val) =
@each($page['page_elements'][$section]))
{
if($val['element_name'])
{
$val['element_expire']
= $val['element_expire'] ? $val['element_expire'] : '0';
$out .= "<?php \$ele[]
= array('name' => '" . $val['element_name'] . "', "
. "'version' =>
'" . $val['element_version'] . "', "
. "'date' => '"
. time() . "', "
. "'expire' =>
'" . $val['element_expire'] . "'); ?>" . "\n";
switch($val['element_type'])
{
/* LIVE hook */
case '5':
$working .= "<?php \$GLOBALS['phpgw']->hooks->single('website_$section', '" .
$val['element_source'] . "', True); ?>";
break;
case '4':
/* Hook
*/
$GLOBALS['phpgw']->hooks->single('website_' . $section,
$val['element_source'],True);
$working .= $GLOBALS['phpgw_info']['wcm'][$section];
break;
case '3':
case '2':
/*
file/image */
if(@stat($val['element_source']))
{
$f = fopen($val['element_source'],'rb');
while($line = fgets($f,1024))
{
$working .= $line;
}
fclose($f);
unset($f);
unset($line);
}
break;
case '1':
/* HTML
from db */
$working .= $val['element_source'];
break;
default:
break;
}
}
}
$tpl->set_var($section . '_content',
$working ? $working : '');
$out .= $tpl->fp('out', $section .
'_start');
$out .= $tpl->fp('out', $section .
'_end');
}
/* Read and parse page footer */
$footer_data =
$elements->read($page['page_footer']);
$footer = $footer_data['element_source'];
$tpl->set_var('footer',$footer ? $footer :
'</body></html>');
/* end of page body */
$out .= $tpl->fp('out','framing_table_end');
$out .= $tpl->fp('out','php_code');
/* Clean out the ^M for unix */
if ((PHP_OS != 'Windows') && (PHP_OS != 'OS/2'))
{
$out = ereg_replace("\r\n","\n",$out);
}
$this->publish_local($outfile,$out);
}
return True;
}
function publish_ftp($outfile='',$content='')
{
if(!$content && $outfile)
{
return False;
}
}
function publish_http($outfile='',$content='')
{
if(!$content && $outfile)
{
return False;
}
}
function publish_scp($outfile='',$content='')
{
if(!$content && $outfile)
{
return False;
}
}
/* Write to a local file */
function publish_local($outfile='',$content='')
{
if(!$content && $outfile)
{
return False;
}
$fp = fopen($this->site['site_puburl'] . SEP .
$outfile,'wb');
fwrite($fp,$content);
fclose($fp);
return True;
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] old/wcm/inc/class.bosite.inc.php, 1.1,
nomail <=