@@ -18,19 +18,19 @@ |
||
| 18 | 18 | |
| 19 | 19 | public function login() |
| 20 | 20 | { |
| 21 | - if ($this->IsValid) |
|
| 21 | + if($this->IsValid) |
|
| 22 | 22 | { |
| 23 | - $this->Session["wsat_password"] = $this->getService()->getPassword(); |
|
| 24 | - $url = $this->Service->constructUrl('TWsatHome'); |
|
| 23 | + $this->Session["wsat_password"]=$this->getService()->getPassword(); |
|
| 24 | + $url=$this->Service->constructUrl('TWsatHome'); |
|
| 25 | 25 | $this->Response->redirect($url); |
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public function validatePassword($sender, $param) |
| 30 | 30 | { |
| 31 | - $config_pass = $this->Service->Password; |
|
| 32 | - $user_pass = $this->password->Text; |
|
| 33 | - $param->IsValid = $user_pass === $config_pass; |
|
| 31 | + $config_pass=$this->Service->Password; |
|
| 32 | + $user_pass=$this->password->Text; |
|
| 33 | + $param->IsValid=$user_pass===$config_pass; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | } |
| 37 | 37 | \ No newline at end of file |
@@ -43,15 +43,15 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | class TWsatService extends TPageService |
| 45 | 45 | { |
| 46 | - const PAGE_NAMESPACE_PREFIX = 'Prado\\Wsat\\pages\\'; |
|
| 47 | - private $_pass = ''; |
|
| 46 | + const PAGE_NAMESPACE_PREFIX='Prado\\Wsat\\pages\\'; |
|
| 47 | + private $_pass=''; |
|
| 48 | 48 | |
| 49 | 49 | public function init($config) |
| 50 | 50 | { |
| 51 | - if ($this->getApplication()->getMode() === TApplicationMode::Performance || $this->getApplication()->getMode() === TApplicationMode::Normal) |
|
| 51 | + if($this->getApplication()->getMode()===TApplicationMode::Performance || $this->getApplication()->getMode()===TApplicationMode::Normal) |
|
| 52 | 52 | throw new TInvalidOperationException("You should not use Prado WSAT in any of the production modes."); |
| 53 | 53 | |
| 54 | - if (empty($this->_pass)) |
|
| 54 | + if(empty($this->_pass)) |
|
| 55 | 55 | throw new TConfigurationException("You need to specify the Password attribute."); |
| 56 | 56 | |
| 57 | 57 | $this->setDefaultPage("TWsatHome"); |
@@ -61,16 +61,16 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | public function getBasePath() |
| 63 | 63 | { |
| 64 | - $basePath = Prado::getPathOfNamespace("System.Wsat.pages"); |
|
| 64 | + $basePath=Prado::getPathOfNamespace("System.Wsat.pages"); |
|
| 65 | 65 | return realpath($basePath); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | private function _startThemeManager() |
| 69 | 69 | { |
| 70 | - $themeManager = new TThemeManager; |
|
| 71 | - $themeManager->BasePath = "System.Wsat.themes"; |
|
| 72 | - $url = Prado::getApplication()->getAssetManager()->publishFilePath(Prado::getPathOfNamespace('System.Wsat')); |
|
| 73 | - $themeManager->BaseUrl = "$url/themes"; |
|
| 70 | + $themeManager=new TThemeManager; |
|
| 71 | + $themeManager->BasePath="System.Wsat.themes"; |
|
| 72 | + $url=Prado::getApplication()->getAssetManager()->publishFilePath(Prado::getPathOfNamespace('System.Wsat')); |
|
| 73 | + $themeManager->BaseUrl="$url/themes"; |
|
| 74 | 74 | |
| 75 | 75 | $themeManager->init(null); |
| 76 | 76 | $this->setThemeManager($themeManager); |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | public function setPassword($_pass) |
| 85 | 85 | { |
| 86 | - $this->_pass = $_pass; |
|
| 86 | + $this->_pass=$_pass; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | } |
| 90 | 90 | \ No newline at end of file |
@@ -33,31 +33,31 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | public function __construct() |
| 35 | 35 | { |
| 36 | - if (!class_exists("TActiveRecordManager", false)) |
|
| 36 | + if(!class_exists("TActiveRecordManager", false)) |
|
| 37 | 37 | throw new Exception("You need to enable the ActiveRecord module in your application configuration file."); |
| 38 | - $ar_manager = TActiveRecordManager::getInstance(); |
|
| 39 | - $_conn = $ar_manager->getDbConnection(); |
|
| 40 | - $_conn->Active = true; |
|
| 41 | - $this->_dbMetaData = TDbMetaData::getInstance($_conn); |
|
| 38 | + $ar_manager=TActiveRecordManager::getInstance(); |
|
| 39 | + $_conn=$ar_manager->getDbConnection(); |
|
| 40 | + $_conn->Active=true; |
|
| 41 | + $this->_dbMetaData=TDbMetaData::getInstance($_conn); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public function setOpFile($op_file_namespace) |
| 45 | 45 | { |
| 46 | - $op_file = Prado::getPathOfNamespace($op_file_namespace); |
|
| 47 | - if (empty($op_file)) |
|
| 46 | + $op_file=Prado::getPathOfNamespace($op_file_namespace); |
|
| 47 | + if(empty($op_file)) |
|
| 48 | 48 | throw new Exception("You need to fix your output folder namespace."); |
| 49 | - if (!is_dir($op_file)) |
|
| 49 | + if(!is_dir($op_file)) |
|
| 50 | 50 | mkdir($op_file, 0777, true); |
| 51 | - $this->_opFile = $op_file; |
|
| 51 | + $this->_opFile=$op_file; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public function renderAllTablesInformation() |
| 55 | 55 | { |
| 56 | - foreach ($this->getAllTableNames() as $table_name) |
|
| 56 | + foreach($this->getAllTableNames() as $table_name) |
|
| 57 | 57 | { |
| 58 | - echo $table_name . "<br>"; |
|
| 59 | - $tableInfo = $this->_dbMetaData->getTableInfo($table_name); |
|
| 60 | - echo "Table info:" . "<br>"; |
|
| 58 | + echo $table_name."<br>"; |
|
| 59 | + $tableInfo=$this->_dbMetaData->getTableInfo($table_name); |
|
| 60 | + echo "Table info:"."<br>"; |
|
| 61 | 61 | echo "<pre>"; |
| 62 | 62 | print_r($tableInfo); |
| 63 | 63 | echo "</pre>"; |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | public function getAllTableNames() |
| 68 | 68 | { |
| 69 | - $tableNames = $this->_dbMetaData->findTableNames(); |
|
| 70 | - $index = array_search('pradocache', $tableNames); |
|
| 71 | - if ($index) |
|
| 69 | + $tableNames=$this->_dbMetaData->findTableNames(); |
|
| 70 | + $index=array_search('pradocache', $tableNames); |
|
| 71 | + if($index) |
|
| 72 | 72 | array_splice($tableNames, $index, 1); |
| 73 | 73 | return $tableNames; |
| 74 | 74 | } |
@@ -82,6 +82,6 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | protected function eq($data) |
| 84 | 84 | { |
| 85 | - return '"' . $data . '"'; |
|
| 85 | + return '"'.$data.'"'; |
|
| 86 | 86 | } |
| 87 | 87 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * unquote chars |
| 39 | 39 | * @var array |
| 40 | 40 | */ |
| 41 | - private $uqChars = ['[', ']', '"', '`', "'"]; |
|
| 41 | + private $uqChars=['[', ']', '"', '`', "'"]; |
|
| 42 | 42 | |
| 43 | 43 | public function __construct() |
| 44 | 44 | { |
@@ -47,31 +47,31 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | public function setClasPrefix($_clas_prefix) |
| 49 | 49 | { |
| 50 | - $this->_clasPrefix = $_clas_prefix; |
|
| 50 | + $this->_clasPrefix=$_clas_prefix; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | public function setClassSufix($_clas_sufix) |
| 54 | 54 | { |
| 55 | - $this->_classSufix = $_clas_sufix; |
|
| 55 | + $this->_classSufix=$_clas_sufix; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | //----------------------------------------------------------------------------- |
| 59 | 59 | // <editor-fold defaultstate="collapsed" desc="Main APIs"> |
| 60 | 60 | public function generate($tableName) |
| 61 | 61 | { |
| 62 | - $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
| 62 | + $tableInfo=$this->_dbMetaData->getTableInfo($tableName); |
|
| 63 | 63 | $this->_commonGenerate($tableName, $tableInfo); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public function generateAll() |
| 67 | 67 | { |
| 68 | - foreach ($this->getAllTableNames() as $tableName) |
|
| 68 | + foreach($this->getAllTableNames() as $tableName) |
|
| 69 | 69 | { |
| 70 | - $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
| 71 | - if (!empty($this->_relations)) |
|
| 70 | + $tableInfo=$this->_dbMetaData->getTableInfo($tableName); |
|
| 71 | + if(!empty($this->_relations)) |
|
| 72 | 72 | { |
| 73 | 73 | // Cancel generation of M-M relationships middle table |
| 74 | - if (count($tableInfo->getPrimaryKeys()) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
| 74 | + if(count($tableInfo->getPrimaryKeys())===2 && count($tableInfo->getColumns())===2)//M-M relationships |
|
| 75 | 75 | continue; |
| 76 | 76 | } |
| 77 | 77 | $this->_commonGenerate($tableName, $tableInfo); |
@@ -80,26 +80,26 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | public function buildRelations() |
| 82 | 82 | { |
| 83 | - $this->_relations = []; |
|
| 84 | - foreach ($this->getAllTableNames() as $table_name) |
|
| 83 | + $this->_relations=[]; |
|
| 84 | + foreach($this->getAllTableNames() as $table_name) |
|
| 85 | 85 | { |
| 86 | - $tableInfo = $this->_dbMetaData->getTableInfo($table_name); |
|
| 87 | - $pks = $tableInfo->getPrimaryKeys(); |
|
| 88 | - $fks = $tableInfo->getForeignKeys(); |
|
| 86 | + $tableInfo=$this->_dbMetaData->getTableInfo($table_name); |
|
| 87 | + $pks=$tableInfo->getPrimaryKeys(); |
|
| 88 | + $fks=$tableInfo->getForeignKeys(); |
|
| 89 | 89 | |
| 90 | - if (count($pks) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
| 90 | + if(count($pks)===2 && count($tableInfo->getColumns())===2)//M-M relationships |
|
| 91 | 91 | { |
| 92 | - $table_name_mm = $fks[0]["table"]; |
|
| 93 | - $table_name_mm2 = $fks[1]["table"]; |
|
| 92 | + $table_name_mm=$fks[0]["table"]; |
|
| 93 | + $table_name_mm2=$fks[1]["table"]; |
|
| 94 | 94 | |
| 95 | - $this->_relations[$table_name_mm][] = [ |
|
| 95 | + $this->_relations[$table_name_mm][]=[ |
|
| 96 | 96 | "prop_name" => strtolower($table_name_mm2), |
| 97 | 97 | "rel_type" => "self::MANY_TO_MANY", |
| 98 | 98 | "ref_class_name" => $this->_getProperClassName($table_name_mm2), |
| 99 | 99 | "prop_ref" => $table_name |
| 100 | 100 | ]; |
| 101 | 101 | |
| 102 | - $this->_relations[$table_name_mm2][] = [ |
|
| 102 | + $this->_relations[$table_name_mm2][]=[ |
|
| 103 | 103 | "prop_name" => strtolower($table_name_mm), |
| 104 | 104 | "rel_type" => "self::MANY_TO_MANY", |
| 105 | 105 | "ref_class_name" => $this->_getProperClassName($table_name_mm), |
@@ -107,20 +107,20 @@ discard block |
||
| 107 | 107 | ]; |
| 108 | 108 | continue; |
| 109 | 109 | } |
| 110 | - foreach ($fks as $fk_data)//1-M relationships |
|
| 110 | + foreach($fks as $fk_data)//1-M relationships |
|
| 111 | 111 | { |
| 112 | - $owner_table = $fk_data["table"]; |
|
| 113 | - $slave_table = $table_name; |
|
| 114 | - $fk_prop = key($fk_data["keys"]); |
|
| 112 | + $owner_table=$fk_data["table"]; |
|
| 113 | + $slave_table=$table_name; |
|
| 114 | + $fk_prop=key($fk_data["keys"]); |
|
| 115 | 115 | |
| 116 | - $this->_relations[$owner_table][] = [ |
|
| 116 | + $this->_relations[$owner_table][]=[ |
|
| 117 | 117 | "prop_name" => strtolower($slave_table), |
| 118 | 118 | "rel_type" => "self::HAS_MANY", |
| 119 | 119 | "ref_class_name" => $this->_getProperClassName($slave_table), |
| 120 | 120 | "prop_ref" => $fk_prop |
| 121 | 121 | ]; |
| 122 | 122 | |
| 123 | - $this->_relations[$slave_table][] = [ |
|
| 123 | + $this->_relations[$slave_table][]=[ |
|
| 124 | 124 | "prop_name" => strtolower($owner_table), |
| 125 | 125 | "rel_type" => "self::BELONGS_TO", |
| 126 | 126 | "ref_class_name" => $this->_getProperClassName($owner_table), |
@@ -136,88 +136,88 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | private function _commonGenerate($tableName, $tableInfo) |
| 138 | 138 | { |
| 139 | - if (count($tableInfo->getColumns()) === 0) |
|
| 140 | - throw new Exception("Unable to find table or view $tableName in " . $this->_dbMetaData->getDbConnection()->getConnectionString() . "."); |
|
| 139 | + if(count($tableInfo->getColumns())===0) |
|
| 140 | + throw new Exception("Unable to find table or view $tableName in ".$this->_dbMetaData->getDbConnection()->getConnectionString()."."); |
|
| 141 | 141 | else |
| 142 | 142 | { |
| 143 | - $properties = []; |
|
| 144 | - foreach ($tableInfo->getColumns() as $field => $metadata) |
|
| 145 | - $properties[] = $this->generateProperty($field, $metadata); |
|
| 146 | - $toString = $this->_buildSmartToString($tableInfo); |
|
| 143 | + $properties=[]; |
|
| 144 | + foreach($tableInfo->getColumns() as $field => $metadata) |
|
| 145 | + $properties[]=$this->generateProperty($field, $metadata); |
|
| 146 | + $toString=$this->_buildSmartToString($tableInfo); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - $clasName = $this->_getProperClassName($tableName); |
|
| 150 | - $class = $this->generateClass($properties, $tableName, $clasName, $toString); |
|
| 151 | - $output = $this->_opFile . DIRECTORY_SEPARATOR . $clasName . ".php"; |
|
| 149 | + $clasName=$this->_getProperClassName($tableName); |
|
| 150 | + $class=$this->generateClass($properties, $tableName, $clasName, $toString); |
|
| 151 | + $output=$this->_opFile.DIRECTORY_SEPARATOR.$clasName.".php"; |
|
| 152 | 152 | file_put_contents($output, $class); |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | private function _getProperClassName($tableName) |
| 156 | 156 | { |
| 157 | - $table_name_words = str_replace("_", " ", strtolower($tableName)); |
|
| 158 | - $final_conversion = str_replace(" ", "", ucwords($table_name_words)); |
|
| 159 | - return $this->_clasPrefix . $final_conversion . $this->_classSufix; |
|
| 157 | + $table_name_words=str_replace("_", " ", strtolower($tableName)); |
|
| 158 | + $final_conversion=str_replace(" ", "", ucwords($table_name_words)); |
|
| 159 | + return $this->_clasPrefix.$final_conversion.$this->_classSufix; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | //----------------------------------------------------------------------------- |
| 163 | 163 | |
| 164 | 164 | protected function generateProperty($field, $metadata) |
| 165 | 165 | { |
| 166 | - $prop = ''; |
|
| 167 | - $name = '$' . $field; |
|
| 166 | + $prop=''; |
|
| 167 | + $name='$'.$field; |
|
| 168 | 168 | |
| 169 | 169 | /* TODO use in version 2.0 */ |
| 170 | 170 | // $type = $column->getPHPType(); |
| 171 | 171 | |
| 172 | - $prop .= "\tpublic $name;"; |
|
| 172 | + $prop.="\tpublic $name;"; |
|
| 173 | 173 | return $prop; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | private function _renderRelations($tablename) |
| 177 | 177 | { |
| 178 | - if (!isset($this->_relations[$tablename])) |
|
| 178 | + if(!isset($this->_relations[$tablename])) |
|
| 179 | 179 | return ""; |
| 180 | 180 | |
| 181 | - $code = "\tpublic static \$RELATIONS = array ("; |
|
| 182 | - foreach ($this->_relations[$tablename] as $rel_data) |
|
| 183 | - $code .= "\n\t\t'" . $rel_data["prop_name"] . "' => array(" . $rel_data["rel_type"] . ", '" . $rel_data["ref_class_name"] . "', '" . $rel_data["prop_ref"] . "'),"; |
|
| 181 | + $code="\tpublic static \$RELATIONS = array ("; |
|
| 182 | + foreach($this->_relations[$tablename] as $rel_data) |
|
| 183 | + $code.="\n\t\t'".$rel_data["prop_name"]."' => array(".$rel_data["rel_type"].", '".$rel_data["ref_class_name"]."', '".$rel_data["prop_ref"]."'),"; |
|
| 184 | 184 | |
| 185 | - $code = substr($code, 0, -1); |
|
| 186 | - $code .= "\n\t);"; |
|
| 185 | + $code=substr($code, 0, -1); |
|
| 186 | + $code.="\n\t);"; |
|
| 187 | 187 | return $code; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | private function _buildSmartToString($tableInfo) |
| 191 | 191 | { |
| 192 | - $code = "\tpublic function __toString() {"; |
|
| 193 | - $property = "throw new THttpException(500, 'Not implemented yet.');"; |
|
| 192 | + $code="\tpublic function __toString() {"; |
|
| 193 | + $property="throw new THttpException(500, 'Not implemented yet.');"; |
|
| 194 | 194 | try |
| 195 | 195 | { |
| 196 | - foreach ($tableInfo->getColumns() as $column) |
|
| 196 | + foreach($tableInfo->getColumns() as $column) |
|
| 197 | 197 | { |
| 198 | - if (isset($column->IsPrimaryKey) && $column->IsPrimaryKey) |
|
| 199 | - $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
| 200 | - elseif ($column->PdoType == PDO::PARAM_STR && $column->DBType != "date") |
|
| 198 | + if(isset($column->IsPrimaryKey) && $column->IsPrimaryKey) |
|
| 199 | + $property=str_replace($this->uqChars, "", $column->ColumnName); |
|
| 200 | + elseif($column->PdoType==PDO::PARAM_STR && $column->DBType!="date") |
|
| 201 | 201 | { |
| 202 | - $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
| 202 | + $property=str_replace($this->uqChars, "", $column->ColumnName); |
|
| 203 | 203 | break; |
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | - } catch (Exception $ex) |
|
| 206 | + } catch(Exception $ex) |
|
| 207 | 207 | { |
| 208 | 208 | Prado::trace($ex->getMessage()); |
| 209 | 209 | } |
| 210 | - $code .= "\n\t\treturn \$this->$property;"; |
|
| 211 | - $code .= "\n\t}"; |
|
| 210 | + $code.="\n\t\treturn \$this->$property;"; |
|
| 211 | + $code.="\n\t}"; |
|
| 212 | 212 | return $code; |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | protected function generateClass($properties, $tablename, $classname, $toString) |
| 216 | 216 | { |
| 217 | - $props = implode("\n", $properties); |
|
| 218 | - $relations = $this->_renderRelations($tablename); |
|
| 219 | - $date = date('Y-m-d h:i:s'); |
|
| 220 | - $env_user = getenv("username"); |
|
| 217 | + $props=implode("\n", $properties); |
|
| 218 | + $relations=$this->_renderRelations($tablename); |
|
| 219 | + $date=date('Y-m-d h:i:s'); |
|
| 220 | + $env_user=getenv("username"); |
|
| 221 | 221 | return <<<EOD |
| 222 | 222 | <?php |
| 223 | 223 | /** |
@@ -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 |
@@ -43,18 +43,18 @@ discard block |
||
| 43 | 43 | public function __call($method, $parameters) |
| 44 | 44 | { |
| 45 | 45 | // send request |
| 46 | - $_response = $this->performRequest($this->getServerUrl(), $this->encodeRequest($method, $parameters), 'application/json'); |
|
| 46 | + $_response=$this->performRequest($this->getServerUrl(), $this->encodeRequest($method, $parameters), 'application/json'); |
|
| 47 | 47 | |
| 48 | 48 | // skip response handling if the request was just a notification request |
| 49 | 49 | if($this->isNotification) |
| 50 | 50 | return true; |
| 51 | 51 | |
| 52 | 52 | // decode response |
| 53 | - if(($_response = json_decode($_response, true)) === null) |
|
| 53 | + if(($_response=json_decode($_response, true))===null) |
|
| 54 | 54 | throw new TRpcClientResponseException('Empty response received'); |
| 55 | 55 | |
| 56 | 56 | // handle error response |
| 57 | - if(null !== $_response['error']) |
|
| 57 | + if(null!==$_response['error']) |
|
| 58 | 58 | throw new TRpcClientResponseException($_response['error']); |
| 59 | 59 | |
| 60 | 60 | return $_response['result']; |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | public function encodeRequest($method, $parameters) |
| 70 | 70 | { |
| 71 | 71 | static $_requestId; |
| 72 | - $_requestId = ($_requestId === null) ? 1 : $_requestId + 1; |
|
| 72 | + $_requestId=($_requestId===null) ? 1 : $_requestId + 1; |
|
| 73 | 73 | |
| 74 | 74 | return json_encode([ |
| 75 | 75 | 'method' => $method, |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @param string url of the rpc server |
| 84 | 84 | * @param boolean whether the requests are considered to be notifications (completely ignoring the response) (default: false) |
| 85 | 85 | */ |
| 86 | - public static function create($type, $serverUrl, $isNotification = false) |
|
| 86 | + public static function create($type, $serverUrl, $isNotification=false) |
|
| 87 | 87 | { |
| 88 | 88 | return new self($serverUrl, $isNotification); |
| 89 | 89 | } |
@@ -24,9 +24,9 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | class TFirebugLogRoute extends TBrowserLogRoute |
| 26 | 26 | { |
| 27 | - protected function renderHeader () |
|
| 27 | + protected function renderHeader() |
|
| 28 | 28 | { |
| 29 | - $string = <<<EOD |
|
| 29 | + $string=<<<EOD |
|
| 30 | 30 | |
| 31 | 31 | <script type="text/javascript"> |
| 32 | 32 | /*<![CDATA[*/ |
@@ -39,23 +39,23 @@ discard block |
||
| 39 | 39 | return $string; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - protected function renderMessage ($log, $info) |
|
| 42 | + protected function renderMessage($log, $info) |
|
| 43 | 43 | { |
| 44 | - $logfunc = $this->getFirebugLoggingFunction($log[1]); |
|
| 45 | - $total = sprintf('%0.6f', $info['total']); |
|
| 46 | - $delta = sprintf('%0.6f', $info['delta']); |
|
| 47 | - $msg = trim($this->formatLogMessage($log[0], $log[1], $log[2], '')); |
|
| 48 | - $msg = preg_replace('/\(line[^\)]+\)$/', '', $msg); //remove line number info |
|
| 49 | - $msg = "[{$total}] [{$delta}] " . $msg; // Add time spent and cumulated time spent |
|
| 50 | - $string = $logfunc . '(\'' . addslashes($msg) . '\');' . "\n"; |
|
| 44 | + $logfunc=$this->getFirebugLoggingFunction($log[1]); |
|
| 45 | + $total=sprintf('%0.6f', $info['total']); |
|
| 46 | + $delta=sprintf('%0.6f', $info['delta']); |
|
| 47 | + $msg=trim($this->formatLogMessage($log[0], $log[1], $log[2], '')); |
|
| 48 | + $msg=preg_replace('/\(line[^\)]+\)$/', '', $msg); //remove line number info |
|
| 49 | + $msg="[{$total}] [{$delta}] ".$msg; // Add time spent and cumulated time spent |
|
| 50 | + $string=$logfunc.'(\''.addslashes($msg).'\');'."\n"; |
|
| 51 | 51 | |
| 52 | 52 | return $string; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | |
| 56 | - protected function renderFooter () |
|
| 56 | + protected function renderFooter() |
|
| 57 | 57 | { |
| 58 | - $string = <<<EOD |
|
| 58 | + $string=<<<EOD |
|
| 59 | 59 | |
| 60 | 60 | } |
| 61 | 61 | </script> |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | protected function getFirebugLoggingFunction($level) |
| 69 | 69 | { |
| 70 | - switch ($level) |
|
| 70 | + switch($level) |
|
| 71 | 71 | { |
| 72 | 72 | case TLogger::DEBUG: |
| 73 | 73 | case TLogger::INFO: |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | /** |
| 31 | 31 | * @TODO add sqlite types. |
| 32 | 32 | */ |
| 33 | - private static $types = []; |
|
| 33 | + private static $types=[]; |
|
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * Overrides parent implementation, returns PHP type from the db type. |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function getPHPType() |
| 40 | 40 | { |
| 41 | - $dbtype = strtolower($this->getDbType()); |
|
| 41 | + $dbtype=strtolower($this->getDbType()); |
|
| 42 | 42 | foreach(self::$types as $type => $dbtypes) |
| 43 | 43 | { |
| 44 | 44 | if(in_array($dbtype, $dbtypes)) |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | public function getTableFullName() |
| 43 | 43 | { |
| 44 | - return "'" . $this->getTableName() . "'"; |
|
| 44 | + return "'".$this->getTableName()."'"; |
|
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | |