| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
class HC3_Ui_Element_List extends HC3_Ui_Abstract_Collection |
| 3 |
{ |
| 4 |
protected $htmlFactory = NULL; |
| 5 |
protected $striped = FALSE; |
| 6 |
|
| 7 |
public function __construct( |
| 8 |
HC3_Ui $htmlFactory, |
| 9 |
array $items = array() |
| 10 |
) |
| 11 |
{ |
| 12 |
$this->htmlFactory = $htmlFactory; |
| 13 |
parent::__construct( $items ); |
| 14 |
} |
| 15 |
|
| 16 |
public function setStriped( $striped = TRUE ) |
| 17 |
{ |
| 18 |
$this->striped = $striped; |
| 19 |
return $this; |
| 20 |
} |
| 21 |
|
| 22 |
public function render() |
| 23 |
{ |
| 24 |
$out = NULL; |
| 25 |
|
| 26 |
// content |
| 27 |
$children = ''; |
| 28 |
$rri = 0; |
| 29 |
foreach( $this->children as $child ){ |
| 30 |
$child = '' . $child; |
| 31 |
if( ! strlen($child) ){ |
| 32 |
continue; |
| 33 |
} |
| 34 |
|
| 35 |
$child = $this->htmlFactory->makeBlock( $child ); |
| 36 |
if( $this->gutter && $rri && (! $this->striped) ){ |
| 37 |
$child->addAttr('class', 'hc-mt' . $this->gutter); |
| 38 |
} |
| 39 |
$rri++; |
| 40 |
|
| 41 |
if( $this->striped ){ |
| 42 |
$child->addAttr('class', 'hc-p' . $this->gutter); |
| 43 |
if( defined('WPINC') ){ |
| 44 |
if( is_admin() ){ |
| 45 |
if( $rri % 2 ){ |
| 46 |
$child->addAttr('class', 'hc-bg-wpsilver'); |
| 47 |
} |
| 48 |
else { |
| 49 |
$child->addAttr('class', 'hc-bg-white'); |
| 50 |
} |
| 51 |
} |
| 52 |
} |
| 53 |
else { |
| 54 |
if( $rri % 2 ){ |
| 55 |
$child->addAttr('class', 'hc-bg-lightsilver'); |
| 56 |
} |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
$children .= '' . $child; |
| 61 |
} |
| 62 |
|
| 63 |
if( strlen($children) ){ |
| 64 |
$out = $this->htmlFactory->makeBlock( $children ); |
| 65 |
} |
| 66 |
|
| 67 |
return $out; |
| 68 |
} |
| 69 |
} |