예제 #1
0
파일: Layout.php 프로젝트: ngreimel/kovent
 /**
  * @param int $arLayoutID
  * @return CustomLayout|ThemeGridLayout|null
  */
 public static function getByID($arLayoutID)
 {
     $db = Loader::db();
     $row = $db->GetRow('select arLayoutID, arLayoutUsesThemeGridFramework from AreaLayouts where arLayoutID = ?', array($arLayoutID));
     if (is_array($row) && $row['arLayoutID']) {
         if ($row['arLayoutUsesThemeGridFramework']) {
             $al = new ThemeGridLayout();
         } else {
             $al = new CustomLayout();
         }
         $al->setPropertiesFromArray($row);
         $al->arLayoutNumColumns = $db->GetOne('select count(arLayoutColumnID) as totalColumns from AreaLayoutColumns where arLayoutID = ?', array($arLayoutID));
         $al->loadDetails();
         return $al;
     }
 }
예제 #2
0
파일: Layout.php 프로젝트: ceko/concrete5-1
 /**
  * @param int $arLayoutID
  *
  * @return CustomLayout|ThemeGridLayout|null
  */
 public static function getByID($arLayoutID)
 {
     $db = Database::connection();
     $row = $db->GetRow('select arLayoutID, arLayoutIsPreset, arLayoutUsesThemeGridFramework from AreaLayouts where arLayoutID = ?', array($arLayoutID));
     if (is_array($row) && $row['arLayoutID']) {
         if ($row['arLayoutUsesThemeGridFramework']) {
             $al = new ThemeGridLayout();
         } elseif ($row['arLayoutIsPreset']) {
             $al = new PresetLayout();
         } else {
             $al = new CustomLayout();
         }
         $al->setPropertiesFromArray($row);
         $al->loadDetails();
         $al->loadColumnNumber();
         return $al;
     }
 }
 /**
  * @param CustomAreaLayout $layout
  */
 public function publish(AreaLayout $layout)
 {
     $arLayout = CustomLayout::add($layout->getSpacing(), $layout->getHasCustomWidths());
     foreach ($layout->getColumns() as $column) {
         /*
          * @var $column CustomAreaLayoutColumn
          */
         $columnObject = $arLayout->addLayoutColumn();
         $columnObject->setAreaLayoutColumnWidth($column->getWidth());
     }
     return $arLayout;
 }
예제 #4
0
 public function testCustomAreaLayoutContainer()
 {
     $layout = \Concrete\Core\Area\Layout\CustomLayout::add(20, false);
     $layout->addLayoutColumn();
     $layout->addLayoutColumn();
     $layout->addLayoutColumn();
     $layout = \Concrete\Core\Area\Layout\Layout::getByID(1);
     $this->assertInstanceOf('\\Concrete\\Core\\Area\\Layout\\CustomLayout', $layout);
     $columns = $layout->getAreaLayoutColumns();
     $this->assertEquals(3, count($columns));
     $formatter = $layout->getFormatter();
     $this->assertInstanceOf('\\Concrete\\Core\\Area\\Layout\\Formatter\\CustomFormatter', $formatter);
     $this->assertEquals('<div class="ccm-layout-column-wrapper" id="ccm-layout-column-wrapper-1"></div>', (string) $formatter->getLayoutContainerHtmlObject());
 }
예제 #5
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;
 }
예제 #6
0
 public function testSavePreset()
 {
     $layout = \Concrete\Core\Area\Layout\CustomLayout::add(20, false);
     $layout->addLayoutColumn();
     $layout->addLayoutColumn();
     $layout->addLayoutColumn();
     $preset1 = \Concrete\Core\Area\Layout\Preset\UserPreset::add($layout, 'Custom Preset');
     $layout = \Concrete\Core\Area\Layout\CustomLayout::add(10, false);
     $layout->addLayoutColumn();
     $layout->addLayoutColumn();
     $layoutID = $layout->getAreaLayoutID();
     $preset2 = \Concrete\Core\Area\Layout\Preset\UserPreset::add($layout, 'Custom Preset 2');
     $layout = \Concrete\Core\Area\Layout\PresetLayout::add($preset2->getPresetObject());
     $this->assertInstanceOf('\\Concrete\\Core\\Area\\Layout\\PresetLayout', $layout);
     $this->assertEquals($layoutID, $layout->getAreaLayoutPresetHandle());
     $this->assertEquals(2, $layout->getAreaLayoutNumColumns());
 }