18 require_once SQ_INCLUDE_PATH.
'/asset.inc';
43 $this->_ser_attrs = TRUE;
44 parent::__construct($assetid);
61 if (!parent::_preCreateCheck($link))
return FALSE;
63 $id_name = trim($this->
attr(
'id_name'));
65 trigger_localised_error(
'CORE0187', E_USER_WARNING, $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($this->type(),
'name'));
92 return parent::_updated(FALSE);
105 $lock_types = parent::lockTypes();
106 $lock_types[
'parsing'] = $lock_types[
'all'];
123 $name = $this->
attr(
'id_name');
125 if ($name ==
'') $name = parent::_getName($short_name);
143 if (parent::processBackend($o, $link)) {
145 for ($i = 0, $max = count($designs); $i < $max; $i++) {
146 $designs[$i]->generateDesignFile(FALSE);
168 $links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_TYPE_3,
'design', FALSE,
'minor');
170 foreach ($links as $link) {
171 $designs[] = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'majorid'], $link[
'major_type_code'], TRUE);
187 foreach ($this->vars[
'var_references'][
'value'] as $var_name => $info) {
188 if (!isset($var_refs[$info[
'id_name']])) {
189 $var_refs[$info[
'id_name']] = Array();
191 $var_refs[$info[
'id_name']][] = $info[
'var'];
209 if (!isset($this->_tmp[
'var_reference_values'])) {
210 $this->_tmp[
'var_reference_values'] = Array();
212 foreach ($this->vars[
'var_references'][
'value'] as $var_name => $info) {
213 if (isset($var_ref_values[$info[
'id_name']][$info[
'var']])) {
214 $this->_tmp[
'var_reference_values'][$var_name] = $var_ref_values[$info[
'id_name']][$info[
'var']];
231 if (isset($this->_tmp[
'var_reference_values'][$name])) {
232 return $this->_tmp[
'var_reference_values'][$name];
234 return parent::attr($name);
251 return $GLOBALS[
'SQ_SYSTEM']->am->getAssetTypeAttributes(
'design_area', Array(
'name'));
286 if (empty($args[
'escape']) || strtolower($args[
'escape']) ==
'no') {
289 return 'addslashes('.$value.
')';
307 return var_export((
string)$string, TRUE);
352 $design =& $GLOBALS[
'DESIGN_BEING_GENERATED'];
353 $instance_id =
'_'.$this->id.
'_'.$design->id;
357 $cm = $GLOBALS[\'SQ_SYSTEM\']->am->getSystemAsset(\'cache_manager\');
358 $asset_contents'.$instance_id.
' = $cm->loadFromCache('.$this->
id.
', \''.$this->
type().
'\', \
''.$design->id.
'\', !
'.$this->attr('cache_globally
').');
360 if ($asset_contents
'.$instance_id.' === FALSE) {
364 $this->_printInitCode();
366 if ($this->attr('cache
') && $this->_canBeCached()) {
374 }//end printInitCode()
385 protected function _printInitCode()
388 }//end _printInitCode()
401 public function printPaintingCode()
403 if (!array_get_index($this->_tmp, 'ready_to_paint
')) {
406 $design =& $GLOBALS['DESIGN_BEING_GENERATED
'];
407 $instance_id = '_
'.$this->id.'_
'.$design->id;
408 if ($this->attr('cache
') && $this->_canBeCached()) {
411 if ($asset_contents
'.$instance_id.' === FALSE) {
417 $this->_printPaintingCode();
419 if ($this->attr('cache
') && $this->_canBeCached()) {
422 $asset_contents
'.$instance_id.' = ob_get_contents();
424 $cm = $GLOBALS[\
'SQ_SYSTEM\']->am->getSystemAsset(\'cache_manager\');
425 $cm->saveToCache('.$this->id.
', \''.$this->
type().
'\', \
''.$design->id.
'\', $asset_contents
'.$instance_id.', !
'.$this->attr('cache_globally
').');
427 echo $asset_contents
'.$instance_id.';
432 }//end printPaintingCode()
444 protected function _printPaintingCode()
446 $contents = $this->attr('contents
');
447 $current_element = NULL;
449 // remove any leading or trailing whitespace elements from the contents
450 // first, the leaders
451 if (count($contents) > 0) {
452 $current_element = array_shift($contents);
453 while(($current_element['_type
'] == 'HTML
') && (trim($current_element['contents
']) == '')) {
454 if (count($contents) == 0) {
455 $current_element = NULL;
458 $current_element = array_shift($contents);
462 if (!is_null($current_element)) {
463 array_unshift($contents, $current_element);
466 // now the trailers...
467 if (count($contents) > 0) {
468 $current_element = array_pop($contents);
469 while(($current_element['_type
'] == 'HTML
') && (trim($current_element['contents
']) == '')) {
470 if (count($contents) == 0) {
471 $current_element = NULL;
474 $current_element = array_pop($contents);
478 if (!is_null($current_element)) {
479 array_push($contents, $current_element);
482 // Now print out what we have left
483 foreach ($contents as $item) {
484 $this->_printContentItemCode($item);
487 }//end _printPaintingCode()
498 protected function _printContentItemCode(Array $item)
500 if ($item['_type
'] == 'HTML
') {
501 // just some HTML content to echo out
502 echo $item['contents
'];
503 } else if ($item['_type
'] == 'TAG
') {
504 if ($item['operation
'] == 'print
') {
505 $design =& $GLOBALS['DESIGN_BEING_GENERATED
'];
506 if (empty($item['attributes
']['id_name
'])) {
507 $args = $item['attributes
'];
508 unset($args['id_name
']);
510 $this->printVar($item['attributes
']['var
'], $args);
512 if ($item['attributes
']['id_name
'] == '__global__
') {
513 // printing a global var
514 $args = $item['attributes
'];
515 unset($args['id_name
']);
517 $design->printVar($item['attributes
']['var
'], $args);
519 // referencing another design area (which should already have been defined)
520 $da = $design->getDesignArea($item['attributes
']['id_name
']);
522 trigger_localised_error('CORE0153
', E_USER_NOTICE, $item['attributes
']['id_name
']);
524 if (isset($item['attributes
']['var
'])) {
525 // printing a particular var from the design area
526 $args = $item['attributes
'];
527 unset($args['id_name
']);
529 $da->printVar($item['attributes
']['var
'], $args);
531 // printing the whole other design area
532 $da->printPaintingCode();
540 }//end _printContentItemCode()
552 public function printAreaCode()
554 if ($this->_canInit()) {
555 $this->printInitCode();
556 $this->_tmp['ready_to_paint
'] = TRUE;
557 if ($this->attr('print
')) $this->printPaintingCode();
560 }//end printAreaCode()