Merge with 6.0.4
This commit is contained in:
@@ -582,24 +582,26 @@ namespace Umbraco.Core.Services
|
||||
foreach (XElement tempElement in templateElements)
|
||||
{
|
||||
var dependencies = new List<string>();
|
||||
if (tempElement.Element("Master") != null &&
|
||||
string.IsNullOrEmpty(tempElement.Element("Master").Value) == false &&
|
||||
templateElements.Any(x => x.Element("Alias").Value == tempElement.Element("Master").Value))
|
||||
var elementCopy = tempElement;
|
||||
|
||||
if (elementCopy.Element("Master") != null &&
|
||||
string.IsNullOrEmpty(elementCopy.Element("Master").Value) == false &&
|
||||
templateElements.Any(x => x.Element("Alias").Value == elementCopy.Element("Master").Value))
|
||||
{
|
||||
dependencies.Add(tempElement.Element("Master").Value);
|
||||
dependencies.Add(elementCopy.Element("Master").Value);
|
||||
}
|
||||
else if (tempElement.Element("Master") != null &&
|
||||
string.IsNullOrEmpty(tempElement.Element("Master").Value) == false &&
|
||||
templateElements.Any(x => x.Element("Alias").Value == tempElement.Element("Master").Value) ==
|
||||
else if (elementCopy.Element("Master") != null &&
|
||||
string.IsNullOrEmpty(elementCopy.Element("Master").Value) == false &&
|
||||
templateElements.Any(x => x.Element("Alias").Value == elementCopy.Element("Master").Value) ==
|
||||
false)
|
||||
{
|
||||
LogHelper.Info<PackagingService>(string.Format("Template '{0}' has an invalid Master '{1}', so the reference has been ignored.", tempElement.Element("Alias").Value, tempElement.Element("Master").Value));
|
||||
LogHelper.Info<PackagingService>(string.Format("Template '{0}' has an invalid Master '{1}', so the reference has been ignored.", elementCopy.Element("Alias").Value, elementCopy.Element("Master").Value));
|
||||
}
|
||||
|
||||
var field = new TopologicalSorter.DependencyField<XElement>
|
||||
{
|
||||
Alias = tempElement.Element("Alias").Value,
|
||||
Item = new Lazy<XElement>(() => tempElement),
|
||||
Alias = elementCopy.Element("Alias").Value,
|
||||
Item = new Lazy<XElement>(() => elementCopy),
|
||||
DependsOn = dependencies.ToArray()
|
||||
};
|
||||
|
||||
|
||||
@@ -25,15 +25,17 @@ using StylesheetProperty = umbraco.cms.businesslogic.web.StylesheetProperty;
|
||||
|
||||
namespace umbraco.controls
|
||||
{
|
||||
public class ContentControlLoadEventArgs : System.ComponentModel.CancelEventArgs { }
|
||||
public class ContentControlLoadEventArgs : CancelEventArgs { }
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for ContentControl.
|
||||
/// </summary>
|
||||
public class ContentControl : TabView
|
||||
{
|
||||
private readonly Content _content;
|
||||
|
||||
|
||||
internal Dictionary<string, IDataType> DataTypes = new Dictionary<string, IDataType>();
|
||||
private readonly Content _content;
|
||||
private UmbracoEnsuredPage _prntpage;
|
||||
public event EventHandler SaveAndPublish;
|
||||
public event EventHandler SaveToPublish;
|
||||
@@ -44,31 +46,53 @@ namespace umbraco.controls
|
||||
public TextBox NameTxt = new TextBox();
|
||||
public PlaceHolder NameTxtHolder = new PlaceHolder();
|
||||
public RequiredFieldValidator NameTxtValidator = new RequiredFieldValidator();
|
||||
private static readonly string _UmbracoPath = SystemDirectories.Umbraco;
|
||||
private readonly CustomValidator _nameTxtCustomValidator = new CustomValidator();
|
||||
private static readonly string UmbracoPath = SystemDirectories.Umbraco;
|
||||
public Pane PropertiesPane = new Pane();
|
||||
// zb-00036 #29889 : load it only once
|
||||
List<ContentType.TabI> _virtualTabs;
|
||||
//default to true!
|
||||
private bool _savePropertyDataWhenInvalid = true;
|
||||
private ContentType _contentType;
|
||||
|
||||
|
||||
public Content ContentObject
|
||||
{
|
||||
get { return _content; }
|
||||
}
|
||||
|
||||
// Error messages
|
||||
/// <summary>
|
||||
/// This property controls whether the content property values are persisted even if validation
|
||||
/// fails. If set to false, then the values will not be persisted.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is required because when we are editing content we should be persisting invalid values to the database
|
||||
/// as this makes it easier for editors to come back and fix up their changes before they publish. Of course we
|
||||
/// don't publish if the page is invalid. In the case of media and members, we don't want to persist the values
|
||||
/// to the database when the page is invalid because there is no published state.
|
||||
/// Relates to: http://issues.umbraco.org/issue/U4-227
|
||||
/// </remarks>
|
||||
public bool SavePropertyDataWhenInvalid
|
||||
{
|
||||
get { return _savePropertyDataWhenInvalid; }
|
||||
set { _savePropertyDataWhenInvalid = value; }
|
||||
}
|
||||
|
||||
[Obsolete("This is no longer used and will be removed from the codebase in future versions")]
|
||||
private string _errorMessage = "";
|
||||
|
||||
[Obsolete("This is no longer used and will be removed from the codebase in future versions")]
|
||||
public string ErrorMessage
|
||||
{
|
||||
set { _errorMessage = value; }
|
||||
}
|
||||
|
||||
[Obsolete("This event handler should not be used, it will stil fire for when a SaveAndPublish event is raised but this should be handled with the data APIs")]
|
||||
[Obsolete("This is no longer used and will be removed from the codebase in future versions")]
|
||||
protected void standardSaveAndPublishHandler(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
// zb-00036 #29889 : load it only once
|
||||
private List<ContentType.TabI> _virtualTabs;
|
||||
private ContentType _contentType;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructor to set default properties.
|
||||
/// </summary>
|
||||
@@ -110,8 +134,7 @@ namespace umbraco.controls
|
||||
{
|
||||
base.CreateChildControls();
|
||||
|
||||
SaveAndPublish += new EventHandler(standardSaveAndPublishHandler);
|
||||
Save += new EventHandler(standardSaveAndPublishHandler);
|
||||
|
||||
_prntpage = (UmbracoEnsuredPage)Page;
|
||||
int i = 0;
|
||||
Hashtable inTab = new Hashtable();
|
||||
@@ -254,12 +277,19 @@ namespace umbraco.controls
|
||||
|
||||
// Name validation
|
||||
NameTxtValidator.ControlToValidate = NameTxt.ID;
|
||||
_nameTxtCustomValidator.ControlToValidate = NameTxt.ID;
|
||||
string[] errorVars = { ui.Text("name") };
|
||||
NameTxtValidator.ErrorMessage = " " + ui.Text("errorHandling", "errorMandatoryWithoutTab", errorVars, null) + "<br/>";
|
||||
NameTxtValidator.EnableClientScript = false;
|
||||
NameTxtValidator.Display = ValidatorDisplay.Dynamic;
|
||||
NameTxtValidator.Display = ValidatorDisplay.Dynamic;
|
||||
_nameTxtCustomValidator.EnableClientScript = false;
|
||||
_nameTxtCustomValidator.Display = ValidatorDisplay.Dynamic;
|
||||
_nameTxtCustomValidator.ServerValidate += NameTxtCustomValidatorServerValidate;
|
||||
_nameTxtCustomValidator.ValidateEmptyText = false;
|
||||
|
||||
NameTxtHolder.Controls.Add(NameTxt);
|
||||
NameTxtHolder.Controls.Add(NameTxtValidator);
|
||||
NameTxtHolder.Controls.Add(_nameTxtCustomValidator);
|
||||
PropertiesPane.addProperty(ui.Text("general", "name", null), NameTxtHolder);
|
||||
|
||||
Literal ltt = new Literal();
|
||||
@@ -284,6 +314,23 @@ namespace umbraco.controls
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom validates the content name field
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="args"></param>
|
||||
/// <remarks>
|
||||
/// We need to ensure people are not entering XSS attacks on this field
|
||||
/// http://issues.umbraco.org/issue/U4-485
|
||||
///
|
||||
/// This doesn't actually 'validate' but changes the text field value and strips html
|
||||
/// </remarks>
|
||||
void NameTxtCustomValidatorServerValidate(object source, ServerValidateEventArgs args)
|
||||
{
|
||||
NameTxt.Text = NameTxt.Text.StripHtml();
|
||||
args.IsValid = true;
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
@@ -316,7 +363,10 @@ namespace umbraco.controls
|
||||
{
|
||||
SetNameAndDataTypeValues();
|
||||
|
||||
Save(this, new EventArgs());
|
||||
if (Save != null)
|
||||
{
|
||||
Save(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
private void DoSaveAndPublish(object sender, ImageClickEventArgs e)
|
||||
@@ -329,20 +379,26 @@ namespace umbraco.controls
|
||||
// see: http://issues.umbraco.org/issue/U4-1660
|
||||
Save(this, new EventArgs());
|
||||
|
||||
SaveAndPublish(this, new EventArgs());
|
||||
if (SaveAndPublish != null)
|
||||
{
|
||||
SaveAndPublish(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
private void DoSaveToPublish(object sender, ImageClickEventArgs e)
|
||||
{
|
||||
SaveClick(sender, e);
|
||||
SaveToPublish(this, new EventArgs());
|
||||
if (SaveToPublish != null)
|
||||
{
|
||||
SaveToPublish(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
private void AddSaveAndPublishButtons(ref TabPage tp)
|
||||
{
|
||||
MenuImageButton menuSave = tp.Menu.NewImageButton();
|
||||
menuSave.ID = tp.ID + "_save";
|
||||
menuSave.ImageUrl = _UmbracoPath + "/images/editor/save.gif";
|
||||
menuSave.ImageUrl = UmbracoPath + "/images/editor/save.gif";
|
||||
menuSave.Click += new ImageClickEventHandler(SaveClick);
|
||||
menuSave.OnClickCommand = "invokeSaveHandlers();";
|
||||
menuSave.AltText = ui.Text("buttons", "save", null);
|
||||
@@ -350,7 +406,7 @@ namespace umbraco.controls
|
||||
{
|
||||
MenuImageButton menuPublish = tp.Menu.NewImageButton();
|
||||
menuPublish.ID = tp.ID + "_publish";
|
||||
menuPublish.ImageUrl = _UmbracoPath + "/images/editor/saveAndPublish.gif";
|
||||
menuPublish.ImageUrl = UmbracoPath + "/images/editor/saveAndPublish.gif";
|
||||
menuPublish.OnClickCommand = "invokeSaveHandlers();";
|
||||
menuPublish.Click += new ImageClickEventHandler(DoSaveAndPublish);
|
||||
menuPublish.AltText = ui.Text("buttons", "saveAndPublish", null);
|
||||
@@ -359,7 +415,7 @@ namespace umbraco.controls
|
||||
{
|
||||
MenuImageButton menuToPublish = tp.Menu.NewImageButton();
|
||||
menuToPublish.ID = tp.ID + "_topublish";
|
||||
menuToPublish.ImageUrl = _UmbracoPath + "/images/editor/saveToPublish.gif";
|
||||
menuToPublish.ImageUrl = UmbracoPath + "/images/editor/saveToPublish.gif";
|
||||
menuToPublish.OnClickCommand = "invokeSaveHandlers();";
|
||||
menuToPublish.Click += new ImageClickEventHandler(DoSaveToPublish);
|
||||
menuToPublish.AltText = ui.Text("buttons", "saveToPublish", null);
|
||||
@@ -367,7 +423,7 @@ namespace umbraco.controls
|
||||
}
|
||||
|
||||
|
||||
private void AddControlNew(Property p, TabPage tp, string Caption)
|
||||
private void AddControlNew(Property p, TabPage tp, string cap)
|
||||
{
|
||||
IDataType dt = p.PropertyType.DataTypeDefinition.DataType;
|
||||
dt.DataEditor.Editor.ID = string.Format("prop_{0}", p.PropertyType.Alias);
|
||||
@@ -494,7 +550,7 @@ namespace umbraco.controls
|
||||
{
|
||||
rq.EnableClientScript = false;
|
||||
rq.Display = ValidatorDisplay.Dynamic;
|
||||
string[] errorVars = { p.PropertyType.Name, Caption };
|
||||
string[] errorVars = { p.PropertyType.Name, cap };
|
||||
rq.ErrorMessage = ui.Text("errorHandling", "errorMandatory", errorVars, null) + "<br/>";
|
||||
holder.Controls.AddAt(0, rq);
|
||||
}
|
||||
@@ -529,7 +585,7 @@ namespace umbraco.controls
|
||||
rv.ValidationExpression = p.PropertyType.ValidationRegExp;
|
||||
rv.EnableClientScript = false;
|
||||
rv.Display = ValidatorDisplay.Dynamic;
|
||||
string[] errorVars = { p.PropertyType.Name, Caption };
|
||||
string[] errorVars = { p.PropertyType.Name, cap };
|
||||
rv.ErrorMessage = ui.Text("errorHandling", "errorRegExp", errorVars, null) + "<br/>";
|
||||
holder.Controls.AddAt(0, rv);
|
||||
}
|
||||
@@ -564,25 +620,6 @@ namespace umbraco.controls
|
||||
NoPublish
|
||||
}
|
||||
|
||||
private string DictinaryItem(string alias)
|
||||
{
|
||||
if (alias.Substring(1, 0) == "#")
|
||||
{
|
||||
|
||||
if (Dictionary.DictionaryItem.hasKey(alias.Substring(1)))
|
||||
{
|
||||
|
||||
Dictionary.DictionaryItem di = new Dictionary.DictionaryItem(alias.Substring(1));
|
||||
|
||||
if (di != null && !string.IsNullOrEmpty(di.Value()))
|
||||
return di.Value();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return alias + " " + alias.Substring(1);
|
||||
}
|
||||
|
||||
// EVENTS
|
||||
public delegate void BeforeContentControlLoadEventHandler(ContentControl contentControl, ContentControlLoadEventArgs e);
|
||||
public delegate void AfterContentControlLoadEventHandler(ContentControl contentControl, ContentControlLoadEventArgs e);
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
using System;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Caching;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Services;
|
||||
using umbraco.BusinessLogic.Actions;
|
||||
using umbraco.uicontrols.DatePicker;
|
||||
using umbraco.BusinessLogic;
|
||||
@@ -13,6 +12,7 @@ using umbraco.cms.businesslogic.web;
|
||||
using umbraco.presentation;
|
||||
using System.Linq;
|
||||
using Image = System.Web.UI.WebControls.Image;
|
||||
using Umbraco.Core;
|
||||
|
||||
namespace umbraco.cms.presentation
|
||||
{
|
||||
@@ -312,9 +312,7 @@ namespace umbraco.cms.presentation
|
||||
_document.Save();
|
||||
return;
|
||||
}
|
||||
|
||||
//var previouslyPublished = _document.HasPublishedVersion();
|
||||
|
||||
|
||||
if (_document.SaveAndPublish(UmbracoUser))
|
||||
{
|
||||
//library.UpdateDocumentCache(_document.Id);
|
||||
|
||||
@@ -18,9 +18,9 @@ namespace umbraco.cms.presentation
|
||||
/// </summary>
|
||||
public partial class editMedia : BasePages.UmbracoEnsuredPage
|
||||
{
|
||||
private uicontrols.Pane mediaPropertiesPane = new uicontrols.Pane();
|
||||
private LiteralControl updateDateLiteral = new LiteralControl();
|
||||
private LiteralControl mediaFileLinksLiteral = new LiteralControl();
|
||||
private readonly uicontrols.Pane _mediaPropertiesPane = new uicontrols.Pane();
|
||||
private readonly LiteralControl _updateDateLiteral = new LiteralControl();
|
||||
private readonly LiteralControl _mediaFileLinksLiteral = new LiteralControl();
|
||||
|
||||
public editMedia()
|
||||
{
|
||||
@@ -28,12 +28,10 @@ namespace umbraco.cms.presentation
|
||||
}
|
||||
|
||||
protected uicontrols.TabView TabView1;
|
||||
protected System.Web.UI.WebControls.TextBox documentName;
|
||||
private cms.businesslogic.media.Media _media;
|
||||
controls.ContentControl tmp;
|
||||
|
||||
//protected System.Web.UI.WebControls.Literal SyncPath;
|
||||
|
||||
protected TextBox documentName;
|
||||
private businesslogic.media.Media _media;
|
||||
controls.ContentControl _contentControl;
|
||||
|
||||
override protected void OnInit(EventArgs e)
|
||||
{
|
||||
base.OnInit(e);
|
||||
@@ -48,89 +46,92 @@ namespace umbraco.cms.presentation
|
||||
bool exists = SqlHelper.ExecuteScalar<int>("SELECT COUNT(nodeId) FROM cmsContentXml WHERE nodeId = @nodeId",
|
||||
SqlHelper.CreateParameter("@nodeId", _media.Id)) > 0;
|
||||
if (!exists)
|
||||
{
|
||||
_media.XmlGenerate(new XmlDocument());
|
||||
}
|
||||
|
||||
_contentControl = new controls.ContentControl(_media, controls.ContentControl.publishModes.NoPublish, "TabView1");
|
||||
_contentControl.Width = Unit.Pixel(666);
|
||||
_contentControl.Height = Unit.Pixel(666);
|
||||
|
||||
tmp = new controls.ContentControl(_media, controls.ContentControl.publishModes.NoPublish, "TabView1");
|
||||
tmp.Width = Unit.Pixel(666);
|
||||
tmp.Height = Unit.Pixel(666);
|
||||
plc.Controls.Add(tmp);
|
||||
//this must be set to false as we don't want to proceed to save anything if the page is invalid
|
||||
_contentControl.SavePropertyDataWhenInvalid = false;
|
||||
|
||||
tmp.Save += new System.EventHandler(Save);
|
||||
plc.Controls.Add(_contentControl);
|
||||
|
||||
this.updateDateLiteral.ID = "updateDate";
|
||||
this.updateDateLiteral.Text = _media.VersionDate.ToShortDateString() + " " + _media.VersionDate.ToShortTimeString();
|
||||
_contentControl.Save += new System.EventHandler(Save);
|
||||
|
||||
this.mediaFileLinksLiteral.ID = "mediaFileLinks";
|
||||
mediaPropertiesPane.addProperty(ui.Text("content", "updateDate", base.getUser()), this.updateDateLiteral);
|
||||
this._updateDateLiteral.ID = "updateDate";
|
||||
this._updateDateLiteral.Text = _media.VersionDate.ToShortDateString() + " " + _media.VersionDate.ToShortTimeString();
|
||||
|
||||
this._mediaFileLinksLiteral.ID = "mediaFileLinks";
|
||||
_mediaPropertiesPane.addProperty(ui.Text("content", "updateDate", base.getUser()), this._updateDateLiteral);
|
||||
|
||||
this.UpdateMediaFileLinksLiteral();
|
||||
mediaPropertiesPane.addProperty(ui.Text("content", "mediaLinks"), this.mediaFileLinksLiteral);
|
||||
_mediaPropertiesPane.addProperty(ui.Text("content", "mediaLinks"), this._mediaFileLinksLiteral);
|
||||
|
||||
// add the property pane to the page rendering
|
||||
tmp.tpProp.Controls.AddAt(1, mediaPropertiesPane);
|
||||
_contentControl.tpProp.Controls.AddAt(1, _mediaPropertiesPane);
|
||||
}
|
||||
|
||||
protected void Page_Load(object sender, System.EventArgs e)
|
||||
{
|
||||
//if (!IsPostBack)
|
||||
//{
|
||||
// SyncPath.Text = _media.Path;
|
||||
// newName.Text = _media.Text.Replace("'", "\\'");
|
||||
//}
|
||||
if (!IsPostBack)
|
||||
{
|
||||
ClientTools.SyncTree(_media.Path, false);
|
||||
}
|
||||
}
|
||||
|
||||
protected void Save(object sender, System.EventArgs e)
|
||||
protected void Save(object sender, EventArgs e)
|
||||
{
|
||||
// error handling test
|
||||
// do not continue saving anything if the page is invalid!
|
||||
// http://issues.umbraco.org/issue/U4-227
|
||||
if (!Page.IsValid)
|
||||
{
|
||||
foreach (uicontrols.TabPage tp in tmp.GetPanels())
|
||||
foreach (uicontrols.TabPage tp in _contentControl.GetPanels())
|
||||
{
|
||||
tp.ErrorControl.Visible = true;
|
||||
tp.ErrorHeader = ui.Text("errorHandling", "errorHeader");
|
||||
tp.CloseCaption = ui.Text("close");
|
||||
}
|
||||
}
|
||||
else if (Page.IsPostBack)
|
||||
else
|
||||
{
|
||||
// hide validation summaries
|
||||
foreach (uicontrols.TabPage tp in tmp.GetPanels())
|
||||
if (Page.IsPostBack)
|
||||
{
|
||||
tp.ErrorControl.Visible = false;
|
||||
}
|
||||
}
|
||||
// hide validation summaries
|
||||
foreach (uicontrols.TabPage tp in _contentControl.GetPanels())
|
||||
{
|
||||
tp.ErrorControl.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
//The value of the properties has been set on IData through IDataEditor in the ContentControl
|
||||
//so we need to 'retrieve' that value and set it on the property of the new IContent object.
|
||||
//NOTE This is a workaround for the legacy approach to saving values through the DataType instead of the Property
|
||||
//- (The DataType shouldn't be responsible for saving the value - especically directly to the db).
|
||||
foreach (var item in tmp.DataTypes)
|
||||
foreach (var item in _contentControl.DataTypes)
|
||||
{
|
||||
_media.getProperty(item.Key).Value = item.Value.Data.Value;
|
||||
}
|
||||
|
||||
_media.Save();
|
||||
_media.Save();
|
||||
|
||||
this.updateDateLiteral.Text = _media.VersionDate.ToShortDateString() + " " + _media.VersionDate.ToShortTimeString();
|
||||
this.UpdateMediaFileLinksLiteral();
|
||||
|
||||
_media.XmlGenerate(new XmlDocument());
|
||||
ClientTools.ShowSpeechBubble(speechBubbleIcon.save, ui.Text("speechBubbles", "editMediaSaved"), ui.Text("editMediaSavedText"));
|
||||
ClientTools.SyncTree(_media.Path, true);
|
||||
}
|
||||
this._updateDateLiteral.Text = _media.VersionDate.ToShortDateString() + " " + _media.VersionDate.ToShortTimeString();
|
||||
this.UpdateMediaFileLinksLiteral();
|
||||
|
||||
_media.XmlGenerate(new XmlDocument());
|
||||
ClientTools.ShowSpeechBubble(speechBubbleIcon.save, ui.Text("speechBubbles", "editMediaSaved"), ui.Text("editMediaSavedText"));
|
||||
ClientTools.SyncTree(_media.Path, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateMediaFileLinksLiteral()
|
||||
{
|
||||
var uploadField = new Factory().GetNewObject(new Guid(Constants.PropertyEditors.UploadField));
|
||||
|
||||
// always clear, incase the upload file was removed
|
||||
this.mediaFileLinksLiteral.Text = string.Empty;
|
||||
this._mediaFileLinksLiteral.Text = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -143,14 +144,14 @@ namespace umbraco.cms.presentation
|
||||
|
||||
if (properties.Any())
|
||||
{
|
||||
this.mediaFileLinksLiteral.Text += "<table>";
|
||||
this._mediaFileLinksLiteral.Text += "<table>";
|
||||
|
||||
foreach (var property in properties)
|
||||
{
|
||||
this.mediaFileLinksLiteral.Text += string.Format("<tr><td>{0} </td><td><a href=\"{1}\" target=\"_blank\">{1}</a></td></tr>", property.PropertyType.Name, property.Value);
|
||||
this._mediaFileLinksLiteral.Text += string.Format("<tr><td>{0} </td><td><a href=\"{1}\" target=\"_blank\">{1}</a></td></tr>", property.PropertyType.Name, property.Value);
|
||||
}
|
||||
|
||||
this.mediaFileLinksLiteral.Text += "</table>";
|
||||
this._mediaFileLinksLiteral.Text += "</table>";
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Web;
|
||||
using System.Web.SessionState;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.HtmlControls;
|
||||
|
||||
using Umbraco.Core.IO;
|
||||
using umbraco.cms.businesslogic.member;
|
||||
using System.Web.Security;
|
||||
using umbraco.IO;
|
||||
|
||||
namespace umbraco.cms.presentation.members
|
||||
{
|
||||
@@ -25,11 +17,11 @@ namespace umbraco.cms.presentation.members
|
||||
CurrentApp = BusinessLogic.DefaultApps.member.ToString();
|
||||
}
|
||||
protected uicontrols.TabView TabView1;
|
||||
protected System.Web.UI.WebControls.TextBox documentName;
|
||||
private cms.businesslogic.member.Member _document;
|
||||
private MembershipUser m_Member;
|
||||
controls.ContentControl tmp;
|
||||
protected umbraco.uicontrols.UmbracoPanel m_MemberShipPanel = new umbraco.uicontrols.UmbracoPanel();
|
||||
protected TextBox documentName;
|
||||
private Member _document;
|
||||
private MembershipUser _member;
|
||||
controls.ContentControl _contentControl;
|
||||
protected uicontrols.UmbracoPanel m_MemberShipPanel = new uicontrols.UmbracoPanel();
|
||||
|
||||
protected TextBox MemberLoginNameTxt = new TextBox();
|
||||
protected RequiredFieldValidator MemberLoginNameVal = new RequiredFieldValidator();
|
||||
@@ -39,7 +31,7 @@ namespace umbraco.cms.presentation.members
|
||||
protected controls.DualSelectbox _memberGroups = new controls.DualSelectbox();
|
||||
|
||||
|
||||
protected void Page_Load(object sender, System.EventArgs e)
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
// Add password changer
|
||||
@@ -47,19 +39,23 @@ namespace umbraco.cms.presentation.members
|
||||
|
||||
if (Member.InUmbracoMemberMode())
|
||||
{
|
||||
_document = new cms.businesslogic.member.Member(int.Parse(Request.QueryString["id"]));
|
||||
m_Member = Membership.GetUser(_document.Id);
|
||||
tmp = new controls.ContentControl(_document, controls.ContentControl.publishModes.NoPublish, "TabView1");
|
||||
tmp.Width = Unit.Pixel(666);
|
||||
tmp.Height = Unit.Pixel(666);
|
||||
plc.Controls.Add(tmp);
|
||||
_document = new Member(int.Parse(Request.QueryString["id"]));
|
||||
_member = Membership.GetUser(_document.Id);
|
||||
_contentControl = new controls.ContentControl(_document, controls.ContentControl.publishModes.NoPublish, "TabView1");
|
||||
_contentControl.Width = Unit.Pixel(666);
|
||||
_contentControl.Height = Unit.Pixel(666);
|
||||
|
||||
//this must be set to false as we don't want to proceed to save anything if the page is invalid
|
||||
_contentControl.SavePropertyDataWhenInvalid = false;
|
||||
|
||||
plc.Controls.Add(_contentControl);
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
MemberLoginNameTxt.Text = _document.LoginName;
|
||||
MemberEmail.Text = _document.Email;
|
||||
}
|
||||
PlaceHolder ph = new PlaceHolder();
|
||||
var ph = new PlaceHolder();
|
||||
MemberLoginNameTxt.ID = "loginname";
|
||||
ph.Controls.Add(MemberLoginNameTxt);
|
||||
ph.Controls.Add(MemberLoginNameVal);
|
||||
@@ -69,26 +65,27 @@ namespace umbraco.cms.presentation.members
|
||||
MemberLoginNameVal.EnableClientScript = false;
|
||||
MemberLoginNameVal.Display = ValidatorDisplay.Dynamic;
|
||||
|
||||
tmp.PropertiesPane.addProperty(ui.Text("login"), ph);
|
||||
tmp.PropertiesPane.addProperty(ui.Text("password"), MemberPasswordTxt);
|
||||
tmp.PropertiesPane.addProperty("Email", MemberEmail);
|
||||
_contentControl.PropertiesPane.addProperty(ui.Text("login"), ph);
|
||||
_contentControl.PropertiesPane.addProperty(ui.Text("password"), MemberPasswordTxt);
|
||||
_contentControl.PropertiesPane.addProperty("Email", MemberEmail);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Member = Membership.GetUser(Request.QueryString["id"]);
|
||||
MemberLoginNameTxt.Text = m_Member.UserName;
|
||||
_member = Membership.GetUser(Request.QueryString["id"]);
|
||||
MemberLoginNameTxt.Text = _member.UserName;
|
||||
if (!IsPostBack)
|
||||
{
|
||||
MemberEmail.Text = m_Member.Email;
|
||||
MemberEmail.Text = _member.Email;
|
||||
}
|
||||
|
||||
m_MemberShipPanel.Width = 300;
|
||||
m_MemberShipPanel.Text = ui.Text("edit") + " " + m_Member.UserName;
|
||||
umbraco.uicontrols.Pane props = new umbraco.uicontrols.Pane();
|
||||
m_MemberShipPanel.Text = ui.Text("edit") + " " + _member.UserName;
|
||||
var props = new uicontrols.Pane();
|
||||
MemberLoginNameTxt.Enabled = false;
|
||||
|
||||
// check for pw support
|
||||
if (!Membership.Provider.EnablePasswordRetrieval) {
|
||||
if (!Membership.Provider.EnablePasswordRetrieval)
|
||||
{
|
||||
MemberPasswordTxt.Controls.Clear();
|
||||
MemberPasswordTxt.Controls.Add(
|
||||
new LiteralControl("<em>" + ui.Text("errorHandling", "errorChangingProviderPassword") + "</em>"));
|
||||
@@ -102,20 +99,20 @@ namespace umbraco.cms.presentation.members
|
||||
}
|
||||
|
||||
// Groups
|
||||
umbraco.uicontrols.Pane p = new umbraco.uicontrols.Pane();
|
||||
var p = new uicontrols.Pane();
|
||||
_memberGroups.ID = "Membergroups";
|
||||
_memberGroups.Width = 175;
|
||||
string selectedMembers = "";
|
||||
foreach(string role in Roles.GetAllRoles())
|
||||
var selectedMembers = "";
|
||||
foreach(var role in Roles.GetAllRoles())
|
||||
{
|
||||
// if a role starts with __umbracoRole we won't show it as it's an internal role used for public access
|
||||
if (!role.StartsWith("__umbracoRole"))
|
||||
{
|
||||
ListItem li = new ListItem(role);
|
||||
var li = new ListItem(role);
|
||||
if (!IsPostBack)
|
||||
{
|
||||
|
||||
if (Roles.IsUserInRole(m_Member.UserName, role))
|
||||
if (Roles.IsUserInRole(_member.UserName, role))
|
||||
selectedMembers += role + ",";
|
||||
}
|
||||
_memberGroups.Items.Add(li);
|
||||
@@ -127,125 +124,131 @@ namespace umbraco.cms.presentation.members
|
||||
|
||||
if (Member.InUmbracoMemberMode())
|
||||
{
|
||||
tmp.tpProp.Controls.Add(p);
|
||||
tmp.Save += new System.EventHandler(tmp_save);
|
||||
_contentControl.tpProp.Controls.Add(p);
|
||||
_contentControl.Save += new System.EventHandler(tmp_save);
|
||||
}
|
||||
else
|
||||
m_MemberShipPanel.Controls.Add(p);
|
||||
|
||||
}
|
||||
|
||||
void menuSave_Click(object sender, ImageClickEventArgs e)
|
||||
void MenuSaveClick(object sender, ImageClickEventArgs e)
|
||||
{
|
||||
|
||||
tmp_save(sender, e);
|
||||
|
||||
}
|
||||
protected void tmp_save(object sender, System.EventArgs e) {
|
||||
Page.Validate();
|
||||
if (Page.IsValid)
|
||||
{
|
||||
if (Member.InUmbracoMemberMode())
|
||||
|
||||
protected void tmp_save(object sender, EventArgs e)
|
||||
{
|
||||
Page.Validate();
|
||||
if (!Page.IsValid)
|
||||
{
|
||||
foreach (uicontrols.TabPage tp in _contentControl.GetPanels())
|
||||
{
|
||||
_document.LoginName = MemberLoginNameTxt.Text;
|
||||
_document.Email = MemberEmail.Text;
|
||||
tp.ErrorControl.Visible = true;
|
||||
tp.ErrorHeader = ui.Text("errorHandling", "errorHeader");
|
||||
tp.CloseCaption = ui.Text("close");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Check if password should be changed
|
||||
string tempPassword = ((controls.passwordChanger) MemberPasswordTxt.Controls[0]).Password;
|
||||
if (tempPassword.Trim() != "")
|
||||
_document.Password = tempPassword;
|
||||
|
||||
// Groups
|
||||
foreach (ListItem li in _memberGroups.Items)
|
||||
if (Page.IsPostBack)
|
||||
{
|
||||
// hide validation summaries
|
||||
foreach (uicontrols.TabPage tp in _contentControl.GetPanels())
|
||||
{
|
||||
if (("," + _memberGroups.Value + ",").IndexOf("," + li.Value + ",") > -1)
|
||||
{
|
||||
if (!Roles.IsUserInRole(_document.LoginName, li.Value))
|
||||
Roles.AddUserToRole(_document.LoginName, li.Value);
|
||||
}
|
||||
else if (Roles.IsUserInRole(_document.LoginName, li.Value))
|
||||
{
|
||||
Roles.RemoveUserFromRole(_document.LoginName, li.Value);
|
||||
}
|
||||
tp.ErrorControl.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (Member.InUmbracoMemberMode())
|
||||
{
|
||||
_document.LoginName = MemberLoginNameTxt.Text;
|
||||
_document.Email = MemberEmail.Text;
|
||||
|
||||
// Check if password should be changed
|
||||
string tempPassword = ((controls.passwordChanger) MemberPasswordTxt.Controls[0]).Password;
|
||||
if (tempPassword.Trim() != "")
|
||||
_document.Password = tempPassword;
|
||||
|
||||
// Groups
|
||||
foreach (ListItem li in _memberGroups.Items)
|
||||
{
|
||||
if (("," + _memberGroups.Value + ",").IndexOf("," + li.Value + ",") > -1)
|
||||
{
|
||||
if (!Roles.IsUserInRole(_document.LoginName, li.Value))
|
||||
Roles.AddUserToRole(_document.LoginName, li.Value);
|
||||
}
|
||||
else if (Roles.IsUserInRole(_document.LoginName, li.Value))
|
||||
{
|
||||
Roles.RemoveUserFromRole(_document.LoginName, li.Value);
|
||||
}
|
||||
}
|
||||
|
||||
//The value of the properties has been set on IData through IDataEditor in the ContentControl
|
||||
//so we need to 'retrieve' that value and set it on the property of the new IContent object.
|
||||
//NOTE This is a workaround for the legacy approach to saving values through the DataType instead of the Property
|
||||
//- (The DataType shouldn't be responsible for saving the value - especically directly to the db).
|
||||
foreach (var item in tmp.DataTypes)
|
||||
foreach (var item in _contentControl.DataTypes)
|
||||
{
|
||||
_document.getProperty(item.Key).Value = item.Value.Data.Value;
|
||||
}
|
||||
|
||||
// refresh cache
|
||||
_document.XmlGenerate(new System.Xml.XmlDocument());
|
||||
_document.Save();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Member.Email = MemberEmail.Text;
|
||||
if (Membership.Provider.EnablePasswordRetrieval)
|
||||
{
|
||||
string tempPassword = ((controls.passwordChanger) MemberPasswordTxt.Controls[0]).Password;
|
||||
if (tempPassword.Trim() != "")
|
||||
m_Member.ChangePassword(m_Member.GetPassword(), tempPassword);
|
||||
}
|
||||
Membership.UpdateUser(m_Member);
|
||||
// Groups
|
||||
foreach (ListItem li in _memberGroups.Items)
|
||||
if (("," + _memberGroups.Value + ",").IndexOf("," + li.Value + ",") > -1)
|
||||
{
|
||||
if (!Roles.IsUserInRole(m_Member.UserName, li.Value))
|
||||
Roles.AddUserToRole(m_Member.UserName, li.Value);
|
||||
}
|
||||
else if (Roles.IsUserInRole(m_Member.UserName, li.Value))
|
||||
{
|
||||
Roles.RemoveUserFromRole(m_Member.UserName, li.Value);
|
||||
}
|
||||
// refresh cache
|
||||
_document.XmlGenerate(new System.Xml.XmlDocument());
|
||||
_document.Save();
|
||||
}
|
||||
else
|
||||
{
|
||||
_member.Email = MemberEmail.Text;
|
||||
if (Membership.Provider.EnablePasswordRetrieval)
|
||||
{
|
||||
string tempPassword = ((controls.passwordChanger) MemberPasswordTxt.Controls[0]).Password;
|
||||
if (tempPassword.Trim() != "")
|
||||
_member.ChangePassword(_member.GetPassword(), tempPassword);
|
||||
}
|
||||
Membership.UpdateUser(_member);
|
||||
// Groups
|
||||
foreach (ListItem li in _memberGroups.Items)
|
||||
if (("," + _memberGroups.Value + ",").IndexOf("," + li.Value + ",") > -1)
|
||||
{
|
||||
if (!Roles.IsUserInRole(_member.UserName, li.Value))
|
||||
Roles.AddUserToRole(_member.UserName, li.Value);
|
||||
}
|
||||
else if (Roles.IsUserInRole(_member.UserName, li.Value))
|
||||
{
|
||||
Roles.RemoveUserFromRole(_member.UserName, li.Value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ClientTools.ShowSpeechBubble(BasePages.BasePage.speechBubbleIcon.save,
|
||||
ui.Text("speechBubbles", "editMemberSaved", base.getUser()), "");
|
||||
ClientTools.ShowSpeechBubble(speechBubbleIcon.save, ui.Text("speechBubbles", "editMemberSaved", base.getUser()), "");
|
||||
}
|
||||
}
|
||||
|
||||
private umbraco.uicontrols.PropertyPanel AddProperty(string Caption, Control C) {
|
||||
umbraco.uicontrols.PropertyPanel pp = new umbraco.uicontrols.PropertyPanel();
|
||||
pp.Controls.Add(C);
|
||||
pp.Text = Caption;
|
||||
return pp;
|
||||
}
|
||||
|
||||
#region Web Form Designer generated code
|
||||
override protected void OnInit(EventArgs e)
|
||||
private uicontrols.PropertyPanel AddProperty(string caption, Control c)
|
||||
{
|
||||
var pp = new uicontrols.PropertyPanel();
|
||||
pp.Controls.Add(c);
|
||||
pp.Text = caption;
|
||||
return pp;
|
||||
}
|
||||
|
||||
override protected void OnInit(EventArgs e)
|
||||
{
|
||||
//
|
||||
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
|
||||
//
|
||||
|
||||
if (!Member.InUmbracoMemberMode()) {
|
||||
m_MemberShipPanel.hasMenu = true;
|
||||
umbraco.uicontrols.MenuImageButton menuSave = m_MemberShipPanel.Menu.NewImageButton();
|
||||
menuSave.ID = m_MemberShipPanel.ID + "_save";
|
||||
menuSave.ImageUrl = SystemDirectories.Umbraco + "/images/editor/save.gif";
|
||||
menuSave.Click += new ImageClickEventHandler(menuSave_Click);
|
||||
menuSave.AltText = ui.Text("buttons", "save", null);
|
||||
|
||||
}
|
||||
InitializeComponent();
|
||||
base.OnInit(e);
|
||||
if (!Member.InUmbracoMemberMode())
|
||||
{
|
||||
m_MemberShipPanel.hasMenu = true;
|
||||
umbraco.uicontrols.MenuImageButton menuSave = m_MemberShipPanel.Menu.NewImageButton();
|
||||
menuSave.ID = m_MemberShipPanel.ID + "_save";
|
||||
menuSave.ImageUrl = SystemDirectories.Umbraco + "/images/editor/save.gif";
|
||||
menuSave.Click += new ImageClickEventHandler(MenuSaveClick);
|
||||
menuSave.AltText = ui.Text("buttons", "save", null);
|
||||
}
|
||||
base.OnInit(e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,15 +10,19 @@ using System.Web.UI.WebControls;
|
||||
using System.Web.UI.HtmlControls;
|
||||
|
||||
namespace umbraco.uicontrols {
|
||||
public class TabPage : System.Web.UI.WebControls.WebControl {
|
||||
|
||||
public class TabPage : WebControl
|
||||
{
|
||||
// Ensure that a TabPage cannot be instatiated outside
|
||||
// this assembly -> New instances of a tabpage can only be retrieved through the tabview
|
||||
private bool _hasMenu = true;
|
||||
private ScrollingMenu _Menu = new ScrollingMenu();
|
||||
private readonly ScrollingMenu _menu = new ScrollingMenu();
|
||||
protected LiteralControl ErrorHeaderControl = new LiteralControl();
|
||||
private ValidationSummary _vs = new ValidationSummary();
|
||||
private Control _tempErr = new Control();
|
||||
internal TabPage() {
|
||||
private readonly ValidationSummary _vs = new ValidationSummary();
|
||||
private readonly Control _tempErr = new Control();
|
||||
|
||||
internal TabPage()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -29,13 +33,19 @@ namespace umbraco.uicontrols {
|
||||
|
||||
public string ErrorHeader { get; set; }
|
||||
public string CloseCaption { get; set; }
|
||||
public Control ErrorControl { get { return _tempErr; } }
|
||||
|
||||
protected override void OnLoad(EventArgs e) {
|
||||
if (this.HasMenu) {
|
||||
Menu.Width = System.Web.UI.WebControls.Unit.Pixel((int)this.Width.Value - 12);
|
||||
_Menu.ID = this.ID + "_menu";
|
||||
this.Controls.Add(_Menu);
|
||||
public Control ErrorControl
|
||||
{
|
||||
get { return _tempErr; }
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
if (this.HasMenu)
|
||||
{
|
||||
Menu.Width = Unit.Pixel((int) this.Width.Value - 12);
|
||||
_menu.ID = this.ID + "_menu";
|
||||
this.Controls.Add(_menu);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,42 +71,49 @@ namespace umbraco.uicontrols {
|
||||
}
|
||||
|
||||
|
||||
public ScrollingMenu Menu {
|
||||
get { return _Menu; }
|
||||
public ScrollingMenu Menu
|
||||
{
|
||||
get { return _menu; }
|
||||
}
|
||||
|
||||
public bool HasMenu {
|
||||
public bool HasMenu
|
||||
{
|
||||
get { return _hasMenu; }
|
||||
set { _hasMenu = value; }
|
||||
}
|
||||
|
||||
protected override void Render(System.Web.UI.HtmlTextWriter writer) {
|
||||
protected override void Render(HtmlTextWriter writer)
|
||||
{
|
||||
ErrorHeaderControl.Text = ErrorHeader;
|
||||
CreateChildControls();
|
||||
writer.WriteLine("<div id='" + this.ClientID + "' class='tabpage'>");
|
||||
if (HasMenu) {
|
||||
if (HasMenu)
|
||||
{
|
||||
writer.WriteLine("<div class='menubar'>");
|
||||
Menu.Width = this.Width;
|
||||
Menu.RenderControl(writer);
|
||||
writer.WriteLine("</div>");
|
||||
}
|
||||
int ScrollingLayerHeight = (int)((System.Web.UI.WebControls.WebControl)this.Parent).Height.Value - 22;
|
||||
int ScrollingLayerWidth = (int)((System.Web.UI.WebControls.WebControl)this.Parent).Width.Value;
|
||||
var scrollingLayerHeight = (int) ((WebControl) this.Parent).Height.Value - 22;
|
||||
var scrollingLayerWidth = (int) ((WebControl) this.Parent).Width.Value;
|
||||
if (HasMenu)
|
||||
ScrollingLayerHeight = ScrollingLayerHeight - 28;
|
||||
writer.WriteLine("<div class='tabpagescrollinglayer' id='" + this.ClientID + "_contentlayer' style='height:" + ScrollingLayerHeight + "px;width:" + ScrollingLayerWidth + "px'>");
|
||||
scrollingLayerHeight = scrollingLayerHeight - 28;
|
||||
writer.WriteLine("<div class='tabpagescrollinglayer' id='" + this.ClientID + "_contentlayer' style='height:" + scrollingLayerHeight + "px;width:" + scrollingLayerWidth + "px'>");
|
||||
|
||||
string styleString = "";
|
||||
foreach (string key in this.Style.Keys) {
|
||||
foreach (string key in this.Style.Keys)
|
||||
{
|
||||
styleString += key + ":" + this.Style[key] + ";";
|
||||
}
|
||||
|
||||
writer.WriteLine("<div class=\"tabpageContent\" style='" + styleString + "'>");
|
||||
|
||||
_tempErr.RenderControl(writer);
|
||||
|
||||
foreach (System.Web.UI.Control C in this.Controls) {
|
||||
if (C.ClientID != _Menu.ClientID && C.ClientID != _tempErr.ClientID ) {
|
||||
|
||||
foreach (Control C in this.Controls)
|
||||
{
|
||||
if (C.ClientID != _menu.ClientID && C.ClientID != _tempErr.ClientID)
|
||||
{
|
||||
C.RenderControl(writer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ using System.Web;
|
||||
using System.Web.SessionState;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using ClientDependency.Core;
|
||||
|
||||
namespace umbraco.uicontrols {
|
||||
@@ -15,92 +14,102 @@ namespace umbraco.uicontrols {
|
||||
[ClientDependency(ClientDependencyType.Javascript, "tabview/javascript.js", "UmbracoClient")]
|
||||
[ClientDependency(ClientDependencyType.Css, "tabview/style.css", "UmbracoClient")]
|
||||
[ClientDependency(0, ClientDependencyType.Javascript, "Application/NamespaceManager.js", "UmbracoClient")]
|
||||
public class TabView : System.Web.UI.WebControls.WebControl
|
||||
public class TabView : WebControl
|
||||
{
|
||||
private HtmlInputHidden tb = new HtmlInputHidden();
|
||||
private ArrayList Tabs = new ArrayList();
|
||||
private readonly ArrayList _tabs = new ArrayList();
|
||||
protected ArrayList Panels = new ArrayList();
|
||||
private string status = "";
|
||||
private string _status = "";
|
||||
|
||||
public ArrayList GetPanels() {
|
||||
return Panels;
|
||||
}
|
||||
public ArrayList GetPanels()
|
||||
{
|
||||
return Panels;
|
||||
}
|
||||
|
||||
public TabPage NewTabPage(string text) {
|
||||
Tabs.Add(text);
|
||||
TabPage tp = new TabPage();
|
||||
tp.Width = this.Width;
|
||||
tp.ID = this.ID + "_tab0" + (Panels.Count + 1) + "layer";
|
||||
Panels.Add(tp);
|
||||
this.Controls.Add(tp);
|
||||
return tp;
|
||||
}
|
||||
public TabPage NewTabPage(string text)
|
||||
{
|
||||
_tabs.Add(text);
|
||||
var tp = new TabPage();
|
||||
tp.Width = this.Width;
|
||||
tp.ID = this.ID + "_tab0" + (Panels.Count + 1) + "layer";
|
||||
Panels.Add(tp);
|
||||
this.Controls.Add(tp);
|
||||
return tp;
|
||||
}
|
||||
|
||||
|
||||
public string Status {
|
||||
get { return status; }
|
||||
set { status = value; }
|
||||
}
|
||||
|
||||
private bool _autoResize = true;
|
||||
public bool AutoResize {
|
||||
get { return _autoResize; }
|
||||
set { _autoResize = value; }
|
||||
}
|
||||
public string Status
|
||||
{
|
||||
get { return _status; }
|
||||
set { _status = value; }
|
||||
}
|
||||
|
||||
private string ActiveTabId {
|
||||
get {
|
||||
if (this.Parent.Page.IsPostBack) {
|
||||
return this.Parent.Page.Request.Form[this.ClientID + "_activetab"];
|
||||
}
|
||||
return this.ClientID + "_tab01";
|
||||
}
|
||||
}
|
||||
private bool _autoResize = true;
|
||||
|
||||
protected override void OnPreRender(EventArgs e) {
|
||||
base.OnPreRender(e);
|
||||
SetupClientScript();
|
||||
}
|
||||
public bool AutoResize
|
||||
{
|
||||
get { return _autoResize; }
|
||||
set { _autoResize = value; }
|
||||
}
|
||||
|
||||
private void SetupClientScript() {
|
||||
|
||||
private string ActiveTabId
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.Parent.Page.IsPostBack)
|
||||
{
|
||||
return this.Parent.Page.Request.Form[this.ClientID + "_activetab"];
|
||||
}
|
||||
return this.ClientID + "_tab01";
|
||||
}
|
||||
}
|
||||
|
||||
string strTmp = "";
|
||||
for (int i = 1; i <= Tabs.Count; i++) {
|
||||
if (i > 1)
|
||||
strTmp += ",";
|
||||
strTmp += "\"" + this.ClientID + "_tab0" + i + "\"";
|
||||
}
|
||||
this.Page.ClientScript.RegisterStartupScript(
|
||||
this.GetType(),
|
||||
this.ClientID + "TabCollection", ";var " + this.ClientID + "_tabs = new Array(" + strTmp + ");setActiveTab('" + this.ClientID + "','" + this.ActiveTabId + "'," + this.ClientID + "_tabs);",
|
||||
true);
|
||||
protected override void OnPreRender(EventArgs e)
|
||||
{
|
||||
base.OnPreRender(e);
|
||||
SetupClientScript();
|
||||
}
|
||||
|
||||
if (_autoResize)
|
||||
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "TabviewEvents", "jQuery(document).ready(function(){resizeTabView(" + this.ClientID + "_tabs, '" + this.ClientID + "'); }); jQuery(window).resize(function(){ resizeTabView(" + this.ClientID + "_tabs, '" + this.ClientID + "'); });", true);
|
||||
}
|
||||
private void SetupClientScript()
|
||||
{
|
||||
string strTmp = "";
|
||||
for (int i = 1; i <= _tabs.Count; i++)
|
||||
{
|
||||
if (i > 1)
|
||||
strTmp += ",";
|
||||
strTmp += "\"" + this.ClientID + "_tab0" + i + "\"";
|
||||
}
|
||||
this.Page.ClientScript.RegisterStartupScript(
|
||||
this.GetType(),
|
||||
this.ClientID + "TabCollection", ";var " + this.ClientID + "_tabs = new Array(" + strTmp + ");setActiveTab('" + this.ClientID + "','" + this.ActiveTabId + "'," + this.ClientID + "_tabs);",
|
||||
true);
|
||||
|
||||
protected override void Render(HtmlTextWriter writer) {
|
||||
writer.WriteLine("<div id='" + this.ClientID + "' style='height:" + this.Height.Value + "px;width:" + this.Width.Value + "px;'>");
|
||||
writer.WriteLine(" <div class='header'>");
|
||||
writer.WriteLine(" <ul>");
|
||||
for (int i = 0; i <= Tabs.Count - 1; i++) {
|
||||
string TabPageCaption = (string)Tabs[i];
|
||||
string TabId = this.ClientID + "_tab0" + (i + 1);
|
||||
writer.WriteLine(" <li id='" + TabId + "' class='tabOff'>");
|
||||
writer.WriteLine(" <a id='" + TabId + "a' href='#' onclick=\"setActiveTab('" + this.ClientID + "','" + TabId + "'," + this.ClientID + "_tabs); return false;\">");
|
||||
writer.WriteLine(" <span><nobr>" + TabPageCaption + "</nobr></span>");
|
||||
writer.WriteLine(" </a>");
|
||||
writer.WriteLine(" </li>");
|
||||
}
|
||||
writer.WriteLine(" </ul>");
|
||||
writer.WriteLine(" </div>");
|
||||
writer.WriteLine(" <div id='' class='tabpagecontainer'>");
|
||||
this.RenderChildren(writer);
|
||||
writer.WriteLine("\t</div>");
|
||||
writer.WriteLine("\t<div class='footer'><div class='status'><h2>" + this.status + "</h2></div></div>");
|
||||
writer.WriteLine("</div>");
|
||||
writer.WriteLine("<input type='hidden' name='" + this.ClientID + "_activetab' id='" + this.ClientID + "_activetab' value='" + this.ActiveTabId + "'/>");
|
||||
}
|
||||
if (_autoResize)
|
||||
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "TabviewEvents", "jQuery(document).ready(function(){resizeTabView(" + this.ClientID + "_tabs, '" + this.ClientID + "'); }); jQuery(window).resize(function(){ resizeTabView(" + this.ClientID + "_tabs, '" + this.ClientID + "'); });", true);
|
||||
}
|
||||
|
||||
protected override void Render(HtmlTextWriter writer)
|
||||
{
|
||||
writer.WriteLine("<div id='" + this.ClientID + "' style='height:" + this.Height.Value + "px;width:" + this.Width.Value + "px;'>");
|
||||
writer.WriteLine(" <div class='header'>");
|
||||
writer.WriteLine(" <ul>");
|
||||
for (int i = 0; i <= _tabs.Count - 1; i++)
|
||||
{
|
||||
string TabPageCaption = (string) _tabs[i];
|
||||
string TabId = this.ClientID + "_tab0" + (i + 1);
|
||||
writer.WriteLine(" <li id='" + TabId + "' class='tabOff'>");
|
||||
writer.WriteLine(" <a id='" + TabId + "a' href='#' onclick=\"setActiveTab('" + this.ClientID + "','" + TabId + "'," + this.ClientID + "_tabs); return false;\">");
|
||||
writer.WriteLine(" <span><nobr>" + TabPageCaption + "</nobr></span>");
|
||||
writer.WriteLine(" </a>");
|
||||
writer.WriteLine(" </li>");
|
||||
}
|
||||
writer.WriteLine(" </ul>");
|
||||
writer.WriteLine(" </div>");
|
||||
writer.WriteLine(" <div id='' class='tabpagecontainer'>");
|
||||
this.RenderChildren(writer);
|
||||
writer.WriteLine("\t</div>");
|
||||
writer.WriteLine("\t<div class='footer'><div class='status'><h2>" + this._status + "</h2></div></div>");
|
||||
writer.WriteLine("</div>");
|
||||
writer.WriteLine("<input type='hidden' name='" + this.ClientID + "_activetab' id='" + this.ClientID + "_activetab' value='" + this.ActiveTabId + "'/>");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user