* @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 ToolStrips Helper * */ class ScToolStrips extends ScGeneral { /** * * Creates a toolscrip * * @param mixed $data If string, it must be the width of the toolstrip. If array, them we will loop through it * @param string $height Height of the button * @param array $members All members for this ToolStrip * @param array $options Additional options * @return string * */ public function create( $data , $height = '' , $members = '' , $options = '' ) { $newToolStrip = array(); // Check if it is an array if ( is_array( $data ) ) { $newToolStrip = $data; } else { // Add vars to the new toolstrip $newToolStrip['width'] = $data; $newToolStrip['height'] = $height; $newToolStrip['members'] = $members; // Check if options is array and do the loop if ( is_array( $options ) ) { foreach ( $options as $name => $value ) { $newToolStrip[$name] = $value; } } } // Encode all data $dataEncoded = json_encode( $newToolStrip ); // Remove vars that shouldn't be quoted $dataEncoded = $this->removeQuotes( $dataEncoded ); // Generate js code $js = 'isc.ToolStrip.create( '. $dataEncoded .' );'; // Add script tag $js = $this->addScriptTags( $js ); return $js; } }