<?php
/*
* Free IT Foundation
* Free Technology Serving Knowledge
* http://www.free-it-foundation.org
*
* This file is part of Knowledge Box.
*
* Knowledge Box is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Knowledge Box is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Knowledge Box. If not, see <http://www.gnu.org/licenses/>.
*/
// restrict access on tab keywords
if (KB_TAB == KB_TAB_KEYWORDS && !KB_IS_CONTRIBUTOR)
$AppUI->redirect (KB_ACCESS_DENIED);
// restrict access on tab fields
if (KB_TAB == KB_TAB_FIELDS && !KB_IS_ADMINISTRATOR)
$AppUI->redirect (KB_ACCESS_DENIED);
// restrict access on tab elements
if (KB_TAB == KB_TAB_ELEMENTS && !KB_IS_ADMINISTRATOR)
$AppUI->redirect (KB_ACCESS_DENIED);
// restrict access on tab config
if (KB_TAB == KB_TAB_CONFIG && !KB_IS_ADMINISTRATOR)
$AppUI->redirect (KB_ACCESS_DENIED);
// restrict access on valid tabs
if (KB_TAB < KB_TAB_SEARCH || KB_TAB > KB_TAB_CONFIG)
{
$_SESSION [KB_SESSION_TAB] = KB_TAB_SEARCH;
$AppUI->redirect (KB_ACCESS_DENIED);
}
// instanciate
$base = new KBModuleBase ();
// load record
if (!$base->load (KB_BASE))
{
// clean session
$_SESSION [KB_SESSION_BASE] = KB_BASE_UNDEFINED;
// failed
$AppUI->redirect (KB_ACCESS_DENIED);
}
// title block
$titleBlock = new CTitleBlock (html_entity_decode ($base->getName ()), KB_MODULE_ICON);
// search actions
if (KB_TAB == KB_TAB_SEARCH)
{
// integrity
$hasKeywords = KBModuleKeyword::hasKeywordsInBase (KB_BASE);
// cell
if (KB_IS_CONTRIBUTOR && $hasKeywords) {
$titleBlock->addCell ('<input type="submit" class="button" value="' . $AppUI->_('actionNewEntry') . '">', '',
'<form action="index.php" method="get">
<input type="hidden" name="m" value="' . KB_MODULE . '" />
<input type="hidden" name="a" value="entry" />',
'</form>');
}
}
// keywords actions
if (KB_TAB == KB_TAB_KEYWORDS)
{
// undefined
if (KB_PANE == KB_PANE_UNDEFINED) {
$titleBlock->addCell ('<input type="submit" class="button" value="' . $AppUI->_('actionNewGroup') . '">', '',
'<form action="index.php" method="get">
<input type="hidden" name="m" value="' . KB_MODULE . '" />
<input type="hidden" name="a" value="group" />',
'</form>');
}
// labels
if (KB_PANE == KB_PANE_LABELS) {
$titleBlock->addCell ('<input type="submit" class="button" value="' . $AppUI->_('actionNewLabel') . '">', '',
'<form action="index.php" method="get">
<input type="hidden" name="m" value="' . KB_MODULE . '" />
<input type="hidden" name="a" value="label" />',
'</form>');
$titleBlock->addCell ('<input type="submit" class="button" value="' . $AppUI->_('backToGroups') . '">', '',
'<form action="index.php" method="get">
<input type="hidden" name="m" value="' . KB_MODULE . '" />',
'</form>');
}
// keywords
if (KB_PANE == KB_PANE_KEYWORDS) {
$titleBlock->addCell ('<input type="submit" class="button" value="' . $AppUI->_('actionNewKeyword') . '">', '',
'<form action="index.php" method="get">
<input type="hidden" name="m" value="' . KB_MODULE . '" />
<input type="hidden" name="a" value="keyword" />',
'</form>');
$titleBlock->addCell ('<input type="submit" class="button" value="' . $AppUI->_('backToLabels') . '">', '',
'<form action="index.php" method="get">
<input type="hidden" name="m" value="' . KB_MODULE . '" />
<input type="hidden" name="pane" value="' . KB_PANE_LABELS . '" />',
'</form>');
}
}
// fields actions
if (KB_TAB == KB_TAB_FIELDS)
{
$titleBlock->addCell ('<input type="submit" class="button" value="' . $AppUI->_('actionNewField') . '">', '',
'<form action="index.php" method="get">
<input type="hidden" name="m" value="' . KB_MODULE . '" />
<input type="hidden" name="a" value="field" />',
'</form>');
}
// elements actions
if (KB_TAB == KB_TAB_ELEMENTS)
{
$titleBlock->addCell ('<input type="submit" class="button" value="' . $AppUI->_('actionNewElement') . '">', '',
'<form action="index.php" method="get">
<input type="hidden" name="m" value="' . KB_MODULE . '" />
<input type="hidden" name="a" value="element" />',
'</form>');
}
// generic back action
if (KB_PANE == KB_PANE_UNDEFINED)
{
$titleBlock->addCell ('<input type="submit" class="button" value="' . $AppUI->_('backToBox') . '">', '',
'<form action="index.php" method="get">
<input type="hidden" name="m" value="' . KB_MODULE . '" />
<input type="hidden" name="kbid" value="' . KB_BASE_UNDEFINED . '" />',
'</form>');
}
// show the title block
$titleBlock->show ();
// tab box
$tabBox = new CTabBox ('?m=' . KB_MODULE, $dPconfig ['root_dir'] . '/modules/' . KB_MODULE .'/display/', KB_TAB);
// add search pane
$tabBox->add ('search', utf8_encode (html_entity_decode ($AppUI->_('tabSearch'))));
// add keywords pane
if (KB_IS_CONTRIBUTOR)
$tabBox->add ('groups', utf8_encode (html_entity_decode ($AppUI->_('tabKeywords'))));
// add fields pane
if (KB_IS_ADMINISTRATOR)
$tabBox->add ('fields', utf8_encode (html_entity_decode ($AppUI->_('tabFields'))));
// add elements pane
if (KB_IS_ADMINISTRATOR)
$tabBox->add ('elements', utf8_encode (html_entity_decode ($AppUI->_('tabResultsOutput'))));
// add config pane
if (KB_IS_ADMINISTRATOR)
$tabBox->add ('config', utf8_encode (html_entity_decode ($AppUI->_('tabConfiguration'))));
// show the tab box
$tabBox->show ();
?>