/**
  *	This function will return the element as HTML.
  *
  *	@returns	The form element as HTML text.
  */
 function toHtml()
 {
     // Create the list of attributes
     $attribs = array('type' => 'text', 'name' => $this->_form . '_' . $this->_name, 'value' => $this->_value);
     $attribs = array_merge($this->_attributes, $attribs);
     // trick to make this text box with the same width as autocompleter.
     // create a style array and a default width for text and div
     $style = array();
     $style['width'] = '143px';
     // if user has defined a custom style we must parse it to check if width was defined
     if (isset($attribs['style'])) {
         foreach (explode(";", $attribs['style']) as $att) {
             if (trim($att) != '') {
                 list($name, $value) = split(":", $att);
                 $style[strtolower($name)] = trim($value);
             }
         }
     }
     // compute style attribute
     $attribs['style'] = '';
     foreach ($style as $name => $value) {
         $attribs['style'] .= $name . ':' . $value . ';';
     }
     // if is a autocompleter we must add an extra div. TODO: automagically apply width to text element and div
     return '<input' . YDForm::_convertToHtmlAttrib($attribs) . ' /><div style="display:none; z-index:999;' . $attribs['style'] . '" id="' . $attribs['name'] . '_div"><ul></ul></div>';
 }
 /**
  *        This function will return the element as HTML.
  *
  *        @returns        The form element as HTML text.
  */
 function toHtml()
 {
     // Create the list of attributes
     $attribs = array('id' => $this->_form . '_' . $this->_name);
     $attribs = array_merge($this->_attributes, $attribs);
     // Get the HTML
     return '<span' . YDForm::_convertToHtmlAttrib($attribs) . '>' . nl2br($this->_value) . '</span>';
 }
 /**
  *	This function will return the element as HTML.
  *
  *	@returns	The form element as HTML text.
  */
 function toHtml()
 {
     // Create the list of attributes
     $attribs = array('name' => $this->_form . '_' . $this->_name);
     $attribs = array_merge($this->_attributes, $attribs);
     // Get the HTML
     return '<textarea' . YDForm::_convertToHtmlAttrib($attribs) . '>' . $this->_value . '</textarea>';
 }
 /**
  *	This function will return the element as HTML.
  *
  *	@returns	The form element as HTML text.
  */
 function toHtml()
 {
     // Create the list of attributes
     $attribs = array('type' => $this->_type, 'name' => $this->_form . '_' . $this->_name, 'src' => $this->_value);
     $attribs = array_merge($this->_attributes, $attribs);
     // Get the HTML
     return '<input' . YDForm::_convertToHtmlAttrib($attribs) . ' />';
 }
 /**
  *	This function will return the element as HTML.
  *
  *	@returns	The form element as HTML text.
  */
 function toHtml()
 {
     // Create the list of attributes
     $attribs = array('type' => $this->_type, 'name' => $this->_form . '_' . $this->_name, 'id' => $this->_form . '_' . $this->_name);
     $attribs = array_merge($this->_attributes, $attribs);
     // If a value, fill it in and make it checked
     if (!empty($this->_value)) {
         $attribs['checked'] = '';
     }
     // Get the HTML
     return '<input' . YDForm::_convertToHtmlAttrib($attribs) . '>';
 }
 /**
  *	This function will return the element as HTML.
  *
  *	@returns	The form element as HTML text.
  */
 function toHtml()
 {
     // Create the list of attributes
     $attribs = array('type' => $this->_type, 'name' => $this->_form . '_' . $this->_name, 'value' => $this->_value);
     $attribs = array_merge($this->_attributes, $attribs);
     // check dynamic
     if ($this->_dynamic) {
         $attribs['onfocus'] = "if(this.value=='" . $this->_value . "'){this.value=''};";
         $attribs['onblur'] = "if(this.value==''){this.value='" . $this->_value . "'};";
     }
     // Get the HTML
     return '<input' . YDForm::_convertToHtmlAttrib($attribs) . ' />';
 }
 /**
  *	This function will return the element as HTML.
  *
  *	@returns	The form element as HTML text.
  */
 function toHtml()
 {
     // Create the list of attributes
     $attribs = array('name' => $this->_form . '_' . $this->_name);
     $attribs = array_merge($this->_attributes, $attribs);
     // check if we are in a Javascript environment
     if (YDConfig::get('YD_FORMELEMENT_TEXTAREA_NL')) {
         $this->_value = preg_replace("/\r*\n/", "\\n", $this->_value);
         $this->_value = preg_replace("/\\//", "\\\\/", $this->_value);
         $this->_value = preg_replace("/'/", " ", $this->_value);
     }
     // Get the HTML
     return '<textarea' . YDForm::_convertToHtmlAttrib($attribs) . '>' . $this->_value . '</textarea>';
 }
 /**
  *	This function will return the element as HTML.
  *
  *	@returns	The form element as HTML text.
  */
 function toHtml()
 {
     // Create the list of attributes
     $attribs = array('name' => $this->_form . '_' . $this->_name);
     $attribs = array_merge($this->_attributes, $attribs);
     // Get the HTML
     $out = '';
     // if js code was not loaded we must load
     if (!defined('YD_SWMENU_MAINSCRIPT')) {
         $out .= trim('<script type="text/javascript">');
         $out .= trim('function hideSMenu( menudiv, obj ){');
         $out .= trim('	var ar = document.getElementById( menudiv ).getElementsByTagName( "span" );');
         $out .= trim('		if( document.getElementById( obj ).style.display != "block" ){');
         $out .= trim('			for ( var i = 0; i < ar.length; i++ ){');
         $out .= trim('				if ( ar[i].className == "submenu" )');
         $out .= trim('					ar[i].style.display = "none";');
         $out .= trim('			}');
         $out .= trim('			document.getElementById( obj ).style.display = "block";');
         $out .= trim('		}else{');
         $out .= trim('			document.getElementById( obj ).style.display = "none";');
         $out .= trim('		}');
         $out .= trim('}');
         $out .= trim('</script>');
         define('YD_SWMENU_MAINSCRIPT', 1);
     }
     // create menu div
     $out .= '<div' . YDForm::_convertToHtmlAttrib($attribs) . '>';
     // create menu id
     $IDmenu = $this->getAttribute('id');
     $i = 1;
     // cycle menus
     foreach ($this->_elements as $_title => $_elements) {
         // create submenu id
         $IDsubmenu = $IDmenu . '_' . $i++;
         // create menu div
         $out .= "<div class=\"menutitle\" onclick=\"hideSMenu('" . $IDmenu . "', '" . $IDsubmenu . "')\">" . $_title . "</div>";
         // create span that includes all menu subitems
         $out .= '<span class="submenu" id="' . $IDsubmenu . '" style="display:none">';
         $out .= implode('<br>', $_elements);
         $out .= '</span>';
     }
     // add final menu div tag
     $out .= '</div>';
     return $out;
 }
 /**
  *	This function will return the element as HTML.
  *
  *	@returns	The form element as HTML text.
  */
 function toHtml()
 {
     // Create the list of attributes
     $attribs = array('name' => $this->_form . '_' . $this->_name);
     $attribs = array_merge($this->_attributes, $attribs);
     // Get the HTML
     $html = '';
     $html .= '<select' . YDForm::_convertToHtmlAttrib($attribs) . '>';
     foreach ($this->_options as $val => $label) {
         if (strval($this->_value) == strval($val)) {
             $html .= '<option value="' . $val . '" selected="selected">' . $label . '</option>';
         } else {
             $html .= '<option value="' . $val . '">' . $label . '</option>';
         }
     }
     $html .= '</select>';
     return $html;
 }
 /**
  *	This function will return the element as HTML.
  *
  *	@returns	The form element as HTML text.
  */
 function toHtml()
 {
     // Create the list of attributes
     $attribs = array('type' => $this->_type, 'name' => $this->_form . '_' . $this->_name, 'value' => $this->_value);
     $attribs = array_merge($this->_attributes, $attribs);
     // Create the HTML
     $out = '';
     if (sizeof($this->_options) > 0) {
         foreach ($this->_options as $key => $val) {
             $attribsElement = $attribs;
             $attribsElement['value'] = $key;
             if ($this->_value == strval($key)) {
                 $attribsElement['checked'] = '';
             }
             $out .= '<input' . YDForm::_convertToHtmlAttrib($attribsElement) . '>' . $val;
         }
     } else {
         $out .= '<input' . YDForm::_convertToHtmlAttrib($attribs) . '>' . $this->_value;
     }
     // Return the HTML
     return $out;
 }
 /**
  *        This function will return the element as HTML.
  *
  *        @returns        The form element as HTML text.
  */
 function toHtml()
 {
     // Get the HTML
     return '<a' . YDForm::_convertToHtmlAttrib($this->_attributes) . '>' . $this->_value . '</a>';
 }
 /**
  *	This function will return the element as HTML.
  *
  *	@returns	The form element as HTML text.
  */
 function toHtml()
 {
     // Create the list of attributes
     $attribs = array('name' => $this->_form . '_' . $this->_name, 'id' => $this->_form . '_' . $this->_name, 'class' => 'bbtextarea');
     //if ( ! isset( $attribs['width'] ) ) { $attribs['width'] = '640'; }
     $attribs = array_merge($this->_attributes, $attribs);
     // Get the HTML
     $out = '';
     if (sizeof($this->_buttons) > 0) {
         if (!defined('YD_BBTA_MAINSCRIPT')) {
             $out .= '<script language="JavaScript">';
             $out .= '	function AddText( element, startTag, defaultText, endTag ) {';
             $out .= '		objElement = document.getElementById( element );';
             $out .= '		if ( objElement.createTextRange ) {';
             $out .= '			var text;';
             $out .= '			objElement.focus( objElement.caretPos);';
             $out .= '			objElement.caretPos = document.selection.createRange().duplicate();';
             $out .= '			if ( objElement.caretPos.text.length > 0 ) {' . "\n";
             $out .= '				objElement.caretPos.text = startTag + objElement.caretPos.text + endTag;';
             $out .= '			} else {';
             $out .= '				objElement.caretPos.text = startTag + defaultText + endTag;';
             $out .= '			}';
             $out .= '		} else {';
             $out .= '			objElement.value += startTag + defaultText + endTag;';
             $out .= '		}';
             $out .= '	}';
             $out .= '	function openWin( url, name, opts ) {';
             $out .= '		win = window.open( url, name, opts );';
             $out .= '		win.focus();';
             $out .= '	}';
             $out .= '</script>';
             define('YD_BBTA_MAINSCRIPT', 1);
         }
         $out .= '<script language="JavaScript">';
         $out .= '	function doButton( element, name ) {';
         foreach ($this->_buttons as $button) {
             if ($button['type'] == 'modifier') {
                 $out .= 'if ( name == \'' . addslashes($button['name']) . '\' ) {';
                 $out .= '	AddText ( element, \'[' . addslashes($button['name']) . ']\',\'' . addslashes($button['text']) . '\',\'[/' . addslashes($button['name']) . ']\');';
                 $out .= '}';
             }
             if ($button['type'] == 'simplepopup') {
                 $out .= 'if ( name == \'' . addslashes($button['name']) . '\' ) {';
                 $out .= '	data = prompt( "' . addslashes($button['question']) . '", "' . addslashes($button['default']) . '" );';
                 $out .= '	if ( data == null ) return;';
                 $out .= '	AddText( element, \'[' . addslashes($button['name']) . '=\' + data + \']\',\'' . addslashes($button['text']) . '\',\'[/' . addslashes($button['name']) . ']\');';
                 $out .= '}';
             }
         }
         $out .= '	}';
         $out .= '</script>';
         if (isset($attribs['width'])) {
             $out .= '<table border="0" cellpadding="0" cellspacing="0" width="' . $attribs['width'] . '">';
         } else {
             $out .= '<table border="0" cellpadding="0" cellspacing="0">';
         }
         $out .= '<tr>';
         $out .= '<td class="bbtoolbar">';
         foreach ($this->_buttons as $button) {
             if ($button['type'] == 'modifier') {
                 $out .= '<a href="#" onClick="void( doButton( \'' . addslashes($attribs['name']) . '\', \'' . addslashes($button['name']) . '\') );">[ ' . $button['label'] . ' ]</a> ';
             }
             if ($button['type'] == 'simplepopup') {
                 $out .= '<a href="#" onClick="void( doButton( \'' . addslashes($attribs['name']) . '\', \'' . addslashes($button['name']) . '\') );">[ ' . $button['label'] . ' ]</a> ';
             }
             if ($button['type'] == 'popupwindow') {
                 $out .= '<a href="#" onClick="void( openWin( \'' . addslashes($button['url']) . '\', \'' . addslashes($button['name']) . '\', \'' . addslashes($button['params']) . '\' ) );">[ ' . $button['label'] . ' ]</a> ';
             }
         }
         $out .= '</td>';
         $out .= '</tr>';
         $out .= '<tr>';
         $out .= '<td><textarea' . YDForm::_convertToHtmlAttrib($attribs) . '>' . $this->_value . '</textarea></td>';
         $out .= '</tr>';
         $out .= '</table>';
     } else {
         $out .= '<textarea' . YDForm::_convertToHtmlAttrib($attribs) . '>' . $this->_value . '</textarea>';
     }
     return $out;
 }
 /**
  *  This function adds a link to the installer template body.
  *
  *  @param  $url        The url
  *  @param  $text       (optional) The link text. Default: $url.
  *  @param  $attributes (optional) Array of attributes
  */
 function addLink($url, $text = '', $attributes = array())
 {
     $attributes['href'] = $url;
     $this->_items[] = array('type' => 'link', 'info' => sizeof($text) ? $text : $url, 'attributes' => YDForm::_convertToHtmlAttrib($attributes));
 }
 /**
  *	This function will return the element as HTML.
  *
  *	@returns	The form element as HTML text.
  */
 function toHtml()
 {
     // when using a multiple select, we should check if name ends with '[]'
     if (isset($this->_attributes['multiple']) && strpos($this->_name, '[]') === false) {
         $this->_name .= '[]';
     }
     // Create the list of attributes
     $attribs = array('name' => $this->_form . '_' . $this->_name);
     $attribs = array_merge($this->_attributes, $attribs);
     // check if value is array ( used on multiple select ) or a simple value
     if (!is_array($this->_value)) {
         $this->_value = explode(';', $this->_value);
     }
     // Get the HTML
     $html = '';
     $html .= '<select' . YDForm::_convertToHtmlAttrib($attribs) . '>';
     foreach ($this->_options as $val => $label) {
         if (in_array(strval($val), $this->_value)) {
             $html .= '<option value="' . $val . '" selected="selected">' . $label . '</option>';
         } else {
             $html .= '<option value="' . $val . '">' . $label . '</option>';
         }
     }
     $html .= '</select>';
     return $html;
 }
 /**
  *	This function will return the element as HTML.
  *
  *	@returns	The form element as HTML text.
  */
 function toHtml()
 {
     $out = '';
     if (!defined('YD_CTTA_MAINSCRIPT')) {
         $out .= '<script type="text/javascript">';
         $out .= 'function textCounter( field, maxlimit ) {';
         $out .= "  var f = document.getElementById( field );";
         $out .= "  var c = document.getElementById( field + '_counter' );";
         $out .= '  if ( f.value.length > maxlimit )';
         $out .= '    f.value = f.value.substring( 0, maxlimit );';
         $out .= '  else ';
         $out .= '    c.innerHTML = maxlimit - f.value.length;';
         $out .= '}';
         $out .= '</script>';
         define('YD_CTTA_MAINSCRIPT', 1);
     }
     // Create the list of attributes
     $attribs = array('name' => $this->_form . '_' . $this->_name);
     $attribs = array_merge($this->_attributes, $attribs);
     // Get the HTML
     $out .= '<textarea' . YDForm::_convertToHtmlAttrib($attribs) . '>' . $this->_value . '</textarea>';
     return $out;
 }
 /**
  *	This function will return the element as HTML.
  *
  *	@returns	The form element as HTML text.
  */
 function toHtml()
 {
     // Create the list of attributes
     $attribs = array('type' => 'text', 'name' => $this->_form . '_' . $this->_name, 'value' => $this->_value, 'size' => 7);
     $attribs = array_merge($this->_attributes, $attribs);
     // Get the HTML
     $img = '<img id="' . $this->getAttribute('id') . '_captcha" width="200" height="40" src="' . $this->_url . '" style="vertical-align: middle"/>';
     $txt = '<input' . YDForm::_convertToHtmlAttrib($attribs) . ' />';
     if (is_null($this->_button)) {
         $button = '';
     } else {
         $button = $this->_button->toHTML();
     }
     if ($this->_textPosition_left) {
         return $txt . ' ' . $img . ' ' . $button;
     } else {
         return $img . ' ' . $txt . ' ' . $button;
     }
 }
 /**
  *	This function will return the element as HTML.
  *
  *	@returns	The form element as HTML text.
  */
 function toHtml()
 {
     // Create the list of attributes
     $attribs = array('type' => $this->_type, 'name' => $this->_form . '_' . $this->_name, 'value' => $this->_value);
     $attribs = array_merge($this->_attributes, $attribs);
     // Create the HTML
     $out = array();
     if (sizeof($this->_options) > 0) {
         foreach ($this->_options as $key => $val) {
             $attribsElement = $attribs;
             $attribsElement['value'] = $key;
             $attribsElement['id'] .= $key;
             if ($this->_value == strval($key)) {
                 $attribsElement['checked'] = 'checked';
             }
             $label = $this->_enableLabels ? '<label for="' . $attribsElement['id'] . '">' . $val . '</label>' : $val;
             $out[] = '<input' . YDForm::_convertToHtmlAttrib($attribsElement) . ' /> ' . $label . ' ';
         }
     } else {
         $label = $this->_enableLabels ? '<label for="' . $attribs['id'] . '">' . $this->_value . '</label>' : $this->_value;
         $out[] = '<input' . YDForm::_convertToHtmlAttrib($attribs) . ' /> ' . $label . ' ';
     }
     // Return the HTML
     return implode($this->_separator, $out);
 }
 /**
  *	This function will return the element as HTML.
  *
  *	@returns	The form element as HTML text.
  */
 function toHtml()
 {
     // Create the list of attributes
     $attribs = array('name' => $this->_form . '_' . $this->_name, 'class' => 'bbtextarea');
     //if ( ! isset( $attribs['width'] ) ) { $attribs['width'] = '640'; }
     $attribs = array_merge($this->_attributes, $attribs);
     // Get the HTML
     $out = '';
     if (sizeof($this->_buttons) > 0) {
         if (!defined('YD_BBTA_MAINSCRIPT')) {
             $out .= '<script src="' . YD_SELF_SCRIPT . '?do=JsBBTextArea" type="text/javascript"></script>';
             define('YD_BBTA_MAINSCRIPT', 1);
         }
         $out .= '<script type="text/javascript">';
         $out .= '	function doButton( element, name ) {';
         foreach ($this->_buttons as $button) {
             if ($button['type'] == 'modifier') {
                 $out .= 'if ( name == \'' . addslashes($button['name']) . '\' ) {';
                 $out .= '	AddText ( element, \'[' . addslashes($button['name']) . ']\',\'' . addslashes($button['text']) . '\',\'[/' . addslashes($button['name']) . ']\');';
                 $out .= '}';
             }
             if ($button['type'] == 'simplepopup') {
                 $out .= 'if ( name == \'' . addslashes($button['name']) . '\' ) {';
                 $out .= '	data = prompt( "' . addslashes($button['question']) . '", "' . addslashes($button['default']) . '" );';
                 $out .= '	if ( data == null ) return;';
                 $out .= '	AddText( element, \'[' . addslashes($button['name']) . '=\' + data + \']\',\'' . addslashes($button['text']) . '\',\'[/' . addslashes($button['name']) . ']\');';
                 $out .= '}';
             }
         }
         $out .= '	}';
         $out .= '</script>';
         if (isset($attribs['width'])) {
             $out .= '<table border="0" cellpadding="0" cellspacing="0" width="' . $attribs['width'] . '">';
         } else {
             $out .= '<table border="0" cellpadding="0" cellspacing="0">';
         }
         $out .= '<tr>';
         $out .= '<td class="bbtoolbar">';
         foreach ($this->_buttons as $button) {
             if ($button['type'] == 'modifier') {
                 $out .= '<a href="#" onclick="void( doButton( \'' . addslashes($attribs['id']) . '\', \'' . addslashes($button['name']) . '\') ); return false;">[ ' . $button['label'] . ' ]</a> ';
             }
             if ($button['type'] == 'simplepopup') {
                 $out .= '<a href="#" onclick="void( doButton( \'' . addslashes($attribs['id']) . '\', \'' . addslashes($button['name']) . '\') ); return false;">[ ' . $button['label'] . ' ]</a> ';
             }
             if ($button['type'] == 'popupwindow') {
                 $out .= '<a href="#" onclick="void( openWin( \'' . addslashes($button['url']) . '\', \'' . addslashes($button['name']) . '\', \'' . addslashes($button['params']) . '\' ) ); return false;">[ ' . $button['label'] . ' ]</a> ';
             }
         }
         $out .= '</td>';
         $out .= '</tr>';
         $out .= '<tr>';
         $out .= '<td><textarea' . YDForm::_convertToHtmlAttrib($attribs) . '>' . $this->_value . '</textarea></td>';
         $out .= '</tr>';
         $out .= '</table>';
     } else {
         $out .= '<textarea' . YDForm::_convertToHtmlAttrib($attribs) . '>' . $this->_value . '</textarea>';
     }
     return $out;
 }
Esempio n. 19
0
 /**
  *      Gets the label of the form element.
  *
  *      @param  $html   (Optional) Return label as html
  *      @returns        The label of the form element.
  */
 function getLabel($html = false)
 {
     if ($html) {
         return '<span ' . YDForm::_convertToHtmlAttrib($this->_label_attributes) . '><label for="' . $this->_attributes['id'] . '">' . $this->_label . '</label></span>';
     }
     return $this->_label;
 }
 /**
  *	This function will return the element as HTML.
  *
  *	@returns	The form element as HTML text.
  */
 function toHtml()
 {
     // Create the list of attributes
     $attribs = array('name' => $this->_form . '_' . $this->_name, 'onchange' => "document.getElementById('" . $this->getAttribute('id') . "_image').src='" . $this->_img_src . "' + document.getElementById('" . $this->getAttribute('id') . "').options[this.selectedIndex].value + '" . $this->_img_ext . "';");
     $attribs = array_merge($this->_attributes, $attribs);
     // Start html table and insert select in left column
     $html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td>';
     // add select
     $html .= '<select' . YDForm::_convertToHtmlAttrib($attribs) . '>';
     foreach ($this->_options as $val => $label) {
         if (strval($this->_value) == strval($val)) {
             $html .= '<option value="' . $val . '" selected="selected">' . $label . '</option>';
         } else {
             $html .= '<option value="' . $val . '">' . $label . '</option>';
         }
     }
     // end select and left column
     $html .= '</select></td>';
     // compute image source
     $source = $this->_img_src;
     // compute selected option. If default value was set and that value is valid, use it. Otherwise use 1st option
     if (!empty($this->_value) && isset($this->_options[$this->_value])) {
         $source .= $this->_value;
     } else {
         $values = array_keys($this->_options);
         $source .= $values[0];
     }
     // add extension
     $source .= $this->_img_ext;
     // Create the list of attributes for image
     $attribs = array('id' => $this->getAttribute('id') . '_image', 'src' => $source);
     $attribs = array_merge($this->_image_parameters, $attribs);
     // add image html to right column and close table row
     $html .= '<td>&nbsp;&nbsp;&nbsp;<img' . YDForm::_convertToHtmlAttrib($attribs) . '></td></tr></table>';
     return $html;
 }
 /**
  *	This function will render the form.
  *
  *	@returns	The rendered form.
  */
 function render()
 {
     // Start with an empty array
     $form = array();
     // Add the list of attributes
     $attribs = array('name' => $this->_form->_name, 'id' => $this->_form->_name, 'method' => $this->_form->_method, 'action' => $this->_form->_action, 'target' => $this->_form->_target);
     $attribs = array_merge($attribs, $this->_form->_attributes);
     if ($attribs['target'] == '_self') {
         unset($attribs['target']);
     }
     // Add the rest of the form attributes
     $form['attribs'] = $this->_form->_convertToHtmlAttrib($attribs);
     $form['tag'] = '<form' . $form['attribs'] . '>';
     $form['requirednote'] = $this->_form->_requiredNote;
     $form['endtag'] = '</form>';
     $form['name'] = $this->_form->_name;
     $form['legend'] = $this->_form->_legend;
     // Add a script for the default item
     if (!empty($this->_form->_defaultItem) && array_key_exists($this->_form->_defaultItem, $this->_form->_elements)) {
         $form['endtag'] .= sprintf('<script type="text/javascript">document.getElementById("%s").focus();</script>', addslashes($this->_form->_name . '_' . $this->_form->_defaultItem));
     }
     // Add the fieldset and legend tag if any
     if (!empty($this->_form->_legend)) {
         // Add it to the start tag
         $form['tag'] .= '<fieldset><legend>' . $this->_form->_legend . '</legend>';
         // Add it to the end tag
         $form['endtag'] = '</fieldset>' . $form['endtag'];
     }
     // Add the errors
     $form['errors'] = $this->_form->_errors;
     $form['errors_unique_messages'] = array_unique(array_values($this->_form->_errors));
     // Loop over the list of elements
     foreach ($this->_form->_elements as $name => $element) {
         // Update the value
         $element->_value = $this->_form->getValue($name);
         // Add the hidden_html value
         $elementArray = $element->toArray();
         $attribs = array('type' => 'hidden', 'name' => $elementArray['id'], 'value' => $elementArray['value']);
         $elementArray['hidden_html'] = '<input' . YDForm::_convertToHtmlAttrib($attribs) . ' />';
         // Add the form element
         $form[$name] = $elementArray;
         // Add errors if any
         if (array_key_exists($name, $this->_form->_errors)) {
             $form[$name]['error'] = $this->_form->_errors[$name];
         } else {
             $form[$name]['error'] = '';
         }
         // Check if the field is required
         $required = false;
         if (array_key_exists($name, $this->_form->_rules)) {
             foreach ($this->_form->_rules[$name] as $rules) {
                 if (strtolower($rules['rule']) == 'required') {
                     $required = true;
                     break;
                 }
             }
         }
         $form[$name]['required'] = $required;
         // Add required and error HTML
         if ($form[$name]['isButton'] === false && $form[$name]['placeLabel'] != 'none') {
             if ($form[$name]['required']) {
                 $form[$name]['label_html'] = $this->_form->_htmlRequiredStart . $form[$name]['label_html'] . $this->_form->_htmlRequiredEnd;
             }
             if (!empty($form[$name]['error'])) {
                 $form[$name]['error_html'] = $this->_form->_htmlErrorStart . $form[$name]['error'] . $this->_form->_htmlErrorEnd;
             }
         }
     }
     // Add the do parameter if it's a get form
     if ($this->_form->_method == 'get') {
         $form['do'] = array();
         $form['do']['name'] = 'do';
         $form['do']['id'] = 'do';
         $form['do']['value'] = YDRequest::getActionName();
         $form['do']['type'] = 'hidden';
         $form['do']['label'] = '';
         $form['do']['label_html'] = '';
         $form['do']['options'] = array();
         $form['do']['placeLabel'] = 'none';
         $form['do']['html'] = '<input type="hidden" name="do" id="do" value="' . YDRequest::getActionName() . '" />';
         $form['do']['isButton'] = false;
         $form['do']['error'] = '';
         $form['do']['required'] = false;
     }
     // Return the form array
     return $form;
 }
 /**
  *	This function will return the element as HTML.
  *
  *	@returns	The form element as HTML text.
  */
 function toHtml()
 {
     // Output the HTML checkboxes
     $output = array();
     // cycle all items to get their html
     foreach ($this->_items as $item) {
         if ($this->_position == 'right') {
             $output[] = $item->toHtml() . '&nbsp;<label for="' . $item->_attributes['id'] . '">' . $item->_label . '</label>';
         } else {
             $output[] = '<label for="' . $item->_attributes['id'] . '">' . $item->_label . '</label>&nbsp;' . $item->toHtml();
         }
     }
     // Add the <nobr> tags
     foreach ($output as $key => $val) {
         $output[$key] = '<nobr>' . $val . '</nobr> ';
     }
     // check if we have more than one item enabled, otherwise the 'select all' will not be displayed
     $checkboxesEnabled = 0;
     foreach ($this->_items as $item) {
         if ($item->isDisabled() == false) {
             $checkboxesEnabled++;
             if ($checkboxesEnabled == 2) {
                 break;
             }
         }
     }
     // init the 'select all' html
     $selall_html = '';
     // check if: user wants a 'select all', we have more than one item in checkboxgroup, we have more than one item enabled
     if ($this->_addSelectAll && count($this->_items) > 1 && $checkboxesEnabled > 1) {
         // compute button code
         $selall = new YDFormElement_Checkbox($this->_form, $this->getAttribute('id') . 'sall');
         $selall->setAttribute('onclick', 'for (var i=0;i<document.forms[\'' . $this->_form . '\'].elements.length;i++) if (document.forms[\'' . $this->_form . '\'].elements[i].type==\'checkbox\' && !document.forms[\'' . $this->_form . '\'].elements[i].disabled && /' . $this->_name . '\\[[a-zA-Z0-9]+\\]/.test( document.forms[\'' . $this->_form . '\'].elements[i].name ) ) document.forms[\'' . $this->_form . '\'].elements[i].checked = this.checked;');
         // if all checkboxes are selected, the 'select all' will be selected too
         $selall->setValue(1);
         foreach ($this->getValue() as $elem => $value) {
             if ($value != 1) {
                 $selall->setValue(0);
                 break;
             }
         }
         // check default translation
         if (!isset($GLOBALS['t']['select all'])) {
             $GLOBALS['t']['select all'] = 'select all';
         }
         // compute button label
         if ($this->_position == 'right') {
             $selall_html = '<span ' . YDForm::_convertToHtmlAttrib($this->_addSelectAll_chk_attributes) . '>' . $selall->toHTML() . '&nbsp;<label for="' . $selall->getAttribute('id') . '">' . t('select all') . '</label></span>';
         } else {
             $selall_html = '<span ' . YDForm::_convertToHtmlAttrib($this->_addSelectAll_chk_attributes) . '><label for="' . $selall->getAttribute('id') . '">' . t('select all') . '</label>&nbsp;' . $selall->toHTML() . '</span>';
         }
     }
     // check if we don't want columns format
     if ($this->_columns == 1) {
         // if we don't have a 'select all' just return checkboxes html
         if ($selall_html == '') {
             return implode($this->_separator, $output);
             // if 'select all' is at the end
         } else {
             if ($this->_addSelectAll_onBottom) {
                 return implode($this->_separator, $output) . $this->_separator . $selall_html;
                 // if 'select all' is at the beggining
             } else {
                 return $selall_html . $this->_separator . implode($this->_separator, $output);
             }
         }
         // create a html table
     } else {
         // init table header
         $table = '<table width="100%" border="0" cellpadding="0" cellspacing="0">';
         // if 'select all' is defined to be on top, add a row with 'select all' column and other cols empty
         if ($selall_html != '' && !$this->_addSelectAll_onBottom) {
             $table .= '<tr>';
             $table .= '<td>' . $selall_html . '</td>';
             for ($k = 1; $k < $this->_columns; $k++) {
                 $table .= '<td>&nbsp;</td>';
             }
             $table .= '</tr>';
         }
         // create option checkboxes content
         for ($i = 0; isset($output[$i]);) {
             $table .= '<tr>';
             for ($k = 0; $k < $this->_columns; $k++) {
                 // if we have a checkbox just add it. otherwise add an empty char
                 if (isset($output[$i])) {
                     $table .= '<td>' . $output[$i] . '</td>';
                 } else {
                     $table .= '<td>&nbsp;</td>';
                 }
                 $i++;
             }
             $table .= '</tr>';
         }
         // if 'select all' is defined to be on bottom, add empty cols and a last column with 'select all' code
         if ($selall_html != '' && $this->_addSelectAll_onBottom) {
             $table .= '<tr>';
             for ($k = 1; $k < $this->_columns; $k++) {
                 $table .= '<td>&nbsp;</td>';
             }
             $table .= '<td>' . $selall_html . '</td>';
             $table .= '</tr>';
         }
         // end table
         $table .= '</table>';
         return $table;
     }
 }
 /**
  *	This function will return the element as HTML.
  *
  *	@returns	The form element as HTML text.
  */
 function toHtml()
 {
     $size = YDConfig::get('YD_CAPTCHA_NUMCHARS', 5);
     // Create the list of attributes
     $attribs = array('type' => 'text', 'name' => $this->_form . '_' . $this->_name, 'value' => $this->_value, 'size' => $size, 'maxlength' => $size);
     $attribs = array_merge($this->_attributes, $attribs);
     // add image auto-refresh
     if ($this->_refreshimage == true) {
         $this->img->setAttribute('onclick', $this->_onclick);
         $this->img->setAttribute('style', "vertical-align: middle;cursor:pointer;");
         $this->img->setAttribute('title', $this->_refreshcaption);
     } else {
         $this->img->setAttribute('style', "vertical-align: middle;");
         $this->img->setAttribute('title', $this->_label);
     }
     // compute text box html
     $txt_HTML = '<input' . YDForm::_convertToHtmlAttrib($attribs) . ' />';
     // compute refresh button html
     if (is_null($this->_button)) {
         $button_HTML = '';
     } else {
         $this->_button->setAttribute('onclick', $onclick);
         $button_HTML = $this->_button->toHTML();
     }
     if ($this->_textPosition_left) {
         return $txt_HTML . ' ' . $this->img->toHTML() . ' ' . $button_HTML;
     } else {
         return $this->img->toHTML() . ' ' . $txt_HTML . ' ' . $button_HTML;
     }
 }