-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuicktime.php
149 lines (129 loc) · 4.52 KB
/
Quicktime.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USAw
*
* Parts of the program use the file 'Image.php' and 'Flash.php' from the MediaWiki project.
* The respective source can be acquired from http://svn.wikimedia.org/viewvc/mediawiki/trunk/.
*
* @author <grinfeder@miami.edu>
*
*
NOTE:
There are some bugs in that code throwing PHP warnings:
To fix these add
var $QTvars;
var $gotQTvars;
after the class definition and replace the 4 occurences of $gotQTvars with $this->gotQTvars
*/
if ( !defined( 'MEDIAWIKI' ) ) {
die( "This file is part of the QuickTime extension. It is not a valid entry point.\n" );
}
$wgExtensionFunctions[] = "wfQTExtension";
/*
* The QT class generates code in order to implement a QT object.
*/
class QT {
var $QTvars;
var $gotQTvars;
/* Constructor */
function QT( $input ) {
QT::parseInput( $input ); // Parse the input
QT::genCode(); // Generate the final code
}
/* Parser */
function parseInput( $input ) {
for ( $pos = 0; $pos < strlen( $input ); $pos++ ) { // go through all arguments
if ( $input { $pos } == '=' ) { // separator between command
// ignore '=' if the attribute is QTvars
// this will enable to pass query string to QT files
if ( $this->gotQTvars ) {
$this->tmp .= $input { $pos };
continue;
}
$this->instr = $this->tmp;
$this->tmp = '';
// set the flag for QTvars
if ( $this->instr == 'QTvars' )
$this->gotQTvars = 1;
}
else if ( $input { $pos } == '|' ) { // separator between arguments
// reset the flags for other attributes
if ( $this->gotQTvars )
$this->gotQTvars = 0;
QT::setValue();
$this->tmp = '';
} else {
$this->tmp .= $input { $pos };
}
}
if ( $this->tmp != '' ) {
QT::setValue(); // Deal with the rest of the input string
}
}
/* Coordinate commands with values */
function setValue() {
$this->value = $this->tmp;
$this->{ $this->instr } = $this->value;
if ( $this->instr == 'autoplay' || // Whitelist of QT commands. Anything else but QT commands is ignored.
$this->instr == 'controller' )
{
/* Create code for <embed> and <object> */
if ( $this->instr != 'id' ) {
$this->codeEmbed .= ' ' . $this->instr . '="' . $this->value . '"';
}
if ( $this->instr != 'name' ) {
$this->codeObject .= '<param name="' . $this->instr . '" value="' . $this->value . '">';
}
}
}
/* Generate big, final chunk of code */
function genCode() {
// Possibly malicious settings:
$codebase = 'http://www.apple.com/qtactivex/qtplugin.cab'; // Code Base /No need to change
$classID = 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B'; // ClassID / No need to change
// Default version Setting:
$this->version = '7,0,0,0'; // Version settings for <object>
$this->url = $this->getTitle( $this->file ); // QT::imageUrl( $this->file, $this->fromSharedDirectory ); // get Wiki internal url
// if QTvars is set append to the url
if ( $this->QTvars ) {
$this->url .= $this->QTvars;
}
/* Final Code */
$this->code = '<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
WIDTH="160"HEIGHT="144" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">
<PARAM name="SRC" VALUE="' . $this->url . '">' . $this->codeObject .
'<EMBED SRC="' . $this->url . '" WIDTH="' . $this->width . '" HEIGHT="' . ($this->height+16) .
'" ' . $this->codeEmbed . ' PLUGINSPAGE="http://www.apple.com/quicktime/download/"></EMBED></OBJECT> ';
return $this->code;
}
function getTitle( $file ) {
// independant from namespace
$title = Title::makeTitleSafe( "Image", $file );
$img = new Image( $title );
$path = $img->getViewURL( false );
return $path;
}
}
function wfQTExtension() {
global $wgParser;
$wgParser->setHook( "QT", "renderQT" );
}
function renderQT( $input ) {
global $code;
// Constructor
$QTFile = new QT( $input );
$code = $QTFile->code;
return $code; // send the final code to the wiki
}