@@ -21,10 +21,10 @@ 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 $GLOBALS['babInstallPath'] . 'utilit/json.php'; |
|
| 24 | +require_once $GLOBALS['babInstallPath'].'utilit/controller.class.php'; |
|
| 25 | +require_once $GLOBALS['babInstallPath'].'utilit/json.php'; |
|
| 26 | 26 | |
| 27 | -require_once dirname(__FILE__). '/functions.php'; |
|
| 27 | +require_once dirname(__FILE__).'/functions.php'; |
|
| 28 | 28 | |
| 29 | 29 | $App = app_App(); |
| 30 | 30 | if ($App) { |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | { |
| 37 | 37 | public function __construct($action, $code = 0) |
| 38 | 38 | { |
| 39 | - $message = 'Unknown method "' . $action->getController() . '::' . $action->getMethod() . '"'; |
|
| 39 | + $message = 'Unknown method "'.$action->getController().'::'.$action->getMethod().'"'; |
|
| 40 | 40 | parent::__construct($message, $code); |
| 41 | 41 | } |
| 42 | 42 | } |
@@ -201,11 +201,11 @@ discard block |
||
| 201 | 201 | // we try to select one according to the classname prefix. |
| 202 | 202 | list($prefix) = explode('_', __CLASS__); |
| 203 | 203 | $functionalityName = ucwords($prefix); |
| 204 | - $App = @bab_functionality::get('App/' . $functionalityName); |
|
| 204 | + $App = @bab_functionality::get('App/'.$functionalityName); |
|
| 205 | 205 | |
| 206 | 206 | if (!$App) |
| 207 | 207 | { |
| 208 | - throw new app_Exception('Faild to autodetect functionality App/' . $functionalityName.', the getInstance method is deprecated, use $App->ControllerProxy() instead'); |
|
| 208 | + throw new app_Exception('Faild to autodetect functionality App/'.$functionalityName.', the getInstance method is deprecated, use $App->ControllerProxy() instead'); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | $controller = $App->ControllerProxy($classname, $proxy); |
@@ -224,9 +224,9 @@ discard block |
||
| 224 | 224 | static function getProxyInstance(Func_App $App, $classname) |
| 225 | 225 | { |
| 226 | 226 | $class = new ReflectionClass($classname); |
| 227 | - $proxyClassname = $class->getShortName() . self::PROXY_CLASS_SUFFIX; |
|
| 227 | + $proxyClassname = $class->getShortName().self::PROXY_CLASS_SUFFIX; |
|
| 228 | 228 | if (!class_exists($proxyClassname)) { |
| 229 | - $classStr = 'class ' . $proxyClassname . ' extends ' . $class->name . ' {' . "\n"; |
|
| 229 | + $classStr = 'class '.$proxyClassname.' extends '.$class->name.' {'."\n"; |
|
| 230 | 230 | $methods = $class->getMethods(); |
| 231 | 231 | |
| 232 | 232 | $classStr .= ' public function __construct(Func_App $App) { |
@@ -239,24 +239,24 @@ discard block |
||
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | |
| 242 | - $classStr .= ' public function ' . $method->name . '('; |
|
| 242 | + $classStr .= ' public function '.$method->name.'('; |
|
| 243 | 243 | $parameters = $method->getParameters(); |
| 244 | 244 | $parametersStr = array(); |
| 245 | 245 | foreach ($parameters as $parameter) { |
| 246 | 246 | |
| 247 | 247 | if ($parameter->isDefaultValueAvailable()) { |
| 248 | - $parametersStr[] = '$' . $parameter->name . ' = ' . var_export($parameter->getDefaultValue(), true); |
|
| 248 | + $parametersStr[] = '$'.$parameter->name.' = '.var_export($parameter->getDefaultValue(), true); |
|
| 249 | 249 | } else { |
| 250 | - $parametersStr[] = '$' . $parameter->name; |
|
| 250 | + $parametersStr[] = '$'.$parameter->name; |
|
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | 253 | $classStr .= implode(', ', $parametersStr); |
| 254 | - $classStr .= ') {' . "\n"; |
|
| 255 | - $classStr .= ' $args = func_get_args();' . "\n"; |
|
| 256 | - $classStr .= ' return $this->getMethodAction(__FUNCTION__, $args);' . "\n"; |
|
| 257 | - $classStr .= ' }' . "\n"; |
|
| 254 | + $classStr .= ') {'."\n"; |
|
| 255 | + $classStr .= ' $args = func_get_args();'."\n"; |
|
| 256 | + $classStr .= ' return $this->getMethodAction(__FUNCTION__, $args);'."\n"; |
|
| 257 | + $classStr .= ' }'."\n"; |
|
| 258 | 258 | } |
| 259 | - $classStr .= '}' . "\n"; |
|
| 259 | + $classStr .= '}'."\n"; |
|
| 260 | 260 | |
| 261 | 261 | // We define the proxy class |
| 262 | 262 | eval($classStr); |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | protected function getObjectName($classname) |
| 298 | 298 | { |
| 299 | 299 | list($objectname) = explode('Controller', $classname); |
| 300 | - if($this->App()->getComponentByName($objectname)){ |
|
| 300 | + if ($this->App()->getComponentByName($objectname)) { |
|
| 301 | 301 | return strtolower($objectname); |
| 302 | 302 | } |
| 303 | 303 | list(, $objectname) = explode('_Ctrl', $classname); |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | |
| 320 | 320 | $reflector = new ReflectionClass(get_class($this)); |
| 321 | 321 | $parent = $reflector->getParentClass(); |
| 322 | - if($parent){ |
|
| 322 | + if ($parent) { |
|
| 323 | 323 | $parentMethod = $parent->getMethod('__construct'); |
| 324 | 324 | $docComment = $parentMethod->getDocComment(); |
| 325 | 325 | if (strpos($docComment, '@isComponentController') !== false) { |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | $rc = new ReflectionClass($fullClassName); |
| 331 | 331 | |
| 332 | 332 | if (!$rc->hasMethod($methodName)) { |
| 333 | - throw new bab_InvalidActionException($fullClassName . '::' . $methodName); |
|
| 333 | + throw new bab_InvalidActionException($fullClassName.'::'.$methodName); |
|
| 334 | 334 | } |
| 335 | 335 | $method = new ReflectionMethod($fullClassName, $methodName); |
| 336 | 336 | |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | |
| 354 | 354 | $action = new Widget_Action(); |
| 355 | 355 | |
| 356 | - $action->setMethod($this->getControllerTg(), $objectName . '.' . $methodName, $actionParams); |
|
| 356 | + $action->setMethod($this->getControllerTg(), $objectName.'.'.$methodName, $actionParams); |
|
| 357 | 357 | |
| 358 | 358 | $docComment = $method->getDocComment(); |
| 359 | 359 | if (strpos($docComment, '@ajax') !== false) { |
@@ -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); |
@@ -420,24 +420,24 @@ discard block |
||
| 420 | 420 | return false; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - list($objectName, ) = explode('.', $method); |
|
| 423 | + list($objectName,) = explode('.', $method); |
|
| 424 | 424 | |
| 425 | 425 | if (!method_exists($this, $objectName)) { |
| 426 | 426 | /* @var $component app_Component */ |
| 427 | 427 | $component = $this->app->getComponentByName(ucfirst($objectName)); |
| 428 | - if($component){ |
|
| 428 | + if ($component) { |
|
| 429 | 429 | $this->app->setCurrentComponent($component); |
| 430 | 430 | $objectController = $component->controller(false); |
| 431 | 431 | } |
| 432 | - else{ |
|
| 432 | + else { |
|
| 433 | 433 | header('HTTP/1.0 400 Bad Request'); |
| 434 | 434 | throw new app_UnknownActionException($action); |
| 435 | 435 | } |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - if(!isset($component)){ |
|
| 438 | + if (!isset($component)) { |
|
| 439 | 439 | $objectController = $this->{$objectName}(false); |
| 440 | - if ( ! ($objectController instanceof app_Controller)) { |
|
| 440 | + if (!($objectController instanceof app_Controller)) { |
|
| 441 | 441 | return false; |
| 442 | 442 | } |
| 443 | 443 | } |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | } else { |
| 452 | 452 | if ($this->isAjaxRequest()) { |
| 453 | 453 | |
| 454 | - header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); |
|
| 454 | + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden', true, 403); |
|
| 455 | 455 | |
| 456 | 456 | die( |
| 457 | 457 | bab_json_encode( |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | } catch (app_SaveException $e) { |
| 473 | 473 | |
| 474 | 474 | if ($this->isAjaxRequest()) { |
| 475 | - header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); |
|
| 475 | + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden', true, 403); |
|
| 476 | 476 | header('Cache-Control: no-cache, must-revalidate'); |
| 477 | 477 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
| 478 | 478 | header('Content-type: application/json'); |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | if (method_exists($htmlCanvas, 'sendPageTitle')) { |
| 528 | 528 | $htmlCanvas->sendPageTitle($pageTitle); |
| 529 | 529 | } else { |
| 530 | - header('X-Cto-PageTitle: ' . $pageTitle); |
|
| 530 | + header('X-Cto-PageTitle: '.$pageTitle); |
|
| 531 | 531 | } |
| 532 | 532 | } |
| 533 | 533 | $html = $returnedValue->display($htmlCanvas); |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | private function deletedItemPage(Widget_Action $action, app_DeletedRecordException $e) |
| 587 | 587 | { |
| 588 | 588 | if ($this->isAjaxRequest()) { |
| 589 | - header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); |
|
| 589 | + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden', true, 403); |
|
| 590 | 590 | header('Cache-Control: no-cache, must-revalidate'); |
| 591 | 591 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
| 592 | 592 | header('Content-type: application/json'); |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | ); |
| 604 | 604 | |
| 605 | 605 | } |
| 606 | - header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true, 404); |
|
| 606 | + header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found', true, 404); |
|
| 607 | 607 | |
| 608 | 608 | $App = $this->App(); |
| 609 | 609 | $W = bab_Widgets(); |
@@ -637,7 +637,7 @@ discard block |
||
| 637 | 637 | private function notFoundPage(Widget_Action $action, app_NotFoundException $e) |
| 638 | 638 | { |
| 639 | 639 | if ($this->isAjaxRequest()) { |
| 640 | - $message = sprintf(app_translate('This %s does not exists'), $e->getObjectTitle() . ' (' . $e->getId() . ')'); |
|
| 640 | + $message = sprintf(app_translate('This %s does not exists'), $e->getObjectTitle().' ('.$e->getId().')'); |
|
| 641 | 641 | $json = array( |
| 642 | 642 | 'messages' => array( |
| 643 | 643 | array( |
@@ -649,7 +649,7 @@ discard block |
||
| 649 | 649 | echo bab_json_encode($json); |
| 650 | 650 | die; |
| 651 | 651 | } |
| 652 | - header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true, 404); |
|
| 652 | + header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found', true, 404); |
|
| 653 | 653 | header('Cache-Control: no-cache, must-revalidate'); |
| 654 | 654 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
| 655 | 655 | |
@@ -669,14 +669,14 @@ discard block |
||
| 669 | 669 | |
| 670 | 670 | private function errorPage(Exception $e) |
| 671 | 671 | { |
| 672 | - header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal server error', true, 500); |
|
| 672 | + header($_SERVER['SERVER_PROTOCOL'].' 500 Internal server error', true, 500); |
|
| 673 | 673 | |
| 674 | - require_once $GLOBALS['babInstallPath'] . 'utilit/uiutil.php'; |
|
| 674 | + require_once $GLOBALS['babInstallPath'].'utilit/uiutil.php'; |
|
| 675 | 675 | $popup = new babBodyPopup(); |
| 676 | 676 | $popup->babEcho( |
| 677 | - '<h1>' . $this->App()->translate('There was a problem when trying to perform this operation') . '</h1>' |
|
| 678 | - . '<h2 class="error">' . $this->App()->translate('Additional debugging information:') . '</h2>' |
|
| 679 | - . '<p class="error">' . $e->getMessage() . ' ' . $e->getFile() . ' ' . $e->getLine() . ' ' . $e->getTraceAsString() . '</p>' |
|
| 677 | + '<h1>'.$this->App()->translate('There was a problem when trying to perform this operation').'</h1>' |
|
| 678 | + . '<h2 class="error">'.$this->App()->translate('Additional debugging information:').'</h2>' |
|
| 679 | + . '<p class="error">'.$e->getMessage().' '.$e->getFile().' '.$e->getLine().' '.$e->getTraceAsString().'</p>' |
|
| 680 | 680 | ); |
| 681 | 681 | |
| 682 | 682 | |
@@ -721,7 +721,7 @@ discard block |
||
| 721 | 721 | */ |
| 722 | 722 | public function CustomField($proxy = true) |
| 723 | 723 | { |
| 724 | - require_once APP_CTRL_PATH . 'customfield.ctrl.php'; |
|
| 724 | + require_once APP_CTRL_PATH.'customfield.ctrl.php'; |
|
| 725 | 725 | return $this->App()->ControllerProxy('app_CtrlCustomField', $proxy); |
| 726 | 726 | } |
| 727 | 727 | |
@@ -732,7 +732,7 @@ discard block |
||
| 732 | 732 | */ |
| 733 | 733 | public function CustomSection($proxy = true) |
| 734 | 734 | { |
| 735 | - require_once APP_CTRL_PATH . 'customsection.ctrl.php'; |
|
| 735 | + require_once APP_CTRL_PATH.'customsection.ctrl.php'; |
|
| 736 | 736 | return $this->App()->ControllerProxy('app_CtrlCustomSection', $proxy); |
| 737 | 737 | } |
| 738 | 738 | } |
@@ -428,8 +428,7 @@ |
||
| 428 | 428 | if($component){ |
| 429 | 429 | $this->app->setCurrentComponent($component); |
| 430 | 430 | $objectController = $component->controller(false); |
| 431 | - } |
|
| 432 | - else{ |
|
| 431 | + } else{ |
|
| 433 | 432 | header('HTTP/1.0 400 Bad Request'); |
| 434 | 433 | throw new app_UnknownActionException($action); |
| 435 | 434 | } |
@@ -86,122 +86,122 @@ |
||
| 86 | 86 | |
| 87 | 87 | |
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * @return Widget_Page |
|
| 91 | - */ |
|
| 92 | - public function edit($customfield = null) |
|
| 93 | - {
|
|
| 94 | - $W = bab_Widgets(); |
|
| 95 | - $App = $this->App(); |
|
| 96 | - $Ui = $App->Ui(); |
|
| 97 | - $page = $Ui->Page(); |
|
| 89 | + /** |
|
| 90 | + * @return Widget_Page |
|
| 91 | + */ |
|
| 92 | + public function edit($customfield = null) |
|
| 93 | + {
|
|
| 94 | + $W = bab_Widgets(); |
|
| 95 | + $App = $this->App(); |
|
| 96 | + $Ui = $App->Ui(); |
|
| 97 | + $page = $Ui->Page(); |
|
| 98 | 98 | |
| 99 | - $page->addClass('app-page-editor');
|
|
| 100 | - $page->setTitle($App->translate('Edit custom field'));
|
|
| 99 | + $page->addClass('app-page-editor');
|
|
| 100 | + $page->setTitle($App->translate('Edit custom field'));
|
|
| 101 | 101 | |
| 102 | - if (null !== $customfield) {
|
|
| 103 | - $set = $App->CustomFieldSet(); |
|
| 104 | - $customfield = $set->request($customfield); |
|
| 105 | - } |
|
| 102 | + if (null !== $customfield) {
|
|
| 103 | + $set = $App->CustomFieldSet(); |
|
| 104 | + $customfield = $set->request($customfield); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - $form = $Ui->CustomFieldEditor($customfield); |
|
| 107 | + $form = $Ui->CustomFieldEditor($customfield); |
|
| 108 | 108 | |
| 109 | - $page->addItem($form); |
|
| 109 | + $page->addItem($form); |
|
| 110 | 110 | |
| 111 | - if ($customfield instanceof app_CustomField) {
|
|
| 112 | - $actionsFrame = $page->ActionsFrame(); |
|
| 113 | - $page->addContextItem($actionsFrame); |
|
| 111 | + if ($customfield instanceof app_CustomField) {
|
|
| 112 | + $actionsFrame = $page->ActionsFrame(); |
|
| 113 | + $page->addContextItem($actionsFrame); |
|
| 114 | 114 | |
| 115 | - $actionsFrame->addItem($W->Link($W->Icon($App->translate('Delete'), Func_Icons::ACTIONS_EDIT_DELETE), $this->proxy()->delete($customfield->id)));
|
|
| 116 | - } |
|
| 115 | + $actionsFrame->addItem($W->Link($W->Icon($App->translate('Delete'), Func_Icons::ACTIONS_EDIT_DELETE), $this->proxy()->delete($customfield->id)));
|
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - return $page; |
|
| 119 | - } |
|
| 118 | + return $page; |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | 121 | |
| 122 | - /** |
|
| 123 | - * @return bool |
|
| 124 | - */ |
|
| 125 | - public function save($customfield = null) |
|
| 126 | - {
|
|
| 127 | - $App = $this->App(); |
|
| 122 | + /** |
|
| 123 | + * @return bool |
|
| 124 | + */ |
|
| 125 | + public function save($customfield = null) |
|
| 126 | + {
|
|
| 127 | + $App = $this->App(); |
|
| 128 | 128 | |
| 129 | - $set = $App->CustomFieldSet(); |
|
| 129 | + $set = $App->CustomFieldSet(); |
|
| 130 | 130 | |
| 131 | - if (empty($customfield['id'])) {
|
|
| 132 | - $record = $set->newRecord(); |
|
| 133 | - } else {
|
|
| 134 | - $record = $set->get($customfield['id']); |
|
| 135 | - } |
|
| 131 | + if (empty($customfield['id'])) {
|
|
| 132 | + $record = $set->newRecord(); |
|
| 133 | + } else {
|
|
| 134 | + $record = $set->get($customfield['id']); |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - if ('Enum' === $customfield['fieldtype'] || 'Set' === $customfield['fieldtype']) {
|
|
| 138 | - $enumvalues = array(); |
|
| 139 | - foreach ($customfield['enumvalues'] as $enumkey => $enumvalue) {
|
|
| 140 | - $enumvalues[$enumkey] = $set->enumvalues->input($enumvalue); |
|
| 141 | - } |
|
| 142 | - $record->enumvalues = serialize($enumvalues); |
|
| 143 | - } else {
|
|
| 144 | - $record->enumvalues = ''; |
|
| 145 | - } |
|
| 137 | + if ('Enum' === $customfield['fieldtype'] || 'Set' === $customfield['fieldtype']) {
|
|
| 138 | + $enumvalues = array(); |
|
| 139 | + foreach ($customfield['enumvalues'] as $enumkey => $enumvalue) {
|
|
| 140 | + $enumvalues[$enumkey] = $set->enumvalues->input($enumvalue); |
|
| 141 | + } |
|
| 142 | + $record->enumvalues = serialize($enumvalues); |
|
| 143 | + } else {
|
|
| 144 | + $record->enumvalues = ''; |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - unset($customfield['enumvalues']); |
|
| 148 | - $record->setFormInputValues($customfield); |
|
| 147 | + unset($customfield['enumvalues']); |
|
| 148 | + $record->setFormInputValues($customfield); |
|
| 149 | 149 | |
| 150 | - $record->save(); |
|
| 150 | + $record->save(); |
|
| 151 | 151 | |
| 152 | - // refresh target table structure |
|
| 152 | + // refresh target table structure |
|
| 153 | 153 | |
| 154 | - $object = $record->object.'Set'; |
|
| 155 | - $mysqlbackend = new ORM_MySqlBackend($GLOBALS['babDB']); |
|
| 154 | + $object = $record->object.'Set'; |
|
| 155 | + $mysqlbackend = new ORM_MySqlBackend($GLOBALS['babDB']); |
|
| 156 | 156 | |
| 157 | - $recordSet = $App->$object(); |
|
| 158 | - if (method_exists($recordSet, 'useLang')) {
|
|
| 159 | - // This is necessary if the recordSet constructor uses a setLang(). |
|
| 160 | - // We need to revert to multilang fields before synchronizing. |
|
| 161 | - $recordSet->useLang(false); |
|
| 162 | - } |
|
| 157 | + $recordSet = $App->$object(); |
|
| 158 | + if (method_exists($recordSet, 'useLang')) {
|
|
| 159 | + // This is necessary if the recordSet constructor uses a setLang(). |
|
| 160 | + // We need to revert to multilang fields before synchronizing. |
|
| 161 | + $recordSet->useLang(false); |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - $sql = $mysqlbackend->setToSql($recordSet); |
|
| 164 | + $sql = $mysqlbackend->setToSql($recordSet); |
|
| 165 | 165 | |
| 166 | - require_once $GLOBALS['babInstallPath'].'utilit/devtools.php'; |
|
| 167 | - $synchronize = new bab_synchronizeSql(); |
|
| 168 | - $synchronize->fromSqlString($sql); |
|
| 166 | + require_once $GLOBALS['babInstallPath'].'utilit/devtools.php'; |
|
| 167 | + $synchronize = new bab_synchronizeSql(); |
|
| 168 | + $synchronize->fromSqlString($sql); |
|
| 169 | 169 | |
| 170 | - return true; |
|
| 171 | - } |
|
| 170 | + return true; |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | 173 | |
| 174 | 174 | /** |
| 175 | 175 | * {@inheritDoc}
|
| 176 | 176 | * @see app_CtrlRecord::delete() |
| 177 | 177 | */ |
| 178 | - public function delete($customfield) |
|
| 179 | - {
|
|
| 180 | - $App = $this->App(); |
|
| 181 | - |
|
| 182 | - if (!$customfield) {
|
|
| 183 | - throw new app_AccessException($App->translate('Access denied'));
|
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - $set = $App->CustomFieldSet(); |
|
| 187 | - $record = $set->request($customfield); |
|
| 188 | - $object = $record->object.'Set'; |
|
| 189 | - $set->delete($set->id->is($customfield)); |
|
| 190 | - |
|
| 191 | - $recordSet = $App->$object(); |
|
| 192 | - if (method_exists($recordSet, 'useLang')) {
|
|
| 193 | - // This is necessary if the recordSet constructor uses a setLang(). |
|
| 194 | - // We need to revert to multilang fields before synchronizing. |
|
| 195 | - $recordSet->useLang(false); |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - $mysqlbackend = new ORM_MySqlBackend($GLOBALS['babDB']); |
|
| 199 | - $sql = $mysqlbackend->setToSql($recordSet); |
|
| 200 | - |
|
| 201 | - require_once $GLOBALS['babInstallPath'].'utilit/devtools.php'; |
|
| 202 | - $synchronize = new bab_synchronizeSql(); |
|
| 203 | - $synchronize->fromSqlString($sql); |
|
| 204 | - |
|
| 205 | - return true; |
|
| 206 | - } |
|
| 178 | + public function delete($customfield) |
|
| 179 | + {
|
|
| 180 | + $App = $this->App(); |
|
| 181 | + |
|
| 182 | + if (!$customfield) {
|
|
| 183 | + throw new app_AccessException($App->translate('Access denied'));
|
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + $set = $App->CustomFieldSet(); |
|
| 187 | + $record = $set->request($customfield); |
|
| 188 | + $object = $record->object.'Set'; |
|
| 189 | + $set->delete($set->id->is($customfield)); |
|
| 190 | + |
|
| 191 | + $recordSet = $App->$object(); |
|
| 192 | + if (method_exists($recordSet, 'useLang')) {
|
|
| 193 | + // This is necessary if the recordSet constructor uses a setLang(). |
|
| 194 | + // We need to revert to multilang fields before synchronizing. |
|
| 195 | + $recordSet->useLang(false); |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + $mysqlbackend = new ORM_MySqlBackend($GLOBALS['babDB']); |
|
| 199 | + $sql = $mysqlbackend->setToSql($recordSet); |
|
| 200 | + |
|
| 201 | + require_once $GLOBALS['babInstallPath'].'utilit/devtools.php'; |
|
| 202 | + $synchronize = new bab_synchronizeSql(); |
|
| 203 | + $synchronize->fromSqlString($sql); |
|
| 204 | + |
|
| 205 | + return true; |
|
| 206 | + } |
|
| 207 | 207 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @copyright Copyright (c) 2008 by CANTICO ({@link http://www.cantico.fr})
|
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | -require_once APP_CTRL_PATH . '/record.ctrl.php'; |
|
| 24 | +require_once APP_CTRL_PATH.'/record.ctrl.php'; |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * This controller manages actions that can be performed on custom fields |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | $W->Link( |
| 40 | 40 | $App->translate('Add a custom field'),
|
| 41 | 41 | $this->proxy()->edit() |
| 42 | - )->addClass('icon', Func_Icons::ACTIONS_LIST_ADD)
|
|
| 42 | + )->addClass('icon', Func_Icons::ACTIONS_LIST_ADD)
|
|
| 43 | 43 | ->setOpenMode(Widget_Link::OPEN_DIALOG_AND_RELOAD) |
| 44 | 44 | ); |
| 45 | 45 | |
@@ -119,7 +119,7 @@ |
||
| 119 | 119 | throw new app_SaveException($this->App()->translate('The name is mandatory'));
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - return '_' . $name; |
|
| 122 | + return '_'.$name; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | { |
| 192 | 192 | $App = $this->App(); |
| 193 | 193 | |
| 194 | - $customFieldSet= $App->CustomFieldSet(); |
|
| 194 | + $customFieldSet = $App->CustomFieldSet(); |
|
| 195 | 195 | $object = mb_substr(get_class($this), mb_strlen($App->classPrefix), -mb_strlen('Set')); |
| 196 | 196 | |
| 197 | 197 | $customFields = $customFieldSet->select($customFieldSet->object->is($object)); |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | |
| 318 | 318 | $linkSet->hasOne('sourceId', get_class($this)); |
| 319 | 319 | |
| 320 | - $criteria = $linkSet->targetClass->is(get_class($target)) |
|
| 320 | + $criteria = $linkSet->targetClass->is(get_class($target)) |
|
| 321 | 321 | ->_AND_($linkSet->targetId->is($target->id)) |
| 322 | 322 | ->_AND_($linkSet->sourceClass->is($this->getRecordClassName())); |
| 323 | 323 | if (isset($linkType)) { |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | |
| 348 | 348 | $linkSet->hasOne('targetId', get_class($this)); |
| 349 | 349 | |
| 350 | - $criteria = $linkSet->sourceClass->is(get_class($source)) |
|
| 350 | + $criteria = $linkSet->sourceClass->is(get_class($source)) |
|
| 351 | 351 | ->_AND_($linkSet->sourceId->is($source->id)) |
| 352 | 352 | ->_AND_($linkSet->targetClass->is($this->getRecordClassName())); |
| 353 | 353 | if (isset($linkType)) { |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | $sourcesCriteria[] = $linkSet->sourceClass->is($sourceClass)->_AND_($linkSet->sourceId->in($sourceIds)); |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | - $criteria = $linkSet->all( |
|
| 394 | + $criteria = $linkSet->all( |
|
| 395 | 395 | $linkSet->targetClass->is($this->getRecordClassName()), |
| 396 | 396 | $linkSet->any($sourcesCriteria) |
| 397 | 397 | ); |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | $targetsCriteria[] = $linkSet->targetClass->is($targetClass)->_AND_($linkSet->targetId->in($targetIds)); |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | - $criteria = $linkSet->all( |
|
| 439 | + $criteria = $linkSet->all( |
|
| 440 | 440 | $linkSet->sourceClass->is($this->getRecordClassName()), |
| 441 | 441 | $linkSet->any($targetsCriteria) |
| 442 | 442 | ); |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | $App = $this->App(); |
| 674 | 674 | $rClass = new ReflectionClass(get_class($this)); |
| 675 | 675 | $component = $App->getComponentByName($rClass->getShortName()); |
| 676 | - if(isset($component)){ |
|
| 676 | + if (isset($component)) { |
|
| 677 | 677 | return $component->getRecordClassName(); |
| 678 | 678 | // list(, $classname) = explode('_', $component->getRecordClassName()); |
| 679 | 679 | // return $classname; |
@@ -694,7 +694,7 @@ discard block |
||
| 694 | 694 | throw new app_Exception('Trying to get the reference string of a record without an id.'); |
| 695 | 695 | } |
| 696 | 696 | $classname = $this->getClassName(); |
| 697 | - return $classname . ':' . $this->id; |
|
| 697 | + return $classname.':'.$this->id; |
|
| 698 | 698 | } |
| 699 | 699 | |
| 700 | 700 | |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | { |
| 935 | 935 | $linkSet = $this->App()->LinkSet(); |
| 936 | 936 | |
| 937 | - $criteria = $linkSet->sourceClass->is(get_class($source)) |
|
| 937 | + $criteria = $linkSet->sourceClass->is(get_class($source)) |
|
| 938 | 938 | ->_AND_($linkSet->sourceId->is($source->id)) |
| 939 | 939 | ->_AND_($linkSet->targetClass->is(get_class($this))) |
| 940 | 940 | ->_AND_($linkSet->targetId->is($this->id)); |
@@ -964,7 +964,7 @@ discard block |
||
| 964 | 964 | { |
| 965 | 965 | $linkSet = $this->App()->LinkSet(); |
| 966 | 966 | |
| 967 | - $criteria = $linkSet->all( |
|
| 967 | + $criteria = $linkSet->all( |
|
| 968 | 968 | $linkSet->targetClass->is(get_class($target)), |
| 969 | 969 | $linkSet->targetId->is($target->id), |
| 970 | 970 | $linkSet->sourceClass->is(get_class($this)), |
@@ -1059,13 +1059,13 @@ discard block |
||
| 1059 | 1059 | */ |
| 1060 | 1060 | protected function importDate($name, $value) |
| 1061 | 1061 | { |
| 1062 | - if (preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2}/',$value)) { |
|
| 1062 | + if (preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2}/', $value)) { |
|
| 1063 | 1063 | return $this->importProperty($name, $value); |
| 1064 | 1064 | } |
| 1065 | 1065 | |
| 1066 | 1066 | // try in DD/MM/YYYY format |
| 1067 | 1067 | |
| 1068 | - if (preg_match('/(?P<day>[0-9]+)\/(?P<month>[0-9]+)\/(?P<year>[0-9]{2,4})/',$value, $matches)) { |
|
| 1068 | + if (preg_match('/(?P<day>[0-9]+)\/(?P<month>[0-9]+)\/(?P<year>[0-9]{2,4})/', $value, $matches)) { |
|
| 1069 | 1069 | |
| 1070 | 1070 | $value = sprintf('%04d-%02d-%02d', (int) $matches['year'], (int) $matches['month'], (int) $matches['day']); |
| 1071 | 1071 | |