Source for file class.acContentBlockBase.php

Documentation is available at class.acContentBlockBase.php

  1. <?php
  2. /**
  3.  * Class definition and methods for AdvancedContent contentblock types.<br />
  4.  * All block types needs to inherit and extend this class!
  5.  *
  6.  * @package AdvancedContent
  7.  * @category CMSModule
  8.  * @license GPL
  9.  * @author Georg Busch (NaN)
  10.  * @copyright 2010-2012 Georg Busch (NaN)
  11.  * @since 0.9
  12.  */
  13. {
  14.     /**
  15.      * @ignore
  16.      */
  17.     private   $_block_properties array('active' => true)// we shouldn't be here if the the block is not active
  18.     
  19.     /**
  20.      * @access protected
  21.      * @var object the content object instance that creates the contentblock
  22.      */
  23.     protected $content_obj;
  24.     
  25.     /**
  26.      * Constructor.<br />
  27.      * Required for all subclasses.<br />
  28.      * Should be called from each subclass as the very first.
  29.      * @param object &$content_obj - the content object instance that creates the contentblock
  30.      * @param array $params - the parameters of that contentblock
  31.      */
  32.     function __construct(&$content_obj&$params array())
  33.     {
  34.         $this->content_obj = $content_obj;
  35.         $AdvancedContent   =cms_utils::get_module('AdvancedContent');
  36.         
  37.         $this->_block_properties['smarty']           = isset($params['smarty']$params['smarty'false;
  38.         $this->_block_properties['editor_groups']    = isset($params['editor_groups']$params['editor_groups''';
  39.         $this->_block_properties['editor_users']     = isset($params['editor_users']$params['editor_users''';
  40.         $this->_block_properties['type']             = isset($params['block_type']$params['block_type''';
  41.         
  42.         $this->_block_properties['name']             = isset($params['block']$params['block''content_en';
  43.         $this->_block_properties['id']               preg_replace('/-+/','_'munge_string_to_url($this->_block_properties['name']));
  44.         $this->_block_properties['label']            = isset($params['label']$params['label'ucwords($this->_block_properties['name']);
  45.         $this->_block_properties['translate_labels'(isset($params['translate_labels']&& $this->content_obj->IsTrue($params['translate_labels']));
  46.         $this->_block_properties['translate_values'(isset($params['translate_values']&& $this->content_obj->IsTrue($params['translate_values']));
  47.         $this->_block_properties['required']         (isset($params['required']&& $this->content_obj->IsTrue($params['required']));
  48.         $this->_block_properties['default']          = isset($params['default']$params['default''';
  49.         $this->_block_properties['style']            = isset($params['style']$params['style'''# deprecated
  50.         $this->_block_properties['page_tab']         = isset($params['page_tab']$params['page_tab''main';
  51.         $this->_block_properties['block_tab']        = isset($params['block_tab']$params['block_tab''';
  52.         $this->_block_properties['block_group']      = isset($params['block_group']$params['block_group''';
  53.         $this->_block_properties['allow_none']       !(isset($params['allow_none']&& $this->content_obj->IsFalse($params['allow_none']));
  54.         $this->_block_properties['description']      = isset($params['description']$params['description''';
  55.         
  56.         $this->_block_properties['no_collapse'(isset($params['no_collapse']&& $this->content_obj->IsTrue($params['no_collapse']));
  57.         $this->_block_properties['collapsible'!$this->_block_properties['no_collapse'];
  58.         if(!$this->_block_properties['collapsible'])
  59.         {
  60.             $this->_block_properties['collapse'false;
  61.         }
  62.         else
  63.         {
  64.             $this->_block_properties['collapse'= isset($params['collapse']!$this->content_obj->IsFalse($params['collapse']$AdvancedContent->GetPreference('collapse_block_default'true);
  65.         }
  66.         
  67.         $this->_block_properties['feu_access'= isset($params['feu_access']$params['feu_access'''
  68.         $this->_block_properties['feu_action'(isset($params['feu_action']&& $this->content_obj->IsTrue($params['feu_action']));
  69.         $this->_block_properties['feu_hide']   (isset($params['feu_hide']&& $this->content_obj->IsTrue($params['feu_hide']));
  70.         
  71.         #$this->_block_properties['inherit'] = (isset($params['inherit']) && $this->content_obj->IsTrue($params['inherit']));
  72.     }
  73.     
  74.     /**
  75.      * Sets the value of a property. If not exists it will be created.
  76.      * @param string $name - the name of the property
  77.      * @param string $value - the value of the property
  78.      */
  79.     public final function SetBlockProperty($name$value '')
  80.     {
  81.         $this->_block_properties[strtolower($name)$value;
  82.     }
  83.     
  84.     /**
  85.      * Returns the value of a property.
  86.      * @param string $name - the name of the property
  87.      * @param string $default - the default value of the property if not exists
  88.      * @return mixed - usually this will be a string
  89.      */
  90.     public final function GetBlockProperty($name$default '')
  91.     {
  92.         $name strtolower($name);
  93.         if(isset($this->_block_properties[$name]))
  94.         {
  95.             return $this->_block_properties[$name];
  96.         }
  97.         return $default;
  98.     }
  99.     
  100.     /**
  101.      * Returns all valid properties of that block.
  102.      * @return array - array(propname => propvalue)
  103.      */
  104.     public final function GetBlockProperties()
  105.     {
  106.         return $this->_block_properties;
  107.     }
  108.     
  109.     /**
  110.      * Defines additional properties of the blocktype that needs to be stored "outside" the block.
  111.      * @return array - array(propname => propvalue)
  112.      */
  113.     public function GetBlockTypeProperties($access 'backend')
  114.     {
  115.         return array();
  116.     }
  117.     
  118.     /**
  119.      * Gets the html output of the block in backend.<br />
  120.      * This method is required and needs to be overwritten.
  121.      * @return string 
  122.      */
  123.     public function GetBlockInput()
  124.     {
  125.         $AdvancedContent =cms_utils::get_module('AdvancedContent');
  126.         return $AdvancedContent->lang('invalid_blocktype'$this->GetBlockProperty('name'));
  127.     }
  128.     
  129.     /**
  130.      * Gets the html that needs to be inserted in the head section for this blocktype when editing a page.<br />
  131.      * Can be useful to add css or js.
  132.      * @return string 
  133.      */
  134.     public function GetHeaderHTML()
  135.     {
  136.         return;
  137.     }
  138.     
  139.     /**
  140.      * Displays the help text for this blocktype.<br />
  141.      * Helptext will be displayed in modulehelp.
  142.      * @return string 
  143.      */
  144.     public function GetHelp()
  145.     {
  146.         return;
  147.     }
  148.     
  149.     /**
  150.      * Displays the changelog text for this blocktype.<br />
  151.      * Changelog will be displayed in modules changelog.
  152.      * @return string 
  153.      */
  154.     public function GetChangeLog()
  155.     {
  156.         return;
  157.     }
  158.     
  159.     /**
  160.      * Function for the subclass to parse out data for it's parameters.<br />
  161.      * Needs to be overwritten if the blocktype provides a special kind of data that needs to be processed before storing it.
  162.      * @param array &$params - the parameters that are passed when the form is submitted
  163.      * @param bool $editing - a flag to determine if the page is created or edited
  164.      * @return string 
  165.      */
  166.     public function FillBlockParams(&$params$editing false)
  167.     {
  168.         return isset($params[$this->GetBlockProperty('id')]$params[$this->GetBlockProperty('id')'';
  169.     }
  170.     
  171.     /**
  172.      * Function for the subclass to perform the blocks output<br />
  173.      * Needs to be overwritten if the blocktype provides a special kind of data that needs to be processed before displaying it in frontend.
  174.      * @return string 
  175.      */
  176.     public function ShowBlock()
  177.     {
  178.         return $this->content_obj->GetPropertyValue($this->GetBlockProperty('id'));
  179.     }
  180. }
  181. ?>

Documentation generated on Thu, 06 Oct 2011 20:54:40 +0200 by phpDocumentor 1.4.1