Ejemplo n.º 1
0
        string GetRequestedPage(ContextInformation context)
        {
            var defaultPage = _host.GetSettingValue(SettingName.RootNamespaceDefaultPage);

            if (context.Page == null)
            {
                return(defaultPage);
            }

            return(context.Page.FullName ?? defaultPage);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes the Storage Provider.
        /// </summary>
        /// <param name="host">The Host of the Component.</param>
        /// <param name="config">The Configuration data, if any.</param>
        /// <exception cref="ArgumentNullException">If <b>host</b> or <b>config</b> are <c>null</c>.</exception>
        /// <exception cref="InvalidConfigurationException">If <b>config</b> is not valid or is incorrect.</exception>
        public void Init(IHostV30 host, string config)
        {
            if(host == null) throw new ArgumentNullException("host");
            if(config == null) throw new ArgumentNullException("config");

            this.host = host;

            if(!LocalProvidersTools.CheckWritePermissions(host.GetSettingValue(SettingName.PublicDirectory))) {
                throw new InvalidConfigurationException("Cannot write into the public directory - check permissions");
            }

            // Create all needed pluginAssemblies
            if(!File.Exists(GetFullPath(LogFile))) {
                File.Create(GetFullPath(LogFile)).Close();
            }

            if(!File.Exists(GetFullPath(ConfigFile))) {
                File.Create(GetFullPath(ConfigFile)).Close();
                isFirstStart = true;
            }

            if(!File.Exists(GetFullPath(RecentChangesFile))) {
                File.Create(GetFullPath(RecentChangesFile)).Close();
            }

            if(!File.Exists(GetFullPath(HtmlHeadFile))) {
                File.Create(GetFullPath(HtmlHeadFile)).Close();
            }

            if(!File.Exists(GetFullPath(HeaderFile))) {
                File.Create(GetFullPath(HeaderFile)).Close();
            }

            if(!File.Exists(GetFullPath(SidebarFile))) {
                File.Create(GetFullPath(SidebarFile)).Close();
            }

            if(!File.Exists(GetFullPath(FooterFile))) {
                File.Create(GetFullPath(FooterFile)).Close();
            }

            if(!File.Exists(GetFullPath(PageHeaderFile))) {
                File.Create(GetFullPath(PageHeaderFile)).Close();
            }

            if(!File.Exists(GetFullPath(PageFooterFile))) {
                File.Create(GetFullPath(PageFooterFile)).Close();
            }

            if(!File.Exists(GetFullPath(AccountActivationMessageFile))) {
                File.Create(GetFullPath(AccountActivationMessageFile)).Close();
            }

            if(!File.Exists(GetFullPath(PasswordResetProcedureMessageFile))) {
                File.Create(GetFullPath(PasswordResetProcedureMessageFile)).Close();
            }

            if(!File.Exists(GetFullPath(EditNoticeFile))) {
                File.Create(GetFullPath(EditNoticeFile)).Close();
            }

            if(!File.Exists(GetFullPath(LoginNoticeFile))) {
                File.Create(GetFullPath(LoginNoticeFile)).Close();
            }

            if(!File.Exists(GetFullPath(AccessDeniedNoticeFile))) {
                File.Create(GetFullPath(AccessDeniedNoticeFile)).Close();
            }

            if(!File.Exists(GetFullPath(RegisterNoticeFile))) {
                File.Create(GetFullPath(RegisterNoticeFile)).Close();
            }

            if(!File.Exists(GetFullPath(PageChangeMessageFile))) {
                File.Create(GetFullPath(PageChangeMessageFile)).Close();
            }

            if(!File.Exists(GetFullPath(DiscussionChangeMessageFile))) {
                File.Create(GetFullPath(DiscussionChangeMessageFile)).Close();
            }

            if(!File.Exists(GetFullPath(ApproveDraftMessageFile))) {
                File.Create(GetFullPath(ApproveDraftMessageFile)).Close();
            }

            if(!Directory.Exists(GetFullPath(PluginsDirectory))) {
                Directory.CreateDirectory(GetFullPath(PluginsDirectory));
            }

            if(!Directory.Exists(GetFullPathForPlugin(PluginsConfigDirectory))) {
                Directory.CreateDirectory(GetFullPathForPlugin(PluginsConfigDirectory));
            }

            if(!File.Exists(GetFullPathForPlugin(PluginsStatusFile))) {
                File.Create(GetFullPathForPlugin(PluginsStatusFile)).Close();
            }

            if(!File.Exists(GetFullPath(LinksFile))) {
                File.Create(GetFullPath(LinksFile)).Close();
            }

            LoadConfig();

            // Initialize ACL Manager and Storer
            aclManager = new StandardAclManager();
            aclStorer = new AclStorer(aclManager, GetFullPath(AclFile));
            aclStorer.LoadData();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes the Provider.
        /// </summary>
        /// <param name="host">The Host of the Provider.</param>
        /// <param name="config">The Configuration data, if any.</param>
        /// <exception cref="ArgumentNullException">If <b>host</b> or <b>config</b> are <c>null</c>.</exception>
        /// <exception cref="InvalidConfigurationException">If <b>config</b> is not valid or is incorrect.</exception>
        public void Init(IHostV30 host, string config)
        {
            if(host == null) throw new ArgumentNullException("host");
            if(config == null) throw new ArgumentNullException("config");

            this.host = host;

            if(!LocalProvidersTools.CheckWritePermissions(host.GetSettingValue(SettingName.PublicDirectory))) {
                throw new InvalidConfigurationException("Cannot write into the public directory - check permissions");
            }

            if(!Directory.Exists(Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), PagesDirectory))) {
                Directory.CreateDirectory(Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), PagesDirectory));
            }
            if(!Directory.Exists(Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), MessagesDirectory))) {
                Directory.CreateDirectory(Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), MessagesDirectory));
            }
            if(!Directory.Exists(Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), SnippetsDirectory))) {
                Directory.CreateDirectory(Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), SnippetsDirectory));
            }
            if(!Directory.Exists(Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), ContentTemplatesDirectory))) {
                Directory.CreateDirectory(Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), ContentTemplatesDirectory));
            }
            if(!Directory.Exists(Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), DraftsDirectory))) {
                Directory.CreateDirectory(Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), DraftsDirectory));
            }

            bool upgradeNeeded = false;

            if(!File.Exists(GetFullPath(NamespacesFile))) {
                File.Create(GetFullPath(NamespacesFile)).Close();
            }

            upgradeNeeded = VerifyIfPagesFileNeedsAnUpgrade();

            if(!File.Exists(GetFullPath(PagesFile))) {
                File.Create(GetFullPath(PagesFile)).Close();
            }
            else if(upgradeNeeded) {
                VerifyAndPerformUpgradeForPages();
            }

            if(!File.Exists(GetFullPath(CategoriesFile))) {
                File.Create(GetFullPath(CategoriesFile)).Close();
            }
            else if(upgradeNeeded) {
                VerifyAndPerformUpgradeForCategories();
            }

            if(!File.Exists(GetFullPath(NavigationPathsFile))) {
                File.Create(GetFullPath(NavigationPathsFile)).Close();
            }
            else if(upgradeNeeded) {
                VerifyAndPerformUpgradeForNavigationPaths();
            }

            // Prepare search index
            index = new StandardIndex();
            index.SetBuildDocumentDelegate(BuildDocumentHandler);
            indexStorer = new IndexStorer(GetFullPath(IndexDocumentsFile),
                GetFullPath(IndexWordsFile),
                GetFullPath(IndexMappingsFile),
                index);
            indexStorer.LoadIndex();

            if(indexStorer.DataCorrupted) {
                host.LogEntry("Search Engine Index is corrupted and needs to be rebuilt\r\n" +
                    indexStorer.ReasonForDataCorruption.ToString(),	LogEntryType.Warning, null, this);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes the Storage Provider.
        /// </summary>
        /// <param name="host">The Host of the Component.</param>
        /// <param name="config">The Configuration data, if any.</param>
        /// <exception cref="ArgumentNullException">If <b>host</b> or <b>config</b> are <c>null</c>.</exception>
        /// <exception cref="InvalidConfigurationException">If <b>config</b> is not valid or is incorrect.</exception>
        public void Init(IHostV30 host, string config)
        {
            if(host == null) throw new ArgumentNullException("host");
            if(config == null) throw new ArgumentNullException("config");

            _host = host;

            int s = int.Parse(host.GetSettingValue(SettingName.CacheSize));

            // Initialize pseudo cache
            _pseudoCache = new Dictionary<string, string>(10);

            // Initialize page content cache
            _pageContentCache = new Dictionary<PageInfo, PageContent>(s);
            _pageCacheUsage = new Dictionary<PageInfo, int>(s);

            // Initialize formatted page content cache
            _formattedContentCache = new Dictionary<PageInfo, string>(s);

            _sessions = new List<EditingSession>(50);

            _redirections = new Dictionary<string, string>(50);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Gets the data directory.
 /// </summary>
 /// <param name="host">The host object.</param>
 /// <returns>The data directory.</returns>
 protected string GetDataDirectory(IHostV30 host)
 {
     return host.GetSettingValue(SettingName.PublicDirectory);
 }
 /// <summary>
 /// Initializes the Storage Provider.
 /// </summary>
 /// <param name="host">The Host of the Component.</param>
 /// <param name="config">The Configuration data, if any.</param>
 /// <remarks>If the configuration string is not valid, the methoud should throw a <see cref="InvalidConfigurationException"/>.</remarks>
 public void Init(IHostV30 host, string config)
 {
     this.host = host;
     this.config = config != null ? config : "";
     defaultLanguage = host.GetSettingValue(SettingName.DefaultLanguage);
     displayWarning = config.ToLowerInvariant().Equals("display warning");
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes the Provider.
        /// </summary>
        /// <param name="host">The Host of the Provider.</param>
        /// <param name="config">The Configuration data, if any.</param>
        /// <exception cref="ArgumentNullException">If <b>host</b> or <b>config</b> are <c>null</c>.</exception>
        /// <exception cref="InvalidConfigurationException">If <b>config</b> is not valid or is incorrect.</exception>
        public void Init(IHostV30 host, string config)
        {
            if(host == null) throw new ArgumentNullException("host");
            if(config == null) throw new ArgumentNullException("config");

            this.host = host;

            if(!LocalProvidersTools.CheckWritePermissions(host.GetSettingValue(SettingName.PublicDirectory))) {
                throw new InvalidConfigurationException("Cannot write into the public directory - check permissions");
            }

            if(!File.Exists(GetFullPath(UsersFile))) {
                File.Create(GetFullPath(UsersFile)).Close();
            }
            if(!File.Exists(GetFullPath(UsersDataFile))) {
                File.Create(GetFullPath(UsersDataFile)).Close();
            }
            if(!File.Exists(GetFullPath(GroupsFile))) {
                File.Create(GetFullPath(GroupsFile)).Close();
            }

            VerifyAndPerformUpgrade();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Initializes the Storage Provider.
        /// </summary>
        /// <param name="host">The Host of the Component.</param>
        /// <param name="config">The Configuration data, if any.</param>
        /// <exception cref="ArgumentNullException">If <paramref name="host"/> or <paramref name="config"/> are <c>null</c>.</exception>
        /// <exception cref="InvalidConfigurationException">If <paramref name="config"/> is not valid or is incorrect.</exception>
        public void Init(IHostV30 host, string config)
        {
            if(host == null) throw new ArgumentNullException("host");
            if(config == null) throw new ArgumentNullException("config");

            this.host = host;

            if(!LocalProvidersTools.CheckWritePermissions(host.GetSettingValue(SettingName.PublicDirectory))) {
                throw new InvalidConfigurationException("Cannot write into the public directory - check permissions");
            }

            // Create directories, if needed
            if(!Directory.Exists(GetFullPath(UploadDirectory))) {
                Directory.CreateDirectory(GetFullPath(UploadDirectory));
            }
            if(!Directory.Exists(GetFullPath(AttachmentsDirectory))) {
                Directory.CreateDirectory(GetFullPath(AttachmentsDirectory));
            }
            if(!File.Exists(GetFullPath(FileDownloadsFile))) {
                File.Create(GetFullPath(FileDownloadsFile)).Close();
            }
            if(!File.Exists(GetFullPath(AttachmentDownloadsFile))) {
                File.Create(GetFullPath(AttachmentDownloadsFile)).Close();
            }
        }