function getSearchResult($gid, $itemid) { global $search_mode, $ordering, $invert_search, $reverse_order, $search_where, $search_phrase, $search_catid; $search_mode = ($invert_search ? '-' : '') . $search_mode; $searchList = array(array('search_mode' => $search_mode, 'search_phrase' => $search_phrase)); $ordering = ($reverse_order ? '-' : '') . $ordering; $rows = DOCMAN_Docs::search($searchList, $ordering, $search_catid, '', $search_where); // This acts as the search header - so they can perform search again if (count($rows) == 0) { $msg = _DML_NOKEYWORD; } else { $msg = sprintf(_DML_SEARCH . ' ' . _DML_SEARCH_MATCHES, count($rows)); } $items = array(); if (count($rows) > 0) { foreach ($rows as $row) { // onFetchDocument event, type = list $bot = new DOCMAN_mambot('onFetchDocument'); $bot->setParm('id', $row->id); $bot->copyParm('type', 'list'); $bot->trigger(); if ($bot->getError()) { _returnTo('cat_view', $bot->getErrorMsg()); } // load doc $doc =& DOCMAN_Document::getInstance($row->id); // process content mambots DOCMAN_Utils::processContentBots($doc, 'dmdescription'); $item = new StdClass(); $item->buttons =& $doc->getLinkObject(); $item->paths =& $doc->getPathObject(); $item->data =& $doc->getDataObject(); $item->data->category = $row->section; $items[] = $item; } } return $items; }
/** * Search method * @param 'text' element is the search term(s) * @param 'phrase' element is whether this is a term/phrase/word to search for * @param 'ordering' element is how to sort the results * * Returns an array that contains: * title Title of the article (ie subject) * section Section name. We use 'Forum:category/section' * text Text from matching articles * created Date created (standard format 2004-....) * browsernav '2' to open in this window * href the link to get back to here. * */ function botSearchDocman($phrase, $mode = '', $ordering = '', $areas = null) { global $_DOCMAN, $Itemid; $database = JFactory::getDBO(); if (is_array($areas)) { if (!array_intersect($areas, array_keys(plgSearchDocmanAreas()))) { return array(); } } $phrase = trim($phrase); if ($phrase == '') { return array(); } $plugin =& JPluginHelper::getPlugin('search', 'docman.searchbot'); $params = new JParameter($plugin->params); $section_prefix = $params->get('prefix', 'Downloads: '); $section_suffix = $params->get('suffix', ''); $search_name = $params->get('search_name', 0); $search_desc = $params->get('search_description', 0); $search_cat = $params->get('search_cat', 0); $option_link = $params->get('href', 'download'); if (!($search_name || $search_desc || $search_cat)) { return array(); } // INTERFACE to standard class $search_for = array(array('search_phrase' => $phrase, 'search_mode' => $mode)); // ...href... $DMItemid = DOCMAN_Utils::getItemid(); switch ($option_link) { case 'download': $href = "CONCAT('index.php?option=com_docman&task=doc_download&Itemid={$DMItemid}&gid=',DM.id )"; break; case 'details': $href = "CONCAT('index.php?option=com_docman&task=doc_details&Itemid={$DMItemid}&gid=',DM.id )"; break; case 'display': default: $href = "CONCAT('index.php?option=com_docman&task=cat_view&Itemid={$DMItemid}&gid=',DM.catid )"; break; } $columns = array("DM.dmname" => "title", "DM.dmdescription" => "text", "DM.dmlastupdateon" => "created", "'2'" => "browsernav", "{$href}" => "href", "DM.catid" => "catid"); $options = array(); if ($search_name) { $options[] = 'search_name'; } if ($search_desc) { $options[] = 'search_desc'; } if ($search_cat) { $options[] = 'search_cat'; } $options['section_prefix'] = $section_prefix; $options['section_suffix'] = $section_suffix; return DOCMAN_Docs::search($search_for, $ordering, 0, $columns, $options); }