本文整理汇总了PHP中JURI::setVar方法的典型用法代码示例。如果您正苦于以下问题:PHP JURI::setVar方法的具体用法?PHP JURI::setVar怎么用?PHP JURI::setVar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JURI
的用法示例。
在下文中一共展示了JURI::setVar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modifyAttrs
function modifyAttrs($lnkAttrs, $imgAttrs, $group, $params)
{
$lnkAttrs['rel'] = 'prettyPhoto';
if ($group) {
$lnkAttrs['rel'] .= '[' . $group . ']';
}
$link = $lnkAttrs['href'];
if ($this->isLink($link)) {
$uri = new JURI($link);
$uri->setVar('iframe', 'true');
if (!$uri->getVar('height')) {
$uri->setVar('height', intval($params->get('lightbox_height'), 10));
} else {
$height = $uri->getVar('height');
$uri->delVar('height');
$uri->setVar('height', $height);
}
if (!$uri->getVar('width')) {
$uri->setVar('width', intval($params->get('lightbox_width'), 10));
} else {
$width = $uri->getVar('width');
$uri->delVar('width');
$uri->setVar('width', $width);
}
$lnkAttrs['href'] = $uri->toString();
}
return parent::modifyAttrs($lnkAttrs, $imgAttrs, $group, $params);
}
示例2: ajaxGetRender
/**
*
* Ajax render to store in session
*/
public function ajaxGetRender()
{
/** load libraries for the system rener **/
JSNFactory::localimport('libraries.joomlashine.mode.rawmode');
JSNFactory::localimport('libraries.joomlashine.menu.menuitems');
/** get url **/
$render_url = JRequest::getVar('render_url', '');
$urlRender = base64_decode($render_url);
$session = JSession::getInstance('files', array('name' => 'jsnpoweradmin'));
if ($render_url == '') {
$urlRender = JSNDatabase::getDefaultPage()->link;
}
$currUri = new JURI($urlRender);
if (!$currUri->hasVar('Itemid')) {
$currUri->setVar('Itemid', JSNDatabase::getDefaultPage()->id);
}
$urlString = $currUri->toString();
$session->set('rawmode_render_url', base64_encode($urlString));
$parts = JString::parse_url($urlString);
if (!empty($parts['query'])) {
parse_str($parts['query'], $params);
} else {
$params = array();
}
$jsntemplate = JSNFactory::getTemplate();
$jsnrawmode = JSNRawmode::getInstance($params);
$jsnrawmode->setParam('positions', $jsntemplate->loadXMLPositions());
$jsnrawmode->renderAll();
$session = JSession::getInstance('files', array('name' => 'jsnajaxgetrender'));
$session->set('component', $jsnrawmode->getHTML('component'));
$session->set('jsondata', $jsnrawmode->getScript('positions', 'JSON'));
jexit('success');
}
示例3: modifyAttrs
function modifyAttrs($lnkAttrs, $imgAttrs, $group, $params)
{
$lnkAttrs['rel'] = 'sexylightbox';
if ($group) {
$lnkAttrs['rel'] .= '[' . $group . ']';
}
$link = $lnkAttrs['href'];
$bgColor = $params->get('lightbox_bgColor');
if ($this->isLink($link)) {
$uri = new JURI($link);
$uri->setVar('TB_iframe', 'true');
$uri->setVar('height', intval($params->get('lightbox_height'), 10));
$uri->setVar('width', intval($params->get('lightbox_width'), 10));
if ($bgColor) {
$uri->setVar('background', $bgColor);
}
$lnkAttrs['href'] = $uri->toString();
} else {
if ($bgColor) {
$uri = new JURI($link);
$uri->setVar('background', $bgColor);
$lnkAttrs['href'] = $uri->toString();
}
}
return parent::modifyAttrs($lnkAttrs, $imgAttrs, $group, $params);
}
示例4: getUri
public static function getUri($layout = null)
{
$uri = new JURI('index.php?option=com_kunena&view=announcement');
if ($layout) {
$uri->setVar('layout', $layout);
}
return $uri;
}
示例5: testSetVar
public function testSetVar() {
$this->object->setVar('somevar', 'somevalue');
$this->assertThat(
$this->object->getVar('somevar'),
$this->equalTo('somevalue')
);
}
示例6: getBlogItemLink
function getBlogItemLink($item)
{
if ($item->params->get('access-view')) {
$link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catid, $item->language));
} else {
$menu = JFactory::getApplication()->getMenu();
$active = $menu->getActive();
$itemId = $active->id;
$link1 = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $itemId);
$returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catid, $item->language));
$link = new JURI($link1);
$link->setVar('return', base64_encode(urlencode($returnURL)));
}
return $link;
}
示例7: getObjectInfo
function getObjectInfo($id, $language = null)
{
$db = JFactory::getDBO();
$article = null;
$link = null;
require_once JPATH_ROOT . '/components/com_content/helpers/route.php';
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select('a.id, a.title, a.created_by, a.access, a.alias, a.catid, a.language');
$query->from('#__content AS a');
// Join over the categories.
$query->select('c.title AS category_title, c.path AS category_route, c.access AS category_access, c.alias AS category_alias');
$query->join('LEFT', '#__categories AS c ON c.id = a.catid');
$query->where('a.id = ' . (int) $id);
$db->setQuery($query);
$article = $db->loadObject();
if (!empty($article)) {
$user = JFactory::getUser();
$article->slug = $article->alias ? $article->id . ':' . $article->alias : $article->id;
$article->catslug = $article->category_alias ? $article->catid . ':' . $article->category_alias : $article->catid;
$authorised = JAccess::getAuthorisedViewLevels($user->get('id'));
$checkAccess = in_array($article->access, $authorised);
if ($checkAccess) {
$link = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->language));
} else {
$returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->language));
$menu = JFactory::getApplication()->getMenu();
$active = $menu->getActive();
$ItemId = $active->id;
$link = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $ItemId);
$uri = new JURI($link);
$uri->setVar('return', base64_encode($returnURL));
$link = $uri->toString();
}
}
$info = new JCommentsObjectInfo();
if (!empty($article)) {
$info->category_id = $article->catid;
$info->title = $article->title;
$info->access = $article->access;
$info->userid = $article->created_by;
$info->link = $link;
}
return $info;
}
示例8: _
public static function _($uri = null, $xhtml = true, $ssl = 0)
{
jimport('joomla.environment.uri');
if (!$uri) {
$link = self::current(true);
$link->delVar('Itemid');
$link->delVar('defaultmenu');
$link->delVar('language');
} else {
if (is_numeric($uri)) {
$item = self::$menu[intval($uri)];
return JRoute::_($item->link . "&Itemid={$item->id}");
} else {
$link = new JURI((string) $uri);
}
}
$query = $link->getQuery(true);
$Itemid = self::_getItemID($query);
$link->setVar('Itemid', $Itemid);
return JRoute::_('index.php?' . $link->getQuery(), $xhtml, $ssl);
}
示例9: __construct
protected function __construct($component, $componentParams, $article, $articleParams)
{
parent::__construct($component, $componentParams, $article, $articleParams);
$this->isPublished = 0 != $this->_article->state;
$this->titleLink = $this->_articleParams->get('link_titles') && $this->_articleParams->get('access-view') ? JRoute::_(ContentHelperRoute::getArticleRoute($this->_article->slug, $this->_article->catid)) : '';
$this->intro = $this->_article->introtext;
if ($this->_articleParams->get('show_readmore') && $this->_article->readmore) {
if (!$this->_articleParams->get('access-view')) {
$this->readmore = JText::_('COM_CONTENT_REGISTER_TO_READ_MORE');
} elseif ($this->readmore = $this->_article->alternative_readmore) {
if ($this->_articleParams->get('show_readmore_title', 0) != 0) {
$this->readmore .= JHtml::_('string.truncate', $this->_article->title, $this->_articleParams->get('readmore_limit'));
}
} elseif ($this->_articleParams->get('show_readmore_title', 0) == 0) {
$this->readmore = JText::sprintf('COM_CONTENT_READ_MORE_TITLE');
} else {
$this->readmore = JText::_('COM_CONTENT_READ_MORE') . JHtml::_('string.truncate', $this->_article->title, $this->_articleParams->get('readmore_limit'));
}
if ($this->_articleParams->get('access-view')) {
$link = JRoute::_(ContentHelperRoute::getArticleRoute($this->_article->slug, $this->_article->catid));
$this->readmoreLink = $link;
} else {
$menu = JFactory::getApplication()->getMenu();
$active = $menu->getActive();
$itemId = $active->id;
$link1 = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $itemId);
$returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($this->_article->slug, $this->_article->catid));
$link = new JURI($link1);
$link->setVar('return', base64_encode($returnURL));
$this->readmoreLink = $link->__toString();
}
} else {
$this->readmore = '';
$this->readmoreLink = '';
}
}
示例10: getRoute
protected static function getRoute($view = 'search', $additionalFilters = array(), $queryOnly = false)
{
$uri = new JURI('index.php');
$uri->setVar('option', 'com_jsolrsearch');
$uri->setVar('view', $view);
if ($queryOnly) {
if (JURI::getInstance()->getVar('q')) {
$uri->setVar('q', urlencode(JURI::getInstance()->getVar('q')));
}
} else {
foreach (JURI::getInstance()->getQuery(true) as $key => $value) {
if ($value && $key != 'limitstart' && $key != 'task') {
$uri->setVar($key, urlencode($value));
}
}
}
foreach ($additionalFilters as $key => $value) {
$uri->setVar($key, urlencode($value));
}
if ($item = self::_findItem($view)) {
$uri->setVar('Itemid', $item);
}
return $uri;
}
示例11: getURI
/**
* Gets the search url.
*
* @return JURI The search url.
*/
public function getURI()
{
$uri = new JURI("index.php");
$uri->setVar("option", "com_jsolrsearch");
$uri->setVar("view", "search");
$uri->setVar("Itemid", JRequest::getVar('Itemid'));
if ($query = $this->buildQuery()) {
$uri->setVar('q', urlencode($query));
}
if ($this->getState('query.o', null)) {
$uri->setVar('o', $this->getState('query.o'));
}
$vars = array('task', 'nq', 'oq', 'eq', 'aq', 'as');
foreach (JURI::getInstance()->getQuery(true) as $key => $value) {
if (array_search($key, $vars) === false && !empty($value)) {
$uri->setVar($key, $value);
}
}
// add the filters.
foreach (JFactory::getApplication()->input->get('as', array(), 'array') as $key => $value) {
if (!empty($value)) {
$uri->setVar($key, $value);
}
}
// finally add the Itemid for basic search
$uri->setVar('Itemid', \JSolr\Search\Factory::getSearchRoute()->getVar('Itemid'));
return $uri;
}
示例12: onPrepareContent
function onPrepareContent(&$article, &$params, $limitstart = 0)
{
require_once (JCOMMENTS_HELPERS . '/content.php');
// check whether plugin has been unpublished
if (!JPluginHelper::isEnabled('content', 'jcomments')) {
JCommentsContentPluginHelper::clear($article, true);
return '';
}
$app = JFactory::getApplication('site');
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
if (!isset($article->id) || ($option != 'com_content' && $option != 'com_alphacontent' && $option != 'com_multicategories')) {
return '';
}
if (!isset($params) || $params == null) {
jimport('joomla.html.parameter');
$params = new JParameter('');
} else if (isset($params->_raw) && strpos($params->_raw, 'moduleclass_sfx') !== false) {
return '';
}
if ($view == 'frontpage' || $view == 'featured') {
if ($this->params->get('show_frontpage', 1) == 0) {
return '';
}
}
require_once (JCOMMENTS_BASE . '/jcomments.config.php');
require_once (JCOMMENTS_BASE . '/jcomments.class.php');
JCommentsContentPluginHelper::processForeignTags($article);
$config = JCommentsFactory::getConfig();
$categoryEnabled = JCommentsContentPluginHelper::checkCategory($article->catid);
$commentsEnabled = JCommentsContentPluginHelper::isEnabled($article) || $categoryEnabled;
$commentsDisabled = JCommentsContentPluginHelper::isDisabled($article) || !$commentsEnabled;
$commentsLocked = JCommentsContentPluginHelper::isLocked($article);
if ($article->state == -1 && $this->params->get('enable_for_archived', 0) == 0) {
$commentsLocked = true;
}
$config->set('comments_on', intval($commentsEnabled));
$config->set('comments_off', intval($commentsDisabled));
$config->set('comments_locked', intval($commentsLocked));
if ($view != 'article') {
$user = JFactory::getUser();
if (JCOMMENTS_JVERSION == '1.5') {
$checkAccess = $article->access <= $user->get('aid', 0);
} else {
$authorised = JAccess::getAuthorisedViewLevels($user->get('id'));
$checkAccess = in_array($article->access, $authorised);
}
if ($checkAccess) {
require_once(JPATH_ROOT . '/components/com_content/helpers/route.php');
if (JCOMMENTS_JVERSION == '1.5') {
$readmore_link = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->sectionid));
} else {
$readmore_link = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid));
}
$readmore_register = 0;
} else {
if (JCOMMENTS_JVERSION == '1.5') {
$readmore_link = JRoute::_('index.php?option=com_user&task=register');
} else {
$returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug));
$menu = JFactory::getApplication()->getMenu();
$active = $menu->getActive();
$itemId = $active->id;
$link1 = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $itemId);
$link = new JURI($link1);
$link->setVar('return', base64_encode($returnURL));
$readmore_link = $link;
}
$readmore_register = 1;
}
// load template for comments & readmore links
$tmpl = JCommentsFactory::getTemplate($article->id, 'com_content', false);
$tmpl->load('tpl_links');
$tmpl->addVar('tpl_links', 'comments_link_style', ($readmore_register ? -1 : 1));
$tmpl->addVar('tpl_links', 'content-item', $article);
$tmpl->addVar('tpl_links', 'show_hits', intval($this->params->get('show_hits', 0) && $params->get('show_hits', 0)));
$readmoreDisabled = false;
if (($params->get('show_readmore') == 0) || (@$article->readmore == 0)) {
$readmoreDisabled = true;
} else if (@$article->readmore > 0) {
$readmoreDisabled = false;
//.........这里部分代码省略.........
示例13: getTaskUri
/**
* Return JUri object pointing to the Announcement task.
*
* @param string $layout
*/
public function getTaskUri($task = null)
{
$uri = new JURI('index.php?option=com_kunena&view=announcement');
if ($task) {
$uri->setVar('task', $task);
}
if ($this->id) {
$uri->setVar('id', $this->id);
}
if ($task) {
$uri->setVar(JUtility::getToken(), 1);
}
return $uri;
}
示例14: explode
function _fixLangSwitcher($reqURI)
{
$isLangFilter = JPluginHelper::isEnabled("system", "languagefilter");
if (!$isLangFilter) {
return $reqURI;
}
$uri = JFactory::getURI();
$app = JFactory::getApplication();
$router = $app->getRouter();
if ($app->isSite()) {
// setup language data
$mode_sef = $router->getMode() == JROUTER_MODE_SEF ? true : false;
$default_lang = JLanguageHelper::getLanguages('lang_code');
if ($mode_sef) {
// Get the route path from the request.
$path = JString::substr($uri->toString(), JString::strlen($uri->base()));
// Apache mod_rewrite is Off
//$path = JFactory::getConfig()->get('sef_rewrite') ? $path : JString::substr($path, 10);
$path = $app->getCfg('sef_rewrite') ? $path : JString::substr($path, 10);
// Trim any spaces or slashes from the ends of the path and explode into segments.
$path = JString::trim($path, '/ ');
$parts = explode('/', $path);
// The language segment is always at the beginning of the route path if it exists.
$langcode = $uri->getVar('lang');
if (!empty($parts) && empty($langcode)) {
$langcode = reset($parts);
}
//set to default language
if (empty($langcode)) {
//$langcode = $default_lang;
// @since 4.0 we get default language from here
$lang = JFactory::getLanguage();
$langcode = $lang->getDefault();
}
//append language code to the request
$reqURI = $reqURI . '/' . $langcode . '/';
} else {
$langcode = $uri->getVar('lang', $default_lang);
//append language code to the request
$tmpURI = new JURI($reqURI);
$tmpURI->setVar('lang', $langcode);
$reqURI = $tmpURI->toString();
}
}
return $reqURI;
}
示例15: JParameter
function &getItem($index = 0, &$params)
{
global $mainframe;
// Initialize some variables
$user =& JFactory::getUser();
$dispatcher =& JDispatcher::getInstance();
$SiteName = $mainframe->getCfg('sitename');
$task = JRequest::getCmd('task');
$linkOn = null;
$linkText = null;
$item =& $this->items[$index];
$item->text = $item->introtext;
// Get the page/component configuration and article parameters
$item->params = clone $params;
$aparams = new JParameter($item->attribs);
// Merge article parameters into the page configuration
$item->params->merge($aparams);
// Process the content preparation plugins
JPluginHelper::importPlugin('content');
$results = $dispatcher->trigger('onPrepareContent', array(&$item, &$item->params, 0));
// Build the link and text of the readmore button
if ($item->params->get('show_readmore') && @$item->readmore || $item->params->get('link_titles')) {
// checks if the item is a public or registered/special item
if ($item->access <= $user->get('aid', 0)) {
//$item->readmore_link = JRoute::_("index.php?view=article&id=".$item->slug);
$item->readmore_link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid));
$item->readmore_register = false;
} else {
$item->readmore_link = JRoute::_("index.php?option=com_user&view=login");
$returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid), false);
$fullURL = new JURI($item->readmore_link);
$fullURL->setVar('return', base64_encode($returnURL));
$item->readmore_link = $fullURL->toString();
$item->readmore_register = true;
}
}
$item->event = new stdClass();
$results = $dispatcher->trigger('onAfterDisplayTitle', array(&$item, &$item->params, 0));
$item->event->afterDisplayTitle = trim(implode("\n", $results));
$results = $dispatcher->trigger('onBeforeDisplayContent', array(&$item, &$item->params, 0));
$item->event->beforeDisplayContent = trim(implode("\n", $results));
$results = $dispatcher->trigger('onAfterDisplayContent', array(&$item, &$item->params, 0));
$item->event->afterDisplayContent = trim(implode("\n", $results));
return $item;
}