Browse Source

liste les modules en json

10504
fredtempez 4 months ago
parent
commit
7dc0b4caf8
  1. 24
      module/download/download.php
  2. 1
      module/download/view/list/list.php

24
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
]);
}
}

1
module/download/view/list/list.php

@ -0,0 +1 @@
<!-- rien -->
Loading…
Cancel
Save