예제 #1
0
        public ActionResult SharedContentDelete(string deleteId)
        {
            SharedContents sharedContents = new SharedContents();

            switch (sharedContents.Delete(deleteId))
            {
            case 0:
                ModelState.AddResult(ViewData, ModelStateResult.Success, Resources.Strings.ItemSuccessfullyDeleted);
                break;

            case 2:
                ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.ItemDoesNotExist);
                break;

            case 3:
                ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.ItemUsedSomewhereElse);
                break;

            default:
                ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.UnexpectedError);
                break;
            }

            return(RedirectToAction("SharedContent"));
        }
예제 #2
0
 public bool EqualsShared(Item otherItem)
 {
     if (otherItem == null)
     {
         return(false);
     }
     return(SharedContents.Equals(otherItem.SharedContents));
 }
예제 #3
0
        public List <SelectListItem> GetSelectItemList()
        {
            List <SelectListItem> result = new List <SelectListItem>();

            SharedContents sharedContents = new SharedContents();

            result.AddRange(sharedContents.GetAllSharedContentsAsSelectListItems());

            return(result);
        }
예제 #4
0
        public ActionResult SharedContent(BackEndSharedContentList backEndSharedContentList)
        {
            SharedContents sharedContents = new SharedContents();

            backEndSharedContentList.SharedContentList = sharedContents.GetSharedContents(backEndSharedContentList.SharedContentCode, backEndSharedContentList.IsActive);
            if (backEndSharedContentList.SharedContentList.IsNull() || backEndSharedContentList.SharedContentList.Count == 0)
            {
                ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.NoDataFound);
            }

            return(View(backEndSharedContentList));
        }
예제 #5
0
        public bool IsFileUsed(string filePath)
        {
            bool result = false;

            SharedContents sharedContents = new SharedContents();

            if (sharedContents.IsNotNull())
            {
                result = sharedContents.IsFileUsed(filePath);
            }

            return(result);
        }
예제 #6
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);
        }
예제 #7
0
        public Item(Relation relation, ItemContents sharedContents)
        {
            OwnerRelation = relation;
            if (sharedContents != null)
            {
                SharedContents = sharedContents;
            }
            else
            {
                SharedContents = new ItemContents();
            }
            _parent  = null;
            Daughter = null;
            _next    = null;
            _prev    = null;

            SharedContents.AddItemRelation(relation.Name, this);
        }
예제 #8
0
 public Item GetItemAs(string relationName)
 {
     return(SharedContents.GetItemRelation(relationName));
 }
예제 #9
0
        public ActionResult SharedContentAddEdit(BackEndSharedContentAddEdit backEndSharedContent)
        {
            if (ModelState.IsValidOrRefresh())
            {
                SharedContents sharedContents = new SharedContents();
                int?           result;
                bool           isLoopSuccessful = true;
                foreach (BackEndSharedContentLanguagesAddEdit backEndSharedContentLanguages in backEndSharedContent.SharedContentLanguages)
                {
                    result = sharedContents.AddEdit(backEndSharedContent.SharedContentCode, backEndSharedContent.NewSharedContentCode, backEndSharedContentLanguages.LanguageCode, backEndSharedContent.IsActive, backEndSharedContentLanguages.HtmlCode);
                    switch (result)
                    {
                    case 0:
                        //success
                        break;

                    case 2:
                        isLoopSuccessful = false;
                        ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.ItemDoesNotExist);
                        ViewData.IsFormVisible(false);
                        break;

                    case 3:
                        isLoopSuccessful = false;
                        ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings_SharedContent.SharedContentCodeAlreadyExists);
                        break;

                    default:
                        isLoopSuccessful = false;
                        ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.UnexpectedError);
                        break;
                    }
                    if (!isLoopSuccessful)
                    {
                        break;
                    }
                }
                if (isLoopSuccessful)
                {
                    if (backEndSharedContent.SharedContentCode.IsEmptyOrWhiteSpace())
                    {
                        ModelState.Clear();
                        backEndSharedContent = new BackEndSharedContentAddEdit();
                        BackEndSharedContentLanguagesAddEdit backEndSharedContentLanguages;
                        List <Language> allActiveLanguages = new Languages().GetAllLanguages(isActive: true);
                        foreach (Language language in allActiveLanguages)
                        {
                            backEndSharedContentLanguages = new BackEndSharedContentLanguagesAddEdit();
                            backEndSharedContentLanguages.LanguageCode = language.LanguageCode;
                            backEndSharedContentLanguages.LanguageName = language.LanguageName;

                            backEndSharedContent.SharedContentLanguages.Add(backEndSharedContentLanguages);
                        }

                        ModelState.AddResult(ViewData, ModelStateResult.Success, Resources.Strings.ItemSuccessfullyAdded);
                    }
                    else
                    {
                        ModelState.AddResult(ViewData, ModelStateResult.Success, Resources.Strings.ItemSuccessfullyEdited);
                    }
                }
            }

            return(View(backEndSharedContent));
        }
예제 #10
0
        public ActionResult SharedContentAddEdit(string id)
        {
            BackEndSharedContentAddEdit backEndSharedContent = new BackEndSharedContentAddEdit();

            SharedContents sharedContents = new SharedContents();
            SharedContent  sharedContent;

            BackEndSharedContentLanguagesAddEdit backEndSharedContentLanguages;

            List <Language> allActiveLanguages = new Languages().GetAllLanguages(isActive: true);

            if (allActiveLanguages.IsNotNull() && allActiveLanguages.Count > 0)
            {
                if (id.IsNotEmptyOrWhiteSpace())
                {
                    List <SharedContent> backEndSharedContentList = sharedContents.GetSharedContents(id);
                    if (backEndSharedContentList.IsNotNull() && backEndSharedContentList.Count > 0)
                    {
                        backEndSharedContent.SharedContentCode    = id;
                        backEndSharedContent.NewSharedContentCode = id;
                        backEndSharedContent.IsActive             = backEndSharedContentList[0].IsActive;

                        foreach (Language language in allActiveLanguages)
                        {
                            backEndSharedContentLanguages = new BackEndSharedContentLanguagesAddEdit();
                            backEndSharedContentLanguages.LanguageCode = language.LanguageCode;
                            backEndSharedContentLanguages.LanguageName = language.LanguageName;

                            sharedContent = sharedContents.GetSharedContent(id, language.LanguageCode);
                            if (sharedContent.IsNotNull())
                            {
                                backEndSharedContentLanguages.HtmlCode = sharedContent.HtmlCode;
                            }

                            backEndSharedContent.SharedContentLanguages.Add(backEndSharedContentLanguages);
                        }
                    }
                    else
                    {
                        ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.ItemDoesNotExist);
                        ViewData.IsFormVisible(false);
                    }
                }
                else
                {
                    foreach (Language language in allActiveLanguages)
                    {
                        backEndSharedContentLanguages = new BackEndSharedContentLanguagesAddEdit();
                        backEndSharedContentLanguages.LanguageCode = language.LanguageCode;
                        backEndSharedContentLanguages.LanguageName = language.LanguageName;

                        backEndSharedContent.SharedContentLanguages.Add(backEndSharedContentLanguages);
                    }
                }
            }
            else
            {
                ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.UnexpectedError);
            }

            return(View(backEndSharedContent));
        }