// // PageBuilder2.cs // // Author: // beckermj <> // // Copyright (c) 2022 ${CopyrightHolder} // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . using System; using System.Collections.Generic; using System.IO; using Mocha.Core; using Mocha.OMS; using UniversalEditor.IO; namespace Mocha.Web.Server { public class PageBuilder2 { private Mocha.OMS.Oms oms = null; private SessionContext sess = null; public PageBuilder2(Mocha.OMS.Oms oms, SessionContext sess) { this.oms = oms; this.sess = sess; } private void RenderBeginTag(Instance inst, StreamWriter sw) { InstanceKey instId = oms.GetInstanceKey(inst); Instance instParentClass = oms.GetParentClass(inst); if (instParentClass.GlobalIdentifier == KnownInstanceGuids.Classes.ImagePageComponent) { Instance instImage = oms.GetRelatedInstance(inst, KnownRelationshipGuids.Image_Page_Component__has_source__Method); OmsContext ctx = new OmsContext(); object val = oms.ExecuteMethod(instImage, ctx); string imgurl = sess.GetAttachmentUrl(((Instance[])val)[0], sess.GetOmsAttachmentEntropy()); sw.WriteLine(String.Format("", instId, imgurl)); } else if (instParentClass.GlobalIdentifier == KnownInstanceGuids.Classes.PanelPageComponent) { sw.WriteLine(String.Format("
", instId)); sw.WriteLine("
"); Instance[] instHeaderComponents = oms.GetRelatedInstances(inst, KnownRelationshipGuids.Panel_Page_Component__has_header__Page_Component); foreach (Instance inst2 in instHeaderComponents) { RenderPageComponent(inst2, sw); } sw.WriteLine("
"); sw.WriteLine("
"); Instance[] instContentComponents = oms.GetRelatedInstances(inst, KnownRelationshipGuids.Panel_Page_Component__has_content__Page_Component); foreach (Instance inst2 in instContentComponents) { RenderPageComponent(inst2, sw); } sw.WriteLine("
"); sw.WriteLine("
"); Instance[] instFooterComponents = oms.GetRelatedInstances(inst, KnownRelationshipGuids.Panel_Page_Component__has_footer__Page_Component); foreach (Instance inst2 in instFooterComponents) { RenderPageComponent(inst2, sw); } sw.WriteLine("
"); } else if (instParentClass.GlobalIdentifier == KnownInstanceGuids.Classes.ButtonPageComponent) { sw.WriteFixedLengthString(String.Format("