예제 #1
0
 public LinuxStorageRoot(LinuxStorageProvider storageProvider, string rootPath)
     : base(storageProvider)
 {
     RootPath = rootPath ?? throw new ArgumentNullException(nameof(rootPath));
     if (!RootPath.EndsWith("/"))
     {
         RootPath += "/";
     }
     Uri = new Uri($"file://{(RootPath == "/" ? RootPath : RootPath.TrimEnd('/'))}");
 }
예제 #2
0
    /// <summary>
    /// Reloads the data.
    /// </summary>
    /// <param name="forceReload">If true, the data is reloaded even when already loaded</param>
    public void ReloadData(bool forceReload)
    {
        if (!dataLoaded || forceReload)
        {
            drpWebpart.Items.Clear();

            if (DisplayNone)
            {
                drpWebpart.Items.Add(new ListItem(ResHelper.GetString("General.SelectNone"), ""));
            }

            // Do not retrieve webparts
            WhereCondition condition = new WhereCondition(WhereCondition);
            if (!ShowWebparts)
            {
                condition.WhereEquals("ObjectType", "webpartcategory");
            }

            if (!ShowInheritedWebparts)
            {
                condition.WhereNull("WebPartParentID");
            }

            if (!String.IsNullOrEmpty(RootPath))
            {
                string rootPath = RootPath.TrimEnd('/');
                condition.Where(new WhereCondition().WhereEquals("ObjectPath", rootPath).Or().WhereStartsWith("ObjectPath", rootPath + "/"));
            }

            ds = WebPartCategoryInfoProvider.GetCategoriesAndWebparts(condition.ToString(true), "DisplayName", 0, "ObjectID, DisplayName, ParentID, ObjectType");

            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                int counter = 0;

                // Make special collection for "tree mapping"
                Dictionary <int, SortedList <string, object[]> > categories = new Dictionary <int, SortedList <string, object[]> >();

                // Fill collection from dataset
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    int    parentId = ValidationHelper.GetInteger(dr["ParentID"], 0);
                    int    id       = ValidationHelper.GetInteger(dr["ObjectID"], 0);
                    string name     = ResHelper.LocalizeString(ValidationHelper.GetString(dr["DisplayName"], String.Empty));
                    string type     = ValidationHelper.GetString(dr["ObjectType"], String.Empty);

                    // Skip webpart, take only WebpartCategory
                    if (type == "webpart")
                    {
                        continue;
                    }

                    SortedList <string, object[]> list;
                    categories.TryGetValue(parentId, out list);

                    // Sub categories list not created yet
                    if (list == null)
                    {
                        list = new SortedList <string, object[]>();
                        categories.Add(parentId, list);
                    }

                    list.Add(name + "_" + counter, new object[] { id, name });

                    counter++;
                }

                // Start filling the dropdown from the root(parentId = 0)
                int level = 0;

                // Root is not shown, start indentation later
                if (!ShowRoot)
                {
                    level = -1;
                }

                AddSubCategories(categories, 0, level);
            }

            dataLoaded = true;
        }
    }
예제 #3
0
 /// <summary>
 /// 生成文件全路径
 /// </summary>
 /// <returns></returns>
 public static string BuildFullUrlPath(string datePath)
 {
     return(string.Format("{0}/{1}", RootPath.TrimEnd('/'), datePath.TrimStart('/')));
 }
예제 #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="supportMultiLang"></param>
 /// <param name="path"></param>
 /// <returns></returns>
 public string GetConfigPath(bool supportMultiLang, string path)
 {
     return(supportMultiLang ?
            string.Format("{0}/Languages/{1}/{2}", RootPath.TrimEnd('/', '\\'), ApplicationContext.LanguageCode, path.TrimStart('/', '\\')) :
            string.Format("{0}/{1}", RootPath.TrimEnd('/', '\\'), path.TrimStart('/', '\\')));
 }
    /// <summary>
    /// Initializes the category provider
    /// </summary>
    private void InitCategoryProvider()
    {
        // Create and set category provider
        UniTreeProvider categoryProvider = new UniTreeProvider();

        categoryProvider.DisplayNameColumn = "DisplayName";
        categoryProvider.IDColumn          = "ObjectID";
        categoryProvider.LevelColumn       = "ObjectLevel";
        categoryProvider.ParentIDColumn    = "ParentID";
        categoryProvider.PathColumn        = "ObjectPath";
        categoryProvider.ValueColumn       = "ObjectID";
        categoryProvider.ChildCountColumn  = "CompleteChildCount";
        categoryProvider.QueryName         = "cms.pagetemplatecategory.selectallview";
        categoryProvider.ObjectTypeColumn  = "ObjectType";
        categoryProvider.Columns           = "DisplayName, CodeName, ObjectID, ObjectLevel, ParentID, ObjectPath, CompleteChildCount, ObjectType, CategoryChildCount, CategoryImagePath, Parameter";
        categoryProvider.ImageColumn       = "CategoryImagePath";
        categoryProvider.ParameterColumn   = "Parameter";

        if (!SelectPageTemplates)
        {
            categoryProvider.WhereCondition   = "ObjectType = 'pagetemplatecategory'";
            categoryProvider.ChildCountColumn = "CategoryChildCount";
            categoryProvider.ObjectTypeColumn = "";
        }
        else
        {
            categoryProvider.OrderBy = "ObjectType DESC, DisplayName ASC";
        }

        // Do not show AdHoc category
        if (!ShowAdHocCategory)
        {
            categoryProvider.WhereCondition = SqlHelper.AddWhereCondition(categoryProvider.WhereCondition, "CodeName <> 'AdHoc' AND CodeName <> 'AdHocUI'");
        }

        // Do not show empty categories
        if (!ShowEmptyCategories)
        {
            categoryProvider.WhereCondition = SqlHelper.AddWhereCondition(categoryProvider.WhereCondition, "CategoryTemplateChildCount > 0 OR CategoryChildCount > 0");

            TreeProvider tp = new TreeProvider(MembershipContext.AuthenticatedUser);
            CMS.DocumentEngine.TreeNode node = DocumentHelper.GetDocument(DocumentID, tp);
            string culture = LocalizationContext.PreferredCultureCode;
            int    level   = 0;
            string path    = string.Empty;

            string className = String.Empty;

            if (node != null)
            {
                level = node.NodeLevel;
                path  = node.NodeAliasPath;
                if (IsNewPage)
                {
                    level++;
                    path = path + "/%";
                }
                else
                {
                    culture = node.DocumentCulture;
                }

                className = node.NodeClassName;

                // Check if class id is in query string - then use it's value instead of document class name
                int classID = QueryHelper.GetInteger("classid", 0);
                if (classID != 0)
                {
                    DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(classID);
                    if (dci != null)
                    {
                        className = dci.ClassName;
                    }
                }
            }

            // Add where condition for scopes
            categoryProvider.WhereCondition += " AND (ObjectLevel = 0 OR (SELECT TOP 1 ObjectID FROM View_CMS_PageTemplateCategoryPageTemplate_Joined AS X WHERE X.ObjectType = 'pagetemplate' ";

            categoryProvider.WhereCondition += " AND (X.PageTemplateType IS NULL OR X.PageTemplateType <> N'" + PageTemplateInfoProvider.GetPageTemplateTypeCode(PageTemplateTypeEnum.Dashboard) + "')";


            if (ShowOnlySiteTemplates)
            {
                categoryProvider.WhereCondition += " AND X.ObjectID IN (SELECT PageTemplateID FROM CMS_PageTemplateSite WHERE SiteID = " + SiteContext.CurrentSiteID + ") ";
            }

            if (node != null)
            {
                categoryProvider.WhereCondition += " AND (" + PageTemplateScopeInfoProvider.GetScopeWhereCondition(path, culture, className, level, SiteContext.CurrentSiteName, "ObjectID") + ") ";
            }

            categoryProvider.WhereCondition += " AND (X.ObjectPath LIKE View_CMS_PageTemplateCategoryPageTemplate_Joined.ObjectPath + '/%')) IS NOT NULL)";

            // Add column count column - minimal number of children
            categoryProvider.Columns += @", (SELECT TOP 1 Count(*) FROM View_CMS_PageTemplateCategoryPageTemplate_Joined AS Y WHERE 
            (Y.ObjectID = View_CMS_PageTemplateCategoryPageTemplate_Joined.ObjectID AND Y.ObjectLevel = 0)
            OR ( View_CMS_PageTemplateCategoryPageTemplate_Joined.ObjectType = 'PageTemplateCategory' 
            AND View_CMS_PageTemplateCategoryPageTemplate_Joined.CategoryChildCount > 0 
            AND Y.ObjectType = 'PageTemplate' AND Y.ObjectLevel > View_CMS_PageTemplateCategoryPageTemplate_Joined.ObjectLevel + 1 ";

            if (ShowOnlySiteTemplates)
            {
                categoryProvider.Columns += "AND Y.ObjectID IN (SELECT PageTemplateID FROM CMS_PageTemplateSite WHERE SiteID = " + SiteContext.CurrentSiteID + ") ";
            }

            if (node != null)
            {
                categoryProvider.Columns += " AND ( " + PageTemplateScopeInfoProvider.GetScopeWhereCondition(path, culture, className, level, SiteContext.CurrentSiteName, "ObjectID") + " ) ";
            }

            categoryProvider.Columns         += " AND Y.ObjectPath LIKE  View_CMS_PageTemplateCategoryPageTemplate_Joined.ObjectPath + '/%')) AS MinNumberOfChilds";
            categoryProvider.ChildCountColumn = "MinNumberOfChilds";
        }

        // Handle the root path
        if (!String.IsNullOrEmpty(RootPath))
        {
            categoryProvider.RootLevelOffset = RootPath.TrimEnd('/').Split('/').Length - 1;

            categoryProvider.WhereCondition = SqlHelper.AddWhereCondition(categoryProvider.WhereCondition, String.Format("((ObjectPath = '{0}' OR ObjectPath LIKE '{0}/%'))", RootPath.TrimEnd('/')));
        }

        treeElem.ProviderObject = categoryProvider;
    }