From 5a7723ff10ee2b01770542b2b5726cdfb8769e4a Mon Sep 17 00:00:00 2001 From: rvelices Date: Fri, 7 Mar 2008 02:07:55 +0000 Subject: [PATCH] - some more smarty migration (admin upload ws_checker profile and plugin) git-svn-id: http://piwigo.org/svn/trunk@2260 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/upload.php | 24 +--- admin/ws_checker.php | 202 ++++++++++------------------- template/yoga/admin/plugin.tpl | 6 +- template/yoga/admin/profile.tpl | 6 +- template/yoga/admin/upload.tpl | 68 +++++----- template/yoga/admin/ws_checker.tpl | 168 +++++++++++------------- 6 files changed, 193 insertions(+), 281 deletions(-) diff --git a/admin/upload.php b/admin/upload.php index 9bc0f5067..55e774de4 100644 --- a/admin/upload.php +++ b/admin/upload.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | PhpWebGallery - a PHP based picture gallery | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | -// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | +// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net | // +-----------------------------------------------------------------------+ // | file : $Id$ // | last update : $Date$ @@ -143,7 +143,7 @@ $template->set_filenames(array('upload'=>'admin/upload.tpl')); // TabSheet initialization waiting_tabsheet(); -$template->assign_vars(array( +$template->assign(array( 'F_ACTION'=>str_replace( '&', '&', $_SERVER['REQUEST_URI']) )); @@ -156,7 +156,6 @@ $query.= " WHERE validated = 'false'"; $query.= ' ORDER BY storage_category_id'; $query.= ';'; $result = pwg_query( $query ); -$i = 0; while ( $row = mysql_fetch_array( $result ) ) { if ( !isset( $cat_names[$row['storage_category_id']] ) ) @@ -169,13 +168,9 @@ while ( $row = mysql_fetch_array( $result ) ) get_cat_display_name($cat['upper_names']); } $preview_url = PHPWG_ROOT_PATH.$cat_names[$row['storage_category_id']]['dir'].$row['file']; - $class='row1'; - if ( $i++ % 2== 0 ) $class='row2'; - $template->assign_block_vars( - 'picture', + $tpl_var = array( - 'WAITING_CLASS'=>$class, 'CATEGORY_IMG'=>$cat_names[$row['storage_category_id']]['display_name'], 'ID_IMG'=>$row['id'], 'DATE_IMG' => date('Y-m-d H:i:s', $row['date']), @@ -186,7 +181,6 @@ while ( $row = mysql_fetch_array( $result ) ) 'PREVIEW_URL_IMG'=>$preview_url, 'UPLOAD_EMAIL'=>get_email_address_as_display_text($row['mail_address']), 'UPLOAD_USERNAME'=>$row['username'] - ) ); // is there an existing associated thumnail ? @@ -198,26 +192,20 @@ while ( $row = mysql_fetch_array( $result ) ) $url = $cat_names[$row['storage_category_id']]['dir']; $url.= 'thumbnail/'.$thumbnail; - $template->assign_block_vars( - 'picture.thumbnail', + $tpl_var['thumbnail'] = array( 'PREVIEW_URL_TN_IMG' => $url, 'FILE_TN_IMG' => (strlen($thumbnail) > 10) ? (substr($thumbnail, 0, 10)).'...' : $thumbnail, 'FILE_TN_TITLE' => $thumbnail - ) ); } - + $template->append('pictures', $tpl_var); array_push($list, $row['id']); } -$template->assign_vars( - array( - 'LIST' => implode(',', $list) - ) - ); +$template->assign('LIST',implode(',', $list) ); //----------------------------------------------------------- sending html code $template->assign_var_from_handle('ADMIN_CONTENT', 'upload'); diff --git a/admin/ws_checker.php b/admin/ws_checker.php index 6a5efb4fc..e50f17fdf 100644 --- a/admin/ws_checker.php +++ b/admin/ws_checker.php @@ -2,10 +2,9 @@ // +-----------------------------------------------------------------------+ // | PhpWebGallery - a PHP based picture gallery | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | -// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | +// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net | // +-----------------------------------------------------------------------+ -// | branch : BSF (Best So Far) -// | file : $RCSfile$ +// | file : $Id$ // | last update : $Date$ // | last modifier : $Author$ // | revision : $Revision$ @@ -154,11 +153,9 @@ VALUES (' . " pwg_query($query); $chk_partner = $add_partner; - $template->assign_block_vars( - 'update_result', - array( - 'UPD_ELEMENT'=> l10n('ws_adding_legend').l10n('ws_success_upd'), - ) + $template->append( + 'update_results', + l10n('ws_adding_legend').l10n('ws_success_upd') ); } @@ -176,18 +173,14 @@ if (isset($_POST['wsu_submit'])) SET '.$settxt.' WHERE id = '.$uid.'; '; pwg_query($query); - $template->assign_block_vars( - 'update_result', - array( - 'UPD_ELEMENT'=> l10n('ws_update_legend').l10n('ws_success_upd'), - ) + $template->append( + 'update_results', + l10n('ws_update_legend').l10n('ws_success_upd') ); } else { - $template->assign_block_vars( - 'update_result', - array( - 'UPD_ELEMENT'=> l10n('ws_update_legend').l10n('ws_failed_upd'), - ) + $template->append( + 'update_results', + l10n('ws_update_legend').l10n('ws_failed_upd') ); } } @@ -202,19 +195,14 @@ if (isset($_POST['wsX_submit'])) $query = 'DELETE FROM '.WEB_SERVICES_ACCESS_TABLE.' WHERE id = '.$uid.'; '; pwg_query($query); - $template->assign_block_vars( - 'update_result', - array( - 'UPD_ELEMENT'=> l10n('ws_delete_legend').l10n('ws_success_upd'), - ) + $template->append( + 'update_results', + l10n('ws_delete_legend').l10n('ws_success_upd') ); } else { - $template->assign_block_vars( - 'update_result', - array( - 'UPD_ELEMENT'=> l10n('Not selected / Not confirmed') - .l10n('ws_failed_upd'), - ) + $template->append( + 'update_results', + l10n('Not selected / Not confirmed').l10n('ws_failed_upd') ); } } @@ -252,23 +240,14 @@ $template->set_filenames( ) ); -$selected = 'selected="selected"'; -$num=0; -if ( $acc_list > 0 ) -{ - $template->assign_block_vars( - 'acc_list', array() ); -} // Access List while ($row = mysql_fetch_array($result)) { - $num++; $chk_partner = ( $chk_partner == '' ) ? $row['name'] : $chk_partner; - $template->assign_block_vars( - 'acc_list.access', + $template->append( + 'access_list', array( - 'CLASS' => ($num % 2 == 1) ? 'row1' : 'row2', 'ID' => $row['id'], 'NAME' => (is_adviser()) ? '*********' : $row['name'], @@ -277,45 +256,17 @@ while ($row = mysql_fetch_array($result)) 'REQUEST' => $row['request'], 'LIMIT' => $row['limit'], 'COMMENT' => $row['comment'], - 'SELECTED' => '', ) ); } -$template->assign_block_vars( - 'add_request', - array( - 'VALUE'=> '', - 'CONTENT' => '', - 'SELECTED' => $selected, - ) -); -foreach ($req_type_list as $value) { +$template->assign('add_requests', $req_type_list); - $template->assign_block_vars( - 'add_request', - array( - 'VALUE'=> $value, - 'CONTENT' => $value, - 'SELECTED' => '', - ) - ); -} - -foreach ($conf['ws_allowed_limit'] as $value) { - $template->assign_block_vars( - 'add_limit', - array( - 'VALUE'=> $value, - 'CONTENT' => $value, - 'SELECTED' => ($conf['ws_allowed_limit'][0] == $value) ? $selected:'', - ) - ); -} +$template->assign('add_limits', $conf['ws_allowed_limit'] ); // Postponed Start Date // By default 0, 1, 2, 3, 5, 7, 14 or 30 days -foreach ($conf['ws_postponed_start'] as $value) { +/*foreach ($conf['ws_postponed_start'] as $value) { $template->assign_block_vars( 'add_start', array( @@ -324,75 +275,58 @@ foreach ($conf['ws_postponed_start'] as $value) { 'SELECTED' => ($conf['ws_postponed_start'][0] == $value) ? $selected:'', ) ); -} +}*/ // Durations (Allowed Web Services Period) // By default 10, 5, 2, 1 year(s) or 6, 3, 1 month(s) or 15, 10, 7, 5, 1, 0 day(s) -foreach ($conf['ws_durations'] as $value) { - $template->assign_block_vars( - 'add_end', - array( - 'VALUE'=> $value, - 'CONTENT' => $value, - 'SELECTED' => ($conf['ws_durations'][3] == $value) ? $selected:'', - ) - ); - if ( $acc_list > 0 ) - { - $template->assign_block_vars( - 'acc_list.upd_end', - array( - 'VALUE'=> $value, - 'CONTENT' => $value, - 'SELECTED' => ($conf['ws_durations'][3] == $value) ? $selected:'', - ) - ); - } -} +$template->assign('add_ends', $conf['ws_durations']); + if ( $chk_partner !== '' ) { - $request = get_absolute_root_url().'ws.php?method=pwg.getVersion&format=rest&' - . "partner=$chk_partner" ; - $session = curl_init($request); - curl_setopt ($session, CURLOPT_POST, true); - curl_setopt($session, CURLOPT_HEADER, true); - curl_setopt($session, CURLOPT_RETURNTRANSFER, true); - $response = curl_exec($session); - curl_close($session); - $status_code = array(); - preg_match('/\d\d\d/', $response, $status_code); - switch( $status_code[0] ) { - case 200: - $ws_status = l10n('Web Services under control'); - break; - case 503: - $ws_status = 'PhpWebGallery Web Services failed and returned an ' - . 'HTTP status of 503. Service is unavailable. An internal ' - . 'problem prevented us from returning data to you.'; - break; - case 403: - $ws_status = 'PhpWebGallery Web Services failed and returned an ' - . 'HTTP status of 403. Access is forbidden. You do not have ' - . 'permission to access this resource, or are over ' - . 'your rate limit.'; - break; - case 400: - // You may want to fall through here and read the specific XML error - $ws_status = 'PhpWebGallery Web Services failed and returned an ' - . 'HTTP status of 400. Bad request. The parameters passed ' - . 'to the service did not match as expected. The exact ' - . 'error is returned in the XML response.'; - break; - default: - $ws_status = 'PhpWebGallery Web Services returned an unexpected HTTP ' - . 'status of:' . $status_code[0]; + if (function_exists('curl_init')) + { + $request = get_absolute_root_url().'ws.php?method=pwg.getVersion&format=rest&' + . "partner=$chk_partner" ; + $session = curl_init($request); + curl_setopt ($session, CURLOPT_POST, true); + curl_setopt($session, CURLOPT_HEADER, true); + curl_setopt($session, CURLOPT_RETURNTRANSFER, true); + $response = curl_exec($session); + curl_close($session); + $status_code = array(); + preg_match('/\d\d\d/', $response, $status_code); + switch( $status_code[0] ) { + case 200: + $ws_status = l10n('Web Services under control'); + break; + case 503: + $ws_status = 'PhpWebGallery Web Services failed and returned an ' + . 'HTTP status of 503. Service is unavailable. An internal ' + . 'problem prevented us from returning data to you.'; + break; + case 403: + $ws_status = 'PhpWebGallery Web Services failed and returned an ' + . 'HTTP status of 403. Access is forbidden. You do not have ' + . 'permission to access this resource, or are over ' + . 'your rate limit.'; + break; + case 400: + // You may want to fall through here and read the specific XML error + $ws_status = 'PhpWebGallery Web Services failed and returned an ' + . 'HTTP status of 400. Bad request. The parameters passed ' + . 'to the service did not match as expected. The exact ' + . 'error is returned in the XML response.'; + break; + default: + $ws_status = 'PhpWebGallery Web Services returned an unexpected HTTP ' + . 'status of:' . $status_code[0]; + } } - $template->assign_block_vars( - 'acc_list.ws_status', - array( - 'VALUE'=> $ws_status, - ) - ); + else + { + $ws_status = 'Cannot check - curl not installed'; + } + $template->assign( 'WS_STATUS', $ws_status ); } //----------------------------------------------------------- sending html code diff --git a/template/yoga/admin/plugin.tpl b/template/yoga/admin/plugin.tpl index 8a10b02cf..5a0a1fbe7 100644 --- a/template/yoga/admin/plugin.tpl +++ b/template/yoga/admin/plugin.tpl @@ -1,7 +1,7 @@ - +{* $Id$ *}
-

{PLUGIN_TITLE}

+

{$PLUGIN_TITLE}

-{PLUGIN_ADMIN_CONTENT} +{$PLUGIN_ADMIN_CONTENT} diff --git a/template/yoga/admin/profile.tpl b/template/yoga/admin/profile.tpl index 383841a79..f6326319c 100644 --- a/template/yoga/admin/profile.tpl +++ b/template/yoga/admin/profile.tpl @@ -1,6 +1,6 @@ - +{* $Id$ *}
-

{lang:Profile}

+

{'Profile'|@translate}

-{PROFILE_CONTENT} +{$PROFILE_CONTENT} diff --git a/template/yoga/admin/upload.tpl b/template/yoga/admin/upload.tpl index 755e5ac35..419a01ec0 100644 --- a/template/yoga/admin/upload.tpl +++ b/template/yoga/admin/upload.tpl @@ -1,51 +1,53 @@ - - +{* $Id$ *}
-

{lang:waiting} {TABSHEET_TITLE}

- {TABSHEET} +

{'waiting'|@translate} {$TABSHEET_TITLE}

+ {$TABSHEET}
-

{lang:title_upload}

+

{'title_upload'|@translate}

-
- + +
- - - - - + + + + + - - - - - + + + - - - - + {/foreach} + {/if}
{lang:category}{lang:date}{lang:file}{lang:thumbnail}{lang:Author}{'category'|@translate}{'date'|@translate}{'file'|@translate}{'thumbnail'|@translate}{'Author'|@translate}  
{picture.CATEGORY_IMG}{picture.DATE_IMG} - {picture.FILE_IMG} + + {if not empty($pictures) } + {foreach from=$pictures item=picture name=picture_loop} +
{$picture.CATEGORY_IMG}{$picture.DATE_IMG} + {$picture.FILE_IMG} - - {picture.thumbnail.FILE_TN_IMG} - + + {if not empty($picture.thumbnail) } + {$picture.thumbnail.FILE_TN_IMG} + {/if} - {picture.UPLOAD_USERNAME} + + {$picture.UPLOAD_USERNAME} - - + + +

- - - - - + + + + +

diff --git a/template/yoga/admin/ws_checker.tpl b/template/yoga/admin/ws_checker.tpl index b61d75176..cce3c7f49 100644 --- a/template/yoga/admin/ws_checker.tpl +++ b/template/yoga/admin/ws_checker.tpl @@ -1,93 +1,87 @@ - - +{* $Id$ *}
-

{lang:title_wscheck} - {lang:web_services}

+

{'title_wscheck'|@translate} - {'web_services'|@translate}

- +{if !empty($update_results)} - +{/if} - -
+{* Add Access *} +
- {lang:ws_adding_legend} + {'ws_adding_legend'|@translate} - + {* Access key *} - + {* Target (cat/ids, tag/ids, or list/ids ids=id,id-id,...) *} - + {* Restricted access to specific request *} - + {* Limit number of images information to be return *} - - - --> + + *} - + {* Opened service only for n days *} - + {* Idendify your partner (name / website / phone) as you want *} - + {* Add submit button *}
- + + id="add_partner" value="{$F_ADD_PARTNER}" + title="{'Basis of access key calculation'|@translate}" />
- + - ({lang:Access: see help text for more}) + id="add_target" value="{$F_ADD_ACCESS}" + title="{'Facultative and restrictive option'|@translate}" /> + ({'Access: see help text for more'|@translate})
- + - ({lang:ws_Methods}) + ({'ws_Methods'|@translate})
- +
- +
- +
+ rows="4" cols="80">{'Comment to identify your partner clearly'|@translate}
+ value="{'Submit'|@translate}" {$TAG_INPUT_ENABLED} + title="{'Add this access definition'|@translate}" />
- +{if !empty($access_list)} -
- - - - - - + + + + + + +
- {lang:ws_update_legend} + {'ws_update_legend'|@translate} - - - - - - + + + + + + - - + {foreach from=$access_list item=access name=access_loop} + - - - - - - + + + + + + - + {/foreach}
 {lang:ws_KeyName}{lang:ws_Access}{lang:ws_End}{lang:ws_Request}{lang:ws_Limit}{lang:ws_Comment}{'ws_KeyName'|@translate}{'ws_Access'|@translate}{'ws_End'|@translate}{'ws_Request'|@translate}{'ws_Limit'|@translate}{'ws_Comment'|@translate}
+ value="{$access.ID}" id="selection-{$access.ID}"> {acc_list.access.TARGET}{acc_list.access.END}{acc_list.access.REQUEST}{acc_list.access.LIMIT}{acc_list.access.COMMENT}{$access.TARGET}{$access.END}{$access.REQUEST}{$access.LIMIT}{$access.COMMENT}
- {lang:ws_delete_legend} + {'ws_delete_legend'|@translate} + value="{'Delete'|@translate}" {$TAG_INPUT_ENABLED}>
@@ -202,29 +193,26 @@ - + + value="{'Submit'|@translate}" {$TAG_INPUT_ENABLED}> - ({lang:Web Services availability duration in days}) + ({'Web Services availability duration in days'|@translate})
- -

{acc_list.ws_status.VALUE}

- - +{/if} + +{if isset($WS_STATUS)} +

{$WS_STATUS}

+{/if}