From 4178a6723321cea62b08c403a58ece13f31902fe Mon Sep 17 00:00:00 2001 From: pombredanne Date: Fri, 27 Oct 2006 01:51:36 +0000 Subject: [PATCH] Moved the code in the "tests" plugin (plural) to the "test" fragment (singular). The tests plugin will be used for shared testing utilities. Each plugin will have its own ".test" fragment for junit tests going forward. --- net.sourceforge.phpeclipse.test/.classpath | 7 + net.sourceforge.phpeclipse.test/.project | 28 + .../META-INF/MANIFEST.MF | 14 + net.sourceforge.phpeclipse.test/build.properties | 4 + net.sourceforge.phpeclipse.test/frament.xml | 88 + .../core/tests/util/AbstractCompilerTest.java | 278 +++ .../sourceforge/phpdt/core/tests/util/Util.java | 504 ++++++ .../internal/formatter/CodeFormatterTest.java | 164 ++ .../phpeclipse/example/outline/Import2Console.java | 72 + .../phpeclipse/example/outline/Type2Console.java | 81 + .../php/test/DualParseSyntaxErrorTest.java | 116 ++ .../phpeditor/php/test/DummyDocument.java | 450 +++++ .../php/test/IdentifierIndexManagerTest.java | 54 + .../phpeclipse/tests/parser/OverlibTestCase.java | 469 +++++ .../phpeclipse/tests/parser/PHPManualTestCase.java | 244 +++ .../phpeclipse/tests/parser/PHPParserTestCase.java | 386 ++++ .../tests/parser/PHPParserTestSuite.java | 35 + .../phpeclipse/tests/parser/ShortTagTestCase.java | 28 + .../tests/parser/SmartyCompilerTestCase.java | 1893 ++++++++++++++++++++ net.sourceforge.phpeclipse.test/test.php | 7 + net.sourceforge.phpeclipse.tests/.classpath | 2 +- net.sourceforge.phpeclipse.tests/.project | 1 - .../.settings/org.eclipse.jdt.core.prefs | 7 + net.sourceforge.phpeclipse.tests/.template | 4 - .../META-INF/MANIFEST.MF | 17 +- net.sourceforge.phpeclipse.tests/build.properties | 9 +- net.sourceforge.phpeclipse.tests/plugin.xml | 88 - .../core/tests/util/AbstractCompilerTest.java | 299 --- .../sourceforge/phpdt/core/tests/util/Util.java | 504 ------ .../phpeclipse/example/outline/Import2Console.java | 72 - .../phpeclipse/example/outline/Type2Console.java | 81 - .../php/test/DualParseSyntaxErrorTest.java | 116 -- .../phpeditor/php/test/DummyDocument.java | 450 ----- .../php/test/IdentifierIndexManagerTest.java | 54 - .../phpeditor/php/test/PHPFormatterTest.java | 163 -- .../phpeclipse/tests/parser/OverlibTestCase.java | 469 ----- .../phpeclipse/tests/parser/PHPManualTestCase.java | 244 --- .../phpeclipse/tests/parser/PHPParserTestCase.java | 386 ---- .../tests/parser/PHPParserTestSuite.java | 35 - .../phpeclipse/tests/parser/ShortTagTestCase.java | 28 - .../tests/parser/SmartyCompilerTestCase.java | 1893 -------------------- net.sourceforge.phpeclipse.tests/test.php | 7 - 42 files changed, 4936 insertions(+), 4915 deletions(-) create mode 100644 net.sourceforge.phpeclipse.test/.classpath create mode 100644 net.sourceforge.phpeclipse.test/.project create mode 100644 net.sourceforge.phpeclipse.test/META-INF/MANIFEST.MF create mode 100644 net.sourceforge.phpeclipse.test/build.properties create mode 100644 net.sourceforge.phpeclipse.test/frament.xml create mode 100644 net.sourceforge.phpeclipse.test/src/net/sourceforge/phpdt/core/tests/util/AbstractCompilerTest.java create mode 100644 net.sourceforge.phpeclipse.test/src/net/sourceforge/phpdt/core/tests/util/Util.java create mode 100644 net.sourceforge.phpeclipse.test/src/net/sourceforge/phpdt/internal/formatter/CodeFormatterTest.java create mode 100644 net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/example/outline/Import2Console.java create mode 100644 net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/example/outline/Type2Console.java create mode 100644 net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/phpeditor/php/test/DualParseSyntaxErrorTest.java create mode 100644 net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/phpeditor/php/test/DummyDocument.java create mode 100644 net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/phpeditor/php/test/IdentifierIndexManagerTest.java create mode 100644 net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/OverlibTestCase.java create mode 100644 net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/PHPManualTestCase.java create mode 100644 net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/PHPParserTestCase.java create mode 100644 net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/PHPParserTestSuite.java create mode 100644 net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/ShortTagTestCase.java create mode 100644 net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/SmartyCompilerTestCase.java create mode 100644 net.sourceforge.phpeclipse.test/test.php create mode 100644 net.sourceforge.phpeclipse.tests/.settings/org.eclipse.jdt.core.prefs delete mode 100644 net.sourceforge.phpeclipse.tests/.template delete mode 100644 net.sourceforge.phpeclipse.tests/plugin.xml delete mode 100644 net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpdt/core/tests/util/AbstractCompilerTest.java delete mode 100644 net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpdt/core/tests/util/Util.java delete mode 100644 net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/example/outline/Import2Console.java delete mode 100644 net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/example/outline/Type2Console.java delete mode 100644 net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/DualParseSyntaxErrorTest.java delete mode 100644 net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/DummyDocument.java delete mode 100644 net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/IdentifierIndexManagerTest.java delete mode 100644 net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/PHPFormatterTest.java delete mode 100644 net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/OverlibTestCase.java delete mode 100644 net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/PHPManualTestCase.java delete mode 100644 net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/PHPParserTestCase.java delete mode 100644 net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/PHPParserTestSuite.java delete mode 100644 net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/ShortTagTestCase.java delete mode 100644 net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/SmartyCompilerTestCase.java delete mode 100644 net.sourceforge.phpeclipse.tests/test.php diff --git a/net.sourceforge.phpeclipse.test/.classpath b/net.sourceforge.phpeclipse.test/.classpath new file mode 100644 index 0000000..751c8f2 --- /dev/null +++ b/net.sourceforge.phpeclipse.test/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/net.sourceforge.phpeclipse.test/.project b/net.sourceforge.phpeclipse.test/.project new file mode 100644 index 0000000..d154713 --- /dev/null +++ b/net.sourceforge.phpeclipse.test/.project @@ -0,0 +1,28 @@ + + + net.sourceforge.phpeclipse.test + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/net.sourceforge.phpeclipse.test/META-INF/MANIFEST.MF b/net.sourceforge.phpeclipse.test/META-INF/MANIFEST.MF new file mode 100644 index 0000000..483bf3a --- /dev/null +++ b/net.sourceforge.phpeclipse.test/META-INF/MANIFEST.MF @@ -0,0 +1,14 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Test Fragment +Bundle-SymbolicName: net.sourceforge.phpeclipse.test +Bundle-Version: 1.0.0 +Bundle-Vendor: PHPEclipse team +Fragment-Host: net.sourceforge.phpeclipse;bundle-version="1.0.0" +Bundle-Localization: plugin +Require-Bundle: org.eclipse.core.runtime.compatibility, + org.eclipse.ui, + org.junit, + org.eclipse.jface.text, + org.eclipse.core.resources +Bundle-RequiredExecutionEnvironment: J2SE-1.4 diff --git a/net.sourceforge.phpeclipse.test/build.properties b/net.sourceforge.phpeclipse.test/build.properties new file mode 100644 index 0000000..34d2e4d --- /dev/null +++ b/net.sourceforge.phpeclipse.test/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/net.sourceforge.phpeclipse.test/frament.xml b/net.sourceforge.phpeclipse.test/frament.xml new file mode 100644 index 0000000..e87d50b --- /dev/null +++ b/net.sourceforge.phpeclipse.test/frament.xml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpdt/core/tests/util/AbstractCompilerTest.java b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpdt/core/tests/util/AbstractCompilerTest.java new file mode 100644 index 0000000..3c77d24 --- /dev/null +++ b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpdt/core/tests/util/AbstractCompilerTest.java @@ -0,0 +1,278 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation 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 + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package net.sourceforge.phpdt.core.tests.util; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Locale; +import java.util.Map; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; +import net.sourceforge.phpdt.core.compiler.IProblem; +import net.sourceforge.phpdt.internal.compiler.CompilationResult; +import net.sourceforge.phpdt.internal.compiler.DefaultErrorHandlingPolicies; +import net.sourceforge.phpdt.internal.compiler.batch.CompilationUnit; +import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit; +import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions; +import net.sourceforge.phpdt.internal.compiler.parser.Scanner; +import net.sourceforge.phpdt.internal.compiler.parser.UnitParser; +import net.sourceforge.phpdt.internal.compiler.problem.DefaultProblem; +import net.sourceforge.phpdt.internal.compiler.problem.DefaultProblemFactory; +import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter; + +public class AbstractCompilerTest extends TestCase { + + protected String complianceLevel; + + public void checkParsePHP(char[] source, String expectedSyntaxErrorDiagnosis) { + // String testName) { + + UnitParser parser = new UnitParser(new ProblemReporter( + DefaultErrorHandlingPolicies.proceedWithAllProblems(), + new CompilerOptions(getCompilerOptions()), + new DefaultProblemFactory(Locale.getDefault()))); + + ICompilationUnit sourceUnit = new CompilationUnit(source, "", null); + CompilationResult compilationResult = new CompilationResult(sourceUnit, + 0, 0, 0); + + parser.dietParse(sourceUnit, compilationResult, true); + StringBuffer buffer = new StringBuffer(100); + if (compilationResult.hasProblems() || compilationResult.hasTasks()) { + IProblem[] problems = compilationResult.getAllProblems(); + int count = problems.length; + int problemCount = 0; + char[] unitSource = compilationResult.compilationUnit.getContents(); + for (int i = 0; i < count; i++) { + if (problems[i] != null) { + if (problemCount == 0) + buffer.append("----------\n"); + problemCount++; + buffer + .append(problemCount + + (problems[i].isError() ? ". ERROR" + : ". WARNING")); + buffer.append(" in " + + new String(problems[i].getOriginatingFileName()) + .replace('/', '\\')); + try { + buffer.append(((DefaultProblem) problems[i]) + .errorReportSource(unitSource)); + buffer.append("\n"); + buffer.append(problems[i].getMessage()); + buffer.append("\n"); + } catch (Exception e) { + StringWriter stringWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(stringWriter)); + buffer.append(stringWriter.getBuffer()); + } + buffer.append("----------\n"); + } + } + } + String computedSyntaxErrorDiagnosis = buffer.toString(); + if (!expectedSyntaxErrorDiagnosis.equals(computedSyntaxErrorDiagnosis)) { + System.out + .println(Util.displayString(computedSyntaxErrorDiagnosis)); + } + assertEquals("Invalid syntax error diagnosis", + expectedSyntaxErrorDiagnosis, computedSyntaxErrorDiagnosis); + } + + public void checkParseHTML(char[] source, + String expectedSyntaxErrorDiagnosis) { + // String testName) { + + UnitParser parser = new UnitParser(new ProblemReporter( + DefaultErrorHandlingPolicies.proceedWithAllProblems(), + new CompilerOptions(getCompilerOptions()), + new DefaultProblemFactory(Locale.getDefault()))); + + ICompilationUnit sourceUnit = new CompilationUnit(source, "", null); + CompilationResult compilationResult = new CompilationResult(sourceUnit, + 0, 0, 0); + + parser.dietParse(sourceUnit, compilationResult, false); + + StringBuffer buffer = new StringBuffer(100); + if (compilationResult.hasProblems() || compilationResult.hasTasks()) { + IProblem[] problems = compilationResult.getAllProblems(); + int count = problems.length; + int problemCount = 0; + char[] unitSource = compilationResult.compilationUnit.getContents(); + for (int i = 0; i < count; i++) { + if (problems[i] != null) { + if (problemCount == 0) + buffer.append("----------\n"); + problemCount++; + buffer + .append(problemCount + + (problems[i].isError() ? ". ERROR" + : ". WARNING")); + buffer.append(" in " + + new String(problems[i].getOriginatingFileName()) + .replace('/', '\\')); + try { + buffer.append(((DefaultProblem) problems[i]) + .errorReportSource(unitSource)); + buffer.append("\n"); + buffer.append(problems[i].getMessage()); + buffer.append("\n"); + } catch (Exception e) { + StringWriter stringWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(stringWriter)); + buffer.append(stringWriter.getBuffer()); + } + buffer.append("----------\n"); + } + } + } + String computedSyntaxErrorDiagnosis = buffer.toString(); + if (!expectedSyntaxErrorDiagnosis.equals(computedSyntaxErrorDiagnosis)) { + System.out + .println(Util.displayString(computedSyntaxErrorDiagnosis)); + } + assertEquals("Invalid syntax error diagnosis", + expectedSyntaxErrorDiagnosis, computedSyntaxErrorDiagnosis); + } + + /* + * Returns the possible compliance levels this VM instance can run. + */ + // public static int getPossibleComplianceLevels() { + // if (possibleComplianceLevels == -1) { + // String compliance = System.getProperty("compliance"); + // if (compliance != null) { + // if (COMPLIANCE_1_3.equals(compliance)) { + // possibleComplianceLevels = F_1_3; + // } else if (COMPLIANCE_1_4.equals(compliance)) { + // possibleComplianceLevels = F_1_4; + // } else if (COMPLIANCE_1_5.equals(compliance)) { + // possibleComplianceLevels = F_1_5; + // } else { + // System.out.println("Invalid compliance specified (" + compliance + ")"); + // System.out.println("Use one of " + COMPLIANCE_1_3 + ", " + COMPLIANCE_1_4 + // + ", " + COMPLIANCE_1_5); + // System.out.println("Defaulting to all possible compliances"); + // } + // } + // if (possibleComplianceLevels == -1) { + // possibleComplianceLevels = F_1_3; + // String specVersion = System.getProperty("java.specification.version"); + // boolean canRun1_4 = !"1.0".equals(specVersion) && + // !"1.1".equals(specVersion) && !"1.2".equals(specVersion) && + // !"1.3".equals(specVersion); + // if (canRun1_4) { + // possibleComplianceLevels |= F_1_4; + // } + // boolean canRun1_5 = canRun1_4 && !"1.4".equals(specVersion); + // if (canRun1_5) { + // possibleComplianceLevels |= F_1_5; + // } + // } + // } + // return possibleComplianceLevels; + // } + /* + * Returns a test suite including the tests defined by the given classes for + * the given complianceLevel (see AbstractCompilerTest for valid values) and + * using the given setup class (CompilerTestSetup or a subclass) + */ + public static Test suiteForComplianceLevel(String complianceLevel, + Class setupClass, ArrayList testClasses) { + TestSuite suite; + if (testClasses.size() == 1) { + suite = new TestSuite((Class) testClasses.get(0), complianceLevel); + } else { + suite = new TestSuite(complianceLevel); + for (int i = 0, length = testClasses.size(); i < length; i++) { + Class testClass = (Class) testClasses.get(i); + TestSuite innerSuite = new TestSuite(testClass); + suite.addTest(innerSuite); + } + } + + // call the setup constructor with the suite and compliance level + try { + Constructor constructor = setupClass.getConstructor(new Class[] { + Test.class, String.class }); + Test setUp = (Test) constructor.newInstance(new Object[] { suite, + complianceLevel }); + return setUp; + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.getTargetException().printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + + return null; + } + + public AbstractCompilerTest(String name) { + super(name); + } + + protected Map getCompilerOptions() { + Map options = new CompilerOptions().getMap(); + // ignore warnings + options.put(CompilerOptions.OPTION_PHPVarDeprecatedWarning, + CompilerOptions.IGNORE); + options.put(CompilerOptions.OPTION_PHPBadStyleKeywordWarning, + CompilerOptions.IGNORE); + options.put( + CompilerOptions.OPTION_PHPBadStyleUppercaseIdentifierWarning, + CompilerOptions.IGNORE); + options.put(CompilerOptions.OPTION_PHPIncludeNotExistWarning, + CompilerOptions.IGNORE); + options.put(CompilerOptions.OPTION_UninitializedLocalVariableWarning, + CompilerOptions.IGNORE); + options.put(CompilerOptions.OPTION_CodeCannotBeReachedWarning, + CompilerOptions.IGNORE); + return options; + } + + public String getName() { + String name = super.getName(); + if (this.complianceLevel != null) { + name = this.complianceLevel + " - " + name; + } + return name; + } + + protected void checkPHP(String strEval) { + checkPHP(strEval, ""); + } + + protected void checkPHP(String strEval, String expectedSyntaxErrorDiagnosis) { + if (Scanner.DEBUG) { + System.out.println("\n------------------------------------"); + System.out.println(strEval); + } + checkParsePHP(strEval.toCharArray(), expectedSyntaxErrorDiagnosis); + } + + protected void checkHTML(String strEval) { + if (Scanner.DEBUG) { + System.out.println("\n------------------------------------"); + System.out.println(strEval); + } + checkParseHTML(strEval.toCharArray(), ""); + } +} diff --git a/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpdt/core/tests/util/Util.java b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpdt/core/tests/util/Util.java new file mode 100644 index 0000000..5316029 --- /dev/null +++ b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpdt/core/tests/util/Util.java @@ -0,0 +1,504 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation 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 + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package net.sourceforge.phpdt.core.tests.util; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintWriter; +import java.net.ServerSocket; + +import net.sourceforge.phpdt.internal.compiler.batch.CompilationUnit; + +public class Util { + public static String OUTPUT_DIRECTORY = "comptest"; + + public static CompilationUnit[] compilationUnits(String[] testFiles) { + int length = testFiles.length / 2; + CompilationUnit[] result = new CompilationUnit[length]; + int index = 0; + for (int i = 0; i < length; i++) { + result[i] = new CompilationUnit(testFiles[index + 1].toCharArray(), + testFiles[index], null); + index += 2; + } + return result; + } + + public static String[] concatWithClassLibs(String classpath, boolean inFront) { + String[] classLibs = getJavaClassLibs(); + final int length = classLibs.length; + String[] defaultClassPaths = new String[length + 1]; + if (inFront) { + System.arraycopy(classLibs, 0, defaultClassPaths, 1, length); + defaultClassPaths[0] = classpath; + } else { + System.arraycopy(classLibs, 0, defaultClassPaths, 0, length); + defaultClassPaths[length] = classpath; + } + return defaultClassPaths; + } + + public static String convertToIndependantLineDelimiter(String source) { + StringBuffer buffer = new StringBuffer(); + for (int i = 0, length = source.length(); i < length; i++) { + char car = source.charAt(i); + if (car == '\r') { + buffer.append('\n'); + if (i < length - 1 && source.charAt(i + 1) == '\n') { + i++; // skip \n after \r + } + } else { + buffer.append(car); + } + } + return buffer.toString(); + } + + /** + * Copy the given source (a file or a directory that must exists) to the + * given destination (a directory that must exists). + */ + public static void copy(String sourcePath, String destPath) { + sourcePath = toNativePath(sourcePath); + destPath = toNativePath(destPath); + File source = new File(sourcePath); + if (!source.exists()) + return; + File dest = new File(destPath); + if (!dest.exists()) + return; + if (source.isDirectory()) { + String[] files = source.list(); + if (files != null) { + for (int i = 0; i < files.length; i++) { + String file = files[i]; + File sourceFile = new File(source, file); + if (sourceFile.isDirectory()) { + File destSubDir = new File(dest, file); + destSubDir.mkdir(); + copy(sourceFile.getPath(), destSubDir.getPath()); + } else { + copy(sourceFile.getPath(), dest.getPath()); + } + } + } + } else { + FileInputStream in = null; + FileOutputStream out = null; + try { + in = new FileInputStream(source); + File destFile = new File(dest, source.getName()); + if (destFile.exists() && !destFile.delete()) { + throw new IOException(destFile + " is in use"); + } + out = new FileOutputStream(destFile); + int bufferLength = 1024; + byte[] buffer = new byte[bufferLength]; + int read = 0; + while (read != -1) { + read = in.read(buffer, 0, bufferLength); + if (read != -1) { + out.write(buffer, 0, read); + } + } + } catch (IOException e) { + throw new Error(e.toString()); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + } + } + if (out != null) { + try { + out.close(); + } catch (IOException e) { + } + } + } + } + } + + // public static void createJar(String[] pathsAndContents, Map options, + // String + // jarPath) throws IOException { + // String classesPath = getOutputDirectory() + File.separator + "classes"; + // File classesDir = new File(classesPath); + // flushDirectoryContent(classesDir); + // compile(pathsAndContents, options, classesPath); + // zip(classesDir, jarPath); + // } + /** + * Generate a display string from the given String. + * + * @param indent + * number of tabs are added at the begining of each line. + * + * Example of use: + * [org.eclipse.jdt.core.tests.util.Util.displayString("abc\ndef\tghi")] + */ + public static String displayString(String inputString) { + return displayString(inputString, 0); + } + + /** + * Generate a display string from the given String. It converts: + * + * This method doesn't convert \r\n to \n. + *

+ * Example of use: + *

  • + * + *
    +	 *   input string = "abc\ndef\tghi",
    +	 *   indent = 3
    +	 *   result = "\"\t\t\tabc\\n" +
    +	 *   			"\t\t\tdef\tghi\""
    +	 * 
    + * + *
  • + *
  • + * + *
    +	 *   input string = "abc\ndef\tghi\n",
    +	 *   indent = 3
    +	 *   result = "\"\t\t\tabc\\n" +
    +	 *   			"\t\t\tdef\tghi\\n\""
    +	 * 
    + * + *
  • + *
  • + * + *
    +	 *   input string = "abc\r\ndef\tghi\r\n",
    +	 *   indent = 3
    +	 *   result = "\"\t\t\tabc\\r\\n" +
    +	 *   			"\t\t\tdef\tghi\\r\\n\""
    +	 * 
    + * + *
  • + * + *

    + * + * @param inputString + * the given input string + * @param indent + * number of tabs are added at the begining of each line. + * + * @return the displayed string + */ + public static String displayString(String inputString, int indent) { + int length = inputString.length(); + StringBuffer buffer = new StringBuffer(length); + java.util.StringTokenizer tokenizer = new java.util.StringTokenizer( + inputString, "\n\r", true); + for (int i = 0; i < indent; i++) + buffer.append("\t"); + buffer.append("\""); + while (tokenizer.hasMoreTokens()) { + + String token = tokenizer.nextToken(); + if (token.equals("\r")) { + buffer.append("\\r"); + if (tokenizer.hasMoreTokens()) { + token = tokenizer.nextToken(); + if (token.equals("\n")) { + buffer.append("\\n"); + if (tokenizer.hasMoreTokens()) { + buffer.append("\" + \n"); + for (int i = 0; i < indent; i++) + buffer.append("\t"); + buffer.append("\""); + } + continue; + } else { + buffer.append("\" + \n"); + for (int i = 0; i < indent; i++) + buffer.append("\t"); + buffer.append("\""); + } + } else { + continue; + } + } else if (token.equals("\n")) { + buffer.append("\\n"); + if (tokenizer.hasMoreTokens()) { + buffer.append("\" + \n"); + for (int i = 0; i < indent; i++) + buffer.append("\t"); + buffer.append("\""); + } + continue; + } + + StringBuffer tokenBuffer = new StringBuffer(); + for (int i = 0; i < token.length(); i++) { + char c = token.charAt(i); + switch (c) { + case '\r': + tokenBuffer.append("\\r"); + break; + case '\n': + tokenBuffer.append("\\n"); + break; + case '\b': + tokenBuffer.append("\\b"); + break; + case '\t': + tokenBuffer.append("\t"); + break; + case '\f': + tokenBuffer.append("\\f"); + break; + case '\"': + tokenBuffer.append("\\\""); + break; + case '\'': + tokenBuffer.append("\\'"); + break; + case '\\': + tokenBuffer.append("\\\\"); + break; + default: + tokenBuffer.append(c); + } + } + buffer.append(tokenBuffer.toString()); + } + buffer.append("\""); + return buffer.toString(); + } + + /** + * Reads the content of the given source file and converts it to a display + * string. + * + * Example of use: + * [org.eclipse.jdt.core.tests.util.Util.fileContentToDisplayString("c:/temp/X.java", + * 0)] + */ + public static String fileContentToDisplayString(String sourceFilePath, + int indent, boolean independantLineDelimiter) { + File sourceFile = new File(sourceFilePath); + if (!sourceFile.exists()) { + System.out.println("File " + sourceFilePath + " does not exists."); + return null; + } + if (!sourceFile.isFile()) { + System.out.println(sourceFilePath + " is not a file."); + return null; + } + StringBuffer sourceContentBuffer = new StringBuffer(); + FileInputStream input = null; + try { + input = new FileInputStream(sourceFile); + } catch (FileNotFoundException e) { + return null; + } + try { + int read; + do { + read = input.read(); + if (read != -1) { + sourceContentBuffer.append((char) read); + } + } while (read != -1); + input.close(); + } catch (IOException e) { + e.printStackTrace(); + return null; + } finally { + try { + input.close(); + } catch (IOException e2) { + } + } + String sourceString = sourceContentBuffer.toString(); + if (independantLineDelimiter) { + sourceString = convertToIndependantLineDelimiter(sourceString); + } + return displayString(sourceString, indent); + } + + /** + * Reads the content of the given source file, converts it to a display + * string. If the destination file path is not null, writes the result to + * this file. Otherwise writes it to the console. + * + * Example of use: + * [org.eclipse.jdt.core.tests.util.Util.fileContentToDisplayString("c:/temp/X.java", + * 0, null)] + */ + public static void fileContentToDisplayString(String sourceFilePath, + int indent, String destinationFilePath, + boolean independantLineDelimiter) { + String displayString = fileContentToDisplayString(sourceFilePath, + indent, independantLineDelimiter); + if (destinationFilePath == null) { + System.out.println(displayString); + return; + } + writeToFile(displayString, destinationFilePath); + } + + /** + * Flush content of a given directory (leaving it empty), no-op if not a + * directory. + */ + public static void flushDirectoryContent(File dir) { + if (dir.isDirectory()) { + String[] files = dir.list(); + if (files == null) + return; + for (int i = 0, max = files.length; i < max; i++) { + File current = new File(dir, files[i]); + if (current.isDirectory()) { + flushDirectoryContent(current); + } + current.delete(); + } + } + } + + /** + * Search the user hard-drive for a Java class library. Returns null if none + * could be found. + * + * Example of use: [org.eclipse.jdt.core.tests.util.Util.getJavaClassLib()] + */ + public static String[] getJavaClassLibs() { + String jreDir = getJREDirectory(); + if (jreDir == null) { + return new String[] {}; + } else { + final String vmName = System.getProperty("java.vm.name"); + if ("J9".equals(vmName)) { + return new String[] { toNativePath(jreDir + + "/lib/jclMax/classes.zip") }; + } else { + File file = new File(jreDir + "/lib/rt.jar"); + if (file.exists()) { + return new String[] { toNativePath(jreDir + "/lib/rt.jar") }; + } else { + return new String[] { + toNativePath(jreDir + "/lib/core.jar"), + toNativePath(jreDir + "/lib/security.jar"), + toNativePath(jreDir + "/lib/graphics.jar") }; + } + } + } + } + + public static String getJavaClassLibsAsString() { + String[] classLibs = getJavaClassLibs(); + StringBuffer buffer = new StringBuffer(); + for (int i = 0, max = classLibs.length; i < max; i++) { + buffer.append(classLibs[i]).append(File.pathSeparatorChar); + + } + return buffer.toString(); + } + + /** + * Returns the JRE directory this tests are running on. Returns null if none + * could be found. + * + * Example of use: [org.eclipse.jdt.core.tests.util.Util.getJREDirectory()] + */ + public static String getJREDirectory() { + return System.getProperty("java.home"); + } + + /** + * Search the user hard-drive for a possible output directory. Returns null + * if none could be found. + * + * Example of use: + * [org.eclipse.jdt.core.tests.util.Util.getOutputDirectory()] + */ + public static String getOutputDirectory() { + String container = System.getProperty("user.home"); + if (container == null) { + return null; + } else { + return toNativePath(container) + File.separator + OUTPUT_DIRECTORY; + } + } + + /** + * Returns the next available port number on the local host. + */ + public static int getFreePort() { + ServerSocket socket = null; + try { + socket = new ServerSocket(0); + return socket.getLocalPort(); + } catch (IOException e) { + // ignore + } finally { + if (socket != null) { + try { + socket.close(); + } catch (IOException e) { + // ignore + } + } + } + return -1; + } + + /** + * Makes the given path a path using native path separators as returned by + * File.getPath() and trimming any extra slash. + */ + public static String toNativePath(String path) { + String nativePath = path.replace('\\', File.separatorChar).replace('/', + File.separatorChar); + return nativePath.endsWith("/") || nativePath.endsWith("\\") ? nativePath + .substring(0, nativePath.length() - 1) + : nativePath; + } + + public static void writeToFile(String contents, String destinationFilePath) { + File destFile = new File(destinationFilePath); + FileOutputStream output = null; + try { + output = new FileOutputStream(destFile); + PrintWriter writer = new PrintWriter(output); + writer.print(contents); + writer.flush(); + } catch (IOException e) { + e.printStackTrace(); + return; + } finally { + if (output != null) { + try { + output.close(); + } catch (IOException e2) { + } + } + } + } +} diff --git a/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpdt/internal/formatter/CodeFormatterTest.java b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpdt/internal/formatter/CodeFormatterTest.java new file mode 100644 index 0000000..d3befec --- /dev/null +++ b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpdt/internal/formatter/CodeFormatterTest.java @@ -0,0 +1,164 @@ +/* + * Created on 28.04.2003 + * + */ +package net.sourceforge.phpdt.internal.formatter; + +import java.util.Map; + +import junit.framework.TestCase; +import net.sourceforge.phpdt.core.JavaCore; +import net.sourceforge.phpdt.internal.corext.codemanipulation.StubUtility; +import net.sourceforge.phpdt.internal.corext.util.Strings; +import net.sourceforge.phpdt.internal.formatter.CodeFormatter; +import net.sourceforge.phpdt.internal.ui.preferences.CodeFormatterPreferencePage; +import net.sourceforge.phpeclipse.phpeditor.php.test.DummyDocument; + +import org.eclipse.jface.text.IDocument; + +/** + * Testcase for the PHP CodeFormatter + * + * @author Stefan Langer + * @version $Revision: 1.7 $ + */ +public class CodeFormatterTest extends TestCase { + private CodeFormatter fFormatter; + + private IDocument fDocument; + + private String fInitialIndentation; + + /* + * (non-Javadoc) + * + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() throws Exception { + Map options = JavaCore.getOptions(); + fFormatter = new CodeFormatter(options); + fDocument = new DummyDocument(); + } + + public void testFormatter0() { + System.out.println("----- testFormatter0 -----"); + String text = ""; + fDocument.set(text); + String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument); + int indent = 0; + if (fInitialIndentation != null) { + indent = Strings.computeIndent(fInitialIndentation, + CodeFormatterPreferencePage.getTabSize()); + } + String formatedString = fFormatter.format(text, indent, null, + lineDelimiter); + String testResult = ""; + junit.framework.Assert.assertEquals(formatedString, testResult); + } + + public void testFormatter1() { + System.out.println("----- testFormatter1 -----"); + String text = ""; + fDocument.set(text); + String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument); + int indent = 0; + if (fInitialIndentation != null) { + indent = Strings.computeIndent(fInitialIndentation, + CodeFormatterPreferencePage.getTabSize()); + } + String formatedString = fFormatter.format(text, indent, null, + lineDelimiter); + String testResult = ""; + junit.framework.Assert.assertEquals(formatedString, testResult); + } + + public void testFormatter2() { + // bug 741752 + System.out.println("----- testFormatter2 -----"); + String text = ""; + fDocument.set(text); + String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument); + int indent = 0; + if (fInitialIndentation != null) { + indent = Strings.computeIndent(fInitialIndentation, + CodeFormatterPreferencePage.getTabSize()); + } + String formatedString = fFormatter.format(text, indent, null, + lineDelimiter); + String testResult = ""; + junit.framework.Assert.assertEquals(formatedString, testResult); + } + + public void testFormatter3() { + System.out.println("----- testFormatter1 -----"); + String text = ""; + fDocument.set(text); + String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument); + int indent = 0; + if (fInitialIndentation != null) { + indent = Strings.computeIndent(fInitialIndentation, + CodeFormatterPreferencePage.getTabSize()); + } + String formatedString = fFormatter.format(text, indent, null, + lineDelimiter); + String testResult = ""; + junit.framework.Assert.assertEquals(formatedString, testResult); + } + + public void testArrayFormatting() throws Exception { + System.out.println("-----testArrayFormatting-----"); + String text = " 'ok','snd' => 'right','3th' => 'super');\n" + + "?>"; + fDocument.set(text); + String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument); + int indent = 0; + if (fInitialIndentation != null) { + indent = Strings.computeIndent(fInitialIndentation, + CodeFormatterPreferencePage.getTabSize()); + } + String formatedString = fFormatter.format(text, indent, null, + lineDelimiter); + String testResult = " 'ok'," + lineDelimiter + + "\t'snd' => 'right'," + lineDelimiter + "\t'3th' => 'super'" + + lineDelimiter + ");" + lineDelimiter + "?>"; + junit.framework.Assert.assertEquals(formatedString, testResult); + } + + public void testDoubleArrayFormatting() throws Exception { + System.out.println("-----testDoubleArrayFormatting-----"); + String text = " 'ok', 'snd' => array ('1' => '11','2' => '22'),'3th' => 'super');\n" + + "?>"; + fDocument.set(text); + String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument); + int indent = 0; + if (fInitialIndentation != null) { + indent = Strings.computeIndent(fInitialIndentation, + CodeFormatterPreferencePage.getTabSize()); + } + String formatedString = fFormatter.format(text, indent, null, + lineDelimiter); + String testResult = " 'ok'," + lineDelimiter + + "\t'snd' => array (" + lineDelimiter + "\t\t'1' => '11'," + + lineDelimiter + "\t\t'2' => '22'" + lineDelimiter + "\t)," + + lineDelimiter + "\t'3th' => 'super'" + lineDelimiter + ");" + + lineDelimiter + "?>"; + junit.framework.Assert.assertEquals(formatedString, testResult); + } + +} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/example/outline/Import2Console.java b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/example/outline/Import2Console.java new file mode 100644 index 0000000..ac1a01b --- /dev/null +++ b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/example/outline/Import2Console.java @@ -0,0 +1,72 @@ +package net.sourceforge.phpeclipse.example.outline; + +import net.sourceforge.phpdt.core.IImportDeclaration; + +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IActionDelegate; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchPartSite; + +public class Import2Console implements IObjectActionDelegate { + + private IWorkbenchPartSite myPartSite = null; + + private IWorkspace myWorkspace = null; + + private IWorkbenchPart myWorkbenchPart = null; + + private IImportDeclaration myType = null; + + public Import2Console() { + // this(new PackageSelector()); + } + + // public CreateMock(IPackageSelector aPackageSelector) { + // myPackageSelector = aPackageSelector; + // } + + /** + * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) + */ + public void setActivePart(IAction action, IWorkbenchPart targetPart) { + myWorkspace = ResourcesPlugin.getWorkspace(); + myWorkbenchPart = targetPart; + } + + /** + * @see IActionDelegate#run(IAction) + */ + public void run(IAction action) { + try { + String actionId = action.getId(); + showSourceInConsole(actionId); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * @see IActionDelegate#selectionChanged(IAction, ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + if (selection instanceof IStructuredSelection) { + Object item = ((IStructuredSelection) selection).getFirstElement(); + myType = (IImportDeclaration) item; // this plugin only reacts to + // IImportDeclaration's + } + } + + private void showSourceInConsole(String actionId) throws Exception { + + String src = myType.getSource(); + System.out.println(actionId); + System.out.println("Source :" + src); + + } + +} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/example/outline/Type2Console.java b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/example/outline/Type2Console.java new file mode 100644 index 0000000..e310315 --- /dev/null +++ b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/example/outline/Type2Console.java @@ -0,0 +1,81 @@ +package net.sourceforge.phpeclipse.example.outline; + +import net.sourceforge.phpdt.core.IMethod; +import net.sourceforge.phpdt.core.IType; + +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IActionDelegate; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchPartSite; + +public class Type2Console implements IObjectActionDelegate { + private IWorkbenchPartSite myPartSite = null; + + private IWorkspace myWorkspace = null; + + private IWorkbenchPart myWorkbenchPart = null; + + private IType myType = null; + + private Shell myShell = new Shell(); // TBReplaced with getShell() + + public Type2Console() { + } + + /** + * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) + */ + public void setActivePart(IAction action, IWorkbenchPart targetPart) { + myWorkspace = ResourcesPlugin.getWorkspace(); + myWorkbenchPart = targetPart; + } + + /** + * @see IActionDelegate#run(IAction) + */ + public void run(IAction action) { + try { + + String actionId = action.getId(); + showSourceInConsole(actionId); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * @see IActionDelegate#selectionChanged(IAction, ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + if (selection instanceof IStructuredSelection) { + Object item = ((IStructuredSelection) selection).getFirstElement(); + myType = (IType) item; // this plugin only reacts to + // "org.eclipse.jdt.core.IType" objects + } + } + + private void showSourceInConsole(String actionId) throws Exception { + System.out.println(actionId); + if (!(myType.isInterface() || myType.isClass())) { + throw new Exception("incompatible Type"); + } + + IMethod[] methods = myType.getMethods(); + + String fqname = myType.getFullyQualifiedName(); // a.b.c.d.MyClass + System.out.println(fqname + '\n'); + for (int i = 0; i < methods.length; i++) { + System.out.println("Method " + i + ":" + + methods[i].getElementName()); + } + + } + +} diff --git a/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/phpeditor/php/test/DualParseSyntaxErrorTest.java b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/phpeditor/php/test/DualParseSyntaxErrorTest.java new file mode 100644 index 0000000..15b4590 --- /dev/null +++ b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/phpeditor/php/test/DualParseSyntaxErrorTest.java @@ -0,0 +1,116 @@ +/* + * Created on 29.02.2004 + * + * To change the template for this generated file go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +package net.sourceforge.phpeclipse.phpeditor.php.test; + +import net.sourceforge.phpdt.core.tests.util.AbstractCompilerTest; + +public class DualParseSyntaxErrorTest extends AbstractCompilerTest { + public static boolean optimizeStringLiterals = false; + + public DualParseSyntaxErrorTest(String testName) { + super(testName); + } + + public void test01() { + String s = "$login =1; " + "final class test {\n" + "\n" + + "private function f1() {\n" + "\n" + "}\n" + + "public function f2() {\n" + "\n" + " \n" + "} \n" + "}"; + + String expectedSyntaxErrorDiagnosis = ""; + + String testName = ""; + checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis); + // testName); + } + + public void test02() { + String s = "class test { \n" + " function f0() \n" + + " { \n" + " } \n" + + "} \n"; + + String expectedSyntaxErrorDiagnosis = ""; + + String testName = ""; + checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis); + // testName); + } + + public void test03() { + String s = "$chars = ( isset($HTTP_GET_VARS['chars']) ) ? intval($HTTP_GET_VARS['chars']) : 200;"; + String expectedSyntaxErrorDiagnosis = ""; + + checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis); + // testName); + } + + public void test96() { + String s = "$str = <<foo = 'Foo';\n" + + " $this->bar = array('Bar1', 'Bar2', 'Bar3');\n" + + " }\n" + "}\n" + "\n" + "$foo = new foo();\n" + + "$name = 'MyName';\n" + "\n" + "echo <<foo.\n" + + "Now, I am printing some {$foo->bar[1]}.\n" + + "This should print a capital 'A': \\x41\n" + "EOT;\n"; + String expectedSyntaxErrorDiagnosis = ""; + + checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis); + // testName); + } + + public void test97() { + String s = "class momo { \n" + + " function &fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null) \n" + + " { \n" + " } \n" + + "} \n"; + + String expectedSyntaxErrorDiagnosis = ""; + + checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis); + // testName); + } + + public void test98() { + String s = "return(array());" + + "if(!$result = mysql_query($sql)) return(array());\n"; + + String expectedSyntaxErrorDiagnosis = ""; + + checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis); + // testName); + } + + public void test99() { + String s = "class test { \n" + + " murks; \n" + + " function &fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null) \n" + + " { \n" + " } \n" + + "} \n"; + + String expectedSyntaxErrorDiagnosis = "----------\n" + + "1. ERROR in (at line 1)\n" + + " murks; \n" + + " ^^^^^^\n" + + "Parser error \"\'public\' \'private\' or \'protected\' modifier expected for field declarations.\"\n" + + "----------\n" + // + "2. ERROR in (at line 1)\n" + // + " } \n" + // + " ^\n" + // + "Parser error \"Too many closing \'}\'; end-of-file not + // reached.\"\n" + // + "----------\n" + ; + + checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis); + // testName); + } +} diff --git a/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/phpeditor/php/test/DummyDocument.java b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/phpeditor/php/test/DummyDocument.java new file mode 100644 index 0000000..4b17910 --- /dev/null +++ b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/phpeditor/php/test/DummyDocument.java @@ -0,0 +1,450 @@ +/* + * Created on 28.04.2003 + * + */ +package net.sourceforge.phpeclipse.phpeditor.php.test; + +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.BadPositionCategoryException; +import org.eclipse.jface.text.Document; +import org.eclipse.jface.text.IDocumentListener; +import org.eclipse.jface.text.IDocumentPartitioner; +import org.eclipse.jface.text.IDocumentPartitioningListener; +import org.eclipse.jface.text.IPositionUpdater; +import org.eclipse.jface.text.IRegion; +import org.eclipse.jface.text.ITypedRegion; +import org.eclipse.jface.text.Position; + +/** + * Mockobject for Testing. + * + * @author Stefan Langer + * @version $Revision: 1.3 $ + */ +public class DummyDocument extends Document // implements IDocument +{ + private char[] fTextBuffer; + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#getChar(int) + */ + public char getChar(int offset) throws BadLocationException { + if (offset >= 0 && offset < fTextBuffer.length) + return fTextBuffer[offset]; + else + throw new BadLocationException("Offset out of range!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#getLength() + */ + public int getLength() { + return fTextBuffer.length; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#get() + */ + public String get() { + return String.copyValueOf(fTextBuffer); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#get(int, int) + */ + public String get(int offset, int length) throws BadLocationException { + if (offset >= 0 && (offset + length) < fTextBuffer.length) + return String.copyValueOf(fTextBuffer, offset, length); + else + throw new BadLocationException("Out of range!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#set(java.lang.String) + */ + public void set(String text) { + fTextBuffer = text.toCharArray(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#replace(int, int, java.lang.String) + */ + public void replace(int offset, int length, String text) + throws BadLocationException { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#addDocumentListener(org.eclipse.jface.text.IDocumentListener) + */ + public void addDocumentListener(IDocumentListener listener) { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#removeDocumentListener(org.eclipse.jface.text.IDocumentListener) + */ + public void removeDocumentListener(IDocumentListener listener) { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#addPrenotifiedDocumentListener(org.eclipse.jface.text.IDocumentListener) + */ + public void addPrenotifiedDocumentListener(IDocumentListener documentAdapter) { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#removePrenotifiedDocumentListener(org.eclipse.jface.text.IDocumentListener) + */ + public void removePrenotifiedDocumentListener( + IDocumentListener documentAdapter) { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#addPositionCategory(java.lang.String) + */ + // public void addPositionCategory(String category) + // { + // throw new UnsupportedOperationException("Not implemented!"); + // } + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#removePositionCategory(java.lang.String) + */ + public void removePositionCategory(String category) + throws BadPositionCategoryException { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#getPositionCategories() + */ + public String[] getPositionCategories() { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#containsPositionCategory(java.lang.String) + */ + // public boolean containsPositionCategory(String category) + // { + // throw new UnsupportedOperationException("Not implemented!"); + // } + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#addPosition(org.eclipse.jface.text.Position) + */ + public void addPosition(Position position) throws BadLocationException { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#removePosition(org.eclipse.jface.text.Position) + */ + public void removePosition(Position position) { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#addPosition(java.lang.String, + * org.eclipse.jface.text.Position) + */ + public void addPosition(String category, Position position) + throws BadLocationException, BadPositionCategoryException { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#removePosition(java.lang.String, + * org.eclipse.jface.text.Position) + */ + public void removePosition(String category, Position position) + throws BadPositionCategoryException { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#getPositions(java.lang.String) + */ + public Position[] getPositions(String category) + throws BadPositionCategoryException { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#containsPosition(java.lang.String, + * int, int) + */ + public boolean containsPosition(String category, int offset, int length) { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#computeIndexInCategory(java.lang.String, + * int) + */ + public int computeIndexInCategory(String category, int offset) + throws BadLocationException, BadPositionCategoryException { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#addPositionUpdater(org.eclipse.jface.text.IPositionUpdater) + */ + // public void addPositionUpdater(IPositionUpdater updater) + // { + // throw new UnsupportedOperationException("Not implemented!"); + // } + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#removePositionUpdater(org.eclipse.jface.text.IPositionUpdater) + */ + public void removePositionUpdater(IPositionUpdater updater) { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#insertPositionUpdater(org.eclipse.jface.text.IPositionUpdater, + * int) + */ + // public void insertPositionUpdater(IPositionUpdater updater, int index) + // { + // throw new UnsupportedOperationException("Not implemented!"); + // } + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#getPositionUpdaters() + */ + public IPositionUpdater[] getPositionUpdaters() { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#getLegalContentTypes() + */ + public String[] getLegalContentTypes() { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#getContentType(int) + */ + public String getContentType(int offset) throws BadLocationException { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#getPartition(int) + */ + public ITypedRegion getPartition(int offset) throws BadLocationException { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#computePartitioning(int, int) + */ + public ITypedRegion[] computePartitioning(int offset, int length) + throws BadLocationException { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#addDocumentPartitioningListener(org.eclipse.jface.text.IDocumentPartitioningListener) + */ + public void addDocumentPartitioningListener( + IDocumentPartitioningListener listener) { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#removeDocumentPartitioningListener(org.eclipse.jface.text.IDocumentPartitioningListener) + */ + public void removeDocumentPartitioningListener( + IDocumentPartitioningListener listener) { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#setDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) + */ + public void setDocumentPartitioner(IDocumentPartitioner partitioner) { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#getDocumentPartitioner() + */ + public IDocumentPartitioner getDocumentPartitioner() { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#getLineLength(int) + */ + public int getLineLength(int line) throws BadLocationException { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#getLineOfOffset(int) + */ + public int getLineOfOffset(int offset) throws BadLocationException { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#getLineOffset(int) + */ + public int getLineOffset(int line) throws BadLocationException { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#getLineInformation(int) + */ + public IRegion getLineInformation(int line) throws BadLocationException { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#getLineInformationOfOffset(int) + */ + public IRegion getLineInformationOfOffset(int offset) + throws BadLocationException { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#getNumberOfLines() + */ + public int getNumberOfLines() { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#getNumberOfLines(int, int) + */ + public int getNumberOfLines(int offset, int length) + throws BadLocationException { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#computeNumberOfLines(java.lang.String) + */ + public int computeNumberOfLines(String text) { + throw new UnsupportedOperationException("Not implemented!"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#getLegalLineDelimiters() + */ + // public String[] getLegalLineDelimiters() + // { + // throw new UnsupportedOperationException("Not implemented!"); + // } + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#getLineDelimiter(int) + */ + // public String getLineDelimiter(int line) throws BadLocationException + // { + // throw new UnsupportedOperationException("Not implemented!"); + // } + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocument#search(int, java.lang.String, + * boolean, boolean, boolean) + */ + public int search(int startOffset, String findString, + boolean forwardSearch, boolean caseSensitive, boolean wholeWord) + throws BadLocationException { + throw new UnsupportedOperationException("Not implemented!"); + } + +} diff --git a/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/phpeditor/php/test/IdentifierIndexManagerTest.java b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/phpeditor/php/test/IdentifierIndexManagerTest.java new file mode 100644 index 0000000..ec1fe7b --- /dev/null +++ b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/phpeditor/php/test/IdentifierIndexManagerTest.java @@ -0,0 +1,54 @@ +/* + * Created on 08.05.2004 + * + * To change the template for this generated file go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +package net.sourceforge.phpeclipse.phpeditor.php.test; + +import java.io.StringBufferInputStream; + +import junit.framework.TestCase; +import net.sourceforge.phpeclipse.builder.IdentifierIndexManager; + +import org.eclipse.core.runtime.CoreException; + +/** + * + */ +public class IdentifierIndexManagerTest extends TestCase { + IdentifierIndexManager fManager; + + public void testManager() { + System.out.println("----- testManager -----"); + String testString = "]*script*\\\"?[^>]*>\", $secvalue)) ||\r\n" + + " (eregi(\"<[^>]*object*\\\"?[^>]*>\", $secvalue)) ||\r\n" + + " (eregi(\"<[^>]*iframe*\\\"?[^>]*>\", $secvalue)) ||\r\n" + + " (eregi(\"<[^>]*applet*\\\"?[^>]*>\", $secvalue)) ||\r\n" + + " (eregi(\"<[^>]*meta*\\\"?[^>]*>\", $secvalue)) ||\r\n" + + " (eregi(\"<[^>]*style*\\\"?[^>]*>\", $secvalue)) ||\r\n" + + " (eregi(\"<[^>]*form*\\\"?[^>]*>\", $secvalue)) ||\r\n" + + " (eregi(\"\\([^>]*\\\"?[^)]*\\)\", $secvalue)) ||\r\n" + + " (eregi(\"\\\"\", $secvalue))) {\r\n" + + " die (\"


    The html tags you attempted to use are not allowed

    [ Go Back ]\");\r\n" + + " } ?>"; + IdentifierIndexManager.LineCreator lineCreator = fManager + .createLineCreator(); + try { + fManager.addInputStream(new StringBufferInputStream(testString), + "test", lineCreator); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /* + * (non-Javadoc) + * + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() throws Exception { + fManager = new IdentifierIndexManager("c:\\temp\\test"); + } +} diff --git a/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/OverlibTestCase.java b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/OverlibTestCase.java new file mode 100644 index 0000000..f6278a2 --- /dev/null +++ b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/OverlibTestCase.java @@ -0,0 +1,469 @@ +package net.sourceforge.phpeclipse.tests.parser; + +/******************************************************************************* + * Copyright (c) 2002 www.phpeclipse.de 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 + ******************************************************************************/ +import net.sourceforge.phpdt.core.tests.util.AbstractCompilerTest; + +/** + * Tests the php parser + */ +public class OverlibTestCase extends AbstractCompilerTest { + // Parser parser; + public OverlibTestCase(String name) { + super(name); + } + + /** + * Test the PHP Parser with different PHP snippets + */ + public void testPHPParser() { + checkPHP("\r\n" + + " /*\r\n" + + "\r\n" + + " This is version 1.11 of class.overlib for php (http://www.php.net) \r\n" + + "\r\n" + + " written 1999, 2000, 2001 Patrick Hess \r\n" + + "\r\n" + + " This software is distributed under GPL.\r\n" + + " \r\n" + + " overLib is from Eric Bosrup (http://www.bosrup.com/web/overlib/)\r\n" + + "\r\n" + + " This class is just a driver/container, so most of this wonderful\r\n" + + " \r\n" + + " work is done by Eric Bosrup! Keep this in mind... \r\n" + + " \r\n" + + " */\r\n" + + "\r\n" + + "include(\"hello_world\"); \r\n" + + "function foo() {" + + "} \r\n" + + "\r\n" + + " class Overlib {\r\n" + + "\r\n" + + " public $ol_path = \"modules/Forums\";\r\n" + + "\r\n" + + " public $ol_sticky = false;\r\n" + + "\r\n" + + " public $ol_align = 0;\r\n" + + "\r\n" + + " public $ol_valign = 0;\r\n" + + "\r\n" + + " public $ol_fgcolor = \"#fcfcfc\";\r\n" + + "\r\n" + + " public $ol_bgcolor = \"#0080C0\";\r\n" + + "\r\n" + + " public $ol_capcolor = \"#ffffff\";\r\n" + + "\r\n" + + " public $ol_textcolor = \"\";\r\n" + + "\r\n" + + " public $ol_closecolor = \"\";\r\n" + + "\r\n" + + " public $ol_textfont = \"\";\r\n" + + "\r\n" + + " public $ol_captionfont = \"\";\r\n" + + "\r\n" + + " public $ol_closefont = \"\";\r\n" + + "\r\n" + + " public $ol_textsize = 0;\r\n" + + "\r\n" + + " public $ol_captionsize = 0;\r\n" + + "\r\n" + + " public $ol_closesize = 0;\r\n" + + "\r\n" + + " public $ol_height = 0;\r\n" + + "\r\n" + + " public $ol_width = 0;\r\n" + + "\r\n" + + " public $ol_border = 3;\r\n" + + "\r\n" + + " public $ol_offsetx = 0;\r\n" + + "\r\n" + + " public $ol_offsety = 0;\r\n" + + "\r\n" + + " public $ol_fgbackground = \"\";\r\n" + + "\r\n" + + " public $ol_bgbackground = \"\";\r\n" + + "\r\n" + + " public $ol_closetext = \"Close\";\r\n" + + "\r\n" + + " public $ol_close = true;\r\n" + + "\r\n" + + " public $ol_noclosetext = false;\r\n" + + "\r\n" + + " public $ol_autostatus = false;\r\n" + + "\r\n" + + " public $ol_autostatuscap = false;\r\n" + + "\r\n" + + " public $ol_capicon = \"images/forum/question.gif\";\r\n" + + "\r\n" + + " public $ol_snapx = 0;\r\n" + + "\r\n" + + " public $ol_snapy = 0;\r\n" + + "\r\n" + + " public $ol_padxl = 0;\r\n" + + "\r\n" + + " public $ol_padxr = 0;\r\n" + + "\r\n" + + " public $ol_padyt = 0;\r\n" + + "\r\n" + + " public $ol_padyb = 0;\r\n" + + "\r\n" + + " public $ol_fixy = 0;\r\n" + + "\r\n" + + " public $ol_background = \"\";\r\n" + + "\r\n" + + " public $ol_fullhtml = false;\r\n" + + "\r\n" + + " public $ol_timeout = -1;\r\n" + + "\r\n" + + " public $ol_delay = -1;\r\n" + + "\r\n" + + " public $ol_vauto = false;\r\n" + + "\r\n" + + " public $ol_hauto = false;\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " function overLib($path = \"\") {\r\n" + + "\r\n" + + " if (strlen($path)) $this->ol_path = $path;\r\n" + + "\r\n" + + "?>\r\n" + + "\r\n" + + "ol_path/overlib.css\' \"; ?> \r\n" + + "\r\n" + + " type=\'text/css\'>\r\n" + + "\r\n" + + "
    \r\n" + + "\r\n" + + "
    \r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "$v = $value;\r\n" + + "\r\n" + + " }\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " function get($var) {\r\n" + + "\r\n" + + " $v = \"ol_$var\";\r\n" + + "\r\n" + + " return($this->$v);\r\n" + + "\r\n" + + " }\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " function over($text, $title = \"\", $status = \"\")\r\n" + + "\r\n" + + " {\r\n" + + "\r\n" + + " $cmd = \"\'$text\'\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if(strlen($title)) \r\n" + + "\r\n" + + " $cmd .= \", CAPTION, \'$title\'\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if(strlen($status)) \r\n" + + "\r\n" + + " $cmd .= \", STATUS, \'$status\'\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if($this->ol_sticky) \r\n" + + "\r\n" + + " $cmd .= \", STICKY\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if($this->ol_align) {\r\n" + + "\r\n" + + " switch($this->ol_align) {\r\n" + + "\r\n" + + " case 1: $cmd .= \", LEFT\"; break;\r\n" + + "\r\n" + + " case 2: $cmd .= \", CENTER\"; break;\r\n" + + "\r\n" + + " case 3: $cmd .= \", RIGHT\"; break;\r\n" + + "\r\n" + + " default: break;\r\n" + + "\r\n" + + " }\r\n" + + "\r\n" + + " }\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if($this->ol_valign) {\r\n" + + "\r\n" + + " switch($this->ol_valign) {\r\n" + + "\r\n" + + " case 1: $cmd .= \", ABOVE\"; break;\r\n" + + "\r\n" + + " case 2: $cmd .= \", BELOW\"; break;\r\n" + + "\r\n" + + " default: break;\r\n" + + "\r\n" + + " }\r\n" + + "\r\n" + + " }\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if (strlen($this->ol_fgbackground)) {\r\n" + + "\r\n" + + " $cmd .= \", FGCOLOR, \'\', FGBACKGROUND, \'$this->ol_fgbackground\'\";\r\n" + + "\r\n" + + " } else {\r\n" + + "\r\n" + + " if (strlen($this->ol_fgcolor))\r\n" + + "\r\n" + + " $cmd .= \", FGCOLOR, \'$this->ol_fgcolor\'\";\r\n" + + "\r\n" + + " }\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if (strlen($this->ol_bgbackground)) {\r\n" + + "\r\n" + + " $cmd .= \", BGCOLOR, \'\', BGBACKGROUND, \'$this->ol_bgbackground\'\";\r\n" + + "\r\n" + + " } else {\r\n" + + "\r\n" + + " if (strlen($this->ol_bgcolor))\r\n" + + "\r\n" + + " $cmd .= \", BGCOLOR, \'$this->ol_bgcolor\'\";\r\n" + + "\r\n" + + " }\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if (strlen($this->ol_capcolor))\r\n" + + "\r\n" + + " $cmd .= \", CAPCOLOR, \'$this->ol_capcolor\'\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if (strlen($this->ol_textcolor))\r\n" + + "\r\n" + + " $cmd .= \", TEXTCOLOR, \'$this->ol_textcolor\'\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if (strlen($this->ol_closecolor))\r\n" + + "\r\n" + + " $cmd .= \", CLOSECOLOR, \'$this->ol_closecolor\'\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if (strlen($this->ol_textfont))\r\n" + + "\r\n" + + " $cmd .= \", TEXTFONT, \'$this->ol_textfont\'\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if (strlen($this->ol_captionfont))\r\n" + + "\r\n" + + " $cmd .= \", CAPTIONFONT, \'$this->ol_captionfont\'\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if (strlen($this->ol_closefont))\r\n" + + "\r\n" + + " $cmd .= \", CLOSEFONT, \'$this->ol_closefont\'\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if ($this->ol_textsize)\r\n" + + "\r\n" + + " $cmd .= \", TEXTSIZE, $this->ol_textsize\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if ($this->ol_captionsize)\r\n" + + "\r\n" + + " $cmd .= \", CAPTIONSIZE, $this->ol_captionsize\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if ($this->ol_closesize)\r\n" + + "\r\n" + + " $cmd .= \", CLOSESIZE, $this->ol_closesize\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if ($this->ol_width)\r\n" + + "\r\n" + + " $cmd .= \", WIDTH, $this->ol_width\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if ($this->ol_height)\r\n" + + "\r\n" + + " $cmd .= \", HEIGHT, $this->ol_height\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if ($this->ol_border >= 0)\r\n" + + "\r\n" + + " $cmd .= \", BORDER, $this->ol_border\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if ($this->ol_offsetx)\r\n" + + "\r\n" + + " $cmd .= \", OFFSETX, $this->ol_offsetx\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if ($this->ol_offsety)\r\n" + + "\r\n" + + " $cmd .= \", OFFSETY, $this->ol_offsety\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if (strlen($this->ol_closetext))\r\n" + + "\r\n" + + " $cmd .= \", CLOSETEXT, \'$this->ol_closetext\'\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if ($this->ol_noclose)\r\n" + + "\r\n" + + " $cmd .= \", NOCLOSETEXT\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if ($this->ol_autostatus)\r\n" + + "\r\n" + + " $cmd .= \", AUTOSTATUS\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if ($this->ol_autostatuscap)\r\n" + + "\r\n" + + " $cmd .= \", AUTOSTATUSCAP\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if (strlen($this->ol_capicon))\r\n" + + "\r\n" + + " $cmd .= \", CAPICON, \'$this->ol_capicon\'\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if ($this->ol_snapx)\r\n" + + "\r\n" + + " $cmd .= \", SNAPX, $this->ol_snapx\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if ($this->ol_snapy)\r\n" + + "\r\n" + + " $cmd .= \", SNAPY, $this->ol_snapy\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if ($this->ol_fixy)\r\n" + + "\r\n" + + " $cmd .= \", FIXY, $this->ol_fixy\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if ($this->ol_padxl || $this->ol_padxr)\r\n" + + "\r\n" + + " $cmd .= \", PADX, $this->ol_padxl, $this->ol_padxr\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if ($this->ol_padyt || $this->ol_padyb)\r\n" + + "\r\n" + + " $cmd .= \", PADY, $this->ol_padyt, $this->ol_padyb\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if (strlen($this->ol_background))\r\n" + + "\r\n" + + " $cmd .= \", BACKGROUND, \'$this->ol_background\'\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if ($this->ol_fullhtml)\r\n" + + "\r\n" + + " $cmd .= \", FULLHTML\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if ($this->ol_timeout >= 0)\r\n" + + "\r\n" + + " $cmd .= \", TIMEOUT, $this->ol_timeout\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if ($this->ol_delay >= 0)\r\n" + + "\r\n" + + " $cmd .= \", DELAY, $this->ol_delay\";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if ($this->ol_hauto) {\r\n" + + "\r\n" + + " $cmd .= \", HAUTO\";\r\n" + + "\r\n" + + " $this->ol_hauto = false;\r\n" + + "\r\n" + + " }\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " if ($this->ol_vauto) {\r\n" + + "\r\n" + + " $cmd .= \", VAUTO\";\r\n" + + "\r\n" + + " $this->ol_hauto = false;\r\n" + + "\r\n" + + " }\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " $output=\" onMouseOver=\\\"return overlib($cmd);\\\" \";\r\n" + + "\r\n" + + " $output.=\" onMouseOut=\\\"nd();\\\" \";\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " return ($output);\r\n" + + "\r\n" + + " }\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " function pover ($text, $title = \"\", $status = \"\") \r\n" + + "\r\n" + " {\r\n" + "\r\n" + + " echo $this->over($text, $title, $status);\r\n" + "\r\n" + + " }\r\n" + "\r\n" + " }\r\n" + "\r\n" + "?>\r\n" + "\r\n" + + "\r\n" + "\r\n" + "\r\n" + "\r\n" + ""); + } +} diff --git a/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/PHPManualTestCase.java b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/PHPManualTestCase.java new file mode 100644 index 0000000..4233c80 --- /dev/null +++ b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/PHPManualTestCase.java @@ -0,0 +1,244 @@ +package net.sourceforge.phpeclipse.tests.parser; + +/******************************************************************************* + * Copyright (c) 2002 www.phpeclipse.de 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 + ******************************************************************************/ +import net.sourceforge.phpdt.core.tests.util.AbstractCompilerTest; + +/** + * Tests the php parser + */ +public class PHPManualTestCase extends AbstractCompilerTest { + // Parser parser; + public PHPManualTestCase(String name) { + super(name); + } + + /** + * Test the PHP Parser with different PHP snippets + */ + public void testPHPParser() { + checkPHP("self::$instance = new Singleton();"); + checkPHP("if ((eregi(\"<[^>]*script*\\\"?[^>]*>\", $secvalue)) ||\r\n" + + " (eregi(\"<[^>]*object*\\\"?[^>]*>\", $secvalue)) ||\r\n" + + " (eregi(\"<[^>]*iframe*\\\"?[^>]*>\", $secvalue)) ||\r\n" + + " (eregi(\"<[^>]*applet*\\\"?[^>]*>\", $secvalue)) ||\r\n" + + " (eregi(\"<[^>]*meta*\\\"?[^>]*>\", $secvalue)) ||\r\n" + + " (eregi(\"<[^>]*style*\\\"?[^>]*>\", $secvalue)) ||\r\n" + + " (eregi(\"<[^>]*form*\\\"?[^>]*>\", $secvalue)) ||\r\n" + + " (eregi(\"\\([^>]*\\\"?[^)]*\\)\", $secvalue)) ||\r\n" + + " (eregi(\"\\\"\", $secvalue))) {\r\n" + + " die (\"


    The html tags you attempted to use are not allowed

    [ Go Back ]\");\r\n" + + " }"); + checkPHP("function foo()" + "{" + " echo \"In foo()
    \\n\";" + "}" + + "" + "function bar($arg = '')" + "{" + + " echo \"In bar(); argument was '$arg'.
    \\n\";" + "}" + + "" + "// This is a wrapper function around echo" + + "function echoit($string)" + "{" + " echo $string;" + "}" + + "" + "$func = 'foo';" + "$func(); // This calls foo()" + + "" + "$func = 'bar';" + "$func('test'); // This calls bar()" + + "" + "$func = 'echoit';" + + "$func('test'); // This calls echoit()" + ""); + checkPHP("class Foo" + "{" + " function Vari()" + " {" + + " $name = 'Bar';" + + " $this->$name(); // This calls the Bar() method\n" + + " }" + " " + " function Bar()" + " {" + + " echo \"This is Bar\";" + " }" + "}" + "" + + "$foo = new Foo();" + "$funcname = \"Var\";" + + "$foo->$varname(); // This calls $foo->Var()\n" + ""); + checkPHP("function square ($num)" + "{" + " return $num * $num;" + + "}" + "echo square (4); // outputs '16'." + ""); + checkPHP("function small_numbers()" + "{" + + " return array (0, 1, 2);" + "}" + + "list ($zero, $one, $two) = small_numbers();" + ""); + checkPHP("function &returns_reference()" + "{" + " return $someref;" + + "}" + "" + "$newref =& returns_reference();" + " " + ""); + checkPHP("function add_some_extra(&$string)" + "{" + + " $string .= 'and something extra.';" + "}" + + "$str = 'This is a string, ';" + "add_some_extra($str);" + + "echo $str; "); + checkPHP("function makecoffee ($type = \"cappuccino\")\n" + "{\n" + + " return \"Making a cup of $type.\\n\";\n" + "}" + + "echo makecoffee ();" + "echo makecoffee (\"espresso\");" + + ""); + checkPHP("$makefoo = true;" + + "" + + "/* We can't call foo() from here " + + " since it doesn't exist yet," + + " but we can call bar() */" + + "" + + "bar();" + + "" + + "if ($makefoo) {" + + " function foo ()" + + " {" + + " echo \"I don't exist until program execution reaches me.\\n\";" + + " }" + "}" + "" + "/* Now we can safely call foo()" + + " since $makefoo evaluated to true */" + "" + + "if ($makefoo) foo();" + "" + "function bar() " + "{" + + " echo \"I exist immediately upon program start.\\n\";" + + "}" + "" + ""); + checkPHP("function foo() " + "{" + " function bar() " + " {" + + " echo \"I don't exist until foo() is called.\\n\";" + + " }" + "}" + "" + "/* We can't call bar() yet" + + " since it doesn't exist. */" + "" + "foo();\n" + "" + + "/* Now we can call bar()," + " foo()'s processesing has" + + " made it accessable. */" + "" + "bar();" + ""); + // Bugs item #690938 + checkPHP(" echo \"This is a test\"; // This is a one-line c++ style comment\n" + + " /* This is a multi line comment\n" + + " yet another line of comment */\n" + + " echo \"This is yet another test\";\n" + + " echo \"One Final Test\"; # This is shell-style style comment \n"); + checkPHP("$bool = TRUE; // a boolean\n" + + "$str = \"foo\"; // a string\n" + + "$int = 12; // an integer\n" + "\n" + + "echo gettype($bool); // prints out \"boolean\"\n" + + "echo gettype($str); // prints out \"string\"\n" + "" + + "// If this is an integer, increment it by four\n" + + "if (is_int($int)) {\n" + " $int += 4;\n" + "}\n" + "\n" + + "// If $bool is a string, print it out\n" + + "// (does not print out anything)\n" + + "if (is_string($bool)) {\n" + " echo \"String: $bool\";\n" + + "}\n"); + checkPHP("$foo = True; // assign the value TRUE to $foo"); + checkPHP("// == is an operator which test\n" + + "// equality and returns a boolean\n" + + "if ($action == \"show_version\") {\n" + + " echo \"The version is 1.23\";\n" + "}\n" + "\n" + + "// this is not necessary...\n" + + "if ($show_separators == TRUE) {\n" + + " echo \"
    \\n\";\n" + "}\n" + "\n" + + "// ...because you can simply type\n" + + "if ($show_separators) {\n" + " echo \"
    \\n\";\n" + "}"); + checkPHP( // "echo gettype((bool) \"\"); // bool(false)\n" + "echo gettype((bool) 1); // bool(true)\n" + + "echo gettype((bool) -2); // bool(true)\n" + + "echo gettype((bool) \"foo\"); // bool(true)\n" + + "echo gettype((bool) 2.3e5); // bool(true)\n" + + "echo gettype((bool) array(12)); // bool(true)\n" + + "echo gettype((bool) array()); // bool(false)\n"); + checkPHP("$a = 1234; # decimal number\n" + + "$a = -123; # a negative number\n" + + "$a = 0123; # octal number (equivalent to 83 decimal)\n" + + "$a = 0x1A; # hexadecimal number (equivalent to 26 decimal)\n"); + checkPHP("$large_number = 2147483647;\n" + + "var_dump($large_number);\n" + "// output: int(2147483647)\n" + + "\n" + "$large_number = 2147483648;\n" + + "var_dump($large_number);\n" + + "// output: float(2147483648)\n" + "" + + "// this goes also for hexadecimal specified integers:\n" + + "var_dump( 0x80000000 );\n" + + "// output: float(2147483648)\n" + "\n" + + "$million = 1000000;\n" + + "$large_number = 50000 * $million;\n" + + "var_dump($large_number);\n" + + "// output: float(50000000000)\n"); + checkPHP("var_dump(25/7); // float(3.5714285714286)\n" + + "var_dump((int) (25/7)); // int(3)\n" + + "var_dump(round(25/7)); // float(4)"); + checkPHP("echo (int) ( (0.1+0.7) * 10 ); // echoes 7!"); + checkPHP("$a = 1.234; " + "$b = 1.2e3; " + "$c = 7E-10;"); + checkPHP("echo 'this is a simple string';\n" + "\n" + + "echo 'You can also have embedded newlines in \n" + + "strings this way as it is\n" + "okay to do';\n" + "\n" + + "// Outputs: \"I'll be back\"\n" + + "echo 'Arnold once said: \"I\\'ll be back\"';\n" + "\n" + + "// Outputs: You deleted C:\\*.*?\n" + + "echo 'You deleted C:\\\\*.*?';\n" + "\n" + + "// Outputs: You deleted C:\\*.*?\n" + + "echo 'You deleted C:\\\\*.*?';\n" + "\n" + + "// Outputs: This will not expand: \\n a newline\n" + + "echo 'This will not expand: \\n a newline';\n" + "\n" + + "// Outputs: Variables do not $expand $either\n" + + "echo 'Variables do not $expand $either';\n"); + + checkPHP("echo \"This works: \" . $arr['foo'][3];"); + checkPHP("echo \"\\$foo==$foo; type is \" . gettype ($foo) . \"
    \\n\";"); + checkPHP("$arr = array(\"foo\" => \"bar\", 12 => true);\n" + "\n" + + "echo $arr[\"foo\"]; // bar\n" + "echo $arr[12]; // 1\n"); + checkPHP("// This array is the same as ...\n" + + "array(5 => 43, 32, 56, \"b\" => 12);\n" + "\n" + + "// ...this array\n" + + "array(5 => 43, 6 => 32, 7 => 56, \"b\" => 12);\n"); + checkPHP("$arr = array(5 => 1, 12 => 2);\n" + + "\n" + + "$arr[] = 56; // This is the same as $arr[13] = 56;\n" + + " // at this point of the script\n" + + "\n" + + "$arr[\"x\"] = 42; // This adds a new element to\n" + + " // the array with key \"x\"\n" + + " \n" + + "unset($arr[5]); // This removes the element from the array\n" + + "\n" + "unset($arr); // This deletes the whole array\n"); + checkPHP("$foo[bar] = 'enemy';\n" + "echo $foo[bar];"); + checkPHP("$a = array( 'color' => 'red',\n" + + " 'taste' => 'sweet',\n" + + " 'shape' => 'round',\n" + + " 'name' => 'apple',\n" + + " 4 // key will be 0\n" + + " );\n" + + "\n" + + "// is completely equivalent with\n" + + "$a['color'] = 'red';\n" + + "$a['taste'] = 'sweet';\n" + + "$a['shape'] = 'round';\n" + + "$a['name'] = 'apple';\n" + + "$a[] = 4; // key will be 0\n" + + "\n" + + "$b[] = 'a';\n" + + "$b[] = 'b';\n" + + "$b[] = 'c';\n" + + "// will result in the array array(0 => 'a' , 1 => 'b' , 2 => 'c'),\n" + + "// or simply array('a', 'b', 'c')\n"); + checkPHP("foreach ($colors as $key => $color) {\n" + + " // won't work:\n" + + " //$color = strtoupper($color);\n" + " \n" + + " // works:\n" + + " $colors[$key] = strtoupper($color);\n" + "}\n" + + "print_r($colors);\n"); + checkPHP("$fruits = array ( \"fruits\" => array ( \"a\" => \"orange\",\n" + + " \"b\" => \"banana\",\n" + + " \"c\" => \"apple\"\n" + + " ),\n" + + " \"numbers\" => array ( 1,\n" + + " 2,\n" + + " 3,\n" + + " 4,\n" + + " 5,\n" + + " 6,\n" + + " ),\n" + + " \"holes\" => array ( \"first\",\n" + + " 5 => \"second\",\n" + + " \"third\"\n" + + " )\n" + + " );\n" + + "\n" + + "// Some examples to address values in the array above \n" + + "echo $fruits[\"holes\"][5]; // prints \"second\"\n" + + "echo $fruits[\"fruits\"][\"a\"]; // prints \"orange\"\n" + + "unset($fruits[\"holes\"][0]); // remove \"first\"\n" + + "\n" + + "// Create a new multi-dimensional array\n" + + "$juices[\"apple\"][\"green\"] = \"good\"; \n"); + checkPHP("$arr3 = &$arr1;"); + checkPHP("class foo\n" + "{\n" + " function do_foo()\n" + " {\n" + + " echo \"Doing foo.\"; \n" + " }\n" + "}\n" + "\n" + + "$bar = new foo;\n" + "$bar->do_foo();\n"); + checkPHP("$obj = (object) 'ciao';\n" + + "echo $obj->scalar; // outputs 'ciao'"); + checkPHP("$var = NULL;"); + checkPHP("$var = \"Bob\";\n" + "$Var = \"Joe\";\n" + + "echo \"$var, $Var\"; // outputs \"Bob, Joe\"\n" + "\n" + + + // "$4site = 'not yet'; // invalid; starts with a number\n" + + "$_4site = 'not yet'; // valid; starts with an underscore\n" + + "$t�yte = 'mansikka'; \n"); + + checkPHP(""); + checkPHP(""); + } +} diff --git a/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/PHPParserTestCase.java b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/PHPParserTestCase.java new file mode 100644 index 0000000..0f3e50e --- /dev/null +++ b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/PHPParserTestCase.java @@ -0,0 +1,386 @@ +package net.sourceforge.phpeclipse.tests.parser; + +/******************************************************************************* + * Copyright (c) 2002 www.phpeclipse.de 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 + ******************************************************************************/ +import net.sourceforge.phpdt.core.tests.util.AbstractCompilerTest; + +/** + * Tests the php parser + */ +public class PHPParserTestCase extends AbstractCompilerTest { + + public PHPParserTestCase(String name) { + super(name); + } + + /** + * Test the PHP Parser with failing PHP snippets + * + */ + public void testPHPParserFailingSyntax() { + checkPHP( + "i=10;", + "----------\n" + + "1. ERROR in (at line 1)\n" + + " i=10;\n" + + " ^^\n" + + "Parser error \"Assignment operator \'=\' not allowed after identifier \'i\' (use \'define(...)\' to define constants).\"\n" + + "----------\n"); + } + + /** + * Test Interface Extending multiple Interfaces + * + * This is valid PHP5 syntax Bug 1431425 + */ + public void testMIInterfaceExtendsInterface() { + // valid PHP5 + checkPHP("interface a {}\n" + "interface b {}\n" + "\n" + + "interface c extends a, b\n" + "{}\n"); + } + + /** + * Test Interface implementing multiple Interfaces + * + * This is invalid PHP5 syntax Bug 1431425 + */ + public void testMIInterfaceImplementsInterface() { + // invalid PHP5 + checkPHP( + "interface a {}\n" + "interface b {}\n" + "\n" + + "interface c implements a, b\n" + "{}\n", + "----------\n" + + "1. ERROR in (at line 1)\n" + + " interface c implements a, b\n" + + " ^^^^^^^^^^^\n" + + "Parser error \"'{' expected at start of class body.\"\n" + + "----------\n" + + "2. ERROR in (at line 1)\n" + + " {}\n" + + "\n" + + " ^^\n" + + "Parser error \"Too many closing '}'; end-of-file not reached.\"\n" + + "----------\n"); + + } + + /** + * Test Class Extending multiple Interfaces + * + * This is invalid PHP5 syntax Bug 1431425 + */ + public void testMIClassExtendsInterface() { + // invalid PHP5 + checkPHP( + "interface a {}\n" + "interface b {}\n" + "\n" + + "class c extends a, b\n" + "{}\n", + "----------\n" + + "1. ERROR in (at line 1)\n" + + " class c extends a, b\n" + + " ^^\n" + + "Parser error \"No multiple inheritence allowed. Expected token \'implements\' or \'{\'.\"\n" + + "----------\n"); + } + + /** + * Test Class implementing multiple Interfaces + * + * This is valid PHP5 syntax Bug 1431425 + */ + public void testMIClassImplementsInterfaces() { + // valid PHP5 + checkPHP("interface a {}\n" + "interface b {}\n" + "\n" + + "class c implements a, b\n" + "{}\n"); + } + + /** + * Test Class Implementing multiple classes + * + * This is invalid PHP5 syntax Bug 1431425 + */ + public void testMIClassImplementsClasses() { + // invalid PHP5 + checkPHP("class a {}\n" + "class b {}\n" + "\n" + + "class c implements a, b\n" + "{}\n", + "This should fail, but doesn't currently."); + } + + /** + * Test Class Extending multiple Classes + * + * This is invalid PHP5 syntax Bug 1431425 + */ + public void testMIClassExtendsClasses() { + // invalid PHP5 + checkPHP( + "class a {}\n" + "class b {}\n" + "\n" + + "class c extends a, b\n" + "{}\n", + "----------\n" + + "1. ERROR in (at line 1)\n" + + " class c extends a, b\n" + + " ^^\n" + + "Parser error \"No multiple inheritence allowed. Expected token \'implements\' or \'{\'.\"\n" + + "----------\n"); + } + + /** + * Test the PHP Parser with different PHP snippets + */ + public void testPHPParserGoodSyntax() { + checkPHP("$y=self::$x->huba;"); + checkPHP("self::x()->set();"); + checkPHP("$test=\"{4IP}/{$include}\";"); + checkPHP("$this->mRegex = \"/{$this->mBaseRegex}/{$case}\";"); + checkPHP("$schema_create .= \" DEFAULT \'$row[Default]\'\";"); + checkPHP("$stringVar=\"ein normaler $varText\";"); + checkPHP("$stringVar=\'ein normaler $varText\';"); + checkPHP("switch ($aItem[ELM_NAME]) {\r\n" + + " case \'channel\':\r\n" + + " $this->readChannel($aItem);\r\n" + + " break;\r\n" + + " case \'item\':\r\n" + + " $this->readItem($aItem);\r\n" + + " break;\r\n" + + " default:\r\n" + + " //printr($aItem);\r\n" + " }"); + checkPHP("try {echo $Stream->readAll(); } catch (Exception $e) {\r\n" + + " // Swallow exception\r\n" + " }"); + + checkHTML("ol_path = $path;\n" + + "\n" + + "?>\n" + + "\n" + + "ol_path/overlib.css\' \"; ?> \n" + + "\n" + + " type=\'text/css\'>\n" + + "\n" + + "
    \n" + + "\n" + + "
    \n" + + "\n" + + "\n" + "\n" + ""); + checkPHP("$t = \') {$ya[]=\'.$this->iFunc.\';$xa[]=\'.$this->iXFunc.\';}\';"); + checkPHP("$output .= \n" + + " \"\\$_smarty_tpl_vars = \\$this->_tpl_vars;\\n\" . \n" + + " \"\\$this->_smarty_include(\".$include_file.\", array(\".implode(\',\', (array)$arg_list).\"));\\n\" .\n" + + " \"\\$this->_tpl_vars = \\$_smarty_tpl_vars;\\n\" .\n" + + " \"unset(\\$_smarty_tpl_vars);\\n\";"); + checkPHP("$test=\"=$post_id#$post_id\""); + checkPHP("$comments .= \" \\${$attrname}[\'xmlns\'] = \'{$this->namespaces[$_argtype[\'namespace\']]}\';\\n\";"); + checkPHP("$this->_raiseSoapFault(\"method \'{{$this->method_namespace}}$this->methodname\' not defined in service\",\'\',\'\',\'Server\');"); + + checkPHP("$emailer->assign_vars(array(\r\n" + + " \'U_TOPIC\' => $server_protocol . POST_POST_URL . \"=$post_id#$post_id\",\r\n" + + " \'U_STOP_WATCHING_TOPIC\' => $server_protocol . $server_name . $server_port . $script_name . \'&\' . POST_TOPIC_URL . \"=$topic_id&unwatch=topic\")\r\n" + + " );"); + checkPHP("$_compile_data = \'\';"); + checkPHP("$output = \'\'.\"\\n\", $text_blocks[$curr_tb]);"); + checkPHP("$repl.=\"$sug
    \";"); + checkPHP("$heading=\'
    {tr}Blog{/tr}: {$title}
    \'.\"\\n\";"); + checkPHP("return SOAP_Base_Object::_raiseSoapFault(\"No Transport for {$urlparts[\'scheme\']}\");"); + checkPHP("$text_blocks[$curr_tb] = str_replace(\'%%%SMARTYSP\'.$curr_sp.\'%%%\', \'\'.\"\\n\", $text_blocks[$curr_tb]);"); + checkPHP("$output = \'\'$alttext\'
    \";\r\n" + + " "); + checkPHP("$aid = \"$admin[0]\";"); + checkPHP("$headers = '';"); + checkPHP("do {$array[] = array(\"$myrow[uid]\" => \"$myrow[uname]\"); } while($myrow = mysql_fetch_array($result));"); + checkPHP("\"\\\"\";"); + checkPHP(" print \"$value\"; \n"); + checkPHP("if ($shape instanceof Rectangle) { \n" + + " print \'$shape is a Rectangle\'; \n" + "} "); + checkPHP("$test=\"values(\'$user\',\'${res[\"name\"]}\' \";"); + + checkPHP("$this->raiseError(\"The auth mode: $mode isn\'t implemented\");"); + checkPHP("\'{$this->_keycolumn[$i]};"); + checkPHP("$this->_reg_objects[$object] =\n" + + " array(&$object_impl, $allowed, $smarty_args);"); + checkPHP("echo <<< EOF\n" + " \"\n" + + ";"); + checkPHP("/* \n overLib is from Eric Bosrup (http://www.bosrup.com/web/overlib/) \n */"); + checkPHP("if ($arrAtchCookie[1]==0 && $IdAtchPostId!=null){ } "); + checkPHP("$arrAtchCookie[1] -= filesize(realpath($AtchTempDir).\"/\".$xattachlist)/ 1024; "); + checkPHP("if (!isset($message)){ \n" + + "$message = $myrow[post_text];\n" + + "$message = eregi_replace(\"\\[addsig]\", \"\\n-----------------\\n\" . $myrow[user_sig], $message); \n" + + "$message = str_replace(\"
    \", \"\\n\", $message); \n" + + "$message = str_replace(\"
    \", \"\\n\", $message); \n } "); + checkPHP("$ol = new Overlib();"); + checkPHP("$risultato = mysql_query($sql) or\n die(mysql_error());"); + checkHTML("\n\n\n\n "); + checkHTML(""); + checkHTML(""); + checkHTML(" foo "); + checkHTML(" "); + checkHTML(""); + } +} diff --git a/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/PHPParserTestSuite.java b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/PHPParserTestSuite.java new file mode 100644 index 0000000..a1dcd97 --- /dev/null +++ b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/PHPParserTestSuite.java @@ -0,0 +1,35 @@ +package net.sourceforge.phpeclipse.tests.parser; + +/******************************************************************************* + * Copyright (c) 2002 www.phpeclipse.de 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 + ******************************************************************************/ + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * PHPeclipse Parser Test Suite Runs all PHP parser test cases + * + */ +public class PHPParserTestSuite extends TestCase { + + public PHPParserTestSuite(String name) { + super(name); + } + + public static Test suite() { + TestSuite suite = new TestSuite("PHPeclipse Parser Test Suite"); + suite.addTest(new TestSuite(PHPParserTestCase.class)); + suite.addTest(new TestSuite(ShortTagTestCase.class)); + suite.addTest(new TestSuite(PHPManualTestCase.class)); + suite.addTest(new TestSuite(OverlibTestCase.class)); + suite.addTest(new TestSuite(SmartyCompilerTestCase.class)); + return suite; + + } + +} diff --git a/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/ShortTagTestCase.java b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/ShortTagTestCase.java new file mode 100644 index 0000000..7351671 --- /dev/null +++ b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/ShortTagTestCase.java @@ -0,0 +1,28 @@ +package net.sourceforge.phpeclipse.tests.parser; + +/******************************************************************************* + * Copyright (c) 2002 www.phpeclipse.de 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 + ******************************************************************************/ +import net.sourceforge.phpdt.core.tests.util.AbstractCompilerTest; + +/** + * Tests the php parser + */ +public class ShortTagTestCase extends AbstractCompilerTest { + public ShortTagTestCase(String name) { + super(name); + } + + /** + * Test the PHP Parser with different PHP short tag snippets + */ + public void testPHPParser() { + checkHTML(""); + checkHTML(""); + checkHTML(" text "); + } + +} diff --git a/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/SmartyCompilerTestCase.java b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/SmartyCompilerTestCase.java new file mode 100644 index 0000000..9244622 --- /dev/null +++ b/net.sourceforge.phpeclipse.test/src/net/sourceforge/phpeclipse/tests/parser/SmartyCompilerTestCase.java @@ -0,0 +1,1893 @@ +package net.sourceforge.phpeclipse.tests.parser; + +/******************************************************************************* + * Copyright (c) 2002 www.phpeclipse.de 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 + ******************************************************************************/ +import net.sourceforge.phpdt.core.tests.util.AbstractCompilerTest; + +/** + * Tests the php parser + */ +public class SmartyCompilerTestCase extends AbstractCompilerTest { + // Parser parser; + public SmartyCompilerTestCase(String name) { + super(name); + } + + /** + * Test the PHP Parser with different PHP snippets + */ + public void testPHPParser() { + checkHTML("\n" + + " * Andrei Zmievski \n" + + " *\n" + + " * Version: 2.4.2\n" + + " * Copyright: 2001,2002 ispi of Lincoln, Inc.\n" + + " *\n" + + " * This library is free software; you can redistribute it and/or\n" + + " * modify it under the terms of the GNU Lesser General Public\n" + + " * License as published by the Free Software Foundation; either\n" + + " * version 2.1 of the License, or (at your option) any later version.\n" + + " *\n" + + " * This library is distributed in the hope that it will be useful,\n" + + " * but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + + " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" + + " * Lesser General Public License for more details.\n" + + " *\n" + + " * You should have received a copy of the GNU Lesser General Public\n" + + " * License along with this library; if not, write to the Free Software\n" + + " * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n" + + " *\n" + + " * You may contact the authors of Smarty by e-mail at:\n" + + " * monte@ispi.net\n" + + " * andrei@php.net\n" + + " *\n" + + " * Or, write to:\n" + + " * Monte Ohrt\n" + + " * Director of Technology, ispi\n" + + " * 237 S. 70th suite 220\n" + + " * Lincoln, NE 68510\n" + + " *\n" + + " * The latest version of Smarty can be obtained from:\n" + + " * http://www.phpinsider.com/\n" + + " *\n" + + " */\n" + + "\n" + + "class Smarty_Compiler extends Smarty {\n" + + " \n" + + " // internal vars\n" + + " public $_sectionelse_stack = array(); // keeps track of whether section had \'else\' part\n" + + " public $_foreachelse_stack = array(); // keeps track of whether foreach had \'else\' part\n" + + " public $_literal_blocks = array(); // keeps literal template blocks\n" + + " public $_php_blocks = array(); // keeps php code blocks\n" + + " public $_current_file = null; // the current template being compiled\n" + + " public $_current_line_no = 1; // line number for error messages\n" + + " public $_capture_stack = array(); // keeps track of nested capture buffers\n" + + " public $_plugin_info = array(); // keeps track of plugins to load\n" + + " public $_init_smarty_vars = false;\n" + + " public $_permitted_tokens = array(\'true\',\'false\',\'yes\',\'no\',\'on\',\'off\');\n" + + " public $_db_qstr_regexp = null; // regexps are setup in the constructor\n" + + " public $_si_qstr_regexp = null;\n" + + " public $_qstr_regexp = null;\n" + + " public $_func_regexp = null;\n" + + " public $_var_bracket_regexp = null;\n" + + " public $_dvar_guts_regexp = null;\n" + + " public $_dvar_regexp = null;\n" + + " public $_cvar_regexp = null;\n" + + " public $_svar_regexp = null;\n" + + " public $_avar_regexp = null;\n" + + " public $_mod_regexp = null;\n" + + " public $_var_regexp = null;\n" + + " public $_parenth_param_regexp = null;\n" + + " public $_func_call_regexp = null;\n" + + " public $_obj_ext_regexp = null;\n" + + " public $_obj_start_regexp = null;\n" + + " public $_obj_params_regexp = null;\n" + + " public $_obj_call_regexp = null;\n" + + "\n" + + " /**\n" + + " * The class constructor.\n" + + " *\n" + + " * @access public\n" + + " */\n" + + " function Smarty_Compiler()\n" + + " {\n" + + " // matches double quoted strings:\n" + + " // \"foobar\"\n" + + " // \"foo\\\"bar\"\n" + + " $this->_db_qstr_regexp = \'\"[^\"\\\\\\\\]*(?:\\\\\\\\.[^\"\\\\\\\\]*)*\"\';\n" + + "\n" + + " // matches single quoted strings:\n" + + " // \'foobar\'\n" + + " // \'foo\\\'bar\'\n" + + " $this->_si_qstr_regexp = \'\\\'[^\\\'\\\\\\\\]*(?:\\\\\\\\.[^\\\'\\\\\\\\]*)*\\\'\';\n" + + "\n" + + " // matches single or double quoted strings\n" + + " $this->_qstr_regexp = \'(?:\' . $this->_db_qstr_regexp . \'|\' . $this->_si_qstr_regexp . \')\';\n" + + "\n" + + " // matches bracket portion of vars\n" + + " // [0]\n" + + " // [foo]\n" + + " // [$bar]\n" + + " $this->_var_bracket_regexp = \'\\[\\$?[\\w\\.]+\\]\';\n" + + " \n" + + " // matches $ vars (not objects):\n" + + " // $foo\n" + + " // $foo.bar\n" + + " // $foo.bar.foobar\n" + + " // $foo[0]\n" + + " // $foo[$bar]\n" + + " // $foo[5][blah]\n" + + " // $foo[5].bar[$foobar][4]\n" + + " $this->_dvar_guts_regexp = \'\\w+(?:\' . $this->_var_bracket_regexp\n" + + " . \')*(?:\\.\\$?\\w+(?:\' . $this->_var_bracket_regexp . \')*)*\';\n" + + " $this->_dvar_regexp = \'\\$\' . $this->_dvar_guts_regexp;\n" + + "\n" + + " // matches config vars:\n" + + " // #foo#\n" + + " // #foobar123_foo#\n" + + " $this->_cvar_regexp = \'\\#\\w+\\#\';\n" + + "\n" + + " // matches section vars:\n" + + " // %foo.bar%\n" + + " $this->_svar_regexp = \'\\%\\w+\\.\\w+\\%\';\n" + + "\n" + + " // matches all valid variables (no quotes, no modifiers)\n" + + " $this->_avar_regexp = \'(?:\' . $this->_dvar_regexp . \'|\'\n" + + " . $this->_cvar_regexp . \'|\' . $this->_svar_regexp . \')\';\n" + + "\n" + + " // matches valid modifier syntax:\n" + + " // |foo\n" + + " // |@foo\n" + + " // |foo:\"bar\"\n" + + " // |foo:$bar\n" + + " // |foo:\"bar\":$foobar\n" + + " // |foo|bar\n" + + " // |foo\n" + + " $this->_mod_regexp = \'(?:\\|@?\\w+(?::(?>\\w+|\'\n" + + " . $this->_avar_regexp . \'|\' . $this->_qstr_regexp .\'))*)\';\n" + + "\n" + + " // matches valid variable syntax:\n" + + " // $foo\n" + + " // $foo\n" + + " // #foo#\n" + + " // #foo#\n" + + " // \"text\"\n" + + " // \"text\"\n" + + " $this->_var_regexp = \'(?:\' . $this->_avar_regexp . \'|\' . $this->_qstr_regexp . \')\';\n" + + " \n" + + " // matches valid object call (no objects allowed in parameters):\n" + + " // $foo->bar\n" + + " // $foo->bar()\n" + + " // $foo->bar(\"text\")\n" + + " // $foo->bar($foo, $bar, \"text\")\n" + + " // $foo->bar($foo|bar, \"foo\"|bar)\n" + + " // $foo->bar->foo()\n" + + " // $foo->bar->foo->bar()\n" + + " $this->_obj_ext_regexp = \'\\->(?:\\w+|\' . $this->_dvar_regexp . \')\';\n" + + " $this->_obj_params_regexp = \'\\((?:\\w+|\'\n" + + " . $this->_var_regexp . \'(?>\' . $this->_mod_regexp . \'*)(?:\\s*,\\s*(?:(?:\\w+|\'\n" + + " . $this->_var_regexp . \'(?>\' . $this->_mod_regexp . \'*))))*)?\\)\'; \n" + + " $this->_obj_start_regexp = \'(?:\' . $this->_dvar_regexp . \'(?:\' . $this->_obj_ext_regexp . \')+)\';\n" + + " $this->_obj_call_regexp = \'(?:\' . $this->_obj_start_regexp . \'(?:\' . $this->_obj_params_regexp . \')?)\';\n" + + " \n" + + " // matches valid function name:\n" + + " // foo123\n" + + " // _foo_bar\n" + + " $this->_func_regexp = \'[a-zA-Z_]\\w*\';\n" + + "\n" + + " // matches valid registered object:\n" + + " // foo.bar\n" + + " $this->_reg_obj_regexp = \'[a-zA-Z_]\\w*->[a-zA-Z_]\\w*\';\n" + + " \n" + + " // matches valid parameter values:\n" + + " // true\n" + + " // $foo\n" + + " // $foo|bar\n" + + " // #foo#\n" + + " // #foo#|bar\n" + + " // \"text\"\n" + + " // \"text\"|bar\n" + + " // $foo->bar\n" + + " $this->_param_regexp = \'(?:\\s*(?:\' . $this->_obj_call_regexp . \'|\'\n" + + " . $this->_var_regexp . \'|\\w+)(?>\' . $this->_mod_regexp . \'*)\\s*)\'; \n" + + " \n" + + " // matches valid parenthesised function parameters:\n" + + " // \n" + + " // \"text\"\n" + + " // $foo, $bar, \"text\"\n" + + " // $foo|bar, \"foo\"|bar, $foo->bar($foo)|bar\n" + + " $this->_parenth_param_regexp = \'(?:\\((?:\\w+|\'\n" + + " . $this->_param_regexp . \'(?:\\s*,\\s*(?:(?:\\w+|\'\n" + + " . $this->_param_regexp . \')))*)?\\))\';\n" + + " \n" + + " // matches valid function call:\n" + + " // foo()\n" + + " // foo_bar($foo)\n" + + " // _foo_bar($foo,\"bar\")\n" + + " // foo123($foo,$foo->bar(),\"foo\")\n" + + " $this->_func_call_regexp = \'(?:\' . $this->_func_regexp . \'\\s*(?:\'\n" + + " . $this->_parenth_param_regexp . \'))\'; \n" + + "\n" + + " } \n" + + " \n" + + " /**\n" + + " * compile a template file\n" + + " *\n" + + " * @access public\n" + + " * @param $tpl_file\n" + + " * @param $template_source\n" + + " * @param $template_compiled\n" + + " */\n" + + " function _compile_file($tpl_file, $template_source, &$template_compiled)\n" + + " {\n" + + " if ($this->security) {\n" + + " // do not allow php syntax to be executed unless specified\n" + + " if ($this->php_handling == SMARTY_PHP_ALLOW &&\n" + + " !$this->security_settings[\'PHP_HANDLING\']) {\n" + + " $this->php_handling = SMARTY_PHP_PASSTHRU;\n" + + " }\n" + + " }\n" + + "\n" + + " $this->_load_filters();\n" + + "\n" + + " $this->_current_file = $tpl_file;\n" + + " $this->_current_line_no = 1;\n" + + " $ldq = preg_quote($this->left_delimiter, \'!\');\n" + + " $rdq = preg_quote($this->right_delimiter, \'!\');\n" + + "\n" + + " // run template source through prefilter functions\n" + + " if (count($this->_plugins[\'prefilter\']) > 0) {\n" + + " foreach ($this->_plugins[\'prefilter\'] as $filter_name => $prefilter) {\n" + + " if ($prefilter === false) continue; \n" + + " if ($prefilter[3] || function_exists($prefilter[0])) {\n" + + " $template_source = $prefilter[0]($template_source, $this);\n" + + " $this->_plugins[\'prefilter\'][$filter_name][3] = true;\n" + + " } else {\n" + + " $this->_trigger_fatal_error(\"[plugin] prefilter \'$filter_name\' is not implemented\");\n" + + " }\n" + + " }\n" + + " }\n" + + "\n" + + " /* Annihilate the comments. */\n" + + " $template_source = preg_replace(\"!({$ldq})\\*(.*?)\\*({$rdq})!se\",\n" + + " \"\'\\\\1*\'.str_repeat(\\\"\\n\\\", substr_count(\'\\\\2\', \\\"\\n\\\")) .\'*\\\\3\'\",\n" + + " $template_source);\n" + + "\n" + + " /* Pull out the literal blocks. */\n" + + " preg_match_all(\"!{$ldq}literal{$rdq}(.*?){$ldq}/literal{$rdq}!s\", $template_source, $match);\n" + + " $this->_literal_blocks = $match[1];\n" + + " $template_source = preg_replace(\"!{$ldq}literal{$rdq}(.*?){$ldq}/literal{$rdq}!s\",\n" + + " $this->quote_replace($this->left_delimiter.\'literal\'.$this->right_delimiter), $template_source);\n" + + "\n" + + " /* Pull out the php code blocks. */\n" + + " preg_match_all(\"!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s\", $template_source, $match);\n" + + " $this->_php_blocks = $match[1];\n" + + " $template_source = preg_replace(\"!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s\",\n" + + " $this->quote_replace($this->left_delimiter.\'php\'.$this->right_delimiter), $template_source);\n" + + "\n" + + " /* Gather all template tags. */\n" + + " preg_match_all(\"!{$ldq}\\s*(.*?)\\s*{$rdq}!s\", $template_source, $match);\n" + + " $template_tags = $match[1];\n" + + " /* Split content by template tags to obtain non-template content. */\n" + + " $text_blocks = preg_split(\"!{$ldq}.*?{$rdq}!s\", $template_source);\n" + + " \n" + + " /* loop through text blocks */\n" + + " for ($curr_tb = 0, $for_max = count($text_blocks); $curr_tb < $for_max; $curr_tb++) {\n" + + " /* match anything resembling php tags */\n" + + " if (preg_match_all(\'!(<\\?(?:\\w+|=)?|\\?>|language\\s*=\\s*[\\\"\\\']?php[\\\"\\\']?)!is\', $text_blocks[$curr_tb], $sp_match)) {\n" + + " /* replace tags with placeholders to prevent recursive replacements */\n" + + " $sp_match[1] = array_unique($sp_match[1]);\n" + + " usort($sp_match[1], \'_smarty_sort_length\');\n" + + " for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) {\n" + + " $text_blocks[$curr_tb] = str_replace($sp_match[1][$curr_sp],\'%%%SMARTYSP\'.$curr_sp.\'%%%\',$text_blocks[$curr_tb]);\n" + + " }\n" + + " /* process each one */\n" + + " for ($curr_sp = 0, $for_max2 = count($sp_match[0]); $curr_sp < $for_max2; $curr_sp++) {\n" + + " if ($this->php_handling == SMARTY_PHP_PASSTHRU) {\n" + + " /* echo php contents */\n" + + " $text_blocks[$curr_tb] = str_replace(\'%%%SMARTYSP\'.$curr_sp.\'%%%\', \'\'.\"\\n\", $text_blocks[$curr_tb]);\n" + + " } else if ($this->php_handling == SMARTY_PHP_QUOTE) {\n" + + " /* quote php tags */\n" + + " $text_blocks[$curr_tb] = str_replace(\'%%%SMARTYSP\'.$curr_sp.\'%%%\', htmlspecialchars($sp_match[1][$curr_sp]), $text_blocks[$curr_tb]);\n" + + " } else if ($this->php_handling == SMARTY_PHP_REMOVE) {\n" + + " /* remove php tags */\n" + + " $text_blocks[$curr_tb] = str_replace(\'%%%SMARTYSP\'.$curr_sp.\'%%%\', \'\', $text_blocks[$curr_tb]);\n" + + " } else {\n" + + " /* SMARTY_PHP_ALLOW, but echo non php starting tags */\n" + + " $sp_match[1][$curr_sp] = preg_replace(\'%(<\\?(?!php|=|$))%i\', \'\'.\"\\n\", $sp_match[1][$curr_sp]);\n" + + " $text_blocks[$curr_tb] = str_replace(\'%%%SMARTYSP\'.$curr_sp.\'%%%\', $sp_match[1][$curr_sp], $text_blocks[$curr_tb]);\n" + + " }\n" + + " }\n" + + " }\n" + + " }\n" + + "\n" + + " /* Compile the template tags into PHP code. */\n" + + " $compiled_tags = array();\n" + + " for ($i = 0, $for_max = count($template_tags); $i < $for_max; $i++) {\n" + + " $this->_current_line_no += substr_count($text_blocks[$i], \"\\n\");\n" + + " $compiled_tags[] = $this->_compile_tag($template_tags[$i]);\n" + + " $this->_current_line_no += substr_count($template_tags[$i], \"\\n\");\n" + + " }\n" + + "\n" + + " $template_compiled = \'\';\n" + + "\n" + + " /* Interleave the compiled contents and text blocks to get the final result. */\n" + + " for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) {\n" + + " $template_compiled .= $text_blocks[$i].$compiled_tags[$i];\n" + + " }\n" + + " $template_compiled .= $text_blocks[$i];\n" + + "\n" + + " /* Reformat data between \'strip\' and \'/strip\' tags, removing spaces, tabs and newlines. */\n" + + " if (preg_match_all(\"!{$ldq}strip{$rdq}.*?{$ldq}/strip{$rdq}!s\", $template_compiled, $match)) {\n" + + " $strip_tags = $match[0];\n" + + " $strip_tags_modified = preg_replace(\"!{$ldq}/?strip{$rdq}|[\\t ]+$|^[\\t ]+!m\", \'\', $strip_tags);\n" + + " $strip_tags_modified = preg_replace(\'![\\r\\n]+!m\', \'\', $strip_tags_modified);\n" + + " for ($i = 0, $for_max = count($strip_tags); $i < $for_max; $i++)\n" + + " $template_compiled = preg_replace(\"!{$ldq}strip{$rdq}.*?{$ldq}/strip{$rdq}!s\",\n" + + " $this->quote_replace($strip_tags_modified[$i]),\n" + + " $template_compiled, 1);\n" + + " }\n" + + "\n" + + " // remove \\n from the end of the file, if any\n" + + " if ($template_compiled{strlen($template_compiled) - 1} == \"\\n\" ) {\n" + + " $template_compiled = substr($template_compiled, 0, -1);\n" + + " }\n" + + "\n" + + " // run compiled template through postfilter functions\n" + + " if (count($this->_plugins[\'postfilter\']) > 0) {\n" + + " foreach ($this->_plugins[\'postfilter\'] as $filter_name => $postfilter) {\n" + + " if ($postfilter === false) continue;\n" + + " if ($postfilter[3] || function_exists($postfilter[0])) {\n" + + " $template_compiled = $postfilter[0]($template_compiled, $this);\n" + + " $this->_plugins[\'postfilter\'][$filter_name][3] = true;\n" + + " } else {\n" + + " $this->_trigger_plugin_error(\"Smarty plugin error: postfilter \'$filter_name\' is not implemented\");\n" + + " }\n" + + " }\n" + + " }\n" + + "\n" + + " // put header at the top of the compiled template\n" + + " $template_header = \"_version.\", created on \".strftime(\"%Y-%m-%d %H:%M:%S\").\"\\n\";\n" + + " $template_header .= \" compiled from \".$tpl_file.\" */ ?>\\n\";\n" + + "\n" + + " /* Emit code to load needed plugins. */\n" + + " if (count($this->_plugin_info)) {\n" + + " $plugins_code = \'_load_plugins(array(\';\n" + + " foreach ($this->_plugin_info as $plugin_type => $plugins) {\n" + + " foreach ($plugins as $plugin_name => $plugin_info) {\n" + + " $plugins_code .= \"\\narray(\'$plugin_type\', \'$plugin_name\', \'$plugin_info[0]\', $plugin_info[1], \";\n" + + " $plugins_code .= $plugin_info[2] ? \'true),\' : \'false),\';\n" + + " }\n" + + " }\n" + + " $plugins_code .= \")); ?>\";\n" + + " $template_header .= $plugins_code;\n" + + " $this->_plugin_info = array();\n" + + " }\n" + + "\n" + + " if ($this->_init_smarty_vars) {\n" + + " $template_header .= \"_assign_smarty_interface(); ?>\\n\";\n" + + " $this->_init_smarty_vars = false;\n" + + " }\n" + + "\n" + + " $template_compiled = $template_header . $template_compiled;\n" + + "\n" + + " return true;\n" + + " }\n" + + "\n" + + " /**\n" + + " * Compile a template tag\n" + + " *\n" + + " * @access public\n" + + " * @param $template_tag\n" + + " */\n" + + " function _compile_tag($template_tag)\n" + + " { \n" + + " \n" + + " /* Matched comment. */\n" + + " if ($template_tag{0} == \'*\' && $template_tag{strlen($template_tag) - 1} == \'*\')\n" + + " return \'\';\n" + + " \n" + + " /* Split tag into two three parts: command, command modifiers and the arguments. */\n" + + " if(! preg_match(\'/^(?:(\' . $this->_obj_call_regexp . \'|\' . $this->_var_regexp\n" + + " . \'|\' . $this->_reg_obj_regexp . \'|\\/?\' . $this->_func_regexp . \')(\' . $this->_mod_regexp . \'*))\n" + + " (?:\\s+(.*))?$\n" + + " /xs\', $template_tag, $match)) {\n" + + " $this->_syntax_error(\"unrecognized tag: $template_tag\", E_USER_ERROR, __FILE__, __LINE__);\n" + + " }\n" + + "\n" + + " $tag_command = $match[1];\n" + + " $tag_modifier = isset($match[2]) ? $match[2] : null;\n" + + " $tag_args = isset($match[3]) ? $match[3] : null;\n" + + " \n" + + " \n" + + " /* If the tag name is a variable or object, we process it. */\n" + + " if (preg_match(\'!^\' . $this->_obj_call_regexp . \'|\' . $this->_var_regexp . \'$!\', $tag_command)) {\n" + + " $return = $this->_parse_var_props($tag_command . $tag_modifier, $this->_parse_attrs($tag_args));\n" + + " if(isset($_tag_attrs[\'assign\'])) {\n" + + " return \"assign(\'\" . $this->_dequote($_tag_attrs[\'assign\']) . \"\', $return ); ?>\\n\"; \n" + + " } else {\n" + + " return \"\\n\";\n" + + " }\n" + + " }\n" + + " \n" + + " /* If the tag name is a registered object, we process it. */\n" + + " if (preg_match(\'!^\' . $this->_reg_obj_regexp . \'$!\', $tag_command)) {\n" + + " return $this->_compile_registered_object_tag($tag_command, $this->_parse_attrs($tag_args), $tag_modifier);\n" + + " }\n" + + "\n" + + " switch ($tag_command) {\n" + + " case \'include\':\n" + + " return $this->_compile_include_tag($tag_args);\n" + + "\n" + + " case \'include_php\':\n" + + " return $this->_compile_include_php_tag($tag_args);\n" + + "\n" + + " case \'if\':\n" + + " return $this->_compile_if_tag($tag_args);\n" + + "\n" + + " case \'else\':\n" + + " return \'\';\n" + + "\n" + + " case \'elseif\':\n" + + " return $this->_compile_if_tag($tag_args, true);\n" + + "\n" + + " case \'/if\':\n" + + " return \'\';\n" + + "\n" + + " case \'capture\':\n" + + " return $this->_compile_capture_tag(true, $tag_args);\n" + + "\n" + + " case \'/capture\':\n" + + " return $this->_compile_capture_tag(false);\n" + + "\n" + + " case \'ldelim\':\n" + + " return $this->left_delimiter;\n" + + "\n" + + " case \'rdelim\':\n" + + " return $this->right_delimiter;\n" + + "\n" + + " case \'section\':\n" + + " array_push($this->_sectionelse_stack, false);\n" + + " return $this->_compile_section_start($tag_args);\n" + + "\n" + + " case \'sectionelse\':\n" + + " $this->_sectionelse_stack[count($this->_sectionelse_stack)-1] = true;\n" + + " return \"\";\n" + + "\n" + + " case \'/section\':\n" + + " if (array_pop($this->_sectionelse_stack))\n" + + " return \"\";\n" + + " else\n" + + " return \"\";\n" + + "\n" + + " case \'foreach\':\n" + + " array_push($this->_foreachelse_stack, false);\n" + + " return $this->_compile_foreach_start($tag_args);\n" + + " break;\n" + + "\n" + + " case \'foreachelse\':\n" + + " $this->_foreachelse_stack[count($this->_foreachelse_stack)-1] = true;\n" + + " return \"\";\n" + + "\n" + + " case \'/foreach\':\n" + + " if (array_pop($this->_foreachelse_stack))\n" + + " return \"\";\n" + + " else\n" + + " return \"\";\n" + + "\n" + + " case \'config_load\':\n" + + " return $this->_compile_config_load_tag($tag_args);\n" + + "\n" + + " case \'strip\':\n" + + " case \'/strip\':\n" + + " return $this->left_delimiter.$tag_command.$this->right_delimiter;\n" + + "\n" + + " case \'literal\':\n" + + " list (,$literal_block) = each($this->_literal_blocks);\n" + + " $this->_current_line_no += substr_count($literal_block, \"\\n\");\n" + + " return \"\\n\";\n" + + "\n" + + " case \'php\':\n" + + " if ($this->security && !$this->security_settings[\'PHP_TAGS\']) {\n" + + " $this->_syntax_error(\"(secure mode) php tags not permitted\", E_USER_WARNING, __FILE__, __LINE__);\n" + + " return;\n" + + " }\n" + + " list (,$php_block) = each($this->_php_blocks);\n" + + " $this->_current_line_no += substr_count($php_block, \"\\n\");\n" + + " return \'\';\n" + + "\n" + + " case \'insert\':\n" + + " return $this->_compile_insert_tag($tag_args);\n" + + "\n" + + " default:\n" + + " if ($this->_compile_compiler_tag($tag_command, $tag_args, $output)) {\n" + + " return $output;\n" + + " } else if ($this->_compile_block_tag($tag_command, $tag_args, $tag_modifier, $output)) {\n" + + " return $output;\n" + + " } else {\n" + + " return $this->_compile_custom_tag($tag_command, $tag_args, $tag_modifier);\n" + + " }\n" + + " }\n" + + " }\n" + + "\n" + + "\n" + + " /**\n" + + " * compile the custom compiler tag\n" + + " *\n" + + " * @access public\n" + + " * @param $tag_command\n" + + " * @param $tag_args\n" + + " * @param $output\n" + + " */\n" + + " function _compile_compiler_tag($tag_command, $tag_args, &$output)\n" + + " {\n" + + " $found = false;\n" + + " $have_function = true;\n" + + "\n" + + " /*\n" + + " * First we check if the compiler function has already been registered\n" + + " * or loaded from a plugin file.\n" + + " */\n" + + " if (isset($this->_plugins[\'compiler\'][$tag_command])) {\n" + + " $found = true;\n" + + " $plugin_func = $this->_plugins[\'compiler\'][$tag_command][0];\n" + + " if (!function_exists($plugin_func)) {\n" + + " $message = \"compiler function \'$tag_command\' is not implemented\";\n" + + " $have_function = false;\n" + + " }\n" + + " }\n" + + " /*\n" + + " * Otherwise we need to load plugin file and look for the function\n" + + " * inside it.\n" + + " */\n" + + " else if ($plugin_file = $this->_get_plugin_filepath(\'compiler\', $tag_command)) {\n" + + " $found = true;\n" + + "\n" + + " include_once $plugin_file;\n" + + "\n" + + " $plugin_func = \'smarty_compiler_\' . $tag_command;\n" + + " if (!function_exists($plugin_func)) {\n" + + " $message = \"plugin function $plugin_func() not found in $plugin_file\\n\";\n" + + " $have_function = false;\n" + + " } else {\n" + + " $this->_plugins[\'compiler\'][$tag_command] = array($plugin_func, null, null);\n" + + " }\n" + + " }\n" + + "\n" + + " /*\n" + + " * True return value means that we either found a plugin or a\n" + + " * dynamically registered function. False means that we didn\'t and the\n" + + " * compiler should now emit code to load custom function plugin for this\n" + + " * tag.\n" + + " */\n" + + " if ($found) {\n" + + " if ($have_function) {\n" + + " $output = \'\';\n" + + " } else {\n" + + " $this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__);\n" + + " }\n" + + " return true;\n" + + " } else {\n" + + " return false;\n" + + " }\n" + + " }\n" + + "\n" + + "\n" + + " /**\n" + + " * compile block function tag\n" + + " *\n" + + " * @access public\n" + + " * @param $tag_command\n" + + " * @param $tag_args\n" + + " * @param $tag_modifier\n" + + " * @param $output\n" + + " */\n" + + " function _compile_block_tag($tag_command, $tag_args, $tag_modifier, &$output)\n" + + " {\n" + + " if ($tag_command{0} == \'/\') {\n" + + " $start_tag = false;\n" + + " $tag_command = substr($tag_command, 1);\n" + + " } else\n" + + " $start_tag = true;\n" + + "\n" + + " $found = false;\n" + + " $have_function = true;\n" + + "\n" + + " /*\n" + + " * First we check if the block function has already been registered\n" + + " * or loaded from a plugin file.\n" + + " */\n" + + " if (isset($this->_plugins[\'block\'][$tag_command])) {\n" + + " $found = true;\n" + + " $plugin_func = $this->_plugins[\'block\'][$tag_command][0];\n" + + " if (!function_exists($plugin_func)) {\n" + + " $message = \"block function \'$tag_command\' is not implemented\";\n" + + " $have_function = false;\n" + + " }\n" + + " }\n" + + " /*\n" + + " * Otherwise we need to load plugin file and look for the function\n" + + " * inside it.\n" + + " */\n" + + " else if ($plugin_file = $this->_get_plugin_filepath(\'block\', $tag_command)) {\n" + + " $found = true;\n" + + "\n" + + " include_once $plugin_file;\n" + + "\n" + + " $plugin_func = \'smarty_block_\' . $tag_command;\n" + + " if (!function_exists($plugin_func)) {\n" + + " $message = \"plugin function $plugin_func() not found in $plugin_file\\n\";\n" + + " $have_function = false;\n" + + " } else {\n" + + " $this->_plugins[\'block\'][$tag_command] = array($plugin_func, null, null);\n" + + " }\n" + + " }\n" + + "\n" + + " if (!$found) {\n" + + " return false;\n" + + " } else if (!$have_function) {\n" + + " $this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__);\n" + + " return true;\n" + + " }\n" + + "\n" + + " /*\n" + + " * Even though we\'ve located the plugin function, compilation\n" + + " * happens only once, so the plugin will still need to be loaded\n" + + " * at runtime for future requests.\n" + + " */\n" + + " $this->_add_plugin(\'block\', $tag_command);\n" + + "\n" + + " if ($start_tag) {\n" + + " $arg_list = array();\n" + + " $attrs = $this->_parse_attrs($tag_args);\n" + + " foreach ($attrs as $arg_name => $arg_value) {\n" + + " if (is_bool($arg_value))\n" + + " $arg_value = $arg_value ? \'true\' : \'false\';\n" + + " $arg_list[] = \"\'$arg_name\' => $arg_value\";\n" + + " }\n" + + "\n" + + " $output = \"_tag_stack[] = array(\'$tag_command\', array(\".implode(\',\', (array)$arg_list).\")); \\$this->_plugins[\'block\'][\'$tag_command\'][0](array(\".implode(\',\', (array)$arg_list).\"), null, \\$this); ob_start(); ?>\";\n" + + " } else {\n" + + " $output = \"_block_content = ob_get_contents(); ob_end_clean(); \";\n" + + " $out_tag_text = \"\\$this->_plugins[\'block\'][\'$tag_command\'][0](\\$this->_tag_stack[count(\\$this->_tag_stack)-1][1], \\$this->_block_content, \\$this)\";\n" + + " if($tag_modifier != \'\') {\n" + + " $this->_parse_modifiers($out_tag_text, $tag_modifier);\n" + + " }\n" + + " $output .= \'echo \' . $out_tag_text . \';\';\n" + + " $output .= \" array_pop(\\$this->_tag_stack); ?>\";\n" + + " }\n" + + "\n" + + " return true;\n" + + " }\n" + + "\n" + + "\n" + + " /**\n" + + " * compile custom function tag\n" + + " *\n" + + " * @access public\n" + + " * @param $tag_command\n" + + " * @param $tag_args\n" + + " * @param $tag_modifier\n" + + " */\n" + + " function _compile_custom_tag($tag_command, $tag_args, $tag_modifier)\n" + + " {\n" + + " $this->_add_plugin(\'function\', $tag_command);\n" + + "\n" + + " $arg_list = array();\n" + + " $attrs = $this->_parse_attrs($tag_args);\n" + + " foreach ($attrs as $arg_name => $arg_value) {\n" + + " if (is_bool($arg_value))\n" + + " $arg_value = $arg_value ? \'true\' : \'false\';\n" + + " $arg_list[] = \"\'$arg_name\' => $arg_value\";\n" + + " }\n" + + " \n" + + " $return = \"\\$this->_plugins[\'function\'][\'$tag_command\'][0](array(\".implode(\',\', (array)$arg_list).\"), \\$this)\";\n" + + " \n" + + " if($tag_modifier != \'\') {\n" + + " $this->_parse_modifiers($return, $tag_modifier);\n" + + " }\n" + + " \n" + + " return \'\\n\";\n" + + " }\n" + + "\n" + + " /**\n" + + " * compile a registered object tag\n" + + " *\n" + + " * @access public\n" + + " * @param $tag_command\n" + + " * @param $attrs\n" + + " * @param $tag_modifier\n" + + " */\n" + + " function _compile_registered_object_tag($tag_command, $attrs, $tag_modifier)\n" + + " {\n" + + " list($object, $obj_comp) = explode(\'->\', $tag_command);\n" + + "\n" + + " $arg_list = array();\n" + + " if(count($attrs)) {\n" + + " $_assign_var = false;\n" + + " foreach ($attrs as $arg_name => $arg_value) {\n" + + " if($arg_name == \'assign\') {\n" + + " $_assign_var = $arg_value;\n" + + " unset($attrs[\'assign\']);\n" + + " continue;\n" + + " }\n" + + " if (is_bool($arg_value))\n" + + " $arg_value = $arg_value ? \'true\' : \'false\';\n" + + " $arg_list[] = \"\'$arg_name\' => $arg_value\";\n" + + " }\n" + + " }\n" + + " \n" + + " if(!is_object($this->_reg_objects[$object][0])) {\n" + + " $this->_trigger_fatal_error(\"registered \'$object\' is not an object\");\n" + + " } elseif(!empty($this->_reg_objects[$object][1]) && !in_array($obj_comp, $this->_reg_objects[$object][1])) {\n" + + " $this->_trigger_fatal_error(\"\'$obj_comp\' is not a registered component of object \'$object\'\");\n" + + " } elseif(method_exists($this->_reg_objects[$object][0], $obj_comp)) {\n" + + " // method\n" + + " if($this->_reg_objects[$object][2]) {\n" + + " // smarty object argument format\n" + + " $return = \"\\$this->_reg_objects[\'$object\'][0]->$obj_comp(array(\".implode(\',\', (array)$arg_list).\"), \\$this)\";\n" + + " } else {\n" + + " // traditional argument format\n" + + " $return = \"\\$this->_reg_objects[\'$object\'][0]->$obj_comp(\".implode(\',\', array_values($attrs)).\")\";\n" + + " }\n" + + " } else {\n" + + " // property\n" + + " $return = \"\\$this->_reg_objects[\'$object\'][0]->$obj_comp\";\n" + + " }\n" + + " \n" + + " if($tag_modifier != \'\') {\n" + + " $this->_parse_modifiers($return, $tag_modifier);\n" + + " }\n" + + " \n" + + " if($_assign_var) {\n" + + " return \"assign(\'\" . $this->_dequote($_assign_var) .\"\', $return); ?>\\n\";\n" + + " } else {\n" + + " return \'\\n\";\n" + + " }\n" + + " }\n" + + " \n" + + " \n" + + "\n" + + " /**\n" + + " * Compile {insert ...} tag\n" + + " *\n" + + " * @access public\n" + + " * @param $tag_args\n" + + " */\n" + + " function _compile_insert_tag($tag_args)\n" + + " {\n" + + " $attrs = $this->_parse_attrs($tag_args);\n" + + " $name = $this->_dequote($attrs[\'name\']);\n" + + "\n" + + " if (empty($name)) {\n" + + " $this->_syntax_error(\"missing insert name\", E_USER_ERROR, __FILE__, __LINE__);\n" + + " }\n" + + "\n" + + " if (!empty($attrs[\'script\'])) {\n" + + " $delayed_loading = true;\n" + + " } else {\n" + + " $delayed_loading = false; \n" + + " }\n" + + "\n" + + " foreach ($attrs as $arg_name => $arg_value) {\n" + + " if (is_bool($arg_value))\n" + + " $arg_value = $arg_value ? \'true\' : \'false\';\n" + + " $arg_list[] = \"\'$arg_name\' => $arg_value\";\n" + + " }\n" + + "\n" + + " $this->_add_plugin(\'insert\', $name, $delayed_loading);\n" + + "\n" + + " return \"_run_insert_handler(array(\".implode(\', \', (array)$arg_list).\")); ?>\\n\";\n" + + " }\n" + + "\n" + + "\n" + + " /**\n" + + " * Compile {config_load ...} tag\n" + + " *\n" + + " * @access public\n" + + " * @param $tag_args\n" + + " */\n" + + " function _compile_config_load_tag($tag_args)\n" + + " {\n" + + " $attrs = $this->_parse_attrs($tag_args);\n" + + "\n" + + " if (empty($attrs[\'file\'])) {\n" + + " $this->_syntax_error(\"missing \'file\' attribute in config_load tag\", E_USER_ERROR, __FILE__, __LINE__);\n" + + " }\n" + + "\n" + + " if (empty($attrs[\'section\'])) {\n" + + " $attrs[\'section\'] = \'null\';\n" + + " }\n" + + "\n" + + " if (isset($attrs[\'scope\'])) {\n" + + " $scope = @$this->_dequote($attrs[\'scope\']);\r\n" + + " if ($scope != \'local\' &&\r\n" + + " $scope != \'parent\' &&\r\n" + + " $scope != \'global\') {\r\n" + + " $this->_syntax_error(\"invalid \'scope\' attribute value\", E_USER_ERROR, __FILE__, __LINE__);\r\n" + + " }\r\n" + + " } else {\r\n" + + " if (isset($attrs[\'global\']) && $attrs[\'global\'])\r\n" + + " $scope = \'parent\';\r\n" + + " else\r\n" + + " $scope = \'local\';\r\n" + + " }\r\n" + + "\r\n" + + " return \'config_load(\' . $attrs[\'file\'] . \', \' . $attrs[\'section\'] . \", \'$scope\'); ?>\";\r\n" + + " }\r\n" + + "\r\n" + + "\r\n" + + " /**\r\n" + + " * Compile {include ...} tag\r\n" + + " *\r\n" + + " * @access public\r\n" + + " * $param $tag_args\r\n" + + " */\r\n" + + " function _compile_include_tag($tag_args)\r\n" + + " {\r\n" + + " $attrs = $this->_parse_attrs($tag_args);\r\n" + + " $arg_list = array();\r\n" + + "\r\n" + + " if (empty($attrs[\'file\'])) {\r\n" + + " $this->_syntax_error(\"missing \'file\' attribute in include tag\", E_USER_ERROR, __FILE__, __LINE__);\r\n" + + " }\r\n" + + "\r\n" + + " foreach ($attrs as $arg_name => $arg_value) {\r\n" + + " if ($arg_name == \'file\') {\r\n" + + " $include_file = $arg_value;\r\n" + + " continue;\r\n" + + " } else if ($arg_name == \'assign\') {\r\n" + + " $assign_var = $arg_value;\r\n" + + " continue;\r\n" + + " }\r\n" + + " if (is_bool($arg_value))\r\n" + + " $arg_value = $arg_value ? \'true\' : \'false\';\r\n" + + " $arg_list[] = \"\'$arg_name\' => $arg_value\";\r\n" + + " }\r\n" + + "\r\n" + + " $output = \'_tpl_vars;\\n\" .\r\n" + + " \"\\$this->_smarty_include(\".$include_file.\", array(\".implode(\',\', (array)$arg_list).\"));\\n\" .\r\n" + + " \"\\$this->_tpl_vars = \\$_smarty_tpl_vars;\\n\" .\r\n" + + " \"unset(\\$_smarty_tpl_vars);\\n\";\r\n" + + "\r\n" + + " if (isset($assign_var)) {\r\n" + + " $output .= \"\\$this->assign(\" . $assign_var . \", ob_get_contents()); ob_end_clean();\\n\";\r\n" + + " }\r\n" + + "\r\n" + + " $output .= \' ?>\';\r\n" + + "\r\n" + + " return $output;\r\n" + + "\r\n" + + " }\r\n" + + "\r\n" + + " /**\r\n" + + " * Compile {include ...} tag\r\n" + + " *\r\n" + + " * @access public\r\n" + + " * @param $tag_args\r\n" + + " */\r\n" + + " function _compile_include_php_tag($tag_args)\r\n" + + " {\r\n" + + " $attrs = $this->_parse_attrs($tag_args);\r\n" + + "\r\n" + + " if (empty($attrs[\'file\'])) {\r\n" + + " $this->_syntax_error(\"missing \'file\' attribute in include_php tag\", E_USER_ERROR, __FILE__, __LINE__);\r\n" + + " }\r\n" + + "\r\n" + + " $assign_var = $this->_dequote($attrs[\'assign\']);\r\n" + + "\r\n" + + " $once_var = ( $attrs[\'once\'] === false ) ? \'false\' : \'true\';\r\n" + + "\r\n" + + " foreach($attrs as $arg_name => $arg_value) {\r\n" + + " if($arg_name != \'file\' AND $arg_name != \'once\' AND $arg_name != \'assign\') {\r\n" + + " if(is_bool($arg_value))\r\n" + + " $arg_value = $arg_value ? \'true\' : \'false\';\r\n" + + " $arg_list[] = \"\'$arg_name\' => $arg_value\";\r\n" + + " }\r\n" + + " }\r\n" + + "\r\n" + + " $output =\r\n" + + " \"_smarty_include_php($attrs[file], \'$assign_var\', $once_var, \" .\r\n" + + " \"array(\".implode(\',\', (array)$arg_list).\")); ?>\";\r\n" + + " \r\n" + + " return $output;\r\n" + + " }\r\n" + + " \r\n" + + "\r\n" + + " /**\r\n" + + " * Compile {section ...} tag\r\n" + + " *\r\n" + + " * @access public\r\n" + + " * @param $tag_args\r\n" + + " */\r\n" + + " function _compile_section_start($tag_args)\r\n" + + " {\r\n" + + " $attrs = $this->_parse_attrs($tag_args);\r\n" + + " $arg_list = array();\r\n" + + "\r\n" + + " $output = \'_syntax_error(\"missing section name\", E_USER_ERROR, __FILE__, __LINE__);\r\n" + + " }\r\n" + + "\r\n" + + " $output .= \"if (isset(\\$this->_sections[$section_name])) unset(\\$this->_sections[$section_name]);\\n\";\r\n" + + " $section_props = \"\\$this->_sections[$section_name]\";\r\n" + + "\r\n" + + " foreach ($attrs as $attr_name => $attr_value) {\r\n" + + " switch ($attr_name) {\r\n" + + " case \'loop\':\r\n" + + " $output .= \"{$section_props}[\'loop\'] = is_array($attr_value) ? count($attr_value) : max(0, (int)$attr_value);\\n\";\r\n" + + " break;\r\n" + + "\r\n" + + " case \'show\':\r\n" + + " if (is_bool($attr_value))\r\n" + + " $show_attr_value = $attr_value ? \'true\' : \'false\';\r\n" + + " else\r\n" + + " $show_attr_value = \"(bool)$attr_value\";\r\n" + + " $output .= \"{$section_props}[\'show\'] = $show_attr_value;\\n\";\r\n" + + " break;\r\n" + + "\r\n" + + " case \'name\':\r\n" + + " $output .= \"{$section_props}[\'$attr_name\'] = $attr_value;\\n\";\r\n" + + " break;\r\n" + + "\r\n" + + " case \'max\':\r\n" + + " case \'start\':\r\n" + + " $output .= \"{$section_props}[\'$attr_name\'] = (int)$attr_value;\\n\";\r\n" + + " break;\r\n" + + "\r\n" + + " case \'step\':\r\n" + + " $output .= \"{$section_props}[\'$attr_name\'] = ((int)$attr_value) == 0 ? 1 : (int)$attr_value;\\n\";\r\n" + + " break;\r\n" + + "\r\n" + + " default:\r\n" + + " $this->_syntax_error(\"unknown section attribute - \'$attr_name\'\", E_USER_ERROR, __FILE__, __LINE__);\r\n" + + " break;\r\n" + + " }\r\n" + + " }\r\n" + + "\r\n" + + " if (!isset($attrs[\'show\']))\r\n" + + " $output .= \"{$section_props}[\'show\'] = true;\\n\";\r\n" + + "\r\n" + + " if (!isset($attrs[\'loop\']))\r\n" + + " $output .= \"{$section_props}[\'loop\'] = 1;\\n\";\r\n" + + "\r\n" + + " if (!isset($attrs[\'max\']))\r\n" + + " $output .= \"{$section_props}[\'max\'] = {$section_props}[\'loop\'];\\n\";\r\n" + + " else\r\n" + + " $output .= \"if ({$section_props}[\'max\'] < 0)\\n\" .\r\n" + + " \" {$section_props}[\'max\'] = {$section_props}[\'loop\'];\\n\";\r\n" + + "\r\n" + + " if (!isset($attrs[\'step\']))\r\n" + + " $output .= \"{$section_props}[\'step\'] = 1;\\n\";\r\n" + + "\r\n" + + " if (!isset($attrs[\'start\']))\r\n" + + " $output .= \"{$section_props}[\'start\'] = {$section_props}[\'step\'] > 0 ? 0 : {$section_props}[\'loop\']-1;\\n\";\r\n" + + " else {\r\n" + + " $output .= \"if ({$section_props}[\'start\'] < 0)\\n\" .\r\n" + + " \" {$section_props}[\'start\'] = max({$section_props}[\'step\'] > 0 ? 0 : -1, {$section_props}[\'loop\'] + {$section_props}[\'start\']);\\n\" .\r\n" + + " \"else\\n\" .\r\n" + + " \" {$section_props}[\'start\'] = min({$section_props}[\'start\'], {$section_props}[\'step\'] > 0 ? {$section_props}[\'loop\'] : {$section_props}[\'loop\']-1);\\n\";\r\n" + + " }\r\n" + + "\r\n" + + " $output .= \"if ({$section_props}[\'show\']) {\\n\";\r\n" + + " if (!isset($attrs[\'start\']) && !isset($attrs[\'step\']) && !isset($attrs[\'max\'])) {\r\n" + + " $output .= \" {$section_props}[\'total\'] = {$section_props}[\'loop\'];\\n\";\r\n" + + " } else {\r\n" + + " $output .= \" {$section_props}[\'total\'] = min(ceil(({$section_props}[\'step\'] > 0 ? {$section_props}[\'loop\'] - {$section_props}[\'start\'] : {$section_props}[\'start\']+1)/abs({$section_props}[\'step\'])), {$section_props}[\'max\']);\\n\";\r\n" + + " }\r\n" + + " $output .= \" if ({$section_props}[\'total\'] == 0)\\n\" .\r\n" + + " \" {$section_props}[\'show\'] = false;\\n\" .\r\n" + + " \"} else\\n\" .\r\n" + + " \" {$section_props}[\'total\'] = 0;\\n\";\r\n" + + "\r\n" + + " $output .= \"if ({$section_props}[\'show\']):\\n\";\r\n" + + " $output .= \"\r\n" + + " for ({$section_props}[\'index\'] = {$section_props}[\'start\'], {$section_props}[\'iteration\'] = 1;\r\n" + + " {$section_props}[\'iteration\'] <= {$section_props}[\'total\'];\r\n" + + " {$section_props}[\'index\'] += {$section_props}[\'step\'], {$section_props}[\'iteration\']++):\\n\";\r\n" + + " $output .= \"{$section_props}[\'rownum\'] = {$section_props}[\'iteration\'];\\n\";\r\n" + + " $output .= \"{$section_props}[\'index_prev\'] = {$section_props}[\'index\'] - {$section_props}[\'step\'];\\n\";\r\n" + + " $output .= \"{$section_props}[\'index_next\'] = {$section_props}[\'index\'] + {$section_props}[\'step\'];\\n\";\r\n" + + " $output .= \"{$section_props}[\'first\'] = ({$section_props}[\'iteration\'] == 1);\\n\";\r\n" + + " $output .= \"{$section_props}[\'last\'] = ({$section_props}[\'iteration\'] == {$section_props}[\'total\']);\\n\";\r\n" + + "\r\n" + + " $output .= \"?>\";\r\n" + + "\r\n" + + " return $output;\r\n" + + " }\r\n" + + "\r\n" + + " \r\n" + + " /**\r\n" + + " * Compile {foreach ...} tag.\r\n" + + " *\r\n" + + " * @access public\r\n" + + " * @param $tag_args\r\n" + + " */\r\n" + + " function _compile_foreach_start($tag_args)\r\n" + + " {\r\n" + + " $attrs = $this->_parse_attrs($tag_args);\r\n" + + " $arg_list = array();\r\n" + + "\r\n" + + " if (empty($attrs[\'from\'])) {\r\n" + + " $this->_syntax_error(\"missing \'from\' attribute\", E_USER_ERROR, __FILE__, __LINE__);\r\n" + + " }\r\n" + + "\r\n" + + " if (empty($attrs[\'item\'])) {\r\n" + + " $this->_syntax_error(\"missing \'item\' attribute\", E_USER_ERROR, __FILE__, __LINE__);\r\n" + + " }\r\n" + + "\r\n" + + " $from = $attrs[\'from\'];\r\n" + + " $item = $this->_dequote($attrs[\'item\']);\r\n" + + " if (isset($attrs[\'name\']))\r\n" + + " $name = $attrs[\'name\'];\r\n" + + "\r\n" + + " $output = \'_foreach[$name])) unset(\\$this->_foreach[$name]);\\n\";\r\n" + + " $foreach_props = \"\\$this->_foreach[$name]\";\r\n" + + " }\r\n" + + "\r\n" + + " $key_part = \'\';\r\n" + + "\r\n" + + " foreach ($attrs as $attr_name => $attr_value) {\r\n" + + " switch ($attr_name) {\r\n" + + " case \'key\':\r\n" + + " $key = $this->_dequote($attrs[\'key\']);\r\n" + + " $key_part = \"\\$this->_tpl_vars[\'$key\'] => \";\r\n" + + " break;\r\n" + + "\r\n" + + " case \'name\':\r\n" + + " $output .= \"{$foreach_props}[\'$attr_name\'] = $attr_value;\\n\";\r\n" + + " break;\r\n" + + " }\r\n" + + " }\r\n" + + "\r\n" + + " if (isset($name)) {\r\n" + + " $output .= \"{$foreach_props}[\'total\'] = count((array)$from);\\n\";\r\n" + + " $output .= \"{$foreach_props}[\'show\'] = {$foreach_props}[\'total\'] > 0;\\n\";\r\n" + + " $output .= \"if ({$foreach_props}[\'show\']):\\n\";\r\n" + + " $output .= \"{$foreach_props}[\'iteration\'] = 0;\\n\";\r\n" + + " $output .= \" foreach ((array)$from as $key_part\\$this->_tpl_vars[\'$item\']):\\n\";\r\n" + + " $output .= \" {$foreach_props}[\'iteration\']++;\\n\";\r\n" + + " $output .= \" {$foreach_props}[\'first\'] = ({$foreach_props}[\'iteration\'] == 1);\\n\";\r\n" + + " $output .= \" {$foreach_props}[\'last\'] = ({$foreach_props}[\'iteration\'] == {$foreach_props}[\'total\']);\\n\";\r\n" + + " } else {\r\n" + + " $output .= \"if (count((array)$from)):\\n\";\r\n" + + " $output .= \" foreach ((array)$from as $key_part\\$this->_tpl_vars[\'$item\']):\\n\";\r\n" + + " }\r\n" + + " $output .= \'?>\';\r\n" + + "\r\n" + + " return $output;\r\n" + + " }\r\n" + + "\r\n" + + "\r\n" + + " /**\r\n" + + " * Compile {capture} .. {/capture} tags\r\n" + + " *\r\n" + + " * @access public\r\n" + + " * @param $start\r\n" + + " * @param $tag_args\r\n" + + " */\r\n" + + " function _compile_capture_tag($start, $tag_args = \'\')\r\n" + + " {\r\n" + + " $attrs = $this->_parse_attrs($tag_args);\r\n" + + "\r\n" + + " if ($start) {\r\n" + + " if (isset($attrs[\'name\']))\r\n" + + " $buffer = $attrs[\'name\'];\r\n" + + " else\r\n" + + " $buffer = \"\'default\'\";\r\n" + + "\r\n" + + " $output = \"\";\r\n" + + " $this->_capture_stack[] = $buffer;\r\n" + + " } else {\r\n" + + " $buffer = array_pop($this->_capture_stack);\r\n" + + " $output = \"_smarty_vars[\'capture\'][$buffer] = ob_get_contents(); ob_end_clean(); ?>\";\r\n" + + " }\r\n" + + "\r\n" + + " return $output;\r\n" + + " }\r\n" + + "\r\n" + + " /**\r\n" + + " * Compile {if ...} tag\r\n" + + " *\r\n" + + " * @access public\r\n" + + " * @param $tag_args\r\n" + + " * @param $elseif\r\n" + + " */\r\n" + + " function _compile_if_tag($tag_args, $elseif = false)\r\n" + + " {\r\n" + + "\r\n" + + " /* Tokenize args for \'if\' tag. */\r\n" + + " preg_match_all(\'/(?>\r\n" + + " \' . $this->_obj_call_regexp . \'(?:\' . $this->_mod_regexp . \'*) | # valid object call\r\n" + + " \' . $this->_var_regexp . \'(?:\' . $this->_mod_regexp . \'*) | # public or quoted string\r\n" + + " \\-?\\d+|!==|<=>|==|!=|<=|>=|\\&\\&|\\|\\||\\(|\\)|,|\\!|\\^|=|<|>|\\||\\%|\\+|\\-|\\/|\\* | # valid non-word token\r\n" + + " \\b\\w+\\b | # valid word token\r\n" + + " \\S+ # anything else\r\n" + + " )/x\', $tag_args, $match);\r\n" + + " \r\n" + + " $tokens = $match[0];\r\n" + + " \r\n" + + " // make sure we have balanced parenthesis\r\n" + + " $token_count = array_count_values($tokens);\r\n" + + " if(isset($token_count[\'(\']) && $token_count[\'(\'] != $token_count[\')\']) {\r\n" + + " $this->_syntax_error(\"unbalanced parenthesis in if statement\", E_USER_ERROR, __FILE__, __LINE__);\r\n" + + " }\r\n" + + " \r\n" + + " $is_arg_stack = array();\r\n" + + "\r\n" + + " for ($i = 0; $i < count($tokens); $i++) {\r\n" + + "\r\n" + + " $token = &$tokens[$i];\r\n" + + " \r\n" + + " switch (strtolower($token)) {\r\n" + + " case \'!\':\r\n" + + " case \'%\':\r\n" + + " case \'!==\':\r\n" + + " case \'==\':\r\n" + + " case \'>\':\r\n" + + " case \'<\':\r\n" + + " case \'!=\':\r\n" + + " case \'<=\':\r\n" + + " case \'>=\':\r\n" + + " case \'&&\':\r\n" + + " case \'||\':\r\n" + + " case \'|\':\r\n" + + " case \'^\':\r\n" + + " case \'&\':\r\n" + + " case \'~\':\r\n" + + " case \')\':\r\n" + + " case \',\':\r\n" + + " case \'+\':\r\n" + + " case \'-\':\r\n" + + " case \'*\':\r\n" + + " case \'/\':\r\n" + + " break; \r\n" + + "\r\n" + + " case \'eq\':\r\n" + + " $token = \'==\';\r\n" + + " break;\r\n" + + "\r\n" + + " case \'ne\':\r\n" + + " case \'neq\':\r\n" + + " $token = \'!=\';\r\n" + + " break;\r\n" + + "\r\n" + + " case \'lt\':\r\n" + + " $token = \'<\';\r\n" + + " break;\r\n" + + "\r\n" + + " case \'le\':\r\n" + + " case \'lte\':\r\n" + + " $token = \'<=\';\r\n" + + " break;\r\n" + + "\r\n" + + " case \'gt\':\r\n" + + " $token = \'>\';\r\n" + + " break;\r\n" + + "\r\n" + + " case \'ge\':\r\n" + + " case \'gte\':\r\n" + + " $token = \'>=\';\r\n" + + " break;\r\n" + + "\r\n" + + " case \'and\':\r\n" + + " $token = \'&&\';\r\n" + + " break;\r\n" + + "\r\n" + + " case \'or\':\r\n" + + " $token = \'||\';\r\n" + + " break;\r\n" + + "\r\n" + + " case \'not\':\r\n" + + " $token = \'!\';\r\n" + + " break;\r\n" + + "\r\n" + + " case \'mod\':\r\n" + + " $token = \'%\';\r\n" + + " break;\r\n" + + "\r\n" + + " case \'(\':\r\n" + + " array_push($is_arg_stack, $i);\r\n" + + " break;\r\n" + + " \r\n" + + " case \'is\':\r\n" + + " /* If last token was a \')\', we operate on the parenthesized\r\n" + + " expression. The start of the expression is on the stack.\r\n" + + " Otherwise, we operate on the last encountered token. */\r\n" + + " if ($tokens[$i-1] == \')\')\r\n" + + " $is_arg_start = array_pop($is_arg_stack);\r\n" + + " else\r\n" + + " $is_arg_start = $i-1;\r\n" + + " /* Construct the argument for \'is\' expression, so it knows\r\n" + + " what to operate on. */\r\n" + + " $is_arg = implode(\' \', array_slice($tokens, $is_arg_start, $i - $is_arg_start));\r\n" + + " \r\n" + + " /* Pass all tokens from next one until the end to the\r\n" + + " \'is\' expression parsing function. The function will\r\n" + + " return modified tokens, where the first one is the result\r\n" + + " of the \'is\' expression and the rest are the tokens it\r\n" + + " didn\'t touch. */ \r\n" + + " $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1));\r\n" + + " \r\n" + + " /* Replace the old tokens with the new ones. */\r\n" + + " array_splice($tokens, $is_arg_start, count($tokens), $new_tokens);\r\n" + + "\r\n" + + " /* Adjust argument start so that it won\'t change from the\r\n" + + " current position for the next iteration. */\r\n" + + " $i = $is_arg_start;\r\n" + + " break;\r\n" + + " \r\n" + + " default:\r\n" + + " if(preg_match(\'!^\' . $this->_func_regexp . \'$!\', $token) ) {\r\n" + + " // function call \r\n" + + " if($this->security &&\r\n" + + " !in_array($token, $this->security_settings[\'IF_FUNCS\'])) {\r\n" + + " $this->_syntax_error(\"(secure mode) \'$token\' not allowed in if statement\", E_USER_ERROR, __FILE__, __LINE__);\r\n" + + " } \r\n" + + " } elseif(preg_match(\'!^\' . $this->_var_regexp . \'(?:\' . $this->_mod_regexp . \'*)$!\', $token)) {\r\n" + + " // variable\r\n" + + " $token = $this->_parse_var_props($token);\r\n" + + " } elseif(preg_match(\'!^\' . $this->_obj_call_regexp . \'(?:\' . $this->_mod_regexp . \'*)$!\', $token)) {\r\n" + + " // object\r\n" + + " $token = $this->_parse_var_props($token);\r\n" + + " } elseif(is_numeric($token)) {\r\n" + + " // number, skip it\r\n" + + " } else {\r\n" + + " $this->_syntax_error(\"unidentified token \'$token\'\", E_USER_ERROR, __FILE__, __LINE__);\r\n" + + " }\r\n" + + " break;\r\n" + + " }\r\n" + + " }\r\n" + + " \r\n" + + " if ($elseif)\r\n" + + " return \'\';\r\n" + + " else\r\n" + + " return \'\';\r\n" + + " }\r\n" + + "\r\n" + + "\r\n" + + " /**\r\n" + + " * Parse is expression\r\n" + + " *\r\n" + + " * @access public\r\n" + + " * @param $is_arg\r\n" + + " * @param $tokens\r\n" + + " */\r\n" + + " function _parse_is_expr($is_arg, $tokens)\r\n" + + " {\r\n" + + " $expr_end = 0;\r\n" + + " $negate_expr = false;\r\n" + + "\r\n" + + " if (($first_token = array_shift($tokens)) == \'not\') {\r\n" + + " $negate_expr = true;\r\n" + + " $expr_type = array_shift($tokens);\r\n" + + " } else\r\n" + + " $expr_type = $first_token;\r\n" + + "\r\n" + + " switch ($expr_type) {\r\n" + + " case \'even\':\r\n" + + " if (@$tokens[$expr_end] == \'by\') {\r\n" + + " $expr_end++;\r\n" + + " $expr_arg = $tokens[$expr_end++];\r\n" + + " $expr = \"!(($is_arg / $expr_arg) % \" . $this->_parse_var_props($expr_arg) . \")\";\r\n" + + " } else\r\n" + + " $expr = \"!($is_arg % 2)\";\r\n" + + " break;\r\n" + + "\r\n" + + " case \'odd\':\r\n" + + " if (@$tokens[$expr_end] == \'by\') {\r\n" + + " $expr_end++;\r\n" + + " $expr_arg = $tokens[$expr_end++];\r\n" + + " $expr = \"(($is_arg / $expr_arg) % \". $this->_parse_var_props($expr_arg) . \")\";\r\n" + + " } else\r\n" + + " $expr = \"($is_arg % 2)\";\r\n" + + " break;\r\n" + + "\r\n" + + " case \'div\':\r\n" + + " if (@$tokens[$expr_end] == \'by\') {\r\n" + + " $expr_end++;\r\n" + + " $expr_arg = $tokens[$expr_end++];\r\n" + + " $expr = \"!($is_arg % \" . $this->_parse_var_props($expr_arg) . \")\";\r\n" + + " } else {\r\n" + + " $this->_syntax_error(\"expecting \'by\' after \'div\'\", E_USER_ERROR, __FILE__, __LINE__);\r\n" + + " }\r\n" + + " break;\r\n" + + "\r\n" + + " default:\r\n" + + " $this->_syntax_error(\"unknown \'is\' expression - \'$expr_type\'\", E_USER_ERROR, __FILE__, __LINE__);\r\n" + + " break;\r\n" + + " }\r\n" + + "\r\n" + + " if ($negate_expr) {\r\n" + + " $expr = \"!($expr)\";\r\n" + + " }\r\n" + + " \r\n" + + " array_splice($tokens, 0, $expr_end, $expr); \r\n" + + " \r\n" + + " return $tokens;\r\n" + + " }\r\n" + + "\r\n" + + "\r\n" + + " /**\r\n" + + " * Parse attribute string\r\n" + + " *\r\n" + + " * @access public\r\n" + + " * @param $tag_args\r\n" + + " * @param $quote\r\n" + + " */\r\n" + + " function _parse_attrs($tag_args, $quote = true)\r\n" + + " {\r\n" + + " \r\n" + + " /* Tokenize tag attributes. */\r\n" + + " preg_match_all(\'/(?:\' . $this->_obj_call_regexp . \'|\' . $this->_qstr_regexp . \' | (?>[^\"\\\'=\\s]+)\r\n" + + " )+ |\r\n" + + " [=]\r\n" + + " /x\', $tag_args, $match);\r\n" + + " $tokens = $match[0]; \r\n" + + " \r\n" + + " $attrs = array();\r\n" + + " /* Parse state:\r\n" + + " 0 - expecting attribute name\r\n" + + " 1 - expecting \'=\'\r\n" + + " 2 - expecting attribute value (not \'=\') */\r\n" + + " $state = 0;\r\n" + + " \r\n" + + " foreach ($tokens as $token) {\r\n" + + " switch ($state) {\r\n" + + " case 0:\r\n" + + " /* If the token is a valid identifier, we set attribute name\r\n" + + " and go to state 1. */\r\n" + + " if (preg_match(\'!^\\w+$!\', $token)) {\r\n" + + " $attr_name = $token;\r\n" + + " $state = 1;\r\n" + + " } else\r\n" + + " $this->_syntax_error(\"invalid attribute name - \'$token\'\", E_USER_ERROR, __FILE__, __LINE__);\r\n" + + " break;\r\n" + + "\r\n" + + " case 1:\r\n" + + " /* If the token is \'=\', then we go to state 2. */\r\n" + + " if ($token == \'=\') {\r\n" + + " $state = 2;\r\n" + + " } else\r\n" + + " $this->_syntax_error(\"expecting \'=\' after attribute name \'$last_token\'\", E_USER_ERROR, __FILE__, __LINE__);\r\n" + + " break;\r\n" + + "\r\n" + + " case 2:\r\n" + + " /* If token is not \'=\', we set the attribute value and go to\r\n" + + " state 0. */\r\n" + + " if ($token != \'=\') {\r\n" + + " /* We booleanize the token if it\'s a non-quoted possible\r\n" + + " boolean value. */\r\n" + + " if (preg_match(\'!^(on|yes|true)$!\', $token))\r\n" + + " $token = true;\r\n" + + " else if (preg_match(\'!^(off|no|false)$!\', $token))\r\n" + + " $token = false;\r\n" + + " /* If the token is just a string,\r\n" + + " we double-quote it. */\r\n" + + " else if (preg_match(\'!^\\w+$!\', $token)) {\r\n" + + " $token = \'\"\'.$token.\'\"\';\r\n" + + " }\r\n" + + "\r\n" + + " $attrs[$attr_name] = $token;\r\n" + + " $state = 0;\r\n" + + " } else\r\n" + + " $this->_syntax_error(\"\'=\' cannot be an attribute value\", E_USER_ERROR, __FILE__, __LINE__);\r\n" + + " break;\r\n" + + " }\r\n" + + " $last_token = $token;\r\n" + + " }\r\n" + + "\r\n" + + " if($state != 0) {\r\n" + + " if($state == 1) {\r\n" + + " $this->_syntax_error(\"expecting \'=\' after attribute name \'$last_token\'\", E_USER_ERROR, __FILE__, __LINE__); \r\n" + + " } else {\r\n" + + " $this->_syntax_error(\"missing attribute value\", E_USER_ERROR, __FILE__, __LINE__); \r\n" + + " }\r\n" + + " }\r\n" + + " \r\n" + + " $this->_parse_vars_props($attrs);\r\n" + + "\r\n" + + " return $attrs;\r\n" + + " }\r\n" + + "\r\n" + + " /**\r\n" + + " * compile multiple variables and section properties tokens into\r\n" + + " * PHP code\r\n" + + " *\r\n" + + " * @access public\r\n" + + " * @param $tokens\r\n" + + " */\r\n" + + " function _parse_vars_props(&$tokens)\r\n" + + " {\r\n" + + " foreach($tokens as $key => $val) { \r\n" + + " $tokens[$key] = $this->_parse_var_props($val);\r\n" + + " }\r\n" + + " }\r\n" + + " \r\n" + + " /**\r\n" + + " * compile single variable and section properties token into\r\n" + + " * PHP code\r\n" + + " *\r\n" + + " * @access public\r\n" + + " * @param $val\r\n" + + " * @param $tag_attrs\r\n" + + " */\r\n" + + " function _parse_var_props($val, $tag_attrs = null)\r\n" + + " { \r\n" + + "\r\n" + + " $val = trim($val);\r\n" + + "\r\n" + + " if(preg_match(\'!^(\' . $this->_obj_call_regexp . \'|\' . $this->_dvar_regexp . \')(?:\' . $this->_mod_regexp . \'*)$!\', $val)) {\r\n" + + " // $ variable or object\r\n" + + " return $this->_parse_var($val, $tag_attrs);\r\n" + + " } \r\n" + + " elseif(preg_match(\'!^\' . $this->_db_qstr_regexp . \'(?:\' . $this->_mod_regexp . \'*)$!\', $val)) {\r\n" + + " // double quoted text\r\n" + + " preg_match(\'!^(\' . $this->_db_qstr_regexp . \')(\'. $this->_mod_regexp . \'*)$!\', $val, $match);\r\n" + + " $return = $this->_expand_quoted_text($match[1]);\r\n" + + " if($match[2] != \'\') {\r\n" + + " $this->_parse_modifiers($return, $match[2]);\r\n" + + " }\r\n" + + " return $return;\r\n" + + " } \r\n" + + " elseif(preg_match(\'!^\' . $this->_si_qstr_regexp . \'(?:\' . $this->_mod_regexp . \'*)$!\', $val)) {\r\n" + + " // single quoted text\r\n" + + " preg_match(\'!^(\' . $this->_si_qstr_regexp . \')(\'. $this->_mod_regexp . \'*)$!\', $val, $match);\r\n" + + " if($match[2] != \'\') {\r\n" + + " $this->_parse_modifiers($match[1], $match[2]);\r\n" + + " return $match[1];\r\n" + + " } \r\n" + + " } \r\n" + + " elseif(preg_match(\'!^\' . $this->_cvar_regexp . \'(?:\' . $this->_mod_regexp . \'*)$!\', $val)) {\r\n" + + " // config var\r\n" + + " return $this->_parse_conf_var($val);\r\n" + + " } \r\n" + + " elseif(preg_match(\'!^\' . $this->_svar_regexp . \'(?:\' . $this->_mod_regexp . \'*)$!\', $val)) {\r\n" + + " // section var\r\n" + + " return $this->_parse_section_prop($val);\r\n" + + " }\r\n" + + " elseif(!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) {\r\n" + + " // literal string\r\n" + + " return $this->_expand_quoted_text(\'\"\' . $val .\'\"\');\r\n" + + " }\r\n" + + " return $val;\r\n" + + " }\r\n" + + "\r\n" + + " /**\r\n" + + " * expand quoted text with embedded variables\r\n" + + " *\r\n" + + " * @access public\r\n" + + " * @param $var_expr\r\n" + + " */\r\n" + + " function _expand_quoted_text($var_expr)\r\n" + + " {\r\n" + + " // if contains unescaped $, expand it\r\n" + + " if(preg_match_all(\'|(?_dvar_guts_regexp . \'|\', $var_expr, $match)) {\r\n" + + " rsort($match[0]);\r\n" + + " reset($match[0]);\r\n" + + " foreach($match[0] as $var) {\r\n" + + " $var_expr = str_replace ($var, \'\".\' . $this->_parse_var($var) . \'.\"\', $var_expr);\r\n" + + " }\r\n" + + " return preg_replace(\'!\\.\"\"|\"\"\\.!\', \'\', $var_expr);\r\n" + + " } else {\r\n" + + " return $var_expr;\r\n" + + " }\r\n" + + " }\r\n" + + " \r\n" + + " /**\r\n" + + " * parse variable expression into PHP code\r\n" + + " *\r\n" + + " * @access public\r\n" + + " * @param $var_expr\r\n" + + " */\r\n" + + " function _parse_var($var_expr)\r\n" + + " {\r\n" + + " \r\n" + + " preg_match(\'!(\' . $this->_obj_call_regexp . \'|\' . $this->_var_regexp . \')(\' . $this->_mod_regexp . \'*)$!\', $var_expr, $match);\r\n" + + " \r\n" + + " $var_ref = substr($match[1],1);\r\n" + + " $modifiers = $match[2];\r\n" + + " \r\n" + + " if(!empty($this->default_modifiers) && !preg_match(\'!(^|\\|)smarty:nodefaults($|\\|)!\',$modifiers)) {\r\n" + + " $_default_mod_string = implode(\'|\',(array)$this->default_modifiers);\r\n" + + " $modifiers = empty($modifiers) ? $_default_mod_string : $_default_mod_string . \'|\' . $modifiers;\r\n" + + " }\r\n" + + "\r\n" + + " // get [foo] and .foo and ->foo() pieces \r\n" + + " preg_match_all(\'!(?:^\\w+)|(?:\' . $this->_obj_ext_regexp . \')+(?:\' . $this->_obj_params_regexp . \')?|(?:\' . $this->_var_bracket_regexp . \')|\\.\\$?\\w+!\', $var_ref, $match); \r\n" + + " \r\n" + + " $indexes = $match[0];\r\n" + + " $var_name = array_shift($indexes);\r\n" + + " \r\n" + + " /* Handle $smarty.* variable references as a special case. */\r\n" + + " if ($var_name == \'smarty\') {\r\n" + + " /*\r\n" + + " * If the reference could be compiled, use the compiled output;\r\n" + + " * otherwise, fall back on the $smarty variable generated at\r\n" + + " * run-time.\r\n" + + " */\r\n" + + " if (($smarty_ref = $this->_compile_smarty_ref($indexes)) !== null) {\r\n" + + " $output = $smarty_ref;\r\n" + + " } else {\r\n" + + " $var_name = substr(array_shift($indexes), 1);\r\n" + + " $output = \"\\$this->_smarty_vars[\'$var_name\']\";\r\n" + + " }\r\n" + + " } else {\r\n" + + " $output = \"\\$this->_tpl_vars[\'$var_name\']\";\r\n" + + " }\r\n" + + "\r\n" + + " foreach ($indexes as $index) { \r\n" + + " if ($index{0} == \'[\') {\r\n" + + " $index = substr($index, 1, -1);\r\n" + + " if (is_numeric($index)) {\r\n" + + " $output .= \"[$index]\";\r\n" + + " } elseif ($index{0} == \'$\') {\r\n" + + " $output .= \"[\\$this->_tpl_vars[\'\" . substr($index, 1) . \"\']]\";\r\n" + + " } else {\r\n" + + " $parts = explode(\'.\', $index);\r\n" + + " $section = $parts[0];\r\n" + + " $section_prop = isset($parts[1]) ? $parts[1] : \'index\';\r\n" + + " $output .= \"[\\$this->_sections[\'$section\'][\'$section_prop\']]\";\r\n" + + " }\r\n" + + " } else if ($index{0} == \'.\') {\r\n" + + " if ($index{1} == \'$\')\r\n" + + " $output .= \"[\\$this->_tpl_vars[\'\" . substr($index, 2) . \"\']]\";\r\n" + + " else\r\n" + + " $output .= \"[\'\" . substr($index, 1) . \"\']\";\r\n" + + " } else if (substr($index,0,2) == \'->\') {\r\n" + + " if(substr($index,2,2) == \'__\') {\r\n" + + " $this->_syntax_error(\'call to internal object members is not allowed\', E_USER_ERROR, __FILE__, __LINE__);\r\n" + + " } elseif($this->security && substr($index,2,1) == \'_\') {\r\n" + + " $this->_syntax_error(\'(secure) call to private object member is not allowed\', E_USER_ERROR, __FILE__, __LINE__);\r\n" + + " } else {\r\n" + + " if(preg_match(\'!((?:\' . $this->_obj_ext_regexp . \')+)(\' . $this->_obj_params_regexp . \')?!\', $index, $match)) {\r\n" + + " if(!empty($match[2])) {\r\n" + + " // parse object parameters\r\n" + + " $index = str_replace($match[2], $this->_parse_parenth_args($match[2]), $index);\r\n" + + " }\r\n" + + " if(preg_match_all(\'!\' . $this->_dvar_regexp . \'!\', $match[1], $_dvar_match)) {\r\n" + + " // parse embedded variables\r\n" + + " $_match_replace = $match[1];\r\n" + + " foreach($_dvar_match[0] as $_curr_var) {\r\n" + + " $_match_replace = str_replace($_curr_var, \'{\' . $this->_parse_var($_curr_var) . \'}\', $_match_replace);\r\n" + + " }\r\n" + + " $index = str_replace($match[1], $_match_replace, $index);\r\n" + + " }\r\n" + + " }\r\n" + + " $output .= $index;\r\n" + + " }\r\n" + + " } else {\r\n" + + " $output .= $index;\r\n" + + " }\r\n" + + " }\r\n" + + "\r\n" + + " // look for variables imbedded in quoted strings, replace them\r\n" + + " if(preg_match(\'!\' . $this->_qstr_regexp . \'!\', $output, $match)) {\r\n" + + " $output = str_replace($match[0], $this->_expand_quoted_text($match[0]), $output);\r\n" + + " }\r\n" + + " \r\n" + + " $this->_parse_modifiers($output, $modifiers);\r\n" + + "\r\n" + + " return $output;\r\n" + + " }\r\n" + + "\r\n" + + " /**\r\n" + + " * parse arguments in function call parenthesis\r\n" + + " *\r\n" + + " * @access public\r\n" + + " * @param $parenth_args\r\n" + + " */\r\n" + + " function _parse_parenth_args($parenth_args)\r\n" + + " {\r\n" + + " preg_match_all(\'!\' . $this->_param_regexp . \'!\',$parenth_args, $match);\r\n" + + " $match = $match[0];\r\n" + + " rsort($match);\r\n" + + " reset($match); \r\n" + + " $orig_vals = $match;\r\n" + + " $this->_parse_vars_props($match);\r\n" + + " return str_replace($orig_vals, $match, $parenth_args);\r\n" + + " } \r\n" + + " \r\n" + + " /**\r\n" + + " * parse configuration variable expression into PHP code\r\n" + + " *\r\n" + + " * @access public\r\n" + + " * @param $conf_var_expr\r\n" + + " */\r\n" + + " function _parse_conf_var($conf_var_expr)\r\n" + + " {\r\n" + + " $parts = explode(\'|\', $conf_var_expr, 2);\r\n" + + " $var_ref = $parts[0];\r\n" + + " $modifiers = isset($parts[1]) ? $parts[1] : \'\';\r\n" + + "\r\n" + + " $var_name = substr($var_ref, 1, -1);\r\n" + + "\r\n" + + " $output = \"\\$this->_config[0][\'vars\'][\'$var_name\']\";\r\n" + + "\r\n" + + " $this->_parse_modifiers($output, $modifiers);\r\n" + + "\r\n" + + " return $output;\r\n" + + " }\r\n" + + "\r\n" + + "\r\n" + + " /**\r\n" + + " * parse section property expression into PHP code\r\n" + + " *\r\n" + + " * @access public\r\n" + + " * @param $section_prop_expr\r\n" + + " */\r\n" + + " function _parse_section_prop($section_prop_expr)\r\n" + + " {\r\n" + + " $parts = explode(\'|\', $section_prop_expr, 2);\r\n" + + " $var_ref = $parts[0];\r\n" + + " $modifiers = isset($parts[1]) ? $parts[1] : \'\';\r\n" + + "\r\n" + + " preg_match(\'!%(\\w+)\\.(\\w+)%!\', $var_ref, $match);\r\n" + + " $section_name = $match[1];\r\n" + + " $prop_name = $match[2];\r\n" + + "\r\n" + + " $output = \"\\$this->_sections[\'$section_name\'][\'$prop_name\']\";\r\n" + + "\r\n" + + " $this->_parse_modifiers($output, $modifiers);\r\n" + + "\r\n" + + " return $output;\r\n" + + " }\r\n" + + "\r\n" + + "\r\n" + + " /**\r\n" + + " * parse modifier chain into PHP code\r\n" + + " *\r\n" + + " * @access public\r\n" + + " * @param $output\r\n" + + " * @param $modifier_string\r\n" + + " */\r\n" + + " function _parse_modifiers(&$output, $modifier_string)\r\n" + + " {\r\n" + + " preg_match_all(\'!\\|(@?\\w+)((?>:(?:\'. $this->_qstr_regexp . \'|[^|]+))*)!\', \'|\' . $modifier_string, $match);\r\n" + + " list(, $modifiers, $modifier_arg_strings) = $match;\r\n" + + "\r\n" + + " for ($i = 0, $for_max = count($modifiers); $i < $for_max; $i++) {\r\n" + + " $modifier_name = $modifiers[$i];\r\n" + + " \r\n" + + " if($modifier_name == \'smarty\') {\r\n" + + " // skip smarty modifier\r\n" + + " continue;\r\n" + + " }\r\n" + + " \r\n" + + " preg_match_all(\'!:(\' . $this->_qstr_regexp . \'|[^:]+)!\', $modifier_arg_strings[$i], $match);\r\n" + + " $modifier_args = $match[1];\r\n" + + "\r\n" + + " if ($modifier_name{0} == \'@\') {\r\n" + + " $map_array = \'false\';\r\n" + + " $modifier_name = substr($modifier_name, 1);\r\n" + + " } else {\r\n" + + " $map_array = \'true\';\r\n" + + " }\r\n" + + " \r\n" + + " $this->_add_plugin(\'modifier\', $modifier_name);\r\n" + + "\r\n" + + " $this->_parse_vars_props($modifier_args);\r\n" + + "\r\n" + + " if (count($modifier_args) > 0)\r\n" + + " $modifier_args = \', \'.implode(\', \', $modifier_args);\r\n" + + " else\r\n" + + " $modifier_args = \'\';\r\n" + + "\r\n" + + " $output = \"\\$this->_run_mod_handler(\'$modifier_name\', $map_array, $output$modifier_args)\";\r\n" + + " }\r\n" + + " }\r\n" + + "\r\n" + + "\r\n" + + " /**\r\n" + + " * add plugin\r\n" + + " *\r\n" + + " * @access public\r\n" + + " * @param $type\r\n" + + " * @param $name\r\n" + + " * @param $delayed_loading\r\n" + + " */\r\n" + + " function _add_plugin($type, $name, $delayed_loading = null)\r\n" + + " {\r\n" + + " if (!isset($this->_plugin_info[$type])) {\r\n" + + " $this->_plugin_info[$type] = array();\r\n" + + " }\r\n" + + " if (!isset($this->_plugin_info[$type][$name])) {\r\n" + + " $this->_plugin_info[$type][$name] = array($this->_current_file,\r\n" + + " $this->_current_line_no,\r\n" + + " $delayed_loading);\r\n" + + " }\r\n" + + " }\r\n" + + " \r\n" + + "\r\n" + + " /**\r\n" + + " * Compiles references of type $smarty.foo\r\n" + + " *\r\n" + + " * @access public\r\n" + + " * @param $indexes\r\n" + + " */\r\n" + + " function _compile_smarty_ref(&$indexes)\r\n" + + " {\r\n" + + " /* Extract the reference name. */\r\n" + + " $ref = substr($indexes[0], 1);\r\n" + + "\r\n" + + " switch ($ref) {\r\n" + + " case \'now\':\r\n" + + " $compiled_ref = \'time()\';\r\n" + + " if (count($indexes) > 1) {\r\n" + + " $this->_syntax_error(\'$smarty\' . implode(\'\', $indexes) .\' is an invalid reference\', E_USER_ERROR, __FILE__, __LINE__);\r\n" + + " }\r\n" + + " break;\r\n" + + "\r\n" + + " case \'foreach\':\r\n" + + " case \'section\':\r\n" + + " if ($indexes[1]{0} != \'.\') {\r\n" + + " $this->_syntax_error(\'$smarty\' . implode(\'\', array_slice($indexes, 0, 2)) . \' is an invalid reference\', E_USER_ERROR, __FILE__, __LINE__);\r\n" + + " }\r\n" + + " $name = substr($indexes[1], 1);\r\n" + + " array_shift($indexes);\r\n" + + " if ($ref == \'foreach\')\r\n" + + " $compiled_ref = \"\\$this->_foreach[\'$name\']\";\r\n" + + " else\r\n" + + " $compiled_ref = \"\\$this->_sections[\'$name\']\";\r\n" + + " break;\r\n" + + "\r\n" + + " case \'get\':\r\n" + + " array_shift($indexes);\r\n" + + " $compiled_ref = \"\\$_GET\";\r\n" + + " if ($name = substr($indexes[0], 1))\r\n" + + " $compiled_ref .= \"[\'$name\']\";\r\n" + + " break;\r\n" + + "\r\n" + + " case \'post\':\r\n" + + " array_shift($indexes);\r\n" + + " $name = substr($indexes[0], 1);\r\n" + + " $compiled_ref = \"\\$_POST\";\r\n" + + " if ($name = substr($indexes[0], 1))\r\n" + + " $compiled_ref .= \"[\'$name\']\";\r\n" + + " break;\r\n" + + "\r\n" + + " case \'cookies\':\r\n" + + " array_shift($indexes);\r\n" + + " $name = substr($indexes[0], 1);\r\n" + + " $compiled_ref = \"\\$_COOKIE\";\r\n" + + " if ($name = substr($indexes[0], 1))\r\n" + + " $compiled_ref .= \"[\'$name\']\";\r\n" + + " break;\r\n" + + "\r\n" + + " case \'env\':\r\n" + + " array_shift($indexes);\r\n" + + " $compiled_ref = \"\\$_ENV\";\r\n" + + " if ($name = substr($indexes[0], 1))\r\n" + + " $compiled_ref .= \"[\'$name\']\";\r\n" + + " break;\r\n" + + "\r\n" + + " case \'server\':\r\n" + + " array_shift($indexes);\r\n" + + " $name = substr($indexes[0], 1);\r\n" + + " $compiled_ref = \"\\$_SERVER\";\r\n" + + " if ($name = substr($indexes[0], 1))\r\n" + + " $compiled_ref .= \"[\'$name\']\";\r\n" + + " break;\r\n" + + "\r\n" + + " case \'session\':\r\n" + + " array_shift($indexes);\r\n" + + " $name = substr($indexes[0], 1);\r\n" + + " $compiled_ref = \"\\$_SESSION\";\r\n" + + " if ($name = substr($indexes[0], 1))\r\n" + + " $compiled_ref .= \"[\'$name\']\";\r\n" + + " break;\r\n" + + "\r\n" + + " /*\r\n" + + " * These cases are handled either at run-time or elsewhere in the\r\n" + + " * compiler.\r\n" + + " */\r\n" + + " case \'request\':\r\n" + + " $this->_init_smarty_vars = true;\r\n" + + " return null;\r\n" + + "\r\n" + + " case \'capture\':\r\n" + + " return null;\r\n" + + "\r\n" + + " case \'template\':\r\n" + + " $compiled_ref = \"\'$this->_current_file\'\";\r\n" + + " if (count($indexes) > 1) {\r\n" + + " $this->_syntax_error(\'$smarty\' . implode(\'\', $indexes) .\' is an invalid reference\', E_USER_ERROR, __FILE__, __LINE__);\r\n" + + " }\r\n" + + " break;\r\n" + + " \r\n" + + " case \'version\':\r\n" + + " $compiled_ref = \"\'$this->_version\'\";\r\n" + + " break;\r\n" + + "\r\n" + + " case \'const\':\r\n" + + " array_shift($indexes);\r\n" + + " $compiled_ref = \'defined(\\\'\' . substr($indexes[0],1) . \'\\\') ? \' . substr($indexes[0],1) . \' : null\';\r\n" + + " break;\r\n" + + "\r\n" + + " default:\r\n" + + " $this->_syntax_error(\'$smarty.\' . $ref . \' is an unknown reference\', E_USER_ERROR, __FILE__, __LINE__);\r\n" + + " break;\r\n" + + " }\r\n" + + "\r\n" + + " array_shift($indexes);\r\n" + + " return $compiled_ref;\r\n" + + " }\r\n" + + "\r\n" + + "\r\n" + + " /**\r\n" + + " * load pre- and post-filters\r\n" + + " *\r\n" + + " * @access public\r\n" + + " */\r\n" + + " function _load_filters()\r\n" + + " {\r\n" + + " if (count($this->_plugins[\'prefilter\']) > 0) {\r\n" + + " foreach ($this->_plugins[\'prefilter\'] as $filter_name => $prefilter) {\r\n" + + " if ($prefilter === false) {\r\n" + + " unset($this->_plugins[\'prefilter\'][$filter_name]);\r\n" + + " $this->_load_plugins(array(array(\'prefilter\', $filter_name, null, null, false)));\r\n" + + " }\r\n" + + " }\r\n" + + " }\r\n" + + " if (count($this->_plugins[\'postfilter\']) > 0) {\r\n" + + " foreach ($this->_plugins[\'postfilter\'] as $filter_name => $postfilter) {\r\n" + + " if ($postfilter === false) {\r\n" + + " unset($this->_plugins[\'postfilter\'][$filter_name]);\r\n" + + " $this->_load_plugins(array(array(\'postfilter\', $filter_name, null, null, false)));\r\n" + + " }\r\n" + + " }\r\n" + + " }\r\n" + + " }\r\n" + + "\r\n" + + "\r\n" + + " /**\r\n" + + " * display Smarty syntax error\r\n" + + " *\r\n" + + " * @access public\r\n" + + " * @param $error_msg\r\n" + + " * @param $error_type\r\n" + + " * @param $file\r\n" + + " * @param $line\r\n" + + " */\r\n" + + " function _syntax_error($error_msg, $error_type = E_USER_ERROR, $file=null, $line=null)\r\n" + + " {\r\n" + + " if(isset($file) && isset($line)) {\r\n" + + " $info = \' (\'.basename($file).\", line $line)\";\r\n" + + " } else {\r\n" + + " $info = null;\r\n" + + " }\r\n" + + " trigger_error(\'Smarty: [in \' . $this->_current_file . \' line \' .\r\n" + + " $this->_current_line_no . \"]: syntax error: $error_msg$info\", $error_type);\r\n" + + " }\r\n" + "}\r\n" + "\r\n" + "/**\r\n" + + " * compare to values by their string length\r\n" + " *\r\n" + + " * @access private\r\n" + " * @param $a\r\n" + + " * @param $b\r\n" + " */\r\n" + + "function _smarty_sort_length($a, $b)\r\n" + "{\r\n" + + " if($a == $b)\r\n" + " return 0;\r\n" + "\r\n" + + " if(strlen($a) == strlen($b))\r\n" + + " return ($a > $b) ? -1 : 1;\r\n" + "\r\n" + + " return (strlen($a) > strlen($b)) ? -1 : 1;\r\n" + "}\r\n" + + "\r\n" + "\r\n" + "/* vim: set et: */\r\n" + "\r\n" + + "?>\r\n" + ""); + } +} diff --git a/net.sourceforge.phpeclipse.test/test.php b/net.sourceforge.phpeclipse.test/test.php new file mode 100644 index 0000000..e12766c --- /dev/null +++ b/net.sourceforge.phpeclipse.test/test.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.tests/.classpath b/net.sourceforge.phpeclipse.tests/.classpath index 065ac06..ce73933 100644 --- a/net.sourceforge.phpeclipse.tests/.classpath +++ b/net.sourceforge.phpeclipse.tests/.classpath @@ -1,7 +1,7 @@ + - diff --git a/net.sourceforge.phpeclipse.tests/.project b/net.sourceforge.phpeclipse.tests/.project index 86b9694..922a772 100644 --- a/net.sourceforge.phpeclipse.tests/.project +++ b/net.sourceforge.phpeclipse.tests/.project @@ -3,7 +3,6 @@ net.sourceforge.phpeclipse.tests - net.sourceforge.phpeclipse diff --git a/net.sourceforge.phpeclipse.tests/.settings/org.eclipse.jdt.core.prefs b/net.sourceforge.phpeclipse.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..607728d --- /dev/null +++ b/net.sourceforge.phpeclipse.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +#Thu Oct 26 18:35:19 PDT 2006 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 +org.eclipse.jdt.core.compiler.compliance=1.4 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning +org.eclipse.jdt.core.compiler.source=1.3 diff --git a/net.sourceforge.phpeclipse.tests/.template b/net.sourceforge.phpeclipse.tests/.template deleted file mode 100644 index f3bcd41..0000000 --- a/net.sourceforge.phpeclipse.tests/.template +++ /dev/null @@ -1,4 +0,0 @@ - - -

    Tips on working with this plug-in project

  • For the view of the new plug-in at a glance, go to the Overview.
  • You can test the contributions of this plug-in by launching another instance of the workbench. On the Run menu, click Run As and choose Run-time Workbench from the available choices.
  • You can add more functionality to this plug-in by adding extensions using the New Extension Wizard.
  • The plug-in project contains Java code that you can debug. Place breakpoints in Java classes. On the Run menu, select Debug As and choose Run-time Workbench from the available choices.
  • - diff --git a/net.sourceforge.phpeclipse.tests/META-INF/MANIFEST.MF b/net.sourceforge.phpeclipse.tests/META-INF/MANIFEST.MF index 5decd51..7604a11 100644 --- a/net.sourceforge.phpeclipse.tests/META-INF/MANIFEST.MF +++ b/net.sourceforge.phpeclipse.tests/META-INF/MANIFEST.MF @@ -1,20 +1,11 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: Core Tests -Bundle-SymbolicName: net.sourceforge.phpeclipse.tests; singleton:=true +Bundle-Name: Common Tests Utilities +Bundle-SymbolicName: net.sourceforge.phpeclipse.tests Bundle-Version: 1.1.0 Bundle-ClassPath: coretests.jar -Bundle-Activator: org.eclipse.core.internal.compatibility.PluginActivator Bundle-Vendor: PHPEclipse project team Bundle-Localization: plugin -Require-Bundle: org.eclipse.core.runtime.compatibility, - org.eclipse.ui, - org.junit, - net.sourceforge.phpeclipse, - org.eclipse.jface.text, - org.eclipse.core.resources +Require-Bundle: org.junit Eclipse-LazyStart: true -Export-Package: net.sourceforge.phpdt.core.tests.util, - net.sourceforge.phpeclipse.example.outline, - net.sourceforge.phpeclipse.phpeditor.php.test, - net.sourceforge.phpeclipse.tests.parser +Bundle-RequiredExecutionEnvironment: J2SE-1.4 diff --git a/net.sourceforge.phpeclipse.tests/build.properties b/net.sourceforge.phpeclipse.tests/build.properties index 6297c21..76de62a 100644 --- a/net.sourceforge.phpeclipse.tests/build.properties +++ b/net.sourceforge.phpeclipse.tests/build.properties @@ -2,14 +2,9 @@ jars.compile.order = coretests.jar source.coretests.jar = src/ output.coretests.jar = bin/ bin.includes = coretests.jar,\ - META-INF/,\ - plugin.xml,\ - test.php -src.includes = test.php,\ - src/,\ - plugin.xml,\ + META-INF/ +src.includes = src/,\ build.properties,\ META-INF/,\ - .template,\ .project,\ .classpath diff --git a/net.sourceforge.phpeclipse.tests/plugin.xml b/net.sourceforge.phpeclipse.tests/plugin.xml deleted file mode 100644 index e87d50b..0000000 --- a/net.sourceforge.phpeclipse.tests/plugin.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpdt/core/tests/util/AbstractCompilerTest.java b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpdt/core/tests/util/AbstractCompilerTest.java deleted file mode 100644 index 19da326..0000000 --- a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpdt/core/tests/util/AbstractCompilerTest.java +++ /dev/null @@ -1,299 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation 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 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package net.sourceforge.phpdt.core.tests.util; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Locale; -import java.util.Map; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import net.sourceforge.phpdt.core.compiler.IProblem; -import net.sourceforge.phpdt.internal.compiler.CompilationResult; -import net.sourceforge.phpdt.internal.compiler.DefaultErrorHandlingPolicies; -import net.sourceforge.phpdt.internal.compiler.ast.CompilationUnitDeclaration; -import net.sourceforge.phpdt.internal.compiler.batch.CompilationUnit; -import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit; -import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions; -import net.sourceforge.phpdt.internal.compiler.parser.Scanner; -import net.sourceforge.phpdt.internal.compiler.parser.UnitParser; -import net.sourceforge.phpdt.internal.compiler.problem.DefaultProblem; -import net.sourceforge.phpdt.internal.compiler.problem.DefaultProblemFactory; -import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter; - -// import net.sourceforge.phpdt.core.tests.junit.extension.TestCase; -// import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions; - -public class AbstractCompilerTest extends TestCase { - - private static int possibleComplianceLevels = -1; - - protected String complianceLevel; - - public void checkParsePHP(char[] source, String expectedSyntaxErrorDiagnosis) { - // String testName) { - - UnitParser parser = new UnitParser(new ProblemReporter( - DefaultErrorHandlingPolicies.proceedWithAllProblems(), - new CompilerOptions(getCompilerOptions()), - new DefaultProblemFactory(Locale.getDefault()))); - - ICompilationUnit sourceUnit = new CompilationUnit(source, "", null); - CompilationResult compilationResult = new CompilationResult(sourceUnit, - 0, 0, 0); - - CompilationUnitDeclaration computedUnit = parser.dietParse(sourceUnit, - compilationResult, true); - // if (computedUnit.types != null) { - // for (int i = computedUnit.types.size(); --i >= 0;){ - // ((TypeDeclaration)computedUnit.types.get(i)).parseMethod(parser, - // computedUnit); - // } - // } - - StringBuffer buffer = new StringBuffer(100); - if (compilationResult.hasProblems() || compilationResult.hasTasks()) { - IProblem[] problems = compilationResult.getAllProblems(); - int count = problems.length; - int problemCount = 0; - char[] unitSource = compilationResult.compilationUnit.getContents(); - for (int i = 0; i < count; i++) { - if (problems[i] != null) { - if (problemCount == 0) - buffer.append("----------\n"); - problemCount++; - buffer - .append(problemCount - + (problems[i].isError() ? ". ERROR" - : ". WARNING")); - buffer.append(" in " - + new String(problems[i].getOriginatingFileName()) - .replace('/', '\\')); - try { - buffer.append(((DefaultProblem) problems[i]) - .errorReportSource(unitSource)); - buffer.append("\n"); - buffer.append(problems[i].getMessage()); - buffer.append("\n"); - } catch (Exception e) { - StringWriter stringWriter = new StringWriter(); - e.printStackTrace(new PrintWriter(stringWriter)); - buffer.append(stringWriter.getBuffer()); - } - buffer.append("----------\n"); - } - } - } - String computedSyntaxErrorDiagnosis = buffer.toString(); - if (!expectedSyntaxErrorDiagnosis.equals(computedSyntaxErrorDiagnosis)) { - System.out - .println(Util.displayString(computedSyntaxErrorDiagnosis)); - } - assertEquals("Invalid syntax error diagnosis", - expectedSyntaxErrorDiagnosis, computedSyntaxErrorDiagnosis); - } - - public void checkParseHTML(char[] source, - String expectedSyntaxErrorDiagnosis) { - // String testName) { - - UnitParser parser = new UnitParser(new ProblemReporter( - DefaultErrorHandlingPolicies.proceedWithAllProblems(), - new CompilerOptions(getCompilerOptions()), - new DefaultProblemFactory(Locale.getDefault()))); - - ICompilationUnit sourceUnit = new CompilationUnit(source, "", null); - CompilationResult compilationResult = new CompilationResult(sourceUnit, - 0, 0, 0); - - CompilationUnitDeclaration computedUnit = parser.dietParse(sourceUnit, - compilationResult, false); - // if (computedUnit.types != null) { - // for (int i = computedUnit.types.size(); --i >= 0;){ - // ((TypeDeclaration)computedUnit.types.get(i)).parseMethod(parser, - // computedUnit); - // } - // } - - StringBuffer buffer = new StringBuffer(100); - if (compilationResult.hasProblems() || compilationResult.hasTasks()) { - IProblem[] problems = compilationResult.getAllProblems(); - int count = problems.length; - int problemCount = 0; - char[] unitSource = compilationResult.compilationUnit.getContents(); - for (int i = 0; i < count; i++) { - if (problems[i] != null) { - if (problemCount == 0) - buffer.append("----------\n"); - problemCount++; - buffer - .append(problemCount - + (problems[i].isError() ? ". ERROR" - : ". WARNING")); - buffer.append(" in " - + new String(problems[i].getOriginatingFileName()) - .replace('/', '\\')); - try { - buffer.append(((DefaultProblem) problems[i]) - .errorReportSource(unitSource)); - buffer.append("\n"); - buffer.append(problems[i].getMessage()); - buffer.append("\n"); - } catch (Exception e) { - StringWriter stringWriter = new StringWriter(); - e.printStackTrace(new PrintWriter(stringWriter)); - buffer.append(stringWriter.getBuffer()); - } - buffer.append("----------\n"); - } - } - } - String computedSyntaxErrorDiagnosis = buffer.toString(); - if (!expectedSyntaxErrorDiagnosis.equals(computedSyntaxErrorDiagnosis)) { - System.out - .println(Util.displayString(computedSyntaxErrorDiagnosis)); - } - assertEquals("Invalid syntax error diagnosis", - expectedSyntaxErrorDiagnosis, computedSyntaxErrorDiagnosis); - } - - /* - * Returns the possible compliance levels this VM instance can run. - */ - // public static int getPossibleComplianceLevels() { - // if (possibleComplianceLevels == -1) { - // String compliance = System.getProperty("compliance"); - // if (compliance != null) { - // if (COMPLIANCE_1_3.equals(compliance)) { - // possibleComplianceLevels = F_1_3; - // } else if (COMPLIANCE_1_4.equals(compliance)) { - // possibleComplianceLevels = F_1_4; - // } else if (COMPLIANCE_1_5.equals(compliance)) { - // possibleComplianceLevels = F_1_5; - // } else { - // System.out.println("Invalid compliance specified (" + compliance + ")"); - // System.out.println("Use one of " + COMPLIANCE_1_3 + ", " + COMPLIANCE_1_4 - // + ", " + COMPLIANCE_1_5); - // System.out.println("Defaulting to all possible compliances"); - // } - // } - // if (possibleComplianceLevels == -1) { - // possibleComplianceLevels = F_1_3; - // String specVersion = System.getProperty("java.specification.version"); - // boolean canRun1_4 = !"1.0".equals(specVersion) && - // !"1.1".equals(specVersion) && !"1.2".equals(specVersion) && - // !"1.3".equals(specVersion); - // if (canRun1_4) { - // possibleComplianceLevels |= F_1_4; - // } - // boolean canRun1_5 = canRun1_4 && !"1.4".equals(specVersion); - // if (canRun1_5) { - // possibleComplianceLevels |= F_1_5; - // } - // } - // } - // return possibleComplianceLevels; - // } - /* - * Returns a test suite including the tests defined by the given classes for - * the given complianceLevel (see AbstractCompilerTest for valid values) and - * using the given setup class (CompilerTestSetup or a subclass) - */ - public static Test suiteForComplianceLevel(String complianceLevel, - Class setupClass, ArrayList testClasses) { - TestSuite suite; - if (testClasses.size() == 1) { - suite = new TestSuite((Class) testClasses.get(0), complianceLevel); - } else { - suite = new TestSuite(complianceLevel); - for (int i = 0, length = testClasses.size(); i < length; i++) { - Class testClass = (Class) testClasses.get(i); - TestSuite innerSuite = new TestSuite(testClass); - suite.addTest(innerSuite); - } - } - - // call the setup constructor with the suite and compliance level - try { - Constructor constructor = setupClass.getConstructor(new Class[] { - Test.class, String.class }); - Test setUp = (Test) constructor.newInstance(new Object[] { suite, - complianceLevel }); - return setUp; - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.getTargetException().printStackTrace(); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } - - return null; - } - - public AbstractCompilerTest(String name) { - super(name); - } - - protected Map getCompilerOptions() { - Map options = new CompilerOptions().getMap(); - // ignore warnings - options.put(CompilerOptions.OPTION_PHPVarDeprecatedWarning, - CompilerOptions.IGNORE); - options.put(CompilerOptions.OPTION_PHPBadStyleKeywordWarning, - CompilerOptions.IGNORE); - options.put( - CompilerOptions.OPTION_PHPBadStyleUppercaseIdentifierWarning, - CompilerOptions.IGNORE); - options.put(CompilerOptions.OPTION_PHPIncludeNotExistWarning, - CompilerOptions.IGNORE); - options.put(CompilerOptions.OPTION_UninitializedLocalVariableWarning, - CompilerOptions.IGNORE); - options.put(CompilerOptions.OPTION_CodeCannotBeReachedWarning, - CompilerOptions.IGNORE); - return options; - } - - public String getName() { - String name = super.getName(); - if (this.complianceLevel != null) { - name = this.complianceLevel + " - " + name; - } - return name; - } - - protected void checkPHP(String strEval) { - checkPHP(strEval, ""); - } - - protected void checkPHP(String strEval, String expectedSyntaxErrorDiagnosis) { - if (Scanner.DEBUG) { - System.out.println("\n------------------------------------"); - System.out.println(strEval); - } - checkParsePHP(strEval.toCharArray(), expectedSyntaxErrorDiagnosis); - } - - protected void checkHTML(String strEval) { - if (Scanner.DEBUG) { - System.out.println("\n------------------------------------"); - System.out.println(strEval); - } - checkParseHTML(strEval.toCharArray(), ""); - } -} diff --git a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpdt/core/tests/util/Util.java b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpdt/core/tests/util/Util.java deleted file mode 100644 index 5316029..0000000 --- a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpdt/core/tests/util/Util.java +++ /dev/null @@ -1,504 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation 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 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package net.sourceforge.phpdt.core.tests.util; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintWriter; -import java.net.ServerSocket; - -import net.sourceforge.phpdt.internal.compiler.batch.CompilationUnit; - -public class Util { - public static String OUTPUT_DIRECTORY = "comptest"; - - public static CompilationUnit[] compilationUnits(String[] testFiles) { - int length = testFiles.length / 2; - CompilationUnit[] result = new CompilationUnit[length]; - int index = 0; - for (int i = 0; i < length; i++) { - result[i] = new CompilationUnit(testFiles[index + 1].toCharArray(), - testFiles[index], null); - index += 2; - } - return result; - } - - public static String[] concatWithClassLibs(String classpath, boolean inFront) { - String[] classLibs = getJavaClassLibs(); - final int length = classLibs.length; - String[] defaultClassPaths = new String[length + 1]; - if (inFront) { - System.arraycopy(classLibs, 0, defaultClassPaths, 1, length); - defaultClassPaths[0] = classpath; - } else { - System.arraycopy(classLibs, 0, defaultClassPaths, 0, length); - defaultClassPaths[length] = classpath; - } - return defaultClassPaths; - } - - public static String convertToIndependantLineDelimiter(String source) { - StringBuffer buffer = new StringBuffer(); - for (int i = 0, length = source.length(); i < length; i++) { - char car = source.charAt(i); - if (car == '\r') { - buffer.append('\n'); - if (i < length - 1 && source.charAt(i + 1) == '\n') { - i++; // skip \n after \r - } - } else { - buffer.append(car); - } - } - return buffer.toString(); - } - - /** - * Copy the given source (a file or a directory that must exists) to the - * given destination (a directory that must exists). - */ - public static void copy(String sourcePath, String destPath) { - sourcePath = toNativePath(sourcePath); - destPath = toNativePath(destPath); - File source = new File(sourcePath); - if (!source.exists()) - return; - File dest = new File(destPath); - if (!dest.exists()) - return; - if (source.isDirectory()) { - String[] files = source.list(); - if (files != null) { - for (int i = 0; i < files.length; i++) { - String file = files[i]; - File sourceFile = new File(source, file); - if (sourceFile.isDirectory()) { - File destSubDir = new File(dest, file); - destSubDir.mkdir(); - copy(sourceFile.getPath(), destSubDir.getPath()); - } else { - copy(sourceFile.getPath(), dest.getPath()); - } - } - } - } else { - FileInputStream in = null; - FileOutputStream out = null; - try { - in = new FileInputStream(source); - File destFile = new File(dest, source.getName()); - if (destFile.exists() && !destFile.delete()) { - throw new IOException(destFile + " is in use"); - } - out = new FileOutputStream(destFile); - int bufferLength = 1024; - byte[] buffer = new byte[bufferLength]; - int read = 0; - while (read != -1) { - read = in.read(buffer, 0, bufferLength); - if (read != -1) { - out.write(buffer, 0, read); - } - } - } catch (IOException e) { - throw new Error(e.toString()); - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException e) { - } - } - if (out != null) { - try { - out.close(); - } catch (IOException e) { - } - } - } - } - } - - // public static void createJar(String[] pathsAndContents, Map options, - // String - // jarPath) throws IOException { - // String classesPath = getOutputDirectory() + File.separator + "classes"; - // File classesDir = new File(classesPath); - // flushDirectoryContent(classesDir); - // compile(pathsAndContents, options, classesPath); - // zip(classesDir, jarPath); - // } - /** - * Generate a display string from the given String. - * - * @param indent - * number of tabs are added at the begining of each line. - * - * Example of use: - * [org.eclipse.jdt.core.tests.util.Util.displayString("abc\ndef\tghi")] - */ - public static String displayString(String inputString) { - return displayString(inputString, 0); - } - - /** - * Generate a display string from the given String. It converts: - *
      - *
    • \t to \t
    • - *
    • \r to \\r
    • - *
    • \n to \n
    • - *
    • \b to \\b
    • - *
    • \f to \\f
    • - *
    • \" to \\\"
    • - *
    • \' to \\'
    • - *
    • \\ to \\\\
    • - *
    • All other characters are unchanged.
    • - *
    - * This method doesn't convert \r\n to \n. - *

    - * Example of use: - *

  • - * - *
    -	 *   input string = "abc\ndef\tghi",
    -	 *   indent = 3
    -	 *   result = "\"\t\t\tabc\\n" +
    -	 *   			"\t\t\tdef\tghi\""
    -	 * 
    - * - *
  • - *
  • - * - *
    -	 *   input string = "abc\ndef\tghi\n",
    -	 *   indent = 3
    -	 *   result = "\"\t\t\tabc\\n" +
    -	 *   			"\t\t\tdef\tghi\\n\""
    -	 * 
    - * - *
  • - *
  • - * - *
    -	 *   input string = "abc\r\ndef\tghi\r\n",
    -	 *   indent = 3
    -	 *   result = "\"\t\t\tabc\\r\\n" +
    -	 *   			"\t\t\tdef\tghi\\r\\n\""
    -	 * 
    - * - *
  • - * - *

    - * - * @param inputString - * the given input string - * @param indent - * number of tabs are added at the begining of each line. - * - * @return the displayed string - */ - public static String displayString(String inputString, int indent) { - int length = inputString.length(); - StringBuffer buffer = new StringBuffer(length); - java.util.StringTokenizer tokenizer = new java.util.StringTokenizer( - inputString, "\n\r", true); - for (int i = 0; i < indent; i++) - buffer.append("\t"); - buffer.append("\""); - while (tokenizer.hasMoreTokens()) { - - String token = tokenizer.nextToken(); - if (token.equals("\r")) { - buffer.append("\\r"); - if (tokenizer.hasMoreTokens()) { - token = tokenizer.nextToken(); - if (token.equals("\n")) { - buffer.append("\\n"); - if (tokenizer.hasMoreTokens()) { - buffer.append("\" + \n"); - for (int i = 0; i < indent; i++) - buffer.append("\t"); - buffer.append("\""); - } - continue; - } else { - buffer.append("\" + \n"); - for (int i = 0; i < indent; i++) - buffer.append("\t"); - buffer.append("\""); - } - } else { - continue; - } - } else if (token.equals("\n")) { - buffer.append("\\n"); - if (tokenizer.hasMoreTokens()) { - buffer.append("\" + \n"); - for (int i = 0; i < indent; i++) - buffer.append("\t"); - buffer.append("\""); - } - continue; - } - - StringBuffer tokenBuffer = new StringBuffer(); - for (int i = 0; i < token.length(); i++) { - char c = token.charAt(i); - switch (c) { - case '\r': - tokenBuffer.append("\\r"); - break; - case '\n': - tokenBuffer.append("\\n"); - break; - case '\b': - tokenBuffer.append("\\b"); - break; - case '\t': - tokenBuffer.append("\t"); - break; - case '\f': - tokenBuffer.append("\\f"); - break; - case '\"': - tokenBuffer.append("\\\""); - break; - case '\'': - tokenBuffer.append("\\'"); - break; - case '\\': - tokenBuffer.append("\\\\"); - break; - default: - tokenBuffer.append(c); - } - } - buffer.append(tokenBuffer.toString()); - } - buffer.append("\""); - return buffer.toString(); - } - - /** - * Reads the content of the given source file and converts it to a display - * string. - * - * Example of use: - * [org.eclipse.jdt.core.tests.util.Util.fileContentToDisplayString("c:/temp/X.java", - * 0)] - */ - public static String fileContentToDisplayString(String sourceFilePath, - int indent, boolean independantLineDelimiter) { - File sourceFile = new File(sourceFilePath); - if (!sourceFile.exists()) { - System.out.println("File " + sourceFilePath + " does not exists."); - return null; - } - if (!sourceFile.isFile()) { - System.out.println(sourceFilePath + " is not a file."); - return null; - } - StringBuffer sourceContentBuffer = new StringBuffer(); - FileInputStream input = null; - try { - input = new FileInputStream(sourceFile); - } catch (FileNotFoundException e) { - return null; - } - try { - int read; - do { - read = input.read(); - if (read != -1) { - sourceContentBuffer.append((char) read); - } - } while (read != -1); - input.close(); - } catch (IOException e) { - e.printStackTrace(); - return null; - } finally { - try { - input.close(); - } catch (IOException e2) { - } - } - String sourceString = sourceContentBuffer.toString(); - if (independantLineDelimiter) { - sourceString = convertToIndependantLineDelimiter(sourceString); - } - return displayString(sourceString, indent); - } - - /** - * Reads the content of the given source file, converts it to a display - * string. If the destination file path is not null, writes the result to - * this file. Otherwise writes it to the console. - * - * Example of use: - * [org.eclipse.jdt.core.tests.util.Util.fileContentToDisplayString("c:/temp/X.java", - * 0, null)] - */ - public static void fileContentToDisplayString(String sourceFilePath, - int indent, String destinationFilePath, - boolean independantLineDelimiter) { - String displayString = fileContentToDisplayString(sourceFilePath, - indent, independantLineDelimiter); - if (destinationFilePath == null) { - System.out.println(displayString); - return; - } - writeToFile(displayString, destinationFilePath); - } - - /** - * Flush content of a given directory (leaving it empty), no-op if not a - * directory. - */ - public static void flushDirectoryContent(File dir) { - if (dir.isDirectory()) { - String[] files = dir.list(); - if (files == null) - return; - for (int i = 0, max = files.length; i < max; i++) { - File current = new File(dir, files[i]); - if (current.isDirectory()) { - flushDirectoryContent(current); - } - current.delete(); - } - } - } - - /** - * Search the user hard-drive for a Java class library. Returns null if none - * could be found. - * - * Example of use: [org.eclipse.jdt.core.tests.util.Util.getJavaClassLib()] - */ - public static String[] getJavaClassLibs() { - String jreDir = getJREDirectory(); - if (jreDir == null) { - return new String[] {}; - } else { - final String vmName = System.getProperty("java.vm.name"); - if ("J9".equals(vmName)) { - return new String[] { toNativePath(jreDir - + "/lib/jclMax/classes.zip") }; - } else { - File file = new File(jreDir + "/lib/rt.jar"); - if (file.exists()) { - return new String[] { toNativePath(jreDir + "/lib/rt.jar") }; - } else { - return new String[] { - toNativePath(jreDir + "/lib/core.jar"), - toNativePath(jreDir + "/lib/security.jar"), - toNativePath(jreDir + "/lib/graphics.jar") }; - } - } - } - } - - public static String getJavaClassLibsAsString() { - String[] classLibs = getJavaClassLibs(); - StringBuffer buffer = new StringBuffer(); - for (int i = 0, max = classLibs.length; i < max; i++) { - buffer.append(classLibs[i]).append(File.pathSeparatorChar); - - } - return buffer.toString(); - } - - /** - * Returns the JRE directory this tests are running on. Returns null if none - * could be found. - * - * Example of use: [org.eclipse.jdt.core.tests.util.Util.getJREDirectory()] - */ - public static String getJREDirectory() { - return System.getProperty("java.home"); - } - - /** - * Search the user hard-drive for a possible output directory. Returns null - * if none could be found. - * - * Example of use: - * [org.eclipse.jdt.core.tests.util.Util.getOutputDirectory()] - */ - public static String getOutputDirectory() { - String container = System.getProperty("user.home"); - if (container == null) { - return null; - } else { - return toNativePath(container) + File.separator + OUTPUT_DIRECTORY; - } - } - - /** - * Returns the next available port number on the local host. - */ - public static int getFreePort() { - ServerSocket socket = null; - try { - socket = new ServerSocket(0); - return socket.getLocalPort(); - } catch (IOException e) { - // ignore - } finally { - if (socket != null) { - try { - socket.close(); - } catch (IOException e) { - // ignore - } - } - } - return -1; - } - - /** - * Makes the given path a path using native path separators as returned by - * File.getPath() and trimming any extra slash. - */ - public static String toNativePath(String path) { - String nativePath = path.replace('\\', File.separatorChar).replace('/', - File.separatorChar); - return nativePath.endsWith("/") || nativePath.endsWith("\\") ? nativePath - .substring(0, nativePath.length() - 1) - : nativePath; - } - - public static void writeToFile(String contents, String destinationFilePath) { - File destFile = new File(destinationFilePath); - FileOutputStream output = null; - try { - output = new FileOutputStream(destFile); - PrintWriter writer = new PrintWriter(output); - writer.print(contents); - writer.flush(); - } catch (IOException e) { - e.printStackTrace(); - return; - } finally { - if (output != null) { - try { - output.close(); - } catch (IOException e2) { - } - } - } - } -} diff --git a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/example/outline/Import2Console.java b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/example/outline/Import2Console.java deleted file mode 100644 index ac1a01b..0000000 --- a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/example/outline/Import2Console.java +++ /dev/null @@ -1,72 +0,0 @@ -package net.sourceforge.phpeclipse.example.outline; - -import net.sourceforge.phpdt.core.IImportDeclaration; - -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IActionDelegate; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchPartSite; - -public class Import2Console implements IObjectActionDelegate { - - private IWorkbenchPartSite myPartSite = null; - - private IWorkspace myWorkspace = null; - - private IWorkbenchPart myWorkbenchPart = null; - - private IImportDeclaration myType = null; - - public Import2Console() { - // this(new PackageSelector()); - } - - // public CreateMock(IPackageSelector aPackageSelector) { - // myPackageSelector = aPackageSelector; - // } - - /** - * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) - */ - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - myWorkspace = ResourcesPlugin.getWorkspace(); - myWorkbenchPart = targetPart; - } - - /** - * @see IActionDelegate#run(IAction) - */ - public void run(IAction action) { - try { - String actionId = action.getId(); - showSourceInConsole(actionId); - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * @see IActionDelegate#selectionChanged(IAction, ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - if (selection instanceof IStructuredSelection) { - Object item = ((IStructuredSelection) selection).getFirstElement(); - myType = (IImportDeclaration) item; // this plugin only reacts to - // IImportDeclaration's - } - } - - private void showSourceInConsole(String actionId) throws Exception { - - String src = myType.getSource(); - System.out.println(actionId); - System.out.println("Source :" + src); - - } - -} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/example/outline/Type2Console.java b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/example/outline/Type2Console.java deleted file mode 100644 index e310315..0000000 --- a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/example/outline/Type2Console.java +++ /dev/null @@ -1,81 +0,0 @@ -package net.sourceforge.phpeclipse.example.outline; - -import net.sourceforge.phpdt.core.IMethod; -import net.sourceforge.phpdt.core.IType; - -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IActionDelegate; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchPartSite; - -public class Type2Console implements IObjectActionDelegate { - private IWorkbenchPartSite myPartSite = null; - - private IWorkspace myWorkspace = null; - - private IWorkbenchPart myWorkbenchPart = null; - - private IType myType = null; - - private Shell myShell = new Shell(); // TBReplaced with getShell() - - public Type2Console() { - } - - /** - * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) - */ - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - myWorkspace = ResourcesPlugin.getWorkspace(); - myWorkbenchPart = targetPart; - } - - /** - * @see IActionDelegate#run(IAction) - */ - public void run(IAction action) { - try { - - String actionId = action.getId(); - showSourceInConsole(actionId); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * @see IActionDelegate#selectionChanged(IAction, ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - if (selection instanceof IStructuredSelection) { - Object item = ((IStructuredSelection) selection).getFirstElement(); - myType = (IType) item; // this plugin only reacts to - // "org.eclipse.jdt.core.IType" objects - } - } - - private void showSourceInConsole(String actionId) throws Exception { - System.out.println(actionId); - if (!(myType.isInterface() || myType.isClass())) { - throw new Exception("incompatible Type"); - } - - IMethod[] methods = myType.getMethods(); - - String fqname = myType.getFullyQualifiedName(); // a.b.c.d.MyClass - System.out.println(fqname + '\n'); - for (int i = 0; i < methods.length; i++) { - System.out.println("Method " + i + ":" - + methods[i].getElementName()); - } - - } - -} diff --git a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/DualParseSyntaxErrorTest.java b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/DualParseSyntaxErrorTest.java deleted file mode 100644 index 15b4590..0000000 --- a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/DualParseSyntaxErrorTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Created on 29.02.2004 - * - * To change the template for this generated file go to - * Window - Preferences - Java - Code Generation - Code and Comments - */ -package net.sourceforge.phpeclipse.phpeditor.php.test; - -import net.sourceforge.phpdt.core.tests.util.AbstractCompilerTest; - -public class DualParseSyntaxErrorTest extends AbstractCompilerTest { - public static boolean optimizeStringLiterals = false; - - public DualParseSyntaxErrorTest(String testName) { - super(testName); - } - - public void test01() { - String s = "$login =1; " + "final class test {\n" + "\n" - + "private function f1() {\n" + "\n" + "}\n" - + "public function f2() {\n" + "\n" + " \n" + "} \n" + "}"; - - String expectedSyntaxErrorDiagnosis = ""; - - String testName = ""; - checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis); - // testName); - } - - public void test02() { - String s = "class test { \n" + " function f0() \n" - + " { \n" + " } \n" - + "} \n"; - - String expectedSyntaxErrorDiagnosis = ""; - - String testName = ""; - checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis); - // testName); - } - - public void test03() { - String s = "$chars = ( isset($HTTP_GET_VARS['chars']) ) ? intval($HTTP_GET_VARS['chars']) : 200;"; - String expectedSyntaxErrorDiagnosis = ""; - - checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis); - // testName); - } - - public void test96() { - String s = "$str = <<foo = 'Foo';\n" - + " $this->bar = array('Bar1', 'Bar2', 'Bar3');\n" - + " }\n" + "}\n" + "\n" + "$foo = new foo();\n" - + "$name = 'MyName';\n" + "\n" + "echo <<foo.\n" - + "Now, I am printing some {$foo->bar[1]}.\n" - + "This should print a capital 'A': \\x41\n" + "EOT;\n"; - String expectedSyntaxErrorDiagnosis = ""; - - checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis); - // testName); - } - - public void test97() { - String s = "class momo { \n" - + " function &fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null) \n" - + " { \n" + " } \n" - + "} \n"; - - String expectedSyntaxErrorDiagnosis = ""; - - checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis); - // testName); - } - - public void test98() { - String s = "return(array());" - + "if(!$result = mysql_query($sql)) return(array());\n"; - - String expectedSyntaxErrorDiagnosis = ""; - - checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis); - // testName); - } - - public void test99() { - String s = "class test { \n" - + " murks; \n" - + " function &fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null) \n" - + " { \n" + " } \n" - + "} \n"; - - String expectedSyntaxErrorDiagnosis = "----------\n" - + "1. ERROR in (at line 1)\n" - + " murks; \n" - + " ^^^^^^\n" - + "Parser error \"\'public\' \'private\' or \'protected\' modifier expected for field declarations.\"\n" - + "----------\n" - // + "2. ERROR in (at line 1)\n" - // + " } \n" - // + " ^\n" - // + "Parser error \"Too many closing \'}\'; end-of-file not - // reached.\"\n" - // + "----------\n" - ; - - checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis); - // testName); - } -} diff --git a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/DummyDocument.java b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/DummyDocument.java deleted file mode 100644 index 4b17910..0000000 --- a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/DummyDocument.java +++ /dev/null @@ -1,450 +0,0 @@ -/* - * Created on 28.04.2003 - * - */ -package net.sourceforge.phpeclipse.phpeditor.php.test; - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.BadPositionCategoryException; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.IDocumentListener; -import org.eclipse.jface.text.IDocumentPartitioner; -import org.eclipse.jface.text.IDocumentPartitioningListener; -import org.eclipse.jface.text.IPositionUpdater; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.ITypedRegion; -import org.eclipse.jface.text.Position; - -/** - * Mockobject for Testing. - * - * @author Stefan Langer - * @version $Revision: 1.3 $ - */ -public class DummyDocument extends Document // implements IDocument -{ - private char[] fTextBuffer; - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#getChar(int) - */ - public char getChar(int offset) throws BadLocationException { - if (offset >= 0 && offset < fTextBuffer.length) - return fTextBuffer[offset]; - else - throw new BadLocationException("Offset out of range!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#getLength() - */ - public int getLength() { - return fTextBuffer.length; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#get() - */ - public String get() { - return String.copyValueOf(fTextBuffer); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#get(int, int) - */ - public String get(int offset, int length) throws BadLocationException { - if (offset >= 0 && (offset + length) < fTextBuffer.length) - return String.copyValueOf(fTextBuffer, offset, length); - else - throw new BadLocationException("Out of range!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#set(java.lang.String) - */ - public void set(String text) { - fTextBuffer = text.toCharArray(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#replace(int, int, java.lang.String) - */ - public void replace(int offset, int length, String text) - throws BadLocationException { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#addDocumentListener(org.eclipse.jface.text.IDocumentListener) - */ - public void addDocumentListener(IDocumentListener listener) { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#removeDocumentListener(org.eclipse.jface.text.IDocumentListener) - */ - public void removeDocumentListener(IDocumentListener listener) { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#addPrenotifiedDocumentListener(org.eclipse.jface.text.IDocumentListener) - */ - public void addPrenotifiedDocumentListener(IDocumentListener documentAdapter) { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#removePrenotifiedDocumentListener(org.eclipse.jface.text.IDocumentListener) - */ - public void removePrenotifiedDocumentListener( - IDocumentListener documentAdapter) { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#addPositionCategory(java.lang.String) - */ - // public void addPositionCategory(String category) - // { - // throw new UnsupportedOperationException("Not implemented!"); - // } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#removePositionCategory(java.lang.String) - */ - public void removePositionCategory(String category) - throws BadPositionCategoryException { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#getPositionCategories() - */ - public String[] getPositionCategories() { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#containsPositionCategory(java.lang.String) - */ - // public boolean containsPositionCategory(String category) - // { - // throw new UnsupportedOperationException("Not implemented!"); - // } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#addPosition(org.eclipse.jface.text.Position) - */ - public void addPosition(Position position) throws BadLocationException { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#removePosition(org.eclipse.jface.text.Position) - */ - public void removePosition(Position position) { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#addPosition(java.lang.String, - * org.eclipse.jface.text.Position) - */ - public void addPosition(String category, Position position) - throws BadLocationException, BadPositionCategoryException { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#removePosition(java.lang.String, - * org.eclipse.jface.text.Position) - */ - public void removePosition(String category, Position position) - throws BadPositionCategoryException { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#getPositions(java.lang.String) - */ - public Position[] getPositions(String category) - throws BadPositionCategoryException { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#containsPosition(java.lang.String, - * int, int) - */ - public boolean containsPosition(String category, int offset, int length) { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#computeIndexInCategory(java.lang.String, - * int) - */ - public int computeIndexInCategory(String category, int offset) - throws BadLocationException, BadPositionCategoryException { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#addPositionUpdater(org.eclipse.jface.text.IPositionUpdater) - */ - // public void addPositionUpdater(IPositionUpdater updater) - // { - // throw new UnsupportedOperationException("Not implemented!"); - // } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#removePositionUpdater(org.eclipse.jface.text.IPositionUpdater) - */ - public void removePositionUpdater(IPositionUpdater updater) { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#insertPositionUpdater(org.eclipse.jface.text.IPositionUpdater, - * int) - */ - // public void insertPositionUpdater(IPositionUpdater updater, int index) - // { - // throw new UnsupportedOperationException("Not implemented!"); - // } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#getPositionUpdaters() - */ - public IPositionUpdater[] getPositionUpdaters() { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#getLegalContentTypes() - */ - public String[] getLegalContentTypes() { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#getContentType(int) - */ - public String getContentType(int offset) throws BadLocationException { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#getPartition(int) - */ - public ITypedRegion getPartition(int offset) throws BadLocationException { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#computePartitioning(int, int) - */ - public ITypedRegion[] computePartitioning(int offset, int length) - throws BadLocationException { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#addDocumentPartitioningListener(org.eclipse.jface.text.IDocumentPartitioningListener) - */ - public void addDocumentPartitioningListener( - IDocumentPartitioningListener listener) { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#removeDocumentPartitioningListener(org.eclipse.jface.text.IDocumentPartitioningListener) - */ - public void removeDocumentPartitioningListener( - IDocumentPartitioningListener listener) { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#setDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) - */ - public void setDocumentPartitioner(IDocumentPartitioner partitioner) { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#getDocumentPartitioner() - */ - public IDocumentPartitioner getDocumentPartitioner() { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#getLineLength(int) - */ - public int getLineLength(int line) throws BadLocationException { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#getLineOfOffset(int) - */ - public int getLineOfOffset(int offset) throws BadLocationException { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#getLineOffset(int) - */ - public int getLineOffset(int line) throws BadLocationException { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#getLineInformation(int) - */ - public IRegion getLineInformation(int line) throws BadLocationException { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#getLineInformationOfOffset(int) - */ - public IRegion getLineInformationOfOffset(int offset) - throws BadLocationException { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#getNumberOfLines() - */ - public int getNumberOfLines() { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#getNumberOfLines(int, int) - */ - public int getNumberOfLines(int offset, int length) - throws BadLocationException { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#computeNumberOfLines(java.lang.String) - */ - public int computeNumberOfLines(String text) { - throw new UnsupportedOperationException("Not implemented!"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#getLegalLineDelimiters() - */ - // public String[] getLegalLineDelimiters() - // { - // throw new UnsupportedOperationException("Not implemented!"); - // } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#getLineDelimiter(int) - */ - // public String getLineDelimiter(int line) throws BadLocationException - // { - // throw new UnsupportedOperationException("Not implemented!"); - // } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocument#search(int, java.lang.String, - * boolean, boolean, boolean) - */ - public int search(int startOffset, String findString, - boolean forwardSearch, boolean caseSensitive, boolean wholeWord) - throws BadLocationException { - throw new UnsupportedOperationException("Not implemented!"); - } - -} diff --git a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/IdentifierIndexManagerTest.java b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/IdentifierIndexManagerTest.java deleted file mode 100644 index ec1fe7b..0000000 --- a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/IdentifierIndexManagerTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Created on 08.05.2004 - * - * To change the template for this generated file go to - * Window - Preferences - Java - Code Generation - Code and Comments - */ -package net.sourceforge.phpeclipse.phpeditor.php.test; - -import java.io.StringBufferInputStream; - -import junit.framework.TestCase; -import net.sourceforge.phpeclipse.builder.IdentifierIndexManager; - -import org.eclipse.core.runtime.CoreException; - -/** - * - */ -public class IdentifierIndexManagerTest extends TestCase { - IdentifierIndexManager fManager; - - public void testManager() { - System.out.println("----- testManager -----"); - String testString = "]*script*\\\"?[^>]*>\", $secvalue)) ||\r\n" - + " (eregi(\"<[^>]*object*\\\"?[^>]*>\", $secvalue)) ||\r\n" - + " (eregi(\"<[^>]*iframe*\\\"?[^>]*>\", $secvalue)) ||\r\n" - + " (eregi(\"<[^>]*applet*\\\"?[^>]*>\", $secvalue)) ||\r\n" - + " (eregi(\"<[^>]*meta*\\\"?[^>]*>\", $secvalue)) ||\r\n" - + " (eregi(\"<[^>]*style*\\\"?[^>]*>\", $secvalue)) ||\r\n" - + " (eregi(\"<[^>]*form*\\\"?[^>]*>\", $secvalue)) ||\r\n" - + " (eregi(\"\\([^>]*\\\"?[^)]*\\)\", $secvalue)) ||\r\n" - + " (eregi(\"\\\"\", $secvalue))) {\r\n" - + " die (\"


    The html tags you attempted to use are not allowed

    [ Go Back ]\");\r\n" - + " } ?>"; - IdentifierIndexManager.LineCreator lineCreator = fManager - .createLineCreator(); - try { - fManager.addInputStream(new StringBufferInputStream(testString), - "test", lineCreator); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - /* - * (non-Javadoc) - * - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - fManager = new IdentifierIndexManager("c:\\temp\\test"); - } -} diff --git a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/PHPFormatterTest.java b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/PHPFormatterTest.java deleted file mode 100644 index a6915be..0000000 --- a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/PHPFormatterTest.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Created on 28.04.2003 - * - */ -package net.sourceforge.phpeclipse.phpeditor.php.test; - -import java.util.Map; - -import junit.framework.TestCase; -import net.sourceforge.phpdt.core.JavaCore; -import net.sourceforge.phpdt.internal.corext.codemanipulation.StubUtility; -import net.sourceforge.phpdt.internal.corext.util.Strings; -import net.sourceforge.phpdt.internal.formatter.CodeFormatter; -import net.sourceforge.phpdt.internal.ui.preferences.CodeFormatterPreferencePage; - -import org.eclipse.jface.text.IDocument; - -/** - * Testcase for the PHP CodeFormatter - * - * @author Stefan Langer - * @version $Revision: 1.7 $ - */ -public class PHPFormatterTest extends TestCase { - private CodeFormatter fFormatter; - - private IDocument fDocument; - - private String fInitialIndentation; - - /* - * (non-Javadoc) - * - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - Map options = JavaCore.getOptions(); - fFormatter = new CodeFormatter(options); - fDocument = new DummyDocument(); - } - - public void testFormatter0() { - System.out.println("----- testFormatter0 -----"); - String text = ""; - fDocument.set(text); - String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument); - int indent = 0; - if (fInitialIndentation != null) { - indent = Strings.computeIndent(fInitialIndentation, - CodeFormatterPreferencePage.getTabSize()); - } - String formatedString = fFormatter.format(text, indent, null, - lineDelimiter); - String testResult = ""; - junit.framework.Assert.assertEquals(formatedString, testResult); - } - - public void testFormatter1() { - System.out.println("----- testFormatter1 -----"); - String text = ""; - fDocument.set(text); - String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument); - int indent = 0; - if (fInitialIndentation != null) { - indent = Strings.computeIndent(fInitialIndentation, - CodeFormatterPreferencePage.getTabSize()); - } - String formatedString = fFormatter.format(text, indent, null, - lineDelimiter); - String testResult = ""; - junit.framework.Assert.assertEquals(formatedString, testResult); - } - - public void testFormatter2() { - // bug 741752 - System.out.println("----- testFormatter2 -----"); - String text = ""; - fDocument.set(text); - String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument); - int indent = 0; - if (fInitialIndentation != null) { - indent = Strings.computeIndent(fInitialIndentation, - CodeFormatterPreferencePage.getTabSize()); - } - String formatedString = fFormatter.format(text, indent, null, - lineDelimiter); - String testResult = ""; - junit.framework.Assert.assertEquals(formatedString, testResult); - } - - public void testFormatter3() { - System.out.println("----- testFormatter1 -----"); - String text = ""; - fDocument.set(text); - String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument); - int indent = 0; - if (fInitialIndentation != null) { - indent = Strings.computeIndent(fInitialIndentation, - CodeFormatterPreferencePage.getTabSize()); - } - String formatedString = fFormatter.format(text, indent, null, - lineDelimiter); - String testResult = ""; - junit.framework.Assert.assertEquals(formatedString, testResult); - } - - public void testArrayFormatting() throws Exception { - System.out.println("-----testArrayFormatting-----"); - String text = " 'ok','snd' => 'right','3th' => 'super');\n" - + "?>"; - fDocument.set(text); - String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument); - int indent = 0; - if (fInitialIndentation != null) { - indent = Strings.computeIndent(fInitialIndentation, - CodeFormatterPreferencePage.getTabSize()); - } - String formatedString = fFormatter.format(text, indent, null, - lineDelimiter); - String testResult = " 'ok'," + lineDelimiter - + "\t'snd' => 'right'," + lineDelimiter + "\t'3th' => 'super'" - + lineDelimiter + ");" + lineDelimiter + "?>"; - junit.framework.Assert.assertEquals(formatedString, testResult); - } - - public void testDoubleArrayFormatting() throws Exception { - System.out.println("-----testDoubleArrayFormatting-----"); - String text = " 'ok', 'snd' => array ('1' => '11','2' => '22'),'3th' => 'super');\n" - + "?>"; - fDocument.set(text); - String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument); - int indent = 0; - if (fInitialIndentation != null) { - indent = Strings.computeIndent(fInitialIndentation, - CodeFormatterPreferencePage.getTabSize()); - } - String formatedString = fFormatter.format(text, indent, null, - lineDelimiter); - String testResult = " 'ok'," + lineDelimiter - + "\t'snd' => array (" + lineDelimiter + "\t\t'1' => '11'," - + lineDelimiter + "\t\t'2' => '22'" + lineDelimiter + "\t)," - + lineDelimiter + "\t'3th' => 'super'" + lineDelimiter + ");" - + lineDelimiter + "?>"; - junit.framework.Assert.assertEquals(formatedString, testResult); - } - -} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/OverlibTestCase.java b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/OverlibTestCase.java deleted file mode 100644 index f6278a2..0000000 --- a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/OverlibTestCase.java +++ /dev/null @@ -1,469 +0,0 @@ -package net.sourceforge.phpeclipse.tests.parser; - -/******************************************************************************* - * Copyright (c) 2002 www.phpeclipse.de 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 - ******************************************************************************/ -import net.sourceforge.phpdt.core.tests.util.AbstractCompilerTest; - -/** - * Tests the php parser - */ -public class OverlibTestCase extends AbstractCompilerTest { - // Parser parser; - public OverlibTestCase(String name) { - super(name); - } - - /** - * Test the PHP Parser with different PHP snippets - */ - public void testPHPParser() { - checkPHP("\r\n" - + " /*\r\n" - + "\r\n" - + " This is version 1.11 of class.overlib for php (http://www.php.net) \r\n" - + "\r\n" - + " written 1999, 2000, 2001 Patrick Hess \r\n" - + "\r\n" - + " This software is distributed under GPL.\r\n" - + " \r\n" - + " overLib is from Eric Bosrup (http://www.bosrup.com/web/overlib/)\r\n" - + "\r\n" - + " This class is just a driver/container, so most of this wonderful\r\n" - + " \r\n" - + " work is done by Eric Bosrup! Keep this in mind... \r\n" - + " \r\n" - + " */\r\n" - + "\r\n" - + "include(\"hello_world\"); \r\n" - + "function foo() {" - + "} \r\n" - + "\r\n" - + " class Overlib {\r\n" - + "\r\n" - + " public $ol_path = \"modules/Forums\";\r\n" - + "\r\n" - + " public $ol_sticky = false;\r\n" - + "\r\n" - + " public $ol_align = 0;\r\n" - + "\r\n" - + " public $ol_valign = 0;\r\n" - + "\r\n" - + " public $ol_fgcolor = \"#fcfcfc\";\r\n" - + "\r\n" - + " public $ol_bgcolor = \"#0080C0\";\r\n" - + "\r\n" - + " public $ol_capcolor = \"#ffffff\";\r\n" - + "\r\n" - + " public $ol_textcolor = \"\";\r\n" - + "\r\n" - + " public $ol_closecolor = \"\";\r\n" - + "\r\n" - + " public $ol_textfont = \"\";\r\n" - + "\r\n" - + " public $ol_captionfont = \"\";\r\n" - + "\r\n" - + " public $ol_closefont = \"\";\r\n" - + "\r\n" - + " public $ol_textsize = 0;\r\n" - + "\r\n" - + " public $ol_captionsize = 0;\r\n" - + "\r\n" - + " public $ol_closesize = 0;\r\n" - + "\r\n" - + " public $ol_height = 0;\r\n" - + "\r\n" - + " public $ol_width = 0;\r\n" - + "\r\n" - + " public $ol_border = 3;\r\n" - + "\r\n" - + " public $ol_offsetx = 0;\r\n" - + "\r\n" - + " public $ol_offsety = 0;\r\n" - + "\r\n" - + " public $ol_fgbackground = \"\";\r\n" - + "\r\n" - + " public $ol_bgbackground = \"\";\r\n" - + "\r\n" - + " public $ol_closetext = \"Close\";\r\n" - + "\r\n" - + " public $ol_close = true;\r\n" - + "\r\n" - + " public $ol_noclosetext = false;\r\n" - + "\r\n" - + " public $ol_autostatus = false;\r\n" - + "\r\n" - + " public $ol_autostatuscap = false;\r\n" - + "\r\n" - + " public $ol_capicon = \"images/forum/question.gif\";\r\n" - + "\r\n" - + " public $ol_snapx = 0;\r\n" - + "\r\n" - + " public $ol_snapy = 0;\r\n" - + "\r\n" - + " public $ol_padxl = 0;\r\n" - + "\r\n" - + " public $ol_padxr = 0;\r\n" - + "\r\n" - + " public $ol_padyt = 0;\r\n" - + "\r\n" - + " public $ol_padyb = 0;\r\n" - + "\r\n" - + " public $ol_fixy = 0;\r\n" - + "\r\n" - + " public $ol_background = \"\";\r\n" - + "\r\n" - + " public $ol_fullhtml = false;\r\n" - + "\r\n" - + " public $ol_timeout = -1;\r\n" - + "\r\n" - + " public $ol_delay = -1;\r\n" - + "\r\n" - + " public $ol_vauto = false;\r\n" - + "\r\n" - + " public $ol_hauto = false;\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " function overLib($path = \"\") {\r\n" - + "\r\n" - + " if (strlen($path)) $this->ol_path = $path;\r\n" - + "\r\n" - + "?>\r\n" - + "\r\n" - + "ol_path/overlib.css\' \"; ?> \r\n" - + "\r\n" - + " type=\'text/css\'>\r\n" - + "\r\n" - + "
    \r\n" - + "\r\n" - + "
    \r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + "$v = $value;\r\n" - + "\r\n" - + " }\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " function get($var) {\r\n" - + "\r\n" - + " $v = \"ol_$var\";\r\n" - + "\r\n" - + " return($this->$v);\r\n" - + "\r\n" - + " }\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " function over($text, $title = \"\", $status = \"\")\r\n" - + "\r\n" - + " {\r\n" - + "\r\n" - + " $cmd = \"\'$text\'\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if(strlen($title)) \r\n" - + "\r\n" - + " $cmd .= \", CAPTION, \'$title\'\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if(strlen($status)) \r\n" - + "\r\n" - + " $cmd .= \", STATUS, \'$status\'\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if($this->ol_sticky) \r\n" - + "\r\n" - + " $cmd .= \", STICKY\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if($this->ol_align) {\r\n" - + "\r\n" - + " switch($this->ol_align) {\r\n" - + "\r\n" - + " case 1: $cmd .= \", LEFT\"; break;\r\n" - + "\r\n" - + " case 2: $cmd .= \", CENTER\"; break;\r\n" - + "\r\n" - + " case 3: $cmd .= \", RIGHT\"; break;\r\n" - + "\r\n" - + " default: break;\r\n" - + "\r\n" - + " }\r\n" - + "\r\n" - + " }\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if($this->ol_valign) {\r\n" - + "\r\n" - + " switch($this->ol_valign) {\r\n" - + "\r\n" - + " case 1: $cmd .= \", ABOVE\"; break;\r\n" - + "\r\n" - + " case 2: $cmd .= \", BELOW\"; break;\r\n" - + "\r\n" - + " default: break;\r\n" - + "\r\n" - + " }\r\n" - + "\r\n" - + " }\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if (strlen($this->ol_fgbackground)) {\r\n" - + "\r\n" - + " $cmd .= \", FGCOLOR, \'\', FGBACKGROUND, \'$this->ol_fgbackground\'\";\r\n" - + "\r\n" - + " } else {\r\n" - + "\r\n" - + " if (strlen($this->ol_fgcolor))\r\n" - + "\r\n" - + " $cmd .= \", FGCOLOR, \'$this->ol_fgcolor\'\";\r\n" - + "\r\n" - + " }\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if (strlen($this->ol_bgbackground)) {\r\n" - + "\r\n" - + " $cmd .= \", BGCOLOR, \'\', BGBACKGROUND, \'$this->ol_bgbackground\'\";\r\n" - + "\r\n" - + " } else {\r\n" - + "\r\n" - + " if (strlen($this->ol_bgcolor))\r\n" - + "\r\n" - + " $cmd .= \", BGCOLOR, \'$this->ol_bgcolor\'\";\r\n" - + "\r\n" - + " }\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if (strlen($this->ol_capcolor))\r\n" - + "\r\n" - + " $cmd .= \", CAPCOLOR, \'$this->ol_capcolor\'\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if (strlen($this->ol_textcolor))\r\n" - + "\r\n" - + " $cmd .= \", TEXTCOLOR, \'$this->ol_textcolor\'\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if (strlen($this->ol_closecolor))\r\n" - + "\r\n" - + " $cmd .= \", CLOSECOLOR, \'$this->ol_closecolor\'\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if (strlen($this->ol_textfont))\r\n" - + "\r\n" - + " $cmd .= \", TEXTFONT, \'$this->ol_textfont\'\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if (strlen($this->ol_captionfont))\r\n" - + "\r\n" - + " $cmd .= \", CAPTIONFONT, \'$this->ol_captionfont\'\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if (strlen($this->ol_closefont))\r\n" - + "\r\n" - + " $cmd .= \", CLOSEFONT, \'$this->ol_closefont\'\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if ($this->ol_textsize)\r\n" - + "\r\n" - + " $cmd .= \", TEXTSIZE, $this->ol_textsize\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if ($this->ol_captionsize)\r\n" - + "\r\n" - + " $cmd .= \", CAPTIONSIZE, $this->ol_captionsize\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if ($this->ol_closesize)\r\n" - + "\r\n" - + " $cmd .= \", CLOSESIZE, $this->ol_closesize\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if ($this->ol_width)\r\n" - + "\r\n" - + " $cmd .= \", WIDTH, $this->ol_width\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if ($this->ol_height)\r\n" - + "\r\n" - + " $cmd .= \", HEIGHT, $this->ol_height\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if ($this->ol_border >= 0)\r\n" - + "\r\n" - + " $cmd .= \", BORDER, $this->ol_border\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if ($this->ol_offsetx)\r\n" - + "\r\n" - + " $cmd .= \", OFFSETX, $this->ol_offsetx\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if ($this->ol_offsety)\r\n" - + "\r\n" - + " $cmd .= \", OFFSETY, $this->ol_offsety\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if (strlen($this->ol_closetext))\r\n" - + "\r\n" - + " $cmd .= \", CLOSETEXT, \'$this->ol_closetext\'\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if ($this->ol_noclose)\r\n" - + "\r\n" - + " $cmd .= \", NOCLOSETEXT\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if ($this->ol_autostatus)\r\n" - + "\r\n" - + " $cmd .= \", AUTOSTATUS\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if ($this->ol_autostatuscap)\r\n" - + "\r\n" - + " $cmd .= \", AUTOSTATUSCAP\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if (strlen($this->ol_capicon))\r\n" - + "\r\n" - + " $cmd .= \", CAPICON, \'$this->ol_capicon\'\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if ($this->ol_snapx)\r\n" - + "\r\n" - + " $cmd .= \", SNAPX, $this->ol_snapx\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if ($this->ol_snapy)\r\n" - + "\r\n" - + " $cmd .= \", SNAPY, $this->ol_snapy\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if ($this->ol_fixy)\r\n" - + "\r\n" - + " $cmd .= \", FIXY, $this->ol_fixy\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if ($this->ol_padxl || $this->ol_padxr)\r\n" - + "\r\n" - + " $cmd .= \", PADX, $this->ol_padxl, $this->ol_padxr\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if ($this->ol_padyt || $this->ol_padyb)\r\n" - + "\r\n" - + " $cmd .= \", PADY, $this->ol_padyt, $this->ol_padyb\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if (strlen($this->ol_background))\r\n" - + "\r\n" - + " $cmd .= \", BACKGROUND, \'$this->ol_background\'\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if ($this->ol_fullhtml)\r\n" - + "\r\n" - + " $cmd .= \", FULLHTML\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if ($this->ol_timeout >= 0)\r\n" - + "\r\n" - + " $cmd .= \", TIMEOUT, $this->ol_timeout\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if ($this->ol_delay >= 0)\r\n" - + "\r\n" - + " $cmd .= \", DELAY, $this->ol_delay\";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if ($this->ol_hauto) {\r\n" - + "\r\n" - + " $cmd .= \", HAUTO\";\r\n" - + "\r\n" - + " $this->ol_hauto = false;\r\n" - + "\r\n" - + " }\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " if ($this->ol_vauto) {\r\n" - + "\r\n" - + " $cmd .= \", VAUTO\";\r\n" - + "\r\n" - + " $this->ol_hauto = false;\r\n" - + "\r\n" - + " }\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " $output=\" onMouseOver=\\\"return overlib($cmd);\\\" \";\r\n" - + "\r\n" - + " $output.=\" onMouseOut=\\\"nd();\\\" \";\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " return ($output);\r\n" - + "\r\n" - + " }\r\n" - + "\r\n" - + "\r\n" - + "\r\n" - + " function pover ($text, $title = \"\", $status = \"\") \r\n" - + "\r\n" + " {\r\n" + "\r\n" - + " echo $this->over($text, $title, $status);\r\n" + "\r\n" - + " }\r\n" + "\r\n" + " }\r\n" + "\r\n" + "?>\r\n" + "\r\n" - + "\r\n" + "\r\n" + "\r\n" + "\r\n" + ""); - } -} diff --git a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/PHPManualTestCase.java b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/PHPManualTestCase.java deleted file mode 100644 index 4233c80..0000000 --- a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/PHPManualTestCase.java +++ /dev/null @@ -1,244 +0,0 @@ -package net.sourceforge.phpeclipse.tests.parser; - -/******************************************************************************* - * Copyright (c) 2002 www.phpeclipse.de 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 - ******************************************************************************/ -import net.sourceforge.phpdt.core.tests.util.AbstractCompilerTest; - -/** - * Tests the php parser - */ -public class PHPManualTestCase extends AbstractCompilerTest { - // Parser parser; - public PHPManualTestCase(String name) { - super(name); - } - - /** - * Test the PHP Parser with different PHP snippets - */ - public void testPHPParser() { - checkPHP("self::$instance = new Singleton();"); - checkPHP("if ((eregi(\"<[^>]*script*\\\"?[^>]*>\", $secvalue)) ||\r\n" - + " (eregi(\"<[^>]*object*\\\"?[^>]*>\", $secvalue)) ||\r\n" - + " (eregi(\"<[^>]*iframe*\\\"?[^>]*>\", $secvalue)) ||\r\n" - + " (eregi(\"<[^>]*applet*\\\"?[^>]*>\", $secvalue)) ||\r\n" - + " (eregi(\"<[^>]*meta*\\\"?[^>]*>\", $secvalue)) ||\r\n" - + " (eregi(\"<[^>]*style*\\\"?[^>]*>\", $secvalue)) ||\r\n" - + " (eregi(\"<[^>]*form*\\\"?[^>]*>\", $secvalue)) ||\r\n" - + " (eregi(\"\\([^>]*\\\"?[^)]*\\)\", $secvalue)) ||\r\n" - + " (eregi(\"\\\"\", $secvalue))) {\r\n" - + " die (\"


    The html tags you attempted to use are not allowed

    [ Go Back ]\");\r\n" - + " }"); - checkPHP("function foo()" + "{" + " echo \"In foo()
    \\n\";" + "}" - + "" + "function bar($arg = '')" + "{" - + " echo \"In bar(); argument was '$arg'.
    \\n\";" + "}" - + "" + "// This is a wrapper function around echo" - + "function echoit($string)" + "{" + " echo $string;" + "}" - + "" + "$func = 'foo';" + "$func(); // This calls foo()" - + "" + "$func = 'bar';" + "$func('test'); // This calls bar()" - + "" + "$func = 'echoit';" - + "$func('test'); // This calls echoit()" + ""); - checkPHP("class Foo" + "{" + " function Vari()" + " {" - + " $name = 'Bar';" - + " $this->$name(); // This calls the Bar() method\n" - + " }" + " " + " function Bar()" + " {" - + " echo \"This is Bar\";" + " }" + "}" + "" - + "$foo = new Foo();" + "$funcname = \"Var\";" - + "$foo->$varname(); // This calls $foo->Var()\n" + ""); - checkPHP("function square ($num)" + "{" + " return $num * $num;" - + "}" + "echo square (4); // outputs '16'." + ""); - checkPHP("function small_numbers()" + "{" - + " return array (0, 1, 2);" + "}" - + "list ($zero, $one, $two) = small_numbers();" + ""); - checkPHP("function &returns_reference()" + "{" + " return $someref;" - + "}" + "" + "$newref =& returns_reference();" + " " + ""); - checkPHP("function add_some_extra(&$string)" + "{" - + " $string .= 'and something extra.';" + "}" - + "$str = 'This is a string, ';" + "add_some_extra($str);" - + "echo $str; "); - checkPHP("function makecoffee ($type = \"cappuccino\")\n" + "{\n" - + " return \"Making a cup of $type.\\n\";\n" + "}" - + "echo makecoffee ();" + "echo makecoffee (\"espresso\");" - + ""); - checkPHP("$makefoo = true;" - + "" - + "/* We can't call foo() from here " - + " since it doesn't exist yet," - + " but we can call bar() */" - + "" - + "bar();" - + "" - + "if ($makefoo) {" - + " function foo ()" - + " {" - + " echo \"I don't exist until program execution reaches me.\\n\";" - + " }" + "}" + "" + "/* Now we can safely call foo()" - + " since $makefoo evaluated to true */" + "" - + "if ($makefoo) foo();" + "" + "function bar() " + "{" - + " echo \"I exist immediately upon program start.\\n\";" - + "}" + "" + ""); - checkPHP("function foo() " + "{" + " function bar() " + " {" - + " echo \"I don't exist until foo() is called.\\n\";" - + " }" + "}" + "" + "/* We can't call bar() yet" - + " since it doesn't exist. */" + "" + "foo();\n" + "" - + "/* Now we can call bar()," + " foo()'s processesing has" - + " made it accessable. */" + "" + "bar();" + ""); - // Bugs item #690938 - checkPHP(" echo \"This is a test\"; // This is a one-line c++ style comment\n" - + " /* This is a multi line comment\n" - + " yet another line of comment */\n" - + " echo \"This is yet another test\";\n" - + " echo \"One Final Test\"; # This is shell-style style comment \n"); - checkPHP("$bool = TRUE; // a boolean\n" - + "$str = \"foo\"; // a string\n" - + "$int = 12; // an integer\n" + "\n" - + "echo gettype($bool); // prints out \"boolean\"\n" - + "echo gettype($str); // prints out \"string\"\n" + "" - + "// If this is an integer, increment it by four\n" - + "if (is_int($int)) {\n" + " $int += 4;\n" + "}\n" + "\n" - + "// If $bool is a string, print it out\n" - + "// (does not print out anything)\n" - + "if (is_string($bool)) {\n" + " echo \"String: $bool\";\n" - + "}\n"); - checkPHP("$foo = True; // assign the value TRUE to $foo"); - checkPHP("// == is an operator which test\n" - + "// equality and returns a boolean\n" - + "if ($action == \"show_version\") {\n" - + " echo \"The version is 1.23\";\n" + "}\n" + "\n" - + "// this is not necessary...\n" - + "if ($show_separators == TRUE) {\n" - + " echo \"
    \\n\";\n" + "}\n" + "\n" - + "// ...because you can simply type\n" - + "if ($show_separators) {\n" + " echo \"
    \\n\";\n" + "}"); - checkPHP( // "echo gettype((bool) \"\"); // bool(false)\n" - "echo gettype((bool) 1); // bool(true)\n" - + "echo gettype((bool) -2); // bool(true)\n" - + "echo gettype((bool) \"foo\"); // bool(true)\n" - + "echo gettype((bool) 2.3e5); // bool(true)\n" - + "echo gettype((bool) array(12)); // bool(true)\n" - + "echo gettype((bool) array()); // bool(false)\n"); - checkPHP("$a = 1234; # decimal number\n" - + "$a = -123; # a negative number\n" - + "$a = 0123; # octal number (equivalent to 83 decimal)\n" - + "$a = 0x1A; # hexadecimal number (equivalent to 26 decimal)\n"); - checkPHP("$large_number = 2147483647;\n" - + "var_dump($large_number);\n" + "// output: int(2147483647)\n" - + "\n" + "$large_number = 2147483648;\n" - + "var_dump($large_number);\n" - + "// output: float(2147483648)\n" + "" - + "// this goes also for hexadecimal specified integers:\n" - + "var_dump( 0x80000000 );\n" - + "// output: float(2147483648)\n" + "\n" - + "$million = 1000000;\n" - + "$large_number = 50000 * $million;\n" - + "var_dump($large_number);\n" - + "// output: float(50000000000)\n"); - checkPHP("var_dump(25/7); // float(3.5714285714286)\n" - + "var_dump((int) (25/7)); // int(3)\n" - + "var_dump(round(25/7)); // float(4)"); - checkPHP("echo (int) ( (0.1+0.7) * 10 ); // echoes 7!"); - checkPHP("$a = 1.234; " + "$b = 1.2e3; " + "$c = 7E-10;"); - checkPHP("echo 'this is a simple string';\n" + "\n" - + "echo 'You can also have embedded newlines in \n" - + "strings this way as it is\n" + "okay to do';\n" + "\n" - + "// Outputs: \"I'll be back\"\n" - + "echo 'Arnold once said: \"I\\'ll be back\"';\n" + "\n" - + "// Outputs: You deleted C:\\*.*?\n" - + "echo 'You deleted C:\\\\*.*?';\n" + "\n" - + "// Outputs: You deleted C:\\*.*?\n" - + "echo 'You deleted C:\\\\*.*?';\n" + "\n" - + "// Outputs: This will not expand: \\n a newline\n" - + "echo 'This will not expand: \\n a newline';\n" + "\n" - + "// Outputs: Variables do not $expand $either\n" - + "echo 'Variables do not $expand $either';\n"); - - checkPHP("echo \"This works: \" . $arr['foo'][3];"); - checkPHP("echo \"\\$foo==$foo; type is \" . gettype ($foo) . \"
    \\n\";"); - checkPHP("$arr = array(\"foo\" => \"bar\", 12 => true);\n" + "\n" - + "echo $arr[\"foo\"]; // bar\n" + "echo $arr[12]; // 1\n"); - checkPHP("// This array is the same as ...\n" - + "array(5 => 43, 32, 56, \"b\" => 12);\n" + "\n" - + "// ...this array\n" - + "array(5 => 43, 6 => 32, 7 => 56, \"b\" => 12);\n"); - checkPHP("$arr = array(5 => 1, 12 => 2);\n" - + "\n" - + "$arr[] = 56; // This is the same as $arr[13] = 56;\n" - + " // at this point of the script\n" - + "\n" - + "$arr[\"x\"] = 42; // This adds a new element to\n" - + " // the array with key \"x\"\n" - + " \n" - + "unset($arr[5]); // This removes the element from the array\n" - + "\n" + "unset($arr); // This deletes the whole array\n"); - checkPHP("$foo[bar] = 'enemy';\n" + "echo $foo[bar];"); - checkPHP("$a = array( 'color' => 'red',\n" - + " 'taste' => 'sweet',\n" - + " 'shape' => 'round',\n" - + " 'name' => 'apple',\n" - + " 4 // key will be 0\n" - + " );\n" - + "\n" - + "// is completely equivalent with\n" - + "$a['color'] = 'red';\n" - + "$a['taste'] = 'sweet';\n" - + "$a['shape'] = 'round';\n" - + "$a['name'] = 'apple';\n" - + "$a[] = 4; // key will be 0\n" - + "\n" - + "$b[] = 'a';\n" - + "$b[] = 'b';\n" - + "$b[] = 'c';\n" - + "// will result in the array array(0 => 'a' , 1 => 'b' , 2 => 'c'),\n" - + "// or simply array('a', 'b', 'c')\n"); - checkPHP("foreach ($colors as $key => $color) {\n" - + " // won't work:\n" - + " //$color = strtoupper($color);\n" + " \n" - + " // works:\n" - + " $colors[$key] = strtoupper($color);\n" + "}\n" - + "print_r($colors);\n"); - checkPHP("$fruits = array ( \"fruits\" => array ( \"a\" => \"orange\",\n" - + " \"b\" => \"banana\",\n" - + " \"c\" => \"apple\"\n" - + " ),\n" - + " \"numbers\" => array ( 1,\n" - + " 2,\n" - + " 3,\n" - + " 4,\n" - + " 5,\n" - + " 6,\n" - + " ),\n" - + " \"holes\" => array ( \"first\",\n" - + " 5 => \"second\",\n" - + " \"third\"\n" - + " )\n" - + " );\n" - + "\n" - + "// Some examples to address values in the array above \n" - + "echo $fruits[\"holes\"][5]; // prints \"second\"\n" - + "echo $fruits[\"fruits\"][\"a\"]; // prints \"orange\"\n" - + "unset($fruits[\"holes\"][0]); // remove \"first\"\n" - + "\n" - + "// Create a new multi-dimensional array\n" - + "$juices[\"apple\"][\"green\"] = \"good\"; \n"); - checkPHP("$arr3 = &$arr1;"); - checkPHP("class foo\n" + "{\n" + " function do_foo()\n" + " {\n" - + " echo \"Doing foo.\"; \n" + " }\n" + "}\n" + "\n" - + "$bar = new foo;\n" + "$bar->do_foo();\n"); - checkPHP("$obj = (object) 'ciao';\n" - + "echo $obj->scalar; // outputs 'ciao'"); - checkPHP("$var = NULL;"); - checkPHP("$var = \"Bob\";\n" + "$Var = \"Joe\";\n" - + "echo \"$var, $Var\"; // outputs \"Bob, Joe\"\n" + "\n" - + - // "$4site = 'not yet'; // invalid; starts with a number\n" + - "$_4site = 'not yet'; // valid; starts with an underscore\n" - + "$t�yte = 'mansikka'; \n"); - - checkPHP(""); - checkPHP(""); - } -} diff --git a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/PHPParserTestCase.java b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/PHPParserTestCase.java deleted file mode 100644 index 0f3e50e..0000000 --- a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/PHPParserTestCase.java +++ /dev/null @@ -1,386 +0,0 @@ -package net.sourceforge.phpeclipse.tests.parser; - -/******************************************************************************* - * Copyright (c) 2002 www.phpeclipse.de 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 - ******************************************************************************/ -import net.sourceforge.phpdt.core.tests.util.AbstractCompilerTest; - -/** - * Tests the php parser - */ -public class PHPParserTestCase extends AbstractCompilerTest { - - public PHPParserTestCase(String name) { - super(name); - } - - /** - * Test the PHP Parser with failing PHP snippets - * - */ - public void testPHPParserFailingSyntax() { - checkPHP( - "i=10;", - "----------\n" - + "1. ERROR in (at line 1)\n" - + " i=10;\n" - + " ^^\n" - + "Parser error \"Assignment operator \'=\' not allowed after identifier \'i\' (use \'define(...)\' to define constants).\"\n" - + "----------\n"); - } - - /** - * Test Interface Extending multiple Interfaces - * - * This is valid PHP5 syntax Bug 1431425 - */ - public void testMIInterfaceExtendsInterface() { - // valid PHP5 - checkPHP("interface a {}\n" + "interface b {}\n" + "\n" - + "interface c extends a, b\n" + "{}\n"); - } - - /** - * Test Interface implementing multiple Interfaces - * - * This is invalid PHP5 syntax Bug 1431425 - */ - public void testMIInterfaceImplementsInterface() { - // invalid PHP5 - checkPHP( - "interface a {}\n" + "interface b {}\n" + "\n" - + "interface c implements a, b\n" + "{}\n", - "----------\n" - + "1. ERROR in (at line 1)\n" - + " interface c implements a, b\n" - + " ^^^^^^^^^^^\n" - + "Parser error \"'{' expected at start of class body.\"\n" - + "----------\n" - + "2. ERROR in (at line 1)\n" - + " {}\n" - + "\n" - + " ^^\n" - + "Parser error \"Too many closing '}'; end-of-file not reached.\"\n" - + "----------\n"); - - } - - /** - * Test Class Extending multiple Interfaces - * - * This is invalid PHP5 syntax Bug 1431425 - */ - public void testMIClassExtendsInterface() { - // invalid PHP5 - checkPHP( - "interface a {}\n" + "interface b {}\n" + "\n" - + "class c extends a, b\n" + "{}\n", - "----------\n" - + "1. ERROR in (at line 1)\n" - + " class c extends a, b\n" - + " ^^\n" - + "Parser error \"No multiple inheritence allowed. Expected token \'implements\' or \'{\'.\"\n" - + "----------\n"); - } - - /** - * Test Class implementing multiple Interfaces - * - * This is valid PHP5 syntax Bug 1431425 - */ - public void testMIClassImplementsInterfaces() { - // valid PHP5 - checkPHP("interface a {}\n" + "interface b {}\n" + "\n" - + "class c implements a, b\n" + "{}\n"); - } - - /** - * Test Class Implementing multiple classes - * - * This is invalid PHP5 syntax Bug 1431425 - */ - public void testMIClassImplementsClasses() { - // invalid PHP5 - checkPHP("class a {}\n" + "class b {}\n" + "\n" - + "class c implements a, b\n" + "{}\n", - "This should fail, but doesn't currently."); - } - - /** - * Test Class Extending multiple Classes - * - * This is invalid PHP5 syntax Bug 1431425 - */ - public void testMIClassExtendsClasses() { - // invalid PHP5 - checkPHP( - "class a {}\n" + "class b {}\n" + "\n" - + "class c extends a, b\n" + "{}\n", - "----------\n" - + "1. ERROR in (at line 1)\n" - + " class c extends a, b\n" - + " ^^\n" - + "Parser error \"No multiple inheritence allowed. Expected token \'implements\' or \'{\'.\"\n" - + "----------\n"); - } - - /** - * Test the PHP Parser with different PHP snippets - */ - public void testPHPParserGoodSyntax() { - checkPHP("$y=self::$x->huba;"); - checkPHP("self::x()->set();"); - checkPHP("$test=\"{4IP}/{$include}\";"); - checkPHP("$this->mRegex = \"/{$this->mBaseRegex}/{$case}\";"); - checkPHP("$schema_create .= \" DEFAULT \'$row[Default]\'\";"); - checkPHP("$stringVar=\"ein normaler $varText\";"); - checkPHP("$stringVar=\'ein normaler $varText\';"); - checkPHP("switch ($aItem[ELM_NAME]) {\r\n" - + " case \'channel\':\r\n" - + " $this->readChannel($aItem);\r\n" - + " break;\r\n" - + " case \'item\':\r\n" - + " $this->readItem($aItem);\r\n" - + " break;\r\n" - + " default:\r\n" - + " //printr($aItem);\r\n" + " }"); - checkPHP("try {echo $Stream->readAll(); } catch (Exception $e) {\r\n" - + " // Swallow exception\r\n" + " }"); - - checkHTML("ol_path = $path;\n" - + "\n" - + "?>\n" - + "\n" - + "ol_path/overlib.css\' \"; ?> \n" - + "\n" - + " type=\'text/css\'>\n" - + "\n" - + "
    \n" - + "\n" - + "
    \n" - + "\n" - + "\n" + "\n" + ""); - checkPHP("$t = \') {$ya[]=\'.$this->iFunc.\';$xa[]=\'.$this->iXFunc.\';}\';"); - checkPHP("$output .= \n" - + " \"\\$_smarty_tpl_vars = \\$this->_tpl_vars;\\n\" . \n" - + " \"\\$this->_smarty_include(\".$include_file.\", array(\".implode(\',\', (array)$arg_list).\"));\\n\" .\n" - + " \"\\$this->_tpl_vars = \\$_smarty_tpl_vars;\\n\" .\n" - + " \"unset(\\$_smarty_tpl_vars);\\n\";"); - checkPHP("$test=\"=$post_id#$post_id\""); - checkPHP("$comments .= \" \\${$attrname}[\'xmlns\'] = \'{$this->namespaces[$_argtype[\'namespace\']]}\';\\n\";"); - checkPHP("$this->_raiseSoapFault(\"method \'{{$this->method_namespace}}$this->methodname\' not defined in service\",\'\',\'\',\'Server\');"); - - checkPHP("$emailer->assign_vars(array(\r\n" - + " \'U_TOPIC\' => $server_protocol . POST_POST_URL . \"=$post_id#$post_id\",\r\n" - + " \'U_STOP_WATCHING_TOPIC\' => $server_protocol . $server_name . $server_port . $script_name . \'&\' . POST_TOPIC_URL . \"=$topic_id&unwatch=topic\")\r\n" - + " );"); - checkPHP("$_compile_data = \'\';"); - checkPHP("$output = \'\'.\"\\n\", $text_blocks[$curr_tb]);"); - checkPHP("$repl.=\"$sug
    \";"); - checkPHP("$heading=\'
    {tr}Blog{/tr}: {$title}
    \'.\"\\n\";"); - checkPHP("return SOAP_Base_Object::_raiseSoapFault(\"No Transport for {$urlparts[\'scheme\']}\");"); - checkPHP("$text_blocks[$curr_tb] = str_replace(\'%%%SMARTYSP\'.$curr_sp.\'%%%\', \'\'.\"\\n\", $text_blocks[$curr_tb]);"); - checkPHP("$output = \'\'$alttext\'
    \";\r\n" - + " "); - checkPHP("$aid = \"$admin[0]\";"); - checkPHP("$headers = '';"); - checkPHP("do {$array[] = array(\"$myrow[uid]\" => \"$myrow[uname]\"); } while($myrow = mysql_fetch_array($result));"); - checkPHP("\"\\\"\";"); - checkPHP(" print \"$value\"; \n"); - checkPHP("if ($shape instanceof Rectangle) { \n" - + " print \'$shape is a Rectangle\'; \n" + "} "); - checkPHP("$test=\"values(\'$user\',\'${res[\"name\"]}\' \";"); - - checkPHP("$this->raiseError(\"The auth mode: $mode isn\'t implemented\");"); - checkPHP("\'{$this->_keycolumn[$i]};"); - checkPHP("$this->_reg_objects[$object] =\n" - + " array(&$object_impl, $allowed, $smarty_args);"); - checkPHP("echo <<< EOF\n" + "
    \n" + + "EOF;"); + checkPHP("interface Shape { \n" + " function draw(); \n" + "} \n" + + "\n" + "class Rectangle implements Shape { \n" + + " function draw() { \n" + + " print \"Drawing a rectangle\"; \n" + " } \n" + + "}"); + checkPHP("class MyClass { \n" + " private $priv; \n" + "\n" + + " public function getVar() { \n" + + " return $this->priv; \n" + " } \n" + "} "); + checkPHP("class Test { \n" + " function __construct() { \n" + + " print \"Test constructor\"; \n" + " } \n" + "}"); + checkPHP("class Test { \n" + " function __destruct() { \n" + + " print \"Destroying Test object\"; \n" + " } \n" + + "}"); + + checkPHP("class Test { \n" + " final function doNotOverload() { \n" + + " return __CLASS__; \n" + " } \n" + "}"); + checkPHP("final class Test { \n" + "} \n" + "\n" + + "class DoNotInherit extends Test { \n" + "}"); + checkPHP("class Test { \n" + " function __clone() { \n" + + " print \"Clone test object\"; \n" + " } \n" + + "} \n" + "$test = new Test(); \n" + "clone $test; "); + checkPHP("class Test { \n" + " const SEMICOLON = \";\"; \n" + + " const QUESTIONMARK = \"?\"; \n" + "} \n" + + "print Test::SEMICOLON; "); + checkPHP("class Singleton { \n" + " static $instance = NULL; \n" + + " function getInstance() { \n" + + " if ($this->instance == NULL) { \n" + + " $this->instance = new Singleton(); \n" + + " } \n" + " return $this->instance; \n" + + " } \n" + "} "); + checkPHP("class Test { \n" + " static function helloWorld() { \n" + + " print \"Hello, world\"; \n" + " } \n" + "} \n" + + "Test::helloWorld();"); + checkPHP("abstract class Test { \n" + " function draw() { \n" + + " print \"Inside draw()\"; \n" + " } \n" + "} "); + checkPHP("abstract class Test { \n" + + " abstract function draw(); \n" + "} "); + checkPHP("function f1(Test $test) { \n" + "\n" + "}"); + checkPHP("$test->m1()->m2(); "); + checkPHP("$test = new IteratorImpl(); \n" + + "foreach ($test as $value) { \n" + " print \"$value\"; \n" + + "}"); + checkPHP("function __autoload($clazz) { \n" + + " include_once($clazz . \"php\"); \n" + "} \n" + "\n" + + "$obj = new Test1(); \n" + "$obj2 = new Test2(); "); + checkPHP("class SQLException extends Exception { \n" + + " public $problem; \n" + + " function __construct($problem) { \n" + + " $this->problem = $problem; \n" + + " } \n" + + "} \n" + + "\n" + + "try { \n" + + " throw new SQLException(\"Couldn’t connect to database\"); \n" + + "} catch (SQLException $e) { \n" + + " print \"Caught an SQLException with problem $obj->problem\"; \n" + + "} catch (Exception $e) { \n" + + " print \"Caught unrecognized exception\"; \n" + "}"); + checkPHP("function my_func(&$arg = null) { \n" + + " if ($arg === NULL) { \n" + + " print \'$arg is empty\'; \n" + " } \n" + "} \n" + + "my_func();"); + checkPHP("foreach ($array as &$value) { \n" + + " if ($value === \"NULL\") { \n" + + " $value = NULL; \n" + " } \n" + "}"); + checkPHP("$testxml = simplexml_load_file(\'test.xml\'); \n" + + "foreach ($$testxml->client as $test) { \n" + + " print \"$test->name has account number $test->account_number \"; \n" + + "} "); + checkHTML(" "); + checkHTML("\n" + + "test me\n" + ""); + + checkHTML(""); + checkPHP("function clean_words($mode, &$entry, &$stopword_list, &$synonym_list)\r\n" + + "{ static $drop_char_match = array(\'^\', \'$\'); }"); + + checkPHP("if ($topic<1) { $topic = 1;}"); + checkPHP("$this->result_field_names[$result_id][] = odbc_field_name($result_id, $i);"); + checkPHP("$db->sql_query($sql);"); + checkPHP("$val = $$add;"); + checkPHP("if(!$result = mysql_query($sql)) return(array());"); + checkPHP("class test { function &fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null) \n{ \n } \n }"); + // Bugs item #690938 + checkPHP("$ebus_sql['sel_url_list'] = <<>\n" + + "and appl_sect_deftn_sk = <>\n" + "order by url_ord\n" + + "EOS;\n"); + checkPHP("foreach ($HTTP_GET_VARS as $secvalue) { }"); + + checkPHP("\"\\[addsig]\""); + checkPHP("$v->read();"); + checkPHP("$add = 'a'.$i;$val = $$add;"); + checkPHP("($a==\"b\") || (c($this->x)==\"d\");"); + checkPHP("(substr($this->file, 0, 2) == \"MM\");"); + checkPHP("(substr($this->file, 0, 2) == \"MM\") || substr($this->file, 0, 2) == \"II\";"); + checkPHP("return (substr($this->file, 0, 2) == \"MM\") || substr($this->file, 0, 2) == \"II\";"); + checkPHP("$this->highlightfile->linkscripts{$category}"); + checkPHP("$code = call_user_method($this->highlightfile->linkscripts{$category}, $this->highlightfile, $oldword, $this->output_module)"); + checkPHP("$this->startmap[$startcurrtag]();"); + checkPHP("new $this->startmap[$startcurrtag]();"); + checkPHP("$this->highlightfile = new $this->startmap[$startcurrtag]();"); + checkPHP("echo \"Test\", \"me\";"); + checkPHP("print (\"Test me\");"); + checkPHP("$s = <<blockvariables[$block][$varname]);"); + checkPHP("new IT_Error(\"The block '$block' was not found in the template.\", __FILE__, __LINE__);"); + checkPHP("for ($i=156, $j=0; $i<512; $i++, $j++) $v_checksum += ord(substr($v_binary_data_last,$j,1));"); + checkPHP("define('MAIL_MIME_CRLF', $crlf, true);"); + checkPHP("static $last_run = 0;"); + checkPHP("unset($headers['Subject']);"); + checkPHP("switch($func) {\n case \"f0\":\n case \"f1\":\n f1();\n break; \n case \"tt\": \n default: \n f0(); \n break;\n }"); + checkPHP("function validateAndParseResponse($code, &$arguments) { }"); + checkPHP("$options = Console_Getopt::getopt($argv, \"h?v:e:p:d:\");"); + checkPHP("$this->container = new $container_class($container_options);"); + checkPHP("class Cmd extends PEAR { var $arrSetting = array(); }"); + checkPHP("class Cmd extends PEAR { var $arrSetting = array(), $i=10; }"); + checkPHP("if (isset($test)) { } elseif (isset($lang)) { }"); + checkPHP("require_once(\"mainfile.php\"); "); + checkPHP("if (eregi(\"footer.php\",$PHP_SELF)) {\n" + + "Header(\"Location: index.php\");\n" + "die();\n" + "}\n"); + checkPHP("while (eregi(\"footer.php\",$PHP_SELF)) {\n" + + "Header(\"Location: index.php\");\n" + "die();\n" + "}\n"); + checkPHP("while (eregi(\"footer.php\",$PHP_SELF)) :\n" + + "Header(\"Location: index.php\");\n" + "die();\n" + + "endwhile;\n"); + checkPHP("$tipath = \"images/topics/\";"); + checkPHP("$reasons = array(\"1\", \"2\",\"test\");"); + checkPHP("if ($home == 1) { message_box(); blocks(Center);}"); + checkPHP("$bresult = sql_query(\"select * from \".$prefix.\"_banner WHERE type='0' AND active='1'\", $dbi);"); + checkPHP("switch($func) {\n case \"f1\":\n f1();\n break; \n default: \n f0(); \n break;\n }"); + checkPHP("list ($catid) = sql_fetch_row($result, $dbi);"); + checkPHP("if (!$name) { \n }"); + checkPHP("mt_srand((double)microtime()*1000000);"); + checkPHP("$alttext = ereg_replace(\"\\\"\", \"\", $alttext);"); + checkPHP("$message .= \"\"._THISISAUTOMATED.\"\\n\\n\";"); + checkPHP("if (!empty($pass) AND $pass==$passwd) { }"); + checkPHP("$AllowableHTML = array(\"b\"=>1,\n \"i\"=>1);"); + checkPHP("if ($term{0}!=$firstChar) {}"); + checkPHP("echo \"
    \"._NOADMINYET.\"


    \"\n" + + ".\"
    \"\n" + + ".\"
    \"._NICKNAME.\":
    \"\n" - + ";"); - checkPHP("/* \n overLib is from Eric Bosrup (http://www.bosrup.com/web/overlib/) \n */"); - checkPHP("if ($arrAtchCookie[1]==0 && $IdAtchPostId!=null){ } "); - checkPHP("$arrAtchCookie[1] -= filesize(realpath($AtchTempDir).\"/\".$xattachlist)/ 1024; "); - checkPHP("if (!isset($message)){ \n" - + "$message = $myrow[post_text];\n" - + "$message = eregi_replace(\"\\[addsig]\", \"\\n-----------------\\n\" . $myrow[user_sig], $message); \n" - + "$message = str_replace(\"
    \", \"\\n\", $message); \n" - + "$message = str_replace(\"
    \", \"\\n\", $message); \n } "); - checkPHP("$ol = new Overlib();"); - checkPHP("$risultato = mysql_query($sql) or\n die(mysql_error());"); - checkHTML("\n\n\n\n "); - checkHTML(""); - checkHTML(""); - checkHTML(" foo "); - checkHTML(" "); - checkHTML(""); - } -} diff --git a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/PHPParserTestSuite.java b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/PHPParserTestSuite.java deleted file mode 100644 index a1dcd97..0000000 --- a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/PHPParserTestSuite.java +++ /dev/null @@ -1,35 +0,0 @@ -package net.sourceforge.phpeclipse.tests.parser; - -/******************************************************************************* - * Copyright (c) 2002 www.phpeclipse.de 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 - ******************************************************************************/ - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * PHPeclipse Parser Test Suite Runs all PHP parser test cases - * - */ -public class PHPParserTestSuite extends TestCase { - - public PHPParserTestSuite(String name) { - super(name); - } - - public static Test suite() { - TestSuite suite = new TestSuite("PHPeclipse Parser Test Suite"); - suite.addTest(new TestSuite(PHPParserTestCase.class)); - suite.addTest(new TestSuite(ShortTagTestCase.class)); - suite.addTest(new TestSuite(PHPManualTestCase.class)); - suite.addTest(new TestSuite(OverlibTestCase.class)); - suite.addTest(new TestSuite(SmartyCompilerTestCase.class)); - return suite; - - } - -} diff --git a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/ShortTagTestCase.java b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/ShortTagTestCase.java deleted file mode 100644 index 7351671..0000000 --- a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/ShortTagTestCase.java +++ /dev/null @@ -1,28 +0,0 @@ -package net.sourceforge.phpeclipse.tests.parser; - -/******************************************************************************* - * Copyright (c) 2002 www.phpeclipse.de 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 - ******************************************************************************/ -import net.sourceforge.phpdt.core.tests.util.AbstractCompilerTest; - -/** - * Tests the php parser - */ -public class ShortTagTestCase extends AbstractCompilerTest { - public ShortTagTestCase(String name) { - super(name); - } - - /** - * Test the PHP Parser with different PHP short tag snippets - */ - public void testPHPParser() { - checkHTML(""); - checkHTML(""); - checkHTML(" text "); - } - -} diff --git a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/SmartyCompilerTestCase.java b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/SmartyCompilerTestCase.java deleted file mode 100644 index 9244622..0000000 --- a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/SmartyCompilerTestCase.java +++ /dev/null @@ -1,1893 +0,0 @@ -package net.sourceforge.phpeclipse.tests.parser; - -/******************************************************************************* - * Copyright (c) 2002 www.phpeclipse.de 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 - ******************************************************************************/ -import net.sourceforge.phpdt.core.tests.util.AbstractCompilerTest; - -/** - * Tests the php parser - */ -public class SmartyCompilerTestCase extends AbstractCompilerTest { - // Parser parser; - public SmartyCompilerTestCase(String name) { - super(name); - } - - /** - * Test the PHP Parser with different PHP snippets - */ - public void testPHPParser() { - checkHTML("\n" - + " * Andrei Zmievski \n" - + " *\n" - + " * Version: 2.4.2\n" - + " * Copyright: 2001,2002 ispi of Lincoln, Inc.\n" - + " *\n" - + " * This library is free software; you can redistribute it and/or\n" - + " * modify it under the terms of the GNU Lesser General Public\n" - + " * License as published by the Free Software Foundation; either\n" - + " * version 2.1 of the License, or (at your option) any later version.\n" - + " *\n" - + " * This library is distributed in the hope that it will be useful,\n" - + " * but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - + " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" - + " * Lesser General Public License for more details.\n" - + " *\n" - + " * You should have received a copy of the GNU Lesser General Public\n" - + " * License along with this library; if not, write to the Free Software\n" - + " * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n" - + " *\n" - + " * You may contact the authors of Smarty by e-mail at:\n" - + " * monte@ispi.net\n" - + " * andrei@php.net\n" - + " *\n" - + " * Or, write to:\n" - + " * Monte Ohrt\n" - + " * Director of Technology, ispi\n" - + " * 237 S. 70th suite 220\n" - + " * Lincoln, NE 68510\n" - + " *\n" - + " * The latest version of Smarty can be obtained from:\n" - + " * http://www.phpinsider.com/\n" - + " *\n" - + " */\n" - + "\n" - + "class Smarty_Compiler extends Smarty {\n" - + " \n" - + " // internal vars\n" - + " public $_sectionelse_stack = array(); // keeps track of whether section had \'else\' part\n" - + " public $_foreachelse_stack = array(); // keeps track of whether foreach had \'else\' part\n" - + " public $_literal_blocks = array(); // keeps literal template blocks\n" - + " public $_php_blocks = array(); // keeps php code blocks\n" - + " public $_current_file = null; // the current template being compiled\n" - + " public $_current_line_no = 1; // line number for error messages\n" - + " public $_capture_stack = array(); // keeps track of nested capture buffers\n" - + " public $_plugin_info = array(); // keeps track of plugins to load\n" - + " public $_init_smarty_vars = false;\n" - + " public $_permitted_tokens = array(\'true\',\'false\',\'yes\',\'no\',\'on\',\'off\');\n" - + " public $_db_qstr_regexp = null; // regexps are setup in the constructor\n" - + " public $_si_qstr_regexp = null;\n" - + " public $_qstr_regexp = null;\n" - + " public $_func_regexp = null;\n" - + " public $_var_bracket_regexp = null;\n" - + " public $_dvar_guts_regexp = null;\n" - + " public $_dvar_regexp = null;\n" - + " public $_cvar_regexp = null;\n" - + " public $_svar_regexp = null;\n" - + " public $_avar_regexp = null;\n" - + " public $_mod_regexp = null;\n" - + " public $_var_regexp = null;\n" - + " public $_parenth_param_regexp = null;\n" - + " public $_func_call_regexp = null;\n" - + " public $_obj_ext_regexp = null;\n" - + " public $_obj_start_regexp = null;\n" - + " public $_obj_params_regexp = null;\n" - + " public $_obj_call_regexp = null;\n" - + "\n" - + " /**\n" - + " * The class constructor.\n" - + " *\n" - + " * @access public\n" - + " */\n" - + " function Smarty_Compiler()\n" - + " {\n" - + " // matches double quoted strings:\n" - + " // \"foobar\"\n" - + " // \"foo\\\"bar\"\n" - + " $this->_db_qstr_regexp = \'\"[^\"\\\\\\\\]*(?:\\\\\\\\.[^\"\\\\\\\\]*)*\"\';\n" - + "\n" - + " // matches single quoted strings:\n" - + " // \'foobar\'\n" - + " // \'foo\\\'bar\'\n" - + " $this->_si_qstr_regexp = \'\\\'[^\\\'\\\\\\\\]*(?:\\\\\\\\.[^\\\'\\\\\\\\]*)*\\\'\';\n" - + "\n" - + " // matches single or double quoted strings\n" - + " $this->_qstr_regexp = \'(?:\' . $this->_db_qstr_regexp . \'|\' . $this->_si_qstr_regexp . \')\';\n" - + "\n" - + " // matches bracket portion of vars\n" - + " // [0]\n" - + " // [foo]\n" - + " // [$bar]\n" - + " $this->_var_bracket_regexp = \'\\[\\$?[\\w\\.]+\\]\';\n" - + " \n" - + " // matches $ vars (not objects):\n" - + " // $foo\n" - + " // $foo.bar\n" - + " // $foo.bar.foobar\n" - + " // $foo[0]\n" - + " // $foo[$bar]\n" - + " // $foo[5][blah]\n" - + " // $foo[5].bar[$foobar][4]\n" - + " $this->_dvar_guts_regexp = \'\\w+(?:\' . $this->_var_bracket_regexp\n" - + " . \')*(?:\\.\\$?\\w+(?:\' . $this->_var_bracket_regexp . \')*)*\';\n" - + " $this->_dvar_regexp = \'\\$\' . $this->_dvar_guts_regexp;\n" - + "\n" - + " // matches config vars:\n" - + " // #foo#\n" - + " // #foobar123_foo#\n" - + " $this->_cvar_regexp = \'\\#\\w+\\#\';\n" - + "\n" - + " // matches section vars:\n" - + " // %foo.bar%\n" - + " $this->_svar_regexp = \'\\%\\w+\\.\\w+\\%\';\n" - + "\n" - + " // matches all valid variables (no quotes, no modifiers)\n" - + " $this->_avar_regexp = \'(?:\' . $this->_dvar_regexp . \'|\'\n" - + " . $this->_cvar_regexp . \'|\' . $this->_svar_regexp . \')\';\n" - + "\n" - + " // matches valid modifier syntax:\n" - + " // |foo\n" - + " // |@foo\n" - + " // |foo:\"bar\"\n" - + " // |foo:$bar\n" - + " // |foo:\"bar\":$foobar\n" - + " // |foo|bar\n" - + " // |foo\n" - + " $this->_mod_regexp = \'(?:\\|@?\\w+(?::(?>\\w+|\'\n" - + " . $this->_avar_regexp . \'|\' . $this->_qstr_regexp .\'))*)\';\n" - + "\n" - + " // matches valid variable syntax:\n" - + " // $foo\n" - + " // $foo\n" - + " // #foo#\n" - + " // #foo#\n" - + " // \"text\"\n" - + " // \"text\"\n" - + " $this->_var_regexp = \'(?:\' . $this->_avar_regexp . \'|\' . $this->_qstr_regexp . \')\';\n" - + " \n" - + " // matches valid object call (no objects allowed in parameters):\n" - + " // $foo->bar\n" - + " // $foo->bar()\n" - + " // $foo->bar(\"text\")\n" - + " // $foo->bar($foo, $bar, \"text\")\n" - + " // $foo->bar($foo|bar, \"foo\"|bar)\n" - + " // $foo->bar->foo()\n" - + " // $foo->bar->foo->bar()\n" - + " $this->_obj_ext_regexp = \'\\->(?:\\w+|\' . $this->_dvar_regexp . \')\';\n" - + " $this->_obj_params_regexp = \'\\((?:\\w+|\'\n" - + " . $this->_var_regexp . \'(?>\' . $this->_mod_regexp . \'*)(?:\\s*,\\s*(?:(?:\\w+|\'\n" - + " . $this->_var_regexp . \'(?>\' . $this->_mod_regexp . \'*))))*)?\\)\'; \n" - + " $this->_obj_start_regexp = \'(?:\' . $this->_dvar_regexp . \'(?:\' . $this->_obj_ext_regexp . \')+)\';\n" - + " $this->_obj_call_regexp = \'(?:\' . $this->_obj_start_regexp . \'(?:\' . $this->_obj_params_regexp . \')?)\';\n" - + " \n" - + " // matches valid function name:\n" - + " // foo123\n" - + " // _foo_bar\n" - + " $this->_func_regexp = \'[a-zA-Z_]\\w*\';\n" - + "\n" - + " // matches valid registered object:\n" - + " // foo.bar\n" - + " $this->_reg_obj_regexp = \'[a-zA-Z_]\\w*->[a-zA-Z_]\\w*\';\n" - + " \n" - + " // matches valid parameter values:\n" - + " // true\n" - + " // $foo\n" - + " // $foo|bar\n" - + " // #foo#\n" - + " // #foo#|bar\n" - + " // \"text\"\n" - + " // \"text\"|bar\n" - + " // $foo->bar\n" - + " $this->_param_regexp = \'(?:\\s*(?:\' . $this->_obj_call_regexp . \'|\'\n" - + " . $this->_var_regexp . \'|\\w+)(?>\' . $this->_mod_regexp . \'*)\\s*)\'; \n" - + " \n" - + " // matches valid parenthesised function parameters:\n" - + " // \n" - + " // \"text\"\n" - + " // $foo, $bar, \"text\"\n" - + " // $foo|bar, \"foo\"|bar, $foo->bar($foo)|bar\n" - + " $this->_parenth_param_regexp = \'(?:\\((?:\\w+|\'\n" - + " . $this->_param_regexp . \'(?:\\s*,\\s*(?:(?:\\w+|\'\n" - + " . $this->_param_regexp . \')))*)?\\))\';\n" - + " \n" - + " // matches valid function call:\n" - + " // foo()\n" - + " // foo_bar($foo)\n" - + " // _foo_bar($foo,\"bar\")\n" - + " // foo123($foo,$foo->bar(),\"foo\")\n" - + " $this->_func_call_regexp = \'(?:\' . $this->_func_regexp . \'\\s*(?:\'\n" - + " . $this->_parenth_param_regexp . \'))\'; \n" - + "\n" - + " } \n" - + " \n" - + " /**\n" - + " * compile a template file\n" - + " *\n" - + " * @access public\n" - + " * @param $tpl_file\n" - + " * @param $template_source\n" - + " * @param $template_compiled\n" - + " */\n" - + " function _compile_file($tpl_file, $template_source, &$template_compiled)\n" - + " {\n" - + " if ($this->security) {\n" - + " // do not allow php syntax to be executed unless specified\n" - + " if ($this->php_handling == SMARTY_PHP_ALLOW &&\n" - + " !$this->security_settings[\'PHP_HANDLING\']) {\n" - + " $this->php_handling = SMARTY_PHP_PASSTHRU;\n" - + " }\n" - + " }\n" - + "\n" - + " $this->_load_filters();\n" - + "\n" - + " $this->_current_file = $tpl_file;\n" - + " $this->_current_line_no = 1;\n" - + " $ldq = preg_quote($this->left_delimiter, \'!\');\n" - + " $rdq = preg_quote($this->right_delimiter, \'!\');\n" - + "\n" - + " // run template source through prefilter functions\n" - + " if (count($this->_plugins[\'prefilter\']) > 0) {\n" - + " foreach ($this->_plugins[\'prefilter\'] as $filter_name => $prefilter) {\n" - + " if ($prefilter === false) continue; \n" - + " if ($prefilter[3] || function_exists($prefilter[0])) {\n" - + " $template_source = $prefilter[0]($template_source, $this);\n" - + " $this->_plugins[\'prefilter\'][$filter_name][3] = true;\n" - + " } else {\n" - + " $this->_trigger_fatal_error(\"[plugin] prefilter \'$filter_name\' is not implemented\");\n" - + " }\n" - + " }\n" - + " }\n" - + "\n" - + " /* Annihilate the comments. */\n" - + " $template_source = preg_replace(\"!({$ldq})\\*(.*?)\\*({$rdq})!se\",\n" - + " \"\'\\\\1*\'.str_repeat(\\\"\\n\\\", substr_count(\'\\\\2\', \\\"\\n\\\")) .\'*\\\\3\'\",\n" - + " $template_source);\n" - + "\n" - + " /* Pull out the literal blocks. */\n" - + " preg_match_all(\"!{$ldq}literal{$rdq}(.*?){$ldq}/literal{$rdq}!s\", $template_source, $match);\n" - + " $this->_literal_blocks = $match[1];\n" - + " $template_source = preg_replace(\"!{$ldq}literal{$rdq}(.*?){$ldq}/literal{$rdq}!s\",\n" - + " $this->quote_replace($this->left_delimiter.\'literal\'.$this->right_delimiter), $template_source);\n" - + "\n" - + " /* Pull out the php code blocks. */\n" - + " preg_match_all(\"!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s\", $template_source, $match);\n" - + " $this->_php_blocks = $match[1];\n" - + " $template_source = preg_replace(\"!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s\",\n" - + " $this->quote_replace($this->left_delimiter.\'php\'.$this->right_delimiter), $template_source);\n" - + "\n" - + " /* Gather all template tags. */\n" - + " preg_match_all(\"!{$ldq}\\s*(.*?)\\s*{$rdq}!s\", $template_source, $match);\n" - + " $template_tags = $match[1];\n" - + " /* Split content by template tags to obtain non-template content. */\n" - + " $text_blocks = preg_split(\"!{$ldq}.*?{$rdq}!s\", $template_source);\n" - + " \n" - + " /* loop through text blocks */\n" - + " for ($curr_tb = 0, $for_max = count($text_blocks); $curr_tb < $for_max; $curr_tb++) {\n" - + " /* match anything resembling php tags */\n" - + " if (preg_match_all(\'!(<\\?(?:\\w+|=)?|\\?>|language\\s*=\\s*[\\\"\\\']?php[\\\"\\\']?)!is\', $text_blocks[$curr_tb], $sp_match)) {\n" - + " /* replace tags with placeholders to prevent recursive replacements */\n" - + " $sp_match[1] = array_unique($sp_match[1]);\n" - + " usort($sp_match[1], \'_smarty_sort_length\');\n" - + " for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) {\n" - + " $text_blocks[$curr_tb] = str_replace($sp_match[1][$curr_sp],\'%%%SMARTYSP\'.$curr_sp.\'%%%\',$text_blocks[$curr_tb]);\n" - + " }\n" - + " /* process each one */\n" - + " for ($curr_sp = 0, $for_max2 = count($sp_match[0]); $curr_sp < $for_max2; $curr_sp++) {\n" - + " if ($this->php_handling == SMARTY_PHP_PASSTHRU) {\n" - + " /* echo php contents */\n" - + " $text_blocks[$curr_tb] = str_replace(\'%%%SMARTYSP\'.$curr_sp.\'%%%\', \'\'.\"\\n\", $text_blocks[$curr_tb]);\n" - + " } else if ($this->php_handling == SMARTY_PHP_QUOTE) {\n" - + " /* quote php tags */\n" - + " $text_blocks[$curr_tb] = str_replace(\'%%%SMARTYSP\'.$curr_sp.\'%%%\', htmlspecialchars($sp_match[1][$curr_sp]), $text_blocks[$curr_tb]);\n" - + " } else if ($this->php_handling == SMARTY_PHP_REMOVE) {\n" - + " /* remove php tags */\n" - + " $text_blocks[$curr_tb] = str_replace(\'%%%SMARTYSP\'.$curr_sp.\'%%%\', \'\', $text_blocks[$curr_tb]);\n" - + " } else {\n" - + " /* SMARTY_PHP_ALLOW, but echo non php starting tags */\n" - + " $sp_match[1][$curr_sp] = preg_replace(\'%(<\\?(?!php|=|$))%i\', \'\'.\"\\n\", $sp_match[1][$curr_sp]);\n" - + " $text_blocks[$curr_tb] = str_replace(\'%%%SMARTYSP\'.$curr_sp.\'%%%\', $sp_match[1][$curr_sp], $text_blocks[$curr_tb]);\n" - + " }\n" - + " }\n" - + " }\n" - + " }\n" - + "\n" - + " /* Compile the template tags into PHP code. */\n" - + " $compiled_tags = array();\n" - + " for ($i = 0, $for_max = count($template_tags); $i < $for_max; $i++) {\n" - + " $this->_current_line_no += substr_count($text_blocks[$i], \"\\n\");\n" - + " $compiled_tags[] = $this->_compile_tag($template_tags[$i]);\n" - + " $this->_current_line_no += substr_count($template_tags[$i], \"\\n\");\n" - + " }\n" - + "\n" - + " $template_compiled = \'\';\n" - + "\n" - + " /* Interleave the compiled contents and text blocks to get the final result. */\n" - + " for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) {\n" - + " $template_compiled .= $text_blocks[$i].$compiled_tags[$i];\n" - + " }\n" - + " $template_compiled .= $text_blocks[$i];\n" - + "\n" - + " /* Reformat data between \'strip\' and \'/strip\' tags, removing spaces, tabs and newlines. */\n" - + " if (preg_match_all(\"!{$ldq}strip{$rdq}.*?{$ldq}/strip{$rdq}!s\", $template_compiled, $match)) {\n" - + " $strip_tags = $match[0];\n" - + " $strip_tags_modified = preg_replace(\"!{$ldq}/?strip{$rdq}|[\\t ]+$|^[\\t ]+!m\", \'\', $strip_tags);\n" - + " $strip_tags_modified = preg_replace(\'![\\r\\n]+!m\', \'\', $strip_tags_modified);\n" - + " for ($i = 0, $for_max = count($strip_tags); $i < $for_max; $i++)\n" - + " $template_compiled = preg_replace(\"!{$ldq}strip{$rdq}.*?{$ldq}/strip{$rdq}!s\",\n" - + " $this->quote_replace($strip_tags_modified[$i]),\n" - + " $template_compiled, 1);\n" - + " }\n" - + "\n" - + " // remove \\n from the end of the file, if any\n" - + " if ($template_compiled{strlen($template_compiled) - 1} == \"\\n\" ) {\n" - + " $template_compiled = substr($template_compiled, 0, -1);\n" - + " }\n" - + "\n" - + " // run compiled template through postfilter functions\n" - + " if (count($this->_plugins[\'postfilter\']) > 0) {\n" - + " foreach ($this->_plugins[\'postfilter\'] as $filter_name => $postfilter) {\n" - + " if ($postfilter === false) continue;\n" - + " if ($postfilter[3] || function_exists($postfilter[0])) {\n" - + " $template_compiled = $postfilter[0]($template_compiled, $this);\n" - + " $this->_plugins[\'postfilter\'][$filter_name][3] = true;\n" - + " } else {\n" - + " $this->_trigger_plugin_error(\"Smarty plugin error: postfilter \'$filter_name\' is not implemented\");\n" - + " }\n" - + " }\n" - + " }\n" - + "\n" - + " // put header at the top of the compiled template\n" - + " $template_header = \"_version.\", created on \".strftime(\"%Y-%m-%d %H:%M:%S\").\"\\n\";\n" - + " $template_header .= \" compiled from \".$tpl_file.\" */ ?>\\n\";\n" - + "\n" - + " /* Emit code to load needed plugins. */\n" - + " if (count($this->_plugin_info)) {\n" - + " $plugins_code = \'_load_plugins(array(\';\n" - + " foreach ($this->_plugin_info as $plugin_type => $plugins) {\n" - + " foreach ($plugins as $plugin_name => $plugin_info) {\n" - + " $plugins_code .= \"\\narray(\'$plugin_type\', \'$plugin_name\', \'$plugin_info[0]\', $plugin_info[1], \";\n" - + " $plugins_code .= $plugin_info[2] ? \'true),\' : \'false),\';\n" - + " }\n" - + " }\n" - + " $plugins_code .= \")); ?>\";\n" - + " $template_header .= $plugins_code;\n" - + " $this->_plugin_info = array();\n" - + " }\n" - + "\n" - + " if ($this->_init_smarty_vars) {\n" - + " $template_header .= \"_assign_smarty_interface(); ?>\\n\";\n" - + " $this->_init_smarty_vars = false;\n" - + " }\n" - + "\n" - + " $template_compiled = $template_header . $template_compiled;\n" - + "\n" - + " return true;\n" - + " }\n" - + "\n" - + " /**\n" - + " * Compile a template tag\n" - + " *\n" - + " * @access public\n" - + " * @param $template_tag\n" - + " */\n" - + " function _compile_tag($template_tag)\n" - + " { \n" - + " \n" - + " /* Matched comment. */\n" - + " if ($template_tag{0} == \'*\' && $template_tag{strlen($template_tag) - 1} == \'*\')\n" - + " return \'\';\n" - + " \n" - + " /* Split tag into two three parts: command, command modifiers and the arguments. */\n" - + " if(! preg_match(\'/^(?:(\' . $this->_obj_call_regexp . \'|\' . $this->_var_regexp\n" - + " . \'|\' . $this->_reg_obj_regexp . \'|\\/?\' . $this->_func_regexp . \')(\' . $this->_mod_regexp . \'*))\n" - + " (?:\\s+(.*))?$\n" - + " /xs\', $template_tag, $match)) {\n" - + " $this->_syntax_error(\"unrecognized tag: $template_tag\", E_USER_ERROR, __FILE__, __LINE__);\n" - + " }\n" - + "\n" - + " $tag_command = $match[1];\n" - + " $tag_modifier = isset($match[2]) ? $match[2] : null;\n" - + " $tag_args = isset($match[3]) ? $match[3] : null;\n" - + " \n" - + " \n" - + " /* If the tag name is a variable or object, we process it. */\n" - + " if (preg_match(\'!^\' . $this->_obj_call_regexp . \'|\' . $this->_var_regexp . \'$!\', $tag_command)) {\n" - + " $return = $this->_parse_var_props($tag_command . $tag_modifier, $this->_parse_attrs($tag_args));\n" - + " if(isset($_tag_attrs[\'assign\'])) {\n" - + " return \"assign(\'\" . $this->_dequote($_tag_attrs[\'assign\']) . \"\', $return ); ?>\\n\"; \n" - + " } else {\n" - + " return \"\\n\";\n" - + " }\n" - + " }\n" - + " \n" - + " /* If the tag name is a registered object, we process it. */\n" - + " if (preg_match(\'!^\' . $this->_reg_obj_regexp . \'$!\', $tag_command)) {\n" - + " return $this->_compile_registered_object_tag($tag_command, $this->_parse_attrs($tag_args), $tag_modifier);\n" - + " }\n" - + "\n" - + " switch ($tag_command) {\n" - + " case \'include\':\n" - + " return $this->_compile_include_tag($tag_args);\n" - + "\n" - + " case \'include_php\':\n" - + " return $this->_compile_include_php_tag($tag_args);\n" - + "\n" - + " case \'if\':\n" - + " return $this->_compile_if_tag($tag_args);\n" - + "\n" - + " case \'else\':\n" - + " return \'\';\n" - + "\n" - + " case \'elseif\':\n" - + " return $this->_compile_if_tag($tag_args, true);\n" - + "\n" - + " case \'/if\':\n" - + " return \'\';\n" - + "\n" - + " case \'capture\':\n" - + " return $this->_compile_capture_tag(true, $tag_args);\n" - + "\n" - + " case \'/capture\':\n" - + " return $this->_compile_capture_tag(false);\n" - + "\n" - + " case \'ldelim\':\n" - + " return $this->left_delimiter;\n" - + "\n" - + " case \'rdelim\':\n" - + " return $this->right_delimiter;\n" - + "\n" - + " case \'section\':\n" - + " array_push($this->_sectionelse_stack, false);\n" - + " return $this->_compile_section_start($tag_args);\n" - + "\n" - + " case \'sectionelse\':\n" - + " $this->_sectionelse_stack[count($this->_sectionelse_stack)-1] = true;\n" - + " return \"\";\n" - + "\n" - + " case \'/section\':\n" - + " if (array_pop($this->_sectionelse_stack))\n" - + " return \"\";\n" - + " else\n" - + " return \"\";\n" - + "\n" - + " case \'foreach\':\n" - + " array_push($this->_foreachelse_stack, false);\n" - + " return $this->_compile_foreach_start($tag_args);\n" - + " break;\n" - + "\n" - + " case \'foreachelse\':\n" - + " $this->_foreachelse_stack[count($this->_foreachelse_stack)-1] = true;\n" - + " return \"\";\n" - + "\n" - + " case \'/foreach\':\n" - + " if (array_pop($this->_foreachelse_stack))\n" - + " return \"\";\n" - + " else\n" - + " return \"\";\n" - + "\n" - + " case \'config_load\':\n" - + " return $this->_compile_config_load_tag($tag_args);\n" - + "\n" - + " case \'strip\':\n" - + " case \'/strip\':\n" - + " return $this->left_delimiter.$tag_command.$this->right_delimiter;\n" - + "\n" - + " case \'literal\':\n" - + " list (,$literal_block) = each($this->_literal_blocks);\n" - + " $this->_current_line_no += substr_count($literal_block, \"\\n\");\n" - + " return \"\\n\";\n" - + "\n" - + " case \'php\':\n" - + " if ($this->security && !$this->security_settings[\'PHP_TAGS\']) {\n" - + " $this->_syntax_error(\"(secure mode) php tags not permitted\", E_USER_WARNING, __FILE__, __LINE__);\n" - + " return;\n" - + " }\n" - + " list (,$php_block) = each($this->_php_blocks);\n" - + " $this->_current_line_no += substr_count($php_block, \"\\n\");\n" - + " return \'\';\n" - + "\n" - + " case \'insert\':\n" - + " return $this->_compile_insert_tag($tag_args);\n" - + "\n" - + " default:\n" - + " if ($this->_compile_compiler_tag($tag_command, $tag_args, $output)) {\n" - + " return $output;\n" - + " } else if ($this->_compile_block_tag($tag_command, $tag_args, $tag_modifier, $output)) {\n" - + " return $output;\n" - + " } else {\n" - + " return $this->_compile_custom_tag($tag_command, $tag_args, $tag_modifier);\n" - + " }\n" - + " }\n" - + " }\n" - + "\n" - + "\n" - + " /**\n" - + " * compile the custom compiler tag\n" - + " *\n" - + " * @access public\n" - + " * @param $tag_command\n" - + " * @param $tag_args\n" - + " * @param $output\n" - + " */\n" - + " function _compile_compiler_tag($tag_command, $tag_args, &$output)\n" - + " {\n" - + " $found = false;\n" - + " $have_function = true;\n" - + "\n" - + " /*\n" - + " * First we check if the compiler function has already been registered\n" - + " * or loaded from a plugin file.\n" - + " */\n" - + " if (isset($this->_plugins[\'compiler\'][$tag_command])) {\n" - + " $found = true;\n" - + " $plugin_func = $this->_plugins[\'compiler\'][$tag_command][0];\n" - + " if (!function_exists($plugin_func)) {\n" - + " $message = \"compiler function \'$tag_command\' is not implemented\";\n" - + " $have_function = false;\n" - + " }\n" - + " }\n" - + " /*\n" - + " * Otherwise we need to load plugin file and look for the function\n" - + " * inside it.\n" - + " */\n" - + " else if ($plugin_file = $this->_get_plugin_filepath(\'compiler\', $tag_command)) {\n" - + " $found = true;\n" - + "\n" - + " include_once $plugin_file;\n" - + "\n" - + " $plugin_func = \'smarty_compiler_\' . $tag_command;\n" - + " if (!function_exists($plugin_func)) {\n" - + " $message = \"plugin function $plugin_func() not found in $plugin_file\\n\";\n" - + " $have_function = false;\n" - + " } else {\n" - + " $this->_plugins[\'compiler\'][$tag_command] = array($plugin_func, null, null);\n" - + " }\n" - + " }\n" - + "\n" - + " /*\n" - + " * True return value means that we either found a plugin or a\n" - + " * dynamically registered function. False means that we didn\'t and the\n" - + " * compiler should now emit code to load custom function plugin for this\n" - + " * tag.\n" - + " */\n" - + " if ($found) {\n" - + " if ($have_function) {\n" - + " $output = \'\';\n" - + " } else {\n" - + " $this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__);\n" - + " }\n" - + " return true;\n" - + " } else {\n" - + " return false;\n" - + " }\n" - + " }\n" - + "\n" - + "\n" - + " /**\n" - + " * compile block function tag\n" - + " *\n" - + " * @access public\n" - + " * @param $tag_command\n" - + " * @param $tag_args\n" - + " * @param $tag_modifier\n" - + " * @param $output\n" - + " */\n" - + " function _compile_block_tag($tag_command, $tag_args, $tag_modifier, &$output)\n" - + " {\n" - + " if ($tag_command{0} == \'/\') {\n" - + " $start_tag = false;\n" - + " $tag_command = substr($tag_command, 1);\n" - + " } else\n" - + " $start_tag = true;\n" - + "\n" - + " $found = false;\n" - + " $have_function = true;\n" - + "\n" - + " /*\n" - + " * First we check if the block function has already been registered\n" - + " * or loaded from a plugin file.\n" - + " */\n" - + " if (isset($this->_plugins[\'block\'][$tag_command])) {\n" - + " $found = true;\n" - + " $plugin_func = $this->_plugins[\'block\'][$tag_command][0];\n" - + " if (!function_exists($plugin_func)) {\n" - + " $message = \"block function \'$tag_command\' is not implemented\";\n" - + " $have_function = false;\n" - + " }\n" - + " }\n" - + " /*\n" - + " * Otherwise we need to load plugin file and look for the function\n" - + " * inside it.\n" - + " */\n" - + " else if ($plugin_file = $this->_get_plugin_filepath(\'block\', $tag_command)) {\n" - + " $found = true;\n" - + "\n" - + " include_once $plugin_file;\n" - + "\n" - + " $plugin_func = \'smarty_block_\' . $tag_command;\n" - + " if (!function_exists($plugin_func)) {\n" - + " $message = \"plugin function $plugin_func() not found in $plugin_file\\n\";\n" - + " $have_function = false;\n" - + " } else {\n" - + " $this->_plugins[\'block\'][$tag_command] = array($plugin_func, null, null);\n" - + " }\n" - + " }\n" - + "\n" - + " if (!$found) {\n" - + " return false;\n" - + " } else if (!$have_function) {\n" - + " $this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__);\n" - + " return true;\n" - + " }\n" - + "\n" - + " /*\n" - + " * Even though we\'ve located the plugin function, compilation\n" - + " * happens only once, so the plugin will still need to be loaded\n" - + " * at runtime for future requests.\n" - + " */\n" - + " $this->_add_plugin(\'block\', $tag_command);\n" - + "\n" - + " if ($start_tag) {\n" - + " $arg_list = array();\n" - + " $attrs = $this->_parse_attrs($tag_args);\n" - + " foreach ($attrs as $arg_name => $arg_value) {\n" - + " if (is_bool($arg_value))\n" - + " $arg_value = $arg_value ? \'true\' : \'false\';\n" - + " $arg_list[] = \"\'$arg_name\' => $arg_value\";\n" - + " }\n" - + "\n" - + " $output = \"_tag_stack[] = array(\'$tag_command\', array(\".implode(\',\', (array)$arg_list).\")); \\$this->_plugins[\'block\'][\'$tag_command\'][0](array(\".implode(\',\', (array)$arg_list).\"), null, \\$this); ob_start(); ?>\";\n" - + " } else {\n" - + " $output = \"_block_content = ob_get_contents(); ob_end_clean(); \";\n" - + " $out_tag_text = \"\\$this->_plugins[\'block\'][\'$tag_command\'][0](\\$this->_tag_stack[count(\\$this->_tag_stack)-1][1], \\$this->_block_content, \\$this)\";\n" - + " if($tag_modifier != \'\') {\n" - + " $this->_parse_modifiers($out_tag_text, $tag_modifier);\n" - + " }\n" - + " $output .= \'echo \' . $out_tag_text . \';\';\n" - + " $output .= \" array_pop(\\$this->_tag_stack); ?>\";\n" - + " }\n" - + "\n" - + " return true;\n" - + " }\n" - + "\n" - + "\n" - + " /**\n" - + " * compile custom function tag\n" - + " *\n" - + " * @access public\n" - + " * @param $tag_command\n" - + " * @param $tag_args\n" - + " * @param $tag_modifier\n" - + " */\n" - + " function _compile_custom_tag($tag_command, $tag_args, $tag_modifier)\n" - + " {\n" - + " $this->_add_plugin(\'function\', $tag_command);\n" - + "\n" - + " $arg_list = array();\n" - + " $attrs = $this->_parse_attrs($tag_args);\n" - + " foreach ($attrs as $arg_name => $arg_value) {\n" - + " if (is_bool($arg_value))\n" - + " $arg_value = $arg_value ? \'true\' : \'false\';\n" - + " $arg_list[] = \"\'$arg_name\' => $arg_value\";\n" - + " }\n" - + " \n" - + " $return = \"\\$this->_plugins[\'function\'][\'$tag_command\'][0](array(\".implode(\',\', (array)$arg_list).\"), \\$this)\";\n" - + " \n" - + " if($tag_modifier != \'\') {\n" - + " $this->_parse_modifiers($return, $tag_modifier);\n" - + " }\n" - + " \n" - + " return \'\\n\";\n" - + " }\n" - + "\n" - + " /**\n" - + " * compile a registered object tag\n" - + " *\n" - + " * @access public\n" - + " * @param $tag_command\n" - + " * @param $attrs\n" - + " * @param $tag_modifier\n" - + " */\n" - + " function _compile_registered_object_tag($tag_command, $attrs, $tag_modifier)\n" - + " {\n" - + " list($object, $obj_comp) = explode(\'->\', $tag_command);\n" - + "\n" - + " $arg_list = array();\n" - + " if(count($attrs)) {\n" - + " $_assign_var = false;\n" - + " foreach ($attrs as $arg_name => $arg_value) {\n" - + " if($arg_name == \'assign\') {\n" - + " $_assign_var = $arg_value;\n" - + " unset($attrs[\'assign\']);\n" - + " continue;\n" - + " }\n" - + " if (is_bool($arg_value))\n" - + " $arg_value = $arg_value ? \'true\' : \'false\';\n" - + " $arg_list[] = \"\'$arg_name\' => $arg_value\";\n" - + " }\n" - + " }\n" - + " \n" - + " if(!is_object($this->_reg_objects[$object][0])) {\n" - + " $this->_trigger_fatal_error(\"registered \'$object\' is not an object\");\n" - + " } elseif(!empty($this->_reg_objects[$object][1]) && !in_array($obj_comp, $this->_reg_objects[$object][1])) {\n" - + " $this->_trigger_fatal_error(\"\'$obj_comp\' is not a registered component of object \'$object\'\");\n" - + " } elseif(method_exists($this->_reg_objects[$object][0], $obj_comp)) {\n" - + " // method\n" - + " if($this->_reg_objects[$object][2]) {\n" - + " // smarty object argument format\n" - + " $return = \"\\$this->_reg_objects[\'$object\'][0]->$obj_comp(array(\".implode(\',\', (array)$arg_list).\"), \\$this)\";\n" - + " } else {\n" - + " // traditional argument format\n" - + " $return = \"\\$this->_reg_objects[\'$object\'][0]->$obj_comp(\".implode(\',\', array_values($attrs)).\")\";\n" - + " }\n" - + " } else {\n" - + " // property\n" - + " $return = \"\\$this->_reg_objects[\'$object\'][0]->$obj_comp\";\n" - + " }\n" - + " \n" - + " if($tag_modifier != \'\') {\n" - + " $this->_parse_modifiers($return, $tag_modifier);\n" - + " }\n" - + " \n" - + " if($_assign_var) {\n" - + " return \"assign(\'\" . $this->_dequote($_assign_var) .\"\', $return); ?>\\n\";\n" - + " } else {\n" - + " return \'\\n\";\n" - + " }\n" - + " }\n" - + " \n" - + " \n" - + "\n" - + " /**\n" - + " * Compile {insert ...} tag\n" - + " *\n" - + " * @access public\n" - + " * @param $tag_args\n" - + " */\n" - + " function _compile_insert_tag($tag_args)\n" - + " {\n" - + " $attrs = $this->_parse_attrs($tag_args);\n" - + " $name = $this->_dequote($attrs[\'name\']);\n" - + "\n" - + " if (empty($name)) {\n" - + " $this->_syntax_error(\"missing insert name\", E_USER_ERROR, __FILE__, __LINE__);\n" - + " }\n" - + "\n" - + " if (!empty($attrs[\'script\'])) {\n" - + " $delayed_loading = true;\n" - + " } else {\n" - + " $delayed_loading = false; \n" - + " }\n" - + "\n" - + " foreach ($attrs as $arg_name => $arg_value) {\n" - + " if (is_bool($arg_value))\n" - + " $arg_value = $arg_value ? \'true\' : \'false\';\n" - + " $arg_list[] = \"\'$arg_name\' => $arg_value\";\n" - + " }\n" - + "\n" - + " $this->_add_plugin(\'insert\', $name, $delayed_loading);\n" - + "\n" - + " return \"_run_insert_handler(array(\".implode(\', \', (array)$arg_list).\")); ?>\\n\";\n" - + " }\n" - + "\n" - + "\n" - + " /**\n" - + " * Compile {config_load ...} tag\n" - + " *\n" - + " * @access public\n" - + " * @param $tag_args\n" - + " */\n" - + " function _compile_config_load_tag($tag_args)\n" - + " {\n" - + " $attrs = $this->_parse_attrs($tag_args);\n" - + "\n" - + " if (empty($attrs[\'file\'])) {\n" - + " $this->_syntax_error(\"missing \'file\' attribute in config_load tag\", E_USER_ERROR, __FILE__, __LINE__);\n" - + " }\n" - + "\n" - + " if (empty($attrs[\'section\'])) {\n" - + " $attrs[\'section\'] = \'null\';\n" - + " }\n" - + "\n" - + " if (isset($attrs[\'scope\'])) {\n" - + " $scope = @$this->_dequote($attrs[\'scope\']);\r\n" - + " if ($scope != \'local\' &&\r\n" - + " $scope != \'parent\' &&\r\n" - + " $scope != \'global\') {\r\n" - + " $this->_syntax_error(\"invalid \'scope\' attribute value\", E_USER_ERROR, __FILE__, __LINE__);\r\n" - + " }\r\n" - + " } else {\r\n" - + " if (isset($attrs[\'global\']) && $attrs[\'global\'])\r\n" - + " $scope = \'parent\';\r\n" - + " else\r\n" - + " $scope = \'local\';\r\n" - + " }\r\n" - + "\r\n" - + " return \'config_load(\' . $attrs[\'file\'] . \', \' . $attrs[\'section\'] . \", \'$scope\'); ?>\";\r\n" - + " }\r\n" - + "\r\n" - + "\r\n" - + " /**\r\n" - + " * Compile {include ...} tag\r\n" - + " *\r\n" - + " * @access public\r\n" - + " * $param $tag_args\r\n" - + " */\r\n" - + " function _compile_include_tag($tag_args)\r\n" - + " {\r\n" - + " $attrs = $this->_parse_attrs($tag_args);\r\n" - + " $arg_list = array();\r\n" - + "\r\n" - + " if (empty($attrs[\'file\'])) {\r\n" - + " $this->_syntax_error(\"missing \'file\' attribute in include tag\", E_USER_ERROR, __FILE__, __LINE__);\r\n" - + " }\r\n" - + "\r\n" - + " foreach ($attrs as $arg_name => $arg_value) {\r\n" - + " if ($arg_name == \'file\') {\r\n" - + " $include_file = $arg_value;\r\n" - + " continue;\r\n" - + " } else if ($arg_name == \'assign\') {\r\n" - + " $assign_var = $arg_value;\r\n" - + " continue;\r\n" - + " }\r\n" - + " if (is_bool($arg_value))\r\n" - + " $arg_value = $arg_value ? \'true\' : \'false\';\r\n" - + " $arg_list[] = \"\'$arg_name\' => $arg_value\";\r\n" - + " }\r\n" - + "\r\n" - + " $output = \'_tpl_vars;\\n\" .\r\n" - + " \"\\$this->_smarty_include(\".$include_file.\", array(\".implode(\',\', (array)$arg_list).\"));\\n\" .\r\n" - + " \"\\$this->_tpl_vars = \\$_smarty_tpl_vars;\\n\" .\r\n" - + " \"unset(\\$_smarty_tpl_vars);\\n\";\r\n" - + "\r\n" - + " if (isset($assign_var)) {\r\n" - + " $output .= \"\\$this->assign(\" . $assign_var . \", ob_get_contents()); ob_end_clean();\\n\";\r\n" - + " }\r\n" - + "\r\n" - + " $output .= \' ?>\';\r\n" - + "\r\n" - + " return $output;\r\n" - + "\r\n" - + " }\r\n" - + "\r\n" - + " /**\r\n" - + " * Compile {include ...} tag\r\n" - + " *\r\n" - + " * @access public\r\n" - + " * @param $tag_args\r\n" - + " */\r\n" - + " function _compile_include_php_tag($tag_args)\r\n" - + " {\r\n" - + " $attrs = $this->_parse_attrs($tag_args);\r\n" - + "\r\n" - + " if (empty($attrs[\'file\'])) {\r\n" - + " $this->_syntax_error(\"missing \'file\' attribute in include_php tag\", E_USER_ERROR, __FILE__, __LINE__);\r\n" - + " }\r\n" - + "\r\n" - + " $assign_var = $this->_dequote($attrs[\'assign\']);\r\n" - + "\r\n" - + " $once_var = ( $attrs[\'once\'] === false ) ? \'false\' : \'true\';\r\n" - + "\r\n" - + " foreach($attrs as $arg_name => $arg_value) {\r\n" - + " if($arg_name != \'file\' AND $arg_name != \'once\' AND $arg_name != \'assign\') {\r\n" - + " if(is_bool($arg_value))\r\n" - + " $arg_value = $arg_value ? \'true\' : \'false\';\r\n" - + " $arg_list[] = \"\'$arg_name\' => $arg_value\";\r\n" - + " }\r\n" - + " }\r\n" - + "\r\n" - + " $output =\r\n" - + " \"_smarty_include_php($attrs[file], \'$assign_var\', $once_var, \" .\r\n" - + " \"array(\".implode(\',\', (array)$arg_list).\")); ?>\";\r\n" - + " \r\n" - + " return $output;\r\n" - + " }\r\n" - + " \r\n" - + "\r\n" - + " /**\r\n" - + " * Compile {section ...} tag\r\n" - + " *\r\n" - + " * @access public\r\n" - + " * @param $tag_args\r\n" - + " */\r\n" - + " function _compile_section_start($tag_args)\r\n" - + " {\r\n" - + " $attrs = $this->_parse_attrs($tag_args);\r\n" - + " $arg_list = array();\r\n" - + "\r\n" - + " $output = \'_syntax_error(\"missing section name\", E_USER_ERROR, __FILE__, __LINE__);\r\n" - + " }\r\n" - + "\r\n" - + " $output .= \"if (isset(\\$this->_sections[$section_name])) unset(\\$this->_sections[$section_name]);\\n\";\r\n" - + " $section_props = \"\\$this->_sections[$section_name]\";\r\n" - + "\r\n" - + " foreach ($attrs as $attr_name => $attr_value) {\r\n" - + " switch ($attr_name) {\r\n" - + " case \'loop\':\r\n" - + " $output .= \"{$section_props}[\'loop\'] = is_array($attr_value) ? count($attr_value) : max(0, (int)$attr_value);\\n\";\r\n" - + " break;\r\n" - + "\r\n" - + " case \'show\':\r\n" - + " if (is_bool($attr_value))\r\n" - + " $show_attr_value = $attr_value ? \'true\' : \'false\';\r\n" - + " else\r\n" - + " $show_attr_value = \"(bool)$attr_value\";\r\n" - + " $output .= \"{$section_props}[\'show\'] = $show_attr_value;\\n\";\r\n" - + " break;\r\n" - + "\r\n" - + " case \'name\':\r\n" - + " $output .= \"{$section_props}[\'$attr_name\'] = $attr_value;\\n\";\r\n" - + " break;\r\n" - + "\r\n" - + " case \'max\':\r\n" - + " case \'start\':\r\n" - + " $output .= \"{$section_props}[\'$attr_name\'] = (int)$attr_value;\\n\";\r\n" - + " break;\r\n" - + "\r\n" - + " case \'step\':\r\n" - + " $output .= \"{$section_props}[\'$attr_name\'] = ((int)$attr_value) == 0 ? 1 : (int)$attr_value;\\n\";\r\n" - + " break;\r\n" - + "\r\n" - + " default:\r\n" - + " $this->_syntax_error(\"unknown section attribute - \'$attr_name\'\", E_USER_ERROR, __FILE__, __LINE__);\r\n" - + " break;\r\n" - + " }\r\n" - + " }\r\n" - + "\r\n" - + " if (!isset($attrs[\'show\']))\r\n" - + " $output .= \"{$section_props}[\'show\'] = true;\\n\";\r\n" - + "\r\n" - + " if (!isset($attrs[\'loop\']))\r\n" - + " $output .= \"{$section_props}[\'loop\'] = 1;\\n\";\r\n" - + "\r\n" - + " if (!isset($attrs[\'max\']))\r\n" - + " $output .= \"{$section_props}[\'max\'] = {$section_props}[\'loop\'];\\n\";\r\n" - + " else\r\n" - + " $output .= \"if ({$section_props}[\'max\'] < 0)\\n\" .\r\n" - + " \" {$section_props}[\'max\'] = {$section_props}[\'loop\'];\\n\";\r\n" - + "\r\n" - + " if (!isset($attrs[\'step\']))\r\n" - + " $output .= \"{$section_props}[\'step\'] = 1;\\n\";\r\n" - + "\r\n" - + " if (!isset($attrs[\'start\']))\r\n" - + " $output .= \"{$section_props}[\'start\'] = {$section_props}[\'step\'] > 0 ? 0 : {$section_props}[\'loop\']-1;\\n\";\r\n" - + " else {\r\n" - + " $output .= \"if ({$section_props}[\'start\'] < 0)\\n\" .\r\n" - + " \" {$section_props}[\'start\'] = max({$section_props}[\'step\'] > 0 ? 0 : -1, {$section_props}[\'loop\'] + {$section_props}[\'start\']);\\n\" .\r\n" - + " \"else\\n\" .\r\n" - + " \" {$section_props}[\'start\'] = min({$section_props}[\'start\'], {$section_props}[\'step\'] > 0 ? {$section_props}[\'loop\'] : {$section_props}[\'loop\']-1);\\n\";\r\n" - + " }\r\n" - + "\r\n" - + " $output .= \"if ({$section_props}[\'show\']) {\\n\";\r\n" - + " if (!isset($attrs[\'start\']) && !isset($attrs[\'step\']) && !isset($attrs[\'max\'])) {\r\n" - + " $output .= \" {$section_props}[\'total\'] = {$section_props}[\'loop\'];\\n\";\r\n" - + " } else {\r\n" - + " $output .= \" {$section_props}[\'total\'] = min(ceil(({$section_props}[\'step\'] > 0 ? {$section_props}[\'loop\'] - {$section_props}[\'start\'] : {$section_props}[\'start\']+1)/abs({$section_props}[\'step\'])), {$section_props}[\'max\']);\\n\";\r\n" - + " }\r\n" - + " $output .= \" if ({$section_props}[\'total\'] == 0)\\n\" .\r\n" - + " \" {$section_props}[\'show\'] = false;\\n\" .\r\n" - + " \"} else\\n\" .\r\n" - + " \" {$section_props}[\'total\'] = 0;\\n\";\r\n" - + "\r\n" - + " $output .= \"if ({$section_props}[\'show\']):\\n\";\r\n" - + " $output .= \"\r\n" - + " for ({$section_props}[\'index\'] = {$section_props}[\'start\'], {$section_props}[\'iteration\'] = 1;\r\n" - + " {$section_props}[\'iteration\'] <= {$section_props}[\'total\'];\r\n" - + " {$section_props}[\'index\'] += {$section_props}[\'step\'], {$section_props}[\'iteration\']++):\\n\";\r\n" - + " $output .= \"{$section_props}[\'rownum\'] = {$section_props}[\'iteration\'];\\n\";\r\n" - + " $output .= \"{$section_props}[\'index_prev\'] = {$section_props}[\'index\'] - {$section_props}[\'step\'];\\n\";\r\n" - + " $output .= \"{$section_props}[\'index_next\'] = {$section_props}[\'index\'] + {$section_props}[\'step\'];\\n\";\r\n" - + " $output .= \"{$section_props}[\'first\'] = ({$section_props}[\'iteration\'] == 1);\\n\";\r\n" - + " $output .= \"{$section_props}[\'last\'] = ({$section_props}[\'iteration\'] == {$section_props}[\'total\']);\\n\";\r\n" - + "\r\n" - + " $output .= \"?>\";\r\n" - + "\r\n" - + " return $output;\r\n" - + " }\r\n" - + "\r\n" - + " \r\n" - + " /**\r\n" - + " * Compile {foreach ...} tag.\r\n" - + " *\r\n" - + " * @access public\r\n" - + " * @param $tag_args\r\n" - + " */\r\n" - + " function _compile_foreach_start($tag_args)\r\n" - + " {\r\n" - + " $attrs = $this->_parse_attrs($tag_args);\r\n" - + " $arg_list = array();\r\n" - + "\r\n" - + " if (empty($attrs[\'from\'])) {\r\n" - + " $this->_syntax_error(\"missing \'from\' attribute\", E_USER_ERROR, __FILE__, __LINE__);\r\n" - + " }\r\n" - + "\r\n" - + " if (empty($attrs[\'item\'])) {\r\n" - + " $this->_syntax_error(\"missing \'item\' attribute\", E_USER_ERROR, __FILE__, __LINE__);\r\n" - + " }\r\n" - + "\r\n" - + " $from = $attrs[\'from\'];\r\n" - + " $item = $this->_dequote($attrs[\'item\']);\r\n" - + " if (isset($attrs[\'name\']))\r\n" - + " $name = $attrs[\'name\'];\r\n" - + "\r\n" - + " $output = \'_foreach[$name])) unset(\\$this->_foreach[$name]);\\n\";\r\n" - + " $foreach_props = \"\\$this->_foreach[$name]\";\r\n" - + " }\r\n" - + "\r\n" - + " $key_part = \'\';\r\n" - + "\r\n" - + " foreach ($attrs as $attr_name => $attr_value) {\r\n" - + " switch ($attr_name) {\r\n" - + " case \'key\':\r\n" - + " $key = $this->_dequote($attrs[\'key\']);\r\n" - + " $key_part = \"\\$this->_tpl_vars[\'$key\'] => \";\r\n" - + " break;\r\n" - + "\r\n" - + " case \'name\':\r\n" - + " $output .= \"{$foreach_props}[\'$attr_name\'] = $attr_value;\\n\";\r\n" - + " break;\r\n" - + " }\r\n" - + " }\r\n" - + "\r\n" - + " if (isset($name)) {\r\n" - + " $output .= \"{$foreach_props}[\'total\'] = count((array)$from);\\n\";\r\n" - + " $output .= \"{$foreach_props}[\'show\'] = {$foreach_props}[\'total\'] > 0;\\n\";\r\n" - + " $output .= \"if ({$foreach_props}[\'show\']):\\n\";\r\n" - + " $output .= \"{$foreach_props}[\'iteration\'] = 0;\\n\";\r\n" - + " $output .= \" foreach ((array)$from as $key_part\\$this->_tpl_vars[\'$item\']):\\n\";\r\n" - + " $output .= \" {$foreach_props}[\'iteration\']++;\\n\";\r\n" - + " $output .= \" {$foreach_props}[\'first\'] = ({$foreach_props}[\'iteration\'] == 1);\\n\";\r\n" - + " $output .= \" {$foreach_props}[\'last\'] = ({$foreach_props}[\'iteration\'] == {$foreach_props}[\'total\']);\\n\";\r\n" - + " } else {\r\n" - + " $output .= \"if (count((array)$from)):\\n\";\r\n" - + " $output .= \" foreach ((array)$from as $key_part\\$this->_tpl_vars[\'$item\']):\\n\";\r\n" - + " }\r\n" - + " $output .= \'?>\';\r\n" - + "\r\n" - + " return $output;\r\n" - + " }\r\n" - + "\r\n" - + "\r\n" - + " /**\r\n" - + " * Compile {capture} .. {/capture} tags\r\n" - + " *\r\n" - + " * @access public\r\n" - + " * @param $start\r\n" - + " * @param $tag_args\r\n" - + " */\r\n" - + " function _compile_capture_tag($start, $tag_args = \'\')\r\n" - + " {\r\n" - + " $attrs = $this->_parse_attrs($tag_args);\r\n" - + "\r\n" - + " if ($start) {\r\n" - + " if (isset($attrs[\'name\']))\r\n" - + " $buffer = $attrs[\'name\'];\r\n" - + " else\r\n" - + " $buffer = \"\'default\'\";\r\n" - + "\r\n" - + " $output = \"\";\r\n" - + " $this->_capture_stack[] = $buffer;\r\n" - + " } else {\r\n" - + " $buffer = array_pop($this->_capture_stack);\r\n" - + " $output = \"_smarty_vars[\'capture\'][$buffer] = ob_get_contents(); ob_end_clean(); ?>\";\r\n" - + " }\r\n" - + "\r\n" - + " return $output;\r\n" - + " }\r\n" - + "\r\n" - + " /**\r\n" - + " * Compile {if ...} tag\r\n" - + " *\r\n" - + " * @access public\r\n" - + " * @param $tag_args\r\n" - + " * @param $elseif\r\n" - + " */\r\n" - + " function _compile_if_tag($tag_args, $elseif = false)\r\n" - + " {\r\n" - + "\r\n" - + " /* Tokenize args for \'if\' tag. */\r\n" - + " preg_match_all(\'/(?>\r\n" - + " \' . $this->_obj_call_regexp . \'(?:\' . $this->_mod_regexp . \'*) | # valid object call\r\n" - + " \' . $this->_var_regexp . \'(?:\' . $this->_mod_regexp . \'*) | # public or quoted string\r\n" - + " \\-?\\d+|!==|<=>|==|!=|<=|>=|\\&\\&|\\|\\||\\(|\\)|,|\\!|\\^|=|<|>|\\||\\%|\\+|\\-|\\/|\\* | # valid non-word token\r\n" - + " \\b\\w+\\b | # valid word token\r\n" - + " \\S+ # anything else\r\n" - + " )/x\', $tag_args, $match);\r\n" - + " \r\n" - + " $tokens = $match[0];\r\n" - + " \r\n" - + " // make sure we have balanced parenthesis\r\n" - + " $token_count = array_count_values($tokens);\r\n" - + " if(isset($token_count[\'(\']) && $token_count[\'(\'] != $token_count[\')\']) {\r\n" - + " $this->_syntax_error(\"unbalanced parenthesis in if statement\", E_USER_ERROR, __FILE__, __LINE__);\r\n" - + " }\r\n" - + " \r\n" - + " $is_arg_stack = array();\r\n" - + "\r\n" - + " for ($i = 0; $i < count($tokens); $i++) {\r\n" - + "\r\n" - + " $token = &$tokens[$i];\r\n" - + " \r\n" - + " switch (strtolower($token)) {\r\n" - + " case \'!\':\r\n" - + " case \'%\':\r\n" - + " case \'!==\':\r\n" - + " case \'==\':\r\n" - + " case \'>\':\r\n" - + " case \'<\':\r\n" - + " case \'!=\':\r\n" - + " case \'<=\':\r\n" - + " case \'>=\':\r\n" - + " case \'&&\':\r\n" - + " case \'||\':\r\n" - + " case \'|\':\r\n" - + " case \'^\':\r\n" - + " case \'&\':\r\n" - + " case \'~\':\r\n" - + " case \')\':\r\n" - + " case \',\':\r\n" - + " case \'+\':\r\n" - + " case \'-\':\r\n" - + " case \'*\':\r\n" - + " case \'/\':\r\n" - + " break; \r\n" - + "\r\n" - + " case \'eq\':\r\n" - + " $token = \'==\';\r\n" - + " break;\r\n" - + "\r\n" - + " case \'ne\':\r\n" - + " case \'neq\':\r\n" - + " $token = \'!=\';\r\n" - + " break;\r\n" - + "\r\n" - + " case \'lt\':\r\n" - + " $token = \'<\';\r\n" - + " break;\r\n" - + "\r\n" - + " case \'le\':\r\n" - + " case \'lte\':\r\n" - + " $token = \'<=\';\r\n" - + " break;\r\n" - + "\r\n" - + " case \'gt\':\r\n" - + " $token = \'>\';\r\n" - + " break;\r\n" - + "\r\n" - + " case \'ge\':\r\n" - + " case \'gte\':\r\n" - + " $token = \'>=\';\r\n" - + " break;\r\n" - + "\r\n" - + " case \'and\':\r\n" - + " $token = \'&&\';\r\n" - + " break;\r\n" - + "\r\n" - + " case \'or\':\r\n" - + " $token = \'||\';\r\n" - + " break;\r\n" - + "\r\n" - + " case \'not\':\r\n" - + " $token = \'!\';\r\n" - + " break;\r\n" - + "\r\n" - + " case \'mod\':\r\n" - + " $token = \'%\';\r\n" - + " break;\r\n" - + "\r\n" - + " case \'(\':\r\n" - + " array_push($is_arg_stack, $i);\r\n" - + " break;\r\n" - + " \r\n" - + " case \'is\':\r\n" - + " /* If last token was a \')\', we operate on the parenthesized\r\n" - + " expression. The start of the expression is on the stack.\r\n" - + " Otherwise, we operate on the last encountered token. */\r\n" - + " if ($tokens[$i-1] == \')\')\r\n" - + " $is_arg_start = array_pop($is_arg_stack);\r\n" - + " else\r\n" - + " $is_arg_start = $i-1;\r\n" - + " /* Construct the argument for \'is\' expression, so it knows\r\n" - + " what to operate on. */\r\n" - + " $is_arg = implode(\' \', array_slice($tokens, $is_arg_start, $i - $is_arg_start));\r\n" - + " \r\n" - + " /* Pass all tokens from next one until the end to the\r\n" - + " \'is\' expression parsing function. The function will\r\n" - + " return modified tokens, where the first one is the result\r\n" - + " of the \'is\' expression and the rest are the tokens it\r\n" - + " didn\'t touch. */ \r\n" - + " $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1));\r\n" - + " \r\n" - + " /* Replace the old tokens with the new ones. */\r\n" - + " array_splice($tokens, $is_arg_start, count($tokens), $new_tokens);\r\n" - + "\r\n" - + " /* Adjust argument start so that it won\'t change from the\r\n" - + " current position for the next iteration. */\r\n" - + " $i = $is_arg_start;\r\n" - + " break;\r\n" - + " \r\n" - + " default:\r\n" - + " if(preg_match(\'!^\' . $this->_func_regexp . \'$!\', $token) ) {\r\n" - + " // function call \r\n" - + " if($this->security &&\r\n" - + " !in_array($token, $this->security_settings[\'IF_FUNCS\'])) {\r\n" - + " $this->_syntax_error(\"(secure mode) \'$token\' not allowed in if statement\", E_USER_ERROR, __FILE__, __LINE__);\r\n" - + " } \r\n" - + " } elseif(preg_match(\'!^\' . $this->_var_regexp . \'(?:\' . $this->_mod_regexp . \'*)$!\', $token)) {\r\n" - + " // variable\r\n" - + " $token = $this->_parse_var_props($token);\r\n" - + " } elseif(preg_match(\'!^\' . $this->_obj_call_regexp . \'(?:\' . $this->_mod_regexp . \'*)$!\', $token)) {\r\n" - + " // object\r\n" - + " $token = $this->_parse_var_props($token);\r\n" - + " } elseif(is_numeric($token)) {\r\n" - + " // number, skip it\r\n" - + " } else {\r\n" - + " $this->_syntax_error(\"unidentified token \'$token\'\", E_USER_ERROR, __FILE__, __LINE__);\r\n" - + " }\r\n" - + " break;\r\n" - + " }\r\n" - + " }\r\n" - + " \r\n" - + " if ($elseif)\r\n" - + " return \'\';\r\n" - + " else\r\n" - + " return \'\';\r\n" - + " }\r\n" - + "\r\n" - + "\r\n" - + " /**\r\n" - + " * Parse is expression\r\n" - + " *\r\n" - + " * @access public\r\n" - + " * @param $is_arg\r\n" - + " * @param $tokens\r\n" - + " */\r\n" - + " function _parse_is_expr($is_arg, $tokens)\r\n" - + " {\r\n" - + " $expr_end = 0;\r\n" - + " $negate_expr = false;\r\n" - + "\r\n" - + " if (($first_token = array_shift($tokens)) == \'not\') {\r\n" - + " $negate_expr = true;\r\n" - + " $expr_type = array_shift($tokens);\r\n" - + " } else\r\n" - + " $expr_type = $first_token;\r\n" - + "\r\n" - + " switch ($expr_type) {\r\n" - + " case \'even\':\r\n" - + " if (@$tokens[$expr_end] == \'by\') {\r\n" - + " $expr_end++;\r\n" - + " $expr_arg = $tokens[$expr_end++];\r\n" - + " $expr = \"!(($is_arg / $expr_arg) % \" . $this->_parse_var_props($expr_arg) . \")\";\r\n" - + " } else\r\n" - + " $expr = \"!($is_arg % 2)\";\r\n" - + " break;\r\n" - + "\r\n" - + " case \'odd\':\r\n" - + " if (@$tokens[$expr_end] == \'by\') {\r\n" - + " $expr_end++;\r\n" - + " $expr_arg = $tokens[$expr_end++];\r\n" - + " $expr = \"(($is_arg / $expr_arg) % \". $this->_parse_var_props($expr_arg) . \")\";\r\n" - + " } else\r\n" - + " $expr = \"($is_arg % 2)\";\r\n" - + " break;\r\n" - + "\r\n" - + " case \'div\':\r\n" - + " if (@$tokens[$expr_end] == \'by\') {\r\n" - + " $expr_end++;\r\n" - + " $expr_arg = $tokens[$expr_end++];\r\n" - + " $expr = \"!($is_arg % \" . $this->_parse_var_props($expr_arg) . \")\";\r\n" - + " } else {\r\n" - + " $this->_syntax_error(\"expecting \'by\' after \'div\'\", E_USER_ERROR, __FILE__, __LINE__);\r\n" - + " }\r\n" - + " break;\r\n" - + "\r\n" - + " default:\r\n" - + " $this->_syntax_error(\"unknown \'is\' expression - \'$expr_type\'\", E_USER_ERROR, __FILE__, __LINE__);\r\n" - + " break;\r\n" - + " }\r\n" - + "\r\n" - + " if ($negate_expr) {\r\n" - + " $expr = \"!($expr)\";\r\n" - + " }\r\n" - + " \r\n" - + " array_splice($tokens, 0, $expr_end, $expr); \r\n" - + " \r\n" - + " return $tokens;\r\n" - + " }\r\n" - + "\r\n" - + "\r\n" - + " /**\r\n" - + " * Parse attribute string\r\n" - + " *\r\n" - + " * @access public\r\n" - + " * @param $tag_args\r\n" - + " * @param $quote\r\n" - + " */\r\n" - + " function _parse_attrs($tag_args, $quote = true)\r\n" - + " {\r\n" - + " \r\n" - + " /* Tokenize tag attributes. */\r\n" - + " preg_match_all(\'/(?:\' . $this->_obj_call_regexp . \'|\' . $this->_qstr_regexp . \' | (?>[^\"\\\'=\\s]+)\r\n" - + " )+ |\r\n" - + " [=]\r\n" - + " /x\', $tag_args, $match);\r\n" - + " $tokens = $match[0]; \r\n" - + " \r\n" - + " $attrs = array();\r\n" - + " /* Parse state:\r\n" - + " 0 - expecting attribute name\r\n" - + " 1 - expecting \'=\'\r\n" - + " 2 - expecting attribute value (not \'=\') */\r\n" - + " $state = 0;\r\n" - + " \r\n" - + " foreach ($tokens as $token) {\r\n" - + " switch ($state) {\r\n" - + " case 0:\r\n" - + " /* If the token is a valid identifier, we set attribute name\r\n" - + " and go to state 1. */\r\n" - + " if (preg_match(\'!^\\w+$!\', $token)) {\r\n" - + " $attr_name = $token;\r\n" - + " $state = 1;\r\n" - + " } else\r\n" - + " $this->_syntax_error(\"invalid attribute name - \'$token\'\", E_USER_ERROR, __FILE__, __LINE__);\r\n" - + " break;\r\n" - + "\r\n" - + " case 1:\r\n" - + " /* If the token is \'=\', then we go to state 2. */\r\n" - + " if ($token == \'=\') {\r\n" - + " $state = 2;\r\n" - + " } else\r\n" - + " $this->_syntax_error(\"expecting \'=\' after attribute name \'$last_token\'\", E_USER_ERROR, __FILE__, __LINE__);\r\n" - + " break;\r\n" - + "\r\n" - + " case 2:\r\n" - + " /* If token is not \'=\', we set the attribute value and go to\r\n" - + " state 0. */\r\n" - + " if ($token != \'=\') {\r\n" - + " /* We booleanize the token if it\'s a non-quoted possible\r\n" - + " boolean value. */\r\n" - + " if (preg_match(\'!^(on|yes|true)$!\', $token))\r\n" - + " $token = true;\r\n" - + " else if (preg_match(\'!^(off|no|false)$!\', $token))\r\n" - + " $token = false;\r\n" - + " /* If the token is just a string,\r\n" - + " we double-quote it. */\r\n" - + " else if (preg_match(\'!^\\w+$!\', $token)) {\r\n" - + " $token = \'\"\'.$token.\'\"\';\r\n" - + " }\r\n" - + "\r\n" - + " $attrs[$attr_name] = $token;\r\n" - + " $state = 0;\r\n" - + " } else\r\n" - + " $this->_syntax_error(\"\'=\' cannot be an attribute value\", E_USER_ERROR, __FILE__, __LINE__);\r\n" - + " break;\r\n" - + " }\r\n" - + " $last_token = $token;\r\n" - + " }\r\n" - + "\r\n" - + " if($state != 0) {\r\n" - + " if($state == 1) {\r\n" - + " $this->_syntax_error(\"expecting \'=\' after attribute name \'$last_token\'\", E_USER_ERROR, __FILE__, __LINE__); \r\n" - + " } else {\r\n" - + " $this->_syntax_error(\"missing attribute value\", E_USER_ERROR, __FILE__, __LINE__); \r\n" - + " }\r\n" - + " }\r\n" - + " \r\n" - + " $this->_parse_vars_props($attrs);\r\n" - + "\r\n" - + " return $attrs;\r\n" - + " }\r\n" - + "\r\n" - + " /**\r\n" - + " * compile multiple variables and section properties tokens into\r\n" - + " * PHP code\r\n" - + " *\r\n" - + " * @access public\r\n" - + " * @param $tokens\r\n" - + " */\r\n" - + " function _parse_vars_props(&$tokens)\r\n" - + " {\r\n" - + " foreach($tokens as $key => $val) { \r\n" - + " $tokens[$key] = $this->_parse_var_props($val);\r\n" - + " }\r\n" - + " }\r\n" - + " \r\n" - + " /**\r\n" - + " * compile single variable and section properties token into\r\n" - + " * PHP code\r\n" - + " *\r\n" - + " * @access public\r\n" - + " * @param $val\r\n" - + " * @param $tag_attrs\r\n" - + " */\r\n" - + " function _parse_var_props($val, $tag_attrs = null)\r\n" - + " { \r\n" - + "\r\n" - + " $val = trim($val);\r\n" - + "\r\n" - + " if(preg_match(\'!^(\' . $this->_obj_call_regexp . \'|\' . $this->_dvar_regexp . \')(?:\' . $this->_mod_regexp . \'*)$!\', $val)) {\r\n" - + " // $ variable or object\r\n" - + " return $this->_parse_var($val, $tag_attrs);\r\n" - + " } \r\n" - + " elseif(preg_match(\'!^\' . $this->_db_qstr_regexp . \'(?:\' . $this->_mod_regexp . \'*)$!\', $val)) {\r\n" - + " // double quoted text\r\n" - + " preg_match(\'!^(\' . $this->_db_qstr_regexp . \')(\'. $this->_mod_regexp . \'*)$!\', $val, $match);\r\n" - + " $return = $this->_expand_quoted_text($match[1]);\r\n" - + " if($match[2] != \'\') {\r\n" - + " $this->_parse_modifiers($return, $match[2]);\r\n" - + " }\r\n" - + " return $return;\r\n" - + " } \r\n" - + " elseif(preg_match(\'!^\' . $this->_si_qstr_regexp . \'(?:\' . $this->_mod_regexp . \'*)$!\', $val)) {\r\n" - + " // single quoted text\r\n" - + " preg_match(\'!^(\' . $this->_si_qstr_regexp . \')(\'. $this->_mod_regexp . \'*)$!\', $val, $match);\r\n" - + " if($match[2] != \'\') {\r\n" - + " $this->_parse_modifiers($match[1], $match[2]);\r\n" - + " return $match[1];\r\n" - + " } \r\n" - + " } \r\n" - + " elseif(preg_match(\'!^\' . $this->_cvar_regexp . \'(?:\' . $this->_mod_regexp . \'*)$!\', $val)) {\r\n" - + " // config var\r\n" - + " return $this->_parse_conf_var($val);\r\n" - + " } \r\n" - + " elseif(preg_match(\'!^\' . $this->_svar_regexp . \'(?:\' . $this->_mod_regexp . \'*)$!\', $val)) {\r\n" - + " // section var\r\n" - + " return $this->_parse_section_prop($val);\r\n" - + " }\r\n" - + " elseif(!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) {\r\n" - + " // literal string\r\n" - + " return $this->_expand_quoted_text(\'\"\' . $val .\'\"\');\r\n" - + " }\r\n" - + " return $val;\r\n" - + " }\r\n" - + "\r\n" - + " /**\r\n" - + " * expand quoted text with embedded variables\r\n" - + " *\r\n" - + " * @access public\r\n" - + " * @param $var_expr\r\n" - + " */\r\n" - + " function _expand_quoted_text($var_expr)\r\n" - + " {\r\n" - + " // if contains unescaped $, expand it\r\n" - + " if(preg_match_all(\'|(?_dvar_guts_regexp . \'|\', $var_expr, $match)) {\r\n" - + " rsort($match[0]);\r\n" - + " reset($match[0]);\r\n" - + " foreach($match[0] as $var) {\r\n" - + " $var_expr = str_replace ($var, \'\".\' . $this->_parse_var($var) . \'.\"\', $var_expr);\r\n" - + " }\r\n" - + " return preg_replace(\'!\\.\"\"|\"\"\\.!\', \'\', $var_expr);\r\n" - + " } else {\r\n" - + " return $var_expr;\r\n" - + " }\r\n" - + " }\r\n" - + " \r\n" - + " /**\r\n" - + " * parse variable expression into PHP code\r\n" - + " *\r\n" - + " * @access public\r\n" - + " * @param $var_expr\r\n" - + " */\r\n" - + " function _parse_var($var_expr)\r\n" - + " {\r\n" - + " \r\n" - + " preg_match(\'!(\' . $this->_obj_call_regexp . \'|\' . $this->_var_regexp . \')(\' . $this->_mod_regexp . \'*)$!\', $var_expr, $match);\r\n" - + " \r\n" - + " $var_ref = substr($match[1],1);\r\n" - + " $modifiers = $match[2];\r\n" - + " \r\n" - + " if(!empty($this->default_modifiers) && !preg_match(\'!(^|\\|)smarty:nodefaults($|\\|)!\',$modifiers)) {\r\n" - + " $_default_mod_string = implode(\'|\',(array)$this->default_modifiers);\r\n" - + " $modifiers = empty($modifiers) ? $_default_mod_string : $_default_mod_string . \'|\' . $modifiers;\r\n" - + " }\r\n" - + "\r\n" - + " // get [foo] and .foo and ->foo() pieces \r\n" - + " preg_match_all(\'!(?:^\\w+)|(?:\' . $this->_obj_ext_regexp . \')+(?:\' . $this->_obj_params_regexp . \')?|(?:\' . $this->_var_bracket_regexp . \')|\\.\\$?\\w+!\', $var_ref, $match); \r\n" - + " \r\n" - + " $indexes = $match[0];\r\n" - + " $var_name = array_shift($indexes);\r\n" - + " \r\n" - + " /* Handle $smarty.* variable references as a special case. */\r\n" - + " if ($var_name == \'smarty\') {\r\n" - + " /*\r\n" - + " * If the reference could be compiled, use the compiled output;\r\n" - + " * otherwise, fall back on the $smarty variable generated at\r\n" - + " * run-time.\r\n" - + " */\r\n" - + " if (($smarty_ref = $this->_compile_smarty_ref($indexes)) !== null) {\r\n" - + " $output = $smarty_ref;\r\n" - + " } else {\r\n" - + " $var_name = substr(array_shift($indexes), 1);\r\n" - + " $output = \"\\$this->_smarty_vars[\'$var_name\']\";\r\n" - + " }\r\n" - + " } else {\r\n" - + " $output = \"\\$this->_tpl_vars[\'$var_name\']\";\r\n" - + " }\r\n" - + "\r\n" - + " foreach ($indexes as $index) { \r\n" - + " if ($index{0} == \'[\') {\r\n" - + " $index = substr($index, 1, -1);\r\n" - + " if (is_numeric($index)) {\r\n" - + " $output .= \"[$index]\";\r\n" - + " } elseif ($index{0} == \'$\') {\r\n" - + " $output .= \"[\\$this->_tpl_vars[\'\" . substr($index, 1) . \"\']]\";\r\n" - + " } else {\r\n" - + " $parts = explode(\'.\', $index);\r\n" - + " $section = $parts[0];\r\n" - + " $section_prop = isset($parts[1]) ? $parts[1] : \'index\';\r\n" - + " $output .= \"[\\$this->_sections[\'$section\'][\'$section_prop\']]\";\r\n" - + " }\r\n" - + " } else if ($index{0} == \'.\') {\r\n" - + " if ($index{1} == \'$\')\r\n" - + " $output .= \"[\\$this->_tpl_vars[\'\" . substr($index, 2) . \"\']]\";\r\n" - + " else\r\n" - + " $output .= \"[\'\" . substr($index, 1) . \"\']\";\r\n" - + " } else if (substr($index,0,2) == \'->\') {\r\n" - + " if(substr($index,2,2) == \'__\') {\r\n" - + " $this->_syntax_error(\'call to internal object members is not allowed\', E_USER_ERROR, __FILE__, __LINE__);\r\n" - + " } elseif($this->security && substr($index,2,1) == \'_\') {\r\n" - + " $this->_syntax_error(\'(secure) call to private object member is not allowed\', E_USER_ERROR, __FILE__, __LINE__);\r\n" - + " } else {\r\n" - + " if(preg_match(\'!((?:\' . $this->_obj_ext_regexp . \')+)(\' . $this->_obj_params_regexp . \')?!\', $index, $match)) {\r\n" - + " if(!empty($match[2])) {\r\n" - + " // parse object parameters\r\n" - + " $index = str_replace($match[2], $this->_parse_parenth_args($match[2]), $index);\r\n" - + " }\r\n" - + " if(preg_match_all(\'!\' . $this->_dvar_regexp . \'!\', $match[1], $_dvar_match)) {\r\n" - + " // parse embedded variables\r\n" - + " $_match_replace = $match[1];\r\n" - + " foreach($_dvar_match[0] as $_curr_var) {\r\n" - + " $_match_replace = str_replace($_curr_var, \'{\' . $this->_parse_var($_curr_var) . \'}\', $_match_replace);\r\n" - + " }\r\n" - + " $index = str_replace($match[1], $_match_replace, $index);\r\n" - + " }\r\n" - + " }\r\n" - + " $output .= $index;\r\n" - + " }\r\n" - + " } else {\r\n" - + " $output .= $index;\r\n" - + " }\r\n" - + " }\r\n" - + "\r\n" - + " // look for variables imbedded in quoted strings, replace them\r\n" - + " if(preg_match(\'!\' . $this->_qstr_regexp . \'!\', $output, $match)) {\r\n" - + " $output = str_replace($match[0], $this->_expand_quoted_text($match[0]), $output);\r\n" - + " }\r\n" - + " \r\n" - + " $this->_parse_modifiers($output, $modifiers);\r\n" - + "\r\n" - + " return $output;\r\n" - + " }\r\n" - + "\r\n" - + " /**\r\n" - + " * parse arguments in function call parenthesis\r\n" - + " *\r\n" - + " * @access public\r\n" - + " * @param $parenth_args\r\n" - + " */\r\n" - + " function _parse_parenth_args($parenth_args)\r\n" - + " {\r\n" - + " preg_match_all(\'!\' . $this->_param_regexp . \'!\',$parenth_args, $match);\r\n" - + " $match = $match[0];\r\n" - + " rsort($match);\r\n" - + " reset($match); \r\n" - + " $orig_vals = $match;\r\n" - + " $this->_parse_vars_props($match);\r\n" - + " return str_replace($orig_vals, $match, $parenth_args);\r\n" - + " } \r\n" - + " \r\n" - + " /**\r\n" - + " * parse configuration variable expression into PHP code\r\n" - + " *\r\n" - + " * @access public\r\n" - + " * @param $conf_var_expr\r\n" - + " */\r\n" - + " function _parse_conf_var($conf_var_expr)\r\n" - + " {\r\n" - + " $parts = explode(\'|\', $conf_var_expr, 2);\r\n" - + " $var_ref = $parts[0];\r\n" - + " $modifiers = isset($parts[1]) ? $parts[1] : \'\';\r\n" - + "\r\n" - + " $var_name = substr($var_ref, 1, -1);\r\n" - + "\r\n" - + " $output = \"\\$this->_config[0][\'vars\'][\'$var_name\']\";\r\n" - + "\r\n" - + " $this->_parse_modifiers($output, $modifiers);\r\n" - + "\r\n" - + " return $output;\r\n" - + " }\r\n" - + "\r\n" - + "\r\n" - + " /**\r\n" - + " * parse section property expression into PHP code\r\n" - + " *\r\n" - + " * @access public\r\n" - + " * @param $section_prop_expr\r\n" - + " */\r\n" - + " function _parse_section_prop($section_prop_expr)\r\n" - + " {\r\n" - + " $parts = explode(\'|\', $section_prop_expr, 2);\r\n" - + " $var_ref = $parts[0];\r\n" - + " $modifiers = isset($parts[1]) ? $parts[1] : \'\';\r\n" - + "\r\n" - + " preg_match(\'!%(\\w+)\\.(\\w+)%!\', $var_ref, $match);\r\n" - + " $section_name = $match[1];\r\n" - + " $prop_name = $match[2];\r\n" - + "\r\n" - + " $output = \"\\$this->_sections[\'$section_name\'][\'$prop_name\']\";\r\n" - + "\r\n" - + " $this->_parse_modifiers($output, $modifiers);\r\n" - + "\r\n" - + " return $output;\r\n" - + " }\r\n" - + "\r\n" - + "\r\n" - + " /**\r\n" - + " * parse modifier chain into PHP code\r\n" - + " *\r\n" - + " * @access public\r\n" - + " * @param $output\r\n" - + " * @param $modifier_string\r\n" - + " */\r\n" - + " function _parse_modifiers(&$output, $modifier_string)\r\n" - + " {\r\n" - + " preg_match_all(\'!\\|(@?\\w+)((?>:(?:\'. $this->_qstr_regexp . \'|[^|]+))*)!\', \'|\' . $modifier_string, $match);\r\n" - + " list(, $modifiers, $modifier_arg_strings) = $match;\r\n" - + "\r\n" - + " for ($i = 0, $for_max = count($modifiers); $i < $for_max; $i++) {\r\n" - + " $modifier_name = $modifiers[$i];\r\n" - + " \r\n" - + " if($modifier_name == \'smarty\') {\r\n" - + " // skip smarty modifier\r\n" - + " continue;\r\n" - + " }\r\n" - + " \r\n" - + " preg_match_all(\'!:(\' . $this->_qstr_regexp . \'|[^:]+)!\', $modifier_arg_strings[$i], $match);\r\n" - + " $modifier_args = $match[1];\r\n" - + "\r\n" - + " if ($modifier_name{0} == \'@\') {\r\n" - + " $map_array = \'false\';\r\n" - + " $modifier_name = substr($modifier_name, 1);\r\n" - + " } else {\r\n" - + " $map_array = \'true\';\r\n" - + " }\r\n" - + " \r\n" - + " $this->_add_plugin(\'modifier\', $modifier_name);\r\n" - + "\r\n" - + " $this->_parse_vars_props($modifier_args);\r\n" - + "\r\n" - + " if (count($modifier_args) > 0)\r\n" - + " $modifier_args = \', \'.implode(\', \', $modifier_args);\r\n" - + " else\r\n" - + " $modifier_args = \'\';\r\n" - + "\r\n" - + " $output = \"\\$this->_run_mod_handler(\'$modifier_name\', $map_array, $output$modifier_args)\";\r\n" - + " }\r\n" - + " }\r\n" - + "\r\n" - + "\r\n" - + " /**\r\n" - + " * add plugin\r\n" - + " *\r\n" - + " * @access public\r\n" - + " * @param $type\r\n" - + " * @param $name\r\n" - + " * @param $delayed_loading\r\n" - + " */\r\n" - + " function _add_plugin($type, $name, $delayed_loading = null)\r\n" - + " {\r\n" - + " if (!isset($this->_plugin_info[$type])) {\r\n" - + " $this->_plugin_info[$type] = array();\r\n" - + " }\r\n" - + " if (!isset($this->_plugin_info[$type][$name])) {\r\n" - + " $this->_plugin_info[$type][$name] = array($this->_current_file,\r\n" - + " $this->_current_line_no,\r\n" - + " $delayed_loading);\r\n" - + " }\r\n" - + " }\r\n" - + " \r\n" - + "\r\n" - + " /**\r\n" - + " * Compiles references of type $smarty.foo\r\n" - + " *\r\n" - + " * @access public\r\n" - + " * @param $indexes\r\n" - + " */\r\n" - + " function _compile_smarty_ref(&$indexes)\r\n" - + " {\r\n" - + " /* Extract the reference name. */\r\n" - + " $ref = substr($indexes[0], 1);\r\n" - + "\r\n" - + " switch ($ref) {\r\n" - + " case \'now\':\r\n" - + " $compiled_ref = \'time()\';\r\n" - + " if (count($indexes) > 1) {\r\n" - + " $this->_syntax_error(\'$smarty\' . implode(\'\', $indexes) .\' is an invalid reference\', E_USER_ERROR, __FILE__, __LINE__);\r\n" - + " }\r\n" - + " break;\r\n" - + "\r\n" - + " case \'foreach\':\r\n" - + " case \'section\':\r\n" - + " if ($indexes[1]{0} != \'.\') {\r\n" - + " $this->_syntax_error(\'$smarty\' . implode(\'\', array_slice($indexes, 0, 2)) . \' is an invalid reference\', E_USER_ERROR, __FILE__, __LINE__);\r\n" - + " }\r\n" - + " $name = substr($indexes[1], 1);\r\n" - + " array_shift($indexes);\r\n" - + " if ($ref == \'foreach\')\r\n" - + " $compiled_ref = \"\\$this->_foreach[\'$name\']\";\r\n" - + " else\r\n" - + " $compiled_ref = \"\\$this->_sections[\'$name\']\";\r\n" - + " break;\r\n" - + "\r\n" - + " case \'get\':\r\n" - + " array_shift($indexes);\r\n" - + " $compiled_ref = \"\\$_GET\";\r\n" - + " if ($name = substr($indexes[0], 1))\r\n" - + " $compiled_ref .= \"[\'$name\']\";\r\n" - + " break;\r\n" - + "\r\n" - + " case \'post\':\r\n" - + " array_shift($indexes);\r\n" - + " $name = substr($indexes[0], 1);\r\n" - + " $compiled_ref = \"\\$_POST\";\r\n" - + " if ($name = substr($indexes[0], 1))\r\n" - + " $compiled_ref .= \"[\'$name\']\";\r\n" - + " break;\r\n" - + "\r\n" - + " case \'cookies\':\r\n" - + " array_shift($indexes);\r\n" - + " $name = substr($indexes[0], 1);\r\n" - + " $compiled_ref = \"\\$_COOKIE\";\r\n" - + " if ($name = substr($indexes[0], 1))\r\n" - + " $compiled_ref .= \"[\'$name\']\";\r\n" - + " break;\r\n" - + "\r\n" - + " case \'env\':\r\n" - + " array_shift($indexes);\r\n" - + " $compiled_ref = \"\\$_ENV\";\r\n" - + " if ($name = substr($indexes[0], 1))\r\n" - + " $compiled_ref .= \"[\'$name\']\";\r\n" - + " break;\r\n" - + "\r\n" - + " case \'server\':\r\n" - + " array_shift($indexes);\r\n" - + " $name = substr($indexes[0], 1);\r\n" - + " $compiled_ref = \"\\$_SERVER\";\r\n" - + " if ($name = substr($indexes[0], 1))\r\n" - + " $compiled_ref .= \"[\'$name\']\";\r\n" - + " break;\r\n" - + "\r\n" - + " case \'session\':\r\n" - + " array_shift($indexes);\r\n" - + " $name = substr($indexes[0], 1);\r\n" - + " $compiled_ref = \"\\$_SESSION\";\r\n" - + " if ($name = substr($indexes[0], 1))\r\n" - + " $compiled_ref .= \"[\'$name\']\";\r\n" - + " break;\r\n" - + "\r\n" - + " /*\r\n" - + " * These cases are handled either at run-time or elsewhere in the\r\n" - + " * compiler.\r\n" - + " */\r\n" - + " case \'request\':\r\n" - + " $this->_init_smarty_vars = true;\r\n" - + " return null;\r\n" - + "\r\n" - + " case \'capture\':\r\n" - + " return null;\r\n" - + "\r\n" - + " case \'template\':\r\n" - + " $compiled_ref = \"\'$this->_current_file\'\";\r\n" - + " if (count($indexes) > 1) {\r\n" - + " $this->_syntax_error(\'$smarty\' . implode(\'\', $indexes) .\' is an invalid reference\', E_USER_ERROR, __FILE__, __LINE__);\r\n" - + " }\r\n" - + " break;\r\n" - + " \r\n" - + " case \'version\':\r\n" - + " $compiled_ref = \"\'$this->_version\'\";\r\n" - + " break;\r\n" - + "\r\n" - + " case \'const\':\r\n" - + " array_shift($indexes);\r\n" - + " $compiled_ref = \'defined(\\\'\' . substr($indexes[0],1) . \'\\\') ? \' . substr($indexes[0],1) . \' : null\';\r\n" - + " break;\r\n" - + "\r\n" - + " default:\r\n" - + " $this->_syntax_error(\'$smarty.\' . $ref . \' is an unknown reference\', E_USER_ERROR, __FILE__, __LINE__);\r\n" - + " break;\r\n" - + " }\r\n" - + "\r\n" - + " array_shift($indexes);\r\n" - + " return $compiled_ref;\r\n" - + " }\r\n" - + "\r\n" - + "\r\n" - + " /**\r\n" - + " * load pre- and post-filters\r\n" - + " *\r\n" - + " * @access public\r\n" - + " */\r\n" - + " function _load_filters()\r\n" - + " {\r\n" - + " if (count($this->_plugins[\'prefilter\']) > 0) {\r\n" - + " foreach ($this->_plugins[\'prefilter\'] as $filter_name => $prefilter) {\r\n" - + " if ($prefilter === false) {\r\n" - + " unset($this->_plugins[\'prefilter\'][$filter_name]);\r\n" - + " $this->_load_plugins(array(array(\'prefilter\', $filter_name, null, null, false)));\r\n" - + " }\r\n" - + " }\r\n" - + " }\r\n" - + " if (count($this->_plugins[\'postfilter\']) > 0) {\r\n" - + " foreach ($this->_plugins[\'postfilter\'] as $filter_name => $postfilter) {\r\n" - + " if ($postfilter === false) {\r\n" - + " unset($this->_plugins[\'postfilter\'][$filter_name]);\r\n" - + " $this->_load_plugins(array(array(\'postfilter\', $filter_name, null, null, false)));\r\n" - + " }\r\n" - + " }\r\n" - + " }\r\n" - + " }\r\n" - + "\r\n" - + "\r\n" - + " /**\r\n" - + " * display Smarty syntax error\r\n" - + " *\r\n" - + " * @access public\r\n" - + " * @param $error_msg\r\n" - + " * @param $error_type\r\n" - + " * @param $file\r\n" - + " * @param $line\r\n" - + " */\r\n" - + " function _syntax_error($error_msg, $error_type = E_USER_ERROR, $file=null, $line=null)\r\n" - + " {\r\n" - + " if(isset($file) && isset($line)) {\r\n" - + " $info = \' (\'.basename($file).\", line $line)\";\r\n" - + " } else {\r\n" - + " $info = null;\r\n" - + " }\r\n" - + " trigger_error(\'Smarty: [in \' . $this->_current_file . \' line \' .\r\n" - + " $this->_current_line_no . \"]: syntax error: $error_msg$info\", $error_type);\r\n" - + " }\r\n" + "}\r\n" + "\r\n" + "/**\r\n" - + " * compare to values by their string length\r\n" + " *\r\n" - + " * @access private\r\n" + " * @param $a\r\n" - + " * @param $b\r\n" + " */\r\n" - + "function _smarty_sort_length($a, $b)\r\n" + "{\r\n" - + " if($a == $b)\r\n" + " return 0;\r\n" + "\r\n" - + " if(strlen($a) == strlen($b))\r\n" - + " return ($a > $b) ? -1 : 1;\r\n" + "\r\n" - + " return (strlen($a) > strlen($b)) ? -1 : 1;\r\n" + "}\r\n" - + "\r\n" + "\r\n" + "/* vim: set et: */\r\n" + "\r\n" - + "?>\r\n" + ""); - } -} diff --git a/net.sourceforge.phpeclipse.tests/test.php b/net.sourceforge.phpeclipse.tests/test.php deleted file mode 100644 index e12766c..0000000 --- a/net.sourceforge.phpeclipse.tests/test.php +++ /dev/null @@ -1,7 +0,0 @@ - \ No newline at end of file -- 1.7.1
    \n" - + "EOF;"); - checkPHP("interface Shape { \n" + " function draw(); \n" + "} \n" - + "\n" + "class Rectangle implements Shape { \n" - + " function draw() { \n" - + " print \"Drawing a rectangle\"; \n" + " } \n" - + "}"); - checkPHP("class MyClass { \n" + " private $priv; \n" + "\n" - + " public function getVar() { \n" - + " return $this->priv; \n" + " } \n" + "} "); - checkPHP("class Test { \n" + " function __construct() { \n" - + " print \"Test constructor\"; \n" + " } \n" + "}"); - checkPHP("class Test { \n" + " function __destruct() { \n" - + " print \"Destroying Test object\"; \n" + " } \n" - + "}"); - - checkPHP("class Test { \n" + " final function doNotOverload() { \n" - + " return __CLASS__; \n" + " } \n" + "}"); - checkPHP("final class Test { \n" + "} \n" + "\n" - + "class DoNotInherit extends Test { \n" + "}"); - checkPHP("class Test { \n" + " function __clone() { \n" - + " print \"Clone test object\"; \n" + " } \n" - + "} \n" + "$test = new Test(); \n" + "clone $test; "); - checkPHP("class Test { \n" + " const SEMICOLON = \";\"; \n" - + " const QUESTIONMARK = \"?\"; \n" + "} \n" - + "print Test::SEMICOLON; "); - checkPHP("class Singleton { \n" + " static $instance = NULL; \n" - + " function getInstance() { \n" - + " if ($this->instance == NULL) { \n" - + " $this->instance = new Singleton(); \n" - + " } \n" + " return $this->instance; \n" - + " } \n" + "} "); - checkPHP("class Test { \n" + " static function helloWorld() { \n" - + " print \"Hello, world\"; \n" + " } \n" + "} \n" - + "Test::helloWorld();"); - checkPHP("abstract class Test { \n" + " function draw() { \n" - + " print \"Inside draw()\"; \n" + " } \n" + "} "); - checkPHP("abstract class Test { \n" - + " abstract function draw(); \n" + "} "); - checkPHP("function f1(Test $test) { \n" + "\n" + "}"); - checkPHP("$test->m1()->m2(); "); - checkPHP("$test = new IteratorImpl(); \n" - + "foreach ($test as $value) { \n" + " print \"$value\"; \n" - + "}"); - checkPHP("function __autoload($clazz) { \n" - + " include_once($clazz . \"php\"); \n" + "} \n" + "\n" - + "$obj = new Test1(); \n" + "$obj2 = new Test2(); "); - checkPHP("class SQLException extends Exception { \n" - + " public $problem; \n" - + " function __construct($problem) { \n" - + " $this->problem = $problem; \n" - + " } \n" - + "} \n" - + "\n" - + "try { \n" - + " throw new SQLException(\"Couldn’t connect to database\"); \n" - + "} catch (SQLException $e) { \n" - + " print \"Caught an SQLException with problem $obj->problem\"; \n" - + "} catch (Exception $e) { \n" - + " print \"Caught unrecognized exception\"; \n" + "}"); - checkPHP("function my_func(&$arg = null) { \n" - + " if ($arg === NULL) { \n" - + " print \'$arg is empty\'; \n" + " } \n" + "} \n" - + "my_func();"); - checkPHP("foreach ($array as &$value) { \n" - + " if ($value === \"NULL\") { \n" - + " $value = NULL; \n" + " } \n" + "}"); - checkPHP("$testxml = simplexml_load_file(\'test.xml\'); \n" - + "foreach ($$testxml->client as $test) { \n" - + " print \"$test->name has account number $test->account_number \"; \n" - + "} "); - checkHTML(" "); - checkHTML("\n" - + "test me\n" + ""); - - checkHTML(""); - checkPHP("function clean_words($mode, &$entry, &$stopword_list, &$synonym_list)\r\n" - + "{ static $drop_char_match = array(\'^\', \'$\'); }"); - - checkPHP("if ($topic<1) { $topic = 1;}"); - checkPHP("$this->result_field_names[$result_id][] = odbc_field_name($result_id, $i);"); - checkPHP("$db->sql_query($sql);"); - checkPHP("$val = $$add;"); - checkPHP("if(!$result = mysql_query($sql)) return(array());"); - checkPHP("class test { function &fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null) \n{ \n } \n }"); - // Bugs item #690938 - checkPHP("$ebus_sql['sel_url_list'] = <<>\n" - + "and appl_sect_deftn_sk = <>\n" + "order by url_ord\n" - + "EOS;\n"); - checkPHP("foreach ($HTTP_GET_VARS as $secvalue) { }"); - - checkPHP("\"\\[addsig]\""); - checkPHP("$v->read();"); - checkPHP("$add = 'a'.$i;$val = $$add;"); - checkPHP("($a==\"b\") || (c($this->x)==\"d\");"); - checkPHP("(substr($this->file, 0, 2) == \"MM\");"); - checkPHP("(substr($this->file, 0, 2) == \"MM\") || substr($this->file, 0, 2) == \"II\";"); - checkPHP("return (substr($this->file, 0, 2) == \"MM\") || substr($this->file, 0, 2) == \"II\";"); - checkPHP("$this->highlightfile->linkscripts{$category}"); - checkPHP("$code = call_user_method($this->highlightfile->linkscripts{$category}, $this->highlightfile, $oldword, $this->output_module)"); - checkPHP("$this->startmap[$startcurrtag]();"); - checkPHP("new $this->startmap[$startcurrtag]();"); - checkPHP("$this->highlightfile = new $this->startmap[$startcurrtag]();"); - checkPHP("echo \"Test\", \"me\";"); - checkPHP("print (\"Test me\");"); - checkPHP("$s = <<blockvariables[$block][$varname]);"); - checkPHP("new IT_Error(\"The block '$block' was not found in the template.\", __FILE__, __LINE__);"); - checkPHP("for ($i=156, $j=0; $i<512; $i++, $j++) $v_checksum += ord(substr($v_binary_data_last,$j,1));"); - checkPHP("define('MAIL_MIME_CRLF', $crlf, true);"); - checkPHP("static $last_run = 0;"); - checkPHP("unset($headers['Subject']);"); - checkPHP("switch($func) {\n case \"f0\":\n case \"f1\":\n f1();\n break; \n case \"tt\": \n default: \n f0(); \n break;\n }"); - checkPHP("function validateAndParseResponse($code, &$arguments) { }"); - checkPHP("$options = Console_Getopt::getopt($argv, \"h?v:e:p:d:\");"); - checkPHP("$this->container = new $container_class($container_options);"); - checkPHP("class Cmd extends PEAR { var $arrSetting = array(); }"); - checkPHP("class Cmd extends PEAR { var $arrSetting = array(), $i=10; }"); - checkPHP("if (isset($test)) { } elseif (isset($lang)) { }"); - checkPHP("require_once(\"mainfile.php\"); "); - checkPHP("if (eregi(\"footer.php\",$PHP_SELF)) {\n" - + "Header(\"Location: index.php\");\n" + "die();\n" + "}\n"); - checkPHP("while (eregi(\"footer.php\",$PHP_SELF)) {\n" - + "Header(\"Location: index.php\");\n" + "die();\n" + "}\n"); - checkPHP("while (eregi(\"footer.php\",$PHP_SELF)) :\n" - + "Header(\"Location: index.php\");\n" + "die();\n" - + "endwhile;\n"); - checkPHP("$tipath = \"images/topics/\";"); - checkPHP("$reasons = array(\"1\", \"2\",\"test\");"); - checkPHP("if ($home == 1) { message_box(); blocks(Center);}"); - checkPHP("$bresult = sql_query(\"select * from \".$prefix.\"_banner WHERE type='0' AND active='1'\", $dbi);"); - checkPHP("switch($func) {\n case \"f1\":\n f1();\n break; \n default: \n f0(); \n break;\n }"); - checkPHP("list ($catid) = sql_fetch_row($result, $dbi);"); - checkPHP("if (!$name) { \n }"); - checkPHP("mt_srand((double)microtime()*1000000);"); - checkPHP("$alttext = ereg_replace(\"\\\"\", \"\", $alttext);"); - checkPHP("$message .= \"\"._THISISAUTOMATED.\"\\n\\n\";"); - checkPHP("if (!empty($pass) AND $pass==$passwd) { }"); - checkPHP("$AllowableHTML = array(\"b\"=>1,\n \"i\"=>1);"); - checkPHP("if ($term{0}!=$firstChar) {}"); - checkPHP("echo \"
    \"._NOADMINYET.\"


    \"\n" - + ".\"
    \"\n" - + ".\"
    \"._NICKNAME.\":