source: extensions/regenerateThumbnails/ws_functions.inc.php @ 9950

Last change on this file since 9950 was 9934, checked in by patdenice, 14 years ago

Move ws function in separate file.

File size: 1.5 KB
Line 
1<?php
2
3if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
4
5global $conf;
6
7$service = &$arr[0];
8$service->addMethod(
9  'pwg.images.regenerateThumbnail',
10  'ws_images_regenerateThumbnail',
11  array(
12    'image_id'  => array(),
13    'maxwidth'  => array('default'=>$conf['upload_form_thumb_maxwidth']),
14    'maxheight' => array('default'=>$conf['upload_form_thumb_maxheight']),
15    'quality'   => array('default'=>$conf['upload_form_thumb_quality']),
16    'square'    => array('default'=>@$conf['upload_form_thumb_square']),
17  ),
18  'Regenerate a thumbnail with given arguments.'
19);
20
21function ws_images_regenerateThumbnail($params, &$service)
22{
23  global $conf;
24
25  if (!is_admin())
26    return new PwgError(401, 'Access denied');
27
28  $query='
29SELECT id, path
30FROM '.IMAGES_TABLE.'
31WHERE id = '.(int)$params['image_id'].'
32;';
33
34  $image = pwg_db_fetch_assoc(pwg_query($query));
35  if ($image == null)
36    return new PwgError(404, "image_id not found");
37
38  include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
39
40  if ($params['square'] == 'true' or $params['square'] == 'false')
41    $params['square'] = get_boolean($params['square']);
42  if (!$params['square'])
43    remove_event_handler('upload_thumbnail_resize', 'upload_square_resize', 40);
44 
45  trigger_event(
46    'upload_thumbnail_resize',
47    false,
48    $image['path'],
49    file_path_for_type($image['path'], 'thumb'),
50    $params['maxwidth'],
51    $params['maxheight'],
52    $params['quality'],
53    true
54    );
55
56  return true;
57}
58
59?>
Note: See TracBrowser for help on using the repository browser.