1: <?php
2: /**
3: * The main entry point for the Kolab_Filter application.
4: *
5: * PHP version 5
6: *
7: * @category Kolab
8: * @package Kolab_Filter
9: * @author Gunnar Wrobel <wrobel@pardus.de>
10: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
11: * @link http://pear.horde.org/index.php?package=Kolab_Filter
12: */
13:
14: /** Setup default autoloading */
15: require_once 'Horde/Autoloader/Default.php';
16:
17: /**
18: * The main entry point for the Kolab_Filter application.
19: *
20: * Copyright 2010 Klarälvdalens Datakonsult AB
21: *
22: * See the enclosed file COPYING for license information (LGPL). If you did not
23: * receive this file, see
24: * http://www.horde.org/licenses/lgpl21.
25: *
26: * @category Kolab
27: * @package Kolab_Filter
28: * @author Gunnar Wrobel <wrobel@pardus.de>
29: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
30: * @link http://pear.horde.org/index.php?package=Kolab_Filter
31: */
32: class Horde_Kolab_Filter
33: {
34: /**
35: * The injector providing the dependencies for this application.
36: *
37: * @var Horde_Injector
38: */
39: private $_injector;
40:
41: public function __construct(Horde_Injector $injector = null)
42: {
43: if ($injector === null) {
44: $this->_injector = new Horde_Injector(new Horde_Injector_TopLevel());
45:
46: $this->_injector->bindFactory(
47: 'Horde_Log_Logger', 'Horde_Kolab_Filter_Factory', 'getLogger'
48: );
49: $this->_injector->bindFactory(
50: 'Horde_Kolab_Server_Composite', 'Horde_Kolab_Filter_Factory', 'getUserDb'
51: );
52: $this->_injector->bindImplementation(
53: 'Horde_Kolab_Filter_Temporary', 'Horde_Kolab_Filter_Temporary_File'
54: );
55: $this->_injector->setInstance(
56: 'Horde_Kolab_Filter', $this
57: );
58: } else {
59: $this->_injector = $injector;
60: }
61: }
62:
63: /**
64: * Run the mail filter.
65: *
66: * @param string $type The type of filtering to run (Incoming|Content).
67: */
68: public function main($type, $inh = STDIN, $transport = null)
69: {
70: /** Setup all configuration information */
71: /* $configuration = $this->_injector->getInstance('Horde_Kolab_Filter_Configuration'); */
72: /* $configuration->init(); */
73:
74: /** Now run the filter */
75: $filter = $this->_injector->getInstance('Horde_Kolab_Filter_' . $type);
76: $filter->init();
77: $filter->parse($inh, $transport);
78: }
79:
80: /**
81: * Return the connection to the user database.
82: *
83: * @return Horde_Kolab_Server_Composite The user DB handle.
84: */
85: public function getUserDb()
86: {
87: return $this->_injector->getInstance('Horde_Kolab_Server_Composite');
88: }
89: }