示例#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') {
             UserPreset::add($arLayout, $_POST['arLayoutPresetName']);
         } else {
             $existingPreset = UserPreset::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();
     }
 }
示例#2
0
 public function getPresets()
 {
     $list = UserPreset::getList();
     $presets = array();
     foreach ($list as $preset) {
         $p = $preset->getPresetObject();
         $presets[] = $p;
     }
     return $presets;
 }
示例#3
0
 public function delete()
 {
     if ($this->validateAction()) {
         $preset = UserPreset::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();
     }
 }
示例#4
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());
 }