@@ -3,99 +3,99 @@ |
||
| 3 | 3 | requireComponent("../Module/Module.php"); |
| 4 | 4 | requireComponent("../JException/JException.php"); |
| 5 | 5 | abstract class Html extends Module { |
| 6 | - public $template; |
|
| 7 | - public $app; |
|
| 8 | - public $page; |
|
| 9 | - public $tags; |
|
| 10 | - public $jsVars; |
|
| 11 | - public function __construct() { |
|
| 12 | - parent::__construct(); |
|
| 13 | - $this->template = ""; |
|
| 14 | - $this->app = []; |
|
| 15 | - $this->page = []; |
|
| 16 | - $this->jsVars = []; |
|
| 17 | - $this->tags = [ |
|
| 18 | - "css" => [], |
|
| 19 | - "js" => [], |
|
| 20 | - "jsVar" => [], |
|
| 21 | - "base" => "" |
|
| 22 | - ]; |
|
| 23 | - } |
|
| 24 | - public function setParameters( $_parameters = [ "app" => null, "page" => null] ) { |
|
| 25 | - $this->app = $_parameters["app"]; |
|
| 26 | - $this->page = $_parameters["page"]; |
|
| 27 | - } |
|
| 28 | - abstract public function init(); |
|
| 29 | - public function draw() { |
|
| 30 | - if($this->template == "") |
|
| 31 | - throw new JException("The variable \$this->template must be set in class $this->name function init()."); |
|
| 32 | - $server = new ServerVars(); |
|
| 33 | - $this->addDipendences(); |
|
| 34 | - $this->tags["css"] = array_unique($this->tags["css"]); |
|
| 35 | - $this->tags["js"] = array_unique($this->tags["js"]); |
|
| 36 | - $this->tags["base"] = $server->server["RELATIVE"]."/"; |
|
| 37 | - $this->stringifyDipendences(); |
|
| 38 | - return jBlockFile($this->template, $this->tags); |
|
| 39 | - } |
|
| 40 | - public function getCss() { |
|
| 41 | - return $this->getRequire("getCss",".css"); |
|
| 42 | - } |
|
| 43 | - public function getJs() { |
|
| 44 | - return $this->getRequire("getJs",".js"); |
|
| 45 | - } |
|
| 46 | - public function getJsVars() { |
|
| 47 | - return $this->jsVars; |
|
| 48 | - } |
|
| 49 | - public function addJsVar( $_name, $_value ) { |
|
| 50 | - if(!is_string($_name)) |
|
| 51 | - throw new InvalidArgumentException("Parameter name must be a string."); |
|
| 52 | - if(!is_string($_value)) |
|
| 53 | - throw new InvalidArgumentException("Parameter value must be a string."); |
|
| 54 | - $this->jsVars[] = [$_name, $_value]; |
|
| 55 | - } |
|
| 56 | - public function addJsVars( $_array ) { |
|
| 57 | - if(!is_array($_array)) |
|
| 58 | - throw new InvalidArgumentException("Parameter must be an array."); |
|
| 59 | - foreach ($_array as $value) |
|
| 60 | - $this->addJsVar($value[0], $value[1]); |
|
| 61 | - } |
|
| 62 | - protected function stringifyDipendences() { |
|
| 63 | - $tempStr = ""; |
|
| 64 | - $timeParameter = "?t=".time(); |
|
| 65 | - $time = ($this->app->cache->css == true) ? "" : $timeParameter; |
|
| 66 | - foreach ($this->tags["css"] as $i) |
|
| 67 | - $tempStr .= "<link rel='stylesheet' href='$i$time'>"; |
|
| 68 | - $this->tags["css"] = $tempStr; |
|
| 69 | - $tempStr = ""; |
|
| 70 | - $time = ($this->app->cache->js == true) ? "" : $timeParameter; |
|
| 71 | - foreach ($this->tags["js"] as $i) |
|
| 72 | - $tempStr .= "<script src='$i$time'></script>"; |
|
| 73 | - $this->tags["js"] = $tempStr; |
|
| 74 | - $tempStr = ""; |
|
| 75 | - $tempStr .= "<script type='text/javascript'>"; |
|
| 76 | - foreach ($this->tags["jsVar"] as $i) |
|
| 77 | - $tempStr .= " $i[0] = $i[1];\n"; |
|
| 78 | - $tempStr .= "</script>"; |
|
| 79 | - $this->tags["jsVar"] = $tempStr; |
|
| 80 | - } |
|
| 81 | - protected function addDipendences() { |
|
| 82 | - $this->tags["css"] = $this->getCss(); |
|
| 83 | - $this->tags["js"] = $this->getJs(); |
|
| 84 | - $this->tags["jsVar"] = $this->getJsVars(); |
|
| 85 | - } |
|
| 86 | - protected function getRequire( $_function, $_extenction) { |
|
| 87 | - $temp = []; |
|
| 88 | - $filesRequired = $this->getFilesRequired(); |
|
| 89 | - $files = $this->getFiles(); |
|
| 90 | - foreach ($filesRequired as $i) |
|
| 91 | - if (!is_array($i) && strpos($i, $_extenction) !== FALSE) |
|
| 92 | - $temp[] = $i; |
|
| 93 | - foreach ($this->modules as $i) |
|
| 94 | - $temp = array_merge( $temp, $i->$_function() ); |
|
| 95 | - foreach ($files as $i) |
|
| 96 | - if (!is_array($i) && strpos($i, $_extenction) !== FALSE) |
|
| 97 | - $temp[] = $i; |
|
| 98 | - return $temp; |
|
| 99 | - } |
|
| 6 | + public $template; |
|
| 7 | + public $app; |
|
| 8 | + public $page; |
|
| 9 | + public $tags; |
|
| 10 | + public $jsVars; |
|
| 11 | + public function __construct() { |
|
| 12 | + parent::__construct(); |
|
| 13 | + $this->template = ""; |
|
| 14 | + $this->app = []; |
|
| 15 | + $this->page = []; |
|
| 16 | + $this->jsVars = []; |
|
| 17 | + $this->tags = [ |
|
| 18 | + "css" => [], |
|
| 19 | + "js" => [], |
|
| 20 | + "jsVar" => [], |
|
| 21 | + "base" => "" |
|
| 22 | + ]; |
|
| 23 | + } |
|
| 24 | + public function setParameters( $_parameters = [ "app" => null, "page" => null] ) { |
|
| 25 | + $this->app = $_parameters["app"]; |
|
| 26 | + $this->page = $_parameters["page"]; |
|
| 27 | + } |
|
| 28 | + abstract public function init(); |
|
| 29 | + public function draw() { |
|
| 30 | + if($this->template == "") |
|
| 31 | + throw new JException("The variable \$this->template must be set in class $this->name function init()."); |
|
| 32 | + $server = new ServerVars(); |
|
| 33 | + $this->addDipendences(); |
|
| 34 | + $this->tags["css"] = array_unique($this->tags["css"]); |
|
| 35 | + $this->tags["js"] = array_unique($this->tags["js"]); |
|
| 36 | + $this->tags["base"] = $server->server["RELATIVE"]."/"; |
|
| 37 | + $this->stringifyDipendences(); |
|
| 38 | + return jBlockFile($this->template, $this->tags); |
|
| 39 | + } |
|
| 40 | + public function getCss() { |
|
| 41 | + return $this->getRequire("getCss",".css"); |
|
| 42 | + } |
|
| 43 | + public function getJs() { |
|
| 44 | + return $this->getRequire("getJs",".js"); |
|
| 45 | + } |
|
| 46 | + public function getJsVars() { |
|
| 47 | + return $this->jsVars; |
|
| 48 | + } |
|
| 49 | + public function addJsVar( $_name, $_value ) { |
|
| 50 | + if(!is_string($_name)) |
|
| 51 | + throw new InvalidArgumentException("Parameter name must be a string."); |
|
| 52 | + if(!is_string($_value)) |
|
| 53 | + throw new InvalidArgumentException("Parameter value must be a string."); |
|
| 54 | + $this->jsVars[] = [$_name, $_value]; |
|
| 55 | + } |
|
| 56 | + public function addJsVars( $_array ) { |
|
| 57 | + if(!is_array($_array)) |
|
| 58 | + throw new InvalidArgumentException("Parameter must be an array."); |
|
| 59 | + foreach ($_array as $value) |
|
| 60 | + $this->addJsVar($value[0], $value[1]); |
|
| 61 | + } |
|
| 62 | + protected function stringifyDipendences() { |
|
| 63 | + $tempStr = ""; |
|
| 64 | + $timeParameter = "?t=".time(); |
|
| 65 | + $time = ($this->app->cache->css == true) ? "" : $timeParameter; |
|
| 66 | + foreach ($this->tags["css"] as $i) |
|
| 67 | + $tempStr .= "<link rel='stylesheet' href='$i$time'>"; |
|
| 68 | + $this->tags["css"] = $tempStr; |
|
| 69 | + $tempStr = ""; |
|
| 70 | + $time = ($this->app->cache->js == true) ? "" : $timeParameter; |
|
| 71 | + foreach ($this->tags["js"] as $i) |
|
| 72 | + $tempStr .= "<script src='$i$time'></script>"; |
|
| 73 | + $this->tags["js"] = $tempStr; |
|
| 74 | + $tempStr = ""; |
|
| 75 | + $tempStr .= "<script type='text/javascript'>"; |
|
| 76 | + foreach ($this->tags["jsVar"] as $i) |
|
| 77 | + $tempStr .= " $i[0] = $i[1];\n"; |
|
| 78 | + $tempStr .= "</script>"; |
|
| 79 | + $this->tags["jsVar"] = $tempStr; |
|
| 80 | + } |
|
| 81 | + protected function addDipendences() { |
|
| 82 | + $this->tags["css"] = $this->getCss(); |
|
| 83 | + $this->tags["js"] = $this->getJs(); |
|
| 84 | + $this->tags["jsVar"] = $this->getJsVars(); |
|
| 85 | + } |
|
| 86 | + protected function getRequire( $_function, $_extenction) { |
|
| 87 | + $temp = []; |
|
| 88 | + $filesRequired = $this->getFilesRequired(); |
|
| 89 | + $files = $this->getFiles(); |
|
| 90 | + foreach ($filesRequired as $i) |
|
| 91 | + if (!is_array($i) && strpos($i, $_extenction) !== FALSE) |
|
| 92 | + $temp[] = $i; |
|
| 93 | + foreach ($this->modules as $i) |
|
| 94 | + $temp = array_merge( $temp, $i->$_function() ); |
|
| 95 | + foreach ($files as $i) |
|
| 96 | + if (!is_array($i) && strpos($i, $_extenction) !== FALSE) |
|
| 97 | + $temp[] = $i; |
|
| 98 | + return $temp; |
|
| 99 | + } |
|
| 100 | 100 | } |
| 101 | 101 | ?> |
@@ -2,34 +2,34 @@ |
||
| 2 | 2 | jRequire("../Query/Query.php"); |
| 3 | 3 | jRequire("../File/File.php"); |
| 4 | 4 | class Module { |
| 5 | - use Query { |
|
| 6 | - Query::__construct as private __queryConstruct; |
|
| 7 | - } |
|
| 8 | - use File { |
|
| 9 | - File::__construct as private __fileConstruct; |
|
| 10 | - } |
|
| 11 | - public $name; |
|
| 12 | - public $modules; |
|
| 13 | - public function __construct() { |
|
| 14 | - $this->name = get_class($this); |
|
| 15 | - $this->modules = []; |
|
| 16 | - $this->__queryConstruct(); |
|
| 17 | - $this->__fileConstruct(); |
|
| 18 | - } |
|
| 19 | - public function addModules( $_modules ) { |
|
| 20 | - if(!is_array($_modules)) |
|
| 21 | - throw new JException("Parameter must be an array."); |
|
| 22 | - foreach ($_modules as $value) |
|
| 23 | - $this->addModule($value); |
|
| 24 | - } |
|
| 25 | - public function addModule( $_module ) { |
|
| 26 | - if(!is_object($_module)) |
|
| 27 | - throw new JException("Parameter must be a object."); |
|
| 28 | - if(! is_subclass_of ($_module, "Module")) |
|
| 29 | - throw new JException("Parameter must be a object inherited from Module object."); |
|
| 30 | - $this->modules[$_module->name] = $_module; |
|
| 31 | - if($this->currentConnection) |
|
| 32 | - $this->modules[$_module->name]->addConnectionMan($this->currentConnection); |
|
| 33 | - } |
|
| 5 | + use Query { |
|
| 6 | + Query::__construct as private __queryConstruct; |
|
| 7 | + } |
|
| 8 | + use File { |
|
| 9 | + File::__construct as private __fileConstruct; |
|
| 10 | + } |
|
| 11 | + public $name; |
|
| 12 | + public $modules; |
|
| 13 | + public function __construct() { |
|
| 14 | + $this->name = get_class($this); |
|
| 15 | + $this->modules = []; |
|
| 16 | + $this->__queryConstruct(); |
|
| 17 | + $this->__fileConstruct(); |
|
| 18 | + } |
|
| 19 | + public function addModules( $_modules ) { |
|
| 20 | + if(!is_array($_modules)) |
|
| 21 | + throw new JException("Parameter must be an array."); |
|
| 22 | + foreach ($_modules as $value) |
|
| 23 | + $this->addModule($value); |
|
| 24 | + } |
|
| 25 | + public function addModule( $_module ) { |
|
| 26 | + if(!is_object($_module)) |
|
| 27 | + throw new JException("Parameter must be a object."); |
|
| 28 | + if(! is_subclass_of ($_module, "Module")) |
|
| 29 | + throw new JException("Parameter must be a object inherited from Module object."); |
|
| 30 | + $this->modules[$_module->name] = $_module; |
|
| 31 | + if($this->currentConnection) |
|
| 32 | + $this->modules[$_module->name]->addConnectionMan($this->currentConnection); |
|
| 33 | + } |
|
| 34 | 34 | } |
| 35 | 35 | ?> |
@@ -1,19 +1,19 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class JConfig { |
| 3 | - public function __construct( $_path ) { |
|
| 4 | - if(!is_string($_path)) |
|
| 5 | - throw new JException("Path must be a string."); |
|
| 6 | - if(!file_exists($_path)) |
|
| 7 | - throw new JException("File [$_path] not found."); |
|
| 8 | - $data = file_get_contents($_path); |
|
| 9 | - $data = json_decode($data); |
|
| 10 | - if($data === NULL) |
|
| 11 | - throw new JException("Invalid file data. [$_path]"); |
|
| 12 | - if(is_object($data)) |
|
| 13 | - foreach (get_object_vars($data) as $key => $value) |
|
| 14 | - $this->$key = $value; |
|
| 15 | - if(is_array($data)) |
|
| 16 | - $this->data = $data; |
|
| 17 | - } |
|
| 3 | + public function __construct( $_path ) { |
|
| 4 | + if(!is_string($_path)) |
|
| 5 | + throw new JException("Path must be a string."); |
|
| 6 | + if(!file_exists($_path)) |
|
| 7 | + throw new JException("File [$_path] not found."); |
|
| 8 | + $data = file_get_contents($_path); |
|
| 9 | + $data = json_decode($data); |
|
| 10 | + if($data === NULL) |
|
| 11 | + throw new JException("Invalid file data. [$_path]"); |
|
| 12 | + if(is_object($data)) |
|
| 13 | + foreach (get_object_vars($data) as $key => $value) |
|
| 14 | + $this->$key = $value; |
|
| 15 | + if(is_array($data)) |
|
| 16 | + $this->data = $data; |
|
| 17 | + } |
|
| 18 | 18 | } |
| 19 | 19 | ?> |