001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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("portlet.xml", srcFile + "/WEB-INF", filterMap);
080            }
081    
082    }