Пример #1
0
function showListview()
{
    global $_DOCMAN;
    $assets = JURI::root() . "components/com_docman/assets";
    // add styles and scripts
    $doc =& JFactory::getDocument();
    JHTML::_('behavior.mootools');
    $doc->addStyleSheet($assets . '/css/doclink.css');
    $doc->addScript($assets . '/js/sortabletable.js');
    $doc->addScript($assets . '/js/listview.js');
    if (isset($_REQUEST['catid'])) {
        $cid = intval($_REQUEST['catid']);
    } else {
        $cid = 0;
    }
    //get folders
    $cats = DOCMAN_Cats::getChildsByUserAccess($cid);
    //get items
    if ($cid) {
        $docs = DOCMAN_Docs::getDocsByUserAccess($cid, 'name', 'ASC', 999, 0);
    } else {
        $docs = array();
    }
    //if ($entries_cnt)
    HTML_DMDoclink::createHeader();
    HTML_DMDoclink::createFolders($cats, $cid);
    HTML_DMDoclink::createItems($docs, $cid);
    HTML_DMDoclink::createFooter();
}
Пример #2
0
function fetchDocumentList($catid)
{
    global $_DOCMAN, $_DMUSER, $ordering, $direction, $limit, $limitstart;
    if (!$catid) {
        return;
    }
    $rows = DOCMAN_Docs::getDocsByUserAccess($catid, $ordering, $direction, $limit, $limitstart);
    if (!is_array($rows)) {
        $rows = array();
    }
    $params = array('limit' => $limit, 'limitstart' => $limitstart);
    // create orderby object
    $links = array();
    $links['name'] = _taskLink('cat_view', $catid, array_merge($params, array('order' => 'name', 'dir' => $direction)));
    $links['date'] = _taskLink('cat_view', $catid, array_merge($params, array('order' => 'date', 'dir' => $direction)));
    $links['hits'] = _taskLink('cat_view', $catid, array_merge($params, array('order' => 'hits', 'dir' => $direction)));
    if ($direction == 'ASC') {
        $links['dir'] = _taskLink('cat_view', $catid, array_merge($params, array('order' => $ordering, 'dir' => 'DESC')));
    } else {
        $links['dir'] = _taskLink('cat_view', $catid, array_merge($params, array('order' => $ordering, 'dir' => 'ASC')));
    }
    //set pathway information
    $pathway = new StdClass();
    $pathway->links = $links;
    //set order information
    $order = new StdClass();
    $order->links = $links;
    $order->direction = $direction;
    $order->orderby = $ordering;
    $order->limit = $limit;
    $order->limitstart = $limitstart;
    $items = array();
    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();
        $items[] = $item;
    }
    return HTML_DMDocuments::displayDocumentList($order, $items);
}
Пример #3
0
 function getLinks($args)
 {
     global $_DOCMAN, $mainframe;
     $wf = WFEditorPlugin::getInstance();
     jimport('joomla.filesystem.file');
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_docman' . DS . 'docman.class.php';
     //DOCMan core interaction API
     $_DOCMAN = new dmMainFrame(_DM_TYPE_DOCLINK);
     // Load classes and language
     require_once $_DOCMAN->getPath('classes', 'utils');
     $cid = isset($args->gid) ? $args->gid : 0;
     //get folders
     $categories = DOCMAN_Cats::getChildsByUserAccess($cid);
     $items = array();
     $view = isset($args->view) ? $args->view : '';
     switch ($view) {
         default:
             foreach ($categories as $category) {
                 $items[] = array('id' => 'index.php?option=com_docman&view=category&gid=' . $category->id . WFLinkBrowser::getItemId('com_docman'), 'name' => $category->name, 'class' => 'folder docmanlinks');
             }
             break;
         case 'category':
             //get items
             if ($cid) {
                 $categories = DOCMAN_Cats::getChildsByUserAccess($cid);
                 $documents = DOCMAN_Docs::getDocsByUserAccess($cid, 'name', 'ASC', 999, 0);
             } else {
                 $categories = array();
                 $documents = array();
             }
             foreach ($categories as $category) {
                 $items[] = array('id' => 'index.php?option=com_docman&view=category&gid=' . $category->id . WFLinkBrowser::getItemId('com_docman'), 'name' => $category->name, 'class' => 'folder docmanlinks');
             }
             foreach ($documents as $document) {
                 $items[] = array('id' => 'index.php?option=com_docman&task=doc_' . $wf->getParam('docmanlinks_link', 'download') . '&gid=' . $document->id . WFLinkBrowser::getItemId('com_docman'), 'name' => $document->dmname, 'class' => 'file docmanlinks ' . JFile::getExt($document->dmfilename));
             }
             break;
     }
     return $items;
 }
Пример #4
0
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;
}
Пример #5
0
 function _dmSearchSection($id, &$cache, $sep)
 {
     global $database;
     if (!$id) {
         return "";
     }
     if (isset($cache[$id])) {
         return $cache[$id];
     }
     // Find it...
     $query = "SELECT parent_id, name FROM #__categories WHERE id = " . (int) $id;
     $database->setQuery($query);
     $row = $database->loadObjectList();
     if (count($row)) {
         if ($row[0]->parent_id) {
             $cache[$id] = DOCMAN_Docs::_dmSearchSection($row[0]->parent_id, $cache, $sep) . $sep . $row[0]->name;
         } else {
             $cache[$id] = $row[0]->name;
         }
     }
     return $cache[$id];
 }
        // Oldest
        $order = "date";
        $dir = "ASC";
        break;
    case 4:
        // Alphabetically
        $order = "name";
        $dir = "ASC";
        break;
    case 5:
        // Alphabetically, reverse
        $order = "name";
        $dir = "DESC";
        break;
}
$rows = DOCMAN_Docs::getDocsByUserAccess($cat_limit, $order, $dir, $limits);
// If we have a textual prefix, show it now
if (strlen($text_pfx) > 0) {
    $html .= "<span class='{$class_prefix}'>" . $text_pfx . "</span><br />";
}
// List output
if ($show_list == 1) {
    $html .= "<ul>";
}
// For each row of our result..
foreach ($rows as $row) {
    // List output
    if ($show_list == 1) {
        $html .= "<li>";
    }
    // Create a new document
    $_DOCMAN = new dmMainFrame();
    $_DMUSER = $_DOCMAN->getUser();
}
$_DOCMAN->setType(_DM_TYPE_MODULE);
$_DOCMAN->loadLanguage('modules');
require_once $_DOCMAN->getPath('classes', 'utils');
require_once $_DOCMAN->getPath('classes', 'file');
require_once $_DOCMAN->getPath('classes', 'model');
// get the parameters
$catid = $params->def('catid', '');
$limits = (int) $params->def('limits', 3);
$show_icon = (int) $params->def('show_icon', 1);
$show_category = (int) $params->def('show_category', 1);
$menuid = $_DOCMAN->getMenuId();
$html = '<div class="mod_docman_catdown' . $params->get('moduleclass_sfx') . '">';
$rows = DOCMAN_Docs::getDocsByUserAccess($catid, '', '', $limits);
if (count($rows)) {
    $html .= '<ul class="mod_docman_catdown' . $params->get('moduleclass_sfx') . '">';
    foreach ($rows as $row) {
        $doc = new DOCMAN_Document($row->id);
        $url = JRoute::_("index.php?option=com_docman&amp;task=cat_view&amp;Itemid={$menuid}&amp;gid=" . $doc->getData('catid') . "&amp;orderby=dmdate_published&amp;ascdesc=DESC");
        $html .= '<li><a href="' . $url . '">';
        if ($show_icon) {
            $html .= '<img src="' . $doc->getPath('icon', 1, '16x16') . '" alt="file icon" border="0" />';
        }
        $html .= $doc->getData('dmname');
        if ($show_category) {
            $html .= '<br />(' . $row->cat_title . ')';
        }
        $html .= '</a></li>';
    }
Пример #8
0
    $_DMUSER = $_DOCMAN->getUser();
}
$_DOCMAN->setType(_DM_TYPE_MODULE);
$_DOCMAN->loadLanguage('modules');
$_DOCMAN->loadLanguage('frontend');
require_once $_DOCMAN->getPath('classes', 'utils');
require_once $_DOCMAN->getPath('classes', 'file');
require_once $_DOCMAN->getPath('classes', 'model');
// get the parameters
$limits = abs($params->def('limits', 3));
$show_icon = abs($params->def('show_icon', 1));
$show_category = abs($params->def('show_category', 1));
$moduleclass_sfx = $params->get('moduleclass_sfx');
$menuid = $_DOCMAN->getMenuId();
$html = '<div class="mod_docman_catdown' . $moduleclass_sfx . '">';
$rows = DOCMAN_Docs::getDocsByUserAccess(0, 'date', 'desc', $limits);
if (count($rows)) {
    $html .= '<ul class="mod_docman_latestdown">';
    foreach ($rows as $row) {
        $doc = new DOCMAN_Document($row->id);
        $catid = $doc->getData('catid');
        $url = JRoute::_("index.php?option=com_docman&task=cat_view&Itemid={$menuid}&gid={$catid}&orderby=dmdate_published");
        $html .= '<li><a href="' . $url . '">';
        if ($show_icon) {
            $html .= '<img border="0" src="' . $doc->getPath('icon', 1, '16x16') . '" alt="file icon" /> ';
        }
        $html .= $doc->getData('dmname');
        if ($show_category) {
            $html .= '<br />(' . $row->cat_title . ')';
        }
        $html .= '</a></li>';
 function getCategoryTree(&$xmap, &$parent, &$params, $catid = 0, $menuid)
 {
     $db =& JFactory::getDBO();
     $limits = 25;
     $list = array();
     $query = 'select id,title from #__categories where parent_id=' . $catid . ' and section=\'com_docman\' and published=1';
     $db->setQuery($query);
     $rows = $db->loadRowList();
     // Get sub-categories list
     $xmap->changeLevel(1);
     foreach ($rows as $row) {
         $node = new stdclass();
         $node->id = $menuid;
         $node->uid = $parent->uid . 'c' . $row[0];
         // should be uniq on component
         $node->name = $row[1];
         $node->browserNav = $parent->browserNav;
         $node->priority = $params['cat_priority'];
         $node->changefreq = $params['cat_changefreq'];
         $node->expandible = true;
         $node->link = 'index.php?option=com_docman&amp;task=cat_view&amp;gid=' . $row[0];
         if ($xmap->printNode($node) !== FALSE) {
             xmap_com_docman::getCategoryTree($xmap, $parent, $params, $row[0], $menuid);
         }
     }
     $xmap->changeLevel(-1);
     $include_docs = @$params['include_docs'];
     if ($catid > 0 && $params['include_docs']) {
         $xmap->changeLevel(1);
         $rows = DOCMAN_Docs::getDocsByUserAccess($catid, '', '', $limits);
         // Get documents list
         foreach ($rows as $row) {
             $doc = new DOCMAN_Document($row->id);
             $node = new stdclass();
             $node->id = $menuid;
             $node->uid = $parent->uid . 'd' . $row->id;
             // should be uniq on component
             $node->link = 'index.php?option=com_docman&amp;task=' . $params['doc_task'] . '&amp;gid=' . $row->id . '&amp;Itemid=' . $menuid;
             $node->browserNav = $parent->browserNav;
             $node->priority = $params['doc_priority'];
             $node->changefreq = $params['doc_changefreq'];
             $node->name = $doc->getData('dmname');
             $node->type = 'separator';
             $node->expandible = false;
             $xmap->printNode($node);
         }
         $xmap->changeLevel(-1);
     }
     return true;
 }
Пример #10
0
/**
* 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);
}
Пример #11
0
if (!is_object($_DOCMAN)) {
    $_DOCMAN = new dmMainFrame();
    $_DMUSER = $_DOCMAN->getUser();
}
$_DOCMAN->setType(_DM_TYPE_MODULE);
$_DOCMAN->loadLanguage('modules');
require_once $_DOCMAN->getPath('classes', 'utils');
require_once $_DOCMAN->getPath('classes', 'file');
require_once $_DOCMAN->getPath('classes', 'model');
// get the parameters
$limits = abs($params->def('limits', 3));
$show_icon = abs($params->def('show_icon', 1));
$show_counter = abs($params->def('show_counter', 1));
$menuid = $_DOCMAN->getMenuId();
$html = '';
$rows = DOCMAN_Docs::getDocsByUserAccess(0, 'hits', 'DESC', $limits);
if (count($rows)) {
    $html .= '<ul class="dm_mod_mostdown">';
    foreach ($rows as $row) {
        $doc = new DOCMAN_Document($row->id);
        $url = JRoute::_("index.php?option=com_docman&task=cat_view&Itemid={$menuid}&gid={$row->catid}");
        $html .= '<li><a href="' . $url . '">';
        if ($show_icon) {
            $html .= '<img border="0" src="' . $doc->getPath('icon', 1, '16x16') . '" alt="file icon" />';
        }
        $html .= $doc->getData('dmname');
        if ($show_counter) {
            $html .= ' (' . $doc->getData('dmcounter') . ')';
        }
        $html .= '</a></li>';
    }