Exemple #1
0
        /// <summary>
        /// Updates an existing page.
        /// </summary>
        /// <param name="reader"></param>
        private void EditPage(IDataReader reader)
        {
            string fileName      = MakePageName(Name.Text);
            bool   fileIsDefault = false;
            bool   fileIsPublic  = false;

            bool isFolder = (bool)reader["IsFolder"];

            if (isFolder)
            {
                return;
            }

            fileIsDefault = IsDefault.IsSelected;

            // clear old default in current folder
            if (fileIsDefault)
            {
                string outline = ((string)reader[_OutlineKey]).Substring(0, ((string)reader[_OutlineKey]).LastIndexOf('/') + 1);
                using (IDataReader reader2 = FileTreeItem.GetItemByOutline(outline, SiteId))
                {
                    while (reader2.Read())
                    {
                        FileTreeItem.UpdateFileItem((int)reader2[_PageIdKey], (string)reader2["Name"], (bool)reader2["IsPublic"], (bool)reader["IsFolder"], false, (string)reader2[reader2.FieldCount - 1] /*MasterPage*/, SiteId);
                    }
                    reader2.Close();
                }
            }

            // update page attributes
            FileTreeItem.UpdateFileItem(PageId, fileName, fileIsPublic, false, fileIsDefault, MasterPageText.Text, SiteId);
            PageAttributes.Update(PageId, txtTitle.Text, txtKeywords.Text, txtDescription.Text);
        }
Exemple #2
0
        /// <summary>
        /// Pages the exists.
        /// </summary>
        /// <param name="parentId">The parent id.</param>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        private bool PageExists(int parentId, string name)
        {
            bool exists = false;

            string parentPath = string.Empty;
            Guid   siteId     = Guid.Empty;

            using (IDataReader reader = FileTreeItem.GetItemById(parentId))
            {
                if (reader.Read())
                {
                    parentPath = (string)reader[_OutlineKey] == "/" ? "" : (string)reader[_OutlineKey];
                    siteId     = (Guid)reader[_SiteIdKey];
                }
                reader.Close();
            }

            if (!parentPath.EndsWith("/"))
            {
                parentPath = parentPath + "/";
            }

            string childPath = parentPath + name;

            using (IDataReader reader2 = FileTreeItem.GetItemByOutline(childPath, siteId))
            {
                if (reader2.Read())
                {
                    if (PageId != (int)reader2[_PageIdKey])
                    {
                        exists = true;
                    }
                }
                reader2.Close();
            }

            return(exists);
        }