示例#1
0
        public virtual void WriteDetail(PropertyData detail, XmlTextWriter writer)
        {
            using (ElementWriter detailElement = new ElementWriter("property", writer))
            {
                detailElement.WriteAttribute("name", detail.Name);
                detailElement.WriteAttribute("typeName", detail.Value.GetType().GetTypeAndAssemblyName());

                if (detail is ObjectProperty)
                {
                    string base64representation = detail.Value.ToBase64String();
                    detailElement.Write(base64representation);
                }
                else if (detail.ValueType == typeof(ContentItem))
                {
                    detailElement.Write(((LinkProperty) detail).LinkedItem.ID.ToString());
                }
                else if (detail.ValueType == typeof(string))//was detail.Value a typo?
                {
                    string value = ((StringProperty) detail).StringValue;

                    if (!string.IsNullOrEmpty(value))
                        detailElement.WriteCData(value);
                }
                else if (detail.ValueType == typeof(DateTime))
                {
                    detailElement.Write(ElementWriter.ToUniversalString(((DateTimeProperty) detail).DateTimeValue));
                }
                else
                {
                    detailElement.Write(detail.Value.ToString());
                }
            }
        }
 protected override void UpdateEditorInternal(IEditableObject item, Control editor)
 {
     BaseDetailCollectionEditor detailCollectionEditor = (BaseDetailCollectionEditor) editor;
     PropertyCollection detailCollection = item.GetDetailCollection(Name, true);
     PropertyData[] details = new PropertyData[detailCollection.Count];
     detailCollection.CopyTo(details, 0);
     detailCollectionEditor.Initialize(details);
 }
示例#3
0
        protected override Control CreateDetailEditor(int id, PropertyData detail)
        {
            StringProperty stringProperty = detail as StringProperty;

            TextBox txt = new TextBox { CssClass = "linkedItem", ID = ID + "_txt_" + id };
            if (stringProperty != null)
                txt.Text = stringProperty.StringValue;
            return txt;
        }
示例#4
0
        protected override Control CreateDetailEditor(int id, PropertyData detail)
        {
            LinkProperty linkDetail = detail as LinkProperty;

            System.Web.UI.WebControls.DropDownList ddl = new System.Web.UI.WebControls.DropDownList { CssClass = "linkedItem", ID = ID + "_ddl_" + id };
            IEnumerable<ContentItem> first = ((IEnumerable) Zeus.Context.Current.Finder.Query(TypeFilterInternal)).Cast<ContentItem>();
            IEnumerable<ContentItem> contentItems = first.ToArray().Cast<ContentItem>();
            ddl.Items.AddRange(contentItems.Select(ci => new ListItem(ci.Title, ci.ID.ToString())).ToArray());
            if (linkDetail != null && linkDetail.LinkValue != null)
                ddl.SelectedValue = linkDetail.LinkValue.Value.ToString();
            return ddl;
        }
示例#5
0
        protected override Control CreateDetailEditor(int id, PropertyData detail)
        {
            LinkProperty linkDetail = detail as LinkProperty;

            FancyFileUpload fileUpload = CreateEditor();
            fileUpload.ID = ID + "_upl_" + id;

            if (linkDetail != null)
                fileUpload.CurrentFileName = ((File) linkDetail.LinkedItem).FileName;

            return fileUpload;
        }
        protected override void CreateOrUpdateDetailCollectionItem(ContentItem contentItem, PropertyData existingDetail, Control editor, out object newDetail)
        {
            FancyFileUpload fileEditor = (FancyFileUpload)editor;
            LinkProperty existingFileProperty = existingDetail as LinkProperty;
            if (fileEditor.HasNewOrChangedFile)
            {
                // Add new file.
                File newFile = null;
                if (existingFileProperty != null)
                    newFile = existingFileProperty.LinkedItem as File;
                if (newFile == null)
                {
                    newFile = CreateNewItem();
                    newFile.Name = Name + Guid.NewGuid();
                    newFile.AddTo(contentItem);
                }

                // Populate FileData object.
                newFile.FileName = fileEditor.FileName;
                string uploadFolder = BaseFileUploadHandler.GetUploadFolder(fileEditor.Identifier);
                string uploadedFile = Path.Combine(uploadFolder, fileEditor.FileName);
                using (FileStream fs = new FileStream(uploadedFile, FileMode.Open))
                {
                    newFile.Data = fs.ReadAllBytes();
                    newFile.ContentType = MimeUtility.GetMimeType(newFile.Data);
                    newFile.Size = fs.Length;
                }

                // Delete temp folder.
                System.IO.File.Delete(uploadedFile);
                Directory.Delete(uploadFolder);

                newDetail = newFile;

                if (existingFileProperty != null)
                    HandleUpdatedFile(newFile);
            }
            else
            {
                newDetail = null;
            }
        }
        private Panel CreateLinkedItemEditor(PropertyData detail)
        {
            Control editor = CreateDetailEditor(_editorIndex, detail);
            Panel panel = CreatePanel(editor, _editorIndex);
            _container.Controls.Add(panel);
            Panels.Add(panel);
            Editors.Add(editor);
            ++_editorIndex;

            return panel;
        }
 protected abstract Control CreateDetailEditor(int id, PropertyData detail);
 protected override void CreateOrUpdateDetailCollectionItem(ContentItem contentItem, PropertyData existingDetail, Control editor, out object newDetail)
 {
     DropDownList ddl = (DropDownList) editor;
     newDetail = Context.Persister.Get(Convert.ToInt32(ddl.SelectedValue));
 }
 protected abstract void CreateOrUpdateDetailCollectionItem(ContentItem item,PropertyData existingDetail, Control editor, out object newDetail);
 protected override void CreateOrUpdateDetailCollectionItem(ContentItem contentItem, PropertyData existingDetail, Control editor, out object newDetail)
 {
     newDetail = ((TextBox) editor).Text;
 }