function _sheetnode_google_import_fetch in Sheetnode 6
Same name and namespace in other branches
- 7.2 modules/sheetnode_google/sheetnode_google.import.inc \_sheetnode_google_import_fetch()
- 7 modules/sheetnode_google/sheetnode_google.import.inc \_sheetnode_google_import_fetch()
1 string reference to '_sheetnode_google_import_fetch'
- sheetnode_google_menu in modules/
sheetnode_google/ sheetnode_google.module - Implementation of hook_menu().
File
- modules/
sheetnode_google/ sheetnode_google.import.inc, line 36
Code
function &_sheetnode_google_import_fetch(&$form, $form_state) {
$form['google']['error'] = array(
'#type' => 'markup',
'#value' => '',
);
try {
$service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($form_state['values']['username'], $form_state['values']['password'], $service);
$spreadsheetService = new Zend_Gdata_Spreadsheets($client);
$feed = $spreadsheetService
->getSpreadsheetFeed();
} catch (Exception $e) {
$feed = array();
$form['google']['error'] = array(
'#type' => 'markup',
'#value' => $e
->getMessage(),
'#prefix' => '<div class="messages error">',
'#suffix' => '</div>',
);
}
$options = array();
foreach ($feed->entries as $entry) {
$id = array_pop(explode('/', $entry->id->text));
$options[$id] = $entry->title->text;
}
$form['google']['key'] = array(
'#type' => 'select',
'#title' => t('Private spreadsheets'),
'#options' => $options,
);
$form['google']['submit'] = array(
'#type' => 'submit',
'#value' => t('Import'),
'#weight' => 99,
'#disabled' => empty($options),
);
return $form['google'];
}