| 1 | package WebEditor::OldFeatures::TeaserLink; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use vars qw($VERSION); | ||
| 5 | $VERSION = sprintf("%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/); | ||
| 6 | |||
| 7 | use CGI qw(param); | ||
| 8 | |||
| 9 | use Data::JavaScript; | ||
| 10 | |||
| 11 | sub showeditor_teaserlink { | ||
| 12 | my $self = shift; | ||
| 13 | my $root = $self->Root; | ||
| 14 | $self->login | ||
| 15 | unless $root->identify($self->User,$self->Password); | ||
| 16 | my $objdb = $root->ObjDB; | ||
| 17 | |||
| 18 | my $lg = param('language'); | ||
| 19 | my $teaserfolderid = $objdb->name_to_objid('teaser'); | ||
| 20 | my @teaserpageids = $objdb->children_ids($teaserfolderid); | ||
| 21 | # how many teaserpages are there in the "teaser"-folder? | ||
| 22 | my @pageids; | ||
| 23 | my @titles; | ||
| 24 | my @pages; | ||
| 25 | foreach my $teaserpageid (@teaserpageids) { | ||
| 26 | my @teaserarray; | ||
| 27 | my @teasers; | ||
| 28 | use vars qw($outdata); | ||
| 29 | eval( $objdb->content($teaserpageid) ); | ||
| 30 | @teaserarray = eval { @{$outdata->{data}->{$lg}->{ct}[0]{ct}} }; | ||
| 31 | warn "Problem for lang=$lg, teaserpageid=$teaserpageid: $@" if $@; | ||
| 32 | # get all teasers of this page | ||
| 33 | my $counter = 0; | ||
| 34 | foreach my $tsr (@teaserarray) { | ||
| 35 | # get this teasers headline | ||
| 36 | push(@teasers, $tsr->{ct}[0]->{text}); | ||
| 37 | } | ||
| 38 | push(@pages,{headlines => \@teasers, | ||
| 39 | pageid => $teaserpageid, | ||
| 40 | pagetitle => $outdata->{data}->{$lg}->{title} }); | ||
| 41 | } | ||
| 42 | my $jscode = Data::JavaScript::jsdump('teaserhl',\@pages); | ||
| 43 | $self->_tpl("bestwe", "we_teaserlinker.tpl.html", | ||
| 44 | { 'js' => $jscode }); | ||
| 45 | } | ||
| 46 | |||
| 47 | 1; | ||
| 48 | |||
| 49 | =head1 NAME | ||
| 50 | |||
| 51 | WebEditor::OldFeatures::TeaserLink - feature to add teasers to pages | ||
| 52 | |||
| 53 | =head1 SYNOPSIS | ||
| 54 | |||
| 55 | Add this to your WE_I<projectname>::OldController: | ||
| 56 | |||
| 57 | use WebEditor::OldFeatures::TeaserLink; | ||
| 58 | *showeditor_teaserlink = \&WebEditor::OldFeatures::TeaserLink::showeditor_teaserlink; | ||
| 59 | |||
| 60 | =head1 AUTHOR | ||
| 61 | |||
| 62 | Slaven Rezic | ||
| 63 | |||
| 64 | =cut |