Ignore:
Timestamp:
Mar 31, 2010, 6:32:40 PM (14 years ago)
Author:
george
Message:
  • Upraveno: Aktualizace fóra.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/forum/includes/acp/acp_icons.php

    r400 r702  
    33*
    44* @package acp
    5 * @version $Id: acp_icons.php 8974 2008-10-06 13:23:41Z acydburn $
     5* @version $Id$
    66* @copyright (c) 2005 phpBB Group
    77* @license http://opensource.org/licenses/gpl-license.php GNU Public License
     
    9090                                        }
    9191
     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
    92107                                        $_images[$path . $img]['file'] = $path . $img;
    93108                                        $_images[$path . $img]['width'] = $img_size[0];
     
    169184                                        }
    170185                                }
    171                                
     186
    172187                                $sql = "SELECT *
    173188                                        FROM $table
    174189                                        ORDER BY {$fields}_order " . (($icon_id || $action == 'add') ? 'DESC' : 'ASC');
    175190                                $result = $db->sql_query($sql);
    176                                
     191
    177192                                $data = array();
    178193                                $after = false;
     
    181196                                $add_order_lists = array('', '');
    182197                                $display_count = 0;
    183                                
     198
    184199                                while ($row = $db->sql_fetchrow($result))
    185200                                {
     
    232247                                }
    233248
    234                                 $colspan = (($mode == 'smilies') ? '7' : '5');
     249                                $colspan = (($mode == 'smilies') ? 7 : 5);
    235250                                $colspan += ($icon_id) ? 1 : 0;
    236251                                $colspan += ($action == 'add') ? 2 : 0;
    237                                
     252
    238253                                $template->assign_vars(array(
    239254                                        'S_EDIT'                => true,
    240255                                        'S_SMILIES'             => ($mode == 'smilies') ? true : false,
    241256                                        'S_ADD'                 => ($action == 'add') ? true : false,
    242                                        
     257
    243258                                        'S_ORDER_LIST_DISPLAY'          => $order_list . $order_lists[1],
    244259                                        'S_ORDER_LIST_UNDISPLAY'        => $order_list . $order_lists[0],
     
    287302
    288303                                                'S_IMG_OPTIONS'         => $smiley_options,
    289                                                
     304
    290305                                                'S_ADD_ORDER_LIST_DISPLAY'              => $add_order_list . $add_order_lists[1],
    291306                                                'S_ADD_ORDER_LIST_UNDISPLAY'    => $add_order_list . $add_order_lists[0],
    292                                                
     307
    293308                                                'IMG_SRC'                       => $phpbb_root_path . $img_path . '/' . $default_row['smiley_url'],
    294309                                                'IMG_PATH'                      => $img_path,
     
    304319
    305320                                return;
    306        
     321
    307322                        break;
    308323
     
    312327                                // Get items to create/modify
    313328                                $images = (isset($_POST['image'])) ? array_keys(request_var('image', array('' => 0))) : array();
    314                                
     329
    315330                                // Now really get the items
    316331                                $image_id               = (isset($_POST['id'])) ? request_var('id', array('' => 0)) : array();
     
    349364                                }
    350365
     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
    351385                                $icons_updated = 0;
    352386                                $errors = array();
     
    368402                                                        $image_width[$image] = $img_size[0];
    369403                                                        $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                                                        }
    370419                                                }
    371420
     
    427476                                                        $icons_updated++;
    428477                                                }
    429                                                
     478
    430479                                        }
    431480                                }
    432                                
     481
    433482                                $cache->destroy('_icons');
    434483                                $cache->destroy('sql', $table);
    435                                
     484
    436485                                $level = E_USER_NOTICE;
    437486                                switch ($icons_updated)
     
    441490                                                $level = E_USER_WARNING;
    442491                                                break;
    443                                                
     492
    444493                                        case 1:
    445494                                                $suc_lang = "{$lang}_ONE";
    446495                                                break;
    447                                                
     496
    448497                                        default:
    449498                                                $suc_lang = $lang;
     
    496545                                        }
    497546
    498 
    499547                                        // The user has already selected a smilies_pak file
    500548                                        if ($current == 'delete')
     
    540588                                                }
    541589                                                $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                                                }
    542599                                        }
    543600
     
    836893
    837894                $spacer = false;
     895                $pagination_start = request_var('start', 0);
     896
     897                $item_count = $this->item_count($table);
    838898
    839899                $sql = "SELECT *
    840900                        FROM $table
    841901                        ORDER BY {$fields}_order ASC";
    842                 $result = $db->sql_query($sql);
     902                $result = $db->sql_query_limit($sql, $config['smilies_per_page'], $pagination_start);
    843903
    844904                while ($row = $db->sql_fetchrow($result))
     
    856916                                'U_EDIT'                => $this->u_action . '&action=edit&id=' . $row[$fields . '_id'],
    857917                                '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                        ));
    861921
    862922                        if (!$spacer && !$row['display_on_posting'])
     
    866926                }
    867927                $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;
    868951        }
    869952}
Note: See TracChangeset for help on using the changeset viewer.