From c86b28a7ab9dad763435b09479c98b075ca40f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?"J.=20Rene=CC=81e=20Beach"?= Date: Fri, 9 Nov 2012 15:45:52 -0500 Subject: [PATCH] debugging the controller error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: J. Renée Beach --- core/modules/grid/config/grid.ninesixty_12.yml | 9 + core/modules/grid/config/grid.ninesixty_16.yml | 9 + core/modules/grid/config/grid.six_column_fluid.yml | 9 + .../grid/config/grid.three_column_fluid.yml | 9 + .../grid/config/grid.twelve_column_fluid.yml | 9 + core/modules/grid/grid.info | 15 + core/modules/grid/grid.module | 26 + core/modules/grid/lib/Drupal/grid/Grid.php | 81 +++ core/modules/grid/lib/Drupal/grid/GridBundle.php | 25 + .../grid/lib/Drupal/grid/Plugin/GridInterface.php | 30 ++ .../lib/Drupal/grid/Plugin/Type/GridManager.php | 27 + .../Drupal/grid/Plugin/grid/grid/EqualColumn.php | 100 ++++ core/modules/layout/layout.info | 7 + core/modules/layout/layout.module | 12 +- core/modules/layout/tests/layout_test.info | 7 + .../layout_test_theme/layout_test_theme.info | 7 + core/modules/page/config/page.front_page.yml | 8 + core/modules/page/config/page.not_admin_page.yml | 8 + core/modules/page/config/page.user_page.yml | 8 + .../page/layouts/static/complex/complex.yml | 2 + core/modules/page/layouts/static/simple/simple.yml | 2 + core/modules/page/lib/Drupal/page/Page.php | 66 +++ .../page/lib/Drupal/page/PageFormController.php | 109 ++++ .../page/lib/Drupal/page/PageListController.php | 71 +++ core/modules/page/page.admin.inc | 120 +++++ core/modules/page/page.info | 15 + core/modules/page/page.module | 176 +++++++ core/modules/region/config/region.body.yml | 2 + core/modules/region/config/region.footer_a.yml | 2 + core/modules/region/config/region.footer_b.yml | 2 + core/modules/region/config/region.footer_c.yml | 2 + core/modules/region/config/region.header_a.yml | 2 + core/modules/region/config/region.header_b.yml | 2 + core/modules/region/config/region.header_c.yml | 2 + core/modules/region/config/region.navigation.yml | 2 + core/modules/region/config/region.sidebar_a.yml | 2 + core/modules/region/config/region.sidebar_b.yml | 2 + core/modules/region/config/region.sidebar_c.yml | 2 + core/modules/region/config/region.subheader_a.yml | 2 + core/modules/region/config/region.subheader_b.yml | 2 + core/modules/region/config/region.subheader_c.yml | 2 + core/modules/region/config/region.title.yml | 2 + core/modules/region/lib/Drupal/region/Region.php | 38 ++ .../lib/Drupal/region/RegionFormController.php | 75 +++ .../region/lib/Drupal/region/Tests/RegionTest.php | 141 ++++++ core/modules/region/region.admin.inc | 67 +++ core/modules/region/region.info | 14 + core/modules/region/region.module | 126 +++++ .../config/grid.six_column_fluid_tablet.yml | 12 + .../config/grid.three_column_fluid_smartphone.yml | 12 + .../config/grid.twelve_column_fluid_standard.yml | 12 + .../modules/rlayout/config/rlayout.breakpoints.yml | 3 + core/modules/rlayout/config/rlayoutset.default.yml | 19 + .../modules/rlayout/designer/app/libs/Grid/Grid.js | 25 + .../rlayout/designer/app/libs/GridList/GridList.js | 58 +++ .../designer/app/libs/LayoutList/LayoutList.js | 72 +++ .../app/libs/LayoutManager/LayoutManager.js | 426 ++++++++++++++++ .../app/libs/LayoutPreviewer/LayoutPreviewer.js | 220 ++++++++ .../designer/app/libs/LayoutStep/LayoutStep.js | 484 ++++++++++++++++++ .../rlayout/designer/app/libs/Region/Region.js | 101 ++++ .../designer/app/libs/RegionList/RegionList.js | 119 +++++ .../modules/rlayout/designer/app/libs/Step/Step.js | 54 ++ .../rlayout/designer/app/libs/StepList/StepList.js | 90 ++++ .../designer/app/libs/StepManager/StepManager.js | 88 ++++ .../rlayout/designer/app/libs/Utils/Utils.js | 84 ++++ core/modules/rlayout/designer/app/main.js | 314 ++++++++++++ .../rlayout/designer/assets/css/application.css | 311 ++++++++++++ core/modules/rlayout/designer/assets/css/grid.css | 117 +++++ .../designer/assets/images/grippie-active.png | 14 + .../rlayout/designer/assets/images/grippie.png | 14 + .../designer/assets/images/large-screen.png | 5 + .../designer/assets/images/small-screen.png | 4 + .../assets/js/plugins/breakup/MIT-LICENSE.txt | 7 + .../designer/assets/js/plugins/breakup/README.md | 54 ++ .../designer/assets/js/plugins/breakup/grunt.js | 10 + .../assets/js/plugins/breakup/jquery.breakup.js | 257 ++++++++++ .../js/plugins/breakup/jquery.breakup.min.js | 1 + .../Drupal/rlayout/Plugin/Derivative/Layout.php | 60 +++ .../Plugin/layout/layout/ResponsiveLayout.php | 44 ++ .../modules/rlayout/lib/Drupal/rlayout/RLayout.php | 52 ++ .../lib/Drupal/rlayout/RLayoutFormController.php | 186 +++++++ core/modules/rlayout/rlayout-admin.css | 23 + core/modules/rlayout/rlayout-admin.js | 149 ++++++ core/modules/rlayout/rlayout.admin.inc | 67 +++ core/modules/rlayout/rlayout.info | 19 + core/modules/rlayout/rlayout.module | 252 ++++++++++ core/modules/shortcut/shortcut.base.css | 13 - core/modules/shortcut/shortcut.module | 43 +- core/modules/shortcut/shortcut.theme.css | 71 +-- core/modules/system/system.module | 10 +- .../modules/toolbar/config/toolbar.breakpoints.yml | 1 + core/modules/toolbar/config/toolbar.config.yml | 2 + core/modules/toolbar/css/toolbar.base-rtl.css | 25 + core/modules/toolbar/css/toolbar.base.css | 230 +++++++++ core/modules/toolbar/css/toolbar.icons.css | 79 +++ core/modules/toolbar/css/toolbar.theme-rtl.css | 7 + core/modules/toolbar/css/toolbar.theme.css | 255 ++++++++++ core/modules/toolbar/js/toolbar.js | 531 ++++++++++++++++++++ core/modules/toolbar/templates/toolbar.tpl.php | 17 +- core/modules/toolbar/toolbar-rtl.css | 37 -- core/modules/toolbar/toolbar.css | 129 ----- core/modules/toolbar/toolbar.info | 6 + core/modules/toolbar/toolbar.js | 115 ----- core/modules/toolbar/toolbar.module | 289 +++++------ core/modules/toolbar/toolbar.png | 4 - core/modules/user/user.css | 11 + core/modules/user/user.module | 64 +++ 107 files changed, 6686 insertions(+), 550 deletions(-) create mode 100644 core/modules/grid/config/grid.ninesixty_12.yml create mode 100644 core/modules/grid/config/grid.ninesixty_16.yml create mode 100644 core/modules/grid/config/grid.six_column_fluid.yml create mode 100644 core/modules/grid/config/grid.three_column_fluid.yml create mode 100644 core/modules/grid/config/grid.twelve_column_fluid.yml create mode 100644 core/modules/grid/grid.info create mode 100644 core/modules/grid/grid.module create mode 100644 core/modules/grid/lib/Drupal/grid/Grid.php create mode 100644 core/modules/grid/lib/Drupal/grid/GridBundle.php create mode 100644 core/modules/grid/lib/Drupal/grid/Plugin/GridInterface.php create mode 100644 core/modules/grid/lib/Drupal/grid/Plugin/Type/GridManager.php create mode 100644 core/modules/grid/lib/Drupal/grid/Plugin/grid/grid/EqualColumn.php create mode 100644 core/modules/page/config/page.front_page.yml create mode 100644 core/modules/page/config/page.not_admin_page.yml create mode 100644 core/modules/page/config/page.user_page.yml create mode 100644 core/modules/page/layouts/static/complex/complex.yml create mode 100644 core/modules/page/layouts/static/simple/simple.yml create mode 100644 core/modules/page/lib/Drupal/page/Page.php create mode 100644 core/modules/page/lib/Drupal/page/PageFormController.php create mode 100644 core/modules/page/lib/Drupal/page/PageListController.php create mode 100644 core/modules/page/page.admin.inc create mode 100644 core/modules/page/page.info create mode 100644 core/modules/page/page.module create mode 100644 core/modules/region/config/region.body.yml create mode 100644 core/modules/region/config/region.footer_a.yml create mode 100644 core/modules/region/config/region.footer_b.yml create mode 100644 core/modules/region/config/region.footer_c.yml create mode 100644 core/modules/region/config/region.header_a.yml create mode 100644 core/modules/region/config/region.header_b.yml create mode 100644 core/modules/region/config/region.header_c.yml create mode 100644 core/modules/region/config/region.navigation.yml create mode 100644 core/modules/region/config/region.sidebar_a.yml create mode 100644 core/modules/region/config/region.sidebar_b.yml create mode 100644 core/modules/region/config/region.sidebar_c.yml create mode 100644 core/modules/region/config/region.subheader_a.yml create mode 100644 core/modules/region/config/region.subheader_b.yml create mode 100644 core/modules/region/config/region.subheader_c.yml create mode 100644 core/modules/region/config/region.title.yml create mode 100644 core/modules/region/lib/Drupal/region/Region.php create mode 100644 core/modules/region/lib/Drupal/region/RegionFormController.php create mode 100644 core/modules/region/lib/Drupal/region/Tests/RegionTest.php create mode 100644 core/modules/region/region.admin.inc create mode 100644 core/modules/region/region.info create mode 100644 core/modules/region/region.module create mode 100644 core/modules/rlayout/config/grid.six_column_fluid_tablet.yml create mode 100644 core/modules/rlayout/config/grid.three_column_fluid_smartphone.yml create mode 100644 core/modules/rlayout/config/grid.twelve_column_fluid_standard.yml create mode 100644 core/modules/rlayout/config/rlayout.breakpoints.yml create mode 100644 core/modules/rlayout/config/rlayoutset.default.yml create mode 100644 core/modules/rlayout/designer/app/libs/Grid/Grid.js create mode 100644 core/modules/rlayout/designer/app/libs/GridList/GridList.js create mode 100644 core/modules/rlayout/designer/app/libs/LayoutList/LayoutList.js create mode 100644 core/modules/rlayout/designer/app/libs/LayoutManager/LayoutManager.js create mode 100644 core/modules/rlayout/designer/app/libs/LayoutPreviewer/LayoutPreviewer.js create mode 100644 core/modules/rlayout/designer/app/libs/LayoutStep/LayoutStep.js create mode 100644 core/modules/rlayout/designer/app/libs/Region/Region.js create mode 100644 core/modules/rlayout/designer/app/libs/RegionList/RegionList.js create mode 100644 core/modules/rlayout/designer/app/libs/Step/Step.js create mode 100644 core/modules/rlayout/designer/app/libs/StepList/StepList.js create mode 100644 core/modules/rlayout/designer/app/libs/StepManager/StepManager.js create mode 100644 core/modules/rlayout/designer/app/libs/Utils/Utils.js create mode 100644 core/modules/rlayout/designer/app/main.js create mode 100644 core/modules/rlayout/designer/assets/css/application.css create mode 100644 core/modules/rlayout/designer/assets/css/grid.css create mode 100644 core/modules/rlayout/designer/assets/images/grippie-active.png create mode 100644 core/modules/rlayout/designer/assets/images/grippie.png create mode 100644 core/modules/rlayout/designer/assets/images/large-screen.png create mode 100644 core/modules/rlayout/designer/assets/images/small-screen.png create mode 100644 core/modules/rlayout/designer/assets/js/plugins/breakup/MIT-LICENSE.txt create mode 100644 core/modules/rlayout/designer/assets/js/plugins/breakup/README.md create mode 100644 core/modules/rlayout/designer/assets/js/plugins/breakup/grunt.js create mode 100644 core/modules/rlayout/designer/assets/js/plugins/breakup/jquery.breakup.js create mode 100644 core/modules/rlayout/designer/assets/js/plugins/breakup/jquery.breakup.min.js create mode 100644 core/modules/rlayout/lib/Drupal/rlayout/Plugin/Derivative/Layout.php create mode 100644 core/modules/rlayout/lib/Drupal/rlayout/Plugin/layout/layout/ResponsiveLayout.php create mode 100644 core/modules/rlayout/lib/Drupal/rlayout/RLayout.php create mode 100644 core/modules/rlayout/lib/Drupal/rlayout/RLayoutFormController.php create mode 100644 core/modules/rlayout/rlayout-admin.css create mode 100644 core/modules/rlayout/rlayout-admin.js create mode 100644 core/modules/rlayout/rlayout.admin.inc create mode 100644 core/modules/rlayout/rlayout.info create mode 100644 core/modules/rlayout/rlayout.module create mode 100755 core/modules/toolbar/config/toolbar.breakpoints.yml create mode 100755 core/modules/toolbar/config/toolbar.config.yml create mode 100644 core/modules/toolbar/css/toolbar.base-rtl.css create mode 100644 core/modules/toolbar/css/toolbar.base.css create mode 100644 core/modules/toolbar/css/toolbar.icons-rtl.css create mode 100644 core/modules/toolbar/css/toolbar.icons.css create mode 100644 core/modules/toolbar/css/toolbar.theme-rtl.css create mode 100644 core/modules/toolbar/css/toolbar.theme.css create mode 100755 core/modules/toolbar/js/toolbar.js delete mode 100644 core/modules/toolbar/toolbar-rtl.css delete mode 100644 core/modules/toolbar/toolbar.css mode change 100644 => 100755 core/modules/toolbar/toolbar.info delete mode 100644 core/modules/toolbar/toolbar.js mode change 100644 => 100755 core/modules/toolbar/toolbar.module delete mode 100644 core/modules/toolbar/toolbar.png diff --git a/core/modules/grid/config/grid.ninesixty_12.yml b/core/modules/grid/config/grid.ninesixty_12.yml new file mode 100644 index 0000000..405317c --- /dev/null +++ b/core/modules/grid/config/grid.ninesixty_12.yml @@ -0,0 +1,9 @@ +id: ninesixty_12 +label: '960px wide, 12 column grid' +type: equal_column +options: + type: 'fixed' + width: 960 + columns: 12 + padding_width: 20 + gutter_width: 10 diff --git a/core/modules/grid/config/grid.ninesixty_16.yml b/core/modules/grid/config/grid.ninesixty_16.yml new file mode 100644 index 0000000..4ddff62 --- /dev/null +++ b/core/modules/grid/config/grid.ninesixty_16.yml @@ -0,0 +1,9 @@ +id: ninesixty_16 +label: '960px wide, 16 column grid' +type: equal_column +options: + type: 'fixed' + width: 960 + columns: 16 + padding_width: 20 + gutter_width: 10 diff --git a/core/modules/grid/config/grid.six_column_fluid.yml b/core/modules/grid/config/grid.six_column_fluid.yml new file mode 100644 index 0000000..baff675 --- /dev/null +++ b/core/modules/grid/config/grid.six_column_fluid.yml @@ -0,0 +1,9 @@ +id: six_column_fluid +label: Six column fluid +type: equal_column +options: + type: 'fluid' + width: 100 + columns: 6 + padding_width: 1.5 + gutter_width: 2 diff --git a/core/modules/grid/config/grid.three_column_fluid.yml b/core/modules/grid/config/grid.three_column_fluid.yml new file mode 100644 index 0000000..95f6dc0 --- /dev/null +++ b/core/modules/grid/config/grid.three_column_fluid.yml @@ -0,0 +1,9 @@ +id: three_column_fluid +label: Three column fluid +type: equal_column +options: + type: 'fluid' + width: 100 + columns: 3 + padding_width: 1.5 + gutter_width: 2 diff --git a/core/modules/grid/config/grid.twelve_column_fluid.yml b/core/modules/grid/config/grid.twelve_column_fluid.yml new file mode 100644 index 0000000..35022f6 --- /dev/null +++ b/core/modules/grid/config/grid.twelve_column_fluid.yml @@ -0,0 +1,9 @@ +id: twelve_column_fluid +label: Twelve column fluid +type: equal_column +options: + type: 'fluid' + width: 100 + columns: 12 + padding_width: 1.5 + gutter_width: 2 diff --git a/core/modules/grid/grid.info b/core/modules/grid/grid.info new file mode 100644 index 0000000..8d28b20 --- /dev/null +++ b/core/modules/grid/grid.info @@ -0,0 +1,15 @@ +name = Grid +description = Pluggable grid system manager. +package = Core +version = VERSION +core = 8.x +dependencies[] = config +configure = admin/structure/grids + + + +; Information added by drush on 2012-11-09 +version = "" +project = "drupal" +datestamp = "1352493228" + diff --git a/core/modules/grid/grid.module b/core/modules/grid/grid.module new file mode 100644 index 0000000..396ae6e --- /dev/null +++ b/core/modules/grid/grid.module @@ -0,0 +1,26 @@ + 'Grid', + 'entity class' => 'Drupal\grid\Grid', + 'controller class' => 'Drupal\Core\Config\Entity\ConfigStorageController', + 'config prefix' => 'grid', + 'entity keys' => array( + 'id' => 'id', + 'label' => 'label', + 'uuid' => 'uuid', + ), + ); + return $types; +} diff --git a/core/modules/grid/lib/Drupal/grid/Grid.php b/core/modules/grid/lib/Drupal/grid/Grid.php new file mode 100644 index 0000000..c40b021 --- /dev/null +++ b/core/modules/grid/lib/Drupal/grid/Grid.php @@ -0,0 +1,81 @@ +plugin)) { + // Pass on Grid ID as part of the configuration array. + $this->options['id'] = $this->id; + $this->plugin = drupal_container()->get('plugin.manager.grid')->createInstance($this->type, $this->options); + } + return $this->plugin; + } + + /** + * Implements Drupal\grid\Plugin\GridInterface::getGridCss(). + */ + public function getGridCss($wrapper_selector = NULL, $col_selector_prefix = NULL, $skip_spacing = FALSE) { + return $this->getPlugin()->getGridCss($wrapper_selector, $col_selector_prefix, $skip_spacing); + } + +} diff --git a/core/modules/grid/lib/Drupal/grid/GridBundle.php b/core/modules/grid/lib/Drupal/grid/GridBundle.php new file mode 100644 index 0000000..7c68f29 --- /dev/null +++ b/core/modules/grid/lib/Drupal/grid/GridBundle.php @@ -0,0 +1,25 @@ +register('plugin.manager.grid', 'Drupal\grid\Plugin\Type\GridManager'); + } +} diff --git a/core/modules/grid/lib/Drupal/grid/Plugin/GridInterface.php b/core/modules/grid/lib/Drupal/grid/Plugin/GridInterface.php new file mode 100644 index 0000000..ca73fd8 --- /dev/null +++ b/core/modules/grid/lib/Drupal/grid/Plugin/GridInterface.php @@ -0,0 +1,30 @@ +discovery = new AnnotatedClassDiscovery('grid', 'grid'); + $this->factory = new ReflectionFactory($this); + } +} diff --git a/core/modules/grid/lib/Drupal/grid/Plugin/grid/grid/EqualColumn.php b/core/modules/grid/lib/Drupal/grid/Plugin/grid/grid/EqualColumn.php new file mode 100644 index 0000000..db38826 --- /dev/null +++ b/core/modules/grid/lib/Drupal/grid/Plugin/grid/grid/EqualColumn.php @@ -0,0 +1,100 @@ +configuration; + $css = ''; + + // If the wrapper selector was not provided, generate one. This is useful for + // specific administration use cases when we scope the classes by grids. + if (empty($wrapper_selector)) { + $wrapper_selector = '.grid-' . $grid['id']; + } + + // If the col span selector was not provided, generate one. This is useful + // for the front end to apply varying span widths under different names. + if (empty($col_selector_prefix)) { + $col_selector_prefix = '.grid-col_'; + } + + // If spacing is to be skipped, override the gutter and padding temporarily. + if ($skip_spacing) { + $grid['gutter_width'] = $grid['padding_width'] = 0; + } + + switch ($grid['type']) { + case 'fluid': + $size_suffix = '%'; + // Override to 100% whatever it was. + $grid['width'] = '100'; + break; + case 'fixed': + $size_suffix = 'px'; + break; + } + + // Because we use the border-box box model, we only need to substract the + // size of margins from the full width and divide the rest by number of + // columns to get a value for column size. + $colwidth = ($grid['width'] - (($grid['columns'] - 1) * $grid['gutter_width'])) / $grid['columns']; + + $css = $wrapper_selector . ' .grid-col { + border: 0px solid rgba(0,0,0,0); + float: left; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + -moz-background-clip: padding-box; + -webkit-background-clip: padding-box; + background-clip: padding-box; + margin-left: ' . $grid['gutter_width'] . $size_suffix . '; + padding: 0 ' . $grid['padding_width'] . $size_suffix . '; +} +' . $wrapper_selector . ' .grid-col' . $col_selector_prefix .'first { + margin-left: 0; + clear: both; +} +'; + for ($i = 1; $i <= $grid['columns']; $i++) { + $css .= $wrapper_selector . ' ' . $col_selector_prefix . $i . " {\n"; + if ($i == 1) { + // The first column does not yet have any margins. + $css .= ' width: ' . $colwidth * $i . $size_suffix . ";\n"; + } + elseif ($i == $grid['columns']) { + // The full width column always spans 100%. + $css .= " width: " . $grid['width'] . $size_suffix . ";\n margin-left: 0;\n"; + } + else { + // Other columns absorb all columns that they need to include and one + // less margin before them. + $css .= ' width: ' . (($colwidth * $i) + ($grid['gutter_width'] * ($i -1))) . $size_suffix . ";\n"; + } + $css .= "}\n"; + } + + return $css; + } + +} diff --git a/core/modules/layout/layout.info b/core/modules/layout/layout.info index 187bfea..d782ec5 100644 --- a/core/modules/layout/layout.info +++ b/core/modules/layout/layout.info @@ -3,3 +3,10 @@ description = Makes it possible to swap different page layouts. package = Core version = VERSION core = 8.x + + +; Information added by drush on 2012-11-09 +version = "" +project = "drupal" +datestamp = "1352493228" + diff --git a/core/modules/layout/layout.module b/core/modules/layout/layout.module index 7d82798..64d7714 100644 --- a/core/modules/layout/layout.module +++ b/core/modules/layout/layout.module @@ -23,11 +23,13 @@ function layout_manager() { function layout_theme($existing, $type, $theme, $path) { $items = array(); foreach (layout_manager()->getDefinitions() as $name => $layout) { - $items[$layout['theme']] = array( - 'variables' => array('content' => NULL), - 'path' => $layout['path'], - 'template' => $layout['template'], - ); + if (!empty($layout['theme'])) { + $items[$layout['theme']] = array( + 'variables' => array('content' => NULL), + 'path' => $layout['path'], + 'template' => $layout['template'], + ); + } } return $items; } diff --git a/core/modules/layout/tests/layout_test.info b/core/modules/layout/tests/layout_test.info index 7b054a9..f040552 100644 --- a/core/modules/layout/tests/layout_test.info +++ b/core/modules/layout/tests/layout_test.info @@ -4,3 +4,10 @@ package = Testing version = VERSION core = 8.x hidden = TRUE + + +; Information added by drush on 2012-11-09 +version = "" +project = "drupal" +datestamp = "1352493228" + diff --git a/core/modules/layout/tests/themes/layout_test_theme/layout_test_theme.info b/core/modules/layout/tests/themes/layout_test_theme/layout_test_theme.info index 84bcff0..2e845a9 100644 --- a/core/modules/layout/tests/themes/layout_test_theme/layout_test_theme.info +++ b/core/modules/layout/tests/themes/layout_test_theme/layout_test_theme.info @@ -2,3 +2,10 @@ name = Layout test theme description = Theme for testing the layout system core = 8.x hidden = TRUE + + +; Information added by drush on 2012-11-09 +version = "" +project = "drupal" +datestamp = "1352493228" + diff --git a/core/modules/page/config/page.front_page.yml b/core/modules/page/config/page.front_page.yml new file mode 100644 index 0000000..7562328 --- /dev/null +++ b/core/modules/page/config/page.front_page.yml @@ -0,0 +1,8 @@ +id: front_page +uuid: 5da81acf-3264-4d91-9b00-b2461c86e974 +label: 'Front page' +visibility: '1' +paths: '' +layout: 'static_layout:page__complex' +langcode: und +weight: 1 diff --git a/core/modules/page/config/page.not_admin_page.yml b/core/modules/page/config/page.not_admin_page.yml new file mode 100644 index 0000000..c7d1032 --- /dev/null +++ b/core/modules/page/config/page.not_admin_page.yml @@ -0,0 +1,8 @@ +id: not_admin_page +uuid: 45e82840-d11b-4726-8d09-9be84a69457d +label: 'Not admin page' +visibility: '0' +paths: "admin\r\nadmin/*" +layout: 'static_layout:page__simple' +langcode: und +weight: 10 diff --git a/core/modules/page/config/page.user_page.yml b/core/modules/page/config/page.user_page.yml new file mode 100644 index 0000000..ce86333 --- /dev/null +++ b/core/modules/page/config/page.user_page.yml @@ -0,0 +1,8 @@ +id: user_page +uuid: ccd213ff-54d4-4f3a-9a00-f8406842dff0 +label: 'User page' +visibility: '1' +paths: "user\r\nuser/*" +layout: 'static_layout:page__complex' +langcode: und +weight: 5 diff --git a/core/modules/page/layouts/static/complex/complex.yml b/core/modules/page/layouts/static/complex/complex.yml new file mode 100644 index 0000000..ec6491a --- /dev/null +++ b/core/modules/page/layouts/static/complex/complex.yml @@ -0,0 +1,2 @@ +title: Complex layout +template: complex diff --git a/core/modules/page/layouts/static/simple/simple.yml b/core/modules/page/layouts/static/simple/simple.yml new file mode 100644 index 0000000..3c395fa --- /dev/null +++ b/core/modules/page/layouts/static/simple/simple.yml @@ -0,0 +1,2 @@ +title: Simple layout +template: simple diff --git a/core/modules/page/lib/Drupal/page/Page.php b/core/modules/page/lib/Drupal/page/Page.php new file mode 100644 index 0000000..bfd835c --- /dev/null +++ b/core/modules/page/lib/Drupal/page/Page.php @@ -0,0 +1,66 @@ + 'textfield', + '#title' => t('Label'), + '#maxlength' => 255, + '#default_value' => $page->label(), + '#description' => t("Example: 'Front page' or 'Section page'."), + '#required' => TRUE, + ); + $form['id'] = array( + '#type' => 'machine_name', + '#default_value' => $page->id(), + '#machine_name' => array( + 'exists' => 'page_load', + 'source' => array('label'), + ), + '#disabled' => !$page->isNew(), + ); + + // Get list of layouts and expose that for page layout selection. + $layouts = drupal_container()->get('plugin.manager.layout')->getDefinitions(); + $layout_options = array(); + foreach ($layouts as $key => $layout) { + $layout_options[$key] = $layout['title']; + } + $form['layout'] = array( + '#type' => 'select', + '#title' => t('Layout for this page'), + '#default_value' => isset($page->layout) ? $page->layout : '', + '#options' => $layout_options, + ); + + // @todo this would ideally be pluggable and depend on general conditions + // and all, however, these are not yet abstracted. + $options = array( + 0 => t('All paths except those listed'), + 1 => t('Only the listed paths'), + ); + $description = t("Enter one path per line. The '*' character is a wildcard. Example paths are %user for the current user's page and %user-wildcard for every user page. %front is the front page.", array('%user' => 'user', '%user-wildcard' => 'user/*', '%front' => '')); + $form['visibility'] = array( + '#type' => 'radios', + '#title' => t('Apply to specific paths'), + '#options' => $options, + '#default_value' => isset($page->visibility) ? $page->visibility : 0, + ); + $form['paths'] = array( + '#type' => 'textarea', + '#title' => '' . t('Paths') . '', + '#default_value' => isset($page->paths) ? $page->paths : '', + '#description' => $description, + ); + + return parent::form($form, $form_state, $page); + } + + /** + * Overrides Drupal\Core\Entity\EntityFormController::actions(). + */ + protected function actions(array $form, array &$form_state) { + // Only includes a Save action for the entity, no direct Delete button. + return array( + 'submit' => array( + '#value' => t('Save'), + '#validate' => array( + array($this, 'validate'), + ), + '#submit' => array( + array($this, 'submit'), + array($this, 'save'), + ), + ), + ); + } + + /** + * Overrides Drupal\Core\Entity\EntityFormController::save(). + */ + public function save(array $form, array &$form_state) { + $page = $this->getEntity($form_state); + $page->save(); + + watchdog('page', 'Page @label saved.', array('@label' => $page->label()), WATCHDOG_NOTICE); + drupal_set_message(t('Page %label saved.', array('%label' => $page->label()))); + + $form_state['redirect'] = 'admin/structure/pages'; + } + +} + diff --git a/core/modules/page/lib/Drupal/page/PageListController.php b/core/modules/page/lib/Drupal/page/PageListController.php new file mode 100644 index 0000000..c3e14d9 --- /dev/null +++ b/core/modules/page/lib/Drupal/page/PageListController.php @@ -0,0 +1,71 @@ + TRUE, + ); + foreach ($this->load() as $entity) { + $form['items'][$entity->id()]['label'] = array( + '#markup' => check_plain($entity->label()), + ); + + $paths = nl2br(check_plain($entity->paths)); + if (empty($entity->visibility)) { + $paths = t('Except: !paths', array('!paths' => '
' . $paths)); + } + $form['items'][$entity->id()]['paths'] = array( + '#markup' => $paths, + ); + + $form['items'][$entity->id()]['weight'] = array( + '#type' => 'weight', + '#title' => t('Weight'), + '#default_value' => $entity->weight, + '#delta' => 100, + '#attributes' => array('class' => array('entity-weight')), + ); + + $form['items'][$entity->id()]['operations'] = array( + $this->buildOperations($entity), + ); + } + + $form['actions'] = array(); + $form['actions']['submit'] = array( + '#type' => 'submit', + '#value' => t('Save changes') + ); + return $form; + } + + /** + * Save weight changes to configuration entities. + */ + public function submitForm($form, &$form_state) { + foreach ($form_state['values']['items'] as $id => $item) { + $page = entity_load('page', $id); + $page->weight = $item['weight']; + $page->save(); + } + } + +} diff --git a/core/modules/page/page.admin.inc b/core/modules/page/page.admin.inc new file mode 100644 index 0000000..5ac414d --- /dev/null +++ b/core/modules/page/page.admin.inc @@ -0,0 +1,120 @@ +getForm($form, $form_state); +} + + +/** + * Form callback to save a tabledrag list. + */ +function page_page_list_form_submit($form, &$form_state) { + $controller = entity_list_controller('page'); + return $controller->submitForm($form, $form_state); +} + +/** + * Page callback: Presents the page editing form. + * + * @see page_menu() + */ +function page_page_edit(Page $page) { + drupal_set_title(t('Edit page @label', array('@label' => $page->label())), PASS_THROUGH); + return entity_get_form($page); +} + +/** + * Page callback: Provides the new page addition form. + * + * @see page_menu() + */ +function page_page_add() { + $page = entity_create('page', array()); + return entity_get_form($page); +} + +/** + * Page callback: Form constructor for page deletion confirmation form. + * + * @see page_menu() + */ +function page_delete_confirm($form, &$form_state, Page $page) { + // Always provide entity id in the same form key as in the entity edit form. + $form['id'] = array('#type' => 'value', '#value' => $page->id()); + $form_state['page'] = $page; + return confirm_form($form, + t('Are you sure you want to remove the page %title?', array('%title' => $page->label())), + 'admin/structure/pages', + t('This action cannot be undone.'), + t('Delete'), + t('Cancel') + ); +} + +/** + * Form submission handler for page_delete_confirm(). + */ +function page_delete_confirm_submit($form, &$form_state) { + $page = $form_state['page']; + $page->delete(); + drupal_set_message(t('Page %label has been deleted.', array('%label' => $page->label()))); + watchdog('page', 'Page %label has been deleted.', array('%label' => $page->label()), WATCHDOG_NOTICE); + $form_state['redirect'] = 'admin/structure/pages'; +} + +/** + * Theme callback for page listing form. + */ +function theme_page_page_list_form($variables) { + $form = $variables['form']; + $rows = array(); + + foreach (element_children($form['items'], TRUE) as $id) { + $rows[] = array( + 'data' => array( + drupal_render($form['items'][$id]['label']), + drupal_render($form['items'][$id]['paths']), + drupal_render($form['items'][$id]['weight']), + drupal_render($form['items'][$id]['operations']), + ), + 'class' => array('draggable'), + ); + } + + $header = array( + t('Label'), + t('Paths'), + t('Weight'), + t('Operations'), + ); + + $variables = array( + 'header' => $header, + 'rows' => $rows, + 'attributes' => array('id' => 'page-list'), + ); + $table = theme('table', $variables); + $table .= drupal_render_children($form); + drupal_add_tabledrag('page-list', 'order', 'sibling', 'entity-weight'); + return $table; +} diff --git a/core/modules/page/page.info b/core/modules/page/page.info new file mode 100644 index 0000000..69c051b --- /dev/null +++ b/core/modules/page/page.info @@ -0,0 +1,15 @@ +name = Page +description = Makes it possible to swap different page layouts. +package = Core +version = VERSION +core = 8.x +dependencies[] = config +dependencies[] = layout +configure = admin/structure/pages + + +; Information added by drush on 2012-11-09 +version = "" +project = "drupal" +datestamp = "1352493228" + diff --git a/core/modules/page/page.module b/core/modules/page/page.module new file mode 100644 index 0000000..695e493 --- /dev/null +++ b/core/modules/page/page.module @@ -0,0 +1,176 @@ + 'Page library', + 'description' => 'Manage pages using layouts that allow content to be placed.', + 'page callback' => 'page_page_list', + 'access callback' => 'user_access', + 'access arguments' => array('administer pages'), + 'file' => 'page.admin.inc', + ); + $items['admin/structure/pages/add'] = array( + 'title' => 'Add page', + 'page callback' => 'page_page_add', + 'access callback' => 'user_access', + 'access arguments' => array('administer pages'), + 'type' => MENU_LOCAL_ACTION, + 'file' => 'page.admin.inc', + ); + $items['admin/structure/pages/manage/%page'] = array( + 'title' => 'Edit page', + 'page callback' => 'page_page_edit', + 'page arguments' => array(4), + 'access callback' => 'user_access', + 'access arguments' => array('administer pages'), + 'type' => MENU_CALLBACK, + 'file' => 'page.admin.inc', + ); + $items['admin/structure/pages/manage/%page/edit'] = array( + 'title' => 'Edit', + 'type' => MENU_DEFAULT_LOCAL_TASK, + 'weight' => -10, + ); + $items['admin/structure/pages/manage/%page/delete'] = array( + 'title' => 'Delete', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('page_delete_confirm', 4), + 'access callback' => 'user_access', + 'access arguments' => array('administer pages'), + 'type' => MENU_LOCAL_TASK, + 'file' => 'page.admin.inc', + ); + return $items; +} + +/** + * Implements hook_permission(). + */ +function page_permission() { + return array( + 'administer pages' => array( + 'title' => t('Administer pages'), + 'description' => t('Manage the set of pages with distinct layouts on the site.'), + ), + ); +} + +/** + * @todo remove this in favor of actually integrating with layout mappers. + */ +function page_init() { + if ($page = page_get_matched_page()) { + drupal_set_message(t('%page matched, %layout to be used.', array('%page' => $page->label(), '%layout' => $page->layout))); + } +} + +/** + * API function to look up if the current page is matched by a config. + * + * @return Drupal\page\Page|FALSE + */ +function page_get_matched_page() { + $pages = page_load_all(); + $page_match = FALSE; + foreach ($pages as $page) { + if (!empty($page->paths)) { + // Convert paths to lowercase. This allows comparison of the same path + // with different case. Ex: /Page, /page, /PAGE. + $paths = drupal_strtolower($page->paths); + // Compare the lowercase path alias (if any) and internal path. + $path = current_path(); + $path_alias = drupal_strtolower(drupal_get_path_alias($path)); + $page_match = drupal_match_path($path_alias, $paths) || (($path != $path_alias) && drupal_match_path($path, $paths)); + // When $page->visibility has a value of 0, the page is used on all + // paths except those listed in $page->paths. When set to 1, it is + // used only on those pages listed in $page->paths. + $page_match = !($page->visibility xor $page_match); + if ($page_match) { + break; + } + } + } + return $page_match ? $page : FALSE; +} + +/** + * Implements hook_entity_info(). + */ +function page_entity_info() { + $types['page'] = array( + 'label' => 'Page', + 'entity class' => 'Drupal\page\Page', + 'controller class' => 'Drupal\Core\Config\Entity\ConfigStorageController', + 'form controller class' => array( + 'default' => 'Drupal\page\PageFormController', + ), + 'list controller class' => 'Drupal\page\PageListController', + 'list path' => 'admin/structure/pages', + 'uri callback' => 'page_uri', + 'config prefix' => 'page', + 'entity keys' => array( + 'id' => 'id', + 'label' => 'label', + 'uuid' => 'uuid', + ), + ); + return $types; +} + +/** + * Entity URI callback. + * + * @param Drupal\page\Page $page + * Page configuration entity instance. + * + * @return array + * Entity URI information. + */ +function page_uri(Page $page) { + return array( + 'path' => 'admin/structure/pages/manage/' . $page->id(), + ); +} + +/** + * Load one page object by its identifier. + * + * @return Drupal\page\Page + * Page configuration entity instance. + */ +function page_load($id) { + return entity_load('page', $id); +} + +/** + * Load all page objects. + * + * @return array + * List of Drupal\page\Page instances keyed by id. + */ +function page_load_all() { + return entity_load_multiple('page'); +} + +/** + * Implements hook_theme(). + */ +function page_theme($existing, $type, $theme, $path) { + return array( + 'page_page_list_form' => array( + 'render element' => 'form', + 'file' => 'page.admin.inc', + ), + ); +} diff --git a/core/modules/region/config/region.body.yml b/core/modules/region/config/region.body.yml new file mode 100644 index 0000000..1b06f89 --- /dev/null +++ b/core/modules/region/config/region.body.yml @@ -0,0 +1,2 @@ +id: body +label: Body diff --git a/core/modules/region/config/region.footer_a.yml b/core/modules/region/config/region.footer_a.yml new file mode 100644 index 0000000..e3f611e --- /dev/null +++ b/core/modules/region/config/region.footer_a.yml @@ -0,0 +1,2 @@ +id: footer_a +label: Footer A diff --git a/core/modules/region/config/region.footer_b.yml b/core/modules/region/config/region.footer_b.yml new file mode 100644 index 0000000..0f04323 --- /dev/null +++ b/core/modules/region/config/region.footer_b.yml @@ -0,0 +1,2 @@ +id: footer_b +label: Footer B diff --git a/core/modules/region/config/region.footer_c.yml b/core/modules/region/config/region.footer_c.yml new file mode 100644 index 0000000..2f9dbe5 --- /dev/null +++ b/core/modules/region/config/region.footer_c.yml @@ -0,0 +1,2 @@ +id: footer_c +label: Footer C diff --git a/core/modules/region/config/region.header_a.yml b/core/modules/region/config/region.header_a.yml new file mode 100644 index 0000000..c3867f3 --- /dev/null +++ b/core/modules/region/config/region.header_a.yml @@ -0,0 +1,2 @@ +id: header_a +label: Header A diff --git a/core/modules/region/config/region.header_b.yml b/core/modules/region/config/region.header_b.yml new file mode 100644 index 0000000..d91fe82 --- /dev/null +++ b/core/modules/region/config/region.header_b.yml @@ -0,0 +1,2 @@ +id: header_b +label: Header B diff --git a/core/modules/region/config/region.header_c.yml b/core/modules/region/config/region.header_c.yml new file mode 100644 index 0000000..204ab21 --- /dev/null +++ b/core/modules/region/config/region.header_c.yml @@ -0,0 +1,2 @@ +id: header_c +label: Header C diff --git a/core/modules/region/config/region.navigation.yml b/core/modules/region/config/region.navigation.yml new file mode 100644 index 0000000..2f7afff --- /dev/null +++ b/core/modules/region/config/region.navigation.yml @@ -0,0 +1,2 @@ +id: navigation +label: Navigation diff --git a/core/modules/region/config/region.sidebar_a.yml b/core/modules/region/config/region.sidebar_a.yml new file mode 100644 index 0000000..7c27f3f --- /dev/null +++ b/core/modules/region/config/region.sidebar_a.yml @@ -0,0 +1,2 @@ +id: sidebar_a +label: Sidebar A diff --git a/core/modules/region/config/region.sidebar_b.yml b/core/modules/region/config/region.sidebar_b.yml new file mode 100644 index 0000000..e5a8e03 --- /dev/null +++ b/core/modules/region/config/region.sidebar_b.yml @@ -0,0 +1,2 @@ +id: sidebar_b +label: Sidebar B diff --git a/core/modules/region/config/region.sidebar_c.yml b/core/modules/region/config/region.sidebar_c.yml new file mode 100644 index 0000000..00c9bc9 --- /dev/null +++ b/core/modules/region/config/region.sidebar_c.yml @@ -0,0 +1,2 @@ +id: sidebar_c +label: Sidebar C diff --git a/core/modules/region/config/region.subheader_a.yml b/core/modules/region/config/region.subheader_a.yml new file mode 100644 index 0000000..db7685c --- /dev/null +++ b/core/modules/region/config/region.subheader_a.yml @@ -0,0 +1,2 @@ +id: subheader_a +label: Subheader A diff --git a/core/modules/region/config/region.subheader_b.yml b/core/modules/region/config/region.subheader_b.yml new file mode 100644 index 0000000..269a100 --- /dev/null +++ b/core/modules/region/config/region.subheader_b.yml @@ -0,0 +1,2 @@ +id: subheader_b +label: Subheader B diff --git a/core/modules/region/config/region.subheader_c.yml b/core/modules/region/config/region.subheader_c.yml new file mode 100644 index 0000000..0149b78 --- /dev/null +++ b/core/modules/region/config/region.subheader_c.yml @@ -0,0 +1,2 @@ +id: subheader_c +label: Subheader C diff --git a/core/modules/region/config/region.title.yml b/core/modules/region/config/region.title.yml new file mode 100644 index 0000000..aa36188 --- /dev/null +++ b/core/modules/region/config/region.title.yml @@ -0,0 +1,2 @@ +id: title +label: Title diff --git a/core/modules/region/lib/Drupal/region/Region.php b/core/modules/region/lib/Drupal/region/Region.php new file mode 100644 index 0000000..d883303 --- /dev/null +++ b/core/modules/region/lib/Drupal/region/Region.php @@ -0,0 +1,38 @@ + 'textfield', + '#title' => t('Label'), + '#maxlength' => 255, + '#default_value' => $region->label(), + '#description' => t("Example: 'Banner' or 'Highlight'."), + '#required' => TRUE, + ); + $form['id'] = array( + '#type' => 'machine_name', + '#default_value' => $region->id(), + '#machine_name' => array( + 'exists' => 'region_load', + 'source' => array('label'), + ), + '#disabled' => !$region->isNew(), + ); + return parent::form($form, $form_state, $region); + } + + /** + * Overrides Drupal\Core\Entity\EntityFormController::actions(). + */ + protected function actions(array $form, array &$form_state) { + // Only includes a Save action for the entity, no direct Delete button. + return array( + 'submit' => array( + '#value' => t('Save'), + '#validate' => array( + array($this, 'validate'), + ), + '#submit' => array( + array($this, 'submit'), + array($this, 'save'), + ), + ), + ); + } + + /** + * Overrides Drupal\Core\Entity\EntityFormController::save(). + */ + public function save(array $form, array &$form_state) { + $region = $this->getEntity($form_state); + $region->save(); + + watchdog('region', 'Region @label saved.', array('@label' => $region->label()), WATCHDOG_NOTICE); + drupal_set_message(t('Region %label saved.', array('%label' => $region->label()))); + + $form_state['redirect'] = 'admin/structure/regions'; + } + +} + diff --git a/core/modules/region/lib/Drupal/region/Tests/RegionTest.php b/core/modules/region/lib/Drupal/region/Tests/RegionTest.php new file mode 100644 index 0000000..981641e --- /dev/null +++ b/core/modules/region/lib/Drupal/region/Tests/RegionTest.php @@ -0,0 +1,141 @@ + 'Region management', + 'description' => 'Tests region management.', + 'group' => 'Region', + ); + } + + /** + * Tests the default regions. + */ + public function testDefaultRegions() { + // Create a new user, allow him to manage the blocks and the languages. + $admin_user = $this->drupalCreateUser(array( + 'administer regions', + )); + $this->drupalLogin($admin_user); + + // Check that these regions show up on the user interface. + $base_regions = array( + 'header_a' => 'Header A', + 'header_b' => 'Header B', + 'header_c' => 'Header C', + 'subheader_a' => 'Subheader A', + 'subheader_b' => 'Subheader B', + 'subheader_c' => 'Subheader C', + 'navigation' => 'Navigation', + 'title' => 'Title', + 'body' => 'Body', + 'sidebar_a' => 'Sidebar A', + 'sidebar_b' => 'Sidebar B', + 'sidebar_c' => 'Sidebar C', + 'footer_a' => 'Footer A', + 'footer_b' => 'Footer B', + 'footer_c' => 'Footer C', + ); + + // Check if the visibility setting is available. + $this->drupalGet('admin/structure/regions'); + foreach($base_regions as $machine_name => $label) { + $this->assertText($machine_name); + $this->assertText($label); + } + } + + /** + * Tests editing a default region. + */ + public function testEditDefaultRegion() { + // Create a new user, allow him to manage the blocks and the languages. + $admin_user = $this->drupalCreateUser(array( + 'administer regions', + )); + $this->drupalLogin($admin_user); + + $this->drupalGet('admin/structure/regions/manage/body/edit'); + $this->assertResponse(200); + $this->assertPattern('!disabled="disabled"(.+)id="edit-id"(.+)value="body"!', 'Existing region name machine name field is disabled.'); + + $edit = array('label' => 'Page content'); + $this->drupalPost('admin/structure/regions/manage/body/edit', $edit, t('Save')); + $this->assertText('Page content'); + $this->assertNoText('Body'); + $this->assertRaw(t('Region %label saved.', array('%label' => 'Page content'))); + } + + /** + * Tests editing a default region. + */ + public function testDeleteDefaultRegion() { + // Create a new user, allow him to manage the blocks and the languages. + $admin_user = $this->drupalCreateUser(array( + 'administer regions', + )); + $this->drupalLogin($admin_user); + + $this->drupalGet('admin/structure/regions/manage/body/delete'); + $this->assertResponse(200); + + $this->drupalPost('admin/structure/regions/manage/body/delete', array(), t('Delete')); + $this->assertRaw(t('Region %label has been deleted.', array('%label' => 'Body'))); + $this->assertNoText('body'); + } + + /** + * Tests adding a new region and all actions on that. + */ + public function testNewRegion() { + // Create a new user, allow him to manage the blocks and the languages. + $admin_user = $this->drupalCreateUser(array( + 'administer regions', + )); + $this->drupalLogin($admin_user); + + $edit = array('label' => 'Banner', 'id' => 'banner'); + $this->drupalPost('admin/structure/regions/add', $edit, t('Save')); + $this->assertText('banner'); + $this->assertRaw(t('Region %label saved.', array('%label' => 'Banner'))); + + $edit = array('label' => 'Highlight'); + $this->drupalPost('admin/structure/regions/manage/banner/edit', $edit, t('Save')); + $this->assertNoText('Banner'); + $this->assertText('banner'); + $this->assertRaw(t('Region %label saved.', array('%label' => 'Highlight'))); + + $edit = array('label' => 'Conflicting banner', 'id' => 'banner'); + $this->drupalPost('admin/structure/regions/add', $edit, t('Save')); + $this->assertText(t('The machine-readable name is already in use. It must be unique.')); + + $this->drupalGet('admin/structure/regions/manage/banner/edit'); + $this->assertPattern('!disabled="disabled"(.+)id="edit-id"(.+)value="banner"!', 'Existing region name machine name field is disabled.'); + + $this->drupalPost('admin/structure/regions/manage/banner/delete', array(), t('Delete')); + $this->assertRaw(t('Region %label has been deleted.', array('%label' => 'Highlight'))); + $this->assertNoText('banner'); + } + +} diff --git a/core/modules/region/region.admin.inc b/core/modules/region/region.admin.inc new file mode 100644 index 0000000..1429ba9 --- /dev/null +++ b/core/modules/region/region.admin.inc @@ -0,0 +1,67 @@ +render(); +} + +/** + * Page callback: Presents the region editing form. + * + * @see region_menu() + */ +function region_page_edit(Region $region) { + drupal_set_title(t('Edit region @label', array('@label' => $region->label())), PASS_THROUGH); + return entity_get_form($region); +} + +/** + * Page callback: Provides the new region addition form. + * + * @see region_menu() + */ +function region_page_add() { + $region = entity_create('region', array()); + return entity_get_form($region); +} + +/** + * Page callback: Form constructor for region deletion confirmation form. + * + * @see region_menu() + */ +function region_delete_confirm($form, &$form_state, Region $region) { + // Always provide entity id in the same form key as in the entity edit form. + $form['id'] = array('#type' => 'value', '#value' => $region->id()); + $form_state['region'] = $region; + return confirm_form($form, + t('Are you sure you want to remove the region %title?', array('%title' => $region->label())), + 'admin/structure/regions', + t('This action cannot be undone.'), + t('Delete'), + t('Cancel') + ); +} + +/** + * Form submission handler for region_delete_confirm(). + */ +function region_delete_confirm_submit($form, &$form_state) { + $region = $form_state['region']; + $region->delete(); + drupal_set_message(t('Region %label has been deleted.', array('%label' => $region->label()))); + watchdog('region', 'Region %label has been deleted.', array('%label' => $region->label()), WATCHDOG_NOTICE); + $form_state['redirect'] = 'admin/structure/regions'; +} diff --git a/core/modules/region/region.info b/core/modules/region/region.info new file mode 100644 index 0000000..e277443 --- /dev/null +++ b/core/modules/region/region.info @@ -0,0 +1,14 @@ +name = Region +description = Maintains a common set of regions available to layouts. +package = Core +version = VERSION +core = 8.x +dependencies[] = config +configure = admin/structure/regions + + +; Information added by drush on 2012-11-09 +version = "" +project = "drupal" +datestamp = "1352493228" + diff --git a/core/modules/region/region.module b/core/modules/region/region.module new file mode 100644 index 0000000..8bf35c7 --- /dev/null +++ b/core/modules/region/region.module @@ -0,0 +1,126 @@ + 'Regions', + 'description' => 'Manage list of regions that allow content to be placed.', + 'page callback' => 'region_page_list', + 'access callback' => 'user_access', + 'access arguments' => array('administer regions'), + 'file' => 'region.admin.inc', + ); + $items['admin/structure/regions/add'] = array( + 'title' => 'Add region', + 'page callback' => 'region_page_add', + 'access callback' => 'user_access', + 'access arguments' => array('administer regions'), + 'type' => MENU_LOCAL_ACTION, + 'file' => 'region.admin.inc', + ); + $items['admin/structure/regions/manage/%region'] = array( + 'title' => 'Edit region', + 'page callback' => 'region_page_edit', + 'page arguments' => array(4), + 'access callback' => 'user_access', + 'access arguments' => array('administer regions'), + 'type' => MENU_CALLBACK, + 'file' => 'region.admin.inc', + ); + $items['admin/structure/regions/manage/%region/edit'] = array( + 'title' => 'Edit', + 'type' => MENU_DEFAULT_LOCAL_TASK, + 'weight' => -100, + ); + $items['admin/structure/regions/manage/%region/delete'] = array( + 'title' => 'Delete', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('region_delete_confirm', 4), + 'access callback' => 'user_access', + 'access arguments' => array('administer regions'), + 'type' => MENU_LOCAL_TASK, + 'file' => 'region.admin.inc', + ); + return $items; +} + +/** + * Implements hook_permission(). + */ +function region_permission() { + return array( + 'administer regions' => array( + 'title' => t('Administer regions'), + 'description' => t('Manage list of regions available on the site.'), + ), + ); +} + +/** + * Implements hook_entity_info(). + */ +function region_entity_info() { + $types['region'] = array( + 'label' => 'Region', + 'entity class' => 'Drupal\region\Region', + 'controller class' => 'Drupal\Core\Config\Entity\ConfigStorageController', + 'form controller class' => array( + 'default' => 'Drupal\region\RegionFormController', + ), + 'list controller class' => 'Drupal\Core\Config\Entity\ConfigEntityListController', + 'list path' => 'admin/structure/regions', + 'uri callback' => 'region_uri', + 'config prefix' => 'region', + 'entity keys' => array( + 'id' => 'id', + 'label' => 'label', + 'uuid' => 'uuid', + ), + ); + return $types; +} + +/** + * Entity URI callback. + * + * @param Drupal\region\Region $region + * Region configuration entity instance. + * + * @return array + * Entity URI information. + */ +function region_uri(Region $region) { + return array( + 'path' => 'admin/structure/regions/manage/' . $region->id(), + ); +} + +/** + * Load one region object by its identifier. + * + * @return Drupal\region\Region + * Region configuration entity instance. + */ +function region_load($id) { + return entity_load('region', $id); +} + +/** + * Load all region objects. + * + * @return array + * List of Drupal\region\Region instances keyed by id. + */ +function region_load_all() { + return entity_load_multiple('region'); +} diff --git a/core/modules/rlayout/config/grid.six_column_fluid_tablet.yml b/core/modules/rlayout/config/grid.six_column_fluid_tablet.yml new file mode 100644 index 0000000..744496e --- /dev/null +++ b/core/modules/rlayout/config/grid.six_column_fluid_tablet.yml @@ -0,0 +1,12 @@ +id: six_column_fluid_tablet +label: Six column fluid +type: equal_column +options: + type: 'fluid' + width: 100 + columns: 6 + padding_width: 1.5 + gutter_width: 2 + breakpoints: + - 'module.rlayout.tablet' + diff --git a/core/modules/rlayout/config/grid.three_column_fluid_smartphone.yml b/core/modules/rlayout/config/grid.three_column_fluid_smartphone.yml new file mode 100644 index 0000000..a5077bf --- /dev/null +++ b/core/modules/rlayout/config/grid.three_column_fluid_smartphone.yml @@ -0,0 +1,12 @@ +id: three_column_fluid_smartphone +label: Three column fluid +type: equal_column +options: + type: 'fluid' + width: 100 + columns: 3 + padding_width: 1.5 + gutter_width: 2 + breakpoints: + - 'module.rlayout.smartphone' + diff --git a/core/modules/rlayout/config/grid.twelve_column_fluid_standard.yml b/core/modules/rlayout/config/grid.twelve_column_fluid_standard.yml new file mode 100644 index 0000000..ef98884 --- /dev/null +++ b/core/modules/rlayout/config/grid.twelve_column_fluid_standard.yml @@ -0,0 +1,12 @@ +id: twelve_column_fluid_standard +label: Twelve column fluid +type: equal_column +options: + type: 'fluid' + width: 100 + columns: 12 + padding_width: 1.5 + gutter_width: 2 + breakpoints: + - 'module.rlayout.standard' + diff --git a/core/modules/rlayout/config/rlayout.breakpoints.yml b/core/modules/rlayout/config/rlayout.breakpoints.yml new file mode 100644 index 0000000..d8f354c --- /dev/null +++ b/core/modules/rlayout/config/rlayout.breakpoints.yml @@ -0,0 +1,3 @@ +smartphone: '(min-width: 0px)' +tablet: 'all and (min-width: 321px) and (max-width: 760px)' +standard: 'all and (min-width: 761px)' diff --git a/core/modules/rlayout/config/rlayoutset.default.yml b/core/modules/rlayout/config/rlayoutset.default.yml new file mode 100644 index 0000000..292e361 --- /dev/null +++ b/core/modules/rlayout/config/rlayoutset.default.yml @@ -0,0 +1,19 @@ +id: default +label: Default layout +regions: + - header_a + - header_b + - header_c + - subheader_a + - subheader_b + - subheader_c + - navigation + - title + - body + - sidebar_a + - sidebar_b + - sidebar_c + - footer_a + - footer_b + - footer_c +overrides: diff --git a/core/modules/rlayout/designer/app/libs/Grid/Grid.js b/core/modules/rlayout/designer/app/libs/Grid/Grid.js new file mode 100644 index 0000000..ff7b42a --- /dev/null +++ b/core/modules/rlayout/designer/app/libs/Grid/Grid.js @@ -0,0 +1,25 @@ +(function (RLD, $) { + + RLD['Grid'] = (function () { + + var plugin = 'Grid'; + + function Grid() { + // Initialize the object. + this.init.apply(this, arguments); + } + /** + * Extend the InitClass Object. + */ + Grid.prototype = new RLD.InitClass(); + /** + * + */ + Grid.prototype.setup = function () { + + }; + + return Grid; + + }()); +}(ResponsiveLayoutDesigner, jQuery)); \ No newline at end of file diff --git a/core/modules/rlayout/designer/app/libs/GridList/GridList.js b/core/modules/rlayout/designer/app/libs/GridList/GridList.js new file mode 100644 index 0000000..2f039d8 --- /dev/null +++ b/core/modules/rlayout/designer/app/libs/GridList/GridList.js @@ -0,0 +1,58 @@ +(function (RLD, $) { + // Temp location. + RLD['GridList'] = (function () { + + var plugin = 'GridList'; + + function GridList() { + this.items = []; + // Initialize the object. + this.init.apply(this, arguments); + } + /** + * Extend the InitClass Object. + */ + GridList.prototype = new RLD.InitClass(); + /** + * + */ + GridList.prototype.setup = function () { + // Process list items. + if ('grids' in this) { + this.processList(this.grids); + delete this.grids; + } + else { + this.log('[RLD | ' + plugin + '] The list has no items at setup.'); + } + }; + /** + * + */ + GridList.prototype.build = function () { + return this.$editor; + }; + /** + * + */ + GridList.prototype.processList = function (items) { + var i; + for (i = 0; i < items.length; i++) { + this.items.push(new RLD.Grid({ + 'machine_name': items[i].machine_name, + 'columns': items[i].columns, + 'classes': items[i].classes + })); + } + }; + /** + * + */ + GridList.prototype.update = function (type, list) { + this.items = type; + }; + + return GridList; + + }()); +}(ResponsiveLayoutDesigner, jQuery)); diff --git a/core/modules/rlayout/designer/app/libs/LayoutList/LayoutList.js b/core/modules/rlayout/designer/app/libs/LayoutList/LayoutList.js new file mode 100644 index 0000000..fa81b04 --- /dev/null +++ b/core/modules/rlayout/designer/app/libs/LayoutList/LayoutList.js @@ -0,0 +1,72 @@ +(function (RLD, $) { + // Temp location. + RLD['LayoutList'] = (function () { + + var plugin = 'LayoutList'; + + function LayoutList() { + this.items = []; + // Initialize the object. + this.init.apply(this, arguments); + } + /** + * Extend the InitClass Object. + */ + LayoutList.prototype = new RLD.InitClass(); + /** + * + */ + LayoutList.prototype.setup = function () { + // Process list items. + if ('layouts' in this) { + this.processList(this.layouts); + delete this.layouts; + } + else { + this.log('[RLD | ' + plugin + '] The list has no items at setup.'); + } + }; + /** + * + */ + LayoutList.prototype.processList = function (items) { + // The broadcaster just pipes events through. + var handlers = {}; + var newSet = []; + var i, layoutStep, listener, fn; + // Create obects for each composite. + for (i = 0; i < items.length; i++) { + // Save the layout elements into a unit. + layoutStep = new RLD.LayoutStep({ + 'regionList': items[i].regionList, + 'step': items[i].step, + 'grid': items[i].grid + }); + // Pust the layoutStep into the list. + this.items.push(layoutStep); + newSet.push(layoutStep); + + } + // Register pass-through topics. + this.transferSubscriptions(this.items); + // Return the items that were added. + return newSet; + }; + /** + * + */ + LayoutList.prototype.addItem = function (layout) { + var items = this.processList([layout]); + return items; + } + /** + * + */ + LayoutList.prototype.update = function (type, list) { + this.items = list; + }; + + return LayoutList; + + }()); +}(ResponsiveLayoutDesigner, jQuery)); diff --git a/core/modules/rlayout/designer/app/libs/LayoutManager/LayoutManager.js b/core/modules/rlayout/designer/app/libs/LayoutManager/LayoutManager.js new file mode 100644 index 0000000..b7e3456 --- /dev/null +++ b/core/modules/rlayout/designer/app/libs/LayoutManager/LayoutManager.js @@ -0,0 +1,426 @@ +(function (RLD, $) { + /** + * LayoutManager editor provides functionality to display, add and remove + * layout representations across arbitrary, user-defined breakpoint limits. + */ + RLD['LayoutManager'] = (function build() { + + var plugin = 'LayoutManager'; + + function LayoutManager() { + // Ui components. + this.options = { + 'ui': { + 'class-layout': 'rld-stepmanager', + 'class-layout-tabs': 'rld-steps', + 'class-layout-content': 'rld-layouts' + } + }; + this.$editor = $(); + this.$stepSelector = $(); + this.$steps = $(); + this.$layouts = $(); + this.activeLayoutStep; + // Setup + this.init.apply(this, arguments); + } + /** + * Extend the InitClass Object. + */ + LayoutManager.prototype = new RLD.InitClass(); + /** + * Integrate instantiation options. + */ + LayoutManager.prototype.setup = function () { + var fn, steps; + // Instantiate classes. + this.stepManager = new RLD.StepManager(); + this.layoutList = new RLD.LayoutList(); + // Define topics that will pass-through. + this.topic('regionOrderUpdated'); + this.topic('layoutSaved'); + this.topic('regionResized'); + this.topic('regionResizing'); + this.topic('regionResizeStarted'); + // Transfer pass-through subscriptions. + this.transferSubscriptions([ + this.stepManager, + this.regionList, + this.layoutList + ]); + // Register for events on the stepManager. + fn = $.proxy(this.switchStep, this); + this.stepManager.topic('stepActivated').subscribe(fn); + // Register for events on the regionList. + fn = $.proxy(this.insertRegion, this); + this.regionList.topic('regionAdded').subscribe(fn); + fn = $.proxy(this.removeRegion, this); + this.regionList.topic('regionRemoved').subscribe(fn); + // Register for events on the layoutList + fn = $.proxy(this.requestRegionRemove, this); + this.layoutList.topic('regionRemoved').subscribe(fn); + // Assemble the editor managers and containers. + this.$stepSelector = $('
', { + 'class': this.ui['class-layout'] + }); + this.$steps = $('
    ', { + 'class': this.ui['class-layout-tabs'] + }); + this.$layouts = $('
    ', { + 'class': this.ui['class-layout-content'] + }); + // Register Layouts into the layoutList + // For every step we'll register a layout. + steps = this.stepList.info('items'); + // Create obects for each composite. + for (i = 0; i < steps.length; i++) { + // Save the composition elements into a unit. + this.registerLayoutStep(steps[i]); + } + }; + /** + * + */ + LayoutManager.prototype.build = function () { + // Assemble the editor fraemwork. + this.$editor = $('
    ', { + 'class': 'rld-layout-manager' + }) + .append( + this.$stepSelector + .append( + this.stepManager.build(this.$steps) + ) + ) + .append( + this.$layouts + .append( + $('
    ', { + 'class': 'rld-screen clearfix', + }) + ) + ); + /*this.$editor + .delegate('button.save', 'click.ResponsiveLayoutDesigner', {'type': 'save'}, this.update); */ + return this.$editor; + }; + /** + * A layout is a set of regions, in the context of a step, laid out on a grid. + */ + LayoutManager.prototype.registerLayoutStep = function (step) { + // Add the LayoutSteps to the LayoutList. + this.layoutList.addItem({ + 'step': step, + 'regionList': this.regionList, + 'grid': this.gridList.getItem(step.grid.info('machine_name')) + }); + // Add the Step to the StepManager. + this.stepManager.addItem(step); + }; + /** + * + */ + LayoutManager.prototype.switchStep = function (event, step) { + var args = arguments; + var id = this.stepManager.info('activeStep').info('breakpoint'); + var $screen = this.$layouts.find('.rld-screen'); + var $layout = $('
    ', { + 'class': 'rld-layout' + }); + var layout = this.getActiveLayout(); + var i, grid, gridColumns, gridClasses; + // Clear out the current screen. + $screen.children('.rld-layout').hide(0, function () { + $(this).remove(); + }); + grid = layout.info('grid'); + gridColumns = grid.info('columns'); + gridClasses = grid.info('classes') || []; + if (gridClasses.length > 0) { + $screen.addClass(); + } + $screen.animate({ + width: layout.step.info('size') + }); + // Append the frame to the screen. + $screen + .append( + $layout + .empty() + .addClass('rld-container-' + gridColumns) + .append(this.buildAddRegionButton('top')) + .append(this.buildGridUnderlay(gridColumns)) + .append(layout.build()) + .append(this.buildAddRegionButton('bottom')) + ); + + this.topic('stepActivated').publish(step); + }; + /** + * + */ + LayoutManager.prototype.getActiveLayout = function () { + var activeStep = this.stepManager.info('activeStep'); + var layout; + for (i = 0; i < this.layoutList.info('items').length; i++) { + layout = this.layoutList.info('items')[i]; + if (layout.step.info('machine_name') === activeStep.info('machine_name')) { + return layout; + } + } + }; + /** + * + */ + LayoutManager.prototype.buildGridUnderlay = function (columns, height) { + var $overlay = $('
    ', { + 'class': 'rld-grid-underlay clearfix' + }); + var cols = Number(columns); + var fn; + while (cols) { + $overlay.append( + $('
    ', { + 'class': 'rld-span_1 rld-col rld-grid-col' + }) + ); + cols -= 1; + } + return $overlay; + }; + /** + * + */ + LayoutManager.prototype.buildAddRegionButton = function (location) { + var handler = $.proxy(this.addRegionHandler, this); + var $controls = $('
    ', { + 'class': 'rld-layoutstep-controls' + ' ' + location + }) + .append( + $('