Changeset 17476


Ignore:
Timestamp:
Aug 8, 2012, 1:55:06 PM (12 years ago)
Author:
mistic100
Message:

some code corrections

Location:
extensions/flickr2piwigo
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • extensions/flickr2piwigo/admin/import.php

    r17313 r17476  
    33
    44set_time_limit(600);
     5
     6include_once(PICASA_WA_PATH . 'include/functions.inc.php');
    57
    68// check API parameters and connect to flickr
     
    1012  $_GET['action'] = 'error';
    1113}
    12 else if ( !function_exists('curl_init') and !ini_get('allow_url_fopen') )
     14else if ( !test_remote_download() )
    1315{
    1416  array_push($page['errors'], l10n('No download method available'));
     
    154156;';
    155157    $existing_photos = simple_hash_from_query($query, 'id', 'file');
    156     $existing_photos = array_map(create_function('$p', '$p=preg_replace("#^'.$flickr_prefix.'([0-9]+)\.([a-z]{3,4})$#i", "$1", $p); return $p;'), $existing_photos);
     158    $existing_photos = array_map(create_function('$p', 'return preg_replace("#^'.$flickr_prefix.'([0-9]+)\.([a-z]{3,4})$#i", "$1", $p);'), $existing_photos);
    157159   
    158160    // remove existing photos
     
    199201  FROM '.CATEGORIES_TABLE.'
    200202;';
    201     display_select_cat_wrapper($query, array(), 'associate_options');
    202203    display_select_cat_wrapper($query, array(), 'category_parent_options');
    203204   
     
    223224   
    224225    $all_photos = array();
    225     foreach ($all_albums as &$album)
     226    foreach ($all_albums as $album)
    226227    {
    227228      $album_photos = $flickr->photosets_getPhotos($album['id'], NULL, NULL, 500, NULL, 'photos');
    228229      $album_photos = $album_photos['photoset']['photo'];
    229230     
    230       foreach ($album_photos as &$photo)
     231      foreach ($album_photos as $photo)
    231232      {
    232233        $all_photos[ $photo['id'] ][] = $album['title'];
    233234      }
    234       unset($photo);
    235     }
    236     unset($album);
     235    }
    237236   
    238237    // get existing photos
     
    243242;';
    244243    $existing_photos = simple_hash_from_query($query, 'id', 'file');
    245     $existing_photos = array_map(create_function('$p', '$p=preg_replace("#^'.$flickr_prefix.'([0-9]+)\.([a-z]{3,4})$#i", "$1", $p); return $p;'), $existing_photos);
     244    $existing_photos = array_map(create_function('$p', 'return preg_replace("#^'.$flickr_prefix.'([0-9]+)\.([a-z]{3,4})$#i", "$1", $p);'), $existing_photos);
    246245   
    247246    // remove existing photos
     
    281280  FROM '.CATEGORIES_TABLE.'
    282281;';
    283     display_select_cat_wrapper($query, array(), 'associate_options', true);
    284282    display_select_cat_wrapper($query, array(), 'category_parent_options');
    285283    break;
  • extensions/flickr2piwigo/admin/template/import.list_all.tpl

    r17313 r17476  
    5757    $("#loader_import").fadeIn();
    5858   
    59     if ($("input[name='album_mode']").val() == 'identical') {
     59    if ($("input[name='album_mode']:checked").val() == 'identical') {
    6060      var album = 0;
    6161    } else {
     
    115115    <p id="albumSelectWrapper" style="display:none;">
    116116      <select style="width:400px" name="associate" id="albumSelect" size="1">
    117         {html_options options=$associate_options}
     117        {html_options options=$category_parent_options}
    118118      </select>
    119119      {'... or '|@translate}<a href="#" class="addAlbumOpen" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>
  • extensions/flickr2piwigo/admin/template/import.list_photos.tpl

    r17313 r17476  
    405405      <label for="albumSelect"><b>{'Album'|@translate}:</b></label>
    406406      <select style="width:400px" name="associate" id="albumSelect" size="1">
    407         {html_options options=$associate_options}
     407        {html_options options=$category_parent_options}
    408408      </select>
    409409      {'... or '|@translate}<a href="#" class="addAlbumOpen" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>
  • extensions/flickr2piwigo/admin/template/style.css

    r16064 r17476  
    66  margin-top:20px;
    77}
     8UL.thumbnails span.wrap2 {
     9  height: 128px;
     10  width: 128px;
     11}
  • extensions/flickr2piwigo/include/functions.inc.php

    r17312 r17476  
    11<?php
    22if (!defined('FLICKR_PATH')) die('Hacking attempt!');
     3
     4/**
     5 * test if a download method is available
     6 * @return: bool
     7 */
     8if (!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}
    315
    416/**
     
    3143     
    3244      curl_setopt($ch, CURLOPT_URL, $src);
    33       curl_setopt($ch, CURLOPT_HEADER, 0);
     45      curl_setopt($ch, CURLOPT_HEADER, false);
    3446      curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept-language: en"));
    3547      curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)');
    3648      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    3749      curl_setopt($ch, CURLOPT_MAXREDIRS, 1);
     50      curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    3851      if (strpos($src, 'https://') !== false)
    3952      {
     
    5063      }
    5164     
    52       if (($out = curl_exec($ch)) === false)
     65      $out = curl_exec($ch);
     66      curl_close($ch);
     67     
     68      if ($out === false)
    5369      {
    5470        return 'file_error';
    5571      }
    56      
    57       curl_close($ch);
    58      
    59       if (!$return)
     72      else if (!$return)
    6073      {
    6174        fclose($newf);
  • extensions/flickr2piwigo/include/ws_functions.inc.php

    r17312 r17476  
    1010    'ws_images_addFlickr',
    1111    array(
    12       'category' => array('default' => null),   
    13       'id' => array('default' => null),
     12      'id' => array(),
     13      'category' => array(),
    1414      'fills' => array('default' =>null),
    1515      ),
    16     'Used by Flickr2Piwigo, fills € (fill_name,fill_posted,fill_taken,fill_author,fill_tags)'
     16    'Used by Flickr2Piwigo'
    1717    );
    1818}
     
    3030  if ( empty($conf['flickr2piwigo']['api_key']) or empty($conf['flickr2piwigo']['secret_key']) )
    3131  {
    32     return new PwgError(500, l10n('Please fill your API keys on the configuration tab'));
     32    return new PwgError(null, l10n('Please fill your API keys on the configuration tab'));
    3333  }
    3434 
     
    3636  include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php');
    3737  include_once(FLICKR_PATH . 'include/functions.inc.php');
     38 
     39  if (test_remote_download() === false)
     40  {
     41    return new PwgError(null, l10n('No download method available'));
     42  }
    3843 
    3944  // init flickr API
     
    5863  if (download_remote_file($photo['url'], $photo['path']) == false)
    5964  {
    60     return new PwgError(500, l10n('No download method available'));
     65    return new PwgError(null, l10n('Can\'t download file'));
    6166  }
    6267 
     
    125130  }
    126131 
    127   return sprintf(l10n('%s imported'), $photo['title']);
     132  return sprintf(l10n('Photo "%s" imported'), $photo['title']);
    128133}
    129134
  • extensions/flickr2piwigo/language/en_UK/description.txt

    r16063 r17476  
    1 Extension for importing pictures from your Flickr account
     1Import pictures from your Flickr account
  • extensions/flickr2piwigo/language/en_UK/plugin.lang.php

    r17313 r17476  
    99$lang['Import'] = 'Import';
    1010$lang['API not authenticated'] = 'API not authenticated';
    11 $lang['%s imported'] = '%s imported';
     11$lang['Photo "%s" imported'] = 'Photo "%s" imported';
    1212$lang['Flickr logins'] = 'Flickr logins';
    1313$lang['API key'] = 'API key';
     
    2929$lang['No download method available'] = 'No download method available';
    3030$lang['Logued as'] = 'Logued as';
     31$lang['Logued out'] = 'Logued out';
    3132$lang['%d elements ready for importation'] = '%d elements ready for importation';
    3233
  • extensions/flickr2piwigo/language/fr_FR/description.txt

    r16063 r17476  
    1 Extension permettant d'importer des photos depuis votre compte Flickr.
     1Importez des photos depuis votre compte Flickr.
  • extensions/flickr2piwigo/language/fr_FR/plugin.lang.php

    r17313 r17476  
    99$lang['Import'] = 'Importation';
    1010$lang['API not authenticated'] = 'API non authentifiée';
    11 $lang['%s imported'] = '%s importé';
     11$lang['Photo "%s" imported'] = 'Photo "%s" importée';
    1212$lang['Flickr logins'] = 'Identifiants Flickr';
    1313$lang['API key'] = 'Clé API';
     
    2929$lang['No download method available'] = 'Aucune méthode de téléchargement n\'est disponible';
    3030$lang['Logued as'] = 'Indentifié en tant que';
     31$lang['Logued out'] = 'Déconnecté';
    3132$lang['%d elements ready for importation'] = '%d elements prêts à l\'importation';
    3233
  • extensions/flickr2piwigo/main.inc.php

    r16087 r17476  
    33Plugin Name: Flickr2Piwigo
    44Version: auto
    5 Description: Extension for importing pictures from your Flickr account
     5Description: Import pictures from your Flickr account
    66Plugin URI: http://piwigo.org/ext/extension_view.php?eid=612
    77Author: Mistic
  • extensions/flickr2piwigo/maintain.inc.php

    r16071 r17476  
    3737function plugin_uninstall()
    3838{
     39  global $conf;
     40 
    3941  pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "flickr2piwigo" LIMIT 1;');
    4042 
Note: See TracChangeset for help on using the changeset viewer.