예제 #1
0
        public ActionResult FileManagerIsFileUsed(string f)
        {
            bool isFileUsed = false;

            if (!isFileUsed)
            {
                PagesLanguages backEndCmsPagesContent = new PagesLanguages();
                isFileUsed = backEndCmsPagesContent.IsFileUsed(f);
            }

            if (!isFileUsed)
            {
                PageTemplates backEndCmsPagesTemplates = new PageTemplates();
                isFileUsed = backEndCmsPagesTemplates.IsFileUsed(f);
            }

            if (!isFileUsed)
            {
                foreach (IModuleConnector moduleConnector in ModuleConnectorsHelper.GetModuleConnectors())
                {
                    isFileUsed = moduleConnector.IsFileUsed(f);
                    if (isFileUsed)
                    {
                        break;
                    }
                }
            }

            return(Content(isFileUsed.ToString(), "text/plain"));
        }
예제 #2
0
        public string GetContent(HtmlHelper htmlHelper, FrontEndCmsPage model, string id)
        {
            string result = string.Empty;

            SharedContent sharedContent = new SharedContents().GetSharedContent(id, model.LanguageCode, true);

            if (sharedContent.IsNotNull())
            {
                //include any extra modules, excluding {$Content} and other {$SharedContent-...} to avoid recursion
                string   controllerAction;
                string[] controllerActionArray;

                bool isModuleFound;

                foreach (string sharedContentPart in ExtensionsHelper.GetHtmlCodeParts(sharedContent.HtmlCode))
                {
                    isModuleFound = false;
                    foreach (IModuleConnector moduleConnector in ModuleConnectorsHelper.GetModuleConnectors())
                    {
                        foreach (SelectListItem module in moduleConnector.GetSelectItemList())
                        {
                            if (!sharedContentPart.StartsWith("{$SharedContent") && sharedContentPart.ToLower() == module.Value.ToLower())
                            {
                                isModuleFound         = true;
                                controllerAction      = sharedContentPart.Substring(2, sharedContentPart.Length - 3);
                                controllerActionArray = controllerAction.Split('-');
                                result += moduleConnector.GetContent(htmlHelper, model, controllerActionArray[1]);
                            }
                        }
                    }

                    if (!isModuleFound)
                    {
                        if (sharedContentPart != "{$Content}" && !sharedContentPart.StartsWith("{$SharedContent") && sharedContentPart.StartsWith("{$") && sharedContentPart.EndsWith("}") && sharedContentPart.Contains('-'))
                        {
                            controllerAction      = sharedContentPart.Substring(2, sharedContentPart.Length - 3);
                            controllerActionArray = controllerAction.Split('-');
                            result += htmlHelper.Action(controllerActionArray[1], "FrontEnd" + controllerActionArray[0], model).ToString();
                        }
                        else
                        {
                            result += sharedContentPart;
                        }
                    }
                }
            }

            return(result);
        }
예제 #3
0
        public static IHtmlString GetPageContent(this HtmlHelper htmlHelper, FrontEndCmsPage model)
        {
            string result = string.Empty;

            PageLanguage backEndCmsPageLanguage = new PagesLanguages().GetPageLanguage(model.PageId, model.LanguageCode);

            string controllerAction;

            string[] controllerActionArray;

            if (model.PageTemplateId.IsNotNull())
            {
                PageTemplate pageTemplate = new PageTemplates().GetPageTemplateById(model.PageTemplateId);

                IEnumerable <IModuleConnector> moduleConnectors = ModuleConnectorsHelper.GetModuleConnectors();

                bool isModuleFound;

                foreach (string templatePart in ExtensionsHelper.GetHtmlCodeParts(pageTemplate.HtmlCode))
                {
                    isModuleFound = false;
                    foreach (IModuleConnector moduleConnector in moduleConnectors)
                    {
                        foreach (SelectListItem module in moduleConnector.GetSelectItemList())
                        {
                            if (templatePart.ToLower() == module.Value.ToLower())
                            {
                                isModuleFound         = true;
                                controllerAction      = templatePart.Substring(2, templatePart.Length - 3);
                                controllerActionArray = controllerAction.Split('-');
                                result += moduleConnector.GetContent(htmlHelper, model, controllerActionArray[1]);
                            }
                        }
                    }

                    if (!isModuleFound)
                    {
                        if (templatePart == "{$Content}")
                        {
                            if (backEndCmsPageLanguage.IsNotNull())
                            {
                                //include any extra modules
                                foreach (string pageLanguagePart in ExtensionsHelper.GetHtmlCodeParts(backEndCmsPageLanguage.HtmlCode))
                                {
                                    isModuleFound = false;
                                    foreach (IModuleConnector moduleConnector in moduleConnectors)
                                    {
                                        foreach (SelectListItem module in moduleConnector.GetSelectItemList())
                                        {
                                            if (pageLanguagePart.ToLower() == module.Value.ToLower())
                                            {
                                                isModuleFound         = true;
                                                controllerAction      = pageLanguagePart.Substring(2, pageLanguagePart.Length - 3);
                                                controllerActionArray = controllerAction.Split('-');
                                                result += moduleConnector.GetContent(htmlHelper, model, controllerActionArray[1]);
                                            }
                                        }
                                    }

                                    if (!isModuleFound)
                                    {
                                        if (pageLanguagePart.StartsWith("{$") && pageLanguagePart.EndsWith("}") && pageLanguagePart.Contains('-'))
                                        {
                                            controllerAction      = pageLanguagePart.Substring(2, pageLanguagePart.Length - 3);
                                            controllerActionArray = controllerAction.Split('-');
                                            try
                                            {
                                                result += htmlHelper.Action(controllerActionArray[1], "FrontEnd" + controllerActionArray[0], model).ToString();
                                            }
                                            catch (Exception ex)
                                            {
                                                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                                            }
                                        }
                                        else
                                        {
                                            result += pageLanguagePart;
                                        }
                                    }
                                }
                            }
                        }
                        else if (templatePart.StartsWith("{$") && templatePart.EndsWith("}") && templatePart.Contains('-'))
                        {
                            controllerAction      = templatePart.Substring(2, templatePart.Length - 3);
                            controllerActionArray = controllerAction.Split('-');
                            result += htmlHelper.Action(controllerActionArray[1], "FrontEnd" + controllerActionArray[0], model).ToString();
                        }
                        else
                        {
                            result += templatePart;
                        }
                    }
                }
            }

            return(htmlHelper.Raw(result.ReplaceGlobalTokens()));
        }