Location: PHPKode > projects > Knowledge Box > knowledgebox/wizard/entry.php
<?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->_($entry_id > 0 ? 'titleEditEntry' : 'titleNewEntry'))), KB_MODULE_ICON);

  // breadcrumb
  $titleBlock->addCrumb ('?m=' . KB_MODULE, html_entity_decode ($base->getName ()));
  if ($entry_id > 0) {
    $titleBlock->addCrumb ('?m=' . KB_MODULE . '&a=view&id=' . $entry->getId (), html_entity_decode ($entry->getName ()));
    $titleBlock->addCrumb ('?m=' . KB_MODULE . '&a=relative&id=' . $entry->getId (), utf8_encode (html_entity_decode ($AppUI->_('crumbEditRelations'))));
  }

  // delete link
  if ($entry_id > 0)
    $titleBlock->addCrumbDelete (utf8_encode (html_entity_decode ($AppUI->_('actionDeleteEntry'))));

  // show the title block
  $titleBlock->show ();

  // get resources
  $fields = KBModuleField::getFieldsByBase (KB_BASE);
  $groups = KBModuleGroup::getGroupsByBase (KB_BASE);
  $relations = KBModuleRelation::getRelationsByEntry ($entry->getId ());
  
  // config
  $configDateFormat = KBModuleConfig::getConfig (KB_BASE, KB_CONFIG_PROPERTY_DATEFORMAT);
  $configDateSeparator = KBModuleConfig::getConfig (KB_BASE, KB_CONFIG_PROPERTY_DATESEPARATOR);
  $configWYSIWYGFormat = KBModuleConfig::getConfig (KB_BASE, KB_CONFIG_PROPERTY_WYSIWYG);

?>

<script type="text/javascript" src="modules/<?= KB_MODULE ?>/lib/overlib/overlib.js"><!-- overLIB (c) Erik Bosrup --></script>

<style type="text/css">@import url(modules/<?= KB_MODULE ?>/lib/jscalendar/calendar-blue.css);</style>
<script type="text/javascript" src="modules/<?= KB_MODULE ?>/lib/jscalendar/calendar.js"></script>
<script type="text/javascript" src="modules/<?= KB_MODULE ?>/lib/jscalendar/lang/calendar-<?= $AppUI->user_locale ?>.js"></script>
<script type="text/javascript" src="modules/<?= KB_MODULE ?>/lib/jscalendar/calendar-setup.js"></script>

<script type="text/javascript" src="modules/<?= KB_MODULE ?>/lib/tinymce/tiny_mce.js"></script>

<script type="text/javascript">
  
  tinyMCE.init ({
    mode : "textareas",
    <? if ($configWYSIWYGFormat->getIntValue () == KB_WYSIWYG_ADVANCED) { ?>
	  theme : "advanced",
    theme_advanced_resizing : true,
	  theme_advanced_resizing_use_cookie : false,
	  theme_advanced_toolbar_location : "top",
	  theme_advanced_statusbar_location : "bottom"
    <? } elseif ($configWYSIWYGFormat->getIntValue () == KB_WYSIWYG_FULL) { ?>
	  theme : "advanced",
    theme_advanced_resizing : true,
	  theme_advanced_resizing_use_cookie : false,
	  plugins : "table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,flash,searchreplace,print,contextmenu",
	theme_advanced_buttons1_add_before : "save,separator",
	theme_advanced_buttons1_add : "fontselect,fontsizeselect",
	theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,zoom,separator,forecolor,backcolor",
	theme_advanced_buttons2_add_before: "cut,copy,paste,separator,search,replace,separator",
	theme_advanced_buttons3_add_before : "tablecontrols,separator",
	theme_advanced_buttons3_add : "emotions,iespell,flash,advhr,separator,print",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_path_location : "bottom",
	plugin_insertdate_dateFormat : "%Y-%m-%d",
	plugin_insertdate_timeFormat : "%H:%M:%S",
	extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]"
    <? } else { ?>
	  theme : "advanced",
    theme_advanced_resizing : true,
	  theme_advanced_resizing_use_cookie : false,
	  theme_advanced_toolbar_location : "top",
	  theme_advanced_statusbar_location : "bottom",
	  plugins : "table",
	  theme_advanced_buttons1 : "bold,italic,underline,separator,sub,sub,separator,bullist,numlist,link,unlink,separator,image,hr,table,separator,undo,redo,removeformat",
	  theme_advanced_buttons2 : ""
	  <? } ?>
  });

  function isEmptyValue (id)
  {
    return document.entryForm ["field_" + id].value.length == 0;
  }
  
  function isEmptyInformation (id)
  {
    return isEmptyValue (id + "_information");
  }
  
  function alertMandatory (id, name)
  {
    alert (name + " <?= utf8_encode (html_entity_decode ($AppUI->_('alertEntryFieldMandatory'))) ?>");
    document.entryForm ["field_" + id].focus ();
    return false;
  }
  
  function alertMandatoryInformation (id, name)
  {
    return alertMandatory (id + "_information", name);
  }
  
  function alertImageType (id, name)
  {
    alert (name + " <?= utf8_encode (html_entity_decode ($AppUI->_('alertEntryImageType'))) ?>");
    document.entryForm ["field_" + id].focus ();
    return false;
  }
  
  function isValidImage (id, name)
  {
    var tn = document.entryForm ["field_" + id].value.split (/[/\\\\]/);
    var te = tn [tn.length - 1].split (".");
    if (te.length < 2)
      return alertImageType (id, name);

    var tx = te [te.length - 1].toLowerCase ();
    if (tx != "png" && tx != "jpg" && tx != "jpeg" && tx != "gif")
      return alertImageType (id, name);

    return true;
  }
  
  function alertMandatoryDate (name)
  {
    alert (name + " <?= utf8_encode (html_entity_decode ($AppUI->_('alertEntryFieldMandatory'))) ?>");
    return false;
  }
  
  function alertInvalidDate (name)
  {
    alert (name + " <?= utf8_encode (html_entity_decode ($AppUI->_('alertEntryNotValidDate'))) ?>");
    return false;
  }
  
  function isValidDate (id)
  {
    var day = new Number (document.entryForm ["field_" + id + "_day"].value);
    var month = new Number (document.entryForm ["field_" + id + "_month"].value);
    var year = new Number (document.entryForm ["field_" + id + "_year"].value);
  
    // parse error
    if (isNaN (day) || day == 0 || isNaN (month) || month == 0 || isNaN (year) || year == 0)
      return false;

    // try date
    var trydate = new Date (year, month - 1, day);
    return (day == trydate.getDate () && (month - 1) == trydate.getMonth () && year == trydate.getFullYear ());
  }

  function submitIt ()
  {
    var f = document.entryForm;

    if (f.name.value.length == 0) {
      alert ("<?= utf8_encode (html_entity_decode ($AppUI->_('alertEmptyEntryName'))) ?>");
      f.name.focus ();
      return false;
    }

  <?
    // fields validation
    foreach ($fields as $field)
    {
        // text mandatory & email mandatory
        if ($field->isMandatory () && ($field->getType () == KB_FIELD_TEXT || $field->getType () == KB_FIELD_EMAIL))
        {
  ?>
    if (isEmptyValue ("<?= $field->getId () ?>"))
      return alertMandatory ("<?= $field->getId () ?>", "<?= $field->getNameJS () ?>");

  <?
        // html mandatory
        } elseif ($field->isMandatory () && $field->getType () == KB_FIELD_HTML) {
  ?>
    if (isEmptyValue ("<?= $field->getId () ?>"))
      return alertMandatory ("<?= $field->getId () ?>", "<?= $field->getNameJS () ?>");

  <?
        // password mandatory on insert
        // (on update, empty password means keep the same password)
        } elseif ($entry_id == 0 && $field->isMandatory () && $field->getType () == KB_FIELD_PASSWORD) {
  ?>
    if (isEmptyValue ("<?= $field->getId () ?>"))
      return alertMandatory ("<?= $field->getId () ?>", "<?= $field->getNameJS () ?>");

  <?
        // date mandatory
        } elseif ($field->isMandatory () && $field->getType () == KB_FIELD_DATE) {
  ?>
    if (isEmptyValue ("<?= $field->getId () ?>_day") && isEmptyValue ("<?= $field->getId () ?>_month") && isEmptyValue ("<?= $field->getId () ?>_year"))
      return alertMandatoryDate ("<?= $field->getNameJS () ?>");

    else if (!isValidDate ("<?= $field->getId () ?>"))
      return alertInvalidDate ("<?= $field->getNameJS () ?>");

  <?
        // date not mandatory
        } elseif (!$field->isMandatory () && $field->getType () == KB_FIELD_DATE) {
  ?>
    if (!isEmptyValue ("<?= $field->getId () ?>_day") || !isEmptyValue ("<?= $field->getId () ?>_month") || !isEmptyValue ("<?= $field->getId () ?>_year")) {

      if (!isValidDate ("<?= $field->getId () ?>"))
        return alertInvalidDate ("<?= $field->getNameJS () ?>");
    }

  <?
        // file mandatory on insert
        } elseif ($entry_id == 0 && $field->isMandatory () && $field->getType () == KB_FIELD_FILE) {
  ?>
    if (isEmptyValue ("<?= $field->getId () ?>"))
      return alertMandatory ("<?= $field->getId () ?>", "<?= $field->getNameJS () ?>");
    
    else if (isEmptyInformation ("<?= $field->getId () ?>"))
      return alertMandatoryInformation ("<?= $field->getId () ?>", "<?= utf8_encode (html_entity_decode ($AppUI->_('alertEntryDescription'))); ?> <?= $field->getNameJS () ?>");

  <?
        // file mandatory on update
        } elseif ($entry_id > 0 && $field->isMandatory () && $field->getType () == KB_FIELD_FILE) {
  ?>    
    if (isEmptyInformation ("<?= $field->getId () ?>"))
      return alertMandatoryInformation ("<?= $field->getId () ?>", "<?= utf8_encode (html_entity_decode ($AppUI->_('alertEntryDescription'))); ?> <?= $field->getNameJS () ?>");

  <?
        // file not mandatory on insert
        } elseif ($entry_id == 0 && !$field->isMandatory () && $field->getType () == KB_FIELD_FILE) {
  ?>
    if (!isEmptyValue ("<?= $field->getId () ?>") && isEmptyInformation ("<?= $field->getId () ?>"))
      return alertMandatoryInformation ("<?= $field->getId () ?>", "<?= utf8_encode (html_entity_decode ($AppUI->_('alertEntryDescription'))); ?> <?= $field->getNameJS () ?>");

  <?
        // file not mandatory on update
        } elseif ($entry_id > 0 && !$field->isMandatory () && $field->getType () == KB_FIELD_FILE) {
  ?>
    if (!isEmptyValue ("<?= $field->getId () ?>") && isEmptyInformation ("<?= $field->getId () ?>"))
      return alertMandatoryInformation ("<?= $field->getId () ?>", "<?= utf8_encode (html_entity_decode ($AppUI->_('alertEntryDescription'))); ?> <?= $field->getNameJS () ?>");

          <?
            // file exists, do not permit empty description
            $substance = KBModuleSubstance::getSubstance ($entry->getId (), $field->getId ());
            if (strlen ($substance->getTextValue ()) > 0) {
          ?>
          else if (isEmptyInformation ("<?= $field->getId () ?>"))
            return alertMandatoryInformation ("<?= $field->getId () ?>", "<?= utf8_encode (html_entity_decode ($AppUI->_('alertEntryDescription'))); ?> <?= $field->getNameJS () ?>");
          <?
            }
          ?>

  <?
        // link mandatory
        } elseif ($field->isMandatory () && $field->getType () == KB_FIELD_LINK) {
  ?>
    if (isEmptyValue ("<?= $field->getId () ?>"))
      return alertMandatory ("<?= $field->getId () ?>", "<?= $field->getNameJS () ?>");

    else if (isEmptyInformation ("<?= $field->getId () ?>"))
      return alertMandatoryInformation ("<?= $field->getId () ?>", "<?= utf8_encode (html_entity_decode ($AppUI->_('alertEntryDescription'))); ?> <?= $field->getNameJS () ?>");

  <?
        // link not mandatory
        } elseif (!$field->isMandatory () && $field->getType () == KB_FIELD_LINK) {
  ?>
    if (!isEmptyValue ("<?= $field->getId () ?>") && isEmptyInformation ("<?= $field->getId () ?>"))
      return alertMandatoryInformation ("<?= $field->getId () ?>", "<?= utf8_encode (html_entity_decode ($AppUI->_('alertEntryDescription'))); ?> <?= $field->getNameJS () ?>");

  <?
        // image mandatory on insert
        } elseif ($entry_id == 0 && $field->isMandatory () && $field->getType () == KB_FIELD_IMAGE) {
  ?>
    if (isEmptyValue ("<?= $field->getId () ?>"))
      return alertMandatory ("<?= $field->getId () ?>", "<?= $field->getNameJS () ?>");

    else {
      if (!isValidImage ("<?= $field->getId () ?>", "<?= $field->getNameJS () ?>"))
        return false;
    }
  <?
        // image must be valid if set on update
        } elseif ($entry_id > 0 && $field->isMandatory () && $field->getType () == KB_FIELD_IMAGE) {
  ?>
    if (!isEmptyValue ("<?= $field->getId () ?>")) {
      if (!isValidImage ("<?= $field->getId () ?>", "<?= $field->getNameJS () ?>"))
        return false;
    }
  <?
        // image not mandatory
        } elseif (!$field->isMandatory () && $field->getType () == KB_FIELD_IMAGE) {
  ?>
    if (!isEmptyValue ("<?= $field->getId () ?>")) {
      if (!isValidImage ("<?= $field->getId () ?>", "<?= $field->getNameJS () ?>"))
        return false;
    }
  <?
        }
    }
  ?>

    if (!hasSelectedKeywords ()) {
      alert ("<?= utf8_encode (html_entity_decode ($AppUI->_('alertUnselectedEntryKeywords'))); ?>");
      return false;
    }

    return true;
  }
  
  function delIt ()
  {
    if (confirm ("<?= utf8_encode (html_entity_decode ($AppUI->_('alertDeleteEntry'))); ?>"))
    {
      var f = document.entryForm;
      f.del.value = "1";
      f.submit ();
    }
  }
  
  function cancelIt ()
  {
    location.href = "index.php?m=<?= KB_MODULE ?>";
  }
  
  function batchKeywords (id, value)
  {
    var opt = document.entryForm ["keywords_" + id + "[]"].options;
    for (var i = 0; i < opt.length; i++)
      opt [i].selected = value;
  }
  
  function hasSelectedKeywords ()
  {
    <? foreach ($groups as $group) { ?>
      if (testKeywords (<?= $group->getId () ?>))
        return true;
    <? } ?>

    return false;
  }
  
  function testKeywords (id)
  {
    var opt = document.entryForm ["keywords_" + id + "[]"].options;
    
    for (var i = 0; i < opt.length; i++) {
      if (opt [i].selected)
        return true;
    }
    
    return false;
  }

</script>

<form name="entryForm" action="index.php?m=<?= KB_MODULE ?>" enctype="multipart/form-data" method="post" onSubmit="return submitIt();">
<input type="hidden" name="MAX_FILE_SIZE" value="<?= 32000000 * 1024 ?>">

<input type="hidden" name="dosql" value="entry" />
<input type="hidden" name="del" value="0" />
<input type="hidden" name="id" value="<?= $entry_id ?>" />

<table cellspacing="0" cellpadding="4" border="0" width="100%" class="std">
<tr>
  <td width="50%" valign="top">
        <br />
        <table cellspacing="0" cellpadding="2" border="0">
        <tr>
          <td align="right" nowrap="nowrap"><b><?= $AppUI->_('columnEntryField') ?></b></td>
          <td width="20">&nbsp;</td>
          <td align="center"><b><?= $AppUI->_('columnEntryMandatory') ?></b></td>      
          <td width="20">&nbsp;</td>
          <td width="100%"><b><?= $AppUI->_('columnEntryValue') ?></b></td>
        </tr>
        <tr>
          <td colspan="5">&nbsp;</td>
        </tr>
        <tr>
          <td align="right" nowrap="nowrap"><?= $AppUI->_('inputEntryName') ?></td>
          <td>&nbsp;</td>
          <td align="center">
            <?= dPshowImage ('./images/icons/posticon.gif', '14', '11') ?>
          </td>
          <td>&nbsp;</td>
          <td>
            <div style="padding-top:2px;padding-bottom:2px;">
              <input type="text" size="72" name="name" value="<?= str_replace ('&amp;', '&', dPformSafe ($entry->getName ())) ?>" maxlength="192" style="width:452px;" />
            </div>
          </td>
        </tr>
        <tr>
          <td align="right" nowrap="nowrap"><?= $AppUI->_('inputEntryVisible') ?></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>
            <input type="checkbox" name="visible" value="1" style="margin-left:0px;"<? if ($entry_id == 0 || $entry->isVisible ()) print (' checked="checked"'); ?> />
          </td>
        </tr>
      <?
        // iterate fields
        foreach ($fields as $field)
        {
          // label
          if ($field->isType (KB_FIELD_LABEL))
          {
        ?>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>
              <h2 style="padding-bottom:10px;"><?= $field->getName () ?></h2>
            </td>
          </tr>
        <?
        
          // normal field
          } else {
          
            // get substance
            $substance = KBModuleSubstance::getSubstance ($entry->getId (), $field->getId ());
        ?>
          <tr>
            <td align="right" nowrap="nowrap">
              <? if (strlen ($field->getHelper ()) > 0) { ?>
                <a href="javascript:void(0);" onmouseover="return overlib('<?= addslashes ($field->getHelper ()) ?>', STICKY, MOUSEOFF, WIDTH, -1);" onmouseout="return nd();"><u><?= $field->getName () ?></u></a>
              <? } else { ?>
                <?= $field->getName () ?>
              <? } ?>
            </td>
            <td>&nbsp;</td>
            <td align="center">
              <? if ($field->isMandatory ()) { ?>
                <?= dPshowImage ('./images/icons/posticon.gif', '14', '11') ?>
              <? } ?>
            </td>
            <td>&nbsp;</td>
            <td>
              <?
                // text & email
                if ($field->getType () == KB_FIELD_TEXT || $field->getType () == KB_FIELD_EMAIL) {
              ?>
                <div style="padding-top:2px;padding-bottom:2px;">
                  <input type="text" size="72" name="field_<?= $field->getId () ?>" value="<?= str_replace ('&amp;', '&', dPformSafe ($substance->getTextValue ())) ?>" maxlength="128" style="width:452px;" />
                </div>
              <?
                // big text
                } elseif ($field->getType () == KB_FIELD_HTML) {
              ?>
                <div style="padding-top:5px;padding-bottom:5px;">
                  <textarea name="field_<?= $field->getId () ?>" cols="32" rows="10" style="width:451px;"><?= $substance->getTextValue () ?></textarea>
                </div>
              <?
                // password
                } elseif ($field->getType () == KB_FIELD_PASSWORD) {
              ?>
                <div style="padding-top:2px;padding-bottom:2px;">
                  <input type="password" size="72" name="field_<?= $field->getId () ?>" value="" maxlength="128" style="width:452px;" />
                </div>
              <?
                // file
                } elseif ($field->getType () == KB_FIELD_FILE) {
              ?>
                <div style="padding-top:2px;padding-bottom:2px;">
                  <table cellpadding="0" cellspacing="0" border="0">
                  <tr>
                    <td style="padding-bottom:4px;"><?= $AppUI->_('inputEntryFile') ?></td>
                    <td style="padding-bottom:4px;padding-left:9px;"><input type="file" size="40" name="field_<?= $field->getId () ?>" /></td>
                  </tr>
                  <tr>
                    <td><?= $AppUI->_('inputEntryDescription') ?></td>
                    <td style="padding-left:9px;"><input type="text" size="72" name="field_<?= $field->getId () ?>_information" value="<?= str_replace ('&amp;', '&', dPformSafe ($substance->getInformation ())) ?>" maxlength="128" style="width:374px;" /></td>
                  </tr>
                  <? if (strlen (!$field->isMandatory () && $substance->getTextValue ()) > 0) { ?>
                    <tr>
                      <td>&nbsp;</td>
                      <td style="padding-left:9px;padding-top:5px;">
                        <input type="checkbox" name="field_<?= $field->getId () ?>_remove" value="1" style="margin-left:0px;" />
                        <?= $AppUI->_('inputEntryRemoveFile') ?>
                      </td>
                    </tr>
                  <? } ?>
                  </table>
                </div>
              <?
                // image
                } elseif ($field->getType () == KB_FIELD_IMAGE) {
              ?>
                <div style="padding-top:2px;">
                  <table cellpadding="0" cellspacing="0" border="0">
                  <tr>
                    <td style="padding-bottom:4px;"><?= $AppUI->_('inputEntryFile') ?></td>
                    <td style="padding-bottom:4px;padding-left:9px;"><input type="file" size="40" name="field_<?= $field->getId () ?>" /></td>
                  </tr>
                  <tr>
                    <td style="width:68px;height:1px;"></td>
                    <td style="height:1px;"></td>
                  </tr>
                  <? if (strlen (!$field->isMandatory () && $substance->getTextValue ()) > 0) { ?>
                    <tr>
                      <td>&nbsp;</td>
                      <td style="padding-left:9px;padding-bottom:2px;">
                        <input type="checkbox" name="field_<?= $field->getId () ?>_remove" value="1" style="margin-left:0px;" />
                        <?= $AppUI->_('inputEntryRemoveFile') ?>
                      </td>
                    </tr>
                  <? } ?>
                  </table>
                </div>
              <?
                // link
                } elseif ($field->getType () == KB_FIELD_LINK) {
              ?>
                <div style="padding-top:2px;padding-bottom:2px;">
                  <table cellpadding="0" cellspacing="0" border="0">
                  <tr>
                    <td style="padding-bottom:4px;"><?= $AppUI->_('inputEntryURL') ?></td>
                    <td style="padding-bottom:4px;padding-left:9px;"><input type="text" size="72" name="field_<?= $field->getId () ?>" value="<?= str_replace ('&amp;', '&', dPformSafe ($substance->getTextValue ())) ?>" maxlength="128" style="width:374px;" /></td>
                  </tr>
                  <tr>
                    <td><?= $AppUI->_('inputEntryDescription') ?></td>
                    <td style="padding-left:9px;"><input type="text" size="72" name="field_<?= $field->getId () ?>_information" value="<?= str_replace ('&amp;', '&', dPformSafe ($substance->getInformation ())) ?>" maxlength="128" style="width:374px;" /></td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td style="padding-left:9px;padding-bottom:2px;">
                      <input type="checkbox" name="field_<?= $field->getId () ?>_target" value="1" style="margin-left:0px;" <? if ($entry_id == 0 || (int) $substance->getMimeType () == 1) print (' checked="checked"'); ?> />
                      <?= $AppUI->_('inputEntryURLNewWindow') ?>
                    </td>
                  </tr>
                  </table>
                </div>
              <?
                // date
                } elseif ($field->getType () == KB_FIELD_DATE) {
    
                  // format
                  if (strlen ($substance->getTextValue ()) > 0)
                  {
                    $day = substr ($substance->getTextValue (), -2);
                    $month = substr ($substance->getTextValue (), 4, 2);
                    $year = substr ($substance->getTextValue (), 0, 4);
                  } else {
                    $day = '';
                    $month = '';
                    $year = '';
                  }
                  
                  // date style
                  $dateParts = explode ('.', $configDateFormat->getStringValue ());
                  $europeanDate = $dateParts [0] == 'dd' || $dateParts [0] == 'd';
                  $unixDate = $dateParts [0] == 'yyyy' || $dateParts [0] == 'yy';

              ?>
                <div style="padding-top:2px;padding-bottom:2px;">
                  <table cellpadding="0" cellspacing="0" border="0">
                  <tr>
                    <td style="padding-bottom:4px;" valign="bottom">
                    <? if ($europeanDate) { ?>
                      dd<?= $configDateSeparator->getStringValue () ?>mm<?= $configDateSeparator->getStringValue () ?>yyyy
                    <? } elseif ($unixDate) { ?>
                      yyyy<?= $configDateSeparator->getStringValue () ?>mm<?= $configDateSeparator->getStringValue () ?>dd
                    <? } else { ?>
                      mm<?= $configDateSeparator->getStringValue () ?>dd<?= $configDateSeparator->getStringValue () ?>yyyy
                    <? } ?>
                    </td>
                    <td style="padding-bottom:4px;padding-left:5px;">
                      <? if ($europeanDate) { ?>
                        <input type="text" size="3" id="field_<?= $field->getId () ?>_day" name="field_<?= $field->getId () ?>_day" value="<?= $day ?>" maxlength="2" />
                        <?= $configDateSeparator->getStringValue () ?>
                        <input type="text" size="3" id="field_<?= $field->getId () ?>_month" name="field_<?= $field->getId () ?>_month" value="<?= $month ?>" maxlength="2" />
                        <?= $configDateSeparator->getStringValue () ?>
                        <input type="text" size="5" id="field_<?= $field->getId () ?>_year" name="field_<?= $field->getId () ?>_year" value="<?= $year ?>" maxlength="4" />
                      <? } elseif ($unixDate) { ?>
                        <input type="text" size="5" id="field_<?= $field->getId () ?>_year" name="field_<?= $field->getId () ?>_year" value="<?= $year ?>" maxlength="4" />
                        <?= $configDateSeparator->getStringValue () ?>
                        <input type="text" size="3" id="field_<?= $field->getId () ?>_month" name="field_<?= $field->getId () ?>_month" value="<?= $month ?>" maxlength="2" />
                        <?= $configDateSeparator->getStringValue () ?>
                        <input type="text" size="3" id="field_<?= $field->getId () ?>_day" name="field_<?= $field->getId () ?>_day" value="<?= $day ?>" maxlength="2" />
                      <? } else { ?>
                        <input type="text" size="3" id="field_<?= $field->getId () ?>_month" name="field_<?= $field->getId () ?>_month" value="<?= $month ?>" maxlength="2" />
                        <?= $configDateSeparator->getStringValue () ?>
                        <input type="text" size="3" id="field_<?= $field->getId () ?>_day" name="field_<?= $field->getId () ?>_day" value="<?= $day ?>" maxlength="2" />
                        <?= $configDateSeparator->getStringValue () ?>
                        <input type="text" size="5" id="field_<?= $field->getId () ?>_year" name="field_<?= $field->getId () ?>_year" value="<?= $year ?>" maxlength="4" />
                      <? } ?>
                      <button id="triggerDate_<?= $field->getId () ?>" style="border:solid 1px #666666;"><?= $AppUI->_('inputEntryChooseDate') ?></button>
                      
                      <script type="text/javascript">
                        function dateChanged<?= $field->getId () ?> (calendar) {
                          var fd = calendar.date.getDate ();
                          fd = fd < 10 ? "0" + fd : fd;
                          document.entryForm.field_<?= $field->getId () ?>_day.value = fd;
                          var fm = calendar.date.getMonth() + 1;
                          fm = fm < 10 ? "0" + fm : fm;
                          document.entryForm.field_<?= $field->getId () ?>_month.value = fm;
                          var fy = document.entryForm.field_<?= $field->getId () ?>_year.value = calendar.date.getFullYear();
                        };

                        Calendar.setup(
                          {
                            inputField : "field_<?= $field->getId () ?>_year",
                            onSelect : dateChanged<?= $field->getId () ?>,
                            button : "triggerDate_<?= $field->getId () ?>",
                            firstDay : 1
                          }
                        );
                      </script>
                    </td>
                  </tr>
                  </table>
                </div>
              <?
                // end type
                }
              ?>
            </td>
          </tr>
        <?
          // end normal field
          }
        // end fields
        }
      ?>
        </table>
  </td>
  <td width="20">&nbsp;</td>
  <td valign="top">
      <br />
      <b><?= $AppUI->_('columnEntryKeywords') ?></b>
      
      <br /><br /><br />
      <?
        // iterate groups
        foreach ($groups as $group)
        {
          // get labels
          $labels = KBModuleLabel::getLabelsByGroup ($group->getId ());
          
          // has keywords
          $has = KBModuleKeyword::hasKeywordsInGroup ($group->getId ());
      ?>
        <div style="padding-bottom:5px;width:300px;">
          <table cellpadding="0" cellspacing="0" border="0" width="100%">
          <tr>
            <td style="font-weight:bold;"><?= $group->getName () ?></td>
            <td align="right">
            <? if ($has) { ?>
              <a href="javascript:batchKeywords(<?= $group->getId () ?>, true);"><?= $AppUI->_('batchSelectAll') ?></a>
              |
              <a href="javascript:batchKeywords(<?= $group->getId () ?>, false);"><?= $AppUI->_('batchSelectNone') ?></a>
            <? } ?>
            </td>
          </tr>
          </table>
        </div>
        <select name="keywords_<?= $group->getId () ?>[]" multiple="multiple" style="width:300px;height:<? if ($has) { ?>135<? } else { ?>35<? } ?>px;">
        <?
          // iterate labels
          foreach ($labels as $label)
          {
            // get keywords
            $keywords = KBModuleKeyword::getKeywordsByLabel ($label->getId ());
        ?>
          <optgroup label="<?= $label->getName () ?>">
          <?
            // iterate keywords
            foreach ($keywords as $keyword)
            {
              $selected = false;
              
              // relations
              foreach ($relations as $relation)
              {
                if ($keyword->getId () == $relation->getKeywordId ()) {
                  $selected = true;
                  continue;
                }
              }
          ?>
            <option value="<?= $keyword->getId () ?>"<?= $selected ? ' selected="selected"' : '' ?>><?= $keyword->getName () ?></option>
          <?
            } // end iterate keywords
          ?>
          </optgroup>
        <?
          } // end iterate labels
        ?>
        </select>
        
        <br /><br />
      <?
        } // end iterate groups
      ?>
  </td>
</tr>
<tr>
  <td>
    <br /><br />
    <input class="button" type="button" name="cancel" value="<?= $AppUI->_('actionCancel') ?>" onClick="cancelIt();" />
  </td>
  <td>&nbsp;</td>
  <td align="right">
    <br /><br />
    <input class="button" type="submit" name="btnFuseAction" value="<?= $AppUI->_('actionSubmit') ?>"/>
  </td>
</tr>
</table>

</form>
Return current item: Knowledge Box