Esempio n. 1
0
<?php

# Movable Type (r) (C) 2001-2015 Six Apart, Ltd. All Rights Reserved.
# This code cannot be redistributed without permission from www.sixapart.com.
# For more information, consult your Movable Type license.
#
# $Id$
require_once 'class.baseobject.php';
BaseObject::install_meta('blog', 'allow_anon_recommend', 'vinteger');
# Because it's hard to map tags back to their fields, we store them in a hash
global $customfields_custom_handlers;
$customfields_custom_handlers = array();
$dynamic_functions = '';
# Loop through fields and register the custom template tag handlers
require_once 'class.baseobject.php';
require_once 'class.mt_field.php';
$fld = new Field();
$fields = $fld->Find('1 = 1');
if (!empty($fields)) {
    foreach ($fields as $field) {
        $tag_name = strtolower($field->field_tag);
        $customfields_custom_handlers[$tag_name] = $field;
        $col_type = $customfield_types[$field->field_type]['column_def'];
        if ($col_type) {
            BaseObject::install_meta($field->field_obj_type, 'field.' . $field->field_basename, $col_type);
        }
        $fn_name = $field->field_id;
        $dynamic_functions .= <<<CODE
function customfield_{$fn_name}(\$args, &\$ctx) {
    return _hdlr_customfield_value(\$args, \$ctx, '{$tag_name}');
}
CODE;
        $ctx->add_tag($tag_name, 'customfield_' . $fn_name);
        if (preg_match('/^video|image|file|audio/', $field->field_type)) {
            $dynamic_functions .= <<<CODE
function customfield_asset_{$fn_name}(\$args, \$content, &\$ctx, &\$repeat) {
    return _hdlr_customfield_asset(\$args, \$content, \$ctx, \$repeat, '{$tag_name}');
}
CODE;
            $ctx->add_container_tag($tag_name . $field->type, 'customfield_asset_' . $fn_name);