# Copyright (c) 2006 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: BlogEntryList.pm,v 1.2 2006/07/01 06:20:19 aviggio Exp $ package Bivio::Biz::Model::BlogEntryList; use strict; use base 'Bivio::Biz::Model::RealmFileList'; our($VERSION) = sprintf('%d.%02d', q$Revision: 1.2 $ =~ /\d+/g); my($_BN) = Bivio::Type->get_instance('BlogName'); sub execute_load_entry_or_page { my($proto, $req) = @_; my($self) = $proto->new($req); my($query) = $self->parse_query_from_request(); $query->put(path_info => '/Blog'); my($name) = $req->unsafe_get('path_info'); if ($name) { $query->put(entry => $_BN->absolute_path($name)); $self->load_all($query); } else { $self->load_page($query); } return 0; } sub get_content { my($self) = @_; return ${$self->get_model('RealmFile')->get_content()}; } sub internal_initialize { my($self) = @_; my($conf) = $self->merge_initialize_info($self->SUPER::internal_initialize, { version => 1, can_iterate => 1, other => [ [qw(RealmFile.user_id RealmOwner.realm_id)], 'RealmOwner.display_name', 'RealmFile.is_public', { name => 'title', type => 'String', } ], }); # realm_file_id is a proxy for creation_date_time $conf->{order_by} = ['RealmFile.realm_file_id']; return $conf; } sub internal_post_load_row { my($self, $row) = @_; ($row->{title}) = $row->{'RealmFile.path'} =~ m{(\d+[^/]+)$}; return 1; } sub internal_prepare_statement { my($self, $stmt, $query) = @_; my($req) = $self->get_request(); shift->SUPER::internal_prepare_statement(@_); $stmt->where(['RealmFile.path', [$query->get('entry')]]) if $query->unsafe_get('entry'); return; } 1;