get("Date Last Modified");
if ($Modified == "0000-00-00 00:00:00") {
$Modified = "—";
} else {
$MUser = $Item->get("Last Modified By Id", true);
$MUser = array_shift($MUser);
$Modified = StdLib::getPrettyTimestamp($Modified)
." - ".(($MUser instanceof User)
? $MUser->name() : "(unknown)")."";
$Modified = str_replace(" ", " ", $Modified);
}
return $Modified;
}
# ----- SETUP ----------------------------------------------------------------
# verify that required incoming variables are set
if (!isset($H_Pages)) {
throw new Exception("Variable \$H_Pages not set.");
}
# set up links
$BaseLink = "index.php?P=P_Pages_ListPages";
$AddPageLink = "index.php?P=P_Pages_EditPage&ID=NEW";
$PageDisplayLink = "index.php?P=P_Pages_DisplayPage&ID=\$ID";
$PageEditLink = "index.php?P=P_Pages_EditPage&ID=\$ID";
$PageDeleteLink = "index.php?P=P_Pages_DeletePage&ID=\$ID";
# get singleton objects
$AnonUser = User::getAnonymousUser();
$AF = ApplicationFramework::getInstance();
$AF->setPageTitle("Page List");
# set up fields to display
$Fields = [
"Pages: Viewable" => [
"Heading" => "",
"ValueFunction" => function ($Item) use ($AnonUser, $AF) {
$EyeSlashLink = $AF->gUIFile("EyeSlash.svg");
return $Item->userCanView($AnonUser) ? "" :
"
";
}
],
"Pages: Title" => [
"Heading" => "Title",
"Link" => $PageDisplayLink,
"MaxLength" => 40
],
"Pages: Clean URL" => [
"Heading" => "URL",
"Link" => $PageDisplayLink
],
"Pages: Date Last Modified" => [
"Heading" => "Modified",
"ValueFunction" => "Metavus\\getLastModifiedText",
"DefaultSortField" => true,
"DefaultToDescendingSort" => true
],
];
# set up list UI
$ListUI = new ItemListUI($Fields, $H_Pages);
$ListUI->setHeading("Page List");
$ListUI->setItemsPerPage(25);
$ListUI->setBaseLink($BaseLink);
$ListUI->setItemTypeName("Page");
$ListUI->sort();
$ListUI->addTopButton("Add New Page", $AddPageLink, "Plus.svg");
$ListUI->addActionButton("Edit", $PageEditLink, "Pencil.svg");
$ListUI->addActionButton("Delete", $PageDeleteLink, "Delete.svg");
# ----- DISPLAY --------------------------------------------------------------
print $ListUI->getHtml();