Source for file PGP_CMS_PAGE.phpclass

Documentation is available at PGP_CMS_PAGE.phpclass

  1. <?php
  2. /**
  3.   * openCSP class file PGP_CMS_PAGE.phpclass
  4.   *
  5.   * @project Open CSP-Management
  6.   * @package shop
  7.   *
  8.   * @author Peter Krebs <pitlinz@users.sourceforge.net>
  9.   * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10.   *
  11.   * @since pk-05.08.2008
  12.   * @version $Id: PGP_CMS_PAGE.phpclass,v 1.5 2008/10/15 06:55:16 pitlinz Exp $
  13.   */
  14.  
  15.     // ---------------------------------------------------------
  16.     // requirements
  17.     // ---------------------------------------------------------
  18.  
  19.     pcf_require_class('CMS_PAGE',"cms/page/");
  20.  
  21.  
  22. /**
  23.   * openCSP class PGP_CMS_PAGE
  24.   *
  25.   * @project Open CSP-Management
  26.   * @package shop
  27.   *
  28.   * @author Peter Krebs <pitlinz@users.sourceforge.net>
  29.   * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  30.   *
  31.   * @since pk-05.08.2008
  32.   * @version $Id: PGP_CMS_PAGE.phpclass,v 1.5 2008/10/15 06:55:16 pitlinz Exp $
  33.   */
  34. class PGP_CMS_PAGE extends CMS_PAGE
  35. {
  36.     // ---------------------------------------------------------------------------
  37.     // constants
  38.     // ---------------------------------------------------------------------------
  39.     
  40.     /**
  41.      * @constant string CLASS_SRC_FILE
  42.      */
  43.     const CLASS_SRC_FILE = __FILE__;
  44.  
  45.     // ---------------------------------------------------------------------------
  46.     // class (static)
  47.     // ---------------------------------------------------------------------------
  48.     
  49.     /*** class vars ------------------------------------------------------ */
  50.     
  51.     /*** class methods --------------------------------------------------- */
  52.     
  53.     // ---------------------------------------------------------------------------
  54.     // object vars
  55.     // ---------------------------------------------------------------------------
  56.     
  57.     /*** compostion --------------------------------------------------- */
  58.     
  59.     /**
  60.      * the product group
  61.      *
  62.      * @var PRO_GROUP $myProGroup 
  63.      */
  64.     protected $myProGroup = Null;
  65.     
  66.     protected $myProductPage = Null;
  67.     
  68.     /*** attributes  -------------------------------------------------- */
  69.     
  70.     /**
  71.      * show the current product group
  72.      *
  73.      * @var boolean $showPGPHeadline 
  74.      */
  75.     protected $showPGPHeadline = True;
  76.     
  77.     /**
  78.      * wether to show all products in the group and it's child groups
  79.      * or only show direct assigned products
  80.      *
  81.      * @var boolean 
  82.      */
  83.     protected $showAllChildProducts = False;
  84.     
  85.     /**
  86.       * @var string $includeRoot 
  87.       */
  88.     protected $includeRoot="templates/";
  89.  
  90.     /**#@+
  91.      * Template variable
  92.      * 
  93.      * @var string
  94.      */      
  95.     protected $tmpl_PGPHEADLINE = "";
  96.     protected $tmpl_PGPCHILDREN = "";
  97.     protected $tmpl_PRODUCT = "";    
  98.     /**#@-*/
  99.     
  100.     
  101.     
  102.     // ---------------------------------------------------------------------------
  103.     // factory / construct
  104.     // ---------------------------------------------------------------------------
  105.     
  106.     // ---------------------------------------------------------------------------
  107.     // getter / setter
  108.     // ---------------------------------------------------------------------------    
  109.  
  110.     /**
  111.       * returns a array of variables used by the page object
  112.       *
  113.       * array[varName]=array(
  114.       *     [TYPE]          datatype
  115.       *     [FLDCLASS]      name of DBMS_FIELD* class
  116.       *     [CLASSVALS]     array of values of [FLDCLASS]
  117.       *
  118.       * @global array $OCSP_CONF 
  119.       *
  120.       * @returns array
  121.       *
  122.       * @since pk-04-08-10
  123.       * @version pk-05-06-17
  124.       *
  125.       ***/
  126.     protected function getObjVarDef(
  127.     {
  128.         $arr_ret parent::getObjVarDef();
  129.         
  130.         $arr_ret['showPGPHeadline'array(
  131.             'TYPE'         => 'boolean',
  132.             'FLDCLASS'    => 'DBMS_FIELD_CHECKBOX',
  133.             'CLASSVALS' => array(
  134.                 'label'            => t_admin("Produktgruppe Anzeigen"),
  135.                 'defaultValue'        => 1,
  136.                 'checkedValue'        => 1,
  137.                 'uncheckedValue'    => 0,    
  138.                 'checkText'            => t_admin("Ja aktuelle Produktgruppe im Kopf anzeigen"),
  139.                 'uncheckText'        => t_admin("Nein"),
  140.                 'lstStyle'            => 2        
  141.             )
  142.         );
  143.                         
  144.         $arr_ret['showPGPHeadline'array(
  145.             'TYPE'         => 'boolean',
  146.             'FLDCLASS'    => 'DBMS_FIELD_CHECKBOX',
  147.             'CLASSVALS' => array(
  148.                 'label'            => t_admin("Produktgruppe Anzeigen"),
  149.                 'defaultValue'        => 1,
  150.                 'checkedValue'        => 1,
  151.                 'uncheckedValue'    => 0,    
  152.                 'checkText'            => t_admin("Ja aktuelle Produktgruppe anzeigen"),
  153.                 'uncheckText'        => t_admin("Nein"),
  154.                 'lstStyle'            => 2        
  155.             )
  156.         );          
  157.         $arr_ret["tmpl_PGPHEADLINE"]array(
  158.                 "TYPE"      => "string",
  159.                 "FLDCLASS"  => "DBMS_FIELD_FILESELECTLIST",
  160.                 "CLASSVALS" =>array(
  161.                     "label"         => t_admin("Produktgruppe Template"),
  162.                     "allowNull"     => True,
  163.                     "isSearchable"  => True,
  164.                     "showInList"    => False,
  165.                     "toolTip"       => t_admin("Include Template f&uumlr  die Produktgruppe"),
  166.                     "rootDir"       => $this->includeRoot,
  167.                     "defaultDir"    => $this->includeRoot."shop",
  168.                     "allow_mkdir"   => True,
  169.                     "allow_upload"  => True
  170.                 )
  171.             );
  172.  
  173.           
  174.         $arr_ret['showPGPChildren'array(
  175.             'TYPE'         => 'boolean',
  176.             'FLDCLASS'    => 'DBMS_FIELD_CHECKBOX',
  177.             'CLASSVALS' => array(
  178.                 'label'            => t_admin("Produkt Untergruppen Anzeigen"),
  179.                 'defaultValue'        => 0,
  180.                 'checkedValue'        => 1,
  181.                 'uncheckedValue'    => 0,    
  182.                 'checkText'            => t_admin("Ja Untergruppen der aktuelle Produktgruppe anzeigen"),
  183.                 'uncheckText'        => t_admin("Nein"),
  184.                 'lstStyle'            => 2        
  185.             )
  186.         );          
  187.             
  188.         $arr_ret["tmpl_PGPCHILDREN"]array(
  189.                 "TYPE"      => "string",
  190.                 "FLDCLASS"  => "DBMS_FIELD_FILESELECTLIST",
  191.                 "CLASSVALS" =>array(
  192.                     "label"         => t_admin("UnterProduktgruppe Template"),
  193.                     "allowNull"     => True,
  194.                     "isSearchable"  => True,
  195.                     "showInList"    => False,
  196.                     "toolTip"       => t_admin("Include Template f&uumlr die Untergruppen der Produktgruppe"),
  197.                     "rootDir"       => $this->includeRoot,
  198.                     "defaultDir"    => $this->includeRoot."shop",
  199.                     "allow_mkdir"   => True,
  200.                     "allow_upload"  => True
  201.                 )
  202.             );   
  203.             
  204.         $arr_ret['showAllChildProducts'array(
  205.             'TYPE'         => 'boolean',
  206.             'FLDCLASS'    => 'DBMS_FIELD_CHECKBOX',
  207.             'CLASSVALS' => array(
  208.                     'label'                => t_admin("Alle Produkte unter der Gruppe"),
  209.                     'defaultValue'        => 0,
  210.                     'checkedValue'        => 1,
  211.                     'uncheckedValue'    => 0,    
  212.                     'checkText'            => t_admin("Ja, Untergruppen einschließen"),
  213.                     'uncheckText'        => t_admin("Nein"),
  214.                     'lstStyle'            => 2
  215.                 )
  216.         );    
  217.                         
  218.         $arr_ret["tmpl_PRODUCT"]array(
  219.                 "TYPE"      => "string",
  220.                 "FLDCLASS"  => "DBMS_FIELD_FILESELECTLIST",
  221.                 "CLASSVALS" =>array(
  222.                     "label"         => t_admin("Produkt Template"),
  223.                     "allowNull"     => True,
  224.                     "isSearchable"  => True,
  225.                     "showInList"    => False,
  226.                     "toolTip"       => t_admin("Include Template f&uumlr die Produktdarstellung"),
  227.                     "rootDir"       => $this->includeRoot,
  228.                     "defaultDir"    => $this->includeRoot."shop",
  229.                     "allow_mkdir"   => True,
  230.                     "allow_upload"  => True
  231.                 )
  232.             )
  233.             
  234.           $arr_ret['productPage'array(
  235.               "TYPE"        => "int",
  236.               "FLDCLASS"    => "DBMS_FIELD_PAGESELECT",
  237.               "CLASSVALS" => array(
  238.                       'label'            => t_admin("Produktseite"),
  239.                     'allowNull'     => True,
  240.                     "isSearchable"  => True,
  241.                     "showInList"    => False,
  242.                       'toolTip'        => t_admin("Seite die für die Produktanzeige ge&ouml;ffnet wird")          
  243.                   )    
  244.           );
  245.  
  246.         return $arr_ret;
  247.     }    
  248.     
  249.     /**
  250.      * returns the product group of the page
  251.      *
  252.      * @param boolean $debug 
  253.      * 
  254.      * @return PRO_GROUP 
  255.      */
  256.     public function &getMyProductGroup($debug=False)
  257.     {
  258.         if (!$this->myProGroup)
  259.         {
  260.             $obj_menu $this->getMyMenuNode($debug);
  261.             if (!method_exists($obj_menu,'getProductGroup'))
  262.             {
  263.                 throw new Exception(_OCSP_EXCEP_WRONGOBJ_TYPE_ ":" get_class($obj_menu));
  264.             }
  265.             $this->myProGroup = $obj_menu->getProductGroup();
  266.         }
  267.         return $this->myProGroup;
  268.     }
  269.     
  270.     /**
  271.      * sets the product group of the page
  272.      *
  273.      * @param PRO_GROUP $aProGroup 
  274.      */
  275.     public function setMyProductGroup(&$aProGroup)
  276.     {
  277.         $this->myProGroup = $aProGroup;
  278.     }
  279.     
  280.     /**
  281.      * returns the product page object
  282.      * 
  283.      * @return PRO_CMS_PAGE 
  284.      */
  285.     public function getProductPage()
  286.     {
  287.         if (!is_object($this->myProductPage))
  288.         {
  289.             $this->myProductPage = CMS_PAGE::getInstance(intval($this->getDBField('productPage')));
  290.             $this->myProductPage->setMyMenuNode($this->getMyMenuNode());
  291.         }
  292.         
  293.         return $this->myProductPage;
  294.     }
  295.     
  296.     
  297.     // ---------------------------------------------------------------------------
  298.     // navigation
  299.     // ---------------------------------------------------------------------------
  300.      
  301.      public function getProductPageLink($debug)
  302.      {
  303.          if ($debugechoDebugMethod(__FILE__,get_class($this),"PGP_CMS_PAGE::getProductPageLink();");
  304.     
  305.          
  306.          
  307.          
  308.      }
  309.     
  310.     // ---------------------------------------------------------------------------
  311.     // output
  312.     // ---------------------------------------------------------------------------
  313.     
  314.      /**
  315.       * renders the product group
  316.       *
  317.       * @param boolean $debug 
  318.       * 
  319.       * @return string (html)
  320.       */
  321.     protected function renderProductGroup($debug=False)
  322.     {
  323.         if ($debugechoDebugMethod(__FILE__,get_class($this),"PGP_CMS_PAGE::renderProductGroup();");
  324.  
  325.         $str_ret "";
  326.         
  327.         if ($this->getMyProductGroup($debug))
  328.         {
  329.             if ($this->myProGroup->getId(&& intval($this->getDBField('showPGPHeadline')))
  330.             {
  331.                 $str_tmpl $this->getDBField('tmpl_PGPHEADLINE');
  332.                 if (!empty($str_tmpl))
  333.                 {
  334.                     //echoDebugLine(__FILE__,__LINE__,"<p>" . $str_tmpl . "</p>");
  335.                     ob_start();
  336.                     include __OCSP_PROJECTPATH__.$str_tmpl;
  337.                     $str_ret .= ob_get_contents();
  338.                     ob_end_clean();
  339.                 else {
  340.                     $str_ret .= "<h1>" $this->myProGroup->getTitle("</h1>";                
  341.                 }
  342.             }
  343.         }
  344.         return $str_ret;
  345.     }
  346.     
  347.     /**
  348.      * returns the child group content
  349.      * 
  350.      * @param boolean $debug 
  351.      */
  352.     protected function renderChildGroups($debug=False)
  353.     {
  354.         if ($debugechoDebugMethod(__FILE__,get_class($this),"PGP_CMS_PAGE::renderChildGroups();");
  355.  
  356.         $str_ret "";
  357.         
  358.         if ($this->getMyProductGroup($debug&& intval($this->getDBField('showPGPChildren',$debug)))
  359.         {            
  360.             if ($debugechoDebugLine(__FILE__,__LINE__,"productgroup found && showPGPChildren");    
  361.             if ($arr_childGroups $this->myProGroup->getChildren($debug))
  362.             {
  363.                 $str_tmpl $this->getDBField('tmpl_PGPCHILDREN');
  364.                 foreach($arr_childGroups as &$obj_progroup)
  365.                 {
  366.                     if (!empty($str_tmpl))
  367.                     {
  368.                         //echoDebugLine(__FILE__,__LINE__,"<p>" . $str_tmpl . "</p>");
  369.                         ob_start();
  370.                         include __OCSP_PROJECTPATH__.$str_tmpl;
  371.                         $str_ret .= ob_get_contents();
  372.                         ob_end_clean();
  373.                     else {
  374.                         if ($obj_progroup->isOnline())
  375.                         {
  376.                             $str_ret .= "<h2>" $obj_progroup->getTitle("</h2>";    
  377.                         }        
  378.                     }                    
  379.                 }
  380.             }
  381.         else if ($debug{
  382.             echoDebugLine(__FILE__,__LINE__,"no product group to render");
  383.         }
  384.         return $str_ret;
  385.     }
  386.     
  387.     /**
  388.      * renders the product
  389.      *
  390.      * @param boolean $debug 
  391.      * 
  392.      * @return string (html)
  393.      */
  394.     protected function renderProducts($debug=False)
  395.     {
  396.         if ($debugechoDebugMethod(__FILE__,get_class($this),"PGP_CMS_PAGE::renderProducts();");
  397.  
  398.         $str_ret "";
  399.         
  400.         if ($this->getMyProductGroup($debug))
  401.         {
  402.             $str_tmpl $this->getDBField('tmpl_PRODUCT');
  403.             
  404.             if ($arr_products $this->myProGroup->getProductList())
  405.             {
  406.                 if (!empty($str_tmpl))
  407.                 {
  408.                     foreach($arr_products as &$obj_product)
  409.                     {
  410.                         ob_start();
  411.                         include __OCSP_PROJECTPATH__.$str_tmpl;
  412.                         $str_ret .= ob_get_contents();
  413.                         ob_end_clean();
  414.                     }
  415.                 }
  416.             }
  417.         }
  418.         return $str_ret;
  419.     }
  420.     
  421.     /**
  422.       * returns the content of the page
  423.       *
  424.       * @param int $chaShowMode 
  425.       * @param boolean $debug 
  426.       *
  427.       * @return string 
  428.       * @since pk-07-08-25
  429.       * @version pk-07-10-04
  430.       * @version pk-08-07-25
  431.       */
  432.     public function getContent($chaShowMode=0,$debug=False
  433.     {                 
  434.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PHPINC_PAGE::getContent($chaShowMode)","<pre>" print_r($this->getDBVal(),True"</pre>");
  435.  
  436.         if (($chaShowMode == 0))
  437.         {
  438.             if ($this->getContentCalled())
  439.             {
  440.                 throw new Exception('content called twice');
  441.             else {
  442.                 $this->setContentCalled(True);
  443.             }
  444.         }        
  445.                 
  446.         if (($chaShowMode != CHAPTER_SHOWMODE_PROGRAMM&& ($chaShowMode != 0))
  447.         {
  448.             return parent::getContent($chaShowMode,$debug);
  449.         else {            
  450.             $str_ret="";
  451.             
  452.             if ($chaShowMode != CHAPTER_SHOWMODE_PROGRAMM)
  453.             {
  454.                 $str_ret .= $this->getContent(CHAPTER_SHOWMODE_ALLWAYS_TOP,$debug)
  455.             }
  456.             
  457.             ob_start();
  458.  
  459.             if ($debugechoDebugLine(__FILE__,__LINE__,"rendering product group");            
  460.             $str_ret .= $this->renderProductGroup($debug);
  461.             $str_ret .= $this->renderChildGroups($debug);
  462.             $str_ret .= $this->renderProducts($debug);
  463.             
  464.             if ($debug$str_ret .= "<hr /><h2>Debug</h2><div style=\"font-size:80%\">" ob_get_contents("</div></hr>";
  465.             ob_end_clean();
  466.  
  467.             if ($chaShowMode != CHAPTER_SHOWMODE_PROGRAMM)
  468.             {
  469.                 $str_ret.=$this->getContent(CHAPTER_SHOWMODE_ALLWAYS_BOTTOM)
  470.             }            
  471.             
  472.             return $str_ret;            
  473.         }
  474.     }    
  475.     
  476. }
  477.  
  478. ?>

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