phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: sitemgr/sitemgr-site/inc class.Template3.inc.ph


From: Michael Totschnig <address@hidden>
Subject: [Phpgroupware-cvs] CVS: sitemgr/sitemgr-site/inc class.Template3.inc.php,1.5,1.5.2.1 class.sitebo.inc.php,1.1.2.1,1.1.2.2 class.ui.inc.php,1.11,1.11.2.1
Date: Mon, 23 Jun 2003 16:31:24 -0400

Update of /cvsroot/phpgroupware/sitemgr/sitemgr-site/inc
In directory subversions:/tmp/cvs-serv14915/sitemgr-site/inc

Modified Files:
      Tag: Version-0_9_16-branch
        class.Template3.inc.php class.sitebo.inc.php class.ui.inc.php 
Log Message:
sync up with HEAD


Index: class.Template3.inc.php
===================================================================
RCS file: 
/cvsroot/phpgroupware/sitemgr/sitemgr-site/inc/class.Template3.inc.php,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -C2 -r1.5 -r1.5.2.1
*** class.Template3.inc.php     4 Mar 2003 18:59:14 -0000       1.5
--- class.Template3.inc.php     23 Jun 2003 20:31:21 -0000      1.5.2.1
***************
*** 5,10 ****
        class Template3
        {
- 
- 
                /* 'yes' => halt, 'report' => report error, continue, 'no' => 
ignore error quietly */
                var $bo;
--- 5,8 ----
***************
*** 15,18 ****
--- 13,17 ----
                var $permitted_modules;
                var $sitename;
+               var $draft_transformer, $edit_transformer;
  
                function Template3($root)
***************
*** 84,87 ****
--- 83,110 ----
                function parse()
                {
+                       if ($GLOBALS['sitemgr_info']['mode'] == 'Draft')
+                       {
+                               $transformerfile = $this->root . SEP . 
'draft_transform.inc.php';
+                               if (file_exists($transformerfile))
+                               {
+                                       include($transformerfile);
+                                       if (class_exists('draft_transform'))
+                                       {
+                                               $this->draft_transformer = new 
draft_transform();
+                                       }
+                               }
+                       }
+                       elseif ($GLOBALS['sitemgr_info']['mode'] == 'Edit')
+                       {
+                               $transformerfile = $this->root . SEP . 
'edit_transform.inc.php';
+                               if (file_exists($transformerfile))
+                               {
+                                       include($transformerfile);
+                                       if (class_exists('edit_transform'))
+                                       {
+                                               $this->edit_transformer = new 
edit_transform();
+                                       }
+                               }
+                       }
                        //get block content for contentareas
                        $str = preg_replace_callback(
***************
*** 114,120 ****
--- 137,147 ----
                {
                        global $page;
+                       global $objbo;
+ 
                        $areaname = $vars[1];
                        $this->permitted_modules = 
array_keys($this->modulebo->getcascadingmodulepermissions($areaname,$page->cat_id));
+ 
                        $transformername = $areaname . '_bt';
+ 
                        $transformerfile = $this->root . SEP . $transformername 
. '.inc.php';
                        if (file_exists($transformerfile))
***************
*** 135,140 ****
                        }
                        $content = '';
-                       $blocks = 
$this->bo->getvisibleblockdefsforarea($areaname,$page->cat_id,$page->id);
  
                        // if we are in the center area, we append special 
blocks
                        if ($areaname == "center" && $page->block)
--- 162,167 ----
                        }
                        $content = '';
  
+                       $blocks = 
$this->bo->getvisibleblockdefsforarea($areaname,$page->cat_id,$page->id,$objbo->isadmin,$objbo->isuser);
                        // if we are in the center area, we append special 
blocks
                        if ($areaname == "center" && $page->block)
***************
*** 142,180 ****
                                array_unshift($blocks,$page->block);
                        }
- 
                        if ($blocks)
                        {
                                while (list(,$block) = each($blocks))
                                {
!                                       if ($this->block_allowed($block->view))
                                        {
!                                               if 
(in_array($block->module_id,$this->permitted_modules))
                                                {
!                                                       if ($block->id)
!                                                       {
!                                                               $block = 
$this->getblockwrapper($block->id);
!                                                       }
!                                                       //we maintain an array 
of modules we have already used, so we do not 
!                                                       //have to create them 
anew. Since they are copied, before the transformer
!                                                       //is added, we do not 
have to worry about transformers staying around 
!                                                       //on the transformer 
chain
!                                                       $moduleobject = 
$this->getmodule($block->module_name);
!                                                       
$moduleobject->set_block($block,True);
!                                                       if (isset($transformer))
!                                                       {
!                                                               
$moduleobject->add_transformer($transformer);
!                                                       }
! 
!                                                       $output = 
$moduleobject->get_output();
!                                                       //process module calls 
embedded into output
!                                                       $content .= 
preg_replace_callback(
!                                                               
"/\{([[:alnum:]_-]*)\.([[:alnum:]_-]*)(\?([^{ ]+))?\}/",
!                                                               
array($this,'exec_module'),
!                                                               $output);
                                                }
!                                               else
                                                {
!                                                       $content .= 
lang('Module %1 is not permitted in this context!',$block->module_name);
                                                }
                                        }
                                }
--- 169,222 ----
                                array_unshift($blocks,$page->block);
                        }
                        if ($blocks)
                        {
                                while (list(,$block) = each($blocks))
                                {
!                                       if 
(in_array($block->module_id,$this->permitted_modules))
                                        {
!                                               //we maintain an array of 
modules we have already used, so we do not 
!                                               //have to create them anew. 
Since they are copied, before the transformer
!                                               //is added, we do not have to 
worry about transformers staying around 
!                                               //on the transformer chain
!                                               $moduleobject = 
$this->getmodule($block->module_name);
! 
!                                               if ($block->id)
                                                {
!                                                       $block->title = 
$this->getblocktitlewrapper($block->id);
!                                                       $block->arguments = 
$moduleobject->i18n ? 
!                                                               
$this->getversionwrapper($block->version) : 
$this->bo->getversion($block->version);
                                                }
!                                               
!                                               
$moduleobject->set_block($block,True);
! 
!                                               if (($block->state == 
SITEMGR_STATE_PREPUBLISH) && is_object($this->draft_transformer))
!                                               {
! 
!                                                       
$moduleobject->add_transformer($this->draft_transformer);
!                                               }
!                                               if (isset($transformer))
!                                               {
!                                                       
$moduleobject->add_transformer($transformer);
!                                               }
!                                               if (
!                                                       
($GLOBALS['sitemgr_info']['mode'] == 'Edit') && 
!                                                       $block->id &&
!                                                       
$GLOBALS['Common_BO']->acl->can_write_category($block->cat_id) &&
!                                                       
is_object($this->edit_transformer))
                                                {
!                                                       
$this->edit_transformer->block_id = $block->id;
!                                                       
$moduleobject->add_transformer($this->edit_transformer);
                                                }
+ 
+                                               $output = 
$moduleobject->get_output();
+                                               //process module calls embedded 
into output
+                                               $content .= 
preg_replace_callback(
+                                                       
"/\{([[:alnum:]_-]*)\.([[:alnum:]_-]*)(\?([^{ ]+))?\}/",
+                                                       
array($this,'exec_module'),
+                                                       $output);
+                                       }
+                                       else
+                                       {
+                                               $content .= lang('Module %1 is 
not permitted in this context!',$block->module_name);
                                        }
                                }
***************
*** 253,263 ****
                                case 'sitename':
                                case 'site_name':
!                                       return 
$GLOBALS['sitemgr_info']['sitemgr-site-name-' . 
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang']];
!                               case 'footer':
!                               case 'site_footer':
!                                       return 
$GLOBALS['Common_BO']->headerfooter->getsitefooter($GLOBALS['phpgw_info']['user']['preferences']['common']['lang']);
!                               case 'header':
!                               case 'site_header':
!                                       return 
$GLOBALS['Common_BO']->headerfooter->getsiteheader($GLOBALS['phpgw_info']['user']['preferences']['common']['lang']);
                                case 'user':
                                        return 
$GLOBALS['phpgw_info']['user']['account_lid'];
--- 295,308 ----
                                case 'sitename':
                                case 'site_name':
!                                       return 
$GLOBALS['sitemgr_info']['site_name_' . 
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang']];
!                               case 'sitedesc':
!                               case 'site_desc':
!                                       return 
$GLOBALS['sitemgr_info']['site_desc_' . 
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang']];
! //                            case 'footer':
! //                            case 'site_footer':
! //                                    return 
$GLOBALS['Common_BO']->headerfooter->getsitefooter($GLOBALS['phpgw_info']['user']['preferences']['common']['lang']);
! //                            case 'header':
! //                            case 'site_header':
! //                                    return 
$GLOBALS['Common_BO']->headerfooter->getsiteheader($GLOBALS['phpgw_info']['user']['preferences']['common']['lang']);
                                case 'user':
                                        return 
$GLOBALS['phpgw_info']['user']['account_lid'];
***************
*** 279,306 ****
                }
  
!               function block_allowed($view)
                {
!                       global $objbo;
! 
!                       switch($view)
                        {
!                               case 0:
!                                       return true;
!                               case 1:
!                                       return $objbo->is_user();
!                               case 2:
!                                       return $objbo->is_admin();
!                               case 3:
!                                       return (! $objbo->is_user());
                        }
-                       return false;
                }
  
!               function getblockwrapper($block_id)
                {
!                       $availablelangsforblock = 
$this->bo->getlangarrayforblock($block_id);
!                       if 
(in_array($GLOBALS['sitemgr_info']['userlang'],$availablelangsforblock))
                        {
!                               return 
$this->bo->getblock($block_id,$GLOBALS['sitemgr_info']['userlang']);
                        }
                        else
--- 324,352 ----
                }
  
!               function getblocktitlewrapper($block_id)
                {
!                       $availablelangsforblocktitle = 
$this->bo->getlangarrayforblocktitle($block_id);
!                       if 
(in_array($GLOBALS['sitemgr_info']['userlang'],$availablelangsforblocktitle))
                        {
!                               return 
$this->bo->getlangblocktitle($block_id,$GLOBALS['sitemgr_info']['userlang']);
!                       }
!                       else
!                       {
!                               foreach 
($GLOBALS['sitemgr_info']['sitelanguages'] as $lang)
!                               {
!                                       if 
(in_array($lang,$availablelangsforblocktitle))
!                                       {
!                                               return 
$this->bo->getlangblocktitle($block_id,$lang);
!                                       }
!                               }
                        }
                }
  
!               function getversionwrapper($version_id)
                {
!                       $availablelangsforversion = 
$this->bo->getlangarrayforversion($version_id);
!                       if 
(in_array($GLOBALS['sitemgr_info']['userlang'],$availablelangsforversion))
                        {
!                               return 
$this->bo->getversion($version_id,$GLOBALS['sitemgr_info']['userlang']);
                        }
                        else
***************
*** 308,319 ****
                                foreach 
($GLOBALS['sitemgr_info']['sitelanguages'] as $lang)
                                {
!                                       if 
(in_array($lang,$availablelangsforblock))
                                        {
!                                               return 
$this->bo->getblock($block_id,$lang);
                                        }
                                }
                        }
                }
- 
        }
  
--- 354,364 ----
                                foreach 
($GLOBALS['sitemgr_info']['sitelanguages'] as $lang)
                                {
!                                       if 
(in_array($lang,$availablelangsforversion))
                                        {
!                                               return 
$this->bo->getversion($version_id,$lang);
                                        }
                                }
                        }
                }
        }
  

Index: class.sitebo.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/sitemgr-site/inc/class.sitebo.inc.php,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -r1.1.2.1 -r1.1.2.2
*** class.sitebo.inc.php        8 Apr 2003 18:13:04 -0000       1.1.2.1
--- class.sitebo.inc.php        23 Jun 2003 20:31:21 -0000      1.1.2.2
***************
*** 22,25 ****
--- 22,28 ----
                        $this->pages_bo = &$GLOBALS['Common_BO']->pages;
                        $this->acl = &$GLOBALS['Common_BO']->acl;
+                       $this->isadmin = $this->acl->is_admin;
+                       //$anonymous_user is globally set in config.inc.php
+                       $this->isuser = 
($GLOBALS['phpgw_info']['user']['account_lid'] != $GLOBALS['anonymous_user']);
                }
  
***************
*** 81,85 ****
                        $page->block->module_name = 'index';
                        $page->block->module_id = 
$GLOBALS['Common_BO']->modules->getmoduleid('index');
!                       $page->block->view = 0;
                        return true;
                }
--- 84,90 ----
                        $page->block->module_name = 'index';
                        $page->block->module_id = 
$GLOBALS['Common_BO']->modules->getmoduleid('index');
!                       $page->block->view = SITEMGR_VIEWABLE_EVERBODY;
!                       $page->block->status = SITEMGR_STATE_PUBLISH;
!                       $page->cat_id = 
$GLOBALS['Common_BO']->current_site['site_id'];
                        return true;
                }
***************
*** 132,162 ****
                        global $page;
  
!                       if ($category_id)
!                       {
!                               if($this->acl->can_read_category($category_id))
!                               {
!                                       $cat = 
$this->getcatwrapper($category_id);
!                                       if ($cat)
!                                       {
!                                               $page->cat_id = $category_id;
!                                               $page->title = 
lang('Category').' '.$cat->name;
!                                               $page->subtitle = 
'<i>'.$cat->description.'</i>';
!                                       }
!                               }
!                       }
!                       else
!                       {
!                               $page->title = lang('Table of Contents');
!                               $page->subtitle = '';
!                               $page->toc = True;
!                       }
                        $page->block = CreateObject('sitemgr.Block_SO',True);
                        $page->block->module_name = 'toc';
                        $page->block->arguments = array('category_id' => 
$category_id);
                        $page->block->module_id = 
$GLOBALS['Common_BO']->modules->getmoduleid('toc');
!                       $page->block->view = 0;
                        return true;
                }
!               
                function getPageLinks($category_id, $showhidden=true)
                {
--- 137,153 ----
                        global $page;
  
!                       $page->title = lang('Table of Contents');
!                       $page->subtitle = '';
!                       $page->toc = True;
!                       $page->cat_id = $category_id ? $category_id : 
CURRENT_SITE_ID;
                        $page->block = CreateObject('sitemgr.Block_SO',True);
                        $page->block->module_name = 'toc';
                        $page->block->arguments = array('category_id' => 
$category_id);
                        $page->block->module_id = 
$GLOBALS['Common_BO']->modules->getmoduleid('toc');
!                       $page->block->view = SITEMGR_VIEWABLE_EVERBODY;
!                       $page->block->state = SITEMGR_STATE_PUBLISH;
                        return true;
                }
! 
                function getPageLinks($category_id, $showhidden=true)
                {
***************
*** 181,192 ****
                {
                        $catlinks = array();
!                       if ($recurse)
!                       {
!                               
$cat_list=$this->catbo->getPermittedCatReadNested($cat_id);
!                       }
!                       else
!                       {
!                               
$cat_list=$this->catbo->getPermittedCategoryIDReadList($cat_id);
!                       }
                        foreach($cat_list as $cat_id)
                        {
--- 172,176 ----
                {
                        $catlinks = array();
!                       $cat_list = 
$this->catbo->getpermittedcatsRead($cat_id,$recurse);
                        foreach($cat_list as $cat_id)
                        {
***************
*** 202,224 ****
                }
  
- 
-               function is_user()
-               {
-                       global $sitemgr_info,$phpgw_info;
-                       if ($phpgw_info['user']['account_lid'] != 
$sitemgr_info['anonymous-user'])
-                       {
-                               return true;
-                       }
-                       else
-                       {
-                               return false;
-                       }
-               }
- 
-               function is_admin()
-               {
-                       return $this->acl->is_admin();
-               }
- 
                //like $GLOBALS['phpgw']->common->getPreferredLanguage,
                //but compares languages accepted by the user 
--- 186,189 ----
***************
*** 227,232 ****
                function setsitemgrPreferredLanguage()
                {
                        $supportedLanguages = 
$GLOBALS['sitemgr_info']['sitelanguages'] ? 
$GLOBALS['sitemgr_info']['sitelanguages'] : array('en');
!                       $postlang = $_POST['language'];
                        if ($postlang && 
in_array($postlang,$supportedLanguages))
                        {
--- 192,201 ----
                function setsitemgrPreferredLanguage()
                {
+                       //since there are lang calls in the API, and the first 
lang call builds $GLOBAL['lang'], wet have to unset it, if
+                       //the change of 
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] should have any 
effect.
+                       //is there a more efficient way to do the same thing?
+                       unset($GLOBALS['lang']);
                        $supportedLanguages = 
$GLOBALS['sitemgr_info']['sitelanguages'] ? 
$GLOBALS['sitemgr_info']['sitelanguages'] : array('en');
!                       $postlang = $_GET['lang_block']['select'];
                        if ($postlang && 
in_array($postlang,$supportedLanguages))
                        {
***************
*** 245,249 ****
                        }
                        
!               if ($this->is_user())
                        {
                                $userlang = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'];
--- 214,218 ----
                        }
                        
!                       if ($this->isuser)
                        {
                                $userlang = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'];
***************
*** 288,291 ****
--- 257,278 ----
                }
  
+               function getmode()
+               {
+                       if ($this->isuser)
+                       {
+                               $postmode = $_GET['administration']['mode'];
+                               if ($postmode)
+                               {
+                                       
$GLOBALS['phpgw']->session->appsession('mode','sitemgr-site',$postmode);
+                                       return $postmode;
+                               }
+                               $sessionmode = 
$GLOBALS['phpgw']->session->appsession('mode','sitemgr-site');
+                               if($sessionmode)
+                               {
+                                       return $sessionmode;
+                               }
+                       }
+                       return 'Production';
+               }
        }
  ?>

Index: class.ui.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/sitemgr-site/inc/class.ui.inc.php,v
retrieving revision 1.11
retrieving revision 1.11.2.1
diff -C2 -r1.11 -r1.11.2.1
*** class.ui.inc.php    18 Jan 2003 04:30:34 -0000      1.11
--- class.ui.inc.php    23 Jun 2003 20:31:21 -0000      1.11.2.1
***************
*** 20,24 ****
                {
                        $themesel = $GLOBALS['sitemgr_info']['themesel'];
!                       $templateroot = 
$GLOBALS['sitemgr_info']['sitemgr-site-dir'] . SEP . 'templates' . SEP . 
$themesel;
                        $this->t = new Template3($templateroot);
                }
--- 20,24 ----
                {
                        $themesel = $GLOBALS['sitemgr_info']['themesel'];
!                       $templateroot = $GLOBALS['sitemgr_info']['site_dir'] . 
SEP . 'templates' . SEP . $themesel;
                        $this->t = new Template3($templateroot);
                }
***************
*** 28,32 ****
                        global $objbo;
                        global $page;
!                       
$objbo->loadPage($GLOBALS['Common_BO']->pages->pageso->PageToID($page_name));
                        $this->generatePage();
                }
--- 28,32 ----
                        global $objbo;
                        global $page;
!                       
$objbo->loadPage($GLOBALS['Common_BO']->pages->so->PageToID($page_name));
                        $this->generatePage();
                }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]