Beispiel #1
0
/**
 * Display category box on edit page
 *
 * @author Maciej Błaszkowski <marooned at wikia-inc.com>
 */
function CategorySelectDisplayCategoryBox($rows, $cols, $ew, $textbox)
{
    global $wgRequest, $wgOut;
    $action = $wgRequest->getVal('action', 'view');
    if ($action != 'view' && $action != 'purge') {
        CategorySelect::SelectCategoryAPIgetData($textbox);
        $wgOut->addHTML(CategorySelectGenerateHTMLforEdit('editform'));
    }
    return true;
}
 private static function lookForCategory(&$text, $outerTag)
 {
     self::$categories = array();
     self::$outerTag = $outerTag;
     $text = preg_replace_callback('/\\[\\[(' . self::$categoryNamespace . '):([^]]+)]]\\n?/i', array('self', 'replaceCallback'), $text);
     $result = array('text' => $text, 'categories' => self::$categories);
     $maybeIndex = count(self::$maybeCategory);
     if ($maybeIndex) {
         //look for category ending
         //TODO: this will not catch [[Category:Abc<noinclude>]]</noinclude>
         if (self::$nodeLevel == self::$maybeCategory[$maybeIndex - 1]['level'] && preg_match('/^([^[]*?]])/', $text, $match)) {
             $text = preg_replace('/^[^[]*?]]/', '', $text, 1);
             self::$maybeCategory[$maybeIndex - 1]['end'] = $match[1];
             self::$maybeCategory[$maybeIndex - 1]['beginSibblingsBefore'] = self::$maybeCategoryBegin[self::$nodeLevel];
         }
     }
     if (preg_match('/(\\[\\[(?:' . self::$categoryNamespace . '):.*$)/i', $text, $match)) {
         self::$maybeCategory[$maybeIndex] = array('namespace' => $match[1], 'begin' => $match[1], 'level' => self::$nodeLevel);
         self::$maybeCategoryBegin[self::$nodeLevel] = 0;
     }
     return $result;
 }