6 * @copyright (c) 2005 phpBB Group
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 if (!defined('IN_PHPBB'))
20 * @todo [smilies] check regular expressions for special char replacements (stored specialchared in db)
27 function main($id, $mode)
29 global $db, $user, $auth, $template, $cache;
30 global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
32 $user->add_lang('acp/posting');
34 // Set up general vars
35 $action = request_var('action', '');
36 $action = (isset($_POST['add'])) ? 'add' : $action;
37 $action = (isset($_POST['edit'])) ? 'edit' : $action;
38 $action = (isset($_POST['import'])) ? 'import' : $action;
39 $icon_id = request_var('id', 0);
41 $mode = ($mode == 'smilies') ? 'smilies' : 'icons';
43 $this->tpl_name = 'acp_icons';
45 // What are we working on?
49 $table = SMILIES_TABLE;
52 $img_path = $config['smilies_path'];
59 $img_path = $config['icons_path'];
63 $this->page_title = 'ACP_' . $lang;
66 $_images = $_paks = array();
69 // Grab file list of paks and images
70 if ($action == 'edit' || $action == 'add' || $action == 'import')
72 $imglist = filelist($phpbb_root_path . $img_path, '');
74 foreach ($imglist as $path => $img_ary)
81 asort($img_ary, SORT_STRING);
83 foreach ($img_ary as $img)
85 $img_size = getimagesize($phpbb_root_path . $img_path . '/' . $path . $img);
87 if (!$img_size[0] || !$img_size[1] || strlen($img) > 255)
92 // adjust the width and height to be lower than 128px while perserving the aspect ratio (for icons)
95 if ($img_size[0] > 127 && $img_size[0] > $img_size[1])
97 $img_size[1] = (int) ($img_size[1] * (127 / $img_size[0]));
100 else if ($img_size[1] > 127)
102 $img_size[0] = (int) ($img_size[0] * (127 / $img_size[1]));
107 $_images[$path . $img]['file'] = $path . $img;
108 $_images[$path . $img]['width'] = $img_size[0];
109 $_images[$path . $img]['height'] = $img_size[1];
114 if ($dir = @opendir($phpbb_root_path . $img_path))
116 while (($file = readdir($dir)) !== false)
118 if (is_file($phpbb_root_path . $img_path . '/' . $file) && preg_match('#\.pak$#i', $file))
127 asort($_paks, SORT_STRING);
132 // What shall we do today? Oops, I believe that's trademarked ...
143 $smilies = $default_row = array();
144 $smiley_options = $order_list = $add_order_list = '';
146 if ($action == 'add' && $mode == 'smilies')
149 FROM ' . SMILIES_TABLE . '
150 ORDER BY smiley_order';
151 $result = $db->sql_query($sql);
153 while ($row = $db->sql_fetchrow($result))
155 if (empty($smilies[$row['smiley_url']]))
157 $smilies[$row['smiley_url']] = $row;
160 $db->sql_freeresult($result);
162 if (sizeof($smilies))
164 foreach ($smilies as $row)
168 if (!$smiley_options)
173 $smiley_options .= '<option value="' . $row['smiley_url'] . '"' . (($selected) ? ' selected="selected"' : '') . '>' . $row['smiley_url'] . '</option>';
175 $template->assign_block_vars('smile', array(
176 'SMILEY_URL' => addslashes($row['smiley_url']),
177 'CODE' => addslashes($row['code']),
178 'EMOTION' => addslashes($row['emotion']),
179 'WIDTH' => $row['smiley_width'],
180 'HEIGHT' => $row['smiley_height'],
181 'ORDER' => $row['smiley_order'] + 1,
189 ORDER BY {$fields}_order " . (($icon_id || $action == 'add') ? 'DESC' : 'ASC');
190 $result = $db->sql_query($sql);
195 $order_lists = array('', '');
196 $add_order_lists = array('', '');
199 while ($row = $db->sql_fetchrow($result))
201 if ($action == 'add')
203 unset($_images[$row[$fields . '_url']]);
207 if ($row[$fields . '_id'] == $icon_id)
210 $display = $row['display_on_posting'];
211 $data[$row[$fields . '_url']] = $row;
215 if ($action == 'edit' && !$icon_id)
217 $data[$row[$fields . '_url']] = $row;
223 $selected = ' selected="selected"';
226 if ($row['display_on_posting'])
230 $after_txt = ($mode == 'smilies') ? $row['code'] : $row['icons_url'];
231 $order_lists[$row['display_on_posting']] = '<option value="' . ($row[$fields . '_order'] + 1) . '"' . $selected . '>' . sprintf($user->lang['AFTER_' . $lang], ' -> ' . $after_txt) . '</option>' . $order_lists[$row['display_on_posting']];
233 if (!empty($default_row))
235 $add_order_lists[$row['display_on_posting']] = '<option value="' . ($row[$fields . '_order'] + 1) . '"' . (($row[$fields . '_id'] == $default_row['smiley_id']) ? ' selected="selected"' : '') . '>' . sprintf($user->lang['AFTER_' . $lang], ' -> ' . $after_txt) . '</option>' . $add_order_lists[$row['display_on_posting']];
239 $db->sql_freeresult($result);
241 $order_list = '<option value="1"' . ((!isset($after)) ? ' selected="selected"' : '') . '>' . $user->lang['FIRST'] . '</option>';
242 $add_order_list = '<option value="1">' . $user->lang['FIRST'] . '</option>';
244 if ($action == 'add')
249 $colspan = (($mode == 'smilies') ? 7 : 5);
250 $colspan += ($icon_id) ? 1 : 0;
251 $colspan += ($action == 'add') ? 2 : 0;
253 $template->assign_vars(array(
255 'S_SMILIES' => ($mode == 'smilies') ? true : false,
256 'S_ADD' => ($action == 'add') ? true : false,
258 'S_ORDER_LIST_DISPLAY' => $order_list . $order_lists[1],
259 'S_ORDER_LIST_UNDISPLAY' => $order_list . $order_lists[0],
260 'S_ORDER_LIST_DISPLAY_COUNT' => $display_count + 1,
262 'L_TITLE' => $user->lang['ACP_' . $lang],
263 'L_EXPLAIN' => $user->lang['ACP_' . $lang . '_EXPLAIN'],
264 'L_CONFIG' => $user->lang[$lang . '_CONFIG'],
265 'L_URL' => $user->lang[$lang . '_URL'],
266 'L_LOCATION' => $user->lang[$lang . '_LOCATION'],
267 'L_WIDTH' => $user->lang[$lang . '_WIDTH'],
268 'L_HEIGHT' => $user->lang[$lang . '_HEIGHT'],
269 'L_ORDER' => $user->lang[$lang . '_ORDER'],
270 'L_NO_ICONS' => $user->lang['NO_' . $lang . '_' . strtoupper($action)],
272 'COLSPAN' => $colspan,
275 'U_BACK' => $this->u_action,
276 'U_ACTION' => $this->u_action . '&action=' . (($action == 'add') ? 'create' : 'modify'),
279 foreach ($data as $img => $img_row)
281 $template->assign_block_vars('items', array(
283 'A_IMG' => addslashes($img),
284 'IMG_SRC' => $phpbb_root_path . $img_path . '/' . $img,
286 'CODE' => ($mode == 'smilies' && isset($img_row['code'])) ? $img_row['code'] : '',
287 'EMOTION' => ($mode == 'smilies' && isset($img_row['emotion'])) ? $img_row['emotion'] : '',
289 'S_ID' => (isset($img_row[$fields . '_id'])) ? true : false,
290 'ID' => (isset($img_row[$fields . '_id'])) ? $img_row[$fields . '_id'] : 0,
291 'WIDTH' => (!empty($img_row[$fields .'_width'])) ? $img_row[$fields .'_width'] : $img_row['width'],
292 'HEIGHT' => (!empty($img_row[$fields .'_height'])) ? $img_row[$fields .'_height'] : $img_row['height'],
293 'POSTING_CHECKED' => (!empty($img_row['display_on_posting']) || $action == 'add') ? ' checked="checked"' : '',
297 // Ok, another row for adding an addition code for a pre-existing image...
298 if ($action == 'add' && $mode == 'smilies' && sizeof($smilies))
300 $template->assign_vars(array(
301 'S_ADD_CODE' => true,
303 'S_IMG_OPTIONS' => $smiley_options,
305 'S_ADD_ORDER_LIST_DISPLAY' => $add_order_list . $add_order_lists[1],
306 'S_ADD_ORDER_LIST_UNDISPLAY' => $add_order_list . $add_order_lists[0],
308 'IMG_SRC' => $phpbb_root_path . $img_path . '/' . $default_row['smiley_url'],
309 'IMG_PATH' => $img_path,
310 'PHPBB_ROOT_PATH' => $phpbb_root_path,
312 'CODE' => $default_row['code'],
313 'EMOTION' => $default_row['emotion'],
315 'WIDTH' => $default_row['smiley_width'],
316 'HEIGHT' => $default_row['smiley_height'],
327 // Get items to create/modify
328 $images = (isset($_POST['image'])) ? array_keys(request_var('image', array('' => 0))) : array();
330 // Now really get the items
331 $image_id = (isset($_POST['id'])) ? request_var('id', array('' => 0)) : array();
332 $image_order = (isset($_POST['order'])) ? request_var('order', array('' => 0)) : array();
333 $image_width = (isset($_POST['width'])) ? request_var('width', array('' => 0)) : array();
334 $image_height = (isset($_POST['height'])) ? request_var('height', array('' => 0)) : array();
335 $image_add = (isset($_POST['add_img'])) ? request_var('add_img', array('' => 0)) : array();
336 $image_emotion = utf8_normalize_nfc(request_var('emotion', array('' => ''), true));
337 $image_code = utf8_normalize_nfc(request_var('code', array('' => ''), true));
338 $image_display_on_posting = (isset($_POST['display_on_posting'])) ? request_var('display_on_posting', array('' => 0)) : array();
340 // Ok, add the relevant bits if we are adding new codes to existing emoticons...
341 if (!empty($_POST['add_additional_code']))
343 $add_image = request_var('add_image', '');
344 $add_code = utf8_normalize_nfc(request_var('add_code', '', true));
345 $add_emotion = utf8_normalize_nfc(request_var('add_emotion', '', true));
347 if ($add_image && $add_emotion && $add_code)
349 $images[] = $add_image;
350 $image_add[$add_image] = true;
352 $image_code[$add_image] = $add_code;
353 $image_emotion[$add_image] = $add_emotion;
354 $image_width[$add_image] = request_var('add_width', 0);
355 $image_height[$add_image] = request_var('add_height', 0);
357 if (!empty($_POST['add_display_on_posting']))
359 $image_display_on_posting[$add_image] = 1;
362 $image_order[$add_image] = request_var('add_order', 0);
366 if ($mode == 'smilies' && $action == 'create')
368 $smiley_count = $this->item_count($table);
370 $addable_smileys_count = sizeof($images);
371 foreach ($images as $image)
373 if (!isset($image_add[$image]))
375 --$addable_smileys_count;
379 if ($smiley_count + $addable_smileys_count > SMILEY_LIMIT)
381 trigger_error(sprintf($user->lang['TOO_MANY_SMILIES'], SMILEY_LIMIT) . adm_back_link($this->u_action), E_USER_WARNING);
387 foreach ($images as $image)
389 if ($mode == 'smilies' && ($image_emotion[$image] == '' || $image_code[$image] == ''))
391 $errors[$image] = 'SMILIE_NO_' . (($image_emotion[$image] == '') ? 'EMOTION' : 'CODE');
393 else if ($action == 'create' && !isset($image_add[$image]))
395 // skip images where add wasn't checked
397 else if (!file_exists($phpbb_root_path . $img_path . '/' . $image))
399 $errors[$image] = 'SMILIE_NO_FILE';
403 if ($image_width[$image] == 0 || $image_height[$image] == 0)
405 $img_size = getimagesize($phpbb_root_path . $img_path . '/' . $image);
406 $image_width[$image] = $img_size[0];
407 $image_height[$image] = $img_size[1];
410 // Adjust image width/height for icons
411 if ($mode == 'icons')
413 if ($image_width[$image] > 127 && $image_width[$image] > $image_height[$image])
415 $image_height[$image] = (int) ($image_height[$image] * (127 / $image_width[$image]));
416 $image_width[$image] = 127;
418 else if ($image_height[$image] > 127)
420 $image_width[$image] = (int) ($image_width[$image] * (127 / $image_height[$image]));
421 $image_height[$image] = 127;
426 $fields . '_url' => $image,
427 $fields . '_width' => $image_width[$image],
428 $fields . '_height' => $image_height[$image],
429 'display_on_posting' => (isset($image_display_on_posting[$image])) ? 1 : 0,
432 if ($mode == 'smilies')
434 $img_sql = array_merge($img_sql, array(
435 'emotion' => $image_emotion[$image],
436 'code' => $image_code[$image])
440 // Image_order holds the 'new' order value
441 if (!empty($image_order[$image]))
443 $img_sql = array_merge($img_sql, array(
444 $fields . '_order' => $image_order[$image])
447 // Since we always add 'after' an item, we just need to increase all following + the current by one
448 $sql = "UPDATE $table
449 SET {$fields}_order = {$fields}_order + 1
450 WHERE {$fields}_order >= {$image_order[$image]}";
451 $db->sql_query($sql);
453 // If we adjust the order, we need to adjust all other orders too - they became inaccurate...
454 foreach ($image_order as $_image => $_order)
456 if ($_image == $image)
461 if ($_order >= $image_order[$image])
463 $image_order[$_image]++;
468 if ($action == 'modify' && !empty($image_id[$image]))
470 $sql = "UPDATE $table
471 SET " . $db->sql_build_array('UPDATE', $img_sql) . "
472 WHERE {$fields}_id = " . $image_id[$image];
473 $db->sql_query($sql);
476 else if ($action !== 'modify')
478 $sql = "INSERT INTO $table " . $db->sql_build_array('INSERT', $img_sql);
479 $db->sql_query($sql);
486 $cache->destroy('_icons');
487 $cache->destroy('sql', $table);
489 $level = E_USER_NOTICE;
490 switch ($icons_updated)
493 $suc_lang = "{$lang}_NONE";
494 $level = E_USER_WARNING;
498 $suc_lang = "{$lang}_ONE";
505 foreach ($errors as $img => $error)
507 $errormsgs .= '<br />' . sprintf($user->lang[$error], $img);
509 if ($action == 'modify')
511 trigger_error($user->lang[$suc_lang . '_EDITED'] . $errormsgs . adm_back_link($this->u_action), $level);
515 trigger_error($user->lang[$suc_lang . '_ADDED'] . $errormsgs . adm_back_link($this->u_action), $level);
522 $pak = request_var('pak', '');
523 $current = request_var('current', '');
529 if (!($pak_ary = @file($phpbb_root_path . $img_path . '/' . $pak)))
531 trigger_error($user->lang['PAK_FILE_NOT_READABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
534 // Make sure the pak_ary is valid
535 foreach ($pak_ary as $pak_entry)
537 if (preg_match_all("#'(.*?)', ?#", $pak_entry, $data))
539 if ((sizeof($data[1]) != 4 && $mode == 'icons') ||
540 ((sizeof($data[1]) != 6 || (empty($data[1][4]) || empty($data[1][5]))) && $mode == 'smilies' ))
542 trigger_error($user->lang['WRONG_PAK_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING);
547 trigger_error($user->lang['WRONG_PAK_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING);
551 // The user has already selected a smilies_pak file
552 if ($current == 'delete')
554 switch ($db->sql_layer)
558 $db->sql_query('DELETE FROM ' . $table);
562 $db->sql_query('TRUNCATE TABLE ' . $table);
572 // Reset all icon_ids
573 $db->sql_query('UPDATE ' . TOPICS_TABLE . ' SET icon_id = 0');
574 $db->sql_query('UPDATE ' . POSTS_TABLE . ' SET icon_id = 0');
582 $field_sql = ($mode == 'smilies') ? 'code' : 'icons_url';
584 $sql = "SELECT $field_sql
586 $result = $db->sql_query($sql);
588 while ($row = $db->sql_fetchrow($result))
591 $cur_img[$row[$field_sql]] = 1;
593 $db->sql_freeresult($result);
596 if ($mode == 'smilies')
598 $smiley_count = $this->item_count($table);
599 if ($smiley_count + sizeof($pak_ary) > SMILEY_LIMIT)
601 trigger_error(sprintf($user->lang['TOO_MANY_SMILIES'], SMILEY_LIMIT) . adm_back_link($this->u_action), E_USER_WARNING);
605 foreach ($pak_ary as $pak_entry)
608 if (preg_match_all("#'(.*?)', ?#", $pak_entry, $data))
610 if ((sizeof($data[1]) != 4 && $mode == 'icons') ||
611 (sizeof($data[1]) != 6 && $mode == 'smilies'))
613 trigger_error($user->lang['WRONG_PAK_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING);
616 // Stripslash here because it got addslashed before... (on export)
617 $img = stripslashes($data[1][0]);
618 $width = stripslashes($data[1][1]);
619 $height = stripslashes($data[1][2]);
620 $display_on_posting = stripslashes($data[1][3]);
622 if (isset($data[1][4]) && isset($data[1][5]))
624 $emotion = stripslashes($data[1][4]);
625 $code = stripslashes($data[1][5]);
628 if ($current == 'replace' &&
629 (($mode == 'smilies' && !empty($cur_img[$code])) ||
630 ($mode == 'icons' && !empty($cur_img[$img]))))
632 $replace_sql = ($mode == 'smilies') ? $code : $img;
634 $fields . '_url' => $img,
635 $fields . '_height' => (int) $height,
636 $fields . '_width' => (int) $width,
637 'display_on_posting' => (int) $display_on_posting,
640 if ($mode == 'smilies')
642 $sql = array_merge($sql, array(
643 'emotion' => $emotion,
647 $sql = "UPDATE $table SET " . $db->sql_build_array('UPDATE', $sql) . "
648 WHERE $field_sql = '" . $db->sql_escape($replace_sql) . "'";
649 $db->sql_query($sql);
656 $fields . '_url' => $img,
657 $fields . '_height' => (int) $height,
658 $fields . '_width' => (int) $width,
659 $fields . '_order' => (int) $order,
660 'display_on_posting'=> (int) $display_on_posting,
663 if ($mode == 'smilies')
665 $sql = array_merge($sql, array(
667 'emotion' => $emotion,
670 $db->sql_query("INSERT INTO $table " . $db->sql_build_array('INSERT', $sql));
675 $cache->destroy('_icons');
676 $cache->destroy('sql', $table);
678 trigger_error($user->lang[$lang . '_IMPORT_SUCCESS'] . adm_back_link($this->u_action));
684 foreach ($_paks as $pak)
686 $pak_options .= '<option value="' . $pak . '">' . htmlspecialchars($pak) . '</option>';
689 $template->assign_vars(array(
690 'S_CHOOSE_PAK' => true,
691 'S_PAK_OPTIONS' => $pak_options,
693 'L_TITLE' => $user->lang['ACP_' . $lang],
694 'L_EXPLAIN' => $user->lang['ACP_' . $lang . '_EXPLAIN'],
695 'L_NO_PAK_OPTIONS' => $user->lang['NO_' . $lang . '_PAK'],
696 'L_CURRENT' => $user->lang['CURRENT_' . $lang],
697 'L_CURRENT_EXPLAIN' => $user->lang['CURRENT_' . $lang . '_EXPLAIN'],
698 'L_IMPORT_SUBMIT' => $user->lang['IMPORT_' . $lang],
700 'U_BACK' => $this->u_action,
701 'U_ACTION' => $this->u_action . '&action=import',
709 $this->page_title = 'EXPORT_' . $lang;
710 $this->tpl_name = 'message_body';
712 $template->assign_vars(array(
713 'MESSAGE_TITLE' => $user->lang['EXPORT_' . $lang],
714 'MESSAGE_TEXT' => sprintf($user->lang['EXPORT_' . $lang . '_EXPLAIN'], '<a href="' . $this->u_action . '&action=send">', '</a>'),
716 'S_USER_NOTICE' => true,
728 ORDER BY {$fields}_order";
729 $result = $db->sql_query($sql);
732 while ($row = $db->sql_fetchrow($result))
734 $pak .= "'" . addslashes($row[$fields . '_url']) . "', ";
735 $pak .= "'" . addslashes($row[$fields . '_width']) . "', ";
736 $pak .= "'" . addslashes($row[$fields . '_height']) . "', ";
737 $pak .= "'" . addslashes($row['display_on_posting']) . "', ";
739 if ($mode == 'smilies')
741 $pak .= "'" . addslashes($row['emotion']) . "', ";
742 $pak .= "'" . addslashes($row['code']) . "', ";
747 $db->sql_freeresult($result);
751 garbage_collection();
753 header('Pragma: public');
755 // Send out the Headers
756 header('Content-Type: text/x-delimtext; name="' . $mode . '.pak"');
757 header('Content-Disposition: inline; filename="' . $mode . '.pak"');
765 trigger_error($user->lang['NO_' . strtoupper($fields) . '_EXPORT'] . adm_back_link($this->u_action), E_USER_WARNING);
772 if (confirm_box(true))
774 $sql = "DELETE FROM $table
775 WHERE {$fields}_id = $icon_id";
776 $db->sql_query($sql);
784 // Reset appropriate icon_ids
785 $db->sql_query('UPDATE ' . TOPICS_TABLE . "
787 WHERE icon_id = $icon_id");
789 $db->sql_query('UPDATE ' . POSTS_TABLE . "
791 WHERE icon_id = $icon_id");
795 $notice = $user->lang[$lang . '_DELETED'];
797 $cache->destroy('_icons');
798 $cache->destroy('sql', $table);
802 confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
806 'action' => 'delete',
815 // Get current order id...
816 $sql = "SELECT {$fields}_order as current_order
818 WHERE {$fields}_id = $icon_id";
819 $result = $db->sql_query($sql);
820 $current_order = (int) $db->sql_fetchfield('current_order');
821 $db->sql_freeresult($result);
823 if ($current_order == 0 && $action == 'move_up')
828 // on move_down, switch position with next order_id...
829 // on move_up, switch position with previous order_id...
830 $switch_order_id = ($action == 'move_down') ? $current_order + 1 : $current_order - 1;
833 $sql = "UPDATE $table
834 SET {$fields}_order = $current_order
835 WHERE {$fields}_order = $switch_order_id
836 AND {$fields}_id <> $icon_id";
837 $db->sql_query($sql);
839 // Only update the other entry too if the previous entry got updated
840 if ($db->sql_affectedrows())
842 $sql = "UPDATE $table
843 SET {$fields}_order = $switch_order_id
844 WHERE {$fields}_order = $current_order
845 AND {$fields}_id = $icon_id";
846 $db->sql_query($sql);
849 $cache->destroy('_icons');
850 $cache->destroy('sql', $table);
855 // By default, check that image_order is valid and fix it if necessary
856 $sql = "SELECT {$fields}_id AS order_id, {$fields}_order AS fields_order
858 ORDER BY display_on_posting DESC, {$fields}_order";
859 $result = $db->sql_query($sql);
861 if ($row = $db->sql_fetchrow($result))
867 if ($row['fields_order'] != $order)
869 $db->sql_query("UPDATE $table
870 SET {$fields}_order = $order
871 WHERE {$fields}_id = " . $row['order_id']);
874 while ($row = $db->sql_fetchrow($result));
876 $db->sql_freeresult($result);
878 $template->assign_vars(array(
879 'L_TITLE' => $user->lang['ACP_' . $lang],
880 'L_EXPLAIN' => $user->lang['ACP_' . $lang . '_EXPLAIN'],
881 'L_IMPORT' => $user->lang['IMPORT_' . $lang],
882 'L_EXPORT' => $user->lang['EXPORT_' . $lang],
883 'L_NOT_DISPLAYED' => $user->lang[$lang . '_NOT_DISPLAYED'],
884 'L_ICON_ADD' => $user->lang['ADD_' . $lang],
885 'L_ICON_EDIT' => $user->lang['EDIT_' . $lang],
888 'COLSPAN' => ($mode == 'smilies') ? 5 : 3,
890 'S_SMILIES' => ($mode == 'smilies') ? true : false,
892 'U_ACTION' => $this->u_action,
893 'U_IMPORT' => $this->u_action . '&action=import',
894 'U_EXPORT' => $this->u_action . '&action=export',
899 $pagination_start = request_var('start', 0);
901 $item_count = $this->item_count($table);
905 ORDER BY {$fields}_order ASC";
906 $result = $db->sql_query_limit($sql, $config['smilies_per_page'], $pagination_start);
908 while ($row = $db->sql_fetchrow($result))
910 $alt_text = ($mode == 'smilies') ? $row['code'] : '';
912 $template->assign_block_vars('items', array(
913 'S_SPACER' => (!$spacer && !$row['display_on_posting']) ? true : false,
914 'ALT_TEXT' => $alt_text,
915 'IMG_SRC' => $phpbb_root_path . $img_path . '/' . $row[$fields . '_url'],
916 'WIDTH' => $row[$fields . '_width'],
917 'HEIGHT' => $row[$fields . '_height'],
918 'CODE' => (isset($row['code'])) ? $row['code'] : '',
919 'EMOTION' => (isset($row['emotion'])) ? $row['emotion'] : '',
920 'U_EDIT' => $this->u_action . '&action=edit&id=' . $row[$fields . '_id'],
921 'U_DELETE' => $this->u_action . '&action=delete&id=' . $row[$fields . '_id'],
922 'U_MOVE_UP' => $this->u_action . '&action=move_up&id=' . $row[$fields . '_id'] . '&start=' . $pagination_start,
923 'U_MOVE_DOWN' => $this->u_action . '&action=move_down&id=' . $row[$fields . '_id'] . '&start=' . $pagination_start,
926 if (!$spacer && !$row['display_on_posting'])
931 $db->sql_freeresult($result);
933 $template->assign_var('PAGINATION',
934 generate_pagination($this->u_action, $item_count, $config['smilies_per_page'], $pagination_start, true)
939 * Returns the count of smilies or icons in the database
941 * @param string $table The table of items to count.
942 * @return int number of items
944 /* private */ function item_count($table)
948 $sql = "SELECT COUNT(*) AS item_count
950 $result = $db->sql_query($sql);
951 $item_count = (int) $db->sql_fetchfield('item_count');
952 $db->sql_freeresult($result);