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)); }
/** * called via AJAX to generate new selected option when the selected rootcond is new (the rootcond cookie was set) * @param $args[0] currently selected expression in encoded infix format */ static function generateSelectedOption() { CB_Setup::initUser(); $args = func_get_args(); if (count($args) < 1) { throw new MWException('Argument 0 is missing in ' . __METHOD__); } $encInfixQueue = $args[0]; $sqlCond = CB_SqlCond::newFromEncodedInfixQueue($encInfixQueue); $ranges = array(); self::addRange($ranges, $sqlCond); # generate div instead of option to avoid innerHTML glitches in IE return self::generateOption($ranges[0], $sqlCond->getEncodedQueue(false), 'div'); }