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); }
/** * Function for getting the list of languages * * @return array Language list */ public static function getList() { $app = JFactory::getApplication(); $languages = JLanguageHelper::getLanguages(); $db = JFactory::getDbo(); $Itemid = $app->input->getInt('Itemid', 0); $uri = new JURI(Juri::current()); $uri->delVar('lang'); $uri->delVar('Itemid'); $location = htmlspecialchars($uri->getQuery()); if (!empty($location)) { $location .= '&'; } if (!$Itemid) { $active = $app->getMenu()->getActive(); if ($active) { $Itemid = $active->id; } } // For every language we load menu items language specific alias and params foreach ($languages as $i => $language) { $db->forceLanguageTranslation = $language->lang_code; RMenu::resetJoomlaMenuItems(); $db->forceLanguageTranslation = false; $languages[$i]->active = $language->lang_code == JFactory::getLanguage()->getTag(); $languages[$i]->link = RRoute::_('index.php?' . $location . 'lang=' . $language->sef . ($Itemid > 0 ? '&Itemid=' . $Itemid : '')); } // After we are done we reset it the way it was RMenu::resetJoomlaMenuItems(); return $languages; }
public function testDelVar() { $this->object->parse('http://*****:*****@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('')); }
/** * Set URL for get front-end content. Correct URL * * @param string $url Link * * @return void */ public static function setRenderUrl($url = '') { $uri = new JURI($url); if ($uri->getScheme() == '') { $scheme = 'http'; if (@$_SERVER['HTTPS']) { $scheme = 'https'; } $uri->setScheme($scheme); } @(list($host, $port) = explode(':', $_SERVER['HTTP_HOST'])); if ($uri->getHost() == '') { $uri->setHost($host); } if ($uri->getPort() == '') { $uri->setPort($port); } if (strtolower($uri->getHost()) != strtolower($host)) { self::$_isExternal = true; } else { if (!$uri->hasVar('jsntpl_position')) { $uri->setVar('jsntpl_position', '1'); } if (!$uri->hasVar('secret_key')) { $config = JFactory::getConfig(); $secret = $config->get('secret'); $uri->setVar('secret_key', md5($secret)); } if ($uri->hasVar('Itemid') and $uri->getVar('Itemid') == '') { $uri->delVar('Itemid'); } self::$_renderUrl = $uri->toString(); } }
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); }
function _uriToUrl($uri, $removeVariables = null) { // Create new JURI object $url = new JURI($uri->toString(array('path', 'query', 'fragment'))); // Remove variables if needed if (!empty($removeVariables)) { if (is_array($removeVariables)) { foreach ($removeVariables as $var) { $url->delVar($var); } } else { $url->delVar($removeVariables); } } // sort variables $vars = $url->getQuery(true); ksort($vars); // Move option to beginning if (isset($vars['option'])) { $opt = $vars['option']; unset($vars['option']); $vars = array_merge(array('option' => $opt), $vars); } // Set vars $url->setQuery($vars); // Create string for db return $url->toString(array('path', 'query')); }
function _uriToUrl($uri, $removeVariables = null) { // Create new JURI object $url = new JURI($uri->toString(array('path', 'query', 'fragment'))); // Remove variables if needed if (!empty($removeVariables)) { if (is_array($removeVariables)) { foreach ($removeVariables as $var) { $url->delVar($var); } } else { $url->delVar($removeVariables); } } // sort variables ksort($url->_vars); $opt = $url->getVar('option'); if (!is_null($opt)) { $url->delVar('option'); array_unshift($url->_vars, array('option' => $opt)); } $url->_query = null; // Create string for db return $url->toString(array('path', 'query')); }
/** * 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; }
/** * delVar * * @param string $name * * @return void */ public function delVar($name) { $this->uri->delVar($name); }
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; }
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; }
/** * Set URL for get front-end content. Correct URL * * @param string $url Link * * @return void */ public function setRenderUrl($url = '') { $uri = new JURI($url); if ($uri->getScheme() == '') { $scheme = 'http'; if (@$_SERVER['HTTPS']) { $scheme = 'https'; } $uri->setScheme($scheme); } @(list($host, $port) = explode(':', $_SERVER['HTTP_HOST'])); if ($uri->getHost() == '') { $uri->setHost($host); } if ($uri->getPort() == '') { $uri->setPort($port); } if (JString::strtolower($uri->getHost()) != JString::strtolower($host)) { $this->_isExternal = true; } else { if (!$uri->hasVar('poweradmin')) { $uri->setVar('poweradmin', '1'); } if ($uri->hasVar('Itemid') and $uri->getVar('Itemid') == '') { $uri->delVar('Itemid'); } $this->_renderUrl = $uri->toString(); } }