| 1 | <?php |
|---|
| 2 | # Movable Type (r) Open Source (C) 2001-2008 Six Apart, Ltd. |
|---|
| 3 | # This program is distributed under the terms of the |
|---|
| 4 | # GNU General Public License, version 2. |
|---|
| 5 | # |
|---|
| 6 | # $Id$ |
|---|
| 7 | |
|---|
| 8 | require_once("function.mtinclude.php"); |
|---|
| 9 | function smarty_function_mtwidgetmanager($args, &$ctx) { |
|---|
| 10 | $blog_id = $args['blog_id']; |
|---|
| 11 | $blog_id or $blog_id = $ctx->stash('blog_id'); |
|---|
| 12 | $blog_id or $blog_id = 0; |
|---|
| 13 | $widgetmanager = $args['name']; // Should we try to load is there's only one? |
|---|
| 14 | if (!$widgetmanager) |
|---|
| 15 | return; |
|---|
| 16 | |
|---|
| 17 | $tmpl = $ctx->mt->db->get_template_text($ctx, $widgetmanager, $blog_id, 'widgetset', $args['global']); |
|---|
| 18 | if ( !isset($tmpl) || !$tmpl ) { |
|---|
| 19 | # TODO: doing save_widgetset should write template text |
|---|
| 20 | # error status for now to see if there is any pattern |
|---|
| 21 | # that requires to consturct includes from template meta (modulesets). |
|---|
| 22 | return $ctx->error($ctx->mt->translate('Error: widgetset [_1] is empty.', $widgetmanager)); |
|---|
| 23 | } |
|---|
| 24 | if ( isset($tmpl) && $tmpl ) { |
|---|
| 25 | // push to ctx->vars |
|---|
| 26 | $ext_args = array(); |
|---|
| 27 | while(list ($key, $val) = each($args)) { |
|---|
| 28 | if (!preg_match('/(^name$|^blog_id$)/', $key)) { |
|---|
| 29 | require_once("function.mtsetvar.php"); |
|---|
| 30 | smarty_function_mtsetvar(array('name' => $key, 'value' => $val), $ctx); |
|---|
| 31 | $ext_args[] = $key; |
|---|
| 32 | } |
|---|
| 33 | } |
|---|
| 34 | if ($ctx->_compile_source('evaluated template', $tmpl, $_var_compiled)) { |
|---|
| 35 | ob_start(); |
|---|
| 36 | $ctx->_eval('?>' . $_var_compiled); |
|---|
| 37 | $_contents = ob_get_contents(); |
|---|
| 38 | ob_end_clean(); |
|---|
| 39 | _clear_vars($ctx, $ext_args); |
|---|
| 40 | return $_contents; |
|---|
| 41 | } |
|---|
| 42 | else { |
|---|
| 43 | _clear_vars($ctx, $ext_args); |
|---|
| 44 | return $ctx->error($ctx->mt->translate('Error compiling widgetset [_1]', $widgetmanager)); |
|---|
| 45 | } |
|---|
| 46 | } |
|---|
| 47 | return ''; |
|---|
| 48 | } |
|---|
| 49 | ?> |
|---|
| 50 | |
|---|