Skip to content

Instantly share code, notes, and snippets.

@mhulse
Created June 13, 2012 22:50
Show Gist options
  • Save mhulse/2927013 to your computer and use it in GitHub Desktop.
Save mhulse/2927013 to your computer and use it in GitHub Desktop.
Caché DTI ContentPublisher: Tested in 7.6, 7.7.2: RG story text methods...
<csp:comment>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</csp:comment>
<script language="cache" method="storyText" arguments='cmsStory:dt.cms.schema.CMSStory=-1, extractFlag:%String = "none", wordLimit:%String="", charLimit:%String="", sentenceLimit:%String="", paragraphLimit:%String="", ellipsis:%String="TRUE", update:%String=""' returntype="%String" procedureblock="1">
set return = ""
if ($isobject(cmsStory)) {
// Get the text:
if ($zconvert(update, "U") = "TRUE" || (($zconvert(update, "U") '= "FALSE") & (..dboStoryStatus(cmsStory) = 0))) {
set return = ##class(dt.cms.support.Rules).extractStoryElement("WebUpdateText", cmsStory, 0, extractFlag)
} else {
set return = ##class(dt.cms.support.Rules).extractStoryElement("WebText", cmsStory, 0, extractFlag)
if ('$length(return)) {
set return = ##class(dt.cms.support.Rules).extractStoryElement("Text", cmsStory, 0, extractFlag)
}
}
// Manipulate text:
if ($length(return)) {
set:($length(charLimit)) return = ##class(dt.cms.support.Rules).charLimit(return, charLimit)
set:($length(wordLimit)) return = ##class(dt.cms.support.Rules).wordLimit(return, wordLimit)
set:($length(sentenceLimit)) return = ##class(dt.cms.support.Rules).sentenceLimit(return, sentenceLimit)
set:($length(paragraphLimit)) return = ##class(dt.cms.support.Rules).paragraphLimit(return, paragraphLimit)
set:($zconvert(ellipsis, "U") = "TRUE") return = return _ " &#8230;"
// Expand any ##()## in the stream - (required to make the inline ##()## work):
set return = $$resolvePP^%cspQuote(return)
}
}
quit return
</script>
<csp:comment>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</csp:comment>
<script language="cache" method="dboStoryStatus" arguments="cmsStory:dt.cms.schema.CMSStory=-1" returntype="%Integer" procedureblock="1">
/// About: Return 1 if the given story has a status of "web", "ready", or "output".
/// Example call:
/// ##class(csp.web.assets.methods.story).dboStoryStatus()
set return = 0
/*
**
** SQL to check current status list:
** SELECT statusName, statusId FROM dbo.status ORDER BY statusId ASC
**
** "-" = 0
** "Notes" = 1
** "Raw" = 2
** "In Progress" = 3
** "Story Completed = 4
** "First Edit" = 5
** "Rimmed" = 9
** "Ready" = 10
** "Output" = 1018
** "Web" = 1019
** "Archive" = 118709
** "Hold" = 632458
**
*/
if ($isobject(cmsStory) && $isobject(cmsStory.story)) {
set statusId = 0
; DBO.story Status Id:
set statusId = cmsStory.story.statusId
; Check if statusId is "ready", "web", or "output":
set:((statusId = 10) || (statusId = 1018) || (statusId = 1019)) return = 1
}
quit return
</script>
<csp:comment>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</csp:comment>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment