Changeset 26199


Ignore:
Timestamp:
Dec 26, 2013, 12:48:21 PM (10 years ago)
Author:
mistic100
Message:

update for 2.6

Location:
extensions/instagram2piwigo
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • extensions/instagram2piwigo/admin.php

    r19561 r26199  
    11<?php
    2 if (!defined('INSTAG_PATH')) die('Hacking attempt!');
     2defined('INSTAG_PATH') or die('Hacking attempt!');
    33
    44global $template, $page, $conf;
    55
    6 $conf['Instagram2Piwigo'] = unserialize($conf['Instagram2Piwigo']);
    76load_language('plugin.lang', INSTAG_PATH);
    87
     
    3130  'INSTAG_ADMIN' => INSTAG_ADMIN,
    3231  ));
     32
    3333$template->assign_var_from_handle('ADMIN_CONTENT', 'Instagram2Piwigo');
    34 
    35 ?>
  • extensions/instagram2piwigo/admin/config.php

    r24817 r26199  
    11<?php
    2 if (!defined('INSTAG_PATH')) die('Hacking attempt!');
     2defined('INSTAG_PATH') or die('Hacking attempt!');
    33
    44if (isset($_POST['save_config']))
     
    88    'secret_key' => trim($_POST['secret_key']),
    99    );
     10
    1011  unset($_SESSION['phpinstagram_auth_token']);
    1112  conf_update_param('Instagram2Piwigo', serialize($conf['Instagram2Piwigo']));
     
    2122
    2223
    23 $template->set_filename('Instagram2Piwigo', dirname(__FILE__) . '/template/config.tpl');
    24 
    25 ?>
     24$template->set_filename('Instagram2Piwigo', realpath(INSTAG_PATH . 'admin/template/config.tpl'));
  • extensions/instagram2piwigo/admin/import.php

    r24817 r26199  
    11<?php
    2 if (!defined('INSTAG_PATH')) die('Hacking attempt!');
     2defined('INSTAG_PATH') or die('Hacking attempt!');
    33
    44set_time_limit(600);
     
    77
    88// check API parameters and connect to instagram
    9 if ( empty($conf['Instagram2Piwigo']['api_key']) or empty($conf['Instagram2Piwigo']['secret_key']) )
    10 {
    11   array_push($page['warnings'], l10n('Please fill your API keys on the configuration tab'));
     9if (empty($conf['Instagram2Piwigo']['api_key']) or empty($conf['Instagram2Piwigo']['secret_key']))
     10{
     11  $page['warnings'][] = l10n('Please fill your API keys on the configuration tab');
    1212  $_GET['action'] = 'error';
    1313}
    1414else if (!function_exists('curl_init'))
    1515{
    16   array_push($page['errors'], l10n('No download method available').' (cURL)');
     16  $page['errors'][] = l10n('No download method available').' (cURL)';
    1717  $_GET['action'] = 'error';
    1818}
     
    2525   
    2626    $auth_config = array(
    27         'client_id'         => $conf['Instagram2Piwigo']['api_key'],
    28         'client_secret'    => $conf['Instagram2Piwigo']['secret_key'],
    29         'redirect_uri'      => get_absolute_root_url() . INSTAG_ADMIN . '-import',
    30     );
     27      'client_id'     => $conf['Instagram2Piwigo']['api_key'],
     28      'client_secret' => $conf['Instagram2Piwigo']['secret_key'],
     29      'redirect_uri'  => get_absolute_root_url() . INSTAG_ADMIN . '-import',
     30      );
    3131   
    3232    $auth = new Instagram_Auth($auth_config);
     
    5757
    5858
    59 if (!isset($_GET['action'])) $_GET['action'] = 'main';
     59if (!isset($_GET['action']))
     60{
     61  $_GET['action'] = 'main';
     62}
    6063
    6164
     
    142145    if ($duplicates>0)
    143146    {
    144       $page['infos'][] = '<a href="admin.php?page=batch_manager&amp;prefilter=instagram">'
    145           .l10n_dec('One picture is not displayed because already existing in the database.', '%d pictures are not displayed because already existing in the database.', $duplicates)
     147      $page['infos'][] = '<a href="admin.php?page=batch_manager&amp;filter=prefilter-instagram">'
     148          .l10n_dec(
     149            'One picture is not displayed because already existing in the database.',
     150            '%d pictures are not displayed because already existing in the database.',
     151            $duplicates)
    146152        .'</a>';
    147153    }
     
    195201    if (isset($_POST['done']))
    196202    {
    197       $_SESSION['page_infos'][] = sprintf(l10n('%d pictures imported'), $_POST['done']);
     203      $_SESSION['page_infos'][] = l10n('%d pictures imported', $_POST['done']);
    198204    }
    199205    redirect(INSTAG_ADMIN . '-import');
     
    204210$template->assign('ACTION', $_GET['action']);
    205211
    206 $template->set_filename('Instagram2Piwigo', dirname(__FILE__) . '/template/import.tpl');
    207 
    208 ?>
     212$template->set_filename('Instagram2Piwigo', realpath(INSTAG_PATH . 'admin/template/import.tpl'));
  • extensions/instagram2piwigo/admin/template/config.tpl

    r19561 r26199  
    55<form method="post" action="" class="properties">
    66<fieldset>
    7   <legend>{'Instagram logins'|@translate}</legend>
     7  <legend>{'Instagram logins'|translate}</legend>
    88 
    99  <ul>
     
    2424</fieldset>
    2525
    26 <p><input type="submit" name="save_config" value="{'Save Settings'|@translate}"></p>
     26<p><input type="submit" name="save_config" value="{'Save Settings'|translate}"></p>
    2727
    2828<fieldset>
    29   <legend>{'How do I get my Instagram Client ID ?'|@translate}</legend>
     29  <legend>{'How do I get my Instagram Client ID ?'|translate}</legend>
    3030 
    3131  <p><b>OAuth redirect_uri :</b> <span style="font-family:monospace;font-size:14px;">{$INSTAG_CALLBACK}</span></p>
  • extensions/instagram2piwigo/admin/template/import.list_photos.tpl

    r19711 r26199  
    11{include file='include/colorbox.inc.tpl'}
    22{include file='include/add_album.inc.tpl'}
     3{combine_script id='common' load='footer' path='admin/themes/default/js/common.js'}
    34{combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'}
    45{combine_script id='jquery.jgrowl' load='footer' require='jquery' path='themes/default/js/plugins/jquery.jgrowl_minimized.js'}
    5 {combine_css path="admin/themes/default/uploadify.jGrowl.css"}
     6{combine_css path="themes/default/js/plugins/jquery.jGrowl.css"}
    67
    78{footer_script require='jquery.ajaxmanager,jquery.jgrowl'}
    8 /* global vars */
    9 var nb_thumbs_page = {$nb_thumbs_page};
    10 var nb_thumbs_set = {$nb_thumbs_set};
    11 var all_elements = [{if !empty($all_elements)}{','|@implode:$all_elements}{/if}];
    12 
    13 var errorHead   = '{'ERROR'|@translate|@escape:'javascript'}';
    14 var errorMsg    = '{'an error happened'|@translate|@escape:'javascript'}';
    15 var successHead = '{'Success'|@translate|@escape:'javascript'}';
    16 var selectedMessage_pattern = "{'%d of %d photos selected'|@translate}";
    17 var selectedMessage_none = "{'No photo selected, %d photos in current set'|@translate}";
    18 var selectedMessage_all = "{'All %d photos are selected'|@translate}";
    19 var applyOnDetails_pattern = "{'on the %d selected photos'|@translate}";
    20 
    21 var import_done = 0;
    22 var import_selected = 0;
    23 var queuedManager = jQuery.manageAjax.create('queued', {ldelim}
    24   queue: true, 
    25   maxRequests: 1
    26 });
    27 
    28 {literal}
    29 /* Shift-click: select all photos between the click and the shift+click */
    30 jQuery(document).ready(function() {
     9(function($){
     10  /* global vars */
     11  var nb_thumbs_set = {$nb_thumbs_set};
     12  var all_elements = [{if !empty($all_elements)}{','|@implode:$all_elements}{/if}];
     13  var import_done = 0;
     14  var import_selected = 0;
     15  var queuedManager = $.manageAjax.create('queued', {
     16    queue: true, 
     17    maxRequests: 1
     18  });
     19
     20  /* Shift-click: select all photos between the click and the shift+click */
    3121  var last_clicked=0;
    3222  var last_clickedstatus=true;
    33   jQuery.fn.enableShiftClick = function() {
     23  $.fn.enableShiftClick = function() {
    3424    var inputs = [];
    3525    var count=0;
     
    6656        return true;
    6757      });
    68       $(this).click(function(event) {console.log(event.shiftKey);$(this).triggerHandler("shclick",event)});
     58      $(this).click(function(event) { $(this).triggerHandler("shclick",event); });
    6959    });
    7060  }
    71 });
    72 
    73 /* sprintf */
    74 function str_repeat(i, m) {
    75     for (var o = []; m > 0; o[--m] = i);
    76     return o.join('');
    77 }
    78 
    79 function sprintf() {
    80   var i = 0, a, f = arguments[i++], o = [], m, p, c, x, s = '';
    81   while (f) {
    82     if (m = /^[^\x25]+/.exec(f)) {
    83       o.push(m[0]);
    84     }
    85     else if (m = /^\x25{2}/.exec(f)) {
    86       o.push('%');
    87     }
    88     else if (m = /^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(f)) {
    89       if (((a = arguments[m[1] || i++]) == null) || (a == undefined)) {
    90         throw('Too few arguments.');
    91       }
    92       if (/[^s]/.test(m[7]) && (typeof(a) != 'number')) {
    93         throw('Expecting number but found ' + typeof(a));
    94       }
    95       switch (m[7]) {
    96         case 'b': a = a.toString(2); break;
    97         case 'c': a = String.fromCharCode(a); break;
    98         case 'd': a = parseInt(a); break;
    99         case 'e': a = m[6] ? a.toExponential(m[6]) : a.toExponential(); break;
    100         case 'f': a = m[6] ? parseFloat(a).toFixed(m[6]) : parseFloat(a); break;
    101         case 'o': a = a.toString(8); break;
    102         case 's': a = ((a = String(a)) && m[6] ? a.substring(0, m[6]) : a); break;
    103         case 'u': a = Math.abs(a); break;
    104         case 'x': a = a.toString(16); break;
    105         case 'X': a = a.toString(16).toUpperCase(); break;
    106       }
    107       a = (/[def]/.test(m[7]) && m[2] && a >= 0 ? '+'+ a : a);
    108       c = m[3] ? m[3] == '0' ? '0' : m[3].charAt(1) : ' ';
    109       x = m[5] - String(a).length - s.length;
    110       p = m[5] ? str_repeat(c, x) : '';
    111       o.push(s + (m[4] ? a + p : p + a));
    112     }
    113     else {
    114       throw('Huh ?!');
    115     }
    116     f = f.substring(m[0].length);
    117   }
    118   return o.join('');
    119 }
    120 
    121 /* update displaying */
    122 function checkPermitAction() {
    123   var nbSelected = 0;
    124   if ($("input[name=setSelected]").is(':checked')) {
    125     nbSelected = nb_thumbs_set;
    126   } else {
    127     $(".thumbnails input[type=checkbox]").each(function() {
    128       if ($(this).is(':checked')) nbSelected++;
    129     });
    130   }
    131 
    132   if (nbSelected == 0) {
    133     $("#beginImport").hide();
    134   } else {
    135     $("#beginImport").show();
    136   }
    137 
    138   $("#applyOnDetails").text(
    139     sprintf(
    140       applyOnDetails_pattern,
    141       nbSelected
    142     )
    143   );
    144 
    145   // display the number of currently selected photos in the "Selection" fieldset
    146   if (nbSelected == 0) {
    147     $("#selectedMessage").text(
     61
     62  /* update displaying */
     63  function checkPermitAction() {
     64    var nbSelected = 0;
     65    if ($("input[name=setSelected]").is(':checked')) {
     66      nbSelected = nb_thumbs_set;
     67    }
     68    else {
     69      $(".thumbnails input[type=checkbox]").each(function() {
     70        if ($(this).is(':checked')) nbSelected++;
     71      });
     72    }
     73
     74    if (nbSelected == 0) {
     75      $("#beginImport").hide();
     76    }
     77    else {
     78      $("#beginImport").show();
     79    }
     80
     81    $("#applyOnDetails").text(
    14882      sprintf(
    149         selectedMessage_none,
    150         nb_thumbs_set
     83        '{'on the %d selected photos'|translate|escape:javascript}',
     84        nbSelected
    15185      )
    15286    );
    153   } else if (nbSelected == nb_thumbs_set) {
    154     $("#selectedMessage").text(
    155       sprintf(
    156         selectedMessage_all,
    157         nb_thumbs_set
    158       )
    159     );
    160   } else {
    161     $("#selectedMessage").text(
    162       sprintf(
    163         selectedMessage_pattern,
    164         nbSelected,
    165         nb_thumbs_set
    166       )
    167     );
     87
     88    // display the number of currently selected photos in the "Selection" fieldset
     89    if (nbSelected == 0) {
     90      $("#selectedMessage").text(
     91        sprintf(
     92          '{'No photo selected, %d photos in current set'|translate|escape:javascript}',
     93          nb_thumbs_set
     94        )
     95      );
     96    }
     97    else if (nbSelected == nb_thumbs_set) {
     98      $("#selectedMessage").text(
     99        sprintf(
     100          '{'All %d photos are selected'|translate|escape:javascript}',
     101          nb_thumbs_set
     102        )
     103      );
     104    }
     105    else {
     106      $("#selectedMessage").text(
     107        sprintf(
     108          '{'%d of %d photos selected'|translate|escape:javascript}',
     109          nbSelected,
     110          nb_thumbs_set
     111        )
     112      );
     113    }
    168114  }
    169 }
    170 
    171 /* import queue */
    172 function performImport(photo, album, fills) {
    173   queuedManager.add({
    174     type: 'GET',
    175     dataType: 'json',
    176     url: 'ws.php',
    177     data: { method: 'pwg.images.addInstagram', id: photo, category: album, fills: fills, format: 'json' },
    178     success: function(data) {
    179       if (data['stat'] == 'ok') {
    180         jQuery.jGrowl(data['result'], { theme: 'success', header: successHead, life: 4000, sticky: false });
    181         jQuery("#photo-"+photo).fadeOut(function(){ $(this).remove(); });
    182       } else {
    183         jQuery.jGrowl(data['result'], { theme: 'error', header: errorHead, sticky: true });
     115
     116  /* import queue */
     117  function performImport(photo, album, fills) {
     118    queuedManager.add({
     119      type: 'GET',
     120      dataType: 'json',
     121      url: 'ws.php',
     122      data: {
     123        method: 'pwg.images.addInstagram',
     124        id: photo,
     125        category: album,
     126        fills: fills,
     127        format: 'json'
     128      },
     129      success: function(data) {
     130        if (data['stat'] == 'ok') {
     131          $.jGrowl(data['result'], {
     132            theme: 'success', life: 4000, sticky: false,
     133            header: '{'Success'|translate}'
     134          });
     135          $("#photo-"+photo).fadeOut(function(){ $(this).remove(); });
     136        }
     137        else {
     138          $.jGrowl(data['result'], {
     139            theme: 'error', sticky: true,
     140            header: '{'ERROR'|translate}'
     141          });
     142        }
     143       
     144        import_done++;
     145        $("#progress").html(import_done +"/"+ import_selected);
     146       
     147        if (import_done == import_selected) {
     148          $("#import_form").append('<input type="hidden" name="done" value="' + import_done + '">');
     149          $("#import_form").submit();
     150        }
     151      },
     152      error: function(data) {
     153        $.jGrowl('{'an error happened'|translate|escape:javascript}', {
     154          theme: 'error', sticky: true,
     155          header: '{'ERROR'|translate}'
     156        });
    184157      }
    185      
    186       import_done++;
    187       $("#progress").html(import_done +"/"+ import_selected);
    188      
    189       if (import_done == import_selected) {
    190         $("#import_form").append('<input type="hidden" name="done" value="' + import_done + '">');
    191         $("#import_form").submit();
    192       }
    193     },
    194     error: function(data) {
    195       jQuery.jGrowl(errorMsg, { theme: 'error', header: errorHead, sticky: true });
    196     }
    197   });
    198 }
    199 
    200 
    201 $(document).ready(function() {
     158    });
     159  }
     160
     161
    202162  checkPermitAction();
    203163  $("a.preview-box").colorbox({
     
    216176  /* thumbnail click */
    217177  $(".wrap1 label").click(function (event) {
    218     $("input[name=setSelected]").attr('checked', false);
     178    $("input[name=setSelected]").prop('checked', false);
    219179
    220180    var wrap2 = $(this).children(".wrap2");
     
    235195  /* select all */
    236196  $("#selectAll").click(function () {
    237     $("input[name=setSelected]").attr('checked', false);
     197    $("input[name=setSelected]").prop('checked', false);
    238198   
    239199    $(".thumbnails label").each(function() {
     
    241201      var checkbox = $(this).children("input[type=checkbox]");
    242202
    243       $(checkbox).attr('checked', true);
     203      $(checkbox).prop('checked', true);
    244204      $(wrap2).addClass("thumbSelected");
    245205    });
     
    251211  /* select none */
    252212  $("#selectNone").click(function () {
    253     $("input[name=setSelected]").attr('checked', false);
     213    $("input[name=setSelected]").prop('checked', false);
    254214   
    255215    $(".thumbnails label").each(function() {
     
    257217      var checkbox = $(this).children("input[type=checkbox]");
    258218
    259       $(checkbox).attr('checked', false);
     219      $(checkbox).prop('checked', false);
    260220      $(wrap2).removeClass("thumbSelected");
    261221    });
     
    267227  /* select invert */
    268228  $("#selectInvert").click(function () {
    269     $("input[name=setSelected]").attr('checked', false);
     229    $("input[name=setSelected]").prop('checked', false);
    270230   
    271231    $(".thumbnails label").each(function() {
     
    273233      var checkbox = $(this).children("input[type=checkbox]");
    274234
    275       $(checkbox).attr('checked', !$(checkbox).is(':checked'));
     235      $(checkbox).prop('checked', !$(checkbox).is(':checked'));
    276236
    277237      if ($(checkbox).is(':checked')) {
    278238        $(wrap2).addClass("thumbSelected");
    279       } else {
     239      }
     240      else {
    280241        $(wrap2).removeClass('thumbSelected');
    281242      }
     
    288249  /* select set */
    289250  $("#selectSet").click(function () {
    290     $("input[name=setSelected]").attr('checked', true);
     251    $("input[name=setSelected]").prop('checked', true);
    291252   
    292253    $(".thumbnails label").each(function() {
     
    294255      var checkbox = $(this).children("input[type=checkbox]");
    295256
    296       $(checkbox).attr('checked', true);
     257      $(checkbox).prop('checked', true);
    297258      $(wrap2).addClass("thumbSelected");
    298259    });
     
    303264 
    304265  /* begin import */
    305   jQuery('#beginImport').click(function() {
     266  $('#beginImport').click(function() {
    306267    $("#loader_import").fadeIn();
    307268    var album = $("#albumSelect option:selected").val();
     
    312273    });
    313274   
    314     if (jQuery('input[name="setSelected"]').attr('checked')) {
     275    if ($('input[name="setSelected"]').prop('checked')) {
    315276      import_selected = all_elements.length;
    316277      $("#progress").html("0/"+ import_selected);
     
    319280        performImport(all_elements[i], album, fills);
    320281      }
    321                 } else {
     282                }
     283    else {
    322284      import_selected = $("input[name='selection[]']:checked").length;
    323285      $("#progress").html("0/"+ import_selected);
    324286     
    325                         jQuery("input[name='selection[]']:checked").each(function() {
    326         performImport(jQuery(this).attr('value'), album, fills);
     287                        $("input[name='selection[]']:checked").each(function() {
     288        performImport($(this).attr('value'), album, fills);
    327289      });
    328290    }
     
    332294 
    333295  /* pagination loader */
    334   jQuery('#navigation a').click(function() {
     296  $('#navigation a').click(function() {
    335297    $("#loader_display").fadeIn();
    336298  });
    337 });
    338 {/literal}
     299}(jQuery));
    339300{/footer_script}
    340301
    341 {html_head}
    342 <style type="text/css">
    343 .thumbnails .wrap2 {ldelim} width:128px; height:128px; }
    344 .thumbnail {ldelim} width:100px; }
    345 </style>
    346 {/html_head}
     302
     303{html_style}
     304.thumbnails .wrap2 { width:128px; height:128px; }
     305.thumbnail { width:100px; }
     306{/html_style}
    347307
    348308
     
    351311
    352312  <fieldset>
    353     <legend>{'Selection'|@translate}</legend>
     313    <legend>{'Selection'|translate}</legend>
    354314
    355315  {if !empty($thumbnails)}
    356316    <p id="checkActions">
    357       {'Select:'|@translate}
     317      {'Select:'|translate}
    358318    {if $nb_thumbs_set > $nb_thumbs_page}
    359       <a href="#" id="selectAll">{'The whole page'|@translate}</a>,
    360       <a href="#" id="selectSet">{'The whole set'|@translate}</a>,
     319      <a href="#" id="selectAll">{'The whole page'|translate}</a>,
     320      <a href="#" id="selectSet">{'The whole set'|translate}</a>,
    361321    {else}
    362       <a href="#" id="selectAll">{'All'|@translate}</a>,
     322      <a href="#" id="selectAll">{'All'|translate}</a>,
    363323    {/if}
    364       <a href="#" id="selectNone">{'None'|@translate}</a>,
    365       <a href="#" id="selectInvert">{'Invert'|@translate}</a>
     324      <a href="#" id="selectNone">{'None'|translate}</a>,
     325      <a href="#" id="selectInvert">{'Invert'|translate}</a>
    366326
    367327      <span id="selectedMessage"></span>
    368328      <input type="checkbox" name="setSelected" style="display:none">
    369       <span id="loader_display" style="display:none;"><img src="admin/themes/default/images/ajax-loader.gif"> <i>{'Processing...'|@translate}</i></span>
     329      <span id="loader_display" style="display:none;"><img src="admin/themes/default/images/ajax-loader.gif"> <i>{'Processing...'|translate}</i></span>
    370330    </p>
    371331
     
    376336                                        <label>
    377337                                                <span class="wrap2">
    378                                                 <div class="actions"><a href="{$thumbnail.src}" class="preview-box">{'Zoom'|@translate}</a> &middot; <a href="{$thumbnail.url}" target="_blank" title="{'Open Instagram page in a new tab'|@translate}">Open</a></div>
     338                                                <div class="actions"><a href="{$thumbnail.src}" class="preview-box">{'Zoom'|translate}</a> &middot; <a href="{$thumbnail.url}" target="_blank" title="{'Open Instagram page in a new tab'|translate}">Open</a></div>
    379339                                                        <span>
    380340                                                                <img src="{$thumbnail.thumb}" alt="{$thumbnail.title}" title="{$thumbnail.title|@escape:'html'}" class="thumbnail">
     
    396356    {/if}
    397357   
    398       <div style="float:right;margin-top:10px;">{'display'|@translate}
     358      <div style="float:right;margin-top:10px;">{'display'|translate}
    399359        <a href="{$U_DISPLAY}&amp;display=20">20</a>
    400360        &middot; <a href="{$U_DISPLAY}&amp;display=50">50</a>
    401361        &middot; <a href="{$U_DISPLAY}&amp;display=100">100</a>
    402         &middot; <a href="{$U_DISPLAY}&amp;display=all">{'all'|@translate}</a>
    403         {'photos per page'|@translate}
     362        &middot; <a href="{$U_DISPLAY}&amp;display=all">{'all'|translate}</a>
     363        {'photos per page'|translate}
    404364      </div>
    405365    </div>
    406366
    407367  {else}
    408     <div>{'No photo in the current set.'|@translate}</div>
     368    <div>{'No photo in the current set.'|translate}</div>
    409369  {/if}
    410370  </fieldset>
    411371 
    412372  <fieldset>
    413     <legend>{'Import options'|@translate}</legend>
     373    <legend>{'Import options'|translate}</legend>
    414374
    415375    <p>
    416       <label for="albumSelect"><b>{'Album'|@translate}:</b></label>
     376      <label for="albumSelect"><b>{'Album'|translate}:</b></label>
    417377      <select style="width:400px" name="associate" id="albumSelect" size="1">
    418378        {html_options options=$category_parent_options}
    419379      </select>
    420       {'... or '|@translate}<a href="#" class="addAlbumOpen" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>
     380      {'... or '|translate}<a href="#" class="addAlbumOpen" title="{'create a new album'|translate}">{'create a new album'|translate}</a>
    421381    </p>
    422382   
    423383    <p>
    424       <b>{'Fill these fields from Instagram datas'|@translate}:</b>
    425       <label><input type="checkbox" name="fill_name" checked="checked"> {'Photo name'|@translate}</label>
    426       <label><input type="checkbox" name="fill_author" checked="checked"> {'Author'|@translate}</label>
    427       <label><input type="checkbox" name="fill_tags" checked="checked"> {'Tags'|@translate}</label>
    428       <label><input type="checkbox" name="fill_taken" checked="checked"> {'Creation date'|@translate}</label>
     384      <b>{'Fill these fields from Instagram datas'|translate}:</b>
     385      <label><input type="checkbox" name="fill_name" checked="checked"> {'Photo name'|translate}</label>
     386      <label><input type="checkbox" name="fill_author" checked="checked"> {'Author'|translate}</label>
     387      <label><input type="checkbox" name="fill_tags" checked="checked"> {'Tags'|translate}</label>
     388      <label><input type="checkbox" name="fill_taken" checked="checked"> {'Creation date'|translate}</label>
     389      <label><input type="checkbox" name="fill_geotag" checked="checked"> {'Geolocalization'|translate}</label>
    429390    </p>
    430391
    431392    <p>
    432393      <input type="hidden" name="album" value="{$album}">
    433       <input type="submit" name="import_set" id="beginImport" value="{'Begin transfer'|@translate}" style="display:none;">
    434       <span id="loader_import" style="display:none;"><img src="admin/themes/default/images/ajax-loader.gif"> <i>{'Processing...'|@translate}</i> <span id="progress"></span></span>
     394      <input type="submit" name="import_set" id="beginImport" value="{'Begin transfer'|translate}" style="display:none;">
     395      <span id="loader_import" style="display:none;"><img src="admin/themes/default/images/ajax-loader.gif"> <i>{'Processing...'|translate}</i> <span id="progress"></span></span>
    435396    </p>
    436397  </fieldset>
  • extensions/instagram2piwigo/admin/template/import.tpl

    r19711 r26199  
    88
    99{* <!-- MAIN MENU --> *}
    10 {elseif $ACTION == 'main'}
    11 {footer_script}{literal}
     10{else if $ACTION == 'main'}
     11{footer_script}
    1212jQuery('input[type="submit"]').click(function() {
    1313  window.location.href = $(this).attr("data");
     
    1616  $("#loader_import").fadeIn();
    1717});
    18 {/literal}{/footer_script}
     18{/footer_script}
    1919
    2020<p>
     
    3030
    3131{* <!-- PHOTOS LIST --> *}
    32 {elseif $ACTION == 'list_photos'}
     32{else if $ACTION == 'list_photos'}
    3333{include file=$INSTAG_ABS_PATH|@cat:'admin/template/import.list_photos.tpl'}
    3434
  • extensions/instagram2piwigo/include/functions.inc.php

    r21290 r26199  
    11<?php
    2 if (!defined('INSTAG_PATH')) die('Hacking attempt!');
    3 
    4 /**
    5  * test if a download method is available
    6  * @return: bool
    7  */
    8 if (!function_exists('test_remote_download'))
    9 {
    10   function test_remote_download()
    11   {
    12     return function_exists('curl_init') || ini_get('allow_url_fopen');
    13   }
    14 }
     2defined('INSTAG_PATH') or die('Hacking attempt!');
    153
    164/**
     
    120108  }
    121109}
    122 
    123 ?>
  • extensions/instagram2piwigo/include/ws_functions.inc.php

    r19583 r26199  
    11<?php
    2 if (!defined('INSTAG_PATH')) die('Hacking attempt!');
     2defined('INSTAG_PATH') or die('Hacking attempt!');
    33
    44function instagram_add_ws_method($arr)
     
    1414      'fills' => array('default' =>null),
    1515      ),
    16     'Used by Instagram2Piwigo'
     16    'Used by Instagram2Piwigo',
     17    null,
     18    array('hidden'=>true)
    1719    );
    1820}
     
    2628 
    2729  global $conf;
    28   $conf['Instagram2Piwigo'] = unserialize($conf['Instagram2Piwigo']);
    2930 
    30   if ( empty($conf['Instagram2Piwigo']['api_key']) or empty($conf['Instagram2Piwigo']['secret_key']) )
     31  if (empty($conf['Instagram2Piwigo']['api_key']) or empty($conf['Instagram2Piwigo']['secret_key']))
    3132  {
    3233    return new PwgError(null, l10n('Please fill your API keys on the configuration tab'));
     
    6566    'username' => $photo_f->getUser()->getFullName(true),
    6667    'tags' => $photo_f->getTags()->toArray(),
     68    'location' => $photo_f->getLocation(),
    6769    );
    6870  $photo = array_merge($param, $photo);
     
    9597 
    9698    $updates = array();
    97     if (in_array('fill_name', $photo['fills']))   $updates['name'] = $photo['title'];
     99    if (in_array('fill_name', $photo['fills']))   $updates['name'] = pwg_db_real_escape_string($photo['title']);
    98100    if (in_array('fill_taken', $photo['fills']))  $updates['date_creation'] = $photo['date'];
    99     if (in_array('fill_author', $photo['fills'])) $updates['author'] = $photo['username'];
     101    if (in_array('fill_author', $photo['fills'])) $updates['author'] = pwg_db_real_escape_string($photo['username']);
     102    if (in_array('fill_geotag', $photo['fills']) and !empty($photo['location']) )
     103    {
     104      $updates['latitude'] = pwg_db_real_escape_string($photo['location']->getLat());
     105      $updates['longitude'] = pwg_db_real_escape_string($photo['location']->getLng());
     106    }
    100107   
    101108    if (count($updates))
     
    108115    }
    109116   
    110     if ( !empty($photo['tags']) and in_array('fill_tags', $photo['fills']) )
     117    if (!empty($photo['tags']) and in_array('fill_tags', $photo['fills']))
    111118    {
    112119      $raw_tags = implode(',', $photo['tags']);
     
    115122  }
    116123 
    117   return sprintf(l10n('Photo "%s" imported'), $photo['title']);
     124  return l10n('Photo "%s" imported', $photo['title']);
    118125}
    119 
    120 ?>
  • extensions/instagram2piwigo/main.inc.php

    r24817 r26199  
    99*/
    1010
    11 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     11defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
    1212
    1313global $conf;
    1414
    15 define('INSTAG_PATH', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
    16 define('INSTAG_ADMIN', get_root_url() . 'admin.php?page=plugin-' . basename(dirname(__FILE__)));
     15define('INSTAG_ID',       basename(dirname(__FILE__)));
     16define('INSTAG_PATH',     PHPWG_PLUGINS_PATH . INSTAG_ID . '/');
     17define('INSTAG_ADMIN',    get_root_url() . 'admin.php?page=plugin-' . INSTAG_ID);
    1718define('INSTAG_FS_CACHE', $conf['data_location'].'instagram_cache/');
     19define('INSTAG_VERSION',  'auto');
    1820
     21
     22include_once(INSTAG_PATH . 'include/ws_functions.inc.php');
     23
     24
     25add_event_handler('init', 'instagram_init');
     26add_event_handler('ws_add_methods', 'instagram_add_ws_method');
    1927
    2028if (defined('IN_ADMIN'))
    2129{
    2230  add_event_handler('get_admin_plugin_menu_links', 'instagram_admin_menu');
     31
    2332  add_event_handler('get_batch_manager_prefilters', 'instagram_add_batch_manager_prefilters');
    2433  add_event_handler('perform_batch_manager_prefilters', 'instagram_perform_batch_manager_prefilters', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    25   add_event_handler('loc_begin_admin_page', 'instagram_prefilter_from_url');
    2634
    2735  function instagram_admin_menu($menu)
    2836  {
    29     array_push($menu, array(
     37    $menu[] = array(
    3038      'NAME' => 'Instagram2Piwigo',
    3139      'URL' => INSTAG_ADMIN,
    32     ));
     40      );
    3341    return $menu;
    3442  }
     
    3644  function instagram_add_batch_manager_prefilters($prefilters)
    3745  {
    38     array_push($prefilters, array(
     46    $prefilters[] = array(
    3947      'ID' => 'instagram',
    4048      'NAME' => l10n('Imported from Instagram'),
    41     ));
     49      );
    4250    return $prefilters;
    4351  }
     
    5765    return $filter_sets;
    5866  }
    59  
    60   function instagram_prefilter_from_url()
    61   {
    62     global $page;
    63     if ($page['page'] == 'batch_manager' && @$_GET['prefilter'] == 'instagram')
    64     {
    65       $_SESSION['bulk_manager_filter'] = array('prefilter' => 'instagram');
    66       unset($_GET['prefilter']);
    67     }
    68   }
    6967}
    7068
    7169
    72 include_once(INSTAG_PATH . 'include/ws_functions.inc.php');
     70function instagram_init()
     71{
     72  global $conf;
    7373
    74 add_event_handler('ws_add_methods', 'instagram_add_ws_method');
     74  include_once(INSTAG_PATH . 'maintain.inc.php');
     75  $maintain = new instagram2piwigo_maintain(INSTAG_ID);
     76  $maintain->autoUpdate(INSTAG_VERSION, 'install');
    7577
    76 ?>
     78  $conf['Instagram2Piwigo'] = unserialize($conf['Instagram2Piwigo']);
     79}
  • extensions/instagram2piwigo/maintain.inc.php

    r24817 r26199  
    11<?php
    2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
    33
    4 define(
    5   'Instagram2Piwigo_default_config',
    6   serialize(array(
     4class instagram2piwigo_maintain extends PluginMaintain
     5{
     6  private $installed = false;
     7
     8  private $default_conf = array(
    79    'api_key' => null,
    810    'secret_key' => null,
    9     ))
    10   );
     11    );
    1112
     13  function install($plugin_version, &$errors=array())
     14  {
     15    global $conf;
    1216
    13 function plugin_install()
    14 {
    15   global $conf;
    16  
    17   conf_update_param('Instagram2Piwigo', Instagram2Piwigo_default_config);
    18  
    19   mkdir($conf['data_location'].'instagram_cache/', 0755);
    20 }
     17    if (empty($conf['Instagram2Piwigo']))
     18    {
     19      $conf['Instagram2Piwigo'] = serialize($this->default_conf);
     20      conf_update_param('Instagram2Piwigo', $conf['Instagram2Piwigo']);
     21    }
    2122
    22 function plugin_activate()
    23 {
    24   global $conf;
     23    mkgetdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'instagram_cache/', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
    2524
    26   if (empty($conf['Instagram2Piwigo']))
     25    $this->installed = true;
     26  }
     27
     28  function activate($plugin_version, &$errors=array())
    2729  {
    28     conf_update_param('Instagram2Piwigo', Instagram2Piwigo_default_config);
     30    if (!$this->installed)
     31    {
     32      $this->install($plugin_version, $errors);
     33    }
    2934  }
    30  
    31   if (!file_exists($conf['data_location'].'instagram_cache/'))
     35
     36  function deactivate()
    3237  {
    33     mkdir($conf['data_location'].'instagram_cache/', 0755);
     38  }
     39
     40  function uninstall()
     41  {
     42    global $conf;
     43
     44    conf_delete_param('Instagram2Piwigo');
     45
     46    self::rrmdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'instagram_cache/');
     47  }
     48
     49  static function rrmdir($dir)
     50  {
     51    if (!is_dir($dir))
     52    {
     53      return false;
     54    }
     55    $dir = rtrim($dir, '/');
     56    $objects = scandir($dir);
     57    $return = true;
     58
     59    foreach ($objects as $object)
     60    {
     61      if ($object !== '.' && $object !== '..')
     62      {
     63        $path = $dir.'/'.$object;
     64        if (filetype($path) == 'dir')
     65        {
     66          $return = $return && self::rrmdir($path);
     67        }
     68        else
     69        {
     70          $return = $return && @unlink($path);
     71        }
     72      }
     73    }
     74
     75    return $return && @rmdir($dir);
    3476  }
    3577}
    36 
    37 function plugin_uninstall()
    38 {
    39   global $conf;
    40  
    41   pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "Instagram2Piwigo";');
    42   unset($conf['Instagram2Piwigo']);
    43  
    44   rrmdir($conf['data_location'].'instagram_cache/');
    45 }
    46 
    47 function rrmdir($dir)
    48 {
    49   if (!is_dir($dir))
    50   {
    51     return false;
    52   }
    53   $dir = rtrim($dir, '/');
    54   $objects = scandir($dir);
    55   $return = true;
    56  
    57   foreach ($objects as $object)
    58   {
    59     if ($object !== '.' && $object !== '..')
    60     {
    61       $path = $dir.'/'.$object;
    62       if (filetype($path) == 'dir')
    63       {
    64         $return = $return && rrmdir($path);
    65       }
    66       else
    67       {
    68         $return = $return && @unlink($path);
    69       }
    70     }
    71   }
    72  
    73   return $return && @rmdir($dir);
    74 }
    75 
    76 ?>
Note: See TracChangeset for help on using the changeset viewer.