diff --git a/bl-kernel/admin/themes/booty/login.php b/bl-kernel/admin/themes/booty/login.php index b53f639a..815030eb 100644 --- a/bl-kernel/admin/themes/booty/login.php +++ b/bl-kernel/admin/themes/booty/login.php @@ -22,8 +22,8 @@ diff --git a/bl-kernel/boot/rules/69.pages.php b/bl-kernel/boot/rules/69.pages.php index 85af105f..aa613ed2 100644 --- a/bl-kernel/boot/rules/69.pages.php +++ b/bl-kernel/boot/rules/69.pages.php @@ -38,7 +38,7 @@ $staticContent = $staticPages = buildStaticPages(); // Execute the scheduler if ($pages->scheduler()) { // Execute plugins with the hook afterPageCreate - Theme::plugins('afterPageCreate'); + execPluginsByHook('afterPageCreate'); reindexTags(); reindexCategories(); diff --git a/bl-kernel/boot/rules/99.paginator.php b/bl-kernel/boot/rules/99.paginator.php index 6324398e..5051c7c3 100644 --- a/bl-kernel/boot/rules/99.paginator.php +++ b/bl-kernel/boot/rules/99.paginator.php @@ -21,7 +21,7 @@ if ($url->whereAmI()=='admin') { } // Execute hook from plugins -Theme::plugins('paginator'); +execPluginsByHook('paginator'); // Items per page Paginator::set('itemsPerPage', $itemsPerPage); diff --git a/bl-kernel/boot/site.php b/bl-kernel/boot/site.php index 7cf997cc..f096f7a7 100644 --- a/bl-kernel/boot/site.php +++ b/bl-kernel/boot/site.php @@ -4,7 +4,7 @@ include(PATH_RULES.'60.plugins.php'); // Plugins before all -Theme::plugins('beforeAll'); +execPluginsByHook('beforeAll'); // Load rules include(PATH_RULES.'60.router.php'); @@ -14,7 +14,7 @@ include(PATH_RULES.'99.paginator.php'); include(PATH_RULES.'99.themes.php'); // Plugins before site loaded -Theme::plugins('beforeSiteLoad'); +execPluginsByHook('beforeSiteLoad'); // Theme init.php if (Sanitize::pathFile(PATH_THEMES.$site->theme().DS.'init.php')) { @@ -29,7 +29,7 @@ if (Sanitize::pathFile(PATH_THEMES.$site->theme().DS.'index.php')) { } // Plugins after site loaded -Theme::plugins('afterSiteLoad'); +execPluginsByHook('afterSiteLoad'); // Plugins after all -Theme::plugins('afterAll'); +execPluginsByHook('afterAll'); diff --git a/bl-kernel/helpers/html.class.php b/bl-kernel/helpers/html.class.php index c51190f1..cd921850 100644 --- a/bl-kernel/helpers/html.class.php +++ b/bl-kernel/helpers/html.class.php @@ -82,6 +82,185 @@ class HTML { return ''.PHP_EOL; } + // --- CHECK OLD + + public static function charset($charset) + { + return ''.PHP_EOL; + } + + public static function viewport($content) + { + return ''.PHP_EOL; + } + + public static function src($file, $base=DOMAIN_THEME) + { + return $base.$file; + } + + public static function socialNetworks() + { + global $site; + $socialNetworks = array( + 'github'=>'Github', + 'gitlab'=>'GitLab', + 'twitter'=>'Twitter', + 'facebook'=>'Facebook', + 'instagram'=>'Instagram', + 'codepen'=>'Codepen', + 'linkedin'=>'Linkedin', + 'xing'=>'Xing', + 'mastodon'=>'Mastodon', + 'vk'=>'VK' + ); + + foreach ($socialNetworks as $key=>$label) { + if (!$site->{$key}()) { + unset($socialNetworks[$key]); + } + } + return $socialNetworks; + } + + 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(); + } + + public static function lang() + { + global $language; + return $language->currentLanguageShortVersion(); + } + + public static function rssUrl() + { + if (pluginActivated('pluginRSS')) { + return DOMAIN_BASE.'rss.xml'; + } + return false; + } + + public static function sitemapUrl() + { + if (pluginActivated('pluginSitemap')) { + return DOMAIN_BASE.'sitemap.xml'; + } + return false; + } + + // 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/ + public static function siteUrl() + { + return DOMAIN_BASE; + } + + // 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/ + public static function adminUrl() + { + return DOMAIN_ADMIN; + } + + public static function metaTags($tag) + { + if ($tag=='title') { + return self::metaTagTitle(); + } elseif ($tag=='description') { + return self::metaTagDescription(); + } + } + + public static function metaTagTitle() + { + global $url; + global $site; + global $tags; + global $categories; + global $WHERE_AM_I; + global $page; + + if ($WHERE_AM_I=='page') { + $format = $site->titleFormatPages(); + $format = Text::replace('{{page-title}}', $page->title(), $format); + $format = Text::replace('{{page-description}}', $page->description(), $format); + } 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 + } + } else { + $format = $site->titleFormatHomepage(); + } + + $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 '