search.php 893 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. require_once( __DIR__ . '/inc/common.php' );
  3. // Get the video id from URL.
  4. // Such as "C0DPdy98e4c"
  5. $search_query = @$_GET['q'];
  6. $page = ( isset( $_GET['page'] ) && is_numeric( $_GET['page'] ) ) ? intval( $_GET['page'] ) : 1;
  7. $templates = new League\Plates\Engine( 'themes/' . $config['theme'] );
  8. if ( ! empty( $search_query ) ) {
  9. $search = new \Vioscope\Search();
  10. echo $templates->render( 'search', array(
  11. 'entries' => $search->run_search( $search_query, $page ),
  12. // TODO: implement next/prev page
  13. 'config' => $config,
  14. 'info' => array(
  15. 'title' => 'Search for ' . $search_query,
  16. 'search_query' => $search_query,
  17. 'page' => $page,
  18. 'next_page_url' => $search->get_change_page_url(true),
  19. 'previous_page_url' => $search->get_change_page_url(false),
  20. ),
  21. ) );
  22. } else {
  23. echo $templates->render( 'search', array(
  24. 'error' => 'No valid channel id provided'
  25. ) );
  26. }