# ================================================================== # Plugins::Days_Old - Auto Generated Install Module # # Plugins::Days_Old # Author : Robert Blackstone and lparry # Version : 1.17 # Updated : Wed Feb 7 20:36:26 2001 # # ================================================================== # package Plugins::Days_Old; # ================================================================== use strict; use GT::Plugins qw/STOP CONTINUE/; use Links qw/$IN $DB $TPL $CFG/; use GT::Date; sub link_Days_Old { # ------------------------------------------------------------------- # You call this tag by placing <%Plugins::Days_Old::link_Days_Old%> at the # top of your link.html or detailed.html template, or wherever you # have "Link" data, and want to use the <%Days_Old%> tag. # my $link = GT::Template->tags; ## load the template tags -- change in Links 2.1 parser Links::init_date(); ## you can either 'use GT::Date' or do it this way, this is probably better GT::Date::date_set_format('%ddd% %mmm% %dd% %yyyy%'); ## this is the key to making it work if (($link->{'isNew'} eq 'Yes') or ($link->{'isNew'} == 1)){ $link->{'Stage_one'} = "I got here"; $link->{'Days_Old'} = GT::Date::date_diff ( GT::Date::date_get(), $link->{'Add_Date'}); if ( ($link->{'Days_Old'} > 14) ) { ## and ($link->{'Days_Old'} <= $CFG->{'build_new_cutoff'}) $link->{'Days_Old'} = 14; } if ($link->{'Days_Old'} > $CFG->{'build_new_cutoff'}) { my $LINK_DB = $DB->table('Links'); $LINK_DB->update ( { isNew => 'No' }, { ID => $link->{'ID'} } ); ($link->{'isNew'} eq 'Yes') && ($link->{'isNew'} = 'No'); ($link->{'isNew'} eq '1') && ($link->{'isNew'} = '0'); $link->{'Days_Old'} = ''; ## might need to delete $link->{'Days_Old'} in some cases. } } else { $link->{'Days_Old'} = ''; ## might need to delete $link->{'Days_Old'} in some cases. } return $link; } sub link { # ------------------------------------------------------------------- # This subroutine will get called whenever the hook 'site_html_link' # is run. You should return STOP if you don't want # the regular code to run, or CONTINUE if you want # the regular code to run. # my $link = shift; # added line to preserve Add_Date from Links table row $link->{Add_Date1} = $link->{Add_Date} ; # Links Days_Old calculate # Figure out how many days old it is if it's a new link. if ($link->{'isNew'} eq 'Yes') { $link->{'Days_Old'} = GT::Date::date_diff ( GT::Date::date_get(), $link->{'Add_Date1'}); } else { $link->{'Days_Old'} = ''; } return $link; } sub subcategory { # ------------------------------------------------------------------- # This subroutine will get called whenever the hook 'site_html_print_cat' # is run. You should return STOP if you don't want # the regular code to run, or CONTINUE if you want # the regular code to run. # my $subcat = shift; my $cat_db = $DB->table('Category'); for (my $x=0;$x[$x]; # Calculate the number of days old. if ($cat_r->{'Has_New_Links'}) { $cat_r->{'Days_Old'} = GT::Date::date_diff (GT::Date::date_get(), $cat_r->{'Newest_Link'}); } else { $cat_r->{'Days_Old'} = ''; } } return $subcat; } # ADMIN MENU OPTIONS # =================================================================== sub about { print $IN->header(); print Links::header ('Days_Old Help Menu', qq|

This plugin allows you to use the <%Days_Old%> Tag in your links templates.


Place this code in your link.html template:

<%if isNew%>
<img src="<%build_root_url%>/images/new_<%Days_Old%>.gif">
<%endif%>


Place this code in your subcategory.html template:

<%if Has_New_Links eq 'Yes'%>
<img src="<%build_root_url%>/images/new_<%Days_Old%>.gif">
<%endif%>
|); } # Always end with a 1. 1;