diff --git a/bl-kernel/admin/controllers/api.php b/bl-kernel/admin/controllers/api.php index 5b20d7b7..16d3d28e 100644 --- a/bl-kernel/admin/controllers/api.php +++ b/bl-kernel/admin/controllers/api.php @@ -25,7 +25,7 @@ checkRole(array('admin')); activatePlugin('pluginAPI'); $apiURL = DOMAIN_BASE.'api/'; $pluginAPI = getPlugin('pluginAPI'); -$apiToken = $pluginAPI->getToken(); +$apiToken = $pluginAPI->token(); $username = $login->username(); $admin = new User($username); $authToken = $admin->tokenAuth(); diff --git a/bl-kernel/admin/themes/booty/init.php b/bl-kernel/admin/themes/booty/init.php new file mode 100644 index 00000000..3e9bf9b5 --- /dev/null +++ b/bl-kernel/admin/themes/booty/init.php @@ -0,0 +1,7 @@ +newToken(); \ No newline at end of file diff --git a/bl-kernel/helpers/html.class.php b/bl-kernel/helpers/html.class.php index cd921850..965b4aef 100644 --- a/bl-kernel/helpers/html.class.php +++ b/bl-kernel/helpers/html.class.php @@ -82,6 +82,88 @@ class HTML { return ''.PHP_EOL; } + /* Generates a dynamiclly the meta tag title for the themes === Bludit v4 + + @return string Returns the meta tag title ... + */ + public static function metaTagTitle() + { + global $url; + global $site; + global $page; + global $WHERE_AM_I; + + 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 ''.$format.''.PHP_EOL; + } + + /* Generates a dynamiclly the meta tag description for the themes === Bludit v4 + + @return string Returns the meta tag title + */ + public static function metaTagDescription() + { + global $site; + global $page; + global $url; + global $WHERE_AM_I; + + $description = $site->description(); + + if ($WHERE_AM_I=='page') { + $description = $page->description(); + } elseif ($WHERE_AM_I=='category') { + try { + $categoryKey = $url->slug(); + $category = new Category($categoryKey); + $description = $category->description(); + } catch (Exception $e) { + // description from the site + } + } + + return ''.PHP_EOL; + } + + /* Returns the short version of the current languages of the site === Bludit v4 + + @return string Returns the language sort version, for example: "en" or "de" + */ + public static function lang() + { + global $language; + return $language->currentLanguageShortVersion(); + } + // --- CHECK OLD public static function charset($charset) @@ -147,12 +229,6 @@ class HTML { return $site->footer(); } - public static function lang() - { - global $language; - return $language->currentLanguageShortVersion(); - } - public static function rssUrl() { if (pluginActivated('pluginRSS')) { @@ -194,72 +270,9 @@ class HTML { } } - 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 ''.$format.''.PHP_EOL; - } - - public static function metaTagDescription() - { - global $site; - global $WHERE_AM_I; - global $page; - global $url; - - $description = $site->description(); - - if ($WHERE_AM_I=='page') { - $description = $page->description(); - } elseif ($WHERE_AM_I=='category') { - try { - $categoryKey = $url->slug(); - $category = new Category($categoryKey); - $description = $category->description(); - } catch (Exception $e) { - // description from the site - } - } - - return ''.PHP_EOL; - } } diff --git a/bl-kernel/js/api.js b/bl-kernel/js/api.js index ba2d07df..71341bd9 100644 --- a/bl-kernel/js/api.js +++ b/bl-kernel/js/api.js @@ -5,10 +5,10 @@ class API { constructor(apiURL, apiToken, apiAuth) { - this.apiURL = "http://localhost:8000/api/"; + this.apiURL = apiURL; this.body = { - token: '45643a4071fad6a12261bb0763550feb', - authentication: '02707c99183896203b41d4a9b5c42692' + token: apiToken, + authentication: apiAuth } } diff --git a/bl-kernel/js/variables.php b/bl-kernel/js/variables.php index 8b9ba260..44c11f5d 100644 --- a/bl-kernel/js/variables.php +++ b/bl-kernel/js/variables.php @@ -26,7 +26,7 @@ echo 'var tokenCSRF = "'.$security->getTokenCSRF().'";'.PHP_EOL; echo 'var UPLOAD_MAX_FILESIZE = '.Text::toBytes( ini_get('upload_max_filesize') ).';'.PHP_EOL; echo 'var DEBUG_MODE = '.(DEBUG_MODE?'true':'false').';'.PHP_EOL; echo 'var PASSWORD_LENGTH = '.PASSWORD_LENGTH.';'.PHP_EOL; -echo 'var api = new API("", "", "", tokenCSRF);'.PHP_EOL; +echo 'var api = new API("'.DOMAIN.'/api/", "'.$plugins['all']['pluginAPI']->token().'", "'.$login->tokenAuth().'", tokenCSRF);'.PHP_EOL; echo ''.PHP_EOL; ?> \ No newline at end of file diff --git a/bl-kernel/login.class.php b/bl-kernel/login.class.php index 5b92bada..f636f6e1 100644 --- a/bl-kernel/login.class.php +++ b/bl-kernel/login.class.php @@ -18,18 +18,24 @@ class Login { } } - // Returns the username of the user logged + // Returns the username public function username() { return Session::get('username'); } - // Returns the role of the user logged + // Returns the role public function role() { return Session::get('role'); } + // Returns the authentication token + public function tokenAuth() + { + return Session::get('tokenAuth'); + } + // Returns TRUE if the user is logged, FALSE otherwise public function isLogged() { @@ -49,10 +55,11 @@ class Login { } // Set the session for the user logged - public function setLogin($username, $role) + public function setLogin($username, $role, $tokenAuth) { Session::set('username', $username); Session::set('role', $role); + Session::set('tokenAuth', $tokenAuth); Session::set('fingerPrint', $this->fingerPrint()); Session::set('sessionTime', time()); @@ -112,7 +119,7 @@ class Login { $passwordHash = $this->users->generatePasswordHash($password, $user->salt()); if ($passwordHash===$user->password()) { - $this->setLogin($username, $user->role()); + $this->setLogin($username, $user->role(), $user->tokenAuth()); Log::set(__METHOD__.LOG_SEP.'Successful user login by username and password - Username ['.$username.']'); return true; } @@ -151,7 +158,7 @@ class Login { // Get user from database and login $user = $this->users->getUserDB($username); - $this->setLogin($username, $user['role']); + $this->setLogin($username, $user['role'], $user->tokenAuth()); Log::set(__METHOD__.LOG_SEP.'User authenticated via Remember Me.'); return true; } diff --git a/bl-kernel/page.class.php b/bl-kernel/page.class.php index 3ab253c1..d6b0e675 100644 --- a/bl-kernel/page.class.php +++ b/bl-kernel/page.class.php @@ -600,9 +600,13 @@ class Page { return false; } - // Returns an array with all pages key related to the page - // The relation is based on the tags - public function related() { + /* Returns an array with all pages key related to the page === Bludit v4 + The relation is based on the tags. + + @sortByDate boolean TRUE if you want to get sort by date the pages, FALSE random order + @return array Returns an array with the page keys related to page + */ + public function related($sortByDate=false) { global $tags; $pageTags = $this->tags(true); $list = array(); @@ -620,6 +624,19 @@ class Page { unset($list[$key]); } + // Sort by date if requested + if ($sortByDate) { + $listSortByDate = array(); + foreach ($list as $pageKey) { + $tmpPage = new Page($pageKey); + $listSortByDate[$tmpPage->date('U')] = new Page($pageKey); + } + krsort($listSortByDate); + return $listSortByDate; + } + return $list; } + + } diff --git a/bl-plugins/api/plugin.php b/bl-plugins/api/plugin.php index 91268b75..e7d23c65 100644 --- a/bl-plugins/api/plugin.php +++ b/bl-plugins/api/plugin.php @@ -7,7 +7,7 @@ class pluginAPI extends Plugin { public function init() { // Generate the API Token - $token = md5( uniqid().time().DOMAIN ); + $token = $this->generateToken(); $this->dbFields = array( 'token'=>$token, // API Token @@ -15,11 +15,22 @@ class pluginAPI extends Plugin { ); } - public function getToken() + public function generateToken() + { + return md5( uniqid().time().DOMAIN ); + } + + public function token() { return $this->getValue('token'); } + public function newToken() + { + $this->db['token'] = $this->generateToken(); + $this->save(); + } + public function form() { global $L; @@ -116,7 +127,7 @@ class pluginAPI extends Plugin { if (($user->role()=='admin') && ($user->enabled())) { // Loggin the user to create the session $login = new Login(); - $login->setLogin($username, 'admin'); + $login->setLogin($username, 'admin', $user->tokenAuth()); // Enable write permissions $writePermissions = true; } diff --git a/bl-themes/popeye/css/style.css b/bl-themes/popeye/css/style.css new file mode 100755 index 00000000..522817c6 --- /dev/null +++ b/bl-themes/popeye/css/style.css @@ -0,0 +1,14 @@ +/* VIDEO EMBED RESPONSIVE */ +.video-embed { + overflow:hidden; + padding-bottom: 56.25%; /* 16:9 */ + position:relative; + height:0; +} +.video-embed iframe{ + left:0; + top:0; + height:100%; + width:100%; + position:absolute; +} diff --git a/bl-themes/popeye/img/favicon.png b/bl-themes/popeye/img/favicon.png new file mode 100644 index 00000000..60349a2b Binary files /dev/null and b/bl-themes/popeye/img/favicon.png differ diff --git a/bl-themes/popeye/index.php b/bl-themes/popeye/index.php new file mode 100755 index 00000000..94fd7f24 --- /dev/null +++ b/bl-themes/popeye/index.php @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + template(); + if (($template) && file_exists(THEME_DIR_TEMPLATES.$template)) { + include(THEME_DIR_TEMPLATES.$template); + } else { + include(THEME_DIR_PHP.'page.php'); + } + } else { + include(THEME_DIR_PHP.'home.php'); + } + ?> + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bl-themes/popeye/languages/en.json b/bl-themes/popeye/languages/en.json new file mode 100644 index 00000000..026b0f76 --- /dev/null +++ b/bl-themes/popeye/languages/en.json @@ -0,0 +1,7 @@ +{ + "theme-data": + { + "name": "Popeye", + "description": "" + } +} \ No newline at end of file diff --git a/bl-themes/popeye/metadata.json b/bl-themes/popeye/metadata.json new file mode 100644 index 00000000..0ff8df3e --- /dev/null +++ b/bl-themes/popeye/metadata.json @@ -0,0 +1,10 @@ +{ + "author": "Bludit", + "email": "", + "website": "https://themes.bludit.com", + "version": "4.0", + "releaseDate": "2020-07-28", + "license": "MIT", + "compatible": "4.0", + "notes": "" +} \ No newline at end of file diff --git a/bl-themes/popeye/php/footer.php b/bl-themes/popeye/php/footer.php new file mode 100644 index 00000000..490bbe90 --- /dev/null +++ b/bl-themes/popeye/php/footer.php @@ -0,0 +1,5 @@ + diff --git a/bl-themes/popeye/php/home.php b/bl-themes/popeye/php/home.php new file mode 100644 index 00000000..3f0dae23 --- /dev/null +++ b/bl-themes/popeye/php/home.php @@ -0,0 +1,92 @@ + +
+
+ + + + description()) : ?> +
+

description(); ?>

+
+ +
+
+ + +
+ p('No pages found') ?> +
+ + + +
+
+
+
+ +
+ + +
+ +
+ +
+
+ +
title() ?>
+ + 3 days ago +
+ + +

Some placeholder content in a paragraph.

+ + + tags(true); + if (!empty($tmp)) { + echo ''; + foreach ($tmp as $tagKey => $tagName) { + echo '' . $tagName . ''; + } + echo ''; + } + ?> +
+ +
+
+
+
+
+ + + + 1) : ?> + + \ No newline at end of file diff --git a/bl-themes/popeye/php/navbar.php b/bl-themes/popeye/php/navbar.php new file mode 100644 index 00000000..7aee8afa --- /dev/null +++ b/bl-themes/popeye/php/navbar.php @@ -0,0 +1,5 @@ + diff --git a/bl-themes/popeye/php/page.php b/bl-themes/popeye/php/page.php new file mode 100644 index 00000000..91713bda --- /dev/null +++ b/bl-themes/popeye/php/page.php @@ -0,0 +1,33 @@ +
+
+
+
+ + + + +

title(); ?>

+ + + description()): ?> +

description(); ?>

+ + + + coverImage()): ?> +
+
+
+ + + +
+ content(); ?> +
+ + + +
+
+
+