CmsGlobal.cs :  » Content-Management-Systems-CMS » Kooboo » Everest » CmsServices » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Content Management Systems CMS » Kooboo 
Kooboo » Everest » CmsServices » CmsGlobal.cs
/*
Kooboo is a content management system based on ASP.NET MVC framework. Copyright 2009 Yardi Technology Limited.

This program is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License version 3 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program.
If not, see http://www.kooboo.com/gpl3/.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Configuration;

using Everest.CmsServices.Services;
using Everest.Library.ExtensionMethod;
using System.Reflection;
namespace Everest.CmsServices{
    public enum BitWidth
    {
        Bit_32,
        Bit_64
    }
    public static class CmsGlobal
    {
        public readonly static string RootApplicationName = "root";
        public static string BaseDirPath
        {
            get
            {
                return AppDomain.CurrentDomain.BaseDirectory;
            }
        }
        private static object lockHelper = new object();

        /// <summary>
        /// Toes the resolve path.
        /// </summary>
        /// <param name="absolutePath">The absolute path.</param>
        /// <returns></returns>
        public static string ToRelativePath(string absolutePath)
        {
            return absolutePath.Replace(BaseDirPath, "");
        }
        /// <summary>
        /// Toes the absolute path.
        /// </summary>
        /// <param name="relativePath">The relative path.</param>
        /// <returns></returns>
        public static string ToAbsolutePath(string relativePath)
        {
            string dir = Path.Combine(BaseDirPath, relativePath);
            return dir;
        }
        /// <summary>
        /// Gets the sys temp path.
        /// </summary>
        /// <returns></returns>
        public static string TempPath
        {
            get
            {
                var tempPath = Path.Combine(BaseDirPath, "TEMP");
                if (!Directory.Exists(tempPath))
                {
                    Directory.CreateDirectory(tempPath);
                }
                //Environment.GetEnvironmentVariable("TEMP");
                //if (string.IsNullOrEmpty(sysTempPath))
                //{
                //    sysTempPath = Environment.GetEnvironmentVariable("TMP");
                //}
                //if (string.IsNullOrEmpty(sysTempPath))
                //{
                //    sysTempPath = Path.Combine(BaseDirPath, "TEMP");
                //}
                return tempPath;
            }
        }

        /// <summary>
        /// Gets the name of the application.
        /// </summary>
        /// <param name="appName">Name of the app.</param>
        /// <returns></returns>
        public static string GetApplicationName(string appName)
        {
            if (appName.Equals(CmsGlobal.RootApplicationName, StringComparison.OrdinalIgnoreCase))
            {
                return "Root";
            }
            return appName;
        }

        static CmsGlobal()
        {
            AdministratorUserName = ConfigurationManager.AppSettings["administratorName"];
            AdministratorEmail = ConfigurationManager.AppSettings["administratorEmail"];
            if (StringExtensions.IsNullOrEmptyTrim(AdministratorEmail))
            {
                AdministratorEmail = "everest@chinasoftware.eu";
            }
            var enableLog = ConfigurationManager.AppSettings["enableLog"];
            EnableLog = false;
            bool bEnabledLog;
            if (bool.TryParse(enableLog, out bEnabledLog))
                EnableLog = bEnabledLog;

            var radEditor = ConfigurationManager.AppSettings["enableRadEditor"];
            EnableRadEditor = StringExtensions.IsTrue(radEditor);

            var enabledTinymce = ConfigurationManager.AppSettings["enableTinymce"];
            EnableTinymce = StringExtensions.IsTrue(enabledTinymce);

            var enabledCKEditor = ConfigurationManager.AppSettings["enableCKEditor"];
            EnableCKEditor = StringExtensions.IsTrue(enabledCKEditor);

            EnableFCKEditor = StringExtensions.IsTrue(ConfigurationManager.AppSettings["enableFCKEditor"]);

            SiteTemplate = ConfigurationManager.AppSettings["siteTemplate"];

            string defaultPageNames = ConfigurationManager.AppSettings["defaultPageNames"];
            if (!StringExtensions.IsNullOrEmptyTrim(defaultPageNames))
            {
                DefaultPageNames = defaultPageNames.Split(',');
            }
            else
            {
                DefaultPageNames = new string[] { "default", "home", "index" };
            }

            PrefixControlId = ConfigurationManager.AppSettings["prefix_ControlId"];
            if (string.IsNullOrEmpty(PrefixControlId))
            {
                PrefixControlId = "mod_";
            }

            IndexDirectory = @"App_Data\ContentIndex";

            KoobooVersion = new AssemblyName(typeof(CmsGlobal).Assembly.FullName).Version.ToString();

            if (IntPtr.Size == 4)
            {
                RuntimeBitWidth = BitWidth.Bit_32;
            }
            else if (IntPtr.Size == 8)
            {
                RuntimeBitWidth = BitWidth.Bit_64;
            }
        }

        /// <summary>
        /// Gets or sets the name of the administrator user.
        /// </summary>
        /// <value>The name of the administrator user.</value>
        public static string AdministratorUserName
        {
            get;
            private set;
        }

        /// <summary>
        /// Gets or sets the administrator email.
        /// </summary>
        /// <value>The administrator email.</value>
        public static string AdministratorEmail
        {
            get;
            private set;
        }

        /// <summary>
        /// Gets or sets a value indicating whether [enable log].
        /// </summary>
        /// <value><c>true</c> if [enable log]; otherwise, <c>false</c>.</value>
        public static bool EnableLog { get; private set; }

        /// <summary>
        /// Gets or sets a value indicating whether [enable RAD editor].
        /// </summary>
        /// <value><c>true</c> if [enable RAD editor]; otherwise, <c>false</c>.</value>
        public static bool EnableRadEditor
        {
            get;
            private set;
        }
        /// <summary>
        /// Gets or sets a value indicating whether [enable tinymce].
        /// </summary>
        /// <value><c>true</c> if [enable tinymce]; otherwise, <c>false</c>.</value>
        public static bool EnableTinymce { get; private set; }

        /// <summary>
        /// Gets or sets a value indicating whether [enable CK editor].
        /// </summary>
        /// <value><c>true</c> if [enable CK editor]; otherwise, <c>false</c>.</value>
        public static bool EnableCKEditor { get; private set; }

        /// <summary>
        /// Gets a value indicating whether [enable CK finder].
        /// </summary>
        /// <value><c>true</c> if [enable CK finder]; otherwise, <c>false</c>.</value>
        public static bool EnableCKFinder
        {
            get
            {
                return Directory.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Kooboojs/ckfinder"));
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether [enable FCK editor].
        /// </summary>
        /// <value><c>true</c> if [enable FCK editor]; otherwise, <c>false</c>.</value>
        public static bool EnableFCKEditor { get; set; }

        /// <summary>
        /// Gets the visual design mode key.
        /// </summary>
        /// <value>The visual design mode key.</value>
        public static string VisualDesignModeKey
        {
            get
            {
                return "designerKey";
            }
        }

        /// <summary>
        /// Gets or sets the site template.
        /// </summary>
        /// <value>The site template.</value>
        public static string SiteTemplate { get; private set; }

        /// <summary>
        /// Gets the site template path.
        /// </summary>
        /// <value>The site template path.</value>
        public static string SiteTemplatePath
        {
            get
            {
                if (StringExtensions.IsNullOrEmptyTrim(SiteTemplate))
                {
                    return string.Empty;
                }
                return ToAbsolutePath(SiteTemplate);
            }
        }

        public static IEnumerable<string> DefaultPageNames { get; private set; }

        /// <summary>
        /// Gets or sets the index directory.
        /// </summary>
        /// <value>The index directory.</value>
        public static string IndexDirectory { get; private set; }

        /// <summary>
        /// Gets or sets the kooboo version.
        /// </summary>
        /// <value>The kooboo version.</value>
        public static string KoobooVersion { get; private set; }

        /// <summary>
        /// Gets the power by.
        /// </summary>
        /// <value>The power by.</value>
        public static string PowerBy
        {
            get
            {
                return string.Format("Kooboo CMS/{0} (http://www.kooboo.com)", CmsGlobal.KoobooVersion);
            }
        }

        /// <summary>
        /// Gets or sets the width of the runtime bit.
        /// </summary>
        /// <value>The width of the runtime bit.</value>
        public static BitWidth RuntimeBitWidth { get; private set; }

        /// <summary>
        /// Gets or sets the prefix control id.
        /// </summary>
        /// <value>The prefix control id.</value>
        public static string PrefixControlId { get; set; }
    }
}

www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.