'tabview/sample',
'title' => t('YUI TabView Sample'),
'callback' => 'yui_tabview_sample',
'access' => TRUE,
'type' => MENU_CALLBACK
);
}
return $items;
}
function yui_tabview_sample() {
$nodes[] = (object)array('nav' => 'Tab One Label', 'content' => 'Tab One Content');
$nodes[] = (object)array('nav' => 'Tab Two Label', 'content' => 'Tab Two Content');
$nodes[] = (object)array('nav' => 'Tab Three Label', 'content' => 'Tab Three Content');
$output = build_tabview('test', $nodes);
return $output;
}
function build_tabview($name, $nodes) {
$yui_source = variable_get('yui_source', 'http://yui.yahooapis.com/2.5.1');
yui_add_css('tabview', $yui_source, '/build/tabview/assets/skins/sam/tabview.css');
yui_add_js('tabview', $yui_source, '/build/yahoo-dom-event/yahoo-dom-event.js');
yui_add_js('tabview', $yui_source, '/build/element/element-beta-min.js');
yui_add_js('tabview', $yui_source, '/build/connection/connection-min.js');
yui_add_js('tabview', $yui_source, '/build/tabview/tabview-min.js');
drupal_add_css(drupal_get_path('module', 'yui_tabview') .'/yui_tabview.css');
$tab_number=1;
foreach ($nodes as $node) {
$yui_nav .= '
'. $node->nav .'';
$yui_content .= ' ';
$tab_number++;
}
$output='
';
return $output;
}
/**
* Implementation of hook_filter_tips().
*/
function yui_tabview_filter_tips($delta, $format, $long = FALSE) {
global $base_url;
if ($delta == 0) {
switch ($long) {
case 0:
return t('Formatting as follows
(YUI_TAB)
(HEADER)Tab1(/HEADER)
Tab1 Content
(HEADER)Tab2(/HEADER)
Tab2 Content
(/YUI_TAB)');
case 1:
$output = ''. t('Yui Tabview tips') .'
';
return $output;
}
}
}
/**
* Implementation of hook_filter().
*
*/
function yui_tabview_filter($op, $delta = 0, $format = -1, $text = '') {
switch ($op) {
case 'list':
return array(0 => t('YUI Tabs'));
case 'no cache':
// No caching for the PHP evaluator.
return $delta == 0;
case 'description':
return t('Turns simple html into a yui tabs');
case 'process':
if (strpos($text, '(YUI_TAB') !== FALSE) {
$yui_source = variable_get('yui_source', 'http://yui.yahooapis.com/2.5.1');
yui_add_css('tabview', $yui_source, '/build/tabview/assets/skins/sam/tabview.css');
yui_add_js('tabview', $yui_source, '/build/yahoo-dom-event/yahoo-dom-event.js');
yui_add_js('tabview', $yui_source, '/build/element/element-beta-min.js');
yui_add_js('tabview', $yui_source, '/build/connection/connection-min.js');
yui_add_js('tabview', $yui_source, '/build/tabview/tabview-min.js');
drupal_add_css(drupal_get_path('module', 'yui_tabview') .'/yui_tabview.css');
}
while (strpos($text, '(YUI_TAB') !== FALSE) {
$text = yui_tabview_insertab($text);
}
return $text;
default:
return $text;
}
}
function yui_tabview_insertab($text) {
$start_chuck = strpos($text, '(YUI_TAB)');
$end_chuck = strpos($text, '(/YUI_TAB)');
$chuck = substr($text, $start_chuck, $end_chuck - $start_chuck + 10);
$working_chuck = substr($chuck, 9, $end_chuck - $start_chuck - 9);
$tabs = explode('(HEADER)', $working_chuck);
$navs = '';
$content = '';
$tab = 1;
foreach ($tabs as $value) {
$pos = strpos($value, '(/HEADER)');
$class = '';
if ($pos !== FALSE) {
if ($tab == 1) {
$class = ' class="selected" ';
}
$navs .= ''. substr($value, 0, $pos) .'';
$content .= ''. substr($value, $pos + 9) .'
';
$tab++;
}
}
$new_chuck = '
';
$text = str_replace($chuck, $new_chuck, $text);
$text = str_replace('(YUI_TAB)', '', $text);
return $text;
}