1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Crop Image |
---|
4 | Version: 2.5.c |
---|
5 | Description: Enables to Crop Images already uploaded to the gallery, basic functionality. Tested with v2.5.1, v2.4.6 |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=700 |
---|
7 | Author: Chillexistence |
---|
8 | Author URI: http://piwigo.org |
---|
9 | */ |
---|
10 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
11 | define('CROPIMAGE_PATH', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__))); |
---|
12 | |
---|
13 | add_event_handler('init', 'cropImage_init' ); |
---|
14 | add_event_handler('tabsheet_before_select','crop_image_add_tab', 50, 2); |
---|
15 | |
---|
16 | function crop_image_add_tab($sheets, $id) |
---|
17 | { |
---|
18 | $image_id = isset($_GET['image_id'])? $_GET['image_id'] : ''; |
---|
19 | |
---|
20 | if ($id == 'photo') |
---|
21 | { |
---|
22 | $sheets['crop'] = array( |
---|
23 | 'caption' => l10n('Crop'), |
---|
24 | 'url' => get_root_url().'admin.php?page=plugin-cropImage-'.$image_id, |
---|
25 | ); |
---|
26 | } |
---|
27 | |
---|
28 | return $sheets; |
---|
29 | } |
---|
30 | |
---|
31 | function cropImage_init() |
---|
32 | { |
---|
33 | global $conf, $pwg_loaded_plugins; |
---|
34 | if (!defined('PWG_HELP') and !defined('IN_ADMIN') and is_admin()) |
---|
35 | { |
---|
36 | // Add an event handler for a prefilter on picture.php pages |
---|
37 | add_event_handler('loc_begin_picture', 'cropImage_set_prefilter_add_to_pic_info', 55 ); |
---|
38 | } |
---|
39 | } |
---|
40 | |
---|
41 | //////////////////////////////////////////////////////////////////////////////// |
---|
42 | // Add the prefilter for the Crop Link on the template on picture.php |
---|
43 | //////////////////////////////////////////////////////////////////////////////// |
---|
44 | function cropImage_set_prefilter_add_to_pic_info() |
---|
45 | { |
---|
46 | global $template, $conf, $user, $page; |
---|
47 | |
---|
48 | $url_admin = |
---|
49 | get_root_url().'admin.php?page=plugin-cropImage-'.$page['image_id'] |
---|
50 | .(isset($page['category']) ? '&cat_id='.$page['category']['id'] : '') |
---|
51 | ; |
---|
52 | $template->set_prefilter('picture', 'cropImage_add_button'); |
---|
53 | |
---|
54 | $template->func_combine_css(array('path' => CROPIMAGE_PATH.'/css/cropimage_toolbar_buttons.css')); |
---|
55 | |
---|
56 | //Get the Theme to display the correct icon style |
---|
57 | if ( in_array($user['theme'], array('Sylvia','sylvia')) ) |
---|
58 | { |
---|
59 | $ButtonTheme = "sylvia"; |
---|
60 | } |
---|
61 | elseif ( in_array($user['theme'], array('elegant')) ) |
---|
62 | { |
---|
63 | $ButtonTheme = "elegant"; |
---|
64 | } |
---|
65 | elseif ( in_array($user['theme'], array('clear')) ) |
---|
66 | { |
---|
67 | $ButtonTheme = "clear"; |
---|
68 | } |
---|
69 | elseif ( in_array($user['theme'], array('dark')) ) |
---|
70 | { |
---|
71 | $ButtonTheme = "dark"; |
---|
72 | } |
---|
73 | else |
---|
74 | { |
---|
75 | $ButtonTheme = "clear"; |
---|
76 | } |
---|
77 | |
---|
78 | $template->assign( |
---|
79 | array( |
---|
80 | 'U_CROPIMAGE' => $url_admin, |
---|
81 | 'U_CROPIMAGE_THEME' => $ButtonTheme, |
---|
82 | ) |
---|
83 | ); |
---|
84 | } |
---|
85 | //////////////////////////////////////////////////////////////////////////////// |
---|
86 | // Insert the template for the Crop Link on picture.php |
---|
87 | //////////////////////////////////////////////////////////////////////////////// |
---|
88 | function cropImage_add_button($content) |
---|
89 | { |
---|
90 | // Add the information after imageInfoTable so before everything else like author and date. |
---|
91 | $search = '{strip}{if isset($U_CADDIE)}{*caddie management BEGIN*}'; |
---|
92 | |
---|
93 | $replacement = ' |
---|
94 | <a class="pwg-state-default pwg-button" href="{$U_CROPIMAGE}" title="Crop Image" rel="nofollow"> |
---|
95 | <span class="ci-icon ci-icon-cropimage-{$U_CROPIMAGE_THEME}"> </span><span class="pwg-button-text">Crop Image</span> |
---|
96 | </a> |
---|
97 | ' . $search; |
---|
98 | |
---|
99 | return str_replace($search, $replacement, $content); |
---|
100 | } |
---|
101 | |
---|
102 | ?> |
---|