/** * Shows search form * * Shows advanced search page * * @author Tony Bibbs <tony AT geeklog DOT net> * @access public * @return string HTML output for form * */ function showForm() { global $_CONF, $_TABLES, $_PLUGINS, $LANG09; $retval = ''; // Verify current user my use the search form if (!$this->_isFormAllowed()) { return $this->_getAccessDeniedMessage(); } $searchform = new Template($_CONF['path_layout'] . 'search'); $searchform->set_file(array('searchform' => 'searchform.thtml', 'authors' => 'searchauthors.thtml')); $searchform->set_var('search_intro', $LANG09[19]); $searchform->set_var('site_url', $_CONF['site_url']); $searchform->set_var('site_admin_url', $_CONF['site_admin_url']); $searchform->set_var('layout_url', $_CONF['layout_url']); $searchform->set_var('lang_keywords', $LANG09[2]); $searchform->set_var('lang_date', $LANG09[20]); $searchform->set_var('lang_to', $LANG09[21]); $searchform->set_var('date_format', $LANG09[22]); $searchform->set_var('lang_topic', $LANG09[3]); $searchform->set_var('lang_all', $LANG09[4]); $searchform->set_var('topic_option_list', COM_topicList('tid,topic', $this->_topic)); $searchform->set_var('lang_type', $LANG09[5]); $searchform->set_var('lang_results', $LANG09[59]); $searchform->set_var('lang_per_page', $LANG09[60]); $searchform->set_var('lang_exact_phrase', $LANG09[43]); $searchform->set_var('lang_all_words', $LANG09[44]); $searchform->set_var('lang_any_word', $LANG09[45]); $searchform->set_var('query', htmlspecialchars($this->_query)); $searchform->set_var('datestart', $this->_dateStart); $searchform->set_var('dateend', $this->_dateEnd); $phrase_selected = ''; $all_selected = ''; $any_selected = ''; if ($this->_keyType == 'phrase') { $phrase_selected = 'selected="selected"'; } else { if ($this->_keyType == 'all') { $all_selected = 'selected="selected"'; } else { if ($this->_keyType == 'any') { $any_selected = 'selected="selected"'; } } } $searchform->set_var('key_phrase_selected', $phrase_selected); $searchform->set_var('key_all_selected', $all_selected); $searchform->set_var('key_any_selected', $any_selected); $options = ''; $plugintypes = array('all' => $LANG09[4], 'stories' => $LANG09[6], 'comments' => $LANG09[7]); $plugintypes = array_merge($plugintypes, PLG_getSearchTypes()); foreach ($plugintypes as $key => $val) { $options .= "<option value=\"{$key}\""; if ($this->_type == $key) { $options .= ' selected="selected"'; } $options .= ">{$val}</option>" . LB; } $plugin_types_option = $options; $searchform->set_var('plugin_types', $options); if ($_CONF['contributedbyline'] == 1) { $searchform->set_var('lang_authors', $LANG09[8]); $searchusers = array(); $result = DB_query("SELECT DISTINCT uid FROM {$_TABLES['comments']}"); while ($A = DB_fetchArray($result)) { $searchusers[$A['uid']] = $A['uid']; } $result = DB_query("SELECT DISTINCT uid FROM {$_TABLES['stories']} WHERE (date <= NOW()) AND (draft_flag = 0)"); while ($A = DB_fetchArray($result)) { $searchusers[$A['uid']] = $A['uid']; } if (in_array('forum', $_PLUGINS)) { $result = DB_query("SELECT DISTINCT uid FROM {$_TABLES['ff_topic']}"); while ($A = DB_fetchArray($result)) { $searchusers[$A['uid']] = $A['uid']; } } $inlist = implode(',', $searchusers); if (!empty($inlist)) { $sql = "SELECT uid,username,fullname FROM {$_TABLES['users']} WHERE uid IN ({$inlist})"; if (isset($_CONF['show_fullname']) && $_CONF['show_fullname'] == 1) { /* Caveat: This will group all users with an emtpy fullname * together, so it's not exactly sorted by their * full name ... */ $sql .= ' ORDER BY fullname,username'; } else { $sql .= ' ORDER BY username'; } $result = DB_query($sql); $options = ''; $options .= '<option value="all">' . $LANG09[4] . '</option>' . LB; while ($A = DB_fetchArray($result)) { $options .= '<option value="' . $A['uid'] . '"'; if ($A['uid'] == $this->_author) { $options .= ' selected="selected"'; } $options .= '>' . htmlspecialchars(COM_getDisplayName($A['uid'], $A['username'], $A['fullname'])) . '</option>'; } $searchform->set_var('author_option_list', $options); $searchform->parse('author_form_element', 'authors', true); } else { $searchform->set_var('author_form_element', '<input type="hidden" name="author" value="0"' . XHTML . '>'); } } else { $searchform->set_var('author_form_element', '<input type="hidden" name="author" value="0"' . XHTML . '>'); } $searchTimeOptions = array('0' => $LANG09[4], '1' => $LANG09[75], '7' => $LANG09[76], '14' => $LANG09[77], '30' => $LANG09[78], '90' => $LANG09[79], '180' => $LANG09[80], '365' => $LANG09[81]); // search time frame $options = ''; foreach ($searchTimeOptions as $days => $prompt) { $options .= '<option value="' . $days . '"'; if ($this->_searchDays == $days) { $options .= ' selected="selected"'; } $options .= '>' . $prompt . '</option>' . LB; } $date_option = $options; $searchform->set_var('search_time', $options); // Results per page $options = ''; $limits = explode(',', $_CONF['search_limits']); foreach ($limits as $limit) { $options .= "<option value=\"{$limit}\""; if ($this->_results == $limit) { $options .= ' selected="selected"'; } $options .= ">{$limit}</option>" . LB; } $search_limit_option = $options; $searchform->set_var('search_limits', $options); $searchform->set_var('lang_search', $LANG09[10]); $searchform->parse('output', 'searchform'); $retval .= $searchform->finish($searchform->get_var('output')); return $retval; }
/** * Shows search form * * Shows advanced search page * * @author Tony Bibbs, tony AT geeklog DOT net * @return string HTML output for form * */ public function showForm() { global $_CONF, $_TABLES, $LANG09; $retval = ''; // Verify current user my use the search form if (!$this->_isFormAllowed()) { return SEC_loginRequiredForm(); } $retval .= COM_startBlock($LANG09[1], 'advancedsearch.html'); $searchform = COM_newTemplate($_CONF['path_layout'] . 'search'); $searchform->set_file(array('searchform' => 'searchform.thtml', 'authors' => 'searchauthors.thtml')); $searchform->set_var('search_intro', $LANG09[19]); $searchform->set_var('lang_keywords', $LANG09[2]); $searchform->set_var('lang_keytype', $LANG09[36]); $searchform->set_var('lang_date', $LANG09[20]); $searchform->set_var('lang_to', $LANG09[21]); $searchform->set_var('date_format', $LANG09[22]); $searchform->set_var('lang_topic', $LANG09[3]); $searchform->set_var('lang_all', $LANG09[4]); $searchform->set_var('topic_option_list', TOPIC_getTopicListSelect($this->_topic, 2, true)); $searchform->set_var('lang_type', $LANG09[5]); $searchform->set_var('lang_results', $LANG09[59]); $searchform->set_var('lang_per_page', $LANG09[60]); $searchform->set_var('lang_exact_phrase', $LANG09[43]); $searchform->set_var('lang_all_words', $LANG09[44]); $searchform->set_var('lang_any_word', $LANG09[45]); $searchform->set_var('lang_titles', $LANG09[69]); $escquery = htmlspecialchars($this->_query); $escquery = str_replace(array('{', '}'), array('{', '}'), $escquery); $searchform->set_var('query', $escquery); $searchform->set_var('datestart', $this->_dateStart); $searchform->set_var('dateend', $this->_dateEnd); if ($this->_titlesOnly) { $searchform->set_var('title_checked', ' checked="checked"'); } else { $searchform->set_var('title_checked', ''); } $phrase_selected = ''; $all_selected = ''; $any_selected = ''; if ($this->_keyType == 'phrase') { $phrase_selected = 'selected="selected"'; } else { if ($this->_keyType == 'all') { $all_selected = 'selected="selected"'; } else { if ($this->_keyType == 'any') { $any_selected = 'selected="selected"'; } } } $searchform->set_var('key_phrase_selected', $phrase_selected); $searchform->set_var('key_all_selected', $all_selected); $searchform->set_var('key_any_selected', $any_selected); $options = ''; $plugintypes = array('all' => $LANG09[4], 'stories' => $LANG09[6], 'comments' => $LANG09[7]); $plugintypes = array_merge($plugintypes, PLG_getSearchTypes()); // Generally I don't like to hardcode HTML but this seems easiest foreach ($plugintypes as $key => $val) { $options .= "<option value=\"{$key}\""; if ($this->_type == $key) { $options .= ' selected="selected"'; } $options .= ">{$val}</option>" . LB; } $searchform->set_var('plugin_types', $options); if ($_CONF['contributedbyline'] == 1) { $searchform->set_var('lang_authors', $LANG09[8]); $searchusers = array(); $result = DB_query("SELECT DISTINCT uid FROM {$_TABLES['comments']}"); while ($A = DB_fetchArray($result)) { $searchusers[$A['uid']] = $A['uid']; } $result = DB_query("SELECT DISTINCT uid FROM {$_TABLES['stories']} WHERE (date <= NOW()) AND (draft_flag = 0)"); while ($A = DB_fetchArray($result)) { $searchusers[$A['uid']] = $A['uid']; } $inlist = implode(',', $searchusers); if (!empty($inlist)) { $sql = "SELECT uid,username,fullname FROM {$_TABLES['users']} WHERE uid IN ({$inlist})"; if (isset($_CONF['show_fullname']) && $_CONF['show_fullname'] == 1) { /* Caveat: This will group all users with an emtpy fullname * together, so it's not exactly sorted by their * full name ... */ $sql .= ' ORDER BY fullname,username'; } else { $sql .= ' ORDER BY username'; } $result = DB_query($sql); $options = ''; while ($A = DB_fetchArray($result)) { $options .= '<option value="' . $A['uid'] . '"'; if ($A['uid'] == $this->_author) { $options .= ' selected="selected"'; } $options .= '>' . htmlspecialchars(COM_getDisplayName('', $A['username'], $A['fullname'])) . '</option>'; } $searchform->set_var('author_option_list', $options); $searchform->parse('author_form_element', 'authors', true); } else { $searchform->set_var('author_form_element', '<input type="hidden" name="author" value="0"' . XHTML . '>'); } } else { $searchform->set_var('author_form_element', '<input type="hidden" name="author" value="0"' . XHTML . '>'); } // Results per page $options = ''; $limits = explode(',', $_CONF['search_limits']); foreach ($limits as $limit) { $options .= "<option value=\"{$limit}\""; if ($_CONF['num_search_results'] == $limit) { $options .= ' selected="selected"'; } $options .= ">{$limit}</option>" . LB; } $searchform->set_var('search_limits', $options); $searchform->set_var('lang_search', $LANG09[10]); PLG_templateSetVars('search', $searchform); $searchform->parse('output', 'searchform'); $retval .= $searchform->finish($searchform->get_var('output')); $retval .= COM_endBlock(); return $retval; }