本文整理汇总了PHP中Events::parseModelName方法的典型用法代码示例。如果您正苦于以下问题:PHP Events::parseModelName方法的具体用法?PHP Events::parseModelName怎么用?PHP Events::parseModelName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Events
的用法示例。
在下文中一共展示了Events::parseModelName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testParseModelName
/**
* Ensure that a model name can be properly parsed and resolved
*/
public function testParseModelName()
{
$models = array('Product' => 'product', 'Opportunity' => 'opportunity', 'Campaign' => 'campaign', 'Contacts' => 'contact', 'Accounts' => 'account', 'Marketing' => 'marketing', 'Quote' => 'quote', 'Non Existant Module' => null);
// First ensure parseModelName works as expected for default modules
foreach ($models as $model => $expected) {
$this->assertEquals($expected, Events::parseModelName($model));
}
// Now ensure renamed modules can be properly resolved
foreach ($models as $model => $expected) {
// Correct pluralization inconsistancies
if ($model === 'Opportunity') {
$model = 'Opportunities';
}
if ($model === 'Product' || $model === 'Quote') {
$model .= 's';
}
$dummyTitle = $model . time();
$module = Modules::model()->findByAttributes(array('name' => strtolower($model)));
if ($module && $module->retitle($dummyTitle)) {
$this->assertEquals(strtolower($dummyTitle), Events::parseModelName($model));
}
}
}
示例2: getText
public function getText(array $params = array(), array $htmlOptions = array())
{
$truncated = array_key_exists('truncated', $params) ? $params['truncated'] : false;
$requireAbsoluteUrl = array_key_exists('requireAbsoluteUrl', $params) ? $params['requireAbsoluteUrl'] : false;
$text = "";
$authorText = "";
if (Yii::app()->user->getName() == $this->user) {
$authorText = CHtml::link(Yii::t('app', 'You'), Yii::app()->controller->createAbsoluteUrl('/profile/view', array('id' => Yii::app()->user->getId())), $htmlOptions);
} else {
$authorText = User::getUserLinks($this->user);
}
if (!empty($authorText)) {
$authorText .= " ";
}
switch ($this->type) {
case 'notif':
$parent = X2Model::model('Notification')->findByPk($this->associationId);
if (isset($parent)) {
$text = $parent->getMessage();
} else {
$text = Yii::t('app', "Notification not found");
}
break;
case 'record_create':
$actionFlag = false;
if (class_exists($this->associationType)) {
if (count(X2Model::model($this->associationType)->findAllByPk($this->associationId)) > 0) {
if ($this->associationType == 'Actions') {
$action = X2Model::model('Actions')->findByPk($this->associationId);
if (isset($action) && (strcasecmp($action->associationType, 'contacts') === 0 || in_array($action->type, array('call', 'note', 'time')))) {
// Special considerations for publisher-created actions, i.e. call,
// note, time, and anything associated with a contact
$actionFlag = true;
// Retrieve the assigned user from the related action
$relatedAction = Actions::model()->findByPk($this->associationId);
if ($authorText) {
$authorText = User::getUserLinks($relatedAction->assignedTo);
}
}
}
if ($actionFlag) {
$authorText = empty($authorText) ? Yii::t('app', 'Someone') : $authorText;
switch ($action->type) {
case 'call':
$text = Yii::t('app', '{authorText} logged a call ({duration}) with {modelLink}: "{logAbbrev}"', array('{authorText}' => $authorText, '{duration}' => empty($action->dueDate) || empty($action->completeDate) ? Yii::t('app', 'duration unknown') : Formatter::formatTimeInterval($action->dueDate, $action->completeDate, '{hoursMinutes}'), '{modelLink}' => X2Model::getModelLink($action->associationId, ucfirst($action->associationType), $requireAbsoluteUrl), '{logAbbrev}' => CHtml::encode($action->actionDescription)));
break;
case 'note':
$text = Yii::t('app', '{authorText} posted a comment on {modelLink}: "{noteAbbrev}"', array('{authorText}' => $authorText, '{modelLink}' => X2Model::getModelLink($action->associationId, ucfirst($action->associationType), $requireAbsoluteUrl), '{noteAbbrev}' => CHtml::encode($action->actionDescription)));
break;
case 'time':
$text = Yii::t('app', '{authorText} logged {time} on {modelLink}: "{noteAbbrev}"', array('{authorText}' => $authorText, '{time}' => Formatter::formatTimeInterval($action->dueDate, $action->dueDate + $action->timeSpent, '{hoursMinutes}'), '{modelLink}' => X2Model::getModelLink($action->associationId, ucfirst($action->associationType)), '{noteAbbrev}' => CHtml::encode($action->actionDescription)));
break;
default:
if (!empty($authorText)) {
$text = Yii::t('app', "A new {actionLink} associated with the contact {contactLink} has been assigned to " . $authorText, array('{actionLink}' => CHtml::link(Events::parseModelName($this->associationType), '#', array_merge($htmlOptions, array('class' => 'action-frame-link', 'data-action-id' => $this->associationId))), '{contactLink}' => X2Model::getModelLink($action->associationId, ucfirst($action->associationType), $requireAbsoluteUrl)));
} else {
$text = Yii::t('app', "A new {actionLink} associated with the contact {contactLink} has been created.", array('{actionLink}' => CHtml::link(Events::parseModelName($this->associationType), '#', array_merge($htmlOptions, array('class' => 'action-frame-link', 'data-action-id' => $this->associationId))), '{contactLink}' => X2Model::getModelLink($action->associationId, ucfirst($action->associationType), $requireAbsoluteUrl)));
}
}
} else {
if (!empty($authorText)) {
$modelLink = X2Model::getModelLink($this->associationId, $this->associationType, $requireAbsoluteUrl);
if (isset($action) && $this->user !== $action->assignedTo) {
// Include the assignee if this is for an action assigned to someone other than the creator
$translateText = "created a new {modelName} for {assignee}, {modelLink}";
} elseif ($modelLink !== '') {
$translateText = "created a new {modelName}, {modelLink}";
} else {
$translateText = "created a new {modelName}";
}
$text = $authorText . Yii::t('app', $translateText, array('{modelName}' => Events::parseModelName($this->associationType), '{modelLink}' => $modelLink, '{assignee}' => isset($action) ? User::getUserLinks($action->assignedTo) : null));
} else {
$text = Yii::t('app', "A new {modelName}, {modelLink}, has been created.", array('{modelName}' => Events::parseModelName($this->associationType), '{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType, $requireAbsoluteUrl)));
}
}
} else {
$deletionEvent = X2Model::model('Events')->findByAttributes(array('type' => 'record_deleted', 'associationType' => $this->associationType, 'associationId' => $this->associationId));
if (isset($deletionEvent)) {
if (!empty($authorText)) {
$text = $authorText . Yii::t('app', "created a new {modelName}, {deletionText}. It has been deleted.", array('{modelName}' => Events::parseModelName($this->associationType), '{deletionText}' => $deletionEvent->text));
} else {
$text = Yii::t('app', "A {modelName}, {deletionText}, was created. It has been deleted.", array('{modelName}' => Events::parseModelName($this->associationType), '{deletionText}' => $deletionEvent->text));
}
} else {
if (!empty($authorText)) {
$text = $authorText . Yii::t('app', "created a new {modelName}, but it could not be found.", array('{modelName}' => Events::parseModelName($this->associationType)));
} else {
$text = Yii::t('app', "A {modelName} was created, but it could not be found.", array('{modelName}' => Events::parseModelName($this->associationType)));
}
}
}
}
break;
case 'weblead_create':
if (count(X2Model::model($this->associationType)->findAllByPk($this->associationId)) > 0) {
$text = Yii::t('app', "A new web lead has come in: {modelLink}", array('{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType)));
} else {
$deletionEvent = X2Model::model('Events')->findByAttributes(array('type' => 'record_deleted', 'associationType' => $this->associationType, 'associationId' => $this->associationId));
if (isset($deletionEvent)) {
$text = Yii::t('app', "A new web lead has come in: {deletionText}. It has been deleted.", array('{deletionText}' => $deletionEvent->text));
//.........这里部分代码省略.........
示例3: array
<?php
if (!empty($model->associationType) && is_numeric($model->associationId) && !is_null(X2Model::getAssociationModel($model->associationType, $model->associationId)) && ($publisher == 'false' || !$publisher)) {
?>
<div id="recordBody" class="form">
<?php
echo '<div class="page-title"><h3>' . Yii::t('actions', 'Associated Record') . '</h3></div>';
?>
<?php
if ($model->associationType == 'contacts') {
$this->widget('DetailView', array('model' => X2Model::model('Contacts')->findByPk($model->associationId), 'scenario' => 'Inline', 'nameLink' => true));
// $this->renderPartial('application.modules.contacts.views.contacts._@DETAILVIEWMini', array(
// 'model' => X2Model::model('Contacts')->findByPk($model->associationId),
// 'actionModel' => $model,
// ));
} else {
echo ucwords(Events::parseModelName(X2Model::getModelName($model->associationType))) . ": <span class='model-link'>" . X2Model::getModelLink($model->associationId, X2Model::getModelName($model->associationType)) . "</span>";
}
?>
</div>
<?php
}
?>
</div>
<div id="actionFooter">
</div>
</body>
</html>
<script>
$(document).on('ready',function(){
$.datepicker.setDefaults( $.datepicker.regional[ '<?php
echo $language;