function showCategories() { global $database, $my, $option, $menutype, $mainframe, $mosConfig_list_limit; $section = "com_docman"; $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); $query = "SELECT c.*, c.checked_out as checked_out_contact_category, c.parent_id as parent, g.name AS groupname, u.name AS editor" . "\n FROM #__categories AS c" . "\n LEFT JOIN #__users AS u ON u.id = c.checked_out" . "\n LEFT JOIN #__groups AS g ON g.id = c.access" . "\n WHERE c.section='{$section}'" . "\n AND c.published != -2" . "\n ORDER BY parent_id,ordering"; $database->setQuery($query); $rows = $database->loadObjectList(); if ($database->getErrorNum()) { echo $database->stderr(); return false; } // establish the hierarchy of the categories $children = array(); // first pass - collect children foreach ($rows as $v) { $pt = $v->parent; $list = @$children[$pt] ? $children[$pt] : array(); array_push($list, $v); $children[$pt] = $list; } // second pass - get an indent list of the items $list = DOCMAN_Utils::mosTreeRecurse(0, '', array(), $children, max(0, $levellimit - 1)); $list = is_array($list) ? $list : array(); $total = count($list); require_once $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php'; $pageNav = new mosPageNav($total, $limitstart, $limit); $levellist = mosHTML::integerSelectList(1, 20, 1, 'levellimit', 'size="1" onchange="document.adminForm.submit();"', $levellimit); // slice out elements based on limits $list = array_slice($list, $pageNav->limitstart, $pageNav->limit); $count = count($list); // number of Active Items for ($i = 0; $i < $count; $i++) { $query = "SELECT COUNT( d.id )" . "\n FROM #__docman AS d" . "\n WHERE d.catid = " . $list[$i]->id; // . "\n AND d.state <> '-2'"; $database->setQuery($query); $active = $database->loadResult(); $list[$i]->documents = $active; } // get list of sections for dropdown filter $javascript = 'onchange="document.adminForm.submit();"'; $lists['sectionid'] = mosAdminMenus::SelectSection('sectionid', $sectionid, $javascript); HTML_DMCategories::show($list, $my->id, $pageNav, $lists, 'other'); }
/** * Shows a list of items for a menu */ function viewMenuItems($menutype, $option) { global $database, $mainframe, $mosConfig_list_limit; $limit = $mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mosConfig_list_limit); $limitstart = $mainframe->getUserStateFromRequest("view{$option}limitstart{$menutype}", 'limitstart', 0); $levellimit = $mainframe->getUserStateFromRequest("view{$option}limit{$menutype}", 'levellimit', 10); $search = $mainframe->getUserStateFromRequest("search{$option}{$menutype}", 'search', ''); $search = $database->getEscaped(trim(strtolower($search))); // select the records // note, since this is a tree we have to do the limits code-side if ($search) { $query = "SELECT m.id" . "\n FROM #__menu AS m" . "\n WHERE menutype='{$menutype}'" . "\n AND LOWER(m.name) LIKE '%" . strtolower($search) . "%'"; $database->setQuery($query); $search_rows = $database->loadResultArray(); } $query = "SELECT m.*, u.name AS editor, g.name AS groupname, c.publish_up, c.publish_down, com.name AS com_name" . "\n FROM #__menu AS m" . "\n LEFT JOIN #__users AS u ON u.id = m.checked_out" . "\n LEFT JOIN #__groups AS g ON g.id = m.access" . "\n LEFT JOIN #__content AS c ON c.id = m.componentid AND m.type='content_typed'" . "\n LEFT JOIN #__components AS com ON com.id = m.componentid AND m.type='components'" . "\n WHERE m.menutype='{$menutype}'" . "\n AND m.published != -2" . "\n ORDER BY parent,ordering"; $database->setQuery($query); $rows = $database->loadObjectList(); // establish the hierarchy of the menu $children = array(); // first pass - collect children foreach ($rows as $v) { $pt = $v->parent; $list = @$children[$pt] ? $children[$pt] : array(); array_push($list, $v); $children[$pt] = $list; } // second pass - get an indent list of the items $list = mosTreeRecurse(0, '', array(), $children, max(0, $levellimit - 1)); // eventually only pick out the searched items. if ($search) { $list1 = array(); foreach ($search_rows as $sid) { foreach ($list as $item) { if ($item->id == $sid) { $list1[] = $item; } } } // replace full list with found items $list = $list1; } $total = count($list); require_once $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php'; $pageNav = new mosPageNav($total, $limitstart, $limit); $levellist = mosHTML::integerSelectList(1, 20, 1, 'levellimit', 'size="1" onchange="document.adminForm.submit();"', $levellimit); // slice out elements based on limits $list = array_slice($list, $pageNav->limitstart, $pageNav->limit); $i = 0; foreach ($list as $mitem) { switch ($mitem->type) { case 'separator': case 'component_item_link': break; case 'content_item_link': $temp = split("&task=view&id=", $mitem->link); $mitem->link .= '&Itemid=' . $mainframe->getItemid($temp[1]); break; case 'url': if (eregi('index.php\\?', $mitem->link)) { if (!eregi('Itemid=', $mitem->link)) { $mitem->link .= '&Itemid=' . $mitem->id; } } break; case 'content_typed': case 'content_item_link': default: $mitem->link .= '&Itemid=' . $mitem->id; break; } $list[$i]->link = $mitem->link; $i++; } $i = 0; foreach ($list as $row) { $name = RenameMenu($row->type, $row->com_name); $list[$i]->type = $name; $i++; } HTML_menusections::showMenusections($list, $pageNav, $search, $levellist, $menutype, $option); }
function BlogOutput(&$rows, &$params, $gid, &$access, $pop, &$menu, $archive = NULL) { global $mainframe, $Itemid, $task, $id, $option, $database, $mosConfig_live_site; // parameters if ($params->get('page_title', 1)) { $header = $params->def('header', $menu->name); } else { $header = ''; } $columns = $params->def('columns', 2); if ($columns == 0) { $columns = 1; } $intro = $params->def('intro', 4); $leading = $params->def('leading', 1); $links = $params->def('link', 4); $pagination = $params->def('pagination', 2); $pagination_results = $params->def('pagination_results', 1); $pagination_results = $params->def('pagination_results', 1); $descrip = $params->def('description', 1); $descrip_image = $params->def('description_image', 1); // needed for back button for page $back = $params->get('back_button', $mainframe->getCfg('back_button')); // needed to disable back button for item $params->set('back_button', 0); $params->def('pageclass_sfx', ''); $params->set('intro_only', 1); $total = count($rows); // pagination support $limitstart = intval(mosGetParam($_REQUEST, 'limitstart', 0)); $limit = $intro + $leading + $links; if ($total <= $limit) { $limitstart = 0; } $i = $limitstart; // needed to reduce queries used by getItemid $ItemidCount['bs'] = $mainframe->getBlogSectionCount(); $ItemidCount['bc'] = $mainframe->getBlogCategoryCount(); $ItemidCount['gbs'] = $mainframe->getGlobalBlogSectionCount(); // used to display section/catagory description text and images // currently not supported in Archives if ($menu->componentid && ($descrip || $descrip_image)) { switch ($menu->type) { case 'content_blog_section': $description = new mosSection($database); $description->load($menu->componentid); break; case 'content_blog_category': $description = new mosCategory($database); $description->load($menu->componentid); break; case 'content_blog_category': case 'components': default: $menu->componentid = 0; break; } } // Page Output // page header if ($header) { echo '<div class="componentheading' . $params->get('pageclass_sfx') . '">' . $header . '</div>'; } if ($archive) { echo '<br />'; echo mosHTML::monthSelectList('month', 'size="1" class="inputbox"', $params->get('month')); echo mosHTML::integerSelectList(2000, 2010, 1, 'year', 'size="1" class="inputbox"', $params->get('year'), "%04d"); echo '<input type="submit" class="button" />'; } // checks to see if there are there any items to display if ($total) { $col_with = 100 / $columns; // width of each column $width = 'width="' . $col_with . '%"'; if ($archive) { // Search Success message $msg = sprintf(_ARCHIVE_SEARCH_SUCCESS, $params->get('month'), $params->get('year')); echo "<br /><br /><div align='center'>" . $msg . "</div><br /><br />"; } echo '<table class="' . $params->get('pageclass_sfx') . '" cellpadding="0" cellspacing="0">'; // Secrion/Category Description & Image if ($menu->componentid && ($descrip || $descrip_image)) { $link = $mosConfig_live_site . '/images/stories/' . $description->image; echo '<tr>'; echo '<td valign="top">'; if ($descrip_image) { echo '<img src="' . $link . '" align="' . $description->image_position . '" hspace="6" alt="" />'; } if ($descrip) { echo $description->description; } echo '<br/><br/>'; echo '</td>'; echo '</tr>'; } // Leading story output if ($leading) { echo '<tr>'; echo '<td valign="top">'; for ($z = 0; $z < $leading; $z++) { if ($i >= $total) { // stops loop if total number of items is less than the number set to display as leading break; } echo '<div>'; show($rows[$i], $params, $gid, $access, $pop, $option, $ItemidCount); echo '</div>'; $i++; } echo '</td>'; echo '</tr>'; } if ($intro && $i < $total) { echo '<tr>'; echo '<td valign="top">'; echo '<table width="100%" cellpadding="0" cellspacing="0">'; // intro story output for ($z = 0; $z < $intro; $z++) { if ($i >= $total) { // stops loop if total number of items is less than the number set to display as intro + leading break; } if (!($z % $columns) || $columns == 1) { echo '<tr>'; } echo '<td valign="top" ' . $width . '>'; // outputs either intro or only a link if ($z < $intro) { show($rows[$i], $params, $gid, $access, $pop, $option, $ItemidCount); } else { echo '</td>'; echo '</tr>'; break; } echo '</td>'; if (!(($z + 1) % $columns) || $columns == 1) { echo '</tr>'; } $i++; } // this is required to output a final closing </tr> tag when the number of items does not fully // fill the last row of output - a blank column is left if ($intro % $columns) { echo '</tr>'; } echo '</table>'; echo '</td>'; echo '</tr>'; } // Links output if ($links && $i < $total) { echo '<tr>'; echo '<td valign="top">'; echo '<div class="blog_more' . $params->get('pageclass_sfx') . '">'; HTML_content::showLinks($rows, $links, $total, $i, 1, $ItemidCount); echo '</div>'; echo '</td>'; echo '</tr>'; } // Pagination output if ($pagination) { if ($pagination == 2 && $total <= $limit) { // not visible when they is no 'other' pages to display } else { // get the total number of records $limitstart = $limitstart ? $limitstart : 0; require_once $GLOBALS['mosConfig_absolute_path'] . '/includes/pageNavigation.php'; $pageNav = new mosPageNav($total, $limitstart, $limit); if ($option == 'com_frontpage') { $link = 'index.php?option=com_frontpage&Itemid=' . $Itemid; } else { if ($archive) { $year = $params->get('year'); $month = $params->get('month'); $link = 'index.php?option=com_content&task=' . $task . '&id=' . $id . '&Itemid=' . $Itemid . '&year=' . $year . '&month=' . $month; } else { $link = 'index.php?option=com_content&task=' . $task . '&id=' . $id . '&Itemid=' . $Itemid; } } echo '<tr>'; echo '<td valign="top" align="center">'; echo $pageNav->writePagesLinks($link); echo '<br /><br />'; echo '</td>'; echo '</tr>'; if ($pagination_results) { echo '<tr>'; echo '<td valign="top" align="center">'; echo $pageNav->writePagesCounter(); echo '</td>'; echo '</tr>'; } } } echo '</table>'; } else { if ($archive && !$total) { // Search Failure message for Archives $msg = sprintf(_ARCHIVE_SEARCH_FAILURE, $params->get('month'), $params->get('year')); echo '<br /><br /><div align="center">' . $msg . '</div><br />'; } else { // Generic blog empty display echo _EMPTY_BLOG; } } // Back Button $params->set('back_button', $back); mosHTML::BackButton($params); }
function showCategories() { global $database, $my, $option, $menutype, $mainframe, $mosConfig_list_limit, $acl; $grooups = get_group_children_bl(); $section = "com_booklibrary"; $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); $query = "SELECT c.*, c.checked_out as checked_out_contact_category, c.parent_id as parent,\n c.params, u.name AS editor, COUNT(bc.id) AS cc" . "\n FROM #__booklibrary_main_categories AS c" . "\n LEFT JOIN #__booklibrary_categories as bc ON bc.catid=c.id" . "\n LEFT JOIN #__users AS u ON u.id = c.checked_out" . "\n WHERE c.section='{$section}'" . "\n GROUP BY c.id " . "\n ORDER BY parent_id DESC, ordering"; $database->setQuery($query); $rows = $database->loadObjectList(); foreach ($rows as $k => $v) { $rows[$k]->ncourses = 0; foreach ($rows as $k1 => $v1) { if ($v->id == $v1->parent) { $rows[$k]->cc += $v1->cc; } } $rows[$k]->cc == 0 ? "-" : "<a href=\"?option=com_booklibrary§ion=book&catid=" . $v->id . "\">" . $v->cc . "</a>"; //for 1.6 $curgroup = ""; $ss = explode(',', $v->params); foreach ($ss as $s) { if ($s == '') { $s = '-2'; } $curgroup[] = $grooups[$s]; } $rows[$k]->groups = implode(', ', $curgroup); } if ($database->getErrorNum()) { echo $database->stderr(); return false; } // establish the hierarchy of the categories $children = array(); // first pass - collect children foreach ($rows as $v) { $pt = $v->parent; $list = @$children[$pt] ? $children[$pt] : array(); array_push($list, $v); $children[$pt] = $list; } // second pass - get an indent list of the items $list = bookLibraryTreeRecurse(0, '', array(), $children, max(0, $levellimit - 1)); $total = count($list); $pageNav = new JPagination($total, $limitstart, $limit); // for J 1.6 $levellist = mosHTML::integerSelectList(1, 20, 1, 'levellimit', 'size="1" onchange="document.adminForm.submit();"', $levellimit); // slice out elements based on limits $list = array_slice($list, $pageNav->limitstart, $pageNav->limit); $count = count($list); // get list of sections for dropdown filter $javascript = 'onchange="document.adminForm.submit();"'; if (version_compare(JVERSION, "3.0.0", "lt")) { $mosAdminMenus = new mosAdminMenus(); $lists['sectionid'] = $mosAdminMenus->SelectSection('sectionid', $sectionid, $javascript); } HTML_Categories::show($list, $my->id, $pageNav, $lists, 'other'); }
function JQ_ListCategoryGQP($option, $page, $id) { global $JLMS_DB, $JLMS_SESSION, $JLMS_CONFIG; $rows = array(); $lists = array(); $pageNav = array(); $is_pool = false; $gqp = true; $limit = intval(mosGetParam($_GET, 'limit', $JLMS_SESSION->get('list_limit', $JLMS_CONFIG->get('list_limit')))); $limitstart = intval(mosGetParam($_GET, 'limitstart', 0)); $levellimit = intval(mosGetParam($_REQUEST, 'levellimit', $JLMS_SESSION->get('GQP_levellimit', 10))); $JLMS_SESSION->set('GQP_levellimit', $levellimit); $query = "SELECT id, c_category as name, parent" . "\n FROM #__lms_gqp_cats" . "\n ORDER BY c_category"; $JLMS_DB->setQuery($query); $rows = $JLMS_DB->loadObjectList(); // establish the hierarchy of the menu $children = array(); // first pass - collect children foreach ($rows as $v) { $pt = $v->parent; /** Joomla 1.6 compability { */ $v->parent_id = $v->parent; $v->title = $v->name; /** } Joomla 1.6 compability*/ $list = @$children[$pt] ? $children[$pt] : array(); array_push($list, $v); $children[$pt] = $list; } // second pass - get an indent list of the items $list = mosTreeRecurse(0, '', array(), $children, max(0, $levellimit - 1)); // eventually only pick out the searched items. $total = count($list); require_once _JOOMLMS_FRONT_HOME . DS . "includes" . DS . "classes" . DS . "lms.pagination.php"; $pageNav = new JLMSPageNav($total, $limitstart, $limit); $levellist = mosHTML::integerSelectList(1, 20, 1, 'levellimit', 'size="1" onchange="document.adminForm.submit();"', $levellimit); // slice out elements based on limits $list = array_slice($list, $pageNav->limitstart, $pageNav->limit); /*For update question delete gqp_cats_levels*/ $query = "SELECT count(*) FROM #__lms_gqp_levels"; $JLMS_DB->setQuery($query); $exist = $JLMS_DB->loadResult(); $query = "SELECT * FROM #__lms_quiz_t_question WHERE course_id = 0 AND c_quiz_id = 0"; $JLMS_DB->setQuery($query); $listQuestions = $JLMS_DB->loadObjectList(); if ($exist && isset($listQuestions) && count($listQuestions)) { $status_check = true; foreach ($listQuestions as $n => $quest) { $listLevels = array(); $query = "SELECT * FROM #__lms_gqp_levels WHERE quest_id = '" . $quest->c_id . "'"; $JLMS_DB->setQuery($query); $listLevels = $JLMS_DB->loadObjectList(); $tmp_last_cat_id = 0; $tmp_update = array(); if (count($listLevels)) { $tmp_level = 0; foreach ($listLevels as $level) { if ($level->level > $tmp_level) { $tmp_last_cat_id = $level->cat_id; $tmp_level = $level->level; $tmp_update[] = $level->quest_id; } } } $query = "UPDATE #__lms_quiz_t_question as qtq, #__lms_gqp_levels as l" . "\n SET qtq.c_qcat = '" . $tmp_last_cat_id . "'" . "\n WHERE 1" . "\n AND qtq.c_id = '" . $quest->c_id . "'" . "\n AND qtq.course_id = 0" . "\n AND qtq.c_quiz_id = 0" . "\n AND qtq.c_id = l.quest_id"; $JLMS_DB->setQuery($query); if ($JLMS_DB->query()) { $status_check = false; } } if (!$status_check) { $query = "DROP TABLE IF EXISTS #__lms_gqp_levels"; $JLMS_DB->setQuery($query); $JLMS_DB->query(); } } /*For update question delete gqp_cats_levels*/ JLMS_quiz_admin_html_class::JQ_showListCategoryGQP($list, $lists, $pageNav, $option, $page, $id, $is_pool, $gqp, $levellist); }