From 7dc0b4caf8aacf870d8942d72e278e6fd9add41b Mon Sep 17 00:00:00 2001 From: fredtempez Date: Fri, 5 Mar 2021 18:33:03 +0100 Subject: [PATCH] liste les modules en json --- module/download/download.php | 24 +++++++++++++++++++++++- module/download/view/list/list.php | 1 + 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 module/download/view/list/list.php diff --git a/module/download/download.php b/module/download/download.php index 4c006721..ac21653e 100644 --- a/module/download/download.php +++ b/module/download/download.php @@ -37,7 +37,8 @@ class download extends common { 'statsDeleteAll' => self::GROUP_MODERATOR, 'index' => self::GROUP_VISITOR, 'rss' => self::GROUP_VISITOR, - 'downloadFile' => self::GROUP_VISITOR + 'downloadFile' => self::GROUP_VISITOR, + 'list' =>self::GROUP_VISITOR ]; public static $items = []; @@ -904,4 +905,25 @@ class download extends common { ]); } } + + /*** + * Retourne une chaîne json contenant la liste des téléchargements disponibles + */ + public function list() { + $itemIdsPublishedOns = helper::arrayCollumn($this->getData(['module', $this->getUrl(0),'items']), 'publishedOn', 'SORT_DESC'); + $itemIdsStates = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'items']), 'state', 'SORT_DESC'); + $itemIds = []; + foreach($itemIdsPublishedOns as $itemId => $itemPublishedOn) { + if($itemPublishedOn <= time() AND $itemIdsStates[$itemId]) { + $itemIds[] = $itemId; + } + } + foreach ($itemIds as $key) { + self::$items[$key] = $this->getData(['module', $this->getUrl(0), 'items', $key]); + } + $this->addOutput([ + 'display' => self::DISPLAY_JSON, + 'content' => self::$items + ]); + } } \ No newline at end of file diff --git a/module/download/view/list/list.php b/module/download/view/list/list.php new file mode 100644 index 00000000..4b8f6d3c --- /dev/null +++ b/module/download/view/list/list.php @@ -0,0 +1 @@ + \ No newline at end of file