Esempio n. 1
0
 /**
  * This method executes the requested commands and applies the changes to
  * the template.
  *
  * @param $actionResult
  * @throws \UnexpectedValueException
  * @return string Rendered plugin content
  */
 protected function render($actionResult)
 {
     $allCommands = CommandResolver::getAllPluginCommandsList();
     $commandList = $this->getCommandList();
     // render commands matching the plugin's requirements
     foreach ($commandList as $commandName) {
         $GLOBALS['TT']->push('solr-' . $commandName);
         $commandContent = '';
         $commandVariables = $this->executeCommand($commandName);
         if (!is_null($commandVariables)) {
             $commandContent = $this->renderCommand($commandName, $commandVariables);
         }
         $this->template->addSubpart('solr_search_' . $commandName, $commandContent);
         unset($subpartTemplate);
         $GLOBALS['TT']->pull($commandContent);
     }
     // remove subparts for commands that are registered but not matching the requirements
     $nonMatchingCommands = array_diff($allCommands, $commandList);
     foreach ($nonMatchingCommands as $nonMatchingCommand) {
         $this->template->addSubpart('solr_search_' . $nonMatchingCommand, '');
     }
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr'][$this->getPluginKey()]['renderTemplate'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr'][$this->getPluginKey()]['renderTemplate'] as $classReference) {
             $templateModifier =& GeneralUtility::getUserObj($classReference);
             if ($templateModifier instanceof TemplateModifier) {
                 $templateModifier->modifyTemplate($this->template);
             } else {
                 throw new \UnexpectedValueException(get_class($templateModifier) . ' must implement interface ApacheSolrForTypo3\\Solr\\TemplateModifier', 1310387230);
             }
         }
     }
     $this->javascriptManager->addJavascriptToPage();
     return $this->template->render(Template::CLEAN_TEMPLATE_YES);
 }
Esempio n. 2
0
 /**
  * Retrieves the list of commands we have to process for the results view
  *
  * @return array Array of command names to process for the result view
  */
 protected function getCommandList()
 {
     $commandList = CommandResolver::getPluginCommands('search');
     return $commandList;
 }
Esempio n. 3
0
 /**
  * Retrieves the list of commands to process for the results view.
  *
  * @return array An array of command names to process for the result view
  */
 protected function getCommandList()
 {
     $requirements = PluginCommand::REQUIREMENT_NONE;
     $commandList = array();
     if ($this->search->hasSearched()) {
         $requirements = PluginCommand::REQUIREMENT_HAS_SEARCHED;
         if ($this->search->getNumberOfResults() > 0) {
             $requirements += PluginCommand::REQUIREMENT_HAS_RESULTS;
         } else {
             $requirements += PluginCommand::REQUIREMENT_NO_RESULTS;
         }
     }
     $commandList = CommandResolver::getPluginCommands('results', $requirements);
     return $commandList;
 }