Changeset 26201


Ignore:
Timestamp:
Dec 26, 2013, 1:22:47 PM (7 years ago)
Author:
mistic100
Message:

update for 2.6

Location:
extensions/pbase2piwigo
Files:
2 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • extensions/pbase2piwigo/admin.php

    r17314 r26201  
    11<?php
    2 if (!defined('PBASE_PATH')) die('Hacking attempt!');
     2defined('PBASE_PATH') or die('Hacking attempt!');
    33
    44global $template, $page, $conf;
    55
    6 // $conf['pbase2piwigo'] = unserialize($conf['pbase2piwigo']);
    76load_language('plugin.lang', PBASE_PATH);
    87
     
    2120  'PBASE_ADMIN' => PBASE_ADMIN,
    2221  ));
     22
    2323$template->assign_var_from_handle('ADMIN_CONTENT', 'pbase2piwigo');
    24 
    25 ?>
  • extensions/pbase2piwigo/admin/import.php

    r17434 r26201  
    11<?php
    2 if (!defined('PBASE_PATH')) die('Hacking attempt!');
     2defined('PBASE_PATH') or die('Hacking attempt!');
    33
    44include_once(PBASE_PATH.'include/functions.inc.php');
     
    66$step = null;
    77
    8 if (test_remote_download() === false)
     8if (!test_remote_download())
    99{
    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');
    1111}
    1212else
     
    5252    if (isset($_SESSION['pbase_empty_error']))
    5353    {
    54       array_push($page['errors'], l10n('Import queue is empty'));
     54      $page['errors'][] = l10n('Import queue is empty');
    5555      unset($_SESSION['pbase_empty_error']);
    5656    }
     
    132132$template->assign('STEP', $_GET['action']);
    133133
    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  
    11{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"}
    44
    55{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;
    98
    10 {literal}
    11 var queue_lenght = 0;
     9  var queuedManager = $.manageAjax.create('queued', {
     10    queue: true, 
     11    maxRequests: 1
     12  });
    1213
    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  }
    1751
    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();
    4559    }
     60    return false;
    4661  });
    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));
    6063{/footer_script}
    6164
    6265
    6366<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>
    6770</form>
    6871
  • extensions/pbase2piwigo/admin/template/import.config.tpl

    r17434 r26201  
    22{include file='include/add_album.inc.tpl'}
    33
    4 {footer_script require='jquery.ui.resizable'}{literal}
     4{footer_script require='jquery.ui.resizable'}
    55jQuery(".categoryList").resizable({
    66  handles: "s,e,se",
     
    99  ghost: true
    1010});
    11 {/literal}{/footer_script}
     11{/footer_script}
    1212
    1313<form action="{$F_ACTION}" method="post">
    1414<fieldset>
    15   <legend>{'Select albums to import'|@translate}</legend>
     15  <legend>{'Select albums to import'|translate}</legend>
    1616 
    1717  <select name="categories[]" class="categoryList" multiple="multiple" size="20">
     
    1919  </select>
    2020 
    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>
    2323 
    2424  <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>
    2626</fieldset>
    2727
    2828<fieldset>
    29   <legend>{'Configuration'|@translate}</legend>
     29  <legend>{'Configuration'|translate}</legend>
    3030 
    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>
    3232 
    3333  <p id="albumSelectWrapper">
    34     <b>{'Import in this album'|@translate}:</b>
     34    <b>{'Import in this album'|translate}:</b>
    3535    <select style="width:400px" name="parent_category" id="albumSelect" size="1">
    3636      <option value="0">------------</option>
    3737      {html_options options=$category_parent_options}
    3838    </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>
    4040  </p>
    4141   
    4242  <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>
    4949  </p>
    5050</fieldset>
    5151
    5252  <p class="bottomButtons">
    53     <input type="submit" value="{'Begin transfer'|@translate}">   
     53    <input type="submit" value="{'Begin transfer'|translate}">   
    5454  </p>
    5555</form>
  • extensions/pbase2piwigo/admin/template/import.init_import.tpl

    r17434 r26201  
    11{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
    35{combine_script id='MultiGetSet' load='header' path=$PBASE_PATH|cat:'admin/template/MultiGetSet.js'}
    4 {combine_css path="admin/themes/default/uploadify.jGrowl.css"}
    56
    67{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}';
    1111
    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    }
    2747  });
    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  });
    5557
    5658
    57 var queuedManager = jQuery.manageAjax.create('queued', {
    58   queue: true, 
    59   maxRequests: 1
    60 });
     59  var queuedManager = $.manageAjax.create('queued', {
     60    queue: true, 
     61    maxRequests: 1
     62  });
    6163
    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");
    7595        }
    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");
    81102        }
    82103       
    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        });
    87111        queue.increment("errors");
    88112      }
    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  }
    98115
    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        });
    111150        queue.increment("errors");
    112151      }
    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  }
    123154
    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}
    127158
    128 queue.set("lenght", {$categories|@count});
     159  queue.set("lenght", {$categories|@count});
     160}(jQuery));
    129161{/footer_script}
    130162
     
    132164<div class="infos" style="display:none;">
    133165  <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>
    135168  </ul>
    136169</div>
    137170<div class="warnings" style="display:none;">
    138171  <ul>
    139     <li>null</li>
     172    <li class="i"></li>
     173    <li class="a"></li>
    140174  </ul>
    141175</div>
    142176
    143177<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>
    147181  <br>
    148182  <img class="loading" src="{$PBASE_PATH}admin/template/loader-{$themeconf.name}.gif">
    149183</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 
    41<div class="titrePage">
    52        <h2>PBase2Piwigo</h2>
     
    107{include file=$PBASE_ABS_PATH|@cat:'admin/template/import.analyze.tpl'}
    118
    12 {elseif $STEP == 'config'}
     9{else if $STEP == 'config'}
    1310{include file=$PBASE_ABS_PATH|@cat:'admin/template/import.config.tpl'}
    1411
    15 {elseif $STEP == 'init_import'}
     12{else if $STEP == 'init_import'}
    1613{include file=$PBASE_ABS_PATH|@cat:'admin/template/import.init_import.tpl'}
    1714 
  • extensions/pbase2piwigo/include/functions.inc.php

    r21291 r26201  
    11<?php
    2 if (!defined('PBASE_PATH')) die('Hacking attempt!');
     2defined('PBASE_PATH') or die('Hacking attempt!');
    33
    44/**
     
    306306
    307307/**
     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 */
     316function 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/**
    308332 * test if a download method is available
    309333 * @return: bool
     
    421445   
    422446    return false;
    423   }
    424 }
    425 
    426 /**
    427  * count pictures and cats in the selected cat
    428  * @param: &array tree
    429  * @param: string $path
    430  * @param: &int nb pictures
    431  * @param: &int nb categories
    432  * @param: bool recursive
    433  * @return: void
    434  */
    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     }
    447447  }
    448448}
     
    516516  }
    517517}
    518 
    519 ?>
  • extensions/pbase2piwigo/include/ws_functions.inc.php

    r24661 r26201  
    11<?php
    2 if (!defined('PBASE_PATH')) die('Hacking attempt!');
     2defined('PBASE_PATH') or die('Hacking attempt!');
    33
    44function pbase_add_ws_method($arr)
     
    1414      'fills' => array('default' => 'fill_name,fill_taken,fill_author,fill_comment,fill_tags'),
    1515      ),
    16     'Used by PBase2Piwigo'
     16    'Used by PBase2Piwigo',
     17    null,
     18    array('hidden'=>true)
    1719    );
    1820   
     
    2527      'recursive' => array('default' => true),
    2628      ),
    27     'Used by PBase2Piwigo'
     29    'Used by PBase2Piwigo',
     30    null,
     31    array('hidden'=>true)
    2832    );
    2933   
     
    3539      'path' => array(),
    3640      ),
    37     'Used by PBase2Piwigo'
     41    'Used by PBase2Piwigo',
     42    null,
     43    array('hidden'=>true)
    3844    );
    3945}
     
    5662  include_once(PBASE_PATH.'include/functions.inc.php');
    5763 
    58   if (test_remote_download() === false)
     64  if (!test_remote_download())
    5965  {
    6066    return new PwgError(null, l10n('No download method available'));
     
    127133  else
    128134  {
    129     $category_id = ws_categories_add(array(
     135    $new_cat = $service->invoke('pwg.categories.add', array(
    130136      'name' => $category['title'].' <!--pbase-->',
    131137      'parent' => $params['parent_id'],
    132138      'comment' => pwg_db_real_escape_string($category['description']),
    133       ), $service);
    134     $category_id = $category_id['id'];
     139      ));
     140    $category_id = $new_cat['id'];
    135141  }
    136142 
     
    140146    'pictures' => array(),
    141147    'categories' => array(),
    142     'message' => sprintf(l10n('Album "%s" created'), $category['title']),
     148    'message' => l10n('Album "%s" created', $category['title']),
    143149    );
    144150   
    145151  foreach ($category['pictures'] as &$pict)
    146152  {
    147     array_push($output['pictures'], $pict['url']);
     153    $output['pictures'][] = $pict['url'];
    148154  }
    149155  if ($params['recursive'])
     
    151157    foreach ($category['categories'] as &$cat)
    152158    {
    153       array_push($output['categories'], $cat['path']);
     159      $output['categories'][] = $cat['path'];
    154160    }
    155161  }
     
    231237      }
    232238     
    233       if ( !empty($photo['keywords']) and in_array('fill_tags', $params['fills']) )
     239      if (!empty($photo['keywords']) and in_array('fill_tags', $params['fills']))
    234240      {
    235241        $raw_tags = implode(',', $photo['keywords']);
     
    239245  }
    240246 
    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  
    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('PBASE_PATH',     PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
    16 define('PBASE_ADMIN',    get_root_url() . 'admin.php?page=plugin-' . basename(dirname(__FILE__)));
     15define('PBASE_ID',       basename(dirname(__FILE__)));
     16define('PBASE_PATH',     PHPWG_PLUGINS_PATH . PBASE_ID . '/');
     17define('PBASE_ADMIN',    get_root_url() . 'admin.php?page=plugin-' . PBASE_ID);
    1718define('PBASE_FS_CACHE', PHPWG_ROOT_PATH . $conf['data_location'] . 'pbase_cache/');
    1819
     20
     21include_once(PBASE_PATH . 'include/ws_functions.inc.php');
     22
     23
     24add_event_handler('ws_add_methods', 'pbase_add_ws_method');
    1925
    2026if (defined('IN_ADMIN'))
     
    2228  add_event_handler('get_admin_plugin_menu_links', 'pbase_admin_menu');
    2329
     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
    2433  function pbase_admin_menu($menu)
    2534  {
    26     array_push($menu, array(
     35    $menu[] = array(
    2736      'NAME' => 'PBase2Piwigo',
    2837      'URL' => PBASE_ADMIN,
    29     ));
     38      );
    3039    return $menu;
    3140  }
     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  }
    3265}
    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.