/** * method: autoloadResources * * todo: write documentation */ protected function autoloadResources() { // STEP 1: Autoload all resources from each plugin as they are requested foreach (Amslib_Plugin_Manager::listPlugin() as $name) { $p = Amslib_Plugin_Manager::getAPI($name); if ($p) { $p->autoloadResources(); } else { Amslib_Debug::log("plugin not found?", $p); } } $default = Amslib_Router::getRouteParam("plugin"); $route = Amslib_Router::getRoute(); // STEP 2: Autoload all resources which are bound the current route. // hack into place the adding or removing of all the stylesheets and javascripts foreach (Amslib_Array::valid(Amslib_Router::getJavascript()) as $j) { // datatables does't load because it's trying with the wrong plugin $name = isset($j["plugin"]) ? str_replace("__CURRENT_PLUGIN__", $route["group"], $j["plugin"]) : $default; $plugin = Amslib_Plugin_Manager::getAPI($name); if ($plugin) { if (isset($j["remove"])) { Amslib_Resource::removeJavascript($j["value"]); } else { $plugin->addJavascript($j["value"]); } } } foreach (Amslib_Array::valid(Amslib_Router::getStylesheet()) as $c) { $name = isset($c["plugin"]) ? str_replace("__CURRENT_PLUGIN__", $route["group"], $c["plugin"]) : $default; $plugin = Amslib_Plugin_Manager::getAPI($name); if ($plugin) { if (isset($c["remove"])) { Amslib_Resource::removeStylesheet($c["value"]); } else { $plugin->addStylesheet($c["value"]); } } } }
public static function processExport() { foreach (self::$export as $key => $list) { foreach ($list as $name => $value) { $src = is_string($value["src"]) ? self::getPlugin($value["src"]) : $value["src"]; $dst = is_string($value["dst"]) ? self::getPlugin($value["dst"]) : $value["dst"]; $data = false; if (!$src || !$dst) { $sname = is_object($src) ? $src->getName() : "searched: {$value["src"]}"; $dname = is_object($dst) ? $dst->getName() : "searched: {$value["dst"]}"; Amslib_Debug::log("plugin list", Amslib_Plugin_Manager::listPlugin()); Amslib_Debug::log("plugin invalid", intval(is_object($src)) . ", " . intval(is_object($dst)), $sname, $dname, Amslib_Router::getPath()); continue; } switch ($value["key"]) { case "stylesheet": case "javascript": case "font": die("[DIE]EXPORT[{$key}] => " . Amslib_Debug::pdump(true, array($src->getName(), $dst->getName(), $value["key"], $value["val"]))); break; case "view": case "value": // NOTE: if I could change getValue to this, I could refactor all of these branches // together maybe into something very generic // NOTE: the new import/export system works slightly differently from the old one, // we push directly into the import/export queues the information that we // want to pass and it doesn't enter the host plugin, this way, we can skip // a lot of bullshit with regard to internal data and data which is destined // for other plugins, the getValue method should in this case, circumstantially // create objects or just parse the data out of the structure, but it's not // about "getting" the value from the pluing, the $value variable already has // it and in many cases we don't need to do anything except return a particular // key depending on the stucture or type of that data, but in the case of // translators, objects or models, we need to ask the host plugin to create // the object on our behalf and then return and use it, because it might be // that the host plugin is the only plugin which has the correct functionality // necessary to create that object, in these cases getValue will do more than // just return a particular key, but will actually process the input data into // an "output data" to use //$data = $src->getValue($value); $dst->setValue($value["key"], $value["val"]); break; case "service": //Amslib_FirePHP::output("export",$item); // Hmmm, I need a test case cause otherwise I won't know if this works break; case "image": $dst->setValue($value["key"], $value["val"]); break; // We do nothing special with these entries, we simply pass them // We do nothing special with these entries, we simply pass them case "model": case "translator": default: // NOTE: I should change $value["key"] here to $value and make "key" something getValue uses internally $data = $src->getValue($value["key"]); $dst->setValue($value["key"], $data); break; } } } self::$export = NULL; }