/[wait]/branches/unido/lib/WAIT/Format/Base.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /branches/unido/lib/WAIT/Format/Base.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 106 - (show annotations)
Tue Jul 13 12:22:09 2004 UTC (19 years, 9 months ago) by dpavlin
File size: 1484 byte(s)
Changes made by Andreas J. Koenig <andreas.koenig(at)anima.de> for Unido project

1 # -*- Mode: Perl -*-
2 # Base.pm --
3 # ITIID : $ITI$ $Header $__Header$
4 # Author : Ulrich Pfeifer
5 # Created On : Wed Sep 18 19:04:42 1996
6 # Last Modified By: Ulrich Pfeifer
7 # Last Modified On: Sun Nov 22 18:44:46 1998
8 # Language : CPerl
9 # Update Count : 49
10 # Status : Unknown, Use with caution!
11 #
12 # Copyright (c) 1996-1997, Ulrich Pfeifer
13 #
14
15 package WAIT::Format::Base;
16 use strict;
17
18 sub new {
19 my $type = shift;
20 my %parm = @_;
21
22 bless \%parm, ref($type) || $type;
23 }
24
25 sub text {
26 $_[1];
27 }
28
29 sub bold {
30 join '', map "$_$_", grep length($_), split /(.)/, $_[1];
31 }
32
33 sub italic {
34 join '', map "_$_", grep length($_), split /(.)/, $_[1];
35 }
36
37 sub query {
38 join '', map "$_$_", grep length($_), split /(.)/, $_[1];
39 }
40
41 sub as_string {
42 my $self = shift;
43 my $text = shift;
44 my $result = '';
45 my $i;
46
47 for ($i=0; $i < @$text; $i+=2) {
48 my %tag = %{$text->[$i]};
49 my $txt = $text->[$i+1];
50
51 next unless length($txt);
52 if (exists $tag{'_qt'}) {
53 $result .= $self->query($txt);
54 #my @line = split ' ', $txt, 2;
55 #$result .= $self->query(shift @line);
56 #next unless @line;
57 #$result .= ' ';
58 #$result .= shift @line;
59 } elsif (exists $tag{'_b'}) {
60 $result .= $self->bold($self->text($txt));
61 } elsif (exists $tag{'_i'}) {
62 $result .= $self->italic($self->text($txt));
63 } else {
64 $result .= $self->text($txt);
65 }
66 }
67 $result;
68 }
69
70 1;

  ViewVC Help
Powered by ViewVC 1.1.26