@@ -92,43 +92,43 @@ |
||
| 92 | 92 | */ |
| 93 | 93 | $dsninfo = $this->dns; |
| 94 | 94 | |
| 95 | - if (isset($dsninfo['protocol']) && $dsninfo['protocol'] == 'unix') |
|
| 96 | - $dbhost = ':' . $dsninfo['socket']; |
|
| 97 | - else |
|
| 98 | - { |
|
| 95 | + if (isset($dsninfo['protocol']) && $dsninfo['protocol'] == 'unix') |
|
| 96 | + $dbhost = ':' . $dsninfo['socket']; |
|
| 97 | + else |
|
| 98 | + { |
|
| 99 | 99 | $dbhost = $dsninfo['hostspec'] ? $dsninfo['hostspec'] : 'localhost'; |
| 100 | - if (!empty($dsninfo['port'])) |
|
| 101 | - $dbhost .= ':' . $dsninfo['port']; |
|
| 102 | - } |
|
| 103 | - $user = $dsninfo['username']; |
|
| 104 | - $pw = $dsninfo['password']; |
|
| 105 | - |
|
| 106 | - $connect_function = 'mysql_connect'; |
|
| 107 | - |
|
| 108 | - if ($dbhost && $user && $pw) |
|
| 109 | - $conn = @$connect_function($dbhost, $user, $pw); |
|
| 110 | - elseif ($dbhost && $user) |
|
| 111 | - $conn = @$connect_function($dbhost, $user); |
|
| 112 | - elseif ($dbhost) |
|
| 113 | - $conn = @$connect_function($dbhost); |
|
| 114 | - else |
|
| 115 | - $conn = false; |
|
| 116 | - |
|
| 117 | - if (empty($conn)) |
|
| 118 | - { |
|
| 119 | - throw new Exception('Error in connecting to '.$dsninfo); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - if ($dsninfo['database']) |
|
| 123 | - { |
|
| 124 | - if (!@mysql_select_db($dsninfo['database'], $conn)) |
|
| 125 | - throw new Exception('Error in connecting database, dns:'. |
|
| 126 | - $dsninfo); |
|
| 127 | - } |
|
| 128 | - else |
|
| 129 | - throw new Exception('Please provide a database for message'. |
|
| 130 | - ' translation.'); |
|
| 131 | - return $conn; |
|
| 100 | + if (!empty($dsninfo['port'])) |
|
| 101 | + $dbhost .= ':' . $dsninfo['port']; |
|
| 102 | + } |
|
| 103 | + $user = $dsninfo['username']; |
|
| 104 | + $pw = $dsninfo['password']; |
|
| 105 | + |
|
| 106 | + $connect_function = 'mysql_connect'; |
|
| 107 | + |
|
| 108 | + if ($dbhost && $user && $pw) |
|
| 109 | + $conn = @$connect_function($dbhost, $user, $pw); |
|
| 110 | + elseif ($dbhost && $user) |
|
| 111 | + $conn = @$connect_function($dbhost, $user); |
|
| 112 | + elseif ($dbhost) |
|
| 113 | + $conn = @$connect_function($dbhost); |
|
| 114 | + else |
|
| 115 | + $conn = false; |
|
| 116 | + |
|
| 117 | + if (empty($conn)) |
|
| 118 | + { |
|
| 119 | + throw new Exception('Error in connecting to '.$dsninfo); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + if ($dsninfo['database']) |
|
| 123 | + { |
|
| 124 | + if (!@mysql_select_db($dsninfo['database'], $conn)) |
|
| 125 | + throw new Exception('Error in connecting database, dns:'. |
|
| 126 | + $dsninfo); |
|
| 127 | + } |
|
| 128 | + else |
|
| 129 | + throw new Exception('Please provide a database for message'. |
|
| 130 | + ' translation.'); |
|
| 131 | + return $conn; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | |
| 60 | 60 | $tmp = $data; |
| 61 | 61 | foreach (explode(".", $field) as $f) |
| 62 | - $tmp = $tmp[$f]; |
|
| 62 | + $tmp = $tmp[$f]; |
|
| 63 | 63 | return $tmp; |
| 64 | 64 | } |
| 65 | 65 | else if(is_object($data)) |
@@ -104,30 +104,30 @@ discard block |
||
| 104 | 104 | /** |
| 105 | 105 | * @var boolean controls the use of a persistent connection. Default to true. |
| 106 | 106 | */ |
| 107 | - private $_persistence = true; |
|
| 108 | - /** |
|
| 109 | - * @var integer number of buckets to create for this server which in turn control its |
|
| 110 | - * probability of it being selected. The probability is relative to the total weight |
|
| 111 | - * of all servers. |
|
| 112 | - */ |
|
| 113 | - private $_weight = 1; |
|
| 107 | + private $_persistence = true; |
|
| 108 | + /** |
|
| 109 | + * @var integer number of buckets to create for this server which in turn control its |
|
| 110 | + * probability of it being selected. The probability is relative to the total weight |
|
| 111 | + * of all servers. |
|
| 112 | + */ |
|
| 113 | + private $_weight = 1; |
|
| 114 | 114 | |
| 115 | - private $_timeout = 360; |
|
| 115 | + private $_timeout = 360; |
|
| 116 | 116 | |
| 117 | - private $_retryInterval = 15; |
|
| 117 | + private $_retryInterval = 15; |
|
| 118 | 118 | /** |
| 119 | - * @var integer Controls the minimum value length before attempting to compress automatically. |
|
| 120 | - */ |
|
| 121 | - private $_threshold=0; |
|
| 119 | + * @var integer Controls the minimum value length before attempting to compress automatically. |
|
| 120 | + */ |
|
| 121 | + private $_threshold=0; |
|
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | - * @var float Specifies the minimum amount of savings to actually store the value compressed. The supplied value must be between 0 and 1. Default value is 0.2 giving a minimum 20% compression savings. |
|
| 125 | - */ |
|
| 126 | - private $_minSavings=0.0; |
|
| 124 | + * @var float Specifies the minimum amount of savings to actually store the value compressed. The supplied value must be between 0 and 1. Default value is 0.2 giving a minimum 20% compression savings. |
|
| 125 | + */ |
|
| 126 | + private $_minSavings=0.0; |
|
| 127 | 127 | |
| 128 | - private $_status = true; |
|
| 128 | + private $_status = true; |
|
| 129 | 129 | |
| 130 | - private $_failureCallback = null; |
|
| 130 | + private $_failureCallback = null; |
|
| 131 | 131 | |
| 132 | 132 | /** |
| 133 | 133 | * @var boolean whether to use memcached or memcache as the underlying caching extension. |
@@ -171,63 +171,63 @@ discard block |
||
| 171 | 171 | $this->_cache = $this->_useMemcached ? new Memcached : new Memcache; |
| 172 | 172 | $this->loadConfig($config); |
| 173 | 173 | if(count($this->_servers)) |
| 174 | - { |
|
| 175 | - foreach($this->_servers as $server) |
|
| 176 | - { |
|
| 177 | - Prado::trace('Adding server '.$server['Host'].' from serverlist', 'System.Caching.TMemCache'); |
|
| 178 | - if($this->_cache->addServer($server['Host'],$server['Port'],$server['Persistent'], |
|
| 179 | - $server['Weight'],$server['Timeout'],$server['RetryInterval'])===false) |
|
| 180 | - throw new TConfigurationException('memcache_connection_failed',$server['Host'],$server['Port']); |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - else |
|
| 184 | - { |
|
| 185 | - Prado::trace('Adding server '.$this->_host, 'System.Caching.TMemCache'); |
|
| 186 | - if($this->_cache->addServer($this->_host,$this->_port)===false) |
|
| 187 | - throw new TConfigurationException('memcache_connection_failed',$this->_host,$this->_port); |
|
| 188 | - } |
|
| 174 | + { |
|
| 175 | + foreach($this->_servers as $server) |
|
| 176 | + { |
|
| 177 | + Prado::trace('Adding server '.$server['Host'].' from serverlist', 'System.Caching.TMemCache'); |
|
| 178 | + if($this->_cache->addServer($server['Host'],$server['Port'],$server['Persistent'], |
|
| 179 | + $server['Weight'],$server['Timeout'],$server['RetryInterval'])===false) |
|
| 180 | + throw new TConfigurationException('memcache_connection_failed',$server['Host'],$server['Port']); |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + else |
|
| 184 | + { |
|
| 185 | + Prado::trace('Adding server '.$this->_host, 'System.Caching.TMemCache'); |
|
| 186 | + if($this->_cache->addServer($this->_host,$this->_port)===false) |
|
| 187 | + throw new TConfigurationException('memcache_connection_failed',$this->_host,$this->_port); |
|
| 188 | + } |
|
| 189 | 189 | if($this->_threshold!==0) |
| 190 | - $this->_cache->setCompressThreshold($this->_threshold,$this->_minSavings); |
|
| 190 | + $this->_cache->setCompressThreshold($this->_threshold,$this->_minSavings); |
|
| 191 | 191 | $this->_initialized=true; |
| 192 | 192 | parent::init($config); |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - /** |
|
| 195 | + /** |
|
| 196 | 196 | * Loads configuration from an XML element |
| 197 | 197 | * @param TXmlElement configuration node |
| 198 | 198 | * @throws TConfigurationException if log route class or type is not specified |
| 199 | 199 | */ |
| 200 | 200 | private function loadConfig($xml) |
| 201 | 201 | { |
| 202 | - if($xml instanceof TXmlElement) |
|
| 202 | + if($xml instanceof TXmlElement) |
|
| 203 | 203 | { |
| 204 | - foreach($xml->getElementsByTagName('server') as $serverConfig) |
|
| 205 | - { |
|
| 206 | - $properties=$serverConfig->getAttributes(); |
|
| 207 | - if(($host=$properties->remove('Host'))===null) |
|
| 208 | - throw new TConfigurationException('memcache_serverhost_required'); |
|
| 209 | - if(($port=$properties->remove('Port'))===null) |
|
| 210 | - throw new TConfigurationException('memcache_serverport_required'); |
|
| 211 | - if(!is_numeric($port)) |
|
| 212 | - throw new TConfigurationException('memcache_serverport_invalid'); |
|
| 213 | - $server = array('Host'=>$host,'Port'=>$port,'Weight'=>1,'Timeout'=>1800,'RetryInterval'=>15,'Persistent'=>true); |
|
| 214 | - $checks = array( |
|
| 215 | - 'Weight'=>'memcache_serverweight_invalid', |
|
| 216 | - 'Timeout'=>'memcache_servertimeout_invalid', |
|
| 217 | - 'RetryInterval'=>'memcach_serverretryinterval_invalid' |
|
| 218 | - ); |
|
| 219 | - foreach($checks as $property=>$exception) |
|
| 220 | - { |
|
| 221 | - $value=$properties->remove($property); |
|
| 222 | - if($value!==null && is_numeric($value)) |
|
| 223 | - $server[$property]=$value; |
|
| 224 | - else if($value!==null) |
|
| 225 | - throw new TConfigurationException($exception); |
|
| 226 | - } |
|
| 227 | - $server['Persistent']= TPropertyValue::ensureBoolean($properties->remove('Persistent')); |
|
| 228 | - $this->_servers[]=$server; |
|
| 229 | - } |
|
| 230 | - } |
|
| 204 | + foreach($xml->getElementsByTagName('server') as $serverConfig) |
|
| 205 | + { |
|
| 206 | + $properties=$serverConfig->getAttributes(); |
|
| 207 | + if(($host=$properties->remove('Host'))===null) |
|
| 208 | + throw new TConfigurationException('memcache_serverhost_required'); |
|
| 209 | + if(($port=$properties->remove('Port'))===null) |
|
| 210 | + throw new TConfigurationException('memcache_serverport_required'); |
|
| 211 | + if(!is_numeric($port)) |
|
| 212 | + throw new TConfigurationException('memcache_serverport_invalid'); |
|
| 213 | + $server = array('Host'=>$host,'Port'=>$port,'Weight'=>1,'Timeout'=>1800,'RetryInterval'=>15,'Persistent'=>true); |
|
| 214 | + $checks = array( |
|
| 215 | + 'Weight'=>'memcache_serverweight_invalid', |
|
| 216 | + 'Timeout'=>'memcache_servertimeout_invalid', |
|
| 217 | + 'RetryInterval'=>'memcach_serverretryinterval_invalid' |
|
| 218 | + ); |
|
| 219 | + foreach($checks as $property=>$exception) |
|
| 220 | + { |
|
| 221 | + $value=$properties->remove($property); |
|
| 222 | + if($value!==null && is_numeric($value)) |
|
| 223 | + $server[$property]=$value; |
|
| 224 | + else if($value!==null) |
|
| 225 | + throw new TConfigurationException($exception); |
|
| 226 | + } |
|
| 227 | + $server['Persistent']= TPropertyValue::ensureBoolean($properties->remove('Persistent')); |
|
| 228 | + $this->_servers[]=$server; |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
@@ -139,9 +139,9 @@ |
||
| 139 | 139 | $feed->init($feedConfig); |
| 140 | 140 | |
| 141 | 141 | $content=$feed->getFeedContent(); |
| 142 | - //$this->getResponse()->setContentType('application/rss+xml'); |
|
| 143 | - $this->getResponse()->setContentType($feed->getContentType()); |
|
| 144 | - $this->getResponse()->write($content); |
|
| 142 | + //$this->getResponse()->setContentType('application/rss+xml'); |
|
| 143 | + $this->getResponse()->setContentType($feed->getContentType()); |
|
| 144 | + $this->getResponse()->write($content); |
|
| 145 | 145 | } |
| 146 | 146 | else |
| 147 | 147 | throw new THttpException(404,'feedservice_feed_unknown',$id); |
@@ -144,15 +144,15 @@ |
||
| 144 | 144 | */ |
| 145 | 145 | public function getKeyPrefix() |
| 146 | 146 | { |
| 147 | - return $this->_prefix; |
|
| 147 | + return $this->_prefix; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | - * @param string prefix of cache variable name to avoid conflict with other cache data |
|
| 152 | - */ |
|
| 151 | + * @param string prefix of cache variable name to avoid conflict with other cache data |
|
| 152 | + */ |
|
| 153 | 153 | public function setKeyPrefix($value) |
| 154 | 154 | { |
| 155 | - $this->_prefix=$value; |
|
| 155 | + $this->_prefix=$value; |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -180,24 +180,24 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
| 183 | - * @return string URL for the CSS file including all relevant CSS class definitions. Defaults to ''. |
|
| 184 | - */ |
|
| 183 | + * @return string URL for the CSS file including all relevant CSS class definitions. Defaults to ''. |
|
| 184 | + */ |
|
| 185 | 185 | public function getCssUrl() |
| 186 | 186 | { |
| 187 | 187 | return $this->getViewState('CssUrl','default'); |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
| 191 | - * @param string URL for the CSS file including all relevant CSS class definitions. |
|
| 192 | - */ |
|
| 191 | + * @param string URL for the CSS file including all relevant CSS class definitions. |
|
| 192 | + */ |
|
| 193 | 193 | public function setCssUrl($value) |
| 194 | 194 | { |
| 195 | 195 | $this->setViewState('CssUrl',TPropertyValue::ensureString($value),''); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
| 199 | - * @return string CSS class for the whole accordion control div. |
|
| 200 | - */ |
|
| 199 | + * @return string CSS class for the whole accordion control div. |
|
| 200 | + */ |
|
| 201 | 201 | public function getCssClass() |
| 202 | 202 | { |
| 203 | 203 | $cssClass=parent::getCssClass(); |
@@ -205,32 +205,32 @@ discard block |
||
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
| 208 | - * @return string CSS class for the currently displayed view div. Defaults to 'accordion-view'. |
|
| 209 | - */ |
|
| 208 | + * @return string CSS class for the currently displayed view div. Defaults to 'accordion-view'. |
|
| 209 | + */ |
|
| 210 | 210 | public function getViewCssClass() |
| 211 | 211 | { |
| 212 | 212 | return $this->getViewStyle()->getCssClass(); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
| 216 | - * @param string CSS class for the currently displayed view div. |
|
| 217 | - */ |
|
| 216 | + * @param string CSS class for the currently displayed view div. |
|
| 217 | + */ |
|
| 218 | 218 | public function setViewCssClass($value) |
| 219 | 219 | { |
| 220 | 220 | $this->getViewStyle()->setCssClass($value); |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
| 224 | - * @return string CSS class for the currently displayed view div. Defaults to 'accordion-view'. |
|
| 225 | - */ |
|
| 224 | + * @return string CSS class for the currently displayed view div. Defaults to 'accordion-view'. |
|
| 225 | + */ |
|
| 226 | 226 | public function getAnimationDuration() |
| 227 | 227 | { |
| 228 | 228 | return $this->getViewState('AnimationDuration','1'); |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
| 232 | - * @param string CSS class for the currently displayed view div. |
|
| 233 | - */ |
|
| 232 | + * @param string CSS class for the currently displayed view div. |
|
| 233 | + */ |
|
| 234 | 234 | public function setAnimationDuration($value) |
| 235 | 235 | { |
| 236 | 236 | $this->setViewState('AnimationDuration',$value); |
@@ -131,14 +131,14 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | public function getIsValid() |
| 133 | 133 | { |
| 134 | - return $this->_isValid; |
|
| 134 | + return $this->_isValid; |
|
| 135 | 135 | } |
| 136 | 136 | /** |
| 137 | 137 | * @param bool wether this control is valid. |
| 138 | 138 | */ |
| 139 | 139 | public function setIsValid($value) |
| 140 | 140 | { |
| 141 | - $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
| 141 | + $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | */ |
| 289 | 289 | public function getSurroundingTag() |
| 290 | 290 | { |
| 291 | - return 'span'; |
|
| 291 | + return 'span'; |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | /** |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | */ |
| 297 | 297 | public function getSurroundingTagID() |
| 298 | 298 | { |
| 299 | - return $this->getSpanNeeded() ? $this->getClientID().'_parent' : $this->getClientID(); |
|
| 299 | + return $this->getSpanNeeded() ? $this->getClientID().'_parent' : $this->getClientID(); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** |
@@ -326,11 +326,11 @@ discard block |
||
| 326 | 326 | } |
| 327 | 327 | else |
| 328 | 328 | $onclick=''; |
| 329 | - if($needspan=$this->getSpanNeeded()) |
|
| 330 | - { |
|
| 331 | - $writer->addAttribute('id',$this->getSurroundingTagID()); |
|
| 332 | - $writer->renderBeginTag($this->getSurroundingTag()); |
|
| 333 | - } |
|
| 329 | + if($needspan=$this->getSpanNeeded()) |
|
| 330 | + { |
|
| 331 | + $writer->addAttribute('id',$this->getSurroundingTagID()); |
|
| 332 | + $writer->renderBeginTag($this->getSurroundingTag()); |
|
| 333 | + } |
|
| 334 | 334 | $clientID=$this->getClientID(); |
| 335 | 335 | if(($text=$this->getText())!=='') |
| 336 | 336 | { |
@@ -416,15 +416,15 @@ discard block |
||
| 416 | 416 | $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true); |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - /** |
|
| 420 | - * Check if we need a span tag to surround this control. The span tag will be created if |
|
| 421 | - * the Text property is set for this control. |
|
| 422 | - * |
|
| 423 | - * @return bool wether this control needs a surrounding span tag |
|
| 424 | - */ |
|
| 425 | - protected function getSpanNeeded() { |
|
| 426 | - return $this->getText()!==''; |
|
| 427 | - } |
|
| 419 | + /** |
|
| 420 | + * Check if we need a span tag to surround this control. The span tag will be created if |
|
| 421 | + * the Text property is set for this control. |
|
| 422 | + * |
|
| 423 | + * @return bool wether this control needs a surrounding span tag |
|
| 424 | + */ |
|
| 425 | + protected function getSpanNeeded() { |
|
| 426 | + return $this->getText()!==''; |
|
| 427 | + } |
|
| 428 | 428 | |
| 429 | 429 | /** |
| 430 | 430 | * Renders a label beside the checkbox. |
@@ -46,50 +46,50 @@ discard block |
||
| 46 | 46 | * @throws TConfigurationException If XSL extension is not available |
| 47 | 47 | */ |
| 48 | 48 | public function __construct() { |
| 49 | - if(!class_exists('XSLTProcessor', false)) { |
|
| 50 | - throw new TConfigurationException('xmltransform_xslextension_required'); |
|
| 51 | - } |
|
| 49 | + if(!class_exists('XSLTProcessor', false)) { |
|
| 50 | + throw new TConfigurationException('xmltransform_xslextension_required'); |
|
| 51 | + } |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * @return string The path to the XML style sheet. |
| 56 | 56 | */ |
| 57 | 57 | public function getTransformPath() { |
| 58 | - return $this->getViewState('TransformPath', ''); |
|
| 58 | + return $this->getViewState('TransformPath', ''); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * @param string The path to the XML style sheet. It must be in namespace format. |
| 63 | 63 | */ |
| 64 | 64 | public function setTransformPath($value) { |
| 65 | - if(!is_file($value)) { |
|
| 66 | - $value = Prado::getPathOfNamespace($value, self::EXT_XSL_FILE); |
|
| 67 | - if($value === null) { |
|
| 65 | + if(!is_file($value)) { |
|
| 66 | + $value = Prado::getPathOfNamespace($value, self::EXT_XSL_FILE); |
|
| 67 | + if($value === null) { |
|
| 68 | 68 | throw new TInvalidDataValueException('xmltransform_transformpath_invalid', $value); |
| 69 | - } |
|
| 70 | - } |
|
| 71 | - $this->setViewState('TransformPath', $value, ''); |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + $this->setViewState('TransformPath', $value, ''); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * @return string XML style sheet as string |
| 76 | 76 | */ |
| 77 | 77 | public function getTransformContent() { |
| 78 | - return $this->getViewState('TransformContent', ''); |
|
| 78 | + return $this->getViewState('TransformContent', ''); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * @param string $value XML style sheet as string |
| 83 | 83 | */ |
| 84 | 84 | public function setTransformContent($value) { |
| 85 | - $this->setViewState('TransformContent', $value, ''); |
|
| 85 | + $this->setViewState('TransformContent', $value, ''); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * @return string The path to the XML document. It must be in namespace format. |
| 90 | 90 | */ |
| 91 | 91 | public function getDocumentPath() { |
| 92 | - return $this->getViewState('DocumentPath', ''); |
|
| 92 | + return $this->getViewState('DocumentPath', ''); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -97,27 +97,27 @@ discard block |
||
| 97 | 97 | * @throws TInvalidDataValueException |
| 98 | 98 | */ |
| 99 | 99 | public function setDocumentPath($value) { |
| 100 | - if(!is_file($value)) { |
|
| 101 | - $value = Prado::getPathOfNamespace($value, self::EXT_XML_FILE); |
|
| 102 | - if($value === null) { |
|
| 100 | + if(!is_file($value)) { |
|
| 101 | + $value = Prado::getPathOfNamespace($value, self::EXT_XML_FILE); |
|
| 102 | + if($value === null) { |
|
| 103 | 103 | throw new TInvalidDataValueException('xmltransform_documentpath_invalid', $value); |
| 104 | - } |
|
| 105 | - } |
|
| 106 | - $this->setViewState('DocumentPath', $value, ''); |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + $this->setViewState('DocumentPath', $value, ''); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * @return string XML data |
| 111 | 111 | */ |
| 112 | 112 | public function getDocumentContent() { |
| 113 | - return $this->getViewState('DocumentContent', ''); |
|
| 113 | + return $this->getViewState('DocumentContent', ''); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
| 117 | 117 | * @param string $value XML data. If not empty, it takes precedence over {@link setDocumentPath DocumentPath}. |
| 118 | 118 | */ |
| 119 | 119 | public function setDocumentContent($value) { |
| 120 | - $this->setViewState('DocumentContent', $value, ''); |
|
| 120 | + $this->setViewState('DocumentContent', $value, ''); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -125,41 +125,41 @@ discard block |
||
| 125 | 125 | * @return TAttributeCollection the list of custom parameters |
| 126 | 126 | */ |
| 127 | 127 | public function getParameters() { |
| 128 | - if($params = $this->getViewState('Parameters',null)) { |
|
| 129 | - return $params; |
|
| 130 | - } else { |
|
| 131 | - $params = new TAttributeCollection(); |
|
| 132 | - $this->setViewState('Parameters', $params, null); |
|
| 133 | - return $params; |
|
| 134 | - } |
|
| 128 | + if($params = $this->getViewState('Parameters',null)) { |
|
| 129 | + return $params; |
|
| 130 | + } else { |
|
| 131 | + $params = new TAttributeCollection(); |
|
| 132 | + $this->setViewState('Parameters', $params, null); |
|
| 133 | + return $params; |
|
| 134 | + } |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | private function getTransformXmlDocument() { |
| 138 | - if(($content = $this->getTransformContent()) !== '') { |
|
| 139 | - $document = new DOMDocument(); |
|
| 140 | - $document->loadXML($content); |
|
| 141 | - return $document; |
|
| 142 | - } else if(($path = $this->getTransformPath()) !== '') { |
|
| 143 | - $document = new DOMDocument(); |
|
| 144 | - $document->load($path); |
|
| 145 | - return $document; |
|
| 146 | - } else { |
|
| 147 | - throw new TConfigurationException('xmltransform_transform_required'); |
|
| 148 | - } |
|
| 138 | + if(($content = $this->getTransformContent()) !== '') { |
|
| 139 | + $document = new DOMDocument(); |
|
| 140 | + $document->loadXML($content); |
|
| 141 | + return $document; |
|
| 142 | + } else if(($path = $this->getTransformPath()) !== '') { |
|
| 143 | + $document = new DOMDocument(); |
|
| 144 | + $document->load($path); |
|
| 145 | + return $document; |
|
| 146 | + } else { |
|
| 147 | + throw new TConfigurationException('xmltransform_transform_required'); |
|
| 148 | + } |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | private function getSourceXmlDocument() { |
| 152 | - if(($content = $this->getDocumentContent()) !== '') { |
|
| 153 | - $document = new DOMDocument(); |
|
| 154 | - $document->loadXML($content); |
|
| 155 | - return $document; |
|
| 156 | - } else if(($path = $this->getDocumentPath()) !== '') { |
|
| 157 | - $document = new DOMDocument(); |
|
| 158 | - $document->load($path); |
|
| 159 | - return $document; |
|
| 160 | - } else { |
|
| 161 | - return null; |
|
| 162 | - } |
|
| 152 | + if(($content = $this->getDocumentContent()) !== '') { |
|
| 153 | + $document = new DOMDocument(); |
|
| 154 | + $document->loadXML($content); |
|
| 155 | + return $document; |
|
| 156 | + } else if(($path = $this->getDocumentPath()) !== '') { |
|
| 157 | + $document = new DOMDocument(); |
|
| 158 | + $document->load($path); |
|
| 159 | + return $document; |
|
| 160 | + } else { |
|
| 161 | + return null; |
|
| 162 | + } |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -167,27 +167,27 @@ discard block |
||
| 167 | 167 | * @param THtmlWriter The writer used for the rendering purpose |
| 168 | 168 | */ |
| 169 | 169 | public function render($writer) { |
| 170 | - if(($document=$this->getSourceXmlDocument()) === null) { |
|
| 170 | + if(($document=$this->getSourceXmlDocument()) === null) { |
|
| 171 | 171 | $htmlWriter = Prado::createComponent($this->GetResponse()->getHtmlWriterType(), new TTextWriter()); |
| 172 | 172 | parent::render($htmlWriter); |
| 173 | - $document = new DOMDocument(); |
|
| 174 | - $document->loadXML($htmlWriter->flush()); |
|
| 175 | - } |
|
| 176 | - $stylesheet = $this->getTransformXmlDocument(); |
|
| 177 | - |
|
| 178 | - // Perform XSL transformation |
|
| 179 | - $xslt = new XSLTProcessor(); |
|
| 180 | - $xslt->importStyleSheet($stylesheet); |
|
| 181 | - |
|
| 182 | - // Check for parameters |
|
| 183 | - $parameters = $this->getParameters(); |
|
| 184 | - foreach($parameters as $name => $value) { |
|
| 185 | - $xslt->setParameter('', $name, $value); |
|
| 186 | - } |
|
| 187 | - $output = $xslt->transformToXML($document); |
|
| 188 | - |
|
| 189 | - // Write output |
|
| 190 | - $writer->write($output); |
|
| 173 | + $document = new DOMDocument(); |
|
| 174 | + $document->loadXML($htmlWriter->flush()); |
|
| 175 | + } |
|
| 176 | + $stylesheet = $this->getTransformXmlDocument(); |
|
| 177 | + |
|
| 178 | + // Perform XSL transformation |
|
| 179 | + $xslt = new XSLTProcessor(); |
|
| 180 | + $xslt->importStyleSheet($stylesheet); |
|
| 181 | + |
|
| 182 | + // Check for parameters |
|
| 183 | + $parameters = $this->getParameters(); |
|
| 184 | + foreach($parameters as $name => $value) { |
|
| 185 | + $xslt->setParameter('', $name, $value); |
|
| 186 | + } |
|
| 187 | + $output = $xslt->transformToXML($document); |
|
| 188 | + |
|
| 189 | + // Write output |
|
| 190 | + $writer->write($output); |
|
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | |
@@ -170,12 +170,12 @@ |
||
| 170 | 170 | public function validate() |
| 171 | 171 | { |
| 172 | 172 | if (! |
| 173 | - ( |
|
| 173 | + ( |
|
| 174 | 174 | ($challenge = @$_POST[$this->getChallengeFieldName()]) |
| 175 | 175 | and |
| 176 | 176 | ($response = @$_POST[$this->getResponseFieldName()]) |
| 177 | - ) |
|
| 178 | - ) |
|
| 177 | + ) |
|
| 178 | + ) |
|
| 179 | 179 | return false; |
| 180 | 180 | |
| 181 | 181 | $resp = recaptcha_check_answer( |