b2evolution PHP Cross Reference Blogging Systems

Source: /inc/widgets/widgets/_coll_search_form.widget.php - 168 lines - 4986 bytes - Summary - Text - Print

Description: This file implements the xyz Widget class. This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * This file implements the xyz Widget class.
   4   *
   5   * This file is part of the evoCore framework - {@link http://evocore.net/}
   6   * See also {@link http://sourceforge.net/projects/evocms/}.
   7   *
   8   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
   9   *
  10   * {@internal License choice
  11   * - If you have received this file as part of a package, please find the license.txt file in
  12   *   the same folder or the closest folder above for complete license terms.
  13   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  14   *   then you must choose one of the following licenses before using the file:
  15   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  16   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  17   * }}
  18   *
  19   * @package evocore
  20   *
  21   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  22   * @author fplanque: Francois PLANQUE.
  23   *
  24   * @version $Id: _coll_search_form.widget.php 6136 2014-03-08 07:59:48Z manuel $
  25   */
  26  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  27  
  28  load_class( 'widgets/model/_widget.class.php', 'ComponentWidget' );
  29  
  30  /**
  31   * ComponentWidget Class
  32   *
  33   * A ComponentWidget is a displayable entity that can be placed into a Container on a web page.
  34   *
  35   * @package evocore
  36   */
  37  class coll_search_form_Widget extends ComponentWidget
  38  {
  39      /**
  40       * Constructor
  41       */
  42  	function coll_search_form_Widget( $db_row = NULL )
  43      {
  44          // Call parent constructor:
  45          parent::ComponentWidget( $db_row, 'core', 'coll_search_form' );
  46      }
  47  
  48  
  49      /**
  50       * Get name of widget
  51       */
  52  	function get_name()
  53      {
  54          return T_('Search Form');
  55      }
  56  
  57  
  58      /**
  59       * Get a very short desc. Used in the widget list.
  60       */
  61  	function get_short_desc()
  62      {
  63          return format_to_output($this->disp_params['title']);
  64      }
  65  
  66  
  67    /**
  68       * Get short description
  69       */
  70  	function get_desc()
  71      {
  72          return T_('Display search form');
  73      }
  74  
  75  
  76    /**
  77     * Get definitions for editable params
  78     *
  79       * @see Plugin::GetDefaultSettings()
  80       * @param local params like 'for_editing' => true
  81       */
  82  	function get_param_definitions( $params )
  83      {
  84          $r = array_merge( array(
  85                  'title' => array(
  86                      'label' => T_('Block title'),
  87                      'note' => T_( 'Title to display in your skin.' ),
  88                      'size' => 40,
  89                      'defaultvalue' => T_('Search'),
  90                  ),
  91                  'button' => array(
  92                      'label' => T_('Button name'),
  93                      'note' => T_( 'Button name to submit a search form.' ),
  94                      'size' => 40,
  95                      'defaultvalue' => T_('Go'),
  96                  ),
  97                  'disp_search_options' => array(
  98                      'label' => T_( 'Search options' ),
  99                      'note' => T_( 'Display radio buttons for "All Words", "Some Word" and "Entire Phrase"' ),
 100                      'type' => 'checkbox',
 101                      'defaultvalue' => false,
 102                  ),
 103                  'use_search_disp' => array(
 104                      'label' => T_( 'Results on search page' ),
 105                      'note' => T_( 'Use advanced search page to display results (disp=search)' ),
 106                      'type' => 'checkbox',
 107                      'defaultvalue' => true,
 108                  ),
 109              ), parent::get_param_definitions( $params )    );
 110  
 111          return $r;
 112      }
 113  
 114  
 115      /**
 116       * Display the widget!
 117       *
 118       * @param array MUST contain at least the basic display params
 119       */
 120  	function display( $params )
 121      {
 122          global $Blog;
 123  
 124          $this->init_display( $params );
 125  
 126          // Collection search form:
 127          echo $this->disp_params['block_start'];
 128  
 129          $this->disp_title();
 130  
 131          form_formstart( $Blog->gen_blogurl(), 'search', 'SearchForm' );
 132          if( $this->disp_params[ 'disp_search_options' ] )
 133          {
 134              echo '<div class="extended_search_form">';
 135          }
 136          else
 137          {
 138              echo '<div class="compact_search_form">';
 139          }
 140  
 141          if( $this->disp_params[ 'disp_search_options' ] )
 142          {
 143              $sentence = get_param( 'sentence' );
 144              echo '<div class="search_options">';
 145              echo '<div class="search_option"><input type="radio" name="sentence" value="AND" id="sentAND" '.( $sentence=='AND' ? 'checked="checked" ' : '' ).'/><label for="sentAND">'.T_('All words').'</label></div>';
 146              echo '<div class="search_option"><input type="radio" name="sentence" value="OR" id="sentOR" '.( $sentence=='OR' ? 'checked="checked" ' : '' ).'/><label for="sentOR">'.T_('Some word').'</label></div>';
 147              echo '<div class="search_option"><input type="radio" name="sentence" value="sentence" id="sentence" '.( $sentence=='sentence' ? 'checked="checked" ' : '' ).'/><label for="sentence">'.T_('Entire phrase').'</label></div>';
 148              echo '</div>';
 149          }
 150  
 151          $s = get_param( 's' );
 152          echo '<input type="text" name="s" size="25" value="'.htmlspecialchars($s).'" class="search_field SearchField" title="'.format_to_output( T_('Enter text to search for'), 'htmlattr' ).'" />';
 153  
 154          if( $this->disp_params[ 'use_search_disp' ] )
 155          {
 156              echo '<input type="hidden" name="disp" value="search" />';
 157          }
 158          echo '<input type="submit" name="submit" class="search_submit submit" value="'.format_to_output( $this->disp_params['button'], 'htmlattr' ).'" />';
 159          echo '</div>';
 160          echo '</form>';
 161  
 162          echo $this->disp_params['block_end'];
 163  
 164          return true;
 165      }
 166  }
 167  
 168  ?>

title

Description

title

Description

title

Description

title

title

Body