note 106372 deleted from language.namespaces by danbrown
| From: | danbrown@php.net | Date: | Fri, 04 Nov 2011 13:59:44 +0000 |
| Subject: | note 106372 deleted from language.namespaces by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-184301@lists.php.net to get a copy of this message | ||
Note Submitter: abdullah aydin
----
class Import
{
private $InternalLibs;
private $ExternalLibs;
// private $IncludedFiles;
private $Type;
final function __construct($Type = NULL)
{
$this->InternalLibs = array("app", "mysql", "sql",
"template", "fb", "user", "quiz", "event");
$this->ExternalLibs = array("cookie", "filter", "globals",
"smarty", "facebook");
// $this->IncludedFiles = get_included_files();
$this->Type = $Type == "external"
? "external"
: "internal";
}
final function __set($name, $value) {}
final function __get($name) {}
final function __clone() {}
final function __destruct() {}
public static function e ()
{
return New self ("external");
}
public static function i ()
{
return New self ("internal");
}
public function Library ($Request = NULL)
{
$Request = strtolower($Request);
if (!class_exists($Request))
{
$IncludePath = INCLUDES_PATH . $this->Type . ".libraries" . DS .
"class." . $Request . ".php";
$ValidLibs = $this->Type == "internal"
? $this->InternalLibs
: $this->ExternalLibs;
if (in_array($Request, $ValidLibs))
return (@include($IncludePath)) === 1
? New self ($this->Type)
: $this->Error(__LINE__, $Request, $IncludePath);
return $this->Error(__LINE__, $Request, $IncludePath, "is not in the valid " .
$this->Type . " library list!");
}
return New self ($this->Type);
}
private function Error ($line = NULL, $Request = "undefined", $IncludePath =
"undefined", $Info = NULL)
{
if (empty($Info))
$Info = !file_exists($IncludePath)
? "Can not import requested library: [$Request], file: [$IncludePath]; does not
exists!"
: "Can not import requested library: [$Request]!";
else
$Info = "Can not import requested library: [$Request], $Info";
Error::Set(__FILE__, __CLASS__, $line, $Info);
return FALSE;
}
}
so use can use it by this way(s);
Import::e()->Library("facebook")->("smarty");
Import::i()->Library("app")->("quiz");
or;
Import::e()->Library("facebook")->Library("smarty")->i()->Library("app");
Import::i()->Library("app")->Library("user")->
e()->Library("smarty");