@@ -74,7 +74,9 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function isInEditMode() |
| 76 | 76 | { |
| 77 | - if (neon()->session===null) return false; |
|
| 77 | + if (neon()->session===null) { |
|
| 78 | + return false; |
|
| 79 | + } |
|
| 78 | 80 | return neon()->session->get(self::COBE_EDITING, false); |
| 79 | 81 | } |
| 80 | 82 | |
@@ -185,8 +187,9 @@ discard block |
||
| 185 | 187 | $data = $this->_page; |
| 186 | 188 | // add the nice_id as CmnUrRoute will add this on first parse through Cobe without gets but |
| 187 | 189 | // not on requests with get parameters which has led to hard-to-debug runtime coding errors |
| 188 | - if (!isset($data['page_params']['nice_id']) && isset($data['nice_id'])) |
|
| 189 | - $data['page_params']['nice_id'] = $data['nice_id']; |
|
| 190 | + if (!isset($data['page_params']['nice_id']) && isset($data['nice_id'])) { |
|
| 191 | + $data['page_params']['nice_id'] = $data['nice_id']; |
|
| 192 | + } |
|
| 190 | 193 | } |
| 191 | 194 | $params = array_merge($data['page_params'], neon()->request->get(), neon()->request->post()); |
| 192 | 195 | unset($data['page_params']); |
@@ -226,8 +229,9 @@ discard block |
||
| 226 | 229 | */ |
| 227 | 230 | public function getUrlOfPage($id) |
| 228 | 231 | { |
| 229 | - if (!$id) |
|
| 230 | - return ''; |
|
| 232 | + if (!$id) { |
|
| 233 | + return ''; |
|
| 234 | + } |
|
| 231 | 235 | $url = $this->loadUrlByPageId($id); |
| 232 | 236 | return $url ? url($url['url']) : ''; |
| 233 | 237 | } |
@@ -241,8 +245,9 @@ discard block |
||
| 241 | 245 | public function getUrlOfPageByNiceId($niceId) |
| 242 | 246 | { |
| 243 | 247 | $url = ''; |
| 244 | - if ($niceId) |
|
| 245 | - $url = $this->loadUrlByNiceId($niceId); |
|
| 248 | + if ($niceId) { |
|
| 249 | + $url = $this->loadUrlByNiceId($niceId); |
|
| 250 | + } |
|
| 246 | 251 | return $url ? url($url['url']) : ''; |
| 247 | 252 | } |
| 248 | 253 | |
@@ -253,10 +258,12 @@ discard block |
||
| 253 | 258 | */ |
| 254 | 259 | public function niceId2PageId($niceId) |
| 255 | 260 | { |
| 256 | - if (!$niceId) |
|
| 257 | - return null; |
|
| 258 | - if (isset($this->_niceId2PageId[$niceId])) |
|
| 259 | - return $this->_niceId2PageId[$niceId]; |
|
| 261 | + if (!$niceId) { |
|
| 262 | + return null; |
|
| 263 | + } |
|
| 264 | + if (isset($this->_niceId2PageId[$niceId])) { |
|
| 265 | + return $this->_niceId2PageId[$niceId]; |
|
| 266 | + } |
|
| 260 | 267 | $url = $this->loadUrlByNiceId($niceId); |
| 261 | 268 | return $url ? $url['page_id'] : null; |
| 262 | 269 | } |
@@ -268,10 +275,12 @@ discard block |
||
| 268 | 275 | */ |
| 269 | 276 | public function pageId2NiceId($pageId) |
| 270 | 277 | { |
| 271 | - if (!$pageId) |
|
| 272 | - return null; |
|
| 273 | - if (isset($this->_pageId2NiceId[$pageId])) |
|
| 274 | - return $this->_pageId2NiceId[$pageId]; |
|
| 278 | + if (!$pageId) { |
|
| 279 | + return null; |
|
| 280 | + } |
|
| 281 | + if (isset($this->_pageId2NiceId[$pageId])) { |
|
| 282 | + return $this->_pageId2NiceId[$pageId]; |
|
| 283 | + } |
|
| 275 | 284 | $url = $this->loadUrlByPageId($pageId); |
| 276 | 285 | return $url ? $url['page_id'] : null; |
| 277 | 286 | } |
@@ -407,15 +416,17 @@ discard block |
||
| 407 | 416 | do { |
| 408 | 417 | $numberOfRenders++; |
| 409 | 418 | $html = $renderer->renderTemplate($template); |
| 410 | - if (($hasDataRequests=$this->hasDataRequests())) |
|
| 411 | - $this->makeDataRequests(); |
|
| 419 | + if (($hasDataRequests=$this->hasDataRequests())) { |
|
| 420 | + $this->makeDataRequests(); |
|
| 421 | + } |
|
| 412 | 422 | } while ($hasDataRequests == true); |
| 413 | 423 | |
| 414 | 424 | // If the number of renders are excessive, issue a warning. |
| 415 | 425 | // Simple cases can result a few renders so take anything over |
| 416 | 426 | // 4 renders as excessive. |
| 417 | - if ($numberOfRenders >= 5) |
|
| 418 | - \Neon::debug('Excessive number of renders (>=5): ' . $numberOfRenders); |
|
| 427 | + if ($numberOfRenders >= 5) { |
|
| 428 | + \Neon::debug('Excessive number of renders (>=5): ' . $numberOfRenders); |
|
| 429 | + } |
|
| 419 | 430 | |
| 420 | 431 | // inject assets into template |
| 421 | 432 | $html = neon()->view->injectHtml($html); |
@@ -446,15 +457,17 @@ discard block |
||
| 446 | 457 | // see if we have the data |
| 447 | 458 | if (isset($this->requestedData[$id])) { |
| 448 | 459 | $data = $this->requestedData[$id]; |
| 449 | - if (!$isStatic && isset($this->requestedDataMeta[$id])) |
|
| 450 | - $meta = $this->requestedDataMeta[$id]; |
|
| 460 | + if (!$isStatic && isset($this->requestedDataMeta[$id])) { |
|
| 461 | + $meta = $this->requestedDataMeta[$id]; |
|
| 462 | + } |
|
| 451 | 463 | return true; |
| 452 | 464 | } |
| 453 | 465 | // if not then add it to the list of requested data |
| 454 | - if ($isStatic) |
|
| 455 | - $this->staticDataRequests[$id] = $dataRequest; |
|
| 456 | - else |
|
| 457 | - $this->dynamicDataRequests[$id] = $dataRequest; |
|
| 466 | + if ($isStatic) { |
|
| 467 | + $this->staticDataRequests[$id] = $dataRequest; |
|
| 468 | + } else { |
|
| 469 | + $this->dynamicDataRequests[$id] = $dataRequest; |
|
| 470 | + } |
|
| 458 | 471 | return false; |
| 459 | 472 | } |
| 460 | 473 | |
@@ -508,13 +521,16 @@ discard block |
||
| 508 | 521 | */ |
| 509 | 522 | protected function loadUrlByNiceId($id) |
| 510 | 523 | { |
| 511 | - if (!$id) |
|
| 512 | - return null; |
|
| 524 | + if (!$id) { |
|
| 525 | + return null; |
|
| 526 | + } |
|
| 513 | 527 | $this->loadUrls(); |
| 514 | - if (isset($this->_allUrlsByNiceId[$id])) |
|
| 515 | - return $this->_allUrlsByNiceId[$id]; |
|
| 516 | - if (isset($this->_allUrlsByPageId[$id])) |
|
| 517 | - return $this->_allUrlsByPageId[$id]; |
|
| 528 | + if (isset($this->_allUrlsByNiceId[$id])) { |
|
| 529 | + return $this->_allUrlsByNiceId[$id]; |
|
| 530 | + } |
|
| 531 | + if (isset($this->_allUrlsByPageId[$id])) { |
|
| 532 | + return $this->_allUrlsByPageId[$id]; |
|
| 533 | + } |
|
| 518 | 534 | return $this->loadUrl($id); |
| 519 | 535 | } |
| 520 | 536 | |
@@ -525,15 +541,17 @@ discard block |
||
| 525 | 541 | */ |
| 526 | 542 | protected function loadUrl($id) |
| 527 | 543 | { |
| 528 | - if (!$id) |
|
| 529 | - return null; |
|
| 544 | + if (!$id) { |
|
| 545 | + return null; |
|
| 546 | + } |
|
| 530 | 547 | $url = CmsUrl::find()->select("cms_url.*, cms_page.id as page_id") |
| 531 | 548 | ->innerJoin('cms_page','`cms_page`.`nice_id`=`cms_url`.`nice_id`') |
| 532 | 549 | ->where(['cms_page.id' => $id]) |
| 533 | 550 | ->orWhere(['cms_url.nice_id' => $id]) |
| 534 | 551 | ->asArray()->one(); |
| 535 | - if ($url) |
|
| 536 | - $this->storeUrl($url); |
|
| 552 | + if ($url) { |
|
| 553 | + $this->storeUrl($url); |
|
| 554 | + } |
|
| 537 | 555 | return $url; |
| 538 | 556 | } |
| 539 | 557 | |
@@ -658,8 +676,9 @@ discard block |
||
| 658 | 676 | if (count($this->staticDataRequests)>0) { |
| 659 | 677 | $cms = $this->getICmsStaticData(); |
| 660 | 678 | $data = $cms->bulkStaticContentRequest($this->staticDataRequests); |
| 661 | - foreach ($data as $i=>$d) |
|
| 662 | - $this->requestedData[$i] = ($d===null ? 'not found' : $d); |
|
| 679 | + foreach ($data as $i=>$d) { |
|
| 680 | + $this->requestedData[$i] = ($d===null ? 'not found' : $d); |
|
| 681 | + } |
|
| 663 | 682 | $this->staticDataRequests = []; |
| 664 | 683 | } |
| 665 | 684 | } |
@@ -702,8 +721,9 @@ discard block |
||
| 702 | 721 | private $cmsStaticData = null; |
| 703 | 722 | private function getICmsStaticData() |
| 704 | 723 | { |
| 705 | - if ($this->cmsStaticData === null) |
|
| 706 | - $this->cmsStaticData = neon('cms')->ICmsStaticData; |
|
| 724 | + if ($this->cmsStaticData === null) { |
|
| 725 | + $this->cmsStaticData = neon('cms')->ICmsStaticData; |
|
| 726 | + } |
|
| 707 | 727 | return $this->cmsStaticData; |
| 708 | 728 | } |
| 709 | 729 | |
@@ -29,8 +29,9 @@ discard block |
||
| 29 | 29 | if (is_string($root) && count($themes)) { |
| 30 | 30 | foreach ($themes as $theme) { |
| 31 | 31 | $themePath = $root.$theme; |
| 32 | - if (!isset($hierarchy[$theme])) |
|
| 33 | - $hierarchy[$theme] = []; |
|
| 32 | + if (!isset($hierarchy[$theme])) { |
|
| 33 | + $hierarchy[$theme] = []; |
|
| 34 | + } |
|
| 34 | 35 | |
| 35 | 36 | // add the default template and plugin directories |
| 36 | 37 | $hierarchy[$theme]['templates'][] = $themePath; |
@@ -104,8 +105,9 @@ discard block |
||
| 104 | 105 | private static function getRoot() |
| 105 | 106 | { |
| 106 | 107 | static $root = null; |
| 107 | - if ($root === null) |
|
| 108 | - $root = Neon::getAlias('@root/themes/'); |
|
| 108 | + if ($root === null) { |
|
| 109 | + $root = Neon::getAlias('@root/themes/'); |
|
| 110 | + } |
|
| 109 | 111 | return $root; |
| 110 | 112 | } |
| 111 | 113 | } |
@@ -117,11 +117,13 @@ discard block |
||
| 117 | 117 | $defaults['type'] = $params['type']; |
| 118 | 118 | // path to the file is determined by the theme hierarchy |
| 119 | 119 | $defaults['file'] = $params['type'] . '.tpl'; |
| 120 | - if (isset($params['key'])) |
|
| 121 | - self::buildDataFromCmsKeyAttributes($params); |
|
| 120 | + if (isset($params['key'])) { |
|
| 121 | + self::buildDataFromCmsKeyAttributes($params); |
|
| 122 | + } |
|
| 122 | 123 | } |
| 123 | - if (isset($params['dds']) || isset($params['dds_page']) || isset($params['dds_class'])) |
|
| 124 | - Daedalus::buildDataFromDdsAttributes($params); |
|
| 124 | + if (isset($params['dds']) || isset($params['dds_page']) || isset($params['dds_class'])) { |
|
| 125 | + Daedalus::buildDataFromDdsAttributes($params); |
|
| 126 | + } |
|
| 125 | 127 | $resolvedParams = ArrayHelper::merge($defaults, $params); |
| 126 | 128 | $out = $widget->render($resolvedParams, $template); |
| 127 | 129 | return $out; |
@@ -170,8 +172,9 @@ discard block |
||
| 170 | 172 | } |
| 171 | 173 | // scb = static content block |
| 172 | 174 | $params['type'] = '_scb'; |
| 173 | - if (isset($params['key'])) |
|
| 174 | - self::buildDataFromCmsKeyAttributes($params); |
|
| 175 | + if (isset($params['key'])) { |
|
| 176 | + self::buildDataFromCmsKeyAttributes($params); |
|
| 177 | + } |
|
| 175 | 178 | $params['content'] = $content; |
| 176 | 179 | $params['wys'] = (isset($params['wys']) ? $params['wys'] : true); |
| 177 | 180 | return $widget->render($params, $template); |
@@ -207,8 +210,9 @@ discard block |
||
| 207 | 210 | $data = []; |
| 208 | 211 | if (($dataRequest = $this->getDataRequest()) !== null) { |
| 209 | 212 | $id = $meta = null; |
| 210 | - if (!$this->getPage()->requestWidgetData($dataRequest, $data, $id, $this->isStatic, $meta)) |
|
| 211 | - return $id; |
|
| 213 | + if (!$this->getPage()->requestWidgetData($dataRequest, $data, $id, $this->isStatic, $meta)) { |
|
| 214 | + return $id; |
|
| 215 | + } |
|
| 212 | 216 | $this->saveData($data); |
| 213 | 217 | $this->saveDataMetaInformation($meta); |
| 214 | 218 | } |
@@ -238,8 +242,9 @@ discard block |
||
| 238 | 242 | $this->params['meta'] = $this->meta; |
| 239 | 243 | |
| 240 | 244 | // createTemplate is an expensive call so only call it once per file and reset all variables on the stored template. |
| 241 | - if (!isset($templates[$file])) |
|
| 242 | - $templates[$file] = $this->renderer->createTemplate($file); |
|
| 245 | + if (!isset($templates[$file])) { |
|
| 246 | + $templates[$file] = $this->renderer->createTemplate($file); |
|
| 247 | + } |
|
| 243 | 248 | $tpl = $templates[$file]; |
| 244 | 249 | $tpl->tpl_vars = $tpl->config_vars = []; |
| 245 | 250 | |
@@ -257,8 +262,9 @@ discard block |
||
| 257 | 262 | */ |
| 258 | 263 | protected function getDataRequest() |
| 259 | 264 | { |
| 260 | - if (isset($this->params['data'])) |
|
| 261 | - return Daedalus::convertDataRequestToJson($this->params['data']); |
|
| 265 | + if (isset($this->params['data'])) { |
|
| 266 | + return Daedalus::convertDataRequestToJson($this->params['data']); |
|
| 267 | + } |
|
| 262 | 268 | return null; |
| 263 | 269 | } |
| 264 | 270 | |
@@ -314,15 +320,17 @@ discard block |
||
| 314 | 320 | */ |
| 315 | 321 | protected static function buildDataFromCmsKeyAttributes(&$params) |
| 316 | 322 | { |
| 317 | - if (!isset($params['type'], $params['key'])) |
|
| 318 | - return; |
|
| 323 | + if (!isset($params['type'], $params['key'])) { |
|
| 324 | + return; |
|
| 325 | + } |
|
| 319 | 326 | $key = "$params[type]_$params[key]"; |
| 320 | 327 | $pageId = isset($params['page']) ? self::$page->getId() : null; |
| 321 | 328 | $params['data-key'] = $key; |
| 322 | 329 | $params['data-page-id'] = $pageId; |
| 323 | 330 | $params['data'] = "'key':'$key','pageId':'$pageId'"; |
| 324 | - if (!isset($params['content'])) |
|
| 325 | - $params['content'] = "Add Content for $params[key] here"; |
|
| 331 | + if (!isset($params['content'])) { |
|
| 332 | + $params['content'] = "Add Content for $params[key] here"; |
|
| 333 | + } |
|
| 326 | 334 | $params['is_static'] = true; |
| 327 | 335 | } |
| 328 | 336 | |
@@ -338,10 +346,11 @@ discard block |
||
| 338 | 346 | if ($this->getPage()->isInEditMode()) { |
| 339 | 347 | $dataKey = $this->params['data-key']; |
| 340 | 348 | $dataPageId = $this->params['data-page-id']; |
| 341 | - if ((isset($this->params['wys']) || isset($this->params['wysiwyg'])) || (isset($this->params['editor']) && strpos('wys', $this->params['editor'] === 0))) |
|
| 342 | - return '<div id="'.$this->getId().'" data-id="'.$this->getId().'" data-key="'.$dataKey.'" data-page-id="'.$dataPageId.'" class="cobe-editable cobe-static-block" contenteditable="true">' . $value . '</div>'; |
|
| 343 | - else |
|
| 344 | - return "<div style='display:inline-block;' class='cobe-editable cobe-static' data-key='$dataKey' data-page-id='$dataPageId' contenteditable='true' />$value</div>"; |
|
| 349 | + if ((isset($this->params['wys']) || isset($this->params['wysiwyg'])) || (isset($this->params['editor']) && strpos('wys', $this->params['editor'] === 0))) { |
|
| 350 | + return '<div id="'.$this->getId().'" data-id="'.$this->getId().'" data-key="'.$dataKey.'" data-page-id="'.$dataPageId.'" class="cobe-editable cobe-static-block" contenteditable="true">' . $value . '</div>'; |
|
| 351 | + } else { |
|
| 352 | + return "<div style='display:inline-block;' class='cobe-editable cobe-static' data-key='$dataKey' data-page-id='$dataPageId' contenteditable='true' />$value</div>"; |
|
| 353 | + } |
|
| 345 | 354 | } else { |
| 346 | 355 | return $value; |
| 347 | 356 | } |
@@ -205,10 +205,11 @@ discard block |
||
| 205 | 205 | $result['edit'] = $this->createEditable($data); |
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | - if ($this->renderer) |
|
| 209 | - $this->renderer->assign($this->params['assign'], $result); |
|
| 210 | - else |
|
| 211 | - return $result; |
|
| 208 | + if ($this->renderer) { |
|
| 209 | + $this->renderer->assign($this->params['assign'], $result); |
|
| 210 | + } else { |
|
| 211 | + return $result; |
|
| 212 | + } |
|
| 212 | 213 | } |
| 213 | 214 | |
| 214 | 215 | /** |
@@ -226,19 +227,22 @@ discard block |
||
| 226 | 227 | protected function queryChoice($template=true) |
| 227 | 228 | { |
| 228 | 229 | // check usage |
| 229 | - if (!isset($this->params['member'])) |
|
| 230 | - return "Usage: you must provide a 'member' parameter. You provided ".print_r($this->params,true); |
|
| 231 | - if ($this->renderer && !isset($this->params['assign'])) |
|
| 232 | - return "Usage: you must provide an 'assign' parameter. You provided ".print_r($this->params,true); |
|
| 233 | - if (strpos($this->params['member'],':') === false && !isset($this->params['class'])) |
|
| 234 | - return "Usage: if you do not scope the member as class::member then you must provide the class parameter"; |
|
| 230 | + if (!isset($this->params['member'])) { |
|
| 231 | + return "Usage: you must provide a 'member' parameter. You provided ".print_r($this->params,true); |
|
| 232 | + } |
|
| 233 | + if ($this->renderer && !isset($this->params['assign'])) { |
|
| 234 | + return "Usage: you must provide an 'assign' parameter. You provided ".print_r($this->params,true); |
|
| 235 | + } |
|
| 236 | + if (strpos($this->params['member'],':') === false && !isset($this->params['class'])) { |
|
| 237 | + return "Usage: if you do not scope the member as class::member then you must provide the class parameter"; |
|
| 238 | + } |
|
| 235 | 239 | |
| 236 | 240 | // extract out class and member |
| 237 | 241 | $class = null; |
| 238 | 242 | $member = null; |
| 239 | - if (strpos($this->params['member'],':') !== false) |
|
| 240 | - list ($class, $member) = explode(':', str_replace('::',':',$this->params['member'])); |
|
| 241 | - else { |
|
| 243 | + if (strpos($this->params['member'],':') !== false) { |
|
| 244 | + list ($class, $member) = explode(':', str_replace('::',':',$this->params['member'])); |
|
| 245 | + } else { |
|
| 242 | 246 | $class = $this->params['class']; |
| 243 | 247 | $member = $this->params['member']; |
| 244 | 248 | } |
@@ -250,10 +254,11 @@ discard block |
||
| 250 | 254 | if (!isset(self::$_choices[$key])) { |
| 251 | 255 | $dds = neon('dds')->iDdsClassManagement; |
| 252 | 256 | $result = $dds->getMember($class, $member, ['choices']); |
| 253 | - if (!empty($result) && isset($result['choices'])) |
|
| 254 | - self::$_choices[$key] = $result['choices']; |
|
| 255 | - else |
|
| 256 | - self::$_choices[$key] = []; |
|
| 257 | + if (!empty($result) && isset($result['choices'])) { |
|
| 258 | + self::$_choices[$key] = $result['choices']; |
|
| 259 | + } else { |
|
| 260 | + self::$_choices[$key] = []; |
|
| 261 | + } |
|
| 257 | 262 | } |
| 258 | 263 | $choices = self::$_choices[$key]; |
| 259 | 264 | if (isset($this->params['order'])) { |
@@ -263,10 +268,11 @@ discard block |
||
| 263 | 268 | asort($choices); |
| 264 | 269 | } |
| 265 | 270 | } |
| 266 | - if ($this->renderer) |
|
| 267 | - $this->renderer->assign($this->params['assign'], $choices); |
|
| 268 | - else |
|
| 269 | - return $choices; |
|
| 271 | + if ($this->renderer) { |
|
| 272 | + $this->renderer->assign($this->params['assign'], $choices); |
|
| 273 | + } else { |
|
| 274 | + return $choices; |
|
| 275 | + } |
|
| 270 | 276 | } |
| 271 | 277 | |
| 272 | 278 | /** |
@@ -284,11 +290,13 @@ discard block |
||
| 284 | 290 | protected function queryMap() |
| 285 | 291 | { |
| 286 | 292 | // check usage |
| 287 | - if (!isset($this->params['class'])) |
|
| 288 | - return "Usage: you must provide a 'class' parameter. You provided ".print_r($this->params,true); |
|
| 293 | + if (!isset($this->params['class'])) { |
|
| 294 | + return "Usage: you must provide a 'class' parameter. You provided ".print_r($this->params,true); |
|
| 295 | + } |
|
| 289 | 296 | |
| 290 | - if ($this->renderer && !isset($this->params['assign'])) |
|
| 291 | - return "Usage: you must provide an 'assign' parameter. You provided ".print_r($this->params,true); |
|
| 297 | + if ($this->renderer && !isset($this->params['assign'])) { |
|
| 298 | + return "Usage: you must provide an 'assign' parameter. You provided ".print_r($this->params,true); |
|
| 299 | + } |
|
| 292 | 300 | |
| 293 | 301 | $fields = isset($this->params['fields']) ? $this->params['fields'] : []; |
| 294 | 302 | |
@@ -307,11 +315,13 @@ discard block |
||
| 307 | 315 | self::$_maps[$class] = $result; |
| 308 | 316 | } |
| 309 | 317 | $map = self::$_maps[$class]; |
| 310 | - if (isset($this->params['flip'])) |
|
| 311 | - $map = array_flip($map); |
|
| 318 | + if (isset($this->params['flip'])) { |
|
| 319 | + $map = array_flip($map); |
|
| 320 | + } |
|
| 312 | 321 | |
| 313 | - if ($this->renderer) |
|
| 314 | - $this->renderer->assign($this->params['assign'], $map); |
|
| 322 | + if ($this->renderer) { |
|
| 323 | + $this->renderer->assign($this->params['assign'], $map); |
|
| 324 | + } |
|
| 315 | 325 | |
| 316 | 326 | return $map; |
| 317 | 327 | } |
@@ -328,11 +338,13 @@ discard block |
||
| 328 | 338 | $json = trim(str_replace("'", '"', $data)); |
| 329 | 339 | if (strlen($json) > 0) { |
| 330 | 340 | // for convenience the beginning and ending brackets are optional so add if not supplied |
| 331 | - if (strpos($json, '{') !== 0) |
|
| 332 | - $json = '{'.$json.'}'; |
|
| 341 | + if (strpos($json, '{') !== 0) { |
|
| 342 | + $json = '{'.$json.'}'; |
|
| 343 | + } |
|
| 333 | 344 | $request = json_decode($json, true); |
| 334 | - if ($request === null) |
|
| 335 | - throw new \Exception("Failing to json decode the data request: $json converted from $data. "); |
|
| 345 | + if ($request === null) { |
|
| 346 | + throw new \Exception("Failing to json decode the data request: $json converted from $data. "); |
|
| 347 | + } |
|
| 336 | 348 | } |
| 337 | 349 | return $request; |
| 338 | 350 | } |
@@ -357,10 +369,12 @@ discard block |
||
| 357 | 369 | $dps = array_intersect_key($params, array_flip($dpa)); |
| 358 | 370 | if (count($dps)) { |
| 359 | 371 | $data = []; |
| 360 | - if ((isset($dps['dds']) || isset($dps['dds_page'])) && empty($dps['dds_class'])) |
|
| 361 | - $dps['dds_class'] = $params['type']; |
|
| 362 | - if (isset($dps['dds_class'])) |
|
| 363 | - $data[] = "'class':'$dps[dds_class]'"; |
|
| 372 | + if ((isset($dps['dds']) || isset($dps['dds_page'])) && empty($dps['dds_class'])) { |
|
| 373 | + $dps['dds_class'] = $params['type']; |
|
| 374 | + } |
|
| 375 | + if (isset($dps['dds_class'])) { |
|
| 376 | + $data[] = "'class':'$dps[dds_class]'"; |
|
| 377 | + } |
|
| 364 | 378 | |
| 365 | 379 | // create the filters |
| 366 | 380 | $filters = []; |
@@ -368,51 +382,60 @@ discard block |
||
| 368 | 382 | // create the page specific filter |
| 369 | 383 | if (!empty($dps['dds_page'])) { |
| 370 | 384 | $pageId = null; |
| 371 | - if ($dps['dds_page'] === true || $dps['dds_page'] === 'true') |
|
| 372 | - $pageId = self::$page->getId(); |
|
| 373 | - else { |
|
| 385 | + if ($dps['dds_page'] === true || $dps['dds_page'] === 'true') { |
|
| 386 | + $pageId = self::$page->getId(); |
|
| 387 | + } else { |
|
| 374 | 388 | // either a nice id or a page id |
| 375 | 389 | $pageId = self::$page->niceId2PageId($dps['dds_page']); |
| 376 | - if (!$pageId) |
|
| 377 | - $pageId = $dps['dds_page']; |
|
| 390 | + if (!$pageId) { |
|
| 391 | + $pageId = $dps['dds_page']; |
|
| 392 | + } |
|
| 393 | + } |
|
| 394 | + if ($pageId) { |
|
| 395 | + $filters[] = "['page_id','=','$pageId']"; |
|
| 378 | 396 | } |
| 379 | - if ($pageId) |
|
| 380 | - $filters[] = "['page_id','=','$pageId']"; |
|
| 381 | 397 | } |
| 382 | 398 | |
| 383 | 399 | // add other filters |
| 384 | 400 | if (isset($dps['dds_filter']) && !empty($dps['dds_filter'])) { |
| 385 | - if (is_array($dps['dds_filter'])) |
|
| 386 | - $filters[] = json_encode($dps['dds_filter']); |
|
| 401 | + if (is_array($dps['dds_filter'])) { |
|
| 402 | + $filters[] = json_encode($dps['dds_filter']); |
|
| 403 | + } |
|
| 387 | 404 | // else deprecated json approach |
| 388 | - else if (strpos(trim($dps['dds_filter']), '[')!==0) |
|
| 389 | - $filters[] = "[$dps[dds_filter]]"; |
|
| 390 | - else |
|
| 391 | - $filters[] = $dps['dds_filter']; |
|
| 405 | + else if (strpos(trim($dps['dds_filter']), '[')!==0) { |
|
| 406 | + $filters[] = "[$dps[dds_filter]]"; |
|
| 407 | + } else { |
|
| 408 | + $filters[] = $dps['dds_filter']; |
|
| 409 | + } |
|
| 392 | 410 | } |
| 393 | 411 | |
| 394 | 412 | // create the filters clause |
| 395 | - if (count($filters)) |
|
| 396 | - $data[] = "'filters':".implode(',',$filters); |
|
| 413 | + if (count($filters)) { |
|
| 414 | + $data[] = "'filters':".implode(',',$filters); |
|
| 415 | + } |
|
| 397 | 416 | |
| 398 | 417 | // sort out the order |
| 399 | 418 | if (isset($dps['dds_order'])) { |
| 400 | - if (is_array($dps['dds_order'])) |
|
| 401 | - $data[] = "'order':".json_encode($dps['dds_order']); |
|
| 419 | + if (is_array($dps['dds_order'])) { |
|
| 420 | + $data[] = "'order':".json_encode($dps['dds_order']); |
|
| 421 | + } |
|
| 402 | 422 | // else deprecated json approach |
| 403 | - else |
|
| 404 | - $data[] = "'order':{".$dps['dds_order']."}"; |
|
| 423 | + else { |
|
| 424 | + $data[] = "'order':{".$dps['dds_order']."}"; |
|
| 425 | + } |
|
| 405 | 426 | } |
| 406 | 427 | |
| 407 | 428 | // sort out the limit |
| 408 | 429 | if (isset($dps['dds_limit'])) { |
| 409 | - if (is_numeric($dps['dds_limit'])) |
|
| 410 | - $data[] = "'limit':{'length':$dps[dds_limit]}"; |
|
| 411 | - else if (is_array($dps['dds_limit'])) |
|
| 412 | - $data[] = "'limit':".json_encode($dps['dds_limit']); |
|
| 430 | + if (is_numeric($dps['dds_limit'])) { |
|
| 431 | + $data[] = "'limit':{'length':$dps[dds_limit]}"; |
|
| 432 | + } else if (is_array($dps['dds_limit'])) { |
|
| 433 | + $data[] = "'limit':".json_encode($dps['dds_limit']); |
|
| 434 | + } |
|
| 413 | 435 | // else deprecated json approach |
| 414 | - else |
|
| 415 | - $data[] = "'limit':{".$dps['dds_limit']."}"; |
|
| 436 | + else { |
|
| 437 | + $data[] = "'limit':{".$dps['dds_limit']."}"; |
|
| 438 | + } |
|
| 416 | 439 | } |
| 417 | 440 | $params['data'] = '{'.implode(', ', $data).'}'; |
| 418 | 441 | } |
@@ -429,8 +452,9 @@ discard block |
||
| 429 | 452 | protected function canonicalise($params) |
| 430 | 453 | { |
| 431 | 454 | $canon = []; |
| 432 | - if (empty($params['assign']) && $this->renderer !== null) |
|
| 433 | - throw new \InvalidArgumentException("You must set an 'assign' parameter when using the 'dds' tag"); |
|
| 455 | + if (empty($params['assign']) && $this->renderer !== null) { |
|
| 456 | + throw new \InvalidArgumentException("You must set an 'assign' parameter when using the 'dds' tag"); |
|
| 457 | + } |
|
| 434 | 458 | foreach ($params as $k => $v) { |
| 435 | 459 | if ($k == 'assign') { |
| 436 | 460 | $canon[$k] = $v; |
@@ -458,8 +482,9 @@ discard block |
||
| 458 | 482 | $classType = $d['_class_type']; |
| 459 | 483 | foreach ($d as $field=>$value) { |
| 460 | 484 | // ignore all bookkeeping fields |
| 461 | - if (strpos($field, '_')===0) |
|
| 462 | - continue; |
|
| 485 | + if (strpos($field, '_')===0) { |
|
| 486 | + continue; |
|
| 487 | + } |
|
| 463 | 488 | $edit[$i][$field] = self::createFieldEditable($classType, $field, $d['_uuid'], $value); |
| 464 | 489 | } |
| 465 | 490 | } |
@@ -477,8 +502,9 @@ discard block |
||
| 477 | 502 | */ |
| 478 | 503 | public static function createFieldEditable($classType, $field, $key, $value) |
| 479 | 504 | { |
| 480 | - if (is_array($value)) |
|
| 481 | - return $value; |
|
| 505 | + if (is_array($value)) { |
|
| 506 | + return $value; |
|
| 507 | + } |
|
| 482 | 508 | |
| 483 | 509 | /** |
| 484 | 510 | * This needs to be changed to generate an appropriate form to edit the |
@@ -39,17 +39,19 @@ discard block |
||
| 39 | 39 | { |
| 40 | 40 | // see if we have a key and if not we can do nothing |
| 41 | 41 | $key = neon()->request->post('key'); |
| 42 | - if (empty($key)) |
|
| 43 | - return; |
|
| 42 | + if (empty($key)) { |
|
| 43 | + return; |
|
| 44 | + } |
|
| 44 | 45 | $content = neon()->request->postUnsafe('content'); |
| 45 | 46 | $content = Html::sanitise($content, $this->inlineAllowedTags); |
| 46 | 47 | $pageId = neon()->request->post('pageId', null); |
| 47 | 48 | try { |
| 48 | 49 | $result = neon('cms')->getICmsStaticData()->editStaticContent($key, $pageId, $content); |
| 49 | - if ($result === true) |
|
| 50 | - return ['success'=>true, 'saved'=>$content]; |
|
| 51 | - else |
|
| 52 | - return neon()->debug ? ['success'=>false, 'errors'=>$result] : ['success'=>false]; |
|
| 50 | + if ($result === true) { |
|
| 51 | + return ['success'=>true, 'saved'=>$content]; |
|
| 52 | + } else { |
|
| 53 | + return neon()->debug ? ['success'=>false, 'errors'=>$result] : ['success'=>false]; |
|
| 54 | + } |
|
| 53 | 55 | } catch (\Exception $e) { |
| 54 | 56 | return neon()->debug ? ['success'=>false, 'errors'=>$e->getMessage()] : ['success'=>false]; |
| 55 | 57 | } |
@@ -67,10 +69,11 @@ discard block |
||
| 67 | 69 | $pageId = neon()->request->post('pageId', null); |
| 68 | 70 | try { |
| 69 | 71 | $result = neon()->cms->getICmsStaticData()->editStaticContent($key, $pageId, $content); |
| 70 | - if ($result === true) |
|
| 71 | - return ['success'=>true, 'saved'=>$content]; |
|
| 72 | - else if (neon()->debug) |
|
| 73 | - return neon()->debug ? ['success'=>false, 'errors'=>$result] : ['success'=>false]; |
|
| 72 | + if ($result === true) { |
|
| 73 | + return ['success'=>true, 'saved'=>$content]; |
|
| 74 | + } else if (neon()->debug) { |
|
| 75 | + return neon()->debug ? ['success'=>false, 'errors'=>$result] : ['success'=>false]; |
|
| 76 | + } |
|
| 74 | 77 | } catch (\Exception $e) { |
| 75 | 78 | return neon()->debug ? ['success'=>false, 'errors'=>$e->getMessage()] : ['success'=>false]; |
| 76 | 79 | } |
@@ -97,8 +97,9 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $render = $page->render(); |
| 100 | - if ($render === false) |
|
| 101 | - throw new \yii\web\HttpException(404, 'No template found'); |
|
| 100 | + if ($render === false) { |
|
| 101 | + throw new \yii\web\HttpException(404, 'No template found'); |
|
| 102 | + } |
|
| 102 | 103 | |
| 103 | 104 | \Neon::endProfile('COBE::RENDER_ACTION', 'cobe'); |
| 104 | 105 | return $render; |
@@ -112,8 +113,9 @@ discard block |
||
| 112 | 113 | { |
| 113 | 114 | $request = neon()->request; |
| 114 | 115 | $url = $request->get('page'); |
| 115 | - if (!$url) |
|
| 116 | - $this->pageNotFound(); |
|
| 116 | + if (!$url) { |
|
| 117 | + $this->pageNotFound(); |
|
| 118 | + } |
|
| 117 | 119 | \Neon::app('cms')->page->setByUrl($url); |
| 118 | 120 | $pageData = neon()->getCms()->getPage()->getPageData(); |
| 119 | 121 | return $this->actionPage($pageData['nice_id']); |
@@ -146,11 +146,13 @@ discard block |
||
| 146 | 146 | public function getThemeHierarchy() |
| 147 | 147 | { |
| 148 | 148 | // if we have a theme hierarchy use that |
| 149 | - if (count($this->_themeHierarchy)) |
|
| 150 | - return $this->_themeHierarchy; |
|
| 149 | + if (count($this->_themeHierarchy)) { |
|
| 150 | + return $this->_themeHierarchy; |
|
| 151 | + } |
|
| 151 | 152 | // otherwise drop back to the themeName |
| 152 | - if (!empty($this->_themeName)) |
|
| 153 | - return [$this->_themeName]; |
|
| 153 | + if (!empty($this->_themeName)) { |
|
| 154 | + return [$this->_themeName]; |
|
| 155 | + } |
|
| 154 | 156 | // otherwise return nothing |
| 155 | 157 | return []; |
| 156 | 158 | } |
@@ -261,8 +263,9 @@ discard block |
||
| 261 | 263 | */ |
| 262 | 264 | public function getMapResults($requestKey) |
| 263 | 265 | { |
| 264 | - if (!isset($this->_mapRequestKey[$requestKey])) |
|
| 265 | - throw new \InvalidArgumentException('The provided request key "'.$requestKey.'" does not exist'); |
|
| 266 | + if (!isset($this->_mapRequestKey[$requestKey])) { |
|
| 267 | + throw new \InvalidArgumentException('The provided request key "'.$requestKey.'" does not exist'); |
|
| 268 | + } |
|
| 266 | 269 | list($key, $ids, $fields) = $this->_mapRequestKey[$requestKey]; |
| 267 | 270 | if ($key === 'pages') { |
| 268 | 271 | $pages = CmsPage::find()->select(array_merge(['id', 'nice_id', 'title'], $fields)) |
@@ -298,8 +301,9 @@ discard block |
||
| 298 | 301 | public function formatPageMapResults($pages, $fields) |
| 299 | 302 | { |
| 300 | 303 | return collect($pages)->mapWithKeys(function ($item, $key) use($fields) { |
| 301 | - if (empty($fields)) |
|
| 302 | - return [$item['id'] => $item['nice_id'] . ': ' . $item['title']]; |
|
| 304 | + if (empty($fields)) { |
|
| 305 | + return [$item['id'] => $item['nice_id'] . ': ' . $item['title']]; |
|
| 306 | + } |
|
| 303 | 307 | return [$item['id'] => $item]; |
| 304 | 308 | })->all(); |
| 305 | 309 | } |
@@ -82,13 +82,15 @@ |
||
| 82 | 82 | $types = $this->listPhoebeTypes(); |
| 83 | 83 | $requested = isset($types[$phoebeKey]) ? $types[$phoebeKey] : null; |
| 84 | 84 | // check that we can create the requested type |
| 85 | - if (!($requested && in_array($requested['status'], ['AVAILABLE', 'IN_DEVELOPMENT']))) |
|
| 86 | - return null; |
|
| 85 | + if (!($requested && in_array($requested['status'], ['AVAILABLE', 'IN_DEVELOPMENT']))) { |
|
| 86 | + return null; |
|
| 87 | + } |
|
| 87 | 88 | $adapter = $requested['adapter']; |
| 88 | - if (strpos($adapter, '\\') !== false) |
|
| 89 | - $type = $adapter; |
|
| 90 | - else |
|
| 91 | - $type = str_replace('ADAPTER', $requested['adapter'], $this->genericTypePath); |
|
| 89 | + if (strpos($adapter, '\\') !== false) { |
|
| 90 | + $type = $adapter; |
|
| 91 | + } else { |
|
| 92 | + $type = str_replace('ADAPTER', $requested['adapter'], $this->genericTypePath); |
|
| 93 | + } |
|
| 92 | 94 | return $type ? new $type : null; |
| 93 | 95 | } |
| 94 | 96 | |
@@ -41,8 +41,9 @@ discard block |
||
| 41 | 41 | public function editObject($changes) |
| 42 | 42 | { |
| 43 | 43 | // check if there's anything to do |
| 44 | - if (empty($changes) || $changes == $this->data) |
|
| 45 | - return true; |
|
| 44 | + if (empty($changes) || $changes == $this->data) { |
|
| 45 | + return true; |
|
| 46 | + } |
|
| 46 | 47 | |
| 47 | 48 | // extract the data and save appropriately to |
| 48 | 49 | // the associated database tables ... if any |
@@ -59,8 +60,9 @@ discard block |
||
| 59 | 60 | public function setDataSources($sources) |
| 60 | 61 | { |
| 61 | 62 | foreach ($sources as $key=>$value) { |
| 62 | - if (empty($value)) |
|
| 63 | - unset($sources[$key]); |
|
| 63 | + if (empty($value)) { |
|
| 64 | + unset($sources[$key]); |
|
| 65 | + } |
|
| 64 | 66 | } |
| 65 | 67 | $this->dataSourceIds = $sources; |
| 66 | 68 | } |
@@ -97,8 +99,9 @@ discard block |
||
| 97 | 99 | */ |
| 98 | 100 | protected function getDataSources() |
| 99 | 101 | { |
| 100 | - foreach ($this->dataSourceIds as $key=>$id) |
|
| 101 | - $this->dataSourceObjects[$key] = $this->getDds()->getObject($id); |
|
| 102 | + foreach ($this->dataSourceIds as $key=>$id) { |
|
| 103 | + $this->dataSourceObjects[$key] = $this->getDds()->getObject($id); |
|
| 104 | + } |
|
| 102 | 105 | } |
| 103 | 106 | |
| 104 | 107 | /** |
@@ -118,8 +121,9 @@ discard block |
||
| 118 | 121 | $object = array_merge($this->getAllowedFieldsForClass($object['_classType']), $object); |
| 119 | 122 | // now update the object with the data from daedalus |
| 120 | 123 | $data = $dds->getObject($object['_uuid']); |
| 121 | - if ($data) |
|
| 122 | - $object = array_replace($object, array_intersect_key($data, $object)); |
|
| 124 | + if ($data) { |
|
| 125 | + $object = array_replace($object, array_intersect_key($data, $object)); |
|
| 126 | + } |
|
| 123 | 127 | } |
| 124 | 128 | // recursively update if this is in a tree structure |
| 125 | 129 | if ($isTree && is_array($object)) { |
@@ -179,8 +183,9 @@ discard block |
||
| 179 | 183 | } |
| 180 | 184 | } |
| 181 | 185 | } |
| 182 | - if (count($relations)) |
|
| 183 | - $this->saveLinkedObjects($relations); |
|
| 186 | + if (count($relations)) { |
|
| 187 | + $this->saveLinkedObjects($relations); |
|
| 188 | + } |
|
| 184 | 189 | } |
| 185 | 190 | |
| 186 | 191 | /** |
@@ -216,8 +221,9 @@ discard block |
||
| 216 | 221 | $relations = $renderables[$subRenderable]['relations']; |
| 217 | 222 | foreach ($relations as $relation) { |
| 218 | 223 | $memberRef = $relation['memberRef']; |
| 219 | - if (!isset($extracted['__relations'][$objId][$memberRef])) |
|
| 220 | - $extracted['__relations'][$objId][$memberRef] = []; |
|
| 224 | + if (!isset($extracted['__relations'][$objId][$memberRef])) { |
|
| 225 | + $extracted['__relations'][$objId][$memberRef] = []; |
|
| 226 | + } |
|
| 221 | 227 | $extracted['__relations'][$objId][$memberRef] = array_merge($extracted['__relations'][$objId][$memberRef], $newObjectIds); |
| 222 | 228 | } |
| 223 | 229 | } |
@@ -259,8 +265,9 @@ discard block |
||
| 259 | 265 | if (empty($fieldsForClass)) { |
| 260 | 266 | $definition = $this->getDefinition(); |
| 261 | 267 | foreach ($definition['renderables'] as $r) { |
| 262 | - if ($r['type'] == 'MemberComponent') |
|
| 263 | - $fieldsForClass[$r['class_type']][$r['member_ref']] = null; |
|
| 268 | + if ($r['type'] == 'MemberComponent') { |
|
| 269 | + $fieldsForClass[$r['class_type']][$r['member_ref']] = null; |
|
| 270 | + } |
|
| 264 | 271 | } |
| 265 | 272 | } |
| 266 | 273 | return $fieldsForClass[$classType]; |
@@ -322,8 +329,9 @@ discard block |
||
| 322 | 329 | if (isset($renderables[$phoebeKey])) { |
| 323 | 330 | // check the renderable exists and is a class component |
| 324 | 331 | $ren = $renderables[$phoebeKey]; |
| 325 | - if ($ren['type'] != 'ClassComponent') |
|
| 326 | - continue; |
|
| 332 | + if ($ren['type'] != 'ClassComponent') { |
|
| 333 | + continue; |
|
| 334 | + } |
|
| 327 | 335 | |
| 328 | 336 | // create the object and any required data params |
| 329 | 337 | $object = [ |
@@ -334,8 +342,9 @@ discard block |
||
| 334 | 342 | foreach ($ren['items'] as $item) { |
| 335 | 343 | if (isset($renderables[$item])) { |
| 336 | 344 | $iRen = $renderables[$item]; |
| 337 | - if ($iRen['type'] != 'MemberComponent') |
|
| 338 | - continue; |
|
| 345 | + if ($iRen['type'] != 'MemberComponent') { |
|
| 346 | + continue; |
|
| 347 | + } |
|
| 339 | 348 | $object[$iRen['member_ref']] = null; |
| 340 | 349 | } |
| 341 | 350 | } |
@@ -455,8 +464,9 @@ discard block |
||
| 455 | 464 | private $_class = null; |
| 456 | 465 | private function getClass() |
| 457 | 466 | { |
| 458 | - if (!$this->_class) |
|
| 459 | - $this->_class = neon('phoebe')->getIPhoebeType($this->phoebeType)->getClass($this->classType); |
|
| 467 | + if (!$this->_class) { |
|
| 468 | + $this->_class = neon('phoebe')->getIPhoebeType($this->phoebeType)->getClass($this->classType); |
|
| 469 | + } |
|
| 460 | 470 | return $this->_class; |
| 461 | 471 | } |
| 462 | 472 | |
@@ -469,8 +479,9 @@ discard block |
||
| 469 | 479 | private $_dds = null; |
| 470 | 480 | private function getDds() |
| 471 | 481 | { |
| 472 | - if (!$this->_dds) |
|
| 473 | - $this->_dds = neon('dds')->getIDdsObjectManagement(); |
|
| 482 | + if (!$this->_dds) { |
|
| 483 | + $this->_dds = neon('dds')->getIDdsObjectManagement(); |
|
| 484 | + } |
|
| 474 | 485 | return $this->_dds; |
| 475 | 486 | } |
| 476 | 487 | |