1 <?php
2 /**
3 * UIX header
4 *
5 * @package ui
6 * @author David Cramer
7 * @license GPL-2.0+
8 * @link
9 * @copyright 2016 David Cramer
10 */
11 namespace uix\ui;
12
13 /**
14 * A generic holder for multiple controls. this panel type does not handle saving, but forms part of the data object tree.
15 *
16 * @since 1.0.0
17 * @see \uix\uix
18 */
19 class header extends section {
20
21 /**
22 * The type of object
23 *
24 * @since 1.0.0
25 * @access public
26 * @var string
27 */
28 public $type = 'header';
29
30 /**
31 * type of header element
32 *
33 * @since 1.0.0
34 * @access public
35 * @var string
36 */
37 public $element = 'h1';
38
39 /**
40 * List of attributes to apply to the wrapper element
41 *
42 * @since 1.0.0
43 * @access public
44 * @var array
45 */
46 public $attributes = array( 'class' => 'uix-title' );
47
48 /**
49 * Set the element type
50 *
51 * @since 1.0.0
52 * @access public
53 */
54 public function init(){
55 if( !empty( $this->struct['element'] ) )
56 $this->element = $this->struct['element'];
57 }
58
59
60
61 /**
62 * Render the complete section
63 *
64 * @since 1.0.0
65 * @access public
66 * @return string|null HTML of rendered notice
67 */
68 public function render(){
69
70 $output = '<' . $this->element . ' ' . $this->build_attributes() . '>';
71
72 $output .= $this->label();
73
74 $output .= $this->description();
75
76 $output .= $this->render_template();
77
78 if( !empty( $this->child ) )
79 $output .= $this->render_children();
80
81
82
83 $output .= '</' . $this->element . '>';
84
85
86 return $output;
87 }
88
89 /**
90 * Define core header styles
91 *
92 * @since 1.0.0
93 * @access public
94 */
95 public function set_assets() {
96
97 $this->assets['style']['header'] = $this->url . 'assets/css/header' . UIX_ASSET_DEBUG . '.css';
98
99 parent::set_assets();
100 }
101
102 /**
103 * Render the panels label
104 *
105 * @since 1.0.0
106 * @access public
107 * @return string|null rendered html of label
108 */
109 public function label(){
110 $output = null;
111 if( !empty( $this->struct['label'] ) )
112 $output .= '<span class="uix-text">' . esc_html( $this->struct['label'] ) . '</span>';
113
114 return $output;
115 }
116
117 /**
118 * Render the panels Description
119 *
120 * @since 1.0.0
121 * @access public
122 * @return string|null HTML of rendered description
123 */
124 public function description(){
125 $output = null;
126 if( !empty( $this->struct['description'] ) )
127 $output .= ' <small>' . esc_html( $this->struct['description'] ) . '</small>';
128
129 return $output;
130 }
131
132 /**
133 * checks if the current section is active
134 *
135 * @since 1.0.0
136 * @access public
137 */
138 public function is_active(){
139 return $this->parent->is_active();
140 }
141
142 }