set_language($tag)translate($str)
MT - Movable Type
use MT;
my $mt = MT->new;
$mt->rebuild(BlogID => 1)
or die $mt->errstr;
The MT class is the main high-level rebuilding/pinging interface in the Movable Type library. It handles all rebuilding operations. It does not handle any of the application functionality--for that, look to MT::App and MT::App::CMS, both of which subclass MT to handle application requests.
MT has the following interface. On failure, all methods return undef
and set the errstr for the object or class (depending on whether the
method is an object or class method, respectively); look below at the section
ERROR HANDLING for more information.
Constructs a new MT instance and returns that object. Returns undef
on failure.
new will also read your mt.cfg file (provided that it can find it--if
you find that it can't, take a look at the Config directive, below). It
will also initialize the chosen object driver; the default is the DBM
object driver.
%args can contain:
If you do not specify a path, MT will try to find your mt.cfg file in the current working directory.
Rebuilds your entire blog, indexes and archives; or some subset of your blog, as specified in the arguments.
%args can contain:
Either this or BlogID is required.
Either this or Blog is required.
Individual, Daily, Weekly, Monthly, or
Category.
This argument is optional; if not provided, all archive types will be rebuilt.
$mt->rebuild(
BlogID => $blog_id,
EntryCallback => sub { print $_[0]->title, "\n" },
);
Or to provide a status indicator:
use MT::Entry;
my $total = MT::Entry->count({ blog_id => $blog_id });
my $i = 0;
local $| = 1;
$mt->rebuild(
BlogID => $blog_id,
EntryCallback => sub { printf "%d/%d\r", ++$i, $total },
);
print "\n";
This argument is optional; by default no callbacks are executed.
This argument is optional.
N entries in the
blog. For example, if you set this to 20 and do not provide an offset (see
Offset, below), the 20 most recent entries in the blog will be rebuilt.
This is only useful if you are rebuilding Individual archives.
This argument is optional; by default all entries will be rebuilt.
Limit, specifies the entry at which to start rebuilding
your individual entry archives. For example, if you set this to 10, and
set a Limit of 5 (see Limit, above), entries 10-14 (inclusive) will
be rebuilt. The offset starts at 0, and the ordering is reverse
chronological.
This is only useful if you are rebuilding Individual archives, and if you
are using Limit.
This argument is optional; by default all entries will be rebuilt, starting at the first entry.
Rebuilds a particular entry in your blog (and its dependencies, if specified).
%args can contain:
This argument is required.
This argument is optional; if not provided, the MT::Blog object will be loaded in rebuild_entry from the $entry->blog_id column of the MT::Entry object passed in. If you already have the MT::Blog object loaded, however, it makes sense to pass it in yourself, as it will skip one small step in rebuild_entry (loading the object).
If you supply this parameter with a true value, rebuild_indexes will rebuild: the archives for the next and previous entries, chronologically; all of the index templates; the archives for the next and previous daily, weekly, and monthly archives.
Rebuilds all of the index templates in your blog, or just one, if you use the Template argument (below). Only rebuilds templates that are set to be rebuilt automatically, unless you use the Force (below).
%args can contain:
Either this or BlogID is required.
Either this or Blog is required.
Note that if the template that you specify here is set to not rebuild automatically, you must specify the Force argument in order to force it to be rebuilt.
The default is 0 (do not rebuild such templates).
Sends all configured XML-RPC pings as a way of notifying other community sites that your blog has been updated.
%args can contain:
Either this or BlogID is required.
Either this or Blog is required.
set_language($tag)Loads the localization plugin for the language specified by $tag, which should be a valid and supported language tag--see supported_languages to obtain a list of supported languages.
The language is set on a global level, and affects error messages and all text in the administration system.
This method can be called as either a class method or an object method; in other words,
MT->set_language($tag)
will also work. However, the setting will still be global--it will not be specified to the $mt object.
The default setting--set when MT::new is called--is U.S. English. If a DefaultLanguage is set in mt.cfg, the default is then set to that language.
translate($str)Translates $str into the currently-set language (set by set_language), and returns the translated string.
Returns the language tag for the currently-set language.
Returns a reference to an associative array mapping language tags to their proper names. For example:
use MT;
my $langs = MT->supported_languages;
print map { $_ . " => " . $langs->{$_} . "\n" } keys %$langs;
Returns the version of MT (including any beta/alpha designations).
Returns the numeric version of MT (without any beta/alpha designations).
For example, if VERSION returned 2.5b1, version_number would
return 2.5.
On an error, all of the above methods return undef, and the error message
can be obtained by calling the method errstr on the class or the object
(depending on whether the method called was a class method or an instance
method).
For example, called on a class name:
my $mt = MT->new or die MT->errstr;
Or, called on an object:
$mt->rebuild(BlogID => $blog_id)
or die $mt->errstr;
Please see the file LICENSE in the Movable Type distribution.
Except where otherwise noted, MT is Copyright 2001, 2002 Benjamin Trott, ben@movabletype.org, and Mena Trott, mena@movabletype.org. All rights reserved.