View source
<?php
function mediafront_schema() {
$schema['mediafront_preset'] = array(
'description' => 'The preset table for MediaFront.',
'fields' => array(
'pid' => array(
'description' => 'The primary identifier for a MediaFront preset.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'name' => array(
'description' => 'The name of this preset.',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'description' => array(
'description' => 'A brief description of this preset.',
'type' => 'text',
'size' => 'medium',
'translatable' => TRUE,
),
'player' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'connect' => array(
'type' => 'text',
'size' => 'medium',
'serialize' => TRUE,
'description' => 'Serialized player connection settings.',
),
'settings' => array(
'type' => 'text',
'size' => 'medium',
'serialize' => TRUE,
'description' => 'Serialized player settings that do not warrant a dedicated column.',
),
),
'unique keys' => array(
'name' => array(
'name',
),
),
'primary key' => array(
'pid',
),
);
$schema['mediafront_filefield'] = array(
'description' => 'Table used to tell the MediaFront module how each FileField should be handled.',
'fields' => array(
'fid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'node_type' => array(
'type' => 'text',
'not null' => FALSE,
),
'field_name' => array(
'type' => 'text',
'not null' => FALSE,
),
'media_type' => array(
'type' => 'text',
'not null' => FALSE,
),
'node_preset' => array(
'type' => 'text',
'not null' => FALSE,
),
'thumb_preset' => array(
'type' => 'text',
'not null' => FALSE,
),
),
'primary key' => array(
'fid',
),
);
return $schema;
}
function mediafront_enable() {
if (module_exists('content')) {
module_load_include('inc', 'mediafront', 'mediafront_field');
content_notify('enable', 'mediafront');
}
}
function mediafront_disable() {
if (module_exists('content')) {
content_notify('disable', 'mediafront');
}
}
function mediafront_install() {
drupal_install_schema('mediafront');
if (module_exists('content')) {
content_notify('install', 'mediafront');
}
}
function mediafront_uninstall() {
drupal_uninstall_schema('mediafront');
if (module_exists('content')) {
content_notify('uninstall', 'mediafront');
}
}
function mediafront_update_6001() {
$update = array();
osmplayer_clear_css();
return $update;
}
function mediafront_update_6002() {
$update = array();
osmplayer_clear_css();
return $update;
}
function mediafront_update_6003() {
$update = array();
db_create_table($update, 'mediafront_filefield', array(
'description' => 'Table used to tell the MediaFront module how each FileField should be handled.',
'fields' => array(
'fid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'node_type' => array(
'type' => 'text',
'not null' => FALSE,
),
'field_name' => array(
'type' => 'text',
'not null' => FALSE,
),
'media_type' => array(
'type' => 'text',
'not null' => FALSE,
),
'node_preset' => array(
'type' => 'text',
'not null' => FALSE,
),
'thumb_preset' => array(
'type' => 'text',
'not null' => FALSE,
),
),
'primary key' => array(
'fid',
),
));
$presets = db_query("SELECT * FROM {mediafront_imagecache}");
while ($preset = db_fetch_object($presets)) {
$sql = "INSERT INTO {mediafront_filefield} (node_type, field_name, node_preset, thumb_preset) ";
$sql .= "VALUES ( '{$preset->node_type}', '{$preset->field_name}', '{$preset->node_preset}', '{$preset->thumb_preset}' )";
$update[] = update_sql($sql);
}
$dir = getcwd() . '/' . drupal_get_path('module', 'mediafront_imagecache');
module_disable(array(
'mediafront_imagecache',
));
drupal_uninstall_module('mediafront_imagecache');
file_delete($dir . '/mediafront_imagecache.module');
file_delete($dir . '/mediafront_imagecache.info');
file_delete($dir . '/mediafront_imagecache.install');
return $update;
}
function mediafront_update_6004() {
$update = array();
$displays = array();
$result = db_query("SELECT * FROM {views_display}");
while ($display = db_fetch_object($result)) {
$display->options = unserialize($display->display_options);
$displays[$display->vid][$display->id] = $display;
}
foreach ($displays as $vid => $group) {
foreach ($group as $id => $display) {
if ($display->display_plugin == 'mediaplayerpage' || $display->display_plugin == 'mediaplayer') {
$preset = '';
if ($display->options['fields']) {
foreach ($display->options['fields'] as $name => $field) {
if (isset($field['mediafront_preset'])) {
$preset = $field['mediafront_preset'];
break;
}
}
}
if (!$preset) {
foreach ($group['default']->options['fields'] as $name => $field) {
if (isset($field['mediafront_preset'])) {
$preset = $field['mediafront_preset'];
break;
}
}
}
if ($preset) {
$new_options = $display->options;
unset($new_options['fields']);
if ($new_options['defaults']) {
unset($new_options['defaults']['fields']);
}
if ($display->options['defaults']) {
$new_options['defaults'] = array_merge($display->options['defaults'], array(
'style_plugin' => false,
'style_options' => false,
'row_plugin' => false,
'row_options' => false,
));
}
else {
$new_options['defaults'] = array(
'style_plugin' => false,
'style_options' => false,
'row_plugin' => false,
'row_options' => false,
);
}
$new_options['row_options'] = array();
$new_options['row_plugin'] = 'fields';
$new_options['style_plugin'] = 'mediaplayer';
$new_options['style_options'] = array(
'mediafront_preset' => $preset,
);
if ($display->options['path']) {
$new_options['path'] = $display->options['path'];
}
if ($display->options['menu']) {
$new_options['menu'] = $display->options['menu'];
}
if ($display->options['block_description']) {
$new_options['block_description'] = $display->options['block_description'];
}
if ($display->options['block_caching']) {
$new_options['block_caching'] = $display->options['block_caching'];
}
$view = views_get_view(db_result(db_query("SELECT name FROM {views_view} WHERE vid=%d", $display->vid)));
$type = $display->display_plugin == 'mediaplayerpage' ? 'page' : 'block';
$plugin = views_fetch_plugin_data('display', $type);
$id = $type . '_1';
$viewTitle = $display->display_plugin == 'mediaplayerpage' ? 'Page' : 'Block';
$title = $viewTitle;
$count = 1;
while (!empty($view->display[$id])) {
$id = $type . '_' . ++$count;
$title = $viewTitle . ' ' . $count;
}
$sql = "INSERT INTO {views_display} (vid, id, display_title, display_plugin, position, display_options) ";
$sql .= "VALUES ({$display->vid}, '{$id}', '{$title}', '{$type}', 10, '%s')";
db_query($sql, serialize($new_options));
$update[] = array(
'success' => TRUE,
'query' => check_plain($sql),
);
}
}
}
}
foreach ($displays as $vid => $group) {
foreach ($group as $id => $display) {
$new_options = $display->options;
if ($display->options['fields']) {
foreach ($display->options['fields'] as $name => $field) {
if ($field['table'] == 'mediafront_preset') {
unset($new_options['fields'][$name]);
$sql = "UPDATE {views_display} SET display_options='%s' WHERE vid={$display->vid} AND id='{$display->id}'";
db_query($sql, serialize($new_options));
$update[] = array(
'success' => TRUE,
'query' => check_plain($sql),
);
}
}
}
}
}
$update[] = update_sql("DELETE FROM {views_display} WHERE display_plugin='mediaplayerpage'");
$update[] = update_sql("DELETE FROM {views_display} WHERE display_plugin='mediaplayer'");
osmplayer_clear_css();
$dir = getcwd() . '/' . drupal_get_path('module', 'mediafront');
file_delete($dir . '/views/mediafront_handler_field_preset.inc');
file_delete($dir . '/views/mediafront_plugin_display_block.inc');
file_delete($dir . '/views/mediafront_plugin_display_page.inc');
return $update;
}
function mediafront_update_6005() {
$update = array();
if (db_table_exists('mediafront_imagecache')) {
db_drop_table($update, 'mediafront_imagecache');
}
return $update;
}
function mediafront_update_6006() {
menu_cache_clear();
}
function mediafront_update_6007() {
menu_cache_clear();
}
function mediafront_update_6008() {
require_once getcwd() . '/' . drupal_get_path('module', 'mediafront') . '/players/osmplayer/player/OSMPlayer.php';
require_once getcwd() . '/' . drupal_get_path('module', 'mediafront') . '/includes/mediafront.preset.inc';
osmplayer_clear_css();
$presets = mediafront_preset_get_presets();
$player = new OSMPlayer();
$path = $player
->getPlayerPath();
foreach ($presets as $preset) {
$preset['settings']['playerPath'] = $path;
unset($preset['settings']['playerURL']);
mediafront_preset_save($preset);
}
}
function mediafront_update_6009() {
mediafront_update_6008();
}