/** * Display search form and results (if any) * * @return void */ public function displayTask() { Plugin::import('search'); // Set breadcrumbs Pathway::append(Lang::txt('COM_SEARCH'), 'index.php?option=com_search'); $terms = new Terms(Request::getString('terms')); // Set the document title Document::setTitle($terms->is_set() ? Lang::txt('COM_SEARCH_RESULTS_FOR', $this->view->escape($terms->get_raw())) : 'Search'); // Get search results $results = new Set($terms); $results->set_limit(Request::getState('global.list.limit', 'limit', Config::get('list_limit'), 'int')); $results->set_offset(Request::getInt('limitstart', 0)); $results->collect(Request::getBool('force-generic')); $this->view->url_terms = urlencode($terms->get_raw_without_section()); @(list($plugin, $section) = $terms->get_section()); if ($plugin) { foreach ($results->get_result_counts() as $cat => $def) { if ($plugin == $cat) { $total = $def['count']; break; } } } else { $total = $results->get_total_count(); } $this->view->terms = $terms; $this->view->results = $results; $this->view->total = $total; $this->view->plugin = $plugin; $this->view->section = $section; $this->view->display(); }
/** * Short description for '__construct' * * Long description (if any) ... * * @param array $row Parameter description (if any) ... * @return void */ public function __construct($row) { if (is_null(self::$tag_weight_modifier)) { self::$tag_weight_modifier = Set::get_tag_weight_modifier(); } self::assert_keys(array('title', 'description', 'link'), $row); foreach ($row as $key => $val) { $this->{$key} = is_array($val) ? array_map('stripslashes', array_map('strip_tags', $val)) : stripslashes(strip_tags($val)); } if ($this->weight === NULL) { if ($this->tag_count) { $this->weight = $this->tag_count * (self::$tag_weight_modifier / 2); } $this->weight = 1.0; $this->weight_log[] = 'plugin did not suggest weight, guessing ' . $this->weight . ' based on tag count(' . $this->tag_count . ')'; } else { if ($this->tag_count) { $this->weight_log[] = 'plugin suggested weight of ' . $this->weight; $this->adjust_weight($this->tag_count * self::$tag_weight_modifier, 'tag count of ' . $this->tag_count); } } $this->contributors = $this->contributors ? array_unique(is_array($this->contributors) ? $this->contributors : preg_split("#\n#", $row['contributors'])) : array(); $this->contributor_ids = $this->contributor_ids ? array_unique(is_array($this->contributor_ids) ? $this->contributor_ids : preg_split("#\n#", $row['contributor_ids'])) : array(); if ($this->date && $this->date != '0000-00-00 00:00:00') { $this->date = strtotime($row['date']); } else { $this->date = null; } }