本文整理汇总了PHP中shRouter::shPageInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP shRouter::shPageInfo方法的具体用法?PHP shRouter::shPageInfo怎么用?PHP shRouter::shPageInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shRouter
的用法示例。
在下文中一共展示了shRouter::shPageInfo方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateShurls
public static function updateShurls()
{
$sefConfig =& shRouter::shGetConfig();
// set the short link tag
$shPageInfo =& shRouter::shPageInfo();
$shPageInfo->shURL = '';
if ($sefConfig->enablePageId && !$sefConfig->stopCreatingShurls) {
try {
jimport('joomla.utilities.string');
$nonSefUrl = JString::ltrim($shPageInfo->shCurrentPageNonSef, '/');
$nonSefUrl = shSortURL($nonSefUrl);
// remove tracking vars (Google Analytics)
$nonSefUrl = Sh404sefHelperGeneral::stripTrackingVarsFromNonSef($nonSefUrl);
// try to get the current shURL, if any
$shURL = Sh404sefHelperDb::selectResult('#__sh404sef_pageids', array('pageid'), array('newurl' => $nonSefUrl));
// if none, we may have to create one
if (empty($shURL)) {
$shURL = self::_createShurl($nonSefUrl);
}
// insert in head and header, if not empty
if (!empty($shURL)) {
$fullShURL = JString::ltrim($GLOBALS['shConfigLiveSite'], '/') . '/' . $shURL;
$document =& JFactory::getDocument();
if ($sefConfig->insertShortlinkTag) {
$document->addHeadLink($fullShURL, 'shortlink');
// also add header, especially for HEAD requests
JResponse::setHeader('Link', '<' . $fullShURL . '>; rel=shortlink', true);
}
if ($sefConfig->insertRevCanTag) {
$document->addHeadLink($fullShURL, 'canonical', 'rev', array('type' => 'text/html'));
}
if ($sefConfig->insertAltShorterTag) {
$document->addHeadLink($fullShURL, 'alternate shorter');
}
// store for reuse
$shPageInfo->shURL = $shURL;
}
} catch (Sh404sefExceptionDefault $e) {
}
}
}
示例2: revert
function revert(&$url_array, $pos)
{
$sefConfig =& shRouter::shGetConfig();
// get DB
$database =& JFactory::getDBO();
$QUERY_STRING = '';
$req = implode('/', $url_array);
if ($req != '/') {
$req = JString::ltrim($req, '/');
}
// V x
$req = str_replace("//", "/", $req);
_log('sef404 reverting URL : ' . $req);
// read from db
$sql = "SELECT oldurl, newurl FROM #__redirection WHERE oldurl = " . $database->Quote($req) . " ORDER BY rank ASC LIMIT 1";
// V 1.2.4.q
$database->setQuery($sql);
$row = $database->loadObject();
if ($row) {
// use the cached url
$string = $row->newurl;
// check for urls using wrong letter case, 301 redirect to correct url case
$shPageInfo =& shRouter::shPageInfo();
if (empty($shPageInfo->autoRedirectsDisabled) && $sefConfig->redirectToCorrectCaseUrl) {
// if initial query exactly matches oldurl found in db, then case is correct
// else we redirect to the url found in db, but we also need to append query string to it !
if ($req != $row->oldurl) {
// can only be different from case
// what is the url we should redirect to ?
$targetUrl = str_replace($req, $row->oldurl, $shPageInfo->shSaveRequestURI);
$targetUrl = $shPageInfo->URI->protocol . '://' . $shPageInfo->URI->host . (!sh404SEF_USE_NON_STANDARD_PORT || empty($shPageInfo->URI->port) ? '' : ':' . $shPageInfo->URI->port) . $targetUrl . (empty($shPageInfo->URI->anchor) ? '' : '#' . $shPageInfo->URI->anchor);
// perform redirect
_log('Redirecting to correct url case : from ' . $req . ' to ' . $targetUrl);
shRedirect($targetUrl);
}
}
// keep going if we did not redirect to correct case
_log('sef404 reverting URL : found : ' . $row->newurl);
// update the count
$database->setQuery("UPDATE #__redirection SET cpt=(cpt+1) WHERE `newurl` = " . $database->Quote($row->newurl) . " AND `oldurl` = " . $database->Quote($row->oldurl));
// V 1.2.4.q
$database->query();
// now we must merge query string from request and POST data with that found in db
// as there might be common variables. For instance, limit=5 in the DB
// but limit=10 as been pass as POST DATA from a drop-down list item
$otherVars = empty($shPageInfo->URI->querystring) ? array() : $shPageInfo->URI->querystring;
$postVars = JRequest::get('post');
$otherVars = array_merge($otherVars, $postVars);
if (!empty($otherVars)) {
foreach ($otherVars as $key => $value) {
// if var exists in the incoming url, override it with querystring or post var value
if (shGetURLVar($string, $key, null) !== null) {
// if we change the value of limit, we must reset limitstart, or we may end up
// with weird page number
if ($key == 'limit') {
$limit = shGetURLVar($string, 'limit', null);
if (!is_null($limit) && $value != $limit) {
// we are changing limit value : is there a limitstart ?
$limitstart = shGetURLVar($string, 'limitstart', null);
if (!is_null($limitstart)) {
// calculate a new limitstart
$limitstart = empty($limit) ? 0 : floor($limitstart / $limit) - 1;
$limitstart = $limitstart < 0 ? 0 : $limitstart;
// and set it
$string = shSetURLVar($string, 'limitstart', $limitstart, $canBeEmpty = true);
// kill any remaining limitstart value
if (array_key_exists('limitstart', $otherVars)) {
unset($otherVars['limitstart']);
}
}
}
}
// now apply new value for the key
$string = shSetURLVar($string, $key, $value);
}
}
}
$string = str_replace('&', '&', $string);
$QUERY_STRING = str_replace('index.php?', '', $string);
// so weird : because of how Joomla choose to not include $limit in urls, I must remove &limit=xx from the restored url
// I do have to store it in db however, otherwise same sef will be associated with same non-sef, and then
// Joomla content views will be screwed up also as they guess $limit and reset JRequest('limit');
if (!empty($QUERY_STRING)) {
$QUERY_STRING = '&' . $QUERY_STRING;
$option = shGetURLVar($QUERY_STRING, 'option');
$layout = shGetURLVar($QUERY_STRING, 'layout');
if (empty($layout)) {
$layout = 'default';
}
$view = shGetURLVar($QUERY_STRING, 'view');
if ($option == 'com_content' && $layout != 'blog' && ($view == 'category' || $view == 'section')) {
$limit = shGetURLVar($QUERY_STRING, 'limit');
//$QUERY_STRING = shCleanUpVar( $QUERY_STRING, 'limit');
// but we need to keep it, because of a bug in Joomla, which I could not trace
// whereby the user state limit value in com_content.default.limit is that of the blog instead of that of the current view
global $mainframe;
$mainframe->setUserState('com_content.sh.' . $view . '.' . $layout . '.limit', $limit);
//_log( 'Removing limit from reverted url, to : ' . $QUERY_STRING);
}
$QUERY_STRING = JString::ltrim($QUERY_STRING, '&');
//.........这里部分代码省略.........
示例3: shCheckVMCookieRedirect
function shCheckVMCookieRedirect()
{
$shPageInfo =& shRouter::shPageInfo();
if (shIsSearchEngine() && strpos($shPageInfo->shCurrentPageURL, 'vmchk/') !== false) {
shRedirect(str_replace('vmchk/', '', $shPageInfo->shCurrentPageURL));
}
}
示例4: _buildSefRoute
function _buildSefRoute(&$uri)
{
$sefConfig =& shRouter::shGetConfig();
$shPageInfo =& shRouter::shPageInfo();
$menu =& shRouter::shGetMenu();
// keep a copy of Joomla original URI, which has article names in it (ie: 43:article-title)
$originalUri = clone $uri;
shNormalizeNonSefUri($uri, $menu);
shNormalizeNonSefUri($originalUri, $menu, $removeSlugs = false);
// do our job!
$query = $uri->getQuery(false);
$route = shSefRelToAbs('index.php?' . $query, null, $uri, $originalUri);
$route = ltrim(str_replace($GLOBALS['shConfigLiveSite'], '', $route), '/');
$route = $shPageInfo->base . ($route == '/' ? '' : $route);
// find path
if (strpos($route, '?') !== false) {
$parts = explode('?', $route);
if ($sefConfig->shRewriteMode == 2) {
// '/index.php?/'
// need to extract the first part of the query, which is actually the path
// and store it as the path
$tmpParts = explode('/index.php?/', $route);
$tmpPath = '';
if (isset($tmpParts[1])) {
// there is somethings after the /index.php?/
if (strpos($tmpParts[1], '?') !== false) {
// but this can also have parameters, so only get the path
$tmpPathParts = explode('?', $tmpParts[1]);
$tmpPath = $tmpPathParts[0];
} else {
$tmpPath = $tmpParts[1];
}
}
$path = $tmpParts[0] . '/index.php?/' . $tmpPath;
} else {
// there are some query vars, just use the path
$path = $parts[0];
}
} else {
$path = $route;
}
$uri->setPath($path);
}
示例5: shDoTitleTags
function shDoTitleTags(&$buffer)
{
// Replace TITLE and DESCRIPTION and KEYWORDS
if (empty($buffer)) {
return;
}
global $shCustomTitleTag, $shCustomDescriptionTag, $shCustomKeywordsTag, $shCustomRobotsTag, $shCustomLangTag, $shHomeLink, $shMosConfig_lang, $shMosConfig_locale;
$database =& JFactory::getDBO();
$sefConfig =& shRouter::shGetConfig();
$shPageInfo =& shRouter::shPageInfo();
// get page details gathered by system plugin
// V 1.2.4.t protect against error if using shCustomtags without sh404SEF activated
// this should not happen, so we simply do nothing
if (!isset($sefConfig) || empty($shPageInfo->shCurrentPageNonSef)) {
return;
}
// fix bug in Joomla search
//$shUri = null;
//$shOriginalUri = null;
//$buffer = str_replace( 'action="index.php"', 'action="'.shSefRelToabs('index.php', '', $shUri, $shUri, $shOriginalUri).'"', $buffer);
// check if there is a manually created set of tags from tags file
// need to get them from DB
if ($sefConfig->shMetaManagementActivated) {
// plugin system to automatically build title and description tags on a component per component basis
$option = JRequest::getVar('option');
$shDoNotOverride = in_array(str_replace('com_', '', $option), $sefConfig->shDoNotOverrideOwnSef);
if (file_exists(sh404SEF_ABS_PATH . 'components/' . $option . '/meta_ext/' . $option . '.php') && ($shDoNotOverride || !$shDoNotOverride && !file_exists(sh404SEF_ABS_PATH . 'components/com_sh404sef/meta_ext/' . $option . '.php'))) {
_log('Loading component own meta plugin');
// Load the plug-in file
include sh404SEF_ABS_PATH . 'components/' . $option . '/meta_ext/' . $option . '.php';
} else {
if (file_exists(sh404SEF_ABS_PATH . 'components/com_sh404sef/meta_ext/' . $option . '.php')) {
_log('Loading built-in meta plugin');
include sh404SEF_ABS_PATH . 'components/com_sh404sef/meta_ext/' . $option . '.php';
}
}
// is this homepage ? set flag for future use
$isHome = shSortUrl($shPageInfo->shCurrentPageNonSef) == shCleanUpAnchor($shHomeLink);
// now read manually setup tags
if ($isHome) {
// V 1.2.4.t homepage custom tags
$sql = 'SELECT id, metadesc, metakey, metatitle, metalang, metarobots FROM #__sh404SEF_meta WHERE newurl = \'' . sh404SEF_HOMEPAGE_CODE . '\'';
} else {
// V 1.2.4.t make sure we have lang info and properly sorted params
if (!preg_match('/(&|\\?)lang=[a-zA-Z]{2,3}/iU', $shPageInfo->shCurrentPageNonSef)) {
// no lang string, let's add default
$shTemp = explode('-', $GLOBALS['shMosConfig_locale']);
$shLangTemp = $shTemp[0] ? $shTemp[0] : 'en';
$shPageInfo->shCurrentPageNonSef .= '&lang=' . $shLangTemp;
}
$shPageInfo->shCurrentPageNonSef = shSortUrl($shPageInfo->shCurrentPageNonSef);
$sql = 'SELECT id, metadesc, metakey, metatitle, metalang, metarobots FROM #__sh404SEF_meta WHERE newurl = \'' . ltrim($shPageInfo->shCurrentPageNonSef, '/') . '\'';
}
$shCustomTags = null;
$database->setQuery($sql);
$shCustomTags = $database->loadObject();
if (!empty($shCustomTags)) {
$shCustomTitleTag = !empty($shCustomTags->metatitle) ? $shCustomTags->metatitle : $shCustomTitleTag;
$shCustomDescriptionTag = !empty($shCustomTags->metadesc) ? $shCustomTags->metadesc : $shCustomDescriptionTag;
$shCustomKeywordsTag = !empty($shCustomTags->metakey) ? $shCustomTags->metakey : $shCustomKeywordsTag;
$shCustomRobotsTag = !empty($shCustomTags->metarobots) ? $shCustomTags->metarobots : $shCustomRobotsTag;
$shCustomLangTag = !empty($shCustomTags->metalang) ? $shCustomTags->metalang : $shCustomLangTag;
}
// then insert them in page
if (empty($shCustomTitleTag)) {
$document =& JFactory::getDocument();
$shCustomTitleTag = $document->getTitle();
}
if (!empty($shCustomTitleTag)) {
$prepend = $isHome ? '' : $sefConfig->prependToPageTitle;
$append = $isHome ? '' : $sefConfig->appendToPageTitle;
$buffer = preg_replace('/\\<\\s*title\\s*\\>.*\\<\\s*\\/title\\s*\\>/isU', '<title>' . shCleanUpTitle($prepend . $shCustomTitleTag . $append) . '</title>', $buffer);
$buffer = preg_replace('/\\<\\s*meta\\s+name\\s*=\\s*"title.*\\/\\>/isU', '', $buffer);
// remove Joomla title meta
}
if (!is_null($shCustomDescriptionTag)) {
$buffer = preg_replace('/\\<\\s*meta\\s+name\\s*=\\s*"description.*\\/\\>/isU', '<meta name="description" content="' . shCleanUpDesc($shCustomDescriptionTag) . '" />', $buffer);
}
if (!is_null($shCustomKeywordsTag)) {
$buffer = preg_replace('/\\<\\s*meta\\s+name\\s*=\\s*"keywords.*\\/\\>/isU', '<meta name="keywords" content="' . shCleanUpDesc($shCustomKeywordsTag) . '" />', $buffer);
}
if (!is_null($shCustomRobotsTag)) {
if (strpos($buffer, '<meta name="robots" content="') !== false) {
$buffer = preg_replace('/\\<\\s*meta\\s+name\\s*=\\s*"robots.*\\/\\>/isU', '<meta name="robots" content="' . $shCustomRobotsTag . '" />', $buffer);
} else {
if (!empty($shCustomRobotsTag)) {
$buffer = shInsertCustomTagInBuffer($buffer, '</head>', 'before', '<meta name="robots" content="' . $shCustomRobotsTag . '" />', 'first');
}
}
}
if (!is_null($shCustomLangTag)) {
$shLang = $shCustomLangTag;
if (strpos($buffer, '<meta http-equiv="Content-Language"') !== false) {
$buffer = preg_replace('/\\<\\s*meta\\s+http-equiv\\s*=\\s*"Content-Language".*\\/\\>/isU', '<meta http-equiv="Content-Language" content="' . $shCustomLangTag . '" />', $buffer);
} else {
$buffer = shInsertCustomTagInBuffer($buffer, '</head>', 'before', '<meta http-equiv="Content-Language" content="' . $shCustomLangTag . '" />', 'first');
}
}
// remove Generator tag
if ($sefConfig->shRemoveGeneratorTag) {
//.........这里部分代码省略.........
示例6: shDoHeadersChanges
function shDoHeadersChanges()
{
global $shCanonicalTag;
$sefConfig =& shRouter::shGetConfig();
$shPageInfo =& shRouter::shPageInfo();
// get page details gathered by system plugin
if (!isset($sefConfig) || empty($sefConfig->shMetaManagementActivated) || empty($shPageInfo->shCurrentPageNonSef)) {
return;
}
// include plugin to build canonical if needed
shIncludeMetaPlugin();
// issue headers for canonical
if (!empty($shCanonicalTag)) {
jimport('joomla.utilities.string');
$link = JURI::root(false, '') . JString::ltrim($shCanonicalTag, '/');
JResponse::setHeader('Link', '<' . $link . '>; rel="canonical"');
}
}
示例7: str_replace
} else {
// there is a page break, but no title. Use a page number
$pattern = str_replace($sefConfig->pagerep, ' ', $sefConfig->pageTexts[$GLOBALS['shMosConfig_locale']]);
$shPageTitle = str_replace('%s', $limitstart + 1, $pattern);
}
}
}
}
}
if (!empty($shPageTitle)) {
// found a heading, we should use that as a Title
$title[] = shCleanUpTitle($shPageTitle);
}
} else {
if (!empty($limit) && !empty($limitstart)) {
$shPageInfo =& shRouter::shPageInfo();
$shLimit = $layout == 'blog' ? shGetDefaultDisplayNumFromConfig($shPageInfo->shCurrentPageNonSef, $includeBlogLinks = $view == 'section') : $limit;
$pagenum = empty($limit) ? (int) $limitstart : (int) ($limitstart / $shLimit) + 1;
if ($sefConfig->alwaysAppendItemsPerPage) {
$shMultPageLength = $sefConfig->pagerep . $shLimit;
} else {
$shMultPageLength = '';
}
$pattern = str_replace($sefConfig->pagerep, ' ', $sefConfig->pageTexts[$GLOBALS['shMosConfig_locale']]);
$pageNumber = str_replace('%s', $pagenum, $pattern) . $shMultPageLength;
} else {
if (!empty($limitstart)) {
// this may be a blog category view, with more than one page
if ($title[count($title) - 1] == '/') {
// need to remove trailing slash added by getContentTitle
unset($title[count($title) - 1]);
示例8: shRankSimilarUrlsSimilarText
/**
* Apply a method to put the most appropriate urls
* at top of list
*
* @param array $urls an array of retrieved urls
* @return array same array, sorted to have most relevant url at offset 0, 1, etc
*/
function shRankSimilarUrlsSimilarText($urls, $searchedPath)
{
if (empty($urls)) {
return $urls;
}
// sort by distance
// first get current sef url
$shPageInfo =& shRouter::shPageInfo();
// current path
$path = JString::trim($searchedPath);
$path = JString::trim($path, '.');
// create a temporary array indexed ondistance
// between the lenght of the request and the current similar url
$tmp = array();
foreach ($urls as $url) {
$r = null;
$distance = similar_text($url->oldurl, $path, $r);
$t = array('distance' => $r, 'url' => $url);
$tmp[] = $t;
}
// sort this array according to text similarity
usort($tmp, 'shSortByReverseDistance');
// recreate the array we want
$rankedUrls = array();
foreach ($tmp as $u) {
$rankedUrls[] = $u['url'];
}
return $rankedUrls;
}
示例9: _log
if (!empty($shPageInfo->URI->host) && strpos($GLOBALS['shConfigLiveSite'], $shPageInfo->URI->host) === false && strpos($sefConfig->shConfig_live_secure_site, $shPageInfo->URI->host) === false) {
_log('Redirecting to home : host don\'t match our config : ' . $GLOBALS['shConfigLiveSite'] . ' | ' . $shPageInfo->URI->host . ' | ' . $sefConfig->shConfig_live_secure_site);
shRedirect($GLOBALS['shConfigLiveSite']);
} else {
$shPageInfo->shCurrentPagePath = $shPageInfo->URI->protocol . '://' . $shPageInfo->URI->host . (!sh404SEF_USE_NON_STANDARD_PORT || empty($shPageInfo->URI->port) ? '' : ':' . $shPageInfo->URI->port) . $shPageInfo->URI->path;
$shPageInfo->shCurrentPagePath = shUrlDecode($shPageInfo->shCurrentPagePath);
$shPageInfo->shCurrentPagePath = str_replace($GLOBALS['shConfigLiveSite'], '', $shPageInfo->shCurrentPagePath);
_log('Current page path : ' . $shPageInfo->shCurrentPagePath);
$qString = $shPageInfo->URI->getQueryString();
$shPageInfo->shCurrentPageURL = empty($qString) ? $shPageInfo->shCurrentPagePath : $shPageInfo->shCurrentPagePath . '?' . JString::ltrim($qString, '&');
$rewriteBit = empty($sefConfig->shRewriteMode) ? '' : JString::rtrim($sefConfig->shRewriteStrings[$sefConfig->shRewriteMode], '/');
$shPageInfo->baseUrl = $GLOBALS['shConfigLiveSite'] . $rewriteBit . $shPageInfo->shCurrentPagePath;
_log('Current base url : ' . $shPageInfo->baseUrl);
// V 1.2.4.s PR2 : workaround for Virtuemart cookie check issue
// see second part in shSef404.php
if (shIsSearchEngine()) {
// simulate doing successfull cookie check
_log('Setting VMCHECK cookie for search engine');
$_COOKIE['VMCHECK'] = 'OK';
$_REQUEST['vmcchk'] = 1;
// from VM 1.1.2 onward, result is stored in session, not cookie
$_SESSION['VMCHECK'] = 'OK';
}
}
} else {
JError::RaiseError(COM_SH404SEF_NOREAD . "( {$sef404} )<br />" . COM_SH404SEF_CHK_PERMS);
}
}
// save page info
shRouter::shPageInfo($shPageInfo);
}
示例10: _buildSefRoute
function _buildSefRoute(&$uri)
{
$sefConfig =& shRouter::shGetConfig();
$shPageInfo =& shRouter::shPageInfo();
$menu =& shRouter::shGetMenu();
// keep a copy of Joomla original URI, which has article names in it (ie: 43:article-title)
$originalUri = clone $uri;
shNormalizeNonSefUri($uri, $menu);
shNormalizeNonSefUri($originalUri, $menu, $removeSlugs = false);
// do our job!
$query = $uri->getQuery(false);
$route = shSefRelToAbs('index.php?' . $query, null, $uri, $originalUri);
$route = ltrim(str_replace($GLOBALS['shConfigLiveSite'], '', $route), '/');
$route = $shPageInfo->base . ($route == '/' ? '' : $route);
// find path
if (strpos($route, '?') !== false) {
$parts = explode('?', $route);
$path = $parts[0];
} else {
$path = $route;
}
$uri->setPath($path);
}