本文整理汇总了PHP中imageResize函数的典型用法代码示例。如果您正苦于以下问题:PHP imageResize函数的具体用法?PHP imageResize怎么用?PHP imageResize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imageResize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: copyNoPictureImage
/**
* Copy a no-product image
*
* @param string $language Language iso_code for no-picture image filename
*/
public function copyNoPictureImage($language)
{
if (isset($_FILES['no-picture']) and $_FILES['no-picture']['error'] === 0) {
if ($error = checkImage($_FILES['no-picture'], $this->maxImageSize)) {
$this->_errors[] = $error;
} else {
if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($_FILES['no-picture']['tmp_name'], $tmpName)) {
return false;
}
if (!imageResize($tmpName, _PS_IMG_DIR_ . 'p/' . $language . '.jpg')) {
$this->_errors[] = Tools::displayError('An error occurred while copying no-picture image to your product folder.');
}
if (!imageResize($tmpName, _PS_IMG_DIR_ . 'c/' . $language . '.jpg')) {
$this->_errors[] = Tools::displayError('An error occurred while copying no-picture image to your category folder.');
}
if (!imageResize($tmpName, _PS_IMG_DIR_ . 'm/' . $language . '.jpg')) {
$this->_errors[] = Tools::displayError('An error occurred while copying no-picture image to your manufacturer folder');
} else {
$imagesTypes = ImageType::getImagesTypes('products');
foreach ($imagesTypes as $k => $imageType) {
if (!imageResize($tmpName, _PS_IMG_DIR_ . 'p/' . $language . '-default-' . stripslashes($imageType['name']) . '.jpg', $imageType['width'], $imageType['height'])) {
$this->_errors[] = Tools::displayError('An error occurred while resizing no-picture image to your product directory.');
}
if (!imageResize($tmpName, _PS_IMG_DIR_ . 'c/' . $language . '-default-' . stripslashes($imageType['name']) . '.jpg', $imageType['width'], $imageType['height'])) {
$this->_errors[] = Tools::displayError('An error occurred while resizing no-picture image to your category directory.');
}
if (!imageResize($tmpName, _PS_IMG_DIR_ . 'm/' . $language . '-default-' . stripslashes($imageType['name']) . '.jpg', $imageType['width'], $imageType['height'])) {
$this->_errors[] = Tools::displayError('An error occurred while resizing no-picture image to your manufacturer directory.');
}
}
}
unlink($tmpName);
}
}
}
示例2: cacheImage
function cacheImage($image, $cacheImage, $size, $imageType = 'jpg', $disableCache = false)
{
if (file_exists($image)) {
if (!file_exists(_PS_TMP_IMG_DIR_ . $cacheImage)) {
$infos = getimagesize($image);
$memory_limit = Tools::getMemoryLimit();
// memory_limit == -1 => unlimited memory
if (function_exists('memory_get_usage') && (int) $memory_limit != -1) {
$current_memory = memory_get_usage();
// Evaluate the memory required to resize the image: if it's too much, you can't resize it.
if (($infos[0] * $infos[1] * $infos['bits'] * (isset($infos['channels']) ? $infos['channels'] / 8 : 1) + pow(2, 16)) * 1.8 + $current_memory > $memory_limit - 1024 * 1024) {
return false;
}
}
$x = $infos[0];
$y = $infos[1];
$max_x = (int) $size * 3;
/* Size is already ok */
if ($y < $size && $x <= $max_x) {
copy($image, _PS_TMP_IMG_DIR_ . $cacheImage);
} else {
$ratioX = $x / ($y / $size);
if ($ratioX > $max_x) {
$ratioX = $max_x;
$size = $y / ($x / $max_x);
}
imageResize($image, _PS_TMP_IMG_DIR_ . $cacheImage, $ratioX, $size, 'jpg');
}
}
return '<img src="' . _PS_TMP_IMG_ . $cacheImage . ($disableCache ? '?time=' . time() : '') . '" alt="" class="imgm" />';
}
return '';
}
示例3: download_files
function download_files()
{
@mkdir('bigFoto', 0777);
@mkdir('smallFoto', 0777);
$file = $_FILES['filename'];
$tmp = $file['tmp_name'];
if (file_exists($tmp)) {
$info = getimagesize($tmp);
//расширение полученной картинки
$expBigPic = substr($info['mime'], 6);
//а картинка ли это
if (preg_match('(image/(.*))is', $info['mime'], $p)) {
//адресс хранения и название картинок
$imgOrig = "bigFoto/" . time() . "." . $р[1] . "{$expBigPic}";
$imgPrev = "smallFoto/" . time() . "." . $р[1] . "png";
//загрузка картинок
move_uploaded_file($tmp, $imgOrig);
$query = "INSERT INTO bigPic VALUES (NULL, '{$imgPrev}', '{$imgOrig}', '{$expBigPic}', 0)";
mysql_query($query);
//делаем превью
imageResize($imgOrig, $info, $imgPrev);
} else {
echo '<p class="attention">Wrong format</p>';
}
} else {
echo '<p class="attention">Test version (only for study)</p>';
}
}
示例4: pictureUpload
function pictureUpload(Product $product, Cart $cart)
{
global $errors;
if (!($fieldIds = $product->getCustomizationFieldIds())) {
return false;
}
$authorizedFileFields = array();
foreach ($fieldIds as $fieldId) {
if ($fieldId['type'] == _CUSTOMIZE_FILE_) {
$authorizedFileFields[intval($fieldId['id_customization_field'])] = 'file' . intval($fieldId['id_customization_field']);
}
}
$indexes = array_flip($authorizedFileFields);
foreach ($_FILES as $fieldName => $file) {
if (in_array($fieldName, $authorizedFileFields) and isset($file['tmp_name']) and !empty($file['tmp_name'])) {
$fileName = md5(uniqid(rand(), true));
if ($error = checkImage($file, intval(Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE')))) {
$errors[] = $error;
}
if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($file['tmp_name'], $tmpName)) {
return false;
} elseif (!imageResize($tmpName, _PS_PROD_PIC_DIR_ . $fileName)) {
$errors[] = Tools::displayError('An error occurred during the image upload.');
} elseif (!imageResize($tmpName, _PS_PROD_PIC_DIR_ . $fileName . '_small', intval(Configuration::get('PS_PRODUCT_PICTURE_WIDTH')), intval(Configuration::get('PS_PRODUCT_PICTURE_HEIGHT')))) {
$errors[] = Tools::displayError('An error occurred during the image upload.');
} elseif (!chmod(_PS_PROD_PIC_DIR_ . $fileName, 0777) or !chmod(_PS_PROD_PIC_DIR_ . $fileName . '_small', 0777)) {
$errors[] = Tools::displayError('An error occurred during the image upload.');
} else {
$cart->addPictureToProduct(intval($product->id), $indexes[$fieldName], $fileName);
}
unlink($tmpName);
}
}
return true;
}
示例5: getContent
function getContent()
{
global $cookie;
/* Languages preliminaries */
$defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT'));
$languages = Language::getLanguages();
$iso = Language::getIsoById($defaultLanguage);
$isoUser = Language::getIsoById(intval($cookie->id_lang));
/* display the module name */
$this->_html = '<h2>' . $this->displayName . ' ' . $this->version . '</h2>';
/* update the editorial xml */
if (isset($_POST['submitUpdate'])) {
// Generate new XML data
$newXml = '<?xml version=\'1.0\' encoding=\'utf-8\' ?>' . "\n";
$newXml .= '<links>' . "\n";
$i = 0;
foreach ($_POST['link'] as $link) {
$newXml .= ' <link>';
foreach ($link as $key => $field) {
if ($line = $this->putContent($newXml, $key, $field)) {
$newXml .= $line;
}
}
/* upload the image */
if (isset($_FILES['link_' . $i . '_img']) and isset($_FILES['link_' . $i . '_img']['tmp_name']) and !empty($_FILES['link_' . $i . '_img']['tmp_name'])) {
Configuration::set('PS_IMAGE_GENERATION_METHOD', 1);
if ($error = checkImage($_FILES['link_' . $i . '_img'], $this->maxImageSize)) {
$this->_html .= $error;
} elseif (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($_FILES['link_' . $i . '_img']['tmp_name'], $tmpName)) {
return false;
} elseif (!imageResize($tmpName, dirname(__FILE__) . '/' . $isoUser . $i . '.jpg')) {
$this->_html .= $this->displayError($this->l('An error occurred during the image upload.'));
}
unlink($tmpName);
}
if ($line = $this->putContent($newXml, 'img', $isoUser . $i . '.jpg')) {
$newXml .= $line;
}
$newXml .= "\n" . ' </link>' . "\n";
$i++;
}
$newXml .= '</links>' . "\n";
/* write it into the editorial xml file */
if ($fd = @fopen(dirname(__FILE__) . '/' . $isoUser . 'links.xml', 'w')) {
if (!@fwrite($fd, $newXml)) {
$this->_html .= $this->displayError($this->l('Unable to write to the editor file.'));
}
if (!@fclose($fd)) {
$this->_html .= $this->displayError($this->l('Can\'t close the editor file.'));
}
} else {
$this->_html .= $this->displayError($this->l('Unable to update the editor file.<br />Please check the editor file\'s writing permissions.'));
}
}
/* display the editorial's form */
$this->_displayForm();
return $this->_html;
}
示例6: afterImageUpload
public function afterImageUpload()
{
/* Generate image with differents size */
if ($id_manufacturer = intval(Tools::getValue('id_manufacturer')) and isset($_FILES) and count($_FILES) and file_exists(_PS_MANU_IMG_DIR_ . $id_manufacturer . '.jpg')) {
$imagesTypes = ImageType::getImagesTypes('manufacturers');
foreach ($imagesTypes as $k => $imageType) {
imageResize(_PS_MANU_IMG_DIR_ . $id_manufacturer . '.jpg', _PS_MANU_IMG_DIR_ . $id_manufacturer . '-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height']));
}
}
}
示例7: addProd
public function addProd($post)
{
$lid = inserting('proizvodi', array('pro_sifra' => $post['sifra'], 'pro_naziv' => $post['naziv'], 'pro_slug' => slugging($post['naziv']), 'pro_cena' => $post['cena'], 'pro_grupa_id' => $post['grupa'], 'pro_kat_id' => $post['kategorija'], 'pro_potkat_id' => $post['potkategorija'], 'pro_marka_id' => $post['marka'], 'pro_model_id' => $post['model'], 'pro_opis' => $post['opis'], 'pro_metakeys' => $post['metakeys'], 'pro_metadesc' => $post['metadesc']));
for ($i = 0; $i < count($_FILES["slike"]["name"]); $i++) {
$file = date('dmY') . rand(1111, 9999) . $_FILES["slike"]["name"][$i];
move_uploaded_file($_FILES["slike"]["tmp_name"][$i], 'assets/images/products/' . $file);
$slid = inserting('slike', array('sli_proizvod_id' => $lid, 'sli_url' => $file));
$tgfile = 'assets/images/products/' . $file;
imageResize($tgfile, '800', '600', $tgfile, 'crop', '100');
}
}
示例8: postImage
protected function postImage($id)
{
$ret = parent::postImage($id);
if ($id_store = (int) Tools::getValue('id_store') and isset($_FILES) and sizeof($_FILES) and file_exists(_PS_STORE_IMG_DIR_ . $id_store . '.jpg')) {
$imagesTypes = ImageType::getImagesTypes('stores');
foreach ($imagesTypes as $k => $imageType) {
imageResize(_PS_STORE_IMG_DIR_ . $id_store . '.jpg', _PS_STORE_IMG_DIR_ . $id_store . '-' . stripslashes($imageType['name']) . '.jpg', (int) $imageType['width'], (int) $imageType['height']);
}
}
return $ret;
}
示例9: PageCompPageMainCode
function PageCompPageMainCode()
{
$iLimit = 30;
$aNewSizes = array('_t.jpg' => array('w' => 240, 'h' => 240, 'square' => true), '_t_2x.jpg' => array('w' => 480, 'h' => 480, 'square' => true, 'new_file' => true));
$sNewFile = false;
foreach ($aNewSizes as $sKey => $r) {
if (isset($r['new_file'])) {
$sNewFile = $sKey;
break;
}
}
$sPathPhotos = BX_DIRECTORY_PATH_MODULES . 'boonex/photos/data/files/';
if ($GLOBALS['MySQL']->getOne("SELECT COUNT(*) FROM `sys_modules` WHERE `uri` IN('photos')")) {
$aRow = $GLOBALS['MySQL']->getFirstRow("SELECT `ID`, `Ext` FROM `bx_photos_main` ORDER BY `ID` ASC");
$iCounter = 0;
while (!empty($aRow)) {
$sFileOrig = $sPathPhotos . $aRow['ID'] . '.' . $aRow['Ext'];
$sFileNew = $sNewFile ? $sPathPhotos . $aRow['ID'] . $sNewFile : false;
if ((!$sFileNew || !file_exists($sFileNew)) && file_exists($sFileOrig)) {
// file isn't already processed and original exists
// resize
foreach ($aNewSizes as $sKey => $r) {
$sFileDest = $sPathPhotos . $aRow['ID'] . $sKey;
imageResize($sFileOrig, $sFileDest, $r['w'], $r['h'], true, $r['square']);
}
++$iCounter;
}
if ($iCounter >= $iLimit) {
break;
}
$aRow = $GLOBALS['MySQL']->getNextRow();
}
if (empty($aRow)) {
$s = "All photos has been resized to the new dimentions.";
} else {
$s = "Page is reloading to resize next bunch of images...\n <script>\n setTimeout(function () {\n document.location = '" . BX_DOL_URL_ROOT . "upgrade/files/7.1.6-7.2.0/photos_resize.php?_t=" . time() . "';\n }, 1000);\n </script>";
}
} else {
$s = "Module 'Photos' isn't installed";
}
return DesignBoxContent($GLOBALS['_page']['header'], $s, $GLOBALS['oTemplConfig']->PageCompThird_db_num);
}
示例10: afterImageUpload
function afterImageUpload()
{
/* Generate image with differents size */
$obj = $this->loadObject(true);
if ($obj->id and (isset($_FILES['image']) or isset($_FILES['thumb']))) {
$imagesTypes = ImageType::getImagesTypes('scenes');
foreach ($imagesTypes as $k => $imageType) {
if ($imageType['name'] == 'large_scene' and isset($_FILES['image'])) {
imageResize($_FILES['image']['tmp_name'], _PS_SCENE_IMG_DIR_ . $obj->id . '-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height']));
} elseif ($imageType['name'] == 'thumb_scene') {
if (isset($_FILES['thumb']) and !$_FILES['thumb']['error']) {
$tmpName = $_FILES['thumb']['tmp_name'];
} else {
$tmpName = $_FILES['image']['tmp_name'];
}
imageResize($tmpName, _PS_SCENE_THUMB_IMG_DIR_ . $obj->id . '-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height']));
}
}
}
return true;
}
示例11: AddNewPostForm
//.........这里部分代码省略.........
}
if (empty($aForm['inputs']['allowComment']['value']) || !$aForm['inputs']['allowComment']['value']) {
$aForm['inputs']['allowComment']['value'] = BX_DOL_PG_ALL;
}
$oForm = new BxTemplFormView($aForm);
$oForm->initChecker();
if ($oForm->isSubmittedAndValid()) {
$this->CheckLogged();
$iOwnID = $this->_iVisitorID;
$sCurTime = time();
$sPostUri = uriGenerate(bx_get('PostCaption'), $this->_oConfig->sSQLPostsTable, 'PostUri');
$sAutoApprovalVal = getParam('blogAutoApproval') == 'on' ? "approval" : "disapproval";
$aValsAdd = array('PostDate' => $sCurTime, 'PostStatus' => $sAutoApprovalVal);
if ($iPostID == 0) {
$aValsAdd['OwnerID'] = $iOwnID;
$aValsAdd['PostUri'] = $sPostUri;
}
$iBlogPostID = -1;
if ($iPostID > 0) {
unset($aValsAdd['PostDate']);
$oForm->update($iPostID, $aValsAdd);
$this->isAllowedPostEdit($iOwnerID, true);
$iBlogPostID = $iPostID;
} else {
$iBlogPostID = $oForm->insert($aValsAdd);
$this->isAllowedPostAdd(true);
}
if ($iBlogPostID) {
$this->iLastPostedPostID = $iBlogPostID;
if ($_FILES) {
for ($i = 0; $i < count($_FILES['BlogPic']['tmp_name']); $i++) {
if ($_FILES['BlogPic']['error'][$i]) {
continue;
}
if (0 < $_FILES['BlogPic']['size'][$i] && 0 < strlen($_FILES['BlogPic']['name'][$i]) && 0 < $iBlogPostID) {
$sTmpFile = $_FILES['BlogPic']['tmp_name'][$i];
if (file_exists($sTmpFile) == false) {
break;
}
$aSize = getimagesize($sTmpFile);
if (!$aSize) {
@unlink($sTmpFile);
break;
}
switch ($aSize[2]) {
case IMAGETYPE_JPEG:
case IMAGETYPE_GIF:
case IMAGETYPE_PNG:
$sOriginalFilename = $_FILES['BlogPic']['name'][$i];
$sExt = strrchr($sOriginalFilename, '.');
$sFileName = 'blog_' . $iBlogPostID . '_' . $i;
@unlink($sFileName);
move_uploaded_file($sTmpFile, BX_BLOGS_IMAGES_PATH . $sFileName . $sExt);
@unlink($sTmpFile);
if (strlen($sExt)) {
$sPathSrc = BX_BLOGS_IMAGES_PATH . $sFileName . $sExt;
$sPathDst = BX_BLOGS_IMAGES_PATH . '%s_' . $sFileName . $sExt;
imageResize($sPathSrc, sprintf($sPathDst, 'small'), $this->iIconSize / 1, $this->iIconSize / 1);
imageResize($sPathSrc, sprintf($sPathDst, 'big'), $this->iThumbSize, $this->iThumbSize);
imageResize($sPathSrc, sprintf($sPathDst, 'browse'), $this->iBigThumbSize, null);
imageResize($sPathSrc, sprintf($sPathDst, 'orig'), $this->iImgSize, $this->iImgSize);
chmod(sprintf($sPathDst, 'small'), 0644);
chmod(sprintf($sPathDst, 'big'), 0644);
chmod(sprintf($sPathDst, 'browse'), 0644);
chmod(sprintf($sPathDst, 'orig'), 0644);
$this->_oDb->performUpdatePostWithPhoto($iBlogPostID, $sFileName . $sExt);
@unlink($sPathSrc);
}
break;
default:
@unlink($sTempFileName);
return false;
}
}
}
}
//reparse tags
bx_import('BxDolTags');
$oTags = new BxDolTags();
$oTags->reparseObjTags('blog', $iBlogPostID);
//reparse categories
$oCategories = new BxDolCategories();
$oCategories->reparseObjTags('bx_blogs', $iBlogPostID);
$sAlertAction = $iPostID == 0 ? 'create' : 'edit_post';
bx_import('BxDolAlerts');
$oZ = new BxDolAlerts('bx_blogs', $sAlertAction, $iBlogPostID, $this->_iVisitorID);
$oZ->alert();
header("X-XSS-Protection: 0");
// to prevent browser's security audit to block youtube embeds(and others), just after post creation
return $this->GenPostPage($iBlogPostID);
} else {
return MsgBox($sErrorC);
}
} else {
$sAddingForm = $oForm->getCode();
}
$sCaption = $iPostID ? $sEditPostC : $sNewPostC;
$sAddingFormVal = '<div class="blogs-view bx-def-bc-padding">' . $sAddingForm . '</div>';
return $bBox ? DesignBoxContent($sCaption, '<div class="blogs-view bx-def-bc-padding">' . $sAddingForm . '</div>', 1) : $sAddingFormVal;
}
示例12: copyImg
/**
* copyImg copy an image located in $url and save it in a path
* according to $entity->$id_entity .
* $id_image is used if we need to add a watermark
*
* @param int $id_entity id of product or category (set in entity)
* @param int $id_image (default null) id of the image if watermark enabled.
* @param string $url path or url to use
* @param string entity 'products' or 'categories'
* @return void
*/
private static function copyImg($id_entity, $id_image = NULL, $url, $entity = 'products')
{
$tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'ps_import');
$watermark_types = explode(',', Configuration::get('WATERMARK_TYPES'));
switch ($entity) {
default:
case 'products':
$imageObj = new Image($id_image);
$path = $imageObj->getPathForCreation();
break;
case 'categories':
$path = _PS_CAT_IMG_DIR_ . (int) $id_entity;
break;
}
$url_source_file = str_replace(' ', '%20', trim($url));
if (@copy($url_source_file, $tmpfile)) {
imageResize($tmpfile, $path . '.jpg');
$imagesTypes = ImageType::getImagesTypes($entity);
foreach ($imagesTypes as $k => $imageType) {
imageResize($tmpfile, $path . '-' . stripslashes($imageType['name']) . '.jpg', $imageType['width'], $imageType['height']);
}
if (in_array($imageType['id_image_type'], $watermark_types)) {
Module::hookExec('watermark', array('id_image' => $id_image, 'id_product' => $id_entity));
}
} else {
unlink($tmpfile);
return false;
}
unlink($tmpfile);
return true;
}
示例13: url
<div id="fanartRibbon" style="position: absolute; width: 125px; height: 125px; background: url(<?php
echo $baseurl;
?>
/images/game-view/ribbon-fanart.png) no-repeat; z-index: 10"></div>
<?php
if ($fanartResult = mysql_query(" SELECT b.id, b.filename FROM banners as b WHERE b.keyvalue = '{$platform->id}' AND b.keytype = 'platform-fanart' ")) {
$fanSlideCount = 0;
if (mysql_num_rows($fanartResult) > 0) {
?>
<div id="fanartSlider" class="nivoSlider">
<?php
while ($fanart = mysql_fetch_object($fanartResult)) {
// $dims = getimagesize("$baseurl/banners/$fanart->filename"); echo "$dims[0] x $dims[1]";
?>
<img class="fanartSlide imgShadow" <?php
echo imageResize("{$baseurl}/banners/{$fanart->filename}", "banners/_platformviewcache/{$fanart->filename}", 470, "width");
?>
alt="<?php
echo $game->GameTitle;
?>
Fanart" title="<?php
echo imageUsername($fanart->id);
?>
<br /><a href='<?php
echo "{$baseurl}/banners/{$fanart->filename}";
?>
' target='_blank'>View Full-Size</a> | <?php
if ($adminuserlevel == 'ADMINISTRATOR') {
echo "<a href='{$baseurl}/platform-edit/{$platform->id}/?function=Delete+Banner&bannerid={$fanart->id}'>Delete This Art</a>";
}
?>
示例14: _makeAvatarFromSharedPhoto
function _makeAvatarFromSharedPhoto($iSharedPhotoId)
{
$aImageFile = BxDolService::call('photos', 'get_photo_array', array((int) $iSharedPhotoId, 'file'), 'Search');
if (!$aImageFile) {
return false;
}
$sImagePath = BX_AVA_DIR_TMP . $this->_iProfileId . BX_AVA_EXT;
if (!@copy($aImageFile['path'], $sImagePath)) {
return false;
}
return IMAGE_ERROR_SUCCESS == imageResize($sImagePath, '', BX_AVA_PRE_RESIZE_W, BX_AVA_PRE_RESIZE_H, true) ? true : false;
}
示例15: getContent
function getContent()
{
/* display the module name */
$this->_html = '<h2>' . $this->displayName . '</h2>';
$errors = '';
/* update the editorial xml */
if (isset($_POST['submitUpdate'])) {
// Forbidden key
$forbidden = array('submitUpdate');
foreach ($_POST as $key => $value) {
if (!Validate::isString($_POST[$key])) {
$this->_html .= $this->displayError($this->l('Invalid html field, javascript is forbidden'));
$this->_displayForm();
return $this->_html;
}
}
// Generate new XML data
$newXml = '<?xml version=\'1.0\' encoding=\'utf-8\' ?>' . "\n";
$newXml .= '<editorial>' . "\n";
$newXml .= ' <header>';
// Making header data
foreach ($_POST as $key => $field) {
if ($line = $this->putContent($newXml, $key, $field, $forbidden, 'header')) {
$newXml .= $line;
}
}
$newXml .= "\n" . ' </header>' . "\n";
$newXml .= ' <body>';
// Making body data
foreach ($_POST as $key => $field) {
if ($line = $this->putContent($newXml, $key, $field, $forbidden, 'body')) {
$newXml .= $line;
}
}
$newXml .= "\n" . ' </body>' . "\n";
$newXml .= '</editorial>' . "\n";
/* write it into the editorial xml file */
if ($fd = @fopen(dirname(__FILE__) . '/editorial.xml', 'w')) {
if (!@fwrite($fd, $newXml)) {
$errors .= $this->displayError($this->l('Unable to write to the editor file.'));
}
if (!@fclose($fd)) {
$errors .= $this->displayError($this->l('Can\'t close the editor file.'));
}
} else {
$errors .= $this->displayError($this->l('Unable to update the editor file.<br />Please check the editor file\'s writing permissions.'));
}
/* upload the image */
if (isset($_FILES['body_homepage_logo']) and isset($_FILES['body_homepage_logo']['tmp_name']) and !empty($_FILES['body_homepage_logo']['tmp_name'])) {
Configuration::set('PS_IMAGE_GENERATION_METHOD', 1);
if ($error = checkImage($_FILES['body_homepage_logo'], $this->maxImageSize)) {
$errors .= $error;
} elseif (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($_FILES['body_homepage_logo']['tmp_name'], $tmpName)) {
return false;
} elseif (!imageResize($tmpName, dirname(__FILE__) . '/homepage_logo.jpg')) {
$errors .= $this->displayError($this->l('An error occurred during the image upload.'));
}
unlink($tmpName);
}
$this->_html .= $errors == '' ? $this->displayConfirmation('Settings updated successfully') : $errors;
}
/* display the editorial's form */
$this->_displayForm();
return $this->_html;
}