Wizard.pm 0000644 0000764 0000764 00000002555 10406653327 012251 0 ustar 00tandat tandat # ================================================================== # Auto Generated Plugin Configuration - Needed for Web Based Creator. # # Plugins::DescSpans # Author : Dat Truong Tan # Version : 1 # Updated : Sat Mar 18 08:24:52 2006 # # ================================================================== # package Plugins::DescSpans; # ================================================================== use strict; use vars qw/$WIZARD/; $WIZARD = { 'files' => [], 'hooks' => [ [ 'site_html_detailed', 'PRE', 'Plugins::DescSpans::create_desc_spans', undef ] ], 'install' => '', 'install_code' => '', 'menu' => [ [ 'About', 'admin.cgi?do=plugin&plugin=DescSpans&func=showabout' ] ], 'meta' => { 'author' => 'Dat Truong Tan', 'description' => 'Allow detailed pages have spans if its Description is too long.', 'license' => 'Commercial', 'prog_ver' => '3.0.4', 'url' => 'http://cgito.net', 'version' => '1' }, 'name' => 'DescSpans', 'uninstall' => '', 'uninstall_code' => '', 'user' => [ [ 'Len_Perl_Page', '1000', 'Specify the lenth of text per page', 'TEXT', [], [] ] ] }; 1; Install.pm 0000644 0000764 0000764 00000006506 10406660544 012416 0 ustar 00tandat tandat # ================================================================== # Plugins::DescSpans - Auto Generated Install Module # # Plugins::DescSpans # Author : Dat Truong Tan # Version : 1 # Updated : Sat Mar 18 08:24:52 2006 # # ================================================================== # package Plugins::DescSpans; # ================================================================== use strict; use vars qw/$VERSION $DEBUG $NAME $META/; use GT::Base; use GT::Plugins qw/STOP CONTINUE/; use Links qw/:objects/; $VERSION = '1'; $DEBUG = 0; $NAME = 'DescSpans'; # Inhert from base class for debug and error methods @Plugins::DescSpans::ISA = qw(GT::Base); $META = { 'author' => 'Dat Truong Tan', 'description' => 'Allow detailed pages have spans if its Description is too long.', 'license' => 'Commercial', 'prog_ver' => '3.0.4', 'url' => 'http://cgito.net', 'version' => '1' }; sub pre_install { # ----------------------------------------------------------------------------- # This function displays an HTML formatted message that will display any # instructions/information to the user before they install the plugin. # my $inst_msg = ''; return $inst_msg; } sub pre_uninstall { # ----------------------------------------------------------------------------- # This function displays an HTML formatted message that will display any # instructions/information to the user before they remove the plugin. # my $uninst_msg = ''; return $uninst_msg; } sub install { # ----------------------------------------------------------------------------- # This function does the actual installation. Its first argument is a plugin # manager which you can use to register hooks, install files, add menu options, # etc. The second argument is a GT::Tar object which you can use to access any # files in your plugin module. # # You should return an HTML formatted string that will be displayed to the # user. # # If there is an error, return undef, and set the error message in # $Plugins::DescSpans::error # my ($mgr, $tar) = @_; $mgr->install_hooks('DescSpans', [['site_html_detailed', 'PRE', 'Plugins::DescSpans::create_desc_spans', '']]); $mgr->install_menu('DescSpans', [['About', 'admin.cgi?do=plugin&plugin=DescSpans&func=showabout']]); $mgr->install_options('DescSpans', [['Len_Perl_Page', '1000', 'Specify the lenth of text per page', 'TEXT', [], [], '']]); ; return "The plugin has been successfully installed!"; } sub uninstall { # ----------------------------------------------------------------------------- # This function removes the plugin. Its first argument is also a plugin # manager which you can use to register hooks, install files, add menu options, # etc. You should return an HTML formatted string that will be displayed to the # user. # # If there is an error, return undef, and set the error message in # $Plugins::DescSpans::error # my $mgr = shift; $mgr->uninstall_hooks('DescSpans', [['site_html_detailed', 'PRE', 'Plugins::DescSpans::create_desc_spans', '']]); $mgr->uninstall_menu('DescSpans', [['About', 'admin.cgi?do=plugin&plugin=DescSpans&func=showabout']]); $mgr->uninstall_options('DescSpans', [['Len_Perl_Page', '1000', 'Specify the lenth of text per page', 'TEXT', [], [], '']]); ; return "The plugin has been successfully removed!"; } 1; DescSpans.pm 0000644 0000764 0000764 00000006413 10406660544 012670 0 ustar 00tandat tandat # ================================================================== # Plugins::DescSpans - Auto Generated Program Module # # Plugins::DescSpans # Author : Dat Truong Tan # Version : 1 # Updated : Sat Mar 18 08:24:52 2006 # # ================================================================== # package Plugins::DescSpans; # ================================================================== use strict; use GT::Base; use GT::Plugins qw/STOP CONTINUE/; use Links qw/:objects/; # Inherit from base class for debug and error methods @Plugins::DescSpans::ISA = qw(GT::Base); # Your code begins here. # PLUGIN HOOKS # =================================================================== sub create_desc_spans { # ----------------------------------------------------------------------------- # This subroutine will be called whenever the hook 'site_html_detailed' is run. You # should call $PLG->action(STOP) if you don't want the regular # 'site_html_detailed' code to run, otherwise the code will continue as normal. # my ($args) = @_; my ($id,$text,$nh,$len); my $curl = $IN->unescape($IN->url); if($curl=~ /html#(\d*?)\D|$/){ $nh = $1; # open(LH,">>$CFG->{admin_root_path}/tmp/desc.log"); # print LH "$nh\n"; # close(LH); } # $nh = $IN->param('nh'); # print $IN->header;print "nh=",$nh;exit; $nh = 1 unless($nh); $text = $args->{Description}; $id = $args->{ID}; $len = Links::Plugins->get_plugin_user_cfg('DescSpans')->{Len_Perl_Page}; my $full_len = length($text); return {span_desc => $text,} if($full_len <= $len); my $count = $full_len/$len; $count++ if($count> int($count)); $args->{Description} = substr($text,($nh-1)*$len,$len); my $url = $CFG->{build_root_url} . "/"; my $detailed = $DB->table('Links')->detailed_url($id); $url = "$CFG->{build_detail_url}/$detailed"; my $span = ""; for(my $i=1;$i<=$count;$i++){ $span .= qq|| if($i ne $nh); $span .= $i ; $span .= qq|| if ($i ne $nh); $span .= ' '; } ##return {span_desc => $text, span_desc_pages => $span, curl => $curl, span_desc_nh => $nh}; $args->{Description_spans} = $span; return $args; } # ADMIN MENU OPTIONS # =================================================================== sub showabout { # ------------------------------------------------------------------- # This subroutine will be called whenever the user clicks on 'About' in the # admin menu. Remember, you need to print your own HTTP header; to do so you # can use: # print $IN->header(); # print qq|
Enable Descrption to be spaned
There is a available template which you can add it into any place in your detailed.html template like
<%if Description_spans%>...More
pages:<%Description_spans%><%endif%>
. And Your <%Description%> in this one is also shortened.
The length of each pages can be change here.
that's it!
Donate for it, if you feel it is useful!
Cheers,
Dat at dat\@cgito.net
http://www.cgito.net