Location: PHPKode > projects > Knowledge Box > knowledgebox/external/print.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/>.
   */


  // 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))
  {
    // failed
    die ('Invalid Entry.');
  }

  // base
  $base = new KBModuleBase ();
  $base->load (KBEV_BASE);

  // config
  $configDateFormat = KBModuleConfig::getConfig (KBEV_BASE, KB_CONFIG_PROPERTY_DATEFORMAT);
  $configDateSeparator = KBModuleConfig::getConfig (KBEV_BASE, KB_CONFIG_PROPERTY_DATESEPARATOR);

  // get resources
  $fields = KBModuleField::getFieldsByBase (KBEV_BASE);
  $groups = KBModuleGroup::getGroupsByBase (KBEV_BASE);
  $relations = KBModuleRelation::getRelationsByEntry ($entry->getId ());
  $relatives = KBModuleRelative::getRelativesByEntry ($entry->getId ());

?>

<!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" />
  <style type="text/css">
    html, body, td
    {
      font-family: arial, helvetica, sans;
      font-size: 12px;
    }
    
    h1
    {
      margin: 0px;
      padding-top: 10px;
      padding-bottom: 20px;
    }
    
    h3
    {
      margin: 0px;
      padding-top:20px;
      padding-bottom:10px;
    }
  </style>
</head>

<body>

<table border="0" width="100%">
<tr>
	<td align="right"><img src="img/knowledgebox.png" alt="Knowledge Box" style="padding-right:20px;" border="0" /></td>
</tr>
</table>

<br />
<?= $base->getName () ?>
<h1><?= $entry->getName () ?></h1>

<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">&nbsp;</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) {
                  ?>
                    <?= $substance->getInformation () ?><br />
                    <?= str_replace ('&', '&amp;', $substance->getTextValue ()) ?>
                  <?
                  }
                  break;
                }
                case KB_FIELD_IMAGE:
                {
                  if (strlen ($substance->getTextValue ()) > 0) {
                  ?>
                    <img border="0" src="../io/<?= KB_STREAM_IMAGE ?>.php?entry=<?= $entry->getId () ?>&amp;field=<?= $field->getId () ?>">
                  <?
                  }
                  break;
                }
                case KB_FIELD_LINK:
                {
                  if (strlen ($substance->getTextValue ()) > 0) {
                    $targetBlank = (int) $substance->getMimeType () == 1;
                  ?>
                    <?= $substance->getInformation () ?>
                    <br />
                    <?= $substance->getTextValue () ?>
                  <?
                  }
                  break;
                }
                case KB_FIELD_EMAIL:
                {
                  if (strlen ($substance->getTextValue ()) > 0) {
                  ?>
                    <?= $substance->getTextValue () ?>
                  <?
                  }
                  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>&nbsp;</td>
            <td>&nbsp;</td>
            <td><h3 style="padding-top:10px;padding-bottom:0px;margin-bottom:5px;"><?= $field->getName () ?></h3></td>
          </tr>
        <?
          } // end normal field
        } // end iterate fields
      ?>
        <tr>
          <td colspan="3" height="3"></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td><h3 style="padding-top:10px;padding-bottom:0px;margin-bottom:5px;"><?= $translation ['labelViewKeywords'] ?></h3></td>
        </tr>
        <tr>
          <td nowrap="nowrap" valign="top" align="right"><?= $translation ['columnViewKeywords'] ?></td>
          <td width="20">&nbsp;</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 />');

                    ?>
                      <?= $keyword->getName () ?>
                    <?

                    $displayedKeywords++;
                    continue;
                  }
                }
              }
            }
            ?>
          </td>
        </tr>
        <? if (count ($relatives) > 0) { ?>
          <tr>
            <td colspan="3" height="3"></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td><h3 style="padding-top:10px;padding-bottom:0px;margin-bottom:5px;"><?= $translation ['labelViewRelations'] ?></h3></td>
          </tr>
          <tr>
            <td nowrap="nowrap" valign="top" align="right"><?= $translation ['columnViewRelations'] ?></td>
            <td width="20">&nbsp;</td>
            <td width="100%" valign="top">
              <?
            
              // iterate relatives
              foreach ($relatives as $relative)
              {            
                $element = new KBModuleEntry ();
                $element->load ($relative->getRelativeId ());
              ?>
                <?= $element->getName () ?>
                <br />
              <?
                }
              ?>
            </td>
          </tr>
        <? } ?>
        </table>

        <br />&nbsp;
  </td>
</tr>
</table>

<script type="text/javascript">
window.focus ();
print ();
</script>

</body>
</html>
Return current item: Knowledge Box