3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
\r
4 * Copyright (C) 2002-2009 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-2009 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
32 // start output buffering
\r
35 $nbOfRows = call_user_func_array($call, $params);
\r
37 // get list contents and stop buffering
\r
38 $list = ob_get_contents();
\r
41 if ($nbOfRows > 0) {
\r
54 * A class used to encapsulate a list of some sort inside next/prev buttons
\r
56 class NavList extends Encapsulate
\r
58 function __construct($action, $start, $amount, $minamount, $maxamount, $blogid, $search, $itemid) {
\r
59 $this->action = $action;
\r
60 $this->start = $start;
\r
61 $this->amount = $amount;
\r
62 $this->minamount = $minamount;
\r
63 $this->maxamount = $maxamount;
\r
64 $this->blogid = $blogid;
\r
65 $this->search = $search;
\r
66 $this->itemid = $itemid;
\r
69 function showBatchList($batchtype, $query, $type, $template, $errorMessage = _LISTS_NOMORE) {
\r
70 $batch = new Batch($batchtype);
\r
72 $this->doEncapsulate(
\r
73 array(&$batch, 'showlist'),
\r
74 array(&$query, $type, $template),
\r
81 function showHead() {
\r
82 $this->showNavigation();
\r
84 function showFoot() {
\r
85 $this->showNavigation();
\r
89 * Displays a next/prev bar for long tables
\r
91 function showNavigation() {
\r
92 $action = $this->action;
\r
93 $start = $this->start;
\r
94 $amount = $this->amount;
\r
95 $minamount = $this->minamount;
\r
96 $maxamount = $this->maxamount;
\r
97 $blogid = $this->blogid;
\r
98 $search = Entity::hsc($this->search);
\r
99 $itemid = $this->itemid;
\r
101 $prev = $start - $amount;
\r
102 if ($prev < $minamount) $prev=$minamount;
\r
104 // maxamount not used yet
\r
105 // if ($start + $amount <= $maxamount)
\r
106 $next = $start + $amount;
\r
111 <table class="navigation">
\r
113 <form method="post" action="index.php"><div>
\r
114 <input type="submit" value="<< <?php echo _LISTS_PREV?>" />
\r
115 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
\r
116 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
\r
117 <input type="hidden" name="action" value="<?php echo $action; ?>" />
\r
118 <input type="hidden" name="amount" value="<?php echo $amount; ?>" />
\r
119 <input type="hidden" name="search" value="<?php echo $search; ?>" />
\r
120 <input type="hidden" name="start" value="<?php echo $prev; ?>" />
\r
123 <form method="post" action="index.php"><div>
\r
124 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
\r
125 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
\r
126 <input type="hidden" name="action" value="<?php echo $action; ?>" />
\r
127 <input name="amount" size="3" value="<?php echo $amount; ?>" /> <?php echo _LISTS_PERPAGE?>
\r
128 <input type="hidden" name="start" value="<?php echo $start; ?>" />
\r
129 <input type="hidden" name="search" value="<?php echo $search; ?>" />
\r
130 <input type="submit" value="> <?php echo _LISTS_CHANGE?>" />
\r
133 <form method="post" action="index.php"><div>
\r
134 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
\r
135 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
\r
136 <input type="hidden" name="action" value="<?php echo $action; ?>" />
\r
137 <input type="hidden" name="amount" value="<?php echo $amount; ?>" />
\r
138 <input type="hidden" name="start" value="0" />
\r
139 <input type="text" name="search" value="<?php echo $search; ?>" size="7" />
\r
140 <input type="submit" value="> <?php echo _LISTS_SEARCH?>" />
\r
143 <form method="post" action="index.php"><div>
\r
144 <input type="submit" value="<?php echo _LISTS_NEXT?> > >" />
\r
145 <input type="hidden" name="search" value="<?php echo $search; ?>" />
\r
146 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
\r
147 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
\r
148 <input type="hidden" name="action" value="<?php echo $action; ?>" />
\r
149 <input type="hidden" name="amount" value="<?php echo $amount; ?>" />
\r
150 <input type="hidden" name="start" value="<?php echo $next; ?>" />
\r
161 * A class used to encapsulate a list of some sort in a batch selection
\r
163 class Batch extends Encapsulate
\r
165 function __construct($type) {
\r
166 $this->type = $type;
\r
169 function showHead() {
\r
171 <form method="post" action="index.php">
\r
173 // TODO: get a list op operations above the list too
\r
174 // (be careful not to use the same names for the select...)
\r
175 // $this->showOperationList();
\r
178 function showFoot() {
\r
179 $this->showOperationList();
\r
184 function showOperationList() {
\r
187 <div class="batchoperations">
\r
188 <?php echo _BATCH_WITH_SEL ?>
\r
189 <select name="batchaction">
\r
190 <?php $options = array();
\r
191 switch($this->type) {
\r
194 'delete' => _BATCH_ITEM_DELETE,
\r
195 'move' => _BATCH_ITEM_MOVE
\r
200 'delete' => _BATCH_MEMBER_DELETE,
\r
201 'setadmin' => _BATCH_MEMBER_SET_ADM,
\r
202 'unsetadmin' => _BATCH_MEMBER_UNSET_ADM
\r
207 'delete' => _BATCH_TEAM_DELETE,
\r
208 'setadmin' => _BATCH_TEAM_SET_ADM,
\r
209 'unsetadmin' => _BATCH_TEAM_UNSET_ADM,
\r
214 'delete' => _BATCH_CAT_DELETE,
\r
215 'move' => _BATCH_CAT_MOVE,
\r
220 'delete' => _BATCH_COMMENT_DELETE,
\r
224 foreach ($options as $option => $label) {
\r
225 echo '<option value="',$option,'">',$label,'</option>';
\r
229 <input type="hidden" name="action" value="batch<?php echo $this->type?>" />
\r
231 $manager->addTicketHidden();
\r
233 // add hidden fields for 'team' and 'comment' batchlists
\r
234 if ($this->type == 'team')
\r
236 echo '<input type="hidden" name="blogid" value="',intRequestVar('blogid'),'" />';
\r
238 if ($this->type == 'comment')
\r
240 echo '<input type="hidden" name="itemid" value="',intRequestVar('itemid'),'" />';
\r
243 echo '<input type="submit" value="',_BATCH_EXEC,'" />';
\r
245 <a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(1); "><?php echo _BATCH_SELECTALL?></a> -
\r
246 <a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(0); "><?php echo _BATCH_DESELECTALL?></a>
\r
252 function showList($query, $type, $template, $errorMessage = _LISTS_NOMORE) {
\r
253 return $this->doEncapsulate( 'showlist',
\r
254 array($query, $type, $template),
\r