本文整理汇总了PHP中X2Model::getModelTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP X2Model::getModelTitle方法的具体用法?PHP X2Model::getModelTitle怎么用?PHP X2Model::getModelTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类X2Model
的用法示例。
在下文中一共展示了X2Model::getModelTitle方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getJSClassParams
public function getJSClassParams()
{
if (!isset($this->_JSClassParams)) {
$title = X2Model::getModelTitle(get_class($this->model), true);
$targetClass = $this->targetClass;
$behavior = $this->model->asa('X2ModelConversionBehavior');
$conversionFailed = $behavior->conversionFailed && $behavior->errorModel !== null && get_class($behavior->errorModel) === $this->targetClass;
$this->_JSClassParams = array_merge(parent::getJSClassParams(), array('buttonSelector' => $this->buttonSelector, 'translations' => array('conversionError' => Yii::t('app', '{model} conversion failed.', array('{model}' => $title)), 'conversionWarning' => Yii::t('app', '{model} Conversion Warning', array('{model}' => $title)), 'convertAnyway' => Yii::t('app', 'Convert Anyway'), 'Cancel' => Yii::t('app', 'Cancel')), 'targetClass' => $this->targetClass, 'modelId' => $this->model->id, 'conversionFailed' => $conversionFailed, 'conversionIncompatibilityWarnings' => $this->model->getConversionIncompatibilityWarnings($this->targetClass), 'errorSummary' => $conversionFailed ? "<div class='form'>" . CHtml::errorSummary($this->model->asa('X2ModelConversionBehavior')->errorModel, Yii::t('app', '{model} conversion failed.', array('{model}' => $title))) . "</div>" : ''));
}
return $this->_JSClassParams;
}
示例2: actionGetRole
/**
* Echo out a series of inputs for a role editor page.
*
* This method is called via AJAX from the "Edit Role" portion of the "Manage Roles"
* page. Upon selection of a role in the dropdown on that page, this method
* finds all relevant information about the role and echoes it back as a form
* to allow for editing of the role.
*/
public function actionGetRole()
{
$output = "";
$roleInput = FilterUtil::filterArrayInput($_POST, 'Roles');
if (!empty($roleInput)) {
$roleName = isset($roleInput['name']) ? filter_var($roleInput['name'], FILTER_SANITIZE_STRING) : '';
$role = Roles::model()->findByAttributes(array('name' => $roleName));
if (isset($role)) {
$usernames = Yii::app()->db->createCommand()->select('a.username')->from('x2_users a')->join('x2_role_to_user b', 'a.id=b.userId')->where('b.roleId=:roleId AND b.type="user"', array(':roleId' => $role->id))->queryColumn();
$groupIds = Yii::app()->db->createCommand()->select('a.id')->from('x2_groups a')->join('x2_role_to_user b', 'a.id=b.userId')->where('b.roleId=:roleId AND b.type="group"', array(':roleId' => $role->id))->queryColumn();
$selected = array_merge($usernames, $groupIds);
$allUsers = X2Model::getAssignmentOptions(false, true, false);
unset($allUsers['admin']);
$sliderId = 'editTimeoutSlider';
$textfieldId = 'editTimeout';
if (isset($_GET['mode']) && in_array($_GET['mode'], array('edit', 'exception'))) {
// Handle whether this was called from editRole or roleException, they
// need different IDs to work on the same page.
$sliderId .= "-" . $_GET['mode'];
$textfieldId .= "-" . $_GET['mode'];
}
$timeoutSet = $role->timeout !== null;
$output .= "\n <div class='row' id='set-session-timeout-row'>\n <input id='set-session-timeout' type='checkbox' class='left' " . ($timeoutSet ? 'checked="checked"' : '') . ">\n <label>" . Yii::t('admin', 'Enable Session Timeout') . "</label>\n </div>\n ";
$output .= "<div id='timeout-row' class='row' " . ($timeoutSet ? '' : "style='display: none;'") . ">";
$output .= Yii::t('admin', 'Set role session expiration time (in minutes).');
$output .= "<br />";
$output .= $this->widget('zii.widgets.jui.CJuiSlider', array('value' => $role->timeout / 60, 'options' => array('min' => 5, 'max' => 1440, 'step' => 5, 'change' => "js:function(event,ui) {\n \$('#" . $textfieldId . "').val(ui.value);\n \$('#save-button').addClass('highlight');\n }", 'slide' => "js:function(event,ui) {\n \$('#" . $textfieldId . "').val(ui.value);\n }"), 'htmlOptions' => array('style' => 'width:340px;margin:10px 9px;', 'id' => $sliderId)), true);
$output .= CHtml::activeTextField($role, 'timeout', array('id' => $textfieldId, 'disabled' => $role->timeout !== null ? '' : 'disabled'));
$output .= "</div>";
Yii::app()->clientScript->registerScript('timeoutScript', "\n \$('#set-session-timeout').change (function () {\n if (\$(this).is (':checked')) {\n \$('#timeout-row').slideDown ();\n \$('#" . $textfieldId . "').removeAttr ('disabled');\n } else {\n \$('#timeout-row').slideUp ();\n \$('#" . $textfieldId . "').attr ('disabled', 'disabled');\n }\n });\n \$('#" . $textfieldId . "').val( \$('#" . $sliderId . "').slider('value') );\n ", CClientScript::POS_READY);
$output .= "<script>";
$output .= Yii::app()->clientScript->echoScripts(true);
$output .= "</script>";
$output .= "<div id='users'><label>Users</label>";
$output .= CHtml::dropDownList('users[]', $selected, $allUsers, array('class' => 'multiselect', 'multiple' => 'multiple', 'size' => 8));
$output .= "</div>";
$fields = Fields::getFieldsOfModelsWithFieldLevelPermissions();
$fieldIds = array_flip(array_map(function ($field) {
return $field->id;
}, $fields));
$viewSelected = array();
$editSelected = array();
$fieldUnselected = array();
$fieldPerms = RoleToPermission::model()->findAllByAttributes(array('roleId' => $role->id));
foreach ($fieldPerms as $perm) {
if (!isset($fieldIds[$perm->fieldId])) {
continue;
}
if ($perm->permission == 2) {
$viewSelected[] = $perm->fieldId;
$editSelected[] = $perm->fieldId;
} else {
if ($perm->permission == 1) {
$viewSelected[] = $perm->fieldId;
}
}
}
foreach ($fields as $field) {
$fieldUnselected[$field->id] = X2Model::getModelTitle($field->modelName) . " - " . $field->attributeLabel;
}
assert(count($fieldUnselected) === count(array_unique(array_keys($fieldUnselected))));
$output .= "<br /><label>View Permissions</label>";
$output .= CHtml::dropDownList('viewPermissions[]', $viewSelected, $fieldUnselected, array('class' => 'multiselect', 'multiple' => 'multiple', 'size' => 8, 'id' => 'edit-role-field-view-permissions'));
$output .= "<br /><label>Edit Permissions</label>";
$output .= CHtml::dropDownList('editPermissions[]', $editSelected, $fieldUnselected, array('class' => 'multiselect', 'multiple' => 'multiple', 'size' => 8, 'id' => 'edit-role-field-edit-permissions'));
}
}
echo $output;
}
示例3: array
* You can contact X2Engine, Inc. P.O. Box 66752, Scotts Valley,
* California 95067, USA. or at email address contact@x2engine.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* X2Engine" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by X2Engine".
*****************************************************************************************/
?>
<div class="page-title"><h2><?php
echo Yii::t('admin', 'Import {model} from Template', array('{model}' => empty($model) ? "" : X2Model::getModelTitle($model)));
?>
</h2></div>
<div class="form">
<?php
if (!empty($errors)) {
echo "<span class='error' style='font-weight:bold'>" . Yii::t('admin', $errors) . "</span>";
unset($_SESSION['errors']);
}
?>
<?php
if (!empty($model)) {
?>
<div id="info-box" style="width:600px;">
示例4: getRelatedModelName
public function getRelatedModelName()
{
if (!isset($this->_relatedModelType)) {
if (!isset($this->relatedModel)) {
return $this->_relatedModelType = null;
}
$title = Yii::app()->db->createCommand()->select("title")->from("x2_modules")->where("name = :name AND custom = 1")->bindValues(array(":name" => get_class($this->relatedModel)))->queryScalar();
if ($title) {
$this->_relatedModelType = $title;
} else {
$this->_relatedModelType = X2Model::getModelTitle(get_class($this->relatedModel));
}
}
return $this->_relatedModelType;
}
示例5: array
}
?>
</div>
<div id="prep-status-box">
</div>
<br />
<div id="status-box">
</div>
<div id="failures-box">
<div id="continue-box" style="display:none;">
<br />
<?php
echo CHtml::link(Yii::t('admin', 'Import more {records}', array('{records}' => X2Model::getModelTitle($model))), 'importModels?model=' . $model, array('class' => 'x2-button'));
echo CHtml::link(Yii::t('admin', 'Import to another module'), 'importModels', array('class' => 'x2-button'));
echo CHtml::link(Yii::t('admin', 'Rollback Import'), array('rollbackImport', 'importId' => $_SESSION['importId']), array('class' => 'x2-button', 'id' => 'revert-btn', 'style' => 'display:none;'));
?>
</div>
<script>
$(function() {
// Hide the import map box if a mapping was uploaded
if (<?php
echo $preselectedMap ? 'true' : 'false';
?>
)
$('#super-import-map-box').hide();
});
var attributeLabels = <?php
示例6: getModelTypes
/**
* Returns all possible models, either as a regular array or associative
* (key and value are the same)
* @param boolean $assoc
* @return array
*/
public static function getModelTypes($assoc = false)
{
$modelTypes = Yii::app()->db->createCommand()->selectDistinct('modelName')->from('x2_fields')->where('modelName!="Calendar"')->order('modelName ASC')->queryColumn();
if ($assoc === true) {
return array_combine($modelTypes, array_map(function ($term) {
return Yii::t('app', X2Model::getModelTitle($term));
}, $modelTypes));
}
$modelTypes = array_map(function ($term) {
return Yii::t('app', $term);
}, $modelTypes);
return $modelTypes;
}
示例7: actionGetRole
/**
* Echo out a series of inputs for a role editor page.
*
* This method is called via AJAX from the "Edit Role" portion of the "Manage Roles"
* page. Upon selection of a role in the dropdown on that page, this method
* finds all relevant information about the role and echoes it back as a form
* to allow for editing of the role.
*/
public function actionGetRole()
{
if (isset($_POST['Roles'])) {
$id = $_POST['Roles']['name'];
$role = Roles::model()->findByAttributes(array('name' => $id));
if (!$role) {
echo "";
exit;
}
$id = $role->id;
$roles = RoleToUser::model()->findAllByAttributes(array('roleId' => $id));
$users = array();
foreach ($roles as $link) {
if ($link->type == 'user') {
$user = User::model()->findByPk($link->userId);
if (isset($user)) {
$users[] = $user->username;
}
} else {
$group = Groups::model()->findByPk($link->userId);
if (isset($group)) {
$users[] = $group->id;
}
}
/* end x2temp */
}
$allUsers = User::model()->findAll('status="1"');
$selected = array();
$unselected = array();
foreach ($users as $user) {
$selected[] = $user;
}
foreach ($allUsers as $user) {
$unselected[CHtml::encode($user->username)] = CHtml::encode($user->firstName . " " . $user->lastName);
}
/* x2temp */
$groups = Groups::model()->findAll();
foreach ($groups as $group) {
$unselected[$group->id] = CHtml::encode($group->name);
}
/* end x2temp */
unset($unselected['admin']);
$sliderId = 'editTimeoutSlider';
$textfieldId = 'editTimeout';
if (isset($_GET['mode']) && in_array($_GET['mode'], array('edit', 'exception'))) {
// Handle whether this was called from editRole or roleException, they
// need different IDs to work on the same page.
$sliderId .= "-" . $_GET['mode'];
$textfieldId .= "-" . $_GET['mode'];
}
$timeoutSet = $role->timeout !== null;
echo "\n <div class='row' id='set-session-timeout-row'>\n <input id='set-session-timeout' type='checkbox' class='left' " . ($timeoutSet ? 'checked="checked"' : '') . ">\n <label>" . Yii::t('admin', 'Enable Session Timeout') . "</label>\n </div>\n ";
echo "<div id='timeout-row' class='row' " . ($timeoutSet ? '' : "style='display: none;'") . ">";
echo Yii::t('admin', 'Set role session expiration time (in minutes).');
echo "<br />";
$this->widget('zii.widgets.jui.CJuiSlider', array('value' => $role->timeout / 60, 'options' => array('min' => 5, 'max' => 1440, 'step' => 5, 'change' => "js:function(event,ui) {\n \$('#" . $textfieldId . "').val(ui.value);\n \$('#save-button').addClass('highlight');\n }", 'slide' => "js:function(event,ui) {\n \$('#" . $textfieldId . "').val(ui.value);\n }"), 'htmlOptions' => array('style' => 'width:340px;margin:10px 9px;', 'id' => $sliderId)));
echo CHtml::activeTextField($role, 'timeout', array('id' => $textfieldId, 'disabled' => $role->timeout !== null ? '' : 'disabled'));
echo "</div>";
Yii::app()->clientScript->registerScript('timeoutScript', "\n \$('#set-session-timeout').change (function () {\n if (\$(this).is (':checked')) {\n \$('#timeout-row').slideDown ();\n \$('#" . $textfieldId . "').removeAttr ('disabled');\n } else {\n \$('#timeout-row').slideUp ();\n \$('#" . $textfieldId . "').attr ('disabled', 'disabled');\n }\n });\n \$('#" . $textfieldId . "').val( \$('#" . $sliderId . "').slider('value') );\n ", CClientScript::POS_READY);
echo "<script>";
Yii::app()->clientScript->echoScripts();
echo "</script>";
echo "<div id='users'><label>Users</label>";
echo CHtml::dropDownList('users[]', $selected, $unselected, array('class' => 'multiselect', 'multiple' => 'multiple', 'size' => 8));
echo "</div>";
$fields = Fields::model()->findAllBySql("SELECT * FROM x2_fields ORDER BY modelName ASC");
$viewSelected = array();
$editSelected = array();
$fieldUnselected = array();
$fieldPerms = RoleToPermission::model()->findAllByAttributes(array('roleId' => $role->id));
foreach ($fieldPerms as $perm) {
if ($perm->permission == 2) {
$viewSelected[] = $perm->fieldId;
$editSelected[] = $perm->fieldId;
} else {
if ($perm->permission == 1) {
$viewSelected[] = $perm->fieldId;
}
}
}
foreach ($fields as $field) {
$fieldUnselected[$field->id] = X2Model::getModelTitle($field->modelName) . " - " . $field->attributeLabel;
}
echo "<br /><label>View Permissions</label>";
echo CHtml::dropDownList('viewPermissions[]', $viewSelected, $fieldUnselected, array('class' => 'multiselect', 'multiple' => 'multiple', 'size' => 8));
echo "<br /><label>Edit Permissions</label>";
echo CHtml::dropDownList('editPermissions[]', $editSelected, $fieldUnselected, array('class' => 'multiselect', 'multiple' => 'multiple', 'size' => 8));
}
}
示例8: array
//Yii::app()->clientScript->registerCssFile(Yii::app()->getBaseUrl().'/js/multiselect/css/ui.multiselect.css','screen, projection');
//Yii::app()->clientScript->registerCss('multiselectCss',"
//.multiselect {
// width: 460px;
// height: 200px;
//}
//#switcher {
// margin-top: 20px;
//}
//",'screen, projection');
Yii::app()->clientScript->registerScript('renderMultiSelect', "\n\$(document).ready(function() {\n\t \$('.multiselect').multiselect();\n});\n", CClientScript::POS_HEAD);
$selected = array();
$unselected = array();
$fields = Fields::model()->findAllBySql("SELECT * FROM x2_fields ORDER BY modelName ASC");
foreach ($fields as $field) {
$unselected[$field->id] = X2Model::getModelTitle($field->modelName) . " - " . $field->attributeLabel;
}
$users = User::getNames();
unset($users['']);
unset($users['Anyone']);
unset($users['admin']);
$users = array_map(array('CHtml', 'encode'), $users);
/* x2temp */
$groups = Groups::model()->findAll();
foreach ($groups as $group) {
$users[$group->id] = CHtml::encode($group->name);
}
/* end x2temp */
?>
<div class="page-title rounded-top"><h2><?php
echo Yii::t('admin', 'Add Role');
示例9: run
public function run()
{
$this->registerPackages();
$this->instantiateJSClass();
$this->render('application.components.views._x2ModelConversionWidget', array('modelTitle' => lcfirst(X2Model::getModelTitle(get_class($this->model), true)), 'targetModelTitle' => lcfirst(X2Model::getModelTitle($this->targetClass, true))));
}
示例10: errorSummary
/**
* Renders error summary containing compatibility warnings
* @return string
*/
public function errorSummary($targetModelClass, $convertMultiple = false)
{
$sourceModelClass = get_class($this->owner);
$sourceModelTitle = X2Model::getModelTitle($sourceModelClass, true);
$targetModelTitle = X2Model::getModelTitle($targetModelClass, true);
$sourceModelTitlePlural = X2Model::getModelTitle($sourceModelClass, false);
$targetModelTitlePlural = X2Model::getModelTitle($targetModelClass, false);
$html = '<p>';
$html .= CHtml::encode(!$convertMultiple ? Yii::t('app', 'Converting this {model} to {article} {targetModel} could result in data
from your {model} being lost. ' . 'The following field incompatibilities have been detected: ', array('{model}' => $sourceModelTitle, '{targetModel}' => $targetModelTitle, '{article}' => preg_match('/^[aeiouAEIOU]/', $targetModelTitle) ? 'an' : 'a')) : Yii::t('app', 'Converting these {model} to {targetModel} could result in data
from your {model} being lost. ' . 'The following field incompatibilities have been detected: ', array('{model}' => $sourceModelTitlePlural, '{targetModel}' => $targetModelTitlePlural)));
$html .= "\n </p>\n <ul class='errorSummary'>\n ";
foreach ($this->owner->getConversionIncompatibilityWarnings($targetModelClass) as $message) {
$html .= '<li>' . CHtml::encode($message) . '</li>';
}
$html .= "\n </ul>\n <p>\n ";
$html .= CHtml::encode(Yii::t('app', 'To resolve these incompatibilities, make sure that every ' . '{model} field has a corresponding {targetModel} field of the same name and type.', array('{model}' => $sourceModelTitlePlural, '{targetModel}' => $targetModelTitlePlural)));
$html .= '</p>';
return $html;
}
示例11: getConversionIncompatibilityWarnings
/**
* @return <array of strings> Incompatibility warnings to be presented to the user before
* they convert this model to the target model.
*/
public function getConversionIncompatibilityWarnings($targetClass)
{
$warnings = array();
$targetModel = $targetClass::model();
$attributeNames = $this->mapFields($this->owner->attributeNames(), $targetClass);
$leadsAttrs = array_diff($attributeNames, $targetClass::model()->attributeNames());
$fieldMap = $this->getFieldMap($targetClass, true);
// look for fields which aren't in the target model
foreach ($leadsAttrs as $name) {
$name = isset($fieldMap[$name]) ? $fieldMap[$name] : $name;
// if field isn't set, there's no risk of data loss
if (!isset($this->owner->{$name})) {
continue;
}
$warnings[] = Yii::t('app', 'A field {fieldName} is in Leads but not in {targetModel}.', array('{fieldName}' => $name, '{targetModel}' => X2Model::getModelTitle($targetClass)));
}
// look for type mismatches
$sharedAttrs = array_intersect($attributeNames, $targetModel->attributeNames());
foreach ($sharedAttrs as $name) {
$originalName = $name;
$name = isset($fieldMap[$name]) ? $fieldMap[$name] : $name;
$leadField = $this->owner->getField($name);
$targetModelField = $targetModel->getField($name);
if (!$leadField instanceof Fields || !$targetModelField instanceof Fields) {
continue;
}
if ($leadField->type !== $targetModelField->type) {
if (isset($fieldMap[$originalName])) {
$warnings[] = Yii::t('app', 'The {model} field {fieldName} maps to the {targetModel} field ' . '{targetField} but the fields have different types.', array('{fieldName}' => $originalName, '{fieldName}' => $name, '{model}' => X2Model::getModelTitle(get_class($this->owner)), '{targetModel}' => X2Model::getModelTitle($targetClass)));
} else {
$warnings[] = Yii::t('app', 'A field {fieldName} is in both {model} and {targetModel} but the fields
have different types.', array('{fieldName}' => $name, '{model}' => X2Model::getModelTitle(get_class($this->owner)), '{targetModel}' => X2Model::getModelTitle($targetClass)));
}
}
}
return $warnings;
}