mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Initial version of the generic MediaPicker module (note: currently largely unstyled html, but functional).
--HG-- branch : dev
This commit is contained in:
26
src/Orchard.Web/Modules/Orchard.MediaPicker/AdminFilter.cs
Normal file
26
src/Orchard.Web/Modules/Orchard.MediaPicker/AdminFilter.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Mvc.Filters;
|
||||
using Orchard.UI.Resources;
|
||||
|
||||
namespace Orchard.MediaPicker {
|
||||
public class AdminFilter : FilterProvider, IResultFilter {
|
||||
private readonly IResourceManager _resourceManager;
|
||||
|
||||
public AdminFilter(IResourceManager resourceManager) {
|
||||
_resourceManager = resourceManager;
|
||||
}
|
||||
|
||||
public void OnResultExecuting(ResultExecutingContext filterContext) {
|
||||
// should only run on a full view rendering result
|
||||
if (!(filterContext.Result is ViewResult) || !Orchard.UI.Admin.AdminFilter.IsApplied(filterContext.RequestContext))
|
||||
return;
|
||||
_resourceManager.Require("script", "OpenAjax");
|
||||
_resourceManager.Require("script", "jQuery");
|
||||
_resourceManager.Include("script", "~/Modules/Orchard.MediaPicker/Scripts/MediaPicker.js", null);
|
||||
}
|
||||
|
||||
public void OnResultExecuted(ResultExecutedContext filterContext) {
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Localization;
|
||||
using Orchard;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Media.Models;
|
||||
using Orchard.Media.ViewModels;
|
||||
using Orchard.Media.Services;
|
||||
using Orchard.Security;
|
||||
using Orchard.UI.Admin;
|
||||
using Orchard.Themes;
|
||||
|
||||
namespace Orchard.MediaPicker.Controllers {
|
||||
[Themed(false)]
|
||||
public class HomeController : Controller {
|
||||
private readonly IMediaService _mediaService;
|
||||
private readonly IAuthorizer _authorizer;
|
||||
|
||||
public IOrchardServices Services { get; set; }
|
||||
|
||||
public HomeController(IOrchardServices services, IMediaService mediaService, IAuthorizer authorizer) {
|
||||
_authorizer = authorizer;
|
||||
|
||||
Services = services;
|
||||
_mediaService = mediaService;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public ActionResult Index(string name, string mediaPath) {
|
||||
// this controller should only be used from the admin panel.
|
||||
// it is not itself an admincontroller, however, because it needs to be 'unthemed',
|
||||
// which admincontrollers currently cannot be.
|
||||
if (!_authorizer.Authorize(StandardPermissions.AccessAdminPanel, T("Can't access the admin"))) {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
IEnumerable<MediaFile> mediaFiles = _mediaService.GetMediaFiles(mediaPath);
|
||||
IEnumerable<MediaFolder> mediaFolders = _mediaService.GetMediaFolders(mediaPath);
|
||||
var model = new MediaFolderEditViewModel { FolderName = name, MediaFiles = mediaFiles, MediaFolders = mediaFolders, MediaPath = mediaPath };
|
||||
ViewData["Service"] = _mediaService;
|
||||
return View(model);
|
||||
}
|
||||
}
|
||||
}
|
13
src/Orchard.Web/Modules/Orchard.MediaPicker/Module.txt
Normal file
13
src/Orchard.Web/Modules/Orchard.MediaPicker/Module.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
Name: MediaPicker
|
||||
AntiForgery: enabled
|
||||
Author: The Orchard Team
|
||||
Website: http://orchardproject.net
|
||||
Version: 1.0
|
||||
OrchardVersion: 1.0
|
||||
Description: Description for the module
|
||||
Features:
|
||||
Orchard.MediaPicker:
|
||||
Name: MediaPicker
|
||||
Dependencies: Orchard.Media, Orchard.jQuery
|
||||
Description: UI for browsing for, uploading, or selecting an image for an HTML editor.
|
||||
Category: Input Editor
|
@@ -0,0 +1,139 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{43D0EC0B-1955-4566-8D31-7B9102DA1703}</ProjectGuid>
|
||||
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Orchard.MediaPicker</RootNamespace>
|
||||
<AssemblyName>Orchard.MediaPicker</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<MvcBuildViews>false</MvcBuildViews>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.DynamicData" />
|
||||
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\lib\aspnetmvc\System.Web.Mvc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Abstractions" />
|
||||
<Reference Include="System.Web.Routing" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Scripts\MediaBrowser.js" />
|
||||
<Content Include="Scripts\MediaPicker.js" />
|
||||
<Content Include="Styles\mediapicker.css" />
|
||||
<Content Include="Views\Web.config" />
|
||||
<Content Include="Scripts\Web.config" />
|
||||
<Content Include="Styles\Web.config" />
|
||||
<Content Include="Properties\AssemblyInfo.cs" />
|
||||
<Content Include="Module.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
|
||||
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
|
||||
<Name>Orchard.Framework</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Core\Orchard.Core.csproj">
|
||||
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
|
||||
<Name>Orchard.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.Media\Orchard.Media.csproj">
|
||||
<Project>{D9A7B330-CD22-4DA1-A95A-8DE1982AD8EB}</Project>
|
||||
<Name>Orchard.Media</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AdminFilter.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Index.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Tab_Url.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Tab_Gallery.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target> -->
|
||||
<Target Name="AfterBuild" DependsOnTargets="AfterBuildCompiler">
|
||||
<PropertyGroup>
|
||||
<AreasManifestDir>$(ProjectDir)\..\Manifests</AreasManifestDir>
|
||||
</PropertyGroup>
|
||||
<!-- If this is an area child project, uncomment the following line:
|
||||
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Child" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
|
||||
-->
|
||||
<!-- If this is an area parent project, uncomment the following lines:
|
||||
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Parent" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
|
||||
<CopyAreaManifests ManifestPath="$(AreasManifestDir)" CrossCopy="false" RenameViews="true" />
|
||||
-->
|
||||
</Target>
|
||||
<Target Name="AfterBuildCompiler" Condition="'$(MvcBuildViews)'=='true'">
|
||||
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" />
|
||||
</Target>
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||
<WebProjectProperties>
|
||||
<UseIIS>False</UseIIS>
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>45979</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>
|
||||
</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>True</UseCustomServer>
|
||||
<CustomServerUrl>http://orchard.codeplex.com</CustomServerUrl>
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
@@ -0,0 +1,34 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Orchard.MediaPicker")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyProduct("Orchard")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("d33b592c-133c-440b-8841-17e55eb08306")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
@@ -0,0 +1,258 @@
|
||||
(function ($) {
|
||||
var currentAspect = {},
|
||||
selectedItem,
|
||||
suppressResize;
|
||||
|
||||
$.extend({
|
||||
mediaPicker: {
|
||||
init: function (data) {
|
||||
// called by the opener to initiate dialog with existing image data.
|
||||
// todo: data.img may contain existing image data, populate the fields
|
||||
var img = data.img;
|
||||
if (img) {
|
||||
for (var name in img) {
|
||||
$("#img-" + name).val(img[name]);
|
||||
}
|
||||
suppressResize = true;
|
||||
$("#img-src").trigger("change");
|
||||
}
|
||||
},
|
||||
uploadMedia: uploadMedia,
|
||||
scalePreview: scalePreview
|
||||
}
|
||||
});
|
||||
|
||||
$("#img-cancel, #lib-cancel").live("click", function () { window.close(); });
|
||||
// when url changes, set the preview and loader src
|
||||
$("#img-src").live("change", function () {
|
||||
selectImage(getIdPrefix(this), this.value);
|
||||
});
|
||||
$(".media-item").live("click", function () {
|
||||
if (selectedItem) {
|
||||
selectedItem.removeClass("selected");
|
||||
}
|
||||
selectedItem = $(this);
|
||||
selectedItem.addClass("selected");
|
||||
selectImage("#lib-", selectedItem.attr("data-imgsrc"));
|
||||
});
|
||||
// maintain aspect ratio when width or height is changed
|
||||
$("#img-width, #lib-width").live("change", fixAspectHeight);
|
||||
$("#img-height, #lib-height").live("change", fixAspectWidth);
|
||||
|
||||
$("#img-insert, #lib-insert").live("click", function () {
|
||||
if ($(this).hasClass("disabled")) return;
|
||||
publishInsertEvent(this);
|
||||
});
|
||||
|
||||
$(function () {
|
||||
$("#tabs").tabs({ selected: parseInt(location.hash.replace("#", "")) || 0 });
|
||||
|
||||
// populate width and height when image loads
|
||||
// note: load event does not bubble so cannot be used with .live
|
||||
$("#img-loader, #lib-loader").bind("load", syncImage);
|
||||
|
||||
// edit mode has slightly different wording
|
||||
// elements advertise this with data-edittext attributes,
|
||||
// the edit text is the element's new val() unless -content is specified.
|
||||
if (query("editmode") === "true") {
|
||||
$("[data-edittext]").each(function () {
|
||||
var self = $(this),
|
||||
isContent = self.attr("data-edittext-content") === "true",
|
||||
editText = self.attr("data-edittext");
|
||||
if (isContent) {
|
||||
self.text(editText);
|
||||
}
|
||||
else {
|
||||
self.attr("value", editText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var data = window.mediaPickerData;
|
||||
if (data) {
|
||||
window.mediaPickerData = null;
|
||||
$.mediaPicker.init(data);
|
||||
}
|
||||
});
|
||||
|
||||
function selectImage(prefix, src) {
|
||||
$(prefix + "preview").width("").height("").attr("src", src);
|
||||
$(prefix + "loader").attr("src", src);
|
||||
$(prefix + "src").val(src);
|
||||
|
||||
var disabled = src ? "" : "disabled";
|
||||
$(prefix + "insert").attr("disabled", disabled).toggleClass("disabled", !!disabled);
|
||||
}
|
||||
|
||||
function getIdPrefix(e) {
|
||||
return "#" + e.id.substr(0, 4);
|
||||
}
|
||||
function publishInsertEvent(button) {
|
||||
var prefix = getIdPrefix(button),
|
||||
editorId = query("editorId"),
|
||||
source = query("source"),
|
||||
img = {
|
||||
src: $(prefix + "src").val(),
|
||||
alt: $(prefix + "alt").val(),
|
||||
"class": $(prefix + "class").val(),
|
||||
style: $(prefix + "style").val(),
|
||||
align: $(prefix + "align").val(),
|
||||
width: $(prefix + "width").val(),
|
||||
height: $(prefix + "height").val()
|
||||
};
|
||||
img.html = getImageHtml(img);
|
||||
window.opener.OpenAjax.hub.publish("orchard.admin.pickimage-picked." + source, {
|
||||
editorId: editorId,
|
||||
img: img
|
||||
});
|
||||
window.close();
|
||||
}
|
||||
|
||||
function parseUnits(value) {
|
||||
if (/\s*[0-9]+\s*(px)?\s*/i.test(value)) {
|
||||
return parseInt(value);
|
||||
}
|
||||
return NaN;
|
||||
}
|
||||
|
||||
function fixAspectWidth() {
|
||||
var prefix = getIdPrefix(this);
|
||||
if (!$(prefix + "lock:checked").val()) return;
|
||||
var height = parseUnits(this.value);
|
||||
if (!isNaN(height)) {
|
||||
$(prefix + "width").val(Math.round(height * currentAspect[prefix]));
|
||||
}
|
||||
}
|
||||
|
||||
function fixAspectHeight() {
|
||||
var prefix = getIdPrefix(this);
|
||||
if (!$(prefix + "lock:checked").val()) return;
|
||||
var width = parseUnits(this.value);
|
||||
if (!isNaN(width)) {
|
||||
$(prefix + "height").val(Math.round(width / currentAspect[prefix]));
|
||||
}
|
||||
}
|
||||
|
||||
function scalePreview(img) {
|
||||
// ensures the loaded image preview fits within the preview area
|
||||
// by scaling it down if not.
|
||||
var self = $(img),
|
||||
width = self.width(),
|
||||
height = self.height(),
|
||||
aspect = width / height,
|
||||
maxWidth = self.parent().width(),
|
||||
maxHeight = self.parent().height();
|
||||
if (width > maxWidth) {
|
||||
width = maxWidth;
|
||||
height = Math.round(width / aspect);
|
||||
}
|
||||
if (height > maxHeight) {
|
||||
height = maxHeight;
|
||||
width = Math.round(width * aspect);
|
||||
}
|
||||
self.width(width).height(height);
|
||||
}
|
||||
|
||||
function syncImage() {
|
||||
// when the image loader loads, we use it to calculate the current image
|
||||
// aspect ratio, and update the width and height fields.
|
||||
var prefix = getIdPrefix(this),
|
||||
self = $(this),
|
||||
width = self.width(),
|
||||
height = self.height();
|
||||
currentAspect[prefix] = width / height;
|
||||
// because we just loaded an edited image, leave the width/height
|
||||
// at their configured values, not the natural size.
|
||||
if (!suppressResize) {
|
||||
$(prefix + "width").val(width);
|
||||
$(prefix + "height").val(height);
|
||||
}
|
||||
suppressResize = false;
|
||||
}
|
||||
|
||||
function getAttr(name, value) {
|
||||
// get an attribute value, escaping any necessary characters to html entities.
|
||||
// not an exhastive list, but should cover all the necessary characters for this UI (e.g. you can't really put in newlines).
|
||||
if (!value && name !== "alt") return "";
|
||||
return ' ' + name + '="' + value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">") + '"';
|
||||
}
|
||||
|
||||
function getImageHtml(data) {
|
||||
return html = '<img src="' + encodeURI(data.src) + '"' + getAttr("alt", data.alt || "")
|
||||
+ getAttr("class", data["class"])
|
||||
+ getAttr("style", data.style)
|
||||
+ getAttr("align", data.align)
|
||||
+ getAttr("width", data.width)
|
||||
+ getAttr("height", data.height)
|
||||
+ "/>";
|
||||
}
|
||||
|
||||
function uploadMedia(form) {
|
||||
var name = "addmedia__" + (new Date()).getTime();
|
||||
$("<iframe/>", {
|
||||
name: name,
|
||||
src: "about:blank",
|
||||
css: { display: "none" },
|
||||
load: iframeLoadHandler
|
||||
}).appendTo(document.body);
|
||||
form.target = name;
|
||||
}
|
||||
|
||||
// get a querystring value
|
||||
function query(name) {
|
||||
name = name.toLowerCase();
|
||||
var search = location.search;
|
||||
var parts = search.replace("?", "").split("&");
|
||||
for (var i = 0, l = parts.length; i < l; i++) {
|
||||
var part = parts[i];
|
||||
var eqIndex = part.indexOf("=");
|
||||
if (eqIndex !== -1 && part.substr(0, eqIndex).toLowerCase() === name) {
|
||||
return part.substr(eqIndex + 1);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function iframeLoadHandler() {
|
||||
try {
|
||||
var self = $(this),
|
||||
frame = window.frames[this.name];
|
||||
if (!frame.document || frame.document.URL == "about:blank") {
|
||||
return true;
|
||||
}
|
||||
var result = frame.result;
|
||||
if (result && result.url) {
|
||||
// successfully uploaded image, response by setting the url
|
||||
// to the new image. The change event will respond just as if
|
||||
// the user typed the url.
|
||||
$("#img-src").val(result.url).trigger("change");
|
||||
}
|
||||
else if (result && result.error) {
|
||||
alert(result.error);
|
||||
}
|
||||
else {
|
||||
var somethingPotentiallyHorrible = "";
|
||||
try {
|
||||
somethingPotentiallyHorrible = $("body", frame.document).html();
|
||||
}
|
||||
catch (ex) { // some browsers flip out trying to access anything in the iframe when there's an error.
|
||||
}
|
||||
if (somethingPotentiallyHorrible) {
|
||||
alert(somethingPotentiallyHorrible);
|
||||
}
|
||||
}
|
||||
|
||||
//cleanup
|
||||
window.setTimeout(function () {
|
||||
self.remove();
|
||||
}, 123);
|
||||
|
||||
}
|
||||
catch (ex) {
|
||||
alert(ex.message);
|
||||
}
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
|
||||
|
@@ -0,0 +1,40 @@
|
||||
(function () {
|
||||
var eventPrefix = "orchard.admin.pickimage-open.",
|
||||
pickerAction = "/MediaPicker",
|
||||
defaultFeatures = "width=800,height=600,status=no,toolbar=no,location=no,menubar=no,resizable=no";
|
||||
|
||||
OpenAjax.hub.subscribe(eventPrefix + "*", function (name, data) {
|
||||
var adminIndex = location.href.toLowerCase().indexOf("/admin/");
|
||||
if (adminIndex === -1) return;
|
||||
var url = location.href.substr(0, adminIndex)
|
||||
+ pickerAction + "?source=" + name.substr(eventPrefix.length)
|
||||
+ "&upload=" + (data.uploadMediaAction || "")
|
||||
+ "&uploadpath=" + (data.uploadMediaPath || "")
|
||||
+ "&editmode=" + (!!(data.img && data.img.src))
|
||||
+ "&editorId=" + data.editorId + "&" + (new Date() - 0);
|
||||
var w = window.open(url, "_blank", data.windowFeatures || defaultFeatures);
|
||||
if (w.jQuery && w.jQuery.mediaPicker) {
|
||||
w.jQuery.mediaPicker.init(data);
|
||||
}
|
||||
else {
|
||||
w.mediaPickerData = data;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
//// Or, with jQuery
|
||||
//(function ($) {
|
||||
// $.orchardHub = $.orchardHub || {}; // this part would be built into the admin.js script or something
|
||||
|
||||
// $($.orchardHub).bind("orchard-admin-pickimage", function(ev, data) {
|
||||
// var adminIndex = location.href.toLowerCase().indexOf("/admin/");
|
||||
// if (adminIndex === -1) return;
|
||||
// var url = location.href.substr(0, adminIndex)
|
||||
// + "/Orchard.MediaPicker/MediaPicker/Index?source=" + data.source
|
||||
// + "&upload=" + data.uploadMediaAction
|
||||
// + "&editorId=" + data.editorId + "&" + (new Date() - 0);
|
||||
// var w = window.open(url, "Orchard.MediaPicker", data.windowFeatures || "width=600,height=300,status=no,toolbar=no,location=no,menubar=no");
|
||||
// // in case it was already open, bring to the fore
|
||||
// w.focus();
|
||||
// });
|
||||
//})(jQuery);
|
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="webpages:Enabled" value="false" />
|
||||
</appSettings>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<!-- iis6 - for any request in this location, return via managed static file handler -->
|
||||
<add path="*" verb="*" type="System.Web.StaticFileHandler" />
|
||||
</httpHandlers>
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<handlers accessPolicy="Script,Read">
|
||||
<!--
|
||||
iis7 - for any request to a file exists on disk, return it via native http module.
|
||||
accessPolicy 'Script' is to allow for a managed 404 page.
|
||||
-->
|
||||
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="webpages:Enabled" value="false" />
|
||||
</appSettings>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<!-- iis6 - for any request in this location, return via managed static file handler -->
|
||||
<add path="*" verb="*" type="System.Web.StaticFileHandler" />
|
||||
</httpHandlers>
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<handlers accessPolicy="Script,Read">
|
||||
<!--
|
||||
iis7 - for any request to a file exists on disk, return it via native http module.
|
||||
accessPolicy 'Script' is to allow for a managed 404 page.
|
||||
-->
|
||||
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
@@ -0,0 +1,25 @@
|
||||
input[disabled], input[disabled="disabled"], input.disabled {
|
||||
color: White
|
||||
}
|
||||
input[type="file"] {
|
||||
border: 1px solid black;
|
||||
}
|
||||
.media-largepreview
|
||||
{
|
||||
width: 300px;
|
||||
height: 300px;
|
||||
}
|
||||
.media-thumbnail
|
||||
{
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
}
|
||||
.media-thumbnail img
|
||||
{
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.selected
|
||||
{
|
||||
background-color: Yellow;
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
@model Orchard.Media.ViewModels.MediaFolderEditViewModel
|
||||
@using Orchard.Media.Extensions;
|
||||
@using Orchard.Media.Helpers;
|
||||
@using Orchard.Media.Services;
|
||||
@using Orchard.Media.Models;
|
||||
@using Orchard.UI.Resources;
|
||||
@{
|
||||
Style.Include("~/themes/theadmin/styles/site.css"); // todo: and the IE conditional ones
|
||||
Style.Include("~/themes/theadmin/styles/ie.css").UseCondition("lte IE 8").Define(d => d.SetAttribute("media", "screen, projection"));
|
||||
Style.Include("~/themes/theadmin/styles/ie6.css").UseCondition("lte IE 6").Define(d => d.SetAttribute("media", "screen, projection"));
|
||||
Style.Include("mediapicker.css");
|
||||
|
||||
// these need to be in the head because MediaBrowser.js defines a callback that the thumbnail images call when they load,
|
||||
// which could happen as soon as they render.
|
||||
Style.Require("jQueryUI_Orchard").AtHead();
|
||||
Script.Require("jQueryUI_Tabs").AtHead();
|
||||
Script.Include("MediaBrowser.js").AtHead();
|
||||
}
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>@T("Pick Image")</title>
|
||||
@Display.Metas()
|
||||
@Display.HeadScripts()
|
||||
@Display.HeadLinks()
|
||||
@Display.StyleSheetLinks()
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="tabs" style="float:left">
|
||||
<ul>
|
||||
<li><a href="#tab-url" data-edittext="@T("Update/Upload Image")" data-edittext-content="true">@T("Insert/Upload Image")</a></li>
|
||||
<li><a href="#tab-gallery">@T("Browse Gallery")</a></li>
|
||||
</ul>
|
||||
<div id="tab-url">
|
||||
@Html.Partial("Tab_Url", Model)
|
||||
</div>
|
||||
<div id="tab-gallery">
|
||||
@Html.Partial("Tab_Gallery", Model)
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@Display.FootScripts()
|
||||
</body>
|
||||
</html>
|
@@ -0,0 +1,109 @@
|
||||
@model Orchard.Media.ViewModels.MediaFolderEditViewModel
|
||||
@using Orchard.Media.Extensions;
|
||||
@using Orchard.Media.Helpers;
|
||||
@using Orchard.Media.Services;
|
||||
@using Orchard.Media.Models;
|
||||
@using Orchard.UI.Resources;
|
||||
@helper FolderLink(string folderName, string mediaPath) {
|
||||
// querystring values need to persist after a new GET when clicking on the media browser's
|
||||
// folders for navigation.
|
||||
@Html.ActionLink(folderName, "Index", null, null, null, "1", new {
|
||||
upload = Request["upload"],
|
||||
uploadpath = Request["uploadpath"],
|
||||
editmode = Request["editmode"],
|
||||
source = Request["source"],
|
||||
editorId = Request["editorId"],
|
||||
name = folderName,
|
||||
mediaPath = mediaPath }, null);
|
||||
}
|
||||
<div style="float:left">
|
||||
|
||||
<div class="breadCrumbs">
|
||||
<p>@FolderLink(T("Media Folders").ToString(), "")
|
||||
@foreach (var navigation in MediaHelpers.GetFolderNavigationHierarchy(Model.MediaPath)) {
|
||||
<text>></text> @FolderLink(navigation.FolderName, navigation.FolderPath)
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
<fieldset>
|
||||
<table class="items" summary="@T("This is a table of the pages currently available for use in your application.")">
|
||||
@foreach (var mediaFolder in Model.MediaFolders) {
|
||||
<tr>
|
||||
<td>
|
||||
<img src="@Href("~/Modules/Orchard.Media/Content/Admin/images/folder.gif")" height="16" width="16" class="mediaTypeIcon" alt="@T("Folder")" />
|
||||
</td>
|
||||
<td>
|
||||
@FolderLink(mediaFolder.Name, mediaFolder.MediaPath)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
@foreach (var mediaFile in Model.MediaFiles) {
|
||||
var src = (((IMediaService)ViewData["Service"]).GetPublicUrl(Path.Combine(Model.MediaPath, mediaFile.Name)));
|
||||
<tr data-imgsrc="@src" class="media-item">
|
||||
<td>
|
||||
<div class="media-thumbnail">
|
||||
<img alt="" src="@src" onload="jQuery.mediaPicker.scalePreview(this)" />
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<ul class="media-summary">
|
||||
<li><a href="@src" target="_blank">@mediaFile.Name</a></li>
|
||||
<li>@T("Added on"): @mediaFile.LastUpdated</li>
|
||||
<li>@T("Size"): @mediaFile.Size.ToFriendlySizeString()</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
</div>
|
||||
<div style="float:right">
|
||||
<img alt="" id="lib-loader" style="display:none" src="" />
|
||||
<fieldset style="width:200px">
|
||||
<label for="lib-src">@T("URL")</label>
|
||||
<input type="text" id="lib-src" />
|
||||
|
||||
<label for="lib-alt">@T("Alternative Text")</label>
|
||||
<input type="text" id="lib-alt" />
|
||||
|
||||
<label for="lib-class">@T("Class")</label>
|
||||
<input type="text" id="lib-class" />
|
||||
|
||||
<label for="lib-style">@T("Style")</label>
|
||||
<input type="text" id="lib-style" />
|
||||
|
||||
<label for="lib-align">@T("Alignment")</label>
|
||||
<select id="lib-align">
|
||||
<option value="">None</option>
|
||||
<option value="left">Left</option>
|
||||
<option value="right">Right</option>
|
||||
<option value="top">Top</option>
|
||||
<option value="texttop">Text Top</option>
|
||||
<option value="middle">Middle</option>
|
||||
<option value="absmiddle">AbsMiddle</option>
|
||||
<option value="bottom">Bottom</option>
|
||||
<option value="absbottom">AbsBottom</option>
|
||||
<option value="baseline">Baseline</option>
|
||||
</select>
|
||||
|
||||
<label for="lib-width">@T("Width")</label>
|
||||
<input type="text" id="lib-width" />
|
||||
X
|
||||
<label for="lib-height">@T("Height")</label>
|
||||
<input type="text" id="lib-height" />
|
||||
|
||||
<input type="checkbox" id="lib-lock" checked="checked" />
|
||||
<label for="lib-lock">@T("Lock Aspect Ratio")</label>
|
||||
|
||||
<input type="button" id="lib-cancel" value="@T("Cancel")" />
|
||||
<input type="button" id="lib-insert" value="@T("Insert")" class="disabled" data-edittext="@T("Update")" />
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -0,0 +1,74 @@
|
||||
@model Orchard.Media.ViewModels.MediaFolderEditViewModel
|
||||
@using Orchard.Media.Extensions;
|
||||
@using Orchard.Media.Helpers;
|
||||
@using Orchard.Media.Services;
|
||||
@using Orchard.Media.Models;
|
||||
@using Orchard.UI.Resources;
|
||||
@{
|
||||
// only allow uploading to a local url
|
||||
var uploadAction = Request["upload"];
|
||||
if (!Url.IsLocalUrl(uploadAction)) {
|
||||
uploadAction = "";
|
||||
}
|
||||
var mediaPath = Request["uploadpath"];
|
||||
if (!Url.IsLocalUrl(mediaPath)) {
|
||||
mediaPath = "";
|
||||
}
|
||||
}
|
||||
<div style="float:left;">
|
||||
<img alt="" id="img-loader" style="display:none" src="" />
|
||||
<div class="media-largepreview">
|
||||
<img alt="@T("Preview of Image")" id="img-preview" src="TODO: some placeholder image" onload="jQuery.mediaPicker.scalePreview(this)" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="img-src">@T("URL for the image resource")</label>
|
||||
<input type="text" id="img-src" />
|
||||
</div>
|
||||
<div>
|
||||
@using(Html.BeginFormAntiForgeryPost(uploadAction, FormMethod.Post, new { enctype = "multipart/form-data", onsubmit="jQuery.mediaPicker.uploadMedia(this)"})) {
|
||||
<input type="hidden" name="MediaPath" value="@mediaPath" />
|
||||
<label for="fileUpload">@T("Upload an image from your computer")</label>
|
||||
<input type="file" name="fileUpload" id="fileUpload" />
|
||||
<input type="submit" id="upload" value="Upload" />
|
||||
}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div style="float:right">
|
||||
<fieldset style="width:200px">
|
||||
<label for="img-alt">@T("Alternative Text")</label>
|
||||
<input type="text" id="img-alt" />
|
||||
|
||||
<label for="img-class">@T("Class")</label>
|
||||
<input type="text" id="img-class" />
|
||||
|
||||
<label for="img-style">@T("Style")</label>
|
||||
<input type="text" id="img-style" />
|
||||
|
||||
<label for="img-align">@T("Alignment")</label>
|
||||
<select id="img-align">
|
||||
<option value="">None</option>
|
||||
<option value="left">Left</option>
|
||||
<option value="right">Right</option>
|
||||
<option value="top">Top</option>
|
||||
<option value="texttop">Text Top</option>
|
||||
<option value="middle">Middle</option>
|
||||
<option value="absmiddle">AbsMiddle</option>
|
||||
<option value="bottom">Bottom</option>
|
||||
<option value="absbottom">AbsBottom</option>
|
||||
<option value="baseline">Baseline</option>
|
||||
</select>
|
||||
|
||||
<label for="img-width">@T("Width")</label>
|
||||
<input type="text" id="img-width" />
|
||||
X
|
||||
<label for="img-height">@T("Height")</label>
|
||||
<input type="text" id="img-height" />
|
||||
|
||||
<input type="checkbox" id="img-lock" checked="checked" />
|
||||
<label for="img-lock">@T("Lock Aspect Ratio")</label>
|
||||
|
||||
<input type="button" id="img-cancel" value="@T("Cancel")" />
|
||||
<input type="button" id="img-insert" value="@T("Insert")" class="disabled" data-edittext="@T("Update")" />
|
||||
</fieldset>
|
||||
</div>
|
41
src/Orchard.Web/Modules/Orchard.MediaPicker/Views/Web.config
Normal file
41
src/Orchard.Web/Modules/Orchard.MediaPicker/Views/Web.config
Normal file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="webpages:Enabled" value="false" />
|
||||
</appSettings>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
</httpHandlers>
|
||||
|
||||
<!--
|
||||
Enabling request validation in view pages would cause validation to occur
|
||||
after the input has already been processed by the controller. By default
|
||||
MVC performs request validation before a controller processes the input.
|
||||
To change this behavior apply the ValidateInputAttribute to a
|
||||
controller or action.
|
||||
-->
|
||||
<pages
|
||||
validateRequest="false"
|
||||
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
|
||||
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
|
||||
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<controls>
|
||||
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" namespace="System.Web.Mvc" tagPrefix="mvc" />
|
||||
</controls>
|
||||
</pages>
|
||||
</system.web>
|
||||
|
||||
<system.webServer>
|
||||
<validation validateIntegratedModeConfiguration="false"/>
|
||||
<handlers>
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="2.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
@@ -93,6 +93,7 @@ namespace Orchard.Setup.Services {
|
||||
"Orchard.jQuery",
|
||||
"Orchard.Lists",
|
||||
"Orchard.Media",
|
||||
"Orchard.MediaPicker",
|
||||
"Orchard.Modules",
|
||||
"Orchard.Pages",
|
||||
"Orchard.Roles",
|
||||
|
@@ -1,35 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" >
|
||||
<head>
|
||||
<title>{#addmedia_dlg.title}</title>
|
||||
<script type="text/javascript" src="../../tiny_mce_popup.js"></script>
|
||||
<script type="text/javascript" src="js/addmedia.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<form enctype="multipart/form-data" method="post" onsubmit="return AddMediaDialog.addMedia(this);">
|
||||
<div class="tabs">
|
||||
<ul>
|
||||
<li id="general_tab" class="current"><span><a href="#general_tab">{#addmedia_dlg.title}</a></span></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="panel_wrapper">
|
||||
<table border="0" cellpadding="4" cellspacing="0">
|
||||
<tr>
|
||||
<td class="nowrap"><label for="pageTitle">{#addmedia_dlg.path_label}</label></td>
|
||||
<td><input id="MediaItemPath" name="MediaItemPath" type="file" class="text" size="42" style="width:410px;" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="hidden" id="MediaPath" name="MediaPath" />
|
||||
</div>
|
||||
<div class="mceActionPanel">
|
||||
<div style="float:left">
|
||||
<input name="__RequestVerificationToken" type="hidden" />
|
||||
<input type="submit" name="insert" value="{#insert}" id="insert" />
|
||||
</div>
|
||||
<div style="float:right">
|
||||
<input type="button" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" id="cancel" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
@@ -1 +0,0 @@
|
||||
(function() { tinymce.PluginManager.requireLangPack("addmedia"); tinymce.create('tinymce.plugins.Orchard.AddMedia', { init: function(ed, url) { ed.addCommand('mceAddMedia', function() { ed.windowManager.open({ file: url + '/addmedia.htm', width: 550 + parseInt(ed.getLang('addmedia.delta_width', 0)), height: 110 + parseInt(ed.getLang('addmedia.delta_height', 0)), inline: 1 }, { plugin_url: url }) }); ed.addButton('addmedia', { title: ed.getLang('addmedia.title'), cmd: 'mceAddMedia', image: url + '/img/picture_add.png' }) }, createControl: function(n, cm) { return null }, getInfo: function() { return { longname: 'Orchard AddMedia Plugin', author: 'Nathan Heskew', authorurl: 'http://orchardproject.net', infourl: 'http://orchardproject.net', version: '0.1'} } }); tinymce.PluginManager.add('addmedia', tinymce.plugins.Orchard.AddMedia) })();
|
@@ -1,68 +0,0 @@
|
||||
(function() {
|
||||
// Load plugin specific language pack
|
||||
tinymce.PluginManager.requireLangPack("addmedia");
|
||||
|
||||
tinymce.create('tinymce.plugins.Orchard.AddMedia', {
|
||||
/**
|
||||
* 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) {
|
||||
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceAddMedia');
|
||||
ed.addCommand('mceAddMedia', function() {
|
||||
ed.windowManager.open({
|
||||
file: url + '/addmedia.htm',
|
||||
width: 550 + parseInt(ed.getLang('addmedia.delta_width', 0)),
|
||||
height: 110 + parseInt(ed.getLang('addmedia.delta_height', 0)),
|
||||
inline: 1
|
||||
}, {
|
||||
plugin_url: url
|
||||
});
|
||||
});
|
||||
|
||||
// Register addmedia button
|
||||
ed.addButton('addmedia', {
|
||||
title: ed.getLang('addmedia.title'),
|
||||
cmd: 'mceAddMedia',
|
||||
image: url + '/img/picture_add.png'
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates control instances based in the incomming name. This method is normally not
|
||||
* needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
|
||||
* but you sometimes need to create more complex controls like listboxes, split buttons etc then this
|
||||
* method can be used to create those.
|
||||
*
|
||||
* @param {String} n Name of the control to create.
|
||||
* @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
|
||||
* @return {tinymce.ui.Control} New control instance or null if no control was created.
|
||||
*/
|
||||
createControl: function(n, cm) {
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* 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: 'Orchard AddMedia Plugin',
|
||||
author: 'Nathan Heskew',
|
||||
authorurl: 'http://orchardproject.net',
|
||||
infourl: 'http://orchardproject.net',
|
||||
version: '0.1'
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// Register plugin
|
||||
tinymce.PluginManager.add('addmedia', tinymce.plugins.Orchard.AddMedia);
|
||||
})();
|
@@ -1,92 +0,0 @@
|
||||
tinyMCEPopup.requireLangPack("addmedia");
|
||||
|
||||
// async media file uploads brought to you with a little insight from reading: http://www.bennadel.com/blog/1244-ColdFusion-jQuery-And-AJAX-File-Upload-Demo.htm
|
||||
var AddMediaDialog = {
|
||||
init: function () {
|
||||
var form = document.forms[0];
|
||||
form.action = tinyMCE.activeEditor.getParam('addmedia_action');
|
||||
form.MediaPath.value = tinyMCE.activeEditor.getParam('addmedia_path');
|
||||
form.__RequestVerificationToken.value = tinyMCE.activeEditor.getParam('request_verification_token');
|
||||
},
|
||||
|
||||
addMedia: function (form) {
|
||||
var iframeName = "addmedia__" + (new Date()).getTime();
|
||||
|
||||
var iframe;
|
||||
try {
|
||||
iframe = document.createElement("<iframe name=\"" + iframeName + "\" />"); // <- for some vowel browser
|
||||
} catch (ex) {
|
||||
iframe = document.createElement("iframe");
|
||||
iframe.name = iframeName;
|
||||
}
|
||||
iframe.src = "about:blank";
|
||||
tinymce.DOM.setStyles(iframe, { display: "none" });
|
||||
|
||||
var iframeLoadHandler = tinymce.dom.Event.add(iframe, 'load', function (ev) {
|
||||
try {
|
||||
var frameWindow = window.frames[iframeName];
|
||||
|
||||
if (frameWindow.document.URL == "about:blank") {
|
||||
return true;
|
||||
}
|
||||
|
||||
var result = frameWindow.result, close = 0;
|
||||
|
||||
if (result && result.url) {
|
||||
if (window.parent && window.parent.AddMediaDialog) {
|
||||
window.parent.AddMediaDialog.insertMedia(result.url);
|
||||
} else {
|
||||
AddMediaDialog.insertMedia(result.url);
|
||||
}
|
||||
|
||||
close = 1;
|
||||
} else if (result && result.error) {
|
||||
alert(tinyMCEPopup.getLang("addmedia_dlg.msg_error") + "\n\r\n\r" + result.error);
|
||||
} else {
|
||||
var somethingPotentiallyHorrible = "";
|
||||
try {
|
||||
somethingPotentiallyHorrible = window.frames[iframeName].document.getElementsByTagName("body")[0].innerHTML;
|
||||
} catch (ex) { // some browsers flip out trying to access anything in the iframe when there's an error. best we can do is guess at this point
|
||||
somethingPotentiallyHorrible = tinyMCEPopup.getLang("addmedia_dlg.msg_error_unknown");
|
||||
}
|
||||
if (somethingPotentiallyHorrible) {
|
||||
alert(tinyMCEPopup.getLang("addmedia_dlg.msg_error_unexpected") + "\n\r\n\r" + somethingPotentiallyHorrible);
|
||||
}
|
||||
}
|
||||
|
||||
//cleanup
|
||||
setTimeout(function () {
|
||||
tinymce.dom.Event.remove(iframe, 'load', iframeLoadHandler);
|
||||
tinymce.DOM.remove(iframe);
|
||||
iframe = null;
|
||||
|
||||
if (close) {
|
||||
if (window.parent && window.parent.tinyMCEPopup) {
|
||||
window.parent.tinyMCEPopup.close();
|
||||
} else {
|
||||
tinyMCEPopup.close();
|
||||
}
|
||||
}
|
||||
},
|
||||
123);
|
||||
} catch (ex) {
|
||||
alert(ex.message);
|
||||
}
|
||||
});
|
||||
|
||||
tinymce.DOM.add(document.body, iframe);
|
||||
form.target = iframe.name;
|
||||
},
|
||||
|
||||
insertMedia: function (url) {
|
||||
if (!url) return;
|
||||
|
||||
var markup = /\.(jpe?g|png|gif)$/i.test(url)
|
||||
? "<img src=\"" + url + "\" />"
|
||||
: "<a href=\"" + url + "\">" + url + "</a>";
|
||||
|
||||
tinyMCE.activeEditor.execCommand("mceInsertContent", false, markup);
|
||||
}
|
||||
};
|
||||
|
||||
tinyMCEPopup.onInit.add(AddMediaDialog.init, AddMediaDialog);
|
@@ -1,6 +0,0 @@
|
||||
tinyMCE.addI18n({ en: {
|
||||
addmedia: {
|
||||
title: "Add Media"
|
||||
}
|
||||
}
|
||||
});
|
@@ -1,12 +0,0 @@
|
||||
tinyMCE.addI18n({ en: {
|
||||
addmedia_dlg: {
|
||||
button_title: "Add Media",
|
||||
title: "Add Media",
|
||||
path_label: "Media File Path",
|
||||
browse_button_text: "Browse",
|
||||
msg_error: "Wait, there was an error:",
|
||||
msg_error_unexpected: "Something unexpected happened:",
|
||||
msg_error_unknown: "Can't get the error from the response. This can happen when the server throws an error. Is the file size larger than what the server is configured to accept?"
|
||||
}
|
||||
}
|
||||
});
|
@@ -0,0 +1,2 @@
|
||||
(function(){tinymce.create("tinymce.plugins.Orchard.MediaPicker",{init:function(b,d){b.addCommand("mceMediaPicker",function(){b.focus();var c,a=b.selection.getContent();if(a){a=a.replace(/\<IMG/gi,"<editimg");a=$(a).filter("editimg");if(a.length)c={src:a.attr("src"),"class":a.attr("class"),style:a.css("cssText"),alt:a.attr("alt"),width:a.attr("width"),height:a.attr("height"),align:a.attr("align")}}OpenAjax.hub.publish("orchard.admin.pickimage-open.tinymce",{editorId:b.id,img:c,uploadMediaAction:b.getParam("mediapicker_uploadaction"),
|
||||
uploadMediaPath:b.getParam("mediapicker_uploadpath")})});b.addButton("mediapicker",{title:b.getParam("mediapicker_title"),cmd:"mceMediaPicker",image:d+"/img/picture_add.png"})},createControl:function(){return null},getInfo:function(){return{longname:"Orchard AddMedia Plugin",author:"Dave Reed",authorurl:"http://orchardproject.net",infourl:"http://orchardproject.net",version:"1.1"}}});tinymce.PluginManager.add("mediapicker",tinymce.plugins.Orchard.MediaPicker)})();
|
@@ -0,0 +1,97 @@
|
||||
(function () {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// NOTE: IF YOU EDIT THIS FILE
|
||||
// You must also update editor_plugin.js with a minified version.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// when the picker selects an image, notice the event and update the editor.
|
||||
OpenAjax.hub.subscribe("orchard.admin.pickimage-picked.tinymce", function (name, data) {
|
||||
var ed = tinyMCE.get(data.editorId);
|
||||
ed.focus();
|
||||
ed.selection.setContent(data.img.html);
|
||||
});
|
||||
|
||||
tinymce.create('tinymce.plugins.Orchard.MediaPicker', {
|
||||
/**
|
||||
* 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) {
|
||||
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceMediaPicker');
|
||||
ed.addCommand('mceMediaPicker', function () {
|
||||
ed.focus();
|
||||
// see if there's an image selected that they intend on editing
|
||||
var editImage,
|
||||
content = ed.selection.getContent();
|
||||
if (content) {
|
||||
// replace <img> with <editimg>, so we can easily use jquery to get the 'src' without it
|
||||
// being resolved by the browser (e.g. prevent '/foo.png' becoming 'http://localhost:12345/orchardlocal/foo.png').
|
||||
content = content.replace(/\<IMG/gi, "<editimg");
|
||||
var firstImg = $(content).filter("editimg");
|
||||
if (firstImg.length) {
|
||||
editImage = {
|
||||
src: firstImg.attr("src"),
|
||||
"class": firstImg.attr("class"),
|
||||
style: firstImg.css("cssText"),
|
||||
alt: firstImg.attr("alt"),
|
||||
width: firstImg.attr("width"),
|
||||
height: firstImg.attr("height"),
|
||||
align: firstImg.attr("align")
|
||||
};
|
||||
}
|
||||
}
|
||||
OpenAjax.hub.publish("orchard.admin.pickimage-open.tinymce", {
|
||||
editorId: ed.id,
|
||||
img: editImage,
|
||||
uploadMediaAction: ed.getParam("mediapicker_uploadaction"),
|
||||
uploadMediaPath: ed.getParam("mediapicker_uploadpath")
|
||||
});
|
||||
});
|
||||
|
||||
// Register media button
|
||||
ed.addButton('mediapicker', {
|
||||
title: ed.getParam("mediapicker_title"),
|
||||
cmd: 'mceMediaPicker',
|
||||
image: url + '/img/picture_add.png'
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates control instances based in the incomming name. This method is normally not
|
||||
* needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
|
||||
* but you sometimes need to create more complex controls like listboxes, split buttons etc then this
|
||||
* method can be used to create those.
|
||||
*
|
||||
* @param {String} n Name of the control to create.
|
||||
* @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
|
||||
* @return {tinymce.ui.Control} New control instance or null if no control was created.
|
||||
*/
|
||||
createControl: function (n, cm) {
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* 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: 'Orchard AddMedia Plugin',
|
||||
author: 'Dave Reed',
|
||||
authorurl: 'http://orchardproject.net',
|
||||
infourl: 'http://orchardproject.net',
|
||||
version: '1.1'
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// Register plugin
|
||||
tinymce.PluginManager.add('mediapicker', tinymce.plugins.Orchard.MediaPicker);
|
||||
})();
|
Before Width: | Height: | Size: 750 B After Width: | Height: | Size: 750 B |
@@ -55,6 +55,9 @@
|
||||
<Content Include="Scripts\plugins\fullscreen\editor_plugin.js" />
|
||||
<Content Include="Scripts\plugins\fullscreen\editor_plugin_src.js" />
|
||||
<Content Include="Scripts\plugins\fullscreen\fullscreen.htm" />
|
||||
<Content Include="Scripts\plugins\mediapicker\editor_plugin_src.js" />
|
||||
<Content Include="Scripts\plugins\mediapicker\editor_plugin.js" />
|
||||
<Content Include="Scripts\plugins\mediapicker\img\picture_add.png" />
|
||||
<Content Include="Scripts\themes\advanced\about.htm" />
|
||||
<Content Include="Scripts\themes\advanced\anchor.htm" />
|
||||
<Content Include="Scripts\themes\advanced\charmap.htm" />
|
||||
@@ -124,13 +127,6 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Scripts\plugins\addmedia\addmedia.htm" />
|
||||
<Content Include="Scripts\plugins\addmedia\editor_plugin_src.js" />
|
||||
<Content Include="Scripts\plugins\addmedia\editor_plugin.js" />
|
||||
<Content Include="Scripts\plugins\addmedia\img\picture_add.png" />
|
||||
<Content Include="Scripts\plugins\addmedia\js\addmedia.js" />
|
||||
<Content Include="Scripts\plugins\addmedia\langs\en_dlg.js" />
|
||||
<Content Include="Scripts\plugins\addmedia\langs\en.js" />
|
||||
<Content Include="Scripts\plugins\searchreplace\css\searchreplace.css" />
|
||||
<Content Include="Scripts\plugins\searchreplace\editor_plugin.js" />
|
||||
<Content Include="Scripts\plugins\searchreplace\editor_plugin_src.js" />
|
||||
@@ -146,6 +142,7 @@
|
||||
<ItemGroup>
|
||||
<Content Include="web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@@ -8,16 +8,16 @@
|
||||
theme: "advanced",
|
||||
mode: "specific_textareas",
|
||||
editor_selector: "html",
|
||||
plugins: "fullscreen,autoresize,searchreplace,addmedia",
|
||||
plugins: "fullscreen,autoresize,searchreplace,mediapicker",
|
||||
theme_advanced_toolbar_location: "top",
|
||||
theme_advanced_toolbar_align: "left",
|
||||
theme_advanced_buttons1: "search,replace,|,cut,copy,paste,|,undo,redo,|,image,addmedia,|,link,unlink,charmap,emoticon,codeblock,|,bold,italic,|,numlist,bullist,formatselect,|,code,fullscreen",
|
||||
theme_advanced_buttons1: "search,replace,|,cut,copy,paste,|,undo,redo,|,mediapicker,|,link,unlink,charmap,emoticon,codeblock,|,bold,italic,|,numlist,bullist,formatselect,|,code,fullscreen",
|
||||
theme_advanced_buttons2: "",
|
||||
theme_advanced_buttons3: "",
|
||||
convert_urls: false,
|
||||
addmedia_action: "@Url.Action("AddFromClient", "Admin", new {area = "Orchard.Media"})",
|
||||
addmedia_path: "@Model.AddMediaPath",
|
||||
request_verification_token: "@Html.AntiForgeryTokenValueOrchard()",
|
||||
mediapicker_uploadaction: "@Url.Action("AddFromClient", "Admin", new {area = "Orchard.Media"})",
|
||||
mediapicker_uploadpath: "@Model.AddMediaPath",
|
||||
mediapicker_title: "@T("Insert/Update Media")",
|
||||
extended_valid_elements: "canvas[id|width|height],script[src|type]," +
|
||||
"object[classid|codebase|width|height|align|name|id],param[name|value],embed[quality|type|pluginspage|width|height|src|align]," +
|
||||
"iframe[src|frameborder|width|height|scrolling|name|id]," +
|
||||
|
@@ -106,6 +106,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Specs", "Specs", "{3E10BF6D
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.DesignerTools", "Orchard.Web\Modules\Orchard.DesignerTools\Orchard.DesignerTools.csproj", "{4A4595EF-6C37-4F99-96ED-4AE0B9E438D3}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.MediaPicker", "Orchard.Web\Modules\Orchard.MediaPicker\Orchard.MediaPicker.csproj", "{43D0EC0B-1955-4566-8D31-7B9102DA1703}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
CodeCoverage|Any CPU = CodeCoverage|Any CPU
|
||||
@@ -115,10 +117,6 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4A4595EF-6C37-4F99-96ED-4AE0B9E438D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4A4595EF-6C37-4F99-96ED-4AE0B9E438D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4A4595EF-6C37-4F99-96ED-4AE0B9E438D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4A4595EF-6C37-4F99-96ED-4AE0B9E438D3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{50B779EA-EC00-4699-84C0-03B395C365D2}.CodeCoverage|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{50B779EA-EC00-4699-84C0-03B395C365D2}.CodeCoverage|Any CPU.Build.0 = Release|Any CPU
|
||||
{50B779EA-EC00-4699-84C0-03B395C365D2}.Coverage|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@@ -556,6 +554,23 @@ Global
|
||||
{99002B65-86F7-415E-BF4A-381AA8AB9CCC}.FxCop|Any CPU.Build.0 = Release|Any CPU
|
||||
{99002B65-86F7-415E-BF4A-381AA8AB9CCC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{99002B65-86F7-415E-BF4A-381AA8AB9CCC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4A4595EF-6C37-4F99-96ED-4AE0B9E438D3}.CodeCoverage|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4A4595EF-6C37-4F99-96ED-4AE0B9E438D3}.Coverage|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4A4595EF-6C37-4F99-96ED-4AE0B9E438D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4A4595EF-6C37-4F99-96ED-4AE0B9E438D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4A4595EF-6C37-4F99-96ED-4AE0B9E438D3}.FxCop|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4A4595EF-6C37-4F99-96ED-4AE0B9E438D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4A4595EF-6C37-4F99-96ED-4AE0B9E438D3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{43D0EC0B-1955-4566-8D31-7B9102DA1703}.CodeCoverage|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{43D0EC0B-1955-4566-8D31-7B9102DA1703}.CodeCoverage|Any CPU.Build.0 = Release|Any CPU
|
||||
{43D0EC0B-1955-4566-8D31-7B9102DA1703}.Coverage|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{43D0EC0B-1955-4566-8D31-7B9102DA1703}.Coverage|Any CPU.Build.0 = Release|Any CPU
|
||||
{43D0EC0B-1955-4566-8D31-7B9102DA1703}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{43D0EC0B-1955-4566-8D31-7B9102DA1703}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{43D0EC0B-1955-4566-8D31-7B9102DA1703}.FxCop|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{43D0EC0B-1955-4566-8D31-7B9102DA1703}.FxCop|Any CPU.Build.0 = Release|Any CPU
|
||||
{43D0EC0B-1955-4566-8D31-7B9102DA1703}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{43D0EC0B-1955-4566-8D31-7B9102DA1703}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -591,6 +606,8 @@ Global
|
||||
{FBC8B571-ED50-49D8-8D9D-64AB7454A0D6} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
|
||||
{2AD6973D-C7BB-416E-89FE-EEE34664E05F} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
|
||||
{99002B65-86F7-415E-BF4A-381AA8AB9CCC} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
|
||||
{4A4595EF-6C37-4F99-96ED-4AE0B9E438D3} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
|
||||
{43D0EC0B-1955-4566-8D31-7B9102DA1703} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
|
||||
{ABC826D4-2FA1-4F2F-87DE-E6095F653810} = {74E681ED-FECC-4034-B9BD-01B0BB1BDECA}
|
||||
{F112851D-B023-4746-B6B1-8D2E5AD8F7AA} = {74E681ED-FECC-4034-B9BD-01B0BB1BDECA}
|
||||
{6CB3EB30-F725-45C0-9742-42599BA8E8D2} = {74E681ED-FECC-4034-B9BD-01B0BB1BDECA}
|
||||
@@ -599,9 +616,8 @@ Global
|
||||
{4AB4B5B6-277E-4FF6-B69B-7AE9E16D2A56} = {383DBA32-4A3E-48D1-AAC3-75377A694452}
|
||||
{33B1BC8D-E292-4972-A363-22056B207156} = {383DBA32-4A3E-48D1-AAC3-75377A694452}
|
||||
{0DFA2E10-96C8-4E05-BC10-B710B97ECCDE} = {383DBA32-4A3E-48D1-AAC3-75377A694452}
|
||||
{CB70A642-8CEC-4DDE-8C9F-AD08900EC98D} = {74492CBC-7201-417E-BC29-28B4C25A58B0}
|
||||
{7354DF37-934B-46CF-A13C-455D5F5F5413} = {3E10BF6D-ADA5-417D-B36C-EBB0660B475E}
|
||||
{94E694A2-D140-468D-A277-C5FCE1D13E9B} = {3E10BF6D-ADA5-417D-B36C-EBB0660B475E}
|
||||
{4A4595EF-6C37-4F99-96ED-4AE0B9E438D3} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
|
||||
{7354DF37-934B-46CF-A13C-455D5F5F5413} = {3E10BF6D-ADA5-417D-B36C-EBB0660B475E}
|
||||
{CB70A642-8CEC-4DDE-8C9F-AD08900EC98D} = {74492CBC-7201-417E-BC29-28B4C25A58B0}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
Reference in New Issue
Block a user