Changeset 26201
- Timestamp:
- Dec 26, 2013, 1:22:47 PM (11 years ago)
- Location:
- extensions/pbase2piwigo
- Files:
-
- 2 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/pbase2piwigo/admin.php
r17314 r26201 1 1 <?php 2 if (!defined('PBASE_PATH'))die('Hacking attempt!');2 defined('PBASE_PATH') or die('Hacking attempt!'); 3 3 4 4 global $template, $page, $conf; 5 5 6 // $conf['pbase2piwigo'] = unserialize($conf['pbase2piwigo']);7 6 load_language('plugin.lang', PBASE_PATH); 8 7 … … 21 20 'PBASE_ADMIN' => PBASE_ADMIN, 22 21 )); 22 23 23 $template->assign_var_from_handle('ADMIN_CONTENT', 'pbase2piwigo'); 24 25 ?> -
extensions/pbase2piwigo/admin/import.php
r17434 r26201 1 1 <?php 2 if (!defined('PBASE_PATH'))die('Hacking attempt!');2 defined('PBASE_PATH') or die('Hacking attempt!'); 3 3 4 4 include_once(PBASE_PATH.'include/functions.inc.php'); … … 6 6 $step = null; 7 7 8 if ( test_remote_download() === false)8 if (!test_remote_download()) 9 9 { 10 array_push($page['errors'], l10n('No download method available. PBase2piwigo needs cURL extension or allow_url_fopen=true'));10 $page['errors'][] = l10n('No download method available. PBase2piwigo needs cURL extension or allow_url_fopen=true'); 11 11 } 12 12 else … … 52 52 if (isset($_SESSION['pbase_empty_error'])) 53 53 { 54 array_push($page['errors'], l10n('Import queue is empty'));54 $page['errors'][] = l10n('Import queue is empty'); 55 55 unset($_SESSION['pbase_empty_error']); 56 56 } … … 132 132 $template->assign('STEP', $_GET['action']); 133 133 134 $template->set_filename('pbase2piwigo', dirname(__FILE__) . '/template/import.tpl'); 135 136 ?> 134 $template->set_filename('pbase2piwigo', realpath(PBASE_PATH . 'admin/template/import.tpl')); -
extensions/pbase2piwigo/admin/template/import.analyze.tpl
r17434 r26201 1 1 {combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'} 2 {combine_script id='jquery.jgrowl' load='footer' require='jquery'path='themes/default/js/plugins/jquery.jgrowl_minimized.js'}3 {combine_css path=" admin/themes/default/uploadify.jGrowl.css"}2 {combine_script id='jquery.jgrowl' load='footer' path='themes/default/js/plugins/jquery.jgrowl_minimized.js'} 3 {combine_css path="themes/default/js/plugins/jquery.jGrowl.css"} 4 4 5 5 {footer_script require='jquery.ajaxmanager,jquery.jgrowl'} 6 var errorHead = '{'ERROR'|@translate|@escape:'javascript'}'; 7 var errorMsg = '{'an error happened'|@translate|@escape:'javascript'}'; 8 var successHead = '{'Success'|@translate|@escape:'javascript'}'; 6 (function($){ 7 var queue_lenght = 0; 9 8 10 {literal} 11 var queue_lenght = 0; 9 var queuedManager = $.manageAjax.create('queued', { 10 queue: true, 11 maxRequests: 1 12 }); 12 13 13 var queuedManager = jQuery.manageAjax.create('queued', { 14 queue: true, 15 maxRequests: 1 16 }); 14 function add_cat_to_parse_queue(url, path) { 15 queuedManager.add({ 16 type: 'POST', 17 dataType: 'json', 18 url: 'ws.php?format=json', 19 data: { method: 'pwg.pBase.parse', url: url, path: path }, 20 success: function(data) { 21 if (data['stat'] == 'ok') { 22 cats = data['result']['categories']; 23 for (i in cats) { 24 queue_lenght++; 25 add_cat_to_parse_queue(cats[i]['url'], cats[i]['path']); 26 } 27 $('#preview').html($('#preview').html()+data['result']['path']+"\n"); 28 } 29 else { 30 $.jGrowl(data['message'], { 31 theme: 'error', sticky: true, 32 header: '{'ERROR'|translate}' 33 }); 34 $('.loading').toggle(); 35 } 36 37 queue_lenght--; 38 if (data['stat'] == 'ok' && queue_lenght == 0) { 39 window.location.reload(); 40 } 41 }, 42 error: function () { 43 $.jGrowl('{'an error happened'|translate|escape:javascript}', { 44 theme: 'error', sticky: true, 45 header: '{'ERROR'|translate}' 46 }); 47 $('.loading').toggle(); 48 } 49 }); 50 } 17 51 18 function add_cat_to_parse_queue(url, path) { 19 queuedManager.add({ 20 type: 'POST', 21 dataType: 'json', 22 url: 'ws.php?format=json', 23 data: { method: 'pwg.pBase.parse', url: url, path: path }, 24 success: function(data) { 25 if (data['stat'] == 'ok') { 26 cats = data['result']['categories']; 27 for (i in cats) { 28 queue_lenght++; 29 add_cat_to_parse_queue(cats[i]['url'], cats[i]['path']); 30 } 31 $('#preview').html($('#preview').html()+data['result']['path']+"\n"); 32 } else { 33 jQuery.jGrowl(data['message'], { theme: 'error', header: errorHead, sticky: true }); 34 jQuery('.loading').toggle(); 35 } 36 37 queue_lenght--; 38 if (data['stat'] == 'ok' && queue_lenght == 0) { 39 window.location.reload(); 40 } 41 }, 42 error: function () { 43 jQuery.jGrowl(errorMsg, { theme: 'error', header: errorHead, sticky: true }); 44 jQuery('.loading').toggle(); 52 $('#begin_analyse').click(function() { 53 login = $('#pbase_login').val(); 54 55 if (login != '') { 56 queue_lenght++; 57 add_cat_to_parse_queue('http://www.pbase.com/'+ login +'/root', '/root'); 58 $('.loading').toggle(); 45 59 } 60 return false; 46 61 }); 47 } 48 {/literal} 49 50 jQuery('#begin_analyse').click(function() {ldelim} 51 login = $('#pbase_login').val(); 52 53 if (login != '') {ldelim} 54 queue_lenght++; 55 add_cat_to_parse_queue('http://www.pbase.com/'+ login +'/root', '/root'); 56 jQuery('.loading').toggle(); 57 } 58 return false; 59 }); 62 }(jQuery)); 60 63 {/footer_script} 61 64 62 65 63 66 <form action="{$PBASE_ADMIN}-import" method="post"> 64 <p><label>{'PBase login'|@translate} <input type="text" id="pbase_login"></label></p>65 <p class="loading"><input type="submit" id="begin_analyse" value="{'Begin analyse'|@translate}"></p>66 <p class="loading" style="display:none;"><img src="{$PBASE_PATH}admin/template/loader-{$themeconf.name}.gif"></p>67 <p><label>{'PBase login'|translate} <input type="text" id="pbase_login"></label></p> 68 <p class="loading"><input type="submit" id="begin_analyse" value="{'Begin analyse'|translate}"></p> 69 <p class="loading" style="display:none;"><img src="{$PBASE_PATH}admin/template/loader-{$themeconf.name}.gif"></p> 67 70 </form> 68 71 -
extensions/pbase2piwigo/admin/template/import.config.tpl
r17434 r26201 2 2 {include file='include/add_album.inc.tpl'} 3 3 4 {footer_script require='jquery.ui.resizable'} {literal}4 {footer_script require='jquery.ui.resizable'} 5 5 jQuery(".categoryList").resizable({ 6 6 handles: "s,e,se", … … 9 9 ghost: true 10 10 }); 11 {/ literal}{/footer_script}11 {/footer_script} 12 12 13 13 <form action="{$F_ACTION}" method="post"> 14 14 <fieldset> 15 <legend>{'Select albums to import'| @translate}</legend>15 <legend>{'Select albums to import'|translate}</legend> 16 16 17 17 <select name="categories[]" class="categoryList" multiple="multiple" size="20"> … … 19 19 </select> 20 20 21 <b>{'Nb albums'| @translate}</b>: {$nb_categories}<br>22 <b>{'Nb photos'| @translate}</b>: {$nb_pictures}<br>21 <b>{'Nb albums'|translate}</b>: {$nb_categories}<br> 22 <b>{'Nb photos'|translate}</b>: {$nb_pictures}<br> 23 23 24 24 <br> 25 <a href="{$RESET_LINK}" onClick="return confirm('{'Are you sure?'| @translate}');">{'Reset'|@translate}</a>25 <a href="{$RESET_LINK}" onClick="return confirm('{'Are you sure?'|translate}');">{'Reset'|translate}</a> 26 26 </fieldset> 27 27 28 28 <fieldset> 29 <legend>{'Configuration'| @translate}</legend>29 <legend>{'Configuration'|translate}</legend> 30 30 31 <p><label><input type="checkbox" name="recursive" value="1" checked="checked"> <b>{'Recursive'| @translate}</b></label></p>31 <p><label><input type="checkbox" name="recursive" value="1" checked="checked"> <b>{'Recursive'|translate}</b></label></p> 32 32 33 33 <p id="albumSelectWrapper"> 34 <b>{'Import in this album'| @translate}:</b>34 <b>{'Import in this album'|translate}:</b> 35 35 <select style="width:400px" name="parent_category" id="albumSelect" size="1"> 36 36 <option value="0">------------</option> 37 37 {html_options options=$category_parent_options} 38 38 </select> 39 {'... or '| @translate}<a href="#" class="addAlbumOpen" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>39 {'... or '|translate}<a href="#" class="addAlbumOpen" title="{'create a new album'|translate}">{'create a new album'|translate}</a> 40 40 </p> 41 41 42 42 <p> 43 <b>{'Fill these fields from pBase datas'| @translate}:</b>44 <label><input type="checkbox" name="fills[]" value="fill_name" checked="checked"> {'Photo name'| @translate}</label>45 <label><input type="checkbox" name="fills[]" value="fill_author" checked="checked"> {'Author'| @translate}</label>46 <label><input type="checkbox" name="fills[]" value="fill_tags" checked="checked"> {'Tags'| @translate}</label>47 <label><input type="checkbox" name="fills[]" value="fill_taken" checked="checked"> {'Creation date'| @translate}</label>48 <label><input type="checkbox" name="fills[]" value="fill_comment" checked="checked"> {'Description'| @translate}</label>43 <b>{'Fill these fields from pBase datas'|translate}:</b> 44 <label><input type="checkbox" name="fills[]" value="fill_name" checked="checked"> {'Photo name'|translate}</label> 45 <label><input type="checkbox" name="fills[]" value="fill_author" checked="checked"> {'Author'|translate}</label> 46 <label><input type="checkbox" name="fills[]" value="fill_tags" checked="checked"> {'Tags'|translate}</label> 47 <label><input type="checkbox" name="fills[]" value="fill_taken" checked="checked"> {'Creation date'|translate}</label> 48 <label><input type="checkbox" name="fills[]" value="fill_comment" checked="checked"> {'Description'|translate}</label> 49 49 </p> 50 50 </fieldset> 51 51 52 52 <p class="bottomButtons"> 53 <input type="submit" value="{'Begin transfer'| @translate}">53 <input type="submit" value="{'Begin transfer'|translate}"> 54 54 </p> 55 55 </form> -
extensions/pbase2piwigo/admin/template/import.init_import.tpl
r17434 r26201 1 1 {combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'} 2 {combine_script id='jquery.jgrowl' load='footer' require='jquery' path='themes/default/js/plugins/jquery.jgrowl_minimized.js'} 2 {combine_script id='jquery.jgrowl' load='footer' path='themes/default/js/plugins/jquery.jgrowl_minimized.js'} 3 {combine_css path="themes/default/js/plugins/jquery.jGrowl.css"} 4 3 5 {combine_script id='MultiGetSet' load='header' path=$PBASE_PATH|cat:'admin/template/MultiGetSet.js'} 4 {combine_css path="admin/themes/default/uploadify.jGrowl.css"}5 6 6 7 {footer_script require='jquery.ajaxmanager,jquery.jgrowl'} 7 var errorHead = '{'ERROR'|@translate|@escape:'javascript'}'; 8 var errorMsg = '{'an error happened'|@translate|@escape:'javascript'}'; 9 var successHead = '{'Success'|@translate|@escape:'javascript'}'; 10 var errors_final_msg = '{'%1$d errors occured. %2$d albums and %3$d photos added.'|@translate}'; 8 (function($){ 9 var errors_final_msg = '{'%1$d errors occured. %2$d albums and %3$d photos added.'|translate|escape:javascript}'; 10 var final_manage_link = '{'Manage this set of %d photos'|translate}'; 11 11 12 {literal} 13 // custom classe for counters listening 14 var MyClass = function(){ 15 var public = this; 16 var private = {}; 17 18 private.lenght = 0; 19 private.errors = 0; 20 private.categories = 0; 21 private.pictures = 0; 22 23 MultiGetSet({ 24 public: public, 25 private: private, 26 handler: Observable 12 // custom class for counters listening 13 var MyClass = function(){ 14 var public = this; 15 var private = {}; 16 17 private.lenght = 0; 18 private.errors = 0; 19 private.categories = 0; 20 private.pictures = 0; 21 22 MultiGetSet({ 23 public: public, 24 private: private, 25 handler: Observable 26 }); 27 }; 28 29 var queue = new MyClass(); 30 31 queue.listen("lenght", function(opt){ 32 if (opt.newValue == 0) { 33 $(".loading").css('display', 'none'); 34 if (queue.get("errors") == 0) { 35 $(".infos").css('display', 'block'); 36 } 37 else { 38 errors_final_msg = errors_final_msg.replace('%1$d', queue.get("errors")); 39 errors_final_msg = errors_final_msg.replace('%2$d', queue.get("categories")); 40 errors_final_msg = errors_final_msg.replace('%3$d', queue.get("pictures")); 41 final_manage_link = final_manage_link.replac('%d', queue.get("pictures")); 42 43 $(".warnings").css('display', '').find('.i').html(errors_final_msg); 44 $(".warnings").find('.a').html('<a href="{$MANAGE_LINK}">' + final_manage_link + '</a>'); 45 } 46 } 27 47 }); 28 }; 29 30 var queue = new MyClass(); 31 32 queue.listen("lenght", function(opt){ 33 if (opt.newValue == 0) { 34 $(".loading").css('display', 'none'); 35 if (queue.get("errors") == 0) { 36 $(".infos").css('display', 'block'); 37 } else { 38 errors_final_msg = errors_final_msg.replace('%1$d', queue.get("errors")); 39 errors_final_msg = errors_final_msg.replace('%2$d', queue.get("categories")); 40 errors_final_msg = errors_final_msg.replace('%3$d', queue.get("pictures")); 41 42 $(".warnings").css('display', '').html('<ul><li>'+ errors_final_msg +'</li></ul>'); 43 } 44 } 45 }); 46 queue.listen("categories", function(opt) { 47 $(".nb_categories").html(opt.newValue); 48 }); 49 queue.listen("pictures", function(opt) { 50 $(".nb_pictures").html(opt.newValue); 51 }); 52 queue.listen("errors", function(opt) { 53 $(".nb_errors").html(opt.newValue); 54 }); 48 queue.listen("categories", function(opt) { 49 $(".nb_categories").html(opt.newValue); 50 }); 51 queue.listen("pictures", function(opt) { 52 $(".nb_pictures").html(opt.newValue); 53 }); 54 queue.listen("errors", function(opt) { 55 $(".nb_errors").html(opt.newValue); 56 }); 55 57 56 58 57 var queuedManager = jQuery.manageAjax.create('queued', {58 queue: true,59 maxRequests: 160 });59 var queuedManager = $.manageAjax.create('queued', { 60 queue: true, 61 maxRequests: 1 62 }); 61 63 62 function add_cat_to_add_queue(path, parent_id, recursive, fills) { 63 queuedManager.add({ 64 type: 'POST', 65 dataType: 'json', 66 url: 'ws.php?format=json', 67 data: { method: 'pwg.pBase.addCat', path: path, parent_id: parent_id, recursive: recursive }, 68 success: function(data) { 69 if (data['stat'] == 'ok') { 70 data = data['result']; 71 72 for (i in data['pictures']) { 73 queue.increment("lenght"); 74 add_picture_to_add_queue(data['pictures'][i], data['category_id'], fills); 64 function add_cat_to_add_queue(path, parent_id, recursive, fills) { 65 queuedManager.add({ 66 type: 'POST', 67 dataType: 'json', 68 url: 'ws.php?format=json', 69 data: { 70 method: 'pwg.pBase.addCat', 71 path: path, 72 parent_id: parent_id, 73 recursive: recursive 74 }, 75 success: function(data) { 76 if (data['stat'] == 'ok') { 77 data = data['result']; 78 79 for (i in data['pictures']) { 80 queue.increment("lenght"); 81 add_picture_to_add_queue(data['pictures'][i], data['category_id'], fills); 82 } 83 if (recursive) { 84 for (i in data['categories']) { 85 queue.increment("lenght"); 86 add_cat_to_add_queue(data['categories'][i], data['category_id'], recursive, fills); 87 } 88 } 89 90 $.jGrowl(data['message'], { 91 theme: 'success', life: 4000, sticky: false, 92 header: '{'Success'|translate}' 93 }); 94 queue.increment("categories"); 75 95 } 76 if (recursive) { 77 for (i in data['categories']) { 78 queue.increment("lenght"); 79 add_cat_to_add_queue(data['categories'][i], data['category_id'], recursive, fills); 80 } 96 else { 97 $.jGrowl(data['result'], { 98 theme: 'error', sticky: true, 99 header: '{'ERROR'|translate}' 100 }); 101 queue.increment("errors"); 81 102 } 82 103 83 jQuery.jGrowl(data['message'], { theme: 'success', header: successHead, life: 4000, sticky: false }); 84 queue.increment("categories"); 85 } else { 86 jQuery.jGrowl(data['result'], { theme: 'error', header: errorHead, sticky: true }); 104 queue.decrement("lenght"); 105 }, 106 error: function () { 107 $.jGrowl('{'an error happened'|translate|escape:javascript}', { 108 theme: 'error', sticky: true, 109 header: '{'ERROR'|translate}' 110 }); 87 111 queue.increment("errors"); 88 112 } 89 90 queue.decrement("lenght"); 91 }, 92 error: function () { 93 jQuery.jGrowl(errorMsg, { theme: 'error', header: errorHead, sticky: true }); 94 queue.increment("errors"); 95 } 96 }); 97 } 113 }); 114 } 98 115 99 function add_picture_to_add_queue(url, cat_id, fills) { 100 queuedManager.add({ 101 type: 'POST', 102 dataType: 'json', 103 url: 'ws.php?format=json', 104 data: { method: 'pwg.pBase.addImage', url: url, category: cat_id, fills: fills }, 105 success: function(data) { 106 if (data['stat'] == 'ok') { 107 jQuery.jGrowl(data['result'], { theme: 'success', header: successHead, life: 2000, sticky: false }); 108 queue.increment("pictures"); 109 } else { 110 jQuery.jGrowl(data['result'], { theme: 'error', header: errorHead, sticky: true }); 116 function add_picture_to_add_queue(url, cat_id, fills) { 117 queuedManager.add({ 118 type: 'POST', 119 dataType: 'json', 120 url: 'ws.php?format=json', 121 data: { 122 method: 'pwg.pBase.addImage', 123 url: url, 124 category: cat_id, 125 fills: fills 126 }, 127 success: function(data) { 128 if (data['stat'] == 'ok') { 129 $.jGrowl(data['result'], { 130 theme: 'success', life: 2000, sticky: false, 131 header: '{'Success'|translate}' 132 }); 133 queue.increment("pictures"); 134 } 135 else { 136 $.jGrowl(data['result'], { 137 theme: 'error', sticky: true, 138 header: '{'ERROR'|translate}' 139 }); 140 queue.increment("errors"); 141 } 142 143 queue.decrement("lenght"); 144 }, 145 error: function () { 146 $.jGrowl('{'an error happened'|translate|escape:javascript}', { 147 theme: 'error', sticky: true, 148 header: '{'ERROR'|translate}' 149 }); 111 150 queue.increment("errors"); 112 151 } 113 114 queue.decrement("lenght"); 115 }, 116 error: function () { 117 jQuery.jGrowl(errorMsg, { theme: 'error', header: errorHead, sticky: true }); 118 queue.increment("errors"); 119 } 120 }); 121 } 122 {/literal} 152 }); 153 } 123 154 124 {foreach from=$categories item=cat}125 add_cat_to_add_queue('{$cat}', {$PARENT_CATEGORY}, {$RECURSIVE}, '{$FILLS}');126 {/foreach}155 {foreach from=$categories item=cat} 156 add_cat_to_add_queue('{$cat}', {$PARENT_CATEGORY}, {$RECURSIVE}, '{$FILLS}'); 157 {/foreach} 127 158 128 queue.set("lenght", {$categories|@count}); 159 queue.set("lenght", {$categories|@count}); 160 }(jQuery)); 129 161 {/footer_script} 130 162 … … 132 164 <div class="infos" style="display:none;"> 133 165 <ul> 134 <li>{'Completed. %1$d albums and %2$d photos added.'|@translate|sprintf:$nb_categories:$nb_pictures}</li> 166 <li>{'Completed. %1$d albums and %2$d photos added.'|translate:$nb_categories:$nb_pictures}</li> 167 <li><a href="{$MANAGE_LINK}">{'Manage this set of %d photos'|translate:$nb_pictures}</a></li> 135 168 </ul> 136 169 </div> 137 170 <div class="warnings" style="display:none;"> 138 171 <ul> 139 <li>null</li> 172 <li class="i"></li> 173 <li class="a"></li> 140 174 </ul> 141 175 </div> 142 176 143 177 <p> 144 <b>{'Nb albums'| @translate}</b>: <span class="nb_categories">0</span>/{$nb_categories}<br>145 <b>{'Nb photos'| @translate}</b>: <span class="nb_pictures">0</span>/{$nb_pictures}<br>146 <b>{'Errors'| @translate}</b>: <span class="nb_errors">0</span><br>178 <b>{'Nb albums'|translate}</b>: <span class="nb_categories">0</span>/{$nb_categories}<br> 179 <b>{'Nb photos'|translate}</b>: <span class="nb_pictures">0</span>/{$nb_pictures}<br> 180 <b>{'Errors'|translate}</b>: <span class="nb_errors">0</span><br> 147 181 <br> 148 182 <img class="loading" src="{$PBASE_PATH}admin/template/loader-{$themeconf.name}.gif"> 149 183 </p> 150 151 {* <a href="{$MANAGE_LINK}">{'Manage this set of %d photos'|@translate|sprintf:$nb_pictures}</a> *} -
extensions/pbase2piwigo/admin/template/import.tpl
r17225 r26201 1 {combine_css path=$PBASE_PATH|@cat:"admin/template/style.css"}2 3 4 1 <div class="titrePage"> 5 2 <h2>PBase2Piwigo</h2> … … 10 7 {include file=$PBASE_ABS_PATH|@cat:'admin/template/import.analyze.tpl'} 11 8 12 {else if $STEP == 'config'}9 {else if $STEP == 'config'} 13 10 {include file=$PBASE_ABS_PATH|@cat:'admin/template/import.config.tpl'} 14 11 15 {else if $STEP == 'init_import'}12 {else if $STEP == 'init_import'} 16 13 {include file=$PBASE_ABS_PATH|@cat:'admin/template/import.init_import.tpl'} 17 14 -
extensions/pbase2piwigo/include/functions.inc.php
r21291 r26201 1 1 <?php 2 if (!defined('PBASE_PATH'))die('Hacking attempt!');2 defined('PBASE_PATH') or die('Hacking attempt!'); 3 3 4 4 /** … … 306 306 307 307 /** 308 * count pictures and cats in the selected cat 309 * @param: &array tree 310 * @param: string $path 311 * @param: &int nb pictures 312 * @param: &int nb categories 313 * @param: bool recursive 314 * @return: void 315 */ 316 function count_pictures_cats(&$tree, $path, &$nb_pictures, &$nb_categories, $recursive=true) 317 { 318 $current = &get_current_cat($tree, $path); 319 $nb_pictures+= $current['nb_pictures']; 320 $nb_categories++; 321 322 if ( $recursive and !empty($current['categories']) ) 323 { 324 foreach ($current['categories'] as $cat) 325 { 326 count_pictures_cats($tree, $cat['path'], $nb_pictures, $nb_categories, $recursive); 327 } 328 } 329 } 330 331 /** 308 332 * test if a download method is available 309 333 * @return: bool … … 421 445 422 446 return false; 423 }424 }425 426 /**427 * count pictures and cats in the selected cat428 * @param: &array tree429 * @param: string $path430 * @param: &int nb pictures431 * @param: &int nb categories432 * @param: bool recursive433 * @return: void434 */435 function count_pictures_cats(&$tree, $path, &$nb_pictures, &$nb_categories, $recursive=true)436 {437 $current = &get_current_cat($tree, $path);438 $nb_pictures+= $current['nb_pictures'];439 $nb_categories++;440 441 if ( $recursive and !empty($current['categories']) )442 {443 foreach ($current['categories'] as $cat)444 {445 count_pictures_cats($tree, $cat['path'], $nb_pictures, $nb_categories, $recursive);446 }447 447 } 448 448 } … … 516 516 } 517 517 } 518 519 ?> -
extensions/pbase2piwigo/include/ws_functions.inc.php
r24661 r26201 1 1 <?php 2 if (!defined('PBASE_PATH'))die('Hacking attempt!');2 defined('PBASE_PATH') or die('Hacking attempt!'); 3 3 4 4 function pbase_add_ws_method($arr) … … 14 14 'fills' => array('default' => 'fill_name,fill_taken,fill_author,fill_comment,fill_tags'), 15 15 ), 16 'Used by PBase2Piwigo' 16 'Used by PBase2Piwigo', 17 null, 18 array('hidden'=>true) 17 19 ); 18 20 … … 25 27 'recursive' => array('default' => true), 26 28 ), 27 'Used by PBase2Piwigo' 29 'Used by PBase2Piwigo', 30 null, 31 array('hidden'=>true) 28 32 ); 29 33 … … 35 39 'path' => array(), 36 40 ), 37 'Used by PBase2Piwigo' 41 'Used by PBase2Piwigo', 42 null, 43 array('hidden'=>true) 38 44 ); 39 45 } … … 56 62 include_once(PBASE_PATH.'include/functions.inc.php'); 57 63 58 if ( test_remote_download() === false)64 if (!test_remote_download()) 59 65 { 60 66 return new PwgError(null, l10n('No download method available')); … … 127 133 else 128 134 { 129 $ category_id = ws_categories_add(array(135 $new_cat = $service->invoke('pwg.categories.add', array( 130 136 'name' => $category['title'].' <!--pbase-->', 131 137 'parent' => $params['parent_id'], 132 138 'comment' => pwg_db_real_escape_string($category['description']), 133 ) , $service);134 $category_id = $ category_id['id'];139 )); 140 $category_id = $new_cat['id']; 135 141 } 136 142 … … 140 146 'pictures' => array(), 141 147 'categories' => array(), 142 'message' => sprintf(l10n('Album "%s" created'), $category['title']),148 'message' => l10n('Album "%s" created', $category['title']), 143 149 ); 144 150 145 151 foreach ($category['pictures'] as &$pict) 146 152 { 147 array_push($output['pictures'], $pict['url']);153 $output['pictures'][] = $pict['url']; 148 154 } 149 155 if ($params['recursive']) … … 151 157 foreach ($category['categories'] as &$cat) 152 158 { 153 array_push($output['categories'], $cat['path']);159 $output['categories'][] = $cat['path']; 154 160 } 155 161 } … … 231 237 } 232 238 233 if ( !empty($photo['keywords']) and in_array('fill_tags', $params['fills']))239 if (!empty($photo['keywords']) and in_array('fill_tags', $params['fills'])) 234 240 { 235 241 $raw_tags = implode(',', $photo['keywords']); … … 239 245 } 240 246 241 return sprintf(l10n('Photo "%s" imported'), $photo['title']); 242 } 243 244 ?> 247 return l10n('Photo "%s" imported', $photo['title']); 248 } -
extensions/pbase2piwigo/main.inc.php
r24661 r26201 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('PBASE_PATH', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); 16 define('PBASE_ADMIN', get_root_url() . 'admin.php?page=plugin-' . basename(dirname(__FILE__))); 15 define('PBASE_ID', basename(dirname(__FILE__))); 16 define('PBASE_PATH', PHPWG_PLUGINS_PATH . PBASE_ID . '/'); 17 define('PBASE_ADMIN', get_root_url() . 'admin.php?page=plugin-' . PBASE_ID); 17 18 define('PBASE_FS_CACHE', PHPWG_ROOT_PATH . $conf['data_location'] . 'pbase_cache/'); 18 19 20 21 include_once(PBASE_PATH . 'include/ws_functions.inc.php'); 22 23 24 add_event_handler('ws_add_methods', 'pbase_add_ws_method'); 19 25 20 26 if (defined('IN_ADMIN')) … … 22 28 add_event_handler('get_admin_plugin_menu_links', 'pbase_admin_menu'); 23 29 30 add_event_handler('get_batch_manager_prefilters', 'pbase_add_batch_manager_prefilters'); 31 add_event_handler('perform_batch_manager_prefilters', 'pbase_perform_batch_manager_prefilters', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); 32 24 33 function pbase_admin_menu($menu) 25 34 { 26 array_push($menu,array(35 $menu[] = array( 27 36 'NAME' => 'PBase2Piwigo', 28 37 'URL' => PBASE_ADMIN, 29 ));38 ); 30 39 return $menu; 31 40 } 41 42 function pbase_add_batch_manager_prefilters($prefilters) 43 { 44 $prefilters[] = array( 45 'ID' => 'pbase', 46 'NAME' => l10n('Imported from PBase'), 47 ); 48 return $prefilters; 49 } 50 51 function pbase_perform_batch_manager_prefilters($filter_sets, $prefilter) 52 { 53 if ($prefilter == 'pbase') 54 { 55 $query = ' 56 SELECT id 57 FROM '.IMAGES_TABLE.' 58 WHERE file LIKE "pbase-%" 59 ;'; 60 $filter_sets[] = array_from_query($query, 'id'); 61 } 62 63 return $filter_sets; 64 } 32 65 } 33 34 35 include_once(PBASE_PATH . 'include/ws_functions.inc.php');36 37 add_event_handler('ws_add_methods', 'pbase_add_ws_method');38 39 ?>
Note: See TracChangeset
for help on using the changeset viewer.