Add period column to posts list and user pref

This commit is contained in:
Jean-Christian Denis 2021-10-23 21:08:22 +02:00
parent ed3f9e4986
commit d07ae07ad0
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
3 changed files with 227 additions and 410 deletions

View file

@ -33,6 +33,18 @@ $core->addBehavior(
'adminColumnsLists',
['adminPeriodical', 'adminColumnsLists']
);
$core->addBehavior(
'adminColumnsLists',
['adminPeriodical', 'adminColumnsLists']
);
$core->addBehavior(
'adminPostListHeader',
['adminPeriodical', 'adminPostListHeader']
);
$core->addBehavior(
'adminPostListValue',
['adminPeriodical', 'adminPostListValue']
);
if ($core->blog->settings->periodical->periodical_active) {
@ -86,6 +98,7 @@ $core->addBehavior(
class adminPeriodical
{
public static $combo_period = null;
protected static $per = null;
public static function sortbyCombo()
{
@ -96,6 +109,14 @@ class adminPeriodical
];
}
protected static function period($core)
{
if (self::$per === null) {
self::$per = new periodical($core);
}
return self::$per;
}
/**
* Add settings to blog preference
*
@ -143,6 +164,12 @@ class adminPeriodical
$blog_settings->periodical->put('periodical_updurl', !empty($_POST['periodical_updurl']));
}
/**
* User pref for periods columns lists.
*
* @param dcCore $core dcCore instance
* @param arrayObject $cols Columns
*/
public static function adminColumnsLists(dcCore $core, $cols)
{
$cols['periodical'] = [
@ -155,8 +182,16 @@ class adminPeriodical
'enddt' => [true, __('End date')]
]
];
$cols['posts'][1]['period'] = [true, __('Period')];
}
/**
* User pref periods filters options.
*
* @param dcCore $core dcCore instance
* @param arrayObject $sorts Sort options
*/
public static function adminFiltersLists(dcCore $core, $sorts)
{
$sorts['periodical'] = [
@ -168,6 +203,44 @@ class adminPeriodical
];
}
/**
* Add columns period to posts list header.
*
* @param dcCore $core dcCore instance
* @param record $rs record instance
* @param arrayObject $cols Columns
*/
public static function adminPostListHeader(dcCore $core, $rs, $cols)
{
if ($core->blog->settings->periodical->periodical_active) {
$cols['period'] = '<th scope="col">' . __('Period') . '</th>';
}
}
/**
* Add columns period to posts list values.
*
* @param dcCore $core dcCore instance
* @param record $rs record instance
* @param arrayObject $cols Columns
*/
public static function adminPostListValue(dcCore $core, $rs, $cols)
{
if (!$core->blog->settings->periodical->periodical_active) {
return null;
}
$r = self::period($core)->getPosts(['post_id' => $rs->post_id]);
if ($r->isEmpty()) {
$name = '-';
} else {
$url = $core->adminurl->get('admin.plugin.periodical', ['part' => 'period', 'period_id' => $r->periodical_id]);
$name = '<a href="' . $url . '#period" title="' . __('edit period') . '">' . html::escapeHTML($r->periodical_title) . '</a>';
}
$cols['period'] = '<td class="nowrap">' . $name . '</td>';
}
/**
* Favorites.
*
@ -345,8 +418,7 @@ class adminPeriodical
# Get existing linked period
$period = '';
if ($post) {
$per = new periodical($core);
$rs = $per->getPosts(['post_id' => $post->post_id]);
$rs = self::period($core)->getPosts(['post_id' => $post->post_id]);
$period = $rs->isEmpty() ? '' : $rs->periodical_id;
}
@ -407,9 +479,7 @@ class adminPeriodical
protected static function comboPeriod(dcCore $core)
{
if (adminPeriodical::$combo_period === null) {
$per = new periodical($core);
$periods = $per->getPeriods();
$periods = self::period($core)->getPeriods();
if ($periods->isEmpty()) {
adminPeriodical::$combo_period = [];
@ -438,8 +508,7 @@ class adminPeriodical
}
$post_id = (integer) $post_id;
$per = new periodical($core);
$per->delPost($post_id);
self::period($core)->delPost($post_id);
}
/**
@ -456,11 +525,8 @@ class adminPeriodical
return null;
}
# Period object
$per = new periodical($core);
# Get periods
$period = $per->getPeriods(['periodical_id' => $period]);
$period = self::period($core)->getPeriods(['periodical_id' => $period]);
# No period
if ($period->isEmpty()) {
@ -470,6 +536,6 @@ class adminPeriodical
$post_id = (integer) $post_id;
# Add relation
$per->addPost($period->periodical_id, $post_id);
self::period($core)->addPost($period->periodical_id, $post_id);
}
}

View file

@ -1,183 +0,0 @@
<?php
// Language: Français
// Module: periodical - 2021.08.23
// Date: 2021-08-23 23:40:28
// Translated with dcTranslater - 2021.08.18
#_admin.php:32
#_admin.php:109
#_admin.php:158
#_admin.php:215
#_admin.php:223
#_admin.php:374
#index.php:437
#index.php:449
#index.php:500
#index.php:714
#index.php:740
$GLOBALS['__l10n']['Periodical'] = 'Publications périodiques';
#_admin.php:91
#inc/lib.index.pager.php:117
$GLOBALS['__l10n']['Create date'] = 'Date de création';
#_admin.php:115
$GLOBALS['__l10n']['Enable plugin'] = 'Activer le plugin';
#_admin.php:116
$GLOBALS['__l10n']['Dates of published entries'] = 'Dates de billets publiés';
#_admin.php:119
$GLOBALS['__l10n']['Update post date'] = 'Mettre à jour la date du billet';
#_admin.php:122
$GLOBALS['__l10n']['Update post url'] = 'Mettre à jour l\'URL du billet';
#_admin.php:125
$GLOBALS['__l10n']['Order of publication of entries'] = 'Ordre de publication des billets';
#_admin.php:215
$GLOBALS['__l10n']['Add to periodical'] = 'Ajouter aux publications périodiques';
#_admin.php:223
#index.php:500
$GLOBALS['__l10n']['Remove from periodical'] = 'Retirer des publications périodiques';
#_admin.php:253
$GLOBALS['__l10n']['Posts have been removed from periodical.'] = 'Billets retirés des publications périodiques.';
#_admin.php:281
$GLOBALS['__l10n']['Posts have been added to periodical.'] = 'Billets ajoutés aux publications périodiques.';
#_admin.php:291
$GLOBALS['__l10n']['Add a period to this selection'] = 'Ajouter une période à cette liste';
#inc/class.periodical.php:320
$GLOBALS['__l10n']['Hourly'] = 'Toutes les heures';
#inc/class.periodical.php:321
$GLOBALS['__l10n']['twice a day'] = 'Deux fois par jour';
#inc/class.periodical.php:322
$GLOBALS['__l10n']['Daily'] = 'Une fois par jour';
#inc/class.periodical.php:323
$GLOBALS['__l10n']['Weekly'] = 'Une fois par semaine';
#inc/class.periodical.php:324
$GLOBALS['__l10n']['Monthly'] = 'Un fois par mois';
#inc/class.periodical.php:356
#inc/lib.index.pager.php:81
$GLOBALS['__l10n']['Unknow frequence'] = 'Fréquence inconnue';
#inc/lib.index.pager.php:29
$GLOBALS['__l10n']['No period'] = 'Pas de période';
#inc/lib.index.pager.php:41
#index.php:661
$GLOBALS['__l10n']['Next update'] = 'Prochaine mise à jour';
#inc/lib.index.pager.php:43
$GLOBALS['__l10n']['Publications'] = 'Publications';
#inc/lib.index.pager.php:45
#index.php:662
$GLOBALS['__l10n']['End date'] = 'Date de fin';
#inc/lib.index.pager.php:78
$GLOBALS['__l10n']['view related entries'] = 'voir les billets liés';
#inc/lib.index.pager.php:87
$GLOBALS['__l10n']['edit period'] = 'modifier la période';
#inc/lib.index.pager.php:182
$GLOBALS['__l10n']['protected'] = 'protégé';
#inc/lib.index.pager.php:187
$GLOBALS['__l10n']['selected'] = 'sélectionné';
#inc/lib.periodical.socialmewriter.php:24
$GLOBALS['__l10n']['New periodical publication'] = 'Nouvelle publication périodique';
#inc/lib.periodical.socialmewriter.php:25
$GLOBALS['__l10n']['When an entry is published on a period'] = 'Lorsque qu\'un billet st marqué comme publié par une période';
#index.php:41
$GLOBALS['__l10n']['One post per day'] = 'Un billet par jour';
#index.php:53
$GLOBALS['__l10n']['This period does not exist.'] = 'Cette période n\'existe pas.';
#index.php:95
$GLOBALS['__l10n']['Period title is already taken'] = 'Le titre de la période est déjà pris';
#index.php:100
$GLOBALS['__l10n']['Period title is required'] = 'Le titre de la période est requis';
#index.php:103
$GLOBALS['__l10n']['Start date must be older than end date'] = 'La date de début doit être plus ancienne que la date de fin';
#index.php:122
$GLOBALS['__l10n']['Period successfully updated.'] = 'Période mise à jour.';
#index.php:130
$GLOBALS['__l10n']['Period successfully created.'] = 'Période crée.';
#index.php:154
$GLOBALS['__l10n']['Entries successfully published.'] = 'Billets publiés.';
#index.php:176
$GLOBALS['__l10n']['Entries successfully unpublished.'] = 'Billets mis hors ligne.';
#index.php:197
$GLOBALS['__l10n']['Entries successfully removed.'] = 'Billets retirés.';
#index.php:450
#index.php:458
#index.php:746
$GLOBALS['__l10n']['New period'] = 'Nouvelle période';
#index.php:450
#index.php:458
$GLOBALS['__l10n']['Edit period'] = 'Modifier la période';
#index.php:467
$GLOBALS['__l10n']['Next update:'] = 'Prochaine mise à jour :';
#index.php:470
$GLOBALS['__l10n']['End date:'] = 'Date de fin :';
#index.php:475
$GLOBALS['__l10n']['Publication frequency:'] = 'Fréquence de publication :';
#index.php:478
$GLOBALS['__l10n']['Number of entries to publish every time:'] = 'Nombre de billets à publier à chaque fois :';
#index.php:520
$GLOBALS['__l10n']['Entries linked to this period'] = 'Billets liés à cette période';
#index.php:627
$GLOBALS['__l10n']['Periods removed.'] = 'Périodes retirées.';
#index.php:647
$GLOBALS['__l10n']['Periods emptied.'] = 'Périodes vidées.';
#index.php:663
$GLOBALS['__l10n']['Frequence'] = 'Fréquence';
#index.php:672
$GLOBALS['__l10n']['empty periods'] = 'vider les périodes';
#index.php:673
$GLOBALS['__l10n']['delete periods'] = 'effacer les périodes';
#index.php:770
$GLOBALS['__l10n']['Results per page :'] = 'Résultats par page :';
#index.php:794
$GLOBALS['__l10n']['Selected periods action:'] = 'Action sur les périodes selectionnées :';
$GLOBALS['__l10n']['Configuration has been successfully updated.'] = 'La configuration a été mise à jour avec succés.';
$GLOBALS['__l10n']['Published periodically entries'] = 'Publier périodiquement des billets';

View file

@ -1,249 +1,183 @@
# Language: Français
# Module: periodical - 2021.08.23
# Date: 2021-08-23 23:40:28
# Translated with translater 2021.08.18
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Project-Id-Version: periodical 2021.08.23\n"
"Project-Id-Version: periodical 2021.09.02.1\n"
"POT-Creation-Date: \n"
"PO-Revision-Date: 2021-08-23T23:40:28+00:00\n"
"PO-Revision-Date: 2021-10-23T18:59:48+00:00\n"
"Last-Translator: Jean-Christian Denis\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: _admin.php:32
#: _admin.php:109
#: _admin.php:158
#: _admin.php:215
#: _admin.php:223
#: _admin.php:374
#: index.php:437
#: index.php:449
#: index.php:500
#: index.php:714
#: index.php:740
msgid "Periodical"
msgstr "Publications périodiques"
#: _admin.php:91
#: inc/lib.index.pager.php:117
msgid "Create date"
msgstr "Date de création"
#: _admin.php:115
msgid "Enable plugin"
msgstr "Activer le plugin"
#: _admin.php:116
msgid "Dates of published entries"
msgstr "Dates de billets publiés"
#: _admin.php:119
msgid "Update post date"
msgstr "Mettre à jour la date du billet"
#: _admin.php:122
msgid "Update post url"
msgstr "Mettre à jour l'URL du billet"
#: _admin.php:125
msgid "Order of publication of entries"
msgstr "Ordre de publication des billets"
#: _admin.php:215
msgid "Add to periodical"
msgstr "Ajouter aux publications périodiques"
#: _admin.php:223
#: index.php:500
msgid "Remove from periodical"
msgstr "Retirer des publications périodiques"
#: _admin.php:253
msgid "Posts have been removed from periodical."
msgstr "Billets retirés des publications périodiques."
#: _admin.php:281
msgid "Posts have been added to periodical."
msgstr "Billets ajoutés aux publications périodiques."
#: _admin.php:291
msgid "Add a period to this selection"
msgstr "Ajouter une période à cette liste"
#: inc/class.periodical.php:320
msgid "Hourly"
msgstr "Toutes les heures"
#: inc/class.periodical.php:321
msgid "twice a day"
msgstr "Deux fois par jour"
#: inc/class.periodical.php:322
msgid "Daily"
msgstr "Une fois par jour"
#: inc/class.periodical.php:323
msgid "Weekly"
msgstr "Une fois par semaine"
#: inc/class.periodical.php:324
msgid "Monthly"
msgstr "Un fois par mois"
#: inc/class.periodical.php:356
#: inc/lib.index.pager.php:81
msgid "Unknow frequence"
msgstr "Fréquence inconnue"
#: inc/lib.index.pager.php:29
msgid "No period"
msgstr "Pas de période"
#: inc/lib.index.pager.php:41
#: index.php:661
msgid "Next update"
msgstr "Prochaine mise à jour"
#: inc/lib.index.pager.php:43
msgid "Publications"
msgstr "Publications"
#: inc/lib.index.pager.php:45
#: index.php:662
msgid "End date"
msgstr "Date de fin"
#: inc/lib.index.pager.php:78
msgid "view related entries"
msgstr "voir les billets liés"
#: inc/lib.index.pager.php:87
msgid "edit period"
msgstr "modifier la période"
#: inc/lib.index.pager.php:182
msgid "protected"
msgstr "protégé"
#: inc/lib.index.pager.php:187
msgid "selected"
msgstr "sélectionné"
#: inc/lib.periodical.socialmewriter.php:24
msgid "New periodical publication"
msgstr "Nouvelle publication périodique"
#: inc/lib.periodical.socialmewriter.php:25
msgid "When an entry is published on a period"
msgstr "Lorsque qu'un billet st marqué comme publié par une période"
#: index.php:41
msgid "One post per day"
msgstr "Un billet par jour"
#: index.php:53
msgid "This period does not exist."
msgstr "Cette période n'existe pas."
#: index.php:95
msgid "Period title is already taken"
msgstr "Le titre de la période est déjà pris"
#: index.php:100
msgid "Period title is required"
msgstr "Le titre de la période est requis"
#: index.php:103
msgid "Start date must be older than end date"
msgstr "La date de début doit être plus ancienne que la date de fin"
#: index.php:122
msgid "Period successfully updated."
msgstr "Période mise à jour."
#: index.php:130
msgid "Period successfully created."
msgstr "Période crée."
#: index.php:154
msgid "Entries successfully published."
msgstr "Billets publiés."
#: index.php:176
msgid "Entries successfully unpublished."
msgstr "Billets mis hors ligne."
#: index.php:197
msgid "Entries successfully removed."
msgstr "Billets retirés."
#: index.php:450
#: index.php:458
#: index.php:746
msgid "New period"
msgstr "Nouvelle période"
#: index.php:450
#: index.php:458
msgid "Edit period"
msgstr "Modifier la période"
#: index.php:467
msgid "Next update:"
msgstr "Prochaine mise à jour :"
#: index.php:470
msgid "End date:"
msgstr "Date de fin :"
#: index.php:475
msgid "Publication frequency:"
msgstr "Fréquence de publication :"
#: index.php:478
msgid "Number of entries to publish every time:"
msgstr "Nombre de billets à publier à chaque fois :"
#: index.php:520
msgid "Entries linked to this period"
msgstr "Billets liés à cette période"
#: index.php:627
msgid "Periods removed."
msgstr "Périodes retirées."
#: index.php:647
msgid "Periods emptied."
msgstr "Périodes vidées."
#: index.php:663
msgid "Frequence"
msgstr "Fréquence"
#: index.php:672
msgid "Enable plugin"
msgstr "Activer le plugin"
msgid "Dates of published entries"
msgstr "Dates de billets publiés"
msgid "Update post date"
msgstr "Mettre à jour la date du billet"
msgid "Update post url"
msgstr "Mettre à jour l'URL du billet"
msgid "Pub per update"
msgstr "Pub par màj"
msgid "Period"
msgstr "Période"
msgid "periods per page"
msgstr "périodes par page"
msgid "edit period"
msgstr "modifier la période"
msgid "Add to periodical"
msgstr "Ajouter aux publications périodiques"
msgid "Remove from periodical"
msgstr "Retirer des publications périodiques"
msgid "No enough right"
msgstr "Privilèges insuffisants"
msgid "Posts have been removed from periodical."
msgstr "Billets retirés des publications périodiques."
msgid "Posts have been added to periodical."
msgstr "Billets ajoutés aux publications périodiques."
msgid "Add a period to this selection"
msgstr "Ajouter une période à cette liste"
msgid "Hourly"
msgstr "Toutes les heures"
msgid "twice a day"
msgstr "Deux fois par jour"
msgid "Daily"
msgstr "Une fois par jour"
msgid "Weekly"
msgstr "Une fois par semaine"
msgid "Monthly"
msgstr "Un fois par mois"
msgid "Unknow frequence"
msgstr "Fréquence inconnue"
msgid "No period matches the filter"
msgstr "Aucune période correspondant au filtre"
msgid "No period"
msgstr "Pas de période"
msgid "List of %s periods matching the filter."
msgstr "Liste des %s périodes correspondant au filtre."
msgid "List of %s periods."
msgstr "Liste des %s périodes."
msgid "view related entries"
msgstr "voir les billets liés"
msgid "Create date"
msgstr "Date de création"
msgid "protected"
msgstr "protégé"
msgid "selected"
msgstr "sélectionné"
msgid "New periodical publication"
msgstr "Nouvelle publication périodique"
msgid "When an entry is published on a period"
msgstr "Lorsque qu'un billet st marqué comme publié par une période"
msgid "One post per day"
msgstr "Un billet par jour"
msgid "This period does not exist."
msgstr "Cette période n'existe pas."
msgid "Period title is already taken"
msgstr "Le titre de la période est déjà pris"
msgid "Period title is required"
msgstr "Le titre de la période est requis"
msgid "Start date must be older than end date"
msgstr "La date de début doit être plus ancienne que la date de fin"
msgid "Period successfully updated."
msgstr "Période mise à jour."
msgid "Period successfully created."
msgstr "Période crée."
msgid "Entries successfully published."
msgstr "Billets publiés."
msgid "Entries successfully unpublished."
msgstr "Billets mis hors ligne."
msgid "Entries successfully removed."
msgstr "Billets retirés."
msgid "New period"
msgstr "Nouvelle période"
msgid "Edit period"
msgstr "Modifier la période"
msgid "Next update:"
msgstr "Prochaine mise à jour :"
msgid "End date:"
msgstr "Date de fin :"
msgid "Publication frequency:"
msgstr "Fréquence de publication :"
msgid "Number of entries to publish every time:"
msgstr "Nombre de billets à publier à chaque fois :"
msgid "Entries linked to this period"
msgstr "Billets liés à cette période"
msgid "Periods removed."
msgstr "Périodes retirées."
msgid "Periods emptied."
msgstr "Périodes vidées."
msgid "empty periods"
msgstr "vider les périodes"
#: index.php:673
msgid "delete periods"
msgstr "effacer les périodes"
#: index.php:770
msgid "Results per page :"
msgstr "Résultats par page :"
#: index.php:794
msgid "Selected periods action:"
msgstr "Action sur les périodes selectionnées :"
msgid "Configuration has been successfully updated."
msgstr "La configuration a été mise à jour avec succés."
msgid "Published periodically entries"
msgstr "Publier périodiquement des billets"