本文整理汇总了PHP中JRequest::getVAr方法的典型用法代码示例。如果您正苦于以下问题:PHP JRequest::getVAr方法的具体用法?PHP JRequest::getVAr怎么用?PHP JRequest::getVAr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JRequest
的用法示例。
在下文中一共展示了JRequest::getVAr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTemplates
/**
* <p>public static function get/load the templates object in the database</p>
* @param boolean $onlyPublish - to get/load only the template that is publish (publish = 1)
* @param boolean $onlyDefault - to load only the default template (premium = 1)
* @param mixed $templateSearch - the template to be seach
* @param int $start - start of query
* @param int $limit - limit of query
* @param availability - show only available templates
*/
public static function getTemplates($onlyPublish = true, $onlyDefault = false, $templateSearch = '', $start = -1, $limit = -1, $setSort = null, $onlyavailable = -1)
{
$db = JFactory::getDBO();
$query = 'SELECT * FROM `#__jnews_templates` ';
$where[] = $onlyPublish ? ' `published`=1 ' : ' `published`<>-1 ';
$where[] = $onlyDefault ? ' `premium`=1 ' : ' `premium`<>-1 ';
//if the search of template is not empty
//if the value is a numeric, we consider it as the template_id so we search by template_id
if (!empty($templateSearch)) {
if (is_numeric($templateSearch)) {
$where[] = ' `template_id` =' . $templateSearch;
} else {
$where[] = ' (name LIKE \'%' . $templateSearch . '%\' OR namekey LIKE \'%' . $templateSearch . '%\') ';
}
}
$query .= count($where) ? " WHERE " . implode(' AND ', $where) : "";
if ($onlyavailable == 1 && JRequest::getVAr('task') == 'assign') {
$query .= ' AND `availability`=1 ';
}
if (!empty($setSort)) {
$s = is_int($setSort->orderValue) ? "{$setSort->orderValue}" : "`{$setSort->orderValue}`";
$query .= "ORDER BY {$s} {$setSort->orderDir}";
} else {
$query .= 'ORDER BY `premium` DESC, `created` DESC, `published` DESC, `ordering` ASC, `name` ASC';
}
if ($start != -1 && $limit != -1) {
$query .= ' LIMIT ' . $start . ', ' . $limit;
}
$db->setQuery($query);
$templates = $db->loadObjectlist();
return $templates;
}