Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
Prepping for 2.2.0RC1.
  • Loading branch information
Show file tree
Hide file tree
Showing 74 changed files with 3,573 additions and 3,098 deletions.
2 changes: 1 addition & 1 deletion src/Helper/AbstractHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
abstract class AbstractHelper implements HelperInterface
{
/**
* View object
* View object instance
*
* @var Renderer
*/
Expand Down
9 changes: 5 additions & 4 deletions src/Helper/AbstractHtmlElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ public function getClosingBracket()
*/
protected function isXhtml()
{
$doctype = $this->view->plugin('doctype');
return $doctype->isXhtml();
return $this->getView()->plugin('doctype')->isXhtml();
}

/**
Expand All @@ -65,7 +64,8 @@ protected function isXhtml()
protected function htmlAttribs($attribs)
{
$xhtml = '';
$escaper = $this->view->plugin('escapehtml');
$escaper = $this->getView()->plugin('escapehtml');

foreach ((array) $attribs as $key => $val) {
$key = $escaper($key);

Expand Down Expand Up @@ -96,8 +96,8 @@ protected function htmlAttribs($attribs)
} else {
$xhtml .= " $key=\"$val\"";
}

}

return $xhtml;
}

Expand All @@ -117,6 +117,7 @@ protected function normalizeId($value)
$value = str_replace('][', '-', $value);
$value = str_replace('[', '-', $value);
}

return $value;
}
}
2 changes: 1 addition & 1 deletion src/Helper/BasePath.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class BasePath extends AbstractHelper
{
/**
* Base path.
* Base path
*
* @var string
*/
Expand Down
109 changes: 59 additions & 50 deletions src/Helper/Cycle.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,12 @@
*/
class Cycle extends AbstractHelper implements \Iterator
{

/**
* Default name
* @var string
*/
const DEFAULT_NAME = 'default';

/**
* Pointers
*
* @var array
*/
protected $pointers = array(self::DEFAULT_NAME =>-1);

/**
* Array of values
*
Expand All @@ -42,28 +34,56 @@ class Cycle extends AbstractHelper implements \Iterator
*/
protected $name = self::DEFAULT_NAME;

/**
* Pointers
*
* @var array
*/
protected $pointers = array(self::DEFAULT_NAME =>-1);

/**
* Add elements to alternate
*
* @param array $data
* @param string $name
* @return \Zend\View\Helper\Cycle
* @param array $data
* @param string $name
* @return Cycle
*/
public function __invoke(array $data = array(), $name = self::DEFAULT_NAME)
{
if (!empty($data))
if (!empty($data)) {
$this->data[$name] = $data;
}

$this->setName($name);
return $this;
}

/**
* Cast to string
*
* @return string
*/
public function __toString()
{
return $this->toString();
}

/**
* Turn helper into string
*
* @return string
*/
public function toString()
{
return (string) $this->data[$this->name][$this->key()];
}

/**
* Add elements to alternate
*
* @param array $data
* @param string $name
* @return \Zend\View\Helper\Cycle
* @param array $data
* @param string $name
* @return Cycle
*/
public function assign(Array $data , $name = self::DEFAULT_NAME)
{
Expand All @@ -76,18 +96,20 @@ public function assign(Array $data , $name = self::DEFAULT_NAME)
/**
* Sets actual name of cycle
*
* @param $name
* @return \Zend\View\Helper\Cycle
* @param $name
* @return Cycle
*/
public function setName($name = self::DEFAULT_NAME)
{
$this->name = $name;

if (!isset($this->data[$this->name]))
$this->data[$this->name] = array();
if (!isset($this->data[$this->name])) {
$this->data[$this->name] = array();
}

if (!isset($this->pointers[$this->name]))
$this->rewind();
if (!isset($this->pointers[$this->name])) {
$this->rewind();
}

return $this;
}
Expand All @@ -113,53 +135,39 @@ public function getAll()
return $this->data[$this->name];
}

/**
* Turn helper into string
*
* @return string
*/
public function toString()
{
return (string) $this->data[$this->name][$this->key()];
}

/**
* Cast to string
*
* @return string
*/
public function __toString()
{
return $this->toString();
}

/**
* Move to next value
*
* @return \Zend\View\Helper\Cycle
* @return Cycle
*/
public function next()
{
$count = count($this->data[$this->name]);
if ($this->pointers[$this->name] == ($count - 1))

if ($this->pointers[$this->name] == ($count - 1)) {
$this->pointers[$this->name] = 0;
else
} else {
$this->pointers[$this->name] = ++$this->pointers[$this->name];
}

return $this;
}

/**
* Move to previous value
*
* @return \Zend\View\Helper\Cycle
* @return Cycle
*/
public function prev()
{
$count = count($this->data[$this->name]);
if ($this->pointers[$this->name] <= 0)

if ($this->pointers[$this->name] <= 0) {
$this->pointers[$this->name] = $count - 1;
else
} else {
$this->pointers[$this->name] = --$this->pointers[$this->name];
}

return $this;
}

Expand All @@ -170,16 +178,17 @@ public function prev()
*/
public function key()
{
if ($this->pointers[$this->name] < 0)
if ($this->pointers[$this->name] < 0) {
return 0;
else
} else {
return $this->pointers[$this->name];
}
}

/**
* Rewind pointer
*
* @return \Zend\View\Helper\Cycle
* @return Cycle
*/
public function rewind()
{
Expand Down
1 change: 1 addition & 0 deletions src/Helper/DeclareVars.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class DeclareVars extends AbstractHelper
{
/**
* The view object that created this helper object.
*
* @var \Zend\View\View
*/
public $view;
Expand Down
Loading

0 comments on commit 812f35d

Please sign in to comment.