WPDK  1.5.0
WordPress Development Kit
 All Data Structures Files Functions Variables Pages
wpdk-jquery.php
Go to the documentation of this file.
1 <?php
12 class WPDKjQuery {
13  /* Not yet implement */
14 }
15 
27 
35  public $content;
43  public $id;
51  public $title;
52 
62  function __construct( $id, $title, $content = '' )
63  {
64  if ( is_a( $id, 'WPDKView' ) ) {
65  $this->id = sanitize_key( $id->id );
66  $this->title = $title;
67  $this->content = $id->html();
68  }
69  else {
70  $this->id = sanitize_key( $id );
71  $this->title = $title;
72  $this->content = $content;
73  }
74  }
75 }
76 
88 
96  public $tabs;
97 
105  public $border;
106 
117  public function __construct( $id, $tabs = array() ) {
118  parent::__construct( $id, 'wpdk-jquery-ui' );
119  $this->tabs = $tabs;
120  $this->border = true;
121  }
122 
131  public function addTab( $tab ) {
132  if ( is_object( $tab ) && is_a( $tab, 'WPDKjQueryTab' ) ) {
133  $id = $tab->id;
134  $this->tabs[$id] = $tab;
135  }
136  }
137 
145  public function removeTab( $tab ) {
146  if ( is_object( $tab ) && is_a( $tab, 'WPDKjQueryTab' ) ) {
147  $id = $tab->id;
148  }
149  elseif ( is_string( $tab ) ) {
150  $id = $tab;
151  }
152  if ( !empty( $id ) && isset( $this->tabs[$id] ) ) {
153  unset( $this->tabs[$id] );
154  }
155  }
156 
162  public function draw()
163  {
164  $html_titles = '';
165  $html_content = '';
166 
167  foreach ( $this->tabs as $tab ) {
168  $html_titles .= sprintf( '<li class="%s"><a href="#%s">%s</a></li>', $tab->id, $tab->id, $tab->title );
169  $html_content .= sprintf( '%s', $tab->content );
170  }
171  ?>
172  <div class="<?php echo $this->border ? 'wpdk-border-container' : '' ?>">
173  <div id="<?php echo $this->id . '-tabs-view' ?>" class="wpdk-tabs">
174  <ul>
175  <?php echo $html_titles ?>
176  </ul>
177  <?php echo $html_content ?>
178  </div>
179  </div>
180  <?php
181 
182  }
183 
184 }
185 
197 
209  public function __construct( $id, $title, $view )
210  {
211  parent::__construct( $id, $title );
212  $this->view->addSubview( $view );
213  }
214 }