コード例 #1
0
ファイル: editContent.aspx.cs プロジェクト: elrute/Triphulcas
        override protected void OnInit(EventArgs e)
        {
            base.OnInit(e);

            //validate!
            int id;
            if (!int.TryParse(Request.QueryString["id"], out id))
            {
                //if this is invalid show an error
                this.DisplayFatalError("Invalid query string");
                return;
            }
            m_ContentId = id;


            this.UnPublish.Click += new System.EventHandler(this.UnPublishDo);

            //_document = new cms.businesslogic.web.Document(int.Parse(Request.QueryString["id"]));
            _document = new Document(true, id);

            //check if the doc exists
            if (string.IsNullOrEmpty(_document.Path))
            {
                //if this is invalid show an error
                this.DisplayFatalError("No document found with id " + m_ContentId);
                //reset the content id to null so processing doesn't continue on OnLoad
                m_ContentId = null;
                return;
            }

            // we need to check if there's a published version of this document
            _documentHasPublishedVersion = _document.HasPublishedVersion();

            // Check publishing permissions
            if (!base.getUser().GetPermissions(_document.Path).Contains(ActionPublish.Instance.Letter.ToString()))
                _canPublish = controls.ContentControl.publishModes.SendToPublish;
            cControl = new controls.ContentControl(_document, _canPublish, "TabView1");

            cControl.ID = "TabView1";

            cControl.Width = Unit.Pixel(666);
            cControl.Height = Unit.Pixel(666);

            // Add preview button

            foreach (uicontrols.TabPage tp in cControl.GetPanels())
            {
                addPreviewButton(tp.Menu, _document.Id);
            }

            plc.Controls.Add(cControl);


            System.Web.UI.WebControls.PlaceHolder publishStatus = new PlaceHolder();
            if (_documentHasPublishedVersion)
            {
                littPublishStatus.Text = ui.Text("content", "lastPublished", base.getUser()) + ": " + _document.VersionDate.ToShortDateString() + "   ";

                publishStatus.Controls.Add(littPublishStatus);
                if (base.getUser().GetPermissions(_document.Path).IndexOf("U") > -1)
                    UnPublish.Visible = true;
                else
                    UnPublish.Visible = false;
            }
            else
            {
                littPublishStatus.Text = ui.Text("content", "itemNotPublished", base.getUser());
                publishStatus.Controls.Add(littPublishStatus);
                UnPublish.Visible = false;
            }

            UnPublish.Text = ui.Text("content", "unPublish", base.getUser());
            UnPublish.ID = "UnPublishButton";
            UnPublish.Attributes.Add("onClick", "if (!confirm('" + ui.Text("defaultdialogs", "confirmSure", base.getUser()) + "')) return false; ");
            publishStatus.Controls.Add(UnPublish);

            publishProps.addProperty(ui.Text("content", "publishStatus", base.getUser()), publishStatus);

            // Template
            PlaceHolder template = new PlaceHolder();
            cms.businesslogic.web.DocumentType DocumentType = new cms.businesslogic.web.DocumentType(_document.ContentType.Id);
            cControl.PropertiesPane.addProperty(ui.Text("documentType"), new LiteralControl(DocumentType.Text));


            //template picker
            cControl.PropertiesPane.addProperty(ui.Text("template"), template);
            int defaultTemplate;
            if (_document.Template != 0)
                defaultTemplate = _document.Template;
            else
                defaultTemplate = DocumentType.DefaultTemplate;

            if (this.getUser().UserType.Name == "writer")
            {
                if (defaultTemplate != 0)
                    template.Controls.Add(new LiteralControl(cms.businesslogic.template.Template.GetTemplate(defaultTemplate).Text));
                else
                    template.Controls.Add(new LiteralControl(ui.Text("content", "noDefaultTemplate")));
            }
            else
            {
                ddlDefaultTemplate.Items.Add(new ListItem(ui.Text("choose") + "...", ""));
                foreach (cms.businesslogic.template.Template t in DocumentType.allowedTemplates)
                {

                    ListItem tTemp = new ListItem(t.Text, t.Id.ToString());
                    if (t.Id == defaultTemplate)
                        tTemp.Selected = true;
                    ddlDefaultTemplate.Items.Add(tTemp);
                }
                template.Controls.Add(ddlDefaultTemplate);
            }


            // Editable update date, release date and expire date added by NH 13.12.04
            dp.ID = "updateDate";
            dp.Text = _document.UpdateDate.ToShortDateString() + " " + _document.UpdateDate.ToShortTimeString();
            publishProps.addProperty(ui.Text("content", "updateDate", base.getUser()), dp);

            dpRelease.ID = "releaseDate";
            dpRelease.DateTime = _document.ReleaseDate;
            dpRelease.ShowTime = true;
            publishProps.addProperty(ui.Text("content", "releaseDate", base.getUser()), dpRelease);

            dpExpire.ID = "expireDate";
            dpExpire.DateTime = _document.ExpireDate;
            dpExpire.ShowTime = true;
            publishProps.addProperty(ui.Text("content", "expireDate", base.getUser()), dpExpire);

            cControl.Save += new System.EventHandler(Save);
            cControl.SaveAndPublish += new System.EventHandler(Publish);
            cControl.SaveToPublish += new System.EventHandler(SendToPublish);

            // Add panes to property page...
            cControl.tpProp.Controls.AddAt(1, publishProps);
            cControl.tpProp.Controls.AddAt(2, linkProps);

            // add preview to properties pane too
            addPreviewButton(cControl.tpProp.Menu, _document.Id);


        }
コード例 #2
0
        override protected void OnInit(EventArgs e)
        {
            base.OnInit(e);

            //validate!
            int id;

            if (!int.TryParse(Request.QueryString["id"], out id))
            {
                //if this is invalid show an error
                this.DisplayFatalError("Invalid query string");
                return;
            }
            m_ContentId = id;


            this.UnPublish.Click += new System.EventHandler(this.UnPublishDo);

            //_document = new cms.businesslogic.web.Document(int.Parse(Request.QueryString["id"]));
            _document = new Document(true, id);

            //check if the doc exists
            if (string.IsNullOrEmpty(_document.Path))
            {
                //if this is invalid show an error
                this.DisplayFatalError("No document found with id " + m_ContentId);
                //reset the content id to null so processing doesn't continue on OnLoad
                m_ContentId = null;
                return;
            }

            // we need to check if there's a published version of this document
            _documentHasPublishedVersion = _document.HasPublishedVersion();

            // Check publishing permissions
            if (!base.getUser().GetPermissions(_document.Path).Contains(ActionPublish.Instance.Letter.ToString()))
            {
                _canPublish = controls.ContentControl.publishModes.SendToPublish;
            }
            cControl = new controls.ContentControl(_document, _canPublish, "TabView1");

            cControl.ID = "TabView1";

            cControl.Width  = Unit.Pixel(666);
            cControl.Height = Unit.Pixel(666);

            // Add preview button

            foreach (uicontrols.TabPage tp in cControl.GetPanels())
            {
                addPreviewButton(tp.Menu, _document.Id);
            }

            plc.Controls.Add(cControl);


            System.Web.UI.WebControls.PlaceHolder publishStatus = new PlaceHolder();
            if (_documentHasPublishedVersion)
            {
                littPublishStatus.Text = ui.Text("content", "lastPublished", base.getUser()) + ": " + _document.VersionDate.ToShortDateString() + "   ";

                publishStatus.Controls.Add(littPublishStatus);
                if (base.getUser().GetPermissions(_document.Path).IndexOf("U") > -1)
                {
                    UnPublish.Visible = true;
                }
                else
                {
                    UnPublish.Visible = false;
                }
            }
            else
            {
                littPublishStatus.Text = ui.Text("content", "itemNotPublished", base.getUser());
                publishStatus.Controls.Add(littPublishStatus);
                UnPublish.Visible = false;
            }

            UnPublish.Text = ui.Text("content", "unPublish", base.getUser());
            UnPublish.ID   = "UnPublishButton";
            UnPublish.Attributes.Add("onClick", "if (!confirm('" + ui.Text("defaultdialogs", "confirmSure", base.getUser()) + "')) return false; ");
            publishStatus.Controls.Add(UnPublish);

            publishProps.addProperty(ui.Text("content", "publishStatus", base.getUser()), publishStatus);

            // Template
            PlaceHolder template = new PlaceHolder();

            cms.businesslogic.web.DocumentType DocumentType = new cms.businesslogic.web.DocumentType(_document.ContentType.Id);
            cControl.PropertiesPane.addProperty(ui.Text("documentType"), new LiteralControl(DocumentType.Text));



            //template picker
            cControl.PropertiesPane.addProperty(ui.Text("template"), template);
            int defaultTemplate;

            if (_document.Template != 0)
            {
                defaultTemplate = _document.Template;
            }
            else
            {
                defaultTemplate = DocumentType.DefaultTemplate;
            }

            if (this.getUser().UserType.Name == "writer")
            {
                if (defaultTemplate != 0)
                {
                    template.Controls.Add(new LiteralControl(cms.businesslogic.template.Template.GetTemplate(defaultTemplate).Text));
                }
                else
                {
                    template.Controls.Add(new LiteralControl(ui.Text("content", "noDefaultTemplate")));
                }
            }
            else
            {
                ddlDefaultTemplate.Items.Add(new ListItem(ui.Text("choose") + "...", ""));
                foreach (cms.businesslogic.template.Template t in DocumentType.allowedTemplates)
                {
                    ListItem tTemp = new ListItem(t.Text, t.Id.ToString());
                    if (t.Id == defaultTemplate)
                    {
                        tTemp.Selected = true;
                    }
                    ddlDefaultTemplate.Items.Add(tTemp);
                }
                template.Controls.Add(ddlDefaultTemplate);
            }


            // Editable update date, release date and expire date added by NH 13.12.04
            dp.ID   = "updateDate";
            dp.Text = _document.UpdateDate.ToShortDateString() + " " + _document.UpdateDate.ToShortTimeString();
            publishProps.addProperty(ui.Text("content", "updateDate", base.getUser()), dp);

            dpRelease.ID       = "releaseDate";
            dpRelease.DateTime = _document.ReleaseDate;
            dpRelease.ShowTime = true;
            publishProps.addProperty(ui.Text("content", "releaseDate", base.getUser()), dpRelease);

            dpExpire.ID       = "expireDate";
            dpExpire.DateTime = _document.ExpireDate;
            dpExpire.ShowTime = true;
            publishProps.addProperty(ui.Text("content", "expireDate", base.getUser()), dpExpire);

            // url's
            updateLinks();
            linkProps.addProperty(ui.Text("content", "urls", base.getUser()), l);

            if (domainText.Text != "")
            {
                linkProps.addProperty(ui.Text("content", "alternativeUrls", base.getUser()), domainText);
            }

            cControl.Save           += new System.EventHandler(Save);
            cControl.SaveAndPublish += new System.EventHandler(Publish);
            cControl.SaveToPublish  += new System.EventHandler(SendToPublish);

            // Add panes to property page...
            cControl.tpProp.Controls.AddAt(1, publishProps);
            cControl.tpProp.Controls.AddAt(2, linkProps);

            // add preview to properties pane too
            addPreviewButton(cControl.tpProp.Menu, _document.Id);
        }
コード例 #3
0
        override protected void OnInit(EventArgs e)
        {
            base.OnInit(e);

            //validate!
            int id;
            if (int.TryParse(Request.QueryString["id"], out id) == false)
            {
                //if this is invalid show an error
                this.DisplayFatalError("Invalid query string");
                return;
            }
            _contentId = id;


            _unPublish.Click += UnPublishDo;

            //Loading Content via new public service to ensure that the Properties are loaded correct
            var content = ApplicationContext.Current.Services.ContentService.GetById(id);
            _document = new Document(content);

            //check if the doc exists
            if (string.IsNullOrEmpty(_document.Path))
            {
                //if this is invalid show an error
                this.DisplayFatalError("No document found with id " + _contentId);
                //reset the content id to null so processing doesn't continue on OnLoad
                _contentId = null;
                return;
            }

            // we need to check if there's a published version of this document
            _documentHasPublishedVersion = _document.Content.HasPublishedVersion();

            // Check publishing permissions
            if (!UmbracoUser.GetPermissions(_document.Path).Contains(ActionPublish.Instance.Letter.ToString()))
            {
                // Check to see if the user has send to publish permissions
                if (!UmbracoUser.GetPermissions(_document.Path).Contains(ActionToPublish.Instance.Letter.ToString()))
                {
                    //If no send to publish permission then revert to NoPublish mode
                    _canPublish = controls.ContentControl.publishModes.NoPublish;
                }
                else
                {
                    _canPublish = controls.ContentControl.publishModes.SendToPublish;
                }
            }

            _cControl = new controls.ContentControl(_document, _canPublish, "TabView1");

            _cControl.ID = "TabView1";

            _cControl.Width = Unit.Pixel(666);
            _cControl.Height = Unit.Pixel(666);

            // Add preview button

            foreach (uicontrols.TabPage tp in _cControl.GetPanels())
            {
                AddPreviewButton(tp.Menu, _document.Id);
            }

            plc.Controls.Add(_cControl);


            var publishStatus = new PlaceHolder();
            if (_documentHasPublishedVersion)
            {
                _littPublishStatus.Text = ui.Text("content", "lastPublished", UmbracoUser) + ": " + _document.VersionDate.ToShortDateString() + "   ";

                publishStatus.Controls.Add(_littPublishStatus);
                if (UmbracoUser.GetPermissions(_document.Path).IndexOf("U") > -1)
                    _unPublish.Visible = true;
                else
                    _unPublish.Visible = false;
            }
            else
            {
                _littPublishStatus.Text = ui.Text("content", "itemNotPublished", UmbracoUser);
                publishStatus.Controls.Add(_littPublishStatus);
                _unPublish.Visible = false;
            }

            _unPublish.Text = ui.Text("content", "unPublish", UmbracoUser);
            _unPublish.ID = "UnPublishButton";
            _unPublish.Attributes.Add("onClick", "if (!confirm('" + ui.Text("defaultdialogs", "confirmSure", UmbracoUser) + "')) return false; ");
            publishStatus.Controls.Add(_unPublish);

            _publishProps.addProperty(ui.Text("content", "publishStatus", UmbracoUser), publishStatus);

            // Template
            var template = new PlaceHolder();
            var documentType = new DocumentType(_document.ContentType.Id);
            _cControl.PropertiesPane.addProperty(ui.Text("documentType"), new LiteralControl(documentType.Text));


            //template picker
            _cControl.PropertiesPane.addProperty(ui.Text("template"), template);
            int defaultTemplate;
            if (_document.Template != 0)
                defaultTemplate = _document.Template;
            else
                defaultTemplate = documentType.DefaultTemplate;

            if (UmbracoUser.UserType.Name == "writer")
            {
                if (defaultTemplate != 0)
                    template.Controls.Add(new LiteralControl(businesslogic.template.Template.GetTemplate(defaultTemplate).Text));
                else
                    template.Controls.Add(new LiteralControl(ui.Text("content", "noDefaultTemplate")));
            }
            else
            {
                _ddlDefaultTemplate.Items.Add(new ListItem(ui.Text("choose") + "...", ""));
                foreach (var t in documentType.allowedTemplates)
                {

                    var tTemp = new ListItem(t.Text, t.Id.ToString());
                    if (t.Id == defaultTemplate)
                        tTemp.Selected = true;
                    _ddlDefaultTemplate.Items.Add(tTemp);
                }
                template.Controls.Add(_ddlDefaultTemplate);
            }


            // Editable update date, release date and expire date added by NH 13.12.04
            _dp.ID = "updateDate";
            _dp.Text = _document.UpdateDate.ToShortDateString() + " " + _document.UpdateDate.ToShortTimeString();
            _publishProps.addProperty(ui.Text("content", "updateDate", UmbracoUser), _dp);

            _dpRelease.ID = "releaseDate";
            _dpRelease.DateTime = _document.ReleaseDate;
            _dpRelease.ShowTime = true;
            _publishProps.addProperty(ui.Text("content", "releaseDate", UmbracoUser), _dpRelease);

            _dpExpire.ID = "expireDate";
            _dpExpire.DateTime = _document.ExpireDate;
            _dpExpire.ShowTime = true;
            _publishProps.addProperty(ui.Text("content", "expireDate", UmbracoUser), _dpExpire);

            _cControl.Save += Save;
            _cControl.SaveAndPublish += Publish;
            _cControl.SaveToPublish += SendToPublish;

            // Add panes to property page...
            _cControl.tpProp.Controls.AddAt(1, _publishProps);
            _cControl.tpProp.Controls.AddAt(2, _linkProps);

            // add preview to properties pane too
            AddPreviewButton(_cControl.tpProp.Menu, _document.Id);


        }
コード例 #4
0
        override protected void OnInit(EventArgs e)
        {
            base.OnInit(e);

            //validate!
            int id;

            if (int.TryParse(Request.QueryString["id"], out id) == false)
            {
                //if this is invalid show an error
                this.DisplayFatalError("Invalid query string");
                return;
            }
            _contentId = id;


            _unPublish.Click += UnPublishDo;

            //Loading Content via new public service to ensure that the Properties are loaded correct
            var content = ApplicationContext.Current.Services.ContentService.GetById(id);

            _document = new Document(content);

            //check if the doc exists
            if (string.IsNullOrEmpty(_document.Path))
            {
                //if this is invalid show an error
                this.DisplayFatalError("No document found with id " + _contentId);
                //reset the content id to null so processing doesn't continue on OnLoad
                _contentId = null;
                return;
            }

            // we need to check if there's a published version of this document
            _documentHasPublishedVersion = _document.Content.HasPublishedVersion();

            // Check publishing permissions
            if (!UmbracoUser.GetPermissions(_document.Path).Contains(ActionPublish.Instance.Letter.ToString()))
            {
                // Check to see if the user has send to publish permissions
                if (!UmbracoUser.GetPermissions(_document.Path).Contains(ActionToPublish.Instance.Letter.ToString()))
                {
                    //If no send to publish permission then revert to NoPublish mode
                    _canPublish = controls.ContentControl.publishModes.NoPublish;
                }
                else
                {
                    _canPublish = controls.ContentControl.publishModes.SendToPublish;
                }
            }

            _cControl = new controls.ContentControl(_document, _canPublish, "TabView1");

            _cControl.ID = "TabView1";

            _cControl.Width  = Unit.Pixel(666);
            _cControl.Height = Unit.Pixel(666);

            // Add preview button

            foreach (uicontrols.TabPage tp in _cControl.GetPanels())
            {
                AddPreviewButton(tp.Menu, _document.Id);
            }

            plc.Controls.Add(_cControl);


            var publishStatus = new PlaceHolder();

            if (_documentHasPublishedVersion)
            {
                _littPublishStatus.Text = ui.Text("content", "lastPublished", UmbracoUser) + ": " + _document.VersionDate.ToShortDateString() + "   ";

                publishStatus.Controls.Add(_littPublishStatus);
                if (UmbracoUser.GetPermissions(_document.Path).IndexOf("U") > -1)
                {
                    _unPublish.Visible = true;
                }
                else
                {
                    _unPublish.Visible = false;
                }
            }
            else
            {
                _littPublishStatus.Text = ui.Text("content", "itemNotPublished", UmbracoUser);
                publishStatus.Controls.Add(_littPublishStatus);
                _unPublish.Visible = false;
            }

            _unPublish.Text = ui.Text("content", "unPublish", UmbracoUser);
            _unPublish.ID   = "UnPublishButton";
            _unPublish.Attributes.Add("onClick", "if (!confirm('" + ui.Text("defaultdialogs", "confirmSure", UmbracoUser) + "')) return false; ");
            publishStatus.Controls.Add(_unPublish);

            _publishProps.addProperty(ui.Text("content", "publishStatus", UmbracoUser), publishStatus);

            // Template
            var template     = new PlaceHolder();
            var documentType = new DocumentType(_document.ContentType.Id);

            _cControl.PropertiesPane.addProperty(ui.Text("documentType"), new LiteralControl(documentType.Text));


            //template picker
            _cControl.PropertiesPane.addProperty(ui.Text("template"), template);
            int defaultTemplate;

            if (_document.Template != 0)
            {
                defaultTemplate = _document.Template;
            }
            else
            {
                defaultTemplate = documentType.DefaultTemplate;
            }

            if (UmbracoUser.UserType.Name == "writer")
            {
                if (defaultTemplate != 0)
                {
                    template.Controls.Add(new LiteralControl(businesslogic.template.Template.GetTemplate(defaultTemplate).Text));
                }
                else
                {
                    template.Controls.Add(new LiteralControl(ui.Text("content", "noDefaultTemplate")));
                }
            }
            else
            {
                _ddlDefaultTemplate.Items.Add(new ListItem(ui.Text("choose") + "...", ""));
                foreach (var t in documentType.allowedTemplates)
                {
                    var tTemp = new ListItem(t.Text, t.Id.ToString());
                    if (t.Id == defaultTemplate)
                    {
                        tTemp.Selected = true;
                    }
                    _ddlDefaultTemplate.Items.Add(tTemp);
                }
                template.Controls.Add(_ddlDefaultTemplate);
            }


            // Editable update date, release date and expire date added by NH 13.12.04
            _dp.ID   = "updateDate";
            _dp.Text = _document.UpdateDate.ToShortDateString() + " " + _document.UpdateDate.ToShortTimeString();
            _publishProps.addProperty(ui.Text("content", "updateDate", UmbracoUser), _dp);

            _dpRelease.ID       = "releaseDate";
            _dpRelease.DateTime = _document.ReleaseDate;
            _dpRelease.ShowTime = true;
            _publishProps.addProperty(ui.Text("content", "releaseDate", UmbracoUser), _dpRelease);

            _dpExpire.ID       = "expireDate";
            _dpExpire.DateTime = _document.ExpireDate;
            _dpExpire.ShowTime = true;
            _publishProps.addProperty(ui.Text("content", "expireDate", UmbracoUser), _dpExpire);

            _cControl.Save           += Save;
            _cControl.SaveAndPublish += Publish;
            _cControl.SaveToPublish  += SendToPublish;

            // Add panes to property page...
            _cControl.tpProp.Controls.AddAt(1, _publishProps);
            _cControl.tpProp.Controls.AddAt(2, _linkProps);

            // add preview to properties pane too
            AddPreviewButton(_cControl.tpProp.Menu, _document.Id);
        }