public function exhibitSearch($args, $view)
 {
     // Get exhibit ID from shortcode
     if (isset($args['exhibit'])) {
         $eid = $args['exhibit'];
     }
     // Get page IDs for the exhibit
     $db = get_db();
     $select = "\n                    SELECT id\n                    FROM omeka_exhibit_pages\n                    WHERE (exhibit_id=?)\n                    ORDER BY id\n                    ";
     $pages = $db->getTable("ExhibitPage")->fetchObjects($select, array($eid));
     $page_ids = array();
     foreach ($pages as $page) {
         array_push($page_ids, $page['id']);
     }
     $page_string = join(",", $page_ids);
     // Build the options and filters arrays used for searches.
     $options = array();
     // Set the default flag indicating whether to show the advanced form.
     if (!isset($options['show_advanced'])) {
         $options['show_advanced'] = true;
     }
     // Set the default submit value.
     if (!isset($options['submit_value'])) {
         $options['submit_value'] = __('Search');
     }
     // Set the default form attributes.
     $options['form_attributes'] = array();
     $url = apply_filters('search_form_default_action', url('search'));
     $options['form_attributes']['action'] = $url;
     $options['form_attributes']['id'] = 'search-form';
     $options['form_attributes']['method'] = 'get';
     $options['form_attributes']['style'] = 'text-align:left;width:75%';
     $this->_validQueryTypes = get_search_query_types();
     $this->_validRecordTypes = get_custom_search_record_types();
     $filters = array();
     if (isset($_GET['query'])) {
         $filters['query'] = $_GET['query'];
     } else {
         $filters['query'] = '';
     }
     if (isset($_GET['query_type']) && array_key_exists($_GET['query_type'], $this->_validQueryTypes)) {
         $filters['query_type'] = $_GET['query_type'];
     } else {
         $filters['query_type'] = 'keyword';
     }
     if (isset($_GET['record_types'])) {
         $filters['record_types'] = $_GET['record_types'];
     } else {
         $filters['record_types'] = array_keys($this->_validRecordTypes);
     }
     // Add a filter for exhibit_id
     if (isset($_GET['exhibit_id'])) {
         $filters['exhibit_id'] = $_GET['exhibit_id'];
     } else {
         $filters['exhibit_id'] = $page_ids;
     }
     $this->_filters = $filters;
     // Pass variables to a view; the view returns a search box.
     return $view->partial('search/search.php', array('options' => $options, 'filters' => $this->_filters, 'recordIDs' => $page_string, 'query_types' => array('keyword' => __('Keyword')), 'record_types' => array('ExhibitPage' => __('Exhibit Page')), 'exhibit_id' => array($eid => "Record Id: {$eid}")));
 }
예제 #2
0
 /**
  * Return a list of current search filters in use.
  * 
  * @param array $options Valid options are as follows:
  * - id (string): the ID of the filter wrapping div.
  * @return string
  */
 public function searchFilters(array $options = array())
 {
     $validQueryTypes = get_search_query_types();
     $validRecordTypes = get_custom_search_record_types();
     $query = '';
     $queryType = 'keyword';
     $recordTypes = $validRecordTypes;
     if (isset($_GET['query'])) {
         $query = $_GET['query'];
     }
     if (isset($_GET['query_type']) && array_key_exists($_GET['query_type'], $validQueryTypes)) {
         $queryType = $_GET['query_type'];
     }
     if (isset($_GET['record_types'])) {
         $recordTypes = array();
         foreach ($_GET['record_types'] as $recordType) {
             $recordTypes[] = $validRecordTypes[$recordType];
         }
     }
     // Set the default options.
     if (!isset($options['id'])) {
         $options['id'] = 'search-filters';
     }
     return $this->view->partial('search/search-filters.php', array('options' => $options, 'query' => $query, 'query_type' => $validQueryTypes[$queryType], 'record_types' => $recordTypes));
 }
예제 #3
0
 /**
  * Return the site-wide search form.
  * 
  * @param array $options Valid options are as follows:
  * - show_advanced: whether to show the advanced search; default is false.
  * - submit_value: the value of the submit button; default "Submit".
  * - form_attributes: an array containing form tag attributes.
  * @return string The search form markup.
  */
 public function searchForm(array $options = array())
 {
     $validQueryTypes = get_search_query_types();
     $validRecordTypes = get_custom_search_record_types();
     $filters = array('query' => apply_filters('search_form_default_query', ''), 'query_type' => apply_filters('search_form_default_query_type', 'keyword'), 'record_types' => apply_filters('search_form_default_record_types', array_keys($validRecordTypes)));
     if (isset($_GET['submit_search'])) {
         if (isset($_GET['query'])) {
             $filters['query'] = $_GET['query'];
         }
         if (isset($_GET['query_type'])) {
             $filters['query_type'] = $_GET['query_type'];
         }
         if (isset($_GET['record_types'])) {
             $filters['record_types'] = $_GET['record_types'];
         }
     }
     // Set the default flag indicating whether to show the advanced form.
     if (!isset($options['show_advanced'])) {
         $options['show_advanced'] = false;
     }
     // Set the default submit value.
     if (!isset($options['submit_value'])) {
         $options['submit_value'] = __('Search');
     }
     // Set the default form attributes.
     if (!isset($options['form_attributes'])) {
         $options['form_attributes'] = array();
     }
     if (!isset($options['form_attributes']['action'])) {
         $url = apply_filters('search_form_default_action', url('search'));
         $options['form_attributes']['action'] = $url;
     }
     if (!isset($options['form_attributes']['id'])) {
         $options['form_attributes']['id'] = 'search-form';
     }
     $options['form_attributes']['method'] = 'get';
     $formParams = array('options' => $options, 'filters' => $filters, 'query_types' => $validQueryTypes, 'record_types' => $validRecordTypes);
     $form = $this->view->partial('search/search-form.php', $formParams);
     return apply_filters('search_form', $form, $formParams);
 }
예제 #4
0
 /**
  * Set the values needs for children of this class.
  */
 public function __construct()
 {
     // Set the valid query and record types.
     $this->_validQueryTypes = get_search_query_types();
     $this->_validRecordTypes = get_custom_search_record_types();
     // Set default form filters if not passed with the request.
     $filters = array();
     if (isset($_GET['query'])) {
         $filters['query'] = $_GET['query'];
     } else {
         $filters['query'] = '';
     }
     if (isset($_GET['query_type']) && array_key_exists($_GET['query_type'], $this->_validQueryTypes)) {
         $filters['query_type'] = $_GET['query_type'];
     } else {
         $filters['query_type'] = 'keyword';
     }
     if (isset($_GET['record_types'])) {
         $filters['record_types'] = $_GET['record_types'];
     } else {
         $filters['record_types'] = array_keys($this->_validRecordTypes);
     }
     $this->_filters = $filters;
 }