本文整理汇总了PHP中X2Model::_modelNames方法的典型用法代码示例。如果您正苦于以下问题:PHP X2Model::_modelNames方法的具体用法?PHP X2Model::_modelNames怎么用?PHP X2Model::_modelNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类X2Model
的用法示例。
在下文中一共展示了X2Model::_modelNames方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getModelNames
/**
* Retrieves a list of model names.
*
* Obtains model names as an associative array with model names as the keys
* and human-readable model names as their values. This is used in place of
* {@link getDisplayedModelNamesList()} (formerly Admin::getModelList) where
* specifying values for {@link modelName}, because the value of that should
* ALWAYS be the name of the actual class, and {@link X2Model::getModelName()}
* is guaranteed to return a class name (or false, if the class does not
* exist).
*
* @param null|CDbCriteria $criteria if not null, will be used to query modules table.
* Specifying a CDbCriteria will bypass caching.
* @return array module titles indexed by associated model class names
*/
public static function getModelNames($criteria = null)
{
if ($criteria !== null || !isset(self::$_modelNames)) {
$modelNames = array();
if ($criteria === null) {
$modules = self::getModules();
} else {
$criteria->addColumnCondition(array('visible' => 1, 'editable' => true), 'AND', 'OR');
$modules = X2Model::model('Modules')->findAll($criteria);
}
foreach ($modules as $module) {
if ($modelName = X2Model::getModelName($module->name)) {
$modelNames[$modelName] = Yii::t('app', $module->title);
} else {
// Shouldn't happen since getModelName uses class_exists
$modelNames[ucfirst($module->name)] = Yii::t('app', $module->title);
}
}
asort($modelNames);
if ($criteria !== null) {
return $modelNames;
} else {
self::$_modelNames = $modelNames;
}
}
return self::$_modelNames;
}