Skip to content

Commit

Permalink
new sorting order: expiration date ascending
Browse files Browse the repository at this point in the history
addresses my main point in WBCE#98,
but other sorting orders might be useful, too
  • Loading branch information
mrbaseman committed Sep 26, 2024
1 parent 372414c commit 01b6d5f
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 13 deletions.
24 changes: 14 additions & 10 deletions functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1748,6 +1748,10 @@ function mod_nwi_get_order(int $section_id)
$order_by = "post_id";
$direction = 'DESC';
break;
case 5:
$order_by = "published_until";
$direction = 'ASC';
break;
}
return array($order_by,$direction);
} // end function mod_nwi_get_order()
Expand Down Expand Up @@ -2185,15 +2189,15 @@ function mod_nwi_display_news_items(
'sort_by' => $sort_by,
'sort_order' => $sort_order,
'not_older_than' => $not_older_than,
'is_not_older_than' => $is_not_older_than,
'is_not_older_than' => $is_not_older_than,
'lang_id' => $lang_id,
'lang_filter' => $lang_filter,
'skip' => $skip,
'tags' => $tags,
'taglist' => $tagList,
'groups_on_tags' => $groups_on_tags,
'view' => $view,
'aslist' => $aslist,
'skip' => $skip,
'tags' => $tags,
'taglist' => $tagList,
'groups_on_tags' => $groups_on_tags,
'view' => $view,
'aslist' => $aslist,
)
);
echo $output;
Expand All @@ -2212,7 +2216,7 @@ function mod_nwi_get_news_items($options=array())
'max_news_length' => -1, // maximum length of the short news text shown (default:=-1 => full news length)
'strip_tags' => true, // true:=remove tags from short and long text (default:=true); false:=dont strip tags
'allowed_tags' => '<p><a><img>', // tags not striped off (default:='<p><a><img>')
'sort_by' => 1, // 1:=position (default), 2:=posted_when, 3:=published_when, 4:=random order
'sort_by' => 1, // 1:=position (default), 2:=posted_when, 3:=published_when, 4:=random order 5:=rand() 6:=published_until
'sort_order' => 1, // 1:=descending (default), 2:=ascending
'not_older_than' => 0, // 0:=disabled (default), 0-999 (only show news `published_when` date <=x days; 12 hours:=0.5)
'is_not_older_than' => 0,
Expand Down Expand Up @@ -2246,7 +2250,7 @@ function mod_nwi_get_news_items($options=array())
mod_nwi_sanitize_input($max_news_length, 'i{-1;0;250}');
mod_nwi_sanitize_input($strip_tags, 'b');
mod_nwi_sanitize_input($allowed_tags, 's{TRIM}');
mod_nwi_sanitize_input($sort_by, 'i{1;1;5}');
mod_nwi_sanitize_input($sort_by, 'i{1;1;6}');
mod_nwi_sanitize_input($sort_order, 'i{1;1;2}');
mod_nwi_sanitize_input($not_older_than, 'd{0;0;999}');
mod_nwi_sanitize_input($is_not_older_than, 'd{0;0;999}');
Expand Down Expand Up @@ -2358,7 +2362,7 @@ function mod_nwi_get_news_items($options=array())
}

// ---------- sort order ---------------------------------------------------
$order_by_options = array('t1.`position`', 't1.`posted_when`', 't1.`published_when`', 'RAND()');
$order_by_options = array('t1.`position`', 't1.`posted_when`', 't1.`published_when`', 'RAND()', 't1.`published_until`');
$sql_order_by = $order_by_options[$sort_by - 1];
$sql_sort_order = ($sort_order == 1) ? 'DESC' : 'ASC';

Expand Down
10 changes: 8 additions & 2 deletions info.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@
$module_directory = 'news_img';
$module_name = 'News with Images';
$module_function = 'page';
$module_version = '5.0.27';
$module_version = '5.0.28';
$module_platform = '1.4';
$module_author = 'Ryan Djurovich, Rob Smith, Silvia Reins, Martin Hecht, Florian Meerwinck, Bianka Martinovic';
$module_license = 'GNU General Public License';
$module_description = 'This page type is designed for making a news page with Images and Lightboxeffect.';

/**
* v5.0.27 - 2024/05/26
* v5.0.28 - 2024/09/26
* - mrbaseman
* * add sorting order: expiration date ascending
* ! bug fix for v5.0.27 concerning access files
* ! complete the language files
*
* v5.0.27 - 2024/09/25
* - mrbaseman
* * add mass actions to clear publication and expiration date
*
Expand Down
1 change: 1 addition & 0 deletions languages/DE.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
$MOD_NEWS_IMG['DESCENDING'] = 'absteigend';
$MOD_NEWS_IMG['EXPERT_MODE'] = 'Expertenmodus';
$MOD_NEWS_IMG['EXPIRED_NOTE'] = 'Der Beitrag wird im Frontend nicht mehr angezeigt, da das Ablaufdatum überschritten ist.';
$MOD_NEWS_IMG['FIRST_EXPIRING_FIRST'] = 'zuerst ablaufende zuerst';
$MOD_NEWS_IMG['FIRST_EXPIRING_LAST'] = 'zuerst ablaufende zuletzt';
$MOD_NEWS_IMG['GALLERY_SETTINGS'] ='Galerie-/Bild-Einstellungen';
$MOD_NEWS_IMG['GALLERYIMAGES'] = 'Galeriebilder';
Expand Down
1 change: 1 addition & 0 deletions languages/EN.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
$MOD_NEWS_IMG['DESCENDING'] = 'descending';
$MOD_NEWS_IMG['EXPERT_MODE'] = 'expert mode';
$MOD_NEWS_IMG['EXPIRED_NOTE'] = 'The posting is no longer displayed in the frontend because the expiration date has passed.';
$MOD_NEWS_IMG['FIRST_EXPIRING_FIRST'] = 'first expiring first';
$MOD_NEWS_IMG['FIRST_EXPIRING_LAST'] = 'first expiring last';
$MOD_NEWS_IMG['GALLERY_SETTINGS'] ='Gallery / image settings';
$MOD_NEWS_IMG['GALLERYIMAGES'] = 'Gallery images';
Expand Down
1 change: 1 addition & 0 deletions languages/FR.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
$MOD_NEWS_IMG['DESCENDING'] = 'absenté';
$MOD_NEWS_IMG['EXPERT_MODE'] = 'mode expert';
$MOD_NEWS_IMG['EXPIRED_NOTE'] = "La publication n'est plus affich&eacute;e dans le front-end car la date d'expiration est d&eacute;pass&eacute;e.";
$MOD_NEWS_IMG['FIRST_EXPIRING_FIRST'] = 'premier expirant en premier';
$MOD_NEWS_IMG['FIRST_EXPIRING_LAST'] = 'premier expirant en dernier';
$MOD_NEWS_IMG['GALLERY_SETTINGS'] = "Param&egrave;tres de la galerie / de l'image";
$MOD_NEWS_IMG['GALLERYIMAGES'] = 'Images de la galerie';
Expand Down
1 change: 1 addition & 0 deletions languages/IT.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
$MOD_NEWS_IMG['DESCENDING'] = 'asteso';
$MOD_NEWS_IMG['EXPERT_MODE'] = 'modalità esperto';
$MOD_NEWS_IMG['EXPIRED_NOTE'] = 'Il post non viene pi&ugrave; visualizzato nel frontend perch&eacute; &egrave; scaduta la data di scadenza.';
$MOD_NEWS_IMG['FIRST_EXPIRING_FIRST'] = 'il primo scade per primo';
$MOD_NEWS_IMG['FIRST_EXPIRING_LAST'] = 'il primo scade per ultimo';
$MOD_NEWS_IMG['GALLERY_SETTINGS'] = 'Galleria / impostazioni immagine';
$MOD_NEWS_IMG['GALLERYIMAGES'] = 'Immagini della galleria';
Expand Down
1 change: 1 addition & 0 deletions languages/NL.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
$MOD_NEWS_IMG['DESCENDING'] = 'afwijzen';
$MOD_NEWS_IMG['EXPERT_MODE'] = 'expertmodus';
$MOD_NEWS_IMG['EXPIRED_NOTE'] = 'Het bericht wordt niet langer weergegeven in de frontend omdat de vervaldatum is verstreken.';
$MOD_NEWS_IMG['FIRST_EXPIRING_FIRST'] = 'eerste verloopt als eerste';
$MOD_NEWS_IMG['FIRST_EXPIRING_LAST'] = 'eerste verloopt als laatste';
$MOD_NEWS_IMG['GALLERY_SETTINGS'] = 'Galerij / beeldinstellingen';
$MOD_NEWS_IMG['GALLERYIMAGES'] = 'Galerijafbeeldingen';
Expand Down
1 change: 1 addition & 0 deletions languages/PT.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
$MOD_NEWS_IMG['DESCENDING'] = 'descendente';
$MOD_NEWS_IMG['EXPERT_MODE'] = 'modo especialista';
$MOD_NEWS_IMG['EXPIRED_NOTE'] = 'O lançamento não é mais exibido no frontend porque a data de validade expirou.';
$MOD_NEWS_IMG['FIRST_EXPIRING_LAST'] = 'primeiro a expirar por primeiro';
$MOD_NEWS_IMG['FIRST_EXPIRING_LAST'] = 'primeiro a expirar por último';
$MOD_NEWS_IMG['GALLERY_SETTINGS'] = 'Configurações de galeria / imagem';
$MOD_NEWS_IMG['GALLERYIMAGES'] = 'Imagens da galeria';
Expand Down
3 changes: 2 additions & 1 deletion modify.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
1 => $TEXT['PUBL_START_DATE'].', '.$MOD_NEWS_IMG['DESCENDING'],
2 => $TEXT['PUBL_END_DATE'].', '.$MOD_NEWS_IMG['DESCENDING'],
3 => $TEXT['SUBMITTED'].', '.$MOD_NEWS_IMG['DESCENDING'],
4 => $TEXT['SUBMISSION_ID'].', '.$MOD_NEWS_IMG['DESCENDING']
4 => $TEXT['SUBMISSION_ID'].', '.$MOD_NEWS_IMG['DESCENDING'],
5 => $TEXT['PUBL_END_DATE']
);

$FTAN = $admin->getFTAN();
Expand Down
1 change: 1 addition & 0 deletions templates/default/modify_settings.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
echo '<option value="2"'.(($settings['view_order'] == 2)?' selected="selected"':'').'>'.$TEXT['PUBL_END_DATE'].' ('.$MOD_NEWS_IMG['DESCENDING'].' = '.$MOD_NEWS_IMG['FIRST_EXPIRING_LAST'].')</option>';
echo '<option value="3"'.(($settings['view_order'] == 3)?' selected="selected"':'').'>'.$TEXT['SUBMITTED'].' ('.$MOD_NEWS_IMG['DESCENDING'].' = '.$MOD_NEWS_IMG['NEWEST_FIRST'].')</option>';
echo '<option value="4"'.(($settings['view_order'] == 4)?' selected="selected"':'').'>'.$TEXT['SUBMISSION_ID'].' ('.$MOD_NEWS_IMG['DESCENDING'].' = '.$MOD_NEWS_IMG['NEWEST_FIRST'].')</option>';
echo '<option value="5"'.(($settings['view_order'] == 5)?' selected="selected"':'').'>'.$TEXT['PUBL_END_DATE'].' ('.$MOD_NEWS_IMG['FIRST_EXPIRING_FIRST'].')</option>';
?>
</select>
</td>
Expand Down

0 comments on commit 01b6d5f

Please sign in to comment.