diff --git a/getid3.drush.inc b/getid3.drush.inc index c5eca3c..675a053 100644 --- a/getid3.drush.inc +++ b/getid3.drush.inc @@ -8,13 +8,13 @@ * Implements hook_drush_command(). */ function getid3_drush_command() { - $items['getid3-download'] = array( + $items['getid3-download'] = [ 'callback' => 'drush_getid3_download', 'description' => dt('Downloads the required getID3 library from SourceForge.net.'), - 'arguments' => array( + 'arguments' => [ 'path' => dt('Optional. A path to the download folder. If omitted Drush will use the default location (sites/all/libraries/getid3).'), - ), - ); + ], + ]; return $items; } @@ -50,28 +50,28 @@ function drush_getid3_download() { // Create the directory. if (!drush_shell_exec('mkdir -p %s', $library_path)) { - return drush_set_error('GETID3_MKDIR', dt('Drush was unable to create the getID3 directory at @path.', array('@path' => $library_path))); + return drush_set_error('GETID3_MKDIR', dt('Drush was unable to create the getID3 directory at @path.', ['@path' => $library_path])); } $zipfile_path = $library_path . '/' . $filename; drush_register_file_for_deletion($zipfile_path); // Download the file. if (!drush_shell_exec('wget -O %s %s', $zipfile_path, $url)) { - return drush_set_error('GETID3_FETCH', dt('Drush was unable to download the getID3 library to @path.', array('@path' => $zipfile_path))); + return drush_set_error('GETID3_FETCH', dt('Drush was unable to download the getID3 library to @path.', ['@path' => $zipfile_path])); } // Check MD5 hash. if (md5_file($zipfile_path) != $md5) { - return drush_set_error('GETID3_MD5', dt('The downloaded file @path was corrupted. Expected MD5 checksum: @md5.', array('@path' => $zipfile_path, '@md5' => $md5))); + return drush_set_error('GETID3_MD5', dt('The downloaded file @path was corrupted. Expected MD5 checksum: @md5.', ['@path' => $zipfile_path, '@md5' => $md5])); } // Unzip it the file -- using the "update" option to avoid being prompted // about overwriting files. if (!drush_shell_exec('unzip -u %s -d %s', $zipfile_path, $library_path)) { - return drush_set_error('GETID3_UNZIP', dt('Drush was unable to unzip the archive @path.', array('@path' => $zipfile_path))); + return drush_set_error('GETID3_UNZIP', dt('Drush was unable to unzip the archive @path.', ['@path' => $zipfile_path])); } // Delete the demos. They're a security risk. $demos_path = $library_path . '/demos'; if (!drush_shell_exec('rm -r %s', $demos_path)) { - return drush_set_error('GETID3_RM', dt("Drush was unable to remove getID3's demos directory. You should do so manually.", array('@path' => $demos_path))); + return drush_set_error('GETID3_RM', dt("Drush was unable to remove getID3's demos directory. You should do so manually.", ['@path' => $demos_path])); } - drush_log(dt('getID3 has been installed to @path.', array('@path' => $library_path)), 'success'); + drush_log(dt('getID3 has been installed to @path.', ['@path' => $library_path]), 'success'); } diff --git a/getid3.install b/getid3.install index 65ef3c8..866ca9d 100644 --- a/getid3.install +++ b/getid3.install @@ -11,7 +11,7 @@ use Drupal\Core\Url; * Implements hook_requirements(). */ function getid3_requirements($phase) { - $requirements = array(); + $requirements = []; if ($phase == 'runtime') { // Test getID3 version @@ -23,14 +23,14 @@ function getid3_requirements($phase) { // Check if demos directory exists. $getid3_demos_path = getid3_get_path() . '/../demos'; if (file_exists($getid3_demos_path)) { - $requirements['getid3']['description'] = t("Your getID3 library is insecure! The demos distributed with getID3 contains code which creates a huge security hole. Remove the demos directory (%path) from beneath Drupal's directory.", array('%path' => realpath($getid3_demos_path))); + $requirements['getid3']['description'] = t("Your getID3 library is insecure! The demos distributed with getID3 contains code which creates a huge security hole. Remove the demos directory (%path) from beneath Drupal's directory.", ['%path' => realpath($getid3_demos_path)]); $requirements['getid3']['severity'] = REQUIREMENT_ERROR; } } // getID3 library not found or wrong version. else { $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' => 'sites/all/libraries/getid3', '@getid3settings' => Url::fromRoute('getid3.config'))); + $requirements['getid3']['description'] = t('You must install getID3() to %getid3dir, or configure its installation path.', ['@getid3' => 'http://www.getid3.org', '%getid3dir' => 'sites/all/libraries/getid3', '@getid3settings' => Url::fromRoute('getid3.config')]); $requirements['getid3']['severity'] = REQUIREMENT_ERROR; } } @@ -46,7 +46,7 @@ function getid3_install() { $status = getid3_load(); if($status == FALSE){ $path = getid3_get_path(); - drupal_set_message(t('The getID3 files getid3.php and write.php could not be found in the %path directory.', array('%path' => $path)),'error'); + drupal_set_message(t('The getID3 files getid3.php and write.php could not be found in the %path directory.', ['%path' => $path]),'error'); } // Set module weight for the getID3 module. module_set_weight('getid3', '-10'); diff --git a/getid3.module b/getid3.module index 5d9cff9..90d9d48 100644 --- a/getid3.module +++ b/getid3.module @@ -12,7 +12,7 @@ function getid3_help($route_name) { case 'help.page.getid3': //case 'admin/help#getid3': return '

' . t("To use this module you'll need to download the library from the getID3 website and extract the contents into the module's getid3 directory. Currently, the recommended version of the getID3 library is %recommended-version.", - array('!download-link' => Url::fromUri('http://prdownloads.sourceforge.net/getid3'), '!info-link' => Url::fromUri('http://getid3.org/'), '%recommended-version' => GETID3_RECOMMENDED_VERSION )) . '

'; + ['!download-link' => Url::fromUri('http://prdownloads.sourceforge.net/getid3'), '!info-link' => Url::fromUri('http://getid3.org/'), '%recommended-version' => GETID3_RECOMMENDED_VERSION ]) . '

'; } } @@ -50,7 +50,7 @@ function getid3_instance() { $id3 = NULL; $id3_lib_available = getid3_load(); if($id3_lib_available == FALSE){ - drupal_set_message(t("The getid3() module cannot find the getID3 library used to read and write ID3 tags. The site administrator will need to verify that it is installed and then update the settings.", array('!admin-settings-audio-getid3' => Url::fromRoute('getid3.config'))), 'error', FALSE); + drupal_set_message(t("The getid3() module cannot find the getID3 library used to read and write ID3 tags. The site administrator will need to verify that it is installed and then update the settings.", ['!admin-settings-audio-getid3' => Url::fromRoute('getid3.config')]), 'error', FALSE); return $id3; } @@ -71,7 +71,7 @@ function getid3_instance() { * An array with the information returned by getID3. */ function getid3_analyze($filepath) { - $info = array(); + $info = []; if ($id3 = getid3_instance()) { $info = $id3->analyze($filepath); unset($id3); diff --git a/src/Form/GetId3ConfigForm.php b/src/Form/GetId3ConfigForm.php index cc67ff4..8deca5d 100644 --- a/src/Form/GetId3ConfigForm.php +++ b/src/Form/GetId3ConfigForm.php @@ -25,41 +25,41 @@ class GetId3ConfigForm extends ConfigFormBase { */ public function buildForm(array $form, FormStateInterface $form_state) { $path = getid3_get_path(); - $form['getid3_path'] = array( + $form['getid3_path'] = [ '#type' => 'textfield', '#title' => $this->t('Path'), '#default_value' => $path, '#description' => $this->t('The location where getID3() is installed. Relative paths are from the Drupal root directory.'), - ); + ]; - $form['getid3_path']['#after_build'][] = array(get_class($this), 'afterBuild'); + $form['getid3_path']['#after_build'][] = [get_class($this), 'afterBuild']; if ($version = getid3_get_version()) { - $form['getid3_version'] = array( + $form['getid3_version'] = [ '#type' => 'item', '#title' => $this->t('Version'), '#markup' => '
' . String::checkPlain($version) . '
', '#description' => $this->t("If you're seeing this it indicates that the getID3 library was found."), - ); + ]; // Check for existence of the 'demos' folder, contained in the getID3 // library. The contents of this folder create a potential securtiy hole, // so we recommend that the user delete it. $getid3_demos_path = $path . '/../demos'; if (file_exists($getid3_demos_path)) { - drupal_set_message($this->t("Your getID3 library is insecure! The demos distributed with getID3 contains code which creates a huge security hole. Remove the demos directory (%path) from beneath Drupal's directory.", array('%path' => realpath($getid3_demos_path))), 'error'); + drupal_set_message($this->t("Your getID3 library is insecure! The demos distributed with getID3 contains code which creates a huge security hole. Remove the demos directory (%path) from beneath Drupal's directory.", ['%path' => realpath($getid3_demos_path)]), 'error'); } } $show_warnings = $this->config('getid3.settings')->get('getid3_show_warnings'); if(empty($show_warnings)){ $show_warnings = FALSE; } - $form['getid3_show_warnings'] = array( + $form['getid3_show_warnings'] = [ '#type' => 'checkbox', '#title' => $this->t("Display Warnings"), '#default_value' => $show_warnings, '#description' => $this->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 parent::buildForm($form, $form_state); } @@ -99,7 +99,7 @@ class GetId3ConfigForm extends ConfigFormBase { public static function afterBuild(array $form_element, FormStateInterface $form_state) { $path = $form_state->getValue('getid3_path'); if (!is_dir($path) || !(file_exists($path . '/getid3.php') && file_exists($path . '/write.php'))) { - drupal_set_message(t('The getID3 files getid3.php and write.php could not be found in the %path directory.', array('%path' => $path)),'error'); + drupal_set_message(t('The getID3 files getid3.php and write.php could not be found in the %path directory.', ['%path' => $path]),'error'); } return $form_element; }