DO NOT DOWNLOAD. DOWNLOAD LATEST STABLE FROM RELEASE TAB

Initial checkin of updates to media picker datatype (preview, advanced dialog with upload)

[TFS Changeset #58362]
This commit is contained in:
starfighter83
2009-08-24 12:15:57 +00:00
parent 89fb257583
commit fe744975d8
12 changed files with 631 additions and 22 deletions

View File

@@ -16,7 +16,9 @@ namespace umbraco.editorControls.mediapicker
get
{
if (_Editor == null)
_Editor = new mediaChooser(Data);
_Editor = new mediaChooser(Data,
((MediaPickerPrevalueEditor)PrevalueEditor).ShowPreview,
((MediaPickerPrevalueEditor)PrevalueEditor).ShowAdvancedDialog);
return _Editor;
}
}
@@ -51,7 +53,7 @@ namespace umbraco.editorControls.mediapicker
get
{
if (_prevalueeditor == null)
_prevalueeditor = new DefaultPrevalueEditor(this,false);
_prevalueeditor = new MediaPickerPrevalueEditor(this);
return _prevalueeditor;
}
}

View File

@@ -0,0 +1,160 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using umbraco.DataLayer;
using umbraco.BusinessLogic;
using umbraco.editorControls;
namespace umbraco.editorControls.mediapicker
{
public class MediaPickerPrevalueEditor : System.Web.UI.WebControls.PlaceHolder, umbraco.interfaces.IDataPrevalue
{
public ISqlHelper SqlHelper
{
get { return Application.SqlHelper; }
}
//private DropDownList _dropdownlist;
private CheckBox _checkboxShowPreview;
private CheckBox _checkboxShowAdvancedDialog;
private umbraco.cms.businesslogic.datatype.BaseDataType _datatype;
public MediaPickerPrevalueEditor(umbraco.cms.businesslogic.datatype.BaseDataType DataType)
{
_datatype = DataType;
setupChildControls();
}
private void setupChildControls()
{
//_dropdownlist = new DropDownList();
//_dropdownlist.ID = "dbtype";
//_dropdownlist.Items.Add(DBTypes.Date.ToString());
//_dropdownlist.Items.Add(DBTypes.Integer.ToString());
//_dropdownlist.Items.Add(DBTypes.Ntext.ToString());
//_dropdownlist.Items.Add(DBTypes.Nvarchar.ToString());
_checkboxShowPreview = new CheckBox();
_checkboxShowPreview.ID = "showpreview";
_checkboxShowAdvancedDialog = new CheckBox();
_checkboxShowAdvancedDialog.ID = "showadvanceddialog";
//Controls.Add(_dropdownlist);
Controls.Add(_checkboxShowPreview);
Controls.Add(_checkboxShowAdvancedDialog);
}
public Control Editor
{
get
{
return this;
}
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (!Page.IsPostBack)
{
_checkboxShowPreview.Checked = ShowPreview;
_checkboxShowAdvancedDialog.Checked = ShowAdvancedDialog;
}
}
public void Save()
{
_datatype.DBType = umbraco.cms.businesslogic.datatype.DBTypes.Integer;
// Generate data-string
string data = _checkboxShowPreview.Checked.ToString() + "|" + _checkboxShowAdvancedDialog.Checked.ToString();
// If the add new prevalue textbox is filled out - add the value to the collection.
IParameter[] SqlParams = new IParameter[] {
SqlHelper.CreateParameter("@value",data),
SqlHelper.CreateParameter("@dtdefid",_datatype.DataTypeDefinitionId)};
SqlHelper.ExecuteNonQuery("delete from cmsDataTypePreValues where datatypenodeid = @dtdefid", SqlParams);
SqlHelper.ExecuteNonQuery("insert into cmsDataTypePreValues (datatypenodeid,[value],sortorder,alias) values (@dtdefid,@value,0,'')", SqlParams);
}
public string Configuration
{
get
{
object conf =
SqlHelper.ExecuteScalar<object>("select value from cmsDataTypePreValues where datatypenodeid = @datatypenodeid",
SqlHelper.CreateParameter("@datatypenodeid", _datatype.DataTypeDefinitionId));
if (conf != null)
return conf.ToString();
else
return "";
}
}
public bool ShowPreview
{
get
{
string[] config = Configuration.Split("|".ToCharArray());
if (config.Length > 1)
{
return Convert.ToBoolean(config[0]);
}
else
{
return false;
}
}
}
public bool ShowAdvancedDialog
{
get
{
string[] config = Configuration.Split("|".ToCharArray());
if (config.Length > 1)
{
return Convert.ToBoolean(config[1]);
}
else
{
return false;
}
}
}
protected override void Render(HtmlTextWriter writer)
{
writer.WriteLine("<table>");
//writer.WriteLine("<tr><th>Database datatype:</th><td>");
//_dropdownlist.RenderControl(writer);
//writer.Write("</td></tr>");
writer.Write("<tr><th>Show preview:</th><td>");
_checkboxShowPreview.RenderControl(writer);
writer.Write("</td></tr>");
writer.Write("<tr><th>Show advanced dialog:</th><td>");
_checkboxShowAdvancedDialog.RenderControl(writer);
writer.Write("</td></tr>");
writer.Write("</table>");
}
}
}

View File

@@ -15,11 +15,21 @@ namespace umbraco.editorControls
public class mediaChooser : System.Web.UI.WebControls.HiddenField, interfaces.IDataEditor
{
interfaces.IData _data;
bool _showpreview;
bool _showadvanced;
public mediaChooser(interfaces.IData Data)
{
_data = Data;
}
public mediaChooser(interfaces.IData Data, bool ShowPreview, bool ShowAdvanced)
{
_data = Data;
_showpreview = ShowPreview;
_showadvanced = ShowAdvanced;
}
public System.Web.UI.Control Editor { get { return this; } }
#region IDataField Members
@@ -62,25 +72,45 @@ namespace umbraco.editorControls
// We need to make sure we have a reference to the legacy ajax calls in the scriptmanager
presentation.webservices.ajaxHelpers.EnsureLegacyCalls(base.Page);
// And a reference to the media picker calls
ScriptManager sm = ScriptManager.GetCurrent(base.Page);
ServiceReference webservicePath = new ServiceReference(GlobalSettings.Path + "/webservices/MediaPickerService.asmx");
if (!sm.Services.Contains(webservicePath))
sm.Services.Add(webservicePath);
}
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
string tempTitle = "";
int mediaId = -1;
string deleteLink = " &nbsp; <a href=\"javascript:" + this.ClientID + "_clear();\" style=\"color: red\">" + ui.Text("delete") + "</a> &nbsp; ";
try
{
if (base.Value != "")
{
mediaId = int.Parse(base.Value);
tempTitle = new cms.businesslogic.CMSNode(int.Parse(base.Value)).Text;
}
}
catch { }
string dialog = "\nshowPopWin('" + TreeService.GetPickerUrl(true, "media", "media") + "', 300, 400, " + ClientID + "_saveId)";
if (_showadvanced)
dialog = "\nshowPopWin('" + GlobalSettings.Path + "/dialogs/mediaPicker.aspx" + "', 500, 530, " + ClientID + "_saveId)";
string preview = string.Empty;
if (_showpreview)
preview = "\numbraco.presentation.webservices.MediaPickerService.GetThumbNail(treePicker, " + this.ClientID + "_UpdateThumbNail);" +
"\numbraco.presentation.webservices.MediaPickerService.GetFile(treePicker, " + this.ClientID + "_UpdateLink);";
string strScript = "function " + this.ClientID + "_chooseId() {" +
"\nshowPopWin('" + TreeService.GetPickerUrl(true,"media","media") + "', 300, 400, " + ClientID + "_saveId)" +
//"\nshowPopWin('" + TreeService.GetPickerUrl(true, "media", "media") + "', 300, 400, " + ClientID + "_saveId)" +
//"\nshowPopWin('" + GlobalSettings.Path + "/dialogs/mediaPicker.aspx" + "', 500, 530, " + ClientID + "_saveId)" +
// "\nvar treePicker = window.showModalDialog(, 'treePicker', 'dialogWidth=350px;dialogHeight=300px;scrollbars=no;center=yes;border=thin;help=no;status=no') " +
dialog +
"\n}" +
"\nfunction " + ClientID + "_saveId(treePicker) {" +
"\nsetTimeout('" + ClientID + "_saveIdDo(' + treePicker + ')', 200);" +
@@ -90,6 +120,7 @@ namespace umbraco.editorControls
"\ndocument.getElementById(\"" + this.ClientID + "\").value = treePicker;" +
"\nif (treePicker > 0) {" +
"\numbraco.presentation.webservices.legacyAjaxCalls.GetNodeName(treePicker, " + this.ClientID + "_updateContentTitle" + ");" +
preview+
"\n} " +
"\n}" +
"\n} " +
@@ -99,6 +130,16 @@ namespace umbraco.editorControls
"\nfunction " + this.ClientID + "_clear() {" +
"\ndocument.getElementById(\"" + this.ClientID + "_title\").innerHTML = \"\";" +
"\ndocument.getElementById(\"" + this.ClientID + "\").value = \"\";" +
"\ndocument.getElementById(\"" + this.ClientID + "_preview\").style.display = 'none';" +
"\n}" +
"\nfunction " + this.ClientID + "_UpdateThumbNail(retVal){" +
"\nif(retVal != \"\"){" +
"\ndocument.getElementById(\"" + this.ClientID + "_thumbnail\").src = retVal;" +
"\ndocument.getElementById(\"" + this.ClientID + "_preview\").style.display = 'block';}" +
"\nelse{document.getElementById(\"" + this.ClientID + "_preview\").style.display = 'none';}" +
"\n}"+
"\nfunction " + this.ClientID + "_UpdateLink(retVal){" +
"\ndocument.getElementById(\"" + this.ClientID + "_thumbnaillink\").href = retVal;" +
"\n}";
try
@@ -116,6 +157,28 @@ namespace umbraco.editorControls
if (base.Value == "")
deleteLink = "";
writer.WriteLine("<span id=\"" + this.ClientID + "_title\"><b>" + tempTitle + "</b>" + deleteLink + "</span><a href=\"javascript:" + this.ClientID + "_chooseId()\">" + ui.Text("choose") + "...</a> &nbsp; ");// &nbsp; <input type=\"hidden\" id=\"" + this.ClientID + "\" name=\"" + this.ClientID + "\" value=\"" + this.Text + "\">");
//Thumbnail preview
if (_showpreview)
{
string thumb = string.Empty;
string link = string.Empty;
string style = "display:none;";
if (mediaId != -1)
{
style = string.Empty;
thumb = string.Format(" src=\"{0}\" ", presentation.webservices.MediaPickerServiceHelpers.GetThumbNail(mediaId));
link = string.Format(" href=\"{0}\" ", presentation.webservices.MediaPickerServiceHelpers.GetFile(mediaId));
}
writer.WriteLine("<div id=\"" + this.ClientID + "_preview\" style=\"margin-top:5px;" + style + "\"><a " + link + "id=\"" + this.ClientID + "_thumbnaillink\" target=\"_blank\" ><img " + thumb + "id=\"" + this.ClientID + "_thumbnail\" /></a></div>");
}
base.Render(writer);
}
#endregion

View File

@@ -258,6 +258,7 @@
<Compile Include="mediapicker\MediaPickerDataType.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="mediapicker\MediaPickerPrevalueEditor.cs" />
<Compile Include="memberpicker\memberPicker.cs">
<SubType>Code</SubType>
</Compile>

View File

@@ -486,6 +486,13 @@
<Compile Include="umbraco\dialogs\insertMasterpagePlaceholder.aspx.designer.cs">
<DependentUpon>insertMasterpagePlaceholder.aspx</DependentUpon>
</Compile>
<Compile Include="umbraco\dialogs\mediaPicker.aspx.cs">
<DependentUpon>mediaPicker.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="umbraco\dialogs\mediaPicker.aspx.designer.cs">
<DependentUpon>mediaPicker.aspx</DependentUpon>
</Compile>
<Compile Include="umbraco\dialogs\republish.aspx.cs">
<DependentUpon>republish.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@@ -1090,13 +1097,6 @@
<Compile Include="umbraco\plugins\tinymce3\tinymce3tinymceCompress.aspx.designer.cs">
<DependentUpon>tinymce3tinymceCompress.aspx</DependentUpon>
</Compile>
<Compile Include="umbraco\plugins\tinymce\insertMacro.aspx.cs">
<DependentUpon>insertMacro.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="umbraco\plugins\tinymce\insertMacro.aspx.designer.cs">
<DependentUpon>insertMacro.aspx</DependentUpon>
</Compile>
<Compile Include="umbraco\plugins\tinymce\insertImage.aspx.cs">
<DependentUpon>insertImage.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@@ -1111,6 +1111,13 @@
<Compile Include="umbraco\plugins\tinymce\insertLink.aspx.designer.cs">
<DependentUpon>insertLink.aspx</DependentUpon>
</Compile>
<Compile Include="umbraco\plugins\tinymce\insertMacro.aspx.cs">
<DependentUpon>insertMacro.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="umbraco\plugins\tinymce\insertMacro.aspx.designer.cs">
<DependentUpon>insertMacro.aspx</DependentUpon>
</Compile>
<Compile Include="umbraco\plugins\tinymce\paste.aspx.cs">
<DependentUpon>paste.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@@ -1206,6 +1213,11 @@
<Compile Include="umbraco\dialogs\sort.aspx.designer.cs">
<DependentUpon>sort.aspx</DependentUpon>
</Compile>
<Compile Include="umbraco\webservices\MediaPickerService.asmx.cs">
<DependentUpon>MediaPickerService.asmx</DependentUpon>
<SubType>Component</SubType>
</Compile>
<Compile Include="umbraco\webservices\MediaPickerServiceHelpers.cs" />
<Compile Include="umbraco\webservices\TreeClientService.asmx.cs">
<DependentUpon>TreeClientService.asmx</DependentUpon>
<SubType>Component</SubType>
@@ -1491,7 +1503,19 @@
<Content Include="umbraco\controls\TreeControl.ascx" />
<Content Include="umbraco\css\permissionsEditor.css" />
<Content Include="umbraco\dialogs\ExportCode.aspx" />
<Content Include="umbraco\dialogs\mediaPicker.aspx" />
<Content Include="umbraco\images\editor\spellchecker.gif" />
<Content Include="umbraco\plugins\tinymce3\InsertAnchor.aspx" />
<Content Include="umbraco\plugins\tinymce3\insertChar.aspx" />
<Content Include="umbraco\plugins\tinymce3\insertImage.aspx" />
<Content Include="umbraco\plugins\tinymce3\insertLink.aspx" />
<Content Include="umbraco\plugins\tinymce3\insertMacro.aspx" />
<Content Include="umbraco\plugins\tinymce3\tinymce3tinymceCompress.aspx" />
<Content Include="umbraco\plugins\tinymce\insertImage.aspx" />
<Content Include="umbraco\plugins\tinymce\insertLink.aspx" />
<Content Include="umbraco\plugins\tinymce\insertMacro.aspx" />
<Content Include="umbraco\plugins\tinymce\paste.aspx" />
<Content Include="umbraco\webservices\MediaPickerService.asmx" />
<Content Include="umbraco_client\Application\JQuery\jquery.cookie.js" />
<Content Include="umbraco_client\imagecropper\Jcrop.gif" />
<Content Include="umbraco_client\tablesorting\img\bg.gif" />
@@ -1570,8 +1594,6 @@
<Content Include="umbraco_client\Tree\tree_component.min.js" />
<Content Include="umbraco_client\Tree\UmbracoTree.js" />
<Content Include="umbraco_client\Application\UmbracoClientManager.js" />
<Content Include="umbraco\plugins\tinymce3\InsertAnchor.aspx" />
<Content Include="umbraco\plugins\tinymce3\insertChar.aspx" />
<Content Include="umbraco\webservices\TreeClientService.asmx" />
<Content Include="umbraco_client\Application\NamespaceManager.js" />
<Content Include="umbraco_client\passwordStrength\passwordstrength.js" />
@@ -1887,10 +1909,6 @@
<Content Include="umbraco\LiveEditing\Modules\UnpublishModule\unpublish.png" />
<Content Include="umbraco\LiveEditing\Modules\UnpublishModule\UnpublishModule.js" />
<Content Include="umbraco\members\ViewMembers.aspx" />
<Content Include="umbraco\plugins\tinymce3\insertImage.aspx" />
<Content Include="umbraco\plugins\tinymce3\insertLink.aspx" />
<Content Include="umbraco\plugins\tinymce3\insertMacro.aspx" />
<Content Include="umbraco\plugins\tinymce3\tinymce3tinymceCompress.aspx" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -1928,8 +1946,6 @@
<Content Include="umbraco\js\submodal\maskBG.png" />
<Content Include="umbraco\js\submodal\subModal.css" />
<Content Include="umbraco\js\submodal\subModal.js" />
<Content Include="umbraco\plugins\tinymce\images\sample.gif" />
<Content Include="umbraco\plugins\tinymce\paste.aspx" />
<Content Include="umbraco\reindex.aspx" />
<Content Include="umbraco\settings\DictionaryItemList.aspx" />
<Content Include="umbraco\settings\scripts\editScript.aspx" />
@@ -2298,9 +2314,6 @@
<Content Include="umbraco\ping.aspx">
<SubType>Form</SubType>
</Content>
<Content Include="umbraco\plugins\tinymce\insertMacro.aspx" />
<Content Include="umbraco\plugins\tinymce\insertImage.aspx" />
<Content Include="umbraco\plugins\tinymce\insertLink.aspx" />
<Content Include="umbraco\publishStatus.aspx" />
<Content Include="umbraco\schemas\umbraco.xsd">
<SubType>Designer</SubType>

View File

@@ -0,0 +1,101 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="mediaPicker.aspx.cs" Inherits="umbraco.presentation.umbraco.dialogs.mediaPicker" %>
<%@ Register TagPrefix="ui" Namespace="umbraco.uicontrols" Assembly="controls" %>
<%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %>
<!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 id="Head1" runat="server">
<title></title>
<!-- Default script and style -->
<umb:CssInclude ID="CssInclude1" runat="server" FilePath="ui/default.css" PathNameAlias="UmbracoClient" />
<umb:JsInclude ID="JsInclude1" runat="server" FilePath="Application/NamespaceManager.js" PathNameAlias="UmbracoClient" Priority="0" />
<umb:JsInclude ID="JsInclude3" runat="server" FilePath="ui/jquery.js" PathNameAlias="UmbracoClient" Priority="1" />
<umb:JsInclude ID="JsInclude4" runat="server" FilePath="Application/UmbracoClientManager.js" PathNameAlias="UmbracoClient" Priority="2" />
<umb:JsInclude ID="JsInclude2" runat="server" FilePath="ui/default.js" PathNameAlias="UmbracoClient" Priority="5" />
<script type="text/javascript" language="javascript">
var mediaid = -1;
function dialogHandler(id) {
if (id != -1) {
mediaid = id;
jQuery("#submitbutton").attr("disabled", false);
}
else
{
jQuery("#submitbutton").attr("disabled", true);
}
document.getElementById('imageViewer').src = '/umbraco/dialogs/imageViewer.aspx?id=' + id;
}
function updateImageSource(src, alt, width, height,id) {
if (id != null) {
mediaid = id;
jQuery("#submitbutton").attr("disabled", false);
}
jQuery("#previewImage").css("background-image", "url(" + src.substring(0, (src.length - 4)) + "_thumb.jpg)");
}
function refreshTree() {
jQuery("#treeFrame").attr("src", jQuery("#treeFrame").attr("src"));
}
function UpdatePicker() {
if(mediaid != -1)
{
parent.hidePopWin(true,mediaid);
}
}
</script>
</head>
<body class="umbracoDialog" style="margin: 15px 10px 0px 10px;">
<ui:UmbracoClientDependencyLoader runat="server" id="ClientLoader" />
<form id="Form1" runat="server" onsubmit="UpdatePicker();return false;" action="#">
<ui:Pane ID="pane_src" runat="server" >
<div style="height:105px"></div>
<div id="previewImage" style="width: 105px; height: 105px; background: #fff center center no-repeat; border: 1px solid #ccc; position: absolute; top: 3px; right: 3px;">
</div>
</ui:Pane>
<br />
<ui:TabView AutoResize="false" Width="455px" Height="305px" runat="server" ID="tv_options" />
<ui:Pane ID="pane_select" runat="server">
<div style="padding: 5px; background: #fff; height: 250px;">
<iframe id="treeFrame" name="treeFrame" src="../TreeInit.aspx?app=media&isDialog=true&dialogMode=id&contextMenu=false&functionToCall=parent.dialogHandler" style="width: 405px; height: 250px; float: left; border: none;" frameborder="0"></iframe>
<iframe src="imageViewer.aspx" id="imageViewer" style="width: 0px; height: 0px; visibility: hidden; float: right; border: none;" frameborder="0"></iframe>
</div>
</ui:Pane>
<asp:Panel ID="pane_upload" runat="server">
<iframe frameborder="0" src="uploadImage.aspx" style="border: none; width: 435px; height: 250px;"></iframe>
</asp:Panel>
<br />
<p>
<input type="submit" value="select" style="width: 60px;" disabled="true" id="submitbutton"/> <em id="orcopy">or</em>
<a href="#" style="color: blue" onclick="parent.hidePopWin(false,0);" id="cancelbutton">{#cancel}</a>
</p>
</form>
<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#submitbutton").attr("value", '<%= umbraco.ui.Text("select") %>');
jQuery("#cancelbutton").text('<%= umbraco.ui.Text("cancel") %>');
jQuery("#orcopy").text('<%= umbraco.ui.Text("or") %>');
});
</script>
</body>
</html>

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace umbraco.presentation.umbraco.dialogs
{
public partial class mediaPicker : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected override void OnInit(EventArgs e)
{
uicontrols.TabPage tp = tv_options.NewTabPage(ui.Text("choose"));
tp.HasMenu = false;
tp.Controls.Add(pane_select);
uicontrols.TabPage tp2 = tv_options.NewTabPage(ui.Text("create") + " " + ui.Text("new"));
tp2.HasMenu = false;
tp2.Controls.Add(pane_upload);
base.OnInit(e);
}
}
}

View File

@@ -0,0 +1,124 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.3074
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace umbraco.presentation.umbraco.dialogs {
public partial class mediaPicker {
/// <summary>
/// Head1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlHead Head1;
/// <summary>
/// CssInclude1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::ClientDependency.Core.Controls.CssInclude CssInclude1;
/// <summary>
/// JsInclude1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::ClientDependency.Core.Controls.JsInclude JsInclude1;
/// <summary>
/// JsInclude3 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::ClientDependency.Core.Controls.JsInclude JsInclude3;
/// <summary>
/// JsInclude4 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::ClientDependency.Core.Controls.JsInclude JsInclude4;
/// <summary>
/// JsInclude2 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::ClientDependency.Core.Controls.JsInclude JsInclude2;
/// <summary>
/// ClientLoader control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.UmbracoClientDependencyLoader ClientLoader;
/// <summary>
/// Form1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm Form1;
/// <summary>
/// pane_src control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.Pane pane_src;
/// <summary>
/// tv_options control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.TabView tv_options;
/// <summary>
/// pane_select control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.Pane pane_select;
/// <summary>
/// pane_upload control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Panel pane_upload;
}
}

View File

@@ -69,7 +69,7 @@ namespace umbraco.dialogs
feedback.Text += "<div style=\"text-align: center\"> <a target=\"_blank\" href='" + umbraco.GlobalSettings.Path + "/.." + m.getProperty("umbracoFile").Value.ToString() + "'><img src='" + umbraco.GlobalSettings.Path + "/../" + imagename + "' style='border: none;'/><br/><br/>";
feedback.Text += umbraco.ui.Text("thumbnailimageclickfororiginal") + "</a><br/><br/></div>";
feedback.Text += "<script type=\"text/javascript\">\n parent.refreshTree(); \nparent.updateImageSource('" + umbraco.GlobalSettings.Path + "/.." + m.getProperty("umbracoFile").Value.ToString() + "', '" + TextBoxTitle.Text + "', " + m.getProperty("umbracoWidth").Value.ToString() + ", " + m.getProperty("umbracoHeight").Value.ToString() + ")\n</script>";
feedback.Text += "<script type=\"text/javascript\">\n parent.refreshTree(); \nparent.updateImageSource('" + umbraco.GlobalSettings.Path + "/.." + m.getProperty("umbracoFile").Value.ToString() + "', '" + TextBoxTitle.Text + "', " + m.getProperty("umbracoWidth").Value.ToString() + ", " + m.getProperty("umbracoHeight").Value.ToString() + ", " + m.Id +")\n</script>";
}
// Put user code to initialize the page here

View File

@@ -0,0 +1 @@
<%@ WebService Language="C#" CodeBehind="MediaPickerService.asmx.cs" Class="umbraco.presentation.webservices.MediaPickerService" %>

View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using umbraco.cms.businesslogic.media;
namespace umbraco.presentation.webservices
{
/// <summary>
/// Summary description for Media
/// </summary>
[WebService(Namespace = "http://umbraco.org/webservices")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[ScriptService]
public class MediaPickerService : System.Web.Services.WebService
{
[WebMethod]
[ScriptMethod]
public string GetThumbNail(int mediaId)
{
return MediaPickerServiceHelpers.GetThumbNail(mediaId);
}
[WebMethod]
[ScriptMethod]
public string GetFile(int mediaId)
{
return MediaPickerServiceHelpers.GetFile(mediaId);
}
}
}

View File

@@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using umbraco.cms.businesslogic.media;
namespace umbraco.presentation.webservices
{
public class MediaPickerServiceHelpers
{
public static string GetThumbNail(int mediaId)
{
string fileName;
string thumbnail = string.Empty;
try
{
Media m = new Media(mediaId);
fileName = m.getProperty("umbracoFile").Value.ToString();
string ext = fileName.Substring(fileName.LastIndexOf('.') + 1, fileName.Length - (fileName.LastIndexOf('.') + 1));
if (",jpeg,jpg,gif,bmp,png,tiff,tif,".IndexOf("," + ext.ToLower() + ",") > -1)
{
thumbnail = fileName.Substring(0, fileName.LastIndexOf('.')) + "_thumb.jpg";
}
else
{
return "";
//switch (ext.ToLower())
//{
// case "pdf":
// thumbnail = "";
// break;
// case "doc":
// thumbnail = "";
// break;
// default:
// thumbnail = "";
// break;
//}
}
}
catch { }
return thumbnail;
}
public static string GetFile(int mediaId)
{
string fileName = string.Empty;
try
{
Media m = new Media(mediaId);
fileName = m.getProperty("umbracoFile").Value.ToString();
}
catch { }
return fileName;
}
}
}