Changeset 16071 for extensions/flickr2piwigo/admin
- Timestamp:
- Jun 27, 2012, 1:53:21 AM (12 years ago)
- Location:
- extensions/flickr2piwigo/admin
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/flickr2piwigo/admin/config.php
r16063 r16071 7 7 'api_key' => trim($_POST['api_key']), 8 8 'secret_key' => trim($_POST['secret_key']), 9 'username' => trim($_POST['username']),10 9 ); 11 10 unset($_SESSION['phpFlickr_auth_token']); … … 14 13 15 14 16 $template->assign('flickr2piwigo', $conf['flickr2piwigo']);17 18 15 $template->assign(array( 16 'flickr2piwigo' => $conf['flickr2piwigo'], 19 17 'FLICKR_HELP_CONTENT' => load_language('help_api_key.html', FLICKR_PATH, array('return'=>true)), 20 'FLICKR_CALLBACK' => get_absolute_root_url() .FLICKR_ADMIN.'-import',18 'FLICKR_CALLBACK' => get_absolute_root_url() . FLICKR_ADMIN . '-import', 21 19 )); 22 20 23 21 24 $template->set_filename('flickr2piwigo', dirname(__FILE__).'/template/config.tpl'); 25 22 $template->set_filename('flickr2piwigo', dirname(__FILE__) . '/template/config.tpl'); 26 23 27 24 ?> -
extensions/flickr2piwigo/admin/import.php
r16070 r16071 3 3 4 4 // check API parameters and connect to flickr 5 if ( empty($conf['flickr2piwigo']['api_key']) or empty($conf['flickr2piwigo']['secret_key']) or empty($conf['flickr2piwigo']['username']))5 if ( empty($conf['flickr2piwigo']['api_key']) or empty($conf['flickr2piwigo']['secret_key']) ) 6 6 { 7 7 array_push($page['warnings'], l10n('Please fill your API keys on the configuration tab')); … … 16 16 17 17 // must authenticate 18 if (empty($_SESSION['phpFlickr_auth_token']) and @$_GET['action']!='login') 18 $u = $flickr->test_login(); 19 if ( ($u === false or empty($_SESSION['phpFlickr_auth_token'])) and @$_GET['action']!='login' ) 19 20 { 20 21 $_GET['action'] = 'init_login'; 21 22 } 22 else23 {24 // get user id25 $u = $flickr->people_findByUsername($conf['flickr2piwigo']['username']);26 if ($u === false)27 {28 array_push($page['errors'], l10n('Unknown username, please verify your configuration'));29 $_GET['action'] = 'error';30 }31 }32 33 23 34 24 // generate token after authentication … … 48 38 case 'init_login': 49 39 { 50 $template->assign('flickr_login', FLICKR_ADMIN .'-import&action=login');40 $template->assign('flickr_login', FLICKR_ADMIN . '-import&action=login'); 51 41 break; 52 42 } … … 63 53 { 64 54 $_SESSION['page_infos'][] = l10n('Successfully logued to you Flickr account'); 65 redirect(FLICKR_ADMIN .'-import');55 redirect(FLICKR_ADMIN . '-import'); 66 56 break; 67 57 } … … 72 62 unset($_SESSION['phpFlickr_auth_token']); 73 63 $_SESSION['page_infos'][] = l10n('Logued out'); 74 redirect(FLICKR_ADMIN .'-import');64 redirect(FLICKR_ADMIN . '-import'); 75 65 break; 76 66 } … … 81 71 $u = $flickr->people_getInfo($u['id']); 82 72 $template->assign(array( 83 'username' => $ conf['flickr2piwigo']['username'],84 'profile_url' => $u['p hotosurl'],85 'logout_url' => FLICKR_ADMIN .'-import&action=logout',86 'list_albums_url' => FLICKR_ADMIN .'-import&action=list_albums',87 'import_all_url' => FLICKR_ADMIN .'-import&action=list_all',73 'username' => $u['username'], 74 'profile_url' => $u['profileurl'], 75 'logout_url' => FLICKR_ADMIN . '-import&action=logout', 76 'list_albums_url' => FLICKR_ADMIN . '-import&action=list_albums', 77 'import_all_url' => FLICKR_ADMIN . '-import&action=list_all', 88 78 )); 89 79 break; … … 100 90 foreach ($albums as &$album) 101 91 { 102 //$album['U_IMPORT_ALL'] = FLICKR_ADMIN.'-import&action=import_album&album='.$album['id']; 103 $album['U_LIST'] = FLICKR_ADMIN.'-import&action=list_photos&album='.$album['id']; 92 $album['U_LIST'] = FLICKR_ADMIN . '-import&action=list_photos&album='.$album['id']; 104 93 } 105 94 unset($album); … … 114 103 'description' => null, 115 104 'photos' => $wo_albums['photos']['total'], 116 //'U_IMPORT_ALL' => FLICKR_ADMIN.'-import&action=import_album&album='.$album['id'], 117 'U_LIST' => FLICKR_ADMIN.'-import&action=list_photos&album=not_in_set', 105 'U_LIST' => FLICKR_ADMIN . '-import&action=list_photos&album=not_in_set', 118 106 )); 119 107 } … … 129 117 case 'list_photos': 130 118 { 119 $self_url = FLICKR_ADMIN . '-import&action=list_photos&album='.$_GET['album']; 120 $flickr_prefix = 'flickr-'.$u['username'].'-'; 121 $flickr_root_url = $flickr->urls_getUserPhotos($u['id']); 122 123 // pagination 131 124 if (isset($_GET['start'])) $page['start'] = intval($_GET['start']); 132 125 else $page['start'] = 0; … … 134 127 else $page['display'] = 20; 135 128 136 $self_url = FLICKR_ADMIN.'-import&action=list_photos&album='.$_GET['album']; 137 $flickr_prefix = 'flickr-'.$conf['flickr2piwigo']['username'].'-'; 138 $flickr_root_url = $flickr->urls_getUserPhotos($u['id']); 129 // get photos 130 if ($_GET['album'] == 'not_in_set') 131 { 132 $all_photos = $flickr->photos_getNotInSet(NULL, NULL, NULL, NULL, 'photos', NULL, NULL, 500); 133 $all_photos = $all_photos['photos']['photo']; 134 } 135 else 136 { 137 $all_photos = $flickr->photosets_getPhotos($_GET['album'], NULL, NULL, 500, NULL, 'photos'); 138 $all_photos = $all_photos['photoset']['photo']; 139 } 139 140 140 141 // get existing photos … … 147 148 $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); 148 149 149 // get photos 150 if ($_GET['album'] == 'not_in_set') 151 { 152 $all_photos = $flickr->photos_getNotInSet(NULL, NULL, NULL, NULL, 'photos', NULL, NULL, 500); 153 $all_photos = $all_photos['photos']['photo']; 154 } 155 else 156 { 157 $all_photos = $flickr->photosets_getPhotos($_GET['album'], NULL, NULL, 500, NULL, 'photos'); 158 $all_photos = $all_photos['photoset']['photo']; 159 } 160 161 // remove existing 150 // remove existing photos 162 151 $duplicates = 0; 163 152 foreach ($all_photos as $i => $photo) … … 169 158 } 170 159 } 160 171 161 if ($duplicates>0) 172 162 { … … 214 204 break; 215 205 } 216 206 207 // list all photos of the user 217 208 case 'list_all': 218 209 { 219 $flickr_prefix = 'flickr-'.$ conf['flickr2piwigo']['username'].'-';210 $flickr_prefix = 'flickr-'.$u['username'].'-'; 220 211 221 212 // get all photos in all albums … … 246 237 $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); 247 238 248 // remove duplicates239 // remove existing photos 249 240 $duplicates = 0; 250 241 foreach ($all_photos as $id => &$photo) … … 264 255 } 265 256 unset($photo); 257 $all_photos = array_values($all_photos); 258 266 259 if ($duplicates>0) 267 260 { 268 261 array_push($page['infos'], l10n_dec('%d picture is not displayed because already existing in the database.', '%d pictures are not displayed because already existing in the database.', $duplicates)); 269 262 } 270 $all_photos = array_values($all_photos);271 263 272 264 $template->assign(array( 273 265 'nb_elements' => count($all_photos), 274 266 'all_elements' => json_encode($all_photos), 275 'F_ACTION' => FLICKR_ADMIN .'-import&action=import_set',267 'F_ACTION' => FLICKR_ADMIN . '-import&action=import_set', 276 268 )); 277 269 … … 293 285 $_SESSION['page_infos'][] = sprintf(l10n('%d pictures imported'), $_POST['done']); 294 286 } 295 redirect(FLICKR_ADMIN .'-import');287 redirect(FLICKR_ADMIN . '-import'); 296 288 } 297 289 } 298 290 291 299 292 $template->assign('ACTION', $_GET['action']); 300 293 301 $template->set_filename('flickr2piwigo', dirname(__FILE__) .'/template/import.tpl');294 $template->set_filename('flickr2piwigo', dirname(__FILE__) . '/template/import.tpl'); 302 295 303 296 ?> -
extensions/flickr2piwigo/admin/template/config.tpl
r16063 r16071 23 23 </label> 24 24 </li> 25 26 <li>27 <label>28 <span class="property">{'Username'|@translate}</span>29 <input type="text" name="username" value="{$flickr2piwigo.username}" size="20"></label>30 </label>31 </li>32 25 </ul> 33 26 </fieldset> -
extensions/flickr2piwigo/admin/template/import.list_photos.tpl
r16063 r16071 330 330 /* pagination loader */ 331 331 jQuery('#navigation a').click(function() { 332 $("#loader_display").fadeIn() 332 $("#loader_display").fadeIn(); 333 333 }); 334 334 }); -
extensions/flickr2piwigo/admin/template/import.tpl
r16064 r16071 5 5 </div> 6 6 7 {* <!-- LOGIN --> *} 7 8 {if $ACTION == 'init_login'} 8 9 <p><input type="submit" onClick="javascript:window.location.href ='{$flickr_login}';" value="{'Login'|@translate}"></p> 9 10 11 {* <!-- MAIN MENU --> *} 10 12 {elseif $ACTION == 'main'} 13 {footer_script}{literal} 14 jQuery('input[type="submit"]').click(function() { 15 window.location.href = $(this).attr("data"); 16 }); 17 jQuery('.load').click(function() { 18 $("#loader_import").fadeIn(); 19 }); 20 {/literal}{/footer_script} 21 11 22 <p> 12 23 <b>{'Logued as'|@translate}</b> : <a href="{$profile_url}" target="_blank">{$username}</a><br><br> 13 <input type="submit" onClick="javascript:window.location.href ='{$logout_url}';" value="{'Logout'|@translate}">24 <input type="submit" data="{$logout_url}" value="{'Logout'|@translate}"> 14 25 </p> 15 26 <br> 16 27 <p> 17 <input type="submit" onClick="javascript:window.location.href ='{$list_albums_url}';" value="{'List my albums'|@translate}"> 18 <input type="submit" onClick="javascript:window.location.href ='{$import_all_url}';" value="{'Import all my pictures'|@translate}"> 28 <input type="submit" data="{$list_albums_url}" class="load" value="{'List my albums'|@translate}"> 29 <input type="submit" data="{$import_all_url}" class="load" value="{'Import all my pictures'|@translate}"> 30 <br> 31 <span id="loader_import" style="display:none;"><img src="admin/themes/default/images/ajax-loader.gif"> <i>{'Processing...'|@translate}</i></span> 19 32 </p> 20 33 34 {* <!-- ALBUMS LIST --> *} 21 35 {elseif $ACTION == 'list_albums'} 36 {footer_script}{literal} 37 jQuery('.load').click(function() { 38 $("#loader_import").fadeIn(); 39 }); 40 {/literal}{/footer_script} 41 22 42 <h3>{'%d albums'|@translate|@sprintf:$total_albums}</h3> 23 43 <ul id="albumsList"> 24 44 {foreach from=$albums item=album} 25 45 <li {if $album.id == "not_in_set"}class="not_in_set"{/if}> 26 <b><a href="{$album.U_LIST}" >{$album.title}</a></b> <i>{'(%d photos)'|@translate|@sprintf:$album.photos}</i> {if $album.description}- {$album.description|@truncate:100}{/if}27 { *- <a href="{$album.U_IMPORT_ALL}">{'Import all pictures of this album'|@translate}</a>*}46 <b><a href="{$album.U_LIST}" class="load">{$album.title}</a></b> <i>{'(%d photos)'|@translate|@sprintf:$album.photos}</i> 47 {if $album.description}- {$album.description|@truncate:100}{/if} 28 48 </li> 29 49 {/foreach} 30 50 </ul> 51 <span id="loader_import" style="display:none;"><img src="admin/themes/default/images/ajax-loader.gif"> <i>{'Processing...'|@translate}</i></span> 31 52 53 {* <!-- PHOTOS LIST --> *} 32 54 {elseif $ACTION == 'list_photos'} 33 55 {include file=$FLICKR_ABS_PATH|@cat:'admin/template/import.list_photos.tpl'} 34 56 57 {* <!-- IMPORT ALL --> *} 35 58 {elseif $ACTION == 'list_all'} 36 59 {include file=$FLICKR_ABS_PATH|@cat:'admin/template/import.list_all.tpl'}
Note: See TracChangeset
for help on using the changeset viewer.