/** * Returns a queried CMS_page value * Static function. * * @param mixed $id The DB ID of the wanted CMS_page or or "self" or the page codename ($currentPageId is mandatory in this case) * @param string $type The value type to get * @param boolean $public : public value or edited value (default : public) * @param integer $currentPageId : the page reference (required if first parameter is not a page Id) * @return CMS_page value or false on failure to find it * @access public */ static function getPageValue($id, $type, $public = true, $currentPageId = null) { static $pagesInfos; //if no current page given, try to get it from constant if (!io::isPositiveInteger($currentPageId) && defined('CURRENT_PAGE') && io::isPositiveInteger(CURRENT_PAGE)) { $currentPageId = CURRENT_PAGE; } if (!SensitiveIO::isPositiveInteger($id)) { if ($id == 'self' && SensitiveIO::isPositiveInteger($currentPageId)) { $id = $currentPageId; } elseif ($id == 'father' && SensitiveIO::isPositiveInteger($currentPageId)) { $id = CMS_tree::getFather($currentPageId); } elseif (SensitiveIO::isPositiveInteger($currentPageId) && strtolower(io::sanitizeAsciiString($id)) == $id) { return CMS_tree::getPageCodenameValue($id, $currentPageId, $type); } elseif ($type != 'exists') { CMS_grandFather::raiseError("Page id must be positive integer : " . print_r(func_get_args(), true) . ' - ' . io::getCallInfos(3)); return false; } else { return false; } } if (!isset($pagesInfos[$id][$type][$public])) { $page = CMS_tree::getPageByID($id); if (!$page) { $return = false; } else { switch ($type) { case 'exists': $return = $page->getPublication() == RESOURCE_PUBLICATION_PUBLIC ? true : false; break; case 'url': $return = $page->getURL(); break; case 'printurl': $return = $page->getURL(true); break; case 'title': $return = $page->getTitle($public); break; case 'link': case 'linktitle': $return = $page->getLinkTitle($public); break; case 'id': $return = $page->getID(); break; case 'website': $return = $page->getWebsite()->getID(); break; case 'codename': case 'keywords': case 'description': case 'category': case 'author': case 'replyto': case 'copyright': case 'language': case 'robots': case 'pragma': case 'refresh': $method = 'get' . ucfirst($type); $return = $page->{$method}($public); break; case 'metas': $return = $page->getMetas($public); break; case 'level': $return = sizeof(CMS_tree::getLineage($page->getWebsite()->getRoot()->getID(), $page->getID(), false, $public)); break; default: CMS_grandFather::raiseError("Unknown type value to get : " . $type); $return = false; break; } $pagesInfos[$id][$type][$public] = $return; } } return $pagesInfos[$id][$type][$public]; }