GetBlogId() == $BlogPlugin->getConfigSetting("EmailNotificationBlog") && $BlogPlugin->notificationsCouldBeSent($Entry, User::getCurrentUser()); } /** * Get the entry's field value. * * This method is used to return the value of a field with the passed in $FieldId * for the passed in entry. * * @param mixed $Entry An entry. * @param mixed $FieldId The id of the field whose value is to be returned. * @return mixed field value if exists. Otherwise, returns an empty string. */ function GetFieldValueForDisplay($Entry, $FieldId) { global $H_Schema; $Methods = [ Blog::TITLE_FIELD_NAME => "TitleForDisplay", Blog::AUTHOR_FIELD_NAME => "AuthorForDisplay", Blog::EDITOR_FIELD_NAME => "EditorForDisplay", Blog::CREATION_DATE_FIELD_NAME => "CreationDateForDisplay", Blog::MODIFICATION_DATE_FIELD_NAME => "ModificationDateForDisplay", Blog::PUBLICATION_DATE_FIELD_NAME => "PublicationDateForDisplay" ]; $FieldName = $H_Schema->GetField($FieldId)->Name(); return isset($Methods[$FieldName]) ? $Entry->{$Methods[$FieldName]}() : ""; } # ----- SETUP ---------------------------------------------------------------- $AF = ApplicationFramework::getInstance(); # verify that required incoming variables are set if (!isset($H_Schema)) { throw new Exception("Variable \$H_Schema not set."); } if (!isset($H_BlogSelectVarName)) { throw new Exception("Variable \$H_BlogSelectVarName not set."); } if (!isset($H_Checksum)) { throw new Exception("Variable \$H_Checksum not set."); } if (!isset($H_CurrentBlogId)) { throw new Exception("Variable \$H_CurrentBlogId not set."); } if (!isset($H_SortField)) { throw new Exception("Variable \$H_SortField not set."); } if (!isset($H_ReverseSort)) { throw new Exception("Variable \$H_ReverseSort not set."); } if (!isset($H_PageSize)) { throw new Exception("Variable \$H_PageSize not set."); } if (!isset($H_BlogEntries)) { throw new Exception("Variable \$H_BlogEntries not set."); } if (!isset($H_EntryCount)) { throw new Exception("Variable \$H_EntryCount not set."); } if (!isset($H_PageOffset)) { throw new Exception("Variable \$H_PageOffset not set."); } $SafeSchemaId = defaulthtmlentities($H_Schema->Id()); $PageTitle = "Blog Entries"; $AF->setPageTitle($PageTitle); # item list ui fields definitions $BlogFieldDefinitions = [ Blog::TITLE_FIELD_NAME => [ "Heading" => "Title", "MaxLength" => 32, "Link" => "index.php?P=P_Blog_Entry&ID=\$ID", "ValueFunction" => "Metavus\\GetFieldValueForDisplay" ], Blog::AUTHOR_FIELD_NAME => [ "Heading" => "Author", "ValueFunction" => "Metavus\\GetFieldValueForDisplay" ], Blog::EDITOR_FIELD_NAME => [ "Heading" => "Editor", "ValueFunction" => "Metavus\\GetFieldValueForDisplay" ], Blog::CREATION_DATE_FIELD_NAME => [ "Heading" => "Created", "ValueFunction" => "Metavus\\GetFieldValueForDisplay" ], Blog::MODIFICATION_DATE_FIELD_NAME => [ "Heading" => "Modified", "DefaultSortField" => true, "ValueFunction" => "Metavus\\GetFieldValueForDisplay", ], Blog::PUBLICATION_DATE_FIELD_NAME => [ "Heading" => "Publication Date", "ValueFunction" => "Metavus\\GetFieldValueForDisplay" ], "Public" => [ "Heading" => "Pub", "ValueFunction" => function ($Entry) { return $Entry->userCanView(User::getAnonymousUser()) ? "Yes" : "No"; }, "Sortable" => false ] ]; # blog list item button links $BaseLink = "index.php?P=P_Blog_ListEntries&CK=".$H_Checksum."&".$H_BlogSelectVarName ."=".$H_CurrentBlogId; $ViewLink = "index.php?P=P_Blog_Entry&ID=\$ID"; $EditLink = $H_Schema->getEditPage(); $NotifyLink = "index.php?P=P_Blog_ConfirmNotifySubscribers&ID=\$ID"; $DeleteLink = "index.php?P=EditResource&ID=\$ID&Submit=Delete"; # Top level button and option list links $AddNewEntryLink = str_replace('$ID', "NEW&SC=".$SafeSchemaId, $H_Schema->getEditPage()); $ManageSubscribersLink = "index.php?P=P_Blog_ManageSubscribers"; $BlogOptionListLink = "index.php?P=P_Blog_ListEntries"; # initiate and add action buttons to the blog entry list $ListUI = new ItemListUI($BlogFieldDefinitions); $ListUI->setBaseLink($BaseLink); $ListUI->addActionButton( "View", $ViewLink, 'EyeOpen.svg', null, ["title" => "View this blog entry"] ); $ListUI->addActionButton( "Edit", $EditLink, "Pencil.svg", null, ["title" => "Edit this blog entry"] ); $ListUI->addActionButton( "Notify", $NotifyLink, "NotifyEmail.svg", "Metavus\\ShouldDisplayEmailNotify", ["title" => "Send e-mail notifications to subscribers about this blog entry"] ); $ListUI->addActionButton( "Delete", $DeleteLink, "Delete.svg", null, ["title" => "Permanently delete this blog entry"] ); $TransportUI = new TransportControlsUI(); $TransportUI->sortField($H_SortField); $TransportUI->reverseSortFlag($H_ReverseSort); $ListUI->setTransportControls($TransportUI); # add a "pick-blog" option list $BlogPlugin = Blog::getInstance(); $ListUI->addTopOptionList( $BlogPlugin->getAvailableBlogs(), $H_BlogSelectVarName, $BlogOptionListLink, $H_CurrentBlogId ); # add a button linking to Manage Subscribers page if ($H_CurrentBlogId == $BlogPlugin->getConfigSetting("EmailNotificationBlog")) { $ListUI->addTopButton("Manage Subscribers", $ManageSubscribersLink, 'cog.png'); } # add an add-entry button for user with the privilege if ($H_Schema->UserCanAuthor(User::getCurrentUser())) { $ListUI->addTopButton("New Entry", $AddNewEntryLink, 'Plus.svg'); } # set other setting $ListUI->setHeading($PageTitle); $ListUI->setNoItemsMessage("There are no blog entries."); $ListUI->setItemsPerPage($H_PageSize); # ----- DISPLAY -------------------------------------------------------------- $ListUI->display($H_BlogEntries, $H_EntryCount, $H_PageOffset);