=== modified file 'block/flickr_block.info'
--- block/flickr_block.info 2008-02-02 20:04:40 +0000
+++ block/flickr_block.info 2008-02-02 23:28:33 +0000
@@ -1,5 +1,6 @@
; $Id: flickr_block.info,v 1.2.2.1 2007/06/18 23:06:43 dww Exp $
name = Flickr Block
description = Flickr Block for inserting photos into content.
-dependencies = flickr
+dependencies[] = flickr
package = Flickr
+core = 6.x
=== modified file 'block/flickr_block.module'
--- block/flickr_block.module 2008-02-02 20:04:40 +0000
+++ block/flickr_block.module 2008-02-02 23:28:33 +0000
@@ -192,10 +192,24 @@
return $output;
}
+/**
+ * Implementation of hook_theme().
+ */
+function flickr_block_theme() {
+ return array(
+ 'flickr_block_photo' => array(
+ 'arguments' => array('p', 'size' => NULL),
+ ),
+ 'flickr_block_photoset' => array(
+ 'arguments' => array('ps', 'owner', 'size'),
+ ),
+ );
+}
+
function theme_flickr_block_photo($p, $size = NULL) {
- return theme_flickr_photo($p, $size);
+ return theme('flickr_photo', $p, $size);
}
function theme_flickr_block_photoset($ps, $owner, $size) {
- return theme_flickr_photoset($ps, $owner, $size);
+ return theme('flickr_photoset', $ps, $owner, $size);
}
=== modified file 'field/flickrfield.info'
--- field/flickrfield.info 2008-02-02 20:04:40 +0000
+++ field/flickrfield.info 2008-02-03 18:42:43 +0000
@@ -1,6 +1,7 @@
; $Id: flickrfield.info,v 1.1.2.1 2007/11/26 15:53:01 drewish Exp $
name = Flickrfield
description = Flickr CCK field to insert Flickr images into content.
-version = "$Name: DRUPAL-5 $"
-dependencies = flickr content
+dependencies[] = flickr
+dependencies[] = content
package = CCK
+core = 6.x
=== modified file 'filter/flickr_filter.info'
--- filter/flickr_filter.info 2008-02-02 20:04:40 +0000
+++ filter/flickr_filter.info 2008-02-02 23:37:09 +0000
@@ -1,5 +1,6 @@
; $Id: flickr_filter.info,v 1.3.2.1 2007/06/18 23:06:43 dww Exp $
name = Flickr Filter
description = Flickr Filter for inserting photos into content.
-dependencies = flickr
+dependencies[] = flickr
package = Flickr
+core = 6.x
=== modified file 'filter/flickr_filter.module'
--- filter/flickr_filter.module 2008-02-02 20:04:40 +0000
+++ filter/flickr_filter.module 2008-02-03 19:02:50 +0000
@@ -12,7 +12,7 @@
$output .= t('The size parameter can be one of the following:');
$items = array();
foreach (flickr_photo_sizes() as $key => $text) {
- $items[] = "$key - $text";
+ $items[] = "$key — (". $text['label'] .') '. $text['description'];
}
$output .= theme('item_list', $items);
}
@@ -103,10 +103,24 @@
return '';
}
+/**
+ * Implementation of hook_theme().
+ */
+function flickr_filter_theme() {
+ return array(
+ 'flickr_filter_photo' => array(
+ 'arguments' => array('p', 'size', 'attribs'),
+ ),
+ 'flickr_filter_photoset' => array(
+ 'arguments' => array('ps', 'owner', 'size', 'attribs'),
+ ),
+ );
+}
+
function theme_flickr_filter_photo($p, $size, $attribs) {
- return theme_flickr_photo($p, $size, NULL, $attribs);
+ return theme('flickr_photo', $p, $size, NULL, $attribs);
}
function theme_flickr_filter_photoset($ps, $owner, $size, $attribs) {
- return theme_flickr_photoset($ps, $owner, $size, $attribs);
+ return theme('flickr_photoset', $ps, $owner, $size, $attribs);
}
=== added file 'flickr.admin.inc'
--- flickr.admin.inc 1970-01-01 00:00:00 +0000
+++ flickr.admin.inc 2008-02-02 23:15:05 +0000
@@ -0,0 +1,89 @@
+ 'textfield',
+ '#title' => t('API Key'),
+ '#required' => TRUE,
+ '#default_value' => variable_get('flickr_api_key', ''),
+ '#description' => t('API Key from Flickr'),
+ );
+ $form['flickr_api_secret'] = array(
+ '#type' => 'textfield',
+ '#title' => t('API Shared Secret'),
+ '#required' => TRUE,
+ '#default_value' => variable_get('flickr_api_secret', ''),
+ '#description' => t("API key's secret from Flickr."),
+ );
+ $form['flickr_default_userid'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Default Flickr User Id'),
+ '#default_value' => variable_get('flickr_default_userid', ''),
+ '#description' => t("An, optional, default Flickr username or user id. This will be used when no user is specified."),
+ );
+ $times = array(900, 1800, 2700, 3600, 7200, 10800, 14400, 18000, 21600, 43200, 86400);
+ $ageoptions = drupal_map_assoc($times, 'format_interval');
+ $form['flickr_cache_duration'] = array(
+ '#type' => 'select',
+ '#title' => t('Update interval'),
+ '#options' => $ageoptions,
+ '#default_value' => variable_get('flickr_cache_duration', 3600),
+ '#description' => t("The refresh interval indicating how often you want to check cached Flickr API calls are up to date."),
+ );
+
+ // we need an api key before we can verify usernames
+ if (!$form['flickr_api_key']['#default_value']) {
+ $form['flickr_default_userid']['#disabled'] = TRUE;
+ $form['flickr_default_userid']['#description'] .= t(" Disabled until a valid API Key is set.");
+ }
+
+ return system_settings_form($form);
+}
+
+function flickr_admin_settings_validate($form, &$form_state) {
+ $key = trim($form_state['values']['flickr_api_key']);
+ $sec = trim($form_state['values']['flickr_api_secret']);
+ $uid = trim($form_state['values']['flickr_default_userid']);
+
+ if ($key && (preg_match('/^[A-Fa-f\d]{32}$/', $key) != 1)) {
+ form_set_error('flickr_api_key', t('This does not appear to be a Flickr API key.'));
+ }
+ if ($sec && (preg_match('/^[A-Fa-f\d]{16}$/', $sec) != 1)) {
+ form_set_error('flickr_api_secret', t('This does not appear to be a Flickr API secret.'));
+ }
+ if ($uid) {
+ if (flickr_is_nsid($uid)) {
+ // it's already a uid
+ }
+ else {
+ $user = flickr_user_find_by_username($uid);
+ if (!$user) {
+ form_set_error('flickr_default_userid', t('%uid is not a Flickr user id and it does not appear to be a valid user name.', array('%uid' => $uid)));
+ }
+ }
+ }
+}
+
+function flickr_admin_settings_submit($form, &$form_state) {
+ // clean up the data ...
+ $form_state['values']['flickr_api_key'] = trim($form_state['values']['flickr_api_key']);
+ $form_state['values']['flickr_api_secret'] = trim($form_state['values']['flickr_api_secret']);
+ $form_state['values']['flickr_default_userid'] = trim($form_state['values']['flickr_default_userid']);
+
+ // ... replace the usernames with a user id ...
+ if (!flickr_is_nsid($form_state['values']['flickr_default_userid'])) {
+ $username = $form_state['values']['flickr_default_userid'];
+ if ($user = flickr_user_find_by_username($username)) {
+ drupal_set_message(t("The Flickr username %username has been replaced with the corresponding user id %uid.", array('%username' => $form_state['values']['flickr_default_userid'], '%uid' => $user['id'])));
+ $form_state['values']['flickr_default_userid'] = $user['id'];
+ }
+ }
+
+ // ... and save the settings
+ system_settings_form_submit($form, &$form_state);
+}
+
=== modified file 'flickr.inc'
--- flickr.inc 2008-02-02 20:04:40 +0000
+++ flickr.inc 2008-02-02 23:37:09 +0000
@@ -127,7 +127,7 @@
// Save cacheable results for future use.
if ($cacheable) {
- cache_set("flickr_$arg_hash", 'cache', $result->data, time() + variable_get('flickr_cache_duration', 3600));
+ cache_set("flickr_$arg_hash", $result->data, 'cache', time() + variable_get('flickr_cache_duration', 3600));
}
return $response;
@@ -159,6 +159,9 @@
if (!isset($attributes) || !is_array($attributes)) {
$attributes = array();
}
+ if (empty($attributs['class'])) {
+ $attributes['class'] = NULL;
+ }
// photoset's use primary instead of id to specify the image.
if (isset($photo['primary'])) {
=== modified file 'flickr.info'
--- flickr.info 2008-02-02 20:04:40 +0000
+++ flickr.info 2008-02-02 23:15:05 +0000
@@ -2,3 +2,4 @@
name = Flickr
description = Flickr and Drupal integration.
package = Flickr
+core = 6.x
=== modified file 'flickr.install'
--- flickr.install 2008-02-02 20:04:40 +0000
+++ flickr.install 2008-02-02 23:15:05 +0000
@@ -2,47 +2,43 @@
// $Id: flickr.install,v 1.2 2007/01/06 00:41:03 andrewlevine Exp $
function flickr_install() {
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- db_query('
- CREATE TABLE {flickr_users} (
- `uid` INT( 10 ) UNSIGNED NOT NULL ,
- `nsid` VARCHAR( 64 ) NOT NULL,
- `identifier` VARCHAR( 64 ) NOT NULL ,
- PRIMARY KEY ( `uid` )
- ) /*!40100 DEFAULT CHARACTER SET utf8 */;
- ');
- break;
- }
+ drupal_install_schema('flickr');
}
function flickr_uninstall() {
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- db_query('DROP TABLE IF EXISTS {flickr_users}');
- break;
- }
+ drupal_uninstall_schema('flickr');
+}
+
+function flickr_schema() {
+ $schema['flickr_users'] = array(
+ 'description' => t('Connects Drupal users to their Flickr accounts.'),
+ 'fields' => array(
+ 'uid' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'description' => t('Primary Key: Drupal user ID'),
+ ),
+ 'nsid' => array(
+ 'type' => 'varchar',
+ 'length' => 64,
+ 'not null' => TRUE,
+ 'description' => t('Flickr NSID'),
+ ),
+ 'identifier' => array(
+ 'type' => 'varchar',
+ 'length' => 64,
+ 'not null' => TRUE,
+ 'description' => t('Flickr identifier'),
+ ),
+ ),
+ 'primary key' => array('uid'),
+ );
+ return $schema;
}
/**
* Adding a table to map Drupal users to Flickr users
*/
function flickr_update_1() {
- $ret = array();
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql('
- CREATE TABLE IF NOT EXISTS {flickr_users} (
- `uid` INT( 10 ) UNSIGNED NOT NULL ,
- `nsid` VARCHAR( 64 ) NOT NULL,
- `identifier` VARCHAR( 64 ) NOT NULL ,
- PRIMARY KEY ( `uid` )
- ) /*!40100 DEFAULT CHARACTER SET utf8 */;
- ');
- break;
- }
- return $ret;
+ flickr_install();
}
=== modified file 'flickr.module'
--- flickr.module 2008-02-02 20:04:40 +0000
+++ flickr.module 2008-02-02 23:15:05 +0000
@@ -7,10 +7,10 @@
/**
* Implementation of hook_help().
*/
-function flickr_help($section) {
+function flickr_help($section, $arg) {
switch ($section) {
case 'admin/settings/flickr':
- return t("You will need a Flickr API key to use this module. You can apply for one at @link", array('@link' => url('http://www.flickr.com/services/api/keys/apply/')));
+ return t("You will need a Flickr API key to use this module. You can apply for one at @link", array('@link' => url('http://www.flickr.com/services/api/keys/apply/')));
case 'admin/help#flickr':
return t('The flickr module uses XML-RPC to connect to Flickr\'s API and retreive photo information.');
}
@@ -28,184 +28,63 @@
}
/**
+ * Implementation of hook_theme().
+ */
+function flickr_theme() {
+ return array(
+ 'flickr_photo' => array(
+ 'arguments' => array('size' => NULL, 'format' => NULL, 'attribs' => NULL),
+ ),
+ 'flickr_photo_box' => array(
+ 'arguments' => array('p', 'size' => NULL, 'format' => NULL, 'attribs' => NULL),
+ ),
+ 'flickr_photos' => array(
+ 'arguments' => array('uid' => NULL, 'photos' => NULL),
+ ),
+ 'flickr_photoset' => array(
+ 'arguments' => array('ps', 'owner', 'size', 'attribs' => NULL),
+ ),
+ );
+}
+
+/**
* Implementation of hook_menu().
*/
-function flickr_menu($may_cache) {
- global $user;
- $items = array();
-
- if ($may_cache) {
- $items[] = array(
- 'path' => 'admin/settings/flickr', 'title' => t('Flickr'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('flickr_admin_settings'),
- 'access' => user_access('administer site configuration'),
- 'type' => MENU_NORMAL_ITEM,
- 'description' => t('Change settings for the flickr module.'));
-
- $items[] = array(
- 'path' => 'flickr',
- 'title' => t('Flickr photos'),
- 'access' => TRUE,
- 'type' => MENU_CALLBACK,
- 'callback' => 'flickr_photos',
- 'description' => t('Flickr photos of default user id.'));
-
- $items[] = array(
- 'path' => 'flickr/auth',
- 'access' => TRUE,
- 'type' => MENU_CALLBACK,
- 'callback' => 'flickr_auth_callback');
- }
- else {
- if (arg(0) == 'flickr' && is_numeric(arg(1)) && arg(1) > 0) {
- $account = user_load(array('uid' => arg(1)));
- if ($account !== FALSE && isset($account->flickr['nsid'])) {
- $nsid = $account->flickr['nsid'];
- $admin_access = user_access('administer flickr');
- // let a user view their own account or all if they have permission
- $view_access |= (user_access('view own flickr photos') && ($user->uid == arg(1))) ||
- user_access('view all flickr photos');
- // Only admins can view blocked accounts
- $view_access &= $account->status || $admin_access;
-
- //main flickr user page(photos)
- $items[] = array(
- 'path' => 'flickr/'. arg(1),
- 'title' => t("@user's Flickr", array('@user' => $account->name)),
- 'type' => MENU_CALLBACK,
- 'callback' => 'flickr_photos',
- 'callback arguments' => array(arg(1)),
- 'access' => $view_access,
- );
- $items[] = array(
- 'path' => 'flickr/'. arg(1) .'/photos',
- 'title' => t('Photos'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => -10,
- 'access' => $view_access,
- );
- }
- elseif ($account !== FALSE && !isset($account->flickr['nsid'])) {
- drupal_set_message(t('%user does not have a Flickr account', array('%user' => $account->name)), 'error');
- }
- }
- }
-
+function flickr_menu() {
+ $items['admin/settings/flickr'] = array(
+ 'title' => 'Flickr',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('flickr_admin_settings'),
+ 'access arguments' => array('administer site configuration'),
+ 'description' => 'Change settings for the flickr module.',
+ 'file' => 'flickr.admin.inc',
+ );
+ $items['flickr'] = array(
+ 'title' => 'Flickr photos',
+ 'type' => MENU_CALLBACK,
+ 'page callback' => 'flickr_photos',
+ 'access callback' => TRUE,
+ 'description' => 'Flickr photos of default user id.',
+ );
+ $items['flickr/%user'] = array(
+ 'title' => 'Flickr photos',
+ 'type' => MENU_CALLBACK,
+ 'page callback' => 'flickr_photos',
+ 'page arguments' => array(1),
+ 'access arguments' => array('view own flickr photos', 'administer flickr'),
+ 'description' => 'Flickr photos of specified user.',
+ // How to handle own photos, blocked accounts, accounts w/o flickr ID
+ );
+ $items['flickr/auth'] = array(
+ 'type' => MENU_CALLBACK,
+ 'access callback' => TRUE,
+ 'page callback' => 'flickr_auth_callback',
+ );
return $items;
}
/**
- * Implementation of hook_settings
- */
-function flickr_admin_settings() {
- $form['#validate'] = array('flickr_admin_settings_validate' => array());
- $form['flickr_api_key'] = array(
- '#type' => 'textfield',
- '#title' => t('API Key'),
- '#required' => TRUE,
- '#default_value' => variable_get('flickr_api_key', ''),
- '#description' => t('API Key from Flickr'),
- );
- $form['flickr_api_secret'] = array(
- '#type' => 'textfield',
- '#title' => t('API Shared Secret'),
- '#required' => TRUE,
- '#default_value' => variable_get('flickr_api_secret', ''),
- '#description' => t("API key's secret from Flickr."),
- );
- $form['flickr_default_userid'] = array(
- '#type' => 'textfield',
- '#title' => t('Default Flickr User Id'),
- '#default_value' => variable_get('flickr_default_userid', ''),
- '#description' => t("An, optional, default Flickr username or user id. This will be used when no user is specified."),
- );
- $times = array(900, 1800, 2700, 3600, 7200, 10800, 14400, 18000, 21600, 43200, 86400);
- $ageoptions = drupal_map_assoc($times, 'format_interval');
- $form['flickr_cache_duration'] = array(
- '#type' => 'select',
- '#title' => t('Update interval'),
- '#options' => $ageoptions,
- '#default_value' => variable_get('flickr_cache_duration', 3600),
- '#description' => t("The refresh interval indicating how often you want to check cached Flickr API calls are up to date."),
- );
-
- // we need an api key before we can verify usernames
- if (!$form['flickr_api_key']['#default_value']) {
- $form['flickr_default_userid']['#disabled'] = TRUE;
- $form['flickr_default_userid']['#description'] .= t(" Disabled until a valid API Key is set.");
- }
-
- return system_settings_form($form);
-}
-
-function flickr_admin_settings_validate($form_id, $form) {
- $key = trim($form['flickr_api_key']);
- $sec = trim($form['flickr_api_secret']);
- $uid = trim($form['flickr_default_userid']);
-
- if ($key && (preg_match('/^[A-Fa-f\d]{32}$/', $key) != 1)) {
- form_set_error('flickr_api_key', t('This does not appear to be a Flickr API key.'));
- }
- if ($sec && (preg_match('/^[A-Fa-f\d]{16}$/', $sec) != 1)) {
- form_set_error('flickr_api_secret', t('This does not appear to be a Flickr API secret.'));
- }
- if ($uid) {
- if (flickr_is_nsid($uid)) {
- // it's already a uid
- }
- else {
- $user = flickr_user_find_by_username($uid);
- if (!$user) {
- form_set_error('flickr_default_userid', t('%uid is not a Flickr user id and it does not appear to be a valid user name.', array('%uid' => $uid)));
- }
- }
- }
-}
-
-function flickr_admin_settings_submit($form_id, $form) {
- // clean up the data ...
- $form['flickr_api_key'] = trim($form['flickr_api_key']);
- $form['flickr_api_secret'] = trim($form['flickr_api_secret']);
- $form['flickr_default_userid'] = trim($form['flickr_default_userid']);
-
- // ... replace the usernames with a user id ...
- if (!flickr_is_nsid($form['flickr_default_userid'])) {
- $username = $form['flickr_default_userid'];
- if ($user = flickr_user_find_by_username($username)) {
- drupal_set_message(t("The Flickr username %username has been replaced with the corresponding user id %uid.", array('%username' => $form['flickr_default_userid'], '%uid' => $user['id'])));
- $form['flickr_default_userid'] = $user['id'];
- }
- }
-
- // ... and save the settings
- system_settings_form_submit($form_id, $form);
-}
-
-function theme_flickr_photo($p, $size = NULL, $format = NULL, $attribs = NULL) {
- $img = flickr_img($p, $size, $attribs);
- $photo_url = flickr_photo_page_url($p['owner'], $p['id']);
- $title = is_array($p['title']) ? $p['title']['_content'] : $p['title'];
- return l($img, $photo_url, array('title' => $title), NULL, NULL, TRUE, TRUE);
-}
-
-function theme_flickr_photo_box($p, $size = NULL, $format = NULL, $attribs = NULL) {
- $img = flickr_img($p, $size, $attribs);
- $title = is_array($p['title']) ? $p['title']['_content'] : $p['title'];
- $photo_url = flickr_photo_page_url($p['owner'], $p['id']);
-
- $output .= "