| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
/**
|
| 4 |
* @file
|
| 5 |
* The module for importing YouTube video feed
|
| 6 |
*/
|
| 7 |
|
| 8 |
/*
|
| 9 |
* The API passes in a $user object that contains four properties:
|
| 10 |
* uid, userid, password, feed. These properties contain the account
|
| 11 |
* information entered into the user's settings page, along with the
|
| 12 |
* uid of their Drupal account.
|
| 13 |
*/
|
| 14 |
function activitystream_youtube_streamapi($user) {
|
| 15 |
// This user doesn't have a Goodreads ID entered
|
| 16 |
// into their settings. Move along. Nothing
|
| 17 |
// to see here.
|
| 18 |
if (!$user->userid) {
|
| 19 |
return;
|
| 20 |
}
|
| 21 |
|
| 22 |
// Use the activitystream_feed module to pull in the user's
|
| 23 |
// YouTube videos
|
| 24 |
$user->feed = 'http://gdata.youtube.com/feeds/base/users/'. $user->userid .'/uploads?alt=rss&v=2&client=ytapi-youtube-profile';
|
| 25 |
$items = activitystream_feed_streamapi($user);
|
| 26 |
return $items;
|
| 27 |
}
|
| 28 |
|
| 29 |
|
| 30 |
/*
|
| 31 |
* Implement a user settings form hook. Modules should build a form
|
| 32 |
* using an array that mirrors the Drupal form API. activitystream.module
|
| 33 |
* will add the form elements to a tab called Activity Streams on the
|
| 34 |
* user's Profile Edit page. Fields should be named
|
| 35 |
* yourmodulename_fieldname. For instance, to store the user ID for
|
| 36 |
* Flickr, the field name is activitystream_flickr_userid
|
| 37 |
*
|
| 38 |
* To avoid collisions with other activitystream module's forms
|
| 39 |
* use your module's name as the form array's key.
|
| 40 |
*
|
| 41 |
* @param $edit
|
| 42 |
* The values of the form fields, used for setting defaults
|
| 43 |
*
|
| 44 |
*/
|
| 45 |
function activitystream_youtube_activitystream_settings(&$edit) {
|
| 46 |
$form['activitystream_youtube'] = array(
|
| 47 |
'#type' => 'fieldset',
|
| 48 |
'#title' => t('YouTube settings'));
|
| 49 |
$form['activitystream_youtube']['activitystream_youtube_userid'] = array(
|
| 50 |
'#type' => 'textfield',
|
| 51 |
'#title' => t('Username'),
|
| 52 |
'#default_value' => empty($edit['activitystream_youtube_userid']) ? '' : $edit['activitystream_youtube_userid'],
|
| 53 |
'#description' => t('The username for your YouTube account'));
|
| 54 |
return $form;
|
| 55 |
}
|
| 56 |
|
| 57 |
function theme_activitystream_youtube_icon() {
|
| 58 |
return theme_image(drupal_get_path('module', 'activitystream_youtube') .'/youtube.jpeg', 'YouTube');
|
| 59 |
}
|
| 60 |
|
| 61 |
function theme_activitystream_youtube_item($activity) {
|
| 62 |
$node = node_load($activity->nid);
|
| 63 |
$date = theme('activitystream_date', $node->created);
|
| 64 |
$user = activitystream_user_load($node->uid);
|
| 65 |
$name = theme('activitystream_username', $user);
|
| 66 |
return '<span class="activitystream-item">'. theme('activitystream_youtube_icon') . " <span>$name posted " . l($node->title, $activity->link) ." <span class=\"activitystream-created\">$date</span></span>". l('#', 'node/'. $node->nid, array('class' => 'permalink')) . '</span>';
|
| 67 |
}
|