本文整理汇总了PHP中SEFTools类的典型用法代码示例。如果您正苦于以下问题:PHP SEFTools类的具体用法?PHP SEFTools怎么用?PHP SEFTools使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SEFTools类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
function display($tpl = null)
{
// Get data from the model
$extension =& $this->get('extension');
$this->assignRef('extension', $extension);
$this->langs = $this->get('languages');
$this->strings = $this->get('strings');
$this->translation = $this->get('translation');
$this->subdomains = $this->get('subdomains');
$this->menus = $this->get('menus');
$filters =& SEFTools::getExtFilters($extension->option, false);
$this->assignRef('filters', $filters);
$acceptVars =& SEFTools::getExtAcceptVars($extension->option, false);
sort($acceptVars, SORT_STRING);
$this->assignRef('acceptVars', $acceptVars);
// Root domain for subdomains configuration
$rootDomain = JFactory::getURI()->getHost();
if (substr($rootDomain, 0, 4) == 'www.') {
$rootDomain = substr($rootDomain, 4);
}
$this->assign('rootDomain', $rootDomain);
JToolBarHelper::title(JText::_('SEF Extension') . ' <small>' . JText::_('Edit') . ' [ ' . (strlen($extension->name) ? $extension->name : $extension->component->name) . ' ]</small>', 'plugin.png');
JToolBarHelper::save();
JToolBarHelper::apply();
JToolBarHelper::spacer();
JToolBarHelper::cancel();
JHTML::_('behavior.tooltip');
$redir = JRequest::getVar('redirto', '');
$this->assignRef('redirto', $redir);
parent::display($tpl);
}
示例2: getFeedTitle
function getFeedTitle($id)
{
$title = array();
$field = 'name';
if (SEFTools::UseAlias($this->params, 'feed_alias')) {
$field = 'alias';
}
$id = intval($id);
$query = "SELECT `id`, `{$field}` AS `name`, `catid`, `language`, `metadesc`, `metakey`, `metadata` FROM `#__newsfeeds` WHERE `id` = '{$id}'";
$this->_db->setQuery($query);
$row = $this->_db->loadObject('stdClass', $this->config->translateItems);
if (is_null($row)) {
JoomSefLogger::Log("Feed with ID {$id} could not be found.", $this, 'com_newsfeeds');
return array();
}
if ($this->params->get('show_category', 2) != 0) {
$catInfo = $this->getCategoryInfo($row->catid);
if ($catInfo === false) {
JoomSefLogger::Log("Category with ID {$row->catid} could not be found.", $this, 'com_newsfeeds');
}
if (is_array($catInfo->path)) {
$title = array_merge($title, $catInfo->path);
}
}
$this->getMetaData($row);
$title[] = ($this->params->get('feedid', '0') == 0 ? '' : $id . '-') . $row->name;
return $title;
}
示例3: create
function create(&$uri)
{
$vars = $uri->getQuery(true);
extract($vars);
$this->params =& SEFTools::getExtParams('com_search');
$newUri = $uri;
if (!(isset($task) ? @$task : null)) {
$title[] = JoomSEF::_getMenuTitle($option, isset($task) ? $task : null);
if (isset($searchword) && $this->params->get('nonsefphrase', '1') != '1') {
$title[] = $searchword;
}
if (count($title) > 0) {
$this->_createNonSefVars($uri);
if (!isset($searchword) || $this->params->get('nonsefphrase', '1') != '1') {
// Generate meta tags
$desc = array();
if (isset($searchword)) {
$desc[] = $searchword;
}
if (isset($searchphrase)) {
$desc[] = $searchphrase;
}
$this->metadesc = implode(', ', $desc);
unset($desc);
}
$metatags = $this->getMetaTags();
$newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$vars['lang'], $this->nonSefVars, null, $metatags);
}
}
return $newUri;
}
示例4: display
function display($tpl = null)
{
JToolBarHelper::title(JText::_('JoomSEF'), 'artio.png');
// Get number of URLs for purge warning
$model =& JModel::getInstance('URLs', 'SEFModel');
$this->assign('purgeCount', $model->getCount(0));
// Get newest version available
$sefConfig =& SEFConfig::getConfig();
if ($sefConfig->versionChecker) {
$model2 =& JModel::getInstance('Upgrade', 'SEFModel');
$newVer = $model2->getNewSEFVersion();
$sefinfo = SEFTools::getSEFInfo();
if (strnatcasecmp($newVer, $sefinfo['version']) > 0 || strnatcasecmp($newVer, substr($sefinfo['version'], 0, strpos($sefinfo['version'], '-'))) == 0) {
$newVer = '<span style="font-weight: bold; color: red;">' . $newVer . '</span> <input type="button" onclick="showUpgrade();" value="' . JText::_('Go to Upgrade page') . '" />';
}
$newVer .= ' <input type="button" onclick="disableStatus(\'versioncheck\');" value="' . JText::_('Disable version checker') . '" />';
$this->assign('newestVersion', $newVer);
} else {
$newestVersion = JText::_('Version checker disabled') . ' <input type="button" onclick="enableStatus(\'versioncheck\');" value="' . JText::_('Enable') . '" />';
$this->assign('newestVersion', $newestVersion);
}
// Get statistics
$stats = $model->getStatistics();
$this->assignRef('stats', $stats);
// Get feed
$feed = $this->get('Feed');
$this->assignRef('feed', $feed);
JHTML::_('behavior.tooltip');
parent::display($tpl);
}
示例5: display
function display($tpl = null)
{
JToolBarHelper::title(JText::_('COM_SEF_JOOMSEF'), 'artio.png');
$user = JFactory::getUser();
if ($user->authorise('core.admin', 'com_sef')) {
JToolBarHelper::preferences('com_sef');
}
// Get number of URLs for purge warning
$model = SEFModel::getInstance('URLs', 'SEFModel');
$this->assign('purgeCount', $model->getCount(0));
// Get newest version available
$sefConfig = SEFConfig::getConfig();
if ($sefConfig->versionChecker) {
$model2 = SEFModel::getInstance('Upgrade', 'SEFModel');
$newVer = $model2->getNewSEFVersion();
$sefinfo = SEFTools::getSEFInfo();
if (strnatcasecmp($newVer, $sefinfo['version']) > 0 || strnatcasecmp($newVer, substr($sefinfo['version'], 0, strpos($sefinfo['version'], '-'))) == 0) {
$newVer = '<span style="font-weight: bold; color: red;">' . $newVer . '</span> <input type="button" class="btn btn-small" onclick="showUpgrade();" value="' . JText::_('COM_SEF_GO_TO_UPGRADE_PAGE') . '" />';
}
$newVer .= ' <input type="button" class="btn btn-danger btn-small" onclick="disableStatus(\'versioncheck\');" value="' . JText::_('COM_SEF_DISABLE_VERSION_CHECKER') . '" />';
$this->assign('newestVersion', $newVer);
} else {
$newestVersion = JText::_('COM_SEF_VERSION_CHECKER_DISABLED') . ' <input type="button" class="btn btn-success btn-small" onclick="enableStatus(\'versioncheck\');" value="' . JText::_('COM_SEF_ENABLE') . '" />';
$this->assign('newestVersion', $newestVersion);
}
// Get statistics
$stats = $model->getStatistics();
$this->assignRef('stats', $stats);
// Get feed
$feed = $this->get('Feed');
$this->assignRef('feed', $feed);
// Check language filter plugin
$this->getModel('sef')->checkLanguagePlugins();
parent::display($tpl);
}
示例6: display
function display()
{
$model =& $this->getModel('extensions');
$view =& $this->getView('sef', 'html', 'sefview');
$view->setModel($model);
SEFTools::checkExtVersions();
parent::display();
}
示例7: create
function create(&$uri)
{
$sefConfig =& SEFConfig::getConfig();
$database =& JFactory::getDBO();
$this->params =& SEFTools::getExtParams('com_weblinks');
// JF translate extension.
$jfTranslate = $sefConfig->translateNames ? ', `id`' : '';
$vars = $uri->getQuery(true);
extract($vars);
$title = array();
$title[] = JoomSEF::_getMenuTitle($option, @$this_task);
if (@$view == 'category') {
$title[] = $this->getCategoryTitle($id, SEFTools::UseAlias($this->params, 'category_alias'));
} elseif (empty($this_task) && @$view == 'weblink') {
if (isset($catid)) {
if ($this->params->get('show_category', '1')) {
$title[] = $this->getCategoryTitle($catid, SEFTools::UseAlias($this->params, 'category_alias'));
}
}
if (!empty($id)) {
$field = 'title';
if (SEFTools::UseAlias($this->params, 'weblink_alias')) {
$field = 'alias';
}
$id = intval($id);
$database->setQuery("SELECT `{$field}` AS `title` {$jfTranslate} FROM `#__weblinks` WHERE `id` = '{$id}'");
$row = $database->loadObject();
if (is_null($row)) {
JoomSefLogger::Log("Weblink with ID {$id} could not be found.", $this, 'com_weblinks');
} elseif (!empty($row->title)) {
$name = $row->title;
if ($this->params->get('weblink_id', '0')) {
$name = $id . '-' . $name;
}
$title[] = $name;
}
} else {
$title[] = JText::_('Submit');
}
}
if (isset($task) && $task == 'new') {
$title[] = 'new' . $sefConfig->suffix;
}
$newUri = $uri;
if (count($title) > 0) {
// Generate meta tags
$metatags = $this->getMetaTags();
$priority = $this->getPriority($uri);
$sitemap = $this->getSitemapParams($uri);
$newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$vars['lang'], null, null, $metatags, $priority, false, null, $sitemap);
}
return $newUri;
}
示例8: GetExts
function GetExts()
{
static $exts;
if (!isset($exts)) {
$exts = array();
$db =& JFactory::getDBO();
$query = "SELECT DISTINCT `extension` FROM `#__sefexttexts`";
$db->setQuery($query);
$extensions = $db->loadResultArray();
if (count($extensions) > 0) {
foreach ($extensions as $ext) {
$exts[$ext] = SEFTools::getExtName($ext);
}
}
}
return $exts;
}
示例9: _parseLinks
function _parseLinks($url, &$found)
{
// Get response, follow 5 redirections
$redirs = 0;
do {
$redirect = false;
$response = SEFTools::PostRequest($url, null, null, 'get', null);
if ($response === false) {
// Error
return;
}
if ($redirs < 5 && $response->code >= 300 && $response->code < 400) {
// Parse redirect URL
$pos = stripos($response->header, 'location:');
if ($pos !== false) {
$pos += 9;
// Skip header name
$pos2 = strpos($response->header, "\r", $pos);
$url = substr($response->header, $pos, $pos2 - $pos);
$url = trim($url);
$redirect = true;
$redirs++;
}
}
} while ($redirect);
// Check code
if ($response->code == 200) {
// Parse URLs
$matches = array();
if (preg_match_all('#<a\\s[^>]*href=["\']([^"\']+)#i', $response->content, $matches) > 0) {
// Loop through found URLs
foreach ($matches[1] as $link) {
$link = str_replace(JURI::root(), '', $link);
if (strpos($link, '://') !== false) {
// Absolute external link, skip
continue;
}
// Internal link
$link = JURI::root() . ltrim(html_entity_decode(urldecode($link)), '/');
if (!in_array($link, $found)) {
$found[] = $link;
}
}
}
}
}
示例10: beforeCreate
function beforeCreate(&$uri)
{
// Remove the part after ':' from variables
if (!is_null($uri->getVar('id'))) {
SEFTools::fixVariable($uri, 'id');
}
if (!is_null($uri->getVar('catid'))) {
SEFTools::fixVariable($uri, 'catid');
}
if ($uri->getVar('id') == 0) {
$uri->delVar('id');
}
if ($uri->getVar('w_id') == 0) {
$uri->delVar('w_id');
}
return;
}
示例11: create
function create(&$uri)
{
$sefConfig =& SEFConfig::getConfig();
$params = SEFTools::GetExtParams('com_content');
$vars = $uri->getQuery(true);
extract($vars);
// Set title.
$title = array();
$title[] = JoomSEF::_getMenuTitle(@$option, @$task, @$Itemid);
if (!empty($tmpl)) {
$title[] = $tmpl;
}
$newUri = $uri;
if (count($title) > 0) {
$this->_createNonSefVars($uri);
$newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$lang, null, $this->ignoreVars);
}
return $newUri;
}
示例12: create
function create(&$uri)
{
$sefConfig =& SEFConfig::getConfig();
$this->params =& SEFTools::getExtParams('com_banners');
$vars = $uri->getQuery(true);
extract($vars);
$title[] = JoomSEF::_getMenuTitleLang(@$option, @$task, @$Itemid);
switch (@$task) {
case 'click':
$title[] = $this->GetBannerName($id);
unset($task);
break;
}
$newUri = $uri;
if (isset($this->lang)) {
$lang = $this->lang;
}
if (count($title) > 0) {
$newUri = JoomSEF::_sefGetLocation($uri, $title, @$task, null, null, @$lang);
}
return $newUri;
}
示例13: create
function create(&$uri)
{
$vars = $uri->getQuery(true);
extract($vars);
// Don't SEF opensearch links
if (isset($format) && $format == 'opensearch') {
return $uri;
}
$this->params =& SEFTools::getExtParams('com_search');
$newUri = $uri;
if (!(isset($task) ? @$task : null)) {
$title[] = JoomSEF::_getMenuTitleLang($option, $lang, @$Itemid);
if (isset($searchword) && $this->params->get('nonsefphrase', '1') != '1') {
$title[] = $searchword;
}
if (isset($view) && ($view != 'search' || $this->params->get('add_search', '0') == '1')) {
$title[] = $view;
}
if (isset($format)) {
$title[] = $format;
}
$this->_createNonSefVars($uri);
if (!isset($searchword) || $this->params->get('nonsefphrase', '1') != '1') {
// Generate meta tags
$desc = array();
if (isset($searchword)) {
$desc[] = $searchword;
}
if (isset($searchphrase)) {
$desc[] = $searchphrase;
}
$this->metadesc = implode(', ', $desc);
unset($desc);
}
$metatags = $this->getMetaTags();
$newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$lang, $this->nonSefVars, null, $metatags, null, true);
}
return $newUri;
}
示例14: _checkRow
/**
* Checks the found row
*
*/
function _checkRow(&$row, $ignoreSource, $Itemid, $url, &$metadata, $temploc, $priority, $option, $host, $sitemapParams)
{
$realloc = null;
$db =& JFactory::getDBO();
$sefConfig =& SEFConfig::getConfig();
$numberDuplicates = $sefConfig->numberDuplicates;
if (!empty($option)) {
$params =& SEFTools::getExtParams($option);
$extDuplicates = $params->get('numberDuplicates', '2');
if ($extDuplicates != '2') {
$numberDuplicates = $extDuplicates;
}
}
if ($row != false && !is_null($row)) {
if ($ignoreSource || !$ignoreSource && (empty($Itemid) || $row->Itemid == $Itemid)) {
// ... check that it matches original URL
if ($row->origurl == $url) {
// found the matching object
// it probably should have been found sooner
// but is checked again here just for CYA purposes
// and to end the loop
$realloc = $row->sefurl;
} else {
if ($sefConfig->langPlacement == _COM_SEF_LANG_DOMAIN) {
// check if the urls differ only by lang variable
if (SEFTools::removeVariable($row->origurl, 'lang') == SEFTools::removeVariable($url, 'lang')) {
$db->setQuery("UPDATE `#__sefurls` SET `origurl` = " . $db->Quote(SEFTools::removeVariable($row->origurl, 'lang')) . " WHERE `id` = '{$row->id}' LIMIT 1");
// if error occured.
if (!$db->query()) {
$msg = JText::_('Could not update SEF URL in database');
if (JDEBUG) {
$msg .= ': ' . $db->getErrorMsg();
}
JError::raiseError('JoomSEF Error', $msg);
}
$realloc = $row->sefurl;
}
}
}
}
// The found URL is not the same
if (!$numberDuplicates) {
// But duplicates management is turned on
// so we can save the same SEF URL for different non-SEF URL
JoomSEF::_saveNewURL($Itemid, $metadata, $priority, $temploc, $url, false, $host, $sitemapParams);
$realloc = $temploc;
}
} else {
// Save URL in the database
JoomSEF::_saveNewURL($Itemid, $metadata, $priority, $temploc, $url, true, $host, $sitemapParams);
$realloc = $temploc;
}
return $realloc;
}
示例15: onAfterInitialise
function onAfterInitialise()
{
$sefConfig = SEFConfig::getConfig();
$mainframe = JFactory::getApplication();
// Enable menu associations if set to
$joomlaVersion = new JVersion();
if ($joomlaVersion->isCompatible('3.0')) {
$mainframe->item_associations = $sefConfig->langMenuAssociations ? 1 : 0;
} else {
$mainframe->set('menu_associations', $sefConfig->langMenuAssociations ? 1 : 0);
}
// Register installer and updater adapters in admin area
$this->registerAdapters();
// Check if JoomSEF should be run
if (!self::_isEnabled()) {
return true;
}
// Store the router for later use
$router = $mainframe->getRouter();
JoomSEF::set('sef.global.jrouter', $router);
// Load JoomSEF language file
$jLang = JFactory::getLanguage();
$jLang->load('com_sef', JPATH_ADMINISTRATOR);
require_once JPATH_ROOT . '/components/com_sef/sef.router.php';
$jsRouter = new JRouterJoomsef();
$router->attachParseRule(array($jsRouter, 'parse'));
$router->attachBuildRule(array($jsRouter, 'build'));
// Disable global "Add suffix to URLs" before parsing and store current config
$config = JFactory::getConfig();
$oldSuffix = $config->get('sef_suffix', 0);
$config->set('sef_suffix', 0);
JoomSEF::set('sef.global.orig_sef_suffix', $oldSuffix);
// Get all configured subdomains
$subdomains = SEFTools::getAllSubdomains();
// Redirect only when there's no POST variables
if ($sefConfig->wwwHandling != _COM_SEF_WWW_NONE && empty($_POST)) {
// Handle www and non-www domain
$uri = JURI::getInstance();
$host = $uri->getHost();
$redirect = false;
// Check if host is only IP
$isIP = preg_match('/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\z/', $host);
if ($sefConfig->wwwHandling == _COM_SEF_WWW_USE_WWW && !$isIP && strpos($host, 'www.') !== 0) {
// Check if host starts with one of our subdomains
if (isset($subdomains['*']) && count($subdomains['*']) > 0) {
$parts = explode('.', $host);
$domain = $parts[0];
$found = false;
foreach ($subdomains['*'] as $sub) {
if ($domain == $sub->subdomain) {
$found = true;
break;
}
}
if (!$found) {
// Redirect to www form
$redirect = true;
$uri->setHost('www.' . $host);
}
} else {
// Redirect to www form
$redirect = true;
$uri->setHost('www.' . $host);
}
} else {
if ($sefConfig->wwwHandling == _COM_SEF_WWW_USE_NONWWW && strpos($host, 'www.') === 0) {
// host must not begin with www.
$redirect = true;
$uri->setHost(substr($host, 4));
}
}
// Redirect if needed
if ($redirect) {
$url = $uri->toString();
header('Location: ' . $url, true, 301);
jexit();
}
}
// Load custom files only if needed for language or subdomains
if ($sefConfig->langPlacementJoomla == _COM_SEF_LANG_DOMAIN || count($subdomains) > 0) {
JLoader::register("JRoute", JPATH_SITE . '/components/com_sef/helpers/methods.php', true);
JLoader::register("JText", JPATH_SITE . '/components/com_sef/helpers/methods.php', true);
}
return true;
}