本文整理汇总了PHP中HTML_QuickForm_Renderer_Default::setElementTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP HTML_QuickForm_Renderer_Default::setElementTemplate方法的具体用法?PHP HTML_QuickForm_Renderer_Default::setElementTemplate怎么用?PHP HTML_QuickForm_Renderer_Default::setElementTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTML_QuickForm_Renderer_Default
的用法示例。
在下文中一共展示了HTML_QuickForm_Renderer_Default::setElementTemplate方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toHtml
/**
* Returns HTML for advchecbox form element.
*
* @return string
*/
function toHtml()
{
include_once 'HTML/QuickForm/Renderer/Default.php';
$renderer = new HTML_QuickForm_Renderer_Default();
$renderer->setElementTemplate('{element}');
parent::accept($renderer);
$html = $this->_wrap[0];
if ($this->_usedcreateelement) {
$html .= html_writer::tag('span', $renderer->toHtml(), array('class' => 'fdate_time_selector'));
} else {
$html .= $renderer->toHtml();
}
$html .= $this->_wrap[1];
return $html;
}
示例2: toHtml
function toHtml()
{
include_once 'HTML/QuickForm/Renderer/Default.php';
$renderer = new HTML_QuickForm_Renderer_Default();
$renderer->setElementTemplate('{element}');
parent::accept($renderer);
return $this->_wrap[0] . $renderer->toHtml() . $this->_wrap[1];
}
示例3: _hs_findOptions
//.........这里部分代码省略.........
function _hs_swapOptions(form, groupName, selectIndex)
{
var hsValue = [];
for (var i = 0; i <= selectIndex; i++) {
hsValue[i] = _hs_findSelect(form, groupName, i).value;
}
_hs_replaceOptions(_hs_findSelect(form, groupName, selectIndex + 1),
_hs_findOptions(_hs_options[groupName][selectIndex], hsValue));
if (selectIndex + 1 < _hs_options[groupName].length) {
_hs_swapOptions(form, groupName, selectIndex + 1);
}
}
function _hs_onReset(form, groupNames)
{
for (var i = 0; i < groupNames.length; i++) {
try {
for (var j = 0; j <= _hs_options[groupNames[i]].length; j++) {
_hs_setValue(_hs_findSelect(form, groupNames[i], j), _hs_defaults[groupNames[i]][j]);
if (j < _hs_options[groupNames[i]].length) {
_hs_replaceOptions(_hs_findSelect(form, groupNames[i], j + 1),
_hs_findOptions(_hs_options[groupNames[i]][j], _hs_defaults[groupNames[i]].slice(0, j + 1)));
}
}
} catch (e) {
if (!(e instanceof TypeError)) {
throw e;
}
}
}
}
function _hs_setupOnReset(form, groupNames)
{
setTimeout(function() { _hs_onReset(form, groupNames); }, 25);
}
function _hs_onReload()
{
var ctl;
for (var i = 0; i < document.forms.length; i++) {
for (var j in _hs_defaults) {
if (ctl = _hs_findSelect(document.forms[i], j, 0)) {
for (var k = 0; k < _hs_defaults[j].length; k++) {
_hs_setValue(_hs_findSelect(document.forms[i], j, k), _hs_defaults[j][k]);
}
}
}
}
if (_hs_prevOnload) {
_hs_prevOnload();
}
}
var _hs_prevOnload = null;
if (window.onload) {
_hs_prevOnload = window.onload;
}
window.onload = _hs_onReload;
var _hs_options = {};
var _hs_defaults = {};
JAVASCRIPT;
define('HTML_QUICKFORM_HIERSELECT_EXISTS', true);
}
// option lists
$jsParts = array();
for ($i = 1; $i < $this->_nbElements; $i++) {
$jsParts[] = $this->_convertArrayToJavascript($this->_options[$i]);
}
$this->_js .= "\n_hs_options['" . $this->_escapeString($this->getName()) . "'] = [\n" . implode(",\n", $jsParts) . "\n];\n";
// default value; if we don't actually have any values yet just use
// the first option (for single selects) or empty array (for multiple)
$values = array();
foreach (array_keys($this->_elements) as $key) {
if (is_array($v = $this->_elements[$key]->getValue())) {
$values[] = count($v) > 1 ? $v : $v[0];
} else {
// XXX: accessing the supposedly private _options array
$values[] = $this->_elements[$key]->getMultiple() || empty($this->_elements[$key]->_options[0]) ? array() : $this->_elements[$key]->_options[0]['attr']['value'];
}
}
$this->_js .= "_hs_defaults['" . $this->_escapeString($this->getName()) . "'] = " . $this->_convertArrayToJavascript($values, false) . ";\n";
}
include_once 'HTML/QuickForm/Renderer/Default.php';
$renderer = new HTML_QuickForm_Renderer_Default();
$renderer->setElementTemplate('{element}');
parent::accept($renderer);
if (!empty($onChange)) {
$keys = array_keys($this->_elements);
for ($i = 0; $i < count($keys) - 1; $i++) {
$this->_elements[$keys[$i]]->updateAttributes(array('onchange' => $onChange[$i]));
}
}
return (empty($this->_js) ? '' : "<script type=\"text/javascript\">\n//<![CDATA[\n" . $this->_js . "//]]>\n</script>") . $renderer->toHtml();
}
示例4: toHtml
/**
* Returns HTML for submitlink form element.
*
* @return string
*/
function toHtml()
{
require_once 'HTML/QuickForm/Renderer/Default.php';
$renderer = new HTML_QuickForm_Renderer_Default();
$renderer->setElementTemplate('{element}');
parent::accept($renderer);
return $renderer->toHtml();
}
示例5: toHtml
/**
* Returns Html for the group
*
* @since 1.0
* @access public
* @return string
*/
public function toHtml()
{
$renderer = new HTML_QuickForm_Renderer_Default();
$renderer->setElementTemplate('{element}');
$this->accept($renderer);
return $renderer->toHtml();
}
示例6: toHtml
/**
* Returns Html for the group
*
* @since 1.0
* @access public
* @return string
*/
function toHtml()
{
// Modified by Ivan Tcholakov, 16-MAR-2010. Suppressing a deprecation warning on PHP 5.3
//$renderer =& new HTML_QuickForm_Renderer_Default();
$renderer = new HTML_QuickForm_Renderer_Default();
//
$renderer->setElementTemplate('{element}');
$this->accept($renderer);
return $renderer->toHtml();
}
示例7: toHtml
function toHtml()
{
include_once 'HTML/QuickForm/Renderer/Default.php';
$renderer = new HTML_QuickForm_Renderer_Default();
$renderer->setElementTemplate('{element}');
$renderer->setGroupElementTemplate('<div>{element}</div>', $this->_elementName);
parent::accept($renderer);
return str_replace(' ', '', $renderer->toHtml());
}
示例8: toHtml
/**
* Returns Html for the group
*
* @since 1.0
* @access public
* @return string
*/
function toHtml()
{
include_once(dirname(__FILE__) . '/Renderer/Default.php');
$renderer = new HTML_QuickForm_Renderer_Default();
$renderer->setElementTemplate('{element}');
$this->accept($renderer);
return $renderer->toHtml();
} //end func toHtml
示例9: toHtml
/**
* Returns Html for the group
*
* @access public
* @return string
*/
function toHtml()
{
if ($this->_flagFrozen) {
$this->_js = '';
} else {
// set the onchange attribute for each element
$keys = array_keys($this->_elements);
$nbElements = count($keys);
$nbElementsUsingFnc = $nbElements - 1;
// last element doesn't need it
for ($i = 0; $i < $nbElementsUsingFnc; $i++) {
$select = $this->_elements[$keys[$i]];
$select->updateAttributes(array('onChange' => 'swapOptions(this, \'' . $this->getName() . '\', ' . $keys[$i] . ', ' . $nbElements . ', \'' . $this->_jsArrayName . '\');'));
}
// create the js function to call
if (!defined('HTML_QUICKFORM_HIERSELECT_EXISTS')) {
$this->_js .= "function swapOptions(frm, grpName, eleIndex, nbElements, arName)\n" . "{\n" . " var n = \"\";\n" . " var ctl;\n\n" . " for (var i = 0; i < nbElements; i++) {\n" . " ctl = frm.form[grpName+'['+i+']'];\n" . " if (!ctl) {\n" . " ctl = frm.form[grpName+'['+i+'][]'];\n" . " }\n" . " if (i <= eleIndex) {\n" . " n += \"_\"+ctl.value;\n" . " } else {\n" . " ctl.length = 0;\n" . " }\n" . " }\n\n" . " var t = eval(\"typeof(\"+arName + n +\")\");\n" . " if (t != 'undefined') {\n" . " var the_array = eval(arName+n);\n" . " var j = 0;\n" . " n = eleIndex + 1;\n" . " ctl = frm.form[grpName+'['+ n +']'];\n" . " if (!ctl) {\n" . " ctl = frm.form[grpName+'['+ n +'][]'];\n" . " }\n" . " for (var i in the_array) {\n" . " opt = new Option(the_array[i], i, false, false);\n" . " ctl.options[j++] = opt;\n" . " }\n" . " }\n" . " if (eleIndex+1 < nbElements) {\n" . " swapOptions(frm, grpName, eleIndex+1, nbElements, arName);\n" . " }\n" . "}\n";
define('HTML_QUICKFORM_HIERSELECT_EXISTS', true);
}
}
include_once 'HTML/QuickForm/Renderer/Default.php';
$renderer = new HTML_QuickForm_Renderer_Default();
$renderer->setElementTemplate('{element}');
parent::accept($renderer);
return "<script type=\"text/javascript\">\n//<![CDATA[\n" . $this->_js . "//]]>\n</script>" . $renderer->toHtml();
}
示例10: export_for_template
public function export_for_template(renderer_base $output)
{
global $OUTPUT;
$context = $this->export_for_template_base($output);
$this->_renderedfromtemplate = true;
include_once 'HTML/QuickForm/Renderer/Default.php';
$elements = [];
$name = $this->getName();
$i = 0;
foreach ($this->_elements as $key => $element) {
$elementname = '';
if ($this->_appendName) {
$elementname = $element->getName();
if (isset($elementname)) {
$element->setName($name . '[' . (strlen($elementname) ? $elementname : $key) . ']');
} else {
$element->setName($name);
}
}
$element->_generateId();
$out = $OUTPUT->mform_element($element, false, false, '', true);
if (empty($out)) {
$renderer = new HTML_QuickForm_Renderer_Default();
$renderer->setElementTemplate('{element}');
$element->accept($renderer);
$out = $renderer->toHtml();
}
// Replicates the separator logic from 'pear/HTML/QuickForm/Renderer/Default.php'.
$separator = '';
if ($i > 0) {
if (is_array($this->_separator)) {
$separator = $this->_separator[($i - 1) % count($this->_separator)];
} else {
if ($this->_separator === null) {
$separator = ' ';
} else {
$separator = (string) $this->_separator;
}
}
}
$elements[] = ['separator' => $separator, 'html' => $out];
// Restore the element's name.
if ($this->_appendName) {
$element->setName($elementname);
}
$i++;
}
$context['elements'] = $elements;
return $context;
}
示例11: toHtml
function toHtml()
{
$this->_js = '';
if (!defined('HTML_QUICKFORM_ADVANDATE_EXISTS')) {
$this->_js .= "\n\n\t\t\t var advandate_Update = function(groupName) {\n\t\t\t\t\t value=\$('select[name=\"'+groupName+'[firstselect]\"]').val();\n\t\t\t\t\t\tfirstD = \$('select[name^=\"'+groupName+'[firstdate]\"]');\n \$(firstD).hide();\n\t\t\t\t\t\tsecD = \$('select[name^=\"'+groupName+'[seconddate]\"]');\n \$(secD).hide();\n\t\t\t\t\t\tnbunits=\$('select[name=\"'+groupName+'[nbunits]\"]');\n \$(nbunits).hide();\n\t\t\t\t\t\tunit=\$('select[name=\"'+groupName+'[unit]\"]');\n \$(unit).hide();\n\t\t\t\t\t\tseparator=\$('#" . $this->_escapeString($this->getName()) . "_dates_separator');\n\t\t\t\t\t\tseparator.hide();\n\t\t\t\t if( value=='is' && \$(\"input[name='created_at[firstselect]']\").val() != 'is' )\n\t\t\t\t {\n today = new Date();\n \$(firstD[0]).val(today.getDate());\n \$(firstD[1]).val(today.getMonth()+1);\n \$(firstD[2]).val(today.getFullYear());\n\t\t\t\t }\n\t\t\t\t\tif(value=='before' || value=='after' || value=='is') {\n \$(firstD).show();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (value=='between'){\n \$(firstD).show();\n \$(secD).show();\n\t\t\t\t\t\t\tseparator.show();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (value=='inthelast'){\n \$(nbunits).show();\n \$(unit).show();\n\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tif (value=='lastmonth'){\n\t\t\t\t\t\t\t\t\t// Nothing to show\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}";
define('HTML_QUICKFORM_ADVANDATE_EXISTS', TRUE);
}
include_once 'HTML/QuickForm/Renderer/Default.php';
$renderer = new HTML_QuickForm_Renderer_Default();
$renderer->setElementTemplate('{element}');
parent::accept($renderer);
if (class_exists('Mtpl')) {
$script = (empty($this->_js) ? '' : $this->_js) . "\n\$(function(){advandate_Update('" . $this->_escapeString($this->getName()) . "');\n \$('select[name=\"" . $this->_escapeString($this->getName()) . "[firstselect]\"]').bind('change',function(){advandate_Update('" . $this->_escapeString($this->getName()) . "')});\n });";
Mtpl::addJSinline($script);
return $renderer->toHtml();
} else {
return "<script type=\"text/javascript\">\n//<![CDATA[\n" . (empty($this->_js) ? '' : $this->_js) . "\n\$(function(){advandate_Update('" . $this->_escapeString($this->getName()) . "');\n \$('select[name=\"" . $this->_escapeString($this->getName()) . "[firstselect]\"]').bind('change',function(){advandate_Update('" . $this->_escapeString($this->getName()) . "')});\n });//]]>\n</script>" . $renderer->toHtml();
}
}
示例12: toHtml
/**
* Returns Html for the group
*
* @since 1.0
* @access public
* @return string
*/
public function toHtml()
{
include_once 'HTML/QuickForm/Renderer/Default.php';
$renderer = new HTML_QuickForm_Renderer_Default();
$renderer->setElementTemplate('{element}');
$this->accept($renderer);
return $renderer->toHtml();
}
示例13: export_for_template
public function export_for_template(renderer_base $output)
{
global $OUTPUT;
$context = $this->export_for_template_base($output);
$this->_renderedfromtemplate = true;
include_once 'HTML/QuickForm/Renderer/Default.php';
$elements = [];
$name = $this->getName();
foreach ($this->_elements as $key => $element) {
$elementname = '';
if ($this->_appendName) {
$elementname = $element->getName();
if (isset($elementname)) {
$element->setName($name . '[' . (strlen($elementname) ? $elementname : $key) . ']');
} else {
$element->setName($name);
}
}
$element->_generateId();
$out = $OUTPUT->mform_element($element, false, false, '', true);
if (empty($out)) {
$renderer = new HTML_QuickForm_Renderer_Default();
$renderer->setElementTemplate('{element}');
$element->accept($renderer);
$out = $renderer->toHtml();
}
$elements[] = $out;
// Restore the element's name.
if ($this->_appendName) {
$element->setName($elementname);
}
}
$context['elements'] = $elements;
return $context;
}