예제 #1
0
 function display($tpl = null)
 {
     // Get data from the model
     $extension =& $this->get('extension');
     $this->assignRef('extension', $extension);
     $this->langs = $this->get('languages');
     $this->strings = $this->get('strings');
     $this->translation = $this->get('translation');
     $this->subdomains = $this->get('subdomains');
     $this->menus = $this->get('menus');
     $filters =& SEFTools::getExtFilters($extension->option, false);
     $this->assignRef('filters', $filters);
     $acceptVars =& SEFTools::getExtAcceptVars($extension->option, false);
     sort($acceptVars, SORT_STRING);
     $this->assignRef('acceptVars', $acceptVars);
     // Root domain for subdomains configuration
     $rootDomain = JFactory::getURI()->getHost();
     if (substr($rootDomain, 0, 4) == 'www.') {
         $rootDomain = substr($rootDomain, 4);
     }
     $this->assign('rootDomain', $rootDomain);
     JToolBarHelper::title(JText::_('SEF Extension') . ' <small>' . JText::_('Edit') . ' [ ' . (strlen($extension->name) ? $extension->name : $extension->component->name) . ' ]</small>', 'plugin.png');
     JToolBarHelper::save();
     JToolBarHelper::apply();
     JToolBarHelper::spacer();
     JToolBarHelper::cancel();
     JHTML::_('behavior.tooltip');
     $redir = JRequest::getVar('redirto', '');
     $this->assignRef('redirto', $redir);
     parent::display($tpl);
 }
예제 #2
0
 function getFeedTitle($id)
 {
     $title = array();
     $field = 'name';
     if (SEFTools::UseAlias($this->params, 'feed_alias')) {
         $field = 'alias';
     }
     $id = intval($id);
     $query = "SELECT `id`, `{$field}` AS `name`, `catid`, `language`, `metadesc`, `metakey`, `metadata` FROM `#__newsfeeds` WHERE `id` = '{$id}'";
     $this->_db->setQuery($query);
     $row = $this->_db->loadObject('stdClass', $this->config->translateItems);
     if (is_null($row)) {
         JoomSefLogger::Log("Feed with ID {$id} could not be found.", $this, 'com_newsfeeds');
         return array();
     }
     if ($this->params->get('show_category', 2) != 0) {
         $catInfo = $this->getCategoryInfo($row->catid);
         if ($catInfo === false) {
             JoomSefLogger::Log("Category with ID {$row->catid} could not be found.", $this, 'com_newsfeeds');
         }
         if (is_array($catInfo->path)) {
             $title = array_merge($title, $catInfo->path);
         }
     }
     $this->getMetaData($row);
     $title[] = ($this->params->get('feedid', '0') == 0 ? '' : $id . '-') . $row->name;
     return $title;
 }
예제 #3
0
 function create(&$uri)
 {
     $vars = $uri->getQuery(true);
     extract($vars);
     $this->params =& SEFTools::getExtParams('com_search');
     $newUri = $uri;
     if (!(isset($task) ? @$task : null)) {
         $title[] = JoomSEF::_getMenuTitle($option, isset($task) ? $task : null);
         if (isset($searchword) && $this->params->get('nonsefphrase', '1') != '1') {
             $title[] = $searchword;
         }
         if (count($title) > 0) {
             $this->_createNonSefVars($uri);
             if (!isset($searchword) || $this->params->get('nonsefphrase', '1') != '1') {
                 // Generate meta tags
                 $desc = array();
                 if (isset($searchword)) {
                     $desc[] = $searchword;
                 }
                 if (isset($searchphrase)) {
                     $desc[] = $searchphrase;
                 }
                 $this->metadesc = implode(', ', $desc);
                 unset($desc);
             }
             $metatags = $this->getMetaTags();
             $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$vars['lang'], $this->nonSefVars, null, $metatags);
         }
     }
     return $newUri;
 }
예제 #4
0
 function display($tpl = null)
 {
     JToolBarHelper::title(JText::_('JoomSEF'), 'artio.png');
     // Get number of URLs for purge warning
     $model =& JModel::getInstance('URLs', 'SEFModel');
     $this->assign('purgeCount', $model->getCount(0));
     // Get newest version available
     $sefConfig =& SEFConfig::getConfig();
     if ($sefConfig->versionChecker) {
         $model2 =& JModel::getInstance('Upgrade', 'SEFModel');
         $newVer = $model2->getNewSEFVersion();
         $sefinfo = SEFTools::getSEFInfo();
         if (strnatcasecmp($newVer, $sefinfo['version']) > 0 || strnatcasecmp($newVer, substr($sefinfo['version'], 0, strpos($sefinfo['version'], '-'))) == 0) {
             $newVer = '<span style="font-weight: bold; color: red;">' . $newVer . '</span>&nbsp;&nbsp;<input type="button" onclick="showUpgrade();" value="' . JText::_('Go to Upgrade page') . '" />';
         }
         $newVer .= ' <input type="button" onclick="disableStatus(\'versioncheck\');" value="' . JText::_('Disable version checker') . '" />';
         $this->assign('newestVersion', $newVer);
     } else {
         $newestVersion = JText::_('Version checker disabled') . '&nbsp;&nbsp;<input type="button" onclick="enableStatus(\'versioncheck\');" value="' . JText::_('Enable') . '" />';
         $this->assign('newestVersion', $newestVersion);
     }
     // Get statistics
     $stats = $model->getStatistics();
     $this->assignRef('stats', $stats);
     // Get feed
     $feed = $this->get('Feed');
     $this->assignRef('feed', $feed);
     JHTML::_('behavior.tooltip');
     parent::display($tpl);
 }
예제 #5
0
파일: view.html.php 프로젝트: 01J/bealtine
 function display($tpl = null)
 {
     JToolBarHelper::title(JText::_('COM_SEF_JOOMSEF'), 'artio.png');
     $user = JFactory::getUser();
     if ($user->authorise('core.admin', 'com_sef')) {
         JToolBarHelper::preferences('com_sef');
     }
     // Get number of URLs for purge warning
     $model = SEFModel::getInstance('URLs', 'SEFModel');
     $this->assign('purgeCount', $model->getCount(0));
     // Get newest version available
     $sefConfig = SEFConfig::getConfig();
     if ($sefConfig->versionChecker) {
         $model2 = SEFModel::getInstance('Upgrade', 'SEFModel');
         $newVer = $model2->getNewSEFVersion();
         $sefinfo = SEFTools::getSEFInfo();
         if (strnatcasecmp($newVer, $sefinfo['version']) > 0 || strnatcasecmp($newVer, substr($sefinfo['version'], 0, strpos($sefinfo['version'], '-'))) == 0) {
             $newVer = '<span style="font-weight: bold; color: red;">' . $newVer . '</span>&nbsp;&nbsp;<input type="button" class="btn btn-small" onclick="showUpgrade();" value="' . JText::_('COM_SEF_GO_TO_UPGRADE_PAGE') . '" />';
         }
         $newVer .= ' <input type="button" class="btn btn-danger btn-small" onclick="disableStatus(\'versioncheck\');" value="' . JText::_('COM_SEF_DISABLE_VERSION_CHECKER') . '" />';
         $this->assign('newestVersion', $newVer);
     } else {
         $newestVersion = JText::_('COM_SEF_VERSION_CHECKER_DISABLED') . '&nbsp;&nbsp;<input type="button" class="btn btn-success btn-small" onclick="enableStatus(\'versioncheck\');" value="' . JText::_('COM_SEF_ENABLE') . '" />';
         $this->assign('newestVersion', $newestVersion);
     }
     // Get statistics
     $stats = $model->getStatistics();
     $this->assignRef('stats', $stats);
     // Get feed
     $feed = $this->get('Feed');
     $this->assignRef('feed', $feed);
     // Check language filter plugin
     $this->getModel('sef')->checkLanguagePlugins();
     parent::display($tpl);
 }
예제 #6
0
 function display()
 {
     $model =& $this->getModel('extensions');
     $view =& $this->getView('sef', 'html', 'sefview');
     $view->setModel($model);
     SEFTools::checkExtVersions();
     parent::display();
 }
 function create(&$uri)
 {
     $sefConfig =& SEFConfig::getConfig();
     $database =& JFactory::getDBO();
     $this->params =& SEFTools::getExtParams('com_weblinks');
     // JF translate extension.
     $jfTranslate = $sefConfig->translateNames ? ', `id`' : '';
     $vars = $uri->getQuery(true);
     extract($vars);
     $title = array();
     $title[] = JoomSEF::_getMenuTitle($option, @$this_task);
     if (@$view == 'category') {
         $title[] = $this->getCategoryTitle($id, SEFTools::UseAlias($this->params, 'category_alias'));
     } elseif (empty($this_task) && @$view == 'weblink') {
         if (isset($catid)) {
             if ($this->params->get('show_category', '1')) {
                 $title[] = $this->getCategoryTitle($catid, SEFTools::UseAlias($this->params, 'category_alias'));
             }
         }
         if (!empty($id)) {
             $field = 'title';
             if (SEFTools::UseAlias($this->params, 'weblink_alias')) {
                 $field = 'alias';
             }
             $id = intval($id);
             $database->setQuery("SELECT `{$field}` AS `title` {$jfTranslate} FROM `#__weblinks` WHERE `id` = '{$id}'");
             $row = $database->loadObject();
             if (is_null($row)) {
                 JoomSefLogger::Log("Weblink with ID {$id} could not be found.", $this, 'com_weblinks');
             } elseif (!empty($row->title)) {
                 $name = $row->title;
                 if ($this->params->get('weblink_id', '0')) {
                     $name = $id . '-' . $name;
                 }
                 $title[] = $name;
             }
         } else {
             $title[] = JText::_('Submit');
         }
     }
     if (isset($task) && $task == 'new') {
         $title[] = 'new' . $sefConfig->suffix;
     }
     $newUri = $uri;
     if (count($title) > 0) {
         // Generate meta tags
         $metatags = $this->getMetaTags();
         $priority = $this->getPriority($uri);
         $sitemap = $this->getSitemapParams($uri);
         $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$vars['lang'], null, null, $metatags, $priority, false, null, $sitemap);
     }
     return $newUri;
 }
 function GetExts()
 {
     static $exts;
     if (!isset($exts)) {
         $exts = array();
         $db =& JFactory::getDBO();
         $query = "SELECT DISTINCT `extension` FROM `#__sefexttexts`";
         $db->setQuery($query);
         $extensions = $db->loadResultArray();
         if (count($extensions) > 0) {
             foreach ($extensions as $ext) {
                 $exts[$ext] = SEFTools::getExtName($ext);
             }
         }
     }
     return $exts;
 }
예제 #9
0
파일: crawler.php 프로젝트: 01J/bealtine
 function _parseLinks($url, &$found)
 {
     // Get response, follow 5 redirections
     $redirs = 0;
     do {
         $redirect = false;
         $response = SEFTools::PostRequest($url, null, null, 'get', null);
         if ($response === false) {
             // Error
             return;
         }
         if ($redirs < 5 && $response->code >= 300 && $response->code < 400) {
             // Parse redirect URL
             $pos = stripos($response->header, 'location:');
             if ($pos !== false) {
                 $pos += 9;
                 // Skip header name
                 $pos2 = strpos($response->header, "\r", $pos);
                 $url = substr($response->header, $pos, $pos2 - $pos);
                 $url = trim($url);
                 $redirect = true;
                 $redirs++;
             }
         }
     } while ($redirect);
     // Check code
     if ($response->code == 200) {
         // Parse URLs
         $matches = array();
         if (preg_match_all('#<a\\s[^>]*href=["\']([^"\']+)#i', $response->content, $matches) > 0) {
             // Loop through found URLs
             foreach ($matches[1] as $link) {
                 $link = str_replace(JURI::root(), '', $link);
                 if (strpos($link, '://') !== false) {
                     // Absolute external link, skip
                     continue;
                 }
                 // Internal link
                 $link = JURI::root() . ltrim(html_entity_decode(urldecode($link)), '/');
                 if (!in_array($link, $found)) {
                     $found[] = $link;
                 }
             }
         }
     }
 }
예제 #10
0
 function beforeCreate(&$uri)
 {
     // Remove the part after ':' from variables
     if (!is_null($uri->getVar('id'))) {
         SEFTools::fixVariable($uri, 'id');
     }
     if (!is_null($uri->getVar('catid'))) {
         SEFTools::fixVariable($uri, 'catid');
     }
     if ($uri->getVar('id') == 0) {
         $uri->delVar('id');
     }
     if ($uri->getVar('w_id') == 0) {
         $uri->delVar('w_id');
     }
     return;
 }
예제 #11
0
파일: view.html.php 프로젝트: 01J/bealtine
 function display($tpl = null)
 {
     JToolBarHelper::title(JText::_('COM_SEF_JOOMSEF') . ' - ' . JText::_('COM_SEF_UPGRADE_MANAGER'), 'update.png');
     JToolBarHelper::back('COM_SEF_BACK', 'index.php?option=com_sef');
     $exts = $this->get('UpgradeExts');
     $this->assignRef('extensions', $exts);
     $oldVer = SEFTools::getSEFVersion();
     $this->assignRef('oldVer', $oldVer);
     $newVer = $this->get('newSEFVersion');
     $this->assignRef('newVer', $newVer);
     $regInfo = $this->get('RegisteredInfo');
     $this->assignRef('regInfo', $regInfo);
     $isPaidVersion = $this->get('IsPaidVersion');
     $this->assignRef('isPaidVersion', $isPaidVersion);
     JHTML::_('behavior.tooltip');
     JHTML::_('behavior.modal');
     parent::display($tpl);
 }
예제 #12
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);
 }
예제 #13
0
 function create(&$uri)
 {
     $sefConfig =& SEFConfig::getConfig();
     $params = SEFTools::GetExtParams('com_content');
     $vars = $uri->getQuery(true);
     extract($vars);
     // Set title.
     $title = array();
     $title[] = JoomSEF::_getMenuTitle(@$option, @$task, @$Itemid);
     if (!empty($tmpl)) {
         $title[] = $tmpl;
     }
     $newUri = $uri;
     if (count($title) > 0) {
         $this->_createNonSefVars($uri);
         $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$lang, null, $this->ignoreVars);
     }
     return $newUri;
 }
예제 #14
0
 function create(&$uri)
 {
     $sefConfig =& SEFConfig::getConfig();
     $this->params =& SEFTools::getExtParams('com_banners');
     $vars = $uri->getQuery(true);
     extract($vars);
     $title[] = JoomSEF::_getMenuTitleLang(@$option, @$task, @$Itemid);
     switch (@$task) {
         case 'click':
             $title[] = $this->GetBannerName($id);
             unset($task);
             break;
     }
     $newUri = $uri;
     if (isset($this->lang)) {
         $lang = $this->lang;
     }
     if (count($title) > 0) {
         $newUri = JoomSEF::_sefGetLocation($uri, $title, @$task, null, null, @$lang);
     }
     return $newUri;
 }
예제 #15
0
 function create(&$uri)
 {
     $vars = $uri->getQuery(true);
     extract($vars);
     // Don't SEF opensearch links
     if (isset($format) && $format == 'opensearch') {
         return $uri;
     }
     $this->params =& SEFTools::getExtParams('com_search');
     $newUri = $uri;
     if (!(isset($task) ? @$task : null)) {
         $title[] = JoomSEF::_getMenuTitleLang($option, $lang, @$Itemid);
         if (isset($searchword) && $this->params->get('nonsefphrase', '1') != '1') {
             $title[] = $searchword;
         }
         if (isset($view) && ($view != 'search' || $this->params->get('add_search', '0') == '1')) {
             $title[] = $view;
         }
         if (isset($format)) {
             $title[] = $format;
         }
         $this->_createNonSefVars($uri);
         if (!isset($searchword) || $this->params->get('nonsefphrase', '1') != '1') {
             // Generate meta tags
             $desc = array();
             if (isset($searchword)) {
                 $desc[] = $searchword;
             }
             if (isset($searchphrase)) {
                 $desc[] = $searchphrase;
             }
             $this->metadesc = implode(', ', $desc);
             unset($desc);
         }
         $metatags = $this->getMetaTags();
         $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$lang, $this->nonSefVars, null, $metatags, null, true);
     }
     return $newUri;
 }
예제 #16
0
 function display($tpl = null)
 {
     // Get data from the model
     $extension =& $this->get('extension');
     $this->assignRef('extension', $extension);
     $filters =& SEFTools::getExtFilters($extension->option, false);
     $this->assignRef('filters', $filters);
     $acceptVars =& SEFTools::getExtAcceptVars($extension->option, false);
     sort($acceptVars, SORT_STRING);
     $this->assignRef('acceptVars', $acceptVars);
     JToolBarHelper::title(JText::_('SEF Extension') . ' <small>' . JText::_('Edit') . ' [ ' . $extension->name . ' ]</small>', 'plugin.png');
     JToolBarHelper::save();
     JToolBarHelper::apply();
     JToolBarHelper::spacer();
     JToolBarHelper::cancel();
     JHTML::_('behavior.tooltip');
     $redir = JRequest::getVar('redirto', '');
     $this->assignRef('redirto', $redir);
     // Sliding pane
     $pane =& JPane::getInstance('tabs');
     $this->assignRef('pane', $pane);
     parent::display($tpl);
 }
예제 #17
0
 /**
  * Checks the found row
  *
  */
 function _checkRow(&$row, $ignoreSource, $Itemid, $url, &$metadata, $temploc, $priority, $option, $host, $sitemapParams)
 {
     $realloc = null;
     $db =& JFactory::getDBO();
     $sefConfig =& SEFConfig::getConfig();
     $numberDuplicates = $sefConfig->numberDuplicates;
     if (!empty($option)) {
         $params =& SEFTools::getExtParams($option);
         $extDuplicates = $params->get('numberDuplicates', '2');
         if ($extDuplicates != '2') {
             $numberDuplicates = $extDuplicates;
         }
     }
     if ($row != false && !is_null($row)) {
         if ($ignoreSource || !$ignoreSource && (empty($Itemid) || $row->Itemid == $Itemid)) {
             // ... check that it matches original URL
             if ($row->origurl == $url) {
                 // found the matching object
                 // it probably should have been found sooner
                 // but is checked again here just for CYA purposes
                 // and to end the loop
                 $realloc = $row->sefurl;
             } else {
                 if ($sefConfig->langPlacement == _COM_SEF_LANG_DOMAIN) {
                     // check if the urls differ only by lang variable
                     if (SEFTools::removeVariable($row->origurl, 'lang') == SEFTools::removeVariable($url, 'lang')) {
                         $db->setQuery("UPDATE `#__sefurls` SET `origurl` = " . $db->Quote(SEFTools::removeVariable($row->origurl, 'lang')) . " WHERE `id` = '{$row->id}' LIMIT 1");
                         // if error occured.
                         if (!$db->query()) {
                             $msg = JText::_('Could not update SEF URL in database');
                             if (JDEBUG) {
                                 $msg .= ': ' . $db->getErrorMsg();
                             }
                             JError::raiseError('JoomSEF Error', $msg);
                         }
                         $realloc = $row->sefurl;
                     }
                 }
             }
         }
         // The found URL is not the same
         if (!$numberDuplicates) {
             // But duplicates management is turned on
             // so we can save the same SEF URL for different non-SEF URL
             JoomSEF::_saveNewURL($Itemid, $metadata, $priority, $temploc, $url, false, $host, $sitemapParams);
             $realloc = $temploc;
         }
     } else {
         // Save URL in the database
         JoomSEF::_saveNewURL($Itemid, $metadata, $priority, $temploc, $url, true, $host, $sitemapParams);
         $realloc = $temploc;
     }
     return $realloc;
 }
예제 #18
0
파일: joomsef.php 프로젝트: 01J/bealtine
 function onAfterInitialise()
 {
     $sefConfig = SEFConfig::getConfig();
     $mainframe = JFactory::getApplication();
     // Enable menu associations if set to
     $joomlaVersion = new JVersion();
     if ($joomlaVersion->isCompatible('3.0')) {
         $mainframe->item_associations = $sefConfig->langMenuAssociations ? 1 : 0;
     } else {
         $mainframe->set('menu_associations', $sefConfig->langMenuAssociations ? 1 : 0);
     }
     // Register installer and updater adapters in admin area
     $this->registerAdapters();
     // Check if JoomSEF should be run
     if (!self::_isEnabled()) {
         return true;
     }
     // Store the router for later use
     $router = $mainframe->getRouter();
     JoomSEF::set('sef.global.jrouter', $router);
     // Load JoomSEF language file
     $jLang = JFactory::getLanguage();
     $jLang->load('com_sef', JPATH_ADMINISTRATOR);
     require_once JPATH_ROOT . '/components/com_sef/sef.router.php';
     $jsRouter = new JRouterJoomsef();
     $router->attachParseRule(array($jsRouter, 'parse'));
     $router->attachBuildRule(array($jsRouter, 'build'));
     // Disable global "Add suffix to URLs" before parsing and store current config
     $config = JFactory::getConfig();
     $oldSuffix = $config->get('sef_suffix', 0);
     $config->set('sef_suffix', 0);
     JoomSEF::set('sef.global.orig_sef_suffix', $oldSuffix);
     // Get all configured subdomains
     $subdomains = SEFTools::getAllSubdomains();
     // Redirect only when there's no POST variables
     if ($sefConfig->wwwHandling != _COM_SEF_WWW_NONE && empty($_POST)) {
         // Handle www and non-www domain
         $uri = JURI::getInstance();
         $host = $uri->getHost();
         $redirect = false;
         // Check if host is only IP
         $isIP = preg_match('/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\z/', $host);
         if ($sefConfig->wwwHandling == _COM_SEF_WWW_USE_WWW && !$isIP && strpos($host, 'www.') !== 0) {
             // Check if host starts with one of our subdomains
             if (isset($subdomains['*']) && count($subdomains['*']) > 0) {
                 $parts = explode('.', $host);
                 $domain = $parts[0];
                 $found = false;
                 foreach ($subdomains['*'] as $sub) {
                     if ($domain == $sub->subdomain) {
                         $found = true;
                         break;
                     }
                 }
                 if (!$found) {
                     // Redirect to www form
                     $redirect = true;
                     $uri->setHost('www.' . $host);
                 }
             } else {
                 // Redirect to www form
                 $redirect = true;
                 $uri->setHost('www.' . $host);
             }
         } else {
             if ($sefConfig->wwwHandling == _COM_SEF_WWW_USE_NONWWW && strpos($host, 'www.') === 0) {
                 // host must not begin with www.
                 $redirect = true;
                 $uri->setHost(substr($host, 4));
             }
         }
         // Redirect if needed
         if ($redirect) {
             $url = $uri->toString();
             header('Location: ' . $url, true, 301);
             jexit();
         }
     }
     // Load custom files only if needed for language or subdomains
     if ($sefConfig->langPlacementJoomla == _COM_SEF_LANG_DOMAIN || count($subdomains) > 0) {
         JLoader::register("JRoute", JPATH_SITE . '/components/com_sef/helpers/methods.php', true);
         JLoader::register("JText", JPATH_SITE . '/components/com_sef/helpers/methods.php', true);
     }
     return true;
 }
예제 #19
0
 function _getPackageFromServer($extension)
 {
     // Make sure that zlib is loaded so that the package can be unpacked
     if (!extension_loaded('zlib')) {
         JError::raiseWarning(100, JText::_('WARNINSTALLZLIB'));
         return false;
     }
     // build the appropriate paths
     $sefConfig =& SEFConfig::getConfig();
     $config =& JFactory::getConfig();
     if (empty($extension)) {
         $tmp_dest = $config->getValue('config.tmp_path') . DS . 'joomsef.zip';
     } else {
         $tmp_dest = $config->getValue('config.tmp_path') . DS . $extension . '.zip';
     }
     // Validate the upgrade on server
     $data = array();
     $data['username'] = $sefConfig->artioUserName;
     $data['password'] = $sefConfig->artioPassword;
     if (empty($extension)) {
         $data['download_id'] = $sefConfig->artioDownloadId;
         $data['file'] = 'com_joomsef';
     } else {
         $params =& SEFTools::getExtParams($extension);
         $data['download_id'] = $params->get('downloadId', '');
         $data['file'] = 'ext_joomsef3_' . substr($extension, 4);
     }
     $uri = parse_url(JURI::root());
     $url = $uri['host'] . $uri['path'];
     $url = trim($url, '/');
     $data['site'] = $url;
     $data['ip'] = $_SERVER['SERVER_ADDR'];
     $lang =& JFactory::getLanguage();
     $data['lang'] = $lang->getTag();
     $data['cat'] = 'joomsef3';
     // Get the server response
     $response = SEFTools::PostRequest($sefConfig->serverAutoUpgrade, JURI::root(), $data);
     // Check the response
     if ($response === false || $response->code != 200) {
         JError::raiseWarning(100, JText::_('Connection to server could not be established.'));
         return false;
     }
     // Response OK, check what we got
     if (strpos($response->header, 'Content-Type: application/zip') === false) {
         JError::raiseWarning(100, $response->content);
         return false;
     }
     // Seems we got the ZIP installation package, let's save it to disk
     if (!JFile::write($tmp_dest, $response->content)) {
         JError::raiseWarning(100, JText::_('Unable to save installation file in temp directory.'));
         return false;
     }
     // Unpack the downloaded package file
     $package = JInstallerHelper::unpack($tmp_dest);
     // Delete the package file
     JFile::delete($tmp_dest);
     return $package;
 }
예제 #20
0
파일: sef_ext.php 프로젝트: sangkasi/joomla
 function create($string, &$vars, &$shAppendString, $shLanguage, $shSaveString = '', &$originalUri)
 {
     $sefConfig =& shRouter::shGetConfig();
     // get DB
     $database =& JFactory::getDBO();
     _log('Calling sef404 create function with ' . $string);
     if ($sefConfig->shInsertGlobalItemidIfNone && !empty($GLOBALS['Itemid'])) {
         // V 1.2.4.t
         $shCurrentItemid = $GLOBALS['Itemid'];
     } else {
         $shCurrentItemid = null;
     }
     _log('CurrentItemid = ' . $shCurrentItemid);
     $index = str_replace($GLOBALS['shConfigLiveSite'], '', $_SERVER['PHP_SELF']);
     $base = dirname($index);
     $base .= $base == '/' ? '' : '/';
     _log('Extracting $vars:', $vars);
     extract($vars);
     if (isset($title)) {
         // V 1.2.4.r : protect against components using 'title' as GET vars (com_jim for instance)
         $sh404SEF_title = $title;
     }
     // means that $sh404SEF_title has to be used in plugins or extensions
     $title = array();
     // V 1.2.4.r
     // get extension plugin
     $extPlugin =& Sh404sefFactory::getExtensionPlugin($option);
     // which plugin file are we supposed to use?
     $extPluginPath = $extPlugin->getSefPluginPath($vars);
     $pluginType = $extPlugin->getPluginType();
     // use Joomla router.php file in extension dir
     switch ($pluginType) {
         case Sh404sefClassBaseextplugin::TYPE_JOOMLA_ROUTER:
             // Load the plug-in file.
             _log('Loading component own router.php file');
             $functionName = ucfirst(str_replace('com_', '', $option)) . 'BuildRoute';
             if (!function_exists($functionName)) {
                 include JPATH_ROOT . DS . 'components' . DS . $option . DS . 'router.php';
             }
             $originalVars = empty($originalUri) ? $vars : $originalUri->getQuery($asArray = true);
             $title = $functionName($originalVars);
             //$title = shRemoveSlugs( $title, $removeWhat = 'removeId');
             global $mainframe;
             $router =& $mainframe->getRouter();
             $title = $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
             // wa 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 =& shRouter::shGetMenu();
                 $item = $menu->getItem($vars['Itemid']);
                 if (is_object($item) && $vars['option'] == $item->component) {
                     $title[] = $item->route;
                 }
             }
             if (empty($title)) {
                 //$title[] = 'comp';
                 $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);
             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:
             _log('Loading sh404SEF plugin in ' . $extPluginPath);
             include $extPluginPath;
             break;
         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 =& shRouter::shGetMenu();
                     $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;
         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 JParameter($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 =& shRouter::shGetMenu();
                 $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:
             _log('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;
 }
예제 #21
0
 public function beforeCreate(&$uri)
 {
     // remove the limitstart and limit variables if they point to the first page
     if (!is_null($uri->getVar('limitstart')) && $uri->getVar('limitstart') == '0') {
         $uri->delVar('limitstart');
         $uri->delVar('limit');
     }
     // Remove empty variables
     if ($uri->getVar('limitstart') == '') {
         $uri->delVar('limitstart');
     }
     if ($uri->getVar('showall') == '') {
         $uri->delVar('showall');
     }
     // Try to guess the correct Itemid if set to
     if ($this->params->get('guessId', '0') != '0') {
         if (!is_null($uri->getVar('Itemid')) && !is_null($uri->getVar('id'))) {
             $itemid = SefExtContentRouteHelper::getItemid($uri->getVar('id'));
             if (!is_null($itemid)) {
                 $uri->setVar('Itemid', $itemid);
             }
         }
     }
     // Remove the part after ':' from variables
     if (!is_null($uri->getVar('id'))) {
         SEFTools::fixVariable($uri, 'id');
     }
     if (!is_null($uri->getVar('catid'))) {
         SEFTools::fixVariable($uri, 'catid');
     }
     // TODO: We should remove this, as it generates 1 unnecessary SQL query for each article link,
     // instead the catid should just be always removed from article URL (but when updating JoomSEF,
     // we'll need to update URLs already in database to reflect such change = remove catid from them!)
     // If catid not given, try to find it
     $catid = $uri->getVar('catid');
     if (!is_null($uri->getVar('view')) && $uri->getVar('view') == 'article' && !is_null($uri->getVar('id')) && empty($catid)) {
         $id = $uri->getVar('id');
         $query = "SELECT `catid` FROM `#__content` WHERE `id` = '{$id}'";
         $this->_db->setQuery($query);
         $catid = $this->_db->loadResult();
         if (is_null($catid)) {
             JoomSefLogger::Log("Article with ID {$id} could not be found.", $this, 'com_content');
         }
         if (!empty($catid)) {
             $uri->setVar('catid', $catid);
         }
     }
     // remove empty id in categories list
     if ($uri->getVar('view') == 'categories' && !(int) $uri->getVar('id')) {
         $uri->delVar('id');
     }
     return;
 }
예제 #22
0
 protected function getCategoryInfo($id)
 {
     $field = 'title';
     if (SEFTools::UseAlias($this->params, 'category_alias')) {
         $field = 'alias';
     }
     $addId = (bool) $this->params->get('categoryid', '0');
     $catInfo = new stdClass();
     $titles = array();
     $path = array();
     $id = intval($id);
     $this->_db->setQuery("SELECT `lft`, `rgt` FROM `#__categories` WHERE `id` = '{$id}'");
     $idx = $this->_db->loadObject();
     if (!$idx) {
         return false;
     }
     $query = "SELECT `id`, `title`, `alias`, `description`, language, `metakey`, `metadesc`, `metadata`, `parent_id` FROM `#__categories` WHERE `lft` <= '{$idx->lft}' AND `rgt` >= '{$idx->rgt}' AND id!=1 ORDER BY `lft` DESC";
     if ($this->params->get('show_category', 2) != 2) {
         $query .= " LIMIT 1";
     }
     $this->_db->setQuery($query);
     $cats = $this->_db->loadObjectList('', 'stdClass', $this->config->translateItems);
     $result = null;
     $this->metatags = array();
     foreach ($cats as $cat) {
         // Get only last category metas
         if (is_null($result)) {
             $result = new stdClass();
             $this->lang = $cat->language;
             $this->metadesc = $cat->description;
             $this->metatags["metakey"] = $cat->metakey;
             $this->metatags["metadesc"] = $cat->metadesc;
             $metadata = new JRegistry($cat->metadata);
             $this->metatags["metaauthor"] = $metadata->get('author');
             $this->metatags["metarobots"] = $metadata->get('robots');
             $this->metadesc = $cat->description;
             $this->origmetadesc = $cat->metadesc;
             $this->metakeysource = $cat->description;
             $this->origmetakey = $cat->metakey;
             $this->pageTitle = $cat->title;
         }
         $name = $addId ? $id . '-' . $cat->{$field} : $cat->{$field};
         array_unshift($path, $name);
         array_unshift($titles, $cat->title);
         if (empty($this->metatags["metadesc"])) {
             $this->metatags["metadesc"] = $cat->description;
         }
         $id = $cat->parent_id;
         if ($id <= 1) {
             break;
         }
     }
     $catInfo->titles = $titles;
     $catInfo->path = $path;
     return $catInfo;
 }
예제 #23
0
 function getPageSpeed($url)
 {
     require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'classes' . DS . 'config.php';
     $url = str_replace("/administrator", "", JFactory::getURI()->base()) . $url;
     $config = SEFConfig::getConfig();
     $ndata = new stdClass();
     if (strlen($config->google_apikey) == 0) {
         return false;
     }
     $google_url = 'https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=' . urlencode($url) . '&key=' . $config->google_apikey;
     if (function_exists('curl_init')) {
         $c = curl_init($google_url);
         curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($c, CURLOPT_ENCODING, "utf-8");
         $data = curl_exec($c);
         curl_close($c);
     } else {
         // Try to use our own method
         $data = SEFTools::PostRequest($google_url, null, null, 'get');
         if ($data !== false) {
             $data = $data->content;
         }
     }
     if ($data === false) {
         // Could not connect
         return false;
     }
     $data = json_decode($data);
     $ndata = new stdClass();
     if (isset($data->error)) {
         $ndata->message = $data->error->errors[0]->message;
         return $ndata;
     }
     @($ndata->pageStats = $data->pageStats);
     @($ndata->score = $data->score);
     $reg = new JRegistry();
     $reg->loadObject($ndata);
     return $reg->toString("ini");
 }
예제 #24
0
 /**
  * Tries to find a SEF URL corresponding with given nonSEF URL
  *
  * @param string $nonsef
  * @param string $Itemid
  * @return string
  */
 function getSefUrl($nonsef, $Itemid = null)
 {
     $sefConfig =& SEFConfig::getConfig();
     // Load the cache if needed
     if (!$this->cacheLoaded) {
         $this->LoadCache();
     }
     // Check if the cache was loaded successfully
     if (!$this->cacheLoaded) {
         return false;
     }
     // Check if non-sef url doesn't contain Itemid
     $vars = array();
     parse_str(str_replace('index.php?', '', $nonsef), $vars);
     if (is_null($Itemid) && strpos($nonsef, 'Itemid=')) {
         if (isset($vars['Itemid'])) {
             $Itemid = $vars['Itemid'];
         }
         $nonsef = SEFTools::removeVariable($nonsef, 'Itemid');
     }
     // Get the ignoreSource parameter
     if (isset($vars['option'])) {
         $params = SEFTools::getExtParams($vars['option']);
         $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
     if (!is_null($Itemid) && isset($vars['option'])) {
         if (SEFTools::isItemidIgnored($vars['option'], $Itemid)) {
             $ignoreSource = 1;
         }
     }
     // Get all sef urls matching non-sef url
     if (isset($this->cache[$nonsef]) && is_array($this->cache[$nonsef]) && count($this->cache[$nonsef]) > 0) {
         // Search with Itemid if set to and Itemid set
         if (!$ignoreSource && !is_null($Itemid)) {
             $nullId = null;
             for ($i = 0, $n = count($this->cache[$nonsef]); $i < $n; $i++) {
                 $row = $this->cache[$nonsef][$i];
                 if (isset($row->Itemid) && $row->Itemid == $Itemid) {
                     return $row;
                 }
                 if (empty($row->Itemid)) {
                     $nullId = $i;
                 }
             }
             // Not found with correct itemid, try to find without itemid
             if (!is_null($nullId)) {
                 // Update Itemid in cache
                 $this->cache[$nonsef][$i]->Itemid = $Itemid;
                 $row = $this->cache[$nonsef][$i];
                 // Save the cache
                 $this->saveCache();
                 // Return found row
                 return $row;
             }
         } else {
             return $this->cache[$nonsef][0];
         }
     }
     // URL does not exist in the cache
     return false;
 }
예제 #25
0
 function create(&$uri)
 {
     // Extract variables
     $vars = $uri->getQuery(true);
     extract($vars);
     $title = array();
     $this->params = SEFTools::getExtParams('com_contact');
     $title[] = JoomSEF::_getMenuTitle(@$option, @$task, @$Itemid);
     if (isset($view)) {
         switch ($view) {
             case 'contact':
                 $title = array_merge($title, $this->getContactName($id));
                 unset($view);
                 break;
             case 'category':
                 if (isset($catid)) {
                     $title[] = $this->getCategoryTitle($catid);
                 }
                 unset($view);
                 break;
         }
     }
     if (!empty($format) && $format == 'feed') {
         if (!empty($type)) {
             $title[] = $type;
         }
     }
     $newUri = $uri;
     if (count($title) > 0) {
         // Generate meta tags
         $metatags = $this->getMetaTags();
         $priority = $this->getPriority($uri);
         $sitemap = $this->getSitemapParams($uri);
         $newUri = JoomSEF::_sefGetLocation($uri, $title, @$view, null, null, @$lang, null, null, $metatags, $priority, false, null, $sitemap);
     }
     return $newUri;
 }
예제 #26
0
 public function beforeCreate(&$uri)
 {
     // Fix IDs
     SEFTools::fixVariable($uri, 'id');
 }
예제 #27
0
 function getLists()
 {
     // make the select list for the component filter
     $comList[] = JHTML::_('select.option', '', JText::_('COM_SEF_ALL'));
     $rows = SEFTools::getInstalledComponents();
     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=\"{$this->filterSEF}\" size=\"40\" maxlength=\"255\" onkeydown=\"return handleKeyDown(event);\" title=\"" . JText::_('COM_SEF_TT_FILTER_SEF') . "\" />";
     $lists['filterReal'] = "<input class=\"hasTip\" type=\"text\" name=\"filterReal\" value=\"{$this->filterReal}\" size=\"40\" maxlength=\"255\" onkeydown=\"return handleKeyDown(event);\" title=\"" . JText::_('COM_SEF_TT_FILTER_REAL') . "\" />";
     $lists['filterSEFRE'] = JText::_('COM_SEF_USE_RE') . '&nbsp;<input type="checkbox" style="float:none" ' . (substr($this->filterSEF, 0, 4) == 'reg:' ? 'checked="checked"' : '') . ' onclick="useRE(this, document.adminForm.filterSEF);" />';
     $lists['filterRealRE'] = JText::_('COM_SEF_USE_RE') . '&nbsp;<input type="checkbox" style="float:none" ' . (substr($this->filterReal, 0, 4) == 'reg:' ? 'checked="checked"' : '') . ' onclick="useRE(this, document.adminForm.filterReal);" />';
     // Filter meta tags
     $metas[] = JHTML::_('select.option', 0, JText::_('COM_SEF_ALL'));
     $metas[] = JHTML::_('select.option', 1, JText::_('COM_SEF_EMPTY'));
     $metas[] = JHTML::_('select.option', 2, JText::_('COM_SEF_FILLED'));
     $lists['filterTitle'] = JHTML::_('select.genericlist', $metas, 'filterTitle', 'class="inputbox" onchange="document.adminForm.submit();" style="width: 120px;" size="1"', 'value', 'text', $this->filterTitle);
     $lists['filterDesc'] = JHTML::_('select.genericlist', $metas, 'filterDesc', 'class="inputbox" onchange="document.adminForm.submit();" style="width: 120px;" size="1"', 'value', 'text', $this->filterDesc);
     $lists['filterKeys'] = JHTML::_('select.genericlist', $metas, 'filterKeys', 'class="inputbox" onchange="document.adminForm.submit();" style="width: 120px;" size="1"', 'value', 'text', $this->filterKeys);
     // Language filter
     $sefConfig = SEFConfig::getConfig();
     if ($sefConfig->langEnable) {
         $langs = JLanguageHelper::getLanguages();
         $langList = array();
         $langList[] = JHTML::_('select.option', '', JText::_('COM_SEF_ALL'));
         foreach ($langs as $lng) {
             $langList[] = JHTML::_('select.option', $lng->sef, $lng->title);
         }
         $lists['filterLang'] = JHTML::_('select.genericlist', $langList, 'filterLang', 'class="inputbox" onchange="document.adminForm.submit();" size="1"', 'value', 'text', $this->filterLang);
     }
     $lists['filterReset'] = '<input type="button" class="btn" value="' . JText::_('COM_SEF_RESET') . '" onclick="resetFilters();" />';
     // Ordering
     $lists['filter_order'] = $this->filterOrder;
     $lists['filter_order_Dir'] = $this->filterOrderDir;
     return $lists;
 }
예제 #28
0
파일: import.php 프로젝트: 01J/bealtine
 function _importAceSEF(&$lines)
 {
     $fieldsMap = array('cpt' => 'cpt', 'sefurl' => 'url_sef', 'origurl' => 'url_real', 'Itemid' => 'Itemid', 'metadesc' => 'metadesc', 'metakey' => 'metakey', 'metatitle' => 'metatitle', 'metalang' => 'metalang', 'metarobots' => 'metarobots', 'metagoogle' => 'metagoogle', 'canonicallink' => 'metacanonical', 'dateadd' => 'date', 'priority' => 'ordering');
     $result = true;
     for ($i = 0, $n = count($lines); $i < $n; $i++) {
         // Trim line
         $line = trim($lines[$i]);
         // Ignore empty lines
         if (strlen($line) == 0) {
             continue;
         }
         // If the query continues at the next line.
         while (substr($line, -1) != ';' && $i + 1 < count($lines)) {
             $i++;
             $newLine = trim($lines[$i]);
             if (strlen($newLine) == 0) {
                 continue;
             }
             $line .= ' ' . $lines[$i];
         }
         if (preg_match('/^INSERT\\s+INTO\\s+`?\\w+acesef_urls`?/i', $line) > 0) {
             // Parse the line
             $pos = strpos($line, '(');
             if ($pos !== false) {
                 $line = substr($line, $pos + 1);
             }
             $line = str_replace(');', '', $line);
             // Split the line to fields and values
             list($fields, $values) = explode(') VALUES (', $line);
             $fields = explode(',', $fields);
             $values = explode("', '", $values);
             $this->_cleanFields($fields);
             $this->_cleanFields($values);
             // Create the associative array of fields and values
             $assoc = array_combine($fields, $values);
             // Modify the assoc array to match our needs
             $assoc['cpt'] = 0;
             $assoc['Itemid'] = SEFTools::extractVariable($assoc['url_real'], 'Itemid');
             // Insert line to database
             if (!SEFModelImport::_insertLine($assoc, $fieldsMap)) {
                 $result = false;
             }
         } else {
             JError::raiseWarning(100, JText::_('COM_SEF_IGNORING_LINE') . ': ' . $line);
         }
     }
     return $result;
 }
예제 #29
0
파일: joomsef.php 프로젝트: 01J/bealtine
 /**
  * Checks the found row
  *
  */
 function _checkRow(&$row, $ignoreSource, $Itemid, $url, &$metadata, $temploc, $priority, $option, $check = false, $host, $sitemapParams = null)
 {
     $realloc = null;
     $db =& JFactory::getDBO();
     $sefConfig =& SEFConfig::getConfig();
     $numberDuplicates = $sefConfig->numberDuplicates;
     if (!empty($option)) {
         $params =& SEFTools::getExtParams($option);
         $extDuplicates = $params->get('numberDuplicates', '2');
         if ($extDuplicates != '2') {
             $numberDuplicates = $extDuplicates;
         }
     }
     if ($row != false && !is_null($row)) {
         if ($ignoreSource || !$ignoreSource && (empty($Itemid) || $row->Itemid == $Itemid)) {
             // ... check that it matches original URL
             if ($row->origurl == $url) {
                 // found the matching object
                 // it probably should have been found sooner
                 // but is checked again here just for CYA purposes
                 // and to end the loop
                 $realloc = $row->sefurl;
             } else {
                 if ($sefConfig->langPlacement == _COM_SEF_LANG_DOMAIN) {
                     // check if the urls differ only by lang variable
                     if (SEFTools::removeVariable($row->origurl, 'lang') == SEFTools::removeVariable($url, 'lang')) {
                         $db->setQuery("UPDATE `#__sefurls` SET `origurl` = '" . SEFTools::removeVariable($row->origurl, 'lang') . "' WHERE `id` = '" . $row->id . "' LIMIT 1");
                         // if error occured.
                         if (!$db->query()) {
                             JError::raiseError('JoomSEF Error', JText::_('COM_SEF_ERROR_SEF_URL_UPDATE') . $db->getErrorMsg());
                         }
                         $realloc = $row->sefurl;
                     }
                 }
             }
         }
         // The found URL is not the same
         if (!$numberDuplicates) {
             // But duplicates management is turned on
             // so we can save the same SEF URL for different non-SEF URL
             if (!$check) {
                 JoomSEF::_saveNewURL($Itemid, $metadata, $priority, $temploc, $url, $host, $sitemapParams);
             }
             $realloc = $temploc;
         }
     } else {
         // first, try to search among 404s
         $query = "SELECT `id` FROM `#__sefurls` WHERE `sefurl` = '{$temploc}' AND `origurl` = ''";
         $db->setQuery($query);
         $id = $db->loadResult();
         // if 404 exists, rewrite it to the new URL
         if (!is_null($id)) {
             $sqlId = !empty($Itemid) ? ", `Itemid` = '{$Itemid}'" : '';
             $query = "UPDATE `#__sefurls` SET `origurl` = " . $db->quote(html_entity_decode(urldecode($url))) . "{$sqlId}, `priority` = '{$priority}' WHERE `id` = '{$id}' LIMIT 1";
             $db->setQuery($query);
             // if error occured
             if (!$db->query()) {
                 JError::raiseError('JoomSEF Error', JText::_('COM_SEF_ERROR_SEF_URL_UPDATE') . $db->getErrorMsg());
             }
         } else {
             if (!$check) {
                 JoomSEF::_saveNewURL($Itemid, $metadata, $priority, $temploc, $url, $host, $sitemapParams);
             }
         }
         $realloc = $temploc;
     }
     return $realloc;
 }
예제 #30
0
파일: seftools.php 프로젝트: 01J/bealtine
 /**
  * Checks, whether the given Itemid is ignored for the given component
  *
  * @param string $option
  * @param string $Itemid
  * @return bool
  */
 function isItemidIgnored($option, $Itemid)
 {
     $params =& SEFTools::getExtParams($option);
     $ignoredIds = trim($params->get('ignoreItemids', ''));
     if (empty($ignoredIds)) {
         return false;
     }
     $ids = array_map('trim', explode(',', $ignoredIds));
     if (in_array($Itemid, $ids)) {
         return true;
     }
     return false;
 }