home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / CMS / xoops-2.0.18.1.exe / xoops-2.0.18.1 / htdocs / class / xoopsform / themeform.php < prev   
Encoding:
PHP Script  |  2008-01-09  |  4.9 KB  |  120 lines

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