00001 <?php
00019 class SPageTemplate {
00020 protected $parent;
00021
00022 protected $topMetaSlots;
00023 protected $metaSlots;
00024 protected $bottomMetaSlots;
00025
00033 function __construct($parent) {
00034 $this->parent = $parent;
00035 include(dirname(__FILE__) . "/../config/SPageTemplateConfig.php5");
00036 }
00037
00052 public function getMetaSlotsList () {
00053 $ret = array();
00054 foreach ($this->metaSlots as $ms){
00055 if ($ms['display']) array_push($ret, $ms['name']);
00056 }
00057 $topms = ($this->parent->getOption('showTopMetaSlots')) ? $this->topMetaSlots : array();
00058 $bottomms = ($this->parent->getOption('showBottomMetaSlots')) ? $this->bottomMetaSlots : array();
00059 return array_merge($topms, $ret, $bottomms);
00060 }
00061
00072 public function setLayoutForMetaSlot ($metaSlot, $layout) {
00073 $this->setAttributeForMetaSlot($metaSlot, 'layout', $layout);
00074 }
00075
00084 public function setDisplayForMetaSlot ($metaSlot, $display) {
00085 $this->setAttributeForMetaSlot($metaSlot, 'display', $display);
00086 }
00087
00094 public function getDisplayForMetaSlot ($metaSlot) {
00095 foreach($this->metaSlots as $ms) {
00096 if($ms['name'] == $metaSlot)
00097 return $ms['display'];
00098 }
00099 return false;
00100 }
00101
00109 public function setAttributeForMetaSlot ($metaSlot, $attribute, $value) {
00110 $this->metaSlots[$this->getIndexForMetaSlot($metaSlot)]["$attribute"] = $value;
00111 }
00112
00120 public function getAttributeForMetaSlot ($metaSlot, $attribute) {
00121 $i = $this->getIndexForMetaSlot($metaSlot);
00122 if ($i != -1) return $this->metaSlots[$i]["$attribute"];
00123 }
00124
00132 public function getIndexForMetaSlot($metaSlot) {
00133 for($i=0;$i<count($this->metaSlots);$i++){
00134 if (isset($this->metaSlots[$i]['name']) && ($this->metaSlots[$i]['name'] == $metaSlot)){
00135 return $i;
00136 }
00137 }
00138 return -1;
00139 }
00140
00149 public function swapMetaSlotOrder($ms1, $ms2) {
00150 $i = $this->getIndexForMetaSlot($ms1); $j = $this->getIndexForMetaSlot($ms2);
00151 $swp = $this->metaSlots[$i];
00152 $this->metaSlots[$i] = $this->metaSlots[$j];
00153 $this->metaSlots[$j] = $swp;
00154 }
00155
00162 public function getLayoutForMetaSlot ($metaSlot) {
00163 return $this->getAttributeForMetaSlot($metaSlot, 'layout');
00164 }
00165 }
00166 ?>