public static function getDBO() { if (!isset(self::$_dbo)) { self::$_dbo = ShlDbHelper::getDb(); } }
* * @author Yannick Gaultier * @copyright (c) Yannick Gaultier 2012 * @package sh404sef * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL * @version 4.1.0.1559 * @date 2013-04-25 */ defined('_JEXEC') or die('Direct Access to this location is not allowed.'); global $Itemid; global $sh_LANG; $mainframe = JFactory::getApplication(); $shPageInfo =& Sh404sefFactory::getPageInfo(); // get page details gathered by system plugin $sefConfig =& Sh404sefFactory::getConfig(); $database = ShlDbHelper::getDb(); $view = JREQUEST::getCmd('view', null); $catid = JREQUEST::getInt('catid', null); $id = JREQUEST::getInt('id', null); $limit = JREQUEST::getInt('limit', null); $limitstart = JREQUEST::getInt('limitstart', null); $layout = JREQUEST::getCmd('layout', null); $showall = JREQUEST::getInt('showall', null); $format = JREQUEST::getCmd('format', null); $print = JREQUEST::getInt('print', null); $tmpl = JREQUEST::getCmd('tmpl', null); $lang = JREQUEST::getString('lang', null); $shLangName = empty($lang) ? $shPageInfo->currentLanguageTag : shGetNameFromIsoCode($lang); $shLangIso = isset($lang) ? $lang : shGetIsoCodeFromName($shPageInfo->currentLanguageTag); $shLangIso = shLoadPluginLanguage('com_content', $shLangIso, 'COM_SH404SEF_CREATE_NEW'); //-------------------------------------------------------------
public function create($string, &$vars, &$shAppendString, $shLanguage, $shSaveString = '', &$originalUri) { // get our config objects $pageInfo = Sh404sefFactory::getPageInfo(); $sefConfig = Sh404sefFactory::getConfig(); // get DB // backward compat, some plugins rely on having this object available in scope $database = ShlDbHelper::getDb(); ShlSystem_Log::debug('sh404sef', 'Entering sef404 create function with ' . $string); // extract request vars to have them readily available ShlSystem_Log::debug('sh404sef', 'Extracting $vars:', print_r($vars, true)); extract($vars); // maybe one of them interfere with the variable holding our result? if (isset($title)) { // V 1.2.4.r : protect against components using 'title' as GET vars $sh404SEF_title = $title; // means that $sh404SEF_title has to be used in plugins or extensions } $title = array(); // V 1.2.4.r // use custom method to find about correct plugin to use // can be overwritten by a user plugin $extPlugin =& Sh404sefFactory::getExtensionPlugin($option); // which plugin file are we supposed to use? $extPluginPath = $extPlugin->getSefPluginPath($vars); $pluginType = $extPlugin->getPluginType(); // various ways to handle various SEF url plugins switch ($pluginType) { // use Joomla router.php file in extension dir case Sh404sefClassBaseextplugin::TYPE_JOOMLA_ROUTER: // Load the plug-in file. ShlSystem_Log::debug('sh404sef', 'Loading component own router.php file'); $functionName = ucfirst(str_replace('com_', '', $option)) . 'BuildRoute'; if (!function_exists($functionName)) { include JPATH_ROOT . '/components/' . $option . '/router.php'; } $originalVars = empty($originalUri) ? $vars : $originalUri->getQuery($asArray = true); $title = $functionName($originalVars); $title = $pageInfo->router->encodeSegments($title); // manage GET var lists ourselves, as Joomla router.php does not do it if (!empty($vars)) { // there are some unused GET vars, we must transfer them to our mechanism, so // that they are eventually appended to the sef url foreach ($vars as $k => $v) { switch ($k) { case 'option': case 'Itemid': shRemoveFromGETVarsList($k); break; default: // if variable has not been used in sef url, add it to list of variables to be // appended to the url as query string elements if (array_key_exists($k, $originalVars)) { shAddToGETVarsList($k, $v); } else { shRemoveFromGETVarsList($k); } break; } } } // special case for search component, as router.php encode the search word in the url // we can't do that, as we are storing each url in the db if (isset($originalVars['option']) && $originalVars['option'] == 'com_search' && !empty($vars['searchword'])) { // router.php has encoded that in the url, we need to undo $title = array(); $originalVars['searchword'] = $vars['searchword']; shAddToGETVarsList('searchword', $vars['searchword']); if (!empty($vars['view'])) { $vars['view'] = $vars['view']; shAddToGETVarsList('view', $vars['view']); } } // handle menu items, having only a single Itemid in the url // (router.php will return an empty array in that case, even if we have restored // the full non-sef url, as we already did) /* * Build the application route */ $tmp = ''; if (empty($title) && isset($vars['Itemid']) && !empty($vars['Itemid'])) { $menu = JFactory::getApplication()->getMenu(); $item = $menu->getItem($vars['Itemid']); if (is_object($item) && $vars['option'] == $item->component) { $title[] = $item->route; } } if (empty($title)) { $title[] = substr($vars['option'], 4); } // add user defined prefix $prefix = shGetComponentPrefix($option); if (!empty($prefix)) { array_unshift($title, $prefix); } // now process the resulting title string $string = shFinalizePlugin($string, $title, $shAppendString, '', isset($limit) ? $limit : null, isset($limitstart) ? $limitstart : null, isset($shLangName) ? $shLangName : null, isset($showall) ? $showall : null, $suppressPagination = true); break; // use sh404sef plugins, either in ext. dir or in sh404sef dir // use sh404sef plugins, either in ext. dir or in sh404sef dir case Sh404sefClassBaseextplugin::TYPE_SH404SEF_ROUTER: ShlSystem_Log::debug('sh404sef', 'Loading sh404SEF plugin in ' . $extPluginPath); include $extPluginPath; break; // Joomsef plugins // Joomsef plugins case Sh404sefClassBaseextplugin::TYPE_JOOMSEF_ROUTER: Sh404sefHelperExtplugins::loadJoomsefCompatLibs(); include_once $extPluginPath; $className = 'SefExt_' . $option; $plugin = new $className(); if (!shIsHomepage($string)) { // make sure the plugin does not try to calculate pagination $params =& SEFTools::GetExtParams('com_content'); $params->set('pagination', '1'); // ask plugin to build url $plugin->beforeCreate($originalUri); $result = $plugin->create($originalUri); $title = empty($result['title']) ? array() : $result['title']; $plugin->afterCreate($originalUri); // make sure we have a url if (empty($title) && isset($vars['Itemid']) && !empty($vars['Itemid'])) { $menu = JFactory::getApplication()->getMenu(); $item = $menu->getItem($vars['Itemid']); if (is_object($item) && $vars['option'] == $item->component) { $title[] = $item->route; } } $prefix = shGetComponentPrefix($option); if (!empty($prefix)) { array_unshift($title, $prefix); } if (empty($title) && !shIsHomepage($string)) { $title[] = substr($vars['option'], 4); } list($usedVars, $ignore) = $plugin->getNonSefVars($result); if (!empty($ignore)) { $usedVars = array_merge($usedVars, $ignore); } } else { $string = ''; $title[] = '/'; $usedVars = array(); } // post process result to adjust to our workflow if (!empty($vars)) { foreach ($vars as $key => $value) { if (!array_key_exists($key, $usedVars)) { shRemoveFromGETVarsList($key); } } } // finalize url $string = shFinalizePlugin($string, $title, $shAppendString = '', $shItemidString = '', isset($limit) ? $limit : null, isset($limitstart) ? $limitstart : null, isset($shLangName) ? $shLangName : null, isset($showall) ? $showall : null); break; // Acesef plugins // Acesef plugins case Sh404sefClassBaseextplugin::TYPE_ACESEF_ROUTER: Sh404sefHelperExtplugins::loadAcesefCompatLibs(); include_once $extPluginPath; $className = 'AceSEF_' . $option; $plugin = new $className(); $plugin->AcesefConfig = AcesefFactory::getConfig(); // some plugins appear to not call the constructor parent, and so AcesefConfig is not set $tmp = JPluginHelper::getPlugin('sh404sefextacesef', $option); $params = new JRegistry(); $params->loadString($tmp->params); $plugin->setParams($params); $segments = array(); $do_sef = true; $metadata = array(); $item_limitstart = 0; $plugin->beforeBuild($originalUri); $originalVars = empty($originalUri) ? $vars : $originalUri->getQuery($asArray = true); $plugin->build($originalVars, $title, $do_sef, $metadata, $item_limitstart); $plugin->afterBuild($originalUri); $prefix = shGetComponentPrefix($option); if (empty($title) && isset($vars['Itemid']) && !empty($vars['Itemid'])) { $menu = JFactory::getApplication()->getMenu(); $item = $menu->getItem($vars['Itemid']); if (is_object($item) && $vars['option'] == $item->component) { $title[] = $item->route; } } if (!empty($prefix)) { array_unshift($title, $prefix); } if (empty($title) && !shIsHomepage($string)) { $title[] = substr($vars['option'], 4); } // acesef plugin don't remove used vars from our GET var manager // we'll do it now. Vars used are those not present anymore in // $originalVars // they will be reappended to the SEF url by shFinalizePlugin $usedVars = array_diff($vars, $originalVars); if (!empty($usedVars)) { foreach ($usedVars as $key => $value) { shRemoveFromGETVarsList($key); } } // remove Itemid and option, as these are not unset by plugin shRemoveFromGETVarsList('Itemid'); shRemoveFromGETVarsList('option'); // finalize url $string = shFinalizePlugin($string, $title, $shAppendString = '', $shItemidString = '', isset($limit) ? $limit : null, isset($limitstart) ? $limitstart : null, isset($shLangName) ? $shLangName : null, isset($showall) ? $showall : null); break; default: ShlSystem_Log::debug('sh404sef', 'Falling back to sefGetLocation'); if (empty($sefConfig->defaultComponentStringList[str_replace('com_', '', $option)])) { $title[] = getMenuTitle($option, isset($task) ? $task : null, null, null, $shLanguage); } else { $title[] = $sefConfig->defaultComponentStringList[str_replace('com_', '', $option)]; } if ($title[0] != '/') { $title[] = '/'; // V 1.2.4.q getMenuTitle can now return '/' } if (count($title) > 0) { // V 1.2.4.q use $shLanguage insted of $lang (lang name rather than lang code) $string = sef_404::sefGetLocation($string, $title, isset($task) ? $task : null, isset($limit) ? $limit : null, isset($limitstart) ? $limitstart : null, isset($shLanguage) ? $shLanguage : null); } break; } return $string; }
/** Returns the array of texts used by the extension for creating URLs * in currently selected language (for JoomFish support) * * @param string Extension name * @return array Extension's texts */ function getExtTexts($option, $lang = '') { $database = ShlDbHelper::getDb(); static $extTexts; if ($option == '') { return false; } // Set the language if ($lang == '') { $lang = SEFTools::getLangLongCode(); } if (!isset($extTexts)) { $extTexts = array(); } if (!isset($extTexts[$option])) { $extTexts[$option] = array(); } if (!isset($extTexts[$option][$lang])) { $extTexts[$option][$lang] = array(); // If lang is different than current language, change it if ($lang != SEFTools::getLangLongCode()) { $language = JFactory::getLanguage(); $oldLang = $language->setLanguage($lang); $language->load(); } $query = "SELECT `id`, `name`, `value` FROM `#__sefexttexts` WHERE `extension` = '{$option}'"; $database->setQuery($query); $texts = $database->loadObjectList(); if (is_array($texts) && count($texts) > 0) { foreach (array_keys($texts) as $i) { $name = $texts[$i]->name; $value = $texts[$i]->value; $extTexts[$option][$lang][$name] = $value; } } // Set the language back to previously selected one if (isset($oldLang) && $oldLang != SEFTools::getLangLongCode()) { $language = JFactory::getLanguage(); $language->setLanguage($oldLang); $language->load(); } } return $extTexts[$option][$lang]; }
function shAddPaginationInfo($limit, $limitstart, $showall, $iteration, $url, $location, $shSeparator = null, $defaultListLimitValue = null) { $mainframe = JFactory::getApplication(); //echo 'Incoming pagination : ' . $url . ' | limit : ' . $limit . ' | start : ' . $limitstart . "\n"; $pageInfo =& Sh404sefFactory::getPageInfo(); // get page details gathered by system plugin $sefConfig =& Sh404sefFactory::getConfig(); $database = ShlDbHelper::getDb(); // get a default limit value, for urls where it's missing $listLimit = shGetDefaultDisplayNumFromURL($url, $includeBlogLinks = true); $defaultListLimit = is_null($defaultListLimitValue) ? shGetDefaultDisplayNumFromConfig($url, $includeBlogLinks = false) : $defaultListLimitValue; //echo 'Incoming pagination : $listLimit : ' . $listLimit . ' | $defaultListLimit : ' . $defaultListLimit . "\n"; // clean suffix and index file before starting to add things to the url // clean suffix if (strpos($url, 'option=com_content') !== false && strpos($url, 'format=pdf') !== false) { $shSuffix = '.pdf'; } else { $shSuffix = $sefConfig->suffix; } $suffixLength = JString::strLen($shSuffix); if (!empty($shSuffix) && $shSuffix != '/' && JString::substr($location, -$suffixLength) == $shSuffix) { $location = JString::substr($location, 0, JString::strlen($location) - $suffixLength); } // clean index file if ($sefConfig->addFile && (empty($shSuffix) || JString::subStr($location, -$suffixLength) != $shSuffix)) { $indexFileLength = JString::strlen($sefConfig->addFile); if ($sefConfig->addFile != '/' && JString::substr($location, -$indexFileLength) == $sefConfig->addFile) { $location = JString::substr($location, 0, JString::strlen($location) - $indexFileLength); } } // do we have a trailing slash ? if (empty($shSeparator)) { $shSeparator = JString::substr($location, -1) == '/' ? '' : '/'; } if (!empty($limit) && is_numeric($limit)) { $pagenum = intval($limitstart / $limit); $pagenum++; } else { if (!isset($limit) && !empty($limitstart)) { // only limitstart if (strpos($url, 'option=com_content') !== false && strpos($url, 'view=article') !== false) { $pagenum = intval($limitstart + 1); // multipage article } else { $pagenum = intval($limitstart / $listLimit) + 1; // blogs, tables, ... } } else { $pagenum = $iteration; } } // Make sure we do not end in infite loop here. if ($pagenum < $iteration) { $pagenum = $iteration; } // shumisha added to handle table-category and table-section which may have variable number of items per page // There still will be a problem with filter, which may reduce the total number of items. Thus the item we are looking for if ($sefConfig->alwaysAppendItemsPerPage || strpos($url, 'option=com_virtuemart') && $sefConfig->shVmUsingItemsPerPage) { $shMultPageLength = $sefConfig->pagerep . (empty($limit) ? $listLimit : $limit); } else { $shMultPageLength = ''; } // shumisha : modified to add # of items per page to URL, for table-category or section-category if (!empty($sefConfig->pageTexts[$pageInfo->currentLanguageTag]) && false !== strpos($sefConfig->pageTexts[$pageInfo->currentLanguageTag], '%s')) { $page = str_replace('%s', $pagenum, $sefConfig->pageTexts[$pageInfo->currentLanguageTag]) . $shMultPageLength; } else { $page = $sefConfig->pagerep . $pagenum . $shMultPageLength; } // V 1.2.4.t special processing to replace page number by headings $shPageNumberWasReplaced = false; if (strpos($url, 'option=com_content') !== false && strpos($url, 'view=article') !== false && !empty($limitstart)) { // this is multipage article - limitstart instead of limit in J1.5 if ($sefConfig->shMultipagesTitle) { parse_str($url, $shParams); if (!empty($shParams['id'])) { $shPageTitle = ''; try { $contentElement = ShlDbHelper::selectObject('#__content', array('id', 'fulltext', 'introtext'), array('id' => $shParams['id'])); } catch (Exception $e) { JError::raise(E_ERROR, 500, $e->getMessage()); } $contentText = $contentElement->introtext . $contentElement->fulltext; if (!empty($contentElement) && strpos($contentText, 'class="system-pagebreak') !== false) { // search for mospagebreak tags // copied over from pagebreak plugin // expression to search for $regex = '#<hr([^>]*)class=(\\"|\')system-pagebreak(\\"|\')([^>]*)\\/>#iU'; // find all instances of mambot and put in $matches $shMatches = array(); preg_match_all($regex, $contentText, $shMatches, PREG_SET_ORDER); // adds heading or title to <site> Title if (empty($limitstart)) { // if first page use heading of first mospagebreak /* if ( $shMatches[0][2] ) { parse_str( html_entity_decode( $shMatches[0][2] ), $args ); if ( @$args['heading'] ) { $shPageTitle = stripslashes( $args['heading'] ); } }*/ } else { // for other pages use title of mospagebreak if ($limitstart > 0 && $shMatches[$limitstart - 1][1]) { $args = JUtility::parseAttributes($shMatches[$limitstart - 1][0]); if (@$args['title']) { $shPageTitle = $args['title']; } else { if (@$args['alt']) { $shPageTitle = $args['alt']; } else { // there is a page break, but no title. Use a page number $shPageTitle = str_replace('%s', $limitstart + 1, $sefConfig->pageTexts[$pageInfo->currentLanguageTag]); } } } } } if (!empty($shPageTitle)) { // found a heading, we should use that as a Title $location .= $shSeparator . titleToLocation($shPageTitle); } $shPageNumberWasReplaced = true; // always set the flag, otherwise we'll a Page-1 added } } else { // mutiple pages article, but we don't want to use smart title. // directly use limitstart $page = str_replace('%s', $limitstart + 1, $sefConfig->pageTexts[$pageInfo->currentLanguageTag]); } } // maybe this is a multipage with "showall=1" if (strpos($url, 'option=com_content') !== false && strpos($url, 'view=article') !== false && strpos($url, 'showall=1') !== false) { // this is multipage article with showall $tempTitle = JText::_('All Pages'); $location .= $shSeparator . titleToLocation($tempTitle); $shPageNumberWasReplaced = true; // always set the flag, otherwise we'll a Page-1 added } // make sure we remove bad characters $takethese = str_replace('|', '', $sefConfig->friendlytrim); $location = JString::trim($location, $takethese); // add page number if (!$shPageNumberWasReplaced && (!isset($limitstart) && (isset($limit) && $limit != 1 && $limit != $listLimit && $limit != $defaultListLimit) || !empty($limitstart))) { $location .= $shSeparator . $page; } // add suffix if (!empty($shSuffix) && !empty($location) && $location != '/' && JString::substr($location, -1) != '/') { $location = $shSuffix == '/' ? $location . $shSuffix : str_replace($shSuffix, '', $location) . $shSuffix; } // add default index file if ($sefConfig->addFile) { // V 1.2.4.t if (empty($shSuffix) || !empty($shSuffix) && JString::subStr($location, -$suffixLength) != $shSuffix) { $location .= (JString::substr($location, -1) == '/' ? '' : '/') . $sefConfig->addFile; } } return JString::ltrim($location, '/'); }
/** * Returns the Joomla category for given id * * @param int $catid * @return string */ function _getCategories($catid, $useAlias = false) { $sefConfig =& SEFConfig::getConfig(); $database = ShlDbHelper::getDb(); $jfTranslate = $sefConfig->translateNames ? ', `id`' : ''; $cat_table = "#__categories"; $field = 'title'; if ($useAlias) { $field = 'alias'; } // Let's find the Joomla category name for given category ID $title = ''; if (isset($catid) && $catid != 0) { $catid = intval($catid); $query = "SELECT `{$field}` AS `title` {$jfTranslate} FROM `{$cat_table}` WHERE `id` = '{$catid}'"; $database->setQuery($query); $rows = $database->loadObjectList(); try { if ($database->getErrorNum()) { $msg = JText::_('Database error'); if (JDEBUG) { $msg .= ': ' . $database->stderr(); } throw new Exception($msg); } } catch (Exception $e) { JError::raiseError('JoomSEF Error', $e->getMessage()); } if (@count($rows) > 0 && !empty($rows[0]->title)) { $title = $rows[0]->title; } } return $title; }
function revert($route, &$disabled) { $db = ShlDbHelper::getDb(); $sefConfig =& SEFConfig::getConfig(); $cache =& SEFCache::getInstance(); $vars = array(); $route = html_entity_decode(urldecode($route)); $route = str_replace(' ', $sefConfig->replacement, $route); $routeNoSlash = rtrim($route, '/'); // try to use cache if ($sefConfig->useCache) { $row = $cache->getNonSefUrl($route); } else { $row = null; } // cache worked if ($row) { $fromCache = true; } else { // URL isn't in cache or cache disabled $fromCache = false; if ($sefConfig->transitSlash) { $where = "(`sefurl` = " . $db->Quote($routeNoSlash) . ") OR (`sefurl` = " . $db->Quote($routeNoSlash . '/') . ")"; } else { $where = "`sefurl` = " . $db->Quote($route); } $sql = "SELECT * FROM `#__sefurls` WHERE ({$where}) AND (`origurl` != '') AND (`trashed` = '0') ORDER BY `priority` LIMIT 1"; $db->setQuery($sql); $row = $db->loadObject(); } if ($row) { // Set the disabled flag (old cache records don't need to have enabled set) if (!isset($row->enabled)) { $row->enabled = 1; } if ($row->enabled) { $disabled = false; } else { $disabled = true; } // Use the already created URL $string = $row->origurl; if (isset($row->Itemid) && $row->Itemid != '') { $string .= (strpos($string, '?') ? '&' : '?') . 'Itemid=' . $row->Itemid; } // update the hits count if needed if (!$fromCache || $sefConfig->cacheRecordHits) { $where = ''; if (!empty($row->id)) { $where = " WHERE `id` = '{$row->id}'"; } else { $where = " WHERE `sefurl` = " . $db->Quote($row->sefurl) . " AND `origurl` != '' AND `trashed` = '0'"; } $db->setQuery("UPDATE `#__sefurls` SET `cpt` = (`cpt` + 1)" . $where); $db->query(); } $string = str_replace('&', '&', $string); $QUERY_STRING = str_replace('index.php?', '', $string); parse_str($QUERY_STRING, $vars); // Moved to JoomSEF::_parseSefUrl() /* if ($sefConfig->setQueryString) { $_SERVER['QUERY_STRING'] = $QUERY_STRING; } */ // prepare the meta tags array for MetaBot // only if URL is not disabled if (!$disabled) { $mainframe = JFactory::getApplication(); if (!empty($row->metatitle)) { JoomSEF::set('sef.meta.title', $row->metatitle); } if (!empty($row->metadesc)) { JoomSEF::set('sef.meta.desc', $row->metadesc); } if (!empty($row->metakey)) { JoomSEF::set('sef.meta.key', $row->metakey); } if (!empty($row->metalang)) { JoomSEF::set('sef.meta.lang', $row->metalang); } if (!empty($row->metarobots)) { JoomSEF::set('sef.meta.robots', $row->metarobots); } if (!empty($row->metagoogle)) { JoomSEF::set('sef.meta.google', $row->metagoogle); } if (!empty($row->canonicallink)) { JoomSEF::set('sef.link.canonical', $row->canonicallink); } if (!empty($row->metacustom)) { $metacustom = @unserialize($row->metacustom); if (!empty($metacustom)) { JoomSEF::set('sef.meta.custom', $metacustom); } } } // If cache is enabled but URL isn't in cache yet, add it if ($sefConfig->useCache && !$fromCache) { $cache->addUrl($row->origurl, $row->sefurl, $row->cpt + 1, $row->Itemid, $row->metatitle, $row->metadesc, $row->metakey, $row->metalang, $row->metarobots, $row->metagoogle, $row->canonicallink, $row->metacustom, $row->enabled, $row->sef); } } elseif ($sefConfig->useMoved) { // URL not found, let's try the Moved Permanently table $where = ''; if ($sefConfig->transitSlash) { $where = '(`old` = ' . $db->Quote($routeNoSlash) . ') OR (`old` = ' . $db->Quote($routeNoSlash . '/') . ')'; } else { $where = '`old` = ' . $db->Quote($route); } $db->setQuery("SELECT * FROM `#__sefmoved` WHERE {$where}"); $row = $db->loadObject(); if ($row) { // URL found, let's update the lastHit in table and redirect $db->setQuery("UPDATE `#__sefmoved` SET `lastHit` = NOW() WHERE `id` = '{$row->id}'"); $db->query(); $root = JURI::root(); $f = $l = ''; if (!headers_sent($f, $l)) { // Let's build absolute URL from our link if (strstr($row->new, $root) === false) { $url = $root; if (substr($url, -1) != '/') { $url .= '/'; } if (substr($row->new, 0, 1) == '/') { $row->new = substr($row->new, 1); } $url .= $row->new; } else { $url = $row->new; } // Use the link to redirect header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $url); header('Connection: close'); exit; } else { JoomSEF::_headers_sent_error($f, $l, __FILE__, __LINE__); } } } return $vars; }
public function loadHomepages() { $app = JFactory::getApplication(); if ($app->isAdmin()) { return; } // store default links in each language jimport('joomla.language.helper'); $languages = JLanguageHelper::getLanguages(); $this->isMultilingual = shIsMultilingual(); $defaultLanguage = shGetDefaultLang(); if ($this->isMultilingual === false || $this->isMultilingual == 'joomla') { $menu = JFactory::getApplication()->getMenu(); foreach ($languages as $language) { $menuItem = $menu->getDefault($language->lang_code); if (!empty($menuItem)) { $this->homeLinks[$language->lang_code] = $this->_prepareLink($menuItem); if ($language->lang_code == $defaultLanguage) { $this->homeLink = $this->homeLinks[$language->lang_code]; $this->homeItemid = $menuItem->id; } } } // find about the "All" languages home link $menuItem = $menu->getDefault('*'); if (!empty($menuItem)) { $this->allLangHomeLink = $this->_prepareLink($menuItem); } } else { // trouble starts $db = ShlDbHelper::getDb(); $query = $db->getQuery(true); $query->select('id,language,link'); $query->from('#__menu'); $query->where('home <> 0'); try { $db->setQuery($query); $items = $db->shlloadObjectList('language'); } catch (Exception $e) { ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage()); } if (!empty($items)) { if (count($items) == 1) { $tmp = array_values($items); $defaultItem = $tmp[0]; } if (empty($defaultItem)) { $defaultItem = empty($items[$defaultLanguage]) ? null : $items[$defaultLanguage]; } if (empty($defaultItem)) { $defaultItem = empty($items['*']) ? null : $items['*']; } foreach ($languages as $language) { if (!empty($items[$language->lang_code])) { $this->homeLinks[$language->lang_code] = $this->_prepareLink($items[$language->lang_code]); } else { // no menu item for home link // let's try to build one $this->homeLinks[$language->lang_code] = $this->_prepareLink($defaultItem, shGetIsoCodeFromName($language->lang_code)); } if ($language->lang_code == $defaultLanguage) { $this->homeLink = $this->homeLinks[$language->lang_code]; $this->homeItemid = $defaultItem->id; $this->allLangHomeLink = shCleanUpLang($this->homeLinks[$language->lang_code]); } } } } ShlSystem_Log::debug('sh404sef', 'HomeLinks = %s', print_r($this->homeLinks, true)); }
function getLanguages() { static $languages; if (!isset($languages)) { $db = ShlDbHelper::getDb(); $tables = $db->getTableList(); $prefix = $db->getPrefix(); $langs = $prefix . "languages"; if (in_array($langs, $tables)) { // Get installed languages and add them to list $langs = AceDatabase::loadObjectList("SELECT `id`, `shortcode`, `name` FROM `#__languages` WHERE `active` = '1' ORDER BY `ordering`"); if (@count(@$langs)) { foreach ($langs as $lang) { $l = new stdClass(); $l->code = $lang->shortcode; $l->name = $lang->name; // Load languages $languages[] = JHTML::_('select.option', $l->code, $l->name); } } } } return $languages; }
/** * Save a list of meta data as entered by user in backend to the database * * @param string $metaData an array of meta key/meta value from user. Also include nonsef url * @return boolean true on success */ public function save($dataArray = null) { $this->_db = ShlDbHelper::getDb(); $row = JTable::getInstance($this->_defaultTable, 'Sh404sefTable'); // only save if there is actually some metas data // at least on new records $metas = ''; foreach ($dataArray as $key => $value) { if ($key != 'meta_id' && (substr($key, 0, 4) == 'meta' || substr($key, 0, 3) == 'fb_' || substr($key, 0, 3) == 'og_' || $key == 'canonical')) { $metas .= $value; } } // if there is no meta data entered, and this is an existing record, delete it, or at least do not save if (!empty($metas) && $metas == SH404SEF_OPTION_VALUE_USE_DEFAULT . SH404SEF_OPTION_VALUE_USE_DEFAULT . SH404SEF_OPTION_VALUE_USE_DEFAULT . SH404SEF_OPTION_VALUE_USE_DEFAULT . SH404SEF_OPTION_VALUE_USE_DEFAULT) { if (!empty($dataArray['meta_id'])) { // there is an existing record, meta data was cleared by user, we can delete the record altogether try { ShlDbHelper::delete('#__sh404sef_metas', array('id' => $dataArray['meta_id'])); return true; } catch (Exception $e) { $this->setError($e->getMessage()); return false; } } // in any case, don't save anything return true; } if (empty($metas) && empty($dataArray['meta_id'])) { // avoid creating a new (and empty) record when savnig a record from the "metas" page // where we're editing several records at a time // This would pass the test just above, because we do not have any values for fb_*, og_*, etc // fields as we're only editing title and description return true; } $status = true; // load pre-existing values if (!empty($dataArray['meta_id'])) { $status = $row->load($dataArray['meta_id']); } // attach incoming data to table object $status = $status && $row->bind($dataArray); // add language code if missing, except on home page if ($status && $row->newurl != sh404SEF_HOMEPAGE_CODE && !preg_match('/(&|\\?)lang=[a-zA-Z]{2,3}/iuU', $row->newurl)) { // no lang string, let's add default $shTemp = explode('-', shGetDefaultLang()); $shLangTemp = $shTemp[0] ? $shTemp[0] : 'en'; $row->newurl .= '&lang=' . $shLangTemp; } // sort url params, except on home page if ($status && $row->newurl != sh404SEF_HOMEPAGE_CODE) { $row->newurl = shSortUrl($row->newurl); } // pre-save checks $status = $status && $row->check(); // save the changes $status = $status && $row->store(); // store error message if (!$status) { $error = $row->getError(); $this->setError($error); } // return true if no error $errors = $this->getError(); return empty($errors); }
/** * Loads custom install adapters, allowing * installation of Acesef and Joomsef custom plugins * as regular Joomla plugins * */ public static function loadInstallAdapters() { // disabled due to J! 3.1 backward compatibility break return; $app = JFactory::getApplication(); $option = JRequest::getCmd('option'); if ($app->isAdmin() && $option == 'com_installer') { // Get the installer instance jimport('joomla.installer.installer'); $installer = JInstaller::getInstance(); $db = ShlDbHelper::getDb(); // create a Joomsef adapter $joomsefAdapter = new Sh404sefAdapterJoomsefinstaller($installer, $db); $installer->setAdapter('sef_ext', $joomsefAdapter); // create an Acesef adapter $acesefAdapter = new Sh404sefAdapterAcesefinstaller($installer, $db); $installer->setAdapter('acesef_ext', $acesefAdapter); } }
private function _shDeletetable($tableName) { $db = ShlDbHelper::getDb(); $query = 'drop table ' . $db->quoteName('#__' . $tableName); try { ShlDbHelper::query($query); } catch (Exception $e) { echo $e->getMessage() . '<br />'; } }
$dosef = false; } } catch (Exception $e) { $dosef = false; ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage()); } break; // View Agent Email // View Agent Email case 'viewagentemail': $agent_id = id; $title[] = $sh_LANG[$shLangIso]['_HP_SEF_EMAIL']; shRemoveFromGETVarsList('task'); if (is_numeric($agent_id)) { try { $db = ShlDbHelper::getDb(); $db->setQuery("SELECT a.id, a.name AS agent_name, c.id, c.name AS company_name FROM #__hp_agents AS a" . "\nLEFT JOIN #__hp_companies AS c ON a.company = c.id" . "\nWHERE a.id = " . $db->Quote($agent_id) . "\nLIMIT 1"); $row = $db->shlLoadObject(); $title[] = $row->company_name; $title[] = $row->agent_name; $title[] = '/'; shRemoveFromGETVarsList('id'); } catch (Exception $e) { $dosef = false; ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage()); } } else { $dosef = false; } break; // Standard Search
/** * Get installed front end language list * * @access private * @return array */ public static function getInstalledLanguagesList($site = true) { static $languages = null; if (is_null($languages)) { $db = ShlDbHelper::getDb(); // is there a languages table ? $languages = array(); $languagesTableName = $db->getPrefix() . 'languages'; $tablesList = $db->getTableList(); if (is_array($tablesList) && in_array($languagesTableName, $tablesList)) { try { $query = 'SELECT * FROM #__languages'; $db->setQuery($query); $languages = $db->shlLoadObjectList(); } catch (Exception $e) { JError::raiseWarning('SOME_ERROR_CODE', "Error loading languages lists: " . $e->getMessage()); ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage()); return false; } // match fields name to what we need, those were changed in version 2.2 of JF foreach ($languages as $key => $language) { if (empty($language->id)) { $languages[$key]->id = $language->lang_id; } if (empty($language->name)) { $languages[$key]->name = $language->title; } if (empty($language->code)) { $languages[$key]->code = $language->lang_code; } if (empty($language->shortcode)) { $languages[$key]->shortcode = $language->sef; } if (empty($language->active) && empty($language->published)) { // drop this language, it is not published unset($languages[$key]); } } } } return $languages; }
private function _prepareControlPanelData() { $sefConfig = Sh404sefFactory::getConfig(); $this->assign('sefConfig', $sefConfig); // update information $versionsInfo = Sh404sefHelperUpdates::getUpdatesInfos(); $this->assign('updates', $versionsInfo); // url databases stats $database = ShlDbHelper::getDb(); try { $sql = 'SELECT count(*) FROM #__sh404sef_urls WHERE '; $database->setQuery($sql . "`dateadd` > '0000-00-00' and `newurl` = '' "); // 404 $count404 = $database->shlLoadResult(); $database->setQuery($sql . "`dateadd` > '0000-00-00' and `newurl` != '' "); // custom $customCount = $database->shlLoadResult(); $database->setQuery($sql . "`dateadd` = '0000-00-00'"); // regular $sefCount = $database->shlLoadResult(); // calculate security stats $default = empty($sefConfig->shSecLastUpdated) ? '- -' : '0'; } catch (Exception $e) { ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage()); $sefCount = 0; $count404 = 0; $customCount = 0; } $this->assign('sefCount', $sefCount); $this->assign('Count404', $count404); $this->assign('customCount', $customCount); }
function shDoTitleTags(&$buffer) { // Replace TITLE and DESCRIPTION and KEYWORDS if (empty($buffer)) { return; } global $shCustomTitleTag, $shCustomDescriptionTag, $shCustomKeywordsTag, $shCustomRobotsTag, $shCustomLangTag, $shCanonicalTag; $database = ShlDbHelper::getDb(); $shPageInfo =& Sh404sefFactory::getPageInfo(); $sefConfig =& Sh404sefFactory::getConfig(); $document = JFactory::getDocument(); $headData = $document->getHeadData(); // V 1.2.4.t protect against error if using shCustomtags without sh404SEF activated // this should not happen, so we simply do nothing if (!isset($sefConfig) || empty($shPageInfo->currentNonSefUrl)) { return; } // check if there is a manually created set of tags from tags file // need to get them from DB if ($sefConfig->shMetaManagementActivated) { shIncludeMetaPlugin(); // is this homepage ? set flag for future use // V 1.2.4.t make sure we have lang info and properly sorted params if (!preg_match('/(&|\\?)lang=[a-zA-Z]{2,3}/iuU', $shPageInfo->currentNonSefUrl)) { // no lang string, let's add default $shTemp = explode('-', $shPageInfo->currentLanguageTag); $shLangTemp = $shTemp[0] ? $shTemp[0] : 'en'; $shPageInfo->currentNonSefUrl .= '&lang=' . $shLangTemp; } $nonSef = shGetCurrentNonSef(); $isHome = $nonSef == shSortUrl(shCleanUpAnchor(Sh404sefFactory::getPageInfo()->homeLink)); $shCustomTags = shGetCustomMetaData($isHome ? sh404SEF_HOMEPAGE_CODE : $nonSef); // J! 2.5 finder canonical handling/hack $highlight = shGetURLVar($nonSef, 'highlight', null); if (!empty($highlight) && empty($shCanonicalTag)) { $searchCanoNonSef = str_replace('?highlight=' . $highlight, '', $nonSef); $searchCanoNonSef = str_replace('&highlight=' . $highlight, '', $searchCanoNonSef); $shCanonicalTag = JRoute::_($searchCanoNonSef); } $tagsToInsert = ''; // group new tags insertion, better perf if (!empty($shCustomTags)) { $shCustomTitleTag = !empty($shCustomTags->metatitle) ? $shCustomTags->metatitle : $shCustomTitleTag; $shCustomDescriptionTag = !empty($shCustomTags->metadesc) ? $shCustomTags->metadesc : $shCustomDescriptionTag; $shCustomKeywordsTag = !empty($shCustomTags->metakey) ? $shCustomTags->metakey : $shCustomKeywordsTag; $shCustomRobotsTag = !empty($shCustomTags->metarobots) ? $shCustomTags->metarobots : $shCustomRobotsTag; $shCustomLangTag = !empty($shCustomTags->metalang) ? $shCustomTags->metalang : $shCustomLangTag; $shCanonicalTag = !empty($shCustomTags->canonical) ? $shCustomTags->canonical : $shCanonicalTag; } // then insert them in page if (empty($shCustomTitleTag)) { $shCustomTitleTag = $document->getTitle(); } if (!empty($shCustomTitleTag)) { $prepend = $isHome ? '' : $sefConfig->prependToPageTitle; $append = $isHome ? '' : $sefConfig->appendToPageTitle; $shPageInfo->pageTitle = htmlspecialchars(shCleanUpTitle($prepend . $shCustomTitleTag . $append), ENT_COMPAT, 'UTF-8'); $buffer = ShlSystem_Strings::pr('/\\<\\s*title\\s*\\>.*\\<\\s*\\/title\\s*\\>/isuU', '<title>' . $shPageInfo->pageTitle . '</title>', $buffer); $buffer = ShlSystem_Strings::pr('/\\<\\s*meta\\s+name\\s*=\\s*"title.*\\/\\>/isuU', '', $buffer); // remove any title meta } if (!is_null($shCustomDescriptionTag)) { $t = htmlspecialchars(shCleanUpDesc($shCustomDescriptionTag), ENT_COMPAT, 'UTF-8'); $shPageInfo->pageDescription = ShlSystem_Strings::pr('#\\$([0-9]*)#u', '\\\\$${1}', $t); if (strpos($buffer, '<meta name="description" content=') !== false) { $buffer = ShlSystem_Strings::pr('/\\<\\s*meta\\s+name\\s*=\\s*"description.*\\/\\>/isUu', '<meta name="description" content="' . $shPageInfo->pageDescription . '" />', $buffer); } else { $tagsToInsert .= "\n" . '<meta name="description" content="' . $shPageInfo->pageDescription . '" />'; } } else { // read Joomla! description if none set by us if (empty($shPageInfo->pageDescription)) { $shPageInfo->pageDescription = empty($headData['description']) ? '' : htmlspecialchars(shCleanUpDesc($headData['description']), ENT_COMPAT, 'UTF-8'); } } if (!is_null($shCustomKeywordsTag)) { $t = htmlspecialchars(shCleanUpDesc($shCustomKeywordsTag), ENT_COMPAT, 'UTF-8'); $shPageInfo->pageKeywords = ShlSystem_Strings::pr('#\\$([0-9]*)#u', '\\\\$${1}', $t); if (strpos($buffer, '<meta name="keywords" content=') !== false) { $buffer = ShlSystem_Strings::pr('/\\<\\s*meta\\s+name\\s*=\\s*"keywords.*\\/\\>/isUu', '<meta name="keywords" content="' . $shPageInfo->pageKeywords . '" />', $buffer); } else { $tagsToInsert .= "\n" . '<meta name="keywords" content="' . $shPageInfo->pageKeywords . '" />'; } } else { // read Joomla! description if none set by us if (empty($shPageInfo->pageKeywords)) { $shPageInfo->pageKeywords = empty($headData['metaTags']['standard']['keywords']) ? '' : htmlspecialchars(shCleanUpDesc($headData['metaTags']['standard']['keywords']), ENT_COMPAT, 'UTF-8'); } } if (!is_null($shCustomRobotsTag)) { $shPageInfo->pageRobotsTag = $shCustomRobotsTag; if (strpos($buffer, '<meta name="robots" content="') !== false) { $buffer = ShlSystem_Strings::pr('/\\<\\s*meta\\s+name\\s*=\\s*"robots.*\\/\\>/isUu', '<meta name="robots" content="' . $shCustomRobotsTag . '" />', $buffer); } else { if (!empty($shCustomRobotsTag)) { $tagsToInsert .= "\n" . '<meta name="robots" content="' . $shCustomRobotsTag . '" />'; } } } else { // read Joomla! description if none set by us if (empty($shPageInfo->pageRobotsTag)) { $shPageInfo->pageRobotsTag = empty($headData['metaTags']['standard']['robots']) ? '' : htmlspecialchars(shCleanUpDesc($headData['metaTags']['standard']['robots']), ENT_COMPAT, 'UTF-8'); } } if (!is_null($shCustomLangTag)) { $shLang = $shCustomLangTag; $shPageInfo->pageLangTag = $shCustomLangTag; if (strpos($buffer, '<meta http-equiv="Content-Language"') !== false) { $buffer = ShlSystem_Strings::pr('/\\<\\s*meta\\s+http-equiv\\s*=\\s*"Content-Language".*\\/\\>/isUu', '<meta http-equiv="Content-Language" content="' . $shCustomLangTag . '" />', $buffer); } else { $tagsToInsert .= "\n" . '<meta http-equiv="Content-Language" content="' . $shCustomLangTag . '" />'; } } // custom handling of canonical $canonicalPattern = '/\\<\\s*link[^>]+rel\\s*=\\s*"canonical[^>]+\\/\\>/isUu'; $matches = array(); $canonicalCount = preg_match_all($canonicalPattern, $buffer, $matches); // more than one canonical already: kill them all if ($canonicalCount > 1 && Sh404sefFactory::getConfig()->removeOtherCanonicals) { $buffer = ShlSystem_Strings::pr($canonicalPattern, '', $buffer); $canonicalCount = 0; } // more than one and J3: must be the one inserted by J3 SEF plugin if ($canonicalCount > 0 && Sh404sefFactory::getConfig()->removeOtherCanonicals && version_compare(JVERSION, '3.0', 'ge')) { // kill it, if asked to $buffer = ShlSystem_Strings::pr($canonicalPattern, '', $buffer); $canonicalCount = 0; } // if there' a custom canonical for that page, insert it, or replace any existing ones if (!empty($shCanonicalTag) && $canonicalCount == 0) { // insert a new canonical $tagsToInsert .= "\n" . '<link href="' . htmlspecialchars($shCanonicalTag, ENT_COMPAT, 'UTF-8') . '" rel="canonical" />' . "\n"; } else { if (!empty($shCanonicalTag)) { // replace existing canonical $buffer = ShlSystem_Strings::pr($canonicalPattern, '<link href="' . htmlspecialchars($shCanonicalTag, ENT_COMPAT, 'UTF-8') . '" rel="canonical" />', $buffer); } } // insert all tags in one go if (!empty($tagsToInsert)) { $buffer = shInsertCustomTagInBuffer($buffer, '<head>', 'after', $tagsToInsert, 'first'); } // remove Generator tag if ($sefConfig->shRemoveGeneratorTag) { $buffer = ShlSystem_Strings::pr('/<meta\\s*name="generator"\\s*content=".*\\/>/isUu', '', $buffer); } // put <h1> tags around content elements titles if ($sefConfig->shPutH1Tags) { if (strpos($buffer, 'class="componentheading') !== false) { $buffer = ShlSystem_Strings::pr('/<div class="componentheading([^>]*)>\\s*(.*)\\s*<\\/div>/isUu', '<div class="componentheading$1><h1>$2</h1></div>', $buffer); $buffer = ShlSystem_Strings::pr('/<td class="contentheading([^>]*)>\\s*(.*)\\s*<\\/td>/isUu', '<td class="contentheading$1><h2>$2</h2></td>', $buffer); } else { // replace contentheading by h1 $buffer = ShlSystem_Strings::pr('/<td class="contentheading([^>]*)>\\s*(.*)\\s*<\\/td>/isUu', '<td class="contentheading$1><h1>$2</h1></td>', $buffer); } } // version x : if multiple h1 headings, replace them by h2 if ($sefConfig->shMultipleH1ToH2 && substr_count(JString::strtolower($buffer), '<h1>') > 1) { $buffer = str_replace('<h1>', '<h2>', $buffer); $buffer = str_replace('<H1>', '<h2>', $buffer); $buffer = str_replace('</h1>', '</h2>', $buffer); $buffer = str_replace('</H1>', '</h2>', $buffer); } // V 1.3.1 : replace outbounds links by internal redirects if (sh404SEF_REDIRECT_OUTBOUND_LINKS) { $tmp = preg_replace_callback('/<\\s*a\\s*href\\s*=\\s*"(.*)"/isUu', 'shDoRedirectOutboundLinksCallback', $buffer); if (empty($tmp)) { ShlSystem_Log::error('shlib', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, 'RegExp failed: invalid character on page ' . Sh404sefFactory::getPageInfo()->currentSefUrl); } else { $buffer = $tmp; } } // V 1.3.1 : add symbol to outbounds links if ($sefConfig->shInsertOutboundLinksImage) { $tmp = preg_replace_callback("/<\\s*a\\s*href\\s*=\\s*(\"|').*(\"|')\\s*>.*<\\/a>/isUu", 'shDoInsertOutboundLinksImageCallback', $buffer); if (empty($tmp)) { ShlSystem_Log::error('shlib', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, 'RegExp failed: invalid character on page ' . Sh404sefFactory::getPageInfo()->currentSefUrl); } else { $buffer = $tmp; } } // fix homepage link when using Joomfish in non default languages, error in joomla mainmenu helper /* if (sh404SEF_PROTECT_AGAINST_BAD_NON_DEFAULT_LANGUAGE_MENU_HOMELINK && !shIsDefaultLang( $shPageInfo->currentLanguageTag)) { $badHomeLink = preg_quote(JURI::base()); $targetLang = explode( '-', $shPageInfo->currentLanguageTag); $goodHomeLink = rtrim(JURI::base(), '/') . $sefConfig->shRewriteStrings[$sefConfig->shRewriteMode] . $targetLang[0] . '/'; $buffer = preg_replace( '#<div class="module_menu(.*)href="' . $badHomeLink . '"#isU', '<div class="module_menu$1href="' . $goodHomeLink . '"', $buffer); $buffer = preg_replace( '#<div class="moduletable_menu(.*)href="' . $badHomeLink . '"#isU', '<div class="moduletable_menu$1href="' . $goodHomeLink . '"', $buffer); } */ // all done return $buffer; } }
function saveConfig($return_data = 0) { $database = ShlDbHelper::getDb(); $sef_config_file = JPATH_ADMINISTRATOR . '/' . 'components' . '/' . 'com_sef' . '/' . 'configuration.php'; $config_data = ''; //build the data file $config_data .= "<?php\n"; $config_data .= '/** * SEF component for Joomla! 1.5 * * @author ARTIO s.r.o. * @copyright ARTIO s.r.o., http://www.artio.cz * @package JoomSEF * @version 3.1.0 * @license GNU/GPLv3 http://www.gnu.org/copyleft/gpl.html */ '; foreach ($this as $key => $value) { if ($key != '0') { $config_data .= "\${$key} = "; switch (gettype($value)) { case 'boolean': $config_data .= $value ? 'true' : 'false'; break; case 'string': // The only character that needs to be escaped is double quote (") $config_data .= '"' . str_replace('"', '\\"', stripslashes($value)) . '"'; break; case 'integer': case 'double': $config_data .= strval($value); break; case 'array': $datastring = ''; foreach ($value as $key2 => $data) { $datastring .= '\'' . $key2 . '\' => "' . str_replace('"', '\\"', stripslashes($data)) . '",'; } $datastring = substr($datastring, 0, -1); $config_data .= "array({$datastring})"; break; default: $config_data .= 'null'; break; } } $config_data .= ";\n"; } $config_data .= '?>'; if ($return_data == 1) { return $config_data; } else { // write to disk jimport('joomla.filesystem.file'); $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl); $config_data = strtr($config_data, $trans_tbl); $ret = JFile::write($sef_config_file, $config_data); return $ret; } }