[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/sitemgr/inc/ -> class.Pages_SO.inc.php (source)

   1  <?php
   2      /**************************************************************************\
   3      * eGroupWare SiteMgr - Web Content Management                              *
   4      * http://www.egroupware.org                                                *
   5      * Rewritten with the new db-functions by RalfBecker-AT-outdoor-training.de *
   6      * --------------------------------------------                             *
   7      *  This program is free software; you can redistribute it and/or modify it *
   8      *  under the terms of the GNU General Public License as published by the   *
   9      *  Free Software Foundation; either version 2 of the License, or (at your  *
  10      *  option) any later version.                                              *
  11      \**************************************************************************/
  12  
  13      /* $Id: class.Pages_SO.inc.php 20295 2006-02-15 12:31:25Z  $ */
  14  
  15      class Pages_SO
  16      {
  17          var $db;
  18          var $pages_table,$pages_lang_table;
  19  
  20  		function Pages_SO()
  21          {
  22              $this->db = clone($GLOBALS['egw']->db);
  23              $this->db->set_app('sitemgr');
  24  
  25              foreach(array('pages','pages_lang') as $name)
  26              {
  27                  $var = $name.'_table';
  28                  $this->$var = 'egw_sitemgr_'.$name;    // only reference to the db-prefix
  29              }
  30          }
  31  
  32          //if $cats is an array, pages from this list are retrieved,
  33          //is $cats is an int, pages from this cat are retrieved,
  34          //if $cats is 0 or false, pages from currentcats are retrieved
  35  		function getPageIDList($cats=False,$states=false)
  36          {
  37              if (!$states)
  38              {
  39                  $states = $GLOBALS['Common_BO']->visiblestates;
  40              }
  41              if (!$cats)
  42              {
  43                  $cats = $GLOBALS['Common_BO']->cats->currentcats;
  44              }
  45  
  46              $page_id_list = array();
  47              if ($cats)
  48              {
  49                  $where = array('cat_id' => $cats);
  50                  if ($states)
  51                  {
  52                      $where['state'] = $states;
  53                  }
  54                  $this->db->select($this->pages_table,'page_id',$where,__LINE__,__FILE__,False,
  55                      'ORDER BY cat_id, sort_order ASC'); 
  56  
  57                  while ($this->db->next_record())
  58                  {
  59                      $page_id_list[] = $this->db->f('page_id');
  60                  }
  61              }
  62              return $page_id_list;
  63          }
  64  
  65  		function addPage($cat_id)
  66          {
  67              $this->db->insert($this->pages_table,array('cat_id'=>$cat_id),False, __LINE__,__FILE__);
  68  
  69              return $this->db->get_last_insert_id($this->pages_table,'page_id');
  70          }
  71  
  72  		function removePage($page_id)
  73          {
  74              $this->db->delete($this->pages_table,array('page_id' => $page_id), __LINE__,__FILE__);
  75              $this->db->delete($this->pages_lang_table,array('page_id' => $page_id), __LINE__,__FILE__);
  76          }
  77  
  78          //this function should be a deprecated function - IMHO - skwashd
  79  		function pageExists($page_name, $exclude_page_id='')
  80          {
  81              $page_id = $this->PagetoID($page_name);
  82              if($page_id)
  83              {
  84                  return ($page_id != $exclude_page_id ? $page_id : False);
  85              }
  86              else
  87              {
  88                  return False;
  89              }
  90          }
  91  
  92  		function getlangarrayforpage($page_id)
  93          {
  94              $this->db->select($this->pages_lang_table,'lang',array('page_id' => $page_id),__LINE__,__FILE__);
  95              
  96              $retval = array();
  97              while ($this->db->next_record())
  98              {
  99                  $retval[] = $this->db->f('lang');
 100              }
 101              return $retval;
 102          }
 103  
 104  		function PagetoID($page_name)
 105          {
 106              $cats =& CreateObject('phpgwapi.categories', -1, 'sitemgr');
 107              $cat_list = $cats->return_sorted_array(0, False, '', '', '', False, CURRENT_SITE_ID);
 108              
 109              if($cat_list)
 110              {
 111                  foreach($cat_list as $val)
 112                  {
 113                      $site_cats[] = $val['id'];
 114                  }
 115              }
 116              $where = array('name' => $page_name);
 117              if($site_cats)
 118              {
 119                  $where['cat_id'] = $site_cats;
 120              }
 121              $this->db->select($this->pages_table,'page_id',$where,__LINE__,__FILE__);
 122  
 123              if ($this->db->next_record())
 124              {
 125                  return $this->db->f('page_id');
 126              }
 127              return false;
 128          }
 129  
 130  		function getcatidforpage($page_id)
 131          {
 132              $this->db->select($this->pages_table,'cat_id',array('page_id'=>$page_id),__LINE__,__FILE__);
 133  
 134              if ($this->db->next_record())
 135               {
 136                  return $this->db->f('cat_id');
 137              }
 138              return false;
 139          }
 140  
 141  		function getPage($page_id,$lang=False)
 142          {
 143              $where = array('page_id'=>$page_id);
 144              $this->db->select($this->pages_table,'*',$where,__LINE__,__FILE__);
 145  
 146              if ($this->db->next_record())
 147              {
 148                  $page =& CreateObject('sitemgr.Page_SO', True);
 149                  $page->id = $page_id;
 150                  $page->cat_id = $this->db->f('cat_id');
 151                  $page->sort_order = (int) $this->db->f('sort_order');
 152                  $page->name = stripslashes($this->db->f('name'));
 153                  $page->hidden = $this->db->f('hide_page');
 154                  $page->state = $this->db->f('state');
 155                  
 156                  if ($lang)
 157                  {
 158                      $where['lang'] = $lang;
 159                  }
 160                  $this->db->select($this->pages_lang_table,'*',$where,__LINE__,__FILE__);
 161                  
 162                  if ($this->db->next_record())
 163                  {
 164                      $page->title= stripslashes($this->db->f('title'));
 165                      $page->subtitle = stripslashes($this->db->f('subtitle'));
 166                      $page->lang = $lang;
 167                  }
 168                  else
 169                  {
 170                      $page->title = $lang ? lang("not yet translated") :
 171                          "This page has no data in any langugage: this should not happen";
 172                  }
 173                  return $page;
 174              }
 175              return false;
 176          }
 177  
 178  		function savePageInfo($pageInfo)
 179          {
 180              return $this->db->update($this->pages_table,array(
 181                      'cat_id'    => $pageInfo->cat_id,
 182                      'name'        => $pageInfo->name,
 183                      'sort_order'=> $pageInfo->sort_order,
 184                      'hide_page'    => $pageInfo->hidden,
 185                      'state'        => $pageInfo->state,
 186                  ),array(
 187                      'page_id'     => $pageInfo->id            
 188                  ), __LINE__,__FILE__);
 189          }
 190          
 191  		function savePageLang($pageInfo,$lang)
 192          {
 193              return $this->db->insert($this->pages_lang_table,array(
 194                      'title'        => $pageInfo->title,
 195                      'subtitle'    => $pageInfo->subtitle,
 196                  ),array(
 197                      'page_id'     => $pageInfo->id,
 198                      'lang'        => $lang,            
 199                  ), __LINE__,__FILE__);
 200          }
 201  
 202  		function removealllang($lang)
 203          {
 204              $this->db->delete($this->pages_lang_table,array('lang'=>$lang), __LINE__,__FILE__);
 205          }
 206  
 207  		function migratealllang($oldlang,$newlang)
 208          {
 209              $this->db->update($this->pages_lang_table,array(
 210                      'lang' => $newlang
 211                  ),array(
 212                      'lang' => $oldlang
 213                  ), __LINE__,__FILE__);
 214          }
 215  
 216  		function commit($page_id)
 217          {
 218              foreach(array(
 219                  SITEMGR_STATE_PREPUBLISH => SITEMGR_STATE_PUBLISH,
 220                  SITEMGR_STATE_PREUNPUBLISH => SITEMGR_STATE_ARCHIVE
 221              ) as $from => $to)
 222              {
 223                  $this->db->update($this->pages_table,array(
 224                          'state'     => $to
 225                      ),array(
 226                          'state'     => $from,
 227                          'page_id'     => $page_id,
 228                      ),__LINE__,__FILE__);
 229              }
 230          }
 231  
 232  		function reactivate($page_id)
 233          {
 234              $this->db->update($this->pages_table,array(
 235                      'state'     => SITEMGR_STATE_DRAFT
 236                  ),array(
 237                      'state'        => SITEMGR_STATE_ARCHIVE,
 238                      'page_id'     => $page_id,
 239                  ),__LINE__,__FILE__);
 240          }
 241      }
 242  ?>


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7