コード例 #1
0
ファイル: Amslib_COOKIE.php プロジェクト: hakosh/amslib
 /**
  * 	method:	set
  *
  * 	todo: write documentation
  */
 public static function set($key, $value, $expire_days, $path, $hash = true)
 {
     $value = $hash ? Amslib::getRandomCode($value) : $value;
     $expire_days = intval($expire_days);
     if (!$expire_days) {
         $expire_days = 30;
     }
     setcookie($key, $value, time() + 60 * 60 * 24 * $expire_days, $path);
     return $value;
 }
コード例 #2
0
ファイル: Amslib_Router.php プロジェクト: hakosh/amslib
 /**
  * 	method:	initialise
  *
  * 	todo: write documentation
  */
 public static function initialise()
 {
     if (self::$is_initialised) {
         return;
     }
     $search = array_merge($_SERVER, $_GET);
     self::$pathList["__WEBSITE_ROOT__"] = $search["__WEBSITE_ROOT__"];
     self::$path = NULL;
     self::$base = self::getPath("__WEBSITE_ROOT__");
     if (self::$base) {
         //	Obtain the path within the website, without the website base
         //	we use this to calculate the path inside the website, not relative to the document root
         self::$path = Amslib_String::lchop($_SERVER["REQUEST_URI"], self::$base);
         self::$path = Amslib_String::rchop(self::$path, "?");
         self::$path = Amslib_File::reduceSlashes("/" . self::$path . "/");
     }
     //	Now automatically load the amslib routers configuration as the framework system
     //	This allows amslib to add routes the system can use to import/export router configurations
     //	This isn't part of your application, this is part of the system and used to self-configure
     self::load(Amslib::locate() . "/router/router.xml", "xml", "framework");
     self::$is_initialised = true;
     //	remove this from the $_GET superglobal, it's kind of annoying to keep finding it in the application code
     Amslib_GET::delete("__WEBSITE_ROOT__");
 }
コード例 #3
0
ファイル: Amslib_Plugin.php プロジェクト: hakosh/amslib
 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;
             }
         }
     }
 }
コード例 #4
0
ファイル: Amslib.php プロジェクト: hakosh/amslib
 function amslib_autoload_exception($c)
 {
     if ($c == __CLASS__) {
         return false;
     }
     $result = false;
     if (strpos($c, '\\') === false) {
         $e = new Exception();
         $t = $e->getTrace();
         if (isset($t[1]) && isset($t[1]["file"])) {
             $result = Amslib::requireFile(dirname($t[1]["file"]) . "/{$c}.php");
             if ($result && !Amslib::autoloaderStatus("exception")) {
                 Amslib_Debug::log("EXCEPTION AUTOLOADER: we loaded the class '{$c}' this is not efficient");
                 Amslib_Debug::log("EXCEPTION AUTOLOADER: call Amslib::autoloader_exception(true,true) to remove this warning");
             }
         }
     }
     return $result;
 }
コード例 #5
0
 /**
  * 	method:	__construct
  *
  * 	todo: write documentation
  */
 public function __construct($name, $location, $config = NULL)
 {
     parent::__construct();
     //	unless I think of a reason to not do this, always initialise sessions
     @session_start();
     //	This is needed so non-routed-services will work without modification
     //	NOTE: probably I shouldn't need to do this, I need to find a way to make this redundant
     Amslib_Router::initialise();
     //	NOTE: I think that this method is redundant and the system should do it for me
     //	NOTE: I'm not sure whether this method is actually useful anymore, I think it's out of date maybe
     Amslib_Website::set();
     $base = Amslib_Router::getBase();
     Amslib_Website::setPath("amslib", Amslib::locate());
     Amslib_Website::setPath("website", $base);
     Amslib_Website::setPath("website_ext", Amslib_Router_URL::externalURL($base));
     Amslib_Website::setPath("host", Amslib_Router_URL::externalURL());
     //	NOTE: I don't think I want this __ADMIN__ parameter anymore
     Amslib_Website::setPath("admin", "__ADMIN__");
     Amslib_Website::setPath("plugin", "__PLUGIN__");
     Amslib_Website::setPath("docroot", Amslib_File::documentRoot());
     $this->completionCallback = array();
     //	Set the name, location and config of the plugin that was found in the hard disk
     $this->setName($name);
     $this->setLocation($location);
     $this->setConfigSource($config);
 }
コード例 #6
0
ファイル: Amslib_MVC.php プロジェクト: hakosh/amslib
 /**
  * 	method:	renderView
  *
  * 	todo: write documentation
  */
 public function renderView($view, $params = NULL)
 {
     if (!is_string($view) || !isset($this->view[$view])) {
         Amslib_Debug::log("stack_trace", "Unable to find view in structure", $this->getName(), $view, $this->view);
         return "";
     }
     if ($params == "inherit") {
         $params = $this->getViewParam();
     }
     if (!is_array($params)) {
         $params = array();
     }
     $global = $this->getViewParam(NULL, NULL, true);
     if (!empty($global)) {
         $params = array_merge($global, $params);
     }
     //	Set the parameters that were used for rendering this view,
     //	useful when wanting to pass along to various child views.
     if (!empty($params)) {
         $this->setViewParam($params);
     }
     if (Amslib_Array::hasKeys($params, array("api", "wt", "ct"))) {
         Amslib_Debug::log("ERROR: A reserved key was detected in this array,\n\t\t\t\t\tthis might result in subtle errors, please remove 'api', 'wt' or 'ct',\n\t\t\t\t\tthey are used by the framework to provide access to the api object, and the translators");
     }
     $params["api"] = $this;
     //	FIXME: what if multiple translators of the same type are defined? they would start to clash
     $params["wt"] = $this->getTranslator("website");
     $params["ct"] = $this->getTranslator("content");
     return Amslib::requireFile($this->view[$view], $params, true);
 }