public function submit($arLayoutID) { if ($this->validateAction()) { $arLayout = AreaLayout::getByID($arLayoutID); if (!is_object($arLayout)) { throw new Exception(t('Invalid layout object.')); } if ($_POST['arLayoutPresetID'] == '-1') { AreaLayoutPreset::add($arLayout, $_POST['arLayoutPresetName']); } else { $existingPreset = AreaLayoutPreset::getByID($_POST['arLayoutPresetID']); if (is_object($existingPreset)) { $existingPreset->updateName($_POST['arLayoutPresetName']); $existingPreset->updateAreaLayoutObject($arLayout); } } $pr = new EditResponse(); if ($existingPreset) { $pr->setMessage(t('Area layout preset updated successfully.')); } else { $pr->setMessage(t('Area layout preset saved successfully.')); } $pr->outputJSON(); } }
public function delete() { if ($this->validateAction()) { $preset = Preset::getByID($this->request->request('arLayoutPresetID')); if (!is_object($preset)) { throw new Exception(t('Invalid layout preset object.')); } $preset->delete(); $pr = new EditResponse(); $pr->setAdditionalDataAttribute('arLayoutPresetID', $preset->getAreaLayoutPresetID()); $pr->outputJSON(); } }
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; }