=== added file 'audio.admin.inc'
--- audio.admin.inc 1970-01-01 00:00:00 +0000
+++ audio.admin.inc 2008-03-30 05:09:24 +0000
@@ -0,0 +1,264 @@
+ 'textfield',
+ '#title' => t('Default node title format'),
+ '#maxlength' => 128,
+ '#default_value' => variable_get('audio_default_title_format', '[audio-tag-title-raw] by [audio-tag-artist-raw]'),
+ '#description' => t("The audio node's title can use the file's metadata as variables. This will be used as the default title for all new audio nodes. By using the tokens listed below, you can automatically create titles from things like a song's artist or title. Note: the node title is escaped so it is safe to use the -raw tokens."),
+ );
+ $form['audio_teaser_format'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Node teaser format'),
+ '#maxlength' => 128,
+ '#default_value' => variable_get('audio_teaser_format', '[audio-player]
[audio-length]'),
+ '#description' => t("Use this setting to customize the teasers for audio nodes. Using the tokens listed below you can select what information about the file will be displayed. Note: the teaser is not escaped so it is unsafe to use the -raw tokens."),
+ );
+ $form['token_help'] = array(
+ '#title' => t('List of available tokens'),
+ '#type' => 'fieldset',
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#description' => t('This is a list of the tokens that can be used in the titles and teasers of audio nodes.'),
+ 'help' => array('#value' => theme('token_help', 'node')),
+ );
+ $form['audio_allowed_extensions'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Permitted audio file extensions'),
+ '#maxlength' => 128,
+ '#default_value' => variable_get('audio_allowed_extensions', 'mp3 wav ogg'),
+ '#description' => t('Audio file extensions that users can upload. Separate extensions with a space and do not include a leading dot.'),
+ );
+ $form['audio_default_downloadable'] = array(
+ '#type' => 'checkbox',
+ '#title' => t("Downloadable by default"),
+ '#default_value' => variable_get('audio_default_downloadable', 1),
+ '#description' => t('Check this to make downloadable the default setting for new audio nodes. You should be aware that even when audio is not marked as downloadable, clever users can still download it, this just makes the work harder. '),
+ );
+
+ return system_settings_form($form);
+}
+
+function audio_admin_settings_validate($form, &$form_state) {
+ // Ensure they don't try to slip raw tokens in.
+ if (preg_match("/\[.*?\-raw\s*?\]/i", $form_state['values']['audio_teaser_format'])) {
+ form_set_error('audio_teaser_format', t('Raw tokens are not allowed.'));
+ }
+}
+
+/**
+ * The ID3 tag settings page.
+ */
+function audio_admin_settings_metadata() {
+ $settings = audio_get_tag_settings();
+ $form['audio_tag_settings'] = array(
+ '#tree' => TRUE,
+ '#theme' => 'audio_admin_settings_metadata',
+ );
+ foreach ($settings as $tag => $setting) {
+ $form['audio_tag_settings'][$tag]['name'] = array(
+ '#type' => 'item',
+ '#value' => $tag
+ );
+ $form['audio_tag_settings'][$tag]['autocomplete'] = array(
+ '#type' => 'checkbox',
+ '#default_value' => $setting['autocomplete']
+ );
+ $form['audio_tag_settings'][$tag]['required'] = array(
+ '#type' => 'checkbox',
+ '#default_value' => $setting['required'],
+ );
+ $form['audio_tag_settings'][$tag]['hidden'] = array(
+ '#type' => 'checkbox',
+ '#default_value' => $setting['hidden'],
+ );
+ $form['audio_tag_settings'][$tag]['browsable'] = array(
+ '#type' => 'checkbox',
+ '#default_value' => $setting['browsable'],
+ );
+ $form['audio_tag_settings'][$tag]['writetofile'] = array(
+ '#type' => 'checkbox',
+ '#default_value' => $setting['writetofile'],
+ );
+ $form['audio_tag_settings'][$tag]['weight'] = array(
+ '#type' => 'weight',
+ '#default_value' => $setting['weight']
+ );
+ $form['audio_tag_settings'][$tag]['delete'] = array(
+ '#type' => 'checkbox',
+ '#default_value' => FALSE,
+ );
+ }
+
+ // Add in a row for a new tag.
+ $form['audio_tag_settings']['new']['name'] = array(
+ '#type' => 'textfield',
+ '#size' => 15,
+ '#maxlength' => 45,
+ );
+ $form['audio_tag_settings']['new']['autocomplete'] = array(
+ '#type' => 'checkbox',
+ '#default_value' => TRUE,
+ );
+ $form['audio_tag_settings']['new']['required'] = array(
+ '#type' => 'checkbox',
+ '#default_value' => FALSE,
+ );
+ $form['audio_tag_settings']['new']['hidden'] = array(
+ '#type' => 'checkbox',
+ '#default_value' => FALSE,
+ );
+ $form['audio_tag_settings']['new']['browsable'] = array(
+ '#type' => 'checkbox',
+ '#default_value' => TRUE,
+ );
+ $form['audio_tag_settings']['new']['writetofile'] = array(
+ '#type' => 'checkbox',
+ '#default_value' => FALSE,
+ );
+ $form['audio_tag_settings']['new']['weight'] = array(
+ '#type' => 'weight',
+ '#default_value' => 0,
+ );
+
+ return system_settings_form($form);
+}
+
+/**
+ * Save the ID3 tag settings, we can't use system_settings_form_submit() as the
+ * form callback because it wouldn't call theme_audio_settings().
+ */
+function audio_admin_settings_metadata_submit($form, $form_state) {
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
+
+ if ($op == t('Reset to defaults')) {
+ variable_del('audio_tag_settings');
+ drupal_set_message(t('The configuration options have been reset to their default values.'));
+ }
+ else {
+ // Remove any deleted tags.
+ foreach ($form_state['values']['delete'] as $field) {
+ if ($field) {
+ unset($form_state['values']['audio_tag_settings'][$field]);
+ }
+ }
+ // If there's a new tag, add it in.
+ if ($form_state['values']['audio_tag_settings']['new']['name']) {
+ $name = $form_state['values']['audio_tag_settings']['new']['name'];
+ $form_state['values']['audio_tag_settings'][$name] = $form_state['values']['audio_tag_settings']['new'];
+ }
+ unset($form_state['values']['audio_tag_settings']['new']);
+
+ // Sort by the weight and then by name of the tag. I'm sure there's a
+ // better way to do this...
+ foreach ($form_state['values']['audio_tag_settings'] as $tag => $settings) {
+ $weights[$tag] = $settings['weight'];
+ $names[$tag] = $tag;
+ }
+ array_multisort($weights, SORT_ASC, SORT_NUMERIC, $names, SORT_ASC, SORT_STRING);
+ $audio_tag_settings = array();
+ foreach ($names as $tag) {
+ $audio_tag_settings[$tag] = $form_state['values']['audio_tag_settings'][$tag];
+ }
+
+ // ...and save it.
+ variable_set('audio_tag_settings', $audio_tag_settings);
+
+ drupal_set_message(t('The configuration options have been saved.'));
+ }
+}
+
+/**
+ * Format the id3tags settings form as a table.
+ */
+function theme_audio_admin_settings_metadata($form_element) {
+ $rows = array();
+ foreach (element_children($form_element) as $key) {
+ $row = array();
+ if (is_array($form_element[$key]['name'])) {
+ $row[] = drupal_render($form_element[$key]['name']);
+ $row[] = drupal_render($form_element[$key]['autocomplete']);
+ $row[] = drupal_render($form_element[$key]['required']);
+ $row[] = drupal_render($form_element[$key]['hidden']);
+ $row[] = drupal_render($form_element[$key]['browsable']);
+ $row[] = drupal_render($form_element[$key]['writetofile']);
+ $row[] = drupal_render($form_element[$key]['weight']);
+ $row[] = drupal_render($form_element[$key]['delete']);
+ }
+ $rows[] = $row;
+ }
+ $header = array(t('Tag'), t('Autocompleted'), t('Required'), t('Hidden'), t('Browsable'),
+ t('Written to file'), t('Weight'), t('Delete'));
+
+ $output = theme('table', $header, $rows);
+ $output .= drupal_render($form_element);
+ return $output;
+}
+
+/**
+ * Form for player settings.
+ */
+function audio_admin_settings_players() {
+ $form = array();
+
+ $form['players'] = array(
+ '#theme' => 'audio_admin_settings_players',
+ );
+
+ $options = array();
+ foreach (audio_get_players('formats') as $format => $players) {
+ foreach ($players as $id => $player) {
+ $options[$id] = $player['title'];
+ $form['players'][$format][$id]['description'] = array(
+ '#type' => 'item',
+ '#title' => t('Description'),
+ '#value' => $player['description'],
+ );
+ $form['players'][$format][$id]['url'] = array(
+ '#type' => 'item',
+ '#title' => t('URL'),
+ '#value' => $player['url'],
+ );
+ $form['players'][$format][$id]['preview'] = array(
+ '#type' => 'item',
+ '#title' => t('URL'),
+ '#value' => drupal_get_path('module', $player['module']) .'/'. $player['preview'],
+ );
+ }
+ $form['audio_player_'. $format] = array(
+ '#type' => 'radios',
+ '#title' => t('Player'),
+ '#default_value' => variable_get('audio_player_'. $format, '1pixelout'),
+ '#options' => $options,
+ );
+ }
+ return system_settings_form($form);
+}
+
+function theme_audio_admin_settings_players($form_element) {
+ $output = '';
+ $header = array(t('Player'), t('Description'), t('Homepage'));
+ foreach (element_children($form_element) as $format) {
+ $output .= '
'. t('%format files', array('%format' => $format)) .'
';
+ $rows = array();
+ foreach (element_children($form_element[$format]) as $name) {
+ $rows[] = array(
+ drupal_render($form['audio_player_'. $format][$name])
+ . theme('image', $form_element[$format][$name]['preview']['#value'], 'preview', 'preview'),
+ check_plain($form_element[$format][$name]['description']['#value']),
+ l(t('Link'), $form_element[$format][$name]['url']['#value']),
+ );
+ unset($form_element[$format][$name]['description']);
+ unset($form_element[$format][$name]['url']);
+ unset($form_element[$format][$name]['preview']);
+ }
+ unset($form['audio_player_'. $format]);
+ $output .= theme('table', $header, $rows);
+ }
+ return $output . drupal_render($form);
+}
=== modified file 'README.txt' (properties changed)
=== modified file 'audio.info'
--- audio.info 2008-03-29 22:24:08 +0000
+++ audio.info 2008-03-30 01:18:28 +0000
@@ -2,4 +2,7 @@
name = Audio
description = Allows you to upload and playback audio files.
package = Audio
-dependencies = token views views_rss
\ No newline at end of file
+core = 6.x
+dependencies[] = token
+dependencies[] = views
+#dependencies[] = views_rss
=== modified file 'audio.install'
--- audio.install 2008-03-29 22:24:08 +0000
+++ audio.install 2008-03-30 01:18:28 +0000
@@ -2,87 +2,10 @@
// $Id: audio.install,v 1.18 2007/11/02 05:56:00 drewish Exp $
/**
- * Install the initial schema.
+ * Implementation of hook_install().
*/
function audio_install() {
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- db_query("
- CREATE TABLE {audio} (
- `vid` int(10) unsigned NOT NULL default '0',
- `nid` int(10) unsigned NOT NULL default '0',
- `title_format` varchar(128) default '',
- `play_count` int(10) unsigned NOT NULL default '0',
- `download_count` int(10) unsigned NOT NULL default '0',
- `downloadable` tinyint(1) NOT NULL default '1',
- `file_format` varchar(10) NOT NULL default '',
- `file_mime` varchar(255) NOT NULL default '',
- `file_name` varchar(255) NOT NULL default '',
- `file_path` varchar(255) NOT NULL default '',
- `file_size` int(10) unsigned NOT NULL default '0',
- `sample_rate` int(10) unsigned NOT NULL default '0',
- `channel_mode` varchar(10) NOT NULL default '',
- `bitrate` float unsigned NOT NULL default '0',
- `bitrate_mode` varchar(4) NOT NULL default '',
- `playtime` varchar(10) NOT NULL default '',
- PRIMARY KEY (`vid`)
- ) /*!40100 DEFAULT CHARACTER SET utf8 */;
- ");
- db_query("
- CREATE TABLE {audio_metadata} (
- `vid` int(10) unsigned NOT NULL default '0',
- `tag` varchar(45) NOT NULL default '',
- `value` varchar(255) NOT NULL default '',
- `clean` varchar(255) NOT NULL default '',
- PRIMARY KEY (`vid`,`tag`,`value`),
- KEY `audio_metadata_tags` (`clean`)
- ) /*!40100 DEFAULT CHARACTER SET utf8 */;
- ");
- break;
-
- case 'pgsql':
- db_query("
- CREATE TABLE {audio} (
- vid integer NOT NULL default '0'
- CHECK (vid >= 0),
- nid integer NOT NULL default '0'
- CHECK (nid >= 0),
- title_format varchar(128) default '',
- play_count integer NOT NULL default '0'
- CHECK (play_count >= 0),
- download_count integer NOT NULL default '0'
- CHECK (download_count >= 0),
- downloadable smallint NOT NULL default '1',
- file_format varchar(10) NOT NULL default '',
- file_mime varchar(255) NOT NULL default '',
- file_name varchar(255) NOT NULL default '',
- file_path varchar(255) NOT NULL default '',
- file_size integer NOT NULL default '0'
- CHECK (filesize >= 0),
- sample_rate integer NOT NULL default '0'
- CHECK (sample_rate >= 0),
- channel_mode varchar(10) NOT NULL default '',
- bitrate float NOT NULL default '0'
- CHECK (bitrate >= 0),
- bitrate_mode varchar(4) NOT NULL default '',
- playtime varchar(10) NOT NULL default '',
- PRIMARY KEY (vid)
- );
- ");
- db_query("
- CREATE TABLE {audio_metadata} (
- vid integer NOT NULL default '0'
- CHECK (vid >= 0),
- tag varchar(45) NOT NULL default '',
- value varchar(255) NOT NULL default '',
- clean varchar(255) NOT NULL default '',
- PRIMARY KEY (vid, tag, value)
- );
- ");
- break;
- }
-
+ drupal_install_schema('audio');
_audio_add_default_perms();
}
@@ -90,10 +13,7 @@
* Implementation of hook_uninstall().
*/
function audio_uninstall() {
- db_query('DROP TABLE {audio}');
- db_query('DROP TABLE {audio_file}');
- db_query('DROP TABLE {audio_metadata}');
-
+ drupal_uninstall_schema('audio');
variable_del('audio_allowed_extensions');
variable_del('audio_block_random_n');
variable_del('audio_default_downloadable');
@@ -105,6 +25,141 @@
variable_del('audio_teaser_format');
}
+function audio_schema() {
+ $schema['audio'] = array(
+ 'description' => t('Main audio table.'),
+ 'fields' => array(
+ 'vid' => array(
+ 'type' => 'int',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ ),
+ 'nid' => array(
+ 'type' => 'int',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ ),
+ 'title_format' => array(
+ 'type' => 'varchar',
+ 'length' => 128,
+ 'default' => '',
+ ),
+ 'play_count' => array(
+ 'type' => 'int',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
+ 'download_count' => array(
+ 'type' => 'int',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
+ 'downloadable' => array(
+ 'type' => 'int',
+ 'size' => 'tiny',
+ 'not null' => TRUE,
+ 'default' => 1,
+ ),
+ 'file_format' => array(
+ 'type' => 'varchar',
+ 'length' => 10,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ 'file_mime' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ 'file_name' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ 'file_path' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ 'file_size' => array(
+ 'type' => 'int',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
+ 'sample_rate' => array(
+ 'type' => 'int',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
+ 'channel_mode' => array(
+ 'type' => 'varchar',
+ 'length' => 10,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ 'bitrate' => array(
+ 'type' => 'float',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
+ 'bitrate_mode' => array(
+ 'type' => 'varchar',
+ 'length' => 4,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ 'playtime' => array(
+ 'type' => 'varchar',
+ 'length' => 10,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ ),
+ 'primary key' => array('vid'),
+ );
+ $schema['audio_metadata'] = array(
+ 'description' => t('Extended data about audio files.'),
+ 'fields' => array(
+ 'vid' => array(
+ 'type' => 'int',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ ),
+ 'tag' => array(
+ 'type' => 'varchar',
+ 'length' => 45,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ 'value' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ 'clean' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ ),
+ 'primary key' => array('vid', 'tag', 'value'),
+ 'indexes' => array(
+ 'audio_metadata_tags' => array('clean'),
+ ),
+ );
+ return $schema;
+}
+
/**
* Add permission to download and view audio to the anonymous and authenticated
* roles by default.
@@ -135,18 +190,22 @@
*/
function audio_update_9() {
$ret = array();
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql(
-<< 'int',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ 'default' => 0,
+ )
+ );
+ db_add_field($ret, 'audio', 'download_count',
+ array(
+ 'type' => 'int',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ 'default' => 0,
+ )
+ );
return $ret;
}
@@ -181,18 +240,14 @@
*/
function audio_update_11() {
$ret = array();
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql(
-<< 'varchar',
+ 'length' => 45,
+ 'not null' => TRUE,
+ 'default' => '',
+ )
+ );
return $ret;
}
@@ -270,13 +325,8 @@
*/
function audio_update_5200() {
$ret = array();
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql("UPDATE {audio_file} SET filename = origname");
- $ret[] = update_sql("ALTER TABLE {audio_file} DROP COLUMN `origname`");
- break;
- }
+ $ret[] = update_sql("UPDATE {audio_file} SET filename = origname");
+ db_drop_field($ret, 'audio_file', 'origname');
return $ret;
}
@@ -328,22 +378,64 @@
*/
function audio_update_5202() {
$ret = array();
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql("ALTER TABLE {audio}
- CHANGE COLUMN `fileformat` `file_format` varchar(10) NOT NULL default '',
- ADD COLUMN `file_mime` varchar(255) NOT NULL default '' AFTER `file_format`,
- ADD COLUMN `file_name` varchar(255) NOT NULL default '' AFTER `file_mime`,
- ADD COLUMN `file_path` varchar(255) NOT NULL default '' AFTER `file_name`,
- ADD COLUMN `file_size` INTEGER UNSIGNED NOT NULL default 0 AFTER `file_path`,
- ADD COLUMN `remote_url` varchar(255) NOT NULL default '' AFTER `file_size`,
- ADD COLUMN `remote_size` INTEGER UNSIGNED NOT NULL default 0 AFTER `remote_url`
- ");
- $ret[] = update_sql("UPDATE {audio} a INNER JOIN {audio_file} af ON a.vid = af.vid SET a.file_name = af.filename, a.file_path = af.filepath, a.file_mime = af.filemime, a.file_size = af.filesize");
- $ret[] = update_sql("DROP TABLE {audio_file}");
- break;
- }
+ db_change_field($ret, 'audio', 'fileformat', 'file_format',
+ array(
+ 'type' => 'varchar',
+ 'length' => 10,
+ 'not null' => TRUE,
+ 'default' => '',
+ )
+ );
+ db_add_field($ret, 'audio', 'file_mime',
+ array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ )
+ );
+ db_add_field($ret, 'audio', 'file_name',
+ array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ )
+ );
+ db_add_field($ret, 'audio', 'file_path',
+ array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ )
+ );
+ db_add_field($ret, 'audio', 'file_size',
+ array(
+ 'type' => 'int',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ 'default' => 0,
+ )
+ );
+ db_add_field($ret, 'audio', 'remote_size',
+ array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ )
+ );
+ db_add_field($ret, 'audio', 'remote_size',
+ array(
+ 'type' => 'int',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ 'default' => 0,
+ )
+ );
+ $ret[] = update_sql("UPDATE {audio} a INNER JOIN {audio_file} af ON a.vid = af.vid SET a.file_name = af.filename, a.file_path = af.filepath, a.file_mime = af.filemime, a.file_size = af.filesize");
+ db_drop_table($ret, 'audio_file');
// Build an array of renamed tokens.
$tokens = array(
=== modified file 'audio.module' (properties changed)
--- audio.module 2008-03-29 22:24:08 +0000
+++ audio.module 2008-03-30 05:09:24 +0000
@@ -10,7 +10,7 @@
/**
* Implementation of hook_help().
*/
-function audio_help($section) {
+function audio_help($section, $arg) {
switch ($section) {
case 'audio/by':
return t("You can browse for audio by any of the following fields.");
@@ -52,68 +52,104 @@
/**
* Implementation of hook_menu().
*/
-function audio_menu($may_cache) {
+function audio_menu() {
$items = array();
- if ($may_cache) {
- $items[] = array(
- 'path' => 'admin/settings/audio', 'title' => t('Audio settings'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('audio_admin_settings'),
- 'access' => user_access('administer site configuration'),
- 'type' => MENU_NORMAL_ITEM,
- 'description' => t('Change settings for the audio module.'),
- );
- $items[] = array(
- 'path' => 'admin/settings/audio/main', 'title' => t('Audio'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('audio_admin_settings'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => '-10',
- );
- $items[] = array(
- 'path' => 'admin/settings/audio/metadata', 'title' => t('Metadata tags'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('audio_admin_settings_metadata'),
- 'type' => MENU_LOCAL_TASK,
- );
- $items[] = array(
- 'path' => 'admin/settings/audio/players', 'title' => t('Players'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('audio_admin_settings_players'),
- 'type' => MENU_LOCAL_TASK,
- );
-
- $items[] = array(
- 'path' => 'audio/autocomplete',
- 'callback' => 'audio_autocomplete',
- 'access' => user_access('access content'),
- 'type' => MENU_CALLBACK,
- );
- $items[] = array(
- 'path' => 'audio/by', 'title' => t('Browse by...'),
- 'access' => user_access('access content'),
- 'type' => MENU_NORMAL_ITEM,
- 'callback' => 'audio_page_browse_by',
- );
-
- $items[] = array(
- 'path' => 'audio/download',
- 'access' => user_access('access content'),
- 'type' => MENU_CALLBACK,
- 'callback' => 'audio_download',
- );
- $items[] = array(
- 'path' => 'audio/play',
- 'access' => user_access('access content'),
- 'type' => MENU_CALLBACK,
- 'callback' => 'audio_play',
- );
- }
+ $items['admin/settings/audio'] = array(
+ 'title' => 'Audio settings',
+ 'description' => 'Change settings for the audio module.',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('audio_admin_settings'),
+ 'access arguments' => array('administer site configuration'),
+ 'file' => 'audio.admin.inc',
+ );
+ $items['admin/settings/audio/main'] = array(
+ 'title' => 'Audio',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('audio_admin_settings'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => '-10',
+ 'file' => 'audio.admin.inc',
+ );
+ $items['admin/settings/audio/metadata'] = array(
+ 'title' => 'Metadata tags',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('audio_admin_settings_metadata'),
+ 'type' => MENU_LOCAL_TASK,
+ 'file' => 'audio.admin.inc',
+ );
+ $items['admin/settings/audio/players'] = array(
+ 'title' => 'Players',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('audio_admin_settings_players'),
+ 'type' => MENU_LOCAL_TASK,
+ 'file' => 'audio.admin.inc',
+ );
+
+ $items['audio/autocomplete'] = array(
+ 'page callback' => 'audio_autocomplete',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['audio/by'] = array(
+ 'title' => 'Browse by...',
+ 'page callback' => 'audio_page_browse_by',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_NORMAL_ITEM,
+ );
+
+ $items['audio/download'] = array(
+ 'page callback' => 'audio_download',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['audio/play'] = array(
+ 'page callback' => 'audio_play',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+
return $items;
}
/**
+ * Implementation of hook_theme
+ */
+function audio_theme() {
+ return array(
+ 'audio_file_form' => array(
+ 'arguments' => array('form'),
+ ),
+ 'audio_admin_settings_metadata' => array(
+ 'arguments' => array('form_element'),
+ 'file' => 'audio.admin.inc',
+ ),
+ 'audio_admin_settings_players' => array(
+ 'arguments' => array('form_element'),
+ 'file' => 'audio.admin.inc',
+ ),
+ 'audio_default_node_player' => array(
+ 'arguments' => array('node'),
+ ),
+ 'audio_teaser' => array(
+ 'arguments' => array('node'),
+ ),
+ 'audio_display' => array(
+ 'arguments' => array('node'),
+ ),
+ 'audio_format_tag' => array(
+ 'arguments' => array('tag', 'value', 'setting'),
+ ),
+ 'audio_format_filelength' => array(
+ 'arguments' => array('fileinfo'),
+ ),
+ 'audio_format_fileformat' => array(
+ 'arguments' => array('fileinfo'),
+ ),
+ );
+}
+
+/**
* Implementation of hook_node_info().
*/
function audio_node_info() {
@@ -277,8 +313,6 @@
}
}
-
-
/**
* Implementation of hook_link().
*/
@@ -396,7 +430,7 @@
$node->title_format = variable_get('audio_default_title_format', '[audio-tag-title-raw] by [audio-tag-artist-raw]');
}
$node->title = token_replace($node->title_format, 'node', $node);
- form_set_value($form['title'], $node->title);
+ $form_state['values']['title'] = $node->title; // FIXME
}
/**
@@ -429,13 +463,13 @@
if (file_exists($fields['file_path'])) {
// TODO: should these links be by vid?
- $ret['url_play'] = url('audio/play/'. $node->nid, NULL, NULL, TRUE);
+ $ret['url_play'] = url('audio/play/'. $node->nid, array('absolution' => TRUE));
if ($ret['audio_file']['downloadable']) {
// iTunes and other podcasting programs check the url to determine the
// file type. we'll add the original file name on to the end. see issues
// #35398 and #68716 for more info.
$url = 'audio/download/'. $node->nid .'/'. $fields['file_name'];
- $ret['url_download'] = url($url , NULL, NULL, TRUE);
+ $ret['url_download'] = url($url, array('absolute' => TRUE));
}
}
@@ -456,6 +490,7 @@
* Implementation of hook_insert().
*/
function audio_insert(&$node) {
+ drupal_set_message('Hammy hoo...?');
file_move($node->audio_file['file_path'], audio_get_directory(), FILE_EXISTS_RENAME);
// Notify other modules.
@@ -575,7 +610,7 @@
// We need to be aware that a user may try to edit multiple audio nodes at
// once. By using the $nid variable each node's files can be stored separately
// in the session.
- $nid = ($node->nid) ? $node->nid : 'new_node';
+ $nid = empty($node->nid) ? 'new_node' : $node->nid;
// When you enter the edit view the first time we need to clear our files in
// session for this node. This is so if you upload a file, then decide you
// don't want it and reload the form (without posting), the files will be
@@ -585,44 +620,33 @@
}
// Check for an upload.
- if ($file = file_check_upload('audio_upload')) {
- // Check for valid file extensions...
- $extensions = variable_get('audio_allowed_extensions', 'mp3 wav ogg');
- $regex = '/\.('. ereg_replace(' +', '|', preg_quote($extensions)) .')$/i';
- if (!preg_match($regex, $file->filename)) {
- //set an error message and delete the the file
- form_set_error('audio', t('The selected file %name can not be uploaded, because it is only possible to upload files with the following extensions: %files-allowed.', array('%name' => $file->filename, '%files-allowed' => $extensions)));
- file_delete($file->filepath);
- }
- else {
- // Save the upload into Drupal's temp directory.
- $temppath = file_directory_temp() .'/audio/';
- file_check_directory($temppath, TRUE);
-
- $file = file_save_upload($file, $temppath .'/'. $file->filename, FILE_EXISTS_REPLACE);
- $node->audio_file = array(
- 'newfile' => TRUE,
- 'play_count' => 0,
- 'download_count' => 0,
- 'downloadable' => (bool) $_POST['audio_file']['downloadable'],
- 'file_name' => $file->filename,
- 'file_path' => $file->filepath,
- 'file_mime' => $file->filemime,
- 'file_size' => filesize($node->audio_file['file_path']),
- );
-
- // Allow other modules to modify the node.
- audio_invoke_audioapi('upload', $node);
-
- // ...save info to $_POST so that it shows up in both the preview and
- // form. Note that we do this after calling we called our api hook with
- // the upload operation, it gives the audio_id3 module a chance to read
- // the tags.
- $_POST['audio_file'] = $node->audio_file;
- $_POST['audio_tags'] = $node->audio_tags;
-
- $_SESSION['audio_new_file'][$nid] = $node->audio_file['file_path'];
- }
+ $validators = array(
+ 'file_validate_extensions' => variable_get('audio_allowed_extensions', 'mp3 wav ogg'),
+ );
+ if ($file = file_save_upload('audio_upload', $validators)) {
+ file_copy($file, 'files/audio/'. $file->filename, FILE_EXISTS_REPLACE);
+ $node->audio_file = array(
+ 'newfile' => TRUE,
+ 'play_count' => 0,
+ 'download_count' => 0,
+ 'downloadable' => (bool) $_POST['audio_file']['downloadable'],
+ 'file_name' => $file->filename,
+ 'file_path' => $file->filepath,
+ 'file_mime' => $file->filemime,
+ 'file_size' => filesize($node->audio_file['file_path']),
+ );
+
+ // Allow other modules to modify the node.
+ audio_invoke_audioapi('upload', $node);
+
+ // ...save info to $_POST so that it shows up in both the preview and
+ // form. Note that we do this after calling we called our api hook with
+ // the upload operation, it gives the audio_id3 module a chance to read
+ // the tags.
+ $_POST['audio_file'] = $node->audio_file;
+ $_POST['audio_tags'] = $node->audio_tags;
+
+ $_SESSION['audio_new_file'][$nid] = $node->audio_file['file_path'];
}
// Assign a newly uploaded file that's being previewed.
else if (isset($_SESSION['audio_new_file'][$nid])) {
@@ -670,6 +694,15 @@
}
$form['#attributes'] = array('enctype' => 'multipart/form-data');
+
+ if (empty($node->nid)) {
+ $node->audio_file = array(
+ 'file_path' => '',
+ 'file_name' => '',
+ 'file_mime' => '',
+ );
+ }
+
$form['audio_file'] = array(
'#type' => 'fieldset',
'#title' => t('Audio File Info'),
@@ -700,11 +733,11 @@
$form['audio_file']['display_file_path'] = array(
'#type' => 'item',
'#title' => t('Current File'),
- '#value' => isset($file_path) ? $file_path : t('No file is attached.'),
+ '#value' => !empty($file_path) ? $file_path : t('No file is attached.'),
);
// If we've got a file, add the file information fields.
- if (isset($node->audio_file)) {
+ if (!empty($node->audio_file['file_name'])) {
$form['audio_file']['#theme'] = 'audio_file_form';
$form['audio_file']['file_format'] = array(
'#type' => 'select',
@@ -773,21 +806,21 @@
$form['audio_file']['audio_upload'] = array(
'#tree' => FALSE,
'#type' => 'file',
- '#title' => !isset($node->audio_file) ? t('Add a new audio file') : t('Replace this with a new file'),
+ '#title' => empty($node->audio_file['file_name']) ? t('Add a new audio file') : t('Replace this with a new file'),
'#description' => t('Click "Browse..." to select an audio file to upload. Only files with the following extensions are allowed: %allowed-extensions.', array('%allowed-extensions' => variable_get('audio_allowed_extensions', 'mp3 wav ogg'))) .'
'
. t('NOTE: the current PHP configuration limits uploads to %maxsize.', array('%maxsize' => format_size(file_upload_max_size()))),
);
$form['audio_file']['downloadable'] = array(
'#type' => 'checkbox',
'#title' => t('Allow file downloads.'),
- '#default_value' => isset($node->audio_file['downloadable']) ? $node->audio_file['downloadable'] : variable_get('audio_default_downloadable', 1),
+ '#default_value' => !empty($node->audio_file['downloadable']) ? $node->audio_file['downloadable'] : variable_get('audio_default_downloadable', 1),
'#description' => t('If checked, a link will be displayed allowing visitors to download this audio file on to their own computer.') .'
'
. t('WARNING: even if you leave this unchecked, clever users will be able to find a way to download the file. This just makes them work a little harder to find the link.'),
);
// If we've got a file, add the fields for editing meta data.
- if (isset($node->audio_file)) {
+ if (!empty($node->audio_file)) {
$form['audio_tags'] = array(
'#type' => 'fieldset',
'#title' => t('Audio Metadata'),
@@ -797,7 +830,8 @@
);
// Delegate out the dirty work of building form elements.
foreach (audio_get_tag_settings() as $tag => $tag_settings) {
- $form['audio_tags'][$tag] = _audio_build_tag_form($tag, $tag_settings, $node->audio_tags[$tag]);
+ $form['audio_tags'][$tag] = _audio_build_tag_form($tag, $tag_settings,
+ empty($node->audio_tags) ? '' : $node->audio_tags[$tag]);
}
}
@@ -809,7 +843,7 @@
* the watchdog module.
*/
function theme_audio_file_form($form) {
- // List of elements to leave out of the table.
+ // List of elements to leave out of the table.
$skip_list = array('audio_upload' => 1, 'downloadable' => 1);
$rows = array();
@@ -933,267 +967,6 @@
}
}
-
-/**
- * Settings form.
- */
-function audio_admin_settings() {
- $form['audio_default_title_format'] = array(
- '#type' => 'textfield',
- '#title' => t('Default node title format'),
- '#maxlength' => 128,
- '#default_value' => variable_get('audio_default_title_format', '[audio-tag-title-raw] by [audio-tag-artist-raw]'),
- '#description' => t("The audio node's title can use the file's metadata as variables. This will be used as the default title for all new audio nodes. By using the tokens listed below, you can automatically create titles from things like a song's artist or title. Note: the node title is escaped so it is safe to use the -raw tokens."),
- );
- $form['audio_teaser_format'] = array(
- '#type' => 'textfield',
- '#title' => t('Node teaser format'),
- '#maxlength' => 128,
- '#default_value' => variable_get('audio_teaser_format', '[audio-player]
[audio-length]'),
- '#description' => t("Use this setting to customize the teasers for audio nodes. Using the tokens listed below you can select what information about the file will be displayed. Note: the teaser is not escaped so it is unsafe to use the -raw tokens."),
- );
- $form['token_help'] = array(
- '#title' => t('List of available tokens'),
- '#type' => 'fieldset',
- '#collapsible' => TRUE,
- '#collapsed' => TRUE,
- '#description' => t('This is a list of the tokens that can be used in the titles and teasers of audio nodes.'),
- 'help' => array('#value' => theme('token_help', 'node')),
- );
- $form['audio_allowed_extensions'] = array(
- '#type' => 'textfield',
- '#title' => t('Permitted audio file extensions'),
- '#maxlength' => 128,
- '#default_value' => variable_get('audio_allowed_extensions', 'mp3 wav ogg'),
- '#description' => t('Audio file extensions that users can upload. Separate extensions with a space and do not include a leading dot.'),
- );
- $form['audio_default_downloadable'] = array(
- '#type' => 'checkbox',
- '#title' => t("Downloadable by default"),
- '#default_value' => variable_get('audio_default_downloadable', 1),
- '#description' => t('Check this to make downloadable the default setting for new audio nodes. You should be aware that even when audio is not marked as downloadable, clever users can still download it, this just makes the work harder. '),
- );
-
- return system_settings_form($form);
-}
-
-function audio_admin_settings_validate($form_id, $form_values) {
- // Ensure they don't try to slip raw tokens in.
- if (preg_match("/\[.*?\-raw\s*?\]/i", $form_values['audio_teaser_format'])) {
- form_set_error('audio_teaser_format', t('Raw tokens are not allowed.'));
- }
-}
-
-/**
- * The ID3 tag settings page.
- */
-function audio_admin_settings_metadata() {
- $settings = audio_get_tag_settings();
- $form['audio_tag_settings'] = array('#tree' => TRUE);
- foreach ($settings as $tag => $setting) {
- $form['audio_tag_settings'][$tag]['name'] = array(
- '#type' => 'item',
- '#value' => $tag
- );
- $form['audio_tag_settings'][$tag]['autocomplete'] = array(
- '#type' => 'checkbox',
- '#default_value' => $setting['autocomplete']
- );
- $form['audio_tag_settings'][$tag]['required'] = array(
- '#type' => 'checkbox',
- '#default_value' => $setting['required'],
- );
- $form['audio_tag_settings'][$tag]['hidden'] = array(
- '#type' => 'checkbox',
- '#default_value' => $setting['hidden'],
- );
- $form['audio_tag_settings'][$tag]['browsable'] = array(
- '#type' => 'checkbox',
- '#default_value' => $setting['browsable'],
- );
- $form['audio_tag_settings'][$tag]['writetofile'] = array(
- '#type' => 'checkbox',
- '#default_value' => $setting['writetofile'],
- );
- $form['audio_tag_settings'][$tag]['weight'] = array(
- '#type' => 'weight',
- '#default_value' => $setting['weight']
- );
- }
- $delete_options = array();
- foreach ($settings as $tag => $setting) {
- $delete_options[$tag] = '';
- }
- $form['delete'] = array(
- '#type' => 'checkboxes',
- '#options' => $delete_options,
- );
-
- // Add in a row for a new tag.
- $form['audio_tag_settings']['new']['name'] = array(
- '#type' => 'textfield',
- '#size' => 15,
- '#maxlength' => 45,
- );
- $form['audio_tag_settings']['new']['autocomplete'] = array(
- '#type' => 'checkbox',
- '#default_value' => TRUE,
- );
- $form['audio_tag_settings']['new']['required'] = array(
- '#type' => 'checkbox',
- '#default_value' => FALSE,
- );
- $form['audio_tag_settings']['new']['hidden'] = array(
- '#type' => 'checkbox',
- '#default_value' => FALSE,
- );
- $form['audio_tag_settings']['new']['browsable'] = array(
- '#type' => 'checkbox',
- '#default_value' => TRUE,
- );
- $form['audio_tag_settings']['new']['writetofile'] = array(
- '#type' => 'checkbox',
- '#default_value' => FALSE,
- );
- $form['audio_tag_settings']['new']['weight'] = array(
- '#type' => 'weight',
- '#default_value' => 0,
- );
-
- return system_settings_form($form);
-}
-
-/**
- * Save the ID3 tag settings, we can't use system_settings_form_submit() as the
- * form callback because it wouldn't call theme_audio_settings().
- */
-function audio_admin_settings_metadata_submit($form_id, $form_values) {
- $op = isset($_POST['op']) ? $_POST['op'] : '';
-
- if ($op == t('Reset to defaults')) {
- variable_del('audio_tag_settings');
- drupal_set_message(t('The configuration options have been reset to their default values.'));
- }
- else {
- // Remove any deleted tags.
- foreach ($form_values['delete'] as $field) {
- if ($field) {
- unset($form_values['audio_tag_settings'][$field]);
- }
- }
- // If there's a new tag, add it in.
- if ($form_values['audio_tag_settings']['new']['name']) {
- $name = $form_values['audio_tag_settings']['new']['name'];
- $form_values['audio_tag_settings'][$name] = $form_values['audio_tag_settings']['new'];
- }
- unset($form_values['audio_tag_settings']['new']);
-
- // Sort by the weight and then by name of the tag. I'm sure there's a
- // better way to do this...
- foreach ($form_values['audio_tag_settings'] as $tag => $settings) {
- $weights[$tag] = $settings['weight'];
- $names[$tag] = $tag;
- }
- array_multisort($weights, SORT_ASC, SORT_NUMERIC, $names, SORT_ASC, SORT_STRING);
- $audio_tag_settings = array();
- foreach ($names as $tag) {
- $audio_tag_settings[$tag] = $form_values['audio_tag_settings'][$tag];
- }
-
- // ...and save it.
- variable_set('audio_tag_settings', $audio_tag_settings);
-
- drupal_set_message(t('The configuration options have been saved.'));
- }
-}
-
-/**
- * Format the id3tags settings form as a table.
- */
-function theme_audio_admin_settings_metadata($form) {
- $rows = array();
- foreach (element_children($form['audio_tag_settings']) as $key) {
- $row = array();
- if (is_array($form['audio_tag_settings'][$key]['name'])) {
- $row[] = drupal_render($form['audio_tag_settings'][$key]['name']);
- $row[] = drupal_render($form['audio_tag_settings'][$key]['autocomplete']);
- $row[] = drupal_render($form['audio_tag_settings'][$key]['required']);
- $row[] = drupal_render($form['audio_tag_settings'][$key]['hidden']);
- $row[] = drupal_render($form['audio_tag_settings'][$key]['browsable']);
- $row[] = drupal_render($form['audio_tag_settings'][$key]['writetofile']);
- $row[] = drupal_render($form['audio_tag_settings'][$key]['weight']);
-
- $row[] = drupal_render($form['delete'][$key]);
- }
- $rows[] = $row;
- }
- $header = array(t('Tag'), t('Autocompleted'), t('Required'), t('Hidden'), t('Browsable'),
- t('Written to file'), t('Weight'), t('Delete'));
-
- $output = theme('table', $header, $rows);
- $output .= drupal_render($form);
- return $output;
-}
-
-/**
- * Form for player settings.
- */
-function audio_admin_settings_players() {
- $form = array();
-
- $options = array();
- foreach (audio_get_players('formats') as $format => $players) {
- foreach ($players as $id => $player) {
- $options[$id] = $player['title'];
- $form['players'][$format][$id]['description'] = array(
- '#type' => 'item',
- '#title' => t('Description'),
- '#value' => $player['description'],
- );
- $form['players'][$format][$id]['url'] = array(
- '#type' => 'item',
- '#title' => t('URL'),
- '#value' => $player['url'],
- );
- $form['players'][$format][$id]['preview'] = array(
- '#type' => 'item',
- '#title' => t('URL'),
- '#value' => drupal_get_path('module', $player['module']) .'/'. $player['preview'],
- );
- }
- $form['audio_player_'. $format] = array(
- '#type' => 'radios',
- '#title' => t('Player'),
- '#default_value' => variable_get('audio_player_'. $format, '1pixelout'),
- '#options' => $options,
- );
- }
- return system_settings_form($form);
-}
-
-function theme_audio_admin_settings_players($form) {
- $output = '';
- $header = array(t('Player'), t('Description'), t('Homepage'));
- foreach (element_children($form['players']) as $format) {
- $output .= ''. t('%format files', array('%format' => $format)) .'
';
- $rows = array();
- foreach (element_children($form['players'][$format]) as $name) {
- $rows[] = array(
- drupal_render($form['audio_player_'. $format][$name])
- . theme('image', $form['players'][$format][$name]['preview']['#value'], 'preview', 'preview'),
- check_plain($form['players'][$format][$name]['description']['#value']),
- l(t('Link'), $form['players'][$format][$name]['url']['#value']),
- );
- unset($form['players'][$format][$name]['description']);
- unset($form['players'][$format][$name]['url']);
- unset($form['players'][$format][$name]['preview']);
- }
- unset($form['audio_player_'. $format]);
- $output .= theme('table', $header, $rows);
- }
- return $output . drupal_render($form);
-}
-
/**
* Get an array of the allowed tags.
*
=== modified file 'audio_getid3.info'
--- audio_getid3.info 2008-03-29 22:24:08 +0000
+++ audio_getid3.info 2008-03-30 01:18:28 +0000
@@ -1,5 +1,6 @@
; $Id: audio_getid3.info,v 1.4 2007/06/18 22:53:31 dww Exp $
name = Audio getID3
description = Adds the ability to read artist info from and write to audio files. Requires that the getID3 library be installed.
-dependencies = audio
package = Audio
+core = 6.x
+dependencies[] = audio
=== modified file 'audio_getid3.module'
--- audio_getid3.module 2008-03-29 22:24:08 +0000
+++ audio_getid3.module 2008-03-30 05:09:24 +0000
@@ -8,7 +8,7 @@
/**
* Implementation of hook_help
*/
-function audio_getid3_help($section) {
+function audio_getid3_help($section, $arg) {
switch ($section) {
case 'admin/help#audio_getid3':
$help = ''. t('The Audio getID3 module enhances the audio module to read metadata from and write to audio files. The module uses the getID3 library to read and write ID3 tags from the audio file. getID3 can read metadata from a many different audio and video formats giving the audio module a great deal of flexibility.',
@@ -18,8 +18,7 @@
',
- array('!admin-settings-audio-getid3' => url('admin/settings/audio/getid3'), '!elink-prdownloads-sourceforge-net' => 'http://prdownloads.sourceforge.net/getid3', '%recommended-version' => AUDIO_GETID3_RECOMMEND_VERSION));
+ ', array('!admin-settings-audio-getid3' => url('admin/settings/audio/getid3'), '!elink-prdownloads-sourceforge-net' => 'http://prdownloads.sourceforge.net/getid3', '%recommended-version' => AUDIO_GETID3_RECOMMEND_VERSION));
$help .= ''. t('For more information please read the configuration and customization handbook Audio page.',
array('!audio' => 'http://www.drupal.org/handbook/modules/audio/')) .'
';
return $help;
@@ -31,16 +30,15 @@
}
}
-function audio_getid3_menu($may_cache) {
+function audio_getid3_menu() {
$items = array();
- if ($may_cache) {
- $items[] = array('path' => 'admin/settings/audio/getid3',
- 'title' => t('getID3'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('audio_getid3_admin_settings'),
- 'access' => user_access('administer site configuration'),
- 'type' => MENU_LOCAL_TASK);
- }
+ $items['admin/settings/audio/getid3'] = array(
+ 'title' => 'getID3',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('audio_getid3_admin_settings'),
+ 'access arguments' => array('administer site configuration'),
+ 'type' => MENU_LOCAL_TASK,
+ );
return $items;
}
@@ -83,7 +81,7 @@
'#title' => t('Path'),
'#default_value' => variable_get('audio_getid3_path', drupal_get_path('module', 'audio') .'/getid3/getid3'),
'#description' => t("The path to the getID3 library. For example: 'modules/audio/getid3/getid3' or 'sites/default/modules/audio/getid3'"),
- '#after_build'=> array('_audio_getid3_settings_check_path'),
+ '#after_build' => array('_audio_getid3_settings_check_path'),
);
if (audio_getid3_isfound()) {
@@ -118,7 +116,7 @@
/**
* Edit the audio node form and insert our file info stuff.
*/
-function audio_getid3_form_alter($form_id, &$form) {
+function audio_getid3_form_alter(&$form, &$form_state, $form_id) {
// We only alter audio node edit forms
if ($form_id == 'audio_node_form' && isset($form['#node']->audio_file)) {
$node = $form['#node'];
@@ -250,17 +248,17 @@
define('GETID3_HELPERAPPSDIR', realpath($path .'/../helperapps') .'/');
require_once($path .'/getid3.php');
- $getID3 = new getID3;
- $getID3->encoding = 'UTF-8';
- $getID3->encoding_id3v1 = 'ISO-8859-1';
- $getID3->option_tags_html = FALSE;
+ $getid3 = new getID3;
+ $getid3->encoding = 'UTF-8';
+ $getid3->encoding_id3v1 = 'ISO-8859-1';
+ $getid3->option_tags_html = FALSE;
// Initialize getID3 tag-writing module. NOTE: Their wanky dependency setup
// requires that this file must be included AFTER an instance of the getID3
// class has been instantiated.
require_once($path .'/write.php');
- return $getID3;
+ return $getid3;
}
/**
@@ -276,15 +274,15 @@
* there's an error.
*/
function audio_read_id3tags($filepath, $load_pics = FALSE) {
- $getID3 = _audio_getid3_load();
- if (!$getID3) {
+ $getid3 = _audio_getid3_load();
+ if (!$getid3) {
// getid3 isn't setup correctly. an error should have already been printed
// so just return.
return FALSE;
}
// Analyze file
- $info = $getID3->analyze($filepath);
+ $info = $getid3->analyze($filepath);
// copy out the basic file info
$ret = array(
@@ -363,8 +361,8 @@
* FALSE on error.
*/
function audio_write_id3tags($filepath, $tags, $images = array(), $tagformats = array('id3v1', 'id3v2.3')) {
- $getID3 = _audio_getid3_load();
- if (!$getID3) {
+ $getid3 = _audio_getid3_load();
+ if (!$getid3) {
// getid3 isn't setup correctly. an error should have already been printed
// so just return.
return FALSE;
=== modified file 'audio_images.info'
--- audio_images.info 2008-03-29 22:24:08 +0000
+++ audio_images.info 2008-03-30 01:18:28 +0000
@@ -1,5 +1,6 @@
; $Id: audio_images.info,v 1.4 2007/06/18 22:53:31 dww Exp $
name = Audio Images
description = Adds the ability to attach album art to audio nodes.
-dependencies = audio
package = Audio
+core = 6.x
+dependencies[] = audio
=== modified file 'audio_images.install'
--- audio_images.install 2008-03-29 22:24:08 +0000
+++ audio_images.install 2008-03-30 01:18:28 +0000
@@ -1,57 +1,82 @@
t('Associates an image (such as album artwork) with an audio file.'),
+ 'fields' => array(
+ 'pid' => array(
+ 'type' => 'serial',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ ),
+ 'nid' => array(
+ 'type' => 'int',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ ),
+ 'vid' => array(
+ 'type' => 'int',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ ),
+ 'pictype' => array(
+ 'type' => 'int',
+ 'size' => 'tiny',
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
+ 'width' => array(
+ 'type' => 'int',
+ 'size' => 'small',
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
+ 'height' => array(
+ 'type' => 'int',
+ 'size' => 'small',
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
+ 'filemime' => array(
+ 'type' => 'varchar',
+ 'length' => 20,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ 'filepath' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ 'filesize' => array(
+ 'type' => 'int',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
+ ),
+ 'primary key' => array('pid'),
+ 'indexes' => array(
+ 'audio_image_vid_pictype' => array('vid', 'pictype'),
+ ),
+ );
+ return $schema;
}
/**
@@ -59,19 +84,23 @@
*/
function audio_images_update_1() {
$ret = array();
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- $ret[] = update_sql(
-<< 'int',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ )
+ );
+ db_change_field($ret, 'audio_image', 'pid', 'pid',
+ array(
+ 'type' => 'serial',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ )
+ );
+ db_add_index($ret, 'audio_image', 'audio_image_vid_pictype', array('vid', 'pictype'));
+
return $ret;
}
@@ -80,10 +109,12 @@
*/
function audio_images_update_2() {
$ret = array();
- switch ($GLOBALS['db_type']) {
- case 'pgsql':
- $ret[] = update_sql("CREATE SEQUENCE audio_image_pid_seq;");
- break;
- }
+ db_change_field($ret, 'audio_image', 'pid', 'pid',
+ array(
+ 'type' => 'serial',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ )
+ );
return $ret;
-}
\ No newline at end of file
+}
=== modified file 'audio_images.module'
--- audio_images.module 2008-03-29 22:24:08 +0000
+++ audio_images.module 2008-03-30 05:09:24 +0000
@@ -6,21 +6,30 @@
/**
* Implementation of hook_menu().
*/
-function audio_images_menu($may_cache) {
+function audio_images_menu() {
$items = array();
- if ($may_cache) {
- $items[] = array('path' => 'admin/settings/audio/images',
- 'title' => t('Images'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('audio_images_admin_settings'),
- 'access' => user_access('administer site configuration'),
- 'type' => MENU_LOCAL_TASK
- );
- }
+ $items['admin/settings/audio/images'] = array(
+ 'title' => 'Images',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('audio_images_admin_settings'),
+ 'access arguments' => array('administer site configuration'),
+ 'type' => MENU_LOCAL_TASK,
+ );
return $items;
}
/**
+ * Implementation of hook_theme
+ */
+function audio_images_theme() {
+ return array(
+ 'audio_images_form' => array(
+ 'arguments' => array('form'),
+ ),
+ );
+}
+
+/**
* Implementation of hook_file_download().
*/
function audio_images_file_download($filename) {
@@ -48,14 +57,14 @@
*
* Here we add our image fields to the audio node form.
*/
-function audio_images_form_alter($form_id, &$form) {
+function audio_images_form_alter(&$form, &$form_state, $form_id) {
// We only alter audio node edit forms.
if ($form_id == 'audio_node_form') {
$node = $form['#node'];
$form['audio_images'] = array(
'#type' => 'fieldset', '#title' => t('Audio Images'),
- '#collapsible'=> TRUE,
+ '#collapsible' => TRUE,
'#description' => t('Cover art or other images.'),
'#weight' => 0,
'#tree' => TRUE,
@@ -126,7 +135,7 @@
case 'prepare':
// Clean out the session the first time the form is viewed.
- if(count($_POST) == 0) {
+ if (count($_POST) == 0) {
$_SESSION['audio_images'] = $node->audio_images;
}
else if (!empty($_SESSION['audio_images'])) {
@@ -260,21 +269,20 @@
/**
* Save an image to the audio_image table and copies it to the audio/images
* directory.
- *
+ *
* The caller needs to delete original image file if it was a temporary.
*/
function _audio_images_save_copy(&$node, $image) {
$newpath = _audio_image_filename($node->vid, $image['filemime'], $image['pictype'], FALSE);
if (file_copy($image['filepath'], $newpath, FILE_EXISTS_REPLACE)) {
- $pid = db_next_id('{audio_image}_pid');
- db_query("INSERT INTO {audio_image} (pid, nid, vid, pictype, filemime, width, height, filepath, filesize)
- VALUES (%d, %d, %d, %d, '%s', %d, %d, '%s', %d)",
- $pid, $node->nid, $node->vid, $image['pictype'], $image['filemime'],
+ db_query("INSERT INTO {audio_image} (nid, vid, pictype, filemime, width, height, filepath, filesize)
+ VALUES (%d, %d, %d, '%s', %d, %d, '%s', %d)",
+ $node->nid, $node->vid, $image['pictype'], $image['filemime'],
$image['width'], $image['height'], $newpath, filesize($newpath));
$image['filepath'] = $newpath;
- $image['pid'] = $pid;
- $node->audio_images[$pid] = $image;
+ $image['pid'] = db_last_insert_id();
+ $node->audio_images[$image['pid']] = $image;
}
}
@@ -329,7 +337,7 @@
/**
* Returns the array of the default image type.
- *
+ *
* If no default image is found, returns a random image array.
*/
function audio_images_get($audio_images, $pictype = NULL) {
@@ -368,7 +376,7 @@
$alt = audio_image_type_dirty_array($image['pictype']);
list($width, $height) = @getimagesize($image['filepath']);
- $attributes = array('width' => $width, 'height'=> $height);
+ $attributes = array('width' => $width, 'height' => $height);
return theme('image', $url, $alt, '', $attributes, FALSE);
-}
\ No newline at end of file
+}
=== modified file 'contrib/attach/audio_attach.info'
--- contrib/attach/audio_attach.info 2008-03-29 22:24:08 +0000
+++ contrib/attach/audio_attach.info 2008-03-30 01:18:28 +0000
@@ -1,6 +1,6 @@
; $Id: audio_attach.info,v 1.2 2007/06/18 23:50:47 dww Exp $
name = Audio Attach
description = Allows audio files to be attached to any node type.
-dependencies = audio
package = "Audio"
-
+core = 6.x
+dependencies[] = audio
=== modified file 'contrib/attach/audio_attach.install'
--- contrib/attach/audio_attach.install 2008-03-29 22:24:08 +0000
+++ contrib/attach/audio_attach.install 2008-03-30 00:22:22 +0000
@@ -5,44 +5,59 @@
* Implementation of hook_install().
*/
function audio_attach_install() {
- switch ($GLOBALS['db_type']) {
- case 'mysqli':
- case 'mysql':
- db_query("
- CREATE TABLE {audio_attach} (
- nid int(10) unsigned NOT NULL default '0',
- aid int(10) unsigned NOT NULL default '0',
- weight int(10) unsigned NOT NULL default '0',
- PRIMARY KEY (nid, aid, weight)
- ) /*!40100 DEFAULT CHARACTER SET utf8 */;
- ");
- break;
- case 'pgsql':
- db_query("
- CREATE TABLE {audio_attach} (
- nid INTEGER PRIMARY KEY,
- aid INTEGER NOT NULL DEFAULT 0
- weight INTEGER NOT NULL DEFAULT 0
- PRIMARY KEY (nid, aid, weight)
- )
- ");
- break;
- }
+ drupal_install_schema('audio_attach');
+}
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function audio_attach_uninstall() {
+ drupal_uninstall_schema('audio_attach');
+}
+
+/**
+ * Implementation of hook_schema().
+ */
+function audio_attach_schema() {
+ $schema['audio_attach'] = array(
+ 'description' => t('Attaches an audio node to another node.'),
+ 'fields' => array(
+ 'nid' => array(
+ 'type' => 'int',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ ),
+ 'aid' => array(
+ 'type' => 'int',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ ),
+ 'weight' => array(
+ 'type' => 'int',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
+ ),
+ 'primary key' => array('nid', 'aid', 'weight'),
+ );
+ return $schema;
}
/**
* Add column for weight type
*/
function audio_attach_update_1() {
- $items = array();
- $items[] = update_sql("ALTER TABLE {audio_attach} ADD weight int(10) NOT NULL default '0'");
- $items[] = update_sql("ALTER TABLE {audio_attach} DROP PRIMARY KEY, ADD PRIMARY KEY (nid, aid, weight)");
- return $items;
+ $ret = array();
+ db_add_field($ret, 'audio_attach', 'weight',
+ array(
+ 'type' => 'int',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ 'default' => 0,
+ )
+ );
+ db_drop_primary_key($ret, 'audio_attach');
+ db_add_primary_key($ret, 'audio_attach', array('nid', 'aid', 'weight'));
+ return $ret;
}
-
-/**
- * Implementation of hook_uninstall().
- */
-function audio_attach_uninstall() {
- db_query('DROP TABLE {audio_attach}');
-}
\ No newline at end of file
=== modified file 'contrib/attach/audio_attach.module'
--- contrib/attach/audio_attach.module 2008-03-29 22:24:08 +0000
+++ contrib/attach/audio_attach.module 2008-03-30 05:09:24 +0000
@@ -10,7 +10,7 @@
/**
* Implementation of hook_help().
*/
-function audio_attach_help($section) {
+function audio_attach_help($section, $args) {
switch ($section) {
case 'admin/help#audio_attach':
return t('Allows audio files to be attached to any content type. You can configure which content types by going to admin/content/types.
');
@@ -19,45 +19,51 @@
}
/**
- * Implementation of hook_menu
+ * Implementation of hook_menu
*/
-function audio_attach_menu($may_cache) {
+function audio_attach_menu() {
$items = array();
- if ($may_cache) {
- // cached items
- }
- elseif (arg(0) == 'audio_attach' && is_numeric(arg(2))) {
- $node = node_load(arg(2));
- $items[] = array(
- 'path' => 'audio_attach',
- 'callback' => '_audio_attach_action',
- 'callback_arguments' => array(arg(1), arg(2), arg(3)),
- 'access' => node_access('update', $node),
- 'type' => MENU_CALLBACK,
- );
- }
+ // For example: audio_attach/remove/314/1
+ $items['audio_attach/%op/%node/%index'] = array(
+ 'page callback' => '_audio_attach_action',
+ 'page arguments' => array(1, 2, 3),
+ 'access callback' => 'node_access',
+ 'access arguments' => array('update', 2),
+ 'type' => MENU_CALLBACK,
+ );
+
return $items;
}
/**
- * Implementation of hook_perm
+ * Implementation of hook_perm
*/
function audio_attach_perm() {
return array(
'attach any existing audio file'
- );
-}
-
-/**
- * implementation of hook_form_alter()
- */
-function audio_attach_form_alter($form_id, &$form) {
-
+ );
+}
+
+/**
+ * Implementation of hook_theme
+ */
+function audio_attach_theme() {
+ return array(
+ 'audio_attach_list' => array(
+ 'arguments' => array('nids', 'teaser' => FALSE),
+ ),
+ );
+}
+
+/**
+ * Implementation of hook_form_alter()
+ */
+function audio_attach_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
// checkbox in the node's content type configuration page.
case 'node_type_form':
- if(isset($form['identity']['type'])) {
+ if (isset($form['identity']['type'])) {
$form['workflow']['audio_attach'] = array(
'#type' => 'radios',
'#title' => t('Attach audio files'),
@@ -68,9 +74,12 @@
}
break;
+ // FIXME: This is broken; I'm not sure what $form['type']['#value'] is
+ // expected to be, but it certainly doesn't always exist.
// if enabled adjust the form
- case $form['type']['#value'] . '_node_form':
- if (variable_get('audio_attach_' . $form['type']['#value'], 0)) {
+ //case $form['type']['#value'] .'_node_form':
+ case 'FIXME_node_form':
+ if (variable_get('audio_attach_'. $form['type']['#value'], 0)) {
$node = $form['#node'];
$form['#attributes'] = array("enctype" => "multipart/form-data");
$form['audio_attach'] = array('#type' => 'fieldset', '#title' => t('Attached audio files'), '#collapsible' => TRUE);
@@ -122,16 +131,16 @@
}
/**
-* Implementation of hook_nodeapi().
-*/
+ * Implementation of hook_nodeapi().
+ */
function audio_attach_nodeapi(&$node, $op, $teaser, $page) {
global $user;
// delete all references from other nodes if audio node is deleted 24/08/2006 sun
- if ($node->type == 'audio' && $op == 'delete'){
+ if ($node->type == 'audio' && $op == 'delete') {
db_query("DELETE FROM {audio_attach} WHERE aid = %d", $node->nid);
return;
}
- if ($node->type == 'audio' || !variable_get("audio_attach_$node->type", 0)){
+ if ($node->type == 'audio' || !variable_get("audio_attach_$node->type", 0)) {
return;
}
switch ($op) {
@@ -183,11 +192,11 @@
}
/**
- * Menu callback, perform an action on attachments.
+ * Menu callback, perform an action on attachments.
*/
function _audio_attach_action($op, $nid, $index) {
- switch($op) {
+ switch ($op) {
case 'remove':
// remove the element index b from the array. rebuild the array, and save.
$children = audio_attach_get_children($nid);
@@ -232,19 +241,19 @@
}
/**
- * Input a parent node id, and return an array of children id's ordered by their weight.
+ * Input a parent node id, and return an array of children id's ordered by their weight.
*/
function audio_attach_get_children($nid) {
$children = array();
$result = db_query("SELECT aid, weight FROM {audio_attach} WHERE nid = %d ORDER BY weight ASC", $nid);
- while($row = db_fetch_object($result)) {
+ while ($row = db_fetch_object($result)) {
$children[$row->weight] = $row->aid;
}
return $children;
}
/**
- * Add a new child to a parent node
+ * Add a new child to a parent node
*/
function audio_attach_add_child($nid, $aid, $stack_bottom = TRUE) {
$weight = audio_attach_get_next_weight($nid);
@@ -252,7 +261,9 @@
}
/**
- * Delete a child node from a given parent node. If no parent node is specified, it deletes the child from all parent nodes. Returns true if successful.
+ * Delete a child node from a given parent node. If no parent node is
+ * specified, it deletes the child from all parent nodes. Returns true if
+ * successful.
*/
function audio_attach_remove_child($aid, $nid, $weight) {
$result = db_query("DELETE FROM {audio_attach} WHERE nid = %d AND aid = %d AND weight = %d", $nid, $aid, $weight);
@@ -260,7 +271,7 @@
}
/**
- * Delete a parent node. Returns true if successful.
+ * Delete a parent node. Returns true if successful.
*/
function audio_attach_remove($nid) {
$result = db_query("DELETE FROM {audio_attach} WHERE nid = %d", $nid);
@@ -268,10 +279,10 @@
}
/**
- * Get next weight in a given list.
- **/
+ * Get next weight in a given list.
+ */
function audio_attach_get_next_weight($nid) {
- $max = db_result(db_query("SELECT MAX(weight) FROM {audio_attach} WHERE nid = %d LIMIT 1", $nid));
+ $max = db_result(db_query("SELECT MAX(weight) FROM {audio_attach} WHERE nid = %d", $nid));
return (is_null($max)) ? 0 : ++$max;
}
@@ -293,14 +304,14 @@
}
/**
- * Theme used if multiple files are attached
+ * Theme used if multiple files are attached
*/
function theme_audio_attach_list($nids, $teaser = FALSE) {
drupal_add_css(AUDIO_ATTACH_PATH .'/audio_attach.css');
foreach ($nids as $aid) {
$audio = node_load($aid);
$audio = node_prepare($audio, $teaser);
- $title = $audio->status ? l($audio->title, 'node/' . $audio->nid, NULL, NULL, NULL, TRUE) : check_plain($audio->title);
+ $title = $audio->status ? l($audio->title, 'node/'. $audio->nid, array('html' => TRUE)) : check_plain($audio->title);
$items[] = ''. $title .'
'. theme('audio_teaser', $audio);
}
return theme('item_list', $items, null, 'ol', array('class' => 'audio-attach-list'));
@@ -317,9 +328,6 @@
$sql .= !user_access("attach any existing audio file") ? "AND n.uid = $user->uid " : "";
$sql .= "ORDER BY n.sticky DESC, n.title ASC";
$result = db_query(db_rewrite_sql($sql));
- if (db_num_rows($result) == 0) {
- return $rows;
- }
while ($node = db_fetch_object($result)) {
$rows[$node->nid] = $node->title;
}
@@ -327,7 +335,7 @@
}
/**
- * Return a list of currently attached audio files for a node. Used in edit form.
+ * Return a list of currently attached audio files for a node. Used in edit form.
* TODO: This is clunky. Needs to be leaner.
*/
function _audio_attach_current_list($nid) {
@@ -337,13 +345,31 @@
$items = array();
$i = 0;
if (is_array($node->audio_attach) && count($node->audio_attach) > 0) {
- foreach($node->audio_attach as $weight => $aid) {
+ foreach ($node->audio_attach as $weight => $aid) {
$audio = node_load($aid);
$drag = theme('image', AUDIO_ATTACH_PATH .'/images/drag_me.gif');
- $link = l($audio->title, 'node/' . $audio->nid, NULL, NULL, NULL, TRUE);
- $trashcan = l(theme('image', AUDIO_ATTACH_PATH .'/images/user-trash.png'), "audio_attach/remove/$node->nid/$i", array('class' => 'audio-attach-quick-link'), drupal_get_destination(), null, false, true);
- $up = $i > 0 ? l(theme('image', AUDIO_ATTACH_PATH .'/images/go-up.png'), "audio_attach/up/$node->nid/$i", array('class' => 'audio-attach-quick-link'), drupal_get_destination(), null, false, true) : '' ;
- $down = $i < count($node->audio_attach) - 1 ? l(theme('image', AUDIO_ATTACH_PATH .'/images/go-down.png'), "audio_attach/down/$node->nid/$i", array('class' => 'audio-attach-quick-link'), drupal_get_destination(), null, false, true) : '';
+ $link = l($audio->title, 'node/'. $audio->nid, array('html' => TRUE));
+ $trashcan = l(theme('image', AUDIO_ATTACH_PATH .'/images/user-trash.png'),
+ "audio_attach/remove/$node->nid/$i", array(
+ 'attributes' => array('class' => 'audio-attach-quick-link'),
+ 'query' => drupal_get_destination(),
+ 'absolute' => true,
+ )
+ );
+ $up = $i > 0 ? l(theme('image', AUDIO_ATTACH_PATH .'/images/go-up.png'),
+ "audio_attach/up/$node->nid/$i", array(
+ 'attributes' => array('class' => 'audio-attach-quick-link'),
+ 'query' => drupal_get_destination(),
+ 'absolute' => true,
+ )
+ ) : '' ;
+ $down = $i < count($node->audio_attach) - 1 ? l(theme('image', AUDIO_ATTACH_PATH .'/images/go-down.png'),
+ "audio_attach/down/$node->nid/$i", array(
+ 'attributes' => array('class' => 'audio-attach-quick-link'),
+ 'query' => drupal_get_destination(),
+ 'absolute' => true,
+ )
+ ) : '';
$items[] = array($i + 1, $link, $down, $up, $trashcan);
$i++;
}
@@ -353,9 +379,9 @@
}
/**
- * Ajax/Ahah callback to update the attached list table
+ * Ajax/Ahah callback to update the attached list table
*/
function _audio_attach_ahah_update($nid) {
print _audio_attach_current_list($nid);
exit();
-}
\ No newline at end of file
+}
=== modified file 'contrib/feeds/audio_feeds.info'
--- contrib/feeds/audio_feeds.info 2008-03-29 22:24:08 +0000
+++ contrib/feeds/audio_feeds.info 2008-03-30 01:18:28 +0000
@@ -1,6 +1,6 @@
; $Id: audio_feeds.info,v 1.2 2007/06/18 23:50:48 dww Exp $
name = Audio Feeds
description = Provide XSPF, PLS, and M3U audio XML feeds.
-dependencies = audio
package = "Audio"
-
+core = 6.x
+dependencies[] = audio
=== modified file 'contrib/feeds/audio_feeds.module'
--- contrib/feeds/audio_feeds.module 2008-03-29 22:24:08 +0000
+++ contrib/feeds/audio_feeds.module 2008-03-30 05:09:24 +0000
@@ -5,18 +5,16 @@
* This module provides XSPF, M3U, and PLS feeds for a list of audio files.
*/
-
include(drupal_get_path('module', 'audio_feeds') .'/feeds.inc');
if (module_exists('views')) {
include(drupal_get_path('module', 'audio_feeds') .'/audio_feeds_views.inc');
}
-
/**
* Implementation of hook_help().
*/
-function audio_feeds_help($section) {
+function audio_feeds_help($section, $arg) {
switch ($section) {
case 'admin/help#audio_feeds':
return t('This module creates XSPF, M3U, and PLS audio feeds.');
@@ -26,26 +24,25 @@
/**
* Implementation of hook_form_alter().
*/
-function audio_feeds_form_alter($form_id, &$form) {
+function audio_feeds_form_alter(&$form, &$form_state, $form_id) {
global $user;
switch ($form_id) {
case 'node_type_form':
- if(isset($form['identity']['type']) && module_exists('audio_attach')) {
+ if (isset($form['identity']['type']) && module_exists('audio_attach')) {
$type = $form['#node_type']->type;
- $form['workflow']['audio_feeds_attach'] = array(
- '#type' => 'radios',
- '#title' => t('Audio Feeds'),
- '#default_value' => variable_get('audio_feeds_attach_'. $type, 0),
- '#options' => array(t('Disabled'), t('Enabled')),
- '#description' => t('Should users be allowed to create XSPF, M3U, and PLS feeds of attached audio files?'),
- );
+ $form['workflow']['audio_feeds_attach'] = array(
+ '#type' => 'radios',
+ '#title' => t('Audio Feeds'),
+ '#default_value' => variable_get('audio_feeds_attach_'. $type, 0),
+ '#options' => array(t('Disabled'), t('Enabled')),
+ '#description' => t('Should users be allowed to create XSPF, M3U, and PLS feeds of attached audio files?'),
+ );
}
break;
}
}
-
/**
* Implementation of hook_link().
*/
@@ -89,53 +86,41 @@
return $links;
}
-
/**
* Implementation of hook_menu().
*/
-function audio_feeds_menu($may_cache) {
- global $user;
+function audio_feeds_menu() {
+ // FIXME: This snippet isn't preserved by this new menu code:
+ // if (variable_get('audio_feeds_attach_'. $node->type, 0)) {
$items = array();
- if ($may_cache) {
-
- }
- else if (arg(0) == 'node' && is_numeric(arg(1)) && module_exists('audio_attach')) {
- $node = node_load(arg(1));
- if (variable_get('audio_feeds_attach_'. $node->type, 0)) {
- $items[] = array('path' => 'node/'. arg(1) .'/xspf',
- 'title' => t('XSPF'),
- 'type' => MENU_CALLBACK,
- 'callback' => 'audio_feeds_xspf',
- 'callback arguments' => arg(1)
- );
- $items[] = array('path' => 'node/'. arg(1) .'/m3u',
- 'title' => t('M3U'),
- 'type' => MENU_CALLBACK,
- 'callback' => 'audio_feeds_m3u',
- 'callback arguments' => arg(1)
- );
- $items[] = array('path' => 'node/'. arg(1) .'/pls',
- 'title' => t('PLS'),
- 'type' => MENU_CALLBACK,
- 'callback' => 'audio_feeds_pls',
- 'callback arguments' => arg(1)
- );
- }
- }
+ $items['node/%node/xspf'] = array(
+ 'title' => 'XSPF',
+ 'page callback' => 'audio_feeds_xspf',
+ 'page arguments' => array(1),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['node/%node/m3u'] = array(
+ 'title' => 'M3U',
+ 'page callback' => 'audio_feeds_m3u',
+ 'page arguments' => array(1),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['node/%node/pls'] = array(
+ 'title' => 'PLS',
+ 'page callback' => 'audio_feeds_pls',
+ 'page arguments' => array(1),
+ 'type' => MENU_CALLBACK,
+ );
return $items;
}
-
-
-
/**
- * Menu Callback to generate M3U feed
- */
-function audio_feeds_m3u($nid) {
+ * Menu Callback to generate M3U feed
+ */
+function audio_feeds_m3u($node) {
$items = array();
- $node = node_load($nid);
// prepare feed metadata
$metadata = array('title' => $node->title);
@@ -145,23 +130,22 @@
foreach ($children as $child) {
$audio = node_load($child);
if (node_access('view', $audio)) {
- $items[] = array('title' => $audio->audio_tags['title'],
- 'author' => $audio->audio_tags['artist'],
- 'duration' => $audio->audio_file['playtime'],
- 'enclosure' => array('url' => $audio->url_play)
- );
+ $items[] = array(
+ 'title' => $audio->audio_tags['title'],
+ 'author' => $audio->audio_tags['artist'],
+ 'duration' => $audio->audio_file['playtime'],
+ 'enclosure' => array('url' => $audio->url_play),
+ );
}
}
audio_feeds_generate_m3u($items, $metadata);
}
-
/**
- * Menu Callback to generate PLS feed
- */
-function audio_feeds_pls($nid) {
+ * Menu Callback to generate PLS feed
+ */
+function audio_feeds_pls($node) {
$items = array();
- $node = node_load($nid);
// prepare feed metadata
$metadata = array('title' => $node->title);
@@ -171,31 +155,32 @@
foreach ($children as $child) {
$audio = node_load($child);
if (node_access('view', $audio)) {
- $items[] = array('title' => $audio->audio_tags['title'],
- 'author' => $audio->audio_tags['artist'],
- 'duration' => $audio->audio_file['playtime'],
- 'enclosure' => array('url' => $audio->url_play)
- );
+ $items[] = array(
+ 'title' => $audio->audio_tags['title'],
+ 'author' => $audio->audio_tags['artist'],
+ 'duration' => $audio->audio_file['playtime'],
+ 'enclosure' => array('url' => $audio->url_play),
+ );
}
}
audio_feeds_generate_pls($items, $metadata);
}
/**
- * Menu Callback to generate XSPF feed
- */
-function audio_feeds_xspf($nid) {
+ * Menu Callback to generate XSPF feed
+ */
+function audio_feeds_xspf($node) {
global $base_url;
- $node = node_load($nid);
$children = $node->audio_attach;
// prepare feed metadata
- $metadata = array('title' =>$node->title,
- 'author' => $node->name,
- 'link' => url('node/'.$node->nid, NULL,NULL, TRUE),
- 'feed_url' => url('node/'.$node->nid.'/xspf', NULL,NULL, TRUE)
- );
- //'copyright' => $node->playlist_info['copyright']
+ $metadata = array(
+ 'title' => $node->title,
+ 'author' => $node->name,
+ 'link' => url('node/'. $node->nid, array('absolute' => TRUE)),
+ 'feed_url' => url('node/'. $node->nid .'/xspf', array('absolute' => TRUE)),
+ //'copyright' => $node->playlist_info['copyright']
+ );
// prepare feed items
$items = array();
@@ -204,14 +189,15 @@
if (node_access('view', $audio)) {
// use the first image uploaded as the included image
$image = is_array($audio->audio_images) ? current($audio->audio_images) : '';
- $items[] = array('title' => $audio->audio_tags['title'],
- 'author' => $audio->audio_tags['artist'],
- 'album' => $audio->audio_tags['album'],
- 'duration' => $audio->audio_file['playtime'],
- 'link' => url('node/'.$audio->nid, NULL,NULL, TRUE),
- 'image' => array('url' => $base_url .'/'. $image['filepath']),
- 'enclosure' => array('url' => $audio->url_play)
- );
+ $items[] = array(
+ 'title' => $audio->audio_tags['title'],
+ 'author' => $audio->audio_tags['artist'],
+ 'album' => $audio->audio_tags['album'],
+ 'duration' => $audio->audio_file['playtime'],
+ 'link' => url('node/'. $audio->nid, array('absolute' => TRUE)),
+ 'image' => array('url' => $base_url .'/'. $image['filepath']),
+ 'enclosure' => array('url' => $audio->url_play),
+ );
}
}
audio_feeds_generate_xspf($items, $metadata);
=== modified file 'contrib/feeds/audio_feeds_views.inc'
--- contrib/feeds/audio_feeds_views.inc 2008-03-29 22:24:08 +0000
+++ contrib/feeds/audio_feeds_views.inc 2008-03-30 00:22:22 +0000
@@ -13,7 +13,7 @@
'theme' => 'audio_feeds_views_xspf',
'summary_theme' => 'views_summary',
);
- return $items;
+ return $items;
}
/**
@@ -21,7 +21,7 @@
*/
function theme_audio_feeds_views_xspf($view, $nodes, $type) {
if (isset($_GET['xspf'])) {
- return audio_feeds_views_prepare_xspf(views_get_title($view, $type), url($view->real_url, null, null, true), $nodes);
+ return audio_feeds_views_prepare_xspf(views_get_title($view, $type), url($view->real_url, array('absolute' => true)), $nodes);
}
elseif (isset($_GET['m3u'])) {
return theme('audio_feeds_views_m3u', $view, $nodes, $type);
@@ -41,7 +41,7 @@
}
}
$filters = $query_string ? audio_feeds_query_string_encode($query_string) .'%26xspf' : 'xspf';
- $playlist_url = url($view->real_url, $filters, NULL, TRUE);
+ $playlist_url = url($view->real_url, array('query' => $filters, 'absolute' => TRUE));
$output = theme($player['theme_xspf'], $playlist_url);
$output .= theme('audio_feeds_views_links', $view, $query_string);
return $output;
@@ -55,26 +55,27 @@
global $base_url;
// prepare feed metadata
- $metadata = array('title' => $title,
- 'author' => $base_url,
- 'link' => $base_url,
- 'feed_url' => $url
- );
+ $metadata = array(
+ 'title' => $title,
+ 'author' => $base_url,
+ 'link' => $base_url,
+ 'feed_url' => $url
+ );
// prepare feed items
foreach ($nodes as $n) {
- $audio = node_load($n->nid);
- // use the first image uploaded as the included image if it exists
- $image = is_array($audio->audio_images) ? current($audio->audio_images) : '';
- $items[] = array('title' => $audio->audio_tags['title'] ? $audio->audio_tags['title'] : $audio->title,
- 'author' => $audio->audio_tags['artist'],
- 'album' => $audio->audio_tags['album'],
- 'duration' => $audio->audio_file['playtime'],
- 'link' => url('node/'.$audio->nid, NULL, NULL, TRUE),
- 'image' => $image ? array('url' => $base_url .'/'. $image['filepath']) : '',
- 'enclosure' => array('url' => $audio->url_play)
- );
-
+ $audio = node_load($n->nid);
+ // use the first image uploaded as the included image if it exists
+ $image = is_array($audio->audio_images) ? current($audio->audio_images) : '';
+ $items[] = array(
+ 'title' => $audio->audio_tags['title'] ? $audio->audio_tags['title'] : $audio->title,
+ 'author' => $audio->audio_tags['artist'],
+ 'album' => $audio->audio_tags['album'],
+ 'duration' => $audio->audio_file['playtime'],
+ 'link' => url('node/'. $audio->nid, array('absolute' => TRUE)),
+ 'image' => $image ? array('url' => $base_url .'/'. $image['filepath']) : '',
+ 'enclosure' => array('url' => $audio->url_play)
+ );
}
audio_feeds_generate_xspf($items, $metadata);
}
@@ -98,11 +99,12 @@
// prepare feed items
foreach ($nodes as $n) {
$audio = node_load($n->nid);
- $items[] = array('title' => $audio->audio_tags['title'] ? $audio->audio_tags['title'] : $audio->title,
- 'author' => $audio->audio_tags['artist'],
- 'duration' => $audio->audio_file['playtime'],
- 'enclosure' => array('url' => $audio->url_play)
- );
+ $items[] = array(
+ 'title' => $audio->audio_tags['title'] ? $audio->audio_tags['title'] : $audio->title,
+ 'author' => $audio->audio_tags['artist'],
+ 'duration' => $audio->audio_file['playtime'],
+ 'enclosure' => array('url' => $audio->url_play)
+ );
}
audio_feeds_generate_m3u($items, $metadata);
}
@@ -126,11 +128,12 @@
// prepare feed items
foreach ($nodes as $n) {
$audio = node_load($n->nid);
- $items[] = array('title' => $audio->audio_tags['title'] ? $audio->audio_tags['title'] : $audio->title,
- 'author' => $audio->audio_tags['artist'],
- 'duration' => $audio->audio_file['playtime'],
- 'enclosure' => array('url' => $audio->url_play)
- );
+ $items[] = array(
+ 'title' => $audio->audio_tags['title'] ? $audio->audio_tags['title'] : $audio->title,
+ 'author' => $audio->audio_tags['artist'],
+ 'duration' => $audio->audio_file['playtime'],
+ 'enclosure' => array('url' => $audio->url_play)
+ );
}
audio_feeds_generate_pls($items, $metadata);
}
@@ -145,11 +148,11 @@
$links = array();
$links['m3u']['title'] = t('m3u');
- $links['m3u']['href'] = url($view->real_url, $m3u_filter, null, true);
+ $links['m3u']['href'] = url($view->real_url, array('query' => $m3u_filter, 'absolute' => true));
$links['pls']['title'] = t('pls');
- $links['pls']['href'] = url($view->real_url, $pls_filter, null, true);
+ $links['pls']['href'] = url($view->real_url, array('query' => $pls_filter, 'absolute' => true));
$links['xspf']['title'] = t('xspf');
- $links['xspf']['href'] = url($view->real_url, $xspf_filter, null, true);
+ $links['xspf']['href'] = url($view->real_url, array('query' => $xspf_filter, 'absolute' => true));
return theme('links', $links);
}
@@ -160,7 +163,7 @@
$view = new stdClass();
$view->name = 'audio_feeds';
$view->description = 'Audio XSPF Player';
- $view->access = array (
+ $view->access = array(
0 => '1',
1 => '2',
);
@@ -177,16 +180,16 @@
$view->url = 'audio/listen';
$view->use_pager = FALSE;
$view->nodes_per_page = '15';
- $view->sort = array (
- array (
+ $view->sort = array(
+ array(
'tablename' => 'node',
'field' => 'created',
'sortorder' => 'DESC',
'options' => 'normal',
),
);
- $view->argument = array (
- array (
+ $view->argument = array(
+ array(
'type' => 'rss_feed',
'argdefault' => '2',
'title' => '',
@@ -195,8 +198,8 @@
'wildcard_substitution' => '',
),
);
- $view->field = array (
- array (
+ $view->field = array(
+ array(
'tablename' => 'node',
'field' => 'title',
'label' => '',
@@ -204,17 +207,17 @@
'options' => 'link',
),
);
- $view->filter = array (
- array (
+ $view->filter = array(
+ array(
'tablename' => 'node',
'field' => 'type',
'operator' => 'OR',
'options' => '',
- 'value' => array (
+ 'value' => array(
0 => 'audio',
),
),
- array (
+ array(
'tablename' => 'node',
'field' => 'status',
'operator' => '=',
=== modified file 'contrib/import/audio_import.info'
--- contrib/import/audio_import.info 2008-03-29 22:24:08 +0000
+++ contrib/import/audio_import.info 2008-03-30 01:18:28 +0000
@@ -1,5 +1,6 @@
; $Id: audio_import.info,v 1.4 2007/06/18 22:53:31 dww Exp $
name = Audio Import
description = Allows audio module admins to import batches of audio files.
-dependencies = audio
package = Audio
+core = 6.x
+dependencies[] = audio
=== modified file 'contrib/import/audio_import.module'
--- contrib/import/audio_import.module 2008-03-29 22:24:08 +0000
+++ contrib/import/audio_import.module 2008-03-30 05:09:24 +0000
@@ -2,44 +2,37 @@
// $Id: audio_import.module,v 1.6 2007/08/06 03:00:58 drewish Exp $
-function audio_import_help($section = '') {
+function audio_import_help($section, $arg) {
switch ($section) {
case 'admin/content/audio_import':
- $output = ''. t("Import multiple audio files and save them as audio nodes. The files will be moved from their location into the audio module's files directory. ")
+ return '
'. t("Import multiple audio files and save them as audio nodes. The files will be moved from their location into the audio module's files directory. ")
. t("Searching for files ending with %extensions in %dirpath directory.", array('%dirpath' => realpath(variable_get('audio_import_path', '')), '%extensions' => variable_get('audio_allowed_extensions', 'mp3 wav ogg'))) .'
';
- return $output;
case 'admin/help#audio':
- $output = ''. t("The audio_import module allows users with 'administer audio' permission to import audio files and create audio nodes from them. ") .'
';
- return $output;
+ return ''. t("The audio_import module allows users with 'administer audio' permission to import audio files and create audio nodes from them. ") .'
';
case 'admin/settings/audio_import':
return t("Configure the audio import module's settings.");
- default:
- return null;
}
}
-function audio_import_menu($may_cache) {
+function audio_import_menu() {
$items = array();
- if ($may_cache) {
- $items[] = array(
- 'path' => 'admin/content/audio_import',
- 'title' => t('Audio import'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('audio_import_form'),
- 'access' => user_access('administer audio'),
- 'type' => MENU_NORMAL_ITEM,
- 'description' => t('Import audio from the filesystem.')
- );
- $items[] = array(
- 'path' => 'admin/settings/audio_import',
- 'title' => t('Audio import settings'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('audio_import_admin_settings'),
- 'access' => user_access('administer site configuration'),
- 'type' => MENU_NORMAL_ITEM,
- 'description' => t('Change settings for the Audio Import module.')
- );
- }
+
+ $items['admin/content/audio_import'] = array(
+ 'title' => 'Audio import',
+ 'description' => 'Import audio from the filesystem.',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('audio_import_form'),
+ 'access arguments' => array('administer audio'),
+ 'type' => MENU_NORMAL_ITEM,
+ );
+ $items['admin/settings/audio_import'] = array(
+ 'title' => 'Audio import settings',
+ 'description' => 'Change settings for the Audio Import module.',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('audio_import_admin_settings'),
+ 'access arguments' => array('administer site configuration'),
+ 'type' => MENU_NORMAL_ITEM,
+ );
return $items;
}
@@ -55,7 +48,7 @@
// convert the extensions setting into a regex for file scanning
$extensions = variable_get('audio_allowed_extensions', 'mp3 wav ogg');
$extensions = preg_split('/[\s,]+/', $extensions, -1, PREG_SPLIT_NO_EMPTY);
- $filemask = '.*(\.'. implode('|\.', $extensions).')$';
+ $filemask = '.*(\.'. implode('|\.', $extensions) .')$';
$options = array();
$files = file_scan_directory($dirpath, $filemask);
@@ -92,6 +85,17 @@
return $form;
}
+/**
+ * Implementation of hook_theme
+ */
+function audio_import_theme() {
+ return array(
+ 'audio_import_form' => array(
+ 'arguments' => array('form'),
+ ),
+ );
+}
+
function theme_audio_import_form($form) {
$output = '';
if (isset($form['audio_import_files']) && $form['audio_import_files']['#type'] == 'checkboxes') {
@@ -110,19 +114,19 @@
return $output . drupal_render($form);
}
-function audio_import_form_submit($form_id, $form_values) {
- $op = isset($form_values['op']) ? $form_values['op'] : '';
+function audio_import_form_submit($form, &$form_state) {
+ $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
if ($op == t('Import')) {
$dirpath = variable_get('audio_import_path', '');
if (file_check_directory($dirpath)) {
$nodes = array();
$files = array();
- foreach (array_filter($form_values['audio_import_files']) as $index) {
+ foreach (array_filter($form_state['values']['audio_import_files']) as $index) {
// try to avoid php's script timeout with a bunch of large files or
// a slow machine
set_time_limit(0);
- $origname = $form_values['file_list'][$index];
+ $origname = $form_state['values']['file_list'][$index];
$filename = file_check_location($dirpath .'/'. $origname, $dirpath);
if ($filename) {
$node = audio_api_insert($filename);
@@ -155,7 +159,7 @@
$form['audio_import_path'] = array(
'#type' => 'textfield',
'#title' => t('Import path'),
- '#default_value' => variable_get('audio_import_path', file_directory_temp() . '/audio/'),
+ '#default_value' => variable_get('audio_import_path', file_directory_temp() .'/audio/'),
'#after_build' => array('_audio_import_settings_check_directory'),
'#description' => t("The directory to import audio nodes from. Drupal will need to have write access to this directory so we can move the file.") .'
'
. t("Note: a path begining with a / indicates the path is relative to the server's root, one starting without specifies a path relative to Drupal's root. I.e. /tmp/audio would be the temp directory off the root while tmp/audio would be inside Drupal's directory."),
@@ -172,10 +176,10 @@
* @see system_check_directory()
*/
function _audio_import_settings_check_directory($form_element) {
- $importDir = $form_element['#value'];
- file_check_directory($importDir, 0, $form_element['#parents'][0]);
- $audioDir = variable_get('audio_file_path', file_directory_path() .'/audio');
- if (realpath($importDir) == realpath($audioDir)) {
+ $import_dir = $form_element['#value'];
+ file_check_directory($import_dir, 0, $form_element['#parents'][0]);
+ $audio_dir = variable_get('audio_file_path', file_directory_path() .'/audio');
+ if (realpath($import_dir) == realpath($audio_dir)) {
form_set_error($form_element['#parents'][0], t("You can't import from the audio module's directory. The import deletes the original files so you would just be asking for trouble."));
}
return $form_element;
=== modified file 'contrib/itunes/audio_itunes.info'
--- contrib/itunes/audio_itunes.info 2008-03-29 22:24:08 +0000
+++ contrib/itunes/audio_itunes.info 2008-03-30 01:18:28 +0000
@@ -2,4 +2,6 @@
name = Audio iTunes
description = An iTunes specific RSS plugin for views feeds.
package = Audio
-dependencies = views views_ui
+core = 6.x
+dependencies[] = views
+dependencies[] = views_ui
=== modified file 'contrib/itunes/audio_itunes.install'
--- contrib/itunes/audio_itunes.install 2008-03-29 22:24:08 +0000
+++ contrib/itunes/audio_itunes.install 2008-03-30 05:09:24 +0000
@@ -2,49 +2,129 @@
// $Id: audio_itunes.install,v 1.1 2007/03/13 18:12:54 drewish Exp $
/**
- * Install the initial schema.
+ * Implementation of hook_install().
*/
function audio_itunes_install() {
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- db_query("
- CREATE TABLE {audio_itunes_channel} (
- `view_id` int(10) unsigned NOT NULL default '0',
- `subtitle` varchar(255) NOT NULL default '',
- `summary` longtext NOT NULL,
- `author` varchar(255) NOT NULL default '',
- `copyright` varchar(255) NOT NULL default '',
- `owner_name` varchar(255) NOT NULL default '',
- `owner_email` varchar(255) NOT NULL default '',
- `image_url` varchar(255) NOT NULL default '',
- `block` int(1) unsigned NOT NULL default '0',
- `explicit` int(1) unsigned NOT NULL default '0',
- PRIMARY KEY (`view_id`)
- ) /*!40100 DEFAULT CHARACTER SET utf8 */;
- ");
- db_query("
- CREATE TABLE {audio_itunes_item} (
- `vid` int(10) unsigned NOT NULL default '0',
- `summary` longtext NOT NULL,
- `subtitle` varchar(255) NOT NULL default '',
- `explicit` int(1) unsigned NOT NULL default '0',
- `block` int(1) unsigned NOT NULL default '0',
- PRIMARY KEY (`vid`)
- ) /*!40100 DEFAULT CHARACTER SET utf8 */;
- ");
- break;
- case 'pgsql':
- break;
- }
+ drupal_install_schema('audio_itunes');
+ _audio_add_default_perms();
}
/**
* Implementation of hook_uninstall().
*/
function audio_itunes_uninstall() {
- db_query('DROP TABLE {audio_itunes_item}');
- db_query('DROP TABLE {audio_itunes_channel}');
+ drupal_uninstall_schema('audio_itunes');
+}
- // variable_del('audio_image_size');
+/**
+ * Implementation of hook_schema().
+ */
+function audio_itunes_schema() {
+ $schema['audio_itunes_channel'] = array(
+ 'description' => t('Audio iTunes channel.'),
+ 'fields' => array(
+ 'view_id' => array(
+ 'type' => 'int',
+ 'size' => 'medium',
+ 'not null' => 'true',
+ 'default' => 0,
+ ),
+ 'subtitle' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => 'true',
+ 'default' => '',
+ ),
+ 'summary' => array(
+ 'type' => 'text',
+ 'size' => 'medium',
+ 'not null' => 'true',
+ ),
+ 'author' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => 'true',
+ 'default' => '',
+ ),
+ 'copyright' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => 'true',
+ 'default' => '',
+ ),
+ 'owner_name' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => 'true',
+ 'default' => '',
+ ),
+ 'owner_email' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => 'true',
+ 'default' => '',
+ ),
+ 'image_url' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => 'true',
+ 'default' => '',
+ ),
+ 'block' => array(
+ 'type' => 'int',
+ 'size' => 'tiny',
+ 'not null' => 'true',
+ 'default' => 0,
+ ),
+ 'explicit' => array(
+ 'type' => 'int',
+ 'size' => 'tiny',
+ 'not null' => 'true',
+ 'default' => 0,
+ ),
+ ),
+ 'primary key' => array('view_id'),
+ );
+ $schema['audio_itunes_item'] = array(
+ 'description' => t('Audio iTunes item.'),
+ 'fields' => array(
+ 'vid' => array(
+ 'type' => 'int',
+ 'size' => 'medium',
+ 'not null' => 'true',
+ 'default' => 0,
+ ),
+ 'summary' => array(
+ 'type' => 'text',
+ 'size' => 'medium',
+ 'not null' => 'true',
+ ),
+ 'subtitle' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => 'true',
+ 'default' => '',
+ ),
+ 'author' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => 'true',
+ 'default' => '',
+ ),
+ 'block' => array(
+ 'type' => 'int',
+ 'size' => 'tiny',
+ 'not null' => 'true',
+ 'default' => 0,
+ ),
+ 'explicit' => array(
+ 'type' => 'int',
+ 'size' => 'tiny',
+ 'not null' => 'true',
+ 'default' => 0,
+ ),
+ ),
+ 'primary key' => array('vid'),
+ );
+ return $schema;
}
=== modified file 'contrib/itunes/audio_itunes.module'
--- contrib/itunes/audio_itunes.module 2008-03-29 22:24:08 +0000
+++ contrib/itunes/audio_itunes.module 2008-03-30 05:09:24 +0000
@@ -4,28 +4,30 @@
define('AUDIO_ITUNES_EXPLICIT_YES', 1);
define('AUDIO_ITUNES_EXPLICIT_CLEAN', 2);
-function audio_itunes_menu($may_cache) {
+function audio_itunes_menu() {
$items = array();
- if (!$may_cache) {
+
+ /* FIXME: Get this into an access callback
// insert a iTunes tab on views our argument handler
if (user_access('administer views') &&
arg(0) == 'admin' && arg(1) == 'build' && arg(2) == 'views') {
if ($view = views_load_view(arg(3))) {
foreach ($view->argument as $index => $argument) {
if ($argument['type'] == 'audio_itunes_feed') {
- $items[] = array(
- 'path' => 'admin/build/views/'. arg(3) .'/itunes',
- 'title' => t('iTunes'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('audio_itunes_channel_form', $view->vid),
- 'type' => MENU_LOCAL_TASK
- );
break;
}
}
}
}
}
+ */
+
+ $items['admin/build/views/%view/itunes'] = array(
+ 'title' => 'iTunes',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('audio_itunes_channel_form', 1),
+ 'type' => MENU_LOCAL_TASK,
+ );
return $items;
}
@@ -34,14 +36,14 @@
* Implementation of hook_form_alter() so we can add our image fields to the
* audio node form.
*/
-function audio_itunes_form_alter($form_id, &$form) {
+function audio_itunes_form_alter(&$form, &$form_state, $form_id) {
// We only alter audio node edit forms
if ($form_id == 'audio_node_form') {
$node = $form['#node'];
$form['audio_itunes'] = array(
'#type' => 'fieldset', '#title' => t('iTunes feed information'),
- '#collapsible'=> TRUE,
+ '#collapsible' => TRUE,
'#description' => t('iTunes specific information.'),
'#weight' => 0,
'#tree' => TRUE,
@@ -208,7 +210,7 @@
$form['owner'] = array(
'#type' => 'fieldset',
'#title' => t('Owner'),
- '#collapsible'=> FALSE,
+ '#collapsible' => FALSE,
'#tree' => FALSE,
'#description' => t("Apple uses this information to contact the owner of the podcast for communication specifically about their podcast. It will not be publicly displayed but it may be picked up by spammers."),
);
@@ -231,30 +233,30 @@
return $form;
}
-function audio_itunes_channel_form_validate($form_id, $values) {
- if (!empty($values['image_url'])) {
- if (!valid_url($values['image_url'])) {
+function audio_itunes_channel_form_validate($form, &$form_state) {
+ if (!empty($form_state['values']['image_url'])) {
+ if (!valid_url($form_state['values']['image_url'])) {
form_set_error('image_url', t('The image URL must be a valid URL.'));
}
else {
- $url = parse_url($values['image_url']);
+ $url = parse_url($form_state['values']['image_url']);
$ext = strtolower(pathinfo($url['path'], PATHINFO_EXTENSION));
if (!isset($url['path']) || ($ext != 'jpg' && $ext != 'png')) {
form_set_error('image_url', t('The URL must specify a file ending with .jpg or .png.'));
}
}
}
- if (!empty($values['owner_email']) && !valid_email_address($values['owner_email'])) {
+ if (!empty($form_state['values']['owner_email']) && !valid_email_address($form_state['values']['owner_email'])) {
form_set_error('owner_email', t('The owner email must be a valid email address.'));
}
}
-function audio_itunes_channel_form_submit($form_id, $values) {
- if ($values['view_id']) {
+function audio_itunes_channel_form_submit($form, &$form_state) {
+ if ($form_state['values']['view_id']) {
// delete and insert rather than updating in case the node doesn't have an existing record
- db_query("DELETE FROM {audio_itunes_channel} WHERE view_id = %d", $values['view_id']);
+ db_query("DELETE FROM {audio_itunes_channel} WHERE view_id = %d", $form_state['values']['view_id']);
db_query("INSERT INTO {audio_itunes_channel} (view_id, subtitle, summary, author, copyright, owner_name, owner_email, image_url, block, explicit) VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d)",
- $values['view_id'], $values['subtitle'], $values['summary'], $values['author'], $values['copyright'], $values['owner_name'], $values['owner_email'], $values['image_url'], $values['block'], $values['explicit']);
+ $form_state['values']['view_id'], $form_state['values']['subtitle'], $form_state['values']['summary'], $form_state['values']['author'], $form_state['values']['copyright'], $form_state['values']['owner_name'], $form_state['values']['owner_email'], $form_state['values']['image_url'], $form_state['values']['block'], $form_state['values']['explicit']);
}
}
@@ -326,7 +328,7 @@
* handler for our own RSS argument; mimics the feed selector
*/
function audio_itunes_arg_handler($op, &$query, $argtype, $arg = '') {
- switch($op) {
+ switch ($op) {
case 'summary':
case 'sort':
case 'link':
@@ -398,7 +400,18 @@
}
/**
- * plugin that actually displays an RSS feed
+ * Implementation of hook_theme
+ */
+function audio_itunes_theme() {
+ return array(
+ 'audio_itunes_feed' => array(
+ 'arguments' => array('view', 'nodes', 'type'),
+ ),
+ );
+}
+
+/**
+ * Plugin that actually displays an RSS feed
*/
function theme_audio_itunes_feed($view, $nodes, $type) {
if ($type == 'block') {
@@ -411,7 +424,7 @@
// a check_plain isn't required on these because format_rss_channel
// already does this.
'title' => views_get_title($view, 'page'),
- 'link' => url($view->feed_url ? $view->feed_url : $view->real_url, NULL, NULL, true),
+ 'link' => url($view->feed_url ? $view->feed_url : $view->real_url, array('absolute' => true)),
'description' => $view->description,
);
@@ -423,7 +436,7 @@
foreach ($nodes as $node) {
// Load the specified node:
$item = node_load($node->nid);
- $link = url("node/$node->nid", NULL, NULL, 1);
+ $link = url("node/$node->nid", array('absolute' => TRUE));
if ($item_length != 'title') {
$teaser = ($item_length == 'teaser') ? TRUE : FALSE;
@@ -442,7 +455,7 @@
// Allow modules to add additional item fields
$extra = node_invoke_nodeapi($item, 'rss item');
- $extra = array_merge($extra, array(array('key' => 'pubDate', 'value' => date('r', $item->created)), array('key' => 'dc:creator', 'value' => $item->name), array('key' => 'guid', 'value' => $item->nid . ' at ' . $base_url, 'attributes' => array('isPermaLink' => 'false'))));
+ $extra = array_merge($extra, array(array('key' => 'pubDate', 'value' => date('r', $item->created)), array('key' => 'dc:creator', 'value' => $item->name), array('key' => 'guid', 'value' => $item->nid .' at '. $base_url, 'attributes' => array('isPermaLink' => 'false'))));
foreach ($extra as $element) {
if ($element['namespace']) {
$namespaces = array_merge($namespaces, $element['namespace']);
@@ -457,7 +470,7 @@
case 'teaser':
$item_text = $item->teaser;
if ($item->readmore) {
- $item_text .= ''. l(t('read more'), 'node/'. $item->nid, NULL, NULL, NULL, TRUE) .'
';
+ $item_text .= ''. l(t('read more'), 'node/'. $item->nid, array('html' => TRUE)) .'
';
}
break;
case 'title':
@@ -477,8 +490,8 @@
);
$channel = array_merge($channel_defaults, $channel);
- $output = "\n";
- $output .= "\n";
+ $output = ''."\n";
+ $output .= '\n";
$output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language'], audio_itunes_feed_channel_arguments($view));
$output .= "\n";
=== modified file 'contrib/playlist/audio_playlist.info'
--- contrib/playlist/audio_playlist.info 2008-03-29 22:24:08 +0000
+++ contrib/playlist/audio_playlist.info 2008-03-30 01:18:28 +0000
@@ -1,6 +1,7 @@
; $Id: audio_playlist.info,v 1.2 2007/06/18 23:50:48 dww Exp $
name = Audio Playlist
description = Provide 'Add to playlist' link to audio content.
-dependencies = audio audio_attach
package = "Audio"
-
+core = 6.x
+dependencies[] = audio
+dependencies[] = audio_attach
=== modified file 'contrib/playlist/audio_playlist.module'
--- contrib/playlist/audio_playlist.module 2008-03-29 22:24:08 +0000
+++ contrib/playlist/audio_playlist.module 2008-03-30 05:09:24 +0000
@@ -10,7 +10,7 @@
/**
* Implementation of hook_help().
*/
-function audio_playlist_help($section) {
+function audio_playlist_help($section, $arg) {
switch ($section) {
case 'admin/help#audio_playlist':
return t('This module provides a quick method of adding audio files to other nodes (that allow audio attachments).');
@@ -31,7 +31,7 @@
$links['audio_playlist_add_link'] = array(
'title' => t('Add to playlist'),
'href' => "audio_playlist/$node->nid",
- 'query' => 'destination='.$_GET['q'],
+ 'query' => 'destination='. $_GET['q'],
'attributes' => array('title' => t('Add to playlist')),
);
}
@@ -47,35 +47,28 @@
return array(
'attach audio to own playlists',
'attach audio to any playlist',
- );
+ );
}
/**
* Implementation of hook_menu().
*/
-function audio_playlist_menu($may_cache) {
- global $user;
+function audio_playlist_menu() {
$items = array();
- if ($may_cache) {
- $items[] = array(
- 'path' => 'audio_playlist',
- 'title' => t('Add audio file to a playlist'),
- 'type' => MENU_CALLBACK,
- 'access' => user_access('attach audio to own playlists') || user_access('attach audio to any playlist'),
- 'callback' => 'audio_playlist_add_page',
- );
- }
+ $items['audio_playlist/%node'] = array(
+ 'title' => 'Add audio file to a playlist',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('audio_playlist_add_form', 1),
+ 'access arguments' => array('attach audio to own playlists', 'attach audio to any playlist'),
+ 'type' => MENU_CALLBACK,
+ );
return $items;
}
-function audio_playlist_add_page() {
- return drupal_get_form('audio_playlist_add_form');
-}
-
-function audio_playlist_add_form() {
- $url = l(t("audio attachments enabled"), "admin/content/types");
+function audio_playlist_add_form($node = NULL) {
+ $url = l(t('audio attachments enabled'), 'admin/content/types');
// make sure things are properly setup
if (!audio_playlist_get_playlist_types()) {
drupal_set_message("At least one content type must have $url for playlists to work.");
@@ -90,12 +83,13 @@
'#type' => 'hidden',
'#value' => arg(1)
);
- $form['audio_playlist']['aid_name'] = array (
+ $form['audio_playlist']['aid_name'] = array(
'#type' => 'item',
'#title' => t("Audio file"),
'#value' => $node->title,
);
- } else {
+ }
+ else {
drupal_set_message("Sorry, but only audio files can be added to a playlist.");
}
}
@@ -116,15 +110,16 @@
'#description' => t('Select which playlists you want to add this file to.'),
);
- $form['submit'] = array('#type' => 'submit', '#value' => t('Submit'));
+ $form['submit'] = array('#type' => 'submit', '#value' => t('Add to playlist'));
+
return $form;
}
-function audio_playlist_add_form_submit($form_id, $form_values) {
- if ($form_values['aid'] != 0) {
- foreach ($form_values['playlists'] as $nid => $checked) {
+function audio_playlist_add_form_submit($form, &$form_state) {
+ if ($form_state['values']['aid'] != 0) {
+ foreach ($form_state['values']['playlists'] as $nid => $checked) {
if ($checked) {
- audio_attach_add_child($nid, $form_values['aid']);
+ audio_attach_add_child($nid, $form_state['values']['aid']);
}
}
drupal_set_message("Added to playlist.");
@@ -154,10 +149,6 @@
$sql .= "ORDER BY n.sticky DESC, n.title ASC";
$rows = array();
$result = db_query(db_rewrite_sql($sql));
- if (db_num_rows($result) == 0) {
- return array();
- }
-
while ($row = db_fetch_object($result)) {
$node = node_load($row->nid);
$rows[$node->nid] = $node->title ." " . l("(i)", 'node/'. $node->nid, array("target" => "_blank")) ."";
=== modified file 'views_defaults.inc'
--- views_defaults.inc 2008-03-29 22:24:08 +0000
+++ views_defaults.inc 2008-03-30 00:22:22 +0000
@@ -2,13 +2,13 @@
// $Id: views_defaults.inc,v 1.2 2007/07/19 23:31:18 drewish Exp $
function audio_views_default_views() {
- $view = new stdClass();
+ $view = new stdClass();
$view->name = 'audio';
$view->description = 'Audio nodes';
- $view->access = array (
- 0 => '1',
- 1 => '2',
-);
+ $view->access = array(
+ 0 => '1',
+ 1 => '2',
+ );
$view->view_args_php = '';
$view->page = TRUE;
$view->page_title = 'Audio';
@@ -41,16 +41,16 @@
$view->block_use_page_header = FALSE;
$view->block_use_page_footer = FALSE;
$view->block_use_page_empty = FALSE;
- $view->sort = array (
- array (
+ $view->sort = array(
+ array(
'tablename' => 'node',
'field' => 'created',
'sortorder' => 'DESC',
'options' => 'normal',
),
);
- $view->argument = array (
- array (
+ $view->argument = array(
+ array(
'type' => 'rss_feed',
'argdefault' => '2',
'title' => '',
@@ -59,8 +59,8 @@
'wildcard_substitution' => '',
),
);
- $view->field = array (
- array (
+ $view->field = array(
+ array(
'tablename' => 'node',
'field' => 'title',
'label' => '',
@@ -68,17 +68,17 @@
'options' => 'link',
),
);
- $view->filter = array (
- array (
+ $view->filter = array(
+ array(
'tablename' => 'node',
'field' => 'type',
'operator' => 'OR',
'options' => '',
- 'value' => array (
+ 'value' => array(
0 => 'audio',
),
),
- array (
+ array(
'tablename' => 'node',
'field' => 'status',
'operator' => '=',
@@ -86,7 +86,7 @@
'value' => '1',
),
);
- $view->exposed_filter = array (
+ $view->exposed_filter = array(
);
$view->requires = array(node);
$views[$view->name] = $view;
@@ -96,7 +96,7 @@
$view = new stdClass();
$view->name = 'audio_random';
$view->description = 'Random audio nodes';
- $view->access = array (
+ $view->access = array(
0 => '1',
1 => '2',
);
@@ -115,18 +115,18 @@
$view->block_use_page_header = FALSE;
$view->block_use_page_footer = FALSE;
$view->block_use_page_empty = FALSE;
- $view->sort = array (
- array (
+ $view->sort = array(
+ array(
'tablename' => 'node',
'field' => 'random',
'sortorder' => 'ASC',
'options' => '',
),
);
- $view->argument = array (
+ $view->argument = array(
);
- $view->field = array (
- array (
+ $view->field = array(
+ array(
'tablename' => 'node',
'field' => 'title',
'label' => '',
@@ -134,17 +134,17 @@
'options' => 'link',
),
);
- $view->filter = array (
- array (
+ $view->filter = array(
+ array(
'tablename' => 'node',
'field' => 'type',
'operator' => 'OR',
'options' => '',
- 'value' => array (
+ 'value' => array(
0 => 'audio',
),
),
- array (
+ array(
'tablename' => 'node',
'field' => 'status',
'operator' => '=',
@@ -152,7 +152,7 @@
'value' => '1',
),
);
- $view->exposed_filter = array (
+ $view->exposed_filter = array(
);
$view->requires = array(node);
$views[$view->name] = $view;
@@ -163,7 +163,7 @@
$view = new stdClass();
$view->name = 'audio_user';
$view->description = 'Audio user feed';
- $view->access = array (
+ $view->access = array(
0 => '1',
1 => '2',
);
@@ -180,16 +180,16 @@
$view->url = 'audio/user';
$view->use_pager = TRUE;
$view->nodes_per_page = '10';
- $view->sort = array (
- array (
+ $view->sort = array(
+ array(
'tablename' => 'node',
'field' => 'created',
'sortorder' => 'DESC',
'options' => 'normal',
),
);
- $view->argument = array (
- array (
+ $view->argument = array(
+ array(
'type' => 'uid',
'argdefault' => '1',
'title' => '%1\'s Audio',
@@ -197,7 +197,7 @@
'wildcard' => '',
'wildcard_substitution' => '',
),
- array (
+ array(
'type' => 'rss_feed',
'argdefault' => '2',
'title' => '%1\'s Audio',
@@ -206,19 +206,19 @@
'wildcard_substitution' => '',
),
);
- $view->field = array (
+ $view->field = array(
);
- $view->filter = array (
- array (
+ $view->filter = array(
+ array(
'tablename' => 'node',
'field' => 'type',
'operator' => 'OR',
'options' => '',
- 'value' => array (
+ 'value' => array(
0 => 'audio',
),
),
- array (
+ array(
'tablename' => 'node',
'field' => 'status',
'operator' => '=',
@@ -226,7 +226,7 @@
'value' => '1',
),
);
- $view->exposed_filter = array (
+ $view->exposed_filter = array(
);
$view->requires = array(node);
$views[$view->name] = $view;
@@ -236,7 +236,7 @@
$view = new stdClass();
$view->name = 'audio_bc_feed_user';
$view->description = 'Audio user feed (for old URL backwards compatiblity)';
- $view->access = array (
+ $view->access = array(
0 => '1',
1 => '2',
);
@@ -253,16 +253,16 @@
$view->url = 'audio/feed/user';
$view->use_pager = FALSE;
$view->nodes_per_page = '10';
- $view->sort = array (
- array (
+ $view->sort = array(
+ array(
'tablename' => 'node',
'field' => 'created',
'sortorder' => 'DESC',
'options' => 'normal',
),
);
- $view->argument = array (
- array (
+ $view->argument = array(
+ array(
'type' => 'uid',
'argdefault' => '1',
'title' => '%1\'s Audio',
@@ -271,19 +271,19 @@
'wildcard_substitution' => '',
),
);
- $view->field = array (
+ $view->field = array(
);
- $view->filter = array (
- array (
+ $view->filter = array(
+ array(
'tablename' => 'node',
'field' => 'type',
'operator' => 'OR',
'options' => '',
- 'value' => array (
+ 'value' => array(
0 => 'audio',
),
),
- array (
+ array(
'tablename' => 'node',
'field' => 'status',
'operator' => '=',
@@ -291,7 +291,7 @@
'value' => '1',
),
);
- $view->exposed_filter = array (
+ $view->exposed_filter = array(
);
$view->requires = array(node);
$views[$view->name] = $view;