Skip to content

Commit 8fffcb5

Browse files
committed
update for 2.6
git-svn-id: http://piwigo.org/svn/extensions/url_uploader@26387 68402e56-0260-453c-a942-63ccdbb3a9ee
1 parent a34db01 commit 8fffcb5

6 files changed

Lines changed: 332 additions & 360 deletions

File tree

admin.php

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
$tabsheet->select('url_uploader');
2323
$tabsheet->assign();
2424

25+
$page['active_menu'] = get_active_menu('photo');
26+
2527

2628
// +-----------------------------------------------------------------------+
2729
// | process form |
@@ -109,10 +111,10 @@
109111
{
110112
if (isset($_POST['onUploadError']) and is_array($_POST['onUploadError']) and count($_POST['onUploadError']) > 0)
111113
{
112-
array_push($page['errors'], sprintf(l10n('%d photos not imported'), count($_POST['onUploadError'])));
114+
$page['errors'][] = l10n('%d photos not imported', count($_POST['onUploadError']));
113115
foreach ($_POST['onUploadError'] as $error)
114116
{
115-
array_push($page['errors'], $error);
117+
$page['errors'][] = $error;
116118
}
117119
}
118120

@@ -139,24 +141,18 @@
139141
'link' => get_root_url().'admin.php?page=photo-'.$image_id.'&cat_id='.$category_id,
140142
);
141143

142-
array_push($page['thumbnails'], $thumbnail);
144+
$page['thumbnails'][] = $thumbnail;
143145
}
144146

145147
if (!empty($page['thumbnails']))
146148
{
147149
// nb uploaded
148-
array_push($page['infos'], sprintf(
149-
l10n('%d photos uploaded'),
150-
count($page['thumbnails'])
151-
));
150+
$page['infos'][] = l10n('%d photos uploaded', count($page['thumbnails']));
152151

153152
// level
154153
if (0 != $_POST['level'])
155154
{
156-
array_push($page['infos'], sprintf(
157-
l10n('Privacy level set to "%s"'),
158-
l10n(sprintf('Level %d', $_POST['level']))
159-
));
155+
$page['infos'][] = l10n('Privacy level set to "%s"', l10n(sprintf('Level %d', $_POST['level'])));
160156
}
161157

162158
// new category count
@@ -168,11 +164,7 @@
168164
list($count) = pwg_db_fetch_row(pwg_query($query));
169165
$category_name = get_cat_display_name_from_id($category_id, 'admin.php?page=album-');
170166

171-
array_push($page['infos'], sprintf(
172-
l10n('Album "%s" now contains %d photos'),
173-
'<em>'.$category_name.'</em>',
174-
$count
175-
));
167+
$page['infos'][] = l10n('Album "%s" now contains %d photos', '<em>'.$category_name.'</em>', $count);
176168

177169
$page['batch_link'] = PHOTOS_ADD_BASE_URL.'&batch='.implode(',', $image_ids);
178170
}
@@ -188,7 +180,7 @@
188180
$upload_modes = array('single', 'multiple');
189181
$upload_mode = isset($conf['url_uploader_mode']) ? $conf['url_uploader_mode'] : 'single';
190182

191-
if ( isset($_GET['upload_mode']) and $_GET['upload_mode']!=$upload_mode and in_array($_GET['upload_mode'], $upload_modes) )
183+
if (isset($_GET['upload_mode']) and $_GET['upload_mode']!=$upload_mode and in_array($_GET['upload_mode'], $upload_modes))
192184
{
193185
$upload_mode = $_GET['upload_mode'];
194186
conf_update_param('url_uploader_mode', $upload_mode);
@@ -217,5 +209,3 @@
217209

218210
// send page content
219211
$template->assign_var_from_handle('ADMIN_CONTENT', 'urluploader_content');
220-
221-
?>

include/functions.inc.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function urluploader_tabsheet_before_select($sheets, $id)
1212
$sheets =
1313
array_slice($sheets, 0, 1) +
1414
array('url_uploader' => array(
15-
'caption' => l10n('URL Uploader'),
15+
'caption' => '<span class="icon-link"></span>' . l10n('URL Uploader'),
1616
'url' => URLUPLOADER_ADMIN,
1717
)) +
1818
array_slice($sheets, 1);
@@ -50,5 +50,3 @@ function get_mime($file, $default="application/octet-stream")
5050

5151
return $default;
5252
}
53-
54-
?>

include/ws_functions.inc.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ function urluploader_ws_add_methods($arr)
1919
),
2020
'url_in_comment' => array('default' => true),
2121
),
22-
'Add image from remote URL.'
22+
'Add image from remote URL.',
23+
null,
24+
array('admin_only'=>true)
2325
);
2426
}
2527

@@ -32,6 +34,8 @@ function ws_images_addRemote($params, &$service)
3234
return new PwgError(401, 'Access denied');
3335
}
3436

37+
load_language('plugin.lang', URLUPLOADER_PATH);
38+
3539
$params = array_map('trim', $params);
3640

3741
$allowed_extensions = array('jpg','jpeg','png','gif');
@@ -40,17 +44,17 @@ function ws_images_addRemote($params, &$service)
4044
// check empty url
4145
if (empty($params['file_url']))
4246
{
43-
return new PwgError(WS_ERR_INVALID_PARAM, 'File URL is empty');
47+
return new PwgError(WS_ERR_INVALID_PARAM, l10n('File URL is empty'));
4448
}
4549
// check remote url
4650
if (!url_is_remote($params['file_url']))
4751
{
48-
return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid file URL');
52+
return new PwgError(WS_ERR_INVALID_PARAM, l10n('Invalid file URL'));
4953
}
5054
// check file extension
5155
if (!in_array(strtolower(get_extension($params['file_url'])), $allowed_extensions))
5256
{
53-
return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid file type');
57+
return new PwgError(WS_ERR_INVALID_PARAM, l10n('Invalid file type'));
5458
}
5559

5660
// download file
@@ -65,13 +69,13 @@ function ws_images_addRemote($params, &$service)
6569
if (!$result)
6670
{
6771
@unlink($temp_filename);
68-
return new PwgError(WS_ERR_INVALID_PARAM, 'Unable to download file');
72+
return new PwgError(WS_ERR_INVALID_PARAM, l10n('Unable to download file'));
6973
}
7074
// check mime-type
7175
if (!in_array(get_mime($temp_filename, $allowed_mimes[0]), $allowed_mimes))
7276
{
7377
@unlink($temp_filename);
74-
return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid file type');
78+
return new PwgError(WS_ERR_INVALID_PARAM, l10n('Invalid file type'));
7579
}
7680

7781
// add photo
@@ -130,5 +134,3 @@ function ws_images_addRemote($params, &$service)
130134
'thumbnail_url' => preg_replace('#^'.PHPWG_ROOT_PATH.'#', './', DerivativeImage::thumb_url($image_infos)),
131135
);
132136
}
133-
134-
?>

main.inc.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,18 @@
1111
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
1212

1313

14-
// +-----------------------------------------------------------------------+
15-
// | Define plugin constants |
16-
// +-----------------------------------------------------------------------+
17-
defined('URLUPLOADER_ID') or define('URLUPLOADER_ID', basename(dirname(__FILE__)));
14+
define('URLUPLOADER_ID', basename(dirname(__FILE__)));
1815
define('URLUPLOADER_PATH' , PHPWG_PLUGINS_PATH . URLUPLOADER_ID . '/');
1916
define('URLUPLOADER_ADMIN', get_root_url() . 'admin.php?page=plugin-' . URLUPLOADER_ID);
2017

2118

22-
// +-----------------------------------------------------------------------+
23-
// | Add event handlers |
24-
// +-----------------------------------------------------------------------+
2519
if (defined('IN_ADMIN'))
2620
{
27-
// new tab on photo page
2821
add_event_handler('tabsheet_before_select', 'urluploader_tabsheet_before_select', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
2922
}
3023

31-
// add API function
3224
add_event_handler('ws_add_methods', 'urluploader_ws_add_methods');
3325

26+
3427
include_once(URLUPLOADER_PATH . 'include/functions.inc.php');
3528
include_once(URLUPLOADER_PATH . 'include/ws_functions.inc.php');
36-
37-
?>

maintain.inc.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@
33

44
function plugin_uninstall()
55
{
6-
pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "url_uploader_mode" LIMIT 1;');
6+
conf_delete_param('url_uploader_mode');
77
}
8-
9-
?>

0 commit comments

Comments
 (0)