function smarty_function_mtentrymore($args, &$ctx) { $entry = $ctx->stash('entry'); $text = $entry['entry_text_more']; $cb = $entry['entry_convert_breaks']; if (isset($args['convert_breaks'])) { $cb = $args['convert_breaks']; } elseif (!isset($cb)) { $blog = $ctx->stash('blog'); $cb = $blog['blog_convert_paras']; } if ($cb) { if ($cb == '1' || $cb == '__default__') { # alter EntryBody, EntryMore in the event that # we're doing convert breaks $cb = 'convert_breaks'; } require_once 'MTUtil.php'; $text = apply_text_filter($ctx, $text, $cb); } if (isset($args['words'])) { require_once "MTUtil.php"; return first_n_text($text, $args['words']); } else { if (preg_match('/\\smt:asset-id="\\d+"/', $text)) { require_once "MTUtil.php"; $text = asset_cleanup($text); } return $text; } }
function smarty_function_mtentryexcerpt($args, &$ctx) { // todo: needs work $e = $ctx->stash('entry'); if ($excerpt = $e->entry_excerpt) { if (!isset($args['convert_breaks']) || !$args['convert_breaks']) { return $excerpt; } $cb = 'convert_breaks'; return apply_text_filter($ctx, $excerpt, $cb); } elseif ($args['no_generate']) { return ''; } if (!isset($args['words'])) { $blog = $ctx->stash('blog'); $words = $blog->blog_words_in_excerpt; if (!isset($words) or empty($words)) { $words = 40; } $args['words'] = $words; } $excerpt = $ctx->tag('MTEntryBody', $args); if (!$excerpt) { return ''; } return $excerpt . '...'; }
function smarty_function_mtcommentbody($args, &$ctx) { $comment = $ctx->stash('comment'); $text = $comment->comment_text; $blog = $ctx->stash('blog'); if (!$blog->blog_allow_comment_html) { $text = strip_tags($text); } $cb = isset($args['convert_breaks']) ? $args['convert_breaks'] : $blog->blog_convert_paras_comments; if ($cb == '1' || $cb == '__default__') { $cb = 'convert_breaks'; } require_once 'MTUtil.php'; if ($cb != '0') { $text = apply_text_filter($ctx, $text, $cb); } if (isset($args['words'])) { require_once "MTUtil.php"; return first_n_text($text, $args['words']); } if ($blog->blog_autolink_urls) { $text = preg_replace('!(^|\\s|>)(https?://[^\\s<]+)!s', '$1<a href="$2">$2</a>', $text); } return $text; }
function smarty_modifier_filters($text, $filters) { // status: complete global $mt; $ctx =& $mt->context(); require_once 'MTUtil.php'; $text = apply_text_filter($ctx, $text, $filters); return $text; }
function _hdlr_customfield_value($args, &$ctx, $tag = null) { global $customfields_custom_handlers; $field = $ctx->stash('field'); $field or $field = $customfields_custom_handlers[$tag]; if (!$field) { return ''; } $obj = _hdlr_customfield_obj($ctx, $field['field_obj_type']); if (!isset($obj) || empty($obj)) { return ''; } $real_type = $field['field_obj_type']; if ($real_type == 'folder') { $real_type = 'category'; } elseif ($real_type == 'page') { $real_type = 'entry'; } $meta = $ctx->mt->db->get_meta($field['field_obj_type'], $obj[$real_type . '_id']); $text = $meta['field.' . $field['field_basename']]; if (preg_match('/\\smt:asset-id="\\d+"/', $text) && !$args['no_asset_cleanup']) { require_once "MTUtil.php"; $text = asset_cleanup($text); } if ($field['field_type'] == 'textarea') { $cb = $obj['entry_convert_breaks']; if (isset($args['convert_breaks'])) { $cb = $args['convert_breaks']; } elseif (!isset($cb)) { $blog = $ctx->stash('blog'); $cb = $blog['blog_convert_paras']; } if ($cb) { if ($cb == '1' || $cb == '__default__') { # alter EntryBody, EntryMore in the event that # we're doing convert breaks $cb = 'convert_breaks'; } require_once 'MTUtil.php'; $text = apply_text_filter($ctx, $text, $cb); } } if (array_key_exists('label', $args) && $args['label']) { $value_label = ''; $type_obj = $customfield_types[$field['field_type']]; if (array_key_exists('options_delimiter', $type_obj)) { $option_loop = array(); $expr = '\\s*' . preg_quote($type_obj['options_delimiter']) . '\\s*'; $options = preg_split('/' . $expr . '/', $field['field_options']); foreach ($options as $option) { $label = $option; if (preg_match('/=/', $option)) { list($option, $label) = preg_split('/\\s*=\\s*/', $option, 2); } if ($text == $option) { $value_label = $label; break; } } } $text = $value_label; } if ($field['field_type'] == 'datetime') { $text = preg_replace('/\\D/', '', $text); if ($text == '' or $text == '00000000') { return ''; } if (strlen($text) == 8) { $text .= '000000'; } $args['ts'] = $text; if ($field['field_options'] == 'date') { $args['format'] = '%x'; } elseif ($field['field_options'] == 'time') { $args['format'] = '%X'; } return $ctx->_hdlr_date($args, $ctx); } return $text; }