* @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 General Helper * */ class ScGeneral { /** * @var String */ public $removeQuotesStr; /** * * @var string */ protected $jsTagHeader; /** * * @var string */ protected $jsTagFooter; /** * * @var bool */ protected $showJsTags; /** * Set $remove_quotes_str */ public function __construct() { // Set initial values $this->removeQuotesStr = '{NQ}'; $this->jsTagHeader = ''; $this->showJsTags = true; } /** * * Return instance * */ public function ScGeneral () { return $this; } /** * Create the scripts for include * * @param string $sc_path Path where SmartClient is located * @param string $theme SmartClient theme * @param boolean $useCompression * @param string $scCompressPath Path where ScCompress.php is located. Only used if $useCompression is true. * @return string */ public function includeScripts( $scPath = 'js/isomorphic/' , $theme = 'SmartClient' , $useCompression = false , $scCompressPath = 'js/' ) { // Check if we have to use compression if ( $useCompression ) { $includeScripts = ' '; } else { $includeScripts = ' '; } return $includeScripts; } /** * * Add QuotesStr to String * * @param string $str * @return string */ public function addQuotesStr( $str ) { return $this->removeQuotesStr . $str . $this->removeQuotesStr; } /** * Remove quotes from specific vars that are not supposed to be quoted using * the $removeQuotesStr var * * @param string $json String in json format * @return string */ public function removeQuotes( $json ) { $newJson = $json; // Removes quotes replacing remove_quotes_str $newJson = str_replace( $this->removeQuotesStr .'"' , '' , $newJson ); $newJson = str_replace( '"'. $this->removeQuotesStr , '' , $newJson ); return $newJson; } /** * Set javascript tag header * * @param string $value * @return void */ public function setJsTagHeader( $value ) { $this->jsTagHeader = $value; } /** * Set javascript tag footer * * @param string $value * @return void */ public function setJsTagFooter( $value ) { $this->jsTagFooter = $value; } /** * Define if javascript tags should show up * * @param boolean $value * @return void */ public function showJsTags( $value ) { $this->showJsTags = (bool) $value; } /** * Add script tags if showJsTags is true * * @param string $script * @return string */ public function addScriptTags( $script ) { if ( $this->showJsTags ) { $script = $this->jsTagHeader . $script . $this->jsTagFooter; } return $script; } }