-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmoviemasherSWEditorCallback.php
executable file
·71 lines (45 loc) · 2.22 KB
/
moviemasherSWEditorCallback.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
<?php
//this file receives SWEditor BSW , parse BSW image and sets Moviemasher timeline.selection.bsw
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
$bsw = (empty($_REQUEST['bsw']) ? "" : $_REQUEST['bsw']);
file_get_contents($CFG->wwwroot."/mod/moviemasher/binarySignWriting.php?palavra=".$bsw );
?>
<script>
function clearnl(text){
text = escape(text);
if(text.indexOf('%0D%0A') > -1){
re_nlchar = /%0D%0A/g ;
}else if(text.indexOf('%0A') > -1){
re_nlchar = /%0A/g ;
}else if(text.indexOf('%0D') > -1){
re_nlchar = /%0D/g ;
}
return unescape( text.replace(re_nlchar,'') );
}
// gets mash
var mash = window.parent.moviemasher("editor_frame","moviemasher_editor").evaluate("mash.xml");
mash = clearnl(mash);
//mash = mash.replace(/\r/,"");
var oldBSW = window.parent.moviemasher("editor_frame","moviemasher_editor").evaluate("timeline.selection.bsw");
//alert(xmash);
var theSearch = '(.*?)<clip(.*?)bsw="'+oldBSW+'"(.*?)>(.*?)<clip(.*?)id="(.*?)"(.*?)>(.*?)</clip>(.*?)';
var re = new RegExp(theSearch);
var matches = re.exec(mash);
var oldID = matches[6];
var newID = "<?php echo md5(substr($bsw,0, 128))?>";
var newBSW="<?php echo $bsw ?>";
var newClip = matches[1]+'<clip'+matches[2]+' bsw="'+newBSW+'"'+matches[3]+'>'+matches[4]+'<clip'+matches[5]+'id="'+newID+'"'+matches[7]+'>'+matches[8]+'</clip>'+matches[9];
newClip = newClip + '<media group="image" type="image" id="'+newID+'" label="SW" url="../../../temp/'+newID+'.png" fill="crop"/>';
var newMash = mash.replace(matches[0],newClip);
var position = window.parent.moviemasher("editor_frame","moviemasher_editor").evaluate("player.position");
window.parent.moviemasher("editor_frame","moviemasher_editor").evaluate(newMash);
window.parent.moviemasher("editor_frame","moviemasher_editor").evaluate("player.position="+position);
//window.parent.moviemasher("editor_frame","moviemasher_editor").evaluate("mash.xml="+newMash);
//alert(newMash);
// replace selected clip with new one into mash
// sets new mash
//window.parent.moviemasher("editor_frame","moviemasher_editor").evaluate("timeline.selection.bsw=<?php echo $bsw; ?>");
window.parent.closeSWEditor();
</script>
<?php
?>