001    /**
002     * Copyright (c) 2000-2011 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            public PHPPortletAutoDeployer() throws AutoDeployException {
031                    try {
032                            String[] phpJars = {"resin.jar", "script-10.jar"};
033    
034                            for (int i = 0; i < phpJars.length; i++) {
035                                    String phpJar = phpJars[i];
036    
037                                    jars.add(downloadJar(phpJar));
038                            }
039    
040                            addRequiredJar(jars, "portals-bridges.jar");
041                    }
042                    catch (Exception e) {
043                            throw new AutoDeployException(e);
044                    }
045            }
046    
047            @Override
048            public void copyXmls(
049                            File srcFile, String displayName, PluginPackage pluginPackage)
050                    throws Exception {
051    
052                    super.copyXmls(srcFile, displayName, pluginPackage);
053    
054                    Map<String, String> filterMap = new HashMap<String, String>();
055    
056                    String pluginName = displayName;
057    
058                    if (pluginPackage != null) {
059                            pluginName = pluginPackage.getName();
060                    }
061    
062                    filterMap.put(
063                            "portlet_class", "com.liferay.util.bridges.php.PHPPortlet");
064                    filterMap.put("portlet_name", pluginName);
065                    filterMap.put("portlet_title", pluginName);
066                    filterMap.put("restore_current_view", "false");
067                    filterMap.put("friendly_url_mapper_class", "");
068                    filterMap.put("friendly_url_mapping", "");
069                    filterMap.put("friendly_url_routes", "");
070                    filterMap.put("init_param_name_0", "view-uri");
071                    filterMap.put("init_param_value_0", "/index.php");
072                    filterMap.put("init_param_name_1", "add-portlet-params");
073                    filterMap.put("init_param_value_1", "true");
074    
075                    copyDependencyXml(
076                            "liferay-display.xml", srcFile + "/WEB-INF", filterMap);
077                    copyDependencyXml(
078                            "liferay-portlet.xml", srcFile + "/WEB-INF", filterMap);
079                    copyDependencyXml(
080                            "portlet.xml", srcFile + "/WEB-INF", filterMap);
081            }
082    
083    }