示例#1
0
        public static bool ResetRewriteVariables()
        {
            /*PhpException.FunctionNotSupported();
             * return false;*/


            ScriptContext  context  = ScriptContext.CurrentContext;
            UrlRewriter    rewriter = UrlRewriter.Current;
            BufferedOutput output   = context.BufferedOutput;

            if (rewriter == null ||
                output.Level == 0 ||
                output.GetFilter() != rewriter.filterCallback)
            {
                return(false);
            }

            // some output flush
            output.Flush();

            rewriter.Variables.Clear();
            output.DecreaseLevel(false);

            if (output.Level == 0)
            {
                context.IsOutputBuffered = false;
            }

            return(true);
        }
示例#2
0
        public static bool AddRewriteVariable(string name, string value)
        {
            if (String.IsNullOrEmpty(name))
            {
                PhpException.InvalidArgument("name", LibResources.GetString("arg:null_or_empty"));
                return(false);
            }

            ScriptContext  context  = ScriptContext.CurrentContext;
            UrlRewriter    rewriter = UrlRewriter.GetOrCreate();
            BufferedOutput output   = context.BufferedOutput;

            // some output flush
            output.Flush();

            rewriter.Variables[name] = value;

            // start UrlRewriter filtering if not yet
            if (output.FindLevelByFilter(rewriter.filterCallback) < 0)
            {
                // create new output buffer level (URL-Rewriter is not started yet)
                int Level = output.IncreaseLevel();
                output.SetFilter(rewriter.GetOrCreateFilterCallback(context), Level);
                output.SetLevelName(Level, "URL-Rewriter");
            }

            context.IsOutputBuffered = true;    // turn on output buffering if not yet

            return(true);
        }
示例#3
0
 private static UrlRewriter /*!*/ GetOrCreate()
 {
     if (current == null)
     {
         current = new UrlRewriter();
     }
     return(current);
 }
示例#4
0
 public TagsUrlRewriter(UrlRewriter rewriter)
 {
     this.rewriter = rewriter;
 }
示例#5
0
 /// <summary>
 /// Clears thread static field. Called on request end.
 /// </summary>
 public static void Clear()
 {
     current = null;
 }
示例#6
0
 public TagsUrlRewriter(UrlRewriter rewriter)
 {
     this.rewriter = rewriter;
 }
示例#7
0
		private static UrlRewriter/*!*/ GetOrCreate()
		{
			if (current == null) current = new UrlRewriter();
			return current;
		}
示例#8
0
		/// <summary>
		/// Clears thread static field. Called on request end.
		/// </summary>
		public static void Clear()
		{
			current = null;
		}