| | 3267 | =head2 MT->handler_to_coderef($handler[, $delayed]) |
|---|
| | 3268 | |
|---|
| | 3269 | Translates a registry handler signature into a Perl coderef. Handlers |
|---|
| | 3270 | are 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 | |
|---|
| | 3280 | When invoked with a '-E<gt>' operator, the subroutine is invoked as |
|---|
| | 3281 | a package method. |
|---|
| | 3282 | |
|---|
| | 3283 | When the handler is a string that starts with 'sub {', it is eval'd |
|---|
| | 3284 | to compile it, and the resulting coderef is returned. |
|---|
| | 3285 | |
|---|
| | 3286 | The coderef that is returned can be passed any parameters you wish. |
|---|
| | 3287 | |
|---|
| | 3288 | When the coderef is invoked, any component that was identified in |
|---|
| | 3289 | the handler signature becomes the active component when running the |
|---|
| | 3290 | code (this affects how strings are translated, and the search paths |
|---|
| | 3291 | for templates that are loaded). |
|---|
| | 3292 | |
|---|
| | 3293 | If the C<$delayed> parameter is given, a special coderef is constructed |
|---|
| | 3294 | that will delay the 'require' of the identified Perl package until |
|---|
| | 3295 | the coderef is actually invoked. |
|---|
| | 3296 | |
|---|
| | 3297 | =head2 MT->registry( @path ) |
|---|
| | 3298 | |
|---|
| | 3299 | Queries the Movable Type registry data structure for a given resource |
|---|
| | 3300 | path. The MT registry is a collection of hash structures that contain |
|---|
| | 3301 | resources MT and/or plugins can utilize. |
|---|
| | 3302 | |
|---|
| | 3303 | When this method is invoked, it actually issues a registry request |
|---|
| | 3304 | against each component registered with MT, then merges the resulting |
|---|
| | 3305 | hashes and returns them. See L<MT::Component> for further details. |
|---|
| | 3306 | |
|---|
| | 3307 | =head2 MT->component( $id ) |
|---|
| | 3308 | |
|---|
| | 3309 | Returns a loaded L<MT::Component> based on the requested C<$id> parameter. |
|---|
| | 3310 | For example: |
|---|
| | 3311 | |
|---|
| | 3312 | # Returns the MT 'core' component |
|---|
| | 3313 | MT->component('core'); |
|---|
| | 3314 | |
|---|
| | 3315 | =head2 MT->model( $id ) |
|---|
| | 3316 | |
|---|
| | 3317 | Returns a Perl package name for the MT object type identified by C<$id>. |
|---|
| | 3318 | For example: |
|---|
| | 3319 | |
|---|
| | 3320 | # Assigns (by default) 'MT::Blog' to $blog_class |
|---|
| | 3321 | my $blog_class = MT->model('blog'); |
|---|
| | 3322 | |
|---|
| | 3323 | It is a recommended practice to utilize the model method to derive the |
|---|
| | 3324 | implementation package name, instead of hardcoding Perl package names. |
|---|
| | 3325 | |
|---|
| | 3326 | =head2 MT->models( $id ) |
|---|
| | 3327 | |
|---|
| | 3328 | Returns a list of object types that are registered as sub-types. For |
|---|
| | 3329 | instance, the MT 'asset' object type has several sub-types associated |
|---|
| | 3330 | with it: |
|---|
| | 3331 | |
|---|
| | 3332 | my @types = MT->models('asset'); |
|---|
| | 3333 | # @types now contains ('asset', 'asset.image', 'asset.video', etc.) |
|---|
| | 3334 | |
|---|
| | 3410 | |
|---|
| | 3411 | =head2 $mt->rebuild_archives |
|---|
| | 3412 | |
|---|
| | 3413 | An alias to L<MT::WeblogPublisher::rebuild_archives>. See |
|---|
| | 3414 | L<MT::WeblogPublisher> for documentation of this method. |
|---|
| | 3415 | |
|---|
| | 3416 | =head2 $app->template_paths |
|---|
| | 3417 | |
|---|
| | 3418 | Returns an array of directory paths where application templates exist. |
|---|
| | 3419 | |
|---|
| | 3420 | =head2 $app->find_file(\@paths, $filename) |
|---|
| | 3421 | |
|---|
| | 3422 | Returns the path and filename for a file found in any of the given paths. |
|---|
| | 3423 | If the file cannot be found, it returns undef. |
|---|
| | 3424 | |
|---|
| | 3425 | =head2 $app->load_tmpl($file[, @params]) |
|---|
| | 3426 | |
|---|
| | 3427 | Loads a L<MT::Template> template using the filename specified. See the |
|---|
| | 3428 | documentation for the C<build_page> method to learn about how templates |
|---|
| | 3429 | are located. The optional C<@params> are passed to the L<MT::Template> |
|---|
| | 3430 | constructor. |
|---|
| | 3431 | |
|---|
| | 3432 | =head2 $app->set_default_tmpl_params($tmpl) |
|---|
| | 3433 | |
|---|
| | 3434 | Assigns standard parameters to the given L<MT::Template> C<$tmpl> object. |
|---|
| | 3435 | Refer to the L<STANDARD APPLICATION TEMPLATE PARAMETERS> section for a |
|---|
| | 3436 | complete list of these parameters. |
|---|
| | 3437 | |
|---|
| | 3438 | =head2 $app->charset( [$charset] ) |
|---|
| | 3439 | |
|---|
| | 3440 | Gets or sets the application's character set based on the "PublishCharset" |
|---|
| | 3441 | configuration 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 | |
|---|
| | 3446 | Builds an application page to be sent to the client; the page name is specified |
|---|
| | 3447 | in C<$tmpl_name>, which should be the name of a template containing valid |
|---|
| | 3448 | L<MT::Template> markup. C<\%param> is a hash ref whose keys and values will |
|---|
| | 3449 | be passed to L<MT::Template::param> for use in the template. |
|---|
| | 3450 | |
|---|
| | 3451 | On success, returns a scalar containing the page to be sent to the client. On |
|---|
| | 3452 | failure, returns C<undef>, and the error message can be obtained from |
|---|
| | 3453 | C<$app-E<gt>errstr>. |
|---|
| | 3454 | |
|---|
| | 3455 | =head3 How does build_page find a template? |
|---|
| | 3456 | |
|---|
| | 3457 | The C<build_page> function looks in several places for an app |
|---|
| | 3458 | template. Two configuration directives can modify these search paths, |
|---|
| | 3459 | and application and plugin code can also affect them. |
|---|
| | 3460 | |
|---|
| | 3461 | The I<TemplatePath> config directive is an absolute path to the directory |
|---|
| | 3462 | where MT's core application templates live. It defaults to the I<mt_dir> |
|---|
| | 3463 | plus an additional path segment of 'tmpl'. |
|---|
| | 3464 | |
|---|
| | 3465 | The optional I<AltTemplatePath> config directive is a path (absolute |
|---|
| | 3466 | or relative) to a directory where some 'override templates' may |
|---|
| | 3467 | live. An override template takes the place of one of MT's core |
|---|
| | 3468 | application templates, and is used interchangeably with the core |
|---|
| | 3469 | template. This allows power users to customize the look and feel of |
|---|
| | 3470 | the MT application. If I<AltTemplatePath> is relative, its base path |
|---|
| | 3471 | is the value of the Movable Type configuration file. |
|---|
| | 3472 | |
|---|
| | 3473 | Next, any application built on the C<MT::App> foundation can define |
|---|
| | 3474 | its own I<template_dir> parameter, which identifies a subdirectory of |
|---|
| | 3475 | TemplatePath (or AltTemplatePath) where that application's templates |
|---|
| | 3476 | can be found. I<template_dir> defaults to C<cms>. Most templates will |
|---|
| | 3477 | be found in this directory, but sometimes the template search will |
|---|
| | 3478 | fall through to the parent directory, where a default error template |
|---|
| | 3479 | is found, for example. I<template_dir> should rightly have been named |
|---|
| | 3480 | I<application_template_dir>, since it is application-specific. |
|---|
| | 3481 | |
|---|
| | 3482 | Finally, a plugin can specify its I<plugin_template_path>, which |
|---|
| | 3483 | locates a directory where the templates for that plugin's own |
|---|
| | 3484 | interface are found. If the I<plugin_template_path> is relative, it |
|---|
| | 3485 | may be relative to either the I<app_dir>, or the I<mt_dir>; the former |
|---|
| | 3486 | takes precedence if it exists. (for a definition of I<app_dir> and |
|---|
| | 3487 | I<mt_dir>, see L<MT>) |
|---|
| | 3488 | |
|---|
| | 3489 | Given 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 | |
|---|
| | 3505 | If a template with the given name is not found in any of these |
|---|
| | 3506 | locations, an ugly error is thrown to the user. |
|---|
| | 3507 | |
|---|
| | 3508 | =head2 $app->build_page_in_mem($tmpl, \%param) |
|---|
| | 3509 | |
|---|
| | 3510 | Used internally by the L<build_page> method to render the output |
|---|
| | 3511 | of a L<MT::Template> object (the first parameter) using the parameter |
|---|
| | 3512 | data (the second parameter). It additionally calls the L<process_mt_template> |
|---|
| | 3513 | method (to process any E<lt>MT_ACTIONE<gt> and E<lt>MT_X:YE<gt> marker tags) |
|---|
| | 3514 | and then L<translate_templatized> (to process any E<lt>MT_TRANSE<gt> tags). |
|---|
| | 3515 | |
|---|
| | 3516 | =head2 $app->process_mt_template($str) |
|---|
| | 3517 | |
|---|
| | 3518 | Processes the E<lt>__action<gt> tags that are present in C<$str>. These tags |
|---|
| | 3519 | are in the following format: |
|---|
| | 3520 | |
|---|
| | 3521 | <__action mode="mode_name" parameter="value"> |
|---|
| | 3522 | |
|---|
| | 3523 | The mode parameter is required (and must be the first attribute). The |
|---|
| | 3524 | following attributes are appended as regular query parameters. |
|---|
| | 3525 | |
|---|
| | 3526 | The MT_ACTION tag is a preferred way to specify application links rather |
|---|
| | 3527 | than using this syntax: |
|---|
| | 3528 | |
|---|
| | 3529 | <mt:var name="script_url">?__mode=mode_name¶meter=value |
|---|
| | 3530 | |
|---|
| | 3531 | C<process_mt_templates> also strips the C<$str> variable of any tags in |
|---|
| | 3532 | the format of C<E<lt>MT_\w+:\w+E<gt>>. These are 'marker' tags that are |
|---|
| | 3533 | used to identify specific portions of the template page and used in |
|---|
| | 3534 | conjunction with the transformer callback helper methods C<tmpl_prepend>, |
|---|
| | 3535 | C<tmpl_append>, C<tmpl_replace>, C<tmpl_select>. |
|---|
| | 3550 | |
|---|
| | 3551 | =head2 $mt->commenter_authenticator($id) |
|---|
| | 3552 | |
|---|
| | 3553 | Returns a specific comment authenication option using the identifier |
|---|
| | 3554 | C<$id> parameter. |
|---|
| | 3555 | |
|---|
| | 3556 | =head2 $mt->commenter_authenticators() |
|---|
| | 3557 | |
|---|
| | 3558 | Returns the available comment authentication identifiers that are |
|---|
| | 3559 | installed in the MT registry. |
|---|
| | 3560 | |
|---|
| | 3561 | =head2 $mt->core_commenter_authenticators() |
|---|
| | 3562 | |
|---|
| | 3563 | A method that returns the MT-supplied comment authentication registry |
|---|
| | 3564 | data. |
|---|
| | 3565 | |
|---|
| | 3566 | =head2 $mt->init_commenter_authenticators() |
|---|
| | 3567 | |
|---|
| | 3568 | Initializes the list of installed MT comment authentication options, |
|---|
| | 3569 | drawing from the MT registry. |
|---|
| | 3570 | |
|---|
| | 3571 | =head2 $mt->captcha_provider($id) |
|---|
| | 3572 | |
|---|
| | 3573 | Returns a specific CAPTCHA provider configuration using the identifier |
|---|
| | 3574 | C<$id> parameter. This is a convenience method that accesses the CAPTCHA |
|---|
| | 3575 | providers installed into the MT registry. |
|---|
| | 3576 | |
|---|
| | 3577 | =head2 $mt->captcha_providers() |
|---|
| | 3578 | |
|---|
| | 3579 | Returns the available CAPTCHA providers. This is a convenience method |
|---|
| | 3580 | that accesses the MT registry for available CAPTCHA providers (it also |
|---|
| | 3581 | invokes the 'condition' key for each provider to filter the list). |
|---|
| | 3582 | |
|---|
| | 3583 | =head2 $mt->core_captcha_providers() |
|---|
| | 3584 | |
|---|
| | 3585 | A method that returns the MT-supplied CAPTCHA provider registry data. |
|---|
| | 3586 | |
|---|
| | 3587 | =head2 $mt->init_captcha_providers() |
|---|
| | 3588 | |
|---|
| | 3589 | Initializes the list of installed CAPTCHA providers, drawing from |
|---|
| | 3590 | the MT registry. |
|---|
| | 3591 | |
|---|
| | 3592 | =head2 $mt->effective_captcha_provider() |
|---|
| | 3593 | |
|---|
| | 3594 | Returns the Perl package name for the configured CAPTCHA provider. |
|---|
| | 3595 | |
|---|
| | 3596 | =head2 $app->static_path() |
|---|
| | 3597 | |
|---|
| | 3598 | Returns the application's static web path. |
|---|
| | 3599 | |
|---|
| | 3600 | =head2 $app->static_file_path() |
|---|
| | 3601 | |
|---|
| | 3602 | Returns the application's static file path. |
|---|
| | 3603 | |
|---|
| | 3604 | =head2 MT::core_upload_file_to_sync |
|---|
| | 3605 | |
|---|
| | 3606 | A MT callback handler routine that forwards to the L<upload_file_to_sync> |
|---|
| | 3607 | method. |
|---|
| | 3608 | |
|---|
| | 3609 | =head2 MT->upload_file_to_sync(%param) |
|---|
| | 3610 | |
|---|
| | 3611 | A routine that will make record of a file that is to be transmitted |
|---|
| | 3612 | to one or more servers (typically via rsync). This method runs when |
|---|
| | 3613 | the C<SyncTarget> MT configuration setting is configured. Normally |
|---|
| | 3614 | published files are automatically processed for syncing operations, |
|---|
| | 3615 | but this routine is used for files that are created through other |
|---|
| | 3616 | means, such as uploading an asset. |
|---|
| | 3617 | |
|---|
| | 3618 | =head2 MT->help_url( [ $suffix ] ) |
|---|
| | 3619 | |
|---|
| | 3620 | Returns a help URL for the application. This method is used to construct |
|---|
| | 3621 | the URL directing users to online documentation. If called without any |
|---|
| | 3622 | parameters, it returns the base URL for providing help. If a parameter is |
|---|
| | 3623 | given, the URL is appended with the given subpath. The base URL by default |
|---|
| | 3624 | is 'http://www.movabletype.org/documentation/'. This string is passed |
|---|
| | 3625 | through MT's localization modules, so it can be changed on a per-language |
|---|
| | 3626 | basis. The C<$suffix> parameter, however, is always appended to this base URL. |
|---|
| | 3627 | |
|---|
| | 3628 | =head2 MT->get_timer |
|---|
| | 3629 | |
|---|
| | 3630 | Returns an instance of L<MT::Util::ReqTimer> for use in timing MT's |
|---|
| | 3631 | operations. |
|---|
| | 3632 | |
|---|
| | 3633 | =head2 MT->log_times |
|---|
| | 3634 | |
|---|
| | 3635 | Used as part of Movable Type's performance logging framework. This method |
|---|
| | 3636 | is called internally, once at the startup of Movable Type, and once as it |
|---|
| | 3637 | is shutting down. |
|---|
| | 3638 | |
|---|
| | 3639 | =head2 MT->time_this($string, $code) |
|---|
| | 3640 | |
|---|
| | 3641 | Utility method to time a particular routine. This will log the execution |
|---|
| | 3642 | time of the C<$code> coderef with the identifying phrase C<$string> using |
|---|
| | 3643 | MT's performance logging framework. |
|---|
| | 3644 | |
|---|
| | 3645 | =head2 MT::refresh_cache($cb) |
|---|
| | 3646 | |
|---|
| | 3647 | A callback handler that invalidates the cache of MT's caching driver. |
|---|
| | 3648 | See L<MT::Cache::Negotiate>. |
|---|
| | 3649 | |
|---|
| | 3650 | =head2 MT->register_refresh_cache_event($callback) |
|---|
| | 3651 | |
|---|
| | 3652 | Registers a callback that will cause the MT cache to invalidate itself. |
|---|
| | 3653 | See L<MT::Cache::Negotiate>. |
|---|