AO3-DL/webui/listWorks.php

142 lines
3.4 KiB
PHP

<?php
# This file is part of AOMO, "Archive Of My Own", a collection of Python and PHP
# scripts designed act as an improved local backup system
# for works published on https://archiveofourown.org
#
# Copyright (c) 2025 Cyberpro123, except where otherwise noted.
#
# This project is available under the GNU General Public License (GPL) v2.0,
# available at https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
# or in the 'LICENSE.md' file that should be distributed alongside this one.
#
# Report issues to https://codeberg.org/Cyberpro123/AOMO
# Contact author at cyberpro123@posteo.com
################################################################
# Setup
################################################################
#include ".aomoCommon.php";
include ".aomoLibList.php";
switch (strtolower(strval(get($_GET, "asc", "t")))) {
case 'desc':
case 'false':
case '0':
case 'd':
case 'f':
$asc = "DESC";
define("SORT_ASC_INT", 0);
break;
case 'asc':
case 'true':
case '1':
case 'a':
case 't':
default:
$asc = "ASC";
define("SORT_ASC_INT", 1);
break;
}
switch (strtolower(strval(get($_GET, "sort", "")))) {
case '8':
case 'alphabet':
case 'alphabetically':
case 'title':
case 'a':
case 't':
define("SORT_INT", 8);
define("SORT_STR", "SELECT id FROM text WHERE chapter = 0 ORDER BY title $asc");
break;
case '7':
case 'chaptersexpected':
case 'ce':
define("SORT_INT", 7);
define("SORT_STR", "SELECT id FROM works ORDER BY chapters_expected $asc");
break;
case '6':
case 'chaptersreleased':
case 'cr':
define("SORT_INT", 6);
define("SORT_STR", "SELECT id FROM works ORDER BY chapters_count $asc");
break;
case '5':
case 'dateprocessed':
case 'dpr':
define("SORT_INT", 5);
define("SORT_STR", "SELECT id FROM works ORDER BY date_processed $asc");
break;
case '4':
case 'datedownloaded':
case 'dd':
define("SORT_INT", 4);
define("SORT_STR", "SELECT id FROM works ORDER BY date_last_downloaded $asc");
break;
case '3':
case 'datepublished':
case 'dp':
case 'dpb':
define("SORT_INT", 3);
define("SORT_STR", "SELECT id FROM works ORDER BY date_published $asc");
break;
case '2':
case 'dateedited':
case 'de':
define("SORT_INT", 2);
define("SORT_STR", "SELECT id FROM works ORDER BY date_last_edited $asc");
break;
case '1':
case 'dateupdated':
case 'du':
define("SORT_INT", 1);
define("SORT_STR", "SELECT id FROM works ORDER BY date_last_updated $asc");
break;
case '0':
case 'workid':
case 'wid':
default:
define("SORT_INT", 0);
define("SORT_STR", "SELECT id FROM works ORDER BY id $asc");
break;
}
unset($asc);
################################################################
# Main
################################################################
$workIDs = sqlFetch(array(SORT_STR))[0];
$itemCount = count($workIDs);
$pagesCount = intdiv($itemCount, 20);
if (fmod($itemCount, 20) != 0) {
$pagesCount += 1;
}
echo getSiteMainLead("Browse All Works - AOMO");
echo getWorksHeader(PAGE, $itemCount);
echo getPageWidget($pagesCount, "listWorks.php");
echo "<ul class='series work index group'>";
$itemNo = 0;
foreach ($workIDs as $rowID) {
$itemNo += 1;
if ($itemNo >= START and $itemNo <= LIMIT) {
echo idToHtmlTags($rowID['id']);
}
}
echo "</ul>";
echo getPageWidget($pagesCount, "listWorks.php");
echo getSiteMainEnd();
?>