本文整理匯總了PHP中Backend\Core\Engine\Model::getUTCDate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model::getUTCDate方法的具體用法?PHP Model::getUTCDate怎麽用?PHP Model::getUTCDate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Backend\Core\Engine\Model
的用法示例。
在下文中一共展示了Model::getUTCDate方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: validateForm
/**
* Validate the form
*/
private function validateForm()
{
if ($this->frm->isSubmitted()) {
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// validate fields
$this->frm->getField('title')->isFilled(BL::err('TitleIsRequired'));
// no errors?
if ($this->frm->isCorrect()) {
// build item
$item['title'] = $this->frm->getField('title')->getValue();
$item['language'] = BL::getWorkingLanguage();
$item['publish_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
$item['hidden'] = $this->frm->getField('hidden')->getValue();
// get the highest sequence available
$item['sequence'] = BackendGalleryModel::getMaximumCategorySequence() + 1;
// insert the item
$item['id'] = BackendGalleryModel::insertCategory($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add_category', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('categories') . '&report=added-category&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']);
}
}
}
示例2: getContent
/**
* Create the XML based on the locale items.
*/
public function getContent()
{
$charset = BackendModel::getContainer()->getParameter('kernel.charset');
// create XML
$xmlOutput = BackendLocaleModel::createXMLForExport($this->locale);
return new Response($xmlOutput, Response::HTTP_OK, ['Content-Disposition' => 'attachment; filename="locale_' . BackendModel::getUTCDate('d-m-Y') . '.xml"', 'Content-Type' => 'application/octet-stream;charset=' . $charset, 'Content-Length' => '' . mb_strlen($xmlOutput)]);
}
示例3: buildQuery
/**
* Builds the query for this datagrid
*
* @return array An array with two arguments containing the query and its parameters.
*/
private function buildQuery()
{
$parameters = array($this->id);
// start query, as you can see this query is build in the wrong place,
// because of the filter it is a special case
// wherein we allow the query to be in the actionfile itself
$query = 'SELECT i.id, UNIX_TIMESTAMP(i.sent_on) AS sent_on
FROM forms_data AS i
WHERE i.form_id = ?';
// add start date
if ($this->filter['start_date'] !== '') {
// explode date parts
$chunks = explode('/', $this->filter['start_date']);
// add condition
$query .= ' AND i.sent_on >= ?';
$parameters[] = BackendModel::getUTCDate(null, gmmktime(23, 59, 59, $chunks[1], $chunks[0], $chunks[2]));
}
// add end date
if ($this->filter['end_date'] !== '') {
// explode date parts
$chunks = explode('/', $this->filter['end_date']);
// add condition
$query .= ' AND i.sent_on <= ?';
$parameters[] = BackendModel::getUTCDate(null, gmmktime(23, 59, 59, $chunks[1], $chunks[0], $chunks[2]));
}
// new query
return array($query, $parameters);
}
示例4: validateForm
/**
* Validate the form
*/
private function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
$fields = $this->frm->getFields();
// validate fields
$fields['title']->isFilled(BL::err('TitleIsRequired'));
if ($this->frm->isCorrect()) {
// build item
$item['id'] = BackendContentBlocksModel::getMaximumId() + 1;
$item['user_id'] = BackendAuthentication::getUser()->getUserId();
$item['template'] = count($this->templates) > 1 ? $fields['template']->getValue() : $this->templates[0];
$item['language'] = BL::getWorkingLanguage();
$item['title'] = $fields['title']->getValue();
$item['text'] = $fields['text']->getValue();
$item['hidden'] = $fields['hidden']->getValue() ? 'N' : 'Y';
$item['status'] = 'active';
$item['created_on'] = BackendModel::getUTCDate();
$item['edited_on'] = BackendModel::getUTCDate();
// insert the item
$item['revision_id'] = BackendContentBlocksModel::insert($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('Index') . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']);
}
}
}
示例5: execute
/**
* Execute the action
*/
public function execute()
{
// call parent, this will probably add some general CSS/JS or other required files
parent::execute();
// action to execute
$id = \SpoonFilter::getGetValue('id', null, 0);
// no id's provided
if (empty($id) || !BackendMailmotorModel::existsMailing($id)) {
$this->redirect(BackendModel::createURLForAction('Index') . '&error=mailing-does-not-exist');
} else {
// get the mailing and reset some fields
$mailing = BackendMailmotorModel::getMailing($id);
$mailing['status'] = 'concept';
$mailing['send_on'] = null;
$mailing['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
$mailing['edited_on'] = $mailing['created_on'];
unset($mailing['recipients'], $mailing['id'], $mailing['cm_id'], $mailing['send_on_raw']);
// set groups
$groups = $mailing['groups'];
unset($mailing['groups']);
// create a new mailing based on the old one
$newId = BackendMailmotorModel::insertMailing($mailing);
// update groups for this mailing
BackendMailmotorModel::updateGroupsForMailing($newId, $groups);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_copy_mailing', array('item' => $mailing));
}
// redirect
$this->redirect(BackendModel::createURLForAction('Index') . '&report=mailing-copied&var=' . $mailing['name']);
}
示例6: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// Get api key
$this->apiKey = BackendModel::getModuleSetting($this->getModule(), 'api_key', null);
// Get uncompressed images list
$this->images = BackendCompressionModel::getImagesFromFolders();
if (!empty($this->images)) {
// Compress each image from each folder
$output = 'Compressing ' . count($this->images) . ' images...' . "<br />\r\n";
BackendCompressionModel::writeToCacheFile($output, true);
foreach ($this->images as $image) {
$tinyPNGApi = new TinyPNGApi($this->apiKey);
// Shrink the image and check if succesful
if ($tinyPNGApi->shrink($image['full_path'])) {
// Check if the file was successfully downloaded.
if ($tinyPNGApi->download($image['full_path'])) {
$output = 'Compression succesful for image ' . $image['filename'] . '. Saved ' . number_format($tinyPNGApi->getSavingSize() / 1024, 2) . ' KB' . ' bytes. (' . $tinyPNGApi->getSavingPercentage() . '%)';
BackendCompressionModel::writeToCacheFile($output);
// Save to db
$imageInfo = array('filename' => $image['filename'], 'path' => $image['full_path'], 'original_size' => $tinyPNGApi->getInputSize(), 'compressed_size' => $tinyPNGApi->getOutputSize(), 'saved_bytes' => $tinyPNGApi->getSavingSize(), 'saved_percentage' => $tinyPNGApi->getSavingPercentage(), 'checksum_hash' => sha1_file($image['full_path']), 'compressed_on' => BackendModel::getUTCDate());
BackendCompressionModel::insertImageHistory($imageInfo, $image['file_compressed_before']);
}
} else {
BackendCompressionModel::writeToCacheFile($tinyPNGApi->getErrorMessage());
}
}
BackendCompressionModel::writeToCacheFile("...Done!");
} else {
BackendCompressionModel::writeToCacheFile('There are no images that can be compressed.', true);
}
// Print the output for debug purposes
$output = BackendCompressionModel::readCacheFile();
print $output;
}
示例7: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// get parameters
$id = \SpoonFilter::getPostValue('id', null, '', 'int');
$name = trim(\SpoonFilter::getPostValue('value', null, '', 'string'));
// validate
if ($name == '') {
$this->output(self::BAD_REQUEST, null, 'no name provided');
} else {
// get existing id
$existingId = BackendMailmotorModel::getCampaignId($name);
// validate
if ($existingId !== 0 && $id !== $existingId) {
$this->output(self::ERROR, array('id' => $existingId, 'error' => true), BL::err('CampaignExists', $this->getModule()));
} else {
// build array
$item = array();
$item['id'] = $id;
$item['name'] = $name;
$item['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
// get page
$rows = BackendMailmotorModel::updateCampaign($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'edited_campaign', array('item' => $item));
// output
if ($rows !== 0) {
$this->output(self::OK, array('id' => $id), BL::msg('CampaignEdited', $this->getModule()));
} else {
$this->output(self::ERROR, null, BL::err('CampaignNotEdited', $this->getModule()));
}
}
}
}
示例8: 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();
// shorten fields
$txtName = $this->frm->getField('name');
$rbtDefaultForLanguage = $this->frm->getField('default');
// validate fields
if ($txtName->isFilled(BL::err('NameIsRequired'))) {
// check if the group exists by name
if (BackendMailmotorModel::existsGroupByName($txtName->getValue())) {
$txtName->addError(BL::err('GroupAlreadyExists'));
}
}
// no errors?
if ($this->frm->isCorrect()) {
// build item
$item['name'] = $txtName->getValue();
$item['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
$item['language'] = $rbtDefaultForLanguage->getValue() === '0' ? null : $rbtDefaultForLanguage->getValue();
$item['is_default'] = $rbtDefaultForLanguage->getChecked() ? 'Y' : 'N';
// insert the item
$item['id'] = BackendMailmotorCMHelper::insertGroup($item);
// check if all default groups were set
BackendMailmotorModel::checkDefaultGroups();
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add_group', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('Groups') . '&report=added&var=' . urlencode($item['name']) . '&highlight=id-' . $item['id']);
}
}
}
示例9: parse
/**
* Export the templates as XML.
*/
protected function parse()
{
$xml = Model::createTemplateXmlForExport($this->selectedTheme);
$filename = 'templates_' . BackendModel::getUTCDate('d-m-Y') . '.xml';
header('Content-type: text/xml');
header('Content-disposition: attachment; filename="' . $filename . '"');
echo $xml;
exit;
}
示例10: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
$isGod = BackendAuthentication::getUser()->isGod();
// get possible languages
if ($isGod) {
$possibleLanguages = array_unique(array_merge(BL::getWorkingLanguages(), BL::getInterfaceLanguages()));
} else {
$possibleLanguages = BL::getWorkingLanguages();
}
// get parameters
$language = \SpoonFilter::getPostValue('language', array_keys($possibleLanguages), null, 'string');
$module = \SpoonFilter::getPostValue('module', BackendModel::getModules(), null, 'string');
$name = \SpoonFilter::getPostValue('name', null, null, 'string');
$type = \SpoonFilter::getPostValue('type', BackendModel::getContainer()->get('database')->getEnumValues('locale', 'type'), null, 'string');
$application = \SpoonFilter::getPostValue('application', array('Backend', 'Frontend'), null, 'string');
$value = \SpoonFilter::getPostValue('value', null, null, 'string');
// validate values
if (trim($value) == '' || $language == '' || $module == '' || $type == '' || $application == '' || $application == 'Frontend' && $module != 'Core') {
$error = BL::err('InvalidValue');
}
// in case this is a 'act' type, there are special rules concerning possible values
if ($type == 'act' && !isset($error)) {
if (urlencode($value) != CommonUri::getUrl($value)) {
$error = BL::err('InvalidActionValue', $this->getModule());
}
}
// no error?
if (!isset($error)) {
// build item
$item['language'] = $language;
$item['module'] = $module;
$item['name'] = $name;
$item['type'] = $type;
$item['application'] = $application;
$item['value'] = $value;
$item['edited_on'] = BackendModel::getUTCDate();
$item['user_id'] = BackendAuthentication::getUser()->getUserId();
// does the translation exist?
if (BackendLocaleModel::existsByName($name, $type, $module, $language, $application)) {
// add the id to the item
$item['id'] = (int) BackendLocaleModel::getByName($name, $type, $module, $language, $application);
// update in db
BackendLocaleModel::update($item);
} else {
// insert in db
BackendLocaleModel::insert($item);
}
// output OK
$this->output(self::OK);
} else {
$this->output(self::ERROR, null, $error);
}
}
示例11: copy
/**
* Copy content blocks
*
* @param string $from The language code to copy the content blocks from.
* @param string $to The language code we want to copy the content blocks to.
*
* @return array
*
* @deprecated use the CopyContentBlocksToOtherLocale command
*/
public static function copy($from, $to)
{
trigger_error('Backend\\Modules\\ContentBlocks\\Engine::copy is deprecated.
Switch the CopyContentBlocksToOtherLocale command instead.', E_USER_DEPRECATED);
// get db
$db = BackendModel::getContainer()->get('database');
// init variables
$contentBlockIds = $oldIds = $newIds = array();
// copy the contentblocks
$contentBlocks = (array) $db->getRecords('SELECT * FROM content_blocks WHERE language = ? AND status = "active"', array($from));
// define counter
$i = 1;
// loop existing content blocks
foreach ($contentBlocks as $contentBlock) {
// define old id
$oldId = $contentBlock['extra_id'];
// init new block
$newBlock = array();
// build new block
$newBlock['id'] = self::getMaximumId() + $i;
$newBlock['language'] = $to;
$newBlock['created_on'] = BackendModel::getUTCDate();
$newBlock['edited_on'] = BackendModel::getUTCDate();
$newBlock['status'] = $contentBlock['status'];
$newBlock['user_id'] = BackendAuthentication::getUser()->getUserId();
$newBlock['template'] = $contentBlock['template'];
$newBlock['title'] = $contentBlock['title'];
$newBlock['text'] = $contentBlock['text'];
$newBlock['hidden'] = $contentBlock['hidden'];
// inset content block
$newId = self::insert($newBlock);
// save ids for later
$oldIds[] = $oldId;
$newIds[$oldId] = $newId;
// redefine counter
++$i;
}
// get the extra Ids for the content blocks
if (!empty($newIds)) {
// get content block extra ids
$contentBlockExtraIds = (array) $db->getRecords('SELECT revision_id, extra_id FROM content_blocks WHERE revision_id IN (' . implode(',', $newIds) . ')');
// loop new ids
foreach ($newIds as $oldId => $newId) {
foreach ($contentBlockExtraIds as $extraId) {
if ($extraId['revision_id'] == $newId) {
$contentBlockIds[$oldId] = $extraId['extra_id'];
}
}
}
}
// return contentBlockIds
return $contentBlockIds;
}
示例12: createXML
/**
* Create the XML based on the locale items.
*/
private function createXML()
{
$charset = BackendModel::getContainer()->getParameter('kernel.charset');
// create XML
$xmlOutput = BackendLocaleModel::createXMLForExport($this->locale);
// xml headers
header('Content-Disposition: attachment; filename="locale_' . BackendModel::getUTCDate('d-m-Y') . '.xml"');
header('Content-Type: application/octet-stream;charset=' . $charset);
header('Content-Length: ' . strlen($xmlOutput));
// output XML
echo $xmlOutput;
exit;
}
示例13: validateForm
/**
* Validate the form add image
*
* @return void
*/
private function validateForm()
{
//--Check if the add-image form is submitted
if ($this->frm->isSubmitted()) {
//--Clean up fields in the form
$this->frm->cleanupFields();
//--Get image field
$filImage = $this->frm->getField('images');
//--Check if the field is filled in
if ($filImage->isFilled()) {
//--Image extension and mime type
$filImage->isAllowedExtension(array('jpg', 'png', 'gif', 'jpeg'), BL::err('JPGGIFAndPNGOnly'));
$filImage->isAllowedMimeType(array('image/jpg', 'image/png', 'image/gif', 'image/jpeg'), BL::err('JPGGIFAndPNGOnly'));
//--Check if there are no errors.
$strError = $filImage->getErrors();
if ($strError === null) {
//--Get the filename
$strFilename = BackendGalleriaModel::checkFilename(substr($filImage->getFilename(), 0, 0 - (strlen($filImage->getExtension()) + 1)), $filImage->getExtension());
//--Fill in the item
$item = array();
$item["album_id"] = (int) $this->id;
$item["user_id"] = BackendAuthentication::getUser()->getUserId();
$item["language"] = BL::getWorkingLanguage();
$item["filename"] = $strFilename;
$item["description"] = "";
$item["publish_on"] = BackendModel::getUTCDate();
$item["hidden"] = "N";
$item["sequence"] = BackendGalleriaModel::getMaximumImageSequence($this->id) + 1;
//--the image path
$imagePath = FRONTEND_FILES_PATH . '/Galleria/Images';
//--create folders if needed
if (!\SpoonDirectory::exists($imagePath . '/Source')) {
\SpoonDirectory::create($imagePath . '/Source');
}
if (!\SpoonDirectory::exists($imagePath . '/128x128')) {
\SpoonDirectory::create($imagePath . '/128x128');
}
if (!\SpoonDirectory::exists($imagePath . '/800x')) {
\SpoonDirectory::create($imagePath . '/800x');
}
//--image provided?
if ($filImage->isFilled()) {
//--upload the image & generate thumbnails
$filImage->generateThumbnails($imagePath, $item["filename"]);
}
//--Add item to the database
BackendGalleriaModel::insert($item);
}
}
}
}
示例14: execute
/**
* Execute the action.
*/
public function execute()
{
// call parent, this will probably add some general CSS/JS or other required files
parent::execute();
// action to execute
$action = \SpoonFilter::getGetValue('action', array('addToGroup', 'delete'), '');
$ids = isset($_GET['id']) ? (array) $_GET['id'] : array();
$newGroupId = \SpoonFilter::getGetValue('newGroup', array_keys(BackendProfilesModel::getGroups()), '');
// no ids provided
if (empty($ids)) {
$this->redirect(BackendModel::createURLForAction('Index') . '&error=no-profiles-selected');
}
// delete the given profiles
if ($action === 'delete') {
BackendProfilesModel::delete($ids);
$report = 'deleted';
} elseif ($action === 'addToGroup') {
// add the profiles to the given group
// no group id provided
if ($newGroupId == '') {
$this->redirect(BackendModel::createURLForAction('Index') . '&error=no-group-selected');
}
// set new status
foreach ($ids as $id) {
// profile must exist
if (BackendProfilesModel::exists($id)) {
// make sure the user is not already part of this group without an expiration date
foreach (BackendProfilesModel::getProfileGroups($id) as $existingGroup) {
// if he is, skip to the next user
if ($existingGroup['group_id'] === $newGroupId) {
continue 2;
}
}
// OK, it's safe to add the user to this group
BackendProfilesModel::insertProfileGroup(array('profile_id' => $id, 'group_id' => $newGroupId, 'starts_on' => BackendModel::getUTCDate()));
}
}
// report
$report = 'added-to-group';
} else {
// unknown action
$this->redirect(BackendModel::createURLForAction('Index') . '&error=unknown-action');
}
// report
$report = (count($ids) > 1 ? 'profiles-' : 'profile-') . $report;
// redirect
$this->redirect(BackendModel::createURLForAction('Index', null, null, array('offset' => \SpoonFilter::getGetValue('offset', null, ''), 'order' => \SpoonFilter::getGetValue('order', null, ''), 'sort' => \SpoonFilter::getGetValue('sort', null, ''), 'email' => \SpoonFilter::getGetValue('email', null, ''), 'status' => \SpoonFilter::getGetValue('status', null, ''), 'group' => \SpoonFilter::getGetValue('group', null, ''))) . '&report=' . $report);
}
示例15: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// get parameters
$mailingId = \SpoonFilter::getPostValue('mailing_id', null, '', 'int');
$sendOnDate = \SpoonFilter::getPostValue('send_on_date', null, BackendModel::getUTCDate('d/m/Y'));
$sendOnTime = \SpoonFilter::getPostValue('send_on_time', null, BackendModel::getUTCDate('H:i'));
$messageDate = $sendOnDate;
// validate mailing ID
if ($mailingId == '') {
$this->output(self::BAD_REQUEST, null, 'Provide a valid mailing ID');
} else {
// validate date & time
if ($sendOnDate == '' || $sendOnTime == '') {
$this->output(self::BAD_REQUEST, null, 'Provide a valid send date date provided');
} else {
// record is empty
if (!BackendMailmotorModel::existsMailing($mailingId)) {
$this->output(self::BAD_REQUEST, null, BL::err('MailingDoesNotExist', $this->getModule()));
} else {
// reverse the date and make it a proper
$explodedDate = explode('/', $sendOnDate);
$sendOnDate = $explodedDate[2] . '-' . $explodedDate[1] . '-' . $explodedDate[0];
// calc full send timestamp
$sendTimestamp = strtotime($sendOnDate . ' ' . $sendOnTime);
// build data
$item['id'] = $mailingId;
$item['send_on'] = BackendModel::getUTCDate('Y-m-d H:i:s', $sendTimestamp);
$item['edited_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
// update mailing
BackendMailmotorModel::updateMailing($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_edit_mailing_step4', array('item' => $item));
// output
$this->output(self::OK, array('mailing_id' => $mailingId, 'timestamp' => $sendTimestamp), sprintf(BL::msg('SendOn', $this->getModule()), $messageDate, $sendOnTime));
}
}
}
}