Skip to content

Instantly share code, notes, and snippets.

@mhulse
Created September 18, 2014 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhulse/59ede19115960ee5a716 to your computer and use it in GitHub Desktop.
Save mhulse/59ede19115960ee5a716 to your computer and use it in GitHub Desktop.
Caché 2009.1 - NEWSCYCLE Solutions: DTI Lighting 7.7.x: Get headline CSP methods.
<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 "ready", "output", "web" or "archive".
/// Example call:
/// ##class(csp.rg.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", "output" or "archive":
set:((statusId = 10) || (statusId = 1018) || (statusId = 1019) || (statusId = 118709)) return = 1 // Could also do: statusId >= 10
}
quit return
</script>
<csp:comment>
Get story headline.
Call: ##class(csp.rg.assets.methods.story).headline()
Dependencies: 1) ..dboStoryStatus(), 2) ##class(dt.cms.support.Rules).extractStoryElement
</csp:comment>
<script language="cache" method="headline" arguments='cmsStory:dt.cms.schema.CMSStory=-1, update:%String=""' returntype="%String" procedureblock="1">
/// This method will return a headline based on The Register-Guard order of precedence:
/// 1) "WebHeadline"
/// 2) "Headline"
/// 3) "Deck"
/// 4) "QuickRead"
/// 5) "Header"
/// 6) "StorySig"
/// 7) "Kicker"
/// 8) "FurnitureText"
/// 9) Story slug (Default return value)
/// Arguments:
/// @param01: A valid CMSStory object.
/// @param02: If set to "true", only the WebUpdateHeadline will be returned.
set return = ""
if ($isobject(cmsStory)) {
; If "update" = "true" OR if the story status is NOT "ready", "web", "output" or "archive", show the WebUpdateHeadline:
if (($zconvert(update, "U") = "TRUE") || (($zconvert(update, "U") '= "FALSE") & (..dboStoryStatus(cmsStory) = 0))) {
set return = ##class(dt.cms.support.Rules).extractStoryElement("WebUpdateHeadline", cmsStory, 0, "textonly")
} else {
; Trying to avoid spaghetti code here... Almost to a fault. :(
set return = ##class(dt.cms.support.Rules).extractStoryElement("WebHeadline", cmsStory, 0, "textonly")
if ('$length(return)) {
set return = ##class(dt.cms.support.Rules).extractStoryElement("Headline", cmsStory, 0, "textonly")
if ('$length(return)) {
set return = ##class(dt.cms.support.Rules).extractStoryElement("Deck", cmsStory, 0, "textonly")
if ('$length(return)) {
set return = ##class(dt.cms.support.Rules).extractStoryElement("QuickRead", cmsStory, 0, "textonly")
if ('$length(return)) {
set return = ##class(dt.cms.support.Rules).extractStoryElement("Header", cmsStory, 0, "textonly")
if ('$length(return)) {
set return = ##class(dt.cms.support.Rules).extractStoryElement("StorySig", cmsStory, 0, "textonly")
if ('$length(return)) {
set return = ##class(dt.cms.support.Rules).extractStoryElement("Kicker", cmsStory, 0, "textonly")
if ('$length(return)) {
set return = ##class(dt.cms.support.Rules).extractStoryElement("StoryLabel", cmsStory, 0, "textonly")
if ('$length(return)) {
set return = ##class(dt.cms.support.Rules).extractStoryElement("FurnitureText", cmsStory, 0, "textonly")
if ('$length(return)) {
set return = cmsStory.story.storyName // Return slug if all else fails.
}
}
}
}
}
}
}
}
}
}
}
quit return
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment