001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.deploy.auto;
016    
017    import com.liferay.portal.kernel.deploy.auto.AutoDeployException;
018    import com.liferay.portal.kernel.plugin.PluginPackage;
019    
020    import java.io.File;
021    
022    import java.util.HashMap;
023    import java.util.Map;
024    
025    /**
026     * @author Jorge Ferrer
027     */
028    public class PHPPortletAutoDeployer extends PortletAutoDeployer {
029    
030            protected PHPPortletAutoDeployer() throws AutoDeployException {
031                    try {
032                            String[] phpJars = new String[] {
033                                    "quercus.jar", "resin-util.jar", "script-10.jar"
034                            };
035    
036                            for (int i = 0; i < phpJars.length; i++) {
037                                    String phpJar = phpJars[i];
038    
039                                    jars.add(downloadJar(phpJar));
040                            }
041    
042                            addRequiredJar(jars, "portals-bridges.jar");
043                    }
044                    catch (Exception e) {
045                            throw new AutoDeployException(e);
046                    }
047            }
048    
049            protected void copyXmls(
050                            File srcFile, String displayName, PluginPackage pluginPackage)
051                    throws Exception {
052    
053                    super.copyXmls(srcFile, displayName, pluginPackage);
054    
055                    Map<String, String> filterMap = new HashMap<String, String>();
056    
057                    String pluginName = displayName;
058    
059                    if (pluginPackage != null) {
060                            pluginName = pluginPackage.getName();
061                    }
062    
063                    filterMap.put(
064                            "portlet_class", "com.liferay.util.bridges.php.PHPPortlet");
065                    filterMap.put("portlet_name", pluginName);
066                    filterMap.put("portlet_title", pluginName);
067                    filterMap.put("restore_current_view", "false");
068                    filterMap.put("friendly_url_mapper_class", "");
069                    filterMap.put("init_param_name_0", "view-uri");
070                    filterMap.put("init_param_value_0", "/index.php");
071                    filterMap.put("init_param_name_1", "add-portlet-params");
072                    filterMap.put("init_param_value_1", "true");
073    
074                    copyDependencyXml(
075                            "liferay-display.xml", srcFile + "/WEB-INF", filterMap);
076                    copyDependencyXml(
077                            "liferay-portlet.xml", srcFile + "/WEB-INF", filterMap);
078                    copyDependencyXml(
079                            "portlet.xml", srcFile + "/WEB-INF", filterMap);
080            }
081    
082    }