You are here

ckeditor_swf.admin.inc in CKEditor SWF - Enhanced Flash embedding plugin 6.2

Same filename and directory in other branches
  1. 7 ckeditor_swf.admin.inc

Written by Henri MEDOT <henri.medot[AT]absyx[DOT]fr> http://www.absyx.fr

File

ckeditor_swf.admin.inc
View source
<?php

/**
 * @file
 * Written by Henri MEDOT <henri.medot[AT]absyx[DOT]fr>
 * http://www.absyx.fr
 */
function ckeditor_swf_admin_form($form_state) {
  $form['notice'] = array(
    '#value' => '<p><strong>Notice:</strong> this administration page is a preliminary version and should be updated to a more user-friendly one in next releases.</p>',
  );
  $form['players_php'] = array(
    '#type' => 'textarea',
    '#title' => t('Players configuration PHP code'),
    '#default_value' => variable_get('ckeditor_swf_players_php', 'return array();'),
    '#description' => '',
    '#rows' => 15,
    '#required' => TRUE,
    '#wysiwyg' => FALSE,
  );
  $form['instructions'] = array(
    '#value' => '<p>Here you can configure the players that <em>CKEditor SWF</em> will use to embed FLV and MP3 files. You can ignore this page if you do not need this feature.</p>' . '<p>Below are 2 sample configurations. Choose the one that suits your needs, copy the associated configuration PHP code, then paste it into the above textarea, in place of its previous content. Finally, click on the <em>Save</em> button at the bottom of the page.</p>' . '<h3><strong>Sample configuration #1</strong></h3>' . '<p>It uses <a href="http://www.longtailvideo.com/players/jw-flv-player">JW Player</a> both for FLV and MP3 playback.<br />' . 'It assumes that you unpacked the content of <em>mediaplayer.zip</em> to the <em>sites/all/libraries</em> directory.<br />' . 'If the file <em>player.swf</em> is somewhere else on your server, adjust the path parameter accordingly.<br />' . 'This path must be relative to the Drupal installation directory.</p>' . "<pre style=\"border:1px solid #CCC;padding:5px;\">return array(\n  'video/x-flv' => array(\n    'path' => 'sites/all/libraries/mediaplayer/player.swf',\n    'offsetHeight' => 24,\n    'fileName' => 'file',\n  ),\n  'audio/mpeg' => array(\n    'path' => 'sites/all/libraries/mediaplayer/player.swf',\n    'offsetHeight' => 0,\n    'fileName' => 'file',\n    'defaultWidth' => 280,\n    'defaultHeight' => 24,\n  ),\n);</pre>" . '<h3><strong>Sample configuration #2</strong></h3>' . '<p>It uses JW Player for FLV playback (see #1 about this) and <a href="http://wpaudioplayer.com/download">WordPress Audio Standalone Player = 1 Pixel Out</a> for MP3 playback.<br />' . 'It assumes that you unpacked the content of <em>audio-player-standalone.zip</em> to the <em>sites/all/libraries</em> directory.<br />' . 'If the file <em>player.swf</em> is somewhere else on your server, adjust the path parameter accordingly.<br />' . 'This path must be relative to the Drupal installation directory.</p>' . "<pre style=\"border:1px solid #CCC;padding:5px;\">return array(\n  'video/x-flv' => array(\n    'path' => 'sites/all/libraries/mediaplayer/player.swf',\n    'offsetHeight' => 24,\n    'fileName' => 'file',\n  ),\n  'audio/mpeg' => array(\n    'path' => 'sites/all/libraries/audio-player/player.swf',\n    'offsetHeight' => 0,\n    'fileName' => 'soundFile',\n    'defaultWidth' => 290,\n    'defaultHeight' => 24,\n  ),\n);</pre>",
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}
function ckeditor_swf_admin_form_validate($form, &$form_state) {
  $elements = $form['players_php'];
  $players_php = $elements['#value'];
  if (strlen($players_php) > 0) {
    ob_start();
    $players = eval($players_php);
    ob_end_clean();
    if (!is_array($players)) {
      form_error($elements, t('!name must return an array.', array(
        '!name' => $elements['#title'],
      )));
    }
    else {
      foreach ($players as $mime => $player) {
        if (!is_array($player) || !array_key_exists('path', $player) || !array_key_exists('fileName', $player)) {
          form_error($elements, t('The players configuration is invalid.'));
          return;
        }
        elseif (!file_exists($path = $player['path'])) {
          form_error($elements, t('The path %path does not exist.', array(
            '%path' => $path,
          )));
        }
      }
    }
  }
}
function ckeditor_swf_admin_form_submit($form, &$form_state) {
  $players_php = $form_state['values']['players_php'];
  variable_set('ckeditor_swf_players_php', $players_php);
  ob_start();
  $players = eval($players_php);
  ob_end_clean();
  variable_set('ckeditor_swf_players', $players);
  drupal_set_message(t('The configuration options have been saved.'));
}

Functions

Namesort descending Description
ckeditor_swf_admin_form @file Written by Henri MEDOT <henri.medot[AT]absyx[DOT]fr> http://www.absyx.fr
ckeditor_swf_admin_form_submit
ckeditor_swf_admin_form_validate