File Coverage

blib/lib/FAQ/OMatic/HelpMod.pm
Criterion Covered Total %
statement 12 28 42.8
branch 0 6 0.0
condition 0 4 0.0
subroutine 3 6 50.0
pod 0 4 0.0
total 15 48 31.2


line stmt bran cond sub pod time code
1             ##############################################################################
2             # The Faq-O-Matic is Copyright 1997 by Jon Howell, all rights reserved. #
3             # #
4             # This program is free software; you can redistribute it and/or #
5             # modify it under the terms of the GNU General Public License #
6             # as published by the Free Software Foundation; either version 2 #
7             # of the License, or (at your option) any later version. #
8             # #
9             # This program is distributed in the hope that it will be useful, #
10             # but WITHOUT ANY WARRANTY; without even the implied warranty of #
11             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
12             # GNU General Public License for more details. #
13             # #
14             # You should have received a copy of the GNU General Public License #
15             # along with this program; if not, write to the Free Software #
16             # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.#
17             # #
18             # Jon Howell can be contacted at: #
19             # 6211 Sudikoff Lab, Dartmouth College #
20             # Hanover, NH 03755-3510 #
21             # jonh@cs.dartmouth.edu #
22             # #
23             # An electronic copy of the GPL is available at: #
24             # http://www.gnu.org/copyleft/gpl.html #
25             # #
26             ##############################################################################
27              
28 1     1   4 use strict;
  1         3  
  1         38  
29              
30             ### Help.pm
31             ###
32             ### Online, context-sensitive help system
33             ###
34              
35             package FAQ::OMatic::HelpMod;
36              
37 1     1   7 use FAQ::OMatic;
  1         2  
  1         388  
38              
39             my $helpIndex = {}; # constant; no mod_perl cache problems
40              
41             sub hr {
42 11     11 0 16 my $fileName = shift;
43 11         12 my $title = shift;
44 11         12 my $nick;
45 11         34 $helpIndex->{$title} = [ $fileName, $title ];
46 11         17 foreach $nick (@_) {
47 12         44 $helpIndex->{$nick} = [ $fileName, $title ];
48             }
49             }
50              
51             hr('help000', 'Online Help', 'faq', '');
52             hr('help001', 'How can I contribute to this FAQ?');
53             hr('help002', 'Search Tips', 'search', 'searchForm');
54             hr('help003', 'Appearance Options', 'appearanceForm');
55             hr('help004', 'Authentication', 'authenticate');
56             hr('help005', "Editing an Item's Title and Options", 'editItem');
57             hr('help006', 'Moderator Options', 'moderatorOptions');
58             hr('help007', 'Editing Text Parts', 'editPart');
59             hr('help008', 'Making Links To Other Sites', 'makingLinks');
60             hr('help009', 'Making Links To Other FAQ-O-Matic Items', 'seeAlso');
61             hr('help010', 'Moving Answers and Categories', 'moveItem');
62              
63             sub helpLookup {
64 0     0 0   my $params = shift;
65 0           my $target = shift;
66              
67 0 0         return @{ $helpIndex->{$target} || ["inv $target", 'Invalid Help Target'] };
  0            
68             }
69              
70             sub helpFor {
71 0     0 0   my $params = shift;
72 0           my $target = shift;
73 0   0       my $punctuation = shift || ''; # add only if button is presented
74              
75 0 0         return '' if (not $params->{'help'});
76 0   0       my $file = $params->{'file'} || '';
77 0 0         return '' if ($file =~ m/^help/);
78              
79 0           my ($helpFile, $helpName) = helpLookup($params, $target);
80              
81 0           return FAQ::OMatic::button(
82             FAQ::OMatic::makeAref('-params'=>$params,
83             '-changedParams'=>{'file'=>$helpFile,
84             'editCmds'=>'hide'},
85             '-target'=>'help'),
86             "HELP: $helpName")
87             .$punctuation
88             ."\n";
89             }
90              
91             sub helpURL {
92 0     0 0   my $params = shift;
93 0           my $target = shift;
94              
95 0           my ($file, $name) = helpLookup($params, $target);
96              
97 0           return FAQ::OMatic::makeAref('-params'=>$params,
98             '-changedParams'=>{'file'=>$file,
99             'editCmds'=>'hide'},
100             '-target'=>'help',
101             '-refType'=>'url');
102             }
103              
104             1;