public static void addSubstitutions(Substitutions substituter, String dir)
        {
            bool rtl = RTL.Equals(dir);

            substituter.addSubstitution(Substitutions.Type.BIDI, START_EDGE, rtl ? RIGHT : LEFT);
            substituter.addSubstitution(Substitutions.Type.BIDI, END_EDGE, rtl ? LEFT : RIGHT);
            substituter.addSubstitution(Substitutions.Type.BIDI, DIR, rtl ? RTL : LTR);
            substituter.addSubstitution(Substitutions.Type.BIDI, REVERSE_DIR, rtl ? LTR : RTL);
        }
Exemple #2
0
        /**
         * Substitutes all hangman variables into the gadget spec.
         *
         * @return A new GadgetSpec, with all fields substituted as needed.
         */
        public GadgetSpec substitute(GadgetContext context, GadgetSpec spec)
        {
            MessageBundle bundle =
                messageBundleFactory.getBundle(spec, context.getLocale(), context.getIgnoreCache());
            String dir = bundle.getLanguageDirection();

            Substitutions substituter = new Substitutions();

            substituter.addSubstitutions(Substitutions.Type.MESSAGE, bundle.getMessages());
            BidiSubstituter.addSubstitutions(substituter, dir);
            substituter.addSubstitution(Substitutions.Type.MODULE, "ID",
                                        context.getModuleId());
            UserPrefSubstituter.addSubstitutions(substituter, spec, context.getUserPrefs());

            return(spec.substitute(substituter));
        }
 public static void addSubstitutions(Substitutions substituter,
                                     GadgetSpec spec, UserPrefs values)
 {
     foreach (UserPref pref in spec.getUserPrefs())
     {
         String name  = pref.getName();
         String value = values.getPref(name);
         if (value == null)
         {
             value = pref.getDefaultValue();
             if (value == null)
             {
                 value = "";
             }
         }
         substituter.addSubstitution(Substitutions.Type.USER_PREF, name, HttpUtility.HtmlEncode(value));
     }
 }