function files()
{
# order alphabetically by link
- $dir = iterator_to_array(new RecursiveIteratorIterator($this->iterator));
- array_walk($dir, function (&$row, $name) {
- # prepare values for sorting (directory index first)
- $row = preg_replace('{/index\.html$}', '', $name);
- });
- asort($dir);
+ $dir = [];
+ foreach (new RecursiveIteratorIterator($this->iterator) as $name) {
+ $article = new ArchiveArticle($name);
+ $dir[$article->link] = $article;
+ }
+ ksort($dir);
return $dir;
}
}
$Page->image = "/$img";
}
if (!$Page->path) {
- return glob("$rootdir/*", GLOB_ONLYDIR); #TODO: recurse
+ return array_map(function ($dir) {
+ return new ArchiveArticle($dir . '/index.html');
+ }, glob("$rootdir/*", GLOB_ONLYDIR)); #TODO: recurse
}
return;
}
if (!$User) {
if ($Page->path) return;
- return array_keys((new PageSearch($Page->link))->files());
+ return (new PageSearch($Page->link))->files();
}
if ($User->admin("edit {$Page->handler}")) {
<?php
+if (empty($article)) {
$article = new ArchiveArticle($Page->place[0]);
+}
$article->index; # apply handler metadata
printf('<a href="%s">%s</a>', $article->link, $article->name);
if ($article->image) {
# list article details
$search = new PageSearch($Page->place[0] ?? '.');
print '<ul class="replies">'."\n";
-foreach ($search->files() as $ref => $sorted) {
- $Page->place[0] = $ref;
+foreach ($search->files() as $ref => $article) {
print '<li>';
include 'linkref.php';
print "</li>\n";