2
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
* Helioviewer Movies Module class definition
8
* @category Configuration
10
* @author Keith Hughitt <keith.hughitt@nasa.gov>
11
* @author Jaclyn Beck <jabeck@nmu.edu>
12
* @license http://www.mozilla.org/MPL/MPL-1.1.html Mozilla Public License 1.1
13
* @link http://launchpad.net/helioviewer.org
15
require_once 'interface.Module.php';
18
* Movie generation and display.
20
* @category Configuration
21
* @package Helioviewer
22
* @author Keith Hughitt <keith.hughitt@nasa.gov>
23
* @author Jaclyn Beck <jabeck@nmu.edu>
24
* @license http://www.mozilla.org/MPL/MPL-1.1.html Mozilla Public License 1.1
25
* @link http://launchpad.net/helioviewer.org
28
class Module_Movies implements Module
31
* API Request parameters
38
* Movie module constructor
40
* @param mixed &$params API request parameters
42
public function __construct(&$params)
44
$this->_params = $params;
53
public function execute()
55
if ($this->validate()) {
56
$this->{$this->_params['action']}();
63
* @return bool Returns true if input parameters are valid
65
public function validate()
67
switch($this->_params['action'])
71
"required" => array('startDate', 'zoomLevel', 'numFrames', 'frameRate', 'timeStep', 'quality'),
72
"dates" => array('startDate'),
73
"ints" => array('zoomLevel, numFrames, frameRate, timeStep, quality')
77
// Temporarily disabled.
78
// TODO: Before re-enabling, validate file input.
79
// Allow only filename specification.
86
if (isset($expected)) {
87
Validation_InputValidator::checkInput($expected, $this->_params);
98
public static function printDoc()
107
* All possible parameters: startDate, zoomLevel, numFrames, frameRate,
108
* timeStep, layers, imageSize ("x,y"), filename, edges, sharpen, format.
110
* API example: http://localhost/helioviewer/api/index.php?action=buildMovie
111
* &startDate=1041465600&zoomLevel=13&numFrames=20&frameRate=8
112
* &timeStep=86400&layers=SOH,EIT,EIT,304,1,100x0,1034,0,1034,-230,-215
113
* /SOH,LAS,0C2,0WL,1,100x0,1174,28,1110,-1,0
114
* &imageSize=588,556&filename=example&sharpen=false&edges=false
116
* Note that filename does NOT have the . extension on it. The reason for
117
* this is that in the media settings pop-up dialog, there is no way of
118
* knowing ahead of time whether the image is a .png, .tif, .flv, etc,
119
* and in the case of movies, the file is both a .flv and .mov/.asf/.mp4
123
public function buildMovie ()
125
include_once 'lib/Movie/HelioviewerMovie.php';
127
// Required parameters
128
$startDate = $this->_params['startDate'];
129
$zoomLevel = $this->_params['zoomLevel'];
130
$numFrames = $this->_params['numFrames'];
131
$frameRate = $this->_params['frameRate'];
132
$timeStep = $this->_params['timeStep'];
133
$quality = $this->_params['quality'];
135
// Layerstrings are separated by "/"
136
$layerStrings = explode("/", $this->_params['layers']);
138
$imageCoords = explode(",", $this->_params['imageSize']);
140
"width" => $imageCoords[0],
141
"height" => $imageCoords[1]
143
$filename = $this->_params['filename'];
144
$hqFormat = $this->_params['format'];
147
// Optional parameters
149
$options['enhanceEdges'] = $this->_params['edges'] || false;
150
$options['sharpen'] = $this->_params['sharpen'] || false;
152
//Check to make sure values are acceptable
154
//Limit number of layers to three
155
if (strlen($this->_params['layers']) == 0) {
156
$msg = "Invalid layer choices! You must specify 1-3 command-separate layernames.";
157
throw new Exception($msg);
160
//Limit number of frames
161
if (($numFrames < 10) || ($numFrames > HV_MAX_MOVIE_FRAMES)) {
162
$msg = "Invalid number of frames. Number of frames should be " .
163
"at least 10 and no more than " . HV_MAX_MOVIE_FRAMES . ".";
164
throw new Exception($msg);
167
$layers = $this->_formatLayerStrings($layerStrings);
169
$movie = new Movie_HelioviewerMovie(
170
$layers, $startDate, $zoomLevel, $numFrames, $frameRate,
171
$hqFormat, $options, $timeStep, $imageSize, $filename, $quality
173
$movie->buildMovie();
175
} catch(Exception $e) {
176
echo 'Error: ' .$e->getMessage();
184
* Gets the movie url and loads it into MC Mediaplayer
188
public function playMovie ()
190
$url = $this->_params['url'];
191
$width = $this->_params['width'];
192
$height = $this->_params['height'];
195
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
196
"http://www.w3.org/TR/html4/strict.dtd">
199
<title>Helioviewer.org QuickMovie</title>
201
<body style="background-color: black; color: #FFF;">
202
<!-- MC Media Player -->
203
<div style="text-align: center;">
204
<script type="text/javascript">
205
playerFile = "http://www.mcmediaplayer.com/public/mcmp_0.8.swf";
206
fpFileURL = "<?php print $url?>";
207
fpButtonSize = "48x48";
209
cpHidePanel = "mouseout";
211
defaultEndAction = "repeat";
212
playerSize = "<?php print $width . 'x' . $height?>";
214
<script type="text/javascript"
215
src="http://www.mcmediaplayer.com/public/mcmp_0.8.js"></script>
216
<!-- / MC Media Player -->
b'\\ No newline at end of file'