Index: trunk/extensions/MetavidWiki/includes/articlepages/MV_SequencePage.php |
— | — | @@ -58,9 +58,9 @@ |
59 | 59 | //this is the heavy lifting of the getSequenceSMIL function: |
60 | 60 | $this->resolveHLRD(); |
61 | 61 | |
62 | | - print "the final xml:\n"; |
| 62 | + //print "the final xml:\n"; |
63 | 63 | print $this->getSmilXml(); |
64 | | - die; |
| 64 | + //die; |
65 | 65 | |
66 | 66 | //get parser Output Object (maybe cleaner way to do this? |
67 | 67 | //maybe parser cache is not the right place for this?) |
— | — | @@ -99,15 +99,9 @@ |
100 | 100 | //@@todo optimize to do all queries/lookups at once. |
101 | 101 | if(isset($tag['attributes'])){ |
102 | 102 | if(isset($tag['attributes']['uri'])){ |
103 | | - //turn the uri into a title: |
104 | | - $uriTitle = Title::newFromDBkey($tag['attributes']['uri']); |
105 | | - if( $uriTitle->exists() ){ |
106 | | - //switch output type based on namespace |
107 | | - $this->getResourceArrayFromTitle($this->aHLRD[$i], $uriTitle); |
108 | | - }else{ |
109 | | - //uri not found |
110 | | - $this->aHLRD[$i]['value']=wfMsg('mv_resource_not_found', htmlspecialchars($tag['attributes']['uri']) ); |
111 | | - } |
| 103 | + //if resolved resource is done for current pass: continue |
| 104 | + if( $this->resolveResource($i) ) |
| 105 | + continue; |
112 | 106 | } |
113 | 107 | } |
114 | 108 | |
— | — | @@ -125,56 +119,120 @@ |
126 | 120 | break; |
127 | 121 | } |
128 | 122 | $tag= $this->aHLRD[$i++]; |
129 | | - } |
| 123 | + } |
| 124 | + //init val if not set: |
| 125 | + if(!isset($this->aHLRD[ $open_inx-1 ][ 'value' ])) |
| 126 | + $this->aHLRD[ $open_inx-1 ][ 'value' ]=''; |
130 | 127 | //swap in the wiki parsed innerHTML: |
131 | | - $parserOutput = $wgParser->parse( |
| 128 | + $this->aHLRD[ $open_inx-1 ][ 'value' ].= |
132 | 129 | $this->ary2xml( |
133 | 130 | array_splice( |
134 | 131 | $this->aHLRD, $open_inx, ($close_inx-$open_inx) |
135 | 132 | ) |
136 | | - ),$this->mTitle, ParserOptions::newFromUser( $wgUser ) |
137 | | - ); |
138 | | - if(isset($this->aHLRD[ $open_inx-1 ][ 'value' ])){ |
139 | | - $this->aHLRD[ $open_inx-1 ][ 'value' ].= $parserOutput->getText(); |
140 | | - }else{ |
141 | | - $this->aHLRD[ $open_inx-1 ][ 'value' ] = $parserOutput->getText(); |
142 | | - } |
143 | | - $this->aHLRD[ $open_inx-1 ][ 'type' ] = 'complete'; |
| 133 | + ); |
| 134 | + |
| 135 | + //$this->aHLRD[ $open_inx-1 ][ 'type' ] = 'complete'; |
144 | 136 | //remove the close index |
145 | 137 | if($this->aHLRD[$open_inx]['type']=='close') |
146 | 138 | unset($this->aHLRD[$open_inx]); |
147 | 139 | //update the index (now that we have spliced the array ): |
148 | 140 | $i= $open_inx-1; //(will ++ on next loop) |
149 | 141 | } |
| 142 | + //$this->aHLRD[ $open_inx-1 ][ 'value' ] = $parserOutput->getText(); |
150 | 143 | } |
151 | 144 | } |
152 | 145 | } |
| 146 | + //print_r($this->aHLRD); |
| 147 | + //now that inner xml has been parse and outputed parse innerValue of tag as wiki_text: |
| 148 | + for($i=0;$i<count($this->aHLRD);$i++){ |
| 149 | + $parserOutput = $wgParser->parse($this->aHLRD[ $i ][ 'value' ] ,$this->mTitle, ParserOptions::newFromUser( $wgUser )); |
| 150 | + $this->aHLRD[ $i ][ 'value' ] = $parserOutput->getText(); |
| 151 | + } |
153 | 152 | //print "resolveHLRD:"; |
154 | 153 | //print_r($this->aHLRD); |
155 | 154 | //die; |
156 | 155 | } |
157 | | - function getResourceArrayFromTitle(&$tag, &$title){ |
158 | | - print "f:getResourceArrayFromTitle"; |
159 | | - switch( $title){ |
| 156 | + /* |
| 157 | + * resolves any resource refrences and gets things ready to be parsed as wikiText |
| 158 | + */ |
| 159 | + function resolveResource(& $i){ //pass in the current index |
| 160 | + $tag = $this->aHLRD[ $i ]; |
| 161 | + $uriTitle = Title::newFromDBkey($tag['attributes']['uri']); |
| 162 | + if( !$uriTitle->exists() ){ |
| 163 | + $this->aHLRD[$i]['value']=wfMsg('mv_resource_not_found', htmlspecialchars($tag['attributes']['uri']) ); |
| 164 | + $this->aHLRD[ $i ]['attributes']['type']='text/html'; |
| 165 | + return false; |
| 166 | + } |
| 167 | + //print "f:getResourceArrayFromTitle"; |
| 168 | + switch( $uriTitle->getNamespace() ){ |
160 | 169 | case NS_MAIN: |
161 | 170 | //top level ref includes of pages in the main namespace not supported |
162 | 171 | break; |
163 | | - case NS_TEMPLATE: |
164 | | - //top level ref includes of temples is not supported |
| 172 | + case NS_TEMPLATE: |
| 173 | + //grab all the template paramaters |
| 174 | + //ignore any tags other than root param values |
| 175 | + //print('on tag: ' .$i. ':' . print_r($tag, true)); |
| 176 | + $paramAry = array(); |
| 177 | + if($tag['type'] == 'open'){ |
| 178 | + $open_inx = $i; |
| 179 | + $base_depth = $tag['level']; |
| 180 | + //find close tag |
| 181 | + while( $i<count( $this->aHLRD ) ){ |
| 182 | + if($tag['type'] == 'close' && $base_depth == $tag['level'] ){ |
| 183 | + $close_inx = $i-1; |
| 184 | + break; |
| 185 | + } |
| 186 | + if($tag['tag']=='param' |
| 187 | + && isset( $tag['attributes'] ) |
| 188 | + && isset( $tag['attributes']['name'] ) ){ |
| 189 | + //set via innerHTML |
| 190 | + if( isset( $tag['value'] ) ) |
| 191 | + $paramAry[ $tag['attributes']['name'] ] = $tag['value']; |
| 192 | + //or set via value attribute |
| 193 | + if(isset( $tag['attributes']['value'] ) ) |
| 194 | + $paramAry[ $tag['attributes']['name'] ] = $tag['attributes']['value']; |
| 195 | + |
| 196 | + } |
| 197 | + $tag= $this->aHLRD[ $i++ ]; |
| 198 | + } |
| 199 | + //remove the striped children (that sounds bad) |
| 200 | + $tmp = array_splice($this->aHLRD, $open_inx, ($close_inx-$open_inx)); |
| 201 | + //print "Removed: " . print_r($tmp, true); |
| 202 | + //restore the original tag: |
| 203 | + $tag = $this->aHLRD[ $open_inx ]; |
| 204 | + //restore the index: |
| 205 | + $i= $open_inx-1; |
| 206 | + } |
| 207 | + //print('NOW on tag: ' .$i. ':' . print_r($this->aHLRD[ $i ], true)); ; |
| 208 | + //$tag_pre_val=$tag['value']; |
| 209 | + //set up wiki_text value: |
| 210 | + $this->aHLRD[ $i ]['value'] = '{{' . $uriTitle->getText(); |
| 211 | + $nl=''; |
| 212 | + foreach($paramAry as $name=>$val){ |
| 213 | + $this->aHLRD[ $i ]['value'].= "\n| ". $name . ' = ' . $val; |
| 214 | + $nl="\n"; |
| 215 | + } |
| 216 | + $this->aHLRD[ $i ]['value'].=$nl.'}}'; |
| 217 | + $this->aHLRD[ $i ]['type']='complete'; |
| 218 | + //set type attribute: |
| 219 | + $this->aHLRD[ $i ]['attributes']['type']='text/html'; |
| 220 | + return true; |
165 | 221 | break; |
166 | 222 | case NS_IMAGE: |
167 | 223 | global $mvDefaultVideoPlaybackRes; |
168 | 224 | list($width,$height)= explode('x',$mvDefaultVideoPlaybackRes); |
169 | | - //@@todo more flexiblity with image grabbing |
| 225 | + //@@todo more flexiblity with image grabbing |
170 | 226 | |
171 | | - //check for video |
172 | | - |
173 | 227 | // (probably should be hanndled via "figure" namespace which could allow arbitary crop, resize, overlay) |
174 | | - $img = wfFindFile( $title ); |
| 228 | + $img = wfFindFile( $uriTitle ); |
| 229 | + //set type attribute: |
| 230 | + $this->aHLRD[ $i ]['attributes']['type']=$img->getMimeType(); |
| 231 | + |
175 | 232 | //get a default width wide image; |
176 | 233 | $thumbnail = $img->transform( array('width'=>$width) ); |
177 | 234 | //a direct link to media |
178 | | - $tag['attributes']['src']=$thumbnail->file->getURL(); |
| 235 | + $this->aHLRD[ $i ]['attributes']['src']=$thumbnail->file->getURL(); |
| 236 | + return true; |
179 | 237 | break; |
180 | 238 | case MV_NS_SEQUENCE: |
181 | 239 | //transclude a sequence |
— | — | @@ -200,7 +258,12 @@ |
201 | 259 | xml_get_current_line_number($xml_parser) |
202 | 260 | ); |
203 | 261 | } |
204 | | - xml_parser_free($xml_parser); |
| 262 | + xml_parser_free($xml_parser); |
| 263 | + |
| 264 | + //maybe easier to go DOM based model: |
| 265 | + //$doc = new DOMDocument(); |
| 266 | + //$doc->loadXML($this->mHLRD); |
| 267 | + |
205 | 268 | //validate input with $mvHLRDTags definition |
206 | 269 | //*Currently dissabled ~~unclear if we really need to do this~~~ |
207 | 270 | /* |
— | — | @@ -375,19 +438,22 @@ |
376 | 439 | //print_r($this->clips); |
377 | 440 | }*/ |
378 | 441 | function doSeqReplace( &$input, &$argv, &$parser ) { |
379 | | - global $wgTitle, $wgUser, $wgRequest, $markerList; |
| 442 | + global $wgTitle, $wgUser, $wgRequest, $markerList, $mvDefaultVideoPlaybackRes; |
380 | 443 | $sk = $wgUser->getSkin(); |
381 | 444 | $title = Title::MakeTitle( NS_SPECIAL, 'MvExportSequence/' . $wgTitle->getDBKey() ); |
382 | | - $title_url = $title->getFullURL(); |
| 445 | + $title_url = $title->getFullURL(); |
| 446 | + |
| 447 | + |
383 | 448 | $oldid = $wgRequest->getVal( 'oldid' ); |
384 | | - if ( isset( $oldid ) ) { |
385 | | - // @@ugly hack .. but really this whole sequencer needs a serious rewrite) |
| 449 | + if ( isset( $oldid ) ) { |
386 | 450 | $ss = ( strpos( $title_url, '?' ) === false ) ? '?':'&'; |
387 | 451 | $title_url .= $ss . 'oldid=' . $oldid; |
388 | | - } |
389 | | - |
| 452 | + } |
| 453 | + |
| 454 | + list($width, $height) = explode('x', $mvDefaultVideoPlaybackRes); |
| 455 | + |
390 | 456 | $vidtag = '<div id="file" class="fullImageLink"><playlist'; |
391 | | - $vidtag .= ' width="400" height="300" src="' . htmlspecialchars( $title_url ) . '">'; |
| 457 | + $vidtag .= ' width="'.$width.'" height="'.$height.'" src="' . htmlspecialchars( $title_url ) .'">'; |
392 | 458 | $vidtag .= '</playlist></div><hr>'; |
393 | 459 | |
394 | 460 | $marker = "xx-marker" . count( $markerList ) . "-xx"; |
Index: trunk/extensions/MetavidWiki/includes/MV_GlobalFunctions.php |
— | — | @@ -178,7 +178,7 @@ |
179 | 179 | |
180 | 180 | $wgHooks['TitleMoveComplete'][] = 'mvMoveHook'; |
181 | 181 | |
182 | | - // note this hook is not avaliable by default in medaiwiki |
| 182 | + // @@NOTE this hook is not avaliable by default in medaiwiki |
183 | 183 | // to use this hook you should add this function to moveTo() in Title.php: |
184 | 184 | /* |
185 | 185 | $err = wfRunHooks('TitleisValidMove', array( &$this, &$nt, &$wgUser, $auth)); |
— | — | @@ -195,6 +195,29 @@ |
196 | 196 | |
197 | 197 | $wgParser->setFunctionHook( 'mvData', 'mvMagicParserFunction_Render' ); |
198 | 198 | |
| 199 | + |
| 200 | + /* |
| 201 | + * OggHandler extension overides |
| 202 | + * if the OggHandler is included remap the object for copatibility with metavid |
| 203 | + * MV_OggHandler.php hanndles all the re-mapping |
| 204 | + */ |
| 205 | + if($wgMediaHandlers['application/ogg'] == 'OggHandler'){ |
| 206 | + $wgMediaHandlers['application/ogg']='mvOggHandler'; |
| 207 | + $wgParserOutputHooks['OggHandler'] = array( 'mvOggHandler', 'outputHook' ); |
| 208 | + foreach($wgHooks['LanguageGetMagic'] as & $hook_function){ |
| 209 | + if($hook_function=='OggHandler::registerMagicWords'){ |
| 210 | + $hook_function='mvOggHandler::registerMagicWords'; |
| 211 | + } |
| 212 | + } |
| 213 | + foreach($wgExtensionCredits as & $ext){ |
| 214 | + if($ext['name']=='OggHandler'){ |
| 215 | + $ext['description'].=' Integrated with the <b>MetaVidWiki Extension</b>'; |
| 216 | + } |
| 217 | + } |
| 218 | + } |
| 219 | + |
| 220 | + |
| 221 | + |
199 | 222 | // $wgHooks['BeforePageDisplay'][] = 'mvDoSpecialPage'; |
200 | 223 | // $wgHooks['ArticleViewHeader'][] = 'mvArticleViewOpts'; |
201 | 224 | /**********************************************/ |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_playlist.js |
— | — | @@ -146,7 +146,8 @@ |
147 | 147 | //load sequencer: |
148 | 148 | mv_do_sequence({ |
149 | 149 | "sequence_container_id":'modalbox', |
150 | | - "mv_pl_url_id":_this.src //kind of redundant but make for a clean "cancel".. |
| 150 | + "mv_pl_url_id":_this.src, //kind of redundant but make for a clean "cancel".. |
| 151 | + "mv_pl_hlrd_url":_this.hlrd |
151 | 152 | // we could switch to moving around dom elements if performance is an issue |
152 | 153 | }); |
153 | 154 | |