/** * method: load * * returns: * Boolean true or false depending on whether it succeeded, there are some codepaths which call setError() * this is because of serious errors which can't be handled at the moment * * NOTE: * - if language is false, you need to call setLanguage before you * call load otherwise the source can't load the correct file */ public function load() { if (!$this->language) { return false; } $dir = $this->getConfig("directory"); $source = Amslib_File::reduceSlashes("{$dir}/{$this->language}.xml"); $filename = false; try { // NOTE: This is ugly and I believe it's a failure of Amslib_File::find() to not do this automatically if (file_exists($source)) { $filename = $source; } else { if (file_exists($f = Amslib_File::find(Amslib_Website::relative($source), true))) { $filename = $f; } else { if (file_exists($f = Amslib_File::find(Amslib_Website::absolute($source), true))) { $filename = $f; } } } if (!$filename) { Amslib_Debug::log("stack_trace", "directory", $dir, "filename", $filename, "language", $this->language); } else { $this->qp = Amslib_QueryPath::qp($filename); return true; } } catch (Exception $e) { Amslib_Debug::log("Exception: ", $e->getMessage(), "file=", $filename, "source=", $source); Amslib_Debug::log("stack_trace"); } return false; }
public static function execCallback($key, $callback, $object = NULL) { if (!self::$qp || !is_callable($callback)) { print "FAILED CALLBACK = " . Amslib_Debug::pdump(true, $callback); return; } try { $results = self::$qp->branch()->find($key); } catch (Exception $e) { Amslib_Debug::log("QueryPath Exception", $e->getMessage); } foreach ($results as $r) { $r = Amslib_QueryPath::toArray($r); call_user_func($callback, $r["tag"], $r, $object); } }
public function execute($plugin) { $filename = $this->getValue("filename"); $this->queryPath = Amslib_QueryPath::qp($filename); $this->executeScan($plugin); $this->executeLoad($plugin); return true; }
/** * method: __construct * * todo: write documentation */ public function __construct($source) { $this->route = false; $this->import = false; $this->valid = false; $filename = false; try { // NOTE: This is ugly and I believe it's a failure of Amslib_File::find() to not do this automatically if (file_exists($source)) { $filename = $source; } else { if (file_exists($f = Amslib_File::find(Amslib_Website::relative($source), true))) { $filename = $f; } else { if (file_exists($f = Amslib_File::find(Amslib_Website::absolute($source), true))) { $filename = $f; } } } if (!$filename) { Amslib_Debug::log("The filename was not valid, we could not getRoutes from this XML Source"); } else { Amslib_QueryPath::qp($filename); Amslib_QueryPath::execCallback("router > path[name]", array($this, "configPath"), $this); Amslib_QueryPath::execCallback("router > service[name]", array($this, "configService"), $this); Amslib_QueryPath::execCallback("router > callback", array($this, "configCallback"), $this); Amslib_QueryPath::execCallback("router > import", array($this, "configImport"), $this); Amslib_QueryPath::execCallback("router > export", array($this, "configExport"), $this); $this->valid = true; } } catch (Exception $e) { Amslib_Debug::log("Exception: ", $e->getMessage(), "file=", $filename, "source=", $source); Amslib_Debug::log("stack_trace"); } }