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); }
static function _($plainURL) { $config = JFactory::getConfig(); $addSuffix = $config->get('sef_suffix', 0) == 1; $url = JRoute::_($plainURL); if ($addSuffix) { $uri = new JURI($plainURL); $format = $uri->getVar('format', 'html'); $format = strtolower($format); if (!in_array($format, array('html', 'raw'))) { // Save any query parameters if (strstr($url, '?')) { list($url, $qparams) = explode('?', $url, 2); $qparams = '?' . $qparams; } else { $qparams = ''; } // Remove the suffix $basename = basename($url); $exploded = explode(".", $basename); $extension = end($exploded); $realbase = basename($url, '.' . $extension); $url = str_replace($basename, $realbase, $url) . $qparams; // Add a format parameter $uri = new JURI($url); $uri->setVar('format', $format); $url = $uri->toString(); } } return $url; }
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; }
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('')); }
/** * 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); } }
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 &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; }
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='******'&tmpl=component'); $menu .= '<li><a href="' . $link . '"><span>' . $title . '</span></a></li>'; } $menu .= '</ul>'; } return $menu; }
/** * 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; }
/** * getVar * * @param string $name * @param null $default * * @return void */ public function getVar($name, $default = null) { $this->uri->getVar($name, $default); }
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; }
/** * 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); }
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(); }
function arsParseRouteXml(&$segments) { $query = array(); $query['view'] = 'Update'; $query['format'] = 'xml'; $menus = JMenu::getInstance('site'); $menuitem = $menus->getActive(); // Analyze the current Itemid if (!empty($menuitem)) { // Analyze URL $uri = new JURI($menuitem->link); $option = $uri->getVar('option'); // Sanity check if ($option != 'com_ars') { $Itemid = null; } else { $view = $uri->getVar('view'); $task = $uri->getVar('task'); $layout = $uri->getVar('layout'); $format = $uri->getVar('format', 'ini'); $id = $uri->getVar('id', null); if (empty($task) && !empty($layout)) { $task = $layout; } if (empty($task)) { if ($format == 'ini') { $task = 'ini'; } else { $task = 'all'; } } // make sure we can grab the ID specified in menu item options if (empty($id)) { switch ($task) { case 'category': $params = $menuitem->params instanceof JRegistry ? $menuitem->params : new JRegistry($menuitem->params); $id = $params->get('category', 'components'); break; case 'ini': case 'stream': $params = $menuitem->params instanceof JRegistry ? $menuitem->params : new JRegistry($menuitem->params); $id = $params->get('streamid', 0); break; } } if ($option == 'com_ars' && in_array($view, ['Update', 'update', 'updates'])) { switch ($task) { case 'stream': $query['task'] = 'stream'; $query['id'] = $id; return $query; break; case 'category': array_unshift($segments, $id); array_unshift($segments, 'updates'); break; case 'all': case 'ini': array_unshift($segments, 'updates'); break; } } } } $check = array_shift($segments); if ($check != 'updates') { return $query; } $cat = count($segments) ? array_shift($segments) : null; $stream = count($segments) ? array_shift($segments) : null; if (empty($cat) && empty($stream)) { return $query; } elseif (!empty($cat) && empty($stream)) { $query['task'] = 'category'; $query['id'] = $cat; } else { $query['task'] = 'stream'; $db = JFactory::getDBO(); $dbquery = $db->getQuery(true)->select('*')->from($db->qn('#__ars_updatestreams'))->where($db->qn('alias') . ' = ' . $db->q($stream))->where($db->qn('type') . ' = ' . $db->q($cat)); $db->setQuery($dbquery, 0, 1); $item = $db->loadObject(); if (empty($item)) { return $query; } $query['id'] = $item->id; } return $query; }
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); } }
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; } } } if ($bestcount == 0) { // still no match found, use any fss menu if (count($FSSRoute_menus) > 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; } $bestcount = 1; $bestmatch = $id; break; } } } if ($d) { echo "Best Found : {$bestcount}, {$bestmatch}<br>"; } // sticky menu items if (FSS_Settings::get('sticky_menus_type')) { $cur_item_id = FSS_Input::GetInt("Itemid"); if ($cur_item_id > 0) { $sticky_ids = explode(";", FSS_Settings::get('sticky_menus')); if (FSS_Settings::get('sticky_menus_type') == 1 && in_array($cur_item_id, $sticky_ids) || FSS_Settings::get('sticky_menus_type') == 2 && !in_array($cur_item_id, $sticky_ids)) { $bestcount = 0; $uri->setVar('Itemid', $cur_item_id); } } } if ($bestcount > 0) { $uri->setVar('Itemid', $bestmatch); // we need to remove parameters that are in the main url as well as the sub one // wait till 2.2 for this change as it may break stuff } if ($d) { echo "Using : " . $uri->toString(array('path', 'query', 'fragment')) . "<br>"; } return JRoute::_($uri->toString(array('path', 'query', 'fragment')), $xhtml, $ssl); }
/** * * Get menu item type * * @param String $link */ protected function getMenuItemType($link) { $uri = new JURI($link); $componentName = $uri->getVar('option'); $view = $uri->getVar('view'); // load language $lang = JFactory::getLanguage(); $lang->load($componentName . '.sys', JPATH_ADMINISTRATOR, null, false, false) || $lang->load($componentName . '.sys', JPATH_ADMINISTRATOR . '/components/' . $componentName, null, false, false) || $lang->load($componentName . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($componentName . '.sys', JPATH_ADMINISTRATOR . '/components/' . $componentName, $lang->getDefault(), false, false); $value = ''; if (!empty($componentName)) { $value = JText::_($componentName, true); $vars = null; parse_str($link, $vars); if (isset($vars['view'])) { // Attempt to load the view xml file. $file = JPATH_SITE . '/components/' . $componentName . '/views/' . $vars['view'] . '/metadata.xml'; if (JFile::exists($file) && ($xml = simplexml_load_file($file))) { // Look for the first view node off of the root node. if ($view = $xml->xpath('view[1]')) { if (!empty($view[0]['title'])) { $vars['layout'] = isset($vars['layout']) ? $vars['layout'] : 'default'; // Attempt to load the layout xml file. // If Alternative Menu Item, get template folder for layout file if (strpos($vars['layout'], ':') > 0) { // Use template folder for layout file $temp = explode(':', $vars['layout']); $file = JPATH_SITE . '/templates/' . $temp[0] . '/html/' . $componentName . '/' . $vars['view'] . '/' . $temp[1] . '.xml'; // Load template language file $lang->load('tpl_' . $temp[0] . '.sys', JPATH_SITE, null, false, false) || $lang->load('tpl_' . $temp[0] . '.sys', JPATH_SITE . '/templates/' . $temp[0], null, false, false) || $lang->load('tpl_' . $temp[0] . '.sys', JPATH_SITE, $lang->getDefault(), false, false) || $lang->load('tpl_' . $temp[0] . '.sys', JPATH_SITE . '/templates/' . $temp[0], $lang->getDefault(), false, false); } else { // Get XML file from component folder for standard layouts $file = JPATH_SITE . '/components/' . $componentName . '/views/' . $vars['view'] . '/tmpl/' . $vars['layout'] . '.xml'; } if (JFile::exists($file) && ($xml = simplexml_load_file($file))) { // Look for the first view node off of the root node. if ($layout = $xml->xpath('layout[1]')) { if (!empty($layout[0]['title'])) { $value .= ' » ' . JText::_(trim((string) $layout[0]['title']), true); } } } } } unset($xml); } else { // Special case for absent views $value .= ' » ' . JText::_($componentName . '_' . $vars['view'] . '_VIEW_DEFAULT_TITLE', true); } } } return JText::_('JSN_MENU_ITEM_TYPE', true) . $value; }
/** * check if we are at the login page & there is a return URI set. * if so, check if the return was to com_content (regarless of the view) & redirect to NotAllowed. */ public function handleLoginRedirect() { $uri = JFactory::getURI(); $task = $uri->getVar('task'); $option = $uri->getVar('option'); $view = $uri->getVar('view'); $return = $uri->getVar('return'); if (empty($task)) { $task = JRequest::getVar('task', null); } if (empty($option)) { $option = JRequest::getVar('option', null); } if (empty($view)) { $view = JRequest::getVar('view', null); } if (empty($return)) { $return = JRequest::getVar('return', '', 'method', 'base64'); $return = base64_decode($return); if (function_exists('JURI::isInternal')) { if (!JURI::isInternal($return)) { $return = ''; } } else { // Copied for pre-1.5.7 compatibility $uri = JURI::getInstance($return); $base = $uri->toString(array('scheme', 'host', 'port', 'path')); $host = $uri->toString(array('scheme', 'host', 'port')); if (strpos(strtolower($base), strtolower(JURI::base())) !== 0 && !empty($host)) { $return = ''; } } } else { $return = base64_decode($return); } if (($option == 'com_user' || $option == 'com_users') && ($view == 'login' || strpos($task, 'login') != false) && strpos($task, 'logout') == false && !empty($return) && $return != 'index.php' && (empty($_REQUEST['username']) && empty($_REQUEST['password']))) { $uri = new JURI($return); $option = $uri->getVar('option'); $cr = array('com_content', 'com_mailto', 'com_newsfeeds', 'com_poll', 'com_weblinks'); if (in_array($option, $cr) || empty($option)) { $error = new stdClass(); $error->code = 403; $this->redirectNotAllowed($error); } } }
/** * Display function */ public function display($tpl = null) { if (function_exists('error_reporting')) { error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE & ~E_STRICT); } /** load libraries for the system rener **/ JSNFactory::localimport('libraries.joomlashine.mode.rawmode'); JSNFactory::localimport('libraries.joomlashine.menu.menuitems'); /** Assignment variables **/ $jsntemplate = JSNFactory::getTemplate(); $jsnmenuitems = JSNMenuitems::getInstance(); /** get url **/ $render_url = JRequest::getVar('render_url', ''); $session = JSession::getInstance('files', array('name' => 'jsnpoweradmin')); if ($render_url == '' && $session->get('rawmode_render_url')) { $render_url = $session->get('rawmode_render_url'); } $urlRender = base64_decode($render_url); 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(); } $jsnrawmode = JSNRawmode::getInstance($params); $jsnrawmode->setParam('positions', $jsntemplate->loadXMLPositions()); $jsnrawmode->renderAll(); $this->assign('component', $jsnrawmode->getHTML('component')); $this->assign('modules', $jsnrawmode->getHTML('positions')); $this->assign('jsnmenuitems', $jsnmenuitems); $this->assign('urlRender', $urlRender); /** add toolbar buttons **/ $this->addToolBar(); /** add scripts and css **/ //$this->addMedia( $currUri->getVar('Itemid'), $urlString, array());//$jsnrawmode->getScript('positions', 'Array')); $this->addMedia($currUri->getVar('Itemid'), $urlString, $jsnrawmode->getScript('positions', 'Array')); return parent::display(); }
/** * Clear the history until the uri. * Two uris are equal if their view and id vars are the same. * * @param mixed $uri The uri until * * @return void */ public function clearHistoryUntil($uri = null) { $history = $this->history->getQueue(); if (empty($history)) { return; } if (null === $uri) { $uri = str_replace(Juri::base(), '', Juri::getInstance()->toString()); } $uri = new JURI($uri); $view = $uri->getVar('view'); $id = $uri->getVar('id'); $newHistory = array(); foreach ($history as $oldLink) { $oldUri = new Juri($oldLink); $oldView = $oldUri->getVar('view'); $oldId = $oldUri->getVar('id'); if ($oldView === $view && $oldId === $id) { break; } $newHistory[] = $oldLink; } $this->history->setQueue($newHistory); }
} ?> ><a href="index.php?option=com_installer"><span><?php echo JText::_('TPL_INSTALLER'); ?> </span></a></li><?php } ?> <?php for ($x = 0; $x < 6; $x++) { $custom_main_acl = $this->params->get('custom' . $x . 'Acl', 0); $custom_main_name = $this->params->get('custom' . $x . 'Name'); $custom_main_link = $this->params->get('custom' . $x . 'Link'); if (strpos($custom_main_link, 'http') === false) { $custom_uri = new JURI($custom_main_link); $custom_option = $custom_uri->getVar('option'); if ($user->authorise('core.manage ,' . $custom_option) && $custom_main_acl != 0) { $html .= '<li><a href="' . $custom_main_link . '">' . htmlspecialchars($custom_main_name) . '</a></li>'; } } else { if ($user->authorise('core.manage', 'com_content') && $custom_main_acl != 0) { $html .= '<li><a href="' . $custom_main_link . '">' . htmlspecialchars($custom_main_name) . '</a></li>'; } } } ?> <?php // Get the current component $current_menu = substr($option, 4); if ($option != "com_cpanel" && $option != "com_menus" && $option != "com_categories" && $option != "com_content" && $option != "com_modules" && $option != "com_plugins" && $option != "com_templates" && $option != "com_users") { ?>
/** * Using CURL get page source. * * @param string $url Link to get content * * @return string */ protected static function curlResponse($url) { $options = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_USERAGENT => "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13", CURLOPT_AUTOREFERER => true, CURLOPT_CONNECTTIMEOUT => 120, CURLOPT_TIMEOUT => 120, CURLOPT_MAXREDIRS => 10, CURLOPT_SSL_VERIFYPEER => false); $ch = curl_init($url); curl_setopt_array($ch, $options); $contents = curl_exec($ch); $err = curl_errno($ch); $errmsg = curl_error($ch); $header = curl_getinfo($ch); curl_close($ch); if ($err > 0) { exit('cUrl error number: ' . $err); } $response = new stdClass(); $response->contents = $contents; $response->redirect_url = $header['redirect_url']; if ($response->redirect_url != self::$_renderUrl and trim($response->redirect_url) != '') { $old_uri = new JURI(self::$_renderUrl); $redirect_uri = new JURI($response->redirect_url); if ($old_uri->hasVar('tp') and !$redirect_uri->hasVar('tp')) { $redirect_uri->setVar('tp', 1); } if ($old_uri->hasVar('jsntpl_position') and !$redirect_uri->hasVar('jsntpl_position')) { $redirect_uri->setVar('jsntpl_position', 1); } if ($old_uri->hasVar('secret_key') and !$redirect_uri->hasVar('secret_key')) { $config = JFactory::getConfig(); $secret = $config->get('secret'); $redirect_uri->setVar('secret_key', md5($secret)); } if ($old_uri->hasVar('Itemid') and !$redirect_uri->hasVar('Itemid')) { $redirect_uri->setVar('Itemid', $old_uri->getVar('Itemid')); } // Save redirect url self::$_renderUrl = $redirect_uri->toString(); $response = self::curlResponse(self::$_renderUrl); } return $response; }
/** * 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(); } }
/** * Returns the default priority value for the url * * @param JURI $uri * @return int */ function _getPriorityDefault(&$uri) { $itemid = $uri->getVar('Itemid'); if (is_null($itemid)) { return _COM_SEF_PRIORITY_DEFAULT; } else { return _COM_SEF_PRIORITY_DEFAULT_ITEMID; } }
function updateMetaNext() { $db =& JFactory::getDBO(); $sefConfig =& SEFConfig::getConfig(); // Load all the URLs $query = "SELECT `id`, `sefurl`, `origurl`, `Itemid` FROM `#__sefurls` WHERE `locked` = '0' AND `trashed` = '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 //$db->setQuery("SELECT COUNT(`id`) FROM `#__sefurls` WHERE `dateadd` = '0000-00-00' AND `locked` = '0' AND `trashed` = '0'"); //$count = $db->loadResult(); $obj = new stdClass(); $obj->type = 'completed'; $obj->updated = 0; return json_encode($obj); } // Load the needed classes jimport('joomla.application.router'); require_once JPATH_ROOT . DS . 'includes' . DS . 'application.php'; require_once JPATH_ROOT . DS . 'components' . DS . 'com_sef' . DS . 'sef.router.php'; if (SEFTools::JoomFishInstalled()) { require_once JPATH_ROOT . DS . 'components' . DS . 'com_joomfish' . DS . 'helpers' . DS . 'defines.php'; JLoader::register('JoomfishManager', JOOMFISH_ADMINPATH . DS . 'classes' . DS . 'JoomfishManager.class.php'); JLoader::register('JoomFishVersion', JOOMFISH_ADMINPATH . DS . 'version.php'); JLoader::register('JoomFish', JOOMFISH_PATH . DS . 'helpers' . DS . 'joomfish.class.php'); } // OK, we've got some data, let's update them $count = count($rows); // Check if JoomFish is present if (SEFTools::JoomFishInstalled()) { // We need to fool JoomFish to think we're running in frontend $mainframe =& JFactory::getApplication(); $mainframe->_clientId = 0; // Load and initialize JoomFish plugin if (!class_exists('plgSystemJFDatabase')) { require JPATH_PLUGINS . DS . 'system' . DS . 'jfdatabase.php'; } $params =& JPluginHelper::getPlugin('system', 'jfdatabase'); $dispatcher =& JDispatcher::getInstance(); $plugin = new plgSystemJFDatabase($dispatcher, (array) $params); $plugin->onAfterInitialise(); // Set the mainframe back to its original state $mainframe->_clientId = 1; } // 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 . DS . 'components' . DS . 'com_sef' . DS . 'sef_ext' . DS . $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()) { return $db->stderr(true); $updated = false; } else { $updated = true; } } } } if ($updated == false) { // Remove flag $query = "UPDATE `#__sefurls` SET `flag` = '0' WHERE `id` = '{$row->id}'"; $db->setQuery($query); $db->query(); } } ob_end_clean(); $obj = new stdClass(); $obj->type = 'updatestep'; $obj->updated = $count; return json_encode($obj); }