| 1 | # Movable Type (r) Open Source (C) 2001-2008 Six Apart, Ltd. |
|---|
| 2 | # This program is distributed under the terms of the |
|---|
| 3 | # GNU General Public License, version 2. |
|---|
| 4 | # |
|---|
| 5 | # $Id$ |
|---|
| 6 | |
|---|
| 7 | package MT::Page; |
|---|
| 8 | |
|---|
| 9 | use strict; |
|---|
| 10 | use base qw( MT::Entry ); |
|---|
| 11 | use MT::Util qw( archive_file_for ); |
|---|
| 12 | |
|---|
| 13 | __PACKAGE__->install_properties({ |
|---|
| 14 | class_type => 'page', |
|---|
| 15 | child_of => 'MT::Blog', |
|---|
| 16 | child_classes => ['MT::Comment','MT::Placement','MT::Trackback','MT::FileInfo'], |
|---|
| 17 | }); |
|---|
| 18 | |
|---|
| 19 | sub class_label { |
|---|
| 20 | return MT->translate("Page"); |
|---|
| 21 | } |
|---|
| 22 | |
|---|
| 23 | sub class_label_plural { |
|---|
| 24 | MT->translate("Pages"); |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | sub container_label { |
|---|
| 28 | MT->translate("Folder"); |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 31 | sub container_type { |
|---|
| 32 | return "folder"; |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | sub folder { |
|---|
| 36 | return $_[0]->category; |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | sub archive_file { |
|---|
| 40 | my $page = shift; |
|---|
| 41 | my $blog = $page->blog() || return $page->error(MT->translate( |
|---|
| 42 | "Load of blog failed: [_1]", |
|---|
| 43 | MT::Blog->errstr)); |
|---|
| 44 | return archive_file_for($page, $blog, 'Page'); |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | sub archive_url { |
|---|
| 48 | my $page = shift; |
|---|
| 49 | my $blog = $page->blog() || return $page->error(MT->translate( |
|---|
| 50 | "Load of blog failed: [_1]", |
|---|
| 51 | MT::Blog->errstr)); |
|---|
| 52 | my $url = $blog->site_url || ""; |
|---|
| 53 | $url .= '/' unless $url =~ m!/$!; |
|---|
| 54 | return $url . $page->archive_file(@_); |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | sub permalink { |
|---|
| 58 | my $page = shift; |
|---|
| 59 | return $page->archive_url(@_); |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | sub all_permalinks { |
|---|
| 63 | my $page = shift; |
|---|
| 64 | return ($page->permalink(@_)); |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | 1; |
|---|
| 68 | __END__ |
|---|
| 69 | |
|---|
| 70 | =head1 NAME |
|---|
| 71 | |
|---|
| 72 | MT::Page - Movable Type page record |
|---|
| 73 | |
|---|
| 74 | =head1 SYNOPSIS |
|---|
| 75 | |
|---|
| 76 | use MT::Page; |
|---|
| 77 | my $page = MT::Page->new; |
|---|
| 78 | $page->blog_id($blog->id); |
|---|
| 79 | $page->author_id($author->id); |
|---|
| 80 | $page->title('Page title'); |
|---|
| 81 | $page->text('Some text'); |
|---|
| 82 | $page->save |
|---|
| 83 | or die $page->errstr; |
|---|
| 84 | |
|---|
| 85 | =head1 DESCRIPTION |
|---|
| 86 | |
|---|
| 87 | The C<MT::Page> class is a subclass of L<MT::Entry>. Pages are very similar |
|---|
| 88 | to entries, except that they are not published in a reverse-chronological |
|---|
| 89 | listing, typically. Pages are published into folders, represented by |
|---|
| 90 | L<MT::Folder> instead of categories. |
|---|
| 91 | |
|---|
| 92 | =head2 MT::Page->class_label |
|---|
| 93 | |
|---|
| 94 | Returns the localized descriptive name for this class. |
|---|
| 95 | |
|---|
| 96 | =head2 MT::Page->class_label_plural |
|---|
| 97 | |
|---|
| 98 | Returns the localized, plural descriptive name for this class. |
|---|
| 99 | |
|---|
| 100 | =head2 MT::Page->container_label |
|---|
| 101 | |
|---|
| 102 | Returns the localized phrase identifying the "container" type for |
|---|
| 103 | pages (ie: "Folder"). |
|---|
| 104 | |
|---|
| 105 | =head2 MT::Page->container_type |
|---|
| 106 | |
|---|
| 107 | Returns the string "folder", which is the MT type identifier for |
|---|
| 108 | the L<MT::Folder> class. |
|---|
| 109 | |
|---|
| 110 | =head2 $page->folder |
|---|
| 111 | |
|---|
| 112 | Returns the L<MT::Folder> the page is assigned to. |
|---|
| 113 | |
|---|
| 114 | =head2 $page->archive_file |
|---|
| 115 | |
|---|
| 116 | Returns the filename for the published page. |
|---|
| 117 | |
|---|
| 118 | =head2 $page->archive_url |
|---|
| 119 | |
|---|
| 120 | Returns the permalink for the page, based on the site_url of the |
|---|
| 121 | blog, and folder assignment for the page. |
|---|
| 122 | |
|---|
| 123 | =head2 $page->permalink |
|---|
| 124 | |
|---|
| 125 | Returns the permalink for the page. |
|---|
| 126 | |
|---|
| 127 | =head2 $page->all_permalinks |
|---|
| 128 | |
|---|
| 129 | Returns the permalink for the page. |
|---|
| 130 | |
|---|
| 131 | =cut |
|---|