本文整理汇总了PHP中data::rearrangeArray方法的典型用法代码示例。如果您正苦于以下问题:PHP data::rearrangeArray方法的具体用法?PHP data::rearrangeArray怎么用?PHP data::rearrangeArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类data
的用法示例。
在下文中一共展示了data::rearrangeArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCode
/**
* Renders HTML code of form.
*
* @return string generated HTML code
*/
public function getCode()
{
$method = $this->usePost ? 'post' : 'get';
$action = is_null($this->processorUrl) ? application::current()->selfUrl($this->usePost ? array() : false) : $this->processorUrl;
$mime = $this->maxFileSize > 0 ? ' enctype="multipart/form-data"' : '';
$size = $this->maxFileSize > 0 ? '<input type="hidden" name="MAX_FILE_SIZE" value="' . $this->maxFileSize . "\"/>\n\t" : '';
$name = html::idname($this->name);
$idName = $this->idName();
$idValue = $this->idValue();
$labelClass = 'without-labels';
// compile code of form's rows
$template = self::getRowTemplate();
$rows = array_filter($this->rows, function ($row) {
return !!count($row);
});
if ($this->sortingOrder) {
data::rearrangeArray($rows, $this->sortingOrder, true);
}
$rows = array_map(function ($row) use($template, &$labelClass) {
if (@$row['label']) {
$labelClass = 'with-labels';
}
$label = view::wrapNotEmpty(@$row['label'], '', '');
$code = view::wrapNotEmpty(@$row['htmlCode'], '', '');
$hint = view::wrapNotEmpty(@$row['hint'], '<span class="hint">', "</span>\n");
$error = view::wrapNotEmpty(@$row['error'], '<span class="error">', "</span>\n");
$mandatory = @$row['mandatory'] ? config::get('html.form.mandatory', '<span class="mandatory">*</span>') : '';
if (trim($label) !== '') {
$label = sprintf(config::get('html.form.label', '%s%s:'), $label, $mandatory);
}
return sprintf($template, trim('form-row-name-' . @$row['name'] . ' ' . @$row['class']), $label, $code, $error, $hint);
}, $rows);
// embed compiled rows in form's custom content
$code = str_replace('%%%%ROWS_STACK%%%%', implode('', $rows), $this->code);
$hidden = $this->enableXsrfMode ? "<input type=\"hidden\" name=\"{$idName}\" value=\"{$idValue}\"/>" : '';
foreach ($this->hidden as $key => $value) {
if (is_array($value)) {
foreach ($value as $subName => $subValue) {
$hidden .= '<input type="hidden" name="' . html::inAttribute($key) . '[' . html::inAttribute($subName) . ']" value="' . html::inAttribute($subValue) . '"/>';
}
} else {
if ($value !== null) {
$hidden .= '<input type="hidden" name="' . html::inAttribute($key) . '" value="' . html::inAttribute($value) . '"/>';
}
}
}
$class = ' class="' . html::inAttribute(trim($this->class . ' ' . $labelClass)) . '"';
return <<<EOT
<form action="{$action}" method="{$method}"{$mime} id="{$name}"{$class}>
\t{$size}{$hidden}
{$code}
</form>
EOT;
}