Skip to content
Permalink
Browse files

管理画面の操作性改善 クラスNAVLISTにページ移動ボタンを追加しました

  • Loading branch information...
piyoyo
piyoyo committed Mar 30, 2015
1 parent c26f010 commit 634e8ce5415de21ed17a415e8755493b8ad35df6
Showing with 183 additions and 71 deletions.
  1. +39 −15 nucleus/libs/ADMIN.php
  2. +144 −56 nucleus/libs/ENCAPSULATE.php
@@ -343,8 +343,8 @@ function action_itemlist($blogid = '') {
$search = postVar('search'); // search through items
$query = 'SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime, bnumber, catid'
. ' FROM ' . sql_table('item') . ', ' . sql_table('blog') . ', ' . sql_table('member') . ', ' . sql_table('category')
$query_view = 'SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime, bnumber, catid';
$query = ' FROM ' . sql_table('item') . ', ' . sql_table('blog') . ', ' . sql_table('member') . ', ' . sql_table('category')
. ' WHERE iblog=bnumber and iauthor=mnumber and icat=catid and iblog=' . $blogid;
$request_catid = isset($_POST['catid']) ? max(0,intval($_POST['catid'])) : 0;
@@ -361,17 +361,20 @@ function action_itemlist($blogid = '') {
if (!$member->blogAdminRights($blogid))
$query .= ' and iauthor=' . $member->getID();
$total = intval(quickQuery( 'SELECT COUNT(*) as result ' . $query ));
$query .= ' ORDER BY itime DESC'
. " LIMIT $start,$amount";
$query_view .= $query;
$template['content'] = 'itemlist';
$template['now'] = $blog->getCorrectTime(time());
$manager->loadClass("ENCAPSULATE");
$navList = new NAVLIST('itemlist', $start, $amount, 0, 1000, $blogid, $search, 0);
$navList->showBatchList('item',$query,'table',$template);
$navList->total = $total;
$navList->showBatchList('item',$query_view,'table',$template);
$this->pagefoot();
}
@@ -1012,8 +1015,8 @@ function action_browseownitems() {
$search = postVar('search'); // search through items
$query = 'SELECT bshortname, cname, mname, ititle, ibody, idraft, inumber, itime'
. ' FROM '.sql_table('item').', '.sql_table('blog') . ', '.sql_table('member') . ', '.sql_table('category')
$query_view = 'SELECT bshortname, cname, mname, ititle, ibody, idraft, inumber, itime';
$query = ' FROM '.sql_table('item').', '.sql_table('blog') . ', '.sql_table('member') . ', '.sql_table('category')
. ' WHERE iauthor='. $member->getID() .' and iauthor=mnumber and iblog=bnumber and icat=catid';
$request_catid = isset($_POST['catid']) ? max(0,intval($_POST['catid'])) : 0;
@@ -1025,15 +1028,20 @@ function action_browseownitems() {
if ($search)
$query .= ' and ((ititle LIKE "%' . sql_real_escape_string($search) . '%") or (ibody LIKE "%' . sql_real_escape_string($search) . '%") or (imore LIKE "%' . sql_real_escape_string($search) . '%"))';
$total = intval(quickQuery( 'SELECT COUNT(*) as result ' . $query ));
$query .= ' ORDER BY itime DESC'
. " LIMIT $start,$amount";
$query_view .= $query;
$template['content'] = 'itemlist';
$template['now'] = time();
$manager->loadClass("ENCAPSULATE");
$navList = new NAVLIST('browseownitems', $start, $amount, 0, 1000, /*$blogid*/ 0, $search, 0);
$navList->showBatchList('item',$query,'table',$template);
$navList->total = $total;
$navList->showBatchList('item',$query_view,'table',$template);
$this->pagefoot();
@@ -1094,20 +1102,26 @@ function action_itemcommentlist($itemid = '') {
echo '<h2>',_COMMENTS,'</h2>';
$query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem FROM ' . sql_table('comment') . ' LEFT OUTER JOIN ' . sql_table('member') . ' ON mnumber = cmember WHERE citem = ' . $itemid;
$query_view = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem';
$query = ' FROM ' . sql_table('comment') . ' LEFT OUTER JOIN ' . sql_table('member') . ' ON mnumber = cmember WHERE citem = ' . $itemid;
if ($search)
$query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
$total = intval(quickQuery( 'SELECT COUNT(*) as result ' . $query ));
$query .= ' ORDER BY ctime ASC'
. " LIMIT $start,$amount";
$query_view .= $query;
$template['content'] = 'commentlist';
$template['canAddBan'] = $member->blogAdminRights(getBlogIDFromItemID($itemid));
$manager->loadClass("ENCAPSULATE");
$navList = new NAVLIST('itemcommentlist', $start, $amount, 0, 1000, 0, $search, $itemid);
$navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS);
$navList->total = $total;
$navList->showBatchList('comment',$query_view,'table',$template,_NOCOMMENTS);
$this->pagefoot();
}
@@ -1136,14 +1150,19 @@ function action_browseowncomments() {
$search = postVar('search');
$query = 'SELECT cbody, cuser, cmail, mname, ctime, chost, cnumber, cip, citem FROM '.sql_table('comment').' LEFT OUTER JOIN '.sql_table('member').' ON mnumber=cmember WHERE cmember=' . $member->getID();
$query_view = 'SELECT cbody, cuser, cmail, mname, ctime, chost, cnumber, cip, citem';
$query = ' FROM '.sql_table('comment').' LEFT OUTER JOIN '.sql_table('member').' ON mnumber=cmember WHERE cmember=' . $member->getID();
if ($search)
$query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
$total = intval(quickQuery( 'SELECT COUNT(*) as result ' . $query ));
$query .= ' ORDER BY ctime DESC'
. " LIMIT $start,$amount";
$query_view .= $query;
$this->pagehead();
echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
@@ -1154,7 +1173,8 @@ function action_browseowncomments() {
$manager->loadClass("ENCAPSULATE");
$navList = new NAVLIST('browseowncomments', $start, $amount, 0, 1000, 0, $search, 0);
$navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS_YOUR);
$navList->total = $total;
$navList->showBatchList('comment',$query_view,'table',$template,_NOCOMMENTS_YOUR);
$this->pagefoot();
}
@@ -1194,12 +1214,13 @@ function action_blogcommentlist($blogid = '')
if ($member->isAdmin() || $member->isBlogAdmin($blogid))
{
$query = 'SELECT cbody, cuser, cemail, cmail, mname, ctime, chost, cnumber, cip, citem FROM '.sql_table('comment').' LEFT OUTER JOIN '.sql_table('member').' ON mnumber=cmember WHERE cblog=' . intval($blogid);
$query_view = 'SELECT cbody, cuser, cemail, cmail, mname, ctime, chost, cnumber, cip, citem';
$query = ' FROM '.sql_table('comment').' LEFT OUTER JOIN '.sql_table('member').' ON mnumber=cmember WHERE cblog=' . intval($blogid);
}
else
{
$query = 'SELECT cbody, cuser, cemail, cmail, mname, ctime, chost, cnumber, cip, citem, cmember, iauthor, 0 as is_badmin' .
' FROM '.sql_table('comment').
$query_view = 'SELECT cbody, cuser, cemail, cmail, mname, ctime, chost, cnumber, cip, citem, cmember, iauthor, 0 as is_badmin';
$query = ' FROM '.sql_table('comment').
' LEFT OUTER JOIN '.sql_table('member').
' ON mnumber=cmember'.
' LEFT OUTER JOIN '.sql_table('item').
@@ -1210,10 +1231,12 @@ function action_blogcommentlist($blogid = '')
if ($search != '')
$query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
$total = intval(quickQuery( 'SELECT COUNT(*) as result ' . $query ));
$query .= ' ORDER BY ctime DESC'
. " LIMIT $start,$amount";
$query_view .= $query;
$blog =& $manager->getBlog($blogid);
@@ -1227,7 +1250,8 @@ function action_blogcommentlist($blogid = '')
$manager->loadClass("ENCAPSULATE");
$navList = new NAVLIST('blogcommentlist', $start, $amount, 0, 1000, $blogid, $search, 0);
$navList->showBatchList('comment',$query,'table',$template, _NOCOMMENTS_BLOG);
$navList->total = $total;
$navList->showBatchList('comment',$query_view,'table',$template, _NOCOMMENTS_BLOG);
$this->pagefoot();
}
@@ -47,6 +47,8 @@ function doEncapsulate($call, $params, $errorMessage = _ENCAPSULATE_ENCAPSULATE_
*/
class NAVLIST extends ENCAPSULATE {
public $total = null;
function NAVLIST($action, $start, $amount, $minamount, $maxamount, $blogid, $search, $itemid) {
$this->action = $action;
$this->start = $start;
@@ -99,64 +101,150 @@ function showNavigation() {
// else
// $next = $start;
?>
<table class="navigation">
<tr>
<?php
$enable_cat_select = in_array($action , array('itemlist' , 'browseownitems'));
if ($enable_cat_select)
$catid = isset($_POST['catid']) ? max(0,intval($_POST['catid'])) : 0;
$enable_cat_select = in_array($action , array('itemlist' , 'browseownitems'));
if ($enable_cat_select)
$catid = isset($_POST['catid']) ? max(0,intval($_POST['catid'])) : 0;
$minamount = $this->minamount;
$maxamount = $this->maxamount;
$page_navigation = "";
// calc page
if ($amount <= 0)
{
$total_pages = 1;
$current_page = 1;
$amount = 1;
}
else
{
// page = (page-1)/$amount + 1 , page item start 1..
$current_page = (int) (floor(max(0, $start) / $amount) + 1); // start 0..
if ( is_null( $this->total ) )
$total_pages = 1;
else
{
$total_pages = (int) floor(max(0, $this->total-1) / $amount) + 1;
$current_page = min($current_page , $total_pages);
}
}
$current_page = max(1 , $current_page); // page 1..
$maxamount = min($maxamount , $total_pages * $amount-1);
if (!is_null( $this->total ))
$maxamount = max(0 , $this->total - 1);
$prev = max(0 , ($current_page-2)) * $amount; // 0..
if ($prev < $minamount) $prev=$minamount;
$next = max(0 , min( $current_page , $total_pages ) * $amount);
if ( !is_null( $this->total ) && (intval($next)+1 > intval($this->total)) )
{
$next = floor(max(0,intval($this->total-1)) / $amount) * $amount ; // 9/10=0,10/10=1
}
$page_last_start = min(max(0,($total_pages-1)*$amount),$maxamount);
$page_navigation = sprintf('page %d / %d (%d - %d / %d)'
, $current_page,$total_pages
, $start + 1
, (is_null($this->total) ? $start + $amount : min($start + $amount , $this->total))
, $this->total);
$input_catid = ($enable_cat_select ? "\n\t\t".sprintf('<input type="hidden" name="catid" value="%d" />', $catid) : '');
$btn_title_change = _LISTS_CHANGE;
$page_navigation .=<<<EOD
<div>
<form method="post" action="index.php">
<input type="number" id="page_select" value="{$current_page}" style="width:50px;" min=1 max={$total_pages} onchange="var e = document.getElementById('page_select_start'); e.value=Math.min(Math.max(0, (this.value-1) * {$amount}),{$page_last_start});" />
<input type="hidden" name="search" value="{$search}" />
<input type="hidden" name="blogid" value="{$blogid}" />{$input_catid}
<input type="hidden" name="itemid" value="{$itemid}" />
<input type="hidden" name="action" value="{$action}" />
<input type="hidden" name="amount" value="{$amount}" />
<input type="hidden" id="page_select_start" name="start" value="{$start}" />
<input type="submit" value="{$btn_title_change}" />
</form></div>
EOD;
if ( is_null( $this->total ) )
{
global $CONF;
if ($CONF['debug'])
$page_navigation .= 'page navigation is disabled: set total before call ';
else
{
$page_navigation = '';
}
$next = $start + $amount;
$disabled_next = '';
}
else
{
$disabled_next = ($current_page<$total_pages) ? '' : 'disabled style="cursor:default;" ';
}
if($start==0)
$disabled ='disabled style="cursor:default;" ';
else
$disabled = '';
if($start==0) $disabled ='disabled style="cursor:default;"';
else $disabled = '';
?>
<td>
<form method="post" action="index.php"><div>
<input type="submit" value="&lt;&lt; <?php echo _LISTS_PREV; ?>" <?php echo $disabled; ?>/>
<input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
<input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
<?php if ($enable_cat_select) echo '<input type="hidden" name="catid" value="' . $catid . '" />'; ?>
<input type="hidden" name="action" value="<?php echo $action; ?>" />
<input type="hidden" name="amount" value="<?php echo $amount; ?>" />
<input type="hidden" name="search" value="<?php echo $search; ?>" />
<input type="hidden" name="start" value="<?php echo $prev; ?>" />
</div></form>
</td>
<td>
<form method="post" action="index.php"><div>
<input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
<input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
<?php if ($enable_cat_select) echo '<input type="hidden" name="catid" value="' . $catid . '" />'; ?>
<input type="hidden" name="action" value="<?php echo $action; ?>" />
<input name="amount" size="3" value="<?php echo $amount; ?>" /> <?php echo _LISTS_PERPAGE?>
<input type="hidden" name="start" value="<?php echo $start; ?>" />
<input type="hidden" name="search" value="<?php echo $search; ?>" />
<input type="submit" value="<?php echo _LISTS_CHANGE?>" />
</div></form>
</td><td>
<form method="post" action="index.php"><div>
<?php if ($enable_cat_select) echo $this->getFormSelectCategoryBlog($action, $blogid , $catid) . '<br />'; ?>
<input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
<input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
<input type="hidden" name="action" value="<?php echo $action; ?>" />
<input type="hidden" name="amount" value="<?php echo $amount; ?>" />
<input type="hidden" name="start" value="0" />
<input type="text" name="search" value="<?php echo $search; ?>" size="7" />
<input type="submit" value="<?php echo _LISTS_SEARCH?>" />
</div></form>
</td><td>
<form method="post" action="index.php"><div>
<input type="submit" value="<?php echo _LISTS_NEXT?> &gt; &gt;" />
<input type="hidden" name="search" value="<?php echo $search; ?>" />
<input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
<input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
<?php if ($enable_cat_select) echo '<input type="hidden" name="catid" value="' . $catid . '" />'; ?>
<input type="hidden" name="action" value="<?php echo $action; ?>" />
<input type="hidden" name="amount" value="<?php echo $amount; ?>" />
<input type="hidden" name="start" value="<?php echo $next; ?>" />
</div></form>
</td></tr>
</table>
<table class="navigation">
<tr>
<td style="vertical-align: top; text-align: left;"><?php echo $page_navigation; ?>
<table border="0" style="width: 250px">
<tr>
<td><form method="post" action="index.php"><div>
<input type="submit" value="&lt;&lt; <?php echo _LISTS_PREV; ?>" <?php echo $disabled; ?>/>
<input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
<input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
<?php if ($enable_cat_select) echo '<input type="hidden" name="catid" value="' . $catid . '" />'; ?>
<input type="hidden" name="action" value="<?php echo $action; ?>" />
<input type="hidden" name="amount" value="<?php echo $amount; ?>" />
<input type="hidden" name="search" value="<?php echo $search; ?>" />
<input type="hidden" name="start" value="<?php echo $prev; ?>" />
</div></form>
</td>
<td><form method="post" action="index.php"><div>
<input type="submit" value="<?php echo _LISTS_NEXT; ?> &gt; &gt;" <?php echo $disabled_next; ?>/>
<input type="hidden" name="search" value="<?php echo $search; ?>" />
<input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
<input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
<?php if ($enable_cat_select) echo '<input type="hidden" name="catid" value="' . $catid . '" />'; ?>
<input type="hidden" name="action" value="<?php echo $action; ?>" />
<input type="hidden" name="amount" value="<?php echo $amount; ?>" />
<input type="hidden" name="start" value="<?php echo $next; ?>" />
</div></form>
</td>
</tr>
</table>
</td>
<td style="white-space: nowrap;">
<form method="post" action="index.php"><div>
<input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
<input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
<?php if ($enable_cat_select) echo '<input type="hidden" name="catid" value="' . $catid . '" />'; ?>
<input type="hidden" name="action" value="<?php echo $action; ?>" />
<input name="amount" size="3" value="<?php echo $amount; ?>" /> <?php echo _LISTS_PERPAGE; ?>
<input type="hidden" name="start" value="<?php echo $start; ?>" />
<input type="hidden" name="search" value="<?php echo $search; ?>" />
<input type="submit" value="<?php echo _LISTS_CHANGE; ?>" />
</div></form>
</td>
<td style="white-space: nowrap;">
<form method="post" action="index.php"><div>
<?php if ($enable_cat_select) echo $this->getFormSelectCategoryBlog($action, $blogid , $catid) . '<br />'; ?>
<input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
<input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
<input type="hidden" name="action" value="<?php echo $action; ?>" />
<input type="hidden" name="amount" value="<?php echo $amount; ?>" />
<input type="hidden" name="start" value="0" />
<input type="text" name="search" value="<?php echo $search; ?>" size="7" />
<input type="submit" value="<?php echo _LISTS_SEARCH; ?>" />
</div></form>
</td>
</tr>
</table>
<?php }
protected function getFormSelectCategoryBlog($action, $blogid, $selected_catid = 0 , $input_name = 'catid')

0 comments on commit 634e8ce

Please sign in to comment.
You can’t perform that action at this time.