[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

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

   1  <?php
   2  // $Id: simpleviewer.module,v 1.4.2.2 2009/04/19 00:02:10 stuartgreenfield Exp $
   3  
   4  /**
   5   * SWF Tools - simpleviewer.module
   6   *
   7   * Enables the use of SimpleViewer Flash
   8   * for image gallery display. SimpleViewer must be downloaded separately.
   9   *
  10   * Author's Site.
  11   * http://www.airtightinteractive.com/simpleviewer/
  12   */
  13  
  14  define('SIMPLEVIEWER', 'simpleviewer'); // 'player', shows multiple images.
  15  
  16  
  17  /**
  18   * Implementation of swftools_methods hook
  19   * Report methods back to SWF Tools
  20   */
  21  function simpleviewer_swftools_methods() {
  22  
  23    $methods = array();
  24    $image_rotator = array(
  25      'name'        => SIMPLEVIEWER,
  26      'module'      => 'simpleviewer',
  27      'shared_file' => 'simpleviewer/viewer.swf',
  28      'file'        => 'xmlDataPath',
  29      'version'     => '7',
  30      'title'       => t('SimpleViewer'),
  31      'download'    => 'http://www.airtightinteractive.com/simpleviewer/',
  32      'width'       => '700',
  33      'height'      => '600',
  34    );
  35    $methods[SWFTOOLS_IMAGE_DISPLAY_LIST][SIMPLEVIEWER] = $image_rotator;
  36    return $methods;
  37  }
  38  
  39  
  40  /**
  41   * Implementation of hook_menu().
  42   */
  43  function simpleviewer_menu() {
  44    $items = array();
  45  
  46      $items['admin/settings/swftools/simpleviewer'] = array(
  47        'title' => 'SimpleViewer',
  48        'description' => 'Settings for <a href="http://www.airtightinteractive.com/simpleviewer/">Airtight Interactive\'s SimpleViewer</a> image gallery.',
  49        'weight' => 1,
  50  
  51        'access arguments' => array('administer flash'),
  52        'page callback' => 'drupal_get_form',
  53        'page arguments' => array('simpleviewer_admin_form'),
  54        'file' => 'simpleviewer.admin.inc',
  55        'file path' => drupal_get_path('module', 'simpleviewer'),
  56  
  57  
  58        );
  59  
  60    return $items;
  61  }
  62  
  63  /**
  64   * Implementation of swftools_flashvars hook
  65   * Allows the Flash player provider to add variables to the Flashvars array.
  66   * Other arrays can also be modified.
  67   *
  68   */
  69  function simpleviewer_swftools_flashvars($action, &$methods, &$vars) {
  70    $sv_vars = _simpleviewer_vars();
  71  
  72    // Here we only assign 'other' settings to othervars, and return 'swf' settings
  73    // as the flashvars. 'xml' settings are for the xml file only.
  74    // See http://www.airtightinteractive.com/forum/viewtopic.php?t=4085&start=0
  75    if (is_array($sv_vars['other'])) {
  76      $vars->othervars = array_merge($sv_vars['other'], $vars->othervars);
  77    }
  78    return $sv_vars['swf'];
  79  }
  80  
  81  
  82  /**
  83   * These are the default options and flashvars.
  84   *
  85   */
  86  function _simpleviewer_vars() {
  87  
  88    include_once(drupal_get_path('module', 'simpleviewer') .'/simpleviewer.admin.inc');
  89    // Grab the admin form and use all of the default values as settings for the flash embedding.
  90    $sv_vars = simpleviewer_admin_form(TRUE);
  91  
  92    foreach (element_children($sv_vars) AS $name) {
  93      $name_parts = explode('_', $name);
  94      if ($name_parts[1] == 'xml') {
  95        // The last part of the Drupal variable name matches the SimpleViewer XML option name
  96        $return['xml'][$name_parts[2]] = $sv_vars[$name]['#default_value'];
  97      }
  98      elseif ($name_parts[1] == 'swf') {
  99        $return['swf'][$name_parts[2]] = $sv_vars[$name]['#default_value'];
 100      }
 101      else {
 102        $return['other'][$name_parts[2]] = $sv_vars[$name]['#default_value'];
 103      }
 104    }
 105    return $return;
 106  }
 107  
 108  
 109  function simpleviewer_simpleviewer_swftools_playlist($playlist_data, &$method, &$vars) {
 110  
 111    $sv_vars = _simpleviewer_vars();
 112    
 113    $xml_vars = array_merge($sv_vars['xml'], $vars->flashvars);
 114  
 115    $xml = '<?xml version="1.0" encoding="UTF-8"?>'."\n";
 116    $xml .= '<simpleviewerGallery '.
 117            'maxImageWidth="'. $xml_vars['maxImageWidth'] .'" '.
 118            'maxImageHeight="'. $xml_vars['maxImageHeight'] .'" '.
 119            'textColor="'. str_replace('#', '0x', $xml_vars['textColor']) .'" '.
 120            'frameColor="'. str_replace('#', '0x', $xml_vars['frameColor']) .'" '.
 121            'frameWidth="'. $xml_vars['frameWidth'] .'" '.
 122            'stagePadding="'. $xml_vars['stagePadding'] .'" '.
 123            'thumbnailColumns="'. $xml_vars['thumbnailColumns'] .'" '.
 124            'thumbnailRows="'. $xml_vars['thumbnailRows'] .'" '.
 125            'navPosition="'. $xml_vars['navPosition'] .'" '.
 126            'title="'. $xml_vars['title'] .'" '.
 127            'imagePath="'. $vars->params['base'] .'" '.
 128            'thumbPath="'. $vars->params['base'] .'" '.
 129            'enableRightClickOpen="'. $xml_vars['enableRightClickOpen'] .'" '.
 130            'backgroundImagePath="'. $xml_vars['backgroundImagePath'] .'">';
 131    
 132    foreach($playlist_data['playlist'] AS $track => $details) {
 133      
 134      // Strip default sites path if it is present
 135      if (strpos($details['filename'], file_create_path()) === 0) {
 136        $details['filename'] = str_replace(file_create_path() . '/', '', $details['filename']);
 137      }
 138      
 139      $xml .= '
 140      <image>
 141        <filename>'. $details['filename']. '</filename>
 142        <caption>'. $details['description'] .'</caption>
 143      </image>';
 144    }
 145  
 146    $xml .= "\n</simpleviewerGallery>";
 147  
 148    return $xml;
 149  }


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