|
|
Rank: Fanatic
Joined: 3/15/2007 Posts: 293 Location: Cary, NC USA
|
Doug - I'll probably need to clean up the code just a tad and seperate some of the external library functions but I'll see what I can come up with. Will keep you posted...
|
|
Rank: Aficionado
Joined: 7/21/2006 Posts: 154 Location: Italy
|
Good Work...Is it possible to upload other data types ( tiff, zip, ecc ... )?
Red Consulting s.a.s - Umbraco from v1.0
|
|
Rank: Fanatic
Joined: 3/15/2007 Posts: 293 Location: Cary, NC USA
|
I'm currently cleaning up the code a bit and adding some more functionality (allowed file exts, max size limits, ability to rename files, etc) after I have it tweaked for the video data type, I'll create a non-video variant which will encapsulate most of the same functionality (the ftp functions have been rolled into their own class for ease of use/re-use) - it will just be a different type though (i.e. something like a generic ftpType vs ftpVideoType).
|
|
Rank: Aficionado
Joined: 7/21/2006 Posts: 154 Location: Italy
|
Red Consulting s.a.s - Umbraco from v1.0
|
|
Rank: Fanatic
Joined: 3/15/2007 Posts: 293 Location: Cary, NC USA
|
OK, here's where this is at... I've added some more tweaks (rename, max file size, allowed file types, dis-allowed file types, etc)... I wanted to keep the functions basic as to not create a full-blown ftp manager functionality (i.e. make dirs, dir listings, etc)...  I've also added the ability to upload/manage non-video files in similiar fashion (runs off it's own rules and config settings):  Cleaned up the document types/media types names (more conventional):   And seperated the config options:  Still need to do some more cleanup and create macros for rendering the non-video media values into urls, links, etc but making some progress... Let me know about any additional features you would like to see...
|
|
Rank: Fanatic
Joined: 3/15/2007 Posts: 293 Location: Cary, NC USA
|
OK, I made a few more tweaks, added some more external xslt library functions to generate urls and created a couple sample macros using the xslt logic (get url, get img ref, get href)... still going to do a little more tweaking and cleanup and then package everything up and send to Doug and the package repository team but it should be getting close... external xslt functions:  xslt editor (get file href logic):  uploading pdf file:  adding macro to content page:  sample macro popups:    setting macro properties:  rending on page:  clicking on generated href link:
|
|
Rank: Aficionado
Joined: 7/21/2006 Posts: 154 Location: Italy
|
When will be in our hands ?
Red Consulting s.a.s - Umbraco from v1.0
|
|
Rank: Fanatic
Joined: 3/15/2007 Posts: 293 Location: Cary, NC USA
|
I think I have an initial version ready to go except for packing it up. I'm no expert on packaging although I've can manually create a basic package setup and I also have Per's package Creator but I'm not aware of a way to configure the xslt extension automatically and also include and configure Data Types (under Developer tab) in the package .xml file. Any ideas or help would be greatly appreciated. Many thanks in advance.
|
|
 Rank: Umbracoholic
Joined: 9/8/2006 Posts: 1,068 Location: KY, USA
|
The package format doesn't support every feature in umbraco (maybe someday :)). For now, you'd want to use the package format to do everything you can, then create an "installer" aspx file and tell the packager to call that file when everything else has been completed. The installer would do the update to the xslt extension file, for instance. cheers, doug.
MVP 2007/2008 - Official Umbraco Trainer for North America - Percipient Studios
|
|
Rank: Fanatic
Joined: 3/15/2007 Posts: 293 Location: Cary, NC USA
|
Doug - good info to know... would you happen to have a sample installer file that does this or something similiar? I'm looking through some packages that I have on my local system to see if I can find anything but have yet been able to find anything thus far. thx!
|
|
 Rank: Umbracoholic
Joined: 9/8/2006 Posts: 1,068 Location: KY, USA
|
Take a look at the logviewer package, as well as Per's packager package. They both have "installers" that are called as the last step. Also, the ebita dashboard ( http://forum.umbraco.org/yaf_postst2338_Umbraco-dashboard.aspx) has an installer. You should be able to get the idea from them. Really, you can call whatever you want as the last step, with or without some UI representation for the user. cheers, doug.
MVP 2007/2008 - Official Umbraco Trainer for North America - Percipient Studios
|
|
Rank: Fanatic
Joined: 3/15/2007 Posts: 293 Location: Cary, NC USA
|
|
|
Rank: Fanatic
Joined: 3/15/2007 Posts: 293 Location: Cary, NC USA
|
|
|
 Rank: Fanatic
Joined: 10/9/2006 Posts: 316
|
oh man, this one looks awesome! can't wait to see the finished product... keep up the great work!
bootnumlock - aka bob baty-barr [ http://www.baty-barr.com]
|
|
Rank: Aficionado
Joined: 7/21/2006 Posts: 154 Location: Italy
|
I'm, too.
Red Consulting s.a.s - Umbraco from v1.0
|
|
Rank: Aficionado
Joined: 7/21/2006 Posts: 154 Location: Italy
|
|
|
Rank: Fanatic
Joined: 3/15/2007 Posts: 293 Location: Cary, NC USA
|
OK, just got the initial package and installer working. I'll go ahead and post the code below in case it helps out others or for reference. It's very similiar to some of the logic in the above url's I posted w/ some tweaks, customizations and mods... I'll also send Doug the umb package so he and the package repository team can take a look at it... Code:
using System; using System.Data; using System.Data.SqlClient; using System.Configuration; using System.Collections; using System.Xml; 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 Microsoft.ApplicationBlocks.Data; using umbraco; using umbraco.BusinessLogic; using umbraco.cms.businesslogic.datatype; using umbraco.cms.businesslogic.datatype.controls; using umbraco.cms.businesslogic.web; using umbraco.interfaces;
namespace FtpMedia { public partial class Installer : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { try { //create user instance User u = new User(0);
//create datatypes DataTypeDefinition dtdMediaFile = null; DataTypeDefinition dtdMediaVideo = null;
//iterate data type definitions foreach (DataTypeDefinition dt in DataTypeDefinition.GetAll()) { //check if media file if (dt.Text == "FTP Media File") dtdMediaFile = dt;
//check if video file if (dt.Text == "FTP Media Video") dtdMediaVideo = dt; }
//create new media file data type if (dtdMediaFile == null) { dtdMediaFile = DataTypeDefinition.MakeNew(u, "FTP Media File"); dtdMediaFile.DataType = new Factory().DataType(new Guid("d15e1281-e456-4b24-aa86-1dda3e4299d5")); // The guid of the data type definition (umbraco usercontrol wrapper) updateDbType(dtdMediaFile.Id, "Nvarchar"); }
//create new media video data type if (dtdMediaVideo == null) { dtdMediaVideo = DataTypeDefinition.MakeNew(u, "FTP Media Video"); dtdMediaVideo.DataType = new Factory().DataType(new Guid("d15e1281-e456-4b24-aa86-1dda3e4299d5")); // The guid of the data type definition (umbraco usercontrol wrapper) updateDbType(dtdMediaVideo.Id, "Nvarchar"); }
// add control path pre-values addPreValue(dtdMediaFile.Id, "/usercontrols/FtpMedia/FtpMedia_FileUpload.ascx"); addPreValue(dtdMediaVideo.Id, "/usercontrols/FtpMedia/FtpMedia_VideoUpload.ascx");
//get media types umbraco.cms.businesslogic.media.MediaType ftpFile = null; umbraco.cms.businesslogic.media.MediaType ftpVideo = null;
//iterate media type definitions foreach (umbraco.cms.businesslogic.media.MediaType mt in umbraco.cms.businesslogic.media.MediaType.GetAll) { //check if media file if (mt.Text == "FTPFile") ftpFile = mt;
//check if video file if (mt.Text == "FTPVideo") ftpVideo = mt; }
//create tab id holders int ftpFileTabId = 0; int ftpVideoTabId = 0;
//if not exists if (ftpFile == null) { //create new media type ftpFile = umbraco.cms.businesslogic.media.MediaType.MakeNew(u, "FTP File");
//create new media tab ftpFileTabId = ftpFile.AddVirtualTab("File"); } else //try to get existing tab id ftpFileTabId = getMediaTabId("File", ftpFile);
//set media file type properties ftpFile.AddPropertyType(new DataTypeDefinition(dtdMediaFile.Id), "FTPFile", "FTP File"); ftpFile.SetTabOnPropertyType(ftpFile.getPropertyType("FTPFile"), ftpFileTabId); updateContentImageType(ftpFile.Id, "mediaMulti.gif");
//if not exists if (ftpVideo == null) { //create new media type ftpVideo = umbraco.cms.businesslogic.media.MediaType.MakeNew(u, "FTP Video");
//create new media tab ftpVideoTabId = ftpVideo.AddVirtualTab("Video"); } else //try to get existing tab id ftpVideoTabId = getMediaTabId("Video", ftpVideo);
//set media video type properties ftpVideo.AddPropertyType(new DataTypeDefinition(dtdMediaVideo.Id), "FTPVideo", "FTP Video"); ftpVideo.SetTabOnPropertyType(ftpVideo.getPropertyType("FTPVideo"), ftpVideoTabId); updateContentImageType(ftpVideo.Id, "mediaMulti.gif");
//update xslt extensions config setting updateXsltExtensions();
//display success message and config example to user lblMessage.Text = "<p>Congratulations! The FTP Media package has successfully installed!</p>"; litConfig.Visible = true; } catch (System.Exception err) { //display error message and hide config example to user lblMessage.Text = "<p>The following error has occured:<br/><br/>" + err.Message + "</p>"; litConfig.Visible = false; } }
private void addPreValue(int dataTypeId, string Text) { //add prevalue to db SqlHelper.ExecuteNonQuery( GlobalSettings.DbDSN, CommandType.Text, "insert into cmsDataTypePrevalues (datatypenodeid,[value],sortorder,alias) values (@dtdefid,@value,0,'')", new SqlParameter("@dtdefid", dataTypeId), new SqlParameter("@value", Text)); }
private int getPreValueId(int dataTypeId, string Text) { //get prevalue from db return int.Parse( SqlHelper.ExecuteScalar( GlobalSettings.DbDSN, CommandType.Text, "select id from cmsDataTypePrevalues where datatypenodeid = @dtdefid and [value] = @value", new SqlParameter("@dtdefid", dataTypeId), new SqlParameter("@value", Text)).ToString()); }
private int updateDbType(int dataTypeId, string dbType) { //update db type value return int.Parse( SqlHelper.ExecuteNonQuery(GlobalSettings.DbDSN, CommandType.Text, "update cmsDataType set dbType = '" + dbType + "' where nodeId = @datadefinitionid", new SqlParameter("@datadefinitionid", dataTypeId)).ToString()); }
private int updateContentImageType(int dataTypeId, string imageType) { //update db type value return int.Parse( SqlHelper.ExecuteNonQuery(GlobalSettings.DbDSN, CommandType.Text, "update cmsContentType set icon = '" + imageType + "' where nodeId = @datadefinitionid", new SqlParameter("@datadefinitionid", dataTypeId)).ToString()); }
private int getContentTabId(string caption, umbraco.cms.businesslogic.ContentType ContentType) { //iterate content types foreach (umbraco.cms.businesslogic.ContentType.TabI t in ContentType.getVirtualTabs) { //if match, return id if (t.Caption.ToLower() == caption) return t.Id; } return 0; }
private int getMediaTabId(string caption, umbraco.cms.businesslogic.media.MediaType MediaType) { //iterate media types foreach (umbraco.cms.businesslogic.media.MediaType.TabI t in MediaType.getVirtualTabs) { //if match, return id if (t.Caption.ToLower() == caption) return t.Id; } return 0; }
private void updateXsltExtensions() { //create new xml doc object XmlDocument document = new XmlDocument();
//load config file values document.Load(Server.MapPath("/config/") + "xsltExtensions.config");
//get root node XmlNode node = document.SelectSingleNode("/XsltExtensions");
//create new element XmlNode newChild = document.CreateElement("ext");
//add element assembly attribute XmlAttribute AtAssembly = document.CreateAttribute("assembly"); AtAssembly.Value = "/bin/FtpMedia"; newChild.Attributes.Append(AtAssembly);
//add element assembly type attribute XmlAttribute atType = document.CreateAttribute("type"); atType.Value = "FtpMedia.XsltHelper"; newChild.Attributes.Append(atType);
//add element assembly alias attribute XmlAttribute atAlias = document.CreateAttribute("alias"); atAlias.Value = "XsltHelper"; newChild.Attributes.Append(atAlias);
//add child element node.AppendChild(newChild);
//save changes document.Save(Server.MapPath("/config/") + "xsltExtensions.config"); } } }
|
|
|
Guest |