/**
* 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);
    $hreftask = $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 ($hreftask) {
        case 'download':
            $href = "CONCAT('index.php?option=com_docman&task=doc_download&gid=', DM.id, '&Itemid={$DMItemid}' )";
            break;
        case 'details':
            $href = "CONCAT('index.php?option=com_docman&task=doc_details&gid=', DM.id, '&Itemid={$DMItemid}' )";
            break;
        case 'display':
        default:
            $href = "CONCAT('index.php?option=com_docman&task=cat_view&gid=', DM.catid, '&Itemid={$DMItemid}' )";
            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;
    $options['hreftask'] = $hreftask;
    return DOCMAN_Docs::search($search_for, $ordering, 0, $columns, $options);
}
Example #2
0
 function _rawLink($task, $gid = '', $params = null, $indexfile = 'index.php')
 {
     global $limitstart, $limit, $Itemid;
     // This translates J1.0's index2.php system to J1.5's tmpl=component&format=raw
     if (defined('_DM_J15') and $indexfile == 'index2.php') {
         $indexfile = 'index.php';
         if (!is_array($params)) {
             $params = array();
         }
         $params['tmpl'] = 'component';
         $params['format'] = 'raw';
     }
     $link = "{$indexfile}?option=com_docman";
     if (!isset($params['Itemid'])) {
         $params['Itemid'] = $Itemid ? $Itemid : DOCMAN_Utils::getItemid();
     }
     if (!empty($task)) {
         $link .= "&task={$task}";
     }
     if (!empty($gid)) {
         $link .= "&gid={$gid}";
     }
     if (is_array($params)) {
         $link .= "&" . DOCMAN_Utils::implode_assoc('=', '&', $params);
     }
     return $link;
 }
    function createItems($rows)
    {
        global $_DOCMAN, $mosConfig_live_site;
        $html = '';
        foreach ($rows as $row) {
            $doc = new DOCMAN_Document($row->id);
            $links = $doc->getLinkObject();
            $paths = $doc->getPathObject();
            $details = $doc->getDataObject();
            $icon = $doc->getPath('icon', 1, '16x16');
            $params = array('Itemid' => DOCMAN_Utils::getItemid());
            $url = DOCMAN_Utils::_rawLink('doc_download', $details->id, $params);
            if ($details->dmlastupdateon != "0000-00-00 00:00:00") {
                $itemtime = $details->dmlastupdateon;
            } else {
                $itemtime = $details->dmdate_published;
            }
            ?>
            <tr>
                <td><img src="<?php 
            echo $icon;
            ?>
" alt="<?php 
            echo $details->dmname;
            ?>
" /></td>
                <td><a href="javascript:;" onClick="onclickItem('<?php 
            echo addslashes($details->dmname);
            ?>
', '<?php 
            echo $url;
            ?>
', <?php 
            echo $details->catid;
            ?>
, '<?php 
            echo $icon;
            ?>
', '<?php 
            echo $details->filesize;
            ?>
', '<?php 
            echo $itemtime;
            ?>
');"><?php 
            echo $details->dmname;
            ?>
</td>
                <td><?php 
            echo $details->filesize;
            ?>
</td>
                <td><?php 
            echo $itemtime;
            ?>
</td>
            </tr>
            <?php 
        }
        return $html;
    }