diff --git a/src/Orchard.Specs/Hosting/Orchard.Web/Web.config b/src/Orchard.Specs/Hosting/Orchard.Web/Web.config index 789634633..a002e025e 100644 --- a/src/Orchard.Specs/Hosting/Orchard.Web/Web.config +++ b/src/Orchard.Specs/Hosting/Orchard.Web/Web.config @@ -86,7 +86,7 @@ it enables developers to configure html error pages to be displayed in place of a error stack trace. --> - + diff --git a/src/Orchard.Web/Modules/Orchard.Localization/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Localization/Controllers/AdminController.cs index d62b3f2df..06cbe4f94 100644 --- a/src/Orchard.Web/Modules/Orchard.Localization/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Localization/Controllers/AdminController.cs @@ -119,7 +119,10 @@ namespace Orchard.Localization.Controllers { if (!ModelState.IsValid) { Services.TransactionManager.Cancel(); model.SiteCultures = _cultureManager.ListCultures().Where(s => s != _localizationService.GetContentCulture(contentItem) && s != _cultureManager.GetSiteCulture()); - contentItem.As().Culture.Culture = null; + var culture = contentItem.As().Culture; + if (culture != null) { + culture.Culture = null; + } model.Content = _contentManager.BuildEditor(contentItem); return View(model); } diff --git a/src/Orchard.Web/Modules/Orchard.Modules/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Modules/Controllers/AdminController.cs index 812c5cecf..fa8031bff 100644 --- a/src/Orchard.Web/Modules/Orchard.Modules/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Modules/Controllers/AdminController.cs @@ -50,8 +50,9 @@ namespace Orchard.Modules.Controllers { var modules = _extensionManager.AvailableExtensions().Where(x => DefaultExtensionTypes.IsModule(x.ExtensionType)); return View(new ModulesIndexViewModel { - Modules = modules, - InstallModules = _featureManager.GetEnabledFeatures().FirstOrDefault(f => f.Id == "Gallery") != null }); + Modules = modules, + InstallModules = _featureManager.GetEnabledFeatures().FirstOrDefault(f => f.Id == "PackagingServices") != null + }); } public ActionResult Features() { diff --git a/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Index.cshtml b/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Index.cshtml index 54645d17f..fbfe4d9d9 100644 --- a/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Index.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Index.cshtml @@ -10,7 +10,7 @@

@Html.TitleForPage(T("Installed Modules").ToString())

@if (Model.InstallModules) { -
@Html.ActionLink(T("Install a module").ToString(), "AddModule", "Gallery", new { area = "Orchard.Packaging", returnUrl = HttpContext.Current.Request.RawUrl }, new { @class = "button primaryAction" })
+
@Html.ActionLink(T("Install a module").ToString(), "AddModule", "PackagingServices", new { area = "Orchard.Packaging", returnUrl = HttpContext.Current.Request.RawUrl }, new { @class = "button primaryAction" })
} @if (Model.Modules.Count() > 0) { diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Controllers/GalleryController.cs b/src/Orchard.Web/Modules/Orchard.Packaging/Controllers/GalleryController.cs index 1e4607f00..57654a990 100644 --- a/src/Orchard.Web/Modules/Orchard.Packaging/Controllers/GalleryController.cs +++ b/src/Orchard.Web/Modules/Orchard.Packaging/Controllers/GalleryController.cs @@ -1,15 +1,12 @@ using System; -using System.IO; +using System.Collections.Generic; using System.Linq; -using System.Web; using System.Web.Hosting; using System.Web.Mvc; using System.Xml.Linq; -using NuGet; -using Orchard.Environment; using Orchard.Environment.Extensions; -using Orchard.FileSystems.AppData; using Orchard.Localization; +using Orchard.Logging; using Orchard.Packaging.Services; using Orchard.Packaging.ViewModels; using Orchard.Themes; @@ -24,26 +21,22 @@ namespace Orchard.Packaging.Controllers { private readonly IPackageManager _packageManager; private readonly IPackagingSourceManager _packagingSourceManager; - private readonly IAppDataFolderRoot _appDataFolderRoot; private readonly INotifier _notifier; - private readonly IHostEnvironment _hostEnvironment; public GalleryController( IPackageManager packageManager, IPackagingSourceManager packagingSourceManager, - INotifier notifier, - IAppDataFolderRoot appDataFolderRoot, - IHostEnvironment hostEnvironment) { + INotifier notifier) { _packageManager = packageManager; _packagingSourceManager = packagingSourceManager; _notifier = notifier; - _appDataFolderRoot = appDataFolderRoot; - _hostEnvironment = hostEnvironment; T = NullLocalizer.Instance; + Logger = NullLogger.Instance; } public Localizer T { get; set; } + public ILogger Logger { get; set; } public ActionResult Sources() { return View(new PackagingSourcesViewModel { @@ -110,8 +103,20 @@ namespace Orchard.Packaging.Controllers { : _packagingSourceManager.GetSources() ; + IEnumerable extensions = null; + foreach (var source in sources) { + try { + var sourceExtensions = _packagingSourceManager.GetModuleList(source).ToArray(); + extensions = extensions == null ? sourceExtensions : extensions.Concat(sourceExtensions); + } + catch (Exception ex) { + Logger.Error(ex, "Error loading extensions from gallery source '{0}'. {1}.", source.FeedTitle, ex.Message); + _notifier.Error(T("Error loading extensions from gallery source '{0}'. {1}.", source.FeedTitle, ex.Message)); + } + } + return View("Modules", new PackagingExtensionsViewModel { - Extensions = sources.SelectMany(source => _packagingSourceManager.GetModuleList(source)), + Extensions = extensions ?? new PackagingEntry[] {}, Sources = _packagingSourceManager.GetSources().OrderBy(s => s.FeedTitle), SelectedSource = selectedSource }); @@ -143,75 +148,5 @@ namespace Orchard.Packaging.Controllers { return RedirectToAction(redirectTo == "Themes" ? "Themes" : "Modules"); } - - public ActionResult AddTheme(string returnUrl) { - return View(); - } - - [HttpPost, ActionName("AddTheme")] - public ActionResult AddThemePOST(string returnUrl) { - return InstallPackage(returnUrl, Request.RawUrl); - } - - [HttpPost, ActionName("RemoveTheme")] - public ActionResult RemoveThemePOST(string themeId, string returnUrl, string retryUrl) { - return UninstallPackage(PackagingSourceManager.ThemesFilter + themeId, returnUrl, retryUrl); - } - - public ActionResult AddModule(string returnUrl) { - return View(); - } - - [HttpPost, ActionName("AddModule")] - public ActionResult AddModulePOST(string returnUrl) { - return InstallPackage(returnUrl, Request.RawUrl); - } - - public ActionResult InstallPackage(string returnUrl, string retryUrl) { - try { - if (Request.Files != null && - Request.Files.Count > 0 && - !string.IsNullOrWhiteSpace(Request.Files[0].FileName)) { - ModelState.AddModelError("File", T("Select a file to upload.").ToString()); - } - - foreach (string fileName in Request.Files) { - HttpPostedFileBase file = Request.Files[fileName]; - if (file != null) { - string fullFileName = Path.Combine(_appDataFolderRoot.RootFolder, fileName + ".nupkg").Replace(Path.DirectorySeparatorChar, '/'); - file.SaveAs(fullFileName); - PackageInfo info = _packageManager.Install(new ZipPackage(fullFileName), _appDataFolderRoot.RootFolder, HostingEnvironment.MapPath("~/")); - System.IO.File.Delete(fullFileName); - - _notifier.Information(T("Installed package \"{0}\", version {1} of type \"{2}\" at location \"{3}\"", - info.ExtensionName, info.ExtensionVersion, info.ExtensionType, info.ExtensionPath)); - } - } - - return Redirect(returnUrl); - } catch (Exception exception) { - for (Exception scan = exception; scan != null; scan = scan.InnerException) { - _notifier.Error(T("Uploading module package failed: {0}", exception.Message)); - } - - return Redirect(retryUrl); - } - } - - public ActionResult UninstallPackage(string id, string returnUrl, string retryUrl) { - try { - _packageManager.Uninstall(id, HostingEnvironment.MapPath("~/")); - - _notifier.Information(T("Uninstalled package \"{0}\"", id)); - - return Redirect(returnUrl); - } catch (Exception exception) { - for (Exception scan = exception; scan != null; scan = scan.InnerException) { - _notifier.Error(T("Uninstall failed: {0}", exception.Message)); - } - - return Redirect(retryUrl); - } - } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Controllers/PackagingServicesController.cs b/src/Orchard.Web/Modules/Orchard.Packaging/Controllers/PackagingServicesController.cs new file mode 100644 index 000000000..b38a3a331 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Packaging/Controllers/PackagingServicesController.cs @@ -0,0 +1,108 @@ +using System; +using System.IO; +using System.Web; +using System.Web.Hosting; +using System.Web.Mvc; +using NuGet; +using Orchard.Environment.Extensions; +using Orchard.FileSystems.AppData; +using Orchard.Localization; +using Orchard.Packaging.Services; +using Orchard.Themes; +using Orchard.UI.Admin; +using Orchard.UI.Notify; +using IPackageManager = Orchard.Packaging.Services.IPackageManager; + +namespace Orchard.Packaging.Controllers { + [OrchardFeature("PackagingServices")] + [Themed, Admin] + public class PackagingServicesController : Controller { + + private readonly IPackageManager _packageManager; + private readonly IAppDataFolderRoot _appDataFolderRoot; + private readonly INotifier _notifier; + + public PackagingServicesController( + IPackageManager packageManager, + INotifier notifier, + IAppDataFolderRoot appDataFolderRoot) { + _packageManager = packageManager; + _notifier = notifier; + _appDataFolderRoot = appDataFolderRoot; + + T = NullLocalizer.Instance; + } + + public Localizer T { get; set; } + + public ActionResult AddTheme(string returnUrl) { + return View(); + } + + [HttpPost, ActionName("AddTheme")] + public ActionResult AddThemePOST(string returnUrl) { + return InstallPackage(returnUrl, Request.RawUrl); + } + + [HttpPost, ActionName("RemoveTheme")] + public ActionResult RemoveThemePOST(string themeId, string returnUrl, string retryUrl) { + return UninstallPackage(PackagingSourceManager.ThemesFilter + themeId, returnUrl, retryUrl); + } + + public ActionResult AddModule(string returnUrl) { + return View(); + } + + [HttpPost, ActionName("AddModule")] + public ActionResult AddModulePOST(string returnUrl) { + return InstallPackage(returnUrl, Request.RawUrl); + } + + public ActionResult InstallPackage(string returnUrl, string retryUrl) { + try { + if (Request.Files != null && + Request.Files.Count > 0 && + !string.IsNullOrWhiteSpace(Request.Files[0].FileName)) { + ModelState.AddModelError("File", T("Select a file to upload.").ToString()); + } + + foreach (string fileName in Request.Files) { + HttpPostedFileBase file = Request.Files[fileName]; + if (file != null) { + string fullFileName = Path.Combine(_appDataFolderRoot.RootFolder, fileName + ".nupkg").Replace(Path.DirectorySeparatorChar, '/'); + file.SaveAs(fullFileName); + PackageInfo info = _packageManager.Install(new ZipPackage(fullFileName), _appDataFolderRoot.RootFolder, HostingEnvironment.MapPath("~/")); + System.IO.File.Delete(fullFileName); + + _notifier.Information(T("Installed package \"{0}\", version {1} of type \"{2}\" at location \"{3}\"", + info.ExtensionName, info.ExtensionVersion, info.ExtensionType, info.ExtensionPath)); + } + } + + return Redirect(returnUrl); + } catch (Exception exception) { + for (Exception scan = exception; scan != null; scan = scan.InnerException) { + _notifier.Error(T("Uploading module package failed: {0}", exception.Message)); + } + + return Redirect(retryUrl); + } + } + + public ActionResult UninstallPackage(string id, string returnUrl, string retryUrl) { + try { + _packageManager.Uninstall(id, HostingEnvironment.MapPath("~/")); + + _notifier.Information(T("Uninstalled package \"{0}\"", id)); + + return Redirect(returnUrl); + } catch (Exception exception) { + for (Exception scan = exception; scan != null; scan = scan.InnerException) { + _notifier.Error(T("Uninstall failed: {0}", exception.Message)); + } + + return Redirect(retryUrl); + } + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Orchard.Packaging.csproj b/src/Orchard.Web/Modules/Orchard.Packaging/Orchard.Packaging.csproj index 33679069e..dcb802462 100644 --- a/src/Orchard.Web/Modules/Orchard.Packaging/Orchard.Packaging.csproj +++ b/src/Orchard.Web/Modules/Orchard.Packaging/Orchard.Packaging.csproj @@ -59,6 +59,7 @@ + @@ -94,7 +95,7 @@ - + @@ -121,7 +122,7 @@ - + diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Views/Gallery/AddModule.cshtml b/src/Orchard.Web/Modules/Orchard.Packaging/Views/PackagingServices/AddModule.cshtml similarity index 73% rename from src/Orchard.Web/Modules/Orchard.Packaging/Views/Gallery/AddModule.cshtml rename to src/Orchard.Web/Modules/Orchard.Packaging/Views/PackagingServices/AddModule.cshtml index 70087bb14..094b3c35a 100644 --- a/src/Orchard.Web/Modules/Orchard.Packaging/Views/Gallery/AddModule.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Packaging/Views/PackagingServices/AddModule.cshtml @@ -1,6 +1,6 @@ @{

@Html.TitleForPage(T("Install a Module").ToString())

- using (Html.BeginFormAntiForgeryPost(Url.Action("AddModule", new { area = "Orchard.Gallery" }), FormMethod.Post, new { enctype = "multipart/form-data" })) { + using (Html.BeginFormAntiForgeryPost(Url.Action("AddModule", new { area = "Orchard.Packaging", returnUrl = HttpContext.Current.Request["returnUrl"] }), FormMethod.Post, new { enctype = "multipart/form-data" })) { Html.ValidationSummary();
diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Views/Gallery/AddTheme.cshtml b/src/Orchard.Web/Modules/Orchard.Packaging/Views/PackagingServices/AddTheme.cshtml similarity index 73% rename from src/Orchard.Web/Modules/Orchard.Packaging/Views/Gallery/AddTheme.cshtml rename to src/Orchard.Web/Modules/Orchard.Packaging/Views/PackagingServices/AddTheme.cshtml index 01bff8201..acdc44e37 100644 --- a/src/Orchard.Web/Modules/Orchard.Packaging/Views/Gallery/AddTheme.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Packaging/Views/PackagingServices/AddTheme.cshtml @@ -1,6 +1,6 @@ @{

@Html.TitleForPage(T("Install a Theme").ToString())

- using (Html.BeginFormAntiForgeryPost(Url.Action("AddTheme", new { area = "Orchard.Gallery" }), FormMethod.Post, new { enctype = "multipart/form-data" })) { + using (Html.BeginFormAntiForgeryPost(Url.Action("AddTheme", new { area = "Orchard.Packaging", returnUrl = HttpContext.Current.Request["returnUrl"] }), FormMethod.Post, new { enctype = "multipart/form-data" })) { Html.ValidationSummary();
diff --git a/src/Orchard.Web/Modules/Orchard.Themes/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Themes/Controllers/AdminController.cs index 8cfa24d2f..b5834ddd6 100644 --- a/src/Orchard.Web/Modules/Orchard.Themes/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Themes/Controllers/AdminController.cs @@ -69,7 +69,8 @@ namespace Orchard.Themes.Controllers { return View(new ThemesIndexViewModel { CurrentTheme = currentTheme, Themes = themes, - InstallThemes = _featureManager.GetEnabledFeatures().FirstOrDefault(f => f.Id == "Gallery") != null }); + InstallThemes = _featureManager.GetEnabledFeatures().FirstOrDefault(f => f.Id == "PackagingServices") != null + }); } catch (Exception exception) { Services.Notifier.Error(T("Listing themes failed: " + exception.Message)); diff --git a/src/Orchard.Web/Modules/Orchard.Themes/Views/Admin/Index.cshtml b/src/Orchard.Web/Modules/Orchard.Themes/Views/Admin/Index.cshtml index e84d5c3e9..13b199089 100644 --- a/src/Orchard.Web/Modules/Orchard.Themes/Views/Admin/Index.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Themes/Views/Admin/Index.cshtml @@ -19,7 +19,7 @@

if (Model.InstallThemes) { - @Html.ActionLink(T("Install a new Theme").ToString(), "AddTheme", "Gallery", new { area = "Orchard.Packaging", returnUrl = HttpContext.Current.Request.RawUrl }, new { @class = "button primaryAction" }) + @Html.ActionLink(T("Install a new Theme").ToString(), "AddTheme", "PackagingServices", new { area = "Orchard.Packaging", returnUrl = HttpContext.Current.Request.RawUrl }, new { @class = "button primaryAction" }) } } @@ -57,7 +57,7 @@ } @if (Model.InstallThemes) { - using (Html.BeginFormAntiForgeryPost(Url.Action("RemoveTheme", "Gallery", new { area = "Orchard.Packaging", returnUrl = HttpContext.Current.Request.RawUrl, retryUrl = HttpContext.Current.Request.RawUrl, themeId = theme.Id }), FormMethod.Post, new { @class = "inline link" })) { + using (Html.BeginFormAntiForgeryPost(Url.Action("RemoveTheme", "PackagingServices", new { area = "Orchard.Packaging", returnUrl = HttpContext.Current.Request.RawUrl, retryUrl = HttpContext.Current.Request.RawUrl, themeId = theme.Id }), FormMethod.Post, new { @class = "inline link" })) { } } diff --git a/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/autoresize/editor_plugin.js b/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/autoresize/editor_plugin.js index 1676b154a..08bd75ffe 100644 --- a/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/autoresize/editor_plugin.js +++ b/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/autoresize/editor_plugin.js @@ -1 +1 @@ -(function(){tinymce.create("tinymce.plugins.AutoResizePlugin",{init:function(a,c){var d=this;if(a.getParam("fullscreen_is_enabled")){return}function b(){var h=a.getDoc(),e=h.body,j=h.documentElement,g=tinymce.DOM,i=d.autoresize_min_height,f;f=tinymce.isIE?e.scrollHeight:j.offsetHeight;if(f>d.autoresize_min_height){i=f}g.setStyle(g.get(a.id+"_ifr"),"height",i+"px");if(d.throbbing){a.setProgressState(false);a.setProgressState(true)}}d.editor=a;d.autoresize_min_height=a.getElement().offsetHeight;a.onChange.add(b);a.onSetContent.add(b);a.onPaste.add(b);a.onKeyUp.add(b);a.onPostRender.add(b);if(a.getParam("autoresize_on_init",true)){a.onInit.add(function(f,e){f.setProgressState(true);d.throbbing=true;f.getBody().style.overflowY="hidden"});a.onLoadContent.add(function(f,e){b();setTimeout(function(){b();f.setProgressState(false);d.throbbing=false},1250)})}a.addCommand("mceAutoResize",b)},getInfo:function(){return{longname:"Auto Resize",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autoresize",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("autoresize",tinymce.plugins.AutoResizePlugin)})(); \ No newline at end of file +(function(){tinymce.create("tinymce.plugins.AutoResizePlugin",{init:function(a){var b=true,d=this;if(a.getParam("fullscreen_is_enabled"))return;function c(){var i=a.getDoc(),h=i.body,g=i.documentElement,f=tinymce.DOM,e=d.autoresize_min_height,c;if((tinymce.isIE?h.scrollWidth:g.offsetWidth)==0)return;c=tinymce.isIE?h.scrollHeight:g.offsetHeight;if(c>d.autoresize_min_height)e=c;f.setStyle(f.get(a.id+"_ifr"),"height",e+"px");if(d.throbbing){a.setProgressState(false);a.setProgressState(b)}}d.editor=a;d.autoresize_min_height=a.getElement().offsetHeight;a.onChange.add(c);a.onSetContent.add(c);a.onPaste.add(c);a.onKeyUp.add(c);a.onPostRender.add(c);if(a.getParam("autoresize_on_init",b)){a.onInit.add(function(a){a.setProgressState(b);d.throbbing=b;a.getBody().style.overflowY="hidden"});a.onLoadContent.add(function(a){c();setTimeout(function(){c();a.setProgressState(false);d.throbbing=false},1250)})}a.addCommand("mceAutoResize",c)},getInfo:function(){return{longname:"Auto Resize",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autoresize",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("autoresize",tinymce.plugins.AutoResizePlugin)})() \ No newline at end of file diff --git a/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/autoresize/editor_plugin_src.js b/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/autoresize/editor_plugin_src.js index c260b7a24..abe5835ba 100644 --- a/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/autoresize/editor_plugin_src.js +++ b/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/autoresize/editor_plugin_src.js @@ -8,112 +8,117 @@ * Contributing: http://tinymce.moxiecode.com/contributing */ -(function() { - /** - * Auto Resize - * - * This plugin automatically resizes the content area to fit its content height. - * It will retain a minimum height, which is the height of the content area when - * it's initialized. - */ - tinymce.create('tinymce.plugins.AutoResizePlugin', { - /** - * Initializes the plugin, this will be executed after the plugin has been created. - * This call is done before the editor instance has finished it's initialization so use the onInit event - * of the editor instance to intercept that event. - * - * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in. - * @param {string} url Absolute URL to where the plugin is located. - */ - init : function(ed, url) { - var t = this; - - if (ed.getParam('fullscreen_is_enabled')) - return; - - /** - * This method gets executed each time the editor needs to resize. - */ - function resize() { - var d = ed.getDoc(), b = d.body, de = d.documentElement, DOM = tinymce.DOM, resizeHeight = t.autoresize_min_height, myHeight; - - // Get height differently depending on the browser used - myHeight = tinymce.isIE ? b.scrollHeight : de.offsetHeight; - - // Don't make it smaller than the minimum height - if (myHeight > t.autoresize_min_height) - resizeHeight = myHeight; - - // Resize content element - DOM.setStyle(DOM.get(ed.id + '_ifr'), 'height', resizeHeight + 'px'); - - // if we're throbbing, we'll re-throb to match the new size - if (t.throbbing) { - ed.setProgressState(false); - ed.setProgressState(true); - } - }; - - t.editor = ed; - - // Define minimum height - t.autoresize_min_height = ed.getElement().offsetHeight; - - // Add appropriate listeners for resizing content area - ed.onChange.add(resize); - ed.onSetContent.add(resize); - ed.onPaste.add(resize); - ed.onKeyUp.add(resize); - ed.onPostRender.add(resize); - - if (ed.getParam('autoresize_on_init', true)) { - // Things to do when the editor is ready - ed.onInit.add(function(ed, l) { - // Show throbber until content area is resized properly - ed.setProgressState(true); - t.throbbing = true; - - // Hide scrollbars - ed.getBody().style.overflowY = "hidden"; - }); - - ed.onLoadContent.add(function(ed, l) { - resize(); - - // Because the content area resizes when its content CSS loads, - // and we can't easily add a listener to its onload event, - // we'll just trigger a resize after a short loading period - setTimeout(function() { - resize(); - - // Disable throbber - ed.setProgressState(false); - t.throbbing = false; - }, 1250); - }); - } - - // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample'); - ed.addCommand('mceAutoResize', resize); - }, - - /** - * Returns information about the plugin as a name/value array. - * The current keys are longname, author, authorurl, infourl and version. - * - * @return {Object} Name/value array containing information about the plugin. - */ - getInfo : function() { - return { - longname : 'Auto Resize', - author : 'Moxiecode Systems AB', - authorurl : 'http://tinymce.moxiecode.com', - infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autoresize', - version : tinymce.majorVersion + "." + tinymce.minorVersion - }; - } - }); - - // Register plugin - tinymce.PluginManager.add('autoresize', tinymce.plugins.AutoResizePlugin); +(function () { + /** + * Auto Resize + * + * This plugin automatically resizes the content area to fit its content height. + * It will retain a minimum height, which is the height of the content area when + * it's initialized. + */ + tinymce.create('tinymce.plugins.AutoResizePlugin', { + /** + * Initializes the plugin, this will be executed after the plugin has been created. + * This call is done before the editor instance has finished it's initialization so use the onInit event + * of the editor instance to intercept that event. + * + * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in. + * @param {string} url Absolute URL to where the plugin is located. + */ + init: function (ed, url) { + var t = this; + + if (ed.getParam('fullscreen_is_enabled')) + return; + + /** + * This method gets executed each time the editor needs to resize. + */ + function resize() { + var d = ed.getDoc(), b = d.body, de = d.documentElement, DOM = tinymce.DOM, resizeHeight = t.autoresize_min_height, myHeight; + + // Don't resize if we have no width - a fix for http://orchard.codeplex.com/workitem/16853 + if ((tinymce.isIE ? b.scrollWidth : de.offsetWidth) == 0) { + return; + } + + // Get height differently depending on the browser used + myHeight = tinymce.isIE ? b.scrollHeight : de.offsetHeight; + + // Don't make it smaller than the minimum height + if (myHeight > t.autoresize_min_height) + resizeHeight = myHeight; + + // Resize content element + DOM.setStyle(DOM.get(ed.id + '_ifr'), 'height', resizeHeight + 'px'); + + // if we're throbbing, we'll re-throb to match the new size + if (t.throbbing) { + ed.setProgressState(false); + ed.setProgressState(true); + } + }; + + t.editor = ed; + + // Define minimum height + t.autoresize_min_height = ed.getElement().offsetHeight; + + // Add appropriate listeners for resizing content area + ed.onChange.add(resize); + ed.onSetContent.add(resize); + ed.onPaste.add(resize); + ed.onKeyUp.add(resize); + ed.onPostRender.add(resize); + + if (ed.getParam('autoresize_on_init', true)) { + // Things to do when the editor is ready + ed.onInit.add(function (ed, l) { + // Show throbber until content area is resized properly + ed.setProgressState(true); + t.throbbing = true; + + // Hide scrollbars + ed.getBody().style.overflowY = "hidden"; + }); + + ed.onLoadContent.add(function (ed, l) { + resize(); + + // Because the content area resizes when its content CSS loads, + // and we can't easily add a listener to its onload event, + // we'll just trigger a resize after a short loading period + setTimeout(function () { + resize(); + + // Disable throbber + ed.setProgressState(false); + t.throbbing = false; + }, 1250); + }); + } + + // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample'); + ed.addCommand('mceAutoResize', resize); + }, + + /** + * Returns information about the plugin as a name/value array. + * The current keys are longname, author, authorurl, infourl and version. + * + * @return {Object} Name/value array containing information about the plugin. + */ + getInfo: function () { + return { + longname: 'Auto Resize', + author: 'Moxiecode Systems AB', + authorurl: 'http://tinymce.moxiecode.com', + infourl: 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autoresize', + version: tinymce.majorVersion + "." + tinymce.minorVersion + }; + } + }); + + // Register plugin + tinymce.PluginManager.add('autoresize', tinymce.plugins.AutoResizePlugin); })(); \ No newline at end of file diff --git a/src/Orchard.Web/Themes/TheAdmin/Views/Menu.cshtml b/src/Orchard.Web/Themes/TheAdmin/Views/Menu.cshtml index 12ddff3ab..ef3d5abf2 100644 --- a/src/Orchard.Web/Themes/TheAdmin/Views/Menu.cshtml +++ b/src/Orchard.Web/Themes/TheAdmin/Views/Menu.cshtml @@ -31,7 +31,7 @@ var firstLevelTag = Tag(firstLevelMenuItem, "li"); @firstLevelTag.StartElement

@sectionHeaderMarkup

- if (secondLevelMenuItems.Count() > 1) { + if (secondLevelMenuItems.Count() > 1 || !firstLevelMenuItem.LinkToFirstChild) {