package WebGUI::Macro::LastModified; #------------------------------------------------------------------- # WebGUI is Copyright 2001-2003 Plain Black LLC. #------------------------------------------------------------------- # Please read the legal notices (docs/legal.txt) and the license # (docs/license.txt) that came with this distribution before using # this software. #------------------------------------------------------------------- # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- # LastModified macro was contributed by Ed Van Duinen (edv@unc.edu) # Version 1.1 -- WebGUI 5.2.x support #------------------------------------------------------------------- # #NAME # LastModified - Display last modified date of a page's wobjects # #SYNOPSIS # ^LastModified; # ^LastModified(LABEL); # ^LastModified(LABEL, DATEFORMAT); # #DESCRIPTION # The LastModified macro outputs the most recent edit date for # the wobjects of a page. If a page has no wobjects, no output # will be produced. In addition, certain wobjects (e.g., USS) # will result in a last modified date reflecting the last time # the wobject definition was edited and not the last date content # was submitted. # # Called with no parameters, LastModified outputs the date in the # user's preferred date format set in their WebGUI profile (i.e., # %z). LastModified may also be called with a single parameter # which is a text string prefix for the date (see LABEL under # OPTIONS). Finally, LastModified may be called with both the # LABEL parameter and also a date format string (see DATEFORMAT # under OPTIONS). # #OPTIONS # LABEL - an optional text string which precedes the date value. # This parameter is not outputted in cases where there is # no date. # # DATEFORMAT - an optional date format string. This parameter # uses the same syntax as the Date macro (^D;). You must # provide the LABEL parameter if you wish to provide the # DATEFORMAT parameter. # #EXAMPLES # ^LastModified; # ==> 2/6/2003 # # ^LastModified("Updated: "); # ==> Updated: 2/6/2003 # # ^LastModified("Last Modified: ","%c %D, %y"); # ==> Last Modified: February 6, 2003 # #INSTALLATION # Place LastModified.pm in your /lib/WebGUI/Macro # directory, add "LastModified => LastModified, \" to the # macro section of the /etc/WebGUI.conf file, # and restart your webserver. # #AUTHORS # LastModified was contributed by Ed Van Duinen for # the WebGUI Content Management system (http://www.plainblack.com) # #SEE ALSO # ^D; (the Date macro) # #------------------------------------------------------------------- use strict; use WebGUI::DateTime; use WebGUI::Macro; use WebGUI::Session; use WebGUI::SQL; #------------------------------------------------------------------- sub process { my ($label, $format, $time, $output); ($label, $format) = WebGUI::Macro::getParams(shift); $format = '%z' if ($format eq ""); $output = ""; ($time) = WebGUI::SQL->quickArray("SELECT max(lastEdited) FROM wobject where pageId=$session{page}{pageId}"); if ($time) { $output = $label.epochToHuman($time,$format); } return $output; } 1;