Ejemplo n.º 1
0
function showLanguageManager($option)
{
    global $database, $mainframe, $mosConfig_list_limit, $menutype, $mosConfig_absolute_path;
    loadConstBook();
    $section = "com_booklibrary";
    $search['const'] = mosGetParam($_POST, 'search_const', '');
    $search['const_value'] = mosGetParam($_POST, 'search_const_value', '');
    $search['languages'] = mosGetParam($_POST, 'search_languages', '');
    $search['sys_type'] = mosGetParam($_POST, 'search_sys_type', '');
    $where_query = array();
    if ($search['const'] != '') {
        $where_query[] = "c.const LIKE '%" . $search['const'] . "%'";
    }
    if ($search['const_value'] != '') {
        $where_query[] = "cl.value_const LIKE '%" . $search['const_value'] . "%'";
    }
    if ($search['languages'] != '') {
        $where_query[] = "cl.fk_languagesid = " . $search['languages'] . " ";
    }
    if ($search['sys_type'] != '') {
        $where_query[] = "c.sys_type LIKE '%" . $search['sys_type'] . "%'";
    }
    $where = "";
    $i = 0;
    if (count($where_query) > 0) {
        $where = "WHERE ";
    }
    foreach ($where_query as $item) {
        if ($i == 0) {
            $where .= "( {$item} ) ";
        } else {
            $where .= "AND ( {$item} ) ";
        }
        $i++;
    }
    $query = "SELECT cl.id, cl.value_const, c.sys_type, l.title, c.const ";
    $query .= "FROM #__booklibrary_const_languages as cl ";
    $query .= "LEFT JOIN #__booklibrary_languages AS l ON cl.fk_languagesid=l.id ";
    $query .= "LEFT JOIN #__booklibrary_const AS c ON cl.fk_constid=c.id {$where}";
    $database->setQuery($query);
    $const_languages = $database->loadObjectList();
    $sectionid = $mainframe->getUserStateFromRequest("sectionid{$section}{$section}", 'sectionid', 0);
    $limit = $mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mosConfig_list_limit);
    $limitstart = $mainframe->getUserStateFromRequest("view{$section}limitstart", 'limitstart', 0);
    $levellimit = $mainframe->getUserStateFromRequest("view{$option}limit{$menutype}", 'levellimit', 10);
    $total = count($const_languages);
    $pageNav = new JPagination($total, $limitstart, $limit);
    // for J 1.6
    $const_languages = array_slice($const_languages, $pageNav->limitstart, $pageNav->limit);
    $query = "SELECT sys_type FROM #__booklibrary_const GROUP BY sys_type";
    $database->setQuery($query);
    $sys_types = $database->loadObjectList();
    $sys_type_row[] = mosHTML::makeOption('', '--Select sys type--');
    foreach ($sys_types as $sys_type) {
        $sys_type_row[] = mosHTML::makeOption($sys_type->sys_type, $sys_type->sys_type);
    }
    $search['sys_type'] = mosHTML::selectList($sys_type_row, 'search_sys_type', 'class="inputbox input-medium" size="1"
        onchange="document.adminForm.submit();"', 'value', 'text', $search['sys_type']);
    $query = "SELECT id, title FROM #__booklibrary_languages";
    $database->setQuery($query);
    $languages = $database->loadObjectList();
    $languages_row[] = mosHTML::makeOption('', '--Select language--');
    foreach ($languages as $language) {
        $languages_row[] = mosHTML::makeOption($language->id, $language->title);
    }
    $search['languages'] = mosHTML::selectList($languages_row, 'search_languages', 'class="inputbox input-medium" size="1"
        onchange="document.adminForm.submit();"', 'value', 'text', $search['languages']);
    HTML_booklibrary::showLanguageManager($const_languages, $pageNav, $search);
}