@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | * the object and method name as string |
45 | 45 | * @param array The array of arguments to the function call chain |
46 | 46 | */ |
47 | - public function addCall($method,$args) |
|
47 | + public function addCall($method, $args) |
|
48 | 48 | { |
49 | - $this->add(array($method,$args)); |
|
49 | + $this->add(array($method, $args)); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | { |
93 | 93 | $args=func_get_args(); |
94 | 94 | if($this->getCount()===0) |
95 | - return isset($args[0])?$args[0]:null; |
|
95 | + return isset($args[0]) ? $args[0] : null; |
|
96 | 96 | |
97 | 97 | if(!$this->_iterator) |
98 | 98 | { |
@@ -103,15 +103,15 @@ discard block |
||
103 | 103 | do { |
104 | 104 | $handler=$this->_iterator->current(); |
105 | 105 | $this->_iterator->next(); |
106 | - if(is_array($handler[0])&&$handler[0][0] instanceof IClassBehavior) |
|
107 | - array_splice($handler[1],1,count($args),$args); |
|
106 | + if(is_array($handler[0]) && $handler[0][0] instanceof IClassBehavior) |
|
107 | + array_splice($handler[1], 1, count($args), $args); |
|
108 | 108 | else |
109 | - array_splice($handler[1],0,count($args),$args); |
|
109 | + array_splice($handler[1], 0, count($args), $args); |
|
110 | 110 | $handler[1][]=$this; |
111 | - $result=call_user_func_array($handler[0],$handler[1]); |
|
111 | + $result=call_user_func_array($handler[0], $handler[1]); |
|
112 | 112 | } while($this->_iterator->valid()); |
113 | 113 | else |
114 | - $result = $args[0]; |
|
114 | + $result=$args[0]; |
|
115 | 115 | return $result; |
116 | 116 | } |
117 | 117 | |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | * @param string method name of the unspecified object method |
138 | 138 | * @param array arguments to the unspecified object method |
139 | 139 | */ |
140 | - public function __dycall($method,$args) |
|
140 | + public function __dycall($method, $args) |
|
141 | 141 | { |
142 | 142 | if($this->_method==$method) |
143 | - return call_user_func_array(array($this,'call'),$args); |
|
143 | + return call_user_func_array(array($this, 'call'), $args); |
|
144 | 144 | return null; |
145 | 145 | } |
146 | 146 | } |
147 | 147 | \ No newline at end of file |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @return mixed value at the specified field |
49 | 49 | * @throws TInvalidDataValueException if field or data is invalid |
50 | 50 | */ |
51 | - public static function getDataFieldValue($data,$field) |
|
51 | + public static function getDataFieldValue($data, $field) |
|
52 | 52 | { |
53 | 53 | try |
54 | 54 | { |
@@ -57,33 +57,33 @@ discard block |
||
57 | 57 | if(isset($data[$field])) |
58 | 58 | return $data[$field]; |
59 | 59 | |
60 | - $tmp = $data; |
|
61 | - foreach (explode(".", $field) as $f) |
|
62 | - $tmp = $tmp[$f]; |
|
60 | + $tmp=$data; |
|
61 | + foreach(explode(".", $field) as $f) |
|
62 | + $tmp=$tmp[$f]; |
|
63 | 63 | return $tmp; |
64 | 64 | } |
65 | 65 | else if(is_object($data)) |
66 | 66 | { |
67 | - if(strpos($field,'.')===false) // simple field |
|
67 | + if(strpos($field, '.')===false) // simple field |
|
68 | 68 | { |
69 | 69 | if(method_exists($data, 'get'.$field)) |
70 | - return call_user_func(array($data,'get'.$field)); |
|
70 | + return call_user_func(array($data, 'get'.$field)); |
|
71 | 71 | else |
72 | 72 | return $data->{$field}; |
73 | 73 | } |
74 | 74 | else // field in the format of xxx.yyy.zzz |
75 | 75 | { |
76 | 76 | $object=$data; |
77 | - foreach(explode('.',$field) as $f) |
|
78 | - $object = TDataFieldAccessor::getDataFieldValue($object, $f); |
|
77 | + foreach(explode('.', $field) as $f) |
|
78 | + $object=TDataFieldAccessor::getDataFieldValue($object, $f); |
|
79 | 79 | return $object; |
80 | 80 | } |
81 | 81 | } |
82 | 82 | } |
83 | 83 | catch(Exception $e) |
84 | 84 | { |
85 | - throw new TInvalidDataValueException('datafieldaccessor_datafield_invalid',$field,$e->getMessage()); |
|
85 | + throw new TInvalidDataValueException('datafieldaccessor_datafield_invalid', $field, $e->getMessage()); |
|
86 | 86 | } |
87 | - throw new TInvalidDataValueException('datafieldaccessor_data_invalid',$field); |
|
87 | + throw new TInvalidDataValueException('datafieldaccessor_data_invalid', $field); |
|
88 | 88 | } |
89 | 89 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | { |
44 | 44 | $this->_owner=$owner; |
45 | 45 | foreach($this->events() as $event=>$handler) |
46 | - $owner->attachEventHandler($event,array($this,$handler)); |
|
46 | + $owner->attachEventHandler($event, array($this, $handler)); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | public function detach($owner) |
57 | 57 | { |
58 | 58 | foreach($this->events() as $event=>$handler) |
59 | - $owner->detachEventHandler($event,array($this,$handler)); |
|
59 | + $owner->detachEventHandler($event, array($this, $handler)); |
|
60 | 60 | $this->_owner=null; |
61 | 61 | } |
62 | 62 |
@@ -63,16 +63,16 @@ discard block |
||
63 | 63 | * @param string category of the message |
64 | 64 | * @param string|TControl control of the message |
65 | 65 | */ |
66 | - public function log($message,$level,$category='Uncategorized', $ctl=null) |
|
66 | + public function log($message, $level, $category='Uncategorized', $ctl=null) |
|
67 | 67 | { |
68 | 68 | if($ctl) { |
69 | 69 | if($ctl instanceof TControl) |
70 | - $ctl = $ctl->ClientId; |
|
70 | + $ctl=$ctl->ClientId; |
|
71 | 71 | else if(!is_string($ctl)) |
72 | - $ctl = null; |
|
72 | + $ctl=null; |
|
73 | 73 | } else |
74 | - $ctl = null; |
|
75 | - $this->_logs[]=array($message,$level,$category,microtime(true),memory_get_usage(),$ctl); |
|
74 | + $ctl=null; |
|
75 | + $this->_logs[]=array($message, $level, $category, microtime(true), memory_get_usage(), $ctl); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * [4] => memory in bytes |
109 | 109 | * [5] => control client id |
110 | 110 | */ |
111 | - public function getLogs($levels=null,$categories=null,$controls=null,$timestamp=null) |
|
111 | + public function getLogs($levels=null, $categories=null, $controls=null, $timestamp=null) |
|
112 | 112 | { |
113 | 113 | $this->_levels=$levels; |
114 | 114 | $this->_categories=$categories; |
@@ -116,15 +116,15 @@ discard block |
||
116 | 116 | $this->_timestamp=$timestamp; |
117 | 117 | if(empty($levels) && empty($categories) && empty($controls) && is_null($timestamp)) |
118 | 118 | return $this->_logs; |
119 | - $logs = $this->_logs; |
|
119 | + $logs=$this->_logs; |
|
120 | 120 | if(!empty($levels)) |
121 | - $logs = array_values(array_filter( array_filter($logs,array($this,'filterByLevels')) )); |
|
121 | + $logs=array_values(array_filter(array_filter($logs, array($this, 'filterByLevels')))); |
|
122 | 122 | if(!empty($categories)) |
123 | - $logs = array_values(array_filter( array_filter($logs,array($this,'filterByCategories')) )); |
|
123 | + $logs=array_values(array_filter(array_filter($logs, array($this, 'filterByCategories')))); |
|
124 | 124 | if(!empty($controls)) |
125 | - $logs = array_values(array_filter( array_filter($logs,array($this,'filterByControl')) )); |
|
125 | + $logs=array_values(array_filter(array_filter($logs, array($this, 'filterByControl')))); |
|
126 | 126 | if(!is_null($timestamp)) |
127 | - $logs = array_values(array_filter( array_filter($logs,array($this,'filterByTimeStamp')) )); |
|
127 | + $logs=array_values(array_filter(array_filter($logs, array($this, 'filterByTimeStamp')))); |
|
128 | 128 | return $logs; |
129 | 129 | } |
130 | 130 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @param array category filter |
153 | 153 | * @param array control filter |
154 | 154 | */ |
155 | - public function deleteLogs($levels=null,$categories=null,$controls=null,$timestamp=null) |
|
155 | + public function deleteLogs($levels=null, $categories=null, $controls=null, $timestamp=null) |
|
156 | 156 | { |
157 | 157 | $this->_levels=$levels; |
158 | 158 | $this->_categories=$categories; |
@@ -163,16 +163,16 @@ discard block |
||
163 | 163 | $this->_logs=array(); |
164 | 164 | return; |
165 | 165 | } |
166 | - $logs = $this->_logs; |
|
166 | + $logs=$this->_logs; |
|
167 | 167 | if(!empty($levels)) |
168 | - $logs = array_filter( array_filter($logs,array($this,'filterByLevels')) ); |
|
168 | + $logs=array_filter(array_filter($logs, array($this, 'filterByLevels'))); |
|
169 | 169 | if(!empty($categories)) |
170 | - $logs = array_filter( array_filter($logs,array($this,'filterByCategories')) ); |
|
170 | + $logs=array_filter(array_filter($logs, array($this, 'filterByCategories'))); |
|
171 | 171 | if(!empty($controls)) |
172 | - $logs = array_filter( array_filter($logs,array($this,'filterByControl')) ); |
|
172 | + $logs=array_filter(array_filter($logs, array($this, 'filterByControl'))); |
|
173 | 173 | if(!is_null($timestamp)) |
174 | - $logs = array_filter( array_filter($logs,array($this,'filterByTimeStamp')) ); |
|
175 | - $this->_logs = array_values( array_diff_key($this->_logs, $logs) ); |
|
174 | + $logs=array_filter(array_filter($logs, array($this, 'filterByTimeStamp'))); |
|
175 | + $this->_logs=array_values(array_diff_key($this->_logs, $logs)); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | foreach($this->_categories as $category) |
185 | 185 | { |
186 | 186 | // element 2 is the category |
187 | - if($value[2]===$category || strpos($value[2],$category.'.')===0) |
|
187 | + if($value[2]===$category || strpos($value[2], $category.'.')===0) |
|
188 | 188 | return $value; |
189 | 189 | } |
190 | 190 | return false; |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | // element 5 are the control client ids |
213 | 213 | foreach($this->_controls as $control) |
214 | 214 | { |
215 | - if($value[5]===$control || strpos($value[5],$control)===0) |
|
215 | + if($value[5]===$control || strpos($value[5], $control)===0) |
|
216 | 216 | return $value; |
217 | 217 | } |
218 | 218 | return false; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | $this->loadParameters($config); |
62 | 62 | if($this->_paramFile!==null) |
63 | 63 | { |
64 | - $configFile = null; |
|
64 | + $configFile=null; |
|
65 | 65 | if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_XML && ($cache=$this->getApplication()->getCache())!==null) |
66 | 66 | { |
67 | 67 | $cacheKey='TParameterModule:'.$this->_paramFile; |
@@ -69,14 +69,14 @@ discard block |
||
69 | 69 | { |
70 | 70 | $configFile=new TXmlDocument; |
71 | 71 | $configFile->loadFromFile($this->_paramFile); |
72 | - $cache->set($cacheKey,$configFile,0,new TFileCacheDependency($this->_paramFile)); |
|
72 | + $cache->set($cacheKey, $configFile, 0, new TFileCacheDependency($this->_paramFile)); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | else |
76 | 76 | { |
77 | 77 | if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
78 | 78 | { |
79 | - $configFile = include $this->_paramFile; |
|
79 | + $configFile=include $this->_paramFile; |
|
80 | 80 | } |
81 | 81 | else |
82 | 82 | { |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | { |
104 | 104 | if(is_array($parameter) && isset($parameter['class'])) |
105 | 105 | { |
106 | - $properties = isset($parameter['properties'])?$parameter['properties']:array(); |
|
107 | - $parameters[$id]=array($parameter['class'],$properties); |
|
106 | + $properties=isset($parameter['properties']) ? $parameter['properties'] : array(); |
|
107 | + $parameters[$id]=array($parameter['class'], $properties); |
|
108 | 108 | } |
109 | 109 | else |
110 | 110 | { |
111 | - $parameters[$id] = $parameter; |
|
111 | + $parameters[$id]=$parameter; |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $parameters[$id]=$value; |
128 | 128 | } |
129 | 129 | else |
130 | - $parameters[$id]=array($type,$properties->toArray()); |
|
130 | + $parameters[$id]=array($type, $properties->toArray()); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | { |
139 | 139 | $component=Prado::createComponent($parameter[0]); |
140 | 140 | foreach($parameter[1] as $name=>$value) |
141 | - $component->setSubProperty($name,$value); |
|
142 | - $appParams->add($id,$component); |
|
141 | + $component->setSubProperty($name, $value); |
|
142 | + $appParams->add($id, $component); |
|
143 | 143 | } |
144 | 144 | else |
145 | - $appParams->add($id,$parameter); |
|
145 | + $appParams->add($id, $parameter); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | { |
165 | 165 | if($this->_initialized) |
166 | 166 | throw new TInvalidOperationException('parametermodule_parameterfile_unchangeable'); |
167 | - else if(($this->_paramFile=Prado::getPathOfNamespace($value,$this->getApplication()->getConfigurationFileExt()))===null || !is_file($this->_paramFile)) |
|
168 | - throw new TConfigurationException('parametermodule_parameterfile_invalid',$value); |
|
167 | + else if(($this->_paramFile=Prado::getPathOfNamespace($value, $this->getApplication()->getConfigurationFileExt()))===null || !is_file($this->_paramFile)) |
|
168 | + throw new TConfigurationException('parametermodule_parameterfile_invalid', $value); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 |
@@ -40,27 +40,27 @@ discard block |
||
40 | 40 | * @param integer maximum depth that the dumper should go into the variable. Defaults to 10. |
41 | 41 | * @return string the string representation of the variable |
42 | 42 | */ |
43 | - public static function dump($var,$depth=10,$highlight=false) |
|
43 | + public static function dump($var, $depth=10, $highlight=false) |
|
44 | 44 | { |
45 | 45 | self::$_output=''; |
46 | 46 | self::$_objects=array(); |
47 | 47 | self::$_depth=$depth; |
48 | - self::dumpInternal($var,0); |
|
48 | + self::dumpInternal($var, 0); |
|
49 | 49 | if($highlight) |
50 | 50 | { |
51 | - $result=highlight_string("<?php\n".self::$_output,true); |
|
52 | - return preg_replace('/<\\?php<br \\/>/','',$result,1); |
|
51 | + $result=highlight_string("<?php\n".self::$_output, true); |
|
52 | + return preg_replace('/<\\?php<br \\/>/', '', $result, 1); |
|
53 | 53 | } |
54 | 54 | else |
55 | 55 | return self::$_output; |
56 | 56 | } |
57 | 57 | |
58 | - private static function dumpInternal($var,$level) |
|
58 | + private static function dumpInternal($var, $level) |
|
59 | 59 | { |
60 | 60 | switch(gettype($var)) |
61 | 61 | { |
62 | 62 | case 'boolean': |
63 | - self::$_output.=$var?'true':'false'; |
|
63 | + self::$_output.=$var ? 'true' : 'false'; |
|
64 | 64 | break; |
65 | 65 | case 'integer': |
66 | 66 | self::$_output.="$var"; |
@@ -81,41 +81,41 @@ discard block |
||
81 | 81 | self::$_output.='{unknown}'; |
82 | 82 | break; |
83 | 83 | case 'array': |
84 | - if(self::$_depth<=$level) |
|
84 | + if(self::$_depth <= $level) |
|
85 | 85 | self::$_output.='array(...)'; |
86 | 86 | else if(empty($var)) |
87 | 87 | self::$_output.='array()'; |
88 | 88 | else |
89 | 89 | { |
90 | 90 | $keys=array_keys($var); |
91 | - $spaces=str_repeat(' ',$level*4); |
|
91 | + $spaces=str_repeat(' ', $level * 4); |
|
92 | 92 | self::$_output.="array\n".$spaces.'('; |
93 | 93 | foreach($keys as $key) |
94 | 94 | { |
95 | 95 | self::$_output.="\n".$spaces." [$key] => "; |
96 | - self::$_output.=self::dumpInternal($var[$key],$level+1); |
|
96 | + self::$_output.=self::dumpInternal($var[$key], $level + 1); |
|
97 | 97 | } |
98 | 98 | self::$_output.="\n".$spaces.')'; |
99 | 99 | } |
100 | 100 | break; |
101 | 101 | case 'object': |
102 | - if(($id=array_search($var,self::$_objects,true))!==false) |
|
103 | - self::$_output.=get_class($var).'#'.($id+1).'(...)'; |
|
104 | - else if(self::$_depth<=$level) |
|
102 | + if(($id=array_search($var, self::$_objects, true))!==false) |
|
103 | + self::$_output.=get_class($var).'#'.($id + 1).'(...)'; |
|
104 | + else if(self::$_depth <= $level) |
|
105 | 105 | self::$_output.=get_class($var).'(...)'; |
106 | 106 | else |
107 | 107 | { |
108 | - $id=array_push(self::$_objects,$var); |
|
108 | + $id=array_push(self::$_objects, $var); |
|
109 | 109 | $className=get_class($var); |
110 | - $members=(array)$var; |
|
110 | + $members=(array) $var; |
|
111 | 111 | $keys=array_keys($members); |
112 | - $spaces=str_repeat(' ',$level*4); |
|
112 | + $spaces=str_repeat(' ', $level * 4); |
|
113 | 113 | self::$_output.="$className#$id\n".$spaces.'('; |
114 | 114 | foreach($keys as $key) |
115 | 115 | { |
116 | - $keyDisplay=strtr(trim($key),array("\0"=>':')); |
|
116 | + $keyDisplay=strtr(trim($key), array("\0"=>':')); |
|
117 | 117 | self::$_output.="\n".$spaces." [$keyDisplay] => "; |
118 | - self::$_output.=self::dumpInternal($members[$key],$level+1); |
|
118 | + self::$_output.=self::dumpInternal($members[$key], $level + 1); |
|
119 | 119 | } |
120 | 120 | self::$_output.="\n".$spaces.')'; |
121 | 121 | } |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function __construct($p_tarname) |
62 | 62 | { |
63 | - $this->_tarname = $p_tarname; |
|
63 | + $this->_tarname=$p_tarname; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | public function __destruct() |
67 | 67 | { |
68 | 68 | $this->_close(); |
69 | 69 | // ----- Look for a local copy to delete |
70 | - if ($this->_temp_tarname != '') |
|
70 | + if($this->_temp_tarname!='') |
|
71 | 71 | @unlink($this->_temp_tarname); |
72 | 72 | } |
73 | 73 | |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | */ |
111 | 111 | protected function extractModify($p_path, $p_remove_path) |
112 | 112 | { |
113 | - $v_result = true; |
|
114 | - $v_list_detail = array(); |
|
113 | + $v_result=true; |
|
114 | + $v_list_detail=array(); |
|
115 | 115 | |
116 | - if ($v_result = $this->_openRead()) { |
|
117 | - $v_result = $this->_extractList($p_path, $v_list_detail, |
|
116 | + if($v_result=$this->_openRead()) { |
|
117 | + $v_result=$this->_extractList($p_path, $v_list_detail, |
|
118 | 118 | "complete", 0, $p_remove_path); |
119 | 119 | $this->_close(); |
120 | 120 | } |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | |
130 | 130 | private function _isArchive($p_filename=null) |
131 | 131 | { |
132 | - if ($p_filename == null) { |
|
133 | - $p_filename = $this->_tarname; |
|
132 | + if($p_filename==null) { |
|
133 | + $p_filename=$this->_tarname; |
|
134 | 134 | } |
135 | 135 | clearstatcache(); |
136 | 136 | return @is_file($p_filename); |
@@ -138,39 +138,39 @@ discard block |
||
138 | 138 | |
139 | 139 | private function _openRead() |
140 | 140 | { |
141 | - if (strtolower(substr($this->_tarname, 0, 7)) == 'http://') { |
|
141 | + if(strtolower(substr($this->_tarname, 0, 7))=='http://') { |
|
142 | 142 | |
143 | 143 | // ----- Look if a local copy need to be done |
144 | - if ($this->_temp_tarname == '') { |
|
145 | - $this->_temp_tarname = uniqid('tar').'.tmp'; |
|
146 | - if (!$v_file_from = @fopen($this->_tarname, 'rb')) { |
|
144 | + if($this->_temp_tarname=='') { |
|
145 | + $this->_temp_tarname=uniqid('tar').'.tmp'; |
|
146 | + if(!$v_file_from=@fopen($this->_tarname, 'rb')) { |
|
147 | 147 | $this->_error('Unable to open in read mode \'' |
148 | 148 | .$this->_tarname.'\''); |
149 | - $this->_temp_tarname = ''; |
|
149 | + $this->_temp_tarname=''; |
|
150 | 150 | return false; |
151 | 151 | } |
152 | - if (!$v_file_to = @fopen($this->_temp_tarname, 'wb')) { |
|
152 | + if(!$v_file_to=@fopen($this->_temp_tarname, 'wb')) { |
|
153 | 153 | $this->_error('Unable to open in write mode \'' |
154 | 154 | .$this->_temp_tarname.'\''); |
155 | - $this->_temp_tarname = ''; |
|
155 | + $this->_temp_tarname=''; |
|
156 | 156 | return false; |
157 | 157 | } |
158 | - while ($v_data = @fread($v_file_from, 1024)) |
|
158 | + while($v_data=@fread($v_file_from, 1024)) |
|
159 | 159 | @fwrite($v_file_to, $v_data); |
160 | 160 | @fclose($v_file_from); |
161 | 161 | @fclose($v_file_to); |
162 | 162 | } |
163 | 163 | |
164 | 164 | // ----- File to open if the local copy |
165 | - $v_filename = $this->_temp_tarname; |
|
165 | + $v_filename=$this->_temp_tarname; |
|
166 | 166 | |
167 | 167 | } else |
168 | 168 | // ----- File to open if the normal Tar file |
169 | - $v_filename = $this->_tarname; |
|
169 | + $v_filename=$this->_tarname; |
|
170 | 170 | |
171 | - $this->_file = @fopen($v_filename, "rb"); |
|
171 | + $this->_file=@fopen($v_filename, "rb"); |
|
172 | 172 | |
173 | - if ($this->_file == 0) { |
|
173 | + if($this->_file==0) { |
|
174 | 174 | $this->_error('Unable to open in read mode \''.$v_filename.'\''); |
175 | 175 | return false; |
176 | 176 | } |
@@ -181,17 +181,17 @@ discard block |
||
181 | 181 | private function _close() |
182 | 182 | { |
183 | 183 | //if (isset($this->_file)) { |
184 | - if (is_resource($this->_file)) |
|
184 | + if(is_resource($this->_file)) |
|
185 | 185 | { |
186 | 186 | @fclose($this->_file); |
187 | - $this->_file = 0; |
|
187 | + $this->_file=0; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | // ----- Look if a local copy need to be erase |
191 | 191 | // Note that it might be interesting to keep the url for a time : ToDo |
192 | - if ($this->_temp_tarname != '') { |
|
192 | + if($this->_temp_tarname!='') { |
|
193 | 193 | @unlink($this->_temp_tarname); |
194 | - $this->_temp_tarname = ''; |
|
194 | + $this->_temp_tarname=''; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | return true; |
@@ -202,76 +202,76 @@ discard block |
||
202 | 202 | $this->_close(); |
203 | 203 | |
204 | 204 | // ----- Look for a local copy |
205 | - if ($this->_temp_tarname != '') { |
|
205 | + if($this->_temp_tarname!='') { |
|
206 | 206 | // ----- Remove the local copy but not the remote tarname |
207 | 207 | @unlink($this->_temp_tarname); |
208 | - $this->_temp_tarname = ''; |
|
208 | + $this->_temp_tarname=''; |
|
209 | 209 | } else { |
210 | 210 | // ----- Remove the local tarname file |
211 | 211 | @unlink($this->_tarname); |
212 | 212 | } |
213 | - $this->_tarname = ''; |
|
213 | + $this->_tarname=''; |
|
214 | 214 | |
215 | 215 | return true; |
216 | 216 | } |
217 | 217 | |
218 | 218 | private function _readBlock() |
219 | 219 | { |
220 | - $v_block = null; |
|
221 | - if (is_resource($this->_file)) { |
|
222 | - $v_block = @fread($this->_file, 512); |
|
220 | + $v_block=null; |
|
221 | + if(is_resource($this->_file)) { |
|
222 | + $v_block=@fread($this->_file, 512); |
|
223 | 223 | } |
224 | 224 | return $v_block; |
225 | 225 | } |
226 | 226 | |
227 | 227 | private function _jumpBlock($p_len=null) |
228 | 228 | { |
229 | - if (is_resource($this->_file)) { |
|
230 | - if ($p_len === null) |
|
231 | - $p_len = 1; |
|
229 | + if(is_resource($this->_file)) { |
|
230 | + if($p_len===null) |
|
231 | + $p_len=1; |
|
232 | 232 | |
233 | - @fseek($this->_file, @ftell($this->_file)+($p_len*512)); |
|
233 | + @fseek($this->_file, @ftell($this->_file) + ($p_len * 512)); |
|
234 | 234 | } |
235 | 235 | return true; |
236 | 236 | } |
237 | 237 | |
238 | 238 | private function _readHeader($v_binary_data, &$v_header) |
239 | 239 | { |
240 | - if (strlen($v_binary_data)==0) { |
|
241 | - $v_header['filename'] = ''; |
|
240 | + if(strlen($v_binary_data)==0) { |
|
241 | + $v_header['filename']=''; |
|
242 | 242 | return true; |
243 | 243 | } |
244 | 244 | |
245 | - if (strlen($v_binary_data) != 512) { |
|
246 | - $v_header['filename'] = ''; |
|
245 | + if(strlen($v_binary_data)!=512) { |
|
246 | + $v_header['filename']=''; |
|
247 | 247 | $this->_error('Invalid block size : '.strlen($v_binary_data)); |
248 | 248 | return false; |
249 | 249 | } |
250 | 250 | |
251 | 251 | // ----- Calculate the checksum |
252 | - $v_checksum = 0; |
|
252 | + $v_checksum=0; |
|
253 | 253 | // ..... First part of the header |
254 | - for ($i=0; $i<148; $i++) |
|
255 | - $v_checksum+=ord(substr($v_binary_data,$i,1)); |
|
254 | + for($i=0; $i < 148; $i++) |
|
255 | + $v_checksum+=ord(substr($v_binary_data, $i, 1)); |
|
256 | 256 | // ..... Ignore the checksum value and replace it by ' ' (space) |
257 | - for ($i=148; $i<156; $i++) |
|
258 | - $v_checksum += ord(' '); |
|
257 | + for($i=148; $i < 156; $i++) |
|
258 | + $v_checksum+=ord(' '); |
|
259 | 259 | // ..... Last part of the header |
260 | - for ($i=156; $i<512; $i++) |
|
261 | - $v_checksum+=ord(substr($v_binary_data,$i,1)); |
|
260 | + for($i=156; $i < 512; $i++) |
|
261 | + $v_checksum+=ord(substr($v_binary_data, $i, 1)); |
|
262 | 262 | |
263 | - $v_data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/" |
|
263 | + $v_data=unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/" |
|
264 | 264 | ."a8checksum/a1typeflag/a100link/a6magic/a2version/" |
265 | 265 | ."a32uname/a32gname/a8devmajor/a8devminor", |
266 | 266 | $v_binary_data); |
267 | 267 | |
268 | 268 | // ----- Extract the checksum |
269 | - $v_header['checksum'] = OctDec(trim($v_data['checksum'])); |
|
270 | - if ($v_header['checksum'] != $v_checksum) { |
|
271 | - $v_header['filename'] = ''; |
|
269 | + $v_header['checksum']=OctDec(trim($v_data['checksum'])); |
|
270 | + if($v_header['checksum']!=$v_checksum) { |
|
271 | + $v_header['filename']=''; |
|
272 | 272 | |
273 | 273 | // ----- Look for last block (empty block) |
274 | - if (($v_checksum == 256) && ($v_header['checksum'] == 0)) |
|
274 | + if(($v_checksum==256) && ($v_header['checksum']==0)) |
|
275 | 275 | return true; |
276 | 276 | |
277 | 277 | $this->_error('Invalid checksum for file "'.$v_data['filename'] |
@@ -281,38 +281,38 @@ discard block |
||
281 | 281 | } |
282 | 282 | |
283 | 283 | // ----- Extract the properties |
284 | - $v_header['filename'] = trim($v_data['filename']); |
|
285 | - $v_header['mode'] = OctDec(trim($v_data['mode'])); |
|
286 | - $v_header['uid'] = OctDec(trim($v_data['uid'])); |
|
287 | - $v_header['gid'] = OctDec(trim($v_data['gid'])); |
|
288 | - $v_header['size'] = OctDec(trim($v_data['size'])); |
|
289 | - $v_header['mtime'] = OctDec(trim($v_data['mtime'])); |
|
290 | - if (($v_header['typeflag'] = $v_data['typeflag']) == "5") { |
|
291 | - $v_header['size'] = 0; |
|
284 | + $v_header['filename']=trim($v_data['filename']); |
|
285 | + $v_header['mode']=OctDec(trim($v_data['mode'])); |
|
286 | + $v_header['uid']=OctDec(trim($v_data['uid'])); |
|
287 | + $v_header['gid']=OctDec(trim($v_data['gid'])); |
|
288 | + $v_header['size']=OctDec(trim($v_data['size'])); |
|
289 | + $v_header['mtime']=OctDec(trim($v_data['mtime'])); |
|
290 | + if(($v_header['typeflag']=$v_data['typeflag'])=="5") { |
|
291 | + $v_header['size']=0; |
|
292 | 292 | } |
293 | 293 | return true; |
294 | 294 | } |
295 | 295 | |
296 | 296 | private function _readLongHeader(&$v_header) |
297 | 297 | { |
298 | - $v_filename = ''; |
|
299 | - $n = floor($v_header['size']/512); |
|
300 | - for ($i=0; $i<$n; $i++) { |
|
301 | - $v_content = $this->_readBlock(); |
|
302 | - $v_filename .= $v_content; |
|
298 | + $v_filename=''; |
|
299 | + $n=floor($v_header['size'] / 512); |
|
300 | + for($i=0; $i < $n; $i++) { |
|
301 | + $v_content=$this->_readBlock(); |
|
302 | + $v_filename.=$v_content; |
|
303 | 303 | } |
304 | - if (($v_header['size'] % 512) != 0) { |
|
305 | - $v_content = $this->_readBlock(); |
|
306 | - $v_filename .= $v_content; |
|
304 | + if(($v_header['size'] % 512)!=0) { |
|
305 | + $v_content=$this->_readBlock(); |
|
306 | + $v_filename.=$v_content; |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | // ----- Read the next header |
310 | - $v_binary_data = $this->_readBlock(); |
|
310 | + $v_binary_data=$this->_readBlock(); |
|
311 | 311 | |
312 | - if (!$this->_readHeader($v_binary_data, $v_header)) |
|
312 | + if(!$this->_readHeader($v_binary_data, $v_header)) |
|
313 | 313 | return false; |
314 | 314 | |
315 | - $v_header['filename'] = $v_filename; |
|
315 | + $v_header['filename']=$v_filename; |
|
316 | 316 | |
317 | 317 | return true; |
318 | 318 | } |
@@ -321,34 +321,34 @@ discard block |
||
321 | 321 | $p_file_list, $p_remove_path) |
322 | 322 | { |
323 | 323 | $v_result=true; |
324 | - $v_nb = 0; |
|
325 | - $v_extract_all = true; |
|
326 | - $v_listing = false; |
|
327 | - |
|
328 | - $p_path = $this->_translateWinPath($p_path, false); |
|
329 | - if ($p_path == '' || (substr($p_path, 0, 1) != '/' |
|
330 | - && substr($p_path, 0, 3) != "../" && !strpos($p_path, ':'))) { |
|
331 | - $p_path = "./".$p_path; |
|
324 | + $v_nb=0; |
|
325 | + $v_extract_all=true; |
|
326 | + $v_listing=false; |
|
327 | + |
|
328 | + $p_path=$this->_translateWinPath($p_path, false); |
|
329 | + if($p_path=='' || (substr($p_path, 0, 1)!='/' |
|
330 | + && substr($p_path, 0, 3)!="../" && !strpos($p_path, ':'))) { |
|
331 | + $p_path="./".$p_path; |
|
332 | 332 | } |
333 | - $p_remove_path = $this->_translateWinPath($p_remove_path); |
|
333 | + $p_remove_path=$this->_translateWinPath($p_remove_path); |
|
334 | 334 | |
335 | 335 | // ----- Look for path to remove format (should end by /) |
336 | - if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/')) |
|
337 | - $p_remove_path .= '/'; |
|
338 | - $p_remove_path_size = strlen($p_remove_path); |
|
336 | + if(($p_remove_path!='') && (substr($p_remove_path, -1)!='/')) |
|
337 | + $p_remove_path.='/'; |
|
338 | + $p_remove_path_size=strlen($p_remove_path); |
|
339 | 339 | |
340 | - switch ($p_mode) { |
|
340 | + switch($p_mode) { |
|
341 | 341 | case "complete" : |
342 | - $v_extract_all = true; |
|
343 | - $v_listing = false; |
|
342 | + $v_extract_all=true; |
|
343 | + $v_listing=false; |
|
344 | 344 | break; |
345 | 345 | case "partial" : |
346 | - $v_extract_all = false; |
|
347 | - $v_listing = false; |
|
346 | + $v_extract_all=false; |
|
347 | + $v_listing=false; |
|
348 | 348 | break; |
349 | 349 | case "list" : |
350 | - $v_extract_all = false; |
|
351 | - $v_listing = true; |
|
350 | + $v_extract_all=false; |
|
351 | + $v_listing=true; |
|
352 | 352 | break; |
353 | 353 | default : |
354 | 354 | $this->_error('Invalid extract mode ('.$p_mode.')'); |
@@ -357,103 +357,103 @@ discard block |
||
357 | 357 | |
358 | 358 | clearstatcache(); |
359 | 359 | |
360 | - while (strlen($v_binary_data = $this->_readBlock()) != 0) |
|
360 | + while(strlen($v_binary_data=$this->_readBlock())!=0) |
|
361 | 361 | { |
362 | - $v_extract_file = false; |
|
363 | - $v_extraction_stopped = 0; |
|
362 | + $v_extract_file=false; |
|
363 | + $v_extraction_stopped=0; |
|
364 | 364 | |
365 | - if (!$this->_readHeader($v_binary_data, $v_header)) |
|
365 | + if(!$this->_readHeader($v_binary_data, $v_header)) |
|
366 | 366 | return false; |
367 | 367 | |
368 | - if ($v_header['filename'] == '') { |
|
368 | + if($v_header['filename']=='') { |
|
369 | 369 | continue; |
370 | 370 | } |
371 | 371 | |
372 | 372 | // ----- Look for long filename |
373 | - if ($v_header['typeflag'] == 'L') { |
|
374 | - if (!$this->_readLongHeader($v_header)) |
|
373 | + if($v_header['typeflag']=='L') { |
|
374 | + if(!$this->_readLongHeader($v_header)) |
|
375 | 375 | return false; |
376 | 376 | } |
377 | 377 | |
378 | - if ((!$v_extract_all) && (is_array($p_file_list))) { |
|
378 | + if((!$v_extract_all) && (is_array($p_file_list))) { |
|
379 | 379 | // ----- By default no unzip if the file is not found |
380 | - $v_extract_file = false; |
|
380 | + $v_extract_file=false; |
|
381 | 381 | |
382 | - for ($i=0; $i<sizeof($p_file_list); $i++) { |
|
382 | + for($i=0; $i < sizeof($p_file_list); $i++) { |
|
383 | 383 | // ----- Look if it is a directory |
384 | - if (substr($p_file_list[$i], -1) == '/') { |
|
384 | + if(substr($p_file_list[$i], -1)=='/') { |
|
385 | 385 | // ----- Look if the directory is in the filename path |
386 | - if ((strlen($v_header['filename']) > strlen($p_file_list[$i])) |
|
386 | + if((strlen($v_header['filename']) > strlen($p_file_list[$i])) |
|
387 | 387 | && (substr($v_header['filename'], 0, strlen($p_file_list[$i])) |
388 | 388 | == $p_file_list[$i])) { |
389 | - $v_extract_file = true; |
|
389 | + $v_extract_file=true; |
|
390 | 390 | break; |
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
394 | 394 | // ----- It is a file, so compare the file names |
395 | - elseif ($p_file_list[$i] == $v_header['filename']) { |
|
396 | - $v_extract_file = true; |
|
395 | + elseif($p_file_list[$i]==$v_header['filename']) { |
|
396 | + $v_extract_file=true; |
|
397 | 397 | break; |
398 | 398 | } |
399 | 399 | } |
400 | 400 | } else { |
401 | - $v_extract_file = true; |
|
401 | + $v_extract_file=true; |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | // ----- Look if this file need to be extracted |
405 | - if (($v_extract_file) && (!$v_listing)) |
|
405 | + if(($v_extract_file) && (!$v_listing)) |
|
406 | 406 | { |
407 | - if (($p_remove_path != '') |
|
407 | + if(($p_remove_path!='') |
|
408 | 408 | && (substr($v_header['filename'], 0, $p_remove_path_size) |
409 | 409 | == $p_remove_path)) |
410 | - $v_header['filename'] = substr($v_header['filename'], |
|
410 | + $v_header['filename']=substr($v_header['filename'], |
|
411 | 411 | $p_remove_path_size); |
412 | - if (($p_path != './') && ($p_path != '/')) { |
|
413 | - while (substr($p_path, -1) == '/') |
|
414 | - $p_path = substr($p_path, 0, strlen($p_path)-1); |
|
412 | + if(($p_path!='./') && ($p_path!='/')) { |
|
413 | + while(substr($p_path, -1)=='/') |
|
414 | + $p_path=substr($p_path, 0, strlen($p_path) - 1); |
|
415 | 415 | |
416 | - if (substr($v_header['filename'], 0, 1) == '/') |
|
417 | - $v_header['filename'] = $p_path.$v_header['filename']; |
|
416 | + if(substr($v_header['filename'], 0, 1)=='/') |
|
417 | + $v_header['filename']=$p_path.$v_header['filename']; |
|
418 | 418 | else |
419 | - $v_header['filename'] = $p_path.'/'.$v_header['filename']; |
|
419 | + $v_header['filename']=$p_path.'/'.$v_header['filename']; |
|
420 | 420 | } |
421 | - if (file_exists($v_header['filename'])) { |
|
422 | - if ( (@is_dir($v_header['filename'])) |
|
423 | - && ($v_header['typeflag'] == '')) { |
|
421 | + if(file_exists($v_header['filename'])) { |
|
422 | + if((@is_dir($v_header['filename'])) |
|
423 | + && ($v_header['typeflag']=='')) { |
|
424 | 424 | $this->_error('File '.$v_header['filename'] |
425 | 425 | .' already exists as a directory'); |
426 | 426 | return false; |
427 | 427 | } |
428 | - if ( ($this->_isArchive($v_header['filename'])) |
|
429 | - && ($v_header['typeflag'] == "5")) { |
|
428 | + if(($this->_isArchive($v_header['filename'])) |
|
429 | + && ($v_header['typeflag']=="5")) { |
|
430 | 430 | $this->_error('Directory '.$v_header['filename'] |
431 | 431 | .' already exists as a file'); |
432 | 432 | return false; |
433 | 433 | } |
434 | - if (!is_writeable($v_header['filename'])) { |
|
434 | + if(!is_writeable($v_header['filename'])) { |
|
435 | 435 | $this->_error('File '.$v_header['filename'] |
436 | 436 | .' already exists and is write protected'); |
437 | 437 | return false; |
438 | 438 | } |
439 | - if (filemtime($v_header['filename']) > $v_header['mtime']) { |
|
439 | + if(filemtime($v_header['filename']) > $v_header['mtime']) { |
|
440 | 440 | // To be completed : An error or silent no replace ? |
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
444 | 444 | // ----- Check the directory availability and create it if necessary |
445 | - elseif (($v_result |
|
446 | - = $this->_dirCheck(($v_header['typeflag'] == "5" |
|
447 | - ?$v_header['filename'] |
|
448 | - :dirname($v_header['filename'])))) != 1) { |
|
445 | + elseif(($v_result |
|
446 | + = $this->_dirCheck(($v_header['typeflag']=="5" |
|
447 | + ? $v_header['filename'] |
|
448 | + :dirname($v_header['filename']))))!=1) { |
|
449 | 449 | $this->_error('Unable to create path for '.$v_header['filename']); |
450 | 450 | return false; |
451 | 451 | } |
452 | 452 | |
453 | - if ($v_extract_file) { |
|
454 | - if ($v_header['typeflag'] == "5") { |
|
455 | - if (!@file_exists($v_header['filename'])) { |
|
456 | - if (!@mkdir($v_header['filename'], PRADO_CHMOD)) { |
|
453 | + if($v_extract_file) { |
|
454 | + if($v_header['typeflag']=="5") { |
|
455 | + if(!@file_exists($v_header['filename'])) { |
|
456 | + if(!@mkdir($v_header['filename'], PRADO_CHMOD)) { |
|
457 | 457 | $this->_error('Unable to create directory {' |
458 | 458 | .$v_header['filename'].'}'); |
459 | 459 | return false; |
@@ -461,18 +461,18 @@ discard block |
||
461 | 461 | chmod($v_header['filename'], PRADO_CHMOD); |
462 | 462 | } |
463 | 463 | } else { |
464 | - if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) { |
|
464 | + if(($v_dest_file=@fopen($v_header['filename'], "wb"))==0) { |
|
465 | 465 | $this->_error('Error while opening {'.$v_header['filename'] |
466 | 466 | .'} in write binary mode'); |
467 | 467 | return false; |
468 | 468 | } else { |
469 | - $n = floor($v_header['size']/512); |
|
470 | - for ($i=0; $i<$n; $i++) { |
|
471 | - $v_content = $this->_readBlock(); |
|
469 | + $n=floor($v_header['size'] / 512); |
|
470 | + for($i=0; $i < $n; $i++) { |
|
471 | + $v_content=$this->_readBlock(); |
|
472 | 472 | fwrite($v_dest_file, $v_content, 512); |
473 | 473 | } |
474 | - if (($v_header['size'] % 512) != 0) { |
|
475 | - $v_content = $this->_readBlock(); |
|
474 | + if(($v_header['size'] % 512)!=0) { |
|
475 | + $v_content=$this->_readBlock(); |
|
476 | 476 | fwrite($v_dest_file, $v_content, ($v_header['size'] % 512)); |
477 | 477 | } |
478 | 478 | |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | |
487 | 487 | // ----- Check the file size |
488 | 488 | clearstatcache(); |
489 | - if (filesize($v_header['filename']) != $v_header['size']) { |
|
489 | + if(filesize($v_header['filename'])!=$v_header['size']) { |
|
490 | 490 | $this->_error('Extracted file '.$v_header['filename'] |
491 | 491 | .' does not have the correct file size \'' |
492 | 492 | .filesize($v_header['filename']) |
@@ -496,10 +496,10 @@ discard block |
||
496 | 496 | } |
497 | 497 | } |
498 | 498 | } else { |
499 | - $this->_jumpBlock(ceil(($v_header['size']/512))); |
|
499 | + $this->_jumpBlock(ceil(($v_header['size'] / 512))); |
|
500 | 500 | } |
501 | 501 | } else { |
502 | - $this->_jumpBlock(ceil(($v_header['size']/512))); |
|
502 | + $this->_jumpBlock(ceil(($v_header['size'] / 512))); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | /* TBC : Seems to be unused ... |
@@ -509,15 +509,15 @@ discard block |
||
509 | 509 | $v_end_of_file = @feof($this->_file); |
510 | 510 | */ |
511 | 511 | |
512 | - if ($v_listing || $v_extract_file || $v_extraction_stopped) { |
|
512 | + if($v_listing || $v_extract_file || $v_extraction_stopped) { |
|
513 | 513 | // ----- Log extracted files |
514 | - if (($v_file_dir = dirname($v_header['filename'])) |
|
514 | + if(($v_file_dir=dirname($v_header['filename'])) |
|
515 | 515 | == $v_header['filename']) |
516 | - $v_file_dir = ''; |
|
517 | - if ((substr($v_header['filename'], 0, 1) == '/') && ($v_file_dir == '')) |
|
518 | - $v_file_dir = '/'; |
|
516 | + $v_file_dir=''; |
|
517 | + if((substr($v_header['filename'], 0, 1)=='/') && ($v_file_dir=='')) |
|
518 | + $v_file_dir='/'; |
|
519 | 519 | |
520 | - $p_list_detail[$v_nb++] = $v_header; |
|
520 | + $p_list_detail[$v_nb++]=$v_header; |
|
521 | 521 | } |
522 | 522 | } |
523 | 523 | |
@@ -534,36 +534,36 @@ discard block |
||
534 | 534 | */ |
535 | 535 | protected function _dirCheck($p_dir) |
536 | 536 | { |
537 | - if ((@is_dir($p_dir)) || ($p_dir == '')) |
|
537 | + if((@is_dir($p_dir)) || ($p_dir=='')) |
|
538 | 538 | return true; |
539 | 539 | |
540 | - $p_parent_dir = dirname($p_dir); |
|
540 | + $p_parent_dir=dirname($p_dir); |
|
541 | 541 | |
542 | - if (($p_parent_dir != $p_dir) && |
|
543 | - ($p_parent_dir != '') && |
|
542 | + if(($p_parent_dir!=$p_dir) && |
|
543 | + ($p_parent_dir!='') && |
|
544 | 544 | (!$this->_dirCheck($p_parent_dir))) |
545 | 545 | return false; |
546 | 546 | |
547 | - if (!@mkdir($p_dir, PRADO_CHMOD)) { |
|
547 | + if(!@mkdir($p_dir, PRADO_CHMOD)) { |
|
548 | 548 | $this->_error("Unable to create directory '$p_dir'"); |
549 | 549 | return false; |
550 | 550 | } |
551 | - chmod($p_dir,PRADO_CHMOD); |
|
551 | + chmod($p_dir, PRADO_CHMOD); |
|
552 | 552 | |
553 | 553 | return true; |
554 | 554 | } |
555 | 555 | |
556 | 556 | protected function _translateWinPath($p_path, $p_remove_disk_letter=true) |
557 | 557 | { |
558 | - if (substr(PHP_OS, 0, 3) == 'WIN') { |
|
558 | + if(substr(PHP_OS, 0, 3)=='WIN') { |
|
559 | 559 | // ----- Look for potential disk letter |
560 | - if ( ($p_remove_disk_letter) |
|
561 | - && (($v_position = strpos($p_path, ':')) != false)) { |
|
562 | - $p_path = substr($p_path, $v_position+1); |
|
560 | + if(($p_remove_disk_letter) |
|
561 | + && (($v_position=strpos($p_path, ':'))!=false)) { |
|
562 | + $p_path=substr($p_path, $v_position + 1); |
|
563 | 563 | } |
564 | 564 | // ----- Change potential windows directory separator |
565 | - if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { |
|
566 | - $p_path = strtr($p_path, '\\', '/'); |
|
565 | + if((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1)=='\\')) { |
|
566 | + $p_path=strtr($p_path, '\\', '/'); |
|
567 | 567 | } |
568 | 568 | } |
569 | 569 | return $p_path; |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | * @return string SQL search condition matching on a set of columns. |
31 | 31 | */ |
32 | 32 | public function getSearchExpression($fields, $keywords) { |
33 | - $columns = array (); |
|
34 | - foreach ($fields as $field) { |
|
35 | - if ($this->isSearchableColumn($this->getTableInfo()->getColumn($field))) |
|
36 | - $columns[] = $field; |
|
33 | + $columns=array(); |
|
34 | + foreach($fields as $field) { |
|
35 | + if($this->isSearchableColumn($this->getTableInfo()->getColumn($field))) |
|
36 | + $columns[]=$field; |
|
37 | 37 | } |
38 | 38 | return parent :: getSearchExpression($columns, $keywords); |
39 | 39 | } |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | * @return boolean true if column can be used for LIKE searching. |
43 | 43 | */ |
44 | 44 | protected function isSearchableColumn($column) { |
45 | - $type = strtolower($column->getDbType()); |
|
46 | - return $type === 'character varying' || $type === 'varchar2' || $type === 'character' || $type === 'char' || $type === 'text'; |
|
45 | + $type=strtolower($column->getDbType()); |
|
46 | + return $type==='character varying' || $type==='varchar2' || $type==='character' || $type==='char' || $type==='text'; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -72,59 +72,59 @@ discard block |
||
72 | 72 | * @param integer row offset, -1 to ignore offset. |
73 | 73 | * @return string SQL with limit and offset in Oracle way. |
74 | 74 | */ |
75 | - public function applyLimitOffset($sql, $limit = -1, $offset = -1) { |
|
76 | - if ((int) $limit <= 0 && (int) $offset <= 0) |
|
75 | + public function applyLimitOffset($sql, $limit=-1, $offset=-1) { |
|
76 | + if((int) $limit <= 0 && (int) $offset <= 0) |
|
77 | 77 | return $sql; |
78 | 78 | |
79 | - $pradoNUMLIN = 'pradoNUMLIN'; |
|
80 | - $fieldsALIAS = 'xyz'; |
|
79 | + $pradoNUMLIN='pradoNUMLIN'; |
|
80 | + $fieldsALIAS='xyz'; |
|
81 | 81 | |
82 | - $nfimDaSQL = strlen($sql); |
|
83 | - $nfimDoWhere = (strpos($sql, 'ORDER') !== false ? strpos($sql, 'ORDER') : $nfimDaSQL); |
|
84 | - $niniDoSelect = strpos($sql, 'SELECT') + 6; |
|
85 | - $nfimDoSelect = (strpos($sql, 'FROM') !== false ? strpos($sql, 'FROM') : $nfimDaSQL); |
|
82 | + $nfimDaSQL=strlen($sql); |
|
83 | + $nfimDoWhere=(strpos($sql, 'ORDER')!==false ? strpos($sql, 'ORDER') : $nfimDaSQL); |
|
84 | + $niniDoSelect=strpos($sql, 'SELECT') + 6; |
|
85 | + $nfimDoSelect=(strpos($sql, 'FROM')!==false ? strpos($sql, 'FROM') : $nfimDaSQL); |
|
86 | 86 | |
87 | 87 | $WhereInSubSelect=""; |
88 | 88 | if(strpos($sql, 'WHERE')!==false) |
89 | - $WhereInSubSelect = "WHERE " .substr($sql, strpos($sql, 'WHERE')+5, $nfimDoWhere - $niniDoWhere); |
|
89 | + $WhereInSubSelect="WHERE ".substr($sql, strpos($sql, 'WHERE') + 5, $nfimDoWhere - $niniDoWhere); |
|
90 | 90 | |
91 | - $sORDERBY = ''; |
|
92 | - if (stripos($sql, 'ORDER') !== false) { |
|
93 | - $p = stripos($sql, 'ORDER'); |
|
94 | - $sORDERBY = substr($sql, $p +8); |
|
91 | + $sORDERBY=''; |
|
92 | + if(stripos($sql, 'ORDER')!==false) { |
|
93 | + $p=stripos($sql, 'ORDER'); |
|
94 | + $sORDERBY=substr($sql, $p + 8); |
|
95 | 95 | } |
96 | 96 | |
97 | - $fields = substr($sql, 0, $nfimDoSelect); |
|
98 | - $fields = trim(substr($fields, $niniDoSelect)); |
|
99 | - $aliasedFields = ', '; |
|
97 | + $fields=substr($sql, 0, $nfimDoSelect); |
|
98 | + $fields=trim(substr($fields, $niniDoSelect)); |
|
99 | + $aliasedFields=', '; |
|
100 | 100 | |
101 | - if (trim($fields) == '*') { |
|
102 | - $aliasedFields = ", {$fieldsALIAS}.{$fields}"; |
|
103 | - $fields = ''; |
|
104 | - $arr = $this->getTableInfo()->getColumns(); |
|
105 | - foreach ($arr as $field) { |
|
106 | - $fields .= strtolower($field->getColumnName()) . ', '; |
|
101 | + if(trim($fields)=='*') { |
|
102 | + $aliasedFields=", {$fieldsALIAS}.{$fields}"; |
|
103 | + $fields=''; |
|
104 | + $arr=$this->getTableInfo()->getColumns(); |
|
105 | + foreach($arr as $field) { |
|
106 | + $fields.=strtolower($field->getColumnName()).', '; |
|
107 | 107 | } |
108 | - $fields = str_replace('"', '', $fields); |
|
109 | - $fields = trim($fields); |
|
110 | - $fields = substr($fields, 0, strlen($fields) - 1); |
|
108 | + $fields=str_replace('"', '', $fields); |
|
109 | + $fields=trim($fields); |
|
110 | + $fields=substr($fields, 0, strlen($fields) - 1); |
|
111 | 111 | } else { |
112 | - if (strpos($fields, ',') !== false) { |
|
113 | - $arr = $this->getTableInfo()->getColumns(); |
|
114 | - foreach ($arr as $field) { |
|
115 | - $field = strtolower($field); |
|
116 | - $existAS = str_ireplace(' as ', '-as-', $field); |
|
117 | - if (strpos($existAS, '-as-') === false) |
|
118 | - $aliasedFields .= "{$fieldsALIAS}." . trim($field) . ", "; |
|
112 | + if(strpos($fields, ',')!==false) { |
|
113 | + $arr=$this->getTableInfo()->getColumns(); |
|
114 | + foreach($arr as $field) { |
|
115 | + $field=strtolower($field); |
|
116 | + $existAS=str_ireplace(' as ', '-as-', $field); |
|
117 | + if(strpos($existAS, '-as-')===false) |
|
118 | + $aliasedFields.="{$fieldsALIAS}.".trim($field).", "; |
|
119 | 119 | else |
120 | - $aliasedFields .= "{$field}, "; |
|
120 | + $aliasedFields.="{$field}, "; |
|
121 | 121 | } |
122 | - $aliasedFields = trim($aliasedFields); |
|
123 | - $aliasedFields = substr($aliasedFields, 0, strlen($aliasedFields) - 1); |
|
122 | + $aliasedFields=trim($aliasedFields); |
|
123 | + $aliasedFields=substr($aliasedFields, 0, strlen($aliasedFields) - 1); |
|
124 | 124 | } |
125 | 125 | } |
126 | - if ($aliasedFields == ', ') |
|
127 | - $aliasedFields = " , $fieldsALIAS.* "; |
|
126 | + if($aliasedFields==', ') |
|
127 | + $aliasedFields=" , $fieldsALIAS.* "; |
|
128 | 128 | |
129 | 129 | /* ************************ |
130 | 130 | $newSql = " SELECT $fields FROM ". |
@@ -134,17 +134,17 @@ discard block |
||
134 | 134 | ") WHERE {$pradoNUMLIN} >= {$offset} "; |
135 | 135 | |
136 | 136 | ************************* */ |
137 | - $offset=(int)$offset; |
|
138 | - $toReg = $offset + $limit ; |
|
139 | - $fullTableName = $this->getTableInfo()->getTableFullName(); |
|
140 | - if (empty ($sORDERBY)) |
|
137 | + $offset=(int) $offset; |
|
138 | + $toReg=$offset + $limit; |
|
139 | + $fullTableName=$this->getTableInfo()->getTableFullName(); |
|
140 | + if(empty ($sORDERBY)) |
|
141 | 141 | $sORDERBY="ROWNUM"; |
142 | 142 | |
143 | - $newSql = " SELECT $fields FROM " . |
|
144 | - "( " . |
|
145 | - " SELECT ROW_NUMBER() OVER ( ORDER BY {$sORDERBY} ) -1 as {$pradoNUMLIN} {$aliasedFields} " . |
|
146 | - " FROM {$fullTableName} {$fieldsALIAS} $WhereInSubSelect" . |
|
147 | - ") nn " . |
|
143 | + $newSql=" SELECT $fields FROM ". |
|
144 | + "( ". |
|
145 | + " SELECT ROW_NUMBER() OVER ( ORDER BY {$sORDERBY} ) -1 as {$pradoNUMLIN} {$aliasedFields} ". |
|
146 | + " FROM {$fullTableName} {$fieldsALIAS} $WhereInSubSelect". |
|
147 | + ") nn ". |
|
148 | 148 | " WHERE nn.{$pradoNUMLIN} >= {$offset} AND nn.{$pradoNUMLIN} < {$toReg} "; |
149 | 149 | //echo $newSql."\n<br>\n"; |
150 | 150 | return $newSql; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | class TOracleTableColumn extends TDbTableColumn |
25 | 25 | { |
26 | 26 | private static $types=array( |
27 | - 'numeric' => array( 'numeric' ) |
|
27 | + 'numeric' => array('numeric') |
|
28 | 28 | // 'integer' => array('bit', 'bit varying', 'real', 'serial', 'int', 'integer'), |
29 | 29 | // 'boolean' => array('boolean'), |
30 | 30 | // 'float' => array('bigint', 'bigserial', 'double precision', 'money', 'numeric') |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function getPHPType() |
38 | 38 | { |
39 | - $dbtype = strtolower($this->getDbType()); |
|
39 | + $dbtype=strtolower($this->getDbType()); |
|
40 | 40 | foreach(self::$types as $type => $dbtypes) |
41 | 41 | { |
42 | 42 | if(in_array($dbtype, $dbtypes)) |