本文整理匯總了PHP中ArrayUtil::asorti方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArrayUtil::asorti方法的具體用法?PHP ArrayUtil::asorti怎麽用?PHP ArrayUtil::asorti使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ArrayUtil
的用法示例。
在下文中一共展示了ArrayUtil::asorti方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _getFieldsForDropdown
/**
* Helper method for {@link getFieldsForDropdown}
* @param string|null $parentAttribute Can be used to prefix names of attributes
* @param bool $condList If true, returned array's values will include, in addition to the
* field label, field data required by the X2ConditionList widget.
* @param bool $sorted if true, results will be sorted by field name
* @param function|null $filterFn if set, will be used to filter results
* @param string $separator used to separate parent attribute from field name
* @return array
*/
private function _getFieldsForDropdown($parentAttribute = null, $condList = false, $sorted = true, $filterFn, $separator = '.')
{
$fieldModels = $this->getFields(false, $filterFn, Fields::READ_PERMISSION);
$permissions = $this->getFieldPermissions();
$fields = array();
foreach ($fieldModels as &$field) {
if ($field->isVirtual) {
continue;
}
$fieldName = $field->fieldName;
if ($this instanceof Actions && $fieldName === 'actionDescription') {
$fieldName = 'ActionText.text';
}
$attributes = $field->getAttributes();
if ($parentAttribute !== null) {
$fieldName = $parentAttribute . $separator . $fieldName;
}
if ($field->type === 'date' || $field->type === 'dateTime') {
$dateFns = array('year', 'month', 'day');
if ($field->type === 'dateTime') {
$dateFns = array_merge($dateFns, array('hour', 'minute', 'second'));
}
foreach ($dateFns as $fn) {
$name = $fn . '(' . $fieldName . ')';
$label = $this->getAttributeLabel($fieldName) . ' (' . Yii::t('app', $fn) . ')';
if ($condList) {
$fields[] = X2ConditionList::listOption(array_merge($attributes, array('attributeLabel' => $label, 'type' => 'varchar')), $name);
} else {
$fields[$name] = $label;
}
}
}
if ($condList) {
$fields[] = X2ConditionList::listOption($attributes, $fieldName);
} else {
$fields[$fieldName] = $this->getAttributeLabel($fieldName);
}
}
if ($sorted) {
if ($condList) {
usort($fields, function ($a, $b) {
return strcasecmp($a['label'], $b['label']);
});
} else {
$fields = ArrayUtil::asorti($fields);
}
}
return $fields;
}
示例2: getHiddenProfileWidgetMenu
public function getHiddenProfileWidgetMenu()
{
$profileWidgetLayout = $this->profileWidgetLayout;
$hiddenProfileWidgetsMenu = '';
$hiddenProfile = false;
$hiddenWidgets = array();
foreach ($profileWidgetLayout as $name => $widgetSettings) {
$hidden = $widgetSettings['hidden'];
$softDeleted = $widgetSettings['softDeleted'];
if ($hidden && !$softDeleted) {
$hiddenWidgets[$name] = Yii::t('app', $widgetSettings['label']);
$hiddenProfile = true;
}
}
$hiddenWidgets = ArrayUtil::asorti($hiddenWidgets);
foreach ($hiddenWidgets as $name => $label) {
$hiddenProfileWidgetsMenu .= '<li>
<span class="x2-hidden-widgets-menu-item profile-widget" id="' . $name . '">' . CHtml::encode($label) . '</span>
</li>';
}
$menu = '<div id="x2-hidden-profile-widgets-menu-container" style="display:none;">';
$menu .= '<ul id="x2-hidden-profile-widgets-menu" class="x2-hidden-widgets-menu-section">';
$menu .= $hiddenProfileWidgetsMenu;
$menu .= '<li><span class="no-hidden-profile-widgets-text" ' . ($hiddenProfile ? 'style="display:none;"' : '') . '>' . Yii::t('app', 'No Hidden Widgets') . '</span></li>';
$menu .= '</ul>';
$menu .= '</div>';
return $menu;
}
示例3: array
</div>
<div class="row">
<?php
echo $form->labelEx($model, 'type');
?>
<?php
if (!$new && !$model->custom) {
echo '<span style="color:red">' . Yii::t('admin', 'Changing the type of a default field is strongly discouraged.') . ' ' . Yii::t('admin', 'It may result in data loss or irregular application behavior.') . '</span><br>';
}
if (!$new && $model->custom && $changedType) {
echo '<span style="color:red">' . Yii::t('admin', 'Changing the type of a field may result in alteration of data. For ' . 'example, changing a field from type "{text}" to type "{varchar}" ' . 'shortens the field\'s width, potentially truncating field values.', array('{text}' => Yii::t('app', 'Multiple Line Text Area'), '{varchar}' => Yii::t('app', 'Single Line Text Area'))) . '</span><br>';
}
$fieldTypes = Fields::getFieldTypes('title');
echo $form->dropDownList($model, 'type', ArrayUtil::asorti($fieldTypes), array('id' => 'fieldType', 'class' => $new ? 'new' : 'existing'));
?>
<?php
echo $form->error($model, 'type');
?>
</div>
<div class="row">
<?php
// Render a dropdown menu and any other fields
// for the "linkType" field
$genericLabel = CHtml::label(Yii::t('app', 'Type'), CHtml::resolveName($model, $assignTypeName));
switch ($model->type) {
case "dropdown":
$dropdowns = Dropdowns::model()->findAll();
$arr = array();
foreach ($dropdowns as $dropdown) {
示例4: renderAttribute
public function renderAttribute($attr)
{
switch ($attr) {
case 'isDefaultFor':
$isDefaultFor = $this->getIsDefaultFor();
if (in_array(self::DEFAULT_ALL_MODULES, $isDefaultFor)) {
return Yii::t('workflow', 'All modules');
} elseif ($isDefaultFor) {
$qpg = new QueryParamGenerator();
$moduleNames = Yii::app()->db->createCommand()->select('name')->from('x2_modules')->where('id in ' . $qpg->bindArray($isDefaultFor, true))->queryColumn($qpg->getParams());
return implode(', ', ArrayUtil::asorti(array_map(function ($name) {
return Modules::displayName(true, $name);
}, $moduleNames)));
}
break;
default:
return $this->{$attr};
}
}
示例5: array
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by X2Engine".
*****************************************************************************************/
?>
<div class="page-title rounded-top"><h2><?php
echo Yii::t('admin', 'Edit Dropdown');
?>
</h2></div>
<div class="form">
<?php
$list = Dropdowns::model()->findAll();
$names = array();
foreach ($list as $dropdown) {
$names[$dropdown->id] = $dropdown->name;
}
$names = ArrayUtil::asorti($names);
$form = $this->beginWidget('CActiveForm', array('id' => 'edit-dropdown-form', 'enableAjaxValidation' => false, 'action' => 'editDropdown'));
?>
<em><?php
echo Yii::t('app', 'Fields with <span class="required">*</span> are required.');
?>
</em><br />
<div class="row">
<?php
echo $form->labelEx($model, 'name');
echo $form->dropDownList($model, 'id', $names, array('empty' => Yii::t('admin', 'Select a dropdown'), 'id' => 'edit-dropdown-dropdown-selector', 'ajax' => array('type' => 'POST', 'url' => CController::createUrl('/admin/getDropdown'), 'update' => '#options')));
echo $form->error($model, 'name');
?>
</div>
示例6: array
*****************************************************************************************/
Yii::app()->clientScript->registerPackage('emailEditor');
Yii::app()->clientScript->registerCssFile($this->module->assetsUrl . '/css/campaignForm.css');
$insertableAttributes = array();
foreach (X2Model::model('Contacts')->attributeLabels() as $fieldName => $label) {
$insertableAttributes[$label] = '{' . $fieldName . '}';
}
$insertableAttributes[Yii::t('profile', 'Signature')] = '{signature}';
$contacts = Yii::t('contacts', '{module} Attributes', array('{module}' => Modules::displayName(false, "Contacts")));
$JSParams = CJSON::encode(array('insertableAttributes' => array($contacts => $insertableAttributes)));
Yii::app()->clientScript->registerScriptFile($this->module->assetsUrl . '/js/CampaignForm.js');
Yii::app()->clientScript->registerScript('editorSetup', "\n x2.CampaignForm ({$JSParams});\n", CClientScript::POS_READY);
$contactLists = CHtml::listData(Campaign::getValidContactLists(), 'id', 'name');
if ($model->list && !in_array($model->list->id, array_keys($contactLists))) {
$contactLists[$model->list->id] = $model->list->name;
$contactLists = ArrayUtil::asorti($contactLists);
}
$templates = CHtml::listData(Docs::getEmailTemplates2('email', 'Contacts'), 'id', 'name');
$templates[0] = Yii::t('marketing', "Custom");
$form = $this->beginWidget('CActiveForm', array('id' => 'campaign-form', 'enableAjaxValidation' => false));
?>
<div id='top-container'>
<div id='campaign-basic-form'>
<div class='row'>
<label><?php
echo Yii::t('marketing', 'Campaign Name:');
?>
</label>
<?php
echo $model->renderInput('name');