本文整理汇总了PHP中Pieform类的典型用法代码示例。如果您正苦于以下问题:PHP Pieform类的具体用法?PHP Pieform怎么用?PHP Pieform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Pieform类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: pieform_rule_required
/**
* Checks whether the field has been specified.
*
* @param Pieform $form The form the rule is being applied to
* @param string $value The value of the field
* @param array $element The element to check
* @param string $check Whether to check the element
* @return string The error message, if the value is invalid.
*/
function pieform_rule_required(Pieform $form, $value, $element, $check)
{
/*{{{*/
if ($check && ($value == '' || $value == array())) {
return $form->i18n('rule', 'required', 'required', $element);
}
}
开发者ID:Br3nda,项目名称:mahara,代码行数:16,代码来源:required.php
示例2: pieform_rule_email
/**
* Returns whether the given field is a valid e-mail address.
*
* Currently, the check is [anything]@[anything]. Someone is welcome to write
* something better, this was made just for testing.
*
* @param Pieform $form The form the rule is being applied to
* @param string $value The e-mail address to check
* @param array $element The element to check
* @return string The error message, if there is something wrong with
* the address.
*/
function pieform_rule_email(Pieform $form, $value, $element)
{
/*{{{*/
if (!preg_match('/^[A-Za-z0-9\\._%-]+@(?:[A-Za-z0-9-]+\\.)+[a-z]{2,4}$/', $value)) {
return $form->i18n('rule', 'email', 'email', $element);
}
}
开发者ID:Br3nda,项目名称:mahara,代码行数:19,代码来源:email.php
示例3: changerole_validate
function changerole_validate(Pieform $form, $values)
{
global $user, $group;
if (!group_can_change_role($group->id, $user->id, $values['role'])) {
$form->set_error('role', get_string('usercannotchangetothisrole', 'group'));
}
}
开发者ID:patkira,项目名称:mahara,代码行数:7,代码来源:changerole.php
示例4: 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;
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:35,代码来源:radio.php
示例5: 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));
}
开发者ID:Br3nda,项目名称:mahara,代码行数:7,代码来源:captcha.php
示例6: networkingform_submit
function networkingform_submit(Pieform $form, $values)
{
$reply = '';
if ($form->get_submitvalue() === 'deletekey') {
global $SESSION;
$openssl = OpenSslRepo::singleton();
$openssl->get_keypair(true);
$SESSION->add_info_msg(get_string('keydeleted', 'admin'));
// Using cancel here as a hack to get it to redirect so it shows the new keys
$form->reply(PIEFORM_CANCEL, array('location' => get_config('wwwroot') . 'admin/site/networking.php'));
}
if (get_config('enablenetworking') != $values['enablenetworking']) {
if (!set_config('enablenetworking', $values['enablenetworking'])) {
networkingform_fail($form);
} else {
if (empty($values['enablenetworking'])) {
$reply .= get_string('networkingdisabled', 'admin');
} else {
$reply .= get_string('networkingenabled', 'admin');
}
}
}
if (get_config('promiscuousmode') != $values['promiscuousmode']) {
if (!set_config('promiscuousmode', $values['promiscuousmode'])) {
networkingform_fail($form);
} else {
if (empty($values['promiscuousmode'])) {
$reply .= get_string('promiscuousmodedisabled', 'admin');
} else {
$reply .= get_string('promiscuousmodeenabled', 'admin');
}
}
}
$form->reply(PIEFORM_OK, array('message' => $reply == '' ? get_string('networkingunchanged', 'admin') : $reply, 'goto' => '/admin/site/networking.php'));
}
开发者ID:sarahjcotton,项目名称:mahara,代码行数:35,代码来源:networking.php
示例7: 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;
}
开发者ID:Br3nda,项目名称:mahara,代码行数:39,代码来源:div.php
示例8: 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;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:33,代码来源:oneline.php
示例9: pieform_element_cancelbackcreate
/**
* Renders a submit and cancel button
*
* @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_cancelbackcreate(Pieform $form, $element)
{
$form->include_plugin('element', 'submit');
$form->include_plugin('element', 'cancel');
$cancelelement = $element;
$cancelelement['value'] = $element['value'][0];
$backelement = $element;
$backelement['name'] = 'back';
$backelement['id'] = 'back';
$backelement['value'] = $element['value'][1];
$submitelement = $element;
$submitelement['value'] = $element['value'][2];
if (isset($element['confirm']) && isset($element['confirm'][0])) {
$cancelelement['confirm'] = $element['confirm'][0];
} else {
unset($cancelelement['confirm']);
}
if (isset($element['confirm']) && isset($element['confirm'][1])) {
$backelement['confirm'] = $element['confirm'][1];
} else {
unset($backelement['confirm']);
}
if (isset($element['confirm']) && isset($element['confirm'][2])) {
$submitelement['confirm'] = $element['confirm'][2];
} else {
unset($submitelement['confirm']);
}
return pieform_element_cancel($form, $cancelelement) . ' ' . pieform_element_submit($form, $backelement) . ' ' . pieform_element_submit($form, $submitelement);
}
开发者ID:Br3nda,项目名称:mahara,代码行数:36,代码来源:cancelbackcreate.php
示例10: contactus_validate
function contactus_validate(Pieform $form, $values)
{
$captcharequired = get_config('captcha_on_contact_form');
if ((is_null($captcharequired) || $captcharequired) && !$values['captcha']) {
$form->set_error('captcha', get_string('captchaincorrect'));
}
}
开发者ID:Br3nda,项目名称:mahara,代码行数:7,代码来源:contact.php
示例11: pieform_element_button
/**
* Renders an <input type="button"> element.
*
* The element must have the 'value' field set.
*
* @param Pieform $form The form to render the element for
* @param array $element The element to render
* @return string The HTML for the element
* @todo rename to inputbutton
*/
function pieform_element_button(Pieform $form, $element)
{
/*{{{*/
if (!isset($element['value'])) {
throw new PieformException('Button elements must have a value');
}
if (isset($element['confirm'])) {
$element['data-confirm'] = Pieform::hsc($element['confirm']);
}
$element['class'] .= ' btn';
if (isset($element['usebuttontag']) && $element['usebuttontag'] === true) {
$value = '';
$action = '';
$type = 'type="submit" ';
if (isset($element['content'])) {
$content = $element['content'];
$value = 'value="' . Pieform::hsc($element['value']) . '" ';
} else {
$content = $element['value'];
}
if (isset($element['action'])) {
$action = 'formaction="' . Pieform::hsc($element['action']) . '" ';
}
$button = '<button ' . $value . $action . $type . $form->element_attributes($element) . '>' . $content . '</button>';
} else {
$button = '<input type="button"' . $form->element_attributes($element) . ' value="' . Pieform::hsc($element['value']) . '">';
}
return $button;
}
开发者ID:rboyatt,项目名称:mahara,代码行数:39,代码来源:button.php
示例12: importeuropassform_validate
function importeuropassform_validate(Pieform $form, $values)
{
global $USER, $SESSION;
$filetype = $values['file']['type'];
if (!$filetype || $filetype != 'text/xml') {
$form->set_error('file', get_string('notvalidxmlfile', 'artefact.europass'));
}
// Check if at least one import option is checked...
$options = array();
if (!empty($values['identification'])) {
$options[] = 'identification';
}
if (!empty($values['application'])) {
$options[] = 'application';
}
if (!empty($values['workexperience'])) {
$options[] = 'workexperience';
}
if (!empty($values['education'])) {
$options[] = 'education';
}
if (!empty($values['languages'])) {
$options[] = 'languages';
}
if (!empty($values['skills'])) {
$options[] = 'skills';
}
if (!empty($values['additionalinfo'])) {
$options[] = 'additionalinfo';
}
if (empty($options)) {
$form->set_error('additionalinfo', get_string('nocheckedoptions', 'artefact.europass'));
}
}
开发者ID:povsod,项目名称:mahara-artefact-europass,代码行数:34,代码来源:import.php
示例13: pieform_element_submitcancel
/**
* Renders a submit and cancel 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_submitcancel(Pieform $form, $element)
{
/*{{{*/
if (!isset($element['value']) || !is_array($element['value']) || count($element['value']) != 2) {
throw new PieformException('The submitcancel element "' . $element['name'] . '" must have a two element array for its value');
}
$form->include_plugin('element', 'submit');
$form->include_plugin('element', 'cancel');
$submitelement = $element;
$submitelement['class'] = isset($submitelement['class']) ? $submitelement['class'] . ' submit' : 'submit';
$submitelement['value'] = $element['value'][0];
$cancelelement = $element;
$cancelelement['class'] = isset($cancelelement['class']) ? $cancelelement['class'] . ' cancel' : 'cancel';
$cancelelement['value'] = $element['value'][1];
if (isset($element['confirm']) && isset($element['confirm'][0])) {
$submitelement['confirm'] = $element['confirm'][0];
} else {
unset($submitelement['confirm']);
}
if (isset($element['confirm']) && isset($element['confirm'][1])) {
$cancelelement['confirm'] = $element['confirm'][1];
} else {
unset($cancelelement['confirm']);
}
return pieform_element_submit($form, $submitelement) . ' ' . pieform_element_cancel($form, $cancelelement);
}
开发者ID:Br3nda,项目名称:mahara,代码行数:33,代码来源:submitcancel.php
示例14: editgroup_validate
function editgroup_validate(Pieform $form, $values)
{
$cid = get_field('group', 'id', 'name', $values['name']);
if ($cid && $cid != $values['id']) {
$form->set_error('name', get_string('groupalreadyexists', 'group'));
}
}
开发者ID:Br3nda,项目名称:mahara,代码行数:7,代码来源:edit.php
示例15: personalinformation_submit
function personalinformation_submit(Pieform $form, $values)
{
global $personalinformation, $USER;
$userid = $USER->get('id');
$errors = array();
try {
if (empty($personalinformation)) {
$personalinformation = new ArtefactTypePersonalinformation(0, array('owner' => $userid, 'title' => get_string('personalinformation', 'artefact.resume')));
}
foreach (array_keys(ArtefactTypePersonalInformation::get_composite_fields()) as $field) {
$personalinformation->set_composite($field, $values[$field]);
}
$personalinformation->commit();
} catch (Exception $e) {
$errors['personalinformation'] = true;
}
if (empty($errors)) {
$form->json_reply(PIEFORM_OK, get_string('resumesaved', 'artefact.resume'));
} else {
$message = '';
foreach (array_keys($errors) as $key) {
$message .= get_string('resumesavefailed', 'artefact.resume') . "\n";
}
$form->json_reply(PIEFORM_ERR, $message);
}
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:26,代码来源:index.php
示例16: export_validate
function export_validate(Pieform $form, $values)
{
global $SESSION;
if ($values['what'] == 'views') {
$viewchosen = false;
foreach ($values as $key => $value) {
if (substr($key, 0, 5) == 'view_' && $value) {
$viewchosen = true;
}
}
if (!$viewchosen) {
$form->set_error('what', '');
$SESSION->add_error_msg(get_string('youmustselectatleastoneviewtoexport', 'export'));
}
} else {
if ($values['what'] == 'collections') {
$viewchosen = false;
foreach ($values as $key => $value) {
if (substr($key, 0, 11) == 'collection_' && $value) {
$viewchosen = true;
}
}
if (!$viewchosen) {
$form->set_error('what', '');
$SESSION->add_error_msg(get_string('youmustselectatleastonecollectiontoexport', 'export'));
}
}
}
}
开发者ID:sarahjcotton,项目名称:mahara,代码行数:29,代码来源:index.php
示例17: 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;
}
开发者ID:Br3nda,项目名称:mahara,代码行数:35,代码来源:oneline.php
示例18: pieform_element_weight_get_value
function pieform_element_weight_get_value(Pieform $form, $element)
{
pieform_element_weight_validate_element($element);
$name = $element['name'];
$global = $form->get_property('method') == 'get' ? $_GET : $_POST;
$value = null;
if (isset($element['value'])) {
$value = $element['value'];
} else {
if (isset($global[$name])) {
$value = $global[$name];
} else {
if (isset($element['defaultvalue'])) {
$value = $element['defaultvalue'];
}
}
}
// How should we return the value? In theory, there could be several ways
// in which the caller wants the data to be returned. For now, only one
// "policy" is implemented
switch ($element['returnpolicy']) {
case 'renumber-from-zero':
return pieform_element_weight_returnpolicy_renumber_from_zero($element, $value);
}
return null;
}
开发者ID:Br3nda,项目名称:mahara,代码行数:26,代码来源:weight.php
示例19: pieform_element_color_get_value
/**
* Returns the color value of the color selector element from the request or transparent
*
* @param Pieform $form The form the element is attached to
* @param array $element The element to get the value for
* @return string A 6-digit hex color value, or the string "transparent"
*/
function pieform_element_color_get_value(Pieform $form, $element)
{
$name = $element['name'];
$global = $form->get_property('method') == 'get' ? $_GET : $_POST;
if ($form->is_submitted() && isset($global[$name . '_color']) && !isset($global[$name . '_optional'])) {
$color = $global[$name . '_color'];
// Whitelist for a 6-digit hex color
$color = preg_replace('/[^a-f0-9]/i', '', $color);
if (strlen($color) >= 6) {
$color = substr($color, 0, 6);
} else {
if (strlen($color) >= 3) {
// If they provided a 3-digit color string, convert it into a 6-digit one by doubling each digit
$color = substr($color, 0, 3);
$color = $color[0] . $color[0] . $color[1] . $color[1] . $color[2] . $color[2];
} else {
$color = '';
}
}
if ($color === '') {
return 'transparent';
}
$color = "#{$color}";
return $color;
}
return 'transparent';
}
开发者ID:rboyatt,项目名称:mahara,代码行数:34,代码来源:color.php
示例20: pieform_rule_maxvalue
/**
* Checks whether the given value is at most a certain size.
*
* @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 int $maxvalue The value to check for
* @return string The error message, if the value is invalid.
*/
function pieform_rule_maxvalue(Pieform $form, $value, $element, $maxvalue)
{
/*{{{*/
if ($value !== '' && doubleval($value) > $maxvalue) {
return sprintf($form->i18n('rule', 'maxvalue', 'maxvalue', $element), $maxvalue);
}
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:16,代码来源:maxvalue.php
注:本文中的Pieform类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论