Exemple #1
0
     }
     break;
 case 'layout':
     $area = Area::get($c, $_GET['arHandle']);
     $ap = new Permissions($area);
     if ($ap->canWrite()) {
         Loader::model('custom_style');
         $nvc = $c->getVersionToModify();
         //Loader::model('layout');
         $originalLayoutID = intval($_REQUEST['originalLayoutID']);
         $layoutID = intval($_REQUEST['layoutID']);
         $params = array('type' => 'table', 'rows' => intval($_REQUEST['layout_rows']), 'columns' => intval($_REQUEST['layout_columns']), 'locked' => intval($_REQUEST['locked']), 'spacing' => intval($_REQUEST['spacing']), 'layoutID' => $layoutID);
         //Save Existing layout preset
         $lpID = intval($_REQUEST['lpID']);
         if ($lpID && $_POST['layoutPresetAction'] == 'update_existing_preset') {
             $layoutPreset = LayoutPreset::getByID($lpID);
             if ($layoutPreset) {
                 $layout = $layoutPreset->getLayoutObject();
             }
             if (!$layout || !intval($layout->layoutID)) {
                 throw new Exception(t('Layout preset not found'));
             }
             $layoutID = intval($layout->layoutID);
             if ($layoutID != $originalLayoutID) {
                 $updateLayoutId = 1;
             }
         }
         //is this an existing layout?
         if ($layoutID) {
             //security check: make sure this layout belongs to this area & collection
             $db = Loader::db();
    echo $json->encode($jsonData);
    exit;
}
$nvc = $c->getVersionToModify();
$cp = new Permissions($c);
$ap = new Permissions($a);
if (!$cp->canEditPageContents() || !$ap->canAddLayoutToArea()) {
    $jsonData = array();
    $jsonData['msg'] = t('Access Denied.');
    echo $json->encode($jsonData);
    exit;
}
$valt = Loader::helper('validation/token');
$token = '&' . $valt->getParameter();
if ($_GET['task'] == 'deletePreset') {
    $layoutPreset = LayoutPreset::getByID($_REQUEST['lpID']);
    if (is_object($layoutPreset)) {
        $layout = $layoutPreset->getLayoutObject();
        $layoutID = $layout->layoutID;
    }
} else {
    $layoutID = intval($_REQUEST['layoutID']);
    $layout = Layout::getById($layoutID);
    $layoutPreset = $layoutPreset = $layout->getLayoutPresetObj();
}
$jsonData = array('success' => '0', 'msg' => '', 'layoutID' => intval($layoutID));
//security checks: make sure this layout belongs to this area & collection
if (is_object($layout) && is_object($a) && is_object($c)) {
    $db = Loader::db();
    $vals = array($layoutID, $a->getAreaHandle(), intval($nvc->cID), intval($nvc->getVersionID()));
    $areaLayoutData = $db->getRow('SELECT * FROM CollectionVersionAreaLayouts WHERE layoutID=? AND arHandle=? AND cID=? AND cvID=?', $vals);
Exemple #3
0
 public function getLayoutPresetObj()
 {
     return LayoutPreset::getByID($this->lpID);
 }