本文整理汇总了PHP中Pieform::info方法的典型用法代码示例。如果您正苦于以下问题:PHP Pieform::info方法的具体用法?PHP Pieform::info怎么用?PHP Pieform::info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pieform
的用法示例。
在下文中一共展示了Pieform::info方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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_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;
}
示例3: 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;
}
示例4: pieform_element_rank
/**
* Renders a drag & drop sortable list using Javascript and CSS.
* Useful for ranking answers to a question.
*
* Based on ToolMan DHTML Library. See: http://tool-man.org/examples/sorting.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_rank(Pieform $form, $element)
{
/*{{{*/
$optionsavailable = true;
if (!isset($element['options']) || !is_array($element['options']) || count($element['options']) < 1) {
$optionsavailable = false;
Pieform::info('Rank elements should have at least one option');
}
if (!empty($element['collapseifoneoption']) && isset($element['options']) && is_array($element['options']) && count($element['options']) == 1) {
foreach ($element['options'] as $key => $value) {
if (is_array($value)) {
$value = $value['value'];
}
$result = Pieform::hsc($value) . '<input type="hidden" name="' . Pieform::hsc($element['name']) . '" value="' . Pieform::hsc($key) . '">';
}
return $result;
}
$result = '<ul' . $form->element_attributes($element) . ">\n";
if (!$optionsavailable) {
$result .= "\t<li> </li>\n</ul>";
return $result;
}
// Values are serialized like: a|b|c|d
// so we need to unserialze them...
$values = explode('|', $form->get_value($element));
$optionselected = false;
foreach ($element['options'] as $key => $value) {
// Get the value to display/put in the value attribute
if (is_array($value)) {
if (!isset($value['value'])) {
Pieform::info('No value set for option "' . $key . '" of rank element "' . $element['name'] . '"');
$value = '';
} else {
$value = $value['value'];
}
}
$result .= "\t<li itemID=\"" . Pieform::hsc($key) . "\">" . Pieform::hsc($value) . "</li>\n";
}
if (!$optionselected && !is_array($values) && $values !== null) {
Pieform::info('Invalid value for rank "' . $element['name'] . '"');
}
$result .= '</ul>';
return $result;
}
示例5: pieform_is_collapsible
/**
* Check if the fieldset is supposed to be collapsible
* @param array $element The element to render
* @return boolean If the fieldset is collapsible
*/
function pieform_is_collapsible($element)
{
if (empty($element['collapsible']) || !$element['collapsible']) {
return false;
}
if (!isset($element['legend']) || $element['legend'] === '') {
Pieform::info('Collapsible fieldsets should have a legend so they can be toggled');
}
return true;
}
示例6: pieform_element_select_get_value
function pieform_element_select_get_value(Pieform $form, $element)
{
if (empty($element['multiple'])) {
$global = $form->get_property('method') == 'get' ? $_GET : $_POST;
if (isset($element['value'])) {
$values = (array) $element['value'];
} else {
if ($form->is_submitted() && isset($global[$element['name']])) {
$values = (array) $global[$element['name']];
if (!empty($element['allowother']) and $values[0] === 'other') {
if (isset($global[$element['name'] . '_other'])) {
$values = (array) $global[$element['name'] . '_other'];
} else {
$values = (array) $element['defaultvalue'];
}
}
} else {
if (isset($element['defaultvalue'])) {
$values = (array) $element['defaultvalue'];
} else {
$values = array(null);
}
}
}
if (count($values) != 1) {
Pieform::info('The select element "' . $element['name'] . '" has ' . 'more than one value, but has not been declared multiple');
}
return $values[0];
} else {
$global = $form->get_property('method') == 'get' ? $_GET : $_POST;
if (isset($element['value'])) {
$values = (array) $element['value'];
} else {
if ($form->is_submitted() && isset($global[$element['name']])) {
$values = (array) $global[$element['name']];
} else {
if (!$form->is_submitted() && isset($element['defaultvalue'])) {
$values = (array) $element['defaultvalue'];
} else {
$values = array();
}
}
}
}
return $values;
}
示例7: 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";
$classes = array('pieform-fieldset');
if (!empty($element['class'])) {
$classes[] = Pieform::hsc($element['class']);
}
if (!empty($element['collapsible'])) {
if (!isset($element['legend']) || $element['legend'] === '') {
Pieform::info('Collapsible fieldsets should have a legend so they can be toggled');
}
$classes[] = 'collapsible';
$formname = $form->get_name();
if (!isset($_PIEFORM_FIELDSETS['forms'][$formname])) {
$_PIEFORM_FIELDSETS['forms'][$formname] = array('formname' => $formname);
}
if (isset($element['name'])) {
$openparam = $formname . '_' . $element['name'] . '_open';
}
// 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 && (!isset($element['name']) || param_alphanumext('fs', null) != $element['name'] && !param_boolean($openparam, false))) {
$classes[] = 'collapsed';
}
}
$result .= ' class="' . implode(' ', $classes) . '"';
$result .= ">\n";
if (isset($element['legend'])) {
$result .= '<legend><h4>';
if (!empty($element['collapsible'])) {
$result .= '<a href="">' . Pieform::hsc($element['legend']) . '</a>';
if (isset($openparam)) {
$result .= '<input type="hidden" name="' . hsc($openparam) . '" class="open-fieldset-input" ' . 'value="' . intval(!in_array('collapsed', $classes)) . '">';
}
} 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 .= "</h4></legend>\n";
}
if (!empty($element['renderer']) && $element['renderer'] == 'multicolumnfieldsettable') {
$result .= _render_elements_as_multicolumn($form, $element);
} else {
foreach ($element['elements'] as $subname => $subelement) {
if ($subelement['type'] == 'hidden') {
throw new PieformException("You cannot put hidden elements in fieldsets");
}
$result .= "\t" . pieform_render_element($form, $subelement);
}
}
$result .= "</fieldset>\n";
return $result;
}
示例8: pieform_element_checks
/**
* Based on Nigel McNie's select Pieform element.
*
* Renders a group of checkboxes for multiple answer type questions in surveys.
*
* @todo Currently, putting a junk defaultvalue/value for a multiple select
* does not trigger any kind of error, it should perhaps trigger a
* Pieform::info
*
* @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_checks(Pieform $form, $element)
{
/*{{{*/
$element['name'] .= '[]';
$result = '';
$separator = "\n";
if (isset($element['separator'])) {
$separator = $element['separator'] . $separator;
}
$optionsavailable = true;
if (!isset($element['options']) || !is_array($element['options']) || count($element['options']) < 1) {
$optionsavailable = false;
Pieform::info('Group of checkboxes should have at least one checkbox');
}
if (!empty($element['collapseifoneoption']) && isset($element['options']) && is_array($element['options']) && count($element['options']) == 1) {
foreach ($element['options'] as $key => $value) {
if (is_array($value)) {
$value = $value['value'];
}
$result = Pieform::hsc($value) . '<input type="hidden" name="' . Pieform::hsc($element['name']) . '" value="' . Pieform::hsc($key) . '">';
}
return $result;
}
$values = $form->get_value($element);
$optionselected = false;
foreach ($element['options'] as $key => $value) {
// Select the element if it's in the values or if there are no values
// and this is the first option
if (!is_array($values) && $key == $values || is_array($values) && (array_key_exists($key, $values) || isset($values[0]) && $values[0] === null && !$optionselected)) {
$selected = ' checked="checked"';
$optionselected = true;
} else {
$selected = '';
}
// Disable the option if necessary
if (is_array($value) && !empty($value['disabled'])) {
$disabled = ' disabled="disabled"';
} else {
$disabled = '';
}
// Add a label if necessary. None of the common browsers actually render
// this properly at the moment, but that may change in future.
if (is_array($value) && isset($value['label'])) {
$label = ' label="' . Pieform::hsc($value['label']) . '"';
} else {
$label = '';
}
// Get the value to display/put in the value attribute
if (is_array($value)) {
if (!isset($value['value'])) {
Pieform::info('No value set for option "' . $key . '" of checkboxes element "' . $element['name'] . '"');
$value = '';
} else {
$value = $value['value'];
}
}
$result .= "<input type=\"checkbox\" name=\"" . $element['id'] . "[" . Pieform::hsc($key) . "]\"{$selected}{$label}{$disabled}> " . Pieform::hsc($value) . "\n";
$result .= $separator;
}
if (!$optionselected && !is_array($values) && $values !== null) {
Pieform::info('Invalid value for checkboxes "' . $element['name'] . '"');
}
$result = substr($result, 0, -strlen($separator));
return $result;
}