[3437] | 1 | <?php |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | |
---|
| 5 | Plugin Name: ImageForAll |
---|
| 6 | |
---|
| 7 | Version: 2.0.b |
---|
| 8 | |
---|
| 9 | Description: Allow to show total number of images for everyone. |
---|
| 10 | |
---|
| 11 | Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=167 |
---|
| 12 | |
---|
| 13 | Author: Sakkhho |
---|
| 14 | |
---|
| 15 | Author URI: http://piwigo.org |
---|
| 16 | |
---|
| 17 | */ |
---|
| 18 | |
---|
| 19 | |
---|
| 20 | |
---|
| 21 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 22 | |
---|
| 23 | define('IMG_DIR' , basename(dirname(__FILE__))); |
---|
| 24 | |
---|
| 25 | define('IMG_PATH' , PHPWG_PLUGINS_PATH . IMG_DIR . '/'); |
---|
| 26 | |
---|
| 27 | |
---|
| 28 | |
---|
| 29 | function img_for_all_admin_menu($menu) |
---|
| 30 | |
---|
| 31 | { |
---|
| 32 | |
---|
| 33 | array_push($menu, array('NAME' => 'ImageForAll', |
---|
| 34 | |
---|
| 35 | 'URL' => get_admin_plugin_menu_link(IMG_PATH . 'admin/img_admin.php'))); |
---|
| 36 | |
---|
| 37 | return $menu; |
---|
| 38 | |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | function img_for_all_replace_tpl_code($menu_ref_arr) |
---|
| 44 | |
---|
| 45 | { |
---|
| 46 | |
---|
| 47 | global $conf, $lang ; |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | $menu = & $menu_ref_arr[0]; |
---|
| 52 | |
---|
| 53 | $block = $menu->get_block('mbCategories'); |
---|
| 54 | |
---|
| 55 | $nb_images = $block->data['NB_PICTURE']; |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | |
---|
| 59 | $query = 'SELECT COUNT(DISTINCT(image_id)) FROM '.IMAGE_CATEGORY_TABLE.';'; |
---|
| 60 | |
---|
| 61 | $result = pwg_query($query) ; |
---|
| 62 | |
---|
| 63 | list($total_img) = mysql_fetch_row($result); |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | $img_for_all = str_replace( |
---|
| 68 | |
---|
| 69 | array('{NB_PICTURE}', '{NB_TOTAL}'), |
---|
| 70 | |
---|
| 71 | array($nb_images, $total_img), |
---|
| 72 | |
---|
| 73 | $conf['imageforall']); |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | $block->data['IMG_FOR_ALL'] = $img_for_all; |
---|
| 78 | |
---|
| 79 | $block->template = dirname(__FILE__) . '/menubar_categories.tpl'; |
---|
| 80 | |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | |
---|
| 86 | |
---|
| 87 | add_event_handler('get_admin_plugin_menu_links', 'img_for_all_admin_menu'); |
---|
| 88 | |
---|
| 89 | add_event_handler('blockmanager_apply', 'img_for_all_replace_tpl_code'); |
---|
| 90 | |
---|
| 91 | |
---|
| 92 | |
---|
| 93 | ?> |
---|