[ Index ] |
|
Code source de GeekLog 1.4.1 |
1 <?php 2 3 /* Reminder: always indent with 4 spaces (no tabs). */ 4 // +---------------------------------------------------------------------------+ 5 // | Geeklog 1.4 | 6 // +---------------------------------------------------------------------------+ 7 // | lib-admin.php | 8 // | | 9 // | Admin-related functions needed in more than one place. | 10 // +---------------------------------------------------------------------------+ 11 // | Copyright (C) 2000-2006 by the following authors: | 12 // | | 13 // | Authors: Tony Bibbs - tony AT tonybibbs DOT com | 14 // | Mark Limburg - mlimburg AT users DOT sourceforge DOT net | 15 // | Jason Whittenburg - jwhitten AT securitygeeks DOT com | 16 // | Dirk Haun - dirk AT haun-online DOT de | 17 // | Oliver Spiesshofer - oliver AT spiesshofer DOT com | 18 // +---------------------------------------------------------------------------+ 19 // | | 20 // | This program is free software; you can redistribute it and/or | 21 // | modify it under the terms of the GNU General Public License | 22 // | as published by the Free Software Foundation; either version 2 | 23 // | of the License, or (at your option) any later version. | 24 // | | 25 // | This program is distributed in the hope that it will be useful, | 26 // | but WITHOUT ANY WARRANTY; without even the implied warranty of | 27 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 28 // | GNU General Public License for more details. | 29 // | | 30 // | You should have received a copy of the GNU General Public License | 31 // | along with this program; if not, write to the Free Software Foundation, | 32 // | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 33 // | | 34 // +---------------------------------------------------------------------------+ 35 // 36 // $Id: lib-admin.php,v 1.95 2006/11/26 12:03:56 dhaun Exp $ 37 38 if (strpos ($_SERVER['PHP_SELF'], 'lib-admin.php') !== false) { 39 die ('This file can not be used on its own!'); 40 } 41 42 /** 43 * Common function used in Admin scripts to display a list of items 44 * 45 * @param string $fieldfunction Name of a function used to display the list item row details 46 * @param array $header_arr array of header fields with sortables and table fields 47 * @param array $text_arr array with different text strings 48 * @param array $data_arr array with sql query data - array of list records 49 * @param array $menu_arr menu-entries 50 * @param array $options array of options - intially just used for the Check-All feature 51 * @return string HTML output of function 52 * 53 */ 54 function ADMIN_simpleList($fieldfunction, $header_arr, $text_arr, 55 $data_arr, $menu_arr = '', $options = '') 56 { 57 global $_CONF, $_TABLES, $LANG01, $LANG_ADMIN, $LANG_ACCESS, $_IMAGE_TYPE, $MESSAGE; 58 59 $retval = ''; 60 61 $help_url = ""; 62 if (!empty($text_arr['help_url'])) { 63 $help_url = $text_arr['help_url']; 64 } 65 66 $title = ""; 67 if (!empty($text_arr['title'])) { 68 $title = $text_arr['title']; 69 } 70 71 $form_url = ''; 72 if (!empty($text_arr['form_url'])) { 73 $form_url = $text_arr['form_url']; 74 } 75 76 $icon = ''; 77 if (isset($text_arr['icon'])) { 78 $icon = $text_arr['icon']; 79 } 80 $admin_templates = new Template($_CONF['path_layout'] . 'admin/lists'); 81 $admin_templates->set_file (array ('topmenu' => 'topmenu_nosearch.thtml', 82 'list' => 'list.thtml', 83 'header' => 'header.thtml', 84 'row' => 'listitem.thtml', 85 'field' => 'field.thtml', 86 'menufields' => 'menufields.thtml' 87 )); 88 $admin_templates->set_var('site_url', $_CONF['site_url']); 89 $admin_templates->set_var('layout_url', $_CONF['layout_url']); 90 $admin_templates->set_var('form_url', $form_url); 91 if (isset ($text_arr['icon']) && ($text_arr['icon'] !== false)) { 92 $admin_templates->set_var('icon', "<img src=\"{$text_arr['icon']}\" alt=\"\">"); 93 } 94 95 $admin_templates->set_var('lang_edit', $LANG_ADMIN['edit']); 96 $admin_templates->set_var('lang_deleteall', $LANG01[124]); 97 $admin_templates->set_var('lang_delconfirm', $LANG01[125]); 98 99 if ($text_arr['has_menu']) { 100 for ($i = 0; $i < count($menu_arr); $i++) { 101 $admin_templates->set_var('menu_url', $menu_arr[$i]['url'] ); 102 $admin_templates->set_var('menu_text', $menu_arr[$i]['text'] ); 103 if ($i < (count($menu_arr) -1)) { 104 $admin_templates->set_var('line', '|' ); 105 } 106 $admin_templates->parse('menu_fields', 'menufields', true); 107 $admin_templates->clear_var('line'); 108 } 109 $admin_templates->set_var('lang_instructions', $text_arr['instructions']); 110 $admin_templates->parse('top_menu', 'topmenu', true); 111 } 112 113 $icon_arr = array( 114 'edit' => '<img src="' . $_CONF['layout_url'] . '/images/edit.' 115 . $_IMAGE_TYPE . '" border="0" alt="' . $LANG_ADMIN['edit'] . '" title="' 116 . $LANG_ADMIN['edit'] . '">', 117 'copy' => '<img src="' . $_CONF['layout_url'] . '/images/copy.' 118 . $_IMAGE_TYPE . '" border="0" alt="' . $LANG_ADMIN['copy'] . '" title="' 119 . $LANG_ADMIN['copy'] . '">', 120 'list' => '<img src="' . $_CONF['layout_url'] . '/images/list.' 121 . $_IMAGE_TYPE . '" border="0" alt="' . $LANG_ACCESS['listthem'] 122 . '" title="' . $LANG_ACCESS['listthem'] . '">' 123 ); 124 125 $retval .= COM_startBlock ($title, $help_url, 126 COM_getBlockTemplate ('_admin_block', 'header')); 127 128 // Check if the delete checkbox and support for the delete all feature should be displayed 129 if (count($data_arr) > 1 AND is_array($options) AND $options['chkdelete']) { 130 $admin_templates->set_var('header_text', '<input type="checkbox" name="chk_selectall" title="'.$LANG01[126].'" onclick="caItems(this.form);">'); 131 $admin_templates->set_var('class', "admin-list-headerfield"); 132 $admin_templates->set_var('show_deleteimage', ''); 133 $admin_templates->parse('header_row', 'header', true); 134 $admin_templates->clear_var('on_click'); 135 } else { 136 $admin_templates->set_var('show_deleteimage','display:none;'); 137 } 138 139 # HEADER FIELDS array(text, field, sort) 140 for ($i=0; $i < count( $header_arr ); $i++) { 141 $admin_templates->set_var('header_text', $header_arr[$i]['text']); 142 if (!empty($header_arr[$i]['header_class'])) { 143 $admin_templates->set_var('class', $header_arr[$i]['header_class']); 144 } else { 145 $admin_templates->set_var('class', "admin-list-headerfield"); 146 } 147 $admin_templates->parse('header_row', 'header', true); 148 } 149 150 if (count($data_arr) == 0) { 151 if (isset($text_arr['no_data'])) { 152 $message = $text_arr['no_data']; 153 } else { 154 $message = $LANG_ADMIN['no_results']; 155 } 156 $admin_templates->set_var('message', $message); 157 } else if ($data_arr === false) { 158 $admin_templates->set_var('message', $LANG_ADMIN['data_error']); 159 } else { 160 $admin_templates->set_var('show_message', 'display:none;'); 161 for ($i = 0; $i < count($data_arr); $i++) { 162 if (count($data_arr) > 1 AND is_array($options) AND $options['chkdelete']) { 163 $admin_templates->set_var('itemtext', '<input type="checkbox" name="delitem[]" value="' . $data_arr[$i][$options['chkfield']].'">'); 164 $admin_templates->parse('item_field', 'field', true); 165 } 166 for ($j = 0; $j < count($header_arr); $j++) { 167 $fieldname = $header_arr[$j]['field']; 168 $fieldvalue = ''; 169 if (!empty($data_arr[$i][$fieldname])) { 170 $fieldvalue = $data_arr[$i][$fieldname]; 171 } 172 if (!empty($fieldfunction)) { 173 $fieldvalue = $fieldfunction($fieldname, $fieldvalue, $data_arr[$i], $icon_arr); 174 } else { 175 $fieldvalue = $fieldvalue; 176 } 177 if (!empty($header_arr[$j]['field_class'])) { 178 $admin_templates->set_var('class', $header_arr[$j]['field_class']); 179 } else { 180 $admin_templates->set_var('class', "admin-list-field"); 181 } 182 if ($fieldvalue !== false) { 183 $admin_templates->set_var('itemtext', $fieldvalue); 184 $admin_templates->parse('item_field', 'field', true); 185 } 186 } 187 $admin_templates->set_var('cssid', ($i%2)+1); 188 $admin_templates->parse('item_row', 'row', true); 189 $admin_templates->clear_var('item_field'); 190 } 191 } 192 193 $admin_templates->parse('output', 'list'); 194 $retval .= $admin_templates->finish($admin_templates->get_var('output')); 195 $retval .= COM_endBlock (COM_getBlockTemplate ('_admin_block', 'footer')); 196 return $retval; 197 198 } 199 200 /** 201 * Creates a list of data with a menu, search, filter, clickable headers etc. 202 * 203 * @param string $component name of the list 204 * @param string $fieldfunction name of the function that handles special entries 205 * @param array $header_arr array of header fields with sortables and table fields 206 * @param array $text_arr array with different text strings 207 * @param array $query_arr array with sql-options 208 * @param array $menu_arr menu-entries 209 * @param array $defsort_arr default sorting values 210 * @param string $filter additional drop-down filters 211 * @param string $extra additional values passed to fieldfunction 212 * @return string HTML output of function 213 * 214 */ 215 function ADMIN_list($component, $fieldfunction, $header_arr, $text_arr, 216 $query_arr, $menu_arr, $defsort_arr, $filter = '', $extra = '', $options = '') 217 { 218 global $_CONF, $_TABLES, $LANG_ADMIN, $LANG_ACCESS, $LANG01, $_IMAGE_TYPE, $MESSAGE; 219 220 // set all variables to avoid warnings 221 $retval = ''; 222 $filter_str = ''; 223 $order_sql = ''; 224 $limit = ''; 225 $prevorder = ''; 226 if (isset ($_GET['prevorder'])) { # what was the last sorting? 227 $prevorder = COM_applyFilter ($_GET['prevorder']); 228 } 229 230 $query = ''; 231 if (isset ($_REQUEST['q'])) { # get query (text-search) 232 $query = $_REQUEST['q']; 233 } 234 235 $query_limit = ""; 236 if (isset($_REQUEST['query_limit'])) { # get query-limit (list-length) 237 $query_limit = COM_applyFilter ($_REQUEST['query_limit'], true); 238 if($query_limit == 0) { 239 $query_limit = 50; 240 } 241 } 242 243 // we assume that the current page is 1 to set it. 244 $curpage = 1; 245 $page = ''; 246 // get the current page from the interface. The variable is linked to the 247 // component, i.e. the plugin/function calling this here to avoid overlap 248 if (isset ($_REQUEST[$component . 'listpage'])) { 249 $page = COM_applyFilter ($_REQUEST[$component . 'listpage'], true); 250 $curpage = $page; 251 } 252 if ($curpage <= 0) { 253 $curpage = 1; #current page has to be larger 0 254 } 255 256 #$unfiltered=''; 257 #if (!empty($query_arr['unfiltered'])) { 258 # $unfiltered = $query_arr['unfiltered']; 259 #} 260 261 $help_url = ''; # do we have a help url for the block-header? 262 if (!empty ($text_arr['help_url'])) { 263 $help_url = $text_arr['help_url']; 264 } 265 266 $form_url = ''; # what is the form-url for the search button and list sorters? 267 if (!empty ($text_arr['form_url'])) { 268 $form_url = $text_arr['form_url']; 269 } 270 271 $title = ''; # what is the title of the page? 272 if (!empty ($text_arr['title'])) { 273 $title = $text_arr['title']; 274 } 275 276 # get all template fields. Maybe menufields can be only loaded if used? 277 $admin_templates = new Template($_CONF['path_layout'] . 'admin/lists'); 278 $admin_templates->set_file (array ( 279 'topmenu' => 'topmenu.thtml', 280 'list' => 'list.thtml', 281 'header' => 'header.thtml', 282 'row' => 'listitem.thtml', 283 'field' => 'field.thtml', 284 'menufields' => 'menufields.thtml' 285 )); 286 287 # insert std. values into the template 288 $admin_templates->set_var('site_url', $_CONF['site_url']); 289 $admin_templates->set_var('layout_url', $_CONF['layout_url']); 290 $admin_templates->set_var('form_url', $form_url); 291 if ($text_arr['icon'] !== false or $text_arr['icon']='') { 292 $admin_templates->set_var('icon', "<img src=\"{$text_arr['icon']}\" alt=\"\">"); 293 } 294 $admin_templates->set_var('lang_edit', $LANG_ADMIN['edit']); 295 $admin_templates->set_var('lang_deleteall', $LANG01[124]); 296 $admin_templates->set_var('lang_delconfirm', $LANG01[125]); 297 298 // Check if the delete checkbox and support for the delete all feature should be displayed 299 if (is_array($options) AND $options['chkdelete']) { 300 $admin_templates->set_var('header_text', '<input type="checkbox" name="chk_selectall" title="'.$LANG01[126].'" onclick="caItems(this.form);">'); 301 $admin_templates->set_var('class', "admin-list-headerfield"); 302 $admin_templates->set_var('show_deleteimage', ''); 303 $admin_templates->parse('header_row', 'header', true); 304 $admin_templates->clear_var('on_click'); 305 } else { 306 $admin_templates->set_var('show_deleteimage','display:none;'); 307 } 308 309 # define icon paths. Those will be transmitted to $fieldfunction. 310 $icon_arr = array( 311 'edit' => '<img src="' . $_CONF['layout_url'] . '/images/edit.' 312 . $_IMAGE_TYPE . '" border="0" alt="' . $LANG_ADMIN['edit'] 313 . '" title="' . $LANG_ADMIN['edit'] . '">', 314 'copy' => '<img src="' . $_CONF['layout_url'] . '/images/copy.' 315 . $_IMAGE_TYPE . '" border="0" alt="' . $LANG_ADMIN['copy'] 316 . '" title="' . $LANG_ADMIN['copy'] . '">', 317 'list' => '<img src="' . $_CONF['layout_url'] . '/images/list.' 318 . $_IMAGE_TYPE . '" border="0" alt="' . $LANG_ACCESS['listthem'] 319 . '" title="' . $LANG_ACCESS['listthem'] . '">' 320 ); 321 // the user can disable the menu. if used, create it. 322 if ($text_arr['has_menu']) { 323 for ($i = 0; $i < count($menu_arr); $i++) { # iterate through menu 324 $admin_templates->set_var('menu_url', $menu_arr[$i]['url'] ); 325 $admin_templates->set_var('menu_text', $menu_arr[$i]['text'] ); 326 if ($i < (count($menu_arr) -1)) { 327 $admin_templates->set_var('line', '|' ); # add separator 328 } 329 $admin_templates->parse('menu_fields', 'menufields', true); 330 $admin_templates->clear_var('line'); # clear separator after use 331 } 332 # add text strings to template 333 $admin_templates->set_var('lang_instructions', $text_arr['instructions']); 334 $admin_templates->set_var('lang_search', $LANG_ADMIN['search']); 335 $admin_templates->set_var('lang_submit', $LANG_ADMIN['submit']); 336 $admin_templates->set_var('lang_limit_results', $LANG_ADMIN['limit_results']); 337 $admin_templates->set_var('last_query', COM_applyFilter($query)); 338 $admin_templates->set_var('filter', $filter); 339 $admin_templates->parse('top_menu', 'topmenu', true); 340 } 341 342 $sql_query = addslashes ($query); # replace quotes etc for security 343 $sql = $query_arr['sql']; # get sql from array that builds data 344 345 $order_var = ''; # number that is displayed in URL 346 $order = ''; # field that is used in SQL 347 $order_var_link = ''; # Variable for google paging. 348 349 // is the order set in the link (when sorting the list) 350 if (!isset ($_GET['order'])) { 351 $order = $defsort_arr['field']; // no, get the default 352 } else { 353 $order_var = COM_applyFilter ($_GET['order'], true); 354 $order_var_link = "&order=$order_var"; # keep the variable for the google paging 355 $order = $header_arr[$order_var]['field']; # current order field name 356 } 357 $order_for_query = $order; 358 // this code sorts only by the field if its in table.field style. 359 // removing this however makes match for arrow-display impossible, so removed it. 360 // maybe now for more fields the table has to be added to the sortfield? 361 //$order = explode ('.', $order); 362 //if (count ($order) > 1) { 363 // $order = $order[1]; 364 //} else { 365 // $order = $order[0]; 366 //} 367 368 $direction = ''; 369 if (!isset ($_GET['direction'])) { # get direction to sort after 370 $direction = $defsort_arr['direction']; 371 } else { 372 $direction = COM_applyFilter ($_GET['direction']); 373 } 374 $direction = strtoupper ($direction); 375 if ($order == $prevorder) { #reverse direction if prev. order was the same 376 $direction = ($direction == 'DESC') ? 'ASC' : 'DESC'; 377 } else { 378 $direction = ($direction == 'DESC') ? 'DESC' : 'ASC'; 379 } 380 381 if ($direction == 'ASC') { # assign proper arrow img name dep. on sort order 382 $arrow = 'bararrowdown'; 383 } else { 384 $arrow = 'bararrowup'; 385 } 386 # make actual order arrow image 387 $img_arrow = ' <img src="' . $_CONF['layout_url'] . '/images/' . $arrow 388 . '.' . $_IMAGE_TYPE . '" border="0" alt="">'; 389 390 if (!empty ($order_for_query)) { # concat order string 391 $order_sql = "ORDER BY $order_for_query $direction"; 392 } 393 $th_subtags = ''; // other tags in the th, such as onlick and mouseover 394 $header_text = ''; // title as displayed to the user 395 // HEADER FIELDS array(text, field, sort, class) 396 // this part defines the contents & format of the header fields 397 398 for ($i=0; $i < count( $header_arr ); $i++) { #iterate through all headers 399 $header_text = $header_arr[$i]['text']; 400 if ($header_arr[$i]['sort'] != false) { # is this sortable? 401 if ($order==$header_arr[$i]['field']) { # is this currently sorted? 402 $header_text .= $img_arrow; 403 } 404 # make the mouseover effect is sortable 405 $th_subtags = " OnMouseOver=\"this.style.cursor='pointer';\""; 406 $order_var = $i; # assign number to field so we know what to sort 407 if (strpos ($form_url, '?') > 0) { 408 $separator = '&'; 409 } else { 410 $separator = '?'; 411 } 412 $th_subtags .= " onclick=\"window.location.href='$form_url$separator" #onclick action 413 ."order=$order_var&prevorder=$order&direction=$direction"; 414 if (!empty ($page)) { 415 $th_subtags .= '&' . $component . 'listpage=' . $page; 416 } 417 if (!empty ($query)) { 418 $th_subtags .= '&q=' . $query; 419 } 420 if (!empty ($query_limit)) { 421 $th_subtags .= '&query_limit=' . $query_limit; 422 } 423 $th_subtags .= "';\""; 424 } 425 426 if (!empty($header_arr[$i]['header_class'])) { 427 $admin_templates->set_var('class', $header_arr[$i]['header_class']); 428 } else { 429 $admin_templates->set_var('class', "admin-list-headerfield"); 430 } 431 $admin_templates->set_var('header_text', $header_text); 432 $admin_templates->set_var('th_subtags', $th_subtags); 433 $admin_templates->parse('header_row', 'header', true); 434 $admin_templates->clear_var('th_subtags'); // clear all for next header 435 $admin_templates->clear_var('class'); 436 $admin_templates->clear_var('header_text'); 437 } 438 439 $has_extras = ''; 440 if (isset($text_arr['has_extras'])) { # does this one use extras? (google paging) 441 $has_extras = $text_arr['has_extras']; 442 } 443 if ($has_extras) { 444 $limit = 50; # default query limit if not other chosen. 445 # maybe this could be a setting from the list? 446 if (!empty($query_limit)) { 447 $limit = $query_limit; 448 } 449 if ($query != '') { # set query into form after search 450 $admin_templates->set_var ('query', urlencode($query) ); 451 } else { 452 $admin_templates->set_var ('query', ''); 453 } 454 $admin_templates->set_var ('query_limit', $query_limit); 455 # choose proper dropdown field for query limit 456 $admin_templates->set_var($limit . '_selected', 'selected="selected"'); 457 458 if (!empty($query_arr['default_filter'])){ # add default filter to sql 459 $filter_str = " {$query_arr['default_filter']}"; 460 } 461 if (!empty ($query)) { # add query fields with search term 462 $filter_str .= " AND ("; 463 for ($f = 0; $f < count($query_arr['query_fields']); $f++) { 464 $filter_str .= $query_arr['query_fields'][$f] 465 . " LIKE '%$sql_query%'"; 466 if ($f < (count($query_arr['query_fields']) - 1)) { 467 $filter_str .= " OR "; 468 } 469 } 470 $filter_str .= ")"; 471 } 472 $num_pages_sql = $sql . $filter_str; 473 // COM_errorLog($num_pages_sql); 474 $num_pages_result = DB_query($num_pages_sql); 475 $num_rows = DB_numRows($num_pages_result); 476 $num_pages = ceil ($num_rows / $limit); 477 if ($num_pages < $curpage) { # make sure we dont go beyond possible results 478 $curpage = 1; 479 } 480 $offset = (($curpage - 1) * $limit); 481 $limit = "LIMIT $offset,$limit"; # get only current page data 482 $admin_templates->set_var ('lang_records_found', 483 $LANG_ADMIN['records_found']); 484 $admin_templates->set_var ('records_found', 485 COM_numberFormat ($num_rows)); 486 } 487 488 # SQL 489 $sql .= "$filter_str $order_sql $limit;"; 490 // echo $sql; 491 $result = DB_query($sql); 492 $nrows = DB_numRows($result); 493 $r = 1; # r is the counter for the actual displayed rows for correct coloring 494 for ($i = 0; $i < $nrows; $i++) { # now go through actual data 495 $A = DB_fetchArray($result); 496 $this_row = false; # as long as no fields are returned, dont print row 497 if (is_array($options) AND $options['chkdelete']) { 498 $admin_templates->set_var('class', "admin-list-field"); 499 $admin_templates->set_var('itemtext', '<input type="checkbox" name="delitem[]" value="' . $A[$options['chkfield']].'">'); 500 $admin_templates->parse('item_field', 'field', true); 501 } 502 for ($j = 0; $j < count($header_arr); $j++) { 503 $fieldname = $header_arr[$j]['field']; # get field name from headers 504 $fieldvalue = ''; 505 if (!empty($A[$fieldname])) { # is there a field in data like that? 506 $fieldvalue = $A[$fieldname]; # yes, get its data 507 } 508 if (!empty ($fieldfunction) && !empty ($extra)) { 509 $fieldvalue = $fieldfunction ($fieldname, $fieldvalue, $A, $icon_arr, $extra); 510 } else if (!empty ($fieldfunction)) { # do we have a fieldfunction? 511 $fieldvalue = $fieldfunction ($fieldname, $fieldvalue, $A, $icon_arr); 512 } else { # if not just take the value 513 $fieldvalue = $fieldvalue; 514 } 515 if ($fieldvalue !== false) { # return was there, so write line 516 $this_row = true; 517 } else { 518 $fieldvalue = ''; // dont give emtpy fields 519 } 520 if (!empty($header_arr[$j]['field_class'])) { 521 $admin_templates->set_var('class', $header_arr[$j]['field_class']); 522 } else { 523 $admin_templates->set_var('class', "admin-list-field"); 524 } 525 $admin_templates->set_var('itemtext', $fieldvalue); # write field 526 $admin_templates->parse('item_field', 'field', true); 527 } 528 if ($this_row) { # there was data in at least one field, so print line 529 $r++; # switch to next color 530 $admin_templates->set_var('cssid', ($r%2)+1); # make alternating table color 531 $admin_templates->parse('item_row', 'row', true); # process the complete row 532 } 533 $admin_templates->clear_var('item_field'); # clear field 534 } 535 536 if ($nrows==0) { # there is no data. return notification message. 537 if (isset($text_arr['no_data'])) { 538 $message = $text_arr['no_data']; # there is a user-message 539 } else { 540 $message = $LANG_ADMIN['no_results']; # take std. 541 } 542 $admin_templates->set_var('message', $message); 543 } 544 545 if ($has_extras) { # now make google-paging 546 $hasargs = strstr( $form_url, '?' ); 547 if( $hasargs ) { 548 $sep = '&'; 549 } else { 550 $sep = '?'; 551 } 552 if (!empty($query)) { # port query to next page 553 $base_url = $form_url . $sep . 'q=' . urlencode($query) . "&query_limit=$query_limit$order_var_link&direction=$direction"; 554 } else { 555 $base_url = $form_url . $sep ."query_limit=$query_limit$order_var_link&direction=$direction"; 556 } 557 558 if ($num_pages > 1) { # print actual google-paging 559 $admin_templates->set_var('google_paging',COM_printPageNavigation($base_url,$curpage,$num_pages, $component . 'listpage=')); 560 } else { 561 $admin_templates->set_var('google_paging', ''); 562 } 563 } 564 565 $admin_templates->parse('output', 'list'); 566 567 # Do the actual output 568 $retval .= COM_startBlock ($title, $help_url, 569 COM_getBlockTemplate ('_admin_block', 'header')); 570 if (!$has_extras) { 571 $retval .= $text_arr['instructions']; 572 } 573 $retval .= $admin_templates->finish($admin_templates->get_var('output')) 574 . COM_endBlock (COM_getBlockTemplate ('_admin_block', 'footer')); 575 576 return $retval; 577 } 578 579 580 581 function ADMIN_getListField_blocks($fieldname, $fieldvalue, $A, $icon_arr) 582 { 583 global $_CONF, $LANG_ADMIN, $LANG21, $_IMAGE_TYPE; 584 $retval = false; 585 586 $access = SEC_hasAccess($A['owner_id'],$A['group_id'],$A['perm_owner'],$A['perm_group'],$A['perm_members'],$A['perm_anon']); 587 588 if (($access > 0) && (hasBlockTopicAccess ($A['tid']) > 0)) { 589 switch($fieldname) { 590 case "edit": 591 if ($access == 3) { 592 $retval = "<a href=\"{$_CONF['site_admin_url']}/block.php?mode=edit&bid={$A['bid']}\">{$icon_arr['edit']}</a>"; 593 } 594 break; 595 case 'title': 596 $retval = stripslashes ($A['title']); 597 if (empty ($retval)) { 598 $retval = '(' . $A['name'] . ')'; 599 } 600 break; 601 case 'blockorder': 602 $retval .= $A['blockorder']; 603 break; 604 case 'is_enabled': 605 if ($access == 3) { 606 if ($A['is_enabled'] == 1) { 607 $switch = 'checked="checked"'; 608 } else { 609 $switch = ''; 610 } 611 $retval = "<form action=\"{$_CONF['site_admin_url']}/block.php\" method=\"post\">" 612 ."<input type=\"checkbox\" name=\"blkenable\" onclick=\"submit()\" value=\"{$A['bid']}\" $switch>" 613 ."<input type=\"hidden\" name=\"blkChange\" value=\"{$A['bid']}\"></form>"; 614 } 615 break; 616 case 'move': 617 if ($access == 3) { 618 if ($A['onleft'] == 1) { 619 $side = $LANG21[40]; 620 $blockcontrol_image = 'block-right.' . $_IMAGE_TYPE; 621 $moveTitleMsg = $LANG21[59]; 622 $switchside = '1'; 623 } else { 624 $blockcontrol_image = 'block-left.' . $_IMAGE_TYPE; 625 $moveTitleMsg = $LANG21[60]; 626 $switchside = '0'; 627 } 628 $retval.="<img src=\"{$_CONF['layout_url']}/images/admin/$blockcontrol_image\" width=\"45\" height=\"20\" border=\"0\" usemap=\"#arrow{$A['bid']}\" alt=\"\">" 629 ."<map name=\"arrow{$A['bid']}\">" 630 ."<area coords=\"0,0,12,20\" title=\"{$LANG21[58]}\" href=\"{$_CONF['site_admin_url']}/block.php?mode=move&bid={$A['bid']}&where=up\" alt=\"{$LANG21[58]}\">" 631 ."<area coords=\"13,0,29,20\" title=\"$moveTitleMsg\" href=\"{$_CONF['site_admin_url']}/block.php?mode=move&bid={$A['bid']}&where=$switchside\" alt=\"$moveTitleMsg\">" 632 ."<area coords=\"30,0,43,20\" title=\"{$LANG21[57]}\" href=\"{$_CONF['site_admin_url']}/block.php?mode=move&bid={$A['bid']}&where=dn\" alt=\"{$LANG21[57]}\">" 633 ."</map>"; 634 } 635 break; 636 default: 637 $retval = $fieldvalue; 638 break; 639 } 640 } 641 return $retval; 642 } 643 644 function ADMIN_getListField_groups($fieldname, $fieldvalue, $A, $icon_arr) 645 { 646 global $_CONF, $LANG_ACCESS, $LANG_ADMIN, $thisUsersGroups; 647 648 $retval = false; 649 650 if( !is_array($thisUsersGroups) ) 651 { 652 $thisUsersGroups = SEC_getUserGroups(); 653 } 654 655 // Extra test required to handle that different ways this option is passed and need to be able to 656 // over-ride the option using the posted form when the URL contains the variable as well 657 $show_all_groups = false; 658 if (isset($_POST['q'])) { // Form has been posted - test actual option in this form 659 if ($_POST['chk_showall'] == 1) { 660 $show_all_groups = true; 661 } 662 } else if (isset ($_GET['showall']) && ($_GET['showall'] == 1)) { 663 $show_all_groups = true; 664 } 665 666 if (in_array ($A['grp_id'], $thisUsersGroups ) || 667 SEC_groupIsRemoteUserAndHaveAccess( $A['grp_id'], $thisUsersGroups )) { 668 switch($fieldname) { 669 case 'edit': 670 if ($show_all_groups) { 671 $retval = "<a href=\"{$_CONF['site_admin_url']}/group.php?mode=edit&grp_id={$A['grp_id']}&chk_showall=1\">{$icon_arr['edit']}</a>"; 672 } else { 673 $retval = "<a href=\"{$_CONF['site_admin_url']}/group.php?mode=edit&grp_id={$A['grp_id']}\">{$icon_arr['edit']}</a>"; 674 } 675 break; 676 case 'grp_gl_core': 677 if ($A['grp_gl_core'] == 1) { 678 $retval = $LANG_ACCESS['yes']; 679 } else { 680 $retval = $LANG_ACCESS['no']; 681 } 682 break; 683 case 'list': 684 if ($show_all_groups) { 685 $retval = "<a href=\"{$_CONF['site_admin_url']}/group.php?mode=listusers&grp_id={$A['grp_id']}&chk_showall=1\">" 686 ."{$icon_arr['list']}</a> " 687 ."<a href=\"{$_CONF['site_admin_url']}/group.php?mode=editusers&grp_id={$A['grp_id']}&chk_showall=1\">" 688 ."{$icon_arr['edit']}</a>"; 689 } else { 690 $retval = "<a href=\"{$_CONF['site_admin_url']}/group.php?mode=listusers&grp_id={$A['grp_id']}\">" 691 ."{$icon_arr['list']}</a> " 692 ."<a href=\"{$_CONF['site_admin_url']}/group.php?mode=editusers&grp_id={$A['grp_id']}\">" 693 ."{$icon_arr['edit']}</a>"; 694 } 695 break; 696 default: 697 $retval = $fieldvalue; 698 break; 699 } 700 } 701 702 return $retval; 703 } 704 705 function ADMIN_getListField_users($fieldname, $fieldvalue, $A, $icon_arr) 706 { 707 global $_CONF, $_TABLES, $LANG_ADMIN, $LANG04, $LANG28, $_IMAGE_TYPE; 708 709 $retval = ''; 710 711 switch ($fieldname) { 712 case 'delete': 713 $retval = '<input type="checkbox" name="delitem[]" checked="checked">'; 714 break; 715 case 'edit': 716 $retval = "<a href=\"{$_CONF['site_admin_url']}/user.php?mode=edit&uid={$A['uid']}\">{$icon_arr['edit']}</a>"; 717 break; 718 case 'username': 719 $photoico = ''; 720 if (!empty ($A['photo'])) { 721 $photoico = " <img src=\"{$_CONF['layout_url']}/images/smallcamera." 722 . $_IMAGE_TYPE . '" border="0" alt="{$LANG04[77]}">'; 723 } else { 724 $photoico = ''; 725 } 726 $retval = '<a href="' . $_CONF['site_url'] 727 . '/users.php?mode=profile&uid=' . $A['uid'] . '">' 728 . $fieldvalue . '</a>' . $photoico; 729 break; 730 case 'lastlogin': 731 if ($fieldvalue < 1) { 732 // if the user never logged in, show the registration date 733 $regdate = strftime ($_CONF['shortdate'], strtotime($A['regdate'])); 734 $retval = "({$LANG28[36]}, {$LANG28[53]} $regdate)"; 735 } else { 736 $retval = strftime ($_CONF['shortdate'], $fieldvalue); 737 } 738 break; 739 case 'lastlogin_short': 740 if ($fieldvalue < 1) { 741 // if the user never logged in, show the registration date 742 $regdate = strftime ($_CONF['shortdate'], strtotime($A['regdate'])); 743 $retval = "({$LANG28[36]})"; 744 } else { 745 $retval = strftime ($_CONF['shortdate'], $fieldvalue); 746 } 747 break; 748 case 'online_days': 749 if ($fieldvalue < 0){ 750 // users that never logged in, would have a negative online days 751 $retval = "N/A"; 752 } else { 753 $retval = $fieldvalue; 754 } 755 break; 756 case 'phantom_date': 757 case 'offline_months': 758 $retval = COM_numberFormat(round($fieldvalue / 2592000, 1)); 759 break; 760 case 'online_hours': 761 $retval = COM_numberFormat(round($fieldvalue / 3600, 3)); 762 break; 763 case 'regdate': 764 $retval = strftime ($_CONF['shortdate'], strtotime($fieldvalue)); 765 break; 766 case $_TABLES['users'] . '.uid': 767 $retval = $A['uid']; 768 break; 769 default: 770 $retval = $fieldvalue; 771 break; 772 } 773 774 if (isset($A['status']) && ($A['status'] == USER_ACCOUNT_DISABLED)) { 775 if (($fieldname != 'edit') && ($fieldname != 'username')) { 776 $retval = sprintf ('<s title="%s">%s</s>', $LANG28[42], $retval); 777 } 778 } 779 780 return $retval; 781 } 782 783 function ADMIN_getListField_stories($fieldname, $fieldvalue, $A, $icon_arr) 784 { 785 global $_CONF, $_TABLES, $LANG_ADMIN, $LANG24, $LANG_ACCESS, $_IMAGE_TYPE; 786 787 static $topics; 788 789 if (!isset ($topics)) { 790 $topics = array (); 791 } 792 793 $retval = ''; 794 795 switch($fieldname) { 796 case "unixdate": 797 $curtime = COM_getUserDateTimeFormat ($A['unixdate']); 798 $retval = strftime($_CONF['daytime'], $curtime[1]); 799 break; 800 case "title": 801 $A['title'] = str_replace('$', '$', $A['title']); 802 $article_url = COM_buildUrl ($_CONF['site_url'] . '/article.php?story=' 803 . $A['sid']); 804 $retval = "<a href=\"$article_url\">" . stripslashes($A['title']) . "</a>"; 805 break; 806 case "draft_flag": 807 if ($A['draft_flag'] == 1) { 808 $retval = $LANG24[35]; 809 } else { 810 $retval = $LANG24[36]; 811 } 812 break; 813 case "access": 814 case "edit": 815 case "edit_adv": 816 $access = SEC_hasAccess ($A['owner_id'], $A['group_id'], 817 $A['perm_owner'], $A['perm_group'], 818 $A['perm_members'], $A['perm_anon']); 819 if ($access == 3) { 820 if (SEC_hasTopicAccess ($A['tid']) == 3) { 821 $access = $LANG_ACCESS['edit']; 822 } else { 823 $access = $LANG_ACCESS['readonly']; 824 } 825 } else { 826 $access = $LANG_ACCESS['readonly']; 827 } 828 if ($fieldname == 'access') { 829 $retval = $access; 830 } else if ($access == $LANG_ACCESS['edit']) { 831 if ($fieldname == 'edit_adv') { 832 $retval = "<a href=\"{$_CONF['site_admin_url']}/story.php?mode=edit&editor=adv&sid={$A['sid']}\">{$icon_arr['edit']}</a>"; 833 } else if ($fieldname == 'edit') { 834 $retval = "<a href=\"{$_CONF['site_admin_url']}/story.php?mode=edit&editor=std&sid={$A['sid']}\">{$icon_arr['edit']}</a>"; 835 } 836 } 837 break; 838 case "featured": 839 if ($A['featured'] == 1) { 840 $retval = $LANG24[35]; 841 } else { 842 $retval = $LANG24[36]; 843 } 844 break; 845 case "ping": 846 $pingico = '<img src="' . $_CONF['layout_url'] . '/images/sendping.' 847 . $_IMAGE_TYPE . '" border="0" alt="' . $LANG24[21] . '" title="' 848 . $LANG24[21] . '">'; 849 if (($A['draft_flag'] == 0) && ($A['unixdate'] < time())) { 850 $url = $_CONF['site_admin_url'] 851 . '/trackback.php?mode=sendall&id=' . $A['sid']; 852 $retval = '<a href="' . $url . '">' . $pingico . '</a>'; 853 } else { 854 $retval = ''; 855 } 856 break; 857 case 'tid': 858 if (!isset ($topics[$A['tid']])) { 859 $topics[$A['tid']] = DB_getItem ($_TABLES['topics'], 'topic', 860 "tid = '{$A['tid']}'"); 861 } 862 $retval = $topics[$A['tid']]; 863 break; 864 case 'username': 865 $retval = COM_getDisplayName ($A['uid'], $A['username'], $A['fullname']); 866 break; 867 default: 868 $retval = $fieldvalue; 869 break; 870 } 871 872 return $retval; 873 } 874 875 function ADMIN_getListField_syndication($fieldname, $fieldvalue, $A, $icon_arr) { 876 global $_CONF, $_TABLES, $LANG_ADMIN, $LANG33, $_IMAGE_TYPE; 877 878 $retval = ''; 879 880 switch($fieldname) { 881 case "edit": 882 $retval = "<a href=\"{$_CONF['site_admin_url']}/syndication.php?mode=edit&fid={$A['fid']}\">{$icon_arr['edit']}</a>"; 883 break; 884 case 'type': 885 $retval = ucwords($A['type']); 886 break; 887 case 'format': 888 $retval = str_replace ('-' , ' ', ucwords ($A['format'])); 889 break; 890 case 'updated': 891 $retval = strftime ($_CONF['daytime'], $A['date']); 892 break; 893 case 'is_enabled': 894 if ($A['is_enabled'] == 1) { 895 $switch = 'checked="checked"'; 896 } else { 897 $switch = ''; 898 } 899 $retval = "<form action=\"{$_CONF['site_admin_url']}/syndication.php\" method=\"POST\">" 900 ."<input type=\"checkbox\" name=\"feedenable\" onclick=\"submit()\" value=\"{$A['fid']}\" $switch>" 901 ."<input type=\"hidden\" name=\"feedChange\" value=\"{$A['fid']}\"></form>"; 902 break; 903 case 'header_tid': 904 if ($A['header_tid'] == 'all') { 905 $retval = $LANG33[43]; 906 } elseif ($A['header_tid'] == 'none') { 907 $retval = $LANG33[44]; 908 } else { 909 $retval = DB_getItem ($_TABLES['topics'], 'topic', 910 "tid = '{$A['header_tid']}'"); 911 } 912 break; 913 case 'filename': 914 $url = SYND_getFeedUrl (); 915 $retval = '<a href="' . $url . $A['filename'] . '">' . $A['filename'] . '</a>'; 916 break; 917 default: 918 $retval = $fieldvalue; 919 break; 920 } 921 return $retval; 922 } 923 924 function ADMIN_getListField_plugins($fieldname, $fieldvalue, $A, $icon_arr) { 925 global $_CONF, $LANG_ADMIN, $LANG32; 926 $retval = ''; 927 928 switch($fieldname) { 929 case "edit": 930 $retval = "<a href=\"{$_CONF['site_admin_url']}/plugins.php?mode=edit&pi_name={$A['pi_name']}\">{$icon_arr['edit']}</a>"; 931 break; 932 case 'pi_version': 933 $plugin_code_version = PLG_chkVersion ($A['pi_name']); 934 if (empty ($plugin_code_version)) { 935 $code_version = 'N/A'; 936 } else { 937 $code_version = $plugin_code_version; 938 } 939 $pi_installed_version = $A['pi_version']; 940 if (empty ($plugin_code_version) || 941 ($pi_installed_version == $code_version)) { 942 $retval = $pi_installed_version; 943 } else { 944 $retval = "{$LANG32[37]}: $pi_installed_version, {$LANG32[36]}: $plugin_code_version"; 945 if ($A['pi_enabled'] == 1) { 946 $retval .= " <b>{$LANG32[38]}</b>"; 947 } 948 } 949 break; 950 case 'enabled': 951 if ($A['pi_enabled'] == 1) { 952 $switch = 'checked="checked"'; 953 } else { 954 $switch = ''; 955 } 956 $retval = "<form action=\"{$_CONF['site_admin_url']}/plugins.php\" method=\"post\">" 957 ."<input type=\"checkbox\" name=\"pluginenable\" onclick=\"submit()\" value=\"{$A['pi_name']}\" $switch>" 958 ."<input type=\"hidden\" name=\"pluginChange\" value=\"{$A['pi_name']}\">" 959 ."</form>"; 960 break; 961 default: 962 $retval = $fieldvalue; 963 break; 964 } 965 return $retval; 966 } 967 968 function ADMIN_getListField_moderation($fieldname, $fieldvalue, $A, $icon_arr) 969 { 970 global $_CONF, $_TABLES, $LANG_ADMIN; 971 972 $retval = ''; 973 974 $type = ''; 975 if (isset ($A['_moderation_type'])) { 976 $type = $A['_moderation_type']; 977 } 978 switch ($fieldname) { 979 case 'edit': 980 $retval = "<a href=\"{$A['edit']}\">{$icon_arr['edit']}</a>"; 981 break; 982 case 'delete': 983 $retval = "<input type=\"radio\" name=\"action[{$A['row']}]\" value=\"delete\">"; 984 break; 985 case 'approve': 986 $retval = "<input type=\"radio\" name=\"action[{$A['row']}]\" value=\"approve\">" 987 ."<input type=\"hidden\" name=\"id[{$A['row']}]\" value=\"{$A[0]}\">"; 988 break; 989 case 'day': 990 $retval = strftime ($_CONF['daytime'], $A['day']); 991 break; 992 case 'tid': 993 $retval = DB_getItem ($_TABLES['topics'], 'topic', 994 "tid = '{$A['tid']}'"); 995 break; 996 default: 997 if (($fieldname == 3) && ($type == 'story')) { 998 $retval = DB_getItem ($_TABLES['topics'], 'topic', 999 "tid = '{$A[3]}'"); 1000 } else { 1001 $retval = COM_makeClickableLinks (stripslashes ($fieldvalue)); 1002 } 1003 break; 1004 } 1005 1006 return $retval; 1007 } 1008 1009 function ADMIN_getListField_trackback($fieldname, $fieldvalue, $A, $icon_arr) 1010 { 1011 global $_CONF, $LANG_TRB; 1012 1013 $retval = ''; 1014 1015 switch($fieldname) { 1016 case "edit": 1017 $retval = "<a href=\"{$_CONF['site_admin_url']}/trackback.php?mode=editservice&service_id={$A['pid']}\">{$icon_arr['edit']}</a>"; 1018 break; 1019 case "name": 1020 $retval = "<a href=\"{$A['site_url']}\">{$A['name']}</a>"; 1021 break; 1022 case "method": 1023 if ($A['method'] == 'weblogUpdates.ping') { 1024 $retval = $LANG_TRB['ping_standard']; 1025 } else if ($A['method'] == 'weblogUpdates.extendedPing') { 1026 $retval = $LANG_TRB['ping_extended']; 1027 } else { 1028 $retval = '<span class="warningsmall">' . 1029 $LANG_TRB['ping_unknown'] . '</span>'; 1030 } 1031 break; 1032 case "is_enabled": 1033 if ($A['is_enabled'] == 1) { 1034 $switch = 'checked="checked"'; 1035 } else { 1036 $switch = ''; 1037 } 1038 $retval = "<form action=\"{$_CONF['site_admin_url']}/trackback.php\" method=\"POST\">" 1039 ."<input type=\"checkbox\" name=\"serviceenable\" onclick=\"submit()\" value=\"{$A['pid']}\" $switch>" 1040 ."<input type=\"hidden\" name=\"serviceChange\" value=\"{$A['pid']}\">" 1041 ."</form>"; 1042 break; 1043 default: 1044 $retval = $fieldvalue; 1045 break; 1046 } 1047 1048 return $retval; 1049 } 1050 1051 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 12:27:40 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |