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 // start output buffering
\r
44 $nbOfRows = call_user_func_array($call, $params);
\r
46 // get list contents and stop buffering
\r
47 $list = ob_get_contents();
\r
50 if ( $nbOfRows > 0 )
\r
52 $this->showHead($templateName);
\r
54 $this->showFoot($templateName);
\r
66 * A class used to encapsulate a list of some sort inside next/prev buttons
\r
68 class NavList extends Encapsulate
\r
70 function __construct($action, $start, $amount, $minamount, $maxamount, $blogid, $search, $itemid)
\r
72 $this->action = $action;
\r
73 $this->start = $start;
\r
74 $this->amount = $amount;
\r
75 $this->minamount = $minamount;
\r
76 $this->maxamount = $maxamount;
\r
77 $this->blogid = $blogid;
\r
78 $this->search = $search;
\r
79 $this->itemid = $itemid;
\r
82 function showBatchList($batchtype, $query, $type, $template, $errorMessage = _LISTS_NOMORE)
\r
84 $batch = new Batch($batchtype);
\r
86 $this->doEncapsulate(
\r
87 array(&$batch, 'showlist'),
\r
88 array(&$query, $type, $template),
\r
97 $this->showNavigation();
\r
101 $this->showNavigation();
\r
105 * Displays a next/prev bar for long tables
\r
107 function showNavigation()
\r
109 $action = $this->action;
\r
110 $start = $this->start;
\r
111 $amount = $this->amount;
\r
112 $minamount = $this->minamount;
\r
113 $maxamount = $this->maxamount;
\r
114 $blogid = $this->blogid;
\r
115 $search = Entity::hsc($this->search);
\r
116 $itemid = $this->itemid;
\r
118 $prev = $start - $amount;
\r
119 if ( $prev < $minamount )
\r
124 // maxamount not used yet
\r
125 // if ($start + $amount <= $maxamount)
\r
126 $next = $start + $amount;
\r
131 <table class="navigation">
\r
133 <form method="post" action="index.php"><div>
\r
134 <input type="submit" value="<< <?php echo _LISTS_PREV?>" />
\r
135 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
\r
136 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
\r
137 <input type="hidden" name="action" value="<?php echo $action; ?>" />
\r
138 <input type="hidden" name="amount" value="<?php echo $amount; ?>" />
\r
139 <input type="hidden" name="search" value="<?php echo $search; ?>" />
\r
140 <input type="hidden" name="start" value="<?php echo $prev; ?>" />
\r
143 <form method="post" action="index.php"><div>
\r
144 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
\r
145 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
\r
146 <input type="hidden" name="action" value="<?php echo $action; ?>" />
\r
147 <input name="amount" size="3" value="<?php echo $amount; ?>" /> <?php echo _LISTS_PERPAGE?>
\r
148 <input type="hidden" name="start" value="<?php echo $start; ?>" />
\r
149 <input type="hidden" name="search" value="<?php echo $search; ?>" />
\r
150 <input type="submit" value="> <?php echo _LISTS_CHANGE?>" />
\r
153 <form method="post" action="index.php"><div>
\r
154 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
\r
155 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
\r
156 <input type="hidden" name="action" value="<?php echo $action; ?>" />
\r
157 <input type="hidden" name="amount" value="<?php echo $amount; ?>" />
\r
158 <input type="hidden" name="start" value="0" />
\r
159 <input type="text" name="search" value="<?php echo $search; ?>" size="7" />
\r
160 <input type="submit" value="> <?php echo _LISTS_SEARCH?>" />
\r
163 <form method="post" action="index.php"><div>
\r
164 <input type="submit" value="<?php echo _LISTS_NEXT?> > >" />
\r
165 <input type="hidden" name="search" value="<?php echo $search; ?>" />
\r
166 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
\r
167 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
\r
168 <input type="hidden" name="action" value="<?php echo $action; ?>" />
\r
169 <input type="hidden" name="amount" value="<?php echo $amount; ?>" />
\r
170 <input type="hidden" name="start" value="<?php echo $next; ?>" />
\r
181 * A class used to encapsulate a list of some sort in a batch selection
\r
183 class Batch extends Encapsulate
\r
185 function __construct($type)
\r
187 $this->type = $type;
\r
190 function showHead($templateName = '')
\r
193 <form method="post" action="index.php">
\r
195 // TODO: get a list op operations above the list too
\r
196 // (be careful not to use the same names for the select...)
\r
197 // $this->showOperationList();
\r
200 function showFoot($templateName = '') {
\r
201 $this->showOperationList();
\r
206 function showOperationList()
\r
210 <div class="batchoperations">
\r
211 <?php echo _BATCH_WITH_SEL ?>
\r
212 <select name="batchaction">
\r
213 <?php $options = array();
\r
214 switch($this->type) {
\r
217 'delete' => _BATCH_ITEM_DELETE,
\r
218 'move' => _BATCH_ITEM_MOVE
\r
223 'delete' => _BATCH_MEMBER_DELETE,
\r
224 'setadmin' => _BATCH_MEMBER_SET_ADM,
\r
225 'unsetadmin' => _BATCH_MEMBER_UNSET_ADM
\r
230 'delete' => _BATCH_TEAM_DELETE,
\r
231 'setadmin' => _BATCH_TEAM_SET_ADM,
\r
232 'unsetadmin' => _BATCH_TEAM_UNSET_ADM,
\r
237 'delete' => _BATCH_CAT_DELETE,
\r
238 'move' => _BATCH_CAT_MOVE,
\r
243 'delete' => _BATCH_COMMENT_DELETE,
\r
247 foreach ($options as $option => $label) {
\r
248 echo '<option value="',$option,'">',$label,'</option>';
\r
252 <input type="hidden" name="action" value="batch<?php echo $this->type?>" />
\r
254 $manager->addTicketHidden();
\r
256 // add hidden fields for 'team' and 'comment' batchlists
\r
257 if ($this->type == 'team')
\r
259 echo '<input type="hidden" name="blogid" value="',intRequestVar('blogid'),'" />';
\r
261 if ($this->type == 'comment')
\r
263 echo '<input type="hidden" name="itemid" value="',intRequestVar('itemid'),'" />';
\r
266 echo '<input type="submit" value="',_BATCH_EXEC,'" />';
\r
268 <a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(1); "><?php echo _BATCH_SELECTALL?></a> -
\r
269 <a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(0); "><?php echo _BATCH_DESELECTALL?></a>
\r
275 function showList($query, $type, $template, $errorMessage = _LISTS_NOMORE, $templateName = '') {
\r
276 return $this->doEncapsulate( 'showlist',
\r
277 array($query, $type, $template, $templateName),
\r