Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
design_area_nest_content.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/designs/design_area/design_area.inc';
19 
32 {
33 
34 
41  function __construct($assetid=0)
42  {
43  parent::__construct($assetid);
44 
45  }//end constructor
46 
47 
57  public function setAttrValue($name, $value)
58  {
59  // if they are trying to set the type_codes, split the string
60  if ($name == 'type_codes') {
61  if (!is_array($value)) {
62  $value = preg_split('/[ ,]+/', (string) $value);
63  }
64  foreach ($value as $type_code) {
65  if (!$GLOBALS['SQ_SYSTEM']->am->installed($type_code)) {
66  trigger_localised_error('CORE0145', E_USER_WARNING, $type_code);
67  return FALSE;
68  }
69  }
70  }
71 
72  return parent::setAttrValue($name, $value);
73 
74  }//end setAttrValue()
75 
76 
89  public function _getAllowedLinks()
90  {
91 
92  return Array(
93  SQ_LINK_TYPE_1 => Array(),
94  SQ_LINK_TYPE_2 => Array(),
95  SQ_LINK_TYPE_3 => Array(),
96  SQ_LINK_NOTICE => Array(
97  'asset' => Array(
98  'card' => 1,
99  'exclusive' => FALSE,
100  ),
101  ),
102  );
103 
104  }//end _getAllowedLinks()
105 
106 
118  public function _getNestAssetInfo($field)
119  {
120  if ((empty($this->_tmp['nest_assetid'])) || (!isset($this->_tmp['nest_assetid']))) {
121  $this->_tmp['nest_assetid'] = $GLOBALS['SQ_SYSTEM']->am->getLink($this->id, SQ_LINK_NOTICE, '', TRUE, 'nest_content_asset');
122  }
123  return (empty($this->_tmp['nest_assetid'])) ? NULL : $this->_tmp['nest_assetid'][$field];
124 
125  }//end _getNestAssetInfo()
126 
127 
134  public function linksUpdated()
135  {
136  parent::linksUpdated();
137  unset($this->_tmp['nest_assetid']);
138 
139  }//end linksUpdated()
140 
141 
148  protected function _canInit()
149  {
150  $assetid = (int) $this->_getNestAssetInfo('minorid');
151  return !(empty($assetid));
152 
153  }//end _canInit()
154 
155 
162  protected function _printInitCode()
163  {
164  $assetid = (int) $this->_getNestAssetInfo('minorid');
165  $paint_layout_id = (int) $this->attr('paint_layout');
166  $paint_with = (string) $this->attr('paint_with');
167  echo '<', '?php
168  $nest_content_'.$this->attr('id_name').'_paint_layout = NULL;
169  $nest_content_'.$this->attr('id_name').'_asset = $GLOBALS[\'SQ_SYSTEM\']->am->getAsset('.$assetid.');';
170  if (!empty($paint_layout_id) && $paint_with == 'arbitrary') {
171  echo '$nest_content_'.$this->attr('id_name').'_paint_layout = $GLOBALS[\'SQ_SYSTEM\']->am->getAsset('.$paint_layout_id.');';
172  }
173  echo '$nest_content_'.$this->attr('id_name').'_paint_with = \''.$paint_with.'\';
174  ?', '>';
175 
176  }//end _printInitCode()
177 
178 
188  protected function _printPaintingCode()
189  {
190  echo '<', '?php
191  if (!is_null($nest_content_'.$this->attr('id_name').'_asset)) {
192  if ($nest_content_'.$this->attr('id_name').'_asset->readAccess()) {
193  ob_start();
194  switch ($nest_content_'.$this->attr('id_name').'_paint_with) {
195  case \'arbitrary\':
196  if (!is_null($nest_content_'.$this->attr('id_name').'_paint_layout)) {
197  $switched_frontend = FALSE;
198  if ($GLOBALS[\'SQ_SYSTEM\']->frontend_asset->id !== $this->id) {
199  $current_frontend_asset =& $GLOBALS[\'SQ_SYSTEM\']->frontend_asset;
200  $GLOBALS[\'SQ_SYSTEM\']->frontend_asset =& $nest_content_'.$this->attr('id_name').'_asset;
201  $switched_frontend = TRUE;
202  }
203  $nest_content_'.$this->attr('id_name').'_paint_layout->paint($nest_content_'.$this->attr('id_name').'_asset);
204 
205  if ($switched_frontend) {
206  $GLOBALS[\'SQ_SYSTEM\']->frontend_asset =& $current_frontend_asset;
207  }
208  } else {
209  $nest_content_'.$this->attr('id_name').'_asset->printBody();
210  }
211  break;
212 
213  case \'default\':
214  $nest_content_'.$this->attr('id_name').'_asset->printBodyWithPaintLayout();
215  break;
216 
217  default:
218  $nest_content_'.$this->attr('id_name').'_asset->printBody();
219  break;
220  }
221  $body = ob_get_clean();
222 
223  echo $body;
224  }
225  }
226  ?', '>';
227 
228  }//end _printPaintingCode()
229 
230 
231 }//end class
232 ?>