@@ -1,15 +1,15 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * File Name: pradolite.php |
|
| 4 | - * Last Update: 2016/03/09 11:34:32 |
|
| 5 | - * Generated By: buildscripts/phpbuilder/build.php |
|
| 6 | - * |
|
| 7 | - * This file is used in lieu of prado.php to boost PRADO application performance. |
|
| 8 | - * It is generated by expanding prado.php with included files. |
|
| 9 | - * Comments and trace statements are stripped off. |
|
| 10 | - * |
|
| 11 | - * Do not modify this file manually. |
|
| 12 | - */ |
|
| 3 | + * File Name: pradolite.php |
|
| 4 | + * Last Update: 2016/03/09 11:34:32 |
|
| 5 | + * Generated By: buildscripts/phpbuilder/build.php |
|
| 6 | + * |
|
| 7 | + * This file is used in lieu of prado.php to boost PRADO application performance. |
|
| 8 | + * It is generated by expanding prado.php with included files. |
|
| 9 | + * Comments and trace statements are stripped off. |
|
| 10 | + * |
|
| 11 | + * Do not modify this file manually. |
|
| 12 | + */ |
|
| 13 | 13 | |
| 14 | 14 | if(!defined('PRADO_DIR')) |
| 15 | 15 | define('PRADO_DIR',dirname(__FILE__)); |
@@ -4170,10 +4170,10 @@ discard block |
||
| 4170 | 4170 | { |
| 4171 | 4171 | $value=TPropertyValue::ensureEnum($value,'THttpSessionCookieMode'); |
| 4172 | 4172 | if($value===THttpSessionCookieMode::None) |
| 4173 | - { |
|
| 4173 | + { |
|
| 4174 | 4174 | ini_set('session.use_cookies','0'); |
| 4175 | 4175 | ini_set('session.use_only_cookies','0'); |
| 4176 | - } |
|
| 4176 | + } |
|
| 4177 | 4177 | else if($value===THttpSessionCookieMode::Allow) |
| 4178 | 4178 | { |
| 4179 | 4179 | ini_set('session.use_cookies','1'); |
@@ -6837,77 +6837,77 @@ discard block |
||
| 6837 | 6837 | throw new TConfigurationException('templatecontrol_mastercontrol_required',get_class($this)); |
| 6838 | 6838 | parent::initRecursive($namingContainer); |
| 6839 | 6839 | } |
| 6840 | - public function tryToUpdateView($arObj, $throwExceptions = false) |
|
| 6841 | - { |
|
| 6842 | - $objAttrs = get_class_vars(get_class($arObj)); |
|
| 6843 | - foreach (array_keys($objAttrs) as $key) |
|
| 6844 | - { |
|
| 6845 | - try |
|
| 6846 | - { |
|
| 6847 | - if ($key != "RELATIONS") |
|
| 6848 | - { |
|
| 6849 | - $control = $this->{$key}; |
|
| 6850 | - if ($control instanceof TTextBox) |
|
| 6851 | - $control->Text = $arObj->{$key}; |
|
| 6852 | - elseif ($control instanceof TCheckBox) |
|
| 6853 | - $control->Checked = (boolean) $arObj->{$key}; |
|
| 6854 | - elseif ($control instanceof TDatePicker) |
|
| 6855 | - $control->Date = $arObj->{$key}; |
|
| 6856 | - } |
|
| 6857 | - else |
|
| 6858 | - { |
|
| 6859 | - foreach ($objAttrs["RELATIONS"] as $relKey => $relValues) |
|
| 6860 | - { |
|
| 6861 | - $relControl = $this->{$relKey}; |
|
| 6862 | - switch ($relValues[0]) |
|
| 6863 | - { |
|
| 6864 | - case TActiveRecord::BELONGS_TO: |
|
| 6865 | - case TActiveRecord::HAS_ONE: |
|
| 6866 | - $relControl->Text = $arObj->{$relKey}; |
|
| 6867 | - break; |
|
| 6868 | - case TActiveRecord::HAS_MANY: |
|
| 6869 | - if ($relControl instanceof TListControl) |
|
| 6870 | - { |
|
| 6871 | - $relControl->DataSource = $arObj->{$relKey}; |
|
| 6872 | - $relControl->dataBind(); |
|
| 6873 | - } |
|
| 6874 | - break; |
|
| 6875 | - } |
|
| 6876 | - } |
|
| 6877 | - break; |
|
| 6878 | - } |
|
| 6879 | - } |
|
| 6880 | - catch (Exception $ex) |
|
| 6881 | - { |
|
| 6882 | - if ($throwExceptions) |
|
| 6883 | - throw $ex; |
|
| 6884 | - } |
|
| 6885 | - } |
|
| 6886 | - } |
|
| 6887 | - public function tryToUpdateAR($arObj, $throwExceptions = false) |
|
| 6888 | - { |
|
| 6889 | - $objAttrs = get_class_vars(get_class($arObj)); |
|
| 6890 | - foreach (array_keys($objAttrs) as $key) |
|
| 6891 | - { |
|
| 6892 | - try |
|
| 6893 | - { |
|
| 6894 | - if ($key == "RELATIONS") |
|
| 6895 | - break; |
|
| 6896 | - $control = $this->{$key}; |
|
| 6897 | - if ($control instanceof TTextBox) |
|
| 6898 | - $arObj->{$key} = $control->Text; |
|
| 6899 | - elseif ($control instanceof TCheckBox) |
|
| 6900 | - $arObj->{$key} = $control->Checked; |
|
| 6901 | - elseif ($control instanceof TDatePicker) |
|
| 6902 | - $arObj->{$key} = $control->Date; |
|
| 6903 | - } |
|
| 6904 | - catch (Exception $ex) |
|
| 6905 | - { |
|
| 6906 | - if ($throwExceptions) |
|
| 6907 | - throw $ex; |
|
| 6908 | - } |
|
| 6909 | - } |
|
| 6910 | - } |
|
| 6840 | + public function tryToUpdateView($arObj, $throwExceptions = false) |
|
| 6841 | + { |
|
| 6842 | + $objAttrs = get_class_vars(get_class($arObj)); |
|
| 6843 | + foreach (array_keys($objAttrs) as $key) |
|
| 6844 | + { |
|
| 6845 | + try |
|
| 6846 | + { |
|
| 6847 | + if ($key != "RELATIONS") |
|
| 6848 | + { |
|
| 6849 | + $control = $this->{$key}; |
|
| 6850 | + if ($control instanceof TTextBox) |
|
| 6851 | + $control->Text = $arObj->{$key}; |
|
| 6852 | + elseif ($control instanceof TCheckBox) |
|
| 6853 | + $control->Checked = (boolean) $arObj->{$key}; |
|
| 6854 | + elseif ($control instanceof TDatePicker) |
|
| 6855 | + $control->Date = $arObj->{$key}; |
|
| 6856 | + } |
|
| 6857 | + else |
|
| 6858 | + { |
|
| 6859 | + foreach ($objAttrs["RELATIONS"] as $relKey => $relValues) |
|
| 6860 | + { |
|
| 6861 | + $relControl = $this->{$relKey}; |
|
| 6862 | + switch ($relValues[0]) |
|
| 6863 | + { |
|
| 6864 | + case TActiveRecord::BELONGS_TO: |
|
| 6865 | + case TActiveRecord::HAS_ONE: |
|
| 6866 | + $relControl->Text = $arObj->{$relKey}; |
|
| 6867 | + break; |
|
| 6868 | + case TActiveRecord::HAS_MANY: |
|
| 6869 | + if ($relControl instanceof TListControl) |
|
| 6870 | + { |
|
| 6871 | + $relControl->DataSource = $arObj->{$relKey}; |
|
| 6872 | + $relControl->dataBind(); |
|
| 6873 | + } |
|
| 6874 | + break; |
|
| 6875 | + } |
|
| 6876 | + } |
|
| 6877 | + break; |
|
| 6878 | + } |
|
| 6879 | + } |
|
| 6880 | + catch (Exception $ex) |
|
| 6881 | + { |
|
| 6882 | + if ($throwExceptions) |
|
| 6883 | + throw $ex; |
|
| 6884 | + } |
|
| 6885 | + } |
|
| 6886 | + } |
|
| 6887 | + public function tryToUpdateAR($arObj, $throwExceptions = false) |
|
| 6888 | + { |
|
| 6889 | + $objAttrs = get_class_vars(get_class($arObj)); |
|
| 6890 | + foreach (array_keys($objAttrs) as $key) |
|
| 6891 | + { |
|
| 6892 | + try |
|
| 6893 | + { |
|
| 6894 | + if ($key == "RELATIONS") |
|
| 6895 | + break; |
|
| 6896 | + $control = $this->{$key}; |
|
| 6897 | + if ($control instanceof TTextBox) |
|
| 6898 | + $arObj->{$key} = $control->Text; |
|
| 6899 | + elseif ($control instanceof TCheckBox) |
|
| 6900 | + $arObj->{$key} = $control->Checked; |
|
| 6901 | + elseif ($control instanceof TDatePicker) |
|
| 6902 | + $arObj->{$key} = $control->Date; |
|
| 6903 | + } |
|
| 6904 | + catch (Exception $ex) |
|
| 6905 | + { |
|
| 6906 | + if ($throwExceptions) |
|
| 6907 | + throw $ex; |
|
| 6908 | + } |
|
| 6909 | + } |
|
| 6910 | + } |
|
| 6911 | 6911 | } |
| 6912 | 6912 | class TForm extends TControl |
| 6913 | 6913 | { |
@@ -7569,13 +7569,13 @@ discard block |
||
| 7569 | 7569 | Prado::using('System.Web.UI.ActiveControls.TActivePageAdapter'); |
| 7570 | 7570 | Prado::using('System.Web.UI.JuiControls.TJuiControlOptions'); |
| 7571 | 7571 | $this->setAdapter(new TActivePageAdapter($this)); |
| 7572 | - $callbackEventParameter = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); |
|
| 7573 | - if(strlen($callbackEventParameter) > 0) |
|
| 7574 | - $this->_postData[TPage::FIELD_CALLBACK_PARAMETER]=TJavaScript::jsonDecode((string)$callbackEventParameter); |
|
| 7575 | - if (($g=$this->getApplication()->getGlobalization(false))!==null && |
|
| 7576 | - strtoupper($enc=$g->getCharset())!='UTF-8') |
|
| 7577 | - foreach ($this->_postData as $k=>$v) |
|
| 7578 | - $this->_postData[$k]=self::decodeUTF8($v, $enc); |
|
| 7572 | + $callbackEventParameter = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); |
|
| 7573 | + if(strlen($callbackEventParameter) > 0) |
|
| 7574 | + $this->_postData[TPage::FIELD_CALLBACK_PARAMETER]=TJavaScript::jsonDecode((string)$callbackEventParameter); |
|
| 7575 | + if (($g=$this->getApplication()->getGlobalization(false))!==null && |
|
| 7576 | + strtoupper($enc=$g->getCharset())!='UTF-8') |
|
| 7577 | + foreach ($this->_postData as $k=>$v) |
|
| 7578 | + $this->_postData[$k]=self::decodeUTF8($v, $enc); |
|
| 7579 | 7579 | $this->onPreInit(null); |
| 7580 | 7580 | $this->initRecursive(); |
| 7581 | 7581 | $this->onInitComplete(null); |
@@ -9160,15 +9160,15 @@ discard block |
||
| 9160 | 9160 | $component=new ReflectionClass('TComponent'); |
| 9161 | 9161 | $behaviors=$component->getStaticProperties(); |
| 9162 | 9162 | if(!isset($behaviors['_um'])) |
| 9163 | - return false; |
|
| 9163 | + return false; |
|
| 9164 | 9164 | foreach($behaviors['_um'] as $name=>$list) |
| 9165 | 9165 | { |
| 9166 | - if(strtolower($class->getShortName())!==$name && !$class->isSubclassOf($name)) continue; |
|
| 9167 | - foreach($list as $param) |
|
| 9168 | - { |
|
| 9169 | - if(method_exists($param->getBehavior(),$method)) |
|
| 9170 | - return true; |
|
| 9171 | - } |
|
| 9166 | + if(strtolower($class->getShortName())!==$name && !$class->isSubclassOf($name)) continue; |
|
| 9167 | + foreach($list as $param) |
|
| 9168 | + { |
|
| 9169 | + if(method_exists($param->getBehavior(),$method)) |
|
| 9170 | + return true; |
|
| 9171 | + } |
|
| 9172 | 9172 | } |
| 9173 | 9173 | return false; |
| 9174 | 9174 | } |
@@ -11,17 +11,17 @@ discard block |
||
| 11 | 11 | * Do not modify this file manually. |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if(!defined('PRADO_DIR')) |
|
| 15 | - define('PRADO_DIR',dirname(__FILE__)); |
|
| 16 | -if(!defined('PRADO_CHMOD')) |
|
| 17 | - define('PRADO_CHMOD',0777); |
|
| 14 | +if (!defined('PRADO_DIR')) |
|
| 15 | + define('PRADO_DIR', dirname(__FILE__)); |
|
| 16 | +if (!defined('PRADO_CHMOD')) |
|
| 17 | + define('PRADO_CHMOD', 0777); |
|
| 18 | 18 | class PradoBase |
| 19 | 19 | { |
| 20 | - const CLASS_FILE_EXT='.php'; |
|
| 21 | - private static $_aliases=array('System'=>PRADO_DIR); |
|
| 22 | - private static $_usings=array(); |
|
| 23 | - private static $_application=null; |
|
| 24 | - private static $_logger=null; |
|
| 20 | + const CLASS_FILE_EXT = '.php'; |
|
| 21 | + private static $_aliases = array('System'=>PRADO_DIR); |
|
| 22 | + private static $_usings = array(); |
|
| 23 | + private static $_application = null; |
|
| 24 | + private static $_logger = null; |
|
| 25 | 25 | protected static $classExists = array(); |
| 26 | 26 | public static function getVersion() |
| 27 | 27 | { |
@@ -29,48 +29,48 @@ discard block |
||
| 29 | 29 | } |
| 30 | 30 | public static function initErrorHandlers() |
| 31 | 31 | { |
| 32 | - set_error_handler(array('PradoBase','phpErrorHandler')); |
|
| 33 | - register_shutdown_function(array('PradoBase','phpFatalErrorHandler')); |
|
| 34 | - set_exception_handler(array('PradoBase','exceptionHandler')); |
|
| 32 | + set_error_handler(array('PradoBase', 'phpErrorHandler')); |
|
| 33 | + register_shutdown_function(array('PradoBase', 'phpFatalErrorHandler')); |
|
| 34 | + set_exception_handler(array('PradoBase', 'exceptionHandler')); |
|
| 35 | 35 | } |
| 36 | 36 | public static function autoload($className) |
| 37 | 37 | { |
| 38 | - include_once($className.self::CLASS_FILE_EXT); |
|
| 39 | - if(!class_exists($className,false) && !interface_exists($className,false)) |
|
| 38 | + include_once($className . self::CLASS_FILE_EXT); |
|
| 39 | + if (!class_exists($className, false) && !interface_exists($className, false)) |
|
| 40 | 40 | self::fatalError("Class file for '$className' cannot be found."); |
| 41 | 41 | } |
| 42 | - public static function poweredByPrado($logoType=0) |
|
| 42 | + public static function poweredByPrado($logoType = 0) |
|
| 43 | 43 | { |
| 44 | - $logoName=$logoType==1?'powered2':'powered'; |
|
| 45 | - if(self::$_application!==null) |
|
| 44 | + $logoName = $logoType == 1 ? 'powered2' : 'powered'; |
|
| 45 | + if (self::$_application !== null) |
|
| 46 | 46 | { |
| 47 | - $am=self::$_application->getAssetManager(); |
|
| 48 | - $url=$am->publishFilePath(self::getPathOfNamespace('System.'.$logoName,'.gif')); |
|
| 47 | + $am = self::$_application->getAssetManager(); |
|
| 48 | + $url = $am->publishFilePath(self::getPathOfNamespace('System.' . $logoName, '.gif')); |
|
| 49 | 49 | } |
| 50 | 50 | else |
| 51 | - $url='http://pradosoft.github.io/docs/'.$logoName.'.gif'; |
|
| 52 | - return '<a title="Powered by PRADO" href="https://github.com/pradosoft/prado" target="_blank"><img src="'.$url.'" style="border-width:0px;" alt="Powered by PRADO" /></a>'; |
|
| 51 | + $url = 'http://pradosoft.github.io/docs/' . $logoName . '.gif'; |
|
| 52 | + return '<a title="Powered by PRADO" href="https://github.com/pradosoft/prado" target="_blank"><img src="' . $url . '" style="border-width:0px;" alt="Powered by PRADO" /></a>'; |
|
| 53 | 53 | } |
| 54 | - public static function phpErrorHandler($errno,$errstr,$errfile,$errline) |
|
| 54 | + public static function phpErrorHandler($errno, $errstr, $errfile, $errline) |
|
| 55 | 55 | { |
| 56 | - if(error_reporting() & $errno) |
|
| 57 | - throw new TPhpErrorException($errno,$errstr,$errfile,$errline); |
|
| 56 | + if (error_reporting() & $errno) |
|
| 57 | + throw new TPhpErrorException($errno, $errstr, $errfile, $errline); |
|
| 58 | 58 | } |
| 59 | 59 | public static function phpFatalErrorHandler() |
| 60 | 60 | { |
| 61 | 61 | $error = error_get_last(); |
| 62 | - if($error && |
|
| 62 | + if ($error && |
|
| 63 | 63 | TPhpErrorException::isFatalError($error) && |
| 64 | 64 | error_reporting() & $error['type']) |
| 65 | 65 | { |
| 66 | - self::exceptionHandler(new TPhpErrorException($error['type'],$error['message'],$error['file'],$error['line'])); |
|
| 66 | + self::exceptionHandler(new TPhpErrorException($error['type'], $error['message'], $error['file'], $error['line'])); |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | public static function exceptionHandler($exception) |
| 70 | 70 | { |
| 71 | - if(self::$_application!==null && ($errorHandler=self::$_application->getErrorHandler())!==null) |
|
| 71 | + if (self::$_application !== null && ($errorHandler = self::$_application->getErrorHandler()) !== null) |
|
| 72 | 72 | { |
| 73 | - $errorHandler->handleError(null,$exception); |
|
| 73 | + $errorHandler->handleError(null, $exception); |
|
| 74 | 74 | } |
| 75 | 75 | else |
| 76 | 76 | { |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | } |
| 81 | 81 | public static function setApplication($application) |
| 82 | 82 | { |
| 83 | - if(self::$_application!==null && !defined('PRADO_TEST_RUN')) |
|
| 83 | + if (self::$_application !== null && !defined('PRADO_TEST_RUN')) |
|
| 84 | 84 | throw new TInvalidOperationException('prado_application_singleton_required'); |
| 85 | - self::$_application=$application; |
|
| 85 | + self::$_application = $application; |
|
| 86 | 86 | } |
| 87 | 87 | public static function getApplication() |
| 88 | 88 | { |
@@ -94,18 +94,18 @@ discard block |
||
| 94 | 94 | } |
| 95 | 95 | public static function createComponent($type) |
| 96 | 96 | { |
| 97 | - if(!isset(self::$classExists[$type])) |
|
| 97 | + if (!isset(self::$classExists[$type])) |
|
| 98 | 98 | self::$classExists[$type] = class_exists($type, false); |
| 99 | - if( !isset(self::$_usings[$type]) && !self::$classExists[$type]) { |
|
| 99 | + if (!isset(self::$_usings[$type]) && !self::$classExists[$type]) { |
|
| 100 | 100 | self::using($type); |
| 101 | 101 | self::$classExists[$type] = class_exists($type, false); |
| 102 | 102 | } |
| 103 | - if( ($pos = strrpos($type, '.')) !== false) |
|
| 104 | - $type = substr($type,$pos+1); |
|
| 105 | - if(($n=func_num_args())>1) |
|
| 103 | + if (($pos = strrpos($type, '.')) !== false) |
|
| 104 | + $type = substr($type, $pos + 1); |
|
| 105 | + if (($n = func_num_args()) > 1) |
|
| 106 | 106 | { |
| 107 | 107 | $args = func_get_args(); |
| 108 | - switch($n) { |
|
| 108 | + switch ($n) { |
|
| 109 | 109 | case 2: |
| 110 | 110 | return new $type($args[1]); |
| 111 | 111 | break; |
@@ -119,9 +119,9 @@ discard block |
||
| 119 | 119 | return new $type($args[1], $args[2], $args[3], $args[4]); |
| 120 | 120 | break; |
| 121 | 121 | default: |
| 122 | - $s='$args[1]'; |
|
| 123 | - for($i=2;$i<$n;++$i) |
|
| 124 | - $s.=",\$args[$i]"; |
|
| 122 | + $s = '$args[1]'; |
|
| 123 | + for ($i = 2; $i < $n; ++$i) |
|
| 124 | + $s .= ",\$args[$i]"; |
|
| 125 | 125 | eval("\$component=new $type($s);"); |
| 126 | 126 | return $component; |
| 127 | 127 | break; |
@@ -130,42 +130,42 @@ discard block |
||
| 130 | 130 | else |
| 131 | 131 | return new $type; |
| 132 | 132 | } |
| 133 | - public static function using($namespace,$checkClassExistence=true) |
|
| 133 | + public static function using($namespace, $checkClassExistence = true) |
|
| 134 | 134 | { |
| 135 | - if(isset(self::$_usings[$namespace]) || class_exists($namespace,false)) |
|
| 135 | + if (isset(self::$_usings[$namespace]) || class_exists($namespace, false)) |
|
| 136 | 136 | return; |
| 137 | - if(($pos=strrpos($namespace,'.'))===false) { |
|
| 137 | + if (($pos = strrpos($namespace, '.')) === false) { |
|
| 138 | 138 | try |
| 139 | 139 | { |
| 140 | - include_once($namespace.self::CLASS_FILE_EXT); |
|
| 140 | + include_once($namespace . self::CLASS_FILE_EXT); |
|
| 141 | 141 | } |
| 142 | - catch(Exception $e) |
|
| 142 | + catch (Exception $e) |
|
| 143 | 143 | { |
| 144 | - if($checkClassExistence && !class_exists($namespace,false)) |
|
| 145 | - throw new TInvalidOperationException('prado_component_unknown',$namespace,$e->getMessage()); |
|
| 144 | + if ($checkClassExistence && !class_exists($namespace, false)) |
|
| 145 | + throw new TInvalidOperationException('prado_component_unknown', $namespace, $e->getMessage()); |
|
| 146 | 146 | else |
| 147 | 147 | throw $e; |
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | - else if(($path=self::getPathOfNamespace($namespace,self::CLASS_FILE_EXT))!==null) |
|
| 150 | + else if (($path = self::getPathOfNamespace($namespace, self::CLASS_FILE_EXT)) !== null) |
|
| 151 | 151 | { |
| 152 | - $className=substr($namespace,$pos+1); |
|
| 153 | - if($className==='*') { |
|
| 154 | - self::$_usings[$namespace]=$path; |
|
| 155 | - set_include_path(get_include_path().PATH_SEPARATOR.$path); |
|
| 152 | + $className = substr($namespace, $pos + 1); |
|
| 153 | + if ($className === '*') { |
|
| 154 | + self::$_usings[$namespace] = $path; |
|
| 155 | + set_include_path(get_include_path() . PATH_SEPARATOR . $path); |
|
| 156 | 156 | } |
| 157 | - else { |
|
| 158 | - self::$_usings[$namespace]=$path; |
|
| 159 | - if(!$checkClassExistence || !class_exists($className,false)) |
|
| 157 | + else { |
|
| 158 | + self::$_usings[$namespace] = $path; |
|
| 159 | + if (!$checkClassExistence || !class_exists($className, false)) |
|
| 160 | 160 | { |
| 161 | 161 | try |
| 162 | 162 | { |
| 163 | 163 | include_once($path); |
| 164 | 164 | } |
| 165 | - catch(Exception $e) |
|
| 165 | + catch (Exception $e) |
|
| 166 | 166 | { |
| 167 | - if($checkClassExistence && !class_exists($className,false)) |
|
| 168 | - throw new TInvalidOperationException('prado_component_unknown',$className,$e->getMessage()); |
|
| 167 | + if ($checkClassExistence && !class_exists($className, false)) |
|
| 168 | + throw new TInvalidOperationException('prado_component_unknown', $className, $e->getMessage()); |
|
| 169 | 169 | else |
| 170 | 170 | throw $e; |
| 171 | 171 | } |
@@ -173,77 +173,77 @@ discard block |
||
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | else |
| 176 | - throw new TInvalidDataValueException('prado_using_invalid',$namespace); |
|
| 176 | + throw new TInvalidDataValueException('prado_using_invalid', $namespace); |
|
| 177 | 177 | } |
| 178 | - public static function getPathOfNamespace($namespace, $ext='') |
|
| 178 | + public static function getPathOfNamespace($namespace, $ext = '') |
|
| 179 | 179 | { |
| 180 | - if(self::CLASS_FILE_EXT === $ext || empty($ext)) |
|
| 180 | + if (self::CLASS_FILE_EXT === $ext || empty($ext)) |
|
| 181 | 181 | { |
| 182 | - if(isset(self::$_usings[$namespace])) |
|
| 182 | + if (isset(self::$_usings[$namespace])) |
|
| 183 | 183 | return self::$_usings[$namespace]; |
| 184 | - if(isset(self::$_aliases[$namespace])) |
|
| 184 | + if (isset(self::$_aliases[$namespace])) |
|
| 185 | 185 | return self::$_aliases[$namespace]; |
| 186 | 186 | } |
| 187 | - $segs = explode('.',$namespace); |
|
| 187 | + $segs = explode('.', $namespace); |
|
| 188 | 188 | $alias = array_shift($segs); |
| 189 | - if(null !== ($file = array_pop($segs)) && null !== ($root = self::getPathOfAlias($alias))) |
|
| 190 | - return rtrim($root.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR ,$segs),'/\\').(($file === '*') ? '' : DIRECTORY_SEPARATOR.$file.$ext); |
|
| 189 | + if (null !== ($file = array_pop($segs)) && null !== ($root = self::getPathOfAlias($alias))) |
|
| 190 | + return rtrim($root . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $segs), '/\\') . (($file === '*') ? '' : DIRECTORY_SEPARATOR . $file . $ext); |
|
| 191 | 191 | return null; |
| 192 | 192 | } |
| 193 | 193 | public static function getPathOfAlias($alias) |
| 194 | 194 | { |
| 195 | - return isset(self::$_aliases[$alias])?self::$_aliases[$alias]:null; |
|
| 195 | + return isset(self::$_aliases[$alias]) ? self::$_aliases[$alias] : null; |
|
| 196 | 196 | } |
| 197 | 197 | protected static function getPathAliases() |
| 198 | 198 | { |
| 199 | 199 | return self::$_aliases; |
| 200 | 200 | } |
| 201 | - public static function setPathOfAlias($alias,$path) |
|
| 201 | + public static function setPathOfAlias($alias, $path) |
|
| 202 | 202 | { |
| 203 | - if(isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN')) |
|
| 204 | - throw new TInvalidOperationException('prado_alias_redefined',$alias); |
|
| 205 | - else if(($rp=realpath($path))!==false && is_dir($rp)) |
|
| 203 | + if (isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN')) |
|
| 204 | + throw new TInvalidOperationException('prado_alias_redefined', $alias); |
|
| 205 | + else if (($rp = realpath($path)) !== false && is_dir($rp)) |
|
| 206 | 206 | { |
| 207 | - if(strpos($alias,'.')===false) |
|
| 208 | - self::$_aliases[$alias]=$rp; |
|
| 207 | + if (strpos($alias, '.') === false) |
|
| 208 | + self::$_aliases[$alias] = $rp; |
|
| 209 | 209 | else |
| 210 | - throw new TInvalidDataValueException('prado_aliasname_invalid',$alias); |
|
| 210 | + throw new TInvalidDataValueException('prado_aliasname_invalid', $alias); |
|
| 211 | 211 | } |
| 212 | 212 | else |
| 213 | - throw new TInvalidDataValueException('prado_alias_invalid',$alias,$path); |
|
| 213 | + throw new TInvalidDataValueException('prado_alias_invalid', $alias, $path); |
|
| 214 | 214 | } |
| 215 | 215 | public static function fatalError($msg) |
| 216 | 216 | { |
| 217 | 217 | echo '<h1>Fatal Error</h1>'; |
| 218 | - echo '<p>'.$msg.'</p>'; |
|
| 219 | - if(!function_exists('debug_backtrace')) |
|
| 218 | + echo '<p>' . $msg . '</p>'; |
|
| 219 | + if (!function_exists('debug_backtrace')) |
|
| 220 | 220 | return; |
| 221 | 221 | echo '<h2>Debug Backtrace</h2>'; |
| 222 | 222 | echo '<pre>'; |
| 223 | - $index=-1; |
|
| 224 | - foreach(debug_backtrace() as $t) |
|
| 223 | + $index = -1; |
|
| 224 | + foreach (debug_backtrace() as $t) |
|
| 225 | 225 | { |
| 226 | 226 | $index++; |
| 227 | - if($index==0) continue; |
|
| 228 | - echo '#'.$index.' '; |
|
| 229 | - if(isset($t['file'])) |
|
| 227 | + if ($index == 0) continue; |
|
| 228 | + echo '#' . $index . ' '; |
|
| 229 | + if (isset($t['file'])) |
|
| 230 | 230 | echo basename($t['file']) . ':' . $t['line']; |
| 231 | 231 | else |
| 232 | 232 | echo '<PHP inner-code>'; |
| 233 | 233 | echo ' -- '; |
| 234 | - if(isset($t['class'])) |
|
| 234 | + if (isset($t['class'])) |
|
| 235 | 235 | echo $t['class'] . $t['type']; |
| 236 | 236 | echo $t['function'] . '('; |
| 237 | - if(isset($t['args']) && sizeof($t['args']) > 0) |
|
| 237 | + if (isset($t['args']) && sizeof($t['args']) > 0) |
|
| 238 | 238 | { |
| 239 | - $count=0; |
|
| 240 | - foreach($t['args'] as $item) |
|
| 239 | + $count = 0; |
|
| 240 | + foreach ($t['args'] as $item) |
|
| 241 | 241 | { |
| 242 | - if(is_string($item)) |
|
| 242 | + if (is_string($item)) |
|
| 243 | 243 | { |
| 244 | - $str=htmlentities(str_replace("\r\n", "", $item), ENT_QUOTES); |
|
| 244 | + $str = htmlentities(str_replace("\r\n", "", $item), ENT_QUOTES); |
|
| 245 | 245 | if (strlen($item) > 70) |
| 246 | - echo "'". substr($str, 0, 70) . "...'"; |
|
| 246 | + echo "'" . substr($str, 0, 70) . "...'"; |
|
| 247 | 247 | else |
| 248 | 248 | echo "'" . $str . "'"; |
| 249 | 249 | } |
@@ -271,102 +271,102 @@ discard block |
||
| 271 | 271 | } |
| 272 | 272 | public static function getUserLanguages() |
| 273 | 273 | { |
| 274 | - static $languages=null; |
|
| 275 | - if($languages===null) |
|
| 274 | + static $languages = null; |
|
| 275 | + if ($languages === null) |
|
| 276 | 276 | { |
| 277 | - if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) |
|
| 278 | - $languages[0]='en'; |
|
| 277 | + if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) |
|
| 278 | + $languages[0] = 'en'; |
|
| 279 | 279 | else |
| 280 | 280 | { |
| 281 | - $languages=array(); |
|
| 282 | - foreach(explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language) |
|
| 281 | + $languages = array(); |
|
| 282 | + foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language) |
|
| 283 | 283 | { |
| 284 | - $array=explode(';q=',trim($language)); |
|
| 285 | - $languages[trim($array[0])]=isset($array[1])?(float)$array[1]:1.0; |
|
| 284 | + $array = explode(';q=', trim($language)); |
|
| 285 | + $languages[trim($array[0])] = isset($array[1]) ? (float) $array[1] : 1.0; |
|
| 286 | 286 | } |
| 287 | 287 | arsort($languages); |
| 288 | - $languages=array_keys($languages); |
|
| 289 | - if(empty($languages)) |
|
| 290 | - $languages[0]='en'; |
|
| 288 | + $languages = array_keys($languages); |
|
| 289 | + if (empty($languages)) |
|
| 290 | + $languages[0] = 'en'; |
|
| 291 | 291 | } |
| 292 | 292 | } |
| 293 | 293 | return $languages; |
| 294 | 294 | } |
| 295 | 295 | public static function getPreferredLanguage() |
| 296 | 296 | { |
| 297 | - static $language=null; |
|
| 298 | - if($language===null) |
|
| 297 | + static $language = null; |
|
| 298 | + if ($language === null) |
|
| 299 | 299 | { |
| 300 | - $langs=Prado::getUserLanguages(); |
|
| 301 | - $lang=explode('-',$langs[0]); |
|
| 302 | - if(empty($lang[0]) || !ctype_alpha($lang[0])) |
|
| 303 | - $language='en'; |
|
| 300 | + $langs = Prado::getUserLanguages(); |
|
| 301 | + $lang = explode('-', $langs[0]); |
|
| 302 | + if (empty($lang[0]) || !ctype_alpha($lang[0])) |
|
| 303 | + $language = 'en'; |
|
| 304 | 304 | else |
| 305 | - $language=$lang[0]; |
|
| 305 | + $language = $lang[0]; |
|
| 306 | 306 | } |
| 307 | 307 | return $language; |
| 308 | 308 | } |
| 309 | - public static function trace($msg,$category='Uncategorized',$ctl=null) |
|
| 309 | + public static function trace($msg, $category = 'Uncategorized', $ctl = null) |
|
| 310 | 310 | { |
| 311 | - if(self::$_application && self::$_application->getMode()===TApplicationMode::Performance) |
|
| 311 | + if (self::$_application && self::$_application->getMode() === TApplicationMode::Performance) |
|
| 312 | 312 | return; |
| 313 | - if(!self::$_application || self::$_application->getMode()===TApplicationMode::Debug) |
|
| 313 | + if (!self::$_application || self::$_application->getMode() === TApplicationMode::Debug) |
|
| 314 | 314 | { |
| 315 | - $trace=debug_backtrace(); |
|
| 316 | - if(isset($trace[0]['file']) && isset($trace[0]['line'])) |
|
| 317 | - $msg.=" (line {$trace[0]['line']}, {$trace[0]['file']})"; |
|
| 318 | - $level=TLogger::DEBUG; |
|
| 315 | + $trace = debug_backtrace(); |
|
| 316 | + if (isset($trace[0]['file']) && isset($trace[0]['line'])) |
|
| 317 | + $msg .= " (line {$trace[0]['line']}, {$trace[0]['file']})"; |
|
| 318 | + $level = TLogger::DEBUG; |
|
| 319 | 319 | } |
| 320 | 320 | else |
| 321 | - $level=TLogger::INFO; |
|
| 322 | - self::log($msg,$level,$category,$ctl); |
|
| 321 | + $level = TLogger::INFO; |
|
| 322 | + self::log($msg, $level, $category, $ctl); |
|
| 323 | 323 | } |
| 324 | - public static function log($msg,$level=TLogger::INFO,$category='Uncategorized',$ctl=null) |
|
| 324 | + public static function log($msg, $level = TLogger::INFO, $category = 'Uncategorized', $ctl = null) |
|
| 325 | 325 | { |
| 326 | - if(self::$_logger===null) |
|
| 327 | - self::$_logger=new TLogger; |
|
| 328 | - self::$_logger->log($msg,$level,$category,$ctl); |
|
| 326 | + if (self::$_logger === null) |
|
| 327 | + self::$_logger = new TLogger; |
|
| 328 | + self::$_logger->log($msg, $level, $category, $ctl); |
|
| 329 | 329 | } |
| 330 | 330 | public static function getLogger() |
| 331 | 331 | { |
| 332 | - if(self::$_logger===null) |
|
| 333 | - self::$_logger=new TLogger; |
|
| 332 | + if (self::$_logger === null) |
|
| 333 | + self::$_logger = new TLogger; |
|
| 334 | 334 | return self::$_logger; |
| 335 | 335 | } |
| 336 | - public static function varDump($var,$depth=10,$highlight=false) |
|
| 336 | + public static function varDump($var, $depth = 10, $highlight = false) |
|
| 337 | 337 | { |
| 338 | 338 | Prado::using('System.Util.TVarDumper'); |
| 339 | - return TVarDumper::dump($var,$depth,$highlight); |
|
| 339 | + return TVarDumper::dump($var, $depth, $highlight); |
|
| 340 | 340 | } |
| 341 | - public static function localize($text, $parameters=array(), $catalogue=null, $charset=null) |
|
| 341 | + public static function localize($text, $parameters = array(), $catalogue = null, $charset = null) |
|
| 342 | 342 | { |
| 343 | 343 | Prado::using('System.I18N.Translation'); |
| 344 | 344 | $app = Prado::getApplication()->getGlobalization(false); |
| 345 | 345 | $params = array(); |
| 346 | - foreach($parameters as $key => $value) |
|
| 347 | - $params['{'.$key.'}'] = $value; |
|
| 348 | - if($app===null || ($config = $app->getTranslationConfiguration())===null) |
|
| 346 | + foreach ($parameters as $key => $value) |
|
| 347 | + $params['{' . $key . '}'] = $value; |
|
| 348 | + if ($app === null || ($config = $app->getTranslationConfiguration()) === null) |
|
| 349 | 349 | return strtr($text, $params); |
| 350 | - if ($catalogue===null) |
|
| 351 | - $catalogue=isset($config['catalogue'])?$config['catalogue']:'messages'; |
|
| 350 | + if ($catalogue === null) |
|
| 351 | + $catalogue = isset($config['catalogue']) ? $config['catalogue'] : 'messages'; |
|
| 352 | 352 | Translation::init($catalogue); |
| 353 | - $appCharset = $app===null ? '' : $app->getCharset(); |
|
| 354 | - $defaultCharset = ($app===null) ? 'UTF-8' : $app->getDefaultCharset(); |
|
| 355 | - if(empty($charset)) $charset = $appCharset; |
|
| 356 | - if(empty($charset)) $charset = $defaultCharset; |
|
| 357 | - return Translation::formatter($catalogue)->format($text,$params,$catalogue,$charset); |
|
| 353 | + $appCharset = $app === null ? '' : $app->getCharset(); |
|
| 354 | + $defaultCharset = ($app === null) ? 'UTF-8' : $app->getDefaultCharset(); |
|
| 355 | + if (empty($charset)) $charset = $appCharset; |
|
| 356 | + if (empty($charset)) $charset = $defaultCharset; |
|
| 357 | + return Translation::formatter($catalogue)->format($text, $params, $catalogue, $charset); |
|
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | 360 | PradoBase::using('System.TComponent'); |
| 361 | 361 | PradoBase::using('System.Exceptions.TException'); |
| 362 | 362 | PradoBase::using('System.Util.TLogger'); |
| 363 | -if(!class_exists('Prado',false)) |
|
| 363 | +if (!class_exists('Prado', false)) |
|
| 364 | 364 | { |
| 365 | 365 | class Prado extends PradoBase |
| 366 | 366 | { |
| 367 | 367 | } |
| 368 | 368 | } |
| 369 | -spl_autoload_register(array('Prado','autoload')); |
|
| 369 | +spl_autoload_register(array('Prado', 'autoload')); |
|
| 370 | 370 | Prado::initErrorHandlers(); |
| 371 | 371 | interface IModule |
| 372 | 372 | { |
@@ -408,8 +408,8 @@ discard block |
||
| 408 | 408 | interface ICache |
| 409 | 409 | { |
| 410 | 410 | public function get($id); |
| 411 | - public function set($id,$value,$expire=0,$dependency=null); |
|
| 412 | - public function add($id,$value,$expire=0,$dependency=null); |
|
| 411 | + public function set($id, $value, $expire = 0, $dependency = null); |
|
| 412 | + public function add($id, $value, $expire = 0, $dependency = null); |
|
| 413 | 413 | public function delete($id); |
| 414 | 414 | public function flush(); |
| 415 | 415 | } |
@@ -470,15 +470,15 @@ discard block |
||
| 470 | 470 | { |
| 471 | 471 | return Prado::getApplication()->getUser(); |
| 472 | 472 | } |
| 473 | - public function publishAsset($assetPath,$className=null) |
|
| 473 | + public function publishAsset($assetPath, $className = null) |
|
| 474 | 474 | { |
| 475 | - if($className===null) |
|
| 476 | - $className=get_class($this); |
|
| 477 | - $class=new ReflectionClass($className); |
|
| 478 | - $fullPath=dirname($class->getFileName()).DIRECTORY_SEPARATOR.$assetPath; |
|
| 475 | + if ($className === null) |
|
| 476 | + $className = get_class($this); |
|
| 477 | + $class = new ReflectionClass($className); |
|
| 478 | + $fullPath = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . $assetPath; |
|
| 479 | 479 | return $this->publishFilePath($fullPath); |
| 480 | 480 | } |
| 481 | - public function publishFilePath($fullPath, $checkTimestamp=false) |
|
| 481 | + public function publishFilePath($fullPath, $checkTimestamp = false) |
|
| 482 | 482 | { |
| 483 | 483 | return Prado::getApplication()->getAssetManager()->publishFilePath($fullPath, $checkTimestamp); |
| 484 | 484 | } |
@@ -495,13 +495,13 @@ discard block |
||
| 495 | 495 | } |
| 496 | 496 | public function setID($value) |
| 497 | 497 | { |
| 498 | - $this->_id=$value; |
|
| 498 | + $this->_id = $value; |
|
| 499 | 499 | } |
| 500 | 500 | } |
| 501 | 501 | abstract class TService extends TApplicationComponent implements IService |
| 502 | 502 | { |
| 503 | 503 | private $_id; |
| 504 | - private $_enabled=true; |
|
| 504 | + private $_enabled = true; |
|
| 505 | 505 | public function init($config) |
| 506 | 506 | { |
| 507 | 507 | } |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | } |
| 512 | 512 | public function setID($value) |
| 513 | 513 | { |
| 514 | - $this->_id=$value; |
|
| 514 | + $this->_id = $value; |
|
| 515 | 515 | } |
| 516 | 516 | public function getEnabled() |
| 517 | 517 | { |
@@ -519,7 +519,7 @@ discard block |
||
| 519 | 519 | } |
| 520 | 520 | public function setEnabled($value) |
| 521 | 521 | { |
| 522 | - $this->_enabled=TPropertyValue::ensureBoolean($value); |
|
| 522 | + $this->_enabled = TPropertyValue::ensureBoolean($value); |
|
| 523 | 523 | } |
| 524 | 524 | public function run() |
| 525 | 525 | { |
@@ -527,244 +527,244 @@ discard block |
||
| 527 | 527 | } |
| 528 | 528 | class TErrorHandler extends TModule |
| 529 | 529 | { |
| 530 | - const ERROR_FILE_NAME='error'; |
|
| 531 | - const EXCEPTION_FILE_NAME='exception'; |
|
| 532 | - const SOURCE_LINES=12; |
|
| 533 | - private $_templatePath=null; |
|
| 530 | + const ERROR_FILE_NAME = 'error'; |
|
| 531 | + const EXCEPTION_FILE_NAME = 'exception'; |
|
| 532 | + const SOURCE_LINES = 12; |
|
| 533 | + private $_templatePath = null; |
|
| 534 | 534 | public function init($config) |
| 535 | 535 | { |
| 536 | 536 | $this->getApplication()->setErrorHandler($this); |
| 537 | 537 | } |
| 538 | 538 | public function getErrorTemplatePath() |
| 539 | 539 | { |
| 540 | - if($this->_templatePath===null) |
|
| 541 | - $this->_templatePath=Prado::getFrameworkPath().'/Exceptions/templates'; |
|
| 540 | + if ($this->_templatePath === null) |
|
| 541 | + $this->_templatePath = Prado::getFrameworkPath() . '/Exceptions/templates'; |
|
| 542 | 542 | return $this->_templatePath; |
| 543 | 543 | } |
| 544 | 544 | public function setErrorTemplatePath($value) |
| 545 | 545 | { |
| 546 | - if(($templatePath=Prado::getPathOfNamespace($value))!==null && is_dir($templatePath)) |
|
| 547 | - $this->_templatePath=$templatePath; |
|
| 546 | + if (($templatePath = Prado::getPathOfNamespace($value)) !== null && is_dir($templatePath)) |
|
| 547 | + $this->_templatePath = $templatePath; |
|
| 548 | 548 | else |
| 549 | - throw new TConfigurationException('errorhandler_errortemplatepath_invalid',$value); |
|
| 549 | + throw new TConfigurationException('errorhandler_errortemplatepath_invalid', $value); |
|
| 550 | 550 | } |
| 551 | - public function handleError($sender,$param) |
|
| 551 | + public function handleError($sender, $param) |
|
| 552 | 552 | { |
| 553 | - static $handling=false; |
|
| 553 | + static $handling = false; |
|
| 554 | 554 | restore_error_handler(); |
| 555 | 555 | restore_exception_handler(); |
| 556 | - if($handling) |
|
| 556 | + if ($handling) |
|
| 557 | 557 | $this->handleRecursiveError($param); |
| 558 | 558 | else |
| 559 | 559 | { |
| 560 | - $handling=true; |
|
| 561 | - if(($response=$this->getResponse())!==null) |
|
| 560 | + $handling = true; |
|
| 561 | + if (($response = $this->getResponse()) !== null) |
|
| 562 | 562 | $response->clear(); |
| 563 | - if(!headers_sent()) |
|
| 563 | + if (!headers_sent()) |
|
| 564 | 564 | header('Content-Type: text/html; charset=UTF-8'); |
| 565 | - if($param instanceof THttpException) |
|
| 566 | - $this->handleExternalError($param->getStatusCode(),$param); |
|
| 567 | - else if($this->getApplication()->getMode()===TApplicationMode::Debug) |
|
| 565 | + if ($param instanceof THttpException) |
|
| 566 | + $this->handleExternalError($param->getStatusCode(), $param); |
|
| 567 | + else if ($this->getApplication()->getMode() === TApplicationMode::Debug) |
|
| 568 | 568 | $this->displayException($param); |
| 569 | 569 | else |
| 570 | - $this->handleExternalError(500,$param); |
|
| 570 | + $this->handleExternalError(500, $param); |
|
| 571 | 571 | } |
| 572 | 572 | } |
| 573 | - protected static function hideSecurityRelated($value, $exception=null) |
|
| 573 | + protected static function hideSecurityRelated($value, $exception = null) |
|
| 574 | 574 | { |
| 575 | 575 | $aRpl = array(); |
| 576 | - if($exception !== null && $exception instanceof Exception) |
|
| 576 | + if ($exception !== null && $exception instanceof Exception) |
|
| 577 | 577 | { |
| 578 | 578 | $aTrace = $exception->getTrace(); |
| 579 | - foreach($aTrace as $item) |
|
| 579 | + foreach ($aTrace as $item) |
|
| 580 | 580 | { |
| 581 | - if(isset($item['file'])) |
|
| 581 | + if (isset($item['file'])) |
|
| 582 | 582 | $aRpl[dirname($item['file']) . DIRECTORY_SEPARATOR] = '<hidden>' . DIRECTORY_SEPARATOR; |
| 583 | 583 | } |
| 584 | 584 | } |
| 585 | 585 | $aRpl[$_SERVER['DOCUMENT_ROOT']] = '${DocumentRoot}'; |
| 586 | 586 | $aRpl[str_replace('/', DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT'])] = '${DocumentRoot}'; |
| 587 | 587 | $aRpl[PRADO_DIR . DIRECTORY_SEPARATOR] = '${PradoFramework}' . DIRECTORY_SEPARATOR; |
| 588 | - if(isset($aRpl[DIRECTORY_SEPARATOR])) unset($aRpl[DIRECTORY_SEPARATOR]); |
|
| 588 | + if (isset($aRpl[DIRECTORY_SEPARATOR])) unset($aRpl[DIRECTORY_SEPARATOR]); |
|
| 589 | 589 | $aRpl = array_reverse($aRpl, true); |
| 590 | 590 | return str_replace(array_keys($aRpl), $aRpl, $value); |
| 591 | 591 | } |
| 592 | - protected function handleExternalError($statusCode,$exception) |
|
| 592 | + protected function handleExternalError($statusCode, $exception) |
|
| 593 | 593 | { |
| 594 | - if(!($exception instanceof THttpException)) |
|
| 594 | + if (!($exception instanceof THttpException)) |
|
| 595 | 595 | error_log($exception->__toString()); |
| 596 | - $content=$this->getErrorTemplate($statusCode,$exception); |
|
| 597 | - $serverAdmin=isset($_SERVER['SERVER_ADMIN'])?$_SERVER['SERVER_ADMIN']:''; |
|
| 598 | - $isDebug = $this->getApplication()->getMode()===TApplicationMode::Debug; |
|
| 596 | + $content = $this->getErrorTemplate($statusCode, $exception); |
|
| 597 | + $serverAdmin = isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : ''; |
|
| 598 | + $isDebug = $this->getApplication()->getMode() === TApplicationMode::Debug; |
|
| 599 | 599 | $errorMessage = $exception->getMessage(); |
| 600 | - if($isDebug) |
|
| 601 | - $version=$_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.Prado::getVersion(); |
|
| 600 | + if ($isDebug) |
|
| 601 | + $version = $_SERVER['SERVER_SOFTWARE'] . ' <a href="https://github.com/pradosoft/prado">PRADO</a>/' . Prado::getVersion(); |
|
| 602 | 602 | else |
| 603 | 603 | { |
| 604 | - $version=''; |
|
| 604 | + $version = ''; |
|
| 605 | 605 | $errorMessage = self::hideSecurityRelated($errorMessage, $exception); |
| 606 | 606 | } |
| 607 | - $tokens=array( |
|
| 607 | + $tokens = array( |
|
| 608 | 608 | '%%StatusCode%%' => "$statusCode", |
| 609 | 609 | '%%ErrorMessage%%' => htmlspecialchars($errorMessage), |
| 610 | 610 | '%%ServerAdmin%%' => $serverAdmin, |
| 611 | 611 | '%%Version%%' => $version, |
| 612 | - '%%Time%%' => @strftime('%Y-%m-%d %H:%M',time()) |
|
| 612 | + '%%Time%%' => @strftime('%Y-%m-%d %H:%M', time()) |
|
| 613 | 613 | ); |
| 614 | 614 | $this->getApplication()->getResponse()->setStatusCode($statusCode, $isDebug ? $exception->getMessage() : null); |
| 615 | - echo strtr($content,$tokens); |
|
| 615 | + echo strtr($content, $tokens); |
|
| 616 | 616 | } |
| 617 | 617 | protected function handleRecursiveError($exception) |
| 618 | 618 | { |
| 619 | - if($this->getApplication()->getMode()===TApplicationMode::Debug) |
|
| 619 | + if ($this->getApplication()->getMode() === TApplicationMode::Debug) |
|
| 620 | 620 | { |
| 621 | 621 | echo "<html><head><title>Recursive Error</title></head>\n"; |
| 622 | 622 | echo "<body><h1>Recursive Error</h1>\n"; |
| 623 | - echo "<pre>".$exception->__toString()."</pre>\n"; |
|
| 623 | + echo "<pre>" . $exception->__toString() . "</pre>\n"; |
|
| 624 | 624 | echo "</body></html>"; |
| 625 | 625 | } |
| 626 | 626 | else |
| 627 | 627 | { |
| 628 | - error_log("Error happened while processing an existing error:\n".$exception->__toString()); |
|
| 628 | + error_log("Error happened while processing an existing error:\n" . $exception->__toString()); |
|
| 629 | 629 | header('HTTP/1.0 500 Internal Error'); |
| 630 | 630 | } |
| 631 | 631 | } |
| 632 | 632 | protected function displayException($exception) |
| 633 | 633 | { |
| 634 | - if(php_sapi_name()==='cli') |
|
| 634 | + if (php_sapi_name() === 'cli') |
|
| 635 | 635 | { |
| 636 | - echo $exception->getMessage()."\n"; |
|
| 636 | + echo $exception->getMessage() . "\n"; |
|
| 637 | 637 | echo $exception->getTraceAsString(); |
| 638 | 638 | return; |
| 639 | 639 | } |
| 640 | - if($exception instanceof TTemplateException) |
|
| 640 | + if ($exception instanceof TTemplateException) |
|
| 641 | 641 | { |
| 642 | - $fileName=$exception->getTemplateFile(); |
|
| 643 | - $lines=empty($fileName)?explode("\n",$exception->getTemplateSource()):@file($fileName); |
|
| 644 | - $source=$this->getSourceCode($lines,$exception->getLineNumber()); |
|
| 645 | - if($fileName==='') |
|
| 646 | - $fileName='---embedded template---'; |
|
| 647 | - $errorLine=$exception->getLineNumber(); |
|
| 642 | + $fileName = $exception->getTemplateFile(); |
|
| 643 | + $lines = empty($fileName) ? explode("\n", $exception->getTemplateSource()) : @file($fileName); |
|
| 644 | + $source = $this->getSourceCode($lines, $exception->getLineNumber()); |
|
| 645 | + if ($fileName === '') |
|
| 646 | + $fileName = '---embedded template---'; |
|
| 647 | + $errorLine = $exception->getLineNumber(); |
|
| 648 | 648 | } |
| 649 | 649 | else |
| 650 | 650 | { |
| 651 | - if(($trace=$this->getExactTrace($exception))!==null) |
|
| 651 | + if (($trace = $this->getExactTrace($exception)) !== null) |
|
| 652 | 652 | { |
| 653 | - $fileName=$trace['file']; |
|
| 654 | - $errorLine=$trace['line']; |
|
| 653 | + $fileName = $trace['file']; |
|
| 654 | + $errorLine = $trace['line']; |
|
| 655 | 655 | } |
| 656 | 656 | else |
| 657 | 657 | { |
| 658 | - $fileName=$exception->getFile(); |
|
| 659 | - $errorLine=$exception->getLine(); |
|
| 658 | + $fileName = $exception->getFile(); |
|
| 659 | + $errorLine = $exception->getLine(); |
|
| 660 | 660 | } |
| 661 | - $source=$this->getSourceCode(@file($fileName),$errorLine); |
|
| 661 | + $source = $this->getSourceCode(@file($fileName), $errorLine); |
|
| 662 | 662 | } |
| 663 | - if($this->getApplication()->getMode()===TApplicationMode::Debug) |
|
| 664 | - $version=$_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.Prado::getVersion(); |
|
| 663 | + if ($this->getApplication()->getMode() === TApplicationMode::Debug) |
|
| 664 | + $version = $_SERVER['SERVER_SOFTWARE'] . ' <a href="https://github.com/pradosoft/prado">PRADO</a>/' . Prado::getVersion(); |
|
| 665 | 665 | else |
| 666 | - $version=''; |
|
| 667 | - $tokens=array( |
|
| 666 | + $version = ''; |
|
| 667 | + $tokens = array( |
|
| 668 | 668 | '%%ErrorType%%' => get_class($exception), |
| 669 | 669 | '%%ErrorMessage%%' => $this->addLink(htmlspecialchars($exception->getMessage())), |
| 670 | - '%%SourceFile%%' => htmlspecialchars($fileName).' ('.$errorLine.')', |
|
| 670 | + '%%SourceFile%%' => htmlspecialchars($fileName) . ' (' . $errorLine . ')', |
|
| 671 | 671 | '%%SourceCode%%' => $source, |
| 672 | 672 | '%%StackTrace%%' => htmlspecialchars($exception->getTraceAsString()), |
| 673 | 673 | '%%Version%%' => $version, |
| 674 | - '%%Time%%' => @strftime('%Y-%m-%d %H:%M',time()) |
|
| 674 | + '%%Time%%' => @strftime('%Y-%m-%d %H:%M', time()) |
|
| 675 | 675 | ); |
| 676 | - $content=$this->getExceptionTemplate($exception); |
|
| 677 | - echo strtr($content,$tokens); |
|
| 676 | + $content = $this->getExceptionTemplate($exception); |
|
| 677 | + echo strtr($content, $tokens); |
|
| 678 | 678 | } |
| 679 | 679 | protected function getExceptionTemplate($exception) |
| 680 | 680 | { |
| 681 | - $lang=Prado::getPreferredLanguage(); |
|
| 682 | - $exceptionFile=Prado::getFrameworkPath().'/Exceptions/templates/'.self::EXCEPTION_FILE_NAME.'-'.$lang.'.html'; |
|
| 683 | - if(!is_file($exceptionFile)) |
|
| 684 | - $exceptionFile=Prado::getFrameworkPath().'/Exceptions/templates/'.self::EXCEPTION_FILE_NAME.'.html'; |
|
| 685 | - if(($content=@file_get_contents($exceptionFile))===false) |
|
| 681 | + $lang = Prado::getPreferredLanguage(); |
|
| 682 | + $exceptionFile = Prado::getFrameworkPath() . '/Exceptions/templates/' . self::EXCEPTION_FILE_NAME . '-' . $lang . '.html'; |
|
| 683 | + if (!is_file($exceptionFile)) |
|
| 684 | + $exceptionFile = Prado::getFrameworkPath() . '/Exceptions/templates/' . self::EXCEPTION_FILE_NAME . '.html'; |
|
| 685 | + if (($content = @file_get_contents($exceptionFile)) === false) |
|
| 686 | 686 | die("Unable to open exception template file '$exceptionFile'."); |
| 687 | 687 | return $content; |
| 688 | 688 | } |
| 689 | - protected function getErrorTemplate($statusCode,$exception) |
|
| 689 | + protected function getErrorTemplate($statusCode, $exception) |
|
| 690 | 690 | { |
| 691 | - $base=$this->getErrorTemplatePath().DIRECTORY_SEPARATOR.self::ERROR_FILE_NAME; |
|
| 692 | - $lang=Prado::getPreferredLanguage(); |
|
| 693 | - if(is_file("$base$statusCode-$lang.html")) |
|
| 694 | - $errorFile="$base$statusCode-$lang.html"; |
|
| 695 | - else if(is_file("$base$statusCode.html")) |
|
| 696 | - $errorFile="$base$statusCode.html"; |
|
| 697 | - else if(is_file("$base-$lang.html")) |
|
| 698 | - $errorFile="$base-$lang.html"; |
|
| 691 | + $base = $this->getErrorTemplatePath() . DIRECTORY_SEPARATOR . self::ERROR_FILE_NAME; |
|
| 692 | + $lang = Prado::getPreferredLanguage(); |
|
| 693 | + if (is_file("$base$statusCode-$lang.html")) |
|
| 694 | + $errorFile = "$base$statusCode-$lang.html"; |
|
| 695 | + else if (is_file("$base$statusCode.html")) |
|
| 696 | + $errorFile = "$base$statusCode.html"; |
|
| 697 | + else if (is_file("$base-$lang.html")) |
|
| 698 | + $errorFile = "$base-$lang.html"; |
|
| 699 | 699 | else |
| 700 | - $errorFile="$base.html"; |
|
| 701 | - if(($content=@file_get_contents($errorFile))===false) |
|
| 700 | + $errorFile = "$base.html"; |
|
| 701 | + if (($content = @file_get_contents($errorFile)) === false) |
|
| 702 | 702 | die("Unable to open error template file '$errorFile'."); |
| 703 | 703 | return $content; |
| 704 | 704 | } |
| 705 | 705 | private function getExactTrace($exception) |
| 706 | 706 | { |
| 707 | - $trace=$exception->getTrace(); |
|
| 708 | - $result=null; |
|
| 709 | - if($exception instanceof TPhpErrorException) |
|
| 707 | + $trace = $exception->getTrace(); |
|
| 708 | + $result = null; |
|
| 709 | + if ($exception instanceof TPhpErrorException) |
|
| 710 | 710 | { |
| 711 | - if(isset($trace[0]['file'])) |
|
| 712 | - $result=$trace[0]; |
|
| 713 | - elseif(isset($trace[1])) |
|
| 714 | - $result=$trace[1]; |
|
| 711 | + if (isset($trace[0]['file'])) |
|
| 712 | + $result = $trace[0]; |
|
| 713 | + elseif (isset($trace[1])) |
|
| 714 | + $result = $trace[1]; |
|
| 715 | 715 | } |
| 716 | - else if($exception instanceof TInvalidOperationException) |
|
| 716 | + else if ($exception instanceof TInvalidOperationException) |
|
| 717 | 717 | { |
| 718 | - if(($result=$this->getPropertyAccessTrace($trace,'__get'))===null) |
|
| 719 | - $result=$this->getPropertyAccessTrace($trace,'__set'); |
|
| 718 | + if (($result = $this->getPropertyAccessTrace($trace, '__get')) === null) |
|
| 719 | + $result = $this->getPropertyAccessTrace($trace, '__set'); |
|
| 720 | 720 | } |
| 721 | - if($result!==null && strpos($result['file'],': eval()\'d code')!==false) |
|
| 721 | + if ($result !== null && strpos($result['file'], ': eval()\'d code') !== false) |
|
| 722 | 722 | return null; |
| 723 | 723 | return $result; |
| 724 | 724 | } |
| 725 | - private function getPropertyAccessTrace($trace,$pattern) |
|
| 725 | + private function getPropertyAccessTrace($trace, $pattern) |
|
| 726 | 726 | { |
| 727 | - $result=null; |
|
| 728 | - foreach($trace as $t) |
|
| 727 | + $result = null; |
|
| 728 | + foreach ($trace as $t) |
|
| 729 | 729 | { |
| 730 | - if(isset($t['function']) && $t['function']===$pattern) |
|
| 731 | - $result=$t; |
|
| 730 | + if (isset($t['function']) && $t['function'] === $pattern) |
|
| 731 | + $result = $t; |
|
| 732 | 732 | else |
| 733 | 733 | break; |
| 734 | 734 | } |
| 735 | 735 | return $result; |
| 736 | 736 | } |
| 737 | - private function getSourceCode($lines,$errorLine) |
|
| 737 | + private function getSourceCode($lines, $errorLine) |
|
| 738 | 738 | { |
| 739 | - $beginLine=$errorLine-self::SOURCE_LINES>=0?$errorLine-self::SOURCE_LINES:0; |
|
| 740 | - $endLine=$errorLine+self::SOURCE_LINES<=count($lines)?$errorLine+self::SOURCE_LINES:count($lines); |
|
| 741 | - $source=''; |
|
| 742 | - for($i=$beginLine;$i<$endLine;++$i) |
|
| 739 | + $beginLine = $errorLine - self::SOURCE_LINES >= 0 ? $errorLine - self::SOURCE_LINES : 0; |
|
| 740 | + $endLine = $errorLine + self::SOURCE_LINES <= count($lines) ? $errorLine + self::SOURCE_LINES : count($lines); |
|
| 741 | + $source = ''; |
|
| 742 | + for ($i = $beginLine; $i < $endLine; ++$i) |
|
| 743 | 743 | { |
| 744 | - if($i===$errorLine-1) |
|
| 744 | + if ($i === $errorLine - 1) |
|
| 745 | 745 | { |
| 746 | - $line=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",' ',$lines[$i]))); |
|
| 747 | - $source.="<div class=\"error\">".$line."</div>"; |
|
| 746 | + $line = htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", ' ', $lines[$i]))); |
|
| 747 | + $source .= "<div class=\"error\">" . $line . "</div>"; |
|
| 748 | 748 | } |
| 749 | 749 | else |
| 750 | - $source.=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",' ',$lines[$i]))); |
|
| 750 | + $source .= htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", ' ', $lines[$i]))); |
|
| 751 | 751 | } |
| 752 | 752 | return $source; |
| 753 | 753 | } |
| 754 | 754 | private function addLink($message) |
| 755 | 755 | { |
| 756 | - $baseUrl='http://pradosoft.github.io/docs/manual/class-'; |
|
| 757 | - return preg_replace('/\b(T[A-Z]\w+)\b/',"<a href=\"$baseUrl\${1}\" target=\"_blank\">\${1}</a>",$message); |
|
| 756 | + $baseUrl = 'http://pradosoft.github.io/docs/manual/class-'; |
|
| 757 | + return preg_replace('/\b(T[A-Z]\w+)\b/', "<a href=\"$baseUrl\${1}\" target=\"_blank\">\${1}</a>", $message); |
|
| 758 | 758 | } |
| 759 | 759 | } |
| 760 | -class TList extends TComponent implements IteratorAggregate,ArrayAccess,Countable |
|
| 760 | +class TList extends TComponent implements IteratorAggregate, ArrayAccess, Countable |
|
| 761 | 761 | { |
| 762 | - private $_d=array(); |
|
| 763 | - private $_c=0; |
|
| 764 | - private $_r=false; |
|
| 765 | - public function __construct($data=null,$readOnly=false) |
|
| 762 | + private $_d = array(); |
|
| 763 | + private $_c = 0; |
|
| 764 | + private $_r = false; |
|
| 765 | + public function __construct($data = null, $readOnly = false) |
|
| 766 | 766 | { |
| 767 | - if($data!==null) |
|
| 767 | + if ($data !== null) |
|
| 768 | 768 | $this->copyFrom($data); |
| 769 | 769 | $this->setReadOnly($readOnly); |
| 770 | 770 | } |
@@ -774,11 +774,11 @@ discard block |
||
| 774 | 774 | } |
| 775 | 775 | protected function setReadOnly($value) |
| 776 | 776 | { |
| 777 | - $this->_r=TPropertyValue::ensureBoolean($value); |
|
| 777 | + $this->_r = TPropertyValue::ensureBoolean($value); |
|
| 778 | 778 | } |
| 779 | 779 | public function getIterator() |
| 780 | 780 | { |
| 781 | - return new ArrayIterator( $this->_d ); |
|
| 781 | + return new ArrayIterator($this->_d); |
|
| 782 | 782 | } |
| 783 | 783 | public function count() |
| 784 | 784 | { |
@@ -790,38 +790,38 @@ discard block |
||
| 790 | 790 | } |
| 791 | 791 | public function itemAt($index) |
| 792 | 792 | { |
| 793 | - if($index>=0 && $index<$this->_c) |
|
| 793 | + if ($index >= 0 && $index < $this->_c) |
|
| 794 | 794 | return $this->_d[$index]; |
| 795 | 795 | else |
| 796 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
| 796 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
| 797 | 797 | } |
| 798 | 798 | public function add($item) |
| 799 | 799 | { |
| 800 | - $this->insertAt($this->_c,$item); |
|
| 801 | - return $this->_c-1; |
|
| 800 | + $this->insertAt($this->_c, $item); |
|
| 801 | + return $this->_c - 1; |
|
| 802 | 802 | } |
| 803 | - public function insertAt($index,$item) |
|
| 803 | + public function insertAt($index, $item) |
|
| 804 | 804 | { |
| 805 | - if(!$this->_r) |
|
| 805 | + if (!$this->_r) |
|
| 806 | 806 | { |
| 807 | - if($index===$this->_c) |
|
| 808 | - $this->_d[$this->_c++]=$item; |
|
| 809 | - else if($index>=0 && $index<$this->_c) |
|
| 807 | + if ($index === $this->_c) |
|
| 808 | + $this->_d[$this->_c++] = $item; |
|
| 809 | + else if ($index >= 0 && $index < $this->_c) |
|
| 810 | 810 | { |
| 811 | - array_splice($this->_d,$index,0,array($item)); |
|
| 811 | + array_splice($this->_d, $index, 0, array($item)); |
|
| 812 | 812 | $this->_c++; |
| 813 | 813 | } |
| 814 | 814 | else |
| 815 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
| 815 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
| 816 | 816 | } |
| 817 | 817 | else |
| 818 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 818 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
| 819 | 819 | } |
| 820 | 820 | public function remove($item) |
| 821 | 821 | { |
| 822 | - if(!$this->_r) |
|
| 822 | + if (!$this->_r) |
|
| 823 | 823 | { |
| 824 | - if(($index=$this->indexOf($item))>=0) |
|
| 824 | + if (($index = $this->indexOf($item)) >= 0) |
|
| 825 | 825 | { |
| 826 | 826 | $this->removeAt($index); |
| 827 | 827 | return $index; |
@@ -830,69 +830,69 @@ discard block |
||
| 830 | 830 | throw new TInvalidDataValueException('list_item_inexistent'); |
| 831 | 831 | } |
| 832 | 832 | else |
| 833 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 833 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
| 834 | 834 | } |
| 835 | 835 | public function removeAt($index) |
| 836 | 836 | { |
| 837 | - if(!$this->_r) |
|
| 837 | + if (!$this->_r) |
|
| 838 | 838 | { |
| 839 | - if($index>=0 && $index<$this->_c) |
|
| 839 | + if ($index >= 0 && $index < $this->_c) |
|
| 840 | 840 | { |
| 841 | 841 | $this->_c--; |
| 842 | - if($index===$this->_c) |
|
| 842 | + if ($index === $this->_c) |
|
| 843 | 843 | return array_pop($this->_d); |
| 844 | 844 | else |
| 845 | 845 | { |
| 846 | - $item=$this->_d[$index]; |
|
| 847 | - array_splice($this->_d,$index,1); |
|
| 846 | + $item = $this->_d[$index]; |
|
| 847 | + array_splice($this->_d, $index, 1); |
|
| 848 | 848 | return $item; |
| 849 | 849 | } |
| 850 | 850 | } |
| 851 | 851 | else |
| 852 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
| 852 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
| 853 | 853 | } |
| 854 | 854 | else |
| 855 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 855 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
| 856 | 856 | } |
| 857 | 857 | public function clear() |
| 858 | 858 | { |
| 859 | - for($i=$this->_c-1;$i>=0;--$i) |
|
| 859 | + for ($i = $this->_c - 1; $i >= 0; --$i) |
|
| 860 | 860 | $this->removeAt($i); |
| 861 | 861 | } |
| 862 | 862 | public function contains($item) |
| 863 | 863 | { |
| 864 | - return $this->indexOf($item)>=0; |
|
| 864 | + return $this->indexOf($item) >= 0; |
|
| 865 | 865 | } |
| 866 | 866 | public function indexOf($item) |
| 867 | 867 | { |
| 868 | - if(($index=array_search($item,$this->_d,true))===false) |
|
| 868 | + if (($index = array_search($item, $this->_d, true)) === false) |
|
| 869 | 869 | return -1; |
| 870 | 870 | else |
| 871 | 871 | return $index; |
| 872 | 872 | } |
| 873 | 873 | public function insertBefore($baseitem, $item) |
| 874 | 874 | { |
| 875 | - if(!$this->_r) |
|
| 875 | + if (!$this->_r) |
|
| 876 | 876 | { |
| 877 | - if(($index = $this->indexOf($baseitem)) == -1) |
|
| 877 | + if (($index = $this->indexOf($baseitem)) == -1) |
|
| 878 | 878 | throw new TInvalidDataValueException('list_item_inexistent'); |
| 879 | 879 | $this->insertAt($index, $item); |
| 880 | 880 | return $index; |
| 881 | 881 | } |
| 882 | 882 | else |
| 883 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 883 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
| 884 | 884 | } |
| 885 | 885 | public function insertAfter($baseitem, $item) |
| 886 | 886 | { |
| 887 | - if(!$this->_r) |
|
| 887 | + if (!$this->_r) |
|
| 888 | 888 | { |
| 889 | - if(($index = $this->indexOf($baseitem)) == -1) |
|
| 889 | + if (($index = $this->indexOf($baseitem)) == -1) |
|
| 890 | 890 | throw new TInvalidDataValueException('list_item_inexistent'); |
| 891 | 891 | $this->insertAt($index + 1, $item); |
| 892 | 892 | return $index + 1; |
| 893 | 893 | } |
| 894 | 894 | else |
| 895 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 895 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
| 896 | 896 | } |
| 897 | 897 | public function toArray() |
| 898 | 898 | { |
@@ -900,42 +900,42 @@ discard block |
||
| 900 | 900 | } |
| 901 | 901 | public function copyFrom($data) |
| 902 | 902 | { |
| 903 | - if(is_array($data) || ($data instanceof Traversable)) |
|
| 903 | + if (is_array($data) || ($data instanceof Traversable)) |
|
| 904 | 904 | { |
| 905 | - if($this->_c>0) |
|
| 905 | + if ($this->_c > 0) |
|
| 906 | 906 | $this->clear(); |
| 907 | - foreach($data as $item) |
|
| 907 | + foreach ($data as $item) |
|
| 908 | 908 | $this->add($item); |
| 909 | 909 | } |
| 910 | - else if($data!==null) |
|
| 910 | + else if ($data !== null) |
|
| 911 | 911 | throw new TInvalidDataTypeException('list_data_not_iterable'); |
| 912 | 912 | } |
| 913 | 913 | public function mergeWith($data) |
| 914 | 914 | { |
| 915 | - if(is_array($data) || ($data instanceof Traversable)) |
|
| 915 | + if (is_array($data) || ($data instanceof Traversable)) |
|
| 916 | 916 | { |
| 917 | - foreach($data as $item) |
|
| 917 | + foreach ($data as $item) |
|
| 918 | 918 | $this->add($item); |
| 919 | 919 | } |
| 920 | - else if($data!==null) |
|
| 920 | + else if ($data !== null) |
|
| 921 | 921 | throw new TInvalidDataTypeException('list_data_not_iterable'); |
| 922 | 922 | } |
| 923 | 923 | public function offsetExists($offset) |
| 924 | 924 | { |
| 925 | - return ($offset>=0 && $offset<$this->_c); |
|
| 925 | + return ($offset >= 0 && $offset < $this->_c); |
|
| 926 | 926 | } |
| 927 | 927 | public function offsetGet($offset) |
| 928 | 928 | { |
| 929 | 929 | return $this->itemAt($offset); |
| 930 | 930 | } |
| 931 | - public function offsetSet($offset,$item) |
|
| 931 | + public function offsetSet($offset, $item) |
|
| 932 | 932 | { |
| 933 | - if($offset===null || $offset===$this->_c) |
|
| 934 | - $this->insertAt($this->_c,$item); |
|
| 933 | + if ($offset === null || $offset === $this->_c) |
|
| 934 | + $this->insertAt($this->_c, $item); |
|
| 935 | 935 | else |
| 936 | 936 | { |
| 937 | 937 | $this->removeAt($offset); |
| 938 | - $this->insertAt($offset,$item); |
|
| 938 | + $this->insertAt($offset, $item); |
|
| 939 | 939 | } |
| 940 | 940 | } |
| 941 | 941 | public function offsetUnset($offset) |
@@ -948,18 +948,18 @@ discard block |
||
| 948 | 948 | } |
| 949 | 949 | abstract class TCache extends TModule implements ICache, ArrayAccess |
| 950 | 950 | { |
| 951 | - private $_prefix=null; |
|
| 952 | - private $_primary=true; |
|
| 951 | + private $_prefix = null; |
|
| 952 | + private $_primary = true; |
|
| 953 | 953 | public function init($config) |
| 954 | 954 | { |
| 955 | - if($this->_prefix===null) |
|
| 956 | - $this->_prefix=$this->getApplication()->getUniqueID(); |
|
| 957 | - if($this->_primary) |
|
| 955 | + if ($this->_prefix === null) |
|
| 956 | + $this->_prefix = $this->getApplication()->getUniqueID(); |
|
| 957 | + if ($this->_primary) |
|
| 958 | 958 | { |
| 959 | - if($this->getApplication()->getCache()===null) |
|
| 959 | + if ($this->getApplication()->getCache() === null) |
|
| 960 | 960 | $this->getApplication()->setCache($this); |
| 961 | 961 | else |
| 962 | - throw new TConfigurationException('cache_primary_duplicated',get_class($this)); |
|
| 962 | + throw new TConfigurationException('cache_primary_duplicated', get_class($this)); |
|
| 963 | 963 | } |
| 964 | 964 | } |
| 965 | 965 | public function getPrimaryCache() |
@@ -968,7 +968,7 @@ discard block |
||
| 968 | 968 | } |
| 969 | 969 | public function setPrimaryCache($value) |
| 970 | 970 | { |
| 971 | - $this->_primary=TPropertyValue::ensureBoolean($value); |
|
| 971 | + $this->_primary = TPropertyValue::ensureBoolean($value); |
|
| 972 | 972 | } |
| 973 | 973 | public function getKeyPrefix() |
| 974 | 974 | { |
@@ -976,39 +976,39 @@ discard block |
||
| 976 | 976 | } |
| 977 | 977 | public function setKeyPrefix($value) |
| 978 | 978 | { |
| 979 | - $this->_prefix=$value; |
|
| 979 | + $this->_prefix = $value; |
|
| 980 | 980 | } |
| 981 | 981 | protected function generateUniqueKey($key) |
| 982 | 982 | { |
| 983 | - return md5($this->_prefix.$key); |
|
| 983 | + return md5($this->_prefix . $key); |
|
| 984 | 984 | } |
| 985 | 985 | public function get($id) |
| 986 | 986 | { |
| 987 | - if(($data=$this->getValue($this->generateUniqueKey($id)))!==false) |
|
| 987 | + if (($data = $this->getValue($this->generateUniqueKey($id))) !== false) |
|
| 988 | 988 | { |
| 989 | - if(!is_array($data)) |
|
| 989 | + if (!is_array($data)) |
|
| 990 | 990 | return false; |
| 991 | - if(!($data[1] instanceof ICacheDependency) || !$data[1]->getHasChanged()) |
|
| 991 | + if (!($data[1] instanceof ICacheDependency) || !$data[1]->getHasChanged()) |
|
| 992 | 992 | return $data[0]; |
| 993 | 993 | } |
| 994 | 994 | return false; |
| 995 | 995 | } |
| 996 | - public function set($id,$value,$expire=0,$dependency=null) |
|
| 996 | + public function set($id, $value, $expire = 0, $dependency = null) |
|
| 997 | 997 | { |
| 998 | - if(empty($value) && $expire === 0) |
|
| 998 | + if (empty($value) && $expire === 0) |
|
| 999 | 999 | $this->delete($id); |
| 1000 | 1000 | else |
| 1001 | 1001 | { |
| 1002 | - $data=array($value,$dependency); |
|
| 1003 | - return $this->setValue($this->generateUniqueKey($id),$data,$expire); |
|
| 1002 | + $data = array($value, $dependency); |
|
| 1003 | + return $this->setValue($this->generateUniqueKey($id), $data, $expire); |
|
| 1004 | 1004 | } |
| 1005 | 1005 | } |
| 1006 | - public function add($id,$value,$expire=0,$dependency=null) |
|
| 1006 | + public function add($id, $value, $expire = 0, $dependency = null) |
|
| 1007 | 1007 | { |
| 1008 | - if(empty($value) && $expire === 0) |
|
| 1008 | + if (empty($value) && $expire === 0) |
|
| 1009 | 1009 | return false; |
| 1010 | - $data=array($value,$dependency); |
|
| 1011 | - return $this->addValue($this->generateUniqueKey($id),$data,$expire); |
|
| 1010 | + $data = array($value, $dependency); |
|
| 1011 | + return $this->addValue($this->generateUniqueKey($id), $data, $expire); |
|
| 1012 | 1012 | } |
| 1013 | 1013 | public function delete($id) |
| 1014 | 1014 | { |
@@ -1019,8 +1019,8 @@ discard block |
||
| 1019 | 1019 | throw new TNotSupportedException('cache_flush_unsupported'); |
| 1020 | 1020 | } |
| 1021 | 1021 | abstract protected function getValue($key); |
| 1022 | - abstract protected function setValue($key,$value,$expire); |
|
| 1023 | - abstract protected function addValue($key,$value,$expire); |
|
| 1022 | + abstract protected function setValue($key, $value, $expire); |
|
| 1023 | + abstract protected function addValue($key, $value, $expire); |
|
| 1024 | 1024 | abstract protected function deleteValue($key); |
| 1025 | 1025 | public function offsetExists($id) |
| 1026 | 1026 | { |
@@ -1056,8 +1056,8 @@ discard block |
||
| 1056 | 1056 | } |
| 1057 | 1057 | public function setFileName($value) |
| 1058 | 1058 | { |
| 1059 | - $this->_fileName=$value; |
|
| 1060 | - $this->_timestamp=@filemtime($value); |
|
| 1059 | + $this->_fileName = $value; |
|
| 1060 | + $this->_timestamp = @filemtime($value); |
|
| 1061 | 1061 | } |
| 1062 | 1062 | public function getTimestamp() |
| 1063 | 1063 | { |
@@ -1065,13 +1065,13 @@ discard block |
||
| 1065 | 1065 | } |
| 1066 | 1066 | public function getHasChanged() |
| 1067 | 1067 | { |
| 1068 | - return @filemtime($this->_fileName)!==$this->_timestamp; |
|
| 1068 | + return @filemtime($this->_fileName) !== $this->_timestamp; |
|
| 1069 | 1069 | } |
| 1070 | 1070 | } |
| 1071 | 1071 | class TDirectoryCacheDependency extends TCacheDependency |
| 1072 | 1072 | { |
| 1073 | - private $_recursiveCheck=true; |
|
| 1074 | - private $_recursiveLevel=-1; |
|
| 1073 | + private $_recursiveCheck = true; |
|
| 1074 | + private $_recursiveLevel = -1; |
|
| 1075 | 1075 | private $_timestamps; |
| 1076 | 1076 | private $_directory; |
| 1077 | 1077 | public function __construct($directory) |
@@ -1084,10 +1084,10 @@ discard block |
||
| 1084 | 1084 | } |
| 1085 | 1085 | public function setDirectory($directory) |
| 1086 | 1086 | { |
| 1087 | - if(($path=realpath($directory))===false || !is_dir($path)) |
|
| 1088 | - throw new TInvalidDataValueException('directorycachedependency_directory_invalid',$directory); |
|
| 1089 | - $this->_directory=$path; |
|
| 1090 | - $this->_timestamps=$this->generateTimestamps($path); |
|
| 1087 | + if (($path = realpath($directory)) === false || !is_dir($path)) |
|
| 1088 | + throw new TInvalidDataValueException('directorycachedependency_directory_invalid', $directory); |
|
| 1089 | + $this->_directory = $path; |
|
| 1090 | + $this->_timestamps = $this->generateTimestamps($path); |
|
| 1091 | 1091 | } |
| 1092 | 1092 | public function getRecursiveCheck() |
| 1093 | 1093 | { |
@@ -1095,7 +1095,7 @@ discard block |
||
| 1095 | 1095 | } |
| 1096 | 1096 | public function setRecursiveCheck($value) |
| 1097 | 1097 | { |
| 1098 | - $this->_recursiveCheck=TPropertyValue::ensureBoolean($value); |
|
| 1098 | + $this->_recursiveCheck = TPropertyValue::ensureBoolean($value); |
|
| 1099 | 1099 | } |
| 1100 | 1100 | public function getRecursiveLevel() |
| 1101 | 1101 | { |
@@ -1103,11 +1103,11 @@ discard block |
||
| 1103 | 1103 | } |
| 1104 | 1104 | public function setRecursiveLevel($value) |
| 1105 | 1105 | { |
| 1106 | - $this->_recursiveLevel=TPropertyValue::ensureInteger($value); |
|
| 1106 | + $this->_recursiveLevel = TPropertyValue::ensureInteger($value); |
|
| 1107 | 1107 | } |
| 1108 | 1108 | public function getHasChanged() |
| 1109 | 1109 | { |
| 1110 | - return $this->generateTimestamps($this->_directory)!=$this->_timestamps; |
|
| 1110 | + return $this->generateTimestamps($this->_directory) != $this->_timestamps; |
|
| 1111 | 1111 | } |
| 1112 | 1112 | protected function validateFile($fileName) |
| 1113 | 1113 | { |
@@ -1117,23 +1117,23 @@ discard block |
||
| 1117 | 1117 | { |
| 1118 | 1118 | return true; |
| 1119 | 1119 | } |
| 1120 | - protected function generateTimestamps($directory,$level=0) |
|
| 1120 | + protected function generateTimestamps($directory, $level = 0) |
|
| 1121 | 1121 | { |
| 1122 | - if(($dir=opendir($directory))===false) |
|
| 1123 | - throw new TIOException('directorycachedependency_directory_invalid',$directory); |
|
| 1124 | - $timestamps=array(); |
|
| 1125 | - while(($file=readdir($dir))!==false) |
|
| 1122 | + if (($dir = opendir($directory)) === false) |
|
| 1123 | + throw new TIOException('directorycachedependency_directory_invalid', $directory); |
|
| 1124 | + $timestamps = array(); |
|
| 1125 | + while (($file = readdir($dir)) !== false) |
|
| 1126 | 1126 | { |
| 1127 | - $path=$directory.DIRECTORY_SEPARATOR.$file; |
|
| 1128 | - if($file==='.' || $file==='..') |
|
| 1127 | + $path = $directory . DIRECTORY_SEPARATOR . $file; |
|
| 1128 | + if ($file === '.' || $file === '..') |
|
| 1129 | 1129 | continue; |
| 1130 | - else if(is_dir($path)) |
|
| 1130 | + else if (is_dir($path)) |
|
| 1131 | 1131 | { |
| 1132 | - if(($this->_recursiveLevel<0 || $level<$this->_recursiveLevel) && $this->validateDirectory($path)) |
|
| 1133 | - $timestamps=array_merge($this->generateTimestamps($path,$level+1)); |
|
| 1132 | + if (($this->_recursiveLevel < 0 || $level < $this->_recursiveLevel) && $this->validateDirectory($path)) |
|
| 1133 | + $timestamps = array_merge($this->generateTimestamps($path, $level + 1)); |
|
| 1134 | 1134 | } |
| 1135 | - else if($this->validateFile($path)) |
|
| 1136 | - $timestamps[$path]=filemtime($path); |
|
| 1135 | + else if ($this->validateFile($path)) |
|
| 1136 | + $timestamps[$path] = filemtime($path); |
|
| 1137 | 1137 | } |
| 1138 | 1138 | closedir($dir); |
| 1139 | 1139 | return $timestamps; |
@@ -1153,29 +1153,29 @@ discard block |
||
| 1153 | 1153 | } |
| 1154 | 1154 | public function setStateName($value) |
| 1155 | 1155 | { |
| 1156 | - $this->_stateName=$value; |
|
| 1157 | - $this->_stateValue=Prado::getApplication()->getGlobalState($value); |
|
| 1156 | + $this->_stateName = $value; |
|
| 1157 | + $this->_stateValue = Prado::getApplication()->getGlobalState($value); |
|
| 1158 | 1158 | } |
| 1159 | 1159 | public function getHasChanged() |
| 1160 | 1160 | { |
| 1161 | - return $this->_stateValue!==Prado::getApplication()->getGlobalState($this->_stateName); |
|
| 1161 | + return $this->_stateValue !== Prado::getApplication()->getGlobalState($this->_stateName); |
|
| 1162 | 1162 | } |
| 1163 | 1163 | } |
| 1164 | 1164 | class TChainedCacheDependency extends TCacheDependency |
| 1165 | 1165 | { |
| 1166 | - private $_dependencies=null; |
|
| 1166 | + private $_dependencies = null; |
|
| 1167 | 1167 | public function getDependencies() |
| 1168 | 1168 | { |
| 1169 | - if($this->_dependencies===null) |
|
| 1170 | - $this->_dependencies=new TCacheDependencyList; |
|
| 1169 | + if ($this->_dependencies === null) |
|
| 1170 | + $this->_dependencies = new TCacheDependencyList; |
|
| 1171 | 1171 | return $this->_dependencies; |
| 1172 | 1172 | } |
| 1173 | 1173 | public function getHasChanged() |
| 1174 | 1174 | { |
| 1175 | - if($this->_dependencies!==null) |
|
| 1175 | + if ($this->_dependencies !== null) |
|
| 1176 | 1176 | { |
| 1177 | - foreach($this->_dependencies as $dependency) |
|
| 1178 | - if($dependency->getHasChanged()) |
|
| 1177 | + foreach ($this->_dependencies as $dependency) |
|
| 1178 | + if ($dependency->getHasChanged()) |
|
| 1179 | 1179 | return true; |
| 1180 | 1180 | } |
| 1181 | 1181 | return false; |
@@ -1185,49 +1185,49 @@ discard block |
||
| 1185 | 1185 | { |
| 1186 | 1186 | public function getHasChanged() |
| 1187 | 1187 | { |
| 1188 | - return Prado::getApplication()->getMode()!==TApplicationMode::Performance; |
|
| 1188 | + return Prado::getApplication()->getMode() !== TApplicationMode::Performance; |
|
| 1189 | 1189 | } |
| 1190 | 1190 | } |
| 1191 | 1191 | class TCacheDependencyList extends TList |
| 1192 | 1192 | { |
| 1193 | - public function insertAt($index,$item) |
|
| 1193 | + public function insertAt($index, $item) |
|
| 1194 | 1194 | { |
| 1195 | - if($item instanceof ICacheDependency) |
|
| 1196 | - parent::insertAt($index,$item); |
|
| 1195 | + if ($item instanceof ICacheDependency) |
|
| 1196 | + parent::insertAt($index, $item); |
|
| 1197 | 1197 | else |
| 1198 | 1198 | throw new TInvalidDataTypeException('cachedependencylist_cachedependency_required'); |
| 1199 | 1199 | } |
| 1200 | 1200 | } |
| 1201 | 1201 | class TTextWriter extends TComponent implements ITextWriter |
| 1202 | 1202 | { |
| 1203 | - private $_str=''; |
|
| 1203 | + private $_str = ''; |
|
| 1204 | 1204 | public function flush() |
| 1205 | 1205 | { |
| 1206 | - $str=$this->_str; |
|
| 1207 | - $this->_str=''; |
|
| 1206 | + $str = $this->_str; |
|
| 1207 | + $this->_str = ''; |
|
| 1208 | 1208 | return $str; |
| 1209 | 1209 | } |
| 1210 | 1210 | public function write($str) |
| 1211 | 1211 | { |
| 1212 | - $this->_str.=$str; |
|
| 1212 | + $this->_str .= $str; |
|
| 1213 | 1213 | } |
| 1214 | - public function writeLine($str='') |
|
| 1214 | + public function writeLine($str = '') |
|
| 1215 | 1215 | { |
| 1216 | - $this->write($str."\n"); |
|
| 1216 | + $this->write($str . "\n"); |
|
| 1217 | 1217 | } |
| 1218 | 1218 | } |
| 1219 | 1219 | class TPriorityList extends TList |
| 1220 | 1220 | { |
| 1221 | - private $_d=array(); |
|
| 1222 | - private $_o=false; |
|
| 1223 | - private $_fd=null; |
|
| 1224 | - private $_c=0; |
|
| 1225 | - private $_dp=10; |
|
| 1226 | - private $_p=8; |
|
| 1227 | - public function __construct($data=null,$readOnly=false,$defaultPriority=10,$precision=8) |
|
| 1221 | + private $_d = array(); |
|
| 1222 | + private $_o = false; |
|
| 1223 | + private $_fd = null; |
|
| 1224 | + private $_c = 0; |
|
| 1225 | + private $_dp = 10; |
|
| 1226 | + private $_p = 8; |
|
| 1227 | + public function __construct($data = null, $readOnly = false, $defaultPriority = 10, $precision = 8) |
|
| 1228 | 1228 | { |
| 1229 | 1229 | parent::__construct(); |
| 1230 | - if($data!==null) |
|
| 1230 | + if ($data !== null) |
|
| 1231 | 1231 | $this->copyFrom($data); |
| 1232 | 1232 | $this->setReadOnly($readOnly); |
| 1233 | 1233 | $this->setPrecision($precision); |
@@ -1241,12 +1241,12 @@ discard block |
||
| 1241 | 1241 | { |
| 1242 | 1242 | return $this->_c; |
| 1243 | 1243 | } |
| 1244 | - public function getPriorityCount($priority=null) |
|
| 1244 | + public function getPriorityCount($priority = null) |
|
| 1245 | 1245 | { |
| 1246 | - if($priority===null) |
|
| 1247 | - $priority=$this->getDefaultPriority(); |
|
| 1248 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
| 1249 | - if(!isset($this->_d[$priority]) || !is_array($this->_d[$priority])) |
|
| 1246 | + if ($priority === null) |
|
| 1247 | + $priority = $this->getDefaultPriority(); |
|
| 1248 | + $priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 1249 | + if (!isset($this->_d[$priority]) || !is_array($this->_d[$priority])) |
|
| 1250 | 1250 | return false; |
| 1251 | 1251 | return count($this->_d[$priority]); |
| 1252 | 1252 | } |
@@ -1256,7 +1256,7 @@ discard block |
||
| 1256 | 1256 | } |
| 1257 | 1257 | protected function setDefaultPriority($value) |
| 1258 | 1258 | { |
| 1259 | - $this->_dp=(string)round(TPropertyValue::ensureFloat($value),$this->_p); |
|
| 1259 | + $this->_dp = (string) round(TPropertyValue::ensureFloat($value), $this->_p); |
|
| 1260 | 1260 | } |
| 1261 | 1261 | public function getPrecision() |
| 1262 | 1262 | { |
@@ -1264,7 +1264,7 @@ discard block |
||
| 1264 | 1264 | } |
| 1265 | 1265 | protected function setPrecision($value) |
| 1266 | 1266 | { |
| 1267 | - $this->_p=TPropertyValue::ensureInteger($value); |
|
| 1267 | + $this->_p = TPropertyValue::ensureInteger($value); |
|
| 1268 | 1268 | } |
| 1269 | 1269 | public function getIterator() |
| 1270 | 1270 | { |
@@ -1276,122 +1276,122 @@ discard block |
||
| 1276 | 1276 | return array_keys($this->_d); |
| 1277 | 1277 | } |
| 1278 | 1278 | protected function sortPriorities() { |
| 1279 | - if(!$this->_o) { |
|
| 1280 | - ksort($this->_d,SORT_NUMERIC); |
|
| 1281 | - $this->_o=true; |
|
| 1279 | + if (!$this->_o) { |
|
| 1280 | + ksort($this->_d, SORT_NUMERIC); |
|
| 1281 | + $this->_o = true; |
|
| 1282 | 1282 | } |
| 1283 | 1283 | } |
| 1284 | 1284 | protected function flattenPriorities() { |
| 1285 | - if(is_array($this->_fd)) |
|
| 1285 | + if (is_array($this->_fd)) |
|
| 1286 | 1286 | return $this->_fd; |
| 1287 | 1287 | $this->sortPriorities(); |
| 1288 | - $this->_fd=array(); |
|
| 1289 | - foreach($this->_d as $priority => $itemsatpriority) |
|
| 1290 | - $this->_fd=array_merge($this->_fd,$itemsatpriority); |
|
| 1288 | + $this->_fd = array(); |
|
| 1289 | + foreach ($this->_d as $priority => $itemsatpriority) |
|
| 1290 | + $this->_fd = array_merge($this->_fd, $itemsatpriority); |
|
| 1291 | 1291 | return $this->_fd; |
| 1292 | 1292 | } |
| 1293 | 1293 | public function itemAt($index) |
| 1294 | 1294 | { |
| 1295 | - if($index>=0&&$index<$this->getCount()) { |
|
| 1296 | - $arr=$this->flattenPriorities(); |
|
| 1295 | + if ($index >= 0 && $index < $this->getCount()) { |
|
| 1296 | + $arr = $this->flattenPriorities(); |
|
| 1297 | 1297 | return $arr[$index]; |
| 1298 | 1298 | } else |
| 1299 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
| 1299 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
| 1300 | 1300 | } |
| 1301 | - public function itemsAtPriority($priority=null) |
|
| 1301 | + public function itemsAtPriority($priority = null) |
|
| 1302 | 1302 | { |
| 1303 | - if($priority===null) |
|
| 1304 | - $priority=$this->getDefaultPriority(); |
|
| 1305 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
| 1306 | - return isset($this->_d[$priority])?$this->_d[$priority]:null; |
|
| 1303 | + if ($priority === null) |
|
| 1304 | + $priority = $this->getDefaultPriority(); |
|
| 1305 | + $priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 1306 | + return isset($this->_d[$priority]) ? $this->_d[$priority] : null; |
|
| 1307 | 1307 | } |
| 1308 | - public function itemAtIndexInPriority($index,$priority=null) |
|
| 1308 | + public function itemAtIndexInPriority($index, $priority = null) |
|
| 1309 | 1309 | { |
| 1310 | - if($priority===null) |
|
| 1311 | - $priority=$this->getDefaultPriority(); |
|
| 1312 | - $priority=(string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 1313 | - return !isset($this->_d[$priority])?false:( |
|
| 1314 | - isset($this->_d[$priority][$index])?$this->_d[$priority][$index]:false |
|
| 1310 | + if ($priority === null) |
|
| 1311 | + $priority = $this->getDefaultPriority(); |
|
| 1312 | + $priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 1313 | + return !isset($this->_d[$priority]) ? false : ( |
|
| 1314 | + isset($this->_d[$priority][$index]) ? $this->_d[$priority][$index] : false |
|
| 1315 | 1315 | ); |
| 1316 | 1316 | } |
| 1317 | - public function add($item,$priority=null) |
|
| 1317 | + public function add($item, $priority = null) |
|
| 1318 | 1318 | { |
| 1319 | - if($this->getReadOnly()) |
|
| 1320 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 1321 | - return $this->insertAtIndexInPriority($item,false,$priority,true); |
|
| 1319 | + if ($this->getReadOnly()) |
|
| 1320 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
| 1321 | + return $this->insertAtIndexInPriority($item, false, $priority, true); |
|
| 1322 | 1322 | } |
| 1323 | - public function insertAt($index,$item) |
|
| 1323 | + public function insertAt($index, $item) |
|
| 1324 | 1324 | { |
| 1325 | - if($this->getReadOnly()) |
|
| 1326 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 1327 | - if(($priority=$this->priorityAt($index,true))!==false) |
|
| 1328 | - $this->insertAtIndexInPriority($item,$priority[1],$priority[0]); |
|
| 1325 | + if ($this->getReadOnly()) |
|
| 1326 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
| 1327 | + if (($priority = $this->priorityAt($index, true)) !== false) |
|
| 1328 | + $this->insertAtIndexInPriority($item, $priority[1], $priority[0]); |
|
| 1329 | 1329 | else |
| 1330 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
| 1330 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
| 1331 | 1331 | } |
| 1332 | - public function insertAtIndexInPriority($item,$index=false,$priority=null,$preserveCache=false) |
|
| 1332 | + public function insertAtIndexInPriority($item, $index = false, $priority = null, $preserveCache = false) |
|
| 1333 | 1333 | { |
| 1334 | - if($this->getReadOnly()) |
|
| 1335 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 1336 | - if($priority===null) |
|
| 1337 | - $priority=$this->getDefaultPriority(); |
|
| 1338 | - $priority=(string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 1339 | - if($preserveCache) { |
|
| 1334 | + if ($this->getReadOnly()) |
|
| 1335 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
| 1336 | + if ($priority === null) |
|
| 1337 | + $priority = $this->getDefaultPriority(); |
|
| 1338 | + $priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 1339 | + if ($preserveCache) { |
|
| 1340 | 1340 | $this->sortPriorities(); |
| 1341 | - $cc=0; |
|
| 1342 | - foreach($this->_d as $prioritykey=>$items) |
|
| 1343 | - if($prioritykey>=$priority) |
|
| 1341 | + $cc = 0; |
|
| 1342 | + foreach ($this->_d as $prioritykey=>$items) |
|
| 1343 | + if ($prioritykey >= $priority) |
|
| 1344 | 1344 | break; |
| 1345 | 1345 | else |
| 1346 | - $cc+=count($items); |
|
| 1347 | - if($index===false&&isset($this->_d[$priority])) { |
|
| 1348 | - $c=count($this->_d[$priority]); |
|
| 1349 | - $c+=$cc; |
|
| 1350 | - $this->_d[$priority][]=$item; |
|
| 1351 | - } else if(isset($this->_d[$priority])) { |
|
| 1352 | - $c=$index+$cc; |
|
| 1353 | - array_splice($this->_d[$priority],$index,0,array($item)); |
|
| 1346 | + $cc += count($items); |
|
| 1347 | + if ($index === false && isset($this->_d[$priority])) { |
|
| 1348 | + $c = count($this->_d[$priority]); |
|
| 1349 | + $c += $cc; |
|
| 1350 | + $this->_d[$priority][] = $item; |
|
| 1351 | + } else if (isset($this->_d[$priority])) { |
|
| 1352 | + $c = $index + $cc; |
|
| 1353 | + array_splice($this->_d[$priority], $index, 0, array($item)); |
|
| 1354 | 1354 | } else { |
| 1355 | 1355 | $c = $cc; |
| 1356 | 1356 | $this->_o = false; |
| 1357 | - $this->_d[$priority]=array($item); |
|
| 1357 | + $this->_d[$priority] = array($item); |
|
| 1358 | 1358 | } |
| 1359 | - if($this->_fd&&is_array($this->_fd)) array_splice($this->_fd,$c,0,array($item)); |
|
| 1359 | + if ($this->_fd && is_array($this->_fd)) array_splice($this->_fd, $c, 0, array($item)); |
|
| 1360 | 1360 | } else { |
| 1361 | - $c=null; |
|
| 1362 | - if($index===false&&isset($this->_d[$priority])) { |
|
| 1363 | - $cc=count($this->_d[$priority]); |
|
| 1364 | - $this->_d[$priority][]=$item; |
|
| 1365 | - } else if(isset($this->_d[$priority])) { |
|
| 1366 | - $cc=$index; |
|
| 1367 | - array_splice($this->_d[$priority],$index,0,array($item)); |
|
| 1361 | + $c = null; |
|
| 1362 | + if ($index === false && isset($this->_d[$priority])) { |
|
| 1363 | + $cc = count($this->_d[$priority]); |
|
| 1364 | + $this->_d[$priority][] = $item; |
|
| 1365 | + } else if (isset($this->_d[$priority])) { |
|
| 1366 | + $cc = $index; |
|
| 1367 | + array_splice($this->_d[$priority], $index, 0, array($item)); |
|
| 1368 | 1368 | } else { |
| 1369 | - $cc=0; |
|
| 1370 | - $this->_o=false; |
|
| 1371 | - $this->_d[$priority]=array($item); |
|
| 1369 | + $cc = 0; |
|
| 1370 | + $this->_o = false; |
|
| 1371 | + $this->_d[$priority] = array($item); |
|
| 1372 | 1372 | } |
| 1373 | - if($this->_fd&&is_array($this->_fd)&&count($this->_d)==1) |
|
| 1374 | - array_splice($this->_fd,$cc,0,array($item)); |
|
| 1373 | + if ($this->_fd && is_array($this->_fd) && count($this->_d) == 1) |
|
| 1374 | + array_splice($this->_fd, $cc, 0, array($item)); |
|
| 1375 | 1375 | else |
| 1376 | - $this->_fd=null; |
|
| 1376 | + $this->_fd = null; |
|
| 1377 | 1377 | } |
| 1378 | 1378 | $this->_c++; |
| 1379 | 1379 | return $c; |
| 1380 | 1380 | } |
| 1381 | - public function remove($item,$priority=false) |
|
| 1381 | + public function remove($item, $priority = false) |
|
| 1382 | 1382 | { |
| 1383 | - if($this->getReadOnly()) |
|
| 1384 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 1385 | - if(($p=$this->priorityOf($item,true))!==false) |
|
| 1383 | + if ($this->getReadOnly()) |
|
| 1384 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
| 1385 | + if (($p = $this->priorityOf($item, true)) !== false) |
|
| 1386 | 1386 | { |
| 1387 | - if($priority!==false) { |
|
| 1388 | - if($priority===null) |
|
| 1389 | - $priority=$this->getDefaultPriority(); |
|
| 1390 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
| 1391 | - if($p[0]!=$priority) |
|
| 1387 | + if ($priority !== false) { |
|
| 1388 | + if ($priority === null) |
|
| 1389 | + $priority = $this->getDefaultPriority(); |
|
| 1390 | + $priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 1391 | + if ($p[0] != $priority) |
|
| 1392 | 1392 | throw new TInvalidDataValueException('list_item_inexistent'); |
| 1393 | 1393 | } |
| 1394 | - $this->removeAtIndexInPriority($p[1],$p[0]); |
|
| 1394 | + $this->removeAtIndexInPriority($p[1], $p[0]); |
|
| 1395 | 1395 | return $p[2]; |
| 1396 | 1396 | } |
| 1397 | 1397 | else |
@@ -1399,97 +1399,97 @@ discard block |
||
| 1399 | 1399 | } |
| 1400 | 1400 | public function removeAt($index) |
| 1401 | 1401 | { |
| 1402 | - if($this->getReadOnly()) |
|
| 1403 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 1404 | - if(($priority=$this->priorityAt($index, true))!==false) |
|
| 1405 | - return $this->removeAtIndexInPriority($priority[1],$priority[0]); |
|
| 1406 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
| 1402 | + if ($this->getReadOnly()) |
|
| 1403 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
| 1404 | + if (($priority = $this->priorityAt($index, true)) !== false) |
|
| 1405 | + return $this->removeAtIndexInPriority($priority[1], $priority[0]); |
|
| 1406 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
| 1407 | 1407 | } |
| 1408 | - public function removeAtIndexInPriority($index, $priority=null) |
|
| 1408 | + public function removeAtIndexInPriority($index, $priority = null) |
|
| 1409 | 1409 | { |
| 1410 | - if($this->getReadOnly()) |
|
| 1411 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 1412 | - if($priority===null) |
|
| 1413 | - $priority=$this->getDefaultPriority(); |
|
| 1414 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
| 1415 | - if(!isset($this->_d[$priority])||$index<0||$index>=count($this->_d[$priority])) |
|
| 1410 | + if ($this->getReadOnly()) |
|
| 1411 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
| 1412 | + if ($priority === null) |
|
| 1413 | + $priority = $this->getDefaultPriority(); |
|
| 1414 | + $priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 1415 | + if (!isset($this->_d[$priority]) || $index < 0 || $index >= count($this->_d[$priority])) |
|
| 1416 | 1416 | throw new TInvalidDataValueException('list_item_inexistent'); |
| 1417 | - $value=array_splice($this->_d[$priority],$index,1); |
|
| 1418 | - $value=$value[0]; |
|
| 1419 | - if(!count($this->_d[$priority])) |
|
| 1417 | + $value = array_splice($this->_d[$priority], $index, 1); |
|
| 1418 | + $value = $value[0]; |
|
| 1419 | + if (!count($this->_d[$priority])) |
|
| 1420 | 1420 | unset($this->_d[$priority]); |
| 1421 | 1421 | $this->_c--; |
| 1422 | - $this->_fd=null; |
|
| 1422 | + $this->_fd = null; |
|
| 1423 | 1423 | return $value; |
| 1424 | 1424 | } |
| 1425 | 1425 | public function clear() |
| 1426 | 1426 | { |
| 1427 | - if($this->getReadOnly()) |
|
| 1428 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 1429 | - $d=array_reverse($this->_d,true); |
|
| 1430 | - foreach($this->_d as $priority=>$items) { |
|
| 1431 | - for($index=count($items)-1;$index>=0;$index--) |
|
| 1432 | - $this->removeAtIndexInPriority($index,$priority); |
|
| 1427 | + if ($this->getReadOnly()) |
|
| 1428 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
| 1429 | + $d = array_reverse($this->_d, true); |
|
| 1430 | + foreach ($this->_d as $priority=>$items) { |
|
| 1431 | + for ($index = count($items) - 1; $index >= 0; $index--) |
|
| 1432 | + $this->removeAtIndexInPriority($index, $priority); |
|
| 1433 | 1433 | unset($this->_d[$priority]); |
| 1434 | 1434 | } |
| 1435 | 1435 | } |
| 1436 | 1436 | public function contains($item) |
| 1437 | 1437 | { |
| 1438 | - return $this->indexOf($item)>=0; |
|
| 1438 | + return $this->indexOf($item) >= 0; |
|
| 1439 | 1439 | } |
| 1440 | 1440 | public function indexOf($item) |
| 1441 | 1441 | { |
| 1442 | - if(($index=array_search($item,$this->flattenPriorities(),true))===false) |
|
| 1442 | + if (($index = array_search($item, $this->flattenPriorities(), true)) === false) |
|
| 1443 | 1443 | return -1; |
| 1444 | 1444 | else |
| 1445 | 1445 | return $index; |
| 1446 | 1446 | } |
| 1447 | - public function priorityOf($item,$withindex = false) |
|
| 1447 | + public function priorityOf($item, $withindex = false) |
|
| 1448 | 1448 | { |
| 1449 | 1449 | $this->sortPriorities(); |
| 1450 | 1450 | $absindex = 0; |
| 1451 | - foreach($this->_d as $priority=>$items) { |
|
| 1452 | - if(($index=array_search($item,$items,true))!==false) { |
|
| 1453 | - $absindex+=$index; |
|
| 1454 | - return $withindex?array($priority,$index,$absindex, |
|
| 1455 | - 'priority'=>$priority,'index'=>$index,'absindex'=>$absindex):$priority; |
|
| 1451 | + foreach ($this->_d as $priority=>$items) { |
|
| 1452 | + if (($index = array_search($item, $items, true)) !== false) { |
|
| 1453 | + $absindex += $index; |
|
| 1454 | + return $withindex ? array($priority, $index, $absindex, |
|
| 1455 | + 'priority'=>$priority, 'index'=>$index, 'absindex'=>$absindex) : $priority; |
|
| 1456 | 1456 | } else |
| 1457 | - $absindex+=count($items); |
|
| 1457 | + $absindex += count($items); |
|
| 1458 | 1458 | } |
| 1459 | 1459 | return false; |
| 1460 | 1460 | } |
| 1461 | - public function priorityAt($index,$withindex = false) |
|
| 1461 | + public function priorityAt($index, $withindex = false) |
|
| 1462 | 1462 | { |
| 1463 | - if($index<0||$index>=$this->getCount()) |
|
| 1464 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
| 1465 | - $absindex=$index; |
|
| 1463 | + if ($index < 0 || $index >= $this->getCount()) |
|
| 1464 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
| 1465 | + $absindex = $index; |
|
| 1466 | 1466 | $this->sortPriorities(); |
| 1467 | - foreach($this->_d as $priority=>$items) { |
|
| 1468 | - if($index>=($c=count($items))) |
|
| 1469 | - $index-=$c; |
|
| 1467 | + foreach ($this->_d as $priority=>$items) { |
|
| 1468 | + if ($index >= ($c = count($items))) |
|
| 1469 | + $index -= $c; |
|
| 1470 | 1470 | else |
| 1471 | - return $withindex?array($priority,$index,$absindex, |
|
| 1472 | - 'priority'=>$priority,'index'=>$index,'absindex'=>$absindex):$priority; |
|
| 1471 | + return $withindex ? array($priority, $index, $absindex, |
|
| 1472 | + 'priority'=>$priority, 'index'=>$index, 'absindex'=>$absindex) : $priority; |
|
| 1473 | 1473 | } |
| 1474 | 1474 | return false; |
| 1475 | 1475 | } |
| 1476 | 1476 | public function insertBefore($indexitem, $item) |
| 1477 | 1477 | { |
| 1478 | - if($this->getReadOnly()) |
|
| 1479 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 1480 | - if(($priority=$this->priorityOf($indexitem,true))===false) |
|
| 1478 | + if ($this->getReadOnly()) |
|
| 1479 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
| 1480 | + if (($priority = $this->priorityOf($indexitem, true)) === false) |
|
| 1481 | 1481 | throw new TInvalidDataValueException('list_item_inexistent'); |
| 1482 | - $this->insertAtIndexInPriority($item,$priority[1],$priority[0]); |
|
| 1482 | + $this->insertAtIndexInPriority($item, $priority[1], $priority[0]); |
|
| 1483 | 1483 | return $priority[2]; |
| 1484 | 1484 | } |
| 1485 | 1485 | public function insertAfter($indexitem, $item) |
| 1486 | 1486 | { |
| 1487 | - if($this->getReadOnly()) |
|
| 1488 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
| 1489 | - if(($priority=$this->priorityOf($indexitem,true))===false) |
|
| 1487 | + if ($this->getReadOnly()) |
|
| 1488 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
| 1489 | + if (($priority = $this->priorityOf($indexitem, true)) === false) |
|
| 1490 | 1490 | throw new TInvalidDataValueException('list_item_inexistent'); |
| 1491 | - $this->insertAtIndexInPriority($item,$priority[1]+1,$priority[0]); |
|
| 1492 | - return $priority[2]+1; |
|
| 1491 | + $this->insertAtIndexInPriority($item, $priority[1] + 1, $priority[0]); |
|
| 1492 | + return $priority[2] + 1; |
|
| 1493 | 1493 | } |
| 1494 | 1494 | public function toArray() |
| 1495 | 1495 | { |
@@ -1500,108 +1500,108 @@ discard block |
||
| 1500 | 1500 | $this->sortPriorities(); |
| 1501 | 1501 | return $this->_d; |
| 1502 | 1502 | } |
| 1503 | - public function toArrayBelowPriority($priority,$inclusive=false) |
|
| 1503 | + public function toArrayBelowPriority($priority, $inclusive = false) |
|
| 1504 | 1504 | { |
| 1505 | 1505 | $this->sortPriorities(); |
| 1506 | - $items=array(); |
|
| 1507 | - foreach($this->_d as $itemspriority=>$itemsatpriority) |
|
| 1506 | + $items = array(); |
|
| 1507 | + foreach ($this->_d as $itemspriority=>$itemsatpriority) |
|
| 1508 | 1508 | { |
| 1509 | - if((!$inclusive&&$itemspriority>=$priority)||$itemspriority>$priority) |
|
| 1509 | + if ((!$inclusive && $itemspriority >= $priority) || $itemspriority > $priority) |
|
| 1510 | 1510 | break; |
| 1511 | - $items=array_merge($items,$itemsatpriority); |
|
| 1511 | + $items = array_merge($items, $itemsatpriority); |
|
| 1512 | 1512 | } |
| 1513 | 1513 | return $items; |
| 1514 | 1514 | } |
| 1515 | - public function toArrayAbovePriority($priority,$inclusive=true) |
|
| 1515 | + public function toArrayAbovePriority($priority, $inclusive = true) |
|
| 1516 | 1516 | { |
| 1517 | 1517 | $this->sortPriorities(); |
| 1518 | - $items=array(); |
|
| 1519 | - foreach($this->_d as $itemspriority=>$itemsatpriority) |
|
| 1518 | + $items = array(); |
|
| 1519 | + foreach ($this->_d as $itemspriority=>$itemsatpriority) |
|
| 1520 | 1520 | { |
| 1521 | - if((!$inclusive&&$itemspriority<=$priority)||$itemspriority<$priority) |
|
| 1521 | + if ((!$inclusive && $itemspriority <= $priority) || $itemspriority < $priority) |
|
| 1522 | 1522 | continue; |
| 1523 | - $items=array_merge($items,$itemsatpriority); |
|
| 1523 | + $items = array_merge($items, $itemsatpriority); |
|
| 1524 | 1524 | } |
| 1525 | 1525 | return $items; |
| 1526 | 1526 | } |
| 1527 | 1527 | public function copyFrom($data) |
| 1528 | 1528 | { |
| 1529 | - if($data instanceof TPriorityList) |
|
| 1529 | + if ($data instanceof TPriorityList) |
|
| 1530 | 1530 | { |
| 1531 | - if($this->getCount()>0) |
|
| 1531 | + if ($this->getCount() > 0) |
|
| 1532 | 1532 | $this->clear(); |
| 1533 | - foreach($data->getPriorities() as $priority) |
|
| 1533 | + foreach ($data->getPriorities() as $priority) |
|
| 1534 | 1534 | { |
| 1535 | - foreach($data->itemsAtPriority($priority) as $index=>$item) |
|
| 1536 | - $this->insertAtIndexInPriority($item,$index,$priority); |
|
| 1535 | + foreach ($data->itemsAtPriority($priority) as $index=>$item) |
|
| 1536 | + $this->insertAtIndexInPriority($item, $index, $priority); |
|
| 1537 | 1537 | } |
| 1538 | - } else if(is_array($data)||$data instanceof Traversable) { |
|
| 1539 | - if($this->getCount()>0) |
|
| 1538 | + } else if (is_array($data) || $data instanceof Traversable) { |
|
| 1539 | + if ($this->getCount() > 0) |
|
| 1540 | 1540 | $this->clear(); |
| 1541 | - foreach($data as $key=>$item) |
|
| 1541 | + foreach ($data as $key=>$item) |
|
| 1542 | 1542 | $this->add($item); |
| 1543 | - } else if($data!==null) |
|
| 1543 | + } else if ($data !== null) |
|
| 1544 | 1544 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
| 1545 | 1545 | } |
| 1546 | 1546 | public function mergeWith($data) |
| 1547 | 1547 | { |
| 1548 | - if($data instanceof TPriorityList) |
|
| 1548 | + if ($data instanceof TPriorityList) |
|
| 1549 | 1549 | { |
| 1550 | - foreach($data->getPriorities() as $priority) |
|
| 1550 | + foreach ($data->getPriorities() as $priority) |
|
| 1551 | 1551 | { |
| 1552 | - foreach($data->itemsAtPriority($priority) as $index=>$item) |
|
| 1553 | - $this->insertAtIndexInPriority($item,false,$priority); |
|
| 1552 | + foreach ($data->itemsAtPriority($priority) as $index=>$item) |
|
| 1553 | + $this->insertAtIndexInPriority($item, false, $priority); |
|
| 1554 | 1554 | } |
| 1555 | 1555 | } |
| 1556 | - else if(is_array($data)||$data instanceof Traversable) |
|
| 1556 | + else if (is_array($data) || $data instanceof Traversable) |
|
| 1557 | 1557 | { |
| 1558 | - foreach($data as $priority=>$item) |
|
| 1558 | + foreach ($data as $priority=>$item) |
|
| 1559 | 1559 | $this->add($item); |
| 1560 | 1560 | } |
| 1561 | - else if($data!==null) |
|
| 1561 | + else if ($data !== null) |
|
| 1562 | 1562 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
| 1563 | 1563 | } |
| 1564 | 1564 | public function offsetExists($offset) |
| 1565 | 1565 | { |
| 1566 | - return ($offset>=0&&$offset<$this->getCount()); |
|
| 1566 | + return ($offset >= 0 && $offset < $this->getCount()); |
|
| 1567 | 1567 | } |
| 1568 | 1568 | public function offsetGet($offset) |
| 1569 | 1569 | { |
| 1570 | 1570 | return $this->itemAt($offset); |
| 1571 | 1571 | } |
| 1572 | - public function offsetSet($offset,$item) |
|
| 1572 | + public function offsetSet($offset, $item) |
|
| 1573 | 1573 | { |
| 1574 | - if($offset===null) |
|
| 1574 | + if ($offset === null) |
|
| 1575 | 1575 | return $this->add($item); |
| 1576 | - if($offset===$this->getCount()) { |
|
| 1577 | - $priority=$this->priorityAt($offset-1,true); |
|
| 1576 | + if ($offset === $this->getCount()) { |
|
| 1577 | + $priority = $this->priorityAt($offset - 1, true); |
|
| 1578 | 1578 | $priority[1]++; |
| 1579 | 1579 | } else { |
| 1580 | - $priority=$this->priorityAt($offset,true); |
|
| 1581 | - $this->removeAtIndexInPriority($priority[1],$priority[0]); |
|
| 1580 | + $priority = $this->priorityAt($offset, true); |
|
| 1581 | + $this->removeAtIndexInPriority($priority[1], $priority[0]); |
|
| 1582 | 1582 | } |
| 1583 | - $this->insertAtIndexInPriority($item,$priority[1],$priority[0]); |
|
| 1583 | + $this->insertAtIndexInPriority($item, $priority[1], $priority[0]); |
|
| 1584 | 1584 | } |
| 1585 | 1585 | public function offsetUnset($offset) |
| 1586 | 1586 | { |
| 1587 | 1587 | $this->removeAt($offset); |
| 1588 | 1588 | } |
| 1589 | 1589 | } |
| 1590 | -class TMap extends TComponent implements IteratorAggregate,ArrayAccess,Countable |
|
| 1590 | +class TMap extends TComponent implements IteratorAggregate, ArrayAccess, Countable |
|
| 1591 | 1591 | { |
| 1592 | - private $_d=array(); |
|
| 1593 | - private $_r=false; |
|
| 1592 | + private $_d = array(); |
|
| 1593 | + private $_r = false; |
|
| 1594 | 1594 | protected function __getZappableSleepProps(&$exprops) |
| 1595 | 1595 | { |
| 1596 | 1596 | parent::__getZappableSleepProps($exprops); |
| 1597 | - if ($this->_d===array()) |
|
| 1597 | + if ($this->_d === array()) |
|
| 1598 | 1598 | $exprops[] = "\0TMap\0_d"; |
| 1599 | - if ($this->_r===false) |
|
| 1599 | + if ($this->_r === false) |
|
| 1600 | 1600 | $exprops[] = "\0TMap\0_r"; |
| 1601 | 1601 | } |
| 1602 | - public function __construct($data=null,$readOnly=false) |
|
| 1602 | + public function __construct($data = null, $readOnly = false) |
|
| 1603 | 1603 | { |
| 1604 | - if($data!==null) |
|
| 1604 | + if ($data !== null) |
|
| 1605 | 1605 | $this->copyFrom($data); |
| 1606 | 1606 | $this->setReadOnly($readOnly); |
| 1607 | 1607 | } |
@@ -1611,11 +1611,11 @@ discard block |
||
| 1611 | 1611 | } |
| 1612 | 1612 | protected function setReadOnly($value) |
| 1613 | 1613 | { |
| 1614 | - $this->_r=TPropertyValue::ensureBoolean($value); |
|
| 1614 | + $this->_r = TPropertyValue::ensureBoolean($value); |
|
| 1615 | 1615 | } |
| 1616 | 1616 | public function getIterator() |
| 1617 | 1617 | { |
| 1618 | - return new ArrayIterator( $this->_d ); |
|
| 1618 | + return new ArrayIterator($this->_d); |
|
| 1619 | 1619 | } |
| 1620 | 1620 | public function count() |
| 1621 | 1621 | { |
@@ -1633,20 +1633,20 @@ discard block |
||
| 1633 | 1633 | { |
| 1634 | 1634 | return isset($this->_d[$key]) ? $this->_d[$key] : null; |
| 1635 | 1635 | } |
| 1636 | - public function add($key,$value) |
|
| 1636 | + public function add($key, $value) |
|
| 1637 | 1637 | { |
| 1638 | - if(!$this->_r) |
|
| 1639 | - $this->_d[$key]=$value; |
|
| 1638 | + if (!$this->_r) |
|
| 1639 | + $this->_d[$key] = $value; |
|
| 1640 | 1640 | else |
| 1641 | - throw new TInvalidOperationException('map_readonly',get_class($this)); |
|
| 1641 | + throw new TInvalidOperationException('map_readonly', get_class($this)); |
|
| 1642 | 1642 | } |
| 1643 | 1643 | public function remove($key) |
| 1644 | 1644 | { |
| 1645 | - if(!$this->_r) |
|
| 1645 | + if (!$this->_r) |
|
| 1646 | 1646 | { |
| 1647 | - if(isset($this->_d[$key]) || array_key_exists($key,$this->_d)) |
|
| 1647 | + if (isset($this->_d[$key]) || array_key_exists($key, $this->_d)) |
|
| 1648 | 1648 | { |
| 1649 | - $value=$this->_d[$key]; |
|
| 1649 | + $value = $this->_d[$key]; |
|
| 1650 | 1650 | unset($this->_d[$key]); |
| 1651 | 1651 | return $value; |
| 1652 | 1652 | } |
@@ -1654,16 +1654,16 @@ discard block |
||
| 1654 | 1654 | return null; |
| 1655 | 1655 | } |
| 1656 | 1656 | else |
| 1657 | - throw new TInvalidOperationException('map_readonly',get_class($this)); |
|
| 1657 | + throw new TInvalidOperationException('map_readonly', get_class($this)); |
|
| 1658 | 1658 | } |
| 1659 | 1659 | public function clear() |
| 1660 | 1660 | { |
| 1661 | - foreach(array_keys($this->_d) as $key) |
|
| 1661 | + foreach (array_keys($this->_d) as $key) |
|
| 1662 | 1662 | $this->remove($key); |
| 1663 | 1663 | } |
| 1664 | 1664 | public function contains($key) |
| 1665 | 1665 | { |
| 1666 | - return isset($this->_d[$key]) || array_key_exists($key,$this->_d); |
|
| 1666 | + return isset($this->_d[$key]) || array_key_exists($key, $this->_d); |
|
| 1667 | 1667 | } |
| 1668 | 1668 | public function toArray() |
| 1669 | 1669 | { |
@@ -1671,24 +1671,24 @@ discard block |
||
| 1671 | 1671 | } |
| 1672 | 1672 | public function copyFrom($data) |
| 1673 | 1673 | { |
| 1674 | - if(is_array($data) || $data instanceof Traversable) |
|
| 1674 | + if (is_array($data) || $data instanceof Traversable) |
|
| 1675 | 1675 | { |
| 1676 | - if($this->getCount()>0) |
|
| 1676 | + if ($this->getCount() > 0) |
|
| 1677 | 1677 | $this->clear(); |
| 1678 | - foreach($data as $key=>$value) |
|
| 1679 | - $this->add($key,$value); |
|
| 1678 | + foreach ($data as $key=>$value) |
|
| 1679 | + $this->add($key, $value); |
|
| 1680 | 1680 | } |
| 1681 | - else if($data!==null) |
|
| 1681 | + else if ($data !== null) |
|
| 1682 | 1682 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
| 1683 | 1683 | } |
| 1684 | 1684 | public function mergeWith($data) |
| 1685 | 1685 | { |
| 1686 | - if(is_array($data) || $data instanceof Traversable) |
|
| 1686 | + if (is_array($data) || $data instanceof Traversable) |
|
| 1687 | 1687 | { |
| 1688 | - foreach($data as $key=>$value) |
|
| 1689 | - $this->add($key,$value); |
|
| 1688 | + foreach ($data as $key=>$value) |
|
| 1689 | + $this->add($key, $value); |
|
| 1690 | 1690 | } |
| 1691 | - else if($data!==null) |
|
| 1691 | + else if ($data !== null) |
|
| 1692 | 1692 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
| 1693 | 1693 | } |
| 1694 | 1694 | public function offsetExists($offset) |
@@ -1699,9 +1699,9 @@ discard block |
||
| 1699 | 1699 | { |
| 1700 | 1700 | return $this->itemAt($offset); |
| 1701 | 1701 | } |
| 1702 | - public function offsetSet($offset,$item) |
|
| 1702 | + public function offsetSet($offset, $item) |
|
| 1703 | 1703 | { |
| 1704 | - $this->add($offset,$item); |
|
| 1704 | + $this->add($offset, $item); |
|
| 1705 | 1705 | } |
| 1706 | 1706 | public function offsetUnset($offset) |
| 1707 | 1707 | { |
@@ -1713,16 +1713,16 @@ discard block |
||
| 1713 | 1713 | } |
| 1714 | 1714 | class TPriorityMap extends TMap |
| 1715 | 1715 | { |
| 1716 | - private $_d=array(); |
|
| 1717 | - private $_r=false; |
|
| 1718 | - private $_o=false; |
|
| 1719 | - private $_fd=null; |
|
| 1720 | - private $_c=0; |
|
| 1721 | - private $_dp=10; |
|
| 1722 | - private $_p=8; |
|
| 1723 | - public function __construct($data=null,$readOnly=false,$defaultPriority=10,$precision=8) |
|
| 1724 | - { |
|
| 1725 | - if($data!==null) |
|
| 1716 | + private $_d = array(); |
|
| 1717 | + private $_r = false; |
|
| 1718 | + private $_o = false; |
|
| 1719 | + private $_fd = null; |
|
| 1720 | + private $_c = 0; |
|
| 1721 | + private $_dp = 10; |
|
| 1722 | + private $_p = 8; |
|
| 1723 | + public function __construct($data = null, $readOnly = false, $defaultPriority = 10, $precision = 8) |
|
| 1724 | + { |
|
| 1725 | + if ($data !== null) |
|
| 1726 | 1726 | $this->copyFrom($data); |
| 1727 | 1727 | $this->setReadOnly($readOnly); |
| 1728 | 1728 | $this->setPrecision($precision); |
@@ -1734,7 +1734,7 @@ discard block |
||
| 1734 | 1734 | } |
| 1735 | 1735 | protected function setReadOnly($value) |
| 1736 | 1736 | { |
| 1737 | - $this->_r=TPropertyValue::ensureBoolean($value); |
|
| 1737 | + $this->_r = TPropertyValue::ensureBoolean($value); |
|
| 1738 | 1738 | } |
| 1739 | 1739 | public function getDefaultPriority() |
| 1740 | 1740 | { |
@@ -1742,7 +1742,7 @@ discard block |
||
| 1742 | 1742 | } |
| 1743 | 1743 | protected function setDefaultPriority($value) |
| 1744 | 1744 | { |
| 1745 | - $this->_dp = (string)round(TPropertyValue::ensureFloat($value), $this->_p); |
|
| 1745 | + $this->_dp = (string) round(TPropertyValue::ensureFloat($value), $this->_p); |
|
| 1746 | 1746 | } |
| 1747 | 1747 | public function getPrecision() |
| 1748 | 1748 | { |
@@ -1750,24 +1750,24 @@ discard block |
||
| 1750 | 1750 | } |
| 1751 | 1751 | protected function setPrecision($value) |
| 1752 | 1752 | { |
| 1753 | - $this->_p=TPropertyValue::ensureInteger($value); |
|
| 1753 | + $this->_p = TPropertyValue::ensureInteger($value); |
|
| 1754 | 1754 | } |
| 1755 | 1755 | public function getIterator() |
| 1756 | 1756 | { |
| 1757 | 1757 | return new ArrayIterator($this->flattenPriorities()); |
| 1758 | 1758 | } |
| 1759 | 1759 | protected function sortPriorities() { |
| 1760 | - if(!$this->_o) { |
|
| 1760 | + if (!$this->_o) { |
|
| 1761 | 1761 | ksort($this->_d, SORT_NUMERIC); |
| 1762 | - $this->_o=true; |
|
| 1762 | + $this->_o = true; |
|
| 1763 | 1763 | } |
| 1764 | 1764 | } |
| 1765 | 1765 | protected function flattenPriorities() { |
| 1766 | - if(is_array($this->_fd)) |
|
| 1766 | + if (is_array($this->_fd)) |
|
| 1767 | 1767 | return $this->_fd; |
| 1768 | 1768 | $this->sortPriorities(); |
| 1769 | 1769 | $this->_fd = array(); |
| 1770 | - foreach($this->_d as $priority => $itemsatpriority) |
|
| 1770 | + foreach ($this->_d as $priority => $itemsatpriority) |
|
| 1771 | 1771 | $this->_fd = array_merge($this->_fd, $itemsatpriority); |
| 1772 | 1772 | return $this->_fd; |
| 1773 | 1773 | } |
@@ -1779,12 +1779,12 @@ discard block |
||
| 1779 | 1779 | { |
| 1780 | 1780 | return $this->_c; |
| 1781 | 1781 | } |
| 1782 | - public function getPriorityCount($priority=null) |
|
| 1782 | + public function getPriorityCount($priority = null) |
|
| 1783 | 1783 | { |
| 1784 | - if($priority===null) |
|
| 1785 | - $priority=$this->getDefaultPriority(); |
|
| 1786 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
| 1787 | - if(!isset($this->_d[$priority])||!is_array($this->_d[$priority])) |
|
| 1784 | + if ($priority === null) |
|
| 1785 | + $priority = $this->getDefaultPriority(); |
|
| 1786 | + $priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 1787 | + if (!isset($this->_d[$priority]) || !is_array($this->_d[$priority])) |
|
| 1788 | 1788 | return false; |
| 1789 | 1789 | return count($this->_d[$priority]); |
| 1790 | 1790 | } |
@@ -1797,119 +1797,119 @@ discard block |
||
| 1797 | 1797 | { |
| 1798 | 1798 | return array_keys($this->flattenPriorities()); |
| 1799 | 1799 | } |
| 1800 | - public function itemAt($key,$priority=false) |
|
| 1800 | + public function itemAt($key, $priority = false) |
|
| 1801 | 1801 | { |
| 1802 | - if($priority===false){ |
|
| 1803 | - $map=$this->flattenPriorities(); |
|
| 1804 | - return isset($map[$key])?$map[$key]:null; |
|
| 1802 | + if ($priority === false) { |
|
| 1803 | + $map = $this->flattenPriorities(); |
|
| 1804 | + return isset($map[$key]) ? $map[$key] : null; |
|
| 1805 | 1805 | } else { |
| 1806 | - if($priority===null) |
|
| 1807 | - $priority=$this->getDefaultPriority(); |
|
| 1808 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
| 1809 | - return (isset($this->_d[$priority])&&isset($this->_d[$priority][$key]))?$this->_d[$priority][$key]:null; |
|
| 1806 | + if ($priority === null) |
|
| 1807 | + $priority = $this->getDefaultPriority(); |
|
| 1808 | + $priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 1809 | + return (isset($this->_d[$priority]) && isset($this->_d[$priority][$key])) ? $this->_d[$priority][$key] : null; |
|
| 1810 | 1810 | } |
| 1811 | 1811 | } |
| 1812 | - public function setPriorityAt($key,$priority=null) |
|
| 1812 | + public function setPriorityAt($key, $priority = null) |
|
| 1813 | 1813 | { |
| 1814 | - if($priority===null) |
|
| 1815 | - $priority=$this->getDefaultPriority(); |
|
| 1816 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
| 1817 | - $oldpriority=$this->priorityAt($key); |
|
| 1818 | - if($oldpriority!==false&&$oldpriority!=$priority) { |
|
| 1819 | - $value=$this->remove($key,$oldpriority); |
|
| 1820 | - $this->add($key,$value,$priority); |
|
| 1814 | + if ($priority === null) |
|
| 1815 | + $priority = $this->getDefaultPriority(); |
|
| 1816 | + $priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 1817 | + $oldpriority = $this->priorityAt($key); |
|
| 1818 | + if ($oldpriority !== false && $oldpriority != $priority) { |
|
| 1819 | + $value = $this->remove($key, $oldpriority); |
|
| 1820 | + $this->add($key, $value, $priority); |
|
| 1821 | 1821 | } |
| 1822 | 1822 | return $oldpriority; |
| 1823 | 1823 | } |
| 1824 | - public function itemsAtPriority($priority=null) |
|
| 1824 | + public function itemsAtPriority($priority = null) |
|
| 1825 | 1825 | { |
| 1826 | - if($priority===null) |
|
| 1827 | - $priority=$this->getDefaultPriority(); |
|
| 1828 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
| 1829 | - return isset($this->_d[$priority])?$this->_d[$priority]:null; |
|
| 1826 | + if ($priority === null) |
|
| 1827 | + $priority = $this->getDefaultPriority(); |
|
| 1828 | + $priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 1829 | + return isset($this->_d[$priority]) ? $this->_d[$priority] : null; |
|
| 1830 | 1830 | } |
| 1831 | 1831 | public function priorityOf($item) |
| 1832 | 1832 | { |
| 1833 | 1833 | $this->sortPriorities(); |
| 1834 | - foreach($this->_d as $priority=>$items) |
|
| 1835 | - if(($index=array_search($item,$items,true))!==false) |
|
| 1834 | + foreach ($this->_d as $priority=>$items) |
|
| 1835 | + if (($index = array_search($item, $items, true)) !== false) |
|
| 1836 | 1836 | return $priority; |
| 1837 | 1837 | return false; |
| 1838 | 1838 | } |
| 1839 | 1839 | public function priorityAt($key) |
| 1840 | 1840 | { |
| 1841 | 1841 | $this->sortPriorities(); |
| 1842 | - foreach($this->_d as $priority=>$items) |
|
| 1843 | - if(array_key_exists($key,$items)) |
|
| 1842 | + foreach ($this->_d as $priority=>$items) |
|
| 1843 | + if (array_key_exists($key, $items)) |
|
| 1844 | 1844 | return $priority; |
| 1845 | 1845 | return false; |
| 1846 | 1846 | } |
| 1847 | - public function add($key,$value,$priority=null) |
|
| 1847 | + public function add($key, $value, $priority = null) |
|
| 1848 | 1848 | { |
| 1849 | - if($priority===null) |
|
| 1850 | - $priority=$this->getDefaultPriority(); |
|
| 1851 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
| 1852 | - if(!$this->_r) |
|
| 1849 | + if ($priority === null) |
|
| 1850 | + $priority = $this->getDefaultPriority(); |
|
| 1851 | + $priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 1852 | + if (!$this->_r) |
|
| 1853 | 1853 | { |
| 1854 | - foreach($this->_d as $innerpriority=>$items) |
|
| 1855 | - if(array_key_exists($key,$items)) |
|
| 1854 | + foreach ($this->_d as $innerpriority=>$items) |
|
| 1855 | + if (array_key_exists($key, $items)) |
|
| 1856 | 1856 | { |
| 1857 | 1857 | unset($this->_d[$innerpriority][$key]); |
| 1858 | 1858 | $this->_c--; |
| 1859 | - if(count($this->_d[$innerpriority])===0) |
|
| 1859 | + if (count($this->_d[$innerpriority]) === 0) |
|
| 1860 | 1860 | unset($this->_d[$innerpriority]); |
| 1861 | 1861 | } |
| 1862 | - if(!isset($this->_d[$priority])) { |
|
| 1863 | - $this->_d[$priority]=array($key=>$value); |
|
| 1864 | - $this->_o=false; |
|
| 1862 | + if (!isset($this->_d[$priority])) { |
|
| 1863 | + $this->_d[$priority] = array($key=>$value); |
|
| 1864 | + $this->_o = false; |
|
| 1865 | 1865 | } |
| 1866 | 1866 | else |
| 1867 | - $this->_d[$priority][$key]=$value; |
|
| 1867 | + $this->_d[$priority][$key] = $value; |
|
| 1868 | 1868 | $this->_c++; |
| 1869 | - $this->_fd=null; |
|
| 1869 | + $this->_fd = null; |
|
| 1870 | 1870 | } |
| 1871 | 1871 | else |
| 1872 | - throw new TInvalidOperationException('map_readonly',get_class($this)); |
|
| 1872 | + throw new TInvalidOperationException('map_readonly', get_class($this)); |
|
| 1873 | 1873 | return $priority; |
| 1874 | 1874 | } |
| 1875 | - public function remove($key,$priority=false) |
|
| 1875 | + public function remove($key, $priority = false) |
|
| 1876 | 1876 | { |
| 1877 | - if(!$this->_r) |
|
| 1877 | + if (!$this->_r) |
|
| 1878 | 1878 | { |
| 1879 | - if($priority===null) |
|
| 1880 | - $priority=$this->getDefaultPriority(); |
|
| 1881 | - if($priority===false) |
|
| 1879 | + if ($priority === null) |
|
| 1880 | + $priority = $this->getDefaultPriority(); |
|
| 1881 | + if ($priority === false) |
|
| 1882 | 1882 | { |
| 1883 | 1883 | $this->sortPriorities(); |
| 1884 | - foreach($this->_d as $priority=>$items) |
|
| 1885 | - if(array_key_exists($key,$items)) |
|
| 1884 | + foreach ($this->_d as $priority=>$items) |
|
| 1885 | + if (array_key_exists($key, $items)) |
|
| 1886 | 1886 | { |
| 1887 | - $value=$this->_d[$priority][$key]; |
|
| 1887 | + $value = $this->_d[$priority][$key]; |
|
| 1888 | 1888 | unset($this->_d[$priority][$key]); |
| 1889 | 1889 | $this->_c--; |
| 1890 | - if(count($this->_d[$priority])===0) |
|
| 1890 | + if (count($this->_d[$priority]) === 0) |
|
| 1891 | 1891 | { |
| 1892 | 1892 | unset($this->_d[$priority]); |
| 1893 | - $this->_o=false; |
|
| 1893 | + $this->_o = false; |
|
| 1894 | 1894 | } |
| 1895 | - $this->_fd=null; |
|
| 1895 | + $this->_fd = null; |
|
| 1896 | 1896 | return $value; |
| 1897 | 1897 | } |
| 1898 | 1898 | return null; |
| 1899 | 1899 | } |
| 1900 | 1900 | else |
| 1901 | 1901 | { |
| 1902 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
| 1903 | - if(isset($this->_d[$priority])&&(isset($this->_d[$priority][$key])||array_key_exists($key,$this->_d[$priority]))) |
|
| 1902 | + $priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
| 1903 | + if (isset($this->_d[$priority]) && (isset($this->_d[$priority][$key]) || array_key_exists($key, $this->_d[$priority]))) |
|
| 1904 | 1904 | { |
| 1905 | - $value=$this->_d[$priority][$key]; |
|
| 1905 | + $value = $this->_d[$priority][$key]; |
|
| 1906 | 1906 | unset($this->_d[$priority][$key]); |
| 1907 | 1907 | $this->_c--; |
| 1908 | - if(count($this->_d[$priority])===0) { |
|
| 1908 | + if (count($this->_d[$priority]) === 0) { |
|
| 1909 | 1909 | unset($this->_d[$priority]); |
| 1910 | - $this->_o=false; |
|
| 1910 | + $this->_o = false; |
|
| 1911 | 1911 | } |
| 1912 | - $this->_fd=null; |
|
| 1912 | + $this->_fd = null; |
|
| 1913 | 1913 | return $value; |
| 1914 | 1914 | } |
| 1915 | 1915 | else |
@@ -1917,85 +1917,85 @@ discard block |
||
| 1917 | 1917 | } |
| 1918 | 1918 | } |
| 1919 | 1919 | else |
| 1920 | - throw new TInvalidOperationException('map_readonly',get_class($this)); |
|
| 1920 | + throw new TInvalidOperationException('map_readonly', get_class($this)); |
|
| 1921 | 1921 | } |
| 1922 | 1922 | public function clear() |
| 1923 | 1923 | { |
| 1924 | - foreach($this->_d as $priority=>$items) |
|
| 1925 | - foreach(array_keys($items) as $key) |
|
| 1924 | + foreach ($this->_d as $priority=>$items) |
|
| 1925 | + foreach (array_keys($items) as $key) |
|
| 1926 | 1926 | $this->remove($key); |
| 1927 | 1927 | } |
| 1928 | 1928 | public function contains($key) |
| 1929 | 1929 | { |
| 1930 | - $map=$this->flattenPriorities(); |
|
| 1931 | - return isset($map[$key])||array_key_exists($key,$map); |
|
| 1930 | + $map = $this->flattenPriorities(); |
|
| 1931 | + return isset($map[$key]) || array_key_exists($key, $map); |
|
| 1932 | 1932 | } |
| 1933 | 1933 | public function toArray() |
| 1934 | 1934 | { |
| 1935 | 1935 | return $this->flattenPriorities(); |
| 1936 | 1936 | } |
| 1937 | - public function toArrayBelowPriority($priority,$inclusive=false) |
|
| 1937 | + public function toArrayBelowPriority($priority, $inclusive = false) |
|
| 1938 | 1938 | { |
| 1939 | 1939 | $this->sortPriorities(); |
| 1940 | - $items=array(); |
|
| 1941 | - foreach($this->_d as $itemspriority=>$itemsatpriority) |
|
| 1940 | + $items = array(); |
|
| 1941 | + foreach ($this->_d as $itemspriority=>$itemsatpriority) |
|
| 1942 | 1942 | { |
| 1943 | - if((!$inclusive&&$itemspriority>=$priority)||$itemspriority>$priority) |
|
| 1943 | + if ((!$inclusive && $itemspriority >= $priority) || $itemspriority > $priority) |
|
| 1944 | 1944 | break; |
| 1945 | - $items=array_merge($items,$itemsatpriority); |
|
| 1945 | + $items = array_merge($items, $itemsatpriority); |
|
| 1946 | 1946 | } |
| 1947 | 1947 | return $items; |
| 1948 | 1948 | } |
| 1949 | - public function toArrayAbovePriority($priority,$inclusive=true) |
|
| 1949 | + public function toArrayAbovePriority($priority, $inclusive = true) |
|
| 1950 | 1950 | { |
| 1951 | 1951 | $this->sortPriorities(); |
| 1952 | - $items=array(); |
|
| 1953 | - foreach($this->_d as $itemspriority=>$itemsatpriority) |
|
| 1952 | + $items = array(); |
|
| 1953 | + foreach ($this->_d as $itemspriority=>$itemsatpriority) |
|
| 1954 | 1954 | { |
| 1955 | - if((!$inclusive&&$itemspriority<=$priority)||$itemspriority<$priority) |
|
| 1955 | + if ((!$inclusive && $itemspriority <= $priority) || $itemspriority < $priority) |
|
| 1956 | 1956 | continue; |
| 1957 | - $items=array_merge($items,$itemsatpriority); |
|
| 1957 | + $items = array_merge($items, $itemsatpriority); |
|
| 1958 | 1958 | } |
| 1959 | 1959 | return $items; |
| 1960 | 1960 | } |
| 1961 | 1961 | public function copyFrom($data) |
| 1962 | 1962 | { |
| 1963 | - if($data instanceof TPriorityMap) |
|
| 1963 | + if ($data instanceof TPriorityMap) |
|
| 1964 | 1964 | { |
| 1965 | - if($this->getCount()>0) |
|
| 1965 | + if ($this->getCount() > 0) |
|
| 1966 | 1966 | $this->clear(); |
| 1967 | - foreach($data->getPriorities() as $priority) { |
|
| 1968 | - foreach($data->itemsAtPriority($priority) as $key => $value) { |
|
| 1969 | - $this->add($key,$value,$priority); |
|
| 1967 | + foreach ($data->getPriorities() as $priority) { |
|
| 1968 | + foreach ($data->itemsAtPriority($priority) as $key => $value) { |
|
| 1969 | + $this->add($key, $value, $priority); |
|
| 1970 | 1970 | } |
| 1971 | 1971 | } |
| 1972 | 1972 | } |
| 1973 | - else if(is_array($data)||$data instanceof Traversable) |
|
| 1973 | + else if (is_array($data) || $data instanceof Traversable) |
|
| 1974 | 1974 | { |
| 1975 | - if($this->getCount()>0) |
|
| 1975 | + if ($this->getCount() > 0) |
|
| 1976 | 1976 | $this->clear(); |
| 1977 | - foreach($data as $key=>$value) |
|
| 1978 | - $this->add($key,$value); |
|
| 1977 | + foreach ($data as $key=>$value) |
|
| 1978 | + $this->add($key, $value); |
|
| 1979 | 1979 | } |
| 1980 | - else if($data!==null) |
|
| 1980 | + else if ($data !== null) |
|
| 1981 | 1981 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
| 1982 | 1982 | } |
| 1983 | 1983 | public function mergeWith($data) |
| 1984 | 1984 | { |
| 1985 | - if($data instanceof TPriorityMap) |
|
| 1985 | + if ($data instanceof TPriorityMap) |
|
| 1986 | 1986 | { |
| 1987 | - foreach($data->getPriorities() as $priority) |
|
| 1987 | + foreach ($data->getPriorities() as $priority) |
|
| 1988 | 1988 | { |
| 1989 | - foreach($data->itemsAtPriority($priority) as $key => $value) |
|
| 1990 | - $this->add($key,$value,$priority); |
|
| 1989 | + foreach ($data->itemsAtPriority($priority) as $key => $value) |
|
| 1990 | + $this->add($key, $value, $priority); |
|
| 1991 | 1991 | } |
| 1992 | 1992 | } |
| 1993 | - else if(is_array($data)||$data instanceof Traversable) |
|
| 1993 | + else if (is_array($data) || $data instanceof Traversable) |
|
| 1994 | 1994 | { |
| 1995 | - foreach($data as $key=>$value) |
|
| 1996 | - $this->add($key,$value); |
|
| 1995 | + foreach ($data as $key=>$value) |
|
| 1996 | + $this->add($key, $value); |
|
| 1997 | 1997 | } |
| 1998 | - else if($data!==null) |
|
| 1998 | + else if ($data !== null) |
|
| 1999 | 1999 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
| 2000 | 2000 | } |
| 2001 | 2001 | public function offsetExists($offset) |
@@ -2006,22 +2006,22 @@ discard block |
||
| 2006 | 2006 | { |
| 2007 | 2007 | return $this->itemAt($offset); |
| 2008 | 2008 | } |
| 2009 | - public function offsetSet($offset,$item) |
|
| 2009 | + public function offsetSet($offset, $item) |
|
| 2010 | 2010 | { |
| 2011 | - $this->add($offset,$item); |
|
| 2011 | + $this->add($offset, $item); |
|
| 2012 | 2012 | } |
| 2013 | 2013 | public function offsetUnset($offset) |
| 2014 | 2014 | { |
| 2015 | 2015 | $this->remove($offset); |
| 2016 | 2016 | } |
| 2017 | 2017 | } |
| 2018 | -class TStack extends TComponent implements IteratorAggregate,Countable |
|
| 2018 | +class TStack extends TComponent implements IteratorAggregate, Countable |
|
| 2019 | 2019 | { |
| 2020 | - private $_d=array(); |
|
| 2021 | - private $_c=0; |
|
| 2022 | - public function __construct($data=null) |
|
| 2020 | + private $_d = array(); |
|
| 2021 | + private $_c = 0; |
|
| 2022 | + public function __construct($data = null) |
|
| 2023 | 2023 | { |
| 2024 | - if($data!==null) |
|
| 2024 | + if ($data !== null) |
|
| 2025 | 2025 | $this->copyFrom($data); |
| 2026 | 2026 | } |
| 2027 | 2027 | public function toArray() |
@@ -2030,37 +2030,37 @@ discard block |
||
| 2030 | 2030 | } |
| 2031 | 2031 | public function copyFrom($data) |
| 2032 | 2032 | { |
| 2033 | - if(is_array($data) || ($data instanceof Traversable)) |
|
| 2033 | + if (is_array($data) || ($data instanceof Traversable)) |
|
| 2034 | 2034 | { |
| 2035 | 2035 | $this->clear(); |
| 2036 | - foreach($data as $item) |
|
| 2036 | + foreach ($data as $item) |
|
| 2037 | 2037 | { |
| 2038 | - $this->_d[]=$item; |
|
| 2038 | + $this->_d[] = $item; |
|
| 2039 | 2039 | ++$this->_c; |
| 2040 | 2040 | } |
| 2041 | 2041 | } |
| 2042 | - else if($data!==null) |
|
| 2042 | + else if ($data !== null) |
|
| 2043 | 2043 | throw new TInvalidDataTypeException('stack_data_not_iterable'); |
| 2044 | 2044 | } |
| 2045 | 2045 | public function clear() |
| 2046 | 2046 | { |
| 2047 | - $this->_c=0; |
|
| 2048 | - $this->_d=array(); |
|
| 2047 | + $this->_c = 0; |
|
| 2048 | + $this->_d = array(); |
|
| 2049 | 2049 | } |
| 2050 | 2050 | public function contains($item) |
| 2051 | 2051 | { |
| 2052 | - return array_search($item,$this->_d,true)!==false; |
|
| 2052 | + return array_search($item, $this->_d, true) !== false; |
|
| 2053 | 2053 | } |
| 2054 | 2054 | public function peek() |
| 2055 | 2055 | { |
| 2056 | - if($this->_c===0) |
|
| 2056 | + if ($this->_c === 0) |
|
| 2057 | 2057 | throw new TInvalidOperationException('stack_empty'); |
| 2058 | 2058 | else |
| 2059 | - return $this->_d[$this->_c-1]; |
|
| 2059 | + return $this->_d[$this->_c - 1]; |
|
| 2060 | 2060 | } |
| 2061 | 2061 | public function pop() |
| 2062 | 2062 | { |
| 2063 | - if($this->_c===0) |
|
| 2063 | + if ($this->_c === 0) |
|
| 2064 | 2064 | throw new TInvalidOperationException('stack_empty'); |
| 2065 | 2065 | else |
| 2066 | 2066 | { |
@@ -2075,7 +2075,7 @@ discard block |
||
| 2075 | 2075 | } |
| 2076 | 2076 | public function getIterator() |
| 2077 | 2077 | { |
| 2078 | - return new ArrayIterator( $this->_d ); |
|
| 2078 | + return new ArrayIterator($this->_d); |
|
| 2079 | 2079 | } |
| 2080 | 2080 | public function getCount() |
| 2081 | 2081 | { |
@@ -2093,13 +2093,13 @@ discard block |
||
| 2093 | 2093 | private $_c; |
| 2094 | 2094 | public function __construct(&$data) |
| 2095 | 2095 | { |
| 2096 | - $this->_d=&$data; |
|
| 2097 | - $this->_i=0; |
|
| 2098 | - $this->_c=count($this->_d); |
|
| 2096 | + $this->_d = &$data; |
|
| 2097 | + $this->_i = 0; |
|
| 2098 | + $this->_c = count($this->_d); |
|
| 2099 | 2099 | } |
| 2100 | 2100 | public function rewind() |
| 2101 | 2101 | { |
| 2102 | - $this->_i=0; |
|
| 2102 | + $this->_i = 0; |
|
| 2103 | 2103 | } |
| 2104 | 2104 | public function key() |
| 2105 | 2105 | { |
@@ -2115,16 +2115,16 @@ discard block |
||
| 2115 | 2115 | } |
| 2116 | 2116 | public function valid() |
| 2117 | 2117 | { |
| 2118 | - return $this->_i<$this->_c; |
|
| 2118 | + return $this->_i < $this->_c; |
|
| 2119 | 2119 | } |
| 2120 | 2120 | } |
| 2121 | 2121 | class TXmlElement extends TComponent |
| 2122 | 2122 | { |
| 2123 | - private $_parent=null; |
|
| 2124 | - private $_tagName='unknown'; |
|
| 2125 | - private $_value=''; |
|
| 2126 | - private $_elements=null; |
|
| 2127 | - private $_attributes=null; |
|
| 2123 | + private $_parent = null; |
|
| 2124 | + private $_tagName = 'unknown'; |
|
| 2125 | + private $_value = ''; |
|
| 2126 | + private $_elements = null; |
|
| 2127 | + private $_attributes = null; |
|
| 2128 | 2128 | public function __construct($tagName) |
| 2129 | 2129 | { |
| 2130 | 2130 | $this->setTagName($tagName); |
@@ -2135,7 +2135,7 @@ discard block |
||
| 2135 | 2135 | } |
| 2136 | 2136 | public function setParent($parent) |
| 2137 | 2137 | { |
| 2138 | - $this->_parent=$parent; |
|
| 2138 | + $this->_parent = $parent; |
|
| 2139 | 2139 | } |
| 2140 | 2140 | public function getTagName() |
| 2141 | 2141 | { |
@@ -2143,7 +2143,7 @@ discard block |
||
| 2143 | 2143 | } |
| 2144 | 2144 | public function setTagName($tagName) |
| 2145 | 2145 | { |
| 2146 | - $this->_tagName=$tagName; |
|
| 2146 | + $this->_tagName = $tagName; |
|
| 2147 | 2147 | } |
| 2148 | 2148 | public function getValue() |
| 2149 | 2149 | { |
@@ -2151,87 +2151,87 @@ discard block |
||
| 2151 | 2151 | } |
| 2152 | 2152 | public function setValue($value) |
| 2153 | 2153 | { |
| 2154 | - $this->_value=TPropertyValue::ensureString($value); |
|
| 2154 | + $this->_value = TPropertyValue::ensureString($value); |
|
| 2155 | 2155 | } |
| 2156 | 2156 | public function getHasElement() |
| 2157 | 2157 | { |
| 2158 | - return $this->_elements!==null && $this->_elements->getCount()>0; |
|
| 2158 | + return $this->_elements !== null && $this->_elements->getCount() > 0; |
|
| 2159 | 2159 | } |
| 2160 | 2160 | public function getHasAttribute() |
| 2161 | 2161 | { |
| 2162 | - return $this->_attributes!==null && $this->_attributes->getCount()>0; |
|
| 2162 | + return $this->_attributes !== null && $this->_attributes->getCount() > 0; |
|
| 2163 | 2163 | } |
| 2164 | 2164 | public function getAttribute($name) |
| 2165 | 2165 | { |
| 2166 | - if($this->_attributes!==null) |
|
| 2166 | + if ($this->_attributes !== null) |
|
| 2167 | 2167 | return $this->_attributes->itemAt($name); |
| 2168 | 2168 | else |
| 2169 | 2169 | return null; |
| 2170 | 2170 | } |
| 2171 | - public function setAttribute($name,$value) |
|
| 2171 | + public function setAttribute($name, $value) |
|
| 2172 | 2172 | { |
| 2173 | - $this->getAttributes()->add($name,TPropertyValue::ensureString($value)); |
|
| 2173 | + $this->getAttributes()->add($name, TPropertyValue::ensureString($value)); |
|
| 2174 | 2174 | } |
| 2175 | 2175 | public function getElements() |
| 2176 | 2176 | { |
| 2177 | - if(!$this->_elements) |
|
| 2178 | - $this->_elements=new TXmlElementList($this); |
|
| 2177 | + if (!$this->_elements) |
|
| 2178 | + $this->_elements = new TXmlElementList($this); |
|
| 2179 | 2179 | return $this->_elements; |
| 2180 | 2180 | } |
| 2181 | 2181 | public function getAttributes() |
| 2182 | 2182 | { |
| 2183 | - if(!$this->_attributes) |
|
| 2184 | - $this->_attributes=new TMap; |
|
| 2183 | + if (!$this->_attributes) |
|
| 2184 | + $this->_attributes = new TMap; |
|
| 2185 | 2185 | return $this->_attributes; |
| 2186 | 2186 | } |
| 2187 | 2187 | public function getElementByTagName($tagName) |
| 2188 | 2188 | { |
| 2189 | - if($this->_elements) |
|
| 2189 | + if ($this->_elements) |
|
| 2190 | 2190 | { |
| 2191 | - foreach($this->_elements as $element) |
|
| 2192 | - if($element->_tagName===$tagName) |
|
| 2191 | + foreach ($this->_elements as $element) |
|
| 2192 | + if ($element->_tagName === $tagName) |
|
| 2193 | 2193 | return $element; |
| 2194 | 2194 | } |
| 2195 | 2195 | return null; |
| 2196 | 2196 | } |
| 2197 | 2197 | public function getElementsByTagName($tagName) |
| 2198 | 2198 | { |
| 2199 | - $list=new TList; |
|
| 2200 | - if($this->_elements) |
|
| 2199 | + $list = new TList; |
|
| 2200 | + if ($this->_elements) |
|
| 2201 | 2201 | { |
| 2202 | - foreach($this->_elements as $element) |
|
| 2203 | - if($element->_tagName===$tagName) |
|
| 2202 | + foreach ($this->_elements as $element) |
|
| 2203 | + if ($element->_tagName === $tagName) |
|
| 2204 | 2204 | $list->add($element); |
| 2205 | 2205 | } |
| 2206 | 2206 | return $list; |
| 2207 | 2207 | } |
| 2208 | - public function toString($indent=0) |
|
| 2208 | + public function toString($indent = 0) |
|
| 2209 | 2209 | { |
| 2210 | - $attr=''; |
|
| 2211 | - if($this->_attributes!==null) |
|
| 2210 | + $attr = ''; |
|
| 2211 | + if ($this->_attributes !== null) |
|
| 2212 | 2212 | { |
| 2213 | - foreach($this->_attributes as $name=>$value) |
|
| 2213 | + foreach ($this->_attributes as $name=>$value) |
|
| 2214 | 2214 | { |
| 2215 | - $value=$this->xmlEncode($value); |
|
| 2216 | - $attr.=" $name=\"$value\""; |
|
| 2215 | + $value = $this->xmlEncode($value); |
|
| 2216 | + $attr .= " $name=\"$value\""; |
|
| 2217 | 2217 | } |
| 2218 | 2218 | } |
| 2219 | - $prefix=str_repeat(' ',$indent*4); |
|
| 2220 | - if($this->getHasElement()) |
|
| 2219 | + $prefix = str_repeat(' ', $indent * 4); |
|
| 2220 | + if ($this->getHasElement()) |
|
| 2221 | 2221 | { |
| 2222 | - $str=$prefix."<{$this->_tagName}$attr>\n"; |
|
| 2223 | - foreach($this->getElements() as $element) |
|
| 2224 | - $str.=$element->toString($indent+1)."\n"; |
|
| 2225 | - $str.=$prefix."</{$this->_tagName}>"; |
|
| 2222 | + $str = $prefix . "<{$this->_tagName}$attr>\n"; |
|
| 2223 | + foreach ($this->getElements() as $element) |
|
| 2224 | + $str .= $element->toString($indent + 1) . "\n"; |
|
| 2225 | + $str .= $prefix . "</{$this->_tagName}>"; |
|
| 2226 | 2226 | return $str; |
| 2227 | 2227 | } |
| 2228 | - else if(($value=$this->getValue())!=='') |
|
| 2228 | + else if (($value = $this->getValue()) !== '') |
|
| 2229 | 2229 | { |
| 2230 | - $value=$this->xmlEncode($value); |
|
| 2231 | - return $prefix."<{$this->_tagName}$attr>$value</{$this->_tagName}>"; |
|
| 2230 | + $value = $this->xmlEncode($value); |
|
| 2231 | + return $prefix . "<{$this->_tagName}$attr>$value</{$this->_tagName}>"; |
|
| 2232 | 2232 | } |
| 2233 | 2233 | else |
| 2234 | - return $prefix."<{$this->_tagName}$attr />"; |
|
| 2234 | + return $prefix . "<{$this->_tagName}$attr />"; |
|
| 2235 | 2235 | } |
| 2236 | 2236 | public function __toString() |
| 2237 | 2237 | { |
@@ -2239,7 +2239,7 @@ discard block |
||
| 2239 | 2239 | } |
| 2240 | 2240 | private function xmlEncode($str) |
| 2241 | 2241 | { |
| 2242 | - return strtr($str,array( |
|
| 2242 | + return strtr($str, array( |
|
| 2243 | 2243 | '>'=>'>', |
| 2244 | 2244 | '<'=>'<', |
| 2245 | 2245 | '&'=>'&', |
@@ -2253,7 +2253,7 @@ discard block |
||
| 2253 | 2253 | { |
| 2254 | 2254 | private $_version; |
| 2255 | 2255 | private $_encoding; |
| 2256 | - public function __construct($version='1.0',$encoding='') |
|
| 2256 | + public function __construct($version = '1.0', $encoding = '') |
|
| 2257 | 2257 | { |
| 2258 | 2258 | parent::__construct(''); |
| 2259 | 2259 | $this->setVersion($version); |
@@ -2265,7 +2265,7 @@ discard block |
||
| 2265 | 2265 | } |
| 2266 | 2266 | public function setVersion($version) |
| 2267 | 2267 | { |
| 2268 | - $this->_version=$version; |
|
| 2268 | + $this->_version = $version; |
|
| 2269 | 2269 | } |
| 2270 | 2270 | public function getEncoding() |
| 2271 | 2271 | { |
@@ -2273,69 +2273,69 @@ discard block |
||
| 2273 | 2273 | } |
| 2274 | 2274 | public function setEncoding($encoding) |
| 2275 | 2275 | { |
| 2276 | - $this->_encoding=$encoding; |
|
| 2276 | + $this->_encoding = $encoding; |
|
| 2277 | 2277 | } |
| 2278 | 2278 | public function loadFromFile($file) |
| 2279 | 2279 | { |
| 2280 | - if(($str=@file_get_contents($file))!==false) |
|
| 2280 | + if (($str = @file_get_contents($file)) !== false) |
|
| 2281 | 2281 | return $this->loadFromString($str); |
| 2282 | 2282 | else |
| 2283 | - throw new TIOException('xmldocument_file_read_failed',$file); |
|
| 2283 | + throw new TIOException('xmldocument_file_read_failed', $file); |
|
| 2284 | 2284 | } |
| 2285 | 2285 | public function loadFromString($string) |
| 2286 | 2286 | { |
| 2287 | - $doc=new DOMDocument(); |
|
| 2288 | - if($doc->loadXML($string)===false) |
|
| 2287 | + $doc = new DOMDocument(); |
|
| 2288 | + if ($doc->loadXML($string) === false) |
|
| 2289 | 2289 | return false; |
| 2290 | 2290 | $this->setEncoding($doc->encoding); |
| 2291 | 2291 | $this->setVersion($doc->xmlVersion); |
| 2292 | - $element=$doc->documentElement; |
|
| 2292 | + $element = $doc->documentElement; |
|
| 2293 | 2293 | $this->setTagName($element->tagName); |
| 2294 | 2294 | $this->setValue($element->nodeValue); |
| 2295 | - $elements=$this->getElements(); |
|
| 2296 | - $attributes=$this->getAttributes(); |
|
| 2295 | + $elements = $this->getElements(); |
|
| 2296 | + $attributes = $this->getAttributes(); |
|
| 2297 | 2297 | $elements->clear(); |
| 2298 | 2298 | $attributes->clear(); |
| 2299 | 2299 | static $bSimpleXml; |
| 2300 | - if($bSimpleXml === null) |
|
| 2301 | - $bSimpleXml = (boolean)function_exists('simplexml_load_string'); |
|
| 2302 | - if($bSimpleXml) |
|
| 2300 | + if ($bSimpleXml === null) |
|
| 2301 | + $bSimpleXml = (boolean) function_exists('simplexml_load_string'); |
|
| 2302 | + if ($bSimpleXml) |
|
| 2303 | 2303 | { |
| 2304 | 2304 | $simpleDoc = simplexml_load_string($string); |
| 2305 | 2305 | $docNamespaces = $simpleDoc->getDocNamespaces(false); |
| 2306 | 2306 | $simpleDoc = null; |
| 2307 | - foreach($docNamespaces as $prefix => $uri) |
|
| 2307 | + foreach ($docNamespaces as $prefix => $uri) |
|
| 2308 | 2308 | { |
| 2309 | - if($prefix === '') |
|
| 2309 | + if ($prefix === '') |
|
| 2310 | 2310 | $attributes->add('xmlns', $uri); |
| 2311 | 2311 | else |
| 2312 | - $attributes->add('xmlns:'.$prefix, $uri); |
|
| 2312 | + $attributes->add('xmlns:' . $prefix, $uri); |
|
| 2313 | 2313 | } |
| 2314 | 2314 | } |
| 2315 | - foreach($element->attributes as $name=>$attr) |
|
| 2316 | - $attributes->add(($attr->prefix === '' ? '' : $attr->prefix . ':') .$name,$attr->value); |
|
| 2317 | - foreach($element->childNodes as $child) |
|
| 2315 | + foreach ($element->attributes as $name=>$attr) |
|
| 2316 | + $attributes->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name, $attr->value); |
|
| 2317 | + foreach ($element->childNodes as $child) |
|
| 2318 | 2318 | { |
| 2319 | - if($child instanceof DOMElement) |
|
| 2319 | + if ($child instanceof DOMElement) |
|
| 2320 | 2320 | $elements->add($this->buildElement($child)); |
| 2321 | 2321 | } |
| 2322 | 2322 | return true; |
| 2323 | 2323 | } |
| 2324 | 2324 | public function saveToFile($file) |
| 2325 | 2325 | { |
| 2326 | - if(($fw=fopen($file,'w'))!==false) |
|
| 2326 | + if (($fw = fopen($file, 'w')) !== false) |
|
| 2327 | 2327 | { |
| 2328 | - fwrite($fw,$this->saveToString()); |
|
| 2328 | + fwrite($fw, $this->saveToString()); |
|
| 2329 | 2329 | fclose($fw); |
| 2330 | 2330 | } |
| 2331 | 2331 | else |
| 2332 | - throw new TIOException('xmldocument_file_write_failed',$file); |
|
| 2332 | + throw new TIOException('xmldocument_file_write_failed', $file); |
|
| 2333 | 2333 | } |
| 2334 | 2334 | public function saveToString() |
| 2335 | 2335 | { |
| 2336 | - $version=empty($this->_version)?' version="1.0"':' version="'.$this->_version.'"'; |
|
| 2337 | - $encoding=empty($this->_encoding)?'':' encoding="'.$this->_encoding.'"'; |
|
| 2338 | - return "<?xml{$version}{$encoding}?>\n".$this->toString(0); |
|
| 2336 | + $version = empty($this->_version) ? ' version="1.0"' : ' version="' . $this->_version . '"'; |
|
| 2337 | + $encoding = empty($this->_encoding) ? '' : ' encoding="' . $this->_encoding . '"'; |
|
| 2338 | + return "<?xml{$version}{$encoding}?>\n" . $this->toString(0); |
|
| 2339 | 2339 | } |
| 2340 | 2340 | public function __toString() |
| 2341 | 2341 | { |
@@ -2343,13 +2343,13 @@ discard block |
||
| 2343 | 2343 | } |
| 2344 | 2344 | protected function buildElement($node) |
| 2345 | 2345 | { |
| 2346 | - $element=new TXmlElement($node->tagName); |
|
| 2346 | + $element = new TXmlElement($node->tagName); |
|
| 2347 | 2347 | $element->setValue($node->nodeValue); |
| 2348 | - foreach($node->attributes as $name=>$attr) |
|
| 2349 | - $element->getAttributes()->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name,$attr->value); |
|
| 2350 | - foreach($node->childNodes as $child) |
|
| 2348 | + foreach ($node->attributes as $name=>$attr) |
|
| 2349 | + $element->getAttributes()->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name, $attr->value); |
|
| 2350 | + foreach ($node->childNodes as $child) |
|
| 2351 | 2351 | { |
| 2352 | - if($child instanceof DOMElement) |
|
| 2352 | + if ($child instanceof DOMElement) |
|
| 2353 | 2353 | $element->getElements()->add($this->buildElement($child)); |
| 2354 | 2354 | } |
| 2355 | 2355 | return $element; |
@@ -2360,18 +2360,18 @@ discard block |
||
| 2360 | 2360 | private $_o; |
| 2361 | 2361 | public function __construct(TXmlElement $owner) |
| 2362 | 2362 | { |
| 2363 | - $this->_o=$owner; |
|
| 2363 | + $this->_o = $owner; |
|
| 2364 | 2364 | } |
| 2365 | 2365 | protected function getOwner() |
| 2366 | 2366 | { |
| 2367 | 2367 | return $this->_o; |
| 2368 | 2368 | } |
| 2369 | - public function insertAt($index,$item) |
|
| 2369 | + public function insertAt($index, $item) |
|
| 2370 | 2370 | { |
| 2371 | - if($item instanceof TXmlElement) |
|
| 2371 | + if ($item instanceof TXmlElement) |
|
| 2372 | 2372 | { |
| 2373 | - parent::insertAt($index,$item); |
|
| 2374 | - if($item->getParent()!==null) |
|
| 2373 | + parent::insertAt($index, $item); |
|
| 2374 | + if ($item->getParent() !== null) |
|
| 2375 | 2375 | $item->getParent()->getElements()->remove($item); |
| 2376 | 2376 | $item->setParent($this->_o); |
| 2377 | 2377 | } |
@@ -2380,8 +2380,8 @@ discard block |
||
| 2380 | 2380 | } |
| 2381 | 2381 | public function removeAt($index) |
| 2382 | 2382 | { |
| 2383 | - $item=parent::removeAt($index); |
|
| 2384 | - if($item instanceof TXmlElement) |
|
| 2383 | + $item = parent::removeAt($index); |
|
| 2384 | + if ($item instanceof TXmlElement) |
|
| 2385 | 2385 | $item->setParent(null); |
| 2386 | 2386 | return $item; |
| 2387 | 2387 | } |
@@ -2396,57 +2396,57 @@ discard block |
||
| 2396 | 2396 | private $_everyone; |
| 2397 | 2397 | private $_guest; |
| 2398 | 2398 | private $_authenticated; |
| 2399 | - public function __construct($action,$users,$roles,$verb='',$ipRules='') |
|
| 2400 | - { |
|
| 2401 | - $action=strtolower(trim($action)); |
|
| 2402 | - if($action==='allow' || $action==='deny') |
|
| 2403 | - $this->_action=$action; |
|
| 2404 | - else |
|
| 2405 | - throw new TInvalidDataValueException('authorizationrule_action_invalid',$action); |
|
| 2406 | - $this->_users=array(); |
|
| 2407 | - $this->_roles=array(); |
|
| 2408 | - $this->_ipRules=array(); |
|
| 2409 | - $this->_everyone=false; |
|
| 2410 | - $this->_guest=false; |
|
| 2411 | - $this->_authenticated=false; |
|
| 2412 | - if(trim($users)==='') |
|
| 2413 | - $users='*'; |
|
| 2414 | - foreach(explode(',',$users) as $user) |
|
| 2415 | - { |
|
| 2416 | - if(($user=trim(strtolower($user)))!=='') |
|
| 2417 | - { |
|
| 2418 | - if($user==='*') |
|
| 2399 | + public function __construct($action, $users, $roles, $verb = '', $ipRules = '') |
|
| 2400 | + { |
|
| 2401 | + $action = strtolower(trim($action)); |
|
| 2402 | + if ($action === 'allow' || $action === 'deny') |
|
| 2403 | + $this->_action = $action; |
|
| 2404 | + else |
|
| 2405 | + throw new TInvalidDataValueException('authorizationrule_action_invalid', $action); |
|
| 2406 | + $this->_users = array(); |
|
| 2407 | + $this->_roles = array(); |
|
| 2408 | + $this->_ipRules = array(); |
|
| 2409 | + $this->_everyone = false; |
|
| 2410 | + $this->_guest = false; |
|
| 2411 | + $this->_authenticated = false; |
|
| 2412 | + if (trim($users) === '') |
|
| 2413 | + $users = '*'; |
|
| 2414 | + foreach (explode(',', $users) as $user) |
|
| 2415 | + { |
|
| 2416 | + if (($user = trim(strtolower($user))) !== '') |
|
| 2417 | + { |
|
| 2418 | + if ($user === '*') |
|
| 2419 | 2419 | { |
| 2420 | - $this->_everyone=true; |
|
| 2420 | + $this->_everyone = true; |
|
| 2421 | 2421 | break; |
| 2422 | 2422 | } |
| 2423 | - else if($user==='?') |
|
| 2424 | - $this->_guest=true; |
|
| 2425 | - else if($user==='@') |
|
| 2426 | - $this->_authenticated=true; |
|
| 2423 | + else if ($user === '?') |
|
| 2424 | + $this->_guest = true; |
|
| 2425 | + else if ($user === '@') |
|
| 2426 | + $this->_authenticated = true; |
|
| 2427 | 2427 | else |
| 2428 | - $this->_users[]=$user; |
|
| 2428 | + $this->_users[] = $user; |
|
| 2429 | 2429 | } |
| 2430 | 2430 | } |
| 2431 | - if(trim($roles)==='') |
|
| 2432 | - $roles='*'; |
|
| 2433 | - foreach(explode(',',$roles) as $role) |
|
| 2431 | + if (trim($roles) === '') |
|
| 2432 | + $roles = '*'; |
|
| 2433 | + foreach (explode(',', $roles) as $role) |
|
| 2434 | 2434 | { |
| 2435 | - if(($role=trim(strtolower($role)))!=='') |
|
| 2436 | - $this->_roles[]=$role; |
|
| 2435 | + if (($role = trim(strtolower($role))) !== '') |
|
| 2436 | + $this->_roles[] = $role; |
|
| 2437 | 2437 | } |
| 2438 | - if(($verb=trim(strtolower($verb)))==='') |
|
| 2439 | - $verb='*'; |
|
| 2440 | - if($verb==='*' || $verb==='get' || $verb==='post') |
|
| 2441 | - $this->_verb=$verb; |
|
| 2438 | + if (($verb = trim(strtolower($verb))) === '') |
|
| 2439 | + $verb = '*'; |
|
| 2440 | + if ($verb === '*' || $verb === 'get' || $verb === 'post') |
|
| 2441 | + $this->_verb = $verb; |
|
| 2442 | 2442 | else |
| 2443 | - throw new TInvalidDataValueException('authorizationrule_verb_invalid',$verb); |
|
| 2444 | - if(trim($ipRules)==='') |
|
| 2445 | - $ipRules='*'; |
|
| 2446 | - foreach(explode(',',$ipRules) as $ipRule) |
|
| 2443 | + throw new TInvalidDataValueException('authorizationrule_verb_invalid', $verb); |
|
| 2444 | + if (trim($ipRules) === '') |
|
| 2445 | + $ipRules = '*'; |
|
| 2446 | + foreach (explode(',', $ipRules) as $ipRule) |
|
| 2447 | 2447 | { |
| 2448 | - if(($ipRule=trim($ipRule))!=='') |
|
| 2449 | - $this->_ipRules[]=$ipRule; |
|
| 2448 | + if (($ipRule = trim($ipRule)) !== '') |
|
| 2449 | + $this->_ipRules[] = $ipRule; |
|
| 2450 | 2450 | } |
| 2451 | 2451 | } |
| 2452 | 2452 | public function getAction() |
@@ -2481,63 +2481,63 @@ discard block |
||
| 2481 | 2481 | { |
| 2482 | 2482 | return $this->_authenticated || $this->_everyone; |
| 2483 | 2483 | } |
| 2484 | - public function isUserAllowed(IUser $user,$verb,$ip) |
|
| 2484 | + public function isUserAllowed(IUser $user, $verb, $ip) |
|
| 2485 | 2485 | { |
| 2486 | - if($this->isVerbMatched($verb) && $this->isIpMatched($ip) && $this->isUserMatched($user) && $this->isRoleMatched($user)) |
|
| 2487 | - return ($this->_action==='allow')?1:-1; |
|
| 2486 | + if ($this->isVerbMatched($verb) && $this->isIpMatched($ip) && $this->isUserMatched($user) && $this->isRoleMatched($user)) |
|
| 2487 | + return ($this->_action === 'allow') ? 1 : -1; |
|
| 2488 | 2488 | else |
| 2489 | 2489 | return 0; |
| 2490 | 2490 | } |
| 2491 | 2491 | private function isIpMatched($ip) |
| 2492 | 2492 | { |
| 2493 | - if(empty($this->_ipRules)) |
|
| 2493 | + if (empty($this->_ipRules)) |
|
| 2494 | 2494 | return 1; |
| 2495 | - foreach($this->_ipRules as $rule) |
|
| 2495 | + foreach ($this->_ipRules as $rule) |
|
| 2496 | 2496 | { |
| 2497 | - if($rule==='*' || $rule===$ip || (($pos=strpos($rule,'*'))!==false && strncmp($ip,$rule,$pos)===0)) |
|
| 2497 | + if ($rule === '*' || $rule === $ip || (($pos = strpos($rule, '*')) !== false && strncmp($ip, $rule, $pos) === 0)) |
|
| 2498 | 2498 | return 1; |
| 2499 | 2499 | } |
| 2500 | 2500 | return 0; |
| 2501 | 2501 | } |
| 2502 | 2502 | private function isUserMatched($user) |
| 2503 | 2503 | { |
| 2504 | - return ($this->_everyone || ($this->_guest && $user->getIsGuest()) || ($this->_authenticated && !$user->getIsGuest()) || in_array(strtolower($user->getName()),$this->_users)); |
|
| 2504 | + return ($this->_everyone || ($this->_guest && $user->getIsGuest()) || ($this->_authenticated && !$user->getIsGuest()) || in_array(strtolower($user->getName()), $this->_users)); |
|
| 2505 | 2505 | } |
| 2506 | 2506 | private function isRoleMatched($user) |
| 2507 | 2507 | { |
| 2508 | - foreach($this->_roles as $role) |
|
| 2508 | + foreach ($this->_roles as $role) |
|
| 2509 | 2509 | { |
| 2510 | - if($role==='*' || $user->isInRole($role)) |
|
| 2510 | + if ($role === '*' || $user->isInRole($role)) |
|
| 2511 | 2511 | return true; |
| 2512 | 2512 | } |
| 2513 | 2513 | return false; |
| 2514 | 2514 | } |
| 2515 | 2515 | private function isVerbMatched($verb) |
| 2516 | 2516 | { |
| 2517 | - return ($this->_verb==='*' || strcasecmp($verb,$this->_verb)===0); |
|
| 2517 | + return ($this->_verb === '*' || strcasecmp($verb, $this->_verb) === 0); |
|
| 2518 | 2518 | } |
| 2519 | 2519 | } |
| 2520 | 2520 | class TAuthorizationRuleCollection extends TList |
| 2521 | 2521 | { |
| 2522 | - public function isUserAllowed($user,$verb,$ip) |
|
| 2522 | + public function isUserAllowed($user, $verb, $ip) |
|
| 2523 | 2523 | { |
| 2524 | - if($user instanceof IUser) |
|
| 2524 | + if ($user instanceof IUser) |
|
| 2525 | 2525 | { |
| 2526 | - $verb=strtolower(trim($verb)); |
|
| 2527 | - foreach($this as $rule) |
|
| 2526 | + $verb = strtolower(trim($verb)); |
|
| 2527 | + foreach ($this as $rule) |
|
| 2528 | 2528 | { |
| 2529 | - if(($decision=$rule->isUserAllowed($user,$verb,$ip))!==0) |
|
| 2530 | - return ($decision>0); |
|
| 2529 | + if (($decision = $rule->isUserAllowed($user, $verb, $ip)) !== 0) |
|
| 2530 | + return ($decision > 0); |
|
| 2531 | 2531 | } |
| 2532 | 2532 | return true; |
| 2533 | 2533 | } |
| 2534 | 2534 | else |
| 2535 | 2535 | return false; |
| 2536 | 2536 | } |
| 2537 | - public function insertAt($index,$item) |
|
| 2537 | + public function insertAt($index, $item) |
|
| 2538 | 2538 | { |
| 2539 | - if($item instanceof TAuthorizationRule) |
|
| 2540 | - parent::insertAt($index,$item); |
|
| 2539 | + if ($item instanceof TAuthorizationRule) |
|
| 2540 | + parent::insertAt($index, $item); |
|
| 2541 | 2541 | else |
| 2542 | 2542 | throw new TInvalidDataTypeException('authorizationrulecollection_authorizationrule_required'); |
| 2543 | 2543 | } |
@@ -2553,17 +2553,17 @@ discard block |
||
| 2553 | 2553 | private $_mbstring; |
| 2554 | 2554 | public function init($config) |
| 2555 | 2555 | { |
| 2556 | - $this->_mbstring=extension_loaded('mbstring'); |
|
| 2556 | + $this->_mbstring = extension_loaded('mbstring'); |
|
| 2557 | 2557 | $this->getApplication()->setSecurityManager($this); |
| 2558 | 2558 | } |
| 2559 | 2559 | protected function generateRandomKey() |
| 2560 | 2560 | { |
| 2561 | - return sprintf('%08x%08x%08x%08x',mt_rand(),mt_rand(),mt_rand(),mt_rand()); |
|
| 2561 | + return sprintf('%08x%08x%08x%08x', mt_rand(), mt_rand(), mt_rand(), mt_rand()); |
|
| 2562 | 2562 | } |
| 2563 | 2563 | public function getValidationKey() |
| 2564 | 2564 | { |
| 2565 | - if(null === $this->_validationKey) { |
|
| 2566 | - if(null === ($this->_validationKey = $this->getApplication()->getGlobalState(self::STATE_VALIDATION_KEY))) { |
|
| 2565 | + if (null === $this->_validationKey) { |
|
| 2566 | + if (null === ($this->_validationKey = $this->getApplication()->getGlobalState(self::STATE_VALIDATION_KEY))) { |
|
| 2567 | 2567 | $this->_validationKey = $this->generateRandomKey(); |
| 2568 | 2568 | $this->getApplication()->setGlobalState(self::STATE_VALIDATION_KEY, $this->_validationKey, null, true); |
| 2569 | 2569 | } |
@@ -2572,14 +2572,14 @@ discard block |
||
| 2572 | 2572 | } |
| 2573 | 2573 | public function setValidationKey($value) |
| 2574 | 2574 | { |
| 2575 | - if('' === $value) |
|
| 2575 | + if ('' === $value) |
|
| 2576 | 2576 | throw new TInvalidDataValueException('securitymanager_validationkey_invalid'); |
| 2577 | 2577 | $this->_validationKey = $value; |
| 2578 | 2578 | } |
| 2579 | 2579 | public function getEncryptionKey() |
| 2580 | 2580 | { |
| 2581 | - if(null === $this->_encryptionKey) { |
|
| 2582 | - if(null === ($this->_encryptionKey = $this->getApplication()->getGlobalState(self::STATE_ENCRYPTION_KEY))) { |
|
| 2581 | + if (null === $this->_encryptionKey) { |
|
| 2582 | + if (null === ($this->_encryptionKey = $this->getApplication()->getGlobalState(self::STATE_ENCRYPTION_KEY))) { |
|
| 2583 | 2583 | $this->_encryptionKey = $this->generateRandomKey(); |
| 2584 | 2584 | $this->getApplication()->setGlobalState(self::STATE_ENCRYPTION_KEY, $this->_encryptionKey, null, true); |
| 2585 | 2585 | } |
@@ -2588,7 +2588,7 @@ discard block |
||
| 2588 | 2588 | } |
| 2589 | 2589 | public function setEncryptionKey($value) |
| 2590 | 2590 | { |
| 2591 | - if('' === $value) |
|
| 2591 | + if ('' === $value) |
|
| 2592 | 2592 | throw new TInvalidDataValueException('securitymanager_encryptionkey_invalid'); |
| 2593 | 2593 | $this->_encryptionKey = $value; |
| 2594 | 2594 | } |
@@ -2610,7 +2610,7 @@ discard block |
||
| 2610 | 2610 | } |
| 2611 | 2611 | public function getEncryption() |
| 2612 | 2612 | { |
| 2613 | - if(is_string($this->_cryptAlgorithm)) |
|
| 2613 | + if (is_string($this->_cryptAlgorithm)) |
|
| 2614 | 2614 | return $this->_cryptAlgorithm; |
| 2615 | 2615 | return "3DES"; |
| 2616 | 2616 | } |
@@ -2628,19 +2628,19 @@ discard block |
||
| 2628 | 2628 | } |
| 2629 | 2629 | public function encrypt($data) |
| 2630 | 2630 | { |
| 2631 | - $module=$this->openCryptModule(); |
|
| 2631 | + $module = $this->openCryptModule(); |
|
| 2632 | 2632 | $key = $this->substr(md5($this->getEncryptionKey()), 0, mcrypt_enc_get_key_size($module)); |
| 2633 | 2633 | srand(); |
| 2634 | 2634 | $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($module), MCRYPT_RAND); |
| 2635 | 2635 | mcrypt_generic_init($module, $key, $iv); |
| 2636 | - $encrypted = $iv.mcrypt_generic($module, $data); |
|
| 2636 | + $encrypted = $iv . mcrypt_generic($module, $data); |
|
| 2637 | 2637 | mcrypt_generic_deinit($module); |
| 2638 | 2638 | mcrypt_module_close($module); |
| 2639 | 2639 | return $encrypted; |
| 2640 | 2640 | } |
| 2641 | 2641 | public function decrypt($data) |
| 2642 | 2642 | { |
| 2643 | - $module=$this->openCryptModule(); |
|
| 2643 | + $module = $this->openCryptModule(); |
|
| 2644 | 2644 | $key = $this->substr(md5($this->getEncryptionKey()), 0, mcrypt_enc_get_key_size($module)); |
| 2645 | 2645 | $ivSize = mcrypt_enc_get_iv_size($module); |
| 2646 | 2646 | $iv = $this->substr($data, 0, $ivSize); |
@@ -2652,13 +2652,13 @@ discard block |
||
| 2652 | 2652 | } |
| 2653 | 2653 | protected function openCryptModule() |
| 2654 | 2654 | { |
| 2655 | - if(extension_loaded('mcrypt')) |
|
| 2655 | + if (extension_loaded('mcrypt')) |
|
| 2656 | 2656 | { |
| 2657 | - if(is_array($this->_cryptAlgorithm)) |
|
| 2658 | - $module=@call_user_func_array('mcrypt_module_open',$this->_cryptAlgorithm); |
|
| 2657 | + if (is_array($this->_cryptAlgorithm)) |
|
| 2658 | + $module = @call_user_func_array('mcrypt_module_open', $this->_cryptAlgorithm); |
|
| 2659 | 2659 | else |
| 2660 | - $module=@mcrypt_module_open($this->_cryptAlgorithm,'', MCRYPT_MODE_CBC,''); |
|
| 2661 | - if($module===false) |
|
| 2660 | + $module = @mcrypt_module_open($this->_cryptAlgorithm, '', MCRYPT_MODE_CBC, ''); |
|
| 2661 | + if ($module === false) |
|
| 2662 | 2662 | throw new TNotSupportedException('securitymanager_mcryptextension_initfailed'); |
| 2663 | 2663 | return $module; |
| 2664 | 2664 | } |
@@ -2668,23 +2668,23 @@ discard block |
||
| 2668 | 2668 | public function hashData($data) |
| 2669 | 2669 | { |
| 2670 | 2670 | $hmac = $this->computeHMAC($data); |
| 2671 | - return $hmac.$data; |
|
| 2671 | + return $hmac . $data; |
|
| 2672 | 2672 | } |
| 2673 | 2673 | public function validateData($data) |
| 2674 | 2674 | { |
| 2675 | - $len=$this->strlen($this->computeHMAC('test')); |
|
| 2676 | - if($this->strlen($data) < $len) |
|
| 2675 | + $len = $this->strlen($this->computeHMAC('test')); |
|
| 2676 | + if ($this->strlen($data) < $len) |
|
| 2677 | 2677 | return false; |
| 2678 | 2678 | $hmac = $this->substr($data, 0, $len); |
| 2679 | - $data2=$this->substr($data, $len, $this->strlen($data)); |
|
| 2679 | + $data2 = $this->substr($data, $len, $this->strlen($data)); |
|
| 2680 | 2680 | return $hmac === $this->computeHMAC($data2) ? $data2 : false; |
| 2681 | 2681 | } |
| 2682 | 2682 | protected function computeHMAC($data) |
| 2683 | 2683 | { |
| 2684 | 2684 | $key = $this->getValidationKey(); |
| 2685 | - if(function_exists('hash_hmac')) |
|
| 2685 | + if (function_exists('hash_hmac')) |
|
| 2686 | 2686 | return hash_hmac($this->_hashAlgorithm, $data, $key); |
| 2687 | - if(!strcasecmp($this->_hashAlgorithm,'sha1')) |
|
| 2687 | + if (!strcasecmp($this->_hashAlgorithm, 'sha1')) |
|
| 2688 | 2688 | { |
| 2689 | 2689 | $pack = 'H40'; |
| 2690 | 2690 | $func = 'sha1'; |
@@ -2697,11 +2697,11 @@ discard block |
||
| 2697 | 2697 | } |
| 2698 | 2698 | private function strlen($string) |
| 2699 | 2699 | { |
| 2700 | - return $this->_mbstring ? mb_strlen($string,'8bit') : strlen($string); |
|
| 2700 | + return $this->_mbstring ? mb_strlen($string, '8bit') : strlen($string); |
|
| 2701 | 2701 | } |
| 2702 | - private function substr($string,$start,$length) |
|
| 2702 | + private function substr($string, $start, $length) |
|
| 2703 | 2703 | { |
| 2704 | - return $this->_mbstring ? mb_substr($string,$start,$length,'8bit') : substr($string,$start,$length); |
|
| 2704 | + return $this->_mbstring ? mb_substr($string, $start, $length, '8bit') : substr($string, $start, $length); |
|
| 2705 | 2705 | } |
| 2706 | 2706 | } |
| 2707 | 2707 | class TSecurityManagerValidationMode extends TEnumerable |
@@ -2711,46 +2711,46 @@ discard block |
||
| 2711 | 2711 | } |
| 2712 | 2712 | class THttpUtility |
| 2713 | 2713 | { |
| 2714 | - private static $_encodeTable=array('<'=>'<','>'=>'>','"'=>'"'); |
|
| 2715 | - private static $_decodeTable=array('<'=>'<','>'=>'>','"'=>'"'); |
|
| 2716 | - private static $_stripTable=array('<'=>'','>'=>'','"'=>''); |
|
| 2714 | + private static $_encodeTable = array('<'=>'<', '>'=>'>', '"'=>'"'); |
|
| 2715 | + private static $_decodeTable = array('<'=>'<', '>'=>'>', '"'=>'"'); |
|
| 2716 | + private static $_stripTable = array('<'=>'', '>'=>'', '"'=>''); |
|
| 2717 | 2717 | public static function htmlEncode($s) |
| 2718 | 2718 | { |
| 2719 | - return strtr($s,self::$_encodeTable); |
|
| 2719 | + return strtr($s, self::$_encodeTable); |
|
| 2720 | 2720 | } |
| 2721 | 2721 | public static function htmlDecode($s) |
| 2722 | 2722 | { |
| 2723 | - return strtr($s,self::$_decodeTable); |
|
| 2723 | + return strtr($s, self::$_decodeTable); |
|
| 2724 | 2724 | } |
| 2725 | 2725 | public static function htmlStrip($s) |
| 2726 | 2726 | { |
| 2727 | - return strtr($s,self::$_stripTable); |
|
| 2727 | + return strtr($s, self::$_stripTable); |
|
| 2728 | 2728 | } |
| 2729 | 2729 | } |
| 2730 | 2730 | class TJavaScript |
| 2731 | 2731 | { |
| 2732 | 2732 | public static function renderScriptFiles($files) |
| 2733 | 2733 | { |
| 2734 | - $str=''; |
|
| 2735 | - foreach($files as $file) |
|
| 2736 | - $str.= self::renderScriptFile($file); |
|
| 2734 | + $str = ''; |
|
| 2735 | + foreach ($files as $file) |
|
| 2736 | + $str .= self::renderScriptFile($file); |
|
| 2737 | 2737 | return $str; |
| 2738 | 2738 | } |
| 2739 | 2739 | public static function renderScriptFile($file) |
| 2740 | 2740 | { |
| 2741 | - return '<script type="text/javascript" src="'.THttpUtility::htmlEncode($file)."\"></script>\n"; |
|
| 2741 | + return '<script type="text/javascript" src="' . THttpUtility::htmlEncode($file) . "\"></script>\n"; |
|
| 2742 | 2742 | } |
| 2743 | 2743 | public static function renderScriptBlocks($scripts) |
| 2744 | 2744 | { |
| 2745 | - if(count($scripts)) |
|
| 2746 | - return "<script type=\"text/javascript\">\n/*<![CDATA[*/\n".implode("\n",$scripts)."\n/*]]>*/\n</script>\n"; |
|
| 2745 | + if (count($scripts)) |
|
| 2746 | + return "<script type=\"text/javascript\">\n/*<![CDATA[*/\n" . implode("\n", $scripts) . "\n/*]]>*/\n</script>\n"; |
|
| 2747 | 2747 | else |
| 2748 | 2748 | return ''; |
| 2749 | 2749 | } |
| 2750 | 2750 | public static function renderScriptBlocksCallback($scripts) |
| 2751 | 2751 | { |
| 2752 | - if(count($scripts)) |
|
| 2753 | - return implode("\n",$scripts)."\n"; |
|
| 2752 | + if (count($scripts)) |
|
| 2753 | + return implode("\n", $scripts) . "\n"; |
|
| 2754 | 2754 | else |
| 2755 | 2755 | return ''; |
| 2756 | 2756 | } |
@@ -2760,11 +2760,11 @@ discard block |
||
| 2760 | 2760 | } |
| 2761 | 2761 | public static function quoteString($js) |
| 2762 | 2762 | { |
| 2763 | - return self::jsonEncode($js,JSON_HEX_QUOT | JSON_HEX_APOS | JSON_HEX_TAG); |
|
| 2763 | + return self::jsonEncode($js, JSON_HEX_QUOT | JSON_HEX_APOS | JSON_HEX_TAG); |
|
| 2764 | 2764 | } |
| 2765 | 2765 | public static function quoteJsLiteral($js) |
| 2766 | 2766 | { |
| 2767 | - if($js instanceof TJavaScriptLiteral) |
|
| 2767 | + if ($js instanceof TJavaScriptLiteral) |
|
| 2768 | 2768 | return $js; |
| 2769 | 2769 | else |
| 2770 | 2770 | return new TJavaScriptLiteral($js); |
@@ -2781,47 +2781,47 @@ discard block |
||
| 2781 | 2781 | { |
| 2782 | 2782 | return self::isJsLiteral($js); |
| 2783 | 2783 | } |
| 2784 | - public static function encode($value,$toMap=true,$encodeEmptyStrings=false) |
|
| 2784 | + public static function encode($value, $toMap = true, $encodeEmptyStrings = false) |
|
| 2785 | 2785 | { |
| 2786 | - if(is_string($value)) |
|
| 2786 | + if (is_string($value)) |
|
| 2787 | 2787 | return self::quoteString($value); |
| 2788 | - else if(is_bool($value)) |
|
| 2789 | - return $value?'true':'false'; |
|
| 2790 | - else if(is_array($value)) |
|
| 2788 | + else if (is_bool($value)) |
|
| 2789 | + return $value ? 'true' : 'false'; |
|
| 2790 | + else if (is_array($value)) |
|
| 2791 | 2791 | { |
| 2792 | - $results=''; |
|
| 2793 | - if(($n=count($value))>0 && array_keys($value)!==range(0,$n-1)) |
|
| 2792 | + $results = ''; |
|
| 2793 | + if (($n = count($value)) > 0 && array_keys($value) !== range(0, $n - 1)) |
|
| 2794 | 2794 | { |
| 2795 | - foreach($value as $k=>$v) |
|
| 2795 | + foreach ($value as $k=>$v) |
|
| 2796 | 2796 | { |
| 2797 | - if($v!=='' || $encodeEmptyStrings) |
|
| 2797 | + if ($v !== '' || $encodeEmptyStrings) |
|
| 2798 | 2798 | { |
| 2799 | - if($results!=='') |
|
| 2800 | - $results.=','; |
|
| 2801 | - $results.="'$k':".self::encode($v,$toMap,$encodeEmptyStrings); |
|
| 2799 | + if ($results !== '') |
|
| 2800 | + $results .= ','; |
|
| 2801 | + $results .= "'$k':" . self::encode($v, $toMap, $encodeEmptyStrings); |
|
| 2802 | 2802 | } |
| 2803 | 2803 | } |
| 2804 | - return '{'.$results.'}'; |
|
| 2804 | + return '{' . $results . '}'; |
|
| 2805 | 2805 | } |
| 2806 | 2806 | else |
| 2807 | 2807 | { |
| 2808 | - foreach($value as $v) |
|
| 2808 | + foreach ($value as $v) |
|
| 2809 | 2809 | { |
| 2810 | - if($v!=='' || $encodeEmptyStrings) |
|
| 2810 | + if ($v !== '' || $encodeEmptyStrings) |
|
| 2811 | 2811 | { |
| 2812 | - if($results!=='') |
|
| 2813 | - $results.=','; |
|
| 2814 | - $results.=self::encode($v,$toMap, $encodeEmptyStrings); |
|
| 2812 | + if ($results !== '') |
|
| 2813 | + $results .= ','; |
|
| 2814 | + $results .= self::encode($v, $toMap, $encodeEmptyStrings); |
|
| 2815 | 2815 | } |
| 2816 | 2816 | } |
| 2817 | - return '['.$results.']'; |
|
| 2817 | + return '[' . $results . ']'; |
|
| 2818 | 2818 | } |
| 2819 | 2819 | } |
| 2820 | - else if(is_integer($value)) |
|
| 2820 | + else if (is_integer($value)) |
|
| 2821 | 2821 | return "$value"; |
| 2822 | - else if(is_float($value)) |
|
| 2822 | + else if (is_float($value)) |
|
| 2823 | 2823 | { |
| 2824 | - switch($value) |
|
| 2824 | + switch ($value) |
|
| 2825 | 2825 | { |
| 2826 | 2826 | case -INF: |
| 2827 | 2827 | return 'Number.NEGATIVE_INFINITY'; |
@@ -2830,46 +2830,46 @@ discard block |
||
| 2830 | 2830 | return 'Number.POSITIVE_INFINITY'; |
| 2831 | 2831 | break; |
| 2832 | 2832 | default: |
| 2833 | - $locale=localeConv(); |
|
| 2834 | - if($locale['decimal_point']=='.') |
|
| 2833 | + $locale = localeConv(); |
|
| 2834 | + if ($locale['decimal_point'] == '.') |
|
| 2835 | 2835 | return "$value"; |
| 2836 | 2836 | else |
| 2837 | 2837 | return str_replace($locale['decimal_point'], '.', "$value"); |
| 2838 | 2838 | break; |
| 2839 | 2839 | } |
| 2840 | 2840 | } |
| 2841 | - else if(is_object($value)) |
|
| 2841 | + else if (is_object($value)) |
|
| 2842 | 2842 | if ($value instanceof TJavaScriptLiteral) |
| 2843 | 2843 | return $value->toJavaScriptLiteral(); |
| 2844 | 2844 | else |
| 2845 | - return self::encode(get_object_vars($value),$toMap); |
|
| 2846 | - else if($value===null) |
|
| 2845 | + return self::encode(get_object_vars($value), $toMap); |
|
| 2846 | + else if ($value === null) |
|
| 2847 | 2847 | return 'null'; |
| 2848 | 2848 | else |
| 2849 | 2849 | return ''; |
| 2850 | 2850 | } |
| 2851 | 2851 | public static function jsonEncode($value, $options = 0) |
| 2852 | 2852 | { |
| 2853 | - if (($g=Prado::getApplication()->getGlobalization(false))!==null && |
|
| 2854 | - strtoupper($enc=$g->getCharset())!='UTF-8') { |
|
| 2853 | + if (($g = Prado::getApplication()->getGlobalization(false)) !== null && |
|
| 2854 | + strtoupper($enc = $g->getCharset()) != 'UTF-8') { |
|
| 2855 | 2855 | self::convertToUtf8($value, $enc); |
| 2856 | 2856 | } |
| 2857 | - $s = @json_encode($value,$options); |
|
| 2857 | + $s = @json_encode($value, $options); |
|
| 2858 | 2858 | self::checkJsonError(); |
| 2859 | 2859 | return $s; |
| 2860 | 2860 | } |
| 2861 | 2861 | private static function convertToUtf8(&$value, $sourceEncoding) { |
| 2862 | - if(is_string($value)) |
|
| 2863 | - $value=iconv($sourceEncoding, 'UTF-8', $value); |
|
| 2862 | + if (is_string($value)) |
|
| 2863 | + $value = iconv($sourceEncoding, 'UTF-8', $value); |
|
| 2864 | 2864 | else if (is_array($value)) |
| 2865 | 2865 | { |
| 2866 | - foreach($value as &$element) |
|
| 2866 | + foreach ($value as &$element) |
|
| 2867 | 2867 | self::convertToUtf8($element, $sourceEncoding); |
| 2868 | 2868 | } |
| 2869 | 2869 | } |
| 2870 | 2870 | public static function jsonDecode($value, $assoc = false, $depth = 512) |
| 2871 | 2871 | { |
| 2872 | - $s= @json_decode($value, $assoc, $depth); |
|
| 2872 | + $s = @json_decode($value, $assoc, $depth); |
|
| 2873 | 2873 | self::checkJsonError(); |
| 2874 | 2874 | return $s; |
| 2875 | 2875 | } |
@@ -2909,77 +2909,77 @@ discard block |
||
| 2909 | 2909 | } |
| 2910 | 2910 | class TUrlManager extends TModule |
| 2911 | 2911 | { |
| 2912 | - public function constructUrl($serviceID,$serviceParam,$getItems,$encodeAmpersand,$encodeGetItems) |
|
| 2912 | + public function constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems) |
|
| 2913 | 2913 | { |
| 2914 | - $url=$serviceID.'='.urlencode($serviceParam); |
|
| 2915 | - $amp=$encodeAmpersand?'&':'&'; |
|
| 2916 | - $request=$this->getRequest(); |
|
| 2917 | - if(is_array($getItems) || $getItems instanceof Traversable) |
|
| 2914 | + $url = $serviceID . '=' . urlencode($serviceParam); |
|
| 2915 | + $amp = $encodeAmpersand ? '&' : '&'; |
|
| 2916 | + $request = $this->getRequest(); |
|
| 2917 | + if (is_array($getItems) || $getItems instanceof Traversable) |
|
| 2918 | 2918 | { |
| 2919 | - if($encodeGetItems) |
|
| 2919 | + if ($encodeGetItems) |
|
| 2920 | 2920 | { |
| 2921 | - foreach($getItems as $name=>$value) |
|
| 2921 | + foreach ($getItems as $name=>$value) |
|
| 2922 | 2922 | { |
| 2923 | - if(is_array($value)) |
|
| 2923 | + if (is_array($value)) |
|
| 2924 | 2924 | { |
| 2925 | - $name=urlencode($name.'[]'); |
|
| 2926 | - foreach($value as $v) |
|
| 2927 | - $url.=$amp.$name.'='.urlencode($v); |
|
| 2925 | + $name = urlencode($name . '[]'); |
|
| 2926 | + foreach ($value as $v) |
|
| 2927 | + $url .= $amp . $name . '=' . urlencode($v); |
|
| 2928 | 2928 | } |
| 2929 | 2929 | else |
| 2930 | - $url.=$amp.urlencode($name).'='.urlencode($value); |
|
| 2930 | + $url .= $amp . urlencode($name) . '=' . urlencode($value); |
|
| 2931 | 2931 | } |
| 2932 | 2932 | } |
| 2933 | 2933 | else |
| 2934 | 2934 | { |
| 2935 | - foreach($getItems as $name=>$value) |
|
| 2935 | + foreach ($getItems as $name=>$value) |
|
| 2936 | 2936 | { |
| 2937 | - if(is_array($value)) |
|
| 2937 | + if (is_array($value)) |
|
| 2938 | 2938 | { |
| 2939 | - foreach($value as $v) |
|
| 2940 | - $url.=$amp.$name.'[]='.$v; |
|
| 2939 | + foreach ($value as $v) |
|
| 2940 | + $url .= $amp . $name . '[]=' . $v; |
|
| 2941 | 2941 | } |
| 2942 | 2942 | else |
| 2943 | - $url.=$amp.$name.'='.$value; |
|
| 2943 | + $url .= $amp . $name . '=' . $value; |
|
| 2944 | 2944 | } |
| 2945 | 2945 | } |
| 2946 | 2946 | } |
| 2947 | - switch($request->getUrlFormat()) |
|
| 2947 | + switch ($request->getUrlFormat()) |
|
| 2948 | 2948 | { |
| 2949 | 2949 | case THttpRequestUrlFormat::Path: |
| 2950 | - return $request->getApplicationUrl().'/'.strtr($url,array($amp=>'/','?'=>'/','='=>$request->getUrlParamSeparator())); |
|
| 2950 | + return $request->getApplicationUrl() . '/' . strtr($url, array($amp=>'/', '?'=>'/', '='=>$request->getUrlParamSeparator())); |
|
| 2951 | 2951 | case THttpRequestUrlFormat::HiddenPath: |
| 2952 | - return rtrim(dirname($request->getApplicationUrl()), '/').'/'.strtr($url,array($amp=>'/','?'=>'/','='=>$request->getUrlParamSeparator())); |
|
| 2952 | + return rtrim(dirname($request->getApplicationUrl()), '/') . '/' . strtr($url, array($amp=>'/', '?'=>'/', '='=>$request->getUrlParamSeparator())); |
|
| 2953 | 2953 | default: |
| 2954 | - return $request->getApplicationUrl().'?'.$url; |
|
| 2954 | + return $request->getApplicationUrl() . '?' . $url; |
|
| 2955 | 2955 | } |
| 2956 | 2956 | } |
| 2957 | 2957 | public function parseUrl() |
| 2958 | 2958 | { |
| 2959 | - $request=$this->getRequest(); |
|
| 2960 | - $pathInfo=trim($request->getPathInfo(),'/'); |
|
| 2961 | - if(($request->getUrlFormat()===THttpRequestUrlFormat::Path || |
|
| 2962 | - $request->getUrlFormat()===THttpRequestUrlFormat::HiddenPath) && |
|
| 2963 | - $pathInfo!=='') |
|
| 2959 | + $request = $this->getRequest(); |
|
| 2960 | + $pathInfo = trim($request->getPathInfo(), '/'); |
|
| 2961 | + if (($request->getUrlFormat() === THttpRequestUrlFormat::Path || |
|
| 2962 | + $request->getUrlFormat() === THttpRequestUrlFormat::HiddenPath) && |
|
| 2963 | + $pathInfo !== '') |
|
| 2964 | 2964 | { |
| 2965 | - $separator=$request->getUrlParamSeparator(); |
|
| 2966 | - $paths=explode('/',$pathInfo); |
|
| 2967 | - $getVariables=array(); |
|
| 2968 | - foreach($paths as $path) |
|
| 2965 | + $separator = $request->getUrlParamSeparator(); |
|
| 2966 | + $paths = explode('/', $pathInfo); |
|
| 2967 | + $getVariables = array(); |
|
| 2968 | + foreach ($paths as $path) |
|
| 2969 | 2969 | { |
| 2970 | - if(($path=trim($path))!=='') |
|
| 2970 | + if (($path = trim($path)) !== '') |
|
| 2971 | 2971 | { |
| 2972 | - if(($pos=strpos($path,$separator))!==false) |
|
| 2972 | + if (($pos = strpos($path, $separator)) !== false) |
|
| 2973 | 2973 | { |
| 2974 | - $name=substr($path,0,$pos); |
|
| 2975 | - $value=substr($path,$pos+1); |
|
| 2976 | - if(($pos=strpos($name,'[]'))!==false) |
|
| 2977 | - $getVariables[substr($name,0,$pos)][]=$value; |
|
| 2974 | + $name = substr($path, 0, $pos); |
|
| 2975 | + $value = substr($path, $pos + 1); |
|
| 2976 | + if (($pos = strpos($name, '[]')) !== false) |
|
| 2977 | + $getVariables[substr($name, 0, $pos)][] = $value; |
|
| 2978 | 2978 | else |
| 2979 | - $getVariables[$name]=$value; |
|
| 2979 | + $getVariables[$name] = $value; |
|
| 2980 | 2980 | } |
| 2981 | 2981 | else |
| 2982 | - $getVariables[$path]=''; |
|
| 2982 | + $getVariables[$path] = ''; |
|
| 2983 | 2983 | } |
| 2984 | 2984 | } |
| 2985 | 2985 | return $getVariables; |
@@ -2988,91 +2988,91 @@ discard block |
||
| 2988 | 2988 | return array(); |
| 2989 | 2989 | } |
| 2990 | 2990 | } |
| 2991 | -class THttpRequest extends TApplicationComponent implements IteratorAggregate,ArrayAccess,Countable,IModule |
|
| 2991 | +class THttpRequest extends TApplicationComponent implements IteratorAggregate, ArrayAccess, Countable, IModule |
|
| 2992 | 2992 | { |
| 2993 | - const CGIFIX__PATH_INFO = 1; |
|
| 2994 | - const CGIFIX__SCRIPT_NAME = 2; |
|
| 2995 | - private $_urlManager=null; |
|
| 2996 | - private $_urlManagerID=''; |
|
| 2997 | - private $_separator=','; |
|
| 2998 | - private $_serviceID=null; |
|
| 2999 | - private $_serviceParam=null; |
|
| 3000 | - private $_cookies=null; |
|
| 2993 | + const CGIFIX__PATH_INFO = 1; |
|
| 2994 | + const CGIFIX__SCRIPT_NAME = 2; |
|
| 2995 | + private $_urlManager = null; |
|
| 2996 | + private $_urlManagerID = ''; |
|
| 2997 | + private $_separator = ','; |
|
| 2998 | + private $_serviceID = null; |
|
| 2999 | + private $_serviceParam = null; |
|
| 3000 | + private $_cookies = null; |
|
| 3001 | 3001 | private $_requestUri; |
| 3002 | 3002 | private $_pathInfo; |
| 3003 | - private $_cookieOnly=null; |
|
| 3004 | - private $_urlFormat=THttpRequestUrlFormat::Get; |
|
| 3003 | + private $_cookieOnly = null; |
|
| 3004 | + private $_urlFormat = THttpRequestUrlFormat::Get; |
|
| 3005 | 3005 | private $_services; |
| 3006 | - private $_requestResolved=false; |
|
| 3007 | - private $_enableCookieValidation=false; |
|
| 3008 | - private $_cgiFix=0; |
|
| 3009 | - private $_enableCache=false; |
|
| 3010 | - private $_url=null; |
|
| 3006 | + private $_requestResolved = false; |
|
| 3007 | + private $_enableCookieValidation = false; |
|
| 3008 | + private $_cgiFix = 0; |
|
| 3009 | + private $_enableCache = false; |
|
| 3010 | + private $_url = null; |
|
| 3011 | 3011 | private $_id; |
| 3012 | - private $_items=array(); |
|
| 3012 | + private $_items = array(); |
|
| 3013 | 3013 | public function getID() |
| 3014 | 3014 | { |
| 3015 | 3015 | return $this->_id; |
| 3016 | 3016 | } |
| 3017 | 3017 | public function setID($value) |
| 3018 | 3018 | { |
| 3019 | - $this->_id=$value; |
|
| 3019 | + $this->_id = $value; |
|
| 3020 | 3020 | } |
| 3021 | 3021 | public function init($config) |
| 3022 | 3022 | { |
| 3023 | - if(php_sapi_name()==='cli') |
|
| 3024 | - { |
|
| 3025 | - $_SERVER['REMOTE_ADDR']='127.0.0.1'; |
|
| 3026 | - $_SERVER['REQUEST_METHOD']='GET'; |
|
| 3027 | - $_SERVER['SERVER_NAME']='localhost'; |
|
| 3028 | - $_SERVER['SERVER_PORT']=80; |
|
| 3029 | - $_SERVER['HTTP_USER_AGENT']=''; |
|
| 3030 | - } |
|
| 3031 | - if(isset($_SERVER['REQUEST_URI'])) |
|
| 3032 | - $this->_requestUri=$_SERVER['REQUEST_URI']; |
|
| 3033 | - else $this->_requestUri=$_SERVER['SCRIPT_NAME'].(empty($_SERVER['QUERY_STRING'])?'':'?'.$_SERVER['QUERY_STRING']); |
|
| 3034 | - if($this->_cgiFix&self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO'])) |
|
| 3035 | - $this->_pathInfo=substr($_SERVER['ORIG_PATH_INFO'], strlen($_SERVER['SCRIPT_NAME'])); |
|
| 3036 | - elseif(isset($_SERVER['PATH_INFO'])) |
|
| 3037 | - $this->_pathInfo=$_SERVER['PATH_INFO']; |
|
| 3038 | - else if(strpos($_SERVER['PHP_SELF'],$_SERVER['SCRIPT_NAME'])===0 && $_SERVER['PHP_SELF']!==$_SERVER['SCRIPT_NAME']) |
|
| 3039 | - $this->_pathInfo=substr($_SERVER['PHP_SELF'],strlen($_SERVER['SCRIPT_NAME'])); |
|
| 3040 | - else |
|
| 3041 | - $this->_pathInfo=''; |
|
| 3042 | - if(get_magic_quotes_gpc()) |
|
| 3043 | - { |
|
| 3044 | - if(isset($_GET)) |
|
| 3045 | - $_GET=$this->stripSlashes($_GET); |
|
| 3046 | - if(isset($_POST)) |
|
| 3047 | - $_POST=$this->stripSlashes($_POST); |
|
| 3048 | - if(isset($_REQUEST)) |
|
| 3049 | - $_REQUEST=$this->stripSlashes($_REQUEST); |
|
| 3050 | - if(isset($_COOKIE)) |
|
| 3051 | - $_COOKIE=$this->stripSlashes($_COOKIE); |
|
| 3023 | + if (php_sapi_name() === 'cli') |
|
| 3024 | + { |
|
| 3025 | + $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; |
|
| 3026 | + $_SERVER['REQUEST_METHOD'] = 'GET'; |
|
| 3027 | + $_SERVER['SERVER_NAME'] = 'localhost'; |
|
| 3028 | + $_SERVER['SERVER_PORT'] = 80; |
|
| 3029 | + $_SERVER['HTTP_USER_AGENT'] = ''; |
|
| 3030 | + } |
|
| 3031 | + if (isset($_SERVER['REQUEST_URI'])) |
|
| 3032 | + $this->_requestUri = $_SERVER['REQUEST_URI']; |
|
| 3033 | + else $this->_requestUri = $_SERVER['SCRIPT_NAME'] . (empty($_SERVER['QUERY_STRING']) ? '' : '?' . $_SERVER['QUERY_STRING']); |
|
| 3034 | + if ($this->_cgiFix & self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO'])) |
|
| 3035 | + $this->_pathInfo = substr($_SERVER['ORIG_PATH_INFO'], strlen($_SERVER['SCRIPT_NAME'])); |
|
| 3036 | + elseif (isset($_SERVER['PATH_INFO'])) |
|
| 3037 | + $this->_pathInfo = $_SERVER['PATH_INFO']; |
|
| 3038 | + else if (strpos($_SERVER['PHP_SELF'], $_SERVER['SCRIPT_NAME']) === 0 && $_SERVER['PHP_SELF'] !== $_SERVER['SCRIPT_NAME']) |
|
| 3039 | + $this->_pathInfo = substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME'])); |
|
| 3040 | + else |
|
| 3041 | + $this->_pathInfo = ''; |
|
| 3042 | + if (get_magic_quotes_gpc()) |
|
| 3043 | + { |
|
| 3044 | + if (isset($_GET)) |
|
| 3045 | + $_GET = $this->stripSlashes($_GET); |
|
| 3046 | + if (isset($_POST)) |
|
| 3047 | + $_POST = $this->stripSlashes($_POST); |
|
| 3048 | + if (isset($_REQUEST)) |
|
| 3049 | + $_REQUEST = $this->stripSlashes($_REQUEST); |
|
| 3050 | + if (isset($_COOKIE)) |
|
| 3051 | + $_COOKIE = $this->stripSlashes($_COOKIE); |
|
| 3052 | 3052 | } |
| 3053 | 3053 | $this->getApplication()->setRequest($this); |
| 3054 | 3054 | } |
| 3055 | 3055 | public function stripSlashes(&$data) |
| 3056 | 3056 | { |
| 3057 | - return is_array($data)?array_map(array($this,'stripSlashes'),$data):stripslashes($data); |
|
| 3057 | + return is_array($data) ? array_map(array($this, 'stripSlashes'), $data) : stripslashes($data); |
|
| 3058 | 3058 | } |
| 3059 | 3059 | public function getUrl() |
| 3060 | 3060 | { |
| 3061 | - if($this->_url===null) |
|
| 3061 | + if ($this->_url === null) |
|
| 3062 | 3062 | { |
| 3063 | - $secure=$this->getIsSecureConnection(); |
|
| 3064 | - $url=$secure?'https://':'http://'; |
|
| 3065 | - if(empty($_SERVER['HTTP_HOST'])) |
|
| 3063 | + $secure = $this->getIsSecureConnection(); |
|
| 3064 | + $url = $secure ? 'https://' : 'http://'; |
|
| 3065 | + if (empty($_SERVER['HTTP_HOST'])) |
|
| 3066 | 3066 | { |
| 3067 | - $url.=$_SERVER['SERVER_NAME']; |
|
| 3068 | - $port=$_SERVER['SERVER_PORT']; |
|
| 3069 | - if(($port!=80 && !$secure) || ($port!=443 && $secure)) |
|
| 3070 | - $url.=':'.$port; |
|
| 3067 | + $url .= $_SERVER['SERVER_NAME']; |
|
| 3068 | + $port = $_SERVER['SERVER_PORT']; |
|
| 3069 | + if (($port != 80 && !$secure) || ($port != 443 && $secure)) |
|
| 3070 | + $url .= ':' . $port; |
|
| 3071 | 3071 | } |
| 3072 | 3072 | else |
| 3073 | - $url.=$_SERVER['HTTP_HOST']; |
|
| 3074 | - $url.=$this->getRequestUri(); |
|
| 3075 | - $this->_url=new TUri($url); |
|
| 3073 | + $url .= $_SERVER['HTTP_HOST']; |
|
| 3074 | + $url .= $this->getRequestUri(); |
|
| 3075 | + $this->_url = new TUri($url); |
|
| 3076 | 3076 | } |
| 3077 | 3077 | return $this->_url; |
| 3078 | 3078 | } |
@@ -3090,16 +3090,16 @@ discard block |
||
| 3090 | 3090 | } |
| 3091 | 3091 | protected function cacheUrlManager($manager) |
| 3092 | 3092 | { |
| 3093 | - if($this->getEnableCache()) |
|
| 3093 | + if ($this->getEnableCache()) |
|
| 3094 | 3094 | { |
| 3095 | 3095 | $cache = $this->getApplication()->getCache(); |
| 3096 | - if($cache !== null) |
|
| 3096 | + if ($cache !== null) |
|
| 3097 | 3097 | { |
| 3098 | 3098 | $dependencies = null; |
| 3099 | - if($this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
| 3099 | + if ($this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
| 3100 | 3100 | if ($manager instanceof TUrlMapping && $fn = $manager->getConfigFile()) |
| 3101 | 3101 | { |
| 3102 | - $fn = Prado::getPathOfNamespace($fn,$this->getApplication()->getConfigurationFileExt()); |
|
| 3102 | + $fn = Prado::getPathOfNamespace($fn, $this->getApplication()->getConfigurationFileExt()); |
|
| 3103 | 3103 | $dependencies = new TFileCacheDependency($fn); |
| 3104 | 3104 | } |
| 3105 | 3105 | return $cache->set($this->getCacheKey(), $manager, 0, $dependencies); |
@@ -3109,13 +3109,13 @@ discard block |
||
| 3109 | 3109 | } |
| 3110 | 3110 | protected function loadCachedUrlManager() |
| 3111 | 3111 | { |
| 3112 | - if($this->getEnableCache()) |
|
| 3112 | + if ($this->getEnableCache()) |
|
| 3113 | 3113 | { |
| 3114 | 3114 | $cache = $this->getApplication()->getCache(); |
| 3115 | - if($cache !== null) |
|
| 3115 | + if ($cache !== null) |
|
| 3116 | 3116 | { |
| 3117 | 3117 | $manager = $cache->get($this->getCacheKey()); |
| 3118 | - if($manager instanceof TUrlManager) |
|
| 3118 | + if ($manager instanceof TUrlManager) |
|
| 3119 | 3119 | return $manager; |
| 3120 | 3120 | } |
| 3121 | 3121 | } |
@@ -3127,26 +3127,26 @@ discard block |
||
| 3127 | 3127 | } |
| 3128 | 3128 | public function setUrlManager($value) |
| 3129 | 3129 | { |
| 3130 | - $this->_urlManagerID=$value; |
|
| 3130 | + $this->_urlManagerID = $value; |
|
| 3131 | 3131 | } |
| 3132 | 3132 | public function getUrlManagerModule() |
| 3133 | 3133 | { |
| 3134 | - if($this->_urlManager===null) |
|
| 3134 | + if ($this->_urlManager === null) |
|
| 3135 | 3135 | { |
| 3136 | - if(($this->_urlManager = $this->loadCachedUrlManager())===null) |
|
| 3136 | + if (($this->_urlManager = $this->loadCachedUrlManager()) === null) |
|
| 3137 | 3137 | { |
| 3138 | - if(empty($this->_urlManagerID)) |
|
| 3138 | + if (empty($this->_urlManagerID)) |
|
| 3139 | 3139 | { |
| 3140 | - $this->_urlManager=new TUrlManager; |
|
| 3140 | + $this->_urlManager = new TUrlManager; |
|
| 3141 | 3141 | $this->_urlManager->init(null); |
| 3142 | 3142 | } |
| 3143 | 3143 | else |
| 3144 | 3144 | { |
| 3145 | - $this->_urlManager=$this->getApplication()->getModule($this->_urlManagerID); |
|
| 3146 | - if($this->_urlManager===null) |
|
| 3147 | - throw new TConfigurationException('httprequest_urlmanager_inexist',$this->_urlManagerID); |
|
| 3148 | - if(!($this->_urlManager instanceof TUrlManager)) |
|
| 3149 | - throw new TConfigurationException('httprequest_urlmanager_invalid',$this->_urlManagerID); |
|
| 3145 | + $this->_urlManager = $this->getApplication()->getModule($this->_urlManagerID); |
|
| 3146 | + if ($this->_urlManager === null) |
|
| 3147 | + throw new TConfigurationException('httprequest_urlmanager_inexist', $this->_urlManagerID); |
|
| 3148 | + if (!($this->_urlManager instanceof TUrlManager)) |
|
| 3149 | + throw new TConfigurationException('httprequest_urlmanager_invalid', $this->_urlManagerID); |
|
| 3150 | 3150 | } |
| 3151 | 3151 | $this->cacheUrlManager($this->_urlManager); |
| 3152 | 3152 | } |
@@ -3159,7 +3159,7 @@ discard block |
||
| 3159 | 3159 | } |
| 3160 | 3160 | public function setUrlFormat($value) |
| 3161 | 3161 | { |
| 3162 | - $this->_urlFormat=TPropertyValue::ensureEnum($value,'THttpRequestUrlFormat'); |
|
| 3162 | + $this->_urlFormat = TPropertyValue::ensureEnum($value, 'THttpRequestUrlFormat'); |
|
| 3163 | 3163 | } |
| 3164 | 3164 | public function getUrlParamSeparator() |
| 3165 | 3165 | { |
@@ -3167,26 +3167,26 @@ discard block |
||
| 3167 | 3167 | } |
| 3168 | 3168 | public function setUrlParamSeparator($value) |
| 3169 | 3169 | { |
| 3170 | - if(strlen($value)===1) |
|
| 3171 | - $this->_separator=$value; |
|
| 3170 | + if (strlen($value) === 1) |
|
| 3171 | + $this->_separator = $value; |
|
| 3172 | 3172 | else |
| 3173 | 3173 | throw new TInvalidDataValueException('httprequest_separator_invalid'); |
| 3174 | 3174 | } |
| 3175 | 3175 | public function getRequestType() |
| 3176 | 3176 | { |
| 3177 | - return isset($_SERVER['REQUEST_METHOD'])?$_SERVER['REQUEST_METHOD']:null; |
|
| 3177 | + return isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null; |
|
| 3178 | 3178 | } |
| 3179 | 3179 | public function getContentType($mimetypeOnly = true) |
| 3180 | 3180 | { |
| 3181 | - if(!isset($_SERVER['CONTENT_TYPE'])) |
|
| 3181 | + if (!isset($_SERVER['CONTENT_TYPE'])) |
|
| 3182 | 3182 | return null; |
| 3183 | - if($mimetypeOnly === true && ($_pos = strpos(';', $_SERVER['CONTENT_TYPE'])) !== false) |
|
| 3183 | + if ($mimetypeOnly === true && ($_pos = strpos(';', $_SERVER['CONTENT_TYPE'])) !== false) |
|
| 3184 | 3184 | return substr($_SERVER['CONTENT_TYPE'], 0, $_pos); |
| 3185 | 3185 | return $_SERVER['CONTENT_TYPE']; |
| 3186 | 3186 | } |
| 3187 | 3187 | public function getIsSecureConnection() |
| 3188 | 3188 | { |
| 3189 | - return isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'],'off'); |
|
| 3189 | + return isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off'); |
|
| 3190 | 3190 | } |
| 3191 | 3191 | public function getPathInfo() |
| 3192 | 3192 | { |
@@ -3194,27 +3194,27 @@ discard block |
||
| 3194 | 3194 | } |
| 3195 | 3195 | public function getQueryString() |
| 3196 | 3196 | { |
| 3197 | - return isset($_SERVER['QUERY_STRING'])?$_SERVER['QUERY_STRING']:null; |
|
| 3197 | + return isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null; |
|
| 3198 | 3198 | } |
| 3199 | 3199 | public function getHttpProtocolVersion() |
| 3200 | 3200 | { |
| 3201 | - return isset($_SERVER['SERVER_PROTOCOL'])?$_SERVER['SERVER_PROTOCOL']:null; |
|
| 3201 | + return isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : null; |
|
| 3202 | 3202 | } |
| 3203 | - public function getHeaders($case=null) |
|
| 3203 | + public function getHeaders($case = null) |
|
| 3204 | 3204 | { |
| 3205 | 3205 | static $result; |
| 3206 | - if($result === null && function_exists('apache_request_headers')) { |
|
| 3206 | + if ($result === null && function_exists('apache_request_headers')) { |
|
| 3207 | 3207 | $result = apache_request_headers(); |
| 3208 | 3208 | } |
| 3209 | - elseif($result === null) { |
|
| 3209 | + elseif ($result === null) { |
|
| 3210 | 3210 | $result = array(); |
| 3211 | - foreach($_SERVER as $key=>$value) { |
|
| 3212 | - if(strncasecmp($key, 'HTTP_', 5) !== 0) continue; |
|
| 3213 | - $key = str_replace(' ','-', ucwords(strtolower(str_replace('_',' ', substr($key, 5))))); |
|
| 3211 | + foreach ($_SERVER as $key=>$value) { |
|
| 3212 | + if (strncasecmp($key, 'HTTP_', 5) !== 0) continue; |
|
| 3213 | + $key = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5))))); |
|
| 3214 | 3214 | $result[$key] = $value; |
| 3215 | 3215 | } |
| 3216 | 3216 | } |
| 3217 | - if($case !== null) |
|
| 3217 | + if ($case !== null) |
|
| 3218 | 3218 | return array_change_key_case($result, $case); |
| 3219 | 3219 | return $result; |
| 3220 | 3220 | } |
@@ -3222,39 +3222,39 @@ discard block |
||
| 3222 | 3222 | { |
| 3223 | 3223 | return $this->_requestUri; |
| 3224 | 3224 | } |
| 3225 | - public function getBaseUrl($forceSecureConnection=null) |
|
| 3225 | + public function getBaseUrl($forceSecureConnection = null) |
|
| 3226 | 3226 | { |
| 3227 | - $url=$this->getUrl(); |
|
| 3228 | - $scheme=($forceSecureConnection)?"https": (($forceSecureConnection === null)?$url->getScheme():'http'); |
|
| 3229 | - $host=$url->getHost(); |
|
| 3230 | - if (($port=$url->getPort())) $host.=':'.$port; |
|
| 3231 | - return $scheme.'://'.$host; |
|
| 3227 | + $url = $this->getUrl(); |
|
| 3228 | + $scheme = ($forceSecureConnection) ? "https" : (($forceSecureConnection === null) ? $url->getScheme() : 'http'); |
|
| 3229 | + $host = $url->getHost(); |
|
| 3230 | + if (($port = $url->getPort())) $host .= ':' . $port; |
|
| 3231 | + return $scheme . '://' . $host; |
|
| 3232 | 3232 | } |
| 3233 | 3233 | public function getApplicationUrl() |
| 3234 | 3234 | { |
| 3235 | - if($this->_cgiFix&self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME'])) |
|
| 3235 | + if ($this->_cgiFix & self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME'])) |
|
| 3236 | 3236 | return $_SERVER['ORIG_SCRIPT_NAME']; |
| 3237 | - return isset($_SERVER['SCRIPT_NAME'])?$_SERVER['SCRIPT_NAME']:null; |
|
| 3237 | + return isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : null; |
|
| 3238 | 3238 | } |
| 3239 | - public function getAbsoluteApplicationUrl($forceSecureConnection=null) |
|
| 3239 | + public function getAbsoluteApplicationUrl($forceSecureConnection = null) |
|
| 3240 | 3240 | { |
| 3241 | 3241 | return $this->getBaseUrl($forceSecureConnection) . $this->getApplicationUrl(); |
| 3242 | 3242 | } |
| 3243 | 3243 | public function getApplicationFilePath() |
| 3244 | 3244 | { |
| 3245 | - return realpath(isset($_SERVER['SCRIPT_FILENAME'])?$_SERVER['SCRIPT_FILENAME']:null); |
|
| 3245 | + return realpath(isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : null); |
|
| 3246 | 3246 | } |
| 3247 | 3247 | public function getServerName() |
| 3248 | 3248 | { |
| 3249 | - return isset($_SERVER['SERVER_NAME'])?$_SERVER['SERVER_NAME']:null; |
|
| 3249 | + return isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null; |
|
| 3250 | 3250 | } |
| 3251 | 3251 | public function getServerPort() |
| 3252 | 3252 | { |
| 3253 | - return isset($_SERVER['SERVER_PORT'])?$_SERVER['SERVER_PORT']:null; |
|
| 3253 | + return isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : null; |
|
| 3254 | 3254 | } |
| 3255 | 3255 | public function getUrlReferrer() |
| 3256 | 3256 | { |
| 3257 | - return isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:null; |
|
| 3257 | + return isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; |
|
| 3258 | 3258 | } |
| 3259 | 3259 | public function getBrowser() |
| 3260 | 3260 | { |
@@ -3262,26 +3262,26 @@ discard block |
||
| 3262 | 3262 | { |
| 3263 | 3263 | return get_browser(); |
| 3264 | 3264 | } |
| 3265 | - catch(TPhpErrorException $e) |
|
| 3265 | + catch (TPhpErrorException $e) |
|
| 3266 | 3266 | { |
| 3267 | 3267 | throw new TConfigurationException('httprequest_browscap_required'); |
| 3268 | 3268 | } |
| 3269 | 3269 | } |
| 3270 | 3270 | public function getUserAgent() |
| 3271 | 3271 | { |
| 3272 | - return isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:null; |
|
| 3272 | + return isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; |
|
| 3273 | 3273 | } |
| 3274 | 3274 | public function getUserHostAddress() |
| 3275 | 3275 | { |
| 3276 | - return isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:null; |
|
| 3276 | + return isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null; |
|
| 3277 | 3277 | } |
| 3278 | 3278 | public function getUserHost() |
| 3279 | 3279 | { |
| 3280 | - return isset($_SERVER['REMOTE_HOST'])?$_SERVER['REMOTE_HOST']:null; |
|
| 3280 | + return isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : null; |
|
| 3281 | 3281 | } |
| 3282 | 3282 | public function getAcceptTypes() |
| 3283 | 3283 | { |
| 3284 | - return isset($_SERVER['HTTP_ACCEPT'])?$_SERVER['HTTP_ACCEPT']:null; |
|
| 3284 | + return isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : null; |
|
| 3285 | 3285 | } |
| 3286 | 3286 | public function getUserLanguages() |
| 3287 | 3287 | { |
@@ -3293,7 +3293,7 @@ discard block |
||
| 3293 | 3293 | } |
| 3294 | 3294 | public function setEnableCookieValidation($value) |
| 3295 | 3295 | { |
| 3296 | - $this->_enableCookieValidation=TPropertyValue::ensureBoolean($value); |
|
| 3296 | + $this->_enableCookieValidation = TPropertyValue::ensureBoolean($value); |
|
| 3297 | 3297 | } |
| 3298 | 3298 | public function getCgiFix() |
| 3299 | 3299 | { |
@@ -3301,26 +3301,26 @@ discard block |
||
| 3301 | 3301 | } |
| 3302 | 3302 | public function setCgiFix($value) |
| 3303 | 3303 | { |
| 3304 | - $this->_cgiFix=TPropertyValue::ensureInteger($value); |
|
| 3304 | + $this->_cgiFix = TPropertyValue::ensureInteger($value); |
|
| 3305 | 3305 | } |
| 3306 | 3306 | public function getCookies() |
| 3307 | 3307 | { |
| 3308 | - if($this->_cookies===null) |
|
| 3308 | + if ($this->_cookies === null) |
|
| 3309 | 3309 | { |
| 3310 | - $this->_cookies=new THttpCookieCollection; |
|
| 3311 | - if($this->getEnableCookieValidation()) |
|
| 3310 | + $this->_cookies = new THttpCookieCollection; |
|
| 3311 | + if ($this->getEnableCookieValidation()) |
|
| 3312 | 3312 | { |
| 3313 | - $sm=$this->getApplication()->getSecurityManager(); |
|
| 3314 | - foreach($_COOKIE as $key=>$value) |
|
| 3313 | + $sm = $this->getApplication()->getSecurityManager(); |
|
| 3314 | + foreach ($_COOKIE as $key=>$value) |
|
| 3315 | 3315 | { |
| 3316 | - if(($value=$sm->validateData($value))!==false) |
|
| 3317 | - $this->_cookies->add(new THttpCookie($key,$value)); |
|
| 3316 | + if (($value = $sm->validateData($value)) !== false) |
|
| 3317 | + $this->_cookies->add(new THttpCookie($key, $value)); |
|
| 3318 | 3318 | } |
| 3319 | 3319 | } |
| 3320 | 3320 | else |
| 3321 | 3321 | { |
| 3322 | - foreach($_COOKIE as $key=>$value) |
|
| 3323 | - $this->_cookies->add(new THttpCookie($key,$value)); |
|
| 3322 | + foreach ($_COOKIE as $key=>$value) |
|
| 3323 | + $this->_cookies->add(new THttpCookie($key, $value)); |
|
| 3324 | 3324 | } |
| 3325 | 3325 | } |
| 3326 | 3326 | return $this->_cookies; |
@@ -3337,13 +3337,13 @@ discard block |
||
| 3337 | 3337 | { |
| 3338 | 3338 | return $_ENV; |
| 3339 | 3339 | } |
| 3340 | - public function constructUrl($serviceID,$serviceParam,$getItems=null,$encodeAmpersand=true,$encodeGetItems=true) |
|
| 3340 | + public function constructUrl($serviceID, $serviceParam, $getItems = null, $encodeAmpersand = true, $encodeGetItems = true) |
|
| 3341 | 3341 | { |
| 3342 | - if ($this->_cookieOnly===null) |
|
| 3343 | - $this->_cookieOnly=(int)ini_get('session.use_cookies') && (int)ini_get('session.use_only_cookies'); |
|
| 3344 | - $url=$this->getUrlManagerModule()->constructUrl($serviceID,$serviceParam,$getItems,$encodeAmpersand,$encodeGetItems); |
|
| 3345 | - if(defined('SID') && SID != '' && !$this->_cookieOnly) |
|
| 3346 | - return $url . (strpos($url,'?')===false? '?' : ($encodeAmpersand?'&':'&')) . SID; |
|
| 3342 | + if ($this->_cookieOnly === null) |
|
| 3343 | + $this->_cookieOnly = (int) ini_get('session.use_cookies') && (int) ini_get('session.use_only_cookies'); |
|
| 3344 | + $url = $this->getUrlManagerModule()->constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems); |
|
| 3345 | + if (defined('SID') && SID != '' && !$this->_cookieOnly) |
|
| 3346 | + return $url . (strpos($url, '?') === false ? '?' : ($encodeAmpersand ? '&' : '&')) . SID; |
|
| 3347 | 3347 | else |
| 3348 | 3348 | return $url; |
| 3349 | 3349 | } |
@@ -3353,14 +3353,14 @@ discard block |
||
| 3353 | 3353 | } |
| 3354 | 3354 | public function resolveRequest($serviceIDs) |
| 3355 | 3355 | { |
| 3356 | - $getParams=$this->parseUrl(); |
|
| 3357 | - foreach($getParams as $name=>$value) |
|
| 3358 | - $_GET[$name]=$value; |
|
| 3359 | - $this->_items=array_merge($_GET,$_POST); |
|
| 3360 | - $this->_requestResolved=true; |
|
| 3361 | - foreach($serviceIDs as $serviceID) |
|
| 3356 | + $getParams = $this->parseUrl(); |
|
| 3357 | + foreach ($getParams as $name=>$value) |
|
| 3358 | + $_GET[$name] = $value; |
|
| 3359 | + $this->_items = array_merge($_GET, $_POST); |
|
| 3360 | + $this->_requestResolved = true; |
|
| 3361 | + foreach ($serviceIDs as $serviceID) |
|
| 3362 | 3362 | { |
| 3363 | - if($this->contains($serviceID)) |
|
| 3363 | + if ($this->contains($serviceID)) |
|
| 3364 | 3364 | { |
| 3365 | 3365 | $this->setServiceID($serviceID); |
| 3366 | 3366 | $this->setServiceParameter($this->itemAt($serviceID)); |
@@ -3379,7 +3379,7 @@ discard block |
||
| 3379 | 3379 | } |
| 3380 | 3380 | public function setServiceID($value) |
| 3381 | 3381 | { |
| 3382 | - $this->_serviceID=$value; |
|
| 3382 | + $this->_serviceID = $value; |
|
| 3383 | 3383 | } |
| 3384 | 3384 | public function getServiceParameter() |
| 3385 | 3385 | { |
@@ -3387,7 +3387,7 @@ discard block |
||
| 3387 | 3387 | } |
| 3388 | 3388 | public function setServiceParameter($value) |
| 3389 | 3389 | { |
| 3390 | - $this->_serviceParam=$value; |
|
| 3390 | + $this->_serviceParam = $value; |
|
| 3391 | 3391 | } |
| 3392 | 3392 | public function getIterator() |
| 3393 | 3393 | { |
@@ -3409,15 +3409,15 @@ discard block |
||
| 3409 | 3409 | { |
| 3410 | 3410 | return isset($this->_items[$key]) ? $this->_items[$key] : null; |
| 3411 | 3411 | } |
| 3412 | - public function add($key,$value) |
|
| 3412 | + public function add($key, $value) |
|
| 3413 | 3413 | { |
| 3414 | - $this->_items[$key]=$value; |
|
| 3414 | + $this->_items[$key] = $value; |
|
| 3415 | 3415 | } |
| 3416 | 3416 | public function remove($key) |
| 3417 | 3417 | { |
| 3418 | - if(isset($this->_items[$key]) || array_key_exists($key,$this->_items)) |
|
| 3418 | + if (isset($this->_items[$key]) || array_key_exists($key, $this->_items)) |
|
| 3419 | 3419 | { |
| 3420 | - $value=$this->_items[$key]; |
|
| 3420 | + $value = $this->_items[$key]; |
|
| 3421 | 3421 | unset($this->_items[$key]); |
| 3422 | 3422 | return $value; |
| 3423 | 3423 | } |
@@ -3426,12 +3426,12 @@ discard block |
||
| 3426 | 3426 | } |
| 3427 | 3427 | public function clear() |
| 3428 | 3428 | { |
| 3429 | - foreach(array_keys($this->_items) as $key) |
|
| 3429 | + foreach (array_keys($this->_items) as $key) |
|
| 3430 | 3430 | $this->remove($key); |
| 3431 | 3431 | } |
| 3432 | 3432 | public function contains($key) |
| 3433 | 3433 | { |
| 3434 | - return isset($this->_items[$key]) || array_key_exists($key,$this->_items); |
|
| 3434 | + return isset($this->_items[$key]) || array_key_exists($key, $this->_items); |
|
| 3435 | 3435 | } |
| 3436 | 3436 | public function toArray() |
| 3437 | 3437 | { |
@@ -3445,9 +3445,9 @@ discard block |
||
| 3445 | 3445 | { |
| 3446 | 3446 | return $this->itemAt($offset); |
| 3447 | 3447 | } |
| 3448 | - public function offsetSet($offset,$item) |
|
| 3448 | + public function offsetSet($offset, $item) |
|
| 3449 | 3449 | { |
| 3450 | - $this->add($offset,$item); |
|
| 3450 | + $this->add($offset, $item); |
|
| 3451 | 3451 | } |
| 3452 | 3452 | public function offsetUnset($offset) |
| 3453 | 3453 | { |
@@ -3457,16 +3457,16 @@ discard block |
||
| 3457 | 3457 | class THttpCookieCollection extends TList |
| 3458 | 3458 | { |
| 3459 | 3459 | private $_o; |
| 3460 | - public function __construct($owner=null) |
|
| 3460 | + public function __construct($owner = null) |
|
| 3461 | 3461 | { |
| 3462 | - $this->_o=$owner; |
|
| 3462 | + $this->_o = $owner; |
|
| 3463 | 3463 | } |
| 3464 | - public function insertAt($index,$item) |
|
| 3464 | + public function insertAt($index, $item) |
|
| 3465 | 3465 | { |
| 3466 | - if($item instanceof THttpCookie) |
|
| 3466 | + if ($item instanceof THttpCookie) |
|
| 3467 | 3467 | { |
| 3468 | - parent::insertAt($index,$item); |
|
| 3469 | - if($this->_o instanceof THttpResponse) |
|
| 3468 | + parent::insertAt($index, $item); |
|
| 3469 | + if ($this->_o instanceof THttpResponse) |
|
| 3470 | 3470 | $this->_o->addCookie($item); |
| 3471 | 3471 | } |
| 3472 | 3472 | else |
@@ -3474,39 +3474,39 @@ discard block |
||
| 3474 | 3474 | } |
| 3475 | 3475 | public function removeAt($index) |
| 3476 | 3476 | { |
| 3477 | - $item=parent::removeAt($index); |
|
| 3478 | - if($this->_o instanceof THttpResponse) |
|
| 3477 | + $item = parent::removeAt($index); |
|
| 3478 | + if ($this->_o instanceof THttpResponse) |
|
| 3479 | 3479 | $this->_o->removeCookie($item); |
| 3480 | 3480 | return $item; |
| 3481 | 3481 | } |
| 3482 | 3482 | public function itemAt($index) |
| 3483 | 3483 | { |
| 3484 | - if(is_integer($index)) |
|
| 3484 | + if (is_integer($index)) |
|
| 3485 | 3485 | return parent::itemAt($index); |
| 3486 | 3486 | else |
| 3487 | 3487 | return $this->findCookieByName($index); |
| 3488 | 3488 | } |
| 3489 | 3489 | public function findCookieByName($name) |
| 3490 | 3490 | { |
| 3491 | - foreach($this as $cookie) |
|
| 3492 | - if($cookie->getName()===$name) |
|
| 3491 | + foreach ($this as $cookie) |
|
| 3492 | + if ($cookie->getName() === $name) |
|
| 3493 | 3493 | return $cookie; |
| 3494 | 3494 | return null; |
| 3495 | 3495 | } |
| 3496 | 3496 | } |
| 3497 | 3497 | class THttpCookie extends TComponent |
| 3498 | 3498 | { |
| 3499 | - private $_domain=''; |
|
| 3499 | + private $_domain = ''; |
|
| 3500 | 3500 | private $_name; |
| 3501 | - private $_value=''; |
|
| 3502 | - private $_expire=0; |
|
| 3503 | - private $_path='/'; |
|
| 3504 | - private $_secure=false; |
|
| 3505 | - private $_httpOnly=false; |
|
| 3506 | - public function __construct($name,$value) |
|
| 3501 | + private $_value = ''; |
|
| 3502 | + private $_expire = 0; |
|
| 3503 | + private $_path = '/'; |
|
| 3504 | + private $_secure = false; |
|
| 3505 | + private $_httpOnly = false; |
|
| 3506 | + public function __construct($name, $value) |
|
| 3507 | 3507 | { |
| 3508 | - $this->_name=$name; |
|
| 3509 | - $this->_value=$value; |
|
| 3508 | + $this->_name = $name; |
|
| 3509 | + $this->_value = $value; |
|
| 3510 | 3510 | } |
| 3511 | 3511 | public function getDomain() |
| 3512 | 3512 | { |
@@ -3514,7 +3514,7 @@ discard block |
||
| 3514 | 3514 | } |
| 3515 | 3515 | public function setDomain($value) |
| 3516 | 3516 | { |
| 3517 | - $this->_domain=$value; |
|
| 3517 | + $this->_domain = $value; |
|
| 3518 | 3518 | } |
| 3519 | 3519 | public function getExpire() |
| 3520 | 3520 | { |
@@ -3522,7 +3522,7 @@ discard block |
||
| 3522 | 3522 | } |
| 3523 | 3523 | public function setExpire($value) |
| 3524 | 3524 | { |
| 3525 | - $this->_expire=TPropertyValue::ensureInteger($value); |
|
| 3525 | + $this->_expire = TPropertyValue::ensureInteger($value); |
|
| 3526 | 3526 | } |
| 3527 | 3527 | public function getHttpOnly() |
| 3528 | 3528 | { |
@@ -3538,7 +3538,7 @@ discard block |
||
| 3538 | 3538 | } |
| 3539 | 3539 | public function setName($value) |
| 3540 | 3540 | { |
| 3541 | - $this->_name=$value; |
|
| 3541 | + $this->_name = $value; |
|
| 3542 | 3542 | } |
| 3543 | 3543 | public function getValue() |
| 3544 | 3544 | { |
@@ -3546,7 +3546,7 @@ discard block |
||
| 3546 | 3546 | } |
| 3547 | 3547 | public function setValue($value) |
| 3548 | 3548 | { |
| 3549 | - $this->_value=$value; |
|
| 3549 | + $this->_value = $value; |
|
| 3550 | 3550 | } |
| 3551 | 3551 | public function getPath() |
| 3552 | 3552 | { |
@@ -3554,7 +3554,7 @@ discard block |
||
| 3554 | 3554 | } |
| 3555 | 3555 | public function setPath($value) |
| 3556 | 3556 | { |
| 3557 | - $this->_path=$value; |
|
| 3557 | + $this->_path = $value; |
|
| 3558 | 3558 | } |
| 3559 | 3559 | public function getSecure() |
| 3560 | 3560 | { |
@@ -3562,12 +3562,12 @@ discard block |
||
| 3562 | 3562 | } |
| 3563 | 3563 | public function setSecure($value) |
| 3564 | 3564 | { |
| 3565 | - $this->_secure=TPropertyValue::ensureBoolean($value); |
|
| 3565 | + $this->_secure = TPropertyValue::ensureBoolean($value); |
|
| 3566 | 3566 | } |
| 3567 | 3567 | } |
| 3568 | 3568 | class TUri extends TComponent |
| 3569 | 3569 | { |
| 3570 | - private static $_defaultPort=array( |
|
| 3570 | + private static $_defaultPort = array( |
|
| 3571 | 3571 | 'ftp'=>21, |
| 3572 | 3572 | 'gopher'=>70, |
| 3573 | 3573 | 'http'=>80, |
@@ -3588,21 +3588,21 @@ discard block |
||
| 3588 | 3588 | private $_uri; |
| 3589 | 3589 | public function __construct($uri) |
| 3590 | 3590 | { |
| 3591 | - if(($ret=@parse_url($uri))!==false) |
|
| 3591 | + if (($ret = @parse_url($uri)) !== false) |
|
| 3592 | 3592 | { |
| 3593 | - $this->_scheme=isset($ret['scheme'])?$ret['scheme']:''; |
|
| 3594 | - $this->_host=isset($ret['host'])?$ret['host']:''; |
|
| 3595 | - $this->_port=isset($ret['port'])?$ret['port']:''; |
|
| 3596 | - $this->_user=isset($ret['user'])?$ret['user']:''; |
|
| 3597 | - $this->_pass=isset($ret['pass'])?$ret['pass']:''; |
|
| 3598 | - $this->_path=isset($ret['path'])?$ret['path']:''; |
|
| 3599 | - $this->_query=isset($ret['query'])?$ret['query']:''; |
|
| 3600 | - $this->_fragment=isset($ret['fragment'])?$ret['fragment']:''; |
|
| 3601 | - $this->_uri=$uri; |
|
| 3593 | + $this->_scheme = isset($ret['scheme']) ? $ret['scheme'] : ''; |
|
| 3594 | + $this->_host = isset($ret['host']) ? $ret['host'] : ''; |
|
| 3595 | + $this->_port = isset($ret['port']) ? $ret['port'] : ''; |
|
| 3596 | + $this->_user = isset($ret['user']) ? $ret['user'] : ''; |
|
| 3597 | + $this->_pass = isset($ret['pass']) ? $ret['pass'] : ''; |
|
| 3598 | + $this->_path = isset($ret['path']) ? $ret['path'] : ''; |
|
| 3599 | + $this->_query = isset($ret['query']) ? $ret['query'] : ''; |
|
| 3600 | + $this->_fragment = isset($ret['fragment']) ? $ret['fragment'] : ''; |
|
| 3601 | + $this->_uri = $uri; |
|
| 3602 | 3602 | } |
| 3603 | 3603 | else |
| 3604 | 3604 | { |
| 3605 | - throw new TInvalidDataValueException('uri_format_invalid',$uri); |
|
| 3605 | + throw new TInvalidDataValueException('uri_format_invalid', $uri); |
|
| 3606 | 3606 | } |
| 3607 | 3607 | } |
| 3608 | 3608 | public function getUri() |
@@ -3644,16 +3644,16 @@ discard block |
||
| 3644 | 3644 | } |
| 3645 | 3645 | class THttpRequestUrlFormat extends TEnumerable |
| 3646 | 3646 | { |
| 3647 | - const Get='Get'; |
|
| 3648 | - const Path='Path'; |
|
| 3649 | - const HiddenPath='HiddenPath'; |
|
| 3647 | + const Get = 'Get'; |
|
| 3648 | + const Path = 'Path'; |
|
| 3649 | + const HiddenPath = 'HiddenPath'; |
|
| 3650 | 3650 | } |
| 3651 | 3651 | class THttpResponseAdapter extends TApplicationComponent |
| 3652 | 3652 | { |
| 3653 | 3653 | private $_response; |
| 3654 | 3654 | public function __construct($response) |
| 3655 | 3655 | { |
| 3656 | - $this->_response=$response; |
|
| 3656 | + $this->_response = $response; |
|
| 3657 | 3657 | } |
| 3658 | 3658 | public function getResponse() |
| 3659 | 3659 | { |
@@ -3669,13 +3669,13 @@ discard block |
||
| 3669 | 3669 | } |
| 3670 | 3670 | public function createNewHtmlWriter($type, $writer) |
| 3671 | 3671 | { |
| 3672 | - return $this->_response->createNewHtmlWriter($type,$writer); |
|
| 3672 | + return $this->_response->createNewHtmlWriter($type, $writer); |
|
| 3673 | 3673 | } |
| 3674 | 3674 | } |
| 3675 | 3675 | class THttpResponse extends TModule implements ITextWriter |
| 3676 | 3676 | { |
| 3677 | - const DEFAULT_CONTENTTYPE = 'text/html'; |
|
| 3678 | - const DEFAULT_CHARSET = 'UTF-8'; |
|
| 3677 | + const DEFAULT_CONTENTTYPE = 'text/html'; |
|
| 3678 | + const DEFAULT_CHARSET = 'UTF-8'; |
|
| 3679 | 3679 | private static $HTTP_STATUS_CODES = array( |
| 3680 | 3680 | 100 => 'Continue', 101 => 'Switching Protocols', |
| 3681 | 3681 | 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', |
@@ -3683,14 +3683,14 @@ discard block |
||
| 3683 | 3683 | 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Time-out', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Large', 415 => 'Unsupported Media Type', 416 => 'Requested range not satisfiable', 417 => 'Expectation Failed', |
| 3684 | 3684 | 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Time-out', 505 => 'HTTP Version not supported' |
| 3685 | 3685 | ); |
| 3686 | - private $_bufferOutput=true; |
|
| 3687 | - private $_initialized=false; |
|
| 3688 | - private $_cookies=null; |
|
| 3689 | - private $_status=200; |
|
| 3690 | - private $_reason='OK'; |
|
| 3691 | - private $_htmlWriterType='System.Web.UI.THtmlWriter'; |
|
| 3692 | - private $_contentType=null; |
|
| 3693 | - private $_charset=''; |
|
| 3686 | + private $_bufferOutput = true; |
|
| 3687 | + private $_initialized = false; |
|
| 3688 | + private $_cookies = null; |
|
| 3689 | + private $_status = 200; |
|
| 3690 | + private $_reason = 'OK'; |
|
| 3691 | + private $_htmlWriterType = 'System.Web.UI.THtmlWriter'; |
|
| 3692 | + private $_contentType = null; |
|
| 3693 | + private $_charset = ''; |
|
| 3694 | 3694 | private $_adapter; |
| 3695 | 3695 | private $_httpHeaderSent; |
| 3696 | 3696 | private $_contentTypeHeaderSent; |
@@ -3699,7 +3699,7 @@ discard block |
||
| 3699 | 3699 | } |
| 3700 | 3700 | public function setAdapter(THttpResponseAdapter $adapter) |
| 3701 | 3701 | { |
| 3702 | - $this->_adapter=$adapter; |
|
| 3702 | + $this->_adapter = $adapter; |
|
| 3703 | 3703 | } |
| 3704 | 3704 | public function getAdapter() |
| 3705 | 3705 | { |
@@ -3707,13 +3707,13 @@ discard block |
||
| 3707 | 3707 | } |
| 3708 | 3708 | public function getHasAdapter() |
| 3709 | 3709 | { |
| 3710 | - return $this->_adapter!==null; |
|
| 3710 | + return $this->_adapter !== null; |
|
| 3711 | 3711 | } |
| 3712 | 3712 | public function init($config) |
| 3713 | 3713 | { |
| 3714 | - if($this->_bufferOutput) |
|
| 3714 | + if ($this->_bufferOutput) |
|
| 3715 | 3715 | ob_start(); |
| 3716 | - $this->_initialized=true; |
|
| 3716 | + $this->_initialized = true; |
|
| 3717 | 3717 | $this->getApplication()->setResponse($this); |
| 3718 | 3718 | } |
| 3719 | 3719 | public function getCacheExpire() |
@@ -3730,7 +3730,7 @@ discard block |
||
| 3730 | 3730 | } |
| 3731 | 3731 | public function setCacheControl($value) |
| 3732 | 3732 | { |
| 3733 | - session_cache_limiter(TPropertyValue::ensureEnum($value,array('none','nocache','private','private_no_expire','public'))); |
|
| 3733 | + session_cache_limiter(TPropertyValue::ensureEnum($value, array('none', 'nocache', 'private', 'private_no_expire', 'public'))); |
|
| 3734 | 3734 | } |
| 3735 | 3735 | public function setContentType($type) |
| 3736 | 3736 | { |
@@ -3748,7 +3748,7 @@ discard block |
||
| 3748 | 3748 | } |
| 3749 | 3749 | public function setCharset($charset) |
| 3750 | 3750 | { |
| 3751 | - $this->_charset = (strToLower($charset) === 'false') ? false : (string)$charset; |
|
| 3751 | + $this->_charset = (strToLower($charset) === 'false') ? false : (string) $charset; |
|
| 3752 | 3752 | } |
| 3753 | 3753 | public function getBufferOutput() |
| 3754 | 3754 | { |
@@ -3756,41 +3756,41 @@ discard block |
||
| 3756 | 3756 | } |
| 3757 | 3757 | public function setBufferOutput($value) |
| 3758 | 3758 | { |
| 3759 | - if($this->_initialized) |
|
| 3759 | + if ($this->_initialized) |
|
| 3760 | 3760 | throw new TInvalidOperationException('httpresponse_bufferoutput_unchangeable'); |
| 3761 | 3761 | else |
| 3762 | - $this->_bufferOutput=TPropertyValue::ensureBoolean($value); |
|
| 3762 | + $this->_bufferOutput = TPropertyValue::ensureBoolean($value); |
|
| 3763 | 3763 | } |
| 3764 | 3764 | public function getStatusCode() |
| 3765 | 3765 | { |
| 3766 | 3766 | return $this->_status; |
| 3767 | 3767 | } |
| 3768 | - public function setStatusCode($status, $reason=null) |
|
| 3768 | + public function setStatusCode($status, $reason = null) |
|
| 3769 | 3769 | { |
| 3770 | 3770 | if ($this->_httpHeaderSent) |
| 3771 | 3771 | throw new Exception('Unable to alter response as HTTP header already sent'); |
| 3772 | - $status=TPropertyValue::ensureInteger($status); |
|
| 3773 | - if(isset(self::$HTTP_STATUS_CODES[$status])) { |
|
| 3774 | - $this->_reason=self::$HTTP_STATUS_CODES[$status]; |
|
| 3775 | - }else{ |
|
| 3776 | - if($reason===null || $reason==='') { |
|
| 3772 | + $status = TPropertyValue::ensureInteger($status); |
|
| 3773 | + if (isset(self::$HTTP_STATUS_CODES[$status])) { |
|
| 3774 | + $this->_reason = self::$HTTP_STATUS_CODES[$status]; |
|
| 3775 | + } else { |
|
| 3776 | + if ($reason === null || $reason === '') { |
|
| 3777 | 3777 | throw new TInvalidDataValueException("response_status_reason_missing"); |
| 3778 | 3778 | } |
| 3779 | - $reason=TPropertyValue::ensureString($reason); |
|
| 3780 | - if(strpos($reason, "\r")!=false || strpos($reason, "\n")!=false) { |
|
| 3779 | + $reason = TPropertyValue::ensureString($reason); |
|
| 3780 | + if (strpos($reason, "\r") != false || strpos($reason, "\n") != false) { |
|
| 3781 | 3781 | throw new TInvalidDataValueException("response_status_reason_barchars"); |
| 3782 | 3782 | } |
| 3783 | - $this->_reason=$reason; |
|
| 3783 | + $this->_reason = $reason; |
|
| 3784 | 3784 | } |
| 3785 | - $this->_status=$status; |
|
| 3785 | + $this->_status = $status; |
|
| 3786 | 3786 | } |
| 3787 | 3787 | public function getStatusReason() { |
| 3788 | 3788 | return $this->_reason; |
| 3789 | 3789 | } |
| 3790 | 3790 | public function getCookies() |
| 3791 | 3791 | { |
| 3792 | - if($this->_cookies===null) |
|
| 3793 | - $this->_cookies=new THttpCookieCollection($this); |
|
| 3792 | + if ($this->_cookies === null) |
|
| 3793 | + $this->_cookies = new THttpCookieCollection($this); |
|
| 3794 | 3794 | return $this->_cookies; |
| 3795 | 3795 | } |
| 3796 | 3796 | public function write($str) |
@@ -3799,9 +3799,9 @@ discard block |
||
| 3799 | 3799 | $this->ensureHeadersSent(); |
| 3800 | 3800 | echo $str; |
| 3801 | 3801 | } |
| 3802 | - public function writeFile($fileName,$content=null,$mimeType=null,$headers=null,$forceDownload=true,$clientFileName=null,$fileSize=null) |
|
| 3802 | + public function writeFile($fileName, $content = null, $mimeType = null, $headers = null, $forceDownload = true, $clientFileName = null, $fileSize = null) |
|
| 3803 | 3803 | { |
| 3804 | - static $defaultMimeTypes=array( |
|
| 3804 | + static $defaultMimeTypes = array( |
|
| 3805 | 3805 | 'css'=>'text/css', |
| 3806 | 3806 | 'gif'=>'image/gif', |
| 3807 | 3807 | 'png'=>'image/png', |
@@ -3813,28 +3813,28 @@ discard block |
||
| 3813 | 3813 | 'pdf'=>'application/pdf', |
| 3814 | 3814 | 'xls'=>'application/vnd.ms-excel', |
| 3815 | 3815 | ); |
| 3816 | - if($mimeType===null) |
|
| 3816 | + if ($mimeType === null) |
|
| 3817 | 3817 | { |
| 3818 | - $mimeType='text/plain'; |
|
| 3819 | - if(function_exists('mime_content_type')) |
|
| 3820 | - $mimeType=mime_content_type($fileName); |
|
| 3821 | - else if(($ext=strrchr($fileName,'.'))!==false) |
|
| 3818 | + $mimeType = 'text/plain'; |
|
| 3819 | + if (function_exists('mime_content_type')) |
|
| 3820 | + $mimeType = mime_content_type($fileName); |
|
| 3821 | + else if (($ext = strrchr($fileName, '.')) !== false) |
|
| 3822 | 3822 | { |
| 3823 | - $ext=substr($ext,1); |
|
| 3824 | - if(isset($defaultMimeTypes[$ext])) |
|
| 3825 | - $mimeType=$defaultMimeTypes[$ext]; |
|
| 3823 | + $ext = substr($ext, 1); |
|
| 3824 | + if (isset($defaultMimeTypes[$ext])) |
|
| 3825 | + $mimeType = $defaultMimeTypes[$ext]; |
|
| 3826 | 3826 | } |
| 3827 | 3827 | } |
| 3828 | - if($clientFileName===null) |
|
| 3829 | - $clientFileName=basename($fileName); |
|
| 3828 | + if ($clientFileName === null) |
|
| 3829 | + $clientFileName = basename($fileName); |
|
| 3830 | 3830 | else |
| 3831 | - $clientFileName=basename($clientFileName); |
|
| 3832 | - if($fileSize===null || $fileSize < 0) |
|
| 3833 | - $fileSize = ($content===null?filesize($fileName):strlen($content)); |
|
| 3831 | + $clientFileName = basename($clientFileName); |
|
| 3832 | + if ($fileSize === null || $fileSize < 0) |
|
| 3833 | + $fileSize = ($content === null ? filesize($fileName) : strlen($content)); |
|
| 3834 | 3834 | $this->sendHttpHeader(); |
| 3835 | - if(is_array($headers)) |
|
| 3835 | + if (is_array($headers)) |
|
| 3836 | 3836 | { |
| 3837 | - foreach($headers as $h) |
|
| 3837 | + foreach ($headers as $h) |
|
| 3838 | 3838 | header($h); |
| 3839 | 3839 | } |
| 3840 | 3840 | else |
@@ -3845,17 +3845,17 @@ discard block |
||
| 3845 | 3845 | header("Content-Type: $mimeType"); |
| 3846 | 3846 | $this->_contentTypeHeaderSent = true; |
| 3847 | 3847 | } |
| 3848 | - header('Content-Length: '.$fileSize); |
|
| 3848 | + header('Content-Length: ' . $fileSize); |
|
| 3849 | 3849 | header("Content-Disposition: " . ($forceDownload ? 'attachment' : 'inline') . "; filename=\"$clientFileName\""); |
| 3850 | 3850 | header('Content-Transfer-Encoding: binary'); |
| 3851 | - if($content===null) |
|
| 3851 | + if ($content === null) |
|
| 3852 | 3852 | readfile($fileName); |
| 3853 | 3853 | else |
| 3854 | 3854 | echo $content; |
| 3855 | 3855 | } |
| 3856 | 3856 | public function redirect($url) |
| 3857 | 3857 | { |
| 3858 | - if($this->getHasAdapter()) |
|
| 3858 | + if ($this->getHasAdapter()) |
|
| 3859 | 3859 | $this->_adapter->httpRedirect($url); |
| 3860 | 3860 | else |
| 3861 | 3861 | $this->httpRedirect($url); |
@@ -3863,13 +3863,13 @@ discard block |
||
| 3863 | 3863 | public function httpRedirect($url) |
| 3864 | 3864 | { |
| 3865 | 3865 | $this->ensureHeadersSent(); |
| 3866 | - if($url[0]==='/') |
|
| 3867 | - $url=$this->getRequest()->getBaseUrl().$url; |
|
| 3866 | + if ($url[0] === '/') |
|
| 3867 | + $url = $this->getRequest()->getBaseUrl() . $url; |
|
| 3868 | 3868 | if ($this->_status >= 300 && $this->_status < 400) |
| 3869 | - header('Location: '.str_replace('&','&',$url), true, $this->_status); |
|
| 3869 | + header('Location: ' . str_replace('&', '&', $url), true, $this->_status); |
|
| 3870 | 3870 | else |
| 3871 | - header('Location: '.str_replace('&','&',$url)); |
|
| 3872 | - if(!$this->getApplication()->getRequestCompleted()) |
|
| 3871 | + header('Location: ' . str_replace('&', '&', $url)); |
|
| 3872 | + if (!$this->getApplication()->getRequestCompleted()) |
|
| 3873 | 3873 | $this->getApplication()->onEndRequest(); |
| 3874 | 3874 | exit(); |
| 3875 | 3875 | } |
@@ -3879,7 +3879,7 @@ discard block |
||
| 3879 | 3879 | } |
| 3880 | 3880 | public function flush($continueBuffering = true) |
| 3881 | 3881 | { |
| 3882 | - if($this->getHasAdapter()) |
|
| 3882 | + if ($this->getHasAdapter()) |
|
| 3883 | 3883 | $this->_adapter->flushContent($continueBuffering); |
| 3884 | 3884 | else |
| 3885 | 3885 | $this->flushContent($continueBuffering); |
@@ -3892,9 +3892,9 @@ discard block |
||
| 3892 | 3892 | public function flushContent($continueBuffering = true) |
| 3893 | 3893 | { |
| 3894 | 3894 | $this->ensureHeadersSent(); |
| 3895 | - if($this->_bufferOutput) |
|
| 3895 | + if ($this->_bufferOutput) |
|
| 3896 | 3896 | { |
| 3897 | - if (ob_get_length()>0) |
|
| 3897 | + if (ob_get_length() > 0) |
|
| 3898 | 3898 | { |
| 3899 | 3899 | if (!$continueBuffering) |
| 3900 | 3900 | { |
@@ -3916,12 +3916,12 @@ discard block |
||
| 3916 | 3916 | } |
| 3917 | 3917 | protected function sendHttpHeader() |
| 3918 | 3918 | { |
| 3919 | - $protocol=$this->getRequest()->getHttpProtocolVersion(); |
|
| 3920 | - if($this->getRequest()->getHttpProtocolVersion() === null) |
|
| 3921 | - $protocol='HTTP/1.1'; |
|
| 3919 | + $protocol = $this->getRequest()->getHttpProtocolVersion(); |
|
| 3920 | + if ($this->getRequest()->getHttpProtocolVersion() === null) |
|
| 3921 | + $protocol = 'HTTP/1.1'; |
|
| 3922 | 3922 | $phpSapiName = substr(php_sapi_name(), 0, 3); |
| 3923 | 3923 | $cgi = $phpSapiName == 'cgi' || $phpSapiName == 'fpm'; |
| 3924 | - header(($cgi ? 'Status:' : $protocol).' '.$this->_status.' '.$this->_reason, true, TPropertyValue::ensureInteger($this->_status)); |
|
| 3924 | + header(($cgi ? 'Status:' : $protocol) . ' ' . $this->_status . ' ' . $this->_reason, true, TPropertyValue::ensureInteger($this->_status)); |
|
| 3925 | 3925 | $this->_httpHeaderSent = true; |
| 3926 | 3926 | } |
| 3927 | 3927 | protected function ensureContentTypeHeaderSent() |
@@ -3931,58 +3931,58 @@ discard block |
||
| 3931 | 3931 | } |
| 3932 | 3932 | protected function sendContentTypeHeader() |
| 3933 | 3933 | { |
| 3934 | - $contentType=$this->_contentType===null?self::DEFAULT_CONTENTTYPE:$this->_contentType; |
|
| 3935 | - $charset=$this->getCharset(); |
|
| 3936 | - if($charset === false) { |
|
| 3937 | - $this->appendHeader('Content-Type: '.$contentType); |
|
| 3934 | + $contentType = $this->_contentType === null ? self::DEFAULT_CONTENTTYPE : $this->_contentType; |
|
| 3935 | + $charset = $this->getCharset(); |
|
| 3936 | + if ($charset === false) { |
|
| 3937 | + $this->appendHeader('Content-Type: ' . $contentType); |
|
| 3938 | 3938 | return; |
| 3939 | 3939 | } |
| 3940 | - if($charset==='' && ($globalization=$this->getApplication()->getGlobalization(false))!==null) |
|
| 3941 | - $charset=$globalization->getCharset(); |
|
| 3942 | - if($charset==='') $charset = self::DEFAULT_CHARSET; |
|
| 3943 | - $this->appendHeader('Content-Type: '.$contentType.';charset='.$charset); |
|
| 3940 | + if ($charset === '' && ($globalization = $this->getApplication()->getGlobalization(false)) !== null) |
|
| 3941 | + $charset = $globalization->getCharset(); |
|
| 3942 | + if ($charset === '') $charset = self::DEFAULT_CHARSET; |
|
| 3943 | + $this->appendHeader('Content-Type: ' . $contentType . ';charset=' . $charset); |
|
| 3944 | 3944 | $this->_contentTypeHeaderSent = true; |
| 3945 | 3945 | } |
| 3946 | 3946 | public function getContents() |
| 3947 | 3947 | { |
| 3948 | - return $this->_bufferOutput?ob_get_contents():''; |
|
| 3948 | + return $this->_bufferOutput ? ob_get_contents() : ''; |
|
| 3949 | 3949 | } |
| 3950 | 3950 | public function clear() |
| 3951 | 3951 | { |
| 3952 | - if($this->_bufferOutput) |
|
| 3952 | + if ($this->_bufferOutput) |
|
| 3953 | 3953 | ob_clean(); |
| 3954 | 3954 | } |
| 3955 | - public function getHeaders($case=null) |
|
| 3955 | + public function getHeaders($case = null) |
|
| 3956 | 3956 | { |
| 3957 | 3957 | $result = array(); |
| 3958 | 3958 | $headers = headers_list(); |
| 3959 | - foreach($headers as $header) { |
|
| 3959 | + foreach ($headers as $header) { |
|
| 3960 | 3960 | $tmp = explode(':', $header); |
| 3961 | 3961 | $key = trim(array_shift($tmp)); |
| 3962 | 3962 | $value = trim(implode(':', $tmp)); |
| 3963 | - if(isset($result[$key])) |
|
| 3963 | + if (isset($result[$key])) |
|
| 3964 | 3964 | $result[$key] .= ', ' . $value; |
| 3965 | 3965 | else |
| 3966 | 3966 | $result[$key] = $value; |
| 3967 | 3967 | } |
| 3968 | - if($case !== null) |
|
| 3968 | + if ($case !== null) |
|
| 3969 | 3969 | return array_change_key_case($result, $case); |
| 3970 | 3970 | return $result; |
| 3971 | 3971 | } |
| 3972 | - public function appendHeader($value, $replace=true) |
|
| 3972 | + public function appendHeader($value, $replace = true) |
|
| 3973 | 3973 | { |
| 3974 | 3974 | header($value, $replace); |
| 3975 | 3975 | } |
| 3976 | - public function appendLog($message,$messageType=0,$destination='',$extraHeaders='') |
|
| 3976 | + public function appendLog($message, $messageType = 0, $destination = '', $extraHeaders = '') |
|
| 3977 | 3977 | { |
| 3978 | - error_log($message,$messageType,$destination,$extraHeaders); |
|
| 3978 | + error_log($message, $messageType, $destination, $extraHeaders); |
|
| 3979 | 3979 | } |
| 3980 | 3980 | public function addCookie($cookie) |
| 3981 | 3981 | { |
| 3982 | - $request=$this->getRequest(); |
|
| 3983 | - if($request->getEnableCookieValidation()) |
|
| 3982 | + $request = $this->getRequest(); |
|
| 3983 | + if ($request->getEnableCookieValidation()) |
|
| 3984 | 3984 | { |
| 3985 | - $value=$this->getApplication()->getSecurityManager()->hashData($cookie->getValue()); |
|
| 3985 | + $value = $this->getApplication()->getSecurityManager()->hashData($cookie->getValue()); |
|
| 3986 | 3986 | setcookie( |
| 3987 | 3987 | $cookie->getName(), |
| 3988 | 3988 | $value, |
@@ -4023,13 +4023,13 @@ discard block |
||
| 4023 | 4023 | } |
| 4024 | 4024 | public function setHtmlWriterType($value) |
| 4025 | 4025 | { |
| 4026 | - $this->_htmlWriterType=$value; |
|
| 4026 | + $this->_htmlWriterType = $value; |
|
| 4027 | 4027 | } |
| 4028 | - public function createHtmlWriter($type=null) |
|
| 4028 | + public function createHtmlWriter($type = null) |
|
| 4029 | 4029 | { |
| 4030 | - if($type===null) |
|
| 4031 | - $type=$this->getHtmlWriterType(); |
|
| 4032 | - if($this->getHasAdapter()) |
|
| 4030 | + if ($type === null) |
|
| 4031 | + $type = $this->getHtmlWriterType(); |
|
| 4032 | + if ($this->getHasAdapter()) |
|
| 4033 | 4033 | return $this->_adapter->createNewHtmlWriter($type, $this); |
| 4034 | 4034 | else |
| 4035 | 4035 | return $this->createNewHtmlWriter($type, $this); |
@@ -4039,60 +4039,60 @@ discard block |
||
| 4039 | 4039 | return Prado::createComponent($type, $writer); |
| 4040 | 4040 | } |
| 4041 | 4041 | } |
| 4042 | -class THttpSession extends TApplicationComponent implements IteratorAggregate,ArrayAccess,Countable,IModule |
|
| 4042 | +class THttpSession extends TApplicationComponent implements IteratorAggregate, ArrayAccess, Countable, IModule |
|
| 4043 | 4043 | { |
| 4044 | - private $_initialized=false; |
|
| 4045 | - private $_started=false; |
|
| 4046 | - private $_autoStart=false; |
|
| 4047 | - private $_cookie=null; |
|
| 4044 | + private $_initialized = false; |
|
| 4045 | + private $_started = false; |
|
| 4046 | + private $_autoStart = false; |
|
| 4047 | + private $_cookie = null; |
|
| 4048 | 4048 | private $_id; |
| 4049 | - private $_customStorage=false; |
|
| 4049 | + private $_customStorage = false; |
|
| 4050 | 4050 | public function getID() |
| 4051 | 4051 | { |
| 4052 | 4052 | return $this->_id; |
| 4053 | 4053 | } |
| 4054 | 4054 | public function setID($value) |
| 4055 | 4055 | { |
| 4056 | - $this->_id=$value; |
|
| 4056 | + $this->_id = $value; |
|
| 4057 | 4057 | } |
| 4058 | 4058 | public function init($config) |
| 4059 | 4059 | { |
| 4060 | - if($this->_autoStart) |
|
| 4060 | + if ($this->_autoStart) |
|
| 4061 | 4061 | $this->open(); |
| 4062 | - $this->_initialized=true; |
|
| 4062 | + $this->_initialized = true; |
|
| 4063 | 4063 | $this->getApplication()->setSession($this); |
| 4064 | 4064 | register_shutdown_function(array($this, "close")); |
| 4065 | 4065 | } |
| 4066 | 4066 | public function open() |
| 4067 | 4067 | { |
| 4068 | - if(!$this->_started) |
|
| 4068 | + if (!$this->_started) |
|
| 4069 | 4069 | { |
| 4070 | - if($this->_customStorage) |
|
| 4071 | - session_set_save_handler(array($this,'_open'),array($this,'_close'),array($this,'_read'),array($this,'_write'),array($this,'_destroy'),array($this,'_gc')); |
|
| 4072 | - if($this->_cookie!==null) |
|
| 4073 | - session_set_cookie_params($this->_cookie->getExpire(),$this->_cookie->getPath(),$this->_cookie->getDomain(),$this->_cookie->getSecure(),$this->_cookie->getHttpOnly()); |
|
| 4074 | - if(ini_get('session.auto_start')!=='1') |
|
| 4070 | + if ($this->_customStorage) |
|
| 4071 | + session_set_save_handler(array($this, '_open'), array($this, '_close'), array($this, '_read'), array($this, '_write'), array($this, '_destroy'), array($this, '_gc')); |
|
| 4072 | + if ($this->_cookie !== null) |
|
| 4073 | + session_set_cookie_params($this->_cookie->getExpire(), $this->_cookie->getPath(), $this->_cookie->getDomain(), $this->_cookie->getSecure(), $this->_cookie->getHttpOnly()); |
|
| 4074 | + if (ini_get('session.auto_start') !== '1') |
|
| 4075 | 4075 | session_start(); |
| 4076 | - $this->_started=true; |
|
| 4076 | + $this->_started = true; |
|
| 4077 | 4077 | } |
| 4078 | 4078 | } |
| 4079 | 4079 | public function close() |
| 4080 | 4080 | { |
| 4081 | - if($this->_started) |
|
| 4081 | + if ($this->_started) |
|
| 4082 | 4082 | { |
| 4083 | 4083 | session_write_close(); |
| 4084 | - $this->_started=false; |
|
| 4084 | + $this->_started = false; |
|
| 4085 | 4085 | } |
| 4086 | 4086 | } |
| 4087 | 4087 | public function destroy() |
| 4088 | 4088 | { |
| 4089 | - if($this->_started) |
|
| 4089 | + if ($this->_started) |
|
| 4090 | 4090 | { |
| 4091 | 4091 | session_destroy(); |
| 4092 | - $this->_started=false; |
|
| 4092 | + $this->_started = false; |
|
| 4093 | 4093 | } |
| 4094 | 4094 | } |
| 4095 | - public function regenerate($deleteOld=false) |
|
| 4095 | + public function regenerate($deleteOld = false) |
|
| 4096 | 4096 | { |
| 4097 | 4097 | $old = $this->getSessionID(); |
| 4098 | 4098 | session_regenerate_id($deleteOld); |
@@ -4108,7 +4108,7 @@ discard block |
||
| 4108 | 4108 | } |
| 4109 | 4109 | public function setSessionID($value) |
| 4110 | 4110 | { |
| 4111 | - if($this->_started) |
|
| 4111 | + if ($this->_started) |
|
| 4112 | 4112 | throw new TInvalidOperationException('httpsession_sessionid_unchangeable'); |
| 4113 | 4113 | else |
| 4114 | 4114 | session_id($value); |
@@ -4119,12 +4119,12 @@ discard block |
||
| 4119 | 4119 | } |
| 4120 | 4120 | public function setSessionName($value) |
| 4121 | 4121 | { |
| 4122 | - if($this->_started) |
|
| 4122 | + if ($this->_started) |
|
| 4123 | 4123 | throw new TInvalidOperationException('httpsession_sessionname_unchangeable'); |
| 4124 | - else if(ctype_alnum($value)) |
|
| 4124 | + else if (ctype_alnum($value)) |
|
| 4125 | 4125 | session_name($value); |
| 4126 | 4126 | else |
| 4127 | - throw new TInvalidDataValueException('httpsession_sessionname_invalid',$value); |
|
| 4127 | + throw new TInvalidDataValueException('httpsession_sessionname_invalid', $value); |
|
| 4128 | 4128 | } |
| 4129 | 4129 | public function getSavePath() |
| 4130 | 4130 | { |
@@ -4132,12 +4132,12 @@ discard block |
||
| 4132 | 4132 | } |
| 4133 | 4133 | public function setSavePath($value) |
| 4134 | 4134 | { |
| 4135 | - if($this->_started) |
|
| 4135 | + if ($this->_started) |
|
| 4136 | 4136 | throw new TInvalidOperationException('httpsession_savepath_unchangeable'); |
| 4137 | - else if(is_dir($value)) |
|
| 4137 | + else if (is_dir($value)) |
|
| 4138 | 4138 | session_save_path($value); |
| 4139 | 4139 | else |
| 4140 | - throw new TInvalidDataValueException('httpsession_savepath_invalid',$value); |
|
| 4140 | + throw new TInvalidDataValueException('httpsession_savepath_invalid', $value); |
|
| 4141 | 4141 | } |
| 4142 | 4142 | public function getUseCustomStorage() |
| 4143 | 4143 | { |
@@ -4145,44 +4145,44 @@ discard block |
||
| 4145 | 4145 | } |
| 4146 | 4146 | public function setUseCustomStorage($value) |
| 4147 | 4147 | { |
| 4148 | - $this->_customStorage=TPropertyValue::ensureBoolean($value); |
|
| 4148 | + $this->_customStorage = TPropertyValue::ensureBoolean($value); |
|
| 4149 | 4149 | } |
| 4150 | 4150 | public function getCookie() |
| 4151 | 4151 | { |
| 4152 | - if($this->_cookie===null) |
|
| 4153 | - $this->_cookie=new THttpCookie($this->getSessionName(),$this->getSessionID()); |
|
| 4152 | + if ($this->_cookie === null) |
|
| 4153 | + $this->_cookie = new THttpCookie($this->getSessionName(), $this->getSessionID()); |
|
| 4154 | 4154 | return $this->_cookie; |
| 4155 | 4155 | } |
| 4156 | 4156 | public function getCookieMode() |
| 4157 | 4157 | { |
| 4158 | - if(ini_get('session.use_cookies')==='0') |
|
| 4158 | + if (ini_get('session.use_cookies') === '0') |
|
| 4159 | 4159 | return THttpSessionCookieMode::None; |
| 4160 | - else if(ini_get('session.use_only_cookies')==='0') |
|
| 4160 | + else if (ini_get('session.use_only_cookies') === '0') |
|
| 4161 | 4161 | return THttpSessionCookieMode::Allow; |
| 4162 | 4162 | else |
| 4163 | 4163 | return THttpSessionCookieMode::Only; |
| 4164 | 4164 | } |
| 4165 | 4165 | public function setCookieMode($value) |
| 4166 | 4166 | { |
| 4167 | - if($this->_started) |
|
| 4167 | + if ($this->_started) |
|
| 4168 | 4168 | throw new TInvalidOperationException('httpsession_cookiemode_unchangeable'); |
| 4169 | 4169 | else |
| 4170 | 4170 | { |
| 4171 | - $value=TPropertyValue::ensureEnum($value,'THttpSessionCookieMode'); |
|
| 4172 | - if($value===THttpSessionCookieMode::None) |
|
| 4171 | + $value = TPropertyValue::ensureEnum($value, 'THttpSessionCookieMode'); |
|
| 4172 | + if ($value === THttpSessionCookieMode::None) |
|
| 4173 | 4173 | { |
| 4174 | - ini_set('session.use_cookies','0'); |
|
| 4175 | - ini_set('session.use_only_cookies','0'); |
|
| 4174 | + ini_set('session.use_cookies', '0'); |
|
| 4175 | + ini_set('session.use_only_cookies', '0'); |
|
| 4176 | 4176 | } |
| 4177 | - else if($value===THttpSessionCookieMode::Allow) |
|
| 4177 | + else if ($value === THttpSessionCookieMode::Allow) |
|
| 4178 | 4178 | { |
| 4179 | - ini_set('session.use_cookies','1'); |
|
| 4180 | - ini_set('session.use_only_cookies','0'); |
|
| 4179 | + ini_set('session.use_cookies', '1'); |
|
| 4180 | + ini_set('session.use_only_cookies', '0'); |
|
| 4181 | 4181 | } |
| 4182 | 4182 | else |
| 4183 | 4183 | { |
| 4184 | - ini_set('session.use_cookies','1'); |
|
| 4185 | - ini_set('session.use_only_cookies','1'); |
|
| 4184 | + ini_set('session.use_cookies', '1'); |
|
| 4185 | + ini_set('session.use_only_cookies', '1'); |
|
| 4186 | 4186 | ini_set('session.use_trans_sid', 0); |
| 4187 | 4187 | } |
| 4188 | 4188 | } |
@@ -4193,10 +4193,10 @@ discard block |
||
| 4193 | 4193 | } |
| 4194 | 4194 | public function setAutoStart($value) |
| 4195 | 4195 | { |
| 4196 | - if($this->_initialized) |
|
| 4196 | + if ($this->_initialized) |
|
| 4197 | 4197 | throw new TInvalidOperationException('httpsession_autostart_unchangeable'); |
| 4198 | 4198 | else |
| 4199 | - $this->_autoStart=TPropertyValue::ensureBoolean($value); |
|
| 4199 | + $this->_autoStart = TPropertyValue::ensureBoolean($value); |
|
| 4200 | 4200 | } |
| 4201 | 4201 | public function getGCProbability() |
| 4202 | 4202 | { |
@@ -4204,34 +4204,34 @@ discard block |
||
| 4204 | 4204 | } |
| 4205 | 4205 | public function setGCProbability($value) |
| 4206 | 4206 | { |
| 4207 | - if($this->_started) |
|
| 4207 | + if ($this->_started) |
|
| 4208 | 4208 | throw new TInvalidOperationException('httpsession_gcprobability_unchangeable'); |
| 4209 | 4209 | else |
| 4210 | 4210 | { |
| 4211 | - $value=TPropertyValue::ensureInteger($value); |
|
| 4212 | - if($value>=0 && $value<=100) |
|
| 4211 | + $value = TPropertyValue::ensureInteger($value); |
|
| 4212 | + if ($value >= 0 && $value <= 100) |
|
| 4213 | 4213 | { |
| 4214 | - ini_set('session.gc_probability',$value); |
|
| 4215 | - ini_set('session.gc_divisor','100'); |
|
| 4214 | + ini_set('session.gc_probability', $value); |
|
| 4215 | + ini_set('session.gc_divisor', '100'); |
|
| 4216 | 4216 | } |
| 4217 | 4217 | else |
| 4218 | - throw new TInvalidDataValueException('httpsession_gcprobability_invalid',$value); |
|
| 4218 | + throw new TInvalidDataValueException('httpsession_gcprobability_invalid', $value); |
|
| 4219 | 4219 | } |
| 4220 | 4220 | } |
| 4221 | 4221 | public function getUseTransparentSessionID() |
| 4222 | 4222 | { |
| 4223 | - return ini_get('session.use_trans_sid')==='1'; |
|
| 4223 | + return ini_get('session.use_trans_sid') === '1'; |
|
| 4224 | 4224 | } |
| 4225 | 4225 | public function setUseTransparentSessionID($value) |
| 4226 | 4226 | { |
| 4227 | - if($this->_started) |
|
| 4227 | + if ($this->_started) |
|
| 4228 | 4228 | throw new TInvalidOperationException('httpsession_transid_unchangeable'); |
| 4229 | 4229 | else |
| 4230 | 4230 | { |
| 4231 | - $value=TPropertyValue::ensureBoolean($value); |
|
| 4232 | - if ($value && $this->getCookieMode()==THttpSessionCookieMode::Only) |
|
| 4231 | + $value = TPropertyValue::ensureBoolean($value); |
|
| 4232 | + if ($value && $this->getCookieMode() == THttpSessionCookieMode::Only) |
|
| 4233 | 4233 | throw new TInvalidOperationException('httpsession_transid_cookieonly'); |
| 4234 | - ini_set('session.use_trans_sid',$value?'1':'0'); |
|
| 4234 | + ini_set('session.use_trans_sid', $value ? '1' : '0'); |
|
| 4235 | 4235 | } |
| 4236 | 4236 | } |
| 4237 | 4237 | public function getTimeout() |
@@ -4240,12 +4240,12 @@ discard block |
||
| 4240 | 4240 | } |
| 4241 | 4241 | public function setTimeout($value) |
| 4242 | 4242 | { |
| 4243 | - if($this->_started) |
|
| 4243 | + if ($this->_started) |
|
| 4244 | 4244 | throw new TInvalidOperationException('httpsession_maxlifetime_unchangeable'); |
| 4245 | 4245 | else |
| 4246 | - ini_set('session.gc_maxlifetime',$value); |
|
| 4246 | + ini_set('session.gc_maxlifetime', $value); |
|
| 4247 | 4247 | } |
| 4248 | - public function _open($savePath,$sessionName) |
|
| 4248 | + public function _open($savePath, $sessionName) |
|
| 4249 | 4249 | { |
| 4250 | 4250 | return true; |
| 4251 | 4251 | } |
@@ -4257,7 +4257,7 @@ discard block |
||
| 4257 | 4257 | { |
| 4258 | 4258 | return ''; |
| 4259 | 4259 | } |
| 4260 | - public function _write($id,$data) |
|
| 4260 | + public function _write($id, $data) |
|
| 4261 | 4261 | { |
| 4262 | 4262 | return true; |
| 4263 | 4263 | } |
@@ -4289,15 +4289,15 @@ discard block |
||
| 4289 | 4289 | { |
| 4290 | 4290 | return isset($_SESSION[$key]) ? $_SESSION[$key] : null; |
| 4291 | 4291 | } |
| 4292 | - public function add($key,$value) |
|
| 4292 | + public function add($key, $value) |
|
| 4293 | 4293 | { |
| 4294 | - $_SESSION[$key]=$value; |
|
| 4294 | + $_SESSION[$key] = $value; |
|
| 4295 | 4295 | } |
| 4296 | 4296 | public function remove($key) |
| 4297 | 4297 | { |
| 4298 | - if(isset($_SESSION[$key])) |
|
| 4298 | + if (isset($_SESSION[$key])) |
|
| 4299 | 4299 | { |
| 4300 | - $value=$_SESSION[$key]; |
|
| 4300 | + $value = $_SESSION[$key]; |
|
| 4301 | 4301 | unset($_SESSION[$key]); |
| 4302 | 4302 | return $value; |
| 4303 | 4303 | } |
@@ -4306,7 +4306,7 @@ discard block |
||
| 4306 | 4306 | } |
| 4307 | 4307 | public function clear() |
| 4308 | 4308 | { |
| 4309 | - foreach(array_keys($_SESSION) as $key) |
|
| 4309 | + foreach (array_keys($_SESSION) as $key) |
|
| 4310 | 4310 | unset($_SESSION[$key]); |
| 4311 | 4311 | } |
| 4312 | 4312 | public function contains($key) |
@@ -4325,9 +4325,9 @@ discard block |
||
| 4325 | 4325 | { |
| 4326 | 4326 | return isset($_SESSION[$offset]) ? $_SESSION[$offset] : null; |
| 4327 | 4327 | } |
| 4328 | - public function offsetSet($offset,$item) |
|
| 4328 | + public function offsetSet($offset, $item) |
|
| 4329 | 4329 | { |
| 4330 | - $_SESSION[$offset]=$item; |
|
| 4330 | + $_SESSION[$offset] = $item; |
|
| 4331 | 4331 | } |
| 4332 | 4332 | public function offsetUnset($offset) |
| 4333 | 4333 | { |
@@ -4340,11 +4340,11 @@ discard block |
||
| 4340 | 4340 | private $_key; |
| 4341 | 4341 | public function __construct() |
| 4342 | 4342 | { |
| 4343 | - $this->_keys=array_keys($_SESSION); |
|
| 4343 | + $this->_keys = array_keys($_SESSION); |
|
| 4344 | 4344 | } |
| 4345 | 4345 | public function rewind() |
| 4346 | 4346 | { |
| 4347 | - $this->_key=reset($this->_keys); |
|
| 4347 | + $this->_key = reset($this->_keys); |
|
| 4348 | 4348 | } |
| 4349 | 4349 | public function key() |
| 4350 | 4350 | { |
@@ -4352,44 +4352,44 @@ discard block |
||
| 4352 | 4352 | } |
| 4353 | 4353 | public function current() |
| 4354 | 4354 | { |
| 4355 | - return isset($_SESSION[$this->_key])?$_SESSION[$this->_key]:null; |
|
| 4355 | + return isset($_SESSION[$this->_key]) ? $_SESSION[$this->_key] : null; |
|
| 4356 | 4356 | } |
| 4357 | 4357 | public function next() |
| 4358 | 4358 | { |
| 4359 | 4359 | do |
| 4360 | 4360 | { |
| 4361 | - $this->_key=next($this->_keys); |
|
| 4361 | + $this->_key = next($this->_keys); |
|
| 4362 | 4362 | } |
| 4363 | - while(!isset($_SESSION[$this->_key]) && $this->_key!==false); |
|
| 4363 | + while (!isset($_SESSION[$this->_key]) && $this->_key !== false); |
|
| 4364 | 4364 | } |
| 4365 | 4365 | public function valid() |
| 4366 | 4366 | { |
| 4367 | - return $this->_key!==false; |
|
| 4367 | + return $this->_key !== false; |
|
| 4368 | 4368 | } |
| 4369 | 4369 | } |
| 4370 | 4370 | class THttpSessionCookieMode extends TEnumerable |
| 4371 | 4371 | { |
| 4372 | - const None='None'; |
|
| 4373 | - const Allow='Allow'; |
|
| 4374 | - const Only='Only'; |
|
| 4372 | + const None = 'None'; |
|
| 4373 | + const Allow = 'Allow'; |
|
| 4374 | + const Only = 'Only'; |
|
| 4375 | 4375 | } |
| 4376 | 4376 | Prado::using('System.Web.UI.WebControls.*'); |
| 4377 | 4377 | class TAttributeCollection extends TMap |
| 4378 | 4378 | { |
| 4379 | - private $_caseSensitive=false; |
|
| 4379 | + private $_caseSensitive = false; |
|
| 4380 | 4380 | protected function __getZappableSleepProps(&$exprops) |
| 4381 | 4381 | { |
| 4382 | 4382 | parent::__getZappableSleepProps($exprops); |
| 4383 | - if ($this->_caseSensitive===false) |
|
| 4383 | + if ($this->_caseSensitive === false) |
|
| 4384 | 4384 | $exprops[] = "\0TAttributeCollection\0_caseSensitive"; |
| 4385 | 4385 | } |
| 4386 | 4386 | public function __get($name) |
| 4387 | 4387 | { |
| 4388 | - return $this->contains($name)?$this->itemAt($name):parent::__get($name); |
|
| 4388 | + return $this->contains($name) ? $this->itemAt($name) : parent::__get($name); |
|
| 4389 | 4389 | } |
| 4390 | - public function __set($name,$value) |
|
| 4390 | + public function __set($name, $value) |
|
| 4391 | 4391 | { |
| 4392 | - $this->add($name,$value); |
|
| 4392 | + $this->add($name, $value); |
|
| 4393 | 4393 | } |
| 4394 | 4394 | public function getCaseSensitive() |
| 4395 | 4395 | { |
@@ -4397,23 +4397,23 @@ discard block |
||
| 4397 | 4397 | } |
| 4398 | 4398 | public function setCaseSensitive($value) |
| 4399 | 4399 | { |
| 4400 | - $this->_caseSensitive=TPropertyValue::ensureBoolean($value); |
|
| 4400 | + $this->_caseSensitive = TPropertyValue::ensureBoolean($value); |
|
| 4401 | 4401 | } |
| 4402 | 4402 | public function itemAt($key) |
| 4403 | 4403 | { |
| 4404 | - return parent::itemAt($this->_caseSensitive?$key:strtolower($key)); |
|
| 4404 | + return parent::itemAt($this->_caseSensitive ? $key : strtolower($key)); |
|
| 4405 | 4405 | } |
| 4406 | - public function add($key,$value) |
|
| 4406 | + public function add($key, $value) |
|
| 4407 | 4407 | { |
| 4408 | - parent::add($this->_caseSensitive?$key:strtolower($key),$value); |
|
| 4408 | + parent::add($this->_caseSensitive ? $key : strtolower($key), $value); |
|
| 4409 | 4409 | } |
| 4410 | 4410 | public function remove($key) |
| 4411 | 4411 | { |
| 4412 | - return parent::remove($this->_caseSensitive?$key:strtolower($key)); |
|
| 4412 | + return parent::remove($this->_caseSensitive ? $key : strtolower($key)); |
|
| 4413 | 4413 | } |
| 4414 | 4414 | public function contains($key) |
| 4415 | 4415 | { |
| 4416 | - return parent::contains($this->_caseSensitive?$key:strtolower($key)); |
|
| 4416 | + return parent::contains($this->_caseSensitive ? $key : strtolower($key)); |
|
| 4417 | 4417 | } |
| 4418 | 4418 | public function hasProperty($name) |
| 4419 | 4419 | { |
@@ -4433,7 +4433,7 @@ discard block |
||
| 4433 | 4433 | protected $_control; |
| 4434 | 4434 | public function __construct($control) |
| 4435 | 4435 | { |
| 4436 | - $this->_control=$control; |
|
| 4436 | + $this->_control = $control; |
|
| 4437 | 4437 | } |
| 4438 | 4438 | public function getControl() |
| 4439 | 4439 | { |
@@ -4441,7 +4441,7 @@ discard block |
||
| 4441 | 4441 | } |
| 4442 | 4442 | public function getPage() |
| 4443 | 4443 | { |
| 4444 | - return $this->_control?$this->_control->getPage():null; |
|
| 4444 | + return $this->_control ? $this->_control->getPage() : null; |
|
| 4445 | 4445 | } |
| 4446 | 4446 | public function createChildControls() |
| 4447 | 4447 | { |
@@ -4482,39 +4482,39 @@ discard block |
||
| 4482 | 4482 | } |
| 4483 | 4483 | class TControl extends TApplicationComponent implements IRenderable, IBindable |
| 4484 | 4484 | { |
| 4485 | - const ID_FORMAT='/^[a-zA-Z_]\\w*$/'; |
|
| 4486 | - const ID_SEPARATOR='$'; |
|
| 4487 | - const CLIENT_ID_SEPARATOR='_'; |
|
| 4488 | - const AUTOMATIC_ID_PREFIX='ctl'; |
|
| 4489 | - const CS_CONSTRUCTED=0; |
|
| 4490 | - const CS_CHILD_INITIALIZED=1; |
|
| 4491 | - const CS_INITIALIZED=2; |
|
| 4492 | - const CS_STATE_LOADED=3; |
|
| 4493 | - const CS_LOADED=4; |
|
| 4494 | - const CS_PRERENDERED=5; |
|
| 4495 | - const IS_ID_SET=0x01; |
|
| 4496 | - const IS_DISABLE_VIEWSTATE=0x02; |
|
| 4497 | - const IS_SKIN_APPLIED=0x04; |
|
| 4498 | - const IS_STYLESHEET_APPLIED=0x08; |
|
| 4499 | - const IS_DISABLE_THEMING=0x10; |
|
| 4500 | - const IS_CHILD_CREATED=0x20; |
|
| 4501 | - const IS_CREATING_CHILD=0x40; |
|
| 4502 | - const RF_CONTROLS=0; const RF_CHILD_STATE=1; const RF_NAMED_CONTROLS=2; const RF_NAMED_CONTROLS_ID=3; const RF_SKIN_ID=4; const RF_DATA_BINDINGS=5; const RF_EVENTS=6; const RF_CONTROLSTATE=7; const RF_NAMED_OBJECTS=8; const RF_ADAPTER=9; const RF_AUTO_BINDINGS=10; |
|
| 4503 | - private $_id=''; |
|
| 4485 | + const ID_FORMAT = '/^[a-zA-Z_]\\w*$/'; |
|
| 4486 | + const ID_SEPARATOR = '$'; |
|
| 4487 | + const CLIENT_ID_SEPARATOR = '_'; |
|
| 4488 | + const AUTOMATIC_ID_PREFIX = 'ctl'; |
|
| 4489 | + const CS_CONSTRUCTED = 0; |
|
| 4490 | + const CS_CHILD_INITIALIZED = 1; |
|
| 4491 | + const CS_INITIALIZED = 2; |
|
| 4492 | + const CS_STATE_LOADED = 3; |
|
| 4493 | + const CS_LOADED = 4; |
|
| 4494 | + const CS_PRERENDERED = 5; |
|
| 4495 | + const IS_ID_SET = 0x01; |
|
| 4496 | + const IS_DISABLE_VIEWSTATE = 0x02; |
|
| 4497 | + const IS_SKIN_APPLIED = 0x04; |
|
| 4498 | + const IS_STYLESHEET_APPLIED = 0x08; |
|
| 4499 | + const IS_DISABLE_THEMING = 0x10; |
|
| 4500 | + const IS_CHILD_CREATED = 0x20; |
|
| 4501 | + const IS_CREATING_CHILD = 0x40; |
|
| 4502 | + const RF_CONTROLS = 0; const RF_CHILD_STATE = 1; const RF_NAMED_CONTROLS = 2; const RF_NAMED_CONTROLS_ID = 3; const RF_SKIN_ID = 4; const RF_DATA_BINDINGS = 5; const RF_EVENTS = 6; const RF_CONTROLSTATE = 7; const RF_NAMED_OBJECTS = 8; const RF_ADAPTER = 9; const RF_AUTO_BINDINGS = 10; |
|
| 4503 | + private $_id = ''; |
|
| 4504 | 4504 | private $_uid; |
| 4505 | 4505 | private $_parent; |
| 4506 | 4506 | private $_page; |
| 4507 | 4507 | private $_namingContainer; |
| 4508 | 4508 | private $_tplControl; |
| 4509 | - private $_viewState=array(); |
|
| 4510 | - private $_tempState=array(); |
|
| 4511 | - private $_trackViewState=true; |
|
| 4512 | - private $_stage=0; |
|
| 4513 | - private $_flags=0; |
|
| 4514 | - private $_rf=array(); |
|
| 4509 | + private $_viewState = array(); |
|
| 4510 | + private $_tempState = array(); |
|
| 4511 | + private $_trackViewState = true; |
|
| 4512 | + private $_stage = 0; |
|
| 4513 | + private $_flags = 0; |
|
| 4514 | + private $_rf = array(); |
|
| 4515 | 4515 | public function __get($name) |
| 4516 | 4516 | { |
| 4517 | - if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
|
| 4517 | + if (isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
|
| 4518 | 4518 | return $this->_rf[self::RF_NAMED_OBJECTS][$name]; |
| 4519 | 4519 | else |
| 4520 | 4520 | return parent::__get($name); |
@@ -4525,11 +4525,11 @@ discard block |
||
| 4525 | 4525 | } |
| 4526 | 4526 | public function getAdapter() |
| 4527 | 4527 | { |
| 4528 | - return isset($this->_rf[self::RF_ADAPTER])?$this->_rf[self::RF_ADAPTER]:null; |
|
| 4528 | + return isset($this->_rf[self::RF_ADAPTER]) ? $this->_rf[self::RF_ADAPTER] : null; |
|
| 4529 | 4529 | } |
| 4530 | 4530 | public function setAdapter(TControlAdapter $adapter) |
| 4531 | 4531 | { |
| 4532 | - $this->_rf[self::RF_ADAPTER]=$adapter; |
|
| 4532 | + $this->_rf[self::RF_ADAPTER] = $adapter; |
|
| 4533 | 4533 | } |
| 4534 | 4534 | public function getParent() |
| 4535 | 4535 | { |
@@ -4537,46 +4537,46 @@ discard block |
||
| 4537 | 4537 | } |
| 4538 | 4538 | public function getNamingContainer() |
| 4539 | 4539 | { |
| 4540 | - if(!$this->_namingContainer && $this->_parent) |
|
| 4540 | + if (!$this->_namingContainer && $this->_parent) |
|
| 4541 | 4541 | { |
| 4542 | - if($this->_parent instanceof INamingContainer) |
|
| 4543 | - $this->_namingContainer=$this->_parent; |
|
| 4542 | + if ($this->_parent instanceof INamingContainer) |
|
| 4543 | + $this->_namingContainer = $this->_parent; |
|
| 4544 | 4544 | else |
| 4545 | - $this->_namingContainer=$this->_parent->getNamingContainer(); |
|
| 4545 | + $this->_namingContainer = $this->_parent->getNamingContainer(); |
|
| 4546 | 4546 | } |
| 4547 | 4547 | return $this->_namingContainer; |
| 4548 | 4548 | } |
| 4549 | 4549 | public function getPage() |
| 4550 | 4550 | { |
| 4551 | - if(!$this->_page) |
|
| 4551 | + if (!$this->_page) |
|
| 4552 | 4552 | { |
| 4553 | - if($this->_parent) |
|
| 4554 | - $this->_page=$this->_parent->getPage(); |
|
| 4555 | - else if($this->_tplControl) |
|
| 4556 | - $this->_page=$this->_tplControl->getPage(); |
|
| 4553 | + if ($this->_parent) |
|
| 4554 | + $this->_page = $this->_parent->getPage(); |
|
| 4555 | + else if ($this->_tplControl) |
|
| 4556 | + $this->_page = $this->_tplControl->getPage(); |
|
| 4557 | 4557 | } |
| 4558 | 4558 | return $this->_page; |
| 4559 | 4559 | } |
| 4560 | 4560 | public function setPage($page) |
| 4561 | 4561 | { |
| 4562 | - $this->_page=$page; |
|
| 4562 | + $this->_page = $page; |
|
| 4563 | 4563 | } |
| 4564 | 4564 | public function setTemplateControl($control) |
| 4565 | 4565 | { |
| 4566 | - $this->_tplControl=$control; |
|
| 4566 | + $this->_tplControl = $control; |
|
| 4567 | 4567 | } |
| 4568 | 4568 | public function getTemplateControl() |
| 4569 | 4569 | { |
| 4570 | - if(!$this->_tplControl && $this->_parent) |
|
| 4571 | - $this->_tplControl=$this->_parent->getTemplateControl(); |
|
| 4570 | + if (!$this->_tplControl && $this->_parent) |
|
| 4571 | + $this->_tplControl = $this->_parent->getTemplateControl(); |
|
| 4572 | 4572 | return $this->_tplControl; |
| 4573 | 4573 | } |
| 4574 | 4574 | public function getSourceTemplateControl() |
| 4575 | 4575 | { |
| 4576 | - $control=$this; |
|
| 4577 | - while(($control instanceof TControl) && ($control=$control->getTemplateControl())!==null) |
|
| 4576 | + $control = $this; |
|
| 4577 | + while (($control instanceof TControl) && ($control = $control->getTemplateControl()) !== null) |
|
| 4578 | 4578 | { |
| 4579 | - if(($control instanceof TTemplateControl) && $control->getIsSourceTemplateControl()) |
|
| 4579 | + if (($control instanceof TTemplateControl) && $control->getIsSourceTemplateControl()) |
|
| 4580 | 4580 | return $control; |
| 4581 | 4581 | } |
| 4582 | 4582 | return $this->getPage(); |
@@ -4587,36 +4587,36 @@ discard block |
||
| 4587 | 4587 | } |
| 4588 | 4588 | protected function setControlStage($value) |
| 4589 | 4589 | { |
| 4590 | - $this->_stage=$value; |
|
| 4590 | + $this->_stage = $value; |
|
| 4591 | 4591 | } |
| 4592 | - public function getID($hideAutoID=true) |
|
| 4592 | + public function getID($hideAutoID = true) |
|
| 4593 | 4593 | { |
| 4594 | - if($hideAutoID) |
|
| 4594 | + if ($hideAutoID) |
|
| 4595 | 4595 | return ($this->_flags & self::IS_ID_SET) ? $this->_id : ''; |
| 4596 | 4596 | else |
| 4597 | 4597 | return $this->_id; |
| 4598 | 4598 | } |
| 4599 | 4599 | public function setID($id) |
| 4600 | 4600 | { |
| 4601 | - if(!preg_match(self::ID_FORMAT,$id)) |
|
| 4602 | - throw new TInvalidDataValueException('control_id_invalid',get_class($this),$id); |
|
| 4603 | - $this->_id=$id; |
|
| 4601 | + if (!preg_match(self::ID_FORMAT, $id)) |
|
| 4602 | + throw new TInvalidDataValueException('control_id_invalid', get_class($this), $id); |
|
| 4603 | + $this->_id = $id; |
|
| 4604 | 4604 | $this->_flags |= self::IS_ID_SET; |
| 4605 | 4605 | $this->clearCachedUniqueID($this instanceof INamingContainer); |
| 4606 | - if($this->_namingContainer) |
|
| 4606 | + if ($this->_namingContainer) |
|
| 4607 | 4607 | $this->_namingContainer->clearNameTable(); |
| 4608 | 4608 | } |
| 4609 | 4609 | public function getUniqueID() |
| 4610 | 4610 | { |
| 4611 | - if($this->_uid==='' || $this->_uid===null) { |
|
| 4612 | - $this->_uid=''; if($namingContainer=$this->getNamingContainer()) |
|
| 4611 | + if ($this->_uid === '' || $this->_uid === null) { |
|
| 4612 | + $this->_uid = ''; if ($namingContainer = $this->getNamingContainer()) |
|
| 4613 | 4613 | { |
| 4614 | - if($this->getPage()===$namingContainer) |
|
| 4615 | - return ($this->_uid=$this->_id); |
|
| 4616 | - else if(($prefix=$namingContainer->getUniqueID())==='') |
|
| 4614 | + if ($this->getPage() === $namingContainer) |
|
| 4615 | + return ($this->_uid = $this->_id); |
|
| 4616 | + else if (($prefix = $namingContainer->getUniqueID()) === '') |
|
| 4617 | 4617 | return $this->_id; |
| 4618 | 4618 | else |
| 4619 | - return ($this->_uid=$prefix.self::ID_SEPARATOR.$this->_id); |
|
| 4619 | + return ($this->_uid = $prefix . self::ID_SEPARATOR . $this->_id); |
|
| 4620 | 4620 | } |
| 4621 | 4621 | else return $this->_id; |
| 4622 | 4622 | } |
@@ -4629,22 +4629,22 @@ discard block |
||
| 4629 | 4629 | } |
| 4630 | 4630 | public function getClientID() |
| 4631 | 4631 | { |
| 4632 | - return strtr($this->getUniqueID(),self::ID_SEPARATOR,self::CLIENT_ID_SEPARATOR); |
|
| 4632 | + return strtr($this->getUniqueID(), self::ID_SEPARATOR, self::CLIENT_ID_SEPARATOR); |
|
| 4633 | 4633 | } |
| 4634 | 4634 | public static function convertUniqueIdToClientId($uniqueID) |
| 4635 | 4635 | { |
| 4636 | - return strtr($uniqueID,self::ID_SEPARATOR,self::CLIENT_ID_SEPARATOR); |
|
| 4636 | + return strtr($uniqueID, self::ID_SEPARATOR, self::CLIENT_ID_SEPARATOR); |
|
| 4637 | 4637 | } |
| 4638 | 4638 | public function getSkinID() |
| 4639 | 4639 | { |
| 4640 | - return isset($this->_rf[self::RF_SKIN_ID])?$this->_rf[self::RF_SKIN_ID]:''; |
|
| 4640 | + return isset($this->_rf[self::RF_SKIN_ID]) ? $this->_rf[self::RF_SKIN_ID] : ''; |
|
| 4641 | 4641 | } |
| 4642 | 4642 | public function setSkinID($value) |
| 4643 | 4643 | { |
| 4644 | - if(($this->_flags & self::IS_SKIN_APPLIED) || $this->_stage>=self::CS_CHILD_INITIALIZED) |
|
| 4645 | - throw new TInvalidOperationException('control_skinid_unchangeable',get_class($this)); |
|
| 4644 | + if (($this->_flags & self::IS_SKIN_APPLIED) || $this->_stage >= self::CS_CHILD_INITIALIZED) |
|
| 4645 | + throw new TInvalidOperationException('control_skinid_unchangeable', get_class($this)); |
|
| 4646 | 4646 | else |
| 4647 | - $this->_rf[self::RF_SKIN_ID]=$value; |
|
| 4647 | + $this->_rf[self::RF_SKIN_ID] = $value; |
|
| 4648 | 4648 | } |
| 4649 | 4649 | public function getIsSkinApplied() |
| 4650 | 4650 | { |
@@ -4652,123 +4652,123 @@ discard block |
||
| 4652 | 4652 | } |
| 4653 | 4653 | public function getEnableTheming() |
| 4654 | 4654 | { |
| 4655 | - if($this->_flags & self::IS_DISABLE_THEMING) |
|
| 4655 | + if ($this->_flags & self::IS_DISABLE_THEMING) |
|
| 4656 | 4656 | return false; |
| 4657 | 4657 | else |
| 4658 | - return $this->_parent?$this->_parent->getEnableTheming():true; |
|
| 4658 | + return $this->_parent ? $this->_parent->getEnableTheming() : true; |
|
| 4659 | 4659 | } |
| 4660 | 4660 | public function setEnableTheming($value) |
| 4661 | 4661 | { |
| 4662 | - if($this->_stage>=self::CS_CHILD_INITIALIZED) |
|
| 4663 | - throw new TInvalidOperationException('control_enabletheming_unchangeable',get_class($this),$this->getUniqueID()); |
|
| 4664 | - else if(TPropertyValue::ensureBoolean($value)) |
|
| 4662 | + if ($this->_stage >= self::CS_CHILD_INITIALIZED) |
|
| 4663 | + throw new TInvalidOperationException('control_enabletheming_unchangeable', get_class($this), $this->getUniqueID()); |
|
| 4664 | + else if (TPropertyValue::ensureBoolean($value)) |
|
| 4665 | 4665 | $this->_flags &= ~self::IS_DISABLE_THEMING; |
| 4666 | 4666 | else |
| 4667 | 4667 | $this->_flags |= self::IS_DISABLE_THEMING; |
| 4668 | 4668 | } |
| 4669 | 4669 | public function getCustomData() |
| 4670 | 4670 | { |
| 4671 | - return $this->getViewState('CustomData',null); |
|
| 4671 | + return $this->getViewState('CustomData', null); |
|
| 4672 | 4672 | } |
| 4673 | 4673 | public function setCustomData($value) |
| 4674 | 4674 | { |
| 4675 | - $this->setViewState('CustomData',$value,null); |
|
| 4675 | + $this->setViewState('CustomData', $value, null); |
|
| 4676 | 4676 | } |
| 4677 | 4677 | public function getHasControls() |
| 4678 | 4678 | { |
| 4679 | - return isset($this->_rf[self::RF_CONTROLS]) && $this->_rf[self::RF_CONTROLS]->getCount()>0; |
|
| 4679 | + return isset($this->_rf[self::RF_CONTROLS]) && $this->_rf[self::RF_CONTROLS]->getCount() > 0; |
|
| 4680 | 4680 | } |
| 4681 | 4681 | public function getControls() |
| 4682 | 4682 | { |
| 4683 | - if(!isset($this->_rf[self::RF_CONTROLS])) |
|
| 4684 | - $this->_rf[self::RF_CONTROLS]=$this->createControlCollection(); |
|
| 4683 | + if (!isset($this->_rf[self::RF_CONTROLS])) |
|
| 4684 | + $this->_rf[self::RF_CONTROLS] = $this->createControlCollection(); |
|
| 4685 | 4685 | return $this->_rf[self::RF_CONTROLS]; |
| 4686 | 4686 | } |
| 4687 | 4687 | protected function createControlCollection() |
| 4688 | 4688 | { |
| 4689 | - return $this->getAllowChildControls()?new TControlCollection($this):new TEmptyControlCollection($this); |
|
| 4689 | + return $this->getAllowChildControls() ? new TControlCollection($this) : new TEmptyControlCollection($this); |
|
| 4690 | 4690 | } |
| 4691 | - public function getVisible($checkParents=true) |
|
| 4691 | + public function getVisible($checkParents = true) |
|
| 4692 | 4692 | { |
| 4693 | - if($checkParents) |
|
| 4693 | + if ($checkParents) |
|
| 4694 | 4694 | { |
| 4695 | - for($control=$this;$control;$control=$control->_parent) |
|
| 4696 | - if(!$control->getVisible(false)) |
|
| 4695 | + for ($control = $this; $control; $control = $control->_parent) |
|
| 4696 | + if (!$control->getVisible(false)) |
|
| 4697 | 4697 | return false; |
| 4698 | 4698 | return true; |
| 4699 | 4699 | } |
| 4700 | 4700 | else |
| 4701 | - return $this->getViewState('Visible',true); |
|
| 4701 | + return $this->getViewState('Visible', true); |
|
| 4702 | 4702 | } |
| 4703 | 4703 | public function setVisible($value) |
| 4704 | 4704 | { |
| 4705 | - $this->setViewState('Visible',TPropertyValue::ensureBoolean($value),true); |
|
| 4705 | + $this->setViewState('Visible', TPropertyValue::ensureBoolean($value), true); |
|
| 4706 | 4706 | } |
| 4707 | - public function getEnabled($checkParents=false) |
|
| 4707 | + public function getEnabled($checkParents = false) |
|
| 4708 | 4708 | { |
| 4709 | - if($checkParents) |
|
| 4709 | + if ($checkParents) |
|
| 4710 | 4710 | { |
| 4711 | - for($control=$this;$control;$control=$control->_parent) |
|
| 4712 | - if(!$control->getViewState('Enabled',true)) |
|
| 4711 | + for ($control = $this; $control; $control = $control->_parent) |
|
| 4712 | + if (!$control->getViewState('Enabled', true)) |
|
| 4713 | 4713 | return false; |
| 4714 | 4714 | return true; |
| 4715 | 4715 | } |
| 4716 | 4716 | else |
| 4717 | - return $this->getViewState('Enabled',true); |
|
| 4717 | + return $this->getViewState('Enabled', true); |
|
| 4718 | 4718 | } |
| 4719 | 4719 | public function setEnabled($value) |
| 4720 | 4720 | { |
| 4721 | - $this->setViewState('Enabled',TPropertyValue::ensureBoolean($value),true); |
|
| 4721 | + $this->setViewState('Enabled', TPropertyValue::ensureBoolean($value), true); |
|
| 4722 | 4722 | } |
| 4723 | 4723 | public function getHasAttributes() |
| 4724 | 4724 | { |
| 4725 | - if($attributes=$this->getViewState('Attributes',null)) |
|
| 4726 | - return $attributes->getCount()>0; |
|
| 4725 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
| 4726 | + return $attributes->getCount() > 0; |
|
| 4727 | 4727 | else |
| 4728 | 4728 | return false; |
| 4729 | 4729 | } |
| 4730 | 4730 | public function getAttributes() |
| 4731 | 4731 | { |
| 4732 | - if($attributes=$this->getViewState('Attributes',null)) |
|
| 4732 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
| 4733 | 4733 | return $attributes; |
| 4734 | 4734 | else |
| 4735 | 4735 | { |
| 4736 | - $attributes=new TAttributeCollection; |
|
| 4737 | - $this->setViewState('Attributes',$attributes,null); |
|
| 4736 | + $attributes = new TAttributeCollection; |
|
| 4737 | + $this->setViewState('Attributes', $attributes, null); |
|
| 4738 | 4738 | return $attributes; |
| 4739 | 4739 | } |
| 4740 | 4740 | } |
| 4741 | 4741 | public function hasAttribute($name) |
| 4742 | 4742 | { |
| 4743 | - if($attributes=$this->getViewState('Attributes',null)) |
|
| 4743 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
| 4744 | 4744 | return $attributes->contains($name); |
| 4745 | 4745 | else |
| 4746 | 4746 | return false; |
| 4747 | 4747 | } |
| 4748 | 4748 | public function getAttribute($name) |
| 4749 | 4749 | { |
| 4750 | - if($attributes=$this->getViewState('Attributes',null)) |
|
| 4750 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
| 4751 | 4751 | return $attributes->itemAt($name); |
| 4752 | 4752 | else |
| 4753 | 4753 | return null; |
| 4754 | 4754 | } |
| 4755 | - public function setAttribute($name,$value) |
|
| 4755 | + public function setAttribute($name, $value) |
|
| 4756 | 4756 | { |
| 4757 | - $this->getAttributes()->add($name,$value); |
|
| 4757 | + $this->getAttributes()->add($name, $value); |
|
| 4758 | 4758 | } |
| 4759 | 4759 | public function removeAttribute($name) |
| 4760 | 4760 | { |
| 4761 | - if($attributes=$this->getViewState('Attributes',null)) |
|
| 4761 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
| 4762 | 4762 | return $attributes->remove($name); |
| 4763 | 4763 | else |
| 4764 | 4764 | return null; |
| 4765 | 4765 | } |
| 4766 | - public function getEnableViewState($checkParents=false) |
|
| 4766 | + public function getEnableViewState($checkParents = false) |
|
| 4767 | 4767 | { |
| 4768 | - if($checkParents) |
|
| 4768 | + if ($checkParents) |
|
| 4769 | 4769 | { |
| 4770 | - for($control=$this;$control!==null;$control=$control->getParent()) |
|
| 4771 | - if($control->_flags & self::IS_DISABLE_VIEWSTATE) |
|
| 4770 | + for ($control = $this; $control !== null; $control = $control->getParent()) |
|
| 4771 | + if ($control->_flags & self::IS_DISABLE_VIEWSTATE) |
|
| 4772 | 4772 | return false; |
| 4773 | 4773 | return true; |
| 4774 | 4774 | } |
@@ -4777,21 +4777,21 @@ discard block |
||
| 4777 | 4777 | } |
| 4778 | 4778 | public function setEnableViewState($value) |
| 4779 | 4779 | { |
| 4780 | - if(TPropertyValue::ensureBoolean($value)) |
|
| 4780 | + if (TPropertyValue::ensureBoolean($value)) |
|
| 4781 | 4781 | $this->_flags &= ~self::IS_DISABLE_VIEWSTATE; |
| 4782 | 4782 | else |
| 4783 | 4783 | $this->_flags |= self::IS_DISABLE_VIEWSTATE; |
| 4784 | 4784 | } |
| 4785 | - protected function getControlState($key,$defaultValue=null) |
|
| 4785 | + protected function getControlState($key, $defaultValue = null) |
|
| 4786 | 4786 | { |
| 4787 | - return isset($this->_rf[self::RF_CONTROLSTATE][$key])?$this->_rf[self::RF_CONTROLSTATE][$key]:$defaultValue; |
|
| 4787 | + return isset($this->_rf[self::RF_CONTROLSTATE][$key]) ? $this->_rf[self::RF_CONTROLSTATE][$key] : $defaultValue; |
|
| 4788 | 4788 | } |
| 4789 | - protected function setControlState($key,$value,$defaultValue=null) |
|
| 4789 | + protected function setControlState($key, $value, $defaultValue = null) |
|
| 4790 | 4790 | { |
| 4791 | - if($value===$defaultValue) |
|
| 4791 | + if ($value === $defaultValue) |
|
| 4792 | 4792 | unset($this->_rf[self::RF_CONTROLSTATE][$key]); |
| 4793 | 4793 | else |
| 4794 | - $this->_rf[self::RF_CONTROLSTATE][$key]=$value; |
|
| 4794 | + $this->_rf[self::RF_CONTROLSTATE][$key] = $value; |
|
| 4795 | 4795 | } |
| 4796 | 4796 | protected function clearControlState($key) |
| 4797 | 4797 | { |
@@ -4799,38 +4799,38 @@ discard block |
||
| 4799 | 4799 | } |
| 4800 | 4800 | public function trackViewState($enabled) |
| 4801 | 4801 | { |
| 4802 | - $this->_trackViewState=TPropertyValue::ensureBoolean($enabled); |
|
| 4802 | + $this->_trackViewState = TPropertyValue::ensureBoolean($enabled); |
|
| 4803 | 4803 | } |
| 4804 | - public function getViewState($key,$defaultValue=null) |
|
| 4804 | + public function getViewState($key, $defaultValue = null) |
|
| 4805 | 4805 | { |
| 4806 | - if(isset($this->_viewState[$key])) |
|
| 4807 | - return $this->_viewState[$key]!==null?$this->_viewState[$key]:$defaultValue; |
|
| 4808 | - else if(isset($this->_tempState[$key])) |
|
| 4806 | + if (isset($this->_viewState[$key])) |
|
| 4807 | + return $this->_viewState[$key] !== null ? $this->_viewState[$key] : $defaultValue; |
|
| 4808 | + else if (isset($this->_tempState[$key])) |
|
| 4809 | 4809 | { |
| 4810 | - if(is_object($this->_tempState[$key]) && $this->_trackViewState) |
|
| 4811 | - $this->_viewState[$key]=$this->_tempState[$key]; |
|
| 4810 | + if (is_object($this->_tempState[$key]) && $this->_trackViewState) |
|
| 4811 | + $this->_viewState[$key] = $this->_tempState[$key]; |
|
| 4812 | 4812 | return $this->_tempState[$key]; |
| 4813 | 4813 | } |
| 4814 | 4814 | else |
| 4815 | 4815 | return $defaultValue; |
| 4816 | 4816 | } |
| 4817 | - public function setViewState($key,$value,$defaultValue=null) |
|
| 4817 | + public function setViewState($key, $value, $defaultValue = null) |
|
| 4818 | 4818 | { |
| 4819 | - if($this->_trackViewState) |
|
| 4819 | + if ($this->_trackViewState) |
|
| 4820 | 4820 | { |
| 4821 | 4821 | unset($this->_tempState[$key]); |
| 4822 | - if($value===$defaultValue) |
|
| 4822 | + if ($value === $defaultValue) |
|
| 4823 | 4823 | unset($this->_viewState[$key]); |
| 4824 | 4824 | else |
| 4825 | - $this->_viewState[$key]=$value; |
|
| 4825 | + $this->_viewState[$key] = $value; |
|
| 4826 | 4826 | } |
| 4827 | 4827 | else |
| 4828 | 4828 | { |
| 4829 | 4829 | unset($this->_viewState[$key]); |
| 4830 | - if($value===$defaultValue) |
|
| 4830 | + if ($value === $defaultValue) |
|
| 4831 | 4831 | unset($this->_tempState[$key]); |
| 4832 | 4832 | else |
| 4833 | - $this->_tempState[$key]=$value; |
|
| 4833 | + $this->_tempState[$key] = $value; |
|
| 4834 | 4834 | } |
| 4835 | 4835 | } |
| 4836 | 4836 | public function clearViewState($key) |
@@ -4838,17 +4838,17 @@ discard block |
||
| 4838 | 4838 | unset($this->_viewState[$key]); |
| 4839 | 4839 | unset($this->_tempState[$key]); |
| 4840 | 4840 | } |
| 4841 | - public function bindProperty($name,$expression) |
|
| 4841 | + public function bindProperty($name, $expression) |
|
| 4842 | 4842 | { |
| 4843 | - $this->_rf[self::RF_DATA_BINDINGS][$name]=$expression; |
|
| 4843 | + $this->_rf[self::RF_DATA_BINDINGS][$name] = $expression; |
|
| 4844 | 4844 | } |
| 4845 | 4845 | public function unbindProperty($name) |
| 4846 | 4846 | { |
| 4847 | 4847 | unset($this->_rf[self::RF_DATA_BINDINGS][$name]); |
| 4848 | 4848 | } |
| 4849 | - public function autoBindProperty($name,$expression) |
|
| 4849 | + public function autoBindProperty($name, $expression) |
|
| 4850 | 4850 | { |
| 4851 | - $this->_rf[self::RF_AUTO_BINDINGS][$name]=$expression; |
|
| 4851 | + $this->_rf[self::RF_AUTO_BINDINGS][$name] = $expression; |
|
| 4852 | 4852 | } |
| 4853 | 4853 | public function dataBind() |
| 4854 | 4854 | { |
@@ -4858,63 +4858,63 @@ discard block |
||
| 4858 | 4858 | } |
| 4859 | 4859 | protected function dataBindProperties() |
| 4860 | 4860 | { |
| 4861 | - if(isset($this->_rf[self::RF_DATA_BINDINGS])) |
|
| 4861 | + if (isset($this->_rf[self::RF_DATA_BINDINGS])) |
|
| 4862 | 4862 | { |
| 4863 | - if(($context=$this->getTemplateControl())===null) |
|
| 4864 | - $context=$this; |
|
| 4865 | - foreach($this->_rf[self::RF_DATA_BINDINGS] as $property=>$expression) |
|
| 4866 | - $this->setSubProperty($property,$context->evaluateExpression($expression)); |
|
| 4863 | + if (($context = $this->getTemplateControl()) === null) |
|
| 4864 | + $context = $this; |
|
| 4865 | + foreach ($this->_rf[self::RF_DATA_BINDINGS] as $property=>$expression) |
|
| 4866 | + $this->setSubProperty($property, $context->evaluateExpression($expression)); |
|
| 4867 | 4867 | } |
| 4868 | 4868 | } |
| 4869 | 4869 | protected function autoDataBindProperties() |
| 4870 | 4870 | { |
| 4871 | - if(isset($this->_rf[self::RF_AUTO_BINDINGS])) |
|
| 4871 | + if (isset($this->_rf[self::RF_AUTO_BINDINGS])) |
|
| 4872 | 4872 | { |
| 4873 | - if(($context=$this->getTemplateControl())===null) |
|
| 4874 | - $context=$this; |
|
| 4875 | - foreach($this->_rf[self::RF_AUTO_BINDINGS] as $property=>$expression) |
|
| 4876 | - $this->setSubProperty($property,$context->evaluateExpression($expression)); |
|
| 4873 | + if (($context = $this->getTemplateControl()) === null) |
|
| 4874 | + $context = $this; |
|
| 4875 | + foreach ($this->_rf[self::RF_AUTO_BINDINGS] as $property=>$expression) |
|
| 4876 | + $this->setSubProperty($property, $context->evaluateExpression($expression)); |
|
| 4877 | 4877 | } |
| 4878 | 4878 | } |
| 4879 | 4879 | protected function dataBindChildren() |
| 4880 | 4880 | { |
| 4881 | - if(isset($this->_rf[self::RF_CONTROLS])) |
|
| 4881 | + if (isset($this->_rf[self::RF_CONTROLS])) |
|
| 4882 | 4882 | { |
| 4883 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
| 4884 | - if($control instanceof IBindable) |
|
| 4883 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
| 4884 | + if ($control instanceof IBindable) |
|
| 4885 | 4885 | $control->dataBind(); |
| 4886 | 4886 | } |
| 4887 | 4887 | } |
| 4888 | 4888 | final protected function getChildControlsCreated() |
| 4889 | 4889 | { |
| 4890 | - return ($this->_flags & self::IS_CHILD_CREATED)!==0; |
|
| 4890 | + return ($this->_flags & self::IS_CHILD_CREATED) !== 0; |
|
| 4891 | 4891 | } |
| 4892 | 4892 | final protected function setChildControlsCreated($value) |
| 4893 | 4893 | { |
| 4894 | - if($value) |
|
| 4894 | + if ($value) |
|
| 4895 | 4895 | $this->_flags |= self::IS_CHILD_CREATED; |
| 4896 | 4896 | else |
| 4897 | 4897 | { |
| 4898 | - if($this->getHasControls() && ($this->_flags & self::IS_CHILD_CREATED)) |
|
| 4898 | + if ($this->getHasControls() && ($this->_flags & self::IS_CHILD_CREATED)) |
|
| 4899 | 4899 | $this->getControls()->clear(); |
| 4900 | 4900 | $this->_flags &= ~self::IS_CHILD_CREATED; |
| 4901 | 4901 | } |
| 4902 | 4902 | } |
| 4903 | 4903 | public function ensureChildControls() |
| 4904 | 4904 | { |
| 4905 | - if(!($this->_flags & self::IS_CHILD_CREATED) && !($this->_flags & self::IS_CREATING_CHILD)) |
|
| 4905 | + if (!($this->_flags & self::IS_CHILD_CREATED) && !($this->_flags & self::IS_CREATING_CHILD)) |
|
| 4906 | 4906 | { |
| 4907 | 4907 | try |
| 4908 | 4908 | { |
| 4909 | 4909 | $this->_flags |= self::IS_CREATING_CHILD; |
| 4910 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
| 4910 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
| 4911 | 4911 | $this->_rf[self::RF_ADAPTER]->createChildControls(); |
| 4912 | 4912 | else |
| 4913 | 4913 | $this->createChildControls(); |
| 4914 | 4914 | $this->_flags &= ~self::IS_CREATING_CHILD; |
| 4915 | 4915 | $this->_flags |= self::IS_CHILD_CREATED; |
| 4916 | 4916 | } |
| 4917 | - catch(Exception $e) |
|
| 4917 | + catch (Exception $e) |
|
| 4918 | 4918 | { |
| 4919 | 4919 | $this->_flags &= ~self::IS_CREATING_CHILD; |
| 4920 | 4920 | $this->_flags |= self::IS_CHILD_CREATED; |
@@ -4927,54 +4927,54 @@ discard block |
||
| 4927 | 4927 | } |
| 4928 | 4928 | public function findControl($id) |
| 4929 | 4929 | { |
| 4930 | - $id=strtr($id,'.',self::ID_SEPARATOR); |
|
| 4931 | - $container=($this instanceof INamingContainer)?$this:$this->getNamingContainer(); |
|
| 4932 | - if(!$container || !$container->getHasControls()) |
|
| 4930 | + $id = strtr($id, '.', self::ID_SEPARATOR); |
|
| 4931 | + $container = ($this instanceof INamingContainer) ? $this : $this->getNamingContainer(); |
|
| 4932 | + if (!$container || !$container->getHasControls()) |
|
| 4933 | 4933 | return null; |
| 4934 | - if(!isset($container->_rf[self::RF_NAMED_CONTROLS])) |
|
| 4934 | + if (!isset($container->_rf[self::RF_NAMED_CONTROLS])) |
|
| 4935 | 4935 | { |
| 4936 | - $container->_rf[self::RF_NAMED_CONTROLS]=array(); |
|
| 4937 | - $container->fillNameTable($container,$container->_rf[self::RF_CONTROLS]); |
|
| 4936 | + $container->_rf[self::RF_NAMED_CONTROLS] = array(); |
|
| 4937 | + $container->fillNameTable($container, $container->_rf[self::RF_CONTROLS]); |
|
| 4938 | 4938 | } |
| 4939 | - if(($pos=strpos($id,self::ID_SEPARATOR))===false) |
|
| 4940 | - return isset($container->_rf[self::RF_NAMED_CONTROLS][$id])?$container->_rf[self::RF_NAMED_CONTROLS][$id]:null; |
|
| 4939 | + if (($pos = strpos($id, self::ID_SEPARATOR)) === false) |
|
| 4940 | + return isset($container->_rf[self::RF_NAMED_CONTROLS][$id]) ? $container->_rf[self::RF_NAMED_CONTROLS][$id] : null; |
|
| 4941 | 4941 | else |
| 4942 | 4942 | { |
| 4943 | - $cid=substr($id,0,$pos); |
|
| 4944 | - $sid=substr($id,$pos+1); |
|
| 4945 | - if(isset($container->_rf[self::RF_NAMED_CONTROLS][$cid])) |
|
| 4943 | + $cid = substr($id, 0, $pos); |
|
| 4944 | + $sid = substr($id, $pos + 1); |
|
| 4945 | + if (isset($container->_rf[self::RF_NAMED_CONTROLS][$cid])) |
|
| 4946 | 4946 | return $container->_rf[self::RF_NAMED_CONTROLS][$cid]->findControl($sid); |
| 4947 | 4947 | else |
| 4948 | 4948 | return null; |
| 4949 | 4949 | } |
| 4950 | 4950 | } |
| 4951 | - public function findControlsByType($type,$strict=true) |
|
| 4951 | + public function findControlsByType($type, $strict = true) |
|
| 4952 | 4952 | { |
| 4953 | - $controls=array(); |
|
| 4954 | - if($this->getHasControls()) |
|
| 4953 | + $controls = array(); |
|
| 4954 | + if ($this->getHasControls()) |
|
| 4955 | 4955 | { |
| 4956 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
| 4956 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
| 4957 | 4957 | { |
| 4958 | - if(is_object($control) && (get_class($control)===$type || (!$strict && ($control instanceof $type)))) |
|
| 4959 | - $controls[]=$control; |
|
| 4960 | - if(($control instanceof TControl) && $control->getHasControls()) |
|
| 4961 | - $controls=array_merge($controls,$control->findControlsByType($type,$strict)); |
|
| 4958 | + if (is_object($control) && (get_class($control) === $type || (!$strict && ($control instanceof $type)))) |
|
| 4959 | + $controls[] = $control; |
|
| 4960 | + if (($control instanceof TControl) && $control->getHasControls()) |
|
| 4961 | + $controls = array_merge($controls, $control->findControlsByType($type, $strict)); |
|
| 4962 | 4962 | } |
| 4963 | 4963 | } |
| 4964 | 4964 | return $controls; |
| 4965 | 4965 | } |
| 4966 | 4966 | public function findControlsByID($id) |
| 4967 | 4967 | { |
| 4968 | - $controls=array(); |
|
| 4969 | - if($this->getHasControls()) |
|
| 4968 | + $controls = array(); |
|
| 4969 | + if ($this->getHasControls()) |
|
| 4970 | 4970 | { |
| 4971 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
| 4971 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
| 4972 | 4972 | { |
| 4973 | - if($control instanceof TControl) |
|
| 4973 | + if ($control instanceof TControl) |
|
| 4974 | 4974 | { |
| 4975 | - if($control->_id===$id) |
|
| 4976 | - $controls[]=$control; |
|
| 4977 | - $controls=array_merge($controls,$control->findControlsByID($id)); |
|
| 4975 | + if ($control->_id === $id) |
|
| 4976 | + $controls[] = $control; |
|
| 4977 | + $controls = array_merge($controls, $control->findControlsByID($id)); |
|
| 4978 | 4978 | } |
| 4979 | 4979 | } |
| 4980 | 4980 | } |
@@ -4985,11 +4985,11 @@ discard block |
||
| 4985 | 4985 | unset($this->_rf[self::RF_NAMED_CONTROLS_ID]); |
| 4986 | 4986 | $this->clearNameTable(); |
| 4987 | 4987 | } |
| 4988 | - public function registerObject($name,$object) |
|
| 4988 | + public function registerObject($name, $object) |
|
| 4989 | 4989 | { |
| 4990 | - if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
|
| 4991 | - throw new TInvalidOperationException('control_object_reregistered',$name); |
|
| 4992 | - $this->_rf[self::RF_NAMED_OBJECTS][$name]=$object; |
|
| 4990 | + if (isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
|
| 4991 | + throw new TInvalidOperationException('control_object_reregistered', $name); |
|
| 4992 | + $this->_rf[self::RF_NAMED_OBJECTS][$name] = $object; |
|
| 4993 | 4993 | } |
| 4994 | 4994 | public function unregisterObject($name) |
| 4995 | 4995 | { |
@@ -5021,7 +5021,7 @@ discard block |
||
| 5021 | 5021 | } |
| 5022 | 5022 | public function getRegisteredObject($name) |
| 5023 | 5023 | { |
| 5024 | - return isset($this->_rf[self::RF_NAMED_OBJECTS][$name])?$this->_rf[self::RF_NAMED_OBJECTS][$name]:null; |
|
| 5024 | + return isset($this->_rf[self::RF_NAMED_OBJECTS][$name]) ? $this->_rf[self::RF_NAMED_OBJECTS][$name] : null; |
|
| 5025 | 5025 | } |
| 5026 | 5026 | public function getAllowChildControls() |
| 5027 | 5027 | { |
@@ -5037,44 +5037,44 @@ discard block |
||
| 5037 | 5037 | } |
| 5038 | 5038 | final protected function isDescendentOf($ancestor) |
| 5039 | 5039 | { |
| 5040 | - $control=$this; |
|
| 5041 | - while($control!==$ancestor && $control->_parent) |
|
| 5042 | - $control=$control->_parent; |
|
| 5043 | - return $control===$ancestor; |
|
| 5040 | + $control = $this; |
|
| 5041 | + while ($control !== $ancestor && $control->_parent) |
|
| 5042 | + $control = $control->_parent; |
|
| 5043 | + return $control === $ancestor; |
|
| 5044 | 5044 | } |
| 5045 | 5045 | public function addedControl($control) |
| 5046 | 5046 | { |
| 5047 | - if($control->_parent) |
|
| 5047 | + if ($control->_parent) |
|
| 5048 | 5048 | $control->_parent->getControls()->remove($control); |
| 5049 | - $control->_parent=$this; |
|
| 5050 | - $control->_page=$this->getPage(); |
|
| 5051 | - $namingContainer=($this instanceof INamingContainer)?$this:$this->_namingContainer; |
|
| 5052 | - if($namingContainer) |
|
| 5049 | + $control->_parent = $this; |
|
| 5050 | + $control->_page = $this->getPage(); |
|
| 5051 | + $namingContainer = ($this instanceof INamingContainer) ? $this : $this->_namingContainer; |
|
| 5052 | + if ($namingContainer) |
|
| 5053 | 5053 | { |
| 5054 | - $control->_namingContainer=$namingContainer; |
|
| 5055 | - if($control->_id==='') |
|
| 5054 | + $control->_namingContainer = $namingContainer; |
|
| 5055 | + if ($control->_id === '') |
|
| 5056 | 5056 | $control->generateAutomaticID(); |
| 5057 | 5057 | else |
| 5058 | 5058 | $namingContainer->clearNameTable(); |
| 5059 | 5059 | $control->clearCachedUniqueID($control instanceof INamingContainer); |
| 5060 | 5060 | } |
| 5061 | - if($this->_stage>=self::CS_CHILD_INITIALIZED) |
|
| 5061 | + if ($this->_stage >= self::CS_CHILD_INITIALIZED) |
|
| 5062 | 5062 | { |
| 5063 | 5063 | $control->initRecursive($namingContainer); |
| 5064 | - if($this->_stage>=self::CS_STATE_LOADED) |
|
| 5064 | + if ($this->_stage >= self::CS_STATE_LOADED) |
|
| 5065 | 5065 | { |
| 5066 | - if(isset($this->_rf[self::RF_CHILD_STATE][$control->_id])) |
|
| 5066 | + if (isset($this->_rf[self::RF_CHILD_STATE][$control->_id])) |
|
| 5067 | 5067 | { |
| 5068 | - $state=$this->_rf[self::RF_CHILD_STATE][$control->_id]; |
|
| 5068 | + $state = $this->_rf[self::RF_CHILD_STATE][$control->_id]; |
|
| 5069 | 5069 | unset($this->_rf[self::RF_CHILD_STATE][$control->_id]); |
| 5070 | 5070 | } |
| 5071 | 5071 | else |
| 5072 | - $state=null; |
|
| 5073 | - $control->loadStateRecursive($state,!($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
|
| 5074 | - if($this->_stage>=self::CS_LOADED) |
|
| 5072 | + $state = null; |
|
| 5073 | + $control->loadStateRecursive($state, !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
|
| 5074 | + if ($this->_stage >= self::CS_LOADED) |
|
| 5075 | 5075 | { |
| 5076 | 5076 | $control->loadRecursive(); |
| 5077 | - if($this->_stage>=self::CS_PRERENDERED) |
|
| 5077 | + if ($this->_stage >= self::CS_PRERENDERED) |
|
| 5078 | 5078 | $control->preRenderRecursive(); |
| 5079 | 5079 | } |
| 5080 | 5080 | } |
@@ -5082,186 +5082,186 @@ discard block |
||
| 5082 | 5082 | } |
| 5083 | 5083 | public function removedControl($control) |
| 5084 | 5084 | { |
| 5085 | - if($this->_namingContainer) |
|
| 5085 | + if ($this->_namingContainer) |
|
| 5086 | 5086 | $this->_namingContainer->clearNameTable(); |
| 5087 | 5087 | $control->unloadRecursive(); |
| 5088 | - $control->_parent=null; |
|
| 5089 | - $control->_page=null; |
|
| 5090 | - $control->_namingContainer=null; |
|
| 5091 | - $control->_tplControl=null; |
|
| 5092 | - if(!($control->_flags & self::IS_ID_SET)) |
|
| 5093 | - $control->_id=''; |
|
| 5088 | + $control->_parent = null; |
|
| 5089 | + $control->_page = null; |
|
| 5090 | + $control->_namingContainer = null; |
|
| 5091 | + $control->_tplControl = null; |
|
| 5092 | + if (!($control->_flags & self::IS_ID_SET)) |
|
| 5093 | + $control->_id = ''; |
|
| 5094 | 5094 | else |
| 5095 | 5095 | unset($this->_rf[self::RF_NAMED_OBJECTS][$control->_id]); |
| 5096 | 5096 | $control->clearCachedUniqueID(true); |
| 5097 | 5097 | } |
| 5098 | - protected function initRecursive($namingContainer=null) |
|
| 5098 | + protected function initRecursive($namingContainer = null) |
|
| 5099 | 5099 | { |
| 5100 | 5100 | $this->ensureChildControls(); |
| 5101 | - if($this->getHasControls()) |
|
| 5101 | + if ($this->getHasControls()) |
|
| 5102 | 5102 | { |
| 5103 | - if($this instanceof INamingContainer) |
|
| 5104 | - $namingContainer=$this; |
|
| 5105 | - $page=$this->getPage(); |
|
| 5106 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
| 5103 | + if ($this instanceof INamingContainer) |
|
| 5104 | + $namingContainer = $this; |
|
| 5105 | + $page = $this->getPage(); |
|
| 5106 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
| 5107 | 5107 | { |
| 5108 | - if($control instanceof TControl) |
|
| 5108 | + if ($control instanceof TControl) |
|
| 5109 | 5109 | { |
| 5110 | - $control->_namingContainer=$namingContainer; |
|
| 5111 | - $control->_page=$page; |
|
| 5112 | - if($control->_id==='' && $namingContainer) |
|
| 5110 | + $control->_namingContainer = $namingContainer; |
|
| 5111 | + $control->_page = $page; |
|
| 5112 | + if ($control->_id === '' && $namingContainer) |
|
| 5113 | 5113 | $control->generateAutomaticID(); |
| 5114 | 5114 | $control->initRecursive($namingContainer); |
| 5115 | 5115 | } |
| 5116 | 5116 | } |
| 5117 | 5117 | } |
| 5118 | - if($this->_stage<self::CS_INITIALIZED) |
|
| 5118 | + if ($this->_stage < self::CS_INITIALIZED) |
|
| 5119 | 5119 | { |
| 5120 | - $this->_stage=self::CS_CHILD_INITIALIZED; |
|
| 5121 | - if(($page=$this->getPage()) && $this->getEnableTheming() && !($this->_flags & self::IS_SKIN_APPLIED)) |
|
| 5120 | + $this->_stage = self::CS_CHILD_INITIALIZED; |
|
| 5121 | + if (($page = $this->getPage()) && $this->getEnableTheming() && !($this->_flags & self::IS_SKIN_APPLIED)) |
|
| 5122 | 5122 | { |
| 5123 | 5123 | $page->applyControlSkin($this); |
| 5124 | 5124 | $this->_flags |= self::IS_SKIN_APPLIED; |
| 5125 | 5125 | } |
| 5126 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
| 5126 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
| 5127 | 5127 | $this->_rf[self::RF_ADAPTER]->onInit(null); |
| 5128 | 5128 | else |
| 5129 | 5129 | $this->onInit(null); |
| 5130 | - $this->_stage=self::CS_INITIALIZED; |
|
| 5130 | + $this->_stage = self::CS_INITIALIZED; |
|
| 5131 | 5131 | } |
| 5132 | 5132 | } |
| 5133 | 5133 | protected function loadRecursive() |
| 5134 | 5134 | { |
| 5135 | - if($this->_stage<self::CS_LOADED) |
|
| 5135 | + if ($this->_stage < self::CS_LOADED) |
|
| 5136 | 5136 | { |
| 5137 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
| 5137 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
| 5138 | 5138 | $this->_rf[self::RF_ADAPTER]->onLoad(null); |
| 5139 | 5139 | else |
| 5140 | 5140 | $this->onLoad(null); |
| 5141 | 5141 | } |
| 5142 | - if($this->getHasControls()) |
|
| 5142 | + if ($this->getHasControls()) |
|
| 5143 | 5143 | { |
| 5144 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
| 5144 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
| 5145 | 5145 | { |
| 5146 | - if($control instanceof TControl) |
|
| 5146 | + if ($control instanceof TControl) |
|
| 5147 | 5147 | $control->loadRecursive(); |
| 5148 | 5148 | } |
| 5149 | 5149 | } |
| 5150 | - if($this->_stage<self::CS_LOADED) |
|
| 5151 | - $this->_stage=self::CS_LOADED; |
|
| 5150 | + if ($this->_stage < self::CS_LOADED) |
|
| 5151 | + $this->_stage = self::CS_LOADED; |
|
| 5152 | 5152 | } |
| 5153 | 5153 | protected function preRenderRecursive() |
| 5154 | 5154 | { |
| 5155 | 5155 | $this->autoDataBindProperties(); |
| 5156 | - if($this->getVisible(false)) |
|
| 5156 | + if ($this->getVisible(false)) |
|
| 5157 | 5157 | { |
| 5158 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
| 5158 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
| 5159 | 5159 | $this->_rf[self::RF_ADAPTER]->onPreRender(null); |
| 5160 | 5160 | else |
| 5161 | 5161 | $this->onPreRender(null); |
| 5162 | - if($this->getHasControls()) |
|
| 5162 | + if ($this->getHasControls()) |
|
| 5163 | 5163 | { |
| 5164 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
| 5164 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
| 5165 | 5165 | { |
| 5166 | - if($control instanceof TControl) |
|
| 5166 | + if ($control instanceof TControl) |
|
| 5167 | 5167 | $control->preRenderRecursive(); |
| 5168 | - else if($control instanceof TCompositeLiteral) |
|
| 5168 | + else if ($control instanceof TCompositeLiteral) |
|
| 5169 | 5169 | $control->evaluateDynamicContent(); |
| 5170 | 5170 | } |
| 5171 | 5171 | } |
| 5172 | 5172 | } |
| 5173 | - $this->_stage=self::CS_PRERENDERED; |
|
| 5173 | + $this->_stage = self::CS_PRERENDERED; |
|
| 5174 | 5174 | } |
| 5175 | 5175 | protected function unloadRecursive() |
| 5176 | 5176 | { |
| 5177 | - if(!($this->_flags & self::IS_ID_SET)) |
|
| 5178 | - $this->_id=''; |
|
| 5179 | - if($this->getHasControls()) |
|
| 5177 | + if (!($this->_flags & self::IS_ID_SET)) |
|
| 5178 | + $this->_id = ''; |
|
| 5179 | + if ($this->getHasControls()) |
|
| 5180 | 5180 | { |
| 5181 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
| 5182 | - if($control instanceof TControl) |
|
| 5181 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
| 5182 | + if ($control instanceof TControl) |
|
| 5183 | 5183 | $control->unloadRecursive(); |
| 5184 | 5184 | } |
| 5185 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
| 5185 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
| 5186 | 5186 | $this->_rf[self::RF_ADAPTER]->onUnload(null); |
| 5187 | 5187 | else |
| 5188 | 5188 | $this->onUnload(null); |
| 5189 | 5189 | } |
| 5190 | 5190 | public function onInit($param) |
| 5191 | 5191 | { |
| 5192 | - $this->raiseEvent('OnInit',$this,$param); |
|
| 5192 | + $this->raiseEvent('OnInit', $this, $param); |
|
| 5193 | 5193 | } |
| 5194 | 5194 | public function onLoad($param) |
| 5195 | 5195 | { |
| 5196 | - $this->raiseEvent('OnLoad',$this,$param); |
|
| 5196 | + $this->raiseEvent('OnLoad', $this, $param); |
|
| 5197 | 5197 | } |
| 5198 | 5198 | public function onDataBinding($param) |
| 5199 | 5199 | { |
| 5200 | - $this->raiseEvent('OnDataBinding',$this,$param); |
|
| 5200 | + $this->raiseEvent('OnDataBinding', $this, $param); |
|
| 5201 | 5201 | } |
| 5202 | 5202 | public function onUnload($param) |
| 5203 | 5203 | { |
| 5204 | - $this->raiseEvent('OnUnload',$this,$param); |
|
| 5204 | + $this->raiseEvent('OnUnload', $this, $param); |
|
| 5205 | 5205 | } |
| 5206 | 5206 | public function onPreRender($param) |
| 5207 | 5207 | { |
| 5208 | - $this->raiseEvent('OnPreRender',$this,$param); |
|
| 5208 | + $this->raiseEvent('OnPreRender', $this, $param); |
|
| 5209 | 5209 | } |
| 5210 | - protected function raiseBubbleEvent($sender,$param) |
|
| 5210 | + protected function raiseBubbleEvent($sender, $param) |
|
| 5211 | 5211 | { |
| 5212 | - $control=$this; |
|
| 5213 | - while($control=$control->_parent) |
|
| 5212 | + $control = $this; |
|
| 5213 | + while ($control = $control->_parent) |
|
| 5214 | 5214 | { |
| 5215 | - if($control->bubbleEvent($sender,$param)) |
|
| 5215 | + if ($control->bubbleEvent($sender, $param)) |
|
| 5216 | 5216 | break; |
| 5217 | 5217 | } |
| 5218 | 5218 | } |
| 5219 | - public function bubbleEvent($sender,$param) |
|
| 5219 | + public function bubbleEvent($sender, $param) |
|
| 5220 | 5220 | { |
| 5221 | 5221 | return false; |
| 5222 | 5222 | } |
| 5223 | - public function broadcastEvent($name,$sender,$param) |
|
| 5223 | + public function broadcastEvent($name, $sender, $param) |
|
| 5224 | 5224 | { |
| 5225 | - $rootControl=(($page=$this->getPage())===null)?$this:$page; |
|
| 5226 | - $rootControl->broadcastEventInternal($name,$sender,new TBroadcastEventParameter($name,$param)); |
|
| 5225 | + $rootControl = (($page = $this->getPage()) === null) ? $this : $page; |
|
| 5226 | + $rootControl->broadcastEventInternal($name, $sender, new TBroadcastEventParameter($name, $param)); |
|
| 5227 | 5227 | } |
| 5228 | - private function broadcastEventInternal($name,$sender,$param) |
|
| 5228 | + private function broadcastEventInternal($name, $sender, $param) |
|
| 5229 | 5229 | { |
| 5230 | - if($this->hasEvent($name)) |
|
| 5231 | - $this->raiseEvent($name,$sender,$param->getParameter()); |
|
| 5232 | - if($this instanceof IBroadcastEventReceiver) |
|
| 5233 | - $this->broadcastEventReceived($sender,$param); |
|
| 5234 | - if($this->getHasControls()) |
|
| 5230 | + if ($this->hasEvent($name)) |
|
| 5231 | + $this->raiseEvent($name, $sender, $param->getParameter()); |
|
| 5232 | + if ($this instanceof IBroadcastEventReceiver) |
|
| 5233 | + $this->broadcastEventReceived($sender, $param); |
|
| 5234 | + if ($this->getHasControls()) |
|
| 5235 | 5235 | { |
| 5236 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
| 5236 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
| 5237 | 5237 | { |
| 5238 | - if($control instanceof TControl) |
|
| 5239 | - $control->broadcastEventInternal($name,$sender,$param); |
|
| 5238 | + if ($control instanceof TControl) |
|
| 5239 | + $control->broadcastEventInternal($name, $sender, $param); |
|
| 5240 | 5240 | } |
| 5241 | 5241 | } |
| 5242 | 5242 | } |
| 5243 | - protected function traverseChildControls($param,$preCallback=null,$postCallback=null) |
|
| 5243 | + protected function traverseChildControls($param, $preCallback = null, $postCallback = null) |
|
| 5244 | 5244 | { |
| 5245 | - if($preCallback!==null) |
|
| 5246 | - call_user_func($preCallback,$this,$param); |
|
| 5247 | - if($this->getHasControls()) |
|
| 5245 | + if ($preCallback !== null) |
|
| 5246 | + call_user_func($preCallback, $this, $param); |
|
| 5247 | + if ($this->getHasControls()) |
|
| 5248 | 5248 | { |
| 5249 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
| 5249 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
| 5250 | 5250 | { |
| 5251 | - if($control instanceof TControl) |
|
| 5251 | + if ($control instanceof TControl) |
|
| 5252 | 5252 | { |
| 5253 | - $control->traverseChildControls($param,$preCallback,$postCallback); |
|
| 5253 | + $control->traverseChildControls($param, $preCallback, $postCallback); |
|
| 5254 | 5254 | } |
| 5255 | 5255 | } |
| 5256 | 5256 | } |
| 5257 | - if($postCallback!==null) |
|
| 5258 | - call_user_func($postCallback,$this,$param); |
|
| 5257 | + if ($postCallback !== null) |
|
| 5258 | + call_user_func($postCallback, $this, $param); |
|
| 5259 | 5259 | } |
| 5260 | 5260 | public function renderControl($writer) |
| 5261 | 5261 | { |
| 5262 | - if($this instanceof IActiveControl || $this->getVisible(false)) |
|
| 5262 | + if ($this instanceof IActiveControl || $this->getVisible(false)) |
|
| 5263 | 5263 | { |
| 5264 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
| 5264 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
| 5265 | 5265 | $this->_rf[self::RF_ADAPTER]->render($writer); |
| 5266 | 5266 | else |
| 5267 | 5267 | $this->render($writer); |
@@ -5273,15 +5273,15 @@ discard block |
||
| 5273 | 5273 | } |
| 5274 | 5274 | public function renderChildren($writer) |
| 5275 | 5275 | { |
| 5276 | - if($this->getHasControls()) |
|
| 5276 | + if ($this->getHasControls()) |
|
| 5277 | 5277 | { |
| 5278 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
| 5278 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
| 5279 | 5279 | { |
| 5280 | - if(is_string($control)) |
|
| 5280 | + if (is_string($control)) |
|
| 5281 | 5281 | $writer->write($control); |
| 5282 | - else if($control instanceof TControl) |
|
| 5282 | + else if ($control instanceof TControl) |
|
| 5283 | 5283 | $control->renderControl($writer); |
| 5284 | - else if($control instanceof IRenderable) |
|
| 5284 | + else if ($control instanceof IRenderable) |
|
| 5285 | 5285 | $control->render($writer); |
| 5286 | 5286 | } |
| 5287 | 5287 | } |
@@ -5292,122 +5292,122 @@ discard block |
||
| 5292 | 5292 | public function loadState() |
| 5293 | 5293 | { |
| 5294 | 5294 | } |
| 5295 | - protected function loadStateRecursive(&$state,$needViewState=true) |
|
| 5295 | + protected function loadStateRecursive(&$state, $needViewState = true) |
|
| 5296 | 5296 | { |
| 5297 | - if(is_array($state)) |
|
| 5297 | + if (is_array($state)) |
|
| 5298 | 5298 | { |
| 5299 | - $needViewState=($needViewState && !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
|
| 5300 | - if(isset($state[1])) |
|
| 5299 | + $needViewState = ($needViewState && !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
|
| 5300 | + if (isset($state[1])) |
|
| 5301 | 5301 | { |
| 5302 | - $this->_rf[self::RF_CONTROLSTATE]=&$state[1]; |
|
| 5302 | + $this->_rf[self::RF_CONTROLSTATE] = &$state[1]; |
|
| 5303 | 5303 | unset($state[1]); |
| 5304 | 5304 | } |
| 5305 | 5305 | else |
| 5306 | 5306 | unset($this->_rf[self::RF_CONTROLSTATE]); |
| 5307 | - if($needViewState) |
|
| 5307 | + if ($needViewState) |
|
| 5308 | 5308 | { |
| 5309 | - if(isset($state[0])) |
|
| 5310 | - $this->_viewState=&$state[0]; |
|
| 5309 | + if (isset($state[0])) |
|
| 5310 | + $this->_viewState = &$state[0]; |
|
| 5311 | 5311 | else |
| 5312 | - $this->_viewState=array(); |
|
| 5312 | + $this->_viewState = array(); |
|
| 5313 | 5313 | } |
| 5314 | 5314 | unset($state[0]); |
| 5315 | - if($this->getHasControls()) |
|
| 5315 | + if ($this->getHasControls()) |
|
| 5316 | 5316 | { |
| 5317 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
| 5317 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
| 5318 | 5318 | { |
| 5319 | - if($control instanceof TControl) |
|
| 5319 | + if ($control instanceof TControl) |
|
| 5320 | 5320 | { |
| 5321 | - if(isset($state[$control->_id])) |
|
| 5321 | + if (isset($state[$control->_id])) |
|
| 5322 | 5322 | { |
| 5323 | - $control->loadStateRecursive($state[$control->_id],$needViewState); |
|
| 5323 | + $control->loadStateRecursive($state[$control->_id], $needViewState); |
|
| 5324 | 5324 | unset($state[$control->_id]); |
| 5325 | 5325 | } |
| 5326 | 5326 | } |
| 5327 | 5327 | } |
| 5328 | 5328 | } |
| 5329 | - if(!empty($state)) |
|
| 5330 | - $this->_rf[self::RF_CHILD_STATE]=&$state; |
|
| 5329 | + if (!empty($state)) |
|
| 5330 | + $this->_rf[self::RF_CHILD_STATE] = &$state; |
|
| 5331 | 5331 | } |
| 5332 | - $this->_stage=self::CS_STATE_LOADED; |
|
| 5333 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
| 5332 | + $this->_stage = self::CS_STATE_LOADED; |
|
| 5333 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
| 5334 | 5334 | $this->_rf[self::RF_ADAPTER]->loadState(); |
| 5335 | 5335 | else |
| 5336 | 5336 | $this->loadState(); |
| 5337 | 5337 | } |
| 5338 | - protected function &saveStateRecursive($needViewState=true) |
|
| 5338 | + protected function &saveStateRecursive($needViewState = true) |
|
| 5339 | 5339 | { |
| 5340 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
| 5340 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
| 5341 | 5341 | $this->_rf[self::RF_ADAPTER]->saveState(); |
| 5342 | 5342 | else |
| 5343 | 5343 | $this->saveState(); |
| 5344 | - $needViewState=($needViewState && !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
|
| 5345 | - $state=array(); |
|
| 5346 | - if($this->getHasControls()) |
|
| 5344 | + $needViewState = ($needViewState && !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
|
| 5345 | + $state = array(); |
|
| 5346 | + if ($this->getHasControls()) |
|
| 5347 | 5347 | { |
| 5348 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
| 5348 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
| 5349 | 5349 | { |
| 5350 | - if($control instanceof TControl) |
|
| 5350 | + if ($control instanceof TControl) |
|
| 5351 | 5351 | { |
| 5352 | - if(count($tmp = &$control->saveStateRecursive($needViewState))) |
|
| 5353 | - $state[$control->_id]=$tmp; |
|
| 5352 | + if (count($tmp = &$control->saveStateRecursive($needViewState))) |
|
| 5353 | + $state[$control->_id] = $tmp; |
|
| 5354 | 5354 | } |
| 5355 | 5355 | } |
| 5356 | 5356 | } |
| 5357 | - if($needViewState && !empty($this->_viewState)) |
|
| 5358 | - $state[0]=&$this->_viewState; |
|
| 5359 | - if(isset($this->_rf[self::RF_CONTROLSTATE])) |
|
| 5360 | - $state[1]=&$this->_rf[self::RF_CONTROLSTATE]; |
|
| 5357 | + if ($needViewState && !empty($this->_viewState)) |
|
| 5358 | + $state[0] = &$this->_viewState; |
|
| 5359 | + if (isset($this->_rf[self::RF_CONTROLSTATE])) |
|
| 5360 | + $state[1] = &$this->_rf[self::RF_CONTROLSTATE]; |
|
| 5361 | 5361 | return $state; |
| 5362 | 5362 | } |
| 5363 | 5363 | public function applyStyleSheetSkin($page) |
| 5364 | 5364 | { |
| 5365 | - if($page && !($this->_flags & self::IS_STYLESHEET_APPLIED)) |
|
| 5365 | + if ($page && !($this->_flags & self::IS_STYLESHEET_APPLIED)) |
|
| 5366 | 5366 | { |
| 5367 | 5367 | $page->applyControlStyleSheet($this); |
| 5368 | 5368 | $this->_flags |= self::IS_STYLESHEET_APPLIED; |
| 5369 | 5369 | } |
| 5370 | - else if($this->_flags & self::IS_STYLESHEET_APPLIED) |
|
| 5371 | - throw new TInvalidOperationException('control_stylesheet_applied',get_class($this)); |
|
| 5370 | + else if ($this->_flags & self::IS_STYLESHEET_APPLIED) |
|
| 5371 | + throw new TInvalidOperationException('control_stylesheet_applied', get_class($this)); |
|
| 5372 | 5372 | } |
| 5373 | 5373 | private function clearCachedUniqueID($recursive) |
| 5374 | 5374 | { |
| 5375 | - if($recursive && $this->_uid!==null && isset($this->_rf[self::RF_CONTROLS])) |
|
| 5375 | + if ($recursive && $this->_uid !== null && isset($this->_rf[self::RF_CONTROLS])) |
|
| 5376 | 5376 | { |
| 5377 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
| 5378 | - if($control instanceof TControl) |
|
| 5377 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
| 5378 | + if ($control instanceof TControl) |
|
| 5379 | 5379 | $control->clearCachedUniqueID($recursive); |
| 5380 | 5380 | } |
| 5381 | - $this->_uid=null; |
|
| 5381 | + $this->_uid = null; |
|
| 5382 | 5382 | } |
| 5383 | 5383 | private function generateAutomaticID() |
| 5384 | 5384 | { |
| 5385 | 5385 | $this->_flags &= ~self::IS_ID_SET; |
| 5386 | - if(!isset($this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID])) |
|
| 5387 | - $this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]=0; |
|
| 5388 | - $id=$this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]++; |
|
| 5389 | - $this->_id=self::AUTOMATIC_ID_PREFIX . $id; |
|
| 5386 | + if (!isset($this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID])) |
|
| 5387 | + $this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID] = 0; |
|
| 5388 | + $id = $this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]++; |
|
| 5389 | + $this->_id = self::AUTOMATIC_ID_PREFIX . $id; |
|
| 5390 | 5390 | $this->_namingContainer->clearNameTable(); |
| 5391 | 5391 | } |
| 5392 | 5392 | private function clearNameTable() |
| 5393 | 5393 | { |
| 5394 | 5394 | unset($this->_rf[self::RF_NAMED_CONTROLS]); |
| 5395 | 5395 | } |
| 5396 | - private function fillNameTable($container,$controls) |
|
| 5396 | + private function fillNameTable($container, $controls) |
|
| 5397 | 5397 | { |
| 5398 | - foreach($controls as $control) |
|
| 5398 | + foreach ($controls as $control) |
|
| 5399 | 5399 | { |
| 5400 | - if($control instanceof TControl) |
|
| 5400 | + if ($control instanceof TControl) |
|
| 5401 | 5401 | { |
| 5402 | - if($control->_id!=='') |
|
| 5402 | + if ($control->_id !== '') |
|
| 5403 | 5403 | { |
| 5404 | - if(isset($container->_rf[self::RF_NAMED_CONTROLS][$control->_id])) |
|
| 5405 | - throw new TInvalidDataValueException('control_id_nonunique',get_class($control),$control->_id); |
|
| 5404 | + if (isset($container->_rf[self::RF_NAMED_CONTROLS][$control->_id])) |
|
| 5405 | + throw new TInvalidDataValueException('control_id_nonunique', get_class($control), $control->_id); |
|
| 5406 | 5406 | else |
| 5407 | - $container->_rf[self::RF_NAMED_CONTROLS][$control->_id]=$control; |
|
| 5407 | + $container->_rf[self::RF_NAMED_CONTROLS][$control->_id] = $control; |
|
| 5408 | 5408 | } |
| 5409 | - if(!($control instanceof INamingContainer) && $control->getHasControls()) |
|
| 5410 | - $this->fillNameTable($container,$control->_rf[self::RF_CONTROLS]); |
|
| 5409 | + if (!($control instanceof INamingContainer) && $control->getHasControls()) |
|
| 5410 | + $this->fillNameTable($container, $control->_rf[self::RF_CONTROLS]); |
|
| 5411 | 5411 | } |
| 5412 | 5412 | } |
| 5413 | 5413 | } |
@@ -5415,38 +5415,38 @@ discard block |
||
| 5415 | 5415 | class TControlCollection extends TList |
| 5416 | 5416 | { |
| 5417 | 5417 | private $_o; |
| 5418 | - public function __construct(TControl $owner,$readOnly=false) |
|
| 5418 | + public function __construct(TControl $owner, $readOnly = false) |
|
| 5419 | 5419 | { |
| 5420 | - $this->_o=$owner; |
|
| 5421 | - parent::__construct(null,$readOnly); |
|
| 5420 | + $this->_o = $owner; |
|
| 5421 | + parent::__construct(null, $readOnly); |
|
| 5422 | 5422 | } |
| 5423 | 5423 | protected function getOwner() |
| 5424 | 5424 | { |
| 5425 | 5425 | return $this->_o; |
| 5426 | 5426 | } |
| 5427 | - public function insertAt($index,$item) |
|
| 5427 | + public function insertAt($index, $item) |
|
| 5428 | 5428 | { |
| 5429 | - if($item instanceof TControl) |
|
| 5429 | + if ($item instanceof TControl) |
|
| 5430 | 5430 | { |
| 5431 | - parent::insertAt($index,$item); |
|
| 5431 | + parent::insertAt($index, $item); |
|
| 5432 | 5432 | $this->_o->addedControl($item); |
| 5433 | 5433 | } |
| 5434 | - else if(is_string($item) || ($item instanceof IRenderable)) |
|
| 5435 | - parent::insertAt($index,$item); |
|
| 5434 | + else if (is_string($item) || ($item instanceof IRenderable)) |
|
| 5435 | + parent::insertAt($index, $item); |
|
| 5436 | 5436 | else |
| 5437 | 5437 | throw new TInvalidDataTypeException('controlcollection_control_required'); |
| 5438 | 5438 | } |
| 5439 | 5439 | public function removeAt($index) |
| 5440 | 5440 | { |
| 5441 | - $item=parent::removeAt($index); |
|
| 5442 | - if($item instanceof TControl) |
|
| 5441 | + $item = parent::removeAt($index); |
|
| 5442 | + if ($item instanceof TControl) |
|
| 5443 | 5443 | $this->_o->removedControl($item); |
| 5444 | 5444 | return $item; |
| 5445 | 5445 | } |
| 5446 | 5446 | public function clear() |
| 5447 | 5447 | { |
| 5448 | 5448 | parent::clear(); |
| 5449 | - if($this->_o instanceof INamingContainer) |
|
| 5449 | + if ($this->_o instanceof INamingContainer) |
|
| 5450 | 5450 | $this->_o->clearNamingContainer(); |
| 5451 | 5451 | } |
| 5452 | 5452 | } |
@@ -5454,11 +5454,11 @@ discard block |
||
| 5454 | 5454 | { |
| 5455 | 5455 | public function __construct(TControl $owner) |
| 5456 | 5456 | { |
| 5457 | - parent::__construct($owner,true); |
|
| 5457 | + parent::__construct($owner, true); |
|
| 5458 | 5458 | } |
| 5459 | - public function insertAt($index,$item) |
|
| 5459 | + public function insertAt($index, $item) |
|
| 5460 | 5460 | { |
| 5461 | - if(!is_string($item)) parent::insertAt($index,$item); } |
|
| 5461 | + if (!is_string($item)) parent::insertAt($index, $item); } |
|
| 5462 | 5462 | } |
| 5463 | 5463 | interface INamingContainer |
| 5464 | 5464 | { |
@@ -5469,7 +5469,7 @@ discard block |
||
| 5469 | 5469 | } |
| 5470 | 5470 | interface IPostBackDataHandler |
| 5471 | 5471 | { |
| 5472 | - public function loadPostData($key,$values); |
|
| 5472 | + public function loadPostData($key, $values); |
|
| 5473 | 5473 | public function raisePostDataChangedEvent(); |
| 5474 | 5474 | public function getDataChanged(); |
| 5475 | 5475 | } |
@@ -5489,7 +5489,7 @@ discard block |
||
| 5489 | 5489 | } |
| 5490 | 5490 | interface IBroadcastEventReceiver |
| 5491 | 5491 | { |
| 5492 | - public function broadcastEventReceived($sender,$param); |
|
| 5492 | + public function broadcastEventReceived($sender, $param); |
|
| 5493 | 5493 | } |
| 5494 | 5494 | interface ITheme |
| 5495 | 5495 | { |
@@ -5525,10 +5525,10 @@ discard block |
||
| 5525 | 5525 | { |
| 5526 | 5526 | private $_name; |
| 5527 | 5527 | private $_param; |
| 5528 | - public function __construct($name='',$parameter=null) |
|
| 5528 | + public function __construct($name = '', $parameter = null) |
|
| 5529 | 5529 | { |
| 5530 | - $this->_name=$name; |
|
| 5531 | - $this->_param=$parameter; |
|
| 5530 | + $this->_name = $name; |
|
| 5531 | + $this->_param = $parameter; |
|
| 5532 | 5532 | } |
| 5533 | 5533 | public function getName() |
| 5534 | 5534 | { |
@@ -5536,7 +5536,7 @@ discard block |
||
| 5536 | 5536 | } |
| 5537 | 5537 | public function setName($value) |
| 5538 | 5538 | { |
| 5539 | - $this->_name=$value; |
|
| 5539 | + $this->_name = $value; |
|
| 5540 | 5540 | } |
| 5541 | 5541 | public function getParameter() |
| 5542 | 5542 | { |
@@ -5544,17 +5544,17 @@ discard block |
||
| 5544 | 5544 | } |
| 5545 | 5545 | public function setParameter($value) |
| 5546 | 5546 | { |
| 5547 | - $this->_param=$value; |
|
| 5547 | + $this->_param = $value; |
|
| 5548 | 5548 | } |
| 5549 | 5549 | } |
| 5550 | 5550 | class TCommandEventParameter extends TEventParameter |
| 5551 | 5551 | { |
| 5552 | 5552 | private $_name; |
| 5553 | 5553 | private $_param; |
| 5554 | - public function __construct($name='',$parameter='') |
|
| 5554 | + public function __construct($name = '', $parameter = '') |
|
| 5555 | 5555 | { |
| 5556 | - $this->_name=$name; |
|
| 5557 | - $this->_param=$parameter; |
|
| 5556 | + $this->_name = $name; |
|
| 5557 | + $this->_param = $parameter; |
|
| 5558 | 5558 | } |
| 5559 | 5559 | public function getCommandName() |
| 5560 | 5560 | { |
@@ -5567,33 +5567,33 @@ discard block |
||
| 5567 | 5567 | } |
| 5568 | 5568 | class TCompositeLiteral extends TComponent implements IRenderable, IBindable |
| 5569 | 5569 | { |
| 5570 | - const TYPE_EXPRESSION=0; |
|
| 5571 | - const TYPE_STATEMENTS=1; |
|
| 5572 | - const TYPE_DATABINDING=2; |
|
| 5573 | - private $_container=null; |
|
| 5574 | - private $_items=array(); |
|
| 5575 | - private $_expressions=array(); |
|
| 5576 | - private $_statements=array(); |
|
| 5577 | - private $_bindings=array(); |
|
| 5570 | + const TYPE_EXPRESSION = 0; |
|
| 5571 | + const TYPE_STATEMENTS = 1; |
|
| 5572 | + const TYPE_DATABINDING = 2; |
|
| 5573 | + private $_container = null; |
|
| 5574 | + private $_items = array(); |
|
| 5575 | + private $_expressions = array(); |
|
| 5576 | + private $_statements = array(); |
|
| 5577 | + private $_bindings = array(); |
|
| 5578 | 5578 | public function __construct($items) |
| 5579 | 5579 | { |
| 5580 | - $this->_items=array(); |
|
| 5581 | - $this->_expressions=array(); |
|
| 5582 | - $this->_statements=array(); |
|
| 5583 | - foreach($items as $id=>$item) |
|
| 5580 | + $this->_items = array(); |
|
| 5581 | + $this->_expressions = array(); |
|
| 5582 | + $this->_statements = array(); |
|
| 5583 | + foreach ($items as $id=>$item) |
|
| 5584 | 5584 | { |
| 5585 | - if(is_array($item)) |
|
| 5585 | + if (is_array($item)) |
|
| 5586 | 5586 | { |
| 5587 | - if($item[0]===self::TYPE_EXPRESSION) |
|
| 5588 | - $this->_expressions[$id]=$item[1]; |
|
| 5589 | - else if($item[0]===self::TYPE_STATEMENTS) |
|
| 5590 | - $this->_statements[$id]=$item[1]; |
|
| 5591 | - else if($item[0]===self::TYPE_DATABINDING) |
|
| 5592 | - $this->_bindings[$id]=$item[1]; |
|
| 5593 | - $this->_items[$id]=''; |
|
| 5587 | + if ($item[0] === self::TYPE_EXPRESSION) |
|
| 5588 | + $this->_expressions[$id] = $item[1]; |
|
| 5589 | + else if ($item[0] === self::TYPE_STATEMENTS) |
|
| 5590 | + $this->_statements[$id] = $item[1]; |
|
| 5591 | + else if ($item[0] === self::TYPE_DATABINDING) |
|
| 5592 | + $this->_bindings[$id] = $item[1]; |
|
| 5593 | + $this->_items[$id] = ''; |
|
| 5594 | 5594 | } |
| 5595 | 5595 | else |
| 5596 | - $this->_items[$id]=$item; |
|
| 5596 | + $this->_items[$id] = $item; |
|
| 5597 | 5597 | } |
| 5598 | 5598 | } |
| 5599 | 5599 | public function getContainer() |
@@ -5602,86 +5602,86 @@ discard block |
||
| 5602 | 5602 | } |
| 5603 | 5603 | public function setContainer(TComponent $value) |
| 5604 | 5604 | { |
| 5605 | - $this->_container=$value; |
|
| 5605 | + $this->_container = $value; |
|
| 5606 | 5606 | } |
| 5607 | 5607 | public function evaluateDynamicContent() |
| 5608 | 5608 | { |
| 5609 | - $context=$this->_container===null?$this:$this->_container; |
|
| 5610 | - foreach($this->_expressions as $id=>$expression) |
|
| 5611 | - $this->_items[$id]=$context->evaluateExpression($expression); |
|
| 5612 | - foreach($this->_statements as $id=>$statement) |
|
| 5613 | - $this->_items[$id]=$context->evaluateStatements($statement); |
|
| 5609 | + $context = $this->_container === null ? $this : $this->_container; |
|
| 5610 | + foreach ($this->_expressions as $id=>$expression) |
|
| 5611 | + $this->_items[$id] = $context->evaluateExpression($expression); |
|
| 5612 | + foreach ($this->_statements as $id=>$statement) |
|
| 5613 | + $this->_items[$id] = $context->evaluateStatements($statement); |
|
| 5614 | 5614 | } |
| 5615 | 5615 | public function dataBind() |
| 5616 | 5616 | { |
| 5617 | - $context=$this->_container===null?$this:$this->_container; |
|
| 5618 | - foreach($this->_bindings as $id=>$binding) |
|
| 5619 | - $this->_items[$id]=$context->evaluateExpression($binding); |
|
| 5617 | + $context = $this->_container === null ? $this : $this->_container; |
|
| 5618 | + foreach ($this->_bindings as $id=>$binding) |
|
| 5619 | + $this->_items[$id] = $context->evaluateExpression($binding); |
|
| 5620 | 5620 | } |
| 5621 | 5621 | public function render($writer) |
| 5622 | 5622 | { |
| 5623 | - $writer->write(implode('',$this->_items)); |
|
| 5623 | + $writer->write(implode('', $this->_items)); |
|
| 5624 | 5624 | } |
| 5625 | 5625 | } |
| 5626 | 5626 | class TFont extends TComponent |
| 5627 | 5627 | { |
| 5628 | - const IS_BOLD=0x01; |
|
| 5629 | - const IS_ITALIC=0x02; |
|
| 5630 | - const IS_OVERLINE=0x04; |
|
| 5631 | - const IS_STRIKEOUT=0x08; |
|
| 5632 | - const IS_UNDERLINE=0x10; |
|
| 5633 | - const IS_SET_BOLD=0x01000; |
|
| 5634 | - const IS_SET_ITALIC=0x02000; |
|
| 5635 | - const IS_SET_OVERLINE=0x04000; |
|
| 5636 | - const IS_SET_STRIKEOUT=0x08000; |
|
| 5637 | - const IS_SET_UNDERLINE=0x10000; |
|
| 5638 | - const IS_SET_SIZE=0x20000; |
|
| 5639 | - const IS_SET_NAME=0x40000; |
|
| 5640 | - private $_flags=0; |
|
| 5641 | - private $_name=''; |
|
| 5642 | - private $_size=''; |
|
| 5628 | + const IS_BOLD = 0x01; |
|
| 5629 | + const IS_ITALIC = 0x02; |
|
| 5630 | + const IS_OVERLINE = 0x04; |
|
| 5631 | + const IS_STRIKEOUT = 0x08; |
|
| 5632 | + const IS_UNDERLINE = 0x10; |
|
| 5633 | + const IS_SET_BOLD = 0x01000; |
|
| 5634 | + const IS_SET_ITALIC = 0x02000; |
|
| 5635 | + const IS_SET_OVERLINE = 0x04000; |
|
| 5636 | + const IS_SET_STRIKEOUT = 0x08000; |
|
| 5637 | + const IS_SET_UNDERLINE = 0x10000; |
|
| 5638 | + const IS_SET_SIZE = 0x20000; |
|
| 5639 | + const IS_SET_NAME = 0x40000; |
|
| 5640 | + private $_flags = 0; |
|
| 5641 | + private $_name = ''; |
|
| 5642 | + private $_size = ''; |
|
| 5643 | 5643 | protected function __getZappableSleepProps(&$exprops) |
| 5644 | 5644 | { |
| 5645 | 5645 | parent::__getZappableSleepProps($exprops); |
| 5646 | - if ($this->_flags===0) |
|
| 5646 | + if ($this->_flags === 0) |
|
| 5647 | 5647 | $exprops[] = "\0TFont\0_flags"; |
| 5648 | - if ($this->_name==='') |
|
| 5648 | + if ($this->_name === '') |
|
| 5649 | 5649 | $exprops[] = "\0TFont\0_name"; |
| 5650 | - if ($this->_size==='') |
|
| 5650 | + if ($this->_size === '') |
|
| 5651 | 5651 | $exprops[] = "\0TFont\0_size"; |
| 5652 | 5652 | } |
| 5653 | 5653 | public function getBold() |
| 5654 | 5654 | { |
| 5655 | - return ($this->_flags & self::IS_BOLD)!==0; |
|
| 5655 | + return ($this->_flags & self::IS_BOLD) !== 0; |
|
| 5656 | 5656 | } |
| 5657 | 5657 | public function setBold($value) |
| 5658 | 5658 | { |
| 5659 | 5659 | $this->_flags |= self::IS_SET_BOLD; |
| 5660 | - if(TPropertyValue::ensureBoolean($value)) |
|
| 5660 | + if (TPropertyValue::ensureBoolean($value)) |
|
| 5661 | 5661 | $this->_flags |= self::IS_BOLD; |
| 5662 | 5662 | else |
| 5663 | 5663 | $this->_flags &= ~self::IS_BOLD; |
| 5664 | 5664 | } |
| 5665 | 5665 | public function getItalic() |
| 5666 | 5666 | { |
| 5667 | - return ($this->_flags & self::IS_ITALIC)!==0; |
|
| 5667 | + return ($this->_flags & self::IS_ITALIC) !== 0; |
|
| 5668 | 5668 | } |
| 5669 | 5669 | public function setItalic($value) |
| 5670 | 5670 | { |
| 5671 | 5671 | $this->_flags |= self::IS_SET_ITALIC; |
| 5672 | - if(TPropertyValue::ensureBoolean($value)) |
|
| 5672 | + if (TPropertyValue::ensureBoolean($value)) |
|
| 5673 | 5673 | $this->_flags |= self::IS_ITALIC; |
| 5674 | 5674 | else |
| 5675 | 5675 | $this->_flags &= ~self::IS_ITALIC; |
| 5676 | 5676 | } |
| 5677 | 5677 | public function getOverline() |
| 5678 | 5678 | { |
| 5679 | - return ($this->_flags & self::IS_OVERLINE)!==0; |
|
| 5679 | + return ($this->_flags & self::IS_OVERLINE) !== 0; |
|
| 5680 | 5680 | } |
| 5681 | 5681 | public function setOverline($value) |
| 5682 | 5682 | { |
| 5683 | 5683 | $this->_flags |= self::IS_SET_OVERLINE; |
| 5684 | - if(TPropertyValue::ensureBoolean($value)) |
|
| 5684 | + if (TPropertyValue::ensureBoolean($value)) |
|
| 5685 | 5685 | $this->_flags |= self::IS_OVERLINE; |
| 5686 | 5686 | else |
| 5687 | 5687 | $this->_flags &= ~self::IS_OVERLINE; |
@@ -5693,28 +5693,28 @@ discard block |
||
| 5693 | 5693 | public function setSize($value) |
| 5694 | 5694 | { |
| 5695 | 5695 | $this->_flags |= self::IS_SET_SIZE; |
| 5696 | - $this->_size=$value; |
|
| 5696 | + $this->_size = $value; |
|
| 5697 | 5697 | } |
| 5698 | 5698 | public function getStrikeout() |
| 5699 | 5699 | { |
| 5700 | - return ($this->_flags & self::IS_STRIKEOUT)!==0; |
|
| 5700 | + return ($this->_flags & self::IS_STRIKEOUT) !== 0; |
|
| 5701 | 5701 | } |
| 5702 | 5702 | public function setStrikeout($value) |
| 5703 | 5703 | { |
| 5704 | 5704 | $this->_flags |= self::IS_SET_STRIKEOUT; |
| 5705 | - if(TPropertyValue::ensureBoolean($value)) |
|
| 5705 | + if (TPropertyValue::ensureBoolean($value)) |
|
| 5706 | 5706 | $this->_flags |= self::IS_STRIKEOUT; |
| 5707 | 5707 | else |
| 5708 | 5708 | $this->_flags &= ~self::IS_STRIKEOUT; |
| 5709 | 5709 | } |
| 5710 | 5710 | public function getUnderline() |
| 5711 | 5711 | { |
| 5712 | - return ($this->_flags & self::IS_UNDERLINE)!==0; |
|
| 5712 | + return ($this->_flags & self::IS_UNDERLINE) !== 0; |
|
| 5713 | 5713 | } |
| 5714 | 5714 | public function setUnderline($value) |
| 5715 | 5715 | { |
| 5716 | 5716 | $this->_flags |= self::IS_SET_UNDERLINE; |
| 5717 | - if(TPropertyValue::ensureBoolean($value)) |
|
| 5717 | + if (TPropertyValue::ensureBoolean($value)) |
|
| 5718 | 5718 | $this->_flags |= self::IS_UNDERLINE; |
| 5719 | 5719 | else |
| 5720 | 5720 | $this->_flags &= ~self::IS_UNDERLINE; |
@@ -5726,7 +5726,7 @@ discard block |
||
| 5726 | 5726 | public function setName($value) |
| 5727 | 5727 | { |
| 5728 | 5728 | $this->_flags |= self::IS_SET_NAME; |
| 5729 | - $this->_name=$value; |
|
| 5729 | + $this->_name = $value; |
|
| 5730 | 5730 | } |
| 5731 | 5731 | public function getIsEmpty() |
| 5732 | 5732 | { |
@@ -5734,188 +5734,188 @@ discard block |
||
| 5734 | 5734 | } |
| 5735 | 5735 | public function reset() |
| 5736 | 5736 | { |
| 5737 | - $this->_flags=0; |
|
| 5738 | - $this->_name=''; |
|
| 5739 | - $this->_size=''; |
|
| 5737 | + $this->_flags = 0; |
|
| 5738 | + $this->_name = ''; |
|
| 5739 | + $this->_size = ''; |
|
| 5740 | 5740 | } |
| 5741 | 5741 | public function mergeWith($font) |
| 5742 | 5742 | { |
| 5743 | - if($font===null || $font->_flags===0) |
|
| 5743 | + if ($font === null || $font->_flags === 0) |
|
| 5744 | 5744 | return; |
| 5745 | - if(!($this->_flags & self::IS_SET_BOLD) && ($font->_flags & self::IS_SET_BOLD)) |
|
| 5745 | + if (!($this->_flags & self::IS_SET_BOLD) && ($font->_flags & self::IS_SET_BOLD)) |
|
| 5746 | 5746 | $this->setBold($font->getBold()); |
| 5747 | - if(!($this->_flags & self::IS_SET_ITALIC) && ($font->_flags & self::IS_SET_ITALIC)) |
|
| 5747 | + if (!($this->_flags & self::IS_SET_ITALIC) && ($font->_flags & self::IS_SET_ITALIC)) |
|
| 5748 | 5748 | $this->setItalic($font->getItalic()); |
| 5749 | - if(!($this->_flags & self::IS_SET_OVERLINE) && ($font->_flags & self::IS_SET_OVERLINE)) |
|
| 5749 | + if (!($this->_flags & self::IS_SET_OVERLINE) && ($font->_flags & self::IS_SET_OVERLINE)) |
|
| 5750 | 5750 | $this->setOverline($font->getOverline()); |
| 5751 | - if(!($this->_flags & self::IS_SET_STRIKEOUT) && ($font->_flags & self::IS_SET_STRIKEOUT)) |
|
| 5751 | + if (!($this->_flags & self::IS_SET_STRIKEOUT) && ($font->_flags & self::IS_SET_STRIKEOUT)) |
|
| 5752 | 5752 | $this->setStrikeout($font->getStrikeout()); |
| 5753 | - if(!($this->_flags & self::IS_SET_UNDERLINE) && ($font->_flags & self::IS_SET_UNDERLINE)) |
|
| 5753 | + if (!($this->_flags & self::IS_SET_UNDERLINE) && ($font->_flags & self::IS_SET_UNDERLINE)) |
|
| 5754 | 5754 | $this->setUnderline($font->getUnderline()); |
| 5755 | - if(!($this->_flags & self::IS_SET_SIZE) && ($font->_flags & self::IS_SET_SIZE)) |
|
| 5755 | + if (!($this->_flags & self::IS_SET_SIZE) && ($font->_flags & self::IS_SET_SIZE)) |
|
| 5756 | 5756 | $this->setSize($font->getSize()); |
| 5757 | - if(!($this->_flags & self::IS_SET_NAME) && ($font->_flags & self::IS_SET_NAME)) |
|
| 5757 | + if (!($this->_flags & self::IS_SET_NAME) && ($font->_flags & self::IS_SET_NAME)) |
|
| 5758 | 5758 | $this->setName($font->getName()); |
| 5759 | 5759 | } |
| 5760 | 5760 | public function copyFrom($font) |
| 5761 | 5761 | { |
| 5762 | - if($font===null || $font->_flags===0) |
|
| 5762 | + if ($font === null || $font->_flags === 0) |
|
| 5763 | 5763 | return; |
| 5764 | - if($font->_flags & self::IS_SET_BOLD) |
|
| 5764 | + if ($font->_flags & self::IS_SET_BOLD) |
|
| 5765 | 5765 | $this->setBold($font->getBold()); |
| 5766 | - if($font->_flags & self::IS_SET_ITALIC) |
|
| 5766 | + if ($font->_flags & self::IS_SET_ITALIC) |
|
| 5767 | 5767 | $this->setItalic($font->getItalic()); |
| 5768 | - if($font->_flags & self::IS_SET_OVERLINE) |
|
| 5768 | + if ($font->_flags & self::IS_SET_OVERLINE) |
|
| 5769 | 5769 | $this->setOverline($font->getOverline()); |
| 5770 | - if($font->_flags & self::IS_SET_STRIKEOUT) |
|
| 5770 | + if ($font->_flags & self::IS_SET_STRIKEOUT) |
|
| 5771 | 5771 | $this->setStrikeout($font->getStrikeout()); |
| 5772 | - if($font->_flags & self::IS_SET_UNDERLINE) |
|
| 5772 | + if ($font->_flags & self::IS_SET_UNDERLINE) |
|
| 5773 | 5773 | $this->setUnderline($font->getUnderline()); |
| 5774 | - if($font->_flags & self::IS_SET_SIZE) |
|
| 5774 | + if ($font->_flags & self::IS_SET_SIZE) |
|
| 5775 | 5775 | $this->setSize($font->getSize()); |
| 5776 | - if($font->_flags & self::IS_SET_NAME) |
|
| 5776 | + if ($font->_flags & self::IS_SET_NAME) |
|
| 5777 | 5777 | $this->setName($font->getName()); |
| 5778 | 5778 | } |
| 5779 | 5779 | public function toString() |
| 5780 | 5780 | { |
| 5781 | - if($this->_flags===0) |
|
| 5781 | + if ($this->_flags === 0) |
|
| 5782 | 5782 | return ''; |
| 5783 | - $str=''; |
|
| 5784 | - if($this->_flags & self::IS_SET_BOLD) |
|
| 5785 | - $str.='font-weight:'.(($this->_flags & self::IS_BOLD)?'bold;':'normal;'); |
|
| 5786 | - if($this->_flags & self::IS_SET_ITALIC) |
|
| 5787 | - $str.='font-style:'.(($this->_flags & self::IS_ITALIC)?'italic;':'normal;'); |
|
| 5788 | - $textDec=''; |
|
| 5789 | - if($this->_flags & self::IS_UNDERLINE) |
|
| 5790 | - $textDec.='underline'; |
|
| 5791 | - if($this->_flags & self::IS_OVERLINE) |
|
| 5792 | - $textDec.=' overline'; |
|
| 5793 | - if($this->_flags & self::IS_STRIKEOUT) |
|
| 5794 | - $textDec.=' line-through'; |
|
| 5795 | - $textDec=ltrim($textDec); |
|
| 5796 | - if($textDec!=='') |
|
| 5797 | - $str.='text-decoration:'.$textDec.';'; |
|
| 5798 | - if($this->_size!=='') |
|
| 5799 | - $str.='font-size:'.$this->_size.';'; |
|
| 5800 | - if($this->_name!=='') |
|
| 5801 | - $str.='font-family:'.$this->_name.';'; |
|
| 5783 | + $str = ''; |
|
| 5784 | + if ($this->_flags & self::IS_SET_BOLD) |
|
| 5785 | + $str .= 'font-weight:' . (($this->_flags & self::IS_BOLD) ? 'bold;' : 'normal;'); |
|
| 5786 | + if ($this->_flags & self::IS_SET_ITALIC) |
|
| 5787 | + $str .= 'font-style:' . (($this->_flags & self::IS_ITALIC) ? 'italic;' : 'normal;'); |
|
| 5788 | + $textDec = ''; |
|
| 5789 | + if ($this->_flags & self::IS_UNDERLINE) |
|
| 5790 | + $textDec .= 'underline'; |
|
| 5791 | + if ($this->_flags & self::IS_OVERLINE) |
|
| 5792 | + $textDec .= ' overline'; |
|
| 5793 | + if ($this->_flags & self::IS_STRIKEOUT) |
|
| 5794 | + $textDec .= ' line-through'; |
|
| 5795 | + $textDec = ltrim($textDec); |
|
| 5796 | + if ($textDec !== '') |
|
| 5797 | + $str .= 'text-decoration:' . $textDec . ';'; |
|
| 5798 | + if ($this->_size !== '') |
|
| 5799 | + $str .= 'font-size:' . $this->_size . ';'; |
|
| 5800 | + if ($this->_name !== '') |
|
| 5801 | + $str .= 'font-family:' . $this->_name . ';'; |
|
| 5802 | 5802 | return $str; |
| 5803 | 5803 | } |
| 5804 | 5804 | public function addAttributesToRender($writer) |
| 5805 | 5805 | { |
| 5806 | - if($this->_flags===0) |
|
| 5806 | + if ($this->_flags === 0) |
|
| 5807 | 5807 | return; |
| 5808 | - if($this->_flags & self::IS_SET_BOLD) |
|
| 5809 | - $writer->addStyleAttribute('font-weight',(($this->_flags & self::IS_BOLD)?'bold':'normal')); |
|
| 5810 | - if($this->_flags & self::IS_SET_ITALIC) |
|
| 5811 | - $writer->addStyleAttribute('font-style',(($this->_flags & self::IS_ITALIC)?'italic':'normal')); |
|
| 5812 | - $textDec=''; |
|
| 5813 | - if($this->_flags & self::IS_UNDERLINE) |
|
| 5814 | - $textDec.='underline'; |
|
| 5815 | - if($this->_flags & self::IS_OVERLINE) |
|
| 5816 | - $textDec.=' overline'; |
|
| 5817 | - if($this->_flags & self::IS_STRIKEOUT) |
|
| 5818 | - $textDec.=' line-through'; |
|
| 5819 | - $textDec=ltrim($textDec); |
|
| 5820 | - if($textDec!=='') |
|
| 5821 | - $writer->addStyleAttribute('text-decoration',$textDec); |
|
| 5822 | - if($this->_size!=='') |
|
| 5823 | - $writer->addStyleAttribute('font-size',$this->_size); |
|
| 5824 | - if($this->_name!=='') |
|
| 5825 | - $writer->addStyleAttribute('font-family',$this->_name); |
|
| 5808 | + if ($this->_flags & self::IS_SET_BOLD) |
|
| 5809 | + $writer->addStyleAttribute('font-weight', (($this->_flags & self::IS_BOLD) ? 'bold' : 'normal')); |
|
| 5810 | + if ($this->_flags & self::IS_SET_ITALIC) |
|
| 5811 | + $writer->addStyleAttribute('font-style', (($this->_flags & self::IS_ITALIC) ? 'italic' : 'normal')); |
|
| 5812 | + $textDec = ''; |
|
| 5813 | + if ($this->_flags & self::IS_UNDERLINE) |
|
| 5814 | + $textDec .= 'underline'; |
|
| 5815 | + if ($this->_flags & self::IS_OVERLINE) |
|
| 5816 | + $textDec .= ' overline'; |
|
| 5817 | + if ($this->_flags & self::IS_STRIKEOUT) |
|
| 5818 | + $textDec .= ' line-through'; |
|
| 5819 | + $textDec = ltrim($textDec); |
|
| 5820 | + if ($textDec !== '') |
|
| 5821 | + $writer->addStyleAttribute('text-decoration', $textDec); |
|
| 5822 | + if ($this->_size !== '') |
|
| 5823 | + $writer->addStyleAttribute('font-size', $this->_size); |
|
| 5824 | + if ($this->_name !== '') |
|
| 5825 | + $writer->addStyleAttribute('font-family', $this->_name); |
|
| 5826 | 5826 | } |
| 5827 | 5827 | } |
| 5828 | 5828 | class TStyle extends TComponent |
| 5829 | 5829 | { |
| 5830 | - private $_fields=array(); |
|
| 5831 | - private $_font=null; |
|
| 5832 | - private $_class=null; |
|
| 5833 | - private $_customStyle=null; |
|
| 5834 | - private $_displayStyle='Fixed'; |
|
| 5830 | + private $_fields = array(); |
|
| 5831 | + private $_font = null; |
|
| 5832 | + private $_class = null; |
|
| 5833 | + private $_customStyle = null; |
|
| 5834 | + private $_displayStyle = 'Fixed'; |
|
| 5835 | 5835 | protected function __getZappableSleepProps(&$exprops) |
| 5836 | 5836 | { |
| 5837 | 5837 | parent::__getZappableSleepProps($exprops); |
| 5838 | - if ($this->_fields===array()) |
|
| 5838 | + if ($this->_fields === array()) |
|
| 5839 | 5839 | $exprops[] = "\0TStyle\0_fields"; |
| 5840 | - if($this->_font===null) |
|
| 5840 | + if ($this->_font === null) |
|
| 5841 | 5841 | $exprops[] = "\0TStyle\0_font"; |
| 5842 | - if($this->_class===null) |
|
| 5842 | + if ($this->_class === null) |
|
| 5843 | 5843 | $exprops[] = "\0TStyle\0_class"; |
| 5844 | - if ($this->_customStyle===null) |
|
| 5844 | + if ($this->_customStyle === null) |
|
| 5845 | 5845 | $exprops[] = "\0TStyle\0_customStyle"; |
| 5846 | - if ($this->_displayStyle==='Fixed') |
|
| 5846 | + if ($this->_displayStyle === 'Fixed') |
|
| 5847 | 5847 | $exprops[] = "\0TStyle\0_displayStyle"; |
| 5848 | 5848 | } |
| 5849 | - public function __construct($style=null) |
|
| 5849 | + public function __construct($style = null) |
|
| 5850 | 5850 | { |
| 5851 | - if($style!==null) |
|
| 5851 | + if ($style !== null) |
|
| 5852 | 5852 | $this->copyFrom($style); |
| 5853 | 5853 | } |
| 5854 | 5854 | public function __clone() |
| 5855 | 5855 | { |
| 5856 | - if($this->_font!==null) |
|
| 5856 | + if ($this->_font !== null) |
|
| 5857 | 5857 | $this->_font = clone($this->_font); |
| 5858 | 5858 | } |
| 5859 | 5859 | public function getBackColor() |
| 5860 | 5860 | { |
| 5861 | - return isset($this->_fields['background-color'])?$this->_fields['background-color']:''; |
|
| 5861 | + return isset($this->_fields['background-color']) ? $this->_fields['background-color'] : ''; |
|
| 5862 | 5862 | } |
| 5863 | 5863 | public function setBackColor($value) |
| 5864 | 5864 | { |
| 5865 | - if(trim($value)==='') |
|
| 5865 | + if (trim($value) === '') |
|
| 5866 | 5866 | unset($this->_fields['background-color']); |
| 5867 | 5867 | else |
| 5868 | - $this->_fields['background-color']=$value; |
|
| 5868 | + $this->_fields['background-color'] = $value; |
|
| 5869 | 5869 | } |
| 5870 | 5870 | public function getBorderColor() |
| 5871 | 5871 | { |
| 5872 | - return isset($this->_fields['border-color'])?$this->_fields['border-color']:''; |
|
| 5872 | + return isset($this->_fields['border-color']) ? $this->_fields['border-color'] : ''; |
|
| 5873 | 5873 | } |
| 5874 | 5874 | public function setBorderColor($value) |
| 5875 | 5875 | { |
| 5876 | - if(trim($value)==='') |
|
| 5876 | + if (trim($value) === '') |
|
| 5877 | 5877 | unset($this->_fields['border-color']); |
| 5878 | 5878 | else |
| 5879 | - $this->_fields['border-color']=$value; |
|
| 5879 | + $this->_fields['border-color'] = $value; |
|
| 5880 | 5880 | } |
| 5881 | 5881 | public function getBorderStyle() |
| 5882 | 5882 | { |
| 5883 | - return isset($this->_fields['border-style'])?$this->_fields['border-style']:''; |
|
| 5883 | + return isset($this->_fields['border-style']) ? $this->_fields['border-style'] : ''; |
|
| 5884 | 5884 | } |
| 5885 | 5885 | public function setBorderStyle($value) |
| 5886 | 5886 | { |
| 5887 | - if(trim($value)==='') |
|
| 5887 | + if (trim($value) === '') |
|
| 5888 | 5888 | unset($this->_fields['border-style']); |
| 5889 | 5889 | else |
| 5890 | - $this->_fields['border-style']=$value; |
|
| 5890 | + $this->_fields['border-style'] = $value; |
|
| 5891 | 5891 | } |
| 5892 | 5892 | public function getBorderWidth() |
| 5893 | 5893 | { |
| 5894 | - return isset($this->_fields['border-width'])?$this->_fields['border-width']:''; |
|
| 5894 | + return isset($this->_fields['border-width']) ? $this->_fields['border-width'] : ''; |
|
| 5895 | 5895 | } |
| 5896 | 5896 | public function setBorderWidth($value) |
| 5897 | 5897 | { |
| 5898 | - if(trim($value)==='') |
|
| 5898 | + if (trim($value) === '') |
|
| 5899 | 5899 | unset($this->_fields['border-width']); |
| 5900 | 5900 | else |
| 5901 | - $this->_fields['border-width']=$value; |
|
| 5901 | + $this->_fields['border-width'] = $value; |
|
| 5902 | 5902 | } |
| 5903 | 5903 | public function getCssClass() |
| 5904 | 5904 | { |
| 5905 | - return $this->_class===null?'':$this->_class; |
|
| 5905 | + return $this->_class === null ? '' : $this->_class; |
|
| 5906 | 5906 | } |
| 5907 | 5907 | public function hasCssClass() |
| 5908 | 5908 | { |
| 5909 | - return ($this->_class!==null); |
|
| 5909 | + return ($this->_class !== null); |
|
| 5910 | 5910 | } |
| 5911 | 5911 | public function setCssClass($value) |
| 5912 | 5912 | { |
| 5913 | - $this->_class=$value; |
|
| 5913 | + $this->_class = $value; |
|
| 5914 | 5914 | } |
| 5915 | 5915 | public function getFont() |
| 5916 | 5916 | { |
| 5917 | - if($this->_font===null) |
|
| 5918 | - $this->_font=new TFont; |
|
| 5917 | + if ($this->_font === null) |
|
| 5918 | + $this->_font = new TFont; |
|
| 5919 | 5919 | return $this->_font; |
| 5920 | 5920 | } |
| 5921 | 5921 | public function hasFont() |
@@ -5925,13 +5925,13 @@ discard block |
||
| 5925 | 5925 | public function setDisplayStyle($value) |
| 5926 | 5926 | { |
| 5927 | 5927 | $this->_displayStyle = TPropertyValue::ensureEnum($value, 'TDisplayStyle'); |
| 5928 | - switch($this->_displayStyle) |
|
| 5928 | + switch ($this->_displayStyle) |
|
| 5929 | 5929 | { |
| 5930 | 5930 | case TDisplayStyle::None: |
| 5931 | 5931 | $this->_fields['display'] = 'none'; |
| 5932 | 5932 | break; |
| 5933 | 5933 | case TDisplayStyle::Dynamic: |
| 5934 | - $this->_fields['display'] = ''; break; |
|
| 5934 | + $this->_fields['display'] = ''; break; |
|
| 5935 | 5935 | case TDisplayStyle::Fixed: |
| 5936 | 5936 | $this->_fields['visibility'] = 'visible'; |
| 5937 | 5937 | break; |
@@ -5946,41 +5946,41 @@ discard block |
||
| 5946 | 5946 | } |
| 5947 | 5947 | public function getForeColor() |
| 5948 | 5948 | { |
| 5949 | - return isset($this->_fields['color'])?$this->_fields['color']:''; |
|
| 5949 | + return isset($this->_fields['color']) ? $this->_fields['color'] : ''; |
|
| 5950 | 5950 | } |
| 5951 | 5951 | public function setForeColor($value) |
| 5952 | 5952 | { |
| 5953 | - if(trim($value)==='') |
|
| 5953 | + if (trim($value) === '') |
|
| 5954 | 5954 | unset($this->_fields['color']); |
| 5955 | 5955 | else |
| 5956 | - $this->_fields['color']=$value; |
|
| 5956 | + $this->_fields['color'] = $value; |
|
| 5957 | 5957 | } |
| 5958 | 5958 | public function getHeight() |
| 5959 | 5959 | { |
| 5960 | - return isset($this->_fields['height'])?$this->_fields['height']:''; |
|
| 5960 | + return isset($this->_fields['height']) ? $this->_fields['height'] : ''; |
|
| 5961 | 5961 | } |
| 5962 | 5962 | public function setHeight($value) |
| 5963 | 5963 | { |
| 5964 | - if(trim($value)==='') |
|
| 5964 | + if (trim($value) === '') |
|
| 5965 | 5965 | unset($this->_fields['height']); |
| 5966 | 5966 | else |
| 5967 | - $this->_fields['height']=$value; |
|
| 5967 | + $this->_fields['height'] = $value; |
|
| 5968 | 5968 | } |
| 5969 | 5969 | public function getCustomStyle() |
| 5970 | 5970 | { |
| 5971 | - return $this->_customStyle===null?'':$this->_customStyle; |
|
| 5971 | + return $this->_customStyle === null ? '' : $this->_customStyle; |
|
| 5972 | 5972 | } |
| 5973 | 5973 | public function setCustomStyle($value) |
| 5974 | 5974 | { |
| 5975 | - $this->_customStyle=$value; |
|
| 5975 | + $this->_customStyle = $value; |
|
| 5976 | 5976 | } |
| 5977 | 5977 | public function getStyleField($name) |
| 5978 | 5978 | { |
| 5979 | - return isset($this->_fields[$name])?$this->_fields[$name]:''; |
|
| 5979 | + return isset($this->_fields[$name]) ? $this->_fields[$name] : ''; |
|
| 5980 | 5980 | } |
| 5981 | - public function setStyleField($name,$value) |
|
| 5981 | + public function setStyleField($name, $value) |
|
| 5982 | 5982 | { |
| 5983 | - $this->_fields[$name]=$value; |
|
| 5983 | + $this->_fields[$name] = $value; |
|
| 5984 | 5984 | } |
| 5985 | 5985 | public function clearStyleField($name) |
| 5986 | 5986 | { |
@@ -5992,61 +5992,61 @@ discard block |
||
| 5992 | 5992 | } |
| 5993 | 5993 | public function getWidth() |
| 5994 | 5994 | { |
| 5995 | - return isset($this->_fields['width'])?$this->_fields['width']:''; |
|
| 5995 | + return isset($this->_fields['width']) ? $this->_fields['width'] : ''; |
|
| 5996 | 5996 | } |
| 5997 | 5997 | public function setWidth($value) |
| 5998 | 5998 | { |
| 5999 | - $this->_fields['width']=$value; |
|
| 5999 | + $this->_fields['width'] = $value; |
|
| 6000 | 6000 | } |
| 6001 | 6001 | public function reset() |
| 6002 | 6002 | { |
| 6003 | - $this->_fields=array(); |
|
| 6004 | - $this->_font=null; |
|
| 6005 | - $this->_class=null; |
|
| 6006 | - $this->_customStyle=null; |
|
| 6003 | + $this->_fields = array(); |
|
| 6004 | + $this->_font = null; |
|
| 6005 | + $this->_class = null; |
|
| 6006 | + $this->_customStyle = null; |
|
| 6007 | 6007 | } |
| 6008 | 6008 | public function copyFrom($style) |
| 6009 | 6009 | { |
| 6010 | - if($style instanceof TStyle) |
|
| 6010 | + if ($style instanceof TStyle) |
|
| 6011 | 6011 | { |
| 6012 | - $this->_fields=array_merge($this->_fields,$style->_fields); |
|
| 6013 | - if($style->_class!==null) |
|
| 6014 | - $this->_class=$style->_class; |
|
| 6015 | - if($style->_customStyle!==null) |
|
| 6016 | - $this->_customStyle=$style->_customStyle; |
|
| 6017 | - if($style->_font!==null) |
|
| 6012 | + $this->_fields = array_merge($this->_fields, $style->_fields); |
|
| 6013 | + if ($style->_class !== null) |
|
| 6014 | + $this->_class = $style->_class; |
|
| 6015 | + if ($style->_customStyle !== null) |
|
| 6016 | + $this->_customStyle = $style->_customStyle; |
|
| 6017 | + if ($style->_font !== null) |
|
| 6018 | 6018 | $this->getFont()->copyFrom($style->_font); |
| 6019 | 6019 | } |
| 6020 | 6020 | } |
| 6021 | 6021 | public function mergeWith($style) |
| 6022 | 6022 | { |
| 6023 | - if($style instanceof TStyle) |
|
| 6023 | + if ($style instanceof TStyle) |
|
| 6024 | 6024 | { |
| 6025 | - $this->_fields=array_merge($style->_fields,$this->_fields); |
|
| 6026 | - if($this->_class===null) |
|
| 6027 | - $this->_class=$style->_class; |
|
| 6028 | - if($this->_customStyle===null) |
|
| 6029 | - $this->_customStyle=$style->_customStyle; |
|
| 6030 | - if($style->_font!==null) |
|
| 6025 | + $this->_fields = array_merge($style->_fields, $this->_fields); |
|
| 6026 | + if ($this->_class === null) |
|
| 6027 | + $this->_class = $style->_class; |
|
| 6028 | + if ($this->_customStyle === null) |
|
| 6029 | + $this->_customStyle = $style->_customStyle; |
|
| 6030 | + if ($style->_font !== null) |
|
| 6031 | 6031 | $this->getFont()->mergeWith($style->_font); |
| 6032 | 6032 | } |
| 6033 | 6033 | } |
| 6034 | 6034 | public function addAttributesToRender($writer) |
| 6035 | 6035 | { |
| 6036 | - if($this->_customStyle!==null) |
|
| 6036 | + if ($this->_customStyle !== null) |
|
| 6037 | 6037 | { |
| 6038 | - foreach(explode(';',$this->_customStyle) as $style) |
|
| 6038 | + foreach (explode(';', $this->_customStyle) as $style) |
|
| 6039 | 6039 | { |
| 6040 | - $arr=explode(':',$style,2); |
|
| 6041 | - if(isset($arr[1]) && trim($arr[0])!=='') |
|
| 6042 | - $writer->addStyleAttribute(trim($arr[0]),trim($arr[1])); |
|
| 6040 | + $arr = explode(':', $style, 2); |
|
| 6041 | + if (isset($arr[1]) && trim($arr[0]) !== '') |
|
| 6042 | + $writer->addStyleAttribute(trim($arr[0]), trim($arr[1])); |
|
| 6043 | 6043 | } |
| 6044 | 6044 | } |
| 6045 | 6045 | $writer->addStyleAttributes($this->_fields); |
| 6046 | - if($this->_font!==null) |
|
| 6046 | + if ($this->_font !== null) |
|
| 6047 | 6047 | $this->_font->addAttributesToRender($writer); |
| 6048 | - if($this->_class!==null) |
|
| 6049 | - $writer->addAttribute('class',$this->_class); |
|
| 6048 | + if ($this->_class !== null) |
|
| 6049 | + $writer->addAttribute('class', $this->_class); |
|
| 6050 | 6050 | } |
| 6051 | 6051 | public function getStyleFields() |
| 6052 | 6052 | { |
@@ -6055,257 +6055,257 @@ discard block |
||
| 6055 | 6055 | } |
| 6056 | 6056 | class TDisplayStyle extends TEnumerable |
| 6057 | 6057 | { |
| 6058 | - const None='None'; |
|
| 6059 | - const Dynamic='Dynamic'; |
|
| 6060 | - const Fixed='Fixed'; |
|
| 6061 | - const Hidden='Hidden'; |
|
| 6058 | + const None = 'None'; |
|
| 6059 | + const Dynamic = 'Dynamic'; |
|
| 6060 | + const Fixed = 'Fixed'; |
|
| 6061 | + const Hidden = 'Hidden'; |
|
| 6062 | 6062 | } |
| 6063 | 6063 | class TTableStyle extends TStyle |
| 6064 | 6064 | { |
| 6065 | - private $_backImageUrl=null; |
|
| 6066 | - private $_horizontalAlign=null; |
|
| 6067 | - private $_cellPadding=null; |
|
| 6068 | - private $_cellSpacing=null; |
|
| 6069 | - private $_gridLines=null; |
|
| 6070 | - private $_borderCollapse=null; |
|
| 6065 | + private $_backImageUrl = null; |
|
| 6066 | + private $_horizontalAlign = null; |
|
| 6067 | + private $_cellPadding = null; |
|
| 6068 | + private $_cellSpacing = null; |
|
| 6069 | + private $_gridLines = null; |
|
| 6070 | + private $_borderCollapse = null; |
|
| 6071 | 6071 | protected function __getZappableSleepProps(&$exprops) |
| 6072 | 6072 | { |
| 6073 | 6073 | parent::__getZappableSleepProps($exprops); |
| 6074 | - if ($this->_backImageUrl===null) |
|
| 6074 | + if ($this->_backImageUrl === null) |
|
| 6075 | 6075 | $exprops[] = "\0TTableStyle\0_backImageUrl"; |
| 6076 | - if ($this->_horizontalAlign===null) |
|
| 6076 | + if ($this->_horizontalAlign === null) |
|
| 6077 | 6077 | $exprops[] = "\0TTableStyle\0_horizontalAlign"; |
| 6078 | - if ($this->_cellPadding===null) |
|
| 6078 | + if ($this->_cellPadding === null) |
|
| 6079 | 6079 | $exprops[] = "\0TTableStyle\0_cellPadding"; |
| 6080 | - if ($this->_cellSpacing===null) |
|
| 6080 | + if ($this->_cellSpacing === null) |
|
| 6081 | 6081 | $exprops[] = "\0TTableStyle\0_cellSpacing"; |
| 6082 | - if ($this->_gridLines===null) |
|
| 6082 | + if ($this->_gridLines === null) |
|
| 6083 | 6083 | $exprops[] = "\0TTableStyle\0_gridLines"; |
| 6084 | - if ($this->_borderCollapse===null) |
|
| 6084 | + if ($this->_borderCollapse === null) |
|
| 6085 | 6085 | $exprops[] = "\0TTableStyle\0_borderCollapse"; |
| 6086 | 6086 | } |
| 6087 | 6087 | public function reset() |
| 6088 | 6088 | { |
| 6089 | - $this->_backImageUrl=null; |
|
| 6090 | - $this->_horizontalAlign=null; |
|
| 6091 | - $this->_cellPadding=null; |
|
| 6092 | - $this->_cellSpacing=null; |
|
| 6093 | - $this->_gridLines=null; |
|
| 6094 | - $this->_borderCollapse=null; |
|
| 6089 | + $this->_backImageUrl = null; |
|
| 6090 | + $this->_horizontalAlign = null; |
|
| 6091 | + $this->_cellPadding = null; |
|
| 6092 | + $this->_cellSpacing = null; |
|
| 6093 | + $this->_gridLines = null; |
|
| 6094 | + $this->_borderCollapse = null; |
|
| 6095 | 6095 | } |
| 6096 | 6096 | public function copyFrom($style) |
| 6097 | 6097 | { |
| 6098 | 6098 | parent::copyFrom($style); |
| 6099 | - if($style instanceof TTableStyle) |
|
| 6100 | - { |
|
| 6101 | - if($style->_backImageUrl!==null) |
|
| 6102 | - $this->_backImageUrl=$style->_backImageUrl; |
|
| 6103 | - if($style->_horizontalAlign!==null) |
|
| 6104 | - $this->_horizontalAlign=$style->_horizontalAlign; |
|
| 6105 | - if($style->_cellPadding!==null) |
|
| 6106 | - $this->_cellPadding=$style->_cellPadding; |
|
| 6107 | - if($style->_cellSpacing!==null) |
|
| 6108 | - $this->_cellSpacing=$style->_cellSpacing; |
|
| 6109 | - if($style->_gridLines!==null) |
|
| 6110 | - $this->_gridLines=$style->_gridLines; |
|
| 6111 | - if($style->_borderCollapse!==null) |
|
| 6112 | - $this->_borderCollapse=$style->_borderCollapse; |
|
| 6099 | + if ($style instanceof TTableStyle) |
|
| 6100 | + { |
|
| 6101 | + if ($style->_backImageUrl !== null) |
|
| 6102 | + $this->_backImageUrl = $style->_backImageUrl; |
|
| 6103 | + if ($style->_horizontalAlign !== null) |
|
| 6104 | + $this->_horizontalAlign = $style->_horizontalAlign; |
|
| 6105 | + if ($style->_cellPadding !== null) |
|
| 6106 | + $this->_cellPadding = $style->_cellPadding; |
|
| 6107 | + if ($style->_cellSpacing !== null) |
|
| 6108 | + $this->_cellSpacing = $style->_cellSpacing; |
|
| 6109 | + if ($style->_gridLines !== null) |
|
| 6110 | + $this->_gridLines = $style->_gridLines; |
|
| 6111 | + if ($style->_borderCollapse !== null) |
|
| 6112 | + $this->_borderCollapse = $style->_borderCollapse; |
|
| 6113 | 6113 | } |
| 6114 | 6114 | } |
| 6115 | 6115 | public function mergeWith($style) |
| 6116 | 6116 | { |
| 6117 | 6117 | parent::mergeWith($style); |
| 6118 | - if($style instanceof TTableStyle) |
|
| 6119 | - { |
|
| 6120 | - if($this->_backImageUrl===null && $style->_backImageUrl!==null) |
|
| 6121 | - $this->_backImageUrl=$style->_backImageUrl; |
|
| 6122 | - if($this->_horizontalAlign===null && $style->_horizontalAlign!==null) |
|
| 6123 | - $this->_horizontalAlign=$style->_horizontalAlign; |
|
| 6124 | - if($this->_cellPadding===null && $style->_cellPadding!==null) |
|
| 6125 | - $this->_cellPadding=$style->_cellPadding; |
|
| 6126 | - if($this->_cellSpacing===null && $style->_cellSpacing!==null) |
|
| 6127 | - $this->_cellSpacing=$style->_cellSpacing; |
|
| 6128 | - if($this->_gridLines===null && $style->_gridLines!==null) |
|
| 6129 | - $this->_gridLines=$style->_gridLines; |
|
| 6130 | - if($this->_borderCollapse===null && $style->_borderCollapse!==null) |
|
| 6131 | - $this->_borderCollapse=$style->_borderCollapse; |
|
| 6118 | + if ($style instanceof TTableStyle) |
|
| 6119 | + { |
|
| 6120 | + if ($this->_backImageUrl === null && $style->_backImageUrl !== null) |
|
| 6121 | + $this->_backImageUrl = $style->_backImageUrl; |
|
| 6122 | + if ($this->_horizontalAlign === null && $style->_horizontalAlign !== null) |
|
| 6123 | + $this->_horizontalAlign = $style->_horizontalAlign; |
|
| 6124 | + if ($this->_cellPadding === null && $style->_cellPadding !== null) |
|
| 6125 | + $this->_cellPadding = $style->_cellPadding; |
|
| 6126 | + if ($this->_cellSpacing === null && $style->_cellSpacing !== null) |
|
| 6127 | + $this->_cellSpacing = $style->_cellSpacing; |
|
| 6128 | + if ($this->_gridLines === null && $style->_gridLines !== null) |
|
| 6129 | + $this->_gridLines = $style->_gridLines; |
|
| 6130 | + if ($this->_borderCollapse === null && $style->_borderCollapse !== null) |
|
| 6131 | + $this->_borderCollapse = $style->_borderCollapse; |
|
| 6132 | 6132 | } |
| 6133 | 6133 | } |
| 6134 | 6134 | public function addAttributesToRender($writer) |
| 6135 | 6135 | { |
| 6136 | - if(($url=trim($this->getBackImageUrl()))!=='') |
|
| 6137 | - $writer->addStyleAttribute('background-image','url('.$url.')'); |
|
| 6138 | - if(($horizontalAlign=$this->getHorizontalAlign())!==THorizontalAlign::NotSet) |
|
| 6139 | - $writer->addStyleAttribute('text-align',strtolower($horizontalAlign)); |
|
| 6140 | - if(($cellPadding=$this->getCellPadding())>=0) |
|
| 6141 | - $writer->addAttribute('cellpadding',"$cellPadding"); |
|
| 6142 | - if(($cellSpacing=$this->getCellSpacing())>=0) |
|
| 6143 | - $writer->addAttribute('cellspacing',"$cellSpacing"); |
|
| 6144 | - if($this->getBorderCollapse()) |
|
| 6145 | - $writer->addStyleAttribute('border-collapse','collapse'); |
|
| 6146 | - switch($this->getGridLines()) |
|
| 6147 | - { |
|
| 6148 | - case TTableGridLines::Horizontal : $writer->addAttribute('rules','rows'); break; |
|
| 6149 | - case TTableGridLines::Vertical : $writer->addAttribute('rules','cols'); break; |
|
| 6150 | - case TTableGridLines::Both : $writer->addAttribute('rules','all'); break; |
|
| 6136 | + if (($url = trim($this->getBackImageUrl())) !== '') |
|
| 6137 | + $writer->addStyleAttribute('background-image', 'url(' . $url . ')'); |
|
| 6138 | + if (($horizontalAlign = $this->getHorizontalAlign()) !== THorizontalAlign::NotSet) |
|
| 6139 | + $writer->addStyleAttribute('text-align', strtolower($horizontalAlign)); |
|
| 6140 | + if (($cellPadding = $this->getCellPadding()) >= 0) |
|
| 6141 | + $writer->addAttribute('cellpadding', "$cellPadding"); |
|
| 6142 | + if (($cellSpacing = $this->getCellSpacing()) >= 0) |
|
| 6143 | + $writer->addAttribute('cellspacing', "$cellSpacing"); |
|
| 6144 | + if ($this->getBorderCollapse()) |
|
| 6145 | + $writer->addStyleAttribute('border-collapse', 'collapse'); |
|
| 6146 | + switch ($this->getGridLines()) |
|
| 6147 | + { |
|
| 6148 | + case TTableGridLines::Horizontal : $writer->addAttribute('rules', 'rows'); break; |
|
| 6149 | + case TTableGridLines::Vertical : $writer->addAttribute('rules', 'cols'); break; |
|
| 6150 | + case TTableGridLines::Both : $writer->addAttribute('rules', 'all'); break; |
|
| 6151 | 6151 | } |
| 6152 | 6152 | parent::addAttributesToRender($writer); |
| 6153 | 6153 | } |
| 6154 | 6154 | public function getBackImageUrl() |
| 6155 | 6155 | { |
| 6156 | - return $this->_backImageUrl===null?'':$this->_backImageUrl; |
|
| 6156 | + return $this->_backImageUrl === null ? '' : $this->_backImageUrl; |
|
| 6157 | 6157 | } |
| 6158 | 6158 | public function setBackImageUrl($value) |
| 6159 | 6159 | { |
| 6160 | - $this->_backImageUrl=$value; |
|
| 6160 | + $this->_backImageUrl = $value; |
|
| 6161 | 6161 | } |
| 6162 | 6162 | public function getHorizontalAlign() |
| 6163 | 6163 | { |
| 6164 | - return $this->_horizontalAlign===null?THorizontalAlign::NotSet:$this->_horizontalAlign; |
|
| 6164 | + return $this->_horizontalAlign === null ? THorizontalAlign::NotSet : $this->_horizontalAlign; |
|
| 6165 | 6165 | } |
| 6166 | 6166 | public function setHorizontalAlign($value) |
| 6167 | 6167 | { |
| 6168 | - $this->_horizontalAlign=TPropertyValue::ensureEnum($value,'THorizontalAlign'); |
|
| 6168 | + $this->_horizontalAlign = TPropertyValue::ensureEnum($value, 'THorizontalAlign'); |
|
| 6169 | 6169 | } |
| 6170 | 6170 | public function getCellPadding() |
| 6171 | 6171 | { |
| 6172 | - return $this->_cellPadding===null?-1:$this->_cellPadding; |
|
| 6172 | + return $this->_cellPadding === null ?-1 : $this->_cellPadding; |
|
| 6173 | 6173 | } |
| 6174 | 6174 | public function setCellPadding($value) |
| 6175 | 6175 | { |
| 6176 | - if(($this->_cellPadding=TPropertyValue::ensureInteger($value))<-1) |
|
| 6176 | + if (($this->_cellPadding = TPropertyValue::ensureInteger($value)) < -1) |
|
| 6177 | 6177 | throw new TInvalidDataValueException('tablestyle_cellpadding_invalid'); |
| 6178 | 6178 | } |
| 6179 | 6179 | public function getCellSpacing() |
| 6180 | 6180 | { |
| 6181 | - return $this->_cellSpacing===null?-1:$this->_cellSpacing; |
|
| 6181 | + return $this->_cellSpacing === null ?-1 : $this->_cellSpacing; |
|
| 6182 | 6182 | } |
| 6183 | 6183 | public function setCellSpacing($value) |
| 6184 | 6184 | { |
| 6185 | - if(($this->_cellSpacing=TPropertyValue::ensureInteger($value))<-1) |
|
| 6185 | + if (($this->_cellSpacing = TPropertyValue::ensureInteger($value)) < -1) |
|
| 6186 | 6186 | throw new TInvalidDataValueException('tablestyle_cellspacing_invalid'); |
| 6187 | 6187 | } |
| 6188 | 6188 | public function getGridLines() |
| 6189 | 6189 | { |
| 6190 | - return $this->_gridLines===null?TTableGridLines::None:$this->_gridLines; |
|
| 6190 | + return $this->_gridLines === null ? TTableGridLines::None : $this->_gridLines; |
|
| 6191 | 6191 | } |
| 6192 | 6192 | public function setGridLines($value) |
| 6193 | 6193 | { |
| 6194 | - $this->_gridLines=TPropertyValue::ensureEnum($value,'TTableGridLines'); |
|
| 6194 | + $this->_gridLines = TPropertyValue::ensureEnum($value, 'TTableGridLines'); |
|
| 6195 | 6195 | } |
| 6196 | 6196 | public function getBorderCollapse() |
| 6197 | 6197 | { |
| 6198 | - return $this->_borderCollapse===null?false:$this->_borderCollapse; |
|
| 6198 | + return $this->_borderCollapse === null ? false : $this->_borderCollapse; |
|
| 6199 | 6199 | } |
| 6200 | 6200 | public function setBorderCollapse($value) |
| 6201 | 6201 | { |
| 6202 | - $this->_borderCollapse=TPropertyValue::ensureBoolean($value); |
|
| 6202 | + $this->_borderCollapse = TPropertyValue::ensureBoolean($value); |
|
| 6203 | 6203 | } |
| 6204 | 6204 | } |
| 6205 | 6205 | class TTableItemStyle extends TStyle |
| 6206 | 6206 | { |
| 6207 | - private $_horizontalAlign=null; |
|
| 6208 | - private $_verticalAlign=null; |
|
| 6209 | - private $_wrap=null; |
|
| 6207 | + private $_horizontalAlign = null; |
|
| 6208 | + private $_verticalAlign = null; |
|
| 6209 | + private $_wrap = null; |
|
| 6210 | 6210 | protected function __getZappableSleepProps(&$exprops) |
| 6211 | 6211 | { |
| 6212 | 6212 | parent::__getZappableSleepProps($exprops); |
| 6213 | - if ($this->_horizontalAlign===null) |
|
| 6213 | + if ($this->_horizontalAlign === null) |
|
| 6214 | 6214 | $exprops[] = "\0TTableItemStyle\0_horizontalAlign"; |
| 6215 | - if ($this->_verticalAlign===null) |
|
| 6215 | + if ($this->_verticalAlign === null) |
|
| 6216 | 6216 | $exprops[] = "\0TTableItemStyle\0_verticalAlign"; |
| 6217 | - if ($this->_wrap===null) |
|
| 6217 | + if ($this->_wrap === null) |
|
| 6218 | 6218 | $exprops[] = "\0TTableItemStyle\0_wrap"; |
| 6219 | 6219 | } |
| 6220 | 6220 | public function reset() |
| 6221 | 6221 | { |
| 6222 | 6222 | parent::reset(); |
| 6223 | - $this->_verticalAlign=null; |
|
| 6224 | - $this->_horizontalAlign=null; |
|
| 6225 | - $this->_wrap=null; |
|
| 6223 | + $this->_verticalAlign = null; |
|
| 6224 | + $this->_horizontalAlign = null; |
|
| 6225 | + $this->_wrap = null; |
|
| 6226 | 6226 | } |
| 6227 | 6227 | public function copyFrom($style) |
| 6228 | 6228 | { |
| 6229 | 6229 | parent::copyFrom($style); |
| 6230 | - if($style instanceof TTableItemStyle) |
|
| 6230 | + if ($style instanceof TTableItemStyle) |
|
| 6231 | 6231 | { |
| 6232 | - if($this->_verticalAlign===null && $style->_verticalAlign!==null) |
|
| 6233 | - $this->_verticalAlign=$style->_verticalAlign; |
|
| 6234 | - if($this->_horizontalAlign===null && $style->_horizontalAlign!==null) |
|
| 6235 | - $this->_horizontalAlign=$style->_horizontalAlign; |
|
| 6236 | - if($this->_wrap===null && $style->_wrap!==null) |
|
| 6237 | - $this->_wrap=$style->_wrap; |
|
| 6232 | + if ($this->_verticalAlign === null && $style->_verticalAlign !== null) |
|
| 6233 | + $this->_verticalAlign = $style->_verticalAlign; |
|
| 6234 | + if ($this->_horizontalAlign === null && $style->_horizontalAlign !== null) |
|
| 6235 | + $this->_horizontalAlign = $style->_horizontalAlign; |
|
| 6236 | + if ($this->_wrap === null && $style->_wrap !== null) |
|
| 6237 | + $this->_wrap = $style->_wrap; |
|
| 6238 | 6238 | } |
| 6239 | 6239 | } |
| 6240 | 6240 | public function mergeWith($style) |
| 6241 | 6241 | { |
| 6242 | 6242 | parent::mergeWith($style); |
| 6243 | - if($style instanceof TTableItemStyle) |
|
| 6243 | + if ($style instanceof TTableItemStyle) |
|
| 6244 | 6244 | { |
| 6245 | - if($style->_verticalAlign!==null) |
|
| 6246 | - $this->_verticalAlign=$style->_verticalAlign; |
|
| 6247 | - if($style->_horizontalAlign!==null) |
|
| 6248 | - $this->_horizontalAlign=$style->_horizontalAlign; |
|
| 6249 | - if($style->_wrap!==null) |
|
| 6250 | - $this->_wrap=$style->_wrap; |
|
| 6245 | + if ($style->_verticalAlign !== null) |
|
| 6246 | + $this->_verticalAlign = $style->_verticalAlign; |
|
| 6247 | + if ($style->_horizontalAlign !== null) |
|
| 6248 | + $this->_horizontalAlign = $style->_horizontalAlign; |
|
| 6249 | + if ($style->_wrap !== null) |
|
| 6250 | + $this->_wrap = $style->_wrap; |
|
| 6251 | 6251 | } |
| 6252 | 6252 | } |
| 6253 | 6253 | public function addAttributesToRender($writer) |
| 6254 | 6254 | { |
| 6255 | - if(!$this->getWrap()) |
|
| 6256 | - $writer->addStyleAttribute('white-space','nowrap'); |
|
| 6257 | - if(($horizontalAlign=$this->getHorizontalAlign())!==THorizontalAlign::NotSet) |
|
| 6258 | - $writer->addAttribute('align',strtolower($horizontalAlign)); |
|
| 6259 | - if(($verticalAlign=$this->getVerticalAlign())!==TVerticalAlign::NotSet) |
|
| 6260 | - $writer->addAttribute('valign',strtolower($verticalAlign)); |
|
| 6255 | + if (!$this->getWrap()) |
|
| 6256 | + $writer->addStyleAttribute('white-space', 'nowrap'); |
|
| 6257 | + if (($horizontalAlign = $this->getHorizontalAlign()) !== THorizontalAlign::NotSet) |
|
| 6258 | + $writer->addAttribute('align', strtolower($horizontalAlign)); |
|
| 6259 | + if (($verticalAlign = $this->getVerticalAlign()) !== TVerticalAlign::NotSet) |
|
| 6260 | + $writer->addAttribute('valign', strtolower($verticalAlign)); |
|
| 6261 | 6261 | parent::addAttributesToRender($writer); |
| 6262 | 6262 | } |
| 6263 | 6263 | public function getHorizontalAlign() |
| 6264 | 6264 | { |
| 6265 | - return $this->_horizontalAlign===null?THorizontalAlign::NotSet:$this->_horizontalAlign; |
|
| 6265 | + return $this->_horizontalAlign === null ? THorizontalAlign::NotSet : $this->_horizontalAlign; |
|
| 6266 | 6266 | } |
| 6267 | 6267 | public function setHorizontalAlign($value) |
| 6268 | 6268 | { |
| 6269 | - $this->_horizontalAlign=TPropertyValue::ensureEnum($value,'THorizontalAlign'); |
|
| 6269 | + $this->_horizontalAlign = TPropertyValue::ensureEnum($value, 'THorizontalAlign'); |
|
| 6270 | 6270 | } |
| 6271 | 6271 | public function getVerticalAlign() |
| 6272 | 6272 | { |
| 6273 | - return $this->_verticalAlign===null?TVerticalAlign::NotSet:$this->_verticalAlign; |
|
| 6273 | + return $this->_verticalAlign === null ? TVerticalAlign::NotSet : $this->_verticalAlign; |
|
| 6274 | 6274 | } |
| 6275 | 6275 | public function setVerticalAlign($value) |
| 6276 | 6276 | { |
| 6277 | - $this->_verticalAlign=TPropertyValue::ensureEnum($value,'TVerticalAlign'); |
|
| 6277 | + $this->_verticalAlign = TPropertyValue::ensureEnum($value, 'TVerticalAlign'); |
|
| 6278 | 6278 | } |
| 6279 | 6279 | public function getWrap() |
| 6280 | 6280 | { |
| 6281 | - return $this->_wrap===null?true:$this->_wrap; |
|
| 6281 | + return $this->_wrap === null ? true : $this->_wrap; |
|
| 6282 | 6282 | } |
| 6283 | 6283 | public function setWrap($value) |
| 6284 | 6284 | { |
| 6285 | - $this->_wrap=TPropertyValue::ensureBoolean($value); |
|
| 6285 | + $this->_wrap = TPropertyValue::ensureBoolean($value); |
|
| 6286 | 6286 | } |
| 6287 | 6287 | } |
| 6288 | 6288 | class THorizontalAlign extends TEnumerable |
| 6289 | 6289 | { |
| 6290 | - const NotSet='NotSet'; |
|
| 6291 | - const Left='Left'; |
|
| 6292 | - const Right='Right'; |
|
| 6293 | - const Center='Center'; |
|
| 6294 | - const Justify='Justify'; |
|
| 6290 | + const NotSet = 'NotSet'; |
|
| 6291 | + const Left = 'Left'; |
|
| 6292 | + const Right = 'Right'; |
|
| 6293 | + const Center = 'Center'; |
|
| 6294 | + const Justify = 'Justify'; |
|
| 6295 | 6295 | } |
| 6296 | 6296 | class TVerticalAlign extends TEnumerable |
| 6297 | 6297 | { |
| 6298 | - const NotSet='NotSet'; |
|
| 6299 | - const Top='Top'; |
|
| 6300 | - const Bottom='Bottom'; |
|
| 6301 | - const Middle='Middle'; |
|
| 6298 | + const NotSet = 'NotSet'; |
|
| 6299 | + const Top = 'Top'; |
|
| 6300 | + const Bottom = 'Bottom'; |
|
| 6301 | + const Middle = 'Middle'; |
|
| 6302 | 6302 | } |
| 6303 | 6303 | class TTableGridLines extends TEnumerable |
| 6304 | 6304 | { |
| 6305 | - const None='None'; |
|
| 6306 | - const Horizontal='Horizontal'; |
|
| 6307 | - const Vertical='Vertical'; |
|
| 6308 | - const Both='Both'; |
|
| 6305 | + const None = 'None'; |
|
| 6306 | + const Horizontal = 'Horizontal'; |
|
| 6307 | + const Vertical = 'Vertical'; |
|
| 6308 | + const Both = 'Both'; |
|
| 6309 | 6309 | } |
| 6310 | 6310 | class TWebControlAdapter extends TControlAdapter |
| 6311 | 6311 | { |
@@ -6333,7 +6333,7 @@ discard block |
||
| 6333 | 6333 | private $_usestate = false; |
| 6334 | 6334 | private $_control; |
| 6335 | 6335 | private $_outercontrol; |
| 6336 | - private $_addedTemplateDecoration=false; |
|
| 6336 | + private $_addedTemplateDecoration = false; |
|
| 6337 | 6337 | private $_pretagtext = ''; |
| 6338 | 6338 | private $_precontentstext = ''; |
| 6339 | 6339 | private $_postcontentstext = ''; |
@@ -6358,97 +6358,97 @@ discard block |
||
| 6358 | 6358 | return $this->_pretagtext; |
| 6359 | 6359 | } |
| 6360 | 6360 | public function setPreTagText($value) { |
| 6361 | - if(!$this->_internalonly && !$this->_control->getIsSkinApplied()) |
|
| 6361 | + if (!$this->_internalonly && !$this->_control->getIsSkinApplied()) |
|
| 6362 | 6362 | $this->_pretagtext = TPropertyValue::ensureString($value); |
| 6363 | 6363 | } |
| 6364 | 6364 | public function getPreContentsText() { |
| 6365 | 6365 | return $this->_precontentstext; |
| 6366 | 6366 | } |
| 6367 | 6367 | public function setPreContentsText($value) { |
| 6368 | - if(!$this->_control->getIsSkinApplied()) |
|
| 6368 | + if (!$this->_control->getIsSkinApplied()) |
|
| 6369 | 6369 | $this->_precontentstext = TPropertyValue::ensureString($value); |
| 6370 | 6370 | } |
| 6371 | 6371 | public function getPostContentsText() { |
| 6372 | 6372 | return $this->_postcontentstext; |
| 6373 | 6373 | } |
| 6374 | 6374 | public function setPostContentsText($value) { |
| 6375 | - if(!$this->_control->getIsSkinApplied()) |
|
| 6375 | + if (!$this->_control->getIsSkinApplied()) |
|
| 6376 | 6376 | $this->_postcontentstext = TPropertyValue::ensureString($value); |
| 6377 | 6377 | } |
| 6378 | 6378 | public function getPostTagText() { |
| 6379 | 6379 | return $this->_posttagtext; |
| 6380 | 6380 | } |
| 6381 | 6381 | public function setPostTagText($value) { |
| 6382 | - if(!$this->_internalonly && !$this->_control->getIsSkinApplied()) |
|
| 6382 | + if (!$this->_internalonly && !$this->_control->getIsSkinApplied()) |
|
| 6383 | 6383 | $this->_posttagtext = TPropertyValue::ensureString($value); |
| 6384 | 6384 | } |
| 6385 | 6385 | public function getPreTagTemplate() { |
| 6386 | 6386 | return $this->_pretagtemplate; |
| 6387 | 6387 | } |
| 6388 | 6388 | public function setPreTagTemplate($value) { |
| 6389 | - if(!$this->_internalonly && !$this->_control->getIsSkinApplied()) |
|
| 6389 | + if (!$this->_internalonly && !$this->_control->getIsSkinApplied()) |
|
| 6390 | 6390 | $this->_pretagtemplate = $value; |
| 6391 | 6391 | } |
| 6392 | 6392 | public function getPreContentsTemplate() { |
| 6393 | 6393 | return $this->_precontentstemplate; |
| 6394 | 6394 | } |
| 6395 | 6395 | public function setPreContentsTemplate($value) { |
| 6396 | - if(!$this->_control->getIsSkinApplied()) |
|
| 6396 | + if (!$this->_control->getIsSkinApplied()) |
|
| 6397 | 6397 | $this->_precontentstemplate = $value; |
| 6398 | 6398 | } |
| 6399 | 6399 | public function getPostContentsTemplate() { |
| 6400 | 6400 | return $this->_postcontentstemplate; |
| 6401 | 6401 | } |
| 6402 | 6402 | public function setPostContentsTemplate($value) { |
| 6403 | - if(!$this->_control->getIsSkinApplied()) |
|
| 6403 | + if (!$this->_control->getIsSkinApplied()) |
|
| 6404 | 6404 | $this->_postcontentstemplate = $value; |
| 6405 | 6405 | } |
| 6406 | 6406 | public function getPostTagTemplate() { |
| 6407 | 6407 | return $this->_posttagtemplate; |
| 6408 | 6408 | } |
| 6409 | 6409 | public function setPostTagTemplate($value) { |
| 6410 | - if(!$this->_internalonly && !$this->_control->getIsSkinApplied()) |
|
| 6410 | + if (!$this->_internalonly && !$this->_control->getIsSkinApplied()) |
|
| 6411 | 6411 | $this->_posttagtemplate = $value; |
| 6412 | 6412 | } |
| 6413 | 6413 | public function instantiate($outercontrol = null) { |
| 6414 | - if($this->getPreTagTemplate() || $this->getPreContentsTemplate() || |
|
| 6414 | + if ($this->getPreTagTemplate() || $this->getPreContentsTemplate() || |
|
| 6415 | 6415 | $this->getPostContentsTemplate() || $this->getPostTagTemplate()) { |
| 6416 | 6416 | $this->_outercontrol = $outercontrol; |
| 6417 | - if($this->getUseState()) |
|
| 6417 | + if ($this->getUseState()) |
|
| 6418 | 6418 | $this->ensureTemplateDecoration(); |
| 6419 | 6419 | else |
| 6420 | 6420 | $this->_control->getPage()->onSaveStateComplete[] = array($this, 'ensureTemplateDecoration'); |
| 6421 | 6421 | } |
| 6422 | 6422 | } |
| 6423 | - public function ensureTemplateDecoration($sender=null, $param=null) { |
|
| 6423 | + public function ensureTemplateDecoration($sender = null, $param = null) { |
|
| 6424 | 6424 | $control = $this->_control; |
| 6425 | 6425 | $outercontrol = $this->_outercontrol; |
| 6426 | - if($outercontrol === null) |
|
| 6426 | + if ($outercontrol === null) |
|
| 6427 | 6427 | $outercontrol = $control; |
| 6428 | - if($this->_addedTemplateDecoration) |
|
| 6428 | + if ($this->_addedTemplateDecoration) |
|
| 6429 | 6429 | return $this->_addedTemplateDecoration; |
| 6430 | 6430 | $this->_addedTemplateDecoration = true; |
| 6431 | - if($this->getPreContentsTemplate()) |
|
| 6431 | + if ($this->getPreContentsTemplate()) |
|
| 6432 | 6432 | { |
| 6433 | 6433 | $precontents = Prado::createComponent('TCompositeControl'); |
| 6434 | 6434 | $this->getPreContentsTemplate()->instantiateIn($precontents); |
| 6435 | 6435 | $control->getControls()->insertAt(0, $precontents); |
| 6436 | 6436 | } |
| 6437 | - if($this->getPostContentsTemplate()) |
|
| 6437 | + if ($this->getPostContentsTemplate()) |
|
| 6438 | 6438 | { |
| 6439 | 6439 | $postcontents = Prado::createComponent('TCompositeControl'); |
| 6440 | 6440 | $this->getPostContentsTemplate()->instantiateIn($postcontents); |
| 6441 | 6441 | $control->getControls()->add($postcontents); |
| 6442 | 6442 | } |
| 6443 | - if(!$outercontrol->getParent()) |
|
| 6443 | + if (!$outercontrol->getParent()) |
|
| 6444 | 6444 | return $this->_addedTemplateDecoration; |
| 6445 | - if($this->getPreTagTemplate()) |
|
| 6445 | + if ($this->getPreTagTemplate()) |
|
| 6446 | 6446 | { |
| 6447 | 6447 | $pretag = Prado::createComponent('TCompositeControl'); |
| 6448 | 6448 | $this->getPreTagTemplate()->instantiateIn($pretag); |
| 6449 | 6449 | $outercontrol->getParent()->getControls()->insertBefore($outercontrol, $pretag); |
| 6450 | 6450 | } |
| 6451 | - if($this->getPostTagTemplate()) |
|
| 6451 | + if ($this->getPostTagTemplate()) |
|
| 6452 | 6452 | { |
| 6453 | 6453 | $posttag = Prado::createComponent('TCompositeControl'); |
| 6454 | 6454 | $this->getPostTagTemplate()->instantiateIn($posttag); |
@@ -6471,7 +6471,7 @@ discard block |
||
| 6471 | 6471 | } |
| 6472 | 6472 | class TWebControl extends TControl implements IStyleable |
| 6473 | 6473 | { |
| 6474 | - private $_ensureid=false; |
|
| 6474 | + private $_ensureid = false; |
|
| 6475 | 6475 | protected $_decorator; |
| 6476 | 6476 | public function setEnsureId($value) |
| 6477 | 6477 | { |
@@ -6481,9 +6481,9 @@ discard block |
||
| 6481 | 6481 | { |
| 6482 | 6482 | return $this->_ensureid; |
| 6483 | 6483 | } |
| 6484 | - public function getDecorator($create=true) |
|
| 6484 | + public function getDecorator($create = true) |
|
| 6485 | 6485 | { |
| 6486 | - if($create && !$this->_decorator) |
|
| 6486 | + if ($create && !$this->_decorator) |
|
| 6487 | 6487 | $this->_decorator = Prado::createComponent('TWebControlDecorator', $this); |
| 6488 | 6488 | return $this->_decorator; |
| 6489 | 6489 | } |
@@ -6492,24 +6492,24 @@ discard block |
||
| 6492 | 6492 | $this->setAccessKey($control->getAccessKey()); |
| 6493 | 6493 | $this->setToolTip($control->getToolTip()); |
| 6494 | 6494 | $this->setTabIndex($control->getTabIndex()); |
| 6495 | - if(!$control->getEnabled()) |
|
| 6495 | + if (!$control->getEnabled()) |
|
| 6496 | 6496 | $this->setEnabled(false); |
| 6497 | - if($control->getHasAttributes()) |
|
| 6497 | + if ($control->getHasAttributes()) |
|
| 6498 | 6498 | $this->getAttributes()->copyFrom($control->getAttributes()); |
| 6499 | 6499 | } |
| 6500 | 6500 | public function getAccessKey() |
| 6501 | 6501 | { |
| 6502 | - return $this->getViewState('AccessKey',''); |
|
| 6502 | + return $this->getViewState('AccessKey', ''); |
|
| 6503 | 6503 | } |
| 6504 | 6504 | public function setAccessKey($value) |
| 6505 | 6505 | { |
| 6506 | - if(strlen($value)>1) |
|
| 6507 | - throw new TInvalidDataValueException('webcontrol_accesskey_invalid',get_class($this),$value); |
|
| 6508 | - $this->setViewState('AccessKey',$value,''); |
|
| 6506 | + if (strlen($value) > 1) |
|
| 6507 | + throw new TInvalidDataValueException('webcontrol_accesskey_invalid', get_class($this), $value); |
|
| 6508 | + $this->setViewState('AccessKey', $value, ''); |
|
| 6509 | 6509 | } |
| 6510 | 6510 | public function getBackColor() |
| 6511 | 6511 | { |
| 6512 | - if($style=$this->getViewState('Style',null)) |
|
| 6512 | + if ($style = $this->getViewState('Style', null)) |
|
| 6513 | 6513 | return $style->getBackColor(); |
| 6514 | 6514 | else |
| 6515 | 6515 | return ''; |
@@ -6520,7 +6520,7 @@ discard block |
||
| 6520 | 6520 | } |
| 6521 | 6521 | public function getBorderColor() |
| 6522 | 6522 | { |
| 6523 | - if($style=$this->getViewState('Style',null)) |
|
| 6523 | + if ($style = $this->getViewState('Style', null)) |
|
| 6524 | 6524 | return $style->getBorderColor(); |
| 6525 | 6525 | else |
| 6526 | 6526 | return ''; |
@@ -6531,7 +6531,7 @@ discard block |
||
| 6531 | 6531 | } |
| 6532 | 6532 | public function getBorderStyle() |
| 6533 | 6533 | { |
| 6534 | - if($style=$this->getViewState('Style',null)) |
|
| 6534 | + if ($style = $this->getViewState('Style', null)) |
|
| 6535 | 6535 | return $style->getBorderStyle(); |
| 6536 | 6536 | else |
| 6537 | 6537 | return ''; |
@@ -6542,7 +6542,7 @@ discard block |
||
| 6542 | 6542 | } |
| 6543 | 6543 | public function getBorderWidth() |
| 6544 | 6544 | { |
| 6545 | - if($style=$this->getViewState('Style',null)) |
|
| 6545 | + if ($style = $this->getViewState('Style', null)) |
|
| 6546 | 6546 | return $style->getBorderWidth(); |
| 6547 | 6547 | else |
| 6548 | 6548 | return ''; |
@@ -6557,7 +6557,7 @@ discard block |
||
| 6557 | 6557 | } |
| 6558 | 6558 | public function getForeColor() |
| 6559 | 6559 | { |
| 6560 | - if($style=$this->getViewState('Style',null)) |
|
| 6560 | + if ($style = $this->getViewState('Style', null)) |
|
| 6561 | 6561 | return $style->getForeColor(); |
| 6562 | 6562 | else |
| 6563 | 6563 | return ''; |
@@ -6568,7 +6568,7 @@ discard block |
||
| 6568 | 6568 | } |
| 6569 | 6569 | public function getHeight() |
| 6570 | 6570 | { |
| 6571 | - if($style=$this->getViewState('Style',null)) |
|
| 6571 | + if ($style = $this->getViewState('Style', null)) |
|
| 6572 | 6572 | return $style->getHeight(); |
| 6573 | 6573 | else |
| 6574 | 6574 | return ''; |
@@ -6587,7 +6587,7 @@ discard block |
||
| 6587 | 6587 | } |
| 6588 | 6588 | public function getCssClass() |
| 6589 | 6589 | { |
| 6590 | - if($style=$this->getViewState('Style',null)) |
|
| 6590 | + if ($style = $this->getViewState('Style', null)) |
|
| 6591 | 6591 | return $style->getCssClass(); |
| 6592 | 6592 | else |
| 6593 | 6593 | return ''; |
@@ -6598,7 +6598,7 @@ discard block |
||
| 6598 | 6598 | } |
| 6599 | 6599 | public function getHasStyle() |
| 6600 | 6600 | { |
| 6601 | - return $this->getViewState('Style',null)!==null; |
|
| 6601 | + return $this->getViewState('Style', null) !== null; |
|
| 6602 | 6602 | } |
| 6603 | 6603 | protected function createStyle() |
| 6604 | 6604 | { |
@@ -6606,21 +6606,21 @@ discard block |
||
| 6606 | 6606 | } |
| 6607 | 6607 | public function getStyle() |
| 6608 | 6608 | { |
| 6609 | - if($style=$this->getViewState('Style',null)) |
|
| 6609 | + if ($style = $this->getViewState('Style', null)) |
|
| 6610 | 6610 | return $style; |
| 6611 | 6611 | else |
| 6612 | 6612 | { |
| 6613 | - $style=$this->createStyle(); |
|
| 6614 | - $this->setViewState('Style',$style,null); |
|
| 6613 | + $style = $this->createStyle(); |
|
| 6614 | + $this->setViewState('Style', $style, null); |
|
| 6615 | 6615 | return $style; |
| 6616 | 6616 | } |
| 6617 | 6617 | } |
| 6618 | 6618 | public function setStyle($value) |
| 6619 | 6619 | { |
| 6620 | - if(is_string($value)) |
|
| 6620 | + if (is_string($value)) |
|
| 6621 | 6621 | $this->getStyle()->setCustomStyle($value); |
| 6622 | 6622 | else |
| 6623 | - throw new TInvalidDataValueException('webcontrol_style_invalid',get_class($this)); |
|
| 6623 | + throw new TInvalidDataValueException('webcontrol_style_invalid', get_class($this)); |
|
| 6624 | 6624 | } |
| 6625 | 6625 | public function clearStyle() |
| 6626 | 6626 | { |
@@ -6628,11 +6628,11 @@ discard block |
||
| 6628 | 6628 | } |
| 6629 | 6629 | public function getTabIndex() |
| 6630 | 6630 | { |
| 6631 | - return $this->getViewState('TabIndex',0); |
|
| 6631 | + return $this->getViewState('TabIndex', 0); |
|
| 6632 | 6632 | } |
| 6633 | 6633 | public function setTabIndex($value) |
| 6634 | 6634 | { |
| 6635 | - $this->setViewState('TabIndex',TPropertyValue::ensureInteger($value),0); |
|
| 6635 | + $this->setViewState('TabIndex', TPropertyValue::ensureInteger($value), 0); |
|
| 6636 | 6636 | } |
| 6637 | 6637 | protected function getTagName() |
| 6638 | 6638 | { |
@@ -6640,15 +6640,15 @@ discard block |
||
| 6640 | 6640 | } |
| 6641 | 6641 | public function getToolTip() |
| 6642 | 6642 | { |
| 6643 | - return $this->getViewState('ToolTip',''); |
|
| 6643 | + return $this->getViewState('ToolTip', ''); |
|
| 6644 | 6644 | } |
| 6645 | 6645 | public function setToolTip($value) |
| 6646 | 6646 | { |
| 6647 | - $this->setViewState('ToolTip',$value,''); |
|
| 6647 | + $this->setViewState('ToolTip', $value, ''); |
|
| 6648 | 6648 | } |
| 6649 | 6649 | public function getWidth() |
| 6650 | 6650 | { |
| 6651 | - if($style=$this->getViewState('Style',null)) |
|
| 6651 | + if ($style = $this->getViewState('Style', null)) |
|
| 6652 | 6652 | return $style->getWidth(); |
| 6653 | 6653 | else |
| 6654 | 6654 | return ''; |
@@ -6658,28 +6658,28 @@ discard block |
||
| 6658 | 6658 | $this->getStyle()->setWidth($value); |
| 6659 | 6659 | } |
| 6660 | 6660 | public function onPreRender($param) { |
| 6661 | - if($decorator = $this->getDecorator(false)) |
|
| 6661 | + if ($decorator = $this->getDecorator(false)) |
|
| 6662 | 6662 | $decorator->instantiate(); |
| 6663 | 6663 | parent::onPreRender($param); |
| 6664 | 6664 | } |
| 6665 | 6665 | protected function addAttributesToRender($writer) |
| 6666 | 6666 | { |
| 6667 | - if($this->getID()!=='' || $this->getEnsureId()) |
|
| 6668 | - $writer->addAttribute('id',$this->getClientID()); |
|
| 6669 | - if(($accessKey=$this->getAccessKey())!=='') |
|
| 6670 | - $writer->addAttribute('accesskey',$accessKey); |
|
| 6671 | - if(!$this->getEnabled()) |
|
| 6672 | - $writer->addAttribute('disabled','disabled'); |
|
| 6673 | - if(($tabIndex=$this->getTabIndex())>0) |
|
| 6674 | - $writer->addAttribute('tabindex',"$tabIndex"); |
|
| 6675 | - if(($toolTip=$this->getToolTip())!=='') |
|
| 6676 | - $writer->addAttribute('title',$toolTip); |
|
| 6677 | - if($style=$this->getViewState('Style',null)) |
|
| 6667 | + if ($this->getID() !== '' || $this->getEnsureId()) |
|
| 6668 | + $writer->addAttribute('id', $this->getClientID()); |
|
| 6669 | + if (($accessKey = $this->getAccessKey()) !== '') |
|
| 6670 | + $writer->addAttribute('accesskey', $accessKey); |
|
| 6671 | + if (!$this->getEnabled()) |
|
| 6672 | + $writer->addAttribute('disabled', 'disabled'); |
|
| 6673 | + if (($tabIndex = $this->getTabIndex()) > 0) |
|
| 6674 | + $writer->addAttribute('tabindex', "$tabIndex"); |
|
| 6675 | + if (($toolTip = $this->getToolTip()) !== '') |
|
| 6676 | + $writer->addAttribute('title', $toolTip); |
|
| 6677 | + if ($style = $this->getViewState('Style', null)) |
|
| 6678 | 6678 | $style->addAttributesToRender($writer); |
| 6679 | - if($this->getHasAttributes()) |
|
| 6679 | + if ($this->getHasAttributes()) |
|
| 6680 | 6680 | { |
| 6681 | - foreach($this->getAttributes() as $name=>$value) |
|
| 6682 | - $writer->addAttribute($name,$value); |
|
| 6681 | + foreach ($this->getAttributes() as $name=>$value) |
|
| 6682 | + $writer->addAttribute($name, $value); |
|
| 6683 | 6683 | } |
| 6684 | 6684 | } |
| 6685 | 6685 | public function render($writer) |
@@ -6690,7 +6690,7 @@ discard block |
||
| 6690 | 6690 | } |
| 6691 | 6691 | public function renderBeginTag($writer) |
| 6692 | 6692 | { |
| 6693 | - if($decorator = $this->getDecorator(false)) { |
|
| 6693 | + if ($decorator = $this->getDecorator(false)) { |
|
| 6694 | 6694 | $decorator->renderPreTagText($writer); |
| 6695 | 6695 | $this->addAttributesToRender($writer); |
| 6696 | 6696 | $writer->renderBeginTag($this->getTagName()); |
@@ -6706,7 +6706,7 @@ discard block |
||
| 6706 | 6706 | } |
| 6707 | 6707 | public function renderEndTag($writer) |
| 6708 | 6708 | { |
| 6709 | - if($decorator = $this->getDecorator(false)) { |
|
| 6709 | + if ($decorator = $this->getDecorator(false)) { |
|
| 6710 | 6710 | $decorator->renderPostContentsText($writer); |
| 6711 | 6711 | $writer->renderEndTag(); |
| 6712 | 6712 | $decorator->renderPostTagText($writer); |
@@ -6716,7 +6716,7 @@ discard block |
||
| 6716 | 6716 | } |
| 6717 | 6717 | class TCompositeControl extends TControl implements INamingContainer |
| 6718 | 6718 | { |
| 6719 | - protected function initRecursive($namingContainer=null) |
|
| 6719 | + protected function initRecursive($namingContainer = null) |
|
| 6720 | 6720 | { |
| 6721 | 6721 | $this->ensureChildControls(); |
| 6722 | 6722 | parent::initRecursive($namingContainer); |
@@ -6724,20 +6724,20 @@ discard block |
||
| 6724 | 6724 | } |
| 6725 | 6725 | class TTemplateControl extends TCompositeControl |
| 6726 | 6726 | { |
| 6727 | - const EXT_TEMPLATE='.tpl'; |
|
| 6728 | - private static $_template=array(); |
|
| 6729 | - private $_localTemplate=null; |
|
| 6730 | - private $_master=null; |
|
| 6731 | - private $_masterClass=''; |
|
| 6732 | - private $_contents=array(); |
|
| 6733 | - private $_placeholders=array(); |
|
| 6727 | + const EXT_TEMPLATE = '.tpl'; |
|
| 6728 | + private static $_template = array(); |
|
| 6729 | + private $_localTemplate = null; |
|
| 6730 | + private $_master = null; |
|
| 6731 | + private $_masterClass = ''; |
|
| 6732 | + private $_contents = array(); |
|
| 6733 | + private $_placeholders = array(); |
|
| 6734 | 6734 | public function getTemplate() |
| 6735 | 6735 | { |
| 6736 | - if($this->_localTemplate===null) |
|
| 6736 | + if ($this->_localTemplate === null) |
|
| 6737 | 6737 | { |
| 6738 | - $class=get_class($this); |
|
| 6739 | - if(!isset(self::$_template[$class])) |
|
| 6740 | - self::$_template[$class]=$this->loadTemplate(); |
|
| 6738 | + $class = get_class($this); |
|
| 6739 | + if (!isset(self::$_template[$class])) |
|
| 6740 | + self::$_template[$class] = $this->loadTemplate(); |
|
| 6741 | 6741 | return self::$_template[$class]; |
| 6742 | 6742 | } |
| 6743 | 6743 | else |
@@ -6745,54 +6745,54 @@ discard block |
||
| 6745 | 6745 | } |
| 6746 | 6746 | public function setTemplate($value) |
| 6747 | 6747 | { |
| 6748 | - $this->_localTemplate=$value; |
|
| 6748 | + $this->_localTemplate = $value; |
|
| 6749 | 6749 | } |
| 6750 | 6750 | public function getIsSourceTemplateControl() |
| 6751 | 6751 | { |
| 6752 | - if(($template=$this->getTemplate())!==null) |
|
| 6752 | + if (($template = $this->getTemplate()) !== null) |
|
| 6753 | 6753 | return $template->getIsSourceTemplate(); |
| 6754 | 6754 | else |
| 6755 | 6755 | return false; |
| 6756 | 6756 | } |
| 6757 | 6757 | public function getTemplateDirectory() |
| 6758 | 6758 | { |
| 6759 | - if(($template=$this->getTemplate())!==null) |
|
| 6759 | + if (($template = $this->getTemplate()) !== null) |
|
| 6760 | 6760 | return $template->getContextPath(); |
| 6761 | 6761 | else |
| 6762 | 6762 | return ''; |
| 6763 | 6763 | } |
| 6764 | 6764 | protected function loadTemplate() |
| 6765 | 6765 | { |
| 6766 | - $template=$this->getService()->getTemplateManager()->getTemplateByClassName(get_class($this)); |
|
| 6766 | + $template = $this->getService()->getTemplateManager()->getTemplateByClassName(get_class($this)); |
|
| 6767 | 6767 | return $template; |
| 6768 | 6768 | } |
| 6769 | 6769 | public function createChildControls() |
| 6770 | 6770 | { |
| 6771 | - if($tpl=$this->getTemplate()) |
|
| 6771 | + if ($tpl = $this->getTemplate()) |
|
| 6772 | 6772 | { |
| 6773 | - foreach($tpl->getDirective() as $name=>$value) |
|
| 6773 | + foreach ($tpl->getDirective() as $name=>$value) |
|
| 6774 | 6774 | { |
| 6775 | - if(is_string($value)) |
|
| 6776 | - $this->setSubProperty($name,$value); |
|
| 6775 | + if (is_string($value)) |
|
| 6776 | + $this->setSubProperty($name, $value); |
|
| 6777 | 6777 | else |
| 6778 | - throw new TConfigurationException('templatecontrol_directive_invalid',get_class($this),$name); |
|
| 6778 | + throw new TConfigurationException('templatecontrol_directive_invalid', get_class($this), $name); |
|
| 6779 | 6779 | } |
| 6780 | 6780 | $tpl->instantiateIn($this); |
| 6781 | 6781 | } |
| 6782 | 6782 | } |
| 6783 | - public function registerContent($id,TContent $object) |
|
| 6783 | + public function registerContent($id, TContent $object) |
|
| 6784 | 6784 | { |
| 6785 | - if(isset($this->_contents[$id])) |
|
| 6786 | - throw new TConfigurationException('templatecontrol_contentid_duplicated',$id); |
|
| 6785 | + if (isset($this->_contents[$id])) |
|
| 6786 | + throw new TConfigurationException('templatecontrol_contentid_duplicated', $id); |
|
| 6787 | 6787 | else |
| 6788 | - $this->_contents[$id]=$object; |
|
| 6788 | + $this->_contents[$id] = $object; |
|
| 6789 | 6789 | } |
| 6790 | - public function registerContentPlaceHolder($id,TContentPlaceHolder $object) |
|
| 6790 | + public function registerContentPlaceHolder($id, TContentPlaceHolder $object) |
|
| 6791 | 6791 | { |
| 6792 | - if(isset($this->_placeholders[$id])) |
|
| 6793 | - throw new TConfigurationException('templatecontrol_placeholderid_duplicated',$id); |
|
| 6792 | + if (isset($this->_placeholders[$id])) |
|
| 6793 | + throw new TConfigurationException('templatecontrol_placeholderid_duplicated', $id); |
|
| 6794 | 6794 | else |
| 6795 | - $this->_placeholders[$id]=$object; |
|
| 6795 | + $this->_placeholders[$id] = $object; |
|
| 6796 | 6796 | } |
| 6797 | 6797 | public function getMasterClass() |
| 6798 | 6798 | { |
@@ -6800,41 +6800,41 @@ discard block |
||
| 6800 | 6800 | } |
| 6801 | 6801 | public function setMasterClass($value) |
| 6802 | 6802 | { |
| 6803 | - $this->_masterClass=$value; |
|
| 6803 | + $this->_masterClass = $value; |
|
| 6804 | 6804 | } |
| 6805 | 6805 | public function getMaster() |
| 6806 | 6806 | { |
| 6807 | 6807 | return $this->_master; |
| 6808 | 6808 | } |
| 6809 | - public function injectContent($id,$content) |
|
| 6809 | + public function injectContent($id, $content) |
|
| 6810 | 6810 | { |
| 6811 | - if(isset($this->_placeholders[$id])) |
|
| 6811 | + if (isset($this->_placeholders[$id])) |
|
| 6812 | 6812 | { |
| 6813 | - $placeholder=$this->_placeholders[$id]; |
|
| 6814 | - $controls=$placeholder->getParent()->getControls(); |
|
| 6815 | - $loc=$controls->remove($placeholder); |
|
| 6816 | - $controls->insertAt($loc,$content); |
|
| 6813 | + $placeholder = $this->_placeholders[$id]; |
|
| 6814 | + $controls = $placeholder->getParent()->getControls(); |
|
| 6815 | + $loc = $controls->remove($placeholder); |
|
| 6816 | + $controls->insertAt($loc, $content); |
|
| 6817 | 6817 | } |
| 6818 | 6818 | else |
| 6819 | - throw new TConfigurationException('templatecontrol_placeholder_inexistent',$id); |
|
| 6819 | + throw new TConfigurationException('templatecontrol_placeholder_inexistent', $id); |
|
| 6820 | 6820 | } |
| 6821 | - protected function initRecursive($namingContainer=null) |
|
| 6821 | + protected function initRecursive($namingContainer = null) |
|
| 6822 | 6822 | { |
| 6823 | 6823 | $this->ensureChildControls(); |
| 6824 | - if($this->_masterClass!=='') |
|
| 6824 | + if ($this->_masterClass !== '') |
|
| 6825 | 6825 | { |
| 6826 | - $master=Prado::createComponent($this->_masterClass); |
|
| 6827 | - if(!($master instanceof TTemplateControl)) |
|
| 6826 | + $master = Prado::createComponent($this->_masterClass); |
|
| 6827 | + if (!($master instanceof TTemplateControl)) |
|
| 6828 | 6828 | throw new TInvalidDataValueException('templatecontrol_mastercontrol_invalid'); |
| 6829 | - $this->_master=$master; |
|
| 6829 | + $this->_master = $master; |
|
| 6830 | 6830 | $this->getControls()->clear(); |
| 6831 | 6831 | $this->getControls()->add($master); |
| 6832 | 6832 | $master->ensureChildControls(); |
| 6833 | - foreach($this->_contents as $id=>$content) |
|
| 6834 | - $master->injectContent($id,$content); |
|
| 6833 | + foreach ($this->_contents as $id=>$content) |
|
| 6834 | + $master->injectContent($id, $content); |
|
| 6835 | 6835 | } |
| 6836 | - else if(!empty($this->_contents)) |
|
| 6837 | - throw new TConfigurationException('templatecontrol_mastercontrol_required',get_class($this)); |
|
| 6836 | + else if (!empty($this->_contents)) |
|
| 6837 | + throw new TConfigurationException('templatecontrol_mastercontrol_required', get_class($this)); |
|
| 6838 | 6838 | parent::initRecursive($namingContainer); |
| 6839 | 6839 | } |
| 6840 | 6840 | public function tryToUpdateView($arObj, $throwExceptions = false) |
@@ -6918,30 +6918,30 @@ discard block |
||
| 6918 | 6918 | } |
| 6919 | 6919 | protected function addAttributesToRender($writer) |
| 6920 | 6920 | { |
| 6921 | - $writer->addAttribute('id',$this->getClientID()); |
|
| 6922 | - $writer->addAttribute('method',$this->getMethod()); |
|
| 6923 | - $uri=$this->getRequest()->getRequestURI(); |
|
| 6924 | - $writer->addAttribute('action',str_replace('&','&',str_replace('&','&',$uri))); |
|
| 6925 | - if(($enctype=$this->getEnctype())!=='') |
|
| 6926 | - $writer->addAttribute('enctype',$enctype); |
|
| 6927 | - $attributes=$this->getAttributes(); |
|
| 6921 | + $writer->addAttribute('id', $this->getClientID()); |
|
| 6922 | + $writer->addAttribute('method', $this->getMethod()); |
|
| 6923 | + $uri = $this->getRequest()->getRequestURI(); |
|
| 6924 | + $writer->addAttribute('action', str_replace('&', '&', str_replace('&', '&', $uri))); |
|
| 6925 | + if (($enctype = $this->getEnctype()) !== '') |
|
| 6926 | + $writer->addAttribute('enctype', $enctype); |
|
| 6927 | + $attributes = $this->getAttributes(); |
|
| 6928 | 6928 | $attributes->remove('action'); |
| 6929 | 6929 | $writer->addAttributes($attributes); |
| 6930 | - if(($butt=$this->getDefaultButton())!=='') |
|
| 6930 | + if (($butt = $this->getDefaultButton()) !== '') |
|
| 6931 | 6931 | { |
| 6932 | - if(($button=$this->findControl($butt))!==null) |
|
| 6932 | + if (($button = $this->findControl($butt)) !== null) |
|
| 6933 | 6933 | $this->getPage()->getClientScript()->registerDefaultButton($this, $button); |
| 6934 | 6934 | else |
| 6935 | - throw new TInvalidDataValueException('form_defaultbutton_invalid',$butt); |
|
| 6935 | + throw new TInvalidDataValueException('form_defaultbutton_invalid', $butt); |
|
| 6936 | 6936 | } |
| 6937 | 6937 | } |
| 6938 | 6938 | public function render($writer) |
| 6939 | 6939 | { |
| 6940 | - $page=$this->getPage(); |
|
| 6940 | + $page = $this->getPage(); |
|
| 6941 | 6941 | $this->addAttributesToRender($writer); |
| 6942 | 6942 | $writer->renderBeginTag('form'); |
| 6943 | - $cs=$page->getClientScript(); |
|
| 6944 | - if($page->getClientSupportsJavaScript()) |
|
| 6943 | + $cs = $page->getClientScript(); |
|
| 6944 | + if ($page->getClientSupportsJavaScript()) |
|
| 6945 | 6945 | { |
| 6946 | 6946 | $cs->renderHiddenFieldsBegin($writer); |
| 6947 | 6947 | $cs->renderScriptFilesBegin($writer); |
@@ -6965,27 +6965,27 @@ discard block |
||
| 6965 | 6965 | } |
| 6966 | 6966 | public function getDefaultButton() |
| 6967 | 6967 | { |
| 6968 | - return $this->getViewState('DefaultButton',''); |
|
| 6968 | + return $this->getViewState('DefaultButton', ''); |
|
| 6969 | 6969 | } |
| 6970 | 6970 | public function setDefaultButton($value) |
| 6971 | 6971 | { |
| 6972 | - $this->setViewState('DefaultButton',$value,''); |
|
| 6972 | + $this->setViewState('DefaultButton', $value, ''); |
|
| 6973 | 6973 | } |
| 6974 | 6974 | public function getMethod() |
| 6975 | 6975 | { |
| 6976 | - return $this->getViewState('Method','post'); |
|
| 6976 | + return $this->getViewState('Method', 'post'); |
|
| 6977 | 6977 | } |
| 6978 | 6978 | public function setMethod($value) |
| 6979 | 6979 | { |
| 6980 | - $this->setViewState('Method',TPropertyValue::ensureEnum($value,'post','get'),'post'); |
|
| 6980 | + $this->setViewState('Method', TPropertyValue::ensureEnum($value, 'post', 'get'), 'post'); |
|
| 6981 | 6981 | } |
| 6982 | 6982 | public function getEnctype() |
| 6983 | 6983 | { |
| 6984 | - return $this->getViewState('Enctype',''); |
|
| 6984 | + return $this->getViewState('Enctype', ''); |
|
| 6985 | 6985 | } |
| 6986 | 6986 | public function setEnctype($value) |
| 6987 | 6987 | { |
| 6988 | - $this->setViewState('Enctype',$value,''); |
|
| 6988 | + $this->setViewState('Enctype', $value, ''); |
|
| 6989 | 6989 | } |
| 6990 | 6990 | public function getName() |
| 6991 | 6991 | { |
@@ -6994,26 +6994,26 @@ discard block |
||
| 6994 | 6994 | } |
| 6995 | 6995 | class TClientScriptManager extends TApplicationComponent |
| 6996 | 6996 | { |
| 6997 | - const SCRIPT_PATH='Web/Javascripts/source'; |
|
| 6998 | - const PACKAGES_FILE='Web/Javascripts/packages.php'; |
|
| 6997 | + const SCRIPT_PATH = 'Web/Javascripts/source'; |
|
| 6998 | + const PACKAGES_FILE = 'Web/Javascripts/packages.php'; |
|
| 6999 | 6999 | private $_page; |
| 7000 | - private $_hiddenFields=array(); |
|
| 7001 | - private $_beginScripts=array(); |
|
| 7002 | - private $_endScripts=array(); |
|
| 7003 | - private $_scriptFiles=array(); |
|
| 7004 | - private $_headScriptFiles=array(); |
|
| 7005 | - private $_headScripts=array(); |
|
| 7006 | - private $_styleSheetFiles=array(); |
|
| 7007 | - private $_styleSheets=array(); |
|
| 7008 | - private $_registeredPradoScripts=array(); |
|
| 7000 | + private $_hiddenFields = array(); |
|
| 7001 | + private $_beginScripts = array(); |
|
| 7002 | + private $_endScripts = array(); |
|
| 7003 | + private $_scriptFiles = array(); |
|
| 7004 | + private $_headScriptFiles = array(); |
|
| 7005 | + private $_headScripts = array(); |
|
| 7006 | + private $_styleSheetFiles = array(); |
|
| 7007 | + private $_styleSheets = array(); |
|
| 7008 | + private $_registeredPradoScripts = array(); |
|
| 7009 | 7009 | private static $_pradoScripts; |
| 7010 | 7010 | private static $_pradoPackages; |
| 7011 | 7011 | private $_renderedHiddenFields; |
| 7012 | - private $_renderedScriptFiles=array(); |
|
| 7012 | + private $_renderedScriptFiles = array(); |
|
| 7013 | 7013 | private $_expandedPradoScripts; |
| 7014 | 7014 | public function __construct(TPage $owner) |
| 7015 | 7015 | { |
| 7016 | - $this->_page=$owner; |
|
| 7016 | + $this->_page = $owner; |
|
| 7017 | 7017 | } |
| 7018 | 7018 | public function getRequiresHead() |
| 7019 | 7019 | { |
@@ -7031,30 +7031,30 @@ discard block |
||
| 7031 | 7031 | public function registerPradoScript($name) |
| 7032 | 7032 | { |
| 7033 | 7033 | $this->registerPradoScriptInternal($name); |
| 7034 | - $params=func_get_args(); |
|
| 7035 | - $this->_page->registerCachingAction('Page.ClientScript','registerPradoScript',$params); |
|
| 7034 | + $params = func_get_args(); |
|
| 7035 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerPradoScript', $params); |
|
| 7036 | 7036 | } |
| 7037 | 7037 | protected function registerPradoScriptInternal($name) |
| 7038 | 7038 | { |
| 7039 | - if(!isset($this->_registeredPradoScripts[$name])) |
|
| 7039 | + if (!isset($this->_registeredPradoScripts[$name])) |
|
| 7040 | 7040 | { |
| 7041 | - if(self::$_pradoScripts === null) |
|
| 7041 | + if (self::$_pradoScripts === null) |
|
| 7042 | 7042 | { |
| 7043 | - $packageFile = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::PACKAGES_FILE; |
|
| 7044 | - list($packages,$deps)= include($packageFile); |
|
| 7043 | + $packageFile = Prado::getFrameworkPath() . DIRECTORY_SEPARATOR . self::PACKAGES_FILE; |
|
| 7044 | + list($packages, $deps) = include($packageFile); |
|
| 7045 | 7045 | self::$_pradoScripts = $deps; |
| 7046 | 7046 | self::$_pradoPackages = $packages; |
| 7047 | 7047 | } |
| 7048 | 7048 | if (isset(self::$_pradoScripts[$name])) |
| 7049 | - $this->_registeredPradoScripts[$name]=true; |
|
| 7049 | + $this->_registeredPradoScripts[$name] = true; |
|
| 7050 | 7050 | else |
| 7051 | - throw new TInvalidOperationException('csmanager_pradoscript_invalid',$name); |
|
| 7052 | - if(($packages=array_keys($this->_registeredPradoScripts))!==array()) |
|
| 7051 | + throw new TInvalidOperationException('csmanager_pradoscript_invalid', $name); |
|
| 7052 | + if (($packages = array_keys($this->_registeredPradoScripts)) !== array()) |
|
| 7053 | 7053 | { |
| 7054 | - $base = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
| 7055 | - list($path,$baseUrl)=$this->getPackagePathUrl($base); |
|
| 7056 | - $packagesUrl=array(); |
|
| 7057 | - $isDebug=$this->getApplication()->getMode()===TApplicationMode::Debug; |
|
| 7054 | + $base = Prado::getFrameworkPath() . DIRECTORY_SEPARATOR . self::SCRIPT_PATH; |
|
| 7055 | + list($path, $baseUrl) = $this->getPackagePathUrl($base); |
|
| 7056 | + $packagesUrl = array(); |
|
| 7057 | + $isDebug = $this->getApplication()->getMode() === TApplicationMode::Debug; |
|
| 7058 | 7058 | foreach ($packages as $p) |
| 7059 | 7059 | { |
| 7060 | 7060 | foreach (self::$_pradoScripts[$p] as $dep) |
@@ -7063,35 +7063,35 @@ discard block |
||
| 7063 | 7063 | if (!isset($this->_expandedPradoScripts[$script])) |
| 7064 | 7064 | { |
| 7065 | 7065 | $this->_expandedPradoScripts[$script] = true; |
| 7066 | - if($isDebug) |
|
| 7066 | + if ($isDebug) |
|
| 7067 | 7067 | { |
| 7068 | - if (!in_array($url=$baseUrl.'/'.$script,$packagesUrl)) |
|
| 7069 | - $packagesUrl[]=$url; |
|
| 7068 | + if (!in_array($url = $baseUrl . '/' . $script, $packagesUrl)) |
|
| 7069 | + $packagesUrl[] = $url; |
|
| 7070 | 7070 | } else { |
| 7071 | - if (!in_array($url=$baseUrl.'/min/'.$script,$packagesUrl)) |
|
| 7071 | + if (!in_array($url = $baseUrl . '/min/' . $script, $packagesUrl)) |
|
| 7072 | 7072 | { |
| 7073 | - if(!is_file($filePath=$path.'/min/'.$script)) |
|
| 7073 | + if (!is_file($filePath = $path . '/min/' . $script)) |
|
| 7074 | 7074 | { |
| 7075 | - $dirPath=dirname($filePath); |
|
| 7076 | - if(!is_dir($dirPath)) |
|
| 7075 | + $dirPath = dirname($filePath); |
|
| 7076 | + if (!is_dir($dirPath)) |
|
| 7077 | 7077 | mkdir($dirPath, PRADO_CHMOD, true); |
| 7078 | - file_put_contents($filePath, TJavaScript::JSMin(file_get_contents($base.'/'.$script))); |
|
| 7078 | + file_put_contents($filePath, TJavaScript::JSMin(file_get_contents($base . '/' . $script))); |
|
| 7079 | 7079 | chmod($filePath, PRADO_CHMOD); |
| 7080 | 7080 | } |
| 7081 | - $packagesUrl[]=$url; |
|
| 7081 | + $packagesUrl[] = $url; |
|
| 7082 | 7082 | } |
| 7083 | 7083 | } |
| 7084 | 7084 | } |
| 7085 | 7085 | } |
| 7086 | 7086 | } |
| 7087 | - foreach($packagesUrl as $url) |
|
| 7088 | - $this->registerScriptFile($url,$url); |
|
| 7087 | + foreach ($packagesUrl as $url) |
|
| 7088 | + $this->registerScriptFile($url, $url); |
|
| 7089 | 7089 | } |
| 7090 | 7090 | } |
| 7091 | 7091 | } |
| 7092 | 7092 | public function getPradoScriptAssetUrl() |
| 7093 | 7093 | { |
| 7094 | - $base = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
| 7094 | + $base = Prado::getFrameworkPath() . DIRECTORY_SEPARATOR . self::SCRIPT_PATH; |
|
| 7095 | 7095 | $assets = Prado::getApplication()->getAssetManager(); |
| 7096 | 7096 | return $assets->getPublishedUrl($base); |
| 7097 | 7097 | } |
@@ -7105,19 +7105,19 @@ discard block |
||
| 7105 | 7105 | protected function getPackagePathUrl($base) |
| 7106 | 7106 | { |
| 7107 | 7107 | $assets = Prado::getApplication()->getAssetManager(); |
| 7108 | - if(strpos($base, $assets->getBaseUrl())===false) |
|
| 7108 | + if (strpos($base, $assets->getBaseUrl()) === false) |
|
| 7109 | 7109 | { |
| 7110 | - if(($dir = Prado::getPathOfNameSpace($base)) !== null) { |
|
| 7110 | + if (($dir = Prado::getPathOfNameSpace($base)) !== null) { |
|
| 7111 | 7111 | $base = $dir; |
| 7112 | 7112 | } |
| 7113 | 7113 | return array($assets->getPublishedPath($base), $assets->publishFilePath($base)); |
| 7114 | 7114 | } |
| 7115 | 7115 | else |
| 7116 | 7116 | { |
| 7117 | - return array($assets->getBasePath().str_replace($assets->getBaseUrl(),'',$base), $base); |
|
| 7117 | + return array($assets->getBasePath() . str_replace($assets->getBaseUrl(), '', $base), $base); |
|
| 7118 | 7118 | } |
| 7119 | 7119 | } |
| 7120 | - public function getCallbackReference(ICallbackEventHandler $callbackHandler, $options=null) |
|
| 7120 | + public function getCallbackReference(ICallbackEventHandler $callbackHandler, $options = null) |
|
| 7121 | 7121 | { |
| 7122 | 7122 | $options = !is_array($options) ? array() : $options; |
| 7123 | 7123 | $class = new ReflectionClass($callbackHandler); |
@@ -7130,43 +7130,43 @@ discard block |
||
| 7130 | 7130 | } |
| 7131 | 7131 | public function registerCallbackControl($class, $options) |
| 7132 | 7132 | { |
| 7133 | - $optionString=TJavaScript::encode($options); |
|
| 7134 | - $code="new {$class}({$optionString});"; |
|
| 7135 | - $this->_endScripts[sprintf('%08X', crc32($code))]=$code; |
|
| 7133 | + $optionString = TJavaScript::encode($options); |
|
| 7134 | + $code = "new {$class}({$optionString});"; |
|
| 7135 | + $this->_endScripts[sprintf('%08X', crc32($code))] = $code; |
|
| 7136 | 7136 | $this->registerPradoScriptInternal('ajax'); |
| 7137 | - $params=func_get_args(); |
|
| 7138 | - $this->_page->registerCachingAction('Page.ClientScript','registerCallbackControl',$params); |
|
| 7137 | + $params = func_get_args(); |
|
| 7138 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerCallbackControl', $params); |
|
| 7139 | 7139 | } |
| 7140 | - public function registerPostBackControl($class,$options) |
|
| 7140 | + public function registerPostBackControl($class, $options) |
|
| 7141 | 7141 | { |
| 7142 | - if($class === null) { |
|
| 7142 | + if ($class === null) { |
|
| 7143 | 7143 | return; |
| 7144 | 7144 | } |
| 7145 | - if(!isset($options['FormID']) && ($form=$this->_page->getForm())!==null) |
|
| 7146 | - $options['FormID']=$form->getClientID(); |
|
| 7147 | - $optionString=TJavaScript::encode($options); |
|
| 7148 | - $code="new {$class}({$optionString});"; |
|
| 7149 | - $this->_endScripts[sprintf('%08X', crc32($code))]=$code; |
|
| 7145 | + if (!isset($options['FormID']) && ($form = $this->_page->getForm()) !== null) |
|
| 7146 | + $options['FormID'] = $form->getClientID(); |
|
| 7147 | + $optionString = TJavaScript::encode($options); |
|
| 7148 | + $code = "new {$class}({$optionString});"; |
|
| 7149 | + $this->_endScripts[sprintf('%08X', crc32($code))] = $code; |
|
| 7150 | 7150 | $this->registerPradoScriptInternal('prado'); |
| 7151 | - $params=func_get_args(); |
|
| 7152 | - $this->_page->registerCachingAction('Page.ClientScript','registerPostBackControl',$params); |
|
| 7151 | + $params = func_get_args(); |
|
| 7152 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerPostBackControl', $params); |
|
| 7153 | 7153 | } |
| 7154 | 7154 | public function registerDefaultButton($panel, $button) |
| 7155 | 7155 | { |
| 7156 | - $panelID=is_string($panel)?$panel:$panel->getUniqueID(); |
|
| 7157 | - if(is_string($button)) |
|
| 7158 | - $buttonID=$button; |
|
| 7156 | + $panelID = is_string($panel) ? $panel : $panel->getUniqueID(); |
|
| 7157 | + if (is_string($button)) |
|
| 7158 | + $buttonID = $button; |
|
| 7159 | 7159 | else |
| 7160 | 7160 | { |
| 7161 | 7161 | $button->setIsDefaultButton(true); |
| 7162 | - $buttonID=$button->getUniqueID(); |
|
| 7162 | + $buttonID = $button->getUniqueID(); |
|
| 7163 | 7163 | } |
| 7164 | 7164 | $options = TJavaScript::encode($this->getDefaultButtonOptions($panelID, $buttonID)); |
| 7165 | 7165 | $code = "new Prado.WebUI.DefaultButton($options);"; |
| 7166 | - $this->_endScripts['prado:'.$panelID]=$code; |
|
| 7166 | + $this->_endScripts['prado:' . $panelID] = $code; |
|
| 7167 | 7167 | $this->registerPradoScriptInternal('prado'); |
| 7168 | - $params=array($panelID,$buttonID); |
|
| 7169 | - $this->_page->registerCachingAction('Page.ClientScript','registerDefaultButton',$params); |
|
| 7168 | + $params = array($panelID, $buttonID); |
|
| 7169 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerDefaultButton', $params); |
|
| 7170 | 7170 | } |
| 7171 | 7171 | protected function getDefaultButtonOptions($panelID, $buttonID) |
| 7172 | 7172 | { |
@@ -7180,26 +7180,26 @@ discard block |
||
| 7180 | 7180 | public function registerFocusControl($target) |
| 7181 | 7181 | { |
| 7182 | 7182 | $this->registerPradoScriptInternal('jquery'); |
| 7183 | - if($target instanceof TControl) |
|
| 7184 | - $target=$target->getClientID(); |
|
| 7185 | - $this->_endScripts['prado:focus'] = 'jQuery(\'#'.$target.'\').focus();'; |
|
| 7186 | - $params=func_get_args(); |
|
| 7187 | - $this->_page->registerCachingAction('Page.ClientScript','registerFocusControl',$params); |
|
| 7183 | + if ($target instanceof TControl) |
|
| 7184 | + $target = $target->getClientID(); |
|
| 7185 | + $this->_endScripts['prado:focus'] = 'jQuery(\'#' . $target . '\').focus();'; |
|
| 7186 | + $params = func_get_args(); |
|
| 7187 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerFocusControl', $params); |
|
| 7188 | 7188 | } |
| 7189 | - public function registerStyleSheetFile($key,$url,$media='') |
|
| 7189 | + public function registerStyleSheetFile($key, $url, $media = '') |
|
| 7190 | 7190 | { |
| 7191 | - if($media==='') |
|
| 7192 | - $this->_styleSheetFiles[$key]=$url; |
|
| 7191 | + if ($media === '') |
|
| 7192 | + $this->_styleSheetFiles[$key] = $url; |
|
| 7193 | 7193 | else |
| 7194 | - $this->_styleSheetFiles[$key]=array($url,$media); |
|
| 7195 | - $params=func_get_args(); |
|
| 7196 | - $this->_page->registerCachingAction('Page.ClientScript','registerStyleSheetFile',$params); |
|
| 7194 | + $this->_styleSheetFiles[$key] = array($url, $media); |
|
| 7195 | + $params = func_get_args(); |
|
| 7196 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerStyleSheetFile', $params); |
|
| 7197 | 7197 | } |
| 7198 | - public function registerStyleSheet($key,$css,$media='') |
|
| 7198 | + public function registerStyleSheet($key, $css, $media = '') |
|
| 7199 | 7199 | { |
| 7200 | - $this->_styleSheets[$key]=$css; |
|
| 7201 | - $params=func_get_args(); |
|
| 7202 | - $this->_page->registerCachingAction('Page.ClientScript','registerStyleSheet',$params); |
|
| 7200 | + $this->_styleSheets[$key] = $css; |
|
| 7201 | + $params = func_get_args(); |
|
| 7202 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerStyleSheet', $params); |
|
| 7203 | 7203 | } |
| 7204 | 7204 | public function getStyleSheetUrls() |
| 7205 | 7205 | { |
@@ -7208,8 +7208,8 @@ discard block |
||
| 7208 | 7208 | return is_array($e) ? $e[0] : $e; |
| 7209 | 7209 | }, $this->_styleSheetFiles) |
| 7210 | 7210 | ); |
| 7211 | - foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path=>$url) |
|
| 7212 | - if (substr($url,strlen($url)-4)=='.css') |
|
| 7211 | + foreach (Prado::getApplication()->getAssetManager()->getPublished() as $path=>$url) |
|
| 7212 | + if (substr($url, strlen($url) - 4) == '.css') |
|
| 7213 | 7213 | $stylesheets[] = $url; |
| 7214 | 7214 | $stylesheets = array_unique($stylesheets); |
| 7215 | 7215 | return $stylesheets; |
@@ -7218,44 +7218,44 @@ discard block |
||
| 7218 | 7218 | { |
| 7219 | 7219 | return array_unique(array_values($this->_styleSheets)); |
| 7220 | 7220 | } |
| 7221 | - public function registerHeadScriptFile($key,$url) |
|
| 7221 | + public function registerHeadScriptFile($key, $url) |
|
| 7222 | 7222 | { |
| 7223 | 7223 | $this->checkIfNotInRender(); |
| 7224 | - $this->_headScriptFiles[$key]=$url; |
|
| 7225 | - $params=func_get_args(); |
|
| 7226 | - $this->_page->registerCachingAction('Page.ClientScript','registerHeadScriptFile',$params); |
|
| 7224 | + $this->_headScriptFiles[$key] = $url; |
|
| 7225 | + $params = func_get_args(); |
|
| 7226 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerHeadScriptFile', $params); |
|
| 7227 | 7227 | } |
| 7228 | - public function registerHeadScript($key,$script) |
|
| 7228 | + public function registerHeadScript($key, $script) |
|
| 7229 | 7229 | { |
| 7230 | 7230 | $this->checkIfNotInRender(); |
| 7231 | - $this->_headScripts[$key]=$script; |
|
| 7232 | - $params=func_get_args(); |
|
| 7233 | - $this->_page->registerCachingAction('Page.ClientScript','registerHeadScript',$params); |
|
| 7231 | + $this->_headScripts[$key] = $script; |
|
| 7232 | + $params = func_get_args(); |
|
| 7233 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerHeadScript', $params); |
|
| 7234 | 7234 | } |
| 7235 | 7235 | public function registerScriptFile($key, $url) |
| 7236 | 7236 | { |
| 7237 | - $this->_scriptFiles[$key]=$url; |
|
| 7238 | - $params=func_get_args(); |
|
| 7239 | - $this->_page->registerCachingAction('Page.ClientScript','registerScriptFile',$params); |
|
| 7237 | + $this->_scriptFiles[$key] = $url; |
|
| 7238 | + $params = func_get_args(); |
|
| 7239 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerScriptFile', $params); |
|
| 7240 | 7240 | } |
| 7241 | - public function registerBeginScript($key,$script) |
|
| 7241 | + public function registerBeginScript($key, $script) |
|
| 7242 | 7242 | { |
| 7243 | 7243 | $this->checkIfNotInRender(); |
| 7244 | - $this->_beginScripts[$key]=$script; |
|
| 7245 | - $params=func_get_args(); |
|
| 7246 | - $this->_page->registerCachingAction('Page.ClientScript','registerBeginScript',$params); |
|
| 7244 | + $this->_beginScripts[$key] = $script; |
|
| 7245 | + $params = func_get_args(); |
|
| 7246 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerBeginScript', $params); |
|
| 7247 | 7247 | } |
| 7248 | - public function registerEndScript($key,$script) |
|
| 7248 | + public function registerEndScript($key, $script) |
|
| 7249 | 7249 | { |
| 7250 | - $this->_endScripts[$key]=$script; |
|
| 7251 | - $params=func_get_args(); |
|
| 7252 | - $this->_page->registerCachingAction('Page.ClientScript','registerEndScript',$params); |
|
| 7250 | + $this->_endScripts[$key] = $script; |
|
| 7251 | + $params = func_get_args(); |
|
| 7252 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerEndScript', $params); |
|
| 7253 | 7253 | } |
| 7254 | - public function registerHiddenField($name,$value) |
|
| 7254 | + public function registerHiddenField($name, $value) |
|
| 7255 | 7255 | { |
| 7256 | - $this->_hiddenFields[$name]=$value; |
|
| 7257 | - $params=func_get_args(); |
|
| 7258 | - $this->_page->registerCachingAction('Page.ClientScript','registerHiddenField',$params); |
|
| 7256 | + $this->_hiddenFields[$name] = $value; |
|
| 7257 | + $params = func_get_args(); |
|
| 7258 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerHiddenField', $params); |
|
| 7259 | 7259 | } |
| 7260 | 7260 | public function isStyleSheetFileRegistered($key) |
| 7261 | 7261 | { |
@@ -7299,24 +7299,24 @@ discard block |
||
| 7299 | 7299 | } |
| 7300 | 7300 | public function renderStyleSheetFiles($writer) |
| 7301 | 7301 | { |
| 7302 | - $str=''; |
|
| 7303 | - foreach($this->_styleSheetFiles as $url) |
|
| 7302 | + $str = ''; |
|
| 7303 | + foreach ($this->_styleSheetFiles as $url) |
|
| 7304 | 7304 | { |
| 7305 | - if(is_array($url)) |
|
| 7306 | - $str.="<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"".THttpUtility::htmlEncode($url[0])."\" />\n"; |
|
| 7305 | + if (is_array($url)) |
|
| 7306 | + $str .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"" . THttpUtility::htmlEncode($url[0]) . "\" />\n"; |
|
| 7307 | 7307 | else |
| 7308 | - $str.="<link rel=\"stylesheet\" type=\"text/css\" href=\"".THttpUtility::htmlEncode($url)."\" />\n"; |
|
| 7308 | + $str .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . THttpUtility::htmlEncode($url) . "\" />\n"; |
|
| 7309 | 7309 | } |
| 7310 | 7310 | $writer->write($str); |
| 7311 | 7311 | } |
| 7312 | 7312 | public function renderStyleSheets($writer) |
| 7313 | 7313 | { |
| 7314 | - if(count($this->_styleSheets)) |
|
| 7315 | - $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n".implode("\n",$this->_styleSheets)."\n/*]]>*/\n</style>\n"); |
|
| 7314 | + if (count($this->_styleSheets)) |
|
| 7315 | + $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n" . implode("\n", $this->_styleSheets) . "\n/*]]>*/\n</style>\n"); |
|
| 7316 | 7316 | } |
| 7317 | 7317 | public function renderHeadScriptFiles($writer) |
| 7318 | 7318 | { |
| 7319 | - $this->renderScriptFiles($writer,$this->_headScriptFiles); |
|
| 7319 | + $this->renderScriptFiles($writer, $this->_headScriptFiles); |
|
| 7320 | 7320 | } |
| 7321 | 7321 | public function renderHeadScripts($writer) |
| 7322 | 7322 | { |
@@ -7333,12 +7333,12 @@ discard block |
||
| 7333 | 7333 | public function markScriptFileAsRendered($url) |
| 7334 | 7334 | { |
| 7335 | 7335 | $this->_renderedScriptFiles[$url] = $url; |
| 7336 | - $params=func_get_args(); |
|
| 7337 | - $this->_page->registerCachingAction('Page.ClientScript','markScriptFileAsRendered',$params); |
|
| 7336 | + $params = func_get_args(); |
|
| 7337 | + $this->_page->registerCachingAction('Page.ClientScript', 'markScriptFileAsRendered', $params); |
|
| 7338 | 7338 | } |
| 7339 | 7339 | protected function renderScriptFiles($writer, Array $scripts) |
| 7340 | 7340 | { |
| 7341 | - foreach($scripts as $script) |
|
| 7341 | + foreach ($scripts as $script) |
|
| 7342 | 7342 | { |
| 7343 | 7343 | $writer->write(TJavaScript::renderScriptFile($script)); |
| 7344 | 7344 | $this->markScriptFileAsRendered($script); |
@@ -7350,10 +7350,10 @@ discard block |
||
| 7350 | 7350 | } |
| 7351 | 7351 | public function renderAllPendingScriptFiles($writer) |
| 7352 | 7352 | { |
| 7353 | - if(!empty($this->_scriptFiles)) |
|
| 7353 | + if (!empty($this->_scriptFiles)) |
|
| 7354 | 7354 | { |
| 7355 | - $addedScripts = array_diff($this->_scriptFiles,$this->getRenderedScriptFiles()); |
|
| 7356 | - $this->renderScriptFiles($writer,$addedScripts); |
|
| 7355 | + $addedScripts = array_diff($this->_scriptFiles, $this->getRenderedScriptFiles()); |
|
| 7356 | + $this->renderScriptFiles($writer, $addedScripts); |
|
| 7357 | 7357 | } |
| 7358 | 7358 | } |
| 7359 | 7359 | public function renderBeginScripts($writer) |
@@ -7374,15 +7374,15 @@ discard block |
||
| 7374 | 7374 | } |
| 7375 | 7375 | public function renderHiddenFieldsBegin($writer) |
| 7376 | 7376 | { |
| 7377 | - $this->renderHiddenFieldsInt($writer,true); |
|
| 7377 | + $this->renderHiddenFieldsInt($writer, true); |
|
| 7378 | 7378 | } |
| 7379 | 7379 | public function renderHiddenFieldsEnd($writer) |
| 7380 | 7380 | { |
| 7381 | - $this->renderHiddenFieldsInt($writer,false); |
|
| 7381 | + $this->renderHiddenFieldsInt($writer, false); |
|
| 7382 | 7382 | } |
| 7383 | - public function flushScriptFiles($writer, $control=null) |
|
| 7383 | + public function flushScriptFiles($writer, $control = null) |
|
| 7384 | 7384 | { |
| 7385 | - if(!$this->_page->getIsCallback()) |
|
| 7385 | + if (!$this->_page->getIsCallback()) |
|
| 7386 | 7386 | { |
| 7387 | 7387 | $this->_page->ensureRenderInForm($control); |
| 7388 | 7388 | $this->renderAllPendingScriptFiles($writer); |
@@ -7391,24 +7391,24 @@ discard block |
||
| 7391 | 7391 | protected function renderHiddenFieldsInt($writer, $initial) |
| 7392 | 7392 | { |
| 7393 | 7393 | if ($initial) $this->_renderedHiddenFields = array(); |
| 7394 | - $str=''; |
|
| 7395 | - foreach($this->_hiddenFields as $name=>$value) |
|
| 7394 | + $str = ''; |
|
| 7395 | + foreach ($this->_hiddenFields as $name=>$value) |
|
| 7396 | 7396 | { |
| 7397 | - if (in_array($name,$this->_renderedHiddenFields)) continue; |
|
| 7398 | - $id=strtr($name,':','_'); |
|
| 7399 | - if(is_array($value)) |
|
| 7397 | + if (in_array($name, $this->_renderedHiddenFields)) continue; |
|
| 7398 | + $id = strtr($name, ':', '_'); |
|
| 7399 | + if (is_array($value)) |
|
| 7400 | 7400 | { |
| 7401 | - foreach($value as $v) |
|
| 7402 | - $str.='<input type="hidden" name="'.$name.'[]" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
|
| 7401 | + foreach ($value as $v) |
|
| 7402 | + $str .= '<input type="hidden" name="' . $name . '[]" id="' . $id . '" value="' . THttpUtility::htmlEncode($value) . "\" />\n"; |
|
| 7403 | 7403 | } |
| 7404 | 7404 | else |
| 7405 | 7405 | { |
| 7406 | - $str.='<input type="hidden" name="'.$name.'" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
|
| 7406 | + $str .= '<input type="hidden" name="' . $name . '" id="' . $id . '" value="' . THttpUtility::htmlEncode($value) . "\" />\n"; |
|
| 7407 | 7407 | } |
| 7408 | 7408 | $this->_renderedHiddenFields[] = $name; |
| 7409 | 7409 | } |
| 7410 | - if($str!=='') |
|
| 7411 | - $writer->write("<div style=\"visibility:hidden;\">\n".$str."</div>\n"); |
|
| 7410 | + if ($str !== '') |
|
| 7411 | + $writer->write("<div style=\"visibility:hidden;\">\n" . $str . "</div>\n"); |
|
| 7412 | 7412 | } |
| 7413 | 7413 | public function getHiddenFields() |
| 7414 | 7414 | { |
@@ -7425,7 +7425,7 @@ discard block |
||
| 7425 | 7425 | private $_options; |
| 7426 | 7426 | protected function setFunction($name, $code) |
| 7427 | 7427 | { |
| 7428 | - if(!TJavaScript::isJsLiteral($code)) |
|
| 7428 | + if (!TJavaScript::isJsLiteral($code)) |
|
| 7429 | 7429 | $code = TJavaScript::quoteJsLiteral($this->ensureFunction($code)); |
| 7430 | 7430 | $this->setOption($name, $code); |
| 7431 | 7431 | } |
@@ -7453,13 +7453,13 @@ discard block |
||
| 7453 | 7453 | } |
| 7454 | 7454 | class TPage extends TTemplateControl |
| 7455 | 7455 | { |
| 7456 | - const FIELD_POSTBACK_TARGET='PRADO_POSTBACK_TARGET'; |
|
| 7457 | - const FIELD_POSTBACK_PARAMETER='PRADO_POSTBACK_PARAMETER'; |
|
| 7458 | - const FIELD_LASTFOCUS='PRADO_LASTFOCUS'; |
|
| 7459 | - const FIELD_PAGESTATE='PRADO_PAGESTATE'; |
|
| 7460 | - const FIELD_CALLBACK_TARGET='PRADO_CALLBACK_TARGET'; |
|
| 7461 | - const FIELD_CALLBACK_PARAMETER='PRADO_CALLBACK_PARAMETER'; |
|
| 7462 | - private static $_systemPostFields=array( |
|
| 7456 | + const FIELD_POSTBACK_TARGET = 'PRADO_POSTBACK_TARGET'; |
|
| 7457 | + const FIELD_POSTBACK_PARAMETER = 'PRADO_POSTBACK_PARAMETER'; |
|
| 7458 | + const FIELD_LASTFOCUS = 'PRADO_LASTFOCUS'; |
|
| 7459 | + const FIELD_PAGESTATE = 'PRADO_PAGESTATE'; |
|
| 7460 | + const FIELD_CALLBACK_TARGET = 'PRADO_CALLBACK_TARGET'; |
|
| 7461 | + const FIELD_CALLBACK_PARAMETER = 'PRADO_CALLBACK_PARAMETER'; |
|
| 7462 | + private static $_systemPostFields = array( |
|
| 7463 | 7463 | 'PRADO_POSTBACK_TARGET'=>true, |
| 7464 | 7464 | 'PRADO_POSTBACK_PARAMETER'=>true, |
| 7465 | 7465 | 'PRADO_LASTFOCUS'=>true, |
@@ -7469,32 +7469,32 @@ discard block |
||
| 7469 | 7469 | ); |
| 7470 | 7470 | private $_form; |
| 7471 | 7471 | private $_head; |
| 7472 | - private $_validators=array(); |
|
| 7473 | - private $_validated=false; |
|
| 7472 | + private $_validators = array(); |
|
| 7473 | + private $_validated = false; |
|
| 7474 | 7474 | private $_theme; |
| 7475 | 7475 | private $_title; |
| 7476 | 7476 | private $_styleSheet; |
| 7477 | 7477 | private $_clientScript; |
| 7478 | 7478 | protected $_postData; |
| 7479 | 7479 | protected $_restPostData; |
| 7480 | - protected $_controlsPostDataChanged=array(); |
|
| 7481 | - protected $_controlsRequiringPostData=array(); |
|
| 7482 | - protected $_controlsRegisteredForPostData=array(); |
|
| 7480 | + protected $_controlsPostDataChanged = array(); |
|
| 7481 | + protected $_controlsRequiringPostData = array(); |
|
| 7482 | + protected $_controlsRegisteredForPostData = array(); |
|
| 7483 | 7483 | private $_postBackEventTarget; |
| 7484 | 7484 | private $_postBackEventParameter; |
| 7485 | - protected $_formRendered=false; |
|
| 7486 | - protected $_inFormRender=false; |
|
| 7485 | + protected $_formRendered = false; |
|
| 7486 | + protected $_inFormRender = false; |
|
| 7487 | 7487 | private $_focus; |
| 7488 | - private $_pagePath=''; |
|
| 7489 | - private $_enableStateValidation=true; |
|
| 7490 | - private $_enableStateEncryption=false; |
|
| 7491 | - private $_enableStateCompression=true; |
|
| 7492 | - private $_statePersisterClass='System.Web.UI.TPageStatePersister'; |
|
| 7488 | + private $_pagePath = ''; |
|
| 7489 | + private $_enableStateValidation = true; |
|
| 7490 | + private $_enableStateEncryption = false; |
|
| 7491 | + private $_enableStateCompression = true; |
|
| 7492 | + private $_statePersisterClass = 'System.Web.UI.TPageStatePersister'; |
|
| 7493 | 7493 | private $_statePersister; |
| 7494 | 7494 | private $_cachingStack; |
| 7495 | - private $_clientState=''; |
|
| 7496 | - protected $_isLoadingPostData=false; |
|
| 7497 | - private $_enableJavaScript=true; |
|
| 7495 | + private $_clientState = ''; |
|
| 7496 | + protected $_isLoadingPostData = false; |
|
| 7497 | + private $_enableJavaScript = true; |
|
| 7498 | 7498 | private $_writer; |
| 7499 | 7499 | public function __construct() |
| 7500 | 7500 | { |
@@ -7504,9 +7504,9 @@ discard block |
||
| 7504 | 7504 | { |
| 7505 | 7505 | $this->_writer = $writer; |
| 7506 | 7506 | $this->determinePostBackMode(); |
| 7507 | - if($this->getIsPostBack()) |
|
| 7507 | + if ($this->getIsPostBack()) |
|
| 7508 | 7508 | { |
| 7509 | - if($this->getIsCallback()) |
|
| 7509 | + if ($this->getIsCallback()) |
|
| 7510 | 7510 | $this->processCallbackRequest($writer); |
| 7511 | 7511 | else |
| 7512 | 7512 | $this->processPostBackRequest($writer); |
@@ -7535,12 +7535,12 @@ discard block |
||
| 7535 | 7535 | $this->onPreInit(null); |
| 7536 | 7536 | $this->initRecursive(); |
| 7537 | 7537 | $this->onInitComplete(null); |
| 7538 | - $this->_restPostData=new TMap; |
|
| 7538 | + $this->_restPostData = new TMap; |
|
| 7539 | 7539 | $this->loadPageState(); |
| 7540 | - $this->processPostData($this->_postData,true); |
|
| 7540 | + $this->processPostData($this->_postData, true); |
|
| 7541 | 7541 | $this->onPreLoad(null); |
| 7542 | 7542 | $this->loadRecursive(); |
| 7543 | - $this->processPostData($this->_restPostData,false); |
|
| 7543 | + $this->processPostData($this->_restPostData, false); |
|
| 7544 | 7544 | $this->raiseChangedEvents(); |
| 7545 | 7545 | $this->raisePostBackEvent(); |
| 7546 | 7546 | $this->onLoadComplete(null); |
@@ -7553,13 +7553,13 @@ discard block |
||
| 7553 | 7553 | } |
| 7554 | 7554 | protected static function decodeUTF8($data, $enc) |
| 7555 | 7555 | { |
| 7556 | - if(is_array($data)) |
|
| 7556 | + if (is_array($data)) |
|
| 7557 | 7557 | { |
| 7558 | - foreach($data as $k=>$v) |
|
| 7559 | - $data[$k]=self::decodeUTF8($v, $enc); |
|
| 7558 | + foreach ($data as $k=>$v) |
|
| 7559 | + $data[$k] = self::decodeUTF8($v, $enc); |
|
| 7560 | 7560 | return $data; |
| 7561 | - } elseif(is_string($data)) { |
|
| 7562 | - return iconv('UTF-8',$enc.'//IGNORE',$data); |
|
| 7561 | + } elseif (is_string($data)) { |
|
| 7562 | + return iconv('UTF-8', $enc . '//IGNORE', $data); |
|
| 7563 | 7563 | } else { |
| 7564 | 7564 | return $data; |
| 7565 | 7565 | } |
@@ -7570,21 +7570,21 @@ discard block |
||
| 7570 | 7570 | Prado::using('System.Web.UI.JuiControls.TJuiControlOptions'); |
| 7571 | 7571 | $this->setAdapter(new TActivePageAdapter($this)); |
| 7572 | 7572 | $callbackEventParameter = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); |
| 7573 | - if(strlen($callbackEventParameter) > 0) |
|
| 7574 | - $this->_postData[TPage::FIELD_CALLBACK_PARAMETER]=TJavaScript::jsonDecode((string)$callbackEventParameter); |
|
| 7575 | - if (($g=$this->getApplication()->getGlobalization(false))!==null && |
|
| 7576 | - strtoupper($enc=$g->getCharset())!='UTF-8') |
|
| 7573 | + if (strlen($callbackEventParameter) > 0) |
|
| 7574 | + $this->_postData[TPage::FIELD_CALLBACK_PARAMETER] = TJavaScript::jsonDecode((string) $callbackEventParameter); |
|
| 7575 | + if (($g = $this->getApplication()->getGlobalization(false)) !== null && |
|
| 7576 | + strtoupper($enc = $g->getCharset()) != 'UTF-8') |
|
| 7577 | 7577 | foreach ($this->_postData as $k=>$v) |
| 7578 | - $this->_postData[$k]=self::decodeUTF8($v, $enc); |
|
| 7578 | + $this->_postData[$k] = self::decodeUTF8($v, $enc); |
|
| 7579 | 7579 | $this->onPreInit(null); |
| 7580 | 7580 | $this->initRecursive(); |
| 7581 | 7581 | $this->onInitComplete(null); |
| 7582 | - $this->_restPostData=new TMap; |
|
| 7582 | + $this->_restPostData = new TMap; |
|
| 7583 | 7583 | $this->loadPageState(); |
| 7584 | - $this->processPostData($this->_postData,true); |
|
| 7584 | + $this->processPostData($this->_postData, true); |
|
| 7585 | 7585 | $this->onPreLoad(null); |
| 7586 | 7586 | $this->loadRecursive(); |
| 7587 | - $this->processPostData($this->_restPostData,false); |
|
| 7587 | + $this->processPostData($this->_restPostData, false); |
|
| 7588 | 7588 | $this->raiseChangedEvents(); |
| 7589 | 7589 | $this->getAdapter()->processCallbackEvent($writer); |
| 7590 | 7590 | $this->onLoadComplete(null); |
@@ -7597,7 +7597,7 @@ discard block |
||
| 7597 | 7597 | } |
| 7598 | 7598 | public function getCallbackClient() |
| 7599 | 7599 | { |
| 7600 | - if($this->getAdapter() !== null) |
|
| 7600 | + if ($this->getAdapter() !== null) |
|
| 7601 | 7601 | return $this->getAdapter()->getCallbackClientHandler(); |
| 7602 | 7602 | else |
| 7603 | 7603 | return new TCallbackClientScript(); |
@@ -7628,41 +7628,41 @@ discard block |
||
| 7628 | 7628 | } |
| 7629 | 7629 | public function setForm(TForm $form) |
| 7630 | 7630 | { |
| 7631 | - if($this->_form===null) |
|
| 7632 | - $this->_form=$form; |
|
| 7631 | + if ($this->_form === null) |
|
| 7632 | + $this->_form = $form; |
|
| 7633 | 7633 | else |
| 7634 | 7634 | throw new TInvalidOperationException('page_form_duplicated'); |
| 7635 | 7635 | } |
| 7636 | - public function getValidators($validationGroup=null) |
|
| 7636 | + public function getValidators($validationGroup = null) |
|
| 7637 | 7637 | { |
| 7638 | - if(!$this->_validators) |
|
| 7639 | - $this->_validators=new TList; |
|
| 7640 | - if(empty($validationGroup) === true) |
|
| 7638 | + if (!$this->_validators) |
|
| 7639 | + $this->_validators = new TList; |
|
| 7640 | + if (empty($validationGroup) === true) |
|
| 7641 | 7641 | return $this->_validators; |
| 7642 | 7642 | else |
| 7643 | 7643 | { |
| 7644 | - $list=new TList; |
|
| 7645 | - foreach($this->_validators as $validator) |
|
| 7646 | - if($validator->getValidationGroup()===$validationGroup) |
|
| 7644 | + $list = new TList; |
|
| 7645 | + foreach ($this->_validators as $validator) |
|
| 7646 | + if ($validator->getValidationGroup() === $validationGroup) |
|
| 7647 | 7647 | $list->add($validator); |
| 7648 | 7648 | return $list; |
| 7649 | 7649 | } |
| 7650 | 7650 | } |
| 7651 | - public function validate($validationGroup=null) |
|
| 7651 | + public function validate($validationGroup = null) |
|
| 7652 | 7652 | { |
| 7653 | - $this->_validated=true; |
|
| 7654 | - if($this->_validators && $this->_validators->getCount()) |
|
| 7653 | + $this->_validated = true; |
|
| 7654 | + if ($this->_validators && $this->_validators->getCount()) |
|
| 7655 | 7655 | { |
| 7656 | - if($validationGroup===null) |
|
| 7656 | + if ($validationGroup === null) |
|
| 7657 | 7657 | { |
| 7658 | - foreach($this->_validators as $validator) |
|
| 7658 | + foreach ($this->_validators as $validator) |
|
| 7659 | 7659 | $validator->validate(); |
| 7660 | 7660 | } |
| 7661 | 7661 | else |
| 7662 | 7662 | { |
| 7663 | - foreach($this->_validators as $validator) |
|
| 7663 | + foreach ($this->_validators as $validator) |
|
| 7664 | 7664 | { |
| 7665 | - if($validator->getValidationGroup()===$validationGroup) |
|
| 7665 | + if ($validator->getValidationGroup() === $validationGroup) |
|
| 7666 | 7666 | $validator->validate(); |
| 7667 | 7667 | } |
| 7668 | 7668 | } |
@@ -7670,12 +7670,12 @@ discard block |
||
| 7670 | 7670 | } |
| 7671 | 7671 | public function getIsValid() |
| 7672 | 7672 | { |
| 7673 | - if($this->_validated) |
|
| 7673 | + if ($this->_validated) |
|
| 7674 | 7674 | { |
| 7675 | - if($this->_validators && $this->_validators->getCount()) |
|
| 7675 | + if ($this->_validators && $this->_validators->getCount()) |
|
| 7676 | 7676 | { |
| 7677 | - foreach($this->_validators as $validator) |
|
| 7678 | - if(!$validator->getIsValid()) |
|
| 7677 | + foreach ($this->_validators as $validator) |
|
| 7678 | + if (!$validator->getIsValid()) |
|
| 7679 | 7679 | return false; |
| 7680 | 7680 | } |
| 7681 | 7681 | return true; |
@@ -7685,107 +7685,107 @@ discard block |
||
| 7685 | 7685 | } |
| 7686 | 7686 | public function getTheme() |
| 7687 | 7687 | { |
| 7688 | - if(is_string($this->_theme)) |
|
| 7689 | - $this->_theme=$this->getService()->getThemeManager()->getTheme($this->_theme); |
|
| 7688 | + if (is_string($this->_theme)) |
|
| 7689 | + $this->_theme = $this->getService()->getThemeManager()->getTheme($this->_theme); |
|
| 7690 | 7690 | return $this->_theme; |
| 7691 | 7691 | } |
| 7692 | 7692 | public function setTheme($value) |
| 7693 | 7693 | { |
| 7694 | - $this->_theme=empty($value)?null:$value; |
|
| 7694 | + $this->_theme = empty($value) ? null : $value; |
|
| 7695 | 7695 | } |
| 7696 | 7696 | public function getStyleSheetTheme() |
| 7697 | 7697 | { |
| 7698 | - if(is_string($this->_styleSheet)) |
|
| 7699 | - $this->_styleSheet=$this->getService()->getThemeManager()->getTheme($this->_styleSheet); |
|
| 7698 | + if (is_string($this->_styleSheet)) |
|
| 7699 | + $this->_styleSheet = $this->getService()->getThemeManager()->getTheme($this->_styleSheet); |
|
| 7700 | 7700 | return $this->_styleSheet; |
| 7701 | 7701 | } |
| 7702 | 7702 | public function setStyleSheetTheme($value) |
| 7703 | 7703 | { |
| 7704 | - $this->_styleSheet=empty($value)?null:$value; |
|
| 7704 | + $this->_styleSheet = empty($value) ? null : $value; |
|
| 7705 | 7705 | } |
| 7706 | 7706 | public function applyControlSkin($control) |
| 7707 | 7707 | { |
| 7708 | - if(($theme=$this->getTheme())!==null) |
|
| 7708 | + if (($theme = $this->getTheme()) !== null) |
|
| 7709 | 7709 | $theme->applySkin($control); |
| 7710 | 7710 | } |
| 7711 | 7711 | public function applyControlStyleSheet($control) |
| 7712 | 7712 | { |
| 7713 | - if(($theme=$this->getStyleSheetTheme())!==null) |
|
| 7713 | + if (($theme = $this->getStyleSheetTheme()) !== null) |
|
| 7714 | 7714 | $theme->applySkin($control); |
| 7715 | 7715 | } |
| 7716 | 7716 | public function getClientScript() |
| 7717 | 7717 | { |
| 7718 | - if(!$this->_clientScript) { |
|
| 7718 | + if (!$this->_clientScript) { |
|
| 7719 | 7719 | $className = $classPath = $this->getService()->getClientScriptManagerClass(); |
| 7720 | 7720 | Prado::using($className); |
| 7721 | - if(($pos=strrpos($className,'.'))!==false) |
|
| 7722 | - $className=substr($className,$pos+1); |
|
| 7723 | - if(!class_exists($className,false) || ($className!=='TClientScriptManager' && !is_subclass_of($className,'TClientScriptManager'))) |
|
| 7724 | - throw new THttpException(404,'page_csmanagerclass_invalid',$classPath); |
|
| 7725 | - $this->_clientScript=new $className($this); |
|
| 7721 | + if (($pos = strrpos($className, '.')) !== false) |
|
| 7722 | + $className = substr($className, $pos + 1); |
|
| 7723 | + if (!class_exists($className, false) || ($className !== 'TClientScriptManager' && !is_subclass_of($className, 'TClientScriptManager'))) |
|
| 7724 | + throw new THttpException(404, 'page_csmanagerclass_invalid', $classPath); |
|
| 7725 | + $this->_clientScript = new $className($this); |
|
| 7726 | 7726 | } |
| 7727 | 7727 | return $this->_clientScript; |
| 7728 | 7728 | } |
| 7729 | 7729 | public function onPreInit($param) |
| 7730 | 7730 | { |
| 7731 | - $this->raiseEvent('OnPreInit',$this,$param); |
|
| 7731 | + $this->raiseEvent('OnPreInit', $this, $param); |
|
| 7732 | 7732 | } |
| 7733 | 7733 | public function onInitComplete($param) |
| 7734 | 7734 | { |
| 7735 | - $this->raiseEvent('OnInitComplete',$this,$param); |
|
| 7735 | + $this->raiseEvent('OnInitComplete', $this, $param); |
|
| 7736 | 7736 | } |
| 7737 | 7737 | public function onPreLoad($param) |
| 7738 | 7738 | { |
| 7739 | - $this->raiseEvent('OnPreLoad',$this,$param); |
|
| 7739 | + $this->raiseEvent('OnPreLoad', $this, $param); |
|
| 7740 | 7740 | } |
| 7741 | 7741 | public function onLoadComplete($param) |
| 7742 | 7742 | { |
| 7743 | - $this->raiseEvent('OnLoadComplete',$this,$param); |
|
| 7743 | + $this->raiseEvent('OnLoadComplete', $this, $param); |
|
| 7744 | 7744 | } |
| 7745 | 7745 | public function onPreRenderComplete($param) |
| 7746 | 7746 | { |
| 7747 | - $this->raiseEvent('OnPreRenderComplete',$this,$param); |
|
| 7748 | - $cs=$this->getClientScript(); |
|
| 7749 | - $theme=$this->getTheme(); |
|
| 7750 | - if($theme instanceof ITheme) |
|
| 7747 | + $this->raiseEvent('OnPreRenderComplete', $this, $param); |
|
| 7748 | + $cs = $this->getClientScript(); |
|
| 7749 | + $theme = $this->getTheme(); |
|
| 7750 | + if ($theme instanceof ITheme) |
|
| 7751 | 7751 | { |
| 7752 | - foreach($theme->getStyleSheetFiles() as $url) |
|
| 7753 | - $cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url)); |
|
| 7754 | - foreach($theme->getJavaScriptFiles() as $url) |
|
| 7755 | - $cs->registerHeadScriptFile($url,$url); |
|
| 7752 | + foreach ($theme->getStyleSheetFiles() as $url) |
|
| 7753 | + $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
|
| 7754 | + foreach ($theme->getJavaScriptFiles() as $url) |
|
| 7755 | + $cs->registerHeadScriptFile($url, $url); |
|
| 7756 | 7756 | } |
| 7757 | - $styleSheet=$this->getStyleSheetTheme(); |
|
| 7758 | - if($styleSheet instanceof ITheme) |
|
| 7757 | + $styleSheet = $this->getStyleSheetTheme(); |
|
| 7758 | + if ($styleSheet instanceof ITheme) |
|
| 7759 | 7759 | { |
| 7760 | - foreach($styleSheet->getStyleSheetFiles() as $url) |
|
| 7761 | - $cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url)); |
|
| 7762 | - foreach($styleSheet->getJavaScriptFiles() as $url) |
|
| 7763 | - $cs->registerHeadScriptFile($url,$url); |
|
| 7760 | + foreach ($styleSheet->getStyleSheetFiles() as $url) |
|
| 7761 | + $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
|
| 7762 | + foreach ($styleSheet->getJavaScriptFiles() as $url) |
|
| 7763 | + $cs->registerHeadScriptFile($url, $url); |
|
| 7764 | 7764 | } |
| 7765 | - if($cs->getRequiresHead() && $this->getHead()===null) |
|
| 7765 | + if ($cs->getRequiresHead() && $this->getHead() === null) |
|
| 7766 | 7766 | throw new TConfigurationException('page_head_required'); |
| 7767 | 7767 | } |
| 7768 | 7768 | private function getCssMediaType($url) |
| 7769 | 7769 | { |
| 7770 | - $segs=explode('.',basename($url)); |
|
| 7771 | - if(isset($segs[2])) |
|
| 7772 | - return $segs[count($segs)-2]; |
|
| 7770 | + $segs = explode('.', basename($url)); |
|
| 7771 | + if (isset($segs[2])) |
|
| 7772 | + return $segs[count($segs) - 2]; |
|
| 7773 | 7773 | else |
| 7774 | 7774 | return ''; |
| 7775 | 7775 | } |
| 7776 | 7776 | public function onSaveStateComplete($param) |
| 7777 | 7777 | { |
| 7778 | - $this->raiseEvent('OnSaveStateComplete',$this,$param); |
|
| 7778 | + $this->raiseEvent('OnSaveStateComplete', $this, $param); |
|
| 7779 | 7779 | } |
| 7780 | 7780 | private function determinePostBackMode() |
| 7781 | 7781 | { |
| 7782 | - $postData=$this->getRequest(); |
|
| 7783 | - if($postData->contains(self::FIELD_PAGESTATE) || $postData->contains(self::FIELD_POSTBACK_TARGET)) |
|
| 7784 | - $this->_postData=$postData; |
|
| 7782 | + $postData = $this->getRequest(); |
|
| 7783 | + if ($postData->contains(self::FIELD_PAGESTATE) || $postData->contains(self::FIELD_POSTBACK_TARGET)) |
|
| 7784 | + $this->_postData = $postData; |
|
| 7785 | 7785 | } |
| 7786 | 7786 | public function getIsPostBack() |
| 7787 | 7787 | { |
| 7788 | - return $this->_postData!==null; |
|
| 7788 | + return $this->_postData !== null; |
|
| 7789 | 7789 | } |
| 7790 | 7790 | public function getIsCallback() |
| 7791 | 7791 | { |
@@ -7794,21 +7794,21 @@ discard block |
||
| 7794 | 7794 | public function saveState() |
| 7795 | 7795 | { |
| 7796 | 7796 | parent::saveState(); |
| 7797 | - $this->setViewState('ControlsRequiringPostBack',$this->_controlsRegisteredForPostData,array()); |
|
| 7797 | + $this->setViewState('ControlsRequiringPostBack', $this->_controlsRegisteredForPostData, array()); |
|
| 7798 | 7798 | } |
| 7799 | 7799 | public function loadState() |
| 7800 | 7800 | { |
| 7801 | 7801 | parent::loadState(); |
| 7802 | - $this->_controlsRequiringPostData=$this->getViewState('ControlsRequiringPostBack',array()); |
|
| 7802 | + $this->_controlsRequiringPostData = $this->getViewState('ControlsRequiringPostBack', array()); |
|
| 7803 | 7803 | } |
| 7804 | 7804 | protected function loadPageState() |
| 7805 | 7805 | { |
| 7806 | - $state=$this->getStatePersister()->load(); |
|
| 7807 | - $this->loadStateRecursive($state,$this->getEnableViewState()); |
|
| 7806 | + $state = $this->getStatePersister()->load(); |
|
| 7807 | + $this->loadStateRecursive($state, $this->getEnableViewState()); |
|
| 7808 | 7808 | } |
| 7809 | 7809 | protected function savePageState() |
| 7810 | 7810 | { |
| 7811 | - $state=&$this->saveStateRecursive($this->getEnableViewState()); |
|
| 7811 | + $state = &$this->saveStateRecursive($this->getEnableViewState()); |
|
| 7812 | 7812 | $this->getStatePersister()->save($state); |
| 7813 | 7813 | } |
| 7814 | 7814 | protected function isSystemPostField($field) |
@@ -7817,79 +7817,79 @@ discard block |
||
| 7817 | 7817 | } |
| 7818 | 7818 | public function registerRequiresPostData($control) |
| 7819 | 7819 | { |
| 7820 | - $id=is_string($control)?$control:$control->getUniqueID(); |
|
| 7821 | - $this->_controlsRegisteredForPostData[$id]=true; |
|
| 7822 | - $params=func_get_args(); |
|
| 7823 | - foreach($this->getCachingStack() as $item) |
|
| 7824 | - $item->registerAction('Page','registerRequiresPostData',array($id)); |
|
| 7820 | + $id = is_string($control) ? $control : $control->getUniqueID(); |
|
| 7821 | + $this->_controlsRegisteredForPostData[$id] = true; |
|
| 7822 | + $params = func_get_args(); |
|
| 7823 | + foreach ($this->getCachingStack() as $item) |
|
| 7824 | + $item->registerAction('Page', 'registerRequiresPostData', array($id)); |
|
| 7825 | 7825 | } |
| 7826 | 7826 | public function getPostBackEventTarget() |
| 7827 | 7827 | { |
| 7828 | - if($this->_postBackEventTarget===null && $this->_postData!==null) |
|
| 7828 | + if ($this->_postBackEventTarget === null && $this->_postData !== null) |
|
| 7829 | 7829 | { |
| 7830 | - $eventTarget=$this->_postData->itemAt(self::FIELD_POSTBACK_TARGET); |
|
| 7831 | - if(!empty($eventTarget)) |
|
| 7832 | - $this->_postBackEventTarget=$this->findControl($eventTarget); |
|
| 7830 | + $eventTarget = $this->_postData->itemAt(self::FIELD_POSTBACK_TARGET); |
|
| 7831 | + if (!empty($eventTarget)) |
|
| 7832 | + $this->_postBackEventTarget = $this->findControl($eventTarget); |
|
| 7833 | 7833 | } |
| 7834 | 7834 | return $this->_postBackEventTarget; |
| 7835 | 7835 | } |
| 7836 | 7836 | public function setPostBackEventTarget(TControl $control) |
| 7837 | 7837 | { |
| 7838 | - $this->_postBackEventTarget=$control; |
|
| 7838 | + $this->_postBackEventTarget = $control; |
|
| 7839 | 7839 | } |
| 7840 | 7840 | public function getPostBackEventParameter() |
| 7841 | 7841 | { |
| 7842 | - if($this->_postBackEventParameter===null && $this->_postData!==null) |
|
| 7842 | + if ($this->_postBackEventParameter === null && $this->_postData !== null) |
|
| 7843 | 7843 | { |
| 7844 | - if(($this->_postBackEventParameter=$this->_postData->itemAt(self::FIELD_POSTBACK_PARAMETER))===null) |
|
| 7845 | - $this->_postBackEventParameter=''; |
|
| 7844 | + if (($this->_postBackEventParameter = $this->_postData->itemAt(self::FIELD_POSTBACK_PARAMETER)) === null) |
|
| 7845 | + $this->_postBackEventParameter = ''; |
|
| 7846 | 7846 | } |
| 7847 | 7847 | return $this->_postBackEventParameter; |
| 7848 | 7848 | } |
| 7849 | 7849 | public function setPostBackEventParameter($value) |
| 7850 | 7850 | { |
| 7851 | - $this->_postBackEventParameter=$value; |
|
| 7851 | + $this->_postBackEventParameter = $value; |
|
| 7852 | 7852 | } |
| 7853 | - protected function processPostData($postData,$beforeLoad) |
|
| 7853 | + protected function processPostData($postData, $beforeLoad) |
|
| 7854 | 7854 | { |
| 7855 | - $this->_isLoadingPostData=true; |
|
| 7856 | - if($beforeLoad) |
|
| 7857 | - $this->_restPostData=new TMap; |
|
| 7858 | - foreach($postData as $key=>$value) |
|
| 7855 | + $this->_isLoadingPostData = true; |
|
| 7856 | + if ($beforeLoad) |
|
| 7857 | + $this->_restPostData = new TMap; |
|
| 7858 | + foreach ($postData as $key=>$value) |
|
| 7859 | 7859 | { |
| 7860 | - if($this->isSystemPostField($key)) |
|
| 7860 | + if ($this->isSystemPostField($key)) |
|
| 7861 | 7861 | continue; |
| 7862 | - else if($control=$this->findControl($key)) |
|
| 7862 | + else if ($control = $this->findControl($key)) |
|
| 7863 | 7863 | { |
| 7864 | - if($control instanceof IPostBackDataHandler) |
|
| 7864 | + if ($control instanceof IPostBackDataHandler) |
|
| 7865 | 7865 | { |
| 7866 | - if($control->loadPostData($key,$postData)) |
|
| 7867 | - $this->_controlsPostDataChanged[]=$control; |
|
| 7866 | + if ($control->loadPostData($key, $postData)) |
|
| 7867 | + $this->_controlsPostDataChanged[] = $control; |
|
| 7868 | 7868 | } |
| 7869 | - else if($control instanceof IPostBackEventHandler && |
|
| 7869 | + else if ($control instanceof IPostBackEventHandler && |
|
| 7870 | 7870 | empty($this->_postData[self::FIELD_POSTBACK_TARGET])) |
| 7871 | 7871 | { |
| 7872 | - $this->_postData->add(self::FIELD_POSTBACK_TARGET,$key); } |
|
| 7872 | + $this->_postData->add(self::FIELD_POSTBACK_TARGET, $key); } |
|
| 7873 | 7873 | unset($this->_controlsRequiringPostData[$key]); |
| 7874 | 7874 | } |
| 7875 | - else if($beforeLoad) |
|
| 7876 | - $this->_restPostData->add($key,$value); |
|
| 7875 | + else if ($beforeLoad) |
|
| 7876 | + $this->_restPostData->add($key, $value); |
|
| 7877 | 7877 | } |
| 7878 | - foreach($this->_controlsRequiringPostData as $key=>$value) |
|
| 7878 | + foreach ($this->_controlsRequiringPostData as $key=>$value) |
|
| 7879 | 7879 | { |
| 7880 | - if($control=$this->findControl($key)) |
|
| 7880 | + if ($control = $this->findControl($key)) |
|
| 7881 | 7881 | { |
| 7882 | - if($control instanceof IPostBackDataHandler) |
|
| 7882 | + if ($control instanceof IPostBackDataHandler) |
|
| 7883 | 7883 | { |
| 7884 | - if($control->loadPostData($key,$this->_postData)) |
|
| 7885 | - $this->_controlsPostDataChanged[]=$control; |
|
| 7884 | + if ($control->loadPostData($key, $this->_postData)) |
|
| 7885 | + $this->_controlsPostDataChanged[] = $control; |
|
| 7886 | 7886 | } |
| 7887 | 7887 | else |
| 7888 | - throw new TInvalidDataValueException('page_postbackcontrol_invalid',$key); |
|
| 7888 | + throw new TInvalidDataValueException('page_postbackcontrol_invalid', $key); |
|
| 7889 | 7889 | unset($this->_controlsRequiringPostData[$key]); |
| 7890 | 7890 | } |
| 7891 | 7891 | } |
| 7892 | - $this->_isLoadingPostData=false; |
|
| 7892 | + $this->_isLoadingPostData = false; |
|
| 7893 | 7893 | } |
| 7894 | 7894 | public function getIsLoadingPostData() |
| 7895 | 7895 | { |
@@ -7897,14 +7897,14 @@ discard block |
||
| 7897 | 7897 | } |
| 7898 | 7898 | protected function raiseChangedEvents() |
| 7899 | 7899 | { |
| 7900 | - foreach($this->_controlsPostDataChanged as $control) |
|
| 7900 | + foreach ($this->_controlsPostDataChanged as $control) |
|
| 7901 | 7901 | $control->raisePostDataChangedEvent(); |
| 7902 | 7902 | } |
| 7903 | 7903 | protected function raisePostBackEvent() |
| 7904 | 7904 | { |
| 7905 | - if(($postBackHandler=$this->getPostBackEventTarget())===null) |
|
| 7905 | + if (($postBackHandler = $this->getPostBackEventTarget()) === null) |
|
| 7906 | 7906 | $this->validate(); |
| 7907 | - else if($postBackHandler instanceof IPostBackEventHandler) |
|
| 7907 | + else if ($postBackHandler instanceof IPostBackEventHandler) |
|
| 7908 | 7908 | $postBackHandler->raisePostBackEvent($this->getPostBackEventParameter()); |
| 7909 | 7909 | } |
| 7910 | 7910 | public function getInFormRender() |
@@ -7913,34 +7913,34 @@ discard block |
||
| 7913 | 7913 | } |
| 7914 | 7914 | public function ensureRenderInForm($control) |
| 7915 | 7915 | { |
| 7916 | - if(!$this->getIsCallback() && !$this->_inFormRender) |
|
| 7917 | - throw new TConfigurationException('page_control_outofform',get_class($control), $control ? $control->getUniqueID() : null); |
|
| 7916 | + if (!$this->getIsCallback() && !$this->_inFormRender) |
|
| 7917 | + throw new TConfigurationException('page_control_outofform', get_class($control), $control ? $control->getUniqueID() : null); |
|
| 7918 | 7918 | } |
| 7919 | 7919 | public function beginFormRender($writer) |
| 7920 | 7920 | { |
| 7921 | - if($this->_formRendered) |
|
| 7921 | + if ($this->_formRendered) |
|
| 7922 | 7922 | throw new TConfigurationException('page_form_duplicated'); |
| 7923 | - $this->_formRendered=true; |
|
| 7924 | - $this->getClientScript()->registerHiddenField(self::FIELD_PAGESTATE,$this->getClientState()); |
|
| 7925 | - $this->_inFormRender=true; |
|
| 7923 | + $this->_formRendered = true; |
|
| 7924 | + $this->getClientScript()->registerHiddenField(self::FIELD_PAGESTATE, $this->getClientState()); |
|
| 7925 | + $this->_inFormRender = true; |
|
| 7926 | 7926 | } |
| 7927 | 7927 | public function endFormRender($writer) |
| 7928 | 7928 | { |
| 7929 | - if($this->_focus) |
|
| 7929 | + if ($this->_focus) |
|
| 7930 | 7930 | { |
| 7931 | - if(($this->_focus instanceof TControl) && $this->_focus->getVisible(true)) |
|
| 7932 | - $focus=$this->_focus->getClientID(); |
|
| 7931 | + if (($this->_focus instanceof TControl) && $this->_focus->getVisible(true)) |
|
| 7932 | + $focus = $this->_focus->getClientID(); |
|
| 7933 | 7933 | else |
| 7934 | - $focus=$this->_focus; |
|
| 7934 | + $focus = $this->_focus; |
|
| 7935 | 7935 | $this->getClientScript()->registerFocusControl($focus); |
| 7936 | 7936 | } |
| 7937 | - else if($this->_postData && ($lastFocus=$this->_postData->itemAt(self::FIELD_LASTFOCUS))!==null) |
|
| 7937 | + else if ($this->_postData && ($lastFocus = $this->_postData->itemAt(self::FIELD_LASTFOCUS)) !== null) |
|
| 7938 | 7938 | $this->getClientScript()->registerFocusControl($lastFocus); |
| 7939 | - $this->_inFormRender=false; |
|
| 7939 | + $this->_inFormRender = false; |
|
| 7940 | 7940 | } |
| 7941 | 7941 | public function setFocus($value) |
| 7942 | 7942 | { |
| 7943 | - $this->_focus=$value; |
|
| 7943 | + $this->_focus = $value; |
|
| 7944 | 7944 | } |
| 7945 | 7945 | public function getClientSupportsJavaScript() |
| 7946 | 7946 | { |
@@ -7948,7 +7948,7 @@ discard block |
||
| 7948 | 7948 | } |
| 7949 | 7949 | public function setClientSupportsJavaScript($value) |
| 7950 | 7950 | { |
| 7951 | - $this->_enableJavaScript=TPropertyValue::ensureBoolean($value); |
|
| 7951 | + $this->_enableJavaScript = TPropertyValue::ensureBoolean($value); |
|
| 7952 | 7952 | } |
| 7953 | 7953 | public function getHead() |
| 7954 | 7954 | { |
@@ -7956,28 +7956,28 @@ discard block |
||
| 7956 | 7956 | } |
| 7957 | 7957 | public function setHead(THead $value) |
| 7958 | 7958 | { |
| 7959 | - if($this->_head) |
|
| 7959 | + if ($this->_head) |
|
| 7960 | 7960 | throw new TInvalidOperationException('page_head_duplicated'); |
| 7961 | - $this->_head=$value; |
|
| 7962 | - if($this->_title!==null) |
|
| 7961 | + $this->_head = $value; |
|
| 7962 | + if ($this->_title !== null) |
|
| 7963 | 7963 | { |
| 7964 | 7964 | $this->_head->setTitle($this->_title); |
| 7965 | - $this->_title=null; |
|
| 7965 | + $this->_title = null; |
|
| 7966 | 7966 | } |
| 7967 | 7967 | } |
| 7968 | 7968 | public function getTitle() |
| 7969 | 7969 | { |
| 7970 | - if($this->_head) |
|
| 7970 | + if ($this->_head) |
|
| 7971 | 7971 | return $this->_head->getTitle(); |
| 7972 | 7972 | else |
| 7973 | - return $this->_title===null ? '' : $this->_title; |
|
| 7973 | + return $this->_title === null ? '' : $this->_title; |
|
| 7974 | 7974 | } |
| 7975 | 7975 | public function setTitle($value) |
| 7976 | 7976 | { |
| 7977 | - if($this->_head) |
|
| 7977 | + if ($this->_head) |
|
| 7978 | 7978 | $this->_head->setTitle($value); |
| 7979 | 7979 | else |
| 7980 | - $this->_title=$value; |
|
| 7980 | + $this->_title = $value; |
|
| 7981 | 7981 | } |
| 7982 | 7982 | public function getClientState() |
| 7983 | 7983 | { |
@@ -7985,7 +7985,7 @@ discard block |
||
| 7985 | 7985 | } |
| 7986 | 7986 | public function setClientState($state) |
| 7987 | 7987 | { |
| 7988 | - $this->_clientState=$state; |
|
| 7988 | + $this->_clientState = $state; |
|
| 7989 | 7989 | } |
| 7990 | 7990 | public function getRequestClientState() |
| 7991 | 7991 | { |
@@ -7997,14 +7997,14 @@ discard block |
||
| 7997 | 7997 | } |
| 7998 | 7998 | public function setStatePersisterClass($value) |
| 7999 | 7999 | { |
| 8000 | - $this->_statePersisterClass=$value; |
|
| 8000 | + $this->_statePersisterClass = $value; |
|
| 8001 | 8001 | } |
| 8002 | 8002 | public function getStatePersister() |
| 8003 | 8003 | { |
| 8004 | - if($this->_statePersister===null) |
|
| 8004 | + if ($this->_statePersister === null) |
|
| 8005 | 8005 | { |
| 8006 | - $this->_statePersister=Prado::createComponent($this->_statePersisterClass); |
|
| 8007 | - if(!($this->_statePersister instanceof IPageStatePersister)) |
|
| 8006 | + $this->_statePersister = Prado::createComponent($this->_statePersisterClass); |
|
| 8007 | + if (!($this->_statePersister instanceof IPageStatePersister)) |
|
| 8008 | 8008 | throw new TInvalidDataTypeException('page_statepersister_invalid'); |
| 8009 | 8009 | $this->_statePersister->setPage($this); |
| 8010 | 8010 | } |
@@ -8016,7 +8016,7 @@ discard block |
||
| 8016 | 8016 | } |
| 8017 | 8017 | public function setEnableStateValidation($value) |
| 8018 | 8018 | { |
| 8019 | - $this->_enableStateValidation=TPropertyValue::ensureBoolean($value); |
|
| 8019 | + $this->_enableStateValidation = TPropertyValue::ensureBoolean($value); |
|
| 8020 | 8020 | } |
| 8021 | 8021 | public function getEnableStateEncryption() |
| 8022 | 8022 | { |
@@ -8024,7 +8024,7 @@ discard block |
||
| 8024 | 8024 | } |
| 8025 | 8025 | public function setEnableStateEncryption($value) |
| 8026 | 8026 | { |
| 8027 | - $this->_enableStateEncryption=TPropertyValue::ensureBoolean($value); |
|
| 8027 | + $this->_enableStateEncryption = TPropertyValue::ensureBoolean($value); |
|
| 8028 | 8028 | } |
| 8029 | 8029 | public function getEnableStateCompression() |
| 8030 | 8030 | { |
@@ -8032,7 +8032,7 @@ discard block |
||
| 8032 | 8032 | } |
| 8033 | 8033 | public function setEnableStateCompression($value) |
| 8034 | 8034 | { |
| 8035 | - $this->_enableStateCompression=TPropertyValue::ensureBoolean($value); |
|
| 8035 | + $this->_enableStateCompression = TPropertyValue::ensureBoolean($value); |
|
| 8036 | 8036 | } |
| 8037 | 8037 | public function getPagePath() |
| 8038 | 8038 | { |
@@ -8040,20 +8040,20 @@ discard block |
||
| 8040 | 8040 | } |
| 8041 | 8041 | public function setPagePath($value) |
| 8042 | 8042 | { |
| 8043 | - $this->_pagePath=$value; |
|
| 8043 | + $this->_pagePath = $value; |
|
| 8044 | 8044 | } |
| 8045 | - public function registerCachingAction($context,$funcName,$funcParams) |
|
| 8045 | + public function registerCachingAction($context, $funcName, $funcParams) |
|
| 8046 | 8046 | { |
| 8047 | - if($this->_cachingStack) |
|
| 8047 | + if ($this->_cachingStack) |
|
| 8048 | 8048 | { |
| 8049 | - foreach($this->_cachingStack as $cache) |
|
| 8050 | - $cache->registerAction($context,$funcName,$funcParams); |
|
| 8049 | + foreach ($this->_cachingStack as $cache) |
|
| 8050 | + $cache->registerAction($context, $funcName, $funcParams); |
|
| 8051 | 8051 | } |
| 8052 | 8052 | } |
| 8053 | 8053 | public function getCachingStack() |
| 8054 | 8054 | { |
| 8055 | - if(!$this->_cachingStack) |
|
| 8056 | - $this->_cachingStack=new TStack; |
|
| 8055 | + if (!$this->_cachingStack) |
|
| 8056 | + $this->_cachingStack = new TStack; |
|
| 8057 | 8057 | return $this->_cachingStack; |
| 8058 | 8058 | } |
| 8059 | 8059 | public function flushWriter() |
@@ -8071,34 +8071,34 @@ discard block |
||
| 8071 | 8071 | } |
| 8072 | 8072 | class TPageStateFormatter |
| 8073 | 8073 | { |
| 8074 | - public static function serialize($page,$data) |
|
| 8074 | + public static function serialize($page, $data) |
|
| 8075 | 8075 | { |
| 8076 | - $sm=$page->getApplication()->getSecurityManager(); |
|
| 8077 | - if($page->getEnableStateValidation()) |
|
| 8078 | - $str=$sm->hashData(serialize($data)); |
|
| 8076 | + $sm = $page->getApplication()->getSecurityManager(); |
|
| 8077 | + if ($page->getEnableStateValidation()) |
|
| 8078 | + $str = $sm->hashData(serialize($data)); |
|
| 8079 | 8079 | else |
| 8080 | - $str=serialize($data); |
|
| 8081 | - if($page->getEnableStateCompression() && extension_loaded('zlib')) |
|
| 8082 | - $str=gzcompress($str); |
|
| 8083 | - if($page->getEnableStateEncryption()) |
|
| 8084 | - $str=$sm->encrypt($str); |
|
| 8080 | + $str = serialize($data); |
|
| 8081 | + if ($page->getEnableStateCompression() && extension_loaded('zlib')) |
|
| 8082 | + $str = gzcompress($str); |
|
| 8083 | + if ($page->getEnableStateEncryption()) |
|
| 8084 | + $str = $sm->encrypt($str); |
|
| 8085 | 8085 | return base64_encode($str); |
| 8086 | 8086 | } |
| 8087 | - public static function unserialize($page,$data) |
|
| 8087 | + public static function unserialize($page, $data) |
|
| 8088 | 8088 | { |
| 8089 | - $str=base64_decode($data); |
|
| 8090 | - if($str==='') |
|
| 8089 | + $str = base64_decode($data); |
|
| 8090 | + if ($str === '') |
|
| 8091 | 8091 | return null; |
| 8092 | - if($str!==false) |
|
| 8092 | + if ($str !== false) |
|
| 8093 | 8093 | { |
| 8094 | - $sm=$page->getApplication()->getSecurityManager(); |
|
| 8095 | - if($page->getEnableStateEncryption()) |
|
| 8096 | - $str=$sm->decrypt($str); |
|
| 8097 | - if($page->getEnableStateCompression() && extension_loaded('zlib')) |
|
| 8098 | - $str=@gzuncompress($str); |
|
| 8099 | - if($page->getEnableStateValidation()) |
|
| 8094 | + $sm = $page->getApplication()->getSecurityManager(); |
|
| 8095 | + if ($page->getEnableStateEncryption()) |
|
| 8096 | + $str = $sm->decrypt($str); |
|
| 8097 | + if ($page->getEnableStateCompression() && extension_loaded('zlib')) |
|
| 8098 | + $str = @gzuncompress($str); |
|
| 8099 | + if ($page->getEnableStateValidation()) |
|
| 8100 | 8100 | { |
| 8101 | - if(($str=$sm->validateData($str))!==false) |
|
| 8101 | + if (($str = $sm->validateData($str)) !== false) |
|
| 8102 | 8102 | return unserialize($str); |
| 8103 | 8103 | } |
| 8104 | 8104 | else |
@@ -8109,22 +8109,22 @@ discard block |
||
| 8109 | 8109 | } |
| 8110 | 8110 | class TOutputCache extends TControl implements INamingContainer |
| 8111 | 8111 | { |
| 8112 | - const CACHE_ID_PREFIX='prado:outputcache'; |
|
| 8113 | - private $_cacheModuleID=''; |
|
| 8114 | - private $_dataCached=false; |
|
| 8115 | - private $_cacheAvailable=false; |
|
| 8116 | - private $_cacheChecked=false; |
|
| 8117 | - private $_cacheKey=null; |
|
| 8118 | - private $_duration=60; |
|
| 8119 | - private $_cache=null; |
|
| 8112 | + const CACHE_ID_PREFIX = 'prado:outputcache'; |
|
| 8113 | + private $_cacheModuleID = ''; |
|
| 8114 | + private $_dataCached = false; |
|
| 8115 | + private $_cacheAvailable = false; |
|
| 8116 | + private $_cacheChecked = false; |
|
| 8117 | + private $_cacheKey = null; |
|
| 8118 | + private $_duration = 60; |
|
| 8119 | + private $_cache = null; |
|
| 8120 | 8120 | private $_contents; |
| 8121 | 8121 | private $_state; |
| 8122 | - private $_actions=array(); |
|
| 8123 | - private $_varyByParam=''; |
|
| 8124 | - private $_keyPrefix=''; |
|
| 8125 | - private $_varyBySession=false; |
|
| 8126 | - private $_cachePostBack=false; |
|
| 8127 | - private $_cacheTime=0; |
|
| 8122 | + private $_actions = array(); |
|
| 8123 | + private $_varyByParam = ''; |
|
| 8124 | + private $_keyPrefix = ''; |
|
| 8125 | + private $_varyBySession = false; |
|
| 8126 | + private $_cachePostBack = false; |
|
| 8127 | + private $_cacheTime = 0; |
|
| 8128 | 8128 | public function getAllowChildControls() |
| 8129 | 8129 | { |
| 8130 | 8130 | $this->determineCacheability(); |
@@ -8132,43 +8132,43 @@ discard block |
||
| 8132 | 8132 | } |
| 8133 | 8133 | private function determineCacheability() |
| 8134 | 8134 | { |
| 8135 | - if(!$this->_cacheChecked) |
|
| 8135 | + if (!$this->_cacheChecked) |
|
| 8136 | 8136 | { |
| 8137 | - $this->_cacheChecked=true; |
|
| 8138 | - if($this->_duration>0 && ($this->_cachePostBack || !$this->getPage()->getIsPostBack())) |
|
| 8137 | + $this->_cacheChecked = true; |
|
| 8138 | + if ($this->_duration > 0 && ($this->_cachePostBack || !$this->getPage()->getIsPostBack())) |
|
| 8139 | 8139 | { |
| 8140 | - if($this->_cacheModuleID!=='') |
|
| 8140 | + if ($this->_cacheModuleID !== '') |
|
| 8141 | 8141 | { |
| 8142 | - $this->_cache=$this->getApplication()->getModule($this->_cacheModuleID); |
|
| 8143 | - if(!($this->_cache instanceof ICache)) |
|
| 8144 | - throw new TConfigurationException('outputcache_cachemoduleid_invalid',$this->_cacheModuleID); |
|
| 8142 | + $this->_cache = $this->getApplication()->getModule($this->_cacheModuleID); |
|
| 8143 | + if (!($this->_cache instanceof ICache)) |
|
| 8144 | + throw new TConfigurationException('outputcache_cachemoduleid_invalid', $this->_cacheModuleID); |
|
| 8145 | 8145 | } |
| 8146 | 8146 | else |
| 8147 | - $this->_cache=$this->getApplication()->getCache(); |
|
| 8148 | - if($this->_cache!==null) |
|
| 8147 | + $this->_cache = $this->getApplication()->getCache(); |
|
| 8148 | + if ($this->_cache !== null) |
|
| 8149 | 8149 | { |
| 8150 | - $this->_cacheAvailable=true; |
|
| 8151 | - $data=$this->_cache->get($this->getCacheKey()); |
|
| 8152 | - if(is_array($data)) |
|
| 8150 | + $this->_cacheAvailable = true; |
|
| 8151 | + $data = $this->_cache->get($this->getCacheKey()); |
|
| 8152 | + if (is_array($data)) |
|
| 8153 | 8153 | { |
| 8154 | - $param=new TOutputCacheCheckDependencyEventParameter; |
|
| 8155 | - $param->setCacheTime(isset($data[3])?$data[3]:0); |
|
| 8154 | + $param = new TOutputCacheCheckDependencyEventParameter; |
|
| 8155 | + $param->setCacheTime(isset($data[3]) ? $data[3] : 0); |
|
| 8156 | 8156 | $this->onCheckDependency($param); |
| 8157 | - $this->_dataCached=$param->getIsValid(); |
|
| 8157 | + $this->_dataCached = $param->getIsValid(); |
|
| 8158 | 8158 | } |
| 8159 | 8159 | else |
| 8160 | - $this->_dataCached=false; |
|
| 8161 | - if($this->_dataCached) |
|
| 8162 | - list($this->_contents,$this->_state,$this->_actions,$this->_cacheTime)=$data; |
|
| 8160 | + $this->_dataCached = false; |
|
| 8161 | + if ($this->_dataCached) |
|
| 8162 | + list($this->_contents, $this->_state, $this->_actions, $this->_cacheTime) = $data; |
|
| 8163 | 8163 | } |
| 8164 | 8164 | } |
| 8165 | 8165 | } |
| 8166 | 8166 | } |
| 8167 | - protected function initRecursive($namingContainer=null) |
|
| 8167 | + protected function initRecursive($namingContainer = null) |
|
| 8168 | 8168 | { |
| 8169 | - if($this->_cacheAvailable && !$this->_dataCached) |
|
| 8169 | + if ($this->_cacheAvailable && !$this->_dataCached) |
|
| 8170 | 8170 | { |
| 8171 | - $stack=$this->getPage()->getCachingStack(); |
|
| 8171 | + $stack = $this->getPage()->getCachingStack(); |
|
| 8172 | 8172 | $stack->push($this); |
| 8173 | 8173 | parent::initRecursive($namingContainer); |
| 8174 | 8174 | $stack->pop(); |
@@ -8178,39 +8178,39 @@ discard block |
||
| 8178 | 8178 | } |
| 8179 | 8179 | protected function loadRecursive() |
| 8180 | 8180 | { |
| 8181 | - if($this->_cacheAvailable && !$this->_dataCached) |
|
| 8181 | + if ($this->_cacheAvailable && !$this->_dataCached) |
|
| 8182 | 8182 | { |
| 8183 | - $stack=$this->getPage()->getCachingStack(); |
|
| 8183 | + $stack = $this->getPage()->getCachingStack(); |
|
| 8184 | 8184 | $stack->push($this); |
| 8185 | 8185 | parent::loadRecursive(); |
| 8186 | 8186 | $stack->pop(); |
| 8187 | 8187 | } |
| 8188 | 8188 | else |
| 8189 | 8189 | { |
| 8190 | - if($this->_dataCached) |
|
| 8190 | + if ($this->_dataCached) |
|
| 8191 | 8191 | $this->performActions(); |
| 8192 | 8192 | parent::loadRecursive(); |
| 8193 | 8193 | } |
| 8194 | 8194 | } |
| 8195 | 8195 | private function performActions() |
| 8196 | 8196 | { |
| 8197 | - $page=$this->getPage(); |
|
| 8198 | - $cs=$page->getClientScript(); |
|
| 8199 | - foreach($this->_actions as $action) |
|
| 8197 | + $page = $this->getPage(); |
|
| 8198 | + $cs = $page->getClientScript(); |
|
| 8199 | + foreach ($this->_actions as $action) |
|
| 8200 | 8200 | { |
| 8201 | - if($action[0]==='Page.ClientScript') |
|
| 8202 | - call_user_func_array(array($cs,$action[1]),$action[2]); |
|
| 8203 | - else if($action[0]==='Page') |
|
| 8204 | - call_user_func_array(array($page,$action[1]),$action[2]); |
|
| 8201 | + if ($action[0] === 'Page.ClientScript') |
|
| 8202 | + call_user_func_array(array($cs, $action[1]), $action[2]); |
|
| 8203 | + else if ($action[0] === 'Page') |
|
| 8204 | + call_user_func_array(array($page, $action[1]), $action[2]); |
|
| 8205 | 8205 | else |
| 8206 | - call_user_func_array(array($this->getSubProperty($action[0]),$action[1]),$action[2]); |
|
| 8206 | + call_user_func_array(array($this->getSubProperty($action[0]), $action[1]), $action[2]); |
|
| 8207 | 8207 | } |
| 8208 | 8208 | } |
| 8209 | 8209 | protected function preRenderRecursive() |
| 8210 | 8210 | { |
| 8211 | - if($this->_cacheAvailable && !$this->_dataCached) |
|
| 8211 | + if ($this->_cacheAvailable && !$this->_dataCached) |
|
| 8212 | 8212 | { |
| 8213 | - $stack=$this->getPage()->getCachingStack(); |
|
| 8213 | + $stack = $this->getPage()->getCachingStack(); |
|
| 8214 | 8214 | $stack->push($this); |
| 8215 | 8215 | parent::preRenderRecursive(); |
| 8216 | 8216 | $stack->pop(); |
@@ -8218,56 +8218,56 @@ discard block |
||
| 8218 | 8218 | else |
| 8219 | 8219 | parent::preRenderRecursive(); |
| 8220 | 8220 | } |
| 8221 | - protected function loadStateRecursive(&$state,$needViewState=true) |
|
| 8221 | + protected function loadStateRecursive(&$state, $needViewState = true) |
|
| 8222 | 8222 | { |
| 8223 | - $st=unserialize($state); |
|
| 8224 | - parent::loadStateRecursive($st,$needViewState); |
|
| 8223 | + $st = unserialize($state); |
|
| 8224 | + parent::loadStateRecursive($st, $needViewState); |
|
| 8225 | 8225 | } |
| 8226 | - protected function &saveStateRecursive($needViewState=true) |
|
| 8226 | + protected function &saveStateRecursive($needViewState = true) |
|
| 8227 | 8227 | { |
| 8228 | - if($this->_dataCached) |
|
| 8228 | + if ($this->_dataCached) |
|
| 8229 | 8229 | return $this->_state; |
| 8230 | 8230 | else |
| 8231 | 8231 | { |
| 8232 | - $st=parent::saveStateRecursive($needViewState); |
|
| 8233 | - $this->_state=serialize($st); |
|
| 8232 | + $st = parent::saveStateRecursive($needViewState); |
|
| 8233 | + $this->_state = serialize($st); |
|
| 8234 | 8234 | return $this->_state; |
| 8235 | 8235 | } |
| 8236 | 8236 | } |
| 8237 | - public function registerAction($context,$funcName,$funcParams) |
|
| 8237 | + public function registerAction($context, $funcName, $funcParams) |
|
| 8238 | 8238 | { |
| 8239 | - $this->_actions[]=array($context,$funcName,$funcParams); |
|
| 8239 | + $this->_actions[] = array($context, $funcName, $funcParams); |
|
| 8240 | 8240 | } |
| 8241 | 8241 | public function getCacheKey() |
| 8242 | 8242 | { |
| 8243 | - if($this->_cacheKey===null) |
|
| 8244 | - $this->_cacheKey=$this->calculateCacheKey(); |
|
| 8243 | + if ($this->_cacheKey === null) |
|
| 8244 | + $this->_cacheKey = $this->calculateCacheKey(); |
|
| 8245 | 8245 | return $this->_cacheKey; |
| 8246 | 8246 | } |
| 8247 | 8247 | protected function calculateCacheKey() |
| 8248 | 8248 | { |
| 8249 | - $key=$this->getBaseCacheKey(); |
|
| 8250 | - if($this->_varyBySession) |
|
| 8251 | - $key.=$this->getSession()->getSessionID(); |
|
| 8252 | - if($this->_varyByParam!=='') |
|
| 8249 | + $key = $this->getBaseCacheKey(); |
|
| 8250 | + if ($this->_varyBySession) |
|
| 8251 | + $key .= $this->getSession()->getSessionID(); |
|
| 8252 | + if ($this->_varyByParam !== '') |
|
| 8253 | 8253 | { |
| 8254 | - $params=array(); |
|
| 8255 | - $request=$this->getRequest(); |
|
| 8256 | - foreach(explode(',',$this->_varyByParam) as $name) |
|
| 8254 | + $params = array(); |
|
| 8255 | + $request = $this->getRequest(); |
|
| 8256 | + foreach (explode(',', $this->_varyByParam) as $name) |
|
| 8257 | 8257 | { |
| 8258 | - $name=trim($name); |
|
| 8259 | - $params[$name]=$request->itemAt($name); |
|
| 8258 | + $name = trim($name); |
|
| 8259 | + $params[$name] = $request->itemAt($name); |
|
| 8260 | 8260 | } |
| 8261 | - $key.=serialize($params); |
|
| 8261 | + $key .= serialize($params); |
|
| 8262 | 8262 | } |
| 8263 | - $param=new TOutputCacheCalculateKeyEventParameter; |
|
| 8263 | + $param = new TOutputCacheCalculateKeyEventParameter; |
|
| 8264 | 8264 | $this->onCalculateKey($param); |
| 8265 | - $key.=$param->getCacheKey(); |
|
| 8265 | + $key .= $param->getCacheKey(); |
|
| 8266 | 8266 | return $key; |
| 8267 | 8267 | } |
| 8268 | 8268 | protected function getBaseCacheKey() |
| 8269 | 8269 | { |
| 8270 | - return self::CACHE_ID_PREFIX.$this->_keyPrefix.$this->getPage()->getPagePath().$this->getUniqueID(); |
|
| 8270 | + return self::CACHE_ID_PREFIX . $this->_keyPrefix . $this->getPage()->getPagePath() . $this->getUniqueID(); |
|
| 8271 | 8271 | } |
| 8272 | 8272 | public function getCacheModuleID() |
| 8273 | 8273 | { |
@@ -8275,11 +8275,11 @@ discard block |
||
| 8275 | 8275 | } |
| 8276 | 8276 | public function setCacheModuleID($value) |
| 8277 | 8277 | { |
| 8278 | - $this->_cacheModuleID=$value; |
|
| 8278 | + $this->_cacheModuleID = $value; |
|
| 8279 | 8279 | } |
| 8280 | 8280 | public function setCacheKeyPrefix($value) |
| 8281 | 8281 | { |
| 8282 | - $this->_keyPrefix=$value; |
|
| 8282 | + $this->_keyPrefix = $value; |
|
| 8283 | 8283 | } |
| 8284 | 8284 | public function getCacheTime() |
| 8285 | 8285 | { |
@@ -8299,9 +8299,9 @@ discard block |
||
| 8299 | 8299 | } |
| 8300 | 8300 | public function setDuration($value) |
| 8301 | 8301 | { |
| 8302 | - if(($value=TPropertyValue::ensureInteger($value))<0) |
|
| 8303 | - throw new TInvalidDataValueException('outputcache_duration_invalid',get_class($this)); |
|
| 8304 | - $this->_duration=$value; |
|
| 8302 | + if (($value = TPropertyValue::ensureInteger($value)) < 0) |
|
| 8303 | + throw new TInvalidDataValueException('outputcache_duration_invalid', get_class($this)); |
|
| 8304 | + $this->_duration = $value; |
|
| 8305 | 8305 | } |
| 8306 | 8306 | public function getVaryByParam() |
| 8307 | 8307 | { |
@@ -8309,7 +8309,7 @@ discard block |
||
| 8309 | 8309 | } |
| 8310 | 8310 | public function setVaryByParam($value) |
| 8311 | 8311 | { |
| 8312 | - $this->_varyByParam=trim($value); |
|
| 8312 | + $this->_varyByParam = trim($value); |
|
| 8313 | 8313 | } |
| 8314 | 8314 | public function getVaryBySession() |
| 8315 | 8315 | { |
@@ -8317,7 +8317,7 @@ discard block |
||
| 8317 | 8317 | } |
| 8318 | 8318 | public function setVaryBySession($value) |
| 8319 | 8319 | { |
| 8320 | - $this->_varyBySession=TPropertyValue::ensureBoolean($value); |
|
| 8320 | + $this->_varyBySession = TPropertyValue::ensureBoolean($value); |
|
| 8321 | 8321 | } |
| 8322 | 8322 | public function getCachingPostBack() |
| 8323 | 8323 | { |
@@ -8325,32 +8325,32 @@ discard block |
||
| 8325 | 8325 | } |
| 8326 | 8326 | public function setCachingPostBack($value) |
| 8327 | 8327 | { |
| 8328 | - $this->_cachePostBack=TPropertyValue::ensureBoolean($value); |
|
| 8328 | + $this->_cachePostBack = TPropertyValue::ensureBoolean($value); |
|
| 8329 | 8329 | } |
| 8330 | 8330 | public function onCheckDependency($param) |
| 8331 | 8331 | { |
| 8332 | - $this->raiseEvent('OnCheckDependency',$this,$param); |
|
| 8332 | + $this->raiseEvent('OnCheckDependency', $this, $param); |
|
| 8333 | 8333 | } |
| 8334 | 8334 | public function onCalculateKey($param) |
| 8335 | 8335 | { |
| 8336 | - $this->raiseEvent('OnCalculateKey',$this,$param); |
|
| 8336 | + $this->raiseEvent('OnCalculateKey', $this, $param); |
|
| 8337 | 8337 | } |
| 8338 | 8338 | public function render($writer) |
| 8339 | 8339 | { |
| 8340 | - if($this->_dataCached) |
|
| 8340 | + if ($this->_dataCached) |
|
| 8341 | 8341 | $writer->write($this->_contents); |
| 8342 | - else if($this->_cacheAvailable) |
|
| 8342 | + else if ($this->_cacheAvailable) |
|
| 8343 | 8343 | { |
| 8344 | 8344 | $textwriter = new TTextWriter(); |
| 8345 | - $multiwriter = new TOutputCacheTextWriterMulti(array($writer->getWriter(),$textwriter)); |
|
| 8345 | + $multiwriter = new TOutputCacheTextWriterMulti(array($writer->getWriter(), $textwriter)); |
|
| 8346 | 8346 | $htmlWriter = Prado::createComponent($this->GetResponse()->getHtmlWriterType(), $multiwriter); |
| 8347 | - $stack=$this->getPage()->getCachingStack(); |
|
| 8347 | + $stack = $this->getPage()->getCachingStack(); |
|
| 8348 | 8348 | $stack->push($this); |
| 8349 | 8349 | parent::render($htmlWriter); |
| 8350 | 8350 | $stack->pop(); |
| 8351 | - $content=$textwriter->flush(); |
|
| 8352 | - $data=array($content,$this->_state,$this->_actions,time()); |
|
| 8353 | - $this->_cache->set($this->getCacheKey(),$data,$this->getDuration(),$this->getCacheDependency()); |
|
| 8351 | + $content = $textwriter->flush(); |
|
| 8352 | + $data = array($content, $this->_state, $this->_actions, time()); |
|
| 8353 | + $this->_cache->set($this->getCacheKey(), $data, $this->getDuration(), $this->getCacheDependency()); |
|
| 8354 | 8354 | } |
| 8355 | 8355 | else |
| 8356 | 8356 | parent::render($writer); |
@@ -8358,15 +8358,15 @@ discard block |
||
| 8358 | 8358 | } |
| 8359 | 8359 | class TOutputCacheCheckDependencyEventParameter extends TEventParameter |
| 8360 | 8360 | { |
| 8361 | - private $_isValid=true; |
|
| 8362 | - private $_cacheTime=0; |
|
| 8361 | + private $_isValid = true; |
|
| 8362 | + private $_cacheTime = 0; |
|
| 8363 | 8363 | public function getIsValid() |
| 8364 | 8364 | { |
| 8365 | 8365 | return $this->_isValid; |
| 8366 | 8366 | } |
| 8367 | 8367 | public function setIsValid($value) |
| 8368 | 8368 | { |
| 8369 | - $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
| 8369 | + $this->_isValid = TPropertyValue::ensureBoolean($value); |
|
| 8370 | 8370 | } |
| 8371 | 8371 | public function getCacheTime() |
| 8372 | 8372 | { |
@@ -8374,19 +8374,19 @@ discard block |
||
| 8374 | 8374 | } |
| 8375 | 8375 | public function setCacheTime($value) |
| 8376 | 8376 | { |
| 8377 | - $this->_cacheTime=TPropertyValue::ensureInteger($value); |
|
| 8377 | + $this->_cacheTime = TPropertyValue::ensureInteger($value); |
|
| 8378 | 8378 | } |
| 8379 | 8379 | } |
| 8380 | 8380 | class TOutputCacheCalculateKeyEventParameter extends TEventParameter |
| 8381 | 8381 | { |
| 8382 | - private $_cacheKey=''; |
|
| 8382 | + private $_cacheKey = ''; |
|
| 8383 | 8383 | public function getCacheKey() |
| 8384 | 8384 | { |
| 8385 | 8385 | return $this->_cacheKey; |
| 8386 | 8386 | } |
| 8387 | 8387 | public function setCacheKey($value) |
| 8388 | 8388 | { |
| 8389 | - $this->_cacheKey=TPropertyValue::ensureString($value); |
|
| 8389 | + $this->_cacheKey = TPropertyValue::ensureString($value); |
|
| 8390 | 8390 | } |
| 8391 | 8391 | } |
| 8392 | 8392 | class TOutputCacheTextWriterMulti extends TTextWriter |
@@ -8398,63 +8398,63 @@ discard block |
||
| 8398 | 8398 | } |
| 8399 | 8399 | public function write($s) |
| 8400 | 8400 | { |
| 8401 | - foreach($this->_writers as $writer) |
|
| 8401 | + foreach ($this->_writers as $writer) |
|
| 8402 | 8402 | $writer->write($s); |
| 8403 | 8403 | } |
| 8404 | 8404 | public function flush() |
| 8405 | 8405 | { |
| 8406 | - foreach($this->_writers as $writer) |
|
| 8406 | + foreach ($this->_writers as $writer) |
|
| 8407 | 8407 | $s = $writer->flush(); |
| 8408 | 8408 | return $s; |
| 8409 | 8409 | } |
| 8410 | 8410 | } |
| 8411 | 8411 | class TTemplateManager extends TModule |
| 8412 | 8412 | { |
| 8413 | - const TEMPLATE_FILE_EXT='.tpl'; |
|
| 8414 | - const TEMPLATE_CACHE_PREFIX='prado:template:'; |
|
| 8413 | + const TEMPLATE_FILE_EXT = '.tpl'; |
|
| 8414 | + const TEMPLATE_CACHE_PREFIX = 'prado:template:'; |
|
| 8415 | 8415 | public function init($config) |
| 8416 | 8416 | { |
| 8417 | 8417 | $this->getService()->setTemplateManager($this); |
| 8418 | 8418 | } |
| 8419 | 8419 | public function getTemplateByClassName($className) |
| 8420 | 8420 | { |
| 8421 | - $class=new ReflectionClass($className); |
|
| 8422 | - $tplFile=dirname($class->getFileName()).DIRECTORY_SEPARATOR.$className.self::TEMPLATE_FILE_EXT; |
|
| 8421 | + $class = new ReflectionClass($className); |
|
| 8422 | + $tplFile = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . $className . self::TEMPLATE_FILE_EXT; |
|
| 8423 | 8423 | return $this->getTemplateByFileName($tplFile); |
| 8424 | 8424 | } |
| 8425 | 8425 | public function getTemplateByFileName($fileName) |
| 8426 | 8426 | { |
| 8427 | - if(($fileName=$this->getLocalizedTemplate($fileName))!==null) |
|
| 8427 | + if (($fileName = $this->getLocalizedTemplate($fileName)) !== null) |
|
| 8428 | 8428 | { |
| 8429 | - if(($cache=$this->getApplication()->getCache())===null) |
|
| 8430 | - return new TTemplate(file_get_contents($fileName),dirname($fileName),$fileName); |
|
| 8429 | + if (($cache = $this->getApplication()->getCache()) === null) |
|
| 8430 | + return new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); |
|
| 8431 | 8431 | else |
| 8432 | 8432 | { |
| 8433 | - $array=$cache->get(self::TEMPLATE_CACHE_PREFIX.$fileName); |
|
| 8434 | - if(is_array($array)) |
|
| 8433 | + $array = $cache->get(self::TEMPLATE_CACHE_PREFIX . $fileName); |
|
| 8434 | + if (is_array($array)) |
|
| 8435 | 8435 | { |
| 8436 | - list($template,$timestamps)=$array; |
|
| 8437 | - if($this->getApplication()->getMode()===TApplicationMode::Performance) |
|
| 8436 | + list($template, $timestamps) = $array; |
|
| 8437 | + if ($this->getApplication()->getMode() === TApplicationMode::Performance) |
|
| 8438 | 8438 | return $template; |
| 8439 | - $cacheValid=true; |
|
| 8440 | - foreach($timestamps as $tplFile=>$timestamp) |
|
| 8439 | + $cacheValid = true; |
|
| 8440 | + foreach ($timestamps as $tplFile=>$timestamp) |
|
| 8441 | 8441 | { |
| 8442 | - if(!is_file($tplFile) || filemtime($tplFile)>$timestamp) |
|
| 8442 | + if (!is_file($tplFile) || filemtime($tplFile) > $timestamp) |
|
| 8443 | 8443 | { |
| 8444 | - $cacheValid=false; |
|
| 8444 | + $cacheValid = false; |
|
| 8445 | 8445 | break; |
| 8446 | 8446 | } |
| 8447 | 8447 | } |
| 8448 | - if($cacheValid) |
|
| 8448 | + if ($cacheValid) |
|
| 8449 | 8449 | return $template; |
| 8450 | 8450 | } |
| 8451 | - $template=new TTemplate(file_get_contents($fileName),dirname($fileName),$fileName); |
|
| 8452 | - $includedFiles=$template->getIncludedFiles(); |
|
| 8453 | - $timestamps=array(); |
|
| 8454 | - $timestamps[$fileName]=filemtime($fileName); |
|
| 8455 | - foreach($includedFiles as $includedFile) |
|
| 8456 | - $timestamps[$includedFile]=filemtime($includedFile); |
|
| 8457 | - $cache->set(self::TEMPLATE_CACHE_PREFIX.$fileName,array($template,$timestamps)); |
|
| 8451 | + $template = new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); |
|
| 8452 | + $includedFiles = $template->getIncludedFiles(); |
|
| 8453 | + $timestamps = array(); |
|
| 8454 | + $timestamps[$fileName] = filemtime($fileName); |
|
| 8455 | + foreach ($includedFiles as $includedFile) |
|
| 8456 | + $timestamps[$includedFile] = filemtime($includedFile); |
|
| 8457 | + $cache->set(self::TEMPLATE_CACHE_PREFIX . $fileName, array($template, $timestamps)); |
|
| 8458 | 8458 | return $template; |
| 8459 | 8459 | } |
| 8460 | 8460 | } |
@@ -8463,11 +8463,11 @@ discard block |
||
| 8463 | 8463 | } |
| 8464 | 8464 | protected function getLocalizedTemplate($filename) |
| 8465 | 8465 | { |
| 8466 | - if(($app=$this->getApplication()->getGlobalization(false))===null) |
|
| 8467 | - return is_file($filename)?$filename:null; |
|
| 8468 | - foreach($app->getLocalizedResource($filename) as $file) |
|
| 8466 | + if (($app = $this->getApplication()->getGlobalization(false)) === null) |
|
| 8467 | + return is_file($filename) ? $filename : null; |
|
| 8468 | + foreach ($app->getLocalizedResource($filename) as $file) |
|
| 8469 | 8469 | { |
| 8470 | - if(($file=realpath($file))!==false && is_file($file)) |
|
| 8470 | + if (($file = realpath($file)) !== false && is_file($file)) |
|
| 8471 | 8471 | return $file; |
| 8472 | 8472 | } |
| 8473 | 8473 | return null; |
@@ -8475,35 +8475,35 @@ discard block |
||
| 8475 | 8475 | } |
| 8476 | 8476 | class TTemplate extends TApplicationComponent implements ITemplate |
| 8477 | 8477 | { |
| 8478 | - const REGEX_RULES='/<!--.*?--!>|<!---.*?--->|<\/?com:([\w\.]+)((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?"|\s*[\w\.]+\s*=\s*<%.*?%>)*)\s*\/?>|<\/?prop:([\w\.]+)\s*>|<%@\s*((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?")*)\s*%>|<%[%#~\/\\$=\\[](.*?)%>|<prop:([\w\.]+)((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?"|\s*[\w\.]+\s*=\s*<%.*?%>)*)\s*\/>/msS'; |
|
| 8479 | - const CONFIG_DATABIND=0; |
|
| 8480 | - const CONFIG_EXPRESSION=1; |
|
| 8481 | - const CONFIG_ASSET=2; |
|
| 8482 | - const CONFIG_PARAMETER=3; |
|
| 8483 | - const CONFIG_LOCALIZATION=4; |
|
| 8484 | - const CONFIG_TEMPLATE=5; |
|
| 8485 | - private $_tpl=array(); |
|
| 8486 | - private $_directive=array(); |
|
| 8478 | + const REGEX_RULES = '/<!--.*?--!>|<!---.*?--->|<\/?com:([\w\.]+)((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?"|\s*[\w\.]+\s*=\s*<%.*?%>)*)\s*\/?>|<\/?prop:([\w\.]+)\s*>|<%@\s*((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?")*)\s*%>|<%[%#~\/\\$=\\[](.*?)%>|<prop:([\w\.]+)((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?"|\s*[\w\.]+\s*=\s*<%.*?%>)*)\s*\/>/msS'; |
|
| 8479 | + const CONFIG_DATABIND = 0; |
|
| 8480 | + const CONFIG_EXPRESSION = 1; |
|
| 8481 | + const CONFIG_ASSET = 2; |
|
| 8482 | + const CONFIG_PARAMETER = 3; |
|
| 8483 | + const CONFIG_LOCALIZATION = 4; |
|
| 8484 | + const CONFIG_TEMPLATE = 5; |
|
| 8485 | + private $_tpl = array(); |
|
| 8486 | + private $_directive = array(); |
|
| 8487 | 8487 | private $_contextPath; |
| 8488 | - private $_tplFile=null; |
|
| 8489 | - private $_startingLine=0; |
|
| 8488 | + private $_tplFile = null; |
|
| 8489 | + private $_startingLine = 0; |
|
| 8490 | 8490 | private $_content; |
| 8491 | - private $_sourceTemplate=true; |
|
| 8492 | - private $_hashCode=''; |
|
| 8493 | - private $_tplControl=null; |
|
| 8494 | - private $_includedFiles=array(); |
|
| 8495 | - private $_includeAtLine=array(); |
|
| 8496 | - private $_includeLines=array(); |
|
| 8497 | - public function __construct($template,$contextPath,$tplFile=null,$startingLine=0,$sourceTemplate=true) |
|
| 8498 | - { |
|
| 8499 | - $this->_sourceTemplate=$sourceTemplate; |
|
| 8500 | - $this->_contextPath=$contextPath; |
|
| 8501 | - $this->_tplFile=$tplFile; |
|
| 8502 | - $this->_startingLine=$startingLine; |
|
| 8503 | - $this->_content=$template; |
|
| 8504 | - $this->_hashCode=md5($template); |
|
| 8491 | + private $_sourceTemplate = true; |
|
| 8492 | + private $_hashCode = ''; |
|
| 8493 | + private $_tplControl = null; |
|
| 8494 | + private $_includedFiles = array(); |
|
| 8495 | + private $_includeAtLine = array(); |
|
| 8496 | + private $_includeLines = array(); |
|
| 8497 | + public function __construct($template, $contextPath, $tplFile = null, $startingLine = 0, $sourceTemplate = true) |
|
| 8498 | + { |
|
| 8499 | + $this->_sourceTemplate = $sourceTemplate; |
|
| 8500 | + $this->_contextPath = $contextPath; |
|
| 8501 | + $this->_tplFile = $tplFile; |
|
| 8502 | + $this->_startingLine = $startingLine; |
|
| 8503 | + $this->_content = $template; |
|
| 8504 | + $this->_hashCode = md5($template); |
|
| 8505 | 8505 | $this->parse($template); |
| 8506 | - $this->_content=null; } |
|
| 8506 | + $this->_content = null; } |
|
| 8507 | 8507 | public function getTemplateFile() |
| 8508 | 8508 | { |
| 8509 | 8509 | return $this->_tplFile; |
@@ -8528,40 +8528,40 @@ discard block |
||
| 8528 | 8528 | { |
| 8529 | 8529 | return $this->_tpl; |
| 8530 | 8530 | } |
| 8531 | - public function instantiateIn($tplControl,$parentControl=null) |
|
| 8532 | - { |
|
| 8533 | - $this->_tplControl=$tplControl; |
|
| 8534 | - if($parentControl===null) |
|
| 8535 | - $parentControl=$tplControl; |
|
| 8536 | - if(($page=$tplControl->getPage())===null) |
|
| 8537 | - $page=$this->getService()->getRequestedPage(); |
|
| 8538 | - $controls=array(); |
|
| 8539 | - $directChildren=array(); |
|
| 8540 | - foreach($this->_tpl as $key=>$object) |
|
| 8541 | - { |
|
| 8542 | - if($object[0]===-1) |
|
| 8543 | - $parent=$parentControl; |
|
| 8544 | - else if(isset($controls[$object[0]])) |
|
| 8545 | - $parent=$controls[$object[0]]; |
|
| 8531 | + public function instantiateIn($tplControl, $parentControl = null) |
|
| 8532 | + { |
|
| 8533 | + $this->_tplControl = $tplControl; |
|
| 8534 | + if ($parentControl === null) |
|
| 8535 | + $parentControl = $tplControl; |
|
| 8536 | + if (($page = $tplControl->getPage()) === null) |
|
| 8537 | + $page = $this->getService()->getRequestedPage(); |
|
| 8538 | + $controls = array(); |
|
| 8539 | + $directChildren = array(); |
|
| 8540 | + foreach ($this->_tpl as $key=>$object) |
|
| 8541 | + { |
|
| 8542 | + if ($object[0] === -1) |
|
| 8543 | + $parent = $parentControl; |
|
| 8544 | + else if (isset($controls[$object[0]])) |
|
| 8545 | + $parent = $controls[$object[0]]; |
|
| 8546 | 8546 | else |
| 8547 | 8547 | continue; |
| 8548 | - if(isset($object[2])) { |
|
| 8549 | - $component=Prado::createComponent($object[1]); |
|
| 8550 | - $properties=&$object[2]; |
|
| 8551 | - if($component instanceof TControl) |
|
| 8548 | + if (isset($object[2])) { |
|
| 8549 | + $component = Prado::createComponent($object[1]); |
|
| 8550 | + $properties = &$object[2]; |
|
| 8551 | + if ($component instanceof TControl) |
|
| 8552 | 8552 | { |
| 8553 | - if($component instanceof TOutputCache) |
|
| 8554 | - $component->setCacheKeyPrefix($this->_hashCode.$key); |
|
| 8553 | + if ($component instanceof TOutputCache) |
|
| 8554 | + $component->setCacheKeyPrefix($this->_hashCode . $key); |
|
| 8555 | 8555 | $component->setTemplateControl($tplControl); |
| 8556 | - if(isset($properties['id'])) |
|
| 8556 | + if (isset($properties['id'])) |
|
| 8557 | 8557 | { |
| 8558 | - if(is_array($properties['id'])) |
|
| 8559 | - $properties['id']=$component->evaluateExpression($properties['id'][1]); |
|
| 8560 | - $tplControl->registerObject($properties['id'],$component); |
|
| 8558 | + if (is_array($properties['id'])) |
|
| 8559 | + $properties['id'] = $component->evaluateExpression($properties['id'][1]); |
|
| 8560 | + $tplControl->registerObject($properties['id'], $component); |
|
| 8561 | 8561 | } |
| 8562 | - if(isset($properties['skinid'])) |
|
| 8562 | + if (isset($properties['skinid'])) |
|
| 8563 | 8563 | { |
| 8564 | - if(is_array($properties['skinid'])) |
|
| 8564 | + if (is_array($properties['skinid'])) |
|
| 8565 | 8565 | $component->setSkinID($component->evaluateExpression($properties['skinid'][1])); |
| 8566 | 8566 | else |
| 8567 | 8567 | $component->setSkinID($properties['skinid']); |
@@ -8569,558 +8569,558 @@ discard block |
||
| 8569 | 8569 | } |
| 8570 | 8570 | $component->trackViewState(false); |
| 8571 | 8571 | $component->applyStyleSheetSkin($page); |
| 8572 | - foreach($properties as $name=>$value) |
|
| 8573 | - $this->configureControl($component,$name,$value); |
|
| 8572 | + foreach ($properties as $name=>$value) |
|
| 8573 | + $this->configureControl($component, $name, $value); |
|
| 8574 | 8574 | $component->trackViewState(true); |
| 8575 | - if($parent===$parentControl) |
|
| 8576 | - $directChildren[]=$component; |
|
| 8575 | + if ($parent === $parentControl) |
|
| 8576 | + $directChildren[] = $component; |
|
| 8577 | 8577 | else |
| 8578 | 8578 | $component->createdOnTemplate($parent); |
| 8579 | - if($component->getAllowChildControls()) |
|
| 8580 | - $controls[$key]=$component; |
|
| 8579 | + if ($component->getAllowChildControls()) |
|
| 8580 | + $controls[$key] = $component; |
|
| 8581 | 8581 | } |
| 8582 | - else if($component instanceof TComponent) |
|
| 8582 | + else if ($component instanceof TComponent) |
|
| 8583 | 8583 | { |
| 8584 | - $controls[$key]=$component; |
|
| 8585 | - if(isset($properties['id'])) |
|
| 8584 | + $controls[$key] = $component; |
|
| 8585 | + if (isset($properties['id'])) |
|
| 8586 | 8586 | { |
| 8587 | - if(is_array($properties['id'])) |
|
| 8588 | - $properties['id']=$component->evaluateExpression($properties['id'][1]); |
|
| 8589 | - $tplControl->registerObject($properties['id'],$component); |
|
| 8590 | - if(!$component->hasProperty('id')) |
|
| 8587 | + if (is_array($properties['id'])) |
|
| 8588 | + $properties['id'] = $component->evaluateExpression($properties['id'][1]); |
|
| 8589 | + $tplControl->registerObject($properties['id'], $component); |
|
| 8590 | + if (!$component->hasProperty('id')) |
|
| 8591 | 8591 | unset($properties['id']); |
| 8592 | 8592 | } |
| 8593 | - foreach($properties as $name=>$value) |
|
| 8594 | - $this->configureComponent($component,$name,$value); |
|
| 8595 | - if($parent===$parentControl) |
|
| 8596 | - $directChildren[]=$component; |
|
| 8593 | + foreach ($properties as $name=>$value) |
|
| 8594 | + $this->configureComponent($component, $name, $value); |
|
| 8595 | + if ($parent === $parentControl) |
|
| 8596 | + $directChildren[] = $component; |
|
| 8597 | 8597 | else |
| 8598 | 8598 | $component->createdOnTemplate($parent); |
| 8599 | 8599 | } |
| 8600 | 8600 | } |
| 8601 | 8601 | else |
| 8602 | 8602 | { |
| 8603 | - if($object[1] instanceof TCompositeLiteral) |
|
| 8603 | + if ($object[1] instanceof TCompositeLiteral) |
|
| 8604 | 8604 | { |
| 8605 | - $o=clone $object[1]; |
|
| 8605 | + $o = clone $object[1]; |
|
| 8606 | 8606 | $o->setContainer($tplControl); |
| 8607 | - if($parent===$parentControl) |
|
| 8608 | - $directChildren[]=$o; |
|
| 8607 | + if ($parent === $parentControl) |
|
| 8608 | + $directChildren[] = $o; |
|
| 8609 | 8609 | else |
| 8610 | 8610 | $parent->addParsedObject($o); |
| 8611 | 8611 | } |
| 8612 | 8612 | else |
| 8613 | 8613 | { |
| 8614 | - if($parent===$parentControl) |
|
| 8615 | - $directChildren[]=$object[1]; |
|
| 8614 | + if ($parent === $parentControl) |
|
| 8615 | + $directChildren[] = $object[1]; |
|
| 8616 | 8616 | else |
| 8617 | 8617 | $parent->addParsedObject($object[1]); |
| 8618 | 8618 | } |
| 8619 | 8619 | } |
| 8620 | 8620 | } |
| 8621 | - foreach($directChildren as $control) |
|
| 8621 | + foreach ($directChildren as $control) |
|
| 8622 | 8622 | { |
| 8623 | - if($control instanceof TComponent) |
|
| 8623 | + if ($control instanceof TComponent) |
|
| 8624 | 8624 | $control->createdOnTemplate($parentControl); |
| 8625 | 8625 | else |
| 8626 | 8626 | $parentControl->addParsedObject($control); |
| 8627 | 8627 | } |
| 8628 | 8628 | } |
| 8629 | - protected function configureControl($control,$name,$value) |
|
| 8629 | + protected function configureControl($control, $name, $value) |
|
| 8630 | 8630 | { |
| 8631 | - if(strncasecmp($name,'on',2)===0) $this->configureEvent($control,$name,$value,$control); |
|
| 8632 | - else if(($pos=strrpos($name,'.'))===false) $this->configureProperty($control,$name,$value); |
|
| 8633 | - else $this->configureSubProperty($control,$name,$value); |
|
| 8631 | + if (strncasecmp($name, 'on', 2) === 0) $this->configureEvent($control, $name, $value, $control); |
|
| 8632 | + else if (($pos = strrpos($name, '.')) === false) $this->configureProperty($control, $name, $value); |
|
| 8633 | + else $this->configureSubProperty($control, $name, $value); |
|
| 8634 | 8634 | } |
| 8635 | - protected function configureComponent($component,$name,$value) |
|
| 8635 | + protected function configureComponent($component, $name, $value) |
|
| 8636 | 8636 | { |
| 8637 | - if(strpos($name,'.')===false) $this->configureProperty($component,$name,$value); |
|
| 8638 | - else $this->configureSubProperty($component,$name,$value); |
|
| 8637 | + if (strpos($name, '.') === false) $this->configureProperty($component, $name, $value); |
|
| 8638 | + else $this->configureSubProperty($component, $name, $value); |
|
| 8639 | 8639 | } |
| 8640 | - protected function configureEvent($control,$name,$value,$contextControl) |
|
| 8640 | + protected function configureEvent($control, $name, $value, $contextControl) |
|
| 8641 | 8641 | { |
| 8642 | - if(strpos($value,'.')===false) |
|
| 8643 | - $control->attachEventHandler($name,array($contextControl,'TemplateControl.'.$value)); |
|
| 8642 | + if (strpos($value, '.') === false) |
|
| 8643 | + $control->attachEventHandler($name, array($contextControl, 'TemplateControl.' . $value)); |
|
| 8644 | 8644 | else |
| 8645 | - $control->attachEventHandler($name,array($contextControl,$value)); |
|
| 8645 | + $control->attachEventHandler($name, array($contextControl, $value)); |
|
| 8646 | 8646 | } |
| 8647 | - protected function configureProperty($component,$name,$value) |
|
| 8647 | + protected function configureProperty($component, $name, $value) |
|
| 8648 | 8648 | { |
| 8649 | - if(is_array($value)) |
|
| 8649 | + if (is_array($value)) |
|
| 8650 | 8650 | { |
| 8651 | - switch($value[0]) |
|
| 8651 | + switch ($value[0]) |
|
| 8652 | 8652 | { |
| 8653 | 8653 | case self::CONFIG_DATABIND: |
| 8654 | - $component->bindProperty($name,$value[1]); |
|
| 8654 | + $component->bindProperty($name, $value[1]); |
|
| 8655 | 8655 | break; |
| 8656 | 8656 | case self::CONFIG_EXPRESSION: |
| 8657 | - if($component instanceof TControl) |
|
| 8658 | - $component->autoBindProperty($name,$value[1]); |
|
| 8657 | + if ($component instanceof TControl) |
|
| 8658 | + $component->autoBindProperty($name, $value[1]); |
|
| 8659 | 8659 | else |
| 8660 | 8660 | { |
| 8661 | - $setter='set'.$name; |
|
| 8661 | + $setter = 'set' . $name; |
|
| 8662 | 8662 | $component->$setter($this->_tplControl->evaluateExpression($value[1])); |
| 8663 | 8663 | } |
| 8664 | 8664 | break; |
| 8665 | 8665 | case self::CONFIG_TEMPLATE: |
| 8666 | - $setter='set'.$name; |
|
| 8666 | + $setter = 'set' . $name; |
|
| 8667 | 8667 | $component->$setter($value[1]); |
| 8668 | 8668 | break; |
| 8669 | - case self::CONFIG_ASSET: $setter='set'.$name; |
|
| 8670 | - $url=$this->publishFilePath($this->_contextPath.DIRECTORY_SEPARATOR.$value[1]); |
|
| 8669 | + case self::CONFIG_ASSET: $setter = 'set' . $name; |
|
| 8670 | + $url = $this->publishFilePath($this->_contextPath . DIRECTORY_SEPARATOR . $value[1]); |
|
| 8671 | 8671 | $component->$setter($url); |
| 8672 | 8672 | break; |
| 8673 | - case self::CONFIG_PARAMETER: $setter='set'.$name; |
|
| 8673 | + case self::CONFIG_PARAMETER: $setter = 'set' . $name; |
|
| 8674 | 8674 | $component->$setter($this->getApplication()->getParameters()->itemAt($value[1])); |
| 8675 | 8675 | break; |
| 8676 | 8676 | case self::CONFIG_LOCALIZATION: |
| 8677 | - $setter='set'.$name; |
|
| 8677 | + $setter = 'set' . $name; |
|
| 8678 | 8678 | $component->$setter(Prado::localize($value[1])); |
| 8679 | 8679 | break; |
| 8680 | - default: throw new TConfigurationException('template_tag_unexpected',$name,$value[1]); |
|
| 8680 | + default: throw new TConfigurationException('template_tag_unexpected', $name, $value[1]); |
|
| 8681 | 8681 | break; |
| 8682 | 8682 | } |
| 8683 | 8683 | } |
| 8684 | 8684 | else |
| 8685 | 8685 | { |
| 8686 | - if (substr($name,0,2)=='js') |
|
| 8686 | + if (substr($name, 0, 2) == 'js') |
|
| 8687 | 8687 | if ($value and !($value instanceof TJavaScriptLiteral)) |
| 8688 | 8688 | $value = new TJavaScriptLiteral($value); |
| 8689 | - $setter='set'.$name; |
|
| 8689 | + $setter = 'set' . $name; |
|
| 8690 | 8690 | $component->$setter($value); |
| 8691 | 8691 | } |
| 8692 | 8692 | } |
| 8693 | - protected function configureSubProperty($component,$name,$value) |
|
| 8693 | + protected function configureSubProperty($component, $name, $value) |
|
| 8694 | 8694 | { |
| 8695 | - if(is_array($value)) |
|
| 8695 | + if (is_array($value)) |
|
| 8696 | 8696 | { |
| 8697 | - switch($value[0]) |
|
| 8697 | + switch ($value[0]) |
|
| 8698 | 8698 | { |
| 8699 | - case self::CONFIG_DATABIND: $component->bindProperty($name,$value[1]); |
|
| 8699 | + case self::CONFIG_DATABIND: $component->bindProperty($name, $value[1]); |
|
| 8700 | 8700 | break; |
| 8701 | - case self::CONFIG_EXPRESSION: if($component instanceof TControl) |
|
| 8702 | - $component->autoBindProperty($name,$value[1]); |
|
| 8701 | + case self::CONFIG_EXPRESSION: if ($component instanceof TControl) |
|
| 8702 | + $component->autoBindProperty($name, $value[1]); |
|
| 8703 | 8703 | else |
| 8704 | - $component->setSubProperty($name,$this->_tplControl->evaluateExpression($value[1])); |
|
| 8704 | + $component->setSubProperty($name, $this->_tplControl->evaluateExpression($value[1])); |
|
| 8705 | 8705 | break; |
| 8706 | 8706 | case self::CONFIG_TEMPLATE: |
| 8707 | - $component->setSubProperty($name,$value[1]); |
|
| 8707 | + $component->setSubProperty($name, $value[1]); |
|
| 8708 | 8708 | break; |
| 8709 | - case self::CONFIG_ASSET: $url=$this->publishFilePath($this->_contextPath.DIRECTORY_SEPARATOR.$value[1]); |
|
| 8710 | - $component->setSubProperty($name,$url); |
|
| 8709 | + case self::CONFIG_ASSET: $url = $this->publishFilePath($this->_contextPath . DIRECTORY_SEPARATOR . $value[1]); |
|
| 8710 | + $component->setSubProperty($name, $url); |
|
| 8711 | 8711 | break; |
| 8712 | - case self::CONFIG_PARAMETER: $component->setSubProperty($name,$this->getApplication()->getParameters()->itemAt($value[1])); |
|
| 8712 | + case self::CONFIG_PARAMETER: $component->setSubProperty($name, $this->getApplication()->getParameters()->itemAt($value[1])); |
|
| 8713 | 8713 | break; |
| 8714 | 8714 | case self::CONFIG_LOCALIZATION: |
| 8715 | - $component->setSubProperty($name,Prado::localize($value[1])); |
|
| 8715 | + $component->setSubProperty($name, Prado::localize($value[1])); |
|
| 8716 | 8716 | break; |
| 8717 | - default: throw new TConfigurationException('template_tag_unexpected',$name,$value[1]); |
|
| 8717 | + default: throw new TConfigurationException('template_tag_unexpected', $name, $value[1]); |
|
| 8718 | 8718 | break; |
| 8719 | 8719 | } |
| 8720 | 8720 | } |
| 8721 | 8721 | else |
| 8722 | - $component->setSubProperty($name,$value); |
|
| 8722 | + $component->setSubProperty($name, $value); |
|
| 8723 | 8723 | } |
| 8724 | 8724 | protected function parse($input) |
| 8725 | 8725 | { |
| 8726 | - $input=$this->preprocess($input); |
|
| 8727 | - $tpl=&$this->_tpl; |
|
| 8728 | - $n=preg_match_all(self::REGEX_RULES,$input,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE); |
|
| 8729 | - $expectPropEnd=false; |
|
| 8730 | - $textStart=0; |
|
| 8731 | - $stack=array(); |
|
| 8732 | - $container=-1; |
|
| 8733 | - $matchEnd=0; |
|
| 8734 | - $c=0; |
|
| 8735 | - $this->_directive=null; |
|
| 8726 | + $input = $this->preprocess($input); |
|
| 8727 | + $tpl = &$this->_tpl; |
|
| 8728 | + $n = preg_match_all(self::REGEX_RULES, $input, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE); |
|
| 8729 | + $expectPropEnd = false; |
|
| 8730 | + $textStart = 0; |
|
| 8731 | + $stack = array(); |
|
| 8732 | + $container = -1; |
|
| 8733 | + $matchEnd = 0; |
|
| 8734 | + $c = 0; |
|
| 8735 | + $this->_directive = null; |
|
| 8736 | 8736 | try |
| 8737 | 8737 | { |
| 8738 | - for($i=0;$i<$n;++$i) |
|
| 8738 | + for ($i = 0; $i < $n; ++$i) |
|
| 8739 | 8739 | { |
| 8740 | - $match=&$matches[$i]; |
|
| 8741 | - $str=$match[0][0]; |
|
| 8742 | - $matchStart=$match[0][1]; |
|
| 8743 | - $matchEnd=$matchStart+strlen($str)-1; |
|
| 8744 | - if(strpos($str,'<com:')===0) { |
|
| 8745 | - if($expectPropEnd) |
|
| 8740 | + $match = &$matches[$i]; |
|
| 8741 | + $str = $match[0][0]; |
|
| 8742 | + $matchStart = $match[0][1]; |
|
| 8743 | + $matchEnd = $matchStart + strlen($str) - 1; |
|
| 8744 | + if (strpos($str, '<com:') === 0) { |
|
| 8745 | + if ($expectPropEnd) |
|
| 8746 | 8746 | continue; |
| 8747 | - if($matchStart>$textStart) |
|
| 8748 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
| 8749 | - $textStart=$matchEnd+1; |
|
| 8750 | - $type=$match[1][0]; |
|
| 8751 | - $attributes=$this->parseAttributes($match[2][0],$match[2][1]); |
|
| 8752 | - $this->validateAttributes($type,$attributes); |
|
| 8753 | - $tpl[$c++]=array($container,$type,$attributes); |
|
| 8754 | - if($str[strlen($str)-2]!=='/') { |
|
| 8747 | + if ($matchStart > $textStart) |
|
| 8748 | + $tpl[$c++] = array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
| 8749 | + $textStart = $matchEnd + 1; |
|
| 8750 | + $type = $match[1][0]; |
|
| 8751 | + $attributes = $this->parseAttributes($match[2][0], $match[2][1]); |
|
| 8752 | + $this->validateAttributes($type, $attributes); |
|
| 8753 | + $tpl[$c++] = array($container, $type, $attributes); |
|
| 8754 | + if ($str[strlen($str) - 2] !== '/') { |
|
| 8755 | 8755 | $stack[] = $type; |
| 8756 | - $container=$c-1; |
|
| 8756 | + $container = $c - 1; |
|
| 8757 | 8757 | } |
| 8758 | 8758 | } |
| 8759 | - else if(strpos($str,'</com:')===0) { |
|
| 8760 | - if($expectPropEnd) |
|
| 8759 | + else if (strpos($str, '</com:') === 0) { |
|
| 8760 | + if ($expectPropEnd) |
|
| 8761 | 8761 | continue; |
| 8762 | - if($matchStart>$textStart) |
|
| 8763 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
| 8764 | - $textStart=$matchEnd+1; |
|
| 8765 | - $type=$match[1][0]; |
|
| 8766 | - if(empty($stack)) |
|
| 8767 | - throw new TConfigurationException('template_closingtag_unexpected',"</com:$type>"); |
|
| 8768 | - $name=array_pop($stack); |
|
| 8769 | - if($name!==$type) |
|
| 8762 | + if ($matchStart > $textStart) |
|
| 8763 | + $tpl[$c++] = array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
| 8764 | + $textStart = $matchEnd + 1; |
|
| 8765 | + $type = $match[1][0]; |
|
| 8766 | + if (empty($stack)) |
|
| 8767 | + throw new TConfigurationException('template_closingtag_unexpected', "</com:$type>"); |
|
| 8768 | + $name = array_pop($stack); |
|
| 8769 | + if ($name !== $type) |
|
| 8770 | 8770 | { |
| 8771 | - $tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>"; |
|
| 8772 | - throw new TConfigurationException('template_closingtag_expected',$tag); |
|
| 8771 | + $tag = $name[0] === '@' ? '</prop:' . substr($name, 1) . '>' : "</com:$name>"; |
|
| 8772 | + throw new TConfigurationException('template_closingtag_expected', $tag); |
|
| 8773 | 8773 | } |
| 8774 | - $container=$tpl[$container][0]; |
|
| 8774 | + $container = $tpl[$container][0]; |
|
| 8775 | 8775 | } |
| 8776 | - else if(strpos($str,'<%@')===0) { |
|
| 8777 | - if($expectPropEnd) |
|
| 8776 | + else if (strpos($str, '<%@') === 0) { |
|
| 8777 | + if ($expectPropEnd) |
|
| 8778 | 8778 | continue; |
| 8779 | - if($matchStart>$textStart) |
|
| 8780 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
| 8781 | - $textStart=$matchEnd+1; |
|
| 8782 | - if(isset($tpl[0]) || $this->_directive!==null) |
|
| 8779 | + if ($matchStart > $textStart) |
|
| 8780 | + $tpl[$c++] = array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
| 8781 | + $textStart = $matchEnd + 1; |
|
| 8782 | + if (isset($tpl[0]) || $this->_directive !== null) |
|
| 8783 | 8783 | throw new TConfigurationException('template_directive_nonunique'); |
| 8784 | - $this->_directive=$this->parseAttributes($match[4][0],$match[4][1]); |
|
| 8784 | + $this->_directive = $this->parseAttributes($match[4][0], $match[4][1]); |
|
| 8785 | 8785 | } |
| 8786 | - else if(strpos($str,'<%')===0) { |
|
| 8787 | - if($expectPropEnd) |
|
| 8786 | + else if (strpos($str, '<%') === 0) { |
|
| 8787 | + if ($expectPropEnd) |
|
| 8788 | 8788 | continue; |
| 8789 | - if($matchStart>$textStart) |
|
| 8790 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
| 8791 | - $textStart=$matchEnd+1; |
|
| 8792 | - $literal=trim($match[5][0]); |
|
| 8793 | - if($str[2]==='=') $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,$literal)); |
|
| 8794 | - else if($str[2]==='%') $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_STATEMENTS,$literal)); |
|
| 8795 | - else if($str[2]==='#') |
|
| 8796 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_DATABINDING,$literal)); |
|
| 8797 | - else if($str[2]==='$') |
|
| 8798 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->getApplication()->getParameters()->itemAt('$literal')")); |
|
| 8799 | - else if($str[2]==='~') |
|
| 8800 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->publishFilePath('$this->_contextPath/$literal')")); |
|
| 8801 | - else if($str[2]==='/') |
|
| 8802 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'")); |
|
| 8803 | - else if($str[2]==='[') |
|
| 8789 | + if ($matchStart > $textStart) |
|
| 8790 | + $tpl[$c++] = array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
| 8791 | + $textStart = $matchEnd + 1; |
|
| 8792 | + $literal = trim($match[5][0]); |
|
| 8793 | + if ($str[2] === '=') $tpl[$c++] = array($container, array(TCompositeLiteral::TYPE_EXPRESSION, $literal)); |
|
| 8794 | + else if ($str[2] === '%') $tpl[$c++] = array($container, array(TCompositeLiteral::TYPE_STATEMENTS, $literal)); |
|
| 8795 | + else if ($str[2] === '#') |
|
| 8796 | + $tpl[$c++] = array($container, array(TCompositeLiteral::TYPE_DATABINDING, $literal)); |
|
| 8797 | + else if ($str[2] === '$') |
|
| 8798 | + $tpl[$c++] = array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "\$this->getApplication()->getParameters()->itemAt('$literal')")); |
|
| 8799 | + else if ($str[2] === '~') |
|
| 8800 | + $tpl[$c++] = array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "\$this->publishFilePath('$this->_contextPath/$literal')")); |
|
| 8801 | + else if ($str[2] === '/') |
|
| 8802 | + $tpl[$c++] = array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'")); |
|
| 8803 | + else if ($str[2] === '[') |
|
| 8804 | 8804 | { |
| 8805 | - $literal=strtr(trim(substr($literal,0,strlen($literal)-1)),array("'"=>"\'","\\"=>"\\\\")); |
|
| 8806 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"Prado::localize('$literal')")); |
|
| 8805 | + $literal = strtr(trim(substr($literal, 0, strlen($literal) - 1)), array("'"=>"\'", "\\"=>"\\\\")); |
|
| 8806 | + $tpl[$c++] = array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "Prado::localize('$literal')")); |
|
| 8807 | 8807 | } |
| 8808 | 8808 | } |
| 8809 | - else if(strpos($str,'<prop:')===0) { |
|
| 8810 | - if(strrpos($str,'/>')===strlen($str)-2) { |
|
| 8811 | - if($expectPropEnd) |
|
| 8809 | + else if (strpos($str, '<prop:') === 0) { |
|
| 8810 | + if (strrpos($str, '/>') === strlen($str) - 2) { |
|
| 8811 | + if ($expectPropEnd) |
|
| 8812 | 8812 | continue; |
| 8813 | - if($matchStart>$textStart) |
|
| 8814 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
| 8815 | - $textStart=$matchEnd+1; |
|
| 8816 | - $prop=strtolower($match[6][0]); |
|
| 8817 | - $attrs=$this->parseAttributes($match[7][0],$match[7][1]); |
|
| 8818 | - $attributes=array(); |
|
| 8819 | - foreach($attrs as $name=>$value) |
|
| 8820 | - $attributes[$prop.'.'.$name]=$value; |
|
| 8821 | - $type=$tpl[$container][1]; |
|
| 8822 | - $this->validateAttributes($type,$attributes); |
|
| 8823 | - foreach($attributes as $name=>$value) |
|
| 8813 | + if ($matchStart > $textStart) |
|
| 8814 | + $tpl[$c++] = array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
| 8815 | + $textStart = $matchEnd + 1; |
|
| 8816 | + $prop = strtolower($match[6][0]); |
|
| 8817 | + $attrs = $this->parseAttributes($match[7][0], $match[7][1]); |
|
| 8818 | + $attributes = array(); |
|
| 8819 | + foreach ($attrs as $name=>$value) |
|
| 8820 | + $attributes[$prop . '.' . $name] = $value; |
|
| 8821 | + $type = $tpl[$container][1]; |
|
| 8822 | + $this->validateAttributes($type, $attributes); |
|
| 8823 | + foreach ($attributes as $name=>$value) |
|
| 8824 | 8824 | { |
| 8825 | - if(isset($tpl[$container][2][$name])) |
|
| 8826 | - throw new TConfigurationException('template_property_duplicated',$name); |
|
| 8827 | - $tpl[$container][2][$name]=$value; |
|
| 8825 | + if (isset($tpl[$container][2][$name])) |
|
| 8826 | + throw new TConfigurationException('template_property_duplicated', $name); |
|
| 8827 | + $tpl[$container][2][$name] = $value; |
|
| 8828 | 8828 | } |
| 8829 | 8829 | } |
| 8830 | - else { |
|
| 8831 | - $prop=strtolower($match[3][0]); |
|
| 8832 | - $stack[] = '@'.$prop; |
|
| 8833 | - if(!$expectPropEnd) |
|
| 8830 | + else { |
|
| 8831 | + $prop = strtolower($match[3][0]); |
|
| 8832 | + $stack[] = '@' . $prop; |
|
| 8833 | + if (!$expectPropEnd) |
|
| 8834 | 8834 | { |
| 8835 | - if($matchStart>$textStart) |
|
| 8836 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
| 8837 | - $textStart=$matchEnd+1; |
|
| 8838 | - $expectPropEnd=true; |
|
| 8835 | + if ($matchStart > $textStart) |
|
| 8836 | + $tpl[$c++] = array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
| 8837 | + $textStart = $matchEnd + 1; |
|
| 8838 | + $expectPropEnd = true; |
|
| 8839 | 8839 | } |
| 8840 | 8840 | } |
| 8841 | 8841 | } |
| 8842 | - else if(strpos($str,'</prop:')===0) { |
|
| 8843 | - $prop=strtolower($match[3][0]); |
|
| 8844 | - if(empty($stack)) |
|
| 8845 | - throw new TConfigurationException('template_closingtag_unexpected',"</prop:$prop>"); |
|
| 8846 | - $name=array_pop($stack); |
|
| 8847 | - if($name!=='@'.$prop) |
|
| 8842 | + else if (strpos($str, '</prop:') === 0) { |
|
| 8843 | + $prop = strtolower($match[3][0]); |
|
| 8844 | + if (empty($stack)) |
|
| 8845 | + throw new TConfigurationException('template_closingtag_unexpected', "</prop:$prop>"); |
|
| 8846 | + $name = array_pop($stack); |
|
| 8847 | + if ($name !== '@' . $prop) |
|
| 8848 | 8848 | { |
| 8849 | - $tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>"; |
|
| 8850 | - throw new TConfigurationException('template_closingtag_expected',$tag); |
|
| 8849 | + $tag = $name[0] === '@' ? '</prop:' . substr($name, 1) . '>' : "</com:$name>"; |
|
| 8850 | + throw new TConfigurationException('template_closingtag_expected', $tag); |
|
| 8851 | 8851 | } |
| 8852 | - if(($last=count($stack))<1 || $stack[$last-1][0]!=='@') |
|
| 8852 | + if (($last = count($stack)) < 1 || $stack[$last - 1][0] !== '@') |
|
| 8853 | 8853 | { |
| 8854 | - if($matchStart>$textStart) |
|
| 8854 | + if ($matchStart > $textStart) |
|
| 8855 | 8855 | { |
| 8856 | - $value=substr($input,$textStart,$matchStart-$textStart); |
|
| 8857 | - if(substr($prop,-8,8)==='template') |
|
| 8858 | - $value=$this->parseTemplateProperty($value,$textStart); |
|
| 8856 | + $value = substr($input, $textStart, $matchStart - $textStart); |
|
| 8857 | + if (substr($prop, -8, 8) === 'template') |
|
| 8858 | + $value = $this->parseTemplateProperty($value, $textStart); |
|
| 8859 | 8859 | else |
| 8860 | - $value=$this->parseAttribute($value); |
|
| 8861 | - if($container>=0) |
|
| 8860 | + $value = $this->parseAttribute($value); |
|
| 8861 | + if ($container >= 0) |
|
| 8862 | 8862 | { |
| 8863 | - $type=$tpl[$container][1]; |
|
| 8864 | - $this->validateAttributes($type,array($prop=>$value)); |
|
| 8865 | - if(isset($tpl[$container][2][$prop])) |
|
| 8866 | - throw new TConfigurationException('template_property_duplicated',$prop); |
|
| 8867 | - $tpl[$container][2][$prop]=$value; |
|
| 8863 | + $type = $tpl[$container][1]; |
|
| 8864 | + $this->validateAttributes($type, array($prop=>$value)); |
|
| 8865 | + if (isset($tpl[$container][2][$prop])) |
|
| 8866 | + throw new TConfigurationException('template_property_duplicated', $prop); |
|
| 8867 | + $tpl[$container][2][$prop] = $value; |
|
| 8868 | 8868 | } |
| 8869 | - else $this->_directive[$prop]=$value; |
|
| 8870 | - $textStart=$matchEnd+1; |
|
| 8869 | + else $this->_directive[$prop] = $value; |
|
| 8870 | + $textStart = $matchEnd + 1; |
|
| 8871 | 8871 | } |
| 8872 | - $expectPropEnd=false; |
|
| 8872 | + $expectPropEnd = false; |
|
| 8873 | 8873 | } |
| 8874 | 8874 | } |
| 8875 | - else if(strpos($str,'<!--')===0) { |
|
| 8876 | - if($expectPropEnd) |
|
| 8875 | + else if (strpos($str, '<!--') === 0) { |
|
| 8876 | + if ($expectPropEnd) |
|
| 8877 | 8877 | throw new TConfigurationException('template_comments_forbidden'); |
| 8878 | - if($matchStart>$textStart) |
|
| 8879 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
| 8880 | - $textStart=$matchEnd+1; |
|
| 8878 | + if ($matchStart > $textStart) |
|
| 8879 | + $tpl[$c++] = array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
| 8880 | + $textStart = $matchEnd + 1; |
|
| 8881 | 8881 | } |
| 8882 | 8882 | else |
| 8883 | - throw new TConfigurationException('template_matching_unexpected',$match); |
|
| 8883 | + throw new TConfigurationException('template_matching_unexpected', $match); |
|
| 8884 | 8884 | } |
| 8885 | - if(!empty($stack)) |
|
| 8885 | + if (!empty($stack)) |
|
| 8886 | 8886 | { |
| 8887 | - $name=array_pop($stack); |
|
| 8888 | - $tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>"; |
|
| 8889 | - throw new TConfigurationException('template_closingtag_expected',$tag); |
|
| 8887 | + $name = array_pop($stack); |
|
| 8888 | + $tag = $name[0] === '@' ? '</prop:' . substr($name, 1) . '>' : "</com:$name>"; |
|
| 8889 | + throw new TConfigurationException('template_closingtag_expected', $tag); |
|
| 8890 | 8890 | } |
| 8891 | - if($textStart<strlen($input)) |
|
| 8892 | - $tpl[$c++]=array($container,substr($input,$textStart)); |
|
| 8891 | + if ($textStart < strlen($input)) |
|
| 8892 | + $tpl[$c++] = array($container, substr($input, $textStart)); |
|
| 8893 | 8893 | } |
| 8894 | - catch(Exception $e) |
|
| 8894 | + catch (Exception $e) |
|
| 8895 | 8895 | { |
| 8896 | - if(($e instanceof TException) && ($e instanceof TTemplateException)) |
|
| 8896 | + if (($e instanceof TException) && ($e instanceof TTemplateException)) |
|
| 8897 | 8897 | throw $e; |
| 8898 | - if($matchEnd===0) |
|
| 8899 | - $line=$this->_startingLine+1; |
|
| 8898 | + if ($matchEnd === 0) |
|
| 8899 | + $line = $this->_startingLine + 1; |
|
| 8900 | 8900 | else |
| 8901 | - $line=$this->_startingLine+count(explode("\n",substr($input,0,$matchEnd+1))); |
|
| 8902 | - $this->handleException($e,$line,$input); |
|
| 8901 | + $line = $this->_startingLine + count(explode("\n", substr($input, 0, $matchEnd + 1))); |
|
| 8902 | + $this->handleException($e, $line, $input); |
|
| 8903 | 8903 | } |
| 8904 | - if($this->_directive===null) |
|
| 8905 | - $this->_directive=array(); |
|
| 8906 | - $objects=array(); |
|
| 8907 | - $parent=null; |
|
| 8908 | - $merged=array(); |
|
| 8909 | - foreach($tpl as $id=>$object) |
|
| 8904 | + if ($this->_directive === null) |
|
| 8905 | + $this->_directive = array(); |
|
| 8906 | + $objects = array(); |
|
| 8907 | + $parent = null; |
|
| 8908 | + $merged = array(); |
|
| 8909 | + foreach ($tpl as $id=>$object) |
|
| 8910 | 8910 | { |
| 8911 | - if(isset($object[2]) || $object[0]!==$parent) |
|
| 8911 | + if (isset($object[2]) || $object[0] !== $parent) |
|
| 8912 | 8912 | { |
| 8913 | - if($parent!==null) |
|
| 8913 | + if ($parent !== null) |
|
| 8914 | 8914 | { |
| 8915 | - if(count($merged[1])===1 && is_string($merged[1][0])) |
|
| 8916 | - $objects[$id-1]=array($merged[0],$merged[1][0]); |
|
| 8915 | + if (count($merged[1]) === 1 && is_string($merged[1][0])) |
|
| 8916 | + $objects[$id - 1] = array($merged[0], $merged[1][0]); |
|
| 8917 | 8917 | else |
| 8918 | - $objects[$id-1]=array($merged[0],new TCompositeLiteral($merged[1])); |
|
| 8918 | + $objects[$id - 1] = array($merged[0], new TCompositeLiteral($merged[1])); |
|
| 8919 | 8919 | } |
| 8920 | - if(isset($object[2])) |
|
| 8920 | + if (isset($object[2])) |
|
| 8921 | 8921 | { |
| 8922 | - $parent=null; |
|
| 8923 | - $objects[$id]=$object; |
|
| 8922 | + $parent = null; |
|
| 8923 | + $objects[$id] = $object; |
|
| 8924 | 8924 | } |
| 8925 | 8925 | else |
| 8926 | 8926 | { |
| 8927 | - $parent=$object[0]; |
|
| 8928 | - $merged=array($parent,array($object[1])); |
|
| 8927 | + $parent = $object[0]; |
|
| 8928 | + $merged = array($parent, array($object[1])); |
|
| 8929 | 8929 | } |
| 8930 | 8930 | } |
| 8931 | 8931 | else |
| 8932 | - $merged[1][]=$object[1]; |
|
| 8932 | + $merged[1][] = $object[1]; |
|
| 8933 | 8933 | } |
| 8934 | - if($parent!==null) |
|
| 8934 | + if ($parent !== null) |
|
| 8935 | 8935 | { |
| 8936 | - if(count($merged[1])===1 && is_string($merged[1][0])) |
|
| 8937 | - $objects[$id]=array($merged[0],$merged[1][0]); |
|
| 8936 | + if (count($merged[1]) === 1 && is_string($merged[1][0])) |
|
| 8937 | + $objects[$id] = array($merged[0], $merged[1][0]); |
|
| 8938 | 8938 | else |
| 8939 | - $objects[$id]=array($merged[0],new TCompositeLiteral($merged[1])); |
|
| 8939 | + $objects[$id] = array($merged[0], new TCompositeLiteral($merged[1])); |
|
| 8940 | 8940 | } |
| 8941 | - $tpl=$objects; |
|
| 8941 | + $tpl = $objects; |
|
| 8942 | 8942 | return $objects; |
| 8943 | 8943 | } |
| 8944 | - protected function parseAttributes($str,$offset) |
|
| 8944 | + protected function parseAttributes($str, $offset) |
|
| 8945 | 8945 | { |
| 8946 | - if($str==='') |
|
| 8946 | + if ($str === '') |
|
| 8947 | 8947 | return array(); |
| 8948 | - $pattern='/([\w\.\-]+)\s*=\s*(\'.*?\'|".*?"|<%.*?%>)/msS'; |
|
| 8949 | - $attributes=array(); |
|
| 8950 | - $n=preg_match_all($pattern,$str,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE); |
|
| 8951 | - for($i=0;$i<$n;++$i) |
|
| 8952 | - { |
|
| 8953 | - $match=&$matches[$i]; |
|
| 8954 | - $name=strtolower($match[1][0]); |
|
| 8955 | - if(isset($attributes[$name])) |
|
| 8956 | - throw new TConfigurationException('template_property_duplicated',$name); |
|
| 8957 | - $value=$match[2][0]; |
|
| 8958 | - if(substr($name,-8,8)==='template') |
|
| 8959 | - { |
|
| 8960 | - if($value[0]==='\'' || $value[0]==='"') |
|
| 8961 | - $attributes[$name]=$this->parseTemplateProperty(substr($value,1,strlen($value)-2),$match[2][1]+1); |
|
| 8948 | + $pattern = '/([\w\.\-]+)\s*=\s*(\'.*?\'|".*?"|<%.*?%>)/msS'; |
|
| 8949 | + $attributes = array(); |
|
| 8950 | + $n = preg_match_all($pattern, $str, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE); |
|
| 8951 | + for ($i = 0; $i < $n; ++$i) |
|
| 8952 | + { |
|
| 8953 | + $match = &$matches[$i]; |
|
| 8954 | + $name = strtolower($match[1][0]); |
|
| 8955 | + if (isset($attributes[$name])) |
|
| 8956 | + throw new TConfigurationException('template_property_duplicated', $name); |
|
| 8957 | + $value = $match[2][0]; |
|
| 8958 | + if (substr($name, -8, 8) === 'template') |
|
| 8959 | + { |
|
| 8960 | + if ($value[0] === '\'' || $value[0] === '"') |
|
| 8961 | + $attributes[$name] = $this->parseTemplateProperty(substr($value, 1, strlen($value) - 2), $match[2][1] + 1); |
|
| 8962 | 8962 | else |
| 8963 | - $attributes[$name]=$this->parseTemplateProperty($value,$match[2][1]); |
|
| 8963 | + $attributes[$name] = $this->parseTemplateProperty($value, $match[2][1]); |
|
| 8964 | 8964 | } |
| 8965 | 8965 | else |
| 8966 | 8966 | { |
| 8967 | - if($value[0]==='\'' || $value[0]==='"') |
|
| 8968 | - $attributes[$name]=$this->parseAttribute(substr($value,1,strlen($value)-2)); |
|
| 8967 | + if ($value[0] === '\'' || $value[0] === '"') |
|
| 8968 | + $attributes[$name] = $this->parseAttribute(substr($value, 1, strlen($value) - 2)); |
|
| 8969 | 8969 | else |
| 8970 | - $attributes[$name]=$this->parseAttribute($value); |
|
| 8970 | + $attributes[$name] = $this->parseAttribute($value); |
|
| 8971 | 8971 | } |
| 8972 | 8972 | } |
| 8973 | 8973 | return $attributes; |
| 8974 | 8974 | } |
| 8975 | - protected function parseTemplateProperty($content,$offset) |
|
| 8975 | + protected function parseTemplateProperty($content, $offset) |
|
| 8976 | 8976 | { |
| 8977 | - $line=$this->_startingLine+count(explode("\n",substr($this->_content,0,$offset)))-1; |
|
| 8978 | - return array(self::CONFIG_TEMPLATE,new TTemplate($content,$this->_contextPath,$this->_tplFile,$line,false)); |
|
| 8977 | + $line = $this->_startingLine + count(explode("\n", substr($this->_content, 0, $offset))) - 1; |
|
| 8978 | + return array(self::CONFIG_TEMPLATE, new TTemplate($content, $this->_contextPath, $this->_tplFile, $line, false)); |
|
| 8979 | 8979 | } |
| 8980 | 8980 | protected function parseAttribute($value) |
| 8981 | 8981 | { |
| 8982 | - if(($n=preg_match_all('/<%[#=].*?%>/msS',$value,$matches,PREG_OFFSET_CAPTURE))>0) |
|
| 8983 | - { |
|
| 8984 | - $isDataBind=false; |
|
| 8985 | - $textStart=0; |
|
| 8986 | - $expr=''; |
|
| 8987 | - for($i=0;$i<$n;++$i) |
|
| 8988 | - { |
|
| 8989 | - $match=$matches[0][$i]; |
|
| 8990 | - $token=$match[0]; |
|
| 8991 | - $offset=$match[1]; |
|
| 8992 | - $length=strlen($token); |
|
| 8993 | - if($token[2]==='#') |
|
| 8994 | - $isDataBind=true; |
|
| 8995 | - if($offset>$textStart) |
|
| 8996 | - $expr.=".'".strtr(substr($value,$textStart,$offset-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'"; |
|
| 8997 | - $expr.='.('.substr($token,3,$length-5).')'; |
|
| 8998 | - $textStart=$offset+$length; |
|
| 8999 | - } |
|
| 9000 | - $length=strlen($value); |
|
| 9001 | - if($length>$textStart) |
|
| 9002 | - $expr.=".'".strtr(substr($value,$textStart,$length-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'"; |
|
| 9003 | - if($isDataBind) |
|
| 9004 | - return array(self::CONFIG_DATABIND,ltrim($expr,'.')); |
|
| 8982 | + if (($n = preg_match_all('/<%[#=].*?%>/msS', $value, $matches, PREG_OFFSET_CAPTURE)) > 0) |
|
| 8983 | + { |
|
| 8984 | + $isDataBind = false; |
|
| 8985 | + $textStart = 0; |
|
| 8986 | + $expr = ''; |
|
| 8987 | + for ($i = 0; $i < $n; ++$i) |
|
| 8988 | + { |
|
| 8989 | + $match = $matches[0][$i]; |
|
| 8990 | + $token = $match[0]; |
|
| 8991 | + $offset = $match[1]; |
|
| 8992 | + $length = strlen($token); |
|
| 8993 | + if ($token[2] === '#') |
|
| 8994 | + $isDataBind = true; |
|
| 8995 | + if ($offset > $textStart) |
|
| 8996 | + $expr .= ".'" . strtr(substr($value, $textStart, $offset - $textStart), array("'"=>"\\'", "\\"=>"\\\\")) . "'"; |
|
| 8997 | + $expr .= '.(' . substr($token, 3, $length - 5) . ')'; |
|
| 8998 | + $textStart = $offset + $length; |
|
| 8999 | + } |
|
| 9000 | + $length = strlen($value); |
|
| 9001 | + if ($length > $textStart) |
|
| 9002 | + $expr .= ".'" . strtr(substr($value, $textStart, $length - $textStart), array("'"=>"\\'", "\\"=>"\\\\")) . "'"; |
|
| 9003 | + if ($isDataBind) |
|
| 9004 | + return array(self::CONFIG_DATABIND, ltrim($expr, '.')); |
|
| 9005 | 9005 | else |
| 9006 | - return array(self::CONFIG_EXPRESSION,ltrim($expr,'.')); |
|
| 9006 | + return array(self::CONFIG_EXPRESSION, ltrim($expr, '.')); |
|
| 9007 | 9007 | } |
| 9008 | - else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS',$value,$matches) && $matches[0]===$value) |
|
| 9008 | + else if (preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS', $value, $matches) && $matches[0] === $value) |
|
| 9009 | 9009 | { |
| 9010 | - $value=$matches[1]; |
|
| 9011 | - if($value[2]==='~') |
|
| 9012 | - return array(self::CONFIG_ASSET,trim(substr($value,3,strlen($value)-5))); |
|
| 9013 | - elseif($value[2]==='[') |
|
| 9014 | - return array(self::CONFIG_LOCALIZATION,trim(substr($value,3,strlen($value)-6))); |
|
| 9015 | - elseif($value[2]==='$') |
|
| 9016 | - return array(self::CONFIG_PARAMETER,trim(substr($value,3,strlen($value)-5))); |
|
| 9017 | - elseif($value[2]==='/') { |
|
| 9018 | - $literal = trim(substr($value,3,strlen($value)-5)); |
|
| 9019 | - return array(self::CONFIG_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'"); |
|
| 9010 | + $value = $matches[1]; |
|
| 9011 | + if ($value[2] === '~') |
|
| 9012 | + return array(self::CONFIG_ASSET, trim(substr($value, 3, strlen($value) - 5))); |
|
| 9013 | + elseif ($value[2] === '[') |
|
| 9014 | + return array(self::CONFIG_LOCALIZATION, trim(substr($value, 3, strlen($value) - 6))); |
|
| 9015 | + elseif ($value[2] === '$') |
|
| 9016 | + return array(self::CONFIG_PARAMETER, trim(substr($value, 3, strlen($value) - 5))); |
|
| 9017 | + elseif ($value[2] === '/') { |
|
| 9018 | + $literal = trim(substr($value, 3, strlen($value) - 5)); |
|
| 9019 | + return array(self::CONFIG_EXPRESSION, "rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'"); |
|
| 9020 | 9020 | } |
| 9021 | 9021 | } |
| 9022 | 9022 | else |
| 9023 | 9023 | return $value; |
| 9024 | 9024 | } |
| 9025 | - protected function validateAttributes($type,$attributes) |
|
| 9025 | + protected function validateAttributes($type, $attributes) |
|
| 9026 | 9026 | { |
| 9027 | 9027 | Prado::using($type); |
| 9028 | - if(($pos=strrpos($type,'.'))!==false) |
|
| 9029 | - $className=substr($type,$pos+1); |
|
| 9028 | + if (($pos = strrpos($type, '.')) !== false) |
|
| 9029 | + $className = substr($type, $pos + 1); |
|
| 9030 | 9030 | else |
| 9031 | - $className=$type; |
|
| 9032 | - $class=new ReflectionClass($className); |
|
| 9033 | - if(is_subclass_of($className,'TControl') || $className==='TControl') |
|
| 9031 | + $className = $type; |
|
| 9032 | + $class = new ReflectionClass($className); |
|
| 9033 | + if (is_subclass_of($className, 'TControl') || $className === 'TControl') |
|
| 9034 | 9034 | { |
| 9035 | - foreach($attributes as $name=>$att) |
|
| 9035 | + foreach ($attributes as $name=>$att) |
|
| 9036 | 9036 | { |
| 9037 | - if(($pos=strpos($name,'.'))!==false) |
|
| 9037 | + if (($pos = strpos($name, '.')) !== false) |
|
| 9038 | 9038 | { |
| 9039 | - $subname=substr($name,0,$pos); |
|
| 9040 | - if(!$class->hasMethod('get'.$subname)) |
|
| 9041 | - throw new TConfigurationException('template_property_unknown',$type,$subname); |
|
| 9039 | + $subname = substr($name, 0, $pos); |
|
| 9040 | + if (!$class->hasMethod('get' . $subname)) |
|
| 9041 | + throw new TConfigurationException('template_property_unknown', $type, $subname); |
|
| 9042 | 9042 | } |
| 9043 | - else if(strncasecmp($name,'on',2)===0) |
|
| 9043 | + else if (strncasecmp($name, 'on', 2) === 0) |
|
| 9044 | 9044 | { |
| 9045 | - if(!$class->hasMethod($name)) |
|
| 9046 | - throw new TConfigurationException('template_event_unknown',$type,$name); |
|
| 9047 | - else if(!is_string($att)) |
|
| 9048 | - throw new TConfigurationException('template_eventhandler_invalid',$type,$name); |
|
| 9045 | + if (!$class->hasMethod($name)) |
|
| 9046 | + throw new TConfigurationException('template_event_unknown', $type, $name); |
|
| 9047 | + else if (!is_string($att)) |
|
| 9048 | + throw new TConfigurationException('template_eventhandler_invalid', $type, $name); |
|
| 9049 | 9049 | } |
| 9050 | 9050 | else |
| 9051 | 9051 | { |
| 9052 | - if (! ($class->hasMethod('set'.$name) || $class->hasMethod('setjs'.$name) || $this->isClassBehaviorMethod($class,'set'.$name)) ) |
|
| 9052 | + if (!($class->hasMethod('set' . $name) || $class->hasMethod('setjs' . $name) || $this->isClassBehaviorMethod($class, 'set' . $name))) |
|
| 9053 | 9053 | { |
| 9054 | - if ($class->hasMethod('get'.$name) || $class->hasMethod('getjs'.$name)) |
|
| 9055 | - throw new TConfigurationException('template_property_readonly',$type,$name); |
|
| 9054 | + if ($class->hasMethod('get' . $name) || $class->hasMethod('getjs' . $name)) |
|
| 9055 | + throw new TConfigurationException('template_property_readonly', $type, $name); |
|
| 9056 | 9056 | else |
| 9057 | - throw new TConfigurationException('template_property_unknown',$type,$name); |
|
| 9057 | + throw new TConfigurationException('template_property_unknown', $type, $name); |
|
| 9058 | 9058 | } |
| 9059 | - else if(is_array($att) && $att[0]!==self::CONFIG_EXPRESSION) |
|
| 9059 | + else if (is_array($att) && $att[0] !== self::CONFIG_EXPRESSION) |
|
| 9060 | 9060 | { |
| 9061 | - if(strcasecmp($name,'id')===0) |
|
| 9062 | - throw new TConfigurationException('template_controlid_invalid',$type); |
|
| 9063 | - else if(strcasecmp($name,'skinid')===0) |
|
| 9064 | - throw new TConfigurationException('template_controlskinid_invalid',$type); |
|
| 9061 | + if (strcasecmp($name, 'id') === 0) |
|
| 9062 | + throw new TConfigurationException('template_controlid_invalid', $type); |
|
| 9063 | + else if (strcasecmp($name, 'skinid') === 0) |
|
| 9064 | + throw new TConfigurationException('template_controlskinid_invalid', $type); |
|
| 9065 | 9065 | } |
| 9066 | 9066 | } |
| 9067 | 9067 | } |
| 9068 | 9068 | } |
| 9069 | - else if(is_subclass_of($className,'TComponent') || $className==='TComponent') |
|
| 9069 | + else if (is_subclass_of($className, 'TComponent') || $className === 'TComponent') |
|
| 9070 | 9070 | { |
| 9071 | - foreach($attributes as $name=>$att) |
|
| 9071 | + foreach ($attributes as $name=>$att) |
|
| 9072 | 9072 | { |
| 9073 | - if(is_array($att) && ($att[0]===self::CONFIG_DATABIND)) |
|
| 9074 | - throw new TConfigurationException('template_databind_forbidden',$type,$name); |
|
| 9075 | - if(($pos=strpos($name,'.'))!==false) |
|
| 9073 | + if (is_array($att) && ($att[0] === self::CONFIG_DATABIND)) |
|
| 9074 | + throw new TConfigurationException('template_databind_forbidden', $type, $name); |
|
| 9075 | + if (($pos = strpos($name, '.')) !== false) |
|
| 9076 | 9076 | { |
| 9077 | - $subname=substr($name,0,$pos); |
|
| 9078 | - if(!$class->hasMethod('get'.$subname)) |
|
| 9079 | - throw new TConfigurationException('template_property_unknown',$type,$subname); |
|
| 9077 | + $subname = substr($name, 0, $pos); |
|
| 9078 | + if (!$class->hasMethod('get' . $subname)) |
|
| 9079 | + throw new TConfigurationException('template_property_unknown', $type, $subname); |
|
| 9080 | 9080 | } |
| 9081 | - else if(strncasecmp($name,'on',2)===0) |
|
| 9082 | - throw new TConfigurationException('template_event_forbidden',$type,$name); |
|
| 9081 | + else if (strncasecmp($name, 'on', 2) === 0) |
|
| 9082 | + throw new TConfigurationException('template_event_forbidden', $type, $name); |
|
| 9083 | 9083 | else |
| 9084 | 9084 | { |
| 9085 | - if(strcasecmp($name,'id')!==0 && !($class->hasMethod('set'.$name) || $this->isClassBehaviorMethod($class,'set'.$name))) |
|
| 9085 | + if (strcasecmp($name, 'id') !== 0 && !($class->hasMethod('set' . $name) || $this->isClassBehaviorMethod($class, 'set' . $name))) |
|
| 9086 | 9086 | { |
| 9087 | - if($class->hasMethod('get'.$name)) |
|
| 9088 | - throw new TConfigurationException('template_property_readonly',$type,$name); |
|
| 9087 | + if ($class->hasMethod('get' . $name)) |
|
| 9088 | + throw new TConfigurationException('template_property_readonly', $type, $name); |
|
| 9089 | 9089 | else |
| 9090 | - throw new TConfigurationException('template_property_unknown',$type,$name); |
|
| 9090 | + throw new TConfigurationException('template_property_unknown', $type, $name); |
|
| 9091 | 9091 | } |
| 9092 | 9092 | } |
| 9093 | 9093 | } |
| 9094 | 9094 | } |
| 9095 | 9095 | else |
| 9096 | - throw new TConfigurationException('template_component_required',$type); |
|
| 9096 | + throw new TConfigurationException('template_component_required', $type); |
|
| 9097 | 9097 | } |
| 9098 | 9098 | public function getIncludedFiles() |
| 9099 | 9099 | { |
| 9100 | 9100 | return $this->_includedFiles; |
| 9101 | 9101 | } |
| 9102 | - protected function handleException($e,$line,$input=null) |
|
| 9102 | + protected function handleException($e, $line, $input = null) |
|
| 9103 | 9103 | { |
| 9104 | - $srcFile=$this->_tplFile; |
|
| 9105 | - if(($n=count($this->_includedFiles))>0) { |
|
| 9106 | - for($i=$n-1;$i>=0;--$i) |
|
| 9104 | + $srcFile = $this->_tplFile; |
|
| 9105 | + if (($n = count($this->_includedFiles)) > 0) { |
|
| 9106 | + for ($i = $n - 1; $i >= 0; --$i) |
|
| 9107 | 9107 | { |
| 9108 | - if($this->_includeAtLine[$i]<=$line) |
|
| 9108 | + if ($this->_includeAtLine[$i] <= $line) |
|
| 9109 | 9109 | { |
| 9110 | - if($line<$this->_includeAtLine[$i]+$this->_includeLines[$i]) |
|
| 9110 | + if ($line < $this->_includeAtLine[$i] + $this->_includeLines[$i]) |
|
| 9111 | 9111 | { |
| 9112 | - $line=$line-$this->_includeAtLine[$i]+1; |
|
| 9113 | - $srcFile=$this->_includedFiles[$i]; |
|
| 9112 | + $line = $line - $this->_includeAtLine[$i] + 1; |
|
| 9113 | + $srcFile = $this->_includedFiles[$i]; |
|
| 9114 | 9114 | break; |
| 9115 | 9115 | } |
| 9116 | 9116 | else |
| 9117 | - $line=$line-$this->_includeLines[$i]+1; |
|
| 9117 | + $line = $line - $this->_includeLines[$i] + 1; |
|
| 9118 | 9118 | } |
| 9119 | 9119 | } |
| 9120 | 9120 | } |
| 9121 | - $exception=new TTemplateException('template_format_invalid',$e->getMessage()); |
|
| 9121 | + $exception = new TTemplateException('template_format_invalid', $e->getMessage()); |
|
| 9122 | 9122 | $exception->setLineNumber($line); |
| 9123 | - if(!empty($srcFile)) |
|
| 9123 | + if (!empty($srcFile)) |
|
| 9124 | 9124 | $exception->setTemplateFile($srcFile); |
| 9125 | 9125 | else |
| 9126 | 9126 | $exception->setTemplateSource($input); |
@@ -9128,45 +9128,45 @@ discard block |
||
| 9128 | 9128 | } |
| 9129 | 9129 | protected function preprocess($input) |
| 9130 | 9130 | { |
| 9131 | - if($n=preg_match_all('/<%include(.*?)%>/',$input,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE)) |
|
| 9131 | + if ($n = preg_match_all('/<%include(.*?)%>/', $input, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) |
|
| 9132 | 9132 | { |
| 9133 | - for($i=0;$i<$n;++$i) |
|
| 9133 | + for ($i = 0; $i < $n; ++$i) |
|
| 9134 | 9134 | { |
| 9135 | - $filePath=Prado::getPathOfNamespace(trim($matches[$i][1][0]),TTemplateManager::TEMPLATE_FILE_EXT); |
|
| 9136 | - if($filePath!==null && is_file($filePath)) |
|
| 9137 | - $this->_includedFiles[]=$filePath; |
|
| 9135 | + $filePath = Prado::getPathOfNamespace(trim($matches[$i][1][0]), TTemplateManager::TEMPLATE_FILE_EXT); |
|
| 9136 | + if ($filePath !== null && is_file($filePath)) |
|
| 9137 | + $this->_includedFiles[] = $filePath; |
|
| 9138 | 9138 | else |
| 9139 | 9139 | { |
| 9140 | - $errorLine=count(explode("\n",substr($input,0,$matches[$i][0][1]+1))); |
|
| 9141 | - $this->handleException(new TConfigurationException('template_include_invalid',trim($matches[$i][1][0])),$errorLine,$input); |
|
| 9140 | + $errorLine = count(explode("\n", substr($input, 0, $matches[$i][0][1] + 1))); |
|
| 9141 | + $this->handleException(new TConfigurationException('template_include_invalid', trim($matches[$i][1][0])), $errorLine, $input); |
|
| 9142 | 9142 | } |
| 9143 | 9143 | } |
| 9144 | - $base=0; |
|
| 9145 | - for($i=0;$i<$n;++$i) |
|
| 9144 | + $base = 0; |
|
| 9145 | + for ($i = 0; $i < $n; ++$i) |
|
| 9146 | 9146 | { |
| 9147 | - $ext=file_get_contents($this->_includedFiles[$i]); |
|
| 9148 | - $length=strlen($matches[$i][0][0]); |
|
| 9149 | - $offset=$base+$matches[$i][0][1]; |
|
| 9150 | - $this->_includeAtLine[$i]=count(explode("\n",substr($input,0,$offset))); |
|
| 9151 | - $this->_includeLines[$i]=count(explode("\n",$ext)); |
|
| 9152 | - $input=substr_replace($input,$ext,$offset,$length); |
|
| 9153 | - $base+=strlen($ext)-$length; |
|
| 9147 | + $ext = file_get_contents($this->_includedFiles[$i]); |
|
| 9148 | + $length = strlen($matches[$i][0][0]); |
|
| 9149 | + $offset = $base + $matches[$i][0][1]; |
|
| 9150 | + $this->_includeAtLine[$i] = count(explode("\n", substr($input, 0, $offset))); |
|
| 9151 | + $this->_includeLines[$i] = count(explode("\n", $ext)); |
|
| 9152 | + $input = substr_replace($input, $ext, $offset, $length); |
|
| 9153 | + $base += strlen($ext) - $length; |
|
| 9154 | 9154 | } |
| 9155 | 9155 | } |
| 9156 | 9156 | return $input; |
| 9157 | 9157 | } |
| 9158 | - protected function isClassBehaviorMethod(ReflectionClass $class,$method) |
|
| 9158 | + protected function isClassBehaviorMethod(ReflectionClass $class, $method) |
|
| 9159 | 9159 | { |
| 9160 | - $component=new ReflectionClass('TComponent'); |
|
| 9161 | - $behaviors=$component->getStaticProperties(); |
|
| 9162 | - if(!isset($behaviors['_um'])) |
|
| 9160 | + $component = new ReflectionClass('TComponent'); |
|
| 9161 | + $behaviors = $component->getStaticProperties(); |
|
| 9162 | + if (!isset($behaviors['_um'])) |
|
| 9163 | 9163 | return false; |
| 9164 | - foreach($behaviors['_um'] as $name=>$list) |
|
| 9164 | + foreach ($behaviors['_um'] as $name=>$list) |
|
| 9165 | 9165 | { |
| 9166 | - if(strtolower($class->getShortName())!==$name && !$class->isSubclassOf($name)) continue; |
|
| 9167 | - foreach($list as $param) |
|
| 9166 | + if (strtolower($class->getShortName()) !== $name && !$class->isSubclassOf($name)) continue; |
|
| 9167 | + foreach ($list as $param) |
|
| 9168 | 9168 | { |
| 9169 | - if(method_exists($param->getBehavior(),$method)) |
|
| 9169 | + if (method_exists($param->getBehavior(), $method)) |
|
| 9170 | 9170 | return true; |
| 9171 | 9171 | } |
| 9172 | 9172 | } |
@@ -9175,177 +9175,177 @@ discard block |
||
| 9175 | 9175 | } |
| 9176 | 9176 | class TThemeManager extends TModule |
| 9177 | 9177 | { |
| 9178 | - const DEFAULT_BASEPATH='themes'; |
|
| 9178 | + const DEFAULT_BASEPATH = 'themes'; |
|
| 9179 | 9179 | const DEFAULT_THEMECLASS = 'TTheme'; |
| 9180 | - private $_themeClass=self::DEFAULT_THEMECLASS; |
|
| 9181 | - private $_initialized=false; |
|
| 9182 | - private $_basePath=null; |
|
| 9183 | - private $_baseUrl=null; |
|
| 9180 | + private $_themeClass = self::DEFAULT_THEMECLASS; |
|
| 9181 | + private $_initialized = false; |
|
| 9182 | + private $_basePath = null; |
|
| 9183 | + private $_baseUrl = null; |
|
| 9184 | 9184 | public function init($config) |
| 9185 | 9185 | { |
| 9186 | - $this->_initialized=true; |
|
| 9187 | - $service=$this->getService(); |
|
| 9188 | - if($service instanceof TPageService) |
|
| 9186 | + $this->_initialized = true; |
|
| 9187 | + $service = $this->getService(); |
|
| 9188 | + if ($service instanceof TPageService) |
|
| 9189 | 9189 | $service->setThemeManager($this); |
| 9190 | 9190 | else |
| 9191 | 9191 | throw new TConfigurationException('thememanager_service_unavailable'); |
| 9192 | 9192 | } |
| 9193 | 9193 | public function getTheme($name) |
| 9194 | 9194 | { |
| 9195 | - $themePath=$this->getBasePath().DIRECTORY_SEPARATOR.$name; |
|
| 9196 | - $themeUrl=rtrim($this->getBaseUrl(),'/').'/'.$name; |
|
| 9195 | + $themePath = $this->getBasePath() . DIRECTORY_SEPARATOR . $name; |
|
| 9196 | + $themeUrl = rtrim($this->getBaseUrl(), '/') . '/' . $name; |
|
| 9197 | 9197 | return Prado::createComponent($this->getThemeClass(), $themePath, $themeUrl); |
| 9198 | 9198 | } |
| 9199 | 9199 | public function setThemeClass($class) { |
| 9200 | - $this->_themeClass = $class===null ? self::DEFAULT_THEMECLASS : (string)$class; |
|
| 9200 | + $this->_themeClass = $class === null ? self::DEFAULT_THEMECLASS : (string) $class; |
|
| 9201 | 9201 | } |
| 9202 | 9202 | public function getThemeClass() { |
| 9203 | 9203 | return $this->_themeClass; |
| 9204 | 9204 | } |
| 9205 | 9205 | public function getAvailableThemes() |
| 9206 | 9206 | { |
| 9207 | - $themes=array(); |
|
| 9208 | - $basePath=$this->getBasePath(); |
|
| 9209 | - $folder=@opendir($basePath); |
|
| 9210 | - while($file=@readdir($folder)) |
|
| 9207 | + $themes = array(); |
|
| 9208 | + $basePath = $this->getBasePath(); |
|
| 9209 | + $folder = @opendir($basePath); |
|
| 9210 | + while ($file = @readdir($folder)) |
|
| 9211 | 9211 | { |
| 9212 | - if($file!=='.' && $file!=='..' && $file!=='.svn' && is_dir($basePath.DIRECTORY_SEPARATOR.$file)) |
|
| 9213 | - $themes[]=$file; |
|
| 9212 | + if ($file !== '.' && $file !== '..' && $file !== '.svn' && is_dir($basePath . DIRECTORY_SEPARATOR . $file)) |
|
| 9213 | + $themes[] = $file; |
|
| 9214 | 9214 | } |
| 9215 | 9215 | closedir($folder); |
| 9216 | 9216 | return $themes; |
| 9217 | 9217 | } |
| 9218 | 9218 | public function getBasePath() |
| 9219 | 9219 | { |
| 9220 | - if($this->_basePath===null) |
|
| 9220 | + if ($this->_basePath === null) |
|
| 9221 | 9221 | { |
| 9222 | - $this->_basePath=dirname($this->getRequest()->getApplicationFilePath()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH; |
|
| 9223 | - if(($basePath=realpath($this->_basePath))===false || !is_dir($basePath)) |
|
| 9224 | - throw new TConfigurationException('thememanager_basepath_invalid2',$this->_basePath); |
|
| 9225 | - $this->_basePath=$basePath; |
|
| 9222 | + $this->_basePath = dirname($this->getRequest()->getApplicationFilePath()) . DIRECTORY_SEPARATOR . self::DEFAULT_BASEPATH; |
|
| 9223 | + if (($basePath = realpath($this->_basePath)) === false || !is_dir($basePath)) |
|
| 9224 | + throw new TConfigurationException('thememanager_basepath_invalid2', $this->_basePath); |
|
| 9225 | + $this->_basePath = $basePath; |
|
| 9226 | 9226 | } |
| 9227 | 9227 | return $this->_basePath; |
| 9228 | 9228 | } |
| 9229 | 9229 | public function setBasePath($value) |
| 9230 | 9230 | { |
| 9231 | - if($this->_initialized) |
|
| 9231 | + if ($this->_initialized) |
|
| 9232 | 9232 | throw new TInvalidOperationException('thememanager_basepath_unchangeable'); |
| 9233 | 9233 | else |
| 9234 | 9234 | { |
| 9235 | - $this->_basePath=Prado::getPathOfNamespace($value); |
|
| 9236 | - if($this->_basePath===null || !is_dir($this->_basePath)) |
|
| 9237 | - throw new TInvalidDataValueException('thememanager_basepath_invalid',$value); |
|
| 9235 | + $this->_basePath = Prado::getPathOfNamespace($value); |
|
| 9236 | + if ($this->_basePath === null || !is_dir($this->_basePath)) |
|
| 9237 | + throw new TInvalidDataValueException('thememanager_basepath_invalid', $value); |
|
| 9238 | 9238 | } |
| 9239 | 9239 | } |
| 9240 | 9240 | public function getBaseUrl() |
| 9241 | 9241 | { |
| 9242 | - if($this->_baseUrl===null) |
|
| 9242 | + if ($this->_baseUrl === null) |
|
| 9243 | 9243 | { |
| 9244 | - $appPath=dirname($this->getRequest()->getApplicationFilePath()); |
|
| 9245 | - $basePath=$this->getBasePath(); |
|
| 9246 | - if(strpos($basePath,$appPath)===false) |
|
| 9244 | + $appPath = dirname($this->getRequest()->getApplicationFilePath()); |
|
| 9245 | + $basePath = $this->getBasePath(); |
|
| 9246 | + if (strpos($basePath, $appPath) === false) |
|
| 9247 | 9247 | throw new TConfigurationException('thememanager_baseurl_required'); |
| 9248 | - $appUrl=rtrim(dirname($this->getRequest()->getApplicationUrl()),'/\\'); |
|
| 9249 | - $this->_baseUrl=$appUrl.strtr(substr($basePath,strlen($appPath)),'\\','/'); |
|
| 9248 | + $appUrl = rtrim(dirname($this->getRequest()->getApplicationUrl()), '/\\'); |
|
| 9249 | + $this->_baseUrl = $appUrl . strtr(substr($basePath, strlen($appPath)), '\\', '/'); |
|
| 9250 | 9250 | } |
| 9251 | 9251 | return $this->_baseUrl; |
| 9252 | 9252 | } |
| 9253 | 9253 | public function setBaseUrl($value) |
| 9254 | 9254 | { |
| 9255 | - $this->_baseUrl=rtrim($value,'/'); |
|
| 9255 | + $this->_baseUrl = rtrim($value, '/'); |
|
| 9256 | 9256 | } |
| 9257 | 9257 | } |
| 9258 | 9258 | class TTheme extends TApplicationComponent implements ITheme |
| 9259 | 9259 | { |
| 9260 | - const THEME_CACHE_PREFIX='prado:theme:'; |
|
| 9261 | - const SKIN_FILE_EXT='.skin'; |
|
| 9260 | + const THEME_CACHE_PREFIX = 'prado:theme:'; |
|
| 9261 | + const SKIN_FILE_EXT = '.skin'; |
|
| 9262 | 9262 | private $_themePath; |
| 9263 | 9263 | private $_themeUrl; |
| 9264 | - private $_skins=null; |
|
| 9265 | - private $_name=''; |
|
| 9266 | - private $_cssFiles=array(); |
|
| 9267 | - private $_jsFiles=array(); |
|
| 9268 | - public function __construct($themePath,$themeUrl) |
|
| 9269 | - { |
|
| 9270 | - $this->_themeUrl=$themeUrl; |
|
| 9271 | - $this->_themePath=realpath($themePath); |
|
| 9272 | - $this->_name=basename($themePath); |
|
| 9273 | - $cacheValid=false; |
|
| 9274 | - if(($cache=$this->getApplication()->getCache())!==null) |
|
| 9275 | - { |
|
| 9276 | - $array=$cache->get(self::THEME_CACHE_PREFIX.$themePath); |
|
| 9277 | - if(is_array($array)) |
|
| 9278 | - { |
|
| 9279 | - list($skins,$cssFiles,$jsFiles,$timestamp)=$array; |
|
| 9280 | - if($this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
| 9264 | + private $_skins = null; |
|
| 9265 | + private $_name = ''; |
|
| 9266 | + private $_cssFiles = array(); |
|
| 9267 | + private $_jsFiles = array(); |
|
| 9268 | + public function __construct($themePath, $themeUrl) |
|
| 9269 | + { |
|
| 9270 | + $this->_themeUrl = $themeUrl; |
|
| 9271 | + $this->_themePath = realpath($themePath); |
|
| 9272 | + $this->_name = basename($themePath); |
|
| 9273 | + $cacheValid = false; |
|
| 9274 | + if (($cache = $this->getApplication()->getCache()) !== null) |
|
| 9275 | + { |
|
| 9276 | + $array = $cache->get(self::THEME_CACHE_PREFIX . $themePath); |
|
| 9277 | + if (is_array($array)) |
|
| 9278 | + { |
|
| 9279 | + list($skins, $cssFiles, $jsFiles, $timestamp) = $array; |
|
| 9280 | + if ($this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
| 9281 | 9281 | { |
| 9282 | - if(($dir=opendir($themePath))===false) |
|
| 9283 | - throw new TIOException('theme_path_inexistent',$themePath); |
|
| 9284 | - $cacheValid=true; |
|
| 9285 | - while(($file=readdir($dir))!==false) |
|
| 9282 | + if (($dir = opendir($themePath)) === false) |
|
| 9283 | + throw new TIOException('theme_path_inexistent', $themePath); |
|
| 9284 | + $cacheValid = true; |
|
| 9285 | + while (($file = readdir($dir)) !== false) |
|
| 9286 | 9286 | { |
| 9287 | - if($file==='.' || $file==='..') |
|
| 9287 | + if ($file === '.' || $file === '..') |
|
| 9288 | 9288 | continue; |
| 9289 | - else if(basename($file,'.css')!==$file) |
|
| 9290 | - $this->_cssFiles[]=$themeUrl.'/'.$file; |
|
| 9291 | - else if(basename($file,'.js')!==$file) |
|
| 9292 | - $this->_jsFiles[]=$themeUrl.'/'.$file; |
|
| 9293 | - else if(basename($file,self::SKIN_FILE_EXT)!==$file && filemtime($themePath.DIRECTORY_SEPARATOR.$file)>$timestamp) |
|
| 9289 | + else if (basename($file, '.css') !== $file) |
|
| 9290 | + $this->_cssFiles[] = $themeUrl . '/' . $file; |
|
| 9291 | + else if (basename($file, '.js') !== $file) |
|
| 9292 | + $this->_jsFiles[] = $themeUrl . '/' . $file; |
|
| 9293 | + else if (basename($file, self::SKIN_FILE_EXT) !== $file && filemtime($themePath . DIRECTORY_SEPARATOR . $file) > $timestamp) |
|
| 9294 | 9294 | { |
| 9295 | - $cacheValid=false; |
|
| 9295 | + $cacheValid = false; |
|
| 9296 | 9296 | break; |
| 9297 | 9297 | } |
| 9298 | 9298 | } |
| 9299 | 9299 | closedir($dir); |
| 9300 | - if($cacheValid) |
|
| 9301 | - $this->_skins=$skins; |
|
| 9300 | + if ($cacheValid) |
|
| 9301 | + $this->_skins = $skins; |
|
| 9302 | 9302 | } |
| 9303 | 9303 | else |
| 9304 | 9304 | { |
| 9305 | - $cacheValid=true; |
|
| 9306 | - $this->_cssFiles=$cssFiles; |
|
| 9307 | - $this->_jsFiles=$jsFiles; |
|
| 9308 | - $this->_skins=$skins; |
|
| 9305 | + $cacheValid = true; |
|
| 9306 | + $this->_cssFiles = $cssFiles; |
|
| 9307 | + $this->_jsFiles = $jsFiles; |
|
| 9308 | + $this->_skins = $skins; |
|
| 9309 | 9309 | } |
| 9310 | 9310 | } |
| 9311 | 9311 | } |
| 9312 | - if(!$cacheValid) |
|
| 9312 | + if (!$cacheValid) |
|
| 9313 | 9313 | { |
| 9314 | - $this->_cssFiles=array(); |
|
| 9315 | - $this->_jsFiles=array(); |
|
| 9316 | - $this->_skins=array(); |
|
| 9317 | - if(($dir=opendir($themePath))===false) |
|
| 9318 | - throw new TIOException('theme_path_inexistent',$themePath); |
|
| 9319 | - while(($file=readdir($dir))!==false) |
|
| 9314 | + $this->_cssFiles = array(); |
|
| 9315 | + $this->_jsFiles = array(); |
|
| 9316 | + $this->_skins = array(); |
|
| 9317 | + if (($dir = opendir($themePath)) === false) |
|
| 9318 | + throw new TIOException('theme_path_inexistent', $themePath); |
|
| 9319 | + while (($file = readdir($dir)) !== false) |
|
| 9320 | 9320 | { |
| 9321 | - if($file==='.' || $file==='..') |
|
| 9321 | + if ($file === '.' || $file === '..') |
|
| 9322 | 9322 | continue; |
| 9323 | - else if(basename($file,'.css')!==$file) |
|
| 9324 | - $this->_cssFiles[]=$themeUrl.'/'.$file; |
|
| 9325 | - else if(basename($file,'.js')!==$file) |
|
| 9326 | - $this->_jsFiles[]=$themeUrl.'/'.$file; |
|
| 9327 | - else if(basename($file,self::SKIN_FILE_EXT)!==$file) |
|
| 9323 | + else if (basename($file, '.css') !== $file) |
|
| 9324 | + $this->_cssFiles[] = $themeUrl . '/' . $file; |
|
| 9325 | + else if (basename($file, '.js') !== $file) |
|
| 9326 | + $this->_jsFiles[] = $themeUrl . '/' . $file; |
|
| 9327 | + else if (basename($file, self::SKIN_FILE_EXT) !== $file) |
|
| 9328 | 9328 | { |
| 9329 | - $template=new TTemplate(file_get_contents($themePath.'/'.$file),$themePath,$themePath.'/'.$file); |
|
| 9330 | - foreach($template->getItems() as $skin) |
|
| 9329 | + $template = new TTemplate(file_get_contents($themePath . '/' . $file), $themePath, $themePath . '/' . $file); |
|
| 9330 | + foreach ($template->getItems() as $skin) |
|
| 9331 | 9331 | { |
| 9332 | - if(!isset($skin[2])) continue; |
|
| 9333 | - else if($skin[0]!==-1) |
|
| 9334 | - throw new TConfigurationException('theme_control_nested',$skin[1],dirname($themePath)); |
|
| 9335 | - $type=$skin[1]; |
|
| 9336 | - $id=isset($skin[2]['skinid'])?$skin[2]['skinid']:0; |
|
| 9332 | + if (!isset($skin[2])) continue; |
|
| 9333 | + else if ($skin[0] !== -1) |
|
| 9334 | + throw new TConfigurationException('theme_control_nested', $skin[1], dirname($themePath)); |
|
| 9335 | + $type = $skin[1]; |
|
| 9336 | + $id = isset($skin[2]['skinid']) ? $skin[2]['skinid'] : 0; |
|
| 9337 | 9337 | unset($skin[2]['skinid']); |
| 9338 | - if(isset($this->_skins[$type][$id])) |
|
| 9339 | - throw new TConfigurationException('theme_skinid_duplicated',$type,$id,dirname($themePath)); |
|
| 9340 | - $this->_skins[$type][$id]=$skin[2]; |
|
| 9338 | + if (isset($this->_skins[$type][$id])) |
|
| 9339 | + throw new TConfigurationException('theme_skinid_duplicated', $type, $id, dirname($themePath)); |
|
| 9340 | + $this->_skins[$type][$id] = $skin[2]; |
|
| 9341 | 9341 | } |
| 9342 | 9342 | } |
| 9343 | 9343 | } |
| 9344 | 9344 | closedir($dir); |
| 9345 | 9345 | sort($this->_cssFiles); |
| 9346 | 9346 | sort($this->_jsFiles); |
| 9347 | - if($cache!==null) |
|
| 9348 | - $cache->set(self::THEME_CACHE_PREFIX.$themePath,array($this->_skins,$this->_cssFiles,$this->_jsFiles,time())); |
|
| 9347 | + if ($cache !== null) |
|
| 9348 | + $cache->set(self::THEME_CACHE_PREFIX . $themePath, array($this->_skins, $this->_cssFiles, $this->_jsFiles, time())); |
|
| 9349 | 9349 | } |
| 9350 | 9350 | } |
| 9351 | 9351 | public function getName() |
@@ -9362,7 +9362,7 @@ discard block |
||
| 9362 | 9362 | } |
| 9363 | 9363 | protected function setBaseUrl($value) |
| 9364 | 9364 | { |
| 9365 | - $this->_themeUrl=rtrim($value,'/'); |
|
| 9365 | + $this->_themeUrl = rtrim($value, '/'); |
|
| 9366 | 9366 | } |
| 9367 | 9367 | public function getBasePath() |
| 9368 | 9368 | { |
@@ -9370,7 +9370,7 @@ discard block |
||
| 9370 | 9370 | } |
| 9371 | 9371 | protected function setBasePath($value) |
| 9372 | 9372 | { |
| 9373 | - $this->_themePath=$value; |
|
| 9373 | + $this->_themePath = $value; |
|
| 9374 | 9374 | } |
| 9375 | 9375 | public function getSkins() |
| 9376 | 9376 | { |
@@ -9382,57 +9382,57 @@ discard block |
||
| 9382 | 9382 | } |
| 9383 | 9383 | public function applySkin($control) |
| 9384 | 9384 | { |
| 9385 | - $type=get_class($control); |
|
| 9386 | - if(($id=$control->getSkinID())==='') |
|
| 9387 | - $id=0; |
|
| 9388 | - if(isset($this->_skins[$type][$id])) |
|
| 9385 | + $type = get_class($control); |
|
| 9386 | + if (($id = $control->getSkinID()) === '') |
|
| 9387 | + $id = 0; |
|
| 9388 | + if (isset($this->_skins[$type][$id])) |
|
| 9389 | 9389 | { |
| 9390 | - foreach($this->_skins[$type][$id] as $name=>$value) |
|
| 9390 | + foreach ($this->_skins[$type][$id] as $name=>$value) |
|
| 9391 | 9391 | { |
| 9392 | - if(is_array($value)) |
|
| 9392 | + if (is_array($value)) |
|
| 9393 | 9393 | { |
| 9394 | - switch($value[0]) |
|
| 9394 | + switch ($value[0]) |
|
| 9395 | 9395 | { |
| 9396 | 9396 | case TTemplate::CONFIG_EXPRESSION: |
| 9397 | - $value=$this->evaluateExpression($value[1]); |
|
| 9397 | + $value = $this->evaluateExpression($value[1]); |
|
| 9398 | 9398 | break; |
| 9399 | 9399 | case TTemplate::CONFIG_ASSET: |
| 9400 | - $value=$this->_themeUrl.'/'.ltrim($value[1],'/'); |
|
| 9400 | + $value = $this->_themeUrl . '/' . ltrim($value[1], '/'); |
|
| 9401 | 9401 | break; |
| 9402 | 9402 | case TTemplate::CONFIG_DATABIND: |
| 9403 | - $control->bindProperty($name,$value[1]); |
|
| 9403 | + $control->bindProperty($name, $value[1]); |
|
| 9404 | 9404 | break; |
| 9405 | 9405 | case TTemplate::CONFIG_PARAMETER: |
| 9406 | - $control->setSubProperty($name,$this->getApplication()->getParameters()->itemAt($value[1])); |
|
| 9406 | + $control->setSubProperty($name, $this->getApplication()->getParameters()->itemAt($value[1])); |
|
| 9407 | 9407 | break; |
| 9408 | 9408 | case TTemplate::CONFIG_TEMPLATE: |
| 9409 | - $control->setSubProperty($name,$value[1]); |
|
| 9409 | + $control->setSubProperty($name, $value[1]); |
|
| 9410 | 9410 | break; |
| 9411 | 9411 | case TTemplate::CONFIG_LOCALIZATION: |
| 9412 | - $control->setSubProperty($name,Prado::localize($value[1])); |
|
| 9412 | + $control->setSubProperty($name, Prado::localize($value[1])); |
|
| 9413 | 9413 | break; |
| 9414 | 9414 | default: |
| 9415 | - throw new TConfigurationException('theme_tag_unexpected',$name,$value[0]); |
|
| 9415 | + throw new TConfigurationException('theme_tag_unexpected', $name, $value[0]); |
|
| 9416 | 9416 | break; |
| 9417 | 9417 | } |
| 9418 | 9418 | } |
| 9419 | - if(!is_array($value)) |
|
| 9419 | + if (!is_array($value)) |
|
| 9420 | 9420 | { |
| 9421 | - if(strpos($name,'.')===false) { |
|
| 9422 | - if($control->hasProperty($name)) |
|
| 9421 | + if (strpos($name, '.') === false) { |
|
| 9422 | + if ($control->hasProperty($name)) |
|
| 9423 | 9423 | { |
| 9424 | - if($control->canSetProperty($name)) |
|
| 9424 | + if ($control->canSetProperty($name)) |
|
| 9425 | 9425 | { |
| 9426 | - $setter='set'.$name; |
|
| 9426 | + $setter = 'set' . $name; |
|
| 9427 | 9427 | $control->$setter($value); |
| 9428 | 9428 | } |
| 9429 | 9429 | else |
| 9430 | - throw new TConfigurationException('theme_property_readonly',$type,$name); |
|
| 9430 | + throw new TConfigurationException('theme_property_readonly', $type, $name); |
|
| 9431 | 9431 | } |
| 9432 | 9432 | else |
| 9433 | - throw new TConfigurationException('theme_property_undefined',$type,$name); |
|
| 9433 | + throw new TConfigurationException('theme_property_undefined', $type, $name); |
|
| 9434 | 9434 | } |
| 9435 | - else $control->setSubProperty($name,$value); |
|
| 9435 | + else $control->setSubProperty($name, $value); |
|
| 9436 | 9436 | } |
| 9437 | 9437 | } |
| 9438 | 9438 | return true; |
@@ -9446,7 +9446,7 @@ discard block |
||
| 9446 | 9446 | } |
| 9447 | 9447 | protected function setStyleSheetFiles($value) |
| 9448 | 9448 | { |
| 9449 | - $this->_cssFiles=$value; |
|
| 9449 | + $this->_cssFiles = $value; |
|
| 9450 | 9450 | } |
| 9451 | 9451 | public function getJavaScriptFiles() |
| 9452 | 9452 | { |
@@ -9454,176 +9454,176 @@ discard block |
||
| 9454 | 9454 | } |
| 9455 | 9455 | protected function setJavaScriptFiles($value) |
| 9456 | 9456 | { |
| 9457 | - $this->_jsFiles=$value; |
|
| 9457 | + $this->_jsFiles = $value; |
|
| 9458 | 9458 | } |
| 9459 | 9459 | } |
| 9460 | 9460 | class TPageService extends TService |
| 9461 | 9461 | { |
| 9462 | - const CONFIG_FILE_XML='config.xml'; |
|
| 9463 | - const CONFIG_FILE_PHP='config.php'; |
|
| 9464 | - const DEFAULT_BASEPATH='Pages'; |
|
| 9465 | - const FALLBACK_BASEPATH='pages'; |
|
| 9466 | - const CONFIG_CACHE_PREFIX='prado:pageservice:'; |
|
| 9467 | - const PAGE_FILE_EXT='.page'; |
|
| 9468 | - private $_basePath=null; |
|
| 9469 | - private $_basePageClass='TPage'; |
|
| 9470 | - private $_clientScriptManagerClass='System.Web.UI.TClientScriptManager'; |
|
| 9471 | - private $_defaultPage='Home'; |
|
| 9472 | - private $_pagePath=null; |
|
| 9473 | - private $_page=null; |
|
| 9474 | - private $_properties=array(); |
|
| 9475 | - private $_initialized=false; |
|
| 9476 | - private $_themeManager=null; |
|
| 9477 | - private $_templateManager=null; |
|
| 9462 | + const CONFIG_FILE_XML = 'config.xml'; |
|
| 9463 | + const CONFIG_FILE_PHP = 'config.php'; |
|
| 9464 | + const DEFAULT_BASEPATH = 'Pages'; |
|
| 9465 | + const FALLBACK_BASEPATH = 'pages'; |
|
| 9466 | + const CONFIG_CACHE_PREFIX = 'prado:pageservice:'; |
|
| 9467 | + const PAGE_FILE_EXT = '.page'; |
|
| 9468 | + private $_basePath = null; |
|
| 9469 | + private $_basePageClass = 'TPage'; |
|
| 9470 | + private $_clientScriptManagerClass = 'System.Web.UI.TClientScriptManager'; |
|
| 9471 | + private $_defaultPage = 'Home'; |
|
| 9472 | + private $_pagePath = null; |
|
| 9473 | + private $_page = null; |
|
| 9474 | + private $_properties = array(); |
|
| 9475 | + private $_initialized = false; |
|
| 9476 | + private $_themeManager = null; |
|
| 9477 | + private $_templateManager = null; |
|
| 9478 | 9478 | public function init($config) |
| 9479 | 9479 | { |
| 9480 | - $pageConfig=$this->loadPageConfig($config); |
|
| 9480 | + $pageConfig = $this->loadPageConfig($config); |
|
| 9481 | 9481 | $this->initPageContext($pageConfig); |
| 9482 | - $this->_initialized=true; |
|
| 9482 | + $this->_initialized = true; |
|
| 9483 | 9483 | } |
| 9484 | 9484 | protected function initPageContext($pageConfig) |
| 9485 | 9485 | { |
| 9486 | - $application=$this->getApplication(); |
|
| 9487 | - foreach($pageConfig->getApplicationConfigurations() as $appConfig) |
|
| 9486 | + $application = $this->getApplication(); |
|
| 9487 | + foreach ($pageConfig->getApplicationConfigurations() as $appConfig) |
|
| 9488 | 9488 | $application->applyConfiguration($appConfig); |
| 9489 | 9489 | $this->applyConfiguration($pageConfig); |
| 9490 | 9490 | } |
| 9491 | 9491 | protected function applyConfiguration($config) |
| 9492 | 9492 | { |
| 9493 | - $this->_properties=array_merge($this->_properties, $config->getProperties()); |
|
| 9493 | + $this->_properties = array_merge($this->_properties, $config->getProperties()); |
|
| 9494 | 9494 | $this->getApplication()->getAuthorizationRules()->mergeWith($config->getRules()); |
| 9495 | - $pagePath=$this->getRequestedPagePath(); |
|
| 9496 | - foreach($config->getExternalConfigurations() as $filePath=>$params) |
|
| 9497 | - { |
|
| 9498 | - list($configPagePath,$condition)=$params; |
|
| 9499 | - if($condition!==true) |
|
| 9500 | - $condition=$this->evaluateExpression($condition); |
|
| 9501 | - if($condition) |
|
| 9502 | - { |
|
| 9503 | - if(($path=Prado::getPathOfNamespace($filePath,Prado::getApplication()->getConfigurationFileExt()))===null || !is_file($path)) |
|
| 9504 | - throw new TConfigurationException('pageservice_includefile_invalid',$filePath); |
|
| 9505 | - $c=new TPageConfiguration($pagePath); |
|
| 9506 | - $c->loadFromFile($path,$configPagePath); |
|
| 9495 | + $pagePath = $this->getRequestedPagePath(); |
|
| 9496 | + foreach ($config->getExternalConfigurations() as $filePath=>$params) |
|
| 9497 | + { |
|
| 9498 | + list($configPagePath, $condition) = $params; |
|
| 9499 | + if ($condition !== true) |
|
| 9500 | + $condition = $this->evaluateExpression($condition); |
|
| 9501 | + if ($condition) |
|
| 9502 | + { |
|
| 9503 | + if (($path = Prado::getPathOfNamespace($filePath, Prado::getApplication()->getConfigurationFileExt())) === null || !is_file($path)) |
|
| 9504 | + throw new TConfigurationException('pageservice_includefile_invalid', $filePath); |
|
| 9505 | + $c = new TPageConfiguration($pagePath); |
|
| 9506 | + $c->loadFromFile($path, $configPagePath); |
|
| 9507 | 9507 | $this->applyConfiguration($c); |
| 9508 | 9508 | } |
| 9509 | 9509 | } |
| 9510 | 9510 | } |
| 9511 | 9511 | protected function determineRequestedPagePath() |
| 9512 | 9512 | { |
| 9513 | - $pagePath=$this->getRequest()->getServiceParameter(); |
|
| 9514 | - if(empty($pagePath)) |
|
| 9515 | - $pagePath=$this->getDefaultPage(); |
|
| 9513 | + $pagePath = $this->getRequest()->getServiceParameter(); |
|
| 9514 | + if (empty($pagePath)) |
|
| 9515 | + $pagePath = $this->getDefaultPage(); |
|
| 9516 | 9516 | return $pagePath; |
| 9517 | 9517 | } |
| 9518 | 9518 | protected function loadPageConfig($config) |
| 9519 | 9519 | { |
| 9520 | - $application=$this->getApplication(); |
|
| 9521 | - $pagePath=$this->getRequestedPagePath(); |
|
| 9522 | - if(($cache=$application->getCache())===null) |
|
| 9520 | + $application = $this->getApplication(); |
|
| 9521 | + $pagePath = $this->getRequestedPagePath(); |
|
| 9522 | + if (($cache = $application->getCache()) === null) |
|
| 9523 | 9523 | { |
| 9524 | - $pageConfig=new TPageConfiguration($pagePath); |
|
| 9525 | - if($config!==null) |
|
| 9524 | + $pageConfig = new TPageConfiguration($pagePath); |
|
| 9525 | + if ($config !== null) |
|
| 9526 | 9526 | { |
| 9527 | - if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
|
| 9528 | - $pageConfig->loadPageConfigurationFromPhp($config,$application->getBasePath(),''); |
|
| 9527 | + if ($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
| 9528 | + $pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), ''); |
|
| 9529 | 9529 | else |
| 9530 | - $pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),''); |
|
| 9530 | + $pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), ''); |
|
| 9531 | 9531 | } |
| 9532 | 9532 | $pageConfig->loadFromFiles($this->getBasePath()); |
| 9533 | 9533 | } |
| 9534 | 9534 | else |
| 9535 | 9535 | { |
| 9536 | - $configCached=true; |
|
| 9537 | - $currentTimestamp=array(); |
|
| 9538 | - $arr=$cache->get(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath); |
|
| 9539 | - if(is_array($arr)) |
|
| 9536 | + $configCached = true; |
|
| 9537 | + $currentTimestamp = array(); |
|
| 9538 | + $arr = $cache->get(self::CONFIG_CACHE_PREFIX . $this->getID() . $pagePath); |
|
| 9539 | + if (is_array($arr)) |
|
| 9540 | 9540 | { |
| 9541 | - list($pageConfig,$timestamps)=$arr; |
|
| 9542 | - if($application->getMode()!==TApplicationMode::Performance) |
|
| 9541 | + list($pageConfig, $timestamps) = $arr; |
|
| 9542 | + if ($application->getMode() !== TApplicationMode::Performance) |
|
| 9543 | 9543 | { |
| 9544 | - foreach($timestamps as $fileName=>$timestamp) |
|
| 9544 | + foreach ($timestamps as $fileName=>$timestamp) |
|
| 9545 | 9545 | { |
| 9546 | - if($fileName===0) { |
|
| 9547 | - $appConfigFile=$application->getConfigurationFile(); |
|
| 9548 | - $currentTimestamp[0]=$appConfigFile===null?0:@filemtime($appConfigFile); |
|
| 9549 | - if($currentTimestamp[0]>$timestamp || ($timestamp>0 && !$currentTimestamp[0])) |
|
| 9550 | - $configCached=false; |
|
| 9546 | + if ($fileName === 0) { |
|
| 9547 | + $appConfigFile = $application->getConfigurationFile(); |
|
| 9548 | + $currentTimestamp[0] = $appConfigFile === null ? 0 : @filemtime($appConfigFile); |
|
| 9549 | + if ($currentTimestamp[0] > $timestamp || ($timestamp > 0 && !$currentTimestamp[0])) |
|
| 9550 | + $configCached = false; |
|
| 9551 | 9551 | } |
| 9552 | 9552 | else |
| 9553 | 9553 | { |
| 9554 | - $currentTimestamp[$fileName]=@filemtime($fileName); |
|
| 9555 | - if($currentTimestamp[$fileName]>$timestamp || ($timestamp>0 && !$currentTimestamp[$fileName])) |
|
| 9556 | - $configCached=false; |
|
| 9554 | + $currentTimestamp[$fileName] = @filemtime($fileName); |
|
| 9555 | + if ($currentTimestamp[$fileName] > $timestamp || ($timestamp > 0 && !$currentTimestamp[$fileName])) |
|
| 9556 | + $configCached = false; |
|
| 9557 | 9557 | } |
| 9558 | 9558 | } |
| 9559 | 9559 | } |
| 9560 | 9560 | } |
| 9561 | 9561 | else |
| 9562 | 9562 | { |
| 9563 | - $configCached=false; |
|
| 9564 | - $paths=explode('.',$pagePath); |
|
| 9565 | - $configPath=$this->getBasePath(); |
|
| 9566 | - $fileName = $this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
| 9563 | + $configCached = false; |
|
| 9564 | + $paths = explode('.', $pagePath); |
|
| 9565 | + $configPath = $this->getBasePath(); |
|
| 9566 | + $fileName = $this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP |
|
| 9567 | 9567 | ? self::CONFIG_FILE_PHP |
| 9568 | 9568 | : self::CONFIG_FILE_XML; |
| 9569 | - foreach($paths as $path) |
|
| 9569 | + foreach ($paths as $path) |
|
| 9570 | 9570 | { |
| 9571 | - $configFile=$configPath.DIRECTORY_SEPARATOR.$fileName; |
|
| 9572 | - $currentTimestamp[$configFile]=@filemtime($configFile); |
|
| 9573 | - $configPath.=DIRECTORY_SEPARATOR.$path; |
|
| 9571 | + $configFile = $configPath . DIRECTORY_SEPARATOR . $fileName; |
|
| 9572 | + $currentTimestamp[$configFile] = @filemtime($configFile); |
|
| 9573 | + $configPath .= DIRECTORY_SEPARATOR . $path; |
|
| 9574 | 9574 | } |
| 9575 | - $appConfigFile=$application->getConfigurationFile(); |
|
| 9576 | - $currentTimestamp[0]=$appConfigFile===null?0:@filemtime($appConfigFile); |
|
| 9575 | + $appConfigFile = $application->getConfigurationFile(); |
|
| 9576 | + $currentTimestamp[0] = $appConfigFile === null ? 0 : @filemtime($appConfigFile); |
|
| 9577 | 9577 | } |
| 9578 | - if(!$configCached) |
|
| 9578 | + if (!$configCached) |
|
| 9579 | 9579 | { |
| 9580 | - $pageConfig=new TPageConfiguration($pagePath); |
|
| 9581 | - if($config!==null) |
|
| 9580 | + $pageConfig = new TPageConfiguration($pagePath); |
|
| 9581 | + if ($config !== null) |
|
| 9582 | 9582 | { |
| 9583 | - if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
|
| 9584 | - $pageConfig->loadPageConfigurationFromPhp($config,$application->getBasePath(),''); |
|
| 9583 | + if ($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
| 9584 | + $pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), ''); |
|
| 9585 | 9585 | else |
| 9586 | - $pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),''); |
|
| 9586 | + $pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), ''); |
|
| 9587 | 9587 | } |
| 9588 | 9588 | $pageConfig->loadFromFiles($this->getBasePath()); |
| 9589 | - $cache->set(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath,array($pageConfig,$currentTimestamp)); |
|
| 9589 | + $cache->set(self::CONFIG_CACHE_PREFIX . $this->getID() . $pagePath, array($pageConfig, $currentTimestamp)); |
|
| 9590 | 9590 | } |
| 9591 | 9591 | } |
| 9592 | 9592 | return $pageConfig; |
| 9593 | 9593 | } |
| 9594 | 9594 | public function getTemplateManager() |
| 9595 | 9595 | { |
| 9596 | - if(!$this->_templateManager) |
|
| 9596 | + if (!$this->_templateManager) |
|
| 9597 | 9597 | { |
| 9598 | - $this->_templateManager=new TTemplateManager; |
|
| 9598 | + $this->_templateManager = new TTemplateManager; |
|
| 9599 | 9599 | $this->_templateManager->init(null); |
| 9600 | 9600 | } |
| 9601 | 9601 | return $this->_templateManager; |
| 9602 | 9602 | } |
| 9603 | 9603 | public function setTemplateManager(TTemplateManager $value) |
| 9604 | 9604 | { |
| 9605 | - $this->_templateManager=$value; |
|
| 9605 | + $this->_templateManager = $value; |
|
| 9606 | 9606 | } |
| 9607 | 9607 | public function getThemeManager() |
| 9608 | 9608 | { |
| 9609 | - if(!$this->_themeManager) |
|
| 9609 | + if (!$this->_themeManager) |
|
| 9610 | 9610 | { |
| 9611 | - $this->_themeManager=new TThemeManager; |
|
| 9611 | + $this->_themeManager = new TThemeManager; |
|
| 9612 | 9612 | $this->_themeManager->init(null); |
| 9613 | 9613 | } |
| 9614 | 9614 | return $this->_themeManager; |
| 9615 | 9615 | } |
| 9616 | 9616 | public function setThemeManager(TThemeManager $value) |
| 9617 | 9617 | { |
| 9618 | - $this->_themeManager=$value; |
|
| 9618 | + $this->_themeManager = $value; |
|
| 9619 | 9619 | } |
| 9620 | 9620 | public function getRequestedPagePath() |
| 9621 | 9621 | { |
| 9622 | - if($this->_pagePath===null) |
|
| 9622 | + if ($this->_pagePath === null) |
|
| 9623 | 9623 | { |
| 9624 | - $this->_pagePath=strtr($this->determineRequestedPagePath(),'/\\','..'); |
|
| 9625 | - if(empty($this->_pagePath)) |
|
| 9626 | - throw new THttpException(404,'pageservice_page_required'); |
|
| 9624 | + $this->_pagePath = strtr($this->determineRequestedPagePath(), '/\\', '..'); |
|
| 9625 | + if (empty($this->_pagePath)) |
|
| 9626 | + throw new THttpException(404, 'pageservice_page_required'); |
|
| 9627 | 9627 | } |
| 9628 | 9628 | return $this->_pagePath; |
| 9629 | 9629 | } |
@@ -9637,10 +9637,10 @@ discard block |
||
| 9637 | 9637 | } |
| 9638 | 9638 | public function setDefaultPage($value) |
| 9639 | 9639 | { |
| 9640 | - if($this->_initialized) |
|
| 9640 | + if ($this->_initialized) |
|
| 9641 | 9641 | throw new TInvalidOperationException('pageservice_defaultpage_unchangeable'); |
| 9642 | 9642 | else |
| 9643 | - $this->_defaultPage=$value; |
|
| 9643 | + $this->_defaultPage = $value; |
|
| 9644 | 9644 | } |
| 9645 | 9645 | public function getDefaultPageUrl() |
| 9646 | 9646 | { |
@@ -9648,29 +9648,29 @@ discard block |
||
| 9648 | 9648 | } |
| 9649 | 9649 | public function getBasePath() |
| 9650 | 9650 | { |
| 9651 | - if($this->_basePath===null) |
|
| 9651 | + if ($this->_basePath === null) |
|
| 9652 | 9652 | { |
| 9653 | - $basePath=$this->getApplication()->getBasePath().DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH; |
|
| 9654 | - if(($this->_basePath=realpath($basePath))===false || !is_dir($this->_basePath)) |
|
| 9653 | + $basePath = $this->getApplication()->getBasePath() . DIRECTORY_SEPARATOR . self::DEFAULT_BASEPATH; |
|
| 9654 | + if (($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath)) |
|
| 9655 | 9655 | { |
| 9656 | - $basePath=$this->getApplication()->getBasePath().DIRECTORY_SEPARATOR.self::FALLBACK_BASEPATH; |
|
| 9657 | - if(($this->_basePath=realpath($basePath))===false || !is_dir($this->_basePath)) |
|
| 9658 | - throw new TConfigurationException('pageservice_basepath_invalid',$basePath); |
|
| 9656 | + $basePath = $this->getApplication()->getBasePath() . DIRECTORY_SEPARATOR . self::FALLBACK_BASEPATH; |
|
| 9657 | + if (($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath)) |
|
| 9658 | + throw new TConfigurationException('pageservice_basepath_invalid', $basePath); |
|
| 9659 | 9659 | } |
| 9660 | 9660 | } |
| 9661 | 9661 | return $this->_basePath; |
| 9662 | 9662 | } |
| 9663 | 9663 | public function setBasePath($value) |
| 9664 | 9664 | { |
| 9665 | - if($this->_initialized) |
|
| 9665 | + if ($this->_initialized) |
|
| 9666 | 9666 | throw new TInvalidOperationException('pageservice_basepath_unchangeable'); |
| 9667 | - else if(($path=Prado::getPathOfNamespace($value))===null || !is_dir($path)) |
|
| 9668 | - throw new TConfigurationException('pageservice_basepath_invalid',$value); |
|
| 9669 | - $this->_basePath=realpath($path); |
|
| 9667 | + else if (($path = Prado::getPathOfNamespace($value)) === null || !is_dir($path)) |
|
| 9668 | + throw new TConfigurationException('pageservice_basepath_invalid', $value); |
|
| 9669 | + $this->_basePath = realpath($path); |
|
| 9670 | 9670 | } |
| 9671 | 9671 | public function setBasePageClass($value) |
| 9672 | 9672 | { |
| 9673 | - $this->_basePageClass=$value; |
|
| 9673 | + $this->_basePageClass = $value; |
|
| 9674 | 9674 | } |
| 9675 | 9675 | public function getBasePageClass() |
| 9676 | 9676 | { |
@@ -9678,7 +9678,7 @@ discard block |
||
| 9678 | 9678 | } |
| 9679 | 9679 | public function setClientScriptManagerClass($value) |
| 9680 | 9680 | { |
| 9681 | - $this->_clientScriptManagerClass=$value; |
|
| 9681 | + $this->_clientScriptManagerClass = $value; |
|
| 9682 | 9682 | } |
| 9683 | 9683 | public function getClientScriptManagerClass() |
| 9684 | 9684 | { |
@@ -9686,58 +9686,58 @@ discard block |
||
| 9686 | 9686 | } |
| 9687 | 9687 | public function run() |
| 9688 | 9688 | { |
| 9689 | - $this->_page=$this->createPage($this->getRequestedPagePath()); |
|
| 9690 | - $this->runPage($this->_page,$this->_properties); |
|
| 9689 | + $this->_page = $this->createPage($this->getRequestedPagePath()); |
|
| 9690 | + $this->runPage($this->_page, $this->_properties); |
|
| 9691 | 9691 | } |
| 9692 | 9692 | protected function createPage($pagePath) |
| 9693 | 9693 | { |
| 9694 | - $path=$this->getBasePath().DIRECTORY_SEPARATOR.strtr($pagePath,'.',DIRECTORY_SEPARATOR); |
|
| 9695 | - $hasTemplateFile=is_file($path.self::PAGE_FILE_EXT); |
|
| 9696 | - $hasClassFile=is_file($path.Prado::CLASS_FILE_EXT); |
|
| 9697 | - if(!$hasTemplateFile && !$hasClassFile) |
|
| 9698 | - throw new THttpException(404,'pageservice_page_unknown',$pagePath); |
|
| 9699 | - if($hasClassFile) |
|
| 9694 | + $path = $this->getBasePath() . DIRECTORY_SEPARATOR . strtr($pagePath, '.', DIRECTORY_SEPARATOR); |
|
| 9695 | + $hasTemplateFile = is_file($path . self::PAGE_FILE_EXT); |
|
| 9696 | + $hasClassFile = is_file($path . Prado::CLASS_FILE_EXT); |
|
| 9697 | + if (!$hasTemplateFile && !$hasClassFile) |
|
| 9698 | + throw new THttpException(404, 'pageservice_page_unknown', $pagePath); |
|
| 9699 | + if ($hasClassFile) |
|
| 9700 | 9700 | { |
| 9701 | - $className=basename($path); |
|
| 9702 | - if(!class_exists($className,false)) |
|
| 9703 | - include_once($path.Prado::CLASS_FILE_EXT); |
|
| 9701 | + $className = basename($path); |
|
| 9702 | + if (!class_exists($className, false)) |
|
| 9703 | + include_once($path . Prado::CLASS_FILE_EXT); |
|
| 9704 | 9704 | } |
| 9705 | 9705 | else |
| 9706 | 9706 | { |
| 9707 | - $className=$this->getBasePageClass(); |
|
| 9707 | + $className = $this->getBasePageClass(); |
|
| 9708 | 9708 | Prado::using($className); |
| 9709 | - if(($pos=strrpos($className,'.'))!==false) |
|
| 9710 | - $className=substr($className,$pos+1); |
|
| 9709 | + if (($pos = strrpos($className, '.')) !== false) |
|
| 9710 | + $className = substr($className, $pos + 1); |
|
| 9711 | 9711 | } |
| 9712 | - if(!class_exists($className,false) || ($className!=='TPage' && !is_subclass_of($className,'TPage'))) |
|
| 9713 | - throw new THttpException(404,'pageservice_page_unknown',$pagePath); |
|
| 9714 | - $page=Prado::createComponent($className); |
|
| 9712 | + if (!class_exists($className, false) || ($className !== 'TPage' && !is_subclass_of($className, 'TPage'))) |
|
| 9713 | + throw new THttpException(404, 'pageservice_page_unknown', $pagePath); |
|
| 9714 | + $page = Prado::createComponent($className); |
|
| 9715 | 9715 | $page->setPagePath($pagePath); |
| 9716 | - if($hasTemplateFile) |
|
| 9717 | - $page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path.self::PAGE_FILE_EXT)); |
|
| 9716 | + if ($hasTemplateFile) |
|
| 9717 | + $page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path . self::PAGE_FILE_EXT)); |
|
| 9718 | 9718 | return $page; |
| 9719 | 9719 | } |
| 9720 | - protected function runPage($page,$properties) |
|
| 9720 | + protected function runPage($page, $properties) |
|
| 9721 | 9721 | { |
| 9722 | - foreach($properties as $name=>$value) |
|
| 9723 | - $page->setSubProperty($name,$value); |
|
| 9722 | + foreach ($properties as $name=>$value) |
|
| 9723 | + $page->setSubProperty($name, $value); |
|
| 9724 | 9724 | $page->run($this->getResponse()->createHtmlWriter()); |
| 9725 | 9725 | } |
| 9726 | - public function constructUrl($pagePath,$getParams=null,$encodeAmpersand=true,$encodeGetItems=true) |
|
| 9726 | + public function constructUrl($pagePath, $getParams = null, $encodeAmpersand = true, $encodeGetItems = true) |
|
| 9727 | 9727 | { |
| 9728 | - return $this->getRequest()->constructUrl($this->getID(),$pagePath,$getParams,$encodeAmpersand,$encodeGetItems); |
|
| 9728 | + return $this->getRequest()->constructUrl($this->getID(), $pagePath, $getParams, $encodeAmpersand, $encodeGetItems); |
|
| 9729 | 9729 | } |
| 9730 | 9730 | } |
| 9731 | 9731 | class TPageConfiguration extends TComponent |
| 9732 | 9732 | { |
| 9733 | - private $_appConfigs=array(); |
|
| 9734 | - private $_properties=array(); |
|
| 9735 | - private $_rules=array(); |
|
| 9736 | - private $_includes=array(); |
|
| 9737 | - private $_pagePath=''; |
|
| 9733 | + private $_appConfigs = array(); |
|
| 9734 | + private $_properties = array(); |
|
| 9735 | + private $_rules = array(); |
|
| 9736 | + private $_includes = array(); |
|
| 9737 | + private $_pagePath = ''; |
|
| 9738 | 9738 | public function __construct($pagePath) |
| 9739 | 9739 | { |
| 9740 | - $this->_pagePath=$pagePath; |
|
| 9740 | + $this->_pagePath = $pagePath; |
|
| 9741 | 9741 | } |
| 9742 | 9742 | public function getExternalConfigurations() |
| 9743 | 9743 | { |
@@ -9757,236 +9757,236 @@ discard block |
||
| 9757 | 9757 | } |
| 9758 | 9758 | public function loadFromFiles($basePath) |
| 9759 | 9759 | { |
| 9760 | - $paths=explode('.',$this->_pagePath); |
|
| 9761 | - $page=array_pop($paths); |
|
| 9762 | - $path=$basePath; |
|
| 9763 | - $configPagePath=''; |
|
| 9764 | - $fileName = Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
| 9760 | + $paths = explode('.', $this->_pagePath); |
|
| 9761 | + $page = array_pop($paths); |
|
| 9762 | + $path = $basePath; |
|
| 9763 | + $configPagePath = ''; |
|
| 9764 | + $fileName = Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP |
|
| 9765 | 9765 | ? TPageService::CONFIG_FILE_PHP |
| 9766 | 9766 | : TPageService::CONFIG_FILE_XML; |
| 9767 | - foreach($paths as $p) |
|
| 9767 | + foreach ($paths as $p) |
|
| 9768 | 9768 | { |
| 9769 | - $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName,$configPagePath); |
|
| 9770 | - $path.=DIRECTORY_SEPARATOR.$p; |
|
| 9771 | - if($configPagePath==='') |
|
| 9772 | - $configPagePath=$p; |
|
| 9769 | + $this->loadFromFile($path . DIRECTORY_SEPARATOR . $fileName, $configPagePath); |
|
| 9770 | + $path .= DIRECTORY_SEPARATOR . $p; |
|
| 9771 | + if ($configPagePath === '') |
|
| 9772 | + $configPagePath = $p; |
|
| 9773 | 9773 | else |
| 9774 | - $configPagePath.='.'.$p; |
|
| 9774 | + $configPagePath .= '.' . $p; |
|
| 9775 | 9775 | } |
| 9776 | - $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName,$configPagePath); |
|
| 9777 | - $this->_rules=new TAuthorizationRuleCollection($this->_rules); |
|
| 9776 | + $this->loadFromFile($path . DIRECTORY_SEPARATOR . $fileName, $configPagePath); |
|
| 9777 | + $this->_rules = new TAuthorizationRuleCollection($this->_rules); |
|
| 9778 | 9778 | } |
| 9779 | - public function loadFromFile($fname,$configPagePath) |
|
| 9779 | + public function loadFromFile($fname, $configPagePath) |
|
| 9780 | 9780 | { |
| 9781 | - if(empty($fname) || !is_file($fname)) |
|
| 9781 | + if (empty($fname) || !is_file($fname)) |
|
| 9782 | 9782 | return; |
| 9783 | - if(Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
|
| 9783 | + if (Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
| 9784 | 9784 | { |
| 9785 | 9785 | $fcontent = include $fname; |
| 9786 | - $this->loadFromPhp($fcontent,dirname($fname),$configPagePath); |
|
| 9786 | + $this->loadFromPhp($fcontent, dirname($fname), $configPagePath); |
|
| 9787 | 9787 | } |
| 9788 | 9788 | else |
| 9789 | 9789 | { |
| 9790 | - $dom=new TXmlDocument; |
|
| 9791 | - if($dom->loadFromFile($fname)) |
|
| 9792 | - $this->loadFromXml($dom,dirname($fname),$configPagePath); |
|
| 9790 | + $dom = new TXmlDocument; |
|
| 9791 | + if ($dom->loadFromFile($fname)) |
|
| 9792 | + $this->loadFromXml($dom, dirname($fname), $configPagePath); |
|
| 9793 | 9793 | else |
| 9794 | - throw new TConfigurationException('pageserviceconf_file_invalid',$fname); |
|
| 9794 | + throw new TConfigurationException('pageserviceconf_file_invalid', $fname); |
|
| 9795 | 9795 | } |
| 9796 | 9796 | } |
| 9797 | - public function loadFromPhp($config,$configPath,$configPagePath) |
|
| 9797 | + public function loadFromPhp($config, $configPath, $configPagePath) |
|
| 9798 | 9798 | { |
| 9799 | - $this->loadApplicationConfigurationFromPhp($config,$configPath); |
|
| 9800 | - $this->loadPageConfigurationFromPhp($config,$configPath,$configPagePath); |
|
| 9799 | + $this->loadApplicationConfigurationFromPhp($config, $configPath); |
|
| 9800 | + $this->loadPageConfigurationFromPhp($config, $configPath, $configPagePath); |
|
| 9801 | 9801 | } |
| 9802 | - public function loadFromXml($dom,$configPath,$configPagePath) |
|
| 9802 | + public function loadFromXml($dom, $configPath, $configPagePath) |
|
| 9803 | 9803 | { |
| 9804 | - $this->loadApplicationConfigurationFromXml($dom,$configPath); |
|
| 9805 | - $this->loadPageConfigurationFromXml($dom,$configPath,$configPagePath); |
|
| 9804 | + $this->loadApplicationConfigurationFromXml($dom, $configPath); |
|
| 9805 | + $this->loadPageConfigurationFromXml($dom, $configPath, $configPagePath); |
|
| 9806 | 9806 | } |
| 9807 | - public function loadApplicationConfigurationFromPhp($config,$configPath) |
|
| 9807 | + public function loadApplicationConfigurationFromPhp($config, $configPath) |
|
| 9808 | 9808 | { |
| 9809 | - $appConfig=new TApplicationConfiguration; |
|
| 9810 | - $appConfig->loadFromPhp($config,$configPath); |
|
| 9811 | - $this->_appConfigs[]=$appConfig; |
|
| 9809 | + $appConfig = new TApplicationConfiguration; |
|
| 9810 | + $appConfig->loadFromPhp($config, $configPath); |
|
| 9811 | + $this->_appConfigs[] = $appConfig; |
|
| 9812 | 9812 | } |
| 9813 | - public function loadApplicationConfigurationFromXml($dom,$configPath) |
|
| 9813 | + public function loadApplicationConfigurationFromXml($dom, $configPath) |
|
| 9814 | 9814 | { |
| 9815 | - $appConfig=new TApplicationConfiguration; |
|
| 9816 | - $appConfig->loadFromXml($dom,$configPath); |
|
| 9817 | - $this->_appConfigs[]=$appConfig; |
|
| 9815 | + $appConfig = new TApplicationConfiguration; |
|
| 9816 | + $appConfig->loadFromXml($dom, $configPath); |
|
| 9817 | + $this->_appConfigs[] = $appConfig; |
|
| 9818 | 9818 | } |
| 9819 | 9819 | public function loadPageConfigurationFromPhp($config, $configPath, $configPagePath) |
| 9820 | 9820 | { |
| 9821 | - if(isset($config['authorization']) && is_array($config['authorization'])) |
|
| 9821 | + if (isset($config['authorization']) && is_array($config['authorization'])) |
|
| 9822 | 9822 | { |
| 9823 | 9823 | $rules = array(); |
| 9824 | - foreach($config['authorization'] as $authorization) |
|
| 9824 | + foreach ($config['authorization'] as $authorization) |
|
| 9825 | 9825 | { |
| 9826 | - $patterns=isset($authorization['pages'])?$authorization['pages']:''; |
|
| 9827 | - $ruleApplies=false; |
|
| 9828 | - if(empty($patterns) || trim($patterns)==='*') $ruleApplies=true; |
|
| 9826 | + $patterns = isset($authorization['pages']) ? $authorization['pages'] : ''; |
|
| 9827 | + $ruleApplies = false; |
|
| 9828 | + if (empty($patterns) || trim($patterns) === '*') $ruleApplies = true; |
|
| 9829 | 9829 | else |
| 9830 | 9830 | { |
| 9831 | - foreach(explode(',',$patterns) as $pattern) |
|
| 9831 | + foreach (explode(',', $patterns) as $pattern) |
|
| 9832 | 9832 | { |
| 9833 | - if(($pattern=trim($pattern))!=='') |
|
| 9833 | + if (($pattern = trim($pattern)) !== '') |
|
| 9834 | 9834 | { |
| 9835 | - if($configPagePath!=='') $pattern=$configPagePath.'.'.$pattern; |
|
| 9836 | - if(strcasecmp($pattern,$this->_pagePath)===0) |
|
| 9835 | + if ($configPagePath !== '') $pattern = $configPagePath . '.' . $pattern; |
|
| 9836 | + if (strcasecmp($pattern, $this->_pagePath) === 0) |
|
| 9837 | 9837 | { |
| 9838 | - $ruleApplies=true; |
|
| 9838 | + $ruleApplies = true; |
|
| 9839 | 9839 | break; |
| 9840 | 9840 | } |
| 9841 | - if($pattern[strlen($pattern)-1]==='*') { |
|
| 9842 | - if(strncasecmp($this->_pagePath,$pattern,strlen($pattern)-1)===0) |
|
| 9841 | + if ($pattern[strlen($pattern) - 1] === '*') { |
|
| 9842 | + if (strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1) === 0) |
|
| 9843 | 9843 | { |
| 9844 | - $ruleApplies=true; |
|
| 9844 | + $ruleApplies = true; |
|
| 9845 | 9845 | break; |
| 9846 | 9846 | } |
| 9847 | 9847 | } |
| 9848 | 9848 | } |
| 9849 | 9849 | } |
| 9850 | 9850 | } |
| 9851 | - if($ruleApplies) |
|
| 9851 | + if ($ruleApplies) |
|
| 9852 | 9852 | { |
| 9853 | - $action = isset($authorization['action'])?$authorization['action']:''; |
|
| 9854 | - $users = isset($authorization['users'])?$authorization['users']:''; |
|
| 9855 | - $roles = isset($authorization['roles'])?$authorization['roles']:''; |
|
| 9856 | - $verb = isset($authorization['verb'])?$authorization['verb']:''; |
|
| 9857 | - $ips = isset($authorization['ips'])?$authorization['ips']:''; |
|
| 9858 | - $rules[]=new TAuthorizationRule($action,$users,$roles,$verb,$ips); |
|
| 9853 | + $action = isset($authorization['action']) ? $authorization['action'] : ''; |
|
| 9854 | + $users = isset($authorization['users']) ? $authorization['users'] : ''; |
|
| 9855 | + $roles = isset($authorization['roles']) ? $authorization['roles'] : ''; |
|
| 9856 | + $verb = isset($authorization['verb']) ? $authorization['verb'] : ''; |
|
| 9857 | + $ips = isset($authorization['ips']) ? $authorization['ips'] : ''; |
|
| 9858 | + $rules[] = new TAuthorizationRule($action, $users, $roles, $verb, $ips); |
|
| 9859 | 9859 | } |
| 9860 | 9860 | } |
| 9861 | - $this->_rules=array_merge($rules,$this->_rules); |
|
| 9861 | + $this->_rules = array_merge($rules, $this->_rules); |
|
| 9862 | 9862 | } |
| 9863 | - if(isset($config['pages']) && is_array($config['pages'])) |
|
| 9863 | + if (isset($config['pages']) && is_array($config['pages'])) |
|
| 9864 | 9864 | { |
| 9865 | - if(isset($config['pages']['properties'])) |
|
| 9865 | + if (isset($config['pages']['properties'])) |
|
| 9866 | 9866 | { |
| 9867 | 9867 | $this->_properties = array_merge($this->_properties, $config['pages']['properties']); |
| 9868 | 9868 | unset($config['pages']['properties']); |
| 9869 | 9869 | } |
| 9870 | - foreach($config['pages'] as $id => $page) |
|
| 9870 | + foreach ($config['pages'] as $id => $page) |
|
| 9871 | 9871 | { |
| 9872 | 9872 | $properties = array(); |
| 9873 | - if(isset($page['properties'])) |
|
| 9873 | + if (isset($page['properties'])) |
|
| 9874 | 9874 | { |
| 9875 | - $properties=$page['properties']; |
|
| 9875 | + $properties = $page['properties']; |
|
| 9876 | 9876 | unset($page['properties']); |
| 9877 | 9877 | } |
| 9878 | - $matching=false; |
|
| 9879 | - $id=($configPagePath==='')?$id:$configPagePath.'.'.$id; |
|
| 9880 | - if(strcasecmp($id,$this->_pagePath)===0) |
|
| 9881 | - $matching=true; |
|
| 9882 | - else if($id[strlen($id)-1]==='*') $matching=strncasecmp($this->_pagePath,$id,strlen($id)-1)===0; |
|
| 9883 | - if($matching) |
|
| 9884 | - $this->_properties=array_merge($this->_properties,$properties); |
|
| 9878 | + $matching = false; |
|
| 9879 | + $id = ($configPagePath === '') ? $id : $configPagePath . '.' . $id; |
|
| 9880 | + if (strcasecmp($id, $this->_pagePath) === 0) |
|
| 9881 | + $matching = true; |
|
| 9882 | + else if ($id[strlen($id) - 1] === '*') $matching = strncasecmp($this->_pagePath, $id, strlen($id) - 1) === 0; |
|
| 9883 | + if ($matching) |
|
| 9884 | + $this->_properties = array_merge($this->_properties, $properties); |
|
| 9885 | 9885 | } |
| 9886 | 9886 | } |
| 9887 | - if(isset($config['includes']) && is_array($config['includes'])) |
|
| 9887 | + if (isset($config['includes']) && is_array($config['includes'])) |
|
| 9888 | 9888 | { |
| 9889 | - foreach($config['includes'] as $include) |
|
| 9889 | + foreach ($config['includes'] as $include) |
|
| 9890 | 9890 | { |
| 9891 | - $when = isset($include['when'])?true:false; |
|
| 9892 | - if(!isset($include['file'])) |
|
| 9891 | + $when = isset($include['when']) ? true : false; |
|
| 9892 | + if (!isset($include['file'])) |
|
| 9893 | 9893 | throw new TConfigurationException('pageserviceconf_includefile_required'); |
| 9894 | 9894 | $filePath = $include['file']; |
| 9895 | - if(isset($this->_includes[$filePath])) |
|
| 9896 | - $this->_includes[$filePath]=array($configPagePath,'('.$this->_includes[$filePath][1].') || ('.$when.')'); |
|
| 9895 | + if (isset($this->_includes[$filePath])) |
|
| 9896 | + $this->_includes[$filePath] = array($configPagePath, '(' . $this->_includes[$filePath][1] . ') || (' . $when . ')'); |
|
| 9897 | 9897 | else |
| 9898 | - $this->_includes[$filePath]=array($configPagePath,$when); |
|
| 9898 | + $this->_includes[$filePath] = array($configPagePath, $when); |
|
| 9899 | 9899 | } |
| 9900 | 9900 | } |
| 9901 | 9901 | } |
| 9902 | - public function loadPageConfigurationFromXml($dom,$configPath,$configPagePath) |
|
| 9902 | + public function loadPageConfigurationFromXml($dom, $configPath, $configPagePath) |
|
| 9903 | 9903 | { |
| 9904 | - if(($authorizationNode=$dom->getElementByTagName('authorization'))!==null) |
|
| 9904 | + if (($authorizationNode = $dom->getElementByTagName('authorization')) !== null) |
|
| 9905 | 9905 | { |
| 9906 | - $rules=array(); |
|
| 9907 | - foreach($authorizationNode->getElements() as $node) |
|
| 9906 | + $rules = array(); |
|
| 9907 | + foreach ($authorizationNode->getElements() as $node) |
|
| 9908 | 9908 | { |
| 9909 | - $patterns=$node->getAttribute('pages'); |
|
| 9910 | - $ruleApplies=false; |
|
| 9911 | - if(empty($patterns) || trim($patterns)==='*') $ruleApplies=true; |
|
| 9909 | + $patterns = $node->getAttribute('pages'); |
|
| 9910 | + $ruleApplies = false; |
|
| 9911 | + if (empty($patterns) || trim($patterns) === '*') $ruleApplies = true; |
|
| 9912 | 9912 | else |
| 9913 | 9913 | { |
| 9914 | - foreach(explode(',',$patterns) as $pattern) |
|
| 9914 | + foreach (explode(',', $patterns) as $pattern) |
|
| 9915 | 9915 | { |
| 9916 | - if(($pattern=trim($pattern))!=='') |
|
| 9916 | + if (($pattern = trim($pattern)) !== '') |
|
| 9917 | 9917 | { |
| 9918 | - if($configPagePath!=='') $pattern=$configPagePath.'.'.$pattern; |
|
| 9919 | - if(strcasecmp($pattern,$this->_pagePath)===0) |
|
| 9918 | + if ($configPagePath !== '') $pattern = $configPagePath . '.' . $pattern; |
|
| 9919 | + if (strcasecmp($pattern, $this->_pagePath) === 0) |
|
| 9920 | 9920 | { |
| 9921 | - $ruleApplies=true; |
|
| 9921 | + $ruleApplies = true; |
|
| 9922 | 9922 | break; |
| 9923 | 9923 | } |
| 9924 | - if($pattern[strlen($pattern)-1]==='*') { |
|
| 9925 | - if(strncasecmp($this->_pagePath,$pattern,strlen($pattern)-1)===0) |
|
| 9924 | + if ($pattern[strlen($pattern) - 1] === '*') { |
|
| 9925 | + if (strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1) === 0) |
|
| 9926 | 9926 | { |
| 9927 | - $ruleApplies=true; |
|
| 9927 | + $ruleApplies = true; |
|
| 9928 | 9928 | break; |
| 9929 | 9929 | } |
| 9930 | 9930 | } |
| 9931 | 9931 | } |
| 9932 | 9932 | } |
| 9933 | 9933 | } |
| 9934 | - if($ruleApplies) |
|
| 9935 | - $rules[]=new TAuthorizationRule($node->getTagName(),$node->getAttribute('users'),$node->getAttribute('roles'),$node->getAttribute('verb'),$node->getAttribute('ips')); |
|
| 9934 | + if ($ruleApplies) |
|
| 9935 | + $rules[] = new TAuthorizationRule($node->getTagName(), $node->getAttribute('users'), $node->getAttribute('roles'), $node->getAttribute('verb'), $node->getAttribute('ips')); |
|
| 9936 | 9936 | } |
| 9937 | - $this->_rules=array_merge($rules,$this->_rules); |
|
| 9937 | + $this->_rules = array_merge($rules, $this->_rules); |
|
| 9938 | 9938 | } |
| 9939 | - if(($pagesNode=$dom->getElementByTagName('pages'))!==null) |
|
| 9939 | + if (($pagesNode = $dom->getElementByTagName('pages')) !== null) |
|
| 9940 | 9940 | { |
| 9941 | - $this->_properties=array_merge($this->_properties,$pagesNode->getAttributes()->toArray()); |
|
| 9942 | - foreach($pagesNode->getElementsByTagName('page') as $node) |
|
| 9941 | + $this->_properties = array_merge($this->_properties, $pagesNode->getAttributes()->toArray()); |
|
| 9942 | + foreach ($pagesNode->getElementsByTagName('page') as $node) |
|
| 9943 | 9943 | { |
| 9944 | - $properties=$node->getAttributes(); |
|
| 9945 | - $id=$properties->remove('id'); |
|
| 9946 | - if(empty($id)) |
|
| 9947 | - throw new TConfigurationException('pageserviceconf_page_invalid',$configPath); |
|
| 9948 | - $matching=false; |
|
| 9949 | - $id=($configPagePath==='')?$id:$configPagePath.'.'.$id; |
|
| 9950 | - if(strcasecmp($id,$this->_pagePath)===0) |
|
| 9951 | - $matching=true; |
|
| 9952 | - else if($id[strlen($id)-1]==='*') $matching=strncasecmp($this->_pagePath,$id,strlen($id)-1)===0; |
|
| 9953 | - if($matching) |
|
| 9954 | - $this->_properties=array_merge($this->_properties,$properties->toArray()); |
|
| 9944 | + $properties = $node->getAttributes(); |
|
| 9945 | + $id = $properties->remove('id'); |
|
| 9946 | + if (empty($id)) |
|
| 9947 | + throw new TConfigurationException('pageserviceconf_page_invalid', $configPath); |
|
| 9948 | + $matching = false; |
|
| 9949 | + $id = ($configPagePath === '') ? $id : $configPagePath . '.' . $id; |
|
| 9950 | + if (strcasecmp($id, $this->_pagePath) === 0) |
|
| 9951 | + $matching = true; |
|
| 9952 | + else if ($id[strlen($id) - 1] === '*') $matching = strncasecmp($this->_pagePath, $id, strlen($id) - 1) === 0; |
|
| 9953 | + if ($matching) |
|
| 9954 | + $this->_properties = array_merge($this->_properties, $properties->toArray()); |
|
| 9955 | 9955 | } |
| 9956 | 9956 | } |
| 9957 | - foreach($dom->getElementsByTagName('include') as $node) |
|
| 9957 | + foreach ($dom->getElementsByTagName('include') as $node) |
|
| 9958 | 9958 | { |
| 9959 | - if(($when=$node->getAttribute('when'))===null) |
|
| 9960 | - $when=true; |
|
| 9961 | - if(($filePath=$node->getAttribute('file'))===null) |
|
| 9959 | + if (($when = $node->getAttribute('when')) === null) |
|
| 9960 | + $when = true; |
|
| 9961 | + if (($filePath = $node->getAttribute('file')) === null) |
|
| 9962 | 9962 | throw new TConfigurationException('pageserviceconf_includefile_required'); |
| 9963 | - if(isset($this->_includes[$filePath])) |
|
| 9964 | - $this->_includes[$filePath]=array($configPagePath,'('.$this->_includes[$filePath][1].') || ('.$when.')'); |
|
| 9963 | + if (isset($this->_includes[$filePath])) |
|
| 9964 | + $this->_includes[$filePath] = array($configPagePath, '(' . $this->_includes[$filePath][1] . ') || (' . $when . ')'); |
|
| 9965 | 9965 | else |
| 9966 | - $this->_includes[$filePath]=array($configPagePath,$when); |
|
| 9966 | + $this->_includes[$filePath] = array($configPagePath, $when); |
|
| 9967 | 9967 | } |
| 9968 | 9968 | } |
| 9969 | 9969 | } |
| 9970 | 9970 | class TAssetManager extends TModule |
| 9971 | 9971 | { |
| 9972 | - const DEFAULT_BASEPATH='assets'; |
|
| 9973 | - private $_basePath=null; |
|
| 9974 | - private $_baseUrl=null; |
|
| 9975 | - private $_checkTimestamp=false; |
|
| 9972 | + const DEFAULT_BASEPATH = 'assets'; |
|
| 9973 | + private $_basePath = null; |
|
| 9974 | + private $_baseUrl = null; |
|
| 9975 | + private $_checkTimestamp = false; |
|
| 9976 | 9976 | private $_application; |
| 9977 | - private $_published=array(); |
|
| 9978 | - private $_initialized=false; |
|
| 9977 | + private $_published = array(); |
|
| 9978 | + private $_initialized = false; |
|
| 9979 | 9979 | public function init($config) |
| 9980 | 9980 | { |
| 9981 | - $application=$this->getApplication(); |
|
| 9982 | - if($this->_basePath===null) |
|
| 9983 | - $this->_basePath=dirname($application->getRequest()->getApplicationFilePath()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH; |
|
| 9984 | - if(!is_writable($this->_basePath) || !is_dir($this->_basePath)) |
|
| 9985 | - throw new TConfigurationException('assetmanager_basepath_invalid',$this->_basePath); |
|
| 9986 | - if($this->_baseUrl===null) |
|
| 9987 | - $this->_baseUrl=rtrim(dirname($application->getRequest()->getApplicationUrl()),'/\\').'/'.self::DEFAULT_BASEPATH; |
|
| 9981 | + $application = $this->getApplication(); |
|
| 9982 | + if ($this->_basePath === null) |
|
| 9983 | + $this->_basePath = dirname($application->getRequest()->getApplicationFilePath()) . DIRECTORY_SEPARATOR . self::DEFAULT_BASEPATH; |
|
| 9984 | + if (!is_writable($this->_basePath) || !is_dir($this->_basePath)) |
|
| 9985 | + throw new TConfigurationException('assetmanager_basepath_invalid', $this->_basePath); |
|
| 9986 | + if ($this->_baseUrl === null) |
|
| 9987 | + $this->_baseUrl = rtrim(dirname($application->getRequest()->getApplicationUrl()), '/\\') . '/' . self::DEFAULT_BASEPATH; |
|
| 9988 | 9988 | $application->setAssetManager($this); |
| 9989 | - $this->_initialized=true; |
|
| 9989 | + $this->_initialized = true; |
|
| 9990 | 9990 | } |
| 9991 | 9991 | public function getBasePath() |
| 9992 | 9992 | { |
@@ -9994,13 +9994,13 @@ discard block |
||
| 9994 | 9994 | } |
| 9995 | 9995 | public function setBasePath($value) |
| 9996 | 9996 | { |
| 9997 | - if($this->_initialized) |
|
| 9997 | + if ($this->_initialized) |
|
| 9998 | 9998 | throw new TInvalidOperationException('assetmanager_basepath_unchangeable'); |
| 9999 | 9999 | else |
| 10000 | 10000 | { |
| 10001 | - $this->_basePath=Prado::getPathOfNamespace($value); |
|
| 10002 | - if($this->_basePath===null || !is_dir($this->_basePath) || !is_writable($this->_basePath)) |
|
| 10003 | - throw new TInvalidDataValueException('assetmanager_basepath_invalid',$value); |
|
| 10001 | + $this->_basePath = Prado::getPathOfNamespace($value); |
|
| 10002 | + if ($this->_basePath === null || !is_dir($this->_basePath) || !is_writable($this->_basePath)) |
|
| 10003 | + throw new TInvalidDataValueException('assetmanager_basepath_invalid', $value); |
|
| 10004 | 10004 | } |
| 10005 | 10005 | } |
| 10006 | 10006 | public function getBaseUrl() |
@@ -10009,132 +10009,132 @@ discard block |
||
| 10009 | 10009 | } |
| 10010 | 10010 | public function setBaseUrl($value) |
| 10011 | 10011 | { |
| 10012 | - if($this->_initialized) |
|
| 10012 | + if ($this->_initialized) |
|
| 10013 | 10013 | throw new TInvalidOperationException('assetmanager_baseurl_unchangeable'); |
| 10014 | 10014 | else |
| 10015 | - $this->_baseUrl=rtrim($value,'/'); |
|
| 10015 | + $this->_baseUrl = rtrim($value, '/'); |
|
| 10016 | 10016 | } |
| 10017 | - public function publishFilePath($path,$checkTimestamp=false) |
|
| 10017 | + public function publishFilePath($path, $checkTimestamp = false) |
|
| 10018 | 10018 | { |
| 10019 | - if(isset($this->_published[$path])) |
|
| 10019 | + if (isset($this->_published[$path])) |
|
| 10020 | 10020 | return $this->_published[$path]; |
| 10021 | - else if(empty($path) || ($fullpath=realpath($path))===false) |
|
| 10022 | - throw new TInvalidDataValueException('assetmanager_filepath_invalid',$path); |
|
| 10023 | - else if(is_file($fullpath)) |
|
| 10021 | + else if (empty($path) || ($fullpath = realpath($path)) === false) |
|
| 10022 | + throw new TInvalidDataValueException('assetmanager_filepath_invalid', $path); |
|
| 10023 | + else if (is_file($fullpath)) |
|
| 10024 | 10024 | { |
| 10025 | - $dir=$this->hash(dirname($fullpath)); |
|
| 10026 | - $fileName=basename($fullpath); |
|
| 10027 | - $dst=$this->_basePath.DIRECTORY_SEPARATOR.$dir; |
|
| 10028 | - if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
| 10029 | - $this->copyFile($fullpath,$dst); |
|
| 10030 | - return $this->_published[$path]=$this->_baseUrl.'/'.$dir.'/'.$fileName; |
|
| 10025 | + $dir = $this->hash(dirname($fullpath)); |
|
| 10026 | + $fileName = basename($fullpath); |
|
| 10027 | + $dst = $this->_basePath . DIRECTORY_SEPARATOR . $dir; |
|
| 10028 | + if (!is_file($dst . DIRECTORY_SEPARATOR . $fileName) || $checkTimestamp || $this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
| 10029 | + $this->copyFile($fullpath, $dst); |
|
| 10030 | + return $this->_published[$path] = $this->_baseUrl . '/' . $dir . '/' . $fileName; |
|
| 10031 | 10031 | } |
| 10032 | 10032 | else |
| 10033 | 10033 | { |
| 10034 | - $dir=$this->hash($fullpath); |
|
| 10035 | - if(!is_dir($this->_basePath.DIRECTORY_SEPARATOR.$dir) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
| 10034 | + $dir = $this->hash($fullpath); |
|
| 10035 | + if (!is_dir($this->_basePath . DIRECTORY_SEPARATOR . $dir) || $checkTimestamp || $this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
| 10036 | 10036 | { |
| 10037 | - $this->copyDirectory($fullpath,$this->_basePath.DIRECTORY_SEPARATOR.$dir); |
|
| 10037 | + $this->copyDirectory($fullpath, $this->_basePath . DIRECTORY_SEPARATOR . $dir); |
|
| 10038 | 10038 | } |
| 10039 | - return $this->_published[$path]=$this->_baseUrl.'/'.$dir; |
|
| 10039 | + return $this->_published[$path] = $this->_baseUrl . '/' . $dir; |
|
| 10040 | 10040 | } |
| 10041 | 10041 | } |
| 10042 | 10042 | public function getPublished() |
| 10043 | 10043 | { |
| 10044 | 10044 | return $this->_published; |
| 10045 | 10045 | } |
| 10046 | - protected function setPublished($values=array()) |
|
| 10046 | + protected function setPublished($values = array()) |
|
| 10047 | 10047 | { |
| 10048 | 10048 | $this->_published = $values; |
| 10049 | 10049 | } |
| 10050 | 10050 | public function getPublishedPath($path) |
| 10051 | 10051 | { |
| 10052 | - $path=realpath($path); |
|
| 10053 | - if(is_file($path)) |
|
| 10054 | - return $this->_basePath.DIRECTORY_SEPARATOR.$this->hash(dirname($path)).DIRECTORY_SEPARATOR.basename($path); |
|
| 10052 | + $path = realpath($path); |
|
| 10053 | + if (is_file($path)) |
|
| 10054 | + return $this->_basePath . DIRECTORY_SEPARATOR . $this->hash(dirname($path)) . DIRECTORY_SEPARATOR . basename($path); |
|
| 10055 | 10055 | else |
| 10056 | - return $this->_basePath.DIRECTORY_SEPARATOR.$this->hash($path); |
|
| 10056 | + return $this->_basePath . DIRECTORY_SEPARATOR . $this->hash($path); |
|
| 10057 | 10057 | } |
| 10058 | 10058 | public function getPublishedUrl($path) |
| 10059 | 10059 | { |
| 10060 | - $path=realpath($path); |
|
| 10061 | - if(is_file($path)) |
|
| 10062 | - return $this->_baseUrl.'/'.$this->hash(dirname($path)).'/'.basename($path); |
|
| 10060 | + $path = realpath($path); |
|
| 10061 | + if (is_file($path)) |
|
| 10062 | + return $this->_baseUrl . '/' . $this->hash(dirname($path)) . '/' . basename($path); |
|
| 10063 | 10063 | else |
| 10064 | - return $this->_baseUrl.'/'.$this->hash($path); |
|
| 10064 | + return $this->_baseUrl . '/' . $this->hash($path); |
|
| 10065 | 10065 | } |
| 10066 | 10066 | protected function hash($dir) |
| 10067 | 10067 | { |
| 10068 | - return sprintf('%x',crc32($dir.Prado::getVersion())); |
|
| 10068 | + return sprintf('%x', crc32($dir . Prado::getVersion())); |
|
| 10069 | 10069 | } |
| 10070 | - protected function copyFile($src,$dst) |
|
| 10070 | + protected function copyFile($src, $dst) |
|
| 10071 | 10071 | { |
| 10072 | - if(!is_dir($dst)) |
|
| 10072 | + if (!is_dir($dst)) |
|
| 10073 | 10073 | { |
| 10074 | 10074 | @mkdir($dst); |
| 10075 | 10075 | @chmod($dst, PRADO_CHMOD); |
| 10076 | 10076 | } |
| 10077 | - $dstFile=$dst.DIRECTORY_SEPARATOR.basename($src); |
|
| 10078 | - if(@filemtime($dstFile)<@filemtime($src)) |
|
| 10077 | + $dstFile = $dst . DIRECTORY_SEPARATOR . basename($src); |
|
| 10078 | + if (@filemtime($dstFile) < @filemtime($src)) |
|
| 10079 | 10079 | { |
| 10080 | - @copy($src,$dstFile); |
|
| 10080 | + @copy($src, $dstFile); |
|
| 10081 | 10081 | } |
| 10082 | 10082 | } |
| 10083 | - public function copyDirectory($src,$dst) |
|
| 10083 | + public function copyDirectory($src, $dst) |
|
| 10084 | 10084 | { |
| 10085 | - if(!is_dir($dst)) |
|
| 10085 | + if (!is_dir($dst)) |
|
| 10086 | 10086 | { |
| 10087 | 10087 | @mkdir($dst); |
| 10088 | 10088 | @chmod($dst, PRADO_CHMOD); |
| 10089 | 10089 | } |
| 10090 | - if($folder=@opendir($src)) |
|
| 10090 | + if ($folder = @opendir($src)) |
|
| 10091 | 10091 | { |
| 10092 | - while($file=@readdir($folder)) |
|
| 10092 | + while ($file = @readdir($folder)) |
|
| 10093 | 10093 | { |
| 10094 | - if($file==='.' || $file==='..' || $file==='.svn') |
|
| 10094 | + if ($file === '.' || $file === '..' || $file === '.svn') |
|
| 10095 | 10095 | continue; |
| 10096 | - else if(is_file($src.DIRECTORY_SEPARATOR.$file)) |
|
| 10096 | + else if (is_file($src . DIRECTORY_SEPARATOR . $file)) |
|
| 10097 | 10097 | { |
| 10098 | - if(@filemtime($dst.DIRECTORY_SEPARATOR.$file)<@filemtime($src.DIRECTORY_SEPARATOR.$file)) |
|
| 10098 | + if (@filemtime($dst . DIRECTORY_SEPARATOR . $file) < @filemtime($src . DIRECTORY_SEPARATOR . $file)) |
|
| 10099 | 10099 | { |
| 10100 | - @copy($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
|
| 10101 | - @chmod($dst.DIRECTORY_SEPARATOR.$file, PRADO_CHMOD); |
|
| 10100 | + @copy($src . DIRECTORY_SEPARATOR . $file, $dst . DIRECTORY_SEPARATOR . $file); |
|
| 10101 | + @chmod($dst . DIRECTORY_SEPARATOR . $file, PRADO_CHMOD); |
|
| 10102 | 10102 | } |
| 10103 | 10103 | } |
| 10104 | 10104 | else |
| 10105 | - $this->copyDirectory($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
|
| 10105 | + $this->copyDirectory($src . DIRECTORY_SEPARATOR . $file, $dst . DIRECTORY_SEPARATOR . $file); |
|
| 10106 | 10106 | } |
| 10107 | 10107 | closedir($folder); |
| 10108 | 10108 | } else { |
| 10109 | 10109 | throw new TInvalidDataValueException('assetmanager_source_directory_invalid', $src); |
| 10110 | 10110 | } |
| 10111 | 10111 | } |
| 10112 | - public function publishTarFile($tarfile, $md5sum, $checkTimestamp=false) |
|
| 10112 | + public function publishTarFile($tarfile, $md5sum, $checkTimestamp = false) |
|
| 10113 | 10113 | { |
| 10114 | - if(isset($this->_published[$md5sum])) |
|
| 10114 | + if (isset($this->_published[$md5sum])) |
|
| 10115 | 10115 | return $this->_published[$md5sum]; |
| 10116 | - else if(($fullpath=realpath($md5sum))===false || !is_file($fullpath)) |
|
| 10117 | - throw new TInvalidDataValueException('assetmanager_tarchecksum_invalid',$md5sum); |
|
| 10116 | + else if (($fullpath = realpath($md5sum)) === false || !is_file($fullpath)) |
|
| 10117 | + throw new TInvalidDataValueException('assetmanager_tarchecksum_invalid', $md5sum); |
|
| 10118 | 10118 | else |
| 10119 | 10119 | { |
| 10120 | - $dir=$this->hash(dirname($fullpath)); |
|
| 10121 | - $fileName=basename($fullpath); |
|
| 10122 | - $dst=$this->_basePath.DIRECTORY_SEPARATOR.$dir; |
|
| 10123 | - if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
| 10120 | + $dir = $this->hash(dirname($fullpath)); |
|
| 10121 | + $fileName = basename($fullpath); |
|
| 10122 | + $dst = $this->_basePath . DIRECTORY_SEPARATOR . $dir; |
|
| 10123 | + if (!is_file($dst . DIRECTORY_SEPARATOR . $fileName) || $checkTimestamp || $this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
| 10124 | 10124 | { |
| 10125 | - if(@filemtime($dst.DIRECTORY_SEPARATOR.$fileName)<@filemtime($fullpath)) |
|
| 10125 | + if (@filemtime($dst . DIRECTORY_SEPARATOR . $fileName) < @filemtime($fullpath)) |
|
| 10126 | 10126 | { |
| 10127 | - $this->copyFile($fullpath,$dst); |
|
| 10128 | - $this->deployTarFile($tarfile,$dst); |
|
| 10127 | + $this->copyFile($fullpath, $dst); |
|
| 10128 | + $this->deployTarFile($tarfile, $dst); |
|
| 10129 | 10129 | } |
| 10130 | 10130 | } |
| 10131 | - return $this->_published[$md5sum]=$this->_baseUrl.'/'.$dir; |
|
| 10131 | + return $this->_published[$md5sum] = $this->_baseUrl . '/' . $dir; |
|
| 10132 | 10132 | } |
| 10133 | 10133 | } |
| 10134 | - protected function deployTarFile($path,$destination) |
|
| 10134 | + protected function deployTarFile($path, $destination) |
|
| 10135 | 10135 | { |
| 10136 | - if(($fullpath=realpath($path))===false || !is_file($fullpath)) |
|
| 10137 | - throw new TIOException('assetmanager_tarfile_invalid',$path); |
|
| 10136 | + if (($fullpath = realpath($path)) === false || !is_file($fullpath)) |
|
| 10137 | + throw new TIOException('assetmanager_tarfile_invalid', $path); |
|
| 10138 | 10138 | else |
| 10139 | 10139 | { |
| 10140 | 10140 | Prado::using('System.IO.TTarFileExtractor'); |
@@ -10147,26 +10147,26 @@ discard block |
||
| 10147 | 10147 | { |
| 10148 | 10148 | private $_defaultCharset = 'UTF-8'; |
| 10149 | 10149 | private $_defaultCulture = 'en'; |
| 10150 | - private $_charset=null; |
|
| 10151 | - private $_culture=null; |
|
| 10150 | + private $_charset = null; |
|
| 10151 | + private $_culture = null; |
|
| 10152 | 10152 | private $_translation; |
| 10153 | - private $_translateDefaultCulture=true; |
|
| 10153 | + private $_translateDefaultCulture = true; |
|
| 10154 | 10154 | public function init($config) |
| 10155 | 10155 | { |
| 10156 | - if($this->_charset===null) |
|
| 10157 | - $this->_charset=$this->getDefaultCharset(); |
|
| 10158 | - if($this->_culture===null) |
|
| 10159 | - $this->_culture=$this->getDefaultCulture(); |
|
| 10160 | - if($config!==null) |
|
| 10156 | + if ($this->_charset === null) |
|
| 10157 | + $this->_charset = $this->getDefaultCharset(); |
|
| 10158 | + if ($this->_culture === null) |
|
| 10159 | + $this->_culture = $this->getDefaultCulture(); |
|
| 10160 | + if ($config !== null) |
|
| 10161 | 10161 | { |
| 10162 | - if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
|
| 10163 | - $translation = isset($config['translate'])?$config['translate']:null; |
|
| 10162 | + if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
| 10163 | + $translation = isset($config['translate']) ? $config['translate'] : null; |
|
| 10164 | 10164 | else |
| 10165 | 10165 | { |
| 10166 | 10166 | $t = $config->getElementByTagName('translation'); |
| 10167 | - $translation = ($t)?$t->getAttributes():null; |
|
| 10167 | + $translation = ($t) ? $t->getAttributes() : null; |
|
| 10168 | 10168 | } |
| 10169 | - if($translation) |
|
| 10169 | + if ($translation) |
|
| 10170 | 10170 | $this->setTranslationConfiguration($translation); |
| 10171 | 10171 | } |
| 10172 | 10172 | $this->getApplication()->setGlobalization($this); |
@@ -10185,7 +10185,7 @@ discard block |
||
| 10185 | 10185 | } |
| 10186 | 10186 | public function setDefaultCulture($culture) |
| 10187 | 10187 | { |
| 10188 | - $this->_defaultCulture = str_replace('-','_',$culture); |
|
| 10188 | + $this->_defaultCulture = str_replace('-', '_', $culture); |
|
| 10189 | 10189 | } |
| 10190 | 10190 | public function getDefaultCharset() |
| 10191 | 10191 | { |
@@ -10201,7 +10201,7 @@ discard block |
||
| 10201 | 10201 | } |
| 10202 | 10202 | public function setCulture($culture) |
| 10203 | 10203 | { |
| 10204 | - $this->_culture = str_replace('-','_',$culture); |
|
| 10204 | + $this->_culture = str_replace('-', '_', $culture); |
|
| 10205 | 10205 | } |
| 10206 | 10206 | public function getCharset() |
| 10207 | 10207 | { |
@@ -10219,32 +10219,32 @@ discard block |
||
| 10219 | 10219 | } |
| 10220 | 10220 | protected function setTranslationConfiguration($config) |
| 10221 | 10221 | { |
| 10222 | - if($config['type'] == 'XLIFF' || $config['type'] == 'gettext') |
|
| 10222 | + if ($config['type'] == 'XLIFF' || $config['type'] == 'gettext') |
|
| 10223 | 10223 | { |
| 10224 | - if($config['source']) |
|
| 10224 | + if ($config['source']) |
|
| 10225 | 10225 | { |
| 10226 | 10226 | $config['source'] = Prado::getPathOfNamespace($config['source']); |
| 10227 | - if(!is_dir($config['source'])) |
|
| 10227 | + if (!is_dir($config['source'])) |
|
| 10228 | 10228 | { |
| 10229 | - if(@mkdir($config['source'])===false) |
|
| 10229 | + if (@mkdir($config['source']) === false) |
|
| 10230 | 10230 | throw new TConfigurationException('globalization_source_path_failed', |
| 10231 | 10231 | $config['source']); |
| 10232 | - chmod($config['source'], PRADO_CHMOD); } |
|
| 10232 | + chmod($config['source'], PRADO_CHMOD); } |
|
| 10233 | 10233 | } |
| 10234 | 10234 | else |
| 10235 | 10235 | { |
| 10236 | 10236 | throw new TConfigurationException("invalid source dir '{$config['source']}'"); |
| 10237 | 10237 | } |
| 10238 | 10238 | } |
| 10239 | - if($config['cache']) |
|
| 10239 | + if ($config['cache']) |
|
| 10240 | 10240 | { |
| 10241 | - $config['cache'] = $this->getApplication()->getRunTimePath().'/i18n'; |
|
| 10242 | - if(!is_dir($config['cache'])) |
|
| 10241 | + $config['cache'] = $this->getApplication()->getRunTimePath() . '/i18n'; |
|
| 10242 | + if (!is_dir($config['cache'])) |
|
| 10243 | 10243 | { |
| 10244 | - if(@mkdir($config['cache'])===false) |
|
| 10244 | + if (@mkdir($config['cache']) === false) |
|
| 10245 | 10245 | throw new TConfigurationException('globalization_cache_path_failed', |
| 10246 | 10246 | $config['cache']); |
| 10247 | - chmod($config['cache'], PRADO_CHMOD); } |
|
| 10247 | + chmod($config['cache'], PRADO_CHMOD); } |
|
| 10248 | 10248 | } |
| 10249 | 10249 | $this->_translation = $config; |
| 10250 | 10250 | } |
@@ -10256,46 +10256,46 @@ discard block |
||
| 10256 | 10256 | { |
| 10257 | 10257 | $this->_translation['catalogue'] = $value; |
| 10258 | 10258 | } |
| 10259 | - public function getCultureVariants($culture=null) |
|
| 10259 | + public function getCultureVariants($culture = null) |
|
| 10260 | 10260 | { |
| 10261 | - if($culture===null) $culture = $this->getCulture(); |
|
| 10261 | + if ($culture === null) $culture = $this->getCulture(); |
|
| 10262 | 10262 | $variants = explode('_', $culture); |
| 10263 | 10263 | $result = array(); |
| 10264 | - for(; count($variants) > 0; array_pop($variants)) |
|
| 10264 | + for (; count($variants) > 0; array_pop($variants)) |
|
| 10265 | 10265 | $result[] = implode('_', $variants); |
| 10266 | 10266 | return $result; |
| 10267 | 10267 | } |
| 10268 | - public function getLocalizedResource($file,$culture=null) |
|
| 10268 | + public function getLocalizedResource($file, $culture = null) |
|
| 10269 | 10269 | { |
| 10270 | 10270 | $files = array(); |
| 10271 | 10271 | $variants = $this->getCultureVariants($culture); |
| 10272 | 10272 | $path = pathinfo($file); |
| 10273 | - foreach($variants as $variant) |
|
| 10274 | - $files[] = $path['dirname'].DIRECTORY_SEPARATOR.$variant.DIRECTORY_SEPARATOR.$path['basename']; |
|
| 10275 | - $filename = substr($path['basename'],0,strrpos($path['basename'],'.')); |
|
| 10276 | - foreach($variants as $variant) |
|
| 10277 | - $files[] = $path['dirname'].DIRECTORY_SEPARATOR.$filename.'.'.$variant.'.'.$path['extension']; |
|
| 10273 | + foreach ($variants as $variant) |
|
| 10274 | + $files[] = $path['dirname'] . DIRECTORY_SEPARATOR . $variant . DIRECTORY_SEPARATOR . $path['basename']; |
|
| 10275 | + $filename = substr($path['basename'], 0, strrpos($path['basename'], '.')); |
|
| 10276 | + foreach ($variants as $variant) |
|
| 10277 | + $files[] = $path['dirname'] . DIRECTORY_SEPARATOR . $filename . '.' . $variant . '.' . $path['extension']; |
|
| 10278 | 10278 | $files[] = $file; |
| 10279 | 10279 | return $files; |
| 10280 | 10280 | } |
| 10281 | 10281 | } |
| 10282 | 10282 | class TApplication extends TComponent |
| 10283 | 10283 | { |
| 10284 | - const STATE_OFF='Off'; |
|
| 10285 | - const STATE_DEBUG='Debug'; |
|
| 10286 | - const STATE_NORMAL='Normal'; |
|
| 10287 | - const STATE_PERFORMANCE='Performance'; |
|
| 10288 | - const PAGE_SERVICE_ID='page'; |
|
| 10289 | - const CONFIG_FILE_XML='application.xml'; |
|
| 10290 | - const CONFIG_FILE_EXT_XML='.xml'; |
|
| 10284 | + const STATE_OFF = 'Off'; |
|
| 10285 | + const STATE_DEBUG = 'Debug'; |
|
| 10286 | + const STATE_NORMAL = 'Normal'; |
|
| 10287 | + const STATE_PERFORMANCE = 'Performance'; |
|
| 10288 | + const PAGE_SERVICE_ID = 'page'; |
|
| 10289 | + const CONFIG_FILE_XML = 'application.xml'; |
|
| 10290 | + const CONFIG_FILE_EXT_XML = '.xml'; |
|
| 10291 | 10291 | const CONFIG_TYPE_XML = 'xml'; |
| 10292 | - const CONFIG_FILE_PHP='application.php'; |
|
| 10293 | - const CONFIG_FILE_EXT_PHP='.php'; |
|
| 10292 | + const CONFIG_FILE_PHP = 'application.php'; |
|
| 10293 | + const CONFIG_FILE_EXT_PHP = '.php'; |
|
| 10294 | 10294 | const CONFIG_TYPE_PHP = 'php'; |
| 10295 | - const RUNTIME_PATH='runtime'; |
|
| 10296 | - const CONFIGCACHE_FILE='config.cache'; |
|
| 10297 | - const GLOBAL_FILE='global.cache'; |
|
| 10298 | - private static $_steps=array( |
|
| 10295 | + const RUNTIME_PATH = 'runtime'; |
|
| 10296 | + const CONFIGCACHE_FILE = 'config.cache'; |
|
| 10297 | + const GLOBAL_FILE = 'global.cache'; |
|
| 10298 | + private static $_steps = array( |
|
| 10299 | 10299 | 'onBeginRequest', |
| 10300 | 10300 | 'onLoadState', |
| 10301 | 10301 | 'onLoadStateComplete', |
@@ -10312,20 +10312,20 @@ discard block |
||
| 10312 | 10312 | ); |
| 10313 | 10313 | private $_id; |
| 10314 | 10314 | private $_uniqueID; |
| 10315 | - private $_requestCompleted=false; |
|
| 10315 | + private $_requestCompleted = false; |
|
| 10316 | 10316 | private $_step; |
| 10317 | 10317 | private $_services; |
| 10318 | 10318 | private $_service; |
| 10319 | - private $_modules=array(); |
|
| 10320 | - private $_lazyModules=array(); |
|
| 10319 | + private $_modules = array(); |
|
| 10320 | + private $_lazyModules = array(); |
|
| 10321 | 10321 | private $_parameters; |
| 10322 | 10322 | private $_configFile; |
| 10323 | 10323 | private $_configFileExt; |
| 10324 | 10324 | private $_configType; |
| 10325 | 10325 | private $_basePath; |
| 10326 | 10326 | private $_runtimePath; |
| 10327 | - private $_stateChanged=false; |
|
| 10328 | - private $_globals=array(); |
|
| 10327 | + private $_stateChanged = false; |
|
| 10328 | + private $_globals = array(); |
|
| 10329 | 10329 | private $_cacheFile; |
| 10330 | 10330 | private $_errorHandler; |
| 10331 | 10331 | private $_request; |
@@ -10338,72 +10338,72 @@ discard block |
||
| 10338 | 10338 | private $_security; |
| 10339 | 10339 | private $_assetManager; |
| 10340 | 10340 | private $_authRules; |
| 10341 | - private $_mode=TApplicationMode::Debug; |
|
| 10341 | + private $_mode = TApplicationMode::Debug; |
|
| 10342 | 10342 | private $_pageServiceID = self::PAGE_SERVICE_ID; |
| 10343 | - public function __construct($basePath='protected',$cacheConfig=true, $configType=self::CONFIG_TYPE_XML) |
|
| 10343 | + public function __construct($basePath = 'protected', $cacheConfig = true, $configType = self::CONFIG_TYPE_XML) |
|
| 10344 | 10344 | { |
| 10345 | 10345 | Prado::setApplication($this); |
| 10346 | 10346 | $this->setConfigurationType($configType); |
| 10347 | 10347 | $this->resolvePaths($basePath); |
| 10348 | - if($cacheConfig) |
|
| 10349 | - $this->_cacheFile=$this->_runtimePath.DIRECTORY_SEPARATOR.self::CONFIGCACHE_FILE; |
|
| 10350 | - $this->_uniqueID=md5($this->_runtimePath); |
|
| 10351 | - $this->_parameters=new TMap; |
|
| 10352 | - $this->_services=array($this->getPageServiceID()=>array('TPageService',array(),null)); |
|
| 10353 | - Prado::setPathOfAlias('Application',$this->_basePath); |
|
| 10348 | + if ($cacheConfig) |
|
| 10349 | + $this->_cacheFile = $this->_runtimePath . DIRECTORY_SEPARATOR . self::CONFIGCACHE_FILE; |
|
| 10350 | + $this->_uniqueID = md5($this->_runtimePath); |
|
| 10351 | + $this->_parameters = new TMap; |
|
| 10352 | + $this->_services = array($this->getPageServiceID()=>array('TPageService', array(), null)); |
|
| 10353 | + Prado::setPathOfAlias('Application', $this->_basePath); |
|
| 10354 | 10354 | } |
| 10355 | 10355 | protected function resolvePaths($basePath) |
| 10356 | 10356 | { |
| 10357 | - if(empty($basePath) || ($basePath=realpath($basePath))===false) |
|
| 10358 | - throw new TConfigurationException('application_basepath_invalid',$basePath); |
|
| 10359 | - if(is_dir($basePath) && is_file($basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName())) |
|
| 10360 | - $configFile=$basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName(); |
|
| 10361 | - else if(is_file($basePath)) |
|
| 10357 | + if (empty($basePath) || ($basePath = realpath($basePath)) === false) |
|
| 10358 | + throw new TConfigurationException('application_basepath_invalid', $basePath); |
|
| 10359 | + if (is_dir($basePath) && is_file($basePath . DIRECTORY_SEPARATOR . $this->getConfigurationFileName())) |
|
| 10360 | + $configFile = $basePath . DIRECTORY_SEPARATOR . $this->getConfigurationFileName(); |
|
| 10361 | + else if (is_file($basePath)) |
|
| 10362 | 10362 | { |
| 10363 | - $configFile=$basePath; |
|
| 10364 | - $basePath=dirname($configFile); |
|
| 10363 | + $configFile = $basePath; |
|
| 10364 | + $basePath = dirname($configFile); |
|
| 10365 | 10365 | } |
| 10366 | 10366 | else |
| 10367 | - $configFile=null; |
|
| 10368 | - $runtimePath=$basePath.DIRECTORY_SEPARATOR.self::RUNTIME_PATH; |
|
| 10369 | - if(is_writable($runtimePath)) |
|
| 10367 | + $configFile = null; |
|
| 10368 | + $runtimePath = $basePath . DIRECTORY_SEPARATOR . self::RUNTIME_PATH; |
|
| 10369 | + if (is_writable($runtimePath)) |
|
| 10370 | 10370 | { |
| 10371 | - if($configFile!==null) |
|
| 10371 | + if ($configFile !== null) |
|
| 10372 | 10372 | { |
| 10373 | - $runtimePath.=DIRECTORY_SEPARATOR.basename($configFile).'-'.Prado::getVersion(); |
|
| 10374 | - if(!is_dir($runtimePath)) |
|
| 10373 | + $runtimePath .= DIRECTORY_SEPARATOR . basename($configFile) . '-' . Prado::getVersion(); |
|
| 10374 | + if (!is_dir($runtimePath)) |
|
| 10375 | 10375 | { |
| 10376 | - if(@mkdir($runtimePath)===false) |
|
| 10377 | - throw new TConfigurationException('application_runtimepath_failed',$runtimePath); |
|
| 10378 | - @chmod($runtimePath, PRADO_CHMOD); } |
|
| 10376 | + if (@mkdir($runtimePath) === false) |
|
| 10377 | + throw new TConfigurationException('application_runtimepath_failed', $runtimePath); |
|
| 10378 | + @chmod($runtimePath, PRADO_CHMOD); } |
|
| 10379 | 10379 | $this->setConfigurationFile($configFile); |
| 10380 | 10380 | } |
| 10381 | 10381 | $this->setBasePath($basePath); |
| 10382 | 10382 | $this->setRuntimePath($runtimePath); |
| 10383 | 10383 | } |
| 10384 | 10384 | else |
| 10385 | - throw new TConfigurationException('application_runtimepath_invalid',$runtimePath); |
|
| 10385 | + throw new TConfigurationException('application_runtimepath_invalid', $runtimePath); |
|
| 10386 | 10386 | } |
| 10387 | 10387 | public function run() |
| 10388 | 10388 | { |
| 10389 | 10389 | try |
| 10390 | 10390 | { |
| 10391 | 10391 | $this->initApplication(); |
| 10392 | - $n=count(self::$_steps); |
|
| 10393 | - $this->_step=0; |
|
| 10394 | - $this->_requestCompleted=false; |
|
| 10395 | - while($this->_step<$n) |
|
| 10396 | - { |
|
| 10397 | - if($this->_mode===self::STATE_OFF) |
|
| 10398 | - throw new THttpException(503,'application_unavailable'); |
|
| 10399 | - if($this->_requestCompleted) |
|
| 10392 | + $n = count(self::$_steps); |
|
| 10393 | + $this->_step = 0; |
|
| 10394 | + $this->_requestCompleted = false; |
|
| 10395 | + while ($this->_step < $n) |
|
| 10396 | + { |
|
| 10397 | + if ($this->_mode === self::STATE_OFF) |
|
| 10398 | + throw new THttpException(503, 'application_unavailable'); |
|
| 10399 | + if ($this->_requestCompleted) |
|
| 10400 | 10400 | break; |
| 10401 | - $method=self::$_steps[$this->_step]; |
|
| 10401 | + $method = self::$_steps[$this->_step]; |
|
| 10402 | 10402 | $this->$method(); |
| 10403 | 10403 | $this->_step++; |
| 10404 | 10404 | } |
| 10405 | 10405 | } |
| 10406 | - catch(Exception $e) |
|
| 10406 | + catch (Exception $e) |
|
| 10407 | 10407 | { |
| 10408 | 10408 | $this->onError($e); |
| 10409 | 10409 | } |
@@ -10411,40 +10411,40 @@ discard block |
||
| 10411 | 10411 | } |
| 10412 | 10412 | public function completeRequest() |
| 10413 | 10413 | { |
| 10414 | - $this->_requestCompleted=true; |
|
| 10414 | + $this->_requestCompleted = true; |
|
| 10415 | 10415 | } |
| 10416 | 10416 | public function getRequestCompleted() |
| 10417 | 10417 | { |
| 10418 | 10418 | return $this->_requestCompleted; |
| 10419 | 10419 | } |
| 10420 | - public function getGlobalState($key,$defaultValue=null) |
|
| 10420 | + public function getGlobalState($key, $defaultValue = null) |
|
| 10421 | 10421 | { |
| 10422 | - return isset($this->_globals[$key])?$this->_globals[$key]:$defaultValue; |
|
| 10422 | + return isset($this->_globals[$key]) ? $this->_globals[$key] : $defaultValue; |
|
| 10423 | 10423 | } |
| 10424 | - public function setGlobalState($key,$value,$defaultValue=null,$forceSave=false) |
|
| 10424 | + public function setGlobalState($key, $value, $defaultValue = null, $forceSave = false) |
|
| 10425 | 10425 | { |
| 10426 | - $this->_stateChanged=true; |
|
| 10427 | - if($value===$defaultValue) |
|
| 10426 | + $this->_stateChanged = true; |
|
| 10427 | + if ($value === $defaultValue) |
|
| 10428 | 10428 | unset($this->_globals[$key]); |
| 10429 | 10429 | else |
| 10430 | - $this->_globals[$key]=$value; |
|
| 10431 | - if($forceSave) |
|
| 10430 | + $this->_globals[$key] = $value; |
|
| 10431 | + if ($forceSave) |
|
| 10432 | 10432 | $this->saveGlobals(); |
| 10433 | 10433 | } |
| 10434 | 10434 | public function clearGlobalState($key) |
| 10435 | 10435 | { |
| 10436 | - $this->_stateChanged=true; |
|
| 10436 | + $this->_stateChanged = true; |
|
| 10437 | 10437 | unset($this->_globals[$key]); |
| 10438 | 10438 | } |
| 10439 | 10439 | protected function loadGlobals() |
| 10440 | 10440 | { |
| 10441 | - $this->_globals=$this->getApplicationStatePersister()->load(); |
|
| 10441 | + $this->_globals = $this->getApplicationStatePersister()->load(); |
|
| 10442 | 10442 | } |
| 10443 | 10443 | protected function saveGlobals() |
| 10444 | 10444 | { |
| 10445 | - if($this->_stateChanged) |
|
| 10445 | + if ($this->_stateChanged) |
|
| 10446 | 10446 | { |
| 10447 | - $this->_stateChanged=false; |
|
| 10447 | + $this->_stateChanged = false; |
|
| 10448 | 10448 | $this->getApplicationStatePersister()->save($this->_globals); |
| 10449 | 10449 | } |
| 10450 | 10450 | } |
@@ -10454,7 +10454,7 @@ discard block |
||
| 10454 | 10454 | } |
| 10455 | 10455 | public function setID($value) |
| 10456 | 10456 | { |
| 10457 | - $this->_id=$value; |
|
| 10457 | + $this->_id = $value; |
|
| 10458 | 10458 | } |
| 10459 | 10459 | public function getPageServiceID() |
| 10460 | 10460 | { |
@@ -10462,7 +10462,7 @@ discard block |
||
| 10462 | 10462 | } |
| 10463 | 10463 | public function setPageServiceID($value) |
| 10464 | 10464 | { |
| 10465 | - $this->_pageServiceID=$value; |
|
| 10465 | + $this->_pageServiceID = $value; |
|
| 10466 | 10466 | } |
| 10467 | 10467 | public function getUniqueID() |
| 10468 | 10468 | { |
@@ -10474,7 +10474,7 @@ discard block |
||
| 10474 | 10474 | } |
| 10475 | 10475 | public function setMode($value) |
| 10476 | 10476 | { |
| 10477 | - $this->_mode=TPropertyValue::ensureEnum($value,'TApplicationMode'); |
|
| 10477 | + $this->_mode = TPropertyValue::ensureEnum($value, 'TApplicationMode'); |
|
| 10478 | 10478 | } |
| 10479 | 10479 | public function getBasePath() |
| 10480 | 10480 | { |
@@ -10482,7 +10482,7 @@ discard block |
||
| 10482 | 10482 | } |
| 10483 | 10483 | public function setBasePath($value) |
| 10484 | 10484 | { |
| 10485 | - $this->_basePath=$value; |
|
| 10485 | + $this->_basePath = $value; |
|
| 10486 | 10486 | } |
| 10487 | 10487 | public function getConfigurationFile() |
| 10488 | 10488 | { |
@@ -10490,7 +10490,7 @@ discard block |
||
| 10490 | 10490 | } |
| 10491 | 10491 | public function setConfigurationFile($value) |
| 10492 | 10492 | { |
| 10493 | - $this->_configFile=$value; |
|
| 10493 | + $this->_configFile = $value; |
|
| 10494 | 10494 | } |
| 10495 | 10495 | public function getConfigurationType() |
| 10496 | 10496 | { |
@@ -10502,9 +10502,9 @@ discard block |
||
| 10502 | 10502 | } |
| 10503 | 10503 | public function getConfigurationFileExt() |
| 10504 | 10504 | { |
| 10505 | - if($this->_configFileExt===null) |
|
| 10505 | + if ($this->_configFileExt === null) |
|
| 10506 | 10506 | { |
| 10507 | - switch($this->_configType) |
|
| 10507 | + switch ($this->_configType) |
|
| 10508 | 10508 | { |
| 10509 | 10509 | case TApplication::CONFIG_TYPE_PHP: |
| 10510 | 10510 | $this->_configFileExt = TApplication::CONFIG_FILE_EXT_PHP; |
@@ -10518,9 +10518,9 @@ discard block |
||
| 10518 | 10518 | public function getConfigurationFileName() |
| 10519 | 10519 | { |
| 10520 | 10520 | static $fileName; |
| 10521 | - if($fileName == null) |
|
| 10521 | + if ($fileName == null) |
|
| 10522 | 10522 | { |
| 10523 | - switch($this->_configType) |
|
| 10523 | + switch ($this->_configType) |
|
| 10524 | 10524 | { |
| 10525 | 10525 | case TApplication::CONFIG_TYPE_PHP: |
| 10526 | 10526 | $fileName = TApplication::CONFIG_FILE_PHP; |
@@ -10537,10 +10537,10 @@ discard block |
||
| 10537 | 10537 | } |
| 10538 | 10538 | public function setRuntimePath($value) |
| 10539 | 10539 | { |
| 10540 | - $this->_runtimePath=$value; |
|
| 10541 | - if($this->_cacheFile) |
|
| 10542 | - $this->_cacheFile=$this->_runtimePath.DIRECTORY_SEPARATOR.self::CONFIGCACHE_FILE; |
|
| 10543 | - $this->_uniqueID=md5($this->_runtimePath); |
|
| 10540 | + $this->_runtimePath = $value; |
|
| 10541 | + if ($this->_cacheFile) |
|
| 10542 | + $this->_cacheFile = $this->_runtimePath . DIRECTORY_SEPARATOR . self::CONFIGCACHE_FILE; |
|
| 10543 | + $this->_uniqueID = md5($this->_runtimePath); |
|
| 10544 | 10544 | } |
| 10545 | 10545 | public function getService() |
| 10546 | 10546 | { |
@@ -10548,20 +10548,20 @@ discard block |
||
| 10548 | 10548 | } |
| 10549 | 10549 | public function setService($value) |
| 10550 | 10550 | { |
| 10551 | - $this->_service=$value; |
|
| 10551 | + $this->_service = $value; |
|
| 10552 | 10552 | } |
| 10553 | - public function setModule($id,IModule $module=null) |
|
| 10553 | + public function setModule($id, IModule $module = null) |
|
| 10554 | 10554 | { |
| 10555 | - if(isset($this->_modules[$id])) |
|
| 10556 | - throw new TConfigurationException('application_moduleid_duplicated',$id); |
|
| 10555 | + if (isset($this->_modules[$id])) |
|
| 10556 | + throw new TConfigurationException('application_moduleid_duplicated', $id); |
|
| 10557 | 10557 | else |
| 10558 | - $this->_modules[$id]=$module; |
|
| 10558 | + $this->_modules[$id] = $module; |
|
| 10559 | 10559 | } |
| 10560 | 10560 | public function getModule($id) |
| 10561 | 10561 | { |
| 10562 | - if(!array_key_exists($id, $this->_modules)) |
|
| 10562 | + if (!array_key_exists($id, $this->_modules)) |
|
| 10563 | 10563 | return null; |
| 10564 | - if($this->_modules[$id]===null) |
|
| 10564 | + if ($this->_modules[$id] === null) |
|
| 10565 | 10565 | { |
| 10566 | 10566 | $module = $this->internalLoadModule($id, true); |
| 10567 | 10567 | $module[0]->init($module[1]); |
@@ -10578,94 +10578,94 @@ discard block |
||
| 10578 | 10578 | } |
| 10579 | 10579 | public function getRequest() |
| 10580 | 10580 | { |
| 10581 | - if(!$this->_request) |
|
| 10581 | + if (!$this->_request) |
|
| 10582 | 10582 | { |
| 10583 | - $this->_request=new THttpRequest; |
|
| 10583 | + $this->_request = new THttpRequest; |
|
| 10584 | 10584 | $this->_request->init(null); |
| 10585 | 10585 | } |
| 10586 | 10586 | return $this->_request; |
| 10587 | 10587 | } |
| 10588 | 10588 | public function setRequest(THttpRequest $request) |
| 10589 | 10589 | { |
| 10590 | - $this->_request=$request; |
|
| 10590 | + $this->_request = $request; |
|
| 10591 | 10591 | } |
| 10592 | 10592 | public function getResponse() |
| 10593 | 10593 | { |
| 10594 | - if(!$this->_response) |
|
| 10594 | + if (!$this->_response) |
|
| 10595 | 10595 | { |
| 10596 | - $this->_response=new THttpResponse; |
|
| 10596 | + $this->_response = new THttpResponse; |
|
| 10597 | 10597 | $this->_response->init(null); |
| 10598 | 10598 | } |
| 10599 | 10599 | return $this->_response; |
| 10600 | 10600 | } |
| 10601 | 10601 | public function setResponse(THttpResponse $response) |
| 10602 | 10602 | { |
| 10603 | - $this->_response=$response; |
|
| 10603 | + $this->_response = $response; |
|
| 10604 | 10604 | } |
| 10605 | 10605 | public function getSession() |
| 10606 | 10606 | { |
| 10607 | - if(!$this->_session) |
|
| 10607 | + if (!$this->_session) |
|
| 10608 | 10608 | { |
| 10609 | - $this->_session=new THttpSession; |
|
| 10609 | + $this->_session = new THttpSession; |
|
| 10610 | 10610 | $this->_session->init(null); |
| 10611 | 10611 | } |
| 10612 | 10612 | return $this->_session; |
| 10613 | 10613 | } |
| 10614 | 10614 | public function setSession(THttpSession $session) |
| 10615 | 10615 | { |
| 10616 | - $this->_session=$session; |
|
| 10616 | + $this->_session = $session; |
|
| 10617 | 10617 | } |
| 10618 | 10618 | public function getErrorHandler() |
| 10619 | 10619 | { |
| 10620 | - if(!$this->_errorHandler) |
|
| 10620 | + if (!$this->_errorHandler) |
|
| 10621 | 10621 | { |
| 10622 | - $this->_errorHandler=new TErrorHandler; |
|
| 10622 | + $this->_errorHandler = new TErrorHandler; |
|
| 10623 | 10623 | $this->_errorHandler->init(null); |
| 10624 | 10624 | } |
| 10625 | 10625 | return $this->_errorHandler; |
| 10626 | 10626 | } |
| 10627 | 10627 | public function setErrorHandler(TErrorHandler $handler) |
| 10628 | 10628 | { |
| 10629 | - $this->_errorHandler=$handler; |
|
| 10629 | + $this->_errorHandler = $handler; |
|
| 10630 | 10630 | } |
| 10631 | 10631 | public function getSecurityManager() |
| 10632 | 10632 | { |
| 10633 | - if(!$this->_security) |
|
| 10633 | + if (!$this->_security) |
|
| 10634 | 10634 | { |
| 10635 | - $this->_security=new TSecurityManager; |
|
| 10635 | + $this->_security = new TSecurityManager; |
|
| 10636 | 10636 | $this->_security->init(null); |
| 10637 | 10637 | } |
| 10638 | 10638 | return $this->_security; |
| 10639 | 10639 | } |
| 10640 | 10640 | public function setSecurityManager(TSecurityManager $sm) |
| 10641 | 10641 | { |
| 10642 | - $this->_security=$sm; |
|
| 10642 | + $this->_security = $sm; |
|
| 10643 | 10643 | } |
| 10644 | 10644 | public function getAssetManager() |
| 10645 | 10645 | { |
| 10646 | - if(!$this->_assetManager) |
|
| 10646 | + if (!$this->_assetManager) |
|
| 10647 | 10647 | { |
| 10648 | - $this->_assetManager=new TAssetManager; |
|
| 10648 | + $this->_assetManager = new TAssetManager; |
|
| 10649 | 10649 | $this->_assetManager->init(null); |
| 10650 | 10650 | } |
| 10651 | 10651 | return $this->_assetManager; |
| 10652 | 10652 | } |
| 10653 | 10653 | public function setAssetManager(TAssetManager $value) |
| 10654 | 10654 | { |
| 10655 | - $this->_assetManager=$value; |
|
| 10655 | + $this->_assetManager = $value; |
|
| 10656 | 10656 | } |
| 10657 | 10657 | public function getApplicationStatePersister() |
| 10658 | 10658 | { |
| 10659 | - if(!$this->_statePersister) |
|
| 10659 | + if (!$this->_statePersister) |
|
| 10660 | 10660 | { |
| 10661 | - $this->_statePersister=new TApplicationStatePersister; |
|
| 10661 | + $this->_statePersister = new TApplicationStatePersister; |
|
| 10662 | 10662 | $this->_statePersister->init(null); |
| 10663 | 10663 | } |
| 10664 | 10664 | return $this->_statePersister; |
| 10665 | 10665 | } |
| 10666 | 10666 | public function setApplicationStatePersister(IStatePersister $persister) |
| 10667 | 10667 | { |
| 10668 | - $this->_statePersister=$persister; |
|
| 10668 | + $this->_statePersister = $persister; |
|
| 10669 | 10669 | } |
| 10670 | 10670 | public function getCache() |
| 10671 | 10671 | { |
@@ -10673,7 +10673,7 @@ discard block |
||
| 10673 | 10673 | } |
| 10674 | 10674 | public function setCache(ICache $cache) |
| 10675 | 10675 | { |
| 10676 | - $this->_cache=$cache; |
|
| 10676 | + $this->_cache = $cache; |
|
| 10677 | 10677 | } |
| 10678 | 10678 | public function getUser() |
| 10679 | 10679 | { |
@@ -10681,207 +10681,207 @@ discard block |
||
| 10681 | 10681 | } |
| 10682 | 10682 | public function setUser(IUser $user) |
| 10683 | 10683 | { |
| 10684 | - $this->_user=$user; |
|
| 10684 | + $this->_user = $user; |
|
| 10685 | 10685 | } |
| 10686 | - public function getGlobalization($createIfNotExists=true) |
|
| 10686 | + public function getGlobalization($createIfNotExists = true) |
|
| 10687 | 10687 | { |
| 10688 | - if($this->_globalization===null && $createIfNotExists) |
|
| 10688 | + if ($this->_globalization === null && $createIfNotExists) |
|
| 10689 | 10689 | { |
| 10690 | - $this->_globalization=new TGlobalization; |
|
| 10690 | + $this->_globalization = new TGlobalization; |
|
| 10691 | 10691 | $this->_globalization->init(null); |
| 10692 | 10692 | } |
| 10693 | 10693 | return $this->_globalization; |
| 10694 | 10694 | } |
| 10695 | 10695 | public function setGlobalization(TGlobalization $glob) |
| 10696 | 10696 | { |
| 10697 | - $this->_globalization=$glob; |
|
| 10697 | + $this->_globalization = $glob; |
|
| 10698 | 10698 | } |
| 10699 | 10699 | public function getAuthorizationRules() |
| 10700 | 10700 | { |
| 10701 | - if($this->_authRules===null) |
|
| 10702 | - $this->_authRules=new TAuthorizationRuleCollection; |
|
| 10701 | + if ($this->_authRules === null) |
|
| 10702 | + $this->_authRules = new TAuthorizationRuleCollection; |
|
| 10703 | 10703 | return $this->_authRules; |
| 10704 | 10704 | } |
| 10705 | 10705 | protected function getApplicationConfigurationClass() |
| 10706 | 10706 | { |
| 10707 | 10707 | return 'TApplicationConfiguration'; |
| 10708 | 10708 | } |
| 10709 | - protected function internalLoadModule($id, $force=false) |
|
| 10709 | + protected function internalLoadModule($id, $force = false) |
|
| 10710 | 10710 | { |
| 10711 | - list($moduleClass, $initProperties, $configElement)=$this->_lazyModules[$id]; |
|
| 10712 | - if(isset($initProperties['lazy']) && $initProperties['lazy'] && !$force) |
|
| 10711 | + list($moduleClass, $initProperties, $configElement) = $this->_lazyModules[$id]; |
|
| 10712 | + if (isset($initProperties['lazy']) && $initProperties['lazy'] && !$force) |
|
| 10713 | 10713 | { |
| 10714 | 10714 | $this->setModule($id, null); |
| 10715 | 10715 | return null; |
| 10716 | 10716 | } |
| 10717 | - $module=Prado::createComponent($moduleClass); |
|
| 10718 | - foreach($initProperties as $name=>$value) |
|
| 10717 | + $module = Prado::createComponent($moduleClass); |
|
| 10718 | + foreach ($initProperties as $name=>$value) |
|
| 10719 | 10719 | { |
| 10720 | - if($name==='lazy') continue; |
|
| 10721 | - $module->setSubProperty($name,$value); |
|
| 10720 | + if ($name === 'lazy') continue; |
|
| 10721 | + $module->setSubProperty($name, $value); |
|
| 10722 | 10722 | } |
| 10723 | - $this->setModule($id,$module); |
|
| 10724 | - $this->_lazyModules[$id]=null; |
|
| 10725 | - return array($module,$configElement); |
|
| 10723 | + $this->setModule($id, $module); |
|
| 10724 | + $this->_lazyModules[$id] = null; |
|
| 10725 | + return array($module, $configElement); |
|
| 10726 | 10726 | } |
| 10727 | - public function applyConfiguration($config,$withinService=false) |
|
| 10727 | + public function applyConfiguration($config, $withinService = false) |
|
| 10728 | 10728 | { |
| 10729 | - if($config->getIsEmpty()) |
|
| 10729 | + if ($config->getIsEmpty()) |
|
| 10730 | 10730 | return; |
| 10731 | - foreach($config->getAliases() as $alias=>$path) |
|
| 10732 | - Prado::setPathOfAlias($alias,$path); |
|
| 10733 | - foreach($config->getUsings() as $using) |
|
| 10731 | + foreach ($config->getAliases() as $alias=>$path) |
|
| 10732 | + Prado::setPathOfAlias($alias, $path); |
|
| 10733 | + foreach ($config->getUsings() as $using) |
|
| 10734 | 10734 | Prado::using($using); |
| 10735 | - if(!$withinService) |
|
| 10735 | + if (!$withinService) |
|
| 10736 | 10736 | { |
| 10737 | - foreach($config->getProperties() as $name=>$value) |
|
| 10738 | - $this->setSubProperty($name,$value); |
|
| 10737 | + foreach ($config->getProperties() as $name=>$value) |
|
| 10738 | + $this->setSubProperty($name, $value); |
|
| 10739 | 10739 | } |
| 10740 | - if(empty($this->_services)) |
|
| 10741 | - $this->_services=array($this->getPageServiceID()=>array('TPageService',array(),null)); |
|
| 10742 | - foreach($config->getParameters() as $id=>$parameter) |
|
| 10740 | + if (empty($this->_services)) |
|
| 10741 | + $this->_services = array($this->getPageServiceID()=>array('TPageService', array(), null)); |
|
| 10742 | + foreach ($config->getParameters() as $id=>$parameter) |
|
| 10743 | 10743 | { |
| 10744 | - if(is_array($parameter)) |
|
| 10744 | + if (is_array($parameter)) |
|
| 10745 | 10745 | { |
| 10746 | - $component=Prado::createComponent($parameter[0]); |
|
| 10747 | - foreach($parameter[1] as $name=>$value) |
|
| 10748 | - $component->setSubProperty($name,$value); |
|
| 10749 | - $this->_parameters->add($id,$component); |
|
| 10746 | + $component = Prado::createComponent($parameter[0]); |
|
| 10747 | + foreach ($parameter[1] as $name=>$value) |
|
| 10748 | + $component->setSubProperty($name, $value); |
|
| 10749 | + $this->_parameters->add($id, $component); |
|
| 10750 | 10750 | } |
| 10751 | 10751 | else |
| 10752 | - $this->_parameters->add($id,$parameter); |
|
| 10752 | + $this->_parameters->add($id, $parameter); |
|
| 10753 | 10753 | } |
| 10754 | - $modules=array(); |
|
| 10755 | - foreach($config->getModules() as $id=>$moduleConfig) |
|
| 10754 | + $modules = array(); |
|
| 10755 | + foreach ($config->getModules() as $id=>$moduleConfig) |
|
| 10756 | 10756 | { |
| 10757 | - if(!is_string($id)) |
|
| 10758 | - $id='_module'.count($this->_lazyModules); |
|
| 10759 | - $this->_lazyModules[$id]=$moduleConfig; |
|
| 10760 | - if($module = $this->internalLoadModule($id)) |
|
| 10761 | - $modules[]=$module; |
|
| 10757 | + if (!is_string($id)) |
|
| 10758 | + $id = '_module' . count($this->_lazyModules); |
|
| 10759 | + $this->_lazyModules[$id] = $moduleConfig; |
|
| 10760 | + if ($module = $this->internalLoadModule($id)) |
|
| 10761 | + $modules[] = $module; |
|
| 10762 | 10762 | } |
| 10763 | - foreach($modules as $module) |
|
| 10763 | + foreach ($modules as $module) |
|
| 10764 | 10764 | $module[0]->init($module[1]); |
| 10765 | - foreach($config->getServices() as $serviceID=>$serviceConfig) |
|
| 10766 | - $this->_services[$serviceID]=$serviceConfig; |
|
| 10767 | - foreach($config->getExternalConfigurations() as $filePath=>$condition) |
|
| 10768 | - { |
|
| 10769 | - if($condition!==true) |
|
| 10770 | - $condition=$this->evaluateExpression($condition); |
|
| 10771 | - if($condition) |
|
| 10772 | - { |
|
| 10773 | - if(($path=Prado::getPathOfNamespace($filePath,$this->getConfigurationFileExt()))===null || !is_file($path)) |
|
| 10774 | - throw new TConfigurationException('application_includefile_invalid',$filePath); |
|
| 10775 | - $cn=$this->getApplicationConfigurationClass(); |
|
| 10776 | - $c=new $cn; |
|
| 10765 | + foreach ($config->getServices() as $serviceID=>$serviceConfig) |
|
| 10766 | + $this->_services[$serviceID] = $serviceConfig; |
|
| 10767 | + foreach ($config->getExternalConfigurations() as $filePath=>$condition) |
|
| 10768 | + { |
|
| 10769 | + if ($condition !== true) |
|
| 10770 | + $condition = $this->evaluateExpression($condition); |
|
| 10771 | + if ($condition) |
|
| 10772 | + { |
|
| 10773 | + if (($path = Prado::getPathOfNamespace($filePath, $this->getConfigurationFileExt())) === null || !is_file($path)) |
|
| 10774 | + throw new TConfigurationException('application_includefile_invalid', $filePath); |
|
| 10775 | + $cn = $this->getApplicationConfigurationClass(); |
|
| 10776 | + $c = new $cn; |
|
| 10777 | 10777 | $c->loadFromFile($path); |
| 10778 | - $this->applyConfiguration($c,$withinService); |
|
| 10778 | + $this->applyConfiguration($c, $withinService); |
|
| 10779 | 10779 | } |
| 10780 | 10780 | } |
| 10781 | 10781 | } |
| 10782 | 10782 | protected function initApplication() |
| 10783 | 10783 | { |
| 10784 | - if($this->_configFile!==null) |
|
| 10784 | + if ($this->_configFile !== null) |
|
| 10785 | 10785 | { |
| 10786 | - if($this->_cacheFile===null || @filemtime($this->_cacheFile)<filemtime($this->_configFile)) |
|
| 10786 | + if ($this->_cacheFile === null || @filemtime($this->_cacheFile) < filemtime($this->_configFile)) |
|
| 10787 | 10787 | { |
| 10788 | - $config=new TApplicationConfiguration; |
|
| 10788 | + $config = new TApplicationConfiguration; |
|
| 10789 | 10789 | $config->loadFromFile($this->_configFile); |
| 10790 | - if($this->_cacheFile!==null) |
|
| 10791 | - file_put_contents($this->_cacheFile,serialize($config),LOCK_EX); |
|
| 10790 | + if ($this->_cacheFile !== null) |
|
| 10791 | + file_put_contents($this->_cacheFile, serialize($config), LOCK_EX); |
|
| 10792 | 10792 | } |
| 10793 | 10793 | else |
| 10794 | - $config=unserialize(file_get_contents($this->_cacheFile)); |
|
| 10795 | - $this->applyConfiguration($config,false); |
|
| 10794 | + $config = unserialize(file_get_contents($this->_cacheFile)); |
|
| 10795 | + $this->applyConfiguration($config, false); |
|
| 10796 | 10796 | } |
| 10797 | - if(($serviceID=$this->getRequest()->resolveRequest(array_keys($this->_services)))===null) |
|
| 10798 | - $serviceID=$this->getPageServiceID(); |
|
| 10797 | + if (($serviceID = $this->getRequest()->resolveRequest(array_keys($this->_services))) === null) |
|
| 10798 | + $serviceID = $this->getPageServiceID(); |
|
| 10799 | 10799 | $this->startService($serviceID); |
| 10800 | 10800 | } |
| 10801 | 10801 | public function startService($serviceID) |
| 10802 | 10802 | { |
| 10803 | - if(isset($this->_services[$serviceID])) |
|
| 10803 | + if (isset($this->_services[$serviceID])) |
|
| 10804 | 10804 | { |
| 10805 | - list($serviceClass,$initProperties,$configElement)=$this->_services[$serviceID]; |
|
| 10806 | - $service=Prado::createComponent($serviceClass); |
|
| 10807 | - if(!($service instanceof IService)) |
|
| 10808 | - throw new THttpException(500,'application_service_invalid',$serviceClass); |
|
| 10809 | - if(!$service->getEnabled()) |
|
| 10810 | - throw new THttpException(500,'application_service_unavailable',$serviceClass); |
|
| 10805 | + list($serviceClass, $initProperties, $configElement) = $this->_services[$serviceID]; |
|
| 10806 | + $service = Prado::createComponent($serviceClass); |
|
| 10807 | + if (!($service instanceof IService)) |
|
| 10808 | + throw new THttpException(500, 'application_service_invalid', $serviceClass); |
|
| 10809 | + if (!$service->getEnabled()) |
|
| 10810 | + throw new THttpException(500, 'application_service_unavailable', $serviceClass); |
|
| 10811 | 10811 | $service->setID($serviceID); |
| 10812 | 10812 | $this->setService($service); |
| 10813 | - foreach($initProperties as $name=>$value) |
|
| 10814 | - $service->setSubProperty($name,$value); |
|
| 10815 | - if($configElement!==null) |
|
| 10813 | + foreach ($initProperties as $name=>$value) |
|
| 10814 | + $service->setSubProperty($name, $value); |
|
| 10815 | + if ($configElement !== null) |
|
| 10816 | 10816 | { |
| 10817 | - $config=new TApplicationConfiguration; |
|
| 10818 | - if($this->getConfigurationType()==self::CONFIG_TYPE_PHP) |
|
| 10819 | - $config->loadFromPhp($configElement,$this->getBasePath()); |
|
| 10817 | + $config = new TApplicationConfiguration; |
|
| 10818 | + if ($this->getConfigurationType() == self::CONFIG_TYPE_PHP) |
|
| 10819 | + $config->loadFromPhp($configElement, $this->getBasePath()); |
|
| 10820 | 10820 | else |
| 10821 | - $config->loadFromXml($configElement,$this->getBasePath()); |
|
| 10822 | - $this->applyConfiguration($config,true); |
|
| 10821 | + $config->loadFromXml($configElement, $this->getBasePath()); |
|
| 10822 | + $this->applyConfiguration($config, true); |
|
| 10823 | 10823 | } |
| 10824 | 10824 | $service->init($configElement); |
| 10825 | 10825 | } |
| 10826 | 10826 | else |
| 10827 | - throw new THttpException(500,'application_service_unknown',$serviceID); |
|
| 10827 | + throw new THttpException(500, 'application_service_unknown', $serviceID); |
|
| 10828 | 10828 | } |
| 10829 | 10829 | public function onError($param) |
| 10830 | 10830 | { |
| 10831 | - Prado::log($param->getMessage(),TLogger::ERROR,'System.TApplication'); |
|
| 10832 | - $this->raiseEvent('OnError',$this,$param); |
|
| 10833 | - $this->getErrorHandler()->handleError($this,$param); |
|
| 10831 | + Prado::log($param->getMessage(), TLogger::ERROR, 'System.TApplication'); |
|
| 10832 | + $this->raiseEvent('OnError', $this, $param); |
|
| 10833 | + $this->getErrorHandler()->handleError($this, $param); |
|
| 10834 | 10834 | } |
| 10835 | 10835 | public function onBeginRequest() |
| 10836 | 10836 | { |
| 10837 | - $this->raiseEvent('OnBeginRequest',$this,null); |
|
| 10837 | + $this->raiseEvent('OnBeginRequest', $this, null); |
|
| 10838 | 10838 | } |
| 10839 | 10839 | public function onAuthentication() |
| 10840 | 10840 | { |
| 10841 | - $this->raiseEvent('OnAuthentication',$this,null); |
|
| 10841 | + $this->raiseEvent('OnAuthentication', $this, null); |
|
| 10842 | 10842 | } |
| 10843 | 10843 | public function onAuthenticationComplete() |
| 10844 | 10844 | { |
| 10845 | - $this->raiseEvent('OnAuthenticationComplete',$this,null); |
|
| 10845 | + $this->raiseEvent('OnAuthenticationComplete', $this, null); |
|
| 10846 | 10846 | } |
| 10847 | 10847 | public function onAuthorization() |
| 10848 | 10848 | { |
| 10849 | - $this->raiseEvent('OnAuthorization',$this,null); |
|
| 10849 | + $this->raiseEvent('OnAuthorization', $this, null); |
|
| 10850 | 10850 | } |
| 10851 | 10851 | public function onAuthorizationComplete() |
| 10852 | 10852 | { |
| 10853 | - $this->raiseEvent('OnAuthorizationComplete',$this,null); |
|
| 10853 | + $this->raiseEvent('OnAuthorizationComplete', $this, null); |
|
| 10854 | 10854 | } |
| 10855 | 10855 | public function onLoadState() |
| 10856 | 10856 | { |
| 10857 | 10857 | $this->loadGlobals(); |
| 10858 | - $this->raiseEvent('OnLoadState',$this,null); |
|
| 10858 | + $this->raiseEvent('OnLoadState', $this, null); |
|
| 10859 | 10859 | } |
| 10860 | 10860 | public function onLoadStateComplete() |
| 10861 | 10861 | { |
| 10862 | - $this->raiseEvent('OnLoadStateComplete',$this,null); |
|
| 10862 | + $this->raiseEvent('OnLoadStateComplete', $this, null); |
|
| 10863 | 10863 | } |
| 10864 | 10864 | public function onPreRunService() |
| 10865 | 10865 | { |
| 10866 | - $this->raiseEvent('OnPreRunService',$this,null); |
|
| 10866 | + $this->raiseEvent('OnPreRunService', $this, null); |
|
| 10867 | 10867 | } |
| 10868 | 10868 | public function runService() |
| 10869 | 10869 | { |
| 10870 | - if($this->_service) |
|
| 10870 | + if ($this->_service) |
|
| 10871 | 10871 | $this->_service->run(); |
| 10872 | 10872 | } |
| 10873 | 10873 | public function onSaveState() |
| 10874 | 10874 | { |
| 10875 | - $this->raiseEvent('OnSaveState',$this,null); |
|
| 10875 | + $this->raiseEvent('OnSaveState', $this, null); |
|
| 10876 | 10876 | $this->saveGlobals(); |
| 10877 | 10877 | } |
| 10878 | 10878 | public function onSaveStateComplete() |
| 10879 | 10879 | { |
| 10880 | - $this->raiseEvent('OnSaveStateComplete',$this,null); |
|
| 10880 | + $this->raiseEvent('OnSaveStateComplete', $this, null); |
|
| 10881 | 10881 | } |
| 10882 | 10882 | public function onPreFlushOutput() |
| 10883 | 10883 | { |
| 10884 | - $this->raiseEvent('OnPreFlushOutput',$this,null); |
|
| 10884 | + $this->raiseEvent('OnPreFlushOutput', $this, null); |
|
| 10885 | 10885 | } |
| 10886 | 10886 | public function flushOutput($continueBuffering = true) |
| 10887 | 10887 | { |
@@ -10889,38 +10889,38 @@ discard block |
||
| 10889 | 10889 | } |
| 10890 | 10890 | public function onEndRequest() |
| 10891 | 10891 | { |
| 10892 | - $this->flushOutput(false); $this->saveGlobals(); $this->raiseEvent('OnEndRequest',$this,null); |
|
| 10892 | + $this->flushOutput(false); $this->saveGlobals(); $this->raiseEvent('OnEndRequest', $this, null); |
|
| 10893 | 10893 | } |
| 10894 | 10894 | } |
| 10895 | 10895 | class TApplicationMode extends TEnumerable |
| 10896 | 10896 | { |
| 10897 | - const Off='Off'; |
|
| 10898 | - const Debug='Debug'; |
|
| 10899 | - const Normal='Normal'; |
|
| 10900 | - const Performance='Performance'; |
|
| 10897 | + const Off = 'Off'; |
|
| 10898 | + const Debug = 'Debug'; |
|
| 10899 | + const Normal = 'Normal'; |
|
| 10900 | + const Performance = 'Performance'; |
|
| 10901 | 10901 | } |
| 10902 | 10902 | class TApplicationConfiguration extends TComponent |
| 10903 | 10903 | { |
| 10904 | - private $_properties=array(); |
|
| 10905 | - private $_usings=array(); |
|
| 10906 | - private $_aliases=array(); |
|
| 10907 | - private $_modules=array(); |
|
| 10908 | - private $_services=array(); |
|
| 10909 | - private $_parameters=array(); |
|
| 10910 | - private $_includes=array(); |
|
| 10911 | - private $_empty=true; |
|
| 10904 | + private $_properties = array(); |
|
| 10905 | + private $_usings = array(); |
|
| 10906 | + private $_aliases = array(); |
|
| 10907 | + private $_modules = array(); |
|
| 10908 | + private $_services = array(); |
|
| 10909 | + private $_parameters = array(); |
|
| 10910 | + private $_includes = array(); |
|
| 10911 | + private $_empty = true; |
|
| 10912 | 10912 | public function loadFromFile($fname) |
| 10913 | 10913 | { |
| 10914 | - if(Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
|
| 10914 | + if (Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
| 10915 | 10915 | { |
| 10916 | 10916 | $fcontent = include $fname; |
| 10917 | - $this->loadFromPhp($fcontent,dirname($fname)); |
|
| 10917 | + $this->loadFromPhp($fcontent, dirname($fname)); |
|
| 10918 | 10918 | } |
| 10919 | 10919 | else |
| 10920 | 10920 | { |
| 10921 | - $dom=new TXmlDocument; |
|
| 10921 | + $dom = new TXmlDocument; |
|
| 10922 | 10922 | $dom->loadFromFile($fname); |
| 10923 | - $this->loadFromXml($dom,dirname($fname)); |
|
| 10923 | + $this->loadFromXml($dom, dirname($fname)); |
|
| 10924 | 10924 | } |
| 10925 | 10925 | } |
| 10926 | 10926 | public function getIsEmpty() |
@@ -10929,50 +10929,50 @@ discard block |
||
| 10929 | 10929 | } |
| 10930 | 10930 | public function loadFromPhp($config, $configPath) |
| 10931 | 10931 | { |
| 10932 | - if(isset($config['application'])) |
|
| 10932 | + if (isset($config['application'])) |
|
| 10933 | 10933 | { |
| 10934 | - foreach($config['application'] as $name=>$value) |
|
| 10934 | + foreach ($config['application'] as $name=>$value) |
|
| 10935 | 10935 | { |
| 10936 | - $this->_properties[$name]=$value; |
|
| 10936 | + $this->_properties[$name] = $value; |
|
| 10937 | 10937 | } |
| 10938 | 10938 | $this->_empty = false; |
| 10939 | 10939 | } |
| 10940 | - if(isset($config['paths']) && is_array($config['paths'])) |
|
| 10941 | - $this->loadPathsPhp($config['paths'],$configPath); |
|
| 10942 | - if(isset($config['modules']) && is_array($config['modules'])) |
|
| 10943 | - $this->loadModulesPhp($config['modules'],$configPath); |
|
| 10944 | - if(isset($config['services']) && is_array($config['services'])) |
|
| 10945 | - $this->loadServicesPhp($config['services'],$configPath); |
|
| 10946 | - if(isset($config['parameters']) && is_array($config['parameters'])) |
|
| 10940 | + if (isset($config['paths']) && is_array($config['paths'])) |
|
| 10941 | + $this->loadPathsPhp($config['paths'], $configPath); |
|
| 10942 | + if (isset($config['modules']) && is_array($config['modules'])) |
|
| 10943 | + $this->loadModulesPhp($config['modules'], $configPath); |
|
| 10944 | + if (isset($config['services']) && is_array($config['services'])) |
|
| 10945 | + $this->loadServicesPhp($config['services'], $configPath); |
|
| 10946 | + if (isset($config['parameters']) && is_array($config['parameters'])) |
|
| 10947 | 10947 | $this->loadParametersPhp($config['parameters'], $configPath); |
| 10948 | - if(isset($config['includes']) && is_array($config['includes'])) |
|
| 10949 | - $this->loadExternalXml($config['includes'],$configPath); |
|
| 10948 | + if (isset($config['includes']) && is_array($config['includes'])) |
|
| 10949 | + $this->loadExternalXml($config['includes'], $configPath); |
|
| 10950 | 10950 | } |
| 10951 | - public function loadFromXml($dom,$configPath) |
|
| 10951 | + public function loadFromXml($dom, $configPath) |
|
| 10952 | 10952 | { |
| 10953 | - foreach($dom->getAttributes() as $name=>$value) |
|
| 10953 | + foreach ($dom->getAttributes() as $name=>$value) |
|
| 10954 | 10954 | { |
| 10955 | - $this->_properties[$name]=$value; |
|
| 10956 | - $this->_empty=false; |
|
| 10955 | + $this->_properties[$name] = $value; |
|
| 10956 | + $this->_empty = false; |
|
| 10957 | 10957 | } |
| 10958 | - foreach($dom->getElements() as $element) |
|
| 10958 | + foreach ($dom->getElements() as $element) |
|
| 10959 | 10959 | { |
| 10960 | - switch($element->getTagName()) |
|
| 10960 | + switch ($element->getTagName()) |
|
| 10961 | 10961 | { |
| 10962 | 10962 | case 'paths': |
| 10963 | - $this->loadPathsXml($element,$configPath); |
|
| 10963 | + $this->loadPathsXml($element, $configPath); |
|
| 10964 | 10964 | break; |
| 10965 | 10965 | case 'modules': |
| 10966 | - $this->loadModulesXml($element,$configPath); |
|
| 10966 | + $this->loadModulesXml($element, $configPath); |
|
| 10967 | 10967 | break; |
| 10968 | 10968 | case 'services': |
| 10969 | - $this->loadServicesXml($element,$configPath); |
|
| 10969 | + $this->loadServicesXml($element, $configPath); |
|
| 10970 | 10970 | break; |
| 10971 | 10971 | case 'parameters': |
| 10972 | - $this->loadParametersXml($element,$configPath); |
|
| 10972 | + $this->loadParametersXml($element, $configPath); |
|
| 10973 | 10973 | break; |
| 10974 | 10974 | case 'include': |
| 10975 | - $this->loadExternalXml($element,$configPath); |
|
| 10975 | + $this->loadExternalXml($element, $configPath); |
|
| 10976 | 10976 | break; |
| 10977 | 10977 | default: |
| 10978 | 10978 | break; |
@@ -10981,155 +10981,155 @@ discard block |
||
| 10981 | 10981 | } |
| 10982 | 10982 | protected function loadPathsPhp($pathsNode, $configPath) |
| 10983 | 10983 | { |
| 10984 | - if(isset($pathsNode['aliases']) && is_array($pathsNode['aliases'])) |
|
| 10984 | + if (isset($pathsNode['aliases']) && is_array($pathsNode['aliases'])) |
|
| 10985 | 10985 | { |
| 10986 | - foreach($pathsNode['aliases'] as $id=>$path) |
|
| 10986 | + foreach ($pathsNode['aliases'] as $id=>$path) |
|
| 10987 | 10987 | { |
| 10988 | - $path=str_replace('\\','/',$path); |
|
| 10989 | - if(preg_match('/^\\/|.:\\/|.:\\\\/',$path)) $p=realpath($path); |
|
| 10988 | + $path = str_replace('\\', '/', $path); |
|
| 10989 | + if (preg_match('/^\\/|.:\\/|.:\\\\/', $path)) $p = realpath($path); |
|
| 10990 | 10990 | else |
| 10991 | - $p=realpath($configPath.DIRECTORY_SEPARATOR.$path); |
|
| 10992 | - if($p===false || !is_dir($p)) |
|
| 10993 | - throw new TConfigurationException('appconfig_aliaspath_invalid',$id,$path); |
|
| 10994 | - if(isset($this->_aliases[$id])) |
|
| 10995 | - throw new TConfigurationException('appconfig_alias_redefined',$id); |
|
| 10996 | - $this->_aliases[$id]=$p; |
|
| 10991 | + $p = realpath($configPath . DIRECTORY_SEPARATOR . $path); |
|
| 10992 | + if ($p === false || !is_dir($p)) |
|
| 10993 | + throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path); |
|
| 10994 | + if (isset($this->_aliases[$id])) |
|
| 10995 | + throw new TConfigurationException('appconfig_alias_redefined', $id); |
|
| 10996 | + $this->_aliases[$id] = $p; |
|
| 10997 | 10997 | } |
| 10998 | 10998 | } |
| 10999 | - if(isset($pathsNode['using']) && is_array($pathsNode['using'])) |
|
| 10999 | + if (isset($pathsNode['using']) && is_array($pathsNode['using'])) |
|
| 11000 | 11000 | { |
| 11001 | - foreach($pathsNode['using'] as $namespace) |
|
| 11001 | + foreach ($pathsNode['using'] as $namespace) |
|
| 11002 | 11002 | { |
| 11003 | 11003 | $this->_usings[] = $namespace; |
| 11004 | 11004 | } |
| 11005 | 11005 | } |
| 11006 | 11006 | } |
| 11007 | - protected function loadPathsXml($pathsNode,$configPath) |
|
| 11007 | + protected function loadPathsXml($pathsNode, $configPath) |
|
| 11008 | 11008 | { |
| 11009 | - foreach($pathsNode->getElements() as $element) |
|
| 11009 | + foreach ($pathsNode->getElements() as $element) |
|
| 11010 | 11010 | { |
| 11011 | - switch($element->getTagName()) |
|
| 11011 | + switch ($element->getTagName()) |
|
| 11012 | 11012 | { |
| 11013 | 11013 | case 'alias': |
| 11014 | 11014 | { |
| 11015 | - if(($id=$element->getAttribute('id'))!==null && ($path=$element->getAttribute('path'))!==null) |
|
| 11015 | + if (($id = $element->getAttribute('id')) !== null && ($path = $element->getAttribute('path')) !== null) |
|
| 11016 | 11016 | { |
| 11017 | - $path=str_replace('\\','/',$path); |
|
| 11018 | - if(preg_match('/^\\/|.:\\/|.:\\\\/',$path)) $p=realpath($path); |
|
| 11017 | + $path = str_replace('\\', '/', $path); |
|
| 11018 | + if (preg_match('/^\\/|.:\\/|.:\\\\/', $path)) $p = realpath($path); |
|
| 11019 | 11019 | else |
| 11020 | - $p=realpath($configPath.DIRECTORY_SEPARATOR.$path); |
|
| 11021 | - if($p===false || !is_dir($p)) |
|
| 11022 | - throw new TConfigurationException('appconfig_aliaspath_invalid',$id,$path); |
|
| 11023 | - if(isset($this->_aliases[$id])) |
|
| 11024 | - throw new TConfigurationException('appconfig_alias_redefined',$id); |
|
| 11025 | - $this->_aliases[$id]=$p; |
|
| 11020 | + $p = realpath($configPath . DIRECTORY_SEPARATOR . $path); |
|
| 11021 | + if ($p === false || !is_dir($p)) |
|
| 11022 | + throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path); |
|
| 11023 | + if (isset($this->_aliases[$id])) |
|
| 11024 | + throw new TConfigurationException('appconfig_alias_redefined', $id); |
|
| 11025 | + $this->_aliases[$id] = $p; |
|
| 11026 | 11026 | } |
| 11027 | 11027 | else |
| 11028 | 11028 | throw new TConfigurationException('appconfig_alias_invalid'); |
| 11029 | - $this->_empty=false; |
|
| 11029 | + $this->_empty = false; |
|
| 11030 | 11030 | break; |
| 11031 | 11031 | } |
| 11032 | 11032 | case 'using': |
| 11033 | 11033 | { |
| 11034 | - if(($namespace=$element->getAttribute('namespace'))!==null) |
|
| 11035 | - $this->_usings[]=$namespace; |
|
| 11034 | + if (($namespace = $element->getAttribute('namespace')) !== null) |
|
| 11035 | + $this->_usings[] = $namespace; |
|
| 11036 | 11036 | else |
| 11037 | 11037 | throw new TConfigurationException('appconfig_using_invalid'); |
| 11038 | - $this->_empty=false; |
|
| 11038 | + $this->_empty = false; |
|
| 11039 | 11039 | break; |
| 11040 | 11040 | } |
| 11041 | 11041 | default: |
| 11042 | - throw new TConfigurationException('appconfig_paths_invalid',$element->getTagName()); |
|
| 11042 | + throw new TConfigurationException('appconfig_paths_invalid', $element->getTagName()); |
|
| 11043 | 11043 | } |
| 11044 | 11044 | } |
| 11045 | 11045 | } |
| 11046 | 11046 | protected function loadModulesPhp($modulesNode, $configPath) |
| 11047 | 11047 | { |
| 11048 | - foreach($modulesNode as $id=>$module) |
|
| 11048 | + foreach ($modulesNode as $id=>$module) |
|
| 11049 | 11049 | { |
| 11050 | - if(!isset($module['class'])) |
|
| 11051 | - throw new TConfigurationException('appconfig_moduletype_required',$id); |
|
| 11050 | + if (!isset($module['class'])) |
|
| 11051 | + throw new TConfigurationException('appconfig_moduletype_required', $id); |
|
| 11052 | 11052 | $type = $module['class']; |
| 11053 | 11053 | unset($module['class']); |
| 11054 | 11054 | $properties = array(); |
| 11055 | - if(isset($module['properties'])) |
|
| 11055 | + if (isset($module['properties'])) |
|
| 11056 | 11056 | { |
| 11057 | 11057 | $properties = $module['properties']; |
| 11058 | 11058 | unset($module['properties']); |
| 11059 | 11059 | } |
| 11060 | 11060 | $properties['id'] = $id; |
| 11061 | - $this->_modules[$id]=array($type,$properties,$module); |
|
| 11062 | - $this->_empty=false; |
|
| 11061 | + $this->_modules[$id] = array($type, $properties, $module); |
|
| 11062 | + $this->_empty = false; |
|
| 11063 | 11063 | } |
| 11064 | 11064 | } |
| 11065 | - protected function loadModulesXml($modulesNode,$configPath) |
|
| 11065 | + protected function loadModulesXml($modulesNode, $configPath) |
|
| 11066 | 11066 | { |
| 11067 | - foreach($modulesNode->getElements() as $element) |
|
| 11067 | + foreach ($modulesNode->getElements() as $element) |
|
| 11068 | 11068 | { |
| 11069 | - if($element->getTagName()==='module') |
|
| 11069 | + if ($element->getTagName() === 'module') |
|
| 11070 | 11070 | { |
| 11071 | - $properties=$element->getAttributes(); |
|
| 11072 | - $id=$properties->itemAt('id'); |
|
| 11073 | - $type=$properties->remove('class'); |
|
| 11074 | - if($type===null) |
|
| 11075 | - throw new TConfigurationException('appconfig_moduletype_required',$id); |
|
| 11071 | + $properties = $element->getAttributes(); |
|
| 11072 | + $id = $properties->itemAt('id'); |
|
| 11073 | + $type = $properties->remove('class'); |
|
| 11074 | + if ($type === null) |
|
| 11075 | + throw new TConfigurationException('appconfig_moduletype_required', $id); |
|
| 11076 | 11076 | $element->setParent(null); |
| 11077 | - if($id===null) |
|
| 11078 | - $this->_modules[]=array($type,$properties->toArray(),$element); |
|
| 11077 | + if ($id === null) |
|
| 11078 | + $this->_modules[] = array($type, $properties->toArray(), $element); |
|
| 11079 | 11079 | else |
| 11080 | - $this->_modules[$id]=array($type,$properties->toArray(),$element); |
|
| 11081 | - $this->_empty=false; |
|
| 11080 | + $this->_modules[$id] = array($type, $properties->toArray(), $element); |
|
| 11081 | + $this->_empty = false; |
|
| 11082 | 11082 | } |
| 11083 | 11083 | else |
| 11084 | - throw new TConfigurationException('appconfig_modules_invalid',$element->getTagName()); |
|
| 11084 | + throw new TConfigurationException('appconfig_modules_invalid', $element->getTagName()); |
|
| 11085 | 11085 | } |
| 11086 | 11086 | } |
| 11087 | - protected function loadServicesPhp($servicesNode,$configPath) |
|
| 11087 | + protected function loadServicesPhp($servicesNode, $configPath) |
|
| 11088 | 11088 | { |
| 11089 | - foreach($servicesNode as $id => $service) |
|
| 11089 | + foreach ($servicesNode as $id => $service) |
|
| 11090 | 11090 | { |
| 11091 | - if(!isset($service['class'])) |
|
| 11091 | + if (!isset($service['class'])) |
|
| 11092 | 11092 | throw new TConfigurationException('appconfig_servicetype_required'); |
| 11093 | 11093 | $type = $service['class']; |
| 11094 | 11094 | $properties = isset($service['properties']) ? $service['properties'] : array(); |
| 11095 | 11095 | unset($service['properties']); |
| 11096 | 11096 | $properties['id'] = $id; |
| 11097 | - $this->_services[$id] = array($type,$properties,$service); |
|
| 11097 | + $this->_services[$id] = array($type, $properties, $service); |
|
| 11098 | 11098 | $this->_empty = false; |
| 11099 | 11099 | } |
| 11100 | 11100 | } |
| 11101 | - protected function loadServicesXml($servicesNode,$configPath) |
|
| 11101 | + protected function loadServicesXml($servicesNode, $configPath) |
|
| 11102 | 11102 | { |
| 11103 | - foreach($servicesNode->getElements() as $element) |
|
| 11103 | + foreach ($servicesNode->getElements() as $element) |
|
| 11104 | 11104 | { |
| 11105 | - if($element->getTagName()==='service') |
|
| 11105 | + if ($element->getTagName() === 'service') |
|
| 11106 | 11106 | { |
| 11107 | - $properties=$element->getAttributes(); |
|
| 11108 | - if(($id=$properties->itemAt('id'))===null) |
|
| 11107 | + $properties = $element->getAttributes(); |
|
| 11108 | + if (($id = $properties->itemAt('id')) === null) |
|
| 11109 | 11109 | throw new TConfigurationException('appconfig_serviceid_required'); |
| 11110 | - if(($type=$properties->remove('class'))===null) |
|
| 11111 | - throw new TConfigurationException('appconfig_servicetype_required',$id); |
|
| 11110 | + if (($type = $properties->remove('class')) === null) |
|
| 11111 | + throw new TConfigurationException('appconfig_servicetype_required', $id); |
|
| 11112 | 11112 | $element->setParent(null); |
| 11113 | - $this->_services[$id]=array($type,$properties->toArray(),$element); |
|
| 11114 | - $this->_empty=false; |
|
| 11113 | + $this->_services[$id] = array($type, $properties->toArray(), $element); |
|
| 11114 | + $this->_empty = false; |
|
| 11115 | 11115 | } |
| 11116 | 11116 | else |
| 11117 | - throw new TConfigurationException('appconfig_services_invalid',$element->getTagName()); |
|
| 11117 | + throw new TConfigurationException('appconfig_services_invalid', $element->getTagName()); |
|
| 11118 | 11118 | } |
| 11119 | 11119 | } |
| 11120 | - protected function loadParametersPhp($parametersNode,$configPath) |
|
| 11120 | + protected function loadParametersPhp($parametersNode, $configPath) |
|
| 11121 | 11121 | { |
| 11122 | - foreach($parametersNode as $id => $parameter) |
|
| 11122 | + foreach ($parametersNode as $id => $parameter) |
|
| 11123 | 11123 | { |
| 11124 | - if(is_array($parameter)) |
|
| 11124 | + if (is_array($parameter)) |
|
| 11125 | 11125 | { |
| 11126 | - if(isset($parameter['class'])) |
|
| 11126 | + if (isset($parameter['class'])) |
|
| 11127 | 11127 | { |
| 11128 | 11128 | $type = $parameter['class']; |
| 11129 | 11129 | unset($parameter['class']); |
| 11130 | 11130 | $properties = isset($service['properties']) ? $service['properties'] : array(); |
| 11131 | 11131 | $properties['id'] = $id; |
| 11132 | - $this->_parameters[$id] = array($type,$properties); |
|
| 11132 | + $this->_parameters[$id] = array($type, $properties); |
|
| 11133 | 11133 | } |
| 11134 | 11134 | } |
| 11135 | 11135 | else |
@@ -11138,56 +11138,56 @@ discard block |
||
| 11138 | 11138 | } |
| 11139 | 11139 | } |
| 11140 | 11140 | } |
| 11141 | - protected function loadParametersXml($parametersNode,$configPath) |
|
| 11141 | + protected function loadParametersXml($parametersNode, $configPath) |
|
| 11142 | 11142 | { |
| 11143 | - foreach($parametersNode->getElements() as $element) |
|
| 11143 | + foreach ($parametersNode->getElements() as $element) |
|
| 11144 | 11144 | { |
| 11145 | - if($element->getTagName()==='parameter') |
|
| 11145 | + if ($element->getTagName() === 'parameter') |
|
| 11146 | 11146 | { |
| 11147 | - $properties=$element->getAttributes(); |
|
| 11148 | - if(($id=$properties->remove('id'))===null) |
|
| 11147 | + $properties = $element->getAttributes(); |
|
| 11148 | + if (($id = $properties->remove('id')) === null) |
|
| 11149 | 11149 | throw new TConfigurationException('appconfig_parameterid_required'); |
| 11150 | - if(($type=$properties->remove('class'))===null) |
|
| 11150 | + if (($type = $properties->remove('class')) === null) |
|
| 11151 | 11151 | { |
| 11152 | - if(($value=$properties->remove('value'))===null) |
|
| 11153 | - $this->_parameters[$id]=$element; |
|
| 11152 | + if (($value = $properties->remove('value')) === null) |
|
| 11153 | + $this->_parameters[$id] = $element; |
|
| 11154 | 11154 | else |
| 11155 | - $this->_parameters[$id]=$value; |
|
| 11155 | + $this->_parameters[$id] = $value; |
|
| 11156 | 11156 | } |
| 11157 | 11157 | else |
| 11158 | - $this->_parameters[$id]=array($type,$properties->toArray()); |
|
| 11159 | - $this->_empty=false; |
|
| 11158 | + $this->_parameters[$id] = array($type, $properties->toArray()); |
|
| 11159 | + $this->_empty = false; |
|
| 11160 | 11160 | } |
| 11161 | 11161 | else |
| 11162 | - throw new TConfigurationException('appconfig_parameters_invalid',$element->getTagName()); |
|
| 11162 | + throw new TConfigurationException('appconfig_parameters_invalid', $element->getTagName()); |
|
| 11163 | 11163 | } |
| 11164 | 11164 | } |
| 11165 | - protected function loadExternalPhp($includeNode,$configPath) |
|
| 11165 | + protected function loadExternalPhp($includeNode, $configPath) |
|
| 11166 | 11166 | { |
| 11167 | - foreach($includeNode as $include) |
|
| 11167 | + foreach ($includeNode as $include) |
|
| 11168 | 11168 | { |
| 11169 | - $when = isset($include['when'])?true:false; |
|
| 11170 | - if(!isset($include['file'])) |
|
| 11169 | + $when = isset($include['when']) ? true : false; |
|
| 11170 | + if (!isset($include['file'])) |
|
| 11171 | 11171 | throw new TConfigurationException('appconfig_includefile_required'); |
| 11172 | 11172 | $filePath = $include['file']; |
| 11173 | - if(isset($this->_includes[$filePath])) |
|
| 11174 | - $this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')'; |
|
| 11173 | + if (isset($this->_includes[$filePath])) |
|
| 11174 | + $this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')'; |
|
| 11175 | 11175 | else |
| 11176 | - $$this->_includes[$filePath]=$when; |
|
| 11177 | - $this->_empty=false; |
|
| 11176 | + $$this->_includes[$filePath] = $when; |
|
| 11177 | + $this->_empty = false; |
|
| 11178 | 11178 | } |
| 11179 | 11179 | } |
| 11180 | - protected function loadExternalXml($includeNode,$configPath) |
|
| 11180 | + protected function loadExternalXml($includeNode, $configPath) |
|
| 11181 | 11181 | { |
| 11182 | - if(($when=$includeNode->getAttribute('when'))===null) |
|
| 11183 | - $when=true; |
|
| 11184 | - if(($filePath=$includeNode->getAttribute('file'))===null) |
|
| 11182 | + if (($when = $includeNode->getAttribute('when')) === null) |
|
| 11183 | + $when = true; |
|
| 11184 | + if (($filePath = $includeNode->getAttribute('file')) === null) |
|
| 11185 | 11185 | throw new TConfigurationException('appconfig_includefile_required'); |
| 11186 | - if(isset($this->_includes[$filePath])) |
|
| 11187 | - $this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')'; |
|
| 11186 | + if (isset($this->_includes[$filePath])) |
|
| 11187 | + $this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')'; |
|
| 11188 | 11188 | else |
| 11189 | - $this->_includes[$filePath]=$when; |
|
| 11190 | - $this->_empty=false; |
|
| 11189 | + $this->_includes[$filePath] = $when; |
|
| 11190 | + $this->_empty = false; |
|
| 11191 | 11191 | } |
| 11192 | 11192 | public function getProperties() |
| 11193 | 11193 | { |
@@ -11220,22 +11220,22 @@ discard block |
||
| 11220 | 11220 | } |
| 11221 | 11221 | class TApplicationStatePersister extends TModule implements IStatePersister |
| 11222 | 11222 | { |
| 11223 | - const CACHE_NAME='prado:appstate'; |
|
| 11223 | + const CACHE_NAME = 'prado:appstate'; |
|
| 11224 | 11224 | public function init($config) |
| 11225 | 11225 | { |
| 11226 | 11226 | $this->getApplication()->setApplicationStatePersister($this); |
| 11227 | 11227 | } |
| 11228 | 11228 | protected function getStateFilePath() |
| 11229 | 11229 | { |
| 11230 | - return $this->getApplication()->getRuntimePath().'/global.cache'; |
|
| 11230 | + return $this->getApplication()->getRuntimePath() . '/global.cache'; |
|
| 11231 | 11231 | } |
| 11232 | 11232 | public function load() |
| 11233 | 11233 | { |
| 11234 | - if(($cache=$this->getApplication()->getCache())!==null && ($value=$cache->get(self::CACHE_NAME))!==false) |
|
| 11234 | + if (($cache = $this->getApplication()->getCache()) !== null && ($value = $cache->get(self::CACHE_NAME)) !== false) |
|
| 11235 | 11235 | return unserialize($value); |
| 11236 | 11236 | else |
| 11237 | 11237 | { |
| 11238 | - if(($content=@file_get_contents($this->getStateFilePath()))!==false) |
|
| 11238 | + if (($content = @file_get_contents($this->getStateFilePath())) !== false) |
|
| 11239 | 11239 | return unserialize($content); |
| 11240 | 11240 | else |
| 11241 | 11241 | return null; |
@@ -11243,19 +11243,19 @@ discard block |
||
| 11243 | 11243 | } |
| 11244 | 11244 | public function save($state) |
| 11245 | 11245 | { |
| 11246 | - $content=serialize($state); |
|
| 11247 | - $saveFile=true; |
|
| 11248 | - if(($cache=$this->getApplication()->getCache())!==null) |
|
| 11246 | + $content = serialize($state); |
|
| 11247 | + $saveFile = true; |
|
| 11248 | + if (($cache = $this->getApplication()->getCache()) !== null) |
|
| 11249 | 11249 | { |
| 11250 | - if($cache->get(self::CACHE_NAME)===$content) |
|
| 11251 | - $saveFile=false; |
|
| 11250 | + if ($cache->get(self::CACHE_NAME) === $content) |
|
| 11251 | + $saveFile = false; |
|
| 11252 | 11252 | else |
| 11253 | - $cache->set(self::CACHE_NAME,$content); |
|
| 11253 | + $cache->set(self::CACHE_NAME, $content); |
|
| 11254 | 11254 | } |
| 11255 | - if($saveFile) |
|
| 11255 | + if ($saveFile) |
|
| 11256 | 11256 | { |
| 11257 | - $fileName=$this->getStateFilePath(); |
|
| 11258 | - file_put_contents($fileName,$content,LOCK_EX); |
|
| 11257 | + $fileName = $this->getStateFilePath(); |
|
| 11258 | + file_put_contents($fileName, $content, LOCK_EX); |
|
| 11259 | 11259 | } |
| 11260 | 11260 | } |
| 11261 | 11261 | } |
@@ -78,6 +78,10 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | exit(1); |
| 80 | 80 | } |
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * @param TApplication $application |
|
| 84 | + */ |
|
| 81 | 85 | public static function setApplication($application) |
| 82 | 86 | { |
| 83 | 87 | if(self::$_application!==null && !defined('PRADO_TEST_RUN')) |
@@ -371,14 +375,26 @@ discard block |
||
| 371 | 375 | interface IModule |
| 372 | 376 | { |
| 373 | 377 | public function init($config); |
| 378 | + |
|
| 379 | + /** |
|
| 380 | + * @return string |
|
| 381 | + */ |
|
| 374 | 382 | public function getID(); |
| 375 | 383 | public function setID($id); |
| 376 | 384 | } |
| 377 | 385 | interface IService |
| 378 | 386 | { |
| 379 | 387 | public function init($config); |
| 388 | + |
|
| 389 | + /** |
|
| 390 | + * @return string |
|
| 391 | + */ |
|
| 380 | 392 | public function getID(); |
| 381 | 393 | public function setID($id); |
| 394 | + |
|
| 395 | + /** |
|
| 396 | + * @return boolean |
|
| 397 | + */ |
|
| 382 | 398 | public function getEnabled(); |
| 383 | 399 | public function setEnabled($value); |
| 384 | 400 | public function run(); |
@@ -390,14 +406,37 @@ discard block |
||
| 390 | 406 | } |
| 391 | 407 | interface IUser |
| 392 | 408 | { |
| 409 | + /** |
|
| 410 | + * @return string |
|
| 411 | + */ |
|
| 393 | 412 | public function getName(); |
| 394 | 413 | public function setName($value); |
| 414 | + |
|
| 415 | + /** |
|
| 416 | + * @return boolean |
|
| 417 | + */ |
|
| 395 | 418 | public function getIsGuest(); |
| 419 | + |
|
| 420 | + /** |
|
| 421 | + * @param boolean $value |
|
| 422 | + */ |
|
| 396 | 423 | public function setIsGuest($value); |
| 397 | 424 | public function getRoles(); |
| 398 | 425 | public function setRoles($value); |
| 426 | + |
|
| 427 | + /** |
|
| 428 | + * @return boolean |
|
| 429 | + */ |
|
| 399 | 430 | public function isInRole($role); |
| 431 | + |
|
| 432 | + /** |
|
| 433 | + * @return string |
|
| 434 | + */ |
|
| 400 | 435 | public function saveToString(); |
| 436 | + |
|
| 437 | + /** |
|
| 438 | + * @return TUser |
|
| 439 | + */ |
|
| 401 | 440 | public function loadFromString($string); |
| 402 | 441 | } |
| 403 | 442 | interface IStatePersister |
@@ -409,6 +448,12 @@ discard block |
||
| 409 | 448 | { |
| 410 | 449 | public function get($id); |
| 411 | 450 | public function set($id,$value,$expire=0,$dependency=null); |
| 451 | + |
|
| 452 | + /** |
|
| 453 | + * @param string $id |
|
| 454 | + * |
|
| 455 | + * @return boolean |
|
| 456 | + */ |
|
| 412 | 457 | public function add($id,$value,$expire=0,$dependency=null); |
| 413 | 458 | public function delete($id); |
| 414 | 459 | public function flush(); |
@@ -427,12 +472,22 @@ discard block |
||
| 427 | 472 | } |
| 428 | 473 | interface IStyleable |
| 429 | 474 | { |
| 475 | + /** |
|
| 476 | + * @return boolean |
|
| 477 | + */ |
|
| 430 | 478 | public function getHasStyle(); |
| 479 | + |
|
| 480 | + /** |
|
| 481 | + * @return TStyle |
|
| 482 | + */ |
|
| 431 | 483 | public function getStyle(); |
| 432 | 484 | public function clearStyle(); |
| 433 | 485 | } |
| 434 | 486 | interface IActiveControl |
| 435 | 487 | { |
| 488 | + /** |
|
| 489 | + * @return TBaseActiveControl |
|
| 490 | + */ |
|
| 436 | 491 | public function getActiveControl(); |
| 437 | 492 | } |
| 438 | 493 | interface ICallbackEventHandler |
@@ -442,6 +497,10 @@ discard block |
||
| 442 | 497 | interface IDataRenderer |
| 443 | 498 | { |
| 444 | 499 | public function getData(); |
| 500 | + |
|
| 501 | + /** |
|
| 502 | + * @param TActiveRecord $value |
|
| 503 | + */ |
|
| 445 | 504 | public function setData($value); |
| 446 | 505 | } |
| 447 | 506 | class TApplicationComponent extends TComponent |
@@ -470,6 +529,10 @@ discard block |
||
| 470 | 529 | { |
| 471 | 530 | return Prado::getApplication()->getUser(); |
| 472 | 531 | } |
| 532 | + |
|
| 533 | + /** |
|
| 534 | + * @param string $assetPath |
|
| 535 | + */ |
|
| 473 | 536 | public function publishAsset($assetPath,$className=null) |
| 474 | 537 | { |
| 475 | 538 | if($className===null) |
@@ -478,6 +541,10 @@ discard block |
||
| 478 | 541 | $fullPath=dirname($class->getFileName()).DIRECTORY_SEPARATOR.$assetPath; |
| 479 | 542 | return $this->publishFilePath($fullPath); |
| 480 | 543 | } |
| 544 | + |
|
| 545 | + /** |
|
| 546 | + * @param string $fullPath |
|
| 547 | + */ |
|
| 481 | 548 | public function publishFilePath($fullPath, $checkTimestamp=false) |
| 482 | 549 | { |
| 483 | 550 | return Prado::getApplication()->getAssetManager()->publishFilePath($fullPath, $checkTimestamp); |
@@ -509,6 +576,10 @@ discard block |
||
| 509 | 576 | { |
| 510 | 577 | return $this->_id; |
| 511 | 578 | } |
| 579 | + |
|
| 580 | + /** |
|
| 581 | + * @param string $value |
|
| 582 | + */ |
|
| 512 | 583 | public function setID($value) |
| 513 | 584 | { |
| 514 | 585 | $this->_id=$value; |
@@ -548,6 +619,10 @@ discard block |
||
| 548 | 619 | else |
| 549 | 620 | throw new TConfigurationException('errorhandler_errortemplatepath_invalid',$value); |
| 550 | 621 | } |
| 622 | + |
|
| 623 | + /** |
|
| 624 | + * @param null|TApplication $sender |
|
| 625 | + */ |
|
| 551 | 626 | public function handleError($sender,$param) |
| 552 | 627 | { |
| 553 | 628 | static $handling=false; |
@@ -570,6 +645,10 @@ discard block |
||
| 570 | 645 | $this->handleExternalError(500,$param); |
| 571 | 646 | } |
| 572 | 647 | } |
| 648 | + |
|
| 649 | + /** |
|
| 650 | + * @return string |
|
| 651 | + */ |
|
| 573 | 652 | protected static function hideSecurityRelated($value, $exception=null) |
| 574 | 653 | { |
| 575 | 654 | $aRpl = array(); |
@@ -589,6 +668,10 @@ discard block |
||
| 589 | 668 | $aRpl = array_reverse($aRpl, true); |
| 590 | 669 | return str_replace(array_keys($aRpl), $aRpl, $value); |
| 591 | 670 | } |
| 671 | + |
|
| 672 | + /** |
|
| 673 | + * @param integer $statusCode |
|
| 674 | + */ |
|
| 592 | 675 | protected function handleExternalError($statusCode,$exception) |
| 593 | 676 | { |
| 594 | 677 | if(!($exception instanceof THttpException)) |
@@ -722,6 +805,10 @@ discard block |
||
| 722 | 805 | return null; |
| 723 | 806 | return $result; |
| 724 | 807 | } |
| 808 | + |
|
| 809 | + /** |
|
| 810 | + * @param string $pattern |
|
| 811 | + */ |
|
| 725 | 812 | private function getPropertyAccessTrace($trace,$pattern) |
| 726 | 813 | { |
| 727 | 814 | $result=null; |
@@ -751,6 +838,10 @@ discard block |
||
| 751 | 838 | } |
| 752 | 839 | return $source; |
| 753 | 840 | } |
| 841 | + |
|
| 842 | + /** |
|
| 843 | + * @param string $message |
|
| 844 | + */ |
|
| 754 | 845 | private function addLink($message) |
| 755 | 846 | { |
| 756 | 847 | $baseUrl='http://pradosoft.github.io/docs/manual/class-'; |
@@ -772,6 +863,10 @@ discard block |
||
| 772 | 863 | { |
| 773 | 864 | return $this->_r; |
| 774 | 865 | } |
| 866 | + |
|
| 867 | + /** |
|
| 868 | + * @param boolean $value |
|
| 869 | + */ |
|
| 775 | 870 | protected function setReadOnly($value) |
| 776 | 871 | { |
| 777 | 872 | $this->_r=TPropertyValue::ensureBoolean($value); |
@@ -1018,9 +1113,27 @@ discard block |
||
| 1018 | 1113 | { |
| 1019 | 1114 | throw new TNotSupportedException('cache_flush_unsupported'); |
| 1020 | 1115 | } |
| 1116 | + |
|
| 1117 | + /** |
|
| 1118 | + * @param string $key |
|
| 1119 | + */ |
|
| 1021 | 1120 | abstract protected function getValue($key); |
| 1121 | + |
|
| 1122 | + /** |
|
| 1123 | + * @param string $key |
|
| 1124 | + * @param integer $expire |
|
| 1125 | + */ |
|
| 1022 | 1126 | abstract protected function setValue($key,$value,$expire); |
| 1127 | + |
|
| 1128 | + /** |
|
| 1129 | + * @param string $key |
|
| 1130 | + * @param integer $expire |
|
| 1131 | + */ |
|
| 1023 | 1132 | abstract protected function addValue($key,$value,$expire); |
| 1133 | + |
|
| 1134 | + /** |
|
| 1135 | + * @param string $key |
|
| 1136 | + */ |
|
| 1024 | 1137 | abstract protected function deleteValue($key); |
| 1025 | 1138 | public function offsetExists($id) |
| 1026 | 1139 | { |
@@ -1109,14 +1222,26 @@ discard block |
||
| 1109 | 1222 | { |
| 1110 | 1223 | return $this->generateTimestamps($this->_directory)!=$this->_timestamps; |
| 1111 | 1224 | } |
| 1225 | + |
|
| 1226 | + /** |
|
| 1227 | + * @param string $fileName |
|
| 1228 | + */ |
|
| 1112 | 1229 | protected function validateFile($fileName) |
| 1113 | 1230 | { |
| 1114 | 1231 | return true; |
| 1115 | 1232 | } |
| 1233 | + |
|
| 1234 | + /** |
|
| 1235 | + * @param string $directory |
|
| 1236 | + */ |
|
| 1116 | 1237 | protected function validateDirectory($directory) |
| 1117 | 1238 | { |
| 1118 | 1239 | return true; |
| 1119 | 1240 | } |
| 1241 | + |
|
| 1242 | + /** |
|
| 1243 | + * @param string $directory |
|
| 1244 | + */ |
|
| 1120 | 1245 | protected function generateTimestamps($directory,$level=0) |
| 1121 | 1246 | { |
| 1122 | 1247 | if(($dir=opendir($directory))===false) |
@@ -1207,6 +1332,10 @@ discard block |
||
| 1207 | 1332 | $this->_str=''; |
| 1208 | 1333 | return $str; |
| 1209 | 1334 | } |
| 1335 | + |
|
| 1336 | + /** |
|
| 1337 | + * @param string $str |
|
| 1338 | + */ |
|
| 1210 | 1339 | public function write($str) |
| 1211 | 1340 | { |
| 1212 | 1341 | $this->_str.=$str; |
@@ -1254,6 +1383,10 @@ discard block |
||
| 1254 | 1383 | { |
| 1255 | 1384 | return $this->_dp; |
| 1256 | 1385 | } |
| 1386 | + |
|
| 1387 | + /** |
|
| 1388 | + * @param integer $value |
|
| 1389 | + */ |
|
| 1257 | 1390 | protected function setDefaultPriority($value) |
| 1258 | 1391 | { |
| 1259 | 1392 | $this->_dp=(string)round(TPropertyValue::ensureFloat($value),$this->_p); |
@@ -1262,6 +1395,10 @@ discard block |
||
| 1262 | 1395 | { |
| 1263 | 1396 | return $this->_p; |
| 1264 | 1397 | } |
| 1398 | + |
|
| 1399 | + /** |
|
| 1400 | + * @param integer $value |
|
| 1401 | + */ |
|
| 1265 | 1402 | protected function setPrecision($value) |
| 1266 | 1403 | { |
| 1267 | 1404 | $this->_p=TPropertyValue::ensureInteger($value); |
@@ -1500,6 +1637,10 @@ discard block |
||
| 1500 | 1637 | $this->sortPriorities(); |
| 1501 | 1638 | return $this->_d; |
| 1502 | 1639 | } |
| 1640 | + |
|
| 1641 | + /** |
|
| 1642 | + * @param integer $priority |
|
| 1643 | + */ |
|
| 1503 | 1644 | public function toArrayBelowPriority($priority,$inclusive=false) |
| 1504 | 1645 | { |
| 1505 | 1646 | $this->sortPriorities(); |
@@ -1512,6 +1653,10 @@ discard block |
||
| 1512 | 1653 | } |
| 1513 | 1654 | return $items; |
| 1514 | 1655 | } |
| 1656 | + |
|
| 1657 | + /** |
|
| 1658 | + * @param integer $priority |
|
| 1659 | + */ |
|
| 1515 | 1660 | public function toArrayAbovePriority($priority,$inclusive=true) |
| 1516 | 1661 | { |
| 1517 | 1662 | $this->sortPriorities(); |
@@ -1609,6 +1754,10 @@ discard block |
||
| 1609 | 1754 | { |
| 1610 | 1755 | return $this->_r; |
| 1611 | 1756 | } |
| 1757 | + |
|
| 1758 | + /** |
|
| 1759 | + * @param boolean $value |
|
| 1760 | + */ |
|
| 1612 | 1761 | protected function setReadOnly($value) |
| 1613 | 1762 | { |
| 1614 | 1763 | $this->_r=TPropertyValue::ensureBoolean($value); |
@@ -1681,6 +1830,10 @@ discard block |
||
| 1681 | 1830 | else if($data!==null) |
| 1682 | 1831 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
| 1683 | 1832 | } |
| 1833 | + |
|
| 1834 | + /** |
|
| 1835 | + * @param TMap $data |
|
| 1836 | + */ |
|
| 1684 | 1837 | public function mergeWith($data) |
| 1685 | 1838 | { |
| 1686 | 1839 | if(is_array($data) || $data instanceof Traversable) |
@@ -1732,6 +1885,10 @@ discard block |
||
| 1732 | 1885 | { |
| 1733 | 1886 | return $this->_r; |
| 1734 | 1887 | } |
| 1888 | + |
|
| 1889 | + /** |
|
| 1890 | + * @param boolean $value |
|
| 1891 | + */ |
|
| 1735 | 1892 | protected function setReadOnly($value) |
| 1736 | 1893 | { |
| 1737 | 1894 | $this->_r=TPropertyValue::ensureBoolean($value); |
@@ -1740,6 +1897,10 @@ discard block |
||
| 1740 | 1897 | { |
| 1741 | 1898 | return $this->_dp; |
| 1742 | 1899 | } |
| 1900 | + |
|
| 1901 | + /** |
|
| 1902 | + * @param integer $value |
|
| 1903 | + */ |
|
| 1743 | 1904 | protected function setDefaultPriority($value) |
| 1744 | 1905 | { |
| 1745 | 1906 | $this->_dp = (string)round(TPropertyValue::ensureFloat($value), $this->_p); |
@@ -1748,6 +1909,10 @@ discard block |
||
| 1748 | 1909 | { |
| 1749 | 1910 | return $this->_p; |
| 1750 | 1911 | } |
| 1912 | + |
|
| 1913 | + /** |
|
| 1914 | + * @param integer $value |
|
| 1915 | + */ |
|
| 1751 | 1916 | protected function setPrecision($value) |
| 1752 | 1917 | { |
| 1753 | 1918 | $this->_p=TPropertyValue::ensureInteger($value); |
@@ -2133,6 +2298,10 @@ discard block |
||
| 2133 | 2298 | { |
| 2134 | 2299 | return $this->_parent; |
| 2135 | 2300 | } |
| 2301 | + |
|
| 2302 | + /** |
|
| 2303 | + * @param TXmlElement|null $parent |
|
| 2304 | + */ |
|
| 2136 | 2305 | public function setParent($parent) |
| 2137 | 2306 | { |
| 2138 | 2307 | $this->_parent=$parent; |
@@ -2194,6 +2363,10 @@ discard block |
||
| 2194 | 2363 | } |
| 2195 | 2364 | return null; |
| 2196 | 2365 | } |
| 2366 | + |
|
| 2367 | + /** |
|
| 2368 | + * @param string $tagName |
|
| 2369 | + */ |
|
| 2197 | 2370 | public function getElementsByTagName($tagName) |
| 2198 | 2371 | { |
| 2199 | 2372 | $list=new TList; |
@@ -2263,6 +2436,10 @@ discard block |
||
| 2263 | 2436 | { |
| 2264 | 2437 | return $this->_version; |
| 2265 | 2438 | } |
| 2439 | + |
|
| 2440 | + /** |
|
| 2441 | + * @param string $version |
|
| 2442 | + */ |
|
| 2266 | 2443 | public function setVersion($version) |
| 2267 | 2444 | { |
| 2268 | 2445 | $this->_version=$version; |
@@ -2271,6 +2448,10 @@ discard block |
||
| 2271 | 2448 | { |
| 2272 | 2449 | return $this->_encoding; |
| 2273 | 2450 | } |
| 2451 | + |
|
| 2452 | + /** |
|
| 2453 | + * @param string $encoding |
|
| 2454 | + */ |
|
| 2274 | 2455 | public function setEncoding($encoding) |
| 2275 | 2456 | { |
| 2276 | 2457 | $this->_encoding=$encoding; |
@@ -2499,10 +2680,18 @@ discard block |
||
| 2499 | 2680 | } |
| 2500 | 2681 | return 0; |
| 2501 | 2682 | } |
| 2683 | + |
|
| 2684 | + /** |
|
| 2685 | + * @param IUser $user |
|
| 2686 | + */ |
|
| 2502 | 2687 | private function isUserMatched($user) |
| 2503 | 2688 | { |
| 2504 | 2689 | return ($this->_everyone || ($this->_guest && $user->getIsGuest()) || ($this->_authenticated && !$user->getIsGuest()) || in_array(strtolower($user->getName()),$this->_users)); |
| 2505 | 2690 | } |
| 2691 | + |
|
| 2692 | + /** |
|
| 2693 | + * @param IUser $user |
|
| 2694 | + */ |
|
| 2506 | 2695 | private function isRoleMatched($user) |
| 2507 | 2696 | { |
| 2508 | 2697 | foreach($this->_roles as $role) |
@@ -2519,6 +2708,11 @@ discard block |
||
| 2519 | 2708 | } |
| 2520 | 2709 | class TAuthorizationRuleCollection extends TList |
| 2521 | 2710 | { |
| 2711 | + /** |
|
| 2712 | + * @param IUser $user |
|
| 2713 | + * @param string $verb |
|
| 2714 | + * @param string $ip |
|
| 2715 | + */ |
|
| 2522 | 2716 | public function isUserAllowed($user,$verb,$ip) |
| 2523 | 2717 | { |
| 2524 | 2718 | if($user instanceof IUser) |
@@ -2626,6 +2820,10 @@ discard block |
||
| 2626 | 2820 | { |
| 2627 | 2821 | $this->_cryptAlgorithm = $value; |
| 2628 | 2822 | } |
| 2823 | + |
|
| 2824 | + /** |
|
| 2825 | + * @param string $data |
|
| 2826 | + */ |
|
| 2629 | 2827 | public function encrypt($data) |
| 2630 | 2828 | { |
| 2631 | 2829 | $module=$this->openCryptModule(); |
@@ -2638,6 +2836,10 @@ discard block |
||
| 2638 | 2836 | mcrypt_module_close($module); |
| 2639 | 2837 | return $encrypted; |
| 2640 | 2838 | } |
| 2839 | + |
|
| 2840 | + /** |
|
| 2841 | + * @param string $data |
|
| 2842 | + */ |
|
| 2641 | 2843 | public function decrypt($data) |
| 2642 | 2844 | { |
| 2643 | 2845 | $module=$this->openCryptModule(); |
@@ -2699,6 +2901,11 @@ discard block |
||
| 2699 | 2901 | { |
| 2700 | 2902 | return $this->_mbstring ? mb_strlen($string,'8bit') : strlen($string); |
| 2701 | 2903 | } |
| 2904 | + |
|
| 2905 | + /** |
|
| 2906 | + * @param integer $start |
|
| 2907 | + * @param integer $length |
|
| 2908 | + */ |
|
| 2702 | 2909 | private function substr($string,$start,$length) |
| 2703 | 2910 | { |
| 2704 | 2911 | return $this->_mbstring ? mb_substr($string,$start,$length,'8bit') : substr($string,$start,$length); |
@@ -2858,6 +3065,10 @@ discard block |
||
| 2858 | 3065 | self::checkJsonError(); |
| 2859 | 3066 | return $s; |
| 2860 | 3067 | } |
| 3068 | + |
|
| 3069 | + /** |
|
| 3070 | + * @param string $sourceEncoding |
|
| 3071 | + */ |
|
| 2861 | 3072 | private static function convertToUtf8(&$value, $sourceEncoding) { |
| 2862 | 3073 | if(is_string($value)) |
| 2863 | 3074 | $value=iconv($sourceEncoding, 'UTF-8', $value); |
@@ -2867,6 +3078,10 @@ discard block |
||
| 2867 | 3078 | self::convertToUtf8($element, $sourceEncoding); |
| 2868 | 3079 | } |
| 2869 | 3080 | } |
| 3081 | + |
|
| 3082 | + /** |
|
| 3083 | + * @param string $value |
|
| 3084 | + */ |
|
| 2870 | 3085 | public static function jsonDecode($value, $assoc = false, $depth = 512) |
| 2871 | 3086 | { |
| 2872 | 3087 | $s= @json_decode($value, $assoc, $depth); |
@@ -2901,6 +3116,10 @@ discard block |
||
| 2901 | 3116 | } |
| 2902 | 3117 | throw new Exception("JSON error ($err): $msg"); |
| 2903 | 3118 | } |
| 3119 | + |
|
| 3120 | + /** |
|
| 3121 | + * @param string $code |
|
| 3122 | + */ |
|
| 2904 | 3123 | public static function JSMin($code) |
| 2905 | 3124 | { |
| 2906 | 3125 | Prado::using('System.Web.Javascripts.JSMin'); |
@@ -3088,6 +3307,10 @@ discard block |
||
| 3088 | 3307 | { |
| 3089 | 3308 | return $this->getID(); |
| 3090 | 3309 | } |
| 3310 | + |
|
| 3311 | + /** |
|
| 3312 | + * @param TUrlManager $manager |
|
| 3313 | + */ |
|
| 3091 | 3314 | protected function cacheUrlManager($manager) |
| 3092 | 3315 | { |
| 3093 | 3316 | if($this->getEnableCache()) |
@@ -3337,6 +3560,10 @@ discard block |
||
| 3337 | 3560 | { |
| 3338 | 3561 | return $_ENV; |
| 3339 | 3562 | } |
| 3563 | + |
|
| 3564 | + /** |
|
| 3565 | + * @param string $serviceID |
|
| 3566 | + */ |
|
| 3340 | 3567 | public function constructUrl($serviceID,$serviceParam,$getItems=null,$encodeAmpersand=true,$encodeGetItems=true) |
| 3341 | 3568 | { |
| 3342 | 3569 | if ($this->_cookieOnly===null) |
@@ -3457,6 +3684,10 @@ discard block |
||
| 3457 | 3684 | class THttpCookieCollection extends TList |
| 3458 | 3685 | { |
| 3459 | 3686 | private $_o; |
| 3687 | + |
|
| 3688 | + /** |
|
| 3689 | + * @param THttpResponse $owner |
|
| 3690 | + */ |
|
| 3460 | 3691 | public function __construct($owner=null) |
| 3461 | 3692 | { |
| 3462 | 3693 | $this->_o=$owner; |
@@ -3520,6 +3751,10 @@ discard block |
||
| 3520 | 3751 | { |
| 3521 | 3752 | return $this->_expire; |
| 3522 | 3753 | } |
| 3754 | + |
|
| 3755 | + /** |
|
| 3756 | + * @param integer $value |
|
| 3757 | + */ |
|
| 3523 | 3758 | public function setExpire($value) |
| 3524 | 3759 | { |
| 3525 | 3760 | $this->_expire=TPropertyValue::ensureInteger($value); |
@@ -3586,6 +3821,10 @@ discard block |
||
| 3586 | 3821 | private $_query; |
| 3587 | 3822 | private $_fragment; |
| 3588 | 3823 | private $_uri; |
| 3824 | + |
|
| 3825 | + /** |
|
| 3826 | + * @param string $uri |
|
| 3827 | + */ |
|
| 3589 | 3828 | public function __construct($uri) |
| 3590 | 3829 | { |
| 3591 | 3830 | if(($ret=@parse_url($uri))!==false) |
@@ -3651,6 +3890,10 @@ discard block |
||
| 3651 | 3890 | class THttpResponseAdapter extends TApplicationComponent |
| 3652 | 3891 | { |
| 3653 | 3892 | private $_response; |
| 3893 | + |
|
| 3894 | + /** |
|
| 3895 | + * @param THttpResponse $response |
|
| 3896 | + */ |
|
| 3654 | 3897 | public function __construct($response) |
| 3655 | 3898 | { |
| 3656 | 3899 | $this->_response=$response; |
@@ -3746,6 +3989,10 @@ discard block |
||
| 3746 | 3989 | { |
| 3747 | 3990 | return $this->_charset; |
| 3748 | 3991 | } |
| 3992 | + |
|
| 3993 | + /** |
|
| 3994 | + * @param string $charset |
|
| 3995 | + */ |
|
| 3749 | 3996 | public function setCharset($charset) |
| 3750 | 3997 | { |
| 3751 | 3998 | $this->_charset = (strToLower($charset) === 'false') ? false : (string)$charset; |
@@ -3969,6 +4216,10 @@ discard block |
||
| 3969 | 4216 | return array_change_key_case($result, $case); |
| 3970 | 4217 | return $result; |
| 3971 | 4218 | } |
| 4219 | + |
|
| 4220 | + /** |
|
| 4221 | + * @param string $value |
|
| 4222 | + */ |
|
| 3972 | 4223 | public function appendHeader($value, $replace=true) |
| 3973 | 4224 | { |
| 3974 | 4225 | header($value, $replace); |
@@ -3977,6 +4228,10 @@ discard block |
||
| 3977 | 4228 | { |
| 3978 | 4229 | error_log($message,$messageType,$destination,$extraHeaders); |
| 3979 | 4230 | } |
| 4231 | + |
|
| 4232 | + /** |
|
| 4233 | + * @param THttpCookie $cookie |
|
| 4234 | + */ |
|
| 3980 | 4235 | public function addCookie($cookie) |
| 3981 | 4236 | { |
| 3982 | 4237 | $request=$this->getRequest(); |
@@ -4034,6 +4289,10 @@ discard block |
||
| 4034 | 4289 | else |
| 4035 | 4290 | return $this->createNewHtmlWriter($type, $this); |
| 4036 | 4291 | } |
| 4292 | + |
|
| 4293 | + /** |
|
| 4294 | + * @param THttpResponse $writer |
|
| 4295 | + */ |
|
| 4037 | 4296 | public function createNewHtmlWriter($type, $writer) |
| 4038 | 4297 | { |
| 4039 | 4298 | return Prado::createComponent($type, $writer); |
@@ -4143,6 +4402,10 @@ discard block |
||
| 4143 | 4402 | { |
| 4144 | 4403 | return $this->_customStorage; |
| 4145 | 4404 | } |
| 4405 | + |
|
| 4406 | + /** |
|
| 4407 | + * @param boolean $value |
|
| 4408 | + */ |
|
| 4146 | 4409 | public function setUseCustomStorage($value) |
| 4147 | 4410 | { |
| 4148 | 4411 | $this->_customStorage=TPropertyValue::ensureBoolean($value); |
@@ -4285,10 +4548,18 @@ discard block |
||
| 4285 | 4548 | { |
| 4286 | 4549 | return array_keys($_SESSION); |
| 4287 | 4550 | } |
| 4551 | + |
|
| 4552 | + /** |
|
| 4553 | + * @param string $key |
|
| 4554 | + */ |
|
| 4288 | 4555 | public function itemAt($key) |
| 4289 | 4556 | { |
| 4290 | 4557 | return isset($_SESSION[$key]) ? $_SESSION[$key] : null; |
| 4291 | 4558 | } |
| 4559 | + |
|
| 4560 | + /** |
|
| 4561 | + * @param string $key |
|
| 4562 | + */ |
|
| 4292 | 4563 | public function add($key,$value) |
| 4293 | 4564 | { |
| 4294 | 4565 | $_SESSION[$key]=$value; |
@@ -4395,6 +4666,10 @@ discard block |
||
| 4395 | 4666 | { |
| 4396 | 4667 | return $this->_caseSensitive; |
| 4397 | 4668 | } |
| 4669 | + |
|
| 4670 | + /** |
|
| 4671 | + * @param boolean $value |
|
| 4672 | + */ |
|
| 4398 | 4673 | public function setCaseSensitive($value) |
| 4399 | 4674 | { |
| 4400 | 4675 | $this->_caseSensitive=TPropertyValue::ensureBoolean($value); |
@@ -4407,6 +4682,10 @@ discard block |
||
| 4407 | 4682 | { |
| 4408 | 4683 | parent::add($this->_caseSensitive?$key:strtolower($key),$value); |
| 4409 | 4684 | } |
| 4685 | + |
|
| 4686 | + /** |
|
| 4687 | + * @param string $key |
|
| 4688 | + */ |
|
| 4410 | 4689 | public function remove($key) |
| 4411 | 4690 | { |
| 4412 | 4691 | return parent::remove($this->_caseSensitive?$key:strtolower($key)); |
@@ -4557,6 +4836,10 @@ discard block |
||
| 4557 | 4836 | } |
| 4558 | 4837 | return $this->_page; |
| 4559 | 4838 | } |
| 4839 | + |
|
| 4840 | + /** |
|
| 4841 | + * @param TPage $page |
|
| 4842 | + */ |
|
| 4560 | 4843 | public function setPage($page) |
| 4561 | 4844 | { |
| 4562 | 4845 | $this->_page=$page; |
@@ -4700,6 +4983,10 @@ discard block |
||
| 4700 | 4983 | else |
| 4701 | 4984 | return $this->getViewState('Visible',true); |
| 4702 | 4985 | } |
| 4986 | + |
|
| 4987 | + /** |
|
| 4988 | + * @param boolean $value |
|
| 4989 | + */ |
|
| 4703 | 4990 | public function setVisible($value) |
| 4704 | 4991 | { |
| 4705 | 4992 | $this->setViewState('Visible',TPropertyValue::ensureBoolean($value),true); |
@@ -4738,6 +5025,10 @@ discard block |
||
| 4738 | 5025 | return $attributes; |
| 4739 | 5026 | } |
| 4740 | 5027 | } |
| 5028 | + |
|
| 5029 | + /** |
|
| 5030 | + * @param string $name |
|
| 5031 | + */ |
|
| 4741 | 5032 | public function hasAttribute($name) |
| 4742 | 5033 | { |
| 4743 | 5034 | if($attributes=$this->getViewState('Attributes',null)) |
@@ -4745,6 +5036,10 @@ discard block |
||
| 4745 | 5036 | else |
| 4746 | 5037 | return false; |
| 4747 | 5038 | } |
| 5039 | + |
|
| 5040 | + /** |
|
| 5041 | + * @param string $name |
|
| 5042 | + */ |
|
| 4748 | 5043 | public function getAttribute($name) |
| 4749 | 5044 | { |
| 4750 | 5045 | if($attributes=$this->getViewState('Attributes',null)) |
@@ -4752,6 +5047,10 @@ discard block |
||
| 4752 | 5047 | else |
| 4753 | 5048 | return null; |
| 4754 | 5049 | } |
| 5050 | + |
|
| 5051 | + /** |
|
| 5052 | + * @param string $name |
|
| 5053 | + */ |
|
| 4755 | 5054 | public function setAttribute($name,$value) |
| 4756 | 5055 | { |
| 4757 | 5056 | $this->getAttributes()->add($name,$value); |
@@ -4775,6 +5074,10 @@ discard block |
||
| 4775 | 5074 | else |
| 4776 | 5075 | return !($this->_flags & self::IS_DISABLE_VIEWSTATE); |
| 4777 | 5076 | } |
| 5077 | + |
|
| 5078 | + /** |
|
| 5079 | + * @param boolean $value |
|
| 5080 | + */ |
|
| 4778 | 5081 | public function setEnableViewState($value) |
| 4779 | 5082 | { |
| 4780 | 5083 | if(TPropertyValue::ensureBoolean($value)) |
@@ -4782,10 +5085,20 @@ discard block |
||
| 4782 | 5085 | else |
| 4783 | 5086 | $this->_flags |= self::IS_DISABLE_VIEWSTATE; |
| 4784 | 5087 | } |
| 5088 | + |
|
| 5089 | + /** |
|
| 5090 | + * @param string $key |
|
| 5091 | + * @param integer $defaultValue |
|
| 5092 | + */ |
|
| 4785 | 5093 | protected function getControlState($key,$defaultValue=null) |
| 4786 | 5094 | { |
| 4787 | 5095 | return isset($this->_rf[self::RF_CONTROLSTATE][$key])?$this->_rf[self::RF_CONTROLSTATE][$key]:$defaultValue; |
| 4788 | 5096 | } |
| 5097 | + |
|
| 5098 | + /** |
|
| 5099 | + * @param string $key |
|
| 5100 | + * @param integer $defaultValue |
|
| 5101 | + */ |
|
| 4789 | 5102 | protected function setControlState($key,$value,$defaultValue=null) |
| 4790 | 5103 | { |
| 4791 | 5104 | if($value===$defaultValue) |
@@ -4797,6 +5110,10 @@ discard block |
||
| 4797 | 5110 | { |
| 4798 | 5111 | unset($this->_rf[self::RF_CONTROLSTATE][$key]); |
| 4799 | 5112 | } |
| 5113 | + |
|
| 5114 | + /** |
|
| 5115 | + * @param boolean $enabled |
|
| 5116 | + */ |
|
| 4800 | 5117 | public function trackViewState($enabled) |
| 4801 | 5118 | { |
| 4802 | 5119 | $this->_trackViewState=TPropertyValue::ensureBoolean($enabled); |
@@ -4814,6 +5131,10 @@ discard block |
||
| 4814 | 5131 | else |
| 4815 | 5132 | return $defaultValue; |
| 4816 | 5133 | } |
| 5134 | + |
|
| 5135 | + /** |
|
| 5136 | + * @param string $key |
|
| 5137 | + */ |
|
| 4817 | 5138 | public function setViewState($key,$value,$defaultValue=null) |
| 4818 | 5139 | { |
| 4819 | 5140 | if($this->_trackViewState) |
@@ -4833,6 +5154,10 @@ discard block |
||
| 4833 | 5154 | $this->_tempState[$key]=$value; |
| 4834 | 5155 | } |
| 4835 | 5156 | } |
| 5157 | + |
|
| 5158 | + /** |
|
| 5159 | + * @param string $key |
|
| 5160 | + */ |
|
| 4836 | 5161 | public function clearViewState($key) |
| 4837 | 5162 | { |
| 4838 | 5163 | unset($this->_viewState[$key]); |
@@ -4889,6 +5214,10 @@ discard block |
||
| 4889 | 5214 | { |
| 4890 | 5215 | return ($this->_flags & self::IS_CHILD_CREATED)!==0; |
| 4891 | 5216 | } |
| 5217 | + |
|
| 5218 | + /** |
|
| 5219 | + * @param boolean $value |
|
| 5220 | + */ |
|
| 4892 | 5221 | final protected function setChildControlsCreated($value) |
| 4893 | 5222 | { |
| 4894 | 5223 | if($value) |
@@ -4948,6 +5277,10 @@ discard block |
||
| 4948 | 5277 | return null; |
| 4949 | 5278 | } |
| 4950 | 5279 | } |
| 5280 | + |
|
| 5281 | + /** |
|
| 5282 | + * @param string $type |
|
| 5283 | + */ |
|
| 4951 | 5284 | public function findControlsByType($type,$strict=true) |
| 4952 | 5285 | { |
| 4953 | 5286 | $controls=array(); |
@@ -4985,6 +5318,10 @@ discard block |
||
| 4985 | 5318 | unset($this->_rf[self::RF_NAMED_CONTROLS_ID]); |
| 4986 | 5319 | $this->clearNameTable(); |
| 4987 | 5320 | } |
| 5321 | + |
|
| 5322 | + /** |
|
| 5323 | + * @param TCheckBox $object |
|
| 5324 | + */ |
|
| 4988 | 5325 | public function registerObject($name,$object) |
| 4989 | 5326 | { |
| 4990 | 5327 | if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
@@ -5019,6 +5356,10 @@ discard block |
||
| 5019 | 5356 | { |
| 5020 | 5357 | return $this->getControlStage() >= self::CS_PRERENDERED; |
| 5021 | 5358 | } |
| 5359 | + |
|
| 5360 | + /** |
|
| 5361 | + * @param string $name |
|
| 5362 | + */ |
|
| 5022 | 5363 | public function getRegisteredObject($name) |
| 5023 | 5364 | { |
| 5024 | 5365 | return isset($this->_rf[self::RF_NAMED_OBJECTS][$name])?$this->_rf[self::RF_NAMED_OBJECTS][$name]:null; |
@@ -5042,6 +5383,10 @@ discard block |
||
| 5042 | 5383 | $control=$control->_parent; |
| 5043 | 5384 | return $control===$ancestor; |
| 5044 | 5385 | } |
| 5386 | + |
|
| 5387 | + /** |
|
| 5388 | + * @param TControl $control |
|
| 5389 | + */ |
|
| 5045 | 5390 | public function addedControl($control) |
| 5046 | 5391 | { |
| 5047 | 5392 | if($control->_parent) |
@@ -5080,6 +5425,10 @@ discard block |
||
| 5080 | 5425 | } |
| 5081 | 5426 | } |
| 5082 | 5427 | } |
| 5428 | + |
|
| 5429 | + /** |
|
| 5430 | + * @param TControl $control |
|
| 5431 | + */ |
|
| 5083 | 5432 | public function removedControl($control) |
| 5084 | 5433 | { |
| 5085 | 5434 | if($this->_namingContainer) |
@@ -5225,6 +5574,10 @@ discard block |
||
| 5225 | 5574 | $rootControl=(($page=$this->getPage())===null)?$this:$page; |
| 5226 | 5575 | $rootControl->broadcastEventInternal($name,$sender,new TBroadcastEventParameter($name,$param)); |
| 5227 | 5576 | } |
| 5577 | + |
|
| 5578 | + /** |
|
| 5579 | + * @param TBroadcastEventParameter $param |
|
| 5580 | + */ |
|
| 5228 | 5581 | private function broadcastEventInternal($name,$sender,$param) |
| 5229 | 5582 | { |
| 5230 | 5583 | if($this->hasEvent($name)) |
@@ -5370,6 +5723,10 @@ discard block |
||
| 5370 | 5723 | else if($this->_flags & self::IS_STYLESHEET_APPLIED) |
| 5371 | 5724 | throw new TInvalidOperationException('control_stylesheet_applied',get_class($this)); |
| 5372 | 5725 | } |
| 5726 | + |
|
| 5727 | + /** |
|
| 5728 | + * @param boolean $recursive |
|
| 5729 | + */ |
|
| 5373 | 5730 | private function clearCachedUniqueID($recursive) |
| 5374 | 5731 | { |
| 5375 | 5732 | if($recursive && $this->_uid!==null && isset($this->_rf[self::RF_CONTROLS])) |
@@ -5393,6 +5750,10 @@ discard block |
||
| 5393 | 5750 | { |
| 5394 | 5751 | unset($this->_rf[self::RF_NAMED_CONTROLS]); |
| 5395 | 5752 | } |
| 5753 | + |
|
| 5754 | + /** |
|
| 5755 | + * @param TControl $container |
|
| 5756 | + */ |
|
| 5396 | 5757 | private function fillNameTable($container,$controls) |
| 5397 | 5758 | { |
| 5398 | 5759 | foreach($controls as $control) |
@@ -5465,11 +5826,18 @@ discard block |
||
| 5465 | 5826 | } |
| 5466 | 5827 | interface IPostBackEventHandler |
| 5467 | 5828 | { |
| 5829 | + /** |
|
| 5830 | + * @return void |
|
| 5831 | + */ |
|
| 5468 | 5832 | public function raisePostBackEvent($param); |
| 5469 | 5833 | } |
| 5470 | 5834 | interface IPostBackDataHandler |
| 5471 | 5835 | { |
| 5472 | 5836 | public function loadPostData($key,$values); |
| 5837 | + |
|
| 5838 | + /** |
|
| 5839 | + * @return void |
|
| 5840 | + */ |
|
| 5473 | 5841 | public function raisePostDataChangedEvent(); |
| 5474 | 5842 | public function getDataChanged(); |
| 5475 | 5843 | } |
@@ -5477,8 +5845,16 @@ discard block |
||
| 5477 | 5845 | { |
| 5478 | 5846 | public function validate(); |
| 5479 | 5847 | public function getIsValid(); |
| 5848 | + |
|
| 5849 | + /** |
|
| 5850 | + * @return void |
|
| 5851 | + */ |
|
| 5480 | 5852 | public function setIsValid($value); |
| 5481 | 5853 | public function getErrorMessage(); |
| 5854 | + |
|
| 5855 | + /** |
|
| 5856 | + * @return void |
|
| 5857 | + */ |
|
| 5482 | 5858 | public function setErrorMessage($value); |
| 5483 | 5859 | } |
| 5484 | 5860 | interface IValidatable |
@@ -5493,26 +5869,66 @@ discard block |
||
| 5493 | 5869 | } |
| 5494 | 5870 | interface ITheme |
| 5495 | 5871 | { |
| 5872 | + /** |
|
| 5873 | + * @return boolean |
|
| 5874 | + */ |
|
| 5496 | 5875 | public function applySkin($control); |
| 5497 | 5876 | } |
| 5498 | 5877 | interface ITemplate |
| 5499 | 5878 | { |
| 5879 | + /** |
|
| 5880 | + * @return void |
|
| 5881 | + */ |
|
| 5500 | 5882 | public function instantiateIn($parent); |
| 5501 | 5883 | } |
| 5502 | 5884 | interface IButtonControl |
| 5503 | 5885 | { |
| 5504 | 5886 | public function getText(); |
| 5887 | + |
|
| 5888 | + /** |
|
| 5889 | + * @param string $value |
|
| 5890 | + * |
|
| 5891 | + * @return void |
|
| 5892 | + */ |
|
| 5505 | 5893 | public function setText($value); |
| 5506 | 5894 | public function getCausesValidation(); |
| 5895 | + |
|
| 5896 | + /** |
|
| 5897 | + * @return void |
|
| 5898 | + */ |
|
| 5507 | 5899 | public function setCausesValidation($value); |
| 5508 | 5900 | public function getCommandName(); |
| 5901 | + |
|
| 5902 | + /** |
|
| 5903 | + * @return void |
|
| 5904 | + */ |
|
| 5509 | 5905 | public function setCommandName($value); |
| 5510 | 5906 | public function getCommandParameter(); |
| 5907 | + |
|
| 5908 | + /** |
|
| 5909 | + * @return void |
|
| 5910 | + */ |
|
| 5511 | 5911 | public function setCommandParameter($value); |
| 5512 | 5912 | public function getValidationGroup(); |
| 5913 | + |
|
| 5914 | + /** |
|
| 5915 | + * @return void |
|
| 5916 | + */ |
|
| 5513 | 5917 | public function setValidationGroup($value); |
| 5918 | + |
|
| 5919 | + /** |
|
| 5920 | + * @return void |
|
| 5921 | + */ |
|
| 5514 | 5922 | public function onClick($param); |
| 5923 | + |
|
| 5924 | + /** |
|
| 5925 | + * @return void |
|
| 5926 | + */ |
|
| 5515 | 5927 | public function onCommand($param); |
| 5928 | + |
|
| 5929 | + /** |
|
| 5930 | + * @return void |
|
| 5931 | + */ |
|
| 5516 | 5932 | public function setIsDefaultButton($value); |
| 5517 | 5933 | public function getIsDefaultButton(); |
| 5518 | 5934 | } |
@@ -5970,6 +6386,10 @@ discard block |
||
| 5970 | 6386 | { |
| 5971 | 6387 | return $this->_customStyle===null?'':$this->_customStyle; |
| 5972 | 6388 | } |
| 6389 | + |
|
| 6390 | + /** |
|
| 6391 | + * @param string $value |
|
| 6392 | + */ |
|
| 5973 | 6393 | public function setCustomStyle($value) |
| 5974 | 6394 | { |
| 5975 | 6395 | $this->_customStyle=$value; |
@@ -5978,6 +6398,11 @@ discard block |
||
| 5978 | 6398 | { |
| 5979 | 6399 | return isset($this->_fields[$name])?$this->_fields[$name]:''; |
| 5980 | 6400 | } |
| 6401 | + |
|
| 6402 | + /** |
|
| 6403 | + * @param string $name |
|
| 6404 | + * @param string $value |
|
| 6405 | + */ |
|
| 5981 | 6406 | public function setStyleField($name,$value) |
| 5982 | 6407 | { |
| 5983 | 6408 | $this->_fields[$name]=$value; |
@@ -6473,6 +6898,10 @@ discard block |
||
| 6473 | 6898 | { |
| 6474 | 6899 | private $_ensureid=false; |
| 6475 | 6900 | protected $_decorator; |
| 6901 | + |
|
| 6902 | + /** |
|
| 6903 | + * @param boolean $value |
|
| 6904 | + */ |
|
| 6476 | 6905 | public function setEnsureId($value) |
| 6477 | 6906 | { |
| 6478 | 6907 | $this->_ensureid |= TPropertyValue::ensureBoolean($value); |
@@ -6562,6 +6991,10 @@ discard block |
||
| 6562 | 6991 | else |
| 6563 | 6992 | return ''; |
| 6564 | 6993 | } |
| 6994 | + |
|
| 6995 | + /** |
|
| 6996 | + * @param string $value |
|
| 6997 | + */ |
|
| 6565 | 6998 | public function setForeColor($value) |
| 6566 | 6999 | { |
| 6567 | 7000 | $this->getStyle()->setForeColor($value); |
@@ -6592,6 +7025,10 @@ discard block |
||
| 6592 | 7025 | else |
| 6593 | 7026 | return ''; |
| 6594 | 7027 | } |
| 7028 | + |
|
| 7029 | + /** |
|
| 7030 | + * @param string $value |
|
| 7031 | + */ |
|
| 6595 | 7032 | public function setHeight($value) |
| 6596 | 7033 | { |
| 6597 | 7034 | $this->getStyle()->setHeight($value); |
@@ -6653,6 +7090,10 @@ discard block |
||
| 6653 | 7090 | else |
| 6654 | 7091 | return ''; |
| 6655 | 7092 | } |
| 7093 | + |
|
| 7094 | + /** |
|
| 7095 | + * @param string $value |
|
| 7096 | + */ |
|
| 6656 | 7097 | public function setWidth($value) |
| 6657 | 7098 | { |
| 6658 | 7099 | $this->getStyle()->setWidth($value); |
@@ -6780,6 +7221,10 @@ discard block |
||
| 6780 | 7221 | $tpl->instantiateIn($this); |
| 6781 | 7222 | } |
| 6782 | 7223 | } |
| 7224 | + |
|
| 7225 | + /** |
|
| 7226 | + * @param string $id |
|
| 7227 | + */ |
|
| 6783 | 7228 | public function registerContent($id,TContent $object) |
| 6784 | 7229 | { |
| 6785 | 7230 | if(isset($this->_contents[$id])) |
@@ -6787,6 +7232,10 @@ discard block |
||
| 6787 | 7232 | else |
| 6788 | 7233 | $this->_contents[$id]=$object; |
| 6789 | 7234 | } |
| 7235 | + |
|
| 7236 | + /** |
|
| 7237 | + * @param string $id |
|
| 7238 | + */ |
|
| 6790 | 7239 | public function registerContentPlaceHolder($id,TContentPlaceHolder $object) |
| 6791 | 7240 | { |
| 6792 | 7241 | if(isset($this->_placeholders[$id])) |
@@ -6983,6 +7432,10 @@ discard block |
||
| 6983 | 7432 | { |
| 6984 | 7433 | return $this->getViewState('Enctype',''); |
| 6985 | 7434 | } |
| 7435 | + |
|
| 7436 | + /** |
|
| 7437 | + * @param string $value |
|
| 7438 | + */ |
|
| 6986 | 7439 | public function setEnctype($value) |
| 6987 | 7440 | { |
| 6988 | 7441 | $this->setViewState('Enctype',$value,''); |
@@ -7102,6 +7555,10 @@ discard block |
||
| 7102 | 7555 | $scripts = array_unique($scripts); |
| 7103 | 7556 | return $scripts; |
| 7104 | 7557 | } |
| 7558 | + |
|
| 7559 | + /** |
|
| 7560 | + * @param string $base |
|
| 7561 | + */ |
|
| 7105 | 7562 | protected function getPackagePathUrl($base) |
| 7106 | 7563 | { |
| 7107 | 7564 | $assets = Prado::getApplication()->getAssetManager(); |
@@ -7251,6 +7708,11 @@ discard block |
||
| 7251 | 7708 | $params=func_get_args(); |
| 7252 | 7709 | $this->_page->registerCachingAction('Page.ClientScript','registerEndScript',$params); |
| 7253 | 7710 | } |
| 7711 | + |
|
| 7712 | + /** |
|
| 7713 | + * @param string $name |
|
| 7714 | + * @param string $value |
|
| 7715 | + */ |
|
| 7254 | 7716 | public function registerHiddenField($name,$value) |
| 7255 | 7717 | { |
| 7256 | 7718 | $this->_hiddenFields[$name]=$value; |
@@ -7388,6 +7850,10 @@ discard block |
||
| 7388 | 7850 | $this->renderAllPendingScriptFiles($writer); |
| 7389 | 7851 | } |
| 7390 | 7852 | } |
| 7853 | + |
|
| 7854 | + /** |
|
| 7855 | + * @param boolean $initial |
|
| 7856 | + */ |
|
| 7391 | 7857 | protected function renderHiddenFieldsInt($writer, $initial) |
| 7392 | 7858 | { |
| 7393 | 7859 | if ($initial) $this->_renderedHiddenFields = array(); |
@@ -7423,12 +7889,20 @@ discard block |
||
| 7423 | 7889 | abstract class TClientSideOptions extends TComponent |
| 7424 | 7890 | { |
| 7425 | 7891 | private $_options; |
| 7892 | + |
|
| 7893 | + /** |
|
| 7894 | + * @param string $name |
|
| 7895 | + */ |
|
| 7426 | 7896 | protected function setFunction($name, $code) |
| 7427 | 7897 | { |
| 7428 | 7898 | if(!TJavaScript::isJsLiteral($code)) |
| 7429 | 7899 | $code = TJavaScript::quoteJsLiteral($this->ensureFunction($code)); |
| 7430 | 7900 | $this->setOption($name, $code); |
| 7431 | 7901 | } |
| 7902 | + |
|
| 7903 | + /** |
|
| 7904 | + * @param string $name |
|
| 7905 | + */ |
|
| 7432 | 7906 | protected function getOption($name) |
| 7433 | 7907 | { |
| 7434 | 7908 | if ($this->_options) |
@@ -7551,6 +8025,10 @@ discard block |
||
| 7551 | 8025 | $this->renderControl($writer); |
| 7552 | 8026 | $this->unloadRecursive(); |
| 7553 | 8027 | } |
| 8028 | + |
|
| 8029 | + /** |
|
| 8030 | + * @param string $enc |
|
| 8031 | + */ |
|
| 7554 | 8032 | protected static function decodeUTF8($data, $enc) |
| 7555 | 8033 | { |
| 7556 | 8034 | if(is_array($data)) |
@@ -7633,6 +8111,10 @@ discard block |
||
| 7633 | 8111 | else |
| 7634 | 8112 | throw new TInvalidOperationException('page_form_duplicated'); |
| 7635 | 8113 | } |
| 8114 | + |
|
| 8115 | + /** |
|
| 8116 | + * @param string $validationGroup |
|
| 8117 | + */ |
|
| 7636 | 8118 | public function getValidators($validationGroup=null) |
| 7637 | 8119 | { |
| 7638 | 8120 | if(!$this->_validators) |
@@ -7703,6 +8185,10 @@ discard block |
||
| 7703 | 8185 | { |
| 7704 | 8186 | $this->_styleSheet=empty($value)?null:$value; |
| 7705 | 8187 | } |
| 8188 | + |
|
| 8189 | + /** |
|
| 8190 | + * @param TControl $control |
|
| 8191 | + */ |
|
| 7706 | 8192 | public function applyControlSkin($control) |
| 7707 | 8193 | { |
| 7708 | 8194 | if(($theme=$this->getTheme())!==null) |
@@ -7850,6 +8336,10 @@ discard block |
||
| 7850 | 8336 | { |
| 7851 | 8337 | $this->_postBackEventParameter=$value; |
| 7852 | 8338 | } |
| 8339 | + |
|
| 8340 | + /** |
|
| 8341 | + * @param boolean $beforeLoad |
|
| 8342 | + */ |
|
| 7853 | 8343 | protected function processPostData($postData,$beforeLoad) |
| 7854 | 8344 | { |
| 7855 | 8345 | $this->_isLoadingPostData=true; |
@@ -7938,6 +8428,10 @@ discard block |
||
| 7938 | 8428 | $this->getClientScript()->registerFocusControl($lastFocus); |
| 7939 | 8429 | $this->_inFormRender=false; |
| 7940 | 8430 | } |
| 8431 | + |
|
| 8432 | + /** |
|
| 8433 | + * @param TControl $value |
|
| 8434 | + */ |
|
| 7941 | 8435 | public function setFocus($value) |
| 7942 | 8436 | { |
| 7943 | 8437 | $this->_focus=$value; |
@@ -7983,6 +8477,10 @@ discard block |
||
| 7983 | 8477 | { |
| 7984 | 8478 | return $this->_clientState; |
| 7985 | 8479 | } |
| 8480 | + |
|
| 8481 | + /** |
|
| 8482 | + * @param string $state |
|
| 8483 | + */ |
|
| 7986 | 8484 | public function setClientState($state) |
| 7987 | 8485 | { |
| 7988 | 8486 | $this->_clientState=$state; |
@@ -8042,6 +8540,11 @@ discard block |
||
| 8042 | 8540 | { |
| 8043 | 8541 | $this->_pagePath=$value; |
| 8044 | 8542 | } |
| 8543 | + |
|
| 8544 | + /** |
|
| 8545 | + * @param string $context |
|
| 8546 | + * @param string $funcName |
|
| 8547 | + */ |
|
| 8045 | 8548 | public function registerCachingAction($context,$funcName,$funcParams) |
| 8046 | 8549 | { |
| 8047 | 8550 | if($this->_cachingStack) |
@@ -8064,13 +8567,27 @@ discard block |
||
| 8064 | 8567 | } |
| 8065 | 8568 | interface IPageStatePersister |
| 8066 | 8569 | { |
| 8570 | + /** |
|
| 8571 | + * @return TPage |
|
| 8572 | + */ |
|
| 8067 | 8573 | public function getPage(); |
| 8574 | + |
|
| 8575 | + /** |
|
| 8576 | + * @return void |
|
| 8577 | + */ |
|
| 8068 | 8578 | public function setPage(TPage $page); |
| 8579 | + |
|
| 8580 | + /** |
|
| 8581 | + * @return void |
|
| 8582 | + */ |
|
| 8069 | 8583 | public function save($state); |
| 8070 | 8584 | public function load(); |
| 8071 | 8585 | } |
| 8072 | 8586 | class TPageStateFormatter |
| 8073 | 8587 | { |
| 8588 | + /** |
|
| 8589 | + * @param TPage $page |
|
| 8590 | + */ |
|
| 8074 | 8591 | public static function serialize($page,$data) |
| 8075 | 8592 | { |
| 8076 | 8593 | $sm=$page->getApplication()->getSecurityManager(); |
@@ -8084,6 +8601,10 @@ discard block |
||
| 8084 | 8601 | $str=$sm->encrypt($str); |
| 8085 | 8602 | return base64_encode($str); |
| 8086 | 8603 | } |
| 8604 | + |
|
| 8605 | + /** |
|
| 8606 | + * @param TPage $page |
|
| 8607 | + */ |
|
| 8087 | 8608 | public static function unserialize($page,$data) |
| 8088 | 8609 | { |
| 8089 | 8610 | $str=base64_decode($data); |
@@ -8277,6 +8798,10 @@ discard block |
||
| 8277 | 8798 | { |
| 8278 | 8799 | $this->_cacheModuleID=$value; |
| 8279 | 8800 | } |
| 8801 | + |
|
| 8802 | + /** |
|
| 8803 | + * @param string $value |
|
| 8804 | + */ |
|
| 8280 | 8805 | public function setCacheKeyPrefix($value) |
| 8281 | 8806 | { |
| 8282 | 8807 | $this->_keyPrefix=$value; |
@@ -8327,10 +8852,18 @@ discard block |
||
| 8327 | 8852 | { |
| 8328 | 8853 | $this->_cachePostBack=TPropertyValue::ensureBoolean($value); |
| 8329 | 8854 | } |
| 8855 | + |
|
| 8856 | + /** |
|
| 8857 | + * @param TOutputCacheCheckDependencyEventParameter $param |
|
| 8858 | + */ |
|
| 8330 | 8859 | public function onCheckDependency($param) |
| 8331 | 8860 | { |
| 8332 | 8861 | $this->raiseEvent('OnCheckDependency',$this,$param); |
| 8333 | 8862 | } |
| 8863 | + |
|
| 8864 | + /** |
|
| 8865 | + * @param TOutputCacheCalculateKeyEventParameter $param |
|
| 8866 | + */ |
|
| 8334 | 8867 | public function onCalculateKey($param) |
| 8335 | 8868 | { |
| 8336 | 8869 | $this->raiseEvent('OnCalculateKey',$this,$param); |
@@ -8422,6 +8955,10 @@ discard block |
||
| 8422 | 8955 | $tplFile=dirname($class->getFileName()).DIRECTORY_SEPARATOR.$className.self::TEMPLATE_FILE_EXT; |
| 8423 | 8956 | return $this->getTemplateByFileName($tplFile); |
| 8424 | 8957 | } |
| 8958 | + |
|
| 8959 | + /** |
|
| 8960 | + * @param string $fileName |
|
| 8961 | + */ |
|
| 8425 | 8962 | public function getTemplateByFileName($fileName) |
| 8426 | 8963 | { |
| 8427 | 8964 | if(($fileName=$this->getLocalizedTemplate($fileName))!==null) |
@@ -8461,6 +8998,10 @@ discard block |
||
| 8461 | 8998 | else |
| 8462 | 8999 | return null; |
| 8463 | 9000 | } |
| 9001 | + |
|
| 9002 | + /** |
|
| 9003 | + * @return string |
|
| 9004 | + */ |
|
| 8464 | 9005 | protected function getLocalizedTemplate($filename) |
| 8465 | 9006 | { |
| 8466 | 9007 | if(($app=$this->getApplication()->getGlobalization(false))===null) |
@@ -8626,12 +9167,20 @@ discard block |
||
| 8626 | 9167 | $parentControl->addParsedObject($control); |
| 8627 | 9168 | } |
| 8628 | 9169 | } |
| 9170 | + |
|
| 9171 | + /** |
|
| 9172 | + * @param TControl $control |
|
| 9173 | + */ |
|
| 8629 | 9174 | protected function configureControl($control,$name,$value) |
| 8630 | 9175 | { |
| 8631 | 9176 | if(strncasecmp($name,'on',2)===0) $this->configureEvent($control,$name,$value,$control); |
| 8632 | 9177 | else if(($pos=strrpos($name,'.'))===false) $this->configureProperty($control,$name,$value); |
| 8633 | 9178 | else $this->configureSubProperty($control,$name,$value); |
| 8634 | 9179 | } |
| 9180 | + |
|
| 9181 | + /** |
|
| 9182 | + * @param TComponent $component |
|
| 9183 | + */ |
|
| 8635 | 9184 | protected function configureComponent($component,$name,$value) |
| 8636 | 9185 | { |
| 8637 | 9186 | if(strpos($name,'.')===false) $this->configureProperty($component,$name,$value); |
@@ -8941,6 +9490,11 @@ discard block |
||
| 8941 | 9490 | $tpl=$objects; |
| 8942 | 9491 | return $objects; |
| 8943 | 9492 | } |
| 9493 | + |
|
| 9494 | + /** |
|
| 9495 | + * @param string $str |
|
| 9496 | + * @param string $offset |
|
| 9497 | + */ |
|
| 8944 | 9498 | protected function parseAttributes($str,$offset) |
| 8945 | 9499 | { |
| 8946 | 9500 | if($str==='') |
@@ -8972,11 +9526,19 @@ discard block |
||
| 8972 | 9526 | } |
| 8973 | 9527 | return $attributes; |
| 8974 | 9528 | } |
| 9529 | + |
|
| 9530 | + /** |
|
| 9531 | + * @param string $content |
|
| 9532 | + */ |
|
| 8975 | 9533 | protected function parseTemplateProperty($content,$offset) |
| 8976 | 9534 | { |
| 8977 | 9535 | $line=$this->_startingLine+count(explode("\n",substr($this->_content,0,$offset)))-1; |
| 8978 | 9536 | return array(self::CONFIG_TEMPLATE,new TTemplate($content,$this->_contextPath,$this->_tplFile,$line,false)); |
| 8979 | 9537 | } |
| 9538 | + |
|
| 9539 | + /** |
|
| 9540 | + * @param string $value |
|
| 9541 | + */ |
|
| 8980 | 9542 | protected function parseAttribute($value) |
| 8981 | 9543 | { |
| 8982 | 9544 | if(($n=preg_match_all('/<%[#=].*?%>/msS',$value,$matches,PREG_OFFSET_CAPTURE))>0) |
@@ -9099,6 +9661,11 @@ discard block |
||
| 9099 | 9661 | { |
| 9100 | 9662 | return $this->_includedFiles; |
| 9101 | 9663 | } |
| 9664 | + |
|
| 9665 | + /** |
|
| 9666 | + * @param Exception $e |
|
| 9667 | + * @param integer $line |
|
| 9668 | + */ |
|
| 9102 | 9669 | protected function handleException($e,$line,$input=null) |
| 9103 | 9670 | { |
| 9104 | 9671 | $srcFile=$this->_tplFile; |
@@ -9155,6 +9722,10 @@ discard block |
||
| 9155 | 9722 | } |
| 9156 | 9723 | return $input; |
| 9157 | 9724 | } |
| 9725 | + |
|
| 9726 | + /** |
|
| 9727 | + * @param string $method |
|
| 9728 | + */ |
|
| 9158 | 9729 | protected function isClassBehaviorMethod(ReflectionClass $class,$method) |
| 9159 | 9730 | { |
| 9160 | 9731 | $component=new ReflectionClass('TComponent'); |
@@ -9237,6 +9808,10 @@ discard block |
||
| 9237 | 9808 | throw new TInvalidDataValueException('thememanager_basepath_invalid',$value); |
| 9238 | 9809 | } |
| 9239 | 9810 | } |
| 9811 | + |
|
| 9812 | + /** |
|
| 9813 | + * @return string |
|
| 9814 | + */ |
|
| 9240 | 9815 | public function getBaseUrl() |
| 9241 | 9816 | { |
| 9242 | 9817 | if($this->_baseUrl===null) |
@@ -9635,6 +10210,10 @@ discard block |
||
| 9635 | 10210 | { |
| 9636 | 10211 | return $this->_defaultPage; |
| 9637 | 10212 | } |
| 10213 | + |
|
| 10214 | + /** |
|
| 10215 | + * @param string $value |
|
| 10216 | + */ |
|
| 9638 | 10217 | public function setDefaultPage($value) |
| 9639 | 10218 | { |
| 9640 | 10219 | if($this->_initialized) |
@@ -9723,6 +10302,10 @@ discard block |
||
| 9723 | 10302 | $page->setSubProperty($name,$value); |
| 9724 | 10303 | $page->run($this->getResponse()->createHtmlWriter()); |
| 9725 | 10304 | } |
| 10305 | + |
|
| 10306 | + /** |
|
| 10307 | + * @param string $pagePath |
|
| 10308 | + */ |
|
| 9726 | 10309 | public function constructUrl($pagePath,$getParams=null,$encodeAmpersand=true,$encodeGetItems=true) |
| 9727 | 10310 | { |
| 9728 | 10311 | return $this->getRequest()->constructUrl($this->getID(),$pagePath,$getParams,$encodeAmpersand,$encodeGetItems); |
@@ -9794,11 +10377,20 @@ discard block |
||
| 9794 | 10377 | throw new TConfigurationException('pageserviceconf_file_invalid',$fname); |
| 9795 | 10378 | } |
| 9796 | 10379 | } |
| 10380 | + |
|
| 10381 | + /** |
|
| 10382 | + * @param string $configPath |
|
| 10383 | + */ |
|
| 9797 | 10384 | public function loadFromPhp($config,$configPath,$configPagePath) |
| 9798 | 10385 | { |
| 9799 | 10386 | $this->loadApplicationConfigurationFromPhp($config,$configPath); |
| 9800 | 10387 | $this->loadPageConfigurationFromPhp($config,$configPath,$configPagePath); |
| 9801 | 10388 | } |
| 10389 | + |
|
| 10390 | + /** |
|
| 10391 | + * @param TXmlDocument $dom |
|
| 10392 | + * @param string $configPath |
|
| 10393 | + */ |
|
| 9802 | 10394 | public function loadFromXml($dom,$configPath,$configPagePath) |
| 9803 | 10395 | { |
| 9804 | 10396 | $this->loadApplicationConfigurationFromXml($dom,$configPath); |
@@ -10055,6 +10647,10 @@ discard block |
||
| 10055 | 10647 | else |
| 10056 | 10648 | return $this->_basePath.DIRECTORY_SEPARATOR.$this->hash($path); |
| 10057 | 10649 | } |
| 10650 | + |
|
| 10651 | + /** |
|
| 10652 | + * @param string $path |
|
| 10653 | + */ |
|
| 10058 | 10654 | public function getPublishedUrl($path) |
| 10059 | 10655 | { |
| 10060 | 10656 | $path=realpath($path); |
@@ -10063,10 +10659,19 @@ discard block |
||
| 10063 | 10659 | else |
| 10064 | 10660 | return $this->_baseUrl.'/'.$this->hash($path); |
| 10065 | 10661 | } |
| 10662 | + |
|
| 10663 | + /** |
|
| 10664 | + * @param string $dir |
|
| 10665 | + */ |
|
| 10066 | 10666 | protected function hash($dir) |
| 10067 | 10667 | { |
| 10068 | 10668 | return sprintf('%x',crc32($dir.Prado::getVersion())); |
| 10069 | 10669 | } |
| 10670 | + |
|
| 10671 | + /** |
|
| 10672 | + * @param string $src |
|
| 10673 | + * @param string $dst |
|
| 10674 | + */ |
|
| 10070 | 10675 | protected function copyFile($src,$dst) |
| 10071 | 10676 | { |
| 10072 | 10677 | if(!is_dir($dst)) |
@@ -10080,6 +10685,11 @@ discard block |
||
| 10080 | 10685 | @copy($src,$dstFile); |
| 10081 | 10686 | } |
| 10082 | 10687 | } |
| 10688 | + |
|
| 10689 | + /** |
|
| 10690 | + * @param string $src |
|
| 10691 | + * @param string $dst |
|
| 10692 | + */ |
|
| 10083 | 10693 | public function copyDirectory($src,$dst) |
| 10084 | 10694 | { |
| 10085 | 10695 | if(!is_dir($dst)) |
@@ -10109,6 +10719,11 @@ discard block |
||
| 10109 | 10719 | throw new TInvalidDataValueException('assetmanager_source_directory_invalid', $src); |
| 10110 | 10720 | } |
| 10111 | 10721 | } |
| 10722 | + |
|
| 10723 | + /** |
|
| 10724 | + * @param string $tarfile |
|
| 10725 | + * @param string $md5sum |
|
| 10726 | + */ |
|
| 10112 | 10727 | public function publishTarFile($tarfile, $md5sum, $checkTimestamp=false) |
| 10113 | 10728 | { |
| 10114 | 10729 | if(isset($this->_published[$md5sum])) |
@@ -10131,6 +10746,10 @@ discard block |
||
| 10131 | 10746 | return $this->_published[$md5sum]=$this->_baseUrl.'/'.$dir; |
| 10132 | 10747 | } |
| 10133 | 10748 | } |
| 10749 | + |
|
| 10750 | + /** |
|
| 10751 | + * @param string $destination |
|
| 10752 | + */ |
|
| 10134 | 10753 | protected function deployTarFile($path,$destination) |
| 10135 | 10754 | { |
| 10136 | 10755 | if(($fullpath=realpath($path))===false || !is_file($fullpath)) |
@@ -10352,6 +10971,10 @@ discard block |
||
| 10352 | 10971 | $this->_services=array($this->getPageServiceID()=>array('TPageService',array(),null)); |
| 10353 | 10972 | Prado::setPathOfAlias('Application',$this->_basePath); |
| 10354 | 10973 | } |
| 10974 | + |
|
| 10975 | + /** |
|
| 10976 | + * @param string $basePath |
|
| 10977 | + */ |
|
| 10355 | 10978 | protected function resolvePaths($basePath) |
| 10356 | 10979 | { |
| 10357 | 10980 | if(empty($basePath) || ($basePath=realpath($basePath))===false) |
@@ -10417,10 +11040,18 @@ discard block |
||
| 10417 | 11040 | { |
| 10418 | 11041 | return $this->_requestCompleted; |
| 10419 | 11042 | } |
| 11043 | + |
|
| 11044 | + /** |
|
| 11045 | + * @param integer $defaultValue |
|
| 11046 | + */ |
|
| 10420 | 11047 | public function getGlobalState($key,$defaultValue=null) |
| 10421 | 11048 | { |
| 10422 | 11049 | return isset($this->_globals[$key])?$this->_globals[$key]:$defaultValue; |
| 10423 | 11050 | } |
| 11051 | + |
|
| 11052 | + /** |
|
| 11053 | + * @param string $key |
|
| 11054 | + */ |
|
| 10424 | 11055 | public function setGlobalState($key,$value,$defaultValue=null,$forceSave=false) |
| 10425 | 11056 | { |
| 10426 | 11057 | $this->_stateChanged=true; |
@@ -10480,6 +11111,10 @@ discard block |
||
| 10480 | 11111 | { |
| 10481 | 11112 | return $this->_basePath; |
| 10482 | 11113 | } |
| 11114 | + |
|
| 11115 | + /** |
|
| 11116 | + * @param string $value |
|
| 11117 | + */ |
|
| 10483 | 11118 | public function setBasePath($value) |
| 10484 | 11119 | { |
| 10485 | 11120 | $this->_basePath=$value; |
@@ -10488,6 +11123,10 @@ discard block |
||
| 10488 | 11123 | { |
| 10489 | 11124 | return $this->_configFile; |
| 10490 | 11125 | } |
| 11126 | + |
|
| 11127 | + /** |
|
| 11128 | + * @param string $value |
|
| 11129 | + */ |
|
| 10491 | 11130 | public function setConfigurationFile($value) |
| 10492 | 11131 | { |
| 10493 | 11132 | $this->_configFile=$value; |
@@ -10496,6 +11135,10 @@ discard block |
||
| 10496 | 11135 | { |
| 10497 | 11136 | return $this->_configType; |
| 10498 | 11137 | } |
| 11138 | + |
|
| 11139 | + /** |
|
| 11140 | + * @param string $value |
|
| 11141 | + */ |
|
| 10499 | 11142 | public function setConfigurationType($value) |
| 10500 | 11143 | { |
| 10501 | 11144 | $this->_configType = $value; |
@@ -10535,6 +11178,10 @@ discard block |
||
| 10535 | 11178 | { |
| 10536 | 11179 | return $this->_runtimePath; |
| 10537 | 11180 | } |
| 11181 | + |
|
| 11182 | + /** |
|
| 11183 | + * @param string $value |
|
| 11184 | + */ |
|
| 10538 | 11185 | public function setRuntimePath($value) |
| 10539 | 11186 | { |
| 10540 | 11187 | $this->_runtimePath=$value; |
@@ -10546,6 +11193,10 @@ discard block |
||
| 10546 | 11193 | { |
| 10547 | 11194 | return $this->_service; |
| 10548 | 11195 | } |
| 11196 | + |
|
| 11197 | + /** |
|
| 11198 | + * @param IService $value |
|
| 11199 | + */ |
|
| 10549 | 11200 | public function setService($value) |
| 10550 | 11201 | { |
| 10551 | 11202 | $this->_service=$value; |
@@ -10826,6 +11477,10 @@ discard block |
||
| 10826 | 11477 | else |
| 10827 | 11478 | throw new THttpException(500,'application_service_unknown',$serviceID); |
| 10828 | 11479 | } |
| 11480 | + |
|
| 11481 | + /** |
|
| 11482 | + * @param Exception $param |
|
| 11483 | + */ |
|
| 10829 | 11484 | public function onError($param) |
| 10830 | 11485 | { |
| 10831 | 11486 | Prado::log($param->getMessage(),TLogger::ERROR,'System.TApplication'); |
@@ -46,8 +46,7 @@ discard block |
||
| 46 | 46 | { |
| 47 | 47 | $am=self::$_application->getAssetManager(); |
| 48 | 48 | $url=$am->publishFilePath(self::getPathOfNamespace('System.'.$logoName,'.gif')); |
| 49 | - } |
|
| 50 | - else |
|
| 49 | + } else |
|
| 51 | 50 | $url='http://pradosoft.github.io/docs/'.$logoName.'.gif'; |
| 52 | 51 | return '<a title="Powered by PRADO" href="https://github.com/pradosoft/prado" target="_blank"><img src="'.$url.'" style="border-width:0px;" alt="Powered by PRADO" /></a>'; |
| 53 | 52 | } |
@@ -71,8 +70,7 @@ discard block |
||
| 71 | 70 | if(self::$_application!==null && ($errorHandler=self::$_application->getErrorHandler())!==null) |
| 72 | 71 | { |
| 73 | 72 | $errorHandler->handleError(null,$exception); |
| 74 | - } |
|
| 75 | - else |
|
| 73 | + } else |
|
| 76 | 74 | { |
| 77 | 75 | echo $exception; |
| 78 | 76 | } |
@@ -120,14 +118,14 @@ discard block |
||
| 120 | 118 | break; |
| 121 | 119 | default: |
| 122 | 120 | $s='$args[1]'; |
| 123 | - for($i=2;$i<$n;++$i) |
|
| 124 | - $s.=",\$args[$i]"; |
|
| 121 | + for($i=2;$i<$n;++$i) { |
|
| 122 | + $s.=",\$args[$i]"; |
|
| 123 | + } |
|
| 125 | 124 | eval("\$component=new $type($s);"); |
| 126 | 125 | return $component; |
| 127 | 126 | break; |
| 128 | 127 | } |
| 129 | - } |
|
| 130 | - else |
|
| 128 | + } else |
|
| 131 | 129 | return new $type; |
| 132 | 130 | } |
| 133 | 131 | public static function using($namespace,$checkClassExistence=true) |
@@ -138,31 +136,27 @@ discard block |
||
| 138 | 136 | try |
| 139 | 137 | { |
| 140 | 138 | include_once($namespace.self::CLASS_FILE_EXT); |
| 141 | - } |
|
| 142 | - catch(Exception $e) |
|
| 139 | + } catch(Exception $e) |
|
| 143 | 140 | { |
| 144 | 141 | if($checkClassExistence && !class_exists($namespace,false)) |
| 145 | 142 | throw new TInvalidOperationException('prado_component_unknown',$namespace,$e->getMessage()); |
| 146 | 143 | else |
| 147 | 144 | throw $e; |
| 148 | 145 | } |
| 149 | - } |
|
| 150 | - else if(($path=self::getPathOfNamespace($namespace,self::CLASS_FILE_EXT))!==null) |
|
| 146 | + } else if(($path=self::getPathOfNamespace($namespace,self::CLASS_FILE_EXT))!==null) |
|
| 151 | 147 | { |
| 152 | 148 | $className=substr($namespace,$pos+1); |
| 153 | 149 | if($className==='*') { |
| 154 | 150 | self::$_usings[$namespace]=$path; |
| 155 | 151 | set_include_path(get_include_path().PATH_SEPARATOR.$path); |
| 156 | - } |
|
| 157 | - else { |
|
| 152 | + } else { |
|
| 158 | 153 | self::$_usings[$namespace]=$path; |
| 159 | 154 | if(!$checkClassExistence || !class_exists($className,false)) |
| 160 | 155 | { |
| 161 | 156 | try |
| 162 | 157 | { |
| 163 | 158 | include_once($path); |
| 164 | - } |
|
| 165 | - catch(Exception $e) |
|
| 159 | + } catch(Exception $e) |
|
| 166 | 160 | { |
| 167 | 161 | if($checkClassExistence && !class_exists($className,false)) |
| 168 | 162 | throw new TInvalidOperationException('prado_component_unknown',$className,$e->getMessage()); |
@@ -171,8 +165,7 @@ discard block |
||
| 171 | 165 | } |
| 172 | 166 | } |
| 173 | 167 | } |
| 174 | - } |
|
| 175 | - else |
|
| 168 | + } else |
|
| 176 | 169 | throw new TInvalidDataValueException('prado_using_invalid',$namespace); |
| 177 | 170 | } |
| 178 | 171 | public static function getPathOfNamespace($namespace, $ext='') |
@@ -208,8 +201,7 @@ discard block |
||
| 208 | 201 | self::$_aliases[$alias]=$rp; |
| 209 | 202 | else |
| 210 | 203 | throw new TInvalidDataValueException('prado_aliasname_invalid',$alias); |
| 211 | - } |
|
| 212 | - else |
|
| 204 | + } else |
|
| 213 | 205 | throw new TInvalidDataValueException('prado_alias_invalid',$alias,$path); |
| 214 | 206 | } |
| 215 | 207 | public static function fatalError($msg) |
@@ -246,8 +238,7 @@ discard block |
||
| 246 | 238 | echo "'". substr($str, 0, 70) . "...'"; |
| 247 | 239 | else |
| 248 | 240 | echo "'" . $str . "'"; |
| 249 | - } |
|
| 250 | - else if (is_int($item) || is_float($item)) |
|
| 241 | + } else if (is_int($item) || is_float($item)) |
|
| 251 | 242 | echo $item; |
| 252 | 243 | else if (is_object($item)) |
| 253 | 244 | echo get_class($item); |
@@ -316,8 +307,7 @@ discard block |
||
| 316 | 307 | if(isset($trace[0]['file']) && isset($trace[0]['line'])) |
| 317 | 308 | $msg.=" (line {$trace[0]['line']}, {$trace[0]['file']})"; |
| 318 | 309 | $level=TLogger::DEBUG; |
| 319 | - } |
|
| 320 | - else |
|
| 310 | + } else |
|
| 321 | 311 | $level=TLogger::INFO; |
| 322 | 312 | self::log($msg,$level,$category,$ctl); |
| 323 | 313 | } |
@@ -343,8 +333,9 @@ discard block |
||
| 343 | 333 | Prado::using('System.I18N.Translation'); |
| 344 | 334 | $app = Prado::getApplication()->getGlobalization(false); |
| 345 | 335 | $params = array(); |
| 346 | - foreach($parameters as $key => $value) |
|
| 347 | - $params['{'.$key.'}'] = $value; |
|
| 336 | + foreach($parameters as $key => $value) { |
|
| 337 | + $params['{'.$key.'}'] = $value; |
|
| 338 | + } |
|
| 348 | 339 | if($app===null || ($config = $app->getTranslationConfiguration())===null) |
| 349 | 340 | return strtr($text, $params); |
| 350 | 341 | if ($catalogue===null) |
@@ -622,8 +613,7 @@ discard block |
||
| 622 | 613 | echo "<body><h1>Recursive Error</h1>\n"; |
| 623 | 614 | echo "<pre>".$exception->__toString()."</pre>\n"; |
| 624 | 615 | echo "</body></html>"; |
| 625 | - } |
|
| 626 | - else |
|
| 616 | + } else |
|
| 627 | 617 | { |
| 628 | 618 | error_log("Error happened while processing an existing error:\n".$exception->__toString()); |
| 629 | 619 | header('HTTP/1.0 500 Internal Error'); |
@@ -645,15 +635,13 @@ discard block |
||
| 645 | 635 | if($fileName==='') |
| 646 | 636 | $fileName='---embedded template---'; |
| 647 | 637 | $errorLine=$exception->getLineNumber(); |
| 648 | - } |
|
| 649 | - else |
|
| 638 | + } else |
|
| 650 | 639 | { |
| 651 | 640 | if(($trace=$this->getExactTrace($exception))!==null) |
| 652 | 641 | { |
| 653 | 642 | $fileName=$trace['file']; |
| 654 | 643 | $errorLine=$trace['line']; |
| 655 | - } |
|
| 656 | - else |
|
| 644 | + } else |
|
| 657 | 645 | { |
| 658 | 646 | $fileName=$exception->getFile(); |
| 659 | 647 | $errorLine=$exception->getLine(); |
@@ -712,8 +700,7 @@ discard block |
||
| 712 | 700 | $result=$trace[0]; |
| 713 | 701 | elseif(isset($trace[1])) |
| 714 | 702 | $result=$trace[1]; |
| 715 | - } |
|
| 716 | - else if($exception instanceof TInvalidOperationException) |
|
| 703 | + } else if($exception instanceof TInvalidOperationException) |
|
| 717 | 704 | { |
| 718 | 705 | if(($result=$this->getPropertyAccessTrace($trace,'__get'))===null) |
| 719 | 706 | $result=$this->getPropertyAccessTrace($trace,'__set'); |
@@ -745,8 +732,7 @@ discard block |
||
| 745 | 732 | { |
| 746 | 733 | $line=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",' ',$lines[$i]))); |
| 747 | 734 | $source.="<div class=\"error\">".$line."</div>"; |
| 748 | - } |
|
| 749 | - else |
|
| 735 | + } else |
|
| 750 | 736 | $source.=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",' ',$lines[$i]))); |
| 751 | 737 | } |
| 752 | 738 | return $source; |
@@ -810,11 +796,9 @@ discard block |
||
| 810 | 796 | { |
| 811 | 797 | array_splice($this->_d,$index,0,array($item)); |
| 812 | 798 | $this->_c++; |
| 813 | - } |
|
| 814 | - else |
|
| 799 | + } else |
|
| 815 | 800 | throw new TInvalidDataValueException('list_index_invalid',$index); |
| 816 | - } |
|
| 817 | - else |
|
| 801 | + } else |
|
| 818 | 802 | throw new TInvalidOperationException('list_readonly',get_class($this)); |
| 819 | 803 | } |
| 820 | 804 | public function remove($item) |
@@ -825,11 +809,9 @@ discard block |
||
| 825 | 809 | { |
| 826 | 810 | $this->removeAt($index); |
| 827 | 811 | return $index; |
| 828 | - } |
|
| 829 | - else |
|
| 812 | + } else |
|
| 830 | 813 | throw new TInvalidDataValueException('list_item_inexistent'); |
| 831 | - } |
|
| 832 | - else |
|
| 814 | + } else |
|
| 833 | 815 | throw new TInvalidOperationException('list_readonly',get_class($this)); |
| 834 | 816 | } |
| 835 | 817 | public function removeAt($index) |
@@ -847,17 +829,16 @@ discard block |
||
| 847 | 829 | array_splice($this->_d,$index,1); |
| 848 | 830 | return $item; |
| 849 | 831 | } |
| 850 | - } |
|
| 851 | - else |
|
| 832 | + } else |
|
| 852 | 833 | throw new TInvalidDataValueException('list_index_invalid',$index); |
| 853 | - } |
|
| 854 | - else |
|
| 834 | + } else |
|
| 855 | 835 | throw new TInvalidOperationException('list_readonly',get_class($this)); |
| 856 | 836 | } |
| 857 | 837 | public function clear() |
| 858 | 838 | { |
| 859 | - for($i=$this->_c-1;$i>=0;--$i) |
|
| 860 | - $this->removeAt($i); |
|
| 839 | + for($i=$this->_c-1;$i>=0;--$i) { |
|
| 840 | + $this->removeAt($i); |
|
| 841 | + } |
|
| 861 | 842 | } |
| 862 | 843 | public function contains($item) |
| 863 | 844 | { |
@@ -878,8 +859,7 @@ discard block |
||
| 878 | 859 | throw new TInvalidDataValueException('list_item_inexistent'); |
| 879 | 860 | $this->insertAt($index, $item); |
| 880 | 861 | return $index; |
| 881 | - } |
|
| 882 | - else |
|
| 862 | + } else |
|
| 883 | 863 | throw new TInvalidOperationException('list_readonly',get_class($this)); |
| 884 | 864 | } |
| 885 | 865 | public function insertAfter($baseitem, $item) |
@@ -890,8 +870,7 @@ discard block |
||
| 890 | 870 | throw new TInvalidDataValueException('list_item_inexistent'); |
| 891 | 871 | $this->insertAt($index + 1, $item); |
| 892 | 872 | return $index + 1; |
| 893 | - } |
|
| 894 | - else |
|
| 873 | + } else |
|
| 895 | 874 | throw new TInvalidOperationException('list_readonly',get_class($this)); |
| 896 | 875 | } |
| 897 | 876 | public function toArray() |
@@ -904,20 +883,20 @@ discard block |
||
| 904 | 883 | { |
| 905 | 884 | if($this->_c>0) |
| 906 | 885 | $this->clear(); |
| 907 | - foreach($data as $item) |
|
| 908 | - $this->add($item); |
|
| 909 | - } |
|
| 910 | - else if($data!==null) |
|
| 886 | + foreach($data as $item) { |
|
| 887 | + $this->add($item); |
|
| 888 | + } |
|
| 889 | + } else if($data!==null) |
|
| 911 | 890 | throw new TInvalidDataTypeException('list_data_not_iterable'); |
| 912 | 891 | } |
| 913 | 892 | public function mergeWith($data) |
| 914 | 893 | { |
| 915 | 894 | if(is_array($data) || ($data instanceof Traversable)) |
| 916 | 895 | { |
| 917 | - foreach($data as $item) |
|
| 918 | - $this->add($item); |
|
| 919 | - } |
|
| 920 | - else if($data!==null) |
|
| 896 | + foreach($data as $item) { |
|
| 897 | + $this->add($item); |
|
| 898 | + } |
|
| 899 | + } else if($data!==null) |
|
| 921 | 900 | throw new TInvalidDataTypeException('list_data_not_iterable'); |
| 922 | 901 | } |
| 923 | 902 | public function offsetExists($offset) |
@@ -1131,8 +1110,7 @@ discard block |
||
| 1131 | 1110 | { |
| 1132 | 1111 | if(($this->_recursiveLevel<0 || $level<$this->_recursiveLevel) && $this->validateDirectory($path)) |
| 1133 | 1112 | $timestamps=array_merge($this->generateTimestamps($path,$level+1)); |
| 1134 | - } |
|
| 1135 | - else if($this->validateFile($path)) |
|
| 1113 | + } else if($this->validateFile($path)) |
|
| 1136 | 1114 | $timestamps[$path]=filemtime($path); |
| 1137 | 1115 | } |
| 1138 | 1116 | closedir($dir); |
@@ -1174,9 +1152,10 @@ discard block |
||
| 1174 | 1152 | { |
| 1175 | 1153 | if($this->_dependencies!==null) |
| 1176 | 1154 | { |
| 1177 | - foreach($this->_dependencies as $dependency) |
|
| 1178 | - if($dependency->getHasChanged()) |
|
| 1155 | + foreach($this->_dependencies as $dependency) { |
|
| 1156 | + if($dependency->getHasChanged()) |
|
| 1179 | 1157 | return true; |
| 1158 | + } |
|
| 1180 | 1159 | } |
| 1181 | 1160 | return false; |
| 1182 | 1161 | } |
@@ -1286,8 +1265,9 @@ discard block |
||
| 1286 | 1265 | return $this->_fd; |
| 1287 | 1266 | $this->sortPriorities(); |
| 1288 | 1267 | $this->_fd=array(); |
| 1289 | - foreach($this->_d as $priority => $itemsatpriority) |
|
| 1290 | - $this->_fd=array_merge($this->_fd,$itemsatpriority); |
|
| 1268 | + foreach($this->_d as $priority => $itemsatpriority) { |
|
| 1269 | + $this->_fd=array_merge($this->_fd,$itemsatpriority); |
|
| 1270 | + } |
|
| 1291 | 1271 | return $this->_fd; |
| 1292 | 1272 | } |
| 1293 | 1273 | public function itemAt($index) |
@@ -1339,9 +1319,10 @@ discard block |
||
| 1339 | 1319 | if($preserveCache) { |
| 1340 | 1320 | $this->sortPriorities(); |
| 1341 | 1321 | $cc=0; |
| 1342 | - foreach($this->_d as $prioritykey=>$items) |
|
| 1343 | - if($prioritykey>=$priority) |
|
| 1322 | + foreach($this->_d as $prioritykey=>$items) { |
|
| 1323 | + if($prioritykey>=$priority) |
|
| 1344 | 1324 | break; |
| 1325 | + } |
|
| 1345 | 1326 | else |
| 1346 | 1327 | $cc+=count($items); |
| 1347 | 1328 | if($index===false&&isset($this->_d[$priority])) { |
@@ -1393,8 +1374,7 @@ discard block |
||
| 1393 | 1374 | } |
| 1394 | 1375 | $this->removeAtIndexInPriority($p[1],$p[0]); |
| 1395 | 1376 | return $p[2]; |
| 1396 | - } |
|
| 1397 | - else |
|
| 1377 | + } else |
|
| 1398 | 1378 | throw new TInvalidDataValueException('list_item_inexistent'); |
| 1399 | 1379 | } |
| 1400 | 1380 | public function removeAt($index) |
@@ -1428,8 +1408,9 @@ discard block |
||
| 1428 | 1408 | throw new TInvalidOperationException('list_readonly',get_class($this)); |
| 1429 | 1409 | $d=array_reverse($this->_d,true); |
| 1430 | 1410 | foreach($this->_d as $priority=>$items) { |
| 1431 | - for($index=count($items)-1;$index>=0;$index--) |
|
| 1432 | - $this->removeAtIndexInPriority($index,$priority); |
|
| 1411 | + for($index=count($items)-1;$index>=0;$index--) { |
|
| 1412 | + $this->removeAtIndexInPriority($index,$priority); |
|
| 1413 | + } |
|
| 1433 | 1414 | unset($this->_d[$priority]); |
| 1434 | 1415 | } |
| 1435 | 1416 | } |
@@ -1532,14 +1513,16 @@ discard block |
||
| 1532 | 1513 | $this->clear(); |
| 1533 | 1514 | foreach($data->getPriorities() as $priority) |
| 1534 | 1515 | { |
| 1535 | - foreach($data->itemsAtPriority($priority) as $index=>$item) |
|
| 1536 | - $this->insertAtIndexInPriority($item,$index,$priority); |
|
| 1516 | + foreach($data->itemsAtPriority($priority) as $index=>$item) { |
|
| 1517 | + $this->insertAtIndexInPriority($item,$index,$priority); |
|
| 1518 | + } |
|
| 1537 | 1519 | } |
| 1538 | 1520 | } else if(is_array($data)||$data instanceof Traversable) { |
| 1539 | 1521 | if($this->getCount()>0) |
| 1540 | 1522 | $this->clear(); |
| 1541 | - foreach($data as $key=>$item) |
|
| 1542 | - $this->add($item); |
|
| 1523 | + foreach($data as $key=>$item) { |
|
| 1524 | + $this->add($item); |
|
| 1525 | + } |
|
| 1543 | 1526 | } else if($data!==null) |
| 1544 | 1527 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
| 1545 | 1528 | } |
@@ -1549,16 +1532,16 @@ discard block |
||
| 1549 | 1532 | { |
| 1550 | 1533 | foreach($data->getPriorities() as $priority) |
| 1551 | 1534 | { |
| 1552 | - foreach($data->itemsAtPriority($priority) as $index=>$item) |
|
| 1553 | - $this->insertAtIndexInPriority($item,false,$priority); |
|
| 1535 | + foreach($data->itemsAtPriority($priority) as $index=>$item) { |
|
| 1536 | + $this->insertAtIndexInPriority($item,false,$priority); |
|
| 1537 | + } |
|
| 1554 | 1538 | } |
| 1555 | - } |
|
| 1556 | - else if(is_array($data)||$data instanceof Traversable) |
|
| 1539 | + } else if(is_array($data)||$data instanceof Traversable) |
|
| 1557 | 1540 | { |
| 1558 | - foreach($data as $priority=>$item) |
|
| 1559 | - $this->add($item); |
|
| 1560 | - } |
|
| 1561 | - else if($data!==null) |
|
| 1541 | + foreach($data as $priority=>$item) { |
|
| 1542 | + $this->add($item); |
|
| 1543 | + } |
|
| 1544 | + } else if($data!==null) |
|
| 1562 | 1545 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
| 1563 | 1546 | } |
| 1564 | 1547 | public function offsetExists($offset) |
@@ -1649,17 +1632,16 @@ discard block |
||
| 1649 | 1632 | $value=$this->_d[$key]; |
| 1650 | 1633 | unset($this->_d[$key]); |
| 1651 | 1634 | return $value; |
| 1652 | - } |
|
| 1653 | - else |
|
| 1635 | + } else |
|
| 1654 | 1636 | return null; |
| 1655 | - } |
|
| 1656 | - else |
|
| 1637 | + } else |
|
| 1657 | 1638 | throw new TInvalidOperationException('map_readonly',get_class($this)); |
| 1658 | 1639 | } |
| 1659 | 1640 | public function clear() |
| 1660 | 1641 | { |
| 1661 | - foreach(array_keys($this->_d) as $key) |
|
| 1662 | - $this->remove($key); |
|
| 1642 | + foreach(array_keys($this->_d) as $key) { |
|
| 1643 | + $this->remove($key); |
|
| 1644 | + } |
|
| 1663 | 1645 | } |
| 1664 | 1646 | public function contains($key) |
| 1665 | 1647 | { |
@@ -1675,20 +1657,20 @@ discard block |
||
| 1675 | 1657 | { |
| 1676 | 1658 | if($this->getCount()>0) |
| 1677 | 1659 | $this->clear(); |
| 1678 | - foreach($data as $key=>$value) |
|
| 1679 | - $this->add($key,$value); |
|
| 1680 | - } |
|
| 1681 | - else if($data!==null) |
|
| 1660 | + foreach($data as $key=>$value) { |
|
| 1661 | + $this->add($key,$value); |
|
| 1662 | + } |
|
| 1663 | + } else if($data!==null) |
|
| 1682 | 1664 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
| 1683 | 1665 | } |
| 1684 | 1666 | public function mergeWith($data) |
| 1685 | 1667 | { |
| 1686 | 1668 | if(is_array($data) || $data instanceof Traversable) |
| 1687 | 1669 | { |
| 1688 | - foreach($data as $key=>$value) |
|
| 1689 | - $this->add($key,$value); |
|
| 1690 | - } |
|
| 1691 | - else if($data!==null) |
|
| 1670 | + foreach($data as $key=>$value) { |
|
| 1671 | + $this->add($key,$value); |
|
| 1672 | + } |
|
| 1673 | + } else if($data!==null) |
|
| 1692 | 1674 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
| 1693 | 1675 | } |
| 1694 | 1676 | public function offsetExists($offset) |
@@ -1767,8 +1749,9 @@ discard block |
||
| 1767 | 1749 | return $this->_fd; |
| 1768 | 1750 | $this->sortPriorities(); |
| 1769 | 1751 | $this->_fd = array(); |
| 1770 | - foreach($this->_d as $priority => $itemsatpriority) |
|
| 1771 | - $this->_fd = array_merge($this->_fd, $itemsatpriority); |
|
| 1752 | + foreach($this->_d as $priority => $itemsatpriority) { |
|
| 1753 | + $this->_fd = array_merge($this->_fd, $itemsatpriority); |
|
| 1754 | + } |
|
| 1772 | 1755 | return $this->_fd; |
| 1773 | 1756 | } |
| 1774 | 1757 | public function count() |
@@ -1831,17 +1814,19 @@ discard block |
||
| 1831 | 1814 | public function priorityOf($item) |
| 1832 | 1815 | { |
| 1833 | 1816 | $this->sortPriorities(); |
| 1834 | - foreach($this->_d as $priority=>$items) |
|
| 1835 | - if(($index=array_search($item,$items,true))!==false) |
|
| 1817 | + foreach($this->_d as $priority=>$items) { |
|
| 1818 | + if(($index=array_search($item,$items,true))!==false) |
|
| 1836 | 1819 | return $priority; |
| 1820 | + } |
|
| 1837 | 1821 | return false; |
| 1838 | 1822 | } |
| 1839 | 1823 | public function priorityAt($key) |
| 1840 | 1824 | { |
| 1841 | 1825 | $this->sortPriorities(); |
| 1842 | - foreach($this->_d as $priority=>$items) |
|
| 1843 | - if(array_key_exists($key,$items)) |
|
| 1826 | + foreach($this->_d as $priority=>$items) { |
|
| 1827 | + if(array_key_exists($key,$items)) |
|
| 1844 | 1828 | return $priority; |
| 1829 | + } |
|
| 1845 | 1830 | return false; |
| 1846 | 1831 | } |
| 1847 | 1832 | public function add($key,$value,$priority=null) |
@@ -1851,10 +1836,11 @@ discard block |
||
| 1851 | 1836 | $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
| 1852 | 1837 | if(!$this->_r) |
| 1853 | 1838 | { |
| 1854 | - foreach($this->_d as $innerpriority=>$items) |
|
| 1855 | - if(array_key_exists($key,$items)) |
|
| 1839 | + foreach($this->_d as $innerpriority=>$items) { |
|
| 1840 | + if(array_key_exists($key,$items)) |
|
| 1856 | 1841 | { |
| 1857 | 1842 | unset($this->_d[$innerpriority][$key]); |
| 1843 | + } |
|
| 1858 | 1844 | $this->_c--; |
| 1859 | 1845 | if(count($this->_d[$innerpriority])===0) |
| 1860 | 1846 | unset($this->_d[$innerpriority]); |
@@ -1862,13 +1848,11 @@ discard block |
||
| 1862 | 1848 | if(!isset($this->_d[$priority])) { |
| 1863 | 1849 | $this->_d[$priority]=array($key=>$value); |
| 1864 | 1850 | $this->_o=false; |
| 1865 | - } |
|
| 1866 | - else |
|
| 1851 | + } else |
|
| 1867 | 1852 | $this->_d[$priority][$key]=$value; |
| 1868 | 1853 | $this->_c++; |
| 1869 | 1854 | $this->_fd=null; |
| 1870 | - } |
|
| 1871 | - else |
|
| 1855 | + } else |
|
| 1872 | 1856 | throw new TInvalidOperationException('map_readonly',get_class($this)); |
| 1873 | 1857 | return $priority; |
| 1874 | 1858 | } |
@@ -1881,10 +1865,11 @@ discard block |
||
| 1881 | 1865 | if($priority===false) |
| 1882 | 1866 | { |
| 1883 | 1867 | $this->sortPriorities(); |
| 1884 | - foreach($this->_d as $priority=>$items) |
|
| 1885 | - if(array_key_exists($key,$items)) |
|
| 1868 | + foreach($this->_d as $priority=>$items) { |
|
| 1869 | + if(array_key_exists($key,$items)) |
|
| 1886 | 1870 | { |
| 1887 | 1871 | $value=$this->_d[$priority][$key]; |
| 1872 | + } |
|
| 1888 | 1873 | unset($this->_d[$priority][$key]); |
| 1889 | 1874 | $this->_c--; |
| 1890 | 1875 | if(count($this->_d[$priority])===0) |
@@ -1896,8 +1881,7 @@ discard block |
||
| 1896 | 1881 | return $value; |
| 1897 | 1882 | } |
| 1898 | 1883 | return null; |
| 1899 | - } |
|
| 1900 | - else |
|
| 1884 | + } else |
|
| 1901 | 1885 | { |
| 1902 | 1886 | $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
| 1903 | 1887 | if(isset($this->_d[$priority])&&(isset($this->_d[$priority][$key])||array_key_exists($key,$this->_d[$priority]))) |
@@ -1911,19 +1895,18 @@ discard block |
||
| 1911 | 1895 | } |
| 1912 | 1896 | $this->_fd=null; |
| 1913 | 1897 | return $value; |
| 1914 | - } |
|
| 1915 | - else |
|
| 1898 | + } else |
|
| 1916 | 1899 | return null; |
| 1917 | 1900 | } |
| 1918 | - } |
|
| 1919 | - else |
|
| 1901 | + } else |
|
| 1920 | 1902 | throw new TInvalidOperationException('map_readonly',get_class($this)); |
| 1921 | 1903 | } |
| 1922 | 1904 | public function clear() |
| 1923 | 1905 | { |
| 1924 | - foreach($this->_d as $priority=>$items) |
|
| 1925 | - foreach(array_keys($items) as $key) |
|
| 1906 | + foreach($this->_d as $priority=>$items) { |
|
| 1907 | + foreach(array_keys($items) as $key) |
|
| 1926 | 1908 | $this->remove($key); |
| 1909 | + } |
|
| 1927 | 1910 | } |
| 1928 | 1911 | public function contains($key) |
| 1929 | 1912 | { |
@@ -1969,15 +1952,14 @@ discard block |
||
| 1969 | 1952 | $this->add($key,$value,$priority); |
| 1970 | 1953 | } |
| 1971 | 1954 | } |
| 1972 | - } |
|
| 1973 | - else if(is_array($data)||$data instanceof Traversable) |
|
| 1955 | + } else if(is_array($data)||$data instanceof Traversable) |
|
| 1974 | 1956 | { |
| 1975 | 1957 | if($this->getCount()>0) |
| 1976 | 1958 | $this->clear(); |
| 1977 | - foreach($data as $key=>$value) |
|
| 1978 | - $this->add($key,$value); |
|
| 1979 | - } |
|
| 1980 | - else if($data!==null) |
|
| 1959 | + foreach($data as $key=>$value) { |
|
| 1960 | + $this->add($key,$value); |
|
| 1961 | + } |
|
| 1962 | + } else if($data!==null) |
|
| 1981 | 1963 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
| 1982 | 1964 | } |
| 1983 | 1965 | public function mergeWith($data) |
@@ -1986,16 +1968,16 @@ discard block |
||
| 1986 | 1968 | { |
| 1987 | 1969 | foreach($data->getPriorities() as $priority) |
| 1988 | 1970 | { |
| 1989 | - foreach($data->itemsAtPriority($priority) as $key => $value) |
|
| 1990 | - $this->add($key,$value,$priority); |
|
| 1971 | + foreach($data->itemsAtPriority($priority) as $key => $value) { |
|
| 1972 | + $this->add($key,$value,$priority); |
|
| 1973 | + } |
|
| 1991 | 1974 | } |
| 1992 | - } |
|
| 1993 | - else if(is_array($data)||$data instanceof Traversable) |
|
| 1975 | + } else if(is_array($data)||$data instanceof Traversable) |
|
| 1994 | 1976 | { |
| 1995 | - foreach($data as $key=>$value) |
|
| 1996 | - $this->add($key,$value); |
|
| 1997 | - } |
|
| 1998 | - else if($data!==null) |
|
| 1977 | + foreach($data as $key=>$value) { |
|
| 1978 | + $this->add($key,$value); |
|
| 1979 | + } |
|
| 1980 | + } else if($data!==null) |
|
| 1999 | 1981 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
| 2000 | 1982 | } |
| 2001 | 1983 | public function offsetExists($offset) |
@@ -2038,8 +2020,7 @@ discard block |
||
| 2038 | 2020 | $this->_d[]=$item; |
| 2039 | 2021 | ++$this->_c; |
| 2040 | 2022 | } |
| 2041 | - } |
|
| 2042 | - else if($data!==null) |
|
| 2023 | + } else if($data!==null) |
|
| 2043 | 2024 | throw new TInvalidDataTypeException('stack_data_not_iterable'); |
| 2044 | 2025 | } |
| 2045 | 2026 | public function clear() |
@@ -2188,9 +2169,10 @@ discard block |
||
| 2188 | 2169 | { |
| 2189 | 2170 | if($this->_elements) |
| 2190 | 2171 | { |
| 2191 | - foreach($this->_elements as $element) |
|
| 2192 | - if($element->_tagName===$tagName) |
|
| 2172 | + foreach($this->_elements as $element) { |
|
| 2173 | + if($element->_tagName===$tagName) |
|
| 2193 | 2174 | return $element; |
| 2175 | + } |
|
| 2194 | 2176 | } |
| 2195 | 2177 | return null; |
| 2196 | 2178 | } |
@@ -2199,9 +2181,10 @@ discard block |
||
| 2199 | 2181 | $list=new TList; |
| 2200 | 2182 | if($this->_elements) |
| 2201 | 2183 | { |
| 2202 | - foreach($this->_elements as $element) |
|
| 2203 | - if($element->_tagName===$tagName) |
|
| 2184 | + foreach($this->_elements as $element) { |
|
| 2185 | + if($element->_tagName===$tagName) |
|
| 2204 | 2186 | $list->add($element); |
| 2187 | + } |
|
| 2205 | 2188 | } |
| 2206 | 2189 | return $list; |
| 2207 | 2190 | } |
@@ -2220,17 +2203,16 @@ discard block |
||
| 2220 | 2203 | if($this->getHasElement()) |
| 2221 | 2204 | { |
| 2222 | 2205 | $str=$prefix."<{$this->_tagName}$attr>\n"; |
| 2223 | - foreach($this->getElements() as $element) |
|
| 2224 | - $str.=$element->toString($indent+1)."\n"; |
|
| 2206 | + foreach($this->getElements() as $element) { |
|
| 2207 | + $str.=$element->toString($indent+1)."\n"; |
|
| 2208 | + } |
|
| 2225 | 2209 | $str.=$prefix."</{$this->_tagName}>"; |
| 2226 | 2210 | return $str; |
| 2227 | - } |
|
| 2228 | - else if(($value=$this->getValue())!=='') |
|
| 2211 | + } else if(($value=$this->getValue())!=='') |
|
| 2229 | 2212 | { |
| 2230 | 2213 | $value=$this->xmlEncode($value); |
| 2231 | 2214 | return $prefix."<{$this->_tagName}$attr>$value</{$this->_tagName}>"; |
| 2232 | - } |
|
| 2233 | - else |
|
| 2215 | + } else |
|
| 2234 | 2216 | return $prefix."<{$this->_tagName}$attr />"; |
| 2235 | 2217 | } |
| 2236 | 2218 | public function __toString() |
@@ -2312,8 +2294,9 @@ discard block |
||
| 2312 | 2294 | $attributes->add('xmlns:'.$prefix, $uri); |
| 2313 | 2295 | } |
| 2314 | 2296 | } |
| 2315 | - foreach($element->attributes as $name=>$attr) |
|
| 2316 | - $attributes->add(($attr->prefix === '' ? '' : $attr->prefix . ':') .$name,$attr->value); |
|
| 2297 | + foreach($element->attributes as $name=>$attr) { |
|
| 2298 | + $attributes->add(($attr->prefix === '' ? '' : $attr->prefix . ':') .$name,$attr->value); |
|
| 2299 | + } |
|
| 2317 | 2300 | foreach($element->childNodes as $child) |
| 2318 | 2301 | { |
| 2319 | 2302 | if($child instanceof DOMElement) |
@@ -2327,8 +2310,7 @@ discard block |
||
| 2327 | 2310 | { |
| 2328 | 2311 | fwrite($fw,$this->saveToString()); |
| 2329 | 2312 | fclose($fw); |
| 2330 | - } |
|
| 2331 | - else |
|
| 2313 | + } else |
|
| 2332 | 2314 | throw new TIOException('xmldocument_file_write_failed',$file); |
| 2333 | 2315 | } |
| 2334 | 2316 | public function saveToString() |
@@ -2345,8 +2327,9 @@ discard block |
||
| 2345 | 2327 | { |
| 2346 | 2328 | $element=new TXmlElement($node->tagName); |
| 2347 | 2329 | $element->setValue($node->nodeValue); |
| 2348 | - foreach($node->attributes as $name=>$attr) |
|
| 2349 | - $element->getAttributes()->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name,$attr->value); |
|
| 2330 | + foreach($node->attributes as $name=>$attr) { |
|
| 2331 | + $element->getAttributes()->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name,$attr->value); |
|
| 2332 | + } |
|
| 2350 | 2333 | foreach($node->childNodes as $child) |
| 2351 | 2334 | { |
| 2352 | 2335 | if($child instanceof DOMElement) |
@@ -2374,8 +2357,7 @@ discard block |
||
| 2374 | 2357 | if($item->getParent()!==null) |
| 2375 | 2358 | $item->getParent()->getElements()->remove($item); |
| 2376 | 2359 | $item->setParent($this->_o); |
| 2377 | - } |
|
| 2378 | - else |
|
| 2360 | + } else |
|
| 2379 | 2361 | throw new TInvalidDataTypeException('xmlelementlist_xmlelement_required'); |
| 2380 | 2362 | } |
| 2381 | 2363 | public function removeAt($index) |
@@ -2419,8 +2401,7 @@ discard block |
||
| 2419 | 2401 | { |
| 2420 | 2402 | $this->_everyone=true; |
| 2421 | 2403 | break; |
| 2422 | - } |
|
| 2423 | - else if($user==='?') |
|
| 2404 | + } else if($user==='?') |
|
| 2424 | 2405 | $this->_guest=true; |
| 2425 | 2406 | else if($user==='@') |
| 2426 | 2407 | $this->_authenticated=true; |
@@ -2530,8 +2511,7 @@ discard block |
||
| 2530 | 2511 | return ($decision>0); |
| 2531 | 2512 | } |
| 2532 | 2513 | return true; |
| 2533 | - } |
|
| 2534 | - else |
|
| 2514 | + } else |
|
| 2535 | 2515 | return false; |
| 2536 | 2516 | } |
| 2537 | 2517 | public function insertAt($index,$item) |
@@ -2661,8 +2641,7 @@ discard block |
||
| 2661 | 2641 | if($module===false) |
| 2662 | 2642 | throw new TNotSupportedException('securitymanager_mcryptextension_initfailed'); |
| 2663 | 2643 | return $module; |
| 2664 | - } |
|
| 2665 | - else |
|
| 2644 | + } else |
|
| 2666 | 2645 | throw new TNotSupportedException('securitymanager_mcryptextension_required'); |
| 2667 | 2646 | } |
| 2668 | 2647 | public function hashData($data) |
@@ -2732,8 +2711,9 @@ discard block |
||
| 2732 | 2711 | public static function renderScriptFiles($files) |
| 2733 | 2712 | { |
| 2734 | 2713 | $str=''; |
| 2735 | - foreach($files as $file) |
|
| 2736 | - $str.= self::renderScriptFile($file); |
|
| 2714 | + foreach($files as $file) { |
|
| 2715 | + $str.= self::renderScriptFile($file); |
|
| 2716 | + } |
|
| 2737 | 2717 | return $str; |
| 2738 | 2718 | } |
| 2739 | 2719 | public static function renderScriptFile($file) |
@@ -2802,8 +2782,7 @@ discard block |
||
| 2802 | 2782 | } |
| 2803 | 2783 | } |
| 2804 | 2784 | return '{'.$results.'}'; |
| 2805 | - } |
|
| 2806 | - else |
|
| 2785 | + } else |
|
| 2807 | 2786 | { |
| 2808 | 2787 | foreach($value as $v) |
| 2809 | 2788 | { |
@@ -2816,8 +2795,7 @@ discard block |
||
| 2816 | 2795 | } |
| 2817 | 2796 | return '['.$results.']'; |
| 2818 | 2797 | } |
| 2819 | - } |
|
| 2820 | - else if(is_integer($value)) |
|
| 2798 | + } else if(is_integer($value)) |
|
| 2821 | 2799 | return "$value"; |
| 2822 | 2800 | else if(is_float($value)) |
| 2823 | 2801 | { |
@@ -2837,8 +2815,7 @@ discard block |
||
| 2837 | 2815 | return str_replace($locale['decimal_point'], '.', "$value"); |
| 2838 | 2816 | break; |
| 2839 | 2817 | } |
| 2840 | - } |
|
| 2841 | - else if(is_object($value)) |
|
| 2818 | + } else if(is_object($value)) |
|
| 2842 | 2819 | if ($value instanceof TJavaScriptLiteral) |
| 2843 | 2820 | return $value->toJavaScriptLiteral(); |
| 2844 | 2821 | else |
@@ -2863,8 +2840,9 @@ discard block |
||
| 2863 | 2840 | $value=iconv($sourceEncoding, 'UTF-8', $value); |
| 2864 | 2841 | else if (is_array($value)) |
| 2865 | 2842 | { |
| 2866 | - foreach($value as &$element) |
|
| 2867 | - self::convertToUtf8($element, $sourceEncoding); |
|
| 2843 | + foreach($value as &$element) { |
|
| 2844 | + self::convertToUtf8($element, $sourceEncoding); |
|
| 2845 | + } |
|
| 2868 | 2846 | } |
| 2869 | 2847 | } |
| 2870 | 2848 | public static function jsonDecode($value, $assoc = false, $depth = 512) |
@@ -2923,23 +2901,22 @@ discard block |
||
| 2923 | 2901 | if(is_array($value)) |
| 2924 | 2902 | { |
| 2925 | 2903 | $name=urlencode($name.'[]'); |
| 2926 | - foreach($value as $v) |
|
| 2927 | - $url.=$amp.$name.'='.urlencode($v); |
|
| 2928 | - } |
|
| 2929 | - else |
|
| 2904 | + foreach($value as $v) { |
|
| 2905 | + $url.=$amp.$name.'='.urlencode($v); |
|
| 2906 | + } |
|
| 2907 | + } else |
|
| 2930 | 2908 | $url.=$amp.urlencode($name).'='.urlencode($value); |
| 2931 | 2909 | } |
| 2932 | - } |
|
| 2933 | - else |
|
| 2910 | + } else |
|
| 2934 | 2911 | { |
| 2935 | 2912 | foreach($getItems as $name=>$value) |
| 2936 | 2913 | { |
| 2937 | 2914 | if(is_array($value)) |
| 2938 | 2915 | { |
| 2939 | - foreach($value as $v) |
|
| 2940 | - $url.=$amp.$name.'[]='.$v; |
|
| 2941 | - } |
|
| 2942 | - else |
|
| 2916 | + foreach($value as $v) { |
|
| 2917 | + $url.=$amp.$name.'[]='.$v; |
|
| 2918 | + } |
|
| 2919 | + } else |
|
| 2943 | 2920 | $url.=$amp.$name.'='.$value; |
| 2944 | 2921 | } |
| 2945 | 2922 | } |
@@ -2977,14 +2954,12 @@ discard block |
||
| 2977 | 2954 | $getVariables[substr($name,0,$pos)][]=$value; |
| 2978 | 2955 | else |
| 2979 | 2956 | $getVariables[$name]=$value; |
| 2980 | - } |
|
| 2981 | - else |
|
| 2957 | + } else |
|
| 2982 | 2958 | $getVariables[$path]=''; |
| 2983 | 2959 | } |
| 2984 | 2960 | } |
| 2985 | 2961 | return $getVariables; |
| 2986 | - } |
|
| 2987 | - else |
|
| 2962 | + } else |
|
| 2988 | 2963 | return array(); |
| 2989 | 2964 | } |
| 2990 | 2965 | } |
@@ -3068,8 +3043,7 @@ discard block |
||
| 3068 | 3043 | $port=$_SERVER['SERVER_PORT']; |
| 3069 | 3044 | if(($port!=80 && !$secure) || ($port!=443 && $secure)) |
| 3070 | 3045 | $url.=':'.$port; |
| 3071 | - } |
|
| 3072 | - else |
|
| 3046 | + } else |
|
| 3073 | 3047 | $url.=$_SERVER['HTTP_HOST']; |
| 3074 | 3048 | $url.=$this->getRequestUri(); |
| 3075 | 3049 | $this->_url=new TUri($url); |
@@ -3139,8 +3113,7 @@ discard block |
||
| 3139 | 3113 | { |
| 3140 | 3114 | $this->_urlManager=new TUrlManager; |
| 3141 | 3115 | $this->_urlManager->init(null); |
| 3142 | - } |
|
| 3143 | - else |
|
| 3116 | + } else |
|
| 3144 | 3117 | { |
| 3145 | 3118 | $this->_urlManager=$this->getApplication()->getModule($this->_urlManagerID); |
| 3146 | 3119 | if($this->_urlManager===null) |
@@ -3205,8 +3178,7 @@ discard block |
||
| 3205 | 3178 | static $result; |
| 3206 | 3179 | if($result === null && function_exists('apache_request_headers')) { |
| 3207 | 3180 | $result = apache_request_headers(); |
| 3208 | - } |
|
| 3209 | - elseif($result === null) { |
|
| 3181 | + } elseif($result === null) { |
|
| 3210 | 3182 | $result = array(); |
| 3211 | 3183 | foreach($_SERVER as $key=>$value) { |
| 3212 | 3184 | if(strncasecmp($key, 'HTTP_', 5) !== 0) continue; |
@@ -3261,8 +3233,7 @@ discard block |
||
| 3261 | 3233 | try |
| 3262 | 3234 | { |
| 3263 | 3235 | return get_browser(); |
| 3264 | - } |
|
| 3265 | - catch(TPhpErrorException $e) |
|
| 3236 | + } catch(TPhpErrorException $e) |
|
| 3266 | 3237 | { |
| 3267 | 3238 | throw new TConfigurationException('httprequest_browscap_required'); |
| 3268 | 3239 | } |
@@ -3316,11 +3287,11 @@ discard block |
||
| 3316 | 3287 | if(($value=$sm->validateData($value))!==false) |
| 3317 | 3288 | $this->_cookies->add(new THttpCookie($key,$value)); |
| 3318 | 3289 | } |
| 3319 | - } |
|
| 3320 | - else |
|
| 3290 | + } else |
|
| 3321 | 3291 | { |
| 3322 | - foreach($_COOKIE as $key=>$value) |
|
| 3323 | - $this->_cookies->add(new THttpCookie($key,$value)); |
|
| 3292 | + foreach($_COOKIE as $key=>$value) { |
|
| 3293 | + $this->_cookies->add(new THttpCookie($key,$value)); |
|
| 3294 | + } |
|
| 3324 | 3295 | } |
| 3325 | 3296 | } |
| 3326 | 3297 | return $this->_cookies; |
@@ -3354,8 +3325,9 @@ discard block |
||
| 3354 | 3325 | public function resolveRequest($serviceIDs) |
| 3355 | 3326 | { |
| 3356 | 3327 | $getParams=$this->parseUrl(); |
| 3357 | - foreach($getParams as $name=>$value) |
|
| 3358 | - $_GET[$name]=$value; |
|
| 3328 | + foreach($getParams as $name=>$value) { |
|
| 3329 | + $_GET[$name]=$value; |
|
| 3330 | + } |
|
| 3359 | 3331 | $this->_items=array_merge($_GET,$_POST); |
| 3360 | 3332 | $this->_requestResolved=true; |
| 3361 | 3333 | foreach($serviceIDs as $serviceID) |
@@ -3420,14 +3392,14 @@ discard block |
||
| 3420 | 3392 | $value=$this->_items[$key]; |
| 3421 | 3393 | unset($this->_items[$key]); |
| 3422 | 3394 | return $value; |
| 3423 | - } |
|
| 3424 | - else |
|
| 3395 | + } else |
|
| 3425 | 3396 | return null; |
| 3426 | 3397 | } |
| 3427 | 3398 | public function clear() |
| 3428 | 3399 | { |
| 3429 | - foreach(array_keys($this->_items) as $key) |
|
| 3430 | - $this->remove($key); |
|
| 3400 | + foreach(array_keys($this->_items) as $key) { |
|
| 3401 | + $this->remove($key); |
|
| 3402 | + } |
|
| 3431 | 3403 | } |
| 3432 | 3404 | public function contains($key) |
| 3433 | 3405 | { |
@@ -3468,8 +3440,7 @@ discard block |
||
| 3468 | 3440 | parent::insertAt($index,$item); |
| 3469 | 3441 | if($this->_o instanceof THttpResponse) |
| 3470 | 3442 | $this->_o->addCookie($item); |
| 3471 | - } |
|
| 3472 | - else |
|
| 3443 | + } else |
|
| 3473 | 3444 | throw new TInvalidDataTypeException('httpcookiecollection_httpcookie_required'); |
| 3474 | 3445 | } |
| 3475 | 3446 | public function removeAt($index) |
@@ -3488,9 +3459,10 @@ discard block |
||
| 3488 | 3459 | } |
| 3489 | 3460 | public function findCookieByName($name) |
| 3490 | 3461 | { |
| 3491 | - foreach($this as $cookie) |
|
| 3492 | - if($cookie->getName()===$name) |
|
| 3462 | + foreach($this as $cookie) { |
|
| 3463 | + if($cookie->getName()===$name) |
|
| 3493 | 3464 | return $cookie; |
| 3465 | + } |
|
| 3494 | 3466 | return null; |
| 3495 | 3467 | } |
| 3496 | 3468 | } |
@@ -3599,8 +3571,7 @@ discard block |
||
| 3599 | 3571 | $this->_query=isset($ret['query'])?$ret['query']:''; |
| 3600 | 3572 | $this->_fragment=isset($ret['fragment'])?$ret['fragment']:''; |
| 3601 | 3573 | $this->_uri=$uri; |
| 3602 | - } |
|
| 3603 | - else |
|
| 3574 | + } else |
|
| 3604 | 3575 | { |
| 3605 | 3576 | throw new TInvalidDataValueException('uri_format_invalid',$uri); |
| 3606 | 3577 | } |
@@ -3772,7 +3743,7 @@ discard block |
||
| 3772 | 3743 | $status=TPropertyValue::ensureInteger($status); |
| 3773 | 3744 | if(isset(self::$HTTP_STATUS_CODES[$status])) { |
| 3774 | 3745 | $this->_reason=self::$HTTP_STATUS_CODES[$status]; |
| 3775 | - }else{ |
|
| 3746 | + } else{ |
|
| 3776 | 3747 | if($reason===null || $reason==='') { |
| 3777 | 3748 | throw new TInvalidDataValueException("response_status_reason_missing"); |
| 3778 | 3749 | } |
@@ -3834,10 +3805,10 @@ discard block |
||
| 3834 | 3805 | $this->sendHttpHeader(); |
| 3835 | 3806 | if(is_array($headers)) |
| 3836 | 3807 | { |
| 3837 | - foreach($headers as $h) |
|
| 3838 | - header($h); |
|
| 3839 | - } |
|
| 3840 | - else |
|
| 3808 | + foreach($headers as $h) { |
|
| 3809 | + header($h); |
|
| 3810 | + } |
|
| 3811 | + } else |
|
| 3841 | 3812 | { |
| 3842 | 3813 | header('Pragma: public'); |
| 3843 | 3814 | header('Expires: 0'); |
@@ -3900,13 +3871,11 @@ discard block |
||
| 3900 | 3871 | { |
| 3901 | 3872 | $this->_bufferOutput = false; |
| 3902 | 3873 | ob_end_flush(); |
| 3903 | - } |
|
| 3904 | - else |
|
| 3874 | + } else |
|
| 3905 | 3875 | ob_flush(); |
| 3906 | 3876 | flush(); |
| 3907 | 3877 | } |
| 3908 | - } |
|
| 3909 | - else |
|
| 3878 | + } else |
|
| 3910 | 3879 | flush(); |
| 3911 | 3880 | } |
| 3912 | 3881 | protected function ensureHttpHeaderSent() |
@@ -3992,8 +3961,7 @@ discard block |
||
| 3992 | 3961 | $cookie->getSecure(), |
| 3993 | 3962 | $cookie->getHttpOnly() |
| 3994 | 3963 | ); |
| 3995 | - } |
|
| 3996 | - else { |
|
| 3964 | + } else { |
|
| 3997 | 3965 | setcookie( |
| 3998 | 3966 | $cookie->getName(), |
| 3999 | 3967 | $cookie->getValue(), |
@@ -4173,13 +4141,11 @@ discard block |
||
| 4173 | 4141 | { |
| 4174 | 4142 | ini_set('session.use_cookies','0'); |
| 4175 | 4143 | ini_set('session.use_only_cookies','0'); |
| 4176 | - } |
|
| 4177 | - else if($value===THttpSessionCookieMode::Allow) |
|
| 4144 | + } else if($value===THttpSessionCookieMode::Allow) |
|
| 4178 | 4145 | { |
| 4179 | 4146 | ini_set('session.use_cookies','1'); |
| 4180 | 4147 | ini_set('session.use_only_cookies','0'); |
| 4181 | - } |
|
| 4182 | - else |
|
| 4148 | + } else |
|
| 4183 | 4149 | { |
| 4184 | 4150 | ini_set('session.use_cookies','1'); |
| 4185 | 4151 | ini_set('session.use_only_cookies','1'); |
@@ -4213,8 +4179,7 @@ discard block |
||
| 4213 | 4179 | { |
| 4214 | 4180 | ini_set('session.gc_probability',$value); |
| 4215 | 4181 | ini_set('session.gc_divisor','100'); |
| 4216 | - } |
|
| 4217 | - else |
|
| 4182 | + } else |
|
| 4218 | 4183 | throw new TInvalidDataValueException('httpsession_gcprobability_invalid',$value); |
| 4219 | 4184 | } |
| 4220 | 4185 | } |
@@ -4300,14 +4265,14 @@ discard block |
||
| 4300 | 4265 | $value=$_SESSION[$key]; |
| 4301 | 4266 | unset($_SESSION[$key]); |
| 4302 | 4267 | return $value; |
| 4303 | - } |
|
| 4304 | - else |
|
| 4268 | + } else |
|
| 4305 | 4269 | return null; |
| 4306 | 4270 | } |
| 4307 | 4271 | public function clear() |
| 4308 | 4272 | { |
| 4309 | - foreach(array_keys($_SESSION) as $key) |
|
| 4310 | - unset($_SESSION[$key]); |
|
| 4273 | + foreach(array_keys($_SESSION) as $key) { |
|
| 4274 | + unset($_SESSION[$key]); |
|
| 4275 | + } |
|
| 4311 | 4276 | } |
| 4312 | 4277 | public function contains($key) |
| 4313 | 4278 | { |
@@ -4617,10 +4582,8 @@ discard block |
||
| 4617 | 4582 | return $this->_id; |
| 4618 | 4583 | else |
| 4619 | 4584 | return ($this->_uid=$prefix.self::ID_SEPARATOR.$this->_id); |
| 4620 | - } |
|
| 4621 | - else return $this->_id; |
|
| 4622 | - } |
|
| 4623 | - else |
|
| 4585 | + } else return $this->_id; |
|
| 4586 | + } else |
|
| 4624 | 4587 | return $this->_uid; |
| 4625 | 4588 | } |
| 4626 | 4589 | public function focus() |
@@ -4692,12 +4655,12 @@ discard block |
||
| 4692 | 4655 | { |
| 4693 | 4656 | if($checkParents) |
| 4694 | 4657 | { |
| 4695 | - for($control=$this;$control;$control=$control->_parent) |
|
| 4696 | - if(!$control->getVisible(false)) |
|
| 4658 | + for($control=$this;$control;$control=$control->_parent) { |
|
| 4659 | + if(!$control->getVisible(false)) |
|
| 4697 | 4660 | return false; |
| 4661 | + } |
|
| 4698 | 4662 | return true; |
| 4699 | - } |
|
| 4700 | - else |
|
| 4663 | + } else |
|
| 4701 | 4664 | return $this->getViewState('Visible',true); |
| 4702 | 4665 | } |
| 4703 | 4666 | public function setVisible($value) |
@@ -4708,12 +4671,12 @@ discard block |
||
| 4708 | 4671 | { |
| 4709 | 4672 | if($checkParents) |
| 4710 | 4673 | { |
| 4711 | - for($control=$this;$control;$control=$control->_parent) |
|
| 4712 | - if(!$control->getViewState('Enabled',true)) |
|
| 4674 | + for($control=$this;$control;$control=$control->_parent) { |
|
| 4675 | + if(!$control->getViewState('Enabled',true)) |
|
| 4713 | 4676 | return false; |
| 4677 | + } |
|
| 4714 | 4678 | return true; |
| 4715 | - } |
|
| 4716 | - else |
|
| 4679 | + } else |
|
| 4717 | 4680 | return $this->getViewState('Enabled',true); |
| 4718 | 4681 | } |
| 4719 | 4682 | public function setEnabled($value) |
@@ -4767,12 +4730,12 @@ discard block |
||
| 4767 | 4730 | { |
| 4768 | 4731 | if($checkParents) |
| 4769 | 4732 | { |
| 4770 | - for($control=$this;$control!==null;$control=$control->getParent()) |
|
| 4771 | - if($control->_flags & self::IS_DISABLE_VIEWSTATE) |
|
| 4733 | + for($control=$this;$control!==null;$control=$control->getParent()) { |
|
| 4734 | + if($control->_flags & self::IS_DISABLE_VIEWSTATE) |
|
| 4772 | 4735 | return false; |
| 4736 | + } |
|
| 4773 | 4737 | return true; |
| 4774 | - } |
|
| 4775 | - else |
|
| 4738 | + } else |
|
| 4776 | 4739 | return !($this->_flags & self::IS_DISABLE_VIEWSTATE); |
| 4777 | 4740 | } |
| 4778 | 4741 | public function setEnableViewState($value) |
@@ -4810,8 +4773,7 @@ discard block |
||
| 4810 | 4773 | if(is_object($this->_tempState[$key]) && $this->_trackViewState) |
| 4811 | 4774 | $this->_viewState[$key]=$this->_tempState[$key]; |
| 4812 | 4775 | return $this->_tempState[$key]; |
| 4813 | - } |
|
| 4814 | - else |
|
| 4776 | + } else |
|
| 4815 | 4777 | return $defaultValue; |
| 4816 | 4778 | } |
| 4817 | 4779 | public function setViewState($key,$value,$defaultValue=null) |
@@ -4823,8 +4785,7 @@ discard block |
||
| 4823 | 4785 | unset($this->_viewState[$key]); |
| 4824 | 4786 | else |
| 4825 | 4787 | $this->_viewState[$key]=$value; |
| 4826 | - } |
|
| 4827 | - else |
|
| 4788 | + } else |
|
| 4828 | 4789 | { |
| 4829 | 4790 | unset($this->_viewState[$key]); |
| 4830 | 4791 | if($value===$defaultValue) |
@@ -4862,8 +4823,9 @@ discard block |
||
| 4862 | 4823 | { |
| 4863 | 4824 | if(($context=$this->getTemplateControl())===null) |
| 4864 | 4825 | $context=$this; |
| 4865 | - foreach($this->_rf[self::RF_DATA_BINDINGS] as $property=>$expression) |
|
| 4866 | - $this->setSubProperty($property,$context->evaluateExpression($expression)); |
|
| 4826 | + foreach($this->_rf[self::RF_DATA_BINDINGS] as $property=>$expression) { |
|
| 4827 | + $this->setSubProperty($property,$context->evaluateExpression($expression)); |
|
| 4828 | + } |
|
| 4867 | 4829 | } |
| 4868 | 4830 | } |
| 4869 | 4831 | protected function autoDataBindProperties() |
@@ -4872,17 +4834,19 @@ discard block |
||
| 4872 | 4834 | { |
| 4873 | 4835 | if(($context=$this->getTemplateControl())===null) |
| 4874 | 4836 | $context=$this; |
| 4875 | - foreach($this->_rf[self::RF_AUTO_BINDINGS] as $property=>$expression) |
|
| 4876 | - $this->setSubProperty($property,$context->evaluateExpression($expression)); |
|
| 4837 | + foreach($this->_rf[self::RF_AUTO_BINDINGS] as $property=>$expression) { |
|
| 4838 | + $this->setSubProperty($property,$context->evaluateExpression($expression)); |
|
| 4839 | + } |
|
| 4877 | 4840 | } |
| 4878 | 4841 | } |
| 4879 | 4842 | protected function dataBindChildren() |
| 4880 | 4843 | { |
| 4881 | 4844 | if(isset($this->_rf[self::RF_CONTROLS])) |
| 4882 | 4845 | { |
| 4883 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
| 4884 | - if($control instanceof IBindable) |
|
| 4846 | + foreach($this->_rf[self::RF_CONTROLS] as $control) { |
|
| 4847 | + if($control instanceof IBindable) |
|
| 4885 | 4848 | $control->dataBind(); |
| 4849 | + } |
|
| 4886 | 4850 | } |
| 4887 | 4851 | } |
| 4888 | 4852 | final protected function getChildControlsCreated() |
@@ -4913,8 +4877,7 @@ discard block |
||
| 4913 | 4877 | $this->createChildControls(); |
| 4914 | 4878 | $this->_flags &= ~self::IS_CREATING_CHILD; |
| 4915 | 4879 | $this->_flags |= self::IS_CHILD_CREATED; |
| 4916 | - } |
|
| 4917 | - catch(Exception $e) |
|
| 4880 | + } catch(Exception $e) |
|
| 4918 | 4881 | { |
| 4919 | 4882 | $this->_flags &= ~self::IS_CREATING_CHILD; |
| 4920 | 4883 | $this->_flags |= self::IS_CHILD_CREATED; |
@@ -5038,8 +5001,9 @@ discard block |
||
| 5038 | 5001 | final protected function isDescendentOf($ancestor) |
| 5039 | 5002 | { |
| 5040 | 5003 | $control=$this; |
| 5041 | - while($control!==$ancestor && $control->_parent) |
|
| 5042 | - $control=$control->_parent; |
|
| 5004 | + while($control!==$ancestor && $control->_parent) { |
|
| 5005 | + $control=$control->_parent; |
|
| 5006 | + } |
|
| 5043 | 5007 | return $control===$ancestor; |
| 5044 | 5008 | } |
| 5045 | 5009 | public function addedControl($control) |
@@ -5067,8 +5031,7 @@ discard block |
||
| 5067 | 5031 | { |
| 5068 | 5032 | $state=$this->_rf[self::RF_CHILD_STATE][$control->_id]; |
| 5069 | 5033 | unset($this->_rf[self::RF_CHILD_STATE][$control->_id]); |
| 5070 | - } |
|
| 5071 | - else |
|
| 5034 | + } else |
|
| 5072 | 5035 | $state=null; |
| 5073 | 5036 | $control->loadStateRecursive($state,!($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
| 5074 | 5037 | if($this->_stage>=self::CS_LOADED) |
@@ -5178,9 +5141,10 @@ discard block |
||
| 5178 | 5141 | $this->_id=''; |
| 5179 | 5142 | if($this->getHasControls()) |
| 5180 | 5143 | { |
| 5181 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
| 5182 | - if($control instanceof TControl) |
|
| 5144 | + foreach($this->_rf[self::RF_CONTROLS] as $control) { |
|
| 5145 | + if($control instanceof TControl) |
|
| 5183 | 5146 | $control->unloadRecursive(); |
| 5147 | + } |
|
| 5184 | 5148 | } |
| 5185 | 5149 | if(isset($this->_rf[self::RF_ADAPTER])) |
| 5186 | 5150 | $this->_rf[self::RF_ADAPTER]->onUnload(null); |
@@ -5301,8 +5265,7 @@ discard block |
||
| 5301 | 5265 | { |
| 5302 | 5266 | $this->_rf[self::RF_CONTROLSTATE]=&$state[1]; |
| 5303 | 5267 | unset($state[1]); |
| 5304 | - } |
|
| 5305 | - else |
|
| 5268 | + } else |
|
| 5306 | 5269 | unset($this->_rf[self::RF_CONTROLSTATE]); |
| 5307 | 5270 | if($needViewState) |
| 5308 | 5271 | { |
@@ -5366,17 +5329,17 @@ discard block |
||
| 5366 | 5329 | { |
| 5367 | 5330 | $page->applyControlStyleSheet($this); |
| 5368 | 5331 | $this->_flags |= self::IS_STYLESHEET_APPLIED; |
| 5369 | - } |
|
| 5370 | - else if($this->_flags & self::IS_STYLESHEET_APPLIED) |
|
| 5332 | + } else if($this->_flags & self::IS_STYLESHEET_APPLIED) |
|
| 5371 | 5333 | throw new TInvalidOperationException('control_stylesheet_applied',get_class($this)); |
| 5372 | 5334 | } |
| 5373 | 5335 | private function clearCachedUniqueID($recursive) |
| 5374 | 5336 | { |
| 5375 | 5337 | if($recursive && $this->_uid!==null && isset($this->_rf[self::RF_CONTROLS])) |
| 5376 | 5338 | { |
| 5377 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
| 5378 | - if($control instanceof TControl) |
|
| 5339 | + foreach($this->_rf[self::RF_CONTROLS] as $control) { |
|
| 5340 | + if($control instanceof TControl) |
|
| 5379 | 5341 | $control->clearCachedUniqueID($recursive); |
| 5342 | + } |
|
| 5380 | 5343 | } |
| 5381 | 5344 | $this->_uid=null; |
| 5382 | 5345 | } |
@@ -5430,8 +5393,7 @@ discard block |
||
| 5430 | 5393 | { |
| 5431 | 5394 | parent::insertAt($index,$item); |
| 5432 | 5395 | $this->_o->addedControl($item); |
| 5433 | - } |
|
| 5434 | - else if(is_string($item) || ($item instanceof IRenderable)) |
|
| 5396 | + } else if(is_string($item) || ($item instanceof IRenderable)) |
|
| 5435 | 5397 | parent::insertAt($index,$item); |
| 5436 | 5398 | else |
| 5437 | 5399 | throw new TInvalidDataTypeException('controlcollection_control_required'); |
@@ -5591,8 +5553,7 @@ discard block |
||
| 5591 | 5553 | else if($item[0]===self::TYPE_DATABINDING) |
| 5592 | 5554 | $this->_bindings[$id]=$item[1]; |
| 5593 | 5555 | $this->_items[$id]=''; |
| 5594 | - } |
|
| 5595 | - else |
|
| 5556 | + } else |
|
| 5596 | 5557 | $this->_items[$id]=$item; |
| 5597 | 5558 | } |
| 5598 | 5559 | } |
@@ -5607,16 +5568,19 @@ discard block |
||
| 5607 | 5568 | public function evaluateDynamicContent() |
| 5608 | 5569 | { |
| 5609 | 5570 | $context=$this->_container===null?$this:$this->_container; |
| 5610 | - foreach($this->_expressions as $id=>$expression) |
|
| 5611 | - $this->_items[$id]=$context->evaluateExpression($expression); |
|
| 5612 | - foreach($this->_statements as $id=>$statement) |
|
| 5613 | - $this->_items[$id]=$context->evaluateStatements($statement); |
|
| 5571 | + foreach($this->_expressions as $id=>$expression) { |
|
| 5572 | + $this->_items[$id]=$context->evaluateExpression($expression); |
|
| 5573 | + } |
|
| 5574 | + foreach($this->_statements as $id=>$statement) { |
|
| 5575 | + $this->_items[$id]=$context->evaluateStatements($statement); |
|
| 5576 | + } |
|
| 5614 | 5577 | } |
| 5615 | 5578 | public function dataBind() |
| 5616 | 5579 | { |
| 5617 | 5580 | $context=$this->_container===null?$this:$this->_container; |
| 5618 | - foreach($this->_bindings as $id=>$binding) |
|
| 5619 | - $this->_items[$id]=$context->evaluateExpression($binding); |
|
| 5581 | + foreach($this->_bindings as $id=>$binding) { |
|
| 5582 | + $this->_items[$id]=$context->evaluateExpression($binding); |
|
| 5583 | + } |
|
| 5620 | 5584 | } |
| 5621 | 5585 | public function render($writer) |
| 5622 | 5586 | { |
@@ -6678,8 +6642,9 @@ discard block |
||
| 6678 | 6642 | $style->addAttributesToRender($writer); |
| 6679 | 6643 | if($this->getHasAttributes()) |
| 6680 | 6644 | { |
| 6681 | - foreach($this->getAttributes() as $name=>$value) |
|
| 6682 | - $writer->addAttribute($name,$value); |
|
| 6645 | + foreach($this->getAttributes() as $name=>$value) { |
|
| 6646 | + $writer->addAttribute($name,$value); |
|
| 6647 | + } |
|
| 6683 | 6648 | } |
| 6684 | 6649 | } |
| 6685 | 6650 | public function render($writer) |
@@ -6739,8 +6704,7 @@ discard block |
||
| 6739 | 6704 | if(!isset(self::$_template[$class])) |
| 6740 | 6705 | self::$_template[$class]=$this->loadTemplate(); |
| 6741 | 6706 | return self::$_template[$class]; |
| 6742 | - } |
|
| 6743 | - else |
|
| 6707 | + } else |
|
| 6744 | 6708 | return $this->_localTemplate; |
| 6745 | 6709 | } |
| 6746 | 6710 | public function setTemplate($value) |
@@ -6814,8 +6778,7 @@ discard block |
||
| 6814 | 6778 | $controls=$placeholder->getParent()->getControls(); |
| 6815 | 6779 | $loc=$controls->remove($placeholder); |
| 6816 | 6780 | $controls->insertAt($loc,$content); |
| 6817 | - } |
|
| 6818 | - else |
|
| 6781 | + } else |
|
| 6819 | 6782 | throw new TConfigurationException('templatecontrol_placeholder_inexistent',$id); |
| 6820 | 6783 | } |
| 6821 | 6784 | protected function initRecursive($namingContainer=null) |
@@ -6830,10 +6793,10 @@ discard block |
||
| 6830 | 6793 | $this->getControls()->clear(); |
| 6831 | 6794 | $this->getControls()->add($master); |
| 6832 | 6795 | $master->ensureChildControls(); |
| 6833 | - foreach($this->_contents as $id=>$content) |
|
| 6834 | - $master->injectContent($id,$content); |
|
| 6835 | - } |
|
| 6836 | - else if(!empty($this->_contents)) |
|
| 6796 | + foreach($this->_contents as $id=>$content) { |
|
| 6797 | + $master->injectContent($id,$content); |
|
| 6798 | + } |
|
| 6799 | + } else if(!empty($this->_contents)) |
|
| 6837 | 6800 | throw new TConfigurationException('templatecontrol_mastercontrol_required',get_class($this)); |
| 6838 | 6801 | parent::initRecursive($namingContainer); |
| 6839 | 6802 | } |
@@ -6853,8 +6816,7 @@ discard block |
||
| 6853 | 6816 | $control->Checked = (boolean) $arObj->{$key}; |
| 6854 | 6817 | elseif ($control instanceof TDatePicker) |
| 6855 | 6818 | $control->Date = $arObj->{$key}; |
| 6856 | - } |
|
| 6857 | - else |
|
| 6819 | + } else |
|
| 6858 | 6820 | { |
| 6859 | 6821 | foreach ($objAttrs["RELATIONS"] as $relKey => $relValues) |
| 6860 | 6822 | { |
@@ -6876,8 +6838,7 @@ discard block |
||
| 6876 | 6838 | } |
| 6877 | 6839 | break; |
| 6878 | 6840 | } |
| 6879 | - } |
|
| 6880 | - catch (Exception $ex) |
|
| 6841 | + } catch (Exception $ex) |
|
| 6881 | 6842 | { |
| 6882 | 6843 | if ($throwExceptions) |
| 6883 | 6844 | throw $ex; |
@@ -6900,8 +6861,7 @@ discard block |
||
| 6900 | 6861 | $arObj->{$key} = $control->Checked; |
| 6901 | 6862 | elseif ($control instanceof TDatePicker) |
| 6902 | 6863 | $arObj->{$key} = $control->Date; |
| 6903 | - } |
|
| 6904 | - catch (Exception $ex) |
|
| 6864 | + } catch (Exception $ex) |
|
| 6905 | 6865 | { |
| 6906 | 6866 | if ($throwExceptions) |
| 6907 | 6867 | throw $ex; |
@@ -6952,8 +6912,7 @@ discard block |
||
| 6952 | 6912 | $page->endFormRender($writer); |
| 6953 | 6913 | $cs->renderScriptFilesEnd($writer); |
| 6954 | 6914 | $cs->renderEndScripts($writer); |
| 6955 | - } |
|
| 6956 | - else |
|
| 6915 | + } else |
|
| 6957 | 6916 | { |
| 6958 | 6917 | $cs->renderHiddenFieldsBegin($writer); |
| 6959 | 6918 | $page->beginFormRender($writer); |
@@ -7059,10 +7018,11 @@ discard block |
||
| 7059 | 7018 | { |
| 7060 | 7019 | foreach (self::$_pradoScripts[$p] as $dep) |
| 7061 | 7020 | { |
| 7062 | - foreach (self::$_pradoPackages[$dep] as $script) |
|
| 7063 | - if (!isset($this->_expandedPradoScripts[$script])) |
|
| 7021 | + foreach (self::$_pradoPackages[$dep] as $script) { |
|
| 7022 | + if (!isset($this->_expandedPradoScripts[$script])) |
|
| 7064 | 7023 | { |
| 7065 | 7024 | $this->_expandedPradoScripts[$script] = true; |
| 7025 | + } |
|
| 7066 | 7026 | if($isDebug) |
| 7067 | 7027 | { |
| 7068 | 7028 | if (!in_array($url=$baseUrl.'/'.$script,$packagesUrl)) |
@@ -7084,8 +7044,9 @@ discard block |
||
| 7084 | 7044 | } |
| 7085 | 7045 | } |
| 7086 | 7046 | } |
| 7087 | - foreach($packagesUrl as $url) |
|
| 7088 | - $this->registerScriptFile($url,$url); |
|
| 7047 | + foreach($packagesUrl as $url) { |
|
| 7048 | + $this->registerScriptFile($url,$url); |
|
| 7049 | + } |
|
| 7089 | 7050 | } |
| 7090 | 7051 | } |
| 7091 | 7052 | } |
@@ -7111,8 +7072,7 @@ discard block |
||
| 7111 | 7072 | $base = $dir; |
| 7112 | 7073 | } |
| 7113 | 7074 | return array($assets->getPublishedPath($base), $assets->publishFilePath($base)); |
| 7114 | - } |
|
| 7115 | - else |
|
| 7075 | + } else |
|
| 7116 | 7076 | { |
| 7117 | 7077 | return array($assets->getBasePath().str_replace($assets->getBaseUrl(),'',$base), $base); |
| 7118 | 7078 | } |
@@ -7208,9 +7168,10 @@ discard block |
||
| 7208 | 7168 | return is_array($e) ? $e[0] : $e; |
| 7209 | 7169 | }, $this->_styleSheetFiles) |
| 7210 | 7170 | ); |
| 7211 | - foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path=>$url) |
|
| 7212 | - if (substr($url,strlen($url)-4)=='.css') |
|
| 7171 | + foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path=>$url) { |
|
| 7172 | + if (substr($url,strlen($url)-4)=='.css') |
|
| 7213 | 7173 | $stylesheets[] = $url; |
| 7174 | + } |
|
| 7214 | 7175 | $stylesheets = array_unique($stylesheets); |
| 7215 | 7176 | return $stylesheets; |
| 7216 | 7177 | } |
@@ -7398,10 +7359,10 @@ discard block |
||
| 7398 | 7359 | $id=strtr($name,':','_'); |
| 7399 | 7360 | if(is_array($value)) |
| 7400 | 7361 | { |
| 7401 | - foreach($value as $v) |
|
| 7402 | - $str.='<input type="hidden" name="'.$name.'[]" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
|
| 7403 | - } |
|
| 7404 | - else |
|
| 7362 | + foreach($value as $v) { |
|
| 7363 | + $str.='<input type="hidden" name="'.$name.'[]" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
|
| 7364 | + } |
|
| 7365 | + } else |
|
| 7405 | 7366 | { |
| 7406 | 7367 | $str.='<input type="hidden" name="'.$name.'" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
| 7407 | 7368 | } |
@@ -7510,8 +7471,7 @@ discard block |
||
| 7510 | 7471 | $this->processCallbackRequest($writer); |
| 7511 | 7472 | else |
| 7512 | 7473 | $this->processPostBackRequest($writer); |
| 7513 | - } |
|
| 7514 | - else |
|
| 7474 | + } else |
|
| 7515 | 7475 | $this->processNormalRequest($writer); |
| 7516 | 7476 | $this->_writer = null; |
| 7517 | 7477 | } |
@@ -7555,8 +7515,9 @@ discard block |
||
| 7555 | 7515 | { |
| 7556 | 7516 | if(is_array($data)) |
| 7557 | 7517 | { |
| 7558 | - foreach($data as $k=>$v) |
|
| 7559 | - $data[$k]=self::decodeUTF8($v, $enc); |
|
| 7518 | + foreach($data as $k=>$v) { |
|
| 7519 | + $data[$k]=self::decodeUTF8($v, $enc); |
|
| 7520 | + } |
|
| 7560 | 7521 | return $data; |
| 7561 | 7522 | } elseif(is_string($data)) { |
| 7562 | 7523 | return iconv('UTF-8',$enc.'//IGNORE',$data); |
@@ -7574,8 +7535,9 @@ discard block |
||
| 7574 | 7535 | $this->_postData[TPage::FIELD_CALLBACK_PARAMETER]=TJavaScript::jsonDecode((string)$callbackEventParameter); |
| 7575 | 7536 | if (($g=$this->getApplication()->getGlobalization(false))!==null && |
| 7576 | 7537 | strtoupper($enc=$g->getCharset())!='UTF-8') |
| 7577 | - foreach ($this->_postData as $k=>$v) |
|
| 7578 | - $this->_postData[$k]=self::decodeUTF8($v, $enc); |
|
| 7538 | + foreach ($this->_postData as $k=>$v) { |
|
| 7539 | + $this->_postData[$k]=self::decodeUTF8($v, $enc); |
|
| 7540 | + } |
|
| 7579 | 7541 | $this->onPreInit(null); |
| 7580 | 7542 | $this->initRecursive(); |
| 7581 | 7543 | $this->onInitComplete(null); |
@@ -7642,9 +7604,10 @@ discard block |
||
| 7642 | 7604 | else |
| 7643 | 7605 | { |
| 7644 | 7606 | $list=new TList; |
| 7645 | - foreach($this->_validators as $validator) |
|
| 7646 | - if($validator->getValidationGroup()===$validationGroup) |
|
| 7607 | + foreach($this->_validators as $validator) { |
|
| 7608 | + if($validator->getValidationGroup()===$validationGroup) |
|
| 7647 | 7609 | $list->add($validator); |
| 7610 | + } |
|
| 7648 | 7611 | return $list; |
| 7649 | 7612 | } |
| 7650 | 7613 | } |
@@ -7655,10 +7618,10 @@ discard block |
||
| 7655 | 7618 | { |
| 7656 | 7619 | if($validationGroup===null) |
| 7657 | 7620 | { |
| 7658 | - foreach($this->_validators as $validator) |
|
| 7659 | - $validator->validate(); |
|
| 7660 | - } |
|
| 7661 | - else |
|
| 7621 | + foreach($this->_validators as $validator) { |
|
| 7622 | + $validator->validate(); |
|
| 7623 | + } |
|
| 7624 | + } else |
|
| 7662 | 7625 | { |
| 7663 | 7626 | foreach($this->_validators as $validator) |
| 7664 | 7627 | { |
@@ -7674,13 +7637,13 @@ discard block |
||
| 7674 | 7637 | { |
| 7675 | 7638 | if($this->_validators && $this->_validators->getCount()) |
| 7676 | 7639 | { |
| 7677 | - foreach($this->_validators as $validator) |
|
| 7678 | - if(!$validator->getIsValid()) |
|
| 7640 | + foreach($this->_validators as $validator) { |
|
| 7641 | + if(!$validator->getIsValid()) |
|
| 7679 | 7642 | return false; |
| 7643 | + } |
|
| 7680 | 7644 | } |
| 7681 | 7645 | return true; |
| 7682 | - } |
|
| 7683 | - else |
|
| 7646 | + } else |
|
| 7684 | 7647 | throw new TInvalidOperationException('page_isvalid_unknown'); |
| 7685 | 7648 | } |
| 7686 | 7649 | public function getTheme() |
@@ -7749,18 +7712,22 @@ discard block |
||
| 7749 | 7712 | $theme=$this->getTheme(); |
| 7750 | 7713 | if($theme instanceof ITheme) |
| 7751 | 7714 | { |
| 7752 | - foreach($theme->getStyleSheetFiles() as $url) |
|
| 7753 | - $cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url)); |
|
| 7754 | - foreach($theme->getJavaScriptFiles() as $url) |
|
| 7755 | - $cs->registerHeadScriptFile($url,$url); |
|
| 7715 | + foreach($theme->getStyleSheetFiles() as $url) { |
|
| 7716 | + $cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url)); |
|
| 7717 | + } |
|
| 7718 | + foreach($theme->getJavaScriptFiles() as $url) { |
|
| 7719 | + $cs->registerHeadScriptFile($url,$url); |
|
| 7720 | + } |
|
| 7756 | 7721 | } |
| 7757 | 7722 | $styleSheet=$this->getStyleSheetTheme(); |
| 7758 | 7723 | if($styleSheet instanceof ITheme) |
| 7759 | 7724 | { |
| 7760 | - foreach($styleSheet->getStyleSheetFiles() as $url) |
|
| 7761 | - $cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url)); |
|
| 7762 | - foreach($styleSheet->getJavaScriptFiles() as $url) |
|
| 7763 | - $cs->registerHeadScriptFile($url,$url); |
|
| 7725 | + foreach($styleSheet->getStyleSheetFiles() as $url) { |
|
| 7726 | + $cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url)); |
|
| 7727 | + } |
|
| 7728 | + foreach($styleSheet->getJavaScriptFiles() as $url) { |
|
| 7729 | + $cs->registerHeadScriptFile($url,$url); |
|
| 7730 | + } |
|
| 7764 | 7731 | } |
| 7765 | 7732 | if($cs->getRequiresHead() && $this->getHead()===null) |
| 7766 | 7733 | throw new TConfigurationException('page_head_required'); |
@@ -7820,8 +7787,9 @@ discard block |
||
| 7820 | 7787 | $id=is_string($control)?$control:$control->getUniqueID(); |
| 7821 | 7788 | $this->_controlsRegisteredForPostData[$id]=true; |
| 7822 | 7789 | $params=func_get_args(); |
| 7823 | - foreach($this->getCachingStack() as $item) |
|
| 7824 | - $item->registerAction('Page','registerRequiresPostData',array($id)); |
|
| 7790 | + foreach($this->getCachingStack() as $item) { |
|
| 7791 | + $item->registerAction('Page','registerRequiresPostData',array($id)); |
|
| 7792 | + } |
|
| 7825 | 7793 | } |
| 7826 | 7794 | public function getPostBackEventTarget() |
| 7827 | 7795 | { |
@@ -7865,14 +7833,12 @@ discard block |
||
| 7865 | 7833 | { |
| 7866 | 7834 | if($control->loadPostData($key,$postData)) |
| 7867 | 7835 | $this->_controlsPostDataChanged[]=$control; |
| 7868 | - } |
|
| 7869 | - else if($control instanceof IPostBackEventHandler && |
|
| 7836 | + } else if($control instanceof IPostBackEventHandler && |
|
| 7870 | 7837 | empty($this->_postData[self::FIELD_POSTBACK_TARGET])) |
| 7871 | 7838 | { |
| 7872 | 7839 | $this->_postData->add(self::FIELD_POSTBACK_TARGET,$key); } |
| 7873 | 7840 | unset($this->_controlsRequiringPostData[$key]); |
| 7874 | - } |
|
| 7875 | - else if($beforeLoad) |
|
| 7841 | + } else if($beforeLoad) |
|
| 7876 | 7842 | $this->_restPostData->add($key,$value); |
| 7877 | 7843 | } |
| 7878 | 7844 | foreach($this->_controlsRequiringPostData as $key=>$value) |
@@ -7883,8 +7849,7 @@ discard block |
||
| 7883 | 7849 | { |
| 7884 | 7850 | if($control->loadPostData($key,$this->_postData)) |
| 7885 | 7851 | $this->_controlsPostDataChanged[]=$control; |
| 7886 | - } |
|
| 7887 | - else |
|
| 7852 | + } else |
|
| 7888 | 7853 | throw new TInvalidDataValueException('page_postbackcontrol_invalid',$key); |
| 7889 | 7854 | unset($this->_controlsRequiringPostData[$key]); |
| 7890 | 7855 | } |
@@ -7897,8 +7862,9 @@ discard block |
||
| 7897 | 7862 | } |
| 7898 | 7863 | protected function raiseChangedEvents() |
| 7899 | 7864 | { |
| 7900 | - foreach($this->_controlsPostDataChanged as $control) |
|
| 7901 | - $control->raisePostDataChangedEvent(); |
|
| 7865 | + foreach($this->_controlsPostDataChanged as $control) { |
|
| 7866 | + $control->raisePostDataChangedEvent(); |
|
| 7867 | + } |
|
| 7902 | 7868 | } |
| 7903 | 7869 | protected function raisePostBackEvent() |
| 7904 | 7870 | { |
@@ -7933,8 +7899,7 @@ discard block |
||
| 7933 | 7899 | else |
| 7934 | 7900 | $focus=$this->_focus; |
| 7935 | 7901 | $this->getClientScript()->registerFocusControl($focus); |
| 7936 | - } |
|
| 7937 | - else if($this->_postData && ($lastFocus=$this->_postData->itemAt(self::FIELD_LASTFOCUS))!==null) |
|
| 7902 | + } else if($this->_postData && ($lastFocus=$this->_postData->itemAt(self::FIELD_LASTFOCUS))!==null) |
|
| 7938 | 7903 | $this->getClientScript()->registerFocusControl($lastFocus); |
| 7939 | 7904 | $this->_inFormRender=false; |
| 7940 | 7905 | } |
@@ -8046,8 +8011,9 @@ discard block |
||
| 8046 | 8011 | { |
| 8047 | 8012 | if($this->_cachingStack) |
| 8048 | 8013 | { |
| 8049 | - foreach($this->_cachingStack as $cache) |
|
| 8050 | - $cache->registerAction($context,$funcName,$funcParams); |
|
| 8014 | + foreach($this->_cachingStack as $cache) { |
|
| 8015 | + $cache->registerAction($context,$funcName,$funcParams); |
|
| 8016 | + } |
|
| 8051 | 8017 | } |
| 8052 | 8018 | } |
| 8053 | 8019 | public function getCachingStack() |
@@ -8100,8 +8066,7 @@ discard block |
||
| 8100 | 8066 | { |
| 8101 | 8067 | if(($str=$sm->validateData($str))!==false) |
| 8102 | 8068 | return unserialize($str); |
| 8103 | - } |
|
| 8104 | - else |
|
| 8069 | + } else |
|
| 8105 | 8070 | return unserialize($str); |
| 8106 | 8071 | } |
| 8107 | 8072 | return null; |
@@ -8142,8 +8107,7 @@ discard block |
||
| 8142 | 8107 | $this->_cache=$this->getApplication()->getModule($this->_cacheModuleID); |
| 8143 | 8108 | if(!($this->_cache instanceof ICache)) |
| 8144 | 8109 | throw new TConfigurationException('outputcache_cachemoduleid_invalid',$this->_cacheModuleID); |
| 8145 | - } |
|
| 8146 | - else |
|
| 8110 | + } else |
|
| 8147 | 8111 | $this->_cache=$this->getApplication()->getCache(); |
| 8148 | 8112 | if($this->_cache!==null) |
| 8149 | 8113 | { |
@@ -8155,8 +8119,7 @@ discard block |
||
| 8155 | 8119 | $param->setCacheTime(isset($data[3])?$data[3]:0); |
| 8156 | 8120 | $this->onCheckDependency($param); |
| 8157 | 8121 | $this->_dataCached=$param->getIsValid(); |
| 8158 | - } |
|
| 8159 | - else |
|
| 8122 | + } else |
|
| 8160 | 8123 | $this->_dataCached=false; |
| 8161 | 8124 | if($this->_dataCached) |
| 8162 | 8125 | list($this->_contents,$this->_state,$this->_actions,$this->_cacheTime)=$data; |
@@ -8172,8 +8135,7 @@ discard block |
||
| 8172 | 8135 | $stack->push($this); |
| 8173 | 8136 | parent::initRecursive($namingContainer); |
| 8174 | 8137 | $stack->pop(); |
| 8175 | - } |
|
| 8176 | - else |
|
| 8138 | + } else |
|
| 8177 | 8139 | parent::initRecursive($namingContainer); |
| 8178 | 8140 | } |
| 8179 | 8141 | protected function loadRecursive() |
@@ -8184,8 +8146,7 @@ discard block |
||
| 8184 | 8146 | $stack->push($this); |
| 8185 | 8147 | parent::loadRecursive(); |
| 8186 | 8148 | $stack->pop(); |
| 8187 | - } |
|
| 8188 | - else |
|
| 8149 | + } else |
|
| 8189 | 8150 | { |
| 8190 | 8151 | if($this->_dataCached) |
| 8191 | 8152 | $this->performActions(); |
@@ -8214,8 +8175,7 @@ discard block |
||
| 8214 | 8175 | $stack->push($this); |
| 8215 | 8176 | parent::preRenderRecursive(); |
| 8216 | 8177 | $stack->pop(); |
| 8217 | - } |
|
| 8218 | - else |
|
| 8178 | + } else |
|
| 8219 | 8179 | parent::preRenderRecursive(); |
| 8220 | 8180 | } |
| 8221 | 8181 | protected function loadStateRecursive(&$state,$needViewState=true) |
@@ -8351,8 +8311,7 @@ discard block |
||
| 8351 | 8311 | $content=$textwriter->flush(); |
| 8352 | 8312 | $data=array($content,$this->_state,$this->_actions,time()); |
| 8353 | 8313 | $this->_cache->set($this->getCacheKey(),$data,$this->getDuration(),$this->getCacheDependency()); |
| 8354 | - } |
|
| 8355 | - else |
|
| 8314 | + } else |
|
| 8356 | 8315 | parent::render($writer); |
| 8357 | 8316 | } |
| 8358 | 8317 | } |
@@ -8398,13 +8357,15 @@ discard block |
||
| 8398 | 8357 | } |
| 8399 | 8358 | public function write($s) |
| 8400 | 8359 | { |
| 8401 | - foreach($this->_writers as $writer) |
|
| 8402 | - $writer->write($s); |
|
| 8360 | + foreach($this->_writers as $writer) { |
|
| 8361 | + $writer->write($s); |
|
| 8362 | + } |
|
| 8403 | 8363 | } |
| 8404 | 8364 | public function flush() |
| 8405 | 8365 | { |
| 8406 | - foreach($this->_writers as $writer) |
|
| 8407 | - $s = $writer->flush(); |
|
| 8366 | + foreach($this->_writers as $writer) { |
|
| 8367 | + $s = $writer->flush(); |
|
| 8368 | + } |
|
| 8408 | 8369 | return $s; |
| 8409 | 8370 | } |
| 8410 | 8371 | } |
@@ -8452,13 +8413,13 @@ discard block |
||
| 8452 | 8413 | $includedFiles=$template->getIncludedFiles(); |
| 8453 | 8414 | $timestamps=array(); |
| 8454 | 8415 | $timestamps[$fileName]=filemtime($fileName); |
| 8455 | - foreach($includedFiles as $includedFile) |
|
| 8456 | - $timestamps[$includedFile]=filemtime($includedFile); |
|
| 8416 | + foreach($includedFiles as $includedFile) { |
|
| 8417 | + $timestamps[$includedFile]=filemtime($includedFile); |
|
| 8418 | + } |
|
| 8457 | 8419 | $cache->set(self::TEMPLATE_CACHE_PREFIX.$fileName,array($template,$timestamps)); |
| 8458 | 8420 | return $template; |
| 8459 | 8421 | } |
| 8460 | - } |
|
| 8461 | - else |
|
| 8422 | + } else |
|
| 8462 | 8423 | return null; |
| 8463 | 8424 | } |
| 8464 | 8425 | protected function getLocalizedTemplate($filename) |
@@ -8569,8 +8530,9 @@ discard block |
||
| 8569 | 8530 | } |
| 8570 | 8531 | $component->trackViewState(false); |
| 8571 | 8532 | $component->applyStyleSheetSkin($page); |
| 8572 | - foreach($properties as $name=>$value) |
|
| 8573 | - $this->configureControl($component,$name,$value); |
|
| 8533 | + foreach($properties as $name=>$value) { |
|
| 8534 | + $this->configureControl($component,$name,$value); |
|
| 8535 | + } |
|
| 8574 | 8536 | $component->trackViewState(true); |
| 8575 | 8537 | if($parent===$parentControl) |
| 8576 | 8538 | $directChildren[]=$component; |
@@ -8578,8 +8540,7 @@ discard block |
||
| 8578 | 8540 | $component->createdOnTemplate($parent); |
| 8579 | 8541 | if($component->getAllowChildControls()) |
| 8580 | 8542 | $controls[$key]=$component; |
| 8581 | - } |
|
| 8582 | - else if($component instanceof TComponent) |
|
| 8543 | + } else if($component instanceof TComponent) |
|
| 8583 | 8544 | { |
| 8584 | 8545 | $controls[$key]=$component; |
| 8585 | 8546 | if(isset($properties['id'])) |
@@ -8590,15 +8551,15 @@ discard block |
||
| 8590 | 8551 | if(!$component->hasProperty('id')) |
| 8591 | 8552 | unset($properties['id']); |
| 8592 | 8553 | } |
| 8593 | - foreach($properties as $name=>$value) |
|
| 8594 | - $this->configureComponent($component,$name,$value); |
|
| 8554 | + foreach($properties as $name=>$value) { |
|
| 8555 | + $this->configureComponent($component,$name,$value); |
|
| 8556 | + } |
|
| 8595 | 8557 | if($parent===$parentControl) |
| 8596 | 8558 | $directChildren[]=$component; |
| 8597 | 8559 | else |
| 8598 | 8560 | $component->createdOnTemplate($parent); |
| 8599 | 8561 | } |
| 8600 | - } |
|
| 8601 | - else |
|
| 8562 | + } else |
|
| 8602 | 8563 | { |
| 8603 | 8564 | if($object[1] instanceof TCompositeLiteral) |
| 8604 | 8565 | { |
@@ -8608,8 +8569,7 @@ discard block |
||
| 8608 | 8569 | $directChildren[]=$o; |
| 8609 | 8570 | else |
| 8610 | 8571 | $parent->addParsedObject($o); |
| 8611 | - } |
|
| 8612 | - else |
|
| 8572 | + } else |
|
| 8613 | 8573 | { |
| 8614 | 8574 | if($parent===$parentControl) |
| 8615 | 8575 | $directChildren[]=$object[1]; |
@@ -8680,8 +8640,7 @@ discard block |
||
| 8680 | 8640 | default: throw new TConfigurationException('template_tag_unexpected',$name,$value[1]); |
| 8681 | 8641 | break; |
| 8682 | 8642 | } |
| 8683 | - } |
|
| 8684 | - else |
|
| 8643 | + } else |
|
| 8685 | 8644 | { |
| 8686 | 8645 | if (substr($name,0,2)=='js') |
| 8687 | 8646 | if ($value and !($value instanceof TJavaScriptLiteral)) |
@@ -8717,8 +8676,7 @@ discard block |
||
| 8717 | 8676 | default: throw new TConfigurationException('template_tag_unexpected',$name,$value[1]); |
| 8718 | 8677 | break; |
| 8719 | 8678 | } |
| 8720 | - } |
|
| 8721 | - else |
|
| 8679 | + } else |
|
| 8722 | 8680 | $component->setSubProperty($name,$value); |
| 8723 | 8681 | } |
| 8724 | 8682 | protected function parse($input) |
@@ -8755,8 +8713,7 @@ discard block |
||
| 8755 | 8713 | $stack[] = $type; |
| 8756 | 8714 | $container=$c-1; |
| 8757 | 8715 | } |
| 8758 | - } |
|
| 8759 | - else if(strpos($str,'</com:')===0) { |
|
| 8716 | + } else if(strpos($str,'</com:')===0) { |
|
| 8760 | 8717 | if($expectPropEnd) |
| 8761 | 8718 | continue; |
| 8762 | 8719 | if($matchStart>$textStart) |
@@ -8772,8 +8729,7 @@ discard block |
||
| 8772 | 8729 | throw new TConfigurationException('template_closingtag_expected',$tag); |
| 8773 | 8730 | } |
| 8774 | 8731 | $container=$tpl[$container][0]; |
| 8775 | - } |
|
| 8776 | - else if(strpos($str,'<%@')===0) { |
|
| 8732 | + } else if(strpos($str,'<%@')===0) { |
|
| 8777 | 8733 | if($expectPropEnd) |
| 8778 | 8734 | continue; |
| 8779 | 8735 | if($matchStart>$textStart) |
@@ -8782,8 +8738,7 @@ discard block |
||
| 8782 | 8738 | if(isset($tpl[0]) || $this->_directive!==null) |
| 8783 | 8739 | throw new TConfigurationException('template_directive_nonunique'); |
| 8784 | 8740 | $this->_directive=$this->parseAttributes($match[4][0],$match[4][1]); |
| 8785 | - } |
|
| 8786 | - else if(strpos($str,'<%')===0) { |
|
| 8741 | + } else if(strpos($str,'<%')===0) { |
|
| 8787 | 8742 | if($expectPropEnd) |
| 8788 | 8743 | continue; |
| 8789 | 8744 | if($matchStart>$textStart) |
@@ -8805,8 +8760,7 @@ discard block |
||
| 8805 | 8760 | $literal=strtr(trim(substr($literal,0,strlen($literal)-1)),array("'"=>"\'","\\"=>"\\\\")); |
| 8806 | 8761 | $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"Prado::localize('$literal')")); |
| 8807 | 8762 | } |
| 8808 | - } |
|
| 8809 | - else if(strpos($str,'<prop:')===0) { |
|
| 8763 | + } else if(strpos($str,'<prop:')===0) { |
|
| 8810 | 8764 | if(strrpos($str,'/>')===strlen($str)-2) { |
| 8811 | 8765 | if($expectPropEnd) |
| 8812 | 8766 | continue; |
@@ -8816,8 +8770,9 @@ discard block |
||
| 8816 | 8770 | $prop=strtolower($match[6][0]); |
| 8817 | 8771 | $attrs=$this->parseAttributes($match[7][0],$match[7][1]); |
| 8818 | 8772 | $attributes=array(); |
| 8819 | - foreach($attrs as $name=>$value) |
|
| 8820 | - $attributes[$prop.'.'.$name]=$value; |
|
| 8773 | + foreach($attrs as $name=>$value) { |
|
| 8774 | + $attributes[$prop.'.'.$name]=$value; |
|
| 8775 | + } |
|
| 8821 | 8776 | $type=$tpl[$container][1]; |
| 8822 | 8777 | $this->validateAttributes($type,$attributes); |
| 8823 | 8778 | foreach($attributes as $name=>$value) |
@@ -8826,8 +8781,7 @@ discard block |
||
| 8826 | 8781 | throw new TConfigurationException('template_property_duplicated',$name); |
| 8827 | 8782 | $tpl[$container][2][$name]=$value; |
| 8828 | 8783 | } |
| 8829 | - } |
|
| 8830 | - else { |
|
| 8784 | + } else { |
|
| 8831 | 8785 | $prop=strtolower($match[3][0]); |
| 8832 | 8786 | $stack[] = '@'.$prop; |
| 8833 | 8787 | if(!$expectPropEnd) |
@@ -8838,8 +8792,7 @@ discard block |
||
| 8838 | 8792 | $expectPropEnd=true; |
| 8839 | 8793 | } |
| 8840 | 8794 | } |
| 8841 | - } |
|
| 8842 | - else if(strpos($str,'</prop:')===0) { |
|
| 8795 | + } else if(strpos($str,'</prop:')===0) { |
|
| 8843 | 8796 | $prop=strtolower($match[3][0]); |
| 8844 | 8797 | if(empty($stack)) |
| 8845 | 8798 | throw new TConfigurationException('template_closingtag_unexpected',"</prop:$prop>"); |
@@ -8865,21 +8818,18 @@ discard block |
||
| 8865 | 8818 | if(isset($tpl[$container][2][$prop])) |
| 8866 | 8819 | throw new TConfigurationException('template_property_duplicated',$prop); |
| 8867 | 8820 | $tpl[$container][2][$prop]=$value; |
| 8868 | - } |
|
| 8869 | - else $this->_directive[$prop]=$value; |
|
| 8821 | + } else $this->_directive[$prop]=$value; |
|
| 8870 | 8822 | $textStart=$matchEnd+1; |
| 8871 | 8823 | } |
| 8872 | 8824 | $expectPropEnd=false; |
| 8873 | 8825 | } |
| 8874 | - } |
|
| 8875 | - else if(strpos($str,'<!--')===0) { |
|
| 8826 | + } else if(strpos($str,'<!--')===0) { |
|
| 8876 | 8827 | if($expectPropEnd) |
| 8877 | 8828 | throw new TConfigurationException('template_comments_forbidden'); |
| 8878 | 8829 | if($matchStart>$textStart) |
| 8879 | 8830 | $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
| 8880 | 8831 | $textStart=$matchEnd+1; |
| 8881 | - } |
|
| 8882 | - else |
|
| 8832 | + } else |
|
| 8883 | 8833 | throw new TConfigurationException('template_matching_unexpected',$match); |
| 8884 | 8834 | } |
| 8885 | 8835 | if(!empty($stack)) |
@@ -8890,8 +8840,7 @@ discard block |
||
| 8890 | 8840 | } |
| 8891 | 8841 | if($textStart<strlen($input)) |
| 8892 | 8842 | $tpl[$c++]=array($container,substr($input,$textStart)); |
| 8893 | - } |
|
| 8894 | - catch(Exception $e) |
|
| 8843 | + } catch(Exception $e) |
|
| 8895 | 8844 | { |
| 8896 | 8845 | if(($e instanceof TException) && ($e instanceof TTemplateException)) |
| 8897 | 8846 | throw $e; |
@@ -8921,14 +8870,12 @@ discard block |
||
| 8921 | 8870 | { |
| 8922 | 8871 | $parent=null; |
| 8923 | 8872 | $objects[$id]=$object; |
| 8924 | - } |
|
| 8925 | - else |
|
| 8873 | + } else |
|
| 8926 | 8874 | { |
| 8927 | 8875 | $parent=$object[0]; |
| 8928 | 8876 | $merged=array($parent,array($object[1])); |
| 8929 | 8877 | } |
| 8930 | - } |
|
| 8931 | - else |
|
| 8878 | + } else |
|
| 8932 | 8879 | $merged[1][]=$object[1]; |
| 8933 | 8880 | } |
| 8934 | 8881 | if($parent!==null) |
@@ -8961,8 +8908,7 @@ discard block |
||
| 8961 | 8908 | $attributes[$name]=$this->parseTemplateProperty(substr($value,1,strlen($value)-2),$match[2][1]+1); |
| 8962 | 8909 | else |
| 8963 | 8910 | $attributes[$name]=$this->parseTemplateProperty($value,$match[2][1]); |
| 8964 | - } |
|
| 8965 | - else |
|
| 8911 | + } else |
|
| 8966 | 8912 | { |
| 8967 | 8913 | if($value[0]==='\'' || $value[0]==='"') |
| 8968 | 8914 | $attributes[$name]=$this->parseAttribute(substr($value,1,strlen($value)-2)); |
@@ -9004,8 +8950,7 @@ discard block |
||
| 9004 | 8950 | return array(self::CONFIG_DATABIND,ltrim($expr,'.')); |
| 9005 | 8951 | else |
| 9006 | 8952 | return array(self::CONFIG_EXPRESSION,ltrim($expr,'.')); |
| 9007 | - } |
|
| 9008 | - else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS',$value,$matches) && $matches[0]===$value) |
|
| 8953 | + } else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS',$value,$matches) && $matches[0]===$value) |
|
| 9009 | 8954 | { |
| 9010 | 8955 | $value=$matches[1]; |
| 9011 | 8956 | if($value[2]==='~') |
@@ -9018,8 +8963,7 @@ discard block |
||
| 9018 | 8963 | $literal = trim(substr($value,3,strlen($value)-5)); |
| 9019 | 8964 | return array(self::CONFIG_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'"); |
| 9020 | 8965 | } |
| 9021 | - } |
|
| 9022 | - else |
|
| 8966 | + } else |
|
| 9023 | 8967 | return $value; |
| 9024 | 8968 | } |
| 9025 | 8969 | protected function validateAttributes($type,$attributes) |
@@ -9039,15 +8983,13 @@ discard block |
||
| 9039 | 8983 | $subname=substr($name,0,$pos); |
| 9040 | 8984 | if(!$class->hasMethod('get'.$subname)) |
| 9041 | 8985 | throw new TConfigurationException('template_property_unknown',$type,$subname); |
| 9042 | - } |
|
| 9043 | - else if(strncasecmp($name,'on',2)===0) |
|
| 8986 | + } else if(strncasecmp($name,'on',2)===0) |
|
| 9044 | 8987 | { |
| 9045 | 8988 | if(!$class->hasMethod($name)) |
| 9046 | 8989 | throw new TConfigurationException('template_event_unknown',$type,$name); |
| 9047 | 8990 | else if(!is_string($att)) |
| 9048 | 8991 | throw new TConfigurationException('template_eventhandler_invalid',$type,$name); |
| 9049 | - } |
|
| 9050 | - else |
|
| 8992 | + } else |
|
| 9051 | 8993 | { |
| 9052 | 8994 | if (! ($class->hasMethod('set'.$name) || $class->hasMethod('setjs'.$name) || $this->isClassBehaviorMethod($class,'set'.$name)) ) |
| 9053 | 8995 | { |
@@ -9055,8 +8997,7 @@ discard block |
||
| 9055 | 8997 | throw new TConfigurationException('template_property_readonly',$type,$name); |
| 9056 | 8998 | else |
| 9057 | 8999 | throw new TConfigurationException('template_property_unknown',$type,$name); |
| 9058 | - } |
|
| 9059 | - else if(is_array($att) && $att[0]!==self::CONFIG_EXPRESSION) |
|
| 9000 | + } else if(is_array($att) && $att[0]!==self::CONFIG_EXPRESSION) |
|
| 9060 | 9001 | { |
| 9061 | 9002 | if(strcasecmp($name,'id')===0) |
| 9062 | 9003 | throw new TConfigurationException('template_controlid_invalid',$type); |
@@ -9065,8 +9006,7 @@ discard block |
||
| 9065 | 9006 | } |
| 9066 | 9007 | } |
| 9067 | 9008 | } |
| 9068 | - } |
|
| 9069 | - else if(is_subclass_of($className,'TComponent') || $className==='TComponent') |
|
| 9009 | + } else if(is_subclass_of($className,'TComponent') || $className==='TComponent') |
|
| 9070 | 9010 | { |
| 9071 | 9011 | foreach($attributes as $name=>$att) |
| 9072 | 9012 | { |
@@ -9077,8 +9017,7 @@ discard block |
||
| 9077 | 9017 | $subname=substr($name,0,$pos); |
| 9078 | 9018 | if(!$class->hasMethod('get'.$subname)) |
| 9079 | 9019 | throw new TConfigurationException('template_property_unknown',$type,$subname); |
| 9080 | - } |
|
| 9081 | - else if(strncasecmp($name,'on',2)===0) |
|
| 9020 | + } else if(strncasecmp($name,'on',2)===0) |
|
| 9082 | 9021 | throw new TConfigurationException('template_event_forbidden',$type,$name); |
| 9083 | 9022 | else |
| 9084 | 9023 | { |
@@ -9091,8 +9030,7 @@ discard block |
||
| 9091 | 9030 | } |
| 9092 | 9031 | } |
| 9093 | 9032 | } |
| 9094 | - } |
|
| 9095 | - else |
|
| 9033 | + } else |
|
| 9096 | 9034 | throw new TConfigurationException('template_component_required',$type); |
| 9097 | 9035 | } |
| 9098 | 9036 | public function getIncludedFiles() |
@@ -9112,8 +9050,7 @@ discard block |
||
| 9112 | 9050 | $line=$line-$this->_includeAtLine[$i]+1; |
| 9113 | 9051 | $srcFile=$this->_includedFiles[$i]; |
| 9114 | 9052 | break; |
| 9115 | - } |
|
| 9116 | - else |
|
| 9053 | + } else |
|
| 9117 | 9054 | $line=$line-$this->_includeLines[$i]+1; |
| 9118 | 9055 | } |
| 9119 | 9056 | } |
@@ -9299,8 +9236,7 @@ discard block |
||
| 9299 | 9236 | closedir($dir); |
| 9300 | 9237 | if($cacheValid) |
| 9301 | 9238 | $this->_skins=$skins; |
| 9302 | - } |
|
| 9303 | - else |
|
| 9239 | + } else |
|
| 9304 | 9240 | { |
| 9305 | 9241 | $cacheValid=true; |
| 9306 | 9242 | $this->_cssFiles=$cssFiles; |
@@ -9425,19 +9361,15 @@ discard block |
||
| 9425 | 9361 | { |
| 9426 | 9362 | $setter='set'.$name; |
| 9427 | 9363 | $control->$setter($value); |
| 9428 | - } |
|
| 9429 | - else |
|
| 9364 | + } else |
|
| 9430 | 9365 | throw new TConfigurationException('theme_property_readonly',$type,$name); |
| 9431 | - } |
|
| 9432 | - else |
|
| 9366 | + } else |
|
| 9433 | 9367 | throw new TConfigurationException('theme_property_undefined',$type,$name); |
| 9434 | - } |
|
| 9435 | - else $control->setSubProperty($name,$value); |
|
| 9368 | + } else $control->setSubProperty($name,$value); |
|
| 9436 | 9369 | } |
| 9437 | 9370 | } |
| 9438 | 9371 | return true; |
| 9439 | - } |
|
| 9440 | - else |
|
| 9372 | + } else |
|
| 9441 | 9373 | return false; |
| 9442 | 9374 | } |
| 9443 | 9375 | public function getStyleSheetFiles() |
@@ -9484,8 +9416,9 @@ discard block |
||
| 9484 | 9416 | protected function initPageContext($pageConfig) |
| 9485 | 9417 | { |
| 9486 | 9418 | $application=$this->getApplication(); |
| 9487 | - foreach($pageConfig->getApplicationConfigurations() as $appConfig) |
|
| 9488 | - $application->applyConfiguration($appConfig); |
|
| 9419 | + foreach($pageConfig->getApplicationConfigurations() as $appConfig) { |
|
| 9420 | + $application->applyConfiguration($appConfig); |
|
| 9421 | + } |
|
| 9489 | 9422 | $this->applyConfiguration($pageConfig); |
| 9490 | 9423 | } |
| 9491 | 9424 | protected function applyConfiguration($config) |
@@ -9530,8 +9463,7 @@ discard block |
||
| 9530 | 9463 | $pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),''); |
| 9531 | 9464 | } |
| 9532 | 9465 | $pageConfig->loadFromFiles($this->getBasePath()); |
| 9533 | - } |
|
| 9534 | - else |
|
| 9466 | + } else |
|
| 9535 | 9467 | { |
| 9536 | 9468 | $configCached=true; |
| 9537 | 9469 | $currentTimestamp=array(); |
@@ -9548,8 +9480,7 @@ discard block |
||
| 9548 | 9480 | $currentTimestamp[0]=$appConfigFile===null?0:@filemtime($appConfigFile); |
| 9549 | 9481 | if($currentTimestamp[0]>$timestamp || ($timestamp>0 && !$currentTimestamp[0])) |
| 9550 | 9482 | $configCached=false; |
| 9551 | - } |
|
| 9552 | - else |
|
| 9483 | + } else |
|
| 9553 | 9484 | { |
| 9554 | 9485 | $currentTimestamp[$fileName]=@filemtime($fileName); |
| 9555 | 9486 | if($currentTimestamp[$fileName]>$timestamp || ($timestamp>0 && !$currentTimestamp[$fileName])) |
@@ -9557,8 +9488,7 @@ discard block |
||
| 9557 | 9488 | } |
| 9558 | 9489 | } |
| 9559 | 9490 | } |
| 9560 | - } |
|
| 9561 | - else |
|
| 9491 | + } else |
|
| 9562 | 9492 | { |
| 9563 | 9493 | $configCached=false; |
| 9564 | 9494 | $paths=explode('.',$pagePath); |
@@ -9701,8 +9631,7 @@ discard block |
||
| 9701 | 9631 | $className=basename($path); |
| 9702 | 9632 | if(!class_exists($className,false)) |
| 9703 | 9633 | include_once($path.Prado::CLASS_FILE_EXT); |
| 9704 | - } |
|
| 9705 | - else |
|
| 9634 | + } else |
|
| 9706 | 9635 | { |
| 9707 | 9636 | $className=$this->getBasePageClass(); |
| 9708 | 9637 | Prado::using($className); |
@@ -9719,8 +9648,9 @@ discard block |
||
| 9719 | 9648 | } |
| 9720 | 9649 | protected function runPage($page,$properties) |
| 9721 | 9650 | { |
| 9722 | - foreach($properties as $name=>$value) |
|
| 9723 | - $page->setSubProperty($name,$value); |
|
| 9651 | + foreach($properties as $name=>$value) { |
|
| 9652 | + $page->setSubProperty($name,$value); |
|
| 9653 | + } |
|
| 9724 | 9654 | $page->run($this->getResponse()->createHtmlWriter()); |
| 9725 | 9655 | } |
| 9726 | 9656 | public function constructUrl($pagePath,$getParams=null,$encodeAmpersand=true,$encodeGetItems=true) |
@@ -9784,8 +9714,7 @@ discard block |
||
| 9784 | 9714 | { |
| 9785 | 9715 | $fcontent = include $fname; |
| 9786 | 9716 | $this->loadFromPhp($fcontent,dirname($fname),$configPagePath); |
| 9787 | - } |
|
| 9788 | - else |
|
| 9717 | + } else |
|
| 9789 | 9718 | { |
| 9790 | 9719 | $dom=new TXmlDocument; |
| 9791 | 9720 | if($dom->loadFromFile($fname)) |
@@ -10028,8 +9957,7 @@ discard block |
||
| 10028 | 9957 | if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
| 10029 | 9958 | $this->copyFile($fullpath,$dst); |
| 10030 | 9959 | return $this->_published[$path]=$this->_baseUrl.'/'.$dir.'/'.$fileName; |
| 10031 | - } |
|
| 10032 | - else |
|
| 9960 | + } else |
|
| 10033 | 9961 | { |
| 10034 | 9962 | $dir=$this->hash($fullpath); |
| 10035 | 9963 | if(!is_dir($this->_basePath.DIRECTORY_SEPARATOR.$dir) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
@@ -10100,8 +10028,7 @@ discard block |
||
| 10100 | 10028 | @copy($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
| 10101 | 10029 | @chmod($dst.DIRECTORY_SEPARATOR.$file, PRADO_CHMOD); |
| 10102 | 10030 | } |
| 10103 | - } |
|
| 10104 | - else |
|
| 10031 | + } else |
|
| 10105 | 10032 | $this->copyDirectory($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
| 10106 | 10033 | } |
| 10107 | 10034 | closedir($folder); |
@@ -10230,8 +10157,7 @@ discard block |
||
| 10230 | 10157 | throw new TConfigurationException('globalization_source_path_failed', |
| 10231 | 10158 | $config['source']); |
| 10232 | 10159 | chmod($config['source'], PRADO_CHMOD); } |
| 10233 | - } |
|
| 10234 | - else |
|
| 10160 | + } else |
|
| 10235 | 10161 | { |
| 10236 | 10162 | throw new TConfigurationException("invalid source dir '{$config['source']}'"); |
| 10237 | 10163 | } |
@@ -10261,8 +10187,9 @@ discard block |
||
| 10261 | 10187 | if($culture===null) $culture = $this->getCulture(); |
| 10262 | 10188 | $variants = explode('_', $culture); |
| 10263 | 10189 | $result = array(); |
| 10264 | - for(; count($variants) > 0; array_pop($variants)) |
|
| 10265 | - $result[] = implode('_', $variants); |
|
| 10190 | + for(; count($variants) > 0; array_pop($variants)) { |
|
| 10191 | + $result[] = implode('_', $variants); |
|
| 10192 | + } |
|
| 10266 | 10193 | return $result; |
| 10267 | 10194 | } |
| 10268 | 10195 | public function getLocalizedResource($file,$culture=null) |
@@ -10270,11 +10197,13 @@ discard block |
||
| 10270 | 10197 | $files = array(); |
| 10271 | 10198 | $variants = $this->getCultureVariants($culture); |
| 10272 | 10199 | $path = pathinfo($file); |
| 10273 | - foreach($variants as $variant) |
|
| 10274 | - $files[] = $path['dirname'].DIRECTORY_SEPARATOR.$variant.DIRECTORY_SEPARATOR.$path['basename']; |
|
| 10200 | + foreach($variants as $variant) { |
|
| 10201 | + $files[] = $path['dirname'].DIRECTORY_SEPARATOR.$variant.DIRECTORY_SEPARATOR.$path['basename']; |
|
| 10202 | + } |
|
| 10275 | 10203 | $filename = substr($path['basename'],0,strrpos($path['basename'],'.')); |
| 10276 | - foreach($variants as $variant) |
|
| 10277 | - $files[] = $path['dirname'].DIRECTORY_SEPARATOR.$filename.'.'.$variant.'.'.$path['extension']; |
|
| 10204 | + foreach($variants as $variant) { |
|
| 10205 | + $files[] = $path['dirname'].DIRECTORY_SEPARATOR.$filename.'.'.$variant.'.'.$path['extension']; |
|
| 10206 | + } |
|
| 10278 | 10207 | $files[] = $file; |
| 10279 | 10208 | return $files; |
| 10280 | 10209 | } |
@@ -10362,8 +10291,7 @@ discard block |
||
| 10362 | 10291 | { |
| 10363 | 10292 | $configFile=$basePath; |
| 10364 | 10293 | $basePath=dirname($configFile); |
| 10365 | - } |
|
| 10366 | - else |
|
| 10294 | + } else |
|
| 10367 | 10295 | $configFile=null; |
| 10368 | 10296 | $runtimePath=$basePath.DIRECTORY_SEPARATOR.self::RUNTIME_PATH; |
| 10369 | 10297 | if(is_writable($runtimePath)) |
@@ -10380,8 +10308,7 @@ discard block |
||
| 10380 | 10308 | } |
| 10381 | 10309 | $this->setBasePath($basePath); |
| 10382 | 10310 | $this->setRuntimePath($runtimePath); |
| 10383 | - } |
|
| 10384 | - else |
|
| 10311 | + } else |
|
| 10385 | 10312 | throw new TConfigurationException('application_runtimepath_invalid',$runtimePath); |
| 10386 | 10313 | } |
| 10387 | 10314 | public function run() |
@@ -10402,8 +10329,7 @@ discard block |
||
| 10402 | 10329 | $this->$method(); |
| 10403 | 10330 | $this->_step++; |
| 10404 | 10331 | } |
| 10405 | - } |
|
| 10406 | - catch(Exception $e) |
|
| 10332 | + } catch(Exception $e) |
|
| 10407 | 10333 | { |
| 10408 | 10334 | $this->onError($e); |
| 10409 | 10335 | } |
@@ -10728,14 +10654,17 @@ discard block |
||
| 10728 | 10654 | { |
| 10729 | 10655 | if($config->getIsEmpty()) |
| 10730 | 10656 | return; |
| 10731 | - foreach($config->getAliases() as $alias=>$path) |
|
| 10732 | - Prado::setPathOfAlias($alias,$path); |
|
| 10733 | - foreach($config->getUsings() as $using) |
|
| 10734 | - Prado::using($using); |
|
| 10657 | + foreach($config->getAliases() as $alias=>$path) { |
|
| 10658 | + Prado::setPathOfAlias($alias,$path); |
|
| 10659 | + } |
|
| 10660 | + foreach($config->getUsings() as $using) { |
|
| 10661 | + Prado::using($using); |
|
| 10662 | + } |
|
| 10735 | 10663 | if(!$withinService) |
| 10736 | 10664 | { |
| 10737 | - foreach($config->getProperties() as $name=>$value) |
|
| 10738 | - $this->setSubProperty($name,$value); |
|
| 10665 | + foreach($config->getProperties() as $name=>$value) { |
|
| 10666 | + $this->setSubProperty($name,$value); |
|
| 10667 | + } |
|
| 10739 | 10668 | } |
| 10740 | 10669 | if(empty($this->_services)) |
| 10741 | 10670 | $this->_services=array($this->getPageServiceID()=>array('TPageService',array(),null)); |
@@ -10744,11 +10673,11 @@ discard block |
||
| 10744 | 10673 | if(is_array($parameter)) |
| 10745 | 10674 | { |
| 10746 | 10675 | $component=Prado::createComponent($parameter[0]); |
| 10747 | - foreach($parameter[1] as $name=>$value) |
|
| 10748 | - $component->setSubProperty($name,$value); |
|
| 10676 | + foreach($parameter[1] as $name=>$value) { |
|
| 10677 | + $component->setSubProperty($name,$value); |
|
| 10678 | + } |
|
| 10749 | 10679 | $this->_parameters->add($id,$component); |
| 10750 | - } |
|
| 10751 | - else |
|
| 10680 | + } else |
|
| 10752 | 10681 | $this->_parameters->add($id,$parameter); |
| 10753 | 10682 | } |
| 10754 | 10683 | $modules=array(); |
@@ -10760,10 +10689,12 @@ discard block |
||
| 10760 | 10689 | if($module = $this->internalLoadModule($id)) |
| 10761 | 10690 | $modules[]=$module; |
| 10762 | 10691 | } |
| 10763 | - foreach($modules as $module) |
|
| 10764 | - $module[0]->init($module[1]); |
|
| 10765 | - foreach($config->getServices() as $serviceID=>$serviceConfig) |
|
| 10766 | - $this->_services[$serviceID]=$serviceConfig; |
|
| 10692 | + foreach($modules as $module) { |
|
| 10693 | + $module[0]->init($module[1]); |
|
| 10694 | + } |
|
| 10695 | + foreach($config->getServices() as $serviceID=>$serviceConfig) { |
|
| 10696 | + $this->_services[$serviceID]=$serviceConfig; |
|
| 10697 | + } |
|
| 10767 | 10698 | foreach($config->getExternalConfigurations() as $filePath=>$condition) |
| 10768 | 10699 | { |
| 10769 | 10700 | if($condition!==true) |
@@ -10789,8 +10720,7 @@ discard block |
||
| 10789 | 10720 | $config->loadFromFile($this->_configFile); |
| 10790 | 10721 | if($this->_cacheFile!==null) |
| 10791 | 10722 | file_put_contents($this->_cacheFile,serialize($config),LOCK_EX); |
| 10792 | - } |
|
| 10793 | - else |
|
| 10723 | + } else |
|
| 10794 | 10724 | $config=unserialize(file_get_contents($this->_cacheFile)); |
| 10795 | 10725 | $this->applyConfiguration($config,false); |
| 10796 | 10726 | } |
@@ -10810,8 +10740,9 @@ discard block |
||
| 10810 | 10740 | throw new THttpException(500,'application_service_unavailable',$serviceClass); |
| 10811 | 10741 | $service->setID($serviceID); |
| 10812 | 10742 | $this->setService($service); |
| 10813 | - foreach($initProperties as $name=>$value) |
|
| 10814 | - $service->setSubProperty($name,$value); |
|
| 10743 | + foreach($initProperties as $name=>$value) { |
|
| 10744 | + $service->setSubProperty($name,$value); |
|
| 10745 | + } |
|
| 10815 | 10746 | if($configElement!==null) |
| 10816 | 10747 | { |
| 10817 | 10748 | $config=new TApplicationConfiguration; |
@@ -10822,8 +10753,7 @@ discard block |
||
| 10822 | 10753 | $this->applyConfiguration($config,true); |
| 10823 | 10754 | } |
| 10824 | 10755 | $service->init($configElement); |
| 10825 | - } |
|
| 10826 | - else |
|
| 10756 | + } else |
|
| 10827 | 10757 | throw new THttpException(500,'application_service_unknown',$serviceID); |
| 10828 | 10758 | } |
| 10829 | 10759 | public function onError($param) |
@@ -10915,8 +10845,7 @@ discard block |
||
| 10915 | 10845 | { |
| 10916 | 10846 | $fcontent = include $fname; |
| 10917 | 10847 | $this->loadFromPhp($fcontent,dirname($fname)); |
| 10918 | - } |
|
| 10919 | - else |
|
| 10848 | + } else |
|
| 10920 | 10849 | { |
| 10921 | 10850 | $dom=new TXmlDocument; |
| 10922 | 10851 | $dom->loadFromFile($fname); |
@@ -11023,8 +10952,7 @@ discard block |
||
| 11023 | 10952 | if(isset($this->_aliases[$id])) |
| 11024 | 10953 | throw new TConfigurationException('appconfig_alias_redefined',$id); |
| 11025 | 10954 | $this->_aliases[$id]=$p; |
| 11026 | - } |
|
| 11027 | - else |
|
| 10955 | + } else |
|
| 11028 | 10956 | throw new TConfigurationException('appconfig_alias_invalid'); |
| 11029 | 10957 | $this->_empty=false; |
| 11030 | 10958 | break; |
@@ -11079,8 +11007,7 @@ discard block |
||
| 11079 | 11007 | else |
| 11080 | 11008 | $this->_modules[$id]=array($type,$properties->toArray(),$element); |
| 11081 | 11009 | $this->_empty=false; |
| 11082 | - } |
|
| 11083 | - else |
|
| 11010 | + } else |
|
| 11084 | 11011 | throw new TConfigurationException('appconfig_modules_invalid',$element->getTagName()); |
| 11085 | 11012 | } |
| 11086 | 11013 | } |
@@ -11112,8 +11039,7 @@ discard block |
||
| 11112 | 11039 | $element->setParent(null); |
| 11113 | 11040 | $this->_services[$id]=array($type,$properties->toArray(),$element); |
| 11114 | 11041 | $this->_empty=false; |
| 11115 | - } |
|
| 11116 | - else |
|
| 11042 | + } else |
|
| 11117 | 11043 | throw new TConfigurationException('appconfig_services_invalid',$element->getTagName()); |
| 11118 | 11044 | } |
| 11119 | 11045 | } |
@@ -11131,8 +11057,7 @@ discard block |
||
| 11131 | 11057 | $properties['id'] = $id; |
| 11132 | 11058 | $this->_parameters[$id] = array($type,$properties); |
| 11133 | 11059 | } |
| 11134 | - } |
|
| 11135 | - else |
|
| 11060 | + } else |
|
| 11136 | 11061 | { |
| 11137 | 11062 | $this->_parameters[$id] = $parameter; |
| 11138 | 11063 | } |
@@ -11153,12 +11078,10 @@ discard block |
||
| 11153 | 11078 | $this->_parameters[$id]=$element; |
| 11154 | 11079 | else |
| 11155 | 11080 | $this->_parameters[$id]=$value; |
| 11156 | - } |
|
| 11157 | - else |
|
| 11081 | + } else |
|
| 11158 | 11082 | $this->_parameters[$id]=array($type,$properties->toArray()); |
| 11159 | 11083 | $this->_empty=false; |
| 11160 | - } |
|
| 11161 | - else |
|
| 11084 | + } else |
|
| 11162 | 11085 | throw new TConfigurationException('appconfig_parameters_invalid',$element->getTagName()); |
| 11163 | 11086 | } |
| 11164 | 11087 | } |