<?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/>.
*/
// retrieve id
$entry_id = (int) dPgetParam ($_GET, 'id');
// instanciate
$entry = new KBModuleEntry ();
// load record
if ($entry_id > 0 && !$entry->load ($entry_id))
{
// failed
$AppUI->setMsg ('invalidID', UI_MSG_ERROR, true);
$AppUI->redirect ();
}
// base
$base = new KBModuleBase ();
$base->load (KB_BASE);
// config
$configDateFormat = KBModuleConfig::getConfig (KB_BASE, KB_CONFIG_PROPERTY_DATEFORMAT);
$configDateSeparator = KBModuleConfig::getConfig (KB_BASE, KB_CONFIG_PROPERTY_DATESEPARATOR);
// title block
$titleBlock = new CTitleBlock (html_entity_decode ($entry->getName ()), KB_MODULE_ICON);
// breadcrumbs
$titleBlock->addCrumb ('?m=' . KB_MODULE, html_entity_decode ($base->getName ()));
$titleBlock->addCrumb ('?m=' . KB_MODULE . '&a=entry&id=' . $entry->getId (), utf8_encode (html_entity_decode ($AppUI->_('crumbEditEntry'))));
$titleBlock->addCrumb ('?m=' . KB_MODULE . '&a=relative&id=' . $entry->getId (), utf8_encode (html_entity_decode ($AppUI->_('crumbEditRelations'))));
// show the title block
$titleBlock->show ();
// get resources
$fields = KBModuleField::getFieldsByBase (KB_BASE);
$groups = KBModuleGroup::getGroupsByBase (KB_BASE);
$relations = KBModuleRelation::getRelationsByEntry ($entry->getId ());
$relatives = KBModuleRelative::getRelativesByEntry ($entry->getId ());
?>
<table cellspacing="0" cellpadding="4" border="0" width="100%" class="std" style="background-color:#ebeaea;">
<tr>
<td width="100%" valign="top">
<br />
<table cellspacing="0" cellpadding="2" border="0">
<?
// iterate fields
foreach ($fields as $field)
{
if (!$field->isVisible ())
continue;
// label
if (!$field->isType (KB_FIELD_LABEL))
{
// get substance
$substance = KBModuleSubstance::getSubstance ($entry->getId (), $field->getId ());
?>
<tr>
<td nowrap="nowrap" valign="top" align="right" style="color:#999999;"><?= $field->getName () ?>:</td>
<td width="20"> </td>
<td width="100%" valign="top" style="background-color:#ffffff;">
<?
// field type
switch ($field->getType ())
{
case KB_FIELD_TEXT:
case KB_FIELD_HTML:
{
print ($substance->getTextValue ());
break;
}
case KB_FIELD_FILE:
{
if (strlen ($substance->getTextValue ()) > 0) {
?>
<a href="modules/<?= KB_MODULE ?>/io/<?= KB_STREAM_FILE ?>.php?entry=<?= $entry->getId () ?>&field=<?= $field->getId () ?>"><?= $substance->getInformation () ?></a>
<?
}
break;
}
case KB_FIELD_IMAGE:
{
if (strlen ($substance->getTextValue ()) > 0) {
?>
<a href="modules/<?= KB_MODULE ?>/io/<?= KB_STREAM_FILE ?>.php?entry=<?= $entry->getId () ?>&field=<?= $field->getId () ?>" border="0"><?= $substance->getInformation () ?><img border="0" src="modules/<?= KB_MODULE ?>/io/<?= KB_STREAM_IMAGE ?>.php?entry=<?= $entry->getId () ?>&field=<?= $field->getId () ?>"></a>
<?
}
break;
}
case KB_FIELD_LINK:
{
if (strlen ($substance->getTextValue ()) > 0) {
$targetBlank = (int) $substance->getMimeType () == 1;
?>
<a href="<?= $substance->getTextValue () ?>"<? if ($targetBlank) { ?> target="_blank"<? } ?>><?= $substance->getInformation () ?></a>
<?
}
break;
}
case KB_FIELD_EMAIL:
{
if (strlen ($substance->getTextValue ()) > 0) {
?>
<a href="mailto:<?= $substance->getTextValue () ?>"><?= $substance->getTextValue () ?></a>
<?
}
break;
}
case KB_FIELD_DATE:
{
if (strlen ($substance->getTextValue ()) > 0) {
$day = substr ($substance->getTextValue (), -2);
$month = substr ($substance->getTextValue (), 4, 2);
$year = substr ($substance->getTextValue (), 0, 4);
?>
<?= formatDateAsInConfig ($day, $month, $year, $configDateFormat, $configDateSeparator); ?>
<?
}
break;
}
case KB_FIELD_PASSWORD:
{
if (strlen ($substance->getTextValue ()) > 0) {
?>
Encrypted
<?
}
}
}
?>
</td>
</tr>
<tr>
<td colspan="3" height="3"></td>
</tr>
<?
// normal field
} else {
?>
<tr>
<td> </td>
<td> </td>
<td><h2 style="padding-bottom:10px;"><?= $field->getName () ?></h2></td>
</tr>
<?
} // end normal field
} // end iterate fields
?>
<tr>
<td colspan="3" height="17" ></td>
</tr>
<tr>
<td nowrap="nowrap" valign="top" align="right"><?= $AppUI->_('columnViewKeywords') ?></td>
<td width="20"> </td>
<td width="100%" valign="top">
<?
$displayedGroups = 0;
// iterate groups
foreach ($groups as $group)
{
// get keywords
$displayedKeywords = 0;
$keywords = KBModuleKeyword::getKeywordsByGroup ($group->getId ());
// group keywords has relations
if (count ($keywords) > 0)
{
// group name
if ($displayedGroups > 0)
print ('<br />');
print ($group->getName () . ': ');
$displayedGroups++;
// keywords. ordered!.
foreach ($keywords as $keyword)
{
// relations
foreach ($relations as $relation)
{
if ($keyword->getId () == $relation->getKeywordId ())
{
if ($displayedKeywords > 0)
print (', ');
print ('<a href="index.php?m=' . KB_MODULE . '&a=relation&keyword=' . $keyword->getId () . '">');
print ($keyword->getName ());
print ('</a>');
$displayedKeywords++;
continue;
}
}
}
}
}
?>
</td>
</tr>
<? if (count ($relatives) > 0) { ?>
<tr>
<td colspan="3" height="17"></td>
</tr>
<tr>
<td nowrap="nowrap" valign="top" align="right"><?= $AppUI->_('columnViewRelations') ?></td>
<td width="20"> </td>
<td width="100%" valign="top">
<?
// iterate relatives
foreach ($relatives as $relative)
{
$element = new KBModuleEntry ();
$element->load ($relative->getRelativeId ());
?>
<a href="index.php?m=<?= KB_MODULE ?>&a=view&kbid=<?= $element->getBaseId () ?>&id=<?= $element->getId () ?>"><?= $element->getName () ?></a>
<br />
<?
}
?>
</td>
</tr>
<? } ?>
</table>
<br />
</td>
</tr>
</table>