本文整理汇总了PHP中X2Model::getModelName方法的典型用法代码示例。如果您正苦于以下问题:PHP X2Model::getModelName方法的具体用法?PHP X2Model::getModelName怎么用?PHP X2Model::getModelName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类X2Model
的用法示例。
在下文中一共展示了X2Model::getModelName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateModelName
public function validateModelName($attr)
{
$value = $this->{$attr};
$modules = MobileModule::supportedModules(new CDbCriteria(array('condition' => 'editable')));
$validNames = array_map(function ($module) {
return X2Model::getModelName($module->name);
}, $modules);
if (!in_array($value, $validNames)) {
$this->addError($attr, Yii::t('app', 'Invalid model name'));
}
}
示例2: getStageMemberDataProvider
/**
* Get a data provider for members of a given type in a given stage
* @param string $type {'contacts', 'opportunities', 'accounts'}
*/
public function getStageMemberDataProvider($type, $workflowId, $dateRange, $expectedCloseDateDateRange, $stage, $user, $perStageWorkflowView = true)
{
$modelName = X2Model::getModelName($type);
$model = X2Model::model($modelName);
$tableName = $model->tableName();
$params = array(':workflowId' => $workflowId, ':stage' => $stage, ':start' => $dateRange['start'], ':end' => $dateRange['end'], ':type' => $type);
if ($expectedCloseDateDateRange['range'] !== 'all') {
$params = array_merge($params, array(':expectedCloseDateStart' => $expectedCloseDateDateRange['end'], ':expectedCloseDateEnd' => $expectedCloseDateDateRange['end']));
}
if (!empty($user)) {
$userString = " AND x2_actions.assignedTo=:user ";
$params[':user'] = $user;
} else {
$userString = "";
}
list($accessCondition, $accessConditionParams) = $modelName::model()->getAccessSQLCondition($tableName);
$params = array_merge($params, $accessConditionParams);
$stageMemberSql = Yii::app()->db->createCommand()->select("{$tableName}.*, x2_actions.lastUpdated as actionLastUpdated")->from($tableName)->join('x2_actions', "{$tableName}.id = x2_actions.associationId")->where(($expectedCloseDateDateRange['range'] !== 'all' ? $tableName . '.expectedCloseDate
BETWEEN :expectedCloseDateStart AND :expectedCloseDateEnd AND ' : '') . "x2_actions.workflowId=:workflowId AND x2_actions.stageNumber=:stage AND\n x2_actions.associationType=:type AND complete!='Yes' AND \n (completeDate IS NULL OR completeDate=0) AND \n x2_actions.createDate BETWEEN :start AND :end " . $userString . " AND " . $accessCondition)->getText();
$memberCount = Yii::app()->db->createCommand()->select("COUNT(*)")->from($tableName)->join('x2_actions', "{$tableName}.id = x2_actions.associationId")->where(($expectedCloseDateDateRange['range'] !== 'all' ? $tableName . '.expectedCloseDate
BETWEEN :expectedCloseDateStart AND :expectedCloseDateEnd AND ' : '') . "x2_actions.workflowId=:workflowId AND x2_actions.stageNumber=:stage AND\n x2_actions.associationType=:type AND complete!='Yes' AND \n (completeDate IS NULL OR completeDate=0) AND \n x2_actions.createDate BETWEEN :start AND :end " . $userString . ' AND ' . $accessCondition, $params)->queryScalar();
$membersDataProvider = new CSqlDataProvider($stageMemberSql, array('totalItemCount' => $memberCount, 'sort' => array('defaultOrder' => 'lastUpdated DESC'), 'pagination' => !$perStageWorkflowView ? false : array('pageSize' => 20), 'params' => $params));
return $membersDataProvider;
}
示例3: array
</td>
</tr>
<tr class="formSectionRow">
<td style="width: 300px">
<div class="formItem leftLabel">
<label><?php
echo Yii::t('media', 'Association Name');
?>
</label>
<div class="formInputBox" style="width: 200px; height: auto;">
<?php
if ($model->associationType && $model->associationType != 'bg') {
?>
<?php
if (!empty($model->associationId) && is_numeric($model->associationId) && ($modelName = X2Model::getModelName($model->associationType))) {
$linkModel = X2Model::model($modelName)->findByPk($model->associationId);
if (isset($linkModel)) {
echo CHtml::link(CHtml::encode($linkModel->name), array('/' . $model->associationType . '/' . $model->associationId));
} else {
echo '';
}
} else {
echo '';
}
?>
<?php
}
?>
</div>
</div>
示例4: getModelOfTypeWithName
public static function getModelOfTypeWithName($type, $name)
{
$modelName = X2Model::getModelName($type);
// both ID and type must be set
if (!(empty($type) || empty($name)) && $modelName) {
// both ID and type must be set
$model = X2Model::model($modelName);
if ($model->hasAttribute('name')) {
return $model->findByAttributes(array('name' => $name));
}
}
return null;
// invalid type or invalid name
}
示例5: echo
echo ($legacy ? '<br />' : '') . CHtml::link(Yii::t('app', '[View email]'), '#', array('onclick' => 'return false;', 'id' => $data->id, 'class' => 'email-frame'));
} elseif ($data->type == 'quotesDeleted') {
echo $data->actionDescription;
} elseif ($data->type == 'quotes') {
$data->renderInlineViewLink();
} else {
echo Yii::app()->controller->convertUrls(CHtml::encode($data->actionDescription));
}
}
// convert LF and CRLF to <br />
?>
</div>
<div class="footer">
<?php
if (isset($relationshipFlag) && $relationshipFlag && $data->associationId !== 0 && X2Model::getModelName($data->associationType) !== false) {
$relString = " | " . X2Model::getModelLink($data->associationId, X2Model::getModelName($data->associationType));
} else {
$relString = "";
}
if (empty($data->type) || $data->type == 'weblead' || $data->type == 'workflow') {
if ($data->complete == 'Yes') {
echo Yii::t('actions', 'Completed by {name}', array('{name}' => User::getUserLinks($data->completedBy))) . $relString;
} else {
$userLink = User::getUserLinks($data->assignedTo);
$userLink = empty($userLink) ? Yii::t('actions', 'Anyone') : $userLink;
echo Yii::t('actions', 'Assigned to {name}', array('{name}' => $userLink)) . $relString;
}
} else {
if (in_array($data->type, array('note', 'call', 'emailOpened', 'time'))) {
echo $data->completedBy == 'Guest' ? "Guest" : User::getUserLinks($data->completedBy) . $relString;
// echo ' '.Formatter::formatDate($data->completeDate);
示例6: getDisplayedModelNamesList
/**
* Legacy function kept for backwards compatibility.
*
* Moved from {@link Admin} and renamed from getModelList because it doesn't
* make sense to put it there; it doesn't fit in a model intended for
* managing system settings, but it does in this model, which is intended
* for managing data models themselves.
*
* @return array
*/
public static function getDisplayedModelNamesList()
{
$modelList = array();
foreach (X2Model::model('Modules')->findAllByAttributes(array('editable' => true, 'visible' => 1)) as $module) {
if ($modelName = X2Model::getModelName($module->name)) {
$modelName = $module->name;
} else {
$modelName = ucfirst($module->name);
}
if (Yii::app()->user->checkAccess(ucfirst($module->name) . 'Index', array())) {
$modelList[$modelName] = $module->title;
}
}
return array_map(function ($term) {
return Yii::t('app', $term);
}, $modelList);
}
示例7: actionParseType
public function actionParseType()
{
if (isset($_POST['Actions']['associationType'])) {
$type = $_POST['Actions']['associationType'];
if ($modelName = X2Model::getModelName($type)) {
$linkModel = $modelName;
if (class_exists($linkModel)) {
if ($linkModel == "X2Calendar") {
$linkSource = '';
} else {
$linkSource = $this->createUrl(X2Model::model($linkModel)->autoCompleteSource);
}
} else {
$linkSource = "";
}
echo $linkSource;
} else {
echo '';
}
} else {
echo '';
}
}
示例8: getStageCounts
/**
* Get number of records at each stage
* @param array $workflowStatus
* @param array $dateRange return value of WorkflowController::getDateRange ()
* @param string $users users filter
* @param string $modelType model type filter
* @return array number of records at each stage subject to specified filters
*/
public static function getStageCounts(&$workflowStatus, $dateRange, $expectedCloseDateDateRange, $users = '', $modelType = '')
{
$stageCount = count($workflowStatus['stages']);
if ($users !== '') {
$userString = " AND x2_actions.assignedTo='{$users}' ";
} else {
$userString = "";
}
$params = array(':start' => $dateRange['start'], ':end' => $dateRange['end'], ':workflowId' => $workflowStatus['id']);
if ($expectedCloseDateDateRange['range'] !== 'all') {
$params = array_merge($params, array(':expectedCloseDateStart' => $expectedCloseDateDateRange['end'], ':expectedCloseDateEnd' => $expectedCloseDateDateRange['end']));
}
$stageCounts = array();
$models = self::getModelsFromTypesArr($modelType);
for ($i = 1; $i <= $stageCount; $i++) {
$recordsAtStage = 0;
foreach ($models as $type => $model) {
$tableName = $model->tableName();
$modelName = X2Model::getModelName($type);
list($accessCondition, $accessConditionParams) = $modelName::model()->getAccessSQLCondition($tableName);
$countParams = array_merge($params, $accessConditionParams);
$recordsAtStage += Yii::app()->db->createCommand()->select("COUNT(*)")->from($tableName)->join('x2_actions', 'x2_actions.associationId=' . $tableName . '.id')->where("x2_actions.complete != 'Yes' {$userString} AND \n (x2_actions.completeDate IS NULL OR x2_actions.completeDate = 0) AND \n x2_actions.createDate BETWEEN :start AND :end AND\n x2_actions.type='workflow' AND workflowId=:workflowId AND \n stageNumber=" . $i . " AND associationType='" . $type . "'" . ' AND ' . $accessCondition . ($expectedCloseDateDateRange['range'] !== 'all' ? ' AND ' . $tableName . '.expectedCloseDate
BETWEEN :expectedCloseDateStart AND :expectedCloseDateEnd' : ''), $countParams)->queryScalar();
}
$stageCounts[] = $recordsAtStage;
}
return $stageCounts;
}
示例9: getStageCounts
/**
* Get number of records at each stage
* @param array $workflowStatus
* @param array $dateRange return value of WorkflowController::getDateRange ()
* @param string $users users filter
* @param string $modelType model type filter
* @return array number of records at each stage subject to specified filters
*/
public static function getStageCounts(&$workflowStatus, $dateRange, $expectedCloseDateDateRange, $users = '', $modelType = 'contacts')
{
$stageCount = count($workflowStatus['stages']);
if ($users !== '') {
$userString = " AND x2_actions.assignedTo='{$users}' ";
} else {
$userString = "";
}
$params = array(':start' => $dateRange['start'], ':end' => $dateRange['end'], ':workflowId' => $workflowStatus['id']);
if ($expectedCloseDateDateRange['range'] !== 'all') {
$params = array_merge($params, array(':expectedCloseDateStart' => $expectedCloseDateDateRange['end'], ':expectedCloseDateEnd' => $expectedCloseDateDateRange['end']));
}
$stageCounts = array();
$modelName = X2Model::getModelName($modelType);
$model = X2Model::model($modelName);
$tableName = $model->tableName();
list($accessCondition, $accessConditionParams) = $modelName::model()->getAccessSQLCondition($tableName);
$allParams = array_merge($params, $accessConditionParams);
$recordsAtStages = Yii::app()->db->createCommand()->select("stageNumber, COUNT(*)")->from($tableName)->join('x2_actions', 'x2_actions.associationId=' . $tableName . '.id')->where("x2_actions.complete != 'Yes' {$userString} AND \n (x2_actions.completeDate IS NULL OR x2_actions.completeDate = 0) AND \n x2_actions.createDate BETWEEN :start AND :end AND\n x2_actions.type='workflow' AND workflowId=:workflowId AND \n associationType='" . $modelType . "' AND " . $accessCondition . ($expectedCloseDateDateRange['range'] !== 'all' ? ' AND ' . $tableName . '.expectedCloseDate
BETWEEN :expectedCloseDateStart AND :expectedCloseDateEnd' : ''), $allParams)->group('stageNumber')->queryAll();
foreach ($recordsAtStages as $row) {
$stage = WorkflowStage::model()->findByPK($row['stageNumber']);
if ($stage) {
$stageCounts[$stage->stageNumber - 1] = $row['COUNT(*)'];
}
}
for ($i = 0; $i < $stageCount; $i++) {
if (!isset($stageCounts[$i])) {
$stageCounts[$i] = 0;
}
}
ksort($stageCounts);
return $stageCounts;
}
示例10: getDialogTooltipsForModels
/**
* Returns array of tooltips to be applied to quick create buttons for each model
* @param array $models
* @param string $modelName
* @return array
*/
public static function getDialogTooltipsForModels($models, $modelName)
{
$tooltips = array_flip($models);
array_walk($tooltips, function (&$val, $key) use($modelName) {
$val = Yii::t('app', 'Create a new {relatedModelClass} associated with this {modelClass}', array('{relatedModelClass}' => X2Model::getRecordName($key), '{modelClass}' => X2Model::getRecordName(X2Model::getModelName($modelName))));
});
return $tooltips;
}
示例11: foreach
}
}
// At this stage, all nameId fields have been created and populated.
//
// Now it's time to update the referencing columns:
$linkFields = Yii::app()->db->createCommand()->select('modelName,fieldName,linkType')->from('x2_fields')->where('type="link" AND linkType IS NOT NULL AND linkType != ""')->queryAll(true);
foreach ($linkFields as $field) {
if ($debug) {
echo "updating refs for field {$field['modelName']}.{$field['fieldName']}\n";
}
$class = X2Model::getModelName($field['modelName']);
if (empty($class) || !class_exists($class)) {
continue;
}
$model = X2Model::model($class);
$referencedClass = X2Model::getModelName($field['linkType']);
if (empty($referencedClass) || !class_exists($referencedClass)) {
continue;
}
$referencedModel = X2Model::model($referencedClass);
if ($referencedModel->asa('X2LinkableBehavior') instanceof X2LinkableBehavior) {
// Referenced model exists and is linkable. Update refs:
$table = $model->tableName();
$referencedTable = $referencedModel->tableName();
$column = $field['fieldName'];
$query = "UPDATE `{$table}` AS `t1`\n INNER JOIN `{$referencedTable}` AS `t2`\n ON CAST(`t1`.`{$column}` AS CHAR)=`t2`.`id`\n SET `t1`.`{$column}`=CAST(`t2`.`nameId` AS CHAR)";
if ($debug) {
echo "Running: {$query}\n";
}
Yii::app()->db->createCommand($query)->execute();
}
示例12: array
* 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='stage-member-container stage-member-id-<?php
echo $data['id'];
?>
stage-member-type-<?php
echo $recordType;
?>
'>
<?php
$modelName = X2Model::getModelName($recordType);
?>
<div class='stage-icon-container'
title='<?php
echo Yii::t('workflow', '{recordName}', array('{recordName}' => $modelName));
?>
'>
<img src='<?php
if (file_exists(substr(Yii::app()->theme->getBaseUrl() . '/images/workflow_stage_' . $recordType . '.png', 1))) {
echo Yii::app()->theme->getBaseUrl() . '/images/workflow_stage_' . $recordType . '.png';
} else {
echo Yii::app()->theme->getBaseUrl() . '/images/workflow_stage_model.png';
}
?>
'
示例13: array
* 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='stage-member-container stage-member-id-<?php
echo $data['id'];
?>
stage-member-type-<?php
echo $data['recordType'];
?>
'>
<?php
$modelName = X2Model::getModelName($data['recordType']);
$recordName = $recordNames[$modelName];
?>
<div class='stage-icon-container'
title='<?php
echo Yii::t('workflow', '{recordName}', array('{recordName}' => $recordName));
?>
'>
<img src='<?php
echo Yii::app()->theme->getBaseUrl() . '/images/workflow_stage_' . $data['recordType'] . '.png';
?>
'
class='stage-member-type-icon left' alt=''>
</div>
<div class='stage-member-name left'><?php
示例14: getStageMembers
public function getStageMembers($workflowId, $stage, $start, $end, $range, $expectedCloseDateStart, $expectedCloseDateEnd, $expectedCloseDateRange, $users, $modelType = '')
{
$params = array();
$dateRange = self::getDateRange();
$expectedCloseDateDateRange = self::getDateRange('expectedCloseDateStart', 'expectedCloseDateEnd', 'expectedCloseDateRange');
if (!is_numeric($workflowId) || !is_numeric($stage)) {
return new CActiveDataProvider();
}
$dataProvider = $this->getStageMemberDataProvider($modelType, $workflowId, $dateRange, $expectedCloseDateDateRange, $stage, $users);
$gridConfig = array('baseScriptUrl' => Yii::app()->theme->getBaseUrl() . '/css/gridview', 'template' => '<div class="page-title">{title}{buttons}' . '</div>{items}{pager}', 'fixedHeader' => false, 'fullscreen' => false, 'buttons' => array('columnSelector', 'autoResize'));
$modelName = X2Model::getModelName($modelType);
$this->renderPartial('_ajaxRequestedStageMembers', array('gridConfig' => array_merge($gridConfig, array('gvSettingsName' => $modelType . '-stageMembers', 'viewName' => $modelType . '-workflowView', 'defaultGvSettings' => array('name' => 125, 'lastUpdated' => 80, 'assignedTo' => 80), 'dataProvider' => $dataProvider, 'id' => 'workflow-stage-grid', 'ajaxUpdate' => 'workflow-stage-grid', 'modelName' => $modelName, 'title' => Modules::displayName(true, $modelType), 'specialColumns' => array('name' => array('name' => 'name', 'header' => Yii::t('app', 'Name'), 'value' => 'X2Model::getModelLinkMock (
"' . $modelName . '",
$data[\'nameId\'],
array (
\'data-qtip-title\' => $data[\'name\']
)
)', 'type' => 'raw', 'htmlOptions' => array('width' => '30%')), 'lastUpdated' => array('name' => 'lastUpdated', 'header' => X2Model::model($modelName)->getAttributeLabel('lastUpdated'), 'value' => 'Formatter::formatDate($data["lastUpdated"])', 'type' => 'raw', 'htmlOptions' => array('width' => '15%')), 'assignedTo' => array('header' => X2Model::model($modelName)->getAttributeLabel('assignedTo'), 'name' => 'assignedTo', 'value' => 'empty($data["assignedTo"])?' . 'Yii::t("app","Anyone"):User::getUserLinks($data["assignedTo"])', 'type' => 'raw'))))), false, true);
}
示例15: array
<?php
echo $form->errorSummary($model);
?>
<div class="row">
<div class="cell">
<?php
echo $form->labelEx($model, 'name');
echo $form->textField($model, 'name', array('maxlength' => 250, 'class' => 'x2-wide-input'));
echo $form->error($model, 'name');
?>
</div>
<div class="cell">
<?php
$moduleOptions = array(Workflow::DEFAULT_ALL_MODULES => Yii::t('workflow', 'All Modules')) + Modules::getDropdownOptions('id', function ($record) {
$modelName = X2Model::getModelName($record['name']);
return $modelName && $modelName::model() instanceof X2Model && $modelName::model()->supportsWorkflow;
});
echo $form->labelEx($model, 'isDefaultFor');
echo $form->dropDownList($model, 'isDefaultFor', $moduleOptions, array('multiple' => 'multiple', 'class' => 'x2-multiselect-dropdown', 'style' => 'display: none', 'data-selected-text' => Yii::t('workflow', 'module(s)')));
?>
</div>
<div class="cell">
<?php
echo $form->labelEx($model, 'financial');
echo $form->checkBox($model, 'financial');
echo $form->error($model, 'financial');
?>
</div>
<div class="cell" id="financialModel" style="<?php
echo $model->financial ? '' : 'display:none;';