From 07bfaa650ebe3aac4a30a85ef982882ff1766496 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Wed, 31 Jul 2013 00:53:28 +0300 Subject: [PATCH] simplify directory layout --- ipf/template/contextvars.php | 26 ------------ ipf/template/file.php | 23 ---------- ipf/template/string.php | 23 ---------- {ipf/template => lib}/compiler.php | 0 {ipf/template => lib}/context.php | 25 +++++++++++ {ipf/template => lib}/environment.php | 0 .../environment_filesystem.php | 0 {ipf => lib}/exception.php | 0 {ipf/template => lib}/modifier.php | 0 {ipf/template => lib}/safestring.php | 0 {ipf/template => lib}/tag.php | 0 {ipf => lib}/template.php | 42 +++++++++++++++++++ 12 files changed, 67 insertions(+), 72 deletions(-) delete mode 100644 ipf/template/contextvars.php delete mode 100644 ipf/template/file.php delete mode 100644 ipf/template/string.php rename {ipf/template => lib}/compiler.php (100%) rename {ipf/template => lib}/context.php (63%) rename {ipf/template => lib}/environment.php (100%) rename ipf/template/environment/filesystem.php => lib/environment_filesystem.php (100%) rename {ipf => lib}/exception.php (100%) rename {ipf/template => lib}/modifier.php (100%) rename {ipf/template => lib}/safestring.php (100%) rename {ipf/template => lib}/tag.php (100%) rename {ipf => lib}/template.php (50%) diff --git a/ipf/template/contextvars.php b/ipf/template/contextvars.php deleted file mode 100644 index 637c12e..0000000 --- a/ipf/template/contextvars.php +++ /dev/null @@ -1,26 +0,0 @@ -offsetExists($prop)) { - return ''; - } - return parent::offsetGet($prop); - } - - function __get($prop) - { - if (isset($this->$prop)) { - return $this->$prop; - } else { - return $this->offsetGet($prop); - } - } - - function __toString() - { - return var_export($this, true); - } -} diff --git a/ipf/template/file.php b/ipf/template/file.php deleted file mode 100644 index 2c813eb..0000000 --- a/ipf/template/file.php +++ /dev/null @@ -1,23 +0,0 @@ -tpl = $template; - } - - public function __toString() - { - return $this->tpl; - } - - protected function content() - { - return $this->environment->loadTemplateFile($this->tpl); - } -} - diff --git a/ipf/template/string.php b/ipf/template/string.php deleted file mode 100644 index 835e55a..0000000 --- a/ipf/template/string.php +++ /dev/null @@ -1,23 +0,0 @@ -tpl = $template; - } - - public function __toString() - { - return $this->tpl; - } - - protected function content() - { - return $this->tpl; - } -} - diff --git a/ipf/template/compiler.php b/lib/compiler.php similarity index 100% rename from ipf/template/compiler.php rename to lib/compiler.php diff --git a/ipf/template/context.php b/lib/context.php similarity index 63% rename from ipf/template/context.php rename to lib/context.php index c6fd6c0..09dc03c 100644 --- a/ipf/template/context.php +++ b/lib/context.php @@ -41,3 +41,28 @@ class IPF_Template_Context } } +class IPF_Template_ContextVars extends ArrayObject +{ + function offsetGet($prop) + { + if (!$this->offsetExists($prop)) { + return ''; + } + return parent::offsetGet($prop); + } + + function __get($prop) + { + if (isset($this->$prop)) { + return $this->$prop; + } else { + return $this->offsetGet($prop); + } + } + + function __toString() + { + return var_export($this, true); + } +} + diff --git a/ipf/template/environment.php b/lib/environment.php similarity index 100% rename from ipf/template/environment.php rename to lib/environment.php diff --git a/ipf/template/environment/filesystem.php b/lib/environment_filesystem.php similarity index 100% rename from ipf/template/environment/filesystem.php rename to lib/environment_filesystem.php diff --git a/ipf/exception.php b/lib/exception.php similarity index 100% rename from ipf/exception.php rename to lib/exception.php diff --git a/ipf/template/modifier.php b/lib/modifier.php similarity index 100% rename from ipf/template/modifier.php rename to lib/modifier.php diff --git a/ipf/template/safestring.php b/lib/safestring.php similarity index 100% rename from ipf/template/safestring.php rename to lib/safestring.php diff --git a/ipf/template/tag.php b/lib/tag.php similarity index 100% rename from ipf/template/tag.php rename to lib/tag.php diff --git a/ipf/template.php b/lib/template.php similarity index 50% rename from ipf/template.php rename to lib/template.php index 0c40fee..269d435 100644 --- a/ipf/template.php +++ b/lib/template.php @@ -36,3 +36,45 @@ abstract class IPF_Template } } +class IPF_Template_File extends IPF_Template +{ + private $filename; + + function __construct($filename, IPF_Template_Environment $environment) + { + parent::__construct($environment); + $this->filename = $filename; + } + + public function __toString() + { + return $this->filename; + } + + protected function content() + { + return $this->environment->loadTemplateFile($this->filename); + } +} + +class IPF_Template_String extends IPF_Template +{ + private $template; + + function __construct($template, IPF_Template_Environment $environment) + { + parent::__construct($environment); + $this->template = $template; + } + + public function __toString() + { + return $this->template; + } + + protected function content() + { + return $this->template; + } +} + -- 2.49.0