Skip to content
This repository was archived by the owner on Oct 17, 2021. It is now read-only.

Commit 6aababa

Browse files
committed
Give some useful messages
1 parent 9300373 commit 6aababa

6 files changed

+20
-5
lines changed

automaticintroimage.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ public function onContentBeforeSave($context, $article, $isNew)
3939
return true;
4040
}
4141

42+
$images = json_decode($article->images);
43+
4244
// Check ImageMagick
4345
if (!extension_loaded('imagick'))
4446
{
47+
JFactory::getApplication()->enqueueMessage(JText::_('PLG_CONTENT_AUTOMATICINTROIMAGE_MESSAGE_IMAGICK_ERROR'), 'error');
4548
return true;
4649
}
47-
48-
$images = json_decode($article->images);
49-
50+
5051
// Return if full article image is not set or empty
5152
if (!isset($images->image_fulltext) or empty($images->image_fulltext))
5253
{
@@ -56,6 +57,7 @@ public function onContentBeforeSave($context, $article, $isNew)
5657
// Return if intro image is already set
5758
if (isset($images->image_intro) and !empty($images->image_intro))
5859
{
60+
JFactory::getApplication()->enqueueMessage(JText::_('PLG_CONTENT_AUTOMATICINTROIMAGE_MESSAGE_ALREADY_SET'), 'notice');
5961
return true;
6062
}
6163

@@ -108,6 +110,11 @@ public function onContentBeforeSave($context, $article, $isNew)
108110
if (!file_exists(JPATH_ROOT . '/' . $images->image_intro))
109111
{
110112
$thumb->writeImage(JPATH_ROOT . '/' . $images->image_intro);
113+
JFactory::getApplication()->enqueueMessage(JText::sprintf('PLG_CONTENT_AUTOMATICINTROIMAGE_MESSAGE_CREATED', $images->image_intro), 'message');
114+
}
115+
else
116+
{
117+
JFactory::getApplication()->enqueueMessage(JText::sprintf('PLG_CONTENT_AUTOMATICINTROIMAGE_MESSAGE_EXIST', $images->image_intro), 'message');
111118
}
112119

113120
$article->images = json_encode($images);

automaticintroimage.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<extension version="3.2" type="plugin" group="content" method="upgrade">
33
<name>Content - Automatic Intro Image</name>
44
<author>Mattia Verga</author>
5-
<creationDate>23 October 2016</creationDate>
5+
<creationDate>15 October 2016</creationDate>
66
<copyright>Copyright (C) 2016 Mattia Verga. All rights reserved.</copyright>
77
<license>GNU General Public License version 3 or later.</license>
88
<authorEmail>mattia.verga@tiscali.it</authorEmail>
9-
<version>1.0</version>
9+
<version>1.1</version>
1010
<description>PLG_CONTENT_AUTOMATICINTROIMAGE_XML_DESCRIPTION</description>
1111
<files>
1212
<filename plugin="automaticintroimage">automaticintroimage.php</filename>

language/en-GB/en-GB.plg_content_automaticintroimage.ini

100644100755
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ PLG_CONTENT_AUTOMATICINTROIMAGE_PARAM_SUFFIX_LABEL="Suffix of resized image"
1717
PLG_CONTENT_AUTOMATICINTROIMAGE_PARAM_SUFFIX_DESCRIPTION="This will be the suffix applied to the resized image."
1818
PLG_CONTENT_AUTOMATICINTROIMAGE_PARAM_YES="Yes"
1919
PLG_CONTENT_AUTOMATICINTROIMAGE_PARAM_NO="No"
20+
PLG_CONTENT_AUTOMATICINTROIMAGE_MESSAGE_IMAGICK_ERROR="Automatic Intro Image: imagick php module not loaded."
21+
PLG_CONTENT_AUTOMATICINTROIMAGE_MESSAGE_ALREADY_SET="Automatic Intro Image: intro image was already set."
22+
PLG_CONTENT_AUTOMATICINTROIMAGE_MESSAGE_CREATED="Automatic Intro Image: %s succesfully created and saved."
23+
PLG_CONTENT_AUTOMATICINTROIMAGE_MESSAGE_EXIST="Automatic Intro Image: %s already exist and it will not be recreated."

language/en-GB/en-GB.plg_content_automaticintroimage.sys.ini

100644100755
File mode changed.

language/it-IT/it-IT.plg_content_automaticintroimage.ini

100644100755
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ PLG_CONTENT_AUTOMATICINTROIMAGE_PARAM_SUFFIX_LABEL="Suffisso dell'immagine ridim
1717
PLG_CONTENT_AUTOMATICINTROIMAGE_PARAM_SUFFIX_DESCRIPTION="Questo sarà il suffisso applicato all'immagine ridimensionata."
1818
PLG_CONTENT_AUTOMATICINTROIMAGE_PARAM_YES=""
1919
PLG_CONTENT_AUTOMATICINTROIMAGE_PARAM_NO="No"
20+
PLG_CONTENT_AUTOMATICINTROIMAGE_MESSAGE_IMAGICK_ERROR="Automatic Intro Image: il modulo php imagick non è caricato."
21+
PLG_CONTENT_AUTOMATICINTROIMAGE_MESSAGE_ALREADY_SET="Automatic Intro Image: l'immagine introduttiva era già stata selezionata."
22+
PLG_CONTENT_AUTOMATICINTROIMAGE_MESSAGE_CREATED="Automatic Intro Image: %s creata e salvata con successo."
23+
PLG_CONTENT_AUTOMATICINTROIMAGE_MESSAGE_EXIST="Automatic Intro Image: %s esiste già e non è stata ricreata."

language/it-IT/it-IT.plg_content_automaticintroimage.sys.ini

100644100755
File mode changed.

0 commit comments

Comments
 (0)