Changeset 28832
- Timestamp:
- Jun 29, 2014, 4:09:08 PM (10 years ago)
- Location:
- extensions/Google2Piwigo
- Files:
-
- 13 added
- 20 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Google2Piwigo/admin.php
r26198 r28832 11 11 } 12 12 13 // tabsheet 14 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 15 $page['tab'] = (isset($_GET['tab'])) ? $_GET['tab'] : $page['tab'] = 'import'; 16 17 $tabsheet = new tabsheet(); 18 $tabsheet->add('import', l10n('Import'), PICASA_WA_ADMIN . '-import'); 19 $tabsheet->add('config', l10n('Configuration'), PICASA_WA_ADMIN . '-config'); 20 $tabsheet->select($page['tab']); 21 $tabsheet->assign(); 22 13 23 // include page 14 include(PICASA_WA_PATH . 'admin/ import.php');24 include(PICASA_WA_PATH . 'admin/' . $page['tab'] . '.php'); 15 25 16 26 // template -
extensions/Google2Piwigo/admin/import.php
r26198 r28832 6 6 include_once(PICASA_WA_PATH . 'include/functions.inc.php'); 7 7 8 if (!test_remote_download()) 8 // check API parameters and connect to flickr 9 if (empty($conf['google2piwigo']['api_key']) or empty($conf['google2piwigo']['secret_key'])) 10 { 11 $page['warnings'][] = l10n('Please fill your API keys on the configuration tab'); 12 $_GET['action'] = 'error'; 13 } 14 else if (!test_remote_download()) 9 15 { 10 16 $page['errors'][] = l10n('No download method available'); … … 18 24 Zend_Loader::loadClass('Zend_Gdata_AuthSub'); 19 25 Zend_Loader::loadClass('Zend_Gdata_Photos'); 26 require_once('OAuth2/Client.php'); 27 require_once('OAuth2/GrantType/AuthorizationCode.php'); 28 29 $oauth_client = new OAuth2_Client($conf['google2piwigo']['api_key'], $conf['google2piwigo']['secret_key']); 30 $oauth_redirect_url = get_absolute_root_url() . PICASA_WA_ADMIN . '-import'; 20 31 21 32 // generate token after authentication 22 if (!empty($_GET['token'])) 23 { 24 $_SESSION['gdata_auth_token'] = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']); 33 if (!empty($_GET['code'])) 34 { 35 $params = array('code' => $_GET['code'], 'redirect_uri' => $oauth_redirect_url, 'scope' => 'https://picasaweb.google.com/data/'); 36 $response = $oauth_client->getAccessToken($conf['google2piwigo']['token_endpoint'], 'authorization_code', $params); 37 $_SESSION['gdata_auth_token'] = $response['result']['access_token']; 25 38 $_GET['action'] = 'logged'; 26 39 } 27 40 28 // authentication 29 if (empty($_SESSION['gdata_auth_token'])) 30 { 31 $_GET['action'] = 'login'; 32 } 33 else 41 // must authenticate 42 if (!empty($_SESSION['gdata_auth_token'])) 34 43 { 35 44 $client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['gdata_auth_token']); 36 45 $picasa = new Zend_Gdata_Photos($client, "Piwigo-Google2Piwigo-1.0"); 37 46 } 47 else 48 { 49 $params = array('scope' => 'https://picasaweb.google.com/data/'); 50 $auth_url = $oauth_client->getAuthenticationUrl($conf['google2piwigo']['auth_endpoint'], $oauth_redirect_url, $params); 51 $_GET['action'] = 'init_login'; 52 } 38 53 } 39 54 … … 47 62 { 48 63 // button to login page 49 case 'login': 50 { 51 $login_url = Zend_Gdata_AuthSub::getAuthSubTokenUri( 52 get_absolute_root_url() . PICASA_WA_ADMIN . '-import', 53 'https://picasaweb.google.com/data', 54 false, true 55 ); 56 57 $template->assign(array( 58 'picasa_login' => $login_url, 59 'HELP_CONTENT' => load_language('help.lang.html', PICASA_WA_PATH, array('return'=>true)), 60 )); 64 case 'init_login': 65 { 66 $template->assign('picasa_login', $auth_url); 61 67 break; 62 68 } … … 73 79 case 'logout': 74 80 { 75 Zend_Gdata_AuthSub::AuthSubRevokeToken(76 $_SESSION['gdata_auth_token'],77 $client78 );79 81 unset($_SESSION['gdata_auth_token']); 80 81 82 $_SESSION['page_infos'][] = l10n('Logged out'); 82 83 redirect(PICASA_WA_ADMIN . '-import'); -
extensions/Google2Piwigo/admin/template/import.tpl
r27824 r28832 12 12 window.location.href = "{$picasa_login}"; 13 13 }); 14 $(".login_help").click(function() {15 $(".infos.tip").slideToggle();16 });17 14 {/footer_script} 18 15 … … 23 20 24 21 {* <!-- LOGIN --> *} 25 {if $ACTION == ' login'}22 {if $ACTION == 'init_login'} 26 23 <p><input type="submit" class="login" value="{'Login'|translate}"></p> 27 <p><a href="#" class="login_help">{'Help! I get the error "The site [...] has not been registered."'|translate}</a></p>28 29 <div class="infos tip" style="display:none;">30 {$HELP_CONTENT}31 </div>32 24 33 25 {* <!-- MAIN MENU --> *} -
extensions/Google2Piwigo/language/en_UK/plugin.lang.php
r24816 r28832 1 1 <?php 2 2 3 $lang['Please fill your API keys on the configuration tab'] = 'Please fill your API keys on the configuration tab'; 3 4 $lang['Successfully logged to you Google account'] = 'Successfully logged to you Google account'; 4 5 $lang['One picture is not displayed because already existing in the database.'] = 'One picture is not displayed because already existing in the database.'; … … 24 25 $lang['Geolocalization'] = 'Geolocalization'; 25 26 $lang['Logged in as'] = 'Logged in as'; 26 $lang['Help! I get the error "The site [...] has not been registered."'] = 'Help! I get the error "The site [...] has not been registered."'; 27 $lang['Google project keys'] = 'Google project keys'; 28 $lang['Callback URL'] = 'Callback URL'; 29 $lang['How do I get my Google project API key?'] = 'How do I get my Google project API key?'; 27 30 28 31 ?> -
extensions/Google2Piwigo/main.inc.php
r26198 r28832 17 17 define('PICASA_WA_ADMIN', get_root_url() . 'admin.php?page=plugin-' . PICASA_WA_ID); 18 18 define('PICASA_WA_CACHE', PHPWG_ROOT_PATH . $conf['data_location'] . 'picasa_wa_cache/'); 19 define('PICASA_WA_VERSION', 'auto'); 19 20 20 21 21 22 include_once(PICASA_WA_PATH . 'include/ws_functions.inc.php'); 22 23 24 25 add_event_handler('init', 'picasa_wa_init'); 23 26 add_event_handler('ws_add_methods', 'picasa_wa_add_ws_method'); 24 27 … … 63 66 } 64 67 } 68 69 function picasa_wa_init() 70 { 71 global $conf; 72 include_once(PICASA_WA_PATH . 'maintain.inc.php'); 73 $maintain = new Google2Piwigo_maintain(PICASA_WA_ID); 74 $maintain->autoUpdate(PICASA_WA_VERSION, 'install'); 75 76 $conf['google2piwigo'] = unserialize($conf['google2piwigo']); 77 }
Note: See TracChangeset
for help on using the changeset viewer.