Code formatting for ViewHelper & tests

This commit is contained in:
Anton Terekhov
2012-11-21 15:43:20 +04:00
parent 0d58a907e5
commit 07a244ca35
11 changed files with 87 additions and 79 deletions

View File

@ -11,9 +11,9 @@
class BreadcrumbViewHelper extends ViewHelper
{
protected $separator = ' > ';
public function breadcrumb($text = false, $href = false)
{
if ($text) {
@ -21,22 +21,22 @@ class BreadcrumbViewHelper extends ViewHelper
}
return $this;
}
public function prepend($text, $href)
{
Registry::set(__CLASS__, array($text => $href) + Registry::get(__CLASS__, array()));
}
public function append($text, $href)
{
Registry::set(__CLASS__, Registry::get(__CLASS__, array()) + array($text => $href));
}
public function setSeparator($sep)
{
$this->separator = $sep;
}
public function __toString()
{
$data = array();

View File

@ -11,9 +11,9 @@
class GetViewHelper extends ViewHelper
{
protected $get;
public function get($replace)
{
$get = $this->getSanitizedRequest();
@ -29,7 +29,7 @@ class GetViewHelper extends ViewHelper
}
return '?' . $this->view->escape(implode('&', $get));
}
protected function getSanitizedRequest()
{
if ($this->get === null) {
@ -40,10 +40,10 @@ class GetViewHelper extends ViewHelper
}
return $this->get;
}
protected function impl($name, $value)
{
if (is_array($value)){
if (is_array($value)) {
$result = array();
foreach ($value as $key => $val) {
$result[] = $name . '[' . $key . ']=' . urlencode($val);

View File

@ -11,7 +11,7 @@
class HeadViewHelper extends ViewHelper
{
public function head($string = false)
{
if ($string) {
@ -21,7 +21,7 @@ class HeadViewHelper extends ViewHelper
}
return $this;
}
public function __toString()
{
return implode("\n ", Registry::get(__CLASS__, array())) . "\n";

View File

@ -11,7 +11,7 @@
class MsgViewHelper extends ViewHelper
{
const SUCCESS = 'success';
const ERROR = 'error';
@ -27,12 +27,12 @@ class MsgViewHelper extends ViewHelper
}
return $this;
}
public function success($msg)
{
Session::set(__CLASS__, array('message' => $msg, 'type' => self::SUCCESS));
}
public function error($msg)
{
Session::set(__CLASS__, array('message' => $msg, 'type' => self::ERROR));

View File

@ -11,9 +11,9 @@
class TitleViewHelper extends ViewHelper
{
protected $separator = ' - ';
public function title($string = false)
{
if ($string) {
@ -23,12 +23,12 @@ class TitleViewHelper extends ViewHelper
}
return $this;
}
public function setSeparator($sep)
{
$this->separator = $sep;
}
public function __toString()
{
return implode($this->separator, Registry::get(__CLASS__, array()));

View File

@ -11,12 +11,12 @@
abstract class ViewHelper
{
/**
* @var PHPView
*/
protected $view = null;
public function __construct($view)
{
$this->view = $view;