Index: subscribe.module =================================================================== RCS file: /cvs/drupal/contributions/modules/subscribe/subscribe.module,v retrieving revision 1.21.2.5 diff -u -r1.21.2.5 subscribe.module --- subscribe.module 1 Nov 2006 15:45:56 -0000 1.21.2.5 +++ subscribe.module 14 Nov 2006 02:42:10 -0000 @@ -93,7 +93,7 @@ case 'view': if (isset($node->remote_nid)) { - $node = theme_external_node($node, 0, 1); + $node = theme('external_node', $node, 0, 1); } break; @@ -122,9 +122,9 @@ function theme_external_node($node, $teaser = 0, $page = 0) { $node->title = t('%node-title (from %remote-url)', array('%node-title' => $node->title, '%remote-url' => $node->remote_site_url)); - $remote_url = $node->remote_site_url. '/'; - $item[] = t('Visit this page', array('%remote-url' => $remote_url. "node/$node->remote_nid")); - $item[] = t('Authored by: %remote-author', array('%remote-author' => $node->remote_author, '%remote-author-url' => $remote_url. "user/$node->remote_uid")); + $remote_url = $node->remote_site_url .'/'; + $item[] = l(t('Visit this page'), $remote_url .'node/'. $node->remote_nid); + $item[] = t('Authored by') .': '. l($node->remote_author, $remote_url .'user/'. $node->remote_uid); $referring_info = theme('item_list', $item); @@ -144,7 +144,7 @@ */ function subscribe_overview() { $output = '
| ' . - // l(t('edit'), "admin/subscribe/sub/$sub->sid/edit") . ' | ' . - l(t('pull'), "admin/subscribe/pull/$sub->sid") . ' | ' . - l(t('delete'), "admin/subscribe/delete/$sub->sid") . ' |
' . t('You currently have no subscriptions.') . '
' . t('Would you like to') . ' ' . l(t('subscribe to a channel'),'admin/subscribe/sub/wizard') . '?
'; + $output .= $row ? theme('table', $header, $row) : ''. t('You currently have no subscriptions.') .'
'. t('Would you like to') .' '. l(t('subscribe to a channel'), 'admin/subscribe/sub/wizard') .'?
'; return $output; } @@ -213,7 +211,7 @@ $form = array(); $form['channel'] = array( '#type' => 'fieldset', - '#title' => 'Subscribe to channel' + '#title' => 'Subscribe to channel', ); $form['channel']['url'] = array( '#type' => 'textfield', @@ -221,7 +219,7 @@ '#size' => '70', '#maxlength' => '255', '#description' => t('E.g. http://example.com/xmlrpc.php'), - '#default_value' => isset($edit['url']) ? $edit['url'] : 'http://' + '#default_value' => isset($edit['url']) ? $edit['url'] : 'http://', ); $form['channel']['channel']['channel_id'] = array( '#type' => 'textfield', @@ -229,24 +227,24 @@ '#size' => '10', '#maxlength' => '255', '#description' => t('Typically an integer corresponding to the channel ID'), - '#default_value' => isset($edit['channel_id']) ? $edit['channel_id'] : '' + '#default_value' => isset($edit['channel_id']) ? $edit['channel_id'] : '', ); $form['channel']['username'] = array( '#type' => 'textfield', '#title' => t('Username'), '#size' => '10', '#maxlength' => '60', - '#default_value' => isset($edit['username']) ? $edit['username'] : '' + '#default_value' => isset($edit['username']) ? $edit['username'] : '', ); $form['channel']['pass'] = array( '#type' => 'password', '#title' => t('Password'), '#size' => '10', - '#maxlength' => '32' + '#maxlength' => '32', ); $form['submit'] = array( '#type' => 'submit', - '#value' => t('Continue') + '#value' => t('Continue'), ); unset($_SESSION['edit']); return drupal_get_form('subscribe_url_form', $form); @@ -331,7 +329,7 @@ function subscribe_vocabmap_form() { if (!isset($_SESSION['edit'])) { drupal_set_message(t('Unable to retrieve session data.'), 'error'); - drupal_goto('/subscribe/sub/wizard'); + drupal_goto('subscribe/sub/wizard'); } $edit = $_SESSION['edit']; $remote_vocabularies = array(); @@ -371,31 +369,31 @@ '#type' => 'select', '#options' => $voc_options, '#default_value' => $selected_voc, - '#vname' => $v->name + '#vname' => $v->name, ); } $form['receiving'] = array( '#type' => 'fieldset', - '#title' => t('Receiving Content') + '#title' => t('Receiving content'), ); $form['receiving']['pushpull'] = array( '#type' => 'radios', '#title' => t('Method'), '#default_value' => isset($edit['pushpull']) ? $edit['pushpull'] : 0, '#options' => array(t('Push: Receive content from channel automatically when the channel decides to send it.'), t('Pull: Receive content from channel only when you manually request it (your server must allow HTTP out).')), - '#description' => t('Choose how you would like this site to receive content.') + '#description' => t('Choose how you would like this site to receive content.'), ); $form['submit'] = array( '#type' => 'submit', - '#value' => t('Subscribe to channel') + '#value' => t('Subscribe to channel'), ); return drupal_get_form('subscribe_vocabmap_form', $form); } function theme_subscribe_vocabmap_form($form) { - $header = array(t('Remote Vocabulary'), '', t('Local Vocabulary')); + $header = array(t('Remote vocabulary'), '', t('Local vocabulary')); $rows = array(); foreach (element_children($form['vocabmap']) as $key) { $rows[] = array( @@ -405,7 +403,7 @@ ); } if ($rows) { - $output = theme('fieldset', array('#title' => t('Vocabulary Mapping'), '#children' => theme_table($header, $rows))); + $output = theme('fieldset', array('#title' => t('Vocabulary mapping'), '#children' => theme('table', $header, $rows))); } $output .= form_render($form); return $output; @@ -414,19 +412,19 @@ function subscribe_vocabmap_form_validate($form, $form_values) { if (!isset($_SESSION['edit'])) { drupal_set_message(t('Unable to retrieve session data.'), 'error'); - drupal_goto('/subscribe/sub/wizard'); + drupal_goto('subscribe/sub/wizard'); } $edit = $_SESSION['edit']; - if (!subscribe_subscription_validate($edit['url'], $edit['channel_id'])) { + if (!subscribe_subscription_validate($edit['url'], $edit['channel_id'])) { drupal_set_message(t('You are already subscribed to this channel.'), 'error'); drupal_goto('admin/subscribe'); - } + } } function subscribe_vocabmap_form_submit($form, $edit) { if (!isset($_SESSION['edit'])) { drupal_set_message(t('Unable to retrieve session data.'), 'error'); - drupal_goto('/subscribe/sub/wizard'); + drupal_goto('subscribe/sub/wizard'); } $edit = array_merge($_SESSION['edit'], $edit); unset($_SESSION['edit']); @@ -473,7 +471,7 @@ function subscribe_vocabmap_save($local_vocabularies, $sid) { db_query("DELETE FROM {subscribe_vocab_map} WHERE sid = '%s'", $sid); foreach ($local_vocabularies as $lvid => $rvid) { - db_query("INSERT INTO {subscribe_vocab_map} (sid, remote_vid, local_vid) VALUES (%d, %d, %d)", $sid, $rvid, $lvid); + db_query('INSERT INTO {subscribe_vocab_map} (sid, remote_vid, local_vid) VALUES (%d, %d, %d)', $sid, $rvid, $lvid); } } @@ -487,7 +485,7 @@ */ function subscribe_get_vocabmap($sid) { $vocabmap = array(); - $result = db_query("SELECT * FROM {subscribe_vocab_map} WHERE sid = %d", $sid); + $result = db_query('SELECT * FROM {subscribe_vocab_map} WHERE sid = %d', $sid); while ($data = db_fetch_object($result)) { $vocabmap[$data->remote_vid] = taxonomy_get_vocabulary($data->local_vid); } @@ -637,15 +635,16 @@ $error = xmlrpc_error_msg(); drupal_set_message($error, 'error'); } + if ($result['count']) { $site_metadata = array('site_url' => $result['site_url'], 'site_name' => $result['site_name'], 'sid' => $subscription->sid); list($n_counter, $u_counter, $t_counter) = subscribe_import($result['nodes'], $site_metadata); - drupal_set_message(t("New content from %name. Nodes imported: %ncount; nodes updated: %ucount; terms imported: %tcount.", array('%ncount' => $n_counter, '%ucount' => $u_counter, '%tcount' => $t_counter, '%name' => $subscription->name))); - db_query("UPDATE {subscribe_subscriptions} SET last_update = %d WHERE sid = %d", time(), $subscription->sid); + drupal_set_message(t('New content from %name. Nodes imported: %ncount; nodes updated: %ucount; terms imported: %tcount.', array('%ncount' => $n_counter, '%ucount' => $u_counter, '%tcount' => $t_counter, '%name' => check_plain($subscription->name)))); + db_query('UPDATE {subscribe_subscriptions} SET last_update = %d WHERE sid = %d', time(), $subscription->sid); drupal_goto('admin/subscribe'); } else { - drupal_set_message(t('Pull attempt failed for %url.', array('%url' => theme('placeholder', check_plain($subscription->url)))), 'error'); + drupal_set_message(t('No new/updated content to pull from %url.', array('%url' => theme('placeholder', $subscription->url)))); } } @@ -724,14 +723,14 @@ // add vocabulary information foreach ($node->taxonomy_terms as $remote_term) { - // which vocabulary will we be adding it to? - $local_vid = $vocab_map[$remote_term['vid']]->vid; - if (!$local_vid) { - watchdog('subscribe', t('Discarding term %term because remote vocabulary id %vid is not mapped to a local vocabulary.', array('%term' => check_plain($remote_term->name), '%vid' => $remote_term->vid))); - continue; - } - - $db_result = db_query("SELECT * FROM {term_data} WHERE LOWER('%s') LIKE LOWER(name) AND vid = %d", trim($remote_term['name']), $local_vid); + // which vocabulary will we be adding it to? + $local_vid = $vocab_map[$remote_term['vid']]->vid; + if (!$local_vid) { + watchdog('subscribe', t('Discarding term %term because remote vocabulary id %vid is not mapped to a local vocabulary.', array('%term' => check_plain($remote_term->name), '%vid' => $remote_term->vid))); + continue; + } + + $db_result = db_query("SELECT * FROM {term_data} WHERE LOWER('%s') LIKE LOWER(name) AND vid = %d", trim($remote_term['name']), $local_vid); $local_term = db_fetch_object($db_result); if ($local_term) { // existing term @@ -739,7 +738,7 @@ $result = db_query("SELECT nid FROM {term_node} WHERE nid = %d AND tid = %d", $local_nid, $local_term->tid); $nid = db_result($result); if (!$nid) { // this nid-tid pair has not yet been mapped - db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $local_nid, $local_term->tid); + db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $local_nid, $local_term->tid); } } else { // term does not exist locally; add new term