本文整理汇总了PHP中X2Model::getModelNames方法的典型用法代码示例。如果您正苦于以下问题:PHP X2Model::getModelNames方法的具体用法?PHP X2Model::getModelNames怎么用?PHP X2Model::getModelNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类X2Model
的用法示例。
在下文中一共展示了X2Model::getModelNames方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getModelsWhichSupportQuickCreate
/**
* Returns an array of all model classes (associated with some module) which have this
* behavior
*
* @return <array of strings>
*/
public static function getModelsWhichSupportQuickCreate($includeActions = false)
{
if (!isset(self::$_modelsWhichSupportQuickCreate)) {
self::$_modelsWhichSupportQuickCreate = array_diff(array_keys(X2Model::getModelNames()), array('Docs', 'Groups', 'Campaign', 'Media', 'Quote', 'BugReports'));
self::$_modelsWhichSupportQuickCreate[] = 'Actions';
}
$modelNames = self::$_modelsWhichSupportQuickCreate;
if (!$includeActions) {
array_pop($modelNames);
}
return $modelNames;
}
示例2: validateValue
protected function validateValue(CModel $object, $value, $attribute)
{
if (!is_string($value) || !in_array($value, array_keys(X2Model::getModelNames())) && (!$this->includeActions || $value !== 'Actions')) {
$this->addError($object, $attribute, Yii::t('app', 'Invalid record type'));
}
}
示例3: modelsWhichSupportEmailTemplates
/**
* @return array names of models which support email templates
*/
public static function modelsWhichSupportEmailTemplates()
{
// get all x2model types not in blacklist
return array_diff_key(X2Model::getModelNames(), array_flip(array('Actions', 'Quote', 'Product', 'Opportunity', 'Campaign')));
}
示例4: testX2ModelSessionSettings
/**
* For each child of X2Model, ensure that filters and sort order get saved in session correctly
* and that analogous methods in ERememberFiltersBehavior and SmartDataProviderBehavior behave
* the same
*/
public function testX2ModelSessionSettings()
{
$models = X2Model::getModelNames();
unset($models['EmailInboxes']);
foreach ($models as $class => $title) {
$_SESSION = array();
X2_TEST_DEBUG_LEVEL > 1 && println('testing sort for ' . $class);
$uid = rand();
$_GET["{$class}_sort"] = 'test';
$_GET[$class] = array('id' => 0);
$searchModel = new $class('search');
$dataProvider = $searchModel->search();
$sort = $searchModel->asa('ERememberFiltersBehavior')->getSetting('sort');
$filters = $searchModel->asa('ERememberFiltersBehavior')->getSetting('filters');
$sort2 = $dataProvider->asa('SmartDataProviderBehavior')->getSetting('sort');
$filters2 = $dataProvider->asa('SmartDataProviderBehavior')->getSetting('filters');
$this->assertEquals($filters, $_GET[$class]);
$this->assertEquals($filters, $filters2);
$this->assertEquals($sort, $_GET[$class . '_sort']);
$this->assertEquals($sort, $sort2);
}
}
示例5: rules
/**
* Rules for saving a field.
*
* See the following MySQL documentation pages for more info on length
* restrictions and naming requirements:
* http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
*
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(array('modelName, attributeLabel', 'length', 'max' => 250), array('fieldName', 'length', 'max' => 64), array('fieldName', 'match', 'pattern' => '/^[a-zA-Z]\\w+$/', 'message' => Yii::t('admin', 'Field name may only contain alphanumeric characters and underscores.')), array('fieldName', 'nonReserved'), array('modelName, fieldName, attributeLabel', 'required'), array('modelName', 'in', 'range' => array_keys(X2Model::getModelNames()), 'allowEmpty' => false), array('defaultValue', 'validDefault'), array('relevance', 'in', 'range' => array_keys(self::searchRelevance())), array('custom, modified, readOnly, searchable, required, uniqueConstraint', 'boolean'), array('fieldName', 'uniqueFieldName'), array('linkType', 'length', 'max' => 250), array('type', 'length', 'max' => 20), array('keyType', 'in', 'range' => array('MUL', 'UNI', 'PRI', 'FIX', 'FOR'), 'allowEmpty' => true), array('keyType', 'requiredUnique'), array('data', 'validCustom'), array('id, modelName, fieldName, attributeLabel, custom, modified, readOnly, keyType', 'safe', 'on' => 'search'));
}
示例6: array
<?php
echo $form->textField($model, 'fieldName', array('id' => 'fieldName-input'));
?>
<?php
echo $form->error($model, 'fieldName');
?>
</div>
<?php
} else {
?>
<div class="row">
<?php
echo $form->labelEx($model, 'modelName');
?>
<?php
echo $form->dropDownList($model, 'modelName', X2Model::getModelNames(), array('empty' => Yii::t('admin', 'Select a model'), 'id' => 'modelName-existing'));
?>
<?php
echo $form->error($model, 'modelName');
?>
</div>
<div class="row">
<?php
echo $form->labelEx($model, 'fieldName');
?>
<?php
$modelSet = !empty($model->modelName);
$fieldList = array();
$fieldOptions = array();
$customOrMod = false;
示例7: actionModels
/**
* Responds with a JSON-encoded list of model classes.
*
* @param integer $partialSupport 1 to include partially-supported models,
* 0 to include only fully-supported models.
*/
public function actionModels($partialSupport = 1)
{
// To obtain all models: iterate through modules
$modelNames = X2Model::getModelNames();
// Partially-supported models
$partial = array('Actions' => Yii::t('app', 'Actions'), 'Docs' => Yii::t('app', 'Docs'), 'Groups' => Yii::t('app', 'Groups'), 'Media' => Yii::t('app', 'Media'), 'Quote' => Yii::t('app', 'Quotes'), 'X2List' => Yii::t('app', 'Contact Lists'));
if ((bool) (int) $partialSupport) {
$modelNames = array_unique(array_merge($modelNames, $partial));
} else {
$modelNames = array_diff($modelNames, $partial);
}
asort($modelNames);
$models = array();
foreach ($modelNames as $modelName => $title) {
$attributes = X2Model::model($modelName)->attributeNames();
$models[] = compact('modelName', 'title', 'attributes');
}
$this->responseBody = $models;
}