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.7,1.8 class.sitebo.inc.php,1.3,1.4 class.ui.inc.php,1.12,1.13
Date: Fri, 30 May 2003 00:01:45 -0400

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

Modified Files:
        class.Template3.inc.php class.sitebo.inc.php class.ui.inc.php 
Log Message:
make sitemgr capable of handling versions


Index: class.Template3.inc.php
===================================================================
RCS file: 
/cvsroot/phpgroupware/sitemgr/sitemgr-site/inc/class.Template3.inc.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** class.Template3.inc.php     23 May 2003 03:37:25 -0000      1.7
--- class.Template3.inc.php     30 May 2003 04:01:43 -0000      1.8
***************
*** 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,117 ****
--- 137,142 ----
                {
                        global $page;
+                       global $objbo;
+ 
                        $areaname = $vars[1];
                        $this->permitted_modules = 
array_keys($this->modulebo->getcascadingmodulepermissions($areaname,$page->cat_id));
***************
*** 138,143 ****
                        $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)
--- 163,167 ----
                        $content = '';
  
!                       $blocks = 
$this->bo->getvisibleblockdefsforarea($areaname,$page->cat_id,$page->id,$objbo->is_admin(),$objbo->is_user());
                        // if we are in the center area, we append special 
blocks
                        if ($areaname == "center" && $page->block)
***************
*** 145,183 ****
                                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,218 ----
                                array_unshift($blocks,$page->block);
                        }
                        if ($blocks)
                        {
                                while (list(,$block) = each($blocks))
                                {
!                                       if 
(in_array($block->module_id,$this->permitted_modules))
                                        {
!                                               if ($block->id)
!                                               {
!                                                       $block->title = 
$this->getblocktitlewrapper($block->id);
!                                                       $blockdata = 
$this->getversionwrapper($block->version);
!                                                       $block->arguments = 
$blockdata->arguments;
!                                                       $block->state = 
$blockdata->state;
!                                               }
! 
!                                               //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 (($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 && 
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);
                                        }
                                }
***************
*** 257,260 ****
--- 292,298 ----
                                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':
***************
*** 300,309 ****
                }
  
!               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
--- 338,347 ----
                }
  
!               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
***************
*** 311,317 ****
                                foreach 
($GLOBALS['sitemgr_info']['sitelanguages'] as $lang)
                                {
!                                       if 
(in_array($lang,$availablelangsforblock))
                                        {
!                                               return 
$this->bo->getblock($block_id,$lang);
                                        }
                                }
--- 349,355 ----
                                foreach 
($GLOBALS['sitemgr_info']['sitelanguages'] as $lang)
                                {
!                                       if 
(in_array($lang,$availablelangsforblocktitle))
                                        {
!                                               return 
$this->bo->getlangblocktitle($block_id,$lang);
                                        }
                                }
***************
*** 319,322 ****
--- 357,378 ----
                }
  
+               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
+                       {
+                               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.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** class.sitebo.inc.php        22 May 2003 02:36:54 -0000      1.3
--- class.sitebo.inc.php        30 May 2003 04:01:43 -0000      1.4
***************
*** 81,85 ****
                        $page->block->module_name = 'index';
                        $page->block->module_id = 
$GLOBALS['Common_BO']->modules->getmoduleid('index');
!                       $page->block->view = 0;
                        $page->cat_id = 
$GLOBALS['Common_BO']->current_site['site_id'];
                        return true;
--- 81,86 ----
                        $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;
***************
*** 158,162 ****
                        $page->block->arguments = array('category_id' => 
$category_id);
                        $page->block->module_id = 
$GLOBALS['Common_BO']->modules->getmoduleid('toc');
!                       $page->block->view = 0;
                        return true;
                }
--- 159,164 ----
                        $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;
                }
***************
*** 184,195 ****
                {
                        $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)
                        {
--- 186,190 ----
                {
                        $catlinks = array();
!                       $cat_list = 
$this->catbo->getpermittedcatsRead($cat_id,$recurse);
                        foreach($cat_list as $cat_id)
                        {
***************
*** 235,239 ****
                        unset($GLOBALS['lang']);
                        $supportedLanguages = 
$GLOBALS['sitemgr_info']['sitelanguages'] ? 
$GLOBALS['sitemgr_info']['sitelanguages'] : array('en');
!                       $postlang = $_POST['language'];
                        if ($postlang && 
in_array($postlang,$supportedLanguages))
                        {
--- 230,234 ----
                        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))
                        {
***************
*** 295,298 ****
--- 290,311 ----
                }
  
+               function getmode()
+               {
+                       if ($this->is_user())
+                       {
+                               $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.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** class.ui.inc.php    22 May 2003 02:36:54 -0000      1.12
--- class.ui.inc.php    30 May 2003 04:01:43 -0000      1.13
***************
*** 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]