Changeset 2744

Show
Ignore:
Timestamp:
07/10/08 01:38:26 (12 months ago)
Author:
bchoate
Message:

Updated POD for MT module.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/release-41/lib/MT.pm.pre

    r2667 r2744  
    330330    my $pkg = shift; 
    331331 
    332     # if (!ref $pkg) { 
    333     #     return $pkg->instance->registry(@_); 
    334     # } 
    335332    require MT::Component; 
    336333    my $regs = MT::Component->registry(@_); 
     
    28292826=back 
    28302827 
    2831 =head2 $mt->init 
     2828=head2 $mt->init(%params) 
    28322829 
    28332830Initializes the Movable Type instance, including registration of basic 
     
    28352832and C<init_plugins> methods. 
    28362833 
     2834=head2 $mt->init_core() 
     2835 
     2836A method that the base MT class uses to initialize all the 'core' 
     2837functionality of Movable Type. If you want to subclass MT and extensively 
     2838modify it's core behavior, this method can be overridden to do that. 
     2839The L<MT::Core> module is a L<MT::Component> that defines the core 
     2840features of MT, and this method loads that component. Non-core components 
     2841are loaded by the L<init_addons> method. 
     2842 
     2843=head2 $mt->init_paths() 
     2844 
     2845Establishes some key file paths for the MT environment. Assigns 
     2846C<$MT_DIR>, C<$APP_DIR> and C<$CFG_FILE> package variables. 
     2847 
     2848=head2 $mt->init_permissions() 
     2849 
     2850Loads the L<MT::Permission> class and runs the 
     2851MT::Permission->init_permissions method to establish system permissions. 
     2852 
     2853=head2 $mt->init_schema() 
     2854 
     2855Completes the initialization of the Movable Type schema following the 
     2856loading of plugins. After this method runs, any MT object class may 
     2857safely be used. 
     2858 
    28372859=head2 MT->instance 
    28382860 
     
    28412863MT->new() is now an alias to instance_of. 
    28422864 
     2865=head2 MT->app 
     2866 
     2867An alias for the 'instance' method. 
     2868 
    28432869=head2 $class->instance_of 
    28442870 
     
    28532879Assigns the active MT instance object. This value is returned when 
    28542880C<MT-E<gt>instance> is invoked. 
     2881 
     2882=head2 MT->run_app( $pkg, $params ) 
     2883 
     2884Instantiates and runs a MT application (identified by C<$pkg>), passing 
     2885the C<$params> hashref as the parameters to the constructor method. This 
     2886method is a self-contained version found in L<MT::Bootstrap> and will 
     2887eventually be the manner in which MT applications are run (eliminating 
     2888the need for the bootstrap module). The MT::import module calls this 
     2889method when the MT module is used with an 'App' parameter. So, you can 
     2890write a mt.cgi script that looks like this: 
     2891 
     2892    #!/usr/bin/perl 
     2893    use strict; 
     2894    use lib $ENV{MT_HOME} ? "$ENV{MT_HOME}/lib" : 'lib'; 
     2895    use MT App => 'MT::App::CMS'; 
    28552896 
    28562897=head2 $mt->find_config($params) 
     
    28632904=head2 $mt->init_config($params) 
    28642905 
    2865 Reads the MT configuration settingss from the MT configuration file 
    2866 and settings from database (L<MT::Config>). 
     2906Reads the MT configuration settingss from the MT configuration file. 
    28672907 
    28682908The C<$params> parameter is a reference to the hash of settings passed to 
    28692909the MT constructor. 
    28702910 
    2871 =head2 $mt->init_plugins 
     2911=head2 $mt->init_config_from_db($param) 
     2912 
     2913Reads any MT configuration settings from the MT database (L<MT::Config>). 
     2914 
     2915The C<$params> parameter is a reference to the hash of settings passed to 
     2916the MT constructor. 
     2917 
     2918=head2 $mt->init_addons(%param) 
     2919 
     2920Loads any discoverable addons that are available. This is called from 
     2921the C<init> method, after C<init_config> method has loaded the 
     2922configuration settings, but prior to making a database connection. 
     2923 
     2924=head2 $mt->init_plugins(%param) 
    28722925 
    28732926Loads any discoverable plugins that are available. This is called from 
     
    28752928configuration settings. 
    28762929 
    2877 =head2 $mt->init_tasks 
     2930=head2 $mt->init_callbacks() 
     2931 
     2932Installs any MT callbacks. This is called from the C<init> method very, 
     2933early; prior to loading any addons or plugins. 
     2934 
     2935=head2 $mt->init_tasks() 
    28782936 
    28792937Registers the standard set of periodic tasks that Movable Type provides 
     
    28852943through L<MT::TaskMgr> to run any registered tasks that are pending 
    28862944execution. See L<MT::TaskMgr> for further documentation. 
     2945 
     2946=head2 MT->find_addons( $type ) 
     2947 
     2948Returns an array of all 'addons' that are found within the MT 'addons' 
     2949directory of the given C<$type>. What is returned is an array reference 
     2950of hash data. Each hash will contain these elements: 'label' (the name 
     2951of the addon), 'id' (the unique identifier of the addon), 'envelope' 
     2952(the subpath of the addon, relative to the MT home directory), and 'path' 
     2953(the full path to the addon subdirectory). 
    28872954 
    28882955=head2 MT->unplug 
     
    31983265C<callback_error> routine. 
    31993266 
     3267=head2 MT->handler_to_coderef($handler[, $delayed]) 
     3268 
     3269Translates a registry handler signature into a Perl coderef. Handlers 
     3270are in one of the following forms: 
     3271 
     3272    $<COMPONENTID>::<PERL_PACKAGE>::<SUBROUTINE> 
     3273 
     3274    <PERL_PACKAGE>::<SUBROUTINE> 
     3275 
     3276    <PERL_PACKAGE>-><SUBROUTINE> 
     3277 
     3278    sub { ... } 
     3279 
     3280When invoked with a '-E<gt>' operator, the subroutine is invoked as 
     3281a package method. 
     3282 
     3283When the handler is a string that starts with 'sub {', it is eval'd 
     3284to compile it, and the resulting coderef is returned. 
     3285 
     3286The coderef that is returned can be passed any parameters you wish. 
     3287 
     3288When the coderef is invoked, any component that was identified in 
     3289the handler signature becomes the active component when running the 
     3290code (this affects how strings are translated, and the search paths 
     3291for templates that are loaded). 
     3292 
     3293If the C<$delayed> parameter is given, a special coderef is constructed 
     3294that will delay the 'require' of the identified Perl package until 
     3295the coderef is actually invoked. 
     3296 
     3297=head2 MT->registry( @path ) 
     3298 
     3299Queries the Movable Type registry data structure for a given resource 
     3300path. The MT registry is a collection of hash structures that contain 
     3301resources MT and/or plugins can utilize. 
     3302 
     3303When this method is invoked, it actually issues a registry request 
     3304against each component registered with MT, then merges the resulting 
     3305hashes and returns them. See L<MT::Component> for further details. 
     3306 
     3307=head2 MT->component( $id ) 
     3308 
     3309Returns a loaded L<MT::Component> based on the requested C<$id> parameter. 
     3310For example: 
     3311 
     3312    # Returns the MT 'core' component 
     3313    MT->component('core'); 
     3314 
     3315=head2 MT->model( $id ) 
     3316 
     3317Returns a Perl package name for the MT object type identified by C<$id>. 
     3318For example: 
     3319 
     3320    # Assigns (by default) 'MT::Blog' to $blog_class 
     3321    my $blog_class = MT->model('blog'); 
     3322 
     3323It is a recommended practice to utilize the model method to derive the 
     3324implementation package name, instead of hardcoding Perl package names. 
     3325 
     3326=head2 MT->models( $id ) 
     3327 
     3328Returns a list of object types that are registered as sub-types. For 
     3329instance, the MT 'asset' object type has several sub-types associated 
     3330with it: 
     3331 
     3332    my @types = MT->models('asset'); 
     3333    # @types now contains ('asset', 'asset.image', 'asset.video', etc.) 
     3334 
    32003335=head2 MT->product_code 
    32013336 
     
    32143349and C<version_number> methods as they report the API version information. 
    32153350 
     3351=head2 MT->VERSION 
     3352 
     3353Returns the API version of MT. When using the MT module with the version 
     3354requirement, this method will also load the suitable API 'compatibility' 
     3355module, if available. For instance, if your plugin declares: 
     3356 
     3357    use MT 4; 
     3358 
     3359Then, once MT 5 is available, that statement will cause the C<VERSION> method 
     3360to attempt to load a module named "MT::Compat::v4". This module would contain 
     3361compatibility support for MT 4-based plugins. 
     3362 
    32163363=head2 MT->version_id 
    32173364 
     
    32283375Returns the version of the MT database schema. 
    32293376 
     3377=head2 $mt->id 
     3378 
     3379Provides an identifier for the application, one that relates to the 
     3380'application' paths of the MT registry. This method may be overridden 
     3381for any subclass of MT to provide the appropriate identifier. By 
     3382default, the base 'id' method will return an id taken from the 
     3383Perl package name, by stripping off any 'MT::App::' prefix, and lowercasing 
     3384the remaining string. 
     3385 
    32303386=head2 MT->version_slug 
    32313387 
     
    32523408An alias to L<MT::WeblogPublisher::rebuild_indexes>. See 
    32533409L<MT::WeblogPublisher> for documentation of this method. 
     3410 
     3411=head2 $mt->rebuild_archives 
     3412 
     3413An alias to L<MT::WeblogPublisher::rebuild_archives>. See 
     3414L<MT::WeblogPublisher> for documentation of this method. 
     3415 
     3416=head2 $app->template_paths 
     3417 
     3418Returns an array of directory paths where application templates exist. 
     3419 
     3420=head2 $app->find_file(\@paths, $filename) 
     3421 
     3422Returns the path and filename for a file found in any of the given paths. 
     3423If the file cannot be found, it returns undef. 
     3424 
     3425=head2 $app->load_tmpl($file[, @params]) 
     3426 
     3427Loads a L<MT::Template> template using the filename specified. See the 
     3428documentation for the C<build_page> method to learn about how templates 
     3429are located. The optional C<@params> are passed to the L<MT::Template> 
     3430constructor. 
     3431 
     3432=head2 $app->set_default_tmpl_params($tmpl) 
     3433 
     3434Assigns standard parameters to the given L<MT::Template> C<$tmpl> object. 
     3435Refer to the L<STANDARD APPLICATION TEMPLATE PARAMETERS> section for a 
     3436complete list of these parameters. 
     3437 
     3438=head2 $app->charset( [$charset] ) 
     3439 
     3440Gets or sets the application's character set based on the "PublishCharset" 
     3441configuration setting or the encoding of the active language 
     3442(C<$app-E<gt>current_language>). 
     3443 
     3444=head2 $app->build_page($tmpl_name, \%param) 
     3445 
     3446Builds an application page to be sent to the client; the page name is specified 
     3447in C<$tmpl_name>, which should be the name of a template containing valid 
     3448L<MT::Template> markup. C<\%param> is a hash ref whose keys and values will 
     3449be passed to L<MT::Template::param> for use in the template. 
     3450 
     3451On success, returns a scalar containing the page to be sent to the client. On 
     3452failure, returns C<undef>, and the error message can be obtained from 
     3453C<$app-E<gt>errstr>. 
     3454 
     3455=head3 How does build_page find a template? 
     3456 
     3457The C<build_page> function looks in several places for an app 
     3458template. Two configuration directives can modify these search paths, 
     3459and application and plugin code can also affect them. 
     3460 
     3461The I<TemplatePath> config directive is an absolute path to the directory 
     3462where MT's core application templates live. It defaults to the I<mt_dir> 
     3463plus an additional path segment of 'tmpl'. 
     3464 
     3465The optional I<AltTemplatePath> config directive is a path (absolute 
     3466or relative) to a directory where some 'override templates' may 
     3467live. An override template takes the place of one of MT's core 
     3468application templates, and is used interchangeably with the core 
     3469template. This allows power users to customize the look and feel of 
     3470the MT application. If I<AltTemplatePath> is relative, its base path 
     3471is the value of the Movable Type configuration file. 
     3472 
     3473Next, any application built on the C<MT::App> foundation can define 
     3474its own I<template_dir> parameter, which identifies a subdirectory of 
     3475TemplatePath (or AltTemplatePath) where that application's templates 
     3476can be found. I<template_dir> defaults to C<cms>. Most templates will 
     3477be found in this directory, but sometimes the template search will 
     3478fall through to the parent directory, where a default error template 
     3479is found, for example. I<template_dir> should rightly have been named 
     3480I<application_template_dir>, since it is application-specific. 
     3481 
     3482Finally, a plugin can specify its I<plugin_template_path>, which 
     3483locates a directory where the templates for that plugin's own 
     3484interface are found. If the I<plugin_template_path> is relative, it 
     3485may be relative to either the I<app_dir>, or the I<mt_dir>; the former 
     3486takes precedence if it exists. (for a definition of I<app_dir> and 
     3487I<mt_dir>, see L<MT>) 
     3488 
     3489Given these values, the order of search is as follows: 
     3490 
     3491=over 4 
     3492 
     3493=item * I<plugin_template_path> 
     3494 
     3495=item * I<AltTemplatePath> 
     3496 
     3497=item * I<AltTemplatePath>F</>I<template_dir> 
     3498 
     3499=item * I<TemplatePath>/I<template_dir> 
     3500 
     3501=item * I<TemplatePath> 
     3502 
     3503=back 
     3504 
     3505If a template with the given name is not found in any of these 
     3506locations, an ugly error is thrown to the user. 
     3507 
     3508=head2 $app->build_page_in_mem($tmpl, \%param) 
     3509 
     3510Used internally by the L<build_page> method to render the output 
     3511of a L<MT::Template> object (the first parameter) using the parameter 
     3512data (the second parameter). It additionally calls the L<process_mt_template> 
     3513method (to process any E<lt>MT_ACTIONE<gt> and E<lt>MT_X:YE<gt> marker tags) 
     3514and then L<translate_templatized> (to process any E<lt>MT_TRANSE<gt> tags). 
     3515 
     3516=head2 $app->process_mt_template($str) 
     3517 
     3518Processes the E<lt>__action<gt> tags that are present in C<$str>. These tags 
     3519are in the following format: 
     3520 
     3521    <__action mode="mode_name" parameter="value"> 
     3522 
     3523The mode parameter is required (and must be the first attribute). The 
     3524following attributes are appended as regular query parameters. 
     3525 
     3526The MT_ACTION tag is a preferred way to specify application links rather 
     3527than using this syntax: 
     3528 
     3529    <mt:var name="script_url">?__mode=mode_name&parameter=value 
     3530 
     3531C<process_mt_templates> also strips the C<$str> variable of any tags in 
     3532the format of C<E<lt>MT_\w+:\w+E<gt>>. These are 'marker' tags that are 
     3533used to identify specific portions of the template page and used in 
     3534conjunction with the transformer callback helper methods C<tmpl_prepend>, 
     3535C<tmpl_append>, C<tmpl_replace>, C<tmpl_select>. 
    32543536 
    32553537=head2 $mt->build_email($file, $param) 
     
    32663548entry that is scheduled for publishing. The return value is the timestamp 
    32673549in UTC time in the format "YYYY-MM-DDTHH:MM:SSZ". 
     3550 
     3551=head2 $mt->commenter_authenticator($id) 
     3552 
     3553Returns a specific comment authenication option using the identifier 
     3554C<$id> parameter. 
     3555 
     3556=head2 $mt->commenter_authenticators() 
     3557 
     3558Returns the available comment authentication identifiers that are 
     3559installed in the MT registry. 
     3560 
     3561=head2 $mt->core_commenter_authenticators() 
     3562 
     3563A method that returns the MT-supplied comment authentication registry 
     3564data. 
     3565 
     3566=head2 $mt->init_commenter_authenticators() 
     3567 
     3568Initializes the list of installed MT comment authentication options, 
     3569drawing from the MT registry. 
     3570 
     3571=head2 $mt->captcha_provider($id) 
     3572 
     3573Returns a specific CAPTCHA provider configuration using the identifier 
     3574C<$id> parameter. This is a convenience method that accesses the CAPTCHA 
     3575providers installed into the MT registry. 
     3576 
     3577=head2 $mt->captcha_providers() 
     3578 
     3579Returns the available CAPTCHA providers. This is a convenience method 
     3580that accesses the MT registry for available CAPTCHA providers (it also 
     3581invokes the 'condition' key for each provider to filter the list). 
     3582 
     3583=head2 $mt->core_captcha_providers() 
     3584 
     3585A method that returns the MT-supplied CAPTCHA provider registry data. 
     3586 
     3587=head2 $mt->init_captcha_providers() 
     3588 
     3589Initializes the list of installed CAPTCHA providers, drawing from 
     3590the MT registry. 
     3591 
     3592=head2 $mt->effective_captcha_provider() 
     3593 
     3594Returns the Perl package name for the configured CAPTCHA provider. 
     3595 
     3596=head2 $app->static_path() 
     3597 
     3598Returns the application's static web path. 
     3599 
     3600=head2 $app->static_file_path() 
     3601 
     3602Returns the application's static file path. 
     3603 
     3604=head2 MT::core_upload_file_to_sync 
     3605 
     3606A MT callback handler routine that forwards to the L<upload_file_to_sync> 
     3607method. 
     3608 
     3609=head2 MT->upload_file_to_sync(%param) 
     3610 
     3611A routine that will make record of a file that is to be transmitted 
     3612to one or more servers (typically via rsync). This method runs when 
     3613the C<SyncTarget> MT configuration setting is configured. Normally 
     3614published files are automatically processed for syncing operations, 
     3615but this routine is used for files that are created through other 
     3616means, such as uploading an asset. 
     3617 
     3618=head2 MT->help_url( [ $suffix ] ) 
     3619 
     3620Returns a help URL for the application. This method is used to construct 
     3621the URL directing users to online documentation. If called without any 
     3622parameters, it returns the base URL for providing help. If a parameter is 
     3623given, the URL is appended with the given subpath. The base URL by default 
     3624is 'http://www.movabletype.org/documentation/'. This string is passed 
     3625through MT's localization modules, so it can be changed on a per-language 
     3626basis. The C<$suffix> parameter, however, is always appended to this base URL. 
     3627 
     3628=head2 MT->get_timer 
     3629 
     3630Returns an instance of L<MT::Util::ReqTimer> for use in timing MT's 
     3631operations. 
     3632 
     3633=head2 MT->log_times 
     3634 
     3635Used as part of Movable Type's performance logging framework. This method 
     3636is called internally, once at the startup of Movable Type, and once as it 
     3637is shutting down. 
     3638 
     3639=head2 MT->time_this($string, $code) 
     3640 
     3641Utility method to time a particular routine. This will log the execution 
     3642time of the C<$code> coderef with the identifying phrase C<$string> using 
     3643MT's performance logging framework. 
     3644 
     3645=head2 MT::refresh_cache($cb) 
     3646 
     3647A callback handler that invalidates the cache of MT's caching driver. 
     3648See L<MT::Cache::Negotiate>. 
     3649 
     3650=head2 MT->register_refresh_cache_event($callback) 
     3651 
     3652Registers a callback that will cause the MT cache to invalidate itself. 
     3653See L<MT::Cache::Negotiate>. 
    32683654 
    32693655=head1 ERROR HANDLING