Exemplo n.º 1
0
    $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);
    $layout->setAreaNameNumber($areaLayoutData['areaNameNumber']);
    $validLayout = intval($areaLayoutData['layoutID']) > 0 || is_object($layoutPreset) ? true : false;
    if ($validLayout) {
        $cvalID = intval($areaLayoutData['cvalID']);
    }
}
if (!$validLayout || !$cp->canEditPageContents() || !$ap->canAddLayoutToArea()) {
Exemplo n.º 2
0
 /** 
  * Gets all layout grid objects for a collection
  * @param Page|Collection $c
  * @return Layout[]
  */
 public function getAreaLayouts($c)
 {
     if (!intval($c->cID)) {
         //Invalid Collection
         return false;
     }
     if (!$c->hasLayouts()) {
         return array();
     }
     $db = Loader::db();
     $vals = array(intval($c->cID), $c->getVersionID(), $this->getAreaHandle());
     $sql = 'SELECT * FROM CollectionVersionAreaLayouts WHERE cID=? AND cvID=? AND arHandle=? ORDER BY position ASC, cvalID ASC';
     $rows = $db->getArray($sql, $vals);
     $layouts = array();
     $i = 0;
     if (is_array($rows)) {
         foreach ($rows as $row) {
             $layout = Layout::getById(intval($row['layoutID']));
             if (is_object($layout)) {
                 $i++;
                 //check position is correct, update if not
                 if ($i != $row['position'] || $renumbering) {
                     $renumbering = 1;
                     $db->query('UPDATE CollectionVersionAreaLayouts SET position=? WHERE cvalID=?', array($i, $row['cvalID']));
                 }
                 $layout->position = $i;
                 $layout->cvalID = intval($row['cvalID']);
                 $layout->setAreaObj($this);
                 $layout->setAreaNameNumber(intval($row['areaNameNumber']));
                 $layouts[] = $layout;
             }
         }
     }
     return $layouts;
 }
Exemplo n.º 3
0
 public function getLayoutObject()
 {
     return Layout::getById($this->layoutID);
 }
Exemplo n.º 4
0
						$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();
						$vals = array( $layoutID, $area->getAreaHandle(), intval($nvc->cID), intval($c->getVersionID()), intval($nvc->getVersionID())  ); 
						$layoutExistsInArea = intval($db->getOne('SELECT count(*) FROM CollectionVersionAreaLayouts WHERE layoutID=? AND arHandle=? AND cID=? AND cvID IN (?,?)',$vals))?1:0;
						$validLayout = ($layoutExistsInArea)?1:0;

						if(!$layout) $layout = Layout::getById($layoutID); 
						
						if( is_object($layout) && (in_array($_POST['layoutPresetAction'],array('update_existing_preset','create_new_preset')) || $validLayout) ){ 
							
							$layout->fill( $params );
							
							// if there's no unique layout record for this collection version, and it's not a preset, then treat this as a new record 
							// bypassed if editing a preset or creating a new one 
							if( (!$layoutPreset && !$layout->isUniqueToCollectionVersion($nvc)) || $_POST['layoutPresetAction']=='create_new_preset' || $_POST['layoutPresetAction']=='save_as_custom'){ 
								$updateLayoutId=1;
								$layout->layoutID=0;
							} 
							
							$layout->save( $nvc ); 
							//if($oldLayoutId) $nvc->updateAreaLayoutId($area, $oldLayoutId, $layout->layoutID);  
						}else{
<?php

defined('C5_EXECUTE') or die("Access Denied.");
if (ENABLE_AREA_LAYOUTS == false) {
    die(t('Area layouts have been disabled.'));
}
global $c;
$form = Loader::helper('form');
//Loader::model('layout');
if (intval($_REQUEST['lpID'])) {
    $layoutPreset = LayoutPreset::getByID($_REQUEST['lpID']);
    if (is_object($layoutPreset)) {
        $layout = $layoutPreset->getLayoutObject();
    }
} elseif (intval($_REQUEST['layoutID'])) {
    $layout = Layout::getById(intval($_REQUEST['layoutID']));
} else {
    $layout = new Layout(array('type' => 'table', 'rows' => 1, 'columns' => 3));
}
if (!$layout) {
    echo t('Error: Layout not found');
} else {
    $layoutPresets = LayoutPreset::getList();
    if (intval($layout->lpID)) {
        $layoutPreset = LayoutPreset::getById($layout->lpID);
    }
    ?>


<?php 
    if (!$_REQUEST['refresh']) {