| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
interface HC3_Ui_Layout1_ |
| 3 |
{ |
| 4 |
public function setMenu( $set ); |
| 5 |
public function setSidebar( $set ); |
| 6 |
public function setBreadcrumb( $set ); |
| 7 |
public function setHeader( $set ); |
| 8 |
public function setContent( $set ); |
| 9 |
public function render(); |
| 10 |
} |
| 11 |
|
| 12 |
class HC3_Ui_Layout1 implements HC3_Ui_Layout1_ |
| 13 |
{ |
| 14 |
public $partialBreadcrumb = array(); |
| 15 |
public $partialBreadcrumbMultiline = false; |
| 16 |
public $partialHeader = null; |
| 17 |
public $partialContent = null; |
| 18 |
public $partialMenu = array(); |
| 19 |
public $partialSidebar = array(); |
| 20 |
|
| 21 |
public $ui; |
| 22 |
|
| 23 |
public function __construct( HC3_Ui $ui ) |
| 24 |
{ |
| 25 |
$this->ui = $ui; |
| 26 |
|
| 27 |
$this->partialBreadcrumb = array(); |
| 28 |
$this->partialBreadcrumbMultiline = false; |
| 29 |
|
| 30 |
$this->partialHeader = null; |
| 31 |
$this->partialContent = null; |
| 32 |
$this->partialMenu = array(); |
| 33 |
$this->partialSidebar = array(); |
| 34 |
} |
| 35 |
|
| 36 |
public function setSidebar( $set ) |
| 37 |
{ |
| 38 |
$this->partialSidebar = $set; |
| 39 |
return $this; |
| 40 |
} |
| 41 |
|
| 42 |
public function setMenu( $set ) |
| 43 |
{ |
| 44 |
$this->partialMenu = $set; |
| 45 |
return $this; |
| 46 |
} |
| 47 |
|
| 48 |
public function setBreadcrumb( $set, $multiline = FALSE ) |
| 49 |
{ |
| 50 |
$this->partialBreadcrumb = $set; |
| 51 |
$this->partialBreadcrumbMultiline = $multiline; |
| 52 |
return $this; |
| 53 |
} |
| 54 |
|
| 55 |
public function setHeader( $set ) |
| 56 |
{ |
| 57 |
$this->partialHeader = $set; |
| 58 |
return $this; |
| 59 |
} |
| 60 |
|
| 61 |
public function setContent( $set ) |
| 62 |
{ |
| 63 |
$this->partialContent = $set; |
| 64 |
return $this; |
| 65 |
} |
| 66 |
|
| 67 |
public function render() |
| 68 |
{ |
| 69 |
$out = array(); |
| 70 |
|
| 71 |
$header = array(); |
| 72 |
|
| 73 |
if( $this->partialBreadcrumb ){ |
| 74 |
$breadcrumb = array(); |
| 75 |
|
| 76 |
$breadcrumbParts = array(); |
| 77 |
if( $this->partialBreadcrumbMultiline ){ |
| 78 |
$breadcrumbParts = $this->partialBreadcrumb; |
| 79 |
} |
| 80 |
else { |
| 81 |
$breadcrumbParts = array( $this->partialBreadcrumb ); |
| 82 |
} |
| 83 |
|
| 84 |
foreach( $breadcrumbParts as $thisBreadcrumbParts ){ |
| 85 |
$thisBreadcrumb = array(); |
| 86 |
foreach( $thisBreadcrumbParts as $item ){ |
| 87 |
if( is_array($item) ){ |
| 88 |
list( $href, $hrefLabel ) = $item; |
| 89 |
$thisBreadcrumb[] = $this->ui->makeAhref( $href, $hrefLabel ); |
| 90 |
} |
| 91 |
else { |
| 92 |
$thisBreadcrumb[] = $this->ui->makeSpan( $item ) |
| 93 |
// ->tag('font-size', 4) |
| 94 |
// ->tag('font-style', 'bold') |
| 95 |
; |
| 96 |
} |
| 97 |
} |
| 98 |
$thisBreadcrumb = $this->ui->makeListInline( $thisBreadcrumb ) |
| 99 |
->tag('breadcrumb'); |
| 100 |
; |
| 101 |
$breadcrumb[] = $thisBreadcrumb; |
| 102 |
} |
| 103 |
|
| 104 |
if( $this->partialBreadcrumbMultiline ){ |
| 105 |
$breadcrumb = $this->ui->makeList( $breadcrumb ) |
| 106 |
->gutter(1) |
| 107 |
; |
| 108 |
} |
| 109 |
else { |
| 110 |
$breadcrumb = array_shift( $breadcrumb ); |
| 111 |
} |
| 112 |
|
| 113 |
$header[] = $breadcrumb; |
| 114 |
} |
| 115 |
|
| 116 |
if( (null !== $this->partialHeader) && strlen($this->partialHeader) ){ |
| 117 |
$label = $this->ui->makeBlock( $this->partialHeader ) |
| 118 |
->tag('page-header') |
| 119 |
; |
| 120 |
|
| 121 |
$links = array(); |
| 122 |
if( $this->partialMenu ){ |
| 123 |
foreach( $this->partialMenu as $item ){ |
| 124 |
if( is_array($item) ){ |
| 125 |
list( $href, $hrefLabel ) = $item; |
| 126 |
$item = $this->ui->makeAhref( $href, $hrefLabel ) |
| 127 |
->tag('secondary') |
| 128 |
; |
| 129 |
} |
| 130 |
$links[] = $item; |
| 131 |
} |
| 132 |
} |
| 133 |
|
| 134 |
if( $links ){ |
| 135 |
$links = $this->ui->makeListInline( $links ); |
| 136 |
$label = $this->ui->makeListInline( array($label, $links) ); |
| 137 |
} |
| 138 |
|
| 139 |
$header[] = $label; |
| 140 |
} |
| 141 |
|
| 142 |
$content = $this->partialContent; |
| 143 |
|
| 144 |
if( $this->partialSidebar ){ |
| 145 |
$sidebar = $this->ui->makeList( $this->partialSidebar ); |
| 146 |
$content = $this->ui->makeGrid() |
| 147 |
->add( $content, 9 ) |
| 148 |
->add( $sidebar, 3 ) |
| 149 |
->gutter(3) |
| 150 |
; |
| 151 |
} |
| 152 |
|
| 153 |
$out[] = $content; |
| 154 |
|
| 155 |
$out = $this->ui->makeList( $out ); |
| 156 |
|
| 157 |
if( $header ){ |
| 158 |
$header = $this->ui->makeList( $header )->gutter(0); |
| 159 |
$out = $this->ui->makeList( array($header,$out) )->gutter(1); |
| 160 |
} |
| 161 |
|
| 162 |
return $out; |
| 163 |
} |
| 164 |
} |