@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | if (null === $url) { |
| 111 | 111 | $script = '<script type="text/javascript">'; |
| 112 | 112 | if (isset($message)) { |
| 113 | - $script .= 'alert("' . bab_toHtml($message, BAB_HTML_JS) . '");'; |
|
| 113 | + $script .= 'alert("'.bab_toHtml($message, BAB_HTML_JS).'");'; |
|
| 114 | 114 | } |
| 115 | 115 | $script .= 'history.back();'; |
| 116 | 116 | $script .= '</script>'; |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $url = $url->url(); |
| 123 | 123 | } |
| 124 | 124 | if (!empty($babBody->msgerror)) { |
| 125 | - $url .= '&msgerror=' . urlencode($babBody->msgerror); |
|
| 125 | + $url .= '&msgerror='.urlencode($babBody->msgerror); |
|
| 126 | 126 | } |
| 127 | 127 | if (isset($message)) { |
| 128 | 128 | $lines = explode("\n", $message); |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - header('Location: ' . $url); |
|
| 134 | + header('Location: '.$url); |
|
| 135 | 135 | die; |
| 136 | 136 | } |
| 137 | 137 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | function app_fileUploadError($error) |
| 165 | 165 | { |
| 166 | - switch($error) { |
|
| 166 | + switch ($error) { |
|
| 167 | 167 | case UPLOAD_ERR_OK: |
| 168 | 168 | return null; |
| 169 | 169 | |
@@ -274,25 +274,25 @@ discard block |
||
| 274 | 274 | return $imageUrl; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | -function app_utf8Decode($input){ |
|
| 278 | - if(is_array($input)){ |
|
| 277 | +function app_utf8Decode($input) { |
|
| 278 | + if (is_array($input)) { |
|
| 279 | 279 | $return = array(); |
| 280 | - foreach($input as $k=>$v){ |
|
| 280 | + foreach ($input as $k=>$v) { |
|
| 281 | 281 | $return[utf8_decode($k)] = app_utf8Decode($v); |
| 282 | 282 | } |
| 283 | - }else{ |
|
| 283 | + } else { |
|
| 284 | 284 | return utf8_decode($input); |
| 285 | 285 | } |
| 286 | 286 | return $return; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | -function app_utf8Encode($input){ |
|
| 290 | - if(is_array($input)){ |
|
| 289 | +function app_utf8Encode($input) { |
|
| 290 | + if (is_array($input)) { |
|
| 291 | 291 | $return = array(); |
| 292 | - foreach($input as $k=>$v){ |
|
| 292 | + foreach ($input as $k=>$v) { |
|
| 293 | 293 | $return[app_utf8Encode($k)] = app_utf8Encode($v); |
| 294 | 294 | } |
| 295 | - }else{ |
|
| 295 | + } else { |
|
| 296 | 296 | return utf8_encode($input); |
| 297 | 297 | } |
| 298 | 298 | return $return; |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | foreach($input as $k=>$v){ |
| 281 | 281 | $return[utf8_decode($k)] = app_utf8Decode($v); |
| 282 | 282 | } |
| 283 | - }else{ |
|
| 283 | + } else{ |
|
| 284 | 284 | return utf8_decode($input); |
| 285 | 285 | } |
| 286 | 286 | return $return; |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | foreach($input as $k=>$v){ |
| 293 | 293 | $return[app_utf8Encode($k)] = app_utf8Encode($v); |
| 294 | 294 | } |
| 295 | - }else{ |
|
| 295 | + } else{ |
|
| 296 | 296 | return utf8_encode($input); |
| 297 | 297 | } |
| 298 | 298 | return $return; |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | use Capwelton\LibOrm\MySql\ORMMySqlBackend; |
| 26 | 26 | |
| 27 | 27 | |
| 28 | -require_once dirname(__FILE__). '/functions.php'; |
|
| 28 | +require_once dirname(__FILE__).'/functions.php'; |
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | function LibApp_upgrade($sVersionBase, $sVersionIni) |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | $addon->unregisterFunctionality('App'); |
| 36 | 36 | $functionnalities = new bab_functionalities(); |
| 37 | - $functionnalities->registerNamespace('App',"Capwelton\LibApp\Func_App",$addon->getPhpPath().'Func_App.php'); |
|
| 37 | + $functionnalities->registerNamespace('App', "Capwelton\LibApp\Func_App", $addon->getPhpPath().'Func_App.php'); |
|
| 38 | 38 | |
| 39 | 39 | $addon->addEventListener('bab_eventBeforePageCreated', 'libapp_onBeforePageCreated', 'init.php', -10); |
| 40 | 40 | $App = app_App(); |
@@ -81,13 +81,13 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | $babBody = bab_getBody(); |
| 83 | 83 | $addon = bab_getAddonInfosInstance('libapp'); |
| 84 | - $babBody->addStyleSheet($addon->getStylePath() . '/styles.css'); |
|
| 85 | - $babBody->addJavascriptFile($addon->getTemplatePath() . 'libapp.js'); |
|
| 84 | + $babBody->addStyleSheet($addon->getStylePath().'/styles.css'); |
|
| 85 | + $babBody->addJavascriptFile($addon->getTemplatePath().'libapp.js'); |
|
| 86 | 86 | |
| 87 | 87 | $App = app_App(); |
| 88 | - if($App && $App->isSSEEnabled()){ |
|
| 89 | - $babBody->addJavascriptFile($addon->getTemplatePath() . 'notification.js'); |
|
| 90 | - if(bab_isUserLogged()){ |
|
| 88 | + if ($App && $App->isSSEEnabled()) { |
|
| 89 | + $babBody->addJavascriptFile($addon->getTemplatePath().'notification.js'); |
|
| 90 | + if (bab_isUserLogged()) { |
|
| 91 | 91 | $babBody->babecho('<script>window.libapp={"sseServerUrl": "'.$App->Controller()->SSE()->server()->url().'"}</script>'); |
| 92 | 92 | $babBody->addJavascriptFile($addon->getTemplatePath().'sse.js'); |
| 93 | 93 | } |
@@ -113,8 +113,8 @@ discard block |
||
| 113 | 113 | $addonPhpPath = $addon->getPhpPath(); |
| 114 | 114 | |
| 115 | 115 | require_once $GLOBALS['babInstallPath'].'utilit/functionalityincl.php'; |
| 116 | - require_once dirname(__FILE__) . '/Portlet/Func_PortletBackend_App.php'; |
|
| 116 | + require_once dirname(__FILE__).'/Portlet/Func_PortletBackend_App.php'; |
|
| 117 | 117 | $functionalities = new bab_functionalities(); |
| 118 | - $functionalities->registerClass('Func_PortletBackend_App', $addonPhpPath . '/Portlet/Func_PortletBackend_App.php'); |
|
| 118 | + $functionalities->registerClass('Func_PortletBackend_App', $addonPhpPath.'/Portlet/Func_PortletBackend_App.php'); |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | \ No newline at end of file |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $App = app_App(); |
| 69 | 69 | static $fieldsLayouts = null; |
| 70 | 70 | |
| 71 | - if(! isset($fieldsLayouts)){ |
|
| 71 | + if (!isset($fieldsLayouts)) { |
|
| 72 | 72 | $fieldsLayouts = array( |
| 73 | 73 | self::FIELDS_LAYOUT_VERTICAL_LABEL => $App->translate('Vertical label'), |
| 74 | 74 | self::FIELDS_LAYOUT_HORIZONTAL_LABEL => $App->translate('Horizontal label'), |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function getRawFields() |
| 87 | 87 | { |
| 88 | - if(empty($this->fields)){ |
|
| 88 | + if (empty($this->fields)) { |
|
| 89 | 89 | return array(); |
| 90 | 90 | } |
| 91 | 91 | return explode(',', $this->fields); |
@@ -110,13 +110,13 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | public function getFields() |
| 112 | 112 | { |
| 113 | - if(empty($this->fields)){ |
|
| 113 | + if (empty($this->fields)) { |
|
| 114 | 114 | return array(); |
| 115 | 115 | } |
| 116 | 116 | $fields = json_decode($this->fields, true); |
| 117 | 117 | |
| 118 | - if(json_last_error() === JSON_ERROR_NONE){ |
|
| 119 | - if(bab_charset::getIso() != bab_charset::UTF_8){ |
|
| 118 | + if (json_last_error() === JSON_ERROR_NONE) { |
|
| 119 | + if (bab_charset::getIso() != bab_charset::UTF_8) { |
|
| 120 | 120 | $fields = app_utf8Decode($fields); |
| 121 | 121 | } |
| 122 | 122 | return $fields; |
@@ -124,19 +124,19 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | $fields = array(); |
| 126 | 126 | $rawFields = $this->getRawFields(); |
| 127 | - foreach ($rawFields as $rawField){ |
|
| 128 | - if(empty($rawField)){ |
|
| 127 | + foreach ($rawFields as $rawField) { |
|
| 128 | + if (empty($rawField)) { |
|
| 129 | 129 | continue; |
| 130 | 130 | } |
| 131 | 131 | $params = array(); |
| 132 | 132 | |
| 133 | - if(strpos($rawField, ':') === false){ |
|
| 133 | + if (strpos($rawField, ':') === false) { |
|
| 134 | 134 | $fieldName = $rawField; |
| 135 | 135 | } |
| 136 | - else{ |
|
| 136 | + else { |
|
| 137 | 137 | list ($fieldName, $parameters) = explode(':', $rawField); |
| 138 | 138 | $parameters = explode(';', $parameters); |
| 139 | - foreach ($parameters as $parameter){ |
|
| 139 | + foreach ($parameters as $parameter) { |
|
| 140 | 140 | list ($key, $value) = explode('=', $parameter); |
| 141 | 141 | $params[$key] = $value; |
| 142 | 142 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | public function getField($searchedFieldName) |
| 171 | 171 | { |
| 172 | - if(empty($this->fields)){ |
|
| 172 | + if (empty($this->fields)) { |
|
| 173 | 173 | return null; |
| 174 | 174 | } |
| 175 | 175 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | public function addField($fieldName, $parameters = null) |
| 187 | 187 | { |
| 188 | 188 | $fields = $this->getFields(); |
| 189 | - if(! isset($parameters)){ |
|
| 189 | + if (!isset($parameters)) { |
|
| 190 | 190 | $fields[$fieldName] = array( |
| 191 | 191 | 'block' => '' |
| 192 | 192 | ); |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | $fields[$fieldName]['fieldname'] = $fieldName; |
| 196 | 196 | $fields[$fieldName]['parameters'] = $parameters; |
| 197 | - if(bab_charset::getIso() != bab_charset::UTF_8){ |
|
| 197 | + if (bab_charset::getIso() != bab_charset::UTF_8) { |
|
| 198 | 198 | $fields = app_utf8Encode($fields); |
| 199 | 199 | } |
| 200 | 200 | $this->fields = json_encode($fields); |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | { |
| 209 | 209 | $fields = $this->getFields(); |
| 210 | 210 | unset($fields[$removedFieldName]); |
| 211 | - if(bab_charset::getIso() != bab_charset::UTF_8){ |
|
| 211 | + if (bab_charset::getIso() != bab_charset::UTF_8) { |
|
| 212 | 212 | $fields = app_utf8Encode($fields); |
| 213 | 213 | } |
| 214 | 214 | $this->fields = json_encode($fields); |
@@ -226,24 +226,24 @@ discard block |
||
| 226 | 226 | { |
| 227 | 227 | $isFieldsGroup = false; |
| 228 | 228 | $fields = $this->getFields(); |
| 229 | - if(strpos($updatedFieldName, '_fieldsGroup') !== false){ |
|
| 229 | + if (strpos($updatedFieldName, '_fieldsGroup') !== false) { |
|
| 230 | 230 | $isFieldsGroup = true; |
| 231 | 231 | list (, $groupPos) = explode('_fieldsGroup', $updatedFieldName); |
| 232 | - if(! isset($groupPos) || empty($groupPos)){ |
|
| 232 | + if (!isset($groupPos) || empty($groupPos)) { |
|
| 233 | 233 | $groupPos = 0; |
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | - if(! isset($fields[$updatedFieldName])){ |
|
| 237 | - if($isFieldsGroup){ |
|
| 238 | - while (isset($fields[$updatedFieldName . $groupPos])){ |
|
| 239 | - $groupPos ++; |
|
| 236 | + if (!isset($fields[$updatedFieldName])) { |
|
| 237 | + if ($isFieldsGroup) { |
|
| 238 | + while (isset($fields[$updatedFieldName.$groupPos])) { |
|
| 239 | + $groupPos++; |
|
| 240 | 240 | } |
| 241 | 241 | $updatedFieldName .= $groupPos; |
| 242 | 242 | } |
| 243 | 243 | $this->addField($updatedFieldName, $parameters); |
| 244 | 244 | return $this; |
| 245 | 245 | } |
| 246 | - if(! isset($parameters)){ |
|
| 246 | + if (!isset($parameters)) { |
|
| 247 | 247 | $fields[$updatedFieldName] = array( |
| 248 | 248 | 'block' => '' |
| 249 | 249 | ); |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | } |
| 252 | 252 | $fields[$updatedFieldName]['fieldname'] = $updatedFieldName; |
| 253 | 253 | $fields[$updatedFieldName]['parameters'] = $parameters; |
| 254 | - if(bab_charset::getIso() != bab_charset::UTF_8){ |
|
| 254 | + if (bab_charset::getIso() != bab_charset::UTF_8) { |
|
| 255 | 255 | $fields = app_utf8Encode($fields); |
| 256 | 256 | } |
| 257 | 257 | $this->fields = json_encode($fields); |
@@ -261,11 +261,11 @@ discard block |
||
| 261 | 261 | public function addFieldToGroup($fieldGroupName, $fieldName, $parameters = null) |
| 262 | 262 | { |
| 263 | 263 | $fields = $this->getFields(); |
| 264 | - if(! isset($fields[$fieldGroupName])){ |
|
| 264 | + if (!isset($fields[$fieldGroupName])) { |
|
| 265 | 265 | return $this; |
| 266 | 266 | } |
| 267 | 267 | $groupFields = isset($fields[$fieldGroupName]['fields']) ? $fields[$fieldGroupName]['fields'] : array(); |
| 268 | - if(! isset($parameters)){ |
|
| 268 | + if (!isset($parameters)) { |
|
| 269 | 269 | $groupFields[$fieldName] = array( |
| 270 | 270 | 'block' => '' |
| 271 | 271 | ); |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | $groupFields[$fieldName]['fieldname'] = $fieldName; |
| 275 | 275 | $groupFields[$fieldName]['parameters'] = $parameters; |
| 276 | 276 | $fields[$fieldGroupName]['fields'] = $groupFields; |
| 277 | - if(bab_charset::getIso() != bab_charset::UTF_8){ |
|
| 277 | + if (bab_charset::getIso() != bab_charset::UTF_8) { |
|
| 278 | 278 | $fields = app_utf8Encode($fields); |
| 279 | 279 | } |
| 280 | 280 | $this->fields = json_encode($fields); |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | { |
| 289 | 289 | $fields = $this->getFields(); |
| 290 | 290 | unset($fields[$fieldGroupName]['fields'][$removedFieldName]); |
| 291 | - if(bab_charset::getIso() != bab_charset::UTF_8){ |
|
| 291 | + if (bab_charset::getIso() != bab_charset::UTF_8) { |
|
| 292 | 292 | $fields = app_utf8Encode($fields); |
| 293 | 293 | } |
| 294 | 294 | $this->fields = json_encode($fields); |
@@ -305,15 +305,15 @@ discard block |
||
| 305 | 305 | public function updateFieldGroup($fieldGroupName, $updatedFieldName, $parameters = null) |
| 306 | 306 | { |
| 307 | 307 | $fields = $this->getFields(); |
| 308 | - if(! isset($fields[$fieldGroupName])){ |
|
| 308 | + if (!isset($fields[$fieldGroupName])) { |
|
| 309 | 309 | return $this; |
| 310 | 310 | } |
| 311 | 311 | $groupFields = isset($fields[$fieldGroupName]['fields']) ? $fields[$fieldGroupName]['fields'] : array(); |
| 312 | - if(! isset($groupFields[$updatedFieldName])){ |
|
| 312 | + if (!isset($groupFields[$updatedFieldName])) { |
|
| 313 | 313 | $this->addFieldToGroup($fieldGroupName, $updatedFieldName, $parameters); |
| 314 | 314 | return $this; |
| 315 | 315 | } |
| 316 | - if(! isset($parameters)){ |
|
| 316 | + if (!isset($parameters)) { |
|
| 317 | 317 | $groupFields[$updatedFieldName] = array( |
| 318 | 318 | 'block' => '' |
| 319 | 319 | ); |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | $groupFields[$updatedFieldName]['fieldname'] = $updatedFieldName; |
| 324 | 324 | $groupFields[$updatedFieldName]['parameters'] = $parameters; |
| 325 | 325 | $fields[$fieldGroupName]['fields'] = $groupFields; |
| 326 | - if(bab_charset::getIso() != bab_charset::UTF_8){ |
|
| 326 | + if (bab_charset::getIso() != bab_charset::UTF_8) { |
|
| 327 | 327 | $fields = app_utf8Encode($fields); |
| 328 | 328 | } |
| 329 | 329 | $this->fields = json_encode($fields); |
@@ -337,46 +337,46 @@ discard block |
||
| 337 | 337 | */ |
| 338 | 338 | public function isVisibleForRecord(AppRecord $record) |
| 339 | 339 | { |
| 340 | - if(empty($this->visibilityCriteria)){ |
|
| 340 | + if (empty($this->visibilityCriteria)) { |
|
| 341 | 341 | return true; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | $App = \bab_functionality::get('App'); |
| 345 | 345 | $recordSet = $record->getParentSet(); |
| 346 | 346 | $arrCriteria = json_decode($this->visibilityCriteria, true); |
| 347 | - if(bab_charset::getIso() != bab_charset::UTF_8){ |
|
| 347 | + if (bab_charset::getIso() != bab_charset::UTF_8) { |
|
| 348 | 348 | $arrCriteria = app_utf8Decode($arrCriteria); |
| 349 | 349 | } |
| 350 | - foreach ($arrCriteria as $fieldName => $condition){ |
|
| 351 | - if(strpos($fieldName, '/') !== false){ |
|
| 350 | + foreach ($arrCriteria as $fieldName => $condition) { |
|
| 351 | + if (strpos($fieldName, '/') !== false) { |
|
| 352 | 352 | list ($oneField, $foreignField) = explode('/', $fieldName); |
| 353 | 353 | $field = $recordSet->$oneField()->$foreignField; |
| 354 | 354 | } |
| 355 | - else{ |
|
| 355 | + else { |
|
| 356 | 356 | $field = $recordSet->$fieldName; |
| 357 | 357 | } |
| 358 | - foreach ($condition as $op => $value){ |
|
| 359 | - if(! is_array($value)){ |
|
| 358 | + foreach ($condition as $op => $value) { |
|
| 359 | + if (!is_array($value)) { |
|
| 360 | 360 | $criteria = $field->$op($value); |
| 361 | 361 | } |
| 362 | - else{ |
|
| 363 | - foreach ($value as $foreignClassName => $foreignValues){ |
|
| 364 | - $foreignClassName = str_replace($App->classPrefix, '', $foreignClassName) . 'Set'; |
|
| 362 | + else { |
|
| 363 | + foreach ($value as $foreignClassName => $foreignValues) { |
|
| 364 | + $foreignClassName = str_replace($App->classPrefix, '', $foreignClassName).'Set'; |
|
| 365 | 365 | $foreignSet = $App->$foreignClassName(); |
| 366 | 366 | $foreignField = ''; |
| 367 | 367 | $foreignCondition = ''; |
| 368 | - foreach ($foreignValues as $foreignFieldName => $foreignConditions){ |
|
| 369 | - if($foreignFieldName === '_foreignField'){ |
|
| 368 | + foreach ($foreignValues as $foreignFieldName => $foreignConditions) { |
|
| 369 | + if ($foreignFieldName === '_foreignField') { |
|
| 370 | 370 | $foreignField = $foreignConditions; |
| 371 | 371 | } |
| 372 | - else{ |
|
| 373 | - foreach ($foreignConditions as $key => $val){ |
|
| 372 | + else { |
|
| 373 | + foreach ($foreignConditions as $key => $val) { |
|
| 374 | 374 | $foreignCondition = $foreignSet->$foreignFieldName->$key($val); |
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | } |
| 378 | 378 | } |
| 379 | - if(method_exists($foreignSet, 'getDefaultCriteria')){ |
|
| 379 | + if (method_exists($foreignSet, 'getDefaultCriteria')) { |
|
| 380 | 380 | $foreignCondition = $foreignCondition->_AND_($foreignSet->getDefaultCriteria()); |
| 381 | 381 | } |
| 382 | 382 | $criteria = $field->in($foreignCondition, $foreignField); |
@@ -103,11 +103,11 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | protected function trimSetName($setName) |
| 105 | 105 | { |
| 106 | - if(strpos($setName, '_') === false){ |
|
| 106 | + if (strpos($setName, '_') === false) { |
|
| 107 | 107 | return $setName; |
| 108 | 108 | } |
| 109 | 109 | $pos = strrpos($setName, '\\'); |
| 110 | - if($pos === false){ |
|
| 110 | + if ($pos === false) { |
|
| 111 | 111 | return explode('_', $setName)[1]; |
| 112 | 112 | } |
| 113 | 113 | return substr($setName, $pos + 1); |
@@ -122,13 +122,13 @@ discard block |
||
| 122 | 122 | public function join($fkFieldName) |
| 123 | 123 | { |
| 124 | 124 | $fkField = $this->getField($fkFieldName); |
| 125 | - if(! ($fkField instanceof ORMFkField)){ |
|
| 125 | + if (!($fkField instanceof ORMFkField)) { |
|
| 126 | 126 | return $this; |
| 127 | 127 | } |
| 128 | 128 | $setName = $fkField->getForeignSetName(); |
| 129 | 129 | |
| 130 | - if(! $setName || 'Set' === $setName){ |
|
| 131 | - throw new \Exception('The set name is missing on foreign key field ' . $fkFieldName); |
|
| 130 | + if (!$setName || 'Set' === $setName) { |
|
| 131 | + throw new \Exception('The set name is missing on foreign key field '.$fkFieldName); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | $appSetName = $this->trimSetName($setName); |
@@ -166,22 +166,22 @@ discard block |
||
| 166 | 166 | { |
| 167 | 167 | $App = $this->App(); |
| 168 | 168 | |
| 169 | - if(null === $this->customFields){ |
|
| 169 | + if (null === $this->customFields) { |
|
| 170 | 170 | $this->customFields = array(); |
| 171 | 171 | |
| 172 | - if(isset($App->CustomField)){ |
|
| 172 | + if (isset($App->CustomField)) { |
|
| 173 | 173 | $customFieldSet = $App->CustomFieldSet(); |
| 174 | 174 | $object = mb_substr(get_class($this), mb_strlen($App->classPrefix), - mb_strlen('Set')); |
| 175 | - try{ |
|
| 175 | + try { |
|
| 176 | 176 | $customFields = $customFieldSet->select($customFieldSet->object->is($object)); |
| 177 | 177 | |
| 178 | - foreach ($customFields as $customfield){ |
|
| 178 | + foreach ($customFields as $customfield) { |
|
| 179 | 179 | $this->customFields[] = $customfield; |
| 180 | 180 | |
| 181 | 181 | /*@var $customfield AppCustomField */ |
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | - catch (ORMBackEndSelectException $e){ |
|
| 184 | + catch (ORMBackEndSelectException $e) { |
|
| 185 | 185 | // table does not exist, this error is thrown by the install program while creating the sets |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -211,15 +211,15 @@ discard block |
||
| 211 | 211 | public function addCustomFields() |
| 212 | 212 | { |
| 213 | 213 | $customFields = $this->selectCustomFields(); |
| 214 | - foreach ($customFields as $customField){ |
|
| 214 | + foreach ($customFields as $customField) { |
|
| 215 | 215 | /*@var $customField AppCustomField */ |
| 216 | 216 | $description = $customField->name; |
| 217 | 217 | $ormField = $customField->getORMField()->setDescription($description); |
| 218 | - if($ormField instanceof ORMFkField){ |
|
| 218 | + if ($ormField instanceof ORMFkField) { |
|
| 219 | 219 | $this->hasOne($customField->fieldname, $ormField->getForeignSetName()) |
| 220 | 220 | ->setDescription($description); |
| 221 | 221 | } |
| 222 | - else{ |
|
| 222 | + else { |
|
| 223 | 223 | $this->addFields($ormField); |
| 224 | 224 | } |
| 225 | 225 | } |
@@ -248,12 +248,12 @@ discard block |
||
| 248 | 248 | public function request($mixedParam = null, $sPropertyName = null) |
| 249 | 249 | { |
| 250 | 250 | $record = $this->get($mixedParam, $sPropertyName); |
| 251 | - if(! isset($record)){ |
|
| 251 | + if (!isset($record)) { |
|
| 252 | 252 | // This will remove the default criteria for TraceableRecords and |
| 253 | 253 | // fetch even 'deleted' ones. |
| 254 | 254 | $this->setDefaultCriteria(null); |
| 255 | 255 | $record = $this->get($mixedParam, $sPropertyName); |
| 256 | - if(isset($record)){ |
|
| 256 | + if (isset($record)) { |
|
| 257 | 257 | throw new AppDeletedRecordException($record, $mixedParam); |
| 258 | 258 | } |
| 259 | 259 | throw new AppNotFoundException($this, $mixedParam); |
@@ -276,14 +276,14 @@ discard block |
||
| 276 | 276 | $linkSet = $this->App()->LinkSet(); |
| 277 | 277 | |
| 278 | 278 | $targetClass = $this->getRecordClassName(); |
| 279 | - if(strpos($targetClass, '\\')){ |
|
| 279 | + if (strpos($targetClass, '\\')) { |
|
| 280 | 280 | $targetClass = (new \ReflectionClass($targetClass))->getShortName(); |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - if(is_array($source) || ($source instanceof \Iterator)){ |
|
| 283 | + if (is_array($source) || ($source instanceof \Iterator)) { |
|
| 284 | 284 | return $linkSet->selectForSources($source, $targetClass, $linkType); |
| 285 | 285 | } |
| 286 | - else{ |
|
| 286 | + else { |
|
| 287 | 287 | return $linkSet->selectForSource($source, $targetClass, $linkType); |
| 288 | 288 | } |
| 289 | 289 | } |
@@ -303,14 +303,14 @@ discard block |
||
| 303 | 303 | $linkSet = $this->App()->LinkSet(); |
| 304 | 304 | |
| 305 | 305 | $sourceClass = $this->getRecordClassName(); |
| 306 | - if(strpos($sourceClass, '\\')){ |
|
| 306 | + if (strpos($sourceClass, '\\')) { |
|
| 307 | 307 | $sourceClass = (new \ReflectionClass($sourceClass))->getShortName(); |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - if(is_array($target) || ($target instanceof \Iterator)){ |
|
| 310 | + if (is_array($target) || ($target instanceof \Iterator)) { |
|
| 311 | 311 | return $linkSet->selectForTargets($target, $sourceClass, $linkType); |
| 312 | 312 | } |
| 313 | - else{ |
|
| 313 | + else { |
|
| 314 | 314 | return $linkSet->selectForTarget($target, $sourceClass, $linkType); |
| 315 | 315 | } |
| 316 | 316 | } |
@@ -328,13 +328,13 @@ discard block |
||
| 328 | 328 | $linkSet = $App->LinkSet(); |
| 329 | 329 | |
| 330 | 330 | $recordClassName = $this->getRecordClassName(); |
| 331 | - if(strpos($recordClassName, '\\')){ |
|
| 331 | + if (strpos($recordClassName, '\\')) { |
|
| 332 | 332 | $recordClassName = (new \ReflectionClass($recordClassName))->getShortName(); |
| 333 | 333 | } |
| 334 | 334 | $linkSet->hasOne('sourceId', $recordClassName); |
| 335 | 335 | |
| 336 | 336 | $targetClass = $target->getClassName(); |
| 337 | - if(strpos($targetClass, '\\')){ |
|
| 337 | + if (strpos($targetClass, '\\')) { |
|
| 338 | 338 | $targetClass = (new \ReflectionClass($targetClass))->getShortName(); |
| 339 | 339 | } |
| 340 | 340 | |
@@ -342,11 +342,11 @@ discard block |
||
| 342 | 342 | ->_AND_($linkSet->targetId->is($target->id)) |
| 343 | 343 | ->_AND_($linkSet->sourceClass->is($this->newRecord() |
| 344 | 344 | ->getClassName())); |
| 345 | - if(isset($linkType)){ |
|
| 346 | - if(is_array($linkType)){ |
|
| 345 | + if (isset($linkType)) { |
|
| 346 | + if (is_array($linkType)) { |
|
| 347 | 347 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 348 | 348 | } |
| 349 | - else{ |
|
| 349 | + else { |
|
| 350 | 350 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 351 | 351 | } |
| 352 | 352 | } |
@@ -368,29 +368,29 @@ discard block |
||
| 368 | 368 | $linkSet = $App->LinkSet(); |
| 369 | 369 | |
| 370 | 370 | $recordClassName = $this->getRecordClassName(); |
| 371 | - if(strpos($recordClassName, '\\')){ |
|
| 371 | + if (strpos($recordClassName, '\\')) { |
|
| 372 | 372 | $recordClassName = (new \ReflectionClass($recordClassName))->getShortName(); |
| 373 | 373 | } |
| 374 | 374 | $linkSet->hasOne('targetId', $recordClassName); |
| 375 | 375 | |
| 376 | 376 | $sourceClass = $source->getClassName(); |
| 377 | - if(strpos($sourceClass, '\\')){ |
|
| 377 | + if (strpos($sourceClass, '\\')) { |
|
| 378 | 378 | $sourceClass = new \ReflectionClass($sourceClass); |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | $targetClass = $this->newRecord()->getClassName(); |
| 382 | - if(strpos($targetClass, '\\')){ |
|
| 382 | + if (strpos($targetClass, '\\')) { |
|
| 383 | 383 | $targetClass = new \ReflectionClass($targetClass); |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | $criteria = $linkSet->sourceClass->is($sourceClass) |
| 387 | 387 | ->_AND_($linkSet->sourceId->is($source->id)) |
| 388 | 388 | ->_AND_($linkSet->targetClass->is($targetClass)); |
| 389 | - if(isset($linkType)){ |
|
| 390 | - if(is_array($linkType)){ |
|
| 389 | + if (isset($linkType)) { |
|
| 390 | + if (is_array($linkType)) { |
|
| 391 | 391 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 392 | 392 | } |
| 393 | - else{ |
|
| 393 | + else { |
|
| 394 | 394 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 395 | 395 | } |
| 396 | 396 | } |
@@ -412,39 +412,39 @@ discard block |
||
| 412 | 412 | $App = $this->App(); |
| 413 | 413 | $linkSet = $App->LinkSet(); |
| 414 | 414 | $recordClassName = $linkSet->getRecordClassName(); |
| 415 | - if(strpos($recordClassName, '\\')){ |
|
| 415 | + if (strpos($recordClassName, '\\')) { |
|
| 416 | 416 | $recordClassName = (new \ReflectionClass($recordClassName))->getShortName(); |
| 417 | 417 | } |
| 418 | 418 | $linkSet->hasOne('targetId', $recordClassName); |
| 419 | 419 | |
| 420 | 420 | $sourceIdsByClasses = array(); |
| 421 | - foreach ($sources as $source){ |
|
| 421 | + foreach ($sources as $source) { |
|
| 422 | 422 | $sourceClass = $source->getClassName(); |
| 423 | - if(strpos($sourceClass, '\\')){ |
|
| 423 | + if (strpos($sourceClass, '\\')) { |
|
| 424 | 424 | $sourceClass = (new \ReflectionClass($sourceClass))->getShortName(); |
| 425 | 425 | } |
| 426 | - if(! isset($sourceIdsByClasses[$sourceClass])){ |
|
| 426 | + if (!isset($sourceIdsByClasses[$sourceClass])) { |
|
| 427 | 427 | $sourceIdsByClasses[$sourceClass] = array(); |
| 428 | 428 | } |
| 429 | 429 | $sourceIdsByClasses[$sourceClass][] = $source->id; |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | $sourcesCriteria = array(); |
| 433 | - foreach ($sourceIdsByClasses as $sourceClass => $sourceIds){ |
|
| 433 | + foreach ($sourceIdsByClasses as $sourceClass => $sourceIds) { |
|
| 434 | 434 | $sourcesCriteria[] = $linkSet->sourceClass->is($sourceClass)->_AND_($linkSet->sourceId->in($sourceIds)); |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | $targetClass = $this->newRecord()->getClassName(); |
| 438 | - if(strpos($targetClass, '\\')){ |
|
| 438 | + if (strpos($targetClass, '\\')) { |
|
| 439 | 439 | $targetClass = (new \ReflectionClass($targetClass))->getShortName(); |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | $criteria = $linkSet->all($linkSet->targetClass->is($targetClass), $linkSet->any($sourcesCriteria)); |
| 443 | - if(isset($linkType)){ |
|
| 444 | - if(is_array($linkType)){ |
|
| 443 | + if (isset($linkType)) { |
|
| 444 | + if (is_array($linkType)) { |
|
| 445 | 445 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 446 | 446 | } |
| 447 | - else{ |
|
| 447 | + else { |
|
| 448 | 448 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 449 | 449 | } |
| 450 | 450 | } |
@@ -466,39 +466,39 @@ discard block |
||
| 466 | 466 | $App = $this->App(); |
| 467 | 467 | $linkSet = $App->LinkSet(); |
| 468 | 468 | $recordClassName = $this->getRecordClassName(); |
| 469 | - if(strpos($recordClassName, '\\')){ |
|
| 469 | + if (strpos($recordClassName, '\\')) { |
|
| 470 | 470 | $recordClassName = (new \ReflectionClass($recordClassName))->getShortName(); |
| 471 | 471 | } |
| 472 | 472 | $linkSet->hasOne('sourceId', $recordClassName); |
| 473 | 473 | |
| 474 | 474 | $targetIdsByClasses = array(); |
| 475 | - foreach ($targets as $target){ |
|
| 475 | + foreach ($targets as $target) { |
|
| 476 | 476 | $targetClass = $target->getClassName(); |
| 477 | - if(strpos($targetClass, '\\')){ |
|
| 477 | + if (strpos($targetClass, '\\')) { |
|
| 478 | 478 | $targetClass = (new \ReflectionClass($targetClass))->getShortName(); |
| 479 | 479 | } |
| 480 | - if(! isset($targetIdsByClasses[$targetClass])){ |
|
| 480 | + if (!isset($targetIdsByClasses[$targetClass])) { |
|
| 481 | 481 | $targetIdsByClasses[$targetClass] = array(); |
| 482 | 482 | } |
| 483 | 483 | $targetIdsByClasses[$targetClass][] = $target->id; |
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | $targetsCriteria = array(); |
| 487 | - foreach ($targetIdsByClasses as $targetClass => $targetIds){ |
|
| 487 | + foreach ($targetIdsByClasses as $targetClass => $targetIds) { |
|
| 488 | 488 | $targetsCriteria[] = $linkSet->targetClass->is($targetClass)->_AND_($linkSet->targetId->in($targetIds)); |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | $sourceClass = $this->newRecord()->getClassName(); |
| 492 | - if(strpos($sourceClass, '\\')){ |
|
| 492 | + if (strpos($sourceClass, '\\')) { |
|
| 493 | 493 | $sourceClass = (new \ReflectionClass($sourceClass))->getShortName(); |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | $criteria = $linkSet->all($linkSet->sourceClass->is($sourceClass), $linkSet->any($targetsCriteria)); |
| 497 | - if(isset($linkType)){ |
|
| 498 | - if(is_array($linkType)){ |
|
| 497 | + if (isset($linkType)) { |
|
| 498 | + if (is_array($linkType)) { |
|
| 499 | 499 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 500 | 500 | } |
| 501 | - else{ |
|
| 501 | + else { |
|
| 502 | 502 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 503 | 503 | } |
| 504 | 504 | } |
@@ -613,19 +613,19 @@ discard block |
||
| 613 | 613 | $criteria = $linkSet->sourceClass->is((new \ReflectionClass($this->getRecordClassName()))->getShortName()) |
| 614 | 614 | ->_AND_($linkSet->targetClass->is($tagClassName)); |
| 615 | 615 | |
| 616 | - if(is_array($tagLabels)){ |
|
| 616 | + if (is_array($tagLabels)) { |
|
| 617 | 617 | $criteria = $criteria->_AND_($linkSet->targetId->label->in($tagLabels)); |
| 618 | 618 | } |
| 619 | - else{ |
|
| 619 | + else { |
|
| 620 | 620 | $criteria = $criteria->_AND_($linkSet->targetId->label->is($tagLabels)); |
| 621 | 621 | } |
| 622 | - if(isset($linkType)){ |
|
| 622 | + if (isset($linkType)) { |
|
| 623 | 623 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 624 | 624 | } |
| 625 | 625 | $links = $linkSet->select($criteria); |
| 626 | 626 | |
| 627 | 627 | $ids = array(); |
| 628 | - foreach ($links as $link){ |
|
| 628 | + foreach ($links as $link) { |
|
| 629 | 629 | $ids[$link->sourceId] = $link->sourceId; |
| 630 | 630 | } |
| 631 | 631 | |
@@ -636,23 +636,23 @@ discard block |
||
| 636 | 636 | { |
| 637 | 637 | $fields = $this->getFields(); |
| 638 | 638 | $manyRelations = $this->getHasManyRelations(); |
| 639 | - foreach ($manyRelations as $fieldName => $manyRelation){ |
|
| 639 | + foreach ($manyRelations as $fieldName => $manyRelation) { |
|
| 640 | 640 | $fields[$fieldName] = $manyRelation; |
| 641 | 641 | } |
| 642 | 642 | return $fields; |
| 643 | 643 | } |
| 644 | 644 | |
| 645 | - public function getController($proxy = true){ |
|
| 645 | + public function getController($proxy = true) { |
|
| 646 | 646 | $name = $this->getRecordClassName(); |
| 647 | 647 | $reflection = new ReflectionClass($name); |
| 648 | 648 | $name = $reflection->getShortName(); |
| 649 | 649 | return $this->App()->Controller()->$name($proxy); |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | - public function getDisplayNameField(){ |
|
| 653 | - if($this->fieldExist("name")){ |
|
| 652 | + public function getDisplayNameField() { |
|
| 653 | + if ($this->fieldExist("name")) { |
|
| 654 | 654 | return $this->name; |
| 655 | - }else{ |
|
| 655 | + } else { |
|
| 656 | 656 | return $this->id; |
| 657 | 657 | } |
| 658 | 658 | } |
@@ -180,8 +180,7 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | /*@var $customfield AppCustomField */ |
| 182 | 182 | } |
| 183 | - } |
|
| 184 | - catch (ORMBackEndSelectException $e){ |
|
| 183 | + } catch (ORMBackEndSelectException $e){ |
|
| 185 | 184 | // table does not exist, this error is thrown by the install program while creating the sets |
| 186 | 185 | } |
| 187 | 186 | } |
@@ -218,8 +217,7 @@ discard block |
||
| 218 | 217 | if($ormField instanceof ORMFkField){ |
| 219 | 218 | $this->hasOne($customField->fieldname, $ormField->getForeignSetName()) |
| 220 | 219 | ->setDescription($description); |
| 221 | - } |
|
| 222 | - else{ |
|
| 220 | + } else{ |
|
| 223 | 221 | $this->addFields($ormField); |
| 224 | 222 | } |
| 225 | 223 | } |
@@ -282,8 +280,7 @@ discard block |
||
| 282 | 280 | |
| 283 | 281 | if(is_array($source) || ($source instanceof \Iterator)){ |
| 284 | 282 | return $linkSet->selectForSources($source, $targetClass, $linkType); |
| 285 | - } |
|
| 286 | - else{ |
|
| 283 | + } else{ |
|
| 287 | 284 | return $linkSet->selectForSource($source, $targetClass, $linkType); |
| 288 | 285 | } |
| 289 | 286 | } |
@@ -309,8 +306,7 @@ discard block |
||
| 309 | 306 | |
| 310 | 307 | if(is_array($target) || ($target instanceof \Iterator)){ |
| 311 | 308 | return $linkSet->selectForTargets($target, $sourceClass, $linkType); |
| 312 | - } |
|
| 313 | - else{ |
|
| 309 | + } else{ |
|
| 314 | 310 | return $linkSet->selectForTarget($target, $sourceClass, $linkType); |
| 315 | 311 | } |
| 316 | 312 | } |
@@ -345,8 +341,7 @@ discard block |
||
| 345 | 341 | if(isset($linkType)){ |
| 346 | 342 | if(is_array($linkType)){ |
| 347 | 343 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 348 | - } |
|
| 349 | - else{ |
|
| 344 | + } else{ |
|
| 350 | 345 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 351 | 346 | } |
| 352 | 347 | } |
@@ -389,8 +384,7 @@ discard block |
||
| 389 | 384 | if(isset($linkType)){ |
| 390 | 385 | if(is_array($linkType)){ |
| 391 | 386 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 392 | - } |
|
| 393 | - else{ |
|
| 387 | + } else{ |
|
| 394 | 388 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 395 | 389 | } |
| 396 | 390 | } |
@@ -443,8 +437,7 @@ discard block |
||
| 443 | 437 | if(isset($linkType)){ |
| 444 | 438 | if(is_array($linkType)){ |
| 445 | 439 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 446 | - } |
|
| 447 | - else{ |
|
| 440 | + } else{ |
|
| 448 | 441 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 449 | 442 | } |
| 450 | 443 | } |
@@ -497,8 +490,7 @@ discard block |
||
| 497 | 490 | if(isset($linkType)){ |
| 498 | 491 | if(is_array($linkType)){ |
| 499 | 492 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 500 | - } |
|
| 501 | - else{ |
|
| 493 | + } else{ |
|
| 502 | 494 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 503 | 495 | } |
| 504 | 496 | } |
@@ -615,8 +607,7 @@ discard block |
||
| 615 | 607 | |
| 616 | 608 | if(is_array($tagLabels)){ |
| 617 | 609 | $criteria = $criteria->_AND_($linkSet->targetId->label->in($tagLabels)); |
| 618 | - } |
|
| 619 | - else{ |
|
| 610 | + } else{ |
|
| 620 | 611 | $criteria = $criteria->_AND_($linkSet->targetId->label->is($tagLabels)); |
| 621 | 612 | } |
| 622 | 613 | if(isset($linkType)){ |
@@ -652,7 +643,7 @@ discard block |
||
| 652 | 643 | public function getDisplayNameField(){ |
| 653 | 644 | if($this->fieldExist("name")){ |
| 654 | 645 | return $this->name; |
| 655 | - }else{ |
|
| 646 | + } else{ |
|
| 656 | 647 | return $this->id; |
| 657 | 648 | } |
| 658 | 649 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | protected function logSave(AppTraceableRecord $record, $noTrace) |
| 135 | 135 | { |
| 136 | - if(! $this->isLoggable()){ |
|
| 136 | + if (!$this->isLoggable()) { |
|
| 137 | 137 | return; |
| 138 | 138 | } |
| 139 | 139 | $App = $this->App(); |
@@ -156,14 +156,14 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | protected function logDelete(ORMCriteria $criteria, $noTrace) |
| 158 | 158 | { |
| 159 | - if(! $this->isLoggable()){ |
|
| 159 | + if (!$this->isLoggable()) { |
|
| 160 | 160 | return; |
| 161 | 161 | } |
| 162 | 162 | $App = $this->App(); |
| 163 | 163 | $userId = bab_getUserId(); |
| 164 | 164 | $logSet = $App->LogSet(); |
| 165 | 165 | $deletedRecords = $this->select($criteria); |
| 166 | - foreach ($deletedRecords as $record){ |
|
| 166 | + foreach ($deletedRecords as $record) { |
|
| 167 | 167 | $log = $logSet->newRecord(); |
| 168 | 168 | $log->noTrace = $noTrace; |
| 169 | 169 | $log->objectClass = get_class($record); |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | public function select(ORMCriteria $criteria = null, $includeDeleted = false) |
| 191 | 191 | { |
| 192 | - if($includeDeleted){ |
|
| 192 | + if ($includeDeleted) { |
|
| 193 | 193 | $this->setDefaultCriteria(null); |
| 194 | 194 | } |
| 195 | 195 | return parent::select($criteria); |
@@ -232,25 +232,25 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | public function delete(ORMCriteria $criteria = null, $deletedStatus = AppTraceableRecord::DELETED_STATUS_DELETED) |
| 234 | 234 | { |
| 235 | - $definitive = ($deletedStatus === true) || ! $this->isTraceable(); |
|
| 235 | + $definitive = ($deletedStatus === true) || !$this->isTraceable(); |
|
| 236 | 236 | $this->logDelete($criteria, $definitive); |
| 237 | - if($definitive){ |
|
| 237 | + if ($definitive) { |
|
| 238 | 238 | return parent::delete($criteria); |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - require_once $GLOBALS['babInstallPath'] . '/utilit/dateTime.php'; |
|
| 241 | + require_once $GLOBALS['babInstallPath'].'/utilit/dateTime.php'; |
|
| 242 | 242 | $now = \BAB_DateTime::now()->getIsoDateTime(); |
| 243 | 243 | |
| 244 | 244 | $records = $this->select($criteria); |
| 245 | 245 | |
| 246 | - foreach ($records as $record){ |
|
| 246 | + foreach ($records as $record) { |
|
| 247 | 247 | /* @var $record AppTraceableRecord */ |
| 248 | 248 | // Could be optimized at ORM level |
| 249 | 249 | $record->deleted = $deletedStatus; |
| 250 | 250 | $record->deletedOn = $now; |
| 251 | 251 | $record->deletedBy = bab_getUserId(); |
| 252 | 252 | |
| 253 | - if(! parent::save($record)){ |
|
| 253 | + if (!parent::save($record)) { |
|
| 254 | 254 | return false; |
| 255 | 255 | } |
| 256 | 256 | } |
@@ -268,13 +268,13 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | public function save(ORMRecord $record, $noTrace = false) |
| 270 | 270 | { |
| 271 | - $noTrace = $noTrace || ! $this->isTraceable(); |
|
| 271 | + $noTrace = $noTrace || !$this->isTraceable(); |
|
| 272 | 272 | $this->logSave($record, $noTrace); |
| 273 | - if($noTrace){ |
|
| 273 | + if ($noTrace) { |
|
| 274 | 274 | return parent::save($record); |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - require_once $GLOBALS['babInstallPath'] . '/utilit/dateTime.php'; |
|
| 277 | + require_once $GLOBALS['babInstallPath'].'/utilit/dateTime.php'; |
|
| 278 | 278 | |
| 279 | 279 | $now = \BAB_DateTime::now()->getIsoDateTime(); |
| 280 | 280 | |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | $set = $record->getParentSet(); |
| 283 | 283 | $primaryKey = $set->getPrimaryKey(); |
| 284 | 284 | |
| 285 | - if(empty($record->{$primaryKey})){ |
|
| 285 | + if (empty($record->{$primaryKey})) { |
|
| 286 | 286 | $record->initValue('createdBy', bab_getUserId()); |
| 287 | 287 | $record->initValue('createdOn', $now); |
| 288 | 288 | $record->initValue('uuid', $this->uuid()); |
@@ -313,21 +313,21 @@ discard block |
||
| 313 | 313 | */ |
| 314 | 314 | public function getRecordByUuid($uuid) |
| 315 | 315 | { |
| 316 | - if('' === (string) $uuid){ |
|
| 316 | + if ('' === (string) $uuid) { |
|
| 317 | 317 | return null; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | $record = $this->get($this->uuid->is($uuid)); |
| 321 | 321 | |
| 322 | - if(! isset($record)){ |
|
| 322 | + if (!isset($record)) { |
|
| 323 | 323 | return null; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - if(! ($record instanceof AppTraceableRecord)){ |
|
| 326 | + if (!($record instanceof AppTraceableRecord)) { |
|
| 327 | 327 | return null; |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - if($record->deleted){ |
|
| 330 | + if ($record->deleted) { |
|
| 331 | 331 | return null; |
| 332 | 332 | } |
| 333 | 333 | |
@@ -343,16 +343,16 @@ discard block |
||
| 343 | 343 | */ |
| 344 | 344 | public function isOwn($userId = null) |
| 345 | 345 | { |
| 346 | - if(! isset($userId)){ |
|
| 346 | + if (!isset($userId)) { |
|
| 347 | 347 | $userId = bab_getUserId(); |
| 348 | 348 | } |
| 349 | 349 | return $this->createdBy->is($userId); |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - public function getDisplayNameField(){ |
|
| 353 | - if($this->fieldExist("name")){ |
|
| 352 | + public function getDisplayNameField() { |
|
| 353 | + if ($this->fieldExist("name")) { |
|
| 354 | 354 | return $this->name; |
| 355 | - }else{ |
|
| 355 | + } else { |
|
| 356 | 356 | return $this->uuid; |
| 357 | 357 | } |
| 358 | 358 | } |
@@ -352,7 +352,7 @@ |
||
| 352 | 352 | public function getDisplayNameField(){ |
| 353 | 353 | if($this->fieldExist("name")){ |
| 354 | 354 | return $this->name; |
| 355 | - }else{ |
|
| 355 | + } else{ |
|
| 356 | 356 | return $this->uuid; |
| 357 | 357 | } |
| 358 | 358 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | { |
| 57 | 57 | static $layouts = null; |
| 58 | 58 | |
| 59 | - if(! isset($layouts)){ |
|
| 59 | + if (!isset($layouts)) { |
|
| 60 | 60 | $layouts = array( |
| 61 | 61 | self::LAYOUT_VERTICAL_BOX => app_translate('Vertical box'), |
| 62 | 62 | self::LAYOUT_HORIZONTAL_BOX => app_translate('Horizontal box'), |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function isVisibleForRecord(AppRecord $record) |
| 75 | 75 | { |
| 76 | - if(empty($this->visibilityCriteria)){ |
|
| 76 | + if (empty($this->visibilityCriteria)) { |
|
| 77 | 77 | return true; |
| 78 | 78 | } |
| 79 | 79 | |
@@ -81,39 +81,39 @@ discard block |
||
| 81 | 81 | $recordSet = $record->getParentSet(); |
| 82 | 82 | |
| 83 | 83 | $arrCriteria = json_decode($this->visibilityCriteria, true); |
| 84 | - if(bab_charset::getIso() != bab_charset::UTF_8){ |
|
| 84 | + if (bab_charset::getIso() != bab_charset::UTF_8) { |
|
| 85 | 85 | $arrCriteria = app_utf8Encode($arrCriteria); |
| 86 | 86 | } |
| 87 | - foreach ($arrCriteria as $fieldName => $condition){ |
|
| 88 | - if(strpos($fieldName, '/') !== false){ |
|
| 87 | + foreach ($arrCriteria as $fieldName => $condition) { |
|
| 88 | + if (strpos($fieldName, '/') !== false) { |
|
| 89 | 89 | list ($oneField, $foreignField) = explode('/', $fieldName); |
| 90 | 90 | $field = $recordSet->$oneField()->$foreignField; |
| 91 | 91 | } |
| 92 | - else{ |
|
| 92 | + else { |
|
| 93 | 93 | $field = $recordSet->$fieldName; |
| 94 | 94 | } |
| 95 | - foreach ($condition as $op => $value){ |
|
| 96 | - if(! is_array($value)){ |
|
| 95 | + foreach ($condition as $op => $value) { |
|
| 96 | + if (!is_array($value)) { |
|
| 97 | 97 | $criteria = $field->$op($value); |
| 98 | 98 | } |
| 99 | - else{ |
|
| 100 | - foreach ($value as $foreignClassName => $foreignValues){ |
|
| 101 | - $foreignClassName = str_replace($App->classPrefix, '', $foreignClassName) . 'Set'; |
|
| 99 | + else { |
|
| 100 | + foreach ($value as $foreignClassName => $foreignValues) { |
|
| 101 | + $foreignClassName = str_replace($App->classPrefix, '', $foreignClassName).'Set'; |
|
| 102 | 102 | $foreignSet = $App->$foreignClassName(); |
| 103 | 103 | $foreignField = ''; |
| 104 | 104 | $foreignCondition = ''; |
| 105 | - foreach ($foreignValues as $foreignFieldName => $foreignConditions){ |
|
| 106 | - if($foreignFieldName === '_foreignField'){ |
|
| 105 | + foreach ($foreignValues as $foreignFieldName => $foreignConditions) { |
|
| 106 | + if ($foreignFieldName === '_foreignField') { |
|
| 107 | 107 | $foreignField = $foreignConditions; |
| 108 | 108 | } |
| 109 | - else{ |
|
| 110 | - foreach ($foreignConditions as $key => $val){ |
|
| 109 | + else { |
|
| 110 | + foreach ($foreignConditions as $key => $val) { |
|
| 111 | 111 | $foreignCondition = $foreignSet->$foreignFieldName->$key($val); |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | - if(method_exists($foreignSet, 'getDefaultCriteria')){ |
|
| 116 | + if (method_exists($foreignSet, 'getDefaultCriteria')) { |
|
| 117 | 117 | $foreignCondition = $foreignCondition->_AND_($foreignSet->getDefaultCriteria()); |
| 118 | 118 | } |
| 119 | 119 | $criteria = $field->in($foreignCondition, $foreignField); |
@@ -38,13 +38,13 @@ discard block |
||
| 38 | 38 | use Capwelton\LibOrm\ORMRecordSet; |
| 39 | 39 | use Capwelton\LibOrm\MySql\ORMMySqlBackend; |
| 40 | 40 | bab_Widgets(); |
| 41 | -require_once dirname(__FILE__) . '/define.php'; |
|
| 42 | -require_once dirname(__FILE__) . '/functions.php'; |
|
| 41 | +require_once dirname(__FILE__).'/define.php'; |
|
| 42 | +require_once dirname(__FILE__).'/functions.php'; |
|
| 43 | 43 | |
| 44 | 44 | $libappAddon = bab_getAddonInfosInstance('libapp'); |
| 45 | 45 | $libappPhpPath = $libappAddon->getPhpPath(); |
| 46 | 46 | |
| 47 | -require_once $libappPhpPath . '../vendor/autoload.php'; |
|
| 47 | +require_once $libappPhpPath.'../vendor/autoload.php'; |
|
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * Provides extensible functionalities to manage an application. |
@@ -80,13 +80,13 @@ discard block |
||
| 80 | 80 | $this->addonPrefix = 'app'; |
| 81 | 81 | |
| 82 | 82 | $this->classPrefix = 'App'; |
| 83 | - $this->controllerTg = 'addon/' . $this->addonName . '/main'; |
|
| 83 | + $this->controllerTg = 'addon/'.$this->addonName.'/main'; |
|
| 84 | 84 | |
| 85 | 85 | $addon = bab_getAddonInfosInstance($this->addonName); |
| 86 | 86 | $this->phpPath = $addon->getPhpPath(); |
| 87 | 87 | $this->recordSetPath = $this->phpPath; |
| 88 | 88 | $this->ctrlPath = $this->phpPath; |
| 89 | - $this->uiPath = $this->phpPath . 'ui/'; |
|
| 89 | + $this->uiPath = $this->phpPath.'ui/'; |
|
| 90 | 90 | |
| 91 | 91 | $babDB = bab_getDB(); |
| 92 | 92 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | if (class_exists($componentDefinitionObjectName)) { |
| 104 | 104 | $componentDefinition = new $componentDefinitionObjectName; |
| 105 | 105 | $components = $componentDefinition->getComponents($this); |
| 106 | - foreach ($components as $singleName => $singleComponent){ |
|
| 106 | + foreach ($components as $singleName => $singleComponent) { |
|
| 107 | 107 | $this->addComponent($singleName, $singleComponent); |
| 108 | 108 | } |
| 109 | 109 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | $nbElem = count($componentName); |
| 133 | 133 | $componentName = $componentName[$nbElem - 1]; |
| 134 | 134 | $componentName = strtoupper($componentName); |
| 135 | - if(isset($this->components[$componentName])){ |
|
| 135 | + if (isset($this->components[$componentName])) { |
|
| 136 | 136 | return $this->components[$componentName]; |
| 137 | 137 | } |
| 138 | 138 | return null; |
@@ -161,9 +161,9 @@ discard block |
||
| 161 | 161 | |
| 162 | 162 | public function __get($componentName) |
| 163 | 163 | { |
| 164 | - if(isset($this->components[$componentName])){ |
|
| 164 | + if (isset($this->components[$componentName])) { |
|
| 165 | 165 | return $this->components[$componentName]; |
| 166 | - }else{ |
|
| 166 | + } else { |
|
| 167 | 167 | return null; |
| 168 | 168 | } |
| 169 | 169 | } |
@@ -182,12 +182,12 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | $messages = array(); |
| 184 | 184 | |
| 185 | - foreach ($components as $componentName => $component){ |
|
| 185 | + foreach ($components as $componentName => $component) { |
|
| 186 | 186 | $dependencies = $component->checkDependencies(); |
| 187 | - foreach($dependencies['requiredComponents'] as $requiredComponent){ |
|
| 187 | + foreach ($dependencies['requiredComponents'] as $requiredComponent) { |
|
| 188 | 188 | $messages['requiredComponents'][$componentName][] = $requiredComponent; |
| 189 | 189 | } |
| 190 | - foreach($dependencies['optionalComponents'] as $optionalComponent){ |
|
| 190 | + foreach ($dependencies['optionalComponents'] as $optionalComponent) { |
|
| 191 | 191 | $messages['optionalComponents'][$componentName][] = $optionalComponent; |
| 192 | 192 | } |
| 193 | 193 | } |
@@ -199,9 +199,9 @@ discard block |
||
| 199 | 199 | { |
| 200 | 200 | $components = $this->getComponents(); |
| 201 | 201 | $componentDefinitions = array(); |
| 202 | - foreach ($components as $component){ |
|
| 202 | + foreach ($components as $component) { |
|
| 203 | 203 | $packageName = $component->getPackageName(); |
| 204 | - if(isset($componentDefinitions[$packageName]) && !empty($componentDefinitions[$packageName])){ |
|
| 204 | + if (isset($componentDefinitions[$packageName]) && !empty($componentDefinitions[$packageName])) { |
|
| 205 | 205 | continue; |
| 206 | 206 | } |
| 207 | 207 | $componentDefinitions[$packageName] = $component->getDefinition(); |
@@ -244,8 +244,8 @@ discard block |
||
| 244 | 244 | public function getRecordSetPathname($class) |
| 245 | 245 | { |
| 246 | 246 | // $App->MyRecordSet() -> myrecord.class.php |
| 247 | - $file = strtolower(substr($class, strlen($this->classPrefix), -3)) . '.class.php'; |
|
| 248 | - return $this->recordSetPath . $file; |
|
| 247 | + $file = strtolower(substr($class, strlen($this->classPrefix), -3)).'.class.php'; |
|
| 248 | + return $this->recordSetPath.$file; |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
@@ -257,8 +257,8 @@ discard block |
||
| 257 | 257 | public function getRecordPathname($class) |
| 258 | 258 | { |
| 259 | 259 | // $App->MyRecord() -> myrecord.class.php |
| 260 | - $file = strtolower(substr($class, strlen($this->classPrefix))) . '.class.php'; |
|
| 261 | - return $this->recordSetPath . $file; |
|
| 260 | + $file = strtolower(substr($class, strlen($this->classPrefix))).'.class.php'; |
|
| 261 | + return $this->recordSetPath.$file; |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /** |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | |
| 360 | 360 | if (substr($method, 0, 7) === 'include' && substr($method, -3) === 'Set') { |
| 361 | 361 | $incl = $method; |
| 362 | - $classNameMethod = substr($method, strlen('include')) . 'ClassName'; |
|
| 362 | + $classNameMethod = substr($method, strlen('include')).'ClassName'; |
|
| 363 | 363 | |
| 364 | 364 | |
| 365 | 365 | $classname = $this->$classNameMethod(); |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | // We need to revert to multilang fields before synchronizing. |
| 382 | 382 | $set->useLang(false); |
| 383 | 383 | } |
| 384 | - $sql .= $mysqlbackend->setToSql($set) . "\n"; |
|
| 384 | + $sql .= $mysqlbackend->setToSql($set)."\n"; |
|
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | } |
@@ -408,9 +408,9 @@ discard block |
||
| 408 | 408 | '; |
| 409 | 409 | |
| 410 | 410 | $noPackageNames = array(); |
| 411 | - foreach ($this->components as $component){ |
|
| 411 | + foreach ($this->components as $component) { |
|
| 412 | 412 | /* @var $component AppComponent */ |
| 413 | - try{ |
|
| 413 | + try { |
|
| 414 | 414 | /* @var $set ORMRecordSet */ |
| 415 | 415 | $set = $component->recordSet(); |
| 416 | 416 | //Check if the component is not overriden by the addon |
@@ -418,26 +418,26 @@ discard block |
||
| 418 | 418 | //In case the set has been overriden, we simply do nothing here, as it will be instanciated by the synchronizeSql method |
| 419 | 419 | $cmprc = new \ReflectionClass($set); |
| 420 | 420 | $componentSetClass = $cmprc->getShortName(); |
| 421 | - if(method_exists($this, $componentSetClass)){ |
|
| 421 | + if (method_exists($this, $componentSetClass)) { |
|
| 422 | 422 | continue; |
| 423 | 423 | } |
| 424 | - if(method_exists($set, 'useLang')){ |
|
| 424 | + if (method_exists($set, 'useLang')) { |
|
| 425 | 425 | // This is necessary if the recordSet constructor uses a setLang(). |
| 426 | 426 | // We need to revert to multilang fields before synchronizing. |
| 427 | 427 | $set->useLang(false); |
| 428 | 428 | } |
| 429 | - $sql .= $mysqlbackend->setToSql($set) . "\n"; |
|
| 429 | + $sql .= $mysqlbackend->setToSql($set)."\n"; |
|
| 430 | 430 | |
| 431 | - if(empty($component->getPackageName())){ |
|
| 431 | + if (empty($component->getPackageName())) { |
|
| 432 | 432 | $noPackageNames[] = $component->getName(); |
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | - catch (\Exception $e){ |
|
| 435 | + catch (\Exception $e) { |
|
| 436 | 436 | |
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - if(!empty($noPackageNames)){ |
|
| 440 | + if (!empty($noPackageNames)) { |
|
| 441 | 441 | $errorMessage = implode(', ', $noPackageNames); |
| 442 | 442 | \bab_installWindow::message( |
| 443 | 443 | sprintf( |
@@ -461,18 +461,18 @@ discard block |
||
| 461 | 461 | $synchronize->fromSqlString($sql); |
| 462 | 462 | |
| 463 | 463 | $dependencies = $this->checkComponentsDependencies(); |
| 464 | - foreach ($dependencies['requiredComponents'] as $componentName => $requiredComponents){ |
|
| 465 | - foreach ($requiredComponents as $requiredComponent){ |
|
| 464 | + foreach ($dependencies['requiredComponents'] as $componentName => $requiredComponents) { |
|
| 465 | + foreach ($requiredComponents as $requiredComponent) { |
|
| 466 | 466 | $hasComponent = $this->getComponentByName($requiredComponent); |
| 467 | - if(!$hasComponent){ |
|
| 467 | + if (!$hasComponent) { |
|
| 468 | 468 | \bab_installWindow::message(sprintf($this->translate('The component %s is required for the component %s to work. You will encounter fatal errors'), $requiredComponent, $componentName)); |
| 469 | 469 | } |
| 470 | 470 | } |
| 471 | 471 | } |
| 472 | - foreach ($dependencies['optionalComponents'] as $componentName => $optionalComponents){ |
|
| 473 | - foreach ($optionalComponents as $optionalComponent){ |
|
| 472 | + foreach ($dependencies['optionalComponents'] as $componentName => $optionalComponents) { |
|
| 473 | + foreach ($optionalComponents as $optionalComponent) { |
|
| 474 | 474 | $hasComponent = $this->getComponentByName($optionalComponent); |
| 475 | - if(!$hasComponent){ |
|
| 475 | + if (!$hasComponent) { |
|
| 476 | 476 | \bab_installWindow::message(sprintf($this->translate('The optional component %s has not been added. The component %s may have reduced functionalities'), $optionalComponent, $componentName)); |
| 477 | 477 | } |
| 478 | 478 | } |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | { |
| 486 | 486 | $components = $this->getComponents(); |
| 487 | 487 | |
| 488 | - foreach ($components as $component){ |
|
| 488 | + foreach ($components as $component) { |
|
| 489 | 489 | $component->onUpdate(); |
| 490 | 490 | } |
| 491 | 491 | |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | |
| 507 | 507 | if (substr($method, 0, strlen('include')) === 'include' && substr($method, -strlen('Set')) === 'Set') { |
| 508 | 508 | $incl = $method; |
| 509 | - $classNameMethod = substr($method, strlen('include')) . 'ClassName'; |
|
| 509 | + $classNameMethod = substr($method, strlen('include')).'ClassName'; |
|
| 510 | 510 | |
| 511 | 511 | $classname = $this->$classNameMethod(); |
| 512 | 512 | |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | |
| 521 | 521 | if (class_exists($classname) && method_exists($this, $call)) { |
| 522 | 522 | $set = $this->$call(); |
| 523 | - $sql .= $mysqlbackend->setToSql($set) . "\n"; |
|
| 523 | + $sql .= $mysqlbackend->setToSql($set)."\n"; |
|
| 524 | 524 | } |
| 525 | 525 | } |
| 526 | 526 | } |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | |
| 535 | 535 | public function includeBase() |
| 536 | 536 | { |
| 537 | - require_once APP_PHP_PATH . 'base.class.php'; |
|
| 537 | + require_once APP_PHP_PATH.'base.class.php'; |
|
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | /** |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | public function getRecordSetByRef($recordClassname) |
| 581 | 581 | { |
| 582 | 582 | $recordClassname = str_replace($this->classPrefix, '', $recordClassname); |
| 583 | - $classSet = $recordClassname . 'Set'; |
|
| 583 | + $classSet = $recordClassname.'Set'; |
|
| 584 | 584 | $set = $this->$classSet(); |
| 585 | 585 | return $set; |
| 586 | 586 | } |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | list($recordClassname, $id) = $refParts; |
| 602 | 602 | $set = $this->getRecordSetByRef($recordClassname); |
| 603 | 603 | if (isset($set)) { |
| 604 | - if($noDefaultCriteria){ |
|
| 604 | + if ($noDefaultCriteria) { |
|
| 605 | 605 | $set->setDefaultCriteria(null); |
| 606 | 606 | } |
| 607 | 607 | return $set->get($id); |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | { |
| 621 | 621 | $fullClassName = get_class($record); |
| 622 | 622 | list(, $className) = explode('_', $fullClassName); |
| 623 | - return $className . ':' . $record->id; |
|
| 623 | + return $className.':'.$record->id; |
|
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | |
@@ -675,7 +675,7 @@ discard block |
||
| 675 | 675 | |
| 676 | 676 | //Then, check if current component has a translation |
| 677 | 677 | if ($translation === $str) { |
| 678 | - if($currentComponent = $this->getCurrentComponent()){ |
|
| 678 | + if ($currentComponent = $this->getCurrentComponent()) { |
|
| 679 | 679 | $translator->setAddonName($currentComponent->getPackageName()); |
| 680 | 680 | $translator->setLangPath($currentComponent->getLangPath()); |
| 681 | 681 | $translation = $translator->translate($str, $str_plurals, $number); |
@@ -684,7 +684,7 @@ discard block |
||
| 684 | 684 | } |
| 685 | 685 | //Then, check if libapp has a translation |
| 686 | 686 | if ($translation === $str) { |
| 687 | - $translator->setLangPath(null);//Reset lang path |
|
| 687 | + $translator->setLangPath(null); //Reset lang path |
|
| 688 | 688 | $translator->setAddonName('libapp'); |
| 689 | 689 | $translation = $translator->translate($str, $str_plurals, $number); |
| 690 | 690 | } |
@@ -732,16 +732,16 @@ discard block |
||
| 732 | 732 | */ |
| 733 | 733 | public function mailTo($addr, $subject = null, $body = null) |
| 734 | 734 | { |
| 735 | - $mailTo = 'mailto:' . $addr; |
|
| 735 | + $mailTo = 'mailto:'.$addr; |
|
| 736 | 736 | $parameters = array(); |
| 737 | 737 | if (isset($subject)) { |
| 738 | - $parameters[] = 'subject=' . $subject; |
|
| 738 | + $parameters[] = 'subject='.$subject; |
|
| 739 | 739 | } |
| 740 | 740 | if (isset($body)) { |
| 741 | - $parameters[] = 'body=' . $body; |
|
| 741 | + $parameters[] = 'body='.$body; |
|
| 742 | 742 | } |
| 743 | 743 | if (!empty($parameters)) { |
| 744 | - $mailTo .= '?' . implode('&', $parameters); |
|
| 744 | + $mailTo .= '?'.implode('&', $parameters); |
|
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | return $mailTo; |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | } |
| 793 | 793 | |
| 794 | 794 | $number = number_format($number, $decimals, ',', ' '); |
| 795 | - return str_replace(' ', bab_nbsp(), $number . ' ' . $prefix . $unitSymbol); |
|
| 795 | + return str_replace(' ', bab_nbsp(), $number.' '.$prefix.$unitSymbol); |
|
| 796 | 796 | } |
| 797 | 797 | |
| 798 | 798 | |
@@ -812,7 +812,7 @@ discard block |
||
| 812 | 812 | } |
| 813 | 813 | |
| 814 | 814 | if (!isset($format)) { |
| 815 | - $format = \bab_registry::get('/' . $this->addonName . '/numberFormat', $PhoneNumber->getDefaultFormat()); |
|
| 815 | + $format = \bab_registry::get('/'.$this->addonName.'/numberFormat', $PhoneNumber->getDefaultFormat()); |
|
| 816 | 816 | } |
| 817 | 817 | $phoneNumberUtil = $PhoneNumber->PhoneNumberUtil(); |
| 818 | 818 | |
@@ -854,12 +854,12 @@ discard block |
||
| 854 | 854 | $rc = new \ReflectionClass($this); |
| 855 | 855 | $namespace = $rc->getNamespaceName(); |
| 856 | 856 | $prefix = ''; |
| 857 | - if(!empty($namespace)){ |
|
| 857 | + if (!empty($namespace)) { |
|
| 858 | 858 | $namespaces = explode('\\', $namespace); |
| 859 | 859 | $prefix = $namespaces[0].'\\'.$namespaces[1].'\Ctrl\\'; |
| 860 | 860 | } |
| 861 | 861 | $this->includeController(); |
| 862 | - return bab_getInstance($prefix.$this->classPrefix . 'Controller')->setApp($this); |
|
| 862 | + return bab_getInstance($prefix.$this->classPrefix.'Controller')->setApp($this); |
|
| 863 | 863 | } |
| 864 | 864 | |
| 865 | 865 | |
@@ -900,12 +900,12 @@ discard block |
||
| 900 | 900 | $rc = new \ReflectionClass($this); |
| 901 | 901 | $namespace = $rc->getNamespaceName(); |
| 902 | 902 | $prefix = ''; |
| 903 | - if(!empty($namespace)){ |
|
| 903 | + if (!empty($namespace)) { |
|
| 904 | 904 | $namespaces = explode('\\', $namespace); |
| 905 | 905 | $prefix = $namespaces[0].'\\'.$namespaces[1].'\Ui\\'; |
| 906 | 906 | } |
| 907 | 907 | $this->includeUi(); |
| 908 | - return bab_getInstance($prefix.$this->classPrefix . 'Ui')->setApp($this); |
|
| 908 | + return bab_getInstance($prefix.$this->classPrefix.'Ui')->setApp($this); |
|
| 909 | 909 | } |
| 910 | 910 | |
| 911 | 911 | /** |
@@ -933,38 +933,38 @@ discard block |
||
| 933 | 933 | |
| 934 | 934 | case substr($name, -strlen('SetClassName')) === 'SetClassName': |
| 935 | 935 | $className = substr($name, 0, strlen($name) - strlen('SetClassName')); |
| 936 | - if($component = $this->getComponentByName($className)){ |
|
| 936 | + if ($component = $this->getComponentByName($className)) { |
|
| 937 | 937 | return $component->getSetClassName(); |
| 938 | 938 | } |
| 939 | 939 | $setName = $className.'Set'; |
| 940 | - return $this->classPrefix . $setName; |
|
| 940 | + return $this->classPrefix.$setName; |
|
| 941 | 941 | |
| 942 | 942 | case substr($name, -strlen('ClassName')) === 'ClassName': |
| 943 | 943 | $recordName = substr($name, 0, strlen($name) - strlen('ClassName')); |
| 944 | - if($component = $this->getComponentByName($recordName)){ |
|
| 944 | + if ($component = $this->getComponentByName($recordName)) { |
|
| 945 | 945 | return $component->getRecordClassName(); |
| 946 | 946 | } |
| 947 | - return $this->classPrefix . $recordName; |
|
| 947 | + return $this->classPrefix.$recordName; |
|
| 948 | 948 | |
| 949 | 949 | case substr($name, 0, strlen('include')) === 'include' && substr($name, -strlen('Set')) === 'Set': |
| 950 | 950 | $fileNameBase = strtolower(substr(substr($name, 0, strlen($name) - strlen('Set')), strlen('include'))); |
| 951 | - if($this->getComponentByName($fileNameBase)){ |
|
| 951 | + if ($this->getComponentByName($fileNameBase)) { |
|
| 952 | 952 | return; |
| 953 | 953 | } |
| 954 | - $path = APP_SET_PATH . $fileNameBase . '.class.php'; |
|
| 955 | - if(is_file($path)){ |
|
| 954 | + $path = APP_SET_PATH.$fileNameBase.'.class.php'; |
|
| 955 | + if (is_file($path)) { |
|
| 956 | 956 | require_once $path; |
| 957 | 957 | } |
| 958 | 958 | return; |
| 959 | 959 | |
| 960 | 960 | case substr($name, -strlen('Set')) === 'Set': |
| 961 | - if($component = $this->getComponentByName(substr($name, 0, strlen($name) -strlen('Set')))){ |
|
| 961 | + if ($component = $this->getComponentByName(substr($name, 0, strlen($name) - strlen('Set')))) { |
|
| 962 | 962 | return $component->recordSet(); |
| 963 | 963 | } |
| 964 | 964 | |
| 965 | - $includeMethod = 'include' . $name; |
|
| 965 | + $includeMethod = 'include'.$name; |
|
| 966 | 966 | $this->$includeMethod(); |
| 967 | - $setClassNameMethod = $name . 'ClassName'; |
|
| 967 | + $setClassNameMethod = $name.'ClassName'; |
|
| 968 | 968 | $className = $this->$setClassNameMethod(); |
| 969 | 969 | $set = new $className($this); |
| 970 | 970 | return $set; |
@@ -972,8 +972,8 @@ discard block |
||
| 972 | 972 | case ($component = $this->getComponentByName($name)) != false: |
| 973 | 973 | return $component; |
| 974 | 974 | default: |
| 975 | - $setName = $name . 'Set'; |
|
| 976 | - $recordClassNameMethod = $name . 'ClassName'; |
|
| 975 | + $setName = $name.'Set'; |
|
| 976 | + $recordClassNameMethod = $name.'ClassName'; |
|
| 977 | 977 | $recordClassName = $this->$recordClassNameMethod(); |
| 978 | 978 | if (isset($arguments[0])) { |
| 979 | 979 | if ($arguments[0] instanceof $recordClassName) { |
@@ -987,38 +987,38 @@ discard block |
||
| 987 | 987 | } |
| 988 | 988 | |
| 989 | 989 | |
| 990 | - public function LinkSet(){ |
|
| 990 | + public function LinkSet() { |
|
| 991 | 991 | return $this->AppLinkSet(); |
| 992 | 992 | } |
| 993 | - public function AppLinkSet(){ |
|
| 993 | + public function AppLinkSet() { |
|
| 994 | 994 | return new AppLinkSet($this); |
| 995 | 995 | } |
| 996 | 996 | |
| 997 | - public function CustomFieldSet(){ |
|
| 997 | + public function CustomFieldSet() { |
|
| 998 | 998 | return $this->AppCustomFieldSet(); |
| 999 | 999 | } |
| 1000 | - public function AppCustomFieldSet(){ |
|
| 1000 | + public function AppCustomFieldSet() { |
|
| 1001 | 1001 | return new AppCustomFieldSet($this); |
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | - public function CustomContainerSet(){ |
|
| 1004 | + public function CustomContainerSet() { |
|
| 1005 | 1005 | return $this->AppCustomContainerSet(); |
| 1006 | 1006 | } |
| 1007 | - public function AppCustomContainerSet(){ |
|
| 1007 | + public function AppCustomContainerSet() { |
|
| 1008 | 1008 | return new AppCustomContainerSet($this); |
| 1009 | 1009 | } |
| 1010 | 1010 | |
| 1011 | - public function CustomSectionSet(){ |
|
| 1011 | + public function CustomSectionSet() { |
|
| 1012 | 1012 | return $this->AppCustomSectionSet(); |
| 1013 | 1013 | } |
| 1014 | - public function AppCustomSectionSet(){ |
|
| 1014 | + public function AppCustomSectionSet() { |
|
| 1015 | 1015 | return new AppCustomSectionSet($this); |
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | - public function LogSet(){ |
|
| 1018 | + public function LogSet() { |
|
| 1019 | 1019 | return $this->AppLogSet(); |
| 1020 | 1020 | } |
| 1021 | - public function AppLogSet(){ |
|
| 1021 | + public function AppLogSet() { |
|
| 1022 | 1022 | return new AppLogSet($this); |
| 1023 | 1023 | } |
| 1024 | 1024 | |
@@ -34,25 +34,25 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | public static function getLocaleApp() |
| 36 | 36 | { |
| 37 | - try{ |
|
| 37 | + try { |
|
| 38 | 38 | $rc = new \ReflectionClass(static::class); |
| 39 | 39 | $path = new \bab_Path($rc->getFileName()); |
| 40 | - for ($popLevel = 0; $popLevel < 7; $popLevel ++){ |
|
| 40 | + for ($popLevel = 0; $popLevel < 7; $popLevel++) { |
|
| 41 | 41 | $path->pop(); |
| 42 | 42 | } |
| 43 | 43 | $path->push('composer.json'); |
| 44 | - if(! $path->fileExists()){ |
|
| 44 | + if (!$path->fileExists()) { |
|
| 45 | 45 | return null; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $composer = file_get_contents($path->tostring()); |
| 49 | 49 | $composerjson = json_decode($composer, true); |
| 50 | - if(!isset($composerjson['appFunctionality']) || empty($composerjson['appFunctionality'])){ |
|
| 50 | + if (!isset($composerjson['appFunctionality']) || empty($composerjson['appFunctionality'])) { |
|
| 51 | 51 | return null; |
| 52 | 52 | } |
| 53 | 53 | return \bab_functionality::get($composerjson['appFunctionality']); |
| 54 | 54 | } |
| 55 | - catch (\Exception $e){ |
|
| 55 | + catch (\Exception $e) { |
|
| 56 | 56 | return null; |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -51,8 +51,7 @@ |
||
| 51 | 51 | return null; |
| 52 | 52 | } |
| 53 | 53 | return \bab_functionality::get($composerjson['appFunctionality']); |
| 54 | - } |
|
| 55 | - catch (\Exception $e){ |
|
| 54 | + } catch (\Exception $e){ |
|
| 56 | 55 | return null; |
| 57 | 56 | } |
| 58 | 57 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | $customSection = $customSectionSet->request($customSectionSet->id->is($section)); |
| 62 | 62 | |
| 63 | 63 | $object = $customSection->container->object; |
| 64 | - if(strpos($object, $App->classPrefix) !== false){ |
|
| 64 | + if (strpos($object, $App->classPrefix) !== false) { |
|
| 65 | 65 | list (, $object) = explode($App->classPrefix, $object); |
| 66 | 66 | } |
| 67 | 67 | $objectCtrl = $App->Controller()->$object(false); |
@@ -70,18 +70,18 @@ discard block |
||
| 70 | 70 | ->_AND_($customSectionSet->object->is($customSection->object))); |
| 71 | 71 | |
| 72 | 72 | $allViewFieldNames = array(); |
| 73 | - foreach ($allViewSections as $viewSection){ |
|
| 73 | + foreach ($allViewSections as $viewSection) { |
|
| 74 | 74 | $fields = $viewSection->getFields(); |
| 75 | - foreach ($fields as $field){ |
|
| 76 | - $allViewFieldNames[$field['fieldname']] = $viewSection->view . ',' . $viewSection->rank . ',' . $viewSection->id; |
|
| 77 | - foreach ($field['fields'] as $subField){ |
|
| 78 | - $allViewFieldNames[$subField['fieldname']] = $viewSection->view . ',' . $viewSection->rank . ',' . $viewSection->id; |
|
| 75 | + foreach ($fields as $field) { |
|
| 76 | + $allViewFieldNames[$field['fieldname']] = $viewSection->view.','.$viewSection->rank.','.$viewSection->id; |
|
| 77 | + foreach ($field['fields'] as $subField) { |
|
| 78 | + $allViewFieldNames[$subField['fieldname']] = $viewSection->view.','.$viewSection->rank.','.$viewSection->id; |
|
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | $box = $W->VBoxItems(); |
| 84 | - if(isset($itemId)){ |
|
| 84 | + if (isset($itemId)) { |
|
| 85 | 85 | $box->setId($itemId); |
| 86 | 86 | } |
| 87 | 87 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | \bab_Sort::asort($availableFields, 'description', \bab_Sort::CASE_INSENSITIVE); |
| 98 | 98 | |
| 99 | - foreach ($availableFields as $field){ |
|
| 99 | + foreach ($availableFields as $field) { |
|
| 100 | 100 | $fieldName = $field['name']; |
| 101 | 101 | $fieldDescription = $field['description']; |
| 102 | 102 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | $field = $customSection->getField($fieldName); |
| 153 | 153 | |
| 154 | - if(! isset($field)){ |
|
| 154 | + if (!isset($field)) { |
|
| 155 | 155 | return null; |
| 156 | 156 | } |
| 157 | 157 | |
@@ -168,11 +168,11 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | $field = $availableFields[$fieldName]; |
| 170 | 170 | $fieldDescription = $field['description']; |
| 171 | - if(substr($fieldName, 0, 1) !== '_'){ |
|
| 171 | + if (substr($fieldName, 0, 1) !== '_') { |
|
| 172 | 172 | $fieldDescription = $App->translate($fieldDescription); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - if(empty($field)){ |
|
| 175 | + if (empty($field)) { |
|
| 176 | 176 | // continue; |
| 177 | 177 | } |
| 178 | 178 | |
@@ -242,12 +242,12 @@ discard block |
||
| 242 | 242 | |
| 243 | 243 | $groupField = $customSection->getField($fieldGroupName); |
| 244 | 244 | |
| 245 | - if(! isset($groupField)){ |
|
| 245 | + if (!isset($groupField)) { |
|
| 246 | 246 | return null; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | $field = $groupField['fields'][$fieldName]; |
| 250 | - if(! isset($field)){ |
|
| 250 | + if (!isset($field)) { |
|
| 251 | 251 | return null; |
| 252 | 252 | } |
| 253 | 253 | |
@@ -263,11 +263,11 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | $field = $availableFields[$fieldName]; |
| 265 | 265 | $fieldDescription = $field['description']; |
| 266 | - if(substr($fieldName, 0, 1) !== '_'){ |
|
| 266 | + if (substr($fieldName, 0, 1) !== '_') { |
|
| 267 | 267 | $fieldDescription = $App->translate($fieldDescription); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - if(empty($field)){ |
|
| 270 | + if (empty($field)) { |
|
| 271 | 271 | // continue; |
| 272 | 272 | } |
| 273 | 273 | |
@@ -350,12 +350,12 @@ discard block |
||
| 350 | 350 | |
| 351 | 351 | $customSection = $customSectionSet->request($customSectionSet->id->is($section)); |
| 352 | 352 | $fields = $customSection->getFields(); |
| 353 | - if(! isset($fields[$fieldGroupName])){ |
|
| 353 | + if (!isset($fields[$fieldGroupName])) { |
|
| 354 | 354 | throw new AppException($App->translate('This fields group does not seem to exist')); |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | $object = $customSection->container->object; |
| 358 | - if(strpos($object, $App->classPrefix) !== false){ |
|
| 358 | + if (strpos($object, $App->classPrefix) !== false) { |
|
| 359 | 359 | list (, $object) = explode($App->classPrefix, $object); |
| 360 | 360 | } |
| 361 | 361 | |
@@ -365,18 +365,18 @@ discard block |
||
| 365 | 365 | ->_AND_($customSectionSet->object->is($customSection->object))); |
| 366 | 366 | |
| 367 | 367 | $allViewFieldNames = array(); |
| 368 | - foreach ($allViewSections as $viewSection){ |
|
| 368 | + foreach ($allViewSections as $viewSection) { |
|
| 369 | 369 | $fields = $viewSection->getFields(); |
| 370 | - foreach ($fields as $field){ |
|
| 371 | - $allViewFieldNames[$field['fieldname']] = $viewSection->view . ',' . $viewSection->rank . ',' . $viewSection->id; |
|
| 372 | - foreach ($field['fields'] as $subField){ |
|
| 373 | - $allViewFieldNames[$subField['fieldname']] = $viewSection->view . ',' . $viewSection->rank . ',' . $viewSection->id; |
|
| 370 | + foreach ($fields as $field) { |
|
| 371 | + $allViewFieldNames[$field['fieldname']] = $viewSection->view.','.$viewSection->rank.','.$viewSection->id; |
|
| 372 | + foreach ($field['fields'] as $subField) { |
|
| 373 | + $allViewFieldNames[$subField['fieldname']] = $viewSection->view.','.$viewSection->rank.','.$viewSection->id; |
|
| 374 | 374 | } |
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | $box = $W->VBoxItems(); |
| 379 | - if(isset($itemId)){ |
|
| 379 | + if (isset($itemId)) { |
|
| 380 | 380 | $box->setId($itemId); |
| 381 | 381 | } |
| 382 | 382 | |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | |
| 394 | 394 | \bab_Sort::asort($availableFields, 'description', \bab_Sort::CASE_INSENSITIVE); |
| 395 | 395 | |
| 396 | - foreach ($availableFields as $field){ |
|
| 396 | + foreach ($availableFields as $field) { |
|
| 397 | 397 | $fieldName = $field['name']; |
| 398 | 398 | $fieldDescription = $field['description']; |
| 399 | 399 | |
@@ -505,10 +505,10 @@ discard block |
||
| 505 | 505 | $container = $customContainerSet->request($customContainerSet->id->is($container)); |
| 506 | 506 | |
| 507 | 507 | $customSectionSet = $App->CustomSectionSet(); |
| 508 | - if(isset($id)){ |
|
| 508 | + if (isset($id)) { |
|
| 509 | 509 | $record = $customSectionSet->request($id); |
| 510 | 510 | } |
| 511 | - else{ |
|
| 511 | + else { |
|
| 512 | 512 | $record = $customSectionSet->newRecord(); |
| 513 | 513 | $record->container = $container->id; |
| 514 | 514 | } |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | |
| 521 | 521 | $editor = new AppEditor($App); |
| 522 | 522 | $editor->setHiddenValue('tg', $App->controllerTg); |
| 523 | - if($record->id){ |
|
| 523 | + if ($record->id) { |
|
| 524 | 524 | $editor->setHiddenValue('data[id]', $record->id); |
| 525 | 525 | } |
| 526 | 526 | $editor->setName('data'); |
@@ -536,16 +536,16 @@ discard block |
||
| 536 | 536 | |
| 537 | 537 | $options = array(); |
| 538 | 538 | $rank = 1; |
| 539 | - foreach ($containers as $container){ |
|
| 539 | + foreach ($containers as $container) { |
|
| 540 | 540 | $options[$container->id] = sprintf('%d (%s)', $rank, $container->name); |
| 541 | - $rank ++; |
|
| 541 | + $rank++; |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | $containerSections = $customSectionSet->select($customSectionSet->container->is($container->id)) |
| 545 | 545 | ->orderDesc($customSectionSet->rank); |
| 546 | 546 | |
| 547 | 547 | $nbSections = 0; |
| 548 | - foreach ($containerSections as $containerSection){ |
|
| 548 | + foreach ($containerSections as $containerSection) { |
|
| 549 | 549 | $nbSections = $containerSection->rank + 1; |
| 550 | 550 | break; |
| 551 | 551 | } |
@@ -629,10 +629,10 @@ discard block |
||
| 629 | 629 | $record = $recordSet->request($id); |
| 630 | 630 | |
| 631 | 631 | $object = $record->object; |
| 632 | - if(empty($object)){ |
|
| 632 | + if (empty($object)) { |
|
| 633 | 633 | $object = $record->container()->object; |
| 634 | 634 | } |
| 635 | - if(strpos($object, $App->classPrefix) !== false){ |
|
| 635 | + if (strpos($object, $App->classPrefix) !== false) { |
|
| 636 | 636 | $object = str_replace($App->classPrefix, '', $object); |
| 637 | 637 | } |
| 638 | 638 | $object .= 'Set'; |
@@ -647,25 +647,25 @@ discard block |
||
| 647 | 647 | $manySets = $objectRecordSet->getHasManyRelations(); |
| 648 | 648 | $oneSets = $objectRecordSet->getHasOneRelations(); |
| 649 | 649 | |
| 650 | - if(! empty($record->visibilityCriteria)){ |
|
| 650 | + if (!empty($record->visibilityCriteria)) { |
|
| 651 | 651 | $arrCriteria = json_decode($record->visibilityCriteria, true); |
| 652 | 652 | |
| 653 | 653 | $data = array(); |
| 654 | - foreach ($arrCriteria as $fieldName => $operation){ |
|
| 654 | + foreach ($arrCriteria as $fieldName => $operation) { |
|
| 655 | 655 | $data['field'] = $fieldName; |
| 656 | - foreach ($operation as $condition => $value){ |
|
| 656 | + foreach ($operation as $condition => $value) { |
|
| 657 | 657 | $data['condition']['default'] = $condition; |
| 658 | 658 | $data['condition']['bool'] = $condition; |
| 659 | - if(is_array($value)){ |
|
| 660 | - foreach ($value as $key => $subValue){ |
|
| 661 | - foreach ($manySets as $manyFieldName => $manyRelation){ |
|
| 662 | - if($key . 'Set' == $manyRelation->getForeignSetClassName()){ |
|
| 663 | - foreach ($subValue as $subFieldName => $subConditions){ |
|
| 664 | - if($subFieldName === '_foreignField'){ |
|
| 659 | + if (is_array($value)) { |
|
| 660 | + foreach ($value as $key => $subValue) { |
|
| 661 | + foreach ($manySets as $manyFieldName => $manyRelation) { |
|
| 662 | + if ($key.'Set' == $manyRelation->getForeignSetClassName()) { |
|
| 663 | + foreach ($subValue as $subFieldName => $subConditions) { |
|
| 664 | + if ($subFieldName === '_foreignField') { |
|
| 665 | 665 | continue; |
| 666 | 666 | } |
| 667 | 667 | $data['field'] = "{$manyFieldName}/{$subFieldName}"; |
| 668 | - foreach ($subConditions as $subCondition => $subConditionValue){ |
|
| 668 | + foreach ($subConditions as $subCondition => $subConditionValue) { |
|
| 669 | 669 | $data['condition']['default'] = $subCondition; |
| 670 | 670 | $data['condition']['bool'] = $subCondition; |
| 671 | 671 | $value = $subConditionValue; |
@@ -674,14 +674,14 @@ discard block |
||
| 674 | 674 | break; |
| 675 | 675 | } |
| 676 | 676 | } |
| 677 | - foreach ($oneSets as $oneFieldName => $oneRelation){ |
|
| 678 | - if($key . 'Set' == $oneRelation->getForeignSetClassName()){ |
|
| 679 | - foreach ($subValue as $subFieldName => $subConditions){ |
|
| 680 | - if($subFieldName === '_foreignField'){ |
|
| 677 | + foreach ($oneSets as $oneFieldName => $oneRelation) { |
|
| 678 | + if ($key.'Set' == $oneRelation->getForeignSetClassName()) { |
|
| 679 | + foreach ($subValue as $subFieldName => $subConditions) { |
|
| 680 | + if ($subFieldName === '_foreignField') { |
|
| 681 | 681 | continue; |
| 682 | 682 | } |
| 683 | 683 | $data['field'] = "{$oneFieldName}/{$subFieldName}"; |
| 684 | - foreach ($subConditions as $subCondition => $subConditionValue){ |
|
| 684 | + foreach ($subConditions as $subCondition => $subConditionValue) { |
|
| 685 | 685 | $data['condition']['default'] = $subCondition; |
| 686 | 686 | $data['condition']['bool'] = $subCondition; |
| 687 | 687 | $value = $subConditionValue; |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | */ |
| 717 | 717 | public function save($data = null) |
| 718 | 718 | { |
| 719 | - if(! isset($data['id']) && isset($data['container']) && $data['container'] != 0 && ! isset($data['rank'])){ |
|
| 719 | + if (!isset($data['id']) && isset($data['container']) && $data['container'] != 0 && !isset($data['rank'])) { |
|
| 720 | 720 | $set = $this->getRecordSet(); |
| 721 | 721 | $data['rank'] = $set->select($set->container->is($data['container'])) |
| 722 | 722 | ->count(); |
@@ -749,11 +749,11 @@ discard block |
||
| 749 | 749 | $set->rank->greaterThanOrEqual($record->rank) |
| 750 | 750 | ))); |
| 751 | 751 | |
| 752 | - $position ++; |
|
| 753 | - foreach ($afterSections as $afterSection){ |
|
| 752 | + $position++; |
|
| 753 | + foreach ($afterSections as $afterSection) { |
|
| 754 | 754 | $afterSection->rank = $position; |
| 755 | 755 | $afterSection->save(); |
| 756 | - $position ++; |
|
| 756 | + $position++; |
|
| 757 | 757 | } |
| 758 | 758 | } |
| 759 | 759 | |
@@ -781,10 +781,10 @@ discard block |
||
| 781 | 781 | $record = $recordSet->request($data['id']); |
| 782 | 782 | |
| 783 | 783 | $object = $record->object; |
| 784 | - if(empty($object)){ |
|
| 784 | + if (empty($object)) { |
|
| 785 | 785 | $object = $record->container()->object; |
| 786 | 786 | } |
| 787 | - if(strpos($object, $App->classPrefix) !== false){ |
|
| 787 | + if (strpos($object, $App->classPrefix) !== false) { |
|
| 788 | 788 | $object = str_replace($App->classPrefix, '', $object); |
| 789 | 789 | } |
| 790 | 790 | $object .= 'Set'; |
@@ -794,14 +794,14 @@ discard block |
||
| 794 | 794 | $field = $data['field']; |
| 795 | 795 | $condition = $data['condition']; |
| 796 | 796 | |
| 797 | - if(strpos($field, '/') !== false){ |
|
| 797 | + if (strpos($field, '/') !== false) { |
|
| 798 | 798 | // The selected field is a hasMany or a hasOne relation |
| 799 | 799 | list ($selectedRelation, $selectedField) = explode('/', $field); |
| 800 | 800 | $classPrefix = $App->classPrefix; |
| 801 | 801 | |
| 802 | 802 | $manyRelations = $objectRecordSet->getHasManyRelations(); |
| 803 | - foreach ($manyRelations as $manyRelation){ |
|
| 804 | - if($selectedRelation != $manyRelation->getOwnerSetFieldName()){ |
|
| 803 | + foreach ($manyRelations as $manyRelation) { |
|
| 804 | + if ($selectedRelation != $manyRelation->getOwnerSetFieldName()) { |
|
| 805 | 805 | continue; |
| 806 | 806 | } |
| 807 | 807 | $foreignSetName = str_replace($classPrefix, '', $manyRelation->getForeignSetClassName()); |
@@ -809,13 +809,13 @@ discard block |
||
| 809 | 809 | |
| 810 | 810 | $visibilityCriteria = ''; |
| 811 | 811 | |
| 812 | - if($foreignSet){ |
|
| 812 | + if ($foreignSet) { |
|
| 813 | 813 | $selectedManyField = $foreignSet->$selectedField; |
| 814 | 814 | |
| 815 | - if($selectedManyField instanceof ORMBoolInterface){ |
|
| 815 | + if ($selectedManyField instanceof ORMBoolInterface) { |
|
| 816 | 816 | $condition = $condition['bool']; |
| 817 | 817 | } |
| 818 | - else{ |
|
| 818 | + else { |
|
| 819 | 819 | $condition = $condition['default']; |
| 820 | 820 | } |
| 821 | 821 | |
@@ -827,9 +827,9 @@ discard block |
||
| 827 | 827 | } |
| 828 | 828 | |
| 829 | 829 | $oneRelations = $objectRecordSet->getHasOneRelations(); |
| 830 | - foreach ($oneRelations as $oneRelation){ |
|
| 830 | + foreach ($oneRelations as $oneRelation) { |
|
| 831 | 831 | /* @var $oneRelation ORMOneRelation*/ |
| 832 | - if($selectedRelation != $oneRelation->getOwnerSetFieldName()){ |
|
| 832 | + if ($selectedRelation != $oneRelation->getOwnerSetFieldName()) { |
|
| 833 | 833 | continue; |
| 834 | 834 | } |
| 835 | 835 | $foreignSetClassName = $oneRelation->getForeignSetClassName(); |
@@ -838,13 +838,13 @@ discard block |
||
| 838 | 838 | |
| 839 | 839 | $visibilityCriteria = ''; |
| 840 | 840 | |
| 841 | - if($foreignSet){ |
|
| 841 | + if ($foreignSet) { |
|
| 842 | 842 | $selectedOneField = $foreignSet->$selectedField; |
| 843 | 843 | |
| 844 | - if($selectedOneField instanceof ORMBoolInterface){ |
|
| 844 | + if ($selectedOneField instanceof ORMBoolInterface) { |
|
| 845 | 845 | $condition = $condition['bool']; |
| 846 | 846 | } |
| 847 | - else{ |
|
| 847 | + else { |
|
| 848 | 848 | $condition = $condition['default']; |
| 849 | 849 | } |
| 850 | 850 | |
@@ -854,20 +854,20 @@ discard block |
||
| 854 | 854 | break; |
| 855 | 855 | } |
| 856 | 856 | } |
| 857 | - else{ |
|
| 857 | + else { |
|
| 858 | 858 | |
| 859 | 859 | $field = $objectRecordSet->$field; |
| 860 | 860 | |
| 861 | - if($field instanceof ORMBoolInterface){ |
|
| 861 | + if ($field instanceof ORMBoolInterface) { |
|
| 862 | 862 | $condition = $condition['bool']; |
| 863 | 863 | } |
| 864 | - else{ |
|
| 864 | + else { |
|
| 865 | 865 | $condition = $condition['default']; |
| 866 | 866 | } |
| 867 | 867 | |
| 868 | 868 | $visibilityCriteria = ''; |
| 869 | 869 | |
| 870 | - if(! empty($condition)){ |
|
| 870 | + if (!empty($condition)) { |
|
| 871 | 871 | $criteria = $field->{$condition}($data['value']); |
| 872 | 872 | $visibilityCriteria = $criteria->toJson(); |
| 873 | 873 | } |
@@ -896,7 +896,7 @@ discard block |
||
| 896 | 896 | $customContainer = $customContainerSet->request($container); |
| 897 | 897 | |
| 898 | 898 | $object = $customContainer->object; |
| 899 | - if(strpos($object, $App->classPrefix) !== false){ |
|
| 899 | + if (strpos($object, $App->classPrefix) !== false) { |
|
| 900 | 900 | list (, $object) = explode($App->classPrefix, $object); |
| 901 | 901 | } |
| 902 | 902 | |
@@ -923,17 +923,17 @@ discard block |
||
| 923 | 923 | |
| 924 | 924 | $nbCol = 0; |
| 925 | 925 | |
| 926 | - foreach ($customSections as $customSection){ |
|
| 926 | + foreach ($customSections as $customSection) { |
|
| 927 | 927 | |
| 928 | - list (, , $nbCol) = explode('-', $customSection->sizePolicy); |
|
| 928 | + list (,, $nbCol) = explode('-', $customSection->sizePolicy); |
|
| 929 | 929 | |
| 930 | 930 | $currentColumn += $nbCol; |
| 931 | 931 | |
| 932 | - $sectionSection = $W->Section($customSection->name . ' (' . $customSection->rank . ')', $sectionBox = $W->VBoxItems($W->Hidden() |
|
| 933 | - ->setName('#' . $customSection->id))); |
|
| 932 | + $sectionSection = $W->Section($customSection->name.' ('.$customSection->rank.')', $sectionBox = $W->VBoxItems($W->Hidden() |
|
| 933 | + ->setName('#'.$customSection->id))); |
|
| 934 | 934 | $sectionSection->addClass('app-custom-section'); |
| 935 | 935 | $sectionSection->addClass($customSection->classname); |
| 936 | - $sectionSection->setSizePolicy($customSection->sizePolicy . ' widget-sameheight'); |
|
| 936 | + $sectionSection->setSizePolicy($customSection->sizePolicy.' widget-sameheight'); |
|
| 937 | 937 | |
| 938 | 938 | $row->addItem($sectionSection); |
| 939 | 939 | |
@@ -951,40 +951,40 @@ discard block |
||
| 951 | 951 | ->addClass('icon', \Func_Icons::ACTIONS_EDIT_DELETE) |
| 952 | 952 | ->setOpenMode(WidgetLink::OPEN_DIALOG) |
| 953 | 953 | ->setDialogClass('box red'))); |
| 954 | - if(! empty($customSection->visibilityCriteria)){ |
|
| 954 | + if (!empty($customSection->visibilityCriteria)) { |
|
| 955 | 955 | $sectionBox->addItem($W->HBoxItems($W->Label($App->translate('This section has a visibility condition'))) |
| 956 | 956 | ->setSizePolicy('alert alert-warning widget-100pc')); |
| 957 | 957 | } |
| 958 | 958 | $fields = $customSection->getFields(); |
| 959 | - if(count($fields) == 0){ |
|
| 959 | + if (count($fields) == 0) { |
|
| 960 | 960 | $sectionBox->addItem($W->HBoxItems($W->Label($App->translate('This section does not contain any field'))) |
| 961 | 961 | ->setSizePolicy('alert alert-warning')); |
| 962 | 962 | } |
| 963 | - foreach ($fields as $fieldId => $field){ |
|
| 964 | - if(empty($field)){ |
|
| 963 | + foreach ($fields as $fieldId => $field) { |
|
| 964 | + if (empty($field)) { |
|
| 965 | 965 | continue; |
| 966 | 966 | } |
| 967 | 967 | |
| 968 | 968 | $fieldName = $field['fieldname']; |
| 969 | 969 | |
| 970 | 970 | $isFieldsGroup = false; |
| 971 | - if(strpos($fieldName, '_fieldsGroup') !== false){ |
|
| 971 | + if (strpos($fieldName, '_fieldsGroup') !== false) { |
|
| 972 | 972 | $fieldName = '_fieldsGroup'; |
| 973 | 973 | $isFieldsGroup = true; |
| 974 | 974 | } |
| 975 | 975 | |
| 976 | 976 | $field = $availableFields[$fieldName]; |
| 977 | 977 | $fieldDescription = $field['description']; |
| 978 | - if(substr($fieldName, 0, 1) !== '_'){ |
|
| 978 | + if (substr($fieldName, 0, 1) !== '_') { |
|
| 979 | 979 | $fieldDescription = $App->translate($fieldDescription); |
| 980 | 980 | } |
| 981 | 981 | |
| 982 | - if(empty($field)){ |
|
| 982 | + if (empty($field)) { |
|
| 983 | 983 | continue; |
| 984 | 984 | } |
| 985 | 985 | |
| 986 | 986 | $fieldName = $field['name']; |
| 987 | - if($isFieldsGroup){ |
|
| 987 | + if ($isFieldsGroup) { |
|
| 988 | 988 | $fieldName = $fieldId; |
| 989 | 989 | } |
| 990 | 990 | |
@@ -995,20 +995,20 @@ discard block |
||
| 995 | 995 | ->setGrowable(true) |
| 996 | 996 | ->setWrap(WidgetFlexLayout::FLEX_WRAP_WRAP)) |
| 997 | 997 | ->setSizePolicy('maximum'), $btnBox = $W->HBoxItems($W->Hidden() |
| 998 | - ->setName($customSection->id . '.' . $fieldId) |
|
| 998 | + ->setName($customSection->id.'.'.$fieldId) |
|
| 999 | 999 | ->setValue($fieldName)) |
| 1000 | 1000 | ->addClass('widget-actions')) |
| 1001 | 1001 | ->setSizePolicy('widget-list-element widget-actions-target') |
| 1002 | 1002 | ->addClass(\Func_Icons::ICON_LEFT_16); |
| 1003 | - if(strpos($field['name'], '_fieldsGroup') !== false){ |
|
| 1003 | + if (strpos($field['name'], '_fieldsGroup') !== false) { |
|
| 1004 | 1004 | $btnBox->addItem($W->Link('', $customSectionCtrl->addDisplayFieldToGroup($customSection->id, $fieldName)) |
| 1005 | 1005 | ->addClass('icon', \Func_Icons::ACTIONS_LIST_ADD) |
| 1006 | 1006 | ->setOpenMode(WidgetLink::OPEN_DIALOG)); |
| 1007 | 1007 | $groupedFields = $fields[$fieldName]['fields']; |
| 1008 | - foreach ($groupedFields as $groupedField){ |
|
| 1008 | + foreach ($groupedFields as $groupedField) { |
|
| 1009 | 1009 | $groupedFieldDetails = $availableFields[$groupedField['fieldname']]; |
| 1010 | 1010 | $fieldGroupBox->addItem($flexField = $W->FlowItems($W->Hidden(null, array( |
| 1011 | - $customSection->id . '.fieldsGroups', |
|
| 1011 | + $customSection->id.'.fieldsGroups', |
|
| 1012 | 1012 | $fieldName, |
| 1013 | 1013 | $groupedField['fieldname'] |
| 1014 | 1014 | ), $groupedField['fieldname']), $W->Label($groupedFieldDetails['description']), $W->FlowItems($W->Link('', $customSectionCtrl->editGroupFieldDisplayField($customSection->id, $fieldName, $groupedField['fieldname'])) |
@@ -1036,23 +1036,23 @@ discard block |
||
| 1036 | 1036 | $sectionsBoxes[] = $sectionBox; |
| 1037 | 1037 | } |
| 1038 | 1038 | |
| 1039 | - if($currentColumn + $nbCol > 0){ |
|
| 1039 | + if ($currentColumn + $nbCol > 0) { |
|
| 1040 | 1040 | $sectionsSection->addItem($row); |
| 1041 | 1041 | } |
| 1042 | 1042 | |
| 1043 | - foreach ($sectionsBoxes as $sectionsBox){ |
|
| 1043 | + foreach ($sectionsBoxes as $sectionsBox) { |
|
| 1044 | 1044 | $sectionsBox->sortable(true, $sectionsBoxes); |
| 1045 | 1045 | $sectionsBox->setMetadata('samePlaceholderSize', true); |
| 1046 | 1046 | } |
| 1047 | 1047 | |
| 1048 | - foreach ($rows as $row){ |
|
| 1048 | + foreach ($rows as $row) { |
|
| 1049 | 1049 | $row->sortable(true, $rows); |
| 1050 | 1050 | $row->setMetadata('samePlaceholderSize', true); |
| 1051 | 1051 | } |
| 1052 | 1052 | |
| 1053 | 1053 | $form = $W->Form(); |
| 1054 | 1054 | |
| 1055 | - if(isset($itemId)){ |
|
| 1055 | + if (isset($itemId)) { |
|
| 1056 | 1056 | $form->setId($itemId); |
| 1057 | 1057 | } |
| 1058 | 1058 | $form->setHiddenValue('tg', $App->controllerTg); |
@@ -1079,7 +1079,7 @@ discard block |
||
| 1079 | 1079 | $customSections = $customSectionSet->select($customSectionSet->container->is($container)); |
| 1080 | 1080 | |
| 1081 | 1081 | $sectionsValues = array(); |
| 1082 | - foreach ($customSections as $customSection){ |
|
| 1082 | + foreach ($customSections as $customSection) { |
|
| 1083 | 1083 | $values = $customSection->getValues(); |
| 1084 | 1084 | unset($values['id']); |
| 1085 | 1085 | unset($values['createdBy']); |
@@ -1093,7 +1093,7 @@ discard block |
||
| 1093 | 1093 | } |
| 1094 | 1094 | |
| 1095 | 1095 | header('Content-type: application/json'); |
| 1096 | - header('Content-Disposition: attachment; filename="' . $container->object . '.' . ($container->view === '' ? 'default' : $container->view) . '.' . $container->name . '.json"' . "\n"); |
|
| 1096 | + header('Content-Disposition: attachment; filename="'.$container->object.'.'.($container->view === '' ? 'default' : $container->view).'.'.$container->name.'.json"'."\n"); |
|
| 1097 | 1097 | |
| 1098 | 1098 | $json = bab_json_encode($sectionsValues); |
| 1099 | 1099 | $json = bab_convertStringFromDatabase($json, \bab_charset::UTF_8); |
@@ -1145,12 +1145,12 @@ discard block |
||
| 1145 | 1145 | $files->push($sectionsfile['uid']); |
| 1146 | 1146 | |
| 1147 | 1147 | $data = null; |
| 1148 | - foreach ($files as $f){ |
|
| 1148 | + foreach ($files as $f) { |
|
| 1149 | 1149 | $data = file_get_contents($f->toString()); |
| 1150 | 1150 | break; |
| 1151 | 1151 | } |
| 1152 | 1152 | |
| 1153 | - if(! isset($data)){ |
|
| 1153 | + if (!isset($data)) { |
|
| 1154 | 1154 | $this->addError($App->translate('Unable to get file content')); |
| 1155 | 1155 | return true; |
| 1156 | 1156 | } |
@@ -1162,7 +1162,7 @@ discard block |
||
| 1162 | 1162 | |
| 1163 | 1163 | $customSectionSet->delete($customSectionSet->container->is($container)); |
| 1164 | 1164 | |
| 1165 | - foreach ($sectionsValues as $sectionValues){ |
|
| 1165 | + foreach ($sectionsValues as $sectionValues) { |
|
| 1166 | 1166 | $customSection = $customSectionSet->newRecord(); |
| 1167 | 1167 | $customSection->setValues($sectionValues); |
| 1168 | 1168 | $customSection->container = $container; |
@@ -1240,62 +1240,62 @@ discard block |
||
| 1240 | 1240 | $ranks = array(); |
| 1241 | 1241 | $rank = 0; |
| 1242 | 1242 | |
| 1243 | - foreach ($sections as $key => $value){ |
|
| 1243 | + foreach ($sections as $key => $value) { |
|
| 1244 | 1244 | // Sections ids start with #, while section fields start with their original section id |
| 1245 | - if(substr($key, 0, 1) === '#'){ |
|
| 1245 | + if (substr($key, 0, 1) === '#') { |
|
| 1246 | 1246 | $currentSectionId = substr($key, 1); |
| 1247 | 1247 | $rawSectionData[$currentSectionId] = array(); |
| 1248 | - if(! isset($oldSectionId)){ |
|
| 1248 | + if (!isset($oldSectionId)) { |
|
| 1249 | 1249 | $oldSectionId = $currentSectionId; |
| 1250 | 1250 | } |
| 1251 | - if(isset($currentSection) && $oldSectionId != $currentSectionId){ |
|
| 1251 | + if (isset($currentSection) && $oldSectionId != $currentSectionId) { |
|
| 1252 | 1252 | $oldSectionId = $currentSectionId; |
| 1253 | 1253 | } |
| 1254 | 1254 | $ranks[$currentSectionId] = $rank; |
| 1255 | - $rank ++; |
|
| 1255 | + $rank++; |
|
| 1256 | 1256 | $currentSection = $customSectionSet->get($customSectionSet->id->is($currentSectionId)); |
| 1257 | 1257 | continue; |
| 1258 | 1258 | } |
| 1259 | - if(! isset($currentSection)){ |
|
| 1259 | + if (!isset($currentSection)) { |
|
| 1260 | 1260 | continue; |
| 1261 | 1261 | } |
| 1262 | 1262 | list ($fieldSectionId, $fieldName) = explode('.', $key); |
| 1263 | - if($fieldSectionId == $currentSectionId){ |
|
| 1263 | + if ($fieldSectionId == $currentSectionId) { |
|
| 1264 | 1264 | $field = $currentSection->getField($fieldName); |
| 1265 | - if(strpos($fieldName, '_fieldsGroup') !== false){ |
|
| 1265 | + if (strpos($fieldName, '_fieldsGroup') !== false) { |
|
| 1266 | 1266 | $rawSectionData[$currentSectionId][$fieldName]['block'] = $field['block']; |
| 1267 | 1267 | $rawSectionData[$currentSectionId][$fieldName]['fieldname'] = '_fieldsGroup'; |
| 1268 | 1268 | $rawSectionData[$currentSectionId][$fieldName]['parameters'] = $field['parameters']; |
| 1269 | - foreach ($sections[$currentSection->id . '.fieldsGroups'][$fieldName] as $subKey => $subValue){ |
|
| 1269 | + foreach ($sections[$currentSection->id.'.fieldsGroups'][$fieldName] as $subKey => $subValue) { |
|
| 1270 | 1270 | $rawSectionData[$currentSectionId][$fieldName]['fields'][$subKey] = $field['fields'][$subKey]; |
| 1271 | 1271 | } |
| 1272 | 1272 | } |
| 1273 | - elseif($fieldName != 'fieldsGroups'){ |
|
| 1273 | + elseif ($fieldName != 'fieldsGroups') { |
|
| 1274 | 1274 | $rawSectionData[$currentSectionId][$fieldName] = $field; |
| 1275 | 1275 | } |
| 1276 | 1276 | } |
| 1277 | - else{ |
|
| 1277 | + else { |
|
| 1278 | 1278 | $field = null; |
| 1279 | 1279 | $tmpSection = $customSectionSet->get($customSectionSet->id->is($fieldSectionId)); |
| 1280 | - if($tmpSection){ |
|
| 1280 | + if ($tmpSection) { |
|
| 1281 | 1281 | $field = $tmpSection->getField($fieldName); |
| 1282 | 1282 | } |
| 1283 | - if(isset($field)){ |
|
| 1283 | + if (isset($field)) { |
|
| 1284 | 1284 | $rawSectionData[$currentSectionId][$fieldName] = $field; |
| 1285 | 1285 | } |
| 1286 | 1286 | } |
| 1287 | 1287 | } |
| 1288 | 1288 | |
| 1289 | - foreach ($rawSectionData as $sectionId => $fields){ |
|
| 1289 | + foreach ($rawSectionData as $sectionId => $fields) { |
|
| 1290 | 1290 | $section = $customSectionSet->get($customSectionSet->id->is($sectionId)); |
| 1291 | - if($section){ |
|
| 1292 | - if(bab_charset::getIso() != bab_charset::UTF_8){ |
|
| 1291 | + if ($section) { |
|
| 1292 | + if (bab_charset::getIso() != bab_charset::UTF_8) { |
|
| 1293 | 1293 | $fields = app_utf8Encode($fields); |
| 1294 | 1294 | } |
| 1295 | 1295 | $section->fields = json_encode($fields); |
| 1296 | 1296 | $section->rank = isset($ranks[$sectionId]) ? $ranks[$sectionId] : 0; |
| 1297 | 1297 | $section->save(); |
| 1298 | - $rank ++; |
|
| 1298 | + $rank++; |
|
| 1299 | 1299 | } |
| 1300 | 1300 | } |
| 1301 | 1301 | |