public function onSearchInputTemplate(tubepress_api_event_EventInterface $event)
 {
     $template = $event->getSubject();
     $context = tubepress_impl_patterns_sl_ServiceLocator::getExecutionContext();
     $qss = tubepress_impl_patterns_sl_ServiceLocator::getQueryStringService();
     $hrps = tubepress_impl_patterns_sl_ServiceLocator::getHttpRequestParameterService();
     $ms = tubepress_impl_patterns_sl_ServiceLocator::getMessageService();
     $resultsUrl = $context->get(tubepress_api_const_options_names_InteractiveSearch::SEARCH_RESULTS_URL);
     $url = '';
     try {
         $url = new ehough_curly_Url($resultsUrl);
     } catch (Exception $e) {
         //this is not a real problem, as the user might simply not supply a custom URL
     }
     /* if the user didn't request a certain page, just send the search results right back here */
     if ($url == '') {
         $url = new ehough_curly_Url($qss->getFullUrl($_SERVER));
     }
     /* clean up the search terms a bit */
     $searchTerms = $hrps->getParamValue(tubepress_spi_const_http_ParamName::SEARCH_TERMS);
     $searchTerms = urldecode($searchTerms);
     //TODO: get rid of this once we move to POST?
     /*
      * 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
      */
     $params = $url->getQueryVariables();
     unset($params[tubepress_spi_const_http_ParamName::PAGE]);
     unset($params[tubepress_spi_const_http_ParamName::SEARCH_TERMS]);
     /* apply the template variables */
     $template->setVariable(tubepress_api_const_template_Variable::SEARCH_HANDLER_URL, $url->toString());
     $template->setVariable(tubepress_api_const_template_Variable::SEARCH_HIDDEN_INPUTS, $params);
     $template->setVariable(tubepress_api_const_template_Variable::SEARCH_TERMS, $searchTerms);
     $template->setVariable(tubepress_api_const_template_Variable::SEARCH_BUTTON, $ms->_('Search'));
     //>(translatable)<
 }
示例#2
0
 /**
  * @param ehough_shortstop_api_HttpRequest   $request
  * @param ehough_coauthor_api_v1_Credentials $clientCredentials
  * @param ehough_curly_Url                   $callbackUrl
  *
  * @return void
  */
 public function signForTemporaryCredentialsRequest(ehough_shortstop_api_HttpRequest $request, ehough_coauthor_api_v1_Credentials $clientCredentials, ehough_curly_Url $callbackUrl)
 {
     $oAuthParams = $this->_getBaseOAuthParams($clientCredentials);
     $oAuthParams['oauth_callback'] = $callbackUrl->toString();
     $this->_sign($request, $oAuthParams, $clientCredentials);
 }
 private function _urlToString($url)
 {
     if (!$url instanceof ehough_curly_Url) {
         $url = new ehough_curly_Url($url);
     }
     return rtrim($url->toString(), '/');
 }
 /**
  * Does the heavy lifting of generating pagination.
  *
  * @param int    $totalitems The total items in this gallery.
  * @param int    $page       The current page number.
  * @param int    $limit      How many videos per page.
  * @param int    $adjacents  How many adjacents.
  * @param string $targetpage The target page
  * @param string $pagestring The query parameter controlling the page number.
  *
  * @return string The HTML for the pagination
  */
 private function _diggStyle($totalitems, tubepress_spi_message_MessageService $messageService, $page = 1, $limit = 15, $adjacents = 1, $targetpage = '/', $pagestring = '?page=')
 {
     $prev = $page - 1;
     $next = $page + 1;
     $lastpage = ceil($totalitems / $limit);
     $lpm1 = $lastpage - 1;
     $pagination = '';
     $url = new ehough_curly_Url($targetpage);
     if ($lastpage > 1) {
         $pagination .= '<div class="pagination">';
         if ($page > 1) {
             $url->setQueryVariable($pagestring, $prev);
             $newurl = $url->toString();
             $pagination .= $this->_buildAnchorOpener($newurl, true, $prev);
             $pagination .= "&laquo; " . $messageService->_('prev') . '</a>';
         }
         if ($lastpage < 7 + $adjacents * 2) {
             for ($counter = 1; $counter <= $lastpage; $counter++) {
                 if ($counter == $page) {
                     $pagination .= "<span class=\"current\">{$counter}</span>";
                 } else {
                     $url->setQueryVariable($pagestring, $counter);
                     $newurl = $url->toString();
                     $pagination .= $this->_buildAnchorOpener($newurl, true, $counter);
                     $pagination .= "{$counter}</a>";
                 }
             }
         } elseif ($lastpage >= 7 + $adjacents * 2) {
             if ($page < 1 + $adjacents * 3) {
                 for ($counter = 1; $counter < 4 + $adjacents * 2; $counter++) {
                     if ($counter == $page) {
                         $pagination .= "<span class=\"current\">{$counter}</span>";
                     } else {
                         $url->setQueryVariable($pagestring, $counter);
                         $newurl = $url->toString();
                         $pagination .= $this->_buildAnchorOpener($newurl, true, $counter);
                         $pagination .= "{$counter}</a>";
                     }
                 }
                 $pagination .= self::DOTS;
                 $url->setQueryVariable($pagestring, $lpm1);
                 $newurl = $url->toString();
                 $pagination .= ' ' . $this->_buildAnchorOpener($newurl, true, $lpm1);
                 $pagination .= "{$lpm1}</a>";
                 $url->setQueryVariable($pagestring, $lastpage);
                 $newurl = $url->toString();
                 $pagination .= $this->_buildAnchorOpener($newurl, true, $lastpage);
                 $pagination .= "{$lastpage}</a>";
             } elseif ($lastpage - $adjacents * 2 > $page && $page > $adjacents * 2) {
                 $url->setQueryVariable($pagestring, 1);
                 $newurl = $url->toString();
                 $pagination .= $this->_buildAnchorOpener($newurl, true, 1);
                 $pagination .= "1</a>";
                 $url->setQueryVariable($pagestring, 2);
                 $newurl = $url->toString();
                 $pagination .= $this->_buildAnchorOpener($newurl, true, 2);
                 $pagination .= "2</a>";
                 $pagination .= self::DOTS;
                 for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) {
                     if ($counter == $page) {
                         $pagination .= "<span class=\"current\">{$counter}</span>";
                     } else {
                         $url->setQueryVariable($pagestring, $counter);
                         $newurl = $url->toString();
                         $pagination .= ' ' . $this->_buildAnchorOpener($newurl, true, $counter);
                         $pagination .= "{$counter}</a>";
                     }
                 }
                 $pagination .= self::DOTS;
                 $url->setQueryVariable($pagestring, $lpm1);
                 $newurl = $url->toString();
                 $pagination .= ' ' . $this->_buildAnchorOpener($newurl, true, $lpm1);
                 $pagination .= "{$lpm1}</a>";
                 $url->setQueryVariable($pagestring, $lastpage);
                 $newurl = $url->toString();
                 $pagination .= ' ' . $this->_buildAnchorOpener($newurl, true, $lastpage);
                 $pagination .= "{$lastpage}</a>";
             } else {
                 $url->setQueryVariable($pagestring, 1);
                 $newurl = $url->toString();
                 $pagination .= $this->_buildAnchorOpener($newurl, true, 1);
                 $pagination .= "1</a>";
                 $url->setQueryVariable($pagestring, 2);
                 $newurl = $url->toString();
                 $pagination .= $this->_buildAnchorOpener($newurl, true, 1);
                 $pagination .= "2</a>";
                 $pagination .= self::DOTS;
                 for ($counter = $lastpage - (1 + $adjacents * 3); $counter <= $lastpage; $counter++) {
                     if ($counter == $page) {
                         $pagination .= "<span class=\"current\">{$counter}</span>";
                     } else {
                         $url->setQueryVariable($pagestring, $counter);
                         $newurl = $url->toString();
                         $pagination .= ' ' . $this->_buildAnchorOpener($newurl, true, $counter);
                         $pagination .= "{$counter}</a>";
                     }
                 }
             }
         }
         if ($page < $counter - 1) {
             $url->setQueryVariable($pagestring, $next);
             $newurl = $url->toString();
             $pagination .= $this->_buildAnchorOpener($newurl, true, $next);
             $pagination .= $messageService->_('next') . ' &raquo;</a>';
         } else {
             $pagination .= '<span class="disabled">' . $messageService->_('next') . ' &raquo;</span>';
         }
         $pagination .= "</div>\n";
     }
     return $pagination;
 }