3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4 * Copyright (C) 2002-2012 The Nucleus Group
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 * (see nucleus/documentation/index.html#license for more info)
12 * Part of the code for the Nucleus admin area
17 * Uses $call to call a function using parameters $params
18 * This function should return the amount of entries shown.
19 * When entries are show, batch operation handlers are shown too.
20 * When no entries were shown, $errormsg is used to display an error
22 * Passes on the amount of results found (for further encapsulation)
24 function doEncapsulate($call, $params, $errorMessage = _ENCAPSULATE_ENCAPSULATE_NOENTRY) {
25 // start output buffering
28 $nbOfRows = call_user_func_array($call, $params);
30 // get list contents and stop buffering
31 $list = ob_get_contents();
47 * A class used to encapsulate a list of some sort inside next/prev buttons
49 class NAVLIST extends ENCAPSULATE {
51 function NAVLIST($action, $start, $amount, $minamount, $maxamount, $blogid, $search, $itemid) {
52 $this->action = $action;
53 $this->start = $start;
54 $this->amount = $amount;
55 $this->minamount = $minamount;
56 $this->maxamount = $maxamount;
57 $this->blogid = $blogid;
58 $this->search = $search;
59 $this->itemid = $itemid;
62 function showBatchList($batchtype, $query, $type, $template, $errorMessage = _LISTS_NOMORE) {
63 $batch = new BATCH($batchtype);
66 array(&$batch, 'showlist'),
67 array(&$query, $type, $template),
75 $this->showNavigation();
78 $this->showNavigation();
82 * Displays a next/prev bar for long tables
84 function showNavigation() {
85 $action = $this->action;
86 $start = $this->start;
87 $amount = $this->amount;
88 $minamount = $this->minamount;
89 $maxamount = $this->maxamount;
90 $blogid = $this->blogid;
91 $search = htmlspecialchars($this->search);
92 $itemid = $this->itemid;
94 $prev = $start - $amount;
95 if ($prev < $minamount) $prev=$minamount;
97 // maxamount not used yet
98 // if ($start + $amount <= $maxamount)
99 $next = $start + $amount;
104 <table class="navigation">
106 <form method="post" action="index.php"><div>
107 <input type="submit" value="<< <?php echo _LISTS_PREV?>" />
108 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
109 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
110 <input type="hidden" name="action" value="<?php echo $action; ?>" />
111 <input type="hidden" name="amount" value="<?php echo $amount; ?>" />
112 <input type="hidden" name="search" value="<?php echo $search; ?>" />
113 <input type="hidden" name="start" value="<?php echo $prev; ?>" />
116 <form method="post" action="index.php"><div>
117 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
118 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
119 <input type="hidden" name="action" value="<?php echo $action; ?>" />
120 <input name="amount" size="3" value="<?php echo $amount; ?>" /> <?php echo _LISTS_PERPAGE?>
121 <input type="hidden" name="start" value="<?php echo $start; ?>" />
122 <input type="hidden" name="search" value="<?php echo $search; ?>" />
123 <input type="submit" value="> <?php echo _LISTS_CHANGE?>" />
126 <form method="post" action="index.php"><div>
127 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
128 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
129 <input type="hidden" name="action" value="<?php echo $action; ?>" />
130 <input type="hidden" name="amount" value="<?php echo $amount; ?>" />
131 <input type="hidden" name="start" value="0" />
132 <input type="text" name="search" value="<?php echo $search; ?>" size="7" />
133 <input type="submit" value="> <?php echo _LISTS_SEARCH?>" />
136 <form method="post" action="index.php"><div>
137 <input type="submit" value="<?php echo _LISTS_NEXT?> > >" />
138 <input type="hidden" name="search" value="<?php echo $search; ?>" />
139 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
140 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
141 <input type="hidden" name="action" value="<?php echo $action; ?>" />
142 <input type="hidden" name="amount" value="<?php echo $amount; ?>" />
143 <input type="hidden" name="start" value="<?php echo $next; ?>" />
154 * A class used to encapsulate a list of some sort in a batch selection
156 class BATCH extends ENCAPSULATE {
157 function BATCH($type) {
161 function showHead() {
163 <form method="post" action="index.php">
165 // TODO: get a list op operations above the list too
166 // (be careful not to use the same names for the select...)
167 // $this->showOperationList();
170 function showFoot() {
171 $this->showOperationList();
176 function showOperationList() {
179 <div class="batchoperations">
180 <?php echo _BATCH_WITH_SEL ?>
181 <select name="batchaction">
182 <?php $options = array();
183 switch($this->type) {
186 'delete' => _BATCH_ITEM_DELETE,
187 'move' => _BATCH_ITEM_MOVE
192 'delete' => _BATCH_MEMBER_DELETE,
193 'setadmin' => _BATCH_MEMBER_SET_ADM,
194 'unsetadmin' => _BATCH_MEMBER_UNSET_ADM
199 'delete' => _BATCH_TEAM_DELETE,
200 'setadmin' => _BATCH_TEAM_SET_ADM,
201 'unsetadmin' => _BATCH_TEAM_UNSET_ADM,
206 'delete' => _BATCH_CAT_DELETE,
207 'move' => _BATCH_CAT_MOVE,
212 'delete' => _BATCH_COMMENT_DELETE,
216 foreach ($options as $option => $label) {
217 echo '<option value="',$option,'">',$label,'</option>';
221 <input type="hidden" name="action" value="batch<?php echo $this->type?>" />
223 $manager->addTicketHidden();
225 // add hidden fields for 'team' and 'comment' batchlists
226 if ($this->type == 'team')
228 echo '<input type="hidden" name="blogid" value="',intRequestVar('blogid'),'" />';
230 if ($this->type == 'comment')
232 echo '<input type="hidden" name="itemid" value="',intRequestVar('itemid'),'" />';
235 echo '<input type="submit" value="',_BATCH_EXEC,'" />';
237 <a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(1); "><?php echo _BATCH_SELECTALL?></a> -
238 <a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(0); "><?php echo _BATCH_DESELECTALL?></a>
244 function showList($query, $type, $template, $errorMessage = _LISTS_NOMORE) {
245 return $this->doEncapsulate( 'showlist',
246 array($query, $type, $template),