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

Source for file ScHtmlFlow.php

Documentation is available at ScHtmlFlow.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 HtmlFlow Helper
  19.  *
  20.  */
  21. class ScHtmlFlow extends ScGeneral 
  22. {
  23.  
  24.     /**
  25.      * 
  26.      * Creates a HtmlFlow
  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 HTML content
  30.      * @param string $contentsURL HTML content from a URL
  31.      * @param array $options Additional options
  32.      * @return string 
  33.      * 
  34.      */
  35.     public function create$data $contents '' $contentsURL '' $options '' )
  36.     {
  37.         $newHtmlFlow array();
  38.         
  39.         // Check if it is an array
  40.         if is_array$data ) )
  41.         {
  42.             $newHtmlFlow $data;
  43.         }
  44.         else
  45.         {
  46.             // Add vars to the new button
  47.             $newHtmlFlow['ID'$data;
  48.             $newHtmlFlow['contents'$contents;
  49.             $newHtmlFlow['contentsURL'$contentsURL;
  50.             
  51.             // Check if options is array and do the loop
  52.             if is_array$options ) )
  53.             {
  54.                 foreach $options as $name => $value )
  55.                 {
  56.                     $newHtmlFlow[$name$value;
  57.                 }
  58.             }
  59.         }
  60.         
  61.         // Encode all data
  62.         $dataEncoded json_encode$newHtmlFlow );
  63.         
  64.         // Remove vars that shouldn't be quoted
  65.         $dataEncoded $this->removeQuotes$dataEncoded );
  66.         
  67.         // Generate js code
  68.         $js '
  69.         <script type="text/javascript">
  70.             isc.HTMLFlow.create(
  71.                 '$dataEncoded .'
  72.             );
  73.         </script>
  74.         ';
  75.         
  76.         return $js;
  77.     }
  78. }

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