Changeset 17314
- Timestamp:
- Aug 2, 2012, 6:38:10 PM (12 years ago)
- Location:
- extensions/pbase2piwigo
- Files:
-
- 2 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/pbase2piwigo/admin.php
r17225 r17314 12 12 } 13 13 14 // tabsheet15 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');16 $page['tab'] = (isset($_GET['tab'])) ? $_GET['tab'] : $page['tab'] = 'import';17 18 $tabsheet = new tabsheet();19 $tabsheet->add('import', l10n('Import'), PBASE_ADMIN . '-import');20 // $tabsheet->add('config', l10n('Configuration'), PBASE_ADMIN . '-config');21 $tabsheet->select($page['tab']);22 $tabsheet->assign();23 24 14 // include page 25 include(PBASE_PATH . 'admin/ ' . $page['tab'] . '.php');15 include(PBASE_PATH . 'admin/import.php'); 26 16 27 17 // template -
extensions/pbase2piwigo/admin/import.php
r17225 r17314 50 50 case 'config': 51 51 { 52 if (isset($_SESSION['pbase_empty_error'])) 53 { 54 array_push($page['errors'], l10n('Import queue is empty')); 55 unset($_SESSION['pbase_empty_error']); 56 } 57 58 // counters 59 $nb_categories = $nb_pictures = 0; 60 count_pictures_cats($tree, '/root', $nb_pictures, $nb_categories, true); 61 62 // get piwigo categories 63 $query = ' 64 SELECT id, name, uppercats, global_rank 65 FROM '.CATEGORIES_TABLE.' 66 ;'; 67 display_select_cat_wrapper($query, array(), 'associate_options'); 68 display_select_cat_wrapper($query, array(), 'category_parent_options'); 69 52 70 $template->assign(array( 71 'nb_categories' => $nb_categories-1, // don't count root 72 'nb_pictures' => $nb_pictures, 53 73 'F_ACTION' => PBASE_ADMIN.'-import&action=init_import', 54 74 'RESET_LINK' => PBASE_ADMIN.'-import&action=reset_tree', … … 61 81 { 62 82 $categories = $_POST['categories']; 83 $nb_categories = $nb_pictures = 0; 63 84 64 // remove duplicate categories (in case of recursive mode)65 85 if (isset($_POST['recursive'])) 66 86 { 87 // we don't add "root", only it's children 88 if (@$categories[0] == '/root') 89 { 90 $temp = &get_current_cat($tree, '/root'); 91 $categories = array_merge($categories, array_values(array_unique_deep($temp['categories'], 'path'))); 92 $categories = array_unique($categories); 93 unset($categories[0]); 94 } 95 96 // remove duplicate categories (in case of recursive mode) 67 97 foreach ($categories as &$path) 68 98 { … … 77 107 // count pictures and cats 78 108 $temp_cats = $categories; 79 $nb_categories = $nb_pictures = 0;80 109 foreach ($temp_cats as $path) 81 110 { 82 111 count_pictures_cats($tree, $path, $nb_pictures, $nb_categories, isset($_POST['recursive'])); 112 } 113 114 if ($nb_pictures == 0) 115 { 116 $_SESSION['pbase_empty_error'] = true; 117 redirect(PBASE_ADMIN.'-import'); 83 118 } 84 119 … … 87 122 'nb_categories' => $nb_categories, 88 123 'categories' => $categories, 124 'PARENT_CATEGORY' => $_POST['parent_category'], 89 125 'RECURSIVE' => boolean_to_string(isset($_POST['recursive'])), 90 126 'FILLS' => implode(',', @$_POST['fills']), -
extensions/pbase2piwigo/admin/template/import.config.tpl
r17225 r17314 1 {include file='include/colorbox.inc.tpl'} 2 {include file='include/add_album.inc.tpl'} 3 1 4 {footer_script require='jquery.ui.resizable'}{literal} 2 5 jQuery(".categoryList").resizable({ … … 10 13 <form action="{$F_ACTION}" method="post"> 11 14 <fieldset> 12 <legend>{' Choosealbums to import'|@translate}</legend>15 <legend>{'Select albums to import'|@translate}</legend> 13 16 14 17 <select name="categories[]" class="categoryList" multiple="multiple" size="20"> … … 16 19 </select> 17 20 21 <b>{'Nb albums'|@translate}</b>: {$nb_categories}<br> 22 <b>{'Nb photos'|@translate}</b>: {$nb_pictures}<br> 23 18 24 <br> 19 <a href="{$RESET_LINK}" onClick="return confirm('{'Are you sure?'|@translate}');"> Reset</a>25 <a href="{$RESET_LINK}" onClick="return confirm('{'Are you sure?'|@translate}');">{'Reset'|@translate}</a> 20 26 </fieldset> 21 27 … … 23 29 <legend>{'Configuration'|@translate}</legend> 24 30 25 <p><label><input type="checkbox" name="recursive" value="1" checked="checked"> <b>Recursive</b></label></p> 31 <p><label><input type="checkbox" name="recursive" value="1" checked="checked"> <b>{'Recursive'|@translate}</b></label></p> 32 33 <p id="albumSelectWrapper"> 34 <b>{'Import in this album'|@translate}:</b> 35 <select style="width:400px" name="parent_category" id="albumSelect" size="1"> 36 <option value="0">------------</option> 37 {html_options options=$associate_options} 38 </select> 39 {'... or '|@translate}<a href="#" class="addAlbumOpen" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a> 40 </p> 41 26 42 <p> 27 43 <b>{'Fill these fields from pBase datas'|@translate}:</b> … … 35 51 36 52 <p class="bottomButtons"> 37 <input type="submit" value=" Begin Transfer">53 <input type="submit" value="{'Begin transfer'|@translate}"> 38 54 </p> 39 55 </form> -
extensions/pbase2piwigo/admin/template/import.init_import.tpl
r17225 r17314 123 123 124 124 {foreach from=$categories item=cat} 125 add_cat_to_add_queue('{$cat}', 0, {$RECURSIVE}, '{$FILLS}');125 add_cat_to_add_queue('{$cat}', {$PARENT_CATEGORY}, {$RECURSIVE}, '{$FILLS}'); 126 126 {/foreach} 127 127 … … 137 137 <div class="warnings" style="display:none;"> 138 138 <ul> 139 <li> hohiho</li>139 <li>null</li> 140 140 </ul> 141 141 </div> 142 142 143 143 <p> 144 <b> Nb albums</b>: <span class="nb_categories">0</span>/{$nb_categories}<br>145 <b> Nb pictures</b>: <span class="nb_pictures">0</span>/{$nb_pictures}<br>146 <b> Errors</b>: <span class="nb_errors">0</span><br>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> 147 147 <br> 148 148 <img class="loading" src="{$PBASE_PATH}admin/template/loader-{$themeconf.name}.gif"> -
extensions/pbase2piwigo/include/functions.inc.php
r17225 r17314 309 309 * @return: bool 310 310 */ 311 function test_remote_download() 312 { 313 return function_exists('curl_init') || ini_get('allow_url_fopen'); 311 if (!function_exists('test_remote_download')) 312 { 313 function test_remote_download() 314 { 315 return function_exists('curl_init') || ini_get('allow_url_fopen'); 316 } 314 317 } 315 318 316 319 /** 317 320 * download a remote file 318 * @param: string source 319 * @param: string destination 320 * @return: bool 321 */ 322 function download_remote_file($src, $dest) 323 { 324 if (function_exists('curl_init')) 325 { 326 $newf = fopen($dest, "wb"); 327 $ch = curl_init(); 328 329 curl_setopt($ch, CURLOPT_URL, $src); 330 curl_setopt($ch, CURLOPT_HEADER, 0); 331 curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept-language: en")); 332 curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)'); 333 curl_setopt($ch, CURLOPT_FILE, $newf); 334 335 if (curl_exec($ch) === false) 336 { 337 return 'file_error'; 338 } 339 340 curl_close($ch); 341 fclose($newf); 342 343 return true; 344 } 345 else if (ini_get('allow_url_fopen')) 346 { 347 $opts = array( 348 'http' => array( 349 'method' => "GET", 350 'user_agent' => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)', 351 'header' => "Accept-language: en", 352 ) 353 ); 354 355 $context = stream_context_create($opts); 356 357 if (($file = file_get_contents($src, false, $context)) === false) 358 { 359 return 'file_error'; 360 } 361 file_put_contents($dest, $file); 362 363 return true; 364 } 365 366 return false; 321 * - needs cURL or allow_url_fopen 322 * - take care of SSL urls 323 * 324 * @param: string source url 325 * @param: mixed destination file (if true, file content is returned) 326 */ 327 if (!function_exists('download_remote_file')) 328 { 329 function download_remote_file($src, $dest) 330 { 331 if (empty($src)) 332 { 333 return false; 334 } 335 336 $return = ($dest === true) ? true : false; 337 338 /* curl */ 339 if (function_exists('curl_init')) 340 { 341 if (!$return) 342 { 343 $newf = fopen($dest, "wb"); 344 } 345 $ch = curl_init(); 346 347 curl_setopt($ch, CURLOPT_URL, $src); 348 curl_setopt($ch, CURLOPT_HEADER, 0); 349 curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept-language: en")); 350 curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)'); 351 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 352 curl_setopt($ch, CURLOPT_MAXREDIRS, 1); 353 if (strpos($src, 'https://') !== false) 354 { 355 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 356 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 357 } 358 if (!$return) 359 { 360 curl_setopt($ch, CURLOPT_FILE, $newf); 361 } 362 else 363 { 364 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 365 } 366 367 if (($out = curl_exec($ch)) === false) 368 { 369 return 'file_error'; 370 } 371 372 curl_close($ch); 373 374 if (!$return) 375 { 376 fclose($newf); 377 return true; 378 } 379 else 380 { 381 return $out; 382 } 383 } 384 /* file get content */ 385 else if (ini_get('allow_url_fopen')) 386 { 387 if (strpos($src, 'https://') !== false and !extension_loaded('openssl')) 388 { 389 return false; 390 } 391 392 $opts = array( 393 'http' => array( 394 'method' => "GET", 395 'user_agent' => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)', 396 'header' => "Accept-language: en", 397 ) 398 ); 399 400 $context = stream_context_create($opts); 401 402 if (($file = file_get_contents($src, false, $context)) === false) 403 { 404 return 'file_error'; 405 } 406 407 if (!$return) 408 { 409 file_put_contents($dest, $file); 410 return true; 411 } 412 else 413 { 414 return $file; 415 } 416 } 417 418 return false; 419 } 367 420 } 368 421 … … 397 450 * @return: array 398 451 */ 399 function array_unique_deep(&$array, $key) 400 { 401 $values = array(); 402 foreach ($array as $k1 => $row) 403 { 404 foreach ($row as $k2 => $v) 405 { 406 if ($k2 == $key) 407 { 408 $values[ $k1 ] = $v; 409 continue; 410 } 411 } 412 } 413 return array_unique($values); 452 if (!function_exists('array_unique_deep')) 453 { 454 function array_unique_deep(&$array, $key) 455 { 456 $values = array(); 457 foreach ($array as $k1 => $row) 458 { 459 foreach ($row as $k2 => $v) 460 { 461 if ($k2 == $key) 462 { 463 $values[ $k1 ] = $v; 464 continue; 465 } 466 } 467 } 468 return array_unique($values); 469 } 414 470 } 415 471 … … 423 479 * @return key or array of keys 424 480 */ 425 function array_pos($needle, &$haystack, $match_all=false, $preg_mode=false)426 { 427 if ($match_all) $matches = array();428 429 foreach ($haystack as $i => $row)430 {431 if (!is_array($row))432 { 433 if (! $preg_mode)434 { 435 if ( strpos($row, $needle) !== false)481 if (!function_exists('array_pos')) 482 { 483 function array_pos($needle, &$haystack, $match_all=false, $preg_mode=false) 484 { 485 if ($match_all) $matches = array(); 486 487 foreach ($haystack as $i => $row) 488 { 489 if (!is_array($row)) 490 { 491 if (!$preg_mode) 436 492 { 437 if (!$match_all) return $i; 438 else array_push($matches, $i); 493 if (strpos($row, $needle) !== false) 494 { 495 if (!$match_all) return $i; 496 else array_push($matches, $i); 497 } 439 498 } 440 } 441 else 442 { 443 if (preg_match($needle, $row) === 1) 499 else 444 500 { 445 if (!$match_all) return $i; 446 else array_push($matches, $i); 501 if (preg_match($needle, $row) === 1) 502 { 503 if (!$match_all) return $i; 504 else array_push($matches, $i); 505 } 447 506 } 448 507 } 449 508 } 450 }451 452 if ( !$match_all or !count($matches) ) return false;453 return $matches;509 510 if ( !$match_all or !count($matches) ) return false; 511 return $matches; 512 } 454 513 } 455 514 -
extensions/pbase2piwigo/include/ws_functions.inc.php
r17225 r17314 111 111 $category = &get_current_cat($tree, $params['path']); 112 112 113 if ($category['path'] == '/root')114 {115 $category['title'] = 'Import PBase';116 }117 118 113 // add category 119 114 $query = ' … … 143 138 'pictures' => array(), 144 139 'categories' => array(), 145 'message' => sprintf(l10n('Album "%s" added'), $category['title']),140 'message' => sprintf(l10n('Album "%s" created'), $category['title']), 146 141 ); 147 142 -
extensions/pbase2piwigo/language/en_UK/description.txt
r17225 r17314 1 Extension for importing pictures from PBase1 Import photos from PBase -
extensions/pbase2piwigo/language/en_UK/plugin.lang.php
r17225 r17314 1 1 <?php 2 2 3 3 $lang['No download method available. PBase2piwigo needs cURL extension or allow_url_fopen=true'] = 'No download method available. PBase2piwigo needs cURL extension or allow_url_fopen=true'; 4 $lang['Import queue is empty'] = 'Import queue is empty'; 5 $lang['Invalid user id'] = 'Invalid user id'; 6 $lang['Album "%s" created'] = 'Album "%s" created'; 7 $lang['Photo "%s" imported'] = 'Photo "%s" imported'; 8 $lang['PBase login'] = 'PBase login'; 9 $lang['Begin analyse'] = 'Begin analyse'; 10 $lang['Select albums to import'] = 'Select albums to import'; 11 $lang['Nb albums'] = 'Nb albums'; 12 $lang['Nb photos'] = 'Nb photos'; 13 $lang['Import in this album'] = 'Import in this album'; 14 $lang['Fill these fields from pBase datas'] = 'Fill these fields from pBase datas'; 15 $lang['%1$d errors occured. %2$d albums and %3$d photos added.'] = '%1$d errors occured. %2$d albums and %3$d photos added.'; 16 $lang['Completed. %1$d albums and %2$d photos added.'] = 'Completed. %1$d albums and %2$d photos added.'; 17 $lang['Errors'] = 'Errors'; 18 $lang['Recursive'] = 'Recursive'; 19 $lang['Begin transfer'] = 'Begin transfer'; 4 20 5 21 ?> -
extensions/pbase2piwigo/language/fr_FR/description.txt
r17225 r17314 1 Extension pour importerdes photos depuis PBase1 Importez des photos depuis PBase -
extensions/pbase2piwigo/language/fr_FR/plugin.lang.php
r17225 r17314 1 1 <?php 2 2 3 $lang['No download method available. PBase2piwigo needs cURL extension or allow_url_fopen=true'] = 'Aucune fonction de téléchargement disponible. PBase2Piwigo a besoin de l\'extension cURL ou du réglage allow_url_fopen=true'; 4 $lang['Import queue is empty'] = 'File d\'attente vide'; 5 $lang['Invalid user id'] = 'Identifiant invdalie'; 6 $lang['Album "%s" created'] = 'Album "%s" créé'; 7 $lang['Photo "%s" imported'] = 'Photo "%s" importée'; 8 $lang['PBase login'] = 'Identifiant PBase'; 9 $lang['Begin analyse'] = 'Démarre l\'analyse'; 10 $lang['Select albums to import'] = 'Selectionnez les albums à importer'; 11 $lang['Nb albums'] = 'Nb d\'albums'; 12 $lang['Nb photos'] = 'Nb de photos'; 13 $lang['Import in this album'] = 'Importer dans cet album'; 14 $lang['Fill these fields from pBase datas'] = 'Remplir ces champs à partir des données de PBase'; 15 $lang['%1$d errors occured. %2$d albums and %3$d photos added.'] = '%1$d erreurs. %2$d albums et %3$d photos ajoutés.'; 16 $lang['Completed. %1$d albums and %2$d photos added.'] = 'Terminé. %1$d albums et %2$d photos ajoutés.'; 17 $lang['Errors'] = 'Erreurs'; 18 $lang['Recursive'] = 'Recursif'; 19 $lang['Begin transfer'] = 'Démarrer le transfert'; 3 20 4 21 -
extensions/pbase2piwigo/main.inc.php
r17225 r17314 3 3 Plugin Name: PBase2Piwigo 4 4 Version: auto 5 Description: Extension for importing pictures from PBase6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid= 5 Description: Import photos from PBase 6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=627 7 7 Author: Mistic 8 8 Author URI: http://www.strangeplanet.fr
Note: See TracChangeset
for help on using the changeset viewer.