NAME

CatalystX::CMS::File - template file class

SYNOPSIS

use CatalystX::CMS::File;

# longhand
my $file = CatalystX::CMS::File->new( $path_to_file );
$file->fetch if $page->size;
$file->content('hello world');
$file->title('super foo');
$file->write;
$file->commit or die $file->errstr;

# shorthand
my $file = CatalystX::CMS::File->new(
                       path    => $path_to_file,
                       title   => 'super foo',
                       content => 'hello world',
                       );
eval { $file->save  } or die $file->errstr;
print "$file was saved\n";
                       

DESCRIPTION

CatalystX::CMS::File is the object model for the Template Toolkit files that make up the content system of your application. Each object represents a .tt file on the filesystem in a Subversion working directory. An object can be read, written, locked and unlocked on the filesystem. As a subclass of SVN::Class::File, the object can be interrogated for its history, added, deleted, committed or updated.

new( path )

new( path => path [, %param ] )

Create a new object.

Either form of new() may be used, but path is always required.

read

Reads the file from disk and parses the metadata attributes and content, thereafter accessible via the attrs() and content() methods.

Will croak if path() is false, empty or non-existent.

committed

Returns true if the delegate file has ever been committed to the repository.

write( [ignore_lock] )

Writes attrs() and content() to file location in TT-compatible format.

Will croak on any error.

If the ignore_lock flag is true, write() will ignore any true value of locked(). Otherwise, will croak() if locked() is true.

Returns the size of the resulting file.

create( user )

Acquires lock for user and writes files as a new page.

update

Calls write().

NOTE: This is not the same as the SVN::Class->update method! If you want that method, use the up() alias instead.

save( message [, leave_lock, username ] )

Will write() file, add() to the SVN workspace if necessary, and then call commit( message ).

Returns -1 if status() of file indicates no modification. Otherwise, returns commit() return value.

Pass a true for leave_lock to leave the lock file intact after the commit().

Pass an authorized username to have the commit() made with that credential.

escape_tt

Returns content() with all TT code wrapped in special XHTML tagset

<code class="tt">

This is to allow for such code to be escaped online or otherwise parsed with a XML parser.

AUTHOR

Peter Karman, <karman@cpan.org>

BUGS

Please report any bugs or feature requests to bug-catalystx-cms@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

ACKNOWLEDGEMENTS

The Minnesota Supercomputing Institute http://www.msi.umn.edu/ sponsored the development of this software.

COPYRIGHT & LICENSE

Copyright 2008 by the Regents of the University of Minnesota.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.