PhpExt : Toolbar [ class tree ] [ index ] [ all elements ]

Source for file Toolbar.php

Documentation is available at Toolbar.php

  1. <?php
  2. /**
  3.  * PHP-Ext Library
  4.  * http://php-ext.googlecode.com
  5.  * @author Sergei Walter <sergeiw[at]gmail[dot]com>
  6.  * @copyright 2008 Sergei Walter
  7.  * @license http://www.gnu.org/licenses/lgpl.html
  8.  * @link http://php-ext.googlecode.com
  9.  * 
  10.  *  Reference for Ex JS: http://extjs.com
  11.  * 
  12.  */
  13.  
  14. /**
  15.  * @see PhpExt_BoxComponent
  16.  */
  17. include_once 'PhpExt/BoxComponent.php';
  18. /**
  19.  * @see PhpExt_Toolbar_IToolbarItemCollection
  20.  */
  21. include_once 'PhpExt/Toolbar/IToolbarItemCollection.php';
  22.  
  23.  
  24. /**
  25.  * Basic Toolbar class.
  26.  * @package PhpExt
  27.  * @subpackage Toolbar
  28.  */
  29. {
  30.     /**
  31.      * Object Collection
  32.      *
  33.      * @var PhpExt_Toolbar_IToolbarItemCollection 
  34.      */
  35.     protected $_items = null;
  36.     // Items
  37.  
  38.     /**
  39.      * 
  40.      * @return PhpExt_Toolbar_IToolbarItemCollection 
  41.      */
  42.     public function getItems({
  43.         return $this->getExtConfigProperty("items");
  44.     }
  45.     
  46.     
  47.         
  48.     public function __construct({
  49.         parent::__construct();
  50.         $this->setExtClassInfo("Ext.Toolbar""toolbar");
  51.     
  52.         $validProps array(
  53.             "items"
  54.         );
  55.         $this->addValidConfigProperties($validProps);
  56.         
  57.         $this->_items = new PhpExt_Toolbar_IToolbarItemCollection();
  58.         $this->_items->setForceArray(true);
  59.         $this->setExtConfigProperty("items"$this->_items);
  60.     }
  61.     
  62.     /**
  63.      * Helper function to quick add a separator
  64.      *
  65.      * @param string $key 
  66.      * @return PhpExt_Toolbar_Toolbar 
  67.      */
  68.     public function addSeparator($key{
  69.         include_once 'PhpExt/Toolbar/Separator.php';
  70.         $this->_items->add(new PhpExt_Toolbar_Separator()$key);
  71.         return $this->_items->getByName($key);
  72.     }
  73.     
  74.     /**
  75.      * Helper function to quick add a spacer
  76.      *
  77.      * @param string $key 
  78.      * @return PhpExt_Toolbar_Spacer 
  79.      */
  80.     public function addSpacer($key{
  81.         include_once 'PhpExt/Toolbar/Spacer.php';
  82.         $this->_items->add(new PhpExt_Toolbar_Spacer()$key);
  83.         return $this->_items->getByName($key);
  84.     }
  85.     
  86.     /**
  87.      * Helper function to quick add a fill
  88.      *
  89.      * @param string $key 
  90.      * @return PhpExt_Toolbar_Fill 
  91.      */
  92.     public function addFill($key{
  93.         include_once 'PhpExt/Toolbar/Fill.php';
  94.         $this->_items->add(new PhpExt_Toolbar_Fill()$key);
  95.         return $this->_items->getByName($key);
  96.     }
  97.     
  98.     /**
  99.      * Helper function to quick add a textitem
  100.      *
  101.      * @param string $key 
  102.      * @param string $text The text to show in the item
  103.      * @return PhpExt_Toolbar_TextItem 
  104.      */
  105.     public function addTextItem($key$text{
  106.         include_once 'PhpExt/Toolbar/TextItem.php';
  107.         $this->_items->add(new PhpExt_Toolbar_TextItem($text)$key);;
  108.         return $this->_items->getByName($key);
  109.     }
  110.     
  111.     /**
  112.      * Helper function to quick add a button
  113.      *
  114.      * @param string $key 
  115.      * @param string $text The text to show in the button
  116.      * @param string $iconUrl The URL of and image to show as button's icon
  117.      * @return PhpExt_Toolbar_Button 
  118.      */
  119.     public function addButton($key$text$iconUrl null$handler null{
  120.         include_once 'PhpExt/Toolbar/Button.php';
  121.         $this->_items->add(PhpExt_Toolbar_Button::createButton($text$iconUrl$handler)$key);
  122.         return $this->_items->getByName($key);
  123.     }
  124.     
  125.     /**
  126.      * Helper function to quick add a item
  127.      *
  128.      * @param string $key 
  129.      * @param string $item 
  130.      * @return PhpExt_Toolbar_Item 
  131.      */
  132.     public function addItem($key&$item{
  133.         $this->_items->add($item$key);
  134.         return $item;
  135.     }
  136.     
  137.     var $_mustRender = false;
  138.     /**
  139.      * True to render the toolbar even if it does not have items.
  140.      *
  141.      * @return boolean 
  142.      */
  143.     public function getMustRender({
  144.         return $this->_mustRender;
  145.     }
  146.     
  147.     /**
  148.      * True to render the toolbar even if it does not have items
  149.      *
  150.      * @param boolean $mustRender 
  151.      */
  152.     public function setMustRender($mustRender{
  153.         $this->_mustRender = $mustRender;
  154.     }
  155.     
  156.     
  157.     public function removeItem($key{
  158.         $this->_items->removeObject($key);
  159.     }
  160.     
  161.     public function &getItem($key{
  162.         return $this->_items->getByName($key);
  163.     }
  164.  
  165.     /*protected function getConfigParams($lazy = false) {
  166.         $params = parent::getConfigParams($lazy);
  167.         
  168.         // Items
  169.         if ($this->_items->getCount() > 0) {
  170.             $this->_items->ForceArray = true;
  171.             $params[] = $this->paramToString("items", $this->Items);            
  172.         }        
  173.                             
  174.         return $params;
  175.     }*/
  176.          
  177. }

Documentation generated on Fri, 08 Aug 2008 16:01:32 -0500 by phpDocumentor 1.4.0