本文整理汇总了PHP中BackendModel::getUTCTimestamp方法的典型用法代码示例。如果您正苦于以下问题:PHP BackendModel::getUTCTimestamp方法的具体用法?PHP BackendModel::getUTCTimestamp怎么用?PHP BackendModel::getUTCTimestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BackendModel
的用法示例。
在下文中一共展示了BackendModel::getUTCTimestamp方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateForm
/**
* Validate the form.
*/
private function validateForm()
{
// is the form submitted?
if ($this->frm->isSubmitted()) {
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// get fields
$ddmGroup = $this->frm->getField('group');
$txtExpirationDate = $this->frm->getField('expiration_date');
$txtExpirationTime = $this->frm->getField('expiration_time');
// fields filled?
$ddmGroup->isFilled(BL::getError('FieldIsRequired'));
if ($txtExpirationDate->isFilled()) {
$txtExpirationDate->isValid(BL::getError('DateIsInvalid'));
}
if ($txtExpirationTime->isFilled()) {
$txtExpirationTime->isValid(BL::getError('TimeIsInvalid'));
}
// no errors?
if ($this->frm->isCorrect()) {
// build item
$values['profile_id'] = $this->id;
$values['group_id'] = $ddmGroup->getSelected();
$values['starts_on'] = BackendModel::getUTCDate();
// only format date if not empty
if ($txtExpirationDate->isFilled() && $txtExpirationTime->isFilled()) {
// format date
$values['expires_on'] = BackendModel::getUTCDate(null, BackendModel::getUTCTimestamp($txtExpirationDate, $txtExpirationTime));
}
// insert values
$id = BackendProfilesModel::insertProfileGroup($values);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_profile_add_to_group', array('item' => $values));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('edit') . '&id=' . $values['profile_id'] . '&report=membership-added&highlight=row-' . $id . '#tabGroups');
}
}
}
示例2: validateForm
/**
* Validate the form
*/
private function validateForm()
{
// is the form submitted?
if ($this->frm->isSubmitted()) {
// get the status
$status = SpoonFilter::getPostValue('status', array('active', 'draft'), 'active');
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// validate fields
$this->frm->getField('title')->isFilled(BL::err('TitleIsRequired'));
$this->frm->getField('text')->isFilled(BL::err('FieldIsRequired'));
$this->frm->getField('publish_on_date')->isValid(BL::err('DateIsInvalid'));
$this->frm->getField('publish_on_time')->isValid(BL::err('TimeIsInvalid'));
$this->frm->getField('category_id')->isFilled(BL::err('FieldIsRequired'));
// validate meta
$this->meta->validate();
// no errors?
if ($this->frm->isCorrect()) {
// build item
$item['id'] = $this->id;
$item['revision_id'] = $this->record['revision_id'];
// this is used to let our model know the status (active, archive, draft) of the edited item
$item['meta_id'] = $this->meta->save();
$item['category_id'] = (int) $this->frm->getField('category_id')->getValue();
$item['user_id'] = $this->frm->getField('user_id')->getValue();
$item['language'] = BL::getWorkingLanguage();
$item['title'] = $this->frm->getField('title')->getValue();
$item['introduction'] = $this->frm->getField('introduction')->getValue();
$item['text'] = $this->frm->getField('text')->getValue();
$item['publish_on'] = BackendModel::getUTCDate(null, BackendModel::getUTCTimestamp($this->frm->getField('publish_on_date'), $this->frm->getField('publish_on_time')));
$item['edited_on'] = BackendModel::getUTCDate();
$item['hidden'] = $this->frm->getField('hidden')->getValue();
$item['allow_comments'] = $this->frm->getField('allow_comments')->getChecked() ? 'Y' : 'N';
$item['status'] = $status;
if ($this->imageIsAllowed) {
$item['image'] = $this->record['image'];
// the image path
$imagePath = FRONTEND_FILES_PATH . '/blog/images';
// if the image should be deleted
if ($this->frm->getField('delete_image')->isChecked()) {
// delete the image
SpoonFile::delete($imagePath . '/source/' . $item['image']);
// reset the name
$item['image'] = null;
}
// new image given?
if ($this->frm->getField('image')->isFilled()) {
// delete the old image
SpoonFile::delete($imagePath . '/source/' . $this->record['image']);
// build the image name
$item['image'] = $this->meta->getURL() . '.' . $this->frm->getField('image')->getExtension();
// upload the image
$this->frm->getField('image')->moveFile($imagePath . '/source/' . $item['image']);
} elseif ($item['image'] != null) {
// get the old file extension
$imageExtension = SpoonFile::getExtension($imagePath . '/source/' . $item['image']);
// get the new image name
$newName = $this->meta->getURL() . '.' . $imageExtension;
// only change the name if there is a difference
if ($newName != $item['image']) {
// move the old file to the new name
SpoonFile::move($imagePath . '/source/' . $item['image'], $imagePath . '/source/' . $newName);
// assign the new name to the database
$item['image'] = $newName;
}
}
} else {
$item['image'] = null;
}
// update the item
$item['revision_id'] = BackendBlogModel::update($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_edit', array('item' => $item));
// recalculate comment count so the new revision has the correct count
BackendBlogModel::reCalculateCommentCount(array($this->id));
// save the tags
BackendTagsModel::saveTags($item['id'], $this->frm->getField('tags')->getValue(), $this->URL->getModule());
// active
if ($item['status'] == 'active') {
// edit search index
BackendSearchModel::saveIndex($this->getModule(), $item['id'], array('title' => $item['title'], 'text' => $item['text']));
// ping
if (BackendModel::getModuleSetting($this->URL->getModule(), 'ping_services', false)) {
BackendModel::ping(SITE_URL . BackendModel::getURLForBlock($this->URL->getModule(), 'detail') . '/' . $this->meta->getURL());
}
// build URL
$redirectUrl = BackendModel::createURLForAction('index') . '&report=edited&var=' . urlencode($item['title']) . '&id=' . $this->id . '&highlight=row-' . $item['revision_id'];
} elseif ($item['status'] == 'draft') {
// everything is saved, so redirect to the edit action
$redirectUrl = BackendModel::createURLForAction('edit') . '&report=saved-as-draft&var=' . urlencode($item['title']) . '&id=' . $item['id'] . '&draft=' . $item['revision_id'] . '&highlight=row-' . $item['revision_id'];
}
// append to redirect URL
if ($this->categoryId != null) {
$redirectUrl .= '&category=' . $this->categoryId;
}
// everything is saved, so redirect to the overview
$this->redirect($redirectUrl);
//.........这里部分代码省略.........
示例3: validateForm
/**
* Validate the form
*/
private function validateForm()
{
// is the form submitted?
if ($this->frm->isSubmitted()) {
// get the status
$status = SpoonFilter::getPostValue('status', array('active', 'draft'), 'active');
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// validate fields
$this->frm->getField('title')->isFilled(BL::err('TitleIsRequired'));
$this->frm->getField('text')->isFilled(BL::err('FieldIsRequired'));
$this->frm->getField('publish_on_date')->isValid(BL::err('DateIsInvalid'));
$this->frm->getField('publish_on_time')->isValid(BL::err('TimeIsInvalid'));
$this->frm->getField('category_id')->isFilled(BL::err('FieldIsRequired'));
if ($this->frm->getField('category_id')->getValue() == 'new_category') {
$this->frm->getField('category_id')->addError(BL::err('FieldIsRequired'));
}
if ($this->imageIsAllowed) {
// validate the image
if ($this->frm->getField('image')->isFilled()) {
// image extension and mime type
$this->frm->getField('image')->isAllowedExtension(array('jpg', 'png', 'gif', 'jpeg'), BL::err('JPGGIFAndPNGOnly'));
$this->frm->getField('image')->isAllowedMimeType(array('image/jpg', 'image/png', 'image/gif', 'image/jpeg'), BL::err('JPGGIFAndPNGOnly'));
}
}
// validate meta
$this->meta->validate();
if ($this->frm->isCorrect()) {
// build item
$item['id'] = (int) BackendBlogModel::getMaximumId() + 1;
$item['meta_id'] = $this->meta->save();
$item['category_id'] = (int) $this->frm->getField('category_id')->getValue();
$item['user_id'] = $this->frm->getField('user_id')->getValue();
$item['language'] = BL::getWorkingLanguage();
$item['title'] = $this->frm->getField('title')->getValue();
$item['introduction'] = $this->frm->getField('introduction')->getValue();
$item['text'] = $this->frm->getField('text')->getValue();
$item['publish_on'] = BackendModel::getUTCDate(null, BackendModel::getUTCTimestamp($this->frm->getField('publish_on_date'), $this->frm->getField('publish_on_time')));
$item['created_on'] = BackendModel::getUTCDate();
$item['edited_on'] = $item['created_on'];
$item['hidden'] = $this->frm->getField('hidden')->getValue();
$item['allow_comments'] = $this->frm->getField('allow_comments')->getChecked() ? 'Y' : 'N';
$item['num_comments'] = 0;
$item['status'] = $status;
if ($this->imageIsAllowed) {
// the image path
$imagePath = FRONTEND_FILES_PATH . '/blog/images';
// validate the image
if ($this->frm->getField('image')->isFilled()) {
// build the image name
$item['image'] = $this->meta->getURL() . '.' . $this->frm->getField('image')->getExtension();
// upload the image
$this->frm->getField('image')->moveFile($imagePath . '/source/' . $item['image']);
}
}
// insert the item
$item['revision_id'] = BackendBlogModel::insert($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $item));
// save the tags
BackendTagsModel::saveTags($item['id'], $this->frm->getField('tags')->getValue(), $this->URL->getModule());
// active
if ($item['status'] == 'active') {
// add search index
BackendSearchModel::saveIndex($this->getModule(), $item['id'], array('title' => $item['title'], 'text' => $item['text']));
// ping
if (BackendModel::getModuleSetting($this->getModule(), 'ping_services', false)) {
BackendModel::ping(SITE_URL . BackendModel::getURLForBlock('blog', 'detail') . '/' . $this->meta->getURL());
}
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('index') . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $item['revision_id']);
} elseif ($item['status'] == 'draft') {
// everything is saved, so redirect to the edit action
$this->redirect(BackendModel::createURLForAction('edit') . '&report=saved-as-draft&var=' . urlencode($item['title']) . '&id=' . $item['id'] . '&draft=' . $item['revision_id'] . '&highlight=row-' . $item['revision_id']);
}
}
}
}
示例4: parsePeriodPicker
/**
* Form for periodpicker
*
* @return void
* @param BackendTemplate $tpl The template to parse the period picker in.
* @param int $startTimestamp The start timestamp for the google call.
* @param int $endTimestamp The end timestamp for the google call.
* @param array[optional] $parameters The extra GET parameters to set on redirect.
*/
public static function parsePeriodPicker(BackendTemplate $tpl, $startTimestamp, $endTimestamp, $parameters = array())
{
// redefine
$startTimestamp = (int) $startTimestamp;
$endTimestamp = (int) $endTimestamp;
// assign
$tpl->assign('startTimestamp', $startTimestamp);
$tpl->assign('endTimestamp', $endTimestamp);
// create form
$frm = new BackendForm('periodPickerForm');
// create datepickers
$frm->addDate('start_date', $startTimestamp, 'range', mktime(0, 0, 0, 1, 1, 2005), time(), 'noFocus');
$frm->addDate('end_date', $endTimestamp, 'range', mktime(0, 0, 0, 1, 1, 2005), time(), 'noFocus');
// submitted
if ($frm->isSubmitted()) {
// show the form
$tpl->assign('showForm', true);
// cleanup fields
$frm->cleanupFields();
// shorten fields
$txtStartDate = $frm->getField('start_date');
$txtEndDate = $frm->getField('end_date');
// required fields
$txtStartDate->isFilled(BL::err('StartDateIsInvalid'));
$txtEndDate->isFilled(BL::err('EndDateIsInvalid'));
// dates within valid range
if ($txtStartDate->isFilled() && $txtEndDate->isFilled()) {
// valid dates
if ($txtStartDate->isValid(BL::err('StartDateIsInvalid')) && $txtEndDate->isValid(BL::err('EndDateIsInvalid'))) {
// get timestamps
$newStartDate = BackendModel::getUTCTimestamp($txtStartDate);
$newEndDate = BackendModel::getUTCTimestamp($txtEndDate);
// init valid
$valid = true;
// startdate cannot be before 2005 (earliest valid google startdate)
if ($newStartDate < mktime(0, 0, 0, 1, 1, 2005)) {
$valid = false;
} elseif ($newEndDate > time()) {
$valid = false;
} elseif ($newStartDate > $newEndDate) {
$valid = false;
}
// invalid range
if (!$valid) {
$txtStartDate->setError(BL::err('DateRangeIsInvalid'));
}
}
}
// valid
if ($frm->isCorrect()) {
// parameters
$parameters['start_timestamp'] = $newStartDate;
$parameters['end_timestamp'] = $newEndDate;
// build redirect string
$redirect = html_entity_decode(BackendModel::createURLForAction(null, null, null, $parameters));
// redirect
SpoonHTTP::redirect($redirect);
}
}
// parse
$frm->parse($tpl);
// we only allow live data fetching when the end date is today, no point in fetching and older range because it will never change
if ($endTimestamp == mktime(0, 0, 0, date('n'), date('j'), date('Y'))) {
// url of current action
$liveDataUrl = BackendModel::createURLForAction('loading') . '&redirect_action=' . Spoon::get('url')->getAction();
// page id set
if (isset($_GET['page_id']) && $_GET['page_id'] != '') {
$liveDataUrl .= '&page_id=' . (int) $_GET['page_id'];
}
// page path set
if (isset($_GET['page_path']) && $_GET['page_path'] != '') {
$liveDataUrl .= '&page_path=' . (string) $_GET['page_path'];
}
// assign
$tpl->assign('liveDataURL', $liveDataUrl);
}
}
示例5: validateForm
/**
* Validate the form
*
* @return void
*/
private function validateForm()
{
// is the form submitted?
if ($this->frm->isSubmitted()) {
// set callback for generating an unique URL
$this->meta->setUrlCallback('BackendBlogModel', 'getURL', array($this->record['id']));
// get the status
$status = SpoonFilter::getPostValue('status', array('active', 'draft'), 'active');
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// validate fields
$this->frm->getField('title')->isFilled(BL::err('TitleIsRequired'));
$this->frm->getField('text')->isFilled(BL::err('FieldIsRequired'));
$this->frm->getField('publish_on_date')->isValid(BL::err('DateIsInvalid'));
$this->frm->getField('publish_on_time')->isValid(BL::err('TimeIsInvalid'));
$this->frm->getField('category_id')->isFilled(BL::err('FieldIsRequired'));
// validate meta
$this->meta->validate();
// no errors?
if ($this->frm->isCorrect()) {
// build item
$item['id'] = $this->id;
$item['revision_id'] = $this->record['revision_id'];
// this is used to let our model know the status (active, archive, draft) of the edited item
$item['meta_id'] = $this->meta->save();
$item['category_id'] = (int) $this->frm->getField('category_id')->getValue();
$item['user_id'] = $this->frm->getField('user_id')->getValue();
$item['language'] = BL::getWorkingLanguage();
$item['title'] = $this->frm->getField('title')->getValue();
$item['introduction'] = $this->frm->getField('introduction')->getValue();
$item['text'] = $this->frm->getField('text')->getValue();
$item['publish_on'] = BackendModel::getUTCDate(null, BackendModel::getUTCTimestamp($this->frm->getField('publish_on_date'), $this->frm->getField('publish_on_time')));
$item['edited_on'] = BackendModel::getUTCDate();
$item['hidden'] = $this->frm->getField('hidden')->getValue();
$item['allow_comments'] = $this->frm->getField('allow_comments')->getChecked() ? 'Y' : 'N';
$item['status'] = $status;
// update the item
$item['revision_id'] = BackendBlogModel::update($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_edit', array('item' => $item));
// recalculate comment count so the new revision has the correct count
BackendBlogModel::reCalculateCommentCount(array($this->id));
// save the tags
BackendTagsModel::saveTags($item['id'], $this->frm->getField('tags')->getValue(), $this->URL->getModule());
// active
if ($item['status'] == 'active') {
// edit search index
if (is_callable(array('BackendSearchModel', 'editIndex'))) {
BackendSearchModel::editIndex($this->getModule(), $item['id'], array('title' => $item['title'], 'text' => $item['text']));
}
// ping
if (BackendModel::getModuleSetting($this->URL->getModule(), 'ping_services', false)) {
BackendModel::ping(SITE_URL . BackendModel::getURLForBlock($this->URL->getModule(), 'detail') . '/' . $this->meta->getURL());
}
// build URL
$redirectUrl = BackendModel::createURLForAction('index') . '&report=edited&var=' . urlencode($item['title']) . '&id=' . $this->id . '&highlight=row-' . $item['revision_id'];
} elseif ($item['status'] == 'draft') {
// everything is saved, so redirect to the edit action
$redirectUrl = BackendModel::createURLForAction('edit') . '&report=saved-as-draft&var=' . urlencode($item['title']) . '&id=' . $item['id'] . '&draft=' . $item['revision_id'] . '&highlight=row-' . $item['revision_id'];
}
// append to redirect URL
if ($this->categoryId != null) {
$redirectUrl .= '&category=' . $this->categoryId;
}
// everything is saved, so redirect to the overview
$this->redirect($redirectUrl);
}
}
}