public function process($plugin, $key, $callback)
 {
     $callback = is_string($callback) ? array($plugin, $callback) : $callback;
     $callback = Amslib_Plugin::getCallback($callback);
     if (!$this->queryPath || !is_callable($callback)) {
         $callback = $callback instanceof Closure ? "{closure}" : $callback;
         Amslib_Debug::log("QueryPath or callback not valid", $plugin->getName(), $key, $callback);
         return;
     }
     try {
         $results = $this->queryPath->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, $plugin);
     }
 }
示例#2
0
 public function configPath($name, $array, $object)
 {
     if (!array_key_exists("child", $array)) {
         return;
     }
     foreach (Amslib_Array::valid($array["child"]) as $c) {
         $v = Amslib_Plugin::expandPath($c["value"]);
         if ($c["tag"] == "include") {
             Amslib::addIncludePath(Amslib_File::absolute($v));
         } else {
             Amslib_Website::setPath($c["tag"], $v);
             switch ($c["tag"]) {
                 case "plugin":
                     Amslib_Plugin_Manager::addLocation($v);
                     break;
                 case "docroot":
                     Amslib_File::documentRoot($v);
                     break;
             }
         }
     }
 }
 /**
  * 	method:	setConfigSource
  *
  * 	Sets the configuration source and initialises all the selectors to import this source
  *
  * 	parameters:
  * 		$config	-	The configuration source to use
  *
  * 	notes:
  * 		-	Thanks alfonso (05/05/2014) for realising I should have $config=NULL to match the parent method :( oops
  */
 public function setConfigSource($config = NULL)
 {
     parent::setConfigSource($config);
     $callback = array(get_class($this->source), "initialiseSelectors");
     if (is_callable($callback)) {
         //	Initialise all the selectors
         call_user_func($callback);
         return true;
     }
     Amslib_Debug::log("initialiseSelectors not available", $callback);
     return false;
 }
示例#4
0
 public function installHandlers($group, $output, $handlerList)
 {
     foreach (Amslib_Array::valid($handlerList) as $h) {
         $c = $h;
         //	"framework" is claimed as a standard name for amslib and is no longer usable
         //	by other plugins, I'm not sure if this is still true, but I should evaluate
         //	whether it causes a problem or not
         if (array_key_exists("plugin", $h) && $h["plugin"] == "framework") {
             $c["plugin"] = false;
         } else {
             if (!array_key_exists("plugin", $c)) {
                 $c["plugin"] = $group;
             }
             if (!array_key_exists("object", $c)) {
                 $c["object"] = false;
             }
         }
         //  set the handler plugin from the callback plugin
         $h["plugin"] = $c["plugin"];
         $callback = Amslib_Plugin::getCallback(array_filter(array($c["plugin"], $c["object"], $c["method"])));
         $params = array($h["plugin"], $callback, $h["input"], $h["record"], $h["global"], $h["failure"]);
         if ($h["type"] == "service") {
             $method = "setHandler";
             array_unshift($params, $output);
         } else {
             $method = "setTerminator";
             array_unshift($params, str_replace("terminator_", "", $h["type"]));
         }
         call_user_func_array(array($this, $method), $params);
     }
 }
示例#5
0
 public static function addJavascript($plugin, $javascript)
 {
     Amslib_Debug::log("DEPRECATED METHOD");
     return Amslib_Plugin::addJavascript($plugin, $javascript);
 }