3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4 * Copyright (C) 2002-2009 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)
14 * Part of the code for the Nucleus admin area
16 * @license http://nucleuscms.org/license.txt GNU General Public License
17 * @copyright Copyright (C) 2002-2009 The Nucleus Group
19 * @version $NucleusJP: ENCAPSULATE.php,v 1.4.2.1 2007/08/08 05:32:54 kimitake Exp $
24 * Uses $call to call a function using parameters $params
25 * This function should return the amount of entries shown.
26 * When entries are show, batch operation handlers are shown too.
27 * When no entries were shown, $errormsg is used to display an error
29 * Passes on the amount of results found (for further encapsulation)
31 function doEncapsulate($call, $params, $errorMessage = _ENCAPSULATE_ENCAPSULATE_NOENTRY) {
32 // start output buffering
35 $nbOfRows = call_user_func_array($call, $params);
37 // get list contents and stop buffering
38 $list = ob_get_contents();
54 * A class used to encapsulate a list of some sort inside next/prev buttons
56 class NAVLIST extends ENCAPSULATE {
58 function NAVLIST($action, $start, $amount, $minamount, $maxamount, $blogid, $search, $itemid) {
59 $this->action = $action;
60 $this->start = $start;
61 $this->amount = $amount;
62 $this->minamount = $minamount;
63 $this->maxamount = $maxamount;
64 $this->blogid = $blogid;
65 $this->search = $search;
66 $this->itemid = $itemid;
69 function showBatchList($batchtype, $query, $type, $template, $errorMessage = _LISTS_NOMORE) {
70 $batch =& new BATCH($batchtype);
73 array(&$batch, 'showlist'),
74 array(&$query, $type, $template),
82 $this->showNavigation();
85 $this->showNavigation();
89 * Displays a next/prev bar for long tables
91 function showNavigation() {
92 $action = $this->action;
93 $start = $this->start;
94 $amount = $this->amount;
95 $minamount = $this->minamount;
96 $maxamount = $this->maxamount;
97 $blogid = $this->blogid;
98 $search = htmlspecialchars($this->search);
99 $itemid = $this->itemid;
101 $prev = $start - $amount;
102 if ($prev < $minamount) $prev=$minamount;
104 // maxamount not used yet
105 // if ($start + $amount <= $maxamount)
106 $next = $start + $amount;
111 <table class="navigation">
113 <form method="post" action="index.php"><div>
114 <input type="submit" value="<< <?php echo _LISTS_PREV?>" />
115 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
116 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
117 <input type="hidden" name="action" value="<?php echo $action; ?>" />
118 <input type="hidden" name="amount" value="<?php echo $amount; ?>" />
119 <input type="hidden" name="search" value="<?php echo $search; ?>" />
120 <input type="hidden" name="start" value="<?php echo $prev; ?>" />
123 <form method="post" action="index.php"><div>
124 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
125 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
126 <input type="hidden" name="action" value="<?php echo $action; ?>" />
127 <input name="amount" size="3" value="<?php echo $amount; ?>" /> <?php echo _LISTS_PERPAGE?>
128 <input type="hidden" name="start" value="<?php echo $start; ?>" />
129 <input type="hidden" name="search" value="<?php echo $search; ?>" />
130 <input type="submit" value="> <?php echo _LISTS_CHANGE?>" />
133 <form method="post" action="index.php"><div>
134 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
135 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
136 <input type="hidden" name="action" value="<?php echo $action; ?>" />
137 <input type="hidden" name="amount" value="<?php echo $amount; ?>" />
138 <input type="hidden" name="start" value="0" />
139 <input type="text" name="search" value="<?php echo $search; ?>" size="7" />
140 <input type="submit" value="> <?php echo _LISTS_SEARCH?>" />
143 <form method="post" action="index.php"><div>
144 <input type="submit" value="<?php echo _LISTS_NEXT?> > >" />
145 <input type="hidden" name="search" value="<?php echo $search; ?>" />
146 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
147 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
148 <input type="hidden" name="action" value="<?php echo $action; ?>" />
149 <input type="hidden" name="amount" value="<?php echo $amount; ?>" />
150 <input type="hidden" name="start" value="<?php echo $next; ?>" />
161 * A class used to encapsulate a list of some sort in a batch selection
163 class BATCH extends ENCAPSULATE {
164 function BATCH($type) {
168 function showHead() {
170 <form method="post" action="index.php">
172 // TODO: get a list op operations above the list too
173 // (be careful not to use the same names for the select...)
174 // $this->showOperationList();
177 function showFoot() {
178 $this->showOperationList();
183 function showOperationList() {
186 <div class="batchoperations">
187 <?php echo _BATCH_WITH_SEL ?>
188 <select name="batchaction">
189 <?php $options = array();
190 switch($this->type) {
193 'delete' => _BATCH_ITEM_DELETE,
194 'move' => _BATCH_ITEM_MOVE
199 'delete' => _BATCH_MEMBER_DELETE,
200 'setadmin' => _BATCH_MEMBER_SET_ADM,
201 'unsetadmin' => _BATCH_MEMBER_UNSET_ADM
206 'delete' => _BATCH_TEAM_DELETE,
207 'setadmin' => _BATCH_TEAM_SET_ADM,
208 'unsetadmin' => _BATCH_TEAM_UNSET_ADM,
213 'delete' => _BATCH_CAT_DELETE,
214 'move' => _BATCH_CAT_MOVE,
219 'delete' => _BATCH_COMMENT_DELETE,
223 foreach ($options as $option => $label) {
224 echo '<option value="',$option,'">',$label,'</option>';
228 <input type="hidden" name="action" value="batch<?php echo $this->type?>" />
230 $manager->addTicketHidden();
232 // add hidden fields for 'team' and 'comment' batchlists
233 if ($this->type == 'team')
235 echo '<input type="hidden" name="blogid" value="',intRequestVar('blogid'),'" />';
237 if ($this->type == 'comment')
239 echo '<input type="hidden" name="itemid" value="',intRequestVar('itemid'),'" />';
242 echo '<input type="submit" value="',_BATCH_EXEC,'" />';
244 <a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(1); "><?php echo _BATCH_SELECTALL?></a> -
245 <a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(0); "><?php echo _BATCH_DESELECTALL?></a>
251 function showList($query, $type, $template, $errorMessage = _LISTS_NOMORE) {
252 return $this->doEncapsulate( 'showlist',
253 array($query, $type, $template),