Lines 1-6
Link Here
|
1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
2 |
|
2 |
|
3 |
# Copyright 2010 Koha Development team |
3 |
# Copyright 2017 Koha Development team |
4 |
# |
4 |
# |
5 |
# This file is part of Koha. |
5 |
# This file is part of Koha. |
6 |
# |
6 |
# |
Lines 18-68
Link Here
|
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
use C4::Templates; |
|
|
22 |
use C4::Output; |
23 |
# use C4::Auth; |
24 |
use C4::Context; |
21 |
use C4::Context; |
25 |
use CGI qw ( -utf8 ); |
22 |
use CGI qw ( -utf8 ); |
26 |
|
23 |
|
27 |
sub _help_template_file_of_url { |
|
|
28 |
my $url = shift; |
29 |
my $file; |
30 |
if ($url =~ /koha\/(.*)\.pl/) { |
31 |
$file = $1; |
32 |
} else { |
33 |
$file = 'mainpage'; |
34 |
} |
35 |
$file =~ s/[^a-zA-Z0-9_\-\/]*//g; |
36 |
return "help/$file.tt"; |
37 |
} |
38 |
|
39 |
my $query = new CGI; |
24 |
my $query = new CGI; |
40 |
|
25 |
|
41 |
# Init the interface to get the correct language. |
|
|
42 |
# This is usually set by get_template_and_user |
43 |
C4::Context->interface('intranet'); |
44 |
|
45 |
# find the script that called the online help using the CGI referer() |
26 |
# find the script that called the online help using the CGI referer() |
46 |
our $refer = $query->param('url'); |
27 |
our $refer = $query->param('url'); |
47 |
$refer = $query->referer() if !$refer || $refer eq 'undefined'; |
28 |
$refer = $query->referer() if !$refer || $refer eq 'undefined'; |
48 |
my $from = _help_template_file_of_url($refer); |
|
|
49 |
my $htdocs = C4::Context->config('intrahtdocs'); |
50 |
|
51 |
# |
52 |
# checking that the help file exist, otherwise, display nohelp.tt page |
53 |
# |
54 |
my ( $theme, $lang ) = C4::Templates::themelanguage( $htdocs, $from, "intranet", $query ); |
55 |
unless ( -e "$htdocs/$theme/$lang/modules/$from" ) { |
56 |
$from = "help/nohelp.tt"; |
57 |
( $theme, $lang ) = C4::Templates::themelanguage( $htdocs, $from, "intranet", $query ); |
58 |
} |
59 |
|
60 |
my $template = C4::Templates::gettemplate($from, 'intranet', $query); |
61 |
$template->param( |
62 |
referer => $refer, |
63 |
intranetstylesheet => C4::Context->preference("intranetstylesheet"), |
64 |
intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), |
65 |
); |
66 |
|
29 |
|
67 |
my $help_version = C4::Context->preference("Version"); |
30 |
my $help_version = C4::Context->preference("Version"); |
68 |
if ( $help_version =~ m|^(\d+)\.(\d{2}).*$| ) { |
31 |
if ( $help_version =~ m|^(\d+)\.(\d{2}).*$| ) { |
Lines 72-77
if ( $help_version =~ m|^(\d+)\.(\d{2}).*$| ) {
Link Here
|
72 |
$major = sprintf("%02d", $major); |
35 |
$major = sprintf("%02d", $major); |
73 |
$help_version = "$version.$major"; |
36 |
$help_version = "$version.$major"; |
74 |
} |
37 |
} |
75 |
$template->param( helpVersion => $help_version ); |
|
|
76 |
|
38 |
|
77 |
output_html_with_http_headers $query, "", $template->output; |
39 |
# FIXME remote url must be a pref |
|
|
40 |
# FIXME /en/ must be configurable (or guessed) |
41 |
our $base_url = 'http://koha-community.org/manual/' . $help_version . '/en/html'; |
42 |
our $mapping = { |
43 |
'about' => '/14_plugins.html#about-koha', |
44 |
'acqui/acqui-home' => '/09_acquisitions.html', |
45 |
'acqui/addorderiso2709' => '/09_acquisitions.html#create-a-basket', |
46 |
'acqui/basket' => '/09_acquisitions.html#create-a-basket', |
47 |
'acqui/basketgroup' => '/09_acquisitions.html#create-a-basket-group', |
48 |
'acqui/basketheader' => '/09_acquisitions.html#create-a-basket', |
49 |
'acqui/booksellers' => '/09_acquisitions.html#acquisition-searches', |
50 |
'acqui/edifactmsgs' => '/09_acquisitions.html#edifact-messages', |
51 |
'acqui/histsearch' => '/09_acquisitions.html#acquisition-searches', |
52 |
'acqui/invoice' => '/09_acquisitions.html#invoices', |
53 |
'acqui/invoices' => '/09_acquisitions.html#invoices', |
54 |
'acqui/lateorders' => '/09_acquisitions.html#claims-late-orders', |
55 |
'acqui/neworderbiblio' => '/09_acquisitions.html#create-a-basket', |
56 |
'acqui/neworderempty' => '/09_acquisitions.html#create-a-basket', |
57 |
'acqui/newordersubscription' => '/09_acquisitions.html#create-a-basket', |
58 |
'acqui/newordersuggestion' => '/09_acquisitions.html#create-a-basket', |
59 |
'acqui/orderreceive' => '/09_acquisitions.html#receiving-orders', |
60 |
'acqui/parcel' => '/09_acquisitions.html#receiving-orders', |
61 |
'acqui/parcels' => '/09_acquisitions.html#receiving-orders', |
62 |
'acqui/supplier' => '/09_acquisitions.html#vendors', |
63 |
'acqui/uncertainprice' => '/09_acquisitions.html#create-a-basket', |
64 |
'acqui/z3950_search' => '/09_acquisitions.html#create-a-basket', |
65 |
'admin/admin-home' => '/02_administration.html', |
66 |
'admin/aqbudgetperiods' => '/02_administration.html#budgets', |
67 |
'admin/aqbudgets' => '/02_administration.html#funds', |
68 |
'admin/aqcontract' => '/09_acquisitions.html#vendor-contracts', |
69 |
'admin/aqplan' => '/02_administration.html#budget-planning', |
70 |
'admin/auth_subfields_structure' => '/02_administration.html#authority-types', |
71 |
'admin/auth_tag_structure' => '/02_administration.html#authority-types', |
72 |
'admin/authorised_values' => '/02_administration.html#authorized-values', |
73 |
'admin/authtypes' => '/02_administration.html#authority-types', |
74 |
'admin/biblio_framework' => '/02_administration.html#marc-bibliographic-frameworks', |
75 |
'admin/branch_transfer_limits' => '/02_administration.html#library-transfer-limits', |
76 |
'admin/branches' => '/02_administration.html#libraries-&-groups', |
77 |
'admin/categorie' => '/02_administration.html#patron-categories', |
78 |
'admin/checkmarc' => '/02_administration.html#marc-bibliographic-framework-test', |
79 |
'admin/cities' => '/02_administration.html#cities-and-towns', |
80 |
'admin/classsources' => '/02_administration.html#classification-sources', |
81 |
'admin/columns_settings' => '/02_administration.html#column-settings', |
82 |
'admin/currency' => '/02_administration.html#currencies-and-exchange-rates', |
83 |
'admin/didyoumean' => '/02_administration.html#did-you-mean?', |
84 |
'admin/edi_accounts' => '/02_administration.html#edi-accounts', |
85 |
'admin/edi_ean_accounts' => '/02_administration.html#library-eans', |
86 |
'admin/fieldmapping' => '/02_administration.html#keywords-to-marc-mapping', |
87 |
'admin/item_circulation_alerts' => '/02_administration.html#item-circulation-alerts', |
88 |
'admin/items_search_fields' => '/02_administration.html#item-search-fields', |
89 |
'admin/itemtypes' => '/02_administration.html#item-types', |
90 |
'admin/koha2marclinks' => '/02_administration.html#koha-to-marc-mapping', |
91 |
'admin/marc_subfields_structure' => '/02_administration.html#marc-bibliographic-frameworks', |
92 |
'admin/marctagstructure' => '/02_administration.html#marc-bibliographic-frameworks', |
93 |
'admin/matching-rules' => '/02_administration.html#record-matching-rules', |
94 |
'admin/oai_set_mappings' => '/02_administration.html#oai-sets-configuration', |
95 |
'admin/oai_sets' => '/02_administration.html#oai-sets-configuration', |
96 |
'admin/patron-attr-types' => '/02_administration.html#patron-attribute-types', |
97 |
'admin/preferences' => '/02_administration.html#global-system-preferences', |
98 |
'admin/smart-rules' => '/02_administration.html#circulation-and-fine-rules', |
99 |
'admin/systempreferences' => '/02_administration.html#global-system-preferences', |
100 |
'admin/transport-cost-matrix' => '/02_administration.html#transport-cost-matrix', |
101 |
'admin/z3950servers' => '/02_administration.html#z39.50/sru-servers', |
102 |
'authorities/authorities-home' => '/06_cataloging.html#authorities', |
103 |
'authorities/authorities' => '/06_cataloging.html#authorities', |
104 |
'authorities/detail' => '/06_cataloging.html#authorities', |
105 |
'authorities/merge' => '/06_cataloging.html#merging-authorities', |
106 |
'catalogue/detail' => '/06_cataloging.html#bibliographic-records', |
107 |
'catalogue/issuehistory' => '/06_cataloging.html#item-specific-circulation-history', |
108 |
'catalogue/itemsearch' => '/13_searching.html#item-searching', |
109 |
'catalogue/moredetail' => '/06_cataloging.html#item-records', |
110 |
'catalogue/search-history' => '/14_plugins.html#search-history', |
111 |
'catalogue/search' => '/13_searching.html', |
112 |
'cataloguing/addbiblio' => '/06_cataloging.html#bibliographic-records', |
113 |
'cataloguing/addbooks' => '/06_cataloging.html', |
114 |
'cataloguing/additem' => '/06_cataloging.html#item-records', |
115 |
'cataloguing/linkitem' => '/06_cataloging.html#adding-analytic-records', |
116 |
'cataloguing/merge' => '/06_cataloging.html#merging-records', |
117 |
'cataloguing/moveitem' => '/06_cataloging.html#moving-items', |
118 |
'circ/branchoverdues' => '/05_circulation.html#overdues-with-fines', |
119 |
'circ/branchtransfers' => '/05_circulation.html#transfers', |
120 |
'circ/circulation-home' => '/05_circulation.html', |
121 |
'circ/circulation' => '/05_circulation.html#check-out-(issuing)', |
122 |
'circ/offline' => '/05_circulation.html#offline-circulation-in-koha', |
123 |
'circ/on-site_checkouts' => '/05_circulation.html#pending-on-site-checkouts', |
124 |
'circ/overdue' => '/05_circulation.html#overdues', |
125 |
'circ/pendingreserves' => '/05_circulation.html#holds-to-pull', |
126 |
'circ/renew' => '/05_circulation.html#renewing', |
127 |
'circ/reserveratios' => '/05_circulation.html#hold-ratios', |
128 |
'circ/returns' => '/05_circulation.html#check-in-returning', |
129 |
'circ/selectbranchprinter' => '/05_circulation.html#set-library', |
130 |
'circ/transferstoreceive' => '/05_circulation.html#transfers-to-receive', |
131 |
'circ/view_holdsqueue' => '/05_circulation.html#holds-queue', |
132 |
'circ/waitingreserves' => '/05_circulation.html#holds-awaiting-pickup', |
133 |
'course_reserves/add_items' => '/07_course_reserves.html', |
134 |
'course_reserves/course-details' => '/07_course_reserves.html', |
135 |
'course_reserves/course-reserves' => '/07_course_reserves.html', |
136 |
'course_reserves/course' => '/07_course_reserves.html#adding-courses', |
137 |
'labels/label-edit-batch' => '/03_tools.html#batches', |
138 |
'labels/label-edit-layout' => '/03_tools.html#layouts', |
139 |
'labels/label-edit-profile' => '/03_tools.html#profiles', |
140 |
'labels/label-edit-template' => '/03_tools.html#templates', |
141 |
'labels/label-home' => '/03_tools.html#label-creator', |
142 |
'labels/label-manage' => '/03_tools.html#layouts', |
143 |
'labels/label-manage' => '/03_tools.html#templates', |
144 |
'labels/label-manage' => '/03_tools.html#profiles', |
145 |
'labels/label-manage' => '/03_tools.html#batches', |
146 |
'labels/spinelabel-home' => '/03_tools.html#quick-spine-label-creator', |
147 |
'mainpage' => '/', |
148 |
'members/boraccount' => '/04_patrons.html#fines', |
149 |
'members/discharge' => '/04_patrons.html#patron-discharges', |
150 |
'members/files' => '/04_patrons.html#files', |
151 |
'members/mancredit' => '/04_patrons.html#creating-manual-credits', |
152 |
'members/maninvoice' => '/04_patrons.html#creating-manual-invoices', |
153 |
'members/member-flags' => '/04_patrons.html#patron-permissions', |
154 |
'members/member-password' => '/04_patrons.html#editing-patrons', |
155 |
'members/member' => '/04_patrons.html#patron-search', |
156 |
'members/memberentry' => '/04_patrons.html#add-a-new-patron', |
157 |
'members/members-home' => '/04_patrons.html', |
158 |
'members/members-update' => '/04_patrons.html#managing-patron-self-edits', |
159 |
'members/moremember' => '/04_patrons.html#patron-information', |
160 |
'members/notices' => '/04_patrons.html#notices', |
161 |
'members/pay' => '/04_patrons.html#pay/reverse-fines', |
162 |
'members/paycollect' => '/04_patrons.html#pay/reverse-fines', |
163 |
'members/purchase-suggestions' => '/04_patrons.html#purchase-suggestions', |
164 |
'members/readingrec' => '/04_patrons.html#circulation-history', |
165 |
'members/routing-lists' => '/04_patrons.html#routing-lists', |
166 |
'members/statistics' => '/04_patrons.html#statistics', |
167 |
'offline_circ/list' => '/05_circulation.html#offline-circulation-utilities', |
168 |
'offline_circ/process_koc' => '/05_circulation.html#upload-offline-circ-file', |
169 |
'patron_lists/lists' => '/03_tools.html#patron-lists', |
170 |
'patroncards/edit-batch' => '/03_tools.html#batches', |
171 |
'patroncards/edit-layout' => '/03_tools.html#layouts', |
172 |
'patroncards/edit-profile' => '/03_tools.html#profiles', |
173 |
'patroncards/edit-template' => '/03_tools.html#templates', |
174 |
'patroncards/home' => '/03_tools.html#patron-card-creator', |
175 |
'patroncards/image-manage' => '/03_tools.html#manage-images', |
176 |
'patroncards/manage' => '/03_tools.html#patron-card-creator', |
177 |
'plugins/plugins-home' => '/14_plugins.html', |
178 |
'plugins/plugins-upload' => '/14_plugins.html', |
179 |
'reports/acquisitions_stats' => '/11_reports.html#acquisitions-statistics', |
180 |
'reports/bor_issues_top' => '/11_reports.html#patrons-with-the-most-checkouts', |
181 |
'reports/borrowers_out' => '/11_reports.html#patrons-with-no-checkouts', |
182 |
'reports/borrowers_stats' => '/11_reports.html#patron-statistics', |
183 |
'reports/cat_issues_top' => '/11_reports.html#most-circulated-items', |
184 |
'reports/catalogue_out' => '/11_reports.html#items-with-no-checkouts', |
185 |
'reports/catalogue_stats' => '/11_reports.html#catalog-statistics', |
186 |
'reports/dictionary' => '/11_reports.html#report-dictionary', |
187 |
'reports/guided_reports' => '/11_reports.html#custom-reports', |
188 |
'reports/issues_avg_stats' => '/11_reports.html#average-loan-time', |
189 |
'reports/issues_stats' => '/11_reports.html#circulation-statistics', |
190 |
'reports/itemslost' => '/11_reports.html#lost-items', |
191 |
'reports/manager' => '/11_reports.html#catalog-by-item-type', |
192 |
'reports/reports-home' => '/11_reports.html', |
193 |
'reports/reserves_stats' => '/11_reports.html#holds-statistics', |
194 |
'reports/serials_stats' => '/11_reports.html#serials-statistics', |
195 |
'reserve/request' => '/05_circulation.html#holds', |
196 |
'reviews/reviewswaiting' => '/03_tools.html#comments', |
197 |
'rotating_collections/rotatingCollections' => '/03_tools.html#rotating-collections', |
198 |
'serials/checkexpiration' => '/08_serials.html#check-serial-expiration', |
199 |
'serials/claims' => '/08_serials.html#claim-late-serials', |
200 |
'serials/routing' => '/08_serials.html#create-a-routing-list', |
201 |
'serials/serials-collection' => '/08_serials.html', |
202 |
'serials/serials-edit' => '/08_serials.html#receive-issues', |
203 |
'serials/serials-home' => '/08_serials.html', |
204 |
'serials/subscription-add' => '/08_serials.html#add-a-subscription', |
205 |
'serials/subscription-detail' => '/08_serials.html', |
206 |
'serials/subscription-frequencies' => '/08_serials.html#manage-serial-frequencies', |
207 |
'serials/subscription-numberpatterns' => '/08_serials.html#manage-serial-numbering-patterns', |
208 |
'suggestion/suggestion' => '/09_acquisitions.html#managing-suggestions', |
209 |
'tags/list' => '/03_tools.html#tag-moderation', |
210 |
'tags/review' => '/03_tools.html#tag-moderation', |
211 |
'tools/batchMod' => '/03_tools.html#batch-item-deletion', |
212 |
'tools/batch_delete_records' => '/03_tools.html#batch-record-deletion', |
213 |
'tools/batch_record_modification' => '/03_tools.html#batch-record-modification', |
214 |
'tools/cleanborrowers' => '/03_tools.html#patrons-anonymize-bulk-delete', |
215 |
'tools/csv-profiles' => '/03_tools.html#csv-profiles', |
216 |
'tools/export' => '/03_tools.html#export-bibliographic-records', |
217 |
'tools/holidays' => '/03_tools.html#calendar', |
218 |
'tools/import_borrowers' => '/03_tools.html#patron-import', |
219 |
'tools/inventory' => '/03_tools.html#inventory-stocktaking', |
220 |
'tools/koha-news' => '/03_tools.html#news', |
221 |
'tools/letter' => '/03_tools.html#notices-slips', |
222 |
'tools/manage-marc-import' => '/03_tools.html#staged-marc-record-management', |
223 |
'tools/marc_modification_templates' => '/03_tools.html#marc-modification-templates', |
224 |
'tools/modborrowers' => '/03_tools.html#batch-patron-modification', |
225 |
'tools/overduerules' => '/03_tools.html#overdue-notice-status-triggers', |
226 |
'tools/picture-upload' => '/03_tools.html#upload-patron-images', |
227 |
'tools/quotes-upload' => '/03_tools.html#import-quotes', |
228 |
'tools/quotes' => '/03_tools.html#quote-of-the-day-(qotd)-editor', |
229 |
'tools/scheduler' => '/03_tools.html#task-scheduler', |
230 |
'tools/stage-marc-import' => '/03_tools.html#stage-marc-records-for-import', |
231 |
'tools/tools-home' => '/03_tools.html', |
232 |
'tools/upload-cover-image' => '/03_tools.html#upload-local-cover-image', |
233 |
'tools/viewlog' => '/03_tools.html#log-viewer', |
234 |
'virtualshelves/shelves' => '/10_lists.html#lists', |
235 |
}; |
236 |
|
237 |
sub _get_manual_url { |
238 |
my $url = shift; |
239 |
my $file; |
240 |
if ($url =~ /koha\/(.*)\.pl/) { |
241 |
$file = $1; |
242 |
} else { |
243 |
$file = 'mainpage'; |
244 |
} |
245 |
$file =~ s/[^a-zA-Z0-9_\-\/]*//g; |
246 |
|
247 |
return $base_url . ( exists $mapping->{$file} ? $mapping->{$file} : $mapping->{mainpage} ); |
248 |
} |
249 |
|
250 |
my $manual_url = _get_manual_url($refer); |
251 |
|
252 |
print $query->redirect($manual_url); |
78 |
- |
|
|