Exemplo n.º 1
0
        public IActionResult GetList()
        {
            List <dynamic> sites = new List <dynamic>();

            foreach (string directory in Directory.GetDirectories(Config.WWWPath + "forms"))
            {
                var directoryInfo = new DirectoryInfo(directory);

                Site site = Site.GetSite(directoryInfo.Name);

                var contents = ContentSummaryList.GetList(site.code, (!site.canEdit || HttpContext.Request.Cookies["user_Lognstatus"] == null));

                // Added by Kalam on 26/01/2020, for load the site based on selected category
                // changed by Imran to check if any category is selected or no.
                if ((CMS.Models.clsCategory.selectedCategory != null) &&
                    (site.categories.Exists(x => x.en.ToUpper().Equals(CMS.Models.clsCategory.selectedCategory.ToUpper())) ||
                     site.categories.Exists(x => x.ar.ToUpper().Equals(CMS.Models.clsCategory.selectedCategory.ToUpper())))
                    )
                {
                    //if (site.canRead)
                    //{
                    // Modified by Kalam on 30/01/2020, for logo link
                    sites.Add(new { site.code, site.name, site.description, site.more, canCreate = site.canEdit, site.categories, contents.contents, site.logoLink });
                    //}
                }
            }

            return(Ok(sites));
        }
Exemplo n.º 2
0
        public ContentResult Edit(string language, string siteCode, string contentCode, string contentVersion)
        {
            var site = Site.GetSite(siteCode);



            if (!site.canEdit)
            {
                return(new ContentResult
                {
                    ContentType = "text/html",
                    StatusCode = (int)HttpStatusCode.Unauthorized,
                    Content = "<html>Not Authorized</html>"
                });
            }

            var html = System.IO.File.ReadAllText(Config.WWWPath + "edit.master.html");

            html = html
                   .Replace("<!-- <#Include components/edit_header.html> -->", System.IO.File.ReadAllText(Config.WWWPath + "components/edit_header.html"))
                   .Replace("<!-- <#Include components/edit_attachments.html> -->", System.IO.File.ReadAllText(Config.WWWPath + "components/edit_attachments.html"))
                   .Replace("<!-- <#Include components/edit_relations.html> -->", System.IO.File.ReadAllText(Config.WWWPath + "components/edit_relations.html"))
                   // .Replace("<!-- <#Include forms/site/edit.html> -->", System.IO.File.ReadAllText(Config.WWWPath + "forms/" + siteCode + "/edit.html"))
                   .Replace("<!-- <#Include forms/site/edit.html> -->", sbForEditPage) //System.IO.File.ReadAllText(Config.BaseWWWPath + "/cms3/forms/" + siteCode + "/edit.html"))
                   .Replace("[[SITE]]", siteCode)
                   .Replace("[[CONTENT]]", contentCode)
                   .Replace("[[VERSION]]", contentVersion)
                   .Replace("[[SITENAME]]", site.name[language ?? "ar"])
                   .Replace("[[LG]]", language ?? "ar");

            //replace lookup options
            Regex filter = new Regex(@"\<\!\-\- \<\#Lookup ([^>]+)\> \-\-\>");

            foreach (Match match in filter.Matches(html))
            {
                var lookupCode = match.Groups[1].Value.Trim();

                var lookupSite = ContentSummaryList.GetList(lookupCode, (!site.canEdit || HttpContext.Request.Cookies["user_Lognstatus"] == null));

                var options = "";

                foreach (var contentSummary in lookupSite.contents)
                {
                    options += $"<option value=\"{contentSummary.code}\">{contentSummary.code} | {contentSummary.subject[language ?? "ar"]}</option>\r\n";
                }

                html = html.Replace(match.Value, options);
            }

            return(new ContentResult
            {
                ContentType = "text/html",
                StatusCode = (int)HttpStatusCode.OK,
                Content = html
            });
        }
Exemplo n.º 3
0
        public IActionResult GetSummaryList(string siteCode)
        {
            Site site = Site.GetSite(siteCode);

            if (site.canRead)
            {
                return(Ok(ContentSummaryList.GetList(siteCode, (!site.canEdit || HttpContext.Request.Cookies["user_Lognstatus"] == null))));
            }
            else
            {
                return(Unauthorized(new { success = false }));
            }
        }