1 package org.apache.maven.doxia.macro;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.doxia.sink.Sink;
23 import org.codehaus.plexus.component.annotations.Component;
24 import org.codehaus.plexus.util.StringUtils;
25
26
27
28
29
30
31
32
33 @Component( role = Macro.class, hint = "swf" )
34 public class SwfMacro
35 extends AbstractMacro
36 {
37
38 public void execute( Sink sink, MacroRequest request )
39 throws MacroExecutionException
40 {
41
42 String src = "";
43 String id = "swf";
44 String width = "400";
45 String height = "400";
46 String quality = "high";
47 String menu = "false";
48 String loop = "0";
49 String play = "true";
50 String version = "9,0,45,0";
51 String allowScript = "sameDomain";
52
53
54 for ( String key : request.getParameters().keySet() )
55 {
56 Object parameterObject = request.getParameter( key );
57 if ( !( parameterObject instanceof String ) )
58 {
59 continue;
60 }
61 String str = (String) parameterObject;
62 if ( key.equals( "src" ) )
63 {
64 if ( StringUtils.isNotEmpty( str ) )
65 {
66 src = str;
67 }
68 }
69 else if ( key.equals( "id" ) )
70 {
71 if ( StringUtils.isNotEmpty( str ) )
72 {
73 id = str;
74 }
75 }
76 else if ( key.equals( "width" ) )
77 {
78 if ( StringUtils.isNotEmpty( str ) )
79 {
80 width = str;
81 }
82 }
83 else if ( key.equals( "height" ) )
84 {
85 if ( StringUtils.isNotEmpty( str ) )
86 {
87 height = str;
88 }
89 }
90 else if ( key.equals( "quality" ) )
91 {
92 if ( StringUtils.isNotEmpty( str ) )
93 {
94 quality = str;
95 }
96 }
97 else if ( key.equals( "menu" ) )
98 {
99 if ( StringUtils.isNotEmpty( str ) )
100 {
101 menu = str;
102 }
103 }
104 else if ( key.equals( "loop" ) )
105 {
106 if ( StringUtils.isNotEmpty( str ) )
107 {
108 loop = str;
109 }
110 }
111 else if ( key.equals( "play" ) )
112 {
113 if ( StringUtils.isNotEmpty( str ) )
114 {
115 play = str;
116 }
117 }
118 else if ( key.equals( "version" ) )
119 {
120
121
122 if ( str.equals( "6" ) )
123 {
124 version = "6,0,29,0";
125 }
126 else
127 {
128 if ( str.equals( "9" ) )
129 {
130 version = "9,0,45,0";
131 }
132 else
133 {
134 if ( StringUtils.isNotEmpty( str ) )
135 {
136 version = str;
137 }
138 }
139 }
140 }
141 else if ( key.equals( "allowScript" ) )
142 {
143 if ( StringUtils.isNotEmpty( str ) )
144 {
145 allowScript = str;
146 }
147 }
148 }
149
150 StringBuilder content = new StringBuilder();
151 content.append( "<center>" ).append( EOL );
152 content.append( "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" " )
153 .append( "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" )
154 .append( version ).append( "\" width=\"" ).append( width ).append( "\" height=\"" ).append( height )
155 .append( "\" id=\"" ).append( id ).append( "\">" ).append( EOL );
156 content.append( "<param name=\"movie\" value=\"" ).append( src ).append( "\" />" ).append( EOL );
157 content.append( "<param name=\"quality\" value=\"" ).append( quality ).append( "\" />" ).append( EOL );
158 content.append( "<param name=\"menu\" value=\"" ).append( menu ).append( "\" />" ).append( EOL );
159 content.append( "<param name=\"loop\" value=\"" ).append( loop ).append( "\" />" ).append( EOL );
160 content.append( "<param name=\"play\" value=\"" ).append( play ).append( "\" />" ).append( EOL );
161 content.append( "<param name=\"allowScriptAccess\" value=\"" )
162 .append( allowScript ).append( "\" />" ).append( EOL );
163 content.append( "<embed src=\"" ).append( src ).append( "\" width=\"" ).append( width ).append( "\" height=\"" )
164 .append( height ).append( "\" loop=\"" ).append( loop ).append( "\" play=\"" ).append( play )
165 .append( "\" quality=\"" ).append( quality ).append( "\" allowScriptAccess=\"" ).append( allowScript )
166 .append( "\" " ).append( "pluginspage=\"http://www.macromedia.com/go/getflashplayer\" " )
167 .append( "type=\"application/x-shockwave-flash\" menu=\"" ).append( menu ).append( "\">" ).append( EOL );
168 content.append( "</embed>" ).append( EOL );
169 content.append( "</object>" ).append( EOL );
170 content.append( "</center>" ).append( EOL );
171
172 sink.rawText( content.toString() );
173 }
174 }