/** * Check if two bits of wikitext have the same images * @param a First wiki-text to test * @param b Second wiki-text to test * @param altImageTags Array of alternative image regex to use such as imagen,... * @return True if the images are the same, and false otherwise */ public static function haveSameImages($a, $b, $altImageTags = array()) { preg_match_all(self::getImageRegex($altImageTags), $a, $matches); preg_match_all(self::getImageRegex($altImageTags), $b, $matches2); if (sizeof($matches) != sizeof($matches2)) { return false; } for ($n = 0; $n < sizeof($matches); $n++) { if (is_array($matches[$n])) { if (sizeof($matches[$n]) != sizeof($matches2[$n])) { return false; } for ($m = 0; $m < sizeof($matches[$n]); $m++) { $matches[$n][$m] = Wikitext::removeImageCaption($matches[$n][$m]); $matches2[$n][$m] = Wikitext::removeImageCaption($matches2[$n][$m]); if ($matches[$n][$m] != $matches2[$n][$m]) { return false; } } } else { $matches[$n][$m] = Wikitext::removeImageCaption($matches[$n][$m]); $matches2[$n][$m] = Wikitext::removeImageCaption($matches2[$n][$m]); if ($matches[$n] != $matches2[$n]) { return false; } } } return true; }