[ Index ]
 

Code source de XOOPS 2.0.17.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/htdocs/class/xoopsform/ -> themeform.php (source)

   1  <?php
   2  // $Id: themeform.php 976 2007-08-11 05:12:30Z phppp $

   3  //  ------------------------------------------------------------------------ //

   4  //                XOOPS - PHP Content Management System                      //

   5  //                    Copyright (c) 2000 XOOPS.org                           //

   6  //                       <http://www.xoops.org/>                             //

   7  //  ------------------------------------------------------------------------ //

   8  //  This program is free software; you can redistribute it and/or modify     //

   9  //  it under the terms of the GNU General Public License as published by     //

  10  //  the Free Software Foundation; either version 2 of the License, or        //

  11  //  (at your option) any later version.                                      //

  12  //                                                                           //

  13  //  You may not change or alter any portion of this comment or credits       //

  14  //  of supporting developers from this source code or any supporting         //

  15  //  source code which is considered copyrighted (c) material of the          //

  16  //  original comment or credit authors.                                      //

  17  //                                                                           //

  18  //  This program is distributed in the hope that it will be useful,          //

  19  //  but WITHOUT ANY WARRANTY; without even the implied warranty of           //

  20  //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //

  21  //  GNU General Public License for more details.                             //

  22  //                                                                           //

  23  //  You should have received a copy of the GNU General Public License        //

  24  //  along with this program; if not, write to the Free Software              //

  25  //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //

  26  //  ------------------------------------------------------------------------ //

  27  // Author: Kazumi Ono (AKA onokazu)                                          //

  28  // URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //

  29  // Project: The XOOPS Project                                                //

  30  // ------------------------------------------------------------------------- //

  31  if (!defined('XOOPS_ROOT_PATH')) {
  32      die("XOOPS root path not defined");
  33  }
  34  /**

  35   * 

  36   * 

  37   * @package     kernel

  38   * @subpackage  form

  39   * 

  40   * @author        Kazumi Ono    <onokazu@xoops.org>

  41   * @copyright    copyright (c) 2000-2003 XOOPS.org

  42   */
  43  /**

  44   * base class

  45   */
  46  include_once XOOPS_ROOT_PATH."/class/xoopsform/form.php";
  47  
  48  /**

  49   * Form that will output as a theme-enabled HTML table

  50   * 

  51   * Also adds JavaScript to validate required fields

  52   * 

  53   * @author    Kazumi Ono    <onokazu@xoops.org>

  54   * @copyright    copyright (c) 2000-2003 XOOPS.org

  55   * 

  56   * @package     kernel

  57   * @subpackage  form

  58   */
  59  class XoopsThemeForm extends XoopsForm
  60  {
  61      /**

  62       * Insert an empty row in the table to serve as a seperator.

  63       * 

  64       * @param    string  $extra  HTML to be displayed in the empty row.

  65       * @param    string    $class    CSS class name for <td> tag

  66       */
  67  	function insertBreak($extra = '', $class= '')
  68      {
  69          $class = ($class != '') ? " class='$class'" : '';
  70           //Fix for $extra tag not showing

  71          if ($extra) {
  72              $extra = "<tr><td colspan='2' $class>$extra</td></tr>";
  73              $this->addElement($extra);
  74          } else {
  75              $extra = "<tr><td colspan='2' $class>&nbsp;</td></tr>";
  76              $this->addElement($extra);
  77          }
  78      }
  79      
  80      /**

  81       * create HTML to output the form as a theme-enabled table with validation.

  82       * 

  83       * @return    string

  84       */
  85  	function render()
  86      {
  87          $ret = "
  88              <form name='".$this->getName()."' id='".$this->getName()."' action='".$this->getAction()."' method='".$this->getMethod()."' onsubmit='return xoopsFormValidate_".$this->getName()."();'".$this->getExtra().">
  89              <table width='100%' class='outer' cellspacing='1'>
  90              <tr><th colspan='2'>".$this->getTitle()."</th></tr>
  91          ";
  92          $hidden = '';
  93          $class ='even';
  94          foreach ( $this->getElements() as $ele ) {
  95              if (!is_object($ele)) {
  96                  $ret .= $ele;
  97              } elseif ( !$ele->isHidden() ) {
  98                  $ret .= "<tr valign='top' align='left'><td class='head'>";
  99                  if ( ($caption = $ele->getCaption()) != '' ) {
 100                      $ret .= 
 101                          "<div class='xoops-form-element-caption" . ($ele->isRequired() ? "-required" : "" ) . "'>".
 102                          "<span class='caption-text'>{$caption}</span>".
 103                          "<span class='caption-marker'>*</span>".
 104                          "</div>";
 105                  }
 106                  if ( ($desc = $ele->getDescription()) != '' ) {
 107                      $ret .= "<div class='xoops-form-element-help'>{$desc}</div>";
 108                  }
 109                  $ret .= "</td><td class='$class'>".$ele->render()."</td></tr>\n";
 110              } else {
 111                  $hidden .= $ele->render();
 112              }
 113          }
 114          $ret .= "</table>\n$hidden\n</form>\n";
 115          $ret .= $this->renderValidationJS( true );
 116          return $ret;
 117      }
 118  }
 119  ?>


Généré le : Sun Nov 25 11:44:32 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics