From: <on...@us...> - 2002-09-18 10:44:53
|
Update of /cvsroot/xoops/xoops-current/html/class/xoopsform In directory usw-pr-cvs1:/tmp/cvs-serv23022 Modified Files: themeform.php formdhtmltextarea.php form.php Log Message: no message Index: themeform.php =================================================================== RCS file: /cvsroot/xoops/xoops-current/html/class/xoopsform/themeform.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** themeform.php 15 Jul 2002 08:13:13 -0000 1.1.1.1 --- themeform.php 18 Sep 2002 10:44:49 -0000 1.2 *************** *** 29,37 **** function render($value=""){ ! $required = $this->getRequired(); ! $ret = "<h4 style='text-align:left;'>".$this->getTitle()."</h4>\n<form name='".$this->getName()."' id='".$this->getName()."' action='".$this->getAction()."' method='".$this->getMethod()."'".$this->getExtra().">\n<table border='0' cellpadding='0' cellspacing='0' valign='top' width='100%'><tr><td class='bg2'><table width='100%' border='0' cellpadding='4' cellspacing='1'>\n"; foreach ( $this->getElements() as $ele ) { if ( !$ele->isHidden() ) { ! $ret .= "<tr valign='top'><td class='bg3'><b>".$ele->getCaption()."</b></td><td class='bg1'>".$ele->render()."</td></tr>\n"; } else { $ret .= $ele->render()."\n"; --- 29,37 ---- function render($value=""){ ! $required =& $this->getRequired(); ! $ret = "<h4 style='text-align:left;'>".$this->getTitle()."</h4>\n<form name='".$this->getName()."' id='".$this->getName()."' action='".$this->getAction()."' method='".$this->getMethod()."'".$this->getExtra().">\n<table width='100%' class='xoopsTable' cellpadding='4' cellspacing='1'>\n"; foreach ( $this->getElements() as $ele ) { if ( !$ele->isHidden() ) { ! $ret .= "<tr valign='top'><td class='xoopsTableCaption'><b>".$ele->getCaption()."</b></td><td class='xoopsTableBody1'>".$ele->render()."</td></tr>\n"; } else { $ret .= $ele->render()."\n"; *************** *** 48,54 **** //---> </script>"; ! $ret .= "</table></td></tr></table>\n</form>\n"; $ret = $js.$ret; return $ret; } } --- 48,89 ---- //---> </script>"; ! $ret .= "</table>\n</form>\n"; $ret = $js.$ret; return $ret; + } + + // assign to smarty form template instead of displaying directly + function assign(&$tpl){ + $i = 0; + foreach ( $this->getElements() as $ele ) { + if ( !$ele->isHidden() ) { + $elements[$i]['caption'] = $ele->getCaption(); + $elements[$i]['body'] = $ele->render(); + $elements[$i]['hidden'] = false; + } else { + $elements[$i]['caption'] = ''; + $elements[$i]['body'] = $ele->render(); + $elements[$i]['hidden'] = true; + } + $i++; + } + $js = " + <!-- Start Form Vaidation JavaScript //--> + <script language='javascript'> + <!-- + function xoopsFormValidate_".$this->getName()."(){ + "; + $required =& $this->getRequired(); + $reqcount = count($required); + for ($i = 0; $i < $reqcount; $i++) { + $js .= "if ( document.".$this->getName().".".$required[$i]->getName().".value == \"\" ) {alert( \"".sprintf(_FORM_ENTER, $required[$i]->getCaption())."\" );document.".$this->getName().".".$required[$i]->getName().".focus();return false;\n} + "; + } + $js .= "} + //--> + </script> + <!-- End Form Vaidation JavaScript //--> + "; + $tpl->assign($this->getName(), array('title' => $this->getTitle(), 'name' => $this->getName(), 'action' => $this->getAction(), 'method' => $this->getMethod(), 'extra' => $this->getExtra(), 'javascript' => $js, 'elements' => $elements)); } } Index: formdhtmltextarea.php =================================================================== RCS file: /cvsroot/xoops/xoops-current/html/class/xoopsform/formdhtmltextarea.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** formdhtmltextarea.php 30 Jul 2002 01:06:00 -0000 1.2 --- formdhtmltextarea.php 18 Sep 2002 10:44:49 -0000 1.3 *************** *** 33,37 **** function render(){ ! $ret = "<input type='button' value='URL' onclick='xoopsCodeUrl(\"".$this->getName()."\");' /><input type='button' value='IMG' onclick='xoopsCodeImg(\"".$this->getName()."\");' /><input type='button' value='EMAIL' onclick='xoopsCodeEmail(\"".$this->getName()."\");' /><input type='button' value='QUOTE' onclick='xoopsCodeQuote(\"".$this->getName()."\");' /><br />\n"; $sizearray = array("xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large"); --- 33,37 ---- function render(){ ! $ret = "<input type='button' value='URL' onclick='xoopsCodeUrl(\"".$this->getName()."\");' /><input type='button' value='IMG' onclick='xoopsCodeImg(\"".$this->getName()."\");' /><input type='button' value='EMAIL' onclick='xoopsCodeEmail(\"".$this->getName()."\");' /><input type='button' value='CODE' onclick='xoopsCodeCode(\"".$this->getName()."\");' /><input type='button' value='QUOTE' onclick='xoopsCodeQuote(\"".$this->getName()."\");' /><br />\n"; $sizearray = array("xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large"); Index: form.php =================================================================== RCS file: /cvsroot/xoops/xoops-current/html/class/xoopsform/form.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** form.php 15 Jul 2002 08:13:13 -0000 1.1.1.1 --- form.php 18 Sep 2002 10:44:49 -0000 1.2 *************** *** 75,84 **** // public ! function addElement($ele){ ! $this->elements[] = $ele; } // public ! function getElements(){ return $this->elements; } --- 75,87 ---- // public ! function addElement(&$ele, $required=false){ ! $this->elements[] =& $ele; ! if ($required) { ! $this->required[] =& $ele; ! } } // public ! function &getElements(){ return $this->elements; } *************** *** 88,92 **** } ! function getExtra(){ if (isset($this->extra)) { return $this->extra; --- 91,95 ---- } ! function &getExtra(){ if (isset($this->extra)) { return $this->extra; *************** *** 94,108 **** } ! function setRequired($required){ if ( is_array($required) ) { foreach ( $required as $req ) { ! $this->required[] = $req; } } else { ! $this->required[] = $required; } } ! function getRequired(){ return $this->required; } --- 97,111 ---- } ! function setRequired(&$required){ if ( is_array($required) ) { foreach ( $required as $req ) { ! $this->required[] =& $req; } } else { ! $this->required[] =& $required; } } ! function &getRequired(){ return $this->required; } |