[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/getid3/ -> getid3.module (source)

   1  <?php
   2  // $Id: getid3.module,v 1.10.2.4 2010/07/25 03:48:38 drewish Exp $
   3  
   4  define('GETID3_RECOMMEND_VERSION', '1.7.9');
   5  
   6  /**
   7   * Implementation of hook_help
   8   */
   9  function getid3_help($section, $arg) {
  10    switch ($section) {
  11      case 'admin/settings/getid3':
  12        $help = '<p>'. t("To use this module you'll need to <a href='!download-link'>download the library</a> from the <a href='!info-link'>getID3 website</a> and extract the contents into the  module's getid3 directory. Currently, the recommended version of the getID3 library is %recommended-version.", array(
  13          '!download-link' => url('http://prdownloads.sourceforge.net/getid3'),
  14          '!info-link' => url('http://getid3.org/'),
  15          '%recommended-version' => GETID3_RECOMMEND_VERSION
  16        )) .'</p>';
  17        return $help;
  18    }
  19  }
  20  
  21  /**
  22   * Loads the getID3 library once and returns whether it was successfully loaded.
  23   *
  24   * @return
  25   *   Boolean indicating if the library was loaded
  26   */
  27  function getid3_load($display_warning = TRUE) {
  28    $getid3_path = getid3_get_path();
  29  
  30    if (file_exists($getid3_path .'/getid3.php') && file_exists($getid3_path .'/write.php')) {
  31      // A little workaround for getID3 on Windows.
  32      if (!defined('GETID3_HELPERAPPSDIR')) {
  33        define('GETID3_HELPERAPPSDIR', realpath($getid3_path .'/../helperapps') .'/');
  34      }
  35      include_once($getid3_path .'/getid3.php');
  36  
  37      // Initialize getID3 tag-writing module. NOTE: Their wanky dependency setup
  38      // requires that this file must be included AFTER an instance of the getID3
  39      // class has been instantiated.
  40      $getid3 = new getID3;
  41      require_once($getid3_path .'/write.php');
  42  
  43      return defined('GETID3_VERSION');
  44    }
  45    else {
  46      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 <a href='!admin-settings-audio-getid3'>settings</a>.", array('!admin-settings-audio-getid3' => url('admin/settings/getid3'))), 'error', FALSE);
  47      return FALSE;
  48    }
  49  }
  50  
  51  /**
  52   * Create and initialize an instance of getID3 class.
  53   */
  54  function &getid3_instance() {
  55    $id3 = NULL;
  56    if (getid3_load()) {
  57      $id3 = new getID3();
  58      // MD5 is a big performance hit. Disable it by default.
  59      $id3->option_md5_data = FALSE;
  60      $id3->option_md5_data_source = FALSE;
  61      $id3->encoding = 'UTF-8';
  62    }
  63    return $id3;
  64  }
  65  
  66  /**
  67   * Analyze file and return its media information.
  68   */
  69  function &getid3_analyze($path) {
  70    $info = array();
  71    if($id3 = &getid3_instance()) {
  72      $info = $id3->analyze($path);
  73      unset($id3);
  74    }
  75    return $info;
  76  }
  77  
  78  /**
  79   * Implementation of hook_menu()
  80   */
  81  function getid3_menu() {
  82    $items['admin/settings/getid3'] = array(
  83      'title' => 'getID3()',
  84      'description' => 'Configure settings associated with getID3().',
  85      'page callback' => 'drupal_get_form',
  86      'page arguments' => array('getid3_admin_settings_form', NULL),
  87      'access arguments' => array('administer site configuration'),
  88      'file' => 'getid3.admin.inc',
  89    );
  90    return $items;
  91  }
  92  
  93  /**
  94   * Returns the path where getID3() is installed.
  95   */
  96  function getid3_get_path() {
  97    return variable_get('getid3_path', 'sites/all/libraries/getid3/getid3');
  98  }
  99  
 100  /**
 101   * Returns the version number of getID3() that's installed.
 102   */
 103  function getid3_get_version() {
 104    return getid3_load(FALSE) ? GETID3_VERSION : NULL;
 105  }


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7