本文整理汇总了PHP中SEFTools::UseAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP SEFTools::UseAlias方法的具体用法?PHP SEFTools::UseAlias怎么用?PHP SEFTools::UseAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SEFTools
的用法示例。
在下文中一共展示了SEFTools::UseAlias方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContactName
function getContactName($id)
{
$database =& JFactory::getDBO();
$sefConfig =& SEFConfig::getConfig();
$field = 'name';
if (SEFTools::UseAlias($this->params, 'contact_alias')) {
$field = 'alias';
}
$jfTranslate = $sefConfig->translateNames ? ', `id`' : '';
$id = intval($id);
$database->setQuery("SELECT `{$field}` AS `name`, `catid` {$jfTranslate} FROM `#__contact_details` WHERE `id` = '{$id}'");
$contact = $database->loadObject();
if (is_null($contact)) {
JoomSefLogger::Log("Contact with ID {$id} could not be found.", $this, 'com_contact');
return array();
}
if ($contact) {
$name = ($this->params->get('contactid', '0') != '0' ? $id . '-' : '') . $contact->name;
if ($this->params->get('category', '1') != '1') {
return array($name);
} else {
return array($this->getCategoryTitle($contact->catid), $name);
}
}
}
示例2: _getArticle
protected function _getArticle($id)
{
$sefConfig =& SEFConfig::getConfig();
$title = array();
$field = 'title';
if (SEFTools::UseAlias($this->params, 'title_alias')) {
$field = 'alias';
}
$id = intval($id);
$query = "SELECT `id`, `title`, `alias`, `introtext`, `fulltext`, `language`, `metakey`, `metadesc`, `metadata`, `catid` FROM `#__content` WHERE `id` = '{$id}'";
$this->_db->setQuery($query);
$row = $this->_db->loadObject('stdClass', $this->config->translateItems);
// Article dont exists
if (!is_object($row)) {
JoomSefLogger::Log("Article with ID {$id} could not be found.", $this, 'com_content');
return array();
}
$catInfo = $this->getCategoryInfo($row->catid);
if ($catInfo === false) {
JoomSefLogger::Log("Category with ID {$row->catid} could not be found.", $this, 'com_content');
return array();
}
if ($this->params->get('show_category', '2') != 0) {
if (is_array($catInfo->path) && count($catInfo->path) > 0) {
$catFilter = trim($this->params->get('exclude_categories', ''));
if ($catFilter != '') {
$catFilter = explode("\n", $catFilter);
foreach ($catFilter as $filter) {
$filter = JString::strtolower(trim($filter));
$haystack = array_map(array('JString', 'strtolower'), $catInfo->titles);
// Case insensitive search
$i = array_search($filter, $haystack);
if ($i !== false) {
unset($catInfo->path[$i]);
unset($catInfo->titles[$i]);
}
}
}
$title = array_merge($title, $catInfo->path);
}
}
//$this->item_desc = $row->introtext;
if ($this->params->get('googlenewsnum', 0) == 0) {
$title[] = ($this->params->get('articleid', '0') == 1 ? $id . '-' : '') . $row->{$field};
} else {
$title = array_merge($title, $this->GoogleNews($row->{$field}, $id));
}
$this->getMetaData($row);
if ($this->params->get('meta_titlecat', 0) == 1) {
$this->pageTitle = $row->title;
$metatitle = array_merge(array($row->title), $catInfo->titles);
$this->metatags["metatitle"] = implode(" - ", $metatitle);
}
$this->metadesc = $row->introtext;
$this->origmetadesc = $row->metadesc;
$this->metakeySource = $row->fulltext;
$this->origmetakey = $row->metakey;
$this->articleText = $row->introtext . chr(13) . chr(13) . $row->fulltext;
return $title;
}
示例3: getContactName
function getContactName($id)
{
$sefConfig =& SEFConfig::getConfig();
$title = array();
$field = 'name';
if (SEFTools::UseAlias($this->params, 'contact_alias')) {
$field = 'alias';
}
$id = intval($id);
$query = "SELECT `id`, `{$field}` AS `name`, `catid`, `metakey`, `metadesc`, `metadata`, `language`,`misc` FROM `#__contact_details` WHERE `id` = '{$id}'";
$this->_db->setQuery($query);
$row = $this->_db->loadObject('stdClass', $this->config->translateItems);
if (is_null($row)) {
JoomSefLogger::Log("Contact with ID {$id} could not be found.", $this, 'com_contact');
return array();
}
$name = ($this->params->get('contactid', '0') != '0' ? $id . '-' : '') . $row->name;
// use contact description as page meta tags if available
if ($row->misc = JString::trim($row->misc)) {
$this->metadesc = $row->misc;
}
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_contact');
}
if (is_array($catInfo->path)) {
$title = array_merge($title, $catInfo->path);
}
}
$title[] = $row->name;
$this->getMetaData($row);
return $title;
}
示例4: 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;
}
示例5: 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;
}
示例6: GetBannerName
function GetBannerName($id)
{
$database =& JFactory::getDBO();
$sefConfig =& SEFConfig::getConfig();
$field = 'name';
if (SEFTools::UseAlias($this->params, 'banner_alias')) {
$field = 'alias';
}
$id = intval($id);
$query = "SELECT id, `{$field}` AS `name`, `language` FROM `#__banners` WHERE `id` = '{$id}'";
$database->setQuery($query);
$row = $database->loadObject('stdClass', $this->config->translateItems);
if (is_null($row)) {
JoomSefLogger::Log("Banner with ID {$id} could not be found.", $this, 'com_banners');
return '';
}
$this->lang = $row->language;
$name = isset($row->name) ? $row->name : '';
if ($this->params->get('banner_id', '0')) {
$name = $id . '-' . $name;
}
return $name;
}
示例7: getWeblinkTitle
function getWeblinkTitle($id)
{
$title = array();
$title_fld = SEFTools::UseAlias($this->params, 'weblink_alias') ? '`alias` AS `title`' : '`title`';
$query = 'SELECT `id`,`catid`, `metakey`, `metadata`, `metadesc`, `language`,' . $title_fld . ' FROM `#__weblinks` WHERE `id` = ' . (int) $id;
$this->_db->setQuery($query);
$row = $this->_db->loadObject('stdClass', $this->config->translateItems);
if (is_null($row)) {
JoomSefLogger::Log("Weblink with ID {$id} could not be found.", $this, 'com_weblinks');
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_weblinks');
}
if (is_array($catInfo->path)) {
$title = array_merge($title, $catInfo->path);
}
}
$title[] = ($this->params->get('weblink_id') == 1 ? $row->id . '-' : '') . $row->title;
$this->getMetaData($row);
return $title;
}
示例8: GetBannerName
function GetBannerName($id)
{
$database =& JFactory::getDBO();
$sefConfig =& SEFConfig::getConfig();
$field = 'name';
if (SEFTools::UseAlias($this->params, 'banner_alias')) {
$field = 'alias';
}
$jfTranslate = $sefConfig->translateNames ? ', `bid`' : '';
$id = intval($id);
$query = "SELECT `{$field}` AS `name` {$jfTranslate} FROM `#__banner` WHERE `bid` = '{$id}'";
$database->setQuery($query);
$row = $database->loadObject();
$name = '';
if (is_null($row)) {
JoomSefLogger::Log("Banner with ID {$id} could not be found.", $this, 'com_banners');
} else {
$name = isset($row->name) ? $row->name : '';
if ($this->params->get('banner_id', '0')) {
$name = $id . '-' . $name;
}
}
return $name;
}
示例9: getCategoryInfo
protected function getCategoryInfo($id)
{
$field = 'title';
if (SEFTools::UseAlias($this->params, 'category_alias')) {
$field = 'alias';
}
$addId = (bool) $this->params->get('categoryid', '0');
$catInfo = new stdClass();
$titles = array();
$path = array();
$id = intval($id);
$this->_db->setQuery("SELECT `lft`, `rgt` FROM `#__categories` WHERE `id` = '{$id}'");
$idx = $this->_db->loadObject();
if (!$idx) {
return false;
}
$query = "SELECT `id`, `title`, `alias`, `description`, language, `metakey`, `metadesc`, `metadata`, `parent_id` FROM `#__categories` WHERE `lft` <= '{$idx->lft}' AND `rgt` >= '{$idx->rgt}' AND id!=1 ORDER BY `lft` DESC";
if ($this->params->get('show_category', 2) != 2) {
$query .= " LIMIT 1";
}
$this->_db->setQuery($query);
$cats = $this->_db->loadObjectList('', 'stdClass', $this->config->translateItems);
$result = null;
$this->metatags = array();
foreach ($cats as $cat) {
// Get only last category metas
if (is_null($result)) {
$result = new stdClass();
$this->lang = $cat->language;
$this->metadesc = $cat->description;
$this->metatags["metakey"] = $cat->metakey;
$this->metatags["metadesc"] = $cat->metadesc;
$metadata = new JRegistry($cat->metadata);
$this->metatags["metaauthor"] = $metadata->get('author');
$this->metatags["metarobots"] = $metadata->get('robots');
$this->metadesc = $cat->description;
$this->origmetadesc = $cat->metadesc;
$this->metakeysource = $cat->description;
$this->origmetakey = $cat->metakey;
$this->pageTitle = $cat->title;
}
$name = $addId ? $id . '-' . $cat->{$field} : $cat->{$field};
array_unshift($path, $name);
array_unshift($titles, $cat->title);
if (empty($this->metatags["metadesc"])) {
$this->metatags["metadesc"] = $cat->description;
}
$id = $cat->parent_id;
if ($id <= 1) {
break;
}
}
$catInfo->titles = $titles;
$catInfo->path = $path;
return $catInfo;
}
示例10: _getContentTitles
/**
* Get SEF titles of content items.
*
* @param string $task
* @param int $id
* @return string
*/
function _getContentTitles($task, $id)
{
$database =& JFactory::getDBO();
$sefConfig =& SEFConfig::getConfig();
$title = array();
// JF translate extension.
$jfTranslate = $sefConfig->translateNames ? ', `id`' : '';
// Fields
$title_field = 'title';
if (SEFTools::UseAlias($this->params, 'title_alias')) {
$title_field = 'title_alias';
}
$category_field = 'category';
if (SEFTools::UseAlias($this->params, 'category_alias')) {
$category_field = 'cat_alias';
}
$section_field = 'section';
if (SEFTools::UseAlias($this->params, 'section_alias')) {
$section_field = 'sec_alias';
}
$showSection = $this->params->get('show_section', '0');
$showCategory = $this->params->get('show_category', '1');
$addCatToTitle = $this->params->get('meta_titlecat', '0');
$descField = null;
$id = intval($id);
$type = '';
switch ($task) {
case 'section':
case 'blogsection':
if (isset($id)) {
$sql = "SELECT `title` AS `section`, `alias` AS `sec_alias`, `description` AS `sec_desc`{$jfTranslate} FROM `#__sections` WHERE `id` = '{$id}'";
}
$descField = 'sec_desc';
$metakeySource = 'sec_desc';
$type = 'Section';
break;
case 'category':
case 'blogcategory':
if (isset($id)) {
if ($showSection) {
$sql = 'SELECT s.title AS section, s.alias AS sec_alias, s.description AS sec_desc' . ($jfTranslate ? ', s.id AS section_id' : '') . ($showCategory ? ', c.title AS category, c.alias AS cat_alias, c.description AS cat_desc' . ($jfTranslate ? ', c.id' : '') : '') . ' FROM #__categories as c ' . 'LEFT JOIN #__sections AS s ON c.section = s.id ' . 'WHERE c.id = ' . $id;
} else {
$sql = "SELECT `title` AS `category`, `alias` AS `cat_alias`, `description` AS `cat_desc`{$jfTranslate} FROM #__categories WHERE `id` = {$id}";
}
/*if ($showCategory) {
$descField = 'cat_desc';
} else {
$descField = 'sec_desc';
}*/
// if this is category URL, use category alias although $showCategory is FALSE
$descField = 'cat_desc';
$metakeySource = 'cat_desc';
$showCategory = true;
}
$type = 'Category';
break;
case 'article':
if (isset($id)) {
/*
Alias should not be empty, Joomla 1.5 ensures that when saving content
if ($sefConfig->useAlias) {
// verify title alias is not empty
$database->setQuery("SELECT alias$jfTranslate FROM #__content WHERE id = $id");
$title_field = $database->loadResult() ? 'alias' : 'title';
}
*/
$selects = array();
$joins = array();
if ($showSection) {
$selects[] = 's.title AS section, s.alias AS sec_alias' . ($jfTranslate ? ', s.id AS section_id' : '') . ', ';
$joins[] = 'LEFT JOIN #__sections AS s ON a.sectionid = s.id';
}
if ($showCategory || $addCatToTitle) {
$selects[] = 'c.title AS category, c.alias AS cat_alias' . ($jfTranslate ? ', c.id AS category_id' : '') . ', ';
$joins[] = 'LEFT JOIN #__categories AS c ON a.catid = c.id';
}
$sql = 'SELECT ' . implode('', $selects) . 'a.title AS title, a.alias AS title_alias, a.`fulltext`, a.introtext AS item_desc, a.metakey, a.metadesc' . ($jfTranslate ? ', a.id' : '') . ' FROM #__content as a ' . implode(' ', $joins) . ' WHERE a.id = ' . $id;
$descField = 'item_desc';
$metakeySource = 'fulltext';
}
$type = 'Article';
break;
default:
$sql = '';
}
if ($sql) {
$database->setQuery($sql);
$row = $database->loadObject();
if (is_null($row)) {
JoomSefLogger::Log($type . " with ID {$id} could not be found.", $this, 'com_content');
return $title;
}
if (isset($row->section)) {
//.........这里部分代码省略.........