moved tab generation to PHP, no empty tabs SPR-799

I still don't like the code directly in the template there. I think it
should be moved to a helper class.

The TOC CSS seems to be broken when there are no tabs right of the TOC.
This commit is contained in:
Andreas Gohr 2017-02-15 16:17:17 +01:00
commit 038d4bfe8d
2 changed files with 49 additions and 27 deletions

View file

@ -27,6 +27,8 @@ $lang['meta_box_jira_tickets_none'] = 'jira associated tickets found: none';
$lang['meta_box_tags_none'] = 'tags found: none';
$lang['js']['meta_box_toc_none'] = 'no Table of Contents available';
$lang['tab_tags'] = 'Tags';
$lang['quality_trigger'] = 'toggle page analysis';
$lang['prefix_tasks'] = 'open tasks: ';

View file

@ -1,39 +1,59 @@
<?php
if (!defined('DOKU_INC')) die();
if(!defined('DOKU_INC')) die();
global $lang;
$tabs = array();
$toc = tpl_toc(true);
if($toc) {
$tabs[] = array(
'id' => 'spr__tab-toc',
'label' => $lang['toc'],
'tab' => $toc,
'count' => null,
);
}
/** @var helper_plugin_tagging $tags */
$tags = plugin_load('helper', 'tagging');
if($tags) {
$tabs[] = array(
'id' => 'spr__tab-tags',
'label' => tpl_getLang('tab_tags'),
'tab' => $tags->tpl_tags(false),
'count' => null, // FIXME
);
}
// fixme add magicmatcher info
?>
<div class="tab-container">
<ul class="meta-tabs">
<li><a href="#spr__tab-toc" aria-expanded="false"><span class="prefix"><?php echo $lang['toc']?></span></a></li>
<li><a href="#spr__tab-tags" aria-expanded="false"><span class="prefix">Tags <span class="num">0</span></span></a></li>
<li><a href="#spr__tab-jira" aria-expanded="false"><span class="prefix">Jira <span class="num">0</span></span></a></li>
<?php
foreach($tabs as $tab) {
echo '<li>';
echo '<a href="#' . $tab['id'] . '" aria-expanded="false">';
echo '<span class="prefix">';
echo $tab['label'];
if($tab['count'] !== null) {
echo ' <span class="num">' . $tab['count'] . '</span>';
}
echo '</span>';
echo '</li>';
}
?>
</ul>
<div class="meta-content">
<div class="box-content">
<div id="spr__tab-toc" class="tab-pane" aria-hidden="true">
<?php tpl_toc(); ?>
</div>
<div id="spr__tab-tags" class="tab-pane" aria-hidden="true">
<div>
<?php
if ($tags !== null) {
$tags->tpl_tags();
}else{
echo "<p>" . tpl_getLang('meta_box_tags_none') . "</p>";
}
?>
</div>
</div>
<div id="spr__tab-jira" class="tab-pane" aria-hidden="true">
<div>
<p><?php echo tpl_getLang('meta_box_jira_tickets_none') ?></p>
</div>
</div>
<?php
foreach($tabs as $tab) {
echo '<div id="' . $tab['id'] . '" class="tab-pane" aria-hidden="true">';
echo $tab['tab'];
echo '</div>';
}
?>
</div>
</div>
</div>