2015-03-11

This commit is contained in:
brol 2015-04-22 17:07:20 +02:00
parent 6c4921ed59
commit ae6e76c8fb
9 changed files with 506 additions and 15 deletions

12
CHANGELOG Normal file
View file

@ -0,0 +1,12 @@
2015-03-11 - Pierre Van Glabeke
* ajout mode hors ligne et codage titre widget (widget)
* encodage UNIX (LF)
* modif url de support
* modifs localisation
* suppression icône
2013.11.18 - Jean-Christian Denis
* First hg release
2013.07.22 - Jean-Christian Denis
* First release

23
LICENSE
View file

@ -1,12 +1,12 @@
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 2, June 1991 Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/> Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
Preamble Preamble
The licenses for most software are designed to take away your The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public freedom to share and change it. By contrast, the GNU General Public
@ -56,7 +56,7 @@ patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and The precise terms and conditions for copying, distribution and
modification follow. modification follow.
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains 0. This License applies to any program or other work which contains
@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally. of promoting the sharing and reuse of software generally.
NO WARRANTY NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES. POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it possible use to the public, the best way to achieve this is to make it
@ -290,8 +290,8 @@ to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found. the "copyright" line and a pointer to where the full notice is found.
{description} <one line to give the program's name and a brief idea of what it does.>
Copyright (C) {year} {fullname} Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -329,7 +329,7 @@ necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker. `Gnomovision' (which makes passes at compilers) written by James Hacker.
{signature of Ty Coon}, 1 April 1989 <signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice Ty Coon, President of Vice
This General Public License does not permit incorporating your program into This General Public License does not permit incorporating your program into
@ -337,4 +337,3 @@ proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. Public License instead of this License.

View file

@ -1,4 +1,23 @@
# dcLatestVersions # README
Afficher les dernières versions disponibles de Dotclear
Ce plugin ajoute simplement un élément sur le tableau de bord l'administration et un widget coté public indiquant les dernières versions (nightly build) de Dotclear. ## WHAT IS DCLATESTVERSION ?
"Dotclear's latest versions" is a plugin for the open-source
web publishing software called Dotclear.
Simply show visitors last versions of nightly build of Dotclear.
## REQUIREMENTS
dcLatestVersions requires:
* permissions to manage widgets
* Dotclear 2.6
## USAGE
First install dcLatestVersions, manualy from a zip package or from
Dotaddict repository. (See Dotclear's documentation to know how do this)
Add and configure "Dotclear's latest versions" from widgets manager.
You can add a dashboard item by enable it from your dashboard preferences.

136
_admin.php Normal file
View file

@ -0,0 +1,136 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of dcLatestVersions, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
#
# 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 null;
}
require dirname(__FILE__).'/_widgets.php';
# Dashboard item and user preference
$core->addBehavior(
'adminDashboardItems',
array('dcLatestVersionsAdmin', 'adminDashboardItems')
);
$core->addBehavior(
'adminDashboardOptionsForm',
array('dcLatestVersionsAdmin', 'adminDashboardOptionsForm')
);
$core->addBehavior(
'adminAfterDashboardOptionsUpdate',
array('dcLatestVersionsAdmin', 'adminAfterDashboardOptionsUpdate')
);
/**
* @ingroup DC_PLUGIN_DCLATESTVERSIONS
* @brief Display latest versions of Dotclear - admin methods.
* @since 2.6
*/
class dcLatestVersionsAdmin
{
public static function adminDashboardItems(dcCore $core, $__dashboard_items)
{
if (!$core->auth->user_prefs->dashboard->get('dcLatestVersionsItems')) {
return null;
}
$builds = (string) $core->blog->settings->dcLatestVersions->builds;
$builds = explode(',', $builds);
if (empty($builds)) {
return null;
}
$text = __('<li><a href="%u" title="Download Dotclear %v">%r</a> : %v</li>');
$li = array();
foreach($builds as $build) {
$build = strtolower(trim($build));
if (empty($build)) {
continue;
}
$updater = new dcUpdate(
DC_UPDATE_URL,
'dotclear',
$build,
DC_TPL_CACHE.'/versions'
);
if (false === $updater->check('0')) {
return false;
}
$li[] = str_replace(
array(
'%r',
'%v',
'%u'
),
array(
$build,
$updater->getVersion(),
$updater->getFileURL()
),
$text
);
}
if (empty($li)) {
return null;
}
# Display
$__dashboard_items[0][] =
'<div class="box small" id="udclatestversionsitems">'.
'<h3>'.html::escapeHTML(__("Dotclear's latest versions")).'</h3>'.
'<ul>'.implode('', $li).'</ul>'.
'</div>';
}
public static function adminDashboardOptionsForm(dcCore $core)
{
if (!$core->auth->user_prefs->dashboard->prefExists('dcLatestVersionsItems')) {
$core->auth->user_prefs->dashboard->put(
'dcLatestVersionsItems',
false,
'boolean'
);
}
$pref = $core->auth->user_prefs->dashboard->get('dcLatestVersionsItems');
echo
'<div class="fieldset">'.
'<h4>'.__("Dotclear's latest versions").'</h4>'.
'<p><label class="classic" for="dcLatestVersionsItems">'.
form::checkbox('dcLatestVersionsItems', 1, $pref).' '.
__("Show Dotclear's latest versions on dashboards.").
'</label></p>'.
'</div>';
}
public static function adminAfterDashboardOptionsUpdate($user_id)
{
$GLOBALS['core']->auth->user_prefs->dashboard->put(
'dcLatestVersionsItems',
!empty($_POST['dcLatestVersionsItems']),
'boolean'
);
}
}

37
_define.php Normal file
View file

@ -0,0 +1,37 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of dcLatestVersions, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
#
# 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 null;
}
$this->registerModule(
/* Name */
"dcLatestVersions",
/* Description*/
"Show the latest available versions of Dotclear",
/* Author */
"Jean-Christian Denis, Pierre Van Glabeke",
/* Version */
'2015-03-11',
/* Properies */
array(
'permissions' => 'usage,contentadmin',
'type' => 'plugin',
'dc_min' => '2.6',
'support' => 'http://forum.dotclear.org/viewforum.php?id=16',
'details' => 'http://plugins.dotaddict.org/dc2/details/dcLatestVersions'
)
);

75
_install.php Normal file
View file

@ -0,0 +1,75 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of dcLatestVersions, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
#
# 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 null;
}
# -- Module specs --
$dc_min = '2.6';
$mod_id = 'dcLatestVersions';
$mod_conf = array(
array(
'builds',
"List of Dotclear's builds",
'stable,unstable,testing,sexy',
'string'
)
);
# -- Nothing to change below --
try {
# Check module version
if (version_compare(
$core->getVersion($mod_id),
$core->plugins->moduleInfo($mod_id, 'version'),
'>='
)) {
return null;
}
# Check Dotclear version
if (!method_exists('dcUtils', 'versionsCompare')
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
throw new Exception(sprintf(
'%s requires Dotclear %s', $mod_id, $dc_min
));
}
# Set module settings
$core->blog->settings->addNamespace($mod_id);
foreach($mod_conf as $v) {
$core->blog->settings->{$mod_id}->put(
$v[0], $v[2], $v[3], $v[1], false, true
);
}
# Set module version
$core->setVersion(
$mod_id,
$core->plugins->moduleInfo($mod_id, 'version')
);
return true;
}
catch (Exception $e) {
$core->error->add($e->getMessage());
return false;
}

20
_public.php Normal file
View file

@ -0,0 +1,20 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of dcLatestVersions, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
#
# 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 null;
}
require dirname(__FILE__).'/_widgets.php';

151
_widgets.php Normal file
View file

@ -0,0 +1,151 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of dcLatestVersions, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
#
# 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 null;
}
$core->blog->settings->addNamespace('dcLatestVersions');
$core->addBehavior(
'initWidgets',
array('dcLatestVersionsWidget', 'adminWidget')
);
/**
* @ingroup DC_PLUGIN_DCLATESTVERSIONS
* @brief Display latest versions of Dotclear - widget methods.
* @since 2.6
*/
class dcLatestVersionsWidget
{
public static function adminWidget($w)
{
$w->create(
'dclatestversionswidget',
__("Dotclear's latest versions"),
array('dcLatestVersionsWidget','publicWidget'),
null,
__("Show the latest available versions of Dotclear")
);
$w->dclatestversionswidget->setting(
'title',
__('Title:'),
__("Dotclear's latest versions"),
'text'
);
$w->dclatestversionswidget->setting(
'text',
__('Text (%r = release, %v = version, %u = url):'),
__('<strong>%r: </strong> <a href="%u" title="Download Dotclear %v">%v</a>'),
'text'
);
$w->dclatestversionswidget->setting(
'homeonly',
__('Display on:'),
0,
'combo',
array(
__('All pages') => 0,
__('Home page only') => 1,
__('Except on home page') => 2
)
);
$w->dclatestversionswidget->setting(
'content_only',
__('Content only'),
0,
'check'
);
$w->dclatestversionswidget->setting(
'class',
__('CSS class:'),
''
);
$w->dclatestversionswidget->setting('offline',__('Offline'),0,'check');
}
public static function publicWidget($w)
{
global $core;
$core->blog->settings->addNamespace('dcLatestVersions');
if ($w->offline)
return;
# Nothing to display
if ($w->homeonly == 1 && $core->url->type != 'default'
|| $w->homeonly == 2 && $core->url->type == 'default'
|| $w->text == ''
) {
return null;
}
# Builds to check
$builds = (string) $core->blog->settings->dcLatestVersions->builds;
$builds = explode(',', $builds);
if (empty($builds)) {
return null;
}
$li = array();
foreach($builds as $build) {
$build = strtolower(trim($build));
if (empty($build)) {
continue;
}
$updater = new dcUpdate(
DC_UPDATE_URL,
'dotclear',
$build,
DC_TPL_CACHE.'/versions'
);
if (false === $updater->check('0')) {
continue;
}
$li[] = '<li>'.str_replace(
array(
'%r',
'%v',
'%u'
),
array(
$build,
$updater->getVersion(),
$updater->getFileURL()
),
$w->text
).'</li>';
}
if (empty($li)) {
return null;
}
# Display
$res =
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
'<ul>'.implode('',$li).'</ul>';
return $w->renderDiv($w->content_only,'dclatestversionswidget '.$w->class,'',$res);
}
}

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

@ -0,0 +1,42 @@
# Language: Français
# Module: dcLatestVersions - 2013.11.18
# Date: 2013-11-18 23:07:16
# Translated with translater 2013.05.11
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Project-Id-Version: dcLatestVersions 2013.11.18\n"
"POT-Creation-Date: \n"
"PO-Revision-Date: 2013-11-18T23:07:16+00:00\n"
"Last-Translator: Jean-Christian Denis\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
#: _admin.php:57
msgid "<li><a href=\"%u\" title=\"Download Dotclear %v\">%r</a> : %v</li>"
msgstr "<li><a href=\"%u\" title=\"Télécharger Dotclear %v\">%r</a> : %v</li>"
#: _admin.php:102
#: _admin.php:120
#: _widgets.php:32
#: _widgets.php:40
msgid "Dotclear's latest versions"
msgstr "Dernières versions de Dotclear"
#: _admin.php:123
msgid "Show Dotclear's latest versions on dashboards."
msgstr "Afficher les dernières versions de Dotclear sur le tableau de bord"
#: _widgets.php:35
msgid "Show the latest available versions of Dotclear"
msgstr "Afficher les dernières versions disponibles de Dotclear"
#: _widgets.php:45
msgid "Text (%r = release, %v = version, %u = url):"
msgstr "Texte (%r = type, %v = version, %u = url) :"
#: _widgets.php:46
msgid "<strong>%r: </strong> <a href=\"%u\" title=\"Download Dotclear %v\">%v</a>"
msgstr "<strong>%r : </strong> <a href=\"%u\" title=\"Télécharger Dotclear %v\">%v</a>"