@@ -9,7 +9,7 @@ |
||
9 | 9 | |
10 | 10 | class CmpManager extends \yii\base\Component |
11 | 11 | { |
12 | - public function getComponents(){ |
|
12 | + public function getComponents() { |
|
13 | 13 | |
14 | 14 | } |
15 | 15 | } |
16 | 16 | \ No newline at end of file |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param array $themeHierarchy |
34 | 34 | * @throws \SmartyException |
35 | 35 | */ |
36 | - public function __construct($page=null, array $themeHierarchy=[]) |
|
36 | + public function __construct($page = null, array $themeHierarchy = []) |
|
37 | 37 | { |
38 | 38 | parent::__construct(); |
39 | 39 | // $this->smarty->escape_html = true; |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | |
74 | 74 | // We have to set cachable to false otherwise it only caches the id output not the full rendering |
75 | 75 | $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'widget', ['\neon\cms\components\Widget', 'factory'], false); |
76 | - $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'editor', ['\neon\cms\components\Editor', 'editor'] , false); |
|
77 | - $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'drop_zone', ['\neon\cms\components\Editor', 'editor'] , false); |
|
76 | + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'editor', ['\neon\cms\components\Editor', 'editor'], false); |
|
77 | + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'drop_zone', ['\neon\cms\components\Editor', 'editor'], false); |
|
78 | 78 | |
79 | 79 | $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'dds', ['\neon\cms\components\Daedalus', 'dds'], false); |
80 | 80 | $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'dds_choice', ['\neon\cms\components\Daedalus', 'dds_choice'], false); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | * @return string |
207 | 207 | * @throws \SmartyException |
208 | 208 | */ |
209 | - public function renderString($string, $saveCompile=true) |
|
209 | + public function renderString($string, $saveCompile = true) |
|
210 | 210 | { |
211 | 211 | $smartyCmd = $saveCompile ? 'string' : 'eval'; |
212 | 212 | return $this->smarty->fetch("$smartyCmd:$string"); |
@@ -48,12 +48,14 @@ discard block |
||
48 | 48 | // set up the theme directories |
49 | 49 | foreach ($themeHierarchy as $theme) { |
50 | 50 | if (isset($theme['templates'])) { |
51 | - foreach ($theme['templates'] as $tplDir) |
|
52 | - $this->smarty->addTemplateDir($tplDir); |
|
51 | + foreach ($theme['templates'] as $tplDir) { |
|
52 | + $this->smarty->addTemplateDir($tplDir); |
|
53 | + } |
|
53 | 54 | } |
54 | 55 | if (isset($theme['plugins'])) { |
55 | - foreach ($theme['plugins'] as $pluginDir) |
|
56 | - $this->smarty->addPluginsDir($pluginDir); |
|
56 | + foreach ($theme['plugins'] as $pluginDir) { |
|
57 | + $this->smarty->addPluginsDir($pluginDir); |
|
58 | + } |
|
57 | 59 | } |
58 | 60 | } |
59 | 61 | |
@@ -158,7 +160,9 @@ discard block |
||
158 | 160 | |
159 | 161 | public static function component($params, $content, $tagName, $template, $repeat) |
160 | 162 | { |
161 | - if ($repeat) return; |
|
163 | + if ($repeat) { |
|
164 | + return; |
|
165 | + } |
|
162 | 166 | $params['content'] = $content; |
163 | 167 | $params['slot'] = $content; |
164 | 168 | $params['type'] = $tagName; |
@@ -187,8 +191,9 @@ discard block |
||
187 | 191 | $this->smarty->assign('site', $this->_page->getSiteData()); |
188 | 192 | |
189 | 193 | // an expensive-ish call so reduce need for it in repeated renders |
190 | - if (!isset($templates[$template])) |
|
191 | - $templates[$template] = $this->smarty->createTemplate($template); |
|
194 | + if (!isset($templates[$template])) { |
|
195 | + $templates[$template] = $this->smarty->createTemplate($template); |
|
196 | + } |
|
192 | 197 | $tpl = $templates[$template]; |
193 | 198 | |
194 | 199 | // reset any parameters for the new render |
@@ -27,7 +27,7 @@ |
||
27 | 27 | 'layout' => 'string COMMENT "the name of the layout template to load for this page"', |
28 | 28 | 'template' => 'string COMMENT "the name of the template file"' |
29 | 29 | ]); |
30 | - $this->createTable(CmsUrl::tableName(),[ |
|
30 | + $this->createTable(CmsUrl::tableName(), [ |
|
31 | 31 | 'id' => 'pk', |
32 | 32 | 'url' => 'string', |
33 | 33 | 'page_id' => 'int', |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $this->run('Generating Page UUIDs and nice_ids', function() { |
45 | 45 | // the soft delete column has not been added yet - so lets turn off this behaviour! |
46 | 46 | CmsPage::$softDelete = false; |
47 | - foreach(CmsPage::find()->each(100) as $page) { |
|
47 | + foreach (CmsPage::find()->each(100) as $page) { |
|
48 | 48 | $page->id = CmsPage::uuid64(); |
49 | 49 | $page->nice_id = "page_{$page->old_id}"; |
50 | 50 | $page->save(); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | "UPDATE $cms_url INNER JOIN $cms_page ON $cms_page.nice_id = $cms_url.page_id SET `page_id` = $cms_page.old_id" |
93 | 93 | ); |
94 | 94 | $this->execute("UPDATE $cms_page SET `id` = `old_id`"); |
95 | - $this->alterColumn($cms_page, 'id', $this->integer(11) . ' NOT NULL AUTO_INCREMENT'); |
|
95 | + $this->alterColumn($cms_page, 'id', $this->integer(11).' NOT NULL AUTO_INCREMENT'); |
|
96 | 96 | $this->dropColumn($cms_page, 'old_id'); |
97 | 97 | $this->dropColumn($cms_page, 'nice_id'); |
98 | 98 | $this->alterColumn($cms_url, 'page_id', $this->integer(11)->comment('cms_page foreign key')); |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | |
5 | 5 | class m170107_201653_cms_create_cms_static_content_table_again extends Migration |
6 | 6 | { |
7 | - public function safeUp() |
|
8 | - { |
|
7 | + public function safeUp() |
|
8 | + { |
|
9 | 9 | $cms_static = 'cms_static_content'; |
10 | 10 | |
11 | 11 | // recreate the table with the new structure |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | // } |
47 | 47 | // } |
48 | 48 | // } while ($count < $total); |
49 | - } |
|
49 | + } |
|
50 | 50 | |
51 | - public function safeDown() |
|
52 | - { |
|
51 | + public function safeDown() |
|
52 | + { |
|
53 | 53 | $this->dropTable('cms_static_content'); |
54 | - } |
|
54 | + } |
|
55 | 55 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | |
11 | 11 | // recreate the table with the new structure |
12 | 12 | $this->execute("DROP TABLE IF EXISTS $cms_static"); |
13 | - $sql =<<<EOQ |
|
13 | + $sql = <<<EOQ |
|
14 | 14 | CREATE TABLE IF NOT EXISTS `cms_static_content` ( |
15 | 15 | `key` varchar(100) NOT NULL COMMENT 'a key to access the content' COLLATE utf8mb4_unicode_ci, |
16 | 16 | `page_id` INT UNSIGNED NULL COMMENT 'if provided, restrict content to the associated page', |
@@ -7,23 +7,23 @@ |
||
7 | 7 | |
8 | 8 | class m170112_201653_cms_static_content_page_ids_to_uuid64 extends Migration |
9 | 9 | { |
10 | - public function safeUp() |
|
11 | - { |
|
12 | - $cms_static_content = CmsStaticContent::tableName(); |
|
10 | + public function safeUp() |
|
11 | + { |
|
12 | + $cms_static_content = CmsStaticContent::tableName(); |
|
13 | 13 | $cms_page = CmsPage::tableName(); |
14 | 14 | |
15 | 15 | // use a nice id |
16 | - $this->alterColumn($cms_static_content, 'page_id', $this->char(22)->null()->comment('A uuid using base 64')); |
|
16 | + $this->alterColumn($cms_static_content, 'page_id', $this->char(22)->null()->comment('A uuid using base 64')); |
|
17 | 17 | // update with nice_id's |
18 | 18 | $this->execute("UPDATE $cms_static_content JOIN $cms_page ON $cms_page.old_id = $cms_static_content.page_id SET $cms_static_content.page_id = $cms_page.id"); |
19 | - } |
|
19 | + } |
|
20 | 20 | |
21 | - public function safeDown() |
|
22 | - { |
|
21 | + public function safeDown() |
|
22 | + { |
|
23 | 23 | $cms_static_content = CmsStaticContent::tableName(); |
24 | 24 | $cms_page = CmsPage::tableName(); |
25 | 25 | |
26 | 26 | $this->execute("UPDATE $cms_static_content JOIN $cms_page ON $cms_page.id = $cms_static_content.page_id SET $cms_static_content.page_id = $cms_page.old_id"); |
27 | 27 | $this->alterColumn($cms_static_content, 'page_id', $this->integer(11)->null()); |
28 | - } |
|
28 | + } |
|
29 | 29 | } |
30 | 30 | \ No newline at end of file |
@@ -10,7 +10,7 @@ |
||
10 | 10 | // created by an earlier cms migration so always appears if the |
11 | 11 | // migration creation order is not adhered to. |
12 | 12 | $connection = neon()->db; |
13 | -$sql =<<<EOQ |
|
13 | +$sql = <<<EOQ |
|
14 | 14 | SET foreign_key_checks = 0; |
15 | 15 | DROP TABLE IF EXISTS `ddt_cms_static_content`; |
16 | 16 | DELETE FROM `dds_member` WHERE `class_type`='cms_static_content'; |
@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | |
8 | 8 | class m170112_211700_change_dds_page_ids_to_uuid64 extends Migration |
9 | 9 | { |
10 | - public function safeUp() |
|
11 | - { |
|
12 | - $cms_page = CmsPage::tableName(); |
|
13 | - // Step 1 |
|
10 | + public function safeUp() |
|
11 | + { |
|
12 | + $cms_page = CmsPage::tableName(); |
|
13 | + // Step 1 |
|
14 | 14 | // ------ |
15 | - // loop through all members in the DDS and find all members with a definition using |
|
15 | + // loop through all members in the DDS and find all members with a definition using |
|
16 | 16 | // {class: neon\\cms\\form\\fields\\PageSelector} |
17 | 17 | // or where the definition uses a `dataMapKey` of `pages` and a `dataMapProvider` of `cms` |
18 | 18 | $members = neon()->db->query()->select('*')->from('dds_member')->where('definition LIKE \'{"class":"neon__cms__form__fields__PageSelector%\'')->all(); |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | } |
48 | 48 | } |
49 | 49 | $this->dropColumn($cms_page, 'old_id'); |
50 | - } |
|
50 | + } |
|
51 | 51 | |
52 | - public function safeDown() |
|
53 | - { |
|
54 | - echo "There is no coming back from this!\n"; |
|
55 | - } |
|
52 | + public function safeDown() |
|
53 | + { |
|
54 | + echo "There is no coming back from this!\n"; |
|
55 | + } |
|
56 | 56 | } |
57 | 57 | \ No newline at end of file |
@@ -27,14 +27,14 @@ |
||
27 | 27 | // - note the `member_ref` as the $column in the ddt table - this column will hold the previous integer based page id |
28 | 28 | // which will match the cms_page.old_id column |
29 | 29 | foreach ($members as $member) { |
30 | - $class_type = $member['class_type']; |
|
31 | - $ddt_table_name = 'ddt_' . $class_type; |
|
30 | + $class_type = $member['class_type']; |
|
31 | + $ddt_table_name = 'ddt_'.$class_type; |
|
32 | 32 | $column = $member['member_ref']; |
33 | 33 | |
34 | 34 | // Step 3 |
35 | 35 | // ------ |
36 | 36 | // Alter the $column in $ddt_table_name to be a uuid64 (char(22)) |
37 | - $exists = $this->db->createCommand("SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE `table_name` = '$ddt_table_name' AND `table_schema` = '". env('DB_NAME')."' AND column_name = '$column'")->queryScalar(); |
|
37 | + $exists = $this->db->createCommand("SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE `table_name` = '$ddt_table_name' AND `table_schema` = '".env('DB_NAME')."' AND column_name = '$column'")->queryScalar(); |
|
38 | 38 | if ($exists) { |
39 | 39 | $this->alterColumn($ddt_table_name, $column, $this->char(22)->comment("A uuid using base 64")); |
40 | 40 | // Update the $column value in every row in the $ddt_table_name by matching it to the cms_page.old_id |
@@ -5,20 +5,20 @@ |
||
5 | 5 | class m161130_180814_cms_additional_page_fields extends Migration |
6 | 6 | { |
7 | 7 | |
8 | - public function safeUp() |
|
9 | - { |
|
8 | + public function safeUp() |
|
9 | + { |
|
10 | 10 | $this->addColumn('cms_page', 'keywords', "VARCHAR(1000) NULL COMMENT 'Keywords for this page'"); |
11 | 11 | $this->addColumn('cms_page', 'description', "VARCHAR(1000) NULL COMMENT 'Description of this page'"); |
12 | 12 | $this->addColumn('cms_page', 'languages', "VARCHAR(1000) NULL COMMENT 'Supported languages on this page'"); |
13 | 13 | $this->addColumn('cms_page', 'page_params', "VARCHAR(10000) NULL COMMENT 'Additional parameters for this page which are interpreted directly within the templates'"); |
14 | - } |
|
14 | + } |
|
15 | 15 | |
16 | - public function safeDown() |
|
17 | - { |
|
16 | + public function safeDown() |
|
17 | + { |
|
18 | 18 | $this->dropColumn('cms_page', 'keywords'); |
19 | 19 | $this->dropColumn('cms_page', 'description'); |
20 | 20 | $this->dropColumn('cms_page', 'languages'); |
21 | 21 | $this->dropColumn('cms_page', 'page_params'); |
22 | - } |
|
22 | + } |
|
23 | 23 | |
24 | 24 | } |