本文整理汇总了PHP中Cx\Core\Routing\Url::fromPage方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::fromPage方法的具体用法?PHP Url::fromPage怎么用?PHP Url::fromPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cx\Core\Routing\Url
的用法示例。
在下文中一共展示了Url::fromPage方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _countRequest
/**
* Count request
*
* @global ADONewConnection
* @see _makeStatistics()
*/
function _countRequest()
{
global $objDb;
$page = \Env::get('em')->getRepository('\\Cx\\Core\\ContentManager\\Model\\Entity\\Page')->findOneBy(array('id' => $this->pageId));
if (!$page) {
return;
}
$url = \Cx\Core\Routing\Url::fromPage($page);
if ($page) {
$objDb->Execute('
UPDATE `' . DBPREFIX . 'stats_requests`
SET `visits` = `visits`+1, `page` = "' . substr('/' . $url->getLangDir() . '/' . $url->getPath(), 0, 255) . '", `pageTitle` = "' . $page->getTitle() . '", `sid` = "' . $this->md5Id . '", `timestamp` = ' . $this->currentTime . '
WHERE `pageId` = ' . $this->pageId . ' AND ((`sid` != "' . $this->md5Id . '") OR (`timestamp` <= ' . ($this->currentTime - $this->arrConfig['reload_block_time']['value']) . '))
');
if ($objDb->Affected_Rows() == 0) {
// this is allowed to fail if page was visited with same sid
try {
$objDb->Execute('
INSERT INTO `' . DBPREFIX . 'stats_requests` (`sid`, `pageId`, `page`, `timestamp`, `visits`, `pageTitle`)
VALUES ("' . $this->md5Id . '", ' . $this->pageId . ', "' . substr('/' . $url->getLangDir() . '/' . $url->getPath(), 0, 255) . '", ' . $this->currentTime . ', 1, "' . $page->getTitle() . '")
');
} catch (\PDOException $e) {
}
}
}
$this->_makeStatistics(DBPREFIX . 'stats_requests_summary');
}
示例2: fetch
/**
* Uses the given Entity Manager to retrieve all links for the placeholders
* @param EntityManager $em
*/
public function fetch($em)
{
if ($this->placeholders === null) {
throw new LinkGeneratorException('Seems like scan() was never called before calling fetch().');
}
$qb = $em->createQueryBuilder();
$qb->add('select', new Doctrine\ORM\Query\Expr\Select(array('p')));
$qb->add('from', new Doctrine\ORM\Query\Expr\From('Cx\\Core\\ContentManager\\Model\\Entity\\Page', 'p'));
//build a big or with all the node ids and pages
$arrExprs = null;
$fetchedPages = array();
$pIdx = 0;
foreach ($this->placeholders as $placeholder => $data) {
if ($data['type'] == 'id') {
# page is referenced by NODE-ID (i.e.: [[NODE_1]])
if (isset($fetchedPages[$data['nodeid']][$data['lang']])) {
continue;
}
$arrExprs[] = $qb->expr()->andx($qb->expr()->eq('p.node', $data['nodeid']), $qb->expr()->eq('p.lang', $data['lang']));
$fetchedPages[$data['nodeid']][$data['lang']] = true;
} else {
# page is referenced by module (i.e.: [[NODE_SHOP_CART]])
if (isset($fetchedPages[$data['module']][$data['cmd']][$data['lang']])) {
continue;
}
$arrExprs[] = $qb->expr()->andx($qb->expr()->eq('p.type', ':type'), $qb->expr()->eq('p.module', ':module_' . $pIdx), $qb->expr()->eq('p.cmd', ':cmd_' . $pIdx), $qb->expr()->eq('p.lang', $data['lang']));
$qb->setParameter('module_' . $pIdx, $data['module']);
$qb->setParameter('cmd_' . $pIdx, empty($data['cmd']) ? null : $data['cmd']);
$qb->setParameter('type', \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION);
$fetchedPages[$data['module']][$data['cmd']][$data['lang']] = true;
$pIdx++;
}
}
//fetch the nodes if there are any in the query
if ($arrExprs) {
foreach ($arrExprs as $expr) {
$qb->orWhere($expr);
}
$pages = $qb->getQuery()->getResult();
foreach ($pages as $page) {
// build placeholder's value -> URL
$url = \Cx\Core\Routing\Url::fromPage($page);
$placeholderByApp = '';
$placeholderById = \Cx\Core\ContentManager\Model\Entity\Page::PLACEHOLDER_PREFIX . $page->getNode()->getId();
$this->placeholders[$placeholderById . '_' . $page->getLang()] = $url;
if ($page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION) {
$module = $page->getModule();
$cmd = $page->getCmd();
$placeholderByApp = \Cx\Core\ContentManager\Model\Entity\Page::PLACEHOLDER_PREFIX;
$placeholderByApp .= strtoupper($module . (empty($cmd) ? '' : '_' . $cmd));
$this->placeholders[$placeholderByApp . '_' . $page->getLang()] = $url;
}
if ($page->getLang() == FRONTEND_LANG_ID) {
$this->placeholders[$placeholderById] = $url;
if (!empty($placeholderByApp)) {
$this->placeholders[$placeholderByApp] = $url;
}
}
}
}
// there might be some placeholders we were unable to resolve.
// try to resolve them by using the fallback-language-reverse-lookup
// methode provided by \Cx\Core\Routing\Url::fromModuleAndCmd().
foreach ($this->placeholders as $placeholder => $data) {
if (!$data instanceof \Cx\Core\Routing\Url) {
if (!empty($data['module'])) {
try {
$url = \Cx\Core\Routing\Url::fromModuleAndCmd($data['module'], $data['cmd'], $data['lang'], array(), '', false);
if ($this->absoluteUris && $this->domain) {
$url->setDomain($this->domain);
}
$this->placeholders[$placeholder] = $url->toString($this->absoluteUris);
} catch (\Cx\Core\Routing\UrlException $e) {
if ($data['lang'] && $data['cmd']) {
$url = \Cx\Core\Routing\Url::fromModuleAndCmd($data['module'], $data['cmd'] . '_' . $data['lang'], FRONTEND_LANG_ID);
if ($this->absoluteUris && $this->domain) {
$url->setDomain($this->domain);
}
$this->placeholders[$placeholder] = $url->toString($this->absoluteUris);
} else {
if ($data['lang'] && empty($data['cmd'])) {
$url = \Cx\Core\Routing\Url::fromModuleAndCmd($data['module'], $data['lang'], FRONTEND_LANG_ID);
if ($this->absoluteUris && $this->domain) {
$url->setDomain($this->domain);
}
$this->placeholders[$placeholder] = $url->toString($this->absoluteUris);
} else {
$url = \Cx\Core\Routing\Url::fromModuleAndCmd('Error', '', $data['lang']);
if ($this->absoluteUris && $this->domain) {
$url->setDomain($this->domain);
}
$this->placeholders[$placeholder] = $url->toString($this->absoluteUris);
}
}
}
} else {
//.........这里部分代码省略.........
示例3: getSearchResults
/**
* Gets the search results.
*
* @return mixed Parsed content.
*/
public function getSearchResults()
{
global $_ARRAYLANG;
$this->template->addBlockfile('ADMIN_CONTENT', 'search', 'Default.html');
if (!empty($this->term)) {
$pages = $this->getSearchedPages();
$countPages = $this->countSearchedPages();
usort($pages, array($this, 'sortPages'));
if ($countPages > 0) {
$parameter = '&cmd=Search' . (empty($this->term) ? '' : '&term=' . contrexx_raw2encodedUrl($this->term));
$paging = \Paging::get($parameter, '', $countPages, 0, true, null, 'pos');
$this->template->setVariable(array('TXT_SEARCH_RESULTS_COMMENT' => sprintf($_ARRAYLANG['TXT_SEARCH_RESULTS_COMMENT'], $this->term, $countPages), 'TXT_SEARCH_TITLE' => $_ARRAYLANG['TXT_NAVIGATION_TITLE'], 'TXT_SEARCH_CONTENT_TITLE' => $_ARRAYLANG['TXT_PAGETITLE'], 'TXT_SEARCH_SLUG' => $_ARRAYLANG['TXT_CORE_CM_SLUG'], 'TXT_SEARCH_LANG' => $_ARRAYLANG['TXT_LANGUAGE'], 'SEARCH_PAGING' => $paging));
foreach ($pages as $page) {
// used for alias pages, because they have no language
if ($page->getLang() == "") {
$languages = "";
foreach (\FWLanguage::getIdArray('frontend') as $langId) {
$languages[] = \FWLanguage::getLanguageCodeById($langId);
}
} else {
$languages = array(\FWLanguage::getLanguageCodeById($page->getLang()));
}
$aliasLanguages = implode(', ', $languages);
$originalPage = $page;
$link = 'index.php?cmd=ContentManager&page=' . $page->getId();
if ($page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_ALIAS) {
$pageRepo = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
if ($originalPage->isTargetInternal()) {
// is internal target, get target page
$originalPage = $pageRepo->getTargetPage($page);
} else {
// is an external target, set the link to the external targets url
$originalPage = new \Cx\Core\ContentManager\Model\Entity\Page();
$originalPage->setTitle($page->getTarget());
$link = $page->getTarget();
}
}
$this->template->setVariable(array('SEARCH_RESULT_BACKEND_LINK' => $link, 'SEARCH_RESULT_TITLE' => $originalPage->getTitle(), 'SEARCH_RESULT_CONTENT_TITLE' => $originalPage->getContentTitle(), 'SEARCH_RESULT_SLUG' => substr($page->getPath(), 1), 'SEARCH_RESULT_LANG' => $aliasLanguages, 'SEARCH_RESULT_FRONTEND_LINK' => \Cx\Core\Routing\Url::fromPage($page)));
$this->template->parse('search_result_row');
}
} else {
$this->template->setVariable(array('TXT_SEARCH_NO_RESULTS' => sprintf($_ARRAYLANG['TXT_SEARCH_NO_RESULTS'], $this->term)));
}
} else {
$this->template->setVariable(array('TXT_SEARCH_NO_TERM' => $_ARRAYLANG['TXT_SEARCH_NO_TERM']));
}
}
示例4: _showMostViewedPages
/**
* Show most viewed pages
*
* Show a list of the most viewed pages
*
* @access private
* @global array
* @see _initMostViewedPagesStatistics()
*/
function _showMostViewedPages()
{
global $_ARRAYLANG;
$i = 0;
$this->_objTpl->addBlockfile('STATS_REQUESTS_CONTENT', 'requests_block', 'module_stats_mvp.html');
$this->pageTitle = $_ARRAYLANG['TXT_MOST_POPULAR_PAGES'];
$this->_initMostViewedPages();
// set language variables
$this->_objTpl->setVariable(array('TXT_MOST_POPULAR_PAGES' => $_ARRAYLANG['TXT_MOST_POPULAR_PAGES'], 'TXT_PAGE' => $_ARRAYLANG['TXT_PAGE'], 'TXT_REQUESTS' => $_ARRAYLANG['TXT_REQUESTS'], 'TXT_LAST_REQUEST' => $_ARRAYLANG['TXT_LAST_REQUEST']));
if (count($this->arrMostViewedPages) > 0) {
foreach ($this->arrMostViewedPages as $stats) {
$page = \Env::get('em')->getRepository('\\Cx\\Core\\ContentManager\\Model\\Entity\\Page')->findOneBy(array('id' => $stats['id']));
if ($page) {
$url = \Cx\Core\Routing\Url::fromPage($page);
$title = '<a href="' . $url . '" target="_blank">' . $page->getTitle() . '</a> (/' . $url->getLangDir() . '/' . $url->getPath() . ')';
} else {
$title = '<span>' . $stats['title'] . '</span> (' . $stats['page'] . ')';
}
$this->_objTpl->setVariable(array('STATS_REQUESTS_PAGE' => $title, 'STATS_REQUESTS_REQUESTS' => $this->_makePercentBar(300, 10, $stats['requests'] * 100 / $this->mostViewedPagesSum, 100, 1, '') . ' ' . round($stats['requests'] * 100 / $this->mostViewedPagesSum, 2) . '%' . ' (' . $stats['requests'] . ')', 'STATS_REQUESTS_LAST_REQUEST' => $stats['last_request'], 'STATS_REQUESTS_ROW_CLASS' => $i % 2 == 0 ? 'row2' : 'row1'));
$this->_objTpl->parse('stats_requests_mvp');
$this->_objTpl->hideBlock('stats_requests_nodata');
$i++;
}
} else {
$this->_objTpl->hideBlock('stats_requests');
$this->_objTpl->setVariable(array('TXT_NO_DATA_AVAILABLE' => $_ARRAYLANG['TXT_NO_DATA_AVAILABLE']));
}
$this->_objTpl->parse('requests_block');
}
示例5: getURL
/**
* Returns "$protocolAndDomainWithPathOffset/link/to/page$params.
* Notice that there is no trailing slash inserted after the link.
* If you need one, prepend it to $params.
* @param string $protocolAndDomain 'http://example.com/cms' - will generate absolute link if left empty
* @param string $params '?a=b'
*
*/
public function getURL($protocolAndDomainWithPathOffset, $params)
{
return \Cx\Core\Routing\Url::fromPage($this, $params);
}
示例6: getSelectedPages
/**
* Get selected pages for a block to display in overview page
* @see $this->_showOverview()
*
* @param integer $blockId Block id
* @param string $placeholder Placeholder (global, direct)
* @param \ContentTree $objContentTree ContentTree instance
* @param \Cx\Core\ContentManager\Model\Repository\PageRepository $pageRepo PageRepository instance
*
* @return string Return the selected pages as <ul><li></li></ul>
*/
function getSelectedPages($blockId, $placeholder, \ContentTree $objContentTree, \Cx\Core\ContentManager\Model\Repository\PageRepository $pageRepo)
{
$pageLinkTemplate = '<li><a href="%1$s" target="_blank">%2$s</a></li>';
$blockAssociatedPageIds = $this->_getAssociatedPageIds($blockId, $placeholder);
$selectedPages = array();
$strSelectedPages = '';
foreach ($objContentTree->getTree() as $arrData) {
if (!in_array($arrData['catid'], $blockAssociatedPageIds)) {
continue;
}
$page = $pageRepo->findOneById($arrData['catid']);
if (!$page) {
continue;
}
$selectedPages[] = sprintf($pageLinkTemplate, \Cx\Core\Routing\Url::fromPage($page)->toString(), contrexx_raw2xhtml($arrData['catname']));
}
if ($selectedPages) {
$strSelectedPages = '<ul>' . implode($selectedPages) . '</ul>';
}
return $strSelectedPages;
}
示例7: getTrail
/**
* Get trail
* @return string The trail with links
*/
public function getTrail()
{
$lang = $this->page->getLang();
$node = $this->page->getNode()->getParent();
$result = '';
while ($node->getLvl() > 0) {
$page = $node->getPage($lang);
$title = $page->getTitle();
$path = \Cx\Core\Routing\Url::fromPage($page);
$result = '<a href="' . $path . '" title="' . contrexx_raw2xhtml($title) . '">' . contrexx_raw2xhtml($title) . '</a>' . $this->separator . ' ' . $result;
$node = $node->getParent();
}
return $result;
}
示例8: parseLetterIndexList
protected function parseLetterIndexList($URI, $paramName, $selectedLetter)
{
global $_CORELANG;
if ($this->_objTpl->blockExists('access_user_letter_index_list')) {
$arrLetters[] = 48;
$arrLetters = array_merge($arrLetters, range(65, 90));
// ascii codes of characters "A" to "Z"
$arrLetters[] = '';
$selfUri = \Cx\Core\Routing\Url::fromPage(\Cx\Core\Core\Controller\Cx::instanciate()->getPage());
foreach ($arrLetters as $letter) {
switch ($letter) {
case 48:
$parsedLetter = '#';
break;
case '':
$parsedLetter = $_CORELANG['TXT_ACCESS_ALL'];
break;
default:
$parsedLetter = chr($letter);
break;
}
if ($letter == '' && $selectedLetter == '' || chr($letter) == $selectedLetter) {
$parsedLetter = '<strong>' . $parsedLetter . '</strong>';
}
$uriLetter = null;
if (!empty($letter)) {
$uriLetter = chr($letter);
}
$selfUri->setParam($paramName, $uriLetter);
$this->_objTpl->setVariable(array($this->modulePrefix . 'USER_LETTER_INDEX_URI' => $URI . (!empty($letter) ? '&' . $paramName . '=' . chr($letter) : null), $this->modulePrefix . 'USER_LETTER_INDEX_LETTER' => $parsedLetter, $this->modulePrefix . 'USER_LETTER_INDEX_URI_SELF' => $selfUri));
$this->_objTpl->parse('access_user_letter_index_list');
}
}
}
示例9: resolve
//.........这里部分代码省略.........
\Cx\Core\Csrf\Controller\Csrf::header('Location: index.php?section=Error&id=404');
exit;
}*/
\Env::get('init')->setCustomizedTheme($page->getSkin(), $page->getCustomContent(), $page->getUseSkinForAllChannels());
$themesPages = \Env::get('init')->getTemplates($page);
//replace the {NODE_<ID>_<LANG>}- placeholders
\LinkGenerator::parseTemplate($themesPages);
//TODO: analyze those, take action.
//$page_protected = $objResult->fields['protected'];
$page_protected = $page->isFrontendProtected();
//$page_access_id = $objResult->fields['frontend_access_id'];
$page_template = $themesPages['content'];
// Authentification for protected pages
// This is only done for regular page requests ($isRegularPageRequest == TRUE)
$this->checkPageFrontendProtection($page, $history);
//TODO: history
}
// TODO: refactor system to be able to remove this backward compatibility
// Backwards compatibility for code pre Contrexx 3.0 (update)
$_GET['cmd'] = $_POST['cmd'] = $_REQUEST['cmd'] = $command;
$_GET['section'] = $_POST['section'] = $_REQUEST['section'] = $section;
// the system should directly use $this->url->getParamArray() instead of using the super globals
$qsArr = $this->url->getParamArray();
foreach ($qsArr as $qsParam => $qsArgument) {
$_GET[$qsParam] = $_REQUEST[$qsParam] = $qsArgument;
}
// To clone any module, use an optional integer cmd suffix.
// E.g.: "shop2", "gallery5", etc.
// Mind that you *MUST* copy all necessary database tables, and fix any
// references to your module (section and cmd parameters, database tables)
// using the MODULE_INDEX constant in the right place both in your code
// *AND* templates!
// See the Shop module for an example.
$arrMatch = array();
if (preg_match('/^(\\D+)(\\d+)$/', $section, $arrMatch)) {
// The plain section/module name, used below
$plainSection = $arrMatch[1];
} else {
$plainSection = $section;
}
// The module index.
// An empty or 1 (one) index represents the same (default) module,
// values 2 (two) and larger represent distinct instances.
$moduleIndex = empty($arrMatch[2]) || $arrMatch[2] == 1 ? '' : $arrMatch[2];
define('MODULE_INDEX', $moduleIndex);
// Start page or default page for no section
if ($section == 'Home') {
if (!\Env::get('init')->hasCustomContent()) {
$page_template = $themesPages['home'];
} else {
$page_template = $themesPages['content'];
}
}
// this is the case for standalone and backend requests
if (!$this->page) {
return null;
}
$this->page = clone $this->page;
$this->page->setVirtual();
// check for further URL parts to resolve
if ($this->page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION) {
// does this work for fallback(/aliases)?
$additionalPath = substr('/' . $this->url->getSuggestedTargetPath(), strlen($this->page->getPath()));
$componentController = $this->em->getRepository('Cx\\Core\\Core\\Model\\Entity\\SystemComponent')->findOneBy(array('name' => $this->page->getModule()));
if ($componentController) {
$parts = array();
if (!empty($additionalPath)) {
$parts = explode('/', substr($additionalPath, 1));
}
$componentController->resolve($parts, $this->page);
}
}
$canonicalPage = $this->page;
if ($this->urlPage && $this->urlPage->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_SYMLINK) {
$canonicalPage = $this->pageRepo->getTargetPage($this->urlPage);
}
// don't set canonical page when replying with an application page
// since we can't know which application pages share the same content.
// Exception to this rule: if we're not on main domain, we know that
// the canonical version is the same page using the main domain.
$cx = \Cx\Core\Core\Controller\Cx::instanciate();
$domainRepo = $cx->getDb()->getEntityManager()->getRepository('Cx\\Core\\Net\\Model\\Entity\\Domain');
// set canonical page only in case it hasn't been set already
$linkHeader = preg_grep('/^Link:.*canonical["\']$/', headers_list());
if ($linkHeader) {
$linkHeader = current($linkHeader);
$linkHeaderParts = explode(':', $linkHeader, 2);
$link = trim($linkHeaderParts[1]);
$this->headers['Link'] = $link;
}
if ($canonicalPage->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION && $this->url->getDomain() == $domainRepo->getMainDomain()->getName()) {
return $this->page;
}
if (!$linkHeader) {
$link = '<' . \Cx\Core\Routing\Url::fromPage($canonicalPage)->toString() . '>; rel="canonical"';
header('Link: ' . $link);
$this->headers['Link'] = $link;
}
return $this->page;
}
示例10: parseLocaleList
/**
* Parses locale list in a template file
* @todo Does language list only for now. Update as soon as locales are available
* @param \Cx\Core\Html\Sigma $template Template file to parse locales in
*/
public function parseLocaleList($template)
{
if (!$template->blockExists('locale_alternate_list')) {
return;
}
$currentPage = $this->cx->getPage();
$listProtectedPages = \Cx\Core\Setting\Controller\Setting::getValue('coreListProtectedPages', 'Config') == 'on';
foreach (\FWLanguage::getActiveFrontendLanguages() as $lang) {
$langId = $lang['id'];
$lang = $lang['lang'];
$langPage = $currentPage->getNode()->getPage($langId);
// if page is not translated, inactive (incl. scheduled publishing) or protected
if (!$langPage || !$langPage->isActive() || !$listProtectedPages && $langPage->isFrontendProtected() && !\Permission::checkAccess($langPage->getFrontendAccessId(), 'dynamic', true)) {
continue;
}
$template->setVariable(array('PAGE_LINK' => contrexx_raw2xhtml(\Cx\Core\Routing\Url::fromPage($langPage)->toString()), 'PAGE_TITLE' => contrexx_raw2xhtml($langPage->getTitle()), 'LOCALE' => $lang, 'LANGUAGE_CODE' => $lang));
$template->parse('locale_alternate_list');
}
}
示例11: renderElement
/**
* Renders the PageTree element
* @param type $title
* @param type $level
* @param type $hasChilds
* @param type $lang
* @param type $path
* @param type $current
* @param type $page
* @return type
*/
protected function renderElement($title, $level, $hasChilds, $lang, $path, $current, $page)
{
return "\t" . '<url>' . "\n\t\t" . '<loc>' . \Cx\Core\Routing\Url::fromPage($page)->toString() . '</loc>' . "\n\t\t" . '<lastmod>' . $this->getLastModificationDate($page) . '</lastmod>' . "\n\t\t" . '<changefreq>' . $this->getChangingFrequency($page) . '</changefreq>' . "\n\t\t" . '<priority>0.5</priority>' . "\n\t" . '</url>' . "\n";
}