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

Documentation generated on Wed, 05 Oct 2011 18:23:02 +0200 by phpDocumentor 1.4.1