当前位置: 首页>>代码示例>>PHP>>正文


PHP Pieform::i18n方法代码示例

本文整理汇总了PHP中Pieform::i18n方法的典型用法代码示例。如果您正苦于以下问题:PHP Pieform::i18n方法的具体用法?PHP Pieform::i18n怎么用?PHP Pieform::i18n使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pieform的用法示例。


在下文中一共展示了Pieform::i18n方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: pieform_element_userlist_rule_required

function pieform_element_userlist_rule_required(Pieform $form, $value, $element)
{
    if (is_array($value) && count($value)) {
        return null;
    }
    return $form->i18n('rule', 'required', 'required', $element);
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:7,代码来源:userlist.php

示例2: pieform_rule_regex

/**
 * Returns whether the given field matches the specified regex.
 *
 * @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  $regex   The regular expression to use for the check
 * @return string        The error message, if there is something wrong with
 *                       the value.
 */
function pieform_rule_regex(Pieform $form, $value, $element, $regex)
{
    /*{{{*/
    if (!preg_match($regex, $value)) {
        return $form->i18n('rule', 'regex', 'regex', $element);
    }
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:17,代码来源:regex.php

示例3: pieform_rule_minlength

/**
 * Checks whether the given value is shorter than the allowed length.
 *
 * @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     $minlength The length to check for
 * @return string            The error message, if the value is invalid.
 */
function pieform_rule_minlength(Pieform $form, $value, $element, $minlength)
{
    /*{{{*/
    if (strlen($value) < $minlength) {
        return sprintf($form->i18n('rule', 'minlength', 'minlength', $element), $minlength);
    }
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:16,代码来源:minlength.php

示例4: 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

示例5: 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

示例6: pieform_rule_integer

/**
 * Returns whether the given field is an integer
 *
 * @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
 * @return string            The error message, if there is something wrong with
 *                           the address.
 */
function pieform_rule_integer(Pieform $form, $value, $element)
{
    /*{{{*/
    if (!is_numeric($value) || floor($value) != $value) {
        return $form->i18n('rule', 'integer', 'integer', $element);
    }
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:16,代码来源:integer.php

示例7: 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

示例8: pieform_rule_minvalue

/**
 * Checks whether the given value is at least 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     $maxlength The value to check for
 * @return string            The error message, if the value is invalid.
 */
function pieform_rule_minvalue(Pieform $form, $value, $element, $minvalue)
{
    /*{{{*/
    if ($value != '' && intval($value) < $minvalue) {
        return sprintf($form->i18n('rule', 'minvalue', 'minvalue', $element), $minvalue);
    }
}
开发者ID:Br3nda,项目名称:mahara,代码行数:16,代码来源:minvalue.php

示例9: 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;
}
开发者ID:Br3nda,项目名称:mahara,代码行数:68,代码来源:expiry.php

示例10: 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']);
    }
}
开发者ID:Br3nda,项目名称:mahara,代码行数:20,代码来源:before.php

示例11: pieform_rule_validateoptions

/**
 * Makes sure that the submitted value is specified in the 'options' index of
 * the element. This prevents malicious people from doing things like
 * submitting values that aren't in a select box.
 *
 * @param Pieform $form      The form the rule is being applied to
 * @param string  $field     The field to check
 * @param string  $element   The element being checked
 * @return string            The error message, if the value is invalid.
 */
function pieform_rule_validateoptions(Pieform $form, $field, $element)
{
    /*{{{*/
    // Get the value into an array as a key if it's a scalar, since
    // the actual check involves array keys
    $field = (array) $field;
    $allowedvalues = array_keys($element['options']);
    foreach ($field as $key) {
        if (!in_array($key, $allowedvalues)) {
            return sprintf($form->i18n('rule', 'validateoptions', 'validateoptions', $element), $key);
        }
    }
}
开发者ID:Br3nda,项目名称:mahara,代码行数:23,代码来源:validateoptions.php

示例12: pieform_element_files

/**
 * Multiple file elements
 *
 * @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_files(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'];
    }
    $smarty->assign('name', $form->get_name() . '_' . $element['name']);
    $smarty->assign('title', $element['title']);
    $smarty->assign('addattachment', $form->i18n('element', 'files', 'addattachment', $element));
    if (isset($element['maxfilesize']) && is_int($element['maxfilesize'])) {
        $smarty->assign('maxfilesize', $element['maxfilesize']);
    }
    return $smarty->fetch('form/files.tpl');
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:24,代码来源:files.php

示例13: pieform_element_color

/**
 * Provides a javascript color selector for inputting a hex color value.
 *
 * General documentation about the JavaScript Color Picker (Chooser) is available at
 * http://jscolor.com/
 *
 * @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_color(Pieform $form, $element)
{
    $result = '';
    $name = Pieform::hsc($element['name']);
    $baseid = Pieform::hsc($form->get_name() . '_' . $element['name']);
    $value = Pieform::hsc($element['defaultvalue']);
    $transparent = !empty($element['options']['transparent']) && $element['options']['transparent'] == true;
    // Transparency optional control
    if ($transparent) {
        $optional = <<<EOF
        <script type="application/javascript">
            var {$baseid}_oldval = '';
            function {$baseid}_toggle(x) {
                if ( x.checked ) {
                    {$baseid}_oldval = \$('{$baseid}').value;
                    \$('{$baseid}').value   = '';
                    \$('{$baseid}').disabled   = true;
                }
                else {
                    \$('{$baseid}').value   = {$baseid}_oldval;
                    \$('{$baseid}').disabled   = false;
                }
            }
        </script>
EOF;
        $title = '';
        if (!empty($element['title'])) {
            $title = '<span class="accessible-hidden sr-only">' . $element['title'] . ':</span>';
        }
        $optional .= ' <input type="checkbox" ' . (isset($element['defaultvalue']) && $element['defaultvalue'] == 'transparent' ? 'checked="checked" ' : '') . 'name="' . $name . '_optional" id="' . $baseid . '_optional" onchange="' . $baseid . '_toggle(this)" ' . 'tabindex="' . Pieform::hsc($element['tabindex']) . '">';
        $optional .= ' <label for="' . $baseid . '_optional">' . $title . $form->i18n('element', 'color', 'transparent', $element) . '</label> ';
        $result .= $optional;
    }
    // Color Picker (Chooser)
    $result .= '<input type="text" name="' . $name . '_color" id="' . $baseid . '"' . ($transparent && (!isset($element['defaultvalue']) || $element['defaultvalue'] == 'transparent') ? ' disabled="disabled"' : '') . ($transparent ? ' class="color {hash:true,required:false}"' : ' class="color {hash:true}"') . ' value="' . ($value == 'transparent' ? '' : $value) . '">';
    return $result;
}
开发者ID:rboyatt,项目名称:mahara,代码行数:47,代码来源:color.php

示例14: auth_register_validate

/**
 * @todo add note: because the form select thing will eventually enforce
 * that the result for $values['institution'] was in the original lot,
 * and because that only allows authmethods that use 'internal' auth, we
 * can guarantee that the auth method is internal
 */
function auth_register_validate(Pieform $form, $values)
{
    global $SESSION;
    $registerterms = get_config('registerterms');
    $spamtrap = new_spam_trap(array(array('type' => 'name', 'value' => $values['firstname']), array('type' => 'name', 'value' => $values['lastname']), array('type' => 'email', 'value' => $values['email'])));
    if ($form->spam_error() || $spamtrap->is_spam()) {
        $msg = get_string('formerror');
        $emailcontact = get_config('emailcontact');
        if (!empty($emailcontact)) {
            $msg .= ' ' . get_string('formerroremail', 'mahara', $emailcontact, $emailcontact);
        }
        $form->set_error(null, $msg);
        return;
    }
    $institution = $values['institution'];
    safe_require('auth', 'internal');
    // First name and last name must contain at least one non whitespace
    // character, so that there's something to read
    if (!$form->get_error('firstname') && !preg_match('/\\S/', $values['firstname'])) {
        $form->set_error('firstname', $form->i18n('required'));
    }
    if (!$form->get_error('lastname') && !preg_match('/\\S/', $values['lastname'])) {
        $form->set_error('lastname', $form->i18n('required'));
    }
    // The e-mail address cannot already be in the system
    if (!$form->get_error('email') && (record_exists('usr', 'email', $values['email']) || record_exists('artefact_internal_profile_email', 'email', $values['email']))) {
        $form->set_error('email', get_string('emailalreadytaken', 'auth.internal'));
    }
    // If the user hasn't agreed to the terms and conditions, don't bother
    if ($registerterms && $values['tandc'] != 'yes') {
        $form->set_error('tandc', get_string('youmaynotregisterwithouttandc', 'auth.internal'), false);
    }
    $institution = get_record_sql('
        SELECT
            i.name, i.maxuseraccounts, i.registerallowed, COUNT(u.id) AS count
        FROM {institution} i
            LEFT OUTER JOIN {usr_institution} ui ON ui.institution = i.name
            LEFT OUTER JOIN {usr} u ON (ui.usr = u.id AND u.deleted = 0)
        WHERE
            i.name = ?
        GROUP BY
            i.name, i.maxuseraccounts, i.registerallowed', array($institution));
    if (!empty($institution->maxuseraccounts) && $institution->count >= $institution->maxuseraccounts) {
        // the institution is full so we need to alert the admins of the institution to this fact so
        // they can either increase the maxusers or turn off the public registration.
        require_once get_config('docroot') . 'lib/institution.php';
        $institutionobj = new Institution($institution->name);
        $institutionobj->send_admin_institution_is_full_message();
        $form->set_error('institution', get_string('institutionfull'));
    }
    if (!$institution || !$institution->registerallowed) {
        $form->set_error('institution', get_string('registrationnotallowed'));
    }
}
开发者ID:janaece,项目名称:globalclassroom4_clean-old,代码行数:60,代码来源:lib.php

示例15: pieform_element_bytes_get_value

/**
 * Gets the value of the expiry element and converts it to a time in seconds.
 *
 * @param Pieform $form    The form the element is attached to
 * @param array   $element The element to get the value for
 * @return int             The number of seconds until expiry
 */
function pieform_element_bytes_get_value(Pieform $form, $element)
{
    /*{{{*/
    $name = $element['name'];
    $global = $form->get_property('method') == 'get' ? $_GET : $_POST;
    $unit = $global[$name . '_units'];
    $allunits = pieform_element_bytes_get_bytes_units();
    $number = $global[$name];
    if (!is_numeric($number)) {
        $form->set_error($name, $form->i18n('element', 'bytes', 'invalidvalue', $element));
    }
    if (!in_array($unit, $allunits) || $number < 0) {
        return null;
    }
    return $number * pieform_element_bytes_in($unit);
}
开发者ID:Br3nda,项目名称:mahara,代码行数:23,代码来源:bytes.php


注:本文中的Pieform::i18n方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。