Skip to content
This repository was archived by the owner on May 5, 2023. It is now read-only.

Commit d28bf74

Browse files
committed
enh: code enhancement
new: fr-FR translation new: de-DE translation
1 parent 184232d commit d28bf74

File tree

8 files changed

+122
-42
lines changed

8 files changed

+122
-42
lines changed

com_k2.php

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ class xmap_com_k2
1414
/**
1515
* @var array
1616
*/
17-
private static $layouts = array('category', 'tag', 'user');
17+
protected static $layouts = array('category', 'tag', 'user');
1818

1919
/**
2020
* @var bool
2121
*/
22-
private static $enabled = false;
22+
protected static $enabled = false;
2323

2424
public function __construct()
2525
{
@@ -33,15 +33,15 @@ public function __construct()
3333
* @param stdClass $parent
3434
* @param array $params
3535
*
36-
* @throws Exception
36+
* @return bool
3737
*/
3838
public static function getTree($xmap, stdClass $parent, array &$params)
3939
{
4040
$uri = new JUri($parent->link);
4141

4242
if (!self::$enabled || !in_array($uri->getVar('layout'), self::$layouts))
4343
{
44-
return;
44+
return false;
4545
}
4646

4747
$params['groups'] = implode(',', JFactory::getUser()->getAuthorisedViewLevels());
@@ -55,53 +55,39 @@ public static function getTree($xmap, stdClass $parent, array &$params)
5555
$params['show_unauth'] = ($params['show_unauth'] == 1 || ($params['show_unauth'] == 2 && $xmap->view == 'xml') || ($params['show_unauth'] == 3 && $xmap->view == 'html'));
5656

5757
$params['category_priority'] = JArrayHelper::getValue($params, 'category_priority', $parent->priority);
58-
$params['category_changefreq'] = JArrayHelper::getValue($params, 'category_changefreq', $parent->changefreq);
59-
60-
if ($params['category_priority'] == -1)
61-
{
62-
$params['category_priority'] = $parent->priority;
63-
}
58+
$params['category_priority'] = ($params['category_priority'] == -1) ? $parent->priority : $params['category_priority'];
6459

65-
if ($params['category_changefreq'] == -1)
66-
{
67-
$params['category_changefreq'] = $parent->changefreq;
68-
}
60+
$params['category_changefreq'] = JArrayHelper::getValue($params, 'category_changefreq', $parent->changefreq);
61+
$params['category_changefreq'] = ($params['category_changefreq'] == -1) ? $parent->changefreq : $params['category_changefreq'];
6962

7063
$params['item_priority'] = JArrayHelper::getValue($params, 'item_priority', $parent->priority);
71-
$params['item_changefreq'] = JArrayHelper::getValue($params, 'item_changefreq', $parent->changefreq);
72-
73-
if ($params['item_priority'] == -1)
74-
{
75-
$params['item_priority'] = $parent->priority;
76-
}
64+
$params['item_priority'] = ($params['item_priority'] == -1) ? $parent->priority : $params['item_priority'];
7765

78-
if ($params['item_changefreq'] == -1)
79-
{
80-
$params['item_changefreq'] = $parent->changefreq;
81-
}
66+
$params['item_changefreq'] = JArrayHelper::getValue($params, 'item_changefreq', $parent->changefreq);
67+
$params['item_changefreq'] = ($params['item_changefreq'] == -1) ? $parent->changefreq : $params['item_changefreq'];
8268

8369
switch ($uri->getVar('layout'))
8470
{
8571
case 'category':
8672
$categories = JFactory::getApplication()->getMenu()->getItem($parent->id)->params->get('categories');
8773
if (count($categories) == 1)
8874
{
89-
self::getItems($xmap, $parent, $params, 'category', $categories[0]);
75+
return self::getItems($xmap, $parent, $params, 'category', $categories[0]);
9076
} elseif (count($categories) > 1)
9177
{
92-
self::getCategoryTree($xmap, $parent, $params, 0, $categories);
78+
return self::getCategoryTree($xmap, $parent, $params, 0, $categories);
9379
} else
9480
{
95-
self::getCategoryTree($xmap, $parent, $params, 0);
81+
return self::getCategoryTree($xmap, $parent, $params, 0);
9682
}
9783
break;
9884

9985
case 'tag':
100-
self::getItems($xmap, $parent, $params, 'tag', $uri->getVar('tag'));
86+
return self::getItems($xmap, $parent, $params, 'tag', $uri->getVar('tag'));
10187
break;
10288

10389
case 'user':
104-
self::getItems($xmap, $parent, $params, 'user', $uri->getVar('id'));
90+
return self::getItems($xmap, $parent, $params, 'user', $uri->getVar('id'));
10591
break;
10692
}
10793
}
@@ -110,10 +96,12 @@ public static function getTree($xmap, stdClass $parent, array &$params)
11096
* @param XmapDisplayerInterface $xmap
11197
* @param stdClass $parent
11298
* @param array $params
113-
* @param $mode
99+
* @param string $mode
114100
* @param int $linkId
101+
*
102+
* @return bool
115103
*/
116-
private static function getItems($xmap, stdClass $parent, array &$params, $mode, $linkId)
104+
protected static function getItems($xmap, stdClass $parent, array &$params, $mode, $linkId)
117105
{
118106
if ($mode == 'category')
119107
{
@@ -122,7 +110,7 @@ private static function getItems($xmap, stdClass $parent, array &$params, $mode,
122110

123111
if (!$params['include_items'])
124112
{
125-
return;
113+
return false;
126114
}
127115

128116
$db = JFactory::getDbo();
@@ -173,18 +161,26 @@ private static function getItems($xmap, stdClass $parent, array &$params, $mode,
173161
}
174162

175163
$db->setQuery($query);
176-
$rows = $db->loadObjectList();
164+
165+
try
166+
{
167+
$rows = $db->loadObjectList();
168+
169+
} catch (RuntimeException $e)
170+
{
171+
return false;
172+
}
177173

178174
if (empty($rows))
179175
{
180-
return;
176+
return false;
181177
}
182178

183179
$xmap->changeLevel(1);
184180

185181
foreach ($rows as $row)
186182
{
187-
$node = new stdclass;
183+
$node = new stdClass;
188184
$node->id = $parent->id;
189185
$node->name = $row->title;
190186
$node->title = $row->title;
@@ -201,6 +197,8 @@ private static function getItems($xmap, stdClass $parent, array &$params, $mode,
201197
}
202198

203199
$xmap->changeLevel(-1);
200+
201+
return true;
204202
}
205203

206204
/**
@@ -209,8 +207,10 @@ private static function getItems($xmap, stdClass $parent, array &$params, $mode,
209207
* @param array $params
210208
* @param int $parent_id
211209
* @param int[]|null $ids
210+
*
211+
* @return bool
212212
*/
213-
private static function getCategoryTree($xmap, stdClass $parent, array &$params, $parent_id, $ids = null)
213+
protected static function getCategoryTree($xmap, stdClass $parent, array &$params, $parent_id, $ids = null)
214214
{
215215
$db = JFactory::getDbo();
216216

@@ -240,18 +240,26 @@ private static function getCategoryTree($xmap, stdClass $parent, array &$params,
240240
}
241241

242242
$db->setQuery($query);
243-
$rows = $db->loadObjectList();
243+
244+
try
245+
{
246+
$rows = $db->loadObjectList();
247+
248+
} catch (RuntimeException $e)
249+
{
250+
return false;
251+
}
244252

245253
if (empty($rows))
246254
{
247-
return;
255+
return false;
248256
}
249257

250258
$xmap->changeLevel(1);
251259

252260
foreach ($rows as $row)
253261
{
254-
$node = new stdclass;
262+
$node = new stdClass;
255263
$node->id = $parent->id;
256264
$node->name = $row->name;
257265
$node->uid = $parent->uid . '_cid_' . $row->id;
@@ -268,5 +276,7 @@ private static function getCategoryTree($xmap, stdClass $parent, array &$params,
268276
}
269277

270278
$xmap->changeLevel(-1);
279+
280+
return true;
271281
}
272-
}
282+
}

com_k2.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
<languages folder="language">
1919
<language tag="en-GB">en-GB/en-GB.plg_xmap_com_k2.ini</language>
2020
<language tag="en-GB">en-GB/en-GB.plg_xmap_com_k2.sys.ini</language>
21+
<language tag="de-DE">de-DE/de-DE.plg_xmap_com_k2.ini</language>
22+
<language tag="de-DE">de-DE/de-DE.plg_xmap_com_k2.sys.ini</language>
23+
<language tag="fr-FR">fr-FR/fr-FR.plg_xmap_com_k2.ini</language>
24+
<language tag="fr-FR">fr-FR/fr-FR.plg_xmap_com_k2.sys.ini</language>
2125
</languages>
2226
<config>
2327
<fields name="params">
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
PLG_XMAP_COM_CONTENT = "Xmap - K2 Integration"
2+
PLG_XMAP_COM_CONTENT_DESC = "Unterstützung für Kategorien, Tags und Benutzer"
3+
4+
PLG_XMAP_COM_K2_INCLUDE_ITEMS_LABEL = "Beiträge einbinden"
5+
PLG_XMAP_COM_K2_INCLUDE_ITEMS_DESC = "Auswählen wann Beiträge mit in die Sitemap eingebunden werden sllen"
6+
7+
PLG_XMAP_COM_K2_SHOW_UNAUTH_LABEL = "Nicht zugängliche Links anzeigen"
8+
PLG_XMAP_COM_K2_SHOW_UNAUTH_DESC = "Wenn Ja, die Links zu registrienten Inhalte werden angezeigt auch wenn der Benutzer nicht eingeloggt ist. Der Benutzer muss sich einloggen um den kompletten Inhalt zu sehen."
9+
10+
PLG_XMAP_COM_K2_CATEGORY_PRIORITY_LABEL = "Priorität für Kategorien"
11+
PLG_XMAP_COM_K2_CATEGORY_PRIORITY_DESC = "Die Priorität für die Kategorien setzen"
12+
13+
PLG_XMAP_COM_K2_CATEGORY_CHANGE_FREQ_LABEL = "Häufigkeit der Aktualisierung für Kategorien"
14+
PLG_XMAP_COM_K2_CATEGORY_CHANGE_FREQ_DESC = "Die Häufigkeit der Aktualisierung für die Kategorien setzen"
15+
16+
PLG_XMAP_COM_K2_ITEM_PRIORITY_LABEL = "Priorität für Einträge"
17+
PLG_XMAP_COM_K2_ITEM_PRIORITY_DESC = "Die Priorität für die Einträge setzen"
18+
19+
PLG_XMAP_COM_K2_ITEM_CHANGE_FREQ_LABEL = "Häufigkeit der Aktualisierung für Einträge"
20+
PLG_XMAP_COM_K2_ITEM_CHANGE_FREQ_DESC = "Die Häufigkeit der Aktualisierung für die Einträge setzen"
21+
22+
PLG_XMAP_COM_CONTENT_OPTION_USE_PARENT_MENU = "Einstellungen des übergeordneten Menüpunkts benutzen"
23+
PLG_XMAP_COM_CONTENT_OPTION_NEVER = "Nie"
24+
PLG_XMAP_COM_CONTENT_OPTION_ALWAYS = "Immer"
25+
PLG_XMAP_COM_CONTENT_OPTION_XML_ONLY = "Nur in der XML Sitemap"
26+
PLG_XMAP_COM_CONTENT_OPTION_HTML_ONLY = "Nur in der HTML Sitemap"
27+
PLG_XMAP_COM_CONTENT_OPTION_WEEKLY = "Wöchentlich"
28+
PLG_XMAP_COM_CONTENT_OPTION_DAILY = "Täglich"
29+
PLG_XMAP_COM_CONTENT_OPTION_MONTHLY = "Monatlich"
30+
PLG_XMAP_COM_CONTENT_OPTION_YEARLY = "Jährlich"
31+
PLG_XMAP_COM_CONTENT_OPTION_HOURLY = "Stündlich"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PLG_XMAP_COM_CONTENT = "Xmap - K2 Integration"
2+
PLG_XMAP_COM_CONTENT_DESC = "Unterstützung für Kategorien, Tags und Benutzer"

language/en-GB/en-GB.plg_xmap_com_k2.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ PLG_XMAP_COM_K2_WEEKLY = "Weekly"
2828
PLG_XMAP_COM_K2_DAILY = "Daily"
2929
PLG_XMAP_COM_K2_MONTHLY = "Monthly"
3030
PLG_XMAP_COM_K2_YEARLY = "Yearly"
31-
PLG_XMAP_COM_K2_HOURLY = "Hourly"
31+
PLG_XMAP_COM_K2_HOURLY = "Hourly"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
PLG_XMAP_COM_K2 = "Xmap - K2 Integration"
2-
PLG_XMAP_COM_K2_DESC = "K2 Integration into Xmap and add support for categories, tags and users"
2+
PLG_XMAP_COM_K2_DESC = "K2 Integration into Xmap and add support for categories, tags and users"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
PLG_XMAP_COM_K2_ = "Xmap - Plugin pour K2"
2+
PLG_XMAP_COM_K2_DESC = "Ce plugin permet de prendre en charge les catégories et articles de K2 dans les plans de site générés par Xmap."
3+
4+
PLG_XMAP_COM_K2_FOLLOW_SUBCATEGORIES = "Sous-catégories"
5+
PLG_XMAP_COM_K2_FOLLOW_SUBCATEGORIES_DESC = "Sélectionnez si les sous-catégories doivent être listées ou non."
6+
7+
PLG_XMAP_COM_K2_SUPRESS_DUPLICATES = "Masquer les doublons"
8+
PLG_XMAP_COM_K2_SUPRESS_DUPLICATES_DESC = "Sélectionnez si les éléments en double doivent être masqués ou non."
9+
10+
PLG_XMAP_COM_K2_SHOW_ITEMS_LABEL = "Articles"
11+
PLG_XMAP_COM_K2_SHOW_ITEMS_LABEL_DESC = "Choisissez si, et dans quel type de plan de site, les articles doivent être inclus sous les liens des catégories."
12+
13+
PLG_XMAP_COM_K2_XML_SITEMAP = "Plan de site XML"
14+
PLG_XMAP_COM_K2_XML_SITEMAP_DESC = "Propriétés spécifiques au plans XML."
15+
16+
PLG_XMAP_COM_K2_PRIORITY = "Priorité des éléments"
17+
PLG_XMAP_COM_K2_PRIORITY_DESC = "Spécifiez la priorité pour les éléments."
18+
19+
PLG_XMAP_COM_K2_CHANGEFREQ_LABEL = "Fréquence de changement"
20+
PLG_XMAP_COM_K2_CHANGEFREQ_LABEL_DESC = "Spécifiez la fréquence de modification des éléments."
21+
22+
PLG_XMAP_COM_K2_OPTION_USE_PARENT_MENU = "Utiliser les paramètres du menu parent"
23+
PLG_XMAP_COM_K2_OPTION_NEVER = "Jamais"
24+
PLG_XMAP_COM_K2_OPTION_ALWAYS = "Toujours"
25+
PLG_XMAP_COM_K2_OPTION_XML_ONLY = "Uniquement dans le plan du site XML "
26+
PLG_XMAP_COM_K2_OPTION_HTML_ONLY = "Uniquement dans le plan du site HTML"
27+
PLG_XMAP_COM_K2_OPTION_WEEKLY = "Hebdomadaire"
28+
PLG_XMAP_COM_K2_OPTION_DAILY = "Quotidien"
29+
PLG_XMAP_COM_K2_OPTION_MONTHLY = "Mensuel"
30+
PLG_XMAP_COM_K2_OPTION_YEARLY = "Annuel"
31+
PLG_XMAP_COM_K2_OPTION_HOURLY = "Horaire"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PLG_XMAP_COM_K2_ = "Xmap - Plugin pour K2"
2+
PLG_XMAP_COM_K2_DESC = "Ce plugin permet de prendre en charge les catégories et articles de K2 dans les plans de site générés par Xmap."

0 commit comments

Comments
 (0)