@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | if (isset($params['type'])) { |
| 117 | 117 | $defaults['type'] = $params['type']; |
| 118 | 118 | // path to the file is determined by the theme hierarchy |
| 119 | - $defaults['file'] = $params['type'] . '.tpl'; |
|
| 119 | + $defaults['file'] = $params['type'].'.tpl'; |
|
| 120 | 120 | if (isset($params['key'])) |
| 121 | 121 | self::buildDataFromCmsKeyAttributes($params); |
| 122 | 122 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | return $this->createStaticEditable($content); |
| 232 | 232 | } else { |
| 233 | 233 | $file = $this->params['file']; |
| 234 | - $this->params['hasData'] = count($this->data)>0; |
|
| 234 | + $this->params['hasData'] = count($this->data) > 0; |
|
| 235 | 235 | $this->params['hasResponse'] = true; |
| 236 | 236 | $this->params['data'] = $this->data; |
| 237 | 237 | $this->params['edit'] = $this->createDynamicEditable(); |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | public function getId() |
| 298 | 298 | { |
| 299 | 299 | if ($this->_id === null) { |
| 300 | - $this->_id = $this->getPage()->getId() . '_' . static::$autoIdPrefix . static::$counter++; |
|
| 300 | + $this->_id = $this->getPage()->getId().'_'.static::$autoIdPrefix.static::$counter++; |
|
| 301 | 301 | } |
| 302 | 302 | return $this->_id; |
| 303 | 303 | } |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | $dataKey = $this->params['data-key']; |
| 340 | 340 | $dataPageId = $this->params['data-page-id']; |
| 341 | 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>'; |
|
| 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 | 343 | else |
| 344 | 344 | return "<div style='display:inline-block;' class='cobe-editable cobe-static' data-key='$dataKey' data-page-id='$dataPageId' contenteditable='true' />$value</div>"; |
| 345 | 345 | } else { |
@@ -118,11 +118,13 @@ discard block |
||
| 118 | 118 | $defaults['type'] = $params['type']; |
| 119 | 119 | // path to the file is determined by the theme hierarchy |
| 120 | 120 | $defaults['file'] = $params['type'] . '.tpl'; |
| 121 | - if (isset($params['key'])) |
|
| 122 | - self::buildDataFromCmsKeyAttributes($params); |
|
| 121 | + if (isset($params['key'])) { |
|
| 122 | + self::buildDataFromCmsKeyAttributes($params); |
|
| 123 | + } |
|
| 123 | 124 | } |
| 124 | - if (isset($params['dds']) || isset($params['dds_page']) || isset($params['dds_class'])) |
|
| 125 | - Daedalus::buildDataFromDdsAttributes($params); |
|
| 125 | + if (isset($params['dds']) || isset($params['dds_page']) || isset($params['dds_class'])) { |
|
| 126 | + Daedalus::buildDataFromDdsAttributes($params); |
|
| 127 | + } |
|
| 126 | 128 | $resolvedParams = Arr::merge($defaults, $params); |
| 127 | 129 | return $widget->render($resolvedParams, $template); |
| 128 | 130 | } |
@@ -169,8 +171,9 @@ discard block |
||
| 169 | 171 | } |
| 170 | 172 | // scb = static content block |
| 171 | 173 | $params['type'] = '_scb'; |
| 172 | - if (isset($params['key'])) |
|
| 173 | - self::buildDataFromCmsKeyAttributes($params); |
|
| 174 | + if (isset($params['key'])) { |
|
| 175 | + self::buildDataFromCmsKeyAttributes($params); |
|
| 176 | + } |
|
| 174 | 177 | $params['content'] = $content; |
| 175 | 178 | $params['wys'] = (isset($params['wys']) ? $params['wys'] : true); |
| 176 | 179 | return $widget->render($params, $template); |
@@ -206,8 +209,9 @@ discard block |
||
| 206 | 209 | $data = []; |
| 207 | 210 | if (($dataRequest = $this->getDataRequest()) !== null) { |
| 208 | 211 | $id = $meta = null; |
| 209 | - if (!$this->getPage()->requestWidgetData($dataRequest, $data, $id, $this->isStatic, $meta)) |
|
| 210 | - return $id; |
|
| 212 | + if (!$this->getPage()->requestWidgetData($dataRequest, $data, $id, $this->isStatic, $meta)) { |
|
| 213 | + return $id; |
|
| 214 | + } |
|
| 211 | 215 | $this->saveData($data); |
| 212 | 216 | $this->saveDataMetaInformation($meta); |
| 213 | 217 | } |
@@ -244,8 +248,9 @@ discard block |
||
| 244 | 248 | $this->params['meta'] = $this->meta; |
| 245 | 249 | |
| 246 | 250 | // createTemplate is an expensive call so only call it once per file and reset all variables on the stored template. |
| 247 | - if (!isset($templates[$file])) |
|
| 248 | - $templates[$file] = $this->renderer->createTemplate($file); |
|
| 251 | + if (!isset($templates[$file])) { |
|
| 252 | + $templates[$file] = $this->renderer->createTemplate($file); |
|
| 253 | + } |
|
| 249 | 254 | $tpl = $templates[$file]; |
| 250 | 255 | $tpl->tpl_vars = $tpl->config_vars = []; |
| 251 | 256 | |
@@ -263,8 +268,9 @@ discard block |
||
| 263 | 268 | */ |
| 264 | 269 | protected function getDataRequest() |
| 265 | 270 | { |
| 266 | - if (isset($this->params['data'])) |
|
| 267 | - return Daedalus::convertDataRequestToJson($this->params['data']); |
|
| 271 | + if (isset($this->params['data'])) { |
|
| 272 | + return Daedalus::convertDataRequestToJson($this->params['data']); |
|
| 273 | + } |
|
| 268 | 274 | return null; |
| 269 | 275 | } |
| 270 | 276 | |
@@ -320,15 +326,17 @@ discard block |
||
| 320 | 326 | */ |
| 321 | 327 | protected static function buildDataFromCmsKeyAttributes(&$params) |
| 322 | 328 | { |
| 323 | - if (!isset($params['type'], $params['key'])) |
|
| 324 | - return; |
|
| 329 | + if (!isset($params['type'], $params['key'])) { |
|
| 330 | + return; |
|
| 331 | + } |
|
| 325 | 332 | $key = "$params[type]_$params[key]"; |
| 326 | 333 | $pageId = isset($params['page']) ? self::$page->getId() : null; |
| 327 | 334 | $params['data-key'] = $key; |
| 328 | 335 | $params['data-page-id'] = $pageId; |
| 329 | 336 | $params['data'] = "'key':'$key','pageId':'$pageId'"; |
| 330 | - if (!isset($params['content'])) |
|
| 331 | - $params['content'] = "Add Content for $params[key] here"; |
|
| 337 | + if (!isset($params['content'])) { |
|
| 338 | + $params['content'] = "Add Content for $params[key] here"; |
|
| 339 | + } |
|
| 332 | 340 | $params['is_static'] = true; |
| 333 | 341 | } |
| 334 | 342 | |
@@ -344,10 +352,11 @@ discard block |
||
| 344 | 352 | if ($this->getPage()->isInEditMode()) { |
| 345 | 353 | $dataKey = $this->params['data-key']; |
| 346 | 354 | $dataPageId = $this->params['data-page-id']; |
| 347 | - if ((isset($this->params['wys']) || isset($this->params['wysiwyg'])) || (isset($this->params['editor']) && strpos('wys', $this->params['editor'] === 0))) |
|
| 348 | - 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>'; |
|
| 349 | - else |
|
| 350 | - return "<div style='display:inline-block;' class='cobe-editable cobe-static' data-key='$dataKey' data-page-id='$dataPageId' contenteditable='true' />$value</div>"; |
|
| 355 | + if ((isset($this->params['wys']) || isset($this->params['wysiwyg'])) || (isset($this->params['editor']) && strpos('wys', $this->params['editor'] === 0))) { |
|
| 356 | + 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>'; |
|
| 357 | + } else { |
|
| 358 | + return "<div style='display:inline-block;' class='cobe-editable cobe-static' data-key='$dataKey' data-page-id='$dataPageId' contenteditable='true' />$value</div>"; |
|
| 359 | + } |
|
| 351 | 360 | } else { |
| 352 | 361 | return $value; |
| 353 | 362 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | $id = $request->get('id'); |
| 39 | 39 | if (!$firefly->fileManager->exists($id)) { |
| 40 | 40 | // show placeholder image - should be handled by image manager - controllers should not know |
| 41 | - return neon()->response->sendFile(dirname(__DIR__) . '/assets/placeholder.jpg', 'No File', ['inline' => true]); |
|
| 41 | + return neon()->response->sendFile(dirname(__DIR__).'/assets/placeholder.jpg', 'No File', ['inline' => true]); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // as the url is unique for a file we can be aggressive about caching |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | return $firefly->fileManager->sendFile($id, (bool) $download); |
| 55 | 55 | } catch (\Exception $e) { |
| 56 | 56 | // if path unknown respond with a blank placeholder |
| 57 | - return neon()->response->sendFile(dirname(__DIR__) . '/assets/placeholder.jpg', 'No File', ['inline' => true]); |
|
| 57 | + return neon()->response->sendFile(dirname(__DIR__).'/assets/placeholder.jpg', 'No File', ['inline' => true]); |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $id = neon()->request->getRequired('id'); |
| 81 | 81 | |
| 82 | 82 | // create a unique request key - add v2 to force use of new cached version |
| 83 | - $requestKey = neon()->request->absoluteUrl . 'v6'; |
|
| 83 | + $requestKey = neon()->request->absoluteUrl.'v6'; |
|
| 84 | 84 | |
| 85 | 85 | // see if we already have this in cache and the browser already has it too |
| 86 | 86 | // We want to remove the need to process images when ever possible |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | public function generatePublicFile($id, $imageContent) |
| 148 | 148 | { |
| 149 | - $dir = substr($id,0, 3); |
|
| 149 | + $dir = substr($id, 0, 3); |
|
| 150 | 150 | $publicDir = neon()->getAlias("@webroot/assets/firefly/$dir"); |
| 151 | 151 | if (!file_exists($publicDir)) { |
| 152 | 152 | FileHelper::createDirectory($publicDir); |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * Handle a request that can return a 304 not modified header |
| 182 | 182 | * @param bool|string $cacheKey - default false - if cache key is specified |
| 183 | 183 | */ |
| 184 | - public function handleNotModified($cacheKey=false) |
|
| 184 | + public function handleNotModified($cacheKey = false) |
|
| 185 | 185 | { |
| 186 | 186 | $requestHeaders = neon()->request->headers; |
| 187 | 187 | $browserHasCache = (isset($requestHeaders['If-Modified-Since']) || isset($requestHeaders['If-None-Match'])); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | { |
| 198 | 198 | header($_SERVER['SERVER_PROTOCOL'].' 304 Not modified'); |
| 199 | 199 | header('Cache-Control: private, max-age=30000000, immutable, only-if-cached'); |
| 200 | - header('Expires: ' . Carbon::now()->addYear(10)->toRfc1123String()); |
|
| 200 | + header('Expires: '.Carbon::now()->addYear(10)->toRfc1123String()); |
|
| 201 | 201 | exit; |
| 202 | 202 | } |
| 203 | 203 | |
@@ -129,7 +129,9 @@ |
||
| 129 | 129 | public function getName($idOrUrl) |
| 130 | 130 | { |
| 131 | 131 | if (Hash::isUuid64($idOrUrl)) { |
| 132 | - if (!neon()->firefly->fileManager->exists($idOrUrl)) throw new HttpException(404); |
|
| 132 | + if (!neon()->firefly->fileManager->exists($idOrUrl)) { |
|
| 133 | + throw new HttpException(404); |
|
| 134 | + } |
|
| 133 | 135 | $meta = neon()->firefly->fileManager->getMeta($idOrUrl); |
| 134 | 136 | return $meta['name']; |
| 135 | 137 | } |