本文整理汇总了PHP中Gdn_UploadImage::isUpload方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_UploadImage::isUpload方法的具体用法?PHP Gdn_UploadImage::isUpload怎么用?PHP Gdn_UploadImage::isUpload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn_UploadImage
的用法示例。
在下文中一共展示了Gdn_UploadImage::isUpload方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: emailStyles
/**
* Settings page for HTML email styling.
*
* Exposes config settings:
* Garden.EmailTemplate.BackgroundColor
* Garden.EmailTemplate.ButtonBackgroundColor
* Garden.EmailTemplate.ButtonTextColor
* Garden.EmailTemplate.Image
*
* Saves the image based on 2 config settings:
* Garden.EmailTemplate.ImageMaxWidth (default 400px) and
* Garden.EmailTemplate.ImageMaxHeight (default 300px)
*
* @throws Gdn_UserException
*/
public function emailStyles()
{
// Set default colors
if (!c('Garden.EmailTemplate.TextColor')) {
saveToConfig('Garden.EmailTemplate.TextColor', EmailTemplate::DEFAULT_TEXT_COLOR, false);
}
if (!c('Garden.EmailTemplate.BackgroundColor')) {
saveToConfig('Garden.EmailTemplate.BackgroundColor', EmailTemplate::DEFAULT_BACKGROUND_COLOR, false);
}
if (!c('Garden.EmailTemplate.ContainerBackgroundColor')) {
saveToConfig('Garden.EmailTemplate.ContainerBackgroundColor', EmailTemplate::DEFAULT_CONTAINER_BACKGROUND_COLOR, false);
}
if (!c('Garden.EmailTemplate.ButtonTextColor')) {
saveToConfig('Garden.EmailTemplate.ButtonTextColor', EmailTemplate::DEFAULT_BUTTON_TEXT_COLOR, false);
}
if (!c('Garden.EmailTemplate.ButtonBackgroundColor')) {
saveToConfig('Garden.EmailTemplate.ButtonBackgroundColor', EmailTemplate::DEFAULT_BUTTON_BACKGROUND_COLOR, false);
}
$this->permission('Garden.Settings.Manage');
$this->setHighlightRoute('dashboard/settings/emailstyles');
$this->addJsFile('email.js');
// Get the current logo.
$image = c('Garden.EmailTemplate.Image');
if ($image) {
$image = ltrim($image, '/');
$this->setData('EmailImage', Gdn_UploadImage::url($image));
}
$this->Form = new Gdn_Form();
$validation = new Gdn_Validation();
$configurationModel = new Gdn_ConfigurationModel($validation);
$configurationModel->setField(array('Garden.EmailTemplate.TextColor', 'Garden.EmailTemplate.BackgroundColor', 'Garden.EmailTemplate.ContainerBackgroundColor', 'Garden.EmailTemplate.ButtonTextColor', 'Garden.EmailTemplate.ButtonBackgroundColor'));
// Set the model on the form.
$this->Form->setModel($configurationModel);
// If seeing the form for the first time...
if ($this->Form->authenticatedPostBack() === false) {
// Apply the config settings to the form.
$this->Form->setData($configurationModel->Data);
} else {
$image = c('Garden.EmailTemplate.Image');
$upload = new Gdn_UploadImage();
if ($upload->isUpload('EmailImage')) {
try {
$tmpImage = $upload->validateUpload('EmailImage');
if ($tmpImage) {
// Generate the target image name
$targetImage = $upload->generateTargetName(PATH_UPLOADS);
$imageBaseName = pathinfo($targetImage, PATHINFO_BASENAME);
// Delete any previously uploaded images.
if ($image) {
$upload->delete($image);
}
// Save the uploaded image
$parts = $upload->saveImageAs($tmpImage, $imageBaseName, c('Garden.EmailTemplate.ImageMaxWidth', 400), c('Garden.EmailTemplate.ImageMaxHeight', 300));
$imageBaseName = $parts['SaveName'];
saveToConfig('Garden.EmailTemplate.Image', $imageBaseName);
$this->setData('EmailImage', Gdn_UploadImage::url($imageBaseName));
}
} catch (Exception $ex) {
$this->Form->addError($ex);
}
}
if ($this->Form->save() !== false) {
$this->informMessage(t("Your settings have been saved."));
}
}
$this->render();
}