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,NONE,1.1 class.bo.inc.php,1.8,1.9 class.ui.inc.php,1.9,1.10 class.Template2.inc.php,1.2,NONE class.blocks_bo.inc.php,1.4,NONE class.so.inc.php,1.2,NONE
Date: Thu, 16 Jan 2003 22:37:55 -0500

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

Modified Files:
        class.bo.inc.php class.ui.inc.php 
Added Files:
        class.Template3.inc.php 
Removed Files:
        class.Template2.inc.php class.blocks_bo.inc.php 
        class.so.inc.php 
Log Message:
First commit of a new modularized architecture for sitemgr 


--- NEW FILE ---
<?php

require_once(PHPGW_INCLUDE_ROOT . SEP . 'sitemgr' . SEP . 'inc' . SEP . 
'class.module.inc.php');

        class Template3
        {


                /* 'yes' => halt, 'report' => report error, continue, 'no' => 
ignore error quietly */
                var $bo;
                var $halt_on_error = 'yes';
                var $file;
                var $template;
                var $modules;
                var $permitted_modules;
                var $sitename;

                function Template3($root)
                {
                        $this->set_root($root);
                        $this->file = $this->root . SEP . 'main.tpl';
                        $this->loadfile();
                        $this->bo = &$GLOBALS['Common_BO']->content;
                        $this->modulebo = &$GLOBALS['Common_BO']->modules;
                        $this->modules = array();
                }

                /* public: setroot(pathname $root)
                 * root:   new template directory.
                 */
                function set_root($root)
                {
                        if (!is_dir($root))
                        {
                                $this->halt("set_root: $root is not a 
directory.");
                                return false;
                        }
                        $this->root = $root;
                        return true;
                }

                function loadfile()
                {
                        $str = implode('', @file($this->file));
                        if (empty($str))
                        {
                                $this->halt("loadfile: While loading $handle, 
$filename does not exist or is empty.");
                                return false;
                        }
                        else 
                        $this->template = $str;
                }


                
/***************************************************************************/
                /* public: halt(string $msg)
                 * msg:    error message to show.
                 */
                function halt($msg)
                {
                        $this->last_error = $msg;

                        if ($this->halt_on_error != 'no')
                        {
                                $this->haltmsg($msg);
                        }

                        if ($this->halt_on_error == 'yes')
                        {
                                echo('<b>Halted.</b>');
                        }

                        $GLOBALS['phpgw']->common->phpgw_exit(True);
                }

                /* public, override: haltmsg($msg)
                 * msg: error message to show.
                 */
                function haltmsg($msg)
                {
                        printf("<b>Template Error:</b> %s<br>\n", $msg);
                }

                function parse()
                {
                        //get block content for contentareas
                        $str = preg_replace_callback(
                                "/\{contentarea:([^{ ]+)\}/",
                                array($this,'process_blocks'),
                                $this->template);
                        $this->permitted_modules = 
array_keys($this->modulebo->getcascadingmodulepermissions('__PAGE__',$page->cat_id));
                        //process module calls hardcoded into template of form 
{appname.modulename?arguments}
                        $str = preg_replace_callback(
                                "/\{([[:alnum:]_-]*)\.([[:alnum:]_-]*)(\?([^{ 
]+))?\}/",
                                array($this,'exec_module'),
                                $str);
                        //{?page_id=4} is a shortcut for calling the link 
functions
                        $str = preg_replace_callback(
                                "/\{\?((sitemgr|phpgw):)?([^{ ]*)\}/",
                                array($this,'make_link'),
                                $str);
                        //all template variables that survive look for 
metainformation
                        return preg_replace_callback(
                                "/\{([^{ ]+)\}/",
                                array($this,'get_meta'),
                                $str);
                }

                function process_blocks($vars)
                {
                        global $page;
                        $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))
                        {
                                include($transformerfile);
                        }
                        if (class_exists($transformername))
                        {
                                $transformer = new $transformername;
                        }

                        $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)
                        {
                                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->app_name,$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->app_name . '.' . 
$block->module_name);
                                                }
                                        }
                                }
                        }
                        return $content;
                }

                function exec_module($vars)
                {
                        global $page;
                        list(,$appname,$modulename,,$query)= $vars;
                        $moduleid = 
$this->modulebo->getmoduleid($appname,$modulename);
                        if (in_array($moduleid,$this->permitted_modules))
                        {
                                $moduleobject = 
$this->getmodule($appname,$modulename);
                                if ($moduleobject)
                                {
                                        parse_str($query,$arguments);
                                        //we set up a block object so that the 
module object can retrieve the right arguments and properties
                                        $block = 
CreateObject('sitemgr.Block_SO',True);
                                        $block->module_id = 0;
                                        $block->area = '__PAGE__';
                                        $block->cat_id = $page->cat_id;
                                        $block->app_name = $appname;
                                        $block->module_name = $modulename;
                                        $block->arguments = $arguments;
                                        $moduleobject->set_block($block,True);
                                        return $moduleobject->get_output();
                                }
                        }
                        else
                        {
                                return lang('Module %1 is not permitted in this 
context!',$appname . '.' . $modulename);
                        }
                }

                function make_link($vars)
                {
                        switch($vars[2])
                        {
                                case 'phpgw':
                                        $params=explode(',',$vars[3]);
                                        switch(count($params))
                                        {
                                                case 0:
                                                        return '';
                                                case 1:
                                                        return 
phpgw_link($params[0]);
                                                case 2:
                                                        return 
phpgw_link($params[0],$params[1]);
                                                default:
                                                        return $vars[0];
                                        }
                                //sitemgr link
                                default:
                                                return sitemgr_link($vars[3]);
                        }
                }

                function get_meta($vars)
                {
                        global $page;

                        switch ($vars[1])
                        {
                                case 'title':
                                        return $page->title;
                                case 'subtitle':
                                        return $page->subtitle;
                                case 'sitename':
                                        return 
$GLOBALS['sitemgr_info']['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'];
                }
                }

                function getmodule($appname,$modulename)
                {
                        $module = $appname . '.' . $modulename;
                        if (!in_array($module,array_keys($this->modules)))
                        {
                                $moduleobject = 
$this->modulebo->createmodule($appname,$modulename);
                                $this->modules[$module] = $moduleobject;
                        }
                        else
                        {
                                $moduleobject = $this->modules[$module];
                        }
                        return $moduleobject;
                }

                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
                        {
                                foreach 
($GLOBALS['sitemgr_info']['sitelanguages'] as $lang)
                                {
                                        if 
(in_array($lang,$availablelangsforblock))
                                        {
                                                return 
$this->bo->getblock($block_id,$lang);
                                        }
                                }
                        }
                }

        }
Index: class.bo.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/sitemgr-site/inc/class.bo.inc.php,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** class.bo.inc.php    5 Dec 2002 22:15:00 -0000       1.8
--- class.bo.inc.php    17 Jan 2003 03:37:52 -0000      1.9
***************
*** 14,20 ****
        {
                var $pages_bo;
-               var $headerfooter_bo;
-               var $page_id;
-               var $page;
                var $catbo;
                var $acl;
--- 14,17 ----
***************
*** 22,31 ****
                function bo()
                {
!                       $this->catbo = CreateObject('sitemgr.Categories_BO');
!                       $this->pages_bo = CreateObject('sitemgr.Pages_BO');
!                       //$this->pages_so = CreateObject('sitemgr.Pages_SO');
!                       $this->headerfooter_bo = 
CreateObject('sitemgr.headerFooter_BO');
!                       $this->page = CreateObject('sitemgr.Page_SO');
!                       $this->acl = CreateObject('sitemgr.ACL_BO');
                }
  
--- 19,25 ----
                function bo()
                {
!                       $this->catbo = &$GLOBALS['Common_BO']->cats;
!                       $this->pages_bo = &$GLOBALS['Common_BO']->pages;
!                       $this->acl = &$GLOBALS['Common_BO']->acl;
                }
  
***************
*** 33,39 ****
                {
                        $availablelangsforcat = 
$this->catbo->getlangarrayforcategory($cat_id);
!                       if 
(in_array($GLOBALS['phpgw_info']['user']['preferences']['common']['lang'],$availablelangsforcat))
                        {
!                               return 
$this->catbo->getCategory($cat_id,$GLOBALS['phpgw_info']['user']['preferences']['common']['lang']);
                        }
                        else
--- 27,33 ----
                {
                        $availablelangsforcat = 
$this->catbo->getlangarrayforcategory($cat_id);
!                       if 
(in_array($GLOBALS['sitemgr_info']['userlang'],$availablelangsforcat))
                        {
!                               return 
$this->catbo->getCategory($cat_id,$GLOBALS['sitemgr_info']['userlang']);
                        }
                        else
***************
*** 47,50 ****
--- 41,46 ----
                                }
                        }
+                       //fall back to a category in "default" lang
+                       return $this->catbo->getCategory($cat_id);
                }
  
***************
*** 52,113 ****
                {
                        $availablelangsforpage = 
$this->pages_bo->getlangarrayforpage($page_id);
!                         if 
(in_array($GLOBALS['phpgw_info']['user']['preferences']['common']['lang'],$availablelangsforpage))
!                         {
!                                 return 
$this->pages_bo->GetPage($page_id,$GLOBALS['phpgw_info']['user']['preferences']['common']['lang']);
!                         }
!                         else
!                         {
!                                 foreach 
($GLOBALS['sitemgr_info']['sitelanguages'] as $lang)
!                                 {
!                                         if 
(in_array($lang,$availablelangsforpage))
!                                         return 
$this->pages_bo->GetPage($page_id,$lang);
!                                 }
!                         }
!                 }
        
  
                function loadPage($page_id)
                {
!                       $this->page = $this->getpagewrapper($page_id);
                }
  
                function loadIndex()
                {
!                       $this->page->title = lang('Site Index');
!                       $this->page->subtitle = '';
!                       $indexarray = $this->getIndex();
!                       $content = "\n".
!                               '<table border="0" width="100%" align="left" 
cellspacing="1" cellpadding="0">
!                               <tr>';
!                       $catname = '';
!                       foreach($indexarray as $page)
!                       {
!                               $buffer = str_pad('', 
$page['catdepth']*24,'&nbsp;');
!                               if ($catname!=$page['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 = $page['catname'];
!                                       if ($page['catdepth'])
!                                       {
!                                               $content .= '&middot;&nbsp;';
!                                       }
!                                       $content .= '<b>'.$catname.'</b> 
&ndash; <i>'.
!                                               $page['catdescrip'].'</i>'."\n";
!                               }
!                               $content .= 
"\n".'<br>&nbsp;&nbsp;&nbsp;&nbsp;&middot;&nbsp;'.$page['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.');
!                       }
!                       $this->page->content = $content;
                }
  
--- 48,87 ----
                {
                        $availablelangsforpage = 
$this->pages_bo->getlangarrayforpage($page_id);
!                       if 
(in_array($GLOBALS['sitemgr_info']['userlang'],$availablelangsforpage))
!                       {
!                               return 
$this->pages_bo->GetPage($page_id,$GLOBALS['sitemgr_info']['userlang']);
!                       }
!                       else
!                       {
!                               foreach 
($GLOBALS['sitemgr_info']['sitelanguages'] as $lang)
!                               {
!                                       if 
(in_array($lang,$availablelangsforpage))
!                                       {
!                                               return 
$this->pages_bo->GetPage($page_id,$lang);
!                                       }
!                               }
!                       }
!                       //fall back to a page in "default" lang
!                       return $this->pages_bo->GetPage($page_id);
!               }
        
  
                function loadPage($page_id)
                {
!                       global $page;
!                       $page = $this->getpagewrapper($page_id);
                }
  
                function loadIndex()
                {
!                       global $page;
!                       $page->title = lang('Site Index');
!                       $page->subtitle = '';
!                       $page->block = CreateObject('sitemgr.Block_SO',True);
!                       $page->block->app_name = 'sitemgr';
!                       $page->block->module_name = 'index';
!                       $page->block->module_id = 
$GLOBALS['Common_BO']->modules->getmoduleid('sitemgr','index');
!                       $page->block->view = 0;
!                       return true;
                }
  
***************
*** 157,252 ****
                function loadTOC($category_id=false)
                {
!                       /*
!                               If category_id is passed in, just show that 
category.  Otherwise,
!                               show all categories.
!                       */
                        if ($category_id)
                        {
!                               $acl = CreateObject('sitemgr.ACL_BO');
!                               if($acl->can_read_category($category_id))
                                {
-                                       $links = 
$this->getPageLinks($category_id,true);
                                        $cat = 
$this->getcatwrapper($category_id);
-                                       $content = '';
                                        if ($cat)
                                        {
!                                               $this->page->title = 
lang('Category').' '.$cat->name;
!                                               $this->page->subtitle = 
'<i>'.$cat->description.'</i>';
!                                               $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 = 
$this->getCatLinks((int) $category_id,false);
!                                               if (count($children))
!                                               {
!                                                       $content .= 
'<br><br><b>' . lang('Subcategories') . ':</b><br>';
!                                                       foreach ($children as 
$child)
!                                                       {
!                                                               $content .= 
'<br>&nbsp;&nbsp;&nbsp;&middot;&nbsp;<b>'.
!                                                                       
$child['link'].'</b> &ndash; '.$child['description'];
!                                                       }
!                                               }
!                                               $content .= '<br><br><b>' . 
lang('Pages') . ':</b><br>';
!                                               $links = 
$this->getPageLinks($category_id,true);
!                                               if (count($links)>0)
!                                               {
!                                                       foreach($links as $pg)
!                                                       {
!                                                               $content .= 
"\n<br>".
!                                                                       
'&nbsp;&nbsp;&nbsp;&middot;&nbsp;'.$pg['link'];
!                                                               if 
(!empty($pg['subtitle']))
!                                                               {
!                                                                       
$content .= ' &ndash; <i>'.$pg['subtitle'].'</i>';
!                                                               }
!                                                               $content .= '';
!                                                       }
!                                               }
!                                               else
!                                               {
!                                                       $content .= '<li>' . 
lang('There are no pages in this section') . '</li>';
!                                               }
!                                               $this->page->content=$content;
!                                       }
!                                       else
!                                       {
!                                               $ui = new ui;
!                                               $ui->displayPage(-1);
!                                               exit;
                                        }
                                }
-                               else
-                               {
-                                       // Following line will spit out an 
ambiguous not exist/ no permission error.
-                                       $ui = new ui;
-                                       $ui->displayPage(-1);
-                                       exit;
-                               }
                        }
                        else
                        {
!                               $this->page->title = lang('Table of Contents');
!                               $this->page->subtitle = '';
!                               $content = '<b>' . lang('Choose a category') . 
':</b><br>';
!                               $links = $this->getCatLinks();
!                               if (count($links)>0)
!                               {
!                                       foreach($links as $cat)
!                                       {
!                                               $buffer = str_pad('', 
$cat['depth']*24,'&nbsp;').'&middot;&nbsp;';
!                                               if (!$cat['depth'])
!                                               {
!                                                       $buffer = 
'<br>'.$buffer;
!                                               }
!                                               $content .= 
"\n".$buffer.$cat['link'].' &mdash; <i>'.$cat['description'].
!                                                       '</i><br>';
!                                       }
!                               }
!                               else
!                               {
!                                       $content .= lang('There are no sections 
available to you.');
!                               }
!                               $this->page->content=$content;
                        }
                        return true;
                }
--- 131,160 ----
                function loadTOC($category_id=false)
                {
!                       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->block = CreateObject('sitemgr.Block_SO',True);
+                       $page->block->app_name = 'sitemgr';
+                       $page->block->module_name = 'toc';
+                       $page->block->arguments = array('category_id' => 
$category_id);
+                       $page->block->module_id = 
$GLOBALS['Common_BO']->modules->getmoduleid('sitemgr','toc');
+                       $page->block->view = 0;
                        return true;
                }
***************
*** 260,263 ****
--- 168,172 ----
                                if ($showhidden || !$page->hidden)
                                {
+                                       //this is not documented!?
                                        if (strtolower($page->subtitle) == 
'link')
                                        {
***************
*** 273,278 ****
                                                $pglinks[$page_id] = array(
                                                        'name'=>$page->name,
!                                                       'link'=>'<a 
href="'.sitemgr_link2('/index.php','page_name='.
!                                                               
$page->name).'">'.$page->title.'</a>',
                                                        'title'=>$page->title,
                                                        
'subtitle'=>$page->subtitle
--- 182,186 ----
                                                $pglinks[$page_id] = array(
                                                        'name'=>$page->name,
!                                                       'link'=>'<a 
href="'.sitemgr_link('page_name='.$page->name).'">'.$page->title.'</a>',
                                                        'title'=>$page->title,
                                                        
'subtitle'=>$page->subtitle
***************
*** 300,305 ****
                                $catlinks[$cat_id] = array(
                                        'name'=>$category->name,
!                                       'link'=>'<a 
href="'.sitemgr_link2('/index.php',
!                                               
'category_id='.$cat_id).'">'.$category->name.'</a>',
                                        'description'=>$category->description,
                                        'depth'=>$category->depth
--- 208,212 ----
                                $catlinks[$cat_id] = array(
                                        'name'=>$category->name,
!                                       'link'=>'<a 
href="'.sitemgr_link('category_id='.$cat_id).'">'.$category->name.'</a>',
                                        'description'=>$category->description,
                                        'depth'=>$category->depth
***************
*** 309,347 ****
                }
  
-               function get_header()
-               {
-                       return 
$this->headerfooter_bo->getsiteheader($GLOBALS['phpgw_info']['user']['preferences']['common']['lang']);
-               }
- 
-               function get_siteName()
-               {
-                       $prefs = CreateObject('sitemgr.sitePreference_SO');
-                       return $prefs->getPreference('sitemgr-site-name-' . 
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang']);
-               }
- 
-               function get_title()
-               {
-                       return $this->page->title;
-               }
- 
-               function get_subtitle()
-               {
-                       return $this->page->subtitle;
-               }
- 
-               function get_content()
-               {
-                       return $this->page->content;
-               }
- 
-               function get_footer()
-               {
-                       return 
$this->headerfooter_bo->getsitefooter($GLOBALS['phpgw_info']['user']['preferences']['common']['lang']);
-               }
  
                function is_user()
                {
                        global $sitemgr_info,$phpgw_info;
!                       if ($phpgw_info['user']['account_lid'] != 
$sitemgr_info['login'])
                        {
                                return true;
--- 216,224 ----
                }
  
  
                function is_user()
                {
                        global $sitemgr_info,$phpgw_info;
!                       if ($phpgw_info['user']['account_lid'] != 
$sitemgr_info['anonymous-user'])
                        {
                                return true;
***************
*** 369,384 ****
                        {
                                
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = $postlang;
                                
$GLOBALS['phpgw']->session->appsession('language','sitemgr-site',$postlang);
                                return;
                        }
!                   
                        $sessionlang = 
$GLOBALS['phpgw']->session->appsession('language','sitemgr-site');
                        if ($sessionlang)
                        {
                                
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = $sessionlang;
                                return;
                        }
                        
!                   if ($this->is_user())
                        {
                                $userlang = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'];
--- 246,263 ----
                        {
                                
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = $postlang;
+                               $GLOBALS['sitemgr_info']['userlang'] = 
$postlang;
                                
$GLOBALS['phpgw']->session->appsession('language','sitemgr-site',$postlang);
                                return;
                        }
!               
                        $sessionlang = 
$GLOBALS['phpgw']->session->appsession('language','sitemgr-site');
                        if ($sessionlang)
                        {
                                
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = $sessionlang;
+                               $GLOBALS['sitemgr_info']['userlang'] = 
$sessionlang;
                                return;
                        }
                        
!               if ($this->is_user())
                        {
                                $userlang = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'];
***************
*** 389,399 ****
                                //but save it to the appsession for quicker 
retrieval
                                
$GLOBALS['phpgw']->session->appsession('language','sitemgr-site',$userlang);
!                           return;
                                }
                        }
!                                    
                        // create a array of languages the user is accepting
                        $userLanguages = 
explode(',',$GLOBALS['HTTP_ACCEPT_LANGUAGE']);
!                   
                        // find usersupported language
                        while (list($key,$value) = each($userLanguages))
--- 268,279 ----
                                //but save it to the appsession for quicker 
retrieval
                                
$GLOBALS['phpgw']->session->appsession('language','sitemgr-site',$userlang);
!                               $GLOBALS['sitemgr_info']['userlang'] = 
$userlang;
!                       return;
                                }
                        }
!                               
                        // create a array of languages the user is accepting
                        $userLanguages = 
explode(',',$GLOBALS['HTTP_ACCEPT_LANGUAGE']);
!               
                        // find usersupported language
                        while (list($key,$value) = each($userLanguages))
***************
*** 416,421 ****
                                $browserlang = $supportedLanguages[0];
                        }
!                   
                        
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = $browserlang;
                        
$GLOBALS['phpgw']->session->appsession('language','sitemgr-site',$browserlang);
                }
--- 296,302 ----
                                $browserlang = $supportedLanguages[0];
                        }
!               
                        
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = $browserlang;
+                       $GLOBALS['sitemgr_info']['userlang'] = $browserlang;
                        
$GLOBALS['phpgw']->session->appsession('language','sitemgr-site',$browserlang);
                }

Index: class.ui.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/sitemgr-site/inc/class.ui.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** class.ui.inc.php    5 Dec 2002 22:15:01 -0000       1.9
--- class.ui.inc.php    17 Jan 2003 03:37:52 -0000      1.10
***************
*** 9,40 ****
        * option) any later version.                                            
   *
        
\**************************************************************************/
        /* $Id$ */
  
        class ui
        {
-               var $bo;
                var $t;
-               var $blocks_bo;
                
  
                function ui()
                {
!                       $this->bo = new bo;
!                       $this->t = new Template2;
! 
!                       $this->bo->setsitemgrPreferredLanguage();
!                       
!                       
require_once($GLOBALS['sitemgr_info']['sitemgr-site_path'] .
!                               '/inc/class.blocks_bo.inc.php');
!                       $this->blocks_bo = new blocks_bo;
!                       
!                       
                }
  
                function displayPageByName($page_name)
                {
!                       $pages_so = CreateObject('sitemgr.Pages_SO');
!                       $page = 
$pages_so->getPageByName($page_name,$GLOBALS['phpgw_info']['user']['preferences']['common']['lang']);
!                       $this->bo->loadPage($page->id);
                        $this->generatePage();
                }
--- 9,33 ----
        * option) any later version.                                            
   *
        
\**************************************************************************/
+ 
        /* $Id$ */
  
        class ui
        {
                var $t;
                
  
                function ui()
                {
!                       $themesel = $GLOBALS['sitemgr_info']['themesel'];
!                       $templateroot = 
$GLOBALS['sitemgr_info']['sitemgr-site-dir'] . SEP . 'templates' . SEP . 
$themesel;
!                       $this->t = new Template3($templateroot);
                }
  
                function displayPageByName($page_name)
                {
!                       global $objbo;
!                       global $page;
!                       $page = 
$GLOBALS['Common_BO']->pages->pageso->getPageByName($page_name,$GLOBALS['phpgw_info']['user']['preferences']['common']['lang']);
!                       $objbo->loadPage($page->id);
                        $this->generatePage();
                }
***************
*** 42,46 ****
                function displayPage($page_id)
                {
!                       $this->bo->loadPage($page_id);
                        $this->generatePage();
                }
--- 35,40 ----
                function displayPage($page_id)
                {
!                       global $objbo;
!                       $objbo->loadPage($page_id);
                        $this->generatePage();
                }
***************
*** 48,52 ****
                function displayIndex()
                {
!                       $this->bo->loadIndex();
                        $this->generatePage();
                }
--- 42,47 ----
                function displayIndex()
                {
!                       global $objbo;
!                       $objbo->loadIndex();
                        $this->generatePage();
                }
***************
*** 54,58 ****
                function displayTOC($categoryid=false)
                {
!                       $this->bo->loadTOC($categoryid);
                        $this->generatePage();
                }
--- 49,54 ----
                function displayTOC($categoryid=false)
                {
!                       global $objbo;
!                       $objbo->loadTOC($categoryid);
                        $this->generatePage();
                }
***************
*** 79,179 ****
                function generatePage()
                {
!                       if ($GLOBALS['sitemgr_info']['usethemes'])
!                       {
!                               $this->generatePageTheme();
!                       }
!                       else
!                       {
!                               $this->generatePageTemplate();
!                       }
!               }
! 
!               function generatePageTheme()
!               {
!                       /* Note: much of this func was taken from phpNuke -- it
!                          is their template system so don't blame me for the 
mess */
!                       global $header,$foot1,$user,$sitename,$index;
! 
!                       require_once('./inc/phpnuke.compat.inc.php');
!                       $index = 1;
! 
!                       $themesel = $GLOBALS['sitemgr_info']['themesel'];
!                       if 
(file_exists($GLOBALS['sitemgr_info']['sitemgr-site_path'].'/themes/'.$themesel.'/theme.php'))
!                       {
!                               
require_once($GLOBALS['sitemgr_info']['sitemgr-site_path'] . '/themes/' . 
$themesel . '/theme.php');
!                       }
!                       else
!                       {
!                               die(lang("Selected theme %1 does not 
exist.",$themesel));
!                       }
! 
!                       echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 
Transitional//EN">';
!                       echo "\n<html>\n<head>\n<title>" . 
$this->bo->get_siteName() . ': ' . 
!                               $this->bo->get_title() . "</title>\n";
!                       add_theme_var('sitename',$this->bo->get_siteName());
!                       
add_theme_var('user',$GLOBALS['phpgw_info']['user']['account_lid']);
!                       add_theme_var('header', $this->bo->get_header());
!                       add_theme_var('footer', $this->bo->get_footer());
!                       include $GLOBALS['sitemgr_info']['sitemgr-site_path'] . 
'/inc/meta.ui.inc.php';
!                       echo '<LINK REL="StyleSheet" HREF="themes/' . $themesel 
. 
!                               '/style/style.css" TYPE="text/css">' . "\n\n\n";
!                       echo '</head>' . "\n";
!                       themeheader();
!                       $this->blocks_bo->blocks('c',$this->t);
!                       echo OpenTable();
!                       echo "<h1>" . $this->bo->get_title() . "</h1>";
!                       echo "<h3>" . $this->bo->get_subtitle() . "</h3>";
!                       echo 
"<p>".parse_theme_vars($this->bo->get_content())."</p>";
!                       echo CloseTable();
!                       themefooter();
!                       echo "</body></html>";
                }
  
-               function generatePageTemplate()
-               {
-                       $themesel = $GLOBALS['sitemgr_info']['themesel'];
-                       $templatedir = 
$GLOBALS['sitemgr_info']['sitemgr-site_path'].'/templates/';
-                       if (!file_exists($templatedir.$themesel.'/main.tpl'))
-                       {
-                               die(lang("Selected template %1 does not 
exist.",$themesel));
-                       }
-                       $this->t->set_root($templatedir);
-                       $this->t->set_unknowns('keep');
- 
-                       $this->t->set_file('header','header.tpl');
-                       $this->t->set_var('themesel',$themesel);
-                       
$this->t->set_var('site_name',$this->bo->get_siteName());
-                       $this->t->set_var('page_title',$this->bo->get_title());
-                       $this->t->pfp('out','header');
-                       $this->t->set_file('body',$themesel.'/main.tpl');
- 
-                       $this->t->set_var('opencurly','{');
-                       $this->t->set_var('closecurly','}');
-                       $this->t->set_var('user', 
-                               $GLOBALS['phpgw_info']['user']['account_lid']);
-                       
$this->t->set_var('site_name',$this->bo->get_siteName());
-                       $this->t->set_var('site_header', 
$this->bo->get_header());
-                       $this->t->set_var('site_footer', 
$this->bo->get_footer());
-                       $this->t->set_var('page_title', $this->bo->get_title());
-                       $this->t->set_var('page_subtitle', 
$this->bo->get_subtitle());
-                       $this->t->set_var('page_content', 
$this->bo->get_content());
- 
-                       
$this->t->set_file('sideblocks',$themesel.'/sideblock.tpl');
-                       $this->t->set_block('sideblocks','SideBlock','SBlock');
-                       $this->blocks_bo->blocks('l',$this->t);
-                       
$this->t->set_var('left_blocks',$this->t->get_var('SBlock'));
-                       $this->t->set_var('SBlock','');
-                       $this->blocks_bo->blocks('r',$this->t);
-                       
$this->t->set_var('right_blocks',$this->t->get_var('SBlock'));
-                       $this->t->set_var('SBlock','');
- 
-                       
$this->t->set_file('centerblocks',$themesel.'/centerblock.tpl');
-                       
$this->t->set_block('centerblocks','SideBlock','SBlock');
-                       $this->blocks_bo->blocks('c',$this->t);
-                       
$this->t->set_var('center_blocks',$this->t->get_var('SBlock'));
-                       $this->t->set_var('SBlock','');
- 
-                       $this->t->pfp('out','body');
-               }
        }
  ?>
--- 75,81 ----
                function generatePage()
                {
!                       echo $this->t->parse();
                }
  
        }
  ?>

--- class.Template2.inc.php DELETED ---

--- class.blocks_bo.inc.php DELETED ---

--- class.so.inc.php DELETED ---





reply via email to

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