View source
<?php
define('VIEWS_RSS_ITUNES_REQUIRED_BUILD', '6.x-2.x-dev-20120215');
function views_rss_itunes_requirements($phase) {
$requirements = array();
$t = get_t();
if (!defined('VIEWS_RSS_BUILD')) {
$requirements['views_rss_itunes'] = array(
'title' => $t('Views RSS: iTunes Elements'),
'description' => $t('<a href="@views_rss_url">Views RSS</a> module does not seem to be enabled. Please make sure it is enabled before enabling <em>Views RSS: iTunes Elements</em> module.', array(
'@views_rss_url' => url('http://drupal.org/project/views_rss'),
)),
'severity' => REQUIREMENT_ERROR,
'value' => NULL,
);
}
elseif (array_pop(explode('-', VIEWS_RSS_BUILD)) < array_pop(explode('-', VIEWS_RSS_ITUNES_REQUIRED_BUILD))) {
$requirements['views_rss_itunes'] = array(
'title' => $t('Views RSS: iTunes Elements'),
'description' => $t('Your current build of <a href="@views_rss_url">Views RSS</a> module (!views_rss_build) is too old for this version of <em>Views RSS: iTunes Elements</em> module to work properly. Minimum version required is <strong>!views_rss_required</strong>. Please upgrade.', array(
'@views_rss_url' => url('http://drupal.org/project/views_rss'),
'!views_rss_build' => VIEWS_RSS_BUILD,
'!views_rss_required' => VIEWS_RSS_ITUNES_REQUIRED_BUILD,
)),
'severity' => REQUIREMENT_ERROR,
'value' => NULL,
);
}
return $requirements;
}
function views_rss_itunes_install() {
$exists = FALSE;
$vocabularies = taxonomy_get_vocabularies();
foreach ($vocabularies as $vocabulary) {
if ($vocabulary->module == 'views_rss_itunes') {
variable_set('views_rss_itunes_category_vid', $vocabulary->vid);
$exists = TRUE;
}
}
if ($exists === FALSE) {
$vocabulary = array(
'name' => 'iTunes Category',
'module' => 'views_rss_itunes',
);
$ret = taxonomy_save_vocabulary($vocabulary);
variable_set('views_rss_itunes_category_vid', $vocabulary['vid']);
$first_level_terms = array(
'arts' => array(
'name' => 'Arts',
'vid' => $vocabulary['vid'],
),
'business' => array(
'name' => 'Business',
'vid' => $vocabulary['vid'],
),
'comedy' => array(
'name' => 'Comedy',
'vid' => $vocabulary['vid'],
),
'education' => array(
'name' => 'Education',
'vid' => $vocabulary['vid'],
),
'games_and_hobbies' => array(
'name' => 'Games & Hobbies',
'vid' => $vocabulary['vid'],
),
'government_and_organizations' => array(
'name' => 'Government & Organizations',
'vid' => $vocabulary['vid'],
),
'health' => array(
'name' => 'Health',
'vid' => $vocabulary['vid'],
),
'kids_and_family' => array(
'name' => 'Kids & Family',
'vid' => $vocabulary['vid'],
),
'music' => array(
'name' => 'Music',
'vid' => $vocabulary['vid'],
),
'news_and_politics' => array(
'name' => 'News & Politics',
'vid' => $vocabulary['vid'],
),
'religion_and_spirituality' => array(
'name' => 'Religion & Spirituality',
'vid' => $vocabulary['vid'],
),
'science_and_medicine' => array(
'name' => 'Science & Medicine',
'vid' => $vocabulary['vid'],
),
'society_and_culture' => array(
'name' => 'Society & Culture',
'vid' => $vocabulary['vid'],
),
'sports_and_recreation' => array(
'name' => 'Sports & Recreation',
'vid' => $vocabulary['vid'],
),
'technology' => array(
'name' => 'Technology',
'vid' => $vocabulary['vid'],
),
'tv_and_film' => array(
'name' => 'TV & Film',
'vid' => $vocabulary['vid'],
),
);
foreach ($first_level_terms as $key => $term_data) {
$ret = taxonomy_save_term($term_data);
$first_level_terms[$key] = $term_data;
}
$second_level_terms = array(
'arts' => array(
array(
'name' => 'Design',
),
array(
'name' => 'Fashion & Beauty',
),
array(
'name' => 'Food',
),
array(
'name' => 'Literature',
),
array(
'name' => 'Performing Arts',
),
array(
'name' => 'Visual Arts',
),
),
'business' => array(
array(
'name' => 'Business News',
),
array(
'name' => 'Careers',
),
array(
'name' => 'Investing',
),
array(
'name' => 'Management & Marketing',
),
array(
'name' => 'Shopping',
),
),
'education' => array(
array(
'name' => 'Education',
),
array(
'name' => 'Education Technology',
),
array(
'name' => 'Higher Education',
),
array(
'name' => 'K-12',
),
array(
'name' => 'Language Courses',
),
array(
'name' => 'Training',
),
),
'games_and_hobbies' => array(
array(
'name' => 'Automotive',
),
array(
'name' => 'Aviation',
),
array(
'name' => 'Hobbies',
),
array(
'name' => 'Other Games',
),
array(
'name' => 'Video Games',
),
),
'government_and_organizations' => array(
array(
'name' => 'Local',
),
array(
'name' => 'National',
),
array(
'name' => 'Non-Profit',
),
array(
'name' => 'Regional',
),
),
'health' => array(
array(
'name' => 'Alternative Health',
),
array(
'name' => 'Fitness & Nutrition',
),
array(
'name' => 'Self-Help',
),
array(
'name' => 'Sexuality',
),
),
'religion_and_spirituality' => array(
array(
'name' => 'Buddhism',
),
array(
'name' => 'Christianity',
),
array(
'name' => 'Hinduism',
),
array(
'name' => 'Islam',
),
array(
'name' => 'Judaism',
),
array(
'name' => 'Other',
),
array(
'name' => 'Spirituality',
),
),
'science_and_medicine' => array(
array(
'name' => 'Medicine',
),
array(
'name' => 'Natural Sciences',
),
array(
'name' => 'Social Sciences',
),
),
'society_and_culture' => array(
array(
'name' => 'History',
),
array(
'name' => 'Personal Journals',
),
array(
'name' => 'Philosophy',
),
array(
'name' => 'Places & Travel',
),
),
'sports_and_recreation' => array(
array(
'name' => 'Amateur',
),
array(
'name' => 'College & High School',
),
array(
'name' => 'Outdoor',
),
array(
'name' => 'Professional',
),
),
'technology' => array(
array(
'name' => 'Gadgets',
),
array(
'name' => 'Tech News',
),
array(
'name' => 'Podcasting',
),
array(
'name' => 'Software How-To',
),
),
);
foreach ($second_level_terms as $key1 => $terms) {
foreach ($terms as $key2 => $term_data) {
$term_data['parent'] = $first_level_terms[$key1]['tid'];
$term_data['vid'] = $vocabulary['vid'];
$ret = taxonomy_save_term($term_data);
$second_level_terms[$key1][$key2] = $term_data;
}
}
}
cache_clear_all('views_rss:', 'cache_views', TRUE);
}
function views_rss_itunes_uninstall() {
if (db_table_exists('cache_views')) {
cache_clear_all('views_rss:', 'cache_views', TRUE);
}
$vocabulary_vid = variable_get('views_rss_itunes_category_vid', NULL);
variable_del('views_rss_itunes_category_vid');
drupal_set_message(t('Please note that taxonomy vocabulary "iTunes Category" has not been deleted, as it could still be used by site\'s content. If you don\'t need it anymore, please <a href="!taxonomy_url">delete it manually</a>.', array(
'!taxonomy_url' => url('admin/content/taxonomy/edit/vocabulary/' . $vocabulary_vid),
)));
}