phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: sitemgr/inc class.ManageTranslations_UI.inc.php,


From: Patrick Walsh <address@hidden>
Subject: [Phpgroupware-cvs] CVS: sitemgr/inc class.ManageTranslations_UI.inc.php,NONE,1.1.2.1 class.Admin_ManageCategories_UI.inc.php,1.5.2.2,1.5.2.3 class.Categories_BO.inc.php,1.4.2.1,1.4.2.2 class.Categories_SO.inc.php,1.10.2.1,1.10.2.2 class.Common_UI.inc.php,1.6.2.3,1.6.2.4 class.MainMenu_UI.inc.php,1.3.2.2,1.3.2.3 class.Page_SO.inc.php,1.3,1.3.2.1 class.Pages_BO.inc.php,1.2.2.1,1.2.2.2 class.Pages_SO.inc.php,1.8,1.8.2.1 class.admin_ManageSiteContent_UI.inc.php,1.1.1.1.2.2,1.1.1.1.2.3 class.contributor_ManagePage_UI.inc.php,1.7.2.3,1.7.2.4 class.headerFooter_BO.inc.php,1.1.1.1,1.1.1.1.2.1
Date: Fri, 22 Nov 2002 01:01:55 -0500

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

Modified Files:
      Tag: Version-0_9_14-branch
        class.Admin_ManageCategories_UI.inc.php 
        class.Categories_BO.inc.php class.Categories_SO.inc.php 
        class.Common_UI.inc.php class.MainMenu_UI.inc.php 
        class.Page_SO.inc.php class.Pages_BO.inc.php 
        class.Pages_SO.inc.php 
        class.admin_ManageSiteContent_UI.inc.php 
        class.contributor_ManagePage_UI.inc.php 
        class.headerFooter_BO.inc.php 
Added Files:
      Tag: Version-0_9_14-branch
        class.ManageTranslations_UI.inc.php 
Log Message:
Updated multi-lingual support


--- NEW FILE ---
<?php
        
/***************************************************************************\
        * phpGroupWare - Web Content Manager                                    
    *
        * http://www.phpgroupware.org                                           
    *
        * -------------------------------------------------                     
    *
        * This program is free software; you can redistribute it and/or modify 
it   *
        * under the terms of the GNU General Public License as published by the 
    *
        * Free Software Foundation; either version 2 of the License, or (at 
your    *
        * option) any later version.                                            
    *
        
\***************************************************************************/

        class ManageTranslations_UI
        {
          var $t;
          var $cat_bo;
          var $acl;
          var $preferenceso;
          var $sitelanguages;
          var $common_ui;
          var $pagebo;
          
          var $public_functions = array
                (
                 '_manageTranslations' => True,
                 '_translateCategory' => True,
                 '_translatePage' => True,
                );

          function ManageTranslations_UI()
            {
              $this->t = $GLOBALS['phpgw']->template;
              $this->cat_bo = CreateObject('sitemgr.Categories_BO', True);
              $this->acl = CreateObject('sitemgr.ACL_BO', True);
              $this->preferenceso = CreateObject('sitemgr.sitePreference_SO', 
true);
              $this->sitelanguages = 
explode(',',$this->preferenceso->getPreference('sitelanguages'));
              $this->common_ui = CreateObject('sitemgr.Common_UI',True);
              $this->pagebo = CreateObject('sitemgr.Pages_BO', True);
              
            }

          function globalize($varname)
                {
                        if (is_array($varname))
                        {
                                foreach($varname as $var)
                                {
                                        $GLOBALS[$var] = $_POST[$var];
                                }
                        }
                        else
                        {
                                $GLOBALS[$varname] = $_POST[$varname];
                        }
                }

                //this has to be moved somewhere else later
                function getlangname($lang)
                  {
                    $GLOBALS['phpgw']->db->query("select lang_name from 
languages where lang_id = '$lang'",__LINE__,__FILE__);
                    $GLOBALS['phpgw']->db->next_record();
                    return $GLOBALS['phpgw']->db->f('lang_name');
                  }

                function _manageTranslations()
                  {
                    $this->common_ui->DisplayHeader();

                    $this->t->set_file('ManageTranslations', 
'manage_translations.tpl');
                    $this->t->set_block('ManageTranslations', 'PageBlock', 
'PBlock');
                    $this->t->set_block('PageBlock', 'langexistpage', 
'langpageBlock');
                    $this->t->set_block('ManageTranslations', 'CategoryBlock', 
'CBlock');
                    $this->t->set_block('CategoryBlock', 'langexistcat', 
'langcatBlock');
                    $this->t->set_block('ManageTranslations', 'sitelanguages', 
'slBlock');

                    foreach ($this->sitelanguages as $lang)
                      {
                        $this->t->set_var('sitelanguage',$lang);
                        $this->t->parse('slBlock', 'sitelanguages', true);
                      }

                    $this->t->set_var(Array('translation_manager' => 
lang('Translation Manager'),
                                            'lang_catname' => lang('Category 
Name')));
                    $this->cat_list = 
$this->cat_bo->getPermittedCatWriteNested();
                    if($this->cat_list)
                      {
                        for($i = 0; $i < sizeof($this->cat_list); $i++)
                          {                     

                            //setup entry in categorblock for translations of 
categories
                            $this->cat = 
$this->cat_bo->getCategory($this->cat_list[$i]);
                            if ($this->cat->depth)
                              {
                                $buffer = '-';
                              }
                            else
                              {
                                $buffer = '';
                              }
                            $buffer = str_pad('',$this->cat->depth*18,
                                              '&nbsp;',STR_PAD_LEFT).$buffer;
                            $this->t->set_var('buffer', $buffer);
                            $this->t->set_var('category', $this->cat->name);
                            $category_id = $this->cat_list[$i];

                            $availablelangsforcat = 
$this->cat_bo->getlangarrayforcategory($category_id);
                            $this->t->set_var('langcatBlock','');
                            foreach ($this->sitelanguages as $lang)
                                {
                                  $this->t->set_var('catexistsinlang', 
in_array($lang,$availablelangsforcat) ? 'ø' : '&nbsp;');
                                  $this->t->parse('langcatBlock', 
'langexistcat', true);
                                }
                            
                            $this->t->set_var('translatecat', 
                                              '<form action="'.
                                              
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.ManageTranslations_UI._translateCategory').
                                              '" method="POST"><input 
type="submit" name="btnTranslateCategory" value="' . lang('Translate') .'">'.
                                              '<input type="hidden" 
name="category_id" value="'.$category_id.'"></form>');

                            //setup page list
                            $this->t->set_var('PBlock', '');
                            $this->page_list = 
$this->pagebo->getPageIDList($this->cat_list[$i]);
                            if($this->page_list && sizeof($this->page_list)>0)
                              {
                                for($j = 0; $j < sizeof($this->page_list); $j++)
                                  {
                                    $this->page_id =$this->page_list[$j];
                                    $this->page = 
$this->pagebo->getPage($this->page_id,$this->sitelanguages[0]);
                                    $page_description = '<i>' . lang('Page') . 
': </i>'.$this->page->name.'<br><i>' . lang('Title') . ': 
</i>'.$this->page->title;
                                    $this->t->set_var('page', 
$page_description);

                                    $availablelangsforpage = 
$this->pagebo->getlangarrayforpage($this->page_id);
                                    $this->t->set_var('langpageBlock','');
                                    foreach ($this->sitelanguages as $lang)
                                      {
                                        $this->t->set_var('pageexistsinlang', 
in_array($lang,$availablelangsforpage) ? 'ø' : '&nbsp;');
                                        $this->t->parse('langpageBlock', 
'langexistpage', true);
                                      }

                                    $this->t->set_var('translatepage', 
                                              '<form action="'.
                                              
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.ManageTranslations_UI._translatePage').
                                              '" method="POST"><input 
type="submit" name="btnTranslatePage" value="' . lang('Translate') .'">'.
                                              '<input type="hidden" 
name="page_id" value="'.$this->page_id.'"></form>');
                                    $this->t->parse('PBlock', 'PageBlock', 
true);
                                  }
                              }
                                
                            $this->t->parse('CBlock', 'CategoryBlock', true); 
                          }
                      }
                    else
                      {
                        $this->t->set_var('category','No category is 
available');
                      }
                    $this->t->pfp('out', 'ManageTranslations');

                    $this->common_ui->DisplayFooter();
                  }

                function _translateCategory()
                  {
                    
                    
$this->globalize(array('category_id','changelanguage','showlanguage','savelanguage','btnSaveCategory','savecatname','savecatdesc'));
                    global $category_id, $changelanguage, $showlanguage, 
$savelanguage, $btnSaveCategory, $savecatname, $savecatdesc;
                    
                    if ($btnSaveCategory)
                      {
                        $this->cat_bo->saveCategoryLang($category_id, 
$savecatname, $savecatdesc, $savelanguage);
                        $this->_manageTranslations();
                        return;
                      }

                    $this->common_ui->DisplayHeader();
                    $this->t->set_file('TranslateCategory', 
'translate_category.tpl');
                    
                    if($error)
                        {
                          $this->t->set_var('error_msg',lang('You failed to 
fill in one or more required fields.'));
                          $this->cat->name = $savecatname;
                          $this->cat->description = $savecatdesc;
                        }
                        else
                        {
                          $this->cat = $this->cat_bo->getCategory($category_id);
                          $showlanguage = $showlanguage ? $showlanguage : 
$this->sitelanguages[0];
                          $showlangdata = 
$this->cat_bo->getCategory($category_id,$showlanguage);
                          $savelanguage = $savelanguage ? $savelanguage : 
$this->sitelanguages[1]; 
                          $savelangdata = 
$this->cat_bo->getCategory($category_id,$savelanguage);

                          $this->t->set_var(Array('translate' => 
lang('Translate Category'),
                                                  'lang_refresh' => '<input 
type="submit" value="' . lang('Refresh') .'" name="changelanguage">'));
                          $select = '<select name="showlanguage">';
                            foreach ($this->sitelanguages as $lang)
                              {
                                $selected= '';
                                if ($lang == $showlanguage)
                                  {
                                    $selected = 'selected="selected" ';
                                  }
                                $select .= '<option ' . $selected .'value="' . 
$lang . '">'. $this->getlangname($lang) . '</option>';
                              }
                            $select .= '</select> ';
                            $this->t->set_var('showlang', $select);

                            $select = '<select name="savelanguage">';
                            foreach ($this->sitelanguages as $lang)
                              {
                                $selected= '';
                                if ($lang == $savelanguage)
                                  {
                                    $selected = 'selected="selected" ';
                                  }
                                $select .= '<option ' . $selected .'value="' . 
$lang . '">'. $this->getlangname($lang) . '</option>';
                              }
                            $select .= '</select>';
                            $this->t->set_var('savelang', $select);
                            
                            $this->t->set_var(Array('catid' => $category_id,
                                                    'lang_catname' => 
lang('Category Name'),
                                                    'showcatname' => 
$showlangdata->name,
                                                    'savecatname' => 
$savelangdata->name,
                                                    'lang_catdesc' => 
lang('Category Description'),
                                                    'showcatdesc' => 
$showlangdata->description,
                                                    'savecatdesc' => 
$savelangdata->description,
                                                    'lang_reset' => 
lang('Reset'),
                                                    'lang_save' => 
lang('Save')));
                            $this->t->pfp('out','TranslateCategory');
                        }
                    $this->common_ui->DisplayFooter();
                  }

                function _translatePage()
                  {

                    
$this->globalize(array('page_id','changelanguage','showlanguage','savelanguage','btnSavePage','savepagetitle','savepagesubtitle','savepagecontent'));
                    global $page_id, $changelanguage, $showlanguage, 
$savelanguage, $btnSavePage, $savepagetitle, $savepagesubtitle, 
$savepagecontent;
                    
                    if ($btnSavePage)
                      {
                        $this->page->id = $page_id;
                        $this->page->title = $savepagetitle;
                        $this->page->subtitle = $savepagesubtitle;
                        $this->page->content = $savepagecontent; 
                        $this->pagebo->savePageLang($this->page, $savelanguage);
                        $this->_manageTranslations();
                        return;
                      }

                    $this->common_ui->DisplayHeader();

                    $this->t->set_file('TranslatePage', 'translate_page.tpl');

                    if($error)
                      {
                        $this->t->set_var('error_msg',lang('You failed to fill 
in one or more required fields.'));
                        $this->page->tite = $savepagetitle;
                        $this->page->subtitle = $savepagesubtitle;
                        $this->page->content = $savepagecontent;
                      }
                    else
                      {
                         $this->page = $this->pagebo->getPage($page_id);
                         $showlanguage = $showlanguage ? $showlanguage : 
$this->sitelanguages[0];
                         $showlangdata = 
$this->pagebo->getPage($page_id,$showlanguage);
                         $savelanguage = $savelanguage ? $savelanguage : 
$this->sitelanguages[1]; 
                         $savelangdata = 
$this->pagebo->getPage($page_id,$savelanguage);

                         $this->t->set_var(Array('translate' => lang('Translate 
Page'),
                                                  'lang_refresh' => '<input 
type="submit" value="' . lang('Refresh') .'" name="changelanguage">'));
                         $select = '<select name="showlanguage">';
                         foreach ($this->sitelanguages as $lang)
                           {
                             $selected= '';
                             if ($lang == $showlanguage)
                               {
                                 $selected = 'selected="selected" ';
                               }
                             $select .= '<option ' . $selected .'value="' . 
$lang . '">'. $this->getlangname($lang) . '</option>';
                           }
                         $select .= '</select> ';
                         $this->t->set_var('showlang', $select);
                         
                         $select = '<select name="savelanguage">';
                         foreach ($this->sitelanguages as $lang)
                           {
                             $selected= '';
                             if ($lang == $savelanguage)
                               {
                                 $selected = 'selected="selected" ';
                               }
                             $select .= '<option ' . $selected .'value="' . 
$lang . '">'. $this->getlangname($lang) . '</option>';
                           }
                         $select .= '</select>';
                         $this->t->set_var('savelang', $select);

                         $this->t->set_var(Array('pageid' => $page_id,
                                                 'lang_pagename' => lang('Page 
Name'),
                                                 'pagename' => 
$this->page->name,
                                                 'lang_pagetitle' => lang('Page 
Title'),
                                                 'showpagetitle' => 
$showlangdata->title,
                                                 'savepagetitle' => 
$savelangdata->title,
                                                 'lang_pagesubtitle' => 
lang('Page Subtitle'),
                                                 'showpagesubtitle' => 
$showlangdata->subtitle,
                                                 'savepagesubtitle' => 
$savelangdata->subtitle,
                                                 'lang_pagecontent' => 
lang('Page Content'),
                                                 'showpagecontent' => 
$GLOBALS['phpgw']->strip_html($showlangdata->content),
                                                 'savepagecontent' => 
$savelangdata->content,
                                                 'lang_reset' => lang('Reset'),
                                                 'lang_save' => lang('Save')));
                         $this->t->pfp('out','TranslatePage');
                      }
                    $this->common_ui->DisplayFooter();
                  }
        }
Index: class.Admin_ManageCategories_UI.inc.php
===================================================================
RCS file: 
/cvsroot/phpgroupware/sitemgr/inc/class.Admin_ManageCategories_UI.inc.php,v
retrieving revision 1.5.2.2
retrieving revision 1.5.2.3
diff -C2 -r1.5.2.2 -r1.5.2.3
*** class.Admin_ManageCategories_UI.inc.php     17 Oct 2002 04:17:14 -0000      
1.5.2.2
--- class.Admin_ManageCategories_UI.inc.php     22 Nov 2002 06:01:53 -0000      
1.5.2.3
***************
*** 18,21 ****
--- 18,23 ----
                var $acl;
                var $t;
+               var $preferenceso;
+               var $sitelanguages;
                
                var $public_functions = array
***************
*** 29,32 ****
--- 31,36 ----
                        $this->cat_bo = CreateObject('sitemgr.Categories_BO', 
True);
                        $this->acl = CreateObject('sitemgr.ACL_BO', True);
+                       $this->preferenceso = 
CreateObject('sitemgr.sitePreference_SO', true);
+                       $this->sitelanguages = 
explode(',',$this->preferenceso->getPreference('sitelanguages'));
                }
  
***************
*** 46,55 ****
                }
  
                function _manageCategories()
                {
!                       
$this->globalize(array('btnSaveCategory','btnAddCategory','btnEditCategory','btnDelete','btnPermission','category_id','catname','catdesc','catid','sort_order','parent','parent_old','groupaccessread','groupaccesswrite','individualaccessread','individualaccesswrite'));
                        global 
$btnSaveCategory,$btnAddCategory,$btnEditCategory,$btnDelete,$btnPermission;
                        global 
$category_id,$catname,$catdesc,$catid,$sort_order,$parent,$parent_old;
                        global $groupaccessread, $groupaccesswrite, 
$individualaccessread, $individualaccesswrite;
  
                        $common_ui = CreateObject('sitemgr.Common_UI',True);
--- 50,68 ----
                }
  
+               //this has to be moved somewhere else later
+               function getlangname($lang)
+                 {
+                   $GLOBALS['phpgw']->db->query("select lang_name from 
languages where lang_id = '$lang'",__LINE__,__FILE__);
+                   $GLOBALS['phpgw']->db->next_record();
+                   return $GLOBALS['phpgw']->db->f('lang_name');
+                 }
+ 
                function _manageCategories()
                {
!                       
$this->globalize(array('btnSaveCategory','btnAddCategory','btnEditCategory','btnDelete','btnPermission','category_id','catname','catdesc','catid','sort_order','parent','parent_old','groupaccessread','groupaccesswrite','individualaccessread','individualaccesswrite','savelanguage'));
                        global 
$btnSaveCategory,$btnAddCategory,$btnEditCategory,$btnDelete,$btnPermission;
                        global 
$category_id,$catname,$catdesc,$catid,$sort_order,$parent,$parent_old;
                        global $groupaccessread, $groupaccesswrite, 
$individualaccessread, $individualaccesswrite;
+                       global $savelanguage;
  
                        $common_ui = CreateObject('sitemgr.Common_UI',True);
***************
*** 89,93 ****
                                                $groupaccess = 
array_merge_recursive($groupaccessread, $groupaccesswrite);
                                                $individualaccess = 
array_merge_recursive($individualaccessread, $individualaccesswrite);
!                                               
$this->cat_bo->saveCategoryInfo($catid, $catname, $catdesc, $sort_order, 
$parent, $parent_old);
                                                
$this->cat_bo->saveCategoryPerms($catid, $groupaccess, $individualaccess);
                                        }
--- 102,107 ----
                                                $groupaccess = 
array_merge_recursive($groupaccessread, $groupaccesswrite);
                                                $individualaccess = 
array_merge_recursive($individualaccessread, $individualaccesswrite);
!                                               $savelanguage = $savelanguage ? 
$savelanguage : $this->sitelanguages[0];
!                                               
$this->cat_bo->saveCategoryInfo($catid, $catname, $catdesc, $savelanguage, 
$sort_order, $parent, $parent_old);
                                                
$this->cat_bo->saveCategoryPerms($catid, $groupaccess, $individualaccess);
                                        }
***************
*** 104,108 ****
                                                for($i = 0; $i < 
sizeof($this->cat_list); $i++)
                                                {
!                                                       $this->cat = 
$this->cat_bo->getCategory($this->cat_list[$i]);
                                                        if ($this->cat->depth)
                                                        {
--- 118,122 ----
                                                for($i = 0; $i < 
sizeof($this->cat_list); $i++)
                                                {
!                                                       $this->cat = 
$this->cat_bo->getCategory($this->cat_list[$i],$this->sitelanguages[0]);
                                                        if ($this->cat->depth)
                                                        {
***************
*** 186,190 ****
                                if ($cat_id)
                                {
!                                       $this->cat = 
$this->cat_bo->getCategory($cat_id); 
                                        $permissionlist = 
$this->acl->get_group_permission_list($cat_id);
                                        //print_r($permissionlist);
--- 200,204 ----
                                if ($cat_id)
                                {
!                                       $this->cat = 
$this->cat_bo->getCategory($cat_id,$this->sitelanguages[0]); 
                                        $permissionlist = 
$this->acl->get_group_permission_list($cat_id);
                                        //print_r($permissionlist);
***************
*** 200,203 ****
--- 214,228 ----
                        }
  
+                       if (count($this->sitelanguages))
+                         {
+                           $select = lang('as') . ' <select 
name="savelanguage">';
+                           foreach ($this->sitelanguages as $lang)
+                             {
+                               $select .= '<option value="' . $lang . '">'. 
$this->getlangname($lang) . '</option>';
+                             }
+                           $select .= '</select> ';
+                           $this->t->set_var('savelang',$select);
+                         }
+ 
                        $this->t->set_var(array(
                                'catid' => $cat_id,
***************
*** 365,369 ****
                        else
                        {
!                               $cat = $this->cat_bo->getCategory($cat_id);
                                
$this->t->set_file('ConfirmDelete','confirmdelete.tpl');
                                $this->t->set_var('deleteheader',lang('Are you 
sure you want to delete the category %1 and all of its associated pages?  You 
cannot retrieve the deleted pages if you continue.',$cat->name));
--- 390,394 ----
                        else
                        {
!                               $cat = 
$this->cat_bo->getCategory($cat_id,$this->sitelanguages[0]);
                                
$this->t->set_file('ConfirmDelete','confirmdelete.tpl');
                                $this->t->set_var('deleteheader',lang('Are you 
sure you want to delete the category %1 and all of its associated pages?  You 
cannot retrieve the deleted pages if you continue.',$cat->name));

Index: class.Categories_BO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Categories_BO.inc.php,v
retrieving revision 1.4.2.1
retrieving revision 1.4.2.2
diff -C2 -r1.4.2.1 -r1.4.2.2
*** class.Categories_BO.inc.php 16 Oct 2002 20:14:06 -0000      1.4.2.1
--- class.Categories_BO.inc.php 22 Nov 2002 06:01:53 -0000      1.4.2.2
***************
*** 172,176 ****
                }
  
!               function saveCategoryInfo($cat_id, $cat_name, $cat_description, 
$sort_order=0, $parent=0, $old_parent=0)
                {
                        $cat_info = CreateObject('sitemgr.Category_SO', True);
--- 172,176 ----
                }
  
!               function saveCategoryInfo($cat_id, $cat_name, $cat_description, 
$lang, $sort_order=0, $parent=0, $old_parent=0)
                {
                        $cat_info = CreateObject('sitemgr.Category_SO', True);
***************
*** 191,199 ****
                        if ($this->acl->can_write_category($cat_id))
                        {       
!                               if($this->so->saveCategory($cat_info))
!                               {
!                                       return True;
!                               }
!                               return False;
                        }
                        else
--- 191,203 ----
                        if ($this->acl->can_write_category($cat_id))
                        {       
!                         if ($this->so->saveCategory($cat_info));
!                         {
!                           if ($this->so->saveCategoryLang($cat_id, $cat_name, 
$cat_description, $lang))
!                             {
!                               return True;
!                             }
!                           return false;
!                         }
!                         return false;
                        }
                        else
***************
*** 203,211 ****
                }
  
!               function getCategory($cat_id)
                {
                        if ($this->acl->can_read_category($cat_id))
                        {
!                               return $this->so->getCategory($cat_id);
                        }
                        else
--- 207,224 ----
                }
  
!               function saveCategoryLang($cat_id, $cat_name, $cat_description, 
$lang)
!                 {
!                   if ($this->so->saveCategoryLang($cat_id, $cat_name, 
$cat_description, $lang))
!                     {
!                       return True;
!                     }
!                   return false;
!                 }
!               
!               function getCategory($cat_id,$lang=False)
                {
                        if ($this->acl->can_read_category($cat_id))
                        {
!                               return $this->so->getCategory($cat_id,$lang);
                        }
                        else
***************
*** 214,218 ****
                        }
                }
!               
                function saveCategoryPerms($cat_id, $group_access, $user_access)
                {
--- 227,236 ----
                        }
                }
! 
!               function getlangarrayforcategory($cat_id)
!                 {
!                   return $this->so->getlangarrayforcategory($cat_id);
!                 }
! 
                function saveCategoryPerms($cat_id, $group_access, $user_access)
                {

Index: class.Categories_SO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Categories_SO.inc.php,v
retrieving revision 1.10.2.1
retrieving revision 1.10.2.2
diff -C2 -r1.10.2.1 -r1.10.2.2
*** class.Categories_SO.inc.php 16 Oct 2002 20:14:06 -0000      1.10.2.1
--- class.Categories_SO.inc.php 22 Nov 2002 06:01:53 -0000      1.10.2.2
***************
*** 3,10 ****
        {
                var $cats;
! 
                function Categories_SO()
                {
                        $this->cats = 
CreateObject('phpgwapi.categories',-1,'sitemgr');
                }
  
--- 3,12 ----
        {
                var $cats;
!               var $db;
!               
                function Categories_SO()
                {
                        $this->cats = 
CreateObject('phpgwapi.categories',-1,'sitemgr');
+                       $this->db = $GLOBALS['phpgw']->db;
                }
  
***************
*** 99,103 ****
                }
  
!               function getCategory($cat_id)
                {
                        $cat = $this->cats->return_single($cat_id);
--- 101,128 ----
                }
  
!               function saveCategoryLang($cat_id, $cat_name, $cat_description, 
$lang)
!                 {
!                   $this->db->query("SELECT * FROM 
phpgw_sitemgr_categories_lang WHERE cat_id='$cat_id' and lang='$lang'", 
__LINE__,__FILE__);
!                   if ($this->db->next_record())
!                     {
!                       $this->db->query("UPDATE phpgw_sitemgr_categories_lang 
SET name='$cat_name', description='$cat_description' WHERE cat_id='$cat_id' and 
lang='$lang'", __LINE__,__FILE__);
!                     }
!                   else
!                     {
!                       $this->db->query("INSERT INTO 
phpgw_sitemgr_categories_lang (cat_id,lang,name,description) VALUES 
('$cat_id','$lang','$cat_name','$cat_description')", __LINE__,__FILE__);
!                     }
!                 }
! 
!               function getlangarrayforcategory($cat_id)
!               {
!                       $this->db->query("SELECT lang FROM 
phpgw_sitemgr_categories_lang WHERE cat_id='$cat_id'");
!                       while ($this->db->next_record())
!                       {
!                               $retval[] = $this->db->f('lang');
!                       }
!                       return $retval;
!               }
! 
!               function getCategory($cat_id,$lang=False)
                {
                        $cat = $this->cats->return_single($cat_id);
***************
*** 107,116 ****
                                $cat_info                               = 
CreateObject('sitemgr.Category_SO', True);
                                $cat_info->id                   = $cat[0]['id'];
!                               $cat_info->name                 = 
stripslashes($cat[0]['name']);
                                $cat_info->sort_order   = $cat[0]['data'];
!                               $cat_info->description  = 
stripslashes($cat[0]['description']);
                                $cat_info->parent               = 
$cat[0]['parent'];
                                $cat_info->depth                = 
$cat[0]['level'];
                                $cat_info->root                 = 
$cat[0]['main'];
                                return $cat_info;
                        }
--- 132,173 ----
                                $cat_info                               = 
CreateObject('sitemgr.Category_SO', True);
                                $cat_info->id                   = $cat[0]['id'];
!                               //$cat_info->name                       = 
stripslashes($cat[0]['name']);
                                $cat_info->sort_order   = $cat[0]['data'];
!                               //$cat_info->description        = 
stripslashes($cat[0]['description']);
                                $cat_info->parent               = 
$cat[0]['parent'];
                                $cat_info->depth                = 
$cat[0]['level'];
                                $cat_info->root                 = 
$cat[0]['main'];
+                               
+                               if ($lang)
+                                 {
+                                   $this->db->query("SELECT * FROM 
phpgw_sitemgr_categories_lang WHERE cat_id='$cat_id' and lang='$lang'");
+                                   if ($this->db->next_record())
+                                     {
+                                       $cat_info->name        = 
$this->db->f('name');
+                                       $cat_info->description = 
$this->db->f('description');
+                                     }
+                                   else
+                                     {
+                                       //return False;
+                                       $cat_info->name        = lang("not yet 
translated");
+                                     }
+                                 }
+ 
+                               //if there is no lang argument we return the 
content in whatever languages turns up first
+                               else
+                                 {
+                                   $this->db->query("SELECT * FROM 
phpgw_sitemgr_categories_lang WHERE cat_id='$cat_id'");
+                                   if ($this->db->next_record())
+                                     {
+                                       $cat_info->name        = 
$this->db->f('name');
+                                       $cat_info->description = 
$this->db->f('description');
+                                       $cat_info->lang = $this->db->f('lang');
+                                     }
+                                   else
+                                     {
+                                       $cat_info->name = "This category has no 
data in any langugage: this should not happen";
+                                     }
+                                 }
+                               
                                return $cat_info;
                        }

Index: class.Common_UI.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Common_UI.inc.php,v
retrieving revision 1.6.2.3
retrieving revision 1.6.2.4
diff -C2 -r1.6.2.3 -r1.6.2.4
*** class.Common_UI.inc.php     1 Nov 2002 06:27:31 -0000       1.6.2.3
--- class.Common_UI.inc.php     22 Nov 2002 06:01:53 -0000      1.6.2.4
***************
*** 27,30 ****
--- 27,39 ----
                }
  
+               //this has to be moved somewhere else later
+               function getlangname($lang)
+                 {
+                   $GLOBALS['phpgw']->db->query("select lang_name from 
languages where lang_id = '$lang'",__LINE__,__FILE__);
+                   $GLOBALS['phpgw']->db->next_record();
+                   return $GLOBALS['phpgw']->db->f('lang_name');
+                 }
+ 
+ 
                function DisplayPrefs()
                {
***************
*** 32,50 ****
                        if ($this->acl->is_admin())
                        {
!                               $preferences['sitemgr-site-name'] = array(
!                                       'title'=>'Site name',
!                                       'note'=>'(This is used chiefly for meta 
data and the title bar.)',
                                        'default'=>'New sitemgr site'
!                               );
                                $preferences['sitemgr-site-url']=array(
!                                       'title'=>'URL to sitemgr-site',
                                        'note'=>'(The URL can be relative or 
absolute.  Name must end in a slash.)'
                                );
                                $preferences['sitemgr-site-dir']=array(
!                                       'title'=>'Filesystem path to 
sitemgr-site directory',
                                        'note'=>'(This must be an absolute 
directory location.  <b>No trailing slash</b>.)'
                                );
                                $preferences['home-page-id'] = array(
!                                       'title'=>'Default home page ID number',
                                        'note'=>'(This should be a page that is 
readable by everyone. If you leave this blank, the site index will be shown by 
default.)',
                                        'input'=>'option',
--- 41,66 ----
                        if ($this->acl->is_admin())
                        {
!                               $sitelanguages = 
explode(',',$this->prefs_so->getPreference('sitelanguages'));
!                               $sitelanguages = $sitelanguages ? 
$sitelanguages : array("en");
!                               
!                               foreach ($sitelanguages as $lang)
!                                 {
!                                   $preferences['sitemgr-site-name-' . $lang] 
= array(
!                                       'title'=>lang('Site name'). ' ' . 
$this->getlangname($lang),
!                                       'note'=>'(This is used chiefly for meta 
data and the title bar. If you change the site languages below you have to save 
before being able to set this preference for a new language.)',
                                        'default'=>'New sitemgr site'
!                                   );
!                                 }
! 
                                $preferences['sitemgr-site-url']=array(
!                                       'title'=>lang('URL to sitemgr-site'),
                                        'note'=>'(The URL can be relative or 
absolute.  Name must end in a slash.)'
                                );
                                $preferences['sitemgr-site-dir']=array(
!                                       'title'=>lang('Filesystem path to 
sitemgr-site directory'),
                                        'note'=>'(This must be an absolute 
directory location.  <b>No trailing slash</b>.)'
                                );
                                $preferences['home-page-id'] = array(
!                                       'title'=>lang('Default home page ID 
number'),
                                        'note'=>'(This should be a page that is 
readable by everyone. If you leave this blank, the site index will be shown by 
default.)',
                                        'input'=>'option',
***************
*** 52,76 ****
                                );
                                $preferences['login-domain'] = array(
!                                       'title'=>'Anonymous user login domain',
                                        'note'=>'If you\'re not sure, enter 
Default.',
                                        'default'=>'Default'
                                );
                                $preferences['anonymous-user'] = array(
!                                       'title'=>'Anonymous user\'s username',
                                        'note'=>'(If you haven\'t done so 
already, create a user that will be used for public viewing of the site.  
Recommended name: anonymous.)',
                                        'default'=>'anonymous'
                                );
                                $preferences['anonymous-passwd'] = array(
!                                       'title'=>'Anonymous user\'s password',
                                        'note'=>'(Password that you assigned 
for the aonymous user account.)',
                                        'default'=>'anonymous'
                                );
                                $preferences['interface'] = array(
!                                       'title'=>'Use phpNuke themes instead of 
templates',
                                        'note'=>'(This is NOT recommended.)',
                                        'input'=>'checkbox'
                                );
                                $preferences['themesel'] = array(
!                                       'title'=>'Theme or template select',
                                        'note'=>'(Choose your site\'s theme or 
template.  Note that if you changed the above checkbox you need to save before 
choosing a theme or template.)',
                                        'input'=>'option',
--- 68,92 ----
                                );
                                $preferences['login-domain'] = array(
!                                       'title'=>lang('Anonymous user login 
domain'),
                                        'note'=>'If you\'re not sure, enter 
Default.',
                                        'default'=>'Default'
                                );
                                $preferences['anonymous-user'] = array(
!                                       'title'=>lang('Anonymous user\'s 
username'),
                                        'note'=>'(If you haven\'t done so 
already, create a user that will be used for public viewing of the site.  
Recommended name: anonymous.)',
                                        'default'=>'anonymous'
                                );
                                $preferences['anonymous-passwd'] = array(
!                                       'title'=>lang('Anonymous user\'s 
password'),
                                        'note'=>'(Password that you assigned 
for the aonymous user account.)',
                                        'default'=>'anonymous'
                                );
                                $preferences['interface'] = array(
!                                       'title'=>lang('Use phpNuke themes 
instead of templates'),
                                        'note'=>'(This is NOT recommended.)',
                                        'input'=>'checkbox'
                                );
                                $preferences['themesel'] = array(
!                                       'title'=>lang('Theme or template 
select'),
                                        'note'=>'(Choose your site\'s theme or 
template.  Note that if you changed the above checkbox you need to save before 
choosing a theme or template.)',
                                        'input'=>'option',
***************
*** 79,84 ****
                                );
                                $preferences['sitelanguages'] = array(
!                                       'title'=>'Lanugages the site user can 
choose from',
!                                       'note'=>'(This should be a 
comma-separated list of language-codes.)'
                                );
                                if ($_POST['btnSave'])
--- 95,101 ----
                                );
                                $preferences['sitelanguages'] = array(
!                                       'title'=>lang('Lanugages the site user 
can choose from'),
!                                       'note'=>'(This should be a 
comma-separated list of language-codes.)',
!                                       'default'=>'en'
                                );
                                if ($_POST['btnSave'])
***************
*** 121,125 ****
                                        if ($inputbox)
                                        {
!                                               
$this->PrefBlock(lang($details['title']),$inputbox,$details['note']);
                                        }
                                }
--- 138,142 ----
                                        if ($inputbox)
                                        {
!                                               
$this->PrefBlock($details['title'],$inputbox,$details['note']);
                                        }
                                }

Index: class.MainMenu_UI.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.MainMenu_UI.inc.php,v
retrieving revision 1.3.2.2
retrieving revision 1.3.2.3
diff -C2 -r1.3.2.2 -r1.3.2.3
*** class.MainMenu_UI.inc.php   1 Nov 2002 06:27:31 -0000       1.3.2.2
--- class.MainMenu_UI.inc.php   22 Nov 2002 06:01:53 -0000      1.3.2.3
***************
*** 61,66 ****
                                
'menuaction=sitemgr.contributor_ManagePage_UI._managePage')
                        );
!                       $this->t->set_var('lang_managepage', lang('Manage 
Pages'));
!                       
                        if ($this->acl->is_admin())
                        {
--- 61,72 ----
                                
'menuaction=sitemgr.contributor_ManagePage_UI._managePage')
                        );
! 
!                       $this->t->set_var('managetranslations',
!                               $GLOBALS['phpgw']->link('/index.php',
!                               
'menuaction=sitemgr.ManageTranslations_UI._manageTranslations')
!                       );
!                       $this->t->set_var(Array('lang_managepage' => 
lang('Manage Pages'),
!                                               'lang_managetranslations' => 
lang('Manage Translations')));
! 
                        if ($this->acl->is_admin())
                        {

Index: class.Page_SO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Page_SO.inc.php,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -r1.3 -r1.3.2.1
*** class.Page_SO.inc.php       1 Sep 2002 22:19:02 -0000       1.3
--- class.Page_SO.inc.php       22 Nov 2002 06:01:53 -0000      1.3.2.1
***************
*** 10,13 ****
--- 10,14 ----
                var $sort_order;
                var $hidden;
+               var $lang;
                
                function Page_SO()

Index: class.Pages_BO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Pages_BO.inc.php,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -C2 -r1.2.2.1 -r1.2.2.2
*** class.Pages_BO.inc.php      1 Nov 2002 06:27:31 -0000       1.2.2.1
--- class.Pages_BO.inc.php      22 Nov 2002 06:01:53 -0000      1.2.2.2
***************
*** 59,67 ****
                }
  
!               function getPage($page_id)
                {
                        if ($this->acl->can_read_page($page_id))
                        {
!                               return $this->pageso->getPage($page_id);
                        }
                        else
--- 59,67 ----
                }
  
!               function getPage($page_id,$lang=False)
                {
                        if ($this->acl->can_read_page($page_id))
                        {
!                               return $this->pageso->getPage($page_id,$lang);
                        }
                        else
***************
*** 76,80 ****
                }
  
!               function savePageInfo($page_Info)
                {
                        if (!$this->acl->can_write_category($page_Info->cat_id))
--- 76,85 ----
                }
  
!               function getlangarrayforpage($page_id)
!                 {
!                 return $this->pageso->getlangarrayforpage($page_id);
!               }
! 
!               function savePageInfo($page_Info,$lang)
                {
                        if (!$this->acl->can_write_category($page_Info->cat_id))
***************
*** 92,99 ****
--- 97,106 ----
                                        $page_Info->name = $fixed_name;
                                        $this->pageso->savePageInfo($page_Info);
+                                       
$this->pageso->savePageLang($page_Info,$lang);
                                        return lang('The Name field cannot 
contain punctuation or spaces (field modified).');
                                }
                                if ($this->pageso->savePageInfo($page_Info))
                                {
+                                       
$this->pageso->savePageLang($page_Info,$lang);
                                        return lang('The page was successfully 
saved.');
                                }
***************
*** 102,105 ****
--- 109,113 ----
                                        return lang('There was an error writing 
to the database.');
                                }
+                               //MT: are the following three lines ever 
executed?
                                $page_Info->name = $fixed_name;
                                $this->pageso->savePageInfo($page_Info);
***************
*** 110,117 ****
--- 118,127 ----
                                $page_Info->name .= '--FIX-DUPLICATE-NAME';
                                $this->pageso->savePageInfo($page_Info);
+                               $this->pageso->savePageLang($page_Info,$lang);
                                return lang('The page name must be unique.');
                        }
                        if ($this->pageso->savePageInfo($page_Info))
                        {
+                               $this->pageso->savePageLang($page_Info,$lang);
                                return True;
                        } 
***************
*** 121,124 ****
--- 131,139 ----
                        }
                }
+ 
+               function savePageLang($page_Info,$lang)
+                 {
+                   $this->pageso->savePageLang($page_Info,$lang);
+                 }
        }
  ?>

Index: class.Pages_SO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Pages_SO.inc.php,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -C2 -r1.8 -r1.8.2.1
*** class.Pages_SO.inc.php      15 Sep 2002 22:32:35 -0000      1.8
--- class.Pages_SO.inc.php      22 Nov 2002 06:01:53 -0000      1.8.2.1
***************
*** 40,43 ****
--- 40,51 ----
                function removePagesInCat($cat_id)
                {
+                       $db2 = $this->db;
+                       $sql = 'SELECT page_id FROM phpgw_sitemgr_pages WHERE 
cat_id=\''.$cat_id.'\'';
+                       $db2->query($sql,__LINE__,__FILE__);
+                       while ($db2->next_record())
+                       {
+                         $page_id = $db2->f('page_id');
+                         $this->db->query("DELETE FROM 
phpgw_sitemgr_pages_lang WHERE page_id='$page_id'");
+                       }
                        $sql = 'DELETE FROM phpgw_sitemgr_pages WHERE 
cat_id=\''.$cat_id.'\'';
                        $this->db->query($sql,__LINE__,__FILE__);
***************
*** 48,51 ****
--- 56,61 ----
                        $sql = 'DELETE FROM phpgw_sitemgr_pages WHERE 
page_id=\'' . $page_id . '\'';
                        $this->db->query($sql, __LINE__,__FILE__);
+                       $sql = 'DELETE FROM phpgw_sitemgr_pages_lang WHERE 
page_id=\'' . $page_id . '\'';
+                       $this->db->query($sql, __LINE__,__FILE__);
                }
  
***************
*** 68,72 ****
                }
  
!               function getPageByName($page_name)
                {
                        $sql = 'SELECT * FROM phpgw_sitemgr_pages WHERE 
name=\'' . $page_name . '\'';
--- 78,93 ----
                }
  
! 
!               function getlangarrayforpage($page_id)
!                 {
!                         $this->db->query("SELECT lang FROM 
phpgw_sitemgr_pages_lang WHERE page_id='$page_id'");
!                         while ($this->db->next_record())
!                         {
!                                 $retval[] = $this->db->f('lang');
!                         }
!                         return $retval;
!                 }
! 
!               function getPageByName($page_name,$lang)
                {
                        $sql = 'SELECT * FROM phpgw_sitemgr_pages WHERE 
name=\'' . $page_name . '\'';
***************
*** 78,86 ****
                                $page->cat_id = $this->db->f('cat_id');
                                $page->name = 
stripslashes($this->db->f('name'));
-                               $page->title= 
stripslashes($this->db->f('title'));
-                               $page->subtitle = 
stripslashes($this->db->f('subtitle'));
                                $page->sort_order = (int) 
$this->db->f('sort_order');
-                               $page->content = 
stripslashes($this->db->f('content'));
                                $page->hidden = $this->db->f('hide_page');
                                return $page;
                        }
--- 99,118 ----
                                $page->cat_id = $this->db->f('cat_id');
                                $page->name = 
stripslashes($this->db->f('name'));
                                $page->sort_order = (int) 
$this->db->f('sort_order');
                                $page->hidden = $this->db->f('hide_page');
+ 
+                               $sql = "SELECT * FROM phpgw_sitemgr_pages_lang 
WHERE page_id='" . $page->id . "' and lang='$lang'";
+                               $this->db->query($sql,__LINE__,__FILE__);
+                               
+                               if ($this->db->next_record())
+                               {
+                                 $page->title= 
stripslashes($this->db->f('title'));
+                                 $page->subtitle = 
stripslashes($this->db->f('subtitle'));
+                                 $page->content = 
stripslashes($this->db->f('content'));
+                               }
+                               else
+                                 {
+                                   $page->title = lang("The page %1 has not 
yet been translated to %2",$page->name, $lang);
+                                 }
                                return $page;
                        }
***************
*** 91,95 ****
                }
  
!               function getPage($page_id)
                {
                        $sql = 'SELECT * FROM phpgw_sitemgr_pages WHERE 
page_id=\'' . $page_id . '\'';
--- 123,127 ----
                }
  
!               function getPage($page_id,$lang=False)
                {
                        $sql = 'SELECT * FROM phpgw_sitemgr_pages WHERE 
page_id=\'' . $page_id . '\'';
***************
*** 102,109 ****
                                $page->sort_order = (int) 
$this->db->f('sort_order');
                                $page->name = 
stripslashes($this->db->f('name'));
-                               $page->title= 
stripslashes($this->db->f('title'));
-                               $page->subtitle = 
stripslashes($this->db->f('subtitle'));
-                               $page->content = 
stripslashes($this->db->f('content'));
                                $page->hidden = $this->db->f('hide_page');
                                return $page;
                        }
--- 134,176 ----
                                $page->sort_order = (int) 
$this->db->f('sort_order');
                                $page->name = 
stripslashes($this->db->f('name'));
                                $page->hidden = $this->db->f('hide_page');
+                               
+                               if ($lang)
+                                 {
+                                   $sql = "SELECT * FROM 
phpgw_sitemgr_pages_lang WHERE page_id='$page_id' and lang='$lang'";
+                                   $this->db->query($sql,__LINE__,__FILE__);
+                                   
+                                   if ($this->db->next_record())
+                                     {
+                                       $page->title= 
stripslashes($this->db->f('title'));
+                                       $page->subtitle = 
stripslashes($this->db->f('subtitle'));
+                                       $page->content = 
stripslashes($this->db->f('content'));
+                                       $page->lang = $lang;
+                                     }
+                                   else
+                                     {
+                                       $page->title = lang("not yet 
translated");
+                                     }
+                                 }
+                               
+                               //if there is no lang argument we return the 
content in whatever languages turns up first 
+                               else
+                                 {
+                                   $sql = "SELECT * FROM 
phpgw_sitemgr_pages_lang WHERE page_id='" . $page->id . "'";
+                                   $this->db->query($sql,__LINE__,__FILE__);
+                                   
+                                   if ($this->db->next_record())
+                                     {
+                                       $page->title= 
stripslashes($this->db->f('title'));
+                                       $page->subtitle = 
stripslashes($this->db->f('subtitle'));
+                                       $page->content = 
stripslashes($this->db->f('content'));
+                                       $page->lang = $this->db->f('lang');
+                                     }
+                                   else
+                                     {
+                                       $page->title = "This page has no data 
in any langugage: this should not happen";
+                                     }
+                                 }
+ 
                                return $page;
                        }
***************
*** 120,131 ****
                                'name=\'' . addslashes($pageInfo->name) . '\',' 
.
                                'sort_order=\'' . (int) $pageInfo->sort_order . 
'\',' .
!                               'title=\'' . addslashes($pageInfo->title) . 
'\',' .
!                               'subtitle=\'' . addslashes($pageInfo->subtitle) 
. '\',' .
!                               'content=\'' . addslashes($pageInfo->content) . 
'\', ' .
!                               'hide_page=\'' . $pageInfo->hidden . '\' ' .
                                'WHERE page_id=\'' . $pageInfo->id . '\'';
                        $this->db->query($sql, __LINE__,__FILE__);
                        return true;
                }
        }
  ?>
--- 187,220 ----
                                'name=\'' . addslashes($pageInfo->name) . '\',' 
.
                                'sort_order=\'' . (int) $pageInfo->sort_order . 
'\',' .
!                               'hide_page=\'' . $pageInfo->hidden . '\' ' .
                                'WHERE page_id=\'' . $pageInfo->id . '\'';
                        $this->db->query($sql, __LINE__,__FILE__);
                        return true;
                }
+               
+               function savePageLang($pageInfo,$lang)
+                 {
+                   $page_id = $pageInfo->id;
+                   $this->db->query("SELECT * FROM phpgw_sitemgr_pages_lang 
WHERE page_id='$page_id' and lang='$lang'", __LINE__,__FILE__);
+                   if ($this->db->next_record())
+                     {
+                       $sql = 'UPDATE phpgw_sitemgr_pages_lang SET ' . 
+                               'title=\'' . addslashes($pageInfo->title) . 
'\',' .
+                               'subtitle=\'' . addslashes($pageInfo->subtitle) 
. '\',' .
+                               'content=\'' . addslashes($pageInfo->content) . 
'\' ' .
+                               "WHERE page_id='$page_id' and lang='$lang'";
+                       $this->db->query($sql, __LINE__,__FILE__);
+                       return true;
+                     }
+                   else
+                     {
+                       $sql = "INSERT INTO phpgw_sitemgr_pages_lang 
(page_id,lang,title,subtitle,content) VALUES ('$page_id','$lang','" .
+                               addslashes($pageInfo->title) . "','" .
+                               addslashes($pageInfo->subtitle) . "','" .
+                               addslashes($pageInfo->content) ."')";
+                       $this->db->query($sql, __LINE__,__FILE__);
+                       return true;
+                     }
+                 }
        }
  ?>

Index: class.admin_ManageSiteContent_UI.inc.php
===================================================================
RCS file: 
/cvsroot/phpgroupware/sitemgr/inc/class.admin_ManageSiteContent_UI.inc.php,v
retrieving revision 1.1.1.1.2.2
retrieving revision 1.1.1.1.2.3
diff -C2 -r1.1.1.1.2.2 -r1.1.1.1.2.3
*** class.admin_ManageSiteContent_UI.inc.php    17 Oct 2002 04:17:14 -0000      
1.1.1.1.2.2
--- class.admin_ManageSiteContent_UI.inc.php    22 Nov 2002 06:01:53 -0000      
1.1.1.1.2.3
***************
*** 5,8 ****
--- 5,9 ----
                var $headerfooterbo;
                var $acl;
+               var $prefs_so;
                
                var $public_functions = array
***************
*** 26,29 ****
--- 27,38 ----
                }
  
+               //this has to be moved somewhere else later
+               function getlangname($lang)
+                 {
+                   $GLOBALS['phpgw']->db->query("select lang_name from 
languages where lang_id = '$lang'",__LINE__,__FILE__);
+                   $GLOBALS['phpgw']->db->next_record();
+                   return $GLOBALS['phpgw']->db->f('lang_name');
+                 }
+ 
                function admin_ManageSiteContent_UI()
                {       
***************
*** 38,41 ****
--- 47,52 ----
                        $this->headerfooterbo = 
CreateObject('sitemgr.headerFooter_BO', True);
                        $this->acl = CreateObject('sitemgr.ACL_BO');
+                       $this->prefs_so = 
CreateObject('sitemgr.sitePreference_SO', True);
+                       $this->sitelanguages = 
explode(',',$this->prefs_so->getPreference('sitelanguages'));
                }
                
***************
*** 53,79 ****
                        {
                                $this->t->set_file('EditHeaderAndFooter', 
'site_format_manager.tpl');
  
                                if ($btnSave)
                                {
!                                       
$this->headerfooterbo->SetSiteHeader($header);
!                                       
$this->headerfooterbo->SetSiteFooter($footer);
                                        $this->t->set_var('message','<b>' 
.lang('Saved') . '</b>.  <a 
href="'.$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.MainMenu_UI.DisplayMenu').'">'
 . lang('Return to main menu.') . '</a><br>');
                                        
//$this->headerfooterbo->SetTheme($this->theme);
                                }
!       
!                               $this->header = 
$this->headerfooterbo->getSiteHeader();
!                               $this->footer = 
$this->headerfooterbo->getSiteFooter();
!                               
                                $this->t->set_var(array
                                (
-                                       'header' => $this->header,
-                                       'footer' => $this->footer,
                                        'site_format_manager' => lang('Site 
Format Manager'),
-                                       'header_editor' => lang('Header 
Editor'),
-                                       'footer_editor' => lang('Footer 
Editor'),
                                        'lang_reset' => lang('Reset'),
                                        'lang_save' => lang('Save')
                                ));
!       
                                if ($btnReset)
                                {
--- 64,100 ----
                        {
                                $this->t->set_file('EditHeaderAndFooter', 
'site_format_manager.tpl');
+                               
$this->t->set_block('EditHeaderAndFooter','Header_Editor','HBlock');
+                               
$this->t->set_block('EditHeaderAndFooter','Footer_Editor','FBlock');
  
                                if ($btnSave)
                                {
!                                 foreach ($this->sitelanguages as $lang)
!                                 {
!                                       
$this->headerfooterbo->SetSiteHeader($header[$lang],$lang);
!                                       
$this->headerfooterbo->SetSiteFooter($footer[$lang],$lang);
!                                 }
                                        $this->t->set_var('message','<b>' 
.lang('Saved') . '</b>.  <a 
href="'.$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.MainMenu_UI.DisplayMenu').'">'
 . lang('Return to main menu.') . '</a><br>');
                                        
//$this->headerfooterbo->SetTheme($this->theme);
                                }
! 
                                $this->t->set_var(array
                                (
                                        'site_format_manager' => lang('Site 
Format Manager'),
                                        'lang_reset' => lang('Reset'),
                                        'lang_save' => lang('Save')
                                ));
! 
!                               foreach ($this->sitelanguages as $lang)
!                                 {
!                                   $this->t->set_var(array('header_editor' => 
lang('Header Editor') . ' - ' . $this->getlangname($lang),
!                                                           'footer_editor' => 
lang('Footer Editor') . ' - ' . $this->getlangname($lang),
!                                                           'header' => 
$this->headerfooterbo->getSiteHeader($lang),
!                                                           'footer' => 
$this->headerfooterbo->getSiteFooter($lang),
!                                                           'textarea_header' 
=> 'header[' . $lang . ']',
!                                                           'textarea_footer' 
=> 'footer[' . $lang . ']'));
!                                   
$this->t->parse('HBlock','Header_Editor',True);
!                                   
$this->t->parse('FBlock','Footer_Editor',True);
!                                 }
!                               
                                if ($btnReset)
                                {

Index: class.contributor_ManagePage_UI.inc.php
===================================================================
RCS file: 
/cvsroot/phpgroupware/sitemgr/inc/class.contributor_ManagePage_UI.inc.php,v
retrieving revision 1.7.2.3
retrieving revision 1.7.2.4
diff -C2 -r1.7.2.3 -r1.7.2.4
*** class.contributor_ManagePage_UI.inc.php     18 Oct 2002 23:24:02 -0000      
1.7.2.3
--- class.contributor_ManagePage_UI.inc.php     22 Nov 2002 06:01:53 -0000      
1.7.2.4
***************
*** 21,25 ****
                var $cat_list;
                var $page_list;
! 
                var $public_functions=array
                (
--- 21,27 ----
                var $cat_list;
                var $page_list;
!               var $preferenceso;
!               var $sitelanguages;
!               
                var $public_functions=array
                (
***************
*** 32,37 ****
--- 34,48 ----
                        $this->pagebo = CreateObject('sitemgr.Pages_BO', True);
                        $this->categorybo = 
CreateObject('sitemgr.Categories_BO',True);
+                       $this->preferenceso = 
CreateObject('sitemgr.sitePreference_SO', true);
+                       $this->sitelanguages = 
explode(',',$this->preferenceso->getPreference('sitelanguages'));
                }
                
+               function getlangname($lang)
+                 {
+                   $GLOBALS['phpgw']->db->query("select lang_name from 
languages where lang_id = '$lang'",__LINE__,__FILE__);
+                   $GLOBALS['phpgw']->db->next_record();
+                   return $GLOBALS['phpgw']->db->f('lang_name');
+                 }
+               
                function _addPage($category_id)
                {
***************
*** 61,65 ****
                function _editPage($category_id, 
$page_id,$cname='',$ctitle='',$csubtitle='',$cmain='')
                {
!                       
$this->globalize(array('title','name','subtitle','main','sort_order','parent','hidden','btnEditPage'));
                        global $title;
                        global $name;
--- 72,76 ----
                function _editPage($category_id, 
$page_id,$cname='',$ctitle='',$csubtitle='',$cmain='')
                {
!                       
$this->globalize(array('title','name','subtitle','main','sort_order','parent','hidden','btnEditPage','savelanguage'));
                        global $title;
                        global $name;
***************
*** 70,78 ****
                        global $hidden;
                        global $btnEditPage;
                
                        $this->t->set_file('EditPage', 'page_editor.tpl');
                        if($page_id)
                        {
!                               $this->page = $this->pagebo->getPage($page_id);
                                if ($cname)
                                {
--- 81,90 ----
                        global $hidden;
                        global $btnEditPage;
+                       global $savelanguage;
                
                        $this->t->set_file('EditPage', 'page_editor.tpl');
                        if($page_id)
                        {
!                               $this->page = 
$this->pagebo->getPage($page_id,$this->sitelanguages[0]);
                                if ($cname)
                                {
***************
*** 118,121 ****
--- 130,151 ----
                                  $this->t->set_var('hidden', '');
                          }
+                       
+                       if (count($this->sitelanguages))
+                         {
+                           $select = lang('as') . ' <select 
name="savelanguage">';
+                           
+                           foreach ($this->sitelanguages as $lang)
+                             {
+                               $selected= '';
+                               if ($lang == $page->lang)
+                                 {
+                                   $selected = 'selected="selected" ';
+                                 }
+                               $select .= '<option ' . $selected .'value="' . 
$lang . '">'. $this->getlangname($lang) . '</option>';
+                             }
+                           $select .= '</select> ';
+                           $this->t->set_var('savelang',$select);
+                         }
+                       
                        $this->t->set_var(array(
                                'title' =>$this->page->title,
***************
*** 151,155 ****
                function _managePage()
                {
!                       
$this->globalize(array('hidden','btnAddPage','btnDelete','btnEditPage','btnPrev','pageid','btnSave','category_id','sort_order','parent','title','name','subtitle','main','error'));
                        global $hidden;
                        global $btnAddPage, $btnDelete, $btnEditPage;
--- 181,185 ----
                function _managePage()
                {
!                       
$this->globalize(array('hidden','btnAddPage','btnDelete','btnEditPage','btnPrev','pageid','btnSave','category_id','sort_order','parent','title','name','subtitle','main','error','savelanguage'));
                        global $hidden;
                        global $btnAddPage, $btnDelete, $btnEditPage;
***************
*** 165,168 ****
--- 195,199 ----
                        global $main;
                        global $error;
+                       global $savelanguage;
  
                        $common_ui = CreateObject('sitemgr.Common_UI',True);
***************
*** 208,212 ****
                                                $this->page->hidden = 0;
                                        }
!                                       $save_msg = 
$this->pagebo->savePageInfo($this->page);
                                }
                                if (!is_string($save_msg))
--- 239,244 ----
                                                $this->page->hidden = 0;
                                        }
!                                       $savelanguage = $savelanguage ? 
$savelanguage : $this->sitelanguages[0];
!                                       $save_msg = 
$this->pagebo->savePageInfo($this->page,$savelanguage);
                                }
                                if (!is_string($save_msg))
***************
*** 263,267 ****
                                                        {
                                                                $this->page_id 
=$this->page_list[$j];
!                                                               $this->page = 
$this->pagebo->getPage($this->page_id);
                                                                
$page_description = '<b>' . lang('Name') . ': </b>'.$this->page->name.'<br><b>' 
. lang('Title') . ': </b>'.$this->page->title;
                                                                
$this->t->set_var('page', $page_description);
--- 295,299 ----
                                                        {
                                                                $this->page_id 
=$this->page_list[$j];
!                                                               $this->page = 
$this->pagebo->getPage($this->page_id,$this->sitelanguages[0]);
                                                                
$page_description = '<b>' . lang('Name') . ': </b>'.$this->page->name.'<br><b>' 
. lang('Title') . ': </b>'.$this->page->title;
                                                                
$this->t->set_var('page', $page_description);

Index: class.headerFooter_BO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.headerFooter_BO.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.2.1
diff -C2 -r1.1.1.1 -r1.1.1.1.2.1
*** class.headerFooter_BO.inc.php       29 Aug 2002 03:03:17 -0000      1.1.1.1
--- class.headerFooter_BO.inc.php       22 Nov 2002 06:01:53 -0000      
1.1.1.1.2.1
***************
*** 13,31 ****
                }
  
!               function getSiteHeader()
                {
!                       return $this->preferenceso->getPreference('siteheader');
                }
  
!               function getSiteFooter()
                {       
!                       return 
$this->preferenceso->getPreference('sitefooter');        
                }
  
!               function setSiteHeader($header)
                {
                        if ($this->acl->is_admin())
                        {
!                               
if($this->preferenceso->setPreference('siteheader',$header))
                                {
                                        return true;
--- 13,31 ----
                }
  
!               function getSiteHeader($lang)
                {
!                       return 
$this->preferenceso->getPreference('siteheader-'. $lang);
                }
  
!               function getSiteFooter($lang)
                {       
!                       return 
$this->preferenceso->getPreference('sitefooter-'. $lang);        
                }
  
!               function setSiteHeader($header,$lang)
                {
                        if ($this->acl->is_admin())
                        {
!                               
if($this->preferenceso->setPreference('siteheader-'. $lang,$header))
                                {
                                        return true;
***************
*** 42,50 ****
                }
  
!               function setSiteFooter($footer)
                {
                        if ($this->acl->is_admin())
                        {
!                               
if($this->preferenceso->setPreference('sitefooter',$footer))
                                {
                                        return true;
--- 42,50 ----
                }
  
!               function setSiteFooter($footer,$lang)
                {
                        if ($this->acl->is_admin())
                        {
!                               
if($this->preferenceso->setPreference('sitefooter-'. $lang,$footer))
                                {
                                        return true;





reply via email to

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