Example #1
0
        public static MvcHtmlString RenderPopup(HtmlHelper helper, TypeContext typeContext, RenderPopupMode mode, EntityBase line, bool isTemplate = false)
        {
            TypeContext tc = TypeContextUtilities.CleanTypeContext((TypeContext)typeContext);

            ViewDataDictionary vdd = GetViewData(helper, line, tc);

            string partialViewName = line.PartialViewName ?? OnPartialViewName(tc);

            vdd[ViewDataKeys.PartialViewName] = partialViewName;
            vdd[ViewDataKeys.ViewMode] = !line.ReadOnly;
            vdd[ViewDataKeys.ViewMode] = ViewMode.View;
            vdd[ViewDataKeys.ShowOperations] = true;
            vdd[ViewDataKeys.SaveProtected] = OperationLogic.IsSaveProtected(tc.UntypedValue.GetType());
            vdd[ViewDataKeys.WriteEntityState] = 
                !isTemplate &&
                !(tc.UntypedValue is EmbeddedEntity) &&
                ((ModifiableEntity)tc.UntypedValue).Modified == ModifiedState.SelfModified;

            switch (mode)
            {
                case RenderPopupMode.Popup:
                    return helper.Partial(Navigator.Manager.PopupControlView, vdd);
                case RenderPopupMode.PopupInDiv:
                    return helper.Div(typeContext.Compose(EntityBaseKeys.Entity),
                        helper.Partial(Navigator.Manager.PopupControlView, vdd),  
                        "",
                        new Dictionary<string, object> { { "style", "display:none" } });
                default:
                    throw new InvalidOperationException();
            }
        }
Example #2
0
        public static MvcHtmlString RenderContent(HtmlHelper helper, TypeContext typeContext, RenderContentMode mode, EntityBase line)
        {
            TypeContext tc = TypeContextUtilities.CleanTypeContext((TypeContext)typeContext);

            ViewDataDictionary vdd = GetViewData(helper, line, tc);
            
            string partialViewName = line.PartialViewName ?? OnPartialViewName(tc);

            switch (mode)
            {
                case RenderContentMode.Content:
                    return helper.Partial(partialViewName, vdd);

                case RenderContentMode.ContentInVisibleDiv:
                    return helper.Div(typeContext.Compose(EntityBaseKeys.Entity),
                      helper.Partial(partialViewName, vdd), "",
                      null);
                case RenderContentMode.ContentInInvisibleDiv:
                    return helper.Div(typeContext.Compose(EntityBaseKeys.Entity),
                        helper.Partial(partialViewName, vdd), "",
                         new Dictionary<string, object> { { "style", "display:none" } });
                default:
                    throw new InvalidOperationException();
            }
        }
Example #3
0
        public static IHtmlString Render(string alias, HtmlHelper<RenderModel> helper)
        {

            try
            {
                // If request is coming from frontend then always show frontend content, check authentication if it comes from backend (.aspx)

                var isAuthenticated = false;

                if (HttpContext.Current.Request.Path.Contains(".aspx"))
                {
                    isAuthenticated = Authorize.isAuthenticated();
                }

                var view = ViewHelper.Get(alias, isAuthenticated);

                var culture = CultureInfo.CreateSpecificCulture(UmbracoContext.Current.PublishedContentRequest.Culture.Name);

                Thread.CurrentThread.CurrentCulture = culture;
                Thread.CurrentThread.CurrentUICulture = culture;

                var model = helper.Partial(view.viewName, view);

                return new HtmlString(model.ToString());

            }
            catch (Exception ex)
            {

                Log.Error("Canvas Error on Render in API.", ex);
                return new HtmlString("");

            }

        }
 public string Render(HtmlHelper html)
 {
     try
     {
         return html.Partial(Macro.ScriptName, html.ViewData).ToHtmlString();
     }
     catch(Exception ex)
     {
         return HttpUtility.HtmlEncode(ex.ToString());
     }
 }
 private static IHtmlString RenderThemeCustomPartial(HtmlHelper helper, string viewPathToFormat)
 {
     string themeName = new LayersCmsConfigHelper().GetTheme();
     string viewPath = string.Format(viewPathToFormat, themeName);
     string filePath = HttpContext.Current.Server.MapPath(String.Format("~/views/shared/{0}.cshtml", viewPath));
     if (File.Exists(filePath))
     {
         return helper.Partial(viewPath);
     }
     return null;
 }
Example #6
0
        public static MvcHtmlString Menu(this HtmlHelper helper)
        {
            server = helper.ViewContext.RequestContext.HttpContext.Server;
            request = helper.ViewContext.RequestContext.HttpContext.Request;
            urlHelper = new UrlHelper(helper.ViewContext.RequestContext);
            routeDictionary = helper.ViewContext.RequestContext.RouteData.Values;
            HtmlHelper htmlHelper = new HtmlHelper(helper.ViewContext, helper.ViewDataContainer);

            //获取当前用户信息
            //TalentMISDbContext db = new TalentMISDbContext();
            //string current_account = helper.ViewContext.RequestContext.HttpContext.User.Identity.Name;
            //Account account = db.Accounts.FirstOrDefault(x => x.UserName.Trim().ToUpper() == current_account.Trim().ToUpper());
            //string roleCode = account.RoleCode;
            string roleCode = ((CurrentUser)helper.ViewContext.RequestContext.HttpContext.Session["CurrentUser"]).RoleCode;

            //加载菜单xml文件
            //string xmlPath = server.MapPath(url.Content("~/Menu.xml"));//当禁用Cookie时会话标识会嵌入URL中,此时该行代码结果就不正确了!(夏春涛)
            string webRootPath = server.MapPath("/");
            string xmlPath = webRootPath.TrimEnd('\\') + "\\Menu.xml";
            XDocument doc = XDocument.Load(xmlPath);
            var xmlNav = doc.Root;

            //获取所有符合条件的一级菜单(其中包括所有二级菜单)
            var nav1Items = xmlNav
                    .Elements("NavItem")
                    .Where(p => p.Attribute("roles").Value.Trim() == "" ||
                                p.Attribute("roles").Value.Trim().ToUpper().Contains(roleCode.ToUpper()));

            foreach (var nav1 in nav1Items)
            {
                //删除一级菜单下不符合条件的二级菜单
                var nav2List = nav1.Elements("NavItem").ToList();
                foreach (var nav2 in nav2List)
                {
                    if (nav2.Attribute("roles").Value.Trim() == "")//任意角色均可访问的二级菜单
                    {
                        continue;
                    }
                    bool isPermitted = nav2.Attribute("roles").Value.ToUpper().Contains(roleCode.Trim().ToUpper());
                    if (!isPermitted)//用户角色不再许可范围内
                    {
                        nav1.Elements("NavItem")
                            .Where(p => p.Attribute("code").Value.Trim().ToUpper() == nav2.Attribute("code").Value.Trim().ToUpper())
                            .Remove();
                    }
                }
            }

            //如果一级菜单下面没有二级菜单,则删除该一级菜单
            nav1Items.Where(p => p.Elements().Count() == 0).Remove();
            //----
            MvcHtmlString result = htmlHelper.Partial("Menu", nav1Items);
            return result;
        }
		/// <summary>
		/// Outputs and caches a partial view in MVC
		/// </summary>
		/// <param name="cacheHelper"></param>
		/// <param name="htmlHelper"></param>
		/// <param name="partialViewName"></param>
		/// <param name="model"></param>
		/// <param name="cachedSeconds"></param>
		/// <param name="cacheKey">used to cache the partial view, this key could change if it is cached by page or by member</param>
		/// <param name="viewData"></param>
		/// <returns></returns>
		public static IHtmlString CachedPartialView(
			this CacheHelper cacheHelper,
			HtmlHelper htmlHelper,
			string partialViewName,
			object model,
			int cachedSeconds,
			string cacheKey,
			ViewDataDictionary viewData = null)
		{
			return cacheHelper.GetCacheItem(
				PartialViewCacheKey + cacheKey,
				CacheItemPriority.NotRemovable, //not removable, the same as macros (apparently issue #27610)
				null,
				new TimeSpan(0, 0, 0, cachedSeconds),
				() => htmlHelper.Partial(partialViewName, model, viewData));
		}
Example #8
0
        /// <summary>
        /// 生成最终的分页Html代码
        /// </summary>
        /// <param name="htmlHelper"></param>
        /// <param name="pagedable"></param>
        /// <param name="pagingTemplatePartialName"></param>
        /// <returns></returns>
        private static MvcHtmlString RenderPager(HtmlHelper htmlHelper, IPagedable pagedable, string pagingTemplatePartialName)
        {
            if (pagedable.PageNumber <= 0)
            {
                pagedable.PageNumber = 1;
            }

            if (pagedable.PageNumber > 0 && pagedable.PageNumber >= pagedable.PageCount)
            {
                pagedable.PageNumber = pagedable.PageCount;
            }

            var templateHtml = htmlHelper.Partial(pagingTemplatePartialName, pagedable);

            if (templateHtml == null)
                throw new ArgumentException(pagingTemplatePartialName);
            return templateHtml;
        }
        /// <summary>
        /// Contains functionality to parse template to html with needed 
        /// for razor attributes to have ability send data to main model
        /// </summary>
        /// <param name="htmlHelper">The HTML helper.</param>
        /// <param name="partialViewName">Template for html generation</param>
        /// <param name="model">Model for data binding</param>
        /// <param name="prefix">Prefix for input fields</param>
        /// <param name="useModelProperties">Define if needed compare attributes with model property names</param>
        public static string GenerateHtmlFromPartialWithPrefix(HtmlHelper htmlHelper, string partialViewName, object model, string prefix, bool useModelProperties = true)
        {
            var partialHtml = htmlHelper.Partial(partialViewName, model).ToHtmlString();

            var res = "";

            var properties = model.GetType().GetProperties().Select(s => s.Name);
            if (useModelProperties)
            {
                var doc = new HtmlDocument();
                doc.LoadHtml(partialHtml);
                AddPrefix(doc, prefix, properties);

                res = doc.DocumentNode.InnerHtml;
            }
            else
            {
                partialHtml = ReplaceTagWithPrefix(partialHtml, "textarea", prefix, true);
                partialHtml = ReplaceTagWithPrefix(partialHtml, "input", prefix, false);
                res = partialHtml;
            }

            return res;
        }
Example #10
0
 public static IHtmlString JsBootstrap(this HtmlHelper html)
 {
     //Contract.Requires( html != null );
     return(html.Partial <Views.JsBootstrap>());
 }
Example #11
0
 public static IHtmlString Render(this PropertyVm propertyVm, HtmlHelper html)
 {
     return(html.Partial("FormFactory/Form.Property", propertyVm));
 }
Example #12
0
 /// <summary>
 /// 根据用户自定义的渲染方法生成数据采集组件
 /// </summary>
 /// <param name="htmlHelper"></param>
 /// <param name="userRenderer"></param>
 /// <returns></returns>
 public static MvcHtmlString AdvDataEdit(this HtmlHelper htmlHelper, Func <string, object, HelperResult> userRenderer = null)
 {
     htmlHelper.ViewBag.UserRenderer = userRenderer;
     return(htmlHelper.Partial("_AdvDataEdit"));
 }
Example #13
0
 /// <summary>
 /// 多语言文本控件
 /// </summary>
 /// <param name="helper">HTML帮助对象</param>
 /// <param name="formData">多语言控件需要的表单属性对象</param>
 /// <returns></returns>
 public static MvcHtmlString LangTextInput(this HtmlHelper helper, LangTextFormData formData)
 {
     helper.ViewBag.ParaModel = formData;
     return(helper.Partial("_LangTextInput"));
 }
Example #14
0
 public static MvcHtmlString PageEditorInfo(this HtmlHelper helper, string infoMessage)
 {
     return(Context.PageMode.IsNormal ? new MvcHtmlString(string.Empty) : helper.Partial(Constants.InfoMessageView, InfoMessage.Info(infoMessage)));
 }
Example #15
0
 /// <summary>
 /// HtmlHelper Pager - 扩展方法
 /// </summary>
 /// <param name="helper">HtmlHelper</param>
 /// <param name="pagerModel">分页信息</param>
 /// <param name="onPageChange">翻页地址或事件</param>
 /// <param name="pagerViewName">分页分部视图名称,默认值为【_PagerPartial】</param>
 /// <param name="displayMode">分页显示模式</param>
 /// <returns></returns>
 public static MvcHtmlString Pager(this HtmlHelper helper, IPagerModel pagerModel, Func <int, string> onPageChange, string pagerViewName, PagingDisplayMode displayMode)
 {
     pagerModel.OnPageChange      = onPageChange;
     pagerModel.PagingDisplayMode = displayMode;
     return(MvcHtmlString.Create(helper.Partial(pagerViewName, pagerModel).ToHtmlString()));
 }
Example #16
0
 public static MvcHtmlString AutocompleteLocalSourceTextBox(this HtmlHelper html, AutocompleteLocalSourceModel model)
 {
     return(html.Partial("AutocompleteLocalSourceTextBox", model));
 }
Example #17
0
 public override MvcHtmlString Render(HtmlHelper <InitialDataViewModel> helper)
 {
     return(helper.Partial("_TurnViewModel", this));
 }
 /// <summary>
 /// An alias for Partial() to indicate a dialog's HTML is being rendered.
 /// </summary>
 public static MvcHtmlString DialogPartial(this HtmlHelper helper, string viewName, object model)
 {
     return(helper.Partial(viewName, model));
 }
 /// <summary>
 /// Returns the rendered partial navigation menu.
 /// </summary>
 public static MvcHtmlString SiteSettingsNavigation(this HtmlHelper htmlHelper)
 {
     return(htmlHelper.Partial("Navigation"));
 }
 /// <summary>
 /// An alias for Partial() to indicate a dialog's HTML is being rendered.
 /// </summary>
 public static MvcHtmlString DialogPartial(this HtmlHelper helper, string viewName)
 {
     return(helper.Partial("Dialogs/" + viewName));
 }
public static System.Web.WebPages.HelperResult Form(HtmlHelper htmlHelper, INode node, IEnumerable<IInvokeableParameter> fieldsToDisplay)
{
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {



#line 53 "..\..\Helpers\NoodlesHelper.cshtml"
 
    if (node != null)
    {
        Func<dynamic, HelperResult> initHtml = (item => new System.Web.WebPages.HelperResult(__razor_template_writer => {

#line default
#line hidden


WebViewPage.WriteLiteralTo(@__razor_template_writer, "\r\n");



#line 57 "..\..\Helpers\NoodlesHelper.cshtml"
      
        var isNodeMethod = node is NodeMethod;
        var fields = fieldsToDisplay as IInvokeableParameter[] ?? fieldsToDisplay.ToArray();
        if (isNodeMethod || fields.Any())
        {

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_template_writer, "        <form class=\"node-form\" action=\"");



#line 62 "..\..\Helpers\NoodlesHelper.cshtml"
WebViewPage.WriteTo(@__razor_template_writer, node.Url);

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_template_writer, "\" method=\"POST\" enctype=\"multipart/form-data\">\r\n");



#line 63 "..\..\Helpers\NoodlesHelper.cshtml"
              
            var descriptionAttribute = node.Attributes.OfType<DescriptionAttribute>().SingleOrDefault();
            if (descriptionAttribute != null)
            {

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_template_writer, "                <div class=\"noodles-callout noodles-callout-info\">\r\n             " +
"       ");



#line 68 "..\..\Helpers\NoodlesHelper.cshtml"
WebViewPage.WriteTo(@__razor_template_writer, htmlHelper.Raw(descriptionAttribute.Description));

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_template_writer, "\r\n                </div>\r\n");



#line 70 "..\..\Helpers\NoodlesHelper.cshtml"
            }
            

#line default
#line hidden



#line 72 "..\..\Helpers\NoodlesHelper.cshtml"
             if (htmlHelper.ViewData.ModelState.SelectMany(ms => ms.Value.Errors).Any())
            {

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_template_writer, "                <div class=\"noodles-callout noodles-callout-danger\">\r\n           " +
"         Please correct the issues below: ");



#line 75 "..\..\Helpers\NoodlesHelper.cshtml"
        WebViewPage.WriteTo(@__razor_template_writer, htmlHelper.ValidationSummary(true));

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_template_writer, "\r\n                </div>\r\n");



#line 77 "..\..\Helpers\NoodlesHelper.cshtml"
            }

#line default
#line hidden



#line 78 "..\..\Helpers\NoodlesHelper.cshtml"
             foreach (var field in fields)
            {
                var parameter = field;
                var vm = parameter.ToPropertyVm();
                
#line default
#line hidden


#line 82 "..\..\Helpers\NoodlesHelper.cshtml"
WebViewPage.WriteTo(@__razor_template_writer, htmlHelper.Partial("FormFactory/Form.Property", vm));

#line default
#line hidden


#line 82 "..\..\Helpers\NoodlesHelper.cshtml"
                                                                    
            }

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_template_writer, "            <input type=\"submit\" value=\"");



#line 84 "..\..\Helpers\NoodlesHelper.cshtml"
WebViewPage.WriteTo(@__razor_template_writer, isNodeMethod ? node.DisplayName : "Update");

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_template_writer, "\" />\r\n        </form>\r\n");



#line 86 "..\..\Helpers\NoodlesHelper.cshtml"
        }

    

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_template_writer, "    ");



#line 89 "..\..\Helpers\NoodlesHelper.cshtml"
         }));
        var html = initHtml(null).ToHtmlString();
        foreach (var transformAtt in node.Attributes.OfType<ITransformHtml>().Where(a => a.GetType().GetCustomAttribute<NotInFormHelperAttribute>() == null))
        {
            html = transformAtt.Transform(htmlHelper, node, html).ToHtmlString();
        }
    
#line default
#line hidden


#line 95 "..\..\Helpers\NoodlesHelper.cshtml"
WebViewPage.WriteTo(@__razor_helper_writer, htmlHelper.Raw(html));

#line default
#line hidden


#line 95 "..\..\Helpers\NoodlesHelper.cshtml"
                         
    }

#line default
#line hidden

});

}
Example #22
0
public static System.Web.WebPages.HelperResult Block(ExerciseBlock block, BlockRenderContext context, HtmlHelper Html)
{
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {


 

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t<div class=\"exercise\">\r\n");


  		
			ExerciseBlockData data = context.GetBlockData(block) ?? new ExerciseBlockData(context.Course.Id, context.Slide as ExerciseSlide) { IsGuest = context.IsGuest, IsLti = context.IsLti };
			var manualCheckingId = context.ManualChecking != null ? (int?)context.ManualChecking.Id : null;

			if (Html != null)
			{
				
WebViewPage.WriteTo(@__razor_helper_writer, Html.Action("Submission", "Exercise", new { courseId = context.Course.Id, slideId = context.Slide.Id, submissionId = context.VersionId, manualCheckingId = manualCheckingId, isLti = data.IsLti, instructorView = manualCheckingId != null }));

                                                                                                                                                                                                                                                  
			}
			else
			{

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t\t\t<div class=\"exercise__submission\">\r\n\t\t\t\t\t<textarea class=\"code code-exercise " +
"hidden\" data-lang=\"");


                 WebViewPage.WriteTo(@__razor_helper_writer, block.LangId);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\">");


                                 WebViewPage.WriteTo(@__razor_helper_writer, block.ExerciseInitialCode.EnsureEnoughLines(4));

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "</textarea>\r\n\t\t\t\t\t<div class=\"loading-spinner\">\r\n\t\t\t\t\t\t<img src=\"/Content/loading" +
".gif\" />\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t");


WebViewPage.WriteTo(@__razor_helper_writer, ExerciseControls(new ExerciseControlsModel(context.Course.Id, (ExerciseSlide)context.Slide)
				   {
					   IsCodeEditableAndSendable = true,
					   DebugView = data.DebugView,
					   RunSolutionUrl = data.RunSolutionUrl,
				   }));

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\r\n\r\n\t\t\t\t\t");


WebViewPage.WriteTo(@__razor_helper_writer, RunErrors());

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\r\n\t\t\t</div>\r\n");


			}
		

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t\r\n\r\n");


 		if (data.DebugView)
		{

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t\t<div>\r\n\t\t\t\t<h3>Подсказки</h3>\r\n\t\t\t\t<ol>\r\n");


 					foreach (var hint in data.Block.HintsMd)
					{

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t\t\t\t\t<li>\r\n\t\t\t\t\t\t\t");


WebViewPage.WriteTo(@__razor_helper_writer, MvcHtmlString.Create(hint.RenderMd(context.BaseUrl)));

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\r\n\t\t\t\t\t\t</li>\r\n");


					}

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t\t\t</ol>\r\n\t\t\t\t<h3>Комментарий после решения</h3>\r\n\t\t\t\t<p>");


WebViewPage.WriteTo(@__razor_helper_writer, data.Block.CommentAfterExerciseIsSolved);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "</p>\r\n\t\t\t</div>\r\n");


		}

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\r\n");


 		if (context.ManualChecking != null)
		{
			var checking = (ManualExerciseChecking)context.ManualChecking;

			
WebViewPage.WriteTo(@__razor_helper_writer, Html.Partial("~/Views/Exercise/_ExerciseScoreForm.cshtml", new ExerciseScoreFormModel(context.Course.Id, (ExerciseSlide) context.Slide, checking, context.GroupId, context.VersionId == null || checking.Submission.Id == context.VersionId)));

                                                                                                                                                                                                                                                 
		}

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t</div>\r\n");



});

}
        /// <summary>
        /// Renders a partial view in the current theme based on the current IMasterModel
        /// </summary>
        /// <param name="html"></param>
        /// <param name="model"></param>
        /// <param name="partialName"></param>
        /// <param name="viewModel"></param>
        /// <param name="viewData"></param>
        /// <returns></returns>
        public static IHtmlString ThemedPartial(this HtmlHelper html, IMasterModel model, string partialName, object viewModel, ViewDataDictionary viewData = null)
        {
            var path = PathHelper.GetThemePartialViewPath(model, partialName);

            return(html.Partial(path, viewModel, viewData));
        }
 public static MvcHtmlString Template(this HtmlHelper htmlHelper, IPublishedContent content)
 {
     return(htmlHelper.Partial(content.GetTemplate().VirtualPath, content));
 }
        public override System.Web.Mvc.MvcHtmlString WriteFilter(HtmlHelper helper, object htmlAttributes)
        {
            IDictionary<string, object> efHtmlAttributes = new RouteValueDictionary(htmlAttributes);
            AddCommonHtmlAttributes(efHtmlAttributes);

            return helper.Partial(PartialViewName, this);
        }
Example #26
0
        public static MvcHtmlString PartialView <T>(this HtmlHelper helper, string path, string tenant) where T : FrapidAreaRegistration, new()
        {
            string view = FrapidViewHelper.GetRazorView <T>(path, tenant);

            return(helper.Partial(view));
        }
Example #27
0
 public IHtmlString Transform(HtmlHelper htmlHelper, INode node, string html)
 {
     return htmlHelper.Partial(ViewName, node);
 }
 public static MvcHtmlString CreateQuestion(this HtmlHelper html, Question question)
 => html.Partial(String.Format("QuestionsPartial/_{0}", question.TypeAnswer), question);
Example #29
0
        public static MvcHtmlString PageEditorError(this HtmlHelper helper, string errorMessage, string friendlyMessage, ID contextItemId, ID renderingId)
        {
            Log.Error($@"Presentation error: {errorMessage}, Context item ID: {contextItemId}, Rendering ID: {renderingId}", typeof(AlertHtmlHelpers));

            return(Context.PageMode.IsNormal ? new MvcHtmlString(string.Empty) : helper.Partial(Constants.InfoMessageView, InfoMessage.Error(friendlyMessage)));
        }
 public MvcHtmlString ToHtml(HtmlHelper helper)
 {
     return helper.Partial(DashboardClient.ViewPrefix.FormatWith("DashboardView"), Dashboard,
         new ViewDataDictionary { { "currentEntity", Entity } });
 }
 public static MvcHtmlString Upload(this HtmlHelper htmlHelper, UploadFormData data)
 {
     return(htmlHelper.Partial("_FileUpload", data));
 }
Example #32
0
        public static MvcHtmlString RPDropDownFor <TModel, TProperty>(
            this HtmlHelper <TModel> htmlHelper,
            Expression <Func <TModel, TProperty> > expression,
            ICollection <SelectListItem> items,
            string labelMessage       = null,
            string placeholderMessage = null,
            bool hasFind       = true,
            string findMessage = null,
            bool isMultiSelect = true,
            string dataId      = null,
            string dataDepends = null,
            string dataUrl     = null)
        {
            var metadata  = htmlHelper.GetModelMetadata(expression, labelMessage, placeholderMessage, findMessage);
            var viewModel = new DropDownViewModel(metadata)
            {
                Items       = new List <SelectListItem>(),
                Name        = ExpressionHelper.GetExpressionText(expression),
                HasFind     = hasFind,
                DataId      = dataId,
                DataDepends = dataDepends,
                DataUrl     = dataUrl
            };

            if (items != null)
            {
                viewModel.Items = items.ToList();
            }

            viewModel.IsMultiSelect = isMultiSelect;
            viewModel.Input         = htmlHelper.RPHiddenFor(expression);

            if (viewModel.Model != null && viewModel.Items != null && viewModel.Items.Count > 0)
            {
                foreach (var item in viewModel.Items)
                {
                    if (viewModel.IsMultiSelect)
                    {
                        if (((IEnumerable)viewModel.Model).Cast <object>().Any() &&
                            ((IEnumerable)viewModel.Model).Cast <object>().Contains(int.Parse(item.Value)))
                        {
                            viewModel.SelectedValue = string.IsNullOrWhiteSpace(viewModel.SelectedValue) ? item.Text : string.Join("|", viewModel.SelectedValue, item.Text);
                            item.Selected           = true;
                        }
                    }
                    else
                    {
                        object value = viewModel.Model;
                        if (viewModel.ModelMetadata.ModelType.IsEnum)
                        {
                            value = Convert.ChangeType(viewModel.Model, item.Value.GetType());
                        }
                        if (item.Value.Equals(value.ToString()))
                        {
                            viewModel.SelectedValue = item.Text;
                            item.Selected           = true;
                        }
                    }
                }
            }
            return(htmlHelper.Partial(Mvc.View.UI.DropDown, viewModel));
        }
Example #33
0
 /// <summary>
 /// 选择用户的控件
 /// </summary>
 /// <param name="helper"></param>
 /// <param name="formData"></param>
 /// <returns></returns>
 public static MvcHtmlString SelectUser(this HtmlHelper helper, SelectUserFormData formData)
 {
     return(helper.Partial("_SelectDepUser", formData));
 }
Example #34
0
 public static MvcHtmlString PSDataFileUpload(this HtmlHelper htmlHelper, DataFileUploadModel model)
 {
     return(htmlHelper.Partial("~/Controls/DataFileUpload/Views/DataFileUpload.cshtml", model));
 }
Example #35
0
 /// <summary>
 /// 输出结果
 /// </summary>
 public string ToHtmlString()
 {
     return(_helper.Partial("Uploaders/Images", _option).ToHtmlString());
 }
Example #36
0
        public CommentFilteredJsonResult IceUpdate()
        {
            CommentFilteredJsonResult result = new CommentFilteredJsonResult();

            disableClientSideCaching();

            try
            {
                //XDocument contentDoc = null;
                //if (_CMSPageRoutingRequest != null)
                //{
                //	//initialize method already processed the request and had a content document already, use it
                //	CMSPageDocumentDynamicPreviewRequest dynamicPreviewRequest = _CMSPageRoutingRequest.CMSRequest as CMSPageDocumentDynamicPreviewRequest;
                //	contentDoc = dynamicPreviewRequest.ContentDocument;
                //}
                //ice update needs to consider content units scenario, so it will look into presentations folder.
                ContentUnitControllerContext controllerContext = new ContentUnitControllerContext(ControllerContext);

                DocumentPreviewIceFieldMarkupUpdateRequest iceUpdateRequest = _PageFactory.GetIceFieldMarkupUpdater(Request, null) as DocumentPreviewIceFieldMarkupUpdateRequest;

                string fieldViewName = ControllerContext.Controller.GetAvailableView(iceUpdateRequest, controllerContext);

                string contentStr;

                //when not able to locate the template in both editable and normal path, try to use the default fallback templates for text and html
                if (ControllerContext.Controller.ViewExists(fieldViewName, controllerContext))
                {
                    using (StringWriter sw = new StringWriter(CultureInfo.InvariantCulture))
                    {
                        HtmlHelper html = new HtmlHelper(new ViewContext(controllerContext, new WebFormView(ControllerContext, "Shared/Title"), new ViewDataDictionary()
                        {
                        },
                                                                         new TempDataDictionary()
                        {
                        }, sw), new ViewPage());

                        contentStr = Server.HtmlDecode(html.Partial(fieldViewName, iceUpdateRequest).ToHtmlString());
                    }
                }
                else
                {
                    DynamicPreviewICEProcessor iceUpdateProc = new DynamicPreviewICEProcessor(_SitePath);
                    InContextEditUpdateInfo    iceInfo       = iceUpdateProc.IceUpdatePreparation(iceUpdateRequest);

                    if (iceInfo == null)
                    {
                        throw new ArgumentException("Cannot locate either MVC view or Xslt template for element \"" + iceUpdateRequest.FieldName + "\". This field cannot be edited. This is an error of site implementation.");
                    }

                    //use classic transformation engine, even though slower, make sure work with all preview cases
                    LegacyTransformationEngine transformer = new LegacyTransformationEngine(_SitePath, string.Empty, true, _UseTempStylesheetsLocation);

                    //during ice update preparation, updated xslts werer already processed, we don't need to process it again.
                    bool ssUpdated = false;
                    contentStr = transformer.Transform(iceInfo.Field, iceInfo.MainStylesheet.FilePath, iceInfo.MainStylesheet.Doc, ssUpdated);
                }

                //only process pretentation if instructed
                if (iceUpdateRequest.PresentationFragTemplate != null)
                {
                    contentStr = processComponentUnitInstance(iceUpdateRequest, contentStr);
                }
                else if (iceUpdateRequest.PresentationInformation != null)
                {
                    //process templates. this is a tricky scenario. we will need to locate a content unit place holder that has "ElementId" value matching the field unique id
                    //only take that part of the presentation and apply to the expanded string's id
                    contentStr = processContentUnit(iceUpdateRequest, contentStr);
                }

                result.Data = new XHRResponse(
                    new Dictionary <string, object>()
                {
                    { "newMarkup", contentStr },
                    //{"fieldXml", iceUpdateRequest.Content.ToString(SaveOptions.DisableFormatting)}
                    { "fieldXml", iceUpdateRequest.ExpandedXml }
                });
            }
            catch (Exception e)
            {
                result.Data = new XHRResponse(
                    e.Message, XHRResponseType.PROCESSING_ERROR);
            }

            return(result);
        }
Example #37
0
 public static IHtmlString GridFor2(this HtmlHelper html, Type modelType, IEnumerable dataSource, string templateName)
 {
     return(new HtmlString(html.Partial(templateName, GridModel.CreateGridModel(modelType, dataSource, html.ViewContext)).ToString()));
 }
        /// <summary>
        /// Gets the HTML for the Grid model.
        /// </summary>
        /// <param name="property">The property holding the Grid model.</param>
        /// <param name="html">The instance of <code>HtmlHelper</code>.</param>
        /// <param name="framework">The framework used to render the Grid.</param>
        public static HtmlString GetTypedGridHtml(this IPublishedProperty property, HtmlHelper html, string framework = DefaultFramework) {

            // Get the property value
            GridDataModel value = property.Value as GridDataModel;
            if (value == null) return new HtmlString(String.Empty);

            // Load the partial view based on the specified framework
            return html.Partial("TypedGrid/" + framework, property.Value);
        
        }
Example #39
0
 public static MvcHtmlString CreatePreview(this HtmlHelper html, Question question)
 => html.Partial(String.Format("_QuestionPreview"), question);
Example #40
0
 public IHtmlString Transform(HtmlHelper htmlHelper, INode node, string html)
 {
     var propertyVm = node.ToPropertyVm();
     var partialViewName = htmlHelper.BestViewName(propertyVm.Type, "FormFactory/Property.");
     return htmlHelper.Partial(partialViewName, propertyVm);
 }
Example #41
0
 public static MvcHtmlString Separator(this HtmlHelper html)
 {
     return(html.Partial("_Separator"));
 }
 public MvcHtmlString Render(HtmlHelper helper, object Model)
 {
     return helper.Partial("NavigationBar", Model);
 }
Example #43
0
            public MvcHtmlString Build()
            {
                var currentViewModel = BuildViewModel();

                return(_helper.Partial(@"~/Views/Shared/_DataTableViewModel.cshtml", currentViewModel));
            }
 public MvcHtmlString Render(HtmlHelper helper, string Name, object Model)
 {
     return helper.Partial(Name, Model);
 }
 public MvcHtmlString Render(HtmlHelper helper)
 {
     return helper.Partial("NavigationBar");
 }
 public string Render(HtmlHelper html)
 {
     //UmbracoHelper helper = new UmbracoHelper(UmbracoContext.Current);
     return html.Partial(Macro.ScriptName, null).ToHtmlString();//UmbracoContext.Current.PublishedContentRequest.PublishedContent)).ToHtmlString();
 }
Example #47
0
 /// <summary>
 /// Includes google analytics.
 /// </summary>
 /// <param name="helper"></param>
 /// <param name="analyticsKey"></param>
 /// <returns></returns>
 public static HtmlString IncludeGoogleAnalytics(this HtmlHelper helper)
 {
     return(helper.Partial("_GoogleAnalytics"));
 }
 public MvcHtmlString Render(HtmlHelper helper, string Name)
 {
     return helper.Partial(Name);
 }
        /// <summary>
        /// Gets the HTML for the Grid model.
        /// </summary>
        /// <param name="content">The parent content item.</param>
        /// <param name="html">The instance of <code>HtmlHelper</code>.</param>
        /// <param name="propertyAlias">The alias of the property.</param>
        /// <param name="framework">The framework used to render the Grid.</param>
        public static HtmlString GetTypedGridHtml(this IPublishedContent content, HtmlHelper html, string propertyAlias, string framework) {
            
            // Get the property with the specifeid alias
            IPublishedProperty property = content.GetProperty(propertyAlias);
            if (property == null) throw new NullReferenceException("No property type found with alias " + propertyAlias);

            // Get the property value
            GridDataModel value = property.Value as GridDataModel;
            if (value == null) return new HtmlString(String.Empty);

            // Load the partial view based on the specified framework
            return html.Partial("TypedGrid/" + framework, property.Value);
        
        }
Example #50
0
 /// <summary>
 /// An HTML Helper that renders Google GA Tracking information
 /// </summary>
 /// <param name="helper"></param>
 /// <returns>MvcHtmlString</returns>
 public static HtmlString IncludeGaEventTracking(this HtmlHelper helper)
 {
     return(helper.Partial("_GAEventTracking"));
 }
Example #51
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="helper"></param>
 /// <param name="customButton"></param>
 /// <returns></returns>
 public static MvcHtmlString ButtonCustom(this HtmlHelper helper, Button[] customButton)
 {
     return(helper.Partial(""));
 }
Example #52
0
        public static MvcHtmlString PageEditorError(this HtmlHelper helper, string errorMessage)
        {
            Log.Error($@"Presentation error on '{helper.Sitecore()?.CurrentRendering?.RenderingItemPath}': {errorMessage}", typeof(AlertHtmlHelpers));

            return(Context.PageMode.IsNormal ? new MvcHtmlString(string.Empty) : helper.Partial(Constants.InfoMessageView, InfoMessage.Error(errorMessage)));
        }
        private IHtmlString Render(ShapeDescriptor shapeDescriptor, DisplayContext displayContext, HarvestShapeInfo harvestShapeInfo, HarvestShapeHit harvestShapeHit) {
            Logger.Information("Rendering template file '{0}'", harvestShapeInfo.TemplateVirtualPath);

            var htmlHelper = new HtmlHelper(displayContext.ViewContext, displayContext.ViewDataContainer);
            var result = htmlHelper.Partial(harvestShapeInfo.TemplateVirtualPath, displayContext.Value);

            Logger.Information("Done rendering template file '{0}'", harvestShapeInfo.TemplateVirtualPath);
            return result;
        }
        private static MvcHtmlString Create(ICollection<dynamic> messages, HtmlHelper helper, string templateName)
        {
            var templateFunc = new Func<FlashContext, MvcHtmlString>(ctx => helper.Partial(templateName, ctx, helper.ViewData));
            var htmlBuilder = new StringBuilder(string.Empty);

            var count = 0;
            var total = messages.Count;

            foreach (var message in messages)
            {
                var current = templateFunc.Invoke(new FlashContext { Message = message, Index = count++, Total = total });
                htmlBuilder.AppendLine(current.ToHtmlString());
            }

            return MvcHtmlString.Create(htmlBuilder.ToString());
        }