Exemplo n.º 1
0
        public ContentApp GetContentAppFor(object o, IEnumerable <IReadOnlyUserGroup> userGroups)
        {
            switch (o)
            {
            case IContent _:
                return(_contentApp ?? (_contentApp = new ContentApp
                {
                    Alias = "umbInfo",
                    Name = "Info",
                    Icon = "icon-info",
                    View = "views/content/apps/info/info.html",
                    Weight = Weight
                }));

            case IMedia _:
                return(_mediaApp ?? (_mediaApp = new ContentApp
                {
                    Alias = "umbInfo",
                    Name = "Info",
                    Icon = "icon-info",
                    View = "views/media/apps/info/info.html",
                    Weight = Weight
                }));

            default:
                throw new NotSupportedException($"Object type {o.GetType()} is not supported here.");
            }
        }
Exemplo n.º 2
0
        public void SetStyle()
        {
            ContentApp app = ctx.app.obj as ContentApp;

            set("styleContent", app.SkinStyle);
            target(SaveStyle);
        }
Exemplo n.º 3
0
        private void bindCategories(ContentApp app)
        {
            List <ContentSection> sections = sectionService.GetInputSectionsByApp(app.Id);

            sections.ForEach(x => x.data["SectionLink"] = to(List, x.Id));
            bindList("cats", "x", sections);
        }
Exemplo n.º 4
0
        private static void deleteRowPrivate( ContentApp app, int rowId ) {

            if (rowId <= 0) return;

            long appId = app.Id;
            List<string> list = new List<string>();
            string[] rowList = app.RowList;

            if (rowId <= rowList.Length) {

                if (rowId < rowList.Length) {
                    ContentSection.updateBatch( "RowId=RowId-1", "RowId>" + rowId + " and AppId=" + appId );
                }
                for (int i = 1; i <= rowList.Length; i++) {
                    if (rowId != i) {
                        list.Add( rowList[i - 1] );
                    }
                }
                String strLayout = string.Empty;
                foreach (String str in list) {
                    strLayout = strLayout + str + "/";
                }
                strLayout = strLayout.TrimEnd( '/' );
                app.Layout = strLayout;
                app.update( "Layout" );
            }
        }
Exemplo n.º 5
0
        //--------------------------------------------------------------------------------------------------

        // 获取当前app首页的数据、排版布局、样式,存储为皮肤
        public void Snapshot()
        {
            ContentApp app = ctx.app.obj as ContentApp;

            PortalMockSkin s = new PortalMockSkin();

            s.Style    = app.Style;  // 样式
            s.Layout   = app.Layout; // 排版布局
            s.Sections = new List <PortalMockSection>();

            List <ContentSection> sections = sectionService.GetByApp(app.Id);

            foreach (ContentSection section in sections)
            {
                PortalMockSection ps = new PortalMockSection {
                    RowId            = section.RowId,
                    ColumnId         = section.ColumnId,
                    SectionType      = section.SectionType,
                    Title            = section.Title,
                    CustomTemplateId = section.CustomTemplateId,
                    ServiceId        = section.ServiceId,
                    ServiceParams    = section.ServiceParams,
                    TemplateId       = section.TemplateId
                };

                ps.Posts = populatePost(postService.GetBySection(section.Id, 20));
                s.Sections.Add(ps);
            }

            String json = Json.ToString(s, true);

            file.Write(PathHelper.Map("/content.json"), json);
        }
        public ContentApp GetContentAppFor(object source, IEnumerable<IReadOnlyUserGroup> userGroups)
        {
            if (!(source is IContent))
            {
                return null;
            }

            if (userGroups.Any(x => x.Alias.ToLowerInvariant() == "admin") == false)
            {
                return null;
            }

            var content = source as IContent;

            if (content.Id == 0)
            {
                return null;
            }

            var exampleApp = new ContentApp
            {
                Alias = "example04",
                Name = "Example 04",
                Icon = "icon-piracy",
                View = "/App_Plugins/Example04/view.html",
                Weight = 0,
                ViewModel = "This is data set from the factory"
            };
            return exampleApp;
        }
Exemplo n.º 7
0
        public virtual void Index()
        {
            ContentApp app = ctx.app.obj as ContentApp;

            DataPage <ContentSkin> list = ContentSkin.findPage("order by Id asc");
            IBlock block = getBlock("list");

            foreach (ContentSkin s in list.Results)
            {
                block.Set("s.Id", s.Id);
                block.Set("s.Name", s.Name);
                block.Set("s.ThumbUrl", strUtil.Join(sys.Path.Skin, s.ThumbUrl));
                block.Set("s.ApplyLink", to(Apply, s.Id));

                String currentClass = "";
                String applyLink    = string.Format("<a href=\"{0}\">应用</a>", to(Apply, s.Id));
                if (app.SkinId == s.Id)
                {
                    currentClass = "currentSkin";
                    applyLink    = "<span>当前皮肤</span>";
                }

                block.Set("s.CurrentClass", currentClass);
                block.Set("s.ApplyLink", applyLink);

                block.Next();
            }

            set("page", list.PageBar);
        }
Exemplo n.º 8
0
        private static void deleteRowPrivate(ContentApp app, int rowId)
        {
            if (rowId <= 0)
            {
                return;
            }

            int           appId = app.Id;
            List <string> list  = new List <string>();

            string[] rowList = app.RowList;

            if (rowId <= rowList.Length)
            {
                if (rowId < rowList.Length)
                {
                    ContentSection.updateBatch("RowId=RowId-1", "RowId>" + rowId + " and AppId=" + appId);
                }
                for (int i = 1; i <= rowList.Length; i++)
                {
                    if (rowId != i)
                    {
                        list.Add(rowList[i - 1]);
                    }
                }
                String strLayout = string.Empty;
                foreach (String str in list)
                {
                    strLayout = strLayout + str + "/";
                }
                strLayout  = strLayout.TrimEnd('/');
                app.Layout = strLayout;
                app.update("Layout");
            }
        }
Exemplo n.º 9
0
        public virtual void SaveHtmlPath()
        {
            String htmlPath = strUtil.SubString(ctx.Post("htmlPath"), 30);

            if (strUtil.IsNullOrEmpty(htmlPath))
            {
                echoError("请填写内容");
                return;
            }

            ContentApp     app = ctx.app.obj as ContentApp;
            ContentSetting s   = app.GetSettingsObj();

            if (htmlPath == s.StaticPath)
            {
                echoError("您没有修改目录名称");
                return;
            }

            if (HtmlHelper.IsHtmlDirError(htmlPath, ctx.errors))
            {
                echoError();
                return;
            }

            s.StaticPath = htmlPath;

            app.Settings = Json.ToString(s);
            app.update();

            echoToParentPart(lang("opok"));
        }
Exemplo n.º 10
0
        public void SaveResize()
        {
            String colIds = ctx.Post("colIds");
            String widths = ctx.Post("widths");

            if (strUtil.IsNullOrEmpty(colIds) || strUtil.IsNullOrEmpty(widths))
            {
                return;
            }

            string[] arrIds   = colIds.Split(',');
            string[] arrWidth = widths.Split(',');
            if (isColumnValid(arrIds) == false)
            {
                return;
            }
            if (isWidthValid(arrWidth) == false)
            {
                return;
            }

            ContentApp app = ctx.app.obj as ContentApp;
            Dictionary <string, Dictionary <string, string> > dic = Css.FromAndFill(app.Style);

            saveColumnOne(arrIds, arrWidth, dic, 0);
            saveColumnOne(arrIds, arrWidth, dic, 1);

            app.Style = Css.To(dic);
            db.update(app, "Style");

            echoAjaxOk();
        }
Exemplo n.º 11
0
        public virtual void MakeSectionAll()
        {
            view("MakeDone");

            ContentApp app = ctx.app.obj as ContentApp;

            MakeSidebar();

            // 最近列表页
            HtmlMaker.GetRecent().ProcessAll(app.Id);
            logger.Info("make recent html");

            // 区块列表页
            int count = 0;
            List <ContentSection> sections = sectionService.GetByApp(ctx.app.Id);

            foreach (ContentSection section in sections)
            {
                int recordCount = postService.CountBySection(section.Id);

                count += HtmlMaker.GetList().ProcessAll(section.Id, recordCount);
                logger.Info("make section html, sectionId=" + section.Id);
            }

            htmlCount += count;
            echo("生成所有列表页成功,共 " + htmlCount + " 篇");
        }
Exemplo n.º 12
0
        private void bindRowList(ContentApp article, List <ContentSection> sections)
        {
            IBlock block = getBlock("rowList");

            string[] rowList = article.RowList;
            for (int i = 1; i < (rowList.Length + 1); i++)
            {
                int columnCount = cvt.ToInt(rowList[i - 1]);
                if (columnCount <= 0)
                {
                    continue;
                }

                block.Set("row.No", string.Format(alang("rowNo"), i));

                block.Set("row.DeleteUrl", to(DeleteRow, i));
                block.Set("row.ColumnCount", columnCount);
                block.Set("row.Index", i);
                block.Set("row.EditUILink", to(new ContentSectionController().EditRowUI, i));


                IBlock columnBlock = block.GetBlock("columnList");
                bindColumnList(sections, i, columnCount, columnBlock);
                block.Next();
            }
        }
Exemplo n.º 13
0
        public void SaveHtmlDir()
        {
            String htmlDir = strUtil.SubString(ctx.Post("htmlDir"), 30);

            if (strUtil.IsNullOrEmpty(htmlDir))
            {
                echoError("请填写内容");
                return;
            }

            if (HtmlHelper.IsHtmlDirError(htmlDir, ctx.errors))
            {
                echoError();
                return;
            }

            ContentApp     app = ctx.app.obj as ContentApp;
            ContentSetting s   = app.GetSettingsObj();

            s.StaticDir = htmlDir;

            app.Settings = Json.ToString(s);
            app.update();

            echoToParentPart(lang("opok"));
        }
Exemplo n.º 14
0
        public virtual void Index()
        {
            ContentApp     app     = ctx.app.obj as ContentApp;
            ContentSetting setting = app.GetSettingsObj();

            ctx.Page.Title       = ctx.app.Name;
            ctx.Page.Description = setting.MetaDescription;

            if (strUtil.HasText(setting.MetaKeywords))
            {
                this.Page.Keywords = setting.MetaKeywords;
            }
            else
            {
                this.Page.Keywords = ctx.app.Name;
            }

            set("app.Style", app.Style);
            set("app.SkinStyle", app.SkinStyle);
            set("lnkSendPost", to(new Submit.PostController().Index));

            List <ContentSection> sections = SectionService.GetByApp(ctx.app.Id);

            bindRows(app, sections);
        }
Exemplo n.º 15
0
        private void bindCmd()
        {
            ContentApp  app = ctx.app.obj as ContentApp;
            ContentSkin s   = ContentSkin.findById(app.SkinId);

            set("skinPath", strUtil.Join(sys.Path.Skin, s.StylePath));

            set("skinLink", to(new SkinController().Index));
            set("addRow1Url", to(new RowController().ConfirmAddRow, 1));
            set("addRow2Url", to(new RowController().ConfirmAddRow, 2));
            set("addRow3Url", to(new RowController().ConfirmAddRow, 3));
            set("addRow4Url", to(new RowController().ConfirmAddRow, 4));
            set("addRow5Url", to(new RowController().ConfirmAddRow, 5));
            set("addRow6Url", to(new RowController().ConfirmAddRow, 6));

            set("setStyleUrl", to(new ContentController().SetStyle));
            set("layoutSaveUrl", to(new ContentController().SaveLayout));

            set("resizeLink", to(new ContentController().SaveResize));

            IBlock xblock = getBlock("export");

            if (ctx.viewer.IsAdministrator())
            {
                xblock.Set("lnkExport", to(new ExportController().Index));
                xblock.Next();
            }
        }
Exemplo n.º 16
0
        private int getPageSize(long appId)
        {
            ContentApp     app = ContentApp.findById(appId);
            ContentSetting s   = app.GetSettingsObj();

            return(s.ListPostPerPage);
        }
Exemplo n.º 17
0
        public ContentApp GetContentAppFor(object o, IEnumerable <IReadOnlyUserGroup> userGroups)
        {
            switch (o)
            {
            case IContent _:
                return(_contentApp ?? (_contentApp = new ContentApp
                {
                    Alias = "umbContent",
                    Name = "Content",
                    Icon = "icon-document",
                    View = "views/content/apps/content/content.html",
                    Weight = Weight
                }));

            case IMedia media when !media.ContentType.IsContainer && media.ContentType.Alias != Core.Constants.Conventions.MediaTypes.Folder:
                return(_mediaApp ?? (_mediaApp = new ContentApp
                {
                    Alias = "umbContent",
                    Name = "Content",
                    Icon = "icon-document",
                    View = "views/media/apps/content/content.html",
                    Weight = Weight
                }));

            case IMedia _:
                return(null);

            default:
                throw new NotSupportedException($"Object type {o.GetType()} is not supported here.");
            }
        }
Exemplo n.º 18
0
        //--------------------------------------------------------------------------------------------------------

        public void List(int sectionId)
        {
            set("addUrl", to(Add, 0));
            set("OperationUrl", to(SaveAdmin));
            set("lnkTrans", to(Trans));

            ContentApp app = ctx.app.obj as ContentApp;

            set("app.Name", ctx.app.Name);
            set("app.Link", to(new ContentController().Index));
            set("searchKey", "");

            set("tagAction", to(SaveTag));

            DataPage <ContentPost> posts;

            if (sectionId <= 0)
            {
                posts = postService.GetByApp(ctx.app.Id, 50);
            }
            else
            {
                posts = postService.GetPageBySection(sectionId, 50);
            }

            bool isTrash = false;

            bindAdminList(posts, isTrash);

            bindCategories(app);

            target(Search);
        }
Exemplo n.º 19
0
        public ContentApp GetContentAppFor(object source, IEnumerable <IReadOnlyUserGroup> userGroups)
        {
            // do not show if logged in user is not in the admin group
            if (userGroups.All(x => x.Alias.ToLowerInvariant() != Umbraco.Core.Constants.Security.AdminGroupAlias))
            {
                return(null);
            }

            // only show app on content items
            if (source is IContent)
            {
                var contentApp = new ContentApp
                {
                    Alias  = "customCodeContentApp",
                    Name   = "Custom Code Content App",
                    Icon   = "icon-hearts",
                    View   = "/App_Plugins/ContentApps/CustomCodeContentApp/view.html",
                    Weight = 0
                };

                return(contentApp);
            }

            return(null);
        }
Exemplo n.º 20
0
        private IMemberApp createApp( User user )
        {
            UserApp ua = AppService.addApp( user, "主页", 4, "wojilu.Apps.Content.Domain.ContentApp", true );

            this.app = ContentApp.findById( ua.AppOid );

            return ua;
        }
Exemplo n.º 21
0
        private IMemberApp createApp(User user)
        {
            UserApp ua = AppService.addApp(user, "主页", 4, "wojilu.Apps.Content.Domain.ContentApp", true);

            this.app = ContentApp.findById(ua.AppOid);

            return(ua);
        }
Exemplo n.º 22
0
        private static List <long> beginImportPrivate(ImportState ts)
        {
            long id = ts.TemplateId;

            SpiderImport item = SpiderImport.findById(id);

            List <SpiderArticle> articles = SpiderArticle
                                            .find("SpiderTemplateId in (" + item.DataSourceIds + ") and Id>" + item.LastImportId + " order by Id")
                                            .list();

            List <ContentSection> sections = ContentSection.find("Id in (" + item.SectionIds + ")").list();

            if (sections.Count == 0)
            {
                throw new Exception("导入的目标section不存在");
            }

            ContentSection section = null;
            List <long>    results = new List <long>();

            for (int i = 0; i < articles.Count; i++)
            {
                if (articleExist(articles[i]))
                {
                    ts.Log.AppendLine("pass..." + articles[i].Title);
                    continue;
                }

                section = getNextSection(sections, section);   // 均匀分散到各目标section中
                ContentApp app = getApp(section);

                if (item.IsApprove == 1)
                {
                    importToTemp(articles[i], item, section, app);
                }
                else
                {
                    long newArticleId = importDirect(articles[i], item, section, app);
                    results.Add(newArticleId);
                }

                ts.Log.AppendLine("导入:" + articles[i].Title);
            }

            if (articles.Count > 0)
            {
                item.LastImportId = articles[articles.Count - 1].Id;
                item.update("LastImportId");
                ts.Log.AppendLine("导入完毕(操作结束)");
            }
            else
            {
                ts.Log.AppendLine("没有新条目可导入(操作结束)");
            }


            return(results);
        }
Exemplo n.º 23
0
        public virtual void EditAutoHtml()
        {
            target(SaveAutoHtml);
            ContentApp     app         = ctx.app.obj as ContentApp;
            ContentSetting s           = app.GetSettingsObj();
            String         chkAutoHtml = s.IsAutoHtml == 1 ? "checked=\"checked\"" : "";

            set("chkAutoHtml", chkAutoHtml);
        }
Exemplo n.º 24
0
        public virtual void Export()
        {
            ContentTheme theme = new ContentTheme();

            theme.Name        = ctx.Post("Name");
            theme.Description = strUtil.CutString(ctx.Post("Description"), 200);

            if (strUtil.IsNullOrEmpty(theme.Name))
            {
                echoError("请填写主题名称");
                return;
            }


            List <ContentSection> sectionList = sectionService.GetByApp(ctx.app.Id);

            // 1、获取app信息
            ContentApp app  = ctx.app.obj as ContentApp;
            XApp       xapp = exportApp(app);

            xapp.SectionList = new List <XSection>();

            // 2、循环导出section
            string[] rowList = app.RowList;

            // 循环行
            for (int iRow = 1; iRow < (rowList.Length + 1); iRow++)
            {
                int columnCount = cvt.ToInt(rowList[iRow - 1]);
                if (columnCount <= 0)
                {
                    continue;
                }

                // 循环列
                for (int iColumn = 1; iColumn < (columnCount + 1); iColumn++)
                {
                    List <ContentSection> sections = sectionService.GetByRowColumn(sectionList, iRow, iColumn);

                    // 循环section
                    for (int iSection = 1; iSection < sections.Count + 1; iSection++)
                    {
                        XSection xSection = getSection(sections[iSection - 1], iRow, iColumn, iSection);
                        xapp.SectionList.Add(xSection);
                    }
                }
            }

            // 处理 #sectionId 的css问题,==> 转化成 #portarContainer .row-iRow .col-iColumn .section-iSection
            processCssId(xapp, sectionList);


            // 3、保存为 json 格式
            exportToDisk(xapp, theme);

            echoToParentPart(lang("opok"));
        }
Exemplo n.º 25
0
        private XApp exportApp(ContentApp app)
        {
            XApp x = new XApp();

            x.Style     = app.Style;
            x.Layout    = app.Layout;
            x.SkinStyle = app.SkinStyle;
            return(x);
        }
Exemplo n.º 26
0
        public void Index()
        {
            target(Save);
            ContentApp app = ctx.app.obj as ContentApp;

            bindSettings(app.GetSettingsObj());

            set("submitSettingLink", to(new SubmitSettingController().EditRole));
        }
Exemplo n.º 27
0
        public void SaveStyle()
        {
            ContentApp app = ctx.app.obj as ContentApp;

            app.SkinStyle = ctx.Post("Style");
            app.update("SkinStyle");

            echoToParentPrivate();
        }
Exemplo n.º 28
0
        private void bindCssForm(String name)
        {
            ContentApp app = ctx.app.obj as ContentApp;
            Dictionary <string, Dictionary <string, string> > dic = Css.FromAndFill(app.Style);
            Dictionary <string, string> values = dic.ContainsKey(name) ? dic[name] : CssInfo.GetEmptyValues();

            ctx.SetItem("cssValues", values);
            load("cssForm", CssForm);
        }
Exemplo n.º 29
0
        public override void Layout()
        {
            ContentApp  app = ctx.app.obj as ContentApp;
            ContentSkin s   = ContentSkin.findById(app.SkinId);

            set("skinPath", strUtil.Join(sys.Path.Skin, s.StylePath));

            set("adminUrl", to(new Admin.ContentController().Index));
            set("appUrl", to(new ContentController().Index));

            set("adminCheckUrl", t2(new SecurityController().CanAppAdmin, app.Id) + "?appType=" + typeof(ContentApp).FullName);

            // 当前app/module所有页面,所属的首页
            List <String> moduleUrlList = new List <string>();

            moduleUrlList.Add(to(new ContentController().Index));
            moduleUrlList.Add(HtmlLink.ToApp(app));

            ContentSetting setting = app.GetSettingsObj();

            if (strUtil.HasText(setting.StaticPath))
            {
                // 把所有可能的路径都加到 _moduleUrl 中
                moduleUrlList.Add(setting.StaticPath);               //news/default.html
                moduleUrlList.Add(getStaticDir(setting.StaticPath)); //news/
            }

            ctx.SetItem("_moduleUrl", moduleUrlList.ToArray());

            // admin link
            set("allPostsLink", to(new Admin.Common.PostController().List, 0));
            set("trashPostsLink", to(new Admin.Common.PostController().Trash));
            set("settingLink", to(new Admin.SettingController().Index));
            set("defaultLink", to(new Admin.ContentController().Home));
            set("commentLink", to(new CommentController().List));

            IBlock htmlBlock = getBlock("html");

            if (ctx.owner.obj is Site)
            {
                htmlBlock.Set("staticLink", to(new Admin.HtmlController().Index));
                htmlBlock.Next();
            }

            if (app.GetSettingsObj().EnableSubmit == 1)
            {
                String slnk = string.Format("<li><a href=\"{0}\" class=\"frmLink\" loadTo=\"contentPage\" nolayout=3>{1}</a></li>",
                                            to(new Admin.SubmitSettingController().List),
                                            "投递员管理");
                set("submitterLink", slnk);
            }
            else
            {
                set("submitterLink", "");
            }
        }
Exemplo n.º 30
0
        public void DeleteRow(int rowId)
        {
            target(DeleteRowSave, rowId);
            ContentApp article = ctx.app.obj as ContentApp;

            if (sectionService.Count(ctx.app.Id, rowId) > 0)
            {
                echo(alang("exRemoveSectionFirst"));
            }
        }
Exemplo n.º 31
0
        private void bindCss()
        {
            ContentApp app = ctx.app.obj as ContentApp;

            String appStyle  = app.Style == null ? "" : app.Style.Replace("display:none;", "");
            String skinStyle = app.SkinStyle == null ? "" : app.SkinStyle.Replace("display:none;", "");

            set("app.Style", appStyle);
            set("app.SkinStyle", skinStyle);
        }
Exemplo n.º 32
0
        // 生成频道的全部html
        private void makeHtml(MvcContext ctx, IMemberApp mApp, String staticPath)
        {
            ContentApp app = initApp(ctx, mApp);

            setStaticPath(app, staticPath);

            HtmlController controller = ControllerFactory.FindController(typeof(HtmlController), ctx) as HtmlController;

            controller.MakeAll();
        }
Exemplo n.º 33
0
        private string getCachedPageName( ContentApp app )
        {
            // 1) appId=396 Created=2010-10-21
            // 2) http://www.xxx.com/Content396/Content/Index.aspx
            // 3) /framework/cache/2010-10-21/Content396_Content_Index.config

            return string.Format( "{0}cache/{1}/Content{2}_Content_Index.config",
                cfgHelper.FrameworkRoot,
                string.Format( "{0}-{1}-{2}", app.Created.Year, app.Created.Month, app.Created.Day ),
                app.Id );
        }
Exemplo n.º 34
0
 private void bindRows( ContentApp article, List<ContentSection> sections ) {
     IBlock block = getBlock( "rowList" );
     string[] rowList = article.RowList;
     for (int i = 1; i < (rowList.Length + 1); i++) {
         int columnCount = cvt.ToInt( rowList[i - 1] );
         IBlock columnBlock = block.GetBlock( "columnList" );
         bindColumnList( sections, i, columnCount, columnBlock );
         block.Set( "row.Index", i );
         block.Next();
     }
 }
Exemplo n.º 35
0
        // 静态配置
        private void setStaticPath( ContentApp app, string staticPath )
        {
            ContentSetting setting = app.GetSettingsObj();

            setting.IsAutoHtml = 1;
            setting.StaticPath = staticPath;
            setting.ArticleListMode = 1; // 摘要列表

            app.Settings = Json.ToString( setting );

            app.update();
        }
Exemplo n.º 36
0
        public void UpdateRow( ContentApp app, MoveRowInfo mr )
        {
            app.Layout = mr.RowString;
            app.Style = updateStyle( app.Style, mr );
            app.SkinStyle = updateStyle( app.SkinStyle, mr );
            app.update();

            int tempId = 9999;
            ContentSection.updateBatch( "RowId=" + tempId, "AppId=" + app.Id + " and RowId=" + mr.Row1 );
            ContentSection.updateBatch( "RowId=" + mr.Row1, "AppId=" + app.Id + " and RowId=" + mr.Row2 );
            ContentSection.updateBatch( "RowId=" + mr.Row2, "AppId=" + app.Id + " and RowId=" + tempId );

            List<ContentSection> list = new ContentSectionService().GetByApp( app.Id );
        }
Exemplo n.º 37
0
        private int moveRowToEnd( ContentApp app, int rowId ) {

            /*
next row int[]=4*,5,6,7
moveRow( 'up', 5 )=>4,5*,6,7
moveRow( 'up', 6 )=>4,5,6*,7
moveRow( 'up', 7 )=>4,5,6,7*
            */

            string[] rowList = app.RowList;
            if (rowId <= 0 || rowId > rowList.Length) return 0;

            for (int i = rowId + 1; i < rowList.Length + 1; i++) {

                MoveRowInfo mr = this.MoveRow( app.Layout, "up", i );
                this.UpdateRow( app, mr );

            }

            return rowList.Length;
        }
Exemplo n.º 38
0
        private void bindRowList( ContentApp app, List<ContentSection> sections ) {
            IBlock block = getBlock( "rowList" );
            string[] rowList = app.RowList;
            for (int i = 1; i < (rowList.Length + 1); i++) {

                int columnCount = cvt.ToInt( rowList[i - 1] );
                if (columnCount <= 0) continue;

                block.Set( "row.No", string.Format( alang( "rowNo" ), i ) );

                block.Set( "row.DeleteUrl", to( new RowController().DeleteRow, i ) );
                block.Set( "row.ColumnCount", columnCount );
                block.Set( "row.Index", i );
                block.Set( "row.EditUILink", to( new ContentSectionController().EditRowUI, i ) );

                if (rowList.Length == 1) {
                    block.Set( "row.RowUpUrl", "#" );
                    block.Set( "row.RowDownUrl", "#" );
                }
                else if (i == 1) {
                    block.Set( "row.RowUpUrl", "#" );
                    block.Set( "row.RowDownUrl", to( new RowController().Move ) + "?action=down&rowId=" + i );
                }
                else if (i == rowList.Length) {
                    block.Set( "row.RowUpUrl", to( new RowController().Move ) + "?action=up&rowId=" + i );
                    block.Set( "row.RowDownUrl", "#" );
                }
                else {
                    block.Set( "row.RowUpUrl", to( new RowController().Move ) + "?action=up&rowId=" + i );
                    block.Set( "row.RowDownUrl", to( new RowController().Move ) + "?action=down&rowId=" + i );
                }


                IBlock columnBlock = block.GetBlock( "columnList" );
                bindColumnList( sections, i, columnCount, columnBlock );
                block.Next();

            }
        }
Exemplo n.º 39
0
 private void bindCategories( ContentApp app )
 {
     List<ContentSection> sections = sectionService.GetInputSectionsByApp( app.Id );
     sections.ForEach( x => x.data["SectionLink"] = to( List, x.Id ) );
     bindList( "cats", "x", sections );
 }
Exemplo n.º 40
0
 public void DeleteRow( ContentApp app,  int rowId )
 {
     int lastRowId = moveRowToEnd( app, rowId );
     deleteRowPrivate( app, lastRowId );
 }
Exemplo n.º 41
0
        //---------------------------------
        /// <summary>
        /// 安装app
        /// </summary>
        /// <returns></returns>
        protected IMemberApp createApp()
        {
            int installerId = 4;
            AppInstaller installer = installerService.GetById( installerId );

            IMember owner = this.owner;
            User creator = this.user;
            String name = appName;

            IMemberApp mapp = appService.Add( creator, owner, name, installer.Id, AccessStatus.Public );
            String appUrl = UrlConverter.clearUrl( mapp, ctx, this.owner );

            IMenu menu = menuService.AddMenuByApp( mapp, name, "", appUrl );

            ContentApp newApp = ContentApp.findById( mapp.AppOid );
            this.app = newApp;

            return mapp;
        }
Exemplo n.º 42
0
 private XApp exportApp( ContentApp app )
 {
     XApp x = new XApp();
     x.Style = app.Style;
     x.Layout = app.Layout;
     x.SkinStyle = app.SkinStyle;
     return x;
 }
Exemplo n.º 43
0
        private IMemberApp createApp()
        {
            int appInfoId = 4;
            AppInstaller info = appinfoService.GetById( appInfoId );

            IMember owner = this.user;
            User creator = this.user;
            String name = lang.get( "homepage" );

            IMemberApp myuserApp = appService.Add( creator, owner, name, info.Id, AccessStatus.Public );
            //String appUrl = UrlConverter.clearUrl( myuserApp, ctx );
            String appUrl = UrlConverter.clearUrl( myuserApp, ctx, owner );

            IMenu menu = menuService.AddMenuByApp( myuserApp, name, "", appUrl );
            menu.Url = "default";
            menu.OrderId = 99;
            menuService.Update( menu );

            this.app = ContentApp.findById( myuserApp.AppOid );

            return myuserApp;
        }
Exemplo n.º 44
0
        private static int importToTemp( SpiderArticle art, SpiderImport item, ContentSection section, ContentApp app )
        {
            ContentTempPost post = new ContentTempPost();
            post.Creator = item.Creator;
            post.OwnerId = app.OwnerId;
            post.OwnerType = app.OwnerType;
            post.AppId = app.Id;
            post.SectionId = section.Id;

            post.Title = art.Title;
            post.SourceLink = art.Url;
            post.Content = art.Body;

            post.insert();

            return post.Id;
        }
Exemplo n.º 45
0
        private static int importDirect( SpiderArticle art, SpiderImport item, ContentSection section, ContentApp app )
        {
            ContentPost post = new ContentPost();
            post.Title = art.Title;
            post.Content = art.Body;

            if (art.IsPic == 1) {
                post.CategoryId = PostCategory.Img;
                post.ImgLink = art.PicUrl;
            }

            post.SourceLink = art.Url;

            post.Creator = item.Creator;
            post.CreatorUrl = item.Creator.Url;
            post.PageSection = section;
            post.OwnerId = app.OwnerId;
            post.OwnerType = app.OwnerType;
            post.OwnerUrl = app.OwnerUrl;
            post.AppId = app.Id;

            post.insert();
            return post.Id;
        }