本文整理汇总了PHP中JUri::buildQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP JUri::buildQuery方法的具体用法?PHP JUri::buildQuery怎么用?PHP JUri::buildQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUri
的用法示例。
在下文中一共展示了JUri::buildQuery方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createMenuItem
/**
* Generates a menu item based on given data.
*
* @param array $data Data to insert to the menu item.
*
* @return null
*/
private static function createMenuItem($data)
{
$count = count(self::$data);
$defaults = array('id' => $count, 'menutype' => 'testmenu', 'title' => '', 'alias' => isset($data['title']) ? JFilterOutput::stringURLSafe($data['title']) : '', 'route' => isset($data['title']) ? JFilterOutput::stringURLSafe($data['title']) : '', 'link' => JUri::buildQuery($data['query']), 'type' => 'component', 'level' => '1', 'language' => '*', 'access' => '1', 'params' => '{}', 'home' => '0', 'component_id' => '1000', 'parent_id' => '0', 'component' => 'com_monitor', 'tree' => isset($data['id']) ? array($data['id']) : array($count), 'query' => array('option' => 'com_monitor'));
$obj = (object) array_merge($defaults, $data);
self::$data[$obj->id] = $obj;
}
示例2: getReturnURL
/**
* Retrieve the url where the user should be returned after logging in
*
* @param \Joomla\Registry\Registry $params module parameters
* @param string $type return type
*
* @return string
*/
public static function getReturnURL($params, $type)
{
$app = JFactory::getApplication();
$item = $app->getMenu()->getItem($params->get($type));
if ($item) {
$vars = $item->query;
} else {
// Stay on the same page
$vars = $app::getRouter()->getVars();
}
return base64_encode('index.php?' . JUri::buildQuery($vars));
}
示例3: getReturnURL
/**
* Returns the login url
*
* @since 1.0
* @access public
* @param string
* @return
*/
public static function getReturnURL(&$params)
{
// $params->get( 'return' , FD::getCallback() );
$app = JFactory::getApplication();
$router = $app->getRouter();
$url = null;
$itemid = $params->get('return');
if ($itemid) {
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select($db->quoteName('link'))->from($db->quoteName('#__menu'))->where($db->quoteName('published') . '=1')->where($db->quoteName('id') . '=' . $db->quote($itemid));
$db->setQuery($query);
if ($link = $db->loadResult()) {
if ($router->getMode() == JROUTER_MODE_SEF) {
$url = 'index.php?Itemid=' . $itemid;
} else {
$url = $link . '&Itemid=' . $itemid;
}
}
}
if (!$url) {
// Stay on the same page
$uri = clone JUri::getInstance();
$vars = $router->parse($uri);
unset($vars['lang']);
if ($router->getMode() == JROUTER_MODE_SEF) {
if (isset($vars['Itemid'])) {
$itemid = $vars['Itemid'];
$menu = $app->getMenu();
$item = $menu->getItem($itemid);
unset($vars['Itemid']);
if (isset($item) && $vars == $item->query) {
$url = 'index.php?Itemid=' . $itemid;
} else {
$url = 'index.php?' . JUri::buildQuery($vars) . '&Itemid=' . $itemid;
}
} else {
$url = 'index.php?' . JUri::buildQuery($vars);
}
} else {
$url = 'index.php?' . JUri::buildQuery($vars);
}
}
return base64_encode($url);
}
示例4: buildInternalUrl
/**
* Builds internal URL - indepedent of SEF function
*
* @param object $uri
*
* @return string
*/
private function buildInternalUrl($uri)
{
// Clone JUri object to avoid an error because of the method -parse- in the next step
$uri_clone = clone $uri;
// Reference to JRouter object
$route = JSite::getRouter();
// Get the internal route
$url_internal_array = $route->parse($uri_clone);
// Move Itemid at the end
if (array_key_exists('Itemid', $url_internal_array)) {
$itemid = $url_internal_array['Itemid'];
unset($url_internal_array['Itemid']);
$url_internal_array['Itemid'] = $itemid;
}
// Move lang at the end
if (array_key_exists('lang', $url_internal_array)) {
$lang = $url_internal_array['lang'];
unset($url_internal_array['lang']);
$url_internal_array['lang'] = $lang;
}
$url_internal = JUri::base() . 'index.php?' . JUri::buildQuery($url_internal_array);
return $url_internal;
}
示例5: getErrorReturnUrl
/**
* Get the URL of current page for redirecting if any error occurs.
*
* @return string Base64 URL.
*
* @since 1.0.0
*/
function getErrorReturnUrl()
{
$app = JFactory::getApplication();
$router = $app->getRouter();
$uri = clone JUri::getInstance();
$vars = $router->parse($uri);
unset($vars['lang']);
if ($router->getMode() == JROUTER_MODE_SEF) {
if (isset($vars['Itemid'])) {
$itemId = $vars['Itemid'];
$menu = $app->getMenu();
$item = $menu->getItem($itemId);
unset($vars['Itemid']);
if (isset($item) && $vars == $item->query) {
$url = 'index.php?Itemid=' . $itemId;
} else {
$url = 'index.php?' . JUri::buildQuery($vars) . '&Itemid=' . $itemId;
}
} else {
$url = 'index.php?' . JUri::buildQuery($vars);
}
} else {
$url = 'index.php?' . JUri::buildQuery($vars);
}
return base64_encode($url);
}
示例6: setType
/**
* Sets the type of the menu item currently being edited.
*
* @return void
*
* @since 1.6
*/
public function setType()
{
$app = JFactory::getApplication();
// Get the posted values from the request.
$data = $this->input->post->get('jform', array(), 'array');
// Get the type.
$type = $data['type'];
$type = json_decode(base64_decode($type));
$title = isset($type->title) ? $type->title : null;
$recordId = isset($type->id) ? $type->id : 0;
$specialTypes = array('alias', 'separator', 'url', 'heading');
if (!in_array($title, $specialTypes)) {
$title = 'component';
}
$app->setUserState('com_menus.edit.item.type', $title);
if ($title == 'component') {
if (isset($type->request)) {
$component = JComponentHelper::getComponent($type->request->option);
$data['component_id'] = $component->id;
$app->setUserState('com_menus.edit.item.link', 'index.php?' . JUri::buildQuery((array) $type->request));
}
} elseif ($title == 'alias') {
$app->setUserState('com_menus.edit.item.link', 'index.php?Itemid=');
}
unset($data['request']);
$data['type'] = $title;
if ($this->input->get('fieldtype') == 'type') {
$data['link'] = $app->getUserState('com_menus.edit.item.link');
}
//Save the data in the session.
$app->setUserState('com_menus.edit.item.data', $data);
$this->type = $type;
$this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId), false));
}
示例7: testBuildQuery
/**
* Test the buildQuery method.
*
* @return void
*
* @since 11.1
* @covers JUri::buildQuery
*/
public function testBuildQuery()
{
$params = array('field' => array('price' => array('from' => 5, 'to' => 10), 'name' => 'foo'), 'v' => 45);
$expected = 'field[price][from]=5&field[price][to]=10&field[name]=foo&v=45';
$this->assertEquals($expected, JUri::buildQuery($params));
}
示例8: buildQuery
public static function buildQuery($parts)
{
if ($item = JoomleagueHelperRoute::_findItem($parts)) {
$parts['Itemid'] = $item->id;
} else {
$params = JComponentHelper::getParams('com_joomleague');
if ($params->get('default_itemid')) {
$parts['Itemid'] = intval($params->get('default_itemid'));
}
}
return JUri::buildQuery($parts);
}
示例9: base64_encode
$totalPhotos = $photosModel->getPhotosCount($user->id);
//group count
$groupmodel = CFactory::getModel('groups');
$totalGroups = $groupmodel->getGroupsCount($user->id);
//event count
$eventmodel = CFactory::getModel('events');
$totalEvents = $eventmodel->getEventsCount($user->id);
if ($moduleParams->get('logout')) {
$app = JFactory::getApplication();
$item = $app->getMenu()->getItem($moduleParams->get('logout'));
if ($item) {
$vars = $item->query;
} else {
base64_encode(CRoute::_('index.php?option=com_community&view=' . CFactory::getConfig()->get('redirect_logout'), false));
}
$logoutlink = base64_encode('index.php?' . JUri::buildQuery($vars));
} else {
$logoutlink = base64_encode(CRoute::_('index.php?option=com_community&view=' . CFactory::getConfig()->get('redirect_logout'), false));
}
}
if ($moduleParams->get('login', 0)) {
$app = JFactory::getApplication();
$item = $app->getMenu()->getItem($moduleParams->get('login'));
if ($item) {
$vars = $item->query;
}
$loginLink = base64_encode('index.php?' . JUri::buildQuery($vars));
} else {
$loginLink = base64_encode(CRoute::_('index.php?option=com_community&view=' . CFactory::getConfig()->get('redirect_logout'), false));
}
require JModuleHelper::getLayoutPath('mod_community_hellome', $params->get('layout', 'default'));
示例10: _createURI
/**
* Create a uri based on a full or partial url string
*
* @param string $url The URI
*
* @return JUri
*
* @since 11.1
*/
protected function _createURI($url)
{
// Create full URL if we are only appending variables to it
if (substr($url, 0, 1) == '&') {
$vars = array();
if (strpos($url, '&') !== false) {
$url = str_replace('&', '&', $url);
}
parse_str($url, $vars);
$vars = array_merge($this->getVars(), $vars);
foreach ($vars as $key => $var) {
if ($var == "") {
unset($vars[$key]);
}
}
$url = 'index.php?' . JUri::buildQuery($vars);
}
// Decompose link into url component parts
return new JUri($url);
}
示例11: createURI
/**
* Create a uri based on a full or partial url string
*
* @param string $url The URI or an associative array
*
* @return JUri
*
* @since 3.2
*/
protected function createURI($url)
{
if (is_array($url)) {
$uri = new JUri('index.php');
$uri->setQuery($url);
return $uri;
} elseif (substr($url, 0, 1) == '&') {
$vars = array();
if (strpos($url, '&') !== false) {
$url = str_replace('&', '&', $url);
}
parse_str($url, $vars);
$vars = array_merge($this->getVars(), $vars);
foreach ($vars as $key => $var) {
if ($var == "") {
unset($vars[$key]);
}
}
$url = 'index.php?' . JUri::buildQuery($vars);
}
// Decompose link into url component parts
return new JUri($url);
}
示例12: pagenav2
static function pagenav2($jl_task, $rlimit, $currentRoundcode = 0, $user = '', $mode = '')
{
$mytask = JRequest::getVar('task', false);
$divLevel = JRequest::getInt('divLevel', 0);
$division = JRequest::getInt('division', 0);
$pageNav2 = '<form action="" method="get" style="display:inline;">';
$pageNav2 .= '<select class="inputbox" onchange="joomleague_changedoc(this)">';
$params = array();
$params['option'] = 'com_joomleague';
$params['controller'] = $jl_task;
$params['p'] = $this->projectid;
if ($user) {
$params['uid'] = $user;
}
if ($mode) {
$params['mode'] = $mode;
}
if ($mytask) {
$params['task'] = $mytask;
}
if ($division > 0) {
$params['division'] = $division;
}
if ($divLevel > 0) {
$params['divLevel'] = $divLevel;
}
for ($counter = 1; $counter <= $rlimit; $counter++) {
if ($counter < 10) {
$pagenumber = "0" . $counter;
} else {
$pagenumber = $counter;
}
if ($counter <= $rlimit) {
$params['r'] = $counter;
$query = JUri::buildQuery($params);
$link = JRoute::_('index.php?' . $query);
$pageNav2 .= "<option value='" . $link . "'";
if ($counter == $currentRoundcode) {
$pageNav2 .= " selected='selected'";
}
$pageNav2 .= '>';
}
$pageNav2 .= $pagenumber . '</option>';
}
$pageNav2 .= '</select></form>';
return $pageNav2;
}
示例13: nextLastPages
public static function nextLastPages($url, $text, $maxentries, $limitstart = 0, $limit = 10)
{
$latestlimitstart = 0;
if (intval($limitstart - $limit) > 0) {
$latestlimitstart = intval($limitstart - $limit);
}
$nextlimitstart = 0;
if ($limitstart + $limit < $maxentries) {
$nextlimitstart = $limitstart + $limit;
}
$lastlimitstart = $maxentries - $maxentries % $limit;
if ($maxentries % $limit == 0) {
$lastlimitstart = $maxentries - $maxentries % $limit - $limit;
}
echo '<center>';
echo '<table style="width: 50%; align: center;" cellspacing="0" cellpadding="0" border="0">';
echo '<tr>';
echo '<td style="width: 10%; text-align: left;" nowrap="nowrap">';
if ($limitstart > 0) {
$query = JUri::buildQuery(array("limit" => $limit, "limitstart" => 0));
echo JHtml::link($url . $query, '<<<');
echo '  ';
$query = JUri::buildQuery(array("limit" => $limit, "limitstart" => $latestlimitstart));
echo JHtml::link($url . $query, '<<');
echo ' ';
}
echo '</td>';
echo '<td style="text-align: center;" nowrap="nowrap">';
$players_to = $maxentries;
if ($limitstart + $limit < $maxentries) {
$players_to = $limitstart + $limit;
}
echo sprintf($text, $maxentries, $limitstart + 1 . ' - ' . $players_to);
echo '</td>';
echo '<td style="width: 10%; text-align: right;" nowrap="nowrap">';
if ($nextlimitstart > 0) {
echo ' ';
$query = JUri::buildQuery(array("limit" => $limit, "limitstart" => $nextlimitstart));
echo JHtml::link($url . $query, '>>');
echo '  ';
$query = JUri::buildQuery(array("limit" => $limit, "limitstart" => $lastlimitstart));
echo JHtml::link($url . $query, '>>>');
}
echo '</td>';
echo '</tr>';
echo '</table>';
echo '</center>';
}
示例14: processRedirects
public static function processRedirects($params, $type)
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
$jinput = JFactory::getApplication()->input;
$option = $jinput->get('option', '', 'string');
if (version_compare(JVERSION, '3.2', '>')) {
$requireReset = $user->requireReset;
} else {
$requireReset = 0;
}
if (!$app->isSite()) {
return false;
} elseif ($option == 'com_users' || $option == 'com_comprofiler' || $option == 'com_community' || $option == 'com_awdwall') {
if ($requireReset) {
return;
}
# $params = $this->params;
$task = $jinput->get('task', '', 'string');
$view = $jinput->get('view', '', 'string');
$layout = $jinput->get('layout', '', 'string');
$return = $jinput->get('return', '', 'string');
$custom_register = $params->get('custom_register', 'cb');
$custom_post_register = $params->get('custom_post_register', 'cb');
$custom_login = $params->get('custom_login', 'cb');
$custom_profile = $params->get('custom_profile', 'cb');
$custom_password = $params->get('custom_password', 'cb');
$custom_username = $params->get('custom_username', 'cb');
$custom_post_login = $params->get('custom_post_login', 0);
$custom_post_login_menu = $params->get('custom_post_login_menu', '');
$custom_post_login_URL = $params->get('custom_post_login_URL', '');
$custom_logout = $params->get('custom_logout', 0);
$custom_logout_menu = $params->get('custom_logout_menu', '');
$custom_logout_URL = $params->get('custom_logout_url', '');
$devMode = $params->get('dev_mode', 0);
$ckeckRegister = $task == 'register' || $view == 'registration' || $view == 'register';
$ckeckProfile = $task != 'user.logout' && $task != 'user.login';
$redirectURL = '';
switch (true) {
// bypass plugin altogether if logging out with a valid token
// (it seems that the task 'user.logout' is only used when a token is present)
case $option == 'com_users' && $task == 'user.logout':
return;
# case $clro:
# return;
// LOGOUT:
// redirect for a forced logout
# case $clro:
# return;
// LOGOUT:
// redirect for a forced logout
case $option == 'com_users' && $view == 'login' && !$user->guest && $custom_logout && $type == 'after_route':
$processType = 'LOGOUT';
if ($custom_logout_menu == '' && $custom_logout_URL == '') {
$vars = $app::getRouter()->getVars();
$returnVar = '&return=' . base64_encode('index.php?' . JUri::buildQuery($vars));
} else {
$redirectURL = self::checkCustomURL($params, 'custom_logout');
$returnVar = '&return=' . base64_encode($redirectURL);
}
$masterRedirect = 'index.php?option=com_users&task=user.logout' . $returnVar . '&' . JSession::getFormToken() . '=1';
break;
// REGISTRATION:
// redirect FROM joomla registration TO community builder registration
// REGISTRATION:
// redirect FROM joomla registration TO community builder registration
case $option == 'com_users' && $ckeckRegister && $custom_register == 'cb':
$processType = 'REGISTRATION';
$masterRedirect = 'index.php?option=com_comprofiler&task=registers';
break;
// redirect FROM joomla registration TO jomsocial registeration
// redirect FROM joomla registration TO jomsocial registeration
case $option == 'com_users' && $ckeckRegister && $custom_register == 'js':
$processType = 'REGISTRATION';
$masterRedirect = "index.php?option=com_community&view=register";
break;
// redirect FROM joomla registration TO custom registration
// redirect FROM joomla registration TO custom registration
case $option == 'com_users' && $ckeckRegister && $custom_register == 'custom':
$processType = 'REGISTRATION';
$masterRedirect = self::checkCustomURL($params, 'custom_register');
break;
// redirect FROM community builder registration TO custom registration
// redirect FROM community builder registration TO custom registration
case $option == 'com_comprofiler' && $task == 'registers' && $custom_register == 'custom':
$processType = 'REGISTRATION';
$masterRedirect = self::checkCustomURL($params, 'custom_register');
break;
// redirect FROM jomsocial registration TO custom registration
// redirect FROM jomsocial registration TO custom registration
case $option == 'com_community' && $task == 'register' && $custom_register == 'custom':
$processType = 'REGISTRATION';
$masterRedirect = self::checkCustomURL($params, 'custom_register');
break;
// redirect FROM jomwall registration TO custom registration
// not sure if this will be able to be used since it appears that JomWall doesn't have a direct URL to a registration page
/*
case $option=='com_awdwall' && $task=='register' && $custom_register == 'custom':
$masterRedirect = self::checkCustomURL($params, 'custom_register');
break;
//.........这里部分代码省略.........