| 1 |
<?php |
| 2 |
/* |
| 3 |
Author: Fakhri Alsadi |
| 4 |
Date: 16-7-2010 |
| 5 |
Contact: www.clogica.com info@clogica.com mobile: +972599322252 |
| 6 |
|
| 7 |
*/ |
| 8 |
|
| 9 |
if (!class_exists('phptab')) { |
| 10 |
class phptab |
| 11 |
{ |
| 12 |
|
| 13 |
var $tabs; // each tab has num,title,content,parameter. |
| 14 |
var $parameter = 'tab'; |
| 15 |
var $ignore_parameters = ''; |
| 16 |
|
| 17 |
|
| 18 |
function __construct($parameter = 'tab') |
| 19 |
{ |
| 20 |
$this->tabs = array(); |
| 21 |
$this->$parameter = $parameter; |
| 22 |
} |
| 23 |
|
| 24 |
//---------------------------------------------------------------------------- |
| 25 |
|
| 26 |
function add_file_tab($num, $title, $content, $type) |
| 27 |
{ |
| 28 |
$index = $this->tabs_count(); |
| 29 |
$this->tabs[$index] = array('num' => $num, 'title' => $title, 'content' => $content, 'type' => $type); |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
//---------------------------------------------------------------------------- |
| 34 |
|
| 35 |
function tabs_count() |
| 36 |
{ |
| 37 |
if (is_array($this->tabs)) |
| 38 |
return count($this->tabs); |
| 39 |
else |
| 40 |
return 0; |
| 41 |
} |
| 42 |
|
| 43 |
//---------------------------------------------------------------------------- |
| 44 |
|
| 45 |
function set_ignore_parameter($ar) |
| 46 |
{ |
| 47 |
if (is_array($ar)) |
| 48 |
$this->ignore_parameters = $ar; |
| 49 |
else |
| 50 |
$this->ignore_parameters = array($ar); |
| 51 |
} |
| 52 |
|
| 53 |
//---------------------------------------------------------------------------- |
| 54 |
|
| 55 |
function get_ignore_parameter($ar) |
| 56 |
{ |
| 57 |
return $this->ignore_parameters; |
| 58 |
} |
| 59 |
|
| 60 |
//---------------------------------------------------------------------------- |
| 61 |
function run() |
| 62 |
{ |
| 63 |
global $util; |
| 64 |
|
| 65 |
$tab_index = htmlspecialchars(strip_tags($util->get($this->parameter, 'url'))); |
| 66 |
|
| 67 |
if ($tab_index == '') |
| 68 |
$tab_index = $this->tabs[0]['num']; |
| 69 |
|
| 70 |
$options_path = ''; |
| 71 |
if (is_array($this->ignore_parameters)) { |
| 72 |
$ignore = array_merge(array($this->parameter), $this->ignore_parameters); |
| 73 |
$options_path = $util->WPSR_get_current_parameters($ignore); |
| 74 |
} else { |
| 75 |
$options_path = $util->WPSR_get_current_parameters($this->parameter); |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
$num_index = -1; |
| 80 |
echo '<ul class="tabs">'; |
| 81 |
|
| 82 |
for ($i = 0; $i < $this->tabs_count(); $i++) { |
| 83 |
if ($this->tabs[$i]['num'] == $tab_index) { |
| 84 |
echo '<li class="active"> <a href="' . esc_url($options_path . '&' . $this->parameter . '=' . $this->tabs[$i]['num']) . '"> ' . esc_html(strip_tags($this->tabs[$i]['title'])) . '</a></li>'; |
| 85 |
$num_index = $i; |
| 86 |
} else { |
| 87 |
echo '<li><a href="' . esc_url($options_path . '&' . $this->parameter . '=' . $this->tabs[$i]['num']) . '">' . esc_html(strip_tags($this->tabs[$i]['title'])) . '</a></li>'; |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
echo '</ul>'; |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
if ($num_index >= 0) { |
| 96 |
echo '<div class="tabContainer"><div id="tab1" class="tabContent">'; |
| 97 |
include $util->get_plugin_path() . 'options/' . $this->tabs[$num_index]['content']; |
| 98 |
echo '</div></div>'; |
| 99 |
} |
| 100 |
} |
| 101 |
} |
| 102 |
} |
| 103 |
|