<?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
if (!KB_IS_CONTRIBUTOR)
$AppUI->redirect (KB_ACCESS_DENIED);
// 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);
// title block
$titleBlock = new CTitleBlock (utf8_encode (html_entity_decode ($AppUI->_('titleRelations'))), KB_MODULE_ICON);
// breadcrumbs
$titleBlock->addCrumb ('?m=' . KB_MODULE, html_entity_decode ($base->getName ()));
$titleBlock->addCrumb ('?m=' . KB_MODULE . '&a=view&id=' . $entry->getId (), html_entity_decode ($entry->getName ()));
$titleBlock->addCrumb ('?m=' . KB_MODULE . '&a=entry&id=' . $entry->getId (), utf8_encode (html_entity_decode ($AppUI->_('crumbEditEntry'))));
// show the title block
$titleBlock->show ();
// get resources
$bases = KBModuleBase::getBases ();
$relations = KBModuleRelative::getRelativesByEntry ($entry->getId ())
?>
<script type="text/javascript">
function cancelIt ()
{
location.href = "index.php?m=<?= KB_MODULE ?>";
}
function batchEntries (id, value)
{
var opt = document.relativeForm ["entries_" + id + "[]"].options;
for (var i = 0; i < opt.length; i++)
opt [i].selected = value;
}
</script>
<form name="relativeForm" action="index.php?m=<?= KB_MODULE ?>" method="post">
<input type="hidden" name="dosql" value="relative" />
<input type="hidden" name="id" value="<?= $entry_id ?>" />
<table cellspacing="0" cellpadding="4" border="0" width="100%" class="std">
<tr>
<td valign="top" colspan="2">
<br />
<?
// iterate
foreach ($bases as $base)
{
// entries
$entries = KBModuleEntry::getEntriesByBaseOrdered ($base->getId ());
// has entries
if (count ($entries) > 0)
{
?>
<br />
<table cellpadding="0" cellspacing="0" border="0" width="95%">
<tr>
<td style="font-weight:bold;"><?= $base->getName () ?></td>
<td align="right">
<a href="javascript:batchEntries(<?= $base->getId () ?>, true);"><?= $AppUI->_('batchSelectAll'); ?></a>
|
<a href="javascript:batchEntries(<?= $base->getId () ?>, false);"><?= $AppUI->_('batchSelectNone'); ?></a>
</td>
</tr>
</table>
<select name="entries_<?= $base->getId () ?>[]" multiple="multiple" style="width:95%;height:130px;">
<?
foreach ($entries as $relative)
{
if ($relative->getId () == $entry->getId ())
continue;
$selected = false;
// relations
foreach ($relations as $relation)
{
if ($relative->getId () == $relation->getRelativeId ()) {
$selected = true;
break;
}
}
?>
<option value="<?= $relative->getId () ?>"<?= $selected ? ' selected="selected"' : '' ?>><?= $relative->getName () ?></option>
<? } ?>
</select>
<br /><br />
<?
}
}
?>
</td>
</tr>
<tr>
<td>
<br /><br />
<input class="button" type="button" name="cancel" value="<?= $AppUI->_('actionCancel') ?>" onClick="cancelIt();" />
</td>
<td> </td>
<td align="right">
<br /><br />
<input class="button" type="submit" name="btnFuseAction" value="<?= $AppUI->_('actionSubmit') ?>"/>
</td>
</tr>
</table>
</form>