Ignore:
Timestamp:
Jul 24, 2012, 7:22:23 PM (12 years ago)
Author:
plg
Message:

add tab "Update" on photo administration screen (requires Piwigo 2.4.2)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/photo_update/main.inc.php

    r11651 r16982  
    1414}
    1515
    16 add_event_handler('loc_begin_admin', 'photo_update_add_form');
    17 function photo_update_add_form()
    18 {
    19   global $template;
    20 
    21   $template->set_prefilter('picture_modify', 'photo_update_add_form_prefilter');
    22 }
    23 
    24 function photo_update_add_form_prefilter($content, &$smarty)
    25 {
    26   $search = '#<form id="associations"#';
    27   $replacement = '
    28 <form id="photo_update" method="post" action="{$F_ACTION}" enctype="multipart/form-data">
    29   <fieldset>
    30     <legend>{\'Photo Update\'|@translate}</legend>
    31 
    32     <p style="text-align:left" class="file"><input type="file" size="60" name="photo_update"></p>
    33     <p style="text-align:left"><input class="submit" type="submit" value="{\'Update\'|@translate}" name="photo_update"></p>
    34   </fieldset>
    35 </form>
    36 
    37 <form id="associations"
    38 ';
    39 
    40   return preg_replace($search, $replacement, $content);
    41 }
    42 
    43 add_event_handler('loc_begin_admin_page', 'photo_update_process_update');
    44 function photo_update_process_update()
    45 {
    46   load_language('plugin.lang', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
     16add_event_handler('tabsheet_before_select','photo_update_add_tab', 50, 2);
     17function photo_update_add_tab($sheets, $id)
     18
     19  if ($id == 'photo')
     20  {
     21    $sheets['update'] = array(
     22      'caption' => l10n('Update'),
     23      'url' => get_root_url().'admin.php?page=plugin-photo_update-'.$_GET['image_id'],
     24      );
     25  }
    4726 
    48   global $page, $template;
    49  
    50   if (isset($_FILES['photo_update']))
    51   {
    52     include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
    53    
    54     if ($_FILES['photo_update']['error'] !== UPLOAD_ERR_OK)
    55     {
    56       $error_message = file_upload_error_message($_FILES['photo_update']['error']);
    57 
    58       array_push(
    59         $page['errors'],
    60         $error_message
    61         );
    62     }
    63     else
    64     {
    65       check_status(ACCESS_ADMINISTRATOR);
    66       check_input_parameter('image_id', $_GET, false, PATTERN_ID);
    67 
    68       add_uploaded_file(
    69         $_FILES['photo_update']['tmp_name'],
    70         $_FILES['photo_update']['name'],
    71         null,
    72         null,
    73         $_GET['image_id']
    74         );
    75 
    76       $page['photo_update_refresh_thumbnail'] = true;
    77 
    78       $template->set_prefilter('picture_modify', 'photo_update_force_thumbnail_refresh_prefilter');
    79 
    80       $template->assign('REFRESH_KEY', time());
    81      
    82       array_push(
    83         $page['infos'],
    84         l10n('The photo was updated')
    85         );
    86     }
    87   }
    88 }
    89 
    90 function photo_update_force_thumbnail_refresh_prefilter($content, &$smarty)
    91 {
    92   $search = '#<img src="{\$TN_SRC}"#';
    93   $replacement = '<img src="{$TN_SRC}?{$REFRESH_KEY}"';
    94 
    95   return preg_replace($search, $replacement, $content);
     27  return $sheets;
    9628}
    9729?>
Note: See TracChangeset for help on using the changeset viewer.