<?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/>.
*/
// knowledge box
require_once ('require/knowledgebox.php');
// retrieve id
$entry_id = (int) dPgetParam ($_GET, 'id');
// instanciate
$entry = new KBModuleEntry ();
// load record
if ($entry_id > 0 && !$entry->load ($entry_id))
$AppUI->redirect ();
// get resources
$fields = KBModuleField::getFieldsByBase (KBEV_BASE);
$groups = KBModuleGroup::getGroupsByBase (KBEV_BASE);
$relations = KBModuleRelation::getRelationsByEntry ($entry->getId ());
$relatives = KBModuleRelative::getRelativesByEntry ($entry->getId ());
// get config
$configDateFormat = KBModuleConfig::getConfig (KBEV_BASE, KB_CONFIG_PROPERTY_DATEFORMAT);
$configDateSeparator = KBModuleConfig::getConfig (KBEV_BASE, KB_CONFIG_PROPERTY_DATESEPARATOR);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title><?= $translation ['titleKnowledgeBox'] ?> - <?= $base->getName () ?> - <?= $entry->getName () ?></title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" href="css/knowledgebox.css" type="text/css" />
</head>
<body>
<table border="0" width="100%">
<tr>
<td valign="bottom"><h1 style="padding-left:10px;"><?= $entry->getName () ?></h1></td>
<td align="right"><img src="img/knowledgebox.png" alt="Knowledge Box" style="padding-right:20px;" border="0" /></td>
</tr>
<tr>
<td colspan="2" style="padding-left:10px;">
<a href="index.php"><?= $base->getName () ?></a>
::
<a href="javascript:printEntry();"><?= $translation ['crumbPrintEntry'] ?></a>
</td>
</tr>
</table>
<br /><br />
<fieldset style="border:solid 1px #AAAAAA;margin-left:10px;margin-right:10px;background-color:#F6F6F6;">
<script type="text/javascript">
function printEntry ()
{
window.open ("", "printableEntry", "width=740,height=450,toolbar=no,scrollbars=yes,menubar=no,resizable=yes,location=no");
setTimeout ("document.printEntry.submit();", 500);
}
</script>
<form name="printEntry" action="print.php" method="get" target="printableEntry">
<input type="hidden" name="id" value="<?= $entry->getId () ?>" />
</form>
<table cellspacing="0" cellpadding="4" border="0" width="100%">
<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"><?= $field->getName () ?>:</td>
<td width="20"> </td>
<td width="100%" valign="top">
<?
// 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="../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="../io/<?= KB_STREAM_FILE ?>.php?entry=<?= $entry->getId () ?>&field=<?= $field->getId () ?>" border="0"><img border="0" src="../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) {
?>
<?= $translation ['encryptedPassword'] ?>
<?
} else {
?>
<?= $translation ['undefinedPassword'] ?>
<?
}
}
}
?>
</td>
</tr>
<tr>
<td colspan="3" height="3"></td>
</tr>
<?
// normal field
} else {
?>
<tr>
<td> </td>
<td> </td>
<td><h2 style="padding-top:10px;padding-bottom:0px;margin-bottom:5px;"><?= $field->getName () ?></h2></td>
</tr>
<?
} // end normal field
} // end iterate fields
?>
<tr>
<td colspan="3" height="3"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><h2 style="padding-top:10px;padding-bottom:0px;margin-bottom:5px;"><?= $translation ['labelViewKeywords'] ?></h2></td>
</tr>
<tr>
<td nowrap="nowrap" valign="top" align="right"><?= $translation ['columnViewKeywords'] ?></td>
<td width="20"> </td>
<td width="100%" valign="top">
<?
$displayedKeywords = 0;
// iterate groups
foreach ($groups as $group)
{
// get keywords
$keywords = KBModuleKeyword::getKeywordsByGroup ($group->getId ());
// keywords. ordered!.
foreach ($keywords as $keyword)
{
// relations
foreach ($relations as $relation)
{
if ($keyword->getId () == $relation->getKeywordId ())
{
if ($displayedKeywords > 0)
print ('<br />');
?>
<a href="relation.php?keyword=<?= $keyword->getId () ?>"><?= $keyword->getName () ?></a>
<?
$displayedKeywords++;
continue;
}
}
}
}
?>
</td>
</tr>
<? if (count ($relatives) > 0) { ?>
<tr>
<td colspan="3" height="3"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><h2 style="padding-top:10px;padding-bottom:0px;margin-bottom:5px;"><?= $translation ['labelViewRelations'] ?></h2></td>
</tr>
<tr>
<td nowrap="nowrap" valign="top" align="right"><?= $translation ['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="view.php?id=<?= $element->getId () ?>&kbid=<?= $element->getBaseId () ?>"><?= $element->getName () ?></a>
<br />
<?
}
?>
</td>
</tr>
<? } ?>
</table>
</td>
</tr>
</table>
</fieldset>
</body>
</html>