本文整理汇总了PHP中SEFTools::fixVariable方法的典型用法代码示例。如果您正苦于以下问题:PHP SEFTools::fixVariable方法的具体用法?PHP SEFTools::fixVariable怎么用?PHP SEFTools::fixVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SEFTools
的用法示例。
在下文中一共展示了SEFTools::fixVariable方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
$view = $uri->getVar('view');
$id = (int) $uri->getVar('id');
$catid = (int) $uri->getVar('catid');
switch ($view) {
case 'category':
case 'categories':
// Remove view and catid if they point to empty category/categories
if (!$id) {
$uri->delVar('view');
$uri->delVar('id');
}
case 'contact':
if ($id && $catid) {
$uri->delVar('catid');
}
}
return;
}
示例2: 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');
}
return;
}
示例3: 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('view') == 'categories' && !(int) $uri->getVar('id')) {
$uri->delVar('id');
}
if (is_null($uri->getVar('view'))) {
$uri->setVar('view', 'categories');
}
return;
}
示例4: 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');
}
// Remove view and catid if they point to empty category
if (!is_null($uri->getVar('view')) && $uri->getVar('view') == 'category') {
if (is_null($uri->getVar('catid')) || $uri->getVar('catid') == 0) {
$uri->delVar('view');
$uri->delVar('catid');
}
}
return;
}
示例5: beforeCreate
public function beforeCreate(&$uri)
{
// remove the limitstart and limit variables if they point to the first page
if (!is_null($uri->getVar('limitstart')) && $uri->getVar('limitstart') == '0') {
$uri->delVar('limitstart');
$uri->delVar('limit');
}
// Remove empty variables
if ($uri->getVar('limitstart') == '') {
$uri->delVar('limitstart');
}
if ($uri->getVar('showall') == '') {
$uri->delVar('showall');
}
// Try to guess the correct Itemid if set to
if ($this->params->get('guessId', '0') != '0') {
if (!is_null($uri->getVar('Itemid')) && !is_null($uri->getVar('id'))) {
$itemid = SefExtContentRouteHelper::getItemid($uri->getVar('id'));
if (!is_null($itemid)) {
$uri->setVar('Itemid', $itemid);
}
}
}
// 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');
}
// TODO: We should remove this, as it generates 1 unnecessary SQL query for each article link,
// instead the catid should just be always removed from article URL (but when updating JoomSEF,
// we'll need to update URLs already in database to reflect such change = remove catid from them!)
// If catid not given, try to find it
$catid = $uri->getVar('catid');
if (!is_null($uri->getVar('view')) && $uri->getVar('view') == 'article' && !is_null($uri->getVar('id')) && empty($catid)) {
$id = $uri->getVar('id');
$query = "SELECT `catid` FROM `#__content` WHERE `id` = '{$id}'";
$this->_db->setQuery($query);
$catid = $this->_db->loadResult();
if (is_null($catid)) {
JoomSefLogger::Log("Article with ID {$id} could not be found.", $this, 'com_content');
}
if (!empty($catid)) {
$uri->setVar('catid', $catid);
}
}
// remove empty id in categories list
if ($uri->getVar('view') == 'categories' && !(int) $uri->getVar('id')) {
$uri->delVar('id');
}
return;
}
示例6: beforeCreate
public function beforeCreate(&$uri)
{
// Fix IDs
SEFTools::fixVariable($uri, 'id');
}
示例7: beforeCreate
function beforeCreate(&$uri)
{
$db =& JFactory::getDBO();
$params = SEFTools::GetExtParams('com_content');
// Compatibility mode
$comp = $params->get('compatibility', '0');
// Change task=view to view=article for old urls
if (!is_null($uri->getVar('task')) && $uri->getVar('task') == 'view') {
if ($comp == '0') {
$uri->delVar('task');
}
$uri->setVar('view', 'article');
}
// Add the task=view in compatibility mode
if ($comp != '0') {
if (is_null($uri->getVar('task')) && !is_null($uri->getVar('view')) && $uri->getVar('view') == 'article') {
$uri->setVar('task', 'view');
}
}
// remove the limitstart and limit variables if they point to the first page
if (!is_null($uri->getVar('limitstart')) && $uri->getVar('limitstart') == '0') {
$uri->delVar('limitstart');
$uri->delVar('limit');
}
// Try to guess the correct Itemid if set to
if ($params->get('guessId', '0') != '0') {
if (!is_null($uri->getVar('Itemid')) && !is_null($uri->getVar('id'))) {
$mainframe =& JFactory::getApplication();
$i = $mainframe->getItemid($uri->getVar('id'));
$uri->setVar('Itemid', $i);
}
}
// 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 catid not given, try to find it
$catid = $uri->getVar('catid');
if (!is_null($uri->getVar('view')) && $uri->getVar('view') == 'article' && !is_null($uri->getVar('id')) && empty($catid)) {
$id = intval($uri->getVar('id'));
$query = "SELECT `catid` FROM `#__content` WHERE `id` = '{$id}'";
$db->setQuery($query);
$catid = $db->loadResult();
if (is_null($catid)) {
JoomSefLogger::Log("Article with ID {$id} could not be found.", $this, 'com_content');
} else {
$uri->setVar('catid', $catid);
}
}
// add the view variable if it's not set
if (is_null($uri->getVar('view'))) {
if (is_null($uri->getVar('id'))) {
$uri->setVar('view', 'frontpage');
} else {
$uri->setVar('view', 'article');
}
}
return;
}