* @copyright Copyright (c) 2009, ConsultorPC * @license http://www.gnu.org/licenses/lgpl-3.0-standalone.html * @link http://smartclientphp.com/ * @since Version 0.1b * @filesource */ /** * Smart Client HtmlFlow Helper * */ class ScHtmlFlow extends ScGeneral { /** * * Creates a HtmlFlow * * @param mixed $data If string, it must be the element ID. If array, them we will loop through it * @param string $contents HTML content * @param string $contentsURL HTML content from a URL * @param array $options Additional options * @return string * */ public function create( $data , $contents = '' , $contentsURL = '' , $options = '' ) { $newHtmlFlow = array(); // Check if it is an array if ( is_array( $data ) ) { $newHtmlFlow = $data; } else { // Add vars to the new button $newHtmlFlow['ID'] = $data; $newHtmlFlow['contents'] = $contents; $newHtmlFlow['contentsURL'] = $contentsURL; // Check if options is array and do the loop if ( is_array( $options ) ) { foreach ( $options as $name => $value ) { $newHtmlFlow[$name] = $value; } } } // Encode all data $dataEncoded = json_encode( $newHtmlFlow ); // Remove vars that shouldn't be quoted $dataEncoded = $this->removeQuotes( $dataEncoded ); // Generate js code $js = 'isc.HTMLFlow.create( '. $dataEncoded .' );'; // Add script tag $js = $this->addScriptTags( $js ); return $js; } }