static function setImageSections($articleText) { global $wgContLang; $sectionArray = array("summary", "steps", "video", "tips", "warnings", "things you'll need", "related wikihows", "ingredients", "sources and citations"); self::$imageArray = array(); $who = WikihowArticleEditor::newFromText($articleText); $nsTxt = "(Image|" . $wgContLang->getNsText(NS_IMAGE) . ")"; foreach ($who->section_array as $section => $sectionText) { if (!in_array($section, $sectionArray)) { $section = "steps"; } if (preg_match_all("@([\\*]*)\\[\\[" . $nsTxt . ":([^\\|\\]]+)[^\\]]*\\]\\]@im", $sectionText, $matches) > 0) { foreach ($matches[3] as $index => $match) { $match = str_replace(" ", "-", $match); if ($section == "steps" && $matches[1][$index] == "*") { self::$imageArray[ucfirst($match)] = "substep"; } else { self::$imageArray[ucfirst($match)] = $section; } } } if (preg_match_all("@\\{\\{largeimage\\|([^\\}]+)\\}\\}@im", $sectionText, $matchesLarge) > 0) { foreach ($matchesLarge[1] as $match) { //apparently some large images still have captions so get rid of everything else $parts = explode("|", $match); $imageName = str_replace(" ", "-", $parts[0]); self::$imageArray[ucfirst($imageName)] = $section; } } } }