本文整理汇总了PHP中Pieform::get_value方法的典型用法代码示例。如果您正苦于以下问题:PHP Pieform::get_value方法的具体用法?PHP Pieform::get_value怎么用?PHP Pieform::get_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pieform
的用法示例。
在下文中一共展示了Pieform::get_value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pieform_element_hidden
/**
* Renders a hidden element.
*
* @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_hidden(Pieform $form, $element)
{
/*{{{*/
if (!array_key_exists('value', $element)) {
throw new PieformException('The hidden element "' . $element['name'] . '" must have a value set');
}
if (!empty($element['sesskey']) && $form->get_property('method') != 'post') {
throw new PieformException('Sesskey values should be POSTed');
}
$value = $form->get_value($element);
if (is_array($value)) {
$result = '';
foreach ($value as $k => $v) {
if (is_array($v)) {
foreach ($v as $subk => $subv) {
$result .= '<input type="hidden" name="' . Pieform::hsc($element['name']) . '[' . Pieform::hsc($k) . '][' . Pieform::hsc($subk) . ']" value="' . Pieform::hsc($subv) . "\">\n";
}
} else {
$result .= '<input type="hidden" name="' . Pieform::hsc($element['name']) . '[' . Pieform::hsc($k) . ']" value="' . Pieform::hsc($v) . "\">\n";
}
}
return $result;
}
return '<input type="hidden"' . $form->element_attributes($element, array('accesskey', 'onclick', 'size', 'style', 'tabindex')) . ' value="' . Pieform::hsc($form->get_value($element)) . "\">\n";
}
示例2: pieform_element_trafficlights
/**
* Renders a set (red, yellow, green) of radio buttons with corresponding background colors as in traffic lights
*
* @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_trafficlights(Pieform $form, $element)
{
/*{{{*/
$global = $form->get_property('method') == 'get' ? $_GET : $_POST;
$submitted = $form->is_submitted();
if ($submitted && isset($global[$element['name']])) {
$value = $global[$element['name']];
}
$result = '';
if (!isset($element['options'])) {
$element['options'] = array(array('value' => '0', 'title' => 'r'), array('value' => '1', 'title' => 'y'), array('value' => '2', 'title' => 'g'));
}
$result .= "<span style='display:block;border:0px;padding-bottom:4px;width:70px !important;'>";
$colors = array('r' => '#FF8080', 'y' => '#FFEB80', 'g' => '#80B280');
$borders = array('r' => 'border-top:1px solid #000000;border-left:1px solid #000000;border-bottom:1px solid #000000;', 'y' => 'border-top:1px solid #000000;border-bottom:1px solid #000000', 'g' => 'border-top:1px solid #000000;border-right:1px solid #000000;border-bottom:1px solid #000000;');
foreach ($element['options'] as $e) {
$checked = $form->get_value($element) === $e['value'] && !is_null($form->get_value($element));
if ($e['value'] == null) {
$checked = false;
}
$result .= '<span style="' . $borders[$e['title']] . ';padding-bottom:4px;background-color:' . $colors[$e['title']] . '"><input type="radio" value="' . $e['value'] . '" ' . $form->element_attributes($element) . ($checked ? ' checked="checked"' : '') . ' style="vertical-align:top"></span>';
}
$result .= "</span>";
$result .= '<div class="cl"></div>';
return $result;
}
示例3: 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');
}
示例4: 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>';
}
示例5: 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;
}
示例6: pieform_element_authlist
/**
* Provides an email list, with verification to enable addresses
*
* @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_authlist(Pieform $form, $element)
{
$smarty = smarty_core();
$smarty->left_delimiter = '{{';
$smarty->right_delimiter = '}}';
$value = $form->get_value($element);
if (!is_array($value) && isset($element['defaultvalue']) && is_array($element['defaultvalue'])) {
$value = $element['defaultvalue'];
}
if (!isset($value['default'])) {
$value['default'] = '';
}
if (is_array($value) && count($value)) {
$smarty->assign('authtypes', $value['authtypes']);
$smarty->assign('instancelist', $value['instancelist']);
$smarty->assign('instancestring', implode(',', $value['instancearray']));
$smarty->assign('default', $value['default']);
$smarty->assign('institution', $value['institution']);
}
$smarty->assign('name', $element['name']);
$smarty->assign('cannotremove', json_encode(get_string('cannotremove', 'auth')));
$smarty->assign('cannotremoveinuse', json_encode(get_string('cannotremoveinuse', 'auth')));
$smarty->assign('saveinstitutiondetailsfirst', json_encode(get_string('saveinstitutiondetailsfirst', 'auth')));
$smarty->assign('noauthpluginconfigoptions', json_encode(get_string('noauthpluginconfigoptions', 'auth')));
return $smarty->fetch('form/authlist.tpl');
}
示例7: pieform_element_rolepermissions
function pieform_element_rolepermissions(Pieform $form, $element)
{
/*{{{*/
$value = $form->get_value($element);
$roles = group_get_role_info($element['group']);
$permissions = array_keys(get_object_vars($value['member']));
$result = '<table class="editpermissions"><tbody>';
$result .= '<tr><th>' . get_string('Role', 'group') . '</th>';
foreach ($permissions as $p) {
$result .= '<th>' . get_string('filepermission.' . $p, 'artefact.file') . '</th>';
}
$result .= '</tr>';
$prefix = $form->get_name() . '_' . $element['name'] . '_p';
foreach ($roles as $r) {
$result .= '<tr>';
$result .= '<td>' . hsc($r->display) . '</td>';
foreach ($permissions as $p) {
$inputname = $prefix . '_' . $r->name . '_' . $p;
$result .= '<td><input type="checkbox" class="permission" name="' . hsc($inputname) . '"';
if ($r->name == 'admin') {
$result .= ' checked disabled';
} else {
if ($value[$r->name]->{$p}) {
$result .= ' checked';
}
}
$result .= '/></td>';
}
$result .= '</tr>';
}
$result .= '</tbody></table>';
return $result;
}
示例8: pieform_element_emaillist
/**
* Provides an email list, with verification to enable addresses
*
* @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_emaillist(Pieform $form, $element)
{
$smarty = smarty_core();
$smarty->left_delimiter = '{{';
$smarty->right_delimiter = '}}';
$value = $form->get_value($element);
if (!is_array($value) && isset($element['defaultvalue']) && is_array($element['defaultvalue'])) {
$value = $element['defaultvalue'];
}
if (!isset($value['validated'])) {
$value['validated'] = array();
}
if (!isset($value['unvalidated'])) {
$value['unvalidated'] = array();
}
if (!isset($value['unsent'])) {
$value['unsent'] = array();
}
if (!isset($value['default'])) {
$value['default'] = '';
}
if (is_array($value) && count($value)) {
$smarty->assign('validated', $value['validated']);
$smarty->assign('unvalidated', $value['unvalidated']);
$smarty->assign('unsent', $value['unsent']);
$smarty->assign('default', $value['default']);
}
$smarty->assign('name', $element['name']);
$smarty->assign('addbuttonstr', get_string('addbutton', 'artefact.internal'));
$smarty->assign('validationemailstr', json_encode(get_string('validationemailwillbesent', 'artefact.internal')));
return $smarty->fetch('form/emaillist.tpl');
}
示例9: 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;
}
示例10: pieform_element_submit
/**
* Renders a submit button
*
* @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_submit(Pieform $form, $element)
{
/*{{{*/
if (isset($element['confirm'])) {
$element['onclick'] = 'return confirm(' . json_encode($element['confirm']) . ');';
}
return '<input type="submit"' . $form->element_attributes($element) . ' value="' . Pieform::hsc($form->get_value($element)) . '">';
}
示例11: pieform_rule_before
/**
* Checks whether the given element's value is less than another element.
*
* Typically useful for dates.
*
* @param Pieform $form The form the rule is being applied to
* @param string $value The value to check
* @param array $element The element to check
* @param string $otherelement The other element to check for
* @return string The error message, if the value is invalid.
*/
function pieform_rule_before(Pieform $form, $value, $element, $otherelement)
{
/*{{{*/
$otherelement = $form->get_element($otherelement);
$othervalue = $form->get_value($otherelement);
if ($value != '' && $othervalue != '' && intval($value) > intval($othervalue)) {
return sprintf($form->i18n('rule', 'before', 'before', $element), $otherelement['title']);
}
}
示例12: pieform_element_autocomplete
/**
* Autocomplete list selector 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_autocomplete(Pieform $form, $element)
{
global $USER;
$wwwroot = get_config('wwwroot');
$smarty = smarty_core();
$smarty->left_delimiter = '{{';
$smarty->right_delimiter = '}}';
$value = $form->get_value($element);
$multiple = !empty($element['multiple']);
if ($multiple) {
$valuestr = implode(',', $value);
} else {
$valuestr = $value;
}
if (!empty($element['initfunction'])) {
$initvalue = json_encode(call_user_func($element['initfunction'], $value));
} else {
$initvalue = '[]';
}
if (array_key_exists('mininputlength', $element)) {
$mininputlength = $element['mininputlength'];
} else {
$mininputlength = 1;
}
$extraparams = '';
if (!empty($element['extraparams'])) {
foreach ($element['extraparams'] as $k => $v) {
if (!is_numeric($v) && !preg_match('/^function/', $v)) {
if (preg_match('/^\'(.*)\'$/', $v, $match)) {
$v = $match[1];
}
$element['extraparams'][$k] = json_encode($v);
}
$extraparams .= $k . ': ' . $element['extraparams'][$k] . ',';
}
}
$smarty->assign('id', $form->get_name() . '_' . $element['id']);
$smarty->assign('name', $element['name']);
$smarty->assign('value', $valuestr);
// Pre-populate form element.
$smarty->assign('initvalue', $initvalue);
$smarty->assign('width', empty($element['width']) ? '300px' : $element['width']);
$smarty->assign('multiple', $multiple ? 'true' : 'false');
$smarty->assign('mininputlength', $mininputlength);
$smarty->assign('allowclear', empty($element['allowclear']) ? 'false' : 'true');
$smarty->assign('disabled', !empty($element['disabled']) ? 'true' : 'false');
$smarty->assign('ajaxurl', $element['ajaxurl']);
$smarty->assign('sesskey', $USER->get('sesskey'));
$smarty->assign('hint', empty($element['hint']) ? get_string('defaulthint') : $element['hint']);
$smarty->assign('extraparams', $extraparams);
$smarty->assign('inblockconfig', !empty($element['inblockconfig']) ? 'true' : 'false');
if (isset($element['description'])) {
$smarty->assign('describedby', $form->element_descriptors($element));
}
return $smarty->fetch('form/autocomplete.tpl');
}
示例13: pieform_element_image
/**
* Renders an <input type="image"> button
*
* @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_image(Pieform $form, $element)
{
/*{{{*/
if (!isset($element['src'])) {
throw new PieformException('"image" elements must have a "src" for the image');
}
if (!isset($element['value'])) {
$element['value'] = true;
}
return '<input type="image" src="' . Pieform::hsc($element['src']) . '"' . $form->element_attributes($element) . ' value="' . Pieform::hsc($form->get_value($element)) . '">';
}
示例14: pieform_element_radio
/**
* Renders a set of radio buttons for a form
*
* @param Pieform $form The form to render the element for
* @param array $element The element to render. In addition to the standard Pieform
* element attributes, it can also take the following optional
* attributes:
* - separator: The HTML string that should separate the radio
* buttons (defaults to \n, always has \n appended to it)
* - rowsize: How many radio buttons to print per row (defaults to 1)
* - nolabels: Don't print the labels next to the individual radio buttons.
* @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;
}
$rowsize = isset($element['rowsize']) ? (int) $element['rowsize'] : 1;
$nolabels = isset($element['nolabels']) ? $element['nolabels'] : false;
$classname = '';
if (!empty($element['hiddenlabels'])) {
$classname = ' class="accessible-hidden"';
}
$titletext = '';
if (!empty($element['title'])) {
$titletext = '<span class="accessible-hidden">' . Pieform::hsc($element['title']) . ': </span>';
}
$i = 0;
foreach ($element['options'] as $value => $data) {
$idsuffix = substr(md5(microtime()), 0, 4);
$baseid = $element['id'];
$element['id'] = $uid = $id . $idsuffix;
if (is_array($data)) {
$text = $data['text'];
$description = isset($data['description']) ? $data['description'] : '';
} else {
$text = $data;
$description = '';
}
$attributes = $form->element_attributes($element);
$attributes = preg_replace("/aria-describedby=\"[^\"]*{$baseid}{$idsuffix}_description\\s*[^\"]*\"/", 'aria-describedby="$1_description"', $attributes);
$result .= '<div class="radio">';
$result .= '<input type="radio"' . $attributes . ' value="' . Pieform::hsc($value) . '"' . ($form_value == $value ? ' checked="checked"' : '') . '>';
if (!$nolabels) {
$result .= ' <label for="' . $form->get_name() . '_' . $uid . '"' . $classname . '>' . $titletext . Pieform::hsc($text) . "</label>" . ($description != '' ? '<div class="description">' . $description . '</div>' : '');
}
$result .= '</div>';
$i++;
if ($rowsize <= 1 || $i % $rowsize == 0) {
$result .= $separator;
}
}
// If there was a separator printed on the end, then remove it
if ($rowsize <= 1 || $i % $rowsize == 0) {
$result = substr($result, 0, -strlen($separator));
}
return $result;
}
示例15: pieform_element_wysiwyg
/**
* Renders a textarea, but with extra javascript to turn it into a wysiwyg
* textarea.
*
* @todo support resizable.
*
* @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_wysiwyg(Pieform $form, $element)
{
global $_PIEFORM_WYSIWYGS;
$_PIEFORM_WYSIWYGS[] = $form->get_name() . '_' . $element['name'];
if (is_html_editor_enabled()) {
if (!$form->get_property('elementclasses')) {
$element['class'] = isset($element['class']) && $element['class'] !== '' ? $element['class'] . ' wysiwyg' : 'wysiwyg';
}
}
$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 {
log_warn('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 {
log_warn('No value for cols or width specified for textarea ' . $element['name']);
}
$element['style'] = isset($element['style']) ? $style . $element['style'] : $style;
if (is_html_editor_enabled()) {
$value = Pieform::hsc($form->get_value($element));
} else {
// Replace <br>s as added by wysiwyg editor or nl2br with a newline
$value = preg_replace("#<br />\\s#", "\n", $form->get_value($element));
// As placed in the value by the wysiwyg editor
$value = str_replace('</p><p>', "\n\n", $value);
// Find the last </p> and replace with newlines
$value = preg_replace('#</p>\\s#', "\n", $value);
$value = strip_tags($value);
}
return '<textarea' . ($rows ? ' rows="' . $rows . '"' : '') . ($cols ? ' cols="' . $cols . '"' : '') . $form->element_attributes($element, array('maxlength', 'size')) . '>' . $value . '</textarea>';
}