Example #1
0
        protected override ValidationResult validateModule()
        {
            ValidationResult returnValue = base.validateModule();

            if (!returnValue.IsValid)
            {
                return(returnValue);
            }
            ModuleNavigationAction navigationAction = this.GetNavigationActionByTagName("{DrillDownLink}");

            //modules die opzelfde pagina blijven moet in <a> de class worden gezet en wordt er een onclick functie in aangemaakt. Hierom moeten dit complete links zijn en niet alleen url
            if (navigationAction.NavigationType == NavigationTypeEnum.ShowDetailsInModules)
            {
                if (this.Content.Contains("{DrillDownUrl}"))
                {
                    returnValue.Message += "Modules met navigatie die op dezelfde pagina blijft mogen geen tags bevatten met {DrillDownUrl}. Gebruik {DrillDownLink} hiervoor in de plaats.<br/>";
                }
            }
            if (Utils.StringHelper.CountOccurences(this.Content, "{List}") > 1)
            {
                returnValue.Message += "Module mag maar 1 keer tag bevatten: {List} (controleer ook code)<br/>";
            }
            if (Utils.StringHelper.CountOccurences(this.Content, "{/List}") > 1)
            {
                returnValue.Message += "Module mag maar 1 keer sluit-tag bevatten: {/List} (controleer ook code)<br/>";
            }
            return(returnValue);
        }
Example #2
0
        public override string Publish2(CmsPage page)
        {
            string html = base.Publish2(page);

            try
            {
                ModuleNavigationAction navAction = NavigationActions[0];
                string navigationUrl             = navAction.NavigationPage != null ? navAction.NavigationPage.RelativeUrl : "";
                string refreshModules            = navAction.RefreshModules == null ? "" : String.Join(",", navAction.RefreshModules);
                html += String.Format(@"
<input type=""hidden"" id=""hiddenModuleID{0:N}"" name=""hiddenModuleID"" value=""{0}""/>
<input type=""hidden"" id=""hiddenModuleType{0:N}"" name=""hiddenModuleType"" value=""{1}""/>
<input type=""hidden"" id=""hiddenModuleNavigationType{0:N}"" name=""hiddenModuleNavigationType"" value=""{2}""/>
<input type=""hidden"" id=""hiddenRefreshModules{0:N}"" name=""hiddenRefreshModules"" value=""{3}""/>
<input type=""hidden"" id=""hiddenNavigationUrl{0:N}"" name=""hiddenNavigationUrl"" value=""{4}""/>
", this.ID, this.Type, navAction.NavigationType, refreshModules, navigationUrl);

                html = ConvertTags(html);
            }
            catch (Exception ex)
            {
                html = base.HandlePublishError(ex);
            }
            //html += "</form>";
            return(html);
        }
Example #3
0
        protected override ValidationResult validateModule()
        {
            ValidationResult returnValue = base.validateModule();

            if (!returnValue.IsValid)
            {
                return(returnValue);
            }
            ModuleNavigationAction navigationAction = this.GetNavigationActionByTagName("{DrillDownLink}");

            if (navigationAction.NavigationType == NavigationTypeEnum.ShowDetailsInModules)
            {
                if (this.Content.Contains("{DrillDownUrl}"))
                {
                    returnValue.Message += "Modules met navigatie die op dezelfde pagina blijft mogen geen tags bevatten met {DrillDownUrl}.<br/>";
                }
            }
            if (Utils.StringHelper.CountOccurences(this.Content, "{List}") > 1)
            {
                returnValue.Message += "Module mag maar 1 keer tag bevatten: {List} (controleer ook code)<br/>";
            }
            if (Utils.StringHelper.CountOccurences(this.Content, "{/List}") > 1)
            {
                returnValue.Message += "Module mag maar 1 keer sluit-tag bevatten: {/List} (controleer ook code)<br/>";
            }
            return(returnValue);
        }
Example #4
0
        public override PostResult HandlePost(CmsPage page, Dictionary <string, string> FormParameters)
        {
            ModuleNavigationAction navigationAction = GetNavigationActionByTagName("{SubmitButton}");
            PostResult             postResult       = base.getNewPostResult(navigationAction);
            string errorMsg = "";

            try
            {
                //op save button geklikt
                BaseUser user = WebSessionHelper.CurrentSiteUser;
                if (user == null)
                {
                    errorMsg += "Geen geldige gebruiker geladen. U moet eerst aanmelden";
                }
                else
                {
                    bool validPassword = true;
                    if (FormParameters.ContainsKey("CurrentPasswordTextbox"))
                    {
                        //validPassword = user...;
                    }
                    user.ForeName   = FormParameters.ContainsKey("ForeNameTextbox") ? FormParameters["ForeNameTextbox"] : "";
                    user.NamePrefix = FormParameters.ContainsKey("NamePrefixTextbox") ? FormParameters["NamePrefixTextbox"] : "";
                    user.Name       = FormParameters.ContainsKey("NameTextbox") ? FormParameters["NameTextbox"] : "";
                    user.Email      = FormParameters.ContainsKey("EmailTextbox") ? FormParameters["EmailTextbox"] : "";
                    //user.Gender = FormParameters.ContainsKey("Gender") ? FormParameters["Gender"] : "";
                    //user.BirthDate = FormParameters.ContainsKey("BirthDateTextbox") ? Convert.ToDateTime(FormParameters["BirthDateTextbox"]) : "";
                    user.Address    = FormParameters.ContainsKey("AddressTextbox") ? FormParameters["AddressTextbox"] : "";
                    user.Postalcode = FormParameters.ContainsKey("PostcodeTextbox") ? FormParameters["PostcodeTextbox"] : "";
                    user.City       = FormParameters.ContainsKey("CityTextbox") ? FormParameters["CityTextbox"] : "";
                    user.Country    = FormParameters.ContainsKey("CountryTextbox") ? FormParameters["CountryTextbox"] : "";


                    string newPassword = FormParameters.ContainsKey("NewPasswordTextbox") ? FormParameters["NewPasswordTextbox"] : "";
                    if (newPassword != null && newPassword != String.Empty)
                    {
                        //check
                    }
                }
                if (errorMsg != String.Empty)
                {
                    new PostResult()
                    {
                        ErrorMessage = errorMsg
                    };
                }
                else
                {
                    postResult.HtmlResult += Regex.Match(this.Content, "{SuccessTemplate}(.*?){/SuccessTemplate}", RegexOptions.Singleline).ToString().Replace("{SuccessTemplate}", "").Replace("{/SuccessTemplate}", ""); //Publish2(page);
                }
            }
            catch (Exception ex)
            {
                postResult = base.HandlePostError(ex);
            }
            return(postResult);
        }
Example #5
0
        public override PostResult HandlePost(CmsPage page, Dictionary <string, string> FormParameters)
        {
            ModuleNavigationAction navigationAction = GetNavigationActionByTagName("{LogoutButton}");
            PostResult             postResult       = base.getNewPostResult(navigationAction);

            try
            {
                //op logout button geklikt
                WebSessionHelper.CurrentSiteUser = null;
                postResult.HtmlResult            = Publish2(page);
            }
            catch (Exception ex)
            {
                postResult = base.HandlePostError(ex);
            }
            return(postResult);
        }
Example #6
0
        protected override string getModuleStartDiv()
        {
            string moduleStartDiv            = base.getModuleStartDiv();
            ModuleNavigationAction navAction = NavigationActions[0];
            string navigationUrl             = navAction.NavigationPage != null ? navAction.NavigationPage.RelativeUrl : "";
            string refreshModules            = navAction.RefreshModules == null ? "" : String.Join(",", navAction.RefreshModules);

            moduleStartDiv += String.Format(@"
<input type=""hidden"" id=""hiddenModuleID{0:N}"" value=""{0}""/>
<input type=""hidden"" id=""hiddenModuleType{0:N}"" value=""{1}""/>
<input type=""hidden"" id=""hiddenModuleNavigationType{0:N}"" value=""{2}""/>
<input type=""hidden"" id=""hiddenRefreshModules{0:N}"" value=""{3}""/>
<input type=""hidden"" id=""hiddenNavigationUrl{0:N}"" value=""{4}""/>
", this.ID, this.Type, navAction.NavigationType, refreshModules, navigationUrl);

            return(moduleStartDiv);
        }
Example #7
0
        protected PostResult handleNavigation(string errorMsg, PostResult result)
        {
            ModuleNavigationAction navigationAction = GetNavigationActionByTagName("{SubmitButton}");

            result.NavigationType = navigationAction.NavigationType;
            if (navigationAction.NavigationType == NavigationTypeEnum.NavigateToPage && navigationAction.NavigationPage != null)
            {
                string queryString = "?errorMsg=" + errorMsg;
                //eigenlijk moet deze code verhuizen naar webform
                result.NavigationUrl = navigationAction.NavigationPage.RelativeUrl + queryString;
                //HttpContext.Current.Response.Redirect(navigationAction.NavigationPage.RelativeUrl + queryString);
            }
            else
            {
                string refreshModules = navigationAction.RefreshModules == null ? "" : String.Join(",", navigationAction.RefreshModules);
                result.RefreshModules = refreshModules;
                if (navigationAction.NavigationType == NavigationTypeEnum.NavigateToPage)
                {
                    result.ErrorMessage = "Kan niet naar pagina navigeren, omdat er geen pagina gezet is.";
                }
            }
            return(result);
        }
Example #8
0
        public override PostResult HandlePost(CmsPage page, Dictionary <string, string> FormParameters)
        {
            ModuleNavigationAction navigationAction = GetNavigationActionByTagName("{LoginButton}");
            PostResult             result           = base.getNewPostResult(navigationAction);
            string userName = FormParameters.ContainsKey("bitUsernameTextbox") ? FormParameters["bitUsernameTextbox"] : "";
            string password = FormParameters.ContainsKey("bitPasswordTextbox") ? FormParameters["bitPasswordTextbox"] : "";

            SiteUser user = SiteUser.Login(userName, password);

            if (user != null)
            {
                WebSessionHelper.CurrentSiteUser = user;
                result.HtmlResult = Publish2(page);
            }
            else
            {
                result = new PostResult()
                {
                    ErrorMessage = "Kon niet aanmelden."
                };
            }

            return(result);
        }
Example #9
0
        public override string Publish2(CmsPage page)
        {
            string html = base.Publish2(page);

            try
            {
                string drillDownUrl  = "";
                string drillDownLink = "";

                ModuleNavigationAction navigationActionDrillDown = this.GetNavigationActionByTagName("{DrillDownLink}");
                if (navigationActionDrillDown != null)
                {
                    drillDownUrl  = navigationActionDrillDown.GetNavigationUrl();
                    drillDownLink = navigationActionDrillDown.CreateNavigationHyperlink("G", refreshItself: true);
                }

                DataGroup group = null;
                if (dataType == "I")
                {
                    //als er op item wordt genavigeerd, parentgroep van item laden
                    //breadcrumb doet namelijk alleen groepen
                    DataItem item = BaseObject.GetById <DataItem>(dataId);
                    if (item != null)
                    {
                        group = item.ParentGroup;
                    }
                }
                else
                {
                    group = BaseObject.GetById <DataGroup>(dataId);
                }

                string itemTemplate = base.GetSubTemplate("{List}");
                string itemsHtml    = "";

                if (group != null)
                {
                    group.TryTranslate(this.LanguageCode);
                    string itemHtml = GetItemHtml(drillDownUrl, drillDownLink, group, itemTemplate);
                    itemsHtml = itemHtml;
                    while (group.ParentGroup != null)
                    {
                        group = group.ParentGroup;
                        group.TryTranslate(this.LanguageCode);
                        itemHtml  = GetItemHtml(drillDownUrl, drillDownLink, group, itemTemplate);
                        itemsHtml = itemHtml + itemsHtml;
                    }
                }

                html = html.Replace("<!--{List}-->" + itemTemplate + "<!--{/List}-->", itemsHtml);
                html = html.Replace("{List}" + itemTemplate + "{/List}", itemsHtml);

                html = html.Replace("{RootLink}", drillDownLink);
                html = html.Replace("{/RootLink}", "</a>");
                // html = html.Replace("{RootUrl}", drillDownUrl);
                html = html.Replace("{DrillDownUrl}", drillDownUrl);
                html = html.Replace("{ID}", Guid.Empty.ToString());
            }
            catch (Exception ex)
            {
                html = base.HandlePublishError(ex);
            }

            return(html);
        }
Example #10
0
        public override string Publish2(CmsPage page)
        {
            string html = "";

            try
            {
                if (DataCollection != null)
                {
                    PrepairTemplate(DataCollection.DataItemFields, DataCollection.DataGroupFields);
                }
                if (DataCollection == null)
                {
                    return(base.Publish2(page));
                }

                html = Content;
                string initAddress = getSetting <string>("InitialAddress");
                string initCountry = getSetting <string>("InitialCountry");
                string initSearch  = "";
                if (initAddress == null || initAddress == "")
                {
                    initSearch = "Utrecht, Nederland";
                }
                else
                {
                    if (initCountry == null || initCountry == "")
                    {
                        initCountry = "Nederland";
                    }
                    initSearch = initAddress + ", " + initCountry;
                }

                GPoint initPoint = GoogleGeocoder.GetLatLng(initSearch, page.Site.GoogleMapsKey);

                string infoBalloonFormat = base.GetSubTemplate("{Marker}");
                string sideBarRowFormat  = base.GetSubTemplate("{SideBar}");

                //LET WEL: vervanging van de datatags zoals {City} en {Address} gebeurt in javascript: BITGoogleMapModule.js --> formatHtml()
                html = html.Replace("{Marker}" + infoBalloonFormat + "{/Marker}", "");                                                        //waardes worden in js var gezet
                html = html.Replace("{SideBar}" + sideBarRowFormat + "{/SideBar}", @"<div id=""bitGooglemapsSideBar""></div>");               //waardes worden in js var gezet
                html = html.Replace("<!--{SideBar}-->" + sideBarRowFormat + "<!--{/SideBar}-->", @"<div id=""bitGooglemapsSideBar""></div>"); //waardes worden in js var gezet

                infoBalloonFormat = infoBalloonFormat.Replace("\r", "").Replace("\n", "").Replace("\t", "");
                infoBalloonFormat = infoBalloonFormat.Replace("'", "&quot;");

                sideBarRowFormat = sideBarRowFormat.Replace("\r", "").Replace("\n", "").Replace("\t", "");
                sideBarRowFormat = sideBarRowFormat.Replace("'", "&quot;");

                string drillDownUrl  = HttpContext.Current.Request.Url.LocalPath;
                string drillDownlink = "";
                ModuleNavigationAction navigationAction = this.GetNavigationActionByTagName("{DrillDownLink}");
                if (navigationAction.NavigationType == NavigationTypeEnum.NavigateToPage)
                {
                    if (navigationAction.NavigationPage != null)
                    {
                        drillDownUrl = navigationAction.NavigationPage.RelativeUrl;
                    }
                    drillDownlink = "<a href=\"{DrillDownUrl}\">";
                }

                else
                {
                    drillDownUrl = HttpContext.Current.Request.Url.LocalPath;
                    string refreshModules = String.Join(",", navigationAction.RefreshModules);
                    //haal eventuele lege waardes weg
                    refreshModules = refreshModules.Replace(",,", "");
                    if (refreshModules.EndsWith(","))
                    {
                        refreshModules = refreshModules.Remove(refreshModules.Length - 1, 1);
                    }

                    drillDownlink = "<a class=\"showDetailsInModules\" href=\"{DrillDownUrl}\" onclick=\"BITSITESCRIPT.reloadModulesOnSamePage('" + refreshModules + "', {dataid: '{ID}'})\">";
                }

                string hiddenfields = String.Format(@"
<!-- FIELDS FOR GOOGLEMAPS  -->
    <input type='hidden' id='hiddenGoogleMapsKey' value='{0}'/>
    <input type='hidden' id='hiddenInitLatitude' value='{1}'/>
    <input type='hidden' id='hiddenInitLongitude' value='{2}'/>
    <input type='hidden' id='hiddenInitZoom' value='{3}'/>
    <input type='hidden' id='hiddenDatacollectionID' value='{4}'/>
    <input type='hidden' id='hiddenInfoBalloonFormat' value='{5}'/>
    <input type='hidden' id='hiddenSideBarRowFormat' value='{6}'/>
    <input type='hidden' id='hiddenNavigationUrl' value='{7}'/>

", page.Site.GoogleMapsKey, initPoint.Lat.ToString().Replace(",", "."), initPoint.Long.ToString().Replace(",", "."), base.getSetting <string>("InitialZoom"), this.DataCollection.ID, infoBalloonFormat, sideBarRowFormat, drillDownUrl);


                html = getModuleStartDiv() + hiddenfields + html + getModuleEndDiv();
                int width = getSetting <int>("MapWidth"), height = getSetting <int>("MapHeight");

                if (width == 0)
                {
                    width = 400;
                }
                if (height == 0)
                {
                    height = 300;
                }

                html = html.Replace("{Map}", String.Format(@"<div id=""bitGoogleMap"" style=""width:{0}px;height:{1}px""></div>", width, height));



                html = html.Replace("{SearchTextBoxAddress}", String.Format(@"<input type=""text"" id=""bitGooglemapsSearchAddress"" value=""{0}"" onkeypress=""javascript:BITGOOGLEMAP.checkEnter(event);"">", initAddress));
                //onderstaande kilometers zijn bij benadering. Ze zijn namelijk ook afhankelijk van de grootte van de kaart op het scherm. Dus zoomlevel 12 is niet altijd 5 km.
                html = html.Replace("{SearchDropDownDistance}", @" <select id=""bitGooglemapsSearchDistance"">
                    <option value=""12"">5 km</option>
                    <option value=""11"">10 km</option>
                    <option value=""10"">20 km</option>
                    <option value=""9"">50 km</option>
                    <option value=""8"">100 km</option>
                    <option value=""7"">250 km</option>
                </select>");

                html = html.Replace("{SearchDropDownCountries}", @" <select id=""bitGooglemapsSearchCountry"">
                    <option value=""Nederland"">Nederland</option>
                    <option value=""Belgium"">Belgiƫ</option>
                    <option value=""Germany"">Duitsland</option>
                    <option value=""France"">Frankrijk</option>
                    <option value=""England"">Engeland</option>
                </select>");

                html = html.Replace("{SearchButton}", @"<button type=""button"" onclick=""BITGOOGLEMAP.searchAddress();""> ");
                html = html.Replace("{/SearchButton}", @"</button> ");


                html = html.Replace("{DrillDownLink}", drillDownlink);
                html = html.Replace("{/DrillDownLink}", @"</a> ");

                //vervang datafields, die blijven {tag} houden en worden pas in js vervangen door de veldwaarde
                //BITGoogleMapModule.js --> formatHtml()
                //data wordt geladen via service voor deze module
                if (navigationAction.NavigationType == NavigationTypeEnum.NavigateToPage)
                {
                    //{RewriteUrl} wordt vervangen in js
                    html = html.Replace("{DrillDownUrl}", "{RewriteUrl}");
                }
                if (DataCollection != null)
                {
                    foreach (DataField field in DataCollection.DataItemFields)
                    {
                        html = html.Replace("{" + field.Name + "}", "{" + field.MappingColumn + "}");
                    }
                }
            }
            catch (Exception ex)
            {
                html = base.HandlePublishError(ex);
            }


            return(html);
        }
Example #11
0
        public string BuildTree2(CmsPage page)
        {
            int viewMode = 1;//int.Parse(this.ViewModeCheckBoxList.SelectedValue);

            this.treeViewTemplate = base.GetSubTemplate("{TreeView}");
            this.treeNodeTemplate = base.GetSubTemplate("{TreeNode}");

            string tree      = treeViewTemplate;
            string rootNodes = "";
            string select    = "SELECT DataGroup.ID, DataGroup.Name, DataGroup.FK_Parent_Group, DataGroup.CompletePath, ";
            string from      = " FROM DataGroup ";

            if (!DataCollection.HasStaticLanguage && this.LanguageCode != "" && this.LanguageCode != Site.DefaultLanguage)
            {
                DataField titleField = DataField.GetFirst <DataField>("FK_DataCollection = '" + DataCollection.ID + "' AND MappingColumn='Title' AND type='group'");
                if (titleField.IsMultiLanguageField)
                {
                    select += "Lang.Title AS Title ";
                    from   += " JOIN DataGroupLanguage AS Lang ON DataGroup.ID = Lang.FK_DataGroup AND Lang.LanguageCode = '" + this.LanguageCode + "'";
                }
                else
                {
                    select += "DataGroup.Title ";
                }
            }
            else
            {
                select += "DataGroup.Title ";
            }

            string where = String.Format(" WHERE DataGroup.FK_DataCollection = '{0}' ", DataCollection.ID);
            string sort = getSort(DataCollection.DataGroupFields); //" ORDER BY DataGroup.OrderNumber";
            string sql  = select + from + where + sort;

            System.Data.DataTable allGroupsTable = DataBase.Get().GetDataTable(sql);

            string drillDownUrl  = "";
            string drillDownLink = "";
            ModuleNavigationAction navigationActionDrillDown = this.GetNavigationActionByTagName("{DrillDownLink}");

            if (navigationActionDrillDown != null)
            {
                drillDownUrl  = navigationActionDrillDown.GetNavigationUrl();
                drillDownLink = navigationActionDrillDown.CreateNavigationHyperlink("G", false, "BITTREEVIEW.isReloadRequired = false;");
            }


            foreach (System.Data.DataRow dataRow in allGroupsTable.Rows)//.Select("FK_Parent_Group Is Null", sort.Replace("ORDER BY ", "")))
            {
                //DataTable.Select() sorteert de items opnieuw. Dit is niet de bedoeling.
                if (dataRow["FK_Parent_Group"] == DBNull.Value)
                {
                    string rewriteUrl = CreateRewriteUrl(page, drillDownUrl, "G", new Guid(dataRow["ID"].ToString()), dataRow["CompletePath"].ToString(), dataRow["Title"].ToString());

                    string rootNode = this.treeNodeTemplate;
                    string name     = dataRow["Name"].ToString();
                    rootNode = rootNode
                               .Replace("{TreeNode.DrillDownLink}", drillDownLink)
                               .Replace("{TreeNode.Name}", dataRow["Name"].ToString())
                               .Replace("{TreeNode.Title}", dataRow["Title"].ToString())
                               .Replace("{/TreeNode.DrillDownLink}", "</a>")
                               .Replace("{TreeNode.ID}", "TreeNode" + dataRow["ID"].ToString().Replace("-", ""))
                               .Replace("{DrillDownUrl}", rewriteUrl)
                               .Replace("{ID}", dataRow["ID"].ToString())
                               .Replace("{TreeNode.ChildNodes}", this.BuildTreeNode2(page, allGroupsTable, rootNode, dataRow["ID"].ToString(), viewMode, drillDownUrl, drillDownLink));

                    rootNodes += rootNode;
                }
            }


            /* if (viewMode == 2) //groups and items
             * {
             *  foreach (DataItem item in dataCollection.Items)
             *  {
             *      TreeNode itemNode = new TreeNode();
             *      itemNode.Text = itemNode.Text;
             *      itemNode.Value = item.ID.ToString();
             *      DataCollectionTreeView.Nodes.Add(itemNode);
             *  }
             * } */
            tree = Content;
            tree = tree.Replace("<!--{TreeNode}-->" + treeNodeTemplate + "<!--{/TreeNode}-->", rootNodes);
            tree = tree.Replace("{TreeNode}" + treeNodeTemplate + "{/TreeNode}", rootNodes);
            string treeDiv = "<div class=\"bitTree\" data-tree-selected-id=\"TreeNode" + dataId.ToString("N") + "\">";

            tree = tree.Replace("<!--{TreeView}-->", treeDiv);
            tree = tree.Replace("{TreeView}", treeDiv);
            tree = tree.Replace("<!--{/TreeView}-->", "</div>");
            tree = tree.Replace("{/TreeView}", "</div>");

            return(tree);
        }
Example #12
0
        public string Publish2(CmsPage page, int currentPage, int totalResults, string sort)
        {
            string html = "";

            try
            {
                if (DataCollection != null)
                {
                    base.PrepairTemplate(DataCollection.DataItemFields, DataCollection.DataGroupFields);
                }

                html = base.Publish2(page);
                if (DataCollection == null)
                {
                    return(html);
                }

                //string drillDownUrl = "", drillDownLink = "";

                ModuleNavigationAction navigationActionDrillDown = this.GetNavigationActionByTagName("{DrillDownLink}");
                if (navigationActionDrillDown != null)
                {
                    drillDownUrl  = navigationActionDrillDown.GetNavigationUrl();
                    drillDownLink = navigationActionDrillDown.CreateNavigationHyperlink("I");
                }

                ModuleNavigationAction navigationActionEdit = this.GetNavigationActionByTagName("{EditLink}");
                if (navigationActionEdit != null)
                {
                    editUrl  = navigationActionEdit.GetNavigationUrl();
                    editLink = navigationActionEdit.CreateNavigationHyperlink("I");
                }

                if (html.Contains("{DrillUpLink}"))
                {
                    ModuleNavigationAction navigationActionDrillUp = this.GetNavigationActionByTagName("{DrillUpLink}");
                    if (navigationActionDrillUp != null)
                    {
                        drillUpUrl  = navigationActionDrillUp.GetNavigationUrl();
                        drillUpLink = navigationActionDrillUp.CreateNavigationHyperlink("G");
                    }
                }

                //getDrillDownUrlAndLink(out drillDownUrl, out drillDownLink);
                int pagesize          = getSetting <int>("MaxNumberOfRows");
                int showFromRowNumber = getSetting <int>("ShowFromRowNumber");

                string rowTemplate = base.GetSubTemplate("{List}");
                string rowsHtml    = "";
                System.Data.DataTable itemsTable = getDataTable("DataItem", "I", DataCollection.DataItemFields, currentPage, pagesize, showFromRowNumber, sort);

                foreach (System.Data.DataRow dataRow in itemsTable.Rows)
                {
                    string rowHtml    = rowTemplate;
                    string rewriteUrl = CreateRewriteUrl(page, drillDownUrl, "I", new Guid(dataRow["ID"].ToString()), dataRow["CompletePath"].ToString(), dataRow["Title"].ToString());
                    rowHtml = rowHtml.Replace("{DrillDownLink}", drillDownLink)
                              .Replace("{/DrillDownLink}", "</a>")
                              .Replace("{DrillDownUrl}", rewriteUrl);
                    if ((WebSessionHelper.CurrentSiteUser != null && WebSessionHelper.CurrentSiteUser.ID.ToString() == dataRow["FK_User"].ToString()) ||
                        (dataRow["FK_User"].ToString() == "" && dataRow["FK_BitplateUser"].ToString() == "" && WebSessionHelper.CurrentBitplateUser != null) ||
                        (WebSessionHelper.CurrentBitplateUser != null && WebSessionHelper.CurrentBitplateUser.ID.ToString() == dataRow["FK_BitplateUser"].ToString()))
                    {
                        rowHtml = rowHtml.Replace("{EditLink}", editLink)
                                  .Replace("{/EditLink}", "</a>");
                    }
                    else
                    {
                        rowHtml = Regex.Replace(rowHtml, "{EditLink}(.*?){/EditLink}", "");
                    }

                    foreach (System.Data.DataColumn column in dataRow.Table.Columns)
                    {
                        rowHtml = ReplaceTag(rowHtml, dataRow, column);

                        //rowHtml = rowHtml.Replace("{" + column.ColumnName + "}", dataRow[column.ColumnName].ToString());
                        if (rowHtml.Contains("{FileList1}"))
                        {
                            rowHtml = fillExtraFilesSubTemplate(rowHtml, dataRow["ID"].ToString(), "");
                        }
                        if (rowHtml.Contains("{ImageList1}"))
                        {
                            rowHtml = fillExtraImagesSubTemplate(rowHtml, dataRow["ID"].ToString(), "");
                        }
                    }
                    rowsHtml += rowHtml;
                }

                html = html.Replace("<!--{List}-->" + rowTemplate + "<!--{/List}-->", rowsHtml);
                html = html.Replace("{List}" + rowTemplate + "{/List}", rowsHtml);

                //parent-tags kunnen ook buiten de list-template staan. dus buiten {List} en {/List}
                //dan ook deze tags vervangen, ook als er geen rows zouden zijn. (parent kan er nog wel zijn)
                if (html.Contains("{Parent") || html.Contains("{DrillUp"))
                {
                    //dataId = dataId == Guid.Empty ? Guid.Parse(getSetting<string>("SelectGroupID")) : dataId;
                    System.Data.DataRow parentGroupRow = base.getDataParentGroupRow(dataId);
                    html = ReplaceDrillUpTag(page, html, parentGroupRow["FK_Parent_Group"].ToString());
                    foreach (System.Data.DataColumn column in parentGroupRow.Table.Columns)
                    {
                        html = html.Replace("{" + column.ColumnName + "}", parentGroupRow[column.ColumnName].ToString());
                    }
                }
                if (pagesize > 0 && totalResults == 0)
                {
                    totalResults = getTotalCount("I");
                }
                else if (totalResults == 0)
                {
                    totalResults = itemsTable.Rows.Count;
                }
                html = html.Replace("{Pager}", CreatePager(currentPage, totalResults, pagesize));
                html = html.Replace("{NumberOfResults}", totalResults.ToString());

                foreach (Tag tag in this.GetSortLinksTags(currentPage, pagesize))
                {
                    html = html.Replace(tag.Name, tag.ReplaceValue)
                           .Replace(tag.CloseTag, tag.ReplaceValueCloseTag);
                }

                bool hideWhenNoData = getSetting <bool>("HideWhenNoData");
                if (hideWhenNoData && totalResults == 0)
                {
                    html = getModuleStartDiv() + getModuleEndDiv();
                }
            }
            catch (Exception ex)
            {
                html = base.HandlePublishError(ex);
            }
            return(html);
        }
Example #13
0
        //internal string Publish2(out string title, out string metaDescription, out string metaKeywords)
        //{
        //    string html = Publish2();
        //    title = this.ItemTitle;
        //    metaDescription = this.ItemMetaDescription;
        //    metaKeywords = this.ItemMetaKeywords;
        //    return html;
        //}


        public override PostResult HandlePost(CmsPage page, Dictionary <string, string> FormParameters)
        {
            this.dataId = (FormParameters.ContainsKey("dataid")) ? Guid.Parse(FormParameters["dataid"]) : Guid.NewGuid();
            PostResult result       = new PostResult();
            string     messageLabel = "<ul>";
            bool       itemValid    = true;
            DataItem   item;

            if (dataId == Guid.Empty)
            {
                item = new DataItem();
            }
            else
            {
                item = BaseObject.GetById <DataItem>(dataId);
            }
            Type dataFieldType = typeof(DataItem);

            foreach (DataField dataField in this.DataCollection.DataItemFields)
            {
                if (FormParameters.ContainsKey(dataField.Name))
                {
                    string value = FormParameters[dataField.Name];
                    if (value == "")
                    {
                        value = dataField.DefaultValue;
                    }

                    if (dataField.FieldRule == FieldRuleEnum.Required)
                    {
                        if (value == "")
                        {
                            messageLabel += "<li>" + dataField.Name + "</li>";
                            itemValid     = false;
                        }
                    }

                    if (dataField.FieldRule == FieldRuleEnum.ReadOnly)
                    {
                    }

                    switch (dataField.FieldType)
                    {
                    case FieldTypeEnum.DropDown:
                        DataLookupValue lookUpValue = BaseObject.GetById <DataLookupValue>(Guid.Parse(value));
                        dataFieldType.GetProperty(dataField.MappingColumn).SetValue(item, lookUpValue, null);
                        break;

                    case FieldTypeEnum.CheckboxList:
                        string[] selectedLookUpIDs = value.Split(',');
                        foreach (string selectedLookUpID in selectedLookUpIDs)
                        {
                            DataLookupValue lookUpValue1 = BaseObject.GetById <DataLookupValue>(Guid.Parse(selectedLookUpID));
                            item.LookupValues1.Add(lookUpValue1);
                        }
                        break;

                    default:
                        dataFieldType.GetProperty(dataField.MappingColumn).SetValue(item, value, null);
                        break;
                    }
                }
            }

            if (itemValid)
            {
                if (WebSessionHelper.CurrentBitplateUser != null)
                {
                    item.BitplateUser = WebSessionHelper.CurrentBitplateUser;
                }

                if (WebSessionHelper.CurrentSiteUser != null)
                {
                    item.User = WebSessionHelper.CurrentSiteUser;
                }

                item.DataCollection = this.DataCollection;
                Guid parentGroupId;
                Guid.TryParse(this.getSetting <string>("SelectGroupID"), out parentGroupId);
                string strParentGroupID = "";
                if (parentGroupId != Guid.Empty && item.ParentGroup == null)
                {
                    item.ParentGroup = BaseObject.GetById <DataGroup>(parentGroupId);
                    strParentGroupID = parentGroupId.ToString();
                }
                DataItem checkItemNameExist = BaseObject.GetFirst <DataItem>("Name = '" + item.Name + "' AND FK_Parent_Group = '" + strParentGroupID + "'");
                if (checkItemNameExist == null || checkItemNameExist != null && checkItemNameExist.ID == this.dataId)
                {
                    bool isNewItemActive = false;

                    if (item.BitplateUser != null || item.User != null)
                    {
                        isNewItemActive = this.getSetting <bool>("IsNewItemActiveKownUsers");
                    }
                    else
                    {
                        isNewItemActive = this.getSetting <bool>("IsNewItemActiveUnkownUsers");
                    }

                    //this.getSetting<bool>("IsNewItemActive");
                    item.Active = (isNewItemActive) ? ActiveEnum.Active : ActiveEnum.InActive;
                    item.Save();
                }
                else
                {
                    itemValid    = false;
                    messageLabel = "<ul><li>Er bestaat al een item met deze naam in de groep.<li>";
                }
            }
            ModuleNavigationAction navigationActionDrillDown = this.GetNavigationActionByTagName("{SubmitButton}");

            result.ErrorMessage   = messageLabel + "</ul>";
            result.Success        = itemValid;
            result.NavigationType = navigationActionDrillDown.NavigationType;
            if (navigationActionDrillDown.NavigationType == NavigationTypeEnum.NavigateToPage)
            {
                result.NavigationUrl = navigationActionDrillDown.NavigationPage.GetRewriteUrl();
            }
            else
            {
                result.HtmlResult += Regex.Match(this.Content, "{SuccessTemplate}(.*?){/SuccessTemplate}", RegexOptions.Singleline).ToString().Replace("{SuccessTemplate}", "").Replace("{/SuccessTemplate}", "");
            }

            return(result);
        }
Example #14
0
        //public string ConvertHeaderFooterTags(string html)
        //{
        //    //{Parent.Naam}
        //    string header = Regex.Match(html, "<HeaderTemplate>(.*?)</HeaderTemplate>", RegexOptions.Singleline).ToString();
        //    html = ConvertHtml(html, header);
        //    string footer = Regex.Match(html, "<FooterTemplate>(.*?)</FooterTemplate>", RegexOptions.Singleline).ToString();
        //    html = ConvertHtml(html, footer);
        //    return html;
        //}

        //public string ConvertHtml(string html, string source)
        //{
        //    if (source != null)
        //    {
        //        string convertedHeader = source;
        //        MatchCollection tags = Regex.Matches(source, "{Parent(.*?)}");
        //        foreach (Match tagMatch in tags)
        //        {
        //            string field = tagMatch.ToString().Replace("{Parent.", "").Replace("}", "");
        //            Tag tag = this._tags.Where(c => c.Name == "{Parent." + field + "}").FirstOrDefault();
        //            if (tag != null)
        //            {
        //                string mappingColumn = tag.ReplaceValue.Replace("<%#DataBinder.Eval(Container.DataItem,\"", "").Replace("\")%>", "");
        //                convertedHeader = convertedHeader.Replace(tagMatch.ToString(), "<%# " + mappingColumn + " %>");
        //            }
        //        }
        //        html = html.Replace(source, convertedHeader);
        //    }
        //    return html;
        //}

        public override string Publish2(CmsPage page)
        {
            string html = "";

            try
            {
                if (DataCollection != null)
                {
                    PrepairTemplate(DataCollection.DataGroupFields, DataCollection.DataGroupFields);
                }
                html = base.Publish2(page);
                if (DataCollection == null)
                {
                    return(html);
                }


                ModuleNavigationAction navigationActionDrillDown = this.GetNavigationActionByTagName("{DrillDownLink}");
                if (navigationActionDrillDown != null)
                {
                    drillDownUrl  = navigationActionDrillDown.GetNavigationUrl();
                    drillDownLink = navigationActionDrillDown.CreateNavigationHyperlink("G");
                }

                if (html.Contains("{DrillUpLink}"))
                {
                    ModuleNavigationAction navigationActionDrillUp = this.GetNavigationActionByTagName("{DrillUpLink}");
                    if (navigationActionDrillUp != null)
                    {
                        drillUpUrl  = navigationActionDrillUp.GetNavigationUrl();
                        drillUpLink = navigationActionDrillUp.CreateNavigationHyperlink("G");
                    }
                }
                //getDrillDownUrlAndLink(out drillDownUrl, out drillDownLink);
                ShowDataEnum          showdataBy  = getSetting <ShowDataEnum>("ShowDataBy");
                System.Data.DataTable groupsTable = new System.Data.DataTable();
                if (showdataBy == ShowDataEnum.UserSelectNoDefaultData)
                {
                    if (this.dataId != Guid.Empty && this.dataId != null)
                    {
                        groupsTable = getDataTable("DataGroup", "G", DataCollection.DataGroupFields);
                    }
                }
                else
                {
                    groupsTable = getDataTable("DataGroup", "G", DataCollection.DataGroupFields);
                }

                string rowTemplate = base.GetSubTemplate("{List}");
                string rowsHtml    = "";
                foreach (System.Data.DataRow dataRow in groupsTable.Rows)
                {
                    string rowHtml             = rowTemplate;
                    string rewriteUrlDrillDown = CreateRewriteUrl(page, drillDownUrl, "G", new Guid(dataRow["ID"].ToString()), dataRow["CompletePath"].ToString(), dataRow["Title"].ToString());
                    rowHtml = rowHtml.Replace("{DrillDownLink}", drillDownLink);
                    rowHtml = rowHtml.Replace("{/DrillDownLink}", "</a>");
                    rowHtml = rowHtml.Replace("{DrillDownUrl}", rewriteUrlDrillDown);
                    foreach (System.Data.DataColumn column in dataRow.Table.Columns)
                    {
                        rowHtml = ReplaceTag(rowHtml, dataRow, column);
                        //rowHtml = rowHtml.Replace("{" + column.ColumnName + "}", dataRow[column.ColumnName].ToString());
                        if (rowHtml.Contains("{FileList1}"))
                        {
                            rowHtml = fillExtraFilesSubTemplate(rowHtml, "", dataRow["ID"].ToString());
                        }
                        if (html.Contains("{ImageList1}"))
                        {
                            rowHtml = fillExtraImagesSubTemplate(rowHtml, "", dataRow["ID"].ToString());
                        }
                    }

                    rowsHtml += rowHtml;
                }
                html = html.Replace("<!--{List}-->" + rowTemplate + "<!--{/List}-->", rowsHtml);
                html = html.Replace("{List}" + rowTemplate + "{/List}", rowsHtml);

                //parent-tags kunnen ook buiten de list-template staan. dus buiten {List} en {/List}
                //dan ook deze tags vervangen, ook als er geen rows zouden zijn. (parent kan er nog wel zijn)
                if (html.Contains("{Parent") || html.Contains("{DrillUp"))
                {
                    //dataId = dataId == Guid.Empty ? Guid.Parse(getSetting<string>("SelectGroupID")) : dataId;
                    System.Data.DataRow parentGroupRow = base.getDataParentGroupRow(dataId);
                    html = ReplaceDrillUpTag(page, html, parentGroupRow["FK_Parent_Group"].ToString());
                    foreach (System.Data.DataColumn column in parentGroupRow.Table.Columns)
                    {
                        html = html.Replace("{" + column.ColumnName + "}", parentGroupRow[column.ColumnName].ToString());
                    }
                }

                bool hideWhenNoData = getSetting <bool>("HideWhenNoData");
                if (hideWhenNoData && groupsTable.Rows.Count == 0)
                {
                    html = getModuleStartDiv() + getModuleEndDiv();
                }
            }
            catch (Exception ex)
            {
                html = base.HandlePublishError(ex);
            }
            return(html);
        }