bergie / midcom

MVC framework for PHP and the Midgard content repository

This URL has Read+Write access

bergie (author)
Wed Jun 24 21:57:52 -0700 2009
commit  afd3f46b73d85a8d425b845a593a65afd8afb5e3
tree    681bcb7d31b4da4eaecb1c993c3ca2e01fde0dfd
parent  320e0614676db7a65372a5d321d02c570fde2668
midcom / midcom_core / services / uimessages.php
100644 116 lines (92 sloc) 2.516 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
/**
* @package midcom_core
* @author The Midgard Project, http://www.midgard-project.org
* @copyright The Midgard Project, http://www.midgard-project.org
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
*/
 
 /**
* UI Message interface
*
* @package midcom_core
*/
interface midcom_core_services_uimessages
{
    /**
* @param &$configuration Configuration for the current uimessage type
*/
    public function __construct(&$configuration = array());
    
    public function add($data);
    
    public function remove($key);
    
    public function get($key);
    
    public function store();
    
    public function has_messages();
    
    public function render($key = null);
    
    public function render_as($type = 'comet', $key = null);
 
    public function supports($type = 'comet');
}
 
/**
* UI Messages core class
*
* @package midcom_core
*/
class midcom_core_services_uimessages_baseclass
{
    public $implementation = null;
    private $configuration = array();
    
    public function __construct()
    {
        $this->load_configuration();
        
        $classname = null;
        $this->implementation =& $_MIDCOM->uimessages;
    }
    
    private function load_configuration()
    {
        $this->configuration = $_MIDCOM->configuration->get('uimessages_configuration');
        if (! is_array($this->configuration))
        {
            $this->configuration = array();
        }
    }
    
    public function add($data)
    {
        return $this->implementation->add($data);
    }
    
    public function store()
    {
        return $this->implementation->store();
    }
    
    public function has_messages()
    {
        return $this->implementation->has_messages();
    }
 
    public function can_view($user=null)
    {
        if ($_MIDCOM->context->mimetype === 'text/html')
        {
            return true;
        }
        
        return false;
    }
 
    public function render($key = null)
    {
        return $this->implementation->render($key);
    }
    
    public function render_as($type = 'comet', $key = null)
    {
        if ($this->supports($type))
        {
            return $this->implementation->render_as($type, $key);
        }
        
        return false;
    }
    
    public function supports($type = 'comet')
    {
        if ($this->implementation->supports($type))
        {
            return true;
        }
        
        return false;
    }
}
 
?>