本文整理汇总了PHP中Pieform::get_name方法的典型用法代码示例。如果您正苦于以下问题:PHP Pieform::get_name方法的具体用法?PHP Pieform::get_name怎么用?PHP Pieform::get_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pieform
的用法示例。
在下文中一共展示了Pieform::get_name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pieform_element_textarea
/**
* Renders a basic HTML <textarea> element.
*
* @param array $element The element to render
* @param Pieform $form The form to render the element for
* @return string The HTML for the element
*/
function pieform_element_textarea(Pieform $form, $element)
{
/*{{{*/
global $_PIEFORM_TEXTAREAS;
$rows = $cols = $style = '';
if (isset($element['height'])) {
$style .= 'height:' . $element['height'] . ';';
$rows = intval($element['height'] > 0) ? ceil(intval($element['height']) / 10) : 1;
} elseif (isset($element['rows'])) {
$rows = $element['rows'];
} else {
Pieform::info('No value for rows or height specified for textarea "' . $element['name'] . '"');
}
if (isset($element['width'])) {
$style .= 'width:' . $element['width'] . ';';
$cols = intval($element['width'] > 0) ? ceil(intval($element['width']) / 10) : 1;
} elseif (isset($element['cols'])) {
$cols = $element['cols'];
} else {
Pieform::info('No value for cols or width specified for textarea "' . $element['name'] . '"');
}
$element['style'] = isset($element['style']) ? $style . $element['style'] : $style;
$fullwidth = !empty($element['fullwidth']) ? 'true' : 'false';
if (!empty($element['resizable'])) {
$element['class'] = isset($element['class']) && $element['class'] ? $element['class'] . ' resizable' : 'resizable';
$_PIEFORM_TEXTAREAS[] = array('formname' => $form->get_name(), 'elementname' => $form->get_name() . '_' . $element['id'], 'fullwidth' => $fullwidth);
}
return '<textarea' . ($rows ? ' rows="' . $rows . '"' : '') . ($cols ? ' cols="' . $cols . '"' : '') . $form->element_attributes($element, array('maxlength', 'size')) . '>' . Pieform::hsc($form->get_value($element)) . '</textarea>';
}
示例2: pieform_element_tinywysiwyg_views_js
/**
* Extension by Mahara. This api function returns the javascript required to
* set up the element, assuming the element has been placed in the page using
* javascript. This feature is used in the views interface.
*
* In theory, this could go upstream to pieforms itself
*
* @param Pieform $form The form
* @param array $element The element
*/
function pieform_element_tinywysiwyg_views_js(Pieform $form, $element)
{
if (is_html_editor_enabled()) {
$formname = json_encode($form->get_name());
$editor = json_encode($form->get_name() . '_' . $element['name']);
return "\ntinyMCE.idCounter=0;" . "\ntinyMCE.execCommand('mceAddEditor', false, {$editor});" . "\nPieformManager.connect('onsubmit', {$formname}, tinyMCE.triggerSave);" . "\nPieformManager.connect('onreply', {$formname}, function () {" . "\n tinyMCE.execCommand('mceRemoveEditor', false, {$editor});" . "});";
}
return '';
}
示例3: pieform_element_tinywysiwyg_views_js
/**
* Extension by Mahara. This api function returns the javascript required to
* set up the element, assuming the element has been placed in the page using
* javascript. This feature is used in the views interface.
*
* In theory, this could go upstream to pieforms itself
*
* @param Pieform $form The form
* @param array $element The element
*/
function pieform_element_tinywysiwyg_views_js(Pieform $form, $element)
{
global $USER;
if ($USER->get_account_preference('wysiwyg') || defined('PUBLIC')) {
$formname = json_encode($form->get_name());
$editor = json_encode($form->get_name() . '_' . $element['name']);
return "\ntinyMCE.idCounter=0;tinyMCE.execCommand('mceAddControl', true, {$editor});PieformManager.connect('onsubmit', {$formname}, tinyMCE.triggerSave);";
}
return '';
}
示例4: pieform_renderer_table
/**
* Renders form elements inside a <table>.
*
* @param Pieform $form The form the element is being rendered for
* @param array $element The element to be rendered
* @return string The element rendered inside an appropriate container
*/
function pieform_renderer_table(Pieform $form, $element)
{
/*{{{*/
$formname = $form->get_name();
if ($element['type'] == 'fieldset') {
// Add table tags to the build element, to preserve HTML compliance
$builtelement = $element['html'];
if (0 === strpos($builtelement, "\n<fieldset")) {
$closelegendpos = strpos($builtelement, '</legend>');
if ($closelegendpos !== false) {
$closelegendpos += 9;
$builtelement = substr($builtelement, 0, $closelegendpos) . '<table><tbody>' . substr($builtelement, $closelegendpos);
} else {
$pos = strpos($builtelement, '>') + 1;
$builtelement = substr($builtelement, 0, $pos) . '<table><tbody>' . substr($builtelement, $pos);
}
} else {
$builtelement = substr($builtelement, 0, 11) . '<table><tbody>' . substr($builtelement, 11);
}
$builtelement = substr($builtelement, 0, -12) . '</tbody></table></fieldset>';
$result = "\t<tr>\n\t\t<td colspan=\"2\">";
$result .= $builtelement;
$result .= "</td>\n\t</tr>";
return $result;
}
$result = "\t<tr";
$result .= ' id="' . $formname . '_' . $element['name'] . '_container"';
// Set the class of the enclosing <tr> to match that of the element
if (!empty($element['class'])) {
$result .= ' class="' . $element['class'] . '"';
}
$result .= ">\n\t\t";
$result .= '<th>';
if (isset($element['labelhtml'])) {
$result .= $element['labelhtml'];
}
$result .= "</th>\n\t\t<td>";
$result .= $element['html'];
if (isset($element['helphtml'])) {
$result .= ' ' . $element['helphtml'];
}
$result .= "</td>\n\t</tr>\n";
// Description - optional description of the element, or other note that should be visible
// on the form itself (without the user having to hover over contextual help
if ((!$form->has_errors() || $form->get_property('showdescriptiononerror')) && !empty($element['description'])) {
if ($form->get_property('descriptionintwocells')) {
$result .= "\t<tr>\n\t\t<td></td><td class=\"description\">";
} else {
$result .= "\t<tr>\n\t\t<td colspan=\"2\" class=\"description\">";
}
$result .= $element['description'];
$result .= "</td>\n\t</tr>\n";
}
if (!empty($element['error'])) {
$result .= "\t<tr>\n\t\t<td colspan=\"2\" class=\"errmsg\">";
$result .= $element['error'];
$result .= "</td>\n\t</tr>\n";
}
return $result;
}
示例5: pieform_renderer_oneline
/**
* Renders form elements all on one line.
*
* @param Pieform $form The form the element is being rendered for
* @param array $element The element that is being rendered
* @return string The element rendered inside an appropriate container
*/
function pieform_renderer_oneline(Pieform $form, $element)
{
/*{{{*/
$formname = $form->get_name();
// Set the class of the enclosing <div> to match that of the element
$result = '<span';
if (isset($element['name'])) {
$result .= ' id="' . $formname . '_' . $element['name'] . '_container"';
}
if (!empty($element['class'])) {
$result .= ' class="' . $element['class'] . '"';
}
$result .= '>';
if (isset($element['title']) && $element['title'] !== '' && $element['type'] != 'fieldset') {
if (!empty($element['nolabel'])) {
// Don't bother with a label for the element
$result .= Pieform::hsc($element['title']);
} else {
$result .= '<label for="' . $element['id'] . '">' . Pieform::hsc($element['title']) . '</label>';
}
if ($form->get_property('requiredmarker') && !empty($element['rules']['required'])) {
$result .= ' <span class="requiredmarker">*</span>';
}
}
$result .= $element['html'];
$result .= "</span>";
return $result;
}
示例6: pieform_element_expiry
/**
* Provides a duration chooser, with a text box for a number and a
* select box to choose the units, in days, weeks, months, years, or 'no end date'.
*
* @param Pieform $form The form to render the element for
* @param array $element The element to render
* @return string The HTML for the element
*/
function pieform_element_expiry(Pieform $form, $element)
{
/*{{{*/
$formname = $form->get_name();
$result = '';
$name = $element['name'];
if (!isset($element['defaultvalue'])) {
$element['defaultvalue'] = null;
}
$global = $form->get_property('method') == 'get' ? $_GET : $_POST;
// Get the value of the element for rendering.
if (isset($element['value'])) {
$seconds = $element['value'];
$values = pieform_element_expiry_get_expiry_from_seconds($element['value']);
} else {
if (isset($global[$element['name']]) && isset($global[$element['name'] . '_units'])) {
$values = array('number' => $global[$element['name']], 'units' => $global[$element['name'] . '_units']);
$seconds = $values['number'] * pieform_element_expiry_seconds_in($values['units']);
} else {
if (isset($element['defaultvalue'])) {
$seconds = $element['defaultvalue'];
$values = pieform_element_expiry_get_expiry_from_seconds($seconds);
} else {
$values = array('number' => '', 'units' => 'noenddate');
$seconds = null;
}
}
}
// @todo probably create with an actual input element, as tabindex doesn't work here for one thing
// Same with the select. And do the events using mochikit signal instead of dom events
$numberinput = '<input';
$numberinput .= $values['units'] == 'noenddate' && empty($element['rules']['required']) ? ' disabled="disabled"' : '';
$numberinput .= ' type="text" size="4" name="' . $name . '"';
$numberinput .= ' id="' . $formname . '_' . $name . '" value="' . $values['number'] . '" tabindex="' . $element['tabindex'] . '"';
$numberinput .= (isset($element['error']) ? ' class="error"' : '') . ">\n";
$uselect = '<select onchange="' . $name . '_change()" ';
$uselect .= 'name="' . $name . '_units" id="' . $formname . '_' . $name . '_units"' . ' tabindex="' . $element['tabindex'] . "\">\n";
foreach (pieform_element_expire_get_expiry_units() as $u) {
// Don't allow 'no end date' if the element is required
if ($u == 'noenddate' && !empty($element['rules']['required'])) {
continue;
}
$uselect .= "\t<option value=\"{$u}\"" . ($values['units'] == $u ? ' selected="selected"' : '') . '>' . $form->i18n('element', 'expiry', $u, $element) . "</option>\n";
}
$uselect .= "</select>\n";
// Make sure the input is disabled if "no end date" is selected
$script = <<<EOJS
<script type="text/javascript" language="javascript">
function {$name}_change() {
if (\$('{$formname}_{$name}_units').value == 'noenddate') {
\$('{$formname}_{$name}').disabled = true;
}
else {
\$('{$formname}_{$name}').disabled = false;
}
}
</script>
EOJS;
return $numberinput . $uselect . $script;
}
示例7: pieform_element_calendar
/**
* Provides a javascript calendar for inputting a date.
*
* General documentation about the calendar is available at
* http://www.dynarch.com/static/jscalendar-1.0/doc/html/reference.html
*
* @param Pieform $form The form to render the element for
* @param array $element The element to render
* @return string The HTML for the element
*/
function pieform_element_calendar(Pieform $form, $element)
{
/*{{{*/
$id = $form->get_name() . '_' . $element['name'];
$value = $form->get_value($element);
if ($value) {
$value = Pieform::hsc(strftime($element['caloptions']['ifFormat'], $value));
}
// Build the HTML
$result = '<input type="text"' . $form->element_attributes($element) . ' value="' . $value . '">';
if (isset($element['imagefile'])) {
$result .= '<a href="" id="' . $id . '_btn" onclick="return false;" class="pieform-calendar-toggle"' . ' tabindex="' . $element['tabindex'] . '">' . '<img src="' . $element['imagefile'] . '" alt=""></a>';
} else {
$result .= '<input type="button" id="' . $id . '_btn" onclick="return false;" class="pieform-calendar-toggle"' . ' value="..." tabindex="' . $element['tabindex'] . '">';
}
// Build the configuring javascript
$options = array_merge($element['caloptions'], array('inputField' => $id, 'button' => $id . '_btn'));
$encodedoptions = json_encode($options);
// Some options are callbacks and need their quoting removed
foreach (array('dateStatusFunc', 'flatCallback', 'onSelect', 'onClose', 'onUpdate') as $function) {
$encodedoptions = preg_replace('/("' . $function . '"):"([a-zA-Z0-9$]+)"/', '\\1:\\2', $encodedoptions);
}
$result .= '<script type="text/javascript">Calendar.setup(' . $encodedoptions . ');</script>';
return $result;
}
示例8: pieform_element_radio
/**
* Renders a set of radio buttons for a form
*
* @param array $element The element to render
* @param Pieform $form The form to render the element for
* @return string The HTML for the element
*/
function pieform_element_radio(Pieform $form, $element)
{
/*{{{*/
if (!isset($element['options']) || !is_array($element['options']) || count($element['options']) < 1) {
throw new PieformException('Radio elements should have at least one option');
}
$result = '';
$form_value = $form->get_value($element);
$id = $element['id'];
$separator = "\n";
if (isset($element['separator'])) {
$separator = $element['separator'] . $separator;
}
foreach ($element['options'] as $value => $data) {
$uid = $id . substr(md5(microtime()), 0, 4);
$element['id'] = $uid;
if (is_array($data)) {
$text = $data['text'];
$description = isset($data['description']) ? $data['description'] : '';
} else {
$text = $data;
$description = '';
}
$result .= '<input type="radio"' . $form->element_attributes($element) . ' value="' . Pieform::hsc($value) . '"' . ($form_value == $value ? ' checked="checked"' : '') . '> <label for="' . $form->get_name() . '_' . $uid . '">' . Pieform::hsc($text) . "</label>" . ($description != '' ? '<div class="radio-description">' . $description . '</div>' : '') . $separator;
}
$result = substr($result, 0, -strlen($separator));
return $result;
}
示例9: pieform_renderer_oneline
/**
* Renders form elements all on one line.
*
* @param Pieform $form The form the element is being rendered for
* @param array $element The element that is being rendered
* @return string The element rendered inside an appropriate container
*/
function pieform_renderer_oneline(Pieform $form, $element)
{
/*{{{*/
$formname = $form->get_name();
// Set the class of the enclosing <div> to match that of the element
$result = '<span';
if (isset($element['name'])) {
$result .= ' id="' . $formname . '_' . Pieform::hsc($element['name']) . '_container"';
}
if (!empty($element['class'])) {
$result .= ' class="' . Pieform::hsc($element['class']) . '"';
}
$result .= '>';
if (isset($element['labelhtml'])) {
$result .= $element['labelhtml'];
}
if (isset($element['prehtml'])) {
$result .= '<span class="prehtml">' . $element['prehtml'] . '</span>';
}
$result .= $element['html'];
if (isset($element['posthtml'])) {
$result .= '<span class="posthtml">' . $element['posthtml'] . '</span>';
}
$result .= "</span>";
return $result;
}
示例10: pieform_element_captcha_get_value
function pieform_element_captcha_get_value(Pieform $form, $element)
{
global $SESSION;
$name = $element['name'];
$global = $form->get_property('method') == 'get' ? $_GET : $_POST;
return isset($global[$name]) && strtolower($global[$name]) == strtolower($SESSION->get($form->get_name() . '_' . $name));
}
示例11: pieform_element_tags
/**
* Provides a tag input field
*
* @param Pieform $form The form to render the element for
* @param array $element The element to render
* @return string The HTML for the element
*/
function pieform_element_tags(Pieform $form, $element)
{
$smarty = smarty();
$value = array();
if (isset($element['defaultvalue']) && is_array($element['defaultvalue'])) {
$value = $element['defaultvalue'];
}
if ($form->get_value($element)) {
$value = $form->get_value($element);
}
if (isset($element['value']) && is_array($element['value'])) {
$value = $element['value'];
}
if (!is_array($value)) {
$value = array();
}
if (!isset($element['size'])) {
$element['size'] = 60;
}
$smarty->assign('name', $element['name']);
$smarty->assign('size', $element['size']);
$smarty->assign('id', $form->get_name() . '_' . $element['id']);
$smarty->assign('value', join(', ', $value));
$smarty->left_delimiter = '{{';
$smarty->right_delimiter = '}}';
return $smarty->fetch('form/tags.tpl');
}
示例12: pieform_renderer_oneline
/**
* Renders form elements all on one line.
*
* @param Pieform $form The form the element is being rendered for
* @param array $element The element that is being rendered
* @return string The element rendered inside an appropriate container
*/
function pieform_renderer_oneline(Pieform $form, $element)
{
/*{{{*/
$formname = $form->get_name();
// Set the class of the enclosing <div> to match that of the element
$result = '<span';
if (isset($element['name'])) {
$result .= ' id="' . $formname . '_' . Pieform::hsc($element['name']) . '_container"';
}
if (!empty($element['class'])) {
// add form-group classes to all real form fields
if (strpos($element['class'], 'html') === false) {
// $element['class'] = $element['class'] . ' form-group-inline';
$element['class'] = 'form-group-inline';
}
// add bootstrap has-error class to any error fields
if (strpos($element['class'], 'error') !== false) {
$element['class'] = $element['class'] . ' has-error';
}
$result .= ' class="' . Pieform::hsc($element['class']) . '"';
}
$result .= '>';
if (isset($element['labelhtml'])) {
$result .= $element['labelhtml'];
}
if (isset($element['prehtml'])) {
$result .= '<span class="prehtml">' . $element['prehtml'] . '</span>';
}
$result .= $element['html'];
if (isset($element['posthtml'])) {
$result .= '<span class="posthtml">' . $element['posthtml'] . '</span>';
}
$result .= "</span>";
return $result;
}
示例13: pieform_renderer_div
/**
* Renders form elements inside <div>s.
*
* @param Pieform $form The form the element is being rendered for
* @param array $element The element to be rendered
* @return string The element rendered inside an appropriate container
*/
function pieform_renderer_div(Pieform $form, $element)
{
/*{{{*/
$formname = $form->get_name();
// Set the class of the enclosing <div> to match that of the element
$result = '<div';
if (isset($element['name'])) {
$result .= ' id="' . $formname . '_' . $element['name'] . '_container"';
}
if (!empty($element['class'])) {
$result .= ' class="' . $element['class'] . '"';
}
$result .= '>';
if (isset($element['labelhtml'])) {
$result .= $element['labelhtml'];
}
//$result .= $builtelement;
$result .= $element['html'];
if (isset($element['helphtml'])) {
$result .= ' ' . $element['helphtml'];
}
// Description - optional description of the element, or other note that should be visible
// on the form itself (without the user having to hover over contextual help
if ((!$form->has_errors() || $form->get_property('showdescriptiononerror')) && !empty($element['description'])) {
$result .= '<div class="description"> ' . Pieform::hsc($element['description']) . "</div>";
}
if (!empty($element['error'])) {
$result .= '<div class="errmsg">' . Pieform::hsc($element['error']) . '</div>';
}
$result .= "</div>\n";
return $result;
}
示例14: pieform_element_fieldset
/**
* Renders a fieldset. Fieldsets contain other elements, and do not count as a
* "true" element, in that they do not have a value and cannot be validated.
*
* @param Pieform $form The form to render the element for
* @param array $element The element to render
* @return string The HTML for the element
*/
function pieform_element_fieldset(Pieform $form, $element)
{
/*{{{*/
global $_PIEFORM_FIELDSETS;
$result = "\n<fieldset";
if (!empty($element['collapsible']) || !empty($element['class'])) {
if (!isset($element['legend']) || $element['legend'] === '') {
Pieform::info('Collapsible fieldsets should have a legend so they can be toggled');
}
$classes = array('collapsible');
$formname = $form->get_name();
if (!isset($_PIEFORM_FIELDSETS['forms'][$formname])) {
$_PIEFORM_FIELDSETS['forms'][$formname] = array('formname' => $formname);
}
// Work out whether any of the children have errors on them
$error = false;
foreach ($element['elements'] as $subelement) {
if (isset($subelement['error'])) {
$error = true;
break;
}
}
if (!empty($element['collapsed']) && !$error) {
$classes[] = 'collapsed';
}
if (!empty($element['class'])) {
$classes[] = Pieform::hsc($element['class']);
}
$result .= ' class="' . implode(' ', $classes) . '"';
}
$result .= ">\n";
if (isset($element['legend'])) {
$result .= '<legend>';
if (!empty($element['collapsible'])) {
$result .= '<a href="">' . Pieform::hsc($element['legend']) . '</a>';
} else {
$result .= Pieform::hsc($element['legend']);
}
// Help icon
if (!empty($element['help'])) {
$function = $form->get_property('helpcallback');
if (function_exists($function)) {
$result .= $function($form, $element);
} else {
$result .= '<span class="help"><a href="" title="' . Pieform::hsc($element['help']) . '" onclick="return false;">?</a></span>';
}
}
$result .= "</legend>\n";
}
foreach ($element['elements'] as $subname => $subelement) {
if ($subelement['type'] == 'hidden') {
throw new PieformError("You cannot put hidden elements in fieldsets");
}
$result .= "\t" . pieform_render_element($form, $subelement);
}
$result .= "</fieldset>\n";
return $result;
}
示例15: pieform_element_files_get_value
function pieform_element_files_get_value(Pieform $form, $element)
{
$name = $form->get_name() . '_' . $element['name'];
$value = array();
foreach ($_FILES as $k => $v) {
if (preg_match('/^' . $name . '_files_\\d+$/', $k) && !empty($v['name'])) {
$value[] = $k;
}
}
return $value;
}