Ejemplo n.º 1
0
        protected override void OnInit(EventArgs e)
        {
            resmgr = ((System.Resources.ResourceManager)ApplicationResourceTable.Get());
            SharedBasePage requestPage = Page as SharedBasePage;
            siteConfig = requestPage.SiteConfig;

            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
            base.OnInit(e);
        }
Ejemplo n.º 2
0
        public static void Save(SiteConfig siteConfig)
        {
            System.Security.Principal.WindowsImpersonationContext wi = Impersonation.Impersonate();

            XmlSerializer ser = new XmlSerializer(typeof (SiteConfig));

            using (StreamWriter writer = new StreamWriter(SiteConfig.GetConfigFilePathFromCurrentContext()))
            {
                ser.Serialize(writer, siteConfig);
            }

            wi.Undo();
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SharedBasePage requestPage = this.Page as SharedBasePage;
            siteConfig = SiteConfig.GetSiteConfig();

            resmgr = ApplicationResourceTable.Get();

            imageUpload.Accept = "image/jpeg,image/gif,image/png";
            editControl.Width = Unit.Percentage(99d);
            editControl.Height = Unit.Pixel(400);
            editControl.Text = "<p></p>";

            // TODO: OmarS need to get rid of this
            isDHTMLEdit = true;

            editControl.SetLanguage(CultureInfo.CurrentUICulture.Name);
            editControl.SetTextDirection(requestPage.ReadingDirection);

            if (!requestPage.SiteConfig.EnableCrossposts)
            {
                gridCrossposts.Visible = false;
                labelCrosspost.Visible = false;
            }

            if (!SiteSecurity.IsValidContributor())
            {
                Response.Redirect("~/FormatPage.aspx?path=SiteConfig/accessdenied.format.html");
            }

            CrosspostInfoCollection crosspostSiteInfo = new CrosspostInfoCollection();

            if (!IsPostBack)
            {
                foreach (CrosspostSite site in requestPage.SiteConfig.CrosspostSites)
                {
                    CrosspostInfo ci = new CrosspostInfo(site);
                    ci.TrackingUrlBase = SiteUtilities.GetCrosspostTrackingUrlBase(requestPage.SiteConfig);
                    crosspostSiteInfo.Add(ci);
                }

                // set up categories
                foreach (CategoryCacheEntry category in requestPage.DataService.GetCategories())
                {
                    this.categoryList.Items.Add(category.Name);
                }

                // get the cultures
                CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);

                // setup temp store for listitem items, for sorting
                List<ListItem> cultureList = new List<ListItem>(cultures.Length);

                foreach (CultureInfo ci in cultures)
                {
                    string langName = (ci.NativeName != ci.EnglishName) ? ci.NativeName + " / " + ci.EnglishName : ci.NativeName;

                    if (langName.Length > 55)
                    {
                        langName = langName.Substring(0, 55) + "...";
                    }

                    cultureList.Add( new ListItem(langName, ci.Name));
                }

                // setup the sort culture
                string rssCulture = requestPage.SiteConfig.RssLanguage;

                CultureInfo sortCulture;

                try{
                    sortCulture = ( rssCulture != null && rssCulture.Length > 0 ? new CultureInfo( rssCulture ) : CultureInfo.CurrentCulture);
                }catch(ArgumentException){
                    // default to the culture of the server
                    sortCulture = CultureInfo.CurrentCulture;
                }

                // sort the list
                cultureList.Sort(delegate(ListItem x, ListItem y)
                {
                    // actual comparison
                    return String.Compare(x.Text, y.Text, true, sortCulture);
                });

                // add to the languages listbox
                ListItem[] cultureListItems = cultureList.ToArray();

                listLanguages.Items.AddRange(cultureListItems);

                listLanguages.SelectedValue = "";

                if (requestPage != null && requestPage.WeblogEntryId != "")
                {
                    Session["newtelligence.DasBlog.Web.EditEntryBox.OriginalReferrer"] = Request.UrlReferrer;
                    Entry entry = requestPage.DataService.GetEntryForEdit(requestPage.WeblogEntryId);

                    if (entry != null)
                    {
                        CurrentEntry = entry;
                        entryTitle.Text = entry.Title;
                        entryAbstract.Text = entry.Description;

                        textDate.SelectedDate = entry.CreatedLocalTime;

                        if (isDHTMLEdit)
                        {
                            editControl.Text = entry.Content;
                        }

                        foreach (string s in entry.GetSplitCategories())
                        {
                            categoryList.Items.FindByText(s).Selected = true;
                        }

                        this.checkBoxAllowComments.Checked = entry.AllowComments;
                        this.checkBoxPublish.Checked = entry.IsPublic;
                        this.checkBoxSyndicated.Checked = entry.Syndicated;

                        // GeoRSS.
                        this.txtLat.Text = String.Format(CultureInfo.InvariantCulture, "{0}", entry.Latitude);
                        this.txtLong.Text = String.Format(CultureInfo.InvariantCulture, "{0}", entry.Longitude);

                        if (entry.Attachments.Count > 0)
                        {
                            foreach (Attachment enclosure in entry.Attachments)
                            {
                                enclosure.Url = SiteUtilities.GetEnclosureLinkUrl(requestPage.SiteConfig, entry.EntryId, enclosure);
                            }

                            this.enclosureUpload.Visible = false;
                            this.buttonRemove.Visible = true;
                            this.labelEnclosureName.Visible = true;
                            this.labelEnclosureName.Text = entry.Attachments[0].Name;
                        }

                        listLanguages.SelectedValue = entry.Language == null ? "" : entry.Language;

                        // merge the crosspost config with the crosspost data
                        foreach (CrosspostInfo cpi in crosspostSiteInfo)
                        {
                            foreach (Crosspost cp in entry.Crossposts)
                            {
                                if (cp.ProfileName == cpi.Site.ProfileName)
                                {
                                    cpi.IsAlreadyPosted = true;
                                    cpi.TargetEntryId = cp.TargetEntryId;
                                    cpi.Categories = cp.Categories;
                                    break;
                                }
                            }
                        }
                        // if the entry is not public yet but opened for editing, then we can setup autosave.
                        // (If the entry was already published publically and then autosave was used, the
                        // entry's status would change to non-public and then no longer be accessible!)
                        if (requestPage.SiteConfig.EnableAutoSave && !entry.IsPublic)
                        {
                            SetupAutoSave();
                        }

                        if (requestPage.SiteConfig.EnableGoogleMaps)
                        {
                            AddGoogleMapsApi();
                        }

                    }
                }
                else // This is a brand new entry, so setup the AutoSave script if it's enabled.
                {
                    if (requestPage.SiteConfig.EnableAutoSave)
                    {
                        SetupAutoSave();
                    }

                    if (requestPage.SiteConfig.EnableGoogleMaps)
                    {
                        AddGoogleMapsApi();
                    }

                    txtLat.Text = String.Format(CultureInfo.InvariantCulture, "{0}", siteConfig.DefaultLatitude);
                    txtLong.Text = String.Format(CultureInfo.InvariantCulture, "{0}", siteConfig.DefaultLongitude);
                }

                gridCrossposts.DataSource = crosspostSiteInfo;
                DataBind();
            }
        }
Ejemplo n.º 4
0
		protected void Page_Load(object sender, System.EventArgs e)
		{
			siteConfig = SiteConfig.GetSiteConfig();
			
			resmgr = ((System.Resources.ResourceManager)ApplicationResourceTable.Get());

			//set the current page <li> tag to here
            string filePath = this.Request.FilePath;

            if (filePath.EndsWith("EditCrossPostSites.aspx", StringComparison.InvariantCultureIgnoreCase))
			{
				editCrossPostSites.Attributes["class"]="here";
				hyperLinkEditCrossPostSites.NavigateUrl= "";
			}
            else if (filePath.EndsWith("EditNavigatorLinks.aspx", StringComparison.InvariantCultureIgnoreCase))
			{
				editNavigatorLinks.Attributes["class"]="here";
				hyperLinkEditNavigatorLinks.NavigateUrl= "";
			}
			else if (filePath.EndsWith("EditBlogRoll.aspx", StringComparison.InvariantCultureIgnoreCase))
			{
				editBlogRoll.Attributes["class"]="here";
				hyperLinkEditBlogRoll.NavigateUrl= "";
			}
			else if (filePath.EndsWith("EditContentFilters.aspx", StringComparison.InvariantCultureIgnoreCase))
			{
				editContentFilters.Attributes["class"]="here";
				hyperLinkEditContentFilters.NavigateUrl= "";
			}
			else if (filePath.EndsWith("EditConfig.aspx", StringComparison.InvariantCultureIgnoreCase))
			{
				editConfig.Attributes["class"]="here";
				hyperLinkEditConfig.NavigateUrl= "";
			}
			else if (filePath.EndsWith("Referrers.aspx", StringComparison.InvariantCultureIgnoreCase)||
                     filePath.EndsWith("Eventlog.aspx", StringComparison.InvariantCultureIgnoreCase)||
                     filePath.EndsWith("AggBugs.aspx", StringComparison.InvariantCultureIgnoreCase)||
                     filePath.EndsWith("ClickThroughs.aspx", StringComparison.InvariantCultureIgnoreCase))
			{
				activity.Attributes["class"]="here";
				hyperLinkActivity.NavigateUrl= "";
			}
			else if (filePath.EndsWith("EditEntry.aspx", StringComparison.InvariantCultureIgnoreCase))
			{
				editEntry.Attributes["class"]="firstHere";
				hyperLinkEditEntry.NavigateUrl= "";
			}				
			else if (filePath.EndsWith("EditUser.aspx", StringComparison.InvariantCultureIgnoreCase))
			{
				editUser.Attributes["class"]="here";
				hyperLinkEditUser.NavigateUrl= "";
			}
			
			// The only tab that should be visible for a contributor is the
			// "Add Entry" and "User Settings" tab
			if (SiteSecurity.IsInRole("contributor"))
			{
				this.editConfig.Visible = false;
				this.editCrossPostSites.Visible = false;
				this.editContentFilters.Visible = false;
				this.editBlogRoll.Visible = false;
				this.editNavigatorLinks.Visible = false;
				this.activity.Visible = false;
			}
			DataBind();
		}