[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: sitemgr/inc class.Categories_UI.inc.php,NONE,1.1
From: |
Michael Totschnig <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: sitemgr/inc class.Categories_UI.inc.php,NONE,1.1 class.Common_BO.inc.php,NONE,1.1 class.Content_BO.inc.php,NONE,1.1 class.Content_SO.inc.php,NONE,1.1 class.Content_UI.inc.php,NONE,1.1 class.Modules_BO.inc.php,NONE,1.1 class.Modules_SO.inc.php,NONE,1.1 class.Modules_UI.inc.php,NONE,1.1 class.Pages_UI.inc.php,NONE,1.1 class.SiteContent_UI.inc.php,NONE,1.1 class.Translations_UI.inc.php,NONE,1.1 class.browser_transform.inc.php,NONE,1.1class.module.inc.php,NONE,1.1 class.module_administration.inc.php,NONE,1.1 class.module_amazon.inc.php,NONE,1.1class.module_appdir.inc.php,NONE,1.1 class.module_calendar.inc.php,NONE,1.1 class.module_currentsection.inc.php,NONE,1.1 class.module_forum.inc.php,NONE,1.1class.module_galerie.inc.php,NONE,1.1 class.module_google.inc.php,NONE,1.1class.module_hello.inc.php,NONE,1.1 class.module_html.inc.php,NONE,1.1class.module_index.inc.php,NONE,1.1 class.module_index_block.inc.php,NONE,1.1 class.module_lang_block.inc.php,NONE,1.1 class.module_login.inc.php,NONE,1.1class.module_meta.inc.php,NONE,1.1 class.module_news.inc.php,NONE,1.1class.module_sitetree.inc.php,NONE,1.1 class.module_toc.inc.php,NONE,1.1class.module_toc_block.inc.php,NONE,1.1 class.module_xml.inc.php,NONE,1.1 class.xmltool2.inc.php,NONE,1.1 class.xslt_transform.inc.php,NONE,1.1 class.ACL_BO.inc.php,1.1.1.1,1.2 class.ACL_SO.inc.php,1.2,1.3 class.Block_SO.inc.php,1.1,1.2 class.Categories_BO.inc.php,1.5,1.6 class.Categories_SO.inc.php,1.11,1.12 class.Common_UI.inc.php,1.7,1.8 class.MainMenu_UI.inc.php,1.5,1.6 class.Page_SO.inc.php,1.4,1.5 class.Pages_BO.inc.php,1.3,1.4 class.Pages_SO.inc.php,1.9,1.10 class.Theme_BO.inc.php,1.3,1.4 class.sitePreference_SO.inc.php,1.2,1.3 hook_admin.inc.php,1.1.1.1,1.2 hook_preferences.inc.php,1.1.1.1,1.2 class.Admin_ManageCategories_UI.inc.php,1.6,NONE class.Blocks_BO.inc.php,1.2,NONE class.Blocks_SO.inc.php,1.1,NONE class.Categories_db_SO.inc.php,1.7,NONE class.admin_ManageSiteContent_UI.inc.php,1.2,NONE class.contributor_ManagePage_UI.inc.php,1.8,NONE |
Date: |
Thu, 16 Jan 2003 22:37:55 -0500 |
Update of /cvsroot/phpgroupware/sitemgr/inc
In directory subversions:/tmp/cvs-serv24731/inc
Modified Files:
class.ACL_BO.inc.php class.ACL_SO.inc.php
class.Block_SO.inc.php class.Categories_BO.inc.php
class.Categories_SO.inc.php class.Common_UI.inc.php
class.MainMenu_UI.inc.php class.Page_SO.inc.php
class.Pages_BO.inc.php class.Pages_SO.inc.php
class.Theme_BO.inc.php class.sitePreference_SO.inc.php
hook_admin.inc.php hook_preferences.inc.php
Added Files:
class.Categories_UI.inc.php class.Common_BO.inc.php
class.Content_BO.inc.php class.Content_SO.inc.php
class.Content_UI.inc.php class.Modules_BO.inc.php
class.Modules_SO.inc.php class.Modules_UI.inc.php
class.Pages_UI.inc.php class.SiteContent_UI.inc.php
class.Translations_UI.inc.php class.browser_transform.inc.php
class.module.inc.php class.module_administration.inc.php
class.module_amazon.inc.php class.module_appdir.inc.php
class.module_calendar.inc.php
class.module_currentsection.inc.php class.module_forum.inc.php
class.module_galerie.inc.php class.module_google.inc.php
class.module_hello.inc.php class.module_html.inc.php
class.module_index.inc.php class.module_index_block.inc.php
class.module_lang_block.inc.php class.module_login.inc.php
class.module_meta.inc.php class.module_news.inc.php
class.module_sitetree.inc.php class.module_toc.inc.php
class.module_toc_block.inc.php class.module_xml.inc.php
class.xmltool2.inc.php class.xslt_transform.inc.php
Removed Files:
class.Admin_ManageCategories_UI.inc.php
class.Blocks_BO.inc.php class.Blocks_SO.inc.php
class.Categories_db_SO.inc.php
class.admin_ManageSiteContent_UI.inc.php
class.contributor_ManagePage_UI.inc.php
Log Message:
First commit of a new modularized architecture for sitemgr
--- NEW FILE ---
<?php
/***************************************************************************\
* phpGroupWare - Web Content Manager
*
* http://www.phpgroupware.org
*
* -------------------------------------------------
*
* 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.
*
\***************************************************************************/
class Categories_UI
{
var $common_ui;
var $cat;
var $cat_list;
var $cat_bo;
var $acl;
var $isadmin;
var $t;
var $sitelanguages;
var $public_functions = array
(
'_manageCategories' => True,
'_editCategory' => True,
'_deleteCategory' => True
);
function Categories_UI()
{
$this->common_ui =
CreateObject('sitemgr.Common_UI',True);
$this->t = $GLOBALS['phpgw']->template;
$this->cat_bo = $GLOBALS['Common_BO']->cats;
$this->cat = CreateObject('sitemgr.Category_SO', True);
$this->acl = $GLOBALS['Common_BO']->acl;
$this->isadmin = $this->acl->is_admin();
$preferenceso =
CreateObject('sitemgr.sitePreference_SO', true);
$this->sitelanguages =
explode(',',$preferenceso->getPreference('sitelanguages'));
}
function _manageCategories()
{
$this->common_ui->DisplayHeader();
$this->t->set_var(Array('category_manager' =>
lang('Category Manager'),
'lang_catname' => lang('Category Name'),
'lang_goto' => lang('Go to Page Manager')));
$this->t->set_file('ManageCategories',
'manage_categories.tpl');
$this->t->set_block('ManageCategories',
'CategoryBlock', 'CBlock');
$this->cat_list =
$this->cat_bo->getPermittedCatWriteNested();
if($this->cat_list)
{
for($i = 0; $i < sizeof($this->cat_list); $i++)
{
$this->cat =
$this->cat_bo->getCategory($this->cat_list[$i],$this->sitelanguages[0]);
if ($this->cat->depth)
{
$buffer = '-';
}
else
{
$buffer = '';
}
$buffer =
str_pad('',$this->cat->depth*18,
' ',STR_PAD_LEFT).$buffer;
$cat_id = $this->cat_list[$i];
$this->t->set_var('buffer', $buffer);
$this->t->set_var('category',
sprintf('%s : %d',$this->cat->name,$cat_id));
$link_data['page_id'] = 0;
$link_data['cat_id'] = $cat_id;
if ($this->isadmin)
{
$this->t->set_var('edit',
'<form action="'.
$GLOBALS['phpgw']->link('/index.php',
'menuaction=sitemgr.Categories_UI._editCategory').
'" method="POST"><input
type="submit" value="' . lang('Edit') .'"><input type="hidden" name="cat_id"
value="'.$cat_id.'">
</form>');
$this->t->set_var('remove',
'<form action="'.
$GLOBALS['phpgw']->link('/index.php',
'menuaction=sitemgr.Categories_UI._deleteCategory').
'" method="POST">
<input type="submit"
value="' . lang('Delete') .'">
<input type="hidden"
name="cat_id" value="'. $cat_id .'">
</form>');
$link_data['menuaction'] =
"sitemgr.Modules_UI._manageModules";
$this->t->set_var('moduleconfig',
'<form action="'.
$GLOBALS['phpgw']->link('/index.php',$link_data).
'" method="POST">
<input type="submit"
value="' . lang('Manage Modules') .'"></form>');
}
$link_data['menuaction'] =
"sitemgr.Content_UI._manageContent";
$this->t->set_var('content',
'<form action="'.
$GLOBALS['phpgw']->link('/index.php',$link_data).
'" method="POST">
<input type="submit" value="' .
lang('Manage Content') .'"></form>');
$this->t->parse('CBlock',
'CategoryBlock', True);
}
}
else
{
$this->t->set_var('category','No category is
available');
}
$this->t->set_var('add',
'<form action="'.
$GLOBALS['phpgw']->link('/index.php',
'menuaction=sitemgr.Categories_UI._editCategory').
'" method="POST">
<input type=submit value = "' . lang('Add a
category') .'">
</form>'
);
$this->t->set_var('managepageslink',$GLOBALS['phpgw']->link(
'/index.php',
'menuaction=sitemgr.Pages_UI._managePage')
);
$this->t->pfp('out', 'ManageCategories');
$this->common_ui->DisplayFooter();
}
function _editCategory()
{
if (!$this->isadmin)
{
$this->_manageCategories();
return False;
}
$GLOBALS['Common_BO']->globalize(array('btnSave','catname','catdesc','cat_id','sort_order','parent','parent_old','groupaccessread','groupaccesswrite','individualaccessread','individualaccesswrite','savelanguage','inputgetparentpermissions','inputapplypermissionstosubs'));
global $btnSave,
$cat_id,$catname,$catdesc,$sort_order,$parent,$parent_old;
global $groupaccessread, $groupaccesswrite,
$individualaccessread, $individualaccesswrite;
global $savelanguage,
$inputgetparentpermissions,$inputapplypermissionstosubs;
if ($btnSave && $catname && $catdesc)
{
if (!$cat_id)
{
$cat_id=$this->cat_bo->addCategory('','');
}
$groupaccess =
array_merge_recursive($groupaccessread, $groupaccesswrite);
$individualaccess =
array_merge_recursive($individualaccessread, $individualaccesswrite);
$savelanguage = $savelanguage ? $savelanguage :
$this->sitelanguages[0];
$this->cat_bo->saveCategoryInfo($cat_id,
$catname, $catdesc, $savelanguage, $sort_order, $parent, $parent_old);
if ($inputgetparentpermissions)
{
$this->cat_bo->saveCategoryPermsfromparent($cat_id);
}
else
{
$this->cat_bo->saveCategoryPerms($cat_id, $groupaccess, $individualaccess);
}
if ($inputapplypermissionstosubs)
{
$this->cat_bo->applyCategoryPermstosubs($cat_id);
}
$this->_manageCategories();
return;
}
$this->common_ui->DisplayHeader();
if ($cat_id)
{
$this->cat =
$this->cat_bo->getCategory($cat_id,$this->sitelanguages[0]);
}
//if the user tried to save, but catname or catdesc
were empty, we remember the modified values
if ($btnSave)
{
$this->t->set_var('error_msg',lang('You failed
to fill in one or more required fields.'));
$this->cat->name = $catname;
$this->cat->description = $catdesc;
}
$this->t->set_file('EditCategory', 'edit_category.tpl');
$this->t->set_block('EditCategory','GroupBlock',
'GBlock');
if (count($this->sitelanguages) > 1)
{
$select = lang('as') . ' <select
name="savelanguage">';
foreach ($this->sitelanguages as $lang)
{
$select .= '<option value="' . $lang .
'">'. $GLOBALS['Common_BO']->getlangname($lang) . '</option>';
}
$select .= '</select> ';
$this->t->set_var('savelang',$select);
}
$this->t->set_var(array(
'add_edit' => ($cat_id ? lang('Edit Category')
: lang('Add Category')),
'cat_id' => $cat_id,
'catname' => $this->cat->name,
'catdesc' => $this->cat->description,
'sort_order' => $this->cat->sort_order,
'parent_dropdown' =>
$this->getParentOptions($this->cat->parent,$cat_id),
'old_parent' => $this->cat->parent,
'lang_basic' => lang('Basic Settings'),
'lang_catname' => lang('Category Name'),
'lang_catsort' => lang('Sort Order'),
'lang_catparent' => lang('Parent'),
'lang_catdesc' => lang('Category Description'),
'lang_groupaccess' => lang('Group Access
Permissions'),
'lang_groupname' => lang('Group Name'),
'lang_readperm' => lang('Read Permission'),
'lang_writeperm' => lang('Write Permission'),
'lang_useraccess' => lang('Individual Access
Permission'),
'lang_username' => lang('User Name'),
'lang_reset' => lang('Reset'),
'lang_save' => lang('Save'),
'lang_getparentpermissions' => lang('Fill in
permissions from parent category? If you check this, below values will be
ignored'),
'lang_applypermissionstosubs' => lang('Apply
permissions also to subcategories?')
));
$acct = CreateObject('phpgwapi.accounts');
$grouplist = $this->acl->get_group_list();
$permissionlist = ($cat_id ?
$this->acl->get_group_permission_list($cat_id) : array());
if($grouplist)
{
for($i = 0; $i < count($grouplist); $i++ )
{
//$account_name =
$acct->id2name($permissionlist[$i]['account_id']);
//$this->t->set_var('group_id',$permissionlist[$i]['account_id']);
$account_name =
$grouplist[$i]['account_lid'];
$this->t->set_var('group_id',$grouplist[$i]['account_id']);
if ($cat_id)
{
$permission_id =
$permissionlist[$i]['rights'];
}
else
{
$permission_id = 0;
}
$this->t->set_var('groupname',
$account_name);
if ($permission_id == PHPGW_ACL_ADD)
{
$permission_id = PHPGW_ACL_ADD
| PHPGW_ACL_READ;
}
if ($permission_id & PHPGW_ACL_READ)
{
$this->t->set_var('checkedgroupread','CHECKED');
}
else
{
$this->t->set_var('checkedgroupread','');
}
if ($permission_id & PHPGW_ACL_ADD)
{
$this->t->set_var('checkedgroupwrite','CHECKED');
}
else
{
$this->t->set_var('checkedgroupwrite','');
}
$this->t->parse('GBlock', 'GroupBlock',
True);
}
}
else
{
$this->t->set_var('groupname',lang("No groups
defined."));
}
$this->t->set_block('EditCategory','UserBlock',
'UBlock');
$userlist = $this->acl->get_user_list();
$userpermissionlist =
$this->acl->get_user_permission_list($cat_id);
if($userlist)
{
for($i = 0; $i < count($userlist); $i++ )
{
$user_name =
$userlist[$i]['account_lid'];
if ($cat_id)
{
$user_permission_id =
$userpermissionlist[$i]['rights'];
}
else
{
$user_permission_id = 0;
}
$this->t->set_var('user_id',
$userlist[$i]['account_id']);
$this->t->set_var('username',
$user_name);
if ($user_permission_id ==
PHPGW_ACL_ADD)
{
$user_permission_id =
PHPGW_ACL_ADD | PHPGW_ACL_READ;
}
if ($user_permission_id &
PHPGW_ACL_READ )
{
$this->t->set_var('checkeduserread','CHECKED');
}
else
{
$this->t->set_var('checkeduserread','');
}
if ($user_permission_id & PHPGW_ACL_ADD
)
{
$this->t->set_var('checkeduserwrite','CHECKED');
}
else
{
$this->t->set_var('checkeduserwrite','');
}
$this->t->parse('UBlock', 'UserBlock',
True);
}
}
else
{
$this->t->set_var('username',lang("No users
defined."));
}
$this->t->pfp('out','EditCategory');
$this->common_ui->DisplayFooter();
}
function getParentOptions($selected_id=0,$skip_id=0)
{
$option_list=$this->cat_bo->getCategoryOptionList();
if (!$selected_id)
{
$selected=' SELECTED';
}
if (!$skip_id)
{
$skip_id = -1;
}
$retval="\n".'<SELECT NAME="parent">'."\n";
foreach($option_list as $option)
{
if ($option['value']!=$skip_id)
{
$selected='';
if ($option['value']==$selected_id)
{
$selected=' SELECTED';
}
$retval.='<OPTION
VALUE="'.$option['value'].'"'.$selected.'>'.
$option['display'].'</OPTION>'."\n";
}
}
$retval.='</SELECT>';
return $retval;
}
function _deleteCategory()
{
if (!$this->isadmin)
{
$this->_manageCategories();
return;
}
$GLOBALS['Common_BO']->globalize(array('cat_id','btnDelete','btnCancel'));
global $cat_id,$btnDelete,$btnCancel;
if ($btnDelete)
{
$this->cat_bo->removeCategory($cat_id);
$this->_manageCategories();
return;
}
if ($btnCancel)
{
$this->_manageCategories();
return;
}
$this->common_ui->DisplayHeader();
$cat =
$this->cat_bo->getCategory($cat_id,$this->sitelanguages[0]);
$this->t->set_file('ConfirmDelete','confirmdelete.tpl');
$this->t->set_var('deleteheader',lang('Are you sure you
want to delete the category %1 and all of its associated pages? You cannot
retrieve the deleted pages if you continue.',$cat->name));
$this->t->set_var('cat_id',$cat_id);
$this->t->set_var('lang_yes',lang('Yes, please delete
it'));
$this->t->set_var('lang_no',lang('Cancel the delete'));
$this->t->pfp('out','ConfirmDelete');
$this->common_ui->DisplayFooter();
}
}
?>
--- NEW FILE ---
<?php
class Common_BO
{
var $acl,$theme,$pages,$cats,$content,$modules,$headerfooter;
function Common_BO()
{
$this->acl = CreateObject('sitemgr.ACL_BO',True);
$this->theme = CreateObject('sitemgr.Theme_BO',True);
$this->pages = CreateObject('sitemgr.Pages_BO',True);
$this->cats =
CreateObject('sitemgr.Categories_BO',True);
$this->content =
CreateObject('sitemgr.Content_BO',True);
$this->modules =
CreateObject('sitemgr.Modules_BO',True);
$this->headerfooter =
CreateObject('sitemgr.headerFooter_BO', True);
}
function globalize($varname)
{
if (is_array($varname))
{
foreach($varname as $var)
{
$GLOBALS[$var] = $_POST[$var];
}
}
else
{
$GLOBALS[$varname] = $_POST[$varname];
}
}
function getlangname($lang)
{
$GLOBALS['phpgw']->db->query("select lang_name from
languages where lang_id = '$lang'",__LINE__,__FILE__);
$GLOBALS['phpgw']->db->next_record();
return $GLOBALS['phpgw']->db->f('lang_name');
}
}
?>
--- NEW FILE ---
<?php
require_once(PHPGW_INCLUDE_ROOT . SEP . 'sitemgr' . SEP . 'inc' . SEP .
'class.module.inc.php');
class Content_BO
{
var $so;
function Content_BO()
{
$this->so = CreateObject('sitemgr.Content_SO', true);
$prefs_so = CreateObject('sitemgr.sitePreference_SO',
True);
$sitemgr_dir =
$prefs_so->getPreference('sitemgr-site-dir');
$themesel = $prefs_so->getPreference('themesel');
$this->templatefile = $sitemgr_dir . SEP . 'templates'
. SEP . $themesel . SEP . 'main.tpl';
}
function getContentAreas()
{
$str = implode('', @file($this->templatefile));
preg_match_all("/\{contentarea:([^{
]+)\}/",$str,$matches);
return $matches[1];
}
function addblock($block)
{
$permittedmoduleids =
array_keys($GLOBALS['Common_BO']->modules->getcascadingmodulepermissions($block->area,$block->cat_id));
$module =
$GLOBALS['Common_BO']->modules->getmodule($block->module_id);
if
($GLOBALS['Common_BO']->acl->can_write_category($block->cat_id) &&
in_array($block->module_id,$permittedmoduleids)
&&
$GLOBALS['Common_BO']->modules->createmodule($module['app_name'],$module['module_name']))
{
return $this->so->addblock($block);
}
else
{
return false;
}
}
function removeBlocksInPageOrCat($cat_id,$page_id)
{
$blocks =
$this->so->getblocksforscope($cat_id,$page_id);
while(list($blockid,) = each($blocks))
{
$this->removeblock($blockid);
}
}
function removeblock($blockid)
{
$block = $this->so->getblockdef($blockid);
if
($GLOBALS['Common_BO']->acl->can_write_category($block->cat_id))
{
return $this->so->removeblock($blockid);
}
else
{
return false;
}
}
//the next two functions retrieves all blocks for a certain
area, if cat_id and page_id are 0, only site-wide blocks are retrieved.
//if cat_id is non zero and page_id is 0, site-wide blocks and
all blocks for the category and all its ancestor categories are retrieved.
//if page_id is non zero, cat_id should be the page's category.
Page blocks + category blocks + site blocks are retrieved.
function getvisibleblockdefsforarea($area,$cat_id,$page_id)
{
$cat_ancestorlist = $cat_id ?
$GLOBALS['Common_BO']->cats->getCategoryancestorids($cat_id,True) : False;
if ($page_id &&
!$GLOBALS['Common_BO']->acl->can_read_category($cat_id))
{
$page_id = False;
}
return
$this->so->getvisibleblockdefsforarea($area,$cat_ancestorlist,$page_id,$visibleonly);
}
function getallblocksforarea($area,$cat_id,$page_id,$lang)
{
$cat_ancestorlist = $cat_id ?
$GLOBALS['Common_BO']->cats->getCategoryancestorids($cat_id,True) : False;
if ($page_id &&
!$GLOBALS['Common_BO']->acl->can_read_category($cat_id))
{
$page_id = False;
}
return
$this->so->getallblocksforarea($area,$cat_ancestorlist,$page_id,$lang);
}
function getblock($block_id,$lang)
{
//do we need ACL here, since we have ACL when getting
the block lists, we could do without it here?
return $this->so->getblock($block_id,$lang);
}
function getlangarrayforblock($block_id)
{
return $this->so->getlangarrayforblock($block_id);
}
//this function retrieves blocks only for a certain scope
(site-wide, specific to one category or specific to one page),
//but for all areas.
function getblocksforscope($cat_id,$page_id)
{
if ($cat_id &&
!$GLOBALS['Common_BO']->acl->can_read_category($cat_id))
{
return array();
}
else
{
return
$this->so->getblocksforscope($cat_id,$page_id);
}
}
function getlangblockdata($blockid,$lang)
{
//TODO: add ACL
return $this->so->getlangblockdata($blockid,$lang);
}
function saveblockdata($block,$data,$lang)
{
$oldblock = $this->so->getblockdef($block->id);
if
($GLOBALS['Common_BO']->acl->can_write_category($oldblock->cat_id))
{
$this->so->saveblockdatalang($block,$data['i18n'],$lang);
unset($data['i18n']);
return $this->so->saveblockdata($block,$data);
}
else
{
return false;
}
}
function saveblockdatalang($block,$data,$lang)
{
$oldblock = $this->so->getblockdef($block->id);
if
($GLOBALS['Common_BO']->acl->can_write_category($block->cat_id))
{
return
$this->so->saveblockdatalang($block,$data['i18n'],$lang);
}
else
{
return false;
}
}
function getblockmodule($blockid)
{
$block = $this->so->getblockdef($blockid);
return
$GLOBALS['Common_BO']->modules->createmodule($block->app_name,$block->module_name);
}
}
?>
--- NEW FILE ---
<?php
class Content_SO
{
var $db;
function Content_SO()
{
$this->db = $GLOBALS['phpgw']->db;
}
function addblock($block)
{
if (!$block->cat_id)
{
$block->cat_id = 0;
}
if (!$block->page_id)
{
$block->page__id = 0;
}
$sql = "INSERT INTO phpgw_sitemgr_content
(area,module_id,page_id,cat_id,sort_order,view,actif) VALUES ('" .
$block->area . "'," . $block->module_id . "," .
$block->page_id . "," . $block->cat_id . ",0,0,0)";
return $this->db->query($sql,__LINE__,__FILE__);
}
function removeblock($blockid)
{
$sql = "DELETE FROM phpgw_sitemgr_content WHERE
block_id = $blockid";
if ($this->db->query($sql,__LINE__,__FILE__))
{
$sql = "DELETE FROM phpgw_sitemgr_content_lang
WHERE block_id = $blockid";
return $this->db->query($sql,__LINE__,__FILE__);
}
else
{
return false;
}
}
function getblocksforscope($cat_id,$page_id)
{
$sql = "SELECT
t1.block_id,t1.module_id,app_name,module_name,area FROM phpgw_sitemgr_content
AS t1,phpgw_sitemgr_modules AS t2 WHERE t1.module_id = t2.module_id AND cat_id
= $cat_id AND page_id = $page_id ORDER by sort_order";
$block = CreateObject('sitemgr.Block_SO',True);
$result = array();
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
$id = $this->db->f('block_id');
$block->id = $id;
$block->module_id = $this->db->f('module_id');
$block->app_name = $this->db->f('app_name');
$block->module_name =
$this->db->f('module_name');
$block->area = $this->db->f('area');
$result[$id] = $block;
}
return $result;
}
function getallblocksforarea($area,$cat_list,$page_id,$lang)
{
$sql = "SELECT
t1.block_id,area,cat_id,page_id,t1.module_id,app_name,module_name,arguments,arguments_lang,sort_order,title,view,actif
FROM phpgw_sitemgr_content AS t1,phpgw_sitemgr_modules AS t2 LEFT JOIN
phpgw_sitemgr_content_lang as t3 ON (t1.block_id=t3.block_id AND lang='$lang')
WHERE t1.module_id = t2.module_id AND area = '$area' AND ((page_id = 0 and
cat_id = 0)";
if ($cat_list)
{
$sql .= " OR (page_id = 0 AND cat_id IN (" .
implode(',',$cat_list) . "))";
}
if ($page_id)
{
$sql .= " OR (page_id = $page_id) ";
}
$sql .= ") ORDER by sort_order";
$block = CreateObject('sitemgr.Block_SO',True);
$result = array();
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
$id = $this->db->f('block_id');
$block->id = $id;
$block->area = $this->db->f('area');
$block->cat_id = $this->db->f('cat_id');
$block->page_id = $this->db->f('page_id');
$block->module_id = $this->db->f('module_id');
$block->app_name = $this->db->f('app_name');
$block->module_name =
$this->db->f('module_name');
$block->arguments = array_merge(
unserialize(stripslashes($this->db->f('arguments'))),
unserialize(stripslashes($this->db->f('arguments_lang')))
);
$block->sort_order = $this->db->f('sort_order');
$block->title =
stripslashes($this->db->f('title'));
$block->view = $this->db->f('view');
$block->actif = $this->db->f('actif');
$result[$id] = $block;
}
return $result;
}
function getvisibleblockdefsforarea($area,$cat_list,$page_id)
{
$sql = "SELECT
t1.block_id,area,cat_id,page_id,t1.module_id,app_name,module_name,view FROM
phpgw_sitemgr_content AS t1,phpgw_sitemgr_modules AS t2 WHERE t1.module_id =
t2.module_id AND area = '$area' AND ((page_id = 0 and cat_id = 0)";
if ($cat_list)
{
$sql .= " OR (page_id = 0 AND cat_id IN (" .
implode(',',$cat_list) . "))";
}
if ($page_id)
{
$sql .= " OR (page_id = $page_id) ";
}
$sql .= ") AND actif = 1 ORDER by sort_order";
$block = CreateObject('sitemgr.Block_SO',True);
$result = array();
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
$id = $this->db->f('block_id');
$block->id = $id;
$block->area = $this->db->f('area');
$block->cat_id = $this->db->f('cat_id');
$block->page_id = $this->db->f('page_id');
$block->module_id = $this->db->f('module_id');
$block->app_name = $this->db->f('app_name');
$block->module_name =
$this->db->f('module_name');
$block->view = $this->db->f('view');
$result[$id] = $block;
}
return $result;
}
function getlangarrayforblock($block_id)
{
$retval = array();
$this->db->query("SELECT lang FROM
phpgw_sitemgr_content_lang WHERE block_id = $block_id",__LINE__,__FILE__);
while ($this->db->next_record())
{
$retval[] = $this->db->f('lang');
}
return $retval;
}
function getlangblockdata($blockid,$lang)
{
$sql = "SELECT title, arguments, arguments_lang FROM
phpgw_sitemgr_content AS t1 LEFT JOIN phpgw_sitemgr_content_lang AS t2 ON
(t1.block_id=t2.block_id AND lang='$lang') WHERE t1.block_id = $blockid";
$this->db->query($sql,__LINE__,__FILE__);
if ($this->db->next_record())
{
$block = CreateObject('sitemgr.Block_SO',True);
$block->arguments = array_merge(
unserialize(stripslashes($this->db->f('arguments'))),
unserialize(stripslashes($this->db->f('arguments_lang')))
);
$block->title =
stripslashes($this->db->f('title'));
return $block;
}
else
{
return false;
}
}
function getblock($block_id,$lang)
{
$sql = "SELECT
t1.block_id,cat_id,page_id,area,t1.module_id,app_name,module_name,arguments,arguments_lang,sort_order,title,view,actif
FROM phpgw_sitemgr_content AS t1,phpgw_sitemgr_modules AS t2 LEFT JOIN
phpgw_sitemgr_content_lang as t3 ON (t1.block_id=t3.block_id AND lang='$lang')
WHERE t1.module_id = t2.module_id AND t1.block_id = $block_id";
$this->db->query($sql,__LINE__,__FILE__);
if ($this->db->next_record())
{
$block = CreateObject('sitemgr.Block_SO',True);
$block->id = $block_id;
$block->cat_id = $this->db->f('cat_id');
$block->page_id = $this->db->f('page_id');
$block->area = $this->db->f('area');
$block->module_id = $this->db->f('module_id');
$block->app_name = $this->db->f('app_name');
$block->module_name =
$this->db->f('module_name');
$block->arguments = array_merge(
unserialize(stripslashes($this->db->f('arguments'))),
unserialize(stripslashes($this->db->f('arguments_lang')))
);
$block->sort_order = $this->db->f('sort_order');
$block->title =
stripslashes($this->db->f('title'));
$block->view = $this->db->f('view');
$block->actif = $this->db->f('actif');
return $block;
}
else
{
return false;
}
}
//this function only retrieves basic info for the block
function getblockdef($block_id)
{
$sql = "SELECT
cat_id,page_id,area,t1.module_id,app_name,module_name FROM
phpgw_sitemgr_content AS t1,phpgw_sitemgr_modules AS t2 WHERE t1.module_id =
t2.module_id AND t1.block_id = $block_id";
$this->db->query($sql,__LINE__,__FILE__);
if ($this->db->next_record())
{
$block = CreateObject('sitemgr.Block_SO',True);
$block->id = $block_id;
$block->cat_id = $this->db->f('cat_id');
$block->page_id = $this->db->f('page_id');
$block->area = $this->db->f('area');
$block->module_id = $this->db->f('module_id');
$block->app_name = $this->db->f('app_name');
$block->module_name =
$this->db->f('module_name');
return $block;
}
else
{
return false;
}
}
function saveblockdata($block,$data)
{
//this is necessary because double slashed data breaks
while serialized
$this->remove_magic_quotes($data);
$s = addslashes(serialize($data));
$sql = "UPDATE phpgw_sitemgr_content SET arguments =
'$s', sort_order = " . (int)$block->sort_order .
", view = " . $block->view . ", actif = " .
$block->actif . " WHERE block_id = " . $block->id;
return $this->db->query($sql,__LINE__,__FILE__);
}
function saveblockdatalang($block,$data,$lang)
{
//this is necessary because double slashed data breaks
while serialized
$this->remove_magic_quotes($data);
$s = addslashes(serialize($data));
$title = addslashes($block->title);
$blockid = $block->id;
$sql = "DELETE FROM phpgw_sitemgr_content_lang WHERE
block_id = $blockid AND lang = '$lang'";
$this->db->query($sql,__LINE__,__FILE__);
$sql = "INSERT INTO phpgw_sitemgr_content_lang
(block_id,lang,arguments_lang,title) VALUES ($blockid,'$lang','$s','$title')";
return $this->db->query($sql,__LINE__,__FILE__);
}
function remove_magic_quotes(&$data)
{
if (is_array($data))
{
reset($data);
while (list($key,$val) = each($data))
{
$this->remove_magic_quotes($data[$key]);
}
}
elseif (get_magic_quotes_gpc())
{
$data = stripslashes($data);
}
}
}
--- NEW FILE ---
<?php
class Content_UI
{
var $common_ui;
var $t;
var $bo;
var $modulebo;
var $acl;
var $viewable;
var $sitelanguages;
var $worklanguage;
var $errormsg;
var $public_functions = array
(
'_manageContent' => True
);
function Content_UI()
{
$this->common_ui =
CreateObject('sitemgr.Common_UI',True);
$this->t = $GLOBALS["phpgw"]->template;
$this->bo = &$GLOBALS['Common_BO']->content;
$this->acl = &$GLOBALS['Common_BO']->acl;
$this->modulebo = &$GLOBALS['Common_BO']->modules;
$this->viewable = array(
'0' => 'everybody',
'1' => 'phpgw users',
'2' => 'administrators',
'3' => 'anonymous'
);
$preferenceso =
CreateObject('sitemgr.sitePreference_SO', true);
$this->sitelanguages =
explode(',',$preferenceso->getPreference('sitelanguages'));
$sessionlang =
$GLOBALS['phpgw']->session->appsession('worklanguage','sitemgr');
$this->worklanguage = $sessionlang ? $sessionlang :
$this->sitelanguages[0];
$this->errormsg = array();
}
function _manageContent()
{
$this->common_ui->DisplayHeader();
$GLOBALS['Common_BO']->globalize(array('blockid','blocktitle','blocksort','blockview','blockactif','btnSaveBlock','btnDeleteBlock','module_id','area','btnAddBlock','element','savelanguage'));
global $blockid, $blocktitle,
$blocksort,$blockview,$blockactif,$btnSaveBlock,$btnDeleteBlock, $module_id,
$area, $btnAddBlock, $element, $savelanguage;
$page_id = $_GET['page_id'];
$cat_id = $_GET['cat_id'];
$scopename = $page_id ? lang('Page') : ($cat_id ?
lang('Category') : lang('Site'));
if ($page_id)
{
$page =
$GLOBALS['Common_BO']->pages->getPage($page_id);
$page_or_cat_name = $page->name;
$cat_id = $page->cat_id;
$managelink =
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Pages_UI._managePage');
$goto = lang('Page manager');
$scopename = lang('Page');
}
elseif ($cat_id)
{
$cat =
$GLOBALS['Common_BO']->cats->getCategory($cat_id);
$page_or_cat_name = $cat->name;
$page_id = 0;
$managelink =
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Categories_UI._manageCategories');
$goto = lang('Category manager');
$scopename = lang('Category');
}
else
{
$cat_id = 0;
$page_id = 0;
}
$this->t->set_file('Managecontent',
'manage_content.tpl');
$this->t->set_block('Managecontent','Contentarea','CBlock');
$this->t->set_block('Contentarea','Module','MBlock');
$this->t->set_block('Module','Moduleeditor','MeBlock');
$this->t->set_block('Module','Moduleview','MvBlock');
$this->t->set_block('Moduleeditor','EditorElement','EeBlock');
$this->t->set_block('Moduleview','ViewElement','VeBlock');
$this->t->set_var(Array(
'lang_reset' => lang('Reset'),
'lang_save' => lang('Save'),
'content_manager' => lang('%1 content manager',
$scopename),
'page_or_cat_name' => ($page_or_cat_name ? (' -
' . $page_or_cat_name) : ''),
'managelink' => ($managelink ? ('<a href="' .
$managelink . '">< ' . lang('Go to') . ' ' . $goto . ' ></a>') : '')
));
if ($btnAddBlock)
{
if ($module_id)
{
$block =
CreateObject('sitemgr.Block_SO',True);
$block->module_id = $module_id;
$block->area = $area;
$block->page_id = $page_id;
$block->cat_id = $cat_id;
if (!$this->bo->addblock($block))
{
$this->errormsg[] = lang("You
are not entitled to create module %1 on this scope",$module_id);
}
}
else
{
$this->errormsg[] = lang("You did not
choose a module.");
}
}
elseif ($btnSaveBlock)
{
$moduleobject =
$this->bo->getblockmodule($blockid);
if ($moduleobject->validate($element))
{
if ($savelanguage)
{
//we save the language the user
chooses as session variable
$this->worklanguage =
$savelanguage;
$GLOBALS['phpgw']->session->appsession('worklanguage','sitemgr',$savelanguage);
}
$block =
CreateObject('sitemgr.Block_SO',True);
$block->id = $blockid;
$block->title = $blocktitle;
$block->sort_order = $blocksort;
$block->view = $blockview;
$block->actif = $blockactif ? 1 : 0;
if
(!$this->bo->saveblockdata($block,$element,$this->worklanguage))
{
$this->errormsg[] = lang("You
are not entitled to edit block %1",$blockid);
}
}
if ($moduleobject->validation_error)
{
$this->errormsg[] =
$moduleobject->validation_error;
}
}
elseif ($btnDeleteBlock)
{
if (!$this->bo->removeblock($blockid))
{
$this->errormsg[] = lang("You are not
entitled to edit block %1",$blockid);
}
}
$contentareas = $this->bo->getContentAreas();
if ($contentareas)
{
$this->t->set_var('help', lang('You can
override each content blocks default title. Be aware that not in all content
areas the block title will be visible.'));
foreach ($contentareas as $contentarea)
{
$permittedmodules =
$this->modulebo->getcascadingmodulepermissions($contentarea,$cat_id);
$this->t->set_var(Array(
'area' => $contentarea,
'addblockform' =>
($permittedmodules ?
('<form
method="POST"><input type="hidden" value="' . $contentarea . '" name="area" />'
.
'<select style="vertical-align:middle" size="10" name="module_id">' .
$this->inputmoduleselect($permittedmodules) .
'</select><input type="submit" name="btnAddBlock" value="' .
lang('Add block to content area') .
'"
/></form>') :
lang('No
modules permitted for this content area/category')
),
'error' => ($contentarea ==
$area && $this->errormsg) ? join('<br>',$this->errormsg) : '',
));
//we get all blocks for the page and
its category, and site wide,
//but only the current scope is editable
//if we have just edited a block in a
certain language, we request all blocks in this language
$blocks =
$this->bo->getallblocksforarea($contentarea,$cat_id,$page_id,$this->worklanguage);
$this->t->set_var('MBlock','');
if ($blocks)
{
if (count($this->sitelanguages)
> 1)
{
$select = lang('as') .
' <select name="savelanguage">';
foreach
($this->sitelanguages as $lang)
{
$selected= '';
if ($lang ==
$this->worklanguage)
{
$selected = 'selected="selected" ';
}
$select
.= '<option ' . $selected .'value="' . $lang . '">'.
$GLOBALS['Common_BO']->getlangname($lang) . '</option>';
}
$select .=
'</select> ';
$this->t->set_var('savelang',$select);
}
while (list($id,$block) =
each($blocks))
{
//TODO: wrap a module
storage around createmodule as in template3,
//TODO: so that we do
not create the same module object twice
$moduleobject =
$this->modulebo->createmodule($block->app_name,$block->module_name);
$this->t->set_var(array(
'moduleinfo' =>
($block->app_name.'.'.$block->module_name),
'description'
=> $moduleobject->description,
));
//if the block is in
our scope and we are entitled we edit it
if ($block->page_id ==
$page_id &&
$block->cat_id
== $cat_id)
{
$editorstandardelements = array(
array('label' => lang('Title'),
'form' => ('<input type="text" name="blocktitle" value="' .
($block->title ? $block->title : $moduleobject->title) . '" />')
),
array('label' => lang('Actif'),
'form' => ('<input type="checkbox" name="blockactif"' .
($block->actif ? 'checked="checked"' : '') . '">')
),
array('label' => lang('Seen by'),
'form' => ('<select name="blockview">' .
$this->inputviewselect((int)$block->view) . '</select>')
),
array('label' => lang('Sort order'),
'form' => ('<input type="text" name="blocksort" size="2" value="' .
(int)$block->sort_order . '">')
)
);
$moduleobject->set_block($block);
$editormoduleelements = $moduleobject->get_user_interface();
$interface =
array_merge($editorstandardelements,$editormoduleelements);
$this->t->set_var(Array(
'blockid' => $id,
'savebutton' => '<input type="submit" value="Save" name="btnSaveBlock" />',
'deletebutton' => '<input type="submit" value="Delete" name="btnDeleteBlock"
/>',
'validationerror' => ($id == $blockid && $this->errormsg) ?
join('<br>',$this->errormsg) : '',
));
$this->t->set_var('EeBlock','');
while
(list(,$element) = each($interface))
{
$this->t->set_var(Array(
'label' => $element['label'],
'form' => $element['form']
));
$this->t->parse('EeBlock','EditorElement', true);
}
$this->t->parse('MeBlock','Moduleeditor');
$this->t->set_var('MvBlock','');
}
//otherwise we only
show it
else
{
if
($block->page_id)
{
$blockscope = lang('Page');
}
elseif
($block->cat_id)
{
$cat =
$GLOBALS['Common_BO']->cats->getCategory($block->cat_id);
$blockscope = lang('Category') . ' - ' . $cat->name;
}
else
{
$blockscope = lang('Site');
}
$viewstandardelements = array(
array('label' => lang('Scope'),
'value' => $blockscope
),
array('label' => lang('Title'),
'value' => ($block->title ? $block->title : $moduleobject->title)
),
array('label' => lang('Actif'),
'value' => ($block->actif ? lang('Yes') : lang('No'))
),
array('label' => lang('Seen by'),
'value' => $this->viewable[(int)$block->view]
),
array('label' => lang('Sort order'),
'value' => (int)$block->sort_order
)
);
$viewmoduleelements = array();
while
(list($argument,$argdef) = @each($moduleobject->arguments))
{
$value
= $block->arguments[$argument];
$viewmoduleelements[] = array(
'label' => $argdef['label'],
'value' => $GLOBALS['phpgw']->strip_html($value)
);
}
$interface =
array_merge($viewstandardelements,$viewmoduleelements);
$this->t->set_var('VeBlock','');
while
(list(,$element) = each($interface))
{
$this->t->set_var(Array(
'label' => $element['label'],
'value' => $element['value'])
);
$this->t->parse('VeBlock','ViewElement', true);
}
$this->t->parse('MvBlock','Moduleview');
$this->t->set_var('MeBlock','');
}
$this->t->parse('MBlock','Module', true);
}
}
$this->t->parse('CBlock','Contentarea',
true);
}
}
else
{
$this->t->set_var('CBlock',lang('No content
areas found in selected template'));
}
$this->t->pfp('out', 'Managecontent');
$this->common_ui->DisplayFooter();
}
function inputmoduleselect($modules)
{
$returnValue = '';
while (list($id,$module) = each($modules))
{
$returnValue.='<option title="' .
$module['description'] . '" value="'.$id.'">'.
$module['app_name'].'.'.
$module['module_name'].'</option>'."\n";
}
return $returnValue;
}
function inputviewselect($default)
{
$returnValue = '';
foreach($this->viewable as $value => $display)
{
$selected = ($default == $value) ? $selected =
'selected="selected" ' : '';
$returnValue.='<option
'.$selected.'value="'.$value.'">'.
$display.'</option>'."\n";
}
return $returnValue;
}
}
--- NEW FILE ---
<?php
require_once(PHPGW_INCLUDE_ROOT . SEP . 'sitemgr' . SEP . 'inc' . SEP .
'class.module.inc.php');
class Modules_BO
{
var $so;
function Modules_BO()
{
//all sitemgr BOs should be instantiated via a
globalized Common_BO object,
$this->so = CreateObject('sitemgr.Modules_SO', true);
}
function getmoduleid($appname,$modulename)
{
return $this->so->getmoduleid($appname,$modulename);
}
function getmodule($module_id)
{
return $this->so->getmodule($module_id);
}
function
savemoduleproperties($module_id,$element,$contentarea,$cat_id)
{
$this->so->savemoduleproperties($module_id,$element,$contentarea,$cat_id);
}
function deletemoduleproperties($module_id,$contentarea,$cat_id)
{
$this->so->deletemoduleproperties($module_id,$contentarea,$cat_id);
}
function createmodule($appname,$modulename)
{
$class = $appname . '.module_' . $modulename;
return CreateObject($class);
}
function getallmodules()
{
return $this->so->getallmodules();
}
function findmodules()
{
$appbo = CreateObject('admin.boapplications');
$app_list = $appbo->get_list();
while(list($app_name,$app) = each($app_list))
{
$incdir = PHPGW_SERVER_ROOT . SEP . $app_name .
SEP . 'inc';
if (is_dir($incdir))
{
$d = dir(PHPGW_SERVER_ROOT . SEP .
$app_name . SEP . 'inc');
while ($entry = $d->read())
{
if (preg_match
("/class\.module_(.*)\.inc\.php$/", $entry, $module))
{
$modulename =
$module[1];
$moduleobject =
$this->createmodule($app_name,$modulename);
if ($moduleobject)
{
$this->so->registermodule($app_name,$modulename,$moduleobject->description);
}
}
}
$d->close();
}
}
}
function savemodulepermissions($contentarea,$cat_id,$modules)
{
$this->so->savemodulepermissions($contentarea,$cat_id,$modules);
}
//this function looks for a configured value for the
combination contentareara,cat_id
function getpermittedmodules($contentarea,$cat_id)
{
return
$this->so->getpermittedmodules($contentarea,$cat_id);
}
//this function looks for a module's configured propertiese for
the combination contentareara,cat_id
//if module_id is 0 the fourth and fith argument should provide
appname and modulename
function
getmoduleproperties($module_id,$contentarea,$cat_id,$appname=False,$modulename=False)
{
return
$this->so->getmoduleproperties($module_id,$contentarea,$cat_id,$appname,$modulename);
}
//this function calculates the permitted modules by asking
first for a value contentarea/cat_id
//if it does not find one, climbing up the category hierarchy
until the site wide value for the same contentarea
//and if it still does not find a value, looking for
__PAGE__/cat_id, and again climbing up until the master list
function getcascadingmodulepermissions($contentarea,$cat_id)
{
$cat_ancestorlist =
$GLOBALS['Common_BO']->cats->getCategoryancestorids($cat_id);
$cat_ancestorlist[] = 0;
$cat_ancestorlist_temp = $cat_ancestorlist;
do
{
$cat_id = array_shift($cat_ancestorlist_temp);
while($cat_id !== NULL)
{
$permitted =
$this->so->getpermittedmodules($contentarea,$cat_id);
if ($permitted)
{
return $permitted;
}
$cat_id =
array_shift($cat_ancestorlist_temp);
}
$contentarea = ($contentarea != "__PAGE__") ?
"__PAGE__" : False;
$cat_ancestorlist_temp = $cat_ancestorlist;
} while($contentarea);
return array();
}
//this function calculates the properties by climbing up the
hierarchy tree in the same way as
//getcascadingmodulepermissions does
function
getcascadingmoduleproperties($module_id,$contentarea,$cat_id,$appname=False,$modulename=False)
{
$cat_ancestorlist =
$GLOBALS['Common_BO']->cats->getCategoryancestorids($cat_id);
$cat_ancestorlist[] = 0;
$cat_ancestorlist_temp = $cat_ancestorlist;
do
{
$cat_id = array_shift($cat_ancestorlist_temp);
while($cat_id !== NULL)
{
$properties =
$this->so->getmoduleproperties($module_id,$contentarea,$cat_id,$appname,$modulename);
//we have to check for type identity
since properties can be NULL in case of unchecked checkbox
if ($properties !== false)
{
return $properties;
}
$cat_id =
array_shift($cat_ancestorlist_temp);
}
$contentarea = ($contentarea != "__PAGE__") ?
"__PAGE__" : False;
$cat_ancestorlist_temp = $cat_ancestorlist;
} while($contentarea);
}
}
--- NEW FILE ---
<?php
class Modules_SO
{
var $db;
function Modules_SO()
{
$this->db = $GLOBALS['phpgw']->db;
}
function
savemoduleproperties($module_id,$data,$contentarea,$cat_id)
{
$this->deletemoduleproperties($module_id,$contentarea,$cat_id);
$s = addslashes(serialize($data));
$sql = "INSERT INTO phpgw_sitemgr_properties
(area,cat_id,module_id,properties) VALUES
('$contentarea',$cat_id,'$module_id','$s')";
$this->db->query($sql,__LINE__,__FILE__);
}
function deletemoduleproperties($module_id,$contentarea,$cat_id)
{
$sql = "DELETE FROM phpgw_sitemgr_properties WHERE
area='$contentarea' AND cat_id = $cat_id AND module_id = $module_id";
$this->db->query($sql,__LINE__,__FILE__);
}
function
getmoduleproperties($module_id,$contentarea,$cat_id,$appname,$modulename)
{
if ($module_id)
{
$sql = "SELECT properties FROM
phpgw_sitemgr_properties WHERE area='$contentarea' AND cat_id = $cat_id AND
module_id = $module_id";
}
else
{
"SELECT properties FROM
phpgw_sitemgr_properties AS t1 LEFT JOIN phpgw_sitemgr_modules AS t2 ON
t1.module_id=t2.module_id WHERE area='$contentarea' AND cat_id = $cat_id AND
app_name = '$appname' and module_name = '$modulename'";
}
$this->db->query($sql,__LINE__,__FILE__);
if ($this->db->next_record())
{
return
unserialize(stripslashes($this->db->f('properties')));
}
else
{
return false;
}
}
function registermodule($app_name,$modulename,$description)
{
$description = addslashes($description);
$sql = "SELECT count(*) FROM phpgw_sitemgr_modules
where app_name='$app_name' AND module_name='$modulename'";
$this->db->query($sql,__LINE__,__FILE__);
$this->db->next_record();
if ($this->db->f(0) == 0)
{
$sql = "INSERT INTO phpgw_sitemgr_modules
(app_name,module_name,description) VALUES
('$app_name','$modulename','$description')";
$this->db->query($sql,__LINE__,__FILE__);
}
else
{
$sql = "UPDATE phpgw_sitemgr_modules SET
description = '$description' WHERE app_name='$app_name' AND
module_name='$modulename'";
$this->db->query($sql,__LINE__,__FILE__);
}
}
function getallmodules()
{
$sql = "SELECT * FROM phpgw_sitemgr_modules";
return $this->constructmodulearray($sql);
}
function getmoduleid($appname,$modulename)
{
$sql = "SELECT module_id FROM phpgw_sitemgr_modules
WHERE app_name = '$appname' AND module_name = '$modulename'";
$this->db->query($sql,__LINE__,__FILE__);
if ($this->db->next_record())
{
return $this->db->f('module_id');
}
}
function getmodule($module_id)
{
$sql = "SELECT * FROM phpgw_sitemgr_modules WHERE
module_id = $module_id";
$this->db->query($sql,__LINE__,__FILE__);
if ($this->db->next_record())
{
$result['id'] = $this->db->f('module_id');
$result['module_name'] =
$this->db->f('module_name');
$result['app_name'] = $this->db->f('app_name');
$result['description'] =
stripslashes($this->db->f('description'));
}
return $result;
}
function constructmodulearray($sql)
{
$result = array();
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
$id = $this->db->f('module_id');
$result[$id]['module_name'] =
$this->db->f('module_name');
$result[$id]['app_name'] =
$this->db->f('app_name');
$result[$id]['description'] =
stripslashes($this->db->f('description'));
}
return $result;
}
function savemodulepermissions($contentarea,$cat_id,$modules)
{
if (!$cat_id)
{
$cat_id = 0;
}
$sql = "DELETE FROM phpgw_sitemgr_active_modules WHERE
area='$contentarea' AND cat_id = $cat_id";
$this->db->query($sql,__LINE__,__FILE__);
while (list(,$module_id) = @each($modules))
{
$sql = "INSERT INTO
phpgw_sitemgr_active_modules (area,cat_id,module_id) VALUES
('$contentarea',$cat_id,'$module_id')";
$this->db->query($sql,__LINE__,__FILE__);
}
}
function getpermittedmodules($contentarea,$cat_id)
{
if (!$cat_id)
{
$cat_id = 0;
}
$sql = "SELECT * from phpgw_sitemgr_modules AS t1 LEFT
JOIN phpgw_sitemgr_active_modules AS t2 ON t1.module_id=t2.module_id WHERE
area='$contentarea' AND cat_id = $cat_id";
return $this->constructmodulearray($sql);
}
}
--- NEW FILE ---
<?php
class Modules_UI
{
var $common_ui;
var $t;
var $bo;
var $acl;
var $modules;
var $errormsg;
var $public_functions = array
(
'_manageModules' => True,
'findmodules' => True,
'_configureModule' => True
);
function Modules_UI()
{
$this->common_ui =
CreateObject('sitemgr.Common_UI',True);
$this->t = $GLOBALS['phpgw']->template;
$this->bo = &$GLOBALS['Common_BO']->modules;
$this->acl = &$GLOBALS['Common_BO']->acl;
}
function _manageModules()
{
$this->common_ui->DisplayHeader();
if ($this->acl->is_admin())
{
$GLOBALS['Common_BO']->globalize(array('btnselect','inputmodules','inputarea'));
global $btnselect,$inputmodules,$inputarea;
$cat_id = $_GET['cat_id'];
$scopename = lang(($cat_id) ? 'Category' :
'Site');
$this->modules = $this->bo->getallmodules();
if ($cat_id)
{
$catbo =
CreateObject('sitemgr.Categories_BO');
$cat =
$catbo->getCategory($cat_id);
$cat_name = $cat->name;
$managelink =
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Categories_UI._manageCategories');
$goto = lang('Category
manager');
}
$this->t->set_file('Managemodules',
'manage_modules.tpl');
$this->t->set_block('Managemodules','Contentarea','CBlock');
$this->t->set_var(array(
'module_manager' => lang('Module
manager'),
'help' => 'You can choose the modules
that can be used on the site. The first list is a sort of master list, that is
consulted if you do not configure lists specific to contentareas or
(sub)categories. Then you can choose lists specific to each content area. In
the category manager these lists can be overriden for each (sub)category.',
'lang_findmodules' => lang('Register
new modules'),
'cat_name' => ($cat_name ? (' - ' .
$cat_name) : ''),
'managelink' => ($managelink ? ('<a
href="' . $managelink . '">< ' . lang('Go to') . ' ' . $goto . ' ></a>')
: '')
));
$link_data['cat_id'] = $cat_id;
$link_data['menuaction'] =
"sitemgr.Modules_UI.findmodules";
$this->t->set_var('findmodules',
$GLOBALS['phpgw']->link('/index.php',$link_data));
$link_data['menuaction'] =
"sitemgr.Modules_UI._configureModule";
$this->t->set_var('configureurl',
$GLOBALS['phpgw']->link('/index.php',$link_data));
$contentareas =
$GLOBALS['Common_BO']->content->getContentAreas();
array_unshift($contentareas,'__PAGE__');
if ($btnselect)
{
$this->bo->savemodulepermissions($inputarea,$cat_id,$inputmodules);
}
foreach ($contentareas as $contentarea)
{
$permittedmodulesconfigured =
$this->bo->getpermittedmodules($contentarea,$cat_id);
$permittedmodulescascading =
$this->bo->getcascadingmodulepermissions($contentarea,$cat_id);
$this->t->set_var(Array(
'title' => ($contentarea ==
'__PAGE__') ?
lang('Master list of
permitted modules') :
lang('List of permitted
modules specific to content area %1',$contentarea),
'contentarea' => $contentarea,
'selectmodules' =>
$this->inputmoduleselect(array_keys($permittedmodulesconfigured)),
'configuremodules' =>
$this->inputmoduleconfigure($permittedmodulescascading),
'error' => ($contentarea ==
$inputarea && $this->errormsg) ? $this->errormsg : '',
));
$this->t->parse('CBlock','Contentarea',
true);
}
$this->t->pfp('out', 'Managemodules');
}
else
{
echo lang("You must be an admin to manage
module properties.") ."<br><br>";
}
$this->common_ui->DisplayFooter();
}
function findmodules()
{
$this->bo->findmodules();
$this->_manageModules();
}
function _configureModule()
{
if ($this->acl->is_admin())
{
$GLOBALS['Common_BO']->globalize(array('btnSaveProperties','btnDeleteProperties','inputmodule_id','inputarea','element'));
global
$btnSaveProperties,$btnDeleteProperties,$inputarea,$inputmodule_id,$element;
if (!$inputmodule_id)
{
$this->errormsg = lang("You did not
choose a module.");
$this->_manageModules();
return;
}
$cat_id = $_GET['cat_id'];
$scopename = lang(($cat_id) ? 'Category' :
'Site');
if ($btnSaveProperties)
{
$this->bo->savemoduleproperties($inputmodule_id,$element,$inputarea,$cat_id);
$this->_manageModules();
return;
}
elseif ($btnDeleteProperties)
{
$this->bo->deletemoduleproperties($inputmodule_id,$inputarea,$cat_id);
$this->_manageModules();
return;
}
$this->common_ui->DisplayHeader();
if ($cat_id)
{
$catbo =
CreateObject('sitemgr.Categories_BO');
$cat =
$catbo->getCategory($cat_id);
$cat_name = $cat->name;
}
$this->t->set_file('Editproperties',
'edit_properties.tpl');
$this->t->set_block('Editproperties','EditorElement','EBlock');
$module = $this->bo->getmodule($inputmodule_id);
$moduleobject =
$this->bo->createmodule($module['app_name'],$module['module_name']);
$blockcontext =
CreateObject('sitemgr.Block_SO',True);
$blockcontext->module_id = $inputmodule_id;
$blockcontext->area = $inputarea;
$blockcontext->cat_id = $cat_id;
$moduleobject->set_block($blockcontext);
$editorstandardelements = array(
array('label' => lang('Title'),
'form' => $moduleobject->title
)
);
$editormoduleelements =
$moduleobject->properties ? $moduleobject->get_admin_interface() : False;
$interface =
array_merge($editorstandardelements,$editormoduleelements);
while (list(,$element) = each($interface))
{
$this->t->set_var(Array(
'label' => $element['label'],
'form' => $element['form'])
);
$this->t->parse('EBlock','EditorElement', true);
}
$this->t->set_var(Array(
'module_edit' => lang(
'Edit properties of module %1
for %2 with scope %3',
$module['app_name'].'.'.$module['module_name'],
($inputarea == '__PAGE__' ?
'the whole page' : ('Contentarea ' . $inputarea)),
($cat_id ? ('category ' .
$cat_name) : ' the whole site')
),
'module_id' => $inputmodule_id,
'contentarea' => $inputarea,
'savebutton' => ($editormoduleelements
?
'<input type="submit"
value="Save" name="btnSaveProperties" />' :
lang('There are no properties
defined for this module')
),
'deletebutton' => $properties === False
? '' : '<input type="submit" value="Delete" name="btnDeleteProperties" />'
)
);
$link_data['cat_id'] = $cat_id;
$link_data['menuaction'] =
"sitemgr.Modules_UI._manageModules";
$this->t->set_var('backlink',
'<a href="' .
$GLOBALS['phpgw']->link('/index.php',$link_data) .
'">< ' . lang('Back to module
manager') . ' ></a>'
);
$this->t->pfp('out', 'Editproperties');
}
else
{
$this->common_ui->DisplayHeader();
echo lang("You must be an admin to manage
module properties.") ."<br><br>";
}
$this->common_ui->DisplayFooter();
}
function inputmoduleselect($permitted)
{
$returnValue = '';
reset($this->modules);
while (list($id,$module) = @each($this->modules))
{
$selected = (in_array($id,$permitted)) ?
$selected = 'selected="selected" ' : '';
$returnValue.='<option title="' .
$module['description'] . '" ' . $selected . 'value="' .$id . '">' .
$module['app_name'].'.'.
$module['module_name'].'</option>'."\n";
}
return $returnValue;
}
function inputmoduleconfigure($permitted)
{
$returnValue = '';
while (list($id,$module) = @each($permitted))
{
$returnValue.='<option title="' .
$module['description'] . '" value="'.$id.'">'.
$module['app_name'].'.'.
$module['module_name'].'</option>'."\n";
}
return $returnValue;
}
}
***** Error reading new file: [Errno 2] No such file or directory:
'class.Pages_UI.inc.php'
--- NEW FILE ---
<?php
class SiteContent_UI
{
var $t;
var $headerfooterbo;
var $acl;
var $prefs_so;
var $public_functions = array
(
'_editHeaderAndFooter' => True,
);
function SiteContent_UI()
{
$this->common_ui =
CreateObject('sitemgr.Common_UI',True);
$this->t = $GLOBALS["phpgw"]->template;
$this->headerfooterbo =
&$GLOBALS['Common_BO']->headerfooter;
$this->acl = &$GLOBALS['Common_BO']->acl;
$this->prefs_so =
CreateObject('sitemgr.sitePreference_SO', True);
$this->sitelanguages =
explode(',',$this->prefs_so->getPreference('sitelanguages'));
}
function _editHeaderAndFooter()
{
$GLOBALS['Common_BO']->globalize(array('btnSave','header','footer'));
global $btnSave;
global $header;
global $footer;
$this->common_ui->DisplayHeader();
if ($this->acl->is_admin())
{
$this->t->set_file('EditHeaderAndFooter',
'site_format_manager.tpl');
$this->t->set_block('EditHeaderAndFooter','Header_Editor','HBlock');
$this->t->set_block('EditHeaderAndFooter','Footer_Editor','FBlock');
if ($btnSave)
{
foreach ($this->sitelanguages as $lang)
{
$this->headerfooterbo->SetSiteHeader($header[$lang],$lang);
$this->headerfooterbo->SetSiteFooter($footer[$lang],$lang);
}
$this->t->set_var('message','<b>'
.lang('Saved') . '</b>. <a
href="'.$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.MainMenu_UI.DisplayMenu').'">'
. lang('Return to main menu.') . '</a><br>');
//$this->headerfooterbo->SetTheme($this->theme);
}
$this->t->set_var(array
(
'site_format_manager' => lang('Site
Format Manager'),
'lang_reset' => lang('Reset'),
'lang_save' => lang('Save')
));
foreach ($this->sitelanguages as $lang)
{
$this->t->set_var(array('header_editor' =>
lang('Header Editor') . ' - ' . $GLOBALS['Common_BO']->getlangname($lang),
'footer_editor' =>
lang('Footer Editor') . ' - ' . $GLOBALS['Common_BO']->getlangname($lang),
'header' =>
$this->headerfooterbo->getSiteHeader($lang),
'footer' =>
$this->headerfooterbo->getSiteFooter($lang),
'textarea_header'
=> 'header[' . $lang . ']',
'textarea_footer'
=> 'footer[' . $lang . ']'));
$this->t->parse('HBlock','Header_Editor',True);
$this->t->parse('FBlock','Footer_Editor',True);
}
if ($btnReset)
{
$btnReset = false;
}
$this->t->set_var('actionurl',
$GLOBALS['phpgw']->link('/index.php',
'menuaction=sitemgr.SiteContent_UI._editHeaderAndFooter'));
$this->t->pfp('out', 'EditHeaderAndFooter');
}
else
{
echo lang("You must be an admin to edit the
site header and footer.") ."<br><br>";
}
$this->common_ui->DisplayFooter();
}
}
?>
--- NEW FILE ---
<?php
/***************************************************************************\
* phpGroupWare - Web Content Manager
*
* http://www.phpgroupware.org
*
* -------------------------------------------------
*
* 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.
*
\***************************************************************************/
class Translations_UI
{
var $t;
var $cat_bo;
var $acl;
var $preferenceso;
var $sitelanguages;
var $common_ui;
var $pagebo;
var $contentbo;
var $modulebo;
var $public_functions = array
(
'_manageTranslations' => True,
'_translateCategory' => True,
'_translatePage' => True,
'_translateSitecontent' => True,
);
function Translations_UI()
{
$this->common_ui =
CreateObject('sitemgr.Common_UI',True);
$this->t = $GLOBALS['phpgw']->template;
$this->cat_bo = &$GLOBALS['Common_BO']->cats;
$this->acl = &$GLOBALS['Common_BO']->acl;
$this->preferenceso =
CreateObject('sitemgr.sitePreference_SO', true);
$this->sitelanguages =
explode(',',$this->preferenceso->getPreference('sitelanguages'));
$this->pagebo = &$GLOBALS['Common_BO']->pages;
$this->contentbo = &$GLOBALS['Common_BO']->content;
$this->modulebo = &$GLOBALS['Common_BO']->modules;
}
function _manageTranslations()
{
$this->common_ui->DisplayHeader();
$this->t->set_file('ManageTranslations',
'manage_translations.tpl');
$this->t->set_block('ManageTranslations', 'PageBlock',
'PBlock');
$this->t->set_block('PageBlock', 'langexistpage',
'langpageBlock');
$this->t->set_block('ManageTranslations',
'CategoryBlock', 'CBlock');
$this->t->set_block('CategoryBlock', 'langexistcat',
'langcatBlock');
$this->t->set_block('ManageTranslations',
'sitelanguages', 'slBlock');
foreach ($this->sitelanguages as $lang)
{
$this->t->set_var('sitelanguage',$lang);
$this->t->parse('slBlock', 'sitelanguages',
true);
}
$this->t->set_var(Array(
'translation_manager' => lang('Translation
Manager'),
'lang_catname' => lang('Category Name'),
'translate_site_content' =>
$GLOBALS['phpgw']->link('/index.php',
'menuaction=sitemgr.Translations_UI._translateSitecontent'),
'lang_site_content' => lang('Translate
site-wide content blocks'),
'colspan' => (count($this->sitelanguages) + 2)
));
$this->cat_list =
$this->cat_bo->getPermittedCatWriteNested();
if($this->cat_list)
{
for($i = 0; $i < sizeof($this->cat_list); $i++)
{
//setup entry in categorblock for
translations of categories
$this->cat =
$this->cat_bo->getCategory($this->cat_list[$i]);
if ($this->cat->depth)
{
$buffer = '-';
}
else
{
$buffer = '';
}
$buffer =
str_pad('',$this->cat->depth*18,
' ',STR_PAD_LEFT).$buffer;
$this->t->set_var('buffer', $buffer);
$this->t->set_var('category',
$this->cat->name);
$category_id = $this->cat_list[$i];
$availablelangsforcat =
$this->cat_bo->getlangarrayforcategory($category_id);
$this->t->set_var('langcatBlock','');
foreach ($this->sitelanguages as $lang)
{
$this->t->set_var('catexistsinlang', in_array($lang,$availablelangsforcat) ?
'ø' : ' ');
$this->t->parse('langcatBlock',
'langexistcat', true);
}
$this->t->set_var('translatecat',
'<form action="'.
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Translations_UI._translateCategory').
'" method="POST"><input
type="submit" name="btnTranslateCategory" value="' . lang('Translate') .'">'.
'<input type="hidden"
name="category_id" value="'.$category_id.'"></form>');
//setup page list
$this->t->set_var('PBlock', '');
$this->page_list =
$this->pagebo->getPageIDList($this->cat_list[$i]);
if($this->page_list &&
sizeof($this->page_list)>0)
{
for($j = 0; $j <
sizeof($this->page_list); $j++)
{
$this->page_id
=$this->page_list[$j];
$this->page =
$this->pagebo->getPage($this->page_id,$this->sitelanguages[0]);
$page_description =
'<i>' . lang('Page') . ': </i>'.$this->page->name.'<br><i>' . lang('Title') .
': </i>'.$this->page->title;
$this->t->set_var('page', $page_description);
$availablelangsforpage
= $this->pagebo->getlangarrayforpage($this->page_id);
$this->t->set_var('langpageBlock','');
foreach
($this->sitelanguages as $lang)
{
$this->t->set_var('pageexistsinlang', in_array($lang,$availablelangsforpage) ?
'ø' : ' ');
$this->t->parse('langpageBlock', 'langexistpage', true);
}
$this->t->set_var('translatepage',
'<form
action="'.
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Translations_UI._translatePage').
'"
method="POST"><input type="submit" name="btnTranslatePage" value="' .
lang('Translate') .'">'.
'<input
type="hidden" name="page_id" value="'.$this->page_id.'"></form>');
$this->t->parse('PBlock', 'PageBlock', true);
}
}
$this->t->parse('CBlock',
'CategoryBlock', true);
}
}
else
{
$this->t->set_var('category','No category is
available');
}
$this->t->pfp('out', 'ManageTranslations');
$this->common_ui->DisplayFooter();
}
function _translateCategory()
{
$GLOBALS['Common_BO']->globalize(array('category_id','changelanguage','showlanguage','savelanguage','btnSaveCategory','savecatname','savecatdesc','btnSaveBlock','element','blockid','blocktitle'));
global $category_id, $changelanguage, $showlanguage,
$savelanguage, $btnSaveCategory, $savecatname, $savecatdesc,$btnSaveBlock;
if ($btnSaveCategory)
{
$this->cat_bo->saveCategoryLang($category_id,
$savecatname, $savecatdesc, $savelanguage);
$this->_manageTranslations();
return;
}
elseif ($btnSaveBlock)
{
$this->save_block();
}
$this->common_ui->DisplayHeader();
$this->t->set_file('TranslateCategory',
'translate_category.tpl');
$this->t->set_block('TranslateCategory','Blocktranslator','Tblock');
$this->t->set_block('Blocktranslator','EditorElement','Eblock');
if($error)
{
$this->t->set_var('error_msg',lang('You failed
to fill in one or more required fields.'));
$this->cat->name = $savecatname;
$this->cat->description = $savecatdesc;
}
else
{
$this->cat =
$this->cat_bo->getCategory($category_id);
$showlanguage = $showlanguage ? $showlanguage :
$this->sitelanguages[0];
$showlangdata =
$this->cat_bo->getCategory($category_id,$showlanguage);
$savelanguage = $savelanguage ? $savelanguage :
$this->sitelanguages[1];
$savelangdata =
$this->cat_bo->getCategory($category_id,$savelanguage);
$this->templatehelper();
$this->t->set_var(Array(
'translate' => lang('Translate
Category'),
'catid' => $category_id,
'lang_catname' => lang('Category Name'),
'showcatname' => $showlangdata->name,
'savecatname' => $savelangdata->name,
'lang_catdesc' => lang('Category
Description'),
'showcatdesc' =>
$showlangdata->description,
'savecatdesc' =>
$savelangdata->description,
'lang_reset' => lang('Reset'),
'lang_save' => lang('Save')));
//Content blocks
$this->process_blocks($this->contentbo->getblocksforscope($category_id,0));
$this->t->pfp('out','TranslateCategory');
}
$this->common_ui->DisplayFooter();
}
function _translatePage()
{
$GLOBALS['Common_BO']->globalize(array('page_id','changelanguage','showlanguage','savelanguage','btnSavePage','savepagetitle','savepagesubtitle','btnSaveBlock','element','blockid','blocktitle'));
global $page_id, $changelanguage, $showlanguage,
$savelanguage, $btnSavePage, $savepagetitle, $savepagesubtitle,$btnSaveBlock;
if ($btnSavePage)
{
$this->page->id = $page_id;
$this->page->title = $savepagetitle;
$this->page->subtitle = $savepagesubtitle;
$this->pagebo->savePageLang($this->page,
$savelanguage);
$this->_manageTranslations();
return;
}
elseif ($btnSaveBlock)
{
$this->save_block();
}
$this->common_ui->DisplayHeader();
$this->t->set_file('TranslatePage',
'translate_page.tpl');
$this->t->set_block('TranslatePage','Blocktranslator','Tblock');
$this->t->set_block('Blocktranslator','EditorElement','Eblock');
//TODO: error handling seems not correct
if($error)
{
$this->t->set_var('error_msg',lang('You failed
to fill in one or more required fields.'));
$this->page->title = $savepagetitle;
$this->page->subtitle = $savepagesubtitle;
}
else
{
$this->page = $this->pagebo->getPage($page_id);
$showlanguage = $showlanguage ? $showlanguage :
$this->sitelanguages[0];
$showlangdata =
$this->pagebo->getPage($page_id,$showlanguage);
$savelanguage = $savelanguage ? $savelanguage :
$this->sitelanguages[1];
$savelangdata =
$this->pagebo->getPage($page_id,$savelanguage);
$this->templatehelper();
$this->t->set_var(Array(
'translate' => lang('Translate Page'),
'pageid' => $page_id,
'lang_pagename' => lang('Page Name'),
'pagename' => $this->page->name,
'lang_pagetitle' => lang('Page Title'),
'showpagetitle' => $showlangdata->title,
'savepagetitle' => $savelangdata->title,
'lang_pagesubtitle' => lang('Page
Subtitle'),
'showpagesubtitle' =>
$showlangdata->subtitle,
'savepagesubtitle' =>
$savelangdata->subtitle,
'lang_reset' => lang('Reset'),
'lang_save' => lang('Save')));
//Content blocks
$this->process_blocks($this->contentbo->getblocksforscope($this->page->cat_id,$page_id));
$this->t->pfp('out','TranslatePage');
}
$this->common_ui->DisplayFooter();
}
function _translateSitecontent()
{
$GLOBALS['Common_BO']->globalize(array('changelanguage','showlanguage','savelanguage','btnSaveBlock','element','blockid','blocktitle'));
global $changelanguage, $showlanguage, $savelanguage,
$btnSaveBlock;
if ($btnSaveBlock)
{
$this->save_block();
}
$this->common_ui->DisplayHeader();
$this->t->set_file('TranslateSitecontent',
'translate_sitecontent.tpl');
$this->t->set_block('TranslateSitecontent','Blocktranslator','Tblock');
$this->t->set_block('Blocktranslator','EditorElement','Eblock');
$showlanguage = $showlanguage ? $showlanguage :
$this->sitelanguages[0];
$savelanguage = $savelanguage ? $savelanguage :
$this->sitelanguages[1];
$this->templatehelper();
$this->process_blocks($this->contentbo->getblocksforscope(0,0));
$this->t->pfp('out','TranslateSitecontent');
}
function process_blocks($blocks)
{
global $showlanguage,$savelanguage;
while (list($id,$block) = @each($blocks))
{
$moduleobject =
$this->modulebo->createmodule($block->app_name,$block->module_name);
$this->t->set_var('moduleinfo',($block->app_name.'.'.$block->module_name));
$savelangdata =
$this->contentbo->getlangblockdata($id,$savelanguage);
$showlangdata =
$this->contentbo->getlangblockdata($id,$showlanguage);
$translatorstandardelements = array(
array('label' => lang('Title'),
'value' =>
($showlangdata->title ? $showlangdata->title : $moduleobject->title),
'form' => ('<input
type="text" name="blocktitle" value="' .
($savelangdata->title ?
$savelangdata->title : $moduleobject->title) . '" />')
)
);
$block->arguments = $showlangdata->arguments;
$moduleobject->set_block($block);
$saveblock = $block;
$saveblock->arguments =
$savelangdata->arguments;
$translatormoduleelements =
$moduleobject->get_translation_interface($block,$saveblock);
$interface =
array_merge($translatorstandardelements,$translatormoduleelements);
$this->t->set_var('Eblock','');
while (list(,$element) = each($interface))
{
$this->t->set_var(Array(
'label' => $element['label'],
'value' => $element['value'],
'form' => $element['form']
));
$this->t->parse('Eblock','EditorElement', true);
}
$this->t->set_var(Array(
'blockid' => $id,
'savebutton' => '<input type="submit"
value="Save" name="btnSaveBlock" />'
));
$this->t->parse('Tblock','Blocktranslator',
true);
}
}
function save_block()
{
global $blockid, $element,$blocktitle,$savelanguage;
$moduleobject =
$this->contentbo->getblockmodule($blockid);
if ($moduleobject->validate($element))
{
$block = CreateObject('sitemgr.Block_SO',True);
$block->id = $blockid;
$block->title = $blocktitle;
if
(!$this->contentbo->saveblockdatalang($block,$element,$savelanguage))
{
$this->t->set_var('validationerror',
lang("You are not entitled to edit block %1",$blockid));;
}
}
else
{
$this->t->set_var('validationerror',
$module->get_validationerror());
}
}
function templatehelper()
{
global $showlanguage,$savelanguage;
$this->t->set_var(Array(
'lang_refresh' => '<input type="submit"
value="' . lang('Refresh') .'" name="changelanguage">'));
$select = '<select name="showlanguage">';
foreach ($this->sitelanguages as $lang)
{
$selected= '';
if ($lang == $showlanguage)
{
$selected = 'selected="selected" ';
}
$select .= '<option ' . $selected .'value="' .
$lang . '">'. $GLOBALS['Common_BO']->getlangname($lang) . '</option>';
}
$select .= '</select> ';
$this->t->set_var('showlang', $select);
$select = '<select name="savelanguage">';
foreach ($this->sitelanguages as $lang)
{
$selected= '';
if ($lang == $savelanguage)
{
$selected = 'selected="selected" ';
}
$select .= '<option ' . $selected .'value="' .
$lang . '">'. $GLOBALS['Common_BO']->getlangname($lang) . '</option>';
}
$select .= '</select>';
$this->t->set_var('savelang', $select);
}
}
--- NEW FILE ---
<?php
class browser_transform
{
function browser_transform($prevlink,$nextlink)
{
$this->prevlink = $prevlink;
$this->nextlink = $nextlink;
}
function apply_transform($title,$content)
{
$result = '<form action="' . $_SERVER['REQUEST_URI'] . '"
method="post">';
$result .= $content;
$result .= '<div align="center">';
$result .= $this->prevlink;
$result .= $this->nextlink;
$result .= '</form></div>';
return $result;
}
}
--- NEW FILE ---
<?php
class Transformer
{
var $arguments;
function Transformer($arguments=array())
{
$this->arguments = $arguments;
}
function apply_transform($title,$content)
{
return $content;
}
}
class Module
{
var $validation_error;
var $transformer_chain;
var $arguments;
var $properties;
var $block;
function Module()
{
$this->arguments = array();
$this->properties = array();
$this->transformer_chain = array();
$this->title = "Standard module";
$this->description = "Parent class that all modules should
extend";
}
function add_transformer($transformer)
{
$this->transformer_chain[] = $transformer;
}
//before calling the functions get_user_interface, get_output,
//the function set_block is used, so that we know in what scope we are,
know the arguments,
//and can retrieve the properties
//this function can be overriden (but do not forget to call
parent::set_block) in order to do some configuration
//that depends on the blocks arguments
//the produce argument is set when content is generated, so we can do
some stuff we do not need when editing the block
function set_block($block,$produce=False)
{
if ($produce)
{
if ($this->session)
{
$sessionarguments =
$GLOBALS['phpgw']->session->appsession($this->name,'sitemgr-site');
while (list(,$argument) = @each($this->session))
{
if (isset($sessionarguments[$argument]))
{
$block->arguments[$argument] =
$sessionarguments[$argument];
}
}
}
while (list(,$argument) = @each($this->get))
{
if (isset($_GET[$this->name][$argument]))
{
$block->arguments[$argument] =
$_GET[$this->name][$argument];
}
}
//contrary to $this->get, cookie and session, the
argument name is the key in $this->post because this array also
//defines the form element
while (list($argument,) = @each($this->post))
{
if (isset($_POST[$this->name][$argument]))
{
$block->arguments[$argument] =
$_POST[$this->name][$argument];
}
}
while (list(,$argument) = @each($this->cookie))
{
if (isset($_COOKIE[$this->name][$argument]))
{
$block->arguments[$argument] =
$_COOKIE[$this->name][$argument];
}
}
}
$this->block = $block;
}
function link($modulevars)
{
while (list($key,$value) = @each($modulevars))
{
$extravars[$this->name.'['.$key.']'] = $value;
}
$extravars['page_id'] = $this->block->page_id;
return sitemgr_link2('/index.php',$extravars);
}
function get_properties($cascading=True)
{
if ($cascading)
{
return
$GLOBALS['Common_BO']->modules->getcascadingmoduleproperties(
$this->block->module_id,
$this->block->area,
$this->block->cat_id,
$this->block->app_name,
$this->block->module_name
);
}
else
{
return
$GLOBALS['Common_BO']->modules->getmoduleproperties(
$this->block->module_id,
$this->block->area,
$this->block->cat_id
);
}
}
function get_user_interface()
{
//if you override this function you can fetch properties and
adapt the interface accordingly
//$properties = $this->get_properties();
$interface = array();
reset($this->arguments);
while (list($key,$input) = @each($this->arguments))
{
$elementname = ($input['i18n'] ? ('element[i18n]['
.$key . ']') : ('element[' .$key . ']'));
//arrays of input elements are only implemented for the
user interface
if ($input['type'] == 'array')
{
$i = 0;
while (isset($input[$i]))
{
$element['label'] = $input[$i]['label'];
$element['form'] =
$this->build_input_element($input[$i],$this->block->arguments[$key][$i],$elementname.'[]');
$interface[] = $element;
$i++;
}
}
else
{
$element['label'] = $input['label'];
$element['form'] =
$this->build_input_element($input,$this->block->arguments[$key],$elementname);
$interface[] = $element;
}
}
return $interface;
}
function get_translation_interface($fromblock,$toblock)
{
//if you override this function you can fetch properties and
adapt the interface accordingly
//$properties = $this->get_properties();
$interface = array();
reset($this->arguments);
while (list($key,$input) = @each($this->arguments))
{
if ($input['i18n'])
{
$elementname = 'element[i18n][' .$key . ']';
//arrays of input elements are only implemented
for the user interface
if ($input['type'] == 'array')
{
$i = 0;
while (isset($input[$i]))
{
$element['label'] =
$input[$i]['label'];
$element['form'] =
$this->build_input_element($input[$i],$toblock->arguments[$key][$i],$elementname.'[]');
$element['value'] =
$fromblock->arguments[$key][$i];
$interface[] = $element;
$i++;
}
}
else
{
$element['label'] = $input['label'];
$element['form'] =
$this->build_input_element($input,$toblock->arguments[$key],$elementname);
$element['value'] =
$fromblock->arguments[$key];
$interface[] = $element;
}
}
}
return $interface;
}
function get_admin_interface()
{
//we set the blockarguments to the properties so that the
build_input_element function can retrieve the right defaults
$properties = $this->get_properties(False);
$elementname = 'element[' .$key . ']';
$interface = array();
while (list($key,$input) = @each($this->properties))
{
$element['label'] = $input['label'];
$element['form'] =
$this->build_input_element($input,$properties[$key],$elementname);
$interface[$key] = $element;
}
return $interface;
}
function build_post_element($key,$default=False)
{
return $this->build_input_element(
$this->post[$key],
($default !== False) ? $default :
$this->block->arguments[$key],
($this->name . '[' . $key . ']')
);
}
function build_input_element($input,$default,$elementname)
{
$trans = array('{' => '{', '}' => '}');
if ($default)
{
$default =
strtr($GLOBALS['phpgw']->strip_html($default),$trans);
}
$paramstring = '';
while (list($param,$value) = @each($input['params']))
{
$paramstring .= $param . '="' . $value . '" ';
}
$inputdef = $paramstring . ' name="' . $elementname . '"';
switch($input['type'])
{
case 'textarea':
return '<textarea ' . $inputdef . '>' .
$default . '</textarea>';
case 'textfield':
return '<input type="text" ' . $inputdef . '
value ="' . $default . '" />';
case 'checkbox':
return '<input type="checkbox" ' . $inputdef .
($default ? 'checked="checked"' :'') . '" />';
case 'select':
$select = '<select name="' . $elementname .
'">';
foreach ($input['options'] as $value =>
$display)
{
$selected='';
if ($default == $value)
{
$selected =
'selected="selected"';
}
$select .= '<option value="'.
$value . '" ' . $selected . '>' . $display . '</option>';
}
$select .= '</select>';
return $select;
case 'submit':
return '<input type="submit" ' . $inputdef .'
value ="' . $input['value'] . '" />';
case 'image':
return '<input type="image" ' . $inputdef .'
src ="' . $input['src'] . '" />';
}
}
function validate(&$data)
{
return true;
}
//never call get_content directly, get_output takes care of passing it
the right arguments
function get_content(&$arguments,$properties)
{
}
function get_output($type='html')
{
$content=
$this->get_content($this->block->arguments,$this->get_properties());
if (!$content)
{
return '';
}
if ($type == 'raw')
{
return $content;
}
else
{
if ($this->transformer_chain)
{
foreach ($this->transformer_chain as
$transformer)
{
$content =
$transformer->apply_transform($this->block->title,$content);
}
}
//store session variables
if ($this->session)
{
reset($this->session);
while (list(,$argument) = each($this->session))
{
if
(isset($this->block->arguments[$argument]))
{
$sessionarguments[$argument] =
$this->block->arguments[$argument];
}
}
$GLOBALS['phpgw']->session->appsession($this->name,'sitemgr-site',$sessionarguments);
}
return $content;
}
}
}
--- NEW FILE ---
<?php
class module_administration extends Module
{
function module_administration()
{
$this->arguments = array();
$this->properties = array();
$this->title = "Administration";
$this->description = "This module presents a link back to the
sitemgr's administration menu. It is meant for registered users";
}
function get_content(&$arguments,$properties)
{
return
' <strong><big>·</big></strong><a
href="'.phpgw_link('/sitemgr/index.php').'">' . lang('Content Manager') .
'</a>';
}
}
--- NEW FILE ---
<?php
class module_amazon extends Module
{
function module_amazon()
{
$this->arguments = array();
$this->properties = array();
$this->title = "Amazon";
$this->description = "Use this module for displaying book ads
for the amazon web site ";
}
function get_content(&$arguments,$properties)
{
$amazon_id = "phpgwsitemgr-20";
mt_srand((double)microtime()*1000000);
$imgs = dir('images/amazon');
while ($file = $imgs->read()) {
if (eregi("gif", $file) || eregi("jpg", $file)) {
$imglist .= "$file ";
}
}
closedir($imgs->handle);
$imglist = explode(" ", $imglist);
$a = sizeof($imglist)-2;
$random = mt_rand(0, $a);
$image = $imglist[$random];
$asin = explode(".", $image);
$content = "<br><center><a
href=\"http://www.amazon.com/exec/obidos/ASIN/$asin[0]/$amazon_id\"
target=\"_blank\">";
$content .= "<img src=\"images/amazon/$image\" border=\"0\"
alt=\"\"><br><br></center>";
}
}
--- NEW FILE ---
<?php
// this module is only for demonstrative purposes,
// a real appdir would be better defined as a real phpgw application
// and a sitemgr module would not have to handle the data, but only to fetch it
class module_appdir extends Module
{
function module_appdir()
{
$this->name = 'appdir';
$this->arguments = array();
$this->title = "An application directory";
$this->description = "This module demonstrates how handling
data stored in XML and building an interacvite interface from it";
}
function get_user_interface()
{
$interface = array();
$allapps = $this->block->arguments['directory'];
//xmltool2 is a slightly modified version of phpgwapi.xmltool
of HEAD
$xmltool = CreateObject('sitemgr.xmltool2');
$xmltool->import_xml($allapps);
$apparray = $xmltool->export_var();
$i = 0;
while (list(,$app) = @each($apparray['app']))
{
$element['label'] = '<hr>';
$element['form'] = '<hr>';
$interface[] = $element;
$element['label'] = '<b>'.$app['name'][0].'</b>';
$element['form'] = '';
$interface[] = $element;
foreach(array('name','maintainer','url','description')
as $key)
{
$elementname = 'element[' .$key . '][' . $i
.']';
$element['label'] = ucfirst($key);
$element['form'] = $this->build_input_element(
array(
'type' => ($key ==
'description') ? 'textarea' : 'textfield',
'params' => ($key ==
'description') ? array('cols' => 50,'rows' => 15) : array('size' => 50)),
$app[$key][0],
$elementname
);
$interface[] = $element;
}
$element['label'] = 'Delete this application';
$element['form'] = $this->build_input_element(
array('type' => 'checkbox'),
False,
'element[delete][' . $i . ']'
);
$interface[] = $element;
$i++;
}
$element['label'] = '<hr>';
$element['form'] = '<hr>';
$interface[] = $element;
$element['label'] = 'Add a new application';
$element['form'] = $this->build_input_element(
array('type' => 'checkbox'),
False,
'element[addnew]'
);
$interface[] = $element;
return $interface;
}
function validate(&$data)
{
$xmltool =
CreateObject('sitemgr.xmltool2','node','directory','');
$i = 0;
while (isset($data['name'][$i]))
{
if (!$data['delete'][$i])
{
$xmltool->import_var(
'app',
array(
'name' => $data['name'][$i],
'maintainer' =>
$data['maintainer'][$i],
'url' => $data['url'][$i],
'description' =>
$data['description'][$i],
)
);
}
$i++;
}
if ($data['addnew'])
{
$xmltool->import_var(
'app',
array(
'name' => 'New application',
'maintainer' => 'Maintainer',
'url' => 'http://',
'description' => 'Description'
)
);
}
$newdata['directory'] = $xmltool->export_xml();
$data = $newdata;
return true;
}
function set_block($block,$produce=False)
{
parent::set_block($block,$produce);
if ($produce)
{
require_once(PHPGW_INCLUDE_ROOT . SEP . 'sitemgr' . SEP
. 'inc' . SEP . 'class.xslt_transform.inc.php');
$this->add_transformer(new
xslt_transform($GLOBALS['sitemgr_info']['sitemgr-site-dir']. SEP .
'templates/modules/sitemgr/appdir/list.xsl'));
}
}
function get_content(&$arguments,$properties)
{
return $arguments['directory'];
}
}
--- NEW FILE ---
<?php
class module_calendar extends Module
{
function module_calendar()
{
$this->name = 'calendar';
$this->arguments = array();
$this->session = array('timestamp');
$this->post = array(
'prevmonth' => array(
'type' => 'image',
'src' =>
$GLOBALS['phpgw']->common->image('phpgwapi','left')
),
'nextmonth' => array(
'type' => 'image',
'src' =>
$GLOBALS['phpgw']->common->image('phpgwapi','right')
)
);
$this->title = "Calendar";
$this->description = "This module displays the current month";
$this->bo = CreateObject('calendar.bocalendar');
}
function get_content(&$arguments,$properties)
{
$t = Createobject('phpgwapi.Template');
$t->set_root($GLOBALS['sitemgr_info']['sitemgr-site-dir']. SEP
. 'templates/modules/sitemgr/calendar/');
$t->set_file('mini_calendar','mini_cal.tpl');
if (!$arguments['timestamp'])
{
$arguments['timestamp'] = time();
}
if ($arguments['prevmonth'])
{
$arguments['timestamp'] =
mktime(0,0,0,date("m",$arguments['timestamp'])-1,date("d",$arguments['timestamp']),
date("Y",$arguments['timestamp']));
}
elseif ($arguments['nextmonth'])
{
$arguments['timestamp'] =
mktime(0,0,0,date("m",$arguments['timestamp'])+1,date("d",$arguments['timestamp']),
date("Y",$arguments['timestamp']));
}
$date =
$GLOBALS['phpgw']->datetime->gmtdate($arguments['timestamp']);
$month = $date['month'];
$day = $date['day'];
$year = $date['year'];
$this->bo->read_holidays($year);
$month_ago = intval(date('Ymd',mktime(0,0,0,$month -
1,$day,$year)));
$month_ahead = intval(date('Ymd',mktime(0,0,0,$month +
1,$day,$year)));
$monthstart = intval(date('Ymd',mktime(0,0,0,$month,1,$year)));
$monthend = intval(date('Ymd',mktime(0,0,0,$month +
1,0,$year)));
$weekstarttime =
$GLOBALS['phpgw']->datetime->get_weekday_start($year,$month,1);
$t->set_block('mini_calendar','mini_cal','mini_cal');
$t->set_block('mini_calendar','mini_week','mini_week');
$t->set_block('mini_calendar','mini_day','mini_day');
$linkdata['menuaction'] = 'calendar.uicalendar.month';
$linkdata['month'] =
$GLOBALS['phpgw']->common->show_date($date['raw'],'m');
$linkdata['year'] =
$GLOBALS['phpgw']->common->show_date($date['raw'],'Y');
$month = '<a href="'
.$GLOBALS['phpgw']->link('/index.php',$linkdata) . '" class="minicalendar">' .
lang($GLOBALS['phpgw']->common->show_date($date['raw'],'F')).'
'.$GLOBALS['phpgw']->common->show_date($date['raw'],'Y').'</a>';
$var = Array(
'cal_img_root' =>
$GLOBALS['phpgw']->common->image('calendar','mini-calendar-bar'),
'bgcolor' =>
$calui->theme['bg_color'],
'bgcolor1' =>
$calui->theme['bg_color'],
'month' => $month,
'bgcolor2' =>
$calui->theme['cal_dayview'],
'holiday_color' => $calui->holiday_color,
'navig' => '<form action="' . $_SERVER['REQUEST_URI'] .
'" method="post">' .
$this->build_post_element('prevmonth') .
' ' .
$this->build_post_element('nextmonth') .
'</form>'
);
$t->set_var($var);
if(!$t->get_var('daynames'))
{
for($i=0;$i<7;$i++)
{
$var = Array(
'dayname' => '<b>' .
substr(lang($GLOBALS['phpgw']->datetime->days[$i]),0,2) . '</b>',
'day_image' => ''
);
$this->output_template_array($t,'daynames','mini_day',$var);
}
}
$today =
date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime);
unset($date);
for($i=$weekstarttime +
$GLOBALS['phpgw']->datetime->tz_offset;date('Ymd',$i)<=$monthend;$i += (24 *
3600 * 7))
{
unset($var);
$daily = $this->set_week_array($i -
$GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly);
@reset($daily);
while(list($date,$day_params) = each($daily))
{
$year = intval(substr($date,0,4));
$month = intval(substr($date,4,2));
$day = intval(substr($date,6,2));
$str = '';
unset($linkdata);
$linkdata['menuaction'] =
'calendar.uicalendar.day';
$linkdata['date']= $date;
$str = '<a href="'
.$GLOBALS['phpgw']->link('/index.php',$linkdata) .'" class="'
.$day_params['class'] .'">' .$day .'</a>';
$var[] = Array(
'day_image' =>
$day_params['day_image'],
'dayname' => $str
);
}
for($l=0;$l<count($var);$l++)
{
$this->output_template_array($t,'monthweek_day','mini_day',$var[$l]);
}
$t->parse('display_monthweek','mini_week',True);
$t->set_var('dayname','');
$t->set_var('monthweek_day','');
}
$return_value = $t->fp('out','mini_cal');
$t->set_var('display_monthweek','');
// $t->set_var('daynames','');
// unset($p);
return $return_value;
}
function output_template_array(&$p,$row,$list,$var)
{
if (!isset($var['hidden_vars']))
{
$var['hidden_vars'] = '';
}
$p->set_var($var);
$p->parse($row,$list,True);
}
function set_week_array($startdate,$cellcolor,$weekly)
{
for ($j=0,$datetime=$startdate;$j<7;$j++,$datetime += 86400)
{
$date = date('Ymd',$datetime + (60 * 60 * 2));
if($this->bo->cached_events[$date])
{
$appts = True;
}
else
{
$appts = False;
}
$holidays = $this->bo->cached_holidays[$date];
if($weekly)
{
$cellcolor =
$GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor);
}
$day_image = '';
if($holidays)
{
$extra = '
bgcolor="'.$this->bo->holiday_color.'"';
$class = ($appts?'b':'').'minicalhol';
if ($date == $this->bo->today)
{
$day_image = '
background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block').'"';
}
}
elseif ($date != $this->bo->today)
{
$extra = ' bgcolor="'.$cellcolor.'"';
$class = ($appts?'b':'').'minicalendar';
}
else
{
$extra = '
bgcolor="'.$GLOBALS['phpgw_info']['theme']['cal_today'].'"';
$class = ($appts?'b':'').'minicalendar';
$day_image = '
background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block').'"';
}
if($this->bo->check_perms(PHPGW_ACL_ADD))
{
$new_event = True;
}
else
{
$new_event = False;
}
$holiday_name = Array();
if($holidays)
{
for($k=0;$k<count($holidays);$k++)
{
$holiday_name[] = $holidays[$k]['name'];
}
}
$week = '';
if (!$j || (!$weekly && $j && substr($date,6,2) ==
'01'))
{
$week = lang('week').'
'.(int)((date('z',($startdate+(24*3600*4)))+7)/7);
}
$daily[$date] = Array(
'extra' => $extra,
'new_event' => $new_event,
'holidays' => $holiday_name,
'appts' => $appts,
'week' => $week,
'day_image' => $day_image,
'class' => $class
);
}
return $daily;
}
}
--- NEW FILE ---
<?php
class module_currentsection extends Module
{
function module_currentsection()
{
$this->arguments = array();
$this->properties = array();
$this->title = "Current Section";
$this->description = "This block displays the current section's
table of contents";
}
function get_content(&$arguments,$properties)
{
global $page;
$catlinks =
$GLOBALS['objbo']->getCatLinks((int)$page->cat_id,false);
if (!$page->cat_id)
{
return '';
}
$pagelinks =
$GLOBALS['objbo']->getPageLinks($page->cat_id,false);
$category = $GLOBALS['objbo']->getcatwrapper($page->cat_id);
$this->block->title = $category->name;
$parent = $category->parent;
unset($category);
$content = '';
if ($parent)
{
$parentcat = $GLOBALS['objbo']->getcatwrapper($parent);
$content .= "\n".'<b>Parent
Section:</b><br> · <a href="'.
sitemgr_link2('/index.php','category_id='.$parent).'">'.$parentcat->name.
'</a><br><br>';
unset($parentcat);
}
if (count($catlinks))
{
$content .= "\n".'<b>Subsections:</b><br>';
foreach ($catlinks as $catlink)
{
$content .=
"\n".' · '.$catlink['link'].'<br>';
}
$content .= '<br>';
}
if (count($pagelinks)>1 || (count($pagelinks)>0 && $content))
{
$content .= "\n".'<b>Pages:</b>';
$content .= ' (<a
href="'.sitemgr_link2('/index.php','category_id='.$page->cat_id).
'"><i>show all</i></a>)<br>';
reset($pagelinks);
while(list($pagelink_id,$pagelink) = each($pagelinks))
{
if ($page->page_id && $page->page_id ==
$pagelink_id)
{
$content .=
' >'.$pagelink['link'].'<<br>';
}
else
{
$content .=
' · '.$pagelink['link'].'<br>';
}
}
}
return $content;
}
}
--- NEW FILE ---
<?php
class module_forum extends Module
{
var $template;
var $startlevel;
function module_forum()
{
$this->name = "forum";
$this->arguments = array(
'startlevel' => array(
'type' => 'select',
'label' => 'With which view should the module
be displayed in the beginning?',
'options' => array(
1 => 'Overview of all available
categories',
2 => 'Overview of one specific
category',
3 => 'Summary of one forum',
),
),
'startcat_id' => array(
'type' => 'select',
'label' => 'Select a category',
'options' => Array(),
),
'startforum_id' => array(
'type' => 'select',
'label' => 'Select a forum',
'options' => Array(),
),
);
$this->get =
array('level','cat_id','forum_id','msg','pos','view');
$this->session = array('level','cat_id','forum_id','view');
$this->title = "Discussions";
$this->description = "This module displays the phpgw forums on
the web site";
$this->bo = CreateObject('forum.boforum',1);
}
function get_user_interface()
{
$defaults = $this->block->arguments;
if ($defaults['startlevel'] == 2 || $defaults['startlevel'] ==
3)
{
$options=array();
$cats = $this->bo->get_all_cat_info();
while(list($key,$cat) = @each($cats))
{
$options[$cat['id']] = $cat['name'];
}
$this->arguments['startcat_id']['options'] = $options;
}
else
{
unset($this->arguments['startcat_id']);
}
if (($defaults['startlevel'] == 3) && $defaults['startcat_id'])
{
$options=array();
$forums =
$this->bo->get_forums_for_cat($defaults['startcat_id']);
while (list($key,$forum) = @each($forums))
{
$options[$forum['id']] = $forum['name'];
}
$this->arguments['startforum_id']['options'] = $options;
}
else
{
unset($this->arguments['startforum_id']);
}
return parent::get_user_interface();
}
function get_content(&$arguments,$properties)
{
$this->startlevel = $arguments['startlevel'];
if (!$arguments['level'] || $arguments['level'] <
$this->startlevel)
{
$arguments['level'] = $this->startlevel;
}
$this->template = CreateObject('phpgwapi.Template');
$this->template->set_root($GLOBALS['sitemgr_info']['sitemgr-site-dir']. SEP .
'templates/modules/sitemgr/forum/');
if ($arguments['level'] == 1)
{
return $this->index();
}
//$arguments['level'] > 1
$cat_id = ($this->startlevel == 1) ? $arguments['cat_id'] :
$arguments['startcat_id'];
$cat = $cat_id ? $this->bo->get_cat_info($cat_id) : False;
if (!$cat)
{
$cats = array_values($this->bo->get_all_cat_info());
if (!$cats)
{
return lang('There are no categories');
}
$cat = $cats[0];
}
if ($arguments['level'] == 2)
{
return $this->forums($cat);
}
//$arguments['level'] > 2
$forum_id = ($this->startlevel > 3) ? $arguments['forum_id'] :
$arguments['startforum_id'];
$forum = $forum_id ?
$this->bo->get_forum_info($cat['id'],$forum_id) : False;
if (!$forum)
{
$forums =
array_values($this->bo->get_forums_for_cat($cat['id']));
if (!$forums)
{
return lang('There are no forums in this
category');
}
$forum = $forums[0];
}
if ($arguments['level'] == 3)
{
return
$this->threads($cat,$forum,(strcmp($arguments['view'],'collapsed') == 0));
}
//$arguments['level'] == 4, if msg is not defined we fall back
to level 3
return $arguments['msg'] ?
$this->read($cat,$forum,$arguments['msg']) :
$this->threads($cat,$forum,(strcmp($arguments['view'],'collapsed') == 0));
}
function index()
{
$this->template->set_file(
Array(
'INDEX' => 'index.body.tpl'
)
);
$this->template->set_block('INDEX','CategoryForum','CatF');
$var = Array(
'CAT_IMG' =>
$GLOBALS['phpgw']->common->image('forum','category'),
);
$this->template->set_var($var);
$cats = $this->bo->get_all_cat_info();
$rowon = true;
while(list($key,$cat) = @each($cats))
{
$rowon = !$rowon;
$var = Array(
'ROWONOFF' => $rowon ? 'rowon' : 'rowoff',
'CAT' => $cat['name'],
'DESC' => $cat['descr'],
'CAT_LINK' => $this->link(Array(
'level' => 2,
'cat_id' => $cat['id']
)),
'value_last_post' => $cat['last_post'],
'value_total'=> $cat['total']
);
$this->template->set_var($var);
$this->template->parse('CatF','CategoryForum',true);
}
$this->template->parse('Out','INDEX');
return $this->template->get('Out');
}
function forums($cat)
{
$this->template->set_file(
Array(
'_list' => 'forums.body.tpl'
)
);
$this->template->set_block('_list','row_empty');
$this->template->set_block('_list','list');
$this->template->set_block('_list','row');
$var = Array(
'FORUM_IMG' =>
$GLOBALS['phpgw']->common->image('forum','forum'),
'CATEGORY'=> $cat['name'],
'LANG_CATEGORY'=> lang('Category'),
'BACKLINK'=> (($this->startlevel == 1) ?
('<a href="' . $this->link(array('level' => 1))
. '">' . lang('All categories') . '</a>') :
''
)
);
$this->template->set_var($var);
$forum_info = $this->bo->get_forums_for_cat($cat['id']);
if(!$forum_info)
{
$this->template->set_var('lang_no_forums',lang('There
are no forums in this category'));
$this->template->fp('rows','row_empty');
}
else
{
$rowon = true;
while (list($key,$forum) = each($forum_info))
{
$rowon = !$rowon;
$this->template->set_var(
Array(
'ROWONOFF'=> $rowon ? 'rowon' :
'rowoff',
'NAME'=> $forum['name'],
'DESC'=> $forum['descr'],
'THREADS_LINK'=>
$this->link(Array(
'level' => 3,
'forum_id' =>
$forum['id']
)),
'value_last_post' =>
$forum['last_post'],
'value_total'=> $forum['total']
)
);
$this->template->fp('rows','row',True);
}
}
$this->template->parse('Out','list');
return $this->template->get('Out');
}
function threads($cat,$forum,$is_collapsed)
{
$pre_var = array(
'LANG_TOPIC'=> lang('Topic'),
'LANG_AUTHOR'=> lang('Author'),
'LANG_REPLIES'=> lang('Replies'),
'LANG_LATREP'=> lang('Latest Reply'),
'LANG_FORUM'=> lang('Forum'),
'FORUM'=> $forum['name'],
'BACKLINK'=> (($this->startlevel < 3) ?
('<a href="' .
$this->link(array('level' => 2))
. '">' .
lang('All forums in category
%1','<b>'.$cat['name'].'</b>') . '</a>'
) :
''
)
);
$thread_listing =
$this->bo->get_thread($cat['id'],$forum['id'],$is_collapsed);
if($is_collapsed)
{
$this->template->set_file(
Array(
'COLLAPSE' =>
'collapse.threads.tpl'
)
);
$this->template->set_block('COLLAPSE','CollapseThreads','CollapseT');
$this->template->set_var($pre_var);
$this->template->set_var('THREAD_IMG',$GLOBALS['phpgw']->common->image('forum','thread'));
$rowon = true;
while($thread_listing && list($key,$thread) =
each($thread_listing))
{
$rowon = !$rowon;
$var = Array(
'ROWONOFF' => $rowon ? 'rowon' :
'rowoff',
'TOPIC' =>
($thread['subject']?$thread['subject']:'[No subject]'),
'AUTHOR' =>
($thread['author']?$GLOBALS['phpgw']->common->grab_owner_name($thread['author']):lang('Unknown')),
'REPLIES' => $thread['replies'],
'READ_LINK' => $this->link(Array(
'level' => 4,
'msg' => $thread['id'],
)),
'LATESTREPLY' => $thread['last_reply']
);
$this->template->set_var($var);
$this->template->parse('CollapseT','CollapseThreads',true);
}
$var = Array(
'THREADS_LINK' => $this->link(Array(
'view' => 'threads',
)),
'LANG_THREADS' => lang('View Threads')
);
$this->template->set_var($var);
$this->template->parse('Out','COLLAPSE');
} //end if
//For viewing the normal view
else
{
$this->template->set_file(
Array(
'NORMAL' => 'normal.threads.tpl'
)
);
$this->template->set_block('NORMAL','NormalThreads','NormalT');
$this->template->set_var($pre_var);
$rowon = true;
$tr_color = $this->row_on_color;
while($thread_listing && list($key,$thread) =
each($thread_listing))
{
$rowon = !$rowon;
$move = '';
for($tmp = 1;$tmp <= $thread['depth']; $tmp++)
{
$move .= ' ';
}
$move .= '<img
src="'.$GLOBALS['phpgw']->common->image('forum','n').'">';
$move .= ' ';
$var = Array(
'ROWONOFF' => $rowon ? 'rowon' :
'rowoff',
'TOPIC' =>
($thread['subject']?$thread['subject']:'[No subject]'),
'AUTHOR' =>
($thread['author']?$GLOBALS['phpgw']->common->grab_owner_name($thread['author']):lang('Unknown')),
'REPLIES' => $thread['replies'],
'READ_LINK' => $this->link(Array(
'level' => 4,
'msg' => $thread['id'],
'pos' => $thread['pos']
)),
'LATESTREPLY' =>
$thread['last_reply'],
'DEPTH' => $move
);
$this->template->set_var($var);
$this->template->parse('NormalT','NormalThreads',true);
} //end while
$var = Array(
'THREADS_LINK' => $this->link(Array(
'view' => 'collapsed'
)),
'LANG_THREADS' => lang('Collapse Threads')
);
$this->template->set_var($var);
$this->template->parse('Out','NORMAL');
}
return $this->template->get('Out');
}
function read($cat,$forum,$msg)
{
$this->template->set_file(
Array(
'READ' => 'read.body.tpl'
)
);
$this->template->set_block('READ','read_body','read_body');
$this->template->set_block('READ','msg_template','msg_template');
$this->template->set_block('READ','post_template','post_template');
$var = array(
'LANG_TOPIC'=> lang('Topic'),
'LANG_AUTHOR'=> lang('Author'),
'LANG_REPLIES'=> lang('Replies'),
'LANG_LATREP'=> lang('Latest Reply'),
'LANG_FORUM'=> lang('Forum'),
'FORUM'=> $forum['name'],
'LANG_SEARCH'=> lang('Search'),
'BACKLINK' => ('<a href="' . $this->link(array('level'
=> 3)) . '">' . lang('Return to message list') . '</a>'),
'LANG_DATE'=> lang('Date'),
'LANG_SUBJECT' => lang('Subject'),
'LANG_THREADS' => lang('Return to forums')
);
$this->template->set_var($var);
//it does not make sense to implement posting in this module, since the forum
app is
//too badly designed to to this in a clean way.
// $var = array(
// 'POST_ACTION' => $this->link(array('level' => 5)),
// 'LANG_REPLYTOPIC' => lang('Post A Message To This
Thread').':',
// 'LANG_MESSAGE' => lang('Message'),
// 'LANG_SUBMIT'=> lang('Submit')
// );
// $this->template->set_var($var);
// $this->template->parse('POST_TEMPLATE','post_template',True);
$post_ul = '';
$pre_ul = '';
$messages = $this->bo->read_msg($cat['id'],$forum['id'],$msg);
while($messages && list($key,$message) = each($messages))
{
if($message['id'] == $msg)
{
$var = Array(
'THREAD'=> $message['thread'],
'DEPTH'=> $message['depth'],
'RE_SUBJECT' => (!strpos('
'.strtoupper($message['subject']),'RE: ')?'RE: ':'').$message['subject']
);
$this->template->set_var($var);
}
$var = Array(
'AUTHOR'=>
($message['thread_owner']?$GLOBALS['phpgw']->common->grab_owner_name($message['thread_owner']):lang('Unknown')),
'POSTDATE'=>
$GLOBALS['phpgw']->common->show_date($GLOBALS['phpgw']->db->from_timestamp($message['postdate'])),
'SUBJECT_LINK' => $this->link(Array(
'msg' => $message['id'],
'pos' => $message['pos']
)),
'SUBJECT'=> $message['subject'],
'MESSAGE' =>
nl2br($message['message']),
'NAME'=> $message['name'],
'EMAIL'=> $message['email']
);
if($key > 0)
{
for($i=$depth,$pre_ul='',$post_ul='';$i<($message['depth'] -
1);$i++,$pre_ul.='<ul>',$post_ul.='</ul>')
{
}
$this->template->set_var('UL_PRE',$pre_ul);
}
else
{
$depth = $message['depth'] - 1;
}
$this->template->set_var($var);
$this->template->parse('MESSAGE_TEMPLATE','msg_template',True);
$this->template->set_var('UL_PRE','');
}
if($post_ul)
{
$this->template->set_var('UL_POST',$post_ul);
}
$this->template->parse('Out','read_body');
return $this->template->get('Out');
}
}
--- NEW FILE ---
<?php
class module_galerie extends Module
{
function module_galerie()
{
$this->name = 'galerie';
$this->arguments = array(
'imagedirurl' => array(
'type' => 'textfield',
'label' => 'URL pointing to the directory where
the images are found (no trailing slash)'
),
'imagedirpath' => array(
'type' => 'textfield',
'label' => 'Filesystem path of the directory
where the images are found (no trailing slash)'
),
'imagename' => array(
'type' => 'textfield',
'label' => 'the images\' common name'
),
'imagetype' => array(
'type' => 'select',
'label' => 'image type',
'options' => array(
'jpeg' => 'jpeg',
'gif' => 'gif',
'png' => 'png'
)
),
);
$this->title = "Galerie";
$this->post = array(
'prev' => array(
'type' => 'submit',
'value' => "<---"
),
'next' => array(
'type' => 'submit',
'value' => "--->"
)
);
$this->session = array('filenumber');
$this->description = "A simple picture galery";
}
function get_user_interface()
{
$this->set_subtext_args();
return parent::get_user_interface();
}
function get_translation_interface($fromblock,$toblock)
{
$this->set_subtext_args();
return parent::get_translation_interface($fromblock,$toblock);
}
function set_subtext_args()
{
$defaults = $this->block->arguments;
if ($defaults['imagedirpath'] &&
is_dir($defaults['imagedirpath']))
{
$i = 1;
$this->arguments['subtext'] = array(
'type' => "array",
'i18n' => True
);
while (file_exists($defaults['imagedirpath'] . SEP .
$defaults['imagename'] . $i . '.' . $defaults['imagetype']))
{
$this->arguments['subtext'][$i-1] = array(
'type' => 'textfield',
'label' => 'Subtext for image ' . $i .
'<br /><img src="' .
$defaults['imagedirurl'] . SEP
. $defaults['imagename'] . $i . '.' . $defaults['imagetype'] . '" />',
'i18n' => True
);
$i++;
}
}
}
function set_block($block,$produce=False)
{
parent::set_block($block,$produce);
if ($produce)
{
if (!$this->block->arguments['filenumber'])
{
$this->block->arguments['filenumber'] = 1;
}
else
{
$this->block->arguments['filenumber'] =
(int)$this->block->arguments['filenumber'];
}
if ($this->block->arguments['next'])
{
$this->block->arguments['filenumber']++;
}
elseif ($this->block->arguments['prev'])
{
$this->block->arguments['filenumber']--;
}
if ($this->block->arguments['filenumber'] < 1 ||
!file_exists(
$this->block->arguments['imagedirpath']
. SEP . $this->block->arguments['imagename'] .
$this->block->arguments['filenumber'] .
'.' . $this->block->arguments['imagetype']
))
{
$this->block->arguments['filenumber'] = 1;
}
$prevlink = ($this->block->arguments['filenumber'] > 1)
? $this->build_post_element('prev') : '';
$nextlink =
(file_exists(
$this->block->arguments['imagedirpath']
. SEP . $this->block->arguments['imagename'] .
($this->block->arguments['filenumber']
+ 1) . '.' . $this->block->arguments['imagetype']
)) ?
$this->build_post_element('next') :
'';
require_once(PHPGW_INCLUDE_ROOT . SEP . 'sitemgr' . SEP
. 'inc' . SEP . 'class.browser_transform.inc.php');
$this->add_transformer(new
browser_transform($prevlink,$nextlink,$this->name));
}
}
function get_content(&$arguments,$properties)
{
$content .= '<div align="center"><img hspace="20"
align="absmiddle" src="'. $arguments['imagedirurl'] . SEP .
$arguments['imagename'] . $arguments['filenumber'] . '.' .
$arguments['imagetype'] . '" /></div>';
$content .= '<div align="center" style="margin:5mm">' .
$arguments['subtext'][$arguments['filenumber']-1] . '</div><div
align="center">';
return $content;
}
}
--- NEW FILE ---
<?php
class module_google extends Module
{
function module_google()
{
$this->arguments = array();
$this->properties = array();
$this->title = "Google";
$this->description = "Interface to Google website";
}
function get_content(&$arguments,$properties)
{
$content = '<form action="http://www.google.com/search"
name=f>';
$content .= '<img src="images/Google_25wht.gif" border="0"
align="middle" hspace="0" vspace="0"><br>';
$content .= '<center><input type=hidden name=hl value=en>';
$content .= '<input type=hidden name=ie value="ISO-8859-1">';
$content .= '<input maxLength=256 size=15 name=q value=""><br>';
$content .= '<input type=submit value="' . lang('Google
Search') . '" name=btnG></center>';
$content .= '</form>';
return $content;
}
}
--- NEW FILE ---
<?php
class module_hello extends Module
{
function module_hello()
{
$this->name = "hello";
$this->arguments = array(
'name' => array(
'type' => 'textfield',
'label' => 'The person to say hello to'
)
);
$this->post = array('name' => array('type' => 'textfield'));
$this->session = array('name');
$this->title = "Hello world";
$this->description = "This is a simple sample module";
}
function get_content(&$arguments,$properties)
{
$this->validate($arguments);
return lang('Hello') . ' ' . $arguments['name'] . '<br><form
action="' .
$_SERVER['REQUEST_URI'] . '" method="post">' .
$this->build_post_element('name',lang('Enter a name')) .
'</form>';
}
function validate(&$data)
{
if (preg_match("/[[:upper:]]/",$data['name']))
{
$data['name'] = strtolower($data['name']);
$this->validation_error = "Name has been translated to
lower case";
}
return true;
}
}
--- NEW FILE ---
<?php
class module_html extends Module
{
function module_html()
{
$this->arguments = array(
'htmlcontent' => array(
'type' => 'textarea',
'label' => 'Enter the page content
here',
'i18n' => True,
'params' => Array('cols' => 50, 'rows'
=> 15)
)
);
$this->properties = array('striphtml' => array('type'
=> 'checkbox', 'label' => 'Strip HTML from block content?'));
$this->title = "HTML module";
$this->description = "This module is a simple HTML
editor";
}
function get_content(&$arguments,$properties)
{
return $properties['striphtml'] ?
$GLOBALS['phpgw']->strip_html($arguments['htmlcontent']) :
$arguments['htmlcontent'];
}
}
--- NEW FILE ---
<?php
class module_index extends Module
{
function module_index()
{
$this->arguments = array();
$this->title = "Site Index";
$this->description = "This module provides the site
index, it is automatically used by the index GET parameter";
}
function get_content(&$arguments,$properties)
{
global $objbo;
$indexarray = $objbo->getIndex();
$content = "\n".
'<table border="0" width="100%" align="left"
cellspacing="1" cellpadding="0">
<tr>';
$catname = '';
foreach($indexarray as $temppage)
{
$buffer = str_pad('',
$temppage['catdepth']*24,' ');
if ($catname!=$temppage['catname']) //category
name change
{
if ($catname!='') //not the first name
change
{
$content .=
'<br><br></td></tr></table></td></tr><tr>';
}
$content .= '<td>
<table border="0" width="100%"
cellspacing="0" align="left" cellpadding="0">
<tr><td>'.$buffer.'</td>
<td width="100%">';
$catname = $temppage['catname'];
if ($temppage['catdepth'])
{
$content .= '· ';
}
$content .= '<b>'.$catname.'</b>
– <i>'.
$temppage['catdescrip'].'</i>'."\n";
}
$content .=
"\n".'<br> · '.$temppage['pagelink'];
}
$content .= "\n".'</td></tr></table></td></tr></table>';
if (count($indexarray)==0)
{
$content=lang('You do not have access to any
content on this site.');
}
return $content;
}
}
?>
--- NEW FILE ---
<?php
class module_index_block extends Module
{
function module_index_block()
{
$this->arguments = array();
$this->title = "Root Site Index";
$this->description = "This module displays the root categories,
meant for side areas";
}
function get_content(&$arguments,$properties)
{
global $objbo;
$indexarray = $objbo->getIndex(false,true);
$content = "\n".'<table border="0" cellspacing="0"
cellpadding="0" width="100%">';
$catname = '';
foreach($indexarray as $page)
{
if ($catname!=$page['catname']) //category name change
{
if ($catname=='')
{
$break = '';
}
else
{
$break = '<br>';
}
$catname = $page['catname'];
$content.="\n".'<tr><td width="15%"
colspan="2">'.$break.' <b>'.
$page['catlink'].'</b></td></tr>'."\n";
}
if (!$page['hidden'])
{
$content .= "\n".'<tr><td align="right"
valign="top" width="15%">'.
'· </td><td>'.$page['pagelink'].'</td></tr>';
}
}
$content .= "\n</table>";
$content .= '<br> <i><a
href="'.sitemgr_link2('/index.php','index=1').'"><font size="1">(' . lang('View
full index') . ')</font></a></i>';
if (count($indexarray)==0)
{
$content=lang('You do not have access to any content on
this site.');
}
return $content;
}
}
?>
--- NEW FILE ---
<?php
class module_lang_block extends Module
{
function module_lang_block()
{
$this->arguments = array();
$this->properties = array();
$this->title = "Choose language";
$this->description = "This module lets users choose
language";
}
function get_content(&$arguments,$properties)
{
if ($GLOBALS['sitemgr_info']['sitelanguages'])
{
$content = '<form name="langselect"
action="'.$_SERVER['REQUEST_URI'].'" method="post">';
$content .= '<select
onChange="this.form.submit()" name="language">';
foreach
($GLOBALS['sitemgr_info']['sitelanguages'] as $lang)
{
$selected='';
if ($lang ==
$GLOBALS['sitemgr_info']['userlang'])
{
$selected =
'selected="selected" ';
}
$content .= '<option ' . $selected .
'value="' . $lang . '">'. $GLOBALS['Common_BO']->getlangname($lang) .
'</option>';
}
$content .= '</select>';
$content .= '</form>';
return $content;
}
else
{
$content = lang('No sitelanguages configured');
}
}
}
--- NEW FILE ---
<?php
class module_login extends Module
{
function module_login()
{
$this->arguments = array();
$this->properties = array();
$this->title = "Login";
$this->description = "This block displays a login form";
}
function get_content(&$arguments,$properties)
{
$content = '<form name="login"
action="'.phpgw_link('/login.php').'" method="post">';
$content .= '<input type="hidden" name="passwd_type"
value="text">';
$content .= '<input type="hidden" name="phpgw_forward"
value="/sitemgr/">';
$content .= '<center><font class="content">' . lang('Login
Name') .'<br>';
$content .= '<input type="text" name="login" size="8"
value=""><br>';
$content .= lang('Password') . '<br>';
$content .= '<input name="passwd" size="8"
type="password"><br>';
$content .= '<input type="submit" value="' . lang('Login') .'"
name="submitit">';
$content .= '</font></center></form>';
$content .= '<center><font class="content">' . lang("Don't have
an account?") .' ';
$content .= '<a
href="'.phpgw_link('/registration/index.php').'">';
$content .= lang('Register for one now.') .
'</a></font></center>';
return $content;
}
}
--- NEW FILE ---
<?php
class module_meta extends Module
{
function module_meta()
{
$this->arguments = array(
'get' => array(
'type' => 'select',
'label' => 'The type of metainformation to
display',
'options' => array(
'title' => 'Page title',
'subtitle' => 'Page subtitle',
'sitename' => 'Site name',
'footer' => 'Site footer',
'header' => 'Site header',
'user' => 'User name'
)
)
);
$this->title = "Metainformation";
$this->description = "This module provides meta information
about the site and the current page";
}
function get_content(&$arguments,$properties)
{
global $page;
switch ($arguments['get'])
{
case 'title':
return $page->title;
case 'subtitle':
return $page->subtitle;
case 'sitename':
$prefs =
CreateObject('sitemgr.sitePreference_SO');
return
$prefs->getPreference('sitemgr-site-name-' .
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang']);
case 'footer':
return
$GLOBALS['Common_BO']->headerfooter->getsitefooter($GLOBALS['phpgw_info']['user']['preferences']['common']['lang']);
case 'header':
return
$GLOBALS['Common_BO']->headerfooter->getsiteheader($GLOBALS['phpgw_info']['user']['preferences']['common']['lang']);
case 'user':
return
$GLOBALS['phpgw_info']['user']['account_lid'];
}
}
}
--- NEW FILE ---
<?php
class news_transform
{
function apply_transform($title,$content)
{
$t = Createobject('phpgwapi.Template');
$templaterootformat =
$GLOBALS['sitemgr_info']['sitemgr-site-dir']. SEP . 'templates' . SEP . '%s' .
SEP . 'sitemgr' . SEP . 'news';
$themetemplatedir =
sprintf($templaterootformat,$GLOBALS['sitemgr_info']['themesel']);
if (is_dir($themetemplatedir))
{
$t->set_root($themetemplatedir);
}
else
{
$t->set_root(sprintf($templaterootformat,'default'));
}
$t->set_file('news','newsblock.tpl');
$result ='';
while (list(,$newsitem) = @each($content))
{
$t->set_var(array(
'news_title' => $newsitem['subject'],
'news_submitter' =>
$GLOBALS['phpgw']->accounts->id2name($newsitem['submittedby']),
'news_date' =>
$GLOBALS['phpgw']->common->show_date($newsitem['submissiondate']),
'news_content' =>
nl2br($newsitem['content'])
));
$result .= $t->parse('out','news');
}
return $result;
}
}
class module_news extends Module
{
function module_news()
{
//specification of options is postponed into the
get_user_interface function
$this->arguments = array('category' => array('type' =>
'select', 'label' => 'Choose a category', 'options' => array()));
$this->properties = array();
$this->title = "News module";
$this->description = "This module is just a first trial
of hooking news_admin into sitmgr's new architecture.";
}
function get_user_interface()
{
//we could put this into the module's constructor, but
by putting it here, we make it execute only when the block is edited,
//and not when it is generated for the web site, thus
speeding the latter up slightly
$cat =
createobject('phpgwapi.categories','','news_admin');
$cats = $cat->return_array('mains',0);
$cat_ids = array(0 => 'Mains');
while (list(,$category) = @each($cats))
{
$cat_ids[$category['id']] = $category['name'];
}
$this->arguments['category']['options'] = $cat_ids;
return parent::get_user_interface();
}
function set_block($block,$produce=False)
{
parent::set_block($block,$produce);
if ($produce)
{
$this->add_transformer(new news_transform());
}
}
function get_content(&$arguments,$properties)
{
$bonews = CreateObject('news_admin.bonews');
return $bonews->get_NewsList($arguments['category'],
false);
}
}
--- NEW FILE ---
<?php
class module_sitetree extends Module
{
function module_sitetree()
{
$this->name = "sitetree";
$this->arguments = array();
$this->properties = array();
$this->cookie = array('menutree');
$this->title = "Site Tree Menu";
$this->description = "This block displays a javascript based
tree menu";
$this->expandedcats;
}
function showcat($cats)
{
while(list($cat_id,$cat) = each($cats))
{
$status = in_array($cat_id,$this->expandedcats);
$childrenandself =
array_keys($GLOBALS['objbo']->getCatLinks($cat_id));
$childrenandself[] = $cat_id;
$catcolour =
in_array($GLOBALS['page']->cat_id,$childrenandself) ? "red" : "black";
$tree .= "\n" .
'<tr><td width="10%">' .
'<img src="images/tree_' .
($status ? "collapse" : "expand") .
'.gif" onclick="toggle(this, \'' .
$cat_id .
'\')"></td><td><b title="' .
$cat['description'] .
'" style="color:' .
$catcolour .
'">'.
$cat['name'] .
'</b></td></tr>' .
"\n";
$subcats =
$GLOBALS['objbo']->getCatLinks($cat_id,False);
$pages = $GLOBALS['objbo']->getPageLinks($cat_id);
if ($subcats || $pages)
{
$tree .= '<tr><td></td><td><table
style="display:' .
($status ? "block" : "none") .
'" border="0" cellspacing="0"
cellpadding="0" width="100%" id="'.
$cat_id .
'">';
while(list($page_id,$page) = @each($pages))
{
//we abuse the subtitle in a
nonstandard way: we want it to serve as a *short title* that is displayed
//in the tree menu, so that we can have
long titles on the page that would not be nice in the tree menu
$title = $page['subtitle'] ?
$page['subtitle'] : $page['title'];
$tree .= '<tr><td colspan="2">' .
(($page_id ==
$GLOBALS['page']->id) ?
('<span
style="color:red">' . $title . '</span>') :
('<a href="' .
sitemgr_link('page_name='. $page['name']) . '">' . $title . '</a>')
) .
'</td></tr>';
}
if ($subcats)
{
$tree .=
$this->showcat($GLOBALS['objbo']->getCatLinks($cat_id,False));
}
$tree .= '</table></td></tr>';
}
}
return $tree;
}
function get_content(&$arguments,$properties)
{
$title = '';
if ($arguments['menutree'])
{
$this->expandedcats =
array_keys($arguments['menutree']);
}
else
{
$this->expandedcats = Array();
}
$topcats = $GLOBALS['objbo']->getCatLinks(0,False);
$content = "<script type='text/javascript'>
// the whole thing only works in a DOM capable browser or IE 4*/
function add(catid)
{
document.cookie = '".$this->name."[menutree][' + catid + ']=';
}
function remove(catid)
{
var now = new Date();
document.cookie = '".$this->name."[menutree][' + catid + ']=; expires='
+ now.toGMTString();
}
function toggle(image, catid)
{
if (document.getElementById)
{ //DOM capable
styleObj = document.getElementById(catid);
}
else //we're helpless
{
return
}
if (styleObj.style.display == 'none')
{
add(catid);
image.src = 'images/tree_collapse.gif';
styleObj.style.display = 'block';
}
else
{
remove(catid);
image.src = 'images/tree_expand.gif';
styleObj.style.display = 'none';
}
}
</script>";
if (count($topcats)==0)
{
$content=lang('You do not have access to any content on
this site.');
}
else
{
$content .= "\n" .
'<table border="0" cellspacing="0"
cellpadding="0" width="100%">' .
$this->showcat($topcats) .
'</table>' .
"\n";
$content .= '<br><a
href="'.sitemgr_link('toc=1').'"><font size="1">(' . lang('Table of contents')
. ')</font></a>';
}
return $content;
}
}
--- NEW FILE ---
<?php
class module_toc extends Module
{
function module_toc()
{
$this->arguments = array('category_id' => array('type'
=> 'textfield', 'label' => 'The category to display, 0 for complete table of
contents'));
$this->title = "Table of contents";
$this->description = "This module provides a complete
table of contents, it is automatically used by the toc and category_id GET
parameters";
}
function get_content(&$arguments,$properties)
{
global $objbo;
$category_id = $arguments['category_id'];
if ($category_id)
{
if($objbo->acl->can_read_category($category_id))
{
$links =
$objbo->getPageLinks($category_id,true);
$cat =
$objbo->getcatwrapper($category_id);
$content = '';
if ($cat)
{
$content .= '<b><a
href="'.sitemgr_link2('/index.php','toc=1').'">' . lang('Up to table of
contents') . '</a></b>';
if ($cat->depth)
{
$content .= ' | <b><a
href="'.sitemgr_link2('/index.php','category_id='.$cat->parent).'">' . lang('Up
to parent') . '</a></b>';
}
$children =
$objbo->getCatLinks((int) $category_id,false);
if (count($children))
{
$content .=
'<br><br><b>' . lang('Subcategories') . ':</b><br>';
foreach ($children as
$child)
{
$content .=
'<br> · <b>'.
$child['link'].'</b> – '.$child['description'];
}
}
$content .= '<br><br><b>' .
lang('Pages') . ':</b><br>';
$links =
$objbo->getPageLinks($category_id,true);
if (count($links)>0)
{
foreach($links as $pg)
{
$content .=
"\n<br>".
' · '.$pg['link'];
if
(!empty($pg['subtitle']))
{
$content .= ' – <i>'.$pg['subtitle'].'</i>';
}
$content .= '';
}
}
else
{
$content .= '<li>' .
lang('There are no pages in this section') . '</li>';
}
}
else
{
$content = lang('There was an
error accessing the requested page. Either you do not have permission to view
this page, or the page does not exist.');
}
}
else
{
$content = lang('There was an error
accessing the requested page. Either you do not have permission to view this
page, or the page does not exist.');
}
}
else
{
$content = '<b>' . lang('Choose a category') .
':</b><br>';
$links = $objbo->getCatLinks();
if (count($links)>0)
{
foreach($links as $cat)
{
$buffer = str_pad('',
$cat['depth']*24,' ').'· ';
if (!$cat['depth'])
{
$buffer =
'<br>'.$buffer;
}
$content .=
"\n".$buffer.$cat['link'].' — <i>'.$cat['description'].
'</i><br>';
}
}
else
{
$content .= lang('There are no sections
available to you.');
}
}
return $content;
}
}
?>
--- NEW FILE ---
<?php
class module_toc_block extends Module
{
function module_toc_block()
{
$this->arguments = array();
$this->title = "Table of contents";
$this->description = "This module provides a condensed table of
contents, meant for side areas";
}
function get_content(&$arguments,$properties)
{
global $objbo;
$indexarray = $objbo->getCatLinks();
$content = "\n".'<table border="0" cellspacing="0"
cellpadding="0" width="100%">'.
'<tr><td>';
foreach($indexarray as $cat)
{
$space = str_pad('',$cat['depth']*18,' ');
$content .= "\n".'<table border="0" cellspacing="0"
cellpadding="0" '.
'width="100%"><tr><td align="right"
valign="top" width="5">'.
$space.'· </td><td
width="100%"><b>'.
$cat['link'].'</b></td></tr></table>';
}
$content .= "\n</td></tr></table>";
if (count($indexarray)==0)
{
$content=lang('You do not have access to any content on
this site.');
}
return $content;
}
}
?>
--- NEW FILE ---
<?php
class module_xml extends Module
{
var $filenumber;
function module_xml()
{
$this->name = 'xml';
$this->arguments = array(
'dirpath' => array('type' => 'textfield', 'label' =>
'Filesystem path of the directory where XML files are stored'),
'filename' => array('type' => 'textfield', 'label' =>
'the XML files\' common name'),
'xsltfile' => array('type' => 'textfield', 'label' =>
'Full path of the XSLT file that should be applied to the XML files')
);
$this->post = array(
'prev' => array(
'type' => 'submit',
'value' => lang('Previous')
),
'next' => array(
'type' => 'submit',
'value' => lang('Next')
)
);
$this->session = array('filenumber');
$this->title = "XML browser";
$this->description = "This module permits browsing through XML
files stored in a directory, and transformed by XSLT";
}
function set_block($block,$produce=False)
{
parent::set_block($block,$produce);
if ($produce)
{
if (!$this->block->arguments['filenumber'])
{
$this->block->arguments['filenumber'] = 1;
}
else
{
$this->block->arguments['filenumber'] =
(int)$this->block->arguments['filenumber'];
}
if ($this->block->arguments['next'])
{
$this->block->arguments['filenumber']++;
}
elseif ($this->block->arguments['prev'])
{
$this->block->arguments['filenumber']--;
}
if ($this->block->arguments['filenumber'] < 1 ||
!file_exists(
$this->block->arguments['dirpath'] .
SEP . $this->block->arguments['filename'] .
$this->block->arguments['filenumber'] .
'.xml'
))
{
$this->block->arguments['filenumber'] = 1;
}
require_once(PHPGW_INCLUDE_ROOT . SEP . 'sitemgr' . SEP
. 'inc' . SEP . 'class.xslt_transform.inc.php');
$this->add_transformer(new
xslt_transform($this->block->arguments['xsltfile']));
$prevlink = ($this->block->arguments['filenumber'] > 1)
? $this->build_post_element('prev') : '';
$nextlink =
(file_exists(
$this->block->arguments['dirpath'] .
SEP . $this->block->arguments['filename'] .
($this->block->arguments['filenumber']
+ 1) . '.xml'
)) ?
$this->build_post_element('next') :
'';
require_once(PHPGW_INCLUDE_ROOT . SEP . 'sitemgr' . SEP
. 'inc' . SEP . 'class.browser_transform.inc.php');
$this->add_transformer(new
browser_transform($prevlink,$nextlink,$this->name));
}
}
function get_content(&$arguments,$properties)
{
return implode('',@file($arguments['dirpath'] . SEP .
$arguments['filename'] . $arguments['filenumber'] . '.xml'));
}
}
***** Error reading new file: [Errno 2] No such file or directory:
'class.xmltool2.inc.php'
--- NEW FILE ---
<?php
class xslt_transform
{
var $arguments;
function xslt_transform($xsltfile)
{
$this->xsltfile = $xsltfile;
}
function apply_transform($title,$content)
{
$xh = xslt_create();
$xsltarguments = array('/_xml' => $content);
$result = xslt_process($xh, 'arg:/_xml', $this->xsltfile, NULL,
$xsltarguments);
xslt_free($xh);
return $result;
}
}
Index: class.ACL_BO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.ACL_BO.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** class.ACL_BO.inc.php 29 Aug 2002 03:03:17 -0000 1.1.1.1
--- class.ACL_BO.inc.php 17 Jan 2003 03:37:52 -0000 1.2
***************
*** 72,75 ****
--- 72,81 ----
}
+ function copy_permissions($fromcat,$tocat)
+ {
+ $this->remove_location($tocat);
+ $this->acl_so->copy_rights('L'.$fromcat,'L'.$tocat);
+ }
+
function grant_permissions($user, $category_id, $can_read,
$can_write)
{
***************
*** 153,157 ****
//$this->acl =
CreateObject('phpgwapi.acl',$this->logged_in_user);
//return
($this->acl->get_rights($account_id,'L'.$category_id) & PHPGW_ACL_ADD);
! return
($this->acl_so->get_permission('L'.$category_id) & PHPGW_ACL_ADD);
}
}
--- 159,166 ----
//$this->acl =
CreateObject('phpgwapi.acl',$this->logged_in_user);
//return
($this->acl->get_rights($account_id,'L'.$category_id) & PHPGW_ACL_ADD);
! // if category_id = 0, we are in site-wide
scope, and only admin can add content
! return $category_id ?
!
($this->acl_so->get_permission('L'.$category_id) & PHPGW_ACL_ADD) :
! $this->is_admin();
}
}
Index: class.ACL_SO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.ACL_SO.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** class.ACL_SO.inc.php 11 Sep 2002 22:39:28 -0000 1.2
--- class.ACL_SO.inc.php 17 Jan 2003 03:37:52 -0000 1.3
***************
*** 49,52 ****
--- 49,62 ----
}
+ function copy_rights($fromlocation,$tolocation)
+ {
+ $sql = 'select acl_account,acl_rights from phpgw_acl where
acl_appname=\'sitemgr\' and acl_location=\''.$fromlocation.'\'';
+ $this->db->query($sql,__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+
$this->acl->add_repository('sitemgr',$tolocation,$this->db->f('acl_account'),$this->db->f('acl_rights'));
+ }
+ }
+
function remove_location($location)
{
Index: class.Block_SO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Block_SO.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.Block_SO.inc.php 6 Dec 2002 04:57:18 -0000 1.1
--- class.Block_SO.inc.php 17 Jan 2003 03:37:52 -0000 1.2
***************
*** 3,14 ****
{
var $id;
! var $filename;
! var $side;
! var $pos;
var $title;
var $view;
- var $description;
var $actif;
!
function Block_SO()
{
--- 3,18 ----
{
var $id;
! var $cat_id;
! var $page_id;
! var $area;
! var $module_id;
! var $app_name;
! var $module_name;
! var $arguments;
! var $sort_order;
var $title;
var $view;
var $actif;
!
function Block_SO()
{
Index: class.Categories_BO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Categories_BO.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** class.Categories_BO.inc.php 5 Dec 2002 22:15:00 -0000 1.5
--- class.Categories_BO.inc.php 17 Jan 2003 03:37:52 -0000 1.6
***************
*** 3,48 ****
{
var $so;
- var $acl;
function Categories_BO()
{
$this->so = CreateObject('sitemgr.Categories_SO', True);
- $this->acl = CreateObject('sitemgr.ACL_BO');
}
- function needUpdateCategories()
- {
- $prefs = CreateObject('sitemgr.sitePreference_SO');
- if ($prefs->getPreference('catsupdated'))
- {
- return False;
- }
- else
- {
- // if there is no table
phpgw_sitemgr_categories we do not need and update
- $table_names =
$GLOBALS['phpgw']->db->table_names();
- foreach ($table_names as $table)
- {
- if ($table['table_name'] ==
'phpgw_sitemgr_categories')
- {
- return True;
- }
- }
- $prefs->setPreference('catsupdated','True');
- return False;
- }
- }
-
- function updateCategories()
- {
- $prefs = CreateObject('sitemgr.sitePreference_SO');
- $db_so = CreateObject('sitemgr.Categories_db_SO');
- $rv = $db_so->convert_to_phpgwapi();
- $prefs->setPreference('catsupdated','True');
- unset($db_so);
- unset($prefs);
- return $rv;
- }
-
function getCategoryOptionList()
{
--- 3,13 ----
{
var $so;
function Categories_BO()
{
+ //all sitemgr BOs should be instantiated via a
globalized Common_BO object,
$this->so = CreateObject('sitemgr.Categories_SO', True);
}
function getCategoryOptionList()
{
***************
*** 76,81 ****
}
! $root_list = $this->so->getFullChildrenIDList($cat_id);
!
$permitted_list=array();
if (is_array($root_list))
--- 41,45 ----
}
! $root_list = $this->so->getChildrenIDList($cat_id);
$permitted_list=array();
if (is_array($root_list))
***************
*** 85,93 ****
if ($check=='read')
{
! $permitted =
$this->acl->can_read_category($root_cat);
}
elseif ($check=='write')
{
! $permitted =
$this->acl->can_write_category($root_cat);
}
else
--- 49,57 ----
if ($check=='read')
{
! $permitted =
$GLOBALS['Common_BO']->acl->can_read_category($root_cat);
}
elseif ($check=='write')
{
! $permitted =
$GLOBALS['Common_BO']->acl->can_write_category($root_cat);
}
else
***************
*** 99,124 ****
{
$permitted_list[]=$root_cat;
! $sub_list =
$this->getPermittedCatNested($root_cat,$check);
! if (is_array($sub_list) &&
count($sub_list)>0)
! {
!
//array_push($permitted_list, $sub_list);
!
$permitted_list=array_merge($permitted_list, $sub_list);
! }
}
}
}
return $permitted_list;
}
! function getPermittedCategoryIDWriteList($cat_id='')
{
! if (is_int($cat_id))
! {
! $full_list =
$this->so->getChildrenIDList($cat_id);
! }
! else
! {
! $full_list = $this->so->getFullcategoryIDList();
! }
$permitted_list=array();
if (is_array($full_list))
--- 63,85 ----
{
$permitted_list[]=$root_cat;
! }
! //subcategories can be
readable/writeable even when parent is not
! $sub_list =
$this->getPermittedCatNested($root_cat,$check);
! if (is_array($sub_list) &&
count($sub_list)>0)
! {
! //array_push($permitted_list,
$sub_list);
!
$permitted_list=array_merge($permitted_list, $sub_list);
}
}
}
+ //print_r($permitted_list);
return $permitted_list;
}
! //the next two functions do not recurse!
! function getPermittedCategoryIDWriteList($cat_id=0)
{
! $full_list = $this->so->getChildrenIDList($cat_id);
!
$permitted_list=array();
if (is_array($full_list))
***************
*** 126,130 ****
foreach($full_list as $item)
{
! if
($this->acl->can_write_category($item))
{
$permitted_list[]=$item;
--- 87,91 ----
foreach($full_list as $item)
{
! if
($GLOBALS['Common_BO']->acl->can_write_category($item))
{
$permitted_list[]=$item;
***************
*** 135,148 ****
}
! function getPermittedCategoryIDReadList($cat_id='')
{
! if (is_int($cat_id))
! {
! $full_list =
$this->so->getChildrenIDList($cat_id);
! }
! else
! {
! $full_list = $this->so->getFullcategoryIDList();
! }
$permitted_list=array();
if (is_array($full_list))
--- 96,103 ----
}
! function getPermittedCategoryIDReadList($cat_id=0)
{
! $full_list = $this->so->getChildrenIDList($cat_id);
!
$permitted_list=array();
if (is_array($full_list))
***************
*** 151,155 ****
foreach($full_list as $item)
{
! if
($this->acl->can_read_category($item))
{
$permitted_list[]=$item;
--- 106,110 ----
foreach($full_list as $item)
{
! if
($GLOBALS['Common_BO']->acl->can_read_category($item))
{
$permitted_list[]=$item;
***************
*** 162,166 ****
function addCategory($name, $description, $parent=0)
{
! if ($this->acl->is_admin())
{
return $this->so->addCategory($name,
$description, $parent);
--- 117,121 ----
function addCategory($name, $description, $parent=0)
{
! if ($GLOBALS['Common_BO']->acl->is_admin())
{
return $this->so->addCategory($name,
$description, $parent);
***************
*** 174,188 ****
function removeCategory($cat_id)
{
! if ($this->acl->is_admin())
{
/********************************************\
* We have to remove the category, all the *
* associated pages, and all the associated *
! * acl stuff too. *
\********************************************/
$this->so->removeCategory($cat_id);
! $this->acl->remove_location($cat_id);
! $pages_so = CreateObject('sitemgr.Pages_SO');
! $pages_so->removePagesInCat($cat_id);
return True;
}
--- 129,143 ----
function removeCategory($cat_id)
{
! if ($GLOBALS['Common_BO']->acl->is_admin())
{
/********************************************\
* We have to remove the category, all the *
* associated pages, and all the associated *
! * acl stuff too. not to forget blocks *
\********************************************/
$this->so->removeCategory($cat_id);
!
$GLOBALS['Common_BO']->acl->remove_location($cat_id);
!
$GLOBALS['Common_BO']->pages->removePagesInCat($cat_id);
!
$GLOBALS['Common_BO']->content->removeBlocksInPageOrCat($cat_id,0);
return True;
}
***************
*** 206,210 ****
}
! if ($this->acl->can_write_category($cat_id))
{
if ($this->so->saveCategory($cat_info));
--- 161,165 ----
}
! if
($GLOBALS['Common_BO']->acl->can_write_category($cat_id))
{
if ($this->so->saveCategory($cat_info));
***************
*** 235,239 ****
function getCategory($cat_id,$lang=False)
{
! if ($this->acl->can_read_category($cat_id))
{
return $this->so->getCategory($cat_id,$lang);
--- 190,194 ----
function getCategory($cat_id,$lang=False)
{
! if
($GLOBALS['Common_BO']->acl->can_read_category($cat_id))
{
return $this->so->getCategory($cat_id,$lang);
***************
*** 245,248 ****
--- 200,218 ----
}
+ function getCategoryancestorids($cat_id,$permittedonly=False)
+ {
+ $result = array();
+ while ($cat_id != 0)
+ {
+ if (!$permittedonly ||
$GLOBALS['Common_BO']->acl->can_read_category($cat_id))
+ {
+ $result[] = $cat_id;
+ }
+ $cat_info = $this->so->getCategory($cat_id);
+ $cat_id = $cat_info->parent;
+ }
+ return $result;
+ }
+
function getlangarrayforcategory($cat_id)
{
***************
*** 252,259 ****
function saveCategoryPerms($cat_id, $group_access, $user_access)
{
! if ($this->acl->is_admin())
{
!
$group_access=array_merge_recursive($this->acl->get_simple_group_list(),$group_access);
!
$user_access=array_merge_recursive($this->acl->get_simple_user_list(),$user_access);
$this->saveCatPermsGeneric($cat_id,
$group_access);
$this->saveCatPermsGeneric($cat_id,
$user_access);
--- 222,229 ----
function saveCategoryPerms($cat_id, $group_access, $user_access)
{
! if ($GLOBALS['Common_BO']->acl->is_admin())
{
!
$group_access=array_merge_recursive($GLOBALS['Common_BO']->acl->get_simple_group_list(),$group_access);
!
$user_access=array_merge_recursive($GLOBALS['Common_BO']->acl->get_simple_user_list(),$user_access);
$this->saveCatPermsGeneric($cat_id,
$group_access);
$this->saveCatPermsGeneric($cat_id,
$user_access);
***************
*** 297,301 ****
}
}
! $this->acl->grant_permissions($acctid,
$cat_id, $can_read, $can_write);
}
}
--- 267,271 ----
}
}
!
$GLOBALS['Common_BO']->acl->grant_permissions($acctid, $cat_id, $can_read,
$can_write);
}
}
***************
*** 303,306 ****
--- 273,296 ----
{
echo 'wth!';
+ }
+ }
+
+ function saveCategoryPermsfromparent($cat_id)
+ {
+ $cat=$this->getCategory($cat_id);
+ $parent=$cat->parent;
+ if ($parent)
+ {
+
$GLOBALS['Common_BO']->acl->copy_permissions($parent,$cat_id);
+ }
+ }
+
+ function applyCategoryPermstosubs($cat_id)
+ {
+ $sublist = $this->getPermittedCatWriteNested($cat_id);
+
+ while (list(,$sub) = @each($sublist))
+ {
+
$GLOBALS['Common_BO']->acl->copy_permissions($cat_id,$sub);
}
}
Index: class.Categories_SO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Categories_SO.inc.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** class.Categories_SO.inc.php 5 Dec 2002 22:15:00 -0000 1.11
--- class.Categories_SO.inc.php 17 Jan 2003 03:37:52 -0000 1.12
***************
*** 21,25 ****
$cats =
$this->cats->return_array('mains','',False,'','','cat_data',False, 0);
}
! while (is_array($cats) && list(,$subs) = each($cats))
{
if ($subs['parent']==$parent)
--- 21,25 ----
$cats =
$this->cats->return_array('mains','',False,'','','cat_data',False, 0);
}
! while (list(,$subs) = @each($cats))
{
if ($subs['parent']==$parent)
***************
*** 31,62 ****
}
- function getFullChildrenIDList($parent = '')
- {
- if (!$parent)
- {
- $parent = 0;
- }
-
- if ($parent == 0)
- {
- $cats =
$this->cats->return_array('mains','',False,'','','cat_data',False, $parent);
- }
- else
- {
- $cats =
$this->cats->return_array('all','',False,'','','cat_data',False,$parent);
- }
-
- while (is_array($cats) && list(,$subs) = each($cats))
- {
- $subs_id_list[] = $subs['id'];
- }
- return $subs_id_list;
- }
-
function getFullCategoryIDList()
{
$cats =
$this->cats->return_array('all','',False,'','','cat_data',False);
! while (is_array($cats) && list(,$cat) = each($cats))
{
$cat_id_list[] = $cat['id'];
--- 31,39 ----
}
function getFullCategoryIDList()
{
$cats =
$this->cats->return_array('all','',False,'','','cat_data',False);
! while (list(,$cat) = @each($cats))
{
$cat_id_list[] = $cat['id'];
***************
*** 116,119 ****
--- 93,97 ----
function getlangarrayforcategory($cat_id)
{
+ $retval = array();
$this->db->query("SELECT lang FROM
phpgw_sitemgr_categories_lang WHERE cat_id='$cat_id'");
while ($this->db->next_record())
Index: class.Common_UI.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Common_UI.inc.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** class.Common_UI.inc.php 5 Dec 2002 22:15:00 -0000 1.7
--- class.Common_UI.inc.php 17 Jan 2003 03:37:52 -0000 1.8
***************
*** 12,16 ****
class Common_UI
{
! var $t, $acl, $theme, $prefs_so, $pages_bo, $cat_bo;
var $public_functions = array
(
--- 12,16 ----
class Common_UI
{
! var $t, $acl, $theme, $prefs_so;
var $public_functions = array
(
***************
*** 20,40 ****
function Common_UI()
{
$this->t = $GLOBALS['phpgw']->template;
! $this->acl = CreateObject('sitemgr.ACL_BO');
! $this->theme = CreateObject('sitemgr.Theme_BO',True);
$this->prefs_so =
CreateObject('sitemgr.sitePreference_SO', True);
! $this->pages_bo = CreateObject('sitemgr.Pages_BO');
! $this->cat_bo = CreateObject('sitemgr.Categories_BO');
}
- //this has to be moved somewhere else later
- function getlangname($lang)
- {
- $GLOBALS['phpgw']->db->query("select lang_name from
languages where lang_id = '$lang'",__LINE__,__FILE__);
- $GLOBALS['phpgw']->db->next_record();
- return $GLOBALS['phpgw']->db->f('lang_name');
- }
-
-
function DisplayPrefs()
{
--- 20,33 ----
function Common_UI()
{
+ global $Common_BO;
+ $Common_BO = CreateObject('sitemgr.Common_BO',True);
$this->t = $GLOBALS['phpgw']->template;
! $this->acl = &$Common_BO->acl;
! $this->theme = &$Common_BO->theme;
$this->prefs_so =
CreateObject('sitemgr.sitePreference_SO', True);
! $this->pages_bo = &$Common_BO->pages;
! $this->cat_bo = &$Common_BO->cats;
}
function DisplayPrefs()
{
***************
*** 49,53 ****
if ($newlang == "delete")
{
! echo '<b>' .
lang('Deleting all data for %1',$this->getlangname($oldlang)) . '</b><br>';
$this->pages_bo->removealllang($oldlang);
$this->cat_bo->removealllang($oldlang);
--- 42,46 ----
if ($newlang == "delete")
{
! echo '<b>' .
lang('Deleting all data for %1',$GLOBALS['Common_BO']->getlangname($oldlang)) .
'</b><br>';
$this->pages_bo->removealllang($oldlang);
$this->cat_bo->removealllang($oldlang);
***************
*** 56,61 ****
{
echo '<b>' .
lang('Migrating data for %1 to %2',
!
$this->getlangname($oldlang),
!
$this->getlangname($newlang)) .
'</b><br>';
$this->pages_bo->migratealllang($oldlang,$newlang);
--- 49,54 ----
{
echo '<b>' .
lang('Migrating data for %1 to %2',
!
$GLOBALS['Common_BO']->getlangname($oldlang),
!
$GLOBALS['Common_BO']->getlangname($newlang)) .
'</b><br>';
$this->pages_bo->migratealllang($oldlang,$newlang);
***************
*** 69,74 ****
{
$preferences = array(
!
'sitemgr-site-url','sitemgr-site-dir','home-page-id','login-domain',
!
'anonymous-user','anonymous-passwd','interface','themesel','sitelanguages');
$oldsitelanguages =
$this->prefs_so->getPreference('sitelanguages');
--- 62,67 ----
{
$preferences = array(
!
'sitemgr-site-url','sitemgr-site-dir','home-page-id',
!
'anonymous-user','anonymous-passwd','themesel','sitelanguages');
$oldsitelanguages =
$this->prefs_so->getPreference('sitelanguages');
***************
*** 96,100 ****
foreach ($replacedlang
as $oldlang)
{
! $oldlangname =
$this->getlangname($oldlang);
echo "<tr><td>"
. $oldlangname . "</td>";
if ($addedlang)
--- 89,93 ----
foreach ($replacedlang
as $oldlang)
{
! $oldlangname =
$GLOBALS['Common_BO']->getlangname($oldlang);
echo "<tr><td>"
. $oldlangname . "</td>";
if ($addedlang)
***************
*** 104,108 ****
echo '<td><input type="radio" name="change[' . $oldlang .
']" value="' . $newlang . '"> Migrate to ' .
!
$this->getlangname($newlang) . "</td>";
}
}
--- 97,101 ----
echo '<td><input type="radio" name="change[' . $oldlang .
']" value="' . $newlang . '"> Migrate to ' .
!
$GLOBALS['Common_BO']->getlangname($newlang) . "</td>";
}
}
***************
*** 134,138 ****
{
$preferences['sitemgr-site-name-' . $lang]
= array(
! 'title'=>lang('Site name'). ' ' .
$this->getlangname($lang),
'note'=>'(This is used chiefly for meta
data and the title bar. If you change the site languages below you have to save
before being able to set this preference for a new language.)',
'default'=>'New sitemgr site'
--- 127,131 ----
{
$preferences['sitemgr-site-name-' . $lang]
= array(
! 'title'=>lang('Site name'). ' ' .
$GLOBALS['Common_BO']->getlangname($lang),
'note'=>'(This is used chiefly for meta
data and the title bar. If you change the site languages below you have to save
before being able to set this preference for a new language.)',
'default'=>'New sitemgr site'
***************
*** 154,162 ****
'options'=>$this->pages_bo->getPageOptionList()
);
! $preferences['login-domain'] = array(
! 'title'=>lang('Anonymous user login
domain'),
! 'note'=>'If you\'re not sure, enter
Default.',
! 'default'=>'Default'
! );
$preferences['anonymous-user'] = array(
'title'=>lang('Anonymous user\'s
username'),
--- 147,156 ----
'options'=>$this->pages_bo->getPageOptionList()
);
! // this does not seem to be used anywhere
! // $preferences['login-domain'] = array(
! // 'title'=>lang('Anonymous user login
domain'),
! // 'note'=>'If you\'re not sure, enter
Default.',
! // 'default'=>'Default'
! // );
$preferences['anonymous-user'] = array(
'title'=>lang('Anonymous user\'s
username'),
***************
*** 169,179 ****
'default'=>'anonymous'
);
- $preferences['interface'] = array(
- 'title'=>lang('Use phpNuke themes
instead of templates'),
- 'note'=>'(This is NOT recommended.)',
- 'input'=>'checkbox'
- );
$preferences['themesel'] = array(
! 'title'=>lang('Theme or template
select'),
'note'=>'(Choose your site\'s theme or
template. Note that if you changed the above checkbox you need to save before
choosing a theme or template.)',
'input'=>'option',
--- 163,168 ----
'default'=>'anonymous'
);
$preferences['themesel'] = array(
! 'title'=>lang('Template select'),
'note'=>'(Choose your site\'s theme or
template. Note that if you changed the above checkbox you need to save before
choosing a theme or template.)',
'input'=>'option',
Index: class.MainMenu_UI.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.MainMenu_UI.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** class.MainMenu_UI.inc.php 6 Dec 2002 04:56:00 -0000 1.5
--- class.MainMenu_UI.inc.php 17 Jan 2003 03:37:52 -0000 1.6
***************
*** 12,15 ****
--- 12,16 ----
class MainMenu_UI
{
+ var $common_ui;
var $t;
var $acl;
***************
*** 21,101 ****
function MainMenu_UI()
{
$this->t = $GLOBALS['phpgw']->template;
! $this->acl = CreateObject('sitemgr.ACL_BO');
}
function DisplayMenu()
{
! $common_ui = CreateObject('sitemgr.Common_UI',True);
! $common_ui->DisplayHeader();
$this->t->set_file('MainMenu','mainmenu.tpl');
- if ($this->acl->is_admin())
- {
- $this->t->set_var(Array('menutitle' =>
lang('Administrative Menu'),
- 'lang_configure' =>
lang('Configure SiteMgr'),
- 'lang_check' =>
lang('check here after every upgrade'),
- 'lang_editheadfoot' =>
lang('Edit Site Header and Footer'),
- 'lang_managecat' =>
lang('Manage Categories'),
- 'lang_manageblocks' =>
lang('Manage Blocks')));
- $catbo = CreateObject('sitemgr.Categories_BO');
- if ($catbo->needUpdateCategories())
- {
- $updatemsg = $catbo->updateCategories();
- $updatemsg = "\n".'<br><b>' .
lang('Updating to new category system') . ':</b><br>'.
- $updatemsg.'<br><b>' .
lang('Done') . '</b><br>';
-
$this->t->set_var('updatecats',$updatemsg);
- }
- else
- {
- $this->t->set_var('updatecats','');
- }
- unset($catbo);
- }
- else
- {
- $this->t->set_var('menutitle',lang('Contributor
Menu'));
- }
! $this->t->set_var('managepage',
! $GLOBALS['phpgw']->link('/index.php',
!
'menuaction=sitemgr.contributor_ManagePage_UI._managePage')
! );
!
! $this->t->set_var('managetranslations',
! $GLOBALS['phpgw']->link('/index.php',
!
'menuaction=sitemgr.ManageTranslations_UI._manageTranslations')
! );
! $this->t->set_var(Array('lang_managepage' =>
lang('Manage Pages'),
! 'lang_managetranslations' =>
lang('Manage Translations')));
if ($this->acl->is_admin())
{
! $this->t->set_var('managecategory',
! $GLOBALS['phpgw']->link('/index.php',
!
'menuaction=sitemgr.Admin_ManageCategories_UI._manageCategories')
! );
! $this->t->set_var('manageblocks',
! $GLOBALS['phpgw']->link('/index.php',
!
'menuaction=sitemgr.ManageBlocks_UI._manageBlocks')
! );
! $this->t->set_var('headerandfooter',
! $GLOBALS['phpgw']->link('/index.php',
!
'menuaction=sitemgr.admin_ManageSiteContent_UI._editHeaderAndFooter')
! );
! $this->t->set_var('setup',
! $GLOBALS['phpgw']->link('/index.php',
!
'menuaction=sitemgr.Common_UI.DisplayPrefs')
! );
}
else
{
! $this->t->set_var('begincomment','<!--');
! $this->t->set_var('endcomment','-->');
}
$this->t->pfp('out','MainMenu');
! $common_ui->DisplayFooter();
}
! }
?>
--- 22,77 ----
function MainMenu_UI()
{
+ $this->common_ui =
CreateObject('sitemgr.Common_UI',True);
$this->t = $GLOBALS['phpgw']->template;
! $this->acl = &$GLOBALS['Common_BO']->acl;
}
function DisplayMenu()
{
! $this->common_ui->DisplayHeader();
$this->t->set_file('MainMenu','mainmenu.tpl');
! $this->t->set_var(Array(
! 'managepage' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Pages_UI._managePage'),
! 'managetranslations' =>
$GLOBALS['phpgw']->link('/index.php',
'menuaction=sitemgr.Translations_UI._manageTranslations'),
! 'managecategory' =>
$GLOBALS['phpgw']->link('/index.php',
'menuaction=sitemgr.Categories_UI._manageCategories'),
! 'lang_managecat' => lang('Manage Categories'),
! 'lang_managepage' => lang('Manage Pages'),
! 'lang_managetranslations' => lang('Manage
Translations')
! ));
if ($this->acl->is_admin())
{
! $this->t->set_var(Array(
! 'menutitle' => lang('Administrative
Menu'),
! 'lang_configure' => lang('Configure
SiteMgr'),
! 'lang_check' => lang('check here after
every upgrade'),
! 'lang_editheadfoot' => lang('Edit Site
Header and Footer'),
! 'lang_managesitemodules' =>
lang('Manage site-wide module properties'),
! 'lang_managesitecontent' =>
lang('Manage Site Content'),
! 'headerandfooter' =>
$GLOBALS['phpgw']->link('/index.php',
'menuaction=sitemgr.SiteContent_UI._editHeaderAndFooter'),
! 'setup' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Common_UI.DisplayPrefs')
! ));
! $link_data['cat_id'] = 0;
! $link_data['menuaction'] =
"sitemgr.Modules_UI._manageModules";
!
$this->t->set_var('managesitemodules',$GLOBALS['phpgw']->link('/index.php',$link_data));
! $link_data['page_id'] = 0;
! $link_data['menuaction'] =
"sitemgr.Content_UI._manageContent";
!
$this->t->set_var('managesitecontent',$GLOBALS['phpgw']->link('/index.php',$link_data));
}
else
{
! $this->t->set_var(Array(
! 'menutitle' => lang('Contributor Menu'),
! 'begincomment' => '<!--',
! 'endcomment' => '-->'
! ));
}
+
$this->t->pfp('out','MainMenu');
! $this->common_ui->DisplayFooter();
}
! }
?>
Index: class.Page_SO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Page_SO.inc.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** class.Page_SO.inc.php 5 Dec 2002 22:15:00 -0000 1.4
--- class.Page_SO.inc.php 17 Jan 2003 03:37:52 -0000 1.5
***************
*** 7,14 ****
var $title;
var $subtitle;
- var $content;
var $sort_order;
var $hidden;
var $lang;
function Page_SO()
--- 7,14 ----
var $title;
var $subtitle;
var $sort_order;
var $hidden;
var $lang;
+ var $block;
function Page_SO()
***************
*** 16,19 ****
--- 16,21 ----
$hidden = 0;
}
+
+
}
?>
Index: class.Pages_BO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Pages_BO.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** class.Pages_BO.inc.php 5 Dec 2002 22:15:00 -0000 1.3
--- class.Pages_BO.inc.php 17 Jan 2003 03:37:52 -0000 1.4
***************
*** 3,12 ****
{
var $pageso;
- var $acl;
function Pages_BO()
{
$this->pageso = CreateObject('sitemgr.Pages_SO',True);
- $this->acl = CreateObject('sitemgr.ACL_BO');
}
--- 3,11 ----
{
var $pageso;
function Pages_BO()
{
+ //all sitemgr BOs should be instantiated via a
globalized Common_BO object,
$this->pageso = CreateObject('sitemgr.Pages_SO',True);
}
***************
*** 25,29 ****
function getPageIDList($cat_id=0)
{
! if ($this->acl->can_read_category($cat_id))
{
return $this->pageso->getPageIDList($cat_id);
--- 24,28 ----
function getPageIDList($cat_id=0)
{
! if
($GLOBALS['Common_BO']->acl->can_read_category($cat_id))
{
return $this->pageso->getPageIDList($cat_id);
***************
*** 37,41 ****
function addPage($cat_id)
{
! if ($this->acl->can_write_category($cat_id))
{
return $this->pageso->addPage($cat_id);
--- 36,40 ----
function addPage($cat_id)
{
! if
($GLOBALS['Common_BO']->acl->can_write_category($cat_id))
{
return $this->pageso->addPage($cat_id);
***************
*** 47,55 ****
}
function removePage($cat_id, $page_id)
{
! if ($this->acl->can_write_category($cat_id))
{
! return $this->pageso->removePage($page_id);
}
else
--- 46,65 ----
}
+ function removePagesInCat($cat_id)
+ {
+ $pages = $this->pageso->getPageIDList($cat_id);
+ while(list(,$page_id) = each($pages))
+ {
+ $this->removePage($cat_id,$page_id);
+ }
+ }
+
function removePage($cat_id, $page_id)
{
! echo "debug $cat_id";
! if
($GLOBALS['Common_BO']->acl->can_write_category($cat_id))
{
! $this->pageso->removePage($page_id);
!
$GLOBALS['Common_BO']->content->removeBlocksInPageOrCat($cat_id,$page_id);
}
else
***************
*** 61,65 ****
function getPage($page_id,$lang=False)
{
! if ($this->acl->can_read_page($page_id))
{
return $this->pageso->getPage($page_id,$lang);
--- 71,75 ----
function getPage($page_id,$lang=False)
{
! if ($GLOBALS['Common_BO']->acl->can_read_page($page_id))
{
return $this->pageso->getPage($page_id,$lang);
***************
*** 71,75 ****
$page->title = lang('Error accessing page');
$page->subtitle = '';
! $page->content = lang('There was an error
accessing the requested page. Either you do not have permission to view this
page, or the page does not exist.');
return $page;
}
--- 81,85 ----
$page->title = lang('Error accessing page');
$page->subtitle = '';
! // $page->content = lang('There was an error
accessing the requested page. Either you do not have permission to view this
page, or the page does not exist.');
return $page;
}
***************
*** 77,87 ****
function getlangarrayforpage($page_id)
! {
! return $this->pageso->getlangarrayforpage($page_id);
}
function savePageInfo($page_Info,$lang)
{
! if (!$this->acl->can_write_category($page_Info->cat_id))
{
return lang("You don't have permission to write
to that category.");
--- 87,97 ----
function getlangarrayforpage($page_id)
! {
! return $this->pageso->getlangarrayforpage($page_id);
}
function savePageInfo($page_Info,$lang)
{
! if
(!$GLOBALS['Common_BO']->acl->can_write_category($page_Info->cat_id))
{
return lang("You don't have permission to write
to that category.");
Index: class.Pages_SO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Pages_SO.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** class.Pages_SO.inc.php 5 Dec 2002 22:15:00 -0000 1.9
--- class.Pages_SO.inc.php 17 Jan 2003 03:37:52 -0000 1.10
***************
*** 38,55 ****
}
- function removePagesInCat($cat_id)
- {
- $db2 = $this->db;
- $sql = 'SELECT page_id FROM phpgw_sitemgr_pages WHERE
cat_id=\''.$cat_id.'\'';
- $db2->query($sql,__LINE__,__FILE__);
- while ($db2->next_record())
- {
- $page_id = $db2->f('page_id');
- $this->db->query("DELETE FROM
phpgw_sitemgr_pages_lang WHERE page_id='$page_id'");
- }
- $sql = 'DELETE FROM phpgw_sitemgr_pages WHERE
cat_id=\''.$cat_id.'\'';
- $this->db->query($sql,__LINE__,__FILE__);
- }
-
function removePage($page_id)
{
--- 38,41 ----
***************
*** 80,91 ****
function getlangarrayforpage($page_id)
! {
! $this->db->query("SELECT lang FROM
phpgw_sitemgr_pages_lang WHERE page_id='$page_id'");
! while ($this->db->next_record())
! {
! $retval[] = $this->db->f('lang');
! }
! return $retval;
! }
function getPageByName($page_name,$lang)
--- 66,78 ----
function getlangarrayforpage($page_id)
! {
! $retval = array();
! $this->db->query("SELECT lang FROM
phpgw_sitemgr_pages_lang WHERE page_id='$page_id'");
! while ($this->db->next_record())
! {
! $retval[] = $this->db->f('lang');
! }
! return $retval;
! }
function getPageByName($page_name,$lang)
***************
*** 107,118 ****
if ($this->db->next_record())
{
! $page->title=
stripslashes($this->db->f('title'));
! $page->subtitle =
stripslashes($this->db->f('subtitle'));
! $page->content =
stripslashes($this->db->f('content'));
}
else
! {
! $page->title = lang("The page %1 has not
yet been translated to %2",$page->name, $lang);
! }
return $page;
}
--- 94,104 ----
if ($this->db->next_record())
{
! $page->title=
stripslashes($this->db->f('title'));
! $page->subtitle =
stripslashes($this->db->f('subtitle'));
}
else
! {
! $page->title = lang("The page %1 has
not yet been translated to %2",$page->name, $lang);
! }
return $page;
}
***************
*** 137,175 ****
if ($lang)
! {
! $sql = "SELECT * FROM
phpgw_sitemgr_pages_lang WHERE page_id='$page_id' and lang='$lang'";
! $this->db->query($sql,__LINE__,__FILE__);
!
! if ($this->db->next_record())
! {
! $page->title=
stripslashes($this->db->f('title'));
! $page->subtitle =
stripslashes($this->db->f('subtitle'));
! $page->content =
stripslashes($this->db->f('content'));
! $page->lang = $lang;
! }
! else
! {
! $page->title = lang("not yet
translated");
! }
! }
//if there is no lang argument we return the
content in whatever languages turns up first
else
! {
! $sql = "SELECT * FROM
phpgw_sitemgr_pages_lang WHERE page_id='" . $page->id . "'";
! $this->db->query($sql,__LINE__,__FILE__);
!
! if ($this->db->next_record())
! {
! $page->title=
stripslashes($this->db->f('title'));
! $page->subtitle =
stripslashes($this->db->f('subtitle'));
! $page->content =
stripslashes($this->db->f('content'));
! $page->lang = $this->db->f('lang');
! }
! else
! {
! $page->title = "This page has no data
in any langugage: this should not happen";
! }
! }
return $page;
--- 123,159 ----
if ($lang)
! {
! $sql = "SELECT * FROM
phpgw_sitemgr_pages_lang WHERE page_id='$page_id' and lang='$lang'";
!
$this->db->query($sql,__LINE__,__FILE__);
!
! if ($this->db->next_record())
! {
! $page->title=
stripslashes($this->db->f('title'));
! $page->subtitle =
stripslashes($this->db->f('subtitle'));
! $page->lang = $lang;
! }
! else
! {
! $page->title = lang("not yet
translated");
! }
! }
//if there is no lang argument we return the
content in whatever languages turns up first
else
! {
! $sql = "SELECT * FROM
phpgw_sitemgr_pages_lang WHERE page_id='" . $page->id . "'";
!
$this->db->query($sql,__LINE__,__FILE__);
!
! if ($this->db->next_record())
! {
! $page->title=
stripslashes($this->db->f('title'));
! $page->subtitle =
stripslashes($this->db->f('subtitle'));
! $page->lang =
$this->db->f('lang');
! }
! else
! {
! $page->title = "This page has
no data in any langugage: this should not happen";
! }
! }
return $page;
***************
*** 187,191 ****
'name=\'' . addslashes($pageInfo->name) . '\','
.
'sort_order=\'' . (int) $pageInfo->sort_order .
'\',' .
! 'hide_page=\'' . $pageInfo->hidden . '\' ' .
'WHERE page_id=\'' . $pageInfo->id . '\'';
$this->db->query($sql, __LINE__,__FILE__);
--- 171,175 ----
'name=\'' . addslashes($pageInfo->name) . '\','
.
'sort_order=\'' . (int) $pageInfo->sort_order .
'\',' .
! 'hide_page=\'' . $pageInfo->hidden . '\' ' .
'WHERE page_id=\'' . $pageInfo->id . '\'';
$this->db->query($sql, __LINE__,__FILE__);
***************
*** 194,220 ****
function savePageLang($pageInfo,$lang)
! {
! $page_id = $pageInfo->id;
! $this->db->query("SELECT * FROM phpgw_sitemgr_pages_lang
WHERE page_id='$page_id' and lang='$lang'", __LINE__,__FILE__);
! if ($this->db->next_record())
! {
! $sql = 'UPDATE phpgw_sitemgr_pages_lang SET ' .
! 'title=\'' . addslashes($pageInfo->title) .
'\',' .
! 'subtitle=\'' . addslashes($pageInfo->subtitle)
. '\',' .
! 'content=\'' . addslashes($pageInfo->content) .
'\' ' .
! "WHERE page_id='$page_id' and lang='$lang'";
! $this->db->query($sql, __LINE__,__FILE__);
! return true;
! }
! else
! {
! $sql = "INSERT INTO phpgw_sitemgr_pages_lang
(page_id,lang,title,subtitle,content) VALUES ('$page_id','$lang','" .
! addslashes($pageInfo->title) . "','" .
! addslashes($pageInfo->subtitle) . "','" .
! addslashes($pageInfo->content) ."')";
! $this->db->query($sql, __LINE__,__FILE__);
! return true;
! }
! }
function removealllang($lang)
--- 178,201 ----
function savePageLang($pageInfo,$lang)
! {
! $page_id = $pageInfo->id;
! $this->db->query("SELECT * FROM
phpgw_sitemgr_pages_lang WHERE page_id='$page_id' and lang='$lang'",
__LINE__,__FILE__);
! if ($this->db->next_record())
! {
! $sql = "UPDATE phpgw_sitemgr_pages_lang SET " .
! "title='" .
addslashes($pageInfo->title) . "'," .
! "subtitle='" .
addslashes($pageInfo->subtitle) . "' WHERE page_id='$page_id' and lang='$lang'";
! $this->db->query($sql, __LINE__,__FILE__);
! return true;
! }
! else
! {
! $sql = "INSERT INTO phpgw_sitemgr_pages_lang
(page_id,lang,title,subtitle) VALUES ('$page_id','$lang','" .
! addslashes($pageInfo->title) . "','" .
! addslashes($pageInfo->subtitle) . "')";
! $this->db->query($sql, __LINE__,__FILE__);
! return true;
! }
! }
function removealllang($lang)
Index: class.Theme_BO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Theme_BO.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** class.Theme_BO.inc.php 7 Sep 2002 02:35:55 -0000 1.3
--- class.Theme_BO.inc.php 17 Jan 2003 03:37:52 -0000 1.4
***************
*** 2,13 ****
class Theme_BO
{
- var $acl;
var $preferenceso;
- var $theme;
function Theme_BO()
{
! $this->acl = CreateObject('ACL', True);
! $this->preferenceso =
CreateObject('sitemgr.sitePreferences_SO', True);
}
--- 2,10 ----
class Theme_BO
{
var $preferenceso;
function Theme_BO()
{
! $this->preferenceso =
CreateObject('sitemgr.sitePreference_SO', True);
}
***************
*** 24,39 ****
function getAvailableThemes()
{
! $pref = CreateObject('sitemgr.sitePreference_SO', True);
! $sitemgr_dir = $pref->getPreference('sitemgr-site-dir');
! $themes = $pref->getPreference('interface');
! if ((int) $themes)
! {
! $interface = 'themes';
! }
! else
! {
! $interface = 'templates';
! }
! $dirname = $sitemgr_dir . '/' . $interface . '/';
$result_array=array();
@$handle=opendir($dirname);
--- 21,26 ----
function getAvailableThemes()
{
! $sitemgr_dir =
$this->preferenceso->getPreference('sitemgr-site-dir');
! $dirname = $sitemgr_dir . SEP . 'templates' . SEP;
$result_array=array();
@$handle=opendir($dirname);
***************
*** 43,59 ****
while (($file = readdir($handle)) !== false)
{
! if (is_dir($dirname.$file) &&
substr($file,0,1)!='.' && strcmp($file,'index.html') != 0
! && strcmp($file,'CVS') != 0)
{
$result_array[]=array('value'=>$file,'display'=>$file);
}
! }
! }
! else
! {
! return array(array('value'=>'','display'=>'No
'.$interface.' found.'));
}
! closedir($handle);
! return $result_array;
}
--- 30,41 ----
while (($file = readdir($handle)) !== false)
{
! if (is_dir($dirname . $file) &&
file_exists($dirname . $file . SEP . 'main.tpl'))
{
$result_array[]=array('value'=>$file,'display'=>$file);
}
! }
! closedir($handle);
}
! return $result_array ? $result_array :
array(array('value'=>'','display'=>lang('No templates found.')));
}
Index: class.sitePreference_SO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.sitePreference_SO.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** class.sitePreference_SO.inc.php 11 Sep 2002 22:39:28 -0000 1.2
--- class.sitePreference_SO.inc.php 17 Jan 2003 03:37:52 -0000 1.3
***************
*** 41,44 ****
--- 41,55 ----
}
}
+
+ function getallprefs()
+ {
+ $sql = 'SELECT name,value FROM
phpgw_sitemgr_preferences';
+ $this->db->query($sql,__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+ $result[$this->db->f('name')] =
$this->db->f('value');
+ }
+ return $result;
+ }
}
Index: hook_admin.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/hook_admin.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** hook_admin.inc.php 29 Aug 2002 03:03:17 -0000 1.1.1.1
--- hook_admin.inc.php 17 Jan 2003 03:37:52 -0000 1.2
***************
*** 18,24 ****
(
'Site Setup' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Common_UI.DisplayPrefs'),
! 'Edit Categories and Permissions' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Admin_ManageCategories_UI._manageCategories'),
! 'Edit Site Header and Footer' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.admin_ManageSiteContent_UI._editHeaderAndFooter'),
! 'Edit Individual Pages' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.contributor_ManagePage_UI._managePage')
);
--- 18,24 ----
(
'Site Setup' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Common_UI.DisplayPrefs'),
! 'Edit Categories and Permissions' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Categories_UI._manageCategories'),
! 'Edit Site Header and Footer' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.SiteContent_UI._editHeaderAndFooter'),
! 'Edit Individual Pages' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Pages_UI._managePage')
);
Index: hook_preferences.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/hook_preferences.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** hook_preferences.inc.php 29 Aug 2002 03:03:17 -0000 1.1.1.1
--- hook_preferences.inc.php 17 Jan 2003 03:37:52 -0000 1.2
***************
*** 17,21 ****
$file = Array
(
! 'Manage Pages' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.contributor_ManagePage_UI._managePage')
);
--- 17,22 ----
$file = Array
(
! 'Manage Categories' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Categories_UI._manageCategories'),
! 'Manage Pages' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Pages_UI._managePage')
);
--- class.Admin_ManageCategories_UI.inc.php DELETED ---
--- class.Blocks_BO.inc.php DELETED ---
--- class.Blocks_SO.inc.php DELETED ---
--- class.Categories_db_SO.inc.php DELETED ---
--- class.admin_ManageSiteContent_UI.inc.php DELETED ---
--- class.contributor_ManagePage_UI.inc.php DELETED ---
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: sitemgr/inc class.Categories_UI.inc.php,NONE,1.1 class.Common_BO.inc.php,NONE,1.1 class.Content_BO.inc.php,NONE,1.1 class.Content_SO.inc.php,NONE,1.1 class.Content_UI.inc.php,NONE,1.1 class.Modules_BO.inc.php,NONE,1.1 class.Modules_SO.inc.php,NONE,1.1 class.Modules_UI.inc.php,NONE,1.1 class.Pages_UI.inc.php,NONE,1.1 class.SiteContent_UI.inc.php,NONE,1.1 class.Translations_UI.inc.php,NONE,1.1 class.browser_transform.inc.php,NONE,1.1class.module.inc.php,NONE,1.1 class.module_administration.inc.php,NONE,1.1 class.module_amazon.inc.php,NONE,1.1class.module_appdir.inc.php,NONE,1.1 class.module_calendar.inc.php,NONE,1.1 class.module_currentsection.inc.php,NONE,1.1 class.module_forum.inc.php,NONE,1.1class.module_galerie.inc.php,NONE,1.1 class.module_google.inc.php,NONE,1.1class.module_hello.inc.php,NONE,1.1 class.module_html.inc.php,NONE,1.1class.module_index.inc.php,NONE,1.1 class.module_index_block.inc.php,NONE,1.1 class.module_lang_block.inc.php,NONE,1.1 class.module_login.inc.php,NONE,1.1class.module_meta.inc.php,NONE,1.1 class.module_news.inc.php,NONE,1.1class.module_sitetree.inc.php,NONE,1.1 class.module_toc.inc.php,NONE,1.1class.module_toc_block.inc.php,NONE,1.1 class.module_xml.inc.php,NONE,1.1 class.xmltool2.inc.php,NONE,1.1 class.xslt_transform.inc.php,NONE,1.1 class.ACL_BO.inc.php,1.1.1.1,1.2 class.ACL_SO.inc.php,1.2,1.3 class.Block_SO.inc.php,1.1,1.2 class.Categories_BO.inc.php,1.5,1.6 class.Categories_SO.inc.php,1.11,1.12 class.Common_UI.inc.php,1.7,1.8 class.MainMenu_UI.inc.php,1.5,1.6 class.Page_SO.inc.php,1.4,1.5 class.Pages_BO.inc.php,1.3,1.4 class.Pages_SO.inc.php,1.9,1.10 class.Theme_BO.inc.php,1.3,1.4 class.sitePreference_SO.inc.php,1.2,1.3 hook_admin.inc.php,1.1.1.1,1.2 hook_preferences.inc.php,1.1.1.1,1.2 class.Admin_ManageCategories_UI.inc.php,1.6,NONE class.Blocks_BO.inc.php,1.2,NONE class.Blocks_SO.inc.php,1.1,NONE class.Categories_db_SO.inc.php,1.7,NONE class.admin_ManageSiteContent_UI.inc.php,1.2,NONE class.contributor_ManagePage_UI.inc.php,1.8,NONE,
Michael Totschnig <address@hidden> <=
- Prev by Date:
[Phpgroupware-cvs] CVS: sitemgr/sitemgr-site/templates/3D-Fantasy/style style.css,1.1,1.2
- Next by Date:
[Phpgroupware-cvs] CVS: sitemgr/doc makedoc.sh,NONE,1.1 modules.dvi,NONE,1.1 modules.html,NONE,1.1 modules.lyx,NONE,1.1 modules.pdf,NONE,1.1 modules.ps,NONE,1.1 modules.sgml,NONE,1.1 modules.txt,NONE,1.1
- Previous by thread:
[Phpgroupware-cvs] CVS: sitemgr/sitemgr-site/templates/3D-Fantasy/style style.css,1.1,1.2
- Next by thread:
[Phpgroupware-cvs] CVS: sitemgr/doc makedoc.sh,NONE,1.1 modules.dvi,NONE,1.1 modules.html,NONE,1.1 modules.lyx,NONE,1.1 modules.pdf,NONE,1.1 modules.ps,NONE,1.1 modules.sgml,NONE,1.1 modules.txt,NONE,1.1
- Index(es):