18 require_once SQ_CORE_PACKAGE_PATH.
'/page/page.inc';
43 $this->_ser_attrs = TRUE;
44 parent::__construct($assetid);
58 $page_links = parent::_getAllowedLinks();
59 $page_links[SQ_LINK_NOTICE][
'asset'] = Array(
'card' =>
'M',
'exclusive' => FALSE);
73 $lock_types = parent::lockTypes();
74 $lock_types[
'content'] = ($lock_types[
'attributes'] | $lock_types[
'links']);
90 $link = $GLOBALS[
'SQ_SYSTEM']->am->getLinkById($linkid);
91 switch (strtolower($link[
'value'])) {
93 return translate(
'cms_root_node_link_desc', translate(
'cms_site_map_asset_name'));;
96 return parent::describeLink($linkid);
112 $cm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'cache_manager');
113 $contextid = $GLOBALS[
'SQ_SYSTEM']->getContextId();
115 $cache_key = $rootid.
'-ctx'.$contextid;
118 $cached_contents = $cm->loadFromCache($this->
id, $this->
type(), $cache_key);
121 if ($cached_contents === FALSE) {
123 $levels = ($this->
attr(
'levels') != 0) ? $this->
attr(
'levels') : NULL;
125 $page_data = $GLOBALS[
'SQ_SYSTEM']->am->getAssetTree($rootid, $levels, array_keys($this->
attr(
'exclude_list')), $this->
attr(
'show_type_2') ? SQ_SC_LINK_BACKEND_NAV : SQ_SC_LINK_FRONTEND_NAV, $this->
attr(
'include_types'), $this->
attr(
'include_dependants'));
129 foreach ($page_data as $assetid => $data) {
130 $assetids[] = $assetid;
131 $assetids = array_merge($assetids, array_keys($data));
133 global $SQ_SITE_MAP_ASSET_URLS;
135 $SQ_SITE_MAP_ASSET_URLS = $GLOBALS[
'SQ_SYSTEM']->am->getAssetURL($assetids);
138 if ($this->
attr(
'icons')) {
139 echo
'<script type="text/javascript" src="'.sq_web_path(
'lib').
'/js/general.js"></script>';
145 $num_columns = ($this->
attr(
'columns') > 0) ? $this->
attr(
'columns') : 1;
146 if (empty($page_data)) {
151 $num_pages = count(array_keys($page_data[$rootid]));
153 $num_chunks = ceil($num_pages / $num_columns);
155 $chunks = array_chunk($page_data[$rootid], $num_chunks, TRUE);
156 $root_data = $page_data[$rootid];
157 unset($page_data[$rootid]);
161 switch ($this->
attr(
'map_format')) {
162 case 'unordered_list':
170 $cached_contents = ob_get_contents();
171 $cm->saveToCache($this->
id, $this->
type(), $cache_key, $cached_contents);
176 echo $cached_contents;
190 $root_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($this->
id, SQ_LINK_NOTICE,
'asset', FALSE,
'root');
191 if (!empty($root_link)) {
192 $root_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($root_link[
'minorid'], $root_link[
'minor_type_code']);
195 if (is_null($root_asset)) {
197 $site_info = $GLOBALS[
'SQ_SYSTEM']->am->getRootURL();
198 if (empty($site_info))
return FALSE;
199 $rootid = $site_info[
'assetid'];
201 $rootid = $root_asset->id;
204 $dynamic_root = $parameter_map->getParameterValue(
'root_node');
205 if (!empty($dynamic_root)) {
206 $parents = $GLOBALS[
'SQ_SYSTEM']->am->getParents($dynamic_root);
207 if (isset($parents[$rootid])) {
209 $rootid = $dynamic_root;
213 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($root_asset);
234 $top_level = $this->
attr(
'top_level');
235 if ($top_level == 0) $level = -1;
237 if (!$generating) global $SQ_SITE_MAP_ASSET_URLS;
239 $display_formats = $this->
attr(
'display_formats');
244 foreach ($chunks as $item) {
245 $url = ($generating) ?
'<'.
'?php echo $SQ_SITE_MAP_ASSET_URLS[$item[\'assetid\']] ?'.
'>' : $SQ_SITE_MAP_ASSET_URLS[$item[
'assetid']];
248 if ($this->
attr(
'icons')) {
249 ?><script
type=
"text/javascript">sq_print_icon(
"<?php echo $GLOBALS['SQ_SYSTEM']->am->getAssetIconURL($item['type_code']); ?>",
"16",
"16",
"");</script> <?php
253 ?><a href=
"<?php echo $url;?>" title=
"<?php echo $item['name']; ?>"><?php echo $format; ?></a>
255 if (isset($page_data[$item[
'assetid']]) && $level + 1 <= $top_level) {
258 $this->
_paintUnorderedList($page_data[$item[
'assetid']], $page_data, $level + 1, $generating);
286 <table cellpadding=
"0" cellspacing=
"0" border=
"0">
289 foreach ($chunks as $chunk) {
290 ?><td valign=
"top"><?php
291 $sub_chunk = Array();
292 $sub_chunk[$rootid] = $chunk;
293 $sub_chunk = $sub_chunk + $page_data;
319 $top_level = $this->
attr(
'top_level');
320 $stalks = $this->
attr(
'stalks');
322 if (!$generating) global $SQ_SITE_MAP_ASSET_URLS;
325 <table cellpadding=
"0" cellspacing=
"0" border=
"0">
327 $num_kids = count($page_data[$parent]);
329 foreach ($page_data[$parent] as $data) {
330 $end = ($i == $num_kids - 1);
331 $image1 = (($level == 1 && !$top_level) || !$stalks) ?
'blank.gif' :
'tree/stalk.gif';
332 $image2 = (($level == 1 && !$top_level) || !$stalks) ?
'blank.gif' :
'tree/branch.gif';
334 $bg = ($end) ?
'' :
'style="background-image: url(\''.sq_web_path(
'lib').
'/web/images/'.$image1.
'\')
"';
336 $url = ($generating) ? '<'.'?php echo $SQ_SITE_MAP_ASSET_URLS[$data[\'assetid\']] ?'.'>' : $SQ_SITE_MAP_ASSET_URLS[$data['assetid']];
339 <td <?php echo $bg; ?>>
340 <img src="<?php echo sq_web_path(
'lib').
'/web/images/'.$image2; ?>
" width="20
" height="20
" border="0
" alt="Level <?php echo $level; ?> Item
" /></td>
343 if ($this->attr('icons')) {
345 <script type="text/javascript
">sq_print_icon("<?php echo $GLOBALS[
'SQ_SYSTEM']->am->getAssetIconURL($data[
'type_code']); ?>
", "16
", "16
", "");</script>
348 $format = $this->_getDisplayFormat($data);
350 <a href="<?php echo $url?>
" title="<?php echo $data[
'name']; ?>
"><?php echo $format; ?></a>
354 if (!empty($page_data[$data['assetid']])) {
357 <td <?php echo $bg; ?>><img src="<?php echo sq_web_path(
'lib').
'/web/images/blank.gif'; ?>
" width="1
" height="1
" alt=" " /></td>
360 $this->_defaultRecursePrintAssetList($page_data, $data['assetid'], ($level +1), $generating);
374 }//end _defaultRecursePrintAssetList()
385 function _getDisplayFormat($data)
387 if (!is_array($data)) return '';
389 $display_formats = $this->attr('display_formats');
391 $format = $data['name'];
392 $format_type_code = NULL;
393 if (isset($display_formats[$data['type_code']])) {
394 $format_type_code = $data['type_code'];
395 } else if (!empty($display_formats)) {
396 foreach ($display_formats as $type => $info) {
397 if ($info['inherit'] == 1) {
398 if ($GLOBALS['SQ_SYSTEM']->am->isTypeDecendant($data['type_code'], $type)) {
399 $format_type_code = $type;
406 if (!is_null($format_type_code)) {
407 $asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($data['assetid']);
408 $format = $display_formats[$format_type_code]['format'];
410 preg_match_all('/%([^%]*)%/i', $format, $matches);
411 foreach ($matches[1] as $key => $keyword) {
412 $rep = $asset->getKeywordReplacement($keyword);
413 $format = preg_replace('!' . preg_quote($matches[0][$key], '!') . '!', $rep, $format);
415 $GLOBALS['SQ_SYSTEM']->am->forgetAsset($asset);
420 }//end _getDisplayFormat()