Created
May 5, 2011 19:10
-
-
Save mhulse/957685 to your computer and use it in GitHub Desktop.
DTI's Content Publisher CMS: Just experimenting with some code that gets all SWFs attached to a story.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<csp:comment>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</csp:comment> | |
<script language="cache" method="getSwf" arguments='cmsStory:dt.cms.schema.CMSStory=-1' returntype="%ArrayOfDataTypes" procedureblock="1"> | |
set sc = $$$OK | |
set return = ##class(%ArrayOfDataTypes).%New() | |
set storyId = cmsStory.story.storyId | |
set currentNS = $znspace | |
znspace ##class(dt.common.NamespaceProcs).GetNewsMediaName() | |
try { | |
w storyId | |
set sql = | |
"SELECT hr1.nativeFile, hr1.nativeFileTypeId, hr1.processedFile, hr1.processedFileTypeId, ft.filetypeid " _ | |
"FROM dbo.ForeignDbLink fdbl, dbo.FileType ft, dbo.HighRes1 hr1 " _ | |
"WHERE fdbl.foreignId = ? " _ | |
"AND fdbl.foreignidfield = 'story.storyId' " _ | |
"AND hr1.fileheaderid = fdbl.fileheaderId " _ | |
"AND (" _ | |
"hr1.nativeFileTypeId = ft.filetypeid OR hr1.processedFileTypeId = ft.filetypeid" _ | |
") " _ | |
"AND ft.extension = '.SWF'" | |
set rs = ##class(%ResultSet).%New("%DynamicQuery:SQL") | |
set sc = rs.Prepare(sql) | |
if ($$$ISOK(sc)) { | |
set sc = rs.Execute(storyId) | |
if ($$$ISOK(sc)) { | |
set counter = 0 | |
while (rs.%Next()) { | |
set counter = counter + 1 | |
set nativeFile = rs.%GetData(1) | |
set nativeFileTypeId = rs.%GetData(2) | |
set processedFile = rs.%GetData(3) | |
set processedFileTypeId = rs.%GetData(4) | |
set fileTypeId = rs.%GetData(5) | |
if (((processedFile '= 0) && (processedFileTypeId = fileTypeId)) || ((nativeFile '= 0) && (nativeFileTypeId = fileTypeId))) { | |
; Q: What is the difference between "processed" and "native" files? | |
; | |
; A: The native file is just that, the original native file. The processed file is a processed version of the file. | |
; Your code should use the processed file if it exists, as it will be the latest, and fall back to using the native | |
; file if the processed file doesn't exist. The native file should always exist (as long as everything was uploaded | |
; correctly), but the processed file will only be there if the image/media was updated. | |
; -- Scott Binns (thanks Scott!!!!) | |
if ((processedFile '= 0) && (processedFileTypeId = fileTypeId)) { | |
do return.SetAt(processedFile, counter) | |
} else { | |
do return.SetAt(nativeFile, counter) | |
} | |
} | |
} | |
} | |
} | |
znspace currentNS | |
} catch(e) { | |
if ($znspace '= currentNS) { | |
znspace currentNS | |
} | |
} | |
quit return | |
</script> | |
<csp:comment>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</csp:comment> | |
<script language="cache" method="goob" arguments='filename:%String=""' returntype="%String" procedureblock="1"> | |
set return = "" | |
if ($length(filename)) { | |
; Inspired by: ##class(dt.cms.support.Rules).GetStorySWF() | |
set currentNS = $znspace | |
set adNS = ##class(dt.common.NamespaceProcs).GetAdsName() | |
set width = 0 | |
set height = 0 | |
try { | |
znspace adNS | |
do ##class(dt.ad.core.components.DTGraphicLoaderComposite).IdentifySWF(filename, .height, .width) | |
w width | |
w height | |
znspace currentNS | |
} catch(e) { | |
if ($znspace '= currentNS) { | |
zn currentNS | |
} | |
} | |
} | |
quit return | |
</script> | |
<csp:comment>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</csp:comment> | |
<csp:object name="gPublication" classname="dt.cms.schema.Publication" objid="7"> | |
<csp:object name="gStory" classname="dt.cms.schema.CMSStory" objid="26203863"> | |
<script language="cache" runat="server"> | |
new embed, file | |
set embed = ##class(dt.cms.support.Rules).GetStorySWF(gStory, "", "", gPublication.name, .sc, 0) | |
set file = ##class(csp.web.assets.methods.string).nab(embed, "data=""", """") | |
</script> | |
<pre>#(..EscapeHTML(embed))#</pre> | |
<hr> | |
#(file)# | |
<hr> | |
#(##class(csp.web.assets.methods.string).nab(embed, "width=""", """"))#, #(##class(csp.web.assets.methods.string).nab(embed, "height=""", """"))# | |
<hr> | |
#(..goob(file))# | |
<hr> | |
#[ new swfs set swfs = ..getSwf(gStory) ]# | |
#(swfs.Count())# | |
<hr> | |
<csp:loop counter="i" from="1" to="#(swfs.Count())#"> | |
#(..goob(swfs.GetAt(i)))# | |
<hr> | |
</csp:loop> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: The "nab" CSP method can be found here.