Commits

Thomas Bouron committed c495e7e

Applied changes in adminItemsList class

  • Participants
  • Parent commits c508ff2
  • Branches formfilters

Comments (0)

Files changed (7)

File admin/blogs.php

 
 dcPage::check('usage,contentadmin');
 
-# Filters
-$sortby_combo = array(
-__('Last update') => 'blog_upddt',
-__('Blog name') => 'UPPER(blog_name)',
-__('Blog ID') => 'B.blog_id'
-);
+$q = !empty($_GET['q']) ? $_GET['q'] : '';
 
-$order_combo = array(
-__('Descending') => 'desc',
-__('Ascending') => 'asc'
-);
+$blogs_list = new adminBlogList($core);
 
-$q = !empty($_GET['q']) ? $_GET['q'] : '';
-$sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : 'blog_upddt';
-$order = !empty($_GET['order']) ? $_GET['order'] : 'desc';
+$params = new ArrayObject();
 
-$page = !empty($_GET['page']) ? $_GET['page'] : 1;
-$nb_per_page =  30;
-
-if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) {
-	$nb_per_page = $_GET['nb'];
-}
+# - Limit, sortby and order filter
+$params = $blogs_list->applyFilters($params);
 
 $show_filters = false;
 	
 	$show_filters = true;
 }
 
-# - Sortby and order filter
-if ($sortby !== '' && in_array($sortby,$sortby_combo)) {
-	if ($order !== '' && in_array($order,$order_combo)) {
-		$params['order'] = $sortby.' '.$order;
-	}
-	
-	if ($sortby != 'blog_upddt' || $order != 'desc') {
-		$show_filters = true;
-	}
-}
-
-$params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page);
-
 try {
 	$counter = $core->getBlogs($params,1);
 	$rs = $core->getBlogs($params);
-	$nb_blog = $counter->f(0);
+	$blogs_list->setItems($rs,$counter->f(0));
 } catch (Exception $e) {
 	$core->error->add($e->getMessage());
 }
 	
 	echo
 	'<form action="blogs.php" method="get" id="filters-form">'.
-	'<fieldset class="two-cols"><legend>'.__('Filters').'</legend>'.
+	'<fieldset><legend>'.__('Filters').'</legend>'.
 	
-	'<div class="col">'.
-	'<p><label for="sortby">'.__('Order by:').' '.
-	form::combo('sortby',$sortby_combo,html::escapeHTML($sortby)).
-	'</label> '.
-	'<label for="order">'.__('Sort:').' '.
-	form::combo('order',$order_combo,html::escapeHTML($order)).
-	'</label></p>'.
-	'</div>'.
-	
-	'<div class="col">'.
 	'<p><label for="q">'.__('Search:').' '.
 	form::field('q',20,255,html::escapeHTML($q)).
 	'</label></p>'.
-	'<p><label for="nb" class="classic">'.	form::field('nb',3,3,$nb_per_page).' '.
-	__('Blogs per page').'</label> '.
-	'<input type="submit" value="'.__('Apply filters').'" /></p>'.
-	'</div>'.
+	'<p><input type="submit" value="'.__('Apply filters').'" /></p>'.
 	
 	'<br class="clear" />'. //Opera sucks
 	'</fieldset>'.
 	'</form>';
 	
 	# Show blogs
-	$blogs_list = new adminBlogList($core,$rs,$nb_blog);
-	$blogs_list->display($page,$nb_per_page);
+	$blogs_list->display();
 }
 
 dcPage::close();

File admin/comments.php

 __('trackback') => '1'
 );
 
-$sortby_combo = array(
-__('Date') => 'comment_dt',
-__('Entry title') => 'post_title',
-__('Author') => 'comment_author',
-__('Status') => 'comment_status'
-);
+$comment_list = new adminCommentList($core);
 
-$order_combo = array(
-__('Descending') => 'desc',
-__('Ascending') => 'asc'
-);
+$params = new ArrayObject();
+$params['no_content'] = true;
 
-
-
-$page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1;
-$nb_per_page =  30;
-
-if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) {
-	if ($nb_per_page != $_GET['nb']) {
-		$show_filters = true;
-	}
-	$nb_per_page = (integer) $_GET['nb'];
-}
-$params = new ArrayObject();
-$params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page);
-$params['no_content'] = true;
+# - Limit, sortby and order filter
+$params = $comment_list->applyFilters($params);
 
 # Actions combo box
 $combo_action = array();
 		$page_title = __('Comments and Trackacks');
 	}
 
-	$comment_list = new adminCommentList($core,$comments,$counter->f(0));
+	$comment_list->setItems($comments,$counter->f(0));
 } catch (Exception $e) {
 	$core->error->add($e->getMessage());
 }
 if (!$core->error->flag())
 {
 	# Filters
-	if (!$show_filters) {
-		echo '<p><a id="filter-control" class="form-control" href="#">'.
-		__('Filters').'</a></p>';
-	}
 	$filterSet->display();
 	
 	if (!$with_spam) {
 	}
 	
 	# Show comments
-	$comment_list->display($page,$nb_per_page,
-	'<form action="comments_actions.php" method="post" id="form-comments">'.
+	$comment_list->display('<form action="comments_actions.php" method="post" id="form-comments">'.
 	
 	'%s'.
 	
 	$core->formNonce().
 	'<input type="submit" value="'.__('ok').'" /></p>'.
 	form::hidden(array('type'),$type).
-	form::hidden(array('sortby'),$sortby).
-	form::hidden(array('order'),$order).
 	form::hidden(array('author'),preg_replace('/%/','%%',$author)).
 	form::hidden(array('status'),$status).
 	form::hidden(array('ip'),preg_replace('/%/','%%',$ip)).
-	form::hidden(array('page'),$page).
-	form::hidden(array('nb'),$nb_per_page).
+	$comment_list->getFormFieldsAsHidden().
 	'</div>'.
 	
 	'</form>'

File admin/permissions_blog.php

 
 dcPage::checkSuper();
 
-# Filters
-$sortby_combo = array(
-__('Blog ID') => 'B.blog_id',
-__('Blog name') => 'blog_name'
-);
-
-$order_combo = array(
-__('Descending') => 'desc',
-__('Ascending') => 'asc'
-);
-
 $q = !empty($_GET['q']) ? $_GET['q'] : '';
-$sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : 'blog_id';
-$order = !empty($_GET['order']) ? $_GET['order'] : 'asc';
-
 
 # Check users
 if (!empty($_REQUEST['user_id']) && is_array($_REQUEST['user_id']))
 }
 else
 {
-	$page = !empty($_GET['page']) ? $_GET['page'] : 1;
-	$nb_per_page =  30;
+	$blogs_list = new adminBlogPermissionsList($core);
 	
-	if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) {
-		$nb_per_page = $_GET['nb'];
-	}
+	$params = new ArrayObject();
+	
+	# - Limit, sortby and order filter
+	$params = $blogs_list->applyFilters($params);
 	
 	$show_filters = false;
 	
 		$show_filters = true;
 	}
 	
-	# - Sortby and order filter
-	if ($sortby !== '' && in_array($sortby,$sortby_combo)) {
-		if ($order !== '' && in_array($order,$order_combo)) {
-			$params['order'] = $sortby.' '.$order;
-			$show_filters = true;
-		}
-	}
-	
-	$params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page);
-	
 	try {
 		$rs = $core->getBlogs($params);
 		$counter = $core->getBlogs($params,1);
-		$nb_blog = $counter->f(0);
+		$blogs_list->setItems($rs,$counter->f(0));
 	} catch (Exception $e) {
 		$core->error->add($e->getMessage());
 	}
 	'<form action="permissions_blog.php" method="get" id="filters-form">'.
 	'<fieldset class="two-cols"><legend>'.__('Filters').'</legend>'.
 	
-	'<div class="col">'.
-	'<p><label for="sortby">'.__('Order by:').' '.
-	form::combo('sortby',$sortby_combo,html::escapeHTML($sortby)).
-	'</label> '.
-	'<label for="order">'.__('Sort:').' '.
-	form::combo('order',$order_combo,html::escapeHTML($order)).
-	'</label></p>'.
-	'</div>'.
-	
-	'<div class="col">'.
 	'<p><label for="q">'.__('Search:').' '.
 	form::field('q',20,255,html::escapeHTML($q)).
 	'</label></p>'.
-	'<p><label for="nb" class="classic">'.	form::field('nb',3,3,$nb_per_page).' '.
-	__('Entries per page').'</label> '.
-	'<input type="submit" value="'.__('Apply filters').'" />'.
+	'<p><input type="submit" value="'.__('Apply filters').'" />'.
 	$hidden_fields.'</p>'.
-	'</div>'.
 	
 	'<br class="clear" />'. //Opera sucks
 	'</fieldset>'.
 	'<strong>'.implode(', ',$users).'</strong>').'</p>';
 	
 	# Show blogs
-	$blogs_list = new adminBlogPermissionsList($core,$rs,$nb_blog);
-	$blogs_list->display($page,$nb_per_page,'<form action="permissions.php" method="post" id="form-blogs">'.
+	$blogs_list->display('<form action="permissions.php" method="post" id="form-blogs">'.
 		'%s'.
 		'<p class="checkboxes-helpers"></p>'.
 		'<p><input type="submit" value="'.__('set permissions').'" />'.

File admin/popup_posts.php

 
 $q = !empty($_GET['q']) ? $_GET['q'] : null;
 
-$page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1;
-$nb_per_page =  10;
+$post_list = new adminPostMiniList($core);
 
 $params = array();
-$params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page);
 $params['no_content'] = true;
-$params['order'] = 'post_dt DESC';
+
+# - Limit, sortby and order filter
+$params = $post_list->applyFilters($params);
 
 if ($q) {
 	$params['search'] = $q;
 try {
 	$posts = $core->blog->getPosts($params);
 	$counter = $core->blog->getPosts($params,true);
-	$post_list = new adminPostMiniList($core,$posts,$counter->f(0));
+	$post_list->setItems($posts,$counter->f(0));
 } catch (Exception $e) {
 	$core->error->add($e->getMessage());
 }
 
 echo '<div id="form-entries">'; # I know it's not a form but we just need the ID
-$post_list->display($page,$nb_per_page);
+$post_list->display();
 echo '</div>';
 
 echo '<p><a class="button" href="#" id="link-insert-cancel">'.__('cancel').'</a></p>';

File admin/posts.php

 
 /* Get posts
 -------------------------------------------------------- */
-$page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1;
-$nb_per_page =  30;
-
-if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) {
-	if ($nb_per_page != $_GET['nb']) {
-		$show_filters = true;
-	}
-	$nb_per_page = (integer) $_GET['nb'];
-}
+$post_list = new adminPostList($core);
 
 $params = new ArrayObject();
-$params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page);
 $params['no_content'] = true;
 
-# - Sortby and order filter
-$sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : 'post_dt';
-$order = !empty($_GET['order']) ? $_GET['order'] : 'desc';
-if ($sortby !== '') {
-	if ($order !== '') {
-		$params['order'] = $sortby.' '.$order;
-	}
-}
+# - Limit, sortby and order filter
+$params = $post_list->applyFilters($params);
 
 $filterSet = new dcFilterSet('posts','posts.php');
 class monthComboFilter extends comboFilter {
 	} else {
 		$page_title = __('Entries');
 	}
-	$post_list = new adminPostList($core,$posts,$counter->f(0));
+	$post_list->setItems($posts,$counter->f(0));
 } catch (Exception $e) {
 	$core->error->add($e->getMessage());
 }
 	$filterSet->display();
 
 	# Show posts
-	$post_list->display($page,$nb_per_page,
-	'<form action="posts_actions.php" method="post" id="form-entries">'.
+	$post_list->display('<form action="posts_actions.php" method="post" id="form-entries">'.
 	
 	'%s'.
 	
 	form::combo('action',$combo_action).
 	'<input type="submit" value="'.__('ok').'" /></p>'.
 	$filterSet->getFormFieldsAsHidden().
+	$post_list->getFormFieldsAsHidden().
 	$core->formNonce().
 	'</div>'.
 	'</form>'

File admin/style/default.css

 	padding: 3px 5px;
 	vertical-align: top;
 }
-thead th{
+thead th {
 	text-align: left;
 	border-top: 1px solid #666;
 	border-bottom: 1px solid #666;
 	text-decoration: none;
 	border-bottom: 1px dotted #000;
 }
-thead th.asc {
+thead th.asc a {
+	color: #2373A8;
 	padding-left: 15px;
 	background: transparent url(asc.png) no-repeat left center;
 }
-thead th.desc {
+thead th.desc a {
+	color: #2373A8;
 	padding-left: 15px;
 	background: transparent url(desc.png) no-repeat left center;
 }

File admin/users.php

 
 
 #�Get users
-$page = !empty($_GET['page']) ? $_GET['page'] : 1;
-$nb_per_page =  30;
-
-if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) {
-	$nb_per_page = $_GET['nb'];
-}
+$user_list = new adminUserList($core);
 
 $q = !empty($_GET['q']) ? $_GET['q'] : '';
-$sortby = !empty($_GET['sortby']) ?	$_GET['sortby'] : 'user_id';
-$order = !empty($_GET['order']) ?		$_GET['order'] : 'asc';
-
-$params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page);
 
 $show_filters = false;
 
+$params = new ArrayObject();
+
+# - Limit, sortby and order filter
+$params = $user_list->applyFilters($params);
+
 # - Search filter
 if ($q) {
 	$params['q'] = $q;
 	$show_filters = true;
 }
 
-# - Sortby and order filter
-if ($sortby !== '' && in_array($sortby,$sortby_combo)) {
-	if ($order !== '' && in_array($order,$order_combo)) {
-		$params['order'] = $sortby.' '.$order;
-		$show_filters = true;
-	}
-}
-
 try {
 	$rs = $core->getUsers($params);
 	$counter = $core->getUsers($params,1);
-	$user_list = new adminUserList($core,$rs,$counter->f(0));
+	$user_list->setItems($rs,$counter->f(0));
 } catch (Exception $e) {
 	$core->error->add($e->getMessage());
 }
 
-
 /* DISPLAY
 -------------------------------------------------------- */
 $starting_script = dcPage::jsLoad('js/_users.js');
 	
 	echo
 	'<form action="users.php" method="get" id="filters-form">'.
-	'<fieldset class="two-cols"><legend>'.__('Filters').'</legend>'.
+	'<fieldset><legend>'.__('Filters').'</legend>'.
 	
-	'<div class="col">'.
-	'<p><label for="sortby">'.__('Order by:').' '.
-	form::combo('sortby',$sortby_combo,$sortby).
-	'</label> '.
-	'<label for="order">'.__('Sort:').' '.
-	form::combo('order',$order_combo,$order).
-	'</label></p>'.
-	'</div>'.
-	
-	'<div class="col">'.
 	'<p><label for="q">'.__('Search:').' '.
 	form::field('q',20,255,html::escapeHTML($q)).
 	'</label></p>'.
-	'<p><label for="nb" class="classic">'.	form::field('nb',3,3,$nb_per_page).' '.
-	__('Users per page').'</label> '.
-	'<input type="submit" value="'.__('Apply filters').'" /></p>'.
-	'</div>'.
+	'<p><input type="submit" value="'.__('Apply filters').'" /></p>'.
 	
 	'<br class="clear" />'. //Opera sucks
 	'</fieldset>'.
 	'</form>';
 	
 	# Show users
-	$user_list->display($page,$nb_per_page,
-	'<form action="dispatcher.php" method="get" id="form-users">'.
+	$user_list->display('<form action="dispatcher.php" method="get" id="form-users">'.
 	
 	'%s'.
 	
 	'</label> '.
 	'<input type="submit" value="'.__('ok').'" />'.
 	'</p>'.
+	$user_list->getFormFieldsAsHidden().
 	'</div>'.
 	'</form>'
 	);