@@ -77,6 +77,7 @@ |
||
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * Saves the current SqlMap manager to cache. |
| 80 | + * @param TSqlMapManager $manager |
|
| 80 | 81 | * @return boolean true if SqlMap manager was cached, false otherwise. |
| 81 | 82 | */ |
| 82 | 83 | protected function cacheSqlMapManager($manager) |
@@ -68,8 +68,7 @@ |
||
| 68 | 68 | $manager->configureXml($file); |
| 69 | 69 | $this->cacheSqlMapManager($manager); |
| 70 | 70 | } |
| 71 | - } |
|
| 72 | - elseif($this->getConnectionID() !== '') { |
|
| 71 | + } elseif($this->getConnectionID() !== '') { |
|
| 73 | 72 | $manager->setDbConnection($this->getDbConnection()); |
| 74 | 73 | } |
| 75 | 74 | return $manager; |
@@ -31,19 +31,19 @@ discard block |
||
| 31 | 31 | { |
| 32 | 32 | private $_configFile; |
| 33 | 33 | private $_sqlmap; |
| 34 | - private $_enableCache = false; |
|
| 34 | + private $_enableCache=false; |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * File extension of external configuration file |
| 38 | 38 | */ |
| 39 | - const CONFIG_FILE_EXT = '.xml'; |
|
| 39 | + const CONFIG_FILE_EXT='.xml'; |
|
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * @return string module ID + configuration file path. |
| 43 | 43 | */ |
| 44 | 44 | private function getCacheKey() |
| 45 | 45 | { |
| 46 | - return $this->getID() . $this->getConfigFile(); |
|
| 46 | + return $this->getID().$this->getConfigFile(); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | public function clearCache() |
| 53 | 53 | { |
| 54 | - $cache = $this->getApplication()->getCache(); |
|
| 55 | - if($cache !== null) { |
|
| 54 | + $cache=$this->getApplication()->getCache(); |
|
| 55 | + if($cache!==null) { |
|
| 56 | 56 | $cache->delete($this->getCacheKey()); |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -66,16 +66,16 @@ discard block |
||
| 66 | 66 | * @since 3.1.7 |
| 67 | 67 | */ |
| 68 | 68 | public function getSqlMapManager() { |
| 69 | - if(($manager = $this->loadCachedSqlMapManager()) === null) |
|
| 69 | + if(($manager=$this->loadCachedSqlMapManager())===null) |
|
| 70 | 70 | { |
| 71 | - $manager = new TSqlMapManager($this->getDbConnection()); |
|
| 72 | - if(strlen($file = $this->getConfigFile()) > 0) |
|
| 71 | + $manager=new TSqlMapManager($this->getDbConnection()); |
|
| 72 | + if(strlen($file=$this->getConfigFile()) > 0) |
|
| 73 | 73 | { |
| 74 | 74 | $manager->configureXml($file); |
| 75 | 75 | $this->cacheSqlMapManager($manager); |
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | - elseif($this->getConnectionID() !== '') { |
|
| 78 | + elseif($this->getConnectionID()!=='') { |
|
| 79 | 79 | $manager->setDbConnection($this->getDbConnection()); |
| 80 | 80 | } |
| 81 | 81 | return $manager; |
@@ -89,11 +89,11 @@ discard block |
||
| 89 | 89 | { |
| 90 | 90 | if($this->getEnableCache()) |
| 91 | 91 | { |
| 92 | - $cache = $this->getApplication()->getCache(); |
|
| 93 | - if($cache !== null) { |
|
| 94 | - $dependencies = null; |
|
| 95 | - if($this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
| 96 | - $dependencies = $manager->getCacheDependencies(); |
|
| 92 | + $cache=$this->getApplication()->getCache(); |
|
| 93 | + if($cache!==null) { |
|
| 94 | + $dependencies=null; |
|
| 95 | + if($this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
| 96 | + $dependencies=$manager->getCacheDependencies(); |
|
| 97 | 97 | return $cache->set($this->getCacheKey(), $manager, 0, $dependencies); |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -108,10 +108,10 @@ discard block |
||
| 108 | 108 | { |
| 109 | 109 | if($this->getEnableCache()) |
| 110 | 110 | { |
| 111 | - $cache = $this->getApplication()->getCache(); |
|
| 112 | - if($cache !== null) |
|
| 111 | + $cache=$this->getApplication()->getCache(); |
|
| 112 | + if($cache!==null) |
|
| 113 | 113 | { |
| 114 | - $manager = $cache->get($this->getCacheKey()); |
|
| 114 | + $manager=$cache->get($this->getCacheKey()); |
|
| 115 | 115 | if($manager instanceof TSqlMapManager) |
| 116 | 116 | return $manager; |
| 117 | 117 | } |
@@ -135,14 +135,14 @@ discard block |
||
| 135 | 135 | public function setConfigFile($value) |
| 136 | 136 | { |
| 137 | 137 | if(is_file($value)) |
| 138 | - $this->_configFile = $value; |
|
| 138 | + $this->_configFile=$value; |
|
| 139 | 139 | else |
| 140 | 140 | { |
| 141 | - $file = Prado::getPathOfNamespace($value, self::CONFIG_FILE_EXT); |
|
| 142 | - if($file === null || !is_file($file)) |
|
| 141 | + $file=Prado::getPathOfNamespace($value, self::CONFIG_FILE_EXT); |
|
| 142 | + if($file===null || !is_file($file)) |
|
| 143 | 143 | throw new TConfigurationException('sqlmap_configfile_invalid', $value); |
| 144 | 144 | else |
| 145 | - $this->_configFile = $file; |
|
| 145 | + $this->_configFile=$file; |
|
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | 148 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public function setEnableCache($value) |
| 154 | 154 | { |
| 155 | - $this->_enableCache = TPropertyValue::ensureBoolean($value); |
|
| 155 | + $this->_enableCache=TPropertyValue::ensureBoolean($value); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -177,8 +177,8 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | public function getClient() |
| 179 | 179 | { |
| 180 | - if($this->_sqlmap === null) |
|
| 181 | - $this->_sqlmap = $this->createSqlMapGateway(); |
|
| 180 | + if($this->_sqlmap===null) |
|
| 181 | + $this->_sqlmap=$this->createSqlMapGateway(); |
|
| 182 | 182 | return $this->_sqlmap; |
| 183 | 183 | } |
| 184 | 184 | } |
@@ -149,6 +149,7 @@ |
||
| 149 | 149 | /** |
| 150 | 150 | * Finds the database connection instance from the Application modules. |
| 151 | 151 | * @param string Database connection module ID. |
| 152 | + * @param string $id |
|
| 152 | 153 | * @return TDbConnection database connection. |
| 153 | 154 | * @throws TConfigurationException when module is not of TDbConnection or TDataSourceConfig. |
| 154 | 155 | */ |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | class TDataSourceConfig extends \Prado\TModule |
| 52 | 52 | { |
| 53 | - private $_connID = ''; |
|
| 53 | + private $_connID=''; |
|
| 54 | 54 | private $_conn; |
| 55 | - private $_connClass = 'System.Data.TDbConnection'; |
|
| 55 | + private $_connClass='System.Data.TDbConnection'; |
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * Initalize the database connection properties from attributes in <database> tag. |
@@ -60,20 +60,20 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public function init($xml) |
| 62 | 62 | { |
| 63 | - if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
| 63 | + if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
|
| 64 | 64 | { |
| 65 | 65 | if(isset($xml['database']) && is_array($xml['database'])) |
| 66 | 66 | { |
| 67 | - $db = $this->getDbConnection(); |
|
| 67 | + $db=$this->getDbConnection(); |
|
| 68 | 68 | foreach($xml['database'] as $name => $value) |
| 69 | 69 | $db->setSubProperty($name, $value); |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | else |
| 73 | 73 | { |
| 74 | - if($prop = $xml->getElementByTagName('database')) |
|
| 74 | + if($prop=$xml->getElementByTagName('database')) |
|
| 75 | 75 | { |
| 76 | - $db = $this->getDbConnection(); |
|
| 76 | + $db=$this->getDbConnection(); |
|
| 77 | 77 | foreach($prop->getAttributes() as $name => $value) |
| 78 | 78 | $db->setSubproperty($name, $value); |
| 79 | 79 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function setConnectionID($value) |
| 90 | 90 | { |
| 91 | - $this->_connID = $value; |
|
| 91 | + $this->_connID=$value; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -107,12 +107,12 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function getDbConnection() |
| 109 | 109 | { |
| 110 | - if($this->_conn === null) |
|
| 110 | + if($this->_conn===null) |
|
| 111 | 111 | { |
| 112 | - if($this->_connID !== '') |
|
| 113 | - $this->_conn = $this->findConnectionByID($this->getConnectionID()); |
|
| 112 | + if($this->_connID!=='') |
|
| 113 | + $this->_conn=$this->findConnectionByID($this->getConnectionID()); |
|
| 114 | 114 | else |
| 115 | - $this->_conn = Prado::createComponent($this->getConnectionClass()); |
|
| 115 | + $this->_conn=Prado::createComponent($this->getConnectionClass()); |
|
| 116 | 116 | } |
| 117 | 117 | return $this->_conn; |
| 118 | 118 | } |
@@ -145,9 +145,9 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | public function setConnectionClass($value) |
| 147 | 147 | { |
| 148 | - if($this->_conn !== null) |
|
| 148 | + if($this->_conn!==null) |
|
| 149 | 149 | throw new TConfigurationException('datasource_dbconnection_exists', $value); |
| 150 | - $this->_connClass = $value; |
|
| 150 | + $this->_connClass=$value; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | protected function findConnectionByID($id) |
| 160 | 160 | { |
| 161 | - $conn = $this->getApplication()->getModule($id); |
|
| 161 | + $conn=$this->getApplication()->getModule($id); |
|
| 162 | 162 | if($conn instanceof TDbConnection) |
| 163 | 163 | return $conn; |
| 164 | 164 | elseif($conn instanceof TDataSourceConfig) |
@@ -68,8 +68,7 @@ |
||
| 68 | 68 | foreach($xml['database'] as $name => $value) |
| 69 | 69 | $db->setSubProperty($name, $value); |
| 70 | 70 | } |
| 71 | - } |
|
| 72 | - else |
|
| 71 | + } else |
|
| 73 | 72 | { |
| 74 | 73 | if($prop = $xml->getElementByTagName('database')) |
| 75 | 74 | { |
@@ -157,6 +157,7 @@ discard block |
||
| 157 | 157 | /** |
| 158 | 158 | * Open or close the DB connection. |
| 159 | 159 | * @param boolean whether to open or close DB connection |
| 160 | + * @param boolean $value |
|
| 160 | 161 | * @throws TDbException if connection fails |
| 161 | 162 | */ |
| 162 | 163 | public function setActive($value) |
@@ -241,6 +242,7 @@ discard block |
||
| 241 | 242 | |
| 242 | 243 | /** |
| 243 | 244 | * @param string The Data Source Name, or DSN, contains the information required to connect to the database. |
| 245 | + * @param string $value |
|
| 244 | 246 | * @see http://www.php.net/manual/en/function.PDO-construct.php |
| 245 | 247 | */ |
| 246 | 248 | public function setConnectionString($value) |
@@ -258,6 +260,7 @@ discard block |
||
| 258 | 260 | |
| 259 | 261 | /** |
| 260 | 262 | * @param string the username for establishing DB connection |
| 263 | + * @param string $value |
|
| 261 | 264 | */ |
| 262 | 265 | public function setUsername($value) |
| 263 | 266 | { |
@@ -274,6 +277,7 @@ discard block |
||
| 274 | 277 | |
| 275 | 278 | /** |
| 276 | 279 | * @param string the password for establishing DB connection |
| 280 | + * @param string $value |
|
| 277 | 281 | */ |
| 278 | 282 | public function setPassword($value) |
| 279 | 283 | { |
@@ -92,14 +92,14 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @since 3.1.7 |
| 94 | 94 | */ |
| 95 | - const DEFAULT_TRANSACTION_CLASS = 'System.Data.TDbTransaction'; |
|
| 96 | - |
|
| 97 | - private $_dsn = ''; |
|
| 98 | - private $_username = ''; |
|
| 99 | - private $_password = ''; |
|
| 100 | - private $_charset = ''; |
|
| 101 | - private $_attributes = []; |
|
| 102 | - private $_active = false; |
|
| 95 | + const DEFAULT_TRANSACTION_CLASS='System.Data.TDbTransaction'; |
|
| 96 | + |
|
| 97 | + private $_dsn=''; |
|
| 98 | + private $_username=''; |
|
| 99 | + private $_password=''; |
|
| 100 | + private $_charset=''; |
|
| 101 | + private $_attributes=[]; |
|
| 102 | + private $_active=false; |
|
| 103 | 103 | private $_pdo; |
| 104 | 104 | private $_transaction; |
| 105 | 105 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * @var string |
| 113 | 113 | * @since 3.1.7 |
| 114 | 114 | */ |
| 115 | - private $_transactionClass = self::DEFAULT_TRANSACTION_CLASS; |
|
| 115 | + private $_transactionClass=self::DEFAULT_TRANSACTION_CLASS; |
|
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | 118 | * Constructor. |
@@ -127,12 +127,12 @@ discard block |
||
| 127 | 127 | * @param string Charset used for DB Connection (MySql & pgsql only). If not set, will use the default charset of your database server |
| 128 | 128 | * @see http://www.php.net/manual/en/function.PDO-construct.php |
| 129 | 129 | */ |
| 130 | - public function __construct($dsn = '', $username = '', $password = '', $charset = '') |
|
| 130 | + public function __construct($dsn='', $username='', $password='', $charset='') |
|
| 131 | 131 | { |
| 132 | - $this->_dsn = $dsn; |
|
| 133 | - $this->_username = $username; |
|
| 134 | - $this->_password = $password; |
|
| 135 | - $this->_charset = $charset; |
|
| 132 | + $this->_dsn=$dsn; |
|
| 133 | + $this->_username=$username; |
|
| 134 | + $this->_password=$password; |
|
| 135 | + $this->_charset=$charset; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | public function __sleep() |
| 142 | 142 | { |
| 143 | 143 | // $this->close(); - DO NOT CLOSE the current connection as serializing doesn't neccessarily mean we don't this connection anymore in the current session |
| 144 | - return array_diff(parent::__sleep(), ["\0Prado\Data\TDbConnection\0_pdo","\0Prado\Data\TDbConnection\0_active"]); |
|
| 144 | + return array_diff(parent::__sleep(), ["\0Prado\Data\TDbConnection\0_pdo", "\0Prado\Data\TDbConnection\0_active"]); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -168,8 +168,8 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | public function setActive($value) |
| 170 | 170 | { |
| 171 | - $value = TPropertyValue::ensureBoolean($value); |
|
| 172 | - if($value !== $this->_active) |
|
| 171 | + $value=TPropertyValue::ensureBoolean($value); |
|
| 172 | + if($value!==$this->_active) |
|
| 173 | 173 | { |
| 174 | 174 | if($value) |
| 175 | 175 | $this->open(); |
@@ -184,17 +184,17 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | protected function open() |
| 186 | 186 | { |
| 187 | - if($this->_pdo === null) |
|
| 187 | + if($this->_pdo===null) |
|
| 188 | 188 | { |
| 189 | 189 | try |
| 190 | 190 | { |
| 191 | - $this->_pdo = new PDO($this->getConnectionString(),$this->getUsername(), |
|
| 191 | + $this->_pdo=new PDO($this->getConnectionString(), $this->getUsername(), |
|
| 192 | 192 | $this->getPassword(), $this->_attributes); |
| 193 | 193 | // This attribute is only useful for PDO::MySql driver. |
| 194 | 194 | // Ignore the warning if a driver doesn't understand this. |
| 195 | 195 | @$this->_pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 196 | 196 | $this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 197 | - $this->_active = true; |
|
| 197 | + $this->_active=true; |
|
| 198 | 198 | $this->setConnectionCharset(); |
| 199 | 199 | } |
| 200 | 200 | catch(PDOException $e) |
@@ -210,8 +210,8 @@ discard block |
||
| 210 | 210 | */ |
| 211 | 211 | protected function close() |
| 212 | 212 | { |
| 213 | - $this->_pdo = null; |
|
| 214 | - $this->_active = false; |
|
| 213 | + $this->_pdo=null; |
|
| 214 | + $this->_active=false; |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | /* |
@@ -221,16 +221,16 @@ discard block |
||
| 221 | 221 | */ |
| 222 | 222 | protected function setConnectionCharset() |
| 223 | 223 | { |
| 224 | - if ($this->_charset === '' || $this->_active === false) |
|
| 224 | + if($this->_charset==='' || $this->_active===false) |
|
| 225 | 225 | return; |
| 226 | - switch ($this->_pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) |
|
| 226 | + switch($this->_pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) |
|
| 227 | 227 | { |
| 228 | 228 | case 'mysql': |
| 229 | 229 | case 'sqlite': |
| 230 | - $stmt = $this->_pdo->prepare('SET NAMES ?'); |
|
| 230 | + $stmt=$this->_pdo->prepare('SET NAMES ?'); |
|
| 231 | 231 | break; |
| 232 | 232 | case 'pgsql': |
| 233 | - $stmt = $this->_pdo->prepare('SET client_encoding TO ?'); |
|
| 233 | + $stmt=$this->_pdo->prepare('SET client_encoding TO ?'); |
|
| 234 | 234 | break; |
| 235 | 235 | default: |
| 236 | 236 | throw new TDbException('dbconnection_unsupported_driver_charset', $driver); |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | public function setConnectionString($value) |
| 254 | 254 | { |
| 255 | - $this->_dsn = $value; |
|
| 255 | + $this->_dsn=$value; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | /** |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | public function setUsername($value) |
| 270 | 270 | { |
| 271 | - $this->_username = $value; |
|
| 271 | + $this->_username=$value; |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | /** |
@@ -284,13 +284,13 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | public function setPassword($value) |
| 286 | 286 | { |
| 287 | - $this->_password = $value; |
|
| 287 | + $this->_password=$value; |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |
| 291 | 291 | * @return string the charset used for database connection. Defaults to emtpy string. |
| 292 | 292 | */ |
| 293 | - public function getCharset () |
|
| 293 | + public function getCharset() |
|
| 294 | 294 | { |
| 295 | 295 | return $this->_charset; |
| 296 | 296 | } |
@@ -298,9 +298,9 @@ discard block |
||
| 298 | 298 | /** |
| 299 | 299 | * @param string the charset used for database connection |
| 300 | 300 | */ |
| 301 | - public function setCharset ($value) |
|
| 301 | + public function setCharset($value) |
|
| 302 | 302 | { |
| 303 | - $this->_charset = $value; |
|
| 303 | + $this->_charset=$value; |
|
| 304 | 304 | $this->setConnectionCharset(); |
| 305 | 305 | } |
| 306 | 306 | |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | */ |
| 332 | 332 | public function getCurrentTransaction() |
| 333 | 333 | { |
| 334 | - if($this->_transaction !== null) |
|
| 334 | + if($this->_transaction!==null) |
|
| 335 | 335 | { |
| 336 | 336 | if($this->_transaction->getActive()) |
| 337 | 337 | return $this->_transaction; |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | if($this->getActive()) |
| 350 | 350 | { |
| 351 | 351 | $this->_pdo->beginTransaction(); |
| 352 | - return $this->_transaction = Prado::createComponent($this->getTransactionClass(), $this); |
|
| 352 | + return $this->_transaction=Prado::createComponent($this->getTransactionClass(), $this); |
|
| 353 | 353 | } |
| 354 | 354 | else |
| 355 | 355 | throw new TDbException('dbconnection_connection_inactive'); |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | */ |
| 372 | 372 | public function setTransactionClass($value) |
| 373 | 373 | { |
| 374 | - $this->_transactionClass = (string)$value; |
|
| 374 | + $this->_transactionClass=(string) $value; |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | /** |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | * @return string the row ID of the last row inserted, or the last value retrieved from the sequence object |
| 381 | 381 | * @see http://www.php.net/manual/en/function.PDO-lastInsertId.php |
| 382 | 382 | */ |
| 383 | - public function getLastInsertID($sequenceName = '') |
|
| 383 | + public function getLastInsertID($sequenceName='') |
|
| 384 | 384 | { |
| 385 | 385 | if($this->getActive()) |
| 386 | 386 | return $this->_pdo->lastInsertId($sequenceName); |
@@ -437,9 +437,9 @@ discard block |
||
| 437 | 437 | */ |
| 438 | 438 | public function getDbMetaData() |
| 439 | 439 | { |
| 440 | - if($this->_dbMeta === null) |
|
| 440 | + if($this->_dbMeta===null) |
|
| 441 | 441 | { |
| 442 | - $this->_dbMeta = TDbMetaData::getInstance($this); |
|
| 442 | + $this->_dbMeta=TDbMetaData::getInstance($this); |
|
| 443 | 443 | } |
| 444 | 444 | return $this->_dbMeta; |
| 445 | 445 | } |
@@ -468,13 +468,13 @@ discard block |
||
| 468 | 468 | switch(TPropertyValue::ensureEnum($value, 'Prado\\Data\\TDbColumnCaseMode')) |
| 469 | 469 | { |
| 470 | 470 | case TDbColumnCaseMode::Preserved: |
| 471 | - $value = PDO::CASE_NATURAL; |
|
| 471 | + $value=PDO::CASE_NATURAL; |
|
| 472 | 472 | break; |
| 473 | 473 | case TDbColumnCaseMode::LowerCase: |
| 474 | - $value = PDO::CASE_LOWER; |
|
| 474 | + $value=PDO::CASE_LOWER; |
|
| 475 | 475 | break; |
| 476 | 476 | case TDbColumnCaseMode::UpperCase: |
| 477 | - $value = PDO::CASE_UPPER; |
|
| 477 | + $value=PDO::CASE_UPPER; |
|
| 478 | 478 | break; |
| 479 | 479 | } |
| 480 | 480 | $this->setAttribute(PDO::ATTR_CASE, $value); |
@@ -504,13 +504,13 @@ discard block |
||
| 504 | 504 | switch(TPropertyValue::ensureEnum($value, 'Prado\\Data\\TDbNullConversionMode')) |
| 505 | 505 | { |
| 506 | 506 | case TDbNullConversionMode::Preserved: |
| 507 | - $value = PDO::NULL_NATURAL; |
|
| 507 | + $value=PDO::NULL_NATURAL; |
|
| 508 | 508 | break; |
| 509 | 509 | case TDbNullConversionMode::EmptyStringToNull: |
| 510 | - $value = PDO::NULL_EMPTY_STRING; |
|
| 510 | + $value=PDO::NULL_EMPTY_STRING; |
|
| 511 | 511 | break; |
| 512 | 512 | case TDbNullConversionMode::NullToEmptyString: |
| 513 | - $value = PDO::NULL_TO_STRING; |
|
| 513 | + $value=PDO::NULL_TO_STRING; |
|
| 514 | 514 | break; |
| 515 | 515 | } |
| 516 | 516 | $this->setAttribute(PDO::ATTR_ORACLE_NULLS, $value); |
@@ -634,6 +634,6 @@ discard block |
||
| 634 | 634 | if($this->_pdo instanceof PDO) |
| 635 | 635 | $this->_pdo->setAttribute($name, $value); |
| 636 | 636 | else |
| 637 | - $this->_attributes[$name] = $value; |
|
| 637 | + $this->_attributes[$name]=$value; |
|
| 638 | 638 | } |
| 639 | 639 | } |
| 640 | 640 | \ No newline at end of file |
@@ -196,8 +196,7 @@ discard block |
||
| 196 | 196 | $this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 197 | 197 | $this->_active = true; |
| 198 | 198 | $this->setConnectionCharset(); |
| 199 | - } |
|
| 200 | - catch(PDOException $e) |
|
| 199 | + } catch(PDOException $e) |
|
| 201 | 200 | { |
| 202 | 201 | throw new TDbException('dbconnection_open_failed', $e->getMessage()); |
| 203 | 202 | } |
@@ -350,8 +349,7 @@ discard block |
||
| 350 | 349 | { |
| 351 | 350 | $this->_pdo->beginTransaction(); |
| 352 | 351 | return $this->_transaction = Prado::createComponent($this->getTransactionClass(), $this); |
| 353 | - } |
|
| 354 | - else |
|
| 352 | + } else |
|
| 355 | 353 | throw new TDbException('dbconnection_connection_inactive'); |
| 356 | 354 | } |
| 357 | 355 | |
@@ -101,6 +101,7 @@ |
||
| 101 | 101 | |
| 102 | 102 | /** |
| 103 | 103 | * @param boolean whether this transaction is active |
| 104 | + * @param boolean $value |
|
| 104 | 105 | */ |
| 105 | 106 | protected function setActive($value) |
| 106 | 107 | { |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function __construct(TDbConnection $connection) |
| 56 | 56 | { |
| 57 | - $this->_connection = $connection; |
|
| 57 | + $this->_connection=$connection; |
|
| 58 | 58 | $this->setActive(true); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | if($this->_active && $this->_connection->getActive()) |
| 68 | 68 | { |
| 69 | 69 | $this->_connection->getPdoInstance()->commit(); |
| 70 | - $this->_active = false; |
|
| 70 | + $this->_active=false; |
|
| 71 | 71 | } |
| 72 | 72 | else |
| 73 | 73 | throw new TDbException('dbtransaction_transaction_inactive'); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | if($this->_active && $this->_connection->getActive()) |
| 83 | 83 | { |
| 84 | 84 | $this->_connection->getPdoInstance()->rollBack(); |
| 85 | - $this->_active = false; |
|
| 85 | + $this->_active=false; |
|
| 86 | 86 | } |
| 87 | 87 | else |
| 88 | 88 | throw new TDbException('dbtransaction_transaction_inactive'); |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | protected function setActive($value) |
| 111 | 111 | { |
| 112 | - $this->_active = TPropertyValue::ensureBoolean($value); |
|
| 112 | + $this->_active=TPropertyValue::ensureBoolean($value); |
|
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | |
@@ -68,8 +68,7 @@ discard block |
||
| 68 | 68 | { |
| 69 | 69 | $this->_connection->getPdoInstance()->commit(); |
| 70 | 70 | $this->_active = false; |
| 71 | - } |
|
| 72 | - else |
|
| 71 | + } else |
|
| 73 | 72 | throw new TDbException('dbtransaction_transaction_inactive'); |
| 74 | 73 | } |
| 75 | 74 | |
@@ -83,8 +82,7 @@ discard block |
||
| 83 | 82 | { |
| 84 | 83 | $this->_connection->getPdoInstance()->rollBack(); |
| 85 | 84 | $this->_active = false; |
| 86 | - } |
|
| 87 | - else |
|
| 85 | + } else |
|
| 88 | 86 | throw new TDbException('dbtransaction_transaction_inactive'); |
| 89 | 87 | } |
| 90 | 88 | |
@@ -486,6 +486,9 @@ |
||
| 486 | 486 | return false; |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | + /** |
|
| 490 | + * @param string $catalogue |
|
| 491 | + */ |
|
| 489 | 492 | protected function createMessageTemplate($catalogue) |
| 490 | 493 | { |
| 491 | 494 | if($catalogue === null) { |
@@ -19,7 +19,6 @@ |
||
| 19 | 19 | namespace Prado\I18N\core; |
| 20 | 20 | |
| 21 | 21 | use DOMDocument; |
| 22 | -use DOMXPath; |
|
| 23 | 22 | use Prado\Exceptions\TException; |
| 24 | 23 | use Prado\Exceptions\TIOException; |
| 25 | 24 | |
@@ -43,13 +43,13 @@ discard block |
||
| 43 | 43 | * Message data filename extension. |
| 44 | 44 | * @var string |
| 45 | 45 | */ |
| 46 | - protected $dataExt = '.xml'; |
|
| 46 | + protected $dataExt='.xml'; |
|
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * Separator between culture name and source. |
| 50 | 50 | * @var string |
| 51 | 51 | */ |
| 52 | - protected $dataSeparator = '.'; |
|
| 52 | + protected $dataSeparator='.'; |
|
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * Constructor. |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public function __construct($source) |
| 60 | 60 | { |
| 61 | - $this->source = (string)$source; |
|
| 61 | + $this->source=(string) $source; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -69,20 +69,20 @@ discard block |
||
| 69 | 69 | protected function &loadData($filename) |
| 70 | 70 | { |
| 71 | 71 | //load it. |
| 72 | - if(false === ($XML = simplexml_load_file($filename))) { |
|
| 72 | + if(false===($XML=simplexml_load_file($filename))) { |
|
| 73 | 73 | return false; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - $translationUnit = $XML->xpath('//trans-unit'); |
|
| 76 | + $translationUnit=$XML->xpath('//trans-unit'); |
|
| 77 | 77 | |
| 78 | - $translations = []; |
|
| 78 | + $translations=[]; |
|
| 79 | 79 | |
| 80 | 80 | foreach($translationUnit as $unit) |
| 81 | 81 | { |
| 82 | - $source = (string)$unit->source; |
|
| 83 | - $translations[$source][] = (string)$unit->target; |
|
| 84 | - $translations[$source][] = (string)$unit['id']; |
|
| 85 | - $translations[$source][] = (string)$unit->note; |
|
| 82 | + $source=(string) $unit->source; |
|
| 83 | + $translations[$source][]=(string) $unit->target; |
|
| 84 | + $translations[$source][]=(string) $unit['id']; |
|
| 85 | + $translations[$source][]=(string) $unit->note; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | return $translations; |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | protected function getSource($variant) |
| 109 | 109 | { |
| 110 | - return $this->source . '/' . $variant; |
|
| 110 | + return $this->source.'/'.$variant; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -127,28 +127,28 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | protected function getCatalogueList($catalogue) |
| 129 | 129 | { |
| 130 | - $variants = explode('_', $this->culture); |
|
| 131 | - $source = $catalogue . $this->dataExt; |
|
| 132 | - $catalogues = [$source]; |
|
| 133 | - $variant = null; |
|
| 130 | + $variants=explode('_', $this->culture); |
|
| 131 | + $source=$catalogue.$this->dataExt; |
|
| 132 | + $catalogues=[$source]; |
|
| 133 | + $variant=null; |
|
| 134 | 134 | |
| 135 | - for($i = 0, $k = count($variants); $i < $k; ++$i) |
|
| 135 | + for($i=0, $k=count($variants); $i < $k; ++$i) |
|
| 136 | 136 | { |
| 137 | 137 | if(isset($variants[$i]{0})) |
| 138 | 138 | { |
| 139 | - $variant .= ($variant)?'_' . $variants[$i]:$variants[$i]; |
|
| 140 | - $catalogues[] = $catalogue . $this->dataSeparator . $variant . $this->dataExt; |
|
| 139 | + $variant.=($variant) ? '_'.$variants[$i] : $variants[$i]; |
|
| 140 | + $catalogues[]=$catalogue.$this->dataSeparator.$variant.$this->dataExt; |
|
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - $byDir = $this->getCatalogueByDir($catalogue); |
|
| 145 | - $catalogues = array_merge($byDir, array_reverse($catalogues)); |
|
| 146 | - $files = []; |
|
| 144 | + $byDir=$this->getCatalogueByDir($catalogue); |
|
| 145 | + $catalogues=array_merge($byDir, array_reverse($catalogues)); |
|
| 146 | + $files=[]; |
|
| 147 | 147 | |
| 148 | 148 | foreach($catalogues as $file) |
| 149 | 149 | { |
| 150 | - $files[] = $file; |
|
| 151 | - $files[] = preg_replace('/\.xml$/', '.xlf', $file); |
|
| 150 | + $files[]=$file; |
|
| 151 | + $files[]=preg_replace('/\.xml$/', '.xlf', $file); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | return $files; |
@@ -163,16 +163,16 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | private function getCatalogueByDir($catalogue) |
| 165 | 165 | { |
| 166 | - $variants = explode('_', $this->culture); |
|
| 167 | - $catalogues = []; |
|
| 168 | - $variant = null; |
|
| 166 | + $variants=explode('_', $this->culture); |
|
| 167 | + $catalogues=[]; |
|
| 168 | + $variant=null; |
|
| 169 | 169 | |
| 170 | - for($i = 0, $k = count($variants); $i < $k; ++$i) |
|
| 170 | + for($i=0, $k=count($variants); $i < $k; ++$i) |
|
| 171 | 171 | { |
| 172 | 172 | if(isset($variants[$i]{0})) |
| 173 | 173 | { |
| 174 | - $variant .= ($variant)?'_' . $variants[$i]:$variants[$i]; |
|
| 175 | - $catalogues[] = $variant . '/' . $catalogue . $this->dataExt; |
|
| 174 | + $variant.=($variant) ? '_'.$variants[$i] : $variants[$i]; |
|
| 175 | + $catalogues[]=$variant.'/'.$catalogue.$this->dataExt; |
|
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | |
@@ -196,38 +196,38 @@ discard block |
||
| 196 | 196 | * E.g. array('messages','en_AU') |
| 197 | 197 | * @return array list of catalogues |
| 198 | 198 | */ |
| 199 | - protected function getCatalogues($dir = null, $variant = null) |
|
| 199 | + protected function getCatalogues($dir=null, $variant=null) |
|
| 200 | 200 | { |
| 201 | - $dir = $dir?$dir:$this->source; |
|
| 202 | - $files = scandir($dir); |
|
| 203 | - $catalogue = []; |
|
| 201 | + $dir=$dir ? $dir : $this->source; |
|
| 202 | + $files=scandir($dir); |
|
| 203 | + $catalogue=[]; |
|
| 204 | 204 | |
| 205 | 205 | foreach($files as $file) |
| 206 | 206 | { |
| 207 | - if(is_dir($dir . '/' . $file) && preg_match('/^[a-z]{2}(_[A-Z]{2,3})?$/', $file)) { |
|
| 208 | - $catalogue = array_merge( |
|
| 207 | + if(is_dir($dir.'/'.$file) && preg_match('/^[a-z]{2}(_[A-Z]{2,3})?$/', $file)) { |
|
| 208 | + $catalogue=array_merge( |
|
| 209 | 209 | $catalogue, |
| 210 | - $this->getCatalogues($dir . '/' . $file, $file) |
|
| 210 | + $this->getCatalogues($dir.'/'.$file, $file) |
|
| 211 | 211 | ); |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - $pos = strpos($file, $this->dataExt); |
|
| 215 | - if($pos > 0 && substr($file, -1 * strlen($this->dataExt)) == $this->dataExt) |
|
| 214 | + $pos=strpos($file, $this->dataExt); |
|
| 215 | + if($pos > 0 && substr($file, -1 * strlen($this->dataExt))==$this->dataExt) |
|
| 216 | 216 | { |
| 217 | - $name = substr($file, 0, $pos); |
|
| 218 | - $dot = strrpos($name, $this->dataSeparator); |
|
| 219 | - $culture = $variant; |
|
| 220 | - $cat = $name; |
|
| 217 | + $name=substr($file, 0, $pos); |
|
| 218 | + $dot=strrpos($name, $this->dataSeparator); |
|
| 219 | + $culture=$variant; |
|
| 220 | + $cat=$name; |
|
| 221 | 221 | |
| 222 | 222 | if(is_int($dot)) |
| 223 | 223 | { |
| 224 | - $culture = substr($name, $dot + 1, strlen($name)); |
|
| 225 | - $cat = substr($name, 0, $dot); |
|
| 224 | + $culture=substr($name, $dot + 1, strlen($name)); |
|
| 225 | + $cat=substr($name, 0, $dot); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - $details[0] = $cat; |
|
| 229 | - $details[1] = $culture; |
|
| 230 | - $catalogue[] = $details; |
|
| 228 | + $details[0]=$cat; |
|
| 229 | + $details[1]=$culture; |
|
| 230 | + $catalogue[]=$details; |
|
| 231 | 231 | } |
| 232 | 232 | } |
| 233 | 233 | sort($catalogue); |
@@ -242,15 +242,15 @@ discard block |
||
| 242 | 242 | * @see update() |
| 243 | 243 | * @see delete() |
| 244 | 244 | */ |
| 245 | - private function getVariants($catalogue = 'messages') |
|
| 245 | + private function getVariants($catalogue='messages') |
|
| 246 | 246 | { |
| 247 | - if($catalogue === null) { |
|
| 248 | - $catalogue = 'messages'; |
|
| 247 | + if($catalogue===null) { |
|
| 248 | + $catalogue='messages'; |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | foreach($this->getCatalogueList($catalogue) as $variant) |
| 252 | 252 | { |
| 253 | - $file = $this->getSource($variant); |
|
| 253 | + $file=$this->getSource($variant); |
|
| 254 | 254 | if(is_file($file)) { |
| 255 | 255 | return [$variant, $file]; |
| 256 | 256 | } |
@@ -265,50 +265,50 @@ discard block |
||
| 265 | 265 | * @param string the catalogue to add to |
| 266 | 266 | * @return boolean true if saved successfuly, false otherwise. |
| 267 | 267 | */ |
| 268 | - public function save($catalogue = 'messages') |
|
| 268 | + public function save($catalogue='messages') |
|
| 269 | 269 | { |
| 270 | - $messages = $this->untranslated; |
|
| 270 | + $messages=$this->untranslated; |
|
| 271 | 271 | if(count($messages) <= 0) { |
| 272 | 272 | return false; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - $variants = $this->getVariants($catalogue); |
|
| 275 | + $variants=$this->getVariants($catalogue); |
|
| 276 | 276 | |
| 277 | 277 | if($variants) { |
| 278 | - list($variant, $filename) = $variants; |
|
| 278 | + list($variant, $filename)=$variants; |
|
| 279 | 279 | } else { |
| 280 | - list($variant, $filename) = $this->createMessageTemplate($catalogue); |
|
| 280 | + list($variant, $filename)=$this->createMessageTemplate($catalogue); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - if(is_writable($filename) == false) { |
|
| 283 | + if(is_writable($filename)==false) { |
|
| 284 | 284 | throw new TIOException("Unable to save to file {$filename}, file must be writable."); |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | //create a new dom, import the existing xml |
| 288 | - $dom = new DOMDocument(); |
|
| 288 | + $dom=new DOMDocument(); |
|
| 289 | 289 | $dom->load($filename); |
| 290 | 290 | |
| 291 | 291 | //find the body element |
| 292 | - $xpath = new DomXPath($dom); |
|
| 293 | - $body = $xpath->query('//body')->item(0); |
|
| 292 | + $xpath=new DomXPath($dom); |
|
| 293 | + $body=$xpath->query('//body')->item(0); |
|
| 294 | 294 | |
| 295 | - $lastNodes = $xpath->query('//trans-unit[last()]'); |
|
| 296 | - if(($last = $lastNodes->item(0)) !== null) { |
|
| 297 | - $count = (int)$last->getAttribute('id'); |
|
| 295 | + $lastNodes=$xpath->query('//trans-unit[last()]'); |
|
| 296 | + if(($last=$lastNodes->item(0))!==null) { |
|
| 297 | + $count=(int) $last->getAttribute('id'); |
|
| 298 | 298 | } else { |
| 299 | - $count = 0; |
|
| 299 | + $count=0; |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | //for each message add it to the XML file using DOM |
| 303 | 303 | foreach($messages as $message) |
| 304 | 304 | { |
| 305 | - $unit = $dom->createElement('trans-unit'); |
|
| 305 | + $unit=$dom->createElement('trans-unit'); |
|
| 306 | 306 | $unit->setAttribute('id', ++$count); |
| 307 | 307 | |
| 308 | - $source = $dom->createElement('source'); |
|
| 308 | + $source=$dom->createElement('source'); |
|
| 309 | 309 | $source->appendChild($dom->createCDATASection($message)); |
| 310 | 310 | |
| 311 | - $target = $dom->createElement('target'); |
|
| 311 | + $target=$dom->createElement('target'); |
|
| 312 | 312 | $target->appendChild($dom->createCDATASection('')); |
| 313 | 313 | |
| 314 | 314 | $unit->appendChild($dom->createTextNode("\n")); |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | |
| 326 | - $fileNode = $xpath->query('//file')->item(0); |
|
| 326 | + $fileNode=$xpath->query('//file')->item(0); |
|
| 327 | 327 | $fileNode->setAttribute('date', @date('Y-m-d\TH:i:s\Z')); |
| 328 | 328 | |
| 329 | 329 | //save it and clear the cache for this variant |
@@ -343,58 +343,58 @@ discard block |
||
| 343 | 343 | * @param string the catalogue to save to. |
| 344 | 344 | * @return boolean true if translation was updated, false otherwise. |
| 345 | 345 | */ |
| 346 | - public function update($text, $target, $comments, $catalogue = 'messages') |
|
| 346 | + public function update($text, $target, $comments, $catalogue='messages') |
|
| 347 | 347 | { |
| 348 | - $variants = $this->getVariants($catalogue); |
|
| 348 | + $variants=$this->getVariants($catalogue); |
|
| 349 | 349 | |
| 350 | 350 | if($variants) { |
| 351 | - list($variant, $filename) = $variants; |
|
| 351 | + list($variant, $filename)=$variants; |
|
| 352 | 352 | } else { |
| 353 | 353 | return false; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - if(is_writable($filename) == false) { |
|
| 356 | + if(is_writable($filename)==false) { |
|
| 357 | 357 | throw new TIOException("Unable to update file {$filename}, file must be writable."); |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | //create a new dom, import the existing xml |
| 361 | - $dom = DOMDocument::load($filename); |
|
| 361 | + $dom=DOMDocument::load($filename); |
|
| 362 | 362 | |
| 363 | 363 | //find the body element |
| 364 | - $xpath = new DomXPath($dom); |
|
| 365 | - $units = $xpath->query('//trans-unit'); |
|
| 364 | + $xpath=new DomXPath($dom); |
|
| 365 | + $units=$xpath->query('//trans-unit'); |
|
| 366 | 366 | |
| 367 | 367 | //for each of the existin units |
| 368 | 368 | foreach($units as $unit) |
| 369 | 369 | { |
| 370 | - $found = false; |
|
| 371 | - $targetted = false; |
|
| 372 | - $commented = false; |
|
| 370 | + $found=false; |
|
| 371 | + $targetted=false; |
|
| 372 | + $commented=false; |
|
| 373 | 373 | |
| 374 | 374 | //in each unit, need to find the source, target and comment nodes |
| 375 | 375 | //it will assume that the source is before the target. |
| 376 | 376 | foreach($unit->childNodes as $node) |
| 377 | 377 | { |
| 378 | 378 | //source node |
| 379 | - if($node->nodeName == 'source' && $node->firstChild->wholeText == $text) { |
|
| 380 | - $found = true; |
|
| 379 | + if($node->nodeName=='source' && $node->firstChild->wholeText==$text) { |
|
| 380 | + $found=true; |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | //found source, get the target and notes |
| 384 | 384 | if($found) |
| 385 | 385 | { |
| 386 | 386 | //set the new translated string |
| 387 | - if($node->nodeName == 'target') |
|
| 387 | + if($node->nodeName=='target') |
|
| 388 | 388 | { |
| 389 | - $node->nodeValue = $target; |
|
| 390 | - $targetted = true; |
|
| 389 | + $node->nodeValue=$target; |
|
| 390 | + $targetted=true; |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | //set the notes |
| 394 | - if(!empty($comments) && $node->nodeName == 'note') |
|
| 394 | + if(!empty($comments) && $node->nodeName=='note') |
|
| 395 | 395 | { |
| 396 | - $node->nodeValue = $comments; |
|
| 397 | - $commented = true; |
|
| 396 | + $node->nodeValue=$comments; |
|
| 397 | + $commented=true; |
|
| 398 | 398 | } |
| 399 | 399 | } |
| 400 | 400 | } |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | } |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | - $fileNode = $xpath->query('//file')->item(0); |
|
| 418 | + $fileNode=$xpath->query('//file')->item(0); |
|
| 419 | 419 | $fileNode->setAttribute('date', @date('Y-m-d\TH:i:s\Z')); |
| 420 | 420 | |
| 421 | 421 | if($dom->save($filename) > 0) |
@@ -436,25 +436,25 @@ discard block |
||
| 436 | 436 | * @param string the catalogue to delete from. |
| 437 | 437 | * @return boolean true if deleted, false otherwise. |
| 438 | 438 | */ |
| 439 | - public function delete($message, $catalogue = 'messages') |
|
| 439 | + public function delete($message, $catalogue='messages') |
|
| 440 | 440 | { |
| 441 | - $variants = $this->getVariants($catalogue); |
|
| 441 | + $variants=$this->getVariants($catalogue); |
|
| 442 | 442 | if($variants) { |
| 443 | - list($variant, $filename) = $variants; |
|
| 443 | + list($variant, $filename)=$variants; |
|
| 444 | 444 | } else { |
| 445 | 445 | return false; |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | - if(is_writable($filename) == false) { |
|
| 448 | + if(is_writable($filename)==false) { |
|
| 449 | 449 | throw new TIOException("Unable to modify file {$filename}, file must be writable."); |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | //create a new dom, import the existing xml |
| 453 | - $dom = DOMDocument::load($filename); |
|
| 453 | + $dom=DOMDocument::load($filename); |
|
| 454 | 454 | |
| 455 | 455 | //find the body element |
| 456 | - $xpath = new DomXPath($dom); |
|
| 457 | - $units = $xpath->query('//trans-unit'); |
|
| 456 | + $xpath=new DomXPath($dom); |
|
| 457 | + $units=$xpath->query('//trans-unit'); |
|
| 458 | 458 | |
| 459 | 459 | //for each of the existin units |
| 460 | 460 | foreach($units as $unit) |
@@ -464,14 +464,14 @@ discard block |
||
| 464 | 464 | foreach($unit->childNodes as $node) |
| 465 | 465 | { |
| 466 | 466 | //source node |
| 467 | - if($node->nodeName == 'source' && $node->firstChild->wholeText == $message) |
|
| 467 | + if($node->nodeName=='source' && $node->firstChild->wholeText==$message) |
|
| 468 | 468 | { |
| 469 | 469 | //we found it, remove and save the xml file. |
| 470 | 470 | $unit->parentNode->removeChild($unit); |
| 471 | - $fileNode = $xpath->query('//file')->item(0); |
|
| 471 | + $fileNode=$xpath->query('//file')->item(0); |
|
| 472 | 472 | $fileNode->setAttribute('date', @date('Y-m-d\TH:i:s\Z')); |
| 473 | 473 | |
| 474 | - if(false !== $dom->save($filename)) { |
|
| 474 | + if(false!==$dom->save($filename)) { |
|
| 475 | 475 | if(!empty($this->cache)) { |
| 476 | 476 | $this->cache->clean($variant, $this->culture); |
| 477 | 477 | } |
@@ -488,14 +488,14 @@ discard block |
||
| 488 | 488 | |
| 489 | 489 | protected function createMessageTemplate($catalogue) |
| 490 | 490 | { |
| 491 | - if($catalogue === null) { |
|
| 492 | - $catalogue = 'messages'; |
|
| 491 | + if($catalogue===null) { |
|
| 492 | + $catalogue='messages'; |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | - $variants = $this->getCatalogueList($catalogue); |
|
| 496 | - $variant = array_shift($variants); |
|
| 497 | - $file = $this->getSource($variant); |
|
| 498 | - $dir = dirname($file); |
|
| 495 | + $variants=$this->getCatalogueList($catalogue); |
|
| 496 | + $variant=array_shift($variants); |
|
| 497 | + $file=$this->getSource($variant); |
|
| 498 | + $dir=dirname($file); |
|
| 499 | 499 | |
| 500 | 500 | if(!is_dir($dir)) { |
| 501 | 501 | @mkdir($dir); |
@@ -514,8 +514,8 @@ discard block |
||
| 514 | 514 | |
| 515 | 515 | protected function getTemplate($catalogue) |
| 516 | 516 | { |
| 517 | - $date = @date('c'); |
|
| 518 | - $xml = <<<EOD |
|
| 517 | + $date=@date('c'); |
|
| 518 | + $xml=<<<EOD |
|
| 519 | 519 | <?xml version="1.0" encoding="UTF-8"?> |
| 520 | 520 | <xliff version="1.0"> |
| 521 | 521 | <file source-language="EN" target-language="{$this->culture}" datatype="plaintext" original="$catalogue" date="$date" product-name="$catalogue"> |
@@ -38,6 +38,7 @@ |
||
| 38 | 38 | /** |
| 39 | 39 | * Writes a string. |
| 40 | 40 | * @param string string to be written |
| 41 | + * @param string $str |
|
| 41 | 42 | */ |
| 42 | 43 | public function write($str) |
| 43 | 44 | { |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | class TTextWriter extends \Prado\TComponent implements \Prado\IO\ITextWriter |
| 26 | 26 | { |
| 27 | - private $_str = ''; |
|
| 27 | + private $_str=''; |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Flushes the content that has been written. |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public function flush() |
| 34 | 34 | { |
| 35 | - $str = $this->_str; |
|
| 36 | - $this->_str = ''; |
|
| 35 | + $str=$this->_str; |
|
| 36 | + $this->_str=''; |
|
| 37 | 37 | return $str; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function write($str) |
| 45 | 45 | { |
| 46 | - $this->_str .= $str; |
|
| 46 | + $this->_str.=$str; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | * @param string content to be written |
| 52 | 52 | * @see write |
| 53 | 53 | */ |
| 54 | - public function writeLine($str = '') |
|
| 54 | + public function writeLine($str='') |
|
| 55 | 55 | { |
| 56 | - $this->write($str . "\n"); |
|
| 56 | + $this->write($str."\n"); |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | |
@@ -49,6 +49,7 @@ |
||
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * @param string id of this service |
| 52 | + * @param string $value |
|
| 52 | 53 | */ |
| 53 | 54 | public function setID($value) |
| 54 | 55 | { |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | /** |
| 31 | 31 | * @var boolean whether the service is enabled |
| 32 | 32 | */ |
| 33 | - private $_enabled = true; |
|
| 33 | + private $_enabled=true; |
|
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * Initializes the service and attaches {@link run} to the RunService event of application. |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function setID($value) |
| 56 | 56 | { |
| 57 | - $this->_id = $value; |
|
| 57 | + $this->_id=$value; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function setEnabled($value) |
| 72 | 72 | { |
| 73 | - $this->_enabled = TPropertyValue::ensureBoolean($value); |
|
| 73 | + $this->_enabled=TPropertyValue::ensureBoolean($value); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -98,6 +98,7 @@ |
||
| 98 | 98 | * @param integer level filter |
| 99 | 99 | * @param array category filter |
| 100 | 100 | * @param array control filter |
| 101 | + * @param integer $levels |
|
| 101 | 102 | * @return array list of messages. Each array elements represents one message |
| 102 | 103 | * with the following structure: |
| 103 | 104 | * array( |
@@ -29,17 +29,17 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * Log levels. |
| 31 | 31 | */ |
| 32 | - const DEBUG = 0x01; |
|
| 33 | - const INFO = 0x02; |
|
| 34 | - const NOTICE = 0x04; |
|
| 35 | - const WARNING = 0x08; |
|
| 36 | - const ERROR = 0x10; |
|
| 37 | - const ALERT = 0x20; |
|
| 38 | - const FATAL = 0x40; |
|
| 32 | + const DEBUG=0x01; |
|
| 33 | + const INFO=0x02; |
|
| 34 | + const NOTICE=0x04; |
|
| 35 | + const WARNING=0x08; |
|
| 36 | + const ERROR=0x10; |
|
| 37 | + const ALERT=0x20; |
|
| 38 | + const FATAL=0x40; |
|
| 39 | 39 | /** |
| 40 | 40 | * @var array log messages |
| 41 | 41 | */ |
| 42 | - private $_logs = []; |
|
| 42 | + private $_logs=[]; |
|
| 43 | 43 | /** |
| 44 | 44 | * @var integer log levels (bits) to be filtered |
| 45 | 45 | */ |
@@ -67,16 +67,16 @@ discard block |
||
| 67 | 67 | * @param string category of the message |
| 68 | 68 | * @param string|TControl control of the message |
| 69 | 69 | */ |
| 70 | - public function log($message, $level, $category = 'Uncategorized', $ctl = null) |
|
| 70 | + public function log($message, $level, $category='Uncategorized', $ctl=null) |
|
| 71 | 71 | { |
| 72 | 72 | if($ctl) { |
| 73 | 73 | if($ctl instanceof TControl) |
| 74 | - $ctl = $ctl->ClientId; |
|
| 74 | + $ctl=$ctl->ClientId; |
|
| 75 | 75 | elseif(!is_string($ctl)) |
| 76 | - $ctl = null; |
|
| 76 | + $ctl=null; |
|
| 77 | 77 | } else |
| 78 | - $ctl = null; |
|
| 79 | - $this->_logs[] = [$message,$level,$category,microtime(true),memory_get_usage(),$ctl]; |
|
| 78 | + $ctl=null; |
|
| 79 | + $this->_logs[]=[$message, $level, $category, microtime(true), memory_get_usage(), $ctl]; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -112,23 +112,23 @@ discard block |
||
| 112 | 112 | * [4] => memory in bytes |
| 113 | 113 | * [5] => control client id |
| 114 | 114 | */ |
| 115 | - public function getLogs($levels = null, $categories = null, $controls = null, $timestamp = null) |
|
| 115 | + public function getLogs($levels=null, $categories=null, $controls=null, $timestamp=null) |
|
| 116 | 116 | { |
| 117 | - $this->_levels = $levels; |
|
| 118 | - $this->_categories = $categories; |
|
| 119 | - $this->_controls = $controls; |
|
| 120 | - $this->_timestamp = $timestamp; |
|
| 121 | - if(empty($levels) && empty($categories) && empty($controls) && null === $timestamp) |
|
| 117 | + $this->_levels=$levels; |
|
| 118 | + $this->_categories=$categories; |
|
| 119 | + $this->_controls=$controls; |
|
| 120 | + $this->_timestamp=$timestamp; |
|
| 121 | + if(empty($levels) && empty($categories) && empty($controls) && null===$timestamp) |
|
| 122 | 122 | return $this->_logs; |
| 123 | - $logs = $this->_logs; |
|
| 123 | + $logs=$this->_logs; |
|
| 124 | 124 | if(!empty($levels)) |
| 125 | - $logs = array_values(array_filter(array_filter($logs, [$this,'filterByLevels']))); |
|
| 125 | + $logs=array_values(array_filter(array_filter($logs, [$this, 'filterByLevels']))); |
|
| 126 | 126 | if(!empty($categories)) |
| 127 | - $logs = array_values(array_filter(array_filter($logs, [$this,'filterByCategories']))); |
|
| 127 | + $logs=array_values(array_filter(array_filter($logs, [$this, 'filterByCategories']))); |
|
| 128 | 128 | if(!empty($controls)) |
| 129 | - $logs = array_values(array_filter(array_filter($logs, [$this,'filterByControl']))); |
|
| 130 | - if(null !== $timestamp) |
|
| 131 | - $logs = array_values(array_filter(array_filter($logs, [$this,'filterByTimeStamp']))); |
|
| 129 | + $logs=array_values(array_filter(array_filter($logs, [$this, 'filterByControl']))); |
|
| 130 | + if(null!==$timestamp) |
|
| 131 | + $logs=array_values(array_filter(array_filter($logs, [$this, 'filterByTimeStamp']))); |
|
| 132 | 132 | return $logs; |
| 133 | 133 | } |
| 134 | 134 | |
@@ -156,27 +156,27 @@ discard block |
||
| 156 | 156 | * @param array category filter |
| 157 | 157 | * @param array control filter |
| 158 | 158 | */ |
| 159 | - public function deleteLogs($levels = null, $categories = null, $controls = null, $timestamp = null) |
|
| 159 | + public function deleteLogs($levels=null, $categories=null, $controls=null, $timestamp=null) |
|
| 160 | 160 | { |
| 161 | - $this->_levels = $levels; |
|
| 162 | - $this->_categories = $categories; |
|
| 163 | - $this->_controls = $controls; |
|
| 164 | - $this->_timestamp = $timestamp; |
|
| 165 | - if(empty($levels) && empty($categories) && empty($controls) && null === $timestamp) |
|
| 161 | + $this->_levels=$levels; |
|
| 162 | + $this->_categories=$categories; |
|
| 163 | + $this->_controls=$controls; |
|
| 164 | + $this->_timestamp=$timestamp; |
|
| 165 | + if(empty($levels) && empty($categories) && empty($controls) && null===$timestamp) |
|
| 166 | 166 | { |
| 167 | - $this->_logs = []; |
|
| 167 | + $this->_logs=[]; |
|
| 168 | 168 | return; |
| 169 | 169 | } |
| 170 | - $logs = $this->_logs; |
|
| 170 | + $logs=$this->_logs; |
|
| 171 | 171 | if(!empty($levels)) |
| 172 | - $logs = array_filter(array_filter($logs, [$this,'filterByLevels'])); |
|
| 172 | + $logs=array_filter(array_filter($logs, [$this, 'filterByLevels'])); |
|
| 173 | 173 | if(!empty($categories)) |
| 174 | - $logs = array_filter(array_filter($logs, [$this,'filterByCategories'])); |
|
| 174 | + $logs=array_filter(array_filter($logs, [$this, 'filterByCategories'])); |
|
| 175 | 175 | if(!empty($controls)) |
| 176 | - $logs = array_filter(array_filter($logs, [$this,'filterByControl'])); |
|
| 177 | - if(null !== $timestamp) |
|
| 178 | - $logs = array_filter(array_filter($logs, [$this,'filterByTimeStamp'])); |
|
| 179 | - $this->_logs = array_values(array_diff_key($this->_logs, $logs)); |
|
| 176 | + $logs=array_filter(array_filter($logs, [$this, 'filterByControl'])); |
|
| 177 | + if(null!==$timestamp) |
|
| 178 | + $logs=array_filter(array_filter($logs, [$this, 'filterByTimeStamp'])); |
|
| 179 | + $this->_logs=array_values(array_diff_key($this->_logs, $logs)); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | foreach($this->_categories as $category) |
| 189 | 189 | { |
| 190 | 190 | // element 2 is the category |
| 191 | - if($value[2] === $category || strpos($value[2], $category . '.') === 0) |
|
| 191 | + if($value[2]===$category || strpos($value[2], $category.'.')===0) |
|
| 192 | 192 | return $value; |
| 193 | 193 | } |
| 194 | 194 | return false; |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | // element 5 are the control client ids |
| 217 | 217 | foreach($this->_controls as $control) |
| 218 | 218 | { |
| 219 | - if($value[5] === $control || strpos($value[5], $control) === 0) |
|
| 219 | + if($value[5]===$control || strpos($value[5], $control)===0) |
|
| 220 | 220 | return $value; |
| 221 | 221 | } |
| 222 | 222 | return false; |
@@ -105,6 +105,9 @@ |
||
| 105 | 105 | * @param string RPC server URL |
| 106 | 106 | * @param array payload data |
| 107 | 107 | * @param string request mime type |
| 108 | + * @param string $serverUrl |
|
| 109 | + * @param string $mimeType |
|
| 110 | + * @return string |
|
| 108 | 111 | */ |
| 109 | 112 | protected function performRequest($serverUrl, $payload, $mimeType) |
| 110 | 113 | { |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | /** |
| 59 | 59 | * @var boolean whether the request is a notification and therefore should not care about the result (default: false) |
| 60 | 60 | */ |
| 61 | - private $_isNotification = false; |
|
| 61 | + private $_isNotification=false; |
|
| 62 | 62 | |
| 63 | 63 | // magics |
| 64 | 64 | |
@@ -66,10 +66,10 @@ discard block |
||
| 66 | 66 | * @param string url to RPC server |
| 67 | 67 | * @param boolean whether requests are considered to be notifications (completely ignoring the response) (default: false) |
| 68 | 68 | */ |
| 69 | - public function __construct($serverUrl, $isNotification = false) |
|
| 69 | + public function __construct($serverUrl, $isNotification=false) |
|
| 70 | 70 | { |
| 71 | - $this->_serverUrl = $serverUrl; |
|
| 72 | - $this->_isNotification = TPropertyValue::ensureBoolean($isNotification); |
|
| 71 | + $this->_serverUrl=$serverUrl; |
|
| 72 | + $this->_isNotification=TPropertyValue::ensureBoolean($isNotification); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // methods |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | * @return TRpcClient instance |
| 80 | 80 | * @throws TApplicationException if an unsupported RPC client type was specified |
| 81 | 81 | */ |
| 82 | - public static function create($type, $serverUrl, $isNotification = false) |
|
| 82 | + public static function create($type, $serverUrl, $isNotification=false) |
|
| 83 | 83 | { |
| 84 | - if(($_handler = constant('TRpcClientTypesEnumerable::' . strtoupper($type))) === null) |
|
| 84 | + if(($_handler=constant('TRpcClientTypesEnumerable::'.strtoupper($type)))===null) |
|
| 85 | 85 | throw new TApplicationException('rpcclient_unsupported_handler'); |
| 86 | 86 | |
| 87 | 87 | return new $_handler($serverUrl, $isNotification); |
@@ -111,8 +111,8 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | protected function performRequest($serverUrl, $payload, $mimeType) |
| 113 | 113 | { |
| 114 | - if(($_response = @file_get_contents($serverUrl, false, $this->createStreamContext($payload, $mimeType))) === false) |
|
| 115 | - throw new TRpcClientRequestException('Request failed ("' . $http_response_header[0] . '")'); |
|
| 114 | + if(($_response=@file_get_contents($serverUrl, false, $this->createStreamContext($payload, $mimeType)))===false) |
|
| 115 | + throw new TRpcClientRequestException('Request failed ("'.$http_response_header[0].'")'); |
|
| 116 | 116 | |
| 117 | 117 | return $_response; |
| 118 | 118 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | public function setIsNotification($bool) |
| 134 | 134 | { |
| 135 | - $this->_isNotification = TPropertyValue::ensureBoolean($bool); |
|
| 135 | + $this->_isNotification=TPropertyValue::ensureBoolean($bool); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -148,6 +148,6 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public function setServerUrl($value) |
| 150 | 150 | { |
| 151 | - $this->_serverUrl = $value; |
|
| 151 | + $this->_serverUrl=$value; |
|
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | \ No newline at end of file |