Skip to content
Permalink
Browse files

管理エリア action=itemlist にカテゴリ絞り込み機能の追加

・カテゴリを指定して検索できるようになります
・カテゴリを選択して、未入力で検索をすると、選択カテゴリのみの一覧を表示できます
  • Loading branch information...
piyoyo
piyoyo committed Mar 24, 2015
1 parent 3f990e6 commit 289d45b5ebd2c31459272e64a3cd64a122dee9a2
Showing with 58 additions and 1 deletion.
  1. +2 −0 nucleus/language/japanese-utf8.php
  2. +7 −0 nucleus/libs/ADMIN.php
  3. +49 −1 nucleus/libs/ENCAPSULATE.php
@@ -17,6 +17,8 @@
// Note for Japanese users
// このファイルは Nucleus の UTF-8 版日本語ランゲージファイルです。
define('_LISTS_FORM_SELECT_ALL_CATEGORY', 'すべてのカテゴリ');
define('_LIST_BACK_TO', '%sに戻る');
define('_LIST_COMMENT_LIST_FOR_BLOG', 'ブログのコメント一覧');
define('_LIST_COMMENT_LIST_FOR_ITEM', 'アイテムのコメント一覧');
@@ -347,6 +347,13 @@ function action_itemlist($blogid = '') {
. ' 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;
if ($request_catid > 0)
{
// @todo NP_MultipleCategories
$query .= ' and icat= '.$request_catid;
}
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) . '%"))';
@@ -103,6 +103,10 @@ function showNavigation() {
<table class="navigation">
<tr>
<?php
$enable_cat_select = (((string) requestVar('action')) == 'itemlist');
if ($enable_cat_select)
$catid = isset($_POST['catid']) ? max(0,intval($_POST['catid'])) : 0;
if($start==0) $disabled ='disabled style="cursor:default;"';
else $disabled = '';
?>
@@ -111,6 +115,7 @@ function showNavigation() {
<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; ?>" />
@@ -121,6 +126,7 @@ function showNavigation() {
<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; ?>" />
@@ -129,6 +135,7 @@ function showNavigation() {
</div></form>
</td><td>
<form method="post" action="index.php"><div>
<?php if ($enable_cat_select) echo $this->getFormSelectCategoryBlog($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; ?>" />
@@ -143,6 +150,7 @@ function showNavigation() {
<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; ?>" />
@@ -151,7 +159,47 @@ function showNavigation() {
</table>
<?php }
protected function getFormSelectCategoryBlog($blogid, $selected_catid = 0 , $input_name = 'catid')
{
global $member;
if ( !$blogid )
return '';
if ( !$member->teamRights($blogid) && !$member->isAdmin() )
return '';
$lists = array();
$selected = false;
$selected_catid = intval($selected_catid);
// @todo NP_MultipleCategories
$sql = 'SELECT catid , cname , count(inumber) as count FROM ' . sql_table('category')
. ' LEFT JOIN `' . sql_table('item') . '` ON catid=icat '
. ' WHERE cblog=' . intval($blogid)
. ' group BY catid '
. ' ORDER BY corder ASC , cname ASC';
$total = 0;
$res = sql_query($sql);
if ($res)
while( $row = sql_fetch_assoc( $res ) )
{
$lists[] = sprintf('<option value="%d" %s>' , intval($row['catid'])
, ( intval($row['catid']) == $selected_catid ? 'selected' : '') )
. hsc( $row['cname'])
. sprintf('(%d)' , $row['count']) . '</option>';
$total += $row['count'];
if ( !$selected && intval($row['catid']) == $selected_catid)
$selected = true;
}
$s = sprintf('<select name="%s">' , htmlentities( $input_name, ENT_COMPAT , _CHARSET ) );
$s .= "\n\t\t".'<option value="0"'
. ( $selected ? '' : 'selected' )
.' >' . hsc(_LISTS_FORM_SELECT_ALL_CATEGORY)
. sprintf('(%d)' , $total) . "</option>\n";
$s .= "\t\t".implode( "\n\t\t" , $lists )."\n";
$s .= "\t\t</select>\n";
return $s;
}
}
@@ -208,7 +256,7 @@ function showOperationList() {
break;
case 'category':
$options = array(
'change_corder' => _BATCH_CAT_CAHANGE_ORDER ,
'change_corder' => _BATCH_CAT_CAHANGE_ORDER ,
'delete' => _BATCH_CAT_DELETE,
'move' => _BATCH_CAT_MOVE,
);

0 comments on commit 289d45b

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