/** * @param PresetAreaLayout $layout */ public function publish(AreaLayout $layout) { $preset = Preset::getByID($layout->getPreset()); $arLayout = PresetLayout::add($preset); foreach ($layout->getColumns() as $column) { $arLayout->addLayoutColumn(); } return $arLayout; }
public function getPresetData($cID, $arLayoutPresetID) { $c = \Page::getByID($cID, 'ACTIVE'); $r = Request::getInstance(); $r->setCurrentPage($c); $existingPreset = Preset::getByID($arLayoutPresetID); if (is_object($existingPreset)) { $r = new \stdClass(); $formatter = $existingPreset->getFormatter(); $container = $formatter->getPresetContainerHtmlObject(); foreach ($existingPreset->getColumns() as $column) { $html = $column->getColumnHtmlObjectEditMode(); $container->appendChild($html); } $r->id = $arLayoutPresetID; $r->html = (string) $container; \Core::make('helper/ajax')->sendResult($r); } }
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['arLayoutPresetID']); $arLayout = PresetLayout::add($arLayoutPreset); foreach ($arLayoutPreset->getColumns() as $column) { $arLayout->addLayoutColumn(); } break; } return $arLayout; }