From e5a0df37fc6971a5b1fd72f7b42d7e7bfbe236b1 Mon Sep 17 00:00:00 2001 From: Anton Terekhov Date: Wed, 21 Nov 2012 17:44:52 +0400 Subject: [PATCH] Added FormViewHelper @method form() to PHPView --- view/PHPView.php | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/view/PHPView.php b/view/PHPView.php index 8c74c9d..877f7de 100644 --- a/view/PHPView.php +++ b/view/PHPView.php @@ -5,8 +5,6 @@ * @package Majestic * @subpackage View * @since 2010-02-25 - * @version SVN: $Id$ - * @filesource $URL$ */ /** @@ -15,17 +13,22 @@ * @method HeadViewHelper head() head(string $string = false) Append another string to HEAD section of Layout * @method MsgViewHelper msg() msg(string $msg = null, string $type = null) Set a message to display for user in Layout * @method TitleViewHelper title() title(string $string = false) Append another section for TITLE of Layout + * @method FormViewHelper form() form(string $form = null) Get form values from session * */ class PHPView implements iView { - - protected $path = ''; + + protected $path = ''; + protected $variables = array(); - protected $helpers = array(); + + protected $helpers = array(); + protected $extension = '.phtml'; - protected $template = ''; - + + protected $template = ''; + public function __construct($config) { if (!isset($config['path'])) { @@ -33,17 +36,17 @@ class PHPView implements iView } $this->setPath($config['path']); } - + public function getPath() { return $this->path; } - + public function setPath($path) { $this->path = $path; } - + /** * @param Action $object */ @@ -53,7 +56,7 @@ class PHPView implements iView $this->assign($name, $value); } } - + /** * @param string $name * @param mixed $value @@ -62,7 +65,7 @@ class PHPView implements iView { $this->variables[$name] = $value; } - + /** * @param string $name * @param mixed $value @@ -75,7 +78,7 @@ class PHPView implements iView $this->variables[$name] = $value; } } - + /** * @param string $name * @param mixed $value @@ -88,7 +91,7 @@ class PHPView implements iView $this->variables[$name] = $value; } } - + public function fetch($template) { $this->template = $this->getTemplatePath($template); @@ -97,20 +100,20 @@ class PHPView implements iView ob_start(); if (!is_readable($this->template)) { ob_clean(); - throw new GeneralException('Template "' . $this->template .'" not found.'); + throw new GeneralException('Template "' . $this->template . '" not found.'); } include($this->template); return ob_get_clean(); } - + public function escape($var) { return htmlentities($var, ENT_QUOTES, 'UTF-8'); } - + /** * Helpers call - * + * * @param mixed $name * @param mixed $args * @return ViewHelper @@ -120,7 +123,7 @@ class PHPView implements iView $helper = $this->getHelper($name); return call_user_func_array(array($helper, $name), $args); } - + protected function getHelper($name) { if (!isset($this->helpers[$name])) { @@ -132,7 +135,7 @@ class PHPView implements iView } return $this->helpers[$name]; } - + protected function getTemplatePath($template) { return $this->path . $template . $this->extension;