18 require_once SQ_CORE_PACKAGE_PATH.
'/page/page.inc';
19 require_once SQ_FUDGE_PATH.
'/general/text.inc';
44 $this->_ser_attrs = TRUE;
45 parent::__construct($assetid);
59 $page_links = parent::_getAllowedLinks();
60 $page_links[SQ_LINK_TYPE_2][
'page_multiple_page_page'] = Array(
'card' =>
'M',
'exclusive' => TRUE);
86 function prepareLink(&$asset, $side_of_link, &$link_type, &$value, &$sort_order, &$dependant, &$exclusive)
89 if (($link_type != SQ_LINK_TYPE_2) || ($exclusive != TRUE)) {
90 $link_type = SQ_LINK_TYPE_2;
111 echo translate(
'currently_no_pages_to_display');
126 $this->_tmp[
'current_page_asset'] = &$asset;
128 $keywords = $asset->getKeywords();
130 $replacements = Array();
132 foreach ($keywords as $value) {
136 $asset->setKeywordReplacements($replacements);
138 $content = $asset->getContent();
152 $contents = translate(
'cms_page_multiple_page_get_content_msg');
166 $lock_types = parent::lockTypes();
167 $lock_types[
'content'] = ($lock_types[
'attributes'] | $lock_types[
'links']);
184 if (!is_array($keywords) || empty($keywords)) {
187 if (!in_array(
'contents', $keywords))
return Array();
188 return Array(
'content');
216 $am = $GLOBALS[
'SQ_SYSTEM']->am;
217 $page_links = $am->getLinks($this->
id, SQ_LINK_TYPE_2|SQ_LINK_TYPE_1,
'page_multiple_page_page', TRUE);
235 foreach ($links as $link_data) {
236 if ($link_data[
'sort_order'] == strval(intval($page_number) - 1)) {
237 $page_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link_data[
'minorid']);
256 $cmp = create_function(
'$a,$b',
'return $a[\'sort_order\'] < $b[\'sort_order\'] ? -1 : 1;');
259 usort($page_links, $cmp);
260 foreach ($page_links as $id => $data) {
261 $ids[] = $data[
'minorid'];
277 if (!empty($this->_tmp[
'deleting_links'])) {
280 $current_children = array_flip($this->
attr(
'current_page_ids'));
282 $am = $GLOBALS[
'SQ_SYSTEM']->am;
285 $new_page_children = Array();
287 $new_paths = Array();
288 foreach ($page_links as $data) {
289 $new_page_children[] = $data[
'minorid'];
290 $page = $am->getAsset($data[
'minorid']);
291 unset($current_children[$data[
'minorid']]);
292 $new_paths[$data[
'minorid']] = $this->
getPageNewWebpaths($page, strval(intval($data[
'sort_order']) + 1));
293 if (!empty($this->_tmp[
'no_sort_order_paths'])) {
294 $page->saveWebPaths(Array());
296 $am->forgetAsset($page);
300 foreach (array_keys($current_children) as $id) {
301 $asset_to_delete_paths_from = $am->getAsset($id);
302 if (!is_null($asset_to_delete_paths_from)) {
303 $asset_to_delete_paths_from->saveWebPaths(Array());
304 $am->forgetAsset($asset_to_delete_paths_from);
308 parent::linksUpdated();
310 if($this->
getURL() ==
'') {
315 $valid_paths = make_valid_web_paths(Array(strtolower($this->name)));
316 $good_paths = $GLOBALS[
'SQ_SYSTEM']->am->webPathsInUse($this, $valid_paths, $this->
id, TRUE);
324 if ((isset($this->_tmp[
'no_sort_order_paths']) && $this->_tmp[
'no_sort_order_paths'] ) && (isset($new_paths) && !empty($new_paths))) {
325 foreach ($new_paths as $pageid => $new_webpaths) {
326 $page = $am->getAsset($pageid,
'', TRUE);
328 $page->saveWebPaths($new_webpaths);
329 $am->forgetAsset($page);
335 $GLOBALS[
'SQ_SYSTEM']->setRunLevel($GLOBALS[
'SQ_SYSTEM']->getRunLevel() - SQ_SECURITY_PERMISSIONS - SQ_SECURITY_LOCKING);
336 $this->
setAttrValue(
'current_page_ids', $new_page_children);
337 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
354 $webpaths = $page->getWebPaths();
356 foreach ($webpaths as $idx => $webpath) {
357 if (is_numeric($webpath)) unset($webpaths[$idx]);
360 if (empty($webpaths)) $webpaths = Array($order);
375 $keywords = parent::getAvailableKeywords();
377 $keywords[
'previous_page_href'] = translate(
'cms_page_multiple_page_previous_page_href');
378 $keywords[
'next_page_href'] = translate(
'cms_page_multiple_page_next_page_href');
379 $keywords[
'previous_page_name'] = translate(
'cms_page_multiple_page_previous_page_name');
380 $keywords[
'next_page_name'] = translate(
'cms_page_multiple_page_next_page_name');
381 $keywords[
'previous_page_link'] = translate(
'cms_page_multiple_page_previous_page_link');
382 $keywords[
'next_page_link'] = translate(
'cms_page_multiple_page_next_page_link');
383 $keywords[
'total_page_count'] = translate(
'cms_page_multiple_page_total_page_count');
384 $keywords[
'page_name_x'] = translate(
'cms_page_multiple_page_page_name_x');
385 $keywords[
'page_href_x'] = translate(
'cms_page_multiple_page_page_href_x');
386 $keywords[
'page_link_x'] = translate(
'cms_page_multiple_page_page_link_x');
387 $keywords[
'page_assetid_x'] = translate(
'cms_page_multiple_page_page_assetid_x');
388 $keywords[
'current_page_name'] = translate(
'cms_page_multiple_page_current_page_name');
389 $keywords[
'current_page_attribute_name'] = translate(
'cms_page_multiple_page_current_page_attribute_name');
390 $keywords[
'current_page_number'] = translate(
'cms_page_multiple_page_current_page_number');
391 $keywords[
'current_page_assetid'] = translate(
'cms_page_multiple_page_current_page_assetid');
392 $keywords[
'toc_unordered'] = translate(
'cms_page_multiple_page_toc_unordered');
393 $keywords[
'toc_ordered'] = translate(
'cms_page_multiple_page_toc_ordered');
394 $keywords[
'navigation_menu_selection_list'] = translate(
'cms_page_multiple_page_navigation_menu_selection_list');
395 $keywords[
'multiple_page_assetid'] =
'Multiple Page Asset ID';
413 $import_link = Array(
'asset' => &$this,
'link_type' => $link_type,
'value' =>
'',
'sort_order' => $this->
getNumberofPages(),
'is_dependant' => 1,
'is_exclusive' => 1);
414 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'page_multiple_page_page');
416 $page->setAttrValue(
'name', $name);
417 $page->create($import_link);
436 if (!isset($this->_tmp[
'current_page_id'])) {
437 $this->_tmp[
'current_page_id'] = 0;
438 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAssetFromURL(NULL, NULL, TRUE, TRUE);
439 if (!empty($asset)) {
440 if ($asset->id == $this->id) {
442 $this->_tmp[
'current_page_id'] = 1;
444 $links = $GLOBALS[
'SQ_SYSTEM']->am->getLinkByAsset($this->
id, $asset->id, SQ_LINK_TYPE_2|SQ_LINK_TYPE_1, NULL,
'major', TRUE);
445 if (!empty($links) && $links[0][
'minorid']) {
446 $this->_tmp[
'current_page_id'] = $links[0][
'sort_order'] + 1;
452 return $this->_tmp[
'current_page_id'];
484 if (!isset($this->_tmp[
'current_page_id']) || empty($this->_tmp[
'current_page_id'])) {
488 if ($value ==
'current_page_number') {
489 return $this->_tmp[
'current_page_id'];
492 if (!isset($this->_tmp[
'current_page_asset']) || empty($this->_tmp[
'current_page_asset'])) {
495 if (!isset($this->_tmp[
'current_page_links']) || empty($this->_tmp[
'current_page_links'])) {
496 $this->_tmp[
'current_page_links'] = $this->
getPageLinks();
500 if ($value ==
'navigation_menu_selection_list') {
505 if (strpos($value,
'toc_') !== FALSE) {
507 if (strpos($value,
'_unordered') !== FALSE) {
513 $am = $GLOBALS[
'SQ_SYSTEM']->am;
519 if (strpos($value,
'next_page_') !== FALSE) {
521 foreach ($this->_tmp[
'current_page_links'] as $id => $data) {
522 if ($found_one == TRUE) {
523 $next_page_id = $data[
'minorid'];
526 if ($data[
'sort_order'] == strval(intval($this->_tmp[
'current_page_id']) - 1)) {
532 if (strpos($value,
'previous_page_') !== FALSE) {
535 foreach ($this->_tmp[
'current_page_links'] as $id => $data) {
536 if ($data[
'sort_order'] == strval(intval($this->_tmp[
'current_page_id']) - 1)) {
539 if ($found_one == TRUE) {
540 $prev_page_id = $prev_page;
543 $prev_page = $data[
'minorid'];
549 $page_number_asset = NULL;
550 if (strpos($value,
'page_link_') !== FALSE) {
551 $page_number = str_replace(
'page_link_',
'', $value);
552 $value =
'page_link_';
554 if (strpos($value,
'page_href_') !== FALSE) {
555 $page_number = str_replace(
'page_href_',
'', $value);
556 $value =
'page_href_';
558 if (strpos($value,
'page_name_') !== FALSE) {
559 $page_number = str_replace(
'page_name_',
'', $value);
560 $value =
'page_name_';
562 if (strpos($value,
'page_assetid_') !== FALSE) {
563 $page_number = str_replace(
'page_assetid_',
'', $value);
564 $value =
'page_assetid_';
566 if ($page_number !=
'') {
574 case 'next_page_href':
575 if (!empty($next_page_id)) {
576 $replacement = current($am->getAssetUrl(Array($next_page_id)));
579 case 'next_page_name':
580 if (!empty($next_page_id)) {
581 $next_page_asset = $am->getAsset($next_page_id);
582 if (!is_null($next_page_asset)) {
583 $replacement = $next_page_asset->_getName();
587 case 'next_page_link':
588 if (!empty($next_page_id)) {
589 $next_page_asset = $am->getAsset($next_page_id);
590 if (!is_null($next_page_asset)) {
591 $href = $next_page_asset->getURL();
593 $replacement =
'<a href="'.$href.
'">'.$next_page_asset->_getName().
'</a>';
600 case 'previous_page_href':
601 if (!empty($prev_page_id)) {
602 $replacement = current($am->getAssetUrl(Array($prev_page_id)));
605 case 'previous_page_name':
606 if (!empty($prev_page_id)) {
607 $prev_page_asset = $am->getAsset($prev_page_id);
608 if (!is_null($prev_page_asset)) {
609 $replacement = $prev_page_asset->_getName();
613 case 'previous_page_link':
614 if (!empty($prev_page_id)) {
615 $prev_page_asset = $am->getAsset($prev_page_id);
616 if (!is_null($prev_page_asset)) {
617 $href = $prev_page_asset->getURL();
619 $replacement =
'<a href="'.$href.
'">'.$prev_page_asset->_getName().
'</a>';
626 case 'total_page_count':
627 $replacement = $this->getNumberOfPages();
632 if (!is_null($page_number_asset)) {
633 $href = $page_number_asset->getURL();
635 $replacement =
'<a href="'.$href.
'">'.$page_number_asset->_getName().
'</a>';
640 if (!is_null($page_number_asset)) {
641 $replacement = $page_number_asset->getHref();
645 if (!is_null($page_number_asset)) {
646 $replacement = $page_number_asset->_getName();
649 case 'page_assetid_':
650 if (!is_null($page_number_asset)) {
651 $replacement = $page_number_asset->id;
656 case 'current_page_name':
657 case 'current_page_attribute_name':
658 if (!is_null($this->_tmp[
'current_page_asset'])) {
659 $replacement = $this->_tmp[
'current_page_asset']->_getName();
663 case 'current_page_assetid':
664 if (!is_null($this->_tmp[
'current_page_asset'])) {
665 $replacement = $this->_tmp[
'current_page_asset']->id;
670 case 'multiple_page_assetid':
671 $replacement = $this->id;
676 $replacement = parent::getKeywordReplacement($value);
708 if (is_null($page_one)) $page_one = $this;
723 function paintTOC($ordered=FALSE, $link_current=FALSE)
725 $am = $GLOBALS[
'SQ_SYSTEM']->am;
728 $current_assetid = $links[intval($current) - 1][
'minorid'];
735 foreach ($links as $link_data) {
736 $assetid = $link_data[
'minorid'];
737 $page_asset = $am->getAsset($assetid);
738 if (is_null($page_asset)) {
742 $name = $page_asset->_getName();
744 if ($assetid == $current_assetid && !$link_current) {
747 $href = $page_asset->getURL();
748 echo
'<a href="'.$href.
'">'.$name.
'</a>';
757 $toc = ob_get_clean();
774 $am = $GLOBALS[
'SQ_SYSTEM']->am;
777 $current_assetid = $links[intval($current) - 1][
'minorid'];
779 echo
'<select id="'.$this->getPrefix().
'nav_selection_list'.
'" onchange="location.href=this.options[selectedIndex].value">';
781 foreach ($links as $link_data) {
782 $assetid = $link_data[
'minorid'];
783 $page_asset = $am->getAsset($assetid);
784 if (is_null($page_asset)) {
788 $name = $page_asset->_getName();
789 if ($assetid == $current_assetid && !$link_current) {
790 echo
'<option value="" selected="selected">'.$name;
792 $href = $page_asset->getURL();
793 echo
'<option value="'.$href.
'">'.$name;
799 $nav = ob_get_clean();
818 $this->_tmp[
'no_sort_order_paths'] = $switch;
819 $GLOBALS[
'SQ_SYSTEM']->am->updateLink($linkid,NULL,NULL,$sort_order);
850 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
851 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
853 if (!parent::cloneComponents($clone, $components, $override)) {
854 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
855 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
859 if (in_array(
'attributes', $components) || in_array(
'all', $components)) {
860 $current_ids = Array();
866 $clone->setAttrValue(
'current_page_ids', $current_ids);
867 $clone->saveAttributes();
872 $this->_tmp[
'no_sort_order_paths'] = TRUE;
874 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
875 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();