本文整理汇总了PHP中JURI::getVar方法的典型用法代码示例。如果您正苦于以下问题:PHP JURI::getVar方法的具体用法?PHP JURI::getVar怎么用?PHP JURI::getVar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JURI
的用法示例。
在下文中一共展示了JURI::getVar方法的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: foreach
function &getItem($translation = null)
{
$table = clone parent::getItem();
// I could pick up the URL here or treat as a special content element field type?
if ($table->type == 'component') {
// Note that to populate the initial value of the urlparams
$conf = JFactory::getConfig();
$elementTable = $conf->get('falang.elementTable', false);
foreach ($elementTable->Fields as $efield) {
if ($efield->Name == "link" && isset($efield->translationContent->value) && $efield->translationContent->value !== "") {
$uri = new JURI($efield->translationContent->value);
if ($uri->getVar("option", false)) {
$table->link = $efield->translationContent->value;
}
}
}
$url = str_replace('index.php?', '', $table->link);
$url = str_replace('&', '&', $url);
$table->linkparts = null;
if (strpos($url, '&') !== false) {
$url = str_replace('&', '&', $url);
}
parse_str($url, $table->linkparts);
$db = $this->getDBO();
if ($component = @$table->linkparts['option']) {
$query = 'SELECT `extension_id`' . ' FROM `#__extensions`' . ' WHERE `element` = "' . $db->escape($component) . '"';
$db->setQuery($query);
$table->componentid = $db->loadResult();
}
}
$item = $table;
return $item;
}
示例3: testDelVar
public function testDelVar()
{
$this->object->parse('http://someuser:somepass@www.example.com:80/path/file.html?var=value#fragment');
$this->assertThat($this->object->getVar('var'), $this->equalTo('value'));
$this->object->delVar('var');
$this->assertThat($this->object->getVar('var'), $this->equalTo(''));
}
示例4: buildRoute
/**
* Method to build the router
*
* @param JRouter $router JRouter instance
* @param JURI $uri Current JURI instance
*
* @return null
*/
public function buildRoute($router, $uri)
{
if ($uri->getVar('view') == 'article') {
$query = $uri->getQuery();
$query = preg_replace('/\\&id=([0-9]+):([a-z0-9\\-\\_]+)/', '&id=\\2', $query);
$uri->setQuery($query);
}
}
示例5: modifyAttrs
function modifyAttrs($lnkAttrs, $imgAttrs, $group, $params)
{
if ($group) {
$lnkAttrs['rel'] = $group;
}
if (empty($lnkAttrs['class'])) {
$lnkAttrs['class'] = '';
} else {
$lnkAttrs['class'] .= ' ';
}
$lnkAttrs['class'] .= 'arifancybox';
$link = $lnkAttrs['href'];
if ($this->isLink($link)) {
$uri = new JURI($link);
$lnkParams = array('width' => intval($uri->getVar('width') ? $uri->getVar('width') : $params->get('lightbox_width'), 10), 'height' => intval($uri->getVar('height') ? $uri->getVar('height') : $params->get('lightbox_height'), 10));
$lnkAttrs['class'] .= ' iframe ' . str_replace('"', '"', AriJSONHelper::encode($lnkParams));
$uri->delVar('width');
$uri->delVar('height');
$lnkAttrs['href'] = $uri->toString();
}
return parent::modifyAttrs($lnkAttrs, $imgAttrs, $group, $params);
}
示例6: JParameter
function &getItem($translation = null)
{
$params = new JParameter($translation);
static $item;
if (isset($item)) {
return $item;
}
$table = clone parent::getItem();
// replace values
$table->params = $translation;
// I could pick up the URL here or treat as a special content element field type?
if ($table->type == 'component') {
// Note that to populate the initial value of the urlparams
$conf = JFactory::getConfig();
$elementTable = $conf->getValue('joomfish.elementTable', false);
foreach ($elementTable->Fields as $efield) {
if ($efield->Name == "link" && isset($efield->translationContent->value) && $efield->translationContent->value !== "") {
$uri = new JURI($efield->translationContent->value);
if ($uri->getVar("option", false)) {
$table->link = $efield->translationContent->value;
}
}
}
$url = str_replace('index.php?', '', $table->link);
$url = str_replace('&', '&', $url);
$table->linkparts = null;
if (strpos($url, '&') !== false) {
$url = str_replace('&', '&', $url);
}
parse_str($url, $table->linkparts);
$db = $this->getDBO();
if ($component = @$table->linkparts['option']) {
$query = 'SELECT `id`' . ' FROM `#__components`' . ' WHERE `link` <> \'\'' . ' AND `parent` = 0' . ' AND `option` = "' . $db->getEscaped($component) . '"';
$db->setQuery($query);
$table->componentid = $db->loadResult();
}
}
//$values = $params->getProperties(false);
//print_r($values);
$item = $table;
return $item;
}
示例7: getUserMenu
function getUserMenu($user_id)
{
$apps = self::getApplications($user_id);
$juser =& JFactory::getUser($user_id);
if ($juser->guest) {
echo 'Trang web không tồn tại';
jexit();
}
if ($apps) {
$menu = '<ul id="blogmenu">';
foreach ($apps as $app) {
$uri = new JURI(JURI::base() . $app->url);
$view = $uri->getVar('view');
if ($app->app_show === 0 || $app->app_show === '0') {
continue;
}
$title = empty($app->app_title) ? $app->title : $app->app_title;
$link = JRoute::_('index.php?option=com_wedding&view=' . $view . '&user=' . $juser->username . '&tmpl=component');
$menu .= '<li><a href="' . $link . '"><span>' . $title . '</span></a></li>';
}
$menu .= '</ul>';
}
return $menu;
}
示例8: RemoveVariables
/**
* Removes given variables from URI and returns a query string
* built of them
*
* @param JURI $uri
* @param array $vars Variables to remove
*/
function RemoveVariables(&$uri, &$vars)
{
$query = array();
if (is_array($vars) && count($vars) > 0) {
foreach ($vars as $var) {
// Get the variable value
$value = $uri->getVar($var);
// Skip variables not present in URL
if (is_null($value)) {
continue;
}
// Add variable to query
if (is_array($value)) {
// Variable is an array, let's remove all its occurences
foreach ($value as $key => $val) {
$query[] = $var . '[' . $key . ']=' . urlencode($val);
}
} else {
// Variable is not an array
$query[] = $var . '=' . urlencode($value);
}
// Remove variable from URI
$uri->delVar($var);
}
}
$query = implode('&', $query);
return $query;
}
示例9: getVar
/**
* getVar
*
* @param string $name
* @param null $default
*
* @return void
*/
public function getVar($name, $default = null)
{
$this->uri->getVar($name, $default);
}
示例10: prepareSlides
function prepareSlides($slides, $params)
{
$newSlides = array();
$target = $params->get('customLinkTarget');
if (empty($target)) {
$target = $params->get('linkTarget', '_self');
}
$baseUri = JURI::base(true);
$lightboxEngine = AriCloudCarouselHelper::getLightboxEngine($params);
$lightboxGroup = uniqid('cc_');
foreach ($slides as $slide) {
$isLink = !empty($slide['link']);
$description = isset($slide['description']) ? $slide['description'] : '';
$title = isset($slide['title']) ? $slide['title'] : '';
$lnkAttrs = null;
$imgAttrs = array('src' => $baseUri . '/' . $slide['image'], 'alt' => $description, 'title' => $title, 'class' => 'cloudcarousel');
if (!empty($slide['width'])) {
$imgAttrs['width'] = $slide['width'];
}
if (!empty($slide['height'])) {
$imgAttrs['height'] = $slide['height'];
}
if ($isLink) {
$lnkAttrs = array('href' => $slide['link'], 'target' => $target);
if ($description) {
$lnkAttrs['title'] = $description;
}
if (!is_null($lightboxEngine)) {
list($lnkAttrs, $imgAttrs) = $lightboxEngine->modifyAttrs($lnkAttrs, $imgAttrs, $lightboxGroup, $params);
} else {
$originalLink = $slide['link'];
if (strpos($originalLink, '_target') !== false) {
$uri = new JURI($originalLink);
$linkTarget = $uri->getVar('_target');
if (!is_null($linkTarget)) {
$uri->delVar('_target');
$lnkAttrs['target'] = $linkTarget;
$lnkAttrs['href'] = $uri->toString();
}
}
}
}
$slide['lnkAttrs'] = $lnkAttrs;
$slide['imgAttrs'] = $imgAttrs;
$newSlides[] = $slide;
}
return $newSlides;
}
示例11: prepareSlides
function prepareSlides($slides, $params)
{
$newSlides = array();
$target = $params->get('customLinkTarget');
if (empty($target)) {
$target = $params->get('linkTarget', '_self');
}
$defLink = $params->get('defaultLink');
$baseUri = JURI::base(true);
$lightboxEngine = AriImageSliderHelper::getLightboxEngine($params);
$lightboxGrouping = (bool) $params->get('lightbox_grouping', true);
$lightboxGroup = $lightboxGrouping ? uniqid('cc_') : null;
foreach ($slides as $slide) {
$slideLink = !empty($slide['link']) ? $slide['link'] : $defLink;
if (empty($slide['link']) && !empty($defLink)) {
$slide['link'] = $defLink;
}
$isLink = !empty($slideLink);
$description = isset($slide['description']) ? $slide['description'] : '';
$altText = isset($slide['alt']) ? $slide['alt'] : '';
$lnkAttrs = null;
$imgAttrs = array('src' => $baseUri . '/' . $slide['image'], 'alt' => $altText, 'title' => $description, 'class' => 'imageslider-item');
if (!empty($slide['width'])) {
$imgAttrs['width'] = $slide['width'];
}
if (!empty($slide['height'])) {
$imgAttrs['height'] = $slide['height'];
}
if ($isLink) {
$lnkAttrs = array('href' => $slideLink, 'target' => $target);
if ($description) {
$lnkAttrs['title'] = $description;
}
$skip_lb = false;
if (!is_null($lightboxEngine) && strpos($slideLink, 'skip_lb') !== false) {
$uri = new JURI($slideLink);
$skip_lb = (bool) $uri->getVar('skip_lb');
$uri->delVar('skip_lb');
$slideLink = $uri->toString();
$lnkAttrs['href'] = $slideLink;
}
if (!$skip_lb && !is_null($lightboxEngine)) {
list($lnkAttrs, $imgAttrs) = $lightboxEngine->modifyAttrs($lnkAttrs, $imgAttrs, $lightboxGroup, $params);
} else {
$originalLink = $slideLink;
if (strpos($originalLink, '_target') !== false) {
$uri = new JURI($originalLink);
$linkTarget = $uri->getVar('_target');
if (!is_null($linkTarget)) {
$uri->delVar('_target');
$lnkAttrs['target'] = $linkTarget;
$lnkAttrs['href'] = $uri->toString();
}
}
}
}
$slide['lnkAttrs'] = $lnkAttrs;
$slide['imgAttrs'] = $imgAttrs;
$newSlides[] = $slide;
}
return $newSlides;
}
示例12: _processBuildRules
/**
* Process the build uri query data based on custom defined rules
*
* @param JURI $uri The URI
*
* @return void
*/
protected function _processBuildRules($uri)
{
// Make sure any menu vars are used if no others are specified
if ($this->_mode != JROUTER_MODE_SEF && $uri->getVar('Itemid') && count($uri->getQuery(true)) == 2) {
$app = JApplication::getInstance('site');
$menu = $app->getMenu();
// Get the active menu item
$itemid = $uri->getVar('Itemid');
$item = $menu->getItem($itemid);
if ($item) {
$uri->setQuery($item->query);
}
$uri->setVar('Itemid', $itemid);
}
// Process the attached build rules
parent::_processBuildRules($uri);
// Get the path data
$route = $uri->getPath();
if ($this->_mode == JROUTER_MODE_SEF && $route) {
$app = JApplication::getInstance('site');
if ($limitstart = $uri->getVar('limitstart')) {
$uri->setVar('start', (int) $limitstart);
$uri->delVar('limitstart');
}
}
$uri->setPath($route);
}
示例13: updateMetaNext
function updateMetaNext()
{
$db =& JFactory::getDBO();
$sefConfig =& SEFConfig::getConfig();
// Load all the URLs
$query = "SELECT `id`, `sefurl`, `origurl`, `Itemid` FROM `#__sefurls` WHERE `locked` = '0' AND `flag` = '1' LIMIT 25";
$db->setQuery($query);
$rows = $db->loadObjectList();
// Check that there's anything to update
if (is_null($rows) || count($rows) == 0) {
// Done
echo json_encode(array('type' => 'completed', 'updated' => 0));
jexit();
}
// OK, we've got some data, let's update them
$count = count($rows);
// Suppress all the normal output
ob_start();
// Loop through URLs and update them one by one
for ($i = 0; $i < $count; $i++) {
$row =& $rows[$i];
$url = $row->origurl;
if (!empty($row->Itemid)) {
if (strpos($url, '?') !== false) {
$url .= '&';
} else {
$url .= '?';
}
$url .= 'Itemid=' . $row->Itemid;
}
$uri = new JURI($url);
// Check if we have an extension for this URL
$updated = false;
$option = $uri->getVar('option');
if (!empty($option)) {
$file = JPATH_ROOT . '/components/com_sef/sef_ext/' . $option . '.php';
$class = 'SefExt_' . $option;
if (!class_exists($class) && file_exists($file)) {
require $file;
}
if (class_exists($class)) {
$ext = new $class();
$metadata = $ext->generateMeta($uri);
if (is_array($metadata) && count($metadata) > 0) {
$metas = '';
foreach ($metadata as $metakey => $metaval) {
$metas .= ", `{$metakey}` = " . $db->Quote($metaval, true);
}
$query = "UPDATE `#__sefurls` SET `flag` = '0'" . $metas . " WHERE `id` = '{$row->id}'";
$db->setQuery($query);
if (!$db->query()) {
echo json_encode(array('type' => 'error', 'msg' => $db->stderr(true)));
jexit();
}
$updated = true;
}
}
}
if ($updated == false) {
// Remove flag
$query = "UPDATE `#__sefurls` SET `flag` = '0' WHERE `id` = '{$row->id}'";
$db->setQuery($query);
if (!$db->query()) {
echo json_encode(array('type' => 'error', 'msg' => $db->stderr(true)));
jexit();
}
}
}
ob_end_clean();
echo json_encode(array('type' => 'updatestep', 'updated' => $count));
jexit();
}
示例14: array
static function append_sid($hook, $url, $params = false, $is_amp = true, $session_id = false)
{
global $_SID, $_EXTRA_URL;
$arrParams = array();
$arrExtra = array();
$anchor = '';
JForumHook::fixPage();
$config =& JFactory::getConfig();
if ($url == '.php') {
$url = '/' . $config->getValue('config.phpbb_path') . '/index.php';
}
// Assign sid if session id is not specified
if ($session_id === false) {
$session_id = $_SID;
}
//Clean the url and the params first
if ($is_amp) {
$url = str_replace('&', '&', $url);
if (!is_array($params)) {
$params = str_replace('&', '&', $params);
}
}
$amp_delim = $is_amp ? '&' : '&';
$url_delim = strpos($url, '?') === false ? '?' : $amp_delim;
// Process the parameters array
if (is_array($params)) {
foreach ($params as $key => $item) {
if ($item === NULL) {
continue;
}
if ($key == '#') {
$anchor = '#' . $item;
continue;
}
$arrParams[$key] = $item;
}
} else {
if (strpos($params, '#') !== false) {
list($params, $anchor) = explode('#', $params, 2);
$anchor = '#' . $anchor;
}
parse_str($params, $arrParams);
}
//Process the extra array
if (!empty($_EXTRA_URL)) {
$extra = implode('&', $_EXTRA_URL);
parse_str($extra, $arrExtra);
}
//Create the URL
$uri = new JURI($url);
$query = $uri->getQuery(true);
$query = $query + $arrParams + $arrExtra;
$uri->setQuery($query);
//Set session id variable
if ($session_id) {
$uri->setVar('sid', $session_id);
}
//Set fragment
if ($anchor) {
$uri->setFragment($anchor);
}
$view = basename($uri->getPath(), '.php');
if (!$uri->getVar('rb_v') && $view != "style") {
if (JRequest::getVar('rb_v') == 'adm') {
if (strpos($url, $config->getValue('config.phpbb_path')) === false) {
$view = 'adm';
}
}
if (stripos($url, $config->getValue('config.phpbb_path') . '/adm') !== false) {
$view = 'adm';
}
if ($view != 'index') {
$uri->setVar('rb_v', $view);
}
}
if ($view != 'style') {
$url = 'index.php' . $uri->toString(array('query', 'fragment'));
// {} getting lost in encoding
$url = str_replace(array('%7B', '%7D'), array('{', '}'), $url);
return urldecode(JURI::base() . JRoute::_($url, $is_amp));
} else {
$url = 'style.php' . $uri->toString(array('query', 'fragment'));
$url = str_replace(array('%7B', '%7D'), array('{', '}'), $url);
return urldecode(JPATH_ROOT . '/' . $config->getValue('config.phpbb_path') . '/' . $url);
}
}
示例15: JURI
static function _($url, $xhtml = false, $ssl = null, $d = false)
{
// skip any external urls
if (strpos($url, "option") !== false && strpos($url, "option=com_fss") === false) {
return JRoute::_($url, $xhtml, $ssl);
}
global $FSSRoute_debug;
global $FSSRoute_menus;
global $FSSRoute_access;
self::$d = $d;
// get any menu items for fss
FSS_Helper::GetRouteMenus();
// Get the router
$router = JFactory::getApplication()->getRouter();
// if the url dont start with index.php, we need to add the exisitng url to what we want
if (substr($url, 0, 9) != "index.php") {
//echo "Making FUll URL: $url<br>";
$url = self::_fullURL($router, $url);
//echo "Resut : $url<br>";
}
$uri = new JURI($url);
// work out is we are in an Itemid already, if so, set it as the best match
if ($uri->hasVar('Itemid')) {
$bestmatch = $uri->getVar('Itemid');
} else {
$bestmatch = '';
}
$bestcount = 0;
$uriquery = $uri->toString(array('query'));
$urivars = FSSRoute::SplitURL($uriquery);
$sourcevars = FSSRoute::SplitURL($url);
// check through the menu item for the current url, and add any items to the new url that are missing
if ($bestmatch && array_key_exists($bestmatch, $FSSRoute_menus)) {
foreach ($FSSRoute_menus[$bestmatch] as $key => $value) {
if (!array_key_exists($key, $urivars) && !array_key_exists($key, $sourcevars)) {
$urivars[$key] = $value;
}
}
}
$current_access = 0;
if (array_key_exists(FSS_Input::getInt('Itemid'), $FSSRoute_access)) {
$current_access = $FSSRoute_access[FSS_Input::getInt('Itemid')];
}
if ($d) {
echo "Incoming Link : {$url}<br>";
echo "Cur Item ID : " . FSS_Input::getInt('Itemid') . "<br>";
//print_p($FSSRoute_menus);
}
foreach ($FSSRoute_menus as $id => $vars) {
if ($d) {
echo "{$id} => <Br>";
print_p($vars);
}
// need to check if the access level is the same
if ($current_access && array_key_exists($id, $FSSRoute_access) && $FSSRoute_access[$id] != $current_access) {
if ($d) {
echo "No Access<br>";
}
continue;
}
$count = FSSRoute::MatchVars($urivars, $vars);
if (FSS_Input::getInt('Itemid') == $id && $count > 0) {
if ($d) {
echo "Current ItemId: increase count<br>";
}
$count++;
}
if ($d) {
echo "Count: {$count}<br>";
}
if ($count > $bestcount) {
if ($d) {
echo "New best match - {$id}<br>";
}
$bestcount = $count;
$bestmatch = $id;
}
}
if ($bestcount == 0 && array_key_exists('view', $sourcevars) && substr($sourcevars['view'], 0, 6) == "admin_") {
foreach ($FSSRoute_menus as $id => $item) {
// need to check if the access level is the same
if ($current_access && array_key_exists($id, $FSSRoute_access) && $FSSRoute_access[$id] != $current_access) {
continue;
}
if ($item['view'] == "admin") {
$bestcount = 1;
$bestmatch = $id;
}
}
}
// no match found, try to fallback on the main support menu id
if ($bestcount == 0) {
foreach ($FSSRoute_menus as $id => $item) {
// need to check if the access level is the same
if ($current_access && array_key_exists($id, $FSSRoute_access) && $FSSRoute_access[$id] != $current_access) {
continue;
}
if ($item['view'] == "main") {
$bestcount = 1;
$bestmatch = $id;
//.........这里部分代码省略.........