summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorxue <>2006-02-19 01:22:03 +0000
committerxue <>2006-02-19 01:22:03 +0000
commitd38334fc8aac7b4488a6fa10fe6acc219665c3bd (patch)
tree13d45ef7012053d8349d7bc4a7aaa08dbcea0296 /framework
parentf401d7f1372240798e0470fb90bdbed83d5da452 (diff)
Updated architecture tutorial page for change of asset manager.
Diffstat (limited to 'framework')
-rw-r--r--framework/Web/Javascripts/TClientScript.php140
-rw-r--r--framework/Web/Javascripts/TJavascriptSerializer.php141
2 files changed, 0 insertions, 281 deletions
diff --git a/framework/Web/Javascripts/TClientScript.php b/framework/Web/Javascripts/TClientScript.php
deleted file mode 100644
index 5047959d..00000000
--- a/framework/Web/Javascripts/TClientScript.php
+++ /dev/null
@@ -1,140 +0,0 @@
-<?php
-
-
-/**
- * PradoClientScript class.
- *
- * Resolves Prado client script dependencies. e.g. TPradoClientScript::getScripts("dom");
- *
- * - <b>base</b> basic javascript utilities, e.g. $()
- * - <b>dom</b> DOM and Form functions, e.g. $F(inputID) to retrive form input values.
- * - <b>effects</b> Effects such as fade, shake, move
- * - <b>controls</b> Prado client-side components, e.g. Slider, AJAX components
- * - <b>validator</b> Prado client-side validators.
- * - <b>ajax</b> Prado AJAX library including Prototype's AJAX and JSON.
- *
- * Dependencies for each library are automatically resolved.
- *
- * Namespace: System.Web.UI
- *
- * @author Wei Zhuo<weizhuo[at]gmail[dot]com>
- * @version $Revision: 1.1 $ $Date: 2005/11/06 23:02:33 $
- * @package System.Web.UI
- */
-class TClientScript
-{
- protected $_manager;
-
- /**
- * Client-side javascript library dependencies
- * @var array
- */
- protected static $_dependencies = array(
- 'prado' => array('prado'),
- 'effects' => array('prado', 'effects'),
- 'ajax' => array('prado', 'effects', 'ajax'),
- 'validator' => array('prado', 'validator'),
- 'logger' => array('prado', 'logger'),
- 'datepicker' => array('prado', 'datepicker'),
- 'rico' => array('prado', 'effects', 'ajax', 'rico'),
- 'colorpicker' => array('prado', 'colorpicker')
- );
-
- public function __construct($manager)
- {
- $this->_manager = $manager;
- }
-
- /**
- * Resolve dependencies for the given library.
- * @param array list of libraries to load.
- * @return array list of libraries including its dependencies.
- */
- public function getScripts($scripts)
- {
- $files = array();
- if(!is_array($scripts)) $scripts = array($scripts);
- foreach($scripts as $script)
- {
- if(isset(self::$_dependencies[$script]))
- $files = array_merge($files, self::$_dependencies[$script]);
- $files[] = $script;
- }
- $files = array_unique($files);
- return $files;
- }
-
-
- /**
- * TODO: clean up
- *
- public function getPostBackEventReference($control,$parameter='',$options=null,$javascriptPrefix=true)
- {
- if(!$options || (!$options->getPerformValidation() && !$options->getTrackFocus() && $options->getClientSubmit() && $options->getActionUrl()==''))
- {
- $this->registerPostBackScript();
- if(($form=$this->_page->getForm())!==null)
- $formID=$form->getClientID();
- else
- throw new TConfigurationException('clientscriptmanager_form_required');
- $postback=self::POSTBACK_FUNC.'(\''.$formID.'\',\''.$control->getUniqueID().'\',\''.THttpUtility::quoteJavaScriptString($parameter).'\')';
- if($options && $options->getAutoPostBack())
- $postback='setTimeout(\''.THttpUtility::quoteJavaScriptString($postback).'\',0)';
- return $javascriptPrefix?'javascript:'.$postback:$postback;
- }
- $opt='';
- $flag=false;
- if($options->getPerformValidation())
- {
- $flag=true;
- $this->registerValidationScript();
- $opt.=',true,';
- }
- else
- $opt.=',false,';
- if($options->getValidationGroup()!=='')
- {
- $flag=true;
- $opt.='"'.$options->getValidationGroup().'",';
- }
- else
- $opt.='\'\',';
- if($options->getActionUrl()!=='')
- {
- $flag=true;
- $this->_page->setCrossPagePostBack(true);
- $opt.='"'.$options->getActionUrl().'",';
- }
- else
- $opt.='null,';
- if($options->getTrackFocus())
- {
- $flag=true;
- $this->registerFocusScript();
- $opt.='true,';
- }
- else
- $opt.='false,';
- if($options->getClientSubmit())
- {
- $flag=true;
- $opt.='true';
- }
- else
- $opt.='false';
- if(!$flag)
- return '';
- $this->registerPostBackScript();
- if(($form=$this->_page->getForm())!==null)
- $formID=$form->getClientID();
- else
- throw new TConfigurationException('clientscriptmanager_form_required');
- $postback=self::POSTBACK_FUNC.'(\''.$formID.'\',\''.$control->getUniqueID().'\',\''.THttpUtility::quoteJavaScriptString($parameter).'\''.$opt.')';
- if($options && $options->getAutoPostBack())
- $postback='setTimeout(\''.THttpUtility::quoteJavaScriptString($postback).'\',0)';
- return $javascriptPrefix?'javascript:'.$postback:$postback;
- }*/
-
-}
-
-?> \ No newline at end of file
diff --git a/framework/Web/Javascripts/TJavascriptSerializer.php b/framework/Web/Javascripts/TJavascriptSerializer.php
deleted file mode 100644
index 65567762..00000000
--- a/framework/Web/Javascripts/TJavascriptSerializer.php
+++ /dev/null
@@ -1,141 +0,0 @@
-<?php
-
-/**
- * TJavascript class file. Javascript utilties, converts basic PHP types into
- * appropriate javascript types.
- *
- * Example:
- * <code>
- * $options['onLoading'] = "doit";
- * $options['onComplete'] = "more";
- * $js = new TJavascriptSerializer($options);
- * echo $js->toMap();
- * //expects the following javascript code
- * // {'onLoading':'doit','onComplete':'more'}
- * </code>
- *
- * For higher complexity data structures use TJSON to serialize and unserialize.
- *
- * Namespace: System.Web.UI
- *
- * @author Wei Zhuo<weizhuo[at]gmail[dot]com>
- * @version $Revision: 1.3 $ $Date: 2005/11/10 23:43:26 $
- * @package System.Web.UI
- */
-class TJavascriptSerializer
-{
- protected $data;
-
- /**
- * Serialize php data type into equivalent javascript type.
- * @param mixed data to seralize
- */
- public function __construct($data)
- {
- $this->data = $data;
- }
-
- /**
- * Converts data to javascript data string
- * @return string javascript equivalent
- */
- public function toJavascript($strict=false,$toMap=true)
- {
- $type = 'to_'.gettype($this->data);
- return $this->$type($strict,$toMap);
- }
-
- /**
- * Coverts PHP arrays (only the array values) into javascript array.
- * @param boolean if true empty string and empty array will be converted
- * @return string javascript array as string.
- */
- public function toList($strict=false)
- {
- return $this->to_array($strict);
- }
-
- /**
- * Coverts PHP arrays (both key and value) into javascript objects.
- * @param boolean if true empty string and empty array will be converted
- * @return string javascript object as string.
- */
- public function toMap($strict=false)
- {
- return $this->to_array($strict, true);
- }
-
- protected function to_array($strict=false,$toMap=false)
- {
- $results = array();
- foreach($this->data as $k => $v)
- {
- if($strict || (!$strict && $v !== '' && $v !== array()))
- {
- $serializer = new TJavascriptSerializer($v);
- $result = $serializer->toJavascript($strict,$toMap);
- $results[] = $toMap ? "'{$k}':$result" : $result;
- }
- }
- $brackets = $toMap ? array('{','}') : array('[',']');
- return $brackets[0].implode(',', $results).$brackets[1];
- }
-
- protected function to_object($strict=false,$toMap=false)
- {
- if($this->data instanceof TComponent)
- return $this->to_component($strict=false,$toMap=false);
-
- $serializer = new TJavascriptSerializer(get_object_vars($this->data));
- return $serializer->toMap($strict,$toMap);
- }
-
- protected function to_component($strict=false,$toMap=false)
- {
- throw new TException("component object too complex to serialize");
- }
-
- protected function to_boolean()
- {
- return $this->data ? 'true' : 'false';
- }
-
- protected function to_integer()
- {
- return "{$this->data}";
- }
-
- protected function to_double()
- {
- if($this->data === -INF)
- return 'Number.NEGATIVE_INFINITY';
- if($this->data === INF)
- return 'Number.POSITIVE_INFINITY';
- return "{$this->data}";
- }
-
- /**
- * Escapes string to javascript strings. If data to convert is string
- * and is bracketed with {} or [], it is assumed that the data
- * is already a javascript object or array and no further coversion is done.
- */
- protected function to_string()
- {
- //ignore strings surrounded with {} or [], assume they are list or map
- if(strlen($this->data)>1)
- {
- $first = $this->data[0]; $last = $this->data[strlen($this->data)-1];
- if($first == '[' && $last == ']' ||
- ($first == '{' && $last == '}'))
- return $this->data;
- }
- return "'".preg_replace("/\r\n/", '\n', addslashes($this->data))."'";
- }
-
- protected function to_null()
- {
- return 'null';
- }
-}
-
-?> \ No newline at end of file