@@ -60,6 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @param string The path to the XML style sheet. It must be in namespace format. |
63 | + * @param string $value |
|
63 | 64 | */ |
64 | 65 | public function setTransformPath($value) { |
65 | 66 | if(!is_file($value)) { |
@@ -94,6 +95,7 @@ discard block |
||
94 | 95 | |
95 | 96 | /** |
96 | 97 | * @param string Namespace or path to XML document |
98 | + * @param string $value |
|
97 | 99 | * @throws TInvalidDataValueException |
98 | 100 | */ |
99 | 101 | public function setDocumentPath($value) { |
@@ -165,6 +167,7 @@ discard block |
||
165 | 167 | /** |
166 | 168 | * Performs XSL transformation and render the output. |
167 | 169 | * @param THtmlWriter The writer used for the rendering purpose |
170 | + * @param THtmlWriter $writer |
|
168 | 171 | */ |
169 | 172 | public function render($writer) { |
170 | 173 | if(($document=$this->getSourceXmlDocument()) === null) { |
@@ -46,50 +46,50 @@ discard block |
||
46 | 46 | * @throws TConfigurationException If XSL extension is not available |
47 | 47 | */ |
48 | 48 | public function __construct() { |
49 | - if(!class_exists('XSLTProcessor', false)) { |
|
50 | - throw new TConfigurationException('xmltransform_xslextension_required'); |
|
51 | - } |
|
49 | + if(!class_exists('XSLTProcessor', false)) { |
|
50 | + throw new TConfigurationException('xmltransform_xslextension_required'); |
|
51 | + } |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @return string The path to the XML style sheet. |
56 | 56 | */ |
57 | 57 | public function getTransformPath() { |
58 | - return $this->getViewState('TransformPath', ''); |
|
58 | + return $this->getViewState('TransformPath', ''); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @param string The path to the XML style sheet. It must be in namespace format. |
63 | 63 | */ |
64 | 64 | public function setTransformPath($value) { |
65 | - if(!is_file($value)) { |
|
66 | - $value = Prado::getPathOfNamespace($value, self::EXT_XSL_FILE); |
|
67 | - if($value === null) { |
|
65 | + if(!is_file($value)) { |
|
66 | + $value = Prado::getPathOfNamespace($value, self::EXT_XSL_FILE); |
|
67 | + if($value === null) { |
|
68 | 68 | throw new TInvalidDataValueException('xmltransform_transformpath_invalid', $value); |
69 | - } |
|
70 | - } |
|
71 | - $this->setViewState('TransformPath', $value, ''); |
|
69 | + } |
|
70 | + } |
|
71 | + $this->setViewState('TransformPath', $value, ''); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
75 | 75 | * @return string XML style sheet as string |
76 | 76 | */ |
77 | 77 | public function getTransformContent() { |
78 | - return $this->getViewState('TransformContent', ''); |
|
78 | + return $this->getViewState('TransformContent', ''); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | 82 | * @param string $value XML style sheet as string |
83 | 83 | */ |
84 | 84 | public function setTransformContent($value) { |
85 | - $this->setViewState('TransformContent', $value, ''); |
|
85 | + $this->setViewState('TransformContent', $value, ''); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | 89 | * @return string The path to the XML document. It must be in namespace format. |
90 | 90 | */ |
91 | 91 | public function getDocumentPath() { |
92 | - return $this->getViewState('DocumentPath', ''); |
|
92 | + return $this->getViewState('DocumentPath', ''); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -97,27 +97,27 @@ discard block |
||
97 | 97 | * @throws TInvalidDataValueException |
98 | 98 | */ |
99 | 99 | public function setDocumentPath($value) { |
100 | - if(!is_file($value)) { |
|
101 | - $value = Prado::getPathOfNamespace($value, self::EXT_XML_FILE); |
|
102 | - if($value === null) { |
|
100 | + if(!is_file($value)) { |
|
101 | + $value = Prado::getPathOfNamespace($value, self::EXT_XML_FILE); |
|
102 | + if($value === null) { |
|
103 | 103 | throw new TInvalidDataValueException('xmltransform_documentpath_invalid', $value); |
104 | - } |
|
105 | - } |
|
106 | - $this->setViewState('DocumentPath', $value, ''); |
|
104 | + } |
|
105 | + } |
|
106 | + $this->setViewState('DocumentPath', $value, ''); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
110 | 110 | * @return string XML data |
111 | 111 | */ |
112 | 112 | public function getDocumentContent() { |
113 | - return $this->getViewState('DocumentContent', ''); |
|
113 | + return $this->getViewState('DocumentContent', ''); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
117 | 117 | * @param string $value XML data. If not empty, it takes precedence over {@link setDocumentPath DocumentPath}. |
118 | 118 | */ |
119 | 119 | public function setDocumentContent($value) { |
120 | - $this->setViewState('DocumentContent', $value, ''); |
|
120 | + $this->setViewState('DocumentContent', $value, ''); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -125,41 +125,41 @@ discard block |
||
125 | 125 | * @return TAttributeCollection the list of custom parameters |
126 | 126 | */ |
127 | 127 | public function getParameters() { |
128 | - if($params = $this->getViewState('Parameters',null)) { |
|
129 | - return $params; |
|
130 | - } else { |
|
131 | - $params = new TAttributeCollection(); |
|
132 | - $this->setViewState('Parameters', $params, null); |
|
133 | - return $params; |
|
134 | - } |
|
128 | + if($params = $this->getViewState('Parameters',null)) { |
|
129 | + return $params; |
|
130 | + } else { |
|
131 | + $params = new TAttributeCollection(); |
|
132 | + $this->setViewState('Parameters', $params, null); |
|
133 | + return $params; |
|
134 | + } |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | private function getTransformXmlDocument() { |
138 | - if(($content = $this->getTransformContent()) !== '') { |
|
139 | - $document = new DOMDocument(); |
|
140 | - $document->loadXML($content); |
|
141 | - return $document; |
|
142 | - } else if(($path = $this->getTransformPath()) !== '') { |
|
143 | - $document = new DOMDocument(); |
|
144 | - $document->load($path); |
|
145 | - return $document; |
|
146 | - } else { |
|
147 | - throw new TConfigurationException('xmltransform_transform_required'); |
|
148 | - } |
|
138 | + if(($content = $this->getTransformContent()) !== '') { |
|
139 | + $document = new DOMDocument(); |
|
140 | + $document->loadXML($content); |
|
141 | + return $document; |
|
142 | + } else if(($path = $this->getTransformPath()) !== '') { |
|
143 | + $document = new DOMDocument(); |
|
144 | + $document->load($path); |
|
145 | + return $document; |
|
146 | + } else { |
|
147 | + throw new TConfigurationException('xmltransform_transform_required'); |
|
148 | + } |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | private function getSourceXmlDocument() { |
152 | - if(($content = $this->getDocumentContent()) !== '') { |
|
153 | - $document = new DOMDocument(); |
|
154 | - $document->loadXML($content); |
|
155 | - return $document; |
|
156 | - } else if(($path = $this->getDocumentPath()) !== '') { |
|
157 | - $document = new DOMDocument(); |
|
158 | - $document->load($path); |
|
159 | - return $document; |
|
160 | - } else { |
|
161 | - return null; |
|
162 | - } |
|
152 | + if(($content = $this->getDocumentContent()) !== '') { |
|
153 | + $document = new DOMDocument(); |
|
154 | + $document->loadXML($content); |
|
155 | + return $document; |
|
156 | + } else if(($path = $this->getDocumentPath()) !== '') { |
|
157 | + $document = new DOMDocument(); |
|
158 | + $document->load($path); |
|
159 | + return $document; |
|
160 | + } else { |
|
161 | + return null; |
|
162 | + } |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -167,27 +167,27 @@ discard block |
||
167 | 167 | * @param THtmlWriter The writer used for the rendering purpose |
168 | 168 | */ |
169 | 169 | public function render($writer) { |
170 | - if(($document=$this->getSourceXmlDocument()) === null) { |
|
170 | + if(($document=$this->getSourceXmlDocument()) === null) { |
|
171 | 171 | $htmlWriter = Prado::createComponent($this->GetResponse()->getHtmlWriterType(), new TTextWriter()); |
172 | 172 | parent::render($htmlWriter); |
173 | - $document = new DOMDocument(); |
|
174 | - $document->loadXML($htmlWriter->flush()); |
|
175 | - } |
|
176 | - $stylesheet = $this->getTransformXmlDocument(); |
|
177 | - |
|
178 | - // Perform XSL transformation |
|
179 | - $xslt = new XSLTProcessor(); |
|
180 | - $xslt->importStyleSheet($stylesheet); |
|
181 | - |
|
182 | - // Check for parameters |
|
183 | - $parameters = $this->getParameters(); |
|
184 | - foreach($parameters as $name => $value) { |
|
185 | - $xslt->setParameter('', $name, $value); |
|
186 | - } |
|
187 | - $output = $xslt->transformToXML($document); |
|
188 | - |
|
189 | - // Write output |
|
190 | - $writer->write($output); |
|
173 | + $document = new DOMDocument(); |
|
174 | + $document->loadXML($htmlWriter->flush()); |
|
175 | + } |
|
176 | + $stylesheet = $this->getTransformXmlDocument(); |
|
177 | + |
|
178 | + // Perform XSL transformation |
|
179 | + $xslt = new XSLTProcessor(); |
|
180 | + $xslt->importStyleSheet($stylesheet); |
|
181 | + |
|
182 | + // Check for parameters |
|
183 | + $parameters = $this->getParameters(); |
|
184 | + foreach($parameters as $name => $value) { |
|
185 | + $xslt->setParameter('', $name, $value); |
|
186 | + } |
|
187 | + $output = $xslt->transformToXML($document); |
|
188 | + |
|
189 | + // Write output |
|
190 | + $writer->write($output); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @throws TConfigurationException If XSL extension is not available |
47 | 47 | */ |
48 | 48 | public function __construct() { |
49 | - if(!class_exists('XSLTProcessor', false)) { |
|
49 | + if (!class_exists('XSLTProcessor', false)) { |
|
50 | 50 | throw new TConfigurationException('xmltransform_xslextension_required'); |
51 | 51 | } |
52 | 52 | } |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | * @param string The path to the XML style sheet. It must be in namespace format. |
63 | 63 | */ |
64 | 64 | public function setTransformPath($value) { |
65 | - if(!is_file($value)) { |
|
65 | + if (!is_file($value)) { |
|
66 | 66 | $value = Prado::getPathOfNamespace($value, self::EXT_XSL_FILE); |
67 | - if($value === null) { |
|
67 | + if ($value === null) { |
|
68 | 68 | throw new TInvalidDataValueException('xmltransform_transformpath_invalid', $value); |
69 | 69 | } |
70 | 70 | } |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | * @throws TInvalidDataValueException |
98 | 98 | */ |
99 | 99 | public function setDocumentPath($value) { |
100 | - if(!is_file($value)) { |
|
100 | + if (!is_file($value)) { |
|
101 | 101 | $value = Prado::getPathOfNamespace($value, self::EXT_XML_FILE); |
102 | - if($value === null) { |
|
102 | + if ($value === null) { |
|
103 | 103 | throw new TInvalidDataValueException('xmltransform_documentpath_invalid', $value); |
104 | 104 | } |
105 | 105 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @return TAttributeCollection the list of custom parameters |
126 | 126 | */ |
127 | 127 | public function getParameters() { |
128 | - if($params = $this->getViewState('Parameters',null)) { |
|
128 | + if ($params = $this->getViewState('Parameters', null)) { |
|
129 | 129 | return $params; |
130 | 130 | } else { |
131 | 131 | $params = new TAttributeCollection(); |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | } |
136 | 136 | |
137 | 137 | private function getTransformXmlDocument() { |
138 | - if(($content = $this->getTransformContent()) !== '') { |
|
138 | + if (($content = $this->getTransformContent()) !== '') { |
|
139 | 139 | $document = new DOMDocument(); |
140 | 140 | $document->loadXML($content); |
141 | 141 | return $document; |
142 | - } else if(($path = $this->getTransformPath()) !== '') { |
|
142 | + } else if (($path = $this->getTransformPath()) !== '') { |
|
143 | 143 | $document = new DOMDocument(); |
144 | 144 | $document->load($path); |
145 | 145 | return $document; |
@@ -149,11 +149,11 @@ discard block |
||
149 | 149 | } |
150 | 150 | |
151 | 151 | private function getSourceXmlDocument() { |
152 | - if(($content = $this->getDocumentContent()) !== '') { |
|
152 | + if (($content = $this->getDocumentContent()) !== '') { |
|
153 | 153 | $document = new DOMDocument(); |
154 | 154 | $document->loadXML($content); |
155 | 155 | return $document; |
156 | - } else if(($path = $this->getDocumentPath()) !== '') { |
|
156 | + } else if (($path = $this->getDocumentPath()) !== '') { |
|
157 | 157 | $document = new DOMDocument(); |
158 | 158 | $document->load($path); |
159 | 159 | return $document; |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @param THtmlWriter The writer used for the rendering purpose |
168 | 168 | */ |
169 | 169 | public function render($writer) { |
170 | - if(($document=$this->getSourceXmlDocument()) === null) { |
|
170 | + if (($document = $this->getSourceXmlDocument()) === null) { |
|
171 | 171 | $htmlWriter = Prado::createComponent($this->GetResponse()->getHtmlWriterType(), new TTextWriter()); |
172 | 172 | parent::render($htmlWriter); |
173 | 173 | $document = new DOMDocument(); |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | |
182 | 182 | // Check for parameters |
183 | 183 | $parameters = $this->getParameters(); |
184 | - foreach($parameters as $name => $value) { |
|
184 | + foreach ($parameters as $name => $value) { |
|
185 | 185 | $xslt->setParameter('', $name, $value); |
186 | 186 | } |
187 | 187 | $output = $xslt->transformToXML($document); |
@@ -207,6 +207,10 @@ |
||
207 | 207 | return $code; |
208 | 208 | } |
209 | 209 | |
210 | + /** |
|
211 | + * @param string $classname |
|
212 | + * @param string $toString |
|
213 | + */ |
|
210 | 214 | protected function generateClass($properties, $tablename, $classname, $toString) |
211 | 215 | { |
212 | 216 | $props = implode("\n", $properties); |
@@ -14,206 +14,206 @@ discard block |
||
14 | 14 | class TWsatARGenerator extends TWsatBaseGenerator |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Class name prefix |
|
19 | - */ |
|
20 | - private $_clasPrefix; |
|
21 | - |
|
22 | - /** |
|
23 | - * Class name sufix |
|
24 | - */ |
|
25 | - private $_classSufix; |
|
26 | - |
|
27 | - /** |
|
28 | - * all table relations array |
|
29 | - */ |
|
30 | - private $_relations; |
|
31 | - |
|
32 | - /** |
|
33 | - * unquote chars |
|
34 | - * @var array |
|
35 | - */ |
|
36 | - private $uqChars = array('[', ']', '"', '`', "'"); |
|
37 | - |
|
38 | - function __construct() |
|
39 | - { |
|
40 | - parent::__construct(); |
|
41 | - } |
|
42 | - |
|
43 | - public function setClasPrefix($_clas_prefix) |
|
44 | - { |
|
45 | - $this->_clasPrefix = $_clas_prefix; |
|
46 | - } |
|
47 | - |
|
48 | - public function setClassSufix($_clas_sufix) |
|
49 | - { |
|
50 | - $this->_classSufix = $_clas_sufix; |
|
51 | - } |
|
17 | + /** |
|
18 | + * Class name prefix |
|
19 | + */ |
|
20 | + private $_clasPrefix; |
|
21 | + |
|
22 | + /** |
|
23 | + * Class name sufix |
|
24 | + */ |
|
25 | + private $_classSufix; |
|
26 | + |
|
27 | + /** |
|
28 | + * all table relations array |
|
29 | + */ |
|
30 | + private $_relations; |
|
31 | + |
|
32 | + /** |
|
33 | + * unquote chars |
|
34 | + * @var array |
|
35 | + */ |
|
36 | + private $uqChars = array('[', ']', '"', '`', "'"); |
|
37 | + |
|
38 | + function __construct() |
|
39 | + { |
|
40 | + parent::__construct(); |
|
41 | + } |
|
42 | + |
|
43 | + public function setClasPrefix($_clas_prefix) |
|
44 | + { |
|
45 | + $this->_clasPrefix = $_clas_prefix; |
|
46 | + } |
|
47 | + |
|
48 | + public function setClassSufix($_clas_sufix) |
|
49 | + { |
|
50 | + $this->_classSufix = $_clas_sufix; |
|
51 | + } |
|
52 | 52 | |
53 | 53 | //----------------------------------------------------------------------------- |
54 | - // <editor-fold defaultstate="collapsed" desc="Main APIs"> |
|
55 | - public function generate($tableName) |
|
56 | - { |
|
57 | - $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
58 | - $this->_commonGenerate($tableName, $tableInfo); |
|
59 | - } |
|
60 | - |
|
61 | - public function generateAll() |
|
62 | - { |
|
63 | - foreach ($this->getAllTableNames() as $tableName) |
|
64 | - { |
|
65 | - $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
66 | - if (!empty($this->_relations)) |
|
67 | - { |
|
68 | - // Cancel generation of M-M relationships middle table |
|
69 | - if (count($tableInfo->getPrimaryKeys()) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
70 | - continue; |
|
71 | - } |
|
72 | - $this->_commonGenerate($tableName, $tableInfo); |
|
73 | - } |
|
74 | - } |
|
75 | - |
|
76 | - public function buildRelations() |
|
77 | - { |
|
78 | - $this->_relations = array(); |
|
79 | - foreach ($this->getAllTableNames() as $table_name) |
|
80 | - { |
|
81 | - $tableInfo = $this->_dbMetaData->getTableInfo($table_name); |
|
82 | - $pks = $tableInfo->getPrimaryKeys(); |
|
83 | - $fks = $tableInfo->getForeignKeys(); |
|
84 | - |
|
85 | - if (count($pks) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
86 | - { |
|
87 | - $table_name_mm = $fks[0]["table"]; |
|
88 | - $table_name_mm2 = $fks[1]["table"]; |
|
89 | - |
|
90 | - $this->_relations[$table_name_mm][] = array( |
|
91 | - "prop_name" => strtolower($table_name_mm2), |
|
92 | - "rel_type" => "self::MANY_TO_MANY", |
|
93 | - "ref_class_name" => $this->_getProperClassName($table_name_mm2), |
|
94 | - "prop_ref" => $table_name |
|
95 | - ); |
|
96 | - |
|
97 | - $this->_relations[$table_name_mm2][] = array( |
|
98 | - "prop_name" => strtolower($table_name_mm), |
|
99 | - "rel_type" => "self::MANY_TO_MANY", |
|
100 | - "ref_class_name" => $this->_getProperClassName($table_name_mm), |
|
101 | - "prop_ref" => $table_name |
|
102 | - ); |
|
103 | - continue; |
|
104 | - } |
|
105 | - foreach ($fks as $fk_data)//1-M relationships |
|
106 | - { |
|
107 | - $owner_table = $fk_data["table"]; |
|
108 | - $slave_table = $table_name; |
|
109 | - $fk_prop = key($fk_data["keys"]); |
|
110 | - |
|
111 | - $this->_relations[$owner_table][] = array( |
|
112 | - "prop_name" => strtolower($slave_table), |
|
113 | - "rel_type" => "self::HAS_MANY", |
|
114 | - "ref_class_name" => $this->_getProperClassName($slave_table), |
|
115 | - "prop_ref" => $fk_prop |
|
116 | - ); |
|
117 | - |
|
118 | - $this->_relations[$slave_table][] = array( |
|
119 | - "prop_name" => strtolower($owner_table), |
|
120 | - "rel_type" => "self::BELONGS_TO", |
|
121 | - "ref_class_name" => $this->_getProperClassName($owner_table), |
|
122 | - "prop_ref" => $fk_prop |
|
123 | - ); |
|
124 | - } |
|
125 | - } |
|
126 | - } |
|
54 | + // <editor-fold defaultstate="collapsed" desc="Main APIs"> |
|
55 | + public function generate($tableName) |
|
56 | + { |
|
57 | + $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
58 | + $this->_commonGenerate($tableName, $tableInfo); |
|
59 | + } |
|
60 | + |
|
61 | + public function generateAll() |
|
62 | + { |
|
63 | + foreach ($this->getAllTableNames() as $tableName) |
|
64 | + { |
|
65 | + $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
66 | + if (!empty($this->_relations)) |
|
67 | + { |
|
68 | + // Cancel generation of M-M relationships middle table |
|
69 | + if (count($tableInfo->getPrimaryKeys()) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
70 | + continue; |
|
71 | + } |
|
72 | + $this->_commonGenerate($tableName, $tableInfo); |
|
73 | + } |
|
74 | + } |
|
75 | + |
|
76 | + public function buildRelations() |
|
77 | + { |
|
78 | + $this->_relations = array(); |
|
79 | + foreach ($this->getAllTableNames() as $table_name) |
|
80 | + { |
|
81 | + $tableInfo = $this->_dbMetaData->getTableInfo($table_name); |
|
82 | + $pks = $tableInfo->getPrimaryKeys(); |
|
83 | + $fks = $tableInfo->getForeignKeys(); |
|
84 | + |
|
85 | + if (count($pks) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
86 | + { |
|
87 | + $table_name_mm = $fks[0]["table"]; |
|
88 | + $table_name_mm2 = $fks[1]["table"]; |
|
89 | + |
|
90 | + $this->_relations[$table_name_mm][] = array( |
|
91 | + "prop_name" => strtolower($table_name_mm2), |
|
92 | + "rel_type" => "self::MANY_TO_MANY", |
|
93 | + "ref_class_name" => $this->_getProperClassName($table_name_mm2), |
|
94 | + "prop_ref" => $table_name |
|
95 | + ); |
|
96 | + |
|
97 | + $this->_relations[$table_name_mm2][] = array( |
|
98 | + "prop_name" => strtolower($table_name_mm), |
|
99 | + "rel_type" => "self::MANY_TO_MANY", |
|
100 | + "ref_class_name" => $this->_getProperClassName($table_name_mm), |
|
101 | + "prop_ref" => $table_name |
|
102 | + ); |
|
103 | + continue; |
|
104 | + } |
|
105 | + foreach ($fks as $fk_data)//1-M relationships |
|
106 | + { |
|
107 | + $owner_table = $fk_data["table"]; |
|
108 | + $slave_table = $table_name; |
|
109 | + $fk_prop = key($fk_data["keys"]); |
|
110 | + |
|
111 | + $this->_relations[$owner_table][] = array( |
|
112 | + "prop_name" => strtolower($slave_table), |
|
113 | + "rel_type" => "self::HAS_MANY", |
|
114 | + "ref_class_name" => $this->_getProperClassName($slave_table), |
|
115 | + "prop_ref" => $fk_prop |
|
116 | + ); |
|
117 | + |
|
118 | + $this->_relations[$slave_table][] = array( |
|
119 | + "prop_name" => strtolower($owner_table), |
|
120 | + "rel_type" => "self::BELONGS_TO", |
|
121 | + "ref_class_name" => $this->_getProperClassName($owner_table), |
|
122 | + "prop_ref" => $fk_prop |
|
123 | + ); |
|
124 | + } |
|
125 | + } |
|
126 | + } |
|
127 | 127 | |
128 | 128 | // </editor-fold> |
129 | 129 | //----------------------------------------------------------------------------- |
130 | - // <editor-fold defaultstate="collapsed" desc="Common Methods"> |
|
131 | - |
|
132 | - private function _commonGenerate($tableName, $tableInfo) |
|
133 | - { |
|
134 | - if (count($tableInfo->getColumns()) === 0) |
|
135 | - throw new Exception("Unable to find table or view $tableName in " . $this->_dbMetaData->getDbConnection()->getConnectionString() . "."); |
|
136 | - else |
|
137 | - { |
|
138 | - $properties = array(); |
|
139 | - foreach ($tableInfo->getColumns() as $field => $metadata) |
|
140 | - $properties[] = $this->generateProperty($field, $metadata); |
|
141 | - $toString = $this->_buildSmartToString($tableInfo); |
|
142 | - } |
|
143 | - |
|
144 | - $clasName = $this->_getProperClassName($tableName); |
|
145 | - $class = $this->generateClass($properties, $tableName, $clasName, $toString); |
|
146 | - $output = $this->_opFile . DIRECTORY_SEPARATOR . $clasName . ".php"; |
|
147 | - file_put_contents($output, $class); |
|
148 | - } |
|
149 | - |
|
150 | - private function _getProperClassName($tableName) |
|
151 | - { |
|
152 | - $table_name_words = str_replace("_", " ", strtolower($tableName)); |
|
153 | - $final_conversion = str_replace(" ", "", ucwords($table_name_words)); |
|
154 | - return $this->_clasPrefix . $final_conversion . $this->_classSufix; |
|
155 | - } |
|
130 | + // <editor-fold defaultstate="collapsed" desc="Common Methods"> |
|
131 | + |
|
132 | + private function _commonGenerate($tableName, $tableInfo) |
|
133 | + { |
|
134 | + if (count($tableInfo->getColumns()) === 0) |
|
135 | + throw new Exception("Unable to find table or view $tableName in " . $this->_dbMetaData->getDbConnection()->getConnectionString() . "."); |
|
136 | + else |
|
137 | + { |
|
138 | + $properties = array(); |
|
139 | + foreach ($tableInfo->getColumns() as $field => $metadata) |
|
140 | + $properties[] = $this->generateProperty($field, $metadata); |
|
141 | + $toString = $this->_buildSmartToString($tableInfo); |
|
142 | + } |
|
143 | + |
|
144 | + $clasName = $this->_getProperClassName($tableName); |
|
145 | + $class = $this->generateClass($properties, $tableName, $clasName, $toString); |
|
146 | + $output = $this->_opFile . DIRECTORY_SEPARATOR . $clasName . ".php"; |
|
147 | + file_put_contents($output, $class); |
|
148 | + } |
|
149 | + |
|
150 | + private function _getProperClassName($tableName) |
|
151 | + { |
|
152 | + $table_name_words = str_replace("_", " ", strtolower($tableName)); |
|
153 | + $final_conversion = str_replace(" ", "", ucwords($table_name_words)); |
|
154 | + return $this->_clasPrefix . $final_conversion . $this->_classSufix; |
|
155 | + } |
|
156 | 156 | |
157 | 157 | //----------------------------------------------------------------------------- |
158 | 158 | |
159 | - protected function generateProperty($field, $metadata) |
|
160 | - { |
|
161 | - $prop = ''; |
|
162 | - $name = '$' . $field; |
|
163 | - |
|
164 | - /* TODO use in version 2.0 */ |
|
165 | - // $type = $column->getPHPType(); |
|
166 | - |
|
167 | - $prop .= "\tpublic $name;"; |
|
168 | - return $prop; |
|
169 | - } |
|
170 | - |
|
171 | - private function _renderRelations($tablename) |
|
172 | - { |
|
173 | - if (!isset($this->_relations[$tablename])) |
|
174 | - return ""; |
|
175 | - |
|
176 | - $code = "\tpublic static \$RELATIONS = array ("; |
|
177 | - foreach ($this->_relations[$tablename] as $rel_data) |
|
178 | - $code .= "\n\t\t'" . $rel_data["prop_name"] . "' => array(" . $rel_data["rel_type"] . ", '" . $rel_data["ref_class_name"] . "', '" . $rel_data["prop_ref"] . "'),"; |
|
179 | - |
|
180 | - $code = substr($code, 0, -1); |
|
181 | - $code .= "\n\t);"; |
|
182 | - return $code; |
|
183 | - } |
|
184 | - |
|
185 | - private function _buildSmartToString($tableInfo) |
|
186 | - { |
|
187 | - $code = "\tpublic function __toString() {"; |
|
188 | - $property = "throw new THttpException(500, 'Not implemented yet.');"; |
|
189 | - try |
|
190 | - { |
|
191 | - foreach ($tableInfo->getColumns() as $column) |
|
192 | - { |
|
193 | - if (isset($column->IsPrimaryKey) && $column->IsPrimaryKey) |
|
194 | - $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
195 | - elseif ($column->PdoType == PDO::PARAM_STR && $column->DBType != "date") |
|
196 | - { |
|
197 | - $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
198 | - break; |
|
199 | - } |
|
200 | - } |
|
201 | - } catch (Exception $ex) |
|
202 | - { |
|
203 | - Prado::trace($ex->getMessage()); |
|
204 | - } |
|
205 | - $code .= "\n\t\treturn \$this->$property;"; |
|
206 | - $code .= "\n\t}"; |
|
207 | - return $code; |
|
208 | - } |
|
209 | - |
|
210 | - protected function generateClass($properties, $tablename, $classname, $toString) |
|
211 | - { |
|
212 | - $props = implode("\n", $properties); |
|
213 | - $relations = $this->_renderRelations($tablename); |
|
214 | - $date = date('Y-m-d h:i:s'); |
|
215 | - $env_user = getenv("username"); |
|
216 | - return <<<EOD |
|
159 | + protected function generateProperty($field, $metadata) |
|
160 | + { |
|
161 | + $prop = ''; |
|
162 | + $name = '$' . $field; |
|
163 | + |
|
164 | + /* TODO use in version 2.0 */ |
|
165 | + // $type = $column->getPHPType(); |
|
166 | + |
|
167 | + $prop .= "\tpublic $name;"; |
|
168 | + return $prop; |
|
169 | + } |
|
170 | + |
|
171 | + private function _renderRelations($tablename) |
|
172 | + { |
|
173 | + if (!isset($this->_relations[$tablename])) |
|
174 | + return ""; |
|
175 | + |
|
176 | + $code = "\tpublic static \$RELATIONS = array ("; |
|
177 | + foreach ($this->_relations[$tablename] as $rel_data) |
|
178 | + $code .= "\n\t\t'" . $rel_data["prop_name"] . "' => array(" . $rel_data["rel_type"] . ", '" . $rel_data["ref_class_name"] . "', '" . $rel_data["prop_ref"] . "'),"; |
|
179 | + |
|
180 | + $code = substr($code, 0, -1); |
|
181 | + $code .= "\n\t);"; |
|
182 | + return $code; |
|
183 | + } |
|
184 | + |
|
185 | + private function _buildSmartToString($tableInfo) |
|
186 | + { |
|
187 | + $code = "\tpublic function __toString() {"; |
|
188 | + $property = "throw new THttpException(500, 'Not implemented yet.');"; |
|
189 | + try |
|
190 | + { |
|
191 | + foreach ($tableInfo->getColumns() as $column) |
|
192 | + { |
|
193 | + if (isset($column->IsPrimaryKey) && $column->IsPrimaryKey) |
|
194 | + $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
195 | + elseif ($column->PdoType == PDO::PARAM_STR && $column->DBType != "date") |
|
196 | + { |
|
197 | + $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
198 | + break; |
|
199 | + } |
|
200 | + } |
|
201 | + } catch (Exception $ex) |
|
202 | + { |
|
203 | + Prado::trace($ex->getMessage()); |
|
204 | + } |
|
205 | + $code .= "\n\t\treturn \$this->$property;"; |
|
206 | + $code .= "\n\t}"; |
|
207 | + return $code; |
|
208 | + } |
|
209 | + |
|
210 | + protected function generateClass($properties, $tablename, $classname, $toString) |
|
211 | + { |
|
212 | + $props = implode("\n", $properties); |
|
213 | + $relations = $this->_renderRelations($tablename); |
|
214 | + $date = date('Y-m-d h:i:s'); |
|
215 | + $env_user = getenv("username"); |
|
216 | + return <<<EOD |
|
217 | 217 | <?php |
218 | 218 | /** |
219 | 219 | * Auto generated by PRADO - WSAT on $date. |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | $toString |
235 | 235 | } |
236 | 236 | EOD; |
237 | - } |
|
237 | + } |
|
238 | 238 | |
239 | 239 | // </editor-fold> |
240 | 240 | } |
241 | 241 | \ No newline at end of file |
@@ -66,8 +66,10 @@ discard block |
||
66 | 66 | if (!empty($this->_relations)) |
67 | 67 | { |
68 | 68 | // Cancel generation of M-M relationships middle table |
69 | - if (count($tableInfo->getPrimaryKeys()) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
69 | + if (count($tableInfo->getPrimaryKeys()) === 2 && count($tableInfo->getColumns()) === 2) { |
|
70 | + //M-M relationships |
|
70 | 71 | continue; |
72 | + } |
|
71 | 73 | } |
72 | 74 | $this->_commonGenerate($tableName, $tableInfo); |
73 | 75 | } |
@@ -82,9 +84,11 @@ discard block |
||
82 | 84 | $pks = $tableInfo->getPrimaryKeys(); |
83 | 85 | $fks = $tableInfo->getForeignKeys(); |
84 | 86 | |
85 | - if (count($pks) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
87 | + if (count($pks) === 2 && count($tableInfo->getColumns()) === 2) { |
|
88 | + //M-M relationships |
|
86 | 89 | { |
87 | 90 | $table_name_mm = $fks[0]["table"]; |
91 | + } |
|
88 | 92 | $table_name_mm2 = $fks[1]["table"]; |
89 | 93 | |
90 | 94 | $this->_relations[$table_name_mm][] = array( |
@@ -102,9 +106,11 @@ discard block |
||
102 | 106 | ); |
103 | 107 | continue; |
104 | 108 | } |
105 | - foreach ($fks as $fk_data)//1-M relationships |
|
109 | + foreach ($fks as $fk_data) { |
|
110 | + //1-M relationships |
|
106 | 111 | { |
107 | 112 | $owner_table = $fk_data["table"]; |
113 | + } |
|
108 | 114 | $slave_table = $table_name; |
109 | 115 | $fk_prop = key($fk_data["keys"]); |
110 | 116 | |
@@ -131,13 +137,14 @@ discard block |
||
131 | 137 | |
132 | 138 | private function _commonGenerate($tableName, $tableInfo) |
133 | 139 | { |
134 | - if (count($tableInfo->getColumns()) === 0) |
|
135 | - throw new Exception("Unable to find table or view $tableName in " . $this->_dbMetaData->getDbConnection()->getConnectionString() . "."); |
|
136 | - else |
|
140 | + if (count($tableInfo->getColumns()) === 0) { |
|
141 | + throw new Exception("Unable to find table or view $tableName in " . $this->_dbMetaData->getDbConnection()->getConnectionString() . "."); |
|
142 | + } else |
|
137 | 143 | { |
138 | 144 | $properties = array(); |
139 | - foreach ($tableInfo->getColumns() as $field => $metadata) |
|
140 | - $properties[] = $this->generateProperty($field, $metadata); |
|
145 | + foreach ($tableInfo->getColumns() as $field => $metadata) { |
|
146 | + $properties[] = $this->generateProperty($field, $metadata); |
|
147 | + } |
|
141 | 148 | $toString = $this->_buildSmartToString($tableInfo); |
142 | 149 | } |
143 | 150 | |
@@ -170,12 +177,14 @@ discard block |
||
170 | 177 | |
171 | 178 | private function _renderRelations($tablename) |
172 | 179 | { |
173 | - if (!isset($this->_relations[$tablename])) |
|
174 | - return ""; |
|
180 | + if (!isset($this->_relations[$tablename])) { |
|
181 | + return ""; |
|
182 | + } |
|
175 | 183 | |
176 | 184 | $code = "\tpublic static \$RELATIONS = array ("; |
177 | - foreach ($this->_relations[$tablename] as $rel_data) |
|
178 | - $code .= "\n\t\t'" . $rel_data["prop_name"] . "' => array(" . $rel_data["rel_type"] . ", '" . $rel_data["ref_class_name"] . "', '" . $rel_data["prop_ref"] . "'),"; |
|
185 | + foreach ($this->_relations[$tablename] as $rel_data) { |
|
186 | + $code .= "\n\t\t'" . $rel_data["prop_name"] . "' => array(" . $rel_data["rel_type"] . ", '" . $rel_data["ref_class_name"] . "', '" . $rel_data["prop_ref"] . "'),"; |
|
187 | + } |
|
179 | 188 | |
180 | 189 | $code = substr($code, 0, -1); |
181 | 190 | $code .= "\n\t);"; |
@@ -190,9 +199,9 @@ discard block |
||
190 | 199 | { |
191 | 200 | foreach ($tableInfo->getColumns() as $column) |
192 | 201 | { |
193 | - if (isset($column->IsPrimaryKey) && $column->IsPrimaryKey) |
|
194 | - $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
195 | - elseif ($column->PdoType == PDO::PARAM_STR && $column->DBType != "date") |
|
202 | + if (isset($column->IsPrimaryKey) && $column->IsPrimaryKey) { |
|
203 | + $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
204 | + } elseif ($column->PdoType == PDO::PARAM_STR && $column->DBType != "date") |
|
196 | 205 | { |
197 | 206 | $property = str_replace($this->uqChars, "", $column->ColumnName); |
198 | 207 | break; |
@@ -44,6 +44,10 @@ discard block |
||
44 | 44 | |
45 | 45 | //--------------------------------------------------------------------- |
46 | 46 | // <editor-fold defaultstate="collapsed" desc="Page Generation"> |
47 | + |
|
48 | + /** |
|
49 | + * @param integer $viewType |
|
50 | + */ |
|
47 | 51 | public function generate($tableName, $viewType) |
48 | 52 | { |
49 | 53 | switch ($viewType) |
@@ -141,6 +145,10 @@ discard block |
||
141 | 145 | // </editor-fold> |
142 | 146 | //--------------------------------------------------------------------- |
143 | 147 | // <editor-fold defaultstate="collapsed" desc="Code Behind Generation"> |
148 | + |
|
149 | + /** |
|
150 | + * @param string $classname |
|
151 | + */ |
|
144 | 152 | private function generateClass($classname) |
145 | 153 | { |
146 | 154 | $date = date('Y-m-d h:i:s'); |
@@ -14,138 +14,138 @@ discard block |
||
14 | 14 | class TWsatScaffoldingGenerator extends TWsatBaseGenerator |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Const View Types for generation |
|
19 | - */ |
|
20 | - const LIST_TYPE = 0; |
|
21 | - const ADD_TYPE = 1; |
|
22 | - const SHOW_TYPE = 2; |
|
23 | - |
|
24 | - /** |
|
25 | - * Bootstrap option |
|
26 | - */ |
|
27 | - private $_bootstrap; |
|
28 | - |
|
29 | - function __construct() |
|
30 | - { |
|
31 | - parent::__construct(); |
|
32 | - } |
|
33 | - |
|
34 | - /** |
|
35 | - * Generates CRUD Operations for a single DB table |
|
36 | - * @param type $tableName |
|
37 | - */ |
|
38 | - public function generateCRUD($tableName) |
|
39 | - { |
|
40 | - $this->generate($tableName, self::ADD_TYPE); |
|
41 | - $this->generate($tableName, self::LIST_TYPE); |
|
42 | - $this->generate($tableName, self::SHOW_TYPE); |
|
43 | - } |
|
44 | - |
|
45 | - //--------------------------------------------------------------------- |
|
46 | - // <editor-fold defaultstate="collapsed" desc="Page Generation"> |
|
47 | - public function generate($tableName, $viewType) |
|
48 | - { |
|
49 | - switch ($viewType) |
|
50 | - { |
|
51 | - default: |
|
52 | - case self::LIST_TYPE: |
|
53 | - $unitName = "list" . ucfirst($tableName); |
|
54 | - break; |
|
55 | - |
|
56 | - case self::ADD_TYPE: |
|
57 | - $unitName = "add" . ucfirst($tableName); |
|
58 | - break; |
|
59 | - |
|
60 | - case self::SHOW_TYPE: |
|
61 | - $unitName = "show" . ucfirst($tableName); |
|
62 | - break; |
|
63 | - } |
|
64 | - |
|
65 | - $class = $this->generateClass($unitName); |
|
66 | - $outputClass = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".php"; |
|
67 | - file_put_contents($outputClass, $class); |
|
68 | - |
|
69 | - $outputPage = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".page"; |
|
70 | - $page = $this->generatePage($tableName, $viewType); |
|
71 | - file_put_contents($outputPage, $page); |
|
72 | - } |
|
73 | - |
|
74 | - private function generatePage($tableName, $type, $tContentId = "Content") |
|
75 | - { |
|
76 | - $pageContent = $this->getPageContent($tableName, $type); |
|
77 | - return <<<EOD |
|
17 | + /** |
|
18 | + * Const View Types for generation |
|
19 | + */ |
|
20 | + const LIST_TYPE = 0; |
|
21 | + const ADD_TYPE = 1; |
|
22 | + const SHOW_TYPE = 2; |
|
23 | + |
|
24 | + /** |
|
25 | + * Bootstrap option |
|
26 | + */ |
|
27 | + private $_bootstrap; |
|
28 | + |
|
29 | + function __construct() |
|
30 | + { |
|
31 | + parent::__construct(); |
|
32 | + } |
|
33 | + |
|
34 | + /** |
|
35 | + * Generates CRUD Operations for a single DB table |
|
36 | + * @param type $tableName |
|
37 | + */ |
|
38 | + public function generateCRUD($tableName) |
|
39 | + { |
|
40 | + $this->generate($tableName, self::ADD_TYPE); |
|
41 | + $this->generate($tableName, self::LIST_TYPE); |
|
42 | + $this->generate($tableName, self::SHOW_TYPE); |
|
43 | + } |
|
44 | + |
|
45 | + //--------------------------------------------------------------------- |
|
46 | + // <editor-fold defaultstate="collapsed" desc="Page Generation"> |
|
47 | + public function generate($tableName, $viewType) |
|
48 | + { |
|
49 | + switch ($viewType) |
|
50 | + { |
|
51 | + default: |
|
52 | + case self::LIST_TYPE: |
|
53 | + $unitName = "list" . ucfirst($tableName); |
|
54 | + break; |
|
55 | + |
|
56 | + case self::ADD_TYPE: |
|
57 | + $unitName = "add" . ucfirst($tableName); |
|
58 | + break; |
|
59 | + |
|
60 | + case self::SHOW_TYPE: |
|
61 | + $unitName = "show" . ucfirst($tableName); |
|
62 | + break; |
|
63 | + } |
|
64 | + |
|
65 | + $class = $this->generateClass($unitName); |
|
66 | + $outputClass = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".php"; |
|
67 | + file_put_contents($outputClass, $class); |
|
68 | + |
|
69 | + $outputPage = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".page"; |
|
70 | + $page = $this->generatePage($tableName, $viewType); |
|
71 | + file_put_contents($outputPage, $page); |
|
72 | + } |
|
73 | + |
|
74 | + private function generatePage($tableName, $type, $tContentId = "Content") |
|
75 | + { |
|
76 | + $pageContent = $this->getPageContent($tableName, $type); |
|
77 | + return <<<EOD |
|
78 | 78 | <com:TContent ID="$tContentId"> |
79 | 79 | |
80 | 80 | $pageContent |
81 | 81 | |
82 | 82 | </com:TContent> |
83 | 83 | EOD; |
84 | - } |
|
85 | - |
|
86 | - private function getPageContent($tableName, $type) |
|
87 | - { |
|
88 | - $code = ""; |
|
89 | - $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
90 | - switch ($type) |
|
91 | - { |
|
92 | - case self::LIST_TYPE: |
|
93 | - break; |
|
94 | - case self::ADD_TYPE: |
|
95 | - foreach ($tableInfo->getColumns() as $colField => $colMetadata) |
|
96 | - { |
|
97 | - if (!$colMetadata->IsPrimaryKey && !$colMetadata->IsForeignKey) |
|
98 | - { |
|
99 | - $code .= $this->generateControl($colMetadata); |
|
100 | - $code .= $this->generateValidators($colMetadata); |
|
101 | - $code .= "\n"; |
|
102 | - } |
|
103 | - } |
|
104 | - foreach ($tableInfo->getForeignKeys() as $colField => $colMetadata) |
|
105 | - { |
|
106 | - $colField = $this->eq($colMetadata["table"]); |
|
107 | - $code .= "\t<com:TTextBox ID=$colField />\n"; |
|
108 | - $code .= "\n"; |
|
109 | - // TWsatBaseGenerator::pr($tableInfo); |
|
110 | - } |
|
111 | - $code .= "\t<com:TButton Text=\"Accept\" />\n"; |
|
112 | - |
|
113 | - case self::SHOW_TYPE: |
|
114 | - break; |
|
115 | - } |
|
116 | - return $code; |
|
117 | - } |
|
118 | - |
|
119 | - private function generateControl($colMetadata) |
|
120 | - { |
|
121 | - $controlType = "TTextBox"; |
|
122 | - switch ($colMetadata->DbType) |
|
123 | - { |
|
84 | + } |
|
85 | + |
|
86 | + private function getPageContent($tableName, $type) |
|
87 | + { |
|
88 | + $code = ""; |
|
89 | + $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
90 | + switch ($type) |
|
91 | + { |
|
92 | + case self::LIST_TYPE: |
|
93 | + break; |
|
94 | + case self::ADD_TYPE: |
|
95 | + foreach ($tableInfo->getColumns() as $colField => $colMetadata) |
|
96 | + { |
|
97 | + if (!$colMetadata->IsPrimaryKey && !$colMetadata->IsForeignKey) |
|
98 | + { |
|
99 | + $code .= $this->generateControl($colMetadata); |
|
100 | + $code .= $this->generateValidators($colMetadata); |
|
101 | + $code .= "\n"; |
|
102 | + } |
|
103 | + } |
|
104 | + foreach ($tableInfo->getForeignKeys() as $colField => $colMetadata) |
|
105 | + { |
|
106 | + $colField = $this->eq($colMetadata["table"]); |
|
107 | + $code .= "\t<com:TTextBox ID=$colField />\n"; |
|
108 | + $code .= "\n"; |
|
109 | + // TWsatBaseGenerator::pr($tableInfo); |
|
110 | + } |
|
111 | + $code .= "\t<com:TButton Text=\"Accept\" />\n"; |
|
112 | + |
|
113 | + case self::SHOW_TYPE: |
|
114 | + break; |
|
115 | + } |
|
116 | + return $code; |
|
117 | + } |
|
118 | + |
|
119 | + private function generateControl($colMetadata) |
|
120 | + { |
|
121 | + $controlType = "TTextBox"; |
|
122 | + switch ($colMetadata->DbType) |
|
123 | + { |
|
124 | 124 | |
125 | - } |
|
126 | - $controlId = $colMetadata->ColumnId; |
|
127 | - return "\t<com:$controlType ID=\"$controlId\" />\n"; |
|
128 | - } |
|
129 | - |
|
130 | - private function generateValidators($colMetadata) |
|
131 | - { |
|
132 | - $controlId = $colMetadata->ColumnId; |
|
133 | - $code = ""; |
|
134 | - if (!$colMetadata->AllowNull) |
|
135 | - { |
|
136 | - $code .= "\t<com:TRequiredFieldValidator ControlToValidate=$controlId ValidationGroup=\"addGroup\" Text=\"Field $controlId is required.\" Display=\"Dynamic\" />\n"; |
|
137 | - } |
|
138 | - return $code; |
|
139 | - } |
|
125 | + } |
|
126 | + $controlId = $colMetadata->ColumnId; |
|
127 | + return "\t<com:$controlType ID=\"$controlId\" />\n"; |
|
128 | + } |
|
129 | + |
|
130 | + private function generateValidators($colMetadata) |
|
131 | + { |
|
132 | + $controlId = $colMetadata->ColumnId; |
|
133 | + $code = ""; |
|
134 | + if (!$colMetadata->AllowNull) |
|
135 | + { |
|
136 | + $code .= "\t<com:TRequiredFieldValidator ControlToValidate=$controlId ValidationGroup=\"addGroup\" Text=\"Field $controlId is required.\" Display=\"Dynamic\" />\n"; |
|
137 | + } |
|
138 | + return $code; |
|
139 | + } |
|
140 | 140 | |
141 | 141 | // </editor-fold> |
142 | - //--------------------------------------------------------------------- |
|
143 | - // <editor-fold defaultstate="collapsed" desc="Code Behind Generation"> |
|
144 | - private function generateClass($classname) |
|
145 | - { |
|
146 | - $date = date('Y-m-d h:i:s'); |
|
147 | - $env_user = getenv("username"); |
|
148 | - return <<<EOD |
|
142 | + //--------------------------------------------------------------------- |
|
143 | + // <editor-fold defaultstate="collapsed" desc="Code Behind Generation"> |
|
144 | + private function generateClass($classname) |
|
145 | + { |
|
146 | + $date = date('Y-m-d h:i:s'); |
|
147 | + $env_user = getenv("username"); |
|
148 | + return <<<EOD |
|
149 | 149 | <?php |
150 | 150 | /** |
151 | 151 | * Auto generated by PRADO - WSAT on $date. |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | } |
158 | 158 | EOD; |
159 | - } |
|
159 | + } |
|
160 | 160 | |
161 | 161 | // </editor-fold> |
162 | 162 | } |
@@ -66,6 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | /** |
68 | 68 | * @param TXmlElement parent element of this element |
69 | + * @param TXmlElement|null $parent |
|
69 | 70 | */ |
70 | 71 | public function setParent($parent) |
71 | 72 | { |
@@ -121,6 +122,7 @@ discard block |
||
121 | 122 | } |
122 | 123 | |
123 | 124 | /** |
125 | + * @param string $name |
|
124 | 126 | * @return string the attribute specified by the name, null if no such attribute |
125 | 127 | */ |
126 | 128 | public function getAttribute($name) |
@@ -134,6 +136,8 @@ discard block |
||
134 | 136 | /** |
135 | 137 | * @param string attribute name |
136 | 138 | * @param string attribute value |
139 | + * @param string $name |
|
140 | + * @param string $value |
|
137 | 141 | */ |
138 | 142 | public function setAttribute($name,$value) |
139 | 143 | { |
@@ -161,6 +165,7 @@ discard block |
||
161 | 165 | } |
162 | 166 | |
163 | 167 | /** |
168 | + * @param string $tagName |
|
164 | 169 | * @return TXmlElement the first child element that has the specified tag-name, null if not found |
165 | 170 | */ |
166 | 171 | public function getElementByTagName($tagName) |
@@ -175,6 +180,7 @@ discard block |
||
175 | 180 | } |
176 | 181 | |
177 | 182 | /** |
183 | + * @param string $tagName |
|
178 | 184 | * @return TList list of all child elements that have the specified tag-name |
179 | 185 | */ |
180 | 186 | public function getElementsByTagName($tagName) |
@@ -334,6 +340,7 @@ discard block |
||
334 | 340 | |
335 | 341 | /** |
336 | 342 | * @param string version of this XML document |
343 | + * @param string $version |
|
337 | 344 | */ |
338 | 345 | public function setVersion($version) |
339 | 346 | { |
@@ -350,6 +357,7 @@ discard block |
||
350 | 357 | |
351 | 358 | /** |
352 | 359 | * @param string encoding of this XML document |
360 | + * @param string $encoding |
|
353 | 361 | */ |
354 | 362 | public function setEncoding($encoding) |
355 | 363 | { |
@@ -426,6 +434,7 @@ discard block |
||
426 | 434 | /** |
427 | 435 | * Saves this XML document as an XML file. |
428 | 436 | * @param string the name of the file to be stored with XML output |
437 | + * @param string $file |
|
429 | 438 | * @throws TIOException if the file cannot be written |
430 | 439 | */ |
431 | 440 | public function saveToFile($file) |
@@ -532,6 +541,7 @@ discard block |
||
532 | 541 | * operations for each newly added TXmlElement object. |
533 | 542 | * @param integer the specified position. |
534 | 543 | * @param mixed new item |
544 | + * @param integer $index |
|
535 | 545 | * @throws TInvalidDataTypeException if the item to be inserted is not a TXmlElement object. |
536 | 546 | */ |
537 | 547 | public function insertAt($index,$item) |
@@ -552,6 +562,7 @@ discard block |
||
552 | 562 | * This overrides the parent implementation by performing additional |
553 | 563 | * cleanup work when removing a TXmlElement object. |
554 | 564 | * @param integer the index of the item to be removed. |
565 | + * @param integer $index |
|
555 | 566 | * @return mixed the removed item. |
556 | 567 | */ |
557 | 568 | public function removeAt($index) |
@@ -29,23 +29,23 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * @var TXmlElement parent of this element |
31 | 31 | */ |
32 | - private $_parent=null; |
|
32 | + private $_parent = null; |
|
33 | 33 | /** |
34 | 34 | * @var string tag-name of this element |
35 | 35 | */ |
36 | - private $_tagName='unknown'; |
|
36 | + private $_tagName = 'unknown'; |
|
37 | 37 | /** |
38 | 38 | * @var string text enclosed between opening and closing tags of this element |
39 | 39 | */ |
40 | - private $_value=''; |
|
40 | + private $_value = ''; |
|
41 | 41 | /** |
42 | 42 | * @var TXmlElementList list of child elements of this element |
43 | 43 | */ |
44 | - private $_elements=null; |
|
44 | + private $_elements = null; |
|
45 | 45 | /** |
46 | 46 | * @var TMap attributes of this element |
47 | 47 | */ |
48 | - private $_attributes=null; |
|
48 | + private $_attributes = null; |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Constructor. |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function setParent($parent) |
71 | 71 | { |
72 | - $this->_parent=$parent; |
|
72 | + $this->_parent = $parent; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function setTagName($tagName) |
87 | 87 | { |
88 | - $this->_tagName=$tagName; |
|
88 | + $this->_tagName = $tagName; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function setValue($value) |
103 | 103 | { |
104 | - $this->_value=TPropertyValue::ensureString($value); |
|
104 | + $this->_value = TPropertyValue::ensureString($value); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function getHasElement() |
111 | 111 | { |
112 | - return $this->_elements!==null && $this->_elements->getCount()>0; |
|
112 | + return $this->_elements !== null && $this->_elements->getCount() > 0; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function getHasAttribute() |
119 | 119 | { |
120 | - return $this->_attributes!==null && $this->_attributes->getCount()>0; |
|
120 | + return $this->_attributes !== null && $this->_attributes->getCount() > 0; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function getAttribute($name) |
127 | 127 | { |
128 | - if($this->_attributes!==null) |
|
128 | + if ($this->_attributes !== null) |
|
129 | 129 | return $this->_attributes->itemAt($name); |
130 | 130 | else |
131 | 131 | return null; |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | * @param string attribute name |
136 | 136 | * @param string attribute value |
137 | 137 | */ |
138 | - public function setAttribute($name,$value) |
|
138 | + public function setAttribute($name, $value) |
|
139 | 139 | { |
140 | - $this->getAttributes()->add($name,TPropertyValue::ensureString($value)); |
|
140 | + $this->getAttributes()->add($name, TPropertyValue::ensureString($value)); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -145,8 +145,8 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public function getElements() |
147 | 147 | { |
148 | - if(!$this->_elements) |
|
149 | - $this->_elements=new TXmlElementList($this); |
|
148 | + if (!$this->_elements) |
|
149 | + $this->_elements = new TXmlElementList($this); |
|
150 | 150 | return $this->_elements; |
151 | 151 | } |
152 | 152 | |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function getAttributes() |
157 | 157 | { |
158 | - if(!$this->_attributes) |
|
159 | - $this->_attributes=new TMap; |
|
158 | + if (!$this->_attributes) |
|
159 | + $this->_attributes = new TMap; |
|
160 | 160 | return $this->_attributes; |
161 | 161 | } |
162 | 162 | |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function getElementByTagName($tagName) |
167 | 167 | { |
168 | - if($this->_elements) |
|
168 | + if ($this->_elements) |
|
169 | 169 | { |
170 | - foreach($this->_elements as $element) |
|
171 | - if($element->_tagName===$tagName) |
|
170 | + foreach ($this->_elements as $element) |
|
171 | + if ($element->_tagName === $tagName) |
|
172 | 172 | return $element; |
173 | 173 | } |
174 | 174 | return null; |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function getElementsByTagName($tagName) |
181 | 181 | { |
182 | - $list=new TList; |
|
183 | - if($this->_elements) |
|
182 | + $list = new TList; |
|
183 | + if ($this->_elements) |
|
184 | 184 | { |
185 | - foreach($this->_elements as $element) |
|
186 | - if($element->_tagName===$tagName) |
|
185 | + foreach ($this->_elements as $element) |
|
186 | + if ($element->_tagName === $tagName) |
|
187 | 187 | $list->add($element); |
188 | 188 | } |
189 | 189 | return $list; |
@@ -192,33 +192,33 @@ discard block |
||
192 | 192 | /** |
193 | 193 | * @return string string representation of this element |
194 | 194 | */ |
195 | - public function toString($indent=0) |
|
195 | + public function toString($indent = 0) |
|
196 | 196 | { |
197 | - $attr=''; |
|
198 | - if($this->_attributes!==null) |
|
197 | + $attr = ''; |
|
198 | + if ($this->_attributes !== null) |
|
199 | 199 | { |
200 | - foreach($this->_attributes as $name=>$value) |
|
200 | + foreach ($this->_attributes as $name=>$value) |
|
201 | 201 | { |
202 | - $value=$this->xmlEncode($value); |
|
203 | - $attr.=" $name=\"$value\""; |
|
202 | + $value = $this->xmlEncode($value); |
|
203 | + $attr .= " $name=\"$value\""; |
|
204 | 204 | } |
205 | 205 | } |
206 | - $prefix=str_repeat(' ',$indent*4); |
|
207 | - if($this->getHasElement()) |
|
206 | + $prefix = str_repeat(' ', $indent * 4); |
|
207 | + if ($this->getHasElement()) |
|
208 | 208 | { |
209 | - $str=$prefix."<{$this->_tagName}$attr>\n"; |
|
210 | - foreach($this->getElements() as $element) |
|
211 | - $str.=$element->toString($indent+1)."\n"; |
|
212 | - $str.=$prefix."</{$this->_tagName}>"; |
|
209 | + $str = $prefix . "<{$this->_tagName}$attr>\n"; |
|
210 | + foreach ($this->getElements() as $element) |
|
211 | + $str .= $element->toString($indent + 1) . "\n"; |
|
212 | + $str .= $prefix . "</{$this->_tagName}>"; |
|
213 | 213 | return $str; |
214 | 214 | } |
215 | - else if(($value=$this->getValue())!=='') |
|
215 | + else if (($value = $this->getValue()) !== '') |
|
216 | 216 | { |
217 | - $value=$this->xmlEncode($value); |
|
218 | - return $prefix."<{$this->_tagName}$attr>$value</{$this->_tagName}>"; |
|
217 | + $value = $this->xmlEncode($value); |
|
218 | + return $prefix . "<{$this->_tagName}$attr>$value</{$this->_tagName}>"; |
|
219 | 219 | } |
220 | 220 | else |
221 | - return $prefix."<{$this->_tagName}$attr />"; |
|
221 | + return $prefix . "<{$this->_tagName}$attr />"; |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | private function xmlEncode($str) |
243 | 243 | { |
244 | - return strtr($str,array( |
|
244 | + return strtr($str, array( |
|
245 | 245 | '>'=>'>', |
246 | 246 | '<'=>'<', |
247 | 247 | '&'=>'&', |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | * @param string version of this XML document |
318 | 318 | * @param string encoding of this XML document |
319 | 319 | */ |
320 | - public function __construct($version='1.0',$encoding='') |
|
320 | + public function __construct($version = '1.0', $encoding = '') |
|
321 | 321 | { |
322 | 322 | parent::__construct(''); |
323 | 323 | $this->setVersion($version); |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | */ |
338 | 338 | public function setVersion($version) |
339 | 339 | { |
340 | - $this->_version=$version; |
|
340 | + $this->_version = $version; |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | */ |
354 | 354 | public function setEncoding($encoding) |
355 | 355 | { |
356 | - $this->_encoding=$encoding; |
|
356 | + $this->_encoding = $encoding; |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | /** |
@@ -364,10 +364,10 @@ discard block |
||
364 | 364 | */ |
365 | 365 | public function loadFromFile($file) |
366 | 366 | { |
367 | - if(($str=@file_get_contents($file))!==false) |
|
367 | + if (($str = @file_get_contents($file)) !== false) |
|
368 | 368 | return $this->loadFromString($str); |
369 | 369 | else |
370 | - throw new TIOException('xmldocument_file_read_failed',$file); |
|
370 | + throw new TIOException('xmldocument_file_read_failed', $file); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
@@ -379,44 +379,44 @@ discard block |
||
379 | 379 | public function loadFromString($string) |
380 | 380 | { |
381 | 381 | // TODO: since PHP 5.1, we can get parsing errors and throw them as exception |
382 | - $doc=new DOMDocument(); |
|
383 | - if($doc->loadXML($string)===false) |
|
382 | + $doc = new DOMDocument(); |
|
383 | + if ($doc->loadXML($string) === false) |
|
384 | 384 | return false; |
385 | 385 | |
386 | 386 | $this->setEncoding($doc->encoding); |
387 | 387 | $this->setVersion($doc->version); |
388 | 388 | |
389 | - $element=$doc->documentElement; |
|
389 | + $element = $doc->documentElement; |
|
390 | 390 | $this->setTagName($element->tagName); |
391 | 391 | $this->setValue($element->nodeValue); |
392 | - $elements=$this->getElements(); |
|
393 | - $attributes=$this->getAttributes(); |
|
392 | + $elements = $this->getElements(); |
|
393 | + $attributes = $this->getAttributes(); |
|
394 | 394 | $elements->clear(); |
395 | 395 | $attributes->clear(); |
396 | 396 | |
397 | 397 | static $bSimpleXml; |
398 | - if($bSimpleXml === null) |
|
399 | - $bSimpleXml = (boolean)function_exists('simplexml_load_string'); |
|
398 | + if ($bSimpleXml === null) |
|
399 | + $bSimpleXml = (boolean) function_exists('simplexml_load_string'); |
|
400 | 400 | |
401 | - if($bSimpleXml) |
|
401 | + if ($bSimpleXml) |
|
402 | 402 | { |
403 | 403 | $simpleDoc = simplexml_load_string($string); |
404 | 404 | $docNamespaces = $simpleDoc->getDocNamespaces(false); |
405 | 405 | $simpleDoc = null; |
406 | - foreach($docNamespaces as $prefix => $uri) |
|
406 | + foreach ($docNamespaces as $prefix => $uri) |
|
407 | 407 | { |
408 | - if($prefix === '') |
|
408 | + if ($prefix === '') |
|
409 | 409 | $attributes->add('xmlns', $uri); |
410 | 410 | else |
411 | - $attributes->add('xmlns:'.$prefix, $uri); |
|
411 | + $attributes->add('xmlns:' . $prefix, $uri); |
|
412 | 412 | } |
413 | 413 | } |
414 | 414 | |
415 | - foreach($element->attributes as $name=>$attr) |
|
416 | - $attributes->add(($attr->prefix === '' ? '' : $attr->prefix . ':') .$name,$attr->value); |
|
417 | - foreach($element->childNodes as $child) |
|
415 | + foreach ($element->attributes as $name=>$attr) |
|
416 | + $attributes->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name, $attr->value); |
|
417 | + foreach ($element->childNodes as $child) |
|
418 | 418 | { |
419 | - if($child instanceof DOMElement) |
|
419 | + if ($child instanceof DOMElement) |
|
420 | 420 | $elements->add($this->buildElement($child)); |
421 | 421 | } |
422 | 422 | |
@@ -430,13 +430,13 @@ discard block |
||
430 | 430 | */ |
431 | 431 | public function saveToFile($file) |
432 | 432 | { |
433 | - if(($fw=fopen($file,'w'))!==false) |
|
433 | + if (($fw = fopen($file, 'w')) !== false) |
|
434 | 434 | { |
435 | - fwrite($fw,$this->saveToString()); |
|
435 | + fwrite($fw, $this->saveToString()); |
|
436 | 436 | fclose($fw); |
437 | 437 | } |
438 | 438 | else |
439 | - throw new TIOException('xmldocument_file_write_failed',$file); |
|
439 | + throw new TIOException('xmldocument_file_write_failed', $file); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | /** |
@@ -445,9 +445,9 @@ discard block |
||
445 | 445 | */ |
446 | 446 | public function saveToString() |
447 | 447 | { |
448 | - $version=empty($this->_version)?' version="1.0"':' version="'.$this->_version.'"'; |
|
449 | - $encoding=empty($this->_encoding)?'':' encoding="'.$this->_encoding.'"'; |
|
450 | - return "<?xml{$version}{$encoding}?>\n".$this->toString(0); |
|
448 | + $version = empty($this->_version) ? ' version="1.0"' : ' version="' . $this->_version . '"'; |
|
449 | + $encoding = empty($this->_encoding) ? '' : ' encoding="' . $this->_encoding . '"'; |
|
450 | + return "<?xml{$version}{$encoding}?>\n" . $this->toString(0); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | /** |
@@ -477,14 +477,14 @@ discard block |
||
477 | 477 | */ |
478 | 478 | protected function buildElement($node) |
479 | 479 | { |
480 | - $element=new TXmlElement($node->tagName); |
|
480 | + $element = new TXmlElement($node->tagName); |
|
481 | 481 | $element->setValue($node->nodeValue); |
482 | - foreach($node->attributes as $name=>$attr) |
|
483 | - $element->getAttributes()->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name,$attr->value); |
|
482 | + foreach ($node->attributes as $name=>$attr) |
|
483 | + $element->getAttributes()->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name, $attr->value); |
|
484 | 484 | |
485 | - foreach($node->childNodes as $child) |
|
485 | + foreach ($node->childNodes as $child) |
|
486 | 486 | { |
487 | - if($child instanceof DOMElement) |
|
487 | + if ($child instanceof DOMElement) |
|
488 | 488 | $element->getElements()->add($this->buildElement($child)); |
489 | 489 | } |
490 | 490 | return $element; |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | */ |
516 | 516 | public function __construct(TXmlElement $owner) |
517 | 517 | { |
518 | - $this->_o=$owner; |
|
518 | + $this->_o = $owner; |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | /** |
@@ -534,12 +534,12 @@ discard block |
||
534 | 534 | * @param mixed new item |
535 | 535 | * @throws TInvalidDataTypeException if the item to be inserted is not a TXmlElement object. |
536 | 536 | */ |
537 | - public function insertAt($index,$item) |
|
537 | + public function insertAt($index, $item) |
|
538 | 538 | { |
539 | - if($item instanceof TXmlElement) |
|
539 | + if ($item instanceof TXmlElement) |
|
540 | 540 | { |
541 | - parent::insertAt($index,$item); |
|
542 | - if($item->getParent()!==null) |
|
541 | + parent::insertAt($index, $item); |
|
542 | + if ($item->getParent() !== null) |
|
543 | 543 | $item->getParent()->getElements()->remove($item); |
544 | 544 | $item->setParent($this->_o); |
545 | 545 | } |
@@ -556,8 +556,8 @@ discard block |
||
556 | 556 | */ |
557 | 557 | public function removeAt($index) |
558 | 558 | { |
559 | - $item=parent::removeAt($index); |
|
560 | - if($item instanceof TXmlElement) |
|
559 | + $item = parent::removeAt($index); |
|
560 | + if ($item instanceof TXmlElement) |
|
561 | 561 | $item->setParent(null); |
562 | 562 | return $item; |
563 | 563 | } |
@@ -125,10 +125,11 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function getAttribute($name) |
127 | 127 | { |
128 | - if($this->_attributes!==null) |
|
129 | - return $this->_attributes->itemAt($name); |
|
130 | - else |
|
131 | - return null; |
|
128 | + if($this->_attributes!==null) { |
|
129 | + return $this->_attributes->itemAt($name); |
|
130 | + } else { |
|
131 | + return null; |
|
132 | + } |
|
132 | 133 | } |
133 | 134 | |
134 | 135 | /** |
@@ -145,8 +146,9 @@ discard block |
||
145 | 146 | */ |
146 | 147 | public function getElements() |
147 | 148 | { |
148 | - if(!$this->_elements) |
|
149 | - $this->_elements=new TXmlElementList($this); |
|
149 | + if(!$this->_elements) { |
|
150 | + $this->_elements=new TXmlElementList($this); |
|
151 | + } |
|
150 | 152 | return $this->_elements; |
151 | 153 | } |
152 | 154 | |
@@ -155,8 +157,9 @@ discard block |
||
155 | 157 | */ |
156 | 158 | public function getAttributes() |
157 | 159 | { |
158 | - if(!$this->_attributes) |
|
159 | - $this->_attributes=new TMap; |
|
160 | + if(!$this->_attributes) { |
|
161 | + $this->_attributes=new TMap; |
|
162 | + } |
|
160 | 163 | return $this->_attributes; |
161 | 164 | } |
162 | 165 | |
@@ -167,9 +170,10 @@ discard block |
||
167 | 170 | { |
168 | 171 | if($this->_elements) |
169 | 172 | { |
170 | - foreach($this->_elements as $element) |
|
171 | - if($element->_tagName===$tagName) |
|
173 | + foreach($this->_elements as $element) { |
|
174 | + if($element->_tagName===$tagName) |
|
172 | 175 | return $element; |
176 | + } |
|
173 | 177 | } |
174 | 178 | return null; |
175 | 179 | } |
@@ -182,9 +186,10 @@ discard block |
||
182 | 186 | $list=new TList; |
183 | 187 | if($this->_elements) |
184 | 188 | { |
185 | - foreach($this->_elements as $element) |
|
186 | - if($element->_tagName===$tagName) |
|
189 | + foreach($this->_elements as $element) { |
|
190 | + if($element->_tagName===$tagName) |
|
187 | 191 | $list->add($element); |
192 | + } |
|
188 | 193 | } |
189 | 194 | return $list; |
190 | 195 | } |
@@ -207,18 +212,18 @@ discard block |
||
207 | 212 | if($this->getHasElement()) |
208 | 213 | { |
209 | 214 | $str=$prefix."<{$this->_tagName}$attr>\n"; |
210 | - foreach($this->getElements() as $element) |
|
211 | - $str.=$element->toString($indent+1)."\n"; |
|
215 | + foreach($this->getElements() as $element) { |
|
216 | + $str.=$element->toString($indent+1)."\n"; |
|
217 | + } |
|
212 | 218 | $str.=$prefix."</{$this->_tagName}>"; |
213 | 219 | return $str; |
214 | - } |
|
215 | - else if(($value=$this->getValue())!=='') |
|
220 | + } else if(($value=$this->getValue())!=='') |
|
216 | 221 | { |
217 | 222 | $value=$this->xmlEncode($value); |
218 | 223 | return $prefix."<{$this->_tagName}$attr>$value</{$this->_tagName}>"; |
224 | + } else { |
|
225 | + return $prefix."<{$this->_tagName}$attr />"; |
|
219 | 226 | } |
220 | - else |
|
221 | - return $prefix."<{$this->_tagName}$attr />"; |
|
222 | 227 | } |
223 | 228 | |
224 | 229 | /** |
@@ -364,10 +369,11 @@ discard block |
||
364 | 369 | */ |
365 | 370 | public function loadFromFile($file) |
366 | 371 | { |
367 | - if(($str=@file_get_contents($file))!==false) |
|
368 | - return $this->loadFromString($str); |
|
369 | - else |
|
370 | - throw new TIOException('xmldocument_file_read_failed',$file); |
|
372 | + if(($str=@file_get_contents($file))!==false) { |
|
373 | + return $this->loadFromString($str); |
|
374 | + } else { |
|
375 | + throw new TIOException('xmldocument_file_read_failed',$file); |
|
376 | + } |
|
371 | 377 | } |
372 | 378 | |
373 | 379 | /** |
@@ -380,8 +386,9 @@ discard block |
||
380 | 386 | { |
381 | 387 | // TODO: since PHP 5.1, we can get parsing errors and throw them as exception |
382 | 388 | $doc=new DOMDocument(); |
383 | - if($doc->loadXML($string)===false) |
|
384 | - return false; |
|
389 | + if($doc->loadXML($string)===false) { |
|
390 | + return false; |
|
391 | + } |
|
385 | 392 | |
386 | 393 | $this->setEncoding($doc->encoding); |
387 | 394 | $this->setVersion($doc->version); |
@@ -395,8 +402,9 @@ discard block |
||
395 | 402 | $attributes->clear(); |
396 | 403 | |
397 | 404 | static $bSimpleXml; |
398 | - if($bSimpleXml === null) |
|
399 | - $bSimpleXml = (boolean)function_exists('simplexml_load_string'); |
|
405 | + if($bSimpleXml === null) { |
|
406 | + $bSimpleXml = (boolean)function_exists('simplexml_load_string'); |
|
407 | + } |
|
400 | 408 | |
401 | 409 | if($bSimpleXml) |
402 | 410 | { |
@@ -405,19 +413,22 @@ discard block |
||
405 | 413 | $simpleDoc = null; |
406 | 414 | foreach($docNamespaces as $prefix => $uri) |
407 | 415 | { |
408 | - if($prefix === '') |
|
409 | - $attributes->add('xmlns', $uri); |
|
410 | - else |
|
411 | - $attributes->add('xmlns:'.$prefix, $uri); |
|
416 | + if($prefix === '') { |
|
417 | + $attributes->add('xmlns', $uri); |
|
418 | + } else { |
|
419 | + $attributes->add('xmlns:'.$prefix, $uri); |
|
420 | + } |
|
412 | 421 | } |
413 | 422 | } |
414 | 423 | |
415 | - foreach($element->attributes as $name=>$attr) |
|
416 | - $attributes->add(($attr->prefix === '' ? '' : $attr->prefix . ':') .$name,$attr->value); |
|
424 | + foreach($element->attributes as $name=>$attr) { |
|
425 | + $attributes->add(($attr->prefix === '' ? '' : $attr->prefix . ':') .$name,$attr->value); |
|
426 | + } |
|
417 | 427 | foreach($element->childNodes as $child) |
418 | 428 | { |
419 | - if($child instanceof DOMElement) |
|
420 | - $elements->add($this->buildElement($child)); |
|
429 | + if($child instanceof DOMElement) { |
|
430 | + $elements->add($this->buildElement($child)); |
|
431 | + } |
|
421 | 432 | } |
422 | 433 | |
423 | 434 | return true; |
@@ -434,9 +445,9 @@ discard block |
||
434 | 445 | { |
435 | 446 | fwrite($fw,$this->saveToString()); |
436 | 447 | fclose($fw); |
448 | + } else { |
|
449 | + throw new TIOException('xmldocument_file_write_failed',$file); |
|
437 | 450 | } |
438 | - else |
|
439 | - throw new TIOException('xmldocument_file_write_failed',$file); |
|
440 | 451 | } |
441 | 452 | |
442 | 453 | /** |
@@ -479,13 +490,15 @@ discard block |
||
479 | 490 | { |
480 | 491 | $element=new TXmlElement($node->tagName); |
481 | 492 | $element->setValue($node->nodeValue); |
482 | - foreach($node->attributes as $name=>$attr) |
|
483 | - $element->getAttributes()->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name,$attr->value); |
|
493 | + foreach($node->attributes as $name=>$attr) { |
|
494 | + $element->getAttributes()->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name,$attr->value); |
|
495 | + } |
|
484 | 496 | |
485 | 497 | foreach($node->childNodes as $child) |
486 | 498 | { |
487 | - if($child instanceof DOMElement) |
|
488 | - $element->getElements()->add($this->buildElement($child)); |
|
499 | + if($child instanceof DOMElement) { |
|
500 | + $element->getElements()->add($this->buildElement($child)); |
|
501 | + } |
|
489 | 502 | } |
490 | 503 | return $element; |
491 | 504 | } |
@@ -539,12 +552,13 @@ discard block |
||
539 | 552 | if($item instanceof TXmlElement) |
540 | 553 | { |
541 | 554 | parent::insertAt($index,$item); |
542 | - if($item->getParent()!==null) |
|
543 | - $item->getParent()->getElements()->remove($item); |
|
555 | + if($item->getParent()!==null) { |
|
556 | + $item->getParent()->getElements()->remove($item); |
|
557 | + } |
|
544 | 558 | $item->setParent($this->_o); |
559 | + } else { |
|
560 | + throw new TInvalidDataTypeException('xmlelementlist_xmlelement_required'); |
|
545 | 561 | } |
546 | - else |
|
547 | - throw new TInvalidDataTypeException('xmlelementlist_xmlelement_required'); |
|
548 | 562 | } |
549 | 563 | |
550 | 564 | /** |
@@ -557,8 +571,9 @@ discard block |
||
557 | 571 | public function removeAt($index) |
558 | 572 | { |
559 | 573 | $item=parent::removeAt($index); |
560 | - if($item instanceof TXmlElement) |
|
561 | - $item->setParent(null); |
|
574 | + if($item instanceof TXmlElement) { |
|
575 | + $item->setParent(null); |
|
576 | + } |
|
562 | 577 | return $item; |
563 | 578 | } |
564 | 579 | } |
@@ -19,6 +19,9 @@ |
||
19 | 19 | $this->setVisible(false); |
20 | 20 | } |
21 | 21 | |
22 | + /** |
|
23 | + * @param boolean $value |
|
24 | + */ |
|
22 | 25 | public function setVisible($value) |
23 | 26 | { |
24 | 27 | $this->ensureChildControls(); |
@@ -2,60 +2,60 @@ |
||
2 | 2 | |
3 | 3 | class DMessagesPanel extends TTemplateControl |
4 | 4 | { |
5 | - private $_panelCssClass = ''; |
|
5 | + private $_panelCssClass = ''; |
|
6 | 6 | |
7 | - public function onInit($param) |
|
8 | - { |
|
9 | - parent::onInit($param); |
|
10 | - $this->MessagesPanelEffect->Text = ""; |
|
11 | - } |
|
7 | + public function onInit($param) |
|
8 | + { |
|
9 | + parent::onInit($param); |
|
10 | + $this->MessagesPanelEffect->Text = ""; |
|
11 | + } |
|
12 | 12 | |
13 | - public function setMessage($value) |
|
14 | - { |
|
15 | - $this->Message->Text = $value; |
|
16 | - if ($value != '') |
|
13 | + public function setMessage($value) |
|
14 | + { |
|
15 | + $this->Message->Text = $value; |
|
16 | + if ($value != '') |
|
17 | 17 | $this->setVisible(true); |
18 | - else |
|
18 | + else |
|
19 | 19 | $this->setVisible(false); |
20 | - } |
|
20 | + } |
|
21 | 21 | |
22 | - public function setVisible($value) |
|
23 | - { |
|
22 | + public function setVisible($value) |
|
23 | + { |
|
24 | 24 | $this->ensureChildControls(); |
25 | - if ($value === true) { |
|
25 | + if ($value === true) { |
|
26 | 26 | echo "set visible"; |
27 | - $this->MessagesPanel->Visible = true; |
|
28 | - $this->Message->Visible = true; |
|
29 | - $this->setEffect(null); |
|
30 | - } else { |
|
31 | - $this->MessagesPanel->Visible = false; |
|
32 | - } |
|
33 | - } |
|
27 | + $this->MessagesPanel->Visible = true; |
|
28 | + $this->Message->Visible = true; |
|
29 | + $this->setEffect(null); |
|
30 | + } else { |
|
31 | + $this->MessagesPanel->Visible = false; |
|
32 | + } |
|
33 | + } |
|
34 | 34 | |
35 | - public function setEffect($effect = null) |
|
36 | - { |
|
37 | - if ($effect !== null) { |
|
38 | - $text = "<script type=\"text/javascript\" language=\"javascript\">\r\n"; |
|
39 | - $text .= "// <![CDATA[\r\n"; |
|
40 | - //$text .= "new Effect.$effect(\"" . $this->Page->DMessagesPanel->MessagesPanel->ClientID . "\");\r\n"; |
|
41 | - $text .= "new Effect.$effect(\"" . $this->ClientID . "\");\r\n"; |
|
42 | - $text .= "// ]]>\r\n"; |
|
43 | - $text .= "</script>"; |
|
44 | - $this->MessagesPanelEffect->Text = $text; |
|
45 | - } else { |
|
46 | - $this->MessagesPanelEffect->Text = ''; |
|
47 | - } |
|
48 | - } |
|
35 | + public function setEffect($effect = null) |
|
36 | + { |
|
37 | + if ($effect !== null) { |
|
38 | + $text = "<script type=\"text/javascript\" language=\"javascript\">\r\n"; |
|
39 | + $text .= "// <![CDATA[\r\n"; |
|
40 | + //$text .= "new Effect.$effect(\"" . $this->Page->DMessagesPanel->MessagesPanel->ClientID . "\");\r\n"; |
|
41 | + $text .= "new Effect.$effect(\"" . $this->ClientID . "\");\r\n"; |
|
42 | + $text .= "// ]]>\r\n"; |
|
43 | + $text .= "</script>"; |
|
44 | + $this->MessagesPanelEffect->Text = $text; |
|
45 | + } else { |
|
46 | + $this->MessagesPanelEffect->Text = ''; |
|
47 | + } |
|
48 | + } |
|
49 | 49 | |
50 | - public function setPanelCssClass($value) |
|
51 | - { |
|
50 | + public function setPanelCssClass($value) |
|
51 | + { |
|
52 | 52 | $this->ensureChildControls(); |
53 | - $this->MessagesPanel->CssClass = $value; |
|
54 | - } |
|
53 | + $this->MessagesPanel->CssClass = $value; |
|
54 | + } |
|
55 | 55 | |
56 | - public function setMessageCssClass($value) |
|
57 | - { |
|
56 | + public function setMessageCssClass($value) |
|
57 | + { |
|
58 | 58 | $this->ensureChildControls(); |
59 | - $this->Message->CssClass = $value; |
|
60 | - } |
|
59 | + $this->Message->CssClass = $value; |
|
60 | + } |
|
61 | 61 | } |
@@ -13,10 +13,11 @@ |
||
13 | 13 | public function setMessage($value) |
14 | 14 | { |
15 | 15 | $this->Message->Text = $value; |
16 | - if ($value != '') |
|
17 | - $this->setVisible(true); |
|
18 | - else |
|
19 | - $this->setVisible(false); |
|
16 | + if ($value != '') { |
|
17 | + $this->setVisible(true); |
|
18 | + } else { |
|
19 | + $this->setVisible(false); |
|
20 | + } |
|
20 | 21 | } |
21 | 22 | |
22 | 23 | public function setVisible($value) |
@@ -4,6 +4,9 @@ |
||
4 | 4 | { |
5 | 5 | private $panels = array('pnlContentsA', 'pnlContentsB', 'pnlContentsC', ); |
6 | 6 | |
7 | + /** |
|
8 | + * @param string $id |
|
9 | + */ |
|
7 | 10 | private function showPanel($id, $param) |
8 | 11 | { |
9 | 12 | foreach($this->panels as $panel) |
@@ -2,13 +2,13 @@ |
||
2 | 2 | |
3 | 3 | class MyTabPanelTest extends TPage |
4 | 4 | { |
5 | - private $panels = array('pnlContentsA', 'pnlContentsB', 'pnlContentsC', ); |
|
5 | + private $panels = array('pnlContentsA', 'pnlContentsB', 'pnlContentsC',); |
|
6 | 6 | |
7 | 7 | private function showPanel($id, $param) |
8 | 8 | { |
9 | - foreach($this->panels as $panel) |
|
9 | + foreach ($this->panels as $panel) |
|
10 | 10 | { |
11 | - if($id == $panel) |
|
11 | + if ($id == $panel) |
|
12 | 12 | { |
13 | 13 | $this->$panel->setAttribute('style', 'display: block;'); |
14 | 14 | $this->$panel->setVisible(true); |
@@ -13,8 +13,7 @@ |
||
13 | 13 | $this->$panel->setAttribute('style', 'display: block;'); |
14 | 14 | $this->$panel->setVisible(true); |
15 | 15 | $this->$panel->render($param->NewWriter); |
16 | - } |
|
17 | - else |
|
16 | + } else |
|
18 | 17 | { |
19 | 18 | $this->$panel->setVisible(false); |
20 | 19 | } |
@@ -247,6 +247,9 @@ |
||
247 | 247 | $this->byXPath("//input[@id='{$clientID}']/../..")->click(); |
248 | 248 | } |
249 | 249 | |
250 | + /** |
|
251 | + * @param integer[] $checks |
|
252 | + */ |
|
250 | 253 | function assertCheckBoxes($clientID, $checks, $total = 5) |
251 | 254 | { |
252 | 255 | for($i = 0; $i < $total; $i++) |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * ActiveRatingListTestCase.php |
|
4 | - * |
|
5 | - * @author Bradley Booms <[email protected]> |
|
6 | - * @version Creation Date: Oct 22, 2008 |
|
7 | - */ |
|
3 | + * ActiveRatingListTestCase.php |
|
4 | + * |
|
5 | + * @author Bradley Booms <[email protected]> |
|
6 | + * @version Creation Date: Oct 22, 2008 |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * ActiveRatingListTestCase.php class |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | { |
24 | 24 | function testCheckBoxes() |
25 | 25 | { |
26 | - $base='ctl0_Content_'; |
|
26 | + $base = 'ctl0_Content_'; |
|
27 | 27 | // Verify we're on the right page. |
28 | 28 | $this->url("active-controls/index.php?page=ActiveRatingListCheckBoxesTest"); |
29 | 29 | $this->assertSourceContains("TActiveRatingList Check Boxes Test Case"); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | function testRating() |
43 | 43 | { |
44 | - $base='ctl0_Content_'; |
|
44 | + $base = 'ctl0_Content_'; |
|
45 | 45 | // Verify we're on the right page. |
46 | 46 | $this->url("active-controls/index.php?page=ActiveRatingListRatingTest"); |
47 | 47 | $this->assertSourceContains("TActiveRatingList Rating Test Case"); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | function testSelectedIndex() |
64 | 64 | { |
65 | - $base='ctl0_Content_'; |
|
65 | + $base = 'ctl0_Content_'; |
|
66 | 66 | // Verify we're on the right page. |
67 | 67 | $this->url("active-controls/index.php?page=ActiveRatingListSelectedIndexTest"); |
68 | 68 | $this->assertSourceContains("TActiveRatingList SelectedIndex Test Case"); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | function testAutoPostBack() |
83 | 83 | { |
84 | - $base='ctl0_Content_'; |
|
84 | + $base = 'ctl0_Content_'; |
|
85 | 85 | // Verify we're on the right page. |
86 | 86 | $this->url("active-controls/index.php?page=ActiveRatingListAutoPostBackTest"); |
87 | 87 | $this->assertSourceContains("TActiveRatingList AutoPostBack Test Case"); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | |
101 | 101 | function testAllowInput() |
102 | 102 | { |
103 | - $base='ctl0_Content_'; |
|
103 | + $base = 'ctl0_Content_'; |
|
104 | 104 | // Verify we're on the right page. |
105 | 105 | $this->url("active-controls/index.php?page=ActiveRatingListAllowInputTest"); |
106 | 106 | $this->assertSourceContains("TActiveRatingList AllowInput Test Case"); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | function testReadOnly() |
118 | 118 | { |
119 | - $base='ctl0_Content_'; |
|
119 | + $base = 'ctl0_Content_'; |
|
120 | 120 | // Verify we're on the right page. |
121 | 121 | $this->url("active-controls/index.php?page=ActiveRatingListReadOnlyTest"); |
122 | 122 | $this->assertSourceContains("TActiveRatingList ReadOnly Test Case"); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | |
156 | 156 | function testEnabled() |
157 | 157 | { |
158 | - $base='ctl0_Content_'; |
|
158 | + $base = 'ctl0_Content_'; |
|
159 | 159 | // Verify we're on the right page. |
160 | 160 | $this->url("active-controls/index.php?page=ActiveRatingListEnabledTest"); |
161 | 161 | $this->assertSourceContains("TActiveRatingList Enabled Test Case"); |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | |
195 | 195 | function testHoverCaption() |
196 | 196 | { |
197 | - $base='ctl0_Content_'; |
|
197 | + $base = 'ctl0_Content_'; |
|
198 | 198 | // Verify we're on the right page. |
199 | 199 | $this->url("active-controls/index.php?page=ActiveRatingListHoverCaptionTest"); |
200 | 200 | $this->assertSourceContains("TActiveRatingList Hover Caption Test Case"); |
@@ -243,15 +243,15 @@ discard block |
||
243 | 243 | $this->assertElementPresent("//input[@id='{$base}RatingList_c5']/../../../td[contains(@class, 'rating')]"); |
244 | 244 | } |
245 | 245 | |
246 | - function clickTD($clientID){ |
|
246 | + function clickTD($clientID) { |
|
247 | 247 | $this->byXPath("//input[@id='{$clientID}']/../..")->click(); |
248 | 248 | } |
249 | 249 | |
250 | 250 | function assertCheckBoxes($clientID, $checks, $total = 5) |
251 | 251 | { |
252 | - for($i = 0; $i < $total; $i++) |
|
252 | + for ($i = 0; $i < $total; $i++) |
|
253 | 253 | { |
254 | - if(in_array($i, $checks)) |
|
254 | + if (in_array($i, $checks)) |
|
255 | 255 | $this->assertTrue($this->byId("{$clientID}_c{$i}")->selected()); |
256 | 256 | else |
257 | 257 | $this->assertFalse($this->byId("{$clientID}_c{$i}")->selected()); |
@@ -251,10 +251,11 @@ |
||
251 | 251 | { |
252 | 252 | for($i = 0; $i < $total; $i++) |
253 | 253 | { |
254 | - if(in_array($i, $checks)) |
|
255 | - $this->assertTrue($this->byId("{$clientID}_c{$i}")->selected()); |
|
256 | - else |
|
257 | - $this->assertFalse($this->byId("{$clientID}_c{$i}")->selected()); |
|
254 | + if(in_array($i, $checks)) { |
|
255 | + $this->assertTrue($this->byId("{$clientID}_c{$i}")->selected()); |
|
256 | + } else { |
|
257 | + $this->assertFalse($this->byId("{$clientID}_c{$i}")->selected()); |
|
258 | + } |
|
258 | 259 | } |
259 | 260 | } |
260 | 261 | } |
261 | 262 | \ No newline at end of file |
@@ -10,6 +10,10 @@ |
||
10 | 10 | $this->List->dataBind(); |
11 | 11 | } |
12 | 12 | |
13 | + /** |
|
14 | + * @param string $directory |
|
15 | + * @param string $basePath |
|
16 | + */ |
|
13 | 17 | protected function getPageList($directory,$basePath) |
14 | 18 | { |
15 | 19 | $list=array(); |
@@ -5,26 +5,26 @@ |
||
5 | 5 | public function onLoad($param) |
6 | 6 | { |
7 | 7 | parent::onLoad($param); |
8 | - $list=$this->getPageList(dirname(__FILE__),''); |
|
9 | - $this->List->DataSource=$list; |
|
8 | + $list = $this->getPageList(dirname(__FILE__), ''); |
|
9 | + $this->List->DataSource = $list; |
|
10 | 10 | $this->List->dataBind(); |
11 | 11 | } |
12 | 12 | |
13 | - protected function getPageList($directory,$basePath) |
|
13 | + protected function getPageList($directory, $basePath) |
|
14 | 14 | { |
15 | - $list=array(); |
|
16 | - $folder=@opendir($directory); |
|
17 | - while($entry=@readdir($folder)) |
|
15 | + $list = array(); |
|
16 | + $folder = @opendir($directory); |
|
17 | + while ($entry = @readdir($folder)) |
|
18 | 18 | { |
19 | - if($entry[0]==='.') |
|
19 | + if ($entry[0] === '.') |
|
20 | 20 | continue; |
21 | - else if(is_file($directory.'/'.$entry)) |
|
21 | + else if (is_file($directory . '/' . $entry)) |
|
22 | 22 | { |
23 | - if(($page=basename($entry,'.page'))!==$entry && strpos($page,'.')===false) |
|
24 | - $list['?page='.$basePath.$page]=$basePath.$page; |
|
23 | + if (($page = basename($entry, '.page')) !== $entry && strpos($page, '.') === false) |
|
24 | + $list['?page=' . $basePath . $page] = $basePath . $page; |
|
25 | 25 | } |
26 | 26 | else |
27 | - $list=array_merge($list,$this->getPageList($directory.'/'.$entry,$basePath.$entry.'.')); |
|
27 | + $list = array_merge($list, $this->getPageList($directory . '/' . $entry, $basePath . $entry . '.')); |
|
28 | 28 | } |
29 | 29 | closedir($folder); |
30 | 30 | return $list; |
@@ -16,15 +16,16 @@ |
||
16 | 16 | $folder=@opendir($directory); |
17 | 17 | while($entry=@readdir($folder)) |
18 | 18 | { |
19 | - if($entry[0]==='.') |
|
20 | - continue; |
|
21 | - else if(is_file($directory.'/'.$entry)) |
|
19 | + if($entry[0]==='.') { |
|
20 | + continue; |
|
21 | + } else if(is_file($directory.'/'.$entry)) |
|
22 | 22 | { |
23 | - if(($page=basename($entry,'.page'))!==$entry && strpos($page,'.')===false) |
|
24 | - $list['?page='.$basePath.$page]=$basePath.$page; |
|
23 | + if(($page=basename($entry,'.page'))!==$entry && strpos($page,'.')===false) { |
|
24 | + $list['?page='.$basePath.$page]=$basePath.$page; |
|
25 | + } |
|
26 | + } else { |
|
27 | + $list=array_merge($list,$this->getPageList($directory.'/'.$entry,$basePath.$entry.'.')); |
|
25 | 28 | } |
26 | - else |
|
27 | - $list=array_merge($list,$this->getPageList($directory.'/'.$entry,$basePath.$entry.'.')); |
|
28 | 29 | } |
29 | 30 | closedir($folder); |
30 | 31 | return $list; |
@@ -74,6 +74,9 @@ |
||
74 | 74 | $this->byId('ctl0_Logout')->click(); |
75 | 75 | } |
76 | 76 | |
77 | + /** |
|
78 | + * @param string $title |
|
79 | + */ |
|
77 | 80 | public function assertTitleEquals($title) |
78 | 81 | { |
79 | 82 | $this->pause(50); |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | // page: admin.Home |
19 | 19 | $this->byId('pageAdminHome')->click(); |
20 | 20 | $this->assertTitleEquals('UserLogin'); |
21 | - $this->type('ctl0_Main_Username','AdminUser'); |
|
22 | - $this->type('ctl0_Main_Password','demo'); |
|
21 | + $this->type('ctl0_Main_Username', 'AdminUser'); |
|
22 | + $this->type('ctl0_Main_Password', 'demo'); |
|
23 | 23 | $this->byId('ctl0_Main_LoginButton')->click(); |
24 | 24 | $this->pause(50); |
25 | 25 | $this->byId('pageAdminHome')->click(); |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | // page: admin.users.Home |
42 | 42 | $this->byId('pageAdminUsersHome')->click(); |
43 | 43 | $this->assertTitleEquals('UserLogin'); |
44 | - $this->type('ctl0_Main_Username','NormalUser'); |
|
45 | - $this->type('ctl0_Main_Password','demo'); |
|
44 | + $this->type('ctl0_Main_Username', 'NormalUser'); |
|
45 | + $this->type('ctl0_Main_Password', 'demo'); |
|
46 | 46 | $this->byId('ctl0_Main_LoginButton')->click(); |
47 | 47 | $this->pause(50); |
48 | 48 | $this->byId('pageAdminUsersHome')->click(); |
49 | 49 | $this->assertTitleEquals('UserLogin'); |
50 | - $this->type('ctl0_Main_Username','AdminUser'); |
|
51 | - $this->type('ctl0_Main_Password','demo'); |
|
50 | + $this->type('ctl0_Main_Username', 'AdminUser'); |
|
51 | + $this->type('ctl0_Main_Password', 'demo'); |
|
52 | 52 | $this->byId('ctl0_Main_LoginButton')->click(); |
53 | 53 | $this->pause(50); |
54 | 54 | $this->byId('pageAdminUsersHome')->click(); |