2015-03-08 18:02:59 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Theme {
|
|
|
|
|
2018-11-09 00:59:06 +01:00
|
|
|
public static function socialNetworks()
|
|
|
|
{
|
|
|
|
global $site;
|
|
|
|
$socialNetworks = array(
|
|
|
|
'github'=>'Github',
|
2019-04-19 00:55:34 +02:00
|
|
|
'gitlab'=>'GitLab',
|
2018-11-09 00:59:06 +01:00
|
|
|
'twitter'=>'Twitter',
|
|
|
|
'facebook'=>'Facebook',
|
|
|
|
'instagram'=>'Instagram',
|
|
|
|
'codepen'=>'Codepen',
|
2019-04-19 00:55:34 +02:00
|
|
|
'linkedin'=>'Linkedin',
|
|
|
|
'mastodon'=>'Mastodon'
|
2018-11-09 00:59:06 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
foreach ($socialNetworks as $key=>$label) {
|
|
|
|
if (!$site->{$key}()) {
|
|
|
|
unset($socialNetworks[$key]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $socialNetworks;
|
|
|
|
}
|
|
|
|
|
2017-07-23 23:31:39 +02:00
|
|
|
public static function title()
|
|
|
|
{
|
2018-07-17 19:13:01 +02:00
|
|
|
global $site;
|
|
|
|
return $site->title();
|
2017-07-23 23:31:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function description()
|
|
|
|
{
|
2018-07-17 19:13:01 +02:00
|
|
|
global $site;
|
|
|
|
return $site->description();
|
2017-07-23 23:31:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function slogan()
|
|
|
|
{
|
2018-07-17 19:13:01 +02:00
|
|
|
global $site;
|
|
|
|
return $site->slogan();
|
2017-07-23 23:31:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function footer()
|
|
|
|
{
|
2018-07-17 19:13:01 +02:00
|
|
|
global $site;
|
|
|
|
return $site->footer();
|
2017-07-23 23:31:39 +02:00
|
|
|
}
|
|
|
|
|
2018-10-17 22:35:30 +02:00
|
|
|
public static function lang()
|
|
|
|
{
|
|
|
|
global $language;
|
|
|
|
return $language->currentLanguageShortVersion();
|
|
|
|
}
|
|
|
|
|
2017-08-03 23:28:32 +02:00
|
|
|
public static function rssUrl()
|
|
|
|
{
|
2018-08-16 14:19:21 +02:00
|
|
|
if (pluginActivated('pluginRSS')) {
|
2017-08-03 23:28:32 +02:00
|
|
|
return DOMAIN_BASE.'rss.xml';
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function sitemapUrl()
|
|
|
|
{
|
2018-08-16 14:19:21 +02:00
|
|
|
if (pluginActivated('pluginSitemap')) {
|
2017-08-03 23:28:32 +02:00
|
|
|
return DOMAIN_BASE.'sitemap.xml';
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-10-03 00:19:19 +02:00
|
|
|
// Returns the absolute URL of the site
|
|
|
|
// Ex. https://example.com the method returns https://example.com/
|
|
|
|
// Ex. https://example.com/bludit/ the method returns https://example.com/bludit/
|
2017-07-23 23:31:39 +02:00
|
|
|
public static function siteUrl()
|
|
|
|
{
|
2018-10-03 00:19:19 +02:00
|
|
|
return DOMAIN_BASE;
|
2017-07-23 23:31:39 +02:00
|
|
|
}
|
|
|
|
|
2018-10-03 00:19:19 +02:00
|
|
|
// Returns the absolute URL of admin panel
|
|
|
|
// Ex. https://example.com/admin/ the method returns https://example.com/admin/
|
|
|
|
// Ex. https://example.com/bludit/admin/ the method returns https://example.com/bludit/admin/
|
2017-07-23 23:31:39 +02:00
|
|
|
public static function adminUrl()
|
|
|
|
{
|
2017-10-13 00:15:13 +02:00
|
|
|
return DOMAIN_ADMIN;
|
2017-07-23 23:31:39 +02:00
|
|
|
}
|
|
|
|
|
2018-07-13 18:30:42 +02:00
|
|
|
public static function metaTags($tag)
|
2015-09-22 01:37:04 +02:00
|
|
|
{
|
2018-07-13 18:30:42 +02:00
|
|
|
if ($tag=='title') {
|
|
|
|
return self::metaTagTitle();
|
|
|
|
} elseif ($tag=='description') {
|
|
|
|
return self::metaTagDescription();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function metaTagTitle()
|
|
|
|
{
|
|
|
|
global $url;
|
|
|
|
global $site;
|
2018-08-02 22:33:53 +02:00
|
|
|
global $tags;
|
|
|
|
global $categories;
|
2017-05-21 22:01:44 +02:00
|
|
|
global $WHERE_AM_I;
|
|
|
|
global $page;
|
|
|
|
|
2017-10-04 23:42:14 +02:00
|
|
|
if ($WHERE_AM_I=='page') {
|
2018-07-13 18:30:42 +02:00
|
|
|
$format = $site->titleFormatPages();
|
|
|
|
$format = Text::replace('{{page-title}}', $page->title(), $format);
|
|
|
|
$format = Text::replace('{{page-description}}', $page->description(), $format);
|
2018-08-02 17:06:53 +02:00
|
|
|
} elseif ($WHERE_AM_I=='tag') {
|
|
|
|
try {
|
|
|
|
$tagKey = $url->slug();
|
|
|
|
$tag = new Tag($tagKey);
|
|
|
|
$format = $site->titleFormatTag();
|
|
|
|
$format = Text::replace('{{tag-name}}', $tag->name(), $format);
|
|
|
|
} catch (Exception $e) {
|
|
|
|
// Tag doesn't exist
|
|
|
|
}
|
|
|
|
|
|
|
|
} elseif ($WHERE_AM_I=='category') {
|
|
|
|
try {
|
|
|
|
$categoryKey = $url->slug();
|
|
|
|
$category = new Category($categoryKey);
|
|
|
|
$format = $site->titleFormatCategory();
|
|
|
|
$format = Text::replace('{{category-name}}', $category->name(), $format);
|
|
|
|
} catch (Exception $e) {
|
|
|
|
// Category doesn't exist
|
|
|
|
}
|
2018-07-13 18:30:42 +02:00
|
|
|
} else {
|
|
|
|
$format = $site->titleFormatHomepage();
|
2016-02-14 17:34:25 +01:00
|
|
|
}
|
|
|
|
|
2018-07-13 18:30:42 +02:00
|
|
|
$format = Text::replace('{{site-title}}', $site->title(), $format);
|
|
|
|
$format = Text::replace('{{site-slogan}}', $site->slogan(), $format);
|
|
|
|
$format = Text::replace('{{site-description}}', $site->description(), $format);
|
|
|
|
|
|
|
|
return '<title>'.$format.'</title>'.PHP_EOL;
|
2017-05-21 22:01:44 +02:00
|
|
|
}
|
2015-09-22 01:37:04 +02:00
|
|
|
|
2018-07-13 18:30:42 +02:00
|
|
|
public static function metaTagDescription()
|
2017-05-21 22:01:44 +02:00
|
|
|
{
|
2018-07-17 19:13:01 +02:00
|
|
|
global $site;
|
2017-05-21 22:01:44 +02:00
|
|
|
global $WHERE_AM_I;
|
|
|
|
global $page;
|
2018-08-02 22:33:53 +02:00
|
|
|
global $url;
|
2017-05-21 22:01:44 +02:00
|
|
|
|
2018-07-17 19:13:01 +02:00
|
|
|
$description = $site->description();
|
2017-05-21 22:01:44 +02:00
|
|
|
|
2018-08-02 17:06:53 +02:00
|
|
|
if ($WHERE_AM_I=='page') {
|
2017-05-21 22:01:44 +02:00
|
|
|
$description = $page->description();
|
2018-08-02 17:06:53 +02:00
|
|
|
} elseif ($WHERE_AM_I=='category') {
|
|
|
|
try {
|
|
|
|
$categoryKey = $url->slug();
|
|
|
|
$category = new Category($categoryKey);
|
|
|
|
$description = $category->description();
|
|
|
|
} catch (Exception $e) {
|
|
|
|
// description from the site
|
|
|
|
}
|
2015-09-22 01:37:04 +02:00
|
|
|
}
|
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
return '<meta name="description" content="'.$description.'">'.PHP_EOL;
|
|
|
|
}
|
|
|
|
|
2018-07-13 18:30:42 +02:00
|
|
|
// DEPRECATED v3.0.0
|
|
|
|
// Return the metatag <title> with a predefine structure
|
|
|
|
public static function headTitle()
|
|
|
|
{
|
|
|
|
return self::metaTagTitle();
|
|
|
|
}
|
|
|
|
|
|
|
|
// DEPRECATED v3.0.0
|
|
|
|
// Return the metatag <decription> with a predefine structure
|
|
|
|
public static function headDescription()
|
|
|
|
{
|
|
|
|
return self::metaTagDescription();
|
|
|
|
}
|
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-07-28 18:33:37 +02:00
|
|
|
public static function src($file, $base=DOMAIN_THEME)
|
|
|
|
{
|
|
|
|
return $base.$file;
|
|
|
|
}
|
|
|
|
|
2018-07-10 18:37:46 +02:00
|
|
|
public static function css($files, $base=DOMAIN_THEME)
|
2015-05-15 00:07:45 +02:00
|
|
|
{
|
2017-05-21 22:01:44 +02:00
|
|
|
if( !is_array($files) ) {
|
2015-05-15 00:07:45 +02:00
|
|
|
$files = array($files);
|
|
|
|
}
|
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
$links = '';
|
2015-05-15 00:07:45 +02:00
|
|
|
foreach($files as $file) {
|
2018-07-10 18:37:46 +02:00
|
|
|
$links .= '<link rel="stylesheet" type="text/css" href="'.$base.$file.'?version='.BLUDIT_VERSION.'">'.PHP_EOL;
|
2015-05-15 00:07:45 +02:00
|
|
|
}
|
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
return $links;
|
2015-05-15 00:07:45 +02:00
|
|
|
}
|
|
|
|
|
2018-07-10 18:37:46 +02:00
|
|
|
public static function javascript($files, $base=DOMAIN_THEME)
|
2015-05-15 00:07:45 +02:00
|
|
|
{
|
2017-05-21 22:01:44 +02:00
|
|
|
if( !is_array($files) ) {
|
2015-05-15 00:07:45 +02:00
|
|
|
$files = array($files);
|
|
|
|
}
|
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
$scripts = '';
|
2015-05-15 00:07:45 +02:00
|
|
|
foreach($files as $file) {
|
2018-10-03 00:19:19 +02:00
|
|
|
$scripts .= '<script src="'.$base.$file.'?version='.BLUDIT_VERSION.'"></script>'.PHP_EOL;
|
2015-05-15 00:07:45 +02:00
|
|
|
}
|
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
return $scripts;
|
|
|
|
}
|
2015-05-15 00:07:45 +02:00
|
|
|
|
2018-07-10 18:37:46 +02:00
|
|
|
public static function js($files, $base=DOMAIN_THEME)
|
2017-05-21 22:01:44 +02:00
|
|
|
{
|
2018-07-10 18:37:46 +02:00
|
|
|
return self::javascript($files, $base);
|
2015-05-15 00:07:45 +02:00
|
|
|
}
|
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
public static function plugins($type)
|
2015-05-15 00:07:45 +02:00
|
|
|
{
|
2017-05-21 22:01:44 +02:00
|
|
|
global $plugins;
|
2017-07-29 00:08:19 +02:00
|
|
|
foreach ($plugins[$type] as $plugin) {
|
2017-05-21 22:01:44 +02:00
|
|
|
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-05-21 22:01:44 +02:00
|
|
|
{
|
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
|
|
|
|
2018-06-25 23:17:43 +02:00
|
|
|
public static function keywords($keywords)
|
2017-07-13 00:44:39 +02:00
|
|
|
{
|
2018-06-25 23:17:43 +02:00
|
|
|
if (is_array($keywords)) {
|
|
|
|
$keywords = implode(',', $keywords);
|
2017-10-04 23:42:14 +02:00
|
|
|
}
|
2018-06-25 23:17:43 +02:00
|
|
|
return '<meta name="keywords" content="'.$keywords.'">'.PHP_EOL;
|
2017-07-13 00:44:39 +02:00
|
|
|
}
|
2015-05-15 00:07:45 +02:00
|
|
|
|
2018-06-25 23:17:43 +02:00
|
|
|
public static function jquery()
|
2017-07-13 00:44:39 +02:00
|
|
|
{
|
2018-10-03 00:19:19 +02:00
|
|
|
return '<script src="'.DOMAIN_CORE_JS.'jquery.min.js?version='.BLUDIT_VERSION.'"></script>'.PHP_EOL;
|
2017-07-13 00:44:39 +02:00
|
|
|
}
|
2015-05-15 00:07:45 +02:00
|
|
|
|
2018-07-13 18:30:42 +02:00
|
|
|
public static function jsBootstrap()
|
2015-07-07 00:22:03 +02:00
|
|
|
{
|
2018-10-03 00:19:19 +02:00
|
|
|
return '<script src="'.DOMAIN_CORE_JS.'bootstrap.bundle.min.js?version='.BLUDIT_VERSION.'"></script>'.PHP_EOL;
|
2018-06-25 23:17:43 +02:00
|
|
|
}
|
|
|
|
|
2018-07-13 18:30:42 +02:00
|
|
|
public static function cssBootstrap()
|
2018-06-25 23:17:43 +02:00
|
|
|
{
|
|
|
|
return '<link rel="stylesheet" type="text/css" href="'.DOMAIN_CORE_CSS.'bootstrap.min.css?version='.BLUDIT_VERSION.'">'.PHP_EOL;
|
2015-07-07 00:22:03 +02:00
|
|
|
}
|
2018-07-20 18:36:47 +02:00
|
|
|
|
|
|
|
public static function jsSortable()
|
|
|
|
{
|
|
|
|
// https://github.com/psfpro/bootstrap-html5sortable
|
2018-10-03 00:19:19 +02:00
|
|
|
return '<script src="'.DOMAIN_CORE_JS.'jquery.sortable.min.js?version='.BLUDIT_VERSION.'"></script>'.PHP_EOL;
|
2018-07-20 18:36:47 +02:00
|
|
|
}
|
2015-03-08 18:02:59 +01:00
|
|
|
}
|
|
|
|
|
2018-03-08 19:50:39 +01:00
|
|
|
?>
|