/********************************************************************** Copyright (c) 2000, 2002 IBM Corp. and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html Klaus Hartlage - www.eclipseproject.de **********************************************************************/ package net.sourceforge.phpeclipse.actions; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import net.sourceforge.phpdt.internal.compiler.parser.Scanner; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import net.sourceforge.phpeclipse.mover.DefaultFilter; import net.sourceforge.phpeclipse.mover.DirectoryWalker; import net.sourceforge.phpeclipse.mover.IFilter; import net.sourceforge.phpeclipse.mover.IMover; import net.sourceforge.phpeclipse.mover.obfuscator.PHPAnalyzer; import net.sourceforge.phpeclipse.mover.obfuscator.PHPIdentifier; import net.sourceforge.phpeclipse.mover.obfuscator.PHPObfuscatorMover; import net.sourceforge.phpeclipse.preferences.IObfuscatorPreferences; import net.sourceforge.phpeclipse.views.PHPConsole; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.action.IAction; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IObjectActionDelegate; import org.eclipse.ui.IWorkbenchPart; public class PHPObfuscatorAction implements IObjectActionDelegate { private static String[] PREDEFINED_PHP_VARIABLES = { "$this", "$AUTH_TYPE", "$CONTENT_LENGTH", "$CONTENT_TYPE", "$GATEWAY_INTERFACE", "$GLOBALS", "$HTTP_ACCEPT", "$HTTP_COOKIE", "$HTTP_COOKIE_VARS", "$HTTP_POST_VARS", "$HTTP_REFERER", "$HTTP_USER_AGENT", "$PATH_INFO", "$PATH_TRANSLATED", "$PHP_AUTH_PW", "$PHP_AUTH_USER", "$PHP_ERRORMSG", "$PHP_SELF", "$QUERY_STRING", "$REMOTE_ADDR", "$REMOTE_HOST", "$REMOTE_IDENT", "$REMOTE_USER", "$REQUEST_METHOD", "$SCRIPT_NAME", "$SERVER_NAME", "$SERVER_PORT", "$SERVER_PROTOCOL", "$SERVER_SOFTWARE" }; private IWorkbenchPart workbenchPart; /** * Constructor for Action1. */ public PHPObfuscatorAction() { super(); } /** * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) */ public void setActivePart(IAction action, IWorkbenchPart targetPart) { workbenchPart = targetPart; } public void run(IAction action) { ISelectionProvider selectionProvider = null; selectionProvider = workbenchPart.getSite().getSelectionProvider(); StructuredSelection selection = null; selection = (StructuredSelection) selectionProvider.getSelection(); PHPConsole console = PHPConsole.getInstance(); IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); Shell shell = null; Iterator iterator = null; iterator = selection.iterator(); while (iterator.hasNext()) { // obj => selected object in the view Object obj = iterator.next(); // is it a resource if (obj instanceof IResource) { IResource resource = (IResource) obj; IProject proj = resource.getProject(); String sourcePath; // String publishPath = "c:\\temp"; String publishPath; try { publishPath = proj.getPersistentProperty(IObfuscatorPreferences.PUBLISH_PROPERTY_NAME); } catch (CoreException e) { return; } HashMap identifierMap = new HashMap(8096); for (int i=0;i