function preGenerateForm(&$fb, &$obj) { $info = $obj->_getPluginsDef(); $info = $info['images']; HTML_QuickForm::registerElementType('imagefile', 'HTML/QuickForm/imagefile.php', 'HTML_QuickForm_imagefile'); foreach ($info as $k => $v) { $v = key_exists(0, $v) ? $v[0] : $v; switch (true) { case $v['x'] && $v['y']: $newSize = $v['x'] . ' X ' . $v['y'] . ' pixels'; break; case $v['x'] && !$v['y']: $newSize = $v['x'] . ' ' . __('pixels wide (proportions kept)'); break; case !$v['x'] && $v['y']: $newSize = $v['y'] . ' ' . __('pixels high (proportions kept)'); break; default: $newSize = ''; break; } $obj->fb_fieldLabels[$k] = array($obj->fb_fieldLabels[$k], 'note' => $newSize ? '. ' . __('Image will be resized to %s', array($newSize)) : ''); if (!empty($obj->{$k})) { //TODO move this to postGenerateForm (like in upload plugin) $obj->fb_fieldLabels[$k]['unit'] = '<input type="checkbox" name="__image_delete_' . $k . '" value="1" />' . __('Delete current'); } $obj->fb_preDefElements[$k] =& MyQuickForm::createElement('imagefile', $obj->fb_elementNamePrefix . $k . $obj->fb_elementNamePostfix, $obj->fb_fieldLabels[$k], array('showimage' => $v['showimage']), SITE_URL . WWW_IMAGES_FOLDER . $info[$k][0]['path'] . '/'); } }
function __construct($formName = '', $method = 'POST', $action = '', $target = '', $attributes = null, $trackSubmit = true) { parent::__construct($formName, $method, $action, $target, $attributes, $trackSubmit); $this->id = $formName; $this->forceClientValidation = false; $this->hasRequiredFields = false; //register custom fields parent::registerElementType('html', MAX_PATH . '/lib/OA/Admin/UI/component/Html.php', 'OA_Admin_UI_Component_Html'); parent::registerElementType('controls', MAX_PATH . '/lib/OA/Admin/UI/component/FormControls.php', 'OA_Admin_UI_Component_FormControls'); parent::registerElementType('break', MAX_PATH . '/lib/OA/Admin/UI/component/FormBreak.php', 'OA_Admin_UI_Component_FormBreak'); parent::registerElementType('custom', MAX_PATH . '/lib/OA/Admin/UI/component/CustomFormElement.php', 'OA_Admin_UI_Component_CustomFormElement'); parent::registerElementType('plugin-custom', MAX_PATH . '/lib/OA/Admin/UI/component/CustomPluginFormElement.php', 'OA_Admin_UI_Component_CustomPluginFormElement'); parent::registerElementType('script', MAX_PATH . '/lib/OA/Admin/UI/component/ScriptFormElement.php', 'OA_Admin_UI_Component_ScriptFormElement'); parent::registerElementType('plugin-script', MAX_PATH . '/lib/OA/Admin/UI/component/PluginScriptFormElement.php', 'OA_Admin_UI_Component_PluginScriptFormElement'); //register additional rules $this->registerRule('wholenumber', 'regex', '/^\\d+$/'); $this->registerRule('wholenumber-', 'regex', '/^\\d+$|^\\-$/'); $this->registerRule('formattednumber', 'regex', '/^\\d+$|^\\d(,\\d{3})+$/'); $this->registerRule('decimal', 'regex', '/^([+-])?\\d+(\\.\\d+)?$/'); $this->registerRule('decimalplaces', 'rule', 'OA_Admin_UI_Rule_DecimalPlaces', MAX_PATH . '/lib/OA/Admin/UI/component/rule/DecimalPlaces.php'); $this->registerRule('min', 'rule', 'OA_Admin_UI_Rule_Min', MAX_PATH . '/lib/OA/Admin/UI/component/rule/Min.php'); $this->registerRule('max', 'rule', 'OA_Admin_UI_Rule_Max', MAX_PATH . '/lib/OA/Admin/UI/component/rule/Max.php'); $this->registerRule('unique', 'rule', 'OA_Admin_UI_Rule_Unique', MAX_PATH . '/lib/OA/Admin/UI/component/rule/Unique.php'); $this->registerRule('equal', 'rule', 'OA_Admin_UI_Rule_Equal', MAX_PATH . '/lib/OA/Admin/UI/component/rule/Equal.php'); //register jquery rule adaptors $this->registerJQueryRuleAdaptor('required', MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormRequiredRuleAdaptor.php', 'OA_Admin_UI_Rule_JQueryRequiredRule'); $this->registerJQueryRuleAdaptor('minlength', MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormMinLengthRuleAdaptor.php', 'OA_Admin_UI_Rule_JQueryMinLengthRule'); $this->registerJQueryRuleAdaptor('maxlength', MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormMaxLengthRuleAdaptor.php', 'OA_Admin_UI_Rule_JQueryMaxLengthRule'); $this->registerJQueryRuleAdaptor('email', MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormEmailRuleAdaptor.php', 'OA_Admin_UI_Rule_JQueryEmailRule'); $this->registerJQueryRuleAdaptor('numeric', MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormDigitsRuleAdaptor.php', 'OA_Admin_UI_Rule_JQueryDigitsRule'); $this->registerJQueryRuleAdaptor('nonzero', MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormNonZeroRuleAdaptor.php', 'OA_Admin_UI_Rule_JQueryNonZeroRule'); $this->registerJQueryRuleAdaptor('decimal', MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormNumberRuleAdaptor.php', 'OA_Admin_UI_Rule_JQueryNumberRule'); $this->registerJQueryRuleAdaptor('min', MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormMinRuleAdaptor.php', 'OA_Admin_UI_Rule_JQueryMinRule'); $this->registerJQueryRuleAdaptor('max', MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormMaxRuleAdaptor.php', 'OA_Admin_UI_Rule_JQueryMaxRule'); $this->registerJQueryRuleAdaptor('decimalplaces', MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormDecimalPlacesAdaptor.php', 'OA_Admin_UI_Rule_QuickFormDecimalPlacesAdaptor'); $this->registerJQueryRuleAdaptor("unique", MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormUniqueRuleAdaptor.php', 'OA_Admin_UI_Rule_JQueryUniqueRule'); $this->registerJQueryRuleAdaptor("equal", MAX_PATH . '/lib/OA/Admin/UI/component/rule/QuickFormEqualRuleAdaptor.php', 'OA_Admin_UI_Rule_JQueryEqualRule'); //register element decorators $this->registerElementDecorator('tag', MAX_PATH . '/lib/OA/Admin/UI/component/decorator/HTMLTagDecorator.php', 'OA_Admin_UI_HTMLTagDecorator'); $this->registerElementDecorator('process', MAX_PATH . '/lib/OA/Admin/UI/component/decorator/ProcessingDecorator.php', 'OA_Admin_UI_ProcessingDecorator'); //apply flat class $this->setAttribute("class", "flat"); //trim spaces from all data sent by the user $this->applyFilter('__ALL__', 'trim'); if (!defined('phpAds_installing')) { $this->addElement('hidden', 'token', phpAds_SessionGetToken()); $this->addRule('token', 'Missing request token', 'required'); $this->addRule('token', 'Invalid request token', 'callback', 'phpAds_SessionValidateToken'); } }
* @package HTML_QuickForm_CAPTCHA * @author Philippe Jausions <*****@*****.**> * @copyright 2006-2008 by Philippe Jausions / 11abacus * @license http://www.opensource.org/licenses/bsd-license.php New BSD * @version Release: 0.3.0 * @link http://pear.php.net/package/HTML_QuickForm_CAPTCHA * @see Text_CAPTCHA_Driver_Equation */ class HTML_QuickForm_CAPTCHA_Equation extends HTML_QuickForm_CAPTCHA { /** * Default options * * @var array * @access protected */ var $_options = array('sessionVar' => '_HTML_QuickForm_CAPTCHA', 'severity' => 1, 'numbersToText' => false, 'phrase' => null); /** * CAPTCHA driver * * @var string * @access protected */ var $_CAPTCHA_driver = 'Equation'; } /** * Registers the class with QuickForm */ if (class_exists('HTML_QuickForm')) { HTML_QuickForm::registerElementType('CAPTCHA_Equation', 'HTML/QuickForm/CAPTCHA/Equation.php', 'HTML_QuickForm_CAPTCHA_Equation'); }
} } out += "<\\/ul>"; document.getElementById(\'target_' . $this->_options['elementId'] . '\').innerHTML = out; } //]]> </script> '; if (!defined('HTML_QUICKFORM_JS_INIT_EXISTS')) { $scriptLoad .= ' <script type="text/javascript">//<![CDATA[ var remoteLiveSearch = new livesearch(callback); remoteLiveSearch.dispatcher.queue = \'rls\'; HTML_AJAX.queues[\'rls\'] = new HTML_AJAX_Queue_Interval_SingleBuffer(' . (int) $this->_options['buffer'] . '); //]]> </script> '; define('HTML_QUICKFORM_JS_INIT_EXISTS', true); } $scriptLoad .= ' <input type="hidden" name="' . $this->realName . '" id="' . $this->realName . '" value="' . $this->_hidden_value . '" />' . "\n"; } return $scriptLoad . parent::toHtml() . $liveform; } } // end class HTML_QuickForm_LiveSearch_Select if (class_exists('HTML_QuickForm')) { HTML_QuickForm::registerElementType('livesearch_select', 'HTML/QuickForm/livesearch_select.php', 'HTML_QuickForm_LiveSearch_Select'); }
/** * DB_DataObject_FormBuilder_QuickForm::_addElementTableToForm * * Adds an elementTable to the form * * @param HTML_QuickForm $form the form to add the element to * @param string $fieldName the name of the element to be added * @param array $columnNames an array of the column names * @param array $rowNames an array of the row names * @param array $rows an array of rows, each row being an array of HTML_QuickForm elements */ function _addElementTableToForm(&$form, $fieldName, $columnNames, $rowNames, &$rows) { if (!HTML_QuickForm::isTypeRegistered('elementTable')) { HTML_QuickForm::registerElementType('elementTable', 'DB/DataObject/FormBuilder/QuickForm/ElementTable.php', 'DB_DataObject_FormBuilder_QuickForm_ElementTable'); } $element =& HTML_QuickForm::createElement($this->_getQFType('elementTable'), $this->getFieldName($fieldName), $this->getFieldLabel($fieldName)); $element->setColumnNames($columnNames); $element->setRowNames($rowNames); $element->setRows($rows); $attr = $this->_getAttributes('elementTable', $fieldName); $element->updateAttributes($attr); $this->_addElementToForm($form, $element); }
*/ var $_CAPTCHA_driver = 'Figlet'; /** * Returns the HTML for the CAPTCHA * * This can be overwritten by sub-classes for specific output behavior * (for instance the Image CAPTCHA displays an image) * * @access public * @return string */ function toHtml() { $result = $this->_initCAPTCHA(); if (PEAR::isError($result)) { return $result; } $attr = $this->_attributes; unset($attr['type']); unset($attr['value']); unset($attr['name']); $html = $this->_getTabs() . '<div' . $this->_getAttrString($attr) . '>' . $_SESSION[$this->_options['sessionVar']]->getCAPTCHA() . '</div>'; return $html; } } /** * Register the class with QuickForm */ if (class_exists('HTML_QuickForm')) { HTML_QuickForm::registerElementType('CAPTCHA_Figlet', 'HTML/QuickForm/CAPTCHA/Figlet.php', 'HTML_QuickForm_CAPTCHA_Figlet'); }
} } $renderer->finishGroup($this); // --->8--- } // }}} // {{{ getElementName /** * Returns the name of this element. Used by HTML_QuickForm::getSubmitValue() * when this element is registered as a group. * * @see HTML_QuickForm::getSubmitValue() * @access public * @return string */ function getElementName() { return $this->getName(); } } // }}} if (class_exists('HTML_QuickForm')) { HTML_QuickForm::registerElementType('altselect', 'HTML/QuickForm/altselect.php', 'HTML_QuickForm_altselect'); } /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */
private function &_widgetThumbnail(&$field, $args) { HTML_QuickForm::registerElementType('thumbnail', 'HTML/QuickForm/thumbnail.php', 'HTML_QuickForm_thumbnail'); // Leave the default thumbnail path/url, that is // the base ones with 'thumbnail' appended $element =& $this->_addElement('thumbnail', $field['id']); $range = $this->_getPictureRange($field); // If set, the thumbnail size is equal to the minimum size if ($range[0] > 0 && $range[1] > 0) { $element->setThumbnailSize($range[0], $range[1]); } return $this->_configPicture($element, $range, $args); }
<?php require_once 'HTML/QuickForm/element.php'; HTML_QuickForm::registerElementType('jscalendar', 'HTML/QuickForm/jscalendar.php', 'HTML_QuickForm_jscalendar'); /** * HTML class for a jscalendar field * * jscalendar is "The coolest DHTML/JavaScript Calendar" which can be obtained * from http://dynarch.com/projects/calendar * * @author Jan Wagner <*****@*****.**> * @license LGPL * @copyright Copyright © 2006, Jan Wagner <*****@*****.**> */ class HTML_QuickForm_jscalendar extends HTML_QuickForm_element { /** * Name of the element * * @var string * @access protected */ var $_name = ''; /** * Options should contain: * * baseURL: where to find the jscalendar files (with trailing /) * styleCss: name of style css file * language: Language code * setup: A hash of options to pass to Calendar.setup *
if ($this->getComment() != '') { $html .= $tabs . '<!-- ' . $this->getComment() . ' // -->'; } $attr = $this->_attributes; unset($attr['type']); unset($attr['value']); unset($attr['name']); $html = $tabs . '<a href="' . $this->_options['callback'] . '" target="_blank" ' . $this->_getAttrString($attr) . ' onclick="var cancelClick = false; ' . $this->getOnclickJs($imgName) . ' return !cancelClick;"><img src="' . $this->_options['callback'] . '" name="' . $imgName . '" id="' . $imgName . '" width="' . $this->_options['width'] . '" height="' . $this->_options['height'] . '" title="' . htmlspecialchars($this->_options['alt']) . '" /></a>'; return $html; } /** * Creates the javascript for the onclick event which will * reload a new CAPTCHA image * * @param string $imageName The image name/id * * @return string * @access public */ function getOnclickJs($imageName) { $onclickJs = '' . 'if (document.images) {' . ' var img = new Image();' . ' var d = new Date();' . ' img.src = this.href + ((this.href.indexOf(\'?\') == -1) ' . '? \'?\' : \'&\') + d.getTime();' . ' document.images[\'' . addslashes($imageName) . '\'].src = img.src;' . ' cancelClick = true;' . '}'; return $onclickJs; } } /** * Registers the class with QuickForm */ if (class_exists('HTML_QuickForm')) { HTML_QuickForm::registerElementType('CAPTCHA_Image', 'HTML/QuickForm/CAPTCHA/Image.php', 'HTML_QuickForm_CAPTCHA_Image'); }
/** * HTML_QuickForm_colorpicker. * * @author guillaule l. <*****@*****.**> * @license PHP License http://www.php.net/license/3_0.txt * $Id: colorpicker.php,v 1.1.1.1 2007-06-06 11:14:50 david Exp $ */ /** * include parent class. */ require_once 'HTML/QuickForm/text.php'; /** * Register QuickForm element type */ HTML_QuickForm::registerElementType('colorpicker', 'HTML/QuickForm/colorpicker.php', 'HTML_QuickForm_colorpicker'); /** * HTML_QuickForm_colorpicker * * Add a javascript color picker to a textfield. * * Example: * <code> * ... * require_once 'HTML/QuickForm/colorpicker.php'; * * $options = array( * 'jsFile' => 'js/colorpicker.js', * 'cssFile' => 'css/png.css' * ); *
</script> EOS; } else { $js = ''; } $vName = $this->_name; $vAnchorName = 'Anchor_' . $vName; $vRetFunctionName = 'OnSet_' . $vName; $vEnableClear = @$this->_options['addEmptyOption'] ? 'true' : 'false'; $vAddDays = @$this->_options['addDays']; if (!is_int($vAddDays)) { $vAddDays = 0; } $vRetFunction = <<<EOS <script language="JavaScript"> function {$vRetFunctionName}(y,m,d) { // document.forms[0]["{$vName}[Y]"].selectedIndex=y; // document.forms[0]["{$vName}[M]"].selectedIndex=m-1; // document.forms[0]["{$vName}[d]"].selectedIndex=d-1; document.forms[0]["{$vName}[Y]"].value=y; document.forms[0]["{$vName}[M]"].value=m; document.forms[0]["{$vName}[d]"].value=d; } </script> EOS; return $js . $vRetFunction . parent::toHtml() . '<a name="' . $vAnchorName . '" id="' . $vAnchorName . '">' . '<button onclick="return PopupDateEx(\'' . $vAnchorName . '\', \'' . $vName . '\', ' . $vEnableClear . ', ' . $vAddDays . ', \'' . $vRetFunctionName . '\')" style="height:20px">' . '<img onclick="return PopupDateEx(\'' . $vAnchorName . '\', \'' . $vName . '\', ' . $vEnableClear . ', ' . $vAddDays . ', \'' . $vRetFunctionName . '\')" src="../images/popupCalendar.gif">' . '</button>'; } } HTML_QuickForm::registerElementType('dateex', 'library/QuickFormEx.php', 'HTML_QuickForm_dateEx');
* @package HTML_QuickForm_CAPTCHA * @author Philippe Jausions <*****@*****.**> * @copyright 2006-2008 by Philippe Jausions / 11abacus * @license http://www.opensource.org/licenses/bsd-license.php New BSD * @version Release: 0.3.0 * @link http://pear.php.net/package/HTML_QuickForm_CAPTCHA * @see Text_CAPTCHA_Driver_Equation */ class HTML_QuickForm_CAPTCHA_Word extends HTML_QuickForm_CAPTCHA { /** * Default options * * @var array * @access protected */ var $_options = array('sessionVar' => '_HTML_QuickForm_CAPTCHA', 'length' => 4, 'mode' => 'single', 'locale' => 'en_US', 'phrase' => null); /** * CAPTCHA driver * * @var string * @access protected */ var $_CAPTCHA_driver = 'Word'; } /** * Registers the class with QuickForm */ if (class_exists('HTML_QuickForm')) { HTML_QuickForm::registerElementType('CAPTCHA_Word', 'HTML/QuickForm/CAPTCHA/Word.php', 'HTML_QuickForm_CAPTCHA_Word'); }
$htmlElements = array($this->getElementCss(false), $this->getElementJs(false), $this->_tableAttributes, $strHtmlUnselectedCountId, $strHtmlSelectedCountId, $strHtmlUnselectedCount, $strHtmlSelectedCount, $strHtmlUnselected, $strHtmlSelected . $strHtmlHidden, $strHtmlAdd, $strHtmlRemove, $strHtmlAll, $strHtmlNone, $strHtmlToggle, $strHtmlMoveUp, $strHtmlMoveDown); $strHtml = str_replace($placeHolders, $htmlElements, $strHtml); return $strHtml; } /** * Returns the javascript code generated to handle this element * * @param boolean $raw (optional) html output with script tags or just raw data * * @access public * @return string * @see setJsElement() * @since 0.4.0 */ function getElementJs($raw = true) { $js = DATAFACE_PATH . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'HTML' . DIRECTORY_SEPARATOR . 'QuickForm' . DIRECTORY_SEPARATOR . 'qfamsHandler.js'; if (file_exists($js)) { $js = file_get_contents($js); } else { $js = ''; } if ($raw !== true) { $js = '<script type="text/javascript">' . PHP_EOL . '//<![CDATA[' . PHP_EOL . $js . PHP_EOL . '//]]>' . PHP_EOL . '</script>' . PHP_EOL; } return $js; } } if (class_exists('HTML_QuickForm')) { HTML_QuickForm::registerElementType('advmultiselect', 'HTML/QuickForm/advmultiselect.php', 'HTML_QuickForm_advmultiselect'); }
switch ($event) { case 'updateValue': $this->_subForm->_submitValues = $caller->_submitValues; $this->_subForm->setDefaults($caller->_defaultValues); $this->_subForm->setConstants($caller->_constantValues); break; default: parent::onQuickFormEvent($event, $arg, $caller); break; } return true; } function _checkForEnctype() { if ($this->_subForm && $this->_parentForm) { if ($this->_subForm->getAttribute('enctype') == 'multipart/form-data') { $this->_parentForm->updateAttributes(array('enctype' => 'multipart/form-data')); $this->_parentForm->setMaxFileSize(); } /*foreach (array_keys($this->_subForm->_elements) as $key) { if (is_a($this->_subForm->_elements[$key], 'HTML_QuickForm_file')) { $this->_parentForm->updateAttributes(array('enctype' => 'multipart/form-data')); $this->_parentForm->setMaxFileSize(); } }*/ } } } if (class_exists('HTML_QuickForm')) { HTML_QuickForm::registerElementType('subForm', __FILE__, 'HTML_QuickForm_SubForm'); }
/** * HTML_QuickForm_tinymce. * * @author guillaule l. <*****@*****.**> * @license PHP License http://www.php.net/license/3_0.txt * $Id: tinymce.php,v 1.1.1.1 2007-06-06 11:14:50 david Exp $ */ /** * include parent class. */ require_once 'HTML/QuickForm/textarea.php'; /** * Register QuickForm element type */ HTML_QuickForm::registerElementType('tinymce', 'HTML/QuickForm/tinymce.php', 'HTML_QuickForm_tinymce'); /** * HTML_QuickForm_tinymce * * Add a web based Javascript HTML WYSIWYG editor control based on * {@link http://tinymce.moxiecode.com TinyMCE}. * * Example: * <code> * ... * require_once 'HTML/QuickForm/tinymce.php'; * * $options = array( * 'baseURL' => 'js/tinymce/jscript/tiny_mce/', * 'configFile' => 'js/tinymce/tinymce.inc.js'); * $attributes = array(
// From // http://www.developingskills.com/ds.php?article=jstrim&page=1 function strtrim() { return this.replace(/^\\s+/,'').replace(/\\s+\$/,''); } String.prototype.trim = strtrim; function qf_AJAXAC() { } // end javascript for AJAXAutocomplete EOS; define('HTML_QUICKFORM_AJAXAUTOCOMPLETE_EXISTS', true); } $jsEscape = array("\r" => '\\r', "\n" => '\\n', "\t" => '\\t', "'" => "\\'", '"' => '\\"', '\\' => '\\\\'); $js .= 'var ' . $arrayName . " = new Array();\n"; for ($i = 0; $i < count($this->extraData); $i++) { $js .= $arrayName . '[' . $i . "] = '" . strtr($this->extraData[$i], $jsEscape) . "';\n"; } $js .= "//]]>\n</script>\n"; return $js . parent::toHtml(); } } } //end class HTML_QuickForm_SelectFilter if (class_exists('HTML_QuickForm')) { HTML_QuickForm::registerElementType('AJAXAutocomplete', 'AJAXAutocomplete.php', 'HTML_QuickForm_AJAXAutocomplete'); }