@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | use Capwelton\LibOrm\MySql\ORMMySqlBackend; |
| 26 | 26 | |
| 27 | 27 | |
| 28 | -require_once dirname(__FILE__). '/functions.php'; |
|
| 28 | +require_once dirname(__FILE__).'/functions.php'; |
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | function LibApp_upgrade($sVersionBase, $sVersionIni) |
@@ -81,13 +81,13 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | $babBody = bab_getBody(); |
| 83 | 83 | $addon = bab_getAddonInfosInstance('libapp'); |
| 84 | - $babBody->addStyleSheet($addon->getStylePath() . '/styles.css'); |
|
| 85 | - $babBody->addJavascriptFile($addon->getTemplatePath() . 'libapp.js'); |
|
| 84 | + $babBody->addStyleSheet($addon->getStylePath().'/styles.css'); |
|
| 85 | + $babBody->addJavascriptFile($addon->getTemplatePath().'libapp.js'); |
|
| 86 | 86 | |
| 87 | 87 | $App = app_App(); |
| 88 | - if($App->isSSEEnabled()){ |
|
| 89 | - $babBody->addJavascriptFile($addon->getTemplatePath() . 'notification.js'); |
|
| 90 | - if(bab_isUserLogged()){ |
|
| 88 | + if ($App->isSSEEnabled()) { |
|
| 89 | + $babBody->addJavascriptFile($addon->getTemplatePath().'notification.js'); |
|
| 90 | + if (bab_isUserLogged()) { |
|
| 91 | 91 | $babBody->babecho('<script>window.libapp={"sseServerUrl": "'.$App->Controller()->SSE()->server()->url().'"}</script>'); |
| 92 | 92 | $babBody->addJavascriptFile($addon->getTemplatePath().'sse.js'); |
| 93 | 93 | } |
@@ -113,8 +113,8 @@ discard block |
||
| 113 | 113 | $addonPhpPath = $addon->getPhpPath(); |
| 114 | 114 | |
| 115 | 115 | require_once $GLOBALS['babInstallPath'].'utilit/functionalityincl.php'; |
| 116 | - require_once dirname(__FILE__) . '/portletbackend.class.php'; |
|
| 116 | + require_once dirname(__FILE__).'/portletbackend.class.php'; |
|
| 117 | 117 | $functionalities = new bab_functionalities(); |
| 118 | - $functionalities->registerClass('Func_PortletBackend_App', $addonPhpPath . 'portletbackend.class.php'); |
|
| 118 | + $functionalities->registerClass('Func_PortletBackend_App', $addonPhpPath.'portletbackend.class.php'); |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | \ No newline at end of file |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | protected function logSave(AppTraceableRecord $record, $noTrace) |
| 135 | 135 | { |
| 136 | - if(! $this->isLoggable()){ |
|
| 136 | + if (!$this->isLoggable()) { |
|
| 137 | 137 | return; |
| 138 | 138 | } |
| 139 | 139 | $App = $this->App(); |
@@ -156,14 +156,14 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | protected function logDelete(ORMCriteria $criteria, $noTrace) |
| 158 | 158 | { |
| 159 | - if(! $this->isLoggable()){ |
|
| 159 | + if (!$this->isLoggable()) { |
|
| 160 | 160 | return; |
| 161 | 161 | } |
| 162 | 162 | $App = $this->App(); |
| 163 | 163 | $userId = bab_getUserId(); |
| 164 | 164 | $logSet = $App->LogSet(); |
| 165 | 165 | $deletedRecords = $this->select($criteria); |
| 166 | - foreach ($deletedRecords as $record){ |
|
| 166 | + foreach ($deletedRecords as $record) { |
|
| 167 | 167 | $log = $logSet->newRecord(); |
| 168 | 168 | $log->noTrace = $noTrace; |
| 169 | 169 | $log->objectClass = get_class($record); |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | public function select(ORMCriteria $criteria = null, $includeDeleted = false) |
| 191 | 191 | { |
| 192 | - if($includeDeleted){ |
|
| 192 | + if ($includeDeleted) { |
|
| 193 | 193 | $this->setDefaultCriteria(null); |
| 194 | 194 | } |
| 195 | 195 | return parent::select($criteria); |
@@ -232,25 +232,25 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | public function delete(ORMCriteria $criteria = null, $deletedStatus = AppTraceableRecord::DELETED_STATUS_DELETED) |
| 234 | 234 | { |
| 235 | - $definitive = ($deletedStatus === true) || ! $this->isTraceable(); |
|
| 235 | + $definitive = ($deletedStatus === true) || !$this->isTraceable(); |
|
| 236 | 236 | $this->logDelete($criteria, $definitive); |
| 237 | - if($definitive){ |
|
| 237 | + if ($definitive) { |
|
| 238 | 238 | return parent::delete($criteria); |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - require_once $GLOBALS['babInstallPath'] . '/utilit/dateTime.php'; |
|
| 241 | + require_once $GLOBALS['babInstallPath'].'/utilit/dateTime.php'; |
|
| 242 | 242 | $now = \BAB_DateTime::now()->getIsoDateTime(); |
| 243 | 243 | |
| 244 | 244 | $records = $this->select($criteria); |
| 245 | 245 | |
| 246 | - foreach ($records as $record){ |
|
| 246 | + foreach ($records as $record) { |
|
| 247 | 247 | /* @var $record AppTraceableRecord */ |
| 248 | 248 | // Could be optimized at ORM level |
| 249 | 249 | $record->deleted = $deletedStatus; |
| 250 | 250 | $record->deletedOn = $now; |
| 251 | 251 | $record->deletedBy = bab_getUserId(); |
| 252 | 252 | |
| 253 | - if(! parent::save($record)){ |
|
| 253 | + if (!parent::save($record)) { |
|
| 254 | 254 | return false; |
| 255 | 255 | } |
| 256 | 256 | } |
@@ -268,13 +268,13 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | public function save(ORMRecord $record, $noTrace = false) |
| 270 | 270 | { |
| 271 | - $noTrace = $noTrace || ! $this->isTraceable(); |
|
| 271 | + $noTrace = $noTrace || !$this->isTraceable(); |
|
| 272 | 272 | $this->logSave($record, $noTrace); |
| 273 | - if($noTrace){ |
|
| 273 | + if ($noTrace) { |
|
| 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 | |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | $set = $record->getParentSet(); |
| 283 | 283 | $primaryKey = $set->getPrimaryKey(); |
| 284 | 284 | |
| 285 | - if(empty($record->{$primaryKey})){ |
|
| 285 | + if (empty($record->{$primaryKey})) { |
|
| 286 | 286 | $record->initValue('createdBy', bab_getUserId()); |
| 287 | 287 | $record->initValue('createdOn', $now); |
| 288 | 288 | $record->initValue('uuid', $this->uuid()); |
@@ -313,21 +313,21 @@ discard block |
||
| 313 | 313 | */ |
| 314 | 314 | public function getRecordByUuid($uuid) |
| 315 | 315 | { |
| 316 | - if('' === (string) $uuid){ |
|
| 316 | + if ('' === (string) $uuid) { |
|
| 317 | 317 | return null; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | $record = $this->get($this->uuid->is($uuid)); |
| 321 | 321 | |
| 322 | - if(! isset($record)){ |
|
| 322 | + if (!isset($record)) { |
|
| 323 | 323 | return null; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - if(! ($record instanceof AppTraceableRecord)){ |
|
| 326 | + if (!($record instanceof AppTraceableRecord)) { |
|
| 327 | 327 | return null; |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - if($record->deleted){ |
|
| 330 | + if ($record->deleted) { |
|
| 331 | 331 | return null; |
| 332 | 332 | } |
| 333 | 333 | |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | */ |
| 344 | 344 | public function isOwn($userId = null) |
| 345 | 345 | { |
| 346 | - if(! isset($userId)){ |
|
| 346 | + if (!isset($userId)) { |
|
| 347 | 347 | $userId = bab_getUserId(); |
| 348 | 348 | } |
| 349 | 349 | return $this->createdBy->is($userId); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | $value = $this->oParentSet->getBackend()->getRecordValue($this, $sFieldName); |
| 60 | 60 | $field = $this->oParentSet->$sFieldName; |
| 61 | - if(! is_null($value) && $field instanceof ORMFkField){ |
|
| 61 | + if (!is_null($value) && $field instanceof ORMFkField) { |
|
| 62 | 62 | |
| 63 | 63 | $sClassName = $field->getForeignSetName(); |
| 64 | 64 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function App() |
| 95 | 95 | { |
| 96 | - if(! isset($this->app)){ |
|
| 96 | + if (!isset($this->app)) { |
|
| 97 | 97 | // If the app object was not specified (through the setApp() method), |
| 98 | 98 | // we set it as parent set's App. |
| 99 | 99 | $this->setApp($this->getParentSet() |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $App = $this->App(); |
| 115 | 115 | $rClass = new \ReflectionClass(get_class($this)); |
| 116 | 116 | $component = $App->getComponentByName($rClass->getShortName()); |
| 117 | - if(isset($component)){ |
|
| 117 | + if (isset($component)) { |
|
| 118 | 118 | return $component->getRecordClassName(); |
| 119 | 119 | // list(, $classname) = explode('_', $component->getRecordClassName()); |
| 120 | 120 | // return $classname; |
@@ -130,11 +130,11 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public function getRef() |
| 132 | 132 | { |
| 133 | - if(! isset($this->id)){ |
|
| 133 | + if (!isset($this->id)) { |
|
| 134 | 134 | throw new AppException('Trying to get the reference string of a record without an id.'); |
| 135 | 135 | } |
| 136 | 136 | $classname = $this->getClassName(); |
| 137 | - return $classname . ':' . $this->id; |
|
| 137 | + return $classname.':'.$this->id; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | { |
| 162 | 162 | $App = $this->App(); |
| 163 | 163 | |
| 164 | - if(! isset($deletedStatus)){ |
|
| 164 | + if (!isset($deletedStatus)) { |
|
| 165 | 165 | $deletedStatus = AppTraceableRecord::DELETED_STATUS_DELETED; |
| 166 | 166 | } |
| 167 | 167 | |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | // referenced elements. |
| 174 | 174 | $manyRelations = $set->getHasManyRelations(); |
| 175 | 175 | |
| 176 | - foreach ($manyRelations as $manyRelation){ |
|
| 176 | + foreach ($manyRelations as $manyRelation) { |
|
| 177 | 177 | /* @var $manyRelation ORMManyRelation */ |
| 178 | 178 | |
| 179 | 179 | $foreignSetClassName = $manyRelation->getForeignSetClassName(); |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | $foreignRecords = $foreignSet->select($foreignSet->$foreignSetFieldName->is($recordId)); |
| 189 | 189 | |
| 190 | - foreach ($foreignRecords as $foreignRecord){ |
|
| 190 | + foreach ($foreignRecords as $foreignRecord) { |
|
| 191 | 191 | $foreignRecord->$foreignSetFieldName = 0; |
| 192 | 192 | $foreignRecord->save(); |
| 193 | 193 | } |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | $foreignRecords = $foreignSet->select($foreignSet->$foreignSetFieldName->is($recordId)); |
| 200 | 200 | |
| 201 | - foreach ($foreignRecords as $foreignRecord){ |
|
| 201 | + foreach ($foreignRecords as $foreignRecord) { |
|
| 202 | 202 | $foreignRecord->delete(); |
| 203 | 203 | } |
| 204 | 204 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | // referenced elements. |
| 245 | 245 | $manyRelations = $set->getHasManyRelations(); |
| 246 | 246 | |
| 247 | - foreach ($manyRelations as $manyRelation){ |
|
| 247 | + foreach ($manyRelations as $manyRelation) { |
|
| 248 | 248 | /* @var $manyRelation ORMManyRelation */ |
| 249 | 249 | |
| 250 | 250 | $foreignSetClassName = $manyRelation->getForeignSetClassName(); |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | // $foreignSet = new $foreignSetClassName($App); |
| 255 | 255 | $foreignRecords = $foreignSet->select($foreignSet->$foreignSetFieldName->is($recordId)); |
| 256 | 256 | |
| 257 | - foreach ($foreignRecords as $foreignRecord){ |
|
| 257 | + foreach ($foreignRecords as $foreignRecord) { |
|
| 258 | 258 | $foreignRecord->$foreignSetFieldName = $id; |
| 259 | 259 | $foreignRecord->save(); |
| 260 | 260 | } |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | $links = $linkSet->select($linkSet->sourceClass->is($recordClassName) |
| 268 | 268 | ->_AND_($linkSet->sourceId->is($recordId))); |
| 269 | 269 | |
| 270 | - foreach ($links as $link){ |
|
| 270 | + foreach ($links as $link) { |
|
| 271 | 271 | $link->sourceId = $id; |
| 272 | 272 | $link->save(); |
| 273 | 273 | } |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | $links = $linkSet->select($linkSet->targetClass->is($recordClassName) |
| 276 | 276 | ->_AND_($linkSet->targetId->is($recordId))); |
| 277 | 277 | |
| 278 | - foreach ($links as $link){ |
|
| 278 | + foreach ($links as $link) { |
|
| 279 | 279 | $link->targetId = $id; |
| 280 | 280 | $link->save(); |
| 281 | 281 | } |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | $relatedRecords = array(); |
| 302 | 302 | |
| 303 | - foreach ($manyRelations as $manyRelation){ |
|
| 303 | + foreach ($manyRelations as $manyRelation) { |
|
| 304 | 304 | /* @var $manyRelation ORMManyRelation */ |
| 305 | 305 | |
| 306 | 306 | $foreignSetClassName = $manyRelation->getForeignSetClassName(); |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | // $foreignSet = new $foreignSetClassName($App); |
| 312 | 312 | $foreignRecords = $foreignSet->select($foreignSet->$foreignSetFieldName->is($recordId)); |
| 313 | 313 | |
| 314 | - if($foreignRecords->count() > 0){ |
|
| 314 | + if ($foreignRecords->count() > 0) { |
|
| 315 | 315 | $relatedRecords[$foreignSetClassName] = $foreignRecords; |
| 316 | 316 | } |
| 317 | 317 | } |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | { |
| 329 | 329 | $path = $this->App()->uploadPath(); |
| 330 | 330 | |
| 331 | - if(null === $path){ |
|
| 331 | + if (null === $path) { |
|
| 332 | 332 | throw new \Exception('Missing upload path information'); |
| 333 | 333 | return null; |
| 334 | 334 | } |
@@ -351,11 +351,11 @@ discard block |
||
| 351 | 351 | ->_AND_($linkSet->sourceId->is($source->id)) |
| 352 | 352 | ->_AND_($linkSet->targetClass->is($this->getClassName())) |
| 353 | 353 | ->_AND_($linkSet->targetId->is($this->id)); |
| 354 | - if(isset($linkType)){ |
|
| 355 | - if(is_array($linkType)){ |
|
| 354 | + if (isset($linkType)) { |
|
| 355 | + if (is_array($linkType)) { |
|
| 356 | 356 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 357 | 357 | } |
| 358 | - else{ |
|
| 358 | + else { |
|
| 359 | 359 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 360 | 360 | } |
| 361 | 361 | } |
@@ -379,11 +379,11 @@ discard block |
||
| 379 | 379 | |
| 380 | 380 | $criteria = $linkSet->all($linkSet->targetClass->is($target->getClassName()), $linkSet->targetId->is($target->id), $linkSet->sourceClass->is($this->getClassName()), $linkSet->sourceId->is($this->id)); |
| 381 | 381 | |
| 382 | - if(isset($linkType)){ |
|
| 383 | - if(is_array($linkType)){ |
|
| 382 | + if (isset($linkType)) { |
|
| 383 | + if (is_array($linkType)) { |
|
| 384 | 384 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 385 | 385 | } |
| 386 | - else{ |
|
| 386 | + else { |
|
| 387 | 387 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 388 | 388 | } |
| 389 | 389 | } |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | */ |
| 446 | 446 | protected function importProperty($name, $value) |
| 447 | 447 | { |
| 448 | - if(((string) $this->$name) !== ((string) $value)){ |
|
| 448 | + if (((string) $this->$name) !== ((string) $value)) { |
|
| 449 | 449 | $this->$name = $value; |
| 450 | 450 | return 1; |
| 451 | 451 | } |
@@ -465,13 +465,13 @@ discard block |
||
| 465 | 465 | */ |
| 466 | 466 | protected function importDate($name, $value) |
| 467 | 467 | { |
| 468 | - if(preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2}/', $value)){ |
|
| 468 | + if (preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2}/', $value)) { |
|
| 469 | 469 | return $this->importProperty($name, $value); |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | // try in DD/MM/YYYY format |
| 473 | 473 | |
| 474 | - if(preg_match('/(?P<day>[0-9]+)\/(?P<month>[0-9]+)\/(?P<year>[0-9]{2,4})/', $value, $matches)){ |
|
| 474 | + if (preg_match('/(?P<day>[0-9]+)\/(?P<month>[0-9]+)\/(?P<year>[0-9]{2,4})/', $value, $matches)) { |
|
| 475 | 475 | |
| 476 | 476 | $value = sprintf('%04d-%02d-%02d', (int) $matches['year'], (int) $matches['month'], (int) $matches['day']); |
| 477 | 477 | |
@@ -491,11 +491,11 @@ discard block |
||
| 491 | 491 | $customContainers->groupBy($customContainerSet->view); |
| 492 | 492 | |
| 493 | 493 | $views = array(); |
| 494 | - foreach ($customContainers as $customContainer){ |
|
| 494 | + foreach ($customContainers as $customContainer) { |
|
| 495 | 495 | $views[] = $customContainer->view; |
| 496 | 496 | } |
| 497 | 497 | |
| 498 | - if(empty($views)){ |
|
| 498 | + if (empty($views)) { |
|
| 499 | 499 | $views[] = ''; |
| 500 | 500 | } |
| 501 | 501 | |
@@ -579,9 +579,9 @@ discard block |
||
| 579 | 579 | */ |
| 580 | 580 | public function requireReadable($message = null) |
| 581 | 581 | { |
| 582 | - if(! $this->isReadable()){ |
|
| 582 | + if (!$this->isReadable()) { |
|
| 583 | 583 | $App = $this->App(); |
| 584 | - if(! isset($message)){ |
|
| 584 | + if (!isset($message)) { |
|
| 585 | 585 | $message = $App->translate('Access denied'); |
| 586 | 586 | } |
| 587 | 587 | throw new AppAccessException($message); |
@@ -597,9 +597,9 @@ discard block |
||
| 597 | 597 | */ |
| 598 | 598 | public function requireUpdatable($message = null) |
| 599 | 599 | { |
| 600 | - if(! $this->isUpdatable()){ |
|
| 600 | + if (!$this->isUpdatable()) { |
|
| 601 | 601 | $App = $this->App(); |
| 602 | - if(! isset($message)){ |
|
| 602 | + if (!isset($message)) { |
|
| 603 | 603 | $message = $App->translate('Access denied'); |
| 604 | 604 | } |
| 605 | 605 | throw new AppAccessException($message); |
@@ -615,9 +615,9 @@ discard block |
||
| 615 | 615 | */ |
| 616 | 616 | public function requireDeletable($message = null) |
| 617 | 617 | { |
| 618 | - if(! $this->isDeletable()){ |
|
| 618 | + if (!$this->isDeletable()) { |
|
| 619 | 619 | $App = $this->App(); |
| 620 | - if(! isset($message)){ |
|
| 620 | + if (!isset($message)) { |
|
| 621 | 621 | $message = $App->translate('Access denied'); |
| 622 | 622 | } |
| 623 | 623 | throw new AppAccessException($message); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | break; |
| 69 | 69 | |
| 70 | 70 | default: |
| 71 | - $function = 'Capwelton\LibOrm\ORM_' . $this->fieldtype . 'Field'; |
|
| 71 | + $function = 'Capwelton\LibOrm\ORM_'.$this->fieldtype.'Field'; |
|
| 72 | 72 | $field = $function($this->fieldname); |
| 73 | 73 | break; |
| 74 | 74 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | $labelledItem = $W->LabelledWidget($this->name, $widget, null); |
| 154 | 154 | $labelledItem->setName($this->fieldname); |
| 155 | 155 | |
| 156 | - if(! empty($this->description)){ |
|
| 156 | + if (!empty($this->description)) { |
|
| 157 | 157 | $labelledItem->setDescription($this->description); |
| 158 | 158 | } |
| 159 | 159 | |
@@ -102,11 +102,11 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | protected function trimSetName($setName) |
| 104 | 104 | { |
| 105 | - if(strpos($setName, '_') === false){ |
|
| 105 | + if (strpos($setName, '_') === false) { |
|
| 106 | 106 | return $setName; |
| 107 | 107 | } |
| 108 | 108 | $pos = strrpos($setName, '\\'); |
| 109 | - if($pos === false){ |
|
| 109 | + if ($pos === false) { |
|
| 110 | 110 | return explode('_', $setName)[1]; |
| 111 | 111 | } |
| 112 | 112 | return substr($setName, $pos + 1); |
@@ -121,13 +121,13 @@ discard block |
||
| 121 | 121 | public function join($fkFieldName) |
| 122 | 122 | { |
| 123 | 123 | $fkField = $this->getField($fkFieldName); |
| 124 | - if(! ($fkField instanceof ORMFkField)){ |
|
| 124 | + if (!($fkField instanceof ORMFkField)) { |
|
| 125 | 125 | return $this; |
| 126 | 126 | } |
| 127 | 127 | $setName = $fkField->getForeignSetName(); |
| 128 | 128 | |
| 129 | - if(! $setName || 'Set' === $setName){ |
|
| 130 | - throw new \Exception('The set name is missing on foreign key field ' . $fkFieldName); |
|
| 129 | + if (!$setName || 'Set' === $setName) { |
|
| 130 | + throw new \Exception('The set name is missing on foreign key field '.$fkFieldName); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | $appSetName = $this->trimSetName($setName); |
@@ -165,22 +165,22 @@ discard block |
||
| 165 | 165 | { |
| 166 | 166 | $App = $this->App(); |
| 167 | 167 | |
| 168 | - if(null === $this->customFields){ |
|
| 168 | + if (null === $this->customFields) { |
|
| 169 | 169 | $this->customFields = array(); |
| 170 | 170 | |
| 171 | - if(isset($App->CustomField)){ |
|
| 171 | + if (isset($App->CustomField)) { |
|
| 172 | 172 | $customFieldSet = $App->CustomFieldSet(); |
| 173 | 173 | $object = mb_substr(get_class($this), mb_strlen($App->classPrefix), - mb_strlen('Set')); |
| 174 | - try{ |
|
| 174 | + try { |
|
| 175 | 175 | $customFields = $customFieldSet->select($customFieldSet->object->is($object)); |
| 176 | 176 | |
| 177 | - foreach ($customFields as $customfield){ |
|
| 177 | + foreach ($customFields as $customfield) { |
|
| 178 | 178 | $this->customFields[] = $customfield; |
| 179 | 179 | |
| 180 | 180 | /*@var $customfield AppCustomField */ |
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | - catch (ORMBackEndSelectException $e){ |
|
| 183 | + catch (ORMBackEndSelectException $e) { |
|
| 184 | 184 | // table does not exist, this error is thrown by the install program while creating the sets |
| 185 | 185 | } |
| 186 | 186 | } |
@@ -210,15 +210,15 @@ discard block |
||
| 210 | 210 | public function addCustomFields() |
| 211 | 211 | { |
| 212 | 212 | $customFields = $this->selectCustomFields(); |
| 213 | - foreach ($customFields as $customField){ |
|
| 213 | + foreach ($customFields as $customField) { |
|
| 214 | 214 | /*@var $customField AppCustomField */ |
| 215 | 215 | $description = $customField->name; |
| 216 | 216 | $ormField = $customField->getORMField()->setDescription($description); |
| 217 | - if($ormField instanceof ORMFkField){ |
|
| 217 | + if ($ormField instanceof ORMFkField) { |
|
| 218 | 218 | $this->hasOne($customField->fieldname, $ormField->getForeignSetName()) |
| 219 | 219 | ->setDescription($description); |
| 220 | 220 | } |
| 221 | - else{ |
|
| 221 | + else { |
|
| 222 | 222 | $this->addFields($ormField); |
| 223 | 223 | } |
| 224 | 224 | } |
@@ -247,12 +247,12 @@ discard block |
||
| 247 | 247 | public function request($mixedParam = null, $sPropertyName = null) |
| 248 | 248 | { |
| 249 | 249 | $record = $this->get($mixedParam, $sPropertyName); |
| 250 | - if(! isset($record)){ |
|
| 250 | + if (!isset($record)) { |
|
| 251 | 251 | // This will remove the default criteria for TraceableRecords and |
| 252 | 252 | // fetch even 'deleted' ones. |
| 253 | 253 | $this->setDefaultCriteria(null); |
| 254 | 254 | $record = $this->get($mixedParam, $sPropertyName); |
| 255 | - if(isset($record)){ |
|
| 255 | + if (isset($record)) { |
|
| 256 | 256 | throw new AppDeletedRecordException($record, $mixedParam); |
| 257 | 257 | } |
| 258 | 258 | throw new AppNotFoundException($this, $mixedParam); |
@@ -273,10 +273,10 @@ discard block |
||
| 273 | 273 | public function selectLinkedTo($source, $linkType = null) |
| 274 | 274 | { |
| 275 | 275 | $linkSet = $this->App()->LinkSet(); |
| 276 | - if(is_array($source) || ($source instanceof \Iterator)){ |
|
| 276 | + if (is_array($source) || ($source instanceof \Iterator)) { |
|
| 277 | 277 | return $linkSet->selectForSources($source, $this->getRecordClassName(), $linkType); |
| 278 | 278 | } |
| 279 | - else{ |
|
| 279 | + else { |
|
| 280 | 280 | return $linkSet->selectForSource($source, $this->getRecordClassName(), $linkType); |
| 281 | 281 | } |
| 282 | 282 | } |
@@ -294,10 +294,10 @@ discard block |
||
| 294 | 294 | public function selectLinkedFrom($target, $linkType = null) |
| 295 | 295 | { |
| 296 | 296 | $linkSet = $this->App()->LinkSet(); |
| 297 | - if(is_array($target) || ($target instanceof \Iterator)){ |
|
| 297 | + if (is_array($target) || ($target instanceof \Iterator)) { |
|
| 298 | 298 | return $linkSet->selectForTargets($target, $this->getRecordClassName(), $linkType); |
| 299 | 299 | } |
| 300 | - else{ |
|
| 300 | + else { |
|
| 301 | 301 | return $linkSet->selectForTarget($target, $this->getRecordClassName(), $linkType); |
| 302 | 302 | } |
| 303 | 303 | } |
@@ -321,11 +321,11 @@ discard block |
||
| 321 | 321 | ->_AND_($linkSet->targetId->is($target->id)) |
| 322 | 322 | ->_AND_($linkSet->sourceClass->is($this->newRecord() |
| 323 | 323 | ->getClassName())); |
| 324 | - if(isset($linkType)){ |
|
| 325 | - if(is_array($linkType)){ |
|
| 324 | + if (isset($linkType)) { |
|
| 325 | + if (is_array($linkType)) { |
|
| 326 | 326 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 327 | 327 | } |
| 328 | - else{ |
|
| 328 | + else { |
|
| 329 | 329 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 330 | 330 | } |
| 331 | 331 | } |
@@ -353,11 +353,11 @@ discard block |
||
| 353 | 353 | ->_AND_($linkSet->sourceId->is($source->id)) |
| 354 | 354 | ->_AND_($linkSet->targetClass->is($this->newRecord() |
| 355 | 355 | ->getClassName())); |
| 356 | - if(isset($linkType)){ |
|
| 357 | - if(is_array($linkType)){ |
|
| 356 | + if (isset($linkType)) { |
|
| 357 | + if (is_array($linkType)) { |
|
| 358 | 358 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 359 | 359 | } |
| 360 | - else{ |
|
| 360 | + else { |
|
| 361 | 361 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 362 | 362 | } |
| 363 | 363 | } |
@@ -382,26 +382,26 @@ discard block |
||
| 382 | 382 | $linkSet->hasOne('targetId', $recordClassName); |
| 383 | 383 | |
| 384 | 384 | $sourceIdsByClasses = array(); |
| 385 | - foreach ($sources as $source){ |
|
| 385 | + foreach ($sources as $source) { |
|
| 386 | 386 | $sourceClass = $source->getClassName(); |
| 387 | - if(! isset($sourceIdsByClasses[$sourceClass])){ |
|
| 387 | + if (!isset($sourceIdsByClasses[$sourceClass])) { |
|
| 388 | 388 | $sourceIdsByClasses[$sourceClass] = array(); |
| 389 | 389 | } |
| 390 | 390 | $sourceIdsByClasses[$sourceClass][] = $source->id; |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | $sourcesCriteria = array(); |
| 394 | - foreach ($sourceIdsByClasses as $sourceClass => $sourceIds){ |
|
| 394 | + foreach ($sourceIdsByClasses as $sourceClass => $sourceIds) { |
|
| 395 | 395 | $sourcesCriteria[] = $linkSet->sourceClass->is($sourceClass)->_AND_($linkSet->sourceId->in($sourceIds)); |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | $criteria = $linkSet->all($linkSet->targetClass->is($this->newRecord() |
| 399 | 399 | ->getClassName()), $linkSet->any($sourcesCriteria)); |
| 400 | - if(isset($linkType)){ |
|
| 401 | - if(is_array($linkType)){ |
|
| 400 | + if (isset($linkType)) { |
|
| 401 | + if (is_array($linkType)) { |
|
| 402 | 402 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 403 | 403 | } |
| 404 | - else{ |
|
| 404 | + else { |
|
| 405 | 405 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 406 | 406 | } |
| 407 | 407 | } |
@@ -426,26 +426,26 @@ discard block |
||
| 426 | 426 | $linkSet->hasOne('sourceId', $recordClassName); |
| 427 | 427 | |
| 428 | 428 | $targetIdsByClasses = array(); |
| 429 | - foreach ($targets as $target){ |
|
| 429 | + foreach ($targets as $target) { |
|
| 430 | 430 | $targetClass = $target->getClassName(); |
| 431 | - if(! isset($targetIdsByClasses[$targetClass])){ |
|
| 431 | + if (!isset($targetIdsByClasses[$targetClass])) { |
|
| 432 | 432 | $targetIdsByClasses[$targetClass] = array(); |
| 433 | 433 | } |
| 434 | 434 | $targetIdsByClasses[$targetClass][] = $target->id; |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | $targetsCriteria = array(); |
| 438 | - foreach ($targetIdsByClasses as $targetClass => $targetIds){ |
|
| 438 | + foreach ($targetIdsByClasses as $targetClass => $targetIds) { |
|
| 439 | 439 | $targetsCriteria[] = $linkSet->targetClass->is($targetClass)->_AND_($linkSet->targetId->in($targetIds)); |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | $criteria = $linkSet->all($linkSet->sourceClass->is($this->newRecord() |
| 443 | 443 | ->getClassName()), $linkSet->any($targetsCriteria)); |
| 444 | - if(isset($linkType)){ |
|
| 445 | - if(is_array($linkType)){ |
|
| 444 | + if (isset($linkType)) { |
|
| 445 | + if (is_array($linkType)) { |
|
| 446 | 446 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 447 | 447 | } |
| 448 | - else{ |
|
| 448 | + else { |
|
| 449 | 449 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 450 | 450 | } |
| 451 | 451 | } |
@@ -560,19 +560,19 @@ discard block |
||
| 560 | 560 | $criteria = $linkSet->sourceClass->is($this->getRecordClassName()) |
| 561 | 561 | ->_AND_($linkSet->targetClass->is($tagClassName)); |
| 562 | 562 | |
| 563 | - if(is_array($tagLabels)){ |
|
| 563 | + if (is_array($tagLabels)) { |
|
| 564 | 564 | $criteria = $criteria->_AND_($linkSet->targetId->label->in($tagLabels)); |
| 565 | 565 | } |
| 566 | - else{ |
|
| 566 | + else { |
|
| 567 | 567 | $criteria = $criteria->_AND_($linkSet->targetId->label->is($tagLabels)); |
| 568 | 568 | } |
| 569 | - if(isset($linkType)){ |
|
| 569 | + if (isset($linkType)) { |
|
| 570 | 570 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 571 | 571 | } |
| 572 | 572 | $links = $linkSet->select($criteria); |
| 573 | 573 | |
| 574 | 574 | $ids = array(); |
| 575 | - foreach ($links as $link){ |
|
| 575 | + foreach ($links as $link) { |
|
| 576 | 576 | $ids[$link->sourceId] = $link->sourceId; |
| 577 | 577 | } |
| 578 | 578 | |
@@ -583,7 +583,7 @@ discard block |
||
| 583 | 583 | { |
| 584 | 584 | $fields = $this->getFields(); |
| 585 | 585 | $manyRelations = $this->getHasManyRelations(); |
| 586 | - foreach ($manyRelations as $fieldName => $manyRelation){ |
|
| 586 | + foreach ($manyRelations as $fieldName => $manyRelation) { |
|
| 587 | 587 | $fields[$fieldName] = $manyRelation; |
| 588 | 588 | } |
| 589 | 589 | return $fields; |
@@ -179,8 +179,7 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | /*@var $customfield AppCustomField */ |
| 181 | 181 | } |
| 182 | - } |
|
| 183 | - catch (ORMBackEndSelectException $e){ |
|
| 182 | + } catch (ORMBackEndSelectException $e){ |
|
| 184 | 183 | // table does not exist, this error is thrown by the install program while creating the sets |
| 185 | 184 | } |
| 186 | 185 | } |
@@ -217,8 +216,7 @@ discard block |
||
| 217 | 216 | if($ormField instanceof ORMFkField){ |
| 218 | 217 | $this->hasOne($customField->fieldname, $ormField->getForeignSetName()) |
| 219 | 218 | ->setDescription($description); |
| 220 | - } |
|
| 221 | - else{ |
|
| 219 | + } else{ |
|
| 222 | 220 | $this->addFields($ormField); |
| 223 | 221 | } |
| 224 | 222 | } |
@@ -275,8 +273,7 @@ discard block |
||
| 275 | 273 | $linkSet = $this->App()->LinkSet(); |
| 276 | 274 | if(is_array($source) || ($source instanceof \Iterator)){ |
| 277 | 275 | return $linkSet->selectForSources($source, $this->getRecordClassName(), $linkType); |
| 278 | - } |
|
| 279 | - else{ |
|
| 276 | + } else{ |
|
| 280 | 277 | return $linkSet->selectForSource($source, $this->getRecordClassName(), $linkType); |
| 281 | 278 | } |
| 282 | 279 | } |
@@ -296,8 +293,7 @@ discard block |
||
| 296 | 293 | $linkSet = $this->App()->LinkSet(); |
| 297 | 294 | if(is_array($target) || ($target instanceof \Iterator)){ |
| 298 | 295 | return $linkSet->selectForTargets($target, $this->getRecordClassName(), $linkType); |
| 299 | - } |
|
| 300 | - else{ |
|
| 296 | + } else{ |
|
| 301 | 297 | return $linkSet->selectForTarget($target, $this->getRecordClassName(), $linkType); |
| 302 | 298 | } |
| 303 | 299 | } |
@@ -324,8 +320,7 @@ discard block |
||
| 324 | 320 | if(isset($linkType)){ |
| 325 | 321 | if(is_array($linkType)){ |
| 326 | 322 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 327 | - } |
|
| 328 | - else{ |
|
| 323 | + } else{ |
|
| 329 | 324 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 330 | 325 | } |
| 331 | 326 | } |
@@ -356,8 +351,7 @@ discard block |
||
| 356 | 351 | if(isset($linkType)){ |
| 357 | 352 | if(is_array($linkType)){ |
| 358 | 353 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 359 | - } |
|
| 360 | - else{ |
|
| 354 | + } else{ |
|
| 361 | 355 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 362 | 356 | } |
| 363 | 357 | } |
@@ -400,8 +394,7 @@ discard block |
||
| 400 | 394 | if(isset($linkType)){ |
| 401 | 395 | if(is_array($linkType)){ |
| 402 | 396 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 403 | - } |
|
| 404 | - else{ |
|
| 397 | + } else{ |
|
| 405 | 398 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 406 | 399 | } |
| 407 | 400 | } |
@@ -444,8 +437,7 @@ discard block |
||
| 444 | 437 | if(isset($linkType)){ |
| 445 | 438 | if(is_array($linkType)){ |
| 446 | 439 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 447 | - } |
|
| 448 | - else{ |
|
| 440 | + } else{ |
|
| 449 | 441 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 450 | 442 | } |
| 451 | 443 | } |
@@ -562,8 +554,7 @@ discard block |
||
| 562 | 554 | |
| 563 | 555 | if(is_array($tagLabels)){ |
| 564 | 556 | $criteria = $criteria->_AND_($linkSet->targetId->label->in($tagLabels)); |
| 565 | - } |
|
| 566 | - else{ |
|
| 557 | + } else{ |
|
| 567 | 558 | $criteria = $criteria->_AND_($linkSet->targetId->label->is($tagLabels)); |
| 568 | 559 | } |
| 569 | 560 | if(isset($linkType)){ |
@@ -80,14 +80,14 @@ discard block |
||
| 80 | 80 | ORM_BoolField('visible')->setOutputOptions($App->translate('No'), $App->translate('Yes'))->setDescription($App->translate('Column in list')) |
| 81 | 81 | ); |
| 82 | 82 | |
| 83 | - if($App->onlineShop){ |
|
| 83 | + if ($App->onlineShop) { |
|
| 84 | 84 | $this->addFields(ORM_BoolField('visible_in_shop')); |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | public function save(ORMRecord $record, $noTrace = false) |
| 89 | 89 | { |
| 90 | - if(! $record->fieldname){ |
|
| 90 | + if (!$record->fieldname) { |
|
| 91 | 91 | $record->fieldname = $this->getFieldName($record->name); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | $name = preg_replace('/[^a-zA-Z0-9]+/', '', $name); |
| 109 | 109 | $name = mb_strtolower($name); |
| 110 | 110 | |
| 111 | - if(empty($name)){ |
|
| 111 | + if (empty($name)) { |
|
| 112 | 112 | throw new AppSaveException($this->App()->translate('The name is mandatory')); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - return '_' . $name; |
|
| 115 | + return '_'.$name; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | $arr = array(); |
| 128 | 128 | |
| 129 | - if(isset($App->Article)){ |
|
| 129 | + if (isset($App->Article)) { |
|
| 130 | 130 | $arr['Article'] = $App->translate('Products database'); |
| 131 | 131 | } |
| 132 | 132 | |
@@ -75,8 +75,8 @@ |
||
| 75 | 75 | public function serialize(AppRecord $record) |
| 76 | 76 | { |
| 77 | 77 | $values = $record->getValues(); |
| 78 | - foreach ($values as $key => $value){ |
|
| 79 | - if($value instanceof ORMRecordSet){ |
|
| 78 | + foreach ($values as $key => $value) { |
|
| 79 | + if ($value instanceof ORMRecordSet) { |
|
| 80 | 80 | $values[$key] = $value->id; |
| 81 | 81 | } |
| 82 | 82 | } |
@@ -57,50 +57,50 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | function app_genericSetEditor(ORMRecordSet $set) |
| 59 | 59 | { |
| 60 | - $O = \bab_functionality::get('LibOrm'); |
|
| 61 | - $O->init(); |
|
| 62 | - $W = \bab_Widgets(); |
|
| 63 | - $layout = $W->VBoxLayout(); |
|
| 64 | - $layout->setVerticalSpacing(1, 'em'); |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - $fields = $set->getFields(); |
|
| 68 | - |
|
| 69 | - foreach ($fields as $field) { |
|
| 70 | - $description = $field->getDescription(); |
|
| 71 | - if (empty($description)) { |
|
| 72 | - $description = $field->getName(); |
|
| 73 | - } |
|
| 74 | - $fieldLabel = $W->Label($description . ':'); |
|
| 75 | - |
|
| 76 | - if ($field instanceof ORMDateField) { |
|
| 77 | - $widget = $W->DatePicker(); |
|
| 78 | - } else if ($field instanceof ORMTimeField) { |
|
| 79 | - $widget = $W->LineEdit()->setMaxSize(5)->setSize(5)->addClass('widget-timepicker'); |
|
| 80 | - } else if ($field instanceof ORMStringField) { |
|
| 81 | - $widget = $W->LineEdit()->setSize(min(array(80, $field->getMaxLength()))); |
|
| 82 | - } else if ($field instanceof ORMEnumField) { |
|
| 83 | - $widget = $W->Select(); |
|
| 84 | - $widget->addOption('', ''); |
|
| 85 | - foreach ($field->getValues() as $key => $text) { |
|
| 86 | - $widget->addOption($key, $text); |
|
| 87 | - } |
|
| 88 | - } else if ($field instanceof ORMIntField) { |
|
| 89 | - $widget = $W->LineEdit()->setSize(9); |
|
| 90 | - } else if ($field instanceof ORMTextField) { |
|
| 91 | - $widget = $W->TextEdit()->setColumns(80)->setLines(5); |
|
| 92 | - } else if ($field instanceof ORMRecordSet) { |
|
| 93 | - $widget = app_genericSetEditor($field); |
|
| 94 | - $widget->addClass('sub-form'); |
|
| 95 | - } else { |
|
| 96 | - $widget = null; |
|
| 97 | - } |
|
| 98 | - if (isset($widget)) { |
|
| 99 | - $layout->addItem($W->VBoxLayout()->addItem($fieldLabel)->addItem($widget)); |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - return $layout; |
|
| 60 | + $O = \bab_functionality::get('LibOrm'); |
|
| 61 | + $O->init(); |
|
| 62 | + $W = \bab_Widgets(); |
|
| 63 | + $layout = $W->VBoxLayout(); |
|
| 64 | + $layout->setVerticalSpacing(1, 'em'); |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + $fields = $set->getFields(); |
|
| 68 | + |
|
| 69 | + foreach ($fields as $field) { |
|
| 70 | + $description = $field->getDescription(); |
|
| 71 | + if (empty($description)) { |
|
| 72 | + $description = $field->getName(); |
|
| 73 | + } |
|
| 74 | + $fieldLabel = $W->Label($description . ':'); |
|
| 75 | + |
|
| 76 | + if ($field instanceof ORMDateField) { |
|
| 77 | + $widget = $W->DatePicker(); |
|
| 78 | + } else if ($field instanceof ORMTimeField) { |
|
| 79 | + $widget = $W->LineEdit()->setMaxSize(5)->setSize(5)->addClass('widget-timepicker'); |
|
| 80 | + } else if ($field instanceof ORMStringField) { |
|
| 81 | + $widget = $W->LineEdit()->setSize(min(array(80, $field->getMaxLength()))); |
|
| 82 | + } else if ($field instanceof ORMEnumField) { |
|
| 83 | + $widget = $W->Select(); |
|
| 84 | + $widget->addOption('', ''); |
|
| 85 | + foreach ($field->getValues() as $key => $text) { |
|
| 86 | + $widget->addOption($key, $text); |
|
| 87 | + } |
|
| 88 | + } else if ($field instanceof ORMIntField) { |
|
| 89 | + $widget = $W->LineEdit()->setSize(9); |
|
| 90 | + } else if ($field instanceof ORMTextField) { |
|
| 91 | + $widget = $W->TextEdit()->setColumns(80)->setLines(5); |
|
| 92 | + } else if ($field instanceof ORMRecordSet) { |
|
| 93 | + $widget = app_genericSetEditor($field); |
|
| 94 | + $widget->addClass('sub-form'); |
|
| 95 | + } else { |
|
| 96 | + $widget = null; |
|
| 97 | + } |
|
| 98 | + if (isset($widget)) { |
|
| 99 | + $layout->addItem($W->VBoxLayout()->addItem($fieldLabel)->addItem($widget)); |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + return $layout; |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | |
@@ -113,50 +113,50 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | function app_genericSetFilterForm(ORMRecordSet $set) |
| 115 | 115 | { |
| 116 | - $O = \bab_functionality::get('LibOrm'); |
|
| 117 | - $O->init(); |
|
| 118 | - $W = \bab_Widgets(); |
|
| 119 | - $layout = $W->FlowLayout(); |
|
| 120 | - $layout->setVerticalSpacing(1, 'em')->setHorizontalSpacing(1, 'em'); |
|
| 121 | - |
|
| 122 | - |
|
| 123 | - $fields = $set->getFields(); |
|
| 124 | - |
|
| 125 | - foreach ($fields as $field) { |
|
| 126 | - $description = $field->getDescription(); |
|
| 127 | - if (empty($description)) { |
|
| 128 | - $description = $field->getName(); |
|
| 129 | - } |
|
| 130 | - $fieldLabel = $W->Label($description . ':'); |
|
| 131 | - |
|
| 132 | - if ($field instanceof ORMDateField) { |
|
| 133 | - $widget = $W->PeriodPicker(); |
|
| 134 | - } else if ($field instanceof ORMTimeField) { |
|
| 135 | - $widget = $W->TimePicker(); |
|
| 136 | - } else if ($field instanceof ORMStringField) { |
|
| 137 | - $widget = $W->LineEdit()->setSize(min(array(15, $field->getMaxLength()))); |
|
| 138 | - } else if ($field instanceof ORMEnumField) { |
|
| 139 | - $widget = $W->Select(); |
|
| 140 | - $widget->addOption('', ''); |
|
| 141 | - foreach ($field->getValues() as $key => $text) { |
|
| 142 | - $widget->addOption($key, $text); |
|
| 143 | - } |
|
| 144 | - } else if ($field instanceof ORMIntField) { |
|
| 145 | - $widget = $W->LineEdit()->setSize(9); |
|
| 146 | - } else if ($field instanceof ORMTextField) { |
|
| 147 | - $widget = $widget = $W->LineEdit()->setSize(15); |
|
| 148 | - } else if ($field instanceof ORMRecordSet) { |
|
| 149 | - $widget = app_genericSetFilterForm($field); |
|
| 150 | - $widget->addClass('sub-form'); |
|
| 151 | - } else { |
|
| 152 | - $widget = null; |
|
| 153 | - } |
|
| 154 | - if (isset($widget)) { |
|
| 155 | - $layout->addItem($W->VBoxLayout()->addItem($fieldLabel)->addItem($widget)); |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - return $layout; |
|
| 116 | + $O = \bab_functionality::get('LibOrm'); |
|
| 117 | + $O->init(); |
|
| 118 | + $W = \bab_Widgets(); |
|
| 119 | + $layout = $W->FlowLayout(); |
|
| 120 | + $layout->setVerticalSpacing(1, 'em')->setHorizontalSpacing(1, 'em'); |
|
| 121 | + |
|
| 122 | + |
|
| 123 | + $fields = $set->getFields(); |
|
| 124 | + |
|
| 125 | + foreach ($fields as $field) { |
|
| 126 | + $description = $field->getDescription(); |
|
| 127 | + if (empty($description)) { |
|
| 128 | + $description = $field->getName(); |
|
| 129 | + } |
|
| 130 | + $fieldLabel = $W->Label($description . ':'); |
|
| 131 | + |
|
| 132 | + if ($field instanceof ORMDateField) { |
|
| 133 | + $widget = $W->PeriodPicker(); |
|
| 134 | + } else if ($field instanceof ORMTimeField) { |
|
| 135 | + $widget = $W->TimePicker(); |
|
| 136 | + } else if ($field instanceof ORMStringField) { |
|
| 137 | + $widget = $W->LineEdit()->setSize(min(array(15, $field->getMaxLength()))); |
|
| 138 | + } else if ($field instanceof ORMEnumField) { |
|
| 139 | + $widget = $W->Select(); |
|
| 140 | + $widget->addOption('', ''); |
|
| 141 | + foreach ($field->getValues() as $key => $text) { |
|
| 142 | + $widget->addOption($key, $text); |
|
| 143 | + } |
|
| 144 | + } else if ($field instanceof ORMIntField) { |
|
| 145 | + $widget = $W->LineEdit()->setSize(9); |
|
| 146 | + } else if ($field instanceof ORMTextField) { |
|
| 147 | + $widget = $widget = $W->LineEdit()->setSize(15); |
|
| 148 | + } else if ($field instanceof ORMRecordSet) { |
|
| 149 | + $widget = app_genericSetFilterForm($field); |
|
| 150 | + $widget->addClass('sub-form'); |
|
| 151 | + } else { |
|
| 152 | + $widget = null; |
|
| 153 | + } |
|
| 154 | + if (isset($widget)) { |
|
| 155 | + $layout->addItem($W->VBoxLayout()->addItem($fieldLabel)->addItem($widget)); |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + return $layout; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | |
@@ -169,47 +169,47 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | function app_LabelledWidget($labelText, WidgetDisplayableInterface $widget) |
| 171 | 171 | { |
| 172 | - $W = \bab_Widgets(); |
|
| 173 | - |
|
| 174 | - $label = $W->Label($labelText); |
|
| 175 | - if ($widget instanceof WidgetInputWidget) { |
|
| 176 | - $label->setAssociatedWidget($widget); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - if ($widget instanceof WidgetCheckBox) { |
|
| 180 | - $layout = $W->HBoxItems( |
|
| 181 | - $widget->setSizePolicy(WidgetSizePolicy::MINIMUM), |
|
| 182 | - $label |
|
| 183 | - )->setVerticalAlign('middle')->setHorizontalSpacing(0.5, 'em'); |
|
| 184 | - } else { |
|
| 185 | - $layout = $W->VBoxItems( |
|
| 186 | - $label, |
|
| 187 | - $widget |
|
| 188 | - )->setVerticalSpacing(0.5, 'em'); |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - return $layout; |
|
| 172 | + $W = \bab_Widgets(); |
|
| 173 | + |
|
| 174 | + $label = $W->Label($labelText); |
|
| 175 | + if ($widget instanceof WidgetInputWidget) { |
|
| 176 | + $label->setAssociatedWidget($widget); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + if ($widget instanceof WidgetCheckBox) { |
|
| 180 | + $layout = $W->HBoxItems( |
|
| 181 | + $widget->setSizePolicy(WidgetSizePolicy::MINIMUM), |
|
| 182 | + $label |
|
| 183 | + )->setVerticalAlign('middle')->setHorizontalSpacing(0.5, 'em'); |
|
| 184 | + } else { |
|
| 185 | + $layout = $W->VBoxItems( |
|
| 186 | + $label, |
|
| 187 | + $widget |
|
| 188 | + )->setVerticalSpacing(0.5, 'em'); |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + return $layout; |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | |
| 195 | 195 | |
| 196 | 196 | function app_LabelledCheckbox($labelText, $checkboxName, $options = null) |
| 197 | 197 | { |
| 198 | - $W = \bab_Widgets(); |
|
| 198 | + $W = \bab_Widgets(); |
|
| 199 | 199 | |
| 200 | - $label = $W->Label($labelText)->colon(false); |
|
| 201 | - $checkbox = $W->Checkbox()->setName($checkboxName); |
|
| 202 | - $label->setAssociatedWidget($checkbox); |
|
| 203 | - if (isset($options)) { |
|
| 204 | - $label->setSizePolicy(WidgetSizePolicy::FIXED)->setCanvasOptions($options); |
|
| 205 | - } |
|
| 200 | + $label = $W->Label($labelText)->colon(false); |
|
| 201 | + $checkbox = $W->Checkbox()->setName($checkboxName); |
|
| 202 | + $label->setAssociatedWidget($checkbox); |
|
| 203 | + if (isset($options)) { |
|
| 204 | + $label->setSizePolicy(WidgetSizePolicy::FIXED)->setCanvasOptions($options); |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | - $layout = $W->HBoxItems( |
|
| 208 | - $checkbox->setSizePolicy(WidgetSizePolicy::MINIMUM), |
|
| 209 | - $label |
|
| 210 | - )->setVerticalAlign('middle')->setHorizontalSpacing(0.5, 'em'); |
|
| 207 | + $layout = $W->HBoxItems( |
|
| 208 | + $checkbox->setSizePolicy(WidgetSizePolicy::MINIMUM), |
|
| 209 | + $label |
|
| 210 | + )->setVerticalAlign('middle')->setHorizontalSpacing(0.5, 'em'); |
|
| 211 | 211 | |
| 212 | - return $layout; |
|
| 212 | + return $layout; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | |
@@ -217,42 +217,42 @@ discard block |
||
| 217 | 217 | |
| 218 | 218 | function app_LabelledOrmSelect(ORMMySqlIterator $iterator, $fieldName, $selectName, $label, $hidden = false, $groupFieldName = null) |
| 219 | 219 | { |
| 220 | - $W = \bab_Widgets(); |
|
| 221 | - |
|
| 222 | - if (isset($groupFieldName)) { |
|
| 223 | - $groupPathElements = explode('/', $groupFieldName); |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - $select = $W->Select()->setName($selectName); |
|
| 227 | - |
|
| 228 | - $select->addOption('', ''); |
|
| 229 | - |
|
| 230 | - $nbOptions = 0; |
|
| 231 | - foreach ($iterator as $record) { |
|
| 232 | - if (isset($record->code)) { |
|
| 233 | - $optionText = $record->code . ' - ' . $record->$fieldName; |
|
| 234 | - } else { |
|
| 235 | - $optionText = $record->$fieldName; |
|
| 236 | - } |
|
| 237 | - if (isset($groupFieldName)) { |
|
| 238 | - $group = $record; |
|
| 239 | - foreach ($groupPathElements as $groupPathElement) { |
|
| 240 | - $group = $group->$groupPathElement; |
|
| 241 | - } |
|
| 242 | - $select->addOption($record->id, $optionText, $group); |
|
| 243 | - } else { |
|
| 244 | - $select->addOption($record->id, $optionText); |
|
| 245 | - } |
|
| 246 | - $nbOptions++; |
|
| 247 | - $lastId = $record->id; |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - if ($nbOptions == 1) { |
|
| 251 | - $select->setValue($lastId); |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - |
|
| 255 | - return app_LabelledWidget($label, $select); |
|
| 220 | + $W = \bab_Widgets(); |
|
| 221 | + |
|
| 222 | + if (isset($groupFieldName)) { |
|
| 223 | + $groupPathElements = explode('/', $groupFieldName); |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + $select = $W->Select()->setName($selectName); |
|
| 227 | + |
|
| 228 | + $select->addOption('', ''); |
|
| 229 | + |
|
| 230 | + $nbOptions = 0; |
|
| 231 | + foreach ($iterator as $record) { |
|
| 232 | + if (isset($record->code)) { |
|
| 233 | + $optionText = $record->code . ' - ' . $record->$fieldName; |
|
| 234 | + } else { |
|
| 235 | + $optionText = $record->$fieldName; |
|
| 236 | + } |
|
| 237 | + if (isset($groupFieldName)) { |
|
| 238 | + $group = $record; |
|
| 239 | + foreach ($groupPathElements as $groupPathElement) { |
|
| 240 | + $group = $group->$groupPathElement; |
|
| 241 | + } |
|
| 242 | + $select->addOption($record->id, $optionText, $group); |
|
| 243 | + } else { |
|
| 244 | + $select->addOption($record->id, $optionText); |
|
| 245 | + } |
|
| 246 | + $nbOptions++; |
|
| 247 | + $lastId = $record->id; |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + if ($nbOptions == 1) { |
|
| 251 | + $select->setValue($lastId); |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + |
|
| 255 | + return app_LabelledWidget($label, $select); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | |
@@ -260,108 +260,108 @@ discard block |
||
| 260 | 260 | |
| 261 | 261 | function app_OrmWidget(ORMField $field) |
| 262 | 262 | { |
| 263 | - $W = \bab_Widgets(); |
|
| 263 | + $W = \bab_Widgets(); |
|
| 264 | 264 | |
| 265 | 265 | |
| 266 | - if ($field instanceof ORMDateField) { |
|
| 267 | - $widget = $W->DatePicker(); |
|
| 268 | - } else if ($field instanceof ORMTimeField) { |
|
| 269 | - $widget = $W->TimeEdit(); //->setMaxSize(5)->setSize(5)->addClass('widget-timepicker'); |
|
| 270 | - } else if ($field instanceof ORMDatetimeField) { |
|
| 271 | - $widget = $W->DateTimePicker(); //->setMaxSize(5)->setSize(5)->addClass('widget-timepicker'); |
|
| 272 | - } else if ($field instanceof ORMEnumField) { |
|
| 273 | - $widget = $W->Select(); |
|
| 266 | + if ($field instanceof ORMDateField) { |
|
| 267 | + $widget = $W->DatePicker(); |
|
| 268 | + } else if ($field instanceof ORMTimeField) { |
|
| 269 | + $widget = $W->TimeEdit(); //->setMaxSize(5)->setSize(5)->addClass('widget-timepicker'); |
|
| 270 | + } else if ($field instanceof ORMDatetimeField) { |
|
| 271 | + $widget = $W->DateTimePicker(); //->setMaxSize(5)->setSize(5)->addClass('widget-timepicker'); |
|
| 272 | + } else if ($field instanceof ORMEnumField) { |
|
| 273 | + $widget = $W->Select(); |
|
| 274 | 274 | //// $widget = $W->MultiSelect()->setSingleSelect(); |
| 275 | - $widget->addOption('', ''); |
|
| 276 | - $values = $field->getValues(); |
|
| 277 | - foreach ($values as $key => $value) { |
|
| 278 | - $widget->addOption($key, $value); |
|
| 279 | - } |
|
| 280 | - } else if ($field instanceof ORMSetField) { |
|
| 281 | - $widget = $W->MultiSelect()->setSelectedList(2); |
|
| 282 | - $values = $field->getValues(); |
|
| 283 | - foreach ($values as $key => $value) { |
|
| 284 | - $widget->addOption($key, $value); |
|
| 285 | - } |
|
| 286 | - } else if ($field instanceof ORMUserField) { |
|
| 287 | - $widget = $W->SuggestUser() |
|
| 288 | - ->setMinChars(0) |
|
| 289 | - ->setSizePolicy(\Func_Icons::ICON_LEFT_16); |
|
| 290 | - } else if ($field instanceof ORMCurrencyField) { |
|
| 291 | - $widget = $W->LineEdit()->setSize(6)->addClass('widget-input-currency'); |
|
| 292 | - } else if ($field instanceof ORMBoolField) { |
|
| 293 | - $widget = $W->CheckBox()->setCheckedValue('1'); |
|
| 294 | - } else if ($field instanceof ORMIntField) { |
|
| 295 | - $widget = $W->LineEdit() |
|
| 296 | - ->setSize(6)->addClass('widget-input-numeric'); |
|
| 297 | - } else if ($field instanceof ORMEmailField) { |
|
| 298 | - $widget = $W->EmailLineEdit() |
|
| 299 | - ->setMaxSize($field->getMaxLength()); |
|
| 300 | - } else if ($field instanceof ORMFileField) { |
|
| 301 | - $widget = $W->FilePicker(); |
|
| 302 | - } else if ($field instanceof ORMStringField) { |
|
| 303 | - $widget = $W->LineEdit() |
|
| 304 | - ->setMaxSize($field->getMaxLength()); |
|
| 305 | - } else if ($field instanceof ORMTextField) { |
|
| 306 | - $widget = $W->TextEdit() |
|
| 307 | - ->addClass('widget-autoresize'); |
|
| 308 | - } else if ($field instanceof ORMPkField) { |
|
| 309 | - $widget = $W->Hidden(); |
|
| 310 | - } else if ($field instanceof ORMFkField) { |
|
| 311 | - $widget = $W->Select(); |
|
| 312 | - $fieldName = $field->getName(); |
|
| 313 | - $parentSet = clone $field->getParentSet(); |
|
| 314 | - $parentSet->join($fieldName); |
|
| 315 | - $set = $parentSet->$fieldName; |
|
| 316 | - $records = $set->select(); |
|
| 317 | - $records->orderAsc($set->name); |
|
| 318 | - $pkName = $set->getPrimaryKey(); |
|
| 319 | - $widget->addOption('', ''); |
|
| 320 | - foreach ($records as $record) { |
|
| 321 | - $widget->addOption($record->$pkName, $record->name); |
|
| 322 | - } |
|
| 323 | - } else if ($field instanceof ORMRecordSet) { |
|
| 324 | - $widget = $W->Select(); |
|
| 275 | + $widget->addOption('', ''); |
|
| 276 | + $values = $field->getValues(); |
|
| 277 | + foreach ($values as $key => $value) { |
|
| 278 | + $widget->addOption($key, $value); |
|
| 279 | + } |
|
| 280 | + } else if ($field instanceof ORMSetField) { |
|
| 281 | + $widget = $W->MultiSelect()->setSelectedList(2); |
|
| 282 | + $values = $field->getValues(); |
|
| 283 | + foreach ($values as $key => $value) { |
|
| 284 | + $widget->addOption($key, $value); |
|
| 285 | + } |
|
| 286 | + } else if ($field instanceof ORMUserField) { |
|
| 287 | + $widget = $W->SuggestUser() |
|
| 288 | + ->setMinChars(0) |
|
| 289 | + ->setSizePolicy(\Func_Icons::ICON_LEFT_16); |
|
| 290 | + } else if ($field instanceof ORMCurrencyField) { |
|
| 291 | + $widget = $W->LineEdit()->setSize(6)->addClass('widget-input-currency'); |
|
| 292 | + } else if ($field instanceof ORMBoolField) { |
|
| 293 | + $widget = $W->CheckBox()->setCheckedValue('1'); |
|
| 294 | + } else if ($field instanceof ORMIntField) { |
|
| 295 | + $widget = $W->LineEdit() |
|
| 296 | + ->setSize(6)->addClass('widget-input-numeric'); |
|
| 297 | + } else if ($field instanceof ORMEmailField) { |
|
| 298 | + $widget = $W->EmailLineEdit() |
|
| 299 | + ->setMaxSize($field->getMaxLength()); |
|
| 300 | + } else if ($field instanceof ORMFileField) { |
|
| 301 | + $widget = $W->FilePicker(); |
|
| 302 | + } else if ($field instanceof ORMStringField) { |
|
| 303 | + $widget = $W->LineEdit() |
|
| 304 | + ->setMaxSize($field->getMaxLength()); |
|
| 305 | + } else if ($field instanceof ORMTextField) { |
|
| 306 | + $widget = $W->TextEdit() |
|
| 307 | + ->addClass('widget-autoresize'); |
|
| 308 | + } else if ($field instanceof ORMPkField) { |
|
| 309 | + $widget = $W->Hidden(); |
|
| 310 | + } else if ($field instanceof ORMFkField) { |
|
| 311 | + $widget = $W->Select(); |
|
| 312 | + $fieldName = $field->getName(); |
|
| 313 | + $parentSet = clone $field->getParentSet(); |
|
| 314 | + $parentSet->join($fieldName); |
|
| 315 | + $set = $parentSet->$fieldName; |
|
| 316 | + $records = $set->select(); |
|
| 317 | + $records->orderAsc($set->name); |
|
| 318 | + $pkName = $set->getPrimaryKey(); |
|
| 319 | + $widget->addOption('', ''); |
|
| 320 | + foreach ($records as $record) { |
|
| 321 | + $widget->addOption($record->$pkName, $record->name); |
|
| 322 | + } |
|
| 323 | + } else if ($field instanceof ORMRecordSet) { |
|
| 324 | + $widget = $W->Select(); |
|
| 325 | 325 | //// $widget = $W->MultiSelect()->setSingleSelect(); |
| 326 | 326 | // $fieldName = $field->getName(); |
| 327 | 327 | // $parentSet = $field->getParentSet(); |
| 328 | 328 | // $parentSet->join($fieldName); |
| 329 | 329 | // $set = $parentSet->$fieldName; |
| 330 | - $records = $field->select(); |
|
| 331 | - $records->orderAsc($field->name); |
|
| 332 | - $pkName = $field->getPrimaryKey(); |
|
| 333 | - $widget->addOption('', ''); |
|
| 334 | - foreach ($records as $record) { |
|
| 335 | - $widget->addOption($record->$pkName, $record->name); |
|
| 336 | - } |
|
| 337 | - } else { |
|
| 338 | - $widget = $W->LineEdit(); |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - $widget->setName($field->getName()); |
|
| 342 | - |
|
| 343 | - return $widget; |
|
| 330 | + $records = $field->select(); |
|
| 331 | + $records->orderAsc($field->name); |
|
| 332 | + $pkName = $field->getPrimaryKey(); |
|
| 333 | + $widget->addOption('', ''); |
|
| 334 | + foreach ($records as $record) { |
|
| 335 | + $widget->addOption($record->$pkName, $record->name); |
|
| 336 | + } |
|
| 337 | + } else { |
|
| 338 | + $widget = $W->LineEdit(); |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + $widget->setName($field->getName()); |
|
| 342 | + |
|
| 343 | + return $widget; |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | |
| 347 | 347 | |
| 348 | 348 | function app_LabelledOrmWidget(ORMField $field, $label = null, $hidden = false) |
| 349 | 349 | { |
| 350 | - $W = \bab_Widgets(); |
|
| 350 | + $W = \bab_Widgets(); |
|
| 351 | 351 | |
| 352 | - if ($hidden) { |
|
| 353 | - $widget = $W->Hidden(); |
|
| 354 | - $widget->setName($field->getName()); |
|
| 355 | - return $widget; |
|
| 356 | - } |
|
| 352 | + if ($hidden) { |
|
| 353 | + $widget = $W->Hidden(); |
|
| 354 | + $widget->setName($field->getName()); |
|
| 355 | + return $widget; |
|
| 356 | + } |
|
| 357 | 357 | |
| 358 | - if (is_null($label)) { |
|
| 359 | - $label = $field->getDescription(); |
|
| 360 | - } |
|
| 358 | + if (is_null($label)) { |
|
| 359 | + $label = $field->getDescription(); |
|
| 360 | + } |
|
| 361 | 361 | |
| 362 | - $widget = app_OrmWidget($field); |
|
| 362 | + $widget = app_OrmWidget($field); |
|
| 363 | 363 | |
| 364 | - return app_LabelledWidget($label, $widget); |
|
| 364 | + return app_LabelledWidget($label, $widget); |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | |
@@ -377,16 +377,16 @@ discard block |
||
| 377 | 377 | */ |
| 378 | 378 | function app_dateTime(ORMField $field, $value) { |
| 379 | 379 | |
| 380 | - $W = \bab_functionality::get('Widgets'); |
|
| 381 | - $name = $field->getName(); |
|
| 382 | - $label = $W->Label($field->getDescription()); |
|
| 380 | + $W = \bab_functionality::get('Widgets'); |
|
| 381 | + $name = $field->getName(); |
|
| 382 | + $label = $W->Label($field->getDescription()); |
|
| 383 | 383 | |
| 384 | - $frame = app_dateTimeField($name, $label, $value); |
|
| 384 | + $frame = app_dateTimeField($name, $label, $value); |
|
| 385 | 385 | |
| 386 | - return $W->VBoxItems( |
|
| 387 | - $label, |
|
| 388 | - $frame |
|
| 389 | - ); |
|
| 386 | + return $W->VBoxItems( |
|
| 387 | + $label, |
|
| 388 | + $frame |
|
| 389 | + ); |
|
| 390 | 390 | |
| 391 | 391 | } |
| 392 | 392 | |
@@ -400,24 +400,24 @@ discard block |
||
| 400 | 400 | */ |
| 401 | 401 | function app_dateTimeField($fieldName, WidgetLabel $label, $value = null) |
| 402 | 402 | { |
| 403 | - $W = \bab_functionality::get('Widgets'); |
|
| 403 | + $W = \bab_functionality::get('Widgets'); |
|
| 404 | 404 | |
| 405 | - $datepart = $W->DatePicker()->setAssociatedLabel($label)->setName('date'); |
|
| 406 | - $timepart = $W->TimePicker()->setName('time'); |
|
| 405 | + $datepart = $W->DatePicker()->setAssociatedLabel($label)->setName('date'); |
|
| 406 | + $timepart = $W->TimePicker()->setName('time'); |
|
| 407 | 407 | |
| 408 | - if (isset($value)) { |
|
| 408 | + if (isset($value)) { |
|
| 409 | 409 | |
| 410 | - $value = explode(' ', $value); |
|
| 410 | + $value = explode(' ', $value); |
|
| 411 | 411 | |
| 412 | - $datepart->setValue($value[0]); |
|
| 413 | - $timepart->setValue($value[1]); |
|
| 414 | - } |
|
| 412 | + $datepart->setValue($value[0]); |
|
| 413 | + $timepart->setValue($value[1]); |
|
| 414 | + } |
|
| 415 | 415 | |
| 416 | - $datetime = $W->Frame(null, $W->HBoxLayout())->setName($fieldName) |
|
| 417 | - ->addItem($datepart) |
|
| 418 | - ->addItem($timepart); |
|
| 416 | + $datetime = $W->Frame(null, $W->HBoxLayout())->setName($fieldName) |
|
| 417 | + ->addItem($datepart) |
|
| 418 | + ->addItem($timepart); |
|
| 419 | 419 | |
| 420 | - return $datetime; |
|
| 420 | + return $datetime; |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | if (empty($description)) { |
| 72 | 72 | $description = $field->getName(); |
| 73 | 73 | } |
| 74 | - $fieldLabel = $W->Label($description . ':'); |
|
| 74 | + $fieldLabel = $W->Label($description.':'); |
|
| 75 | 75 | |
| 76 | 76 | if ($field instanceof ORMDateField) { |
| 77 | 77 | $widget = $W->DatePicker(); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | if (empty($description)) { |
| 128 | 128 | $description = $field->getName(); |
| 129 | 129 | } |
| 130 | - $fieldLabel = $W->Label($description . ':'); |
|
| 130 | + $fieldLabel = $W->Label($description.':'); |
|
| 131 | 131 | |
| 132 | 132 | if ($field instanceof ORMDateField) { |
| 133 | 133 | $widget = $W->PeriodPicker(); |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | $nbOptions = 0; |
| 231 | 231 | foreach ($iterator as $record) { |
| 232 | 232 | if (isset($record->code)) { |
| 233 | - $optionText = $record->code . ' - ' . $record->$fieldName; |
|
| 233 | + $optionText = $record->code.' - '.$record->$fieldName; |
|
| 234 | 234 | } else { |
| 235 | 235 | $optionText = $record->$fieldName; |
| 236 | 236 | } |
@@ -136,7 +136,7 @@ |
||
| 136 | 136 | |
| 137 | 137 | $displayable = $field->output($value); |
| 138 | 138 | |
| 139 | - switch(true) { |
|
| 139 | + switch (true) { |
|
| 140 | 140 | case ($field instanceof ORMTextField): |
| 141 | 141 | $displayable = $W->RichText($displayable)->setRenderingOptions(BAB_HTML_ALL ^ BAB_HTML_P); |
| 142 | 142 | break; |