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

Commit 32681c9

Browse files
committed
Adding Google Web Font script support. Thanks CSnipper!
1 parent 18e77d3 commit 32681c9

File tree

3 files changed

+82
-24
lines changed

3 files changed

+82
-24
lines changed

elements/logic.php

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,13 @@
4343
$fluidMedia = $this->params->get('fluidMedia');
4444
$fullWidth = $this->params->get('fullWidth');
4545
$googleWebFont = $this->params->get('googleWebFont');
46+
$googleWebFontSubset = $this->params->get('googleWebFontSubset');
4647
$googleWebFontTargets = htmlspecialchars($this->params->get('googleWebFontTargets'));
4748
$googleWebFont2 = $this->params->get('googleWebFont2');
49+
$googleWebFontSubset2 = $this->params->get('googleWebFontSubset2');
4850
$googleWebFontTargets2 = htmlspecialchars($this->params->get('googleWebFontTargets2'));
4951
$googleWebFont3 = $this->params->get('googleWebFont3');
52+
$googleWebFontSubset3 = $this->params->get('googleWebFontSubset3');
5053
$googleWebFontTargets3 = htmlspecialchars($this->params->get('googleWebFontTargets3'));
5154
$IECSS3 = $this->params->get('IECSS3');
5255
$IECSS3Targets = htmlspecialchars($this->params->get('IECSS3Targets'));
@@ -85,7 +88,7 @@
8588

8689
// Define fallback version number for custom style sheet
8790
if ($customStyleSheetVersion == '') {
88-
$customStyleSheetVersion = $version;
91+
$customStyleSheetVersion = $version;
8992
}
9093

9194
// Change generator tag
@@ -99,7 +102,7 @@
99102

100103
// Enable Mootols
101104
if ($loadMoo) {
102-
JHtml::_('behavior.framework', true);
105+
JHtml::_('behavior.framework', TRUE);
103106
}
104107

105108
// Enable modal pop-ups
@@ -118,7 +121,7 @@
118121
}
119122

120123
// Change Google Web Font name for CSS
121-
$googleWebFontFamily = str_replace(array('+', ':bold', ':italic'), " ", $googleWebFont);
124+
$googleWebFontFamily = str_replace(array('+', ':bold', ':italic'), " ", $googleWebFont);
122125
$googleWebFontFamily2 = str_replace(array('+', ':bold', ':italic'), " ", $googleWebFont2);
123126
$googleWebFontFamily3 = str_replace(array('+', ':bold', ':italic'), " ", $googleWebFont3);
124127

@@ -222,10 +225,8 @@
222225
$columnLayout = 'main-only';
223226

224227
if (($columnGroupAlphaCount > 0) && ($columnGroupBetaCount == 0)) :
225-
$columnLayout = 'alpha-' . $columnGroupAlphaCount . '-main';
226-
elseif (($columnGroupAlphaCount > 0) && ($columnGroupBetaCount > 0)) :
227-
$columnLayout = 'alpha-' . $columnGroupAlphaCount . '-main-beta-' . $columnGroupBetaCount;
228-
elseif (($columnGroupAlphaCount == 0) && ($columnGroupBetaCount > 0)) :
228+
$columnLayout = 'alpha-' . $columnGroupAlphaCount . '-main'; elseif (($columnGroupAlphaCount > 0) && ($columnGroupBetaCount > 0)) :
229+
$columnLayout = 'alpha-' . $columnGroupAlphaCount . '-main-beta-' . $columnGroupBetaCount; elseif (($columnGroupAlphaCount == 0) && ($columnGroupBetaCount > 0)) :
229230
$columnLayout = 'main-beta-' . $columnGroupBetaCount;
230231
endif;
231232

@@ -237,20 +238,19 @@
237238

238239
if ($view == 'article')
239240
$articleId = JRequest::getInt('id');
240-
else ($articleId = null);
241+
else ($articleId = NULL);
241242

242243
#------------------------------ Category ID -------------------------------#
243244

244-
function getCategory($id)
245-
{
245+
function getCategory($id) {
246246
$database = JFactory::getDBO();
247247
if ((JRequest::getCmd('view', 0) == "category") || (JRequest::getCmd('view', 0) == "categories")) {
248248
return $id;
249-
}
250-
elseif (JRequest::getCmd('view', 0) == "article") {
249+
} elseif (JRequest::getCmd('view', 0) == "article") {
251250
$temp = explode(":", $id);
252-
$sql = "SELECT catid FROM #__content WHERE id = " . $temp[0];
251+
$sql = "SELECT catid FROM #__content WHERE id = " . $temp[0];
253252
$database->setQuery($sql);
253+
254254
return $database->loadResult();
255255
}
256256
}
@@ -261,22 +261,21 @@ function getCategory($id)
261261

262262
if ($catId && ($inheritStyle || $inheritLayout)) {
263263

264-
function getParentCategory($id)
265-
{
264+
function getParentCategory($id) {
266265
$database = JFactory::getDBO();
267-
$sql = "SELECT parent_id
266+
$sql = "SELECT parent_id
268267
FROM #__categories
269268
WHERE id = $id";
270269
$database->setQuery($sql);
270+
271271
return $database->loadResult();
272272
}
273273

274274
$parentCategory = getParentCategory($catId);
275275

276-
function getAncestorCategories($id)
277-
{
276+
function getAncestorCategories($id) {
278277
$database = JFactory::getDBO();
279-
$sql = "SELECT b.id, b.title
278+
$sql = "SELECT b.id, b.title
280279
FROM #__categories a,
281280
#__categories b
282281
WHERE a.id = $id
@@ -285,6 +284,7 @@ function getAncestorCategories($id)
285284
AND a.id <> b.id
286285
AND b.lft > 0";
287286
$database->setQuery($sql);
287+
288288
return $database->loadObjectList();
289289
}
290290

@@ -423,15 +423,27 @@ function getAncestorCategories($id)
423423

424424
// Typography
425425
if ($googleWebFont) {
426-
$doc->addStyleSheet('http://fonts.googleapis.com/css?family=' . $googleWebFont . '');
426+
$googleWebFont = 'http://fonts.googleapis.com/css?family=' . $googleWebFont;
427+
if ($googleWebFontSubset) {
428+
$googleWebFont = $googleWebFont . '&subset=' . $googleWebFontSubset;
429+
}
430+
$doc->addStyleSheet($googleWebFont);
427431
$doc->addStyleDeclaration($googleWebFontTargets . ' {font-family:' . $googleWebFontFamily . ', serif;}');
428432
}
429433
if ($googleWebFont2) {
430-
$doc->addStyleSheet('http://fonts.googleapis.com/css?family=' . $googleWebFont2 . '');
434+
$googleWebFont2 = 'http://fonts.googleapis.com/css?family=' . $googleWebFont2;
435+
if ($googleWebFontSubset) {
436+
$googleWebFont2 = $googleWebFont2 . '&subset=' . $googleWebFontSubset2;
437+
}
438+
$doc->addStyleSheet($googleWebFont2);
431439
$doc->addStyleDeclaration($googleWebFontTargets2 . ' {font-family:' . $googleWebFontFamily2 . ', serif;}');
432440
}
433441
if ($googleWebFont3) {
434-
$doc->addStyleSheet('http://fonts.googleapis.com/css?family=' . $googleWebFont3 . '');
442+
$googleWebFont3 = 'http://fonts.googleapis.com/css?family=' . $googleWebFont3;
443+
if ($googleWebFontSubset) {
444+
$googleWebFont3 = $googleWebFont3 . '&subset=' . $googleWebFontSubset3;
445+
}
446+
$doc->addStyleSheet($googleWebFont3);
435447
$doc->addStyleDeclaration($googleWebFontTargets3 . ' {font-family:' . $googleWebFontFamily3 . ', serif;}');
436448
}
437449

@@ -475,8 +487,7 @@ function getAncestorCategories($id)
475487
}
476488
if ($siteWidth && !$fullWidth) {
477489
$doc->addCustomTag('#body-container, #header-above, #header, #footer {width: expression( document.body.clientWidth >' . ($siteWidth - 1) . ' ? "' . $siteWidth . $siteWidthUnit . '" : "auto" );margin:0 auto;}');
478-
}
479-
else {
490+
} else {
480491
$doc->addCustomTag('#body-container, #header-above {width: expression( document.body.clientWidth >' . ($siteWidth - 1) . ' ? "' . $siteWidth . $siteWidthUnit . '" : "auto" );margin:0 auto;}');
481492
}
482493
$doc->addCustomTag('</style>');

language/en-GB/en-GB.tpl_construct.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ TPL_CONSTRUCT_GOOGLE_WEB_FONT_DESC="The Google API font family to be used for he
7373
TPL_CONSTRUCT_GOOGLE_WEB_FONT_LABEL="Google Web Font"
7474
TPL_CONSTRUCT_GOOGLE_WEB_FONT_SIZE_DESC="Define the font size, including the unit of measure, of the font family defined above. Percentage is preferred. NOTE: Construct's base typography uses a font size of 76%, which is 12px in most modern browsers."
7575
TPL_CONSTRUCT_GOOGLE_WEB_FONT_SIZE_LABEL="Google Web Font Size"
76+
TPL_CONSTRUCT_GOOGLE_WEB_FONT_SUBSET_DESC="The character set (i.e. Latin, Greek, Cyrillic) to use. Use default when no subset needs to be specified."
77+
TPL_CONSTRUCT_GOOGLE_WEB_FONT_SUBSET_LABEL="Google Web Font Script"
7678
TPL_CONSTRUCT_GOOGLE_WEB_FONT_TARGETS_DESC="The HTML elements, classes or IDs to target with the above Google Web Font (eg. h1, .article-info h1, .readmore, #product465)"
7779
TPL_CONSTRUCT_GOOGLE_WEB_FONT_TARGETS_LABEL="Google Web Font Targets"
7880
TPL_CONSTRUCT_IE_CSS3_DESC="Enable the use of PIE (http://css3pie.com/) to add CSS3 support to Internet Explorer version 8 and before. Also adds pie_hover class to non-link items on hover. For performance reason, you must define the target elements below."

templateDetails.xml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,21 @@
398398
type="googlewebfont"
399399
label="TPL_CONSTRUCT_GOOGLE_WEB_FONT_LABEL"
400400
description="TPL_CONSTRUCT_GOOGLE_WEB_FONT_DESC"/>
401+
<field name="googleWebFontSubset"
402+
type="list"
403+
default=""
404+
label="TPL_CONSTRUCT_GOOGLE_WEB_FONT_SUBSET_LABEL"
405+
description="TPL_CONSTRUCT_GOOGLE_WEB_FONT_SUBSET_DESC">
406+
<option value="">Default</option>
407+
<option value="latin">Latin</option>
408+
<option value="latin-ext">Latin extended</option>
409+
<option value="cirrilic">Cirrilic</option>
410+
<option value="cirrilic-ext">Cirrilic extended</option>
411+
<option value="greek">Greek</option>
412+
<option value="greek-ext">Greek extended</option>
413+
<option value="khmer">Khmer</option>
414+
<option value="vietnamese">Vietnamese</option>
415+
</field>
401416
<field name="googleWebFontTargets"
402417
type="text"
403418
default=""
@@ -411,6 +426,21 @@
411426
default=""
412427
label="TPL_CONSTRUCT_GOOGLE_WEB_FONT_LABEL"
413428
description="TPL_CONSTRUCT_GOOGLE_WEB_FONT_DESC"/>
429+
<field name="googleWebFontSubset2"
430+
type="list"
431+
default=""
432+
label="TPL_CONSTRUCT_GOOGLE_WEB_FONT_SUBSET_LABEL"
433+
description="TPL_CONSTRUCT_GOOGLE_WEB_FONT_SUBSET_DESC">
434+
<option value="">Default</option>
435+
<option value="latin">Latin</option>
436+
<option value="latin-ext">Latin extended</option>
437+
<option value="cirrilic">Cirrilic</option>
438+
<option value="cirrilic-ext">Cirrilic extended</option>
439+
<option value="greek">Greek</option>
440+
<option value="greek-ext">Greek extended</option>
441+
<option value="khmer">Khmer</option>
442+
<option value="vietnamese">Vietnamese</option>
443+
</field>
414444
<field name="googleWebFontTargets2"
415445
type="text"
416446
default=""
@@ -424,6 +454,21 @@
424454
default=""
425455
label="TPL_CONSTRUCT_GOOGLE_WEB_FONT_LABEL"
426456
description="TPL_CONSTRUCT_GOOGLE_WEB_FONT_DESC"/>
457+
<field name="googleWebFontSubset3"
458+
type="list"
459+
default=""
460+
label="TPL_CONSTRUCT_GOOGLE_WEB_FONT_SUBSET_LABEL"
461+
description="TPL_CONSTRUCT_GOOGLE_WEB_FONT_SUBSET_DESC">
462+
<option value="">Default</option>
463+
<option value="latin">Latin</option>
464+
<option value="latin-ext">Latin extended</option>
465+
<option value="cirrilic">Cirrilic</option>
466+
<option value="cirrilic-ext">Cirrilic extended</option>
467+
<option value="greek">Greek</option>
468+
<option value="greek-ext">Greek extended</option>
469+
<option value="khmer">Khmer</option>
470+
<option value="vietnamese">Vietnamese</option>
471+
</field>
427472
<field name="googleWebFontTargets3"
428473
type="text"
429474
default=""

0 commit comments

Comments
 (0)