Changeset 702 for trunk/forum/includes/acp/acp_icons.php
- Timestamp:
- Mar 31, 2010, 6:32:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/forum/includes/acp/acp_icons.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_icons.php 8974 2008-10-06 13:23:41Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 90 90 } 91 91 92 // adjust the width and height to be lower than 128px while perserving the aspect ratio (for icons) 93 if ($mode == 'icons') 94 { 95 if ($img_size[0] > 127 && $img_size[0] > $img_size[1]) 96 { 97 $img_size[1] = (int) ($img_size[1] * (127 / $img_size[0])); 98 $img_size[0] = 127; 99 } 100 else if ($img_size[1] > 127) 101 { 102 $img_size[0] = (int) ($img_size[0] * (127 / $img_size[1])); 103 $img_size[1] = 127; 104 } 105 } 106 92 107 $_images[$path . $img]['file'] = $path . $img; 93 108 $_images[$path . $img]['width'] = $img_size[0]; … … 169 184 } 170 185 } 171 186 172 187 $sql = "SELECT * 173 188 FROM $table 174 189 ORDER BY {$fields}_order " . (($icon_id || $action == 'add') ? 'DESC' : 'ASC'); 175 190 $result = $db->sql_query($sql); 176 191 177 192 $data = array(); 178 193 $after = false; … … 181 196 $add_order_lists = array('', ''); 182 197 $display_count = 0; 183 198 184 199 while ($row = $db->sql_fetchrow($result)) 185 200 { … … 232 247 } 233 248 234 $colspan = (($mode == 'smilies') ? '7' : '5');249 $colspan = (($mode == 'smilies') ? 7 : 5); 235 250 $colspan += ($icon_id) ? 1 : 0; 236 251 $colspan += ($action == 'add') ? 2 : 0; 237 252 238 253 $template->assign_vars(array( 239 254 'S_EDIT' => true, 240 255 'S_SMILIES' => ($mode == 'smilies') ? true : false, 241 256 'S_ADD' => ($action == 'add') ? true : false, 242 257 243 258 'S_ORDER_LIST_DISPLAY' => $order_list . $order_lists[1], 244 259 'S_ORDER_LIST_UNDISPLAY' => $order_list . $order_lists[0], … … 287 302 288 303 'S_IMG_OPTIONS' => $smiley_options, 289 304 290 305 'S_ADD_ORDER_LIST_DISPLAY' => $add_order_list . $add_order_lists[1], 291 306 'S_ADD_ORDER_LIST_UNDISPLAY' => $add_order_list . $add_order_lists[0], 292 307 293 308 'IMG_SRC' => $phpbb_root_path . $img_path . '/' . $default_row['smiley_url'], 294 309 'IMG_PATH' => $img_path, … … 304 319 305 320 return; 306 321 307 322 break; 308 323 … … 312 327 // Get items to create/modify 313 328 $images = (isset($_POST['image'])) ? array_keys(request_var('image', array('' => 0))) : array(); 314 329 315 330 // Now really get the items 316 331 $image_id = (isset($_POST['id'])) ? request_var('id', array('' => 0)) : array(); … … 349 364 } 350 365 366 if ($mode == 'smilies' && $action == 'create') 367 { 368 $smiley_count = $this->item_count($table); 369 370 $addable_smileys_count = sizeof($images); 371 foreach ($images as $image) 372 { 373 if (!isset($image_add[$image])) 374 { 375 --$addable_smileys_count; 376 } 377 } 378 379 if ($smiley_count + $addable_smileys_count > SMILEY_LIMIT) 380 { 381 trigger_error(sprintf($user->lang['TOO_MANY_SMILIES'], SMILEY_LIMIT) . adm_back_link($this->u_action), E_USER_WARNING); 382 } 383 } 384 351 385 $icons_updated = 0; 352 386 $errors = array(); … … 368 402 $image_width[$image] = $img_size[0]; 369 403 $image_height[$image] = $img_size[1]; 404 } 405 406 // Adjust image width/height for icons 407 if ($mode == 'icons') 408 { 409 if ($image_width[$image] > 127 && $image_width[$image] > $image_height[$image]) 410 { 411 $image_height[$image] = (int) ($image_height[$image] * (127 / $image_width[$image])); 412 $image_width[$image] = 127; 413 } 414 else if ($image_height[$image] > 127) 415 { 416 $image_width[$image] = (int) ($image_width[$image] * (127 / $image_height[$image])); 417 $image_height[$image] = 127; 418 } 370 419 } 371 420 … … 427 476 $icons_updated++; 428 477 } 429 478 430 479 } 431 480 } 432 481 433 482 $cache->destroy('_icons'); 434 483 $cache->destroy('sql', $table); 435 484 436 485 $level = E_USER_NOTICE; 437 486 switch ($icons_updated) … … 441 490 $level = E_USER_WARNING; 442 491 break; 443 492 444 493 case 1: 445 494 $suc_lang = "{$lang}_ONE"; 446 495 break; 447 496 448 497 default: 449 498 $suc_lang = $lang; … … 496 545 } 497 546 498 499 547 // The user has already selected a smilies_pak file 500 548 if ($current == 'delete') … … 540 588 } 541 589 $db->sql_freeresult($result); 590 } 591 592 if ($mode == 'smilies') 593 { 594 $smiley_count = $this->item_count($table); 595 if ($smiley_count + sizeof($pak_ary) > SMILEY_LIMIT) 596 { 597 trigger_error(sprintf($user->lang['TOO_MANY_SMILIES'], SMILEY_LIMIT) . adm_back_link($this->u_action), E_USER_WARNING); 598 } 542 599 } 543 600 … … 836 893 837 894 $spacer = false; 895 $pagination_start = request_var('start', 0); 896 897 $item_count = $this->item_count($table); 838 898 839 899 $sql = "SELECT * 840 900 FROM $table 841 901 ORDER BY {$fields}_order ASC"; 842 $result = $db->sql_query ($sql);902 $result = $db->sql_query_limit($sql, $config['smilies_per_page'], $pagination_start); 843 903 844 904 while ($row = $db->sql_fetchrow($result)) … … 856 916 'U_EDIT' => $this->u_action . '&action=edit&id=' . $row[$fields . '_id'], 857 917 'U_DELETE' => $this->u_action . '&action=delete&id=' . $row[$fields . '_id'], 858 'U_MOVE_UP' => $this->u_action . '&action=move_up&id=' . $row[$fields . '_id'] ,859 'U_MOVE_DOWN' => $this->u_action . '&action=move_down&id=' . $row[$fields . '_id'] )860 ) ;918 'U_MOVE_UP' => $this->u_action . '&action=move_up&id=' . $row[$fields . '_id'] . '&start=' . $pagination_start, 919 'U_MOVE_DOWN' => $this->u_action . '&action=move_down&id=' . $row[$fields . '_id'] . '&start=' . $pagination_start, 920 )); 861 921 862 922 if (!$spacer && !$row['display_on_posting']) … … 866 926 } 867 927 $db->sql_freeresult($result); 928 929 $template->assign_var('PAGINATION', 930 generate_pagination($this->u_action, $item_count, $config['smilies_per_page'], $pagination_start, true) 931 ); 932 } 933 934 /** 935 * Returns the count of smilies or icons in the database 936 * 937 * @param string $table The table of items to count. 938 * @return int number of items 939 */ 940 /* private */ function item_count($table) 941 { 942 global $db; 943 944 $sql = "SELECT COUNT(*) AS item_count 945 FROM $table"; 946 $result = $db->sql_query($sql); 947 $item_count = (int) $db->sql_fetchfield('item_count'); 948 $db->sql_freeresult($result); 949 950 return $item_count; 868 951 } 869 952 }
Note:
See TracChangeset
for help on using the changeset viewer.