Beispiel #1
0
 protected function displayTableGrid($rows = 3, $columns = 3, $c = NULL)
 {
     if (!$c) {
         global $c;
     }
     if ($c->isEditMode()) {
         $editMode = 'ccm-edit-mode';
     }
     if (!intval($rows)) {
         $rows = 1;
     }
     if (!intval($columns)) {
         $columns = 3;
     }
     $layoutNameClass = 'ccm-layout-name-' . TextHelper::camelcase($this->getAreaHandle()) . '-' . TextHelper::camelcase($this->getLayoutNameTxt()) . '-' . $this->getAreaNameNumber();
     echo '<div id="ccm-layout-' . $this->layoutID . '" class="ccm-layout ccm-layout-table  ' . $layoutNameClass . ' ' . $editMode . '">';
     for ($i = 0; $i < $rows; $i++) {
         echo '<div class="ccm-layout-row ccm-layout-row-' . ($i + 1) . '">';
         $cumulativeWidth = 0;
         for ($j = 0; $j < $columns; $j++) {
             $colWidth = $columns == 1 ? '100%' : $this->getNextColWidth($j, $cumulativeWidth);
             $cumulativeWidth += intval(str_replace(array('px', '%'), '', strtolower($colWidth)));
             $columnn_id = 'ccm-layout-' . intval($this->layoutID) . '-col-' . ($j + 1);
             if ($j == 0) {
                 $positionTag = 'first';
             } elseif ($j == $columns - 1) {
                 $positionTag = 'last';
             } else {
                 $positionTag = '';
             }
             echo '<div class="' . $columnn_id . ' ccm-layout-cell ccm-layout-col ccm-layout-col-' . ($j + 1) . ' ' . $positionTag . '" style="width:' . $colWidth . '">';
             $a = new Area($this->getCellAreaHandle($this->getCellNumber()));
             ob_start();
             $a->display($c);
             $areaHTML = ob_get_contents();
             ob_end_clean();
             if (strlen($areaHTML)) {
                 if (intval($this->spacing)) {
                     $areaHTML = '<div class="ccm-layout-col-spacing">' . $areaHTML . '</div>';
                 }
                 echo $areaHTML;
             } else {
                 echo '&nbsp;';
             }
             echo '</div>';
         }
         echo '<div class="ccm-spacer"></div>';
         echo '</div>';
     }
     echo '</div>';
 }
Beispiel #2
0
	/** 
	 * Retrieves all custom style rules that should be inserted into the header on a page, whether they are defined in areas
	 * or blocks
	 */
	public function outputCustomStyleHeaderItems($return = false) {	
		
		$db = Loader::db();
		$csrs = array();
		$txt = Loader::helper('text');
		CacheLocal::set('csrCheck', $this->getCollectionID() . ':' . $this->getVersionID(), true);

		$r1 = $db->GetAll('select bID, arHandle, csrID from CollectionVersionBlockStyles where cID = ? and cvID = ? and csrID > 0', array($this->getCollectionID(), $this->getVersionID()));
		$r2 = $db->GetAll('select arHandle, csrID from CollectionVersionAreaStyles where cID = ? and cvID = ? and csrID > 0', array($this->getCollectionID(), $this->getVersionID()));
		foreach($r1 as $r) {
			$csrID = $r['csrID'];
			$arHandle = $txt->filterNonAlphaNum($r['arHandle']);
			$bID = $r['bID'];
			$obj = CustomStyleRule::getByID($csrID);
			if (is_object($obj)) {
				$obj->setCustomStyleNameSpace('blockStyle' . $bID . $arHandle);
				$csrs[] = $obj;
				CacheLocal::set('csrObject', $this->getCollectionID(). ':' . $this->getVersionID() . ':' . $r['arHandle']  . ':' . $r['bID'], $obj);
			}
		}

		foreach($r2 as $r) {
			$csrID = $r['csrID'];
			$arHandle = $txt->filterNonAlphaNum($r['arHandle']);
			$obj = CustomStyleRule::getByID($csrID);
			if (is_object($obj)) {
				$obj->setCustomStyleNameSpace('areaStyle' . $arHandle);
				$csrs[] = $obj;
				CacheLocal::set('csrObject', $this->getCollectionID(). ':' . $this->getVersionID() . ':' . $r['arHandle'], $obj);
			}
		}
		
		// grab all the header block style rules for items in global areas on this page
		$rs = $db->GetCol('select arHandle from Areas where arIsGlobal = 1 and cID = ?', array($this->getCollectionID()));
		if (count($rs) > 0) {
			$pcp = new Permissions($this);
			foreach($rs as $garHandle) {
				if ($pcp->canViewPageVersions()) {
					$s = Stack::getByName($garHandle, 'RECENT');
				} else {
					$s = Stack::getByName($garHandle, 'ACTIVE');
				}
				if (is_object($s)) {
					CacheLocal::set('csrCheck', $s->getCollectionID() . ':' . $s->getVersionID(), true);
					$rs1 = $db->GetAll('select bID, csrID, arHandle from CollectionVersionBlockStyles where cID = ? and cvID = ? and csrID > 0', array($s->getCollectionID(), $s->getVersionID()));
					foreach($rs1 as $r) {
						$csrID = $r['csrID'];
						$arHandle = $txt->filterNonAlphaNum($r['arHandle']);
						$bID = $r['bID'];
						$obj = CustomStyleRule::getByID($csrID);
						if (is_object($obj)) {
							$obj->setCustomStyleNameSpace('blockStyle' . $bID . $arHandle);
							$csrs[] = $obj;
							CacheLocal::set('csrObject', $s->getCollectionID(). ':' . $s->getVersionID() . ':' . $r['arHandle'] . ':' . $r['bID'], $obj);
						}
					}
				}
			}
		}
		//get the header style rules
		$styleHeader = ''; 
		foreach($csrs as $st) { 
			if ($st->getCustomStyleRuleCSSID(true)) { 
				$styleHeader .= '#'.$st->getCustomStyleRuleCSSID(1).' {'. $st->getCustomStyleRuleText(). "} \r\n";  
			}
		} 		
		  
		$r3 = $db->GetAll('select l.layoutID, l.spacing, arHandle, areaNameNumber from CollectionVersionAreaLayouts cval LEFT JOIN Layouts AS l ON  cval.layoutID=l.layoutID WHERE cval.cID = ? and cval.cvID = ?', array($this->getCollectionID(), $this->getVersionID()));
		foreach($r3 as $data){  
			if(!intval($data['spacing'])) continue; 
			$layoutIDVal = strtolower('ccm-layout-'.TextHelper::camelcase($data['arHandle']).'-'.$data['layoutID'] . '-'. $data['areaNameNumber']);
			$layoutStyleRules='#' . $layoutIDVal . ' .ccm-layout-col-spacing { margin:0px '.ceil(floatval($data['spacing'])/2).'px }';
			$styleHeader .= $layoutStyleRules . " \r\n";  
		}  
		
		if(strlen(trim($styleHeader))) {
			if ($return == true) {
				return $styleHeader;
			} else {
				$v = View::getInstance();
				$v->addHeaderItem("<style type=\"text/css\"> \r\n".$styleHeader.'</style>', 'VIEW');
			}
		}
	}