Created
January 7, 2010 20:50
-
-
Save robzienert/271556 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Prpl_View_Helper_Zebra extends Zend_View_Helper_Abstract | |
{ | |
/** | |
* Internal tracker; static to allow tracking in partial loops, etc | |
* | |
* @var integer | |
*/ | |
private static $_count = 0; | |
/** | |
* Alternate string | |
* | |
* @var string | |
*/ | |
private static $_alternate = 'stripe'; | |
/** | |
* Zebra cycler; similar to Zend_View_Helper_Cycle, but more to the point | |
* | |
* @param boolean $includeHtml | |
* @return string | |
*/ | |
public function zebra($includeHtml = true) | |
{ | |
++self::$_count; | |
$string = $this->getAlternate(); | |
if ($includeHtml) { | |
$string = " class=\"{$string}\""; | |
} | |
return (self::$_count % 2) ? $string : ''; | |
} | |
/** | |
* Set the alternate string | |
* | |
* @param string $alternate | |
* @return Prpl_View_Helper_Zebra | |
*/ | |
public function setAlternate($alternate) | |
{ | |
self::$_alternate = (string) $alternate; | |
return $this; | |
} | |
/** | |
* Get the alternate string | |
* | |
* @return string | |
*/ | |
public function getAlternate() | |
{ | |
return self::$_alternate; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment