public static function fnCategorizeGetPageCategories($m_pageObj) { global $wgOut; # Get page contents: $m_pageText = $m_pageObj->textbox1; $arrAllCats = array(); $regulartext = ''; $nowikitext = ''; $cleanedtext = ''; $finaltext = ''; # Check linewise for category links: # Get the first part of the text up until the first <nowiki> tag. $arrBlocks1 = explode("<nowiki>", $m_pageText); $regulartext = $arrBlocks1[0]; # Get and strip categories from the first part $cleanedtext = CategorizeBody::fnCategorizeStripCats($regulartext, $arrAllCats); $finaltext .= $cleanedtext; # Go through the rest of the blocks to find more categories for ($i = 1; $i < count($arrBlocks1); $i++) { $arrBlocks2 = explode("</nowiki>", $arrBlocks1[$i]); // ignore cats here because it is part of the <nowiki> block $nowikitext = $arrBlocks2[0]; // add to final text $finaltext .= '<nowiki>' . $nowikitext . '</nowiki> '; // strip cats here because it's the text after the <nowiki> block $regulartext = $arrBlocks2[1]; $cleanedtext = CategorizeBody::fnCategorizeStripCats($regulartext, $arrAllCats); $finaltext .= ltrim($cleanedtext); } // Place cleaned text back into the text box: $m_pageObj->textbox1 = rtrim($finaltext); return $arrAllCats; }