SCZF
[ class tree: SCZF ] [ index: SCZF ] [ all elements ]

Source for file ScTabs.php

Documentation is available at ScTabs.php

  1. <?php
  2. /**
  3.  * SCZF
  4.  *
  5.  * An open source SmartClient View Helper for Zend Framework
  6.  *
  7.  * @package        SCZF
  8.  * @author        Fernando Marcelo Morgenstern <fernando@consultorpc.com>
  9.  * @copyright    Copyright (c) 2009, ConsultorPC
  10.  * @license        http://www.gnu.org/licenses/lgpl-3.0-standalone.html
  11.  * @link        http://smartclientphp.com/
  12.  * @since        Version 0.1b
  13.  * @filesource
  14.  */
  15.  
  16.  
  17. /**
  18.  * Smart Client Tabs Helper
  19.  *
  20.  * @uses viewHelper SmartClient
  21.  */
  22. {
  23.  
  24.     /**
  25.      * @var Zend_View_Interface 
  26.      */
  27.     public $view;
  28.     
  29.     /**
  30.      * @var Array All tabs
  31.      */
  32.     protected $_tabs;
  33.  
  34.     /**
  35.      * 
  36.      * Return instance
  37.      * 
  38.      */
  39.     public function ScTabs()
  40.     {
  41.         return $this;
  42.     }
  43.  
  44.     /**
  45.      * 
  46.      * Sets the view field
  47.      * @param $view Zend_View_Interface
  48.      * 
  49.      */
  50.     public function setViewZend_View_Interface $view )
  51.     {
  52.         $this->view = $view;
  53.     }
  54.     
  55.     /**
  56.      * 
  57.      * Add Tab
  58.      *
  59.      * @param mixed $data If string, it must be the title of the tab. If array, them we will loop on it
  60.      * @param string $pane Content of the tab
  61.      * @param array $options Additional options
  62.      * @return string 
  63.      * 
  64.      */
  65.     public function addTab$data $pane '' $options '' )
  66.     {
  67.         $newTab array();
  68.         
  69.         // Check if it is an array
  70.         if is_array$data ) )
  71.         {
  72.             $newTab $data;
  73.         }
  74.         else
  75.         {
  76.             // Add name and title to the new field
  77.             $newTab['title'$data;
  78.             $newTab['pane'$pane;
  79.             
  80.             // Check if options is array and do the loop
  81.             if is_array$options ) )
  82.             {
  83.                 foreach $options as $name => $value )
  84.                 {
  85.                     $newTab[$name$value;
  86.                 }
  87.             }
  88.         }
  89.         
  90.         // Add tab to the array
  91.         $this->_tabs[$newTab;
  92.     }
  93.  
  94.     /**
  95.      * Add Multiple Tabs
  96.      * 
  97.      * @param array $data Array containing multiple tabs
  98.      *  
  99.      */
  100.     public function addTabs$data )
  101.     {
  102.         if is_array$data ) )
  103.         {
  104.             foreach $data as $row )
  105.             {
  106.                 $this->addTab$row );
  107.             }
  108.         }
  109.     }
  110.     
  111.     /**
  112.      * Get Tabs
  113.      *
  114.      * Return the current tabs array
  115.      * 
  116.      * @return array 
  117.      *  
  118.      */
  119.     public function getTabs()
  120.     {
  121.         return $this->_tabs;
  122.     }
  123.     
  124.     /**
  125.      * 
  126.      * Clear Items array
  127.      *  
  128.      */
  129.     public function clearTabs()
  130.     {
  131.         unset$this->_tabs );
  132.     }
  133.  
  134.     /**
  135.      * 
  136.      * Creates a Tab Set
  137.      *
  138.      * @param mixed $data If string, it must be the element ID. If array, them we will loop through it
  139.      * @param integer $width Width of the tab set
  140.      * @param integer $height Height of the tab set
  141.      * @param array $options Additional options
  142.      * @return string 
  143.      * 
  144.      */
  145.     public function create$data $width '' $height '' $options '' )
  146.     {
  147.         $newTabSet array();
  148.         
  149.         // Check if it is an array
  150.         if is_array$data ) )
  151.         {
  152.             $newTabSet $data;
  153.         }
  154.         else
  155.         {
  156.             // Add vars to the new button
  157.             $newTabSet['ID'$data;
  158.             $newTabSet['width'$width;
  159.             $newTabSet['height'$height;
  160.             
  161.             // Set tabs
  162.             $newTabSet['tabs'$this->_tabs;
  163.             
  164.             // Check if options is array and do the loop
  165.             if is_array$options ) )
  166.             {
  167.                 foreach $options as $name => $value )
  168.                 {
  169.                     $newTabSet[$name$value;
  170.                 }
  171.             }
  172.         }
  173.         
  174.         // Encode all data
  175.         $dataEncoded Zend_Json::encode$newTabSet );
  176.         
  177.         // Remove vars that shouldn't be quoted
  178.         $dataEncoded $this->removeQuotes$dataEncoded );
  179.         
  180.         // Generate js code
  181.         $js '
  182.         <script type="text/javascript">
  183.             isc.TabSet.create(
  184.                 '$dataEncoded .'
  185.             );
  186.         </script>
  187.         ';
  188.         
  189.         return $js;
  190.     }
  191. }

Documentation generated on Mon, 20 Jul 2009 16:51:57 -0300 by phpDocumentor 1.4.1