예제 #1
0
        /// <summary>
        /// Reads the Menu.sort file and creates a MenuSortItem containg the information read
        /// </summary>
        /// <param name="path">Path to the Menu.sort file</param>
        /// <returns>A MenuSOrtItem containg the information from the Menu.sort file</returns>
        /// <remarks>
        /// If the alias file do not have a language specified in the name then the
        /// default language specified in the settings will be used
        /// </remarks>
        public object Handle(string path, DatabaseLogger logger)
        {
            string fileName    = System.IO.Path.GetFileName(path);
            int    splittIndex = fileName.LastIndexOf('.');

            MenuSortItem sort = new MenuSortItem();

            if (splittIndex == 4)
            {
                sort.Language = Settings.Current.General.Language.DefaultLanguage;
            }
            else
            {
                sort.Language = fileName.Substring(5, splittIndex - 5);
            }
            try
            {
                sort.SortString = ReadAll(path);
            }
            catch (System.IO.IOException ex)
            {
                logger(new DatabaseMessage()
                {
                    MessageType = DatabaseMessage.BuilderMessageType.Error, Message = "Could not read file " + path
                });
                _logger.Warn(ex.ToString());
                return(null);
            }

            return(sort);
        }
예제 #2
0
파일: MenuBuilder.cs 프로젝트: trygu/PxWeb
 public void NewItem(object item, string path)
 {
     if (item is AliasItem)
     {
         AliasItem alias = (AliasItem)item;
         if (Array.IndexOf(_languages, alias.Language) >= 0)
         {
             if (_currentItems[alias.Language].Text == _currentItems[alias.Language].SortCode)
             {
                 _currentItems[alias.Language].SortCode = alias.Alias;
             }
             _currentItems[alias.Language].Text = alias.Alias;
         }
     }
     else if (item is LinkItem)
     {
         LinkItem itm = (LinkItem)item;
         if (Array.IndexOf(_languages, itm.Language) >= 0)
         {
             if (CheckIfLinkShallBeAdded(path, _currentItems[itm.Language]))
             {
                 //Url url = new Url(itm.Text, "", path, "", PresCategory.NotSet, itm.Location, LinkPres.NotSet);
                 Url url = new Url(itm.Text, "", "MENU_TEST", itm.Location, "", PresCategory.NotSet, itm.Location, LinkPres.NotSet);
                 _currentItems[itm.Language].SubItems.Add(url);
             }
         }
     }
     else if (item is MenuSortItem)
     {
         MenuSortItem sort = item as MenuSortItem;
         if (Array.IndexOf(_languages, sort.Language) >= 0)
         {
             _currentItems[sort.Language].SortCode = sort.SortString;
         }
     }
     else if (item is PCAxis.Paxiom.PXMeta)
     {
         PCAxis.Paxiom.PXMeta meta = (PCAxis.Paxiom.PXMeta)item;
         foreach (var language in _languages)
         {
             if (meta.HasLanguage(language))
             {
                 meta.SetLanguage(language);
                 TableLink tbl = CreateTableLink(meta, path);
                 _currentItems[language].AddSubItem(tbl);
             }
             else
             {
                 if (!_languageDependent)
                 {
                     if (meta.HasLanguage(Settings.Current.General.Language.DefaultLanguage))
                     {
                         meta.SetLanguage(Settings.Current.General.Language.DefaultLanguage);
                     }
                     else
                     {
                         meta.SetLanguage("default");
                     }
                     TableLink tbl = CreateTableLink(meta, path);
                     _currentItems[language].AddSubItem(tbl);
                 }
             }
         }
     }
 }