/** * Checks any additional data that is relevant to this task. If the task * class is not relevant, the method is expected to return TRUE * * @param array $submittedData reference to the array containing the data submitted by the user * @param SchedulerModuleController $schedulerModule reference to the calling object (Scheduler's BE module) * @return boolean True if validation was ok (or selected class is not relevant), FALSE otherwise */ public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $schedulerModule) { $result = false; // validate site $sites = Site::getAvailableSites(); if (array_key_exists($submittedData['site'], $sites)) { $result = true; } // escape limit $submittedData['documentsToIndexLimit'] = intval($submittedData['documentsToIndexLimit']); return $result; }
/** * @return mixed */ public function render() { $availableSites = Site::getAvailableSites(); $currentSite = $this->moduleDataStorageService->loadModuleData()->getSite(); $hasSites = is_array($availableSites) && count($availableSites) > 0; $this->templateVariableContainer->add('availableSites', $availableSites); $this->templateVariableContainer->add('currentSite', $currentSite); $this->templateVariableContainer->add('hasSites', $hasSites); $output = $this->renderChildren(); $this->templateVariableContainer->remove('hasSites'); $this->templateVariableContainer->remove('currentSite'); $this->templateVariableContainer->remove('availableSites'); return $output; }
public function render() { $this->tag->addAttribute('onchange', 'jumpToUrl(document.URL + \'&tx_solr_tools_solradministration[action]=setSite&tx_solr_tools_solradministration[site]=\'+this.options[this.selectedIndex].value,this);'); $sites = Site::getAvailableSites(); $currentSite = $this->moduleDataStorageService->loadModuleData()->getSite(); $options = ''; foreach ($sites as $site) { $selectedAttribute = ''; if ($site == $currentSite) { $selectedAttribute = ' selected="selected"'; } $options .= '<option value="' . $site->getRootPageId() . '"' . $selectedAttribute . '>' . $site->getLabel() . '</option>'; } $this->tag->setContent($options); return '<div class="docheader-funcmenu siteSelector"><label>Site: </label>' . $this->tag->render() . '</div>'; }
/** * Resolves magic keywords in allowed sites configuration. * Supported keywords: * __solr_current_site - The domain of the site the query has been started from * __current_site - Same as __solr_current_site * __all - Adds all domains as allowed sites * * - Same as __all * * @param integer $pageId A page ID that is then resolved to the site it belongs to * @param string $allowedSitesConfiguration TypoScript setting for allowed sites * @return string List of allowed sites/domains, magic keywords resolved */ public static function resolveSiteHashAllowedSites($pageId, $allowedSitesConfiguration) { if ($allowedSitesConfiguration == '*' || $allowedSitesConfiguration == '__all') { $sites = Site::getAvailableSites(); $domains = array(); foreach ($sites as $site) { $domains[] = $site->getDomain(); } $allowedSites = implode(',', $domains); } else { $allowedSites = str_replace(array('__solr_current_site', '__current_site'), Site::getSiteByPageId($pageId)->getDomain(), $allowedSitesConfiguration); } return $allowedSites; }
/** * Checks any additional data that is relevant to this task. If the task * class is not relevant, the method is expected to return TRUE * * @param array $submittedData reference to the array containing the data submitted by the user * @param SchedulerModuleController $schedulerModule reference to the calling object (Scheduler's BE module) * @return bool True if validation was ok (or selected class is not relevant), FALSE otherwise */ public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $schedulerModule) { $result = false; // validate site $sites = Site::getAvailableSites(); if (array_key_exists($submittedData['site'], $sites)) { $result = true; } return $result; }
/** * Initializes resources commonly needed for several actions * * @return void */ protected function initializeAction() { try { $site = $this->request->getArgument('site'); if (is_numeric($site)) { $siteRootPageId = $this->request->getArgument('site'); $this->site = Site::getSiteByPageId($siteRootPageId); } else { if ($site instanceof Site) { $this->site = $site; } } } catch (NoSuchArgumentException $nsae) { $sites = Site::getAvailableSites(); $site = array_shift($sites); $this->site = $site; } $this->request->setArgument('site', $this->site); $moduleData = $this->moduleDataStorageService->loadModuleData(); $moduleData->setSite($this->site); $this->moduleDataStorageService->persistModuleData($moduleData); }
/** * @test */ public function canGetAllSites() { $this->importDataSetFromFixture('can_get_all_sites.xml'); $sites = Site::getAvailableSites(); $this->assertSame(1, count($sites), 'Expected to retrieve one site from fixture'); }