/** * 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; }
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; }
</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) {
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}; } }
* 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>
*****************************************************************************************/ 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');