latemp / Perl / modules / HTML-Latemp-NavLinks-GenHtml / lib / HTML / Latemp / NavLinks / GenHtml /

package HTML::Latemp::NavLinks::GenHtml::ArrowImages;

use strict;
use warnings;

use vars qw($nav_buttons_html);

use base 'HTML::Latemp::NavLinks::GenHtml';


sub _init
    my $self = shift;
    my (%args) = (@_);


    $self->_ext($args{ext} || '.png');


=head1 NAME

HTML::Latemp::NavLinks::GenHtml::ArrowImages - A class to generate the image-based HTML of the navigation links.


    my $obj = HTML::Latemp::NavLinks::GenHtml::Text->new(
        ext => '.png', # Default.
        root => $path_to_root,
        nav_links_obj => $links,


This module generates text navigation links. C<root> is the relative path to
the site's root directory. C<nav_links_obj> are the hash of navigation links'
objects as returned by L<HTML::Widgets::NavMenu> or something similar.

=head1 METHODS


use Template;

# load Template::Stash to make method tables visible
use Template::Stash;

# Define a method to return a substring.
$Template::Stash::SCALAR_OPS->{ 'substr' } = sub {
    return substr($_[0], $_[1], $_[2]);

sub _get_nav_buttons_html
    my $self = shift;

    my (%args) = (@_);

    my $with_accesskey = $args{'with_accesskey'};

    my $root = $self->root();

    my $template =
            'POST_CHOMP' => 1,

    my $vars =
        'buttons' => $self->_get_buttons(),
        'root' => $root,
        'with_accesskey' => $with_accesskey,
        'image_base' => $self->get_image_base(),
        ext => $self->_ext(),

    my $nav_links_template = <<'EOF';
[% USE HTML %]
[% FOREACH b = buttons %]
[% SET key = b.dir.substr(0, 1) %]
[% IF b.exists %]
<a href="[% HTML.escape(b.link_obj.direct_url()) %]" title="[% b.title %] (Alt+[% key FILTER upper %])"
[% IF with_accesskey %]
accesskey="[% key %]"
[% END %]
>[% END %]<img src="[% root %]/images/[% image_base %][% b.button %][% UNLESS b.exists %]-disabled[% END %][% ext %]"
alt="[% b.title %]" class="bless" />[% IF b.exists %]</a>
[% END %]
[% END %]

    my $nav_buttons_html = "";

    $template->process(\$nav_links_template, $vars, \$nav_buttons_html);
    return $nav_buttons_html;

=head2 $obj->get_image_base()

Can be overrided. Should return the base of the image filename of the module.


sub get_image_base
    my $self = shift;

    return "arrow-";

=head2 $obj->get_total_html()

Calculates and returns the final HTML.


sub get_total_html
    my $self = shift;

    return "<ul class=\"nav_links\">\n" .
        $self->_get_nav_buttons_html(@_) .

=head1 AUTHOR

Shlomi Fish, C<< <> >>

=head1 BUGS

Please report any bugs or feature requests to
C<>, or through the web interface at
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.


Copyright 2005 Shlomi Fish, All Rights Reserved.

This program is free software; you can redistribute it and/or modify it
under the terms of the MIT X11 license.


Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.