Skip to content

Instantly share code, notes, and snippets.

@snipe
snipe / rss_img_ripper.php
Last active July 28, 2023 14:00
Quick and dirty script to download thumbnail and fullsize images from RSS feed. The RSS feed can be remote, but this was a one-off I needed to throw together, so I just downloaded the RSS feed to my local drive.
<?php
$feed = 'recent.rss';
$xml = new SimpleXMLElement(file_get_contents($feed));
$xml->registerXPathNamespace('media', $feed);
$images = $xml->xpath('/rss/channel/item/media:content/@url');
foreach ( $xml->channel->item as $item ) {
$namespaces = $item->getNameSpaces(true);
$media = $item->children($namespaces['media']);
@mhulse
mhulse / DTI get fullLayout name.csp
Created January 30, 2013 21:11
One way to get selcected summary layout name name using Caché 2009.1 and DTI's Lightning 7.7.3.
#[ new linesonly set linesonly = "" ]#
<csp:if condition='$get(%request.Data("psid", 1))'>
#[ set linesonly = $zconvert(##class(dt.cms.support.Utilities).getSummaryLayout(gSection, ##class(dt.cms.support.Rules).getSlot(gMapping, gSection, 0), gMapping).name, "L") ]#
<csp:else>
#[ set linesonly = $zconvert(##class(dt.cms.support.Utilities).getSummaryLayout(gSection, gSlot, gMapping).name, "L") ]#
@mhulse
mhulse / story.csp
Created November 21, 2012 04:49
Caché DTI ContentPublisher v7.7.3: Handling a "WebEmbed" field from InCopy...
<dti:file:include base="assets" file="/includes/webembed.csp" />
@mhulse
mhulse / picinfo.csp
Created October 31, 2012 18:28
Caché DTI ContentPublisher v7.7.3: COS to get a story's attached pictures and their priority...
<csp:comment>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</csp:comment>
<script language="cache" method="picinfo" arguments='fhid:%Integer=-1, item:%String=""' returntype="%String" procedureblock="1">
/// My half-baked attempt at an easy way to get an image's meta data.
/// @TODO: Make more robust; allow for multiple values to be retunred; return the fileheader as an object?
//----------------------------------
// Initialize:
//----------------------------------
@mhulse
mhulse / DateTime.csp
Created October 18, 2012 18:52
Caché DTI ContentPublisher: v7.7.3; CSP method: ODBC timestamp to W3C date for use with HTML5 <time> tag & RG publish date logic...
<csp:comment>
/// Converts an ODBC timestamp to W3C date for use with HTML5 <time> tag.
///
/// @param ODBC formatted timestamp. Example: 2010-10-25 01:08:21.512. Required.
/// @see http://bit.ly/fj8ZI1
/// @see http://rgne.ws/QuTBrv
/// @see http://rgne.ws/S6kSSE
/// @see http://rgne.ws/Rh67IW
/// @return Valid rfc3339 formatted date. Example: YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00).
</csp:comment>
@mhulse
mhulse / Setups.csp
Created September 21, 2012 18:42
Caché DTI ContentPublisher: v7.7.3; Getting summary template group name to determine which photo version to use.
<csp:comment>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</csp:comment>
<script language="cache" method="summary" arguments='psid:%String, section:dt.cms.schema.Section, mapping:dt.cms.schema.Mapping, slot:dt.cms.schema.Slot' returntype="dt.cms.schema.LayoutSummary" procedureblock="1">
set return = ""
if ($isobject(section) && $isobject(mapping)) {
if ($length(psid)) {
@mhulse
mhulse / Category.csp
Created September 4, 2012 23:53
Caché DTI ContentPublisher: Tested in 7.6, 7.7.X: Get category/subcategory name...
<csp:comment>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</csp:comment>
<csp:comment>
/// @param: Category/subcategory id. Required.
/// @return: Category/subcategory name.
</csp:comment>
<script language="cache" method="catName" arguments='id:%String=""' returntype="%String" procedureblock="1">
//----------------------------------
@mhulse
mhulse / 1-validate.csp
Created August 2, 2012 20:33
Caché DTI ContentPublisher: Tested in 7.6, 7.7.2: Experimental date validation...
<script language="cache" runat="server">
//--------------------------------------------------------------------------
//
// Snakes. Why did it have to be snakes?
//
//--------------------------------------------------------------------------
/**
* Validate date.
@mhulse
mhulse / config.inc.csp
Created June 16, 2012 10:07
Caché DTI ContentPublisher: Tested in 7.6, 7.7.2: RG Skybox Example...
<script language="cache" runat="server">
/*
**
** GETs:
**
*/
set conf("section") = $get(%request.Data("s", 1)) // The current section.
set conf("parent") = $get(%request.Data("p", 1)) // The current section's parent.
@mhulse
mhulse / headlines.csp
Created June 13, 2012 23:00
Caché DTI ContentPublisher: Tested in 7.6, 7.7.2: RG story headline methods...
<csp:comment>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</csp:comment>
<csp:comment>
Get story headline.
Call: ##class(csp.web.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">