示例#1
0
文件: index.php 项目: punktDe/solr
 /**
  * Builds the drop down menu to select the solr instance we want to
  * administer.
  *
  * @return	void
  */
 public function menuConfig()
 {
     $registry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('t3lib_Registry');
     $sites = Tx_Solr_Site::getAvailableSites();
     // TODO add a menu entry on top to manage all indexes, otherwise when selecting a specific index actions will only affect that specific one
     foreach ($sites as $key => $site) {
         $this->MOD_MENU['function'][$site->getRootPageId()] = $site->getLabel();
     }
     parent::menuConfig();
 }
 /**
  * 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	tx_scheduler_module1	$parentObject: 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, tx_scheduler_Module $schedulerModule)
 {
     $result = FALSE;
     // validate site
     $sites = Tx_Solr_Site::getAvailableSites();
     if (array_key_exists($submittedData['site'], $sites)) {
         $result = TRUE;
     }
     // escape limit
     $submittedData['documentsToIndexLimit'] = intval($submittedData['documentsToIndexLimit']);
     return $result;
 }
 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 = \Tx_Solr_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>';
 }
示例#4
0
 /**
  * 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 = \Tx_Solr_Site::getSiteByPageId($siteRootPageId);
         } else {
             if ($site instanceof \Tx_Solr_Site) {
                 $this->site = $site;
             }
         }
     } catch (NoSuchArgumentException $nsae) {
         $sites = \Tx_Solr_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);
 }
 /**
  * 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 = Tx_Solr_Site::getAvailableSites();
     if (array_key_exists($submittedData['site'], $sites)) {
         $result = TRUE;
     }
     return $result;
 }
示例#6
0
 /**
  * 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 = Tx_Solr_Site::getAvailableSites();
         $domains = array();
         foreach ($sites as $site) {
             $domains[] = $site->getDomain();
         }
         $allowedSites = implode(',', $domains);
     } else {
         $allowedSites = str_replace(array('__solr_current_site', '__current_site'), Tx_Solr_Site::getSiteByPageId($pageId)->getDomain(), $allowedSitesConfiguration);
     }
     return $allowedSites;
 }