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

Source for file ScGeneral.php

Documentation is available at ScGeneral.php

  1. <?php
  2. /**
  3.  * SCZF
  4.  *
  5.  * An open source SmartClient View Helper for Zend Framework
  6.  *
  7.  * @package        SCZF
  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. require_once 'Zend/View/Interface.php';
  17. require_once 'Zend/Json/Encoder.php';
  18.  
  19. /**
  20.  * Smart Client General Helper
  21.  *
  22.  * @uses viewHelper SmartClient
  23.  */
  24. class SmartClient_Helper_ScGeneral extends Zend_View_Helper_Action 
  25. {
  26.     /**
  27.      * @var Zend_View_Interface 
  28.      */
  29.     public $view;
  30.     
  31.     /**
  32.      * @var String 
  33.      */
  34.     public $removeQuotesStr;
  35.     
  36.     /**
  37.      * Set $remove_quotes_str
  38.      */
  39.     public function __construct()
  40.     {
  41.         $this->removeQuotesStr = '{NQ}';
  42.     }
  43.  
  44.     /**
  45.      * 
  46.      * Return instance
  47.      * 
  48.      */
  49.     public function ScGeneral ()
  50.     {
  51.         return $this;
  52.     }
  53.  
  54.     /**
  55.      * Sets the view field
  56.      * @param $view Zend_View_Interface
  57.      */
  58.     public function setView (Zend_View_Interface $view)
  59.     {
  60.         $this->view = $view;
  61.     }
  62.     
  63.     /**
  64.      * Create the scripts for include
  65.      *
  66.      * @param string $sc_path Path where SmartClient is located
  67.      * @param string $theme    SmartClient theme
  68.      * @return string 
  69.      */
  70.     public function includeScripts$scPath 'js/isomorphic/' $theme 'SmartClient' )
  71.     {
  72.         $includeScripts '
  73.         <script type="text/javascript">var isomorphicDir="'$scPath .'";</script>
  74.         <script src='$scPath .'system/modules/ISC_Core.js type="text/javascript"></script>
  75.         <script src='$scPath .'system/modules/ISC_Foundation.js type="text/javascript"></script>
  76.         <script src='$scPath .'system/modules/ISC_Containers.js type="text/javascript"></script>
  77.         <script src='$scPath .'system/modules/ISC_Grids.js type="text/javascript"></script>
  78.         <script src='$scPath .'system/modules/ISC_Forms.js type="text/javascript"></script>
  79.         <script src='$scPath .'system/modules/ISC_DataBinding.js type="text/javascript"></script>
  80.         <script src='$scPath .'skins/'$theme .'/load_skin.js type="text/javascript"></script>
  81.         ';
  82.         
  83.         return $includeScripts;
  84.     }
  85.     
  86.     /**
  87.      *
  88.      * Add QuotesStr to String
  89.      *
  90.      * @param string $str 
  91.      * @return string 
  92.      */
  93.     public function addQuotesStr$str )
  94.     {
  95.         return $this->removeQuotesStr . $str $this->removeQuotesStr;
  96.     }
  97.     
  98.     /**
  99.      * Remove quotes from specific vars that are not supposed to be quoted using
  100.      * the $removeQuotesStr var
  101.      *
  102.      * @param string $json String in json format
  103.      * @return string 
  104.      */
  105.     public function removeQuotes$json )
  106.     {
  107.         $newJson $json;
  108.         
  109.         // Removes quotes replacing remove_quotes_str
  110.         $newJson str_replace$this->removeQuotesStr .'"' '' $newJson );
  111.         $newJson str_replace'"'$this->removeQuotesStr '' $newJson );
  112.         
  113.         return $newJson;
  114.     }
  115. }

Documentation generated on Mon, 20 Jul 2009 16:51:57 -0300 by phpDocumentor 1.4.1