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


  // get fields
  $fields = KBModuleField::getFieldsByBase (KB_BASE);

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

?>

<h2 style="background-color:#FFFFFF;padding-top:10px;padding-bottom:10px;padding-left:2px;"><?= $AppUI->_('titleFields') ?></h2>

<table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl">
<tr>
  <th width="35"><?= $AppUI->_('columnEdit') ?></th>
  <th><?= $AppUI->_('columnFieldName') ?></th>
  <th><?= $AppUI->_('columnFieldHelper') ?></th>
  <th width="75"><?= $AppUI->_('columnFieldType') ?></th>
  <th width="75"><?= $AppUI->_('columnFieldMandatory') ?></th>
  <th width="70"><?= $AppUI->_('columnFieldDisplayed') ?></th>
  <? if ($base->isAuthenticationBase ()) { ?>
    <th width="110"><?= $AppUI->_('columnFieldAuthentication') ?></th>
  <? } ?>
</tr>
<tr>
  <td align="center">
    <?= dPshowImage ('./images/obj/lock.gif', '16', '16') ?>
  </td>
  <td>
    <?= $AppUI->_('fieldTypeName') ?>
  </td>
  <td style="color:#666666;">
    <?= $AppUI->_('identifiantWarning') ?>
  </td>
  <td align="center">
    <?= $AppUI->_('fieldTypeText') ?>
  </td>
  <td align="center">
    <?= dPshowImage ('./images/log-notice.gif', '14', '14') ?></a>
  </td>
  <td align="center">
    <?= dPshowImage ('./images/log-notice.gif', '14', '14') ?>
  </td>
  <? if ($base->isAuthenticationBase ()) { ?>
    <td align="center">
      <?
        // config
        $configAuthenticationUsername = KBModuleConfig::getConfig (KB_BASE_UNDEFINED, KB_CONFIG_PROPERTY_AUTHENTICATION_USERNAME);

        // base is negative
        if ($configAuthenticationUsername->getIntValue () < KB_CONFIG_DEFAULT_AUTHENTICATION_UNDEFINED && abs ($configAuthenticationUsername->getIntValue ()) == KB_BASE)
        {
      ?>
        <?= $AppUI->_('identifiantTypeUser') ?>
      <? } ?>
    </td>
  <? } ?>
</tr>
<?

  // iterate over fields
  foreach ($fields as $field)
  {

?>
<tr>
  <td align="center">
    <a href="index.php?m=<?= KB_MODULE ?>&a=field&id=<?= $field->getId () ?>">
    <?= dPshowImage ('./images/icons/posticon.gif', '14', '11') ?></a>
  </td>
  <td>
    <?= $field->getName () ?>
  </td>
  <td>
    <?= $field->getHelper () ?>
  </td>
  <td align="center" nowrap="nowrap">
    <? if ($field->isType (KB_FIELD_TEXT)) { ?>
      <?= $AppUI->_('fieldTypeText') ?>
    <? } elseif ($field->isType (KB_FIELD_HTML)) { ?>
      <?= $AppUI->_('fieldTypeHTML') ?>
    <? } elseif ($field->isType (KB_FIELD_FILE)) { ?>
      <?= $AppUI->_('fieldTypeFile') ?>
    <? } elseif ($field->isType (KB_FIELD_IMAGE)) { ?>
      <?= $AppUI->_('fieldTypeImage') ?>
    <? } elseif ($field->isType (KB_FIELD_LINK)) { ?>
      <?= $AppUI->_('fieldTypeLink') ?>
    <? } elseif ($field->isType (KB_FIELD_EMAIL)) { ?>
      <?= $AppUI->_('fieldTypeEmail') ?>
    <? } elseif ($field->isType (KB_FIELD_DATE)) { ?>
      <?= $AppUI->_('fieldTypeDate') ?>
    <? } elseif ($field->isType (KB_FIELD_PASSWORD)) { ?>
      <?= $AppUI->_('fieldTypePassword') ?>
    <? } elseif ($field->isType (KB_FIELD_LABEL)) { ?>
      <?= $AppUI->_('fieldTypeLabel') ?>
    <? } ?>
  </td>
  <td align="center">
    <? if (!$field->isType (KB_FIELD_LABEL)) { ?>
      <? if ($field->isMandatory ()) { ?>
        <?= dPshowImage ('./images/log-notice.gif', '14', '14') ?>
      <? } else { ?>
        <?= dPshowImage ('./images/log-error.gif', '14', '14') ?>
      <? } ?>
    <? } ?>
  </td>
  <td align="center">
    <? if (!$field->isType (KB_FIELD_LABEL)) { ?>
      <? if ($field->isVisible ()) { ?>
        <?= dPshowImage ('./images/log-notice.gif', '14', '14') ?>
      <? } else { ?>
        <?= dPshowImage ('./images/log-error.gif', '14', '14') ?>
      <? } ?>
    <? } ?>
  </td>
  <? if ($base->isAuthenticationBase ()) { ?>
    <td align="center" nowrap="nowrap">
      <?
        // config
        $configAuthenticationUsername = KBModuleConfig::getConfig (KB_BASE_UNDEFINED, KB_CONFIG_PROPERTY_AUTHENTICATION_USERNAME);
        $configAuthenticationPassword = KBModuleConfig::getConfig (KB_BASE_UNDEFINED, KB_CONFIG_PROPERTY_AUTHENTICATION_PASSWORD);
        $configAuthenticationRecovery = KBModuleConfig::getConfig (KB_BASE_UNDEFINED, KB_CONFIG_PROPERTY_AUTHENTICATION_RECOVERY);

        // authenticate as username
        if ($configAuthenticationUsername->getIntValue () == $field->getId ())
        {
      ?>
          <?= $AppUI->_('identifiantTypeUser') ?>
      <?
        }
        // authenticate as password
        if ($configAuthenticationPassword->getIntValue () == $field->getId ())
        {
      ?>
          <?= $AppUI->_('identifiantTypePassword') ?>
      <?
        }
        // authenticate as recovery
        if ($configAuthenticationRecovery->getIntValue () == $field->getId ())
        {
          if ($configAuthenticationUsername->getIntValue () == $field->getId ())
            print ('&amp;');
      ?>
          <?= $AppUI->_('identifiantTypeRecovery') ?>
      <?
        }
      ?>
    </td>
  <? } ?>
</tr>
<?

  }
  // end iteration

?>
</table>

<div>&nbsp;</div>
Return current item: Knowledge Box