/** * 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 htmlqp($document = NULL, $selector = NULL, $options = array()) { self::$qp = false; // I copied and modified the default options from the htmlqp method to provide a custom version for Amslib // NOTE: Hmm....I'm not 100% sure this will work in all circumstances.... $document = iconv("ISO8859-1", "UTF-8", $document); // NOTE: see output buffer trick comment in qp() ob_start(); self::$qp = QueryPath::withHTML($document, $selector, $options); $warnings = ob_get_clean(); if (strlen($warnings)) { Amslib_Debug::log("FAILED TO OBTAIN CLEAN OUTPUT WHEN PROCESSING HTML: error = ", $warnings); } return self::$qp; }
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"); } }