Alexander Nicolaysen Sørnes : Use objectManager to show 'Comments Management' page
Alexander Nicolaysen Sørnes
asornes at winehq.org
Tue Oct 27 19:11:41 CDT 2009
Module: appdb
Branch: master
Commit: 0b8e7c97fe4b0a4f97734c98fab6aa464d972809
URL: http://source.winehq.org/git/appdb.git/?a=commit;h=0b8e7c97fe4b0a4f97734c98fab6aa464d972809
Author: Alexander Nicolaysen Sørnes <alexander at linux-xqqm.(none)>
Date: Tue Oct 27 23:25:26 2009 +0100
Use objectManager to show 'Comments Management' page
---
admin/adminCommentView.php | 73 -------------------------------------------
include/comment.php | 74 ++++++++++++++++++++++++++++++++++++++++++++
include/sidebar_admin.php | 2 +-
3 files changed, 75 insertions(+), 74 deletions(-)
diff --git a/admin/adminCommentView.php b/admin/adminCommentView.php
deleted file mode 100644
index 13f5929..0000000
--- a/admin/adminCommentView.php
+++ /dev/null
@@ -1,73 +0,0 @@
-<?php
-/************************************************************/
-/* Page for managing all of the comments in the apidb */
-/* Without having go into each application version to do so */
-/************************************************************/
-
-require("path.php");
-require(BASE."include/incl.php");
-
-apidb_header("Comments");
-
-/* display a range of 10 pages */
-$pageRange = 10;
-
-$ItemsPerPage = isset($aClean['iItemsPerPage']) ? $aClean['iItemsPerPage'] : 10;
-$currentPage = isset($aClean['iPage']) ? $aClean['iPage'] : 1;
-
-$totalPages = ceil(getNumberOfComments()/$ItemsPerPage);
-
-if($ItemsPerPage > 100) $ItemsPerPage = 100;
-
-
-/* display page selection links */
-echo "<center>";
-echo "<b>Page $currentPage of $totalPages</b><br>";
-display_page_range($currentPage, $pageRange, $totalPages, $_SERVER['PHP_SELF']."?iItemsPerPage=".$ItemsPerPage);
-echo "<br>";
-echo "<br>";
-
-/* display the option to choose how many comments per-page to display */
-echo "<form method=\"get\" name=\"sMessage\" action=\"".$_SERVER['PHP_SELF']."\">";
-echo "<b>Number of comments per page:</b>";
-echo " <select name='iItemsPerPage'>";
-
-$ItemsPerPageArray = array(10, 20, 50, 100, 500);
-foreach($ItemsPerPageArray as $i => $value)
-{
- if($ItemsPerPageArray[$i] == $ItemsPerPage)
- echo "<option value='$ItemsPerPageArray[$i]' SELECTED>$ItemsPerPageArray[$i]";
- else
- echo "<option value='$ItemsPerPageArray[$i]'>$ItemsPerPageArray[$i]";
-}
-echo "</select>";
-
-echo "<input type=hidden name=iPage value=$currentPage>";
-echo " <input type=submit value='Refresh'>";
-echo "</form>";
-
-echo "</center>";
-
-/* query for all of the commentId's, ordering by their time in reverse order */
-$offset = (($currentPage-1) * $ItemsPerPage);
-$commentIds = query_parameters("SELECT commentId from appComments ORDER BY ".
- "appComments.time ASC LIMIT ?, ?", $offset, $ItemsPerPage);
-while ($oRow = query_fetch_object($commentIds))
-{
- $sQuery = "SELECT from_unixtime(unix_timestamp(time), \"%W %M %D %Y, %k:%i\") as time, ".
- "commentId, parentId, versionId, userid, subject, body ".
- "FROM appComments WHERE commentId = '?'";
- $hResult = query_parameters($sQuery, $oRow->commentId);
- /* call view_app_comment to display the comment */
- $oComment_row = query_fetch_object($hResult);
- Comment::view_app_comment($oComment_row, true);
-}
-
-/* display page selection links */
-
-echo "<center>";
-display_page_range($currentPage, $pageRange, $totalPages, $_SERVER['PHP_SELF']."?iItemsPerPage=".$ItemsPerPage);
-echo "</center>";
-
-apidb_footer();
-?>
diff --git a/include/comment.php b/include/comment.php
index a999e41..a890ec3 100644
--- a/include/comment.php
+++ b/include/comment.php
@@ -296,6 +296,80 @@ class Comment {
echo html_frame_end();
}
+ public function objectWantCustomDraw($sWhat, $sQueued)
+ {
+ switch($sWhat)
+ {
+ case 'table':
+ return true;
+ }
+
+ return false;
+ }
+
+ public static function objectGetEntries($sState, $iNumRows = 0, $iStart = 0, $sOrderBy = 'commentId')
+ {
+ $sLimit = '';
+
+ if($iNumRows)
+ {
+ $iStart = mysql_real_escape_string($iStart);
+ $iNumRows = mysql_real_escape_string($iNumRows);
+ $sLimit = " LIMIT $iStart,$iNumRows";
+ }
+
+ if($sOrderBy)
+ $sOrderBy = " ORDER BY ".mysql_real_escape_string($sOrderBy);
+
+ $hResult = query_parameters("SELECT * FROM appComments$sOrderBy$sLimit");
+
+ return $hResult;
+ }
+
+ public function objectGetDefaultSort()
+ {
+ return 'commentId';
+ }
+
+ public static function objectGetEntriesCount($sState)
+ {
+ $hResult = query_parameters("SELECT COUNT(commentId) as count FROM appComments");
+
+ if(!$hResult)
+ return null;
+
+ $oRow = mysql_fetch_object($hResult);
+
+ return $oRow->count;
+ }
+
+ public function objectGetItemsPerPage()
+ {
+ $aItemsPerPage = array(10, 20, 50, 100, 500);
+ $iDefaultPerPage = 10;
+
+ return array($aItemsPerPage, $iDefaultPerPage);
+ }
+
+ public function objectDrawCustomTable($hResult, $sQueued)
+ {
+ while($oRow = mysql_fetch_object($hResult))
+ comment::view_app_comment($oRow, true);
+ }
+
+ public function objectGetHeader()
+ {
+ return new TableRow();
+ }
+
+ public function objectGetTableRow()
+ {
+ $oTableRow = new TableRow();
+ $oOMRow = new OMTableRow($oTableRow);
+
+ return $oOMRow;
+ }
+
function display()
{
$this->output_comment();
diff --git a/include/sidebar_admin.php b/include/sidebar_admin.php
index c06864e..746470d 100644
--- a/include/sidebar_admin.php
+++ b/include/sidebar_admin.php
@@ -39,7 +39,7 @@ function global_admin_menu() {
BASE."objectManager.php?sClass=testData&sTitle=".
"View%20Test%20Results");
$g->add("Users Management", BASE."admin/adminUsers.php");
- $g->add("Comments Management", BASE."admin/adminCommentView.php");
+ $g->add('Comments Management', BASE.'objectManager.php?sClass=comment');
$g->add("Screenshots Management", BASE."admin/adminScreenshots.php");
$g->addmisc(" ");
More information about the wine-cvs
mailing list