Example #1
0
        /// <summary>
        /// Creates all the root nodes for each language
        /// </summary>
        /// <param name="path"></param>
        public void BeginBuild(string path, DatabaseLogger logger)
        {
            _logger4Net.InfoFormat("Start building menu for {0}", path);
            _logger = logger;
            //TODO set use Date format
            _rootPath = System.IO.Path.GetDirectoryName(path) + "\\";
            _databaseName = System.IO.Path.GetFileName(path);
            _logger(new DatabaseMessage() { MessageType = DatabaseMessage.BuilderMessageType.Information, Message = "Menu build started " + DateTime.Now.ToString() });
            string folderName = System.IO.Path.GetFileNameWithoutExtension(path);
            foreach (var language in _languages)
            {
                PxMenuItem root = new PxMenuItem(null, System.IO.Path.GetDirectoryName(path), folderName, folderName, folderName, path, "");
                _languageRoots.Add(language, root);
                _currentItems.Add(language, root);
                _links.Add(root, new List<string>());
            }

        }
Example #2
0
 public void BeginNewLevel(string id)
 {
     string name = System.IO.Path.GetFileNameWithoutExtension(id);
     foreach (var language in _languages)
     {
         ItemSelection cid = new ItemSelection(System.IO.Path.GetDirectoryName(id.Substring(_rootPath.Length)), id.Substring(_rootPath.Length));
         PxMenuItem newItem = new PxMenuItem(null, name, "", name, cid.Menu, cid.Selection, "");
         _currentItems[language].AddSubItem(newItem);
         _currentItems[language] = newItem;
         _links.Add(newItem, new List<string>());
     }
 }
Example #3
0
        /// <summary>
        /// Checks if a link shall be added or not. If this check is not done a link may be added 
        /// twice for the default language - which is wrong.
        /// </summary>
        /// <param name="path">Path to the .link-file</param>
        /// <param name="itm">MenuItem object that the link shall be added to</param>
        /// <returns></returns>
        private bool CheckIfLinkShallBeAdded(string path, PxMenuItem itm)
        {
            string filename = System.IO.Path.GetFileNameWithoutExtension(path);
            int index = filename.IndexOf("_");


            if ((index != -1) && (index > 0))
            {
                //Remove the language-specific part of the filename (for example: "_en" or "_sv")
                filename = filename.Substring(0, index);
            }

            if (_links[itm].Contains(filename))
            {
                return false;
            }
            else
            {
                _links[itm].Add(filename);
                return true;
            }
        }
Example #4
0
 private bool HasLinks(PxMenuItem item)
 {
     for (int i = 0; i < item.SubItems.Count; i++)
     {
         Item itm = item.SubItems[i];
         if (itm is Link)
         {
             return true;
         }
         else if (itm is PxMenuItem)
         {
             if (HasLinks((PxMenuItem)itm))
             {
                 return true;
             }
         }
     }
     return false;
 }