3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
\r
4 * Copyright (C) 2002-2012 The Nucleus Group
\r
6 * This program is free software; you can redistribute it and/or
\r
7 * modify it under the terms of the GNU General Public License
\r
8 * as published by the Free Software Foundation; either version 2
\r
9 * of the License, or (at your option) any later version.
\r
10 * (see nucleus/documentation/index.html#license for more info)
\r
14 * Part of the code for the Nucleus admin area
\r
16 * @license http://nucleuscms.org/license.txt GNU General Public License
\r
17 * @copyright Copyright (C) 2002-2012 The Nucleus Group
\r
18 * @version $Id: ENCAPSULATE.php 1624 2012-01-09 11:36:20Z sakamocchi $
\r
24 * Uses $call to call a function using parameters $params
\r
25 * This function should return the amount of entries shown.
\r
26 * When entries are show, batch operation handlers are shown too.
\r
27 * When no entries were shown, $errormsg is used to display an error
\r
29 * Passes on the amount of results found (for further encapsulation)
\r
31 function doEncapsulate($call, $params, $errorMessage = _Encapsulate_Encapsulate_NOENTRY)
\r
33 if ( isset($params[3]) && !empty($params[3]) )
\r
35 $templateName = $params[3];
\r
41 $params[4] = $errorMessage;
\r
42 // start output buffering
\r
45 $nbOfRows = call_user_func_array($call, $params);
\r
47 // get list contents and stop buffering
\r
48 $list = ob_get_contents();
\r
51 if ( $nbOfRows > 0 )
\r
53 $this->showHead($templateName);
\r
55 $this->showFoot($templateName);
\r
67 * A class used to encapsulate a list of some sort inside next/prev buttons
\r
69 class NavList extends Encapsulate
\r
71 function __construct($action, $start, $amount, $minamount, $maxamount, $blogid, $search, $itemid)
\r
73 $this->action = $action;
\r
74 $this->start = $start;
\r
75 $this->amount = $amount;
\r
76 $this->minamount = $minamount;
\r
77 $this->maxamount = $maxamount;
\r
78 $this->blogid = $blogid;
\r
79 $this->search = $search;
\r
80 $this->itemid = $itemid;
\r
83 function showBatchList($batchtype, $query, $type, $template, $errorMessage = _LISTS_NOMORE, $templateName = '')
\r
85 $batch = new Batch($batchtype);
\r
87 $this->doEncapsulate(
\r
88 array(&$batch, 'showlist'),
\r
89 array(&$query, $type, $template, $templateName),
\r
98 $this->showNavigation();
\r
100 function showFoot()
\r
102 $this->showNavigation();
\r
106 * Displays a next/prev bar for long tables
\r
108 function showNavigation()
\r
110 $action = $this->action;
\r
111 $start = $this->start;
\r
112 $amount = $this->amount;
\r
113 $minamount = $this->minamount;
\r
114 $maxamount = $this->maxamount;
\r
115 $blogid = $this->blogid;
\r
116 $search = Entity::hsc($this->search);
\r
117 $itemid = $this->itemid;
\r
119 $prev = $start - $amount;
\r
120 if ( $prev < $minamount )
\r
125 // maxamount not used yet
\r
126 // if ($start + $amount <= $maxamount)
\r
127 $next = $start + $amount;
\r
132 <table class="navigation">
\r
134 <form method="post" action="index.php"><div>
\r
135 <input type="submit" value="<< <?php echo _LISTS_PREV?>" />
\r
136 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
\r
137 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
\r
138 <input type="hidden" name="action" value="<?php echo $action; ?>" />
\r
139 <input type="hidden" name="amount" value="<?php echo $amount; ?>" />
\r
140 <input type="hidden" name="search" value="<?php echo $search; ?>" />
\r
141 <input type="hidden" name="start" value="<?php echo $prev; ?>" />
\r
144 <form method="post" action="index.php"><div>
\r
145 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
\r
146 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
\r
147 <input type="hidden" name="action" value="<?php echo $action; ?>" />
\r
148 <input name="amount" size="3" value="<?php echo $amount; ?>" /> <?php echo _LISTS_PERPAGE?>
\r
149 <input type="hidden" name="start" value="<?php echo $start; ?>" />
\r
150 <input type="hidden" name="search" value="<?php echo $search; ?>" />
\r
151 <input type="submit" value="> <?php echo _LISTS_CHANGE?>" />
\r
154 <form method="post" action="index.php"><div>
\r
155 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
\r
156 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
\r
157 <input type="hidden" name="action" value="<?php echo $action; ?>" />
\r
158 <input type="hidden" name="amount" value="<?php echo $amount; ?>" />
\r
159 <input type="hidden" name="start" value="0" />
\r
160 <input type="text" name="search" value="<?php echo $search; ?>" size="7" />
\r
161 <input type="submit" value="> <?php echo _LISTS_SEARCH?>" />
\r
164 <form method="post" action="index.php"><div>
\r
165 <input type="submit" value="<?php echo _LISTS_NEXT?> > >" />
\r
166 <input type="hidden" name="search" value="<?php echo $search; ?>" />
\r
167 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
\r
168 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
\r
169 <input type="hidden" name="action" value="<?php echo $action; ?>" />
\r
170 <input type="hidden" name="amount" value="<?php echo $amount; ?>" />
\r
171 <input type="hidden" name="start" value="<?php echo $next; ?>" />
\r
182 * A class used to encapsulate a list of some sort in a batch selection
\r
184 class Batch extends Encapsulate
\r
186 function __construct($type)
\r
188 $this->type = $type;
\r
191 function showHead($templateName = '')
\r
194 <form method="post" action="index.php">
\r
196 // TODO: get a list op operations above the list too
\r
197 // (be careful not to use the same names for the select...)
\r
198 // $this->showOperationList();
\r
201 function showFoot($templateName = '')
\r
203 $this->showOperationList();
\r
209 function showOperationList()
\r
213 <div class="batchoperations">
\r
214 <?php echo _BATCH_WITH_SEL ?>
\r
215 <select name="batchaction">
\r
216 <?php $options = array();
\r
217 switch($this->type) {
\r
220 'delete' => _BATCH_ITEM_DELETE,
\r
221 'move' => _BATCH_ITEM_MOVE
\r
226 'delete' => _BATCH_MEMBER_DELETE,
\r
227 'setadmin' => _BATCH_MEMBER_SET_ADM,
\r
228 'unsetadmin' => _BATCH_MEMBER_UNSET_ADM
\r
233 'delete' => _BATCH_TEAM_DELETE,
\r
234 'setadmin' => _BATCH_TEAM_SET_ADM,
\r
235 'unsetadmin' => _BATCH_TEAM_UNSET_ADM,
\r
240 'delete' => _BATCH_CAT_DELETE,
\r
241 'move' => _BATCH_CAT_MOVE,
\r
246 'delete' => _BATCH_COMMENT_DELETE,
\r
250 foreach ($options as $option => $label) {
\r
251 echo '<option value="',$option,'">',$label,'</option>';
\r
255 <input type="hidden" name="action" value="batch<?php echo $this->type?>" />
\r
257 $manager->addTicketHidden();
\r
259 // add hidden fields for 'team' and 'comment' batchlists
\r
260 if ($this->type == 'team')
\r
262 echo '<input type="hidden" name="blogid" value="',intRequestVar('blogid'),'" />';
\r
264 if ($this->type == 'comment')
\r
266 echo '<input type="hidden" name="itemid" value="',intRequestVar('itemid'),'" />';
\r
269 echo '<input type="submit" value="',_BATCH_EXEC,'" />';
\r
271 <a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(1); "><?php echo _BATCH_SELECTALL?></a> -
\r
272 <a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(0); "><?php echo _BATCH_DESELECTALL?></a>
\r
278 function showList($query, $type, $template, $templateName = '', $errorMessage = _LISTS_NOMORE)
\r
280 return $this->doEncapsulate( 'showlist',
\r
281 array($query, $type, $template, $templateName),
\r