This commit is contained in:
brol 2015-04-25 20:38:55 +02:00
parent de6cb68981
commit a8692bb2e7
10 changed files with 202 additions and 1 deletions

View file

@ -1,2 +1,2 @@
# shortArchives # shortArchives
Permet d'afficher les archives du blog dans un menu accordéon, trié par années. Afficher les archives du blog dans un menu accordéon, trié par années.

15
_admin.php Normal file
View file

@ -0,0 +1,15 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
# This file is part of shortArchives, a plugin for Dotclear.
#
# Copyright (c) 2009-2015 - annso and contributors
# contact@as-i-am.fr
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) {return;}
require dirname(__FILE__).'/_widgets.php';

28
_define.php Normal file
View file

@ -0,0 +1,28 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
# This file is part of shortArchives, a plugin for Dotclear.
#
# Copyright (c) 2009-2015 - annso and contributors
# contact@as-i-am.fr
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) {return;}
$this->registerModule(
/* Name */ "shortArchives",
/* Description*/ "Display blog archives in an accordion menu, sorted by year",
/* Author */ "annso, Pierre Van Glabeke",
/* Version */ "1.6",
/* Properties */
array(
'permissions' => 'usage,contentadmin',
'type' => 'plugin',
'dc_min' => '2.7',
'support' => 'http://forum.dotclear.org/viewtopic.php?pid=321044#p321044',
'details' => 'http://plugins.dotaddict.org/dc2/details/shortArchives'
)
);

76
_public.php Normal file
View file

@ -0,0 +1,76 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
# This file is part of shortArchives, a plugin for Dotclear.
#
# Copyright (c) 2009-2015 - annso and contributors
# contact@as-i-am.fr
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) {return;}
require dirname(__FILE__).'/_widgets.php';
$core->addBehavior('publicHeadContent',array('publicShortArchives','publicHeadContent'));
class publicShortArchives
{
public static function publicHeadContent($core)
{
$url = $core->blog->getQmarkURL().'pf='.basename(dirname(__FILE__));
echo '<script type="text/javascript" src="'.$url.'/js/accordion.js"></script>'."\n";
echo '<link rel="stylesheet" type="text/css" media="projection, screen" href="'.$url."/css/shortArchives.css\" />\n";
}
}
class tplShortArchives
{
public static function shortArchivesWidgets($w)
{
global $core;
if ($w->offline)
return;
if (($w->homeonly == 1 && $core->url->type != 'default') ||
($w->homeonly == 2 && $core->url->type == 'default')) {
return;
}
$params = array();
$params['type'] = 'month';
$rs = $core->blog->getDates($params);
unset($params);
if ($rs->isEmpty()) {
return;
}
$posts = array();
while ($rs->fetch()) {
$posts[dt::dt2str(__('%Y'),$rs->dt)][] = array('url' => $rs->url($core),
'date' => html::escapeHTML(dt::dt2str(__('%B'),$rs->dt)),
'nbpost' => $rs->nb_post);
}
$res =
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
'<ul>';
foreach($posts as $annee=>$post) {
$res .= '<li><span>'.$annee.'</span><ul>';
for($i=0; $i<sizeof($post); $i++) {
$res .=
'<li><a href="'.$post[$i]['url'].'">'.$post[$i]['date'].'</a>'.
($w->postcount ? ' ('.$post[$i]['nbpost'].')' : '').
'</li>';
}
$res .= '</ul></li>';
}
$res .= '</ul>';
return $w->renderDiv($w->content_only,'shortArchives '.$w->class,'',$res);
}
}

36
_widgets.php Normal file
View file

@ -0,0 +1,36 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
# This file is part of shortArchives, a plugin for Dotclear.
#
# Copyright (c) 2009-2015 - annso and contributors
# contact@as-i-am.fr
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { return; }
$core->addBehavior('initWidgets',array('shortArchivesWidgets','initWidgets'));
class shortArchivesWidgets
{
public static function initWidgets($w)
{
$w->create('shortArchives',__('Short Archives'), array('tplShortArchives','shortArchivesWidgets'),
null,
__('Blog Archive List an accordion menu, sorted by year'));
$w->shortArchives->setting('title',__('Title:'),__('Archives'));
$w->shortArchives->setting('postcount',__('With entries counts'),1,'check');
$w->shortArchives->setting('homeonly',__('Display on:'),0,'combo',
array(
__('All pages') => 0,
__('Home page only') => 1,
__('Except on home page') => 2
)
);
$w->shortArchives->setting('content_only',__('Content only'),0,'check');
$w->shortArchives->setting('class',__('CSS class:'),'');
$w->shortArchives->setting('offline',__('Offline'),0,'check');
}
}

7
changelog Normal file
View file

@ -0,0 +1,7 @@
v1.6 - 25-04-2015 - Pierre Van Glabeke
* modif appel css
* ajout localisation
* ajout identification widget
v1.5 - 14-12-2014 - Pierre Van Glabeke
* compatibilité dc2.7

5
css/shortArchives.css Normal file
View file

@ -0,0 +1,5 @@
.shortArchives li a.archives-year {
background: url(index.php?pf=shortArchives/img/bullet_arrow_down.png) left center no-repeat;
padding-left: 20px;
}
.shortArchives li ul li { list-style-type: none;}

BIN
img/bullet_arrow_down.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 B

18
js/accordion.js Normal file
View file

@ -0,0 +1,18 @@
$(document).ready(function(){
$(".shortArchives li ul:not(:first)").hide();
$(".shortArchives li span").each( function () {
var txt = $(this).text();
$(this).replaceWith('<a href="" class="archives-year">' + txt + '<\/a>') ;
} ) ;
$(".shortArchives li a.archives-year").click(function(){
if ($(this).next(".shortArchives li ul:visible").length != 0) {
$(".shortArchives li ul:visible").slideUp("normal", function () { $(this).parent().removeClass("open") });
} else {
$(".shortArchives li ul").slideUp("normal", function () { $(this).parent().removeClass("open") });
$(this).next("ul").slideDown("normal", function () { $(this).parent().addClass("open") });
}
return false;
});
});

16
locales/fr/main.po Normal file
View file

@ -0,0 +1,16 @@
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Project-Id-Version: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: brol <contact@brol.info>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "Display blog archives in an accordion menu, sorted by year"
msgstr "Afficher les archives du blog dans un menu accordéon, trié par années"
msgid "Blog Archive List an accordion menu, sorted by year"
msgstr "Liste des archives du blog dans un menu accordéon, trié par années"