예제 #1
0
 function display($tpl = null)
 {
     JToolBarHelper::title(JText::_('JoomSEF Configuration'), 'config.png');
     JToolBarHelper::save();
     JToolBarHelper::apply();
     JToolBarHelper::spacer();
     JToolBarHelper::cancel();
     // Get data from the model
     $lists =& $this->get('Lists');
     $this->assignRef('lists', $lists);
     $this->subdomains = $this->get('subdomains');
     // Which tab to show?
     $sefConfig =& SEFConfig::getConfig();
     $tabs = array('basic');
     if ($sefConfig->professionalMode) {
         $tabs[] = 'advanced';
     }
     $tabs[] = 'cache';
     $tabs[] = 'metatags';
     $tabs[] = 'seo';
     $tabs[] = 'sitemap';
     if (SEFTools::JoomFishInstalled()) {
         $tabs[] = 'joomfish';
     }
     $tabs[] = 'analytics';
     if (!SEFTools::JoomFishInstalled()) {
         $tabs[] = 'subdomains';
     }
     $tabs[] = 'tab404';
     $tabs[] = 'registration';
     $tab = JRequest::getVar('tab', 'basic');
     $tabIdx = array_search($tab, $tabs);
     if ($tabIdx === false) {
         $tabIdx = 0;
     }
     $this->assign('tab', $tabIdx);
     JHTML::_('behavior.tooltip');
     $sefConfig =& SEFConfig::getConfig();
     if (!$sefConfig->professionalMode) {
         $mainframe =& JFactory::getApplication();
         $mainframe->enqueueMessage(JText::_('COM_SEF_BEGINNER_MODE_INFO'));
     }
     parent::display($tpl);
 }
예제 #2
0
 /**
  * Find existing or create new SEO URL.
  *
  * @param array $data
  * @return string
  */
 function _storeLocation(&$data)
 {
     $mainframe =& JFactory::getApplication();
     $db =& JFactory::getDBO();
     $sefConfig =& SEFConfig::getConfig();
     $cache =& SEFCache::getInstance();
     // Extract variables
     $defaults = array('uri' => null, 'title' => null, 'task' => null, 'limit' => null, 'limitstart' => null, 'lang' => null, 'nonSefVars' => null, 'ignoreSefVars' => null, 'metadata' => null, 'priority' => null, 'pageHandled' => false, 'host' => null, 'sitemapParams' => null);
     foreach ($defaults as $varName => $value) {
         if (is_array($data) && isset($data[$varName])) {
             ${$varName} = $data[$varName];
         } else {
             ${$varName} = $value;
         }
     }
     // Get the default priority if not set
     if (is_null($priority)) {
         $priority = JoomSEF::_getPriorityDefault($uri);
     }
     // Get the parameters for this component
     if (!is_null($uri->getVar('option'))) {
         $params =& SEFTools::getExtParams($uri->getVar('option'));
     }
     // remove the menu title if set to for this component
     if (isset($params) && $params->get('showMenuTitle', '1') == '0') {
         if (count($title) > 1 && (count($title) != 2 || $title[1] != '/') && $title[0] == JoomSEF::_getMenuTitle(@$uri->getVar('option'), @$uri->getVar('task'), @$uri->getVar('Itemid'))) {
             array_shift($title);
         }
     }
     // add the page number if the extension does not handle it
     if (!$pageHandled && !is_null($uri->getVar('limitstart'))) {
         $limit = $uri->getVar('limit');
         if (is_null($limit)) {
             if (!is_null($uri->getVar('option'))) {
                 $limit = intval($params->get('pageLimit', ''));
             }
         }
         if (empty($limit)) {
             $pageNum = intval($uri->getVar('limitstart'));
         } else {
             $pageNum = intval($uri->getVar('limitstart') / $limit) + 1;
         }
         $pagetext = strval($pageNum);
         if ($cnfPageText = $sefConfig->getPageText()) {
             $pagetext = str_replace('%s', $pageNum, $cnfPageText);
         }
         $title = array_merge($title, explode('/', $pagetext));
         //$title[] = $pagetext;
     }
     // get all the titles ready for urls.
     $location = array();
     foreach ($title as $titlePart) {
         $titlePart = JoomSEF::_titleToLocation($titlePart);
         if (strlen($titlePart) == 0) {
             continue;
         }
         $location[] = $titlePart;
     }
     // remove unwanted characters.
     $finalstrip = explode('|', $sefConfig->stripthese);
     $takethese = str_replace('|', '', $sefConfig->friendlytrim);
     if (strstr($takethese, $sefConfig->replacement) === false) {
         $takethese .= $sefConfig->replacement;
     }
     $imptrim = implode('/', $location);
     if (!is_null($task)) {
         $task = str_replace($sefConfig->replacement . '-' . $sefConfig->replacement, $sefConfig->replacement, $task);
         $task = str_replace($finalstrip, '', $task);
         $task = trim($task, $takethese);
     }
     $imptrim = str_replace($sefConfig->replacement . '-' . $sefConfig->replacement, $sefConfig->replacement, $imptrim);
     $suffixthere = 0;
     $regexSuffix = str_replace('.', '\\.', $sefConfig->suffix);
     $pregSuffix = addcslashes($regexSuffix, '/');
     if (preg_match('/' . $pregSuffix . '$/i', $imptrim)) {
         $suffixthere = strlen($sefConfig->suffix);
     }
     $imptrim = str_replace($finalstrip, $sefConfig->replacement, substr($imptrim, 0, strlen($imptrim) - $suffixthere));
     $imptrim = str_replace($sefConfig->replacement . $sefConfig->replacement, $sefConfig->replacement, $imptrim);
     $suffixthere = 0;
     if (preg_match('/' . $pregSuffix . '$/i', $imptrim)) {
         $suffixthere = strlen($sefConfig->suffix);
     }
     $imptrim = trim(substr($imptrim, 0, strlen($imptrim) - $suffixthere), $takethese);
     // add the task if set
     $imptrim .= !is_null($task) ? '/' . $task . $sefConfig->suffix : '';
     // remove all the -/
     $imptrim = SEFTools::ReplaceAll($sefConfig->replacement . '/', '/', $imptrim);
     // remove all the /-
     $imptrim = SEFTools::ReplaceAll('/' . $sefConfig->replacement, '/', $imptrim);
     // Remove all the //
     $location = SEFTools::ReplaceAll('//', '/', $imptrim);
     // Remove starting /
     $location = ltrim($location, '/');
     // check if the location isn't too long for database storage and truncate it in that case
     $suffixthere = 0;
     if (preg_match('/' . $pregSuffix . '$/i', $location)) {
         $suffixthere = strlen($sefConfig->suffix);
     }
     $suffixLen = strlen($sefConfig->suffix);
     $maxlen = 240 + $suffixthere - $suffixLen;
     // Leave some space for language and numbers
     if (strlen($location) > $maxlen) {
         // Temporarily remove the suffix
         $location = preg_replace('/' . $pregSuffix . '$/', '', $location);
         // Explode the location to parts
         $parts = explode('/', $location);
         do {
             // Find the key of the longest part
             $key = 0;
             $len = strlen($parts[0]);
             for ($i = 1, $n = count($parts); $i < $n; $i++) {
                 $tmpLen = strlen($parts[$i]);
                 if ($tmpLen > $len) {
                     $key = $i;
                     $len = $tmpLen;
                 }
             }
             // Truncate the longest part
             $truncBy = strlen($location) - $maxlen;
             if ($truncBy > 10) {
                 $truncBy = 10;
             }
             $parts[$key] = substr($parts[$key], 0, -$truncBy);
             // Implode to location again
             $location = implode('/', $parts);
             // Add suffix if was there
             if ($suffixthere > 0) {
                 $location .= $sefConfig->suffix;
             }
         } while (strlen($location) > $maxlen);
     }
     // remove variables we don't want to be included in non-SEF URL
     // and build the non-SEF part of our SEF URL
     $nonSefUrl = '';
     // load the nonSEF vars from option parameters
     $paramNonSef = array();
     if (isset($params)) {
         $nsef = $params->get('customNonSef', '');
         if (!empty($nsef)) {
             // Some variables are set, let's explode them
             $paramNonSef = explode(';', $nsef);
         }
     }
     // get globally configured nonSEF vars
     $configNonSef = array();
     if (!empty($sefConfig->customNonSef)) {
         $configNonSef = explode(';', $sefConfig->customNonSef);
     }
     // combine all the nonSEF vars arrays
     $nsefvars = array_merge($paramNonSef, $configNonSef);
     if (!empty($nsefvars)) {
         foreach ($nsefvars as $nsefvar) {
             // add each variable, that isn't already set, and that is present in our URL
             if (!isset($nonSefVars[$nsefvar]) && !is_null($uri->getVar($nsefvar))) {
                 $nonSefVars[$nsefvar] = $uri->getVar($nsefvar);
             }
         }
     }
     // nonSefVars - variables to exclude only if set to in configuration
     if ($sefConfig->appendNonSef && isset($nonSefVars)) {
         $vars = array_keys($nonSefVars);
         $q = SEFTools::RemoveVariables($uri, $vars);
         if ($q != '') {
             if ($nonSefUrl == '') {
                 $nonSefUrl = '?' . $q;
             } else {
                 $nonSefUrl .= '&amp;' . $q;
             }
         }
         // if $nonSefVars mixes with $GLOBALS['JOOMSEF_NONSEFVARS'], exclude the mixed vars
         // this is important to prevent duplicating params by adding JOOMSEF_NONSEFVARS to
         // $ignoreSefVars
         $gNonSef = JoomSEF::get('sef.global.nonsefvars');
         if (!empty($gNonSef)) {
             foreach (array_keys($gNonSef) as $key) {
                 if (in_array($key, array_keys($nonSefVars))) {
                     unset($gNonSef[$key]);
                 }
             }
             JoomSEF::set('sef.global.nonsefvars', $gNonSef);
         }
     }
     // if there are global variables to exclude, add them to ignoreSefVars array
     $gNonSef = JoomSEF::get('sef.global.nonsefvars');
     if (!empty($gNonSef)) {
         if (!empty($ignoreSefVars)) {
             $ignoreSefVars = array_merge($gNonSef, $ignoreSefVars);
         } else {
             $ignoreSefVars = $gNonSef;
         }
     }
     // ignoreSefVars - variables to exclude allways
     if (isset($ignoreSefVars)) {
         $vars = array_keys($ignoreSefVars);
         $q = SEFTools::RemoveVariables($uri, $vars);
         if ($q != '') {
             if ($nonSefUrl == '') {
                 $nonSefUrl = '?' . $q;
             } else {
                 $nonSefUrl .= '&amp;' . $q;
             }
         }
     }
     // If the component requests strict accept variables filtering, remove the ones that don't match
     if (isset($params) && $params->get('acceptStrict', '0') == '1') {
         $acceptVars =& SEFTools::getExtAcceptVars($uri->getVar('option'));
         $uriVars = $uri->getQuery(true);
         if (count($acceptVars) > 0 && count($uriVars) > 0) {
             foreach ($uriVars as $name => $value) {
                 // Standard Joomla variables
                 if (in_array($name, $sefConfig->globalAcceptVars)) {
                     continue;
                 }
                 // Accepted variables
                 if (in_array($name, $acceptVars)) {
                     continue;
                 }
                 // Variable not accepted, add it to non-SEF part of the URL
                 $value = urlencode($value);
                 if (strlen($nonSefUrl) > 0) {
                     $nonSefUrl .= '&amp;' . $name . '=' . $value;
                 } else {
                     $nonSefUrl = '?' . $name . '=' . $value;
                 }
                 $uri->delVar($name);
             }
         }
     }
     // always remove Itemid and store it in a separate column
     if (!is_null($uri->getVar('Itemid'))) {
         $Itemid = $uri->getVar('Itemid');
         $uri->delVar('Itemid');
     }
     // check for non-sef url first and avoid repeative lookups
     // we only want to look for title variations when adding new
     // this should also help eliminate duplicates.
     // David (284): ignore Itemid if set to
     if (isset($params)) {
         $extIgnore = $params->get('ignoreSource', 2);
     } else {
         $extIgnore = 2;
     }
     $ignoreSource = $extIgnore == 2 ? $sefConfig->ignoreSource : $extIgnore;
     // If Itemid is set as ignored for the component, set ignoreSource to 1
     $itemidIgnored = false;
     if (isset($Itemid) && !is_null($uri->getVar('option'))) {
         $itemidIgnored = SEFTools::isItemidIgnored($uri->getVar('option'), $Itemid);
         if ($itemidIgnored) {
             $ignoreSource = 1;
         }
     }
     $where = '';
     if (!$ignoreSource && isset($Itemid)) {
         $where .= " AND (`Itemid` = '{$Itemid}' OR `Itemid` IS NULL)";
     }
     $url = JoomSEF::_uriToUrl($uri);
     // if cache is activated, search in cache first
     if ($sefConfig->useCache) {
         $realloc = $cache->GetSefUrl($url, @$Itemid);
     }
     // search if URL exists, if we do not use cache or URL was not cached
     if (!$sefConfig->useCache || !$realloc) {
         $query = "SELECT * FROM `#__sefurls` WHERE `origurl` = " . $db->Quote(html_entity_decode(urldecode($url))) . $where . " AND (`trashed` = '0') LIMIT 2";
         $db->setQuery($query);
         $sefurls = $db->loadObjectList('Itemid');
         if (!is_array($sefurls)) {
             $realloc = false;
         } else {
             if (!$ignoreSource && isset($Itemid)) {
                 if (isset($sefurls[$Itemid])) {
                     $realloc = $sefurls[$Itemid];
                 } else {
                     if (isset($sefurls[''])) {
                         // We've found one of the ignored Itemids, update it with the current and return
                         $realloc = $sefurls[''];
                         $realloc->Itemid = $Itemid;
                         $query = "UPDATE `#__sefurls` SET `Itemid` = '{$Itemid}' WHERE `id` = '{$realloc->id}' LIMIT 1";
                         $db->setQuery($query);
                         $db->query();
                     } else {
                         $realloc = reset($sefurls);
                     }
                 }
             } else {
                 $realloc = reset($sefurls);
             }
         }
         /*
         // removed - causing problems, ignore multiple sources not working correctly
         // test if current Itemid record exists, if YES, use it, if NO, use first found
         $curId = isset($Itemid) ? $Itemid : '';
         $active = isset($sefurls[$curId]) ? $sefurls[$curId] : reset($sefurls);
         $realloc = $active;
         */
     }
     // if not found, try to find the url without lang variable
     if (!$realloc && $sefConfig->langPlacement == _COM_SEF_LANG_DOMAIN) {
         $url = JoomSEF::_uriToUrl($uri, 'lang');
         if ($sefConfig->useCache) {
             $realloc = $cache->GetSefUrl($url, @$Itemid);
         }
         if (!$sefConfig->useCache || !$realloc) {
             $query = "SELECT * FROM `#__sefurls` WHERE `origurl` = " . $db->Quote(html_entity_decode(urldecode($url))) . $where . " AND (`trashed` = '0') LIMIT 2";
             $db->setQuery($query);
             $sefurls = $db->loadObjectList('Itemid');
             if (!is_array($sefurls)) {
                 $realloc = false;
             } else {
                 if (!$ignoreSource && isset($Itemid)) {
                     if (isset($sefurls[$Itemid])) {
                         $realloc = $sefurls[$Itemid];
                     } else {
                         if (isset($sefurls[''])) {
                             // We've found one of the ignored Itemids, update it with the current and return
                             $realloc = $sefurls[''];
                             $realloc->Itemid = $Itemid;
                             $query = "UPDATE `#__sefurls` SET `Itemid` = '{$Itemid}' WHERE `id` = '{$realloc->id}' LIMIT 1";
                             $db->setQuery($query);
                             $db->query();
                         } else {
                             $realloc = reset($sefurls);
                         }
                     }
                 } else {
                     $realloc = reset($sefurls);
                 }
             }
             /*
                             // removed - causing problems, ignore multiple sources not working correctly
                        		// test if current Itemid record exists, if YES, use it, if NO, use first found
                        		$curId = isset($Itemid) ? $Itemid : '';
             $active = isset($sefurls[$curId]) ? $sefurls[$curId] : reset($sefurls);
             $realloc = $active;
             */
         }
     }
     // found a match, so we are done
     if (is_object($realloc)) {
         // return the original URL if SEF is disabled
         if (!$realloc->sef) {
             return $uri;
         }
         // return found URL with non-SEF part appended
         if ($nonSefUrl != '' && strstr($realloc->sefurl, '?')) {
             $nonSefUrl = str_replace('?', '&amp;', $nonSefUrl);
         }
         $url = JURI::root();
         if (substr($url, -1) != '/') {
             $url .= '/';
         }
         $url .= $realloc->sefurl . $nonSefUrl;
         $fragment = $uri->getFragment();
         if (!empty($fragment)) {
             $url .= '#' . $fragment;
         }
         return new JURI($url);
     } else {
         // return the original URL if we don't want to save new URLs
         if ($sefConfig->disableNewSEF) {
             return $uri;
         }
         $realloc = null;
         $suffixMust = false;
         // add lang to suffix, if set to
         if (SEFTools::JoomFishInstalled() && isset($lang) && $sefConfig->langPlacement == _COM_SEF_LANG_SUFFIX) {
             if ($sefConfig->mainLanguage == '0' || $lang != $sefConfig->mainLanguage) {
                 $suffix = '_' . $lang . $sefConfig->suffix;
                 $suffixMust = true;
             }
         }
         if (!isset($suffix)) {
             $suffix = $sefConfig->suffix;
         }
         $addFile = $sefConfig->addFile;
         if (($pos = strrpos($addFile, '.')) !== false) {
             $addFile = substr($addFile, 0, $pos);
         }
         // in case the created SEF URL is already in database for different non-SEF URL,
         // we need to distinguish them by using numbers, so let's find the first unused URL
         $leftPart = '';
         // string to be searched before page number
         $rightPart = '';
         // string to be searched after page number
         if (substr($location, -1) == '/' || strlen($location) == 0) {
             if ($pagetext = $sefConfig->getPageText()) {
                 // use global limit if NULL and set in globals
                 if (is_null($limit) && isset($_REQUEST['limit']) && $_REQUEST['limit'] > 0) {
                     $limit = $_REQUEST['limit'];
                 }
                 // if we are using pagination, try to calculate page number
                 if (!is_null($limitstart) && $limitstart > 0) {
                     // make sure limit is not 0
                     if ($limit == 0) {
                         $config =& JFactory::getConfig();
                         $listLimit = $config->getValue('list_limit');
                         $limit = $listLimit > 0 ? $listLimit : 20;
                     }
                     $pagenum = $limitstart / $limit;
                     $pagenum++;
                 } else {
                     $pagenum = 1;
                 }
                 if (strpos($pagetext, '%s') !== false) {
                     $page = str_replace('%s', $pagenum == 1 ? $addFile : $pagenum, $pagetext) . $suffix;
                     $pages = explode('%s', $pagetext);
                     $leftPart = $location . $pages[0];
                     $rightPart = $pages[1] . $suffix;
                 } else {
                     $page = $pagetext . ($pagenum == 1 ? $addFile : $sefConfig->pagerep . $pagenum) . $suffix;
                     $leftPart = $location . $pagetext . $sefConfig->pagerep;
                     $rightPart = $suffix;
                 }
                 $temploc = $location . ($pagenum == 1 && !$suffixMust ? '' : $page);
             } else {
                 $temploc = $location . ($suffixMust ? $sefConfig->pagerep . $suffix : '');
                 $leftPart = $location . $sefConfig->pagerep;
                 $rightPart = $suffix;
             }
         } elseif ($suffix) {
             if ($sefConfig->suffix != '/') {
                 if (preg_match('/' . $pregSuffix . '/i', $location)) {
                     $temploc = preg_replace('/' . $pregSuffix . '/', '', $location) . $suffix;
                     $leftPart = preg_replace('/' . $pregSuffix . '/', '', $location) . $sefConfig->pagerep;
                     $rightPart = $suffix;
                 } else {
                     $temploc = $location . $suffix;
                     $leftPart = $location . $sefConfig->pagerep;
                     $rightPart = $suffix;
                 }
             } else {
                 $temploc = $location . $suffix;
                 $leftPart = $location . $sefConfig->pagerep;
                 $rightPart = $suffix;
             }
         } else {
             $temploc = $location . ($suffixMust ? $sefConfig->pagerep . $suffix : '');
             $leftPart = $location . $sefConfig->pagerep;
             $rightPart = $suffix;
         }
         // add language to path if set to
         if (SEFTools::JoomFishInstalled() && isset($lang) && $sefConfig->langPlacement == _COM_SEF_LANG_PATH) {
             if ($sefConfig->mainLanguage == '0' || $lang != $sefConfig->mainLanguage) {
                 $slash = $temploc != '' && $temploc[0] == '/';
                 $temploc = $lang . ($slash || strlen($temploc) > 0 ? '/' : '') . $temploc;
                 $leftPart = $lang . '/' . $leftPart;
             }
         }
         if ($sefConfig->addFile) {
             if (!preg_match('/' . $pregSuffix . '$/i', $temploc) && substr($temploc, -1) == '/') {
                 $temploc .= $sefConfig->addFile;
             }
         }
         // convert to lowercase if set to
         if ($sefConfig->lowerCase) {
             $temploc = JoomSEF::_toLowerCase($temploc);
             $leftPart = JoomSEF::_toLowerCase($leftPart);
             $rightPart = JoomSEF::_toLowerCase($rightPart);
         }
         $url = JoomSEF::_uriToUrl($uri);
         // see if we have a result for this location
         $sql = "SELECT `id`, `origurl`, `Itemid`, `sefurl` FROM `#__sefurls` WHERE `sefurl` = " . $db->Quote($temploc) . " AND `origurl` != '' AND `trashed` = '0'";
         $db->setQuery($sql);
         $row = $db->loadObject();
         if ($itemidIgnored) {
             $Itemid = null;
         }
         $realloc = JoomSEF::_checkRow($row, $ignoreSource, @$Itemid, $url, $metadata, $temploc, $priority, $uri->getVar('option'), $host, $sitemapParams);
         // the correct URL could not be used, we must find the first free number
         if (is_null($realloc)) {
             // let's get all the numbered pages
             $sql = "SELECT `id`, `origurl`, `Itemid`, `sefurl` FROM `#__sefurls` WHERE `sefurl` LIKE " . $db->Quote($leftPart . '%' . $rightPart) . " AND `trashed` = '0'";
             $db->setQuery($sql);
             $pages = $db->loadObjectList();
             // create associative array of form number => URL info
             $urls = array();
             if (!empty($pages)) {
                 $leftLen = strlen($leftPart);
                 $rightLen = strlen($rightPart);
                 foreach ($pages as $page) {
                     $sefurl = $page->sefurl;
                     // separate URL number
                     $urlnum = substr($sefurl, $leftLen, strlen($sefurl) - $leftLen - $rightLen);
                     // use only if it's really numeric
                     if (is_numeric($urlnum)) {
                         $urls[intval($urlnum)] = $page;
                     }
                 }
             }
             $i = 2;
             do {
                 $temploc = $leftPart . $i . $rightPart;
                 $row = null;
                 if (isset($urls[$i])) {
                     $row = $urls[$i];
                 }
                 $realloc = JoomSEF::_checkRow($row, $ignoreSource, @$Itemid, $url, $metadata, $temploc, $priority, $uri->getVar('option'), $host, $sitemapParams);
                 $i++;
             } while (is_null($realloc));
         }
     }
     // return found URL with non-SEF part appended
     if ($nonSefUrl != '' && strstr($realloc, '?')) {
         $nonSefUrl = str_replace('?', '&amp;', $nonSefUrl);
     }
     if (!strlen($host)) {
         $root = JFactory::getUri()->toString(array('host', 'port'));
     } else {
         $root = $host;
     }
     $url = JFactory::getURI()->getScheme() . "://" . $root . JURI::root(true);
     if (substr($url, -1) != '/') {
         $url .= '/';
     }
     $url .= $realloc . $nonSefUrl;
     $fragment = $uri->getFragment();
     if (!empty($fragment)) {
         $url .= '#' . $fragment;
     }
     return new JURI($url);
 }
예제 #3
0
 function getLangLongCode($langCode = null)
 {
     static $codes;
     // Get current language code
     if (is_null($langCode)) {
         $lang = JFactory::getLanguage();
         return $lang->getTag();
     }
     if (is_null($codes)) {
         $codes = array();
         if (SEFTools::JoomFishInstalled()) {
             $jfm =& JoomFishManager::getInstance();
             $langs =& $jfm->getLanguages(false);
             if (!empty($langs)) {
                 foreach ($langs as $lang) {
                     $codes[$lang->shortcode] = $lang->code;
                 }
             }
         } else {
             // Only one language
             $lang = JFactory::getLanguage();
             $tag = $lang->getTag();
             $parts = explode('-', $tag);
             $iso = $parts[0];
             $codes[$iso] = $tag;
         }
     }
     if (isset($codes[$langCode])) {
         return $codes[$langCode];
     }
     return null;
 }
예제 #4
0
 function getLists()
 {
     // make the select list for the component filter
     $comList[] = JHTML::_('select.option', '', JText::_('(All)'));
     //$comList[] = JHTML::_('select.option', 'com_content', 'Content');
     $this->_db->setQuery("SELECT `name`,`option` FROM `#__components` WHERE `parent` = '0' ORDER BY `name`");
     $rows = $this->_db->loadObjectList();
     if ($this->_db->getErrorNum()) {
         echo $this->_db->stderr();
         return false;
     }
     foreach (array_keys($rows) as $i) {
         $row =& $rows[$i];
         $comList[] = JHTML::_('select.option', $row->option, $row->name);
     }
     $lists['comList'] = JHTML::_('select.genericlist', $comList, 'comFilter', "class=\"inputbox\" onchange=\"document.adminForm.submit();\" size=\"1\"", 'value', 'text', $this->filterComponent);
     // make the filter text boxes
     $lists['filterSEF'] = "<input class=\"hasTip\" type=\"text\" name=\"filterSEF\" value=\"" . htmlspecialchars($this->filterSEF) . "\" size=\"40\" maxlength=\"255\" onkeydown=\"return handleKeyDown(event);\" title=\"" . JText::_('TT_FILTER_SEF') . "\" />";
     $lists['filterReal'] = "<input class=\"hasTip\" type=\"text\" name=\"filterReal\" value=\"" . htmlspecialchars($this->filterReal) . "\" size=\"40\" maxlength=\"255\" onkeydown=\"return handleKeyDown(event);\" title=\"" . JText::_('TT_FILTER_REAL') . "\" />";
     // Load the active languages
     if (SEFTools::JoomFishInstalled()) {
         $db =& JFactory::getDBO();
         $query = "SELECT `name`, `shortcode` FROM `#__languages` WHERE `active` = '1' ORDER BY `name`";
         $db->setQuery($query);
         $langs = $db->loadObjectList();
         $langList = array();
         $langList[] = JHTML::_('select.option', '', JText::_('(All)'));
         foreach ($langs as $lang) {
             $langList[] = JHTML::_('select.option', $lang->shortcode, $lang->name);
         }
         // Make the language filter
         $lists['filterLang'] = JHTML::_('select.genericlist', $langList, 'filterLang', 'class="inputbox" onchange="document.adminForm.submit();" size="1"', 'value', 'text', $this->filterLang);
     }
     // Filter meta tags
     $metas[] = JHTML::_('select.option', 0, JText::_('(All)'));
     $metas[] = JHTML::_('select.option', 1, JText::_('Empty'));
     $metas[] = JHTML::_('select.option', 2, JText::_('Filled'));
     $lists['filterTitle'] = JHTML::_('select.genericlist', $metas, 'filterTitle', 'class="inputbox" onchange="document.adminForm.submit();" size="1"', 'value', 'text', $this->filterTitle);
     $lists['filterDesc'] = JHTML::_('select.genericlist', $metas, 'filterDesc', 'class="inputbox" onchange="document.adminForm.submit();" size="1"', 'value', 'text', $this->filterDesc);
     $lists['filterKeys'] = JHTML::_('select.genericlist', $metas, 'filterKeys', 'class="inputbox" onchange="document.adminForm.submit();" size="1"', 'value', 'text', $this->filterKeys);
     // Filter trashed
     $trashed[] = JHTML::_('select.option', 0, JText::_('(All)'));
     $trashed[] = JHTML::_('select.option', 1, JText::_('Not Trashed'));
     $trashed[] = JHTML::_('select.option', 2, JText::_('Trashed'));
     $lists['filterTrashed'] = JHTML::_('select.genericlist', $trashed, 'filterTrashed', 'class="inputbox" onchange="document.adminForm.submit();" size="1"', 'value', 'text', $this->filterTrashed);
     $lists['filterReset'] = '<input type="button" value="' . JText::_('Reset') . '" onclick="resetFilters();" />';
     // Ordering
     $lists['filter_order'] = $this->filterOrder;
     $lists['filter_order_Dir'] = $this->filterOrderDir;
     return $lists;
 }
예제 #5
0
    echo $jfbutton;
    ?>
</td>
		          </tr>
		      </table>
		  </fieldset>
          <?php 
}
?>

		  <?php 
echo $pane->endPanel();
echo $pane->startPanel(JText::_('COM_SEF_ANALYTICS'), 'analytics');
$x = 0;
JoomSEF::OnlyPaidVersion();
if (!SEFTools::JoomFishInstalled()) {
    echo $pane->endPanel();
    echo $pane->startPanel(JText::_('COM_SEF_SUBDOMAINS'), 'subdomains');
    $x = 0;
    ?>
            <fieldset class="adminform">
            	<legend><?php 
    echo JText::_('COM_SEF_SUBDOMAINS');
    ?>
</legend>
            	<table id="subdomains_tbl">
            		<tr>
            			<th width="140" align="left">
            			<?php 
    echo Jtext::_('COM_SEF_SUBDOMAIN');
    ?>
예제 #6
0
 function &getLists()
 {
     $db =& JFactory::getDBO();
     $sefConfig = SEFConfig::getConfig();
     $std_opt = 'class="inputbox" size="2"';
     $lists['enabled'] = JHTML::_('select.booleanlist', 'enabled', $std_opt, $sefConfig->enabled);
     $lists['professionalMode'] = JHTML::_('select.booleanlist', 'professionalMode', $std_opt, $sefConfig->professionalMode);
     $lists['lowerCase'] = JHTML::_('select.booleanlist', 'lowerCase', $std_opt, $sefConfig->lowerCase);
     $lists['disableNewSEF'] = JHTML::_('select.booleanlist', 'disableNewSEF', $std_opt, $sefConfig->disableNewSEF);
     $lists['dontRemoveSid'] = JHTML::_('select.booleanlist', 'dontRemoveSid', $std_opt, $sefConfig->dontRemoveSid);
     $lists['setQueryString'] = JHTML::_('select.booleanlist', 'setQueryString', $std_opt, $sefConfig->setQueryString);
     $lists['parseJoomlaSEO'] = JHTML::_('select.booleanlist', 'parseJoomlaSEO', $std_opt, $sefConfig->parseJoomlaSEO);
     $lists['redirectJoomlaSEF'] = JHTML::_('select.booleanlist', 'redirectJoomlaSEF', $std_opt, $sefConfig->redirectJoomlaSEF);
     $lists['checkJunkUrls'] = JHTML::_('select.booleanlist', 'checkJunkUrls', $std_opt, $sefConfig->checkJunkUrls);
     $lists['preventNonSefOverwrite'] = JHTML::_('select.booleanlist', 'preventNonSefOverwrite', $std_opt, $sefConfig->preventNonSefOverwrite);
     $basehrefs[] = JHTML::_('select.option', _COM_SEF_BASE_HOMEPAGE, JText::_('Yes - always use only base URL'));
     $basehrefs[] = JHTML::_('select.option', _COM_SEF_BASE_CURRENT, JText::_('Yes - always use full SEO URL'));
     $basehrefs[] = JHTML::_('select.option', _COM_SEF_BASE_NONE, JText::_('No - disable base href generation'));
     $basehrefs[] = JHTML::_('select.option', _COM_SEF_BASE_IGNORE, JText::_('No - leave original'));
     $lists['check_base_href'] = JHTML::_('select.genericlist', $basehrefs, 'check_base_href', 'class="inputbox" size="1"', 'value', 'text', $sefConfig->check_base_href);
     // www and non-www handling
     $wwws[] = JHTML::_('select.option', _COM_SEF_WWW_NONE, JText::_('Don\'t handle'));
     $wwws[] = JHTML::_('select.option', _COM_SEF_WWW_USE_WWW, JText::_('Always use www domain'));
     $wwws[] = JHTML::_('select.option', _COM_SEF_WWW_USE_NONWWW, JText::_('Always use non-www domain'));
     $lists['wwwHandling'] = JHTML::_('select.genericlist', $wwws, 'wwwHandling', 'class="inputbox" size="1"', 'value', 'text', $sefConfig->wwwHandling);
     if (SEFTools::JoomFishInstalled()) {
         $jfrouterEnabled = JPluginHelper::isEnabled('system', 'jfrouter');
         // lang placement
         $langPlacement[] = JHTML::_('select.option', _COM_SEF_LANG_PATH, JText::_('include in path'));
         $langPlacement[] = JHTML::_('select.option', _COM_SEF_LANG_SUFFIX, JText::_('add as suffix'));
         $langPlacement[] = JHTML::_('select.option', _COM_SEF_LANG_DOMAIN, JText::_('use different domains'));
         $langPlacement[] = JHTML::_('select.option', _COM_SEF_LANG_NONE, JText::_('do not add'));
         $lists['langPlacement'] = JHTML::_('select.genericlist', $langPlacement, 'langPlacement', 'class="inputbox" size="1" onchange="langTypeChanged(this.value);"', 'value', 'text', $sefConfig->langPlacement);
         // Prepare main language array
         $mainlangs = array();
         $mainlangs[] = JHTML::_('select.option', '0', JText::_('(none)'));
         // language domains and main language
         $db->setQuery("SELECT `id`, `shortcode`, `name` FROM `#__languages` WHERE `active` = '1' ORDER BY `ordering`");
         $langs = $db->loadObjectList();
         if (@count(@$langs)) {
             $uri =& JURI::getInstance();
             $host = $uri->getHost();
             foreach ($langs as $lang) {
                 $l = new stdClass();
                 $l->code = $lang->shortcode;
                 $l->name = $lang->name;
                 $l->value = isset($sefConfig->jfSubDomains[$lang->shortcode]) ? $sefConfig->jfSubDomains[$lang->shortcode] : $host;
                 // domain list
                 $langlist[] = $l;
                 // main language list
                 $mainlangs[] = JHTML::_('select.option', $l->code, $l->name);
             }
             //$lists['jfSubDomains'] = '<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr>'. implode('</tr><tr>', $langlist) .'</tr></table>';
             $lists['jfSubDomains'] = $langlist;
         }
         // Create the main language list
         $disabled = $sefConfig->langPlacement == _COM_SEF_LANG_DOMAIN ? ' disabled="disabled"' : '';
         $lists['mainLanguage'] = JHTML::_('select.genericlist', $mainlangs, 'mainLanguage', 'class="inputbox" size="1"' . $disabled, 'value', 'text', $sefConfig->mainLanguage);
         $disabled = '';
         if ($jfrouterEnabled) {
             $disabled = ' disabled="disabled"';
         }
         $lists['jfBrowserLang'] = JHTML::_('select.booleanlist', 'jfBrowserLang', $std_opt . $disabled, $sefConfig->jfBrowserLang);
         $lists['jfLangCookie'] = JHTML::_('select.booleanlist', 'jfLangCookie', $std_opt . $disabled, $sefConfig->jfLangCookie);
     }
     $lists['record404'] = JHTML::_('select.booleanlist', 'record404', $std_opt, $sefConfig->record404);
     $lists['template404'] = JHTML::_('select.booleanlist', 'template404', $std_opt, $sefConfig->template404);
     $lists['msg404'] = JHTML::_('select.booleanlist', 'showMessageOn404', $std_opt, $sefConfig->showMessageOn404);
     $lists['use404itemid'] = JHTML::_('select.booleanlist', 'use404itemid', $std_opt, $sefConfig->use404itemid);
     $lists['nonSefRedirect'] = JHTML::_('select.booleanlist', 'nonSefRedirect', $std_opt, $sefConfig->nonSefRedirect);
     $lists['useMoved'] = JHTML::_('select.booleanlist', 'useMoved', $std_opt, $sefConfig->useMoved);
     $lists['useMovedAsk'] = JHTML::_('select.booleanlist', 'useMovedAsk', $std_opt, $sefConfig->useMovedAsk);
     $lists['alwaysUseLang'] = JHTML::_('select.booleanlist', 'alwaysUseLang', $std_opt, $sefConfig->alwaysUseLang);
     $lists['translateNames'] = JHTML::_('select.booleanlist', 'translateNames', $std_opt, $sefConfig->translateNames);
     $lists['contentUseIndex'] = JHTML::_('select.booleanlist', 'contentUseIndex', $std_opt, $sefConfig->contentUseIndex);
     $lists['allowUTF'] = JHTML::_('select.booleanlist', 'allowUTF', $std_opt, $sefConfig->allowUTF);
     $lists['excludeSource'] = JHTML::_('select.booleanlist', 'excludeSource', $std_opt, $sefConfig->excludeSource);
     $lists['reappendSource'] = JHTML::_('select.booleanlist', 'reappendSource', $std_opt, $sefConfig->reappendSource);
     $lists['ignoreSource'] = JHTML::_('select.booleanlist', 'ignoreSource', $std_opt, $sefConfig->ignoreSource);
     $lists['appendNonSef'] = JHTML::_('select.booleanlist', 'appendNonSef', $std_opt, $sefConfig->appendNonSef);
     $lists['transitSlash'] = JHTML::_('select.booleanlist', 'transitSlash', $std_opt, $sefConfig->transitSlash);
     $lists['redirectSlash'] = JHTML::_('select.booleanlist', 'redirectSlash', $std_opt, $sefConfig->redirectSlash);
     $lists['useCache'] = JHTML::_('select.booleanlist', 'useCache', $std_opt, $sefConfig->useCache);
     $lists['numberDuplicates'] = JHTML::_('select.booleanlist', 'numberDuplicates', $std_opt, $sefConfig->numberDuplicates);
     $lists['autoCanonical'] = JHTML::_('select.booleanlist', 'autoCanonical', $std_opt, $sefConfig->autoCanonical);
     $lists['cacheRecordHits'] = JHTML::_('select.booleanlist', 'cacheRecordHits', $std_opt, $sefConfig->cacheRecordHits);
     $lists['cacheShowErr'] = JHTML::_('select.booleanlist', 'cacheShowErr', $std_opt, $sefConfig->cacheShowErr);
     $lists['sefComponentUrls'] = JHTML::_('select.booleanlist', 'sefComponentUrls', $std_opt, $sefConfig->sefComponentUrls);
     $lists['versionChecker'] = JHTML::_('select.booleanlist', 'versionChecker', $std_opt, $sefConfig->versionChecker);
     $lists['artioFeedDisplay'] = JHTML::_('select.booleanlist', 'artioFeedDisplay', $std_opt, $sefConfig->artioFeedDisplay);
     $lists['fixIndexPhp'] = JHTML::_('select.booleanlist', 'fixIndexPhp', $std_opt, $sefConfig->fixIndexPhp);
     $lists['fixQuestionMark'] = JHTML::_('select.booleanlist', 'fixQuestionMark', $std_opt, $sefConfig->fixQuestionMark);
     $lists['fixDocumentFormat'] = JHTML::_('select.booleanlist', 'fixDocumentFormat', $std_opt, $sefConfig->fixDocumentFormat);
     $lists['autolock_urls'] = JHTML::_('select.booleanlist', 'autolock_urls', $std_opt, $sefConfig->autolock_urls);
     $lists['indexPhpCurrentMenu'] = JHTML::_('select.booleanlist', 'indexPhpCurrentMenu', $std_opt, $sefConfig->indexPhpCurrentMenu);
     $lists['spaceTolerant'] = JHTML::_('select.booleanlist', 'spaceTolerant', $std_opt, $sefConfig->spaceTolerant);
     $lists['cacheSize'] = '<input type="text" name="cacheSize" size="10" class="inputbox" value="' . $sefConfig->cacheSize . '" />';
     $lists['cacheMinHits'] = '<input type="text" name="cacheMinHits" size="10" class="inputbox" value="' . $sefConfig->cacheMinHits . '" />';
     $lists['junkWords'] = '<input type="text" name="junkWords" size="60" class="inputbox" value="' . $sefConfig->junkWords . '" />';
     $lists['junkExclude'] = '<input type="text" name="junkExclude" size="60" class="inputbox" value="' . $sefConfig->junkExclude . '" />';
     $lists['tag_generator'] = '<input type="text" name="tag_generator" size="60" class="inputbox" value="' . $sefConfig->tag_generator . '" />';
     $lists['tag_googlekey'] = '<input type="text" name="tag_googlekey" size="60" class="inputbox" value="' . $sefConfig->tag_googlekey . '" />';
     $lists['tag_livekey'] = '<input type="text" name="tag_livekey" size="60" class="inputbox" value="' . $sefConfig->tag_livekey . '" />';
     $lists['tag_yahookey'] = '<input type="text" name="tag_yahookey" size="60" class="inputbox" value="' . $sefConfig->tag_yahookey . '" />';
     $lists['artioUserName'] = '******' . $sefConfig->artioUserName . '" />';
     $lists['artioPassword'] = '******' . $sefConfig->artioPassword . '" />';
     $lists['artioDownloadId'] = '<input type="text" name="artioDownloadId" size="60" class="inputbox" value="' . $sefConfig->artioDownloadId . '" />';
     $lists['logErrors'] = JHTML::_('select.booleanlist', 'logErrors', $std_opt, $sefConfig->logErrors);
     $lists['trace'] = JHTML::_('select.booleanlist', 'trace', $std_opt, $sefConfig->trace);
     $lists['traceLevel'] = '<input type="text" name="traceLevel" size="2" class="inputbox" value="' . $sefConfig->traceLevel . '" />';
     $useSitenameOpts[] = JHTML::_('select.option', _COM_SEF_SITENAME_BEFORE, JText::_('Yes - before page title'));
     $useSitenameOpts[] = JHTML::_('select.option', _COM_SEF_SITENAME_AFTER, JText::_('Yes - after page title'));
     $useSitenameOpts[] = JHTML::_('select.option', _COM_SEF_SITENAME_NO, JText::_('No'));
     $lists['use_sitename'] = JHTML::_('select.genericlist', $useSitenameOpts, 'use_sitename', 'class="inputbox" size="1"', 'value', 'text', $sefConfig->use_sitename);
     // metadata
     $lists['enable_metadata'] = JHTML::_('select.booleanlist', 'enable_metadata', $std_opt, $sefConfig->enable_metadata);
     $metadataGenerateOpts[] = JHTML::_('select.option', _COM_SEF_META_GEN_EMPTY, JText::_('Only if original empty'));
     $metadataGenerateOpts[] = JHTML::_('select.option', _COM_SEF_META_GEN_ALWAYS, JText::_('Always'));
     $metadataGenerateOpts[] = JHTML::_('select.option', _COM_SEF_META_GEN_NEVER, JText::_('Never'));
     $lists['metadata_auto'] = JHTML::_('select.genericlist', $metadataGenerateOpts, 'metadata_auto', 'class="inputbox" size="1"', 'value', 'text', $sefConfig->metadata_auto);
     $metadataPriorityOpts[] = JHTML::_('select.option', _COM_SEF_META_PR_ORIGINAL, JText::_('Prefer original'));
     $metadataPriorityOpts[] = JHTML::_('select.option', _COM_SEF_META_PR_JOOMSEF, JText::_('Prefer JoomSEF'));
     $metadataPriorityOpts[] = JHTML::_('select.option', _COM_SEF_META_PR_JOIN, JText::_('Join both'));
     $lists['rewrite_keywords'] = JHTML::_('select.genericlist', $metadataPriorityOpts, 'rewrite_keywords', 'class="inputbox" size="1"', 'value', 'text', $sefConfig->rewrite_keywords);
     $lists['rewrite_description'] = JHTML::_('select.genericlist', $metadataPriorityOpts, 'rewrite_description', 'class="inputbox" size="1"', 'value', 'text', $sefConfig->rewrite_description);
     $lists['prefer_joomsef_title'] = JHTML::_('select.booleanlist', 'prefer_joomsef_title', $std_opt, $sefConfig->prefer_joomsef_title);
     $lists['sitename_sep'] = '<input type="text" name="sitename_sep" size="10" class="inputbox" value="' . $sefConfig->sitename_sep . '" />';
     //$lists['rewrite_keywords']      = JHTML::_('select.booleanlist', 'rewrite_keywords',    $std_opt, $sefConfig->rewrite_keywords);
     //$lists['rewrite_description']   = JHTML::_('select.booleanlist', 'rewrite_description',    $std_opt, $sefConfig->rewrite_description);
     $lists['prevent_dupl'] = JHTML::_('select.booleanlist', 'prevent_dupl', $std_opt, $sefConfig->prevent_dupl);
     $aliases[] = JHTML::_('select.option', '0', JText::_('Full Title'));
     $aliases[] = JHTML::_('select.option', '1', JText::_('Title Alias'));
     $lists['useAlias'] = JHTML::_('select.radiolist', $aliases, 'useAlias', $std_opt, 'value', 'text', $sefConfig->useAlias);
     // get a list of the static content items for 404 page
     $query = "SELECT id, title" . "\n FROM #__content" . "\n WHERE sectionid = 0 AND title != '404'" . "\n AND catid = 0" . "\n ORDER BY ordering";
     $db->setQuery($query);
     $items = $db->loadObjectList();
     $options = array();
     $options[] = JHTML::_('select.option', _COM_SEF_404_DEFAULT, '(' . JText::_('Custom 404 Page') . ')');
     $options[] = JHTML::_('select.option', _COM_SEF_404_FRONTPAGE, '(' . JText::_('Front Page') . ')');
     $options[] = JHTML::_('select.option', _COM_SEF_404_JOOMLA, '(' . JText::_('Joomla! Error Page') . ')');
     // assemble menu items to the array
     foreach ($items as $item) {
         $options[] = JHTML::_('select.option', $item->id, $item->title);
     }
     $lists['page404'] = JHTML::_('select.genericlist', $options, 'page404', 'class="inputbox" size="1"', 'value', 'text', $sefConfig->page404);
     // Get the menu selection list
     $selections = JHTML::_('menu.linkoptions');
     $lists['itemid404'] = JHTML::_('select.genericlist', $selections, 'itemid404', 'class="inputbox" size="15"', 'value', 'text', $sefConfig->itemid404);
     $sql = "SELECT `id`, `introtext` FROM `#__content` WHERE `title` = '404'";
     $row = null;
     $db->setQuery($sql);
     $row = $db->loadObject();
     $lists['txt404'] = isset($row->introtext) ? $row->introtext : JText::_('ERROR_DEFAULT_404');
     $lists['txt404'] = htmlspecialchars($lists['txt404']);
     // Statistics
     $lists["google_email"] = $sefConfig->google_email;
     $lists["google_password"] = $sefConfig->google_password;
     $lists["google_id"] = $sefConfig->google_id;
     $lists["google_apikey"] = $sefConfig->google_apikey;
     $lists["google_enable"] = JHTML::_('select.booleanlist', 'google_enable', $std_opt, $sefConfig->google_enable);
     $lists["google_exclude_ip"] = $sefConfig->google_exclude_ip;
     // Exclude access level
     $acl =& JFactory::getACL();
     $gtree = $acl->get_group_children_tree(null, 'USERS', false);
     $lists["google_exclude_level"] = JHTML::_('select.genericlist', $gtree, 'google_exclude_level[]', 'class="inputbox" size="10" multiple="multiple"', 'value', 'text', $sefConfig->google_exclude_level);
     $lists['subdomains_menus'] = JHTML::_('select.genericlist', $selections, 'subdomain_Itemid[][]', 'class="inputbox" size="10" multiple="multiple"');
     $lists['subdomains_titles'] = JHTML::_('select.genericlist', $selections, 'subdomain_titlepage[]', 'class="inputbox" size="1"');
     $lists['subdomains_remove'] = '<input class="button" type="button" onclick="remove_subdomain(this);" value="' . Jtext::_('COM_SEF_REMOVE_SUBDOMAIN') . '" />';
     $this->_lists = $lists;
     return $this->_lists;
 }
예제 #7
0
 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);
 }
예제 #8
0
    ?>
        <td colspan="2">
            <?php 
    echo $this->lists['filterReal'];
    ?>
        </td>
        <?php 
}
?>
        <td>
            <?php 
echo $this->lists['comList'];
?>
        </td>
        <?php 
if (SEFTools::JoomFishInstalled() && $this->viewmode != _COM_SEF_VIEWMODE_404) {
    ?>
        <td>
            <?php 
    echo $this->lists['filterLang'];
    ?>
        </td>
        <?php 
}
?>
        <td>
            <?php 
echo $this->lists['filterReset'];
?>
        </td>
    </tr>