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

Source for file ScLabel.php

Documentation is available at ScLabel.php

  1. <?php
  2. /**
  3.  * SCPHP
  4.  *
  5.  * An open source SmartClient library for PHP
  6.  *
  7.  * @package        SCPHP
  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.  */
  21. class ScLabel extends ScGeneral 
  22. {
  23.  
  24.     /**
  25.      * 
  26.      * Creates a label
  27.      *
  28.      * @param mixed $data If string, it must be the element ID. If array, them we will loop through it
  29.      * @param string $contents Content of the label
  30.      * @param array $options Additional options
  31.      * @return string 
  32.      * 
  33.      */
  34.     public function create$data $contents '' $options '' )
  35.     {
  36.         $newLabel array();
  37.         
  38.         // Check if it is an array
  39.         if is_array$data ) )
  40.         {
  41.             $newLabel $data;
  42.         }
  43.         else
  44.         {
  45.             // Add vars to the new label
  46.             $newLabel['ID'$data;
  47.             $newLabel['contents'$contents;
  48.             
  49.             // Check if options is array and do the loop
  50.             if is_array$options ) )
  51.             {
  52.                 foreach $options as $name => $value )
  53.                 {
  54.                     $newLabel[$name$value;
  55.                 }
  56.             }
  57.         }
  58.         
  59.         // Encode all data
  60.         $dataEncoded json_encode$newLabel );
  61.         
  62.         // Remove vars that shouldn't be quoted
  63.         $dataEncoded $this->removeQuotes$dataEncoded );
  64.         
  65.         // Generate js code
  66.         $js '
  67.         <script type="text/javascript">
  68.             isc.Label.create(
  69.                 '$dataEncoded .'
  70.             );
  71.         </script>
  72.         ';
  73.         
  74.         return $js;
  75.     }
  76. }

Documentation generated on Wed, 29 Jul 2009 22:37:14 -0300 by phpDocumentor 1.4.1