search_box.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Modbash Clean Elgg Theme
  4. *
  5. * Copyright (c) 2015 ModBash
  6. *
  7. * @author Shane Barron <admin@modbash.com>
  8. * @copyright 2015 SocialApparatus
  9. * @license GNU General Public License (GPL) version 2
  10. * @version 1
  11. * @link http://modbash.com
  12. */
  13. if (array_key_exists('value', $vars)) {
  14. $value = $vars['value'];
  15. } elseif ($value = get_input('q', get_input('tag', NULL))) {
  16. $value = $value;
  17. } else {
  18. $value = elgg_echo('search');
  19. }
  20. $class = "elgg-search";
  21. if (isset($vars['class'])) {
  22. $class = "$class {$vars['class']}";
  23. }
  24. // @todo - why the strip slashes?
  25. $value = stripslashes($value);
  26. // @todo - create function for sanitization of strings for display in 1.8
  27. // encode <,>,&, quotes and characters above 127
  28. if (function_exists('mb_convert_encoding')) {
  29. $display_query = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8');
  30. } else {
  31. // if no mbstring extension, we just strip characters
  32. $display_query = preg_replace("/[^\x01-\x7F]/", "", $value);
  33. }
  34. $display_query = htmlspecialchars($display_query, ENT_QUOTES, 'UTF-8', false);
  35. ?>
  36. <form class="form-inline" role="search" action="<?php echo elgg_get_site_url(); ?>search" method="get" style="margin-bottom:10px;">
  37. <div class="form-group">
  38. <input type="text" class="form-control" name="q" placeholder="<?php echo elgg_echo('search'); ?>">
  39. </div>
  40. <button type="submit" class="btn btn-default"><?php echo elgg_echo('search:go'); ?></button>
  41. </form>