<?php $flavors = video_get_flavor_settings(); $info = elgg_echo('video:flavors:info'); if (empty($flavors)) { $flavors = elgg_echo('admin:video:no_flavors'); } else { foreach ($flavors as $key => $flavor) { $flavors[$key][] = elgg_view('output/confirmlink', array('href' => "action/video/delete_flavor?id={$key}", 'text' => elgg_echo('delete'))); } $headers = array(elgg_echo('video:format'), elgg_echo('video:resolution'), elgg_echo('video:bitrate'), ''); $table = elgg_view('output/table', array('headers' => $headers, 'rows' => $flavors, 'table_class' => 'elgg-table-alt')); } $body = elgg_view_module('inline', elgg_echo('admin:video:flavors'), $table); $button = elgg_view('output/url', array('href' => 'admin/video/add_flavor', 'text' => elgg_echo('admin:video:add_flavor'), 'class' => 'elgg-button elgg-button-action')); echo <<<HTML \t<div>{$info}</div> \t<div>{$body}</div> \t<div>{$button}</div> HTML ;
/** * Add a new flavor to flavor settings. */ function video_delete_flavor_setting($id) { $flavors = video_get_flavor_settings(); unset($flavors[$id]); $settings = serialize($flavors); return elgg_set_plugin_setting('flavors', $settings, 'video'); }
/** * Create different video sources based on plugin configuration */ public function setSources() { $flavors = video_get_flavor_settings(); foreach ($flavors as $flavor) { $source = new VideoSource(); $source->container_guid = $this->getGUID(); $source->owner_guid = $this->getOwnerGUID(); $source->access_id = $this->access_id; $source->conversion_done = false; if (empty($flavor['resolution'])) { $source->resolution = null; // Use resolution of the parent in the filename $resolution = $this->resolution; } else { $source->resolution = $flavor['resolution']; $resolution = $source->resolution; } if (empty($flavor['bitrate'])) { $source->bitrate = null; } else { $source->bitrate = $flavor['bitrate']; } $source->format = $flavor['format']; $basename = $this->getFilenameWithoutExtension(); $filename = "video/{$this->getGUID()}/{$basename}_{$resolution}.{$source->format}"; $source->setFilename($filename); $source->setMimeType("video/{$source->format}"); $source->save(); } }