bludit/bl-kernel/helpers/theme.class.php

187 lines
3.8 KiB
PHP
Raw Normal View History

2015-03-08 18:02:59 +01:00
<?php
class Theme {
2017-07-23 23:31:39 +02:00
public static function title()
{
global $Site;
return $Site->title();
}
public static function description()
{
global $Site;
return $Site->description();
}
public static function slogan()
{
global $Site;
return $Site->slogan();
}
public static function footer()
{
global $Site;
return $Site->footer();
}
2017-08-03 23:28:32 +02:00
public static function rssUrl()
{
2017-12-27 14:19:28 +01:00
if (pluginEnabled('pluginRSS')) {
2017-08-03 23:28:32 +02:00
return DOMAIN_BASE.'rss.xml';
}
return false;
}
public static function sitemapUrl()
{
2017-12-27 14:19:28 +01:00
if (pluginEnabled('pluginSitemap')) {
2017-08-03 23:28:32 +02:00
return DOMAIN_BASE.'sitemap.xml';
}
return false;
}
2017-07-23 23:31:39 +02:00
public static function siteUrl()
{
global $Site;
return $Site->url();
}
public static function adminUrl()
{
2017-10-13 00:15:13 +02:00
return DOMAIN_ADMIN;
2017-07-23 23:31:39 +02:00
}
// Return the metatag <title> with a predefine structure
public static function headTitle()
2015-09-22 01:37:04 +02:00
{
global $Url;
global $Site;
global $dbTags;
global $dbCategories;
global $WHERE_AM_I;
global $page;
$title = $Site->title();
2017-10-04 23:42:14 +02:00
if (Text::isNotEmpty($Site->slogan())) {
$title = $Site->slogan().' | '.$Site->title();
}
if ($WHERE_AM_I=='page') {
$title = $page->title().' | '.$Site->title();
}
2017-10-04 23:42:14 +02:00
elseif ($WHERE_AM_I=='tag') {
$tagKey = $Url->slug();
$tagName = $dbTags->getName($tagKey);
2017-10-04 23:42:14 +02:00
$title = $tagName.' | '.$Site->title();
}
2017-10-04 23:42:14 +02:00
elseif ($WHERE_AM_I=='category') {
$categoryKey = $Url->slug();
$categoryName = $dbCategories->getName($categoryKey);
2017-10-04 23:42:14 +02:00
$title = $categoryName.' | '.$Site->title();
2016-02-14 17:34:25 +01:00
}
return '<title>'.$title.'</title>'.PHP_EOL;
}
2015-09-22 01:37:04 +02:00
// Return the metatag <decription> with a predefine structure
public static function headDescription()
{
global $Site;
global $WHERE_AM_I;
global $page;
$description = $Site->description();
if( $WHERE_AM_I=='page' ) {
$description = $page->description();
2015-09-22 01:37:04 +02:00
}
return '<meta name="description" content="'.$description.'">'.PHP_EOL;
}
public static function charset($charset)
{
return '<meta charset="'.$charset.'">'.PHP_EOL;
}
public static function viewport($content)
{
return '<meta name="viewport" content="'.$content.'">'.PHP_EOL;
2015-09-22 01:37:04 +02:00
}
2017-05-30 20:28:55 +02:00
public static function css($files)
2015-05-15 00:07:45 +02:00
{
if( !is_array($files) ) {
2015-05-15 00:07:45 +02:00
$files = array($files);
}
$links = '';
2015-05-15 00:07:45 +02:00
foreach($files as $file) {
2017-05-30 20:28:55 +02:00
$links .= '<link rel="stylesheet" type="text/css" href="'.DOMAIN_THEME.$file.'">'.PHP_EOL;
2015-05-15 00:07:45 +02:00
}
return $links;
2015-05-15 00:07:45 +02:00
}
2017-05-30 20:28:55 +02:00
public static function javascript($files)
2015-05-15 00:07:45 +02:00
{
if( !is_array($files) ) {
2015-05-15 00:07:45 +02:00
$files = array($files);
}
$scripts = '';
2015-05-15 00:07:45 +02:00
foreach($files as $file) {
2017-05-30 20:28:55 +02:00
$scripts .= '<script src="'.DOMAIN_THEME.$file.'"></script>'.PHP_EOL;
2015-05-15 00:07:45 +02:00
}
return $scripts;
}
2015-05-15 00:07:45 +02:00
2017-05-30 20:28:55 +02:00
public static function js($files)
{
2017-05-30 20:28:55 +02:00
return self::javascript($files);
2015-05-15 00:07:45 +02:00
}
public static function plugins($type)
2015-05-15 00:07:45 +02:00
{
global $plugins;
2017-07-29 00:08:19 +02:00
foreach ($plugins[$type] as $plugin) {
echo call_user_func(array($plugin, $type));
}
}
2016-02-14 17:34:25 +01:00
2017-07-09 22:04:00 +02:00
public static function favicon($file='favicon.png', $typeIcon='image/png')
{
2017-07-09 22:04:00 +02:00
return '<link rel="shortcut icon" href="'.DOMAIN_THEME.$file.'" type="'.$typeIcon.'">'.PHP_EOL;
}
2016-02-14 17:34:25 +01:00
2017-10-04 23:42:14 +02:00
public static function fontAwesome($cdn=false)
2017-07-13 00:44:39 +02:00
{
2017-10-04 23:42:14 +02:00
if ($cdn) {
return '<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">'.PHP_EOL;
}
2017-07-22 20:06:19 +02:00
return '<link rel="stylesheet" href="'.DOMAIN_CORE_CSS.'font-awesome/css/font-awesome.min.css'.'">'.PHP_EOL;
2017-07-13 00:44:39 +02:00
}
2015-05-15 00:07:45 +02:00
2017-07-13 00:44:39 +02:00
public static function jquery($cdn=false)
{
2017-10-04 23:42:14 +02:00
if ($cdn) {
2017-07-13 00:44:39 +02:00
return '<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>';
}
return '<script src="'.DOMAIN_CORE_JS.'jquery.min.js'.'"></script>'.PHP_EOL;
}
2015-05-15 00:07:45 +02:00
2017-10-04 23:42:14 +02:00
public static function keywords($keywords)
2015-07-07 00:22:03 +02:00
{
2017-10-04 23:42:14 +02:00
if (is_array($keywords)) {
2015-07-07 00:22:03 +02:00
$keywords = implode(',', $keywords);
}
2017-10-04 23:42:14 +02:00
return '<meta name="keywords" content="'.$keywords.'">'.PHP_EOL;
2015-07-07 00:22:03 +02:00
}
2015-03-08 18:02:59 +01:00
}
2017-12-27 14:19:28 +01:00
?>