✨ (plugins): add an archive plugin
This commit is contained in:
parent
67ae3af009
commit
7afbf96ca3
6 changed files with 101 additions and 5 deletions
|
@ -182,17 +182,17 @@ function table($type) {
|
||||||
|
|
||||||
<!-- TABS -->
|
<!-- TABS -->
|
||||||
<ul class="nav nav-pills mb-3" role="tablist">
|
<ul class="nav nav-pills mb-3" role="tablist">
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item me-2" role="presentation">
|
||||||
<button class="nav-link active" id="pages-tab" data-bs-toggle="tab" data-bs-target="#pages" role="tab"><?php $L->p('Pages') ?></button>
|
<button class="nav-link active" id="pages-tab" data-bs-toggle="tab" data-bs-target="#pages" role="tab"><?php $L->p('Pages') ?></button>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item me-2" role="presentation">
|
||||||
<button class="nav-link" id="scheduled-tab" data-bs-toggle="tab" data-bs-target="#scheduled" role="tab"><?php $L->p('Scheduled') ?> <?php if (count($scheduled)>0) { echo '<span class="badge bg-danger" style="position:relative;top:-2px;">'.count($scheduled).'</span>'; } ?></button>
|
<button class="nav-link" id="scheduled-tab" data-bs-toggle="tab" data-bs-target="#scheduled" role="tab"><?php $L->p('Scheduled') ?> <?php if (count($scheduled)>0) { echo '<span class="badge bg-danger" style="position:relative;top:-2px;">'.count($scheduled).'</span>'; } ?></button>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item me-2" role="presentation">
|
||||||
<button class="nav-link" id="draft-tab" data-bs-toggle="tab" data-bs-target="#draft" role="tab"><?php $L->p('Draft') ?></button>
|
<button class="nav-link" id="draft-tab" data-bs-toggle="tab" data-bs-target="#draft" role="tab"><?php $L->p('Draft') ?></button>
|
||||||
</li>
|
</li>
|
||||||
<?php if (!empty($autosave)): ?>
|
<?php if (!empty($autosave)): ?>
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item me-2" role="presentation">
|
||||||
<button class="nav-link" id="autosave-tab" data-bs-toggle="tab" data-bs-target="#autosave" role="tab"><?php $L->p('Autosave') ?></button>
|
<button class="nav-link" id="autosave-tab" data-bs-toggle="tab" data-bs-target="#autosave" role="tab"><?php $L->p('Autosave') ?></button>
|
||||||
</li>
|
</li>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
|
@ -35,7 +35,7 @@ class Archives extends dbList {
|
||||||
if (isset($archiveIndex[$month])) {
|
if (isset($archiveIndex[$month])) {
|
||||||
array_push($archiveIndex[$month]['list'], $pageKey);
|
array_push($archiveIndex[$month]['list'], $pageKey);
|
||||||
} else {
|
} else {
|
||||||
$archiveIndex[$month]['name'] = $month;
|
$archiveIndex[$month]['name'] = Date::prettyArchiveDate($month);
|
||||||
$archiveIndex[$month]['list'] = array($pageKey);
|
$archiveIndex[$month]['list'] = array($pageKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
7
bl-plugins/archive/languages/en.json
Normal file
7
bl-plugins/archive/languages/en.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"plugin-data":
|
||||||
|
{
|
||||||
|
"name": "Archives list",
|
||||||
|
"description": "Shows all archives on the sidebar."
|
||||||
|
}
|
||||||
|
}
|
9
bl-plugins/archive/languages/fr_FR.json
Normal file
9
bl-plugins/archive/languages/fr_FR.json
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"plugin-data":
|
||||||
|
{
|
||||||
|
"name": "Liste des archives",
|
||||||
|
"description": "Affiche tous les archives sur la barre latérale."
|
||||||
|
},
|
||||||
|
"monthly": "Mensuel",
|
||||||
|
"show-archives-by-months":"Afficher les archives par mois"
|
||||||
|
}
|
11
bl-plugins/archive/metadata.json
Normal file
11
bl-plugins/archive/metadata.json
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"author": "Koblog",
|
||||||
|
"email": "",
|
||||||
|
"website": "https://plugins.koblog.com",
|
||||||
|
"version": "kb_0.0.1",
|
||||||
|
"releaseDate": "2025-01-25",
|
||||||
|
"license": "MIT",
|
||||||
|
"compatible": "kb_0.0.1",
|
||||||
|
"notes": "",
|
||||||
|
"type": "widget"
|
||||||
|
}
|
69
bl-plugins/archive/plugin.php
Normal file
69
bl-plugins/archive/plugin.php
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class pluginArchives extends Plugin
|
||||||
|
{
|
||||||
|
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
$this->dbFields = array(
|
||||||
|
'label' => 'Archives',
|
||||||
|
'monthly' => false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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>';
|
||||||
|
|
||||||
|
echo Bootstrap::formCheckbox(array(
|
||||||
|
'name' => 'monthly',
|
||||||
|
'label' => $L->g('Monthly'),
|
||||||
|
'labelForCheckbox' => $L->g('Show archives by months.'),
|
||||||
|
'placeholder' => '',
|
||||||
|
'checked' => $this->getValue('monthly'),
|
||||||
|
'tip' => ""
|
||||||
|
));
|
||||||
|
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function siteSidebar()
|
||||||
|
{
|
||||||
|
global $L;
|
||||||
|
global $archives;
|
||||||
|
global $url;
|
||||||
|
|
||||||
|
$filter = $url->filters('archive');
|
||||||
|
|
||||||
|
$html = '<div class="plugin plugin-archives">';
|
||||||
|
$html .= '<h2 class="plugin-label">' . $this->getValue('label') . '</h2>';
|
||||||
|
$html .= '<div class="plugin-content">';
|
||||||
|
$html .= '<ul>';
|
||||||
|
|
||||||
|
// 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 class="flat-list">';
|
||||||
|
$html .= '<a href="' . DOMAIN_ARCHIVES . $key . '">';
|
||||||
|
$html .= $fields['name'];
|
||||||
|
$html .= '</a>';
|
||||||
|
$html .= '</li>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$html .= '</ul>';
|
||||||
|
$html .= '</div>';
|
||||||
|
$html .= '</div>';
|
||||||
|
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue