/** * Loads a list of Configurations for the specicifies parameters, returns an array of Configuration elements * * @return array */ public function load() { $routesData = $this->db->fetchAll($this->model->getFilter(), $this->model->getOrder()); $routes = array(); foreach ($routesData as $routeData) { $routes[] = Model\Configuration::getById($routeData['id']); } $this->model->setConfigurations($routes); return $routes; }
public function createDirectories() { //create folder for search in website if (!is_dir(PIMCORE_WEBSITE_PATH . '/var/search')) { mkdir(PIMCORE_WEBSITE_PATH . '/var/search', 0755, TRUE); } $index = PIMCORE_DOCUMENT_ROOT . '/' . Configuration::get('frontend.index'); if (!empty($index) && !is_dir($index)) { mkdir($index, 0755, TRUE); chmod($index, 0755); } return TRUE; }
/** * Get all allowed hosts. */ private function getValidHosts() { $urls = Configuration::get('frontend.urls'); if (empty($urls)) { return array(); } $hosts = array(); foreach ($urls as $url) { $parsedUrl = parse_url($url); $hosts[] = $parsedUrl['host']; } return $hosts; }
public function setSettingAction() { $values = \Zend_Json::decode($this->_getParam('data')); //general settings Configuration::set('frontend.enabled', FALSE); if (!Configuration::get('frontend.enabled') && $values['search.frontend.enabled']) { Configuration::set('frontend.enabled', TRUE); } Configuration::set('frontend.ignoreLanguage', FALSE); if ($values['frontend.ignoreLanguage']) { Configuration::set('frontend.ignoreLanguage', TRUE); } Configuration::set('frontend.ignoreCountry', FALSE); if ($values['frontend.ignoreCountry']) { Configuration::set('frontend.ignoreCountry', TRUE); } Configuration::set('frontend.ignoreRestriction', FALSE); Configuration::set('frontend.auth.useAuth', FALSE); Configuration::set('frontend.auth.username', ''); Configuration::set('frontend.auth.password', ''); Configuration::set('frontend.restriction.class', ''); Configuration::set('frontend.restriction.method', ''); if ($values['frontend.ignoreRestriction']) { Configuration::set('frontend.ignoreRestriction', TRUE); } else { if ($values['frontend.auth.useAuth']) { Configuration::set('frontend.auth.useAuth', TRUE); Configuration::set('frontend.auth.username', $values['frontend.auth.username']); Configuration::set('frontend.auth.password', $values['frontend.auth.password']); } Configuration::set('frontend.restriction.class', $values['frontend.restriction.class']); Configuration::set('frontend.restriction.method', $values['frontend.restriction.method']); } Configuration::set('frontend.fuzzySearch', FALSE); if ($values['frontend.fuzzySearch']) { Configuration::set('frontend.fuzzySearch', TRUE); } Configuration::set('frontend.ownHostOnly', FALSE); if ($values['frontend.ownHostOnly']) { Configuration::set('frontend.ownHostOnly', TRUE); } Configuration::set('frontend.sitemap.render', FALSE); if ($values['frontend.sitemap.render']) { Configuration::set('frontend.sitemap.render', TRUE); } if (is_numeric($values['frontend.crawler.maxLinkDepth'])) { Configuration::set('frontend.crawler.maxLinkDepth', (int) $values['frontend.crawler.maxLinkDepth']); } else { Configuration::set('frontend.crawler.maxLinkDepth', 15); } if (is_numeric($values['frontend.crawler.maxDownloadLimit'])) { Configuration::set('frontend.crawler.maxDownloadLimit', (int) $values['frontend.crawler.maxDownloadLimit']); } else { Configuration::set('frontend.crawler.maxDownloadLimit', 0); } //Frontend Urls must end with an trailing slash $_frontendUrls = $values['frontend.urls']; $frontendUrls = array(); if (is_array($_frontendUrls)) { foreach ($_frontendUrls as $seedUrl) { $frontendUrls[] = rtrim($seedUrl, '/') . '/'; } } Configuration::set('frontend.urls', $frontendUrls); Configuration::set('frontend.allowedSchemes', $values['frontend.allowedSchemes']); Configuration::set('frontend.categories', $values['frontend.categories']); Configuration::set('frontend.validLinkRegexes', $values['frontend.validLinkRegexes']); Configuration::set('frontend.invalidLinkRegexesEditable', $values['frontend.invalidLinkRegexesEditable']); Configuration::set('frontend.crawler.contentStartIndicator', $values['frontend.crawler.contentStartIndicator']); Configuration::set('frontend.crawler.contentEndIndicator', $values['frontend.crawler.contentEndIndicator']); Configuration::set('frontend.crawler.contentExcludeStartIndicator', $values['frontend.crawler.contentExcludeStartIndicator']); Configuration::set('frontend.crawler.contentExcludeEndIndicator', $values['frontend.crawler.contentExcludeEndIndicator']); if (is_numeric($values['frontend.view.maxPerPage'])) { Configuration::set('frontend.view.maxPerPage', (int) $values['frontend.view.maxPerPage']); } else { Configuration::set('frontend.view.maxPerPage', 10); } if (is_numeric($values['frontend.view.maxSuggestions'])) { Configuration::set('frontend.view.maxSuggestions', (int) $values['frontend.view.maxSuggestions']); } else { Configuration::set('frontend.view.maxSuggestions', 10); } $this->_helper->json(array('success' => TRUE)); }
public static function generateSitemap() { if (Configuration::get('frontend.sitemap.render') === FALSE) { return FALSE; } $builder = new SitemapBuilder(); $builder->generateSitemap(); return TRUE; }
/** * Hook called when maintenance script is called */ public function maintenanceJob() { if (self::isInstalled()) { $currentHour = date('H', time()); //Frontend recrawl $running = self::frontendCrawlerRunning(); $enabled = Configuration::get('frontend.enabled'); $lastStarted = Configuration::getCoreSetting('started'); $lastFinished = Configuration::getCoreSetting('finished'); $forceStart = Configuration::getCoreSetting('forceStart'); $aDayAgo = time() - 24 * 60 * 60; /** * + If Crawler is enabled * + If Crawler is not running * + If last start of Crawler is initial or a day ago * + If it's between 1 + 3 o clock in the night * + OR if its force * => RUN */ if ($enabled && !$running && ((is_bool($lastStarted) || $lastStarted <= $aDayAgo) && $currentHour > 1 && $currentHour < 3 || $forceStart)) { \Pimcore\Logger::debug('starting frontend recrawl...'); $this->frontendCrawl(); /** * + If Crawler is Running * + If last stop of crawler is before last start * + If last start is older than one day * => We have some errors: EXIT CRAWLING! */ } else { if ($running && $lastFinished < $lastStarted && $lastStarted <= $aDayAgo) { \Pimcore\Logger::error('LuceneSearch: There seems to be a problem with the search crawler! Trying to stop it.'); $this->stopFrontendCrawler(); } } } else { \Pimcore\Logger::debug('LuceneSearch: Plugin is not installed - no maintenance to do for this plugin.'); } }
private function addRestrictionQuery($query) { if ($this->searchRestriction) { $restrictionTerms = array(new \Zend_Search_Lucene_Index_Term(TRUE, 'restrictionGroup_default')); $signs = array(NULL); $class = Configuration::get('frontend.restriction.class'); $method = Configuration::get('frontend.restriction.method'); $call = array($class, $method); if (is_callable($call, FALSE)) { $allowedGroups = call_user_func($call); if (is_array($allowedGroups)) { foreach ($allowedGroups as $group) { $restrictionTerms[] = new \Zend_Search_Lucene_Index_Term(TRUE, 'restrictionGroup_' . $group); $signs[] = NULL; } } $restrictionQuery = new \Zend_Search_Lucene_Search_Query_MultiTerm($restrictionTerms, $signs); $query->addSubquery($restrictionQuery, TRUE); } else { throw new \Exception('Method "' . $method . '" in "' . $class . '" not callable'); } } return $query; }