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


PHP Pieform::get_property方法代码示例

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


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

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

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

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

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

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

示例7: pieform_element_artefactchooser_get_value

function pieform_element_artefactchooser_get_value(Pieform $form, $element)
{
    $name = $element['name'];
    $global = $form->get_property('method') == 'get' ? $_GET : $_POST;
    if (isset($global[$name]) || isset($global["{$name}_onpage"])) {
        $value = isset($global[$name]) ? $global[$name] : array();
        if ($element['selectone']) {
            if (!$value) {
                return null;
            }
            if (preg_match('/^\\d+$/', $value)) {
                return intval($value);
            }
        } else {
            $onpage = isset($global["{$name}_onpage"]) ? $global["{$name}_onpage"] : array();
            $selected = is_array($value) ? array_map('intval', array_keys($value)) : array();
            $default = is_array($element['defaultvalue']) ? $element['defaultvalue'] : array();
            // 1) Start with what's currently available
            // 2) Remove everything on the page that was active when submitted
            // 3) Add in everything that was selected
            $value = array_merge(array_diff($default, $onpage), $selected);
            return array_map('intval', $value);
        }
        throw new PieformException("Invalid value for artefactchooser form element '{$name}' = '{$value}'");
    }
    if (isset($element['defaultvalue'])) {
        return $element['defaultvalue'];
    }
    return null;
}
开发者ID:rboyatt,项目名称:mahara,代码行数:30,代码来源:artefactchooser.php

示例8: 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";
}
开发者ID:rboyatt,项目名称:mahara,代码行数:32,代码来源:hidden.php

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

示例10: pieform_element_tags_get_value

function pieform_element_tags_get_value(Pieform $form, $element)
{
    $name = $element['name'];
    $global = $form->get_property('method') == 'get' ? $_GET : $_POST;
    if (!isset($global[$name])) {
        return null;
    }
    $value = preg_split("/\\s*,\\s*/", trim($global[$name]));
    $value = array_unique(array_filter($value, create_function('$v', 'return !empty($v);')));
    return $value;
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:11,代码来源:tags.php

示例11: pieform_element_image_get_value

function pieform_element_image_get_value(Pieform $form, $element)
{
    /*{{{*/
    if (isset($element['value'])) {
        return $element['value'];
    }
    $global = $form->get_property('method') == 'get' ? $_GET : $_POST;
    if ($form->is_submitted() && isset($global[$element['name'] . '_x'])) {
        return true;
    }
    return null;
}
开发者ID:Br3nda,项目名称:mahara,代码行数:12,代码来源:image.php

示例12: 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)
{
    /*{{{*/
    $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');
        // 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[] = $element['class'];
        }
        $result .= ' class="' . implode(' ', $classes) . '"';
    }
    $result .= ">\n";
    if (isset($element['legend'])) {
        $result .= '<legend';
        if (!empty($element['collapsible'])) {
            $id = substr(md5(microtime()), 0, 4);
            $result .= ' id="' . $id . '">';
            $result .= '<script type="text/javascript">';
            $result .= "var a = A({'href':'', 'tabindex':{$form->get_property('tabindex')}}, " . json_encode($element['legend']) . "); ";
            $result .= "connect(a, 'onclick', function(e) { toggleElementClass('collapsed', \$('{$id}').parentNode); e.stop(); });";
            $result .= "replaceChildNodes('{$id}', a);</script>";
        } else {
            $result .= '>' . Pieform::hsc($element['legend']);
        }
        $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;
}
开发者ID:Br3nda,项目名称:mahara,代码行数:57,代码来源:fieldset.php

示例13: pieform_element_password_get_value

function pieform_element_password_get_value(Pieform $form, $element)
{
    /*{{{*/
    if (isset($element['value'])) {
        return $element['value'];
    }
    $global = $form->get_property('method') == 'get' ? $_GET : $_POST;
    if ($form->is_submitted() && isset($global[$element['name']])) {
        return $global[$element['name']];
    }
    if (isset($element['defaultvalue'])) {
        return $element['defaultvalue'];
    }
    return null;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:15,代码来源:password.php

示例14: pieform_element_textarea_get_value

function pieform_element_textarea_get_value(Pieform $form, $element)
{
    /*{{{*/
    if (isset($element['value'])) {
        return $element['value'];
    }
    $global = $form->get_property('method') == 'get' ? $_GET : $_POST;
    if ($form->is_submitted() && isset($global[$element['name']])) {
        return str_replace("\r\n", "\n", $global[$element['name']]);
    }
    if (isset($element['defaultvalue'])) {
        return $element['defaultvalue'];
    }
    return '';
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:15,代码来源:textarea.php

示例15: pieform_element_emaillist_get_value

function pieform_element_emaillist_get_value(Pieform $form, $element)
{
    $name = $element['name'];
    $global = $form->get_property('method') == 'get' ? $_GET : $_POST;
    if (!isset($global[$name . '_valid']) || !is_array($global[$name . '_valid'])) {
        return null;
    }
    $value = array();
    $value['default'] = $global[$name . '_selected'];
    $value['validated'] = $global[$name . '_valid'];
    if (isset($global[$name . '_invalid']) && is_array($global[$name . '_invalid'])) {
        $value['unvalidated'] = $global[$name . '_invalid'];
    }
    return $value;
}
开发者ID:Br3nda,项目名称:mahara,代码行数:15,代码来源:emaillist.php


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