[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/swftools/onepixelout/ -> onepixelout.module (source)

   1  <?php
   2  // $Id: onepixelout.module,v 1.3.2.2 2009/04/20 21:40:08 stuartgreenfield Exp $
   3  
   4  /**
   5   * SWF Tools - Jeroen Onepixelout's Flash Players
   6   *
   7   * Enables the use of Jeroen Onepixelout's Flash Media and Flash Image
   8   * Rotator files, branded forms of which ship with SWF Tools module.
   9   *
  10   * Author's Site.
  11   * http://jeroenonepixelout.com
  12   */
  13  
  14  define('ONEPIXELOUT', 'onepixelout'); // 'player', plays a single mp3
  15  
  16  
  17  /**
  18   * Implementation of swftools_methods hook
  19   * Report methods back to SWF Tools
  20   */
  21  function onepixelout_swftools_methods() {
  22  
  23    $methods = array();
  24    $media_player = array(
  25      'name'        => ONEPIXELOUT,
  26      'module'      => 'onepixelout',
  27      'file'        => 'soundFile', // Define which flashvar to assign a 'file to play' variable.
  28      'version'     => '7',
  29      'shared_file' => '1pixelout/player.swf',
  30      'title'       => t('1 Pixel Out MP3 Player'),
  31      'download'    => 'http://www.1pixelout.net/code/audio-player-wordpress-plugin/',
  32      'width'       => '290',
  33      'height'      => '24',
  34    );
  35  
  36    // Onepixelout support various actions with the same player and info.
  37    $methods[SWFTOOLS_MP3_DISPLAY][ONEPIXELOUT] = $media_player;
  38  
  39    return $methods;
  40  }
  41  
  42  /**
  43   * Implementation of hook_menu().
  44   */
  45  function onepixelout_menu() {
  46    $items = array();
  47  
  48      //$items['admin/media/swf/onepixelout'] = array(
  49      $items['admin/settings/swftools/onepixelout'] = array(
  50        'title' => '1 Pixel Out',
  51        'description' => 'Settings for '. l('1 Pixel Out MP3 Player', 'http://www.1pixelout.net/code/audio-player-wordpress-plugin/') .'.',
  52        'access arguments' => array('administer flash'),
  53        'page callback' => 'drupal_get_form',
  54        'page arguments' => array('onepixelout_admin_form'),
  55        'file' => 'onepixelout.admin.inc',
  56        'file path' => drupal_get_path('module', 'onepixelout'),
  57      );
  58  
  59    return $items;
  60  }
  61  
  62  
  63  /**
  64   * These are the default settings as they are stored in the database and displayed
  65   * on the settings page.
  66   */
  67  function _onepixelout_settings() {
  68  
  69    $saved = variable_get('swftools_'. ONEPIXELOUT, array());
  70  
  71    $defaults = array(
  72      'autostart'      => 'no',
  73      'loop'           => 'no',
  74      'bg'             => '',
  75      'leftbg'         => '',
  76      'rightbg'        => '',
  77      'rightbghover'   => '',
  78      'lefticon'       => '',
  79      'righticon'      => '',
  80      'righticonhover' => '',
  81      'text'           => '',
  82      'slider'         => '',
  83      'loader'         => '',
  84      'track'          => '',
  85      'border'         => '',
  86    );
  87  
  88    return array_merge($defaults, $saved);
  89  }
  90  
  91  /**
  92   * Implementation of swftools_flashvars hook.
  93   * Return an array of flashvars.
  94   */
  95  function onepixelout_swftools_flashvars($action, &$methods, &$vars) {
  96    
  97    // Generate sequential player ids
  98    static $player_id = 1;
  99    
 100    // Assign a flashvar to identify the player - we add time as well, like swfobject2, to ensure truly unique ids
 101    $vars->flashvars['playerID'] = time() . $player_id++;
 102    
 103    // Retreive default onepixelout settings
 104    $saved = _onepixelout_flashvars();
 105  
 106    // Combine user and admin defaults, overwriting defaults.
 107    $saved = array_merge($saved, $vars->flashvars);
 108    
 109    // Return the completed set of flashvars
 110    return $saved;
 111  }
 112  
 113  /**
 114   * This function takes the module settings and massages them
 115   * as required for flashvar output.
 116   *
 117   */
 118  function _onepixelout_flashvars() {
 119    // Cache this.
 120    static $flashvars = array();
 121    if (!count($flashvars)) {
 122      // Get saved settings for this method.
 123      $saved = _onepixelout_settings();
 124      foreach ($saved AS $key => $setting) {
 125        if (!$setting || $setting == 'default') {
 126          // Don't pass out any undefined values.
 127          unset($saved[$key]);
 128        }
 129      }
 130    }
 131    return $saved;
 132  }
 133  
 134  
 135  /*
 136   * Implementation of hook_swftools_variable_mapping.
 137   *
 138   */
 139  function onepixelout_swftools_variable_mapping() {
 140    return array(
 141      ONEPIXELOUT => array(
 142        'loop' => 'flashvars',
 143        'autostart' => 'flashvars',
 144        'leftbg' => 'flashvars',
 145        'lefticon' => 'flashvars',
 146        'rightbg' => 'flashvars',
 147        'righticon' => 'flashvars',
 148        'rightbghover' => 'flashvars',
 149        'righticonhover' => 'flashvars',
 150      ),
 151    );
 152  }
 153  
 154  
 155  /**
 156   * Implementation of hook_init().
 157   * 
 158   * Push the script to stop other players on to the page.
 159   */
 160  function onepixelout_init() {
 161    if (variable_get('swftools_always_add_js', SWFTOOLS_ALWAYS_ADD_JS)) {
 162      onepixelout_push_js();
 163    }
 164  };
 165  
 166  
 167  function onepixelout_push_js() {
 168    drupal_add_js(drupal_get_path('module', 'onepixelout') .'/onepixelout.js', 'module', 'footer');
 169  }


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