/** * include stylesheets and scripts; set javascript variables * @param $outputPage - an instance of OutputPage * @param $isRTL - whether the current language is RTL * currently set: cookie prefix; * localAllOp, local1opTemplate, local2opTemplate, localDbFields, localBrackets, localBoolOps, localCmpOps */ static function headScripts(&$outputPage, $isRTL) { global $wgJsMimeType; $outputPage->addLink(array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => CB_Setup::$ScriptPath . '/category_browser.css?' . CB_Setup::$version)); if ($isRTL) { $outputPage->addLink(array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => CB_Setup::$ScriptPath . '/category_browser_rtl.css?' . CB_Setup::$version)); } $outputPage->addScript('<script type="' . $wgJsMimeType . '" src="' . CB_Setup::$ScriptPath . '/category_browser.js?' . CB_Setup::$version . '"></script> <script type="' . $wgJsMimeType . '"> CB_lib.setCookiePrefix("' . CB_Setup::getJsCookiePrefix() . '"); CB_ConditionEditor.setLocalNames( ' . CategoryBrowser::getJsObject('cbLocalMessages', 'apply_button', 'all_op', 'op1_template', 'op2_template', 'ie6_warning') . ", \n\t\t\t" . CategoryBrowser::getJsObject('cbLocalEditHints', 'left', 'right', 'remove', 'copy', 'append', 'clear', 'paste', 'paste_right') . ", \n\t\t\t" . CategoryBrowser::getJsObject('cbLocalDbFields', 's', 'p', 'f') . ", \n\t\t\t" . CategoryBrowser::getJsObject('cbLocalOps', 'lbracket', 'rbracket') . ", \n\t\t\t" . CategoryBrowser::getJsObject('cbLocalOps', 'or', 'and') . ", \n\t\t\t" . CategoryBrowser::getJsObject('cbLocalOps', 'le', 'ge', 'eq') . ' );</script>' . "\n"); }
function execute($param) { global $wgOut; $this->setHeaders(); $this->ranges = CategoryBrowser::generateRanges($this->source_ranges); $cb = new CategoryBrowser(); # try to create rootPager from rootcond cookie value if (is_string($encPolishQueue = CB_Setup::getCookie('rootcond'))) { $sqlCond = CB_SqlCond::newFromEncodedPolishQueue($encPolishQueue); $rootPager = CB_RootPager::newFromSqlCond($sqlCond); # add selected condition to range, if not duplicate CategoryBrowser::addRange($this->ranges, $rootPager->sqlCond); } else { # otherwise, try to create rootPager from the list of predefined infix queues (ranges) if (!is_object($rootPager = CB_RootPager::newFromCategoryRange($this->ranges))) { return; } } $rootPager->getCurrentRows(); /* reverse polish queue encode / decode validations */ $testCond = CB_SqlCond::newFromEncodedPolishQueue($rootPager->sqlCond->getEncodedQueue(false)); if ($rootPager->sqlCond->getCond() != $testCond->getCond()) { throw new MWException('Infix queue was not re-built correctly from encoded polish queue in ' . __METHOD__); } /* infix queue encode / decode validations */ $testCond = CB_SqlCond::newFromEncodedInfixQueue($rootPager->sqlCond->getEncodedQueue(true)); if ($rootPager->sqlCond->getCond() != $testCond->getCond()) { throw new MWException('Infix queue was not re-built correctly from encoded infix queue in ' . __METHOD__); } /* end of validations */ # {{{ top template $condSelector = ''; $catlist = array(); $js_setFilter = 'CategoryBrowser.setFilter()'; $filterFields = array(); if (CB_Setup::$cat_title_CI != '') { // case insensitive search is possible $filterFields[] = array('__tag' => 'span', 0 => wfMsg('cb_cat_name_filter_ci')); $filterFields[] = array('__tag' => 'input', 'class' => 'cb_filter_field', 'type' => 'checkbox', 'onchange' => $js_setFilter, 'id' => 'cb_cat_name_filter_ci', 'title' => wfMsg('cb_cat_name_filter_ci'), 'checked' => null); } if (CB_Setup::$allowNoParentsOnly) { $filterFields[] = array(array('__tag' => 'span', 'class' => 'cb_filter_field', 0 => wfMsg('cb_show_no_parents_only')), array('__tag' => 'input', 'class' => 'cb_filter_field', 'type' => 'checkbox', 'onchange' => $js_setFilter, 'onclick' => $js_setFilter, 'title' => wfMsg('cb_show_no_parents_only'), 'id' => 'cb_cat_no_parents_only')); } $top_tpl = array('__tag' => 'table', 'class' => 'cb_top_container', '__end' => "\n", array('__tag' => 'tr', '__end' => "\n", array('__tag' => 'td', 'class' => 'cb_toolbox_top', '__end' => "\n", 0 => &$condSelector)), array('__tag' => 'tr', '__end' => "\n", array('__tag' => 'td', 'class' => 'cb_toolbox_bottom', '__end' => "\n", array('__tag' => 'div', 'class' => 'cb_filter_container', wfMsg('cb_cat_name_filter'), array('__tag' => 'input', 'type' => 'text', 'onkeyup' => $js_setFilter, 'onchange' => $js_setFilter, 'id' => 'cb_cat_name_filter'), array('__tag' => 'input', 'type' => 'button', 'class' => 'cb_filter_field', 'onclick' => 'CategoryBrowser.clearNameFilter(this)', 'title' => wfMsg('cb_cat_name_filter_clear'), 'value' => '※')), array('__tag' => 'div', 'class' => 'cb_filter_container', &$filterFields))), array('__tag' => 'tr', '__end' => "\n", array('__tag' => 'td', 'class' => 'cb_toolbox', 'style' => 'display:none; ', '__end' => "\n", array('__tag' => 'div', 'id' => 'cb_editor_container', 0 => ''), array('__tag' => 'div', 'class' => 'cb_separate_container', 0 => ''))), array('__tag' => 'tr', '__end' => "\n", array('__tag' => 'td', 'class' => 'cb_toolbox', 'style' => 'display:none; ', '__end' => "\n", array('__tag' => 'div', 'class' => 'cb_copy_line_hint', 0 => wfMsg('cb_copy_line_hint')), array('__tag' => 'div', 'id' => 'cb_samples_container', 0 => ''))), array('__tag' => 'tr', '__end' => "\n", array('__tag' => 'td', '__end' => "\n", array('__tag' => 'div', 'id' => 'cb_root_container', 0 => &$catlist)))); # }}} $condSelector = CategoryBrowser::generateSelector($this->ranges, $rootPager); $pagerView = new CB_CategoriesView($rootPager); $catlist = $pagerView->generateList(); $wgOut->addHTML(CB_XML::toText($top_tpl)); }
} if (get_conf('allowToSelfEnroll', true)) { $userCommands[] = '<a href="claroline/auth/courses.php?cmd=rqReg&categoryId=0" class="userCommandsItem">' . '<img src="' . get_icon_url('enroll') . '" alt="" /> ' . get_lang('Enrol on a new course') . '</a>' . "\n"; $userCommands[] = '<a href="claroline/auth/courses.php?cmd=rqUnreg" class="userCommandsItem">' . '<img src="' . get_icon_url('unenroll') . '" alt="" /> ' . get_lang('Remove course enrolment') . '</a>' . "\n"; } $userCommands[] = '<a href="claroline/course/platform_courses.php" class="userCommandsItem">' . '<img src="' . get_icon_url('course') . '" alt="" /> ' . get_lang('All platform courses') . '</a>' . "\n"; $userCommands[] = '<img class="iconDefinitionList" src="' . get_icon_url('hot') . '" alt="' . get_lang('New items') . '" />' . ' ' . get_lang('New items') . ' ' . '(<a href="' . claro_htmlspecialchars(Url::Contextualize(get_path('clarolineRepositoryWeb') . 'notification_date.php')) . '" class="userCommandsItem">' . get_lang('to another date') . '</a>)' . (substr($lastUserAction, strlen($lastUserAction) - 8) == '00:00:00' ? ' <br />[' . claro_html_localised_date(get_locale('dateFormatNumeric'), strtotime($lastUserAction)) . ']' : '') . "\n"; $template->assign('userCommands', $userCommands); // User profilebox FromKernel::uses('display/userprofilebox.lib'); $userProfileBox = new UserProfileBox(false); $template->assign('userProfileBox', $userProfileBox); } else { // Category browser $categoryId = !empty($_REQUEST['categoryId']) ? (int) $_REQUEST['categoryId'] : 0; $categoryBrowser = new CategoryBrowser($categoryId); $templateCategoryBrowser = $categoryBrowser->getTemplate(); $template->assign('templateCategoryBrowser', $templateCategoryBrowser); } // Render $claroline->display->body->setContent($template->render()); if (!(isset($_REQUEST['logout']) && isset($_SESSION['isVirtualUser']))) { echo $claroline->display->render(); } } else { require_once get_path('clarolineRepositorySys') . '/desktop/index.php'; } // Logout request : delete session data if (isset($_REQUEST['logout'])) { if (isset($_SESSION['isVirtualUser'])) { unset($_SESSION['isVirtualUser']);
if ($cmd == 'rqUnreg') { $courseListView = CourseTreeNodeViewFactory::getUserCourseTreeView($userId); $unenrollUrl = Url::buildUrl($_SERVER['PHP_SELF'] . '?cmd=exUnreg', $urlParamList, null); $viewOptions = new CourseTreeViewOptions(false, true, null, $unenrollUrl->toUrl()); $courseListView->setViewOptions($viewOptions); $displayMode = DISPLAY_USER_COURSES; } // end if ($cmd == 'rqUnreg') /*---------------------------------------------------------------------------- Search a course to register ----------------------------------------------------------------------------*/ if ($cmd == 'rqReg') { // Set user id to null if we're working on a class $userId = $fromAdmin == 'class' ? null : $userId; // Build the category browser $categoryBrowser = new CategoryBrowser($categoryId, $userId); if ($fromAdmin == 'class') { $viewOptions = new CourseTreeViewOptions(true, false, Url::buildUrl(get_module_url('CLUSR') . '/class_add.php?cmd=exEnrol', $urlParamList, null)->toUrl(), null, true); // var_dump($viewOptions); } else { $viewOptions = new CourseTreeViewOptions(true, false, Url::buildUrl($_SERVER['PHP_SELF'] . '?cmd=exReg', $urlParamList, null)->toUrl(), null); } $categoryBrowser->setViewOptions($viewOptions); $parentCategoryId = $categoryBrowser->getCurrentCategorySettings()->idParent; // Build the search box $searchBox = new CourseSearchBox($_SERVER['REQUEST_URI']); if ($fromAdmin == 'class') { $viewOptions = new CourseTreeViewOptions(true, false, Url::buildUrl(get_module_url('CLUSR') . '/class_add.php?cmd=exEnrol', $urlParamList, null)->toUrl(), null, true); // var_dump($viewOptions); } else { $viewOptions = new CourseTreeViewOptions(true, false, Url::buildUrl($_SERVER['PHP_SELF'] . '?cmd=exReg', $urlParamList, null)->toUrl(), null);