33
44class ThisTemplateHelper
55{
6- static public function isHome ()
6+ public function getDocument ()
7+ {
8+ return JFactory::getDocument ();
9+ }
10+
11+ public function adjustHead ($ template )
12+ {
13+ // Determine the variables
14+ $ doc = $ this ->getDocument ();
15+ $ head = $ doc ->getHeadData ();
16+ $ site_title = $ template ->params ->get ('sitetitle ' );
17+
18+ // remove deprecated meta-data (html5)
19+ //unset($head['metaTags']['http-equiv']);
20+ //unset($head['metaTags']['standard']['title']);
21+ //unset($head['metaTags']['standard']['rights']);
22+ //unset($head['metaTags']['standard']['language']);
23+
24+ // Robots if you wish
25+ //unset($head['metaTags']['standard']['robots']);
26+
27+ $ doc ->setHeadData ($ head );
28+
29+ // New meta
30+ //$doc->setMetadata( 'X-UA-Compatible', 'IE=edge,chrome=1' );
31+ //$doc->setMetadata( 'viewport', 'width=device-width, initial-scale=1.0, maximum-scale=3.0, user-scalable=yes' );
32+ //$doc->setMetadata( 'HandheldFriendly', 'true' );
33+ //$doc->setMetadata( 'apple-mobile-web-app-capable', 'yes' );
34+ //$doc->setMetadata( 'copyright', $site_title );
35+
36+ //Yandex and Google Webmaster-tools if you wish
37+ //$doc->setMetadata('yandex-verification', 'xxxxxxxxxxxxxxxx');
38+ //$doc->setMetadata('google-verification', 'xxxxxxxxxxxxxxxx');
39+
40+ // Remove or rewrite
41+ //$doc->setGenerator('');
42+ $ doc ->setGenerator ($ site_title );
43+ }
44+
45+ public function isHome ()
746 {
847 // Fetch the active menu-item
948 $ menu = JFactory::getApplication ()->getMenu ();
@@ -13,13 +52,13 @@ static public function isHome()
1352 return (boolean )$ active ->home ;
1453 }
1554
16- static public function loadCss ($ template )
55+ public function loadCss ($ template )
1756 {
1857 // Determine the variables
58+ $ doc = JFactory::getDocument ();
1959 $ cssmode = $ template ->params ->get ('cssmode ' , 'css ' );
2060 $ templateUrl = 'templates/ ' .$ template ->template ;
2161 $ templateDir = JPATH_SITE .'/templates/ ' .$ template ->template .'/ ' ;
22- $ doc = JFactory::getDocument ();
2362
2463 $ versionLess = '1.6.3 ' ;
2564 $ versionBootstrap = '3.2.0 ' ;
@@ -30,16 +69,14 @@ static public function loadCss($template)
3069 unset($ doc ->_styleSheets ['/components/com_rsform/assets/css/front.css ' ]);
3170
3271 // Google Fonts
33- $ doc ->addStyleSheet ('//fonts.googleapis.com/css?family=Roboto:400,300,700 ' );
34- $ doc ->addStyleSheet ('//fonts.googleapis.com/css?family=Roboto+Slab:400,300,700 ' );
35- $ doc ->addStyleSheet ('//fonts.googleapis.com/css?family=Roboto+Condensed:400,700,300 ' );
72+ $ doc ->addStyleSheet ('//fonts.googleapis.com/css?family=Open+Sans:400,300,700 ' );
3673
3774 switch ($ cssmode )
3875 {
3976 case 'lessjs ' :
4077 // Load LESS.js
4178 $ doc ->addStyleSheet ($ templateUrl .'/less/template.less ' ,'text/less ' );
42- $ doc ->addScript ($ templateUrl .'/js/cloudflare/ less.compiler.params.js ' ); // @todo: jisse: Why CloudFlare???
79+ $ doc ->addScript ($ templateUrl .'/js/less.compiler.params.js ' );
4380 $ doc ->addScript ('//cdnjs.cloudflare.com/ajax/libs/less.js/ ' . $ versionLess . '/less.min.js ' );
4481 unset($ doc ->_scripts [JPATH_SITE .'/media/jui/js/bootstrap.min.js ' ]);
4582 $ doc ->addScript ('//netdna.bootstrapcdn.com/bootstrap/ ' . $ versionBootstrap . '/js/bootstrap.min.js ' );
@@ -78,4 +115,138 @@ static public function loadCss($template)
78115 $ doc ->addStyleSheet ($ templateUrl .'/css/compiled.css ' );
79116 }
80117 }
118+
119+ public function getAnalytics ($ template )
120+ {
121+ // Determine the variables
122+ $ doc = JFactory::getDocument ();
123+ $ analytics = $ template ->params ->get ('analytics ' ,0 );
124+ $ analyticsId = $ template ->params ->get ('analyticsid ' );
125+
126+ // Analytics
127+ switch ($ analytics ) {
128+ case 0 :
129+ break ;
130+ case 1 :
131+ // Google Analytics - load in head
132+ if ($ analyticsId ) {
133+ $ analyticsScript = "
134+
135+ var _gaq = _gaq || [];
136+ _gaq.push(['_setAccount', ' " . $ analyticsId . "']);
137+ _gaq.push(['_trackPageview']);
138+
139+ (function() {
140+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
141+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
142+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
143+ })();
144+ " ;
145+ $ doc ->addScriptDeclaration ($ analyticsScript );
146+ }
147+ break ;
148+ case 2 :
149+ // Universal Google Universal Analytics - load in head
150+ if ($ analyticsId ) {
151+ $ analyticsScript = "
152+
153+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
154+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
155+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
156+ })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
157+
158+ ga('create', ' " . $ analyticsId . "', 'auto');
159+ ga('send', 'pageview');
160+ " ;
161+ $ doc ->addScriptDeclaration ($ analyticsScript );
162+ }
163+ break ;
164+ case 3 :
165+ // Google Analytics - load in head
166+ if ($ analyticsId ) {
167+ $ analyticsScript = "
168+ <!-- Google Tag Manager -->
169+ <noscript><iframe src= \"//www.googletagmanager.com/ns.html?id= " . $ analyticsId . "\"
170+ height= \"0 \" width= \"0 \" style= \"display:none;visibility:hidden \"></iframe></noscript>
171+ <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
172+ new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
173+ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
174+ '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
175+ })(window,document,'script','dataLayer',' " . $ analyticsId . "');</script>
176+ <!-- End Google Tag Manager -->
177+
178+ " ;
179+ return array ('script ' => $ analyticsScript , 'position ' => 'after_body_start ' );
180+ }
181+ break ;
182+ }
183+ }
184+
185+ public function getLogo ($ template )
186+ {
187+ // Determine the variables
188+ $ sitebrand = $ template ->params ->get ('sitebrand ' ,0 );
189+ $ site_title = $ template ->params ->get ('sitetitle ' );
190+ $ site_tagline = $ template ->params ->get ('sitetagline ' );
191+ $ site_logo = $ template ->params ->get ('sitelogo ' );
192+ $ site_logosvg = $ template ->params ->get ('sitelogosvg ' );
193+ $ site_url = JURI ::root ();
194+
195+ // Site Logo
196+ switch ($ sitebrand ) {
197+ case 0 :
198+ break ;
199+ case 1 :
200+ // using an image
201+ if ($ site_logo AND $ site_title )
202+ {
203+ $ logo = '<a href=" ' . $ site_url . '/" class="navbar-brand"><img src=" ' . JURI ::root () . $ site_logo . '" alt=" ' . htmlspecialchars ($ site_title ) . '" /></a> ' ;
204+ return $ logo ;
205+ }
206+ break ;
207+ case 2 :
208+ // using an SVG image
209+ if ($ site_logosvg AND $ site_title )
210+ {
211+ $ logo = '<a href=" ' . $ site_url . '/" class="navbar-brand"><img src=" ' . JURI ::root () . 'images/ ' . $ site_logosvg . '" alt=" ' . htmlspecialchars ($ site_title ) . '" class="inject-me" /></a> ' ;
212+ // using SVGInjector to inject the image
213+ $ this ->getSVGInjector ($ template );
214+ return $ logo ;
215+ }
216+ break ;
217+ case 3 :
218+ // using the title
219+ if ($ site_title )
220+ {
221+ $ logo .= '<a href=" ' . $ site_url . '/" class="navbar-brand"> ' . htmlspecialchars ($ site_title ) . '</a> ' ;
222+ return $ logo ;
223+ }
224+ break ;
225+ case 4 :
226+ // using the title and the tag line
227+ if ($ site_title AND $ site_tagline )
228+ {
229+ $ logo .= '<a href=" ' . $ site_url . '/" class="navbar-brand"> ' . htmlspecialchars ($ site_title ) . '<small> ' . htmlspecialchars ($ site_tagline ) . '</small></a> ' ;
230+ return $ logo ;
231+ }
232+ break ;
233+ case 5 :
234+ // using the tag line
235+ if ($ site_tagline )
236+ {
237+ $ logo .= '<span class="navbar-brand"> ' . htmlspecialchars ($ site_tagline ) . '</span> ' ;
238+ return $ logo ;
239+ }
240+ break ;
241+ }
242+ }
243+
244+ public function getSVGInjector ($ template )
245+ {
246+ // Determine the variables
247+ $ doc = $ this ->getDocument ();
248+ $ templateUrl = 'templates/ ' .$ template ->template ;
249+
250+ $ doc ->addScript ($ templateUrl .'js/svg-injector/svg-injector.min.js ' );
251+ }
81252}
0 commit comments