| @@ -102,7 +102,7 @@ discard block | ||
| 102 | 102 | public function __construct(Func_App $app, $id = null, Widget_Layout $layout = null) | 
| 103 | 103 |      { | 
| 104 | 104 | parent::__construct($app); | 
| 105 | - // We simulate inheritance from Widget_VBoxLayout. | |
| 105 | + // We simulate inheritance from Widget_VBoxLayout. | |
| 106 | 106 | $W = $this->widgets = bab_Widgets(); | 
| 107 | 107 | |
| 108 | 108 | |
| @@ -307,9 +307,9 @@ discard block | ||
| 307 | 307 |              $cancelLabel = isset($this->cancelLabel) ? $this->cancelLabel : $App->translate('Cancel'); | 
| 308 | 308 | $this->addButton( | 
| 309 | 309 | $W->SubmitButton(/*'cancel'*/) | 
| 310 | -                     ->addClass('widget-close-dialog') | |
| 310 | +                        ->addClass('widget-close-dialog') | |
| 311 | 311 | ->setAction($this->cancelAction) | 
| 312 | - ->setLabel($cancelLabel) | |
| 312 | + ->setLabel($cancelLabel) | |
| 313 | 313 | ); | 
| 314 | 314 | } | 
| 315 | 315 | |
| @@ -1148,21 +1148,21 @@ discard block | ||
| 1148 | 1148 | |
| 1149 | 1149 | |
| 1150 | 1150 | |
| 1151 | - protected function addCustomFields(app_RecordSet $recordSet) | |
| 1152 | -	{ | |
| 1153 | - $customFields = $recordSet->getCustomFields(); | |
| 1151 | + protected function addCustomFields(app_RecordSet $recordSet) | |
| 1152 | +    { | |
| 1153 | + $customFields = $recordSet->getCustomFields(); | |
| 1154 | 1154 | |
| 1155 | 1155 |          foreach ($customFields as $customField) { | 
| 1156 | 1156 | $fieldname = $customField->fieldname; | 
| 1157 | 1157 | $this->addColumn( | 
| 1158 | 1158 | widget_TableModelViewColumn($recordSet->$fieldname, $customField->name) | 
| 1159 | - ->setSortable(true) | |
| 1160 | - ->setExportable(true) | |
| 1161 | - ->setSearchable($customField->searchable) | |
| 1162 | - ->setVisible($customField->visible) | |
| 1159 | + ->setSortable(true) | |
| 1160 | + ->setExportable(true) | |
| 1161 | + ->setSearchable($customField->searchable) | |
| 1162 | + ->setVisible($customField->visible) | |
| 1163 | 1163 | ); | 
| 1164 | 1164 | } | 
| 1165 | - } | |
| 1165 | + } | |
| 1166 | 1166 | |
| 1167 | 1167 | |
| 1168 | 1168 | /** | 
| @@ -26,7 +26,7 @@ discard block | ||
| 26 | 26 |  bab_Widgets()->includePhpClass('widget_InputWidget'); | 
| 27 | 27 |  bab_Widgets()->includePhpClass('widget_TableModelView'); | 
| 28 | 28 | |
| 29 | -require_once dirname(__FILE__) . '/ui.helpers.php'; | |
| 29 | +require_once dirname(__FILE__).'/ui.helpers.php'; | |
| 30 | 30 | |
| 31 | 31 | /** | 
| 32 | 32 | * @return Widget_Form | 
| @@ -680,7 +680,7 @@ discard block | ||
| 680 | 680 | continue; | 
| 681 | 681 | } | 
| 682 | 682 | |
| 683 | -            list(, , $nbCol) = explode('-', $customSection->sizePolicy); | |
| 683 | +            list(,, $nbCol) = explode('-', $customSection->sizePolicy); | |
| 684 | 684 | |
| 685 | 685 |              if ($currentColumn + $nbCol > 12) { | 
| 686 | 686 | $this->addItem($row); | 
| @@ -708,7 +708,7 @@ discard block | ||
| 708 | 708 | $parameters = $displayField['parameters']; | 
| 709 | 709 | $classname = isset($parameters['classname']) ? $parameters['classname'] : ''; | 
| 710 | 710 | $label = isset($parameters['label']) && $parameters['label'] !== '__' ? $parameters['label'] : ''; | 
| 711 | - $displayFieldMethod = '_' . $displayFieldName; | |
| 711 | + $displayFieldMethod = '_'.$displayFieldName; | |
| 712 | 712 | |
| 713 | 713 |                  if (method_exists($this, $displayFieldMethod)) { | 
| 714 | 714 | $widget = $this->$displayFieldMethod($customSection); | 
| @@ -766,7 +766,7 @@ discard block | ||
| 766 | 766 | $parameters = $displayField['parameters']; | 
| 767 | 767 | $classname = isset($parameters['classname']) ? $parameters['classname'] : ''; | 
| 768 | 768 | $label = isset($parameters['label']) && $parameters['label'] !== '__' ? $parameters['label'] : ''; | 
| 769 | - $displayFieldMethod = '_' . $displayFieldName; | |
| 769 | + $displayFieldMethod = '_'.$displayFieldName; | |
| 770 | 770 | |
| 771 | 771 |              if (method_exists($this, $displayFieldMethod)) { | 
| 772 | 772 | $widget = $this->$displayFieldMethod($customSection); | 
| @@ -1036,7 +1036,7 @@ discard block | ||
| 1036 | 1036 |          $row = $W->Items()->setSizePolicy('row'); | 
| 1037 | 1037 |          foreach ($customSections as $customSection) { | 
| 1038 | 1038 | |
| 1039 | -            list(, , $nbCol) = explode('-', $customSection->sizePolicy); | |
| 1039 | +            list(,, $nbCol) = explode('-', $customSection->sizePolicy); | |
| 1040 | 1040 | |
| 1041 | 1041 |              if ($currentColumn + $nbCol > 12) { | 
| 1042 | 1042 | $this->addItem($row); | 
| @@ -1063,7 +1063,7 @@ discard block | ||
| 1063 | 1063 | $parameters = $displayField['parameters']; | 
| 1064 | 1064 | $classname = isset($parameters['classname']) ? $parameters['classname'] : ''; | 
| 1065 | 1065 | $label = isset($parameters['label']) ? $parameters['label'] : ''; | 
| 1066 | - $displayFieldMethod = '_' . $displayFieldName; | |
| 1066 | + $displayFieldMethod = '_'.$displayFieldName; | |
| 1067 | 1067 | |
| 1068 | 1068 |                  if (method_exists($this, $displayFieldMethod)) { | 
| 1069 | 1069 | $value = $this->$displayFieldMethod($customSection); | 
| @@ -1154,7 +1154,7 @@ discard block | ||
| 1154 | 1154 | // we try to select one according to the classname prefix. | 
| 1155 | 1155 |              list($prefix) = explode('_', get_class($this)); | 
| 1156 | 1156 | $functionalityName = ucwords($prefix); | 
| 1157 | -            $this->app = @bab_functionality::get('App/' . $functionalityName); | |
| 1157 | +            $this->app = @bab_functionality::get('App/'.$functionalityName); | |
| 1158 | 1158 |              if (!$this->app) { | 
| 1159 | 1159 |                  $this->app = @bab_functionality::get('App'); | 
| 1160 | 1160 | } | 
| @@ -1215,7 +1215,7 @@ discard block | ||
| 1215 | 1215 | $this->setCurrentPage(isset($filter['pageNumber']) ? $filter['pageNumber'] : $pageNumber); | 
| 1216 | 1216 | |
| 1217 | 1217 |          if (isset($name)) { | 
| 1218 | - $this->sortParameterName = $name . '[filter][sort]'; | |
| 1218 | + $this->sortParameterName = $name.'[filter][sort]'; | |
| 1219 | 1219 |          } else { | 
| 1220 | 1220 | $this->sortParameterName = 'filter[sort]'; | 
| 1221 | 1221 | } | 
| @@ -1366,11 +1366,11 @@ discard block | ||
| 1366 | 1366 | |
| 1367 | 1367 |          foreach ($columns as $fieldName => $column) { | 
| 1368 | 1368 | $field = $column->getField(); | 
| 1369 | -            if (! $column->isSearchable()) { | |
| 1369 | +            if (!$column->isSearchable()) { | |
| 1370 | 1370 | continue; | 
| 1371 | 1371 | } | 
| 1372 | 1372 | |
| 1373 | -            if (! ($field instanceof ORM_Field)) { | |
| 1373 | +            if (!($field instanceof ORM_Field)) { | |
| 1374 | 1374 | $field = null; | 
| 1375 | 1375 | } | 
| 1376 | 1376 | |
| @@ -1387,7 +1387,7 @@ discard block | ||
| 1387 | 1387 | |
| 1388 | 1388 | $formItem = $this->handleFilterLabel($label, $input); | 
| 1389 | 1389 |                  $formItem->setSizePolicy('col-lg-2 col-md-3 col-sm-6 col-xs-12'); | 
| 1390 | -                $formItem->addClass('field_' . $fieldName); | |
| 1390 | +                $formItem->addClass('field_'.$fieldName); | |
| 1391 | 1391 | |
| 1392 | 1392 | $mainSearch = (method_exists($column, 'isMainSearch') && $column->isMainSearch()); | 
| 1393 | 1393 | |
| @@ -1400,7 +1400,7 @@ discard block | ||
| 1400 | 1400 | } | 
| 1401 | 1401 | |
| 1402 | 1402 | |
| 1403 | -        if (! $this->submit) { | |
| 1403 | +        if (!$this->submit) { | |
| 1404 | 1404 | $this->submit = $W->SubmitButton(); | 
| 1405 | 1405 |              $this->submit->setLabel(widget_translate('Filter')); | 
| 1406 | 1406 | } | 
| @@ -1473,7 +1473,7 @@ discard block | ||
| 1473 | 1473 | // $this->setCurrentPage(isset($filter['pageNumber']) ? $filter['pageNumber'] : $pageNumber); | 
| 1474 | 1474 | |
| 1475 | 1475 |          if (isset($name)) { | 
| 1476 | - $this->sortParameterName = $name . '[filter][sort]'; | |
| 1476 | + $this->sortParameterName = $name.'[filter][sort]'; | |
| 1477 | 1477 |          } else { | 
| 1478 | 1478 | $this->sortParameterName = 'filter[sort]'; | 
| 1479 | 1479 | } | 
| @@ -1538,7 +1538,7 @@ discard block | ||
| 1538 | 1538 | |
| 1539 | 1539 | $tableview->setCurrentPage(isset($filterValues['pageNumber']) ? $filterValues['pageNumber'] : 0); | 
| 1540 | 1540 | |
| 1541 | - $tableview->sortParameterName = $name . '[filter][sort]'; | |
| 1541 | + $tableview->sortParameterName = $name.'[filter][sort]'; | |
| 1542 | 1542 | |
| 1543 | 1543 |      if (isset($filterValues['sort'])) { | 
| 1544 | 1544 | $tableview->setSortField($filterValues['sort']); | 
| @@ -1837,7 +1837,7 @@ discard block | ||
| 1837 | 1837 | continue; | 
| 1838 | 1838 | } | 
| 1839 | 1839 | |
| 1840 | -            list(, , $nbCol) = explode('-', $customSection->sizePolicy); | |
| 1840 | +            list(,, $nbCol) = explode('-', $customSection->sizePolicy); | |
| 1841 | 1841 | |
| 1842 | 1842 |              if ($currentColumn + $nbCol > 12) { | 
| 1843 | 1843 | $this->addItem($row); | 
| @@ -1879,7 +1879,7 @@ discard block | ||
| 1879 | 1879 | $classname = isset($parameters['classname']) ? $parameters['classname'] : ''; | 
| 1880 | 1880 | $label = isset($parameters['label']) ? $parameters['label'] : null; | 
| 1881 | 1881 | |
| 1882 | - $displayFieldMethod = '_' . $displayFieldName; | |
| 1882 | + $displayFieldMethod = '_'.$displayFieldName; | |
| 1883 | 1883 |                  if (method_exists($this, $displayFieldMethod)) { | 
| 1884 | 1884 | $item = $this->$displayFieldMethod($customSection, $label); | 
| 1885 | 1885 |                  } else { | 
| @@ -1908,7 +1908,7 @@ discard block | ||
| 1908 | 1908 | } | 
| 1909 | 1909 | } | 
| 1910 | 1910 | |
| 1911 | -        if ($currentColumn + $nbCol> 0) { | |
| 1911 | +        if ($currentColumn + $nbCol > 0) { | |
| 1912 | 1912 | $this->addItem($row); | 
| 1913 | 1913 | } | 
| 1914 | 1914 | } | 
| @@ -2022,7 +2022,7 @@ discard block | ||
| 2022 | 2022 | |
| 2023 | 2023 | $displayable = $field->output($value); | 
| 2024 | 2024 | |
| 2025 | -        switch(true) { | |
| 2025 | +        switch (true) { | |
| 2026 | 2026 | case ($field instanceof ORM_TextField): | 
| 2027 | 2027 | $displayable = $W->RichText($displayable)->setRenderingOptions(BAB_HTML_ALL ^ BAB_HTML_P); | 
| 2028 | 2028 | break; | 
| @@ -286,7 +286,7 @@ discard block | ||
| 286 | 286 | |
| 287 | 287 | // all widget have static id to not change id of others widgets in page | 
| 288 | 288 | |
| 289 | - $infoMessages = $_SESSION['app_msginfo']; | |
| 289 | + $infoMessages = $_SESSION['app_msginfo']; | |
| 290 | 290 |              foreach ($infoMessages as $infoLine) { | 
| 291 | 291 | $this->App()->Controller()->addMessage($infoLine); | 
| 292 | 292 | } | 
| @@ -304,6 +304,6 @@ discard block | ||
| 304 | 304 | * @see app.jquery.js#window.babAddonLibApp.numberFormat | 
| 305 | 305 | */ | 
| 306 | 306 |          $this->setMetadata('numberFormatSeparator', mb_substr($str, 1, 1)); | 
| 307 | -        $this->setMetadata('numberFormatPrecision', mb_strlen($str) -2); | |
| 307 | +        $this->setMetadata('numberFormatPrecision', mb_strlen($str) - 2); | |
| 308 | 308 | } | 
| 309 | 309 | } | 
| @@ -1642,7 +1642,7 @@ | ||
| 1642 | 1642 | $W->SubmitButton() | 
| 1643 | 1643 | ->setAjaxAction($confirmedAction) | 
| 1644 | 1644 |                  ->setLabel($App->translate('Delete')) | 
| 1645 | - ); | |
| 1645 | + ); | |
| 1646 | 1646 |          $form->addButton($W->SubmitButton()->setLabel($App->translate('Cancel'))->addClass('widget-close-dialog')); | 
| 1647 | 1647 | $page->addItem($form); | 
| 1648 | 1648 | |
| @@ -21,7 +21,7 @@ discard block | ||
| 21 | 21 |   * @copyright Copyright (c) 2006 by CANTICO ({@link http://www.cantico.fr}) | 
| 22 | 22 | */ | 
| 23 | 23 | |
| 24 | -require_once dirname(__FILE__) . '/controller.class.php'; | |
| 24 | +require_once dirname(__FILE__).'/controller.class.php'; | |
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | |
| @@ -52,7 +52,7 @@ discard block | ||
| 52 | 52 |      { | 
| 53 | 53 | $App = $this->App(); | 
| 54 | 54 | $recordClassname = $this->getRecordClassName(); | 
| 55 | - $recordSetClassname = $recordClassname . 'Set'; | |
| 55 | + $recordSetClassname = $recordClassname.'Set'; | |
| 56 | 56 | |
| 57 | 57 | $recordSet = $App->$recordSetClassname(); | 
| 58 | 58 | return $recordSet; | 
| @@ -103,7 +103,7 @@ discard block | ||
| 103 | 103 |              if ($showLabel) { | 
| 104 | 104 | $text = $actions->getTitle(); | 
| 105 | 105 | } | 
| 106 | - $html = '<li><a class="icon ' . $actions->getIcon() . '"href="' . $actions->url() . '">' . $text . '</a></li>'; | |
| 106 | + $html = '<li><a class="icon '.$actions->getIcon().'"href="'.$actions->url().'">'.$text.'</a></li>'; | |
| 107 | 107 |          } elseif (is_array($actions)) { | 
| 108 | 108 |              if (isset($actions['items'])) { | 
| 109 | 109 | $items = $actions['items']; | 
| @@ -116,10 +116,10 @@ discard block | ||
| 116 | 116 |              if (isset($actions['icon'])) { | 
| 117 | 117 | |
| 118 | 118 | $html = '<li class="dropdown">' | 
| 119 | - . '<a href="#" class="' . $actions['icon'] . ' icon dropdown-toogle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">' | |
| 119 | + . '<a href="#" class="'.$actions['icon'].' icon dropdown-toogle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">' | |
| 120 | 120 | . ($actions['icon'] === 'actions-context-menu'/*Func_Icons::ACTIONS_CONTEXT_MENU*/ ? '' : '<span class="caret"></span>') | 
| 121 | 121 | . '</a>' | 
| 122 | - . '<ul class="dropdown-menu dropdown-menu-right ' . Func_Icons::ICON_LEFT_SYMBOLIC . '">' | |
| 122 | + . '<ul class="dropdown-menu dropdown-menu-right '.Func_Icons::ICON_LEFT_SYMBOLIC.'">' | |
| 123 | 123 | . $html | 
| 124 | 124 | . '</ul>'; | 
| 125 | 125 | } | 
| @@ -142,7 +142,7 @@ discard block | ||
| 142 | 142 | |
| 143 | 143 | $recordClassname = $this->getRecordClassName(); | 
| 144 | 144 | |
| 145 | - $viewClassname = $recordClassname . 'TableView'; | |
| 145 | + $viewClassname = $recordClassname.'TableView'; | |
| 146 | 146 |          if (method_exists($Ui, $viewClassname)) { | 
| 147 | 147 | $types['table'] = array( | 
| 148 | 148 | 'classname' => $viewClassname, | 
| @@ -151,7 +151,7 @@ discard block | ||
| 151 | 151 | ); | 
| 152 | 152 | } | 
| 153 | 153 | |
| 154 | - $viewClassname = $recordClassname . 'CardsView'; | |
| 154 | + $viewClassname = $recordClassname.'CardsView'; | |
| 155 | 155 |          if (method_exists($Ui, $viewClassname)) { | 
| 156 | 156 | $types['cards'] = array( | 
| 157 | 157 | 'classname' => $viewClassname, | 
| @@ -160,7 +160,7 @@ discard block | ||
| 160 | 160 | ); | 
| 161 | 161 | } | 
| 162 | 162 | |
| 163 | - $viewClassname = $recordClassname . 'MapView'; | |
| 163 | + $viewClassname = $recordClassname.'MapView'; | |
| 164 | 164 |          if (method_exists($Ui, $viewClassname)) { | 
| 165 | 165 | $types['map'] = array( | 
| 166 | 166 | 'classname' => $viewClassname, | 
| @@ -169,7 +169,7 @@ discard block | ||
| 169 | 169 | ); | 
| 170 | 170 | } | 
| 171 | 171 | |
| 172 | - $viewClassname = $recordClassname . 'CalendarView'; | |
| 172 | + $viewClassname = $recordClassname.'CalendarView'; | |
| 173 | 173 |          if (method_exists($Ui, $viewClassname)) { | 
| 174 | 174 | $types['calendar'] = array( | 
| 175 | 175 | 'classname' => $viewClassname, | 
| @@ -241,7 +241,7 @@ discard block | ||
| 241 | 241 |          foreach ($allViewSections as $viewSection) { | 
| 242 | 242 | $fields = $viewSection->getFields(); | 
| 243 | 243 |              foreach ($fields as $field) { | 
| 244 | - $allViewFieldNames[$field['fieldname']] = $viewSection->view . ',' . $viewSection->rank . ',' . $viewSection->id; | |
| 244 | + $allViewFieldNames[$field['fieldname']] = $viewSection->view.','.$viewSection->rank.','.$viewSection->id; | |
| 245 | 245 | } | 
| 246 | 246 | } | 
| 247 | 247 | |
| @@ -265,7 +265,7 @@ discard block | ||
| 265 | 265 | bab_Sort::asort($availableFields, 'description', bab_Sort::CASE_INSENSITIVE); | 
| 266 | 266 | |
| 267 | 267 |          foreach ($availableFields as $field) { | 
| 268 | - $fieldName = $field['name']; | |
| 268 | + $fieldName = $field['name']; | |
| 269 | 269 | $fieldDescription = $field['description']; | 
| 270 | 270 | |
| 271 | 271 | $used = isset($allViewFieldNames[$fieldName]); | 
| @@ -459,7 +459,7 @@ discard block | ||
| 459 | 459 | $nbCol = 0; | 
| 460 | 460 |          foreach ($customSections as $customSection) { | 
| 461 | 461 | |
| 462 | -            list(, , $nbCol) = explode('-', $customSection->sizePolicy); | |
| 462 | +            list(,, $nbCol) = explode('-', $customSection->sizePolicy); | |
| 463 | 463 | |
| 464 | 464 |  //             if ($currentColumn + $nbCol > 12) { | 
| 465 | 465 | // $sectionsSection->addItem($row); | 
| @@ -470,8 +470,8 @@ discard block | ||
| 470 | 470 | $currentColumn += $nbCol; | 
| 471 | 471 | |
| 472 | 472 | $sectionSection = $W->Section( | 
| 473 | -                $customSection->name . ' (' . $customSection->rank . ')', | |
| 474 | -                $sectionBox = $W->VBoxItems($W->Hidden()->setName('#' . $customSection->id)) | |
| 473 | +                $customSection->name.' ('.$customSection->rank.')', | |
| 474 | +                $sectionBox = $W->VBoxItems($W->Hidden()->setName('#'.$customSection->id)) | |
| 475 | 475 |  //                     ->addClass('widget-dockable-content') | 
| 476 | 476 | ); | 
| 477 | 477 |              $sectionSection->addClass('crm-custom-section'); | 
| @@ -516,16 +516,16 @@ discard block | ||
| 516 | 516 | } | 
| 517 | 517 | |
| 518 | 518 | $fieldItem = $W->FlowItems( | 
| 519 | - $W->Label($fieldDescription)->setSizePolicy(Func_Icons::ICON_LEFT_16 . ' widget-80pc' ), | |
| 519 | + $W->Label($fieldDescription)->setSizePolicy(Func_Icons::ICON_LEFT_16.' widget-80pc'), | |
| 520 | 520 | $W->FlowItems( | 
| 521 | - $W->Hidden()->setName($customSection->id . '.' . $fieldId)->setValue($field['name']), | |
| 521 | + $W->Hidden()->setName($customSection->id.'.'.$fieldId)->setValue($field['name']), | |
| 522 | 522 |                          $W->Link('', $this->proxy()->editDisplayField($customSection->id, $field['name'])) | 
| 523 | 523 |                              ->addClass('icon', Func_Icons::ACTIONS_DOCUMENT_EDIT) | 
| 524 | 524 | ->setOpenMode(Widget_Link::OPEN_DIALOG), | 
| 525 | 525 |                          $W->Link('', $this->proxy()->removeDisplayField($customSection->id, $field['name'])) | 
| 526 | 526 |                              ->addClass('icon', Func_Icons::ACTIONS_LIST_REMOVE) | 
| 527 | 527 | ->setAjaxAction() | 
| 528 | - )->setSizePolicy(Func_Icons::ICON_LEFT_16 . ' widget-20pc widget-align-right widget-actions' ) | |
| 528 | + )->setSizePolicy(Func_Icons::ICON_LEFT_16.' widget-20pc widget-align-right widget-actions') | |
| 529 | 529 |                  )->setSizePolicy('widget-list-element  widget-actions-target'); | 
| 530 | 530 | |
| 531 | 531 | $sectionBox->addItem($fieldItem); | 
| @@ -598,7 +598,7 @@ discard block | ||
| 598 | 598 | } | 
| 599 | 599 | |
| 600 | 600 |          header('Content-type: application/json'); | 
| 601 | -        header('Content-Disposition: attachment; filename="' . $objectName . '.' . ($view === '' ? 'default' : $view) . '.json"'."\n"); | |
| 601 | +        header('Content-Disposition: attachment; filename="'.$objectName.'.'.($view === '' ? 'default' : $view).'.json"'."\n"); | |
| 602 | 602 | |
| 603 | 603 | $json = bab_json_encode($sectionsValues); | 
| 604 | 604 | $json = bab_convertStringFromDatabase($json, bab_charset::UTF_8); | 
| @@ -842,11 +842,11 @@ discard block | ||
| 842 | 842 | $recordSet = $this->getEditRecordSet(); | 
| 843 | 843 | |
| 844 | 844 | $recordClassname = $this->getRecordClassName(); | 
| 845 | - $editorClassname = $recordClassname . 'SectionEditor'; | |
| 845 | + $editorClassname = $recordClassname.'SectionEditor'; | |
| 846 | 846 | /* @var $editor app_RecordEditor */ | 
| 847 | 847 | $editor = $Ui->$editorClassname(); | 
| 848 | 848 |          if (!isset($itemId)) { | 
| 849 | - $itemId = $this->getClass() . '.' . __FUNCTION__; | |
| 849 | + $itemId = $this->getClass().'.'.__FUNCTION__; | |
| 850 | 850 | } | 
| 851 | 851 | $editor->setId($itemId); | 
| 852 | 852 |          $editor->setHiddenValue('tg', $App->controllerTg); | 
| @@ -889,7 +889,7 @@ discard block | ||
| 889 | 889 | public function getModelViewDefaultId($itemId = null) | 
| 890 | 890 |      { | 
| 891 | 891 |          if (!isset($itemId)) { | 
| 892 | - $itemId = $this->getClass() . '.modelView'; | |
| 892 | + $itemId = $this->getClass().'.modelView'; | |
| 893 | 893 | } | 
| 894 | 894 | |
| 895 | 895 | return $itemId; | 
| @@ -923,20 +923,20 @@ discard block | ||
| 923 | 923 | |
| 924 | 924 |          switch ($type) { | 
| 925 | 925 | case 'cards': | 
| 926 | - $tableviewClassname = $recordClassname . 'CardsView'; | |
| 926 | + $tableviewClassname = $recordClassname.'CardsView'; | |
| 927 | 927 | break; | 
| 928 | 928 | |
| 929 | 929 | case 'map': | 
| 930 | - $tableviewClassname = $recordClassname . 'MapView'; | |
| 930 | + $tableviewClassname = $recordClassname.'MapView'; | |
| 931 | 931 | break; | 
| 932 | 932 | |
| 933 | 933 | case 'calendar': | 
| 934 | - $tableviewClassname = $recordClassname . 'CalendarView'; | |
| 934 | + $tableviewClassname = $recordClassname.'CalendarView'; | |
| 935 | 935 | break; | 
| 936 | 936 | |
| 937 | 937 | case 'table': | 
| 938 | 938 | default: | 
| 939 | - $tableviewClassname = $recordClassname . 'TableView'; | |
| 939 | + $tableviewClassname = $recordClassname.'TableView'; | |
| 940 | 940 | break; | 
| 941 | 941 | } | 
| 942 | 942 | |
| @@ -1002,10 +1002,10 @@ discard block | ||
| 1002 | 1002 | $Ui = $App->Ui(); | 
| 1003 | 1003 | |
| 1004 | 1004 | $recordClassname = $this->getRecordClassName(); | 
| 1005 | - $editorClassname = $recordClassname . 'Editor'; | |
| 1005 | + $editorClassname = $recordClassname.'Editor'; | |
| 1006 | 1006 | $editor = $Ui->$editorClassname(); | 
| 1007 | 1007 |          if (!isset($itemId)) { | 
| 1008 | - $itemId = $this->getClass() . '_' . __FUNCTION__; | |
| 1008 | + $itemId = $this->getClass().'_'.__FUNCTION__; | |
| 1009 | 1009 | } | 
| 1010 | 1010 | $editor->setId($itemId); | 
| 1011 | 1011 |          $editor->setHiddenValue('tg', $App->controllerTg); | 
| @@ -1050,7 +1050,7 @@ discard block | ||
| 1050 | 1050 | $W->Link( | 
| 1051 | 1051 | '', | 
| 1052 | 1052 | $proxy->setFilteredViewType($tableView->getId(), $viewTypeId) | 
| 1053 | -                    )->addClass('icon', $viewType['icon'] . ($filteredViewType=== $viewTypeId ? ' active' : '')) | |
| 1053 | +                    )->addClass('icon', $viewType['icon'].($filteredViewType === $viewTypeId ? ' active' : '')) | |
| 1054 | 1054 |  //                    ->setSizePolicy('btn btn-xs btn-default ' . ($filteredViewType === $viewTypeId ? 'active' : '')) | 
| 1055 | 1055 | ->setTitle($viewType['label']) | 
| 1056 | 1056 | ->setAjaxAction() | 
| @@ -1094,7 +1094,7 @@ discard block | ||
| 1094 | 1094 | |
| 1095 | 1095 | $filterVisibility = $this->getFilterVisibility($itemId); | 
| 1096 | 1096 | $filterVisibility = !$filterVisibility; | 
| 1097 | - $W->setUserConfiguration($itemId . '/filterVisibility', $filterVisibility); | |
| 1097 | + $W->setUserConfiguration($itemId.'/filterVisibility', $filterVisibility); | |
| 1098 | 1098 | |
| 1099 | 1099 | return true; | 
| 1100 | 1100 | } | 
| @@ -1107,10 +1107,10 @@ discard block | ||
| 1107 | 1107 | protected function getFilterVisibility($itemId) | 
| 1108 | 1108 |      { | 
| 1109 | 1109 | $W = bab_Widgets(); | 
| 1110 | - $filterVisibility = $W->getUserConfiguration($itemId . '/filterVisibility'); | |
| 1110 | + $filterVisibility = $W->getUserConfiguration($itemId.'/filterVisibility'); | |
| 1111 | 1111 |          if (!isset($filterVisibility)) { | 
| 1112 | 1112 | $filterVisibility = false; | 
| 1113 | - $W->setUserConfiguration($itemId . '/filterVisibility', $filterVisibility); | |
| 1113 | + $W->setUserConfiguration($itemId.'/filterVisibility', $filterVisibility); | |
| 1114 | 1114 | } | 
| 1115 | 1115 | return $filterVisibility; | 
| 1116 | 1116 | } | 
| @@ -1124,7 +1124,7 @@ discard block | ||
| 1124 | 1124 | protected function getFilteredViewType($itemId) | 
| 1125 | 1125 |      { | 
| 1126 | 1126 | $W = bab_Widgets(); | 
| 1127 | - $type = $W->getUserConfiguration($itemId . '/viewType'); | |
| 1127 | + $type = $W->getUserConfiguration($itemId.'/viewType'); | |
| 1128 | 1128 |          if (!isset($type)) { | 
| 1129 | 1129 | $type = 'table'; | 
| 1130 | 1130 | } | 
| @@ -1140,7 +1140,7 @@ discard block | ||
| 1140 | 1140 | public function setFilteredViewType($itemId, $type = null) | 
| 1141 | 1141 |      { | 
| 1142 | 1142 | $W = bab_Widgets(); | 
| 1143 | - $W->setUserConfiguration($itemId . '/viewType', $type); | |
| 1143 | + $W->setUserConfiguration($itemId.'/viewType', $type); | |
| 1144 | 1144 | |
| 1145 | 1145 | return true; | 
| 1146 | 1146 | } | 
| @@ -1285,14 +1285,14 @@ discard block | ||
| 1285 | 1285 | |
| 1286 | 1286 |          switch ($format) { | 
| 1287 | 1287 | case 'xlsx': | 
| 1288 | - $tableview->downloadXlsx($filename . '.xlsx'); | |
| 1288 | + $tableview->downloadXlsx($filename.'.xlsx'); | |
| 1289 | 1289 | case 'xls': | 
| 1290 | - $tableview->downloadExcel($filename . '.xls'); | |
| 1290 | + $tableview->downloadExcel($filename.'.xls'); | |
| 1291 | 1291 | case 'ssv': | 
| 1292 | - $tableview->downloadCsv($filename . '.csv', ';', $inline, 'Windows-1252'); | |
| 1292 | + $tableview->downloadCsv($filename.'.csv', ';', $inline, 'Windows-1252'); | |
| 1293 | 1293 | case 'csv': | 
| 1294 | 1294 | default: | 
| 1295 | - $tableview->downloadCsv($filename . '.csv', ',', $inline, bab_charset::getIso()); | |
| 1295 | + $tableview->downloadCsv($filename.'.csv', ',', $inline, bab_charset::getIso()); | |
| 1296 | 1296 | } | 
| 1297 | 1297 | } | 
| 1298 | 1298 | |
| @@ -1320,7 +1320,7 @@ discard block | ||
| 1320 | 1320 | $Ui = $App->Ui(); | 
| 1321 | 1321 | |
| 1322 | 1322 | $recordClassname = $this->getRecordClassName(); | 
| 1323 | - $fullFrameClassname = $recordClassname . 'FullFrame'; | |
| 1323 | + $fullFrameClassname = $recordClassname.'FullFrame'; | |
| 1324 | 1324 | $fullFrame = $Ui->$fullFrameClassname($record, $view); | 
| 1325 | 1325 | |
| 1326 | 1326 | |
| @@ -1483,7 +1483,7 @@ discard block | ||
| 1483 | 1483 | |
| 1484 | 1484 | $recordTitle = $record->getRecordTitle(); | 
| 1485 | 1485 | |
| 1486 | -        $message = sprintf($App->translate('%s has been deleted'), $App->translate($recordSet->getDescription()) . ' "' . $recordTitle . '"'); | |
| 1486 | +        $message = sprintf($App->translate('%s has been deleted'), $App->translate($recordSet->getDescription()).' "'.$recordTitle.'"'); | |
| 1487 | 1487 | return $message; | 
| 1488 | 1488 | } | 
| 1489 | 1489 | |
| @@ -1610,7 +1610,7 @@ discard block | ||
| 1610 | 1610 | $this->addMessage($deletedMessage); | 
| 1611 | 1611 | } | 
| 1612 | 1612 | |
| 1613 | -        $this->addReloadSelector('.depends-' . strtolower($record->getClassName())); | |
| 1613 | +        $this->addReloadSelector('.depends-'.strtolower($record->getClassName())); | |
| 1614 | 1614 | |
| 1615 | 1615 | return true; | 
| 1616 | 1616 | } | 
| @@ -1641,7 +1641,7 @@ discard block | ||
| 1641 | 1641 | |
| 1642 | 1642 | $recordTitle = $record->getRecordTitle(); | 
| 1643 | 1643 | |
| 1644 | - $subTitle = $App->translate($recordSet->getDescription()) . ' "' . $recordTitle . '"'; | |
| 1644 | + $subTitle = $App->translate($recordSet->getDescription()).' "'.$recordTitle.'"'; | |
| 1645 | 1645 | $form->addItem($W->Title($subTitle, 5)); | 
| 1646 | 1646 | |
| 1647 | 1647 |          $form->addItem($W->Title($App->translate('Confirm delete?'), 6)); | 
| @@ -94,13 +94,13 @@ discard block | ||
| 94 | 94 | |
| 95 | 95 | |
| 96 | 96 | |
| 97 | - /** | |
| 98 | - * @return Widget_Page | |
| 99 | - */ | |
| 100 | - public function edit($customfield = null) | |
| 101 | -	{ | |
| 102 | - $W = bab_Widgets(); | |
| 103 | - $App = $this->App(); | |
| 97 | + /** | |
| 98 | + * @return Widget_Page | |
| 99 | + */ | |
| 100 | + public function edit($customfield = null) | |
| 101 | +    { | |
| 102 | + $W = bab_Widgets(); | |
| 103 | + $App = $this->App(); | |
| 104 | 104 | // $access = $Crm->Access(); | 
| 105 | 105 | |
| 106 | 106 |  // 		if (!$access->viewShopAdmin()) { | 
| @@ -109,134 +109,134 @@ discard block | ||
| 109 | 109 | |
| 110 | 110 |  // 		crm_BreadCrumbs::setCurrentPosition($this->proxy()->edit($customfield), $Crm->translate('Edit custom field')); | 
| 111 | 111 | |
| 112 | - /* @var $Ui app_Ui */ | |
| 113 | - $Ui = $App->Ui(); | |
| 114 | - $page = $Ui->Page(); | |
| 112 | + /* @var $Ui app_Ui */ | |
| 113 | + $Ui = $App->Ui(); | |
| 114 | + $page = $Ui->Page(); | |
| 115 | 115 | |
| 116 | -		$page->addClass('app-page-editor'); | |
| 117 | -		$page->setTitle($App->translate('Edit custom field')); | |
| 116 | +        $page->addClass('app-page-editor'); | |
| 117 | +        $page->setTitle($App->translate('Edit custom field')); | |
| 118 | 118 | |
| 119 | -		if (null !== $customfield) { | |
| 120 | - $set = $App->CustomFieldSet(); | |
| 121 | - $customfield = $set->request($customfield); | |
| 122 | - } | |
| 119 | +        if (null !== $customfield) { | |
| 120 | + $set = $App->CustomFieldSet(); | |
| 121 | + $customfield = $set->request($customfield); | |
| 122 | + } | |
| 123 | 123 | |
| 124 | 124 | |
| 125 | 125 | |
| 126 | - $form = $Ui->CustomFieldEditor($customfield); | |
| 126 | + $form = $Ui->CustomFieldEditor($customfield); | |
| 127 | 127 | |
| 128 | - $page->addItem($form); | |
| 128 | + $page->addItem($form); | |
| 129 | 129 | |
| 130 | -		if ($customfield instanceof app_CustomField) { | |
| 131 | - $actionsFrame = $page->ActionsFrame(); | |
| 132 | - $page->addContextItem($actionsFrame); | |
| 130 | +        if ($customfield instanceof app_CustomField) { | |
| 131 | + $actionsFrame = $page->ActionsFrame(); | |
| 132 | + $page->addContextItem($actionsFrame); | |
| 133 | 133 | |
| 134 | -			$actionsFrame->addItem($W->Link($W->Icon($App->translate('Delete'), Func_Icons::ACTIONS_EDIT_DELETE), $this->proxy()->delete($customfield->id))); | |
| 135 | - } | |
| 134 | +            $actionsFrame->addItem($W->Link($W->Icon($App->translate('Delete'), Func_Icons::ACTIONS_EDIT_DELETE), $this->proxy()->delete($customfield->id))); | |
| 135 | + } | |
| 136 | 136 | |
| 137 | - return $page; | |
| 138 | - } | |
| 137 | + return $page; | |
| 138 | + } | |
| 139 | 139 | |
| 140 | 140 | |
| 141 | - /** | |
| 142 | - * @return bool | |
| 143 | - */ | |
| 144 | - public function save($customfield = null) | |
| 145 | -	{ | |
| 146 | - $App = $this->App(); | |
| 141 | + /** | |
| 142 | + * @return bool | |
| 143 | + */ | |
| 144 | + public function save($customfield = null) | |
| 145 | +    { | |
| 146 | + $App = $this->App(); | |
| 147 | 147 | // $access = $Crm->Access(); | 
| 148 | 148 | |
| 149 | 149 |  // 		if (!$access->viewShopAdmin()) { | 
| 150 | 150 |  // 			throw new crm_AccessException($Crm->translate('Access denied to online shop administration')); | 
| 151 | 151 | // } | 
| 152 | 152 | |
| 153 | - $set = $App->CustomFieldSet(); | |
| 153 | + $set = $App->CustomFieldSet(); | |
| 154 | 154 | |
| 155 | -		if (empty($customfield['id'])) { | |
| 156 | - $record = $set->newRecord(); | |
| 157 | -		} else { | |
| 158 | - $record = $set->get($customfield['id']); | |
| 155 | +        if (empty($customfield['id'])) { | |
| 156 | + $record = $set->newRecord(); | |
| 157 | +        } else { | |
| 158 | + $record = $set->get($customfield['id']); | |
| 159 | 159 |  // 			if (null == $record) { | 
| 160 | 160 |  // 				throw new crm_SaveException($Crm->translate('This custom field does not exists')); | 
| 161 | 161 | // } | 
| 162 | - } | |
| 162 | + } | |
| 163 | 163 | |
| 164 | -		if ('Enum' === $customfield['fieldtype'] || 'Set' === $customfield['fieldtype']) { | |
| 165 | - $enumvalues = array(); | |
| 166 | -		    foreach ($customfield['enumvalues'] as $enumkey => $enumvalue) { | |
| 167 | - $enumvalues[$enumkey] = $set->enumvalues->input($enumvalue); | |
| 168 | - } | |
| 169 | - $record->enumvalues = serialize($enumvalues); | |
| 170 | -		} else { | |
| 171 | - $record->enumvalues = ''; | |
| 172 | - } | |
| 164 | +        if ('Enum' === $customfield['fieldtype'] || 'Set' === $customfield['fieldtype']) { | |
| 165 | + $enumvalues = array(); | |
| 166 | +            foreach ($customfield['enumvalues'] as $enumkey => $enumvalue) { | |
| 167 | + $enumvalues[$enumkey] = $set->enumvalues->input($enumvalue); | |
| 168 | + } | |
| 169 | + $record->enumvalues = serialize($enumvalues); | |
| 170 | +        } else { | |
| 171 | + $record->enumvalues = ''; | |
| 172 | + } | |
| 173 | 173 | |
| 174 | - unset($customfield['enumvalues']); | |
| 175 | - $record->setFormInputValues($customfield); | |
| 174 | + unset($customfield['enumvalues']); | |
| 175 | + $record->setFormInputValues($customfield); | |
| 176 | 176 | |
| 177 | 177 | |
| 178 | - $record->save(); | |
| 178 | + $record->save(); | |
| 179 | 179 | |
| 180 | 180 | |
| 181 | - // refresh target table structure | |
| 181 | + // refresh target table structure | |
| 182 | 182 | |
| 183 | - $object = $record->object.'Set'; | |
| 184 | - $mysqlbackend = new ORM_MySqlBackend($GLOBALS['babDB']); | |
| 183 | + $object = $record->object.'Set'; | |
| 184 | + $mysqlbackend = new ORM_MySqlBackend($GLOBALS['babDB']); | |
| 185 | 185 | |
| 186 | - $recordSet = $App->$object(); | |
| 187 | -		if (method_exists($recordSet, 'useLang')) { | |
| 188 | - // This is necessary if the recordSet constructor uses a setLang(). | |
| 189 | - // We need to revert to multilang fields before synchronizing. | |
| 190 | - $recordSet->useLang(false); | |
| 191 | - } | |
| 186 | + $recordSet = $App->$object(); | |
| 187 | +        if (method_exists($recordSet, 'useLang')) { | |
| 188 | + // This is necessary if the recordSet constructor uses a setLang(). | |
| 189 | + // We need to revert to multilang fields before synchronizing. | |
| 190 | + $recordSet->useLang(false); | |
| 191 | + } | |
| 192 | 192 | |
| 193 | - $sql = $mysqlbackend->setToSql($recordSet); | |
| 193 | + $sql = $mysqlbackend->setToSql($recordSet); | |
| 194 | 194 | |
| 195 | - require_once $GLOBALS['babInstallPath'].'utilit/devtools.php'; | |
| 196 | - $synchronize = new bab_synchronizeSql(); | |
| 197 | - $synchronize->fromSqlString($sql); | |
| 195 | + require_once $GLOBALS['babInstallPath'].'utilit/devtools.php'; | |
| 196 | + $synchronize = new bab_synchronizeSql(); | |
| 197 | + $synchronize->fromSqlString($sql); | |
| 198 | 198 | |
| 199 | - return true; | |
| 200 | - } | |
| 199 | + return true; | |
| 200 | + } | |
| 201 | 201 | |
| 202 | 202 | |
| 203 | 203 | /** | 
| 204 | 204 |       * {@inheritDoc} | 
| 205 | 205 | * @see app_CtrlRecord::delete() | 
| 206 | 206 | */ | 
| 207 | - public function delete($customfield) | |
| 208 | -	{ | |
| 209 | - $App = $this->App(); | |
| 207 | + public function delete($customfield) | |
| 208 | +    { | |
| 209 | + $App = $this->App(); | |
| 210 | 210 | // $access = $Crm->Access(); | 
| 211 | 211 | |
| 212 | 212 |  // 		if (!$access->viewShopAdmin()) { | 
| 213 | 213 |  // 			throw new crm_AccessException($Crm->translate('Access denied to online shop administration')); | 
| 214 | 214 | // } | 
| 215 | 215 | |
| 216 | - if (!$customfield) | |
| 217 | -		{ | |
| 218 | -		    throw new app_AccessException($App->translate('Access denied')); | |
| 219 | - } | |
| 216 | + if (!$customfield) | |
| 217 | +        { | |
| 218 | +            throw new app_AccessException($App->translate('Access denied')); | |
| 219 | + } | |
| 220 | 220 | |
| 221 | - $set = $App->CustomFieldSet(); | |
| 222 | - $record = $set->request($customfield); | |
| 223 | - $object = $record->object.'Set'; | |
| 224 | - $set->delete($set->id->is($customfield)); | |
| 221 | + $set = $App->CustomFieldSet(); | |
| 222 | + $record = $set->request($customfield); | |
| 223 | + $object = $record->object.'Set'; | |
| 224 | + $set->delete($set->id->is($customfield)); | |
| 225 | 225 | |
| 226 | - $recordSet = $App->$object(); | |
| 227 | -		if (method_exists($recordSet, 'useLang')) { | |
| 228 | - // This is necessary if the recordSet constructor uses a setLang(). | |
| 229 | - // We need to revert to multilang fields before synchronizing. | |
| 230 | - $recordSet->useLang(false); | |
| 231 | - } | |
| 226 | + $recordSet = $App->$object(); | |
| 227 | +        if (method_exists($recordSet, 'useLang')) { | |
| 228 | + // This is necessary if the recordSet constructor uses a setLang(). | |
| 229 | + // We need to revert to multilang fields before synchronizing. | |
| 230 | + $recordSet->useLang(false); | |
| 231 | + } | |
| 232 | 232 | |
| 233 | - $mysqlbackend = new ORM_MySqlBackend($GLOBALS['babDB']); | |
| 234 | - $sql = $mysqlbackend->setToSql($recordSet); | |
| 233 | + $mysqlbackend = new ORM_MySqlBackend($GLOBALS['babDB']); | |
| 234 | + $sql = $mysqlbackend->setToSql($recordSet); | |
| 235 | 235 | |
| 236 | - require_once $GLOBALS['babInstallPath'].'utilit/devtools.php'; | |
| 237 | - $synchronize = new bab_synchronizeSql(); | |
| 238 | - $synchronize->fromSqlString($sql); | |
| 236 | + require_once $GLOBALS['babInstallPath'].'utilit/devtools.php'; | |
| 237 | + $synchronize = new bab_synchronizeSql(); | |
| 238 | + $synchronize->fromSqlString($sql); | |
| 239 | 239 | |
| 240 | - return true; | |
| 241 | - } | |
| 240 | + return true; | |
| 241 | + } | |
| 242 | 242 | } | 
| @@ -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 | |
| @@ -30,11 +30,11 @@ | ||
| 30 | 30 | |
| 31 | 31 | class app_UnknownActionException extends Exception | 
| 32 | 32 |  { | 
| 33 | - public function __construct($action, $code = 0) | |
| 34 | -	{ | |
| 35 | - $message = 'Unknown method "' . $action->getController() . '::' . $action->getMethod() . '"'; | |
| 36 | - parent::__construct($message, $code); | |
| 37 | - } | |
| 33 | + public function __construct($action, $code = 0) | |
| 34 | +    { | |
| 35 | + $message = 'Unknown method "' . $action->getController() . '::' . $action->getMethod() . '"'; | |
| 36 | + parent::__construct($message, $code); | |
| 37 | + } | |
| 38 | 38 | } | 
| 39 | 39 | |
| 40 | 40 | |
| @@ -21,8 +21,8 @@ discard block | ||
| 21 | 21 |   * @copyright Copyright (c) 2008 by CANTICO ({@link http://www.cantico.fr}) | 
| 22 | 22 | */ | 
| 23 | 23 | |
| 24 | -require_once $GLOBALS['babInstallPath'] . 'utilit/controller.class.php'; | |
| 25 | -require_once dirname(__FILE__). '/functions.php'; | |
| 24 | +require_once $GLOBALS['babInstallPath'].'utilit/controller.class.php'; | |
| 25 | +require_once dirname(__FILE__).'/functions.php'; | |
| 26 | 26 | |
| 27 | 27 | $App = app_App(); | 
| 28 | 28 | $App->includeBase(); | 
| @@ -32,7 +32,7 @@ discard block | ||
| 32 | 32 |  { | 
| 33 | 33 | public function __construct($action, $code = 0) | 
| 34 | 34 |  	{ | 
| 35 | - $message = 'Unknown method "' . $action->getController() . '::' . $action->getMethod() . '"'; | |
| 35 | + $message = 'Unknown method "'.$action->getController().'::'.$action->getMethod().'"'; | |
| 36 | 36 | parent::__construct($message, $code); | 
| 37 | 37 | } | 
| 38 | 38 | } | 
| @@ -215,11 +215,11 @@ discard block | ||
| 215 | 215 | // we try to select one according to the classname prefix. | 
| 216 | 216 |          list($prefix) = explode('_', __CLASS__); | 
| 217 | 217 | $functionalityName = ucwords($prefix); | 
| 218 | -        $App = @bab_functionality::get('App/' . $functionalityName); | |
| 218 | +        $App = @bab_functionality::get('App/'.$functionalityName); | |
| 219 | 219 | |
| 220 | 220 | if (!$App) | 
| 221 | 221 |          { | 
| 222 | -            throw new app_Exception('Faild to autodetect functionality App/' . $functionalityName.', the getInstance method is deprecated, use $App->ControllerProxy() instead'); | |
| 222 | +            throw new app_Exception('Faild to autodetect functionality App/'.$functionalityName.', the getInstance method is deprecated, use $App->ControllerProxy() instead'); | |
| 223 | 223 | } | 
| 224 | 224 | |
| 225 | 225 | $controller = $App->ControllerProxy($classname, $proxy); | 
| @@ -238,9 +238,9 @@ discard block | ||
| 238 | 238 | static function getProxyInstance(Func_App $App, $classname) | 
| 239 | 239 |      { | 
| 240 | 240 | $class = new ReflectionClass($classname); | 
| 241 | - $proxyClassname = $class->name . self::PROXY_CLASS_SUFFIX; | |
| 241 | + $proxyClassname = $class->name.self::PROXY_CLASS_SUFFIX; | |
| 242 | 242 |          if (!class_exists($proxyClassname)) { | 
| 243 | -            $classStr = 'class ' . $proxyClassname . ' extends ' . $class->name . ' {' . "\n"; | |
| 243 | +            $classStr = 'class '.$proxyClassname.' extends '.$class->name.' {'."\n"; | |
| 244 | 244 | $methods = $class->getMethods(); | 
| 245 | 245 | |
| 246 | 246 |              $classStr .= '	public function __construct(Func_App $App) { | 
| @@ -253,24 +253,24 @@ discard block | ||
| 253 | 253 | } | 
| 254 | 254 | |
| 255 | 255 | |
| 256 | -                $classStr .= '	public function ' . $method->name . '('; | |
| 256 | +                $classStr .= '	public function '.$method->name.'('; | |
| 257 | 257 | $parameters = $method->getParameters(); | 
| 258 | 258 | $parametersStr = array(); | 
| 259 | 259 |                  foreach ($parameters as $parameter) { | 
| 260 | 260 | |
| 261 | 261 |                      if ($parameter->isDefaultValueAvailable()) { | 
| 262 | - $parametersStr[] = '$' . $parameter->name . ' = ' . var_export($parameter->getDefaultValue(), true); | |
| 262 | + $parametersStr[] = '$'.$parameter->name.' = '.var_export($parameter->getDefaultValue(), true); | |
| 263 | 263 |                      } else { | 
| 264 | - $parametersStr[] = '$' . $parameter->name; | |
| 264 | + $parametersStr[] = '$'.$parameter->name; | |
| 265 | 265 | } | 
| 266 | 266 | } | 
| 267 | 267 |                  $classStr .= implode(', ', $parametersStr); | 
| 268 | -                $classStr .= ') {' . "\n"; | |
| 269 | - $classStr .= ' $args = func_get_args();' . "\n"; | |
| 270 | - $classStr .= ' return $this->getMethodAction(__FUNCTION__, $args);' . "\n"; | |
| 271 | - $classStr .= ' }' . "\n"; | |
| 268 | +                $classStr .= ') {'."\n"; | |
| 269 | + $classStr .= ' $args = func_get_args();'."\n"; | |
| 270 | + $classStr .= ' return $this->getMethodAction(__FUNCTION__, $args);'."\n"; | |
| 271 | + $classStr .= ' }'."\n"; | |
| 272 | 272 | } | 
| 273 | - $classStr .= '}' . "\n"; | |
| 273 | + $classStr .= '}'."\n"; | |
| 274 | 274 | |
| 275 | 275 | // We define the proxy class | 
| 276 | 276 | eval($classStr); | 
| @@ -394,7 +394,7 @@ discard block | ||
| 394 | 394 | $action->setParameters($actionParams); | 
| 395 | 395 | |
| 396 | 396 | |
| 397 | -        list(,,$file) = explode('/', $App->controllerTg); | |
| 397 | +        list(,, $file) = explode('/', $App->controllerTg); | |
| 398 | 398 | |
| 399 | 399 |          $action->setParameter('addon', $App->getAddonName().'.'.$file); | 
| 400 | 400 |          $action->setParameter('idx', $idx); | 
| @@ -418,7 +418,7 @@ discard block | ||
| 418 | 418 | return false; | 
| 419 | 419 | } | 
| 420 | 420 | |
| 421 | -        list($objectName, ) = explode('.', $method); | |
| 421 | +        list($objectName,) = explode('.', $method); | |
| 422 | 422 | |
| 423 | 423 |          if (!method_exists($this, $objectName)) { | 
| 424 | 424 |              header('HTTP/1.0 400 Bad Request'); | 
| @@ -426,7 +426,7 @@ discard block | ||
| 426 | 426 | } | 
| 427 | 427 | |
| 428 | 428 |          $objectController = $this->{$objectName}(false); | 
| 429 | -        if ( ! ($objectController instanceof app_Controller)) { | |
| 429 | +        if (!($objectController instanceof app_Controller)) { | |
| 430 | 430 | return false; | 
| 431 | 431 | } | 
| 432 | 432 | |
| @@ -440,7 +440,7 @@ discard block | ||
| 440 | 440 |              } else { | 
| 441 | 441 |                  if ($this->isAjaxRequest()) { | 
| 442 | 442 | |
| 443 | - header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); | |
| 443 | + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden', true, 403); | |
| 444 | 444 | |
| 445 | 445 | die( | 
| 446 | 446 | bab_json_encode( | 
| @@ -461,7 +461,7 @@ discard block | ||
| 461 | 461 |          } catch (app_SaveException $e) { | 
| 462 | 462 | |
| 463 | 463 |              if ($this->isAjaxRequest()) { | 
| 464 | - header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); | |
| 464 | + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden', true, 403); | |
| 465 | 465 |                  header('Cache-Control: no-cache, must-revalidate'); | 
| 466 | 466 |                  header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | 
| 467 | 467 |                  header('Content-type: application/json'); | 
| @@ -528,7 +528,7 @@ discard block | ||
| 528 | 528 |                          if (method_exists($htmlCanvas, 'sendPageTitle')) { | 
| 529 | 529 | $htmlCanvas->sendPageTitle($pageTitle); | 
| 530 | 530 |                          } else { | 
| 531 | -                            header('X-Cto-PageTitle: ' . $pageTitle); | |
| 531 | +                            header('X-Cto-PageTitle: '.$pageTitle); | |
| 532 | 532 | } | 
| 533 | 533 | } | 
| 534 | 534 | $html = $returnedValue->display($htmlCanvas); | 
| @@ -588,7 +588,7 @@ discard block | ||
| 588 | 588 | private function deletedItemPage(Widget_Action $action, app_DeletedRecordException $e) | 
| 589 | 589 |      { | 
| 590 | 590 |          if ($this->isAjaxRequest()) { | 
| 591 | - header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); | |
| 591 | + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden', true, 403); | |
| 592 | 592 |              header('Cache-Control: no-cache, must-revalidate'); | 
| 593 | 593 |              header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | 
| 594 | 594 |              header('Content-type: application/json'); | 
| @@ -605,7 +605,7 @@ discard block | ||
| 605 | 605 | ); | 
| 606 | 606 | |
| 607 | 607 | } | 
| 608 | - header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true, 404); | |
| 608 | + header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found', true, 404); | |
| 609 | 609 | |
| 610 | 610 | $App = $this->App(); | 
| 611 | 611 | $W = bab_Widgets(); | 
| @@ -639,7 +639,7 @@ discard block | ||
| 639 | 639 | private function notFoundPage(Widget_Action $action, app_NotFoundException $e) | 
| 640 | 640 |      { | 
| 641 | 641 |          if ($this->isAjaxRequest()) { | 
| 642 | -            $message = sprintf(app_translate('This %s does not exists'), $e->getObjectTitle() . ' (' . $e->getId() . ')'); | |
| 642 | +            $message = sprintf(app_translate('This %s does not exists'), $e->getObjectTitle().' ('.$e->getId().')'); | |
| 643 | 643 | $json = array( | 
| 644 | 644 | 'messages' => array( | 
| 645 | 645 | array( | 
| @@ -651,7 +651,7 @@ discard block | ||
| 651 | 651 | echo bab_json_encode($json); | 
| 652 | 652 | die; | 
| 653 | 653 | } | 
| 654 | - header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true, 404); | |
| 654 | + header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found', true, 404); | |
| 655 | 655 |          header('Cache-Control: no-cache, must-revalidate'); | 
| 656 | 656 |          header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | 
| 657 | 657 | |
| @@ -671,14 +671,14 @@ discard block | ||
| 671 | 671 | |
| 672 | 672 | private function errorPage(Exception $e) | 
| 673 | 673 |      { | 
| 674 | - header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal server error', true, 500); | |
| 674 | + header($_SERVER['SERVER_PROTOCOL'].' 500 Internal server error', true, 500); | |
| 675 | 675 | |
| 676 | - require_once $GLOBALS['babInstallPath'] . 'utilit/uiutil.php'; | |
| 676 | + require_once $GLOBALS['babInstallPath'].'utilit/uiutil.php'; | |
| 677 | 677 | $popup = new babBodyPopup(); | 
| 678 | 678 | $popup->babEcho( | 
| 679 | -            '<h1>' . $this->App()->translate('There was a problem when trying to perform this operation') . '</h1>' | |
| 680 | -            . '<h2 class="error">' . $this->App()->translate('Additional debugging information:') . '</h2>' | |
| 681 | - . '<p class="error">' . $e->getMessage() . ' ' . $e->getFile() . ' ' . $e->getLine() . ' ' . $e->getTraceAsString() . '</p>' | |
| 679 | +            '<h1>'.$this->App()->translate('There was a problem when trying to perform this operation').'</h1>' | |
| 680 | +            . '<h2 class="error">'.$this->App()->translate('Additional debugging information:').'</h2>' | |
| 681 | + . '<p class="error">'.$e->getMessage().' '.$e->getFile().' '.$e->getLine().' '.$e->getTraceAsString().'</p>' | |
| 682 | 682 | ); | 
| 683 | 683 | |
| 684 | 684 | |
| @@ -69,205 +69,205 @@ | ||
| 69 | 69 | |
| 70 | 70 | |
| 71 | 71 | |
| 72 | - /** | |
| 73 | - * @param string $sourceClass | |
| 74 | - */ | |
| 75 | - public function joinSource($sourceClass) | |
| 76 | -	{ | |
| 77 | -	    if (get_class($this->sourceId) !== $sourceClass . 'Set') { | |
| 78 | -    	    $this->hasOne('sourceId', $sourceClass . 'Set'); | |
| 79 | -    		$this->join('sourceId'); | |
| 80 | - } | |
| 81 | - } | |
| 82 | - | |
| 83 | - | |
| 84 | - /** | |
| 85 | - * @param string $targetClass | |
| 86 | - */ | |
| 87 | - public function joinTarget($targetClass = null) | |
| 88 | -	{ | |
| 89 | -	    if (get_class($this->targetId) !== $targetClass . 'Set') { | |
| 90 | -    		$this->hasOne('targetId', $targetClass . 'Set'); | |
| 91 | -    		$this->join('targetId'); | |
| 92 | - } | |
| 93 | - } | |
| 94 | - | |
| 95 | - | |
| 96 | - | |
| 97 | - public function sourceIsA($recordClass) | |
| 98 | -	{ | |
| 99 | - return $this->sourceClass->is($recordClass); | |
| 100 | - } | |
| 101 | - | |
| 102 | - /** | |
| 103 | - * | |
| 104 | - * @return ORM_Iterator | |
| 105 | - */ | |
| 106 | - public function selectForSource(app_Record $object, $targetClass = null, $linkType = null) | |
| 107 | -	{ | |
| 108 | - $criteria = $this->sourceId->is($object->id) | |
| 72 | + /** | |
| 73 | + * @param string $sourceClass | |
| 74 | + */ | |
| 75 | + public function joinSource($sourceClass) | |
| 76 | +    { | |
| 77 | +        if (get_class($this->sourceId) !== $sourceClass . 'Set') { | |
| 78 | +            $this->hasOne('sourceId', $sourceClass . 'Set'); | |
| 79 | +            $this->join('sourceId'); | |
| 80 | + } | |
| 81 | + } | |
| 82 | + | |
| 83 | + | |
| 84 | + /** | |
| 85 | + * @param string $targetClass | |
| 86 | + */ | |
| 87 | + public function joinTarget($targetClass = null) | |
| 88 | +    { | |
| 89 | +        if (get_class($this->targetId) !== $targetClass . 'Set') { | |
| 90 | +            $this->hasOne('targetId', $targetClass . 'Set'); | |
| 91 | +            $this->join('targetId'); | |
| 92 | + } | |
| 93 | + } | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + public function sourceIsA($recordClass) | |
| 98 | +    { | |
| 99 | + return $this->sourceClass->is($recordClass); | |
| 100 | + } | |
| 101 | + | |
| 102 | + /** | |
| 103 | + * | |
| 104 | + * @return ORM_Iterator | |
| 105 | + */ | |
| 106 | + public function selectForSource(app_Record $object, $targetClass = null, $linkType = null) | |
| 107 | +    { | |
| 108 | + $criteria = $this->sourceId->is($object->id) | |
| 109 | 109 | ->_AND_($this->sourceClass->is(get_class($object))); | 
| 110 | 110 | |
| 111 | -		if (isset($targetClass)) { | |
| 112 | - $this->joinTarget($targetClass); | |
| 113 | - $criteria = $criteria->_AND_($this->targetClass->is($targetClass)); | |
| 114 | - } | |
| 115 | - | |
| 116 | -		if (isset($linkType)) { | |
| 117 | -			if (is_array($linkType)) { | |
| 118 | - $criteria = $criteria->_AND_($this->type->in($linkType)); | |
| 119 | -			} else { | |
| 120 | - $criteria = $criteria->_AND_($this->type->is($linkType)); | |
| 121 | - } | |
| 122 | - } | |
| 123 | - | |
| 124 | -		if (is_a($this->targetId, 'app_TraceableRecordSet')) { | |
| 125 | - $criteria = $criteria->_AND_($this->targetId->deleted->is(false)); | |
| 126 | - } | |
| 127 | - | |
| 128 | - return $this->select($criteria); | |
| 129 | - } | |
| 130 | - | |
| 131 | - | |
| 132 | - /** | |
| 133 | - * | |
| 134 | - * @return ORM_Iterator | |
| 135 | - */ | |
| 136 | - public function selectForSources($objects, $targetClass, $linkType = null) | |
| 137 | -	{ | |
| 138 | - $sourceClass = null; | |
| 139 | - $sourceIds = array(); | |
| 140 | - | |
| 141 | -		foreach ($objects as $obj) { | |
| 142 | -			if (is_null($sourceClass)) { | |
| 143 | - $sourceClass = get_class($obj); | |
| 144 | - } | |
| 145 | - $sourceIds[] = $obj->id; | |
| 146 | - } | |
| 147 | - $criteria = $this->sourceId->in($sourceIds) | |
| 148 | - ->_AND_($this->sourceClass->is($sourceClass)); | |
| 149 | - | |
| 150 | -		if (isset($targetClass)) { | |
| 151 | - $this->joinTarget($targetClass); | |
| 152 | - $criteria = $criteria->_AND_($this->targetClass->is($targetClass)); | |
| 153 | - } | |
| 154 | - | |
| 155 | -		if (isset($linkType)) { | |
| 156 | -			if (is_array($linkType)) { | |
| 157 | - $criteria = $criteria->_AND_($this->type->in($linkType)); | |
| 158 | -			} else { | |
| 159 | - $criteria = $criteria->_AND_($this->type->is($linkType)); | |
| 160 | - } | |
| 161 | - } | |
| 162 | - return $this->select($criteria); | |
| 163 | - } | |
| 164 | - | |
| 165 | - | |
| 166 | - /** | |
| 167 | - * | |
| 168 | - * @return ORM_Iterator | |
| 169 | - */ | |
| 170 | - public function selectForTarget(app_Record $object, $sourceClass = null, $linkType = null) | |
| 171 | -	{ | |
| 172 | - $criteria = $this->targetId->is($object->id) | |
| 173 | - ->_AND_($this->targetClass->is(get_class($object))); | |
| 174 | - | |
| 175 | -		if (isset($sourceClass)) { | |
| 176 | - $this->joinSource($sourceClass); | |
| 177 | - $criteria = $criteria->_AND_($this->sourceClass->is($sourceClass)); | |
| 178 | - } | |
| 179 | - | |
| 180 | -		if (isset($linkType)) { | |
| 181 | -			if (is_array($linkType)) { | |
| 182 | - $criteria = $criteria->_AND_($this->type->in($linkType)); | |
| 183 | -			} else { | |
| 184 | - $criteria = $criteria->_AND_($this->type->is($linkType)); | |
| 185 | - } | |
| 186 | - } | |
| 187 | - | |
| 188 | - return $this->select($criteria); | |
| 189 | - } | |
| 190 | - | |
| 191 | - | |
| 192 | - /** | |
| 193 | - * | |
| 194 | - * @return ORM_Iterator | |
| 195 | - */ | |
| 196 | - public function selectForTargets($objects, $sourceClass = null, $linkType = null) | |
| 197 | -	{ | |
| 198 | - $targetClass = null; | |
| 199 | - $targetIds = array(); | |
| 200 | - | |
| 201 | -		foreach ($objects as $obj) { | |
| 202 | -			if (is_null($targetClass)) { | |
| 203 | - $targetClass = get_class($obj); | |
| 204 | - } | |
| 205 | - $targetIds[] = $obj->id; | |
| 206 | - } | |
| 207 | - $criteria = $this->targetId->in($targetIds) | |
| 208 | - ->_AND_($this->targetClass->is($targetClass)); | |
| 209 | - | |
| 210 | -		if (isset($sourceClass)) { | |
| 211 | - $this->joinSource($sourceClass); | |
| 212 | - $criteria = $criteria->_AND_($this->sourceClass->is($sourceClass)); | |
| 213 | - } | |
| 214 | - | |
| 215 | -		if (isset($linkType)) { | |
| 216 | -			if (is_array($linkType)) { | |
| 217 | - $criteria = $criteria->_AND_($this->type->in($linkType)); | |
| 218 | -			} else { | |
| 219 | - $criteria = $criteria->_AND_($this->type->is($linkType)); | |
| 220 | - } | |
| 221 | - } | |
| 222 | - | |
| 223 | - return $this->select($criteria); | |
| 224 | - } | |
| 225 | - | |
| 226 | - | |
| 227 | - | |
| 228 | - /** | |
| 229 | - * delete all links to an object | |
| 230 | - * | |
| 231 | - * @param app_Record $object | |
| 232 | - * @param string $targetClass if target class is set, links will be deleted only for target classes | |
| 233 | - * @param bool $deleteTarget if set to true, the target will be deleted to | |
| 234 | - */ | |
| 235 | - public function deleteForSource(app_Record $object, $targetClass = null, $deleteTarget = false, $linkType = null) | |
| 236 | -	{ | |
| 237 | - $set = clone $this; | |
| 238 | - $App = $object->App(); | |
| 239 | - | |
| 240 | - $criteria = $set->sourceId->is($object->id)->_AND_( | |
| 241 | - $set->sourceClass->is(get_class($object)) | |
| 242 | - ); | |
| 243 | - | |
| 244 | -		if (null !== $targetClass) { | |
| 245 | - $criteria = $criteria->_AND_( | |
| 246 | - $set->targetClass->is($targetClass) | |
| 247 | - ); | |
| 248 | - } | |
| 249 | -		if (null !== $linkType) { | |
| 250 | - $criteria = $criteria->_AND_( | |
| 251 | - $set->type->is($linkType) | |
| 252 | - ); | |
| 253 | - } | |
| 254 | - | |
| 255 | -		if ($deleteTarget) { | |
| 256 | -			foreach($set->select($criteria) as $link) { | |
| 257 | - | |
| 258 | - $className = $link->targetClass.'Set'; | |
| 259 | - | |
| 260 | - // remove prefix | |
| 261 | - | |
| 262 | - $className = mb_substr($className, 1 + mb_strpos($className, '_')); | |
| 263 | - $targetSet = $App->$className(); | |
| 264 | - | |
| 265 | - $targetSet->delete($targetSet->id->is($link->targetId)); | |
| 266 | - } | |
| 267 | - } | |
| 268 | - | |
| 269 | - return $set->delete($criteria); | |
| 270 | - } | |
| 111 | +        if (isset($targetClass)) { | |
| 112 | + $this->joinTarget($targetClass); | |
| 113 | + $criteria = $criteria->_AND_($this->targetClass->is($targetClass)); | |
| 114 | + } | |
| 115 | + | |
| 116 | +        if (isset($linkType)) { | |
| 117 | +            if (is_array($linkType)) { | |
| 118 | + $criteria = $criteria->_AND_($this->type->in($linkType)); | |
| 119 | +            } else { | |
| 120 | + $criteria = $criteria->_AND_($this->type->is($linkType)); | |
| 121 | + } | |
| 122 | + } | |
| 123 | + | |
| 124 | +        if (is_a($this->targetId, 'app_TraceableRecordSet')) { | |
| 125 | + $criteria = $criteria->_AND_($this->targetId->deleted->is(false)); | |
| 126 | + } | |
| 127 | + | |
| 128 | + return $this->select($criteria); | |
| 129 | + } | |
| 130 | + | |
| 131 | + | |
| 132 | + /** | |
| 133 | + * | |
| 134 | + * @return ORM_Iterator | |
| 135 | + */ | |
| 136 | + public function selectForSources($objects, $targetClass, $linkType = null) | |
| 137 | +    { | |
| 138 | + $sourceClass = null; | |
| 139 | + $sourceIds = array(); | |
| 140 | + | |
| 141 | +        foreach ($objects as $obj) { | |
| 142 | +            if (is_null($sourceClass)) { | |
| 143 | + $sourceClass = get_class($obj); | |
| 144 | + } | |
| 145 | + $sourceIds[] = $obj->id; | |
| 146 | + } | |
| 147 | + $criteria = $this->sourceId->in($sourceIds) | |
| 148 | + ->_AND_($this->sourceClass->is($sourceClass)); | |
| 149 | + | |
| 150 | +        if (isset($targetClass)) { | |
| 151 | + $this->joinTarget($targetClass); | |
| 152 | + $criteria = $criteria->_AND_($this->targetClass->is($targetClass)); | |
| 153 | + } | |
| 154 | + | |
| 155 | +        if (isset($linkType)) { | |
| 156 | +            if (is_array($linkType)) { | |
| 157 | + $criteria = $criteria->_AND_($this->type->in($linkType)); | |
| 158 | +            } else { | |
| 159 | + $criteria = $criteria->_AND_($this->type->is($linkType)); | |
| 160 | + } | |
| 161 | + } | |
| 162 | + return $this->select($criteria); | |
| 163 | + } | |
| 164 | + | |
| 165 | + | |
| 166 | + /** | |
| 167 | + * | |
| 168 | + * @return ORM_Iterator | |
| 169 | + */ | |
| 170 | + public function selectForTarget(app_Record $object, $sourceClass = null, $linkType = null) | |
| 171 | +    { | |
| 172 | + $criteria = $this->targetId->is($object->id) | |
| 173 | + ->_AND_($this->targetClass->is(get_class($object))); | |
| 174 | + | |
| 175 | +        if (isset($sourceClass)) { | |
| 176 | + $this->joinSource($sourceClass); | |
| 177 | + $criteria = $criteria->_AND_($this->sourceClass->is($sourceClass)); | |
| 178 | + } | |
| 179 | + | |
| 180 | +        if (isset($linkType)) { | |
| 181 | +            if (is_array($linkType)) { | |
| 182 | + $criteria = $criteria->_AND_($this->type->in($linkType)); | |
| 183 | +            } else { | |
| 184 | + $criteria = $criteria->_AND_($this->type->is($linkType)); | |
| 185 | + } | |
| 186 | + } | |
| 187 | + | |
| 188 | + return $this->select($criteria); | |
| 189 | + } | |
| 190 | + | |
| 191 | + | |
| 192 | + /** | |
| 193 | + * | |
| 194 | + * @return ORM_Iterator | |
| 195 | + */ | |
| 196 | + public function selectForTargets($objects, $sourceClass = null, $linkType = null) | |
| 197 | +    { | |
| 198 | + $targetClass = null; | |
| 199 | + $targetIds = array(); | |
| 200 | + | |
| 201 | +        foreach ($objects as $obj) { | |
| 202 | +            if (is_null($targetClass)) { | |
| 203 | + $targetClass = get_class($obj); | |
| 204 | + } | |
| 205 | + $targetIds[] = $obj->id; | |
| 206 | + } | |
| 207 | + $criteria = $this->targetId->in($targetIds) | |
| 208 | + ->_AND_($this->targetClass->is($targetClass)); | |
| 209 | + | |
| 210 | +        if (isset($sourceClass)) { | |
| 211 | + $this->joinSource($sourceClass); | |
| 212 | + $criteria = $criteria->_AND_($this->sourceClass->is($sourceClass)); | |
| 213 | + } | |
| 214 | + | |
| 215 | +        if (isset($linkType)) { | |
| 216 | +            if (is_array($linkType)) { | |
| 217 | + $criteria = $criteria->_AND_($this->type->in($linkType)); | |
| 218 | +            } else { | |
| 219 | + $criteria = $criteria->_AND_($this->type->is($linkType)); | |
| 220 | + } | |
| 221 | + } | |
| 222 | + | |
| 223 | + return $this->select($criteria); | |
| 224 | + } | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + /** | |
| 229 | + * delete all links to an object | |
| 230 | + * | |
| 231 | + * @param app_Record $object | |
| 232 | + * @param string $targetClass if target class is set, links will be deleted only for target classes | |
| 233 | + * @param bool $deleteTarget if set to true, the target will be deleted to | |
| 234 | + */ | |
| 235 | + public function deleteForSource(app_Record $object, $targetClass = null, $deleteTarget = false, $linkType = null) | |
| 236 | +    { | |
| 237 | + $set = clone $this; | |
| 238 | + $App = $object->App(); | |
| 239 | + | |
| 240 | + $criteria = $set->sourceId->is($object->id)->_AND_( | |
| 241 | + $set->sourceClass->is(get_class($object)) | |
| 242 | + ); | |
| 243 | + | |
| 244 | +        if (null !== $targetClass) { | |
| 245 | + $criteria = $criteria->_AND_( | |
| 246 | + $set->targetClass->is($targetClass) | |
| 247 | + ); | |
| 248 | + } | |
| 249 | +        if (null !== $linkType) { | |
| 250 | + $criteria = $criteria->_AND_( | |
| 251 | + $set->type->is($linkType) | |
| 252 | + ); | |
| 253 | + } | |
| 254 | + | |
| 255 | +        if ($deleteTarget) { | |
| 256 | +            foreach($set->select($criteria) as $link) { | |
| 257 | + | |
| 258 | + $className = $link->targetClass.'Set'; | |
| 259 | + | |
| 260 | + // remove prefix | |
| 261 | + | |
| 262 | + $className = mb_substr($className, 1 + mb_strpos($className, '_')); | |
| 263 | + $targetSet = $App->$className(); | |
| 264 | + | |
| 265 | + $targetSet->delete($targetSet->id->is($link->targetId)); | |
| 266 | + } | |
| 267 | + } | |
| 268 | + | |
| 269 | + return $set->delete($criteria); | |
| 270 | + } | |
| 271 | 271 | |
| 272 | 272 | |
| 273 | 273 | /** | 
| @@ -74,8 +74,8 @@ discard block | ||
| 74 | 74 | */ | 
| 75 | 75 | public function joinSource($sourceClass) | 
| 76 | 76 |  	{ | 
| 77 | -	    if (get_class($this->sourceId) !== $sourceClass . 'Set') { | |
| 78 | -    	    $this->hasOne('sourceId', $sourceClass . 'Set'); | |
| 77 | +	    if (get_class($this->sourceId) !== $sourceClass.'Set') { | |
| 78 | +    	    $this->hasOne('sourceId', $sourceClass.'Set'); | |
| 79 | 79 |      		$this->join('sourceId'); | 
| 80 | 80 | } | 
| 81 | 81 | } | 
| @@ -86,8 +86,8 @@ discard block | ||
| 86 | 86 | */ | 
| 87 | 87 | public function joinTarget($targetClass = null) | 
| 88 | 88 |  	{ | 
| 89 | -	    if (get_class($this->targetId) !== $targetClass . 'Set') { | |
| 90 | -    		$this->hasOne('targetId', $targetClass . 'Set'); | |
| 89 | +	    if (get_class($this->targetId) !== $targetClass.'Set') { | |
| 90 | +    		$this->hasOne('targetId', $targetClass.'Set'); | |
| 91 | 91 |      		$this->join('targetId'); | 
| 92 | 92 | } | 
| 93 | 93 | } | 
| @@ -253,7 +253,7 @@ discard block | ||
| 253 | 253 | } | 
| 254 | 254 | |
| 255 | 255 |  		if ($deleteTarget) { | 
| 256 | -			foreach($set->select($criteria) as $link) { | |
| 256 | +			foreach ($set->select($criteria) as $link) { | |
| 257 | 257 | |
| 258 | 258 | $className = $link->targetClass.'Set'; | 
| 259 | 259 | |
| @@ -239,7 +239,7 @@ discard block | ||
| 239 | 239 | return parent::delete($criteria); | 
| 240 | 240 | } | 
| 241 | 241 | |
| 242 | - require_once $GLOBALS['babInstallPath'] . '/utilit/dateTime.php'; | |
| 242 | + require_once $GLOBALS['babInstallPath'].'/utilit/dateTime.php'; | |
| 243 | 243 | $now = BAB_DateTime::now()->getIsoDateTime(); | 
| 244 | 244 | |
| 245 | 245 | $records = $this->select($criteria); | 
| @@ -274,7 +274,7 @@ discard block | ||
| 274 | 274 | return parent::save($record); | 
| 275 | 275 | } | 
| 276 | 276 | |
| 277 | - require_once $GLOBALS['babInstallPath'] . '/utilit/dateTime.php'; | |
| 277 | + require_once $GLOBALS['babInstallPath'].'/utilit/dateTime.php'; | |
| 278 | 278 | |
| 279 | 279 | $now = BAB_DateTime::now()->getIsoDateTime(); | 
| 280 | 280 | |
| @@ -304,11 +304,11 @@ discard block | ||
| 304 | 304 | */ | 
| 305 | 305 | private function uuid() | 
| 306 | 306 |      { | 
| 307 | - return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', | |
| 308 | - mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), | |
| 309 | - mt_rand( 0, 0x0fff ) | 0x4000, | |
| 310 | - mt_rand( 0, 0x3fff ) | 0x8000, | |
| 311 | - mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) ); | |
| 307 | +        return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', | |
| 308 | + mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), | |
| 309 | + mt_rand(0, 0x0fff) | 0x4000, | |
| 310 | + mt_rand(0, 0x3fff) | 0x8000, | |
| 311 | + mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)); | |
| 312 | 312 | } | 
| 313 | 313 | |
| 314 | 314 | /** | 
| @@ -398,7 +398,7 @@ discard block | ||
| 398 | 398 | |
| 399 | 399 |          $linkSet->hasOne('sourceId', get_class($this)); | 
| 400 | 400 | |
| 401 | - $criteria = $linkSet->targetClass->is(get_class($target)) | |
| 401 | + $criteria = $linkSet->targetClass->is(get_class($target)) | |
| 402 | 402 | ->_AND_($linkSet->targetId->is($target->id)) | 
| 403 | 403 | ->_AND_($linkSet->sourceClass->is($this->getRecordClassName())); | 
| 404 | 404 |          if (isset($linkType)) { | 
| @@ -428,7 +428,7 @@ discard block | ||
| 428 | 428 | |
| 429 | 429 |          $linkSet->hasOne('targetId', get_class($this)); | 
| 430 | 430 | |
| 431 | - $criteria = $linkSet->sourceClass->is(get_class($source)) | |
| 431 | + $criteria = $linkSet->sourceClass->is(get_class($source)) | |
| 432 | 432 | ->_AND_($linkSet->sourceId->is($source->id)) | 
| 433 | 433 | ->_AND_($linkSet->targetClass->is($this->getRecordClassName())); | 
| 434 | 434 |          if (isset($linkType)) { | 
| @@ -472,7 +472,7 @@ discard block | ||
| 472 | 472 | $sourcesCriteria[] = $linkSet->sourceClass->is($sourceClass)->_AND_($linkSet->sourceId->in($sourceIds)); | 
| 473 | 473 | } | 
| 474 | 474 | |
| 475 | - $criteria = $linkSet->all( | |
| 475 | + $criteria = $linkSet->all( | |
| 476 | 476 | $linkSet->targetClass->is($this->getRecordClassName()), | 
| 477 | 477 | $linkSet->any($sourcesCriteria) | 
| 478 | 478 | ); | 
| @@ -517,7 +517,7 @@ discard block | ||
| 517 | 517 | $targetsCriteria[] = $linkSet->targetClass->is($targetClass)->_AND_($linkSet->targetId->in($targetIds)); | 
| 518 | 518 | } | 
| 519 | 519 | |
| 520 | - $criteria = $linkSet->all( | |
| 520 | + $criteria = $linkSet->all( | |
| 521 | 521 | $linkSet->sourceClass->is($this->getRecordClassName()), | 
| 522 | 522 | $linkSet->any($targetsCriteria) | 
| 523 | 523 | ); | 
| @@ -575,7 +575,7 @@ discard block | ||
| 575 | 575 |      { | 
| 576 | 576 | $linkSet = $this->App()->LinkSet(); | 
| 577 | 577 | |
| 578 | - $criteria = $linkSet->sourceClass->is(get_class($source)) | |
| 578 | + $criteria = $linkSet->sourceClass->is(get_class($source)) | |
| 579 | 579 | ->_AND_($linkSet->sourceId->is($source->id)) | 
| 580 | 580 | ->_AND_($linkSet->targetClass->is(get_class($this))) | 
| 581 | 581 | ->_AND_($linkSet->targetId->is($this->id)); | 
| @@ -605,7 +605,7 @@ discard block | ||
| 605 | 605 |      { | 
| 606 | 606 | $linkSet = $this->App()->LinkSet(); | 
| 607 | 607 | |
| 608 | - $criteria = $linkSet->targetClass->is(get_class($target)) | |
| 608 | + $criteria = $linkSet->targetClass->is(get_class($target)) | |
| 609 | 609 | ->_AND_($linkSet->targetId->is($target->id)) | 
| 610 | 610 | ->_AND_($linkSet->sourceClass->is(get_class($this))) | 
| 611 | 611 | ->_AND_($linkSet->sourceId->is($this->id)); | 
| @@ -21,15 +21,15 @@ | ||
| 21 | 21 |   * @copyright Copyright (c) 2006 by CANTICO ({@link http://www.cantico.fr}) | 
| 22 | 22 | */ | 
| 23 | 23 | |
| 24 | -define('APP_PHP_PATH', dirname(__FILE__) . '/'); | |
| 25 | -define('APP_SET_PATH', dirname(__FILE__) . '/'); | |
| 26 | -define('APP_UI_PATH', dirname(__FILE__) . '/ui/'); | |
| 27 | -define('APP_CTRL_PATH', dirname(__FILE__) . '/'); | |
| 24 | +define('APP_PHP_PATH', dirname(__FILE__).'/'); | |
| 25 | +define('APP_SET_PATH', dirname(__FILE__).'/'); | |
| 26 | +define('APP_UI_PATH', dirname(__FILE__).'/ui/'); | |
| 27 | +define('APP_CTRL_PATH', dirname(__FILE__).'/'); | |
| 28 | 28 | |
| 29 | -require_once APP_PHP_PATH . 'base.class.php'; | |
| 30 | -require_once APP_UI_PATH . 'base.ui.php'; | |
| 29 | +require_once APP_PHP_PATH.'base.class.php'; | |
| 30 | +require_once APP_UI_PATH.'base.ui.php'; | |
| 31 | 31 | |
| 32 | -require_once $GLOBALS['babInstallPath'] . 'utilit/dateTime.php'; | |
| 32 | +require_once $GLOBALS['babInstallPath'].'utilit/dateTime.php'; | |
| 33 | 33 | |
| 34 | 34 | |
| 35 | 35 | |
| @@ -22,7 +22,7 @@ discard block | ||
| 22 | 22 | */ | 
| 23 | 23 | |
| 24 | 24 | |
| 25 | -require_once APP_CTRL_PATH . '/record.ctrl.php'; | |
| 25 | +require_once APP_CTRL_PATH.'/record.ctrl.php'; | |
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | /** | 
| @@ -74,7 +74,7 @@ discard block | ||
| 74 | 74 | $box = $W->VBoxItems(); | 
| 75 | 75 | |
| 76 | 76 |          foreach ($availableFields as $field) {
 | 
| 77 | - $fieldName = $field['name']; | |
| 77 | + $fieldName = $field['name']; | |
| 78 | 78 | $fieldDescription = $field['description']; | 
| 79 | 79 |              if (substr($fieldName, 0, 1) !== '_') {
 | 
| 80 | 80 | $fieldDescription = $App->translate($fieldDescription); | 
| @@ -280,7 +280,7 @@ discard block | ||
| 280 | 280 | $recordSet = $this->getRecordSet(); | 
| 281 | 281 | $record = $recordSet->request($id); | 
| 282 | 282 | |
| 283 | - $object = $record->object . 'Set'; | |
| 283 | + $object = $record->object.'Set'; | |
| 284 | 284 | |
| 285 | 285 | $objectRecordSet = $App->$object(); | 
| 286 | 286 | |
| @@ -354,7 +354,7 @@ discard block | ||
| 354 | 354 | $recordSet = $this->getRecordSet(); | 
| 355 | 355 | $record = $recordSet->request($data['id']); | 
| 356 | 356 | |
| 357 | - $object = $record->object . 'Set'; | |
| 357 | + $object = $record->object.'Set'; | |
| 358 | 358 | |
| 359 | 359 | $objectRecordSet = $App->$object(); | 
| 360 | 360 | |