Source for file CMS_SUMMARYPAGE.phpclass

Documentation is available at CMS_SUMMARYPAGE.phpclass

  1. <?php
  2. /**
  3.   * Class file summarypage.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    cms
  7.   *
  8.   * @author     Peter Krebs <p.krebs@lvus.at>
  9.   * @copyright  (c) 2002-2003 by Peter Krebs and Landesverlag Unternehmensservice
  10.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  11.   *
  12.   ***/
  13.  
  14. require_once $GLOBALS['PROJECT']['CONFIGPATH']."cms.conf";
  15. require_once $GLOBALS['CMS']['PHPINCPATH']."page/pageV2.phpclass";
  16.  
  17. /**
  18.   * Class CMS_SUMMARYPAGE
  19.   *
  20.   * shows the chapters of all pages in
  21.   * CMS_SUMMARYPAGE::pages where
  22.   * $GLOBALS['CMS']['CHAPTER_PAGEMODE'][$this->CHA_SHOWMODE]['SUMMARY] == TRUE
  23.   *
  24.   * @project    Open CSP-Management
  25.   * @package    cms
  26.   *
  27.   * @author     Peter Krebs <p.krebs@lvus.at>
  28.   * @copyright  (c) 2002-2003 by Peter Krebs and Landesverlag Unternehmensservice
  29.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  30.   *
  31.   ***/
  32. class CMS_SUMMARYPAGE extends CMS_PAGE_V2 {
  33.     /*
  34.      * @staticvar string $myClassName   name of the class
  35.      **/
  36.     var $myClassName    = "CMS_SUMMARYPAGE";
  37.  
  38.     /**
  39.       * @var array $pages list of pages to check
  40.       ***/
  41.     var $pages=array();
  42.  
  43.     /**
  44.       * @var int $pagesmenId if > 0 use all pages in this menu
  45.       ***/
  46.     var $pagesmenId=-1;
  47.  
  48.  
  49.     /**
  50.       * init the object and populates it if (intval($aId))
  51.       *
  52.       * @param int $projId  the project ID
  53.       * @param int $menId   the menu ID
  54.       * @param int $aId     the page ID
  55.       * @param int $langId  the language ID
  56.       * @param bool $debug 
  57.       *
  58.       ***/
  59.     function CMS_SUMMARYPAGE($projId=0,$menId=0,$aId=0,$langId=0,$debug=FALSE{
  60.         $this->init("USRDB",$debug);
  61.  
  62.         $this->db_SetKey('PROJ_ID',$projId);
  63.         $this->db_SetKey('LANG_ID',$langId);
  64.         $this->db_SetKey('MEN_ID',$menId);
  65.         if (intval($aId)) {
  66.             $this->db_SetKey($this->colPrevix."ID",$aId);
  67.             $this->dbPopulate($debug);
  68.         }
  69.     }
  70.  
  71.     /**
  72.       * unserialze the object field after populate with parent::dbPopulateDB
  73.       *
  74.       * @param string $gDBIDX GLOBAL ARRAY INDEX OF DB OBJECT
  75.       * @param bool   $debug  SHOW DEBUG INFO
  76.       *
  77.       * @return bool  found row ?
  78.       *
  79.       * @version pk-03-12-14  fixed bug no return value
  80.       *
  81.       ***/
  82.     function dbPopulateDB($gDBIDX="USRDB",$debug=FALSE{
  83.         if ($debugecho "<p><b>CMS_SUMMARYPAGE::dbPopulateDB($gDBIDX,$debug)</b> (".get_class($this).")</p>";
  84.         if (parent::dbPopulateDB($gDBIDX,$debug)) {
  85.             $this->pages=unserialize($this->PAG_OBJECTVARS);
  86.             return TRUE;
  87.         else {
  88.             return FALSE;
  89.         }
  90.     }
  91.  
  92.     /**
  93.       * saves the object to the database
  94.       *
  95.       * if the object is populated dbReplace is called
  96.       * otherwise dbInsert is called
  97.       *
  98.       * Allways use dbSave to be sure object elements are serialized
  99.       *
  100.       **/
  101.  
  102.     function dbSave($gDBIDX="USRDB",$debug)  {
  103.         if ($debugecho "<p><b>CMS_SUMMARYPAGE::dbSave($gDBIDX,$debug)</b> (".get_class($this).")</p>";
  104.         $this->PAG_OBJECTVARS serialize($this->pages);
  105.         return parent::dbSave($gDBIDX,$debug);
  106.     }
  107.  
  108.     /**
  109.       * returns an array of chapter template names with chapter template ID as index
  110.       * returns false if the page does not support chapter input
  111.       *
  112.       * @param bool $debug 
  113.       * @return array 
  114.       *
  115.       ***/
  116.     function getChaTemplates($debug=FALSE{
  117.         if ($debugecho "<p><b>CMS_SUMMARYPAGE::getChaTemplates($debug)</b> (".get_class($this).")</p>";
  118.         return FALSE;
  119.     }
  120.  
  121.     /**
  122.       * returns a database form
  123.       *
  124.       * @param int $mode       dbms form show mode
  125.       * @param string $frmName    dbms form name
  126.       *
  127.       * @return DBMS_FORM 
  128.       *
  129.       * @todo   input field PAGES is allways enabled
  130.       *
  131.       ***/
  132.     function &dbGetForm($mode,$frmName "",$debug=FALSE)  {
  133.         $form=&parent::dbGetForm($mode,$frmName);
  134.         $fldPages=&$form->addNoDbClassField("DBMS_FIELD_PAGESELECT","PAGES","Seiten");
  135.         $fldPages->multiselect=TRUE;
  136.         $fldPages->allowChange=TRUE;
  137.         $fldPages->enableNew=TRUE;
  138.         $fldPages->enableEdit=TRUE;
  139.         return $form;
  140.     }
  141.  
  142.  
  143.     /**
  144.       * returns a comma seperated list of page states to show
  145.       *
  146.       * @return array 
  147.       *
  148.       * @since pk-03-12-18
  149.       *
  150.       ***/
  151.     function getPageOnlineStates({
  152.         $ret=array();
  153.         foreach($GLOBALS['CMS']['PAGESTATE'as $key => $settings{
  154.             if ($settings['SHOW']$ret[]=$key;
  155.         }
  156.         return $ret;
  157.     }
  158.  
  159.     /**
  160.       * returns the query string to select the chapters
  161.       *
  162.       * adds $addWhere between WHERE and ORDER BY
  163.       *
  164.       * <code>
  165.       * $query.=" AND LANG_ID=".$this->getLangId();
  166.       * $query.=$addWhere;
  167.       * $query.=" ORDER BY ".$this->."_SORTORDER";
  168.       * </code>
  169.       *
  170.       * @param bool $showAll            don't care about chapter state
  171.       * @param bool $showTimedOut       show chapters with SHOWTILL date in past
  172.       * @param bool $showFuture         show chapters with SHOWFROM date in futur
  173.       * @param string $addWhere 
  174.       * @return string 
  175.       *
  176.       * @since pk-03-12-14
  177.       *
  178.       ***/
  179.     function getChapQuery($showAllStates=FALSE,$showTimedOut=FALSE,$showFuter=FALSE,$showGroup=0,$addWhere="",$debug=FALSE{
  180.         if ($debugecho "<p><b>CMS_PAGE_V2::getChapQuery($showAll,$showTimedOut,$showFuter,$showGroup,$addWhere,$debug)</b> (".get_class($this).")</p>";
  181.  
  182.         $query ="SELECT c.* FROM ".$this->cTable." c, ".$this->myTable." p ";
  183.         $query.=" WHERE p.".$this->previx."ID IN (".implode(",",$this->pages).")";
  184.  
  185.         if (!$showAllStates{
  186.             $query.=" AND p.".$this->previx."STATE IN (".implode(",",$this->getPageOnlineStates()).")";
  187.         }
  188.         if (!$showTimedOut{
  189.             $query.=" AND p.".$this->previx."SHOWTILL >= ".$GLOBALS[$this->$this->get_gDBIDX()]->qs_getNowStmt();
  190.         }
  191.         if (!$showFuter{
  192.             $query.=" AND p.".$this->previx."SHOWFROM <= ".$GLOBALS[$this->$this->get_gDBIDX()]->qs_getNowStmt();
  193.         }
  194.         if ($showGroup !== FALSE {    // note !== type equal compare (0 != FALSE)
  195.             if ($showGroup != -1{
  196.                 $query.=" AND p.".$this->previx."SHOWGROUP IN (".$GLOBALS['USER']->getGroups().")";
  197.             else {
  198.                 $query.=" AND p.".$this->previx."SHOWGROUP = ".$showGroup;
  199.             }
  200.         }
  201.  
  202.  
  203.         $query.=" AND c.PAG_ID=p.PAG_ID ";
  204.         $query.=" AND c.LANG_ID=".$this->getLangId();
  205.         if (!$showAllStates{
  206.             $query.=" AND c.".$this->chapPrevix."STATE IN (".implode(",",$this->getChapOnlineStates()).")";
  207.         }
  208.         if (!$showTimedOut{
  209.             $query.=" AND c.".$this->chapPrevix."SHOWTILL >= ".$GLOBALS[$this->$this->get_gDBIDX()]->qs_getNowStmt();
  210.         }
  211.         if (!$showFuter{
  212.             $query.=" AND c.".$this->chapPrevix."SHOWFROM <= ".$GLOBALS[$this->$this->get_gDBIDX()]->qs_getNowStmt();
  213.         }
  214.         if ($showGroup !== FALSE {    // note !== type equal compare (0 != FALSE)
  215.             if ($showGroup != -1{
  216.                 $query.=" AND c.".$this->chapPrevix."SHOWGROUP IN (".$GLOBALS['USER']->getGroups().")";
  217.             else {
  218.                 $query.=" AND c.".$this->chapPrevix."SHOWGROUP = ".$showGroup;
  219.             }
  220.         }
  221.         
  222.         $query.=" AND c.".$this->chapPrevix."SHOWMODE IN (".implode(",".getChapPageModes()).") ";
  223.  
  224.         $query.=$addWhere;
  225.         $query.=" ORDER BY ".$this->chapPrevix."SORTORDER";
  226.         return $query;
  227.     }
  228.  
  229.  
  230.  
  231. }
  232.  
  233. ?>

Documentation generated on Thu, 08 Jan 2009 17:40:02 +0100 by phpDocumentor 1.4.0a2