1 # Copyright 2003-2009 Interchange Development Group and others
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version. See the LICENSE file for details.
10 UserTag css Version $Revision: 1.9 $
11 UserTag css Routine <<EOR
13 my ($name, $opt) = @_;
22 my $dir = $opt->{output_dir} ||= 'images';
26 if (! $opt->{no_imagedir} ) {
27 $id = $opt->{imagedir} || $Vend::Cfg->{ImageDir};
33 if($opt->{relative}) {
34 my @dirs = split m{/}, $Global::Variable->{MV_PAGE};
37 $id .= join "/", @dirs, '';
38 $dir = join "/", $dir, @dirs;
43 if($opt->{basefile}) {
44 $sourcetime = (stat($opt->{basefile}))[9];
45 #::logDebug("basefile=$opt->{basefile} sourcetime=$sourcetime");
60 if($opt->{basefile}) {
61 if($sourcetime > $stat[9]) {
62 #::logDebug("Found a basefile, out of date at modtime=$stat[9]");
66 #::logDebug("Found a basefile, in date at modtime=$stat[9]");
70 elsif($opt->{timed}) {
72 $opt->{timed} .= ' min' if $opt->{timed} =~ /^\d+$/;
73 my $fliptime = adjust_time($opt->{timed}, $stat[9]);
74 #::logDebug("fliptime=$fliptime now=$now");
75 if ($fliptime <= $now) {
93 $extra .= qq{ media="$opt->{media}"} if $opt->{media};
96 $css = length($opt->{literal})
98 : interpolate_html($Tag->var($name));
99 $css =~ s/^\s*<style.*?>\s*//si;
100 $css =~ s:\s*</style>\s*$:\n:i;
103 last WRITE unless $write;
106 logError("CSS file %s has no write permission.", $fn);
110 logError("CSS dir %s has no write permission.", $dir);
113 logError("CSS dir %s does not exist.", $dir);
118 my $mode = $opt->{mode} ? oct($opt->{mode}) : 0644;
119 $success = $Tag->write_relative_file($fn, $css) && chmod($mode, $fn)
120 or logError("Error writing CSS file %s, returning in page", $fn);
123 return qq{<link rel="stylesheet" href="$url"$extra>} if $success;
124 return qq{<style type="text/css">\n$css</style>};