Example #1
0
    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();

        }
    }
Example #2
0
 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();
     }
 }
Example #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;
 }
Example #4
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
use Concrete\Core\Area\Layout\Preset as AreaLayoutPreset;
$minColumns = 1;
if ($controller->getTask() == 'add') {
    $spacing = 0;
    $iscustom = false;
}
$presets = AreaLayoutPreset::getList();
?>

<ul id="ccm-layouts-toolbar" class="ccm-inline-toolbar ccm-ui">
	<li class="ccm-sub-toolbar-text-cell">
		<label for="useThemeGrid"><?php 
echo t("Grid:");
?>
</label>
		<select name="gridType" id="gridType" style="width: auto !important">
			<optgroup label="<?php 
echo t('Grids');
?>
">
			<?php 
if ($enableThemeGrid) {
    ?>
				<option value="TG"><?php 
    echo $themeGridName;
    ?>
</option>
			<?php