SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/Widgets/AdvancedSearchFormWidget.php

  1. <?php
  2. /*
  3.  * Copyright (C) 2017 Karmabunny Pty Ltd.
  4.  *
  5.  * This file is a part of SproutCMS.
  6.  *
  7.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  8.  * of the GNU General Public License as published by the Free Software Foundation, either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * For more information, visit <http://getsproutcms.com>.
  12.  */
  13.  
  14. namespace Sprout\Widgets;
  15.  
  16. use Sprout\Helpers\Constants;
  17. use Sprout\Helpers\Enc;
  18.  
  19.  
  20. /**
  21. * Shows a box for searching documents
  22. **/
  23. class AdvancedSearchFormWidget extends Widget
  24. {
  25. protected $friendly_name = "Advanced Search Form";
  26. protected $friendly_desc = 'An advanced search form for the site search';
  27.  
  28.  
  29. /**
  30.   * Return the front-end view of this widget
  31.   *
  32.   * @param int $orientation The orientation of the widget.
  33.   **/
  34. public function render($orientation)
  35. {
  36.  
  37. $out = '<form action="SITE/advanced_search" method="get">';
  38.  
  39. // Keyword
  40. $out .= '<p><b>Keyword:</b>';
  41. $out .= '<br><input type="text" name="q" value="' . Enc::html($_GET['q']) . '" class="textbox"></p>';
  42.  
  43. // Tag
  44. $out .= '<p><b>Tag:</b>';
  45. $out .= '<br><input type="text" name="tag" value="' . Enc::html($_GET['tag']) . '" class="textbox"></p>';
  46.  
  47. // Date
  48. $out .= '<p><b>Date:</b>';
  49. $out .= '<br><select name="date">';
  50. $out .= '<option value="">- Select -</option>';
  51. foreach (Constants::$relative_dates as $idx => $name) {
  52. $name = Enc::html($name);
  53. $sel = ($idx == $_GET['date'] ? ' selected' : '');
  54. $out .= "<option value=\"{$idx}\"{$sel}>{$name}</option>";
  55. }
  56. $out .= '</select></p>';
  57.  
  58. $out .= '<p><input type="submit" value="Search" class="button"></p>';
  59.  
  60. $out .= '</form>';
  61.  
  62. return $out;
  63. }
  64.  
  65. }
  66.  
  67.  
  68.