Various fix for themes #94
31 changed files with 392 additions and 182 deletions
|
@ -18,7 +18,7 @@ class Archives extends dbList {
|
|||
$db = $pages->getDB($onlyKeys=false);
|
||||
$archiveIndex = array();
|
||||
foreach ($db as $pageKey=>$pageFields) {
|
||||
if (in_array($pageFields['type'], $GLOBALS['DB_TAGS_TYPES'])) {
|
||||
if (in_array($pageFields['type'], $GLOBALS['DB_TAGS_AUTHOR_ARCHIVE'])) {
|
||||
$date = $pageFields['date'];
|
||||
$year = mb_substr($date, 0, 4);
|
||||
$month = mb_substr($date, 0, 7);
|
||||
|
@ -46,4 +46,19 @@ class Archives extends dbList {
|
|||
return $this->save();
|
||||
}
|
||||
|
||||
public function getLinkList($month, $class = "", $classActive = "active")
|
||||
{
|
||||
$listLink = array();
|
||||
foreach ($this->db as $pageKey=>$pageFields) {
|
||||
if (
|
||||
($month && strlen($pageKey) != 4)
|
||||
|| (!$month && strlen($pageKey) == 4)
|
||||
) {
|
||||
$link = DOMAIN_ARCHIVES . $pageKey;
|
||||
$listLink[] = new Link($pageFields['name'], $link, $class, $classActive);
|
||||
}
|
||||
}
|
||||
return $listLink;
|
||||
}
|
||||
|
||||
}
|
|
@ -18,7 +18,7 @@ class Authors extends dbList {
|
|||
$db = $pages->getDB($onlyKeys=false);
|
||||
$authorsIndex = array();
|
||||
foreach ($db as $pageKey=>$pageFields) {
|
||||
if (in_array($pageFields['type'], $GLOBALS['DB_TAGS_TYPES'])) {
|
||||
if (in_array($pageFields['type'], $GLOBALS['DB_TAGS_AUTHOR_ARCHIVE'])) {
|
||||
$authorName = $pageFields['username'];
|
||||
if (isset($authorsIndex[$authorName])) {
|
||||
array_push($authorsIndex[$authorName]['list'], $pageKey);
|
||||
|
|
|
@ -41,6 +41,7 @@ define('PATH_CONTENT', PATH_ROOT . 'bl-content' . DS);
|
|||
define('PATH_ABSTRACT', PATH_KERNEL . 'abstract' . DS);
|
||||
define('PATH_RULES', PATH_KERNEL . 'boot' . DS . 'rules' . DS);
|
||||
define('PATH_HELPERS', PATH_KERNEL . 'helpers' . DS);
|
||||
define('PATH_CLASSES', PATH_KERNEL . 'class' . DS);
|
||||
define('PATH_AJAX', PATH_KERNEL . 'ajax' . DS);
|
||||
define('PATH_CORE_JS', PATH_KERNEL . 'js' . DS);
|
||||
|
||||
|
@ -116,6 +117,9 @@ include(PATH_KERNEL . 'social.class.php');
|
|||
// Include functions
|
||||
include(PATH_KERNEL . 'functions.php');
|
||||
|
||||
// Include classes
|
||||
include(PATH_CLASSES . 'link.class.php');
|
||||
|
||||
// Include Helpers Classes
|
||||
include(PATH_HELPERS . 'text.class.php');
|
||||
include(PATH_HELPERS . 'log.class.php');
|
||||
|
@ -131,6 +135,7 @@ include(PATH_HELPERS . 'alert.class.php');
|
|||
include(PATH_HELPERS . 'paginator.class.php');
|
||||
include(PATH_HELPERS . 'image.class.php');
|
||||
include(PATH_HELPERS . 'media.class.php');
|
||||
include(PATH_HELPERS . 'menus.class.php');
|
||||
include(PATH_HELPERS . 'tcp.class.php');
|
||||
include(PATH_HELPERS . 'dom.class.php');
|
||||
include(PATH_HELPERS . 'cookie.class.php');
|
||||
|
|
|
@ -15,6 +15,18 @@ if ($url->whereAmI()=='admin') {
|
|||
$itemsPerPage = $site->itemsPerPage();
|
||||
$categoryKey = $url->slug();
|
||||
$numberOfItems = $categories->numberOfPages($categoryKey);
|
||||
} elseif ($url->whereAmI()=='author') {
|
||||
$itemsPerPage = $site->itemsPerPage();
|
||||
$categoryKey = $url->slug();
|
||||
$numberOfItems = $authors->numberOfPages($categoryKey);
|
||||
} elseif ($url->whereAmI()=='archive') {
|
||||
$itemsPerPage = $site->itemsPerPage();
|
||||
$categoryKey = $url->slug();
|
||||
$numberOfItems = $archives->numberOfPages($categoryKey);
|
||||
} elseif ($url->whereAmI()=='kind') {
|
||||
$itemsPerPage = $site->itemsPerPage();
|
||||
$categoryKey = $url->slug();
|
||||
$numberOfItems = $kinds->numberOfPages($categoryKey);
|
||||
} else {
|
||||
$itemsPerPage = $site->itemsPerPage();
|
||||
$numberOfItems = $pages->count(true);
|
||||
|
|
|
@ -106,6 +106,9 @@ define('MEDIA_MANAGER_SORT_BY_DATE', true);
|
|||
// Type of pages included in the tag database
|
||||
$GLOBALS['DB_TAGS_TYPES'] = array('published','static','sticky');
|
||||
|
||||
// Type of pages included in the author/archive database
|
||||
$GLOBALS['DB_TAGS_AUTHOR_ARCHIVE'] = array('published','sticky');
|
||||
|
||||
// Allowed image extensions
|
||||
$GLOBALS['ALLOWED_IMG_EXTENSION'] = array('gif', 'png', 'jpg', 'jpeg', 'svg', 'webp');
|
||||
|
||||
|
|
|
@ -40,4 +40,20 @@ class Categories extends dbList {
|
|||
|
||||
return $this->save();
|
||||
}
|
||||
|
||||
public function getLinkList($hideEmpty, $showCount, $class = "", $classActive = "active")
|
||||
{
|
||||
$listLink = array();
|
||||
foreach ($this->db as $pageKey=>$pageFields) {
|
||||
$count = count($pageFields['list']);
|
||||
if (
|
||||
(!$hideEmpty || $count > 0)
|
||||
) {
|
||||
$link = DOMAIN_CATEGORIES . $pageKey;
|
||||
$name = $pageFields['name'] . ($showCount ? ' (' . $count . ')' : '');
|
||||
$listLink[] = new Link($name, $link, $class, $classActive);
|
||||
}
|
||||
}
|
||||
return $listLink;
|
||||
}
|
||||
}
|
42
bl-kernel/class/link.class.php
Normal file
42
bl-kernel/class/link.class.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php defined('KOBLOG') or die('Koblog CMS.');
|
||||
|
||||
/**
|
||||
* Basic representation of a Link
|
||||
*/
|
||||
class Link {
|
||||
|
||||
private $label;
|
||||
private $href;
|
||||
private $class;
|
||||
private $classActive;
|
||||
|
||||
function __construct($label, $href, $class = "", $classActive = "active")
|
||||
{
|
||||
$this->label = $label;
|
||||
$this->href = $href;
|
||||
$this->class = $class;
|
||||
$this->classActive = $classActive;
|
||||
}
|
||||
|
||||
function isActive()
|
||||
{
|
||||
global $url;
|
||||
global $site;
|
||||
return str_ends_with($this->href, $url->uri()) || ($this->href == $site->url() && $url->uri() == "/");
|
||||
}
|
||||
|
||||
function haveClass()
|
||||
{
|
||||
return ($this->getClasses() != "");
|
||||
}
|
||||
|
||||
function getClasses()
|
||||
{
|
||||
return $this->class . ($this->isActive() ? " " . $this->classActive : "");
|
||||
}
|
||||
|
||||
function toHTML()
|
||||
{
|
||||
return "<a href='" . $this->href . "' " . ($this->haveClass() ? "class='" . $this->getClasses() . "'" : "" ) . ($this->isActive() ? "aria-current='page'" : "") . " >".$this->label."</a>";
|
||||
}
|
||||
}
|
46
bl-kernel/helpers/menus.class.php
Normal file
46
bl-kernel/helpers/menus.class.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php defined('KOBLOG') or die('Koblog CMS.');
|
||||
|
||||
class MenuHelper {
|
||||
|
||||
public static function getArticles($numberOfItems, $showStatic = false, $classUl = "", $classLink = "", $classActive = "active", $include = "")
|
||||
{
|
||||
global $pages;
|
||||
return MenuHelper::toMenu($pages->getArticleLinkList($numberOfItems, $showStatic, $classLink, $classActive), $classUl, $include);
|
||||
}
|
||||
|
||||
public static function getStatics($numberOfItems, $showHome = true, $classUl = "", $classLink = "", $classActive = "active", $include = "")
|
||||
{
|
||||
global $pages;
|
||||
return MenuHelper::toMenu($pages->getStaticLinkList($numberOfItems, $showHome, $classLink, $classActive), $classUl, $include);
|
||||
}
|
||||
|
||||
public static function getArchive($monthly, $classUl = "", $classLink = "", $classActive = "active", $include = "")
|
||||
{
|
||||
global $archives;
|
||||
return MenuHelper::toMenu($archives->getLinkList($monthly, $classLink, $classActive), $classUl, $include);
|
||||
}
|
||||
|
||||
public static function getCategories($showEmpty, $showCount, $classUl = "", $classLink = "", $classActive = "active", $include = "")
|
||||
{
|
||||
global $categories;
|
||||
return MenuHelper::toMenu($categories->getLinkList($showEmpty, $showCount, $classLink, $classActive), $classUl, $include);
|
||||
}
|
||||
|
||||
public static function getTags($minArticle = 1, $classUl = "", $classLink = "", $classActive = "active", $include = "")
|
||||
{
|
||||
global $tags;
|
||||
return MenuHelper::toMenu($tags->getLinkList($minArticle, $classLink, $classActive), $classUl, $include);
|
||||
}
|
||||
|
||||
private static function toMenu($links, $classUl, $include = "")
|
||||
{
|
||||
$html = '<ul '. ($classUl != '' ? 'class="'.$classUl.'"' : '') .'>';
|
||||
foreach ($links as $link) {
|
||||
$html .= "<li>" . $link->toHTML() . "</li>";
|
||||
}
|
||||
$html .= $include;
|
||||
$html .= "</ul>";
|
||||
return $html;
|
||||
}
|
||||
|
||||
}
|
|
@ -163,7 +163,7 @@ class Paginator {
|
|||
if ($i <= 1 || $i >= self::get('numberOfPages') || abs($i - self::currentPage()) < $maxDistance) {
|
||||
if ($i == self::currentPage()) {
|
||||
$html .= '<li class="pagination-page">';
|
||||
$html .= '<span class="current-page">'.($i).'</span>';
|
||||
$html .= '<a href="#" aria-current="page" class="current-page">'.($i).'</a>';
|
||||
$html .= '</li>';
|
||||
} else {
|
||||
$html .= '<li class="pagination-page">';
|
||||
|
@ -198,7 +198,7 @@ class Paginator {
|
|||
return "";
|
||||
}
|
||||
|
||||
$html = '<nav id="paginator">';
|
||||
$html = '<nav id="paginator" aria-label="Pagination">';
|
||||
$html .= '<ul class="pagination '.$class.'">';
|
||||
|
||||
if(self::get('showPrev'))
|
||||
|
@ -216,7 +216,7 @@ class Paginator {
|
|||
if ($i <= 1 || $i >= self::get('numberOfPages') || abs($i - self::currentPage()) < $maxDistance) {
|
||||
if ($i == self::currentPage()) {
|
||||
$html .= '<li class="page-item active">';
|
||||
$html .= '<span class="page-link">'.($i).'</span>';
|
||||
$html .= '<a href="#" class="page-link" aria-current="page">'.($i).'</a>';
|
||||
$html .= '</li>';
|
||||
} else {
|
||||
$html .= '<li class="page-item">';
|
||||
|
|
|
@ -143,6 +143,14 @@ class Theme
|
|||
} catch (Exception $e) {
|
||||
// Author doesn't exist
|
||||
}
|
||||
} elseif ($WHERE_AM_I == 'kind') {
|
||||
try {
|
||||
$kindKey = $url->slug();
|
||||
$format = $site->titleFormatKind();
|
||||
return $L->get($kindKey);
|
||||
} catch (Exception $e) {
|
||||
// Kind doesn't exist
|
||||
}
|
||||
} elseif ($WHERE_AM_I == 'home') {
|
||||
return $L->get("Latest articles");
|
||||
}
|
||||
|
@ -195,6 +203,14 @@ class Theme
|
|||
} catch (Exception $e) {
|
||||
// Author doesn't exist
|
||||
}
|
||||
} elseif ($WHERE_AM_I == 'kind') {
|
||||
try {
|
||||
$kindKey = $url->slug();
|
||||
$format = $site->titleFormatKind();
|
||||
return $L->get('all-post-kind') . " " . $L->get($kindKey);
|
||||
} catch (Exception $e) {
|
||||
// Kind doesn't exist
|
||||
}
|
||||
} elseif ($WHERE_AM_I == 'home') {
|
||||
return $L->get("all-post");
|
||||
}
|
||||
|
@ -221,6 +237,7 @@ class Theme
|
|||
global $categories;
|
||||
global $WHERE_AM_I;
|
||||
global $page;
|
||||
global $L;
|
||||
|
||||
if ($WHERE_AM_I == 'page') {
|
||||
$format = $site->titleFormatPages();
|
||||
|
@ -261,6 +278,14 @@ class Theme
|
|||
} catch (Exception $e) {
|
||||
// Author doesn't exist
|
||||
}
|
||||
} elseif ($WHERE_AM_I == 'kind') {
|
||||
try {
|
||||
$kindKey = $url->slug();
|
||||
$format = $site->titleFormatKind();
|
||||
$format = Text::replace('{{kind-name}}', $L->get($kindKey), $format);
|
||||
} catch (Exception $e) {
|
||||
// Kind doesn't exist
|
||||
}
|
||||
} else {
|
||||
$format = $site->titleFormatHomepage();
|
||||
}
|
||||
|
|
|
@ -535,6 +535,36 @@ class Pages extends dbJSON
|
|||
return false;
|
||||
}
|
||||
|
||||
public function getArticleLinkList($numberOfItems, $showStatic = false, $classLink = "", $classActive = "active")
|
||||
{
|
||||
return $this->getLinkList($numberOfItems, false, true, false, $showStatic, $classLink, $classActive);
|
||||
}
|
||||
|
||||
public function getStaticLinkList($numberOfItems, $showHome = true, $classLink = "", $classActive = "active")
|
||||
{
|
||||
return $this->getLinkList($numberOfItems, $showHome, false, true, false, $classLink, $classActive);
|
||||
}
|
||||
|
||||
private function getLinkList($numberOfItems, $showHome, $published = true, $static = false, $sticky = false, $classLink = "", $classActive = "active")
|
||||
{
|
||||
$publishedPages = $this->getList(1, $numberOfItems, $published, $static, $sticky);
|
||||
$linkList = array();
|
||||
if ($showHome) {
|
||||
global $site;
|
||||
global $L;
|
||||
$linkList[] = new Link($L->get('Home'), $site->url(), $classLink, $classActive);
|
||||
}
|
||||
foreach ($publishedPages as $pageKey) {
|
||||
try {
|
||||
$page = new Page($pageKey);
|
||||
$linkList[] = new Link($page->title(), $page->permalink(), $classLink, $classActive);
|
||||
} catch (Exception $e) {
|
||||
// Continue
|
||||
}
|
||||
}
|
||||
return $linkList;
|
||||
}
|
||||
|
||||
// Returns an array with a list of key of pages, FALSE if out of range
|
||||
// The database is sorted by date or by position
|
||||
// (int) $pageNumber, the page number
|
||||
|
|
|
@ -632,4 +632,10 @@ class Page
|
|||
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function getLink($class, $classActive = "active")
|
||||
{
|
||||
return new Link($this->name(), $this->permalink(), $class, $classActive);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ class Site extends dbJSON
|
|||
'titleFormatTag' => '{{tag-name}} | {{site-title}}',
|
||||
'titleFormatAuthor' => '{{author-name}} | {{site-title}}',
|
||||
'titleFormatArchive' => '{{archive-name}} | {{site-title}}',
|
||||
'titleFormatKind' => '{{kind-name}} | {{site-title}}',
|
||||
'imageRestrict' => true,
|
||||
'imageRelativeToAbsolute' => false,
|
||||
'thumbnailWidth' => 400, // px
|
||||
|
@ -346,6 +347,11 @@ class Site extends dbJSON
|
|||
return $this->getField('titleFormatArchive');
|
||||
}
|
||||
|
||||
public function titleFormatKind()
|
||||
{
|
||||
return $this->getField('titleFormatKind');
|
||||
}
|
||||
|
||||
public function titleFormatAuthor()
|
||||
{
|
||||
return $this->getField('titleFormatAuthor');
|
||||
|
|
|
@ -36,4 +36,20 @@ class Tags extends dbList {
|
|||
return $this->save();
|
||||
}
|
||||
|
||||
public function getLinkList($minArticles = 1, $class = "", $classActive = "active")
|
||||
{
|
||||
$listLink = array();
|
||||
foreach ($this->db as $pageKey=>$pageFields) {
|
||||
$count = count($pageFields['list']);
|
||||
if (
|
||||
($count >= $minArticles)
|
||||
) {
|
||||
$link = DOMAIN_TAGS . $pageKey;
|
||||
$name = $pageFields['name'];
|
||||
$listLink[] = new Link($name, $link, $class, $classActive);
|
||||
}
|
||||
}
|
||||
return $listLink;
|
||||
}
|
||||
|
||||
}
|
|
@ -420,6 +420,7 @@
|
|||
"all-post-tags": "All posts with the tag",
|
||||
"all-post-archive": "All posts written in",
|
||||
"all-post-author": "All posts written by",
|
||||
"all-post-kind": "All posts using the following format :",
|
||||
"all-post": "All the latest posts written on the blog"
|
||||
|
||||
}
|
||||
|
|
|
@ -431,5 +431,6 @@
|
|||
"all-post-tags": "Tous les articles avec le tag",
|
||||
"all-post-archive": "Tous les articles écrits en",
|
||||
"all-post-author": "Tous les articles écrits par",
|
||||
"all-post-kind": "Tous les post utilisant le format suivant :",
|
||||
"all-post": "Tout les articles écrits récemment sur le blog"
|
||||
}
|
|
@ -41,28 +41,12 @@ class pluginArchives extends Plugin
|
|||
|
||||
$filter = $url->filters('archive');
|
||||
|
||||
$html = '<div class="plugin plugin-archives">';
|
||||
$html .= '<h2 class="plugin-label">' . $this->getValue('label') . '</h2>';
|
||||
$html = '<nav class="plugin plugin-archives" aria-labelledby="plugin-archives-title">';
|
||||
$html .= '<h2 class="plugin-label" id="plugin-archives-title">' . $this->getValue('label') . '</h2>';
|
||||
$html .= '<div class="plugin-content">';
|
||||
$html .= '<ul class="flat-list">';
|
||||
|
||||
// By default the database of tags are alphanumeric sorted
|
||||
foreach ($archives->db as $key => $fields) {
|
||||
if (
|
||||
($this->getValue('monthly') && strlen($key) != 4)
|
||||
|| (!$this->getValue('monthly') && strlen($key) == 4)
|
||||
) {
|
||||
$html .= '<li>';
|
||||
$html .= '<a href="' . DOMAIN_ARCHIVES . $key . '">';
|
||||
$html .= $fields['name'];
|
||||
$html .= '</a>';
|
||||
$html .= '</li>';
|
||||
}
|
||||
}
|
||||
|
||||
$html .= '</ul>';
|
||||
$html .= '</div>';
|
||||
$html .= MenuHelper::getArchive($this->getValue('monthly'), "flat-list");
|
||||
$html .= '</div>';
|
||||
$html .= '</nav>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
|
|
@ -41,27 +41,12 @@ class pluginCategories extends Plugin
|
|||
global $categories;
|
||||
|
||||
// HTML for sidebar
|
||||
$html = '<div class="plugin plugin-categories">';
|
||||
$html = '<nav class="plugin plugin-categories">';
|
||||
$html .= '<h2 class="plugin-label">' . $this->getValue('label') . '</h2>';
|
||||
$html .= '<div class="plugin-content">';
|
||||
$html .= '<ul>';
|
||||
|
||||
// By default the database of categories are alphanumeric sorted
|
||||
foreach ($categories->db as $key => $fields) {
|
||||
$count = count($fields['list']);
|
||||
if (!$this->getValue('hideCero') || $count > 0) {
|
||||
$html .= '<li>';
|
||||
$html .= '<a href="' . DOMAIN_CATEGORIES . $key . '">';
|
||||
$html .= $fields['name'];
|
||||
$html .= ' (' . count($fields['list']) . ')';
|
||||
$html .= '</a>';
|
||||
$html .= '</li>';
|
||||
}
|
||||
}
|
||||
|
||||
$html .= '</ul>';
|
||||
$html .= '</div>';
|
||||
$html .= MenuHelper::getCategories($this->getValue('hideCero'), true);
|
||||
$html .= '</div>';
|
||||
$html .= '</nav>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
|
8
bl-plugins/last-articles/languages/en.json
Normal file
8
bl-plugins/last-articles/languages/en.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"plugin-data":
|
||||
{
|
||||
"name": "Latest articles",
|
||||
"description": "Show latest articles in the blog."
|
||||
},
|
||||
"amount-of-items": "Amount of items"
|
||||
}
|
8
bl-plugins/last-articles/languages/fr_FR.json
Executable file
8
bl-plugins/last-articles/languages/fr_FR.json
Executable file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"plugin-data":
|
||||
{
|
||||
"name": "Derniers articles",
|
||||
"description": "Afficher les derniers articles parus sur le blog."
|
||||
},
|
||||
"amount-of-items": "Quantité d’articles"
|
||||
}
|
11
bl-plugins/last-articles/metadata.json
Normal file
11
bl-plugins/last-articles/metadata.json
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"author": "Koblog",
|
||||
"email": "",
|
||||
"website": "https://plugins.koblog.com",
|
||||
"version": "kb_0.0.1",
|
||||
"releaseDate": "2024-08-23",
|
||||
"license": "MIT",
|
||||
"compatible": "kb_0.0.1",
|
||||
"notes": "",
|
||||
"type": "widget"
|
||||
}
|
59
bl-plugins/last-articles/plugin.php
Normal file
59
bl-plugins/last-articles/plugin.php
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
class pluginLastArticles extends Plugin
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
global $L;
|
||||
// Fields and default values for the database of this plugin
|
||||
$this->dbFields = array(
|
||||
'label' => $L->get('Lastest articles'),
|
||||
'numberOfItems' => 5
|
||||
);
|
||||
}
|
||||
|
||||
// Method called on the settings of the plugin on the admin area
|
||||
public function form()
|
||||
{
|
||||
global $L;
|
||||
|
||||
$html = '<div>';
|
||||
$html .= '<label>' . $L->get('Label') . '</label>';
|
||||
$html .= '<input id="jslabel" name="label" type="text" dir="auto" value="' . $this->getValue('label') . '">';
|
||||
$html .= '<span class="tip">' . $L->get('This title is almost always used in the sidebar of the site') . '</span>';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div>';
|
||||
$html .= '<label>' . $L->get('Amount of items') . '</label>';
|
||||
$html .= '<input id="jsnumberOfItems" name="numberOfItems" type="text" dir="auto" value="' . $this->getValue('numberOfItems') . '">';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
// Method called on the sidebar of the website
|
||||
public function siteSidebar()
|
||||
{
|
||||
global $L;
|
||||
global $url;
|
||||
global $site;
|
||||
global $pages;
|
||||
|
||||
// HTML for sidebar
|
||||
$html = '<nav class="plugin plugin-lastarticles">';
|
||||
|
||||
// Print the label if not empty
|
||||
$label = $this->getValue('label');
|
||||
if (!empty($label)) {
|
||||
$html .= '<h2 class="plugin-label">' . $label . '</h2>';
|
||||
}
|
||||
|
||||
$html .= '<div class="plugin-content">';
|
||||
$html .= MenuHelper::getArticles($this->getValue('numberOfItems'), false);
|
||||
$html .= '</div>';
|
||||
$html .= '</nav>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
|
@ -2,9 +2,8 @@
|
|||
"plugin-data":
|
||||
{
|
||||
"name": "Navigation",
|
||||
"description": "Créez votre propre menu de navigation avec les dernières pages ou pages statiques."
|
||||
"description": "Créez votre propre menu de navigation avec les différentes pages non-statiques et leurs enfants."
|
||||
},
|
||||
"home-link": "Lien de la page d’accueil",
|
||||
"show-the-home-link-on-the-sidebar": "Afficher un lien vers la page d’accueil dans la barre latérale.",
|
||||
"amount-of-items": "Quantité d’articles"
|
||||
"show-the-home-link-on-the-sidebar": "Afficher un lien vers la page d’accueil dans la barre latérale."
|
||||
}
|
|
@ -8,8 +8,7 @@ class pluginNavigation extends Plugin
|
|||
// Fields and default values for the database of this plugin
|
||||
$this->dbFields = array(
|
||||
'label' => 'Navigation',
|
||||
'homeLink' => true,
|
||||
'numberOfItems' => 5
|
||||
'homeLink' => true
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -33,13 +32,6 @@ class pluginNavigation extends Plugin
|
|||
$html .= '<span class="tip">' . $L->get('Show the home link on the sidebar') . '</span>';
|
||||
$html .= '</div>';
|
||||
|
||||
if (ORDER_BY == 'date') {
|
||||
$html .= '<div>';
|
||||
$html .= '<label>' . $L->get('Amount of items') . '</label>';
|
||||
$html .= '<input id="jsnumberOfItems" name="numberOfItems" type="text" dir="auto" value="' . $this->getValue('numberOfItems') . '">';
|
||||
$html .= '</div>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
@ -52,7 +44,7 @@ class pluginNavigation extends Plugin
|
|||
global $pages;
|
||||
|
||||
// HTML for sidebar
|
||||
$html = '<div class="plugin plugin-navigation">';
|
||||
$html = '<nav class="plugin plugin-navigation">';
|
||||
|
||||
// Print the label if not empty
|
||||
$label = $this->getValue('label');
|
||||
|
@ -70,51 +62,29 @@ class pluginNavigation extends Plugin
|
|||
$html .= '</li>';
|
||||
}
|
||||
|
||||
// Pages order by position
|
||||
if (ORDER_BY == 'position') {
|
||||
// Get parents
|
||||
$parents = buildParentPages();
|
||||
foreach ($parents as $parent) {
|
||||
$html .= '<li class="parent">';
|
||||
$html .= '<a href="' . $parent->permalink() . '">' . $parent->title() . '</a>';
|
||||
// Get parents
|
||||
$parents = buildParentPages();
|
||||
foreach ($parents as $parent) {
|
||||
$html .= '<li class="parent">';
|
||||
$html .= '<a href="' . $parent->permalink() . '">' . $parent->title() . '</a>';
|
||||
|
||||
if ($parent->hasChildren()) {
|
||||
// Get children
|
||||
$children = $parent->children();
|
||||
$html .= '<ul class="child">';
|
||||
foreach ($children as $child) {
|
||||
$html .= '<li class="child">';
|
||||
$html .= '<a class="child" href="' . $child->permalink() . '">' . $child->title() . '</a>';
|
||||
$html .= '</li>';
|
||||
}
|
||||
$html .= '</ul>';
|
||||
}
|
||||
$html .= '</li>';
|
||||
}
|
||||
}
|
||||
// Pages order by date
|
||||
else {
|
||||
// List of published pages
|
||||
$onlyPublished = true;
|
||||
$pageNumber = 1;
|
||||
$numberOfItems = $this->getValue('numberOfItems');
|
||||
$publishedPages = $pages->getList($pageNumber, $numberOfItems, $onlyPublished);
|
||||
|
||||
foreach ($publishedPages as $pageKey) {
|
||||
try {
|
||||
$page = new Page($pageKey);
|
||||
$html .= '<li>';
|
||||
$html .= '<a href="' . $page->permalink() . '">' . $page->title() . '</a>';
|
||||
if ($parent->hasChildren()) {
|
||||
// Get children
|
||||
$children = $parent->children();
|
||||
$html .= '<ul class="child">';
|
||||
foreach ($children as $child) {
|
||||
$html .= '<li class="child">';
|
||||
$html .= '<a class="child" href="' . $child->permalink() . '">' . $child->title() . '</a>';
|
||||
$html .= '</li>';
|
||||
} catch (Exception $e) {
|
||||
// Continue
|
||||
}
|
||||
$html .= '</ul>';
|
||||
}
|
||||
$html .= '</li>';
|
||||
}
|
||||
|
||||
$html .= '</ul>';
|
||||
$html .= '</div>';
|
||||
$html .= '</div>';
|
||||
$html .= '</nav>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ class pluginStaticPages extends Plugin
|
|||
global $pages;
|
||||
|
||||
// HTML for sidebar
|
||||
$html = '<div class="plugin plugin-static-pages">';
|
||||
$html = '<nav class="plugin plugin-static-pages">';
|
||||
|
||||
// Print the label if not empty
|
||||
$label = $this->getValue('label');
|
||||
|
@ -53,30 +53,9 @@ class pluginStaticPages extends Plugin
|
|||
}
|
||||
|
||||
$html .= '<div class="plugin-content">';
|
||||
$html .= '<ul>';
|
||||
|
||||
// Show Home page link
|
||||
if ($this->getValue('homeLink')) {
|
||||
$html .= '<li>';
|
||||
$html .= '<a href="' . $site->url() . '">' . $L->get('Home') . '</a>';
|
||||
$html .= '</li>';
|
||||
}
|
||||
|
||||
// Show static pages
|
||||
$staticPages = buildStaticPages();
|
||||
foreach ($staticPages as $page) {
|
||||
if ($page->isParent()) {
|
||||
$html .= '<li class="parent">';
|
||||
} else {
|
||||
$html .= '<li class="subpage" style="margin-left: 10px">';
|
||||
}
|
||||
$html .= '<a href="' . $page->permalink() . '">' . $page->title() . '</a>';
|
||||
$html .= '</li>';
|
||||
}
|
||||
|
||||
$html .= '</ul>';
|
||||
$html .= '</div>';
|
||||
$html .= MenuHelper::getStatics(-1, $this->getValue('homeLink'));
|
||||
$html .= '</div>';
|
||||
$html .= '</nav>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
|
|
@ -31,23 +31,12 @@ class pluginTags extends Plugin
|
|||
|
||||
$filter = $url->filters('tag');
|
||||
|
||||
$html = '<div class="plugin plugin-tags">';
|
||||
$html = '<nav class="plugin plugin-tags">';
|
||||
$html .= '<h2 class="plugin-label">' . $this->getValue('label') . '</h2>';
|
||||
$html .= '<div class="plugin-content">';
|
||||
$html .= '<ul class="flat-list">';
|
||||
|
||||
// By default the database of tags are alphanumeric sorted
|
||||
foreach ($tags->db as $key => $fields) {
|
||||
$html .= '<li>';
|
||||
$html .= '<a href="' . DOMAIN_TAGS . $key . '">';
|
||||
$html .= $fields['name'];
|
||||
$html .= '</a>';
|
||||
$html .= '</li>';
|
||||
}
|
||||
|
||||
$html .= '</ul>';
|
||||
$html .= '</div>';
|
||||
$html .= MenuHelper::getTags(1, "flat-list");
|
||||
$html .= '</div>';
|
||||
$html .= '</nav>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
|
|
@ -48,10 +48,12 @@ header#main-header {
|
|||
padding:8px;
|
||||
a {
|
||||
color:white!important;
|
||||
outline-color: white;
|
||||
border-radius: var(--border-radius);
|
||||
padding:8px;
|
||||
}
|
||||
a:hover {
|
||||
a:hover,
|
||||
a.active {
|
||||
background-color: rgba(255,255,255,0.2);
|
||||
}
|
||||
}
|
||||
|
@ -129,30 +131,34 @@ aside {
|
|||
.plugin {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
a.active {
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
nav ul {
|
||||
header#main-header nav ul {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
padding: .5rem 0;
|
||||
}
|
||||
|
||||
nav ul li {
|
||||
header#main-header nav ul li {
|
||||
list-style-type: none;
|
||||
margin: 0
|
||||
}
|
||||
|
||||
nav ul li a,
|
||||
nav ul li span {
|
||||
header#main-header nav ul li a,
|
||||
header#main-header nav ul li span {
|
||||
padding: .5rem
|
||||
}
|
||||
|
||||
|
||||
nav ul li.separator {
|
||||
header#main-header nav ul li.separator {
|
||||
margin-right: auto
|
||||
}
|
||||
|
||||
nav ul li.separator-left {
|
||||
header#main-header nav ul li.separator-left {
|
||||
margin-left: auto
|
||||
}
|
||||
|
||||
|
@ -179,6 +185,10 @@ article {
|
|||
margin: 0 0 1rem 0
|
||||
}
|
||||
|
||||
.no-margin {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
p:last-child {
|
||||
margin-bottom: 0
|
||||
}
|
||||
|
|
|
@ -1,14 +1,5 @@
|
|||
<header id="main-header">
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="<?php echo Theme::siteUrl() ?>"><?php echo $L->get('Home'); ?></a></li>
|
||||
<!-- Static pages -->
|
||||
<?php foreach ($staticContent as $staticPage) : ?>
|
||||
<li><a href="<?php echo $staticPage->permalink() ?>"><?php echo $staticPage->title() ?></a></li>
|
||||
<?php endforeach ?>
|
||||
<li class="separator-left"><a href="<?php echo Theme::siteUrl() ?>rss.xml">RSS</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<nav aria-label="<?php $language->p('Pages') ?>"><?php echo MenuHelper::getStatics(6, true, "", "", "active", '<li class="separator-left"><a href="'.Theme::siteUrl().'rss.xml">RSS</a></li>'); ?></nav>
|
||||
<hgroup id="title-container">
|
||||
<?php $logo = MediaHelper::getLogo(); ?>
|
||||
<?php if ($logo) : ?>
|
||||
|
@ -18,14 +9,5 @@
|
|||
<p><?php echo $site->description() ?></p>
|
||||
<?php endif ?>
|
||||
</hgroup>
|
||||
<nav>
|
||||
<ul>
|
||||
<?php foreach (getCategories() as $category) : ?>
|
||||
<?php if (count($category->pages())>0) : ?>
|
||||
<li><a href="<?php echo $category->permalink(); ?>"><?php echo $category->name(); ?> </a></li>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
|
||||
</nav>
|
||||
<nav aria-label="<?php $language->p('Categories') ?>"><?php echo MenuHelper::getCategories(true, false); ?></nav>
|
||||
</header>
|
|
@ -1,4 +1,4 @@
|
|||
<div class="h-feed">
|
||||
<div class="h-feed hfeed">
|
||||
|
||||
<?php if ($WHERE_AM_I == 'home') : ?>
|
||||
<?php echo Theme::getHomepagePresentation(); ?>
|
||||
|
@ -16,13 +16,13 @@
|
|||
|
||||
<div class="article-list"><?php foreach ($content as $page) : ?>
|
||||
<!-- Post -->
|
||||
<article class="h-entry">
|
||||
<article class="h-entry hentry">
|
||||
<!-- Load Koblog Plugins: Page Begin -->
|
||||
<?php Theme::plugins('pageBegin'); ?>
|
||||
|
||||
<!-- Title -->
|
||||
<h3 class="title p-name">
|
||||
<a class="u-url" href="<?php echo $page->permalink(); ?>"><?php echo $page->title(); ?></a>
|
||||
<h3 class="title p-name entry-title">
|
||||
<a class="u-url" rel="bookmark" href="<?php echo $page->permalink(); ?>"><?php echo $page->title(); ?></a>
|
||||
</h3>
|
||||
|
||||
<!-- Cover image -->
|
||||
|
@ -38,9 +38,9 @@
|
|||
<div class="article-metadata flex p">
|
||||
<div>
|
||||
<?php if ($themePlugin->dateFormat() == 'relative') : ?>
|
||||
<time class="dt-published" datetime="<?php echo $page->date(DATE_ATOM) ?>"><?php echo $page->relativeTime() ?></time>
|
||||
<time class="dt-published published" datetime="<?php echo $page->date(DATE_ATOM) ?>"><?php echo $page->relativeTime() ?></time>
|
||||
<?php else : ?>
|
||||
<time class="dt-published" datetime="<?php echo $page->date(DATE_ATOM) ?>"><?php echo $page->date() ?></time>
|
||||
<time class="dt-published published" datetime="<?php echo $page->date(DATE_ATOM) ?>"><?php echo $page->date() ?></time>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<div><?php echo $L->get('Reading time') . ': ' . $page->readingTime(); ?></div>
|
||||
|
@ -48,12 +48,12 @@
|
|||
|
||||
<!-- Breaked content -->
|
||||
<?php if ($page->readMore()) : ?>
|
||||
<div class="p-summary"><?php echo $page->contentBreak(); ?></div>
|
||||
<div class="p-summary entry-summary"><?php echo $page->contentBreak(); ?></div>
|
||||
<?php else : ?>
|
||||
<?php if ($page->description()) : ?>
|
||||
<div class="p-summary p"><?php echo $page->description(); ?></div>
|
||||
<div class="p-summary p entry-summary"><?php echo $page->description(); ?></div>
|
||||
<?php else : ?>
|
||||
<div class="e-content p"><?php echo $page->contentBreak(); ?></div>
|
||||
<div class="e-content p entry-content"><?php echo $page->contentBreak(); ?></div>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
<!-- "Read more" button -->
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<!-- Post -->
|
||||
<article id="article-solo" class="h-entry">
|
||||
<article id="article-solo" class="h-entry hentry">
|
||||
|
||||
<!-- Load Koblog Plugins: Page Begin -->
|
||||
<?php Theme::plugins('pageBegin'); ?>
|
||||
|
||||
<!-- Title -->
|
||||
<h2 class="title p-name">
|
||||
<a class="u-url" href="<?php echo $page->permalink(); ?>"><?php echo $page->title(); ?></a>
|
||||
<h2 class="title p-name entry-title">
|
||||
<a class="u-url" href="<?php echo $page->permalink(); ?>" rel="bookmark"><?php echo $page->title(); ?></a>
|
||||
</h2>
|
||||
|
||||
<!-- Cover image -->
|
||||
|
@ -17,18 +17,18 @@
|
|||
<!-- Creation date -->
|
||||
<?php if (!$page->isStatic() && !$url->notFound()) : ?>
|
||||
<div class="article-metadata flex p">
|
||||
<div><time class="dt-published" datetime="<?php echo $page->date(DATE_ATOM) ?>"><?php echo $page->date(); ?></time></div>
|
||||
<div><time class="dt-published published" datetime="<?php echo $page->date(DATE_ATOM) ?>"><?php echo $page->date(); ?></time></div>
|
||||
<div><?php echo $L->get('Reading time') . ': ' . $page->readingTime(); ?></div>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($page->description()) : ?>
|
||||
<div class="p-summary p article-metadata"><?php echo $page->description(); ?></div>
|
||||
<div class="p-summary p article-metadata entry-summary"><?php echo $page->description(); ?></div>
|
||||
<hr />
|
||||
<?php endif ?>
|
||||
|
||||
<!-- Full content -->
|
||||
<div class="article-body e-content">
|
||||
<div class="article-body e-content entry-content">
|
||||
<?php echo $page->content(); ?>
|
||||
</div>
|
||||
<?php if (!$page->isStatic() && !$url->notFound()) : ?>
|
||||
|
@ -45,20 +45,20 @@
|
|||
<?php endforeach ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card author-area p-author h-card">
|
||||
<div class="card author-area p-author h-card vcard author">
|
||||
<div class="author-identity">
|
||||
<img alt="" class="avatar u-photo" src="<?php echo ($page->user('profilePicture'));?>" height="64" width="64" decoding="async">
|
||||
<img alt="" class="avatar u-photo photo" src="<?php echo ($page->user('profilePicture'));?>" height="64" width="64" decoding="async">
|
||||
<div class="author-metadata">
|
||||
<div class="author-pseudo">
|
||||
Écrit par <a href="<?php echo $page->user('authorUri'); ?>" class="p-name"><?php echo $page->user('displayName'); ?></a>
|
||||
<p class="author-pseudo no-margin">
|
||||
Écrit par <a href="<?php echo $page->user('authorUri'); ?>" class="p-name fn"><?php echo $page->user('displayName'); ?></a>
|
||||
<span class="pill p-pronouns"><?php echo $page->user('pronouns'); ?></span>
|
||||
</div>
|
||||
<div class="p-note"><?php echo $page->user('description'); ?></div>
|
||||
</p>
|
||||
<p class="p-note note no-margin"><?php echo $page->user('description'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="author-links">
|
||||
<?php if ($page->user('homepage')):?>
|
||||
<li><a href="<?php echo ($page->user('homepage'));?>" class="u-url">Homepage</a> </li>
|
||||
<li><a href="<?php echo ($page->user('homepage'));?>" class="u-url url">Homepage</a> </li>
|
||||
<?php endif ?>
|
||||
<?php foreach ($page->user('socials') as $key => $social):?>
|
||||
<li><a href="<?php echo ($social->url);?>" rel="me"><?php echo $social->name; ?></a> </li>
|
||||
|
|
|
@ -75,7 +75,8 @@ class defaultTheme extends Plugin
|
|||
if ($this->getValue('banner') == '') {
|
||||
return '';
|
||||
}
|
||||
return new Media($this->getValue('banner'))->permalink();
|
||||
$banner = new Media($this->getValue('banner'));
|
||||
return $banner->permalink();
|
||||
}
|
||||
|
||||
public function backgroundURI()
|
||||
|
@ -83,6 +84,7 @@ class defaultTheme extends Plugin
|
|||
if ($this->getValue('background') == '') {
|
||||
return '';
|
||||
}
|
||||
return new Media($this->getValue('background'))->permalink();
|
||||
$background = new Media($this->getValue('background'));
|
||||
return $background->permalink();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue