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

Source for file ScLabel.php

Documentation is available at ScLabel.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 Label Helper
  19.  *
  20.  * @uses viewHelper SmartClient
  21.  */
  22. {
  23.  
  24.     /**
  25.      * @var Zend_View_Interface 
  26.      */
  27.     public $view;
  28.  
  29.     /**
  30.      * 
  31.      * Return instance
  32.      * 
  33.      */
  34.     public function ScLabel()
  35.     {
  36.         return $this;
  37.     }
  38.  
  39.     /**
  40.      * 
  41.      * Sets the view field
  42.      * @param $view Zend_View_Interface
  43.      * 
  44.      */
  45.     public function setViewZend_View_Interface $view )
  46.     {
  47.         $this->view = $view;
  48.     }
  49.  
  50.     /**
  51.      * 
  52.      * Creates a label
  53.      *
  54.      * @param mixed $data If string, it must be the element ID. If array, them we will loop through it
  55.      * @param string $contents Content of the label
  56.      * @param array $options Additional options
  57.      * @return string 
  58.      * 
  59.      */
  60.     public function create$data $contents '' $options '' )
  61.     {
  62.         $newLabel array();
  63.         
  64.         // Check if it is an array
  65.         if is_array$data ) )
  66.         {
  67.             $newLabel $data;
  68.         }
  69.         else
  70.         {
  71.             // Add vars to the new label
  72.             $newLabel['ID'$data;
  73.             $newLabel['contents'$contents;
  74.             
  75.             // Check if options is array and do the loop
  76.             if is_array$options ) )
  77.             {
  78.                 foreach $options as $name => $value )
  79.                 {
  80.                     $newLabel[$name$value;
  81.                 }
  82.             }
  83.         }
  84.         
  85.         // Encode all data
  86.         $dataEncoded Zend_Json::encode$newLabel );
  87.         
  88.         // Remove vars that shouldn't be quoted
  89.         $dataEncoded $this->removeQuotes$dataEncoded );
  90.         
  91.         // Generate js code
  92.         $js '
  93.         <script type="text/javascript">
  94.             isc.Label.create(
  95.                 '$dataEncoded .'
  96.             );
  97.         </script>
  98.         ';
  99.         
  100.         return $js;
  101.     }
  102. }

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