18 require_once SQ_CORE_PACKAGE_PATH.
'/designs/design_area/design_area.inc';
43 parent::__construct($assetid);
59 public function printVar($var, Array $args, $value_prefix=
'', $value_suffix=
'')
63 echo
'<',
'?php echo $ASSET_LINEAGE[$'.$this->attr(
'id_name').
'_i][\'assetid\']; ?',
'>';
67 echo
'<',
'?php echo $ASSET_LINEAGE[$'.$this->attr(
'id_name').
'_i][\'protocol\'].\'://\'.$ASSET_LINEAGE[$'.$this->
attr(
'id_name').
'_i][\'url\']; ?',
'>';
70 case 'asset_short_name' :
72 echo
'<',
'?php echo ', $this->
_escapeVar($value_prefix.
'htmlspecialchars($ASSET_LINEAGE[$'.$this->attr(
'id_name').
'_i]['.var_export((
string) substr($var, 6), TRUE).
'])'.$value_suffix, $args),
'; ?',
'>';
75 case 'lineage_level' :
76 echo
'<',
'?php echo ',
'$'.$this->attr(
'id_name').
'_i; ?',
'>';
79 case (preg_match(
'/^asset_/i', $var) ? $var : !$var):
81 echo
'$keyword = \'',$var,
'\';
';
82 echo '$ASSET1 = $GLOBALS[\
'SQ_SYSTEM\']->am->getAsset($ASSET_LINEAGE[$'.$this->attr(
'id_name').
'_i][\'assetid\']);';
83 echo
'if (!is_null($ASSET1)) {';
84 echo
'$replacement = '.$this->_escapeVar(
'$ASSET1->getKeywordReplacement($keyword)', $args).
';';
85 echo
'if ($replacement == $keyword) {';
88 echo
' echo $replacement;';
90 echo
'$GLOBALS[\'SQ_SYSTEM\']->am->forgetAsset($ASSET1);';
98 parent::printVar($var, $args);
115 switch (array_get_index($element,
'operation')) {
119 if ( isset($_GET[\'a\']) && isset($GLOBALS[\'SQ_SYSTEM\']->frontend_asset) && $_GET[\'a\'] == $GLOBALS[\'SQ_SYSTEM\']->frontend_asset->id){
120 $last_ele_index = count($ASSET_LINEAGE) - 1;
121 $ASSET_LINEAGE[] = array (
122 \'url\' => $ASSET_LINEAGE[$last_ele_index][\'url\'].\'?a=\'.$GLOBALS[\'SQ_SYSTEM\']->frontend_asset->id,
123 \'assetid\' => $GLOBALS[\'SQ_SYSTEM\']->frontend_asset->id,
124 \'name\' => $GLOBALS[\'SQ_SYSTEM\']->frontend_asset->name,
125 \'short_name\' => $GLOBALS[\'SQ_SYSTEM\']->frontend_asset->short_name,
126 \'type_code\' => get_class_lower($GLOBALS[\'SQ_SYSTEM\']->frontend_asset),
127 \'protocol\' => $ASSET_LINEAGE[$last_ele_index][\'protocol\'],
128 \'link_type\' => $ASSET_LINEAGE[$last_ele_index][\'link_type\'],
135 $start_index = ($this->
attr(
'prefix_with_home_link')) ? 0 : 1;
137 $start_at_level = $this->
attr(
'start_at_level');
138 if (!is_null($start_at_level) && $start_at_level !==
'') {
139 $start_index = $start_at_level >= 0 ? $start_at_level :
'max(0, (count($ASSET_LINEAGE) - 1 - '.abs($start_at_level).
'))';
142 $total =
'count($ASSET_LINEAGE)';
145 if (!$this->
attr(
'suffix_with_current_link')) {
149 $levels_to_print = (int) $this->
attr(
'levels_to_print');
151 if (is_int($levels_to_print)) {
153 if ($levels_to_print > 0) {
154 $total =
'min('.$total.
', '.($levels_to_print.
' + '.$start_index).
')';
155 }
else if ($levels_to_print < 0) {
157 $start_index =
'max(0, (count($ASSET_LINEAGE) - 1 - '.abs($levels_to_print).
'))';
161 if ($divider_contents = $this->
attr(
'divider_contents')) {
163 foreach ($divider_contents as $item) {
166 $divider = ob_get_contents();
172 if ($divider !=
'' && $this->
attr(
'prefix_with_divider')) {
180 if ($this->
attr(
'reverse_lineage')) {
181 echo
'for ($'.$this->attr(
'id_name').
'_i = '.$total.
' - 1, $'.$this->
attr(
'id_name').
'_total = '.$total.
';
182 $'.$this->
attr(
'id_name').
'_i >= '.$start_index.
';
183 $'.$this->
attr(
'id_name').
'_i--) {
186 echo
'for ($'.$this->attr(
'id_name').
'_i = '.$start_index.
', $'.$this->
attr(
'id_name').
'_total = '.$total.
';
187 $'.$this->
attr(
'id_name').
'_i < $'.$this->
attr(
'id_name').
'_total;
188 $'.$this->
attr(
'id_name').
'_i++) {
192 if (!$this->
attr(
'show_hidden_links')) {
193 echo
'if ($ASSET_LINEAGE[$'.$this->attr(
'id_name').
'_i][\'link_type\'] != SQ_LINK_TYPE_1) continue;
197 $unwanted_types = $this->
attr(
'unwanted_asset_types');
198 $all_type_codes = Array();
199 foreach ($unwanted_types as $type) {
201 $all_type_codes = array_merge($all_type_codes, $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants($type, TRUE));
204 $unwanted_types = $all_type_codes;
206 if (!empty($unwanted_types)) {
207 $unwanted_types_literal_array =
'Array("'.implode(
'", "', $unwanted_types).
'")';
208 if ($this->
attr(
'prefix_with_home_link')) {
211 echo
'if (($'.$this->attr(
'id_name').
'_i != 0) && in_array($ASSET_LINEAGE[$'.$this->
attr(
'id_name').
'_i][\'type_code\'], '.$unwanted_types_literal_array.
')) continue;
214 echo
'if (in_array($ASSET_LINEAGE[$'.$this->attr(
'id_name').
'_i][\'type_code\'], '.$unwanted_types_literal_array.
')) continue;
220 if ($asset_contents = $this->
attr(
'asset_contents')) {
222 foreach ($asset_contents as $item) {
229 if ($divider !=
'') {
232 if (!$this->
attr(
'suffix_with_divider')) {
233 if ($this->
attr(
'reverse_lineage')) {
235 if ($'.$this->attr(
'id_name').
'_i != '.$start_index.
') {
239 if ($'.$this->attr(
'id_name').
'_i != $'.$this->
attr(
'id_name').
'_total - 1) {
244 echo
'?',
'>', $divider,
'<',
'?php ';
247 if (!$this->
attr(
'suffix_with_divider')) {
261 return parent::_printContentItemCode($element);
278 $res = parent::getProtectedAttrs();
279 $res[] =
'asset_contents';
280 $res[] =
'divider_contents';
301 if (($name ==
'unwanted_asset_types') && is_scalar($value)) {
302 $value = preg_split(
'/[ ,]+/', (
string)$value);
303 foreach ($value as $type_code) {
304 if (!$GLOBALS[
'SQ_SYSTEM']->am->installed($type_code)) {
305 trigger_localised_error(
'CORE0145', E_USER_WARNING, $type_code);
310 return parent::setAttrValue($name, $value);