~ubuntu-branches/debian/squeeze/movabletype-opensource/squeeze

« back to all changes in this revision

Viewing changes to plugins/WidgetManager/php/function.mtwidgetmanager.php

  • Committer: Bazaar Package Importer
  • Author(s): Dominic Hargreaves
  • Date: 2008-06-13 23:28:40 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080613232840-ya4jfxv1jgl45a3d
Tags: 4.2~rc2-1
* New upstream release candidate
* Update Standards-Version (no changes)
* Ensure that schema upgrade message is always seen

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
function smarty_function_mtwidgetmanager($args, &$ctx) {
9
 
    $blog_id = $ctx->stash('blog_id');
10
 
    $widgetmanager = $args['name']; // Should we try to load is there's only one?
11
 
    if (!$widgetmanager) 
12
 
        return;
13
 
 
14
 
    if (! $config = widgetmanager_config($ctx)) 
15
 
        return;
16
 
 
17
 
    foreach (explode(",",$config['modulesets'][$widgetmanager]) as $template_id) {
18
 
      if ($template_id)
19
 
          $widget_source[] = $ctx->mt->fetch('mt:'.$template_id);
20
 
    }
21
 
    $source = '';
22
 
    if ($widget_source) {
23
 
        $source = implode('',$widget_source);
24
 
    }
25
 
    return $source;
26
 
}
27
 
 
28
 
function widgetmanager_config($ctx) {
29
 
    $config = $ctx->stash('widget-manager-config');
30
 
    if ($config)
31
 
        return $config;
32
 
    $blog_id = $ctx->stash('blog_id');
33
 
    $config = $ctx->mt->db->fetch_plugin_config('widget-manager', 'blog:' . $blog_id);
34
 
    if (!$config)
35
 
        $config = $ctx->mt->db->fetch_plugin_config('widget-manager');
36
 
 
37
 
    if ($config) {
38
 
        $ctx->stash('widget-manager-config', $config);
39
 
    }
40
 
    return $config;
41
 
}
42
 
?>