4 * Ninja Toolbar Management
9 class Toolbar_Controller
{
11 public $title = false;
12 public $subtitle = false;
13 public function __construct ( $title = false, $subtitle = false ) {
15 $this->title
= ( gettype( $title ) == "string" ) ?
$title: false;
16 $this->subtitle
= ( gettype( $subtitle ) == "string" ) ?
$subtitle: false;
20 private $should_render_buttons = false;
21 public function should_render_buttons($should_render_buttons = true) {
22 $this->should_render_buttons
= $should_render_buttons;
25 private $buttons = array();
26 public function button ( $title, $attr = false ) {
27 $this->should_render_buttons(true);
28 if ( !$attr ) $attr = array();
30 $this->buttons
[ ] = array(
37 private $tabs = array();
38 public function tab ( $title, $attr = false ) {
40 if ( !$attr ) $attr = array();
42 $this->tabs
[ ] = array(
49 private $info = array();
50 public function info ( $html ) {
52 if ( gettype( $html ) == "string" ) {
53 $this->info
[ ] = $html;
61 private function get_button_html () {
65 foreach ( $this->buttons
as $b ) {
67 foreach ( $b[ "attr" ] as $k => $v )
69 $h .= "<a " . implode( " ", $a ) . ">" . $b[ "name" ] . "</a>";
76 public function render () {
78 print '<div class="main-toolbar">';
80 if ( gettype( $this->title
) == "string" ) {
81 print '<div class="main-toolbar-title">' . $this->title
. '</div>';
84 if ( gettype( $this->subtitle
) == "string" ) {
85 print '<div class="main-toolbar-subtitle">' . $this->subtitle
. '</div>';
87 print '<div class="main-toolbar-subtitle"></div>';
90 if ( count( $this->info
) > 0 ) {
91 print '<div class="main-toolbar-info">';
92 foreach ( $this->info
as $html ) print $html;
96 if ($this->should_render_buttons
) {
97 print '<div class="main-toolbar-buttons">';
98 print $this->get_button_html();
102 print '<div class="clear"></div>';