|
|
Line 479: |
Line 479: |
| Movie | | Movie |
| | | |
- | class QT {
| + | [[Media:pk.mov|width=320|height=320|autoplay=true]] |
- | /* 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($gotQTvars) {
| + | |
- | $this->tmp .= $input{$pos};
| + | |
- | continue;
| + | |
- | }
| + | |
- | $this->instr = $this->tmp;
| + | |
- | $this->tmp = '';
| + | |
- | //set the flag for QTvars
| + | |
- | if($this->instr == 'QTvars') $gotQTvars = 1;
| + | |
- | }
| + | |
- | else if($input{$pos}=='|') { // separator between arguments
| + | |
- | //reset the flags for other attributes
| + | |
- | if($gotQTvars) $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 . '" ' . $this->codeEmbed . ' PLUGINSPAGE="http://www.apple.com/quicktime/download/"></EMBED></OBJECT> ';
| + | |
- | return $this->code;
| + | |
- | }
| + | |
- |
| + | |
- | function getTitle($file) {
| + | |
- | $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
| + | |
- | }
| + | |
- | | + | |
- | var $QTvars;
| + | |
- | var $gotQTvars;
| + | |
- | | + | |
- | | + | |
- | <qt>file=pk.mov|width=320|height=240|autoplay=true</qt>
| + | |