| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | Plugin Name: External ImageMagick |
|---|
| 4 | Version: auto |
|---|
| 5 | Description: Use external ImageMagick installation |
|---|
| 6 | Plugin URI: auto |
|---|
| 7 | Author: P@t |
|---|
| 8 | Author URI: http://www.gauchon.com |
|---|
| 9 | */ |
|---|
| 10 | |
|---|
| 11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
|---|
| 12 | |
|---|
| 13 | define('IMAGICK_EXEC_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); |
|---|
| 14 | |
|---|
| 15 | add_event_handler('get_admin_plugin_menu_links', 'imagick_exec_init'); |
|---|
| 16 | add_event_handler('ws_add_methods', 'ws_add_method_load_imagick_exec_functions'); |
|---|
| 17 | add_event_handler('loc_end_section_init', 'imagick_exec_section_init', 60); |
|---|
| 18 | |
|---|
| 19 | function imagick_exec_init($menu) |
|---|
| 20 | { |
|---|
| 21 | global $conf, $page; |
|---|
| 22 | |
|---|
| 23 | if (in_array($page['page'], array('intro','plugins_list','photos_add')) and !test_imagick_exec()) |
|---|
| 24 | { |
|---|
| 25 | array_push($page['warnings'], l10n('Unable to locate ImageMagick directory. Please fill $conf[\'imagick_directory\'] in your local configuration file.')); |
|---|
| 26 | } |
|---|
| 27 | elseif ($page['page'] == 'photos_add' and test_imagick_exec()) |
|---|
| 28 | { |
|---|
| 29 | include_once(IMAGICK_EXEC_PATH.'imagick.class.php'); |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | return $menu; |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | // Only for Community plugin |
|---|
| 36 | function imagick_exec_section_init() |
|---|
| 37 | { |
|---|
| 38 | global $page; |
|---|
| 39 | |
|---|
| 40 | if (isset($page['section']) and $page['section'] == 'add_photos') |
|---|
| 41 | { |
|---|
| 42 | include_once(IMAGICK_EXEC_PATH.'imagick.class.php'); |
|---|
| 43 | } |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | function ws_add_method_load_imagick_exec_functions() |
|---|
| 47 | { |
|---|
| 48 | if (test_imagick_exec()) |
|---|
| 49 | include_once(IMAGICK_EXEC_PATH.'imagick.class.php'); |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | function test_imagick_exec() |
|---|
| 53 | { |
|---|
| 54 | global $conf; |
|---|
| 55 | |
|---|
| 56 | $imagick_dir = isset($conf['imagick_dir']) ? rtrim($conf['imagick_dir'], ' /\\').'/' : ''; |
|---|
| 57 | @exec($imagick_dir.'convert', $returnarray, $returnvalue); |
|---|
| 58 | return (!$returnvalue and !empty($returnarray[0]) and preg_match('/ImageMagick/', $returnarray[0])); |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | if (script_basename() == 'uploadify' and test_imagick_exec()) |
|---|
| 62 | { |
|---|
| 63 | include_once(IMAGICK_EXEC_PATH.'imagick.class.php'); |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | ?> |
|---|