@@ -34,13 +34,13 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function includeBase() |
| 36 | 36 | { |
| 37 | - require_once APP_UI_PATH . 'base.ui.php'; |
|
| 38 | - require_once APP_UI_PATH . 'ui.helpers.php'; |
|
| 37 | + require_once APP_UI_PATH.'base.ui.php'; |
|
| 38 | + require_once APP_UI_PATH.'ui.helpers.php'; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function includePage() |
| 42 | 42 | { |
| 43 | - require_once APP_UI_PATH . 'page.class.php'; |
|
| 43 | + require_once APP_UI_PATH.'page.class.php'; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public function ExportSelectEditor($id, app_TableModelView $tableview, $filter = null) |
| 79 | 79 | { |
| 80 | - require_once dirname(__FILE__) . '/exportselect.ui.php'; |
|
| 80 | + require_once dirname(__FILE__).'/exportselect.ui.php'; |
|
| 81 | 81 | return new app_ExportSelectEditor($this->App(), $id, $tableview, $filter); |
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | \ No newline at end of file |
@@ -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(); |
@@ -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 | |
@@ -650,13 +650,13 @@ discard block |
||
| 650 | 650 | */ |
| 651 | 651 | protected function importDate($name, $value) |
| 652 | 652 | { |
| 653 | - if (preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2}/',$value)) { |
|
| 653 | + if (preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2}/', $value)) { |
|
| 654 | 654 | return $this->importProperty($name, $value); |
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | // try in DD/MM/YYYY format |
| 658 | 658 | |
| 659 | - if (preg_match('/(?P<day>[0-9]+)\/(?P<month>[0-9]+)\/(?P<year>[0-9]{2,4})/',$value, $matches)) { |
|
| 659 | + if (preg_match('/(?P<day>[0-9]+)\/(?P<month>[0-9]+)\/(?P<year>[0-9]{2,4})/', $value, $matches)) { |
|
| 660 | 660 | |
| 661 | 661 | $value = sprintf('%04d-%02d-%02d', (int) $matches['year'], (int) $matches['month'], (int) $matches['day']); |
| 662 | 662 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | if (null === $url) { |
| 113 | 113 | $script = '<script type="text/javascript">'; |
| 114 | 114 | if (isset($message)) { |
| 115 | - $script .= 'alert("' . bab_toHtml($message, BAB_HTML_JS) . '");'; |
|
| 115 | + $script .= 'alert("'.bab_toHtml($message, BAB_HTML_JS).'");'; |
|
| 116 | 116 | } |
| 117 | 117 | $script .= 'history.back();'; |
| 118 | 118 | $script .= '</script>'; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $url = $url->url(); |
| 125 | 125 | } |
| 126 | 126 | if (!empty($babBody->msgerror)) { |
| 127 | - $url .= '&msgerror=' . urlencode($babBody->msgerror); |
|
| 127 | + $url .= '&msgerror='.urlencode($babBody->msgerror); |
|
| 128 | 128 | } |
| 129 | 129 | if (isset($message)) { |
| 130 | 130 | $lines = explode("\n", $message); |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - header('Location: ' . $url); |
|
| 136 | + header('Location: '.$url); |
|
| 137 | 137 | die; |
| 138 | 138 | } |
| 139 | 139 | |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | function app_fileUploadError($error) |
| 167 | 167 | { |
| 168 | - switch($error) { |
|
| 168 | + switch ($error) { |
|
| 169 | 169 | case UPLOAD_ERR_OK: |
| 170 | 170 | return null; |
| 171 | 171 | |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | * @copyright Copyright (c) 2018 by CANTICO ({@link http://www.cantico.fr}) |
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | -require_once dirname(__FILE__) . '/define.php'; |
|
| 25 | -require_once dirname(__FILE__) . '/functions.php'; |
|
| 24 | +require_once dirname(__FILE__).'/define.php'; |
|
| 25 | +require_once dirname(__FILE__).'/functions.php'; |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | |
@@ -55,14 +55,14 @@ discard block |
||
| 55 | 55 | $this->addonName = 'libapp'; |
| 56 | 56 | $this->addonPrefix = 'app'; |
| 57 | 57 | |
| 58 | - $this->classPrefix = $this->addonPrefix . '_'; |
|
| 59 | - $this->controllerTg = 'addon/' . $this->addonName . '/main'; |
|
| 58 | + $this->classPrefix = $this->addonPrefix.'_'; |
|
| 59 | + $this->controllerTg = 'addon/'.$this->addonName.'/main'; |
|
| 60 | 60 | |
| 61 | 61 | $addon = bab_getAddonInfosInstance($this->addonName); |
| 62 | 62 | $this->phpPath = $addon->getPhpPath(); |
| 63 | 63 | $this->recordSetPath = $this->phpPath; |
| 64 | 64 | $this->ctrlPath = $this->phpPath; |
| 65 | - $this->uiPath = $this->phpPath . 'ui/'; |
|
| 65 | + $this->uiPath = $this->phpPath.'ui/'; |
|
| 66 | 66 | |
| 67 | 67 | $babDB = bab_getDB(); |
| 68 | 68 | |
@@ -109,8 +109,8 @@ discard block |
||
| 109 | 109 | public function getRecordSetPathname($class) |
| 110 | 110 | { |
| 111 | 111 | // $App->MyRecordSet() -> myrecord.class.php |
| 112 | - $file = strtolower(substr($class, strlen($this->classPrefix), -3)) . '.class.php'; |
|
| 113 | - return $this->recordSetPath . $file; |
|
| 112 | + $file = strtolower(substr($class, strlen($this->classPrefix), -3)).'.class.php'; |
|
| 113 | + return $this->recordSetPath.$file; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | public function getRecordPathname($class) |
| 123 | 123 | { |
| 124 | 124 | // $App->MyRecord() -> myrecord.class.php |
| 125 | - $file = strtolower(substr($class, strlen($this->classPrefix))) . '.class.php'; |
|
| 126 | - return $this->recordSetPath . $file; |
|
| 125 | + $file = strtolower(substr($class, strlen($this->classPrefix))).'.class.php'; |
|
| 126 | + return $this->recordSetPath.$file; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | if (substr($method, 0, 7) === 'include' && substr($method, -3) === 'Set') { |
| 229 | 229 | $incl = $method; |
| 230 | - $classNameMethod = substr($method, strlen('include')) . 'ClassName'; |
|
| 230 | + $classNameMethod = substr($method, strlen('include')).'ClassName'; |
|
| 231 | 231 | |
| 232 | 232 | |
| 233 | 233 | $classname = $this->$classNameMethod(); |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | // We need to revert to multilang fields before synchronizing. |
| 250 | 250 | $set->useLang(false); |
| 251 | 251 | } |
| 252 | - $sql .= $mysqlbackend->setToSql($set) . "\n"; |
|
| 252 | + $sql .= $mysqlbackend->setToSql($set)."\n"; |
|
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | } |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | |
| 281 | 281 | if (substr($method, 0, strlen('include')) === 'include' && substr($method, -strlen('Set')) === 'Set') { |
| 282 | 282 | $incl = $method; |
| 283 | - $classNameMethod = substr($method, strlen('include')) . 'ClassName'; |
|
| 283 | + $classNameMethod = substr($method, strlen('include')).'ClassName'; |
|
| 284 | 284 | |
| 285 | 285 | $classname = $this->$classNameMethod(); |
| 286 | 286 | |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | |
| 295 | 295 | if (class_exists($classname) && method_exists($this, $call)) { |
| 296 | 296 | $set = $this->$call(); |
| 297 | - $sql .= $mysqlbackend->setToSql($set) . "\n"; |
|
| 297 | + $sql .= $mysqlbackend->setToSql($set)."\n"; |
|
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | 300 | } |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | |
| 309 | 309 | public function includeBase() |
| 310 | 310 | { |
| 311 | - require_once APP_PHP_PATH . 'base.class.php'; |
|
| 311 | + require_once APP_PHP_PATH.'base.class.php'; |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | /** |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | */ |
| 317 | 317 | public function includeRecordSet() |
| 318 | 318 | { |
| 319 | - require_once APP_SET_PATH . 'record.class.php'; |
|
| 319 | + require_once APP_SET_PATH.'record.class.php'; |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | */ |
| 326 | 326 | public function includeTraceableRecordSet() |
| 327 | 327 | { |
| 328 | - require_once APP_SET_PATH . 'traceablerecord.class.php'; |
|
| 328 | + require_once APP_SET_PATH.'traceablerecord.class.php'; |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | public function includeLogSet() |
| 343 | 343 | { |
| 344 | - require_once APP_SET_PATH . 'log.class.php'; |
|
| 344 | + require_once APP_SET_PATH.'log.class.php'; |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | /** |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | */ |
| 358 | 358 | public function LogSetClassName() |
| 359 | 359 | { |
| 360 | - return $this->LogClassName() . 'Set'; |
|
| 360 | + return $this->LogClassName().'Set'; |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | /** |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | */ |
| 380 | 380 | public function includeLinkSet() |
| 381 | 381 | { |
| 382 | - require_once APP_SET_PATH . 'link.class.php'; |
|
| 382 | + require_once APP_SET_PATH.'link.class.php'; |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | /** |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | */ |
| 396 | 396 | public function LinkSetClassName() |
| 397 | 397 | { |
| 398 | - return $this->LinkClassName() . 'Set'; |
|
| 398 | + return $this->LinkClassName().'Set'; |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | /** |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | return null; |
| 430 | 430 | } |
| 431 | 431 | list($classname, $id) = $refParts; |
| 432 | - $classSet = $classname . 'Set'; |
|
| 432 | + $classSet = $classname.'Set'; |
|
| 433 | 433 | $set = $this->$classSet(); |
| 434 | 434 | if (isset($set)) { |
| 435 | 435 | return $set->get($id); |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | { |
| 449 | 449 | $fullClassName = get_class($record); |
| 450 | 450 | list(, $className) = explode('_', $fullClassName); |
| 451 | - return $className . ':' . $record->id; |
|
| 451 | + return $className.':'.$record->id; |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | */ |
| 476 | 476 | public function translate($str, $str_plurals = null, $number = null) |
| 477 | 477 | { |
| 478 | - require_once APP_PHP_PATH . 'functions.php'; |
|
| 478 | + require_once APP_PHP_PATH.'functions.php'; |
|
| 479 | 479 | $translation = $str; |
| 480 | 480 | if ($translate = bab_functionality::get('Translate/Gettext')) { |
| 481 | 481 | /* @var $translate Func_Translate_Gettext */ |
@@ -526,16 +526,16 @@ discard block |
||
| 526 | 526 | */ |
| 527 | 527 | public function mailTo($addr, $subject = null, $body = null) |
| 528 | 528 | { |
| 529 | - $mailTo = 'mailto:' . $addr; |
|
| 529 | + $mailTo = 'mailto:'.$addr; |
|
| 530 | 530 | $parameters = array(); |
| 531 | 531 | if (isset($subject)) { |
| 532 | - $parameters[] = 'subject=' . $subject; |
|
| 532 | + $parameters[] = 'subject='.$subject; |
|
| 533 | 533 | } |
| 534 | 534 | if (isset($body)) { |
| 535 | - $parameters[] = 'body=' . $body; |
|
| 535 | + $parameters[] = 'body='.$body; |
|
| 536 | 536 | } |
| 537 | 537 | if (!empty($parameters)) { |
| 538 | - $mailTo .= '?' . implode('&', $parameters); |
|
| 538 | + $mailTo .= '?'.implode('&', $parameters); |
|
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | return $mailTo; |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | $number = number_format($number, $decimals, ',', ' '); |
| 589 | - return str_replace(' ', bab_nbsp(), $number . ' ' . $prefix . $unitSymbol); |
|
| 589 | + return str_replace(' ', bab_nbsp(), $number.' '.$prefix.$unitSymbol); |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | if (!isset($format)) { |
| 609 | - $format = bab_registry::get('/' . $this->addonName . '/numberFormat', $PhoneNumber->getDefaultFormat()); |
|
| 609 | + $format = bab_registry::get('/'.$this->addonName.'/numberFormat', $PhoneNumber->getDefaultFormat()); |
|
| 610 | 610 | } |
| 611 | 611 | $phoneNumberUtil = $PhoneNumber->PhoneNumberUtil(); |
| 612 | 612 | |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | */ |
| 628 | 628 | public function includeController() |
| 629 | 629 | { |
| 630 | - require_once APP_PHP_PATH . '/controller.class.php'; |
|
| 630 | + require_once APP_PHP_PATH.'/controller.class.php'; |
|
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | */ |
| 637 | 637 | public function includeRecordController() |
| 638 | 638 | { |
| 639 | - require_once APP_CTRL_PATH . '/record.ctrl.php'; |
|
| 639 | + require_once APP_CTRL_PATH.'/record.ctrl.php'; |
|
| 640 | 640 | } |
| 641 | 641 | |
| 642 | 642 | |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | */ |
| 677 | 677 | public function includeUi() |
| 678 | 678 | { |
| 679 | - require_once APP_UI_PATH . 'ui.class.php'; |
|
| 679 | + require_once APP_UI_PATH.'ui.class.php'; |
|
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | |
@@ -688,14 +688,14 @@ discard block |
||
| 688 | 688 | public function Ui() |
| 689 | 689 | { |
| 690 | 690 | $this->includeUi(); |
| 691 | - return bab_getInstance($this->classPrefix . 'Ui');//->setApp($this); |
|
| 691 | + return bab_getInstance($this->classPrefix.'Ui'); //->setApp($this); |
|
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | |
| 695 | 695 | |
| 696 | 696 | protected function includeAccess() |
| 697 | 697 | { |
| 698 | - require_once WORKSPACE_PHP_PATH . '/access.class.php'; |
|
| 698 | + require_once WORKSPACE_PHP_PATH.'/access.class.php'; |
|
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | |
@@ -727,29 +727,29 @@ discard block |
||
| 727 | 727 | |
| 728 | 728 | case substr($name, -strlen('SetClassName')) === 'SetClassName': |
| 729 | 729 | $setName = substr($name, 0, strlen($name) - strlen('ClassName')); |
| 730 | - return $this->classPrefix . $setName; |
|
| 730 | + return $this->classPrefix.$setName; |
|
| 731 | 731 | |
| 732 | 732 | case substr($name, -strlen('ClassName')) === 'ClassName': |
| 733 | 733 | $recordName = substr($name, 0, strlen($name) - strlen('ClassName')); |
| 734 | - return $this->classPrefix . $recordName; |
|
| 734 | + return $this->classPrefix.$recordName; |
|
| 735 | 735 | |
| 736 | 736 | case substr($name, 0, strlen('include')) === 'include' && substr($name, -strlen('Set')) === 'Set': |
| 737 | 737 | $fileNameBase = strtolower(substr(substr($name, 0, strlen($name) - strlen('Set')), strlen('include'))); |
| 738 | - require_once PHP_SET_PATH . $fileNameBase . '.class.php'; |
|
| 738 | + require_once PHP_SET_PATH.$fileNameBase.'.class.php'; |
|
| 739 | 739 | return; |
| 740 | 740 | |
| 741 | 741 | case substr($name, -strlen('Set')) === 'Set': |
| 742 | - $includeMethod = 'include' . $name; |
|
| 742 | + $includeMethod = 'include'.$name; |
|
| 743 | 743 | $this->$includeMethod(); |
| 744 | - $setClassNameMethod = $name . 'ClassName'; |
|
| 744 | + $setClassNameMethod = $name.'ClassName'; |
|
| 745 | 745 | $className = $this->$setClassNameMethod(); |
| 746 | 746 | $set = new $className($this); |
| 747 | 747 | return $set; |
| 748 | 748 | |
| 749 | 749 | //case method_exists($this, $name . 'Set'): |
| 750 | 750 | default: |
| 751 | - $setName = $name . 'Set'; |
|
| 752 | - $recordClassNameMethod = $name . 'ClassName'; |
|
| 751 | + $setName = $name.'Set'; |
|
| 752 | + $recordClassNameMethod = $name.'ClassName'; |
|
| 753 | 753 | $recordClassName = $this->$recordClassNameMethod(); |
| 754 | 754 | if (isset($arguments[0])) { |
| 755 | 755 | if ($arguments[0] instanceof $recordClassName) { |
@@ -318,9 +318,9 @@ discard block |
||
| 318 | 318 | if (is_array($parameters)) { |
| 319 | 319 | $params = array(); |
| 320 | 320 | foreach ($parameters as $key => $value) { |
| 321 | - $params[] = $key . '=' . $value; |
|
| 321 | + $params[] = $key.'='.$value; |
|
| 322 | 322 | } |
| 323 | - $rawField .= ':' . implode(';', $params); |
|
| 323 | + $rawField .= ':'.implode(';', $params); |
|
| 324 | 324 | } |
| 325 | 325 | array_push($rawFields, $rawField); |
| 326 | 326 | $this->fields = implode(',', $rawFields); |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | if (empty($rawField)) { |
| 340 | 340 | continue; |
| 341 | 341 | } |
| 342 | - list($fieldName, ) = explode(':', $rawField); |
|
| 342 | + list($fieldName,) = explode(':', $rawField); |
|
| 343 | 343 | |
| 344 | 344 | if ($removedFieldName == $fieldName) { |
| 345 | 345 | continue; |
@@ -46,72 +46,72 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * @param Func_App $App |
| 48 | 48 | */ |
| 49 | - public function __construct(Func_App $App) |
|
| 50 | - { |
|
| 51 | - parent::__construct($App); |
|
| 52 | - |
|
| 53 | - $this->setDescription('Custom field'); |
|
| 54 | - |
|
| 55 | - $this->setPrimaryKey('id'); |
|
| 56 | - |
|
| 57 | - $this->addFields( |
|
| 58 | - ORM_StringField('name') |
|
| 59 | - ->setDescription('Name of field used for display'), |
|
| 60 | - ORM_StringField('fieldname') |
|
| 61 | - ->setDescription('Name of field used in table, not modifiable'), |
|
| 62 | - ORM_TextField('description') |
|
| 63 | - ->setDescription('Optional description'), |
|
| 64 | - ORM_EnumField('object', $this->getObjects()) |
|
| 65 | - ->setDescription('Name of object in App ex : Article, Contact, Organization...'), |
|
| 66 | - ORM_EnumField('fieldtype', $this->getFieldTypes()) |
|
| 67 | - ->setDescription('Name of ORM field ex : Enum, String, Text, Bool...'), |
|
| 68 | - ORM_TextField('enumvalues') |
|
| 69 | - ->setDescription('serialized array of values for enum fields'), |
|
| 70 | - ORM_BoolField('mandatory') |
|
| 71 | - ->setDescription('Mandatory') |
|
| 72 | - ); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * List of objects where custom fields are applicable. |
|
| 79 | - * |
|
| 80 | - * @return string[] |
|
| 81 | - */ |
|
| 82 | - public function getObjects() |
|
| 83 | - { |
|
| 84 | - $App = $this->App(); |
|
| 85 | - |
|
| 86 | - $arr = array(); |
|
| 87 | - |
|
| 88 | - if (isset($App->Article)) { |
|
| 89 | - $arr['Article'] = $App->translate('Products database'); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - return $arr; |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * list of ORM fields to use for a custom field |
|
| 97 | - */ |
|
| 98 | - public function getFieldTypes() |
|
| 99 | - { |
|
| 100 | - $App = $this->App(); |
|
| 101 | - |
|
| 102 | - return array( |
|
| 103 | - 'String' => $App->translate('Line edit'), |
|
| 104 | - 'Text' => $App->translate('Text edit'), |
|
| 105 | - 'Bool' => $App->translate('Checkbox'), |
|
| 106 | - 'Int' => $App->translate('Integer number'), |
|
| 107 | - 'Decimal' => $App->translate('Decimal number'), |
|
| 108 | - 'Date' => $App->translate('Date'), |
|
| 109 | - 'DateTime' => $App->translate('Date and time'), |
|
| 110 | - 'Enum' => $App->translate('Selection list'), |
|
| 111 | - 'Url' => $App->translate('Url'), |
|
| 112 | - 'Email' => $App->translate('Email address'), |
|
| 113 | - ); |
|
| 114 | - } |
|
| 49 | + public function __construct(Func_App $App) |
|
| 50 | + { |
|
| 51 | + parent::__construct($App); |
|
| 52 | + |
|
| 53 | + $this->setDescription('Custom field'); |
|
| 54 | + |
|
| 55 | + $this->setPrimaryKey('id'); |
|
| 56 | + |
|
| 57 | + $this->addFields( |
|
| 58 | + ORM_StringField('name') |
|
| 59 | + ->setDescription('Name of field used for display'), |
|
| 60 | + ORM_StringField('fieldname') |
|
| 61 | + ->setDescription('Name of field used in table, not modifiable'), |
|
| 62 | + ORM_TextField('description') |
|
| 63 | + ->setDescription('Optional description'), |
|
| 64 | + ORM_EnumField('object', $this->getObjects()) |
|
| 65 | + ->setDescription('Name of object in App ex : Article, Contact, Organization...'), |
|
| 66 | + ORM_EnumField('fieldtype', $this->getFieldTypes()) |
|
| 67 | + ->setDescription('Name of ORM field ex : Enum, String, Text, Bool...'), |
|
| 68 | + ORM_TextField('enumvalues') |
|
| 69 | + ->setDescription('serialized array of values for enum fields'), |
|
| 70 | + ORM_BoolField('mandatory') |
|
| 71 | + ->setDescription('Mandatory') |
|
| 72 | + ); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * List of objects where custom fields are applicable. |
|
| 79 | + * |
|
| 80 | + * @return string[] |
|
| 81 | + */ |
|
| 82 | + public function getObjects() |
|
| 83 | + { |
|
| 84 | + $App = $this->App(); |
|
| 85 | + |
|
| 86 | + $arr = array(); |
|
| 87 | + |
|
| 88 | + if (isset($App->Article)) { |
|
| 89 | + $arr['Article'] = $App->translate('Products database'); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + return $arr; |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * list of ORM fields to use for a custom field |
|
| 97 | + */ |
|
| 98 | + public function getFieldTypes() |
|
| 99 | + { |
|
| 100 | + $App = $this->App(); |
|
| 101 | + |
|
| 102 | + return array( |
|
| 103 | + 'String' => $App->translate('Line edit'), |
|
| 104 | + 'Text' => $App->translate('Text edit'), |
|
| 105 | + 'Bool' => $App->translate('Checkbox'), |
|
| 106 | + 'Int' => $App->translate('Integer number'), |
|
| 107 | + 'Decimal' => $App->translate('Decimal number'), |
|
| 108 | + 'Date' => $App->translate('Date'), |
|
| 109 | + 'DateTime' => $App->translate('Date and time'), |
|
| 110 | + 'Enum' => $App->translate('Selection list'), |
|
| 111 | + 'Url' => $App->translate('Url'), |
|
| 112 | + 'Email' => $App->translate('Email address'), |
|
| 113 | + ); |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | 116 | /** |
| 117 | 117 | * @return ORM_Criteria |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | case 'Bool': |
| 176 | 176 | $field = ORM_BoolField($this->fieldname); |
| 177 | 177 | $field->setOutputOptions( |
| 178 | - $this->App()->translate('No'), |
|
| 178 | + $this->App()->translate('No'), |
|
| 179 | 179 | $this->App()->translate('Yes') |
| 180 | 180 | ); |
| 181 | 181 | break; |
@@ -192,80 +192,80 @@ discard block |
||
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | |
| 195 | - /** |
|
| 196 | - * @return string[] |
|
| 197 | - */ |
|
| 198 | - public function getEnumValues() |
|
| 199 | - { |
|
| 200 | - return unserialize($this->enumvalues); |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * @return Widget_LabelledWidget |
|
| 206 | - */ |
|
| 207 | - public function getWidget() |
|
| 208 | - { |
|
| 209 | - $W = bab_Widgets(); |
|
| 210 | - $App = $this->App(); |
|
| 211 | - |
|
| 212 | - switch ($this->fieldtype) { |
|
| 213 | - case 'Text': |
|
| 214 | - $widget = $W->TextEdit()->setLines(3)->setColumns(70); |
|
| 215 | - break; |
|
| 216 | - |
|
| 217 | - case 'Bool': |
|
| 218 | - $widget = $W->Checkbox(); |
|
| 219 | - break; |
|
| 220 | - |
|
| 221 | - case 'Enum': |
|
| 222 | - $options = array('' => '') + $this->getEnumValues(); |
|
| 223 | - $widget = $W->Select()->setOptions($options); |
|
| 224 | - break; |
|
| 225 | - |
|
| 226 | - case 'Date': |
|
| 227 | - $widget = $W->DatePicker(); |
|
| 228 | - break; |
|
| 229 | - |
|
| 230 | - case 'DateTime': |
|
| 231 | - $widget = $W->DateTimePicker(); |
|
| 232 | - break; |
|
| 233 | - |
|
| 234 | - case 'Int': |
|
| 235 | - $widget = $W->RegExpLineEdit(); |
|
| 236 | - $widget->setRegExp(Widget_RegExpLineEdit::INT_FORMAT) |
|
| 237 | - ->setSubmitMessage(sprintf($App->translate('The field %s should be a integer number'), $this->name)) |
|
| 238 | - ->setSize(10); |
|
| 239 | - break; |
|
| 240 | - |
|
| 241 | - case 'Decimal': |
|
| 242 | - $widget = $W->RegExpLineEdit(); |
|
| 243 | - $widget->setRegExp(Widget_RegExpLineEdit::FLOAT_FORMAT) |
|
| 244 | - ->setSubmitMessage(sprintf($App->translate('The field %s should be a decimal number'), $this->name)) |
|
| 245 | - ->setSize(10); |
|
| 246 | - break; |
|
| 247 | - |
|
| 248 | - case 'Url': |
|
| 249 | - $widget = $W->UrlLineEdit(); |
|
| 250 | - break; |
|
| 251 | - |
|
| 252 | - case 'Email': |
|
| 253 | - $widget = $W->EmailLineEdit(); |
|
| 254 | - break; |
|
| 255 | - |
|
| 256 | - default: |
|
| 257 | - case 'String': |
|
| 258 | - $widget = $W->LineEdit()->setSize(70)->setMaxSize(255); |
|
| 259 | - break; |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - $labelledItem = $W->LabelledWidget($this->name, $widget, null); |
|
| 263 | - $labelledItem->setName($this->fieldname); |
|
| 264 | - |
|
| 265 | - if (!empty($this->description)) { |
|
| 266 | - $labelledItem->setDescription($this->description); |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - return $labelledItem; |
|
| 270 | - } |
|
| 195 | + /** |
|
| 196 | + * @return string[] |
|
| 197 | + */ |
|
| 198 | + public function getEnumValues() |
|
| 199 | + { |
|
| 200 | + return unserialize($this->enumvalues); |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * @return Widget_LabelledWidget |
|
| 206 | + */ |
|
| 207 | + public function getWidget() |
|
| 208 | + { |
|
| 209 | + $W = bab_Widgets(); |
|
| 210 | + $App = $this->App(); |
|
| 211 | + |
|
| 212 | + switch ($this->fieldtype) { |
|
| 213 | + case 'Text': |
|
| 214 | + $widget = $W->TextEdit()->setLines(3)->setColumns(70); |
|
| 215 | + break; |
|
| 216 | + |
|
| 217 | + case 'Bool': |
|
| 218 | + $widget = $W->Checkbox(); |
|
| 219 | + break; |
|
| 220 | + |
|
| 221 | + case 'Enum': |
|
| 222 | + $options = array('' => '') + $this->getEnumValues(); |
|
| 223 | + $widget = $W->Select()->setOptions($options); |
|
| 224 | + break; |
|
| 225 | + |
|
| 226 | + case 'Date': |
|
| 227 | + $widget = $W->DatePicker(); |
|
| 228 | + break; |
|
| 229 | + |
|
| 230 | + case 'DateTime': |
|
| 231 | + $widget = $W->DateTimePicker(); |
|
| 232 | + break; |
|
| 233 | + |
|
| 234 | + case 'Int': |
|
| 235 | + $widget = $W->RegExpLineEdit(); |
|
| 236 | + $widget->setRegExp(Widget_RegExpLineEdit::INT_FORMAT) |
|
| 237 | + ->setSubmitMessage(sprintf($App->translate('The field %s should be a integer number'), $this->name)) |
|
| 238 | + ->setSize(10); |
|
| 239 | + break; |
|
| 240 | + |
|
| 241 | + case 'Decimal': |
|
| 242 | + $widget = $W->RegExpLineEdit(); |
|
| 243 | + $widget->setRegExp(Widget_RegExpLineEdit::FLOAT_FORMAT) |
|
| 244 | + ->setSubmitMessage(sprintf($App->translate('The field %s should be a decimal number'), $this->name)) |
|
| 245 | + ->setSize(10); |
|
| 246 | + break; |
|
| 247 | + |
|
| 248 | + case 'Url': |
|
| 249 | + $widget = $W->UrlLineEdit(); |
|
| 250 | + break; |
|
| 251 | + |
|
| 252 | + case 'Email': |
|
| 253 | + $widget = $W->EmailLineEdit(); |
|
| 254 | + break; |
|
| 255 | + |
|
| 256 | + default: |
|
| 257 | + case 'String': |
|
| 258 | + $widget = $W->LineEdit()->setSize(70)->setMaxSize(255); |
|
| 259 | + break; |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + $labelledItem = $W->LabelledWidget($this->name, $widget, null); |
|
| 263 | + $labelledItem->setName($this->fieldname); |
|
| 264 | + |
|
| 265 | + if (!empty($this->description)) { |
|
| 266 | + $labelledItem->setDescription($this->description); |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + return $labelledItem; |
|
| 270 | + } |
|
| 271 | 271 | } |