Example #1
0
        public bool Delete()
        {
            cms.businesslogic.media.Media d = new cms.businesslogic.media.Media(ParentID);

            // Log
            BasePages.UmbracoEnsuredPage bp = new BasePages.UmbracoEnsuredPage();
            BusinessLogic.Log.Add(BusinessLogic.LogTypes.Delete, bp.getUser(), d.Id, "");

            d.delete();
            return(true);
        }
Example #2
0
        public bool Delete()
        {
            cms.businesslogic.web.Document d = new cms.businesslogic.web.Document(ParentID);

            // Log
            BasePages.UmbracoEnsuredPage bp = new BasePages.UmbracoEnsuredPage();
            BusinessLogic.Log.Add(BusinessLogic.LogTypes.Delete, bp.getUser(), d.Id, "");

            library.UnPublishSingleNode(d.Id);

            d.delete();

            return true;
        }
Example #3
0
        public bool Delete()
        {
            cms.businesslogic.web.Document d = new cms.businesslogic.web.Document(ParentID);

            // Log
            BasePages.UmbracoEnsuredPage bp = new BasePages.UmbracoEnsuredPage();
            BusinessLogic.Log.Add(BusinessLogic.LogTypes.Delete, bp.getUser(), d.Id, "");

            library.UnPublishSingleNode(d.Id);

            d.delete();

            return(true);
        }
Example #4
0
        /// <summary>
        /// Constructor to set default properties.
        /// </summary>
        /// <param name="c"></param>
        /// <param name="CanPublish"></param>
        /// <param name="Id"></param>
        /// <remarks>
        /// This method used to create all of the child controls too which is BAD since
        /// the page hasn't started initializing yet. Control IDs were not being named
        /// correctly, etc... I've moved the child control setup/creation to the CreateChildControls
        /// method where they are suposed to be.
        /// </remarks>
        public ContentControl(Content c, publishModes CanPublish, string Id)
        {
            ID = Id;
            this.CanPublish = CanPublish;
            _content = c;

            Width = 350;
            Height = 350;

            SaveAndPublish += new EventHandler(standardSaveAndPublishHandler);
            Save += new EventHandler(standardSaveAndPublishHandler);
            prntpage = (UmbracoEnsuredPage)Page;

            // zb-00036 #29889 : load it only once
            if (virtualTabs == null)
                virtualTabs = _content.ContentType.getVirtualTabs.ToList();

            foreach (ContentType.TabI t in virtualTabs)
            {
                TabPage tp = NewTabPage(t.Caption);
                addSaveAndPublishButtons(ref tp);
            }
        }
 private User currentUser()
 {
     UmbracoEnsuredPage page = new UmbracoEnsuredPage();
     return page.getUser();
 }
        /// <summary>
        /// Create and setup all of the controls child controls.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            
            _prntpage = (UmbracoEnsuredPage)Page;
            int i = 0;
            Hashtable inTab = new Hashtable();

            // zb-00036 #29889 : load it only once
            if (_virtualTabs == null)
                _virtualTabs = _content.ContentType.getVirtualTabs.ToList();

            if(_contentType == null)
                _contentType = ContentType.GetContentType(_content.ContentType.Id);

            foreach (ContentType.TabI tab in _virtualTabs)
            {
                var tabPage = this.Panels[i] as TabPage;
                if (tabPage == null)
                {
                    throw new ArgumentException("Unable to load tab \"" + tab.Caption + "\"");
                }

                tabPage.Style.Add("text-align", "center");

                //Legacy vs New API loading of PropertyTypes
                if (_contentType.ContentTypeItem != null)
                {
                    LoadPropertyTypes(_contentType.ContentTypeItem, tabPage, inTab, tab.Id, tab.Caption);
                }
                else
                {
                    LoadPropertyTypes(tab, tabPage, inTab);
                }

                i++;
            }

            // Add property pane
            tpProp = NewTabPage(ui.Text("general", "properties", null));
            AddSaveAndPublishButtons(ref tpProp);
            tpProp.Controls.Add(
                new LiteralControl("<div id=\"errorPane_" + tpProp.ClientID +
                                   "\" style=\"display: none; text-align: left; color: red;width: 100%; border: 1px solid red; background-color: #FCDEDE\"><div><b>There were errors - data has not been saved!</b><br/></div></div>"));

            //if the property is not in a tab, add it to the general tab
            var props = _content.GenericProperties;
            foreach (Property p in props)
            {
                if (inTab[p.PropertyType.Id.ToString()] == null)
                    AddControlNew(p, tpProp, ui.Text("general", "properties", null));
            }

        }
Example #7
0
        /// <summary>
        /// Create and setup all of the controls child controls.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            SaveAndPublish += new EventHandler(standardSaveAndPublishHandler);
            Save += new EventHandler(standardSaveAndPublishHandler);
            prntpage = (UmbracoEnsuredPage)Page;
            int i = 0;
            var inTab = new Hashtable();

            // zb-00036 #29889 : load it only once
            if (virtualTabs == null)
                virtualTabs = _content.ContentType.getVirtualTabs.ToList();

            foreach (ContentType.TabI t in virtualTabs)
            {
                var tp = this.Panels[i] as TabPage;
                if (tp == null)
                {
                    throw new ArgumentException("Unable to load tab \"" + t.Caption + "\"");
                }
                //TabPage tp = NewTabPage(t.Caption);
                //addSaveAndPublishButtons(ref tp);

                tp.Style.Add("text-align", "center");

                // Iterate through the property types and add them to the tab
                // zb-00036 #29889 : fix property types getter to get the right set of properties
                foreach (PropertyType pt in t.GetPropertyTypes(_content.ContentType.Id))
                {
                    // table.Rows.Add(addControl(_content.getProperty(editPropertyType.Alias), tp));
                    addControlNew(_content.getProperty(pt), tp, t.Caption);
                    inTab.Add(pt.Id.ToString(), true);
                }

                i++;
            }

            // Add property pane
            tpProp = NewTabPage(ui.Text("general", "properties", null));
            addSaveAndPublishButtons(ref tpProp);
            tpProp.Controls.Add(
                new LiteralControl("<div id=\"errorPane_" + tpProp.ClientID +
                                   "\" style=\"display: none; text-align: left; color: red;width: 100%; border: 1px solid red; background-color: #FCDEDE\"><div><b>There were errors - data has not been saved!</b><br/></div></div>"));

            //if the property is not in a tab, add it to the general tab
            var props = _content.GenericProperties;
            foreach (Property p in props)
            {
                if (inTab[p.PropertyType.Id.ToString()] == null)
                    addControlNew(p, tpProp, ui.Text("general", "properties", null));
            }
        }
Example #8
0
        /// <summary>
        /// Initializes the control and looks up the tree structures that are required to be rendered.
        /// Properties of the control (or SetTreeService) need to be set before pre render or calling
        /// GetJSONContextMenu or GetJSONNode
        /// </summary>
        protected void Initialize()
        {
            //use the query strings if the TreeParams isn't explicitly set
            if (m_TreeService == null)
            {
                m_TreeService = TreeRequestParams.FromQueryStrings().CreateTreeService();
            }
            m_TreeService.App = GetCurrentApp();

            // Validate permissions
            if (!BasePages.BasePage.ValidateUserContextID(BasePages.BasePage.umbracoUserContextID))
                return;
            UmbracoEnsuredPage page = new UmbracoEnsuredPage();
            if (!page.ValidateUserApp(GetCurrentApp()))
                throw new ArgumentException("The current user doesn't have access to this application. Please contact the system administrator.");

            //find all tree definitions that have the current application alias that are ACTIVE.
            //if an explicit tree has been requested, then only load that tree in.
            m_ActiveTreeDefs = TreeDefinitionCollection.Instance.FindActiveTrees(GetCurrentApp());
            if (!string.IsNullOrEmpty(this.TreeType))
            {
                m_ActiveTreeDefs = m_ActiveTreeDefs
                    .Where(x => x.Tree.Alias == this.TreeType)
                    .ToList(); //this will only return 1
            }

            //find all tree defs that exists for the current application regardless of if they are active
            List<TreeDefinition> appTreeDefs = TreeDefinitionCollection.Instance.FindTrees(GetCurrentApp());

            //Create the BaseTree's based on the tree definitions found
            foreach (TreeDefinition treeDef in appTreeDefs)
            {
                //create the tree and initialize it
                BaseTree bTree = treeDef.CreateInstance();
                bTree.SetTreeParameters(m_TreeService);

                //store the created tree
                m_AllAppTrees.Add(bTree);
                if (treeDef.Tree.Initialize)
                    m_ActiveTrees.Add(bTree);
            }

            m_IsInit = true;
        }
        void Page_PreInit(Object sender, EventArgs e)
        {
            Trace.Write("umbracoInit", "handling request");

            if (UmbracoContext.Current == null)
            {
                UmbracoContext.Current = new UmbracoContext(HttpContext.Current);
            }

            bool editMode = UmbracoContext.Current.LiveEditingContext.Enabled;

            if (editMode)
            {
                ValidateRequest = false;
            }

            if (m_tmp != "" && Request["umbPageID"] == null)
            {
                // Check numeric
                string tryIntParse = m_tmp.Replace("/", "").Replace(".aspx", string.Empty);
                int    result;
                if (int.TryParse(tryIntParse, out result))
                {
                    m_tmp = m_tmp.Replace(".aspx", string.Empty);

                    // Check for request
                    if (!string.IsNullOrEmpty(Request["umbVersion"]))
                    {
                        // Security check
                        BasePages.UmbracoEnsuredPage bp = new BasePages.UmbracoEnsuredPage();
                        bp.ensureContext();
                        m_version = new Guid(Request["umbVersion"]);
                    }
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(Request["umbPageID"]))
                {
                    int result;
                    if (int.TryParse(Request["umbPageID"], out result))
                    {
                        m_tmp = Request["umbPageID"];
                    }
                }
            }

            if (m_version != Guid.Empty)
            {
                HttpContext.Current.Items["pageID"] = m_tmp.Replace("/", "");
                m_umbPage = new page(int.Parse(m_tmp.Replace("/", "")), m_version);
            }
            else
            {
                m_umbRequest = new requestHandler(UmbracoContext.Current.GetXml(), m_tmp);
                Trace.Write("umbracoInit", "Done handling request");
                if (m_umbRequest.currentPage != null)
                {
                    HttpContext.Current.Items["pageID"] = m_umbRequest.currentPage.Attributes.GetNamedItem("id").Value;

                    // Handle edit
                    if (editMode)
                    {
                        Document d = new Document(int.Parse(m_umbRequest.currentPage.Attributes.GetNamedItem("id").Value));
                        m_umbPage = new page(d.Id, d.Version);
                    }
                    else
                    {
                        m_umbPage = new page(m_umbRequest.currentPage);
                    }
                }
            }

            // set the friendly path so it's used by forms
            HttpContext.Current.RewritePath(HttpContext.Current.Items[requestModule.ORIGINAL_URL_CXT_KEY].ToString());

            if (UmbracoSettings.UseAspNetMasterPages)
            {
                HttpContext.Current.Trace.Write("umbracoPage", "Looking up skin information");

                if (m_umbPage != null)
                {
                    if (m_umbPage.Template == 0)
                    {
                        string custom404 = umbraco.library.GetCurrentNotFoundPageId();
                        if (!String.IsNullOrEmpty(custom404))
                        {
                            XmlNode xmlNodeNotFound = content.Instance.XmlContent.GetElementById(custom404);
                            if (xmlNodeNotFound != null)
                            {
                                m_umbPage = new page(xmlNodeNotFound);
                            }
                        }
                    }

                    if (m_umbPage.Template != 0)
                    {
                        this.MasterPageFile = template.GetMasterPageName(m_umbPage.Template);
                    }
                    else
                    {
                        GenerateNotFoundContent();
                        Response.End();
                    }
                }

                initUmbracoPage();
            }
        }
Example #10
0
        /// <summary>
        /// Whenever an action is performed upon a document/media/member, this method is executed, ensuring that 
        /// all registered handlers will have an oppotunity to handle the action.
        /// </summary>
        /// <param name="d">The document being operated on</param>
        /// <param name="action">The action triggered</param>
        public static void RunActionHandlers(Document d, IAction action)
        {
            foreach (IActionHandler ia in _actionHandlers)
            {
                try
                {
                    foreach (IAction a in ia.ReturnActions())
                    {
                        if (a.Alias == action.Alias)
                        {
                            // Uncommented for auto publish support
                            // System.Web.HttpContext.Current.Trace.Write("BusinessLogic.Action.RunActionHandlers", "Running " + ia.HandlerName() + " (matching action: " + a.Alias + ")");
                            ia.Execute(d, action);
                        }
                    }
                }
                catch (Exception iaExp)
                {
                    Log.Add(LogTypes.Error, User.GetUser(0), -1, string.Format("Error loading actionhandler '{0}': {1}",
                        ia.HandlerName(), iaExp));
                }
            }

            // Run notification
            // Find current user
            User u;
            try
            {
                u = new UmbracoEnsuredPage().getUser();
            }
            catch
            {
                u = User.GetUser(0);
            }
            Notification.GetNotifications(d, u, action);
        }
Example #11
0
        /// <summary>
        /// Create and setup all of the controls child controls.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            SaveAndPublish += new EventHandler(standardSaveAndPublishHandler);
            Save += new EventHandler(standardSaveAndPublishHandler);
            prntpage = (UmbracoEnsuredPage)Page;
            int i = 0;
            var inTab = new Hashtable();

            // zb-00036 #29889 : load it only once
            if (virtualTabs == null)
                virtualTabs = _content.ContentType.getVirtualTabs.ToList();

            foreach (ContentType.TabI tab in virtualTabs)
            {
                var tabPage = this.Panels[i] as TabPage;
                if (tabPage == null)
                {
                    throw new ArgumentException("Unable to load tab \"" + tab.Caption + "\"");
                }
                //TabPage tp = NewTabPage(t.Caption);
                //addSaveAndPublishButtons(ref tp);

                tabPage.Style.Add("text-align", "center");


                // Iterate through the property types and add them to the tab
                // zb-00036 #29889 : fix property types getter to get the right set of properties
                // ge : had a bit of a corrupt db and got weird NRE errors so rewrote this to catch the error and rethrow with detail
                foreach (PropertyType propertyType in tab.GetPropertyTypes(_content.ContentType.Id))
                {
                    // table.Rows.Add(addControl(_content.getProperty(editPropertyType.Alias), tp));
                    var property = _content.getProperty(propertyType);
                    if (property != null && tabPage != null)
                    {
                        addControlNew(property, tabPage, tab.Caption);

                        // adding this check, as we occasionally get an already in dictionary error, though not sure why
                        if (!inTab.ContainsKey(propertyType.Id.ToString()))
                            inTab.Add(propertyType.Id.ToString(), true);
                    }
                    else
                    {
                        throw new ArgumentNullException(string.Format("Property {0} ({1}) on Content Type {2} could not be retrieved for Document {3} on Tab Page {4}. To fix this problem, delete the property and recreate it.", propertyType.Alias, propertyType.Id, _content.ContentType.Alias, _content.Id, tab.Caption));
                    }
                }

                i++;
            }

            // Add property pane
            tpProp = NewTabPage(ui.Text("general", "properties", null));
            addSaveAndPublishButtons(ref tpProp);
            tpProp.Controls.Add(
                new LiteralControl("<div id=\"errorPane_" + tpProp.ClientID +
                                   "\" style=\"display: none; text-align: left; color: red;width: 100%; border: 1px solid red; background-color: #FCDEDE\"><div><b>There were errors - data has not been saved!</b><br/></div></div>"));

            //if the property is not in a tab, add it to the general tab
            var props = _content.GenericProperties;
            foreach (Property p in props)
            {
                if (inTab[p.PropertyType.Id.ToString()] == null)
                    addControlNew(p, tpProp, ui.Text("general", "properties", null));
            }

        }
Example #12
0
        void Page_PreInit(Object sender, EventArgs e)
        {
            Trace.Write("umbracoInit", "handling request");

            if (UmbracoContext.Current == null)
                UmbracoContext.Current = new UmbracoContext(HttpContext.Current);

            bool editMode = UmbracoContext.Current.LiveEditingContext.Enabled;

            if (editMode)
                ValidateRequest = false;

            if (m_tmp != "" && Request["umbPageID"] == null)
            {
                // Check numeric
                string tryIntParse = m_tmp.Replace("/", "").Replace(".aspx", string.Empty);
                int result;
                if (int.TryParse(tryIntParse, out result))
                {
                    m_tmp = m_tmp.Replace(".aspx", string.Empty);

                    // Check for request
                    if (!string.IsNullOrEmpty(Request["umbVersion"]))
                    {
                        // Security check
                        BasePages.UmbracoEnsuredPage bp = new BasePages.UmbracoEnsuredPage();
                        bp.ensureContext();
                        m_version = new Guid(Request["umbVersion"]);
                    }
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(Request["umbPageID"]))
                {
                    int result;
                    if (int.TryParse(Request["umbPageID"], out result))
                    {
                        m_tmp = Request["umbPageID"];
                    }
                }
            }

            if (m_version != Guid.Empty)
            {
                HttpContext.Current.Items["pageID"] = m_tmp.Replace("/", "");
                m_umbPage = new page(int.Parse(m_tmp.Replace("/", "")), m_version);
            }
            else
            {
                m_umbRequest = new requestHandler(UmbracoContext.Current.GetXml(), m_tmp);
                Trace.Write("umbracoInit", "Done handling request");
                if (m_umbRequest.currentPage != null)
                {
                    HttpContext.Current.Items["pageID"] = m_umbRequest.currentPage.Attributes.GetNamedItem("id").Value;

                    // Handle edit
                    if (editMode)
                    {
                        Document d = new Document(int.Parse(m_umbRequest.currentPage.Attributes.GetNamedItem("id").Value));
                        m_umbPage = new page(d.Id, d.Version);
                    }
                    else
                        m_umbPage = new page(m_umbRequest.currentPage);
                }
            }

            // set the friendly path so it's used by forms
            HttpContext.Current.RewritePath(HttpContext.Current.Items[requestModule.ORIGINAL_URL_CXT_KEY].ToString());

            if (UmbracoSettings.UseAspNetMasterPages)
            {
                HttpContext.Current.Trace.Write("umbracoPage", "Looking up skin information");

                if (m_umbPage != null)
                {
                    if (m_umbPage.Template == 0)
                    {
                        string custom404 = umbraco.library.GetCurrentNotFoundPageId();
                        if (!String.IsNullOrEmpty(custom404))
                        {
                            XmlNode xmlNodeNotFound = content.Instance.XmlContent.GetElementById(custom404);
                            if (xmlNodeNotFound != null)
                            {
                                m_umbPage = new page(xmlNodeNotFound);
                            }
                        }
                    }

                    if (m_umbPage.Template != 0)
                    {
                        this.MasterPageFile = template.GetMasterPageName(m_umbPage.Template);
                    }
                    else
                    {
                        GenerateNotFoundContent();
                        Response.End();
                    }
                }

                initUmbracoPage();
            }
        }