function showFiles() { global $option, $section; global $_DOCMAN; $database = JFactory::getDBO(); $mainframe = JFactory::getApplication(); $limit = $mainframe->getCfg('list_limit'); $limit = $mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $limit); $limitstart = $mainframe->getUserStateFromRequest("view{$option}{$section}limitstart", 'limitstart', 0); $levellimit = $mainframe->getUserStateFromRequest("view{$option}{$section}limit", 'levellimit', 10); $filter = $mainframe->getUserStateFromRequest("filterarc{$option}{$section}", 'filter', 0); $search = $mainframe->getUserStateFromRequest("search{$option}{$section}", 'search', ''); // read directory content $folder = new DOCMAN_Folder($_DOCMAN->getCfg('dmpath')); $files = $folder->getFiles($search); for ($i = 0, $n = count($files); $i < $n; $i++) { $file =& $files[$i]; $database->setQuery("SELECT COUNT(dmfilename) FROM #__docman WHERE dmfilename='" . $database->getEscaped($file->name) . "'"); $result = $database->loadResult(); if ($database->getErrorNum()) { echo $database->stderr(); return false; } $file->links = $result; } if ($filter == 2) { $files = array_filter($files, 'filterOrphans'); } if ($filter == 3) { $files = array_filter($files, 'filterDocuments'); } $total = count($files); $pageNav = new DOCMAN_Pagination($total, $limitstart, $limit); // slice out elements based on limits $rows = array_slice($files, $pageNav->limitstart, $pageNav->limit); $filters[] = JHTML::_('select.option', '0', _DML_SELECT_FILE); $filters[] = JHTML::_('select.option', '1', _DML_ALLFILES); $filters[] = JHTML::_('select.option', '2', _DML_ORPHANS); $filters[] = JHTML::_('select.option', '3', _DML_DOCFILES); $lists['filter'] = JHTML::_('select.genericlist', $filters, 'filter', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $filter); //$search = ''; HTML_DMFiles::showFiles($rows, $lists, $search, $pageNav); }
function showFiles() { global $option, $section; global $_DOCMAN; $database = JFactory::getDBO(); $mainframe = JFactory::getApplication(); $limit = $mainframe->getCfg('list_limit'); $limit = $mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $limit); $limitstart = $mainframe->getUserStateFromRequest("view{$option}{$section}limitstart", 'limitstart', 0); $levellimit = $mainframe->getUserStateFromRequest("view{$option}{$section}limit", 'levellimit', 10); $filter = $mainframe->getUserStateFromRequest("filterarc{$option}{$section}", 'filter', 0); $search = $mainframe->getUserStateFromRequest("search{$option}{$section}", 'search', ''); // read directory content $folder = new DOCMAN_Folder($_DOCMAN->getCfg('dmpath')); $files = $folder->getFiles($search); // count number of links to docs $database->setQuery("SELECT `dmfilename`, COUNT(`dmfilename`) AS cnt FROM `#__docman` GROUP BY `dmfilename`"); $links = $database->loadObjectList('dmfilename'); if ($database->getErrorNum()) { echo $database->stderr(); return false; } foreach ($files as $file) { $file->links = (int) @$links[$file->name]->cnt; } if ($filter == 2) { $files = array_filter($files, 'filterOrphans'); } if ($filter == 3) { $files = array_filter($files, 'filterDocuments'); } $total = count($files); $pageNav = new DOCMAN_Pagination($total, $limitstart, $limit); // slice out elements based on limits $rows = array_slice($files, $pageNav->limitstart, $pageNav->limit); $filters[] = JHTML::_('select.option', '0', _DML_SELECT_FILE); $filters[] = JHTML::_('select.option', '1', _DML_ALLFILES); $filters[] = JHTML::_('select.option', '2', _DML_ORPHANS); $filters[] = JHTML::_('select.option', '3', _DML_DOCFILES); $lists['filter'] = JHTML::_('select.genericlist', $filters, 'filter', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $filter); HTML_DMFiles::showFiles($rows, $lists, $search, $pageNav); }
function clear() { if (!$this->check()) { return false; } global $_DOCMAN; require_once $_DOCMAN->getPath('classes', 'file'); $folder = new DOCMAN_Folder($_DOCMAN->getCfg('dmpath')); $files = $folder->getFiles(); $this->msg = _DML_CLEARDATA_CLEARED . $this->friendlyname; if (count($files)) { foreach ($files as $file) { if (!$file->remove()) { $this->msg = _DML_CLEARDATA_FAILED . $this->friendlyname; return false; } } } return true; }