示例#1
0
function showLicenses($option)
{
    global $sectionid;
    $database = JFactory::getDBO();
    $mainframe = JFactory::getApplication();
    $catid = (int) $mainframe->getUserStateFromRequest("catid{$option}{$sectionid}", 'catid', 0);
    $limit = (int) $mainframe->getUserStateFromRequest("viewlistlimit", 'limit', 10);
    $limitstart = (int) $mainframe->getUserStateFromRequest("view{$option}{$sectionid}limitstart", 'limitstart', 0);
    $search = $mainframe->getUserStateFromRequest("search{$option}{$sectionid}", 'search', '');
    $search = $database->getEscaped(trim(strtolower($search)));
    $where = array();
    if ($search) {
        $where[] = "LOWER(name) LIKE '%{$search}%'";
    }
    // get the total number of records
    $database->setQuery("SELECT count(*) FROM #__docman_licenses" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : ""));
    $total = $database->loadResult();
    echo $database->getErrorMsg();
    $id = JRequest::getInt('id', 0, 'post');
    $pageNav = new DOCMAN_Pagination($total, $limitstart, $limit);
    $query = "SELECT id, name, license" . "\n FROM #__docman_licenses" . (count($where) ? "\n WHERE " . implode(' AND ', $where) : "") . "\n ORDER BY name";
    $database->setQuery($query, $pageNav->limitstart, $pageNav->limit);
    $rows = $database->loadObjectList();
    // show the beginning of each license text
    foreach ($rows as $key => $row) {
        $rows[$key]->license = substr(strip_tags($row->license), 0, 100) . ' (...)';
    }
    if ($database->getErrorNum()) {
        echo $database->stderr();
        return false;
    }
    HTML_DMLicenses::showLicenses($option, $rows, $search, $pageNav);
}
示例#2
0
function showLicenses($option)
{
    global $database, $mainframe, $sectionid;
    $catid = (int) $mainframe->getUserStateFromRequest("catid{$option}{$sectionid}", 'catid', 0);
    $limit = (int) $mainframe->getUserStateFromRequest("viewlistlimit", 'limit', 10);
    $limitstart = (int) $mainframe->getUserStateFromRequest("view{$option}{$sectionid}limitstart", 'limitstart', 0);
    $search = $mainframe->getUserStateFromRequest("search{$option}{$sectionid}", 'search', '');
    $search = $database->getEscaped(trim(strtolower($search)));
    $where = array();
    if ($search) {
        $where[] = "LOWER(name) LIKE '%{$search}%'";
    }
    // get the total number of records
    $database->setQuery("SELECT count(*) FROM #__docman_licenses" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : ""));
    $total = $database->loadResult();
    echo $database->getErrorMsg();
    $id = mosGetParam($_POST, 'id', 0);
    require_once $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php';
    $pageNav = new mosPageNav($total, $limitstart, $limit);
    $query = "SELECT id, name, license" . "\n FROM #__docman_licenses" . (count($where) ? "\n WHERE " . implode(' AND ', $where) : "") . "\n ORDER BY name";
    $database->setQuery($query, $limitstart, $limit);
    $rows = $database->loadObjectList();
    // show the beginning of each license text
    foreach ($rows as $key => $row) {
        $rows[$key]->license = substr(strip_tags($row->license), 0, 100) . ' (...)';
    }
    if ($database->getErrorNum()) {
        echo $database->stderr();
        return false;
    }
    HTML_DMLicenses::showLicenses($option, $rows, $search, $pageNav);
}