<?php $path = $search = dirname(__DIR__); do { $file = "{$search}/vendor/autoload.php"; if (file_exists($file)) { require_once $file; break; } else { if (!strlen($search)) { die("Cannot find the composer autoload.php, dying..."); } } } while ($search = rtrim(dirname($search), "/")); $application = new Amslib_Plugin_Application("application", $path); $application->setDebug(true); $application->initialise(); $application->execute();
/** * method: finalisePlugin * * todo: write documentation */ protected function finalisePlugin() { $api = $this->getAPI(); if ($api) { $translators = $api->listTranslators(false); foreach (Amslib_Array::valid($translators) as $name => $object) { if (!$object) { Amslib_Debug::log("we found a translator which was not valid", $name, $object); continue; } // Obtain the language the system should use when printing text $object->setLanguage(Amslib_Plugin_Application::getLanguage($name)); $object->load(); } $api->finalise(); } else { Amslib_Debug::log("plugin not found?", $api); } }
/** * method: setLanguageKey * * Will retrieve the lang_key from the configuration and set it into the static data, ready to use when required * Then if the old key exists in the session, it will upgrade all the existing keys to the new language key, keeping * everything clean and tidy */ public function setLanguageKey() { $k = current(Amslib_Array::filter(Amslib_Array::valid($this->data["value"]), "name", "lang_key", true)); // key wasn't found, do nothing if (empty($k)) { return; } // key was found, attempt to upgrade old keys to new keys $old = self::$langKey; self::$langKey = $k["value"]; // loop through session, find matching keys against the old key, replace with the new keys foreach ($_SESSION as $key => $value) { if (strpos($key, $old) !== false) { unset($_SESSION[$key]); $key = str_replace($old, self::$langKey, $key); Amslib_SESSION::set(Amslib_File::reduceSlashes($key), $value); } } }