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));
 }
 /**
  * create root pager from the largest non-empty category range
  * @param $ranges - array of "complete" token queues (range)
  *   (every range is an stdobject of decoded infix queue and encoded reverse polish queue)
  */
 public static function newFromCategoryRange($ranges)
 {
     $rp = null;
     foreach ($ranges as &$range) {
         $rp = CB_RootPager::newFromInfixTokens($range->infix_tokens);
         $rp->getCurrentRows();
         if (is_object($rp) && $rp->offset != -1) {
             break;
         }
     }
     return $rp;
 }
 /**
  * called via AJAX to get root list for specitied offset, limit
  * where condition will be read from the cookie previousely set
  * @param $args[0] : encoded reverse polish queue
  * @param $args[1] : category name filter string
  * @param $args[2] : category name filter case insensitive flag
  * @param $args[3] : browse only categories which has no parents flag (by default, false)
  * @param $args[4] : offset (optional)
  * @param $args[5] : limit (optional)
  */
 static function getRootOffsetHtml()
 {
     $args = func_get_args();
     $limit = count($args) > 5 ? abs(intval($args[5])) : CB_PAGING_ROWS;
     $offset = count($args) > 4 ? abs(intval($args[4])) : 0;
     $noParentsOnly = count($args) > 3 ? $args[3] == 'true' : false;
     $nameFilterCI = count($args) > 2 ? $args[2] == 'true' : false;
     $nameFilter = count($args) > 1 ? $args[1] : '';
     $encPolishQueue = count($args) > 0 ? $args[0] : 'all';
     $cb = new CategoryBrowser();
     $sqlCond = CB_SqlCond::newFromEncodedPolishQueue($encPolishQueue);
     $rootPager = CB_RootPager::newFromSqlCond($sqlCond, $offset, $limit);
     $rootPager->setNoParentsOnly($noParentsOnly);
     $rootPager->setNameFilter($nameFilter, $nameFilterCI);
     $rootPager->getCurrentRows();
     $catView = new CB_CategoriesView($rootPager);
     $catlist = $catView->generateList();
     return CB_XML::toText($catlist);
 }