* @copyright Copyright (c) 2010, ConsultorPC * @license http://www.gnu.org/licenses/lgpl-3.0-standalone.html * @link http://smartclientphp.com/ * @since Version 0.1b * @filesource */ /** * Smart Client Label Helper * */ class ScLabel extends ScGeneral { /** * * Creates a label * * @param mixed $data If string, it must be the element ID. If array, them we will loop through it * @param string $contents Content of the label * @param array $options Additional options * @return string * */ public function create( $data , $contents = '' , $options = '' ) { $newLabel = array(); // Check if it is an array if ( is_array( $data ) ) { $newLabel = $data; } else { // Add vars to the new label $newLabel['ID'] = $data; $newLabel['contents'] = $contents; // Check if options is array and do the loop if ( is_array( $options ) ) { foreach ( $options as $name => $value ) { $newLabel[$name] = $value; } } } // Encode data $dataEncoded = $this->encode( $newLabel ); // Generate js code $js = 'isc.Label.create( '. $dataEncoded .' );'; // Add script tag $js = $this->addScriptTags( $js ); return $js; } }