本文整理匯總了PHP中ImageManager類的典型用法代碼示例。如果您正苦於以下問題:PHP ImageManager類的具體用法?PHP ImageManager怎麽用?PHP ImageManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ImageManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Run
function Run()
{
//Load config
$config = new Config();
$config->Load();
$displayManager = new DisplayManager();
//Create Login Manager
$loginManager = new LoginManager();
$loginManager->Load();
$loginFail = false;
if ($loginManager->WantLogin()) {
$loginFail = !$loginManager->TryLogin();
if (!$loginFail) {
header('location: index.php');
}
}
if ($loginManager->WantLogout()) {
$loginManager->Logout();
}
if (isset($_GET['want']) and $_GET['want'] == 'logo') {
$logo = new Logo();
$logo->Generate();
return;
} elseif (isset($_GET['want']) and $_GET['want'] == 'source') {
$displayManager->DisplaySource();
} else {
if ($loginManager->IsLogged()) {
$imageManager = new ImageManager();
$images = $imageManager->GetImages();
$displayManager->DisplayImagesPage($images);
} else {
$displayManager->DisplayLoginPage($loginFail);
}
}
}
示例2: import
public function import()
{
if (File::exists(Config::get('filegallery.uploadsfolder') . '/' . Config::get('filegallery.readyfile'))) {
$files = new ImageManager(Config::get('filegallery.uploadsfolder'), Config::get('filegallery.imagesfolder'));
if (!$files->import()) {
$errors = $files->messages()->get('error');
return Redirect::to('/')->with('error', $errors[0]);
}
return Redirect::to('/')->with('success', 'Done importing images.');
}
return Redirect::to('/')->with('error', 'Not ready for import.');
}
示例3: generate
/**
* 生成驗證碼字符串,寫入SESSION,將字符串圖片返回給瀏覽器
*
* @param $len
* @param int $width
* @param int $height
* @param int $font_size
*/
public static function generate($len, $width = 108, $height = 30, $font_size = 18)
{
$sizes = array('18' => array('width' => 25, 'height' => 25));
$words = self::words($len);
session_start();
$session_key = 'captcha';
$_SESSION[$session_key] = strtolower($words);
$image = ImageManager::createWhiteImage($width, $height);
$font_config = array('spacing' => -17, 'font' => '5.ttf');
$font_path = dirname(__FILE__) . '/font/' . $font_config['font'];
$color = imagecolorallocate($image, mt_rand(0, 100), mt_rand(20, 120), mt_rand(50, 150));
$rand = 0;
$w = $sizes[$font_size]['width'] * $len;
$h = $sizes[$font_size]['height'];
$x = round(($width - $w) / 2);
$y = round(($height + $h) / 2) - 6;
$coors = imagettftext($image, $font_size, $rand, $x, $y, $color, $font_path, $words);
if ($coors) {
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Pragma: no-cache");
header("Cache-control: private");
header('Content-Type: image/png');
ob_clean();
imagepng($image);
imagedestroy($image);
}
exit;
}
示例4: run
public function run()
{
$news_repo = app(NewsRepositoryInterface::class);
// we remove all the files in the config folder
$files = glob(storage_path('app/news/*'));
foreach ($files as $file) {
if (is_file($file)) {
unlink($file);
}
}
// we create the folder if it doesn't exist
if (!is_dir($storage_path = storage_path('app/news'))) {
if (!is_dir($path = storage_path('app'))) {
mkdir($path);
}
mkdir($path . '/news');
}
// we insert the news page content
$file_name = ImageManager::optimizeAndResize(database_path('seeds/files/news/una_news.jpg'), config('image.news.background_image.name'), 'jpg', config('image.news.storage_path'), config('image.news.background_image.sizes'), false);
$inputs = ['title' => 'Les actualités du club Université Nantes Aviron (UNA)', 'description' => "## Vie du club & actualités sportives\r\n\r\nA partir de cette page, suivez les actualités du club Université Nantes Aviron (UNA).\r\nRésultats sportifs, annonces d'événements, compte-rendus de déplacements ou autres annonces diverses...\r\nNe perdez pas une miette de la vie du club !", 'background_image' => $file_name];
file_put_contents(storage_path('app/news/content.json'), json_encode($inputs));
// we create the news
$news = $news_repo->create(['author_id' => app(UserRepositoryInterface::class)->where('last_name', 'LORENT')->first()->id, 'category_id' => config('news.category_key.club'), 'key' => "rentree-2015-3-sessions-de-portes-ouvertes-a-l-una", 'title' => "Rentrée 2015 : 3 sessions de portes-ouvertes à l'UNA", 'meta_title' => 'Rentrée 2015 : portes-ouvertes', 'meta_description' => null, 'meta_keywords' => 'club, université, nantes, aviron, portes, ouvertes, rentree, 2015, sportive', 'released_at' => Carbon\Carbon::createFromDate(2015, 9, 1)->hour(17)->minute(33), 'content' => "Vous ne savez pas quel sport choisir cette année ? \r\nVous pensez à l'aviron sans n'avoir jamais osé vous lancer ? \r\nLe club Université Nantes vous convie à ses portes-ouvertes, l'occasion rêvée de vous essayer gratuitement à notre sport ! \r\n## C'est quand ? \r\nNous vous accueillons les samedis 12 septembre, 19 septembre et 10 octobre, de 10h à 17h, sans interuption. Nous misons naturellement sur des journées ensoleillées pour vous accueillir de la plus agréable des manières, cependant n'ayez crainte si quelques gouttes de pluie font leur apparition, la pratique demeure possible. \r\n## Le programme ? \r\nDes initiations gratuites pour toute la famille (à partir de 10 ans), encadrée par nos professionnels et bénévoles ! Vous vous familiariserez avec la planche à ramer, une embarcation pour débutants qui permet de découvrir le mouvement et les premières sensations de l'aviron. Pas de panique, la planche à ramer est (quasiment) insubmersible ! \r\n## Découvrez le club Université Nantes Aviron (UNA) ! \r\nL'UNA est LE club d'aviron universitaire de Nantes. Nous accueillons à la fois un public d'étudiants à l'Université de Nantes ou dans les écoles supérieures nantaises, mais également des plus jeunes à l'Ecole d'Aviron (entre 10 et 18 ans), ainsi que des moins jeunes (population d'actifs, quelque soit l'age ou le type de pratique). \r\nPour en savoir plus, rendez-vous sur notre [présentation du club](../#una 'Présentation du club'). \r\n\r\nEt pour toute question, n'hésitez pas, [contactez-nous](#contact 'Contactez-nous') ! \r\nA bientôt au club Université Nantes Aviron", 'active' => false]);
// we optimize and resize the news image
$file_name = \ImageManager::optimizeAndResize(database_path('seeds/files/news/news_po_una_september.jpg'), $news->imageName('image'), 'jpg', $news->storagePath(), $news->availableSizes('image'), false);
$news->image = $file_name;
$news->save();
// we create the news
$news = $news_repo->create(['author_id' => app(UserRepositoryInterface::class)->where('last_name', 'LORENT')->first()->id, 'category_id' => config('news.category_key.club'), 'key' => "lancement-du-nouveau-site-internet-de-l-una", 'title' => "Lancement du nouveau site Internet de l'UNA !", 'meta_title' => null, 'meta_description' => null, 'meta_keywords' => 'club, université, nantes, aviron, nouveau, site, internet, web', 'released_at' => Carbon\Carbon::createFromDate(2016, 5, 6)->hour(10)->minute(00), 'content' => "## Bienvenue sur notre nouveau site Internet !\r\nNous vous souhaitons la bienvenue sur le **nouveau site Internet du club Université Nantes Aviron (UNA)**.\r\nNous sommes heureux de vous présenter notre nouvel outil, vecteur de nos futures communication et qui permettra à tous d'accéder de manière plus facile et efficace à toutes les informations concernant l'UNA.\r\n## Toutes vos informations accessibles en ligne\r\nA travers notre nouveau site, consultez régulièrement nos [actualités sportive ou nouveautés à propos de la vie du club](../../actualites), qui seront automatiquement relayées sur nos réseaux sociaux ([Facebook](https://www.facebook.com/UniversiteNantesAviron), [Twitter](https://twitter.com/unaclub), [Google+](https://plus.google.com/+Univ-nantes-avironFr)). Découvrez également l'[historique du club](../../page/historique), l'[équipe dirigeante](../../equipe-dirigeante) de notre structure, nos [statuts associatifs](../../page/statuts), ainsi que notre [règlement intérieur](../../page/reglement-interieur). Enfin, prenez connaissance de nos [tarifs d'inscription](../../inscription), consultez nos [créneaux horaires](../../horaires) et assurez vous de rester informés de nos événements grâce à notre [calendrier](../../calendrier).\r\n## L'UNA dans votre poche\r\nDe design dit \"Responsive\", ce site **s'adapte à la taille de votre terminal** et vous permet d'accéder à toutes les pages et fonctionnalités proposées depuis vos smartphones, tablettes, ordinateurs portables ou de bureau. Grâce à cela, gardez un oeil sur le club Université Nantes Aviron (UNA), que vous soyiez en déplacement ou à la maison.\r\n## Une plateforme évolutive et collaborative\r\nLoin d'être un outil figé, le site du club Université Nantes Aviron (UNA) se veut **évolutif et à l'écoute de ses utilisateurs**. Il s'agit d'un outil fait par l'UNA et pour l'UNA. C'est ainsi que les actualités, par exemple, seront régulièrement rédigées par une équipe de rédacteurs qui ne sont autres que des rameurs du club. De plus, de nouvelles fonctionnalités telles qu'une page mettant en avant le palmares de l'UNA, un nouveau système de souscription de licence en ligne, une boutique du club en ligne, ... sont autant de fonctionnalités déjà sur le feu !\r\nNous n'en disons pas plus et vous laissons découvrir par vous même notre nouveau site.\r\nVous avez une question, vous souhaitez en savoir plus sur le club ? N'hésitez pas, [contactez-nous](../../#contact) !\r\nA bientôt au club Université Nantes Aviron (UNA).", 'active' => true]);
// we optimize and resize the news image
$file_name = \ImageManager::optimizeAndResize(database_path('seeds/files/news/news_una_new_website.jpg'), $news->imageName('image'), 'jpg', $news->storagePath(), $news->availableSizes('image'), false);
$news->image = $file_name;
$news->save();
}
示例5: createThumbnail
/**
* Create all the thumbnails for a picture.
*
* @param string $path Path to the file. This can be a virtual path or a absolute path.
* @param string $fileNamePlain Plain file name without extension
* @param string $fileExtension Extension of the file
* @param \ImageManager $imageManager
*
* <code>
* <?php
* \Cx\Core_Modules\MediaBrowser\Model\FileSystem::createThumbnail(
* 'files/',
* 'Django,
* 'jpg',
* new ImageManager() // Please recycle the instance and don't create a new anonymous instance for each call.
* // This is just a simple example.
* );
* ?>
* </code>
*
* @return array With all thumbnail types and if they were generated successfully.
*/
public static function createThumbnail($path, $fileNamePlain, $fileExtension, \ImageManager $imageManager, $generateThumbnailByRatio = false)
{
$success = array();
foreach (UploaderConfiguration::getInstance()->getThumbnails() as $thumbnail) {
if (\Cx\Lib\FileSystem\FileSystem::exists(MediaSourceManager::getAbsolutePath($path) . $fileNamePlain . $thumbnail['value'] . '.' . $fileExtension)) {
$success[$thumbnail['value']] = self::THUMBNAIL_GENERATOR_NEUTRAL;
continue;
}
if ($imageManager->_createThumb(MediaSourceManager::getAbsolutePath($path) . '/', '', $fileNamePlain . '.' . $fileExtension, $thumbnail['size'], $thumbnail['quality'], $fileNamePlain . $thumbnail['value'] . '.' . $fileExtension, $generateThumbnailByRatio)) {
$success[$thumbnail['value']] = self::THUMBNAIL_GENERATOR_SUCCESS;
continue;
}
$success[$thumbnail['value']] = self::THUMBNAIL_GENERATOR_FAIL;
}
return $success;
}
示例6: renderContent
/**
*
*/
public function renderContent($setting)
{
$t = array('name' => '', 'image' => '', 'imagesize' => '', 'alignment' => '', 'animation' => '', 'ispopup' => '1', 'imageurl' => '');
$protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://';
$url = Tools::htmlentitiesutf8($protocol . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__);
$setting = array_merge($t, $setting);
$size = explode('x', $setting['size']);
$setting['thumbnailurl'] = _PAGEBUILDER_IMAGE_URL_ . $setting['imagefile'];
$setting['imageurl'] = _PAGEBUILDER_IMAGE_URL_ . $setting['imagefile'];
if (count($size) == 2) {
$cache = _PS_CACHE_DIR_ . 'pspagebuilder/';
if (!file_exists($cache . $setting['imagefile'])) {
if (!is_dir($cache)) {
mkdir($cache, 0755);
}
if (ImageManager::resize(_PAGEBUILDER_IMAGE_DIR_ . $setting['imagefile'], $cache . $setting['imagefile'], $size[0], $size[1])) {
$setting['thumbnailurl'] = $url . 'cache/pspagebuilder/' . $setting['imagefile'];
}
} else {
$setting['thumbnailurl'] = $url . 'cache/pspagebuilder/' . $setting['imagefile'];
}
}
$output = array('type' => 'image', 'data' => $setting);
return $output;
}
示例7: renderContent
/**
*
*/
public function renderContent($setting)
{
$t = array('name' => '', 'image' => '', 'imagesize' => '80x80', 'alignment' => '', 'animation' => '', 'ispopup' => '1', 'imageurl' => '', 'icon' => '', 'widget_heading' => '', 'icon_position' => 'left');
$protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://';
$url = Tools::htmlentitiesutf8($protocol . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__);
$setting = array_merge($t, $setting);
$size = explode('x', $setting['imagesize']);
//$setting['thumbnailurl'] = $url.'modules/pspagebuilder/images/'.$setting['imagefile'];
//$setting['imageurl'] = $url.'modules/pspagebuilder/images/'.$setting['imagefile'];
$setting['thumbnailurl'] = '';
$setting['imageurl'] = '';
if (count($size) == 2 && empty($setting['icon'])) {
$cache = _PS_CACHE_DIR_ . 'pspagebuilder/';
if (!file_exists($cache . $setting['imagefile'])) {
if (!is_dir($cache)) {
mkdir($cache, 0777);
}
if (ImageManager::resize(_PAGEBUILDER_IMAGE_DIR_ . $setting['imagefile'], $cache . $setting['imagefile'], $size[0], $size[1])) {
$setting['thumbnailurl'] = $url . 'cache/pspagebuilder/' . $setting['imagefile'];
}
} else {
$setting['thumbnailurl'] = $url . 'cache/pspagebuilder/' . $setting['imagefile'];
}
}
$setting['content'] = $this->getValueByLang($setting, 'content');
$output = array('type' => 'ourservice', 'data' => $setting);
return $output;
}
示例8: afterImageUpload
protected function afterImageUpload()
{
/* Generate image with differents size */
if (!($obj = $this->loadObject(true))) {
return;
}
if ($obj->id && (isset($_FILES['image']) || isset($_FILES['thumb']))) {
$base_img_path = _PS_SCENE_IMG_DIR_ . $obj->id . '.jpg';
$images_types = ImageType::getImagesTypes('scenes');
foreach ($images_types as $k => $image_type) {
if ($image_type['name'] == 'scene_default' && isset($_FILES['image'])) {
ImageManager::resize($base_img_path, _PS_SCENE_IMG_DIR_ . $obj->id . '-' . stripslashes($image_type['name']) . '.jpg', (int) $image_type['width'], (int) $image_type['height']);
} else {
if ($image_type['name'] == 'm_scene_default') {
if (isset($_FILES['thumb']) && !$_FILES['thumb']['error']) {
$base_thumb_path = _PS_SCENE_THUMB_IMG_DIR_ . $obj->id . '.jpg';
} else {
$base_thumb_path = $base_img_path;
}
ImageManager::resize($base_thumb_path, _PS_SCENE_THUMB_IMG_DIR_ . $obj->id . '-' . stripslashes($image_type['name']) . '.jpg', (int) $image_type['width'], (int) $image_type['height']);
}
}
}
}
return true;
}
示例9: validate
protected function validate(&$file)
{
$file['error'] = $this->checkUploadError($file['error']);
if ($file['error']) {
return false;
}
$post_max_size = Tools::convertBytes(ini_get('post_max_size'));
$upload_max_filesize = Tools::convertBytes(ini_get('upload_max_filesize'));
if ($post_max_size && $this->_getServerVars('CONTENT_LENGTH') > $post_max_size) {
$file['error'] = Tools::displayError('The uploaded file exceeds the post_max_size directive in php.ini');
return false;
}
if ($upload_max_filesize && $this->_getServerVars('CONTENT_LENGTH') > $upload_max_filesize) {
$file['error'] = Tools::displayError('The uploaded file exceeds the upload_max_filesize directive in php.ini');
return false;
}
if ($error = ImageManager::validateUpload($file, Tools::getMaxUploadSize($this->getMaxSize()), $this->getAcceptTypes())) {
$file['error'] = $error;
return false;
}
if ($file['size'] > $this->getMaxSize()) {
$file['error'] = sprintf(Tools::displayError('File (size : %1s) is too big (max : %2s)'), $file['size'], $this->getMaxSize());
return false;
}
return true;
}
示例10: getContent
/**
* Returns the template's HTML content
* @return string HTML content
*/
public function getContent()
{
$invoice_address = new Address((int) $this->order->id_address_invoice);
$country = new Country((int) $invoice_address->id_country);
$formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' ');
$formatted_delivery_address = '';
if ($this->order->id_address_delivery != $this->order->id_address_invoice) {
$delivery_address = new Address((int) $this->order->id_address_delivery);
$formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' ');
}
$customer = new Customer((int) $this->order->id_customer);
$order_details = $this->order_invoice->getProducts();
if (Configuration::get('PS_PDF_IMG_INVOICE')) {
foreach ($order_details as &$order_detail) {
if ($order_detail['image'] != null) {
$name = 'product_mini_' . (int) $order_detail['product_id'] . (isset($order_detail['product_attribute_id']) ? '_' . (int) $order_detail['product_attribute_id'] : '') . '.jpg';
$order_detail['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_ . 'p/' . $order_detail['image']->getExistingImgPath() . '.jpg', $name, 45, 'jpg', false);
if (file_exists(_PS_TMP_IMG_DIR_ . $name)) {
$order_detail['image_size'] = getimagesize(_PS_TMP_IMG_DIR_ . $name);
} else {
$order_detail['image_size'] = false;
}
}
}
}
$data = array('order' => $this->order, 'order_details' => $order_details, 'cart_rules' => $this->order->getCartRules($this->order_invoice->id), 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'tax_excluded_display' => Group::getPriceDisplayMethod($customer->id_default_group), 'tax_tab' => $this->getTaxTabContent(), 'customer' => $customer);
if (Tools::getValue('debug')) {
die(json_encode($data));
}
$this->smarty->assign($data);
return $this->smarty->fetch($this->getTemplateByCountry($country->iso_code));
}
示例11: getContent
/**
* Returns the template's HTML content
*
* @return string HTML content
*/
public function getContent()
{
$delivery_address = new Address((int) $this->order->id_address_delivery);
$formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' ');
$formatted_invoice_address = '';
if ($this->order->id_address_delivery != $this->order->id_address_invoice) {
$invoice_address = new Address((int) $this->order->id_address_invoice);
$formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' ');
}
$carrier = new Carrier($this->order->id_carrier);
$carrier->name = $carrier->name == '0' ? Configuration::get('PS_SHOP_NAME') : $carrier->name;
$order_details = $this->order_invoice->getProducts();
if (Configuration::get('PS_PDF_IMG_DELIVERY')) {
foreach ($order_details as &$order_detail) {
if ($order_detail['image'] != null) {
$name = 'product_mini_' . (int) $order_detail['product_id'] . (isset($order_detail['product_attribute_id']) ? '_' . (int) $order_detail['product_attribute_id'] : '') . '.jpg';
$path = _PS_PROD_IMG_DIR_ . $order_detail['image']->getExistingImgPath() . '.jpg';
$order_detail['image_tag'] = preg_replace('/\\.*' . preg_quote(__PS_BASE_URI__, '/') . '/', _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR, ImageManager::thumbnail($path, $name, 45, 'jpg', false), 1);
if (file_exists(_PS_TMP_IMG_DIR_ . $name)) {
$order_detail['image_size'] = getimagesize(_PS_TMP_IMG_DIR_ . $name);
} else {
$order_detail['image_size'] = false;
}
}
}
}
$this->smarty->assign(array('order' => $this->order, 'order_details' => $order_details, 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'order_invoice' => $this->order_invoice, 'carrier' => $carrier, 'display_product_images' => Configuration::get('PS_PDF_IMG_DELIVERY')));
$tpls = array('style_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.style-tab')), 'addresses_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.addresses-tab')), 'summary_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.summary-tab')), 'product_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.product-tab')), 'payment_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.payment-tab')));
$this->smarty->assign($tpls);
return $this->smarty->fetch($this->getTemplate('delivery-slip'));
}
示例12: postProcess
public function postProcess()
{
if (Tools::isSubmit('submitStoreConf')) {
Configuration::updateValue('PRODUCTPAYMENTLOGOS_LINK', Tools::getValue('PRODUCTPAYMENTLOGOS_LINK'));
Configuration::updateValue('PRODUCTPAYMENTLOGOS_TITLE', Tools::getValue('PRODUCTPAYMENTLOGOS_TITLE'));
if (isset($_FILES['PRODUCTPAYMENTLOGOS_IMG']) && isset($_FILES['PRODUCTPAYMENTLOGOS_IMG']['tmp_name']) && !empty($_FILES['PRODUCTPAYMENTLOGOS_IMG']['tmp_name'])) {
if (ImageManager::validateUpload($_FILES['PRODUCTPAYMENTLOGOS_IMG'], 4000000)) {
return $this->displayError($this->l('Invalid image'));
} else {
$ext = Tools::substr($_FILES['PRODUCTPAYMENTLOGOS_IMG']['name'], Tools::strrpos($_FILES['PRODUCTPAYMENTLOGOS_IMG']['name'], '.') + 1);
$file_name = md5($_FILES['PRODUCTPAYMENTLOGOS_IMG']['name']) . '.' . $ext;
if (!move_uploaded_file($_FILES['PRODUCTPAYMENTLOGOS_IMG']['tmp_name'], dirname(__FILE__) . '/img/' . $file_name)) {
return $this->displayError($this->l('An error occurred while attempting to upload the file.'));
} else {
$file_path = dirname(__FILE__) . '/img/' . Configuration::get('PRODUCTPAYMENTLOGOS_IMG');
if (Configuration::hasContext('PRODUCTPAYMENTLOGOS_IMG', null, Shop::getContext()) && Configuration::get('PRODUCTPAYMENTLOGOS_IMG') != $file_name && file_exists($file_path)) {
unlink($file_path);
}
Configuration::updateValue('PRODUCTPAYMENTLOGOS_IMG', $file_name);
$this->_clearCache('productpaymentlogos.tpl');
Tools::redirectAdmin('index.php?tab=AdminModules&conf=6&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules'));
}
}
}
$this->_clearCache('productpaymentlogos.tpl');
}
return '';
}
示例13: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
ImageManager::create([]);
}
}
示例14: getContent
/**
* Returns the template's HTML content
* @return string HTML content
*/
public function getContent()
{
$delivery_address = new Address((int) $this->order->id_address_delivery);
$formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' ');
$formatted_invoice_address = '';
if ($this->order->id_address_delivery != $this->order->id_address_invoice) {
$invoice_address = new Address((int) $this->order->id_address_invoice);
$formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' ');
}
$carrier = new Carrier($this->order->id_carrier);
$carrier->name = $carrier->name == '0' ? Configuration::get('PS_SHOP_NAME') : $carrier->name;
$order_details = $this->order_invoice->getProducts();
if (Configuration::get('PS_PDF_IMG_DELIVERY')) {
foreach ($order_details as &$order_detail) {
if ($order_detail['image'] != null) {
$name = 'product_mini_' . (int) $order_detail['product_id'] . (isset($order_detail['product_attribute_id']) ? '_' . (int) $order_detail['product_attribute_id'] : '') . '.jpg';
$order_detail['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_ . 'p/' . $order_detail['image']->getExistingImgPath() . '.jpg', $name, 45, 'jpg', false);
if (file_exists(_PS_TMP_IMG_DIR_ . $name)) {
$order_detail['image_size'] = getimagesize(_PS_TMP_IMG_DIR_ . $name);
} else {
$order_detail['image_size'] = false;
}
}
}
}
$this->smarty->assign(array('order' => $this->order, 'order_details' => $order_details, 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'order_invoice' => $this->order_invoice, 'carrier' => $carrier));
return $this->smarty->fetch($this->getTemplate('delivery-slip'));
}
示例15: postProcess
public function postProcess()
{
if (Tools::isSubmit('submitStoreConf')) {
if (!($languages = Language::getLanguages(true))) {
return false;
}
$text = array();
foreach ($languages as $lang) {
$text[$lang['id_lang']] = Tools::getValue('BLOCKSTORE_TEXT_' . $lang['id_lang']);
}
Configuration::updateValue('BLOCKSTORE_TEXT', $text);
if (isset($_FILES['BLOCKSTORE_IMG']) && isset($_FILES['BLOCKSTORE_IMG']['tmp_name']) && !empty($_FILES['BLOCKSTORE_IMG']['tmp_name'])) {
if ($error = ImageManager::validateUpload($_FILES['BLOCKSTORE_IMG'], 4000000)) {
return $this->displayError($this->l('Invalid image.'));
} else {
$ext = substr($_FILES['BLOCKSTORE_IMG']['name'], strrpos($_FILES['BLOCKSTORE_IMG']['name'], '.') + 1);
$file_name = md5($_FILES['BLOCKSTORE_IMG']['name']) . '.' . $ext;
if (!move_uploaded_file($_FILES['BLOCKSTORE_IMG']['tmp_name'], dirname(__FILE__) . '/' . $file_name)) {
return $this->displayError($this->l('An error occurred while attempting to upload the file.'));
} else {
if (Configuration::hasContext('BLOCKSTORE_IMG', null, Shop::getContext()) && Configuration::get('BLOCKSTORE_IMG') != $file_name) {
@unlink(dirname(__FILE__) . '/' . Configuration::get('BLOCKSTORE_IMG'));
}
Configuration::updateValue('BLOCKSTORE_IMG', $file_name);
$this->_clearCache('blockstore.tpl');
return $this->displayConfirmation($this->l('The settings have been updated.'));
}
}
}
$this->_clearCache('blockstore.tpl');
}
return '';
}