@@ -27,11 +27,11 @@ |
||
27 | 27 | |
28 | 28 | class app_UnknownActionException extends Exception |
29 | 29 | { |
30 | - public function __construct($action, $code = 0) |
|
31 | - { |
|
32 | - $message = 'Unknown method "' . $action->getController() . '::' . $action->getMethod() . '"'; |
|
33 | - parent::__construct($message, $code); |
|
34 | - } |
|
30 | + public function __construct($action, $code = 0) |
|
31 | + { |
|
32 | + $message = 'Unknown method "' . $action->getController() . '::' . $action->getMethod() . '"'; |
|
33 | + parent::__construct($message, $code); |
|
34 | + } |
|
35 | 35 | } |
36 | 36 | |
37 | 37 |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * @copyright Copyright (c) 2008 by CANTICO ({@link http://www.cantico.fr}) |
22 | 22 | */ |
23 | 23 | |
24 | -require_once $GLOBALS['babInstallPath'] . 'utilit/controller.class.php'; |
|
25 | -require_once dirname(__FILE__). '/functions.php'; |
|
24 | +require_once $GLOBALS['babInstallPath'].'utilit/controller.class.php'; |
|
25 | +require_once dirname(__FILE__).'/functions.php'; |
|
26 | 26 | |
27 | 27 | $App = app_App(); |
28 | 28 | $App->includeBase(); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | { |
33 | 33 | public function __construct($action, $code = 0) |
34 | 34 | { |
35 | - $message = 'Unknown method "' . $action->getController() . '::' . $action->getMethod() . '"'; |
|
35 | + $message = 'Unknown method "'.$action->getController().'::'.$action->getMethod().'"'; |
|
36 | 36 | parent::__construct($message, $code); |
37 | 37 | } |
38 | 38 | } |
@@ -215,11 +215,11 @@ discard block |
||
215 | 215 | // we try to select one according to the classname prefix. |
216 | 216 | list($prefix) = explode('_', __CLASS__); |
217 | 217 | $functionalityName = ucwords($prefix); |
218 | - $App = @bab_functionality::get('App/' . $functionalityName); |
|
218 | + $App = @bab_functionality::get('App/'.$functionalityName); |
|
219 | 219 | |
220 | 220 | if (!$App) |
221 | 221 | { |
222 | - throw new app_Exception('Faild to autodetect functionality App/' . $functionalityName.', the getInstance method is deprecated, use $App->ControllerProxy() instead'); |
|
222 | + throw new app_Exception('Faild to autodetect functionality App/'.$functionalityName.', the getInstance method is deprecated, use $App->ControllerProxy() instead'); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | $controller = $App->ControllerProxy($classname, $proxy); |
@@ -238,9 +238,9 @@ discard block |
||
238 | 238 | static function getProxyInstance(Func_App $App, $classname) |
239 | 239 | { |
240 | 240 | $class = new ReflectionClass($classname); |
241 | - $proxyClassname = $class->name . self::PROXY_CLASS_SUFFIX; |
|
241 | + $proxyClassname = $class->name.self::PROXY_CLASS_SUFFIX; |
|
242 | 242 | if (!class_exists($proxyClassname)) { |
243 | - $classStr = 'class ' . $proxyClassname . ' extends ' . $class->name . ' {' . "\n"; |
|
243 | + $classStr = 'class '.$proxyClassname.' extends '.$class->name.' {'."\n"; |
|
244 | 244 | $methods = $class->getMethods(); |
245 | 245 | |
246 | 246 | $classStr .= ' public function __construct(Func_App $App) { |
@@ -253,24 +253,24 @@ discard block |
||
253 | 253 | } |
254 | 254 | |
255 | 255 | |
256 | - $classStr .= ' public function ' . $method->name . '('; |
|
256 | + $classStr .= ' public function '.$method->name.'('; |
|
257 | 257 | $parameters = $method->getParameters(); |
258 | 258 | $parametersStr = array(); |
259 | 259 | foreach ($parameters as $parameter) { |
260 | 260 | |
261 | 261 | if ($parameter->isDefaultValueAvailable()) { |
262 | - $parametersStr[] = '$' . $parameter->name . ' = ' . var_export($parameter->getDefaultValue(), true); |
|
262 | + $parametersStr[] = '$'.$parameter->name.' = '.var_export($parameter->getDefaultValue(), true); |
|
263 | 263 | } else { |
264 | - $parametersStr[] = '$' . $parameter->name; |
|
264 | + $parametersStr[] = '$'.$parameter->name; |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 | $classStr .= implode(', ', $parametersStr); |
268 | - $classStr .= ') {' . "\n"; |
|
269 | - $classStr .= ' $args = func_get_args();' . "\n"; |
|
270 | - $classStr .= ' return $this->getMethodAction(__FUNCTION__, $args);' . "\n"; |
|
271 | - $classStr .= ' }' . "\n"; |
|
268 | + $classStr .= ') {'."\n"; |
|
269 | + $classStr .= ' $args = func_get_args();'."\n"; |
|
270 | + $classStr .= ' return $this->getMethodAction(__FUNCTION__, $args);'."\n"; |
|
271 | + $classStr .= ' }'."\n"; |
|
272 | 272 | } |
273 | - $classStr .= '}' . "\n"; |
|
273 | + $classStr .= '}'."\n"; |
|
274 | 274 | |
275 | 275 | // We define the proxy class |
276 | 276 | eval($classStr); |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | $action->setParameters($actionParams); |
395 | 395 | |
396 | 396 | |
397 | - list(,,$file) = explode('/', $App->controllerTg); |
|
397 | + list(,, $file) = explode('/', $App->controllerTg); |
|
398 | 398 | |
399 | 399 | $action->setParameter('addon', $App->getAddonName().'.'.$file); |
400 | 400 | $action->setParameter('idx', $idx); |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | return false; |
419 | 419 | } |
420 | 420 | |
421 | - list($objectName, ) = explode('.', $method); |
|
421 | + list($objectName,) = explode('.', $method); |
|
422 | 422 | |
423 | 423 | if (!method_exists($this, $objectName)) { |
424 | 424 | header('HTTP/1.0 400 Bad Request'); |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | } |
427 | 427 | |
428 | 428 | $objectController = $this->{$objectName}(false); |
429 | - if ( ! ($objectController instanceof app_Controller)) { |
|
429 | + if (!($objectController instanceof app_Controller)) { |
|
430 | 430 | return false; |
431 | 431 | } |
432 | 432 | |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | } else { |
443 | 443 | if ($this->isAjaxRequest()) { |
444 | 444 | |
445 | - header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); |
|
445 | + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden', true, 403); |
|
446 | 446 | |
447 | 447 | die( |
448 | 448 | bab_json_encode( |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | } catch (app_SaveException $e) { |
464 | 464 | |
465 | 465 | if ($this->isAjaxRequest()) { |
466 | - header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); |
|
466 | + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden', true, 403); |
|
467 | 467 | header('Cache-Control: no-cache, must-revalidate'); |
468 | 468 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
469 | 469 | header('Content-type: application/json'); |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | private function deletedItemPage(Widget_Action $action, app_DeletedRecordException $e) |
585 | 585 | { |
586 | 586 | if ($this->isAjaxRequest()) { |
587 | - header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); |
|
587 | + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden', true, 403); |
|
588 | 588 | header('Cache-Control: no-cache, must-revalidate'); |
589 | 589 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
590 | 590 | header('Content-type: application/json'); |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | ); |
602 | 602 | |
603 | 603 | } |
604 | - header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true, 404); |
|
604 | + header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found', true, 404); |
|
605 | 605 | |
606 | 606 | $App = $this->App(); |
607 | 607 | $W = bab_Widgets(); |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | private function notFoundPage(Widget_Action $action, app_NotFoundException $e) |
636 | 636 | { |
637 | 637 | if ($this->isAjaxRequest()) { |
638 | - $message = sprintf(app_translate('This %s does not exists'), $e->getObjectTitle() . ' (' . $e->getId() . ')'); |
|
638 | + $message = sprintf(app_translate('This %s does not exists'), $e->getObjectTitle().' ('.$e->getId().')'); |
|
639 | 639 | $json = array( |
640 | 640 | 'messages' => array( |
641 | 641 | array( |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | echo bab_json_encode($json); |
648 | 648 | die; |
649 | 649 | } |
650 | - header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true, 404); |
|
650 | + header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found', true, 404); |
|
651 | 651 | header('Cache-Control: no-cache, must-revalidate'); |
652 | 652 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
653 | 653 | |
@@ -667,14 +667,14 @@ discard block |
||
667 | 667 | |
668 | 668 | private function errorPage(Exception $e) |
669 | 669 | { |
670 | - header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal server error', true, 500); |
|
670 | + header($_SERVER['SERVER_PROTOCOL'].' 500 Internal server error', true, 500); |
|
671 | 671 | |
672 | - require_once $GLOBALS['babInstallPath'] . 'utilit/uiutil.php'; |
|
672 | + require_once $GLOBALS['babInstallPath'].'utilit/uiutil.php'; |
|
673 | 673 | $popup = new babBodyPopup(); |
674 | 674 | $popup->babEcho( |
675 | - '<h1>' . $this->App()->translate('There was a problem when trying to perform this operation') . '</h1>' |
|
676 | - . '<h2 class="error">' . $this->App()->translate('Additional debugging information:') . '</h2>' |
|
677 | - . '<p class="error">' . $e->getMessage() . ' ' . $e->getFile() . ' ' . $e->getLine() . ' ' . $e->getTraceAsString() . '</p>' |
|
675 | + '<h1>'.$this->App()->translate('There was a problem when trying to perform this operation').'</h1>' |
|
676 | + . '<h2 class="error">'.$this->App()->translate('Additional debugging information:').'</h2>' |
|
677 | + . '<p class="error">'.$e->getMessage().' '.$e->getFile().' '.$e->getLine().' '.$e->getTraceAsString().'</p>' |
|
678 | 678 | ); |
679 | 679 | |
680 | 680 |
@@ -69,205 +69,205 @@ |
||
69 | 69 | |
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * @param string $sourceClass |
|
74 | - */ |
|
75 | - public function joinSource($sourceClass) |
|
76 | - { |
|
77 | - if (get_class($this->sourceId) !== $sourceClass . 'Set') { |
|
78 | - $this->hasOne('sourceId', $sourceClass . 'Set'); |
|
79 | - $this->join('sourceId'); |
|
80 | - } |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * @param string $targetClass |
|
86 | - */ |
|
87 | - public function joinTarget($targetClass = null) |
|
88 | - { |
|
89 | - if (get_class($this->targetId) !== $targetClass . 'Set') { |
|
90 | - $this->hasOne('targetId', $targetClass . 'Set'); |
|
91 | - $this->join('targetId'); |
|
92 | - } |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - |
|
97 | - public function sourceIsA($recordClass) |
|
98 | - { |
|
99 | - return $this->sourceClass->is($recordClass); |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * |
|
104 | - * @return ORM_Iterator |
|
105 | - */ |
|
106 | - public function selectForSource(app_Record $object, $targetClass = null, $linkType = null) |
|
107 | - { |
|
108 | - $criteria = $this->sourceId->is($object->id) |
|
72 | + /** |
|
73 | + * @param string $sourceClass |
|
74 | + */ |
|
75 | + public function joinSource($sourceClass) |
|
76 | + { |
|
77 | + if (get_class($this->sourceId) !== $sourceClass . 'Set') { |
|
78 | + $this->hasOne('sourceId', $sourceClass . 'Set'); |
|
79 | + $this->join('sourceId'); |
|
80 | + } |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * @param string $targetClass |
|
86 | + */ |
|
87 | + public function joinTarget($targetClass = null) |
|
88 | + { |
|
89 | + if (get_class($this->targetId) !== $targetClass . 'Set') { |
|
90 | + $this->hasOne('targetId', $targetClass . 'Set'); |
|
91 | + $this->join('targetId'); |
|
92 | + } |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + |
|
97 | + public function sourceIsA($recordClass) |
|
98 | + { |
|
99 | + return $this->sourceClass->is($recordClass); |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * |
|
104 | + * @return ORM_Iterator |
|
105 | + */ |
|
106 | + public function selectForSource(app_Record $object, $targetClass = null, $linkType = null) |
|
107 | + { |
|
108 | + $criteria = $this->sourceId->is($object->id) |
|
109 | 109 | ->_AND_($this->sourceClass->is(get_class($object))); |
110 | 110 | |
111 | - if (isset($targetClass)) { |
|
112 | - $this->joinTarget($targetClass); |
|
113 | - $criteria = $criteria->_AND_($this->targetClass->is($targetClass)); |
|
114 | - } |
|
115 | - |
|
116 | - if (isset($linkType)) { |
|
117 | - if (is_array($linkType)) { |
|
118 | - $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
119 | - } else { |
|
120 | - $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
121 | - } |
|
122 | - } |
|
123 | - |
|
124 | - if (is_a($this->targetId, 'app_TraceableRecordSet')) { |
|
125 | - $criteria = $criteria->_AND_($this->targetId->deleted->is(false)); |
|
126 | - } |
|
127 | - |
|
128 | - return $this->select($criteria); |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * |
|
134 | - * @return ORM_Iterator |
|
135 | - */ |
|
136 | - public function selectForSources($objects, $targetClass, $linkType = null) |
|
137 | - { |
|
138 | - $sourceClass = null; |
|
139 | - $sourceIds = array(); |
|
140 | - |
|
141 | - foreach ($objects as $obj) { |
|
142 | - if (is_null($sourceClass)) { |
|
143 | - $sourceClass = get_class($obj); |
|
144 | - } |
|
145 | - $sourceIds[] = $obj->id; |
|
146 | - } |
|
147 | - $criteria = $this->sourceId->in($sourceIds) |
|
148 | - ->_AND_($this->sourceClass->is($sourceClass)); |
|
149 | - |
|
150 | - if (isset($targetClass)) { |
|
151 | - $this->joinTarget($targetClass); |
|
152 | - $criteria = $criteria->_AND_($this->targetClass->is($targetClass)); |
|
153 | - } |
|
154 | - |
|
155 | - if (isset($linkType)) { |
|
156 | - if (is_array($linkType)) { |
|
157 | - $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
158 | - } else { |
|
159 | - $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
160 | - } |
|
161 | - } |
|
162 | - return $this->select($criteria); |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * |
|
168 | - * @return ORM_Iterator |
|
169 | - */ |
|
170 | - public function selectForTarget(app_Record $object, $sourceClass = null, $linkType = null) |
|
171 | - { |
|
172 | - $criteria = $this->targetId->is($object->id) |
|
173 | - ->_AND_($this->targetClass->is(get_class($object))); |
|
174 | - |
|
175 | - if (isset($sourceClass)) { |
|
176 | - $this->joinSource($sourceClass); |
|
177 | - $criteria = $criteria->_AND_($this->sourceClass->is($sourceClass)); |
|
178 | - } |
|
179 | - |
|
180 | - if (isset($linkType)) { |
|
181 | - if (is_array($linkType)) { |
|
182 | - $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
183 | - } else { |
|
184 | - $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
185 | - } |
|
186 | - } |
|
187 | - |
|
188 | - return $this->select($criteria); |
|
189 | - } |
|
190 | - |
|
191 | - |
|
192 | - /** |
|
193 | - * |
|
194 | - * @return ORM_Iterator |
|
195 | - */ |
|
196 | - public function selectForTargets($objects, $sourceClass = null, $linkType = null) |
|
197 | - { |
|
198 | - $targetClass = null; |
|
199 | - $targetIds = array(); |
|
200 | - |
|
201 | - foreach ($objects as $obj) { |
|
202 | - if (is_null($targetClass)) { |
|
203 | - $targetClass = get_class($obj); |
|
204 | - } |
|
205 | - $targetIds[] = $obj->id; |
|
206 | - } |
|
207 | - $criteria = $this->targetId->in($targetIds) |
|
208 | - ->_AND_($this->targetClass->is($targetClass)); |
|
209 | - |
|
210 | - if (isset($sourceClass)) { |
|
211 | - $this->joinSource($sourceClass); |
|
212 | - $criteria = $criteria->_AND_($this->sourceClass->is($sourceClass)); |
|
213 | - } |
|
214 | - |
|
215 | - if (isset($linkType)) { |
|
216 | - if (is_array($linkType)) { |
|
217 | - $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
218 | - } else { |
|
219 | - $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
220 | - } |
|
221 | - } |
|
222 | - |
|
223 | - return $this->select($criteria); |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - |
|
228 | - /** |
|
229 | - * delete all links to an object |
|
230 | - * |
|
231 | - * @param app_Record $object |
|
232 | - * @param string $targetClass if target class is set, links will be deleted only for target classes |
|
233 | - * @param bool $deleteTarget if set to true, the target will be deleted to |
|
234 | - */ |
|
235 | - public function deleteForSource(app_Record $object, $targetClass = null, $deleteTarget = false, $linkType = null) |
|
236 | - { |
|
237 | - $set = clone $this; |
|
238 | - $App = $object->App(); |
|
239 | - |
|
240 | - $criteria = $set->sourceId->is($object->id)->_AND_( |
|
241 | - $set->sourceClass->is(get_class($object)) |
|
242 | - ); |
|
243 | - |
|
244 | - if (null !== $targetClass) { |
|
245 | - $criteria = $criteria->_AND_( |
|
246 | - $set->targetClass->is($targetClass) |
|
247 | - ); |
|
248 | - } |
|
249 | - if (null !== $linkType) { |
|
250 | - $criteria = $criteria->_AND_( |
|
251 | - $set->type->is($linkType) |
|
252 | - ); |
|
253 | - } |
|
254 | - |
|
255 | - if ($deleteTarget) { |
|
256 | - foreach($set->select($criteria) as $link) { |
|
257 | - |
|
258 | - $className = $link->targetClass.'Set'; |
|
259 | - |
|
260 | - // remove prefix |
|
261 | - |
|
262 | - $className = mb_substr($className, 1 + mb_strpos($className, '_')); |
|
263 | - $targetSet = $App->$className(); |
|
264 | - |
|
265 | - $targetSet->delete($targetSet->id->is($link->targetId)); |
|
266 | - } |
|
267 | - } |
|
268 | - |
|
269 | - return $set->delete($criteria); |
|
270 | - } |
|
111 | + if (isset($targetClass)) { |
|
112 | + $this->joinTarget($targetClass); |
|
113 | + $criteria = $criteria->_AND_($this->targetClass->is($targetClass)); |
|
114 | + } |
|
115 | + |
|
116 | + if (isset($linkType)) { |
|
117 | + if (is_array($linkType)) { |
|
118 | + $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
119 | + } else { |
|
120 | + $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
121 | + } |
|
122 | + } |
|
123 | + |
|
124 | + if (is_a($this->targetId, 'app_TraceableRecordSet')) { |
|
125 | + $criteria = $criteria->_AND_($this->targetId->deleted->is(false)); |
|
126 | + } |
|
127 | + |
|
128 | + return $this->select($criteria); |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * |
|
134 | + * @return ORM_Iterator |
|
135 | + */ |
|
136 | + public function selectForSources($objects, $targetClass, $linkType = null) |
|
137 | + { |
|
138 | + $sourceClass = null; |
|
139 | + $sourceIds = array(); |
|
140 | + |
|
141 | + foreach ($objects as $obj) { |
|
142 | + if (is_null($sourceClass)) { |
|
143 | + $sourceClass = get_class($obj); |
|
144 | + } |
|
145 | + $sourceIds[] = $obj->id; |
|
146 | + } |
|
147 | + $criteria = $this->sourceId->in($sourceIds) |
|
148 | + ->_AND_($this->sourceClass->is($sourceClass)); |
|
149 | + |
|
150 | + if (isset($targetClass)) { |
|
151 | + $this->joinTarget($targetClass); |
|
152 | + $criteria = $criteria->_AND_($this->targetClass->is($targetClass)); |
|
153 | + } |
|
154 | + |
|
155 | + if (isset($linkType)) { |
|
156 | + if (is_array($linkType)) { |
|
157 | + $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
158 | + } else { |
|
159 | + $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
160 | + } |
|
161 | + } |
|
162 | + return $this->select($criteria); |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * |
|
168 | + * @return ORM_Iterator |
|
169 | + */ |
|
170 | + public function selectForTarget(app_Record $object, $sourceClass = null, $linkType = null) |
|
171 | + { |
|
172 | + $criteria = $this->targetId->is($object->id) |
|
173 | + ->_AND_($this->targetClass->is(get_class($object))); |
|
174 | + |
|
175 | + if (isset($sourceClass)) { |
|
176 | + $this->joinSource($sourceClass); |
|
177 | + $criteria = $criteria->_AND_($this->sourceClass->is($sourceClass)); |
|
178 | + } |
|
179 | + |
|
180 | + if (isset($linkType)) { |
|
181 | + if (is_array($linkType)) { |
|
182 | + $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
183 | + } else { |
|
184 | + $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
185 | + } |
|
186 | + } |
|
187 | + |
|
188 | + return $this->select($criteria); |
|
189 | + } |
|
190 | + |
|
191 | + |
|
192 | + /** |
|
193 | + * |
|
194 | + * @return ORM_Iterator |
|
195 | + */ |
|
196 | + public function selectForTargets($objects, $sourceClass = null, $linkType = null) |
|
197 | + { |
|
198 | + $targetClass = null; |
|
199 | + $targetIds = array(); |
|
200 | + |
|
201 | + foreach ($objects as $obj) { |
|
202 | + if (is_null($targetClass)) { |
|
203 | + $targetClass = get_class($obj); |
|
204 | + } |
|
205 | + $targetIds[] = $obj->id; |
|
206 | + } |
|
207 | + $criteria = $this->targetId->in($targetIds) |
|
208 | + ->_AND_($this->targetClass->is($targetClass)); |
|
209 | + |
|
210 | + if (isset($sourceClass)) { |
|
211 | + $this->joinSource($sourceClass); |
|
212 | + $criteria = $criteria->_AND_($this->sourceClass->is($sourceClass)); |
|
213 | + } |
|
214 | + |
|
215 | + if (isset($linkType)) { |
|
216 | + if (is_array($linkType)) { |
|
217 | + $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
218 | + } else { |
|
219 | + $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
220 | + } |
|
221 | + } |
|
222 | + |
|
223 | + return $this->select($criteria); |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + |
|
228 | + /** |
|
229 | + * delete all links to an object |
|
230 | + * |
|
231 | + * @param app_Record $object |
|
232 | + * @param string $targetClass if target class is set, links will be deleted only for target classes |
|
233 | + * @param bool $deleteTarget if set to true, the target will be deleted to |
|
234 | + */ |
|
235 | + public function deleteForSource(app_Record $object, $targetClass = null, $deleteTarget = false, $linkType = null) |
|
236 | + { |
|
237 | + $set = clone $this; |
|
238 | + $App = $object->App(); |
|
239 | + |
|
240 | + $criteria = $set->sourceId->is($object->id)->_AND_( |
|
241 | + $set->sourceClass->is(get_class($object)) |
|
242 | + ); |
|
243 | + |
|
244 | + if (null !== $targetClass) { |
|
245 | + $criteria = $criteria->_AND_( |
|
246 | + $set->targetClass->is($targetClass) |
|
247 | + ); |
|
248 | + } |
|
249 | + if (null !== $linkType) { |
|
250 | + $criteria = $criteria->_AND_( |
|
251 | + $set->type->is($linkType) |
|
252 | + ); |
|
253 | + } |
|
254 | + |
|
255 | + if ($deleteTarget) { |
|
256 | + foreach($set->select($criteria) as $link) { |
|
257 | + |
|
258 | + $className = $link->targetClass.'Set'; |
|
259 | + |
|
260 | + // remove prefix |
|
261 | + |
|
262 | + $className = mb_substr($className, 1 + mb_strpos($className, '_')); |
|
263 | + $targetSet = $App->$className(); |
|
264 | + |
|
265 | + $targetSet->delete($targetSet->id->is($link->targetId)); |
|
266 | + } |
|
267 | + } |
|
268 | + |
|
269 | + return $set->delete($criteria); |
|
270 | + } |
|
271 | 271 | |
272 | 272 | |
273 | 273 | /** |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function joinSource($sourceClass) |
76 | 76 | { |
77 | - if (get_class($this->sourceId) !== $sourceClass . 'Set') { |
|
78 | - $this->hasOne('sourceId', $sourceClass . 'Set'); |
|
77 | + if (get_class($this->sourceId) !== $sourceClass.'Set') { |
|
78 | + $this->hasOne('sourceId', $sourceClass.'Set'); |
|
79 | 79 | $this->join('sourceId'); |
80 | 80 | } |
81 | 81 | } |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function joinTarget($targetClass = null) |
88 | 88 | { |
89 | - if (get_class($this->targetId) !== $targetClass . 'Set') { |
|
90 | - $this->hasOne('targetId', $targetClass . 'Set'); |
|
89 | + if (get_class($this->targetId) !== $targetClass.'Set') { |
|
90 | + $this->hasOne('targetId', $targetClass.'Set'); |
|
91 | 91 | $this->join('targetId'); |
92 | 92 | } |
93 | 93 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | } |
254 | 254 | |
255 | 255 | if ($deleteTarget) { |
256 | - foreach($set->select($criteria) as $link) { |
|
256 | + foreach ($set->select($criteria) as $link) { |
|
257 | 257 | |
258 | 258 | $className = $link->targetClass.'Set'; |
259 | 259 |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | { |
176 | 176 | $App = $this->App(); |
177 | 177 | |
178 | - $customFieldSet= $App->CustomFieldSet(); |
|
178 | + $customFieldSet = $App->CustomFieldSet(); |
|
179 | 179 | $object = mb_substr(get_class($this), mb_strlen($App->classPrefix), -mb_strlen('Set')); |
180 | 180 | |
181 | 181 | $customFields = $customFieldSet->select($customFieldSet->object->is($object)); |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | throw new app_Exception('Trying to get the reference string of a record without an id.'); |
391 | 391 | } |
392 | 392 | $classname = $this->getClassName(); |
393 | - return $classname . ':' . $this->id; |
|
393 | + return $classname.':'.$this->id; |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | |
@@ -641,13 +641,13 @@ discard block |
||
641 | 641 | */ |
642 | 642 | protected function importDate($name, $value) |
643 | 643 | { |
644 | - if (preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2}/',$value)) { |
|
644 | + if (preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2}/', $value)) { |
|
645 | 645 | return $this->importProperty($name, $value); |
646 | 646 | } |
647 | 647 | |
648 | 648 | // try in DD/MM/YYYY format |
649 | 649 | |
650 | - if (preg_match('/(?P<day>[0-9]+)\/(?P<month>[0-9]+)\/(?P<year>[0-9]{2,4})/',$value, $matches)) { |
|
650 | + if (preg_match('/(?P<day>[0-9]+)\/(?P<month>[0-9]+)\/(?P<year>[0-9]{2,4})/', $value, $matches)) { |
|
651 | 651 | |
652 | 652 | $value = sprintf('%04d-%02d-%02d', (int) $matches['year'], (int) $matches['month'], (int) $matches['day']); |
653 | 653 |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | return parent::delete($criteria); |
240 | 240 | } |
241 | 241 | |
242 | - require_once $GLOBALS['babInstallPath'] . '/utilit/dateTime.php'; |
|
242 | + require_once $GLOBALS['babInstallPath'].'/utilit/dateTime.php'; |
|
243 | 243 | $now = BAB_DateTime::now()->getIsoDateTime(); |
244 | 244 | |
245 | 245 | $records = $this->select($criteria); |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | return parent::save($record); |
275 | 275 | } |
276 | 276 | |
277 | - require_once $GLOBALS['babInstallPath'] . '/utilit/dateTime.php'; |
|
277 | + require_once $GLOBALS['babInstallPath'].'/utilit/dateTime.php'; |
|
278 | 278 | |
279 | 279 | $now = BAB_DateTime::now()->getIsoDateTime(); |
280 | 280 | |
@@ -304,11 +304,11 @@ discard block |
||
304 | 304 | */ |
305 | 305 | private function uuid() |
306 | 306 | { |
307 | - return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', |
|
308 | - mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), |
|
309 | - mt_rand( 0, 0x0fff ) | 0x4000, |
|
310 | - mt_rand( 0, 0x3fff ) | 0x8000, |
|
311 | - mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) ); |
|
307 | + return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', |
|
308 | + mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), |
|
309 | + mt_rand(0, 0x0fff) | 0x4000, |
|
310 | + mt_rand(0, 0x3fff) | 0x8000, |
|
311 | + mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | |
399 | 399 | $linkSet->hasOne('sourceId', get_class($this)); |
400 | 400 | |
401 | - $criteria = $linkSet->targetClass->is(get_class($target)) |
|
401 | + $criteria = $linkSet->targetClass->is(get_class($target)) |
|
402 | 402 | ->_AND_($linkSet->targetId->is($target->id)) |
403 | 403 | ->_AND_($linkSet->sourceClass->is($this->getRecordClassName())); |
404 | 404 | if (isset($linkType)) { |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | |
429 | 429 | $linkSet->hasOne('targetId', get_class($this)); |
430 | 430 | |
431 | - $criteria = $linkSet->sourceClass->is(get_class($source)) |
|
431 | + $criteria = $linkSet->sourceClass->is(get_class($source)) |
|
432 | 432 | ->_AND_($linkSet->sourceId->is($source->id)) |
433 | 433 | ->_AND_($linkSet->targetClass->is($this->getRecordClassName())); |
434 | 434 | if (isset($linkType)) { |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | $sourcesCriteria[] = $linkSet->sourceClass->is($sourceClass)->_AND_($linkSet->sourceId->in($sourceIds)); |
473 | 473 | } |
474 | 474 | |
475 | - $criteria = $linkSet->all( |
|
475 | + $criteria = $linkSet->all( |
|
476 | 476 | $linkSet->targetClass->is($this->getRecordClassName()), |
477 | 477 | $linkSet->any($sourcesCriteria) |
478 | 478 | ); |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | $targetsCriteria[] = $linkSet->targetClass->is($targetClass)->_AND_($linkSet->targetId->in($targetIds)); |
518 | 518 | } |
519 | 519 | |
520 | - $criteria = $linkSet->all( |
|
520 | + $criteria = $linkSet->all( |
|
521 | 521 | $linkSet->sourceClass->is($this->getRecordClassName()), |
522 | 522 | $linkSet->any($targetsCriteria) |
523 | 523 | ); |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | { |
576 | 576 | $linkSet = $this->App()->LinkSet(); |
577 | 577 | |
578 | - $criteria = $linkSet->sourceClass->is(get_class($source)) |
|
578 | + $criteria = $linkSet->sourceClass->is(get_class($source)) |
|
579 | 579 | ->_AND_($linkSet->sourceId->is($source->id)) |
580 | 580 | ->_AND_($linkSet->targetClass->is(get_class($this))) |
581 | 581 | ->_AND_($linkSet->targetId->is($this->id)); |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | { |
606 | 606 | $linkSet = $this->App()->LinkSet(); |
607 | 607 | |
608 | - $criteria = $linkSet->targetClass->is(get_class($target)) |
|
608 | + $criteria = $linkSet->targetClass->is(get_class($target)) |
|
609 | 609 | ->_AND_($linkSet->targetId->is($target->id)) |
610 | 610 | ->_AND_($linkSet->sourceClass->is(get_class($this))) |
611 | 611 | ->_AND_($linkSet->sourceId->is($this->id)); |
@@ -23,12 +23,12 @@ |
||
23 | 23 | |
24 | 24 | |
25 | 25 | |
26 | -require_once dirname(__FILE__). '/functions.php'; |
|
26 | +require_once dirname(__FILE__).'/functions.php'; |
|
27 | 27 | |
28 | 28 | |
29 | 29 | function LibApp_upgrade($sVersionBase, $sVersionIni) |
30 | 30 | { |
31 | - require_once dirname(__FILE__) . '/app.php'; |
|
31 | + require_once dirname(__FILE__).'/app.php'; |
|
32 | 32 | Func_App::register(); |
33 | 33 | |
34 | 34 | $App = app_App(); |
@@ -33,50 +33,50 @@ discard block |
||
33 | 33 | */ |
34 | 34 | function app_genericSetEditor(ORM_RecordSet $set) |
35 | 35 | { |
36 | - $O = bab_functionality::get('LibOrm'); |
|
37 | - $O->init(); |
|
38 | - $W = bab_Widgets(); |
|
39 | - $layout = $W->VBoxLayout(); |
|
40 | - $layout->setVerticalSpacing(1, 'em'); |
|
41 | - |
|
42 | - |
|
43 | - $fields = $set->getFields(); |
|
44 | - |
|
45 | - foreach ($fields as $field) { |
|
46 | - $description = $field->getDescription(); |
|
47 | - if (empty($description)) { |
|
48 | - $description = $field->getName(); |
|
49 | - } |
|
50 | - $fieldLabel = $W->Label($description . ':'); |
|
51 | - |
|
52 | - if ($field instanceof ORM_DateField) { |
|
53 | - $widget = $W->DatePicker(); |
|
54 | - } else if ($field instanceof ORM_TimeField) { |
|
55 | - $widget = $W->LineEdit()->setMaxSize(5)->setSize(5)->addClass('widget-timepicker'); |
|
56 | - } else if ($field instanceof ORM_StringField) { |
|
57 | - $widget = $W->LineEdit()->setSize(min(array(80, $field->getMaxLength()))); |
|
58 | - } else if ($field instanceof ORM_EnumField) { |
|
59 | - $widget = $W->Select(); |
|
60 | - $widget->addOption('', ''); |
|
61 | - foreach ($field->getValues() as $key => $text) { |
|
62 | - $widget->addOption($key, $text); |
|
63 | - } |
|
64 | - } else if ($field instanceof ORM_IntField) { |
|
65 | - $widget = $W->LineEdit()->setSize(9); |
|
66 | - } else if ($field instanceof ORM_TextField) { |
|
67 | - $widget = $W->TextEdit()->setColumns(80)->setLines(5); |
|
68 | - } else if ($field instanceof ORM_RecordSet) { |
|
69 | - $widget = app_genericSetEditor($field); |
|
70 | - $widget->addClass('sub-form'); |
|
71 | - } else { |
|
72 | - $widget = null; |
|
73 | - } |
|
74 | - if (isset($widget)) { |
|
75 | - $layout->addItem($W->VBoxLayout()->addItem($fieldLabel)->addItem($widget)); |
|
76 | - } |
|
77 | - } |
|
78 | - |
|
79 | - return $layout; |
|
36 | + $O = bab_functionality::get('LibOrm'); |
|
37 | + $O->init(); |
|
38 | + $W = bab_Widgets(); |
|
39 | + $layout = $W->VBoxLayout(); |
|
40 | + $layout->setVerticalSpacing(1, 'em'); |
|
41 | + |
|
42 | + |
|
43 | + $fields = $set->getFields(); |
|
44 | + |
|
45 | + foreach ($fields as $field) { |
|
46 | + $description = $field->getDescription(); |
|
47 | + if (empty($description)) { |
|
48 | + $description = $field->getName(); |
|
49 | + } |
|
50 | + $fieldLabel = $W->Label($description . ':'); |
|
51 | + |
|
52 | + if ($field instanceof ORM_DateField) { |
|
53 | + $widget = $W->DatePicker(); |
|
54 | + } else if ($field instanceof ORM_TimeField) { |
|
55 | + $widget = $W->LineEdit()->setMaxSize(5)->setSize(5)->addClass('widget-timepicker'); |
|
56 | + } else if ($field instanceof ORM_StringField) { |
|
57 | + $widget = $W->LineEdit()->setSize(min(array(80, $field->getMaxLength()))); |
|
58 | + } else if ($field instanceof ORM_EnumField) { |
|
59 | + $widget = $W->Select(); |
|
60 | + $widget->addOption('', ''); |
|
61 | + foreach ($field->getValues() as $key => $text) { |
|
62 | + $widget->addOption($key, $text); |
|
63 | + } |
|
64 | + } else if ($field instanceof ORM_IntField) { |
|
65 | + $widget = $W->LineEdit()->setSize(9); |
|
66 | + } else if ($field instanceof ORM_TextField) { |
|
67 | + $widget = $W->TextEdit()->setColumns(80)->setLines(5); |
|
68 | + } else if ($field instanceof ORM_RecordSet) { |
|
69 | + $widget = app_genericSetEditor($field); |
|
70 | + $widget->addClass('sub-form'); |
|
71 | + } else { |
|
72 | + $widget = null; |
|
73 | + } |
|
74 | + if (isset($widget)) { |
|
75 | + $layout->addItem($W->VBoxLayout()->addItem($fieldLabel)->addItem($widget)); |
|
76 | + } |
|
77 | + } |
|
78 | + |
|
79 | + return $layout; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -89,50 +89,50 @@ discard block |
||
89 | 89 | */ |
90 | 90 | function app_genericSetFilterForm(ORM_RecordSet $set) |
91 | 91 | { |
92 | - $O = bab_functionality::get('LibOrm'); |
|
93 | - $O->init(); |
|
94 | - $W = bab_Widgets(); |
|
95 | - $layout = $W->FlowLayout(); |
|
96 | - $layout->setVerticalSpacing(1, 'em')->setHorizontalSpacing(1, 'em'); |
|
97 | - |
|
98 | - |
|
99 | - $fields = $set->getFields(); |
|
100 | - |
|
101 | - foreach ($fields as $field) { |
|
102 | - $description = $field->getDescription(); |
|
103 | - if (empty($description)) { |
|
104 | - $description = $field->getName(); |
|
105 | - } |
|
106 | - $fieldLabel = $W->Label($description . ':'); |
|
107 | - |
|
108 | - if ($field instanceof ORM_DateField) { |
|
109 | - $widget = $W->PeriodPicker(); |
|
110 | - } else if ($field instanceof ORM_TimeField) { |
|
111 | - $widget = $W->TimePicker(); |
|
112 | - } else if ($field instanceof ORM_StringField) { |
|
113 | - $widget = $W->LineEdit()->setSize(min(array(15, $field->getMaxLength()))); |
|
114 | - } else if ($field instanceof ORM_EnumField) { |
|
115 | - $widget = $W->Select(); |
|
116 | - $widget->addOption('', ''); |
|
117 | - foreach ($field->getValues() as $key => $text) { |
|
118 | - $widget->addOption($key, $text); |
|
119 | - } |
|
120 | - } else if ($field instanceof ORM_IntField) { |
|
121 | - $widget = $W->LineEdit()->setSize(9); |
|
122 | - } else if ($field instanceof ORM_TextField) { |
|
123 | - $widget = $widget = $W->LineEdit()->setSize(15); |
|
124 | - } else if ($field instanceof ORM_RecordSet) { |
|
125 | - $widget = app_genericSetFilterForm($field); |
|
126 | - $widget->addClass('sub-form'); |
|
127 | - } else { |
|
128 | - $widget = null; |
|
129 | - } |
|
130 | - if (isset($widget)) { |
|
131 | - $layout->addItem($W->VBoxLayout()->addItem($fieldLabel)->addItem($widget)); |
|
132 | - } |
|
133 | - } |
|
134 | - |
|
135 | - return $layout; |
|
92 | + $O = bab_functionality::get('LibOrm'); |
|
93 | + $O->init(); |
|
94 | + $W = bab_Widgets(); |
|
95 | + $layout = $W->FlowLayout(); |
|
96 | + $layout->setVerticalSpacing(1, 'em')->setHorizontalSpacing(1, 'em'); |
|
97 | + |
|
98 | + |
|
99 | + $fields = $set->getFields(); |
|
100 | + |
|
101 | + foreach ($fields as $field) { |
|
102 | + $description = $field->getDescription(); |
|
103 | + if (empty($description)) { |
|
104 | + $description = $field->getName(); |
|
105 | + } |
|
106 | + $fieldLabel = $W->Label($description . ':'); |
|
107 | + |
|
108 | + if ($field instanceof ORM_DateField) { |
|
109 | + $widget = $W->PeriodPicker(); |
|
110 | + } else if ($field instanceof ORM_TimeField) { |
|
111 | + $widget = $W->TimePicker(); |
|
112 | + } else if ($field instanceof ORM_StringField) { |
|
113 | + $widget = $W->LineEdit()->setSize(min(array(15, $field->getMaxLength()))); |
|
114 | + } else if ($field instanceof ORM_EnumField) { |
|
115 | + $widget = $W->Select(); |
|
116 | + $widget->addOption('', ''); |
|
117 | + foreach ($field->getValues() as $key => $text) { |
|
118 | + $widget->addOption($key, $text); |
|
119 | + } |
|
120 | + } else if ($field instanceof ORM_IntField) { |
|
121 | + $widget = $W->LineEdit()->setSize(9); |
|
122 | + } else if ($field instanceof ORM_TextField) { |
|
123 | + $widget = $widget = $W->LineEdit()->setSize(15); |
|
124 | + } else if ($field instanceof ORM_RecordSet) { |
|
125 | + $widget = app_genericSetFilterForm($field); |
|
126 | + $widget->addClass('sub-form'); |
|
127 | + } else { |
|
128 | + $widget = null; |
|
129 | + } |
|
130 | + if (isset($widget)) { |
|
131 | + $layout->addItem($W->VBoxLayout()->addItem($fieldLabel)->addItem($widget)); |
|
132 | + } |
|
133 | + } |
|
134 | + |
|
135 | + return $layout; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -145,47 +145,47 @@ discard block |
||
145 | 145 | */ |
146 | 146 | function app_LabelledWidget($labelText, Widget_Displayable_Interface $widget) |
147 | 147 | { |
148 | - $W = bab_Widgets(); |
|
149 | - |
|
150 | - $label = $W->Label($labelText); |
|
151 | - if ($widget instanceof Widget_InputWidget) { |
|
152 | - $label->setAssociatedWidget($widget); |
|
153 | - } |
|
154 | - |
|
155 | - if ($widget instanceof Widget_CheckBox) { |
|
156 | - $layout = $W->HBoxItems( |
|
157 | - $widget->setSizePolicy(Widget_SizePolicy::MINIMUM), |
|
158 | - $label |
|
159 | - )->setVerticalAlign('middle')->setHorizontalSpacing(0.5, 'em'); |
|
160 | - } else { |
|
161 | - $layout = $W->VBoxItems( |
|
162 | - $label, |
|
163 | - $widget |
|
164 | - )->setVerticalSpacing(0.5, 'em'); |
|
165 | - } |
|
166 | - |
|
167 | - return $layout; |
|
148 | + $W = bab_Widgets(); |
|
149 | + |
|
150 | + $label = $W->Label($labelText); |
|
151 | + if ($widget instanceof Widget_InputWidget) { |
|
152 | + $label->setAssociatedWidget($widget); |
|
153 | + } |
|
154 | + |
|
155 | + if ($widget instanceof Widget_CheckBox) { |
|
156 | + $layout = $W->HBoxItems( |
|
157 | + $widget->setSizePolicy(Widget_SizePolicy::MINIMUM), |
|
158 | + $label |
|
159 | + )->setVerticalAlign('middle')->setHorizontalSpacing(0.5, 'em'); |
|
160 | + } else { |
|
161 | + $layout = $W->VBoxItems( |
|
162 | + $label, |
|
163 | + $widget |
|
164 | + )->setVerticalSpacing(0.5, 'em'); |
|
165 | + } |
|
166 | + |
|
167 | + return $layout; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | |
171 | 171 | |
172 | 172 | function app_LabelledCheckbox($labelText, $checkboxName, $options = null) |
173 | 173 | { |
174 | - $W = bab_Widgets(); |
|
174 | + $W = bab_Widgets(); |
|
175 | 175 | |
176 | - $label = $W->Label($labelText)->colon(false); |
|
177 | - $checkbox = $W->Checkbox()->setName($checkboxName); |
|
178 | - $label->setAssociatedWidget($checkbox); |
|
179 | - if (isset($options)) { |
|
180 | - $label->setSizePolicy(Widget_SizePolicy::FIXED)->setCanvasOptions($options); |
|
181 | - } |
|
176 | + $label = $W->Label($labelText)->colon(false); |
|
177 | + $checkbox = $W->Checkbox()->setName($checkboxName); |
|
178 | + $label->setAssociatedWidget($checkbox); |
|
179 | + if (isset($options)) { |
|
180 | + $label->setSizePolicy(Widget_SizePolicy::FIXED)->setCanvasOptions($options); |
|
181 | + } |
|
182 | 182 | |
183 | - $layout = $W->HBoxItems( |
|
184 | - $checkbox->setSizePolicy(Widget_SizePolicy::MINIMUM), |
|
185 | - $label |
|
186 | - )->setVerticalAlign('middle')->setHorizontalSpacing(0.5, 'em'); |
|
183 | + $layout = $W->HBoxItems( |
|
184 | + $checkbox->setSizePolicy(Widget_SizePolicy::MINIMUM), |
|
185 | + $label |
|
186 | + )->setVerticalAlign('middle')->setHorizontalSpacing(0.5, 'em'); |
|
187 | 187 | |
188 | - return $layout; |
|
188 | + return $layout; |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | |
@@ -193,42 +193,42 @@ discard block |
||
193 | 193 | |
194 | 194 | function app_LabelledOrmSelect(ORM_MysqlIterator $iterator, $fieldName, $selectName, $label, $hidden = false, $groupFieldName = null) |
195 | 195 | { |
196 | - $W = bab_Widgets(); |
|
197 | - |
|
198 | - if (isset($groupFieldName)) { |
|
199 | - $groupPathElements = explode('/', $groupFieldName); |
|
200 | - } |
|
201 | - |
|
202 | - $select = $W->Select()->setName($selectName); |
|
203 | - |
|
204 | - $select->addOption('', ''); |
|
205 | - |
|
206 | - $nbOptions = 0; |
|
207 | - foreach ($iterator as $record) { |
|
208 | - if (isset($record->code)) { |
|
209 | - $optionText = $record->code . ' - ' . $record->$fieldName; |
|
210 | - } else { |
|
211 | - $optionText = $record->$fieldName; |
|
212 | - } |
|
213 | - if (isset($groupFieldName)) { |
|
214 | - $group = $record; |
|
215 | - foreach ($groupPathElements as $groupPathElement) { |
|
216 | - $group = $group->$groupPathElement; |
|
217 | - } |
|
218 | - $select->addOption($record->id, $optionText, $group); |
|
219 | - } else { |
|
220 | - $select->addOption($record->id, $optionText); |
|
221 | - } |
|
222 | - $nbOptions++; |
|
223 | - $lastId = $record->id; |
|
224 | - } |
|
225 | - |
|
226 | - if ($nbOptions == 1) { |
|
227 | - $select->setValue($lastId); |
|
228 | - } |
|
229 | - |
|
230 | - |
|
231 | - return app_LabelledWidget($label, $select); |
|
196 | + $W = bab_Widgets(); |
|
197 | + |
|
198 | + if (isset($groupFieldName)) { |
|
199 | + $groupPathElements = explode('/', $groupFieldName); |
|
200 | + } |
|
201 | + |
|
202 | + $select = $W->Select()->setName($selectName); |
|
203 | + |
|
204 | + $select->addOption('', ''); |
|
205 | + |
|
206 | + $nbOptions = 0; |
|
207 | + foreach ($iterator as $record) { |
|
208 | + if (isset($record->code)) { |
|
209 | + $optionText = $record->code . ' - ' . $record->$fieldName; |
|
210 | + } else { |
|
211 | + $optionText = $record->$fieldName; |
|
212 | + } |
|
213 | + if (isset($groupFieldName)) { |
|
214 | + $group = $record; |
|
215 | + foreach ($groupPathElements as $groupPathElement) { |
|
216 | + $group = $group->$groupPathElement; |
|
217 | + } |
|
218 | + $select->addOption($record->id, $optionText, $group); |
|
219 | + } else { |
|
220 | + $select->addOption($record->id, $optionText); |
|
221 | + } |
|
222 | + $nbOptions++; |
|
223 | + $lastId = $record->id; |
|
224 | + } |
|
225 | + |
|
226 | + if ($nbOptions == 1) { |
|
227 | + $select->setValue($lastId); |
|
228 | + } |
|
229 | + |
|
230 | + |
|
231 | + return app_LabelledWidget($label, $select); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | |
@@ -236,101 +236,101 @@ discard block |
||
236 | 236 | |
237 | 237 | function app_OrmWidget(ORM_Field $field) |
238 | 238 | { |
239 | - $W = bab_Widgets(); |
|
239 | + $W = bab_Widgets(); |
|
240 | 240 | |
241 | 241 | |
242 | - if ($field instanceof ORM_DateField) { |
|
243 | - $widget = $W->DatePicker(); |
|
244 | - } else if ($field instanceof ORM_TimeField) { |
|
245 | - $widget = $W->TimeEdit(); //->setMaxSize(5)->setSize(5)->addClass('widget-timepicker'); |
|
246 | - } else if ($field instanceof ORM_EnumField) { |
|
247 | - $widget = $W->Select(); |
|
242 | + if ($field instanceof ORM_DateField) { |
|
243 | + $widget = $W->DatePicker(); |
|
244 | + } else if ($field instanceof ORM_TimeField) { |
|
245 | + $widget = $W->TimeEdit(); //->setMaxSize(5)->setSize(5)->addClass('widget-timepicker'); |
|
246 | + } else if ($field instanceof ORM_EnumField) { |
|
247 | + $widget = $W->Select(); |
|
248 | 248 | //// $widget = $W->MultiSelect()->setSingleSelect(); |
249 | - $widget->addOption('', ''); |
|
250 | - $values = $field->getValues(); |
|
251 | - foreach ($values as $key => $value) { |
|
252 | - $widget->addOption($key, $value); |
|
253 | - } |
|
254 | - } else if ($field instanceof ORM_SetField) { |
|
255 | - $widget = $W->MultiSelect()->setSelectedList(2); |
|
256 | - $values = $field->getValues(); |
|
257 | - foreach ($values as $key => $value) { |
|
258 | - $widget->addOption($key, $value); |
|
259 | - } |
|
260 | - } else if ($field instanceof ORM_CurrencyField) { |
|
261 | - $widget = $W->LineEdit()->setSize(6)->addClass('widget-input-currency'); |
|
262 | - } else if ($field instanceof ORM_BoolField) { |
|
263 | - $widget = $W->CheckBox()->setCheckedValue('1'); |
|
264 | - } else if ($field instanceof ORM_IntField) { |
|
265 | - $widget = $W->LineEdit() |
|
266 | - ->setSize(6)->addClass('widget-input-numeric'); |
|
267 | - } else if ($field instanceof ORM_EmailField) { |
|
268 | - $widget = $W->EmailLineEdit() |
|
269 | - ->setMaxSize($field->getMaxLength()); |
|
270 | - } else if ($field instanceof ORM_FileField) { |
|
271 | - $widget = $W->FilePicker(); |
|
272 | - } else if ($field instanceof ORM_StringField) { |
|
273 | - $widget = $W->LineEdit() |
|
274 | - ->setMaxSize($field->getMaxLength()); |
|
275 | - } else if ($field instanceof ORM_TextField) { |
|
276 | - $widget = $W->TextEdit(); |
|
277 | - } else if ($field instanceof ORM_PkField) { |
|
278 | - $widget = $W->Hidden(); |
|
279 | - } else if ($field instanceof ORM_FkField) { |
|
280 | - $widget = $W->Select(); |
|
281 | - $fieldName = $field->getName(); |
|
282 | - $parentSet = clone $field->getParentSet(); |
|
283 | - $parentSet->join($fieldName); |
|
284 | - $set = $parentSet->$fieldName; |
|
285 | - $records = $set->select(); |
|
286 | - $records->orderAsc($set->name); |
|
287 | - $pkName = $set->getPrimaryKey(); |
|
288 | - $widget->addOption('', ''); |
|
289 | - foreach ($records as $record) { |
|
290 | - $widget->addOption($record->$pkName, $record->name); |
|
291 | - } |
|
292 | - } else if ($field instanceof ORM_RecordSet) { |
|
293 | - $widget = $W->Select(); |
|
249 | + $widget->addOption('', ''); |
|
250 | + $values = $field->getValues(); |
|
251 | + foreach ($values as $key => $value) { |
|
252 | + $widget->addOption($key, $value); |
|
253 | + } |
|
254 | + } else if ($field instanceof ORM_SetField) { |
|
255 | + $widget = $W->MultiSelect()->setSelectedList(2); |
|
256 | + $values = $field->getValues(); |
|
257 | + foreach ($values as $key => $value) { |
|
258 | + $widget->addOption($key, $value); |
|
259 | + } |
|
260 | + } else if ($field instanceof ORM_CurrencyField) { |
|
261 | + $widget = $W->LineEdit()->setSize(6)->addClass('widget-input-currency'); |
|
262 | + } else if ($field instanceof ORM_BoolField) { |
|
263 | + $widget = $W->CheckBox()->setCheckedValue('1'); |
|
264 | + } else if ($field instanceof ORM_IntField) { |
|
265 | + $widget = $W->LineEdit() |
|
266 | + ->setSize(6)->addClass('widget-input-numeric'); |
|
267 | + } else if ($field instanceof ORM_EmailField) { |
|
268 | + $widget = $W->EmailLineEdit() |
|
269 | + ->setMaxSize($field->getMaxLength()); |
|
270 | + } else if ($field instanceof ORM_FileField) { |
|
271 | + $widget = $W->FilePicker(); |
|
272 | + } else if ($field instanceof ORM_StringField) { |
|
273 | + $widget = $W->LineEdit() |
|
274 | + ->setMaxSize($field->getMaxLength()); |
|
275 | + } else if ($field instanceof ORM_TextField) { |
|
276 | + $widget = $W->TextEdit(); |
|
277 | + } else if ($field instanceof ORM_PkField) { |
|
278 | + $widget = $W->Hidden(); |
|
279 | + } else if ($field instanceof ORM_FkField) { |
|
280 | + $widget = $W->Select(); |
|
281 | + $fieldName = $field->getName(); |
|
282 | + $parentSet = clone $field->getParentSet(); |
|
283 | + $parentSet->join($fieldName); |
|
284 | + $set = $parentSet->$fieldName; |
|
285 | + $records = $set->select(); |
|
286 | + $records->orderAsc($set->name); |
|
287 | + $pkName = $set->getPrimaryKey(); |
|
288 | + $widget->addOption('', ''); |
|
289 | + foreach ($records as $record) { |
|
290 | + $widget->addOption($record->$pkName, $record->name); |
|
291 | + } |
|
292 | + } else if ($field instanceof ORM_RecordSet) { |
|
293 | + $widget = $W->Select(); |
|
294 | 294 | //// $widget = $W->MultiSelect()->setSingleSelect(); |
295 | 295 | // $fieldName = $field->getName(); |
296 | 296 | // $parentSet = $field->getParentSet(); |
297 | 297 | // $parentSet->join($fieldName); |
298 | 298 | // $set = $parentSet->$fieldName; |
299 | - $records = $field->select(); |
|
300 | - $records->orderAsc($field->name); |
|
301 | - $pkName = $field->getPrimaryKey(); |
|
302 | - $widget->addOption('', ''); |
|
303 | - foreach ($records as $record) { |
|
304 | - $widget->addOption($record->$pkName, $record->name); |
|
305 | - } |
|
306 | - } else { |
|
307 | - $widget = $W->LineEdit(); |
|
308 | - } |
|
309 | - |
|
310 | - $widget->setName($field->getName()); |
|
311 | - |
|
312 | - return $widget; |
|
299 | + $records = $field->select(); |
|
300 | + $records->orderAsc($field->name); |
|
301 | + $pkName = $field->getPrimaryKey(); |
|
302 | + $widget->addOption('', ''); |
|
303 | + foreach ($records as $record) { |
|
304 | + $widget->addOption($record->$pkName, $record->name); |
|
305 | + } |
|
306 | + } else { |
|
307 | + $widget = $W->LineEdit(); |
|
308 | + } |
|
309 | + |
|
310 | + $widget->setName($field->getName()); |
|
311 | + |
|
312 | + return $widget; |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | |
316 | 316 | |
317 | 317 | function app_LabelledOrmWidget(ORM_Field $field, $label = null, $hidden = false) |
318 | 318 | { |
319 | - $W = bab_Widgets(); |
|
319 | + $W = bab_Widgets(); |
|
320 | 320 | |
321 | - if ($hidden) { |
|
322 | - $widget = $W->Hidden(); |
|
323 | - $widget->setName($field->getName()); |
|
324 | - return $widget; |
|
325 | - } |
|
321 | + if ($hidden) { |
|
322 | + $widget = $W->Hidden(); |
|
323 | + $widget->setName($field->getName()); |
|
324 | + return $widget; |
|
325 | + } |
|
326 | 326 | |
327 | - if (is_null($label)) { |
|
328 | - $label = $field->getDescription(); |
|
329 | - } |
|
327 | + if (is_null($label)) { |
|
328 | + $label = $field->getDescription(); |
|
329 | + } |
|
330 | 330 | |
331 | - $widget = app_OrmWidget($field); |
|
331 | + $widget = app_OrmWidget($field); |
|
332 | 332 | |
333 | - return app_LabelledWidget($label, $widget); |
|
333 | + return app_LabelledWidget($label, $widget); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | |
@@ -346,16 +346,16 @@ discard block |
||
346 | 346 | */ |
347 | 347 | function app_dateTime(ORM_Field $field, $value) { |
348 | 348 | |
349 | - $W = bab_functionality::get('Widgets'); |
|
350 | - $name = $field->getName(); |
|
351 | - $label = $W->Label($field->getDescription()); |
|
349 | + $W = bab_functionality::get('Widgets'); |
|
350 | + $name = $field->getName(); |
|
351 | + $label = $W->Label($field->getDescription()); |
|
352 | 352 | |
353 | - $frame = app_dateTimeField($name, $label, $value); |
|
353 | + $frame = app_dateTimeField($name, $label, $value); |
|
354 | 354 | |
355 | - return $W->VBoxItems( |
|
356 | - $label, |
|
357 | - $frame |
|
358 | - ); |
|
355 | + return $W->VBoxItems( |
|
356 | + $label, |
|
357 | + $frame |
|
358 | + ); |
|
359 | 359 | |
360 | 360 | } |
361 | 361 | |
@@ -369,24 +369,24 @@ discard block |
||
369 | 369 | */ |
370 | 370 | function app_dateTimeField($fieldName, Widget_Label $label, $value = null) |
371 | 371 | { |
372 | - $W = bab_functionality::get('Widgets'); |
|
372 | + $W = bab_functionality::get('Widgets'); |
|
373 | 373 | |
374 | - $datepart = $W->DatePicker()->setAssociatedLabel($label)->setName('date'); |
|
375 | - $timepart = $W->TimePicker()->setName('time'); |
|
374 | + $datepart = $W->DatePicker()->setAssociatedLabel($label)->setName('date'); |
|
375 | + $timepart = $W->TimePicker()->setName('time'); |
|
376 | 376 | |
377 | - if (isset($value)) { |
|
377 | + if (isset($value)) { |
|
378 | 378 | |
379 | - $value = explode(' ', $value); |
|
379 | + $value = explode(' ', $value); |
|
380 | 380 | |
381 | - $datepart->setValue($value[0]); |
|
382 | - $timepart->setValue($value[1]); |
|
383 | - } |
|
381 | + $datepart->setValue($value[0]); |
|
382 | + $timepart->setValue($value[1]); |
|
383 | + } |
|
384 | 384 | |
385 | - $datetime = $W->Frame(null, $W->HBoxLayout())->setName($fieldName) |
|
386 | - ->addItem($datepart) |
|
387 | - ->addItem($timepart); |
|
385 | + $datetime = $W->Frame(null, $W->HBoxLayout())->setName($fieldName) |
|
386 | + ->addItem($datepart) |
|
387 | + ->addItem($timepart); |
|
388 | 388 | |
389 | - return $datetime; |
|
389 | + return $datetime; |
|
390 | 390 | } |
391 | 391 | |
392 | 392 |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | if (empty($description)) { |
48 | 48 | $description = $field->getName(); |
49 | 49 | } |
50 | - $fieldLabel = $W->Label($description . ':'); |
|
50 | + $fieldLabel = $W->Label($description.':'); |
|
51 | 51 | |
52 | 52 | if ($field instanceof ORM_DateField) { |
53 | 53 | $widget = $W->DatePicker(); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | if (empty($description)) { |
104 | 104 | $description = $field->getName(); |
105 | 105 | } |
106 | - $fieldLabel = $W->Label($description . ':'); |
|
106 | + $fieldLabel = $W->Label($description.':'); |
|
107 | 107 | |
108 | 108 | if ($field instanceof ORM_DateField) { |
109 | 109 | $widget = $W->PeriodPicker(); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | $nbOptions = 0; |
207 | 207 | foreach ($iterator as $record) { |
208 | 208 | if (isset($record->code)) { |
209 | - $optionText = $record->code . ' - ' . $record->$fieldName; |
|
209 | + $optionText = $record->code.' - '.$record->$fieldName; |
|
210 | 210 | } else { |
211 | 211 | $optionText = $record->$fieldName; |
212 | 212 | } |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | * @copyright Copyright (c) 2009 by CANTICO ({@link http://www.cantico.fr}) |
22 | 22 | */ |
23 | 23 | |
24 | -define('APP_PHP_PATH', dirname(__FILE__) . '/'); |
|
25 | -define('APP_SET_PATH', dirname(__FILE__) . '/'); |
|
26 | -define('APP_UI_PATH', dirname(__FILE__) . '/ui/'); |
|
24 | +define('APP_PHP_PATH', dirname(__FILE__).'/'); |
|
25 | +define('APP_SET_PATH', dirname(__FILE__).'/'); |
|
26 | +define('APP_UI_PATH', dirname(__FILE__).'/ui/'); |
|
27 | 27 | |
28 | -require_once APP_PHP_PATH . 'base.class.php'; |
|
29 | -require_once APP_UI_PATH . 'base.ui.php'; |
|
28 | +require_once APP_PHP_PATH.'base.class.php'; |
|
29 | +require_once APP_UI_PATH.'base.ui.php'; |
|
30 | 30 | |
31 | 31 | |
32 | 32 | if (!class_exists('Widget_Action')) { |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | if (null === $url) { |
121 | 121 | $script = '<script type="text/javascript">'; |
122 | 122 | if (isset($message)) { |
123 | - $script .= 'alert("' . bab_toHtml($message, BAB_HTML_JS) . '");'; |
|
123 | + $script .= 'alert("'.bab_toHtml($message, BAB_HTML_JS).'");'; |
|
124 | 124 | } |
125 | 125 | $script .= 'history.back();'; |
126 | 126 | $script .= '</script>'; |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $url = $url->url(); |
133 | 133 | } |
134 | 134 | if (!empty($babBody->msgerror)) { |
135 | - $url .= '&msgerror=' . urlencode($babBody->msgerror); |
|
135 | + $url .= '&msgerror='.urlencode($babBody->msgerror); |
|
136 | 136 | } |
137 | 137 | if (isset($message)) { |
138 | 138 | $lines = explode("\n", $message); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
144 | - header('Location: ' . $url); |
|
144 | + header('Location: '.$url); |
|
145 | 145 | die; |
146 | 146 | } |
147 | 147 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | function app_fileUploadError($error) |
175 | 175 | { |
176 | - switch($error) { |
|
176 | + switch ($error) { |
|
177 | 177 | case UPLOAD_ERR_OK: |
178 | 178 | return null; |
179 | 179 |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | public function __construct(Func_App $app, $id = null, Widget_Layout $layout = null) |
102 | 102 | { |
103 | 103 | parent::__construct($app); |
104 | - // We simulate inheritance from Widget_VBoxLayout. |
|
104 | + // We simulate inheritance from Widget_VBoxLayout. |
|
105 | 105 | $W = $this->widgets = bab_Widgets(); |
106 | 106 | |
107 | 107 | |
@@ -305,9 +305,9 @@ discard block |
||
305 | 305 | $cancelLabel = isset($this->cancelLabel) ? $this->cancelLabel : $App->translate('Cancel'); |
306 | 306 | $this->addButton( |
307 | 307 | $W->SubmitButton(/*'cancel'*/) |
308 | - ->addClass('widget-close-dialog') |
|
308 | + ->addClass('widget-close-dialog') |
|
309 | 309 | ->setAction($this->cancelAction) |
310 | - ->setLabel($cancelLabel) |
|
310 | + ->setLabel($cancelLabel) |
|
311 | 311 | ); |
312 | 312 | } |
313 | 313 | |
@@ -1098,21 +1098,21 @@ discard block |
||
1098 | 1098 | |
1099 | 1099 | |
1100 | 1100 | |
1101 | - protected function addCustomFields(app_RecordSet $recordSet) |
|
1102 | - { |
|
1103 | - $customFields = $recordSet->getCustomFields(); |
|
1101 | + protected function addCustomFields(app_RecordSet $recordSet) |
|
1102 | + { |
|
1103 | + $customFields = $recordSet->getCustomFields(); |
|
1104 | 1104 | |
1105 | 1105 | foreach ($customFields as $customField) { |
1106 | 1106 | $fieldname = $customField->fieldname; |
1107 | 1107 | $this->addColumn( |
1108 | 1108 | widget_TableModelViewColumn($recordSet->$fieldname, $customField->name) |
1109 | - ->setSortable(true) |
|
1110 | - ->setExportable(true) |
|
1111 | - ->setSearchable($customField->searchable) |
|
1112 | - ->setVisible($customField->visible) |
|
1109 | + ->setSortable(true) |
|
1110 | + ->setExportable(true) |
|
1111 | + ->setSearchable($customField->searchable) |
|
1112 | + ->setVisible($customField->visible) |
|
1113 | 1113 | ); |
1114 | 1114 | } |
1115 | - } |
|
1115 | + } |
|
1116 | 1116 | |
1117 | 1117 | |
1118 | 1118 | /** |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | continue; |
677 | 677 | } |
678 | 678 | |
679 | - list(, , $nbCol) = explode('-', $customSection->sizePolicy); |
|
679 | + list(,, $nbCol) = explode('-', $customSection->sizePolicy); |
|
680 | 680 | |
681 | 681 | if ($currentColumn + $nbCol > 12) { |
682 | 682 | $this->addItem($row); |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | $parameters = $displayField['parameters']; |
705 | 705 | $classname = isset($parameters['classname']) ? $parameters['classname'] : ''; |
706 | 706 | $label = isset($parameters['label']) && $parameters['label'] !== '__' ? $parameters['label'] : ''; |
707 | - $displayFieldMethod = '_' . $displayFieldName; |
|
707 | + $displayFieldMethod = '_'.$displayFieldName; |
|
708 | 708 | |
709 | 709 | if (method_exists($this, $displayFieldMethod)) { |
710 | 710 | $widget = $this->$displayFieldMethod($customSection); |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | } |
736 | 736 | } |
737 | 737 | |
738 | - if ($currentColumn + $nbCol> 0) { |
|
738 | + if ($currentColumn + $nbCol > 0) { |
|
739 | 739 | $this->addItem($row); |
740 | 740 | } |
741 | 741 | } |
@@ -944,7 +944,7 @@ discard block |
||
944 | 944 | $row = $W->Items()->setSizePolicy('row'); |
945 | 945 | foreach ($customSections as $customSection) { |
946 | 946 | |
947 | - list(, , $nbCol) = explode('-', $customSection->sizePolicy); |
|
947 | + list(,, $nbCol) = explode('-', $customSection->sizePolicy); |
|
948 | 948 | |
949 | 949 | if ($currentColumn + $nbCol > 12) { |
950 | 950 | $this->addItem($row); |
@@ -971,7 +971,7 @@ discard block |
||
971 | 971 | $parameters = $displayField['parameters']; |
972 | 972 | $classname = isset($parameters['classname']) ? $parameters['classname'] : ''; |
973 | 973 | $label = isset($parameters['label']) ? $parameters['label'] : ''; |
974 | - $displayFieldMethod = '_' . $displayFieldName; |
|
974 | + $displayFieldMethod = '_'.$displayFieldName; |
|
975 | 975 | |
976 | 976 | if (method_exists($this, $displayFieldMethod)) { |
977 | 977 | $value = $this->$displayFieldMethod($customSection); |
@@ -996,7 +996,7 @@ discard block |
||
996 | 996 | } |
997 | 997 | } |
998 | 998 | |
999 | - if ($currentColumn + $nbCol> 0) { |
|
999 | + if ($currentColumn + $nbCol > 0) { |
|
1000 | 1000 | $this->addItem($row); |
1001 | 1001 | } |
1002 | 1002 | } |
@@ -1018,14 +1018,14 @@ discard block |
||
1018 | 1018 | |
1019 | 1019 | $fileSize = filesize($file->getFilePath()->tostring()); |
1020 | 1020 | if ($fileSize > 1024 * 1024) { |
1021 | - $fileSizeText = round($fileSize / (1024 * 1024), 1) . ' ' . $App->translate('MB'); |
|
1021 | + $fileSizeText = round($fileSize / (1024 * 1024), 1).' '.$App->translate('MB'); |
|
1022 | 1022 | } elseif ($fileSize > 1024) { |
1023 | - $fileSizeText = round($fileSize / 1024) . ' ' . $App->translate('KB'); |
|
1023 | + $fileSizeText = round($fileSize / 1024).' '.$App->translate('KB'); |
|
1024 | 1024 | } else { |
1025 | - $fileSizeText = $fileSize . ' ' . $App->translate('Bytes'); |
|
1025 | + $fileSizeText = $fileSize.' '.$App->translate('Bytes'); |
|
1026 | 1026 | } |
1027 | 1027 | |
1028 | - $fileIcon = $W->FileIcon($file->toString() . "\n" . $fileSizeText, $file->getFilePath()) |
|
1028 | + $fileIcon = $W->FileIcon($file->toString()."\n".$fileSizeText, $file->getFilePath()) |
|
1029 | 1029 | ->setThumbnailSize($width, $height); |
1030 | 1030 | |
1031 | 1031 | return $fileIcon; |
@@ -1088,7 +1088,7 @@ discard block |
||
1088 | 1088 | // we try to select one according to the classname prefix. |
1089 | 1089 | list($prefix) = explode('_', get_class($this)); |
1090 | 1090 | $functionalityName = ucwords($prefix); |
1091 | - $this->app = @bab_functionality::get('App/' . $functionalityName); |
|
1091 | + $this->app = @bab_functionality::get('App/'.$functionalityName); |
|
1092 | 1092 | if (!$this->app) { |
1093 | 1093 | $this->app = @bab_functionality::get('App'); |
1094 | 1094 | } |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | $this->setCurrentPage(isset($filter['pageNumber']) ? $filter['pageNumber'] : $pageNumber); |
1150 | 1150 | |
1151 | 1151 | if (isset($name)) { |
1152 | - $this->sortParameterName = $name . '[filter][sort]'; |
|
1152 | + $this->sortParameterName = $name.'[filter][sort]'; |
|
1153 | 1153 | } else { |
1154 | 1154 | $this->sortParameterName = 'filter[sort]'; |
1155 | 1155 | } |
@@ -1301,11 +1301,11 @@ discard block |
||
1301 | 1301 | |
1302 | 1302 | foreach ($columns as $fieldName => $column) { |
1303 | 1303 | $field = $column->getField(); |
1304 | - if (! $column->isSearchable()) { |
|
1304 | + if (!$column->isSearchable()) { |
|
1305 | 1305 | continue; |
1306 | 1306 | } |
1307 | 1307 | |
1308 | - if (! ($field instanceof ORM_Field)) { |
|
1308 | + if (!($field instanceof ORM_Field)) { |
|
1309 | 1309 | $field = null; |
1310 | 1310 | } |
1311 | 1311 | |
@@ -1322,7 +1322,7 @@ discard block |
||
1322 | 1322 | |
1323 | 1323 | $formItem = $this->handleFilterLabel($label, $input); |
1324 | 1324 | $formItem->setSizePolicy('col-lg-2 col-md-3 col-sm-6 col-xs-12'); |
1325 | - $formItem->addClass('field_' . $fieldName); |
|
1325 | + $formItem->addClass('field_'.$fieldName); |
|
1326 | 1326 | |
1327 | 1327 | $mainSearch = (method_exists($column, 'isMainSearch') && $column->isMainSearch()); |
1328 | 1328 | |
@@ -1335,7 +1335,7 @@ discard block |
||
1335 | 1335 | } |
1336 | 1336 | |
1337 | 1337 | |
1338 | - if (! $this->submit) { |
|
1338 | + if (!$this->submit) { |
|
1339 | 1339 | $this->submit = $W->SubmitButton(); |
1340 | 1340 | $this->submit->setLabel(widget_translate('Filter')); |
1341 | 1341 | } |
@@ -1408,7 +1408,7 @@ discard block |
||
1408 | 1408 | // $this->setCurrentPage(isset($filter['pageNumber']) ? $filter['pageNumber'] : $pageNumber); |
1409 | 1409 | |
1410 | 1410 | if (isset($name)) { |
1411 | - $this->sortParameterName = $name . '[filter][sort]'; |
|
1411 | + $this->sortParameterName = $name.'[filter][sort]'; |
|
1412 | 1412 | } else { |
1413 | 1413 | $this->sortParameterName = 'filter[sort]'; |
1414 | 1414 | } |
@@ -1473,7 +1473,7 @@ discard block |
||
1473 | 1473 | |
1474 | 1474 | $tableview->setCurrentPage(isset($filterValues['pageNumber']) ? $filterValues['pageNumber'] : 0); |
1475 | 1475 | |
1476 | - $tableview->sortParameterName = $name . '[filter][sort]'; |
|
1476 | + $tableview->sortParameterName = $name.'[filter][sort]'; |
|
1477 | 1477 | |
1478 | 1478 | if (isset($filterValues['sort'])) { |
1479 | 1479 | $tableview->setSortField($filterValues['sort']); |
@@ -906,7 +906,7 @@ |
||
906 | 906 | $W->SubmitButton() |
907 | 907 | ->setAjaxAction($confirmedAction) |
908 | 908 | ->setLabel($App->translate('Delete')) |
909 | - ); |
|
909 | + ); |
|
910 | 910 | $form->addButton($W->SubmitButton()->setLabel($App->translate('Cancel'))->addClass('widget-close-dialog')); |
911 | 911 | $page->addItem($form); |
912 | 912 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @copyright Copyright (c) 2006 by CANTICO ({@link http://www.cantico.fr}) |
22 | 22 | */ |
23 | 23 | |
24 | -require_once dirname(__FILE__) . '/controller.class.php'; |
|
24 | +require_once dirname(__FILE__).'/controller.class.php'; |
|
25 | 25 | |
26 | 26 | |
27 | 27 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | { |
53 | 53 | $App = $this->App(); |
54 | 54 | $recordClassname = $this->getRecordClassName(); |
55 | - $recordSetClassname = $recordClassname . 'Set'; |
|
55 | + $recordSetClassname = $recordClassname.'Set'; |
|
56 | 56 | |
57 | 57 | $recordSet = $App->$recordSetClassname(); |
58 | 58 | return $recordSet; |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | $recordClassname = $this->getRecordClassName(); |
105 | 105 | |
106 | - $viewClassname = $recordClassname . 'TableView'; |
|
106 | + $viewClassname = $recordClassname.'TableView'; |
|
107 | 107 | if (method_exists($Ui, $viewClassname)) { |
108 | 108 | $types['table'] = array( |
109 | 109 | 'classname' => $viewClassname, |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | ); |
113 | 113 | } |
114 | 114 | |
115 | - $viewClassname = $recordClassname . 'CardsView'; |
|
115 | + $viewClassname = $recordClassname.'CardsView'; |
|
116 | 116 | if (method_exists($Ui, $viewClassname)) { |
117 | 117 | $types['cards'] = array( |
118 | 118 | 'classname' => $viewClassname, |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | ); |
122 | 122 | } |
123 | 123 | |
124 | - $viewClassname = $recordClassname . 'MapView'; |
|
124 | + $viewClassname = $recordClassname.'MapView'; |
|
125 | 125 | if (method_exists($Ui, $viewClassname)) { |
126 | 126 | $types['map'] = array( |
127 | 127 | 'classname' => $viewClassname, |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | public function getModelViewDefaultId($itemId = null) |
143 | 143 | { |
144 | 144 | if (!isset($itemId)) { |
145 | - $itemId = $this->getClass() . '.modelView'; |
|
145 | + $itemId = $this->getClass().'.modelView'; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | return $itemId; |
@@ -176,16 +176,16 @@ discard block |
||
176 | 176 | |
177 | 177 | switch ($type) { |
178 | 178 | case 'cards': |
179 | - $tableviewClassname = $recordClassname . 'CardsView'; |
|
179 | + $tableviewClassname = $recordClassname.'CardsView'; |
|
180 | 180 | break; |
181 | 181 | |
182 | 182 | case 'map': |
183 | - $tableviewClassname = $recordClassname . 'MapView'; |
|
183 | + $tableviewClassname = $recordClassname.'MapView'; |
|
184 | 184 | break; |
185 | 185 | |
186 | 186 | case 'table': |
187 | 187 | default: |
188 | - $tableviewClassname = $recordClassname . 'TableView'; |
|
188 | + $tableviewClassname = $recordClassname.'TableView'; |
|
189 | 189 | break; |
190 | 190 | } |
191 | 191 | |
@@ -251,10 +251,10 @@ discard block |
||
251 | 251 | $Ui = $App->Ui(); |
252 | 252 | |
253 | 253 | $recordClassname = $this->getRecordClassName(); |
254 | - $editorClassname = $recordClassname . 'Editor'; |
|
254 | + $editorClassname = $recordClassname.'Editor'; |
|
255 | 255 | $editor = $Ui->$editorClassname(); |
256 | 256 | if (!isset($itemId)) { |
257 | - $itemId = $this->getClass() . '.' . __FUNCTION__; |
|
257 | + $itemId = $this->getClass().'.'.__FUNCTION__; |
|
258 | 258 | } |
259 | 259 | $editor->setId($itemId); |
260 | 260 | $editor->setHiddenValue('tg', $App->controllerTg); |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | $W->Link( |
300 | 300 | '', |
301 | 301 | $proxy->setFilteredViewType($tableView->getId(), $viewTypeId) |
302 | - )->addClass('icon', $viewType['icon'] . ($filteredViewType=== $viewTypeId ? ' active' : '')) |
|
302 | + )->addClass('icon', $viewType['icon'].($filteredViewType === $viewTypeId ? ' active' : '')) |
|
303 | 303 | // ->setSizePolicy('btn btn-xs btn-default ' . ($filteredViewType === $viewTypeId ? 'active' : '')) |
304 | 304 | ->setTitle($viewType['label']) |
305 | 305 | ->setAjaxAction() |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | |
344 | 344 | $filterVisibility = $this->getFilterVisibility($itemId); |
345 | 345 | $filterVisibility = !$filterVisibility; |
346 | - $W->setUserConfiguration($itemId . '/filterVisibility', $filterVisibility); |
|
346 | + $W->setUserConfiguration($itemId.'/filterVisibility', $filterVisibility); |
|
347 | 347 | |
348 | 348 | return true; |
349 | 349 | } |
@@ -356,10 +356,10 @@ discard block |
||
356 | 356 | protected function getFilterVisibility($itemId) |
357 | 357 | { |
358 | 358 | $W = bab_Widgets(); |
359 | - $filterVisibility = $W->getUserConfiguration($itemId . '/filterVisibility'); |
|
359 | + $filterVisibility = $W->getUserConfiguration($itemId.'/filterVisibility'); |
|
360 | 360 | if (!isset($filterVisibility)) { |
361 | 361 | $filterVisibility = false; |
362 | - $W->setUserConfiguration($itemId . '/filterVisibility', $filterVisibility); |
|
362 | + $W->setUserConfiguration($itemId.'/filterVisibility', $filterVisibility); |
|
363 | 363 | } |
364 | 364 | return $filterVisibility; |
365 | 365 | } |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | protected function getFilteredViewType($itemId) |
374 | 374 | { |
375 | 375 | $W = bab_Widgets(); |
376 | - $type = $W->getUserConfiguration($itemId . '/viewType'); |
|
376 | + $type = $W->getUserConfiguration($itemId.'/viewType'); |
|
377 | 377 | if (!isset($type)) { |
378 | 378 | $type = 'table'; |
379 | 379 | } |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | public function setFilteredViewType($itemId, $type = null) |
390 | 390 | { |
391 | 391 | $W = bab_Widgets(); |
392 | - $W->setUserConfiguration($itemId . '/viewType', $type); |
|
392 | + $W->setUserConfiguration($itemId.'/viewType', $type); |
|
393 | 393 | |
394 | 394 | return true; |
395 | 395 | } |
@@ -535,14 +535,14 @@ discard block |
||
535 | 535 | |
536 | 536 | switch ($format) { |
537 | 537 | case 'xlsx': |
538 | - $tableview->downloadXlsx($filename . '.xlsx'); |
|
538 | + $tableview->downloadXlsx($filename.'.xlsx'); |
|
539 | 539 | case 'xls': |
540 | - $tableview->downloadExcel($filename . '.xls'); |
|
540 | + $tableview->downloadExcel($filename.'.xls'); |
|
541 | 541 | case 'ssv': |
542 | - $tableview->downloadCsv($filename . '.csv', ';', $inline, 'Windows-1252'); |
|
542 | + $tableview->downloadCsv($filename.'.csv', ';', $inline, 'Windows-1252'); |
|
543 | 543 | case 'csv': |
544 | 544 | default: |
545 | - $tableview->downloadCsv($filename . '.csv', ',', $inline, bab_charset::getIso()); |
|
545 | + $tableview->downloadCsv($filename.'.csv', ',', $inline, bab_charset::getIso()); |
|
546 | 546 | } |
547 | 547 | } |
548 | 548 | |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | $Ui = $App->Ui(); |
571 | 571 | |
572 | 572 | $recordClassname = $this->getRecordClassName(); |
573 | - $fullFrameClassname = $recordClassname . 'FullFrame'; |
|
573 | + $fullFrameClassname = $recordClassname.'FullFrame'; |
|
574 | 574 | $fullFrame = $Ui->$fullFrameClassname($record, $view); |
575 | 575 | |
576 | 576 | |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | |
735 | 735 | $recordTitle = $record->getRecordTitle(); |
736 | 736 | |
737 | - $message = sprintf($App->translate('%s has been deleted'), $App->translate($recordSet->getDescription()) . ' "' . $recordTitle . '"'); |
|
737 | + $message = sprintf($App->translate('%s has been deleted'), $App->translate($recordSet->getDescription()).' "'.$recordTitle.'"'); |
|
738 | 738 | return $message; |
739 | 739 | } |
740 | 740 | |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | |
891 | 891 | $recordTitle = $record->getRecordTitle(); |
892 | 892 | |
893 | - $subTitle = $App->translate($recordSet->getDescription()) . ' "' . $recordTitle . '"'; |
|
893 | + $subTitle = $App->translate($recordSet->getDescription()).' "'.$recordTitle.'"'; |
|
894 | 894 | $form->addItem($W->Title($subTitle, 5)); |
895 | 895 | |
896 | 896 | $form->addItem($W->Title($App->translate('Confirm delete?'), 6)); |