public function alter_searchInputTemplate(org_tubepress_api_template_Template $template)
 {
     $ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
     $context = $ioc->get('org_tubepress_api_exec_ExecutionContext');
     $qss = $ioc->get('org_tubepress_api_querystring_QueryStringService');
     $ms = $ioc->get('org_tubepress_api_message_MessageService');
     $resultsUrl = $context->get(org_tubepress_api_const_options_names_Output::SEARCH_RESULTS_URL);
     /* if the user didn't request a certain page, just send the search results right back here */
     if ($resultsUrl == '') {
         $resultsUrl = $qss->getFullUrl($_SERVER);
     }
     /* clean up the search terms a bit */
     $searchTerms = urldecode($qss->getSearchTerms($_GET));
     $searchTerms = org_tubepress_impl_util_StringUtils::cleanForSearch($searchTerms);
     /* 
      * read http://stackoverflow.com/questions/1116019/submitting-a-get-form-with-query-string-params-and-hidden-params-disappear
      * if you're curious as to what's going on here
      */
     $url = new org_tubepress_api_url_Url($resultsUrl);
     $params = $url->getQueryVariables();
     unset($params[org_tubepress_api_const_querystring_QueryParamName::PAGE]);
     unset($params[org_tubepress_api_const_querystring_QueryParamName::SEARCH_TERMS]);
     /* apply the template variables */
     $template->setVariable(org_tubepress_api_const_template_Variable::SEARCH_HANDLER_URL, $resultsUrl);
     $template->setVariable(org_tubepress_api_const_template_Variable::SEARCH_HIDDEN_INPUTS, $params);
     $template->setVariable(org_tubepress_api_const_template_Variable::SEARCH_TERMS, $searchTerms);
     $template->setVariable(org_tubepress_api_const_template_Variable::SEARCH_BUTTON, $ms->_('search-input-button'));
     return $template;
 }
 /**
  * Execute the command.
  *
  * @param array $context An array of context elements (may be empty).
  *
  * @return boolean True if this command was able to handle the execution. False otherwise.
  */
 public function execute($context)
 {
     $ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
     $execContext = $ioc->get('org_tubepress_api_exec_ExecutionContext');
     /* not configured at all for search results */
     if ($execContext->get(org_tubepress_api_const_options_names_Output::OUTPUT) !== org_tubepress_api_const_options_values_OutputValue::SEARCH_RESULTS) {
         org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Not configured for search results');
         return false;
     }
     /* do we have search terms? */
     $qss = $ioc->get('org_tubepress_api_querystring_QueryStringService');
     $rawSearchTerms = $qss->getSearchTerms($_GET);
     /* are we set up for a gallery fallback? */
     $mustShowSearchResults = $execContext->get(org_tubepress_api_const_options_names_Output::SEARCH_RESULTS_ONLY);
     $hasSearchTerms = $rawSearchTerms != '';
     /* the user is not searching and we don't have to show results */
     if (!$hasSearchTerms && !$mustShowSearchResults) {
         org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'The user isn\'t searching.');
         return false;
     }
     /* if the user isn't searching, don't display anything */
     if (!$hasSearchTerms) {
         org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'User doesn\'t appear to be searching. Will not display anything.');
         $context->returnValue = '';
         return true;
     }
     org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'User is searching. We\'ll handle this.');
     /* clean up the search terms */
     $searchTerms = org_tubepress_impl_util_StringUtils::cleanForSearch($rawSearchTerms);
     /* who are we searching? */
     switch ($execContext->get(org_tubepress_api_const_options_names_Output::SEARCH_PROVIDER)) {
         case org_tubepress_api_provider_Provider::VIMEO:
             $execContext->set(org_tubepress_api_const_options_names_Output::MODE, org_tubepress_api_const_options_values_ModeValue::VIMEO_SEARCH);
             $execContext->set(org_tubepress_api_const_options_names_Output::VIMEO_SEARCH_VALUE, $searchTerms);
             break;
         default:
             $execContext->set(org_tubepress_api_const_options_names_Output::MODE, org_tubepress_api_const_options_values_ModeValue::TAG);
             $execContext->set(org_tubepress_api_const_options_names_Output::TAG_VALUE, $searchTerms);
             break;
     }
     /* display the results as a thumb gallery */
     return $ioc->get('org_tubepress_api_patterns_cor_Chain')->execute($context, array('org_tubepress_impl_shortcode_commands_ThumbGalleryCommand'));
 }