E2-Interface

 view release on metacpan or  search on metacpan

E2Node.pm  view on Meta::CPAN

our @ISA = "E2::Node";
our $VERSION = "0.33";
our $DEBUG; *DEBUG = *E2::Interface::DEBUG;

# Prototypes

sub new;
sub clear;

sub has_mine;
sub is_locked;

sub list_writeups;
sub list_softlinks;
sub list_firmlinks;
sub list_sametitles;

sub get_writeup;
sub get_writeup_by_author;
sub get_my_writeup;
sub get_writeup_number;

E2Node.pm  view on Meta::CPAN

}

sub clear {
	my $self = shift	or croak "Usage: clear E2E2NODE";

	warn "E2::E2Node::clear\n"	if $DEBUG > 1;

	@{ $self->{writeups} } = ();	 # Array to hold writeups in currently
					 # loaded node. See E2::Writeup.
	
	$self->{locked}		= undef; # soft locked

	$self->{next}		= 0;	 # Next writeup to return
	$self->{mine}		= undef; # My writeup in this node.

	@{ $self->{firmlinks} }	= ();	 # List of firmlinks
	@{ $self->{softlinks} }	= ();	 # List of softlinks
	@{ $self->{sametitles}}	= ();	 # List of sametitles
					 # The preceding three return hashrefs
					 # with the following keys:
					 # 	o title

E2Node.pm  view on Meta::CPAN


	if(!$self->node_id)	{ return undef; }	# No node loaded

	if( defined( $self->{mine} ) ) { 
		return 1;
	}

	return 0;
}

sub is_locked {
	my $self = shift	or croak "Usage: is_locked E2E2NODE";

	if( !$self->node_id )	{ return undef; }

	if( $self->{locked} )	{ return 1; }
	else			{ return 0; }
}

sub list_softlinks {
	my $self = shift	or croak "Usage: list_softlinks E2NODE";

	return undef if !$self->node_id;
	
	return @{ $self->{softlinks} };
}

E2Node.pm  view on Meta::CPAN

	return @{ $self->{sametitles} };
}

sub twig_handlers {
	my $self = shift or croak "Usage: twig_handlers E2E2NODE";

	return (

		'node/nodelock' => sub {
			(my $a, my $b) = @_;
			$self->{locked} = $b->text;
			if( $self->{locked} eq "" ) {
				$self->{locked} = undef;
			}
		},
		'node/writeup' => sub {
			(my $a, my $b) = @_;

			my $wu = new E2::Writeup;
			$wu->clone( $self );
			$wu->parse( $b );

			my $name = $self->this_username;

E2Node.pm  view on Meta::CPAN

=head1 METHODS

=over

=item $node-E<gt>clear

C<clear> clears all the information currently stored in $node. 

=item $node-E<gt>has_mine

=item $node-E<gt>is_locked

Boolean: "Does this node have a writeup by me in it?"; "Is this node softlocked?"

C<is_locked> is actually a string value, if true, consisting of the text of the softlock.

=item $node-E<gt>list_softlinks

=item $node-E<gt>list_firmlinks

=item $node-E<gt>list_sametitles

These methods return a list of softlinks, firmlinks, or sametitles.

They each return a list of hashrefs. C<list_softlinks> and C<list_firmlinks> return hashrefs with the keys "title" and "id". C<list_sametitles>, which deals with the "'x' is also a: user / room / etc.", has the additional key of "type".

t/load_e2node_xml.t  view on Meta::CPAN

ok( $s[1]->{title}	eq "and another" );
ok( $s[1]->{id}		== 99998 );
ok( $s[2]->{title}	eq "and one final softlink" );
ok( $s[2]->{id}		== 99997 );

ok( @s = $node->list_sametitles );
ok( $s[0]->{title}	eq "test" );
ok( $s[0]->{id}		== 99996 );
ok( $s[0]->{type}	eq "room" );

ok( $node->is_locked );



( run in 1.522 second using v1.01-cache-2.11-cpan-49f99fa48dc )