/** * Helper function to create a new Array within 'Arrays' extension. Takes care of different versions * as well as the old 'ArrayExtension'. */ protected function createArray($array) { global $wgArrayExtension; $arrayId = $this->mArrayName; if (defined('ExtArrays::VERSION')) { // 'Arrays' extension 2+ global $wgParser; /** ToDo: is there a way to get the actual parser which has started the query? */ ExtArrays::get($wgParser)->createArray($arrayId, $array); return true; } // compatbility to 'ArrayExtension' extension before 2.0: if (!isset($wgArrayExtension)) { //Hash extension is not installed in this wiki return false; } $version = null; if (defined('ArrayExtension::VERSION')) { $version = ArrayExtension::VERSION; } elseif (defined('ExtArrayExtension::VERSION')) { $version = ExtArrayExtension::VERSION; } if ($version !== null && version_compare($version, '1.3.2', '>=')) { // ArrayExtension 1.3.2+ $wgArrayExtension->createArray($arrayId, $array); } else { // dirty way $wgArrayExtension->mArrays[trim($arrayId)] = $array; } return true; }
/** * Sends an array to ArrayExtension and stores it. Takes care of different ArrayExtension versions. * The array should be sanitized in case ArrayExtension before 2.0 is being used. * * @since 1.0 * * @return boolean whether array was sent to ArrayExtension successful */ protected static function setArrayExtensionArray($parser, $arrayId, $array = array()) { if (class_exists('ExtArrays')) { // ArrayExtension 2.0+ ExtArrays::get($parser)->createArray($arrayId, $array); return true; } elseif (isset($wgArrayExtension) && isset($wgArrayExtension->mArrayExtension)) { // ArrayExtension before 2.0 if (array_key_exists($arrayId, $wgArrayExtension->mArrayExtension)) { // array exist $array = $wgArrayExtension->mArrayExtension[$arrayId]; } else { $array = array(); } } return false; }