forms.pl 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env perl
  2. use strict;
  3. use v5.10;
  4. # ====================[ forms.pl ]====================
  5. AddModuleDescription('forms.pl', 'Form Extension');
  6. our ($q, $OpenPageName, @MyRules, $CrossbarPageName);
  7. # ....................{ MARKUP }....................
  8. push(@MyRules, \&FormsRule);
  9. sub FormsRule {
  10. if (IsFile(GetLockedPageFile($OpenPageName)) or (InElement('div', '^class="crossbar"$') and
  11. IsFile(GetLockedPageFile($CrossbarPageName)))) {
  12. if (/\G(\<form.*?\<\/form\>)/cgs) {
  13. my $form = $1;
  14. my $oldpos = pos;
  15. Clean(CloseHtmlEnvironments());
  16. Dirty($form);
  17. $form =~ s/\%([a-z]+)\%/GetParam($1)/eg;
  18. $form =~ s/\$([a-z]+)\$/$q->span({-class=>'param'}, GetParam($1))
  19. .$q->input({-type=>'hidden', -name=>$1, -value=>GetParam($1)})/eg;
  20. print UnquoteHtml($form);
  21. pos = $oldpos;
  22. return AddHtmlEnvironment('p');
  23. }
  24. elsif (m/\G\<html\>(.*?)\<\/html\>/cgs) {
  25. return UnquoteHtml($1);
  26. }
  27. }
  28. return;
  29. }
  30. =head1 COPYRIGHT AND LICENSE
  31. The information below applies to everything in this distribution,
  32. except where noted.
  33. Copyleft 2008 by B.w.Curry <http://www.raiazome.com>.
  34. Copyright 2004 by Alex Schroeder <alex@emacswiki.org>.
  35. This program is free software; you can redistribute it and/or modify
  36. it under the terms of the GNU General Public License as published by
  37. the Free Software Foundation; either version 3 of the License, or
  38. (at your option) any later version.
  39. This program is distributed in the hope that it will be useful,
  40. but WITHOUT ANY WARRANTY; without even the implied warranty of
  41. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  42. GNU General Public License for more details.
  43. You should have received a copy of the GNU General Public License
  44. along with this program. If not, see L<http://www.gnu.org/licenses/>.
  45. =cut