예제 #1
0
        public ControllerInfo(Type controllerType, string url, RouteValueDictionary defaults)
        {
            this.Controller = controllerType;
            this.Name       = this.Controller.Name.UpTo("Controller");
            this.Url        = url.Replace("{controller}", this.Name);
            this.Actions    = controllerType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly)
                              .Where(m => m.ReturnType == typeof(ActionResult))
                              .Select(m => m.GetCustomAttributes(typeof(ActionNameAttribute), false)
                                      .OfType <ActionNameAttribute>()
                                      .Select(ana => ana.Name)
                                      .FirstOrDefault() ?? m.Name)
                              .Distinct()
                              .ToList();
            this.UrlPatterns = new List <UrlPattern> {
                new UrlPattern {
                    Url = url, Defaults = defaults
                }
            };
            this.Defaults = defaults.ToDictionary(rv => rv.Key, rv => (string)rv.Value);
            if (defaults.ContainsKey("action"))
            {
                this.DefaultAction = (string)defaults["action"];
            }
            IContentController cc = Activator.CreateInstance(this.Controller) as IContentController;

            this.SignificantRouteKeys = cc.SignificantRouteKeys;
            this.Content = cc.ContentType;
        }
예제 #2
0
        public override void FillFromExecutionResult(IExecutionResult result, IContentController contentController)
        {
            base.FillFromExecutionResult(result, contentController);

            Decimals         = 2;
            DecimalsOptional = true;
        }
예제 #3
0
        public ICollator Create(RouteData rd)
        {
            ControllerInfo     cInfo = SiteStructure.Current[rd.Values["controller"] as string];
            IContentController cc    = Activator.CreateInstance(cInfo.Controller) as IContentController;

            return(cc.GetCollator());
        }
예제 #4
0
 public override void DefineOptions(IExecutionResult result, IContentController contentController)
 {
     foreach (var p in result.QuestionParameters)
     {
         Options.Add(p.Name, contentController.GetText(
                         result.GetParameterSemanticKey(p.Name), FormElementContentType.Description, result.GetParameterSemanticKey(p.Name)));
     }
 }
예제 #5
0
        public void UpdateFromModel(IContentController contentController)
        {
            _contentController = contentController;

            TagManager.Instance.TagsChanged       += (s, args) => RefreshChildren();
            TagManager.Instance.CategoriesChanged += (s, args) => RefreshChildren();

            RefreshChildren();
        }
예제 #6
0
        public static IContentController GetContentController()
        {
            IContentController ctl = ComponentFactory.GetComponent <IContentController>();

            if (ctl == null)
            {
                ctl = new ContentController();
                ComponentFactory.RegisterComponentInstance <IContentController>(ctl);
            }
            return(ctl);
        }
예제 #7
0
 public override void DefineOptions(IExecutionResult result, IContentController contentController)
 {
     if (result?.QuestionFirstParameter?.Value == null)
     {
         return;
     }
     foreach (var item in result.QuestionFirstParameter.Value as IEnumerable <object> )
     {
         var itemString = item.ToString();
         Options.Add(itemString, itemString.Substring(0, 1).ToUpper() + itemString.Substring(1));
     }
 }
예제 #8
0
        private void Init()
        {
            foreach (var item in DisplayHelper.MonitorInfo())
            {
                _captureViews.Add(new CaptureView(item));
            }
            var controller = new BaseContentController();

            controller.SetContentView(this);
            this.contentController = controller;
            Clear();
        }
예제 #9
0
        public ContentViewModel(IContent content, IContentController contentController, IExplorer explorer = null) : base(content.Name)
        {
            Content            = content;
            _contentController = contentController;
            _explorer          = explorer;

            foreach (var menuItem in GetMenuItems())
            {
                ContextMenu.Items.Add(menuItem);
            }

            GetOrGenerateThumbnail();
        }
        public static void Init(IContentController <TChangeInfo> controller)
        {
            _controller = controller;

            foreach (var contentEditControl in _controller.ContentControls.OfType <IContentEditControl <TChangeInfo> >())
            {
                contentEditControl.ContentChanged += OnContentChanged;
            }

            _controller.ContentRibbon.Items.Clear();
            _controller.ContentRibbon.Items.AddRange(_controller.ContentControls.Select(c => c.TabPage).ToArray());

            ContentRibbonManager <TChangeInfo> .Init(_controller);
        }
예제 #11
0
 public WorkflowEngine()
 {
     _contentController                  = Util.GetContentController();
     _workflowRepository                 = WorkflowRepository.Instance;
     _workflowStateRepository            = WorkflowStateRepository.Instance;
     _workflowStatePermissionsRepository = WorkflowStatePermissionsRepository.Instance;
     _workflowLogRepository              = WorkflowLogRepository.Instance;
     _workflowActionManager              = WorkflowActionManager.Instance;
     _workflowSecurity        = WorkflowSecurity.Instance;
     _userController          = UserController.Instance;
     _notificationsController = NotificationsController.Instance;
     _workflowManager         = WorkflowManager.Instance;
     _workflowLogger          = WorkflowLogger.Instance;
     _systemWorkflowManager   = SystemWorkflowManager.Instance;
 }
예제 #12
0
        public static TagCategoryViewModel CreateForUncategorized(IContentController contentController, ITagRearranger tagRearranger)
        {
            var viewModel = new TagCategoryViewModel("Uncategorized")
            {
                _tagRearranger = tagRearranger
            };

            foreach (var tag in TagManager.Instance.UncategorizedTags)
            {
                viewModel._tags.Add(new TaggedViewModel(tag, contentController, tagRearranger));
            }

            viewModel.Children = new ReadOnlyCollection <TaggedViewModel>(viewModel._tags);

            return(viewModel);
        }
예제 #13
0
        /// <summary>
        /// Gets the meta data.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="contentItemId">The content item id.</param>
        /// <returns>meta data collection</returns>
        internal static NameValueCollection GetMetaData(this ContentItem item, int contentItemId)
        {
            IContentController ctl = Util.GetContentController();

            NameValueCollection _MetaData;

            if (contentItemId == Null.NullInteger)
            {
                _MetaData = new NameValueCollection();
            }
            else
            {
                _MetaData = ctl.GetMetaData(contentItemId);
            }

            return(_MetaData);
        }
        private static void CreateContentItem(DesktopModuleInfo desktopModule)
        {
            IContentTypeController typeController = new ContentTypeController();
            ContentType            contentType    = ContentType.DesktopModule;

            if (contentType == null)
            {
                contentType = new ContentType {
                    ContentType = "DesktopModule"
                };
                contentType.ContentTypeId = typeController.AddContentType(contentType);
            }

            IContentController contentController = Util.GetContentController();

            desktopModule.Content       = desktopModule.FriendlyName;
            desktopModule.Indexed       = false;
            desktopModule.ContentTypeId = contentType.ContentTypeId;
            desktopModule.ContentItemId = contentController.AddContentItem(desktopModule);
        }
예제 #15
0
        private static void CreateContentItem(DesktopModuleInfo desktopModule)
        {
            IContentTypeController typeController = new ContentTypeController();
            ContentType            contentType    = (from t in typeController.GetContentTypes()
                                                     where t.ContentType == "DesktopModule"
                                                     select t).SingleOrDefault();

            if (contentType == null)
            {
                contentType = new ContentType {
                    ContentType = "DesktopModule"
                };
                contentType.ContentTypeId = typeController.AddContentType(contentType);
            }

            IContentController contentController = Util.GetContentController();

            desktopModule.Content       = desktopModule.FriendlyName;
            desktopModule.Indexed       = false;
            desktopModule.ContentTypeId = contentType.ContentTypeId;
            desktopModule.ContentItemId = contentController.AddContentItem(desktopModule);
        }
예제 #16
0
        //private RelayCommand _dropCommand;

        public TaggedViewModel(ITag tag, IContentController contentController, ITagRearranger tagRearranger)
        {
            _tag = tag;
            _contentController = contentController;
            _tagRearranger     = tagRearranger;

            ContextMenu = new ContextMenu();
            ContextMenu.Items.Add(new MenuItem()
            {
                Header  = "Add " + Name,
                Command = CreateCommand
            });

            GetInfo();

            /*foreach (var video in _tag.Videos)
             * {
             *  _tagLeaves.Add(new TagVideoViewModel(video, _tag, _videoController, _playlistController, _tagRearranger));
             * }
             *
             * Children = new ReadOnlyCollection<TagVideoViewModel>(_tagLeaves);*/
        }
예제 #17
0
 public AttachmentController(IContentController contentController)
 {
     _contentController = contentController;
 }
예제 #18
0
 public override void FillDataFromResult(IExecutionResult result, IContentController contentController)
 {
     Data = new NumericFormElementData();
     Data.FillFromExecutionResult(result, contentController);
 }
 public static void Init(IContentController <TChangeInfo> controller)
 {
     _controller = controller;
     _controller.ContentRibbon.SelectedRibbonTabChanged += OnSelectedRibbonTabChanged;
 }
예제 #20
0
 public ContentImpl(IContentController contentController, IContentTypeController typeController)
 {
     _contentController = contentController;
     _typeController    = typeController;
 }
 public override void FillFromExecutionResult(IExecutionResult result, IContentController contentController)
 {
     base.FillFromExecutionResult(result, contentController);
     DefineOptions(result, contentController);
 }
예제 #22
0
        public static HtmlString RenderWidget(string placeHolderName)
        {
            StringBuilder sb                  = new StringBuilder();
            string        sWidgetZone         = String.Empty;
            string        masterWidgetWrapper = String.Empty;
            string        widgetMenuTemplate  = String.Empty;
            string        sStatusTemplate     = String.Empty;

            if (SecurityData.AdvancedEditMode)
            {
                widgetMenuTemplate  = "<li id=\"liMenu\"><a href=\"javascript:[[JS_CALL]]\" id=\"cmsMenuEditLink\" class=\"cmsWidgetBarLink cmsWidgetBarIconPencil\" alt=\"[[CAP]]\" title=\"[[CAP]]\"> [[CAP]]</a></li>";
                sWidgetZone         = ControlUtilities.GetManifestResourceStream("Carrotware.CMS.UI.Components._WidgetZone.cshtml");
                masterWidgetWrapper = ControlUtilities.GetManifestResourceStream("Carrotware.CMS.UI.Components._WidgetWrapper.cshtml");

                sWidgetZone         = sWidgetZone.Replace("[[PLACEHOLDER]]", placeHolderName);
                masterWidgetWrapper = masterWidgetWrapper.Replace("[[PLACEHOLDER]]", placeHolderName);
            }

            int iWidgetCount = 0;

            var widgetList = (from w in CmsPage.TheWidgets
                              where w.PlaceholderName.ToLowerInvariant() == placeHolderName.ToLowerInvariant()
                              orderby w.WidgetOrder, w.EditDate
                              select w).ToList();

            foreach (Widget widget in widgetList)
            {
                bool IsWidgetClass = false;

                string widgetKey = String.Format("WidgetId_{0}_{1}", placeHolderName, iWidgetCount);
                if (Html.ViewContext.Controller is IContentController)
                {
                    IContentController cc = (Html.ViewContext.Controller as IContentController);

                    widgetKey = String.Format("WidgetId_{0}", cc.WidgetCount);
                }

                iWidgetCount++;

                string widgetText    = String.Empty;
                string widgetWrapper = String.Empty;
                Dictionary <string, string> lstMenus = new Dictionary <string, string>();

                if (widget.ControlPath.Contains(":"))
                {
                    string[] path         = widget.ControlPath.Split(':');
                    string   objectPrefix = path[0];
                    string   objectClass  = path[1];
                    string   altView      = path.Length >= 3 ? path[2] : String.Empty;

                    Object obj      = null;
                    Object settings = null;

                    try {
                        Type objType = ReflectionUtilities.GetTypeFromString(objectClass);

                        obj = Activator.CreateInstance(objType);

                        if (objectPrefix.ToUpperInvariant() != "CLASS")
                        {
                            IsWidgetClass = false;
                            // assumed to be a controller action/method
                            Object attrib = ReflectionUtilities.GetAttribute <WidgetActionSettingModelAttribute>(objType, objectPrefix);

                            if (attrib != null && attrib is WidgetActionSettingModelAttribute)
                            {
                                string attrClass = (attrib as WidgetActionSettingModelAttribute).ClassName;
                                Type   s         = ReflectionUtilities.GetTypeFromString(attrClass);
                                settings = Activator.CreateInstance(s);
                            }
                        }
                        else
                        {
                            IsWidgetClass = true;
                            // a class widget is its own setting object
                            settings = obj;
                        }

                        if (settings != null)
                        {
                            if (settings is IWidget)
                            {
                                IWidget w = settings as IWidget;
                                w.SiteID            = CmsPage.TheSite.SiteID;
                                w.RootContentID     = widget.Root_ContentID;
                                w.PageWidgetID      = widget.Root_WidgetID;
                                w.IsDynamicInserted = true;
                                w.IsBeingEdited     = SecurityData.AdvancedEditMode;
                                w.WidgetClientID    = widgetKey;

                                List <WidgetProps> lstProp = widget.ParseDefaultControlProperties();
                                w.PublicParmValues = lstProp.ToDictionary(t => t.KeyName, t => t.KeyValue);

                                lstMenus = w.JSEditFunctions;

                                if (!lstMenus.Any() && w.EnableEdit)
                                {
                                    lstMenus.Add("Edit", "cmsGenericEdit('" + widget.Root_ContentID.ToString() + "','" + widget.Root_WidgetID.ToString() + "')");
                                }
                            }

                            if (settings is IWidgetView)
                            {
                                if (!String.IsNullOrEmpty(altView))
                                {
                                    (settings as IWidgetView).AlternateViewFile = altView;
                                }
                            }

                            if (settings is IWidgetRawData)
                            {
                                (settings as IWidgetRawData).RawWidgetData = widget.ControlProperties;
                            }
                        }

                        if (obj != null && settings != null && obj is IWidgetDataObject)
                        {
                            (obj as IWidgetDataObject).WidgetPayload = settings;
                        }

                        if (IsWidgetClass && obj is IHtmlString)
                        {
                            widgetText = (obj as IHtmlString).ToHtmlString();
                        }
                        else
                        {
                            widgetText = GetResultViewStringFromController(objectPrefix, objType, obj);
                        }
                    } catch (Exception ex) {
                        LiteralMessage msg = new LiteralMessage(ex, widgetKey, widget.ControlPath);
                        obj        = msg;
                        widgetText = msg.ToHtmlString();
                    }
                }

                widgetText = widgetText ?? String.Empty;

                if (!widget.ControlPath.Contains(":") && String.IsNullOrEmpty(widgetText))
                {
                    string[] path       = widget.ControlPath.Split('|');
                    string   viewPath   = path[0];
                    string   modelClass = String.Empty;
                    if (path.Length > 1)
                    {
                        modelClass = path[1];
                    }

                    try {
                        if (viewPath.EndsWith(".cshtml") || viewPath.EndsWith(".vbhtml"))
                        {
                            if (String.IsNullOrEmpty(modelClass))
                            {
                                widgetText = RenderPartialToString(viewPath);
                            }
                            else
                            {
                                Type objType = ReflectionUtilities.GetTypeFromString(modelClass);

                                Object model = Activator.CreateInstance(objType);

                                if (model is IWidgetRawData)
                                {
                                    (model as IWidgetRawData).RawWidgetData = widget.ControlProperties;
                                }

                                if (model is IWidget)
                                {
                                    IWidget w = model as IWidget;
                                    w.SiteID            = CmsPage.TheSite.SiteID;
                                    w.RootContentID     = widget.Root_ContentID;
                                    w.PageWidgetID      = widget.Root_WidgetID;
                                    w.IsDynamicInserted = true;
                                    w.IsBeingEdited     = SecurityData.AdvancedEditMode;
                                    w.WidgetClientID    = widgetKey;

                                    List <WidgetProps> lstProp = widget.ParseDefaultControlProperties();
                                    w.PublicParmValues = lstProp.ToDictionary(t => t.KeyName, t => t.KeyValue);

                                    lstMenus = w.JSEditFunctions;

                                    if (!lstMenus.Any() && w.EnableEdit)
                                    {
                                        lstMenus.Add("Edit", "cmsGenericEdit('" + widget.Root_ContentID.ToString() + "','" + widget.Root_WidgetID.ToString() + "')");
                                    }
                                }

                                widgetText = RenderPartialToString(viewPath, model);
                            }
                        }
                    } catch (Exception ex) {
                        LiteralMessage msg = new LiteralMessage(ex, widgetKey, widget.ControlPath);
                        widgetText = msg.ToHtmlString();
                    }
                }

                if (widgetText == null || widget.ControlPath.ToLowerInvariant().EndsWith(".ascx"))
                {
                    LiteralMessage msg = new LiteralMessage("The widget is not supported.", widgetKey, widget.ControlPath);
                    widgetText = msg.ToHtmlString();
                }

                widgetText = widgetText ?? String.Empty;

                if (SecurityData.AdvancedEditMode)
                {
                    if (widget.IsWidgetActive)
                    {
                        sStatusTemplate = "<a href=\"javascript:cmsRemoveWidgetLink('[[ITEM_ID]]');\" id=\"cmsContentRemoveLink\" class=\"cmsWidgetBarLink cmsWidgetBarIconCross\" alt=\"Remove\" title=\"Remove\">  Disable</a>";
                    }
                    else
                    {
                        sStatusTemplate = "<a href=\"javascript:cmsActivateWidgetLink('[[ITEM_ID]]');\" id=\"cmsActivateWidgetLink\" class=\"cmsWidgetBarLink cmsWidgetBarIconActive\" alt=\"Activate\" title=\"Activate\">  Enable</a>";
                    }

                    widgetWrapper = masterWidgetWrapper;
                    widgetWrapper = widgetWrapper.Replace("[[STATUS_LINK]]", sStatusTemplate);
                    widgetWrapper = widgetWrapper.Replace("[[WIDGET_PATH]]", widget.ControlPath);
                    widgetWrapper = widgetWrapper.Replace("[[sequence]]", widget.WidgetOrder.ToString());
                    widgetWrapper = widgetWrapper.Replace("[[ITEM_ID]]", widget.Root_WidgetID.ToString());

                    CMSPlugin plug = (from p in CmsPage.Plugins
                                      where p.FilePath.ToLowerInvariant() == widget.ControlPath.ToLowerInvariant()
                                      select p).FirstOrDefault();

                    string captionPrefix = String.Empty;

                    if (!widget.IsWidgetActive)
                    {
                        captionPrefix = String.Format("{0} {1}", CMSConfigHelper.InactivePagePrefix, captionPrefix);
                    }
                    if (widget.IsRetired)
                    {
                        captionPrefix = String.Format("{0} {1}", CMSConfigHelper.RetiredPagePrefix, captionPrefix);
                    }
                    if (widget.IsUnReleased)
                    {
                        captionPrefix = String.Format("{0} {1}", CMSConfigHelper.UnreleasedPagePrefix, captionPrefix);
                    }
                    if (widget.IsWidgetPendingDelete)
                    {
                        captionPrefix = String.Format("{0} {1}", CMSConfigHelper.PendingDeletePrefix, captionPrefix);
                    }

                    if (plug != null)
                    {
                        string sysControl = (plug.SystemPlugin ? "[CMS]" : String.Empty);
                        widgetWrapper = widgetWrapper.Replace("[[WIDGET_CAPTION]]", String.Format("{0}  {1}  {2}", captionPrefix, plug.Caption, sysControl).Trim());
                    }
                    else
                    {
                        widgetWrapper = widgetWrapper.Replace("[[WIDGET_CAPTION]]", String.Format("{0}  UNTITLED", captionPrefix).Trim());
                    }

                    StringBuilder sbMenu = new StringBuilder();
                    sbMenu.AppendLine();
                    if (lstMenus != null)
                    {
                        foreach (var d in lstMenus)
                        {
                            sbMenu.AppendLine(widgetMenuTemplate.Replace("[[JS_CALL]]", d.Value).Replace("[[CAP]]", d.Key));
                        }
                    }

                    widgetWrapper = widgetWrapper.Replace("[[MENU_ITEMS]]", sbMenu.ToString().Trim());
                    widgetWrapper = widgetWrapper.Replace("[[WIDGET_CAPTION]]", widget.ControlPath + captionPrefix);

                    widgetWrapper = widgetWrapper.Replace("[[CONTENT]]", widgetText);
                }
                else
                {
                    widgetWrapper = widgetText;
                }

                if (!String.IsNullOrEmpty(widgetWrapper))
                {
                    sb.AppendLine(widgetWrapper);
                }
            }

            string bodyText = String.Empty;

            if (SecurityData.AdvancedEditMode)
            {
                bodyText = sWidgetZone.Replace("[[CONTENT]]", sb.ToString());
            }
            else
            {
                bodyText = sb.ToString();
            }

            return(new HtmlString(bodyText));
        }
 public virtual void DefineOptions(IExecutionResult result, IContentController contentController)
 {
 }
예제 #24
0
 public AttachmentController(IContentController contentController)
 {
     _contentController = contentController;
 }
예제 #25
0
 public ContentFascade(IContentController contentController)
 {
     this.contentController = contentController;
 }