public function testThemeGridAreaLayoutContainer()
 {
     $layout = \Concrete\Core\Area\Layout\ThemeGridLayout::add();
     $layout->addLayoutColumn()->setAreaLayoutColumnSpan(4);
     $column = $layout->addLayoutColumn();
     $column->setAreaLayoutColumnSpan(2);
     $column->setAreaLayoutColumnOffset(2);
     $layout->addLayoutColumn()->setAreaLayoutColumnSpan(6);
     $elemental = \Concrete\Core\Page\Theme\Theme::add('elemental');
     Page::addHomePage();
     Core::make('cache/request')->disable();
     $c = Page::getByID(1);
     $c->setTheme($elemental);
     $c = Page::getByID(1);
     $req = Request::getInstance();
     $req->setCurrentPage($c);
     $layout = \Concrete\Core\Area\Layout\Layout::getByID(1);
     $this->assertInstanceOf('\\Concrete\\Core\\Area\\Layout\\ThemeGridLayout', $layout);
     $columns = $layout->getAreaLayoutColumns();
     $this->assertEquals(3, count($columns));
     $formatter = $layout->getFormatter();
     $this->assertInstanceOf('\\Concrete\\Core\\Area\\Layout\\Formatter\\ThemeGridFormatter', $formatter);
     $this->assertEquals('<div class="row"></div>', (string) $formatter->getLayoutContainerHtmlObject());
     $req->clearCurrentPage();
 }
 /**
  * @param ThemeGridAreaLayout $layout
  */
 public function publish(AreaLayout $layout)
 {
     $arLayout = ThemeGridLayout::add();
     foreach ($layout->getColumns() as $column) {
         /*
          * @var $column ThemeGridAreaLayoutColumn
          */
         $columnObject = $arLayout->addLayoutColumn();
         $columnObject->setAreaLayoutColumnSpan($column->getSpan());
         $columnObject->setAreaLayoutColumnOffset($column->getOffset());
     }
     return $arLayout;
 }
Beispiel #3
0
 public function addFromPost($post)
 {
     // we are adding a new layout
     switch ($post['gridType']) {
         case 'TG':
             $arLayout = ThemeGridAreaLayout::add();
             $arLayout->setAreaLayoutMaxColumns($post['arLayoutMaxColumns']);
             for ($i = 0; $i < $post['themeGridColumns']; $i++) {
                 $span = $post['span'][$i] ? $post['span'][$i] : 0;
                 $offset = $post['offset'][$i] ? $post['offset'][$i] : 0;
                 $column = $arLayout->addLayoutColumn();
                 $column->setAreaLayoutColumnSpan($span);
                 $column->setAreaLayoutColumnOffset($offset);
             }
             break;
         case 'FF':
             if (!$post['isautomated'] && $post['columns'] > 1) {
                 $iscustom = 1;
             } else {
                 $iscustom = 0;
             }
             $arLayout = CustomAreaLayout::add($post['spacing'], $iscustom);
             for ($i = 0; $i < $post['columns']; $i++) {
                 $width = $post['width'][$i] ? $post['width'][$i] : 0;
                 $column = $arLayout->addLayoutColumn();
                 $column->setAreaLayoutColumnWidth($width);
             }
             break;
         default:
             // a preset
             $arLayoutPreset = AreaLayoutPreset::getByID($post['gridType']);
             $arLayout = $arLayoutPreset->getAreaLayoutObject();
             $arLayout = $arLayout->duplicate();
             break;
     }
     return $arLayout;
 }
 public function testSavedGridPresets()
 {
     $layout = \Concrete\Core\Area\Layout\ThemeGridLayout::add();
     $layout->addLayoutColumn()->setAreaLayoutColumnSpan(4);
     $column = $layout->addLayoutColumn();
     $column->setAreaLayoutColumnSpan(2);
     $column->setAreaLayoutColumnOffset(2);
     $layout->addLayoutColumn()->setAreaLayoutColumnSpan(6);
     $preset1 = \Concrete\Core\Area\Layout\Preset\UserPreset::add($layout, 'Custom Preset');
     /** @var $manager \Concrete\Core\Area\Layout\Preset\Provider\Manager */
     $manager = Core::make('manager/area_layout_preset_provider');
     $elemental = \Concrete\Core\Page\Theme\Theme::add('elemental');
     Core::make('cache/request')->disable();
     $c = Page::getByID(1);
     $c->setTheme($elemental);
     $c = Page::getByID(1);
     $req = Request::getInstance();
     $req->setCurrentPage($c);
     $presets = $manager->getPresets();
     $this->assertEquals(1, count($presets));
     $c = Page::getCurrentPage();
     $this->assertEquals('Custom Preset', $presets[0]->getName());
     $this->assertInstanceOf('\\Concrete\\Core\\Area\\Layout\\Preset\\Preset', $presets[0]);
     $columns = $presets[0]->getColumns();
     $this->assertEquals('<div class="col-sm-4"></div>', (string) $columns[0]->getColumnHtmlObject());
     $this->assertEquals('<div class="col-sm-2 col-sm-offset-2"></div>', (string) $columns[1]->getColumnHtmlObject());
     $this->assertEquals('<div class="col-sm-6"></div>', (string) $columns[2]->getColumnHtmlObject());
     $req->clearCurrentPage();
 }