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)); } }
private ValiditySetting GetValiditySetting(SNC.Content content) { ValiditySetting result = new ValiditySetting(); //if (!String.IsNullOrEmpty(this.ValidFromPropertyName)) // result.ValidFromPropertyName = this.ValidFromPropertyName; //if (!String.IsNullOrEmpty(this.ValidTillPropertyName)) // result.ValidTillPropertyName = this.ValidTillPropertyName; // try to fetch PreviewDate value if (content.Security.HasPermission(ContentRepository.Storage.Schema.PermissionType.OpenMinor)) { result.CurrentDateTime = GetPreviewDate(); } // reads property values result.Fill(content); // if error has been occured while parsing property values, returns null. if (!result.IsValid) { return(null); } return(result); }
private void BuildAfterSubmitForm(SNC.Content formitem) { if (!string.IsNullOrEmpty(AfterSubmitViewPath)) { BuildAfterSubmitForm_ContentView(formitem); } else { Controls.Add(new LiteralControl(string.Concat("<div class=\"sn-form-submittext\">", CurrentForm.AfterSubmitText, "</div>"))); Button ok = new Button(); ok.ID = "btnOk"; ok.Text = "Ok"; ok.CssClass = "sn-submit"; ok.Click += new EventHandler(ok_Click); Controls.Add(ok); } }
public void Fill(SNC.Content content) { _isValid = true; DateTimeField validFromField = content.Fields[_validFromPropertyName] as DateTimeField; DateTimeField reviewDateField = content.Fields[_reviewDatePropertyName] as DateTimeField; DateTimeField archiveDateField = content.Fields[_archiveDatePropertyName] as DateTimeField; DateTimeField validTillField = content.Fields[_validTillPropertyName] as DateTimeField; if (_isValid) { _validFrom = Convert.ToDateTime(validFromField.GetData()); _reviewDate = Convert.ToDateTime(reviewDateField.GetData()); _archiveDate = Convert.ToDateTime(archiveDateField.GetData()); _validTill = Convert.ToDateTime(validTillField.GetData()); } }
//-- Methods ----------------------------------------------------- private void CreateNewFormItem() { if (CurrentForm == null) { return; } var act = CurrentForm.GetAllowedChildTypes(); var allowedType = act.FirstOrDefault(ct => ct.IsInstaceOfOrDerivedFrom("FormItem")); var typeName = allowedType == null ? "FormItem" : allowedType.Name; _cFormItem = SNC.Content.CreateNew(typeName, CurrentForm, null); try { if (string.IsNullOrEmpty(ContentViewPath)) { _cvFormItem = ContentView.Create(_cFormItem, this.Page, ViewMode.New); } else { _cvFormItem = ContentView.Create(_cFormItem, this.Page, ViewMode.New, ContentViewPath); } _cvFormItem.ID = "cvNewFormItem"; _cvFormItem.Init += new EventHandler(_cvFormItem_Init); _cvFormItem.UserAction += new EventHandler <UserActionEventArgs>(_cvFormItem_UserAction); this.Controls.Add(_cvFormItem); } catch (Exception ex) //logged { Logger.WriteException(ex); this.Controls.Clear(); this.Controls.Add(new LiteralControl("ContentView error: " + ex.Message)); } }
private void BuildContentView(string contentTypeName, Node parent, ViewMode viewMode) { var viewPath = string.Empty; #region creates container) if (_container == null) { CreateContainer(); } else { _container.Controls.Clear(); //this.Controls.Remove(_container); } if (this._container.Parent == null) { this.Controls.Add(this._container); } #endregion #region creates new content or loads an existing one // when we are in InlineNew creates an empty content if (viewMode == ViewMode.InlineNew) { if (!string.IsNullOrEmpty(contentTypeName) && !((GenericContent)PortalContext.Current.ContextNode).IsAllowedChildType(contentTypeName)) { var ct = ContentType.GetByName(contentTypeName); this._errorMessage = string.Format(SNSR.GetString("SingleContentPortlet", "TypeIsNotAllowed"), ct != null ? Content.Create(ct).DisplayName : contentTypeName); ShowSimpleErrorMessage(); return; } _content = SNC.Content.CreateNew(contentTypeName, parent, string.Empty); } // when the portlet is in browse, edit, inlineedit states, loads the content if (viewMode == ViewMode.Browse || viewMode == ViewMode.Edit || viewMode == ViewMode.InlineEdit) { Node node = Node.LoadNode(this.AbsoulteContentPath); // check if can select a single node (ie smartfolderex) ICustomSingleNode singleNode = node as ICustomSingleNode; // select single node if (singleNode != null) { node = singleNode.SelectedItem(); } if (node == null) { _content = null; } else { _content = SNC.Content.Create(node); } } #endregion if (viewMode == ViewMode.InlineEdit || viewMode == ViewMode.Edit) { this._displayMode = GetViewModeName(ViewMode.Edit); } // if content does not exist stop creating controls. if (_content == null) { this._errorMessage = String.Format(HttpContext.GetGlobalResourceObject("SingleContentPortlet", "PathNotFound") as string, AbsoulteContentPath); return; } #region checks validity // if content is not valid, exit the method, and an empty contol will be shown to the user. if (this.ValidationSetting != ValidationOption.DontCheckValidity) { //Use cache setting for deciding if we need to check content expiration. //This code will not run if the user is in one of the administrator groups. //Equivalent to: !PortalContext.IsInAdminGroup(User.Current, AdminGroupPaths) if (PortalContext.Current.LoggedInUserCacheEnabled) { _validitySetting = GetValiditySetting(_content); if (_validitySetting != null) { // User has been set the ValidationSetting, // and checks the content will be displayed or not. // if the content is not visible, just return (and don't do anything else) // otherwise the content processing will be going on. switch (this.ValidationSetting) { case ValidationOption.ShowAllValid: if (!_validitySetting.ShowAllValidContent) { return; } break; case ValidationOption.ShowValidButArchived: if (!_validitySetting.ShowValidAndArchived) { return; } break; case ValidationOption.ShowValidButNotArchived: if (!_validitySetting.ShowValidAndNotArchived) { return; } break; case ValidationOption.DontCheckValidity: // not used default: break; } } } } #endregion viewPath = GetViewPath(); // try to create ContentView which contains all webcontrols of the content try { if (this.UseUrlPath) { _contentView = ContentView.Create(_content, this.Page, viewMode, String.IsNullOrEmpty(this.ContentViewPath) ? viewPath : this.ContentViewPath); } else { _contentView = ContentView.Create(_content, this.Page, viewMode, viewPath); } _container.Controls.Remove(_contentView); } catch (Exception e) //logged { Logger.WriteException(e); this._errorMessage = String.Format("Message: {0} {1} Source: {2} {3} StackTrace: {4} {5}", e.Message, Environment.NewLine, e.Source, Environment.NewLine, e.StackTrace, Environment.NewLine); return; } _contentView.UserAction += _contentView_UserAction; _contentView.CommandButtonsAction += _contentView_CommandButtonsAction; _container.Controls.Add(_contentView); }