private void AddThankYouPage() { var parent = Content.Load((int)this.Content["ParentId"]); Node landingPage = null; Node landingView = null; // elevation: we do not want to grant Open permission to the user for this technical content using (new SystemAccount()) { if (parent.Fields.ContainsKey("LandingPage") && parent.Fields.ContainsKey("PageContentView")) { landingPage = parent["LandingPage"] as Node; landingView = parent["PageContentView"] as Node; } } if (landingPage == null || landingView == null) { return; } var landingContent = Content.Create(landingPage); var landingCV = ContentView.Create(landingContent, this.Page, ViewMode.Browse, landingView.Path); _wizard.WizardSteps[_wizard.WizardSteps.Count - 1].Controls.Add(landingCV); _wizard.WizardSteps[_wizard.WizardSteps.Count - 2].AllowReturn = false; }
private static ListItem[] GetListItems(IEnumerable <ContentType> contentTypes, Node contextNode) { var dict = new SortedDictionary <string, string>(); if (contentTypes == null) { return(new ListItem[0]); } foreach (var contentType in contentTypes) { if (!SavingAction.CheckManageListPermission(contentType.NodeType, contextNode)) { continue; } var ct = Content.Create(contentType); var title = string.IsNullOrEmpty(ct.DisplayName) ? ct.Name : ct.DisplayName; if (!dict.ContainsKey(title)) { dict.Add(title, ct.Name); } } return(dict.Keys.Count == 0 ? new ListItem[0] : dict.Keys.Select(key => new ListItem(key, dict[key])).ToArray()); }
public void Content_FieldControl() { Node automobileNode = LoadOrCreateAutomobileAndSave(AutomobileHandler.ExtendedCTD, "Automobile12", "Honda", "Gyeby"); SNC.Content automobileContent = SNC.Content.Create(automobileNode); Field manuField = automobileContent.Fields["Manufacturer"]; Field drivField = automobileContent.Fields["Driver"]; ShortText shortText = new ShortText(); ShortTextAccessor shortTextAcc = new ShortTextAccessor(shortText); ShortText shortTextEditor = new ShortText(); ShortTextAccessor shortTextEditorAcc = new ShortTextAccessor(shortTextEditor); //-- contentview szimulacio: RegisterFieldControl shortTextAcc.ConnectToField(manuField); shortTextEditorAcc.ConnectToField(drivField); Assert.IsTrue(shortTextAcc.Text == (string)automobileContent["Manufacturer"], "#01"); Assert.IsTrue(shortTextEditorAcc.InputTextBox.Text == (string)automobileContent["Driver"], "#02"); shortTextEditorAcc.InputTextBox.Text = "Netudki"; //-- contentview szimulacio: PostData drivField.SetData(shortTextEditor.GetData()); // automobileContent.IsValid? string result = (string)automobileContent["Driver"]; Assert.IsTrue(result == "Netudki", "#03"); }
internal bool UpdateReferences(SNC.Content content, bool needToValidate) { if (_transferringContext == null) { _transferringContext = new ImportContext(_xmlDoc.SelectNodes("/ContentMetaData/Fields/*"), null, false, needToValidate, true); } else { _transferringContext.UpdateReferences = true; } var node = content.ContentHandler; node.ModificationDate = node.ModificationDate; node.VersionModificationDate = node.VersionModificationDate; node.ModifiedBy = node.ModifiedBy; node.VersionModifiedBy = node.VersionModifiedBy; if (!content.ImportFieldData(_transferringContext)) { return(false); } if (!HasPermissions && !HasBreakPermissions) { return(true); } var permissionsNode = _xmlDoc.SelectSingleNode("/ContentMetaData/Permissions"); content.ContentHandler.Security.ImportPermissions(permissionsNode, this._metaDataPath); return(true); }
internal void CreateNewWorkspace() { try { var state = WizardState; var newName = state.WorkspaceNewName; var sourceNodePath = state.SelectedWorkspacePath; var targetNode = PortalContext.Current.ContextNodeHead ?? NodeHead.Get(TargetPath); var sourceNode = Node.LoadNode(sourceNodePath); var contentTypeName = sourceNode.Name; Content workspace = null; workspace = ContentTemplate.HasTemplate(contentTypeName) ? ContentTemplate.CreateTemplated(Node.LoadNode(targetNode.Id), ContentTemplate.GetTemplate(contentTypeName), newName) : Content.CreateNew(contentTypeName, Node.LoadNode(targetNode.Id), newName); workspace.Fields["Description"].SetData(state.WorkspaceNewDescription); workspace.Save(); var newPath = new StringBuilder(PortalContext.Current.OriginalUri.GetLeftPart(UriPartial.Authority)).Append(targetNode.Path).Append("/").Append(newName); NewWorkspaceLink.HRef = newPath.ToString(); } catch (Exception exc) //logged { Logger.WriteException(exc); HasError = true; ErrorMessageControl.Visible = true; ErrorMessageControl.Text = exc.Message; // log exception } }
private void BuildAfterSubmitForm_ContentView(SNC.Content formitem) { if (CurrentForm == null) { return; } //FormItem fi = new FormItem(CurrentForm); //_cFormItem = SNC.Content.Create(fi); if (formitem == null && _formItemID != 0) { formitem = Content.Load(_formItemID); } if (formitem != null) { _cFormItem = formitem; _cvFormItem = ContentView.Create(_cFormItem, this.Page, ViewMode.New, AfterSubmitViewPath); _cvFormItem.ID = "cvAfterSubmitFormItem"; //_cvFormItem.Init += new EventHandler(_cvFormItem_Init); _cvFormItem.UserAction += new EventHandler <UserActionEventArgs>(_cvAfterSubmitFormItem_UserAction); this.Controls.Add(_cvFormItem); } else if (!string.IsNullOrEmpty(AfterSubmitViewPath)) { this.Controls.Add(Page.LoadControl(AfterSubmitViewPath)); } }
internal static List <SNC.Content> GetChildren(int contentId, string repositoryId, out SNC.Content folder) { SNC.Content content = null; content = SNC.Content.Load(contentId); if (content == null) { throw new ArgumentException("Object '" + contentId + "' is not exist in '" + repositoryId + "' repository"); } var ifolder = content.ContentHandler as IFolder; if (ifolder == null) { throw new ArgumentException("Object is not a folder (id = '" + contentId + "')"); } var contentList = new List <SNC.Content>(); foreach (var node in ifolder.Children) { contentList.Add(SNC.Content.Create(node)); } folder = content; return(contentList); }
private void UpdateReference(int contentId, string metadataPath, bool validate) { var contentInfo = new ContentInfo(metadataPath, null, XsltOptions); LogWrite(" "); LogWriteLine(contentId + "\t" + contentInfo.Name); SNC.Content content = SNC.Content.Load(contentId); if (content != null) { try { if (!contentInfo.UpdateReferences(content, validate)) { PrintFieldErrors(content, contentInfo.MetaDataPath); } } catch (Exception e) { PrintException(e, contentInfo.MetaDataPath); } } else { LogWrite("---------- Content does not exist. MetaDataPath: "); LogWrite(contentInfo.MetaDataPath); LogWrite(", ContentId: "); LogWrite(contentInfo.ContentId); LogWrite(", ContentTypeName: "); LogWrite(contentInfo.ContentTypeName); } }
private void UpdateReference(int contentId, string metadataPath) { var contentInfo = new ContentInfo(metadataPath, null); Log(ImportLogLevel.Verbose, " " + contentId + "\t" + contentInfo.Name); SNC.Content content = SNC.Content.Load(contentId); if (content != null) { try { if (!contentInfo.UpdateReferences(content)) { PrintFieldErrors(content, contentInfo.MetaDataPath); } } catch (Exception e) { PrintException(e, contentInfo.MetaDataPath); } } else { Log(ImportLogLevel.Info, "---------- Content does not exist. MetaDataPath: {0}, ContentId: {1}, ContentTypeName: {2}", contentInfo.MetaDataPath, contentInfo.ContentId, contentInfo.ContentTypeName); } }
//-- Object service tools private static Atom10FeedFormatter BuildEntry(SNC.Content content, string repositoryId) { var baseUri = GetBaseUri(); var title = content.Name; var description = GenerateAtomContent(content); var lastUpdateTime = new DateTimeOffset(content.ContentHandler.ModificationDate); var linkHref = GetEntryActionUri(baseUri, repositoryId, content.Id, "getEntry"); var feedAlternateLink = new Uri(linkHref); var feedId = linkHref; CmisObject cmisObject = new CmisObject { Properties = BuildCmisProperties(content), AllowableActions = GetAllowableActions(content) }; SyndicationFeed feed = new SyndicationFeed(title, description, feedAlternateLink, feedId, lastUpdateTime); feed.ElementExtensions.Add(cmisObject, new XmlSerializer(typeof(CmisObject))); foreach (var link in BuildLinks(content, baseUri, repositoryId)) { feed.Links.Add(link); } var formatter = new Atom10FeedFormatter(feed); return(formatter); }
protected override void CreateChildControls() { var content = Content.Create(ContextNode); var view = ContentView.Create(content, Page, ViewMode.Browse); Controls.Add(view); }
// Invalid View private void AddInvalidView() { var votingNode = ContextNode as Voting; if (votingNode == null) { Controls.Add(new Literal { Text = ResourceManager.Current.GetString("Voting", "ContextNodeError") }); return; } if (votingNode.InvalidSurveyPage == null) { Controls.Add(new Literal { Text = ResourceManager.Current.GetString("Voting", "InvalidSurveyPageError") }); return; } var landingContent = Content.Create(votingNode.InvalidSurveyPage); var landingCv = ContentView.Create(landingContent, Page, ViewMode.Browse, "/Root/Global/contentviews/WebContentDemo/Browse.ascx"); if (landingCv == null) { Controls.Add(new Literal { Text = ResourceManager.Current.GetString("Voting", "ContentViewCreateError") }); return; } Controls.Add(landingCv); }
//========================================================================================= Helper methods private static void AddContentListField(ContentRepository.Content content) { if (content == null) { return; } var contentList = ContentList.GetContentListByParentWalk(content.ContentHandler); if (contentList == null) { return; } //build longtext field for custom status messages var fs = new LongTextFieldSetting { ShortName = "LongText", Name = "#" + ContentNamingHelper.GetNameFromDisplayName(content.Name, content.DisplayName) + "_status", DisplayName = content.DisplayName + " status", Icon = content.Icon }; contentList.AddOrUpdateField(fs); }
/// <summary> /// Gets the number of participants. /// </summary> /// <param name="item">The CalendarEvent item.</param> /// <returns>Number of approved participants.</returns> private static int GetNumberOfParticipants(Node item) { var regForm = item.GetReference <Node>("RegistrationForm"); if (regForm != null) { var qResult = ContentQuery.Query("+Type:eventregistrationformitem +ParentId:@0", new QuerySettings { EnableAutofilters = FilterStatus.Disabled, EnableLifespanFilter = FilterStatus.Disabled }, regForm.Id); var i = 0; foreach (var node in qResult.Nodes) { var subs = Content.Create(node); var guests = 0; int.TryParse(subs["GuestNumber"].ToString(), out guests); i += (guests + 1); } return(i); } return(0); }
public void Content_UsingFieldControls_ReadWriteWithConversion() { Node automobileNode = LoadOrCreateAutomobile(@"<?xml version='1.0' encoding='utf-8'?> <ContentType name='Automobile' parentType='GenericContent' handler='ContentRepository.Tests.ContentHandlers.AutomobileHandler' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'> <Fields> <Field name='Manufacturer' type='ShortText'> <Configuration> <Compulsory>true</Compulsory> <MaxLength>100</MaxLength> <Format>TitleCase</Format> </Configuration> </Field> <Field name='Driver' type='ShortText'> <Configuration> <Compulsory>true</Compulsory> <MaxLength>100</MaxLength> </Configuration> </Field> <Field name='BodyColor' type='Color'> <Bind property='BodyColor' /> </Field> </Fields> </ContentType> ", "Automobile12", "Trabant", "Netudki"); SNC.Content automobileContent = SNC.Content.Create(automobileNode); automobileContent["BodyColor"] = Color.Red; automobileContent.Save(); automobileContent = SNC.Content.Load(automobileContent.ContentHandler.Id); ColorEditorControl colorControl = new ColorEditorControl(); ColorControlAccessor colorControlAcc = new ColorControlAccessor(colorControl); colorControl.FieldName = "BodyColor"; colorControlAcc.ConnectToField(automobileContent.Fields["BodyColor"]); ShortText manuControl = new ShortText(); ShortTextAccessor manuControlAcc = new ShortTextAccessor(manuControl); manuControl.FieldName = "Manufacturer"; manuControlAcc.ConnectToField(automobileContent.Fields["Manufacturer"]); ShortText driverControl = new ShortText(); ShortTextAccessor driverControlAcc = new ShortTextAccessor(driverControl); driverControl.FieldName = "Driver"; driverControlAcc.ConnectToField(automobileContent.Fields["Driver"]); string colorString = colorControl.textBox1.Text; Color color = colorControl.textBox1.BackColor; string manu = manuControlAcc.Text; string driver = driverControlAcc.Text; Assert.IsTrue(colorString == "#FF0000", "#1"); Assert.IsTrue(color == ColorField.ColorFromString(ColorField.ColorToString(Color.Red)), "#2"); Assert.IsTrue(manu == "Trabant", "#2"); Assert.IsTrue(driver == "Netudki", "#2"); //-- Ha nincs hiba: sikeres }
// Thank You View private void AddThankYouView() { var votingNode = ContextNode as Voting; if (votingNode == null) { Controls.Add(new Literal { Text = ResourceManager.Current.GetString("Voting", "ContextNodeError") }); return; } if (votingNode.LandingPage == null) { Controls.Add(new Literal { Text = ResourceManager.Current.GetString("Voting", "LandingPageError") }); return; } var landingContent = Content.Create(votingNode.LandingPage); if (landingContent == null) { Controls.Add(new Literal { Text = ResourceManager.Current.GetString("Voting", "ContentCreateError") }); return; } var landingCv = ContentView.Create(landingContent, Page, ViewMode.Browse, votingNode.GetReference <Node>("LandingPageContentView") != null ? votingNode.GetReference <Node>("LandingPageContentView").Path : "/Root/Global/contentviews/WebContentDemo/Browse.ascx"); if (landingCv == null) { Controls.Add(new Literal { Text = ResourceManager.Current.GetString("Voting", "ContentViewCreateError") }); return; } Controls.Add(landingCv); //if (MoreFilingIsEnabled && UserVoted && VotingPortletMode == PortletMode.VoteAndGotoResult) //{ // var lb = landingCv.FindControl("VotingAndResult") as LinkButton; // if (lb == null) // { // Controls.Add(new Literal { Text = ResourceManager.Current.GetString("Voting", "CannotFindLink") }); // return; // } // lb.Text = ResourceManager.Current.GetString("Voting", "GoToResultLink"); // lb.Click += LbClick; // lb.Visible = true; //} }
public void Content_UsingFieldControls_ReadComplexProperties() { Node automobileNode = CreateNewAutomobileAndSave(@"<?xml version='1.0' encoding='utf-8'?> <ContentType name='Automobile' parentType='GenericContent' handler='ContentRepository.Tests.ContentHandlers.AutomobileHandler' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'> <Fields> <Field name='Modified' type='WhoAndWhen'> <Bind property='ModifiedBy' /> <Bind property='ModificationDate' /> </Field> <Field name='Manufacturer' type='ShortText'> <Configuration> <Compulsory>true</Compulsory> <MaxLength>100</MaxLength> <Format>TitleCase</Format> </Configuration> </Field> <Field name='Driver' type='ShortText'> <Configuration> <Compulsory>true</Compulsory> <MaxLength>100</MaxLength> </Configuration> </Field> </Fields> </ContentType> ", "Automobile12", "Trabant", "Netudki"); SNC.Content automobileContent = SNC.Content.Create(automobileNode); WhoAndWhen whoAndWhenControl = new WhoAndWhen(); WhoAndWhenAccessor whoAndWhenAcc = new WhoAndWhenAccessor(whoAndWhenControl); whoAndWhenControl.FieldName = "Modified"; whoAndWhenAcc.ConnectToField(automobileContent.Fields["Modified"]); //automobileContent.Fields["Modified"].ConnectToView(whoAndWhenControl); ShortText manuControl = new ShortText(); ShortTextAccessor manuControlAcc = new ShortTextAccessor(manuControl); manuControl.FieldName = "Manufacturer"; manuControlAcc.ConnectToField(automobileContent.Fields["Manufacturer"]); //automobileContent.Fields["Manufacturer"].ConnectToView(manuControl); ShortText driverControl = new ShortText(); ShortTextAccessor driverControlAcc = new ShortTextAccessor(driverControl); driverControl.FieldName = "Driver"; driverControlAcc.ConnectToField(automobileContent.Fields["Driver"]); //automobileContent.Fields["Driver"].ConnectToView(driverControl); string who = whoAndWhenControl.label1.Text; string when = whoAndWhenControl.label2.Text; string manu = manuControlAcc.Text; string driver = driverControlAcc.Text; Assert.IsFalse(String.IsNullOrEmpty(who), "#1"); Assert.IsFalse(String.IsNullOrEmpty(when), "#2"); Assert.IsFalse(String.IsNullOrEmpty(manu), "#3"); Assert.IsFalse(String.IsNullOrEmpty(driver), "#4"); }
internal static SNC.Content GetContent(int contentId, string repositoryId) { SNC.Content content = null; content = SNC.Content.Load(contentId); if (content == null) { throw new ArgumentException("Object '" + contentId + "' is not exist in '" + repositoryId + "' repository"); } return(content); }
private static string GenerateAtomContent(SNC.Content content) { return(String.Concat( "Name: ", content.Name, ", type: ", String.IsNullOrEmpty(content.ContentType.DisplayName) ? content.ContentType.Name : content.ContentType.DisplayName, content.ContentHandler is IFolder ? ". This object can contain other objects" : "", ". ", String.IsNullOrEmpty(content.ContentType.Description) ? "" : content.ContentType.Description )); }
protected override ContentView GetContentView(Content newContent) { if (!string.IsNullOrEmpty(ContentViewPath)) { return(base.GetContentView(newContent)); } var contentList = ContentList.GetContentListByParentWalk(GetContextNode()); if (contentList != null) { //try to find a content view at /Root/.../MyList/WorkflowTemplates/MyWorkflow.ascx var wfTemplatesPath = RepositoryPath.Combine(contentList.Path, "WorkflowTemplates"); var viewPath = RepositoryPath.Combine(wfTemplatesPath, newContent.Name + ".ascx"); if (Node.Exists(viewPath)) { return(ContentView.Create(newContent, Page, ViewMode.InlineNew, viewPath)); } //try to find it by type name, still locally viewPath = RepositoryPath.Combine(wfTemplatesPath, newContent.ContentType.Name + ".ascx"); if (Node.Exists(viewPath)) { return(ContentView.Create(newContent, Page, ViewMode.InlineNew, viewPath)); } //last attempt: global view for the workflow type return(ContentView.Create(newContent, Page, ViewMode.InlineNew, "StartWorkflow.ascx")); } else { var viewPath = string.Format("{0}/{1}/{2}", Repository.ContentViewFolderName, newContent.ContentType.Name, "StartWorkflow.ascx"); var resolvedPath = string.Empty; if (!SkinManager.TryResolve(viewPath, out resolvedPath)) { resolvedPath = RepositoryPath.Combine(Repository.SkinGlobalFolderPath, SkinManager.TrimSkinPrefix(viewPath)); if (!Node.Exists(resolvedPath)) { resolvedPath = string.Empty; } } if (!string.IsNullOrEmpty(resolvedPath)) { return(ContentView.Create(newContent, Page, ViewMode.InlineNew, resolvedPath)); } } return(base.GetContentView(newContent)); }
private static ContentView CreateFromViewRoot(SNC.Content content, System.Web.UI.Page aspNetPage, ViewMode mode, string viewRoot) { // ways to call this function: // - absolute root: "/Root/Global/contentviews" // - relative root: "$skin/contentviews" // - empty string: "" string resolvedPath = ResolveContentViewPath(content, mode, viewRoot); return(string.IsNullOrEmpty(resolvedPath) ? null : CreateFromActualPath(content, aspNetPage, mode, resolvedPath)); }
public override object Execute(ContentRepository.Content content, params object[] parameters) { var aspect = content.ContentHandler as Aspect; if (aspect == null) { throw new InvalidOperationException("This action only works with Aspect content items."); } var result = aspect.FieldSettings.Select(x => x.ToFieldInfo()).ToArray(); return(result); }
public bool SetMetadata(SNC.Content content, string currentDirectory, bool isNewContent, bool needToValidate, bool updateReferences) { if (_xmlDoc == null) { return(true); } _transferringContext = new ImportContext( _xmlDoc.SelectNodes("/ContentMetaData/Fields/*"), currentDirectory, isNewContent, needToValidate, updateReferences); bool result = content.ImportFieldData(_transferringContext); _contentId = content.ContentHandler.Id; return(result); }
public void Content_CarContentChoiceField() { SNC.Content content = SNC.Content.Load(String.Concat(_testRoot.Path, "/Car123")); if (content == null) { content = SNC.Content.CreateNew("Car", _testRoot, "Car123"); } content["Style"] = new List <string>(new string[] { "Sedan" }); content.Save(); content = SNC.Content.Load(String.Concat(_testRoot.Path, "/Car123")); Assert.IsTrue(((List <string>)content["Style"])[0] == "Sedan"); }
protected override string CreateEmailBody(bool isHtml) { string emailText = ""; ContentRepository.Content c = ContentRepository.Content.Create(this); bool first = true; foreach (var kvp in c.Fields) { Field f = kvp.Value; if (!f.Name.StartsWith("#") || f.Name == "Email") { continue; } if (first) { first = false; } else { emailText = isHtml ? string.Concat(emailText, "<br/>") : string.Concat(emailText, "\n\r\n"); } emailText = string.Concat(emailText, f.DisplayName, ": "); foreach (string b in f.FieldSetting.Bindings) { emailText = string.Concat(emailText, Convert.ToString(this[b])); } } emailText = isHtml ? string.Concat(emailText, "<br/>") : string.Concat(emailText, "\n\r\n"); emailText = string.Concat(emailText, ResourceManager.Current.GetString("EventRegistration", "ToCancel")); emailText = isHtml ? string.Concat(emailText, "<br/>") : string.Concat(emailText, "\n\r\n"); emailText = isHtml ? string.Concat(emailText, "<a href=", GenerateCancelLink(), @""">", GenerateCancelLink(), "</a>") : string.Concat(emailText, GenerateCancelLink()); if (_admin) { emailText = isHtml ? string.Concat(emailText, "<br/>") : string.Concat(emailText, "\n\r\n"); emailText = string.Concat(emailText, ResourceManager.Current.GetString("EventRegistration", "ToApprove")); emailText = isHtml ? string.Concat(emailText, "<br/>") : string.Concat(emailText, "\n\r\n"); emailText = isHtml ? string.Concat(emailText, "<a href=", GenerateApproveLink(), @""">", GenerateApproveLink(), "</a>") : string.Concat(emailText, GenerateApproveLink()); } return(emailText); }
public void Content_UsingFields_WriteNodeAttribute() { string contentTypeDef = @"<?xml version='1.0' encoding='utf-8'?> <ContentType name='Automobile' parentType='GenericContent' handler='ContentRepository.Tests.ContentHandlers.AutomobileHandler' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'> <Fields> <Field name='Name' type='ShortText' /> <Field name='Path' type='ShortText' /> <Field name='Created' type='WhoAndWhen'> <Bind property='CreatedBy' /> <Bind property='CreationDate' /> </Field> <Field name='Modified' type='WhoAndWhen'> <Bind property='ModifiedBy' /> <Bind property='ModificationDate' /> </Field> <Field name='Manufacturer' type='ShortText' /> <Field name='Driver' type='ShortText' /> </Fields> </ContentType>" ; ContentTypeInstaller.InstallContentType(contentTypeDef); Node automobileNode = Node.LoadNode(String.Concat(_testRoot.Path, "/Automobile12")); if (automobileNode != null) { automobileNode.ForceDelete(); } automobileNode = new AutomobileHandler(_testRoot); automobileNode.Name = "Automobile12"; automobileNode["Manufacturer"] = "Honda"; automobileNode["Driver"] = "Gyeby"; automobileNode.Save(); string path = automobileNode.Path; SNC.Content automobileContent = SNC.Content.Create(automobileNode); automobileContent["Index"] = 987; automobileContent.Save(); automobileNode = Node.LoadNode(path); int index = automobileNode.Index; automobileNode.ForceDelete(); Assert.IsTrue(index == 987); }
private bool Update(Node original, Dictionary <string, string> import) { var content = Content.Create(original); bool success = false; foreach (var field in content.Fields) { if (import.ContainsKey(field.Key) && !string.IsNullOrEmpty(import[field.Key])) { success = field.Value.Parse(import[field.Key]); } } content.Save(); return(success); }
internal void Initialize(SNC.Content content, ViewMode viewMode) { this.Content = content; this.FieldControls = new List <FieldControl>(); _errorControls = new List <ErrorControl>(); this.DisplayName = content.DisplayName; this.Description = content.Description; this.Icon = content.Icon; string prefixId = String.Concat("ContentView", "_", viewMode, "_"); this.ID = String.Concat(prefixId, content.ContentHandler.Id.ToString()); this.ViewMode = viewMode; this.DefaultControlRenderMode = GetDefaultControlRenderMode(viewMode); OnViewInitialize(); }
protected override object GetModel() { var sf = SmartFolder.GetRuntimeQueryFolder(); var model = Content.Create(sf); if (!this.AllowEmptySearch && SearchTextIsTooGeneric(this.QueryString)) { if (HttpContext.Current.Request.Params.AllKeys.Contains(QueryParameterName)) { this.ErrorMessage = SNSR.GetString(ContextSearchClass, "Error_GenericSearchExpression"); } return(model); } sf.Query = ReplaceTemplates(this.QueryString); var baseModel = base.GetModel() as Content; if (baseModel != null) { model.ChildrenDefinition = baseModel.ChildrenDefinition; model.ChildrenDefinition.PathUsage = PathUsageMode.NotUsed; if (FilterByContext) { var ctx = GetContextNode(); if (ctx != null) { //add filter: we search only under the current context var escapedPath = ctx.Path.Replace("(", "\\(").Replace(")", "\\)"); model.ChildrenDefinition.ContentQuery = ContentQuery.AddClause(model.ChildrenDefinition.ContentQuery, ContentQuery.AddClause(sf.Query, string.Format("InTree:\"{0}\"", escapedPath), ChainOperator.And), ChainOperator.And); } } else { if (!string.IsNullOrEmpty(sf.Query)) { model.ChildrenDefinition.ContentQuery = ContentQuery.AddClause(model.ChildrenDefinition.ContentQuery, sf.Query, ChainOperator.And); } } } ResultModel = model; return(model); }
public ActionResult CreateContent(string node, string contentName, string contentType, string templateName, string back) { AssertPermission(); node = HttpUtility.UrlDecode(node); contentName = HttpUtility.UrlDecode(contentName); contentType = HttpUtility.UrlDecode(contentType); templateName = HttpUtility.UrlDecode(templateName); back = HttpUtility.UrlDecode(back); if (string.IsNullOrEmpty(contentName)) { contentName = !string.IsNullOrEmpty(templateName) ? templateName : contentType; } var parent = Node.LoadNode(node); if (parent == null) { return(this.Redirect(back)); } //var template = SNCR.ContentTemplateResolver.Instance.GetNamedTemplate(contentType, templateName); var template = ContentTemplate.GetNamedTemplate(contentType, templateName); SNCR.Content newContent = null; if (template != null) { newContent = ContentTemplate.CreateTemplated(parent, template, contentName); } //else // SNCR.Content.CreateNew(contentType, parent, contentName, null); try { if (newContent != null) { newContent.Save(); } } catch (Exception ex) { Logger.WriteException(ex); } return(this.Redirect(back)); }