Exemplo n.º 1
0
 public Menu(string __Name, string __Description, string __Code, int __Ordering, 
             string __Url, Menu __Parent, Category __Category, int __Show)
 {
     _Name = __Name;
     _Description = __Description;
     _Code = __Code; 
     _Ordering = __Ordering;
     _Url = __Url;
     _Show= __Show;
     _Parent = __Parent;
     if (__Category != null)
         _CategoryId = __Category.Id;
     else
         _CategoryId = 0;
 }
    public static MenuTranslation FindByMenuAndLang(Menu menu, string lang)
    {
        SimpleQuery q = new SimpleQuery(typeof(MenuTranslation), @"
            from MenuTranslation T
            where
                T.Menu = ? and
                T.Language = ?", menu, lang);

        MenuTranslation[] translations = (MenuTranslation[])ExecuteQuery(q);
        if (translations.Length > 0)
            return translations[0];
        else
            return null;
    }
		public abstract string PrintSelectedItem (Menu menu, string item);
		public abstract string PrintItem (Menu menu, string item);
	public string BuildTreeLeftWithVinyetas (string givenMenu, Menu actualMenu, Category currentCategory, int depth_level, string currentLanguage, string styleClass)
	{
      User user = (User) Controller.Context.Session[Constants.USER];
		TreeLeftWithVinyetas wv = new TreeLeftWithVinyetas (givenMenu, currentCategory, actualMenu, user);

		return wv.BuildTree(currentLanguage, depth_level, styleClass);
	}
 public static MenuTranslation FindByMenuAndLang(Menu menu, Language lang)
 {
     MenuTranslation[] translations = (MenuTranslation[]) ActiveRecordBase.FindAll( typeof(MenuTranslation),
                            Expression.Eq("Menu", menu), Expression.Eq("Lang", lang));
     if ((translations != null) && (translations.Length > 0))
         return translations[0];
     else
         return null;
 }
		protected bool Selected (Menu menu)
		{
			bool isAntecessor = false;
	
			if ((menu != null) && (this.actualMenu != null)) 
			{
				for (Menu m = this.actualMenu; m.Parent != null; m = m.Parent)
				{
					if (m.Id == menu.Id) 
					{
						isAntecessor = true;
						break;
					}
				}
			}

			if (((this.currentCategory != null) && (menu.CategoryId == this.currentCategory.Id)) || (isAntecessor == true))
				return true;
			return false;
		}
		public TreeTable (string menuName, Category currentCategory, Menu actualMenu, User user) {
			_givenMenu = Menu.FindByName (menuName);
			_currentCategory = currentCategory;
			_actualMenu = actualMenu;
			_user = user;
		}
		public override string PrintSelectedItem (Menu menu, string item)
		{
			string html = String.Empty;
			html += "<td class=\"" + this.styleClass + "_td_current_" + this.actualDepth + "\">";
			html += "<a href=" + menu.ToUrl(config.GetValue(Constants.SITE_ROOT));
			html += " title=\"" + menu.Name +"\">"+ item;
			html += "</a>";
			html += "</td>";
			return html;
		}
Exemplo n.º 10
0
		public override string PrintSelectedItem (Menu menu, string item)
		{
			string html = String.Empty;

			html += "<li class=\"" + this.styleClass + "_li_current_" + this.actualDepth + "\">";
			html += "<table class=\"" + this.styleClass + "\">";
			html += "<td class=\"" + this.styleClass + "vinyeta" + this.actualDepth + "\">";
			if (this.actualDepth != 1)
				html += ">";						// Viñeta
			html += "</td>";
			html += "<td class=\"" + this.styleClass + "texto" + this.actualDepth + "\">";
			html += "<a href=" + menu.ToUrl(config.GetValue(Constants.SITE_ROOT));
			html += " title=\"" + menu.Name +"\">" + item;
			html += "</a>";
			html += "</td>";
			html += "</table>";
			html += "</li>";
         html += "<img src=\"" + config.GetValue(Constants.SITE_ROOT) + "/Public/style/img/separamenu.gif\" class=\"" + this.styleClass + ">";
			return html;
		}
Exemplo n.º 11
0
		public TreeTable (Menu givenMenu, Category currentCategory, Menu actualMenu, User user) {
			_givenMenu = givenMenu;
			_currentCategory = currentCategory;
			_actualMenu = actualMenu;
			_user = user;
		}
Exemplo n.º 12
0
		public TreeLeftWithVinyetas (Menu givenMenu, Category currentCategory, Menu actualMenu, User user) {
			_givenMenu = givenMenu;
			_currentCategory = currentCategory;
			_actualMenu = actualMenu;
			_user = user;
		}
Exemplo n.º 13
0
		protected string GetDescription (Menu menu)
		{
			MenuTranslation mt = MenuTranslation.FindByMenuAndLang(menu, Language.FindByName(this.language));
			string description;

			if (mt != null)
				description = mt.Translation;
			else
				description = menu.Description;

			return description;
		}
Exemplo n.º 14
0
		public string BuildSubTree (Menu menu)
		{
			this.actualDepth++;
			if (this.actualDepth <= this.depthLimit) {
				if (menu.Children.Count > 0)
				{
					String subtree = String.Empty;
					foreach (Menu m in menu.Children) 
					{
						if ((Selected(m)) || (this.actualMenu.Code == "showAllChilds"))
						{
							subtree += PrintSelectedItem (m, GetDescription(m));
							subtree += BuildSubTree(m);
						}
						else
							subtree += PrintItem (m, GetDescription(m));
					}
					this.actualDepth--;
					return subtree;
				}
			}
			
			this.actualDepth--;
			return String.Empty;
		}
    public static MenuTranslation[] FindByMenu(Menu menu)
    {
        SimpleQuery q = new SimpleQuery(typeof(MenuTranslation), @"
            from MenuTranslation T
            where T.Menu = ?", menu);

        return (MenuTranslation[]) ExecuteQuery(q);

    }
Exemplo n.º 16
0
	public string BuildTreeMapaWeb (string givenMenu, Category currentCategory, string currentLanguage, string styleClass)
	{
		Menu menu = new Menu("", "", "showAllChilds", 0, "", null, null, 0);

      User user = (User) Controller.Context.Session[Constants.USER];
		Tree mw = new Tree (givenMenu, currentCategory, menu, user);

		return mw.BuildTree(currentLanguage, 999, styleClass);
	}
 public MenuTranslation(Language lang, Menu menu, string translation)
 {
     _lang = lang;
     _menu = menu;
     _translation = translation;
 }
Exemplo n.º 18
0
	public string MakeMenu(string givenMenu, Category currentCategory, string currentLanguage, string styleClass)
	{
		Menu menu = new Menu(); //("", "", "", 0, "", null, null, 0);

      User user = (User) Controller.Context.Session[Constants.USER];
		Tree mw = new Tree (givenMenu, currentCategory, menu, user);

		return mw.BuildTree(currentLanguage, 1, styleClass);
	}
    private static string ReadMenu(XmlNode node, Menu parent)
    {
        try
        {
            if (node.Name == "Menu")
            {
                string name = NodeGetString(node, "nombre");
                string description = NodeGetString(node, "description");
                if (name != "" && description == "")
                    description = name;
                if (name == "" && description != "")
                    name = description;
                string idcategory = NodeGetString(node, "categorycode");
                string code = NodeGetString(node, "code");

//                Menu parent = (Menu)NodeGetObject(node, "parent", menus);
                string orderString = NodeGetString(node, "order");
                int ordering = int.Parse(orderString);

                string url = NodeGetString(node, "url");

                string categorystring = NodeGetString(node, "category");
                if (categorystring == "")
                    categorystring = name;

                Category category = null;
                if (url == "")
                {
                    if (idcategory != "")
                        category = (Category) NodeGetObject(node, "categorycode", categories);
                    else
                        category = (Category) GetObject(categorystring, categories, node, "category");
                }

                System.Console.WriteLine ("Menu: "+ name);
                int show = 0;
                Menu m = new Menu(name, description, code, ordering, url, parent, category, show);
                m.Save();
                menus[name] = m;
                if (menus[code] == null)
                    menus[code] = m;
                else
                    System.Console.WriteLine("Hay otro menú con el mismo CODE ({0})", m.Description);

                foreach (XmlNode n in node.ChildNodes)
                if (n.Name == "Menu")
                    ReadMenu(n, m);
            }
            return null;
        }
        catch(System.FormatException)
        {
            return "No se pudo leeer columna ordering";
        }
    }
Exemplo n.º 20
0
		private bool CheckMenuPermission(Menu menu)
		{
			bool hasPermission = false;

			Hashtable menuPermissionsHash;
			if (menu.CategoryId > 0)
			{
				Category category = Category.Find(menu.CategoryId);
				menuPermissionsHash = category.GetPermissionsHash(this.user);
			}
			else
				menuPermissionsHash = Commons.GetPermissionsBaseHash(true);

			if (menuPermissionsHash != null)
			{
				// Permissions check: (is working fine)
				Object permission = menuPermissionsHash[Permission.Read];
				if ((permission != null) && ((bool)permission))
					hasPermission = true;
			}

			return hasPermission;
		}