$t('getID3()'),
);
$getid3_path = getid3_get_path();
if (!file_exists($getid3_path .'/getid3/getid3.php')) {
$requirements['getid3']['value'] = $t('Not found or wrong version');
$requirements['getid3']['description'] = $t('You must install getID3() to %getid3dir, or configure its installation path.', array('@getid3' => 'http://www.getid3.org', '%getid3dir' => drupal_get_path('module', 'getid3') .'/getid3', '@getid3settings' => url('admin/settings/getid3')));
$requirements['getid3']['severity'] = REQUIREMENT_ERROR;
}
else {
$requirements['getid3']['value'] = check_plain(getid3_get_version());
if (file_exists($getid3_path .'/demos')) {
$requirements['getid3']['description'] = $t("Your getID3 library is insecure. The demos distributed with getID3 contain code which can create a security holes. Please remove the demos directory (%path).", array('%path' => $getid3_path .'/demos'));
$requirements['getid3']['severity'] = REQUIREMENT_WARNING;
}
}
return $requirements;
}
/**
* Loads the getID3 library once and returns whether it was successfully loaded.
*
* @return
* Boolean indicating if the library was loaded
*/
function getid3_load($display_warning = TRUE) {
@(include_once(getid3_get_path() .'/getid3/getid3.php')) or _getid3_library_not_found($display_warning);
$version = GETID3_VERSION;
return !empty($version);
}
/**
* Let the user know that the getID3 PHP library is not installed.
*/
function _getid3_library_not_found($display_warning = TRUE) {
global $_getid3_library_not_found_displayed;
if ($_getid3_library_not_found_displayed = TRUE && $display_warning) {
drupal_set_message(t('The getID3() library was not found. Please install it into %getid3dir.', array('@getid3' => 'http://www.getid3.org', '%getid3dir' => drupal_get_path('module', 'getid3') .'/getid3')), 'error');
}
}
/**
* Create and initialize an instance of getID3 class.
*/
function &getid3_instance() {
getid3_load();
$id3 = new getID3();
$id3-> option_md5_data = true;
$id3-> option_md5_data_source = true;
$id3-> encoding = 'UTF-8';
return $id3;
}
/**
* Analyze file and return its media information.
*/
function &getid3_analyze($path) {
$info = array();
if($id3 = &getid3_instance()) {
$info = $id3-> analyze($path);
unset($id3);
}
return $info;
}
/**
* Implementation of hook_menu()
*/
function getid3_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'admin/settings/getid3',
'title' => t('getID3()'),
'description' => t('Configure settings associated with getID3().'),
'callback' => 'drupal_get_form',
'callback arguments' => array('getid3_admin_settings'),
'access' => user_access('administer site configuration'),
'type' => MENU_NORMAL_ITEM
);
}
return $items;
}
/**
* Administration settings for getID3().
*/
function getid3_admin_settings() {
$form['getid3_path'] = array(
'#type' => 'textfield',
'#title' => t('Path'),
'#default_value' => getid3_get_path(),
'#description' => t('The location where getID3() is installed. Relative paths are from the Drupal root directory.'),
'#after_build'=> array('_getid3_admin_settings_check_path'),
);
$form['getid3_show_warnings'] = array(
'#type' => 'checkbox',
'#title' => t("Display Warnings"),
'#default_value' => variable_get('getid3_show_warnings', FALSE),
'#description' => t("Check this to display the warning messages from the getID3 library when reading and writing ID3 tags. Generally it's a good idea to leave this unchecked, getID3 reports warnings for several trivial problems and the warnings can be confusing to users. This setting can be useful when debugging problems with the ID3 tags."),
);
return system_settings_form($form);
}
/**
* Checks the that the directory in $form_element exists and contains a file
* named 'getid3.php'. If validation fails, the form element is flagged with an
* error from within the file_check_directory function. See:
* system_check_directory()
*
* @param $form_element
* The form element containing the name of the directory to check.
*/
function _getid3_admin_settings_check_path($form_element) {
$path = $form_element['#value'];
if (!is_dir($path) || !file_exists($path .'/getid3/getid3.php')) {
form_set_error($form_element['#parents'][0], t('The getID3 PHP library could not be found in %path.', array('@url' => 'http://www.getid3.org', '%path' => $path)));
}
else {
$form_element['#description'] .= t(' Version %version found.', array('%version' => getid3_get_version()));
}
return $form_element;
}
/**
* Returns the path where getID3() is installed.
*/
function getid3_get_path() {
return variable_get('getid3_path', drupal_get_path('module', 'getid3') .'/getid3');
}
/**
* Returns the version number of getID3() that's installed.
*/
function getid3_get_version() {
getid3_load(FALSE);
return GETID3_VERSION;
}