public void SetSessionModel(Session aSession, IPageModel aModel) { lock (iLock) { iSessionModels[aSession] = aModel; } }
public Pager(IPageModel model, ViewContext context) { this.model = model; this.viewContext = context; this.urlBuilder = CreateDefaultUrl; this.booleanParameterNames = new List <string>(); }
internal Page(PrintJob job, Guid id, IPageModel pageModel) { _job = job; _id = id; _templateUri = pageModel.TemplateUrl; _variables = pageModel.Variables; }
/// <summary> /// Initializes a new instance of the <b>PagesController</b> class. /// </summary> /// <param name="structureInfo">The structure info.</param> /// <param name="currentPage">The current page.</param> /// <param name="session">The session.</param> /// <param name="content">The content.</param> public PagesController(IStructureInfo structureInfo, IPageModel currentPage, IDocumentSession session, IContent content) { _structureInfo = structureInfo; _currentPage = currentPage; _session = session; _content = content; }
public MasterPageViewModel(MenuPage menu, IPageModel detailModel) { Title = "Home Page"; _menu = menu; Master = _menu; Detail = new NavigationPage(detailModel.ViewModel.ContentPage); }
private void AddSections(string pageName, IPageModel page) { var sections = this.GetSectionsForPage(pageName); foreach (var section in sections) { page.Sections.Add(section.Name, section); } }
public IPathData ResolvePath(string virtualUrl) { // Set the default action to index _pathData.Action = ContentRoute.DefaultAction; // Set the default controller to content _pathData.Controller = ContentRoute.DefaultControllerName; // Get an up to date document session from structuremap _session = ObjectFactory.GetInstance <IDocumentSession>(); // The requested url is for the start page with no action if (string.IsNullOrEmpty(virtualUrl) || string.Equals(virtualUrl, "/")) { _pageModel = _session.Query <IPageModel>() .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite()) .SingleOrDefault(x => x.Parent == null); _pathData.CurrentPageModel = _pageModel; return(_pathData); } // Remove the trailing slash virtualUrl = VirtualPathUtility.RemoveTrailingSlash(virtualUrl); // The normal beahaviour should be to load the page based on the url _pageModel = _session.Query <IPageModel, Document_ByUrl>() .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite()) .FirstOrDefault(x => x.Metadata.Url == virtualUrl); // Try to load the page without the last segment of the url and set the last segment as action)) if (_pageModel == null && virtualUrl.LastIndexOf("/", System.StringComparison.Ordinal) > 0) { var index = virtualUrl.LastIndexOf("/", System.StringComparison.Ordinal); var action = virtualUrl.Substring(index, virtualUrl.Length - index).Trim(new[] { '/' }); virtualUrl = virtualUrl.Substring(0, index).TrimStart(new[] { '/' }); _pageModel = _session.Query <IPageModel, Document_ByUrl>() .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite()) .FirstOrDefault(x => x.Metadata.Url == virtualUrl); _pathData.Action = action; } // If the page model still is empty, let's try to resolve if the start page has an action named (virtualUrl) if (_pageModel == null) { _pageModel = _session.Query <IPageModel>().SingleOrDefault(x => x.Parent == null); var controllerName = _controllerMapper.GetControllerName(typeof(ContentController)); var action = virtualUrl.TrimStart(new[] { '/' }); if (!_controllerMapper.ControllerHasAction(controllerName, action)) { return(null); } _pathData.Action = action; } if (_pageModel == null) { return(null); } _pathData.CurrentPageModel = _pageModel; return(_pathData); }
/// <summary> /// Resolves the path. /// </summary> /// <param name="virtualUrl">The virtual URL.</param> /// <returns></returns> public IPathData ResolvePath(string virtualUrl) { // Set the default action to index _pathData.Action = PageRoute.DefaultAction; // Get an up to date page repository //_pageService = _container.Resolve<IPageServiceFacade>(); // The requested url is for the start page with no action if (string.IsNullOrEmpty(virtualUrl) || string.Equals(virtualUrl, "/") || virtualUrl.StartsWith("classifieds")) { //_pageModel = _pageService.SingleOrDefault<IPageModel>(x => x.Parent == null); //_pageModel = _pageService.GetPageByUrl(null); //This is a site home page _pageModel = null; // new Home(); } else { // Remove the trailing slash virtualUrl = VirtualPathUtility.RemoveTrailingSlash(virtualUrl); // The normal beahaviour should be to load the page based on the url //_pageModel = _pageService.GetPageByUrl<IPageModel>(virtualUrl); _pageModel = _pageService.GetPageByUrl(virtualUrl); // Try to load the page without the last segment of the url and set the last segment as action)) if (_pageModel == null && virtualUrl.LastIndexOf("/") > 0) { var index = virtualUrl.LastIndexOf("/"); var action = virtualUrl.Substring(index, virtualUrl.Length - index).Trim(new[] { '/' }); virtualUrl = virtualUrl.Substring(0, index).TrimStart(new[] { '/' }); //_pageModel = _pageService.GetPageByUrl<IPageModel>(virtualUrl); _pageModel = _pageService.GetPageByUrl(virtualUrl); _pathData.Action = action; } // If the page model still is empty, let's try to resolve if the start page has an action named (virtualUrl) if (_pageModel == null) { //_pageModel = _pageService.SingleOrDefault<IPageModel>(x => x.Parent == null); _pageModel = _pageService.GetPageByUrl(null); var pageModelAttribute = _pageModel.GetType().GetAttribute<PageModelAttribute>(); _controllerName = _controllerMapper.GetControllerName(pageModelAttribute.ControllerType); var action = virtualUrl.TrimStart(new[] { '/' }); if (!_controllerMapper.ControllerHasAction(_controllerName, action)) { return null; } _pathData.Action = action; } } if (_pageModel == null) { return null; } var controllerType = _pageModel.GetType().GetAttribute<PageModelAttribute>().ControllerType; _pathData.Controller = _controllerMapper.GetControllerName(controllerType); _pathData.CurrentPageModel = _pageModel; return _pathData; }
public PageHandler(Main main) { this._main = main; this._menu = new MenuPage(); _menu.ListView.ItemSelected += OnItemSelected; this._detailPage = new HomePageModel(); _detailPage.SetMain(_main); _mainPage = new MasterPageViewModel(_menu, _detailPage); main.App.MainPage = _mainPage; }
public PageModel(IPageModel model) : base() { if (model != null) { this.PageIndex = model.PageIndex; this.PageSize = model.PageSize; this.ResultCount = model.ResultCount; this.SortBy = model.SortBy; this.SortDesc = model.SortDesc; } }
public PageModel(IPageModel model) : base() { if (model != null) { this.PageIndex = model.PageIndex; this.PageSize = model.PageSize; this.ResultCount = model.ResultCount; this.SortBy = model.SortBy; this.SortDesc = model.SortDesc; } }
public IPathData ResolvePath(string virtualUrl) { // Set the default action to index _pathData.Action = ContentRoute.DefaultAction; // Set the default controller to content _pathData.Controller = ContentRoute.DefaultControllerName; // Get an up to date document session from structuremap _session = ObjectFactory.GetInstance<IDocumentSession>(); // The requested url is for the start page with no action if (string.IsNullOrEmpty(virtualUrl) || string.Equals(virtualUrl,"/")) { _pageModel = _session.Query<IPageModel>() .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite()) .SingleOrDefault(x => x.Parent == null); _pathData.CurrentPageModel = _pageModel; return _pathData; } // Remove the trailing slash virtualUrl = VirtualPathUtility.RemoveTrailingSlash(virtualUrl); // The normal beahaviour should be to load the page based on the url _pageModel = _session.Query<IPageModel, Document_ByUrl>() .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite()) .FirstOrDefault(x => x.Metadata.Url == virtualUrl); // Try to load the page without the last segment of the url and set the last segment as action)) if (_pageModel == null && virtualUrl.LastIndexOf("/", System.StringComparison.Ordinal) > 0) { var index = virtualUrl.LastIndexOf("/", System.StringComparison.Ordinal); var action = virtualUrl.Substring(index, virtualUrl.Length - index).Trim(new[] {'/'}); virtualUrl = virtualUrl.Substring(0, index).TrimStart(new[] { '/' }); _pageModel = _session.Query<IPageModel, Document_ByUrl>() .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite()) .FirstOrDefault(x => x.Metadata.Url == virtualUrl); _pathData.Action = action; } // If the page model still is empty, let's try to resolve if the start page has an action named (virtualUrl) if(_pageModel == null) { _pageModel = _session.Query<IPageModel>().SingleOrDefault(x => x.Parent == null); var controllerName = _controllerMapper.GetControllerName(typeof(ContentController)); var action = virtualUrl.TrimStart(new[] {'/'}); if(!_controllerMapper.ControllerHasAction(controllerName,action)) { return null; } _pathData.Action = action; } if (_pageModel == null) { return null; } _pathData.CurrentPageModel = _pageModel; return _pathData; }
void OnItemSelected(object sender, SelectedItemChangedEventArgs e) { var item = e.SelectedItem as MenuItem; if (item != null) { IPageModel model = (IPageModel)Activator.CreateInstance(item.TargetType); model.SetMain(_main); _mainPage.SetDetailPage(model); //change page and hide menu _menu.ListView.SelectedItem = null; } }
private PageInstance CreatePageInstance(Entry aEntry, Session aSession) { IPageModel pageModel = null; if (!string.IsNullOrEmpty(aEntry.PageDefinition.Model)) { Type pageModelType = Type.GetType(aEntry.PageDefinition.Model, true); pageModel = Activator.CreateInstance(pageModelType, aSession) as IPageModel; Assert.Check(pageModel != null); } return(new PageInstance(aEntry.Page, pageModel)); }
public void CloseModel() { if (DataModel is null) { return; } DataModel = null; var task = Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { _window.Close(); }); }
protected override void OnActivated(Session aSession) { // get the page model for this session IPageModel model = GetSessionModel(aSession); // enable analytics and send page view event if tracking aSession.Tracker.SetTracking(aSession.Tracking); aSession.Tracker.TrackPageView(Id); // update any ui widgets that reflect tracking state aSession.Send("DataCollectionEnabled", aSession.Tracking); // render widgets foreach (PageDefinitions.Widget widget in iPageDefinition.Widgets) { // get the value of the data from the page model Assert.Check(model != null); System.Reflection.PropertyInfo prop = model.GetType().GetProperty(widget.DataId); string data = prop.GetValue(model, null) as string; // create the json object OpenHome.Xapp.JsonObject json = new OpenHome.Xapp.JsonObject(); // add the basic required properties json.Add("Id", new OpenHome.Xapp.JsonValueString(widget.Id)); json.Add("DataId", new OpenHome.Xapp.JsonValueString(widget.DataId)); json.Add("Value", new OpenHome.Xapp.JsonValueString(data)); // add the optional allowed values if (widget.AllowedValues != null || widget.AllowedValuesSource != null) { // get the list of string allowed values from either the widget XML or an IPageModel property string[] allowedValuesStr = (widget.AllowedValues != null) ? widget.AllowedValues : model.GetType().GetProperty(widget.AllowedValuesSource).GetValue(model, null) as string[]; // create the json array of allowed values OpenHome.Xapp.JsonArray <OpenHome.Xapp.JsonValueString> allowedValues = new OpenHome.Xapp.JsonArray <OpenHome.Xapp.JsonValueString>(); foreach (string value in allowedValuesStr) { allowedValues.Add(new OpenHome.Xapp.JsonValueString(value)); } json.Add("AllowedValues", allowedValues); } // render the widget aSession.Send(widget.XappEvent, json); } }
public Maybe <IPageModel> GetModel(string uri) { IPageModel model = null; dataFileFetcher.Find(uri).Apply(page => { var parser = parserFactory.CreateParser(page); var baseModel = parser.Parse <PageModel>(); var modelType = typeFetcher.GetModelType(baseModel.View); model = parser.Parse(modelType); }); return(model == null ? new Maybe <IPageModel>() : new Maybe <IPageModel>(model)); }
/// <summary> /// Resolves the virtual path. /// </summary> /// <param name="pageModel">The page model.</param> /// <param name="routeValueDictionary">The route value dictionary.</param> /// <returns></returns> public virtual string ResolveVirtualPath(IPageModel pageModel, RouteValueDictionary routeValueDictionary) { if (pageModel == null) { return null; } var url = pageModel.Metadata.Url ?? string.Empty; if (routeValueDictionary.ContainsKey(UIRoute.ActionKey)) { _action = routeValueDictionary[UIRoute.ActionKey] as string; if (_action != null && !_action.Equals(UIRoute.DefaultAction)) { return string.Format("{0}/{1}/", url, _action); } } return string.Format("{0}", VirtualPathUtility.AppendTrailingSlash(url)); }
private List <WebContentResultsModel> GetResults(IPageModel model) { return(Service .FindAll() .OrderBy(x => x.WebContentId) .Skip(model.PageIndex * model.PageSize) .Take(model.PageSize) .Select(x => new WebContentResultsModel() { PageIndex = model.PageIndex, PageSize = model.PageSize, ResultCount = model.ResultCount, WebContentId = x.WebContentId, Name = x.Name }).ToList()); }
/// <summary> /// Resolves the virtual path. /// </summary> /// <param name="pageModel">The page model.</param> /// <param name="routeValueDictionary">The route value dictionary.</param> /// <returns></returns> public virtual string ResolveVirtualPath(IPageModel pageModel, RouteValueDictionary routeValueDictionary) { if(pageModel == null) { throw new BrickPileException("A link cannot be created to a non existing page"); } var url = pageModel.Parent == null ? string.Empty : pageModel.Metadata.Url; if (routeValueDictionary.ContainsKey(PageRoute.ActionKey)) { _action = routeValueDictionary[PageRoute.ActionKey] as string; if (!string.IsNullOrEmpty(_action) && !_action.Equals(PageRoute.DefaultAction)) { return string.Format("{0}/{1}", url, _action); } } return string.Format("{0}", url); }
public IPathData ResolvePath(string virtualUrl) { // Set the default action to index _pathData.Action = ContentRoute.DefaultAction; // Set the default controller to content _pathData.Controller = ContentRoute.DefaultControllerName; // Get an up to date page repository _repository = _container.GetInstance<IPageRepository>(); // The requested url is for the start page with no action if (string.IsNullOrEmpty(virtualUrl) || string.Equals(virtualUrl,"/")) { _pageModel = _repository.SingleOrDefault<IPageModel>(x => x.Parent == null); _pathData.CurrentPageModel = _pageModel; return _pathData; } // Remove the trailing slash virtualUrl = VirtualPathUtility.RemoveTrailingSlash(virtualUrl); // The normal beahaviour should be to load the page based on the url _pageModel = _repository.GetPageByUrl<IPageModel>(virtualUrl); // Try to load the page without the last segment of the url and set the last segment as action)) if (_pageModel == null && virtualUrl.LastIndexOf("/") > 0) { var index = virtualUrl.LastIndexOf("/"); var action = virtualUrl.Substring(index, virtualUrl.Length - index).Trim(new[] {'/'}); virtualUrl = virtualUrl.Substring(0, index).TrimStart(new[] { '/' }); _pageModel = _repository.GetPageByUrl<IPageModel>(virtualUrl); _pathData.Action = action; } // If the page model still is empty, let's try to resolve if the start page has an action named (virtualUrl) if(_pageModel == null) { _pageModel = _repository.SingleOrDefault<IPageModel>(x => x.Parent == null); var controllerName = _controllerMapper.GetControllerName(typeof(ContentController)); var action = virtualUrl.TrimStart(new[] {'/'}); if(!_controllerMapper.ControllerHasAction(controllerName,action)) { return null; } _pathData.Action = action; } if (_pageModel == null) { return null; } _pathData.CurrentPageModel = _pageModel; return _pathData; }
/// <summary> /// Resolves the virtual path. /// </summary> /// <param name="pageModel">The page model.</param> /// <param name="routeValueDictionary">The route value dictionary.</param> /// <returns></returns> public virtual string ResolveVirtualPath(IPageModel pageModel, RouteValueDictionary routeValueDictionary) { if (pageModel == null) { return(null); } var url = pageModel.Metadata.Url ?? string.Empty; if (routeValueDictionary.ContainsKey(UIRoute.ActionKey)) { _action = routeValueDictionary[UIRoute.ActionKey] as string; if (_action != null && !_action.Equals(UIRoute.DefaultAction)) { return(string.Format("{0}/{1}/", url, _action)); } } return(string.Format("{0}", VirtualPathUtility.AppendTrailingSlash(url))); }
void Frame_SelectionChanged(object sender, SelectionChangedEventArgs e) { var tabFrame = Frame; IPageModel page = PageActive; if (tabFrame.SelectedIndex < 0 || page == null) { return; } if (oldPageActive != null && page != oldPageActive) { //oldPageActive.Deactivate(); //oldPageActive = null; } //page.Activate(); oldPageActive = page; }
private List <ListBookModel> GetResults(IPageModel model) { return(Service .FindAll() .OrderBy(x => x.BookingId) .Skip(model.PageIndex * model.PageSize) .Take(model.PageSize) .Select(x => new ListBookModel() { PageIndex = model.PageIndex, PageSize = model.PageSize, ResultCount = model.ResultCount, BookingId = x.BookingId, CreatedOn = x.CreatedOn, Email = x.Email, Name = x.Name, Telephone = x.Telephone }).ToList()); }
public void CloseRelatedModels(IPageModel model) { var views = SecondaryViews.ToArray(); foreach (var view in views) { var m = view.DataModel; if (m is null) { continue; } if (m.Root != m.Root) { continue; } view.CloseModel(); } }
/// <summary> /// Responsible for providing the Edit view with data from the current page /// </summary> /// <returns></returns> public ActionResult Edit() { IPageModel parent = _model.Parent != null?_session.Load <IPageModel>(_model.Parent.Id) : null; var viewModel = new EditViewModel { RootModel = _session.Query <IPageModel>().SingleOrDefault(model => model.Parent == null), CurrentModel = _model, ParentModel = parent, IlligalSlugs = parent != null?Newtonsoft.Json.JsonConvert.SerializeObject(_session.Load <IPageModel>(parent.Children).Select(x => x.Metadata.Slug)) : null }; if (Request.IsAjaxRequest()) { return(PartialView("Edit", viewModel)); } ViewBag.Class = "edit"; return(View(viewModel)); }
public static IHtmlString Pager(this HtmlHelper helper, IPageModel model, int showCount = 10, bool isShowHomeAndLast = true, bool isShowPrevAndNext = true, bool isHomeAndLastInside = true, bool isShowInput = true, bool isUseDefaultSubmitScript = true, bool isWithQueryString = true, bool isUrlEncode = false, string interval = "<span class=\"{0}\">...</span>", string itemTemplate = "<a href=\"{1}\" class=\"{2}\">{0}</a>", string indexTemplate = "<b class=\"{1}\">{0}</b>", string parentTemplate = null, string inputTemplate = "<input class=\"{1}\" value=\"{0}\" />", string submitTemplate = "<input type=\"button\" class=\"{0}\" id=\"{1}\" value=\"确定\" />", string homeString = null, string lastString = null, string prevString = "上一页", string nextString = "下一页") { return new Pager(helper, model, showCount: showCount, isShowHomeAndLast: isShowHomeAndLast, isShowPrevAndNext: isShowPrevAndNext, isHomeAndLastInside: isHomeAndLastInside, isShowInput: isShowInput, isUseDefaultSubmitScript: isUseDefaultSubmitScript, isWithQueryString: isWithQueryString, isUrlEncode: isUrlEncode, interval: interval, itemTemplate: itemTemplate, indexTemplate: indexTemplate, parentTemplate: parentTemplate, inputTemplate: inputTemplate, submitTemplate: submitTemplate, homeString: homeString, lastString: lastString, prevString: prevString, nextString: nextString); }
public static IHtmlString Pager(this HtmlHelper helper, IPageModel model, int showCount = 10, bool isShowHomeAndLast = true, bool isShowPrevAndNext = true, bool isHomeAndLastInside = true, bool isShowInput = true, bool isUseDefaultSubmitScript = true, bool isWithQueryString = true, bool isUrlEncode = false, string interval = "<span class=\"{0}\">...</span>", string itemTemplate = "<a href=\"{1}\" class=\"{2}\">{0}</a>", string indexTemplate = "<b class=\"{1}\">{0}</b>", string parentTemplate = null, string inputTemplate = "<input class=\"{1}\" value=\"{0}\" />", string submitTemplate = "<input type=\"button\" class=\"{0}\" id=\"{1}\" value=\"确定\" />", string homeString = null, string lastString = null, string prevString = "上一页", string nextString = "下一页") { return(new Pager(helper, model, showCount: showCount, isShowHomeAndLast: isShowHomeAndLast, isShowPrevAndNext: isShowPrevAndNext, isHomeAndLastInside: isHomeAndLastInside, isShowInput: isShowInput, isUseDefaultSubmitScript: isUseDefaultSubmitScript, isWithQueryString: isWithQueryString, isUrlEncode: isUrlEncode, interval: interval, itemTemplate: itemTemplate, indexTemplate: indexTemplate, parentTemplate: parentTemplate, inputTemplate: inputTemplate, submitTemplate: submitTemplate, homeString: homeString, lastString: lastString, prevString: prevString, nextString: nextString)); }
// #region RemoveModelPage ============================================== public void RemoveModelPage(IPageModel model) { var item = navigationView.MenuItems .OfType <WinUI.NavigationViewItem>() .FirstOrDefault(menuItem => (menuItem.Tag == model)); if (item is null) { return; } navigationView.MenuItems.Remove(item); var home = navigationView.MenuItems .OfType <WinUI.NavigationViewItem>() .FirstOrDefault(menuItem => (menuItem.Name == "Home")); if (!(home is null)) { home.IsSelected = true; NavigationService.Navigate(typeof(MainPage)); } }
// #region InsertModelPage ============================================== public void InsertModelPage(IPageModel model) { if (model is null) { return; } Root.SetLocalizer(Helpers.ResourceExtensions.CoreLocalizer()); var item = navigationView.MenuItems .OfType <WinUI.NavigationViewItem>() .FirstOrDefault(menuItem => (menuItem.Name == "Home")); if (item is null) { return; } var index = navigationView.MenuItems.IndexOf(item) + 2; var navItem = new WinUI.NavigationViewItem { Content = model.TitleName, Icon = new SymbolIcon(Symbol.AllApps), Tag = model }; ToolTipService.SetToolTip(navItem, model.TitleSummary); navItem.Loaded += NavItem_Loaded; navigationView.MenuItems.Insert(index, navItem); //navigationView.SelectedItem = navItem; //Selected = navItem; NavigationService.Navigate(typeof(ModelPage), model); }
/// <summary> /// Initializes a new instance of the <b>PagesController</b> class. /// </summary> /// <param name="model">The model.</param> /// <param name="session">The session.</param> public PagesController(IPageModel model, IDocumentSession session) { _model = model; _session = session; }
public AdminValuesController(IUserModel userModel, ITokenModel token, IPageModel page) { _page = page; _user = userModel; _token = token; }
private static void RenderLi(StringBuilder sb, string format, IPageModel item, Func<IPageModel, MvcHtmlString> itemContent) { sb.AppendFormat(format, itemContent(item)); }
public static Pager Pager(this HtmlHelper helper, IPageModel pager) { return(new Pager(pager, helper.ViewContext)); }
/// <summary> /// Initializes a new instance of the <see cref="PageModelEventArgs"/> class. /// </summary> /// <param name="model">The model.</param> public PageModelEventArgs(IPageModel model) { this.Model = model; }
/// <summary> /// Initializes a new instance of the <see cref="DashboardViewModel"/> class. /// </summary> /// <param name="model">The model.</param> public DashboardViewModel(IPageModel model) { CurrentModel = model; }
/// <summary> /// Responsible for creating a navigation based on an unordered list /// </summary> /// <param name="html">HtmlHelper</param> /// <param name="id">Id of the unordered list</param> /// <param name="currentModel">The current page in the current request</param> /// <param name="hierarchy">The hierarchy.</param> /// <param name="itemContent">Default content for links</param> /// <returns></returns> public static string Menu(this HtmlHelper html, string id, IPageModel currentModel, IEnumerable<IPageModel> hierarchy, Func<IPageModel, MvcHtmlString> itemContent) { return Menu(html, id, currentModel, hierarchy, itemContent, itemContent); }
/// <summary> /// Responsible for creating a main navigation based on an unordered list /// </summary> /// <param name="html">HtmlHelper</param> /// <param name="id">The id of the unordered list</param> /// <param name="currentModel">The current model.</param> /// <param name="hierarchy">The hierarchy.</param> /// <param name="itemContent">Default content for links</param> /// <param name="selectedItemContent">Content for selected links</param> /// <returns></returns> public static string Menu(this HtmlHelper html, string id, IPageModel currentModel, IEnumerable<IPageModel> hierarchy, Func<IPageModel, MvcHtmlString> itemContent, Func<IPageModel, MvcHtmlString> selectedItemContent) { if (hierarchy== null) { return String.Empty; } var hierarchyNodes = hierarchy.AsHierarchy(); // only render the top level items var items = hierarchyNodes.Where(x => x.Depth == 1); var sb = new StringBuilder(); if(string.IsNullOrEmpty(id)) { sb.AppendLine("<ul>"); } else { sb.AppendFormat("<ul id=\"{0}\">", id); } foreach (var item in items) { RenderLi(sb, "<li>{0}</li>", item.Entity, item.Entity.Equals(currentModel) ? selectedItemContent : itemContent); } sb.AppendLine("</ul>"); return sb.ToString(); }
/// <summary> /// Actions the specified URL helper. /// </summary> /// <param name="urlHelper">The URL helper.</param> /// <param name="actionName">Name of the action.</param> /// <param name="model">The model.</param> /// <returns></returns> public static string Action(this UrlHelper urlHelper, string actionName, IPageModel model) { return(urlHelper.Action(actionName, new { model })); }
public PageInstance(Page aPage, IPageModel aModel) { iPage = aPage; iModel = aModel; }
internal Page(PrintJob job, Guid id, IPageModel pageModel) { _job = job; _id = id; _templateUri = pageModel.TemplateUrl; _variables = pageModel.Variables; }
/// <summary> /// Creates and executes a single-page print job. /// </summary> /// <param name="pageModel"></param> /// <returns></returns> public static Result Run(IPageModel pageModel) { return Run(new[] {pageModel}); }
/// <summary> /// Creates and executes a single-page print job. /// </summary> /// <param name="pageModel"></param> /// <returns></returns> public static Result Run(IPageModel pageModel) { return(Run(new[] { pageModel })); }
protected override void OnReceive(Session aSession, string aName, string aValue) { switch (aName) { case "PreviousPage": aSession.Navigator.PreviousPage(aSession); return; case "ReturnToPage": aSession.Navigator.PreviousPage(aSession, aValue); return; case "LinkClicked": System.Diagnostics.Process.Start(aValue); return; case "DataCollectionEnabled": aSession.Tracking = bool.Parse(aValue); return; } if (aName.StartsWith("setData")) { // get the page model for this session IPageModel model = GetSessionModel(aSession); Assert.Check(model != null); // get the data id to set string dataId = aName.Substring(7); System.Reflection.PropertyInfo prop = model.GetType().GetProperty(dataId); prop.SetValue(model, aValue, null); } if (aName.StartsWith("action")) { // get the page model for this session IPageModel model = GetSessionModel(aSession); // get the action id to process string actionId = aName.Substring(6); // process all actions with the given id foreach (PageDefinitions.Action action in iPageDefinition.Actions) { if (action.Id == actionId) { // process <Action type="navigate"> actions PageDefinitions.ActionNavigate actionNav = action as PageDefinitions.ActionNavigate; if (actionNav != null) { if (actionNav.Source != null) { Assert.Check(model != null); // get next page name from data model System.Reflection.PropertyInfo prop = model.GetType().GetProperty(actionNav.Source); string pageId = prop.GetValue(model, null) as string; aSession.Navigator.NextPage(aSession, pageId); } else { // jump to specified page id aSession.Navigator.NextPage(aSession, actionNav.PageId); } } // process <Action type="data"> actions PageDefinitions.ActionData actionData = action as PageDefinitions.ActionData; if (actionData != null) { Assert.Check(model != null); System.Reflection.PropertyInfo prop = model.GetType().GetProperty(actionData.DataId); prop.SetValue(model, (actionData.DataValue != null) ? actionData.DataValue : aValue, null); } // process <Action type="method"> actions PageDefinitions.ActionMethod actionMethod = action as PageDefinitions.ActionMethod; if (actionMethod != null) { Assert.Check(model != null); System.Reflection.MethodInfo method = model.GetType().GetMethod(actionMethod.MethodId); method.Invoke(model, null); } } } } }
/// <summary> /// Initializes a new instance of the <b>PagesController</b> class. /// </summary> /// <param name="model">The model.</param> /// <param name="session">The session.</param> public PagesController(IPageModel model, IDocumentSession session) { _model = model; _session = session; }
public PageNotExpectedException(IPageModel model, string expectedUrl) : base(ToMessage(model, expectedUrl)) { }
private static string ToMessage(IPageModel model, string expectedUrl) { return string.Format("Expected URL was {0} but page was created with URL {1}", expectedUrl, model.Url); }
/// <summary> /// Initializes a new instance of the <see cref="PageModelEventArgs"/> class. /// </summary> /// <param name="model">The model.</param> public PageModelEventArgs(IPageModel model) { this.Model = model; }
public GuestBookController(IPageRepository pageRepository, IStructureInfo structureInfo,IPageModel currentPage) { _currentPage = currentPage as GuestBook; _pageRepository = pageRepository; _structureInfo = structureInfo; }
/// <summary> /// Resolves the path. /// </summary> /// <param name="routeData">The route data.</param> /// <param name="virtualUrl">The virtual URL.</param> /// <returns></returns> public IPathData ResolvePath(RouteData routeData, string virtualUrl) { // Set the default action to index _pathData.Action = UIRoute.DefaultAction; // Get an up to date document session from structuremap _session = _container.GetInstance<IDocumentSession>(); // The requested url is for the start page with no action if (string.IsNullOrEmpty(virtualUrl) || string.Equals(virtualUrl, "/")) { _pageModel = _session.Query<IPageModel>() .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite()) .SingleOrDefault(x => x.Parent == null); } else { // Remove the trailing slash virtualUrl = VirtualPathUtility.RemoveTrailingSlash(virtualUrl).TrimStart(new[] { '/' }); // The normal beahaviour should be to load the page based on the url _pageModel = _session.Query<IPageModel, PageByUrl>() .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite()) .FirstOrDefault(x => x.Metadata.Url == virtualUrl); // Try to load the page without the last segment of the url and set the last segment as action)) if (_pageModel == null && virtualUrl.LastIndexOf("/") > 0) { var index = virtualUrl.LastIndexOf("/"); var action = virtualUrl.Substring(index, virtualUrl.Length - index).Trim(new[] { '/' }); virtualUrl = virtualUrl.Substring(0, index).TrimStart(new[] { '/' }); _pageModel = _session.Query<IPageModel, PageByUrl>() .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite()) .FirstOrDefault(x => x.Metadata.Url == virtualUrl); _pathData.Action = action; } // If the page model still is empty, let's try to resolve if the start page has an action named (virtualUrl) if (_pageModel == null) { _pageModel = _session.Query<IPageModel>().SingleOrDefault(x => x.Parent == null); if(_pageModel == null) { return null; } var pageTypeAttribute = _pageModel.GetType().GetAttribute<PageTypeAttribute>(); object area; _controllerName = _controllerMapper.GetControllerName(routeData.Values.TryGetValue("area", out area) ? typeof(PagesController) : pageTypeAttribute.ControllerType); var action = virtualUrl.TrimStart(new[] { '/' }); if (!_controllerMapper.ControllerHasAction(_controllerName, action)) { return null; } _pathData.Action = action; } } if (_pageModel == null) { return null; } var controllerType = _pageModel.GetType().GetAttribute<PageTypeAttribute>().ControllerType; _pathData.Controller = controllerType != null ? _controllerMapper.GetControllerName(controllerType) : string.Format("{0}Controller", _pageModel.GetType().Name); _pathData.CurrentPage = _pageModel; _pathData.NavigationContext = _session.GetPublishedPages(_pageModel.Id); return _pathData; }
/// <summary> /// Initializes a new instance of the <b>PagesController</b> class. /// </summary> /// <param name="model">The model.</param> /// <param name="repository">The repository.</param> /// <param name="session">The session.</param> public ContentController(IPageModel model, IRepository<IPageModel> repository, IDocumentSession session) { _model = model; _repository = repository; _session = session; }