1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.deploy.auto;
16  
17  import com.liferay.portal.kernel.deploy.auto.AutoDeployException;
18  import com.liferay.portal.kernel.plugin.PluginPackage;
19  
20  import java.io.File;
21  
22  import java.util.HashMap;
23  import java.util.Map;
24  
25  /**
26   * <a href="PHPPortletAutoDeployer.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Jorge Ferrer
29   */
30  public class PHPPortletAutoDeployer extends PortletAutoDeployer {
31  
32      public PHPPortletAutoDeployer() throws AutoDeployException {
33          try {
34              String[] phpJars = new String[] {
35                  "quercus.jar", "resin-util.jar", "script-10.jar"
36              };
37  
38              for (int i = 0; i < phpJars.length; i++) {
39                  String phpJar = phpJars[i];
40  
41                  jars.add(downloadJar(phpJar));
42              }
43  
44              addRequiredJar(jars, "portals-bridges.jar");
45          }
46          catch (Exception e) {
47              throw new AutoDeployException(e);
48          }
49      }
50  
51      public void copyXmls(
52              File srcFile, String displayName, PluginPackage pluginPackage)
53          throws Exception {
54  
55          super.copyXmls(srcFile, displayName, pluginPackage);
56  
57          Map<String, String> filterMap = new HashMap<String, String>();
58  
59          String pluginName = displayName;
60  
61          if (pluginPackage != null) {
62              pluginName = pluginPackage.getName();
63          }
64  
65          filterMap.put(
66              "portlet_class", "com.liferay.util.bridges.php.PHPPortlet");
67          filterMap.put("portlet_name", pluginName);
68          filterMap.put("portlet_title", pluginName);
69          filterMap.put("restore_current_view", "false");
70          filterMap.put("friendly_url_mapper_class", "");
71          filterMap.put("init_param_name_0", "view-uri");
72          filterMap.put("init_param_value_0", "/index.php");
73          filterMap.put("init_param_name_1", "add-portlet-params");
74          filterMap.put("init_param_value_1", "true");
75  
76          copyDependencyXml(
77              "liferay-display.xml", srcFile + "/WEB-INF", filterMap);
78          copyDependencyXml(
79              "liferay-portlet.xml", srcFile + "/WEB-INF", filterMap);
80          copyDependencyXml(
81              "portlet.xml", srcFile + "/WEB-INF", filterMap);
82      }
83  
84  }