コード例 #1
0
        public static IHtmlString EditItemAttributes(TextContent data)
        {
            var userName = Page_Context.Current.ControllerContext.HttpContext.User.Identity.Name;

            if (data == null || !Page_Context.Current.EnabledInlineEditing(EditingType.Content) ||
                !Kooboo.CMS.Content.Services.ServiceFactory.WorkflowManager.AvailableToEditContent(data, userName))
            {
                return(new HtmlString(""));
            }
            var availableToPublish = Kooboo.CMS.Content.Services.ServiceFactory.WorkflowManager.AvailableToPublish(data.GetFolder(), userName);

            return(new HtmlString(string.Format("editType=\"list\" schema=\"{0}\" folder=\"{1}\" title=\"{2}\" uuid=\"{3}\" published=\"{4}\" editUrl=\"{5}\" summary=\"{6}\" publishAvailable=\"{7}\"",
                                                data.SchemaName, data.FolderName, data.GetFolder().AsActual().FriendlyText, data.UUID, data.Published
                                                , Page_Context.Current.Url.Action("InlineEdit", new
            {
                controller = "TextContent",
                Area = "Contents",
                RepositoryName = data.Repository,
                SiteName = Page_Context.Current.PageRequestContext.Site.FullName,
                FolderName = data.FolderName,
                UUID = data.UUID,
                Return = Page_Context.Current.ControllerContext.HttpContext.Request.RawUrl
            }), HttpUtility.HtmlAttributeEncode(data.GetSummary())
                                                , availableToPublish)));
        }
コード例 #2
0
        public static string GetTextContentDirectoryPath(this TextContent textContent)
        {
            var textFolder = textContent.GetFolder();

            return(UrlUtility.Combine(new string[] { textFolder.Repository.Name.ToLower(), TextContentFileDirectoryName }
                                      .Concat(textFolder.NamePaths)
                                      .Concat(new[] { textContent.UUID })
                                      .ToArray()));
        }
コード例 #3
0
        public static string GetTextContentDirectoryPath(this TextContent textContent)
        {
            var textFolder = textContent.GetFolder();

            return(UrlUtility.Combine(new string[] { StorageNamesEncoder.EncodeContainerName(textFolder.Repository.Name), TextContentFileDirectoryName }
                                      .Concat(textFolder.NamePaths.Select(it => StorageNamesEncoder.EncodeBlobName(it)))
                                      .Concat(new[] { StorageNamesEncoder.EncodeBlobName(textContent.UUID) })
                                      .ToArray()));
        }
コード例 #4
0
ファイル: TextContentQuery.cs プロジェクト: Epitomy/CMS
        public static TextContent Previous(this TextContent textContent)
        {
            var textFolder = textContent.GetFolder().AsActual();
            var orderField = "UtcCreationDate";
            var direction  = OrderDirection.Descending;

            if (textFolder.OrderSetting != null)
            {
                orderField = textFolder.OrderSetting.FieldName;
                direction  = textFolder.OrderSetting.Direction;
            }
            return(Previous(textContent, orderField, direction));
        }
コード例 #5
0
ファイル: TextContentQuery.cs プロジェクト: nguyenhuy2911/CMS
        public static TextContent Previous(this TextContent textContent)
        {
            var textFolder = textContent.GetFolder().AsActual();
            var orderField = "UtcCreationDate";
            var direction  = OrderDirection.Descending;

            if (textFolder.Sortable.HasValue && textFolder.Sortable.Value == true)
            {
                orderField = "Sequence";
                direction  = OrderDirection.Descending;
            }
            return(Previous(textContent, orderField, direction));
        }
コード例 #6
0
ファイル: WorkflowManager.cs プロジェクト: nguyenhuy2911/CMS
        public virtual bool AvailableToEditContent(TextContent content, string userName)
        {
            var repository = content.GetRepository().AsActual();
            var folder     = content.GetFolder();
            var available  = AvailableViewContent(folder, userName);

            if (available == true && repository.EnableWorkflow == true)
            {
                available = AvailableToPublish(folder, userName);
                if (!available)
                {
                    var workflowItem = GetPendWorkflowItemForContent(content.GetRepository(), content, userName);
                    available = workflowItem["_WorkflowItem_"] != null;
                }
            }
            return(available);
        }
コード例 #7
0
ファイル: TextContentQuery.cs プロジェクト: Epitomy/CMS
        public static TextContent Previous(this TextContent textContent, string orderField, OrderDirection direction)
        {
            var textFolder = textContent.GetFolder().AsActual();

            if (direction == OrderDirection.Ascending)
            {
                return(textFolder.CreateQuery()
                       .WhereEquals("ParentUUID", textContent.ParentUUID)
                       .WhereEquals("ParentFolder", textContent.ParentFolder)
                       .WhereLessThan(orderField, textContent[orderField]).OrderByDescending(orderField).FirstOrDefault());
            }
            else
            {
                return(textFolder.CreateQuery()
                       .WhereEquals("ParentUUID", textContent.ParentUUID)
                       .WhereEquals("ParentFolder", textContent.ParentFolder)
                       .WhereGreaterThan(orderField, textContent[orderField]).OrderBy(orderField).FirstOrDefault());
            }
        }
コード例 #8
0
ファイル: TextContentManager.cs プロジェクト: bootmarket/CMS
        public virtual ContentBase Copy(TextContent originalContent, TextFolder textFolder, bool keepStatus, bool keepUUID, NameValueCollection values)
        {
            textFolder = textFolder.AsActual();
            var repository    = textFolder.Repository;
            var schema        = new Schema(repository, textFolder.SchemaName);
            var copyedContent = new TextContent(originalContent);

            copyedContent.Id   = "";
            copyedContent.UUID = "";
            if (keepUUID)
            {
                copyedContent.UUID = originalContent.UUID;
            }
            copyedContent.UtcCreationDate    = DateTime.Now.ToUniversalTime();
            copyedContent.Repository         = textFolder.Repository.Name;
            copyedContent.FolderName         = textFolder.FullName;
            copyedContent.SchemaName         = textFolder.SchemaName;
            copyedContent.OriginalUUID       = originalContent.UUID;
            copyedContent.OriginalRepository = originalContent.Repository;
            copyedContent.OriginalFolder     = originalContent.FolderName;
            copyedContent.IsLocalized        = false;
            copyedContent.Sequence           = 0;
            copyedContent.UserId             = originalContent.UserId;

            var versions = Kooboo.CMS.Content.Versioning.VersionManager.AllVersionInfos(originalContent);

            if (versions.Count() > 0)
            {
                copyedContent.OriginalLastestVisitedVersionId = versions.Max(it => it.Version);
            }


            if (values != null)
            {
                originalContent = Binder.Bind(schema, copyedContent, values);
            }

            if (!keepStatus)
            {
                copyedContent.Published = false;
            }
            //如果没有Content event,那么在发送设置的“转发”功能就会失效。
            EventBus.Content.ContentEvent.Fire(ContentAction.PreAdd, copyedContent);


            TextContentProvider.Add(copyedContent);


            if (textFolder.Categories != null && textFolder.Categories.Count > 0)
            {
                var originalRepository = originalContent.GetRepository();
                var originalFolder     = originalContent.GetFolder().AsActual();
                var originalCategories = QueryCategories(originalRepository, originalFolder.FullName, originalContent.UUID);

                List <TextContent> categories = new List <TextContent>();

                foreach (var category in originalCategories)
                {
                    foreach (var originalCategoryContent in category.Contents)
                    {
                        foreach (var categoryFolder in textFolder.Categories)
                        {
                            var categoryContent = (new TextFolder(textFolder.Repository, categoryFolder.FolderName)).CreateQuery()
                                                  .WhereEquals("UUID", originalCategoryContent.UUID).FirstOrDefault();
                            if (categoryContent != null)
                            {
                                categories.Add(categoryContent);
                                break;
                            }
                        }
                    }
                }

                AddCategories(repository, copyedContent, categories.ToArray());
            }

            EventBus.Content.ContentEvent.Fire(ContentAction.Add, copyedContent);

            return(copyedContent);
        }