3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4 * Copyright (C) 2002-2006 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-2006 The Nucleus Group
18 * @version $Id: ENCAPSULATE.php,v 1.1 2006-07-12 07:13:31 kimitake Exp $
23 * Uses $call to call a function using parameters $params
24 * This function should return the amount of entries shown.
25 * When entries are show, batch operation handlers are shown too.
26 * When no entries were shown, $errormsg is used to display an error
28 * Passes on the amount of results found (for further encapsulation)
30 function doEncapsulate($call, $params, $errorMessage = 'No entries') {
31 // start output buffering
34 $nbOfRows = call_user_func_array($call, $params);
36 // get list contents and stop buffering
37 $list = ob_get_contents();
53 * A class used to encapsulate a list of some sort inside next/prev buttons
55 class NAVLIST extends ENCAPSULATE {
57 function NAVLIST($action, $start, $amount, $minamount, $maxamount, $blogid, $search, $itemid) {
58 $this->action = $action;
59 $this->start = $start;
60 $this->amount = $amount;
61 $this->minamount = $minamount;
62 $this->maxamount = $maxamount;
63 $this->blogid = $blogid;
64 $this->search = $search;
65 $this->itemid = $itemid;
68 function showBatchList($batchtype, $query, $type, $template, $errorMessage = _LISTS_NOMORE) {
69 $batch =& new BATCH($batchtype);
72 array(&$batch, 'showlist'),
73 array(&$query, $type, $template),
81 $this->showNavigation();
84 $this->showNavigation();
88 * Displays a next/prev bar for long tables
90 function showNavigation() {
91 $action = $this->action;
92 $start = $this->start;
93 $amount = $this->amount;
94 $minamount = $this->minamount;
95 $maxamount = $this->maxamount;
96 $blogid = $this->blogid;
97 $search = $this->search;
98 $itemid = $this->itemid;
100 $prev = $start - $amount;
101 if ($prev < $minamount) $prev=$minamount;
103 // maxamount not used yet
104 // if ($start + $amount <= $maxamount)
105 $next = $start + $amount;
110 <table class="navigation">
112 <form method="post" action="index.php"><div>
113 <input type="submit" value="<< <?php echo _LISTS_PREV?>" />
114 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
115 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
116 <input type="hidden" name="action" value="<?php echo $action; ?>" />
117 <input type="hidden" name="amount" value="<?php echo $amount; ?>" />
118 <input type="hidden" name="search" value="<?php echo $search; ?>" />
119 <input type="hidden" name="start" value="<?php echo $prev; ?>" />
122 <form method="post" action="index.php"><div>
123 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
124 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
125 <input type="hidden" name="action" value="<?php echo $action; ?>" />
126 <input name="amount" size="3" value="<?php echo $amount; ?>" /> <?php echo _LISTS_PERPAGE?>
127 <input type="hidden" name="start" value="<?php echo $start; ?>" />
128 <input type="hidden" name="search" value="<?php echo $search; ?>" />
129 <input type="submit" value="> <?php echo _LISTS_CHANGE?>" />
132 <form method="post" action="index.php"><div>
133 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
134 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
135 <input type="hidden" name="action" value="<?php echo $action; ?>" />
136 <input type="hidden" name="amount" value="<?php echo $amount; ?>" />
137 <input type="hidden" name="start" value="0" />
138 <input type="text" name="search" value="<?php echo $search; ?>" size="7" />
139 <input type="submit" value="> <?php echo _LISTS_SEARCH?>" />
142 <form method="post" action="index.php"><div>
143 <input type="submit" value="<?php echo _LISTS_NEXT?> > >" />
144 <input type="hidden" name="search" value="<?php echo $search; ?>" />
145 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
146 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
147 <input type="hidden" name="action" value="<?php echo $action; ?>" />
148 <input type="hidden" name="amount" value="<?php echo $amount; ?>" />
149 <input type="hidden" name="start" value="<?php echo $next; ?>" />
160 * A class used to encapsulate a list of some sort in a batch selection
162 class BATCH extends ENCAPSULATE {
163 function BATCH($type) {
167 function showHead() {
169 <form method="post" action="index.php">
171 // TODO: get a list op operations above the list too
172 // (be careful not to use the same names for the select...)
173 // $this->showOperationList();
176 function showFoot() {
177 $this->showOperationList();
182 function showOperationList() {
185 <div class="batchoperations">
186 <?php echo _BATCH_WITH_SEL ?>
187 <select name="batchaction">
188 <?php $options = array();
189 switch($this->type) {
192 'delete' => _BATCH_ITEM_DELETE,
193 'move' => _BATCH_ITEM_MOVE
198 'delete' => _BATCH_MEMBER_DELETE,
199 'setadmin' => _BATCH_MEMBER_SET_ADM,
200 'unsetadmin' => _BATCH_MEMBER_UNSET_ADM
205 'delete' => _BATCH_TEAM_DELETE,
206 'setadmin' => _BATCH_TEAM_SET_ADM,
207 'unsetadmin' => _BATCH_TEAM_UNSET_ADM,
212 'delete' => _BATCH_CAT_DELETE,
213 'move' => _BATCH_CAT_MOVE,
218 'delete' => _BATCH_COMMENT_DELETE,
222 foreach ($options as $option => $label) {
223 echo '<option value="',$option,'">',$label,'</option>';
227 <input type="hidden" name="action" value="batch<?php echo $this->type?>" />
229 $manager->addTicketHidden();
231 // add hidden fields for 'team' and 'comment' batchlists
232 if ($this->type == 'team')
234 echo '<input type="hidden" name="blogid" value="',intRequestVar('blogid'),'" />';
236 if ($this->type == 'comment')
238 echo '<input type="hidden" name="itemid" value="',intRequestVar('itemid'),'" />';
241 echo '<input type="submit" value="',_BATCH_EXEC,'" />';
243 <a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(1); "><?php echo _BATCH_SELECTALL?></a> -
244 <a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(0); "><?php echo _BATCH_DESELECTALL?></a>
250 function showList($query, $type, $template, $errorMessage = _LISTS_NOMORE) {
251 return $this->doEncapsulate( 'showlist',
252 array($query, $type, $template),