public ActionResult Browse() { WorkContext.Breadcrumbs.Add(T("Media"), Url.Action("Index", new { area = Constants.Areas.Media })); WorkContext.Breadcrumbs.Add(T("Browse")); var sb = new StringBuilder(); sb.Append("<div class=\"box\">"); sb.Append("<div class=\"box-header\"><i class=\"cx-icon cx-icon-close\" onclick=\"window.parent.fancyboxResult = null; parent.jQuery.fancybox.close();\"></i><h2 style=\"cursor:pointer\">File Browse</h2></div>"); sb.Append("<div class=\"box-content nopadding\" style=\"border-bottom: none;\">"); sb.Append("<div id=\"fileContainer\" style=\"height: 190px; padding-left: 5px;\"></div>"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<script type=\"text/javascript\">"); sb.Append("$(document).ready( function() {"); sb.AppendFormat("$('#fileContainer').fileTree({{ root: '/', script: '{0}', multiFolder: false }}, function(file){{ window.parent.fancyboxResult = file; parent.jQuery.fancybox.close(); }});", Url.Action("FileTreeConnector", "Media", new { area = Constants.Areas.Media })); sb.Append("});"); sb.Append("</script>"); var result = new ControlContentResult(sb.ToString()) { AdditionResources = () => new[] { ResourceType.JQueryFileTree } }; return(result); }
public ActionResult Search(PagerParameters pagerParameters, string q = "") { q = q.Trim(); if (string.IsNullOrEmpty(q)) { return(Redirect(Request.UrlReferrer != null ? Request.UrlReferrer.ToString() : Url.Content("~/"))); } PagedList <ISearchHit> searchHits; try { searchHits = searchService.Query(q, 0, 20, searchSettings.SearchedFields, WorkContext.CurrentCulture, searchHit => searchHit); } catch (Exception exception) { Logger.Error(T("Invalid search query: {0}", exception.Message).Text); notifier.Error(T("Invalid search query: {0}", exception.Message)); searchHits = new PagedList <ISearchHit>(new ISearchHit[] { }); } var sb = new StringBuilder(); if (searchHits.ItemCount == 0) { notifier.Information(T("Your search - {0} - did not match any documents.", new HtmlString("<strong>" + q + "</strong>"))); } else { notifier.Information(T("Your search - {0} - resulted in {1} documents.", new HtmlString("<strong>" + q + "</strong>"), searchHits.ItemCount)); sb.Append("<ul class=\"thumbnails search-results\">"); foreach (var searchHit in searchHits) { sb.Append("<li>"); sb.AppendFormat("<a href=\"{1}\">{0}</a>", searchHit.GetString("title"), searchHit.GetString("url")); sb.AppendFormat("<div class=\"description\">{0}</div>", searchHit.GetString("description") ?? searchHit.GetString("body")); sb.Append("</li>"); } sb.Append("</ul>"); } var result = new ControlContentResult(sb.ToString()) { Title = T("Search") }; return(result); }
public ActionResult Index() { if (!CheckPermission(MediaPermissions.ManageMedia)) { return(new HttpUnauthorizedResult()); } WorkContext.Breadcrumbs.Add(T("Media")); ViewBag.Title = T("Manage Media"); var sb = new StringBuilder(); sb.Append("<article>"); sb.Append("<div class='jarviswidget' data-widget-editbutton='false' data-widget-deletebutton='false'>"); sb.Append("<header>"); sb.Append("<span class='widget-icon'>"); sb.Append("<i class='fa fa-lg fa-fw fa-picture-o'></i>"); sb.Append("</span>"); sb.Append("<h2>Gallery</h2>"); sb.Append("</header>"); sb.Append("<div>"); sb.Append("<div class=\"widget-body\">"); sb.Append("<div id=\"elfinder\"></div>"); sb.Append("<div>"); sb.Append("<div>"); sb.Append("<div>"); sb.Append("</article>"); sb.AppendFormat(@"<script type=""text/javascript""> $(document).ready(function() {{ var myCommands = elFinder.prototype._options.commands; var disabled = ['extract', 'archive', 'resize', 'help', 'select']; $.each(disabled, function (i, cmd) {{ var idx; (idx = $.inArray(cmd, myCommands)) !== -1 && myCommands.splice(idx, 1); }}); var options = {{ url: '{0}', requestType: 'post', commands: myCommands, lang: 'en', ui: ['toolbar'], rememberLastDir: false, height: 500, resizable: false, defaultView: 'list', uiOptions: {{ toolbar: [ ['home', 'up'], ['mkdir', 'upload'], ['info'], ['quicklook'], ['cut', 'paste'], ['rm'], ['view', 'sort'] ], tree: {{ openRootOnLoad: false, }}, cwd: {{ oldSchool: true }} }}, contextmenu: {{ navbar: ['open', '|', 'cut', 'paste', '|', 'rm', '|', 'info'], cwd: ['reload', 'back', '|', 'upload', 'paste', '|', 'info'], files: [ 'getfile', '|', 'open', 'quicklook', '|', 'download', '|', 'cut', 'paste', '|', 'rm', '|', 'edit', 'rename', 'resize', '|', 'archive', 'extract', '|', 'info' ] }}, handlers: {{ upload: function (event, instance) {{ var uploadedFiles = event.data.added; var archives = ['application/x-gzip', 'application/x-tar', 'application/x-bzip2']; for (i in uploadedFiles) {{ var file = uploadedFiles[i]; if (jQuery.inArray(file.mime, archives) >= 0) {{ instance.exec('extract', file.hash); }} }} }}, }}, dialog: {{ width: 900, modal: true, title: ""Files"" }}, // open in dialog window commandsOptions: {{ getfile: {{ onlyURL: true, multiple: false, folders: false, oncomplete: '' }}, }} }}; $('#elfinder').elfinder(options).elfinder('instance'); }}); </script>", @Url.Action("Connector", "Media", RouteData.Values)); var result = new ControlContentResult(sb.ToString()) { AdditionResources = () => new[] { ResourceType.JQueryUI, ResourceType.ElFinder } }; return(result); }
public ActionResult Index() { if (!CheckPermission(StandardPermissions.FullAccess, T("Not allowed to manage the search index."))) { return(new HttpUnauthorizedResult()); } WorkContext.Breadcrumbs.Add(T("Indexing")); IndexEntry indexEntry; try { indexEntry = indexingService.GetIndexEntry(DefaultIndexName); if (indexEntry == null) { notifier.Information(T("There is no search index to manage for this site.")); } } catch (Exception e) { indexEntry = null; Logger.ErrorFormat(e, "Search index couldn't be read."); notifier.Information(T("The index might be corrupted. If you can't recover click on Rebuild.")); } if (indexEntry == null) { notifier.Information(T("There is currently no search index.")); } else if (indexEntry.LastUpdateUtc == DateTime.MinValue) { notifier.Information(T("The search index has not been built yet.")); } else { if (indexEntry.DocumentCount == 0) { notifier.Information(T("The search index does not contain any document.")); } else { notifier.Information(T("The search index contains {0} document(s).", indexEntry.DocumentCount)); } if (indexEntry.Fields.Any()) { notifier.Information(T("The search index contains the following fields: {0}.", string.Join(", ", indexEntry.Fields))); } else { notifier.Information(T("The search index does not contain any field.")); } notifier.Information(T("The search index was last updated {0}.", indexEntry.LastUpdateUtc)); switch (indexEntry.IndexingStatus) { case IndexingStatus.Rebuilding: notifier.Information(T("The indexing process is currently being rebuilt.")); break; case IndexingStatus.Updating: notifier.Information(T("The indexing process is currently being updated.")); break; } } var sb = new StringBuilder(); if (indexEntry != null) { sb.AppendFormat("<form method=\"post\" action=\"{0}\">", Url.Action("Rebuild")); sb.AppendFormat("<div class=\"form-group\"><label>{0}</label><br />", T("Rebuild the search index for a fresh start:")); sb.AppendFormat("<button class=\"btn btn-primary\" type=\"submit\"><i class=\"cx-icon cx-icon-refresh\"></i> {0}</button></div>", T("Rebuild")); sb.Append("</form>"); } var result = new ControlContentResult(sb.ToString()) { Title = T("Search Index") }; return(result); }
public ActionResult Sublayers(Guid slideId) { var slide = Service.GetById(slideId); var sb = new StringBuilder(); var textWriter = new StringWriter(sb); var writer = new HtmlTextWriter(textWriter); writer.AddAttribute("method", "post"); writer.AddAttribute("action", Url.Action("SaveSublayers")); writer.RenderBeginTag(HtmlTextWriterTag.Form); writer.AddAttribute(HtmlTextWriterAttribute.Name, "SlideId"); writer.AddAttribute(HtmlTextWriterAttribute.Value, slideId.ToString()); writer.AddAttribute(HtmlTextWriterAttribute.Type, "hidden"); writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag();// input writer.AddAttribute(HtmlTextWriterAttribute.Id, "hdfSublayers"); writer.AddAttribute(HtmlTextWriterAttribute.Name, "Sublayers"); writer.AddAttribute(HtmlTextWriterAttribute.Type, "hidden"); writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag();// input writer.AddAttribute(HtmlTextWriterAttribute.Class, "btn-toolbar"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.AddAttribute(HtmlTextWriterAttribute.Class, "btn-group"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.AddAttribute(HtmlTextWriterAttribute.Class, "btn btn-primary"); writer.AddAttribute(HtmlTextWriterAttribute.Name, "Save"); writer.AddAttribute(HtmlTextWriterAttribute.Type, "submit"); writer.AddAttribute(HtmlTextWriterAttribute.Onclick, "var html = ''; $('#sublayers-container .ls-s').each(function(){ html+=this.outerHTML; }); $('#hdfSublayers').val(html);"); writer.RenderBeginTag(HtmlTextWriterTag.Button); writer.Write("Save"); writer.RenderEndTag(); // button writer.RenderEndTag(); writer.AddAttribute(HtmlTextWriterAttribute.Class, "btn-group"); writer.RenderBeginTag(HtmlTextWriterTag.Div); CreateButton(writer, "img"); CreateButton(writer, "div"); CreateButton(writer, "p"); CreateButton(writer, "span"); CreateButton(writer, "h1"); CreateButton(writer, "h2"); CreateButton(writer, "h3"); CreateButton(writer, "h4"); CreateButton(writer, "h5"); CreateButton(writer, "h6"); writer.RenderEndTag(); // div writer.RenderEndTag(); // div writer.AddAttribute(HtmlTextWriterAttribute.Id, "sublayers-container"); writer.AddStyleAttribute(HtmlTextWriterStyle.Overflow, "auto"); writer.AddStyleAttribute(HtmlTextWriterStyle.Height, "400px"); writer.AddStyleAttribute(HtmlTextWriterStyle.Position, "relative"); writer.AddStyleAttribute(HtmlTextWriterStyle.MarginTop, "10px"); writer.RenderBeginTag(HtmlTextWriterTag.Div); if (!string.IsNullOrEmpty(slide.BackgroundUrl)) { writer.AddAttribute(HtmlTextWriterAttribute.Src, Url.Content(slide.BackgroundUrl)); writer.AddAttribute(HtmlTextWriterAttribute.Class, "ls-bg"); writer.AddStyleAttribute(HtmlTextWriterStyle.Position, "absolute"); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); } writer.Write(slide.Sublayers); writer.RenderEndTag(); writer.RenderEndTag(); // form writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript"); writer.RenderBeginTag(HtmlTextWriterTag.Script); writer.Write("$(document).ready(function(){"); if (!string.IsNullOrEmpty(slide.BackgroundUrl)) { writer.Write("var image = new Image(); image.onload = function(){{ var img = $('#sublayers-container .ls-bg'); img.css('width', image.naturalWidth + 'px'); img.css('max-width', image.naturalWidth + 'px'); img.css('height', image.naturalHeight + 'px'); }}; image.src = '{0}';", slide.BackgroundUrl); } if (!string.IsNullOrEmpty(slide.Sublayers)) { writer.Write("$('#sublayers-container .ls-s').draggable({cursor:'pointer'});"); } writer.Write("$('#sublayers-container').on('dblclick', '.ls-s', function(){{ $.fancybox.open({{ href: '{0}?tag=' + this.tagName.toLowerCase() + '&id=' + this.id, type: 'iframe', modal: true, padding: 0, width: 600 }}); }});", Url.Action("AddOrEditSublayer")); writer.Write("});"); writer.RenderEndTag(); WorkContext.Breadcrumbs.Add(T("Sliders"), Url.Action("Index", "Slider")); WorkContext.Breadcrumbs.Add(T("Slides"), Url.Action("Index", "Slide", new { sliderId = slide.SliderId })); var result = new ControlContentResult(sb.ToString()) { Title = T("Slide Sublayers"), AdditionResources = () => new[] { ResourceType.JQueryUI } }; return(result); }