00001 <?php 00002 /* 00003 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) 00004 * Copyright (C) 2002-2007 The Nucleus Group 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * (see nucleus/documentation/index.html#license for more info) 00011 */ 00012 00022 class ENCAPSULATE { 00031 function doEncapsulate($call, $params, $errorMessage = 'No entries') { 00032 // start output buffering 00033 ob_start(); 00034 00035 $nbOfRows = call_user_func_array($call, $params); 00036 00037 // get list contents and stop buffering 00038 $list = ob_get_contents(); 00039 ob_end_clean(); 00040 00041 if ($nbOfRows > 0) { 00042 $this->showHead(); 00043 echo $list; 00044 $this->showFoot(); 00045 } else { 00046 echo $errorMessage; 00047 } 00048 00049 return $nbOfRows; 00050 } 00051 } 00052 00056 class NAVLIST extends ENCAPSULATE { 00057 00058 function NAVLIST($action, $start, $amount, $minamount, $maxamount, $blogid, $search, $itemid) { 00059 $this->action = $action; 00060 $this->start = $start; 00061 $this->amount = $amount; 00062 $this->minamount = $minamount; 00063 $this->maxamount = $maxamount; 00064 $this->blogid = $blogid; 00065 $this->search = $search; 00066 $this->itemid = $itemid; 00067 } 00068 00069 function showBatchList($batchtype, $query, $type, $template, $errorMessage = _LISTS_NOMORE) { 00070 $batch =& new BATCH($batchtype); 00071 00072 $this->doEncapsulate( 00073 array(&$batch, 'showlist'), 00074 array(&$query, $type, $template), 00075 $errorMessage 00076 ); 00077 00078 } 00079 00080 00081 function showHead() { 00082 $this->showNavigation(); 00083 } 00084 function showFoot() { 00085 $this->showNavigation(); 00086 } 00087 00091 function showNavigation() { 00092 $action = $this->action; 00093 $start = $this->start; 00094 $amount = $this->amount; 00095 $minamount = $this->minamount; 00096 $maxamount = $this->maxamount; 00097 $blogid = $this->blogid; 00098 $search = htmlspecialchars($this->search); 00099 $itemid = $this->itemid; 00100 00101 $prev = $start - $amount; 00102 if ($prev < $minamount) $prev=$minamount; 00103 00104 // maxamount not used yet 00105 // if ($start + $amount <= $maxamount) 00106 $next = $start + $amount; 00107 // else 00108 // $next = $start; 00109 00110 ?> 00111 <table class="navigation"> 00112 <tr><td> 00113 <form method="post" action="index.php"><div> 00114 <input type="submit" value="<< <?php echo _LISTS_PREV?>" /> 00115 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" /> 00116 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" /> 00117 <input type="hidden" name="action" value="<?php echo $action; ?>" /> 00118 <input type="hidden" name="amount" value="<?php echo $amount; ?>" /> 00119 <input type="hidden" name="search" value="<?php echo $search; ?>" /> 00120 <input type="hidden" name="start" value="<?php echo $prev; ?>" /> 00121 </div></form> 00122 </td><td> 00123 <form method="post" action="index.php"><div> 00124 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" /> 00125 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" /> 00126 <input type="hidden" name="action" value="<?php echo $action; ?>" /> 00127 <input name="amount" size="3" value="<?php echo $amount; ?>" /> <?php echo _LISTS_PERPAGE?> 00128 <input type="hidden" name="start" value="<?php echo $start; ?>" /> 00129 <input type="hidden" name="search" value="<?php echo $search; ?>" /> 00130 <input type="submit" value="> <?php echo _LISTS_CHANGE?>" /> 00131 </div></form> 00132 </td><td> 00133 <form method="post" action="index.php"><div> 00134 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" /> 00135 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" /> 00136 <input type="hidden" name="action" value="<?php echo $action; ?>" /> 00137 <input type="hidden" name="amount" value="<?php echo $amount; ?>" /> 00138 <input type="hidden" name="start" value="0" /> 00139 <input type="text" name="search" value="<?php echo $search; ?>" size="7" /> 00140 <input type="submit" value="> <?php echo _LISTS_SEARCH?>" /> 00141 </div></form> 00142 </td><td> 00143 <form method="post" action="index.php"><div> 00144 <input type="submit" value="<?php echo _LISTS_NEXT?> > >" /> 00145 <input type="hidden" name="search" value="<?php echo $search; ?>" /> 00146 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" /> 00147 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" /> 00148 <input type="hidden" name="action" value="<?php echo $action; ?>" /> 00149 <input type="hidden" name="amount" value="<?php echo $amount; ?>" /> 00150 <input type="hidden" name="start" value="<?php echo $next; ?>" /> 00151 </div></form> 00152 </td></tr> 00153 </table> 00154 <?php } 00155 00156 00157 } 00158 00159 00163 class BATCH extends ENCAPSULATE { 00164 function BATCH($type) { 00165 $this->type = $type; 00166 } 00167 00168 function showHead() { 00169 ?> 00170 <form method="post" action="index.php"> 00171 <?php 00172 // TODO: get a list op operations above the list too 00173 // (be careful not to use the same names for the select...) 00174 // $this->showOperationList(); 00175 } 00176 00177 function showFoot() { 00178 $this->showOperationList(); 00179 ?> 00180 </form> 00181 <?php } 00182 00183 function showOperationList() { 00184 global $manager; 00185 ?> 00186 <div class="batchoperations"> 00187 <?php echo _BATCH_WITH_SEL ?> 00188 <select name="batchaction"> 00189 <?php $options = array(); 00190 switch($this->type) { 00191 case 'item': 00192 $options = array( 00193 'delete' => _BATCH_ITEM_DELETE, 00194 'move' => _BATCH_ITEM_MOVE 00195 ); 00196 break; 00197 case 'member': 00198 $options = array( 00199 'delete' => _BATCH_MEMBER_DELETE, 00200 'setadmin' => _BATCH_MEMBER_SET_ADM, 00201 'unsetadmin' => _BATCH_MEMBER_UNSET_ADM 00202 ); 00203 break; 00204 case 'team': 00205 $options = array( 00206 'delete' => _BATCH_TEAM_DELETE, 00207 'setadmin' => _BATCH_TEAM_SET_ADM, 00208 'unsetadmin' => _BATCH_TEAM_UNSET_ADM, 00209 ); 00210 break; 00211 case 'category': 00212 $options = array( 00213 'delete' => _BATCH_CAT_DELETE, 00214 'move' => _BATCH_CAT_MOVE, 00215 ); 00216 break; 00217 case 'comment': 00218 $options = array( 00219 'delete' => _BATCH_COMMENT_DELETE, 00220 ); 00221 break; 00222 } 00223 foreach ($options as $option => $label) { 00224 echo '<option value="',$option,'">',$label,'</option>'; 00225 } 00226 ?> 00227 </select> 00228 <input type="hidden" name="action" value="batch<?php echo $this->type?>" /> 00229 <?php 00230 $manager->addTicketHidden(); 00231 00232 // add hidden fields for 'team' and 'comment' batchlists 00233 if ($this->type == 'team') 00234 { 00235 echo '<input type="hidden" name="blogid" value="',intRequestVar('blogid'),'" />'; 00236 } 00237 if ($this->type == 'comment') 00238 { 00239 echo '<input type="hidden" name="itemid" value="',intRequestVar('itemid'),'" />'; 00240 } 00241 00242 echo '<input type="submit" value="',_BATCH_EXEC,'" />'; 00243 ?>( 00244 <a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(1); "><?php echo _BATCH_SELECTALL?></a> - 00245 <a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(0); "><?php echo _BATCH_DESELECTALL?></a> 00246 ) 00247 </div> 00248 <?php } 00249 00250 // shortcut :) 00251 function showList($query, $type, $template, $errorMessage = _LISTS_NOMORE) { 00252 return $this->doEncapsulate( 'showlist', 00253 array($query, $type, $template), 00254 $errorMessage 00255 ); 00256 } 00257 00258 } 00259 ?>