本文整理汇总了PHP中Formatter::formatLongDateTime方法的典型用法代码示例。如果您正苦于以下问题:PHP Formatter::formatLongDateTime方法的具体用法?PHP Formatter::formatLongDateTime怎么用?PHP Formatter::formatLongDateTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Formatter
的用法示例。
在下文中一共展示了Formatter::formatLongDateTime方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createEmailOpenedAction
private function createEmailOpenedAction()
{
$now = time();
$action = new Actions();
$action->type = 'emailOpened';
$action->associationType = $this->action->associationType;
$action->associationId = $this->action->associationId;
$action->createDate = $now;
$action->lastUpdated = $now;
$action->completeDate = $now;
$action->complete = 'Yes';
$action->updatedBy = 'admin';
$action->associationName = $this->action->associationName;
$action->visibility = $this->action->visibility;
$action->assignedTo = $this->action->assignedTo;
$action->actionDescription = Yii::t('marketing', '{recordType} has opened the email sent on ', array('{recordType}' => Modules::displayName(false, $this->action->associationType)));
$action->actionDescription .= Formatter::formatLongDateTime($this->action->createDate) . "<br>";
$action->actionDescription .= $this->action->actionDescription;
return $action;
}
示例2: actionExportModelRecords
/**
* An AJAX called function which exports data to a CSV via pagination.
* This is a generalized version of the Contacts export.
* @param int $page The page of the data provider to export
*/
public function actionExportModelRecords($page, $model)
{
X2Model::$autoPopulateFields = false;
$file = $this->safePath($_SESSION['modelExportFile']);
$staticModel = X2Model::model(str_replace(' ', '', $model));
$fields = $staticModel->getFields();
$fp = fopen($file, 'a+');
// Load data provider based on export criteria
$excludeHidden = !isset($_GET['includeHidden']) || $_GET['includeHidden'] === 'false';
if ($page == 0 && $excludeHidden && isset($_SESSION['exportModelCriteria']) && $_SESSION['exportModelCriteria'] instanceof CDbCriteria) {
// Save hidden condition in criteria
$hiddenConditions = $staticModel->getHiddenCondition();
$_SESSION['exportModelCriteria']->addCondition($hiddenConditions);
}
$dp = new CActiveDataProvider($model, array('criteria' => isset($_SESSION['exportModelCriteria']) ? $_SESSION['exportModelCriteria'] : array(), 'pagination' => array('pageSize' => 100)));
// Flip through to the right page.
$pg = $dp->getPagination();
$pg->setCurrentPage($page);
$dp->setPagination($pg);
$records = $dp->getData();
$pageCount = $dp->getPagination()->getPageCount();
// Retrieve specified export delimeter and enclosure
$delimeter = isset($_GET['delimeter']) ? $_GET['delimeter'] : ',';
$enclosure = isset($_GET['enclosure']) ? $_GET['enclosure'] : '"';
// We need to set our data to be human friendly, so loop through all the
// records and format any date / link / visibility fields.
foreach ($records as $record) {
foreach ($fields as $field) {
$fieldName = $field->fieldName;
if ($field->type == 'date' || $field->type == 'dateTime') {
if (is_numeric($record->{$fieldName})) {
$record->{$fieldName} = Formatter::formatLongDateTime($record->{$fieldName});
}
} elseif ($field->type == 'link') {
$name = $record->{$fieldName};
if (!empty($field->linkType)) {
list($name, $id) = Fields::nameAndId($name);
}
if (!empty($name)) {
$record->{$fieldName} = $name;
}
} elseif ($fieldName == 'visibility') {
switch ($record->{$fieldName}) {
case 0:
$record->{$fieldName} = 'Private';
break;
case 1:
$record->{$fieldName} = 'Public';
break;
case 2:
$record->{$fieldName} = 'User\'s Groups';
break;
default:
$record->{$fieldName} = 'Private';
}
}
}
// Enforce metadata to ensure accuracy of column order, then export.
$combinedMeta = array_combine($_SESSION['modelExportMeta'], $_SESSION['modelExportMeta']);
$recordAttributes = $record->attributes;
if ($model === 'Actions') {
// Export descriptions with Actions
$actionText = $record->actionText;
if ($actionText) {
$actionDescription = $actionText->text;
$recordAttributes = array_merge($recordAttributes, array('actionDescription' => $actionDescription));
}
}
if ($_SESSION['includeTags']) {
$tags = $record->getTags();
$recordAttributes = array_merge($recordAttributes, array('tags' => implode(',', $tags)));
}
$tempAttributes = array_intersect_key($recordAttributes, $combinedMeta);
$tempAttributes = array_merge($combinedMeta, $tempAttributes);
fputcsv($fp, $tempAttributes, $delimeter, $enclosure);
}
unset($dp);
fclose($fp);
if ($page + 1 < $pageCount) {
echo $page + 1;
}
}
示例3: actionShareAction
public function actionShareAction($id)
{
$model = $this->loadModel($id);
$body = "\n\n\n\n" . Yii::t('actions', "Reminder, the following action is due") . " " . Formatter::formatLongDateTime($model->dueDate) . ":<br />\n<br />" . Yii::t('actions', 'Description') . ": {$model->actionDescription}\n<br />" . Yii::t('actions', 'Type') . ": {$model->type}\n<br />" . Yii::t('actions', 'Associations') . ": " . $model->associationName . "\n<br />" . Yii::t('actions', 'Link to the action') . ": " . CHtml::link('Link', 'http://' . Yii::app()->request->getServerName() . $this->createUrl('/actions/' . $model->id));
$body = trim($body);
$errors = array();
$status = array();
$email = array();
if (isset($_POST['email'], $_POST['body'])) {
$subject = Yii::t('actions', "Reminder, the following action is due") . " " . date("Y-m-d", $model->dueDate);
$email['to'] = $this->parseEmailTo($this->decodeQuotes($_POST['email']));
$body = $_POST['body'];
// if(empty($email) || !preg_match("/[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}/",$email))
if ($email['to'] === false) {
$errors[] = 'email';
}
if (empty($body)) {
$errors[] = 'body';
}
if (empty($errors)) {
$status = $this->sendUserEmail($email, $subject, $body);
}
if (array_search('200', $status)) {
$this->redirect(array('view', 'id' => $model->id));
return;
}
if ($email['to'] === false) {
$email = $_POST['email'];
} else {
$email = $this->mailingListToString($email['to']);
}
}
$this->render('shareAction', array('model' => $model, 'body' => $body, 'email' => $email, 'status' => $status, 'errors' => $errors));
}
示例4: elseif
}
}
}
?>
</div>
</div>
<div class="description">
<?php
if ($type == 'attachment' && $data->completedBy != 'Email') {
echo Media::attachmentActionText(Yii::app()->controller->convertUrls($data->actionDescription), true, true);
} else {
if ($type == 'workflow') {
if ($data->complete == 'Yes') {
echo ' <b>' . Yii::t('workflow', 'Completed') . '</b> ' . Formatter::formatLongDateTime($data->completeDate);
} else {
echo ' <b>' . Yii::t('workflow', 'Started') . '</b> ' . Formatter::formatLongDateTime($data->createDate);
}
if (isset($data->actionDescription)) {
echo '<br>' . CHtml::encode($data->actionDescription);
}
} elseif ($type == 'webactivity') {
if (!empty($data->actionDescription)) {
echo CHtml::encode($data->actionDescription), '<br>';
}
echo date('Y-m-d H:i:s', $data->completeDate);
} elseif (in_array($data->type, array('email', 'emailFrom', 'email_quote', 'email_invoice', 'emailOpened', 'emailOpened_quote', 'emailOpened_invoice'))) {
$legacy = false;
if (!preg_match(InlineEmail::insertedPattern('ah', '(.*)', 1, 'mis'), $data->actionDescription, $matches)) {
// Legacy pattern:
preg_match('/<b>(.*?)<\\/b>(.*)/mis', $data->actionDescription, $matches);
$legacy = true;
示例5: actionEmailOpened
/**
* Called when a Contact opens an email sent from Inline Email Form. Inline Email Form
* appends an image to the email with src pointing to this function. This function
* creates an action associated with the Contact indicating that the email was opened.
*
* @param integer $uid The unique id of the recipient
* @param string $type 'open', 'click', or 'unsub'
*
*/
public function actionEmailOpened($uid, $type)
{
// If the request is coming from within the web application, ignore it.
$referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$baseUrl = Yii::app()->request->getBaseUrl(true);
$fromApp = strpos($referrer, $baseUrl) === 0;
if ($type == 'open' && !$fromApp) {
$track = TrackEmail::model()->findByAttributes(array('uniqueId' => $uid));
if ($track && $track->opened == null) {
$action = $track->action;
if ($action) {
$note = new Actions();
switch ($action->type) {
case 'email_quote':
case 'email_invoice':
$subType = str_replace('email_', '', $action->type);
$note->type = "emailOpened_{$subType}";
$quote = Quote::model()->findByPk($action->associationId);
if ($quote instanceof Quote) {
$contact = $quote->associatedContactsModel;
if ($contact instanceof Contacts) {
$note->associationType = 'contacts';
$note->associationId = $contact->id;
}
}
break;
default:
$note->type = 'emailOpened';
$note->associationType = $action->associationType;
$note->associationId = $action->associationId;
}
$now = time();
$note->createDate = $now;
$note->lastUpdated = $now;
$note->completeDate = $now;
$note->complete = 'Yes';
$note->updatedBy = 'admin';
$note->associationName = $action->associationName;
$note->visibility = $action->visibility;
$note->assignedTo = $action->assignedTo;
$note->actionDescription = Yii::t('marketing', 'Contact has opened the email sent on ');
$note->actionDescription .= Formatter::formatLongDateTime($action->createDate) . "<br>";
$note->actionDescription .= $action->actionDescription;
if ($note->save()) {
$event = new Events();
$event->type = 'email_opened';
switch ($action->type) {
case 'email_quote':
$event->subtype = 'quote';
break;
case 'email_invoice':
$event->subtype = 'invoice';
break;
default:
$event->subtype = 'email';
}
$contact = isset($quote) && $quote instanceof Quote ? $quote->associatedContactsModel : X2Model::model('Contacts')->findByPk($action->associationId);
if (isset($contact)) {
$event->user = $contact->assignedTo;
}
$event->associationType = 'Contacts';
$event->associationId = isset($contact) ? $contact->id : $note->associationId;
if ($action->associationType == 'services') {
$case = X2Model::model('Services')->findByPk($action->associationId);
if (isset($case) && is_numeric($case->contactId)) {
$event->associationId = $case->contactId;
} elseif (isset($case)) {
$event->associationType = 'Services';
$event->associationId = $case->id;
}
}
$event->save();
$track->opened = $now;
$track->update();
}
}
}
}
//return a one pixel transparent png
header('Content-Type: image/png');
echo base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAAXNSR0IArs4c6QAAAAJiS0dEAP+Hj8y/AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAC0lEQVQI12NgYAAAAAMAASDVlMcAAAAASUVORK5CYII=');
}
示例6: elseif
$model->completeDate = Formatter::formatDateTime($model->completeDate);
}
echo $form->textField($model, 'completeDate');
echo "</div>";
}
echo "</span>";
echo "<div class='field-value'>";
echo "<span style='color:grey'>" . $model->getAttributeLabel('dueDate', true) . ':' . " </span>" . '<b>' . $model->formatDueDate() . '</b>';
echo "</div>";
if (in_array($model->type, array('event', 'time', 'call'))) {
echo "<div class='field-value'>";
echo "<span style='color:grey'>" . $model->getAttributeLabel('completeDate', true) . ':' . " </span>" . '<b>' . Formatter::formatDateTime($model->completeDate) . '</b>';
echo "</div>";
}
} elseif (!empty($model->createDate)) {
echo Yii::t('actions', 'Created:') . " " . Formatter::formatLongDateTime($model->createDate) . '</b>';
} else {
echo " ";
}
} else {
echo Yii::t('actions', 'Completed {date}', array('{date}' => Formatter::formatCompleteDate($model->completeDate)));
}
?>
</span>
<span>
<span id="controls">
<?php
if (Yii::app()->user->checkAccess('ActionsComplete', array('X2Model' => $model))) {
if ($model->complete != 'Yes') {
?>
<div class="control-button icon complete-button"
示例7: actionCreateUpdateCredentials
/**
* Basic CRUD for application credentials
* @param type $id
* @param type $class embedded model class name
* @throws CHttpException
*/
public function actionCreateUpdateCredentials($id = null, $class = null)
{
$this->pageTitle = Yii::t('app', 'Edit Credentials');
$profile = Yii::app()->params->profile;
// Create or retrieve model:
if (empty($id)) {
if (empty($class)) {
throw new CHttpException(400, 'Class must be specified when creating new credentials.');
}
$model = new Credentials();
$model->modelClass = $class;
} else {
$model = Credentials::model()->findByPk($id);
if (empty($model)) {
throw new CHttpException(404);
}
}
if ($model->getAuthModel()->getMetaData()) {
$model->setAttributes($model->getAuthModel()->getMetaData(), false);
$disableMetaDataForm = true;
}
if (in_array($model->modelClass, array('TwitterApp', 'GoogleProject'))) {
if (!Yii::app()->params->isAdmin) {
$this->denied();
}
if ($model->modelClass === 'GoogleProject') {
if (isset($_POST['Admin']['gaTracking_public'])) {
Yii::app()->settings->gaTracking_public = $_POST['Admin']['gaTracking_public'];
}
if (isset($_POST['Admin']['gaTracking_internal'])) {
Yii::app()->settings->gaTracking_internal = $_POST['Admin']['gaTracking_internal'];
}
if (isset($_POST['Admin']['googleIntegration'])) {
Yii::app()->settings->googleIntegration = $_POST['Admin']['googleIntegration'];
}
}
$this->layout = '//layouts/column1';
}
$model->scenario = $model->isNewRecord ? 'create' : 'update';
// Apply changes if any:
if (isset($_POST['Credentials'])) {
$model->attributes = $_POST['Credentials'];
// Check to see if user has permission:
if (!Yii::app()->user->checkAccess('CredentialsCreateUpdate', array('model' => $model))) {
$this->denied();
}
// Save the model:
if ($model->validate()) {
// Set timestamps
$time = time();
if ($model->isNewRecord) {
$model->createDate = $time;
}
$model->lastUpdated = $time;
if ($model->save()) {
$message = Yii::t('app', 'Saved') . ' ' . Formatter::formatLongDateTime($time);
Yii::app()->user->setFlash('success', $message);
if (in_array($model->modelClass, array('TwitterApp', 'GoogleProject'))) {
if ($model->modelClass === 'GoogleProject') {
Yii::app()->settings->save();
}
} else {
$this->redirect(array('manageCredentials'));
}
}
} else {
//AuxLib::debugLogR ($model->getErrors ());
}
}
$this->render('createUpdateCredentials', array('model' => $model, 'profile' => $profile, 'disableMetaDataForm' => isset($disableMetaDataForm) ? $disableMetaDataForm : false));
}
示例8: afterUpdate
/**
* Responds when {@link X2Model::afterUpdate()} is called (record saved, but
* not a new record). Sends a notification to anyone subscribed to this contact.
*
* Before executing this, the model must check whether the contact has the
* "changelog" behavior. That is because the behavior is disabled
* when checking for duplicates in {@link ContactsController}
*/
public function afterUpdate()
{
if (!Yii::app()->params->noSession && $this->asa('changelog') && $this->asa('changelog')->enabled) {
//$this->scenario != 'noChangelog') {
// send subscribe emails if anyone has subscribed to this contact
$result = Yii::app()->db->createCommand()->select('user_id')->from('x2_subscribe_contacts')->where('contact_id=:id', array(':id' => $this->id))->queryColumn();
$datetime = Formatter::formatLongDateTime(time());
$modelLink = CHtml::link($this->name, Yii::app()->controller->createAbsoluteUrl('/contacts/' . $this->id));
$subject = 'X2Engine: ' . $this->name . ' updated';
$message = "Hello,<br>\n<br>\n";
$message .= 'You are receiving this email because you are subscribed to changes made to the contact ' . $modelLink . ' in X2Engine. ';
$message .= 'The following changes were made on ' . $datetime . ":<br>\n<br>\n";
foreach ($this->getChanges() as $attribute => $change) {
if ($attribute != 'lastActivity') {
$old = $change[0] == '' ? '-----' : $change[0];
$new = $change[1] == '' ? '-----' : $change[1];
$label = $this->getAttributeLabel($attribute);
$message .= "{$label}: {$old} => {$new}<br>\n";
}
}
$message .= "<br>\nYou can unsubscribe to these messages by going to {$modelLink} and clicking Unsubscribe.<br>\n<br>\n";
$adminProfile = Yii::app()->params->adminProfile;
foreach ($result as $subscription) {
$subscription = array();
if (isset($subscription['user_id'])) {
$profile = X2Model::model('Profile')->findByPk($subscription['user_id']);
if ($profile && $profile->emailAddress && $adminProfile && $adminProfile->emailAddress) {
$to = array('to' => array(array($profile->fullName, $profile->emailAddress)));
Yii::app()->controller->sendUserEmail($to, $subject, $message, null, Credentials::$sysUseId['systemNotificationEmail']);
}
}
}
}
parent::afterUpdate();
}
示例9: array
}
} else {
echo Formatter::formatLongDateTime($data->dueDate);
if ($data->completeDate) {
echo ' - ' . Formatter::formatLongDateTime($data->completeDate);
}
}
echo '</b>';
} else {
if ($data->complete == 'Yes') {
echo Yii::t('actions', 'Completed {date}', array('{date}' => Formatter::formatCompleteDate($data->completeDate)));
} else {
if (!empty($data->dueDate) && (!isset($order) || $order == 'due')) {
echo Yii::t('actions', 'Due: ') . Actions::parseStatus($data->dueDate) . '</b>';
} elseif (isset($dateType) && $order == 'create' || empty($data->dueDate) && !empty($data->createDate)) {
echo Yii::t('actions', 'Created: ') . Formatter::formatLongDateTime($data->createDate) . '</b>';
} else {
echo " ";
}
}
}
?>
</div>
<div class="description" style="overflow:hidden;height:15px;text-overflow: ellipsis;white-space:nowrap;">
<?php
if ($type == 'attachment' && $data->completedBy != 'Email') {
echo Media::attachmentActionText(Yii::app()->controller->convertUrls($data->actionDescription), true, true);
} else {
if ($type == 'workflow') {
if ($data->complete == 'Yes') {
echo ' <b>' . Yii::t('workflow', 'Completed') . '</b> ' . date('Y-m-d H:i:s', $data->completeDate);
示例10: actionCreateUpdateCredentials
/**
* Basic CRUD for application credentials
* @param type $id
* @param type $class embedded model class name
* @throws CHttpException
*/
public function actionCreateUpdateCredentials($id = null, $class = null)
{
if (!Yii::app()->params->isAdmin && $class === 'TwitterApp') {
$this->denied();
}
$this->pageTitle = Yii::t('app', 'Edit Credentials');
$profile = Yii::app()->params->profile;
// Create or retrieve model:
if (empty($id)) {
if (empty($class)) {
throw new CHttpException(400, 'Class must be specified when creating new credentials.');
}
$model = new Credentials();
$model->modelClass = $class;
} else {
$model = Credentials::model()->findByPk($id);
if (empty($model)) {
throw new CHttpException(404);
}
}
if ($model->modelClass === 'TwitterApp') {
$model->private = 1;
$model->userId = Credentials::SYS_ID;
$model->name = 'Twitter app';
$disableMetaDataForm = true;
}
$model->scenario = $model->isNewRecord ? 'create' : 'update';
// Apply changes if any:
$message = null;
if (isset($_POST['Credentials'])) {
$model->attributes = $_POST['Credentials'];
// Check to see if user has permission:
if (!Yii::app()->user->checkAccess('CredentialsCreateUpdate', array('model' => $model))) {
$this->denied();
}
// Save the model:
if ($model->validate()) {
// Set timestamps
$time = time();
if ($model->isNewRecord) {
$model->createDate = $time;
}
$model->lastUpdated = $time;
if ($model->save()) {
$message = Yii::t('app', 'Saved') . ' ' . Formatter::formatLongDateTime($time);
if ($model->modelClass === 'TwitterApp') {
$this->redirect('/admin/index');
} else {
$this->redirect(array('manageCredentials'));
}
}
} else {
//AuxLib::debugLogR ($model->getErrors ());
}
}
$this->render('createUpdateCredentials', array('model' => $model, 'profile' => $profile, 'disableMetaDataForm' => isset($disableMetaDataForm) ? $disableMetaDataForm : false, 'message' => $message));
}
示例11:
echo $attributeLabels['createDate'];
?>
</td>
<td><b><?php
echo Formatter::formatLongDateTime($model->createDate);
?>
</b></td>
</tr>
<tr>
<td class="label"><?php
echo Yii::t('actions', 'Status');
?>
</td>
<td><b><?php
echo $status;
?>
</b></td>
<td class="label"><?php
echo $attributeLabels['lastUpdated'];
?>
</td>
<td><b><?php
echo Formatter::formatLongDateTime($model->lastUpdated);
?>
</b></td>
</tr>
<?php
?>
</table>
<?php
}