Changeset 26199
- Timestamp:
- Dec 26, 2013, 12:48:21 PM (10 years ago)
- Location:
- extensions/instagram2piwigo
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/instagram2piwigo/admin.php
r19561 r26199 1 1 <?php 2 if (!defined('INSTAG_PATH'))die('Hacking attempt!');2 defined('INSTAG_PATH') or die('Hacking attempt!'); 3 3 4 4 global $template, $page, $conf; 5 5 6 $conf['Instagram2Piwigo'] = unserialize($conf['Instagram2Piwigo']);7 6 load_language('plugin.lang', INSTAG_PATH); 8 7 … … 31 30 'INSTAG_ADMIN' => INSTAG_ADMIN, 32 31 )); 32 33 33 $template->assign_var_from_handle('ADMIN_CONTENT', 'Instagram2Piwigo'); 34 35 ?> -
extensions/instagram2piwigo/admin/config.php
r24817 r26199 1 1 <?php 2 if (!defined('INSTAG_PATH'))die('Hacking attempt!');2 defined('INSTAG_PATH') or die('Hacking attempt!'); 3 3 4 4 if (isset($_POST['save_config'])) … … 8 8 'secret_key' => trim($_POST['secret_key']), 9 9 ); 10 10 11 unset($_SESSION['phpinstagram_auth_token']); 11 12 conf_update_param('Instagram2Piwigo', serialize($conf['Instagram2Piwigo'])); … … 21 22 22 23 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 1 1 <?php 2 if (!defined('INSTAG_PATH'))die('Hacking attempt!');2 defined('INSTAG_PATH') or die('Hacking attempt!'); 3 3 4 4 set_time_limit(600); … … 7 7 8 8 // 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'));9 if (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'); 12 12 $_GET['action'] = 'error'; 13 13 } 14 14 else if (!function_exists('curl_init')) 15 15 { 16 array_push($page['errors'], l10n('No download method available').' (cURL)');16 $page['errors'][] = l10n('No download method available').' (cURL)'; 17 17 $_GET['action'] = 'error'; 18 18 } … … 25 25 26 26 $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 ); 31 31 32 32 $auth = new Instagram_Auth($auth_config); … … 57 57 58 58 59 if (!isset($_GET['action'])) $_GET['action'] = 'main'; 59 if (!isset($_GET['action'])) 60 { 61 $_GET['action'] = 'main'; 62 } 60 63 61 64 … … 142 145 if ($duplicates>0) 143 146 { 144 $page['infos'][] = '<a href="admin.php?page=batch_manager&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&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) 146 152 .'</a>'; 147 153 } … … 195 201 if (isset($_POST['done'])) 196 202 { 197 $_SESSION['page_infos'][] = sprintf(l10n('%d pictures imported'), $_POST['done']);203 $_SESSION['page_infos'][] = l10n('%d pictures imported', $_POST['done']); 198 204 } 199 205 redirect(INSTAG_ADMIN . '-import'); … … 204 210 $template->assign('ACTION', $_GET['action']); 205 211 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 5 5 <form method="post" action="" class="properties"> 6 6 <fieldset> 7 <legend>{'Instagram logins'| @translate}</legend>7 <legend>{'Instagram logins'|translate}</legend> 8 8 9 9 <ul> … … 24 24 </fieldset> 25 25 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> 27 27 28 28 <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> 30 30 31 31 <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 1 1 {include file='include/colorbox.inc.tpl'} 2 2 {include file='include/add_album.inc.tpl'} 3 {combine_script id='common' load='footer' path='admin/themes/default/js/common.js'} 3 4 {combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'} 4 5 {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"} 6 7 7 8 {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 */ 31 21 var last_clicked=0; 32 22 var last_clickedstatus=true; 33 jQuery.fn.enableShiftClick = function() {23 $.fn.enableShiftClick = function() { 34 24 var inputs = []; 35 25 var count=0; … … 66 56 return true; 67 57 }); 68 $(this).click(function(event) { console.log(event.shiftKey);$(this).triggerHandler("shclick",event)});58 $(this).click(function(event) { $(this).triggerHandler("shclick",event); }); 69 59 }); 70 60 } 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( 148 82 sprintf( 149 selectedMessage_none,150 nb _thumbs_set83 '{'on the %d selected photos'|translate|escape:javascript}', 84 nbSelected 151 85 ) 152 86 ); 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 } 168 114 } 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 }); 184 157 } 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 202 162 checkPermitAction(); 203 163 $("a.preview-box").colorbox({ … … 216 176 /* thumbnail click */ 217 177 $(".wrap1 label").click(function (event) { 218 $("input[name=setSelected]"). attr('checked', false);178 $("input[name=setSelected]").prop('checked', false); 219 179 220 180 var wrap2 = $(this).children(".wrap2"); … … 235 195 /* select all */ 236 196 $("#selectAll").click(function () { 237 $("input[name=setSelected]"). attr('checked', false);197 $("input[name=setSelected]").prop('checked', false); 238 198 239 199 $(".thumbnails label").each(function() { … … 241 201 var checkbox = $(this).children("input[type=checkbox]"); 242 202 243 $(checkbox). attr('checked', true);203 $(checkbox).prop('checked', true); 244 204 $(wrap2).addClass("thumbSelected"); 245 205 }); … … 251 211 /* select none */ 252 212 $("#selectNone").click(function () { 253 $("input[name=setSelected]"). attr('checked', false);213 $("input[name=setSelected]").prop('checked', false); 254 214 255 215 $(".thumbnails label").each(function() { … … 257 217 var checkbox = $(this).children("input[type=checkbox]"); 258 218 259 $(checkbox). attr('checked', false);219 $(checkbox).prop('checked', false); 260 220 $(wrap2).removeClass("thumbSelected"); 261 221 }); … … 267 227 /* select invert */ 268 228 $("#selectInvert").click(function () { 269 $("input[name=setSelected]"). attr('checked', false);229 $("input[name=setSelected]").prop('checked', false); 270 230 271 231 $(".thumbnails label").each(function() { … … 273 233 var checkbox = $(this).children("input[type=checkbox]"); 274 234 275 $(checkbox). attr('checked', !$(checkbox).is(':checked'));235 $(checkbox).prop('checked', !$(checkbox).is(':checked')); 276 236 277 237 if ($(checkbox).is(':checked')) { 278 238 $(wrap2).addClass("thumbSelected"); 279 } else { 239 } 240 else { 280 241 $(wrap2).removeClass('thumbSelected'); 281 242 } … … 288 249 /* select set */ 289 250 $("#selectSet").click(function () { 290 $("input[name=setSelected]"). attr('checked', true);251 $("input[name=setSelected]").prop('checked', true); 291 252 292 253 $(".thumbnails label").each(function() { … … 294 255 var checkbox = $(this).children("input[type=checkbox]"); 295 256 296 $(checkbox). attr('checked', true);257 $(checkbox).prop('checked', true); 297 258 $(wrap2).addClass("thumbSelected"); 298 259 }); … … 303 264 304 265 /* begin import */ 305 jQuery('#beginImport').click(function() {266 $('#beginImport').click(function() { 306 267 $("#loader_import").fadeIn(); 307 268 var album = $("#albumSelect option:selected").val(); … … 312 273 }); 313 274 314 if ( jQuery('input[name="setSelected"]').attr('checked')) {275 if ($('input[name="setSelected"]').prop('checked')) { 315 276 import_selected = all_elements.length; 316 277 $("#progress").html("0/"+ import_selected); … … 319 280 performImport(all_elements[i], album, fills); 320 281 } 321 } else { 282 } 283 else { 322 284 import_selected = $("input[name='selection[]']:checked").length; 323 285 $("#progress").html("0/"+ import_selected); 324 286 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); 327 289 }); 328 290 } … … 332 294 333 295 /* pagination loader */ 334 jQuery('#navigation a').click(function() {296 $('#navigation a').click(function() { 335 297 $("#loader_display").fadeIn(); 336 298 }); 337 }); 338 {/literal} 299 }(jQuery)); 339 300 {/footer_script} 340 301 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} 347 307 348 308 … … 351 311 352 312 <fieldset> 353 <legend>{'Selection'| @translate}</legend>313 <legend>{'Selection'|translate}</legend> 354 314 355 315 {if !empty($thumbnails)} 356 316 <p id="checkActions"> 357 {'Select:'| @translate}317 {'Select:'|translate} 358 318 {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>, 361 321 {else} 362 <a href="#" id="selectAll">{'All'| @translate}</a>,322 <a href="#" id="selectAll">{'All'|translate}</a>, 363 323 {/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> 366 326 367 327 <span id="selectedMessage"></span> 368 328 <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> 370 330 </p> 371 331 … … 376 336 <label> 377 337 <span class="wrap2"> 378 <div class="actions"><a href="{$thumbnail.src}" class="preview-box">{'Zoom'| @translate}</a> · <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> · <a href="{$thumbnail.url}" target="_blank" title="{'Open Instagram page in a new tab'|translate}">Open</a></div> 379 339 <span> 380 340 <img src="{$thumbnail.thumb}" alt="{$thumbnail.title}" title="{$thumbnail.title|@escape:'html'}" class="thumbnail"> … … 396 356 {/if} 397 357 398 <div style="float:right;margin-top:10px;">{'display'| @translate}358 <div style="float:right;margin-top:10px;">{'display'|translate} 399 359 <a href="{$U_DISPLAY}&display=20">20</a> 400 360 · <a href="{$U_DISPLAY}&display=50">50</a> 401 361 · <a href="{$U_DISPLAY}&display=100">100</a> 402 · <a href="{$U_DISPLAY}&display=all">{'all'| @translate}</a>403 {'photos per page'| @translate}362 · <a href="{$U_DISPLAY}&display=all">{'all'|translate}</a> 363 {'photos per page'|translate} 404 364 </div> 405 365 </div> 406 366 407 367 {else} 408 <div>{'No photo in the current set.'| @translate}</div>368 <div>{'No photo in the current set.'|translate}</div> 409 369 {/if} 410 370 </fieldset> 411 371 412 372 <fieldset> 413 <legend>{'Import options'| @translate}</legend>373 <legend>{'Import options'|translate}</legend> 414 374 415 375 <p> 416 <label for="albumSelect"><b>{'Album'| @translate}:</b></label>376 <label for="albumSelect"><b>{'Album'|translate}:</b></label> 417 377 <select style="width:400px" name="associate" id="albumSelect" size="1"> 418 378 {html_options options=$category_parent_options} 419 379 </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> 421 381 </p> 422 382 423 383 <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> 429 390 </p> 430 391 431 392 <p> 432 393 <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> 435 396 </p> 436 397 </fieldset> -
extensions/instagram2piwigo/admin/template/import.tpl
r19711 r26199 8 8 9 9 {* <!-- MAIN MENU --> *} 10 {else if $ACTION == 'main'}11 {footer_script} {literal}10 {else if $ACTION == 'main'} 11 {footer_script} 12 12 jQuery('input[type="submit"]').click(function() { 13 13 window.location.href = $(this).attr("data"); … … 16 16 $("#loader_import").fadeIn(); 17 17 }); 18 {/ literal}{/footer_script}18 {/footer_script} 19 19 20 20 <p> … … 30 30 31 31 {* <!-- PHOTOS LIST --> *} 32 {else if $ACTION == 'list_photos'}32 {else if $ACTION == 'list_photos'} 33 33 {include file=$INSTAG_ABS_PATH|@cat:'admin/template/import.list_photos.tpl'} 34 34 -
extensions/instagram2piwigo/include/functions.inc.php
r21290 r26199 1 1 <?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 } 2 defined('INSTAG_PATH') or die('Hacking attempt!'); 15 3 16 4 /** … … 120 108 } 121 109 } 122 123 ?> -
extensions/instagram2piwigo/include/ws_functions.inc.php
r19583 r26199 1 1 <?php 2 if (!defined('INSTAG_PATH'))die('Hacking attempt!');2 defined('INSTAG_PATH') or die('Hacking attempt!'); 3 3 4 4 function instagram_add_ws_method($arr) … … 14 14 'fills' => array('default' =>null), 15 15 ), 16 'Used by Instagram2Piwigo' 16 'Used by Instagram2Piwigo', 17 null, 18 array('hidden'=>true) 17 19 ); 18 20 } … … 26 28 27 29 global $conf; 28 $conf['Instagram2Piwigo'] = unserialize($conf['Instagram2Piwigo']);29 30 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'])) 31 32 { 32 33 return new PwgError(null, l10n('Please fill your API keys on the configuration tab')); … … 65 66 'username' => $photo_f->getUser()->getFullName(true), 66 67 'tags' => $photo_f->getTags()->toArray(), 68 'location' => $photo_f->getLocation(), 67 69 ); 68 70 $photo = array_merge($param, $photo); … … 95 97 96 98 $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']); 98 100 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 } 100 107 101 108 if (count($updates)) … … 108 115 } 109 116 110 if ( !empty($photo['tags']) and in_array('fill_tags', $photo['fills']))117 if (!empty($photo['tags']) and in_array('fill_tags', $photo['fills'])) 111 118 { 112 119 $raw_tags = implode(',', $photo['tags']); … … 115 122 } 116 123 117 return sprintf(l10n('Photo "%s" imported'), $photo['title']);124 return l10n('Photo "%s" imported', $photo['title']); 118 125 } 119 120 ?> -
extensions/instagram2piwigo/main.inc.php
r24817 r26199 9 9 */ 10 10 11 if (!defined('PHPWG_ROOT_PATH'))die('Hacking attempt!');11 defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); 12 12 13 13 global $conf; 14 14 15 define('INSTAG_PATH', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); 16 define('INSTAG_ADMIN', get_root_url() . 'admin.php?page=plugin-' . basename(dirname(__FILE__))); 15 define('INSTAG_ID', basename(dirname(__FILE__))); 16 define('INSTAG_PATH', PHPWG_PLUGINS_PATH . INSTAG_ID . '/'); 17 define('INSTAG_ADMIN', get_root_url() . 'admin.php?page=plugin-' . INSTAG_ID); 17 18 define('INSTAG_FS_CACHE', $conf['data_location'].'instagram_cache/'); 19 define('INSTAG_VERSION', 'auto'); 18 20 21 22 include_once(INSTAG_PATH . 'include/ws_functions.inc.php'); 23 24 25 add_event_handler('init', 'instagram_init'); 26 add_event_handler('ws_add_methods', 'instagram_add_ws_method'); 19 27 20 28 if (defined('IN_ADMIN')) 21 29 { 22 30 add_event_handler('get_admin_plugin_menu_links', 'instagram_admin_menu'); 31 23 32 add_event_handler('get_batch_manager_prefilters', 'instagram_add_batch_manager_prefilters'); 24 33 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');26 34 27 35 function instagram_admin_menu($menu) 28 36 { 29 array_push($menu,array(37 $menu[] = array( 30 38 'NAME' => 'Instagram2Piwigo', 31 39 'URL' => INSTAG_ADMIN, 32 ));40 ); 33 41 return $menu; 34 42 } … … 36 44 function instagram_add_batch_manager_prefilters($prefilters) 37 45 { 38 array_push($prefilters,array(46 $prefilters[] = array( 39 47 'ID' => 'instagram', 40 48 'NAME' => l10n('Imported from Instagram'), 41 ));49 ); 42 50 return $prefilters; 43 51 } … … 57 65 return $filter_sets; 58 66 } 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 }69 67 } 70 68 71 69 72 include_once(INSTAG_PATH . 'include/ws_functions.inc.php'); 70 function instagram_init() 71 { 72 global $conf; 73 73 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'); 75 77 76 ?> 78 $conf['Instagram2Piwigo'] = unserialize($conf['Instagram2Piwigo']); 79 } -
extensions/instagram2piwigo/maintain.inc.php
r24817 r26199 1 1 <?php 2 if (!defined('PHPWG_ROOT_PATH'))die('Hacking attempt!');2 defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); 3 3 4 define( 5 'Instagram2Piwigo_default_config', 6 serialize(array( 4 class instagram2piwigo_maintain extends PluginMaintain 5 { 6 private $installed = false; 7 8 private $default_conf = array( 7 9 'api_key' => null, 8 10 'secret_key' => null, 9 )) 10 ); 11 ); 11 12 13 function install($plugin_version, &$errors=array()) 14 { 15 global $conf; 12 16 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 } 21 22 22 function plugin_activate() 23 { 24 global $conf; 23 mkgetdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'instagram_cache/', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR); 25 24 26 if (empty($conf['Instagram2Piwigo'])) 25 $this->installed = true; 26 } 27 28 function activate($plugin_version, &$errors=array()) 27 29 { 28 conf_update_param('Instagram2Piwigo', Instagram2Piwigo_default_config); 30 if (!$this->installed) 31 { 32 $this->install($plugin_version, $errors); 33 } 29 34 } 30 31 if (!file_exists($conf['data_location'].'instagram_cache/'))35 36 function deactivate() 32 37 { 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); 34 76 } 35 77 } 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 else67 {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.