Skip to content

Commit 7d6067d

Browse files
committed
Update to 2.0
* Generete default OG image from site logo * Add default OG image to pages without images * Fix PHP 8.2 warnings
1 parent 5375a9f commit 7d6067d

File tree

12 files changed

+131
-59
lines changed

12 files changed

+131
-59
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
## Download
1717

18-
[JUPWA v 1.29](https://github.com/Joomla-Ukraine/JUPWA/releases/download/1.29/pkg_jupwa_v1.29.zip)
18+
[JUPWA v 2.0.0](https://github.com/Joomla-Ukraine/JUPWA/releases/download/2.0.0/pkg_jupwa_v2.0.0.zip)
1919

2020
## Integration
2121

build.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
basedir=".">
44

55
<property name="VERSION"
6-
value="1.29" />
6+
value="2.0.0" />
77
<property name="JOOMLA"
88
value="4.0" />
99

packages/plg_jupwa_content/content.php

+17-5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*
1111
**/
1212

13+
use Joomla\CMS\Factory;
1314
use Joomla\CMS\Plugin\CMSPlugin;
1415
use JUPWA\Helpers\HTML;
1516
use JUPWA\Helpers\Images;
@@ -22,11 +23,20 @@
2223
class PlgJUPWAContent extends CMSPlugin
2324
{
2425
/**
25-
* @since 1.0
26-
* @var \Joomla\CMS\Application\CMSApplication
26+
* PlgJUPWASeblod constructor.
27+
*
28+
* @param $subject
29+
* @param $config
2730
*
31+
* @throws \Exception
32+
* @since 1.0
2833
*/
29-
protected $app;
34+
public function __construct(&$subject, $config)
35+
{
36+
parent::__construct($subject, $config);
37+
38+
$this->app = Factory::getApplication();
39+
}
3040

3141
/**
3242
* @param $article
@@ -149,12 +159,14 @@ private function image($article, $params)
149159
'alltxt' => $this->core($article)->text,
150160
]);
151161

152-
if($image)
162+
if($image !== '')
153163
{
154164
return Images::display($image);
155165
}
156166

157-
return false;
167+
$default_image = Images::display_default($params->get('selectimg'), $params->get('image'), $params->get('imagemain'));
168+
169+
return Images::display($default_image);
158170
}
159171

160172
/**

packages/plg_jupwa_jshopping/jshopping.php

+26-15
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,28 @@
2424
class PlgJUPWAJShopping extends CMSPlugin
2525
{
2626
/**
27-
* @since 4.0.0
28-
* @var \Joomla\CMS\Application\CMSApplication
27+
* PlgJUPWASeblod constructor.
2928
*
29+
* @param $subject
30+
* @param $config
31+
*
32+
* @throws \Exception
33+
* @since 1.0
3034
*/
31-
protected $app;
35+
public function __construct(&$subject, $config)
36+
{
37+
parent::__construct($subject, $config);
38+
39+
$this->app = Factory::getApplication();
40+
}
3241

3342
/**
3443
* @return void
3544
*
3645
* @throws \Exception
3746
* @since 1.0
3847
*/
39-
public function onJUPWASchema(): void
48+
public function onJUPWASchema($params): void
4049
{
4150
$use_schema = $this->params->get('use_schema', 0);
4251

@@ -61,9 +70,9 @@ public function onJUPWASchema(): void
6170
'sku' => $product->product_ean,
6271
'image' => [
6372
'@type' => 'ImageObject',
64-
'url' => $this->image()->image,
65-
'height' => $this->image()->width,
66-
'width' => $this->image()->height
73+
'url' => $this->image($params)->image,
74+
'height' => $this->image($params)->width,
75+
'width' => $this->image($params)->height
6776
],
6877
'offers' => [
6978
'@type' => 'AggregateOffer',
@@ -152,9 +161,9 @@ public function onJUPWAOG($params): void
152161
'params' => $params,
153162
'type' => 'product',
154163
'title' => $this->core()->title,
155-
'image' => $this->image()->image,
156-
'image_width' => $this->image()->width,
157-
'image_height' => $this->image()->height,
164+
'image' => $this->image($params)->image,
165+
'image_width' => $this->image($params)->width,
166+
'image_height' => $this->image($params)->height,
158167
'description' => $this->core()->description
159168
], [
160169
'price:amount' => $this->core()->price,
@@ -180,9 +189,9 @@ public function onJUPWATwitter($params): void
180189
OG::twitter([
181190
'params' => $params,
182191
'title' => $this->core()->title,
183-
'image' => $this->image()->image,
184-
'image_width' => $this->image()->width,
185-
'image_height' => $this->image()->height,
192+
'image' => $this->image($params)->image,
193+
'image_width' => $this->image($params)->width,
194+
'image_height' => $this->image($params)->height,
186195
'description' => $this->core()->intro
187196
]);
188197
}
@@ -193,7 +202,7 @@ public function onJUPWATwitter($params): void
193202
*
194203
* @since 1.0
195204
*/
196-
private function image(): object|bool
205+
private function image($params): object|bool
197206
{
198207
$jshopConfig = JSFactory::getConfig();
199208
$image = $this->core()->image;
@@ -205,7 +214,9 @@ private function image(): object|bool
205214
return Images::display($image);
206215
}
207216

208-
return false;
217+
$default_image = Images::display_default($params->get('selectimg'), $params->get('image'), $params->get('imagemain'));
218+
219+
return Images::display($default_image);
209220
}
210221

211222
/**

packages/plg_jupwa_seblod/seblod.php

+30-20
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*
1111
**/
1212

13+
use Joomla\CMS\Factory;
1314
use Joomla\CMS\Language\Multilanguage;
1415
use Joomla\CMS\Plugin\CMSPlugin;
1516
use JUPWA\Helpers\HTML;
@@ -24,17 +25,21 @@
2425
class PlgJUPWASeblod extends CMSPlugin
2526
{
2627
/**
27-
* @since 1.0
28-
* @var \Joomla\CMS\Application\CMSApplication
28+
* PlgJUPWASeblod constructor.
2929
*
30-
*/
31-
protected $app;
32-
33-
/**
30+
* @param $subject
31+
* @param $config
32+
*
33+
* @throws \Exception
3434
* @since 1.0
35-
* @var array
3635
*/
37-
protected array $loaded = [];
36+
public function __construct(&$subject, $config)
37+
{
38+
parent::__construct($subject, $config);
39+
40+
$this->app = Factory::getApplication();
41+
$this->loaded = [];
42+
}
3843

3944
/**
4045
* @param $article
@@ -51,9 +56,9 @@ public function onJUPWAArticleSchema($article, $params, $context): void
5156
$option = [
5257
'params' => $this->params,
5358
'title' => $this->core($article, $context)->title,
54-
'image' => $this->image($article, $params)->image,
55-
'image_width' => $this->image($article, $params)->width,
56-
'image_height' => $this->image($article, $params)->height,
59+
'image' => $this->image($article, $params, $context)->image,
60+
'image_width' => $this->image($article, $params, $context)->width,
61+
'image_height' => $this->image($article, $params, $context)->height,
5762
'description' => $this->core($article, $context)->description,
5863
'intro' => $this->core($article, $context)->intro,
5964
'article' => $article
@@ -92,9 +97,9 @@ public function onJUPWAArticleOG($article, $params, $context): void
9297
'params' => $params,
9398
'type' => $type,
9499
'title' => $this->core($article, $context)->title,
95-
'image' => $this->image($article, $context)->image,
96-
'image_width' => $this->image($article, $context)->width,
97-
'image_height' => $this->image($article, $context)->height,
100+
'image' => $this->image($article, $params, $context)->image,
101+
'image_width' => $this->image($article, $params, $context)->width,
102+
'image_height' => $this->image($article, $params, $context)->height,
98103
'description' => $this->core($article, $context)->description
99104
], [
100105
'headline' => $this->core($article, $context)->title
@@ -127,32 +132,36 @@ public function onJUPWAArticleTwitter($article, $params, $context): void
127132
OG::twitter([
128133
'params' => $params,
129134
'title' => $this->core($article, $context)->title,
130-
'image' => $this->image($article, $params)->image,
131-
'image_width' => $this->image($article, $params)->width,
132-
'image_height' => $this->image($article, $params)->height,
135+
'image' => $this->image($article, $params, $context)->image,
136+
'image_width' => $this->image($article, $params, $context)->width,
137+
'image_height' => $this->image($article, $params, $context)->height,
133138
'description' => $this->core($article, $context)->description
134139
]);
135140
}
136141
}
137142

138143
/**
139144
* @param $article
145+
* @param $params
140146
* @param $context
141147
*
142148
* @return false|object
143149
*
150+
* @throws \Exception
144151
* @since 1.0
145152
*/
146-
private function image($article, $context): object|bool
153+
private function image($article, $params, $context): object|bool
147154
{
148155
$image = $this->core($article, $context)->image;
149156

150-
if($image)
157+
if($image !== '')
151158
{
152159
return Images::display($image);
153160
}
154161

155-
return false;
162+
$default_image = Images::display_default($params->get('selectimg'), $params->get('image'), $params->get('imagemain'));
163+
164+
return Images::display($default_image);
156165
}
157166

158167
private function core($article, $context): object
@@ -215,6 +224,7 @@ public function onJUPWAAccess($context): bool
215224
}
216225

217226
/**
227+
* @param $id
218228
* @param null $attr
219229
*
220230
* @return array|bool

packages/plg_system_jupwa/jupwa.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
defined('_JEXEC') or die('Restricted access');
1414

1515
use Joomla\CMS\Document\HtmlDocument;
16+
use Joomla\CMS\Factory;
1617
use Joomla\CMS\Language\Text;
1718
use Joomla\CMS\Plugin\CMSPlugin;
1819
use Joomla\CMS\Plugin\PluginHelper;
@@ -39,13 +40,6 @@
3940
*/
4041
class plgSystemJUPWA extends CMSPlugin
4142
{
42-
/**
43-
* @since 4.0.0
44-
* @var \Joomla\CMS\Application\CMSApplication
45-
*
46-
*/
47-
protected $app;
48-
4943
/**
5044
* plgSystemJUPWA constructor.
5145
*
@@ -61,6 +55,8 @@ public function __construct(&$subject, $config)
6155

6256
$this->loadLanguage();
6357

58+
$this->app = Factory::getApplication();
59+
6460
if($this->app->isClient('site'))
6561
{
6662
return;
@@ -378,7 +374,7 @@ public function onBeforeCompileHead()
378374
}
379375

380376
// Integration
381-
$this->app->triggerEvent('onJUPWASchema');
377+
$this->app->triggerEvent('onJUPWASchema', [ $this->params ]);
382378

383379
if($this->params->get('tw') == 1)
384380
{

packages/plg_system_jupwa/jupwa.xml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
<media folder="media/jupwa"
2323
destination="jupwa">
24+
<folder>image</folder>
2425
<folder>js</folder>
2526
</media>
2627

packages/plg_system_jupwa/libraries/src/Data/Data.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ class Data
7070
'd_height' => 1024,
7171
'orientation' => 'landscape'
7272
],
73-
7473
[
7574
'width' => 1668,
7675
'height' => 2224,
@@ -85,7 +84,6 @@ class Data
8584
'd_height' => 1194,
8685
'orientation' => 'landscape'
8786
],
88-
8987
[
9088
'width' => 2048,
9189
'height' => 2732,
@@ -100,7 +98,6 @@ class Data
10098
'd_height' => 1366,
10199
'orientation' => 'landscape'
102100
],
103-
104101
[
105102
'width' => 750,
106103
'height' => 1334,
@@ -115,7 +112,6 @@ class Data
115112
'd_height' => 667,
116113
'orientation' => 'landscape'
117114
],
118-
119115
[
120116
'width' => 1242,
121117
'height' => 2208,
@@ -130,7 +126,6 @@ class Data
130126
'd_height' => 736,
131127
'orientation' => 'landscape'
132128
],
133-
134129
[
135130
'width' => 1125,
136131
'height' => 2436,
@@ -189,7 +184,7 @@ class Data
189184
'site' => ''
190185
]
191186
];
192-
187+
193188
public static string $workbox = 'https://storage.googleapis.com/workbox-cdn/releases/7.0.0/workbox-sw.js';
194189

195190
public static array $preconnect = [

packages/plg_system_jupwa/libraries/src/Helpers/Images.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public static function display_default($selectimg, $img, $imgmain): string
114114
{
115115
$img = HTMLHelper::cleanImageURL($img)->url;
116116
$imgmain = HTMLHelper::cleanImageURL($imgmain)->url;
117-
$image = Uri::base() . 'media/jupwa/jupwa.png';
117+
$image = Uri::base() . 'favicons/og_cover.png';
118118

119119
if($selectimg == 1)
120120
{

0 commit comments

Comments
 (0)