1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17: 18: 19: 20: 21: 22:
23: abstract class IMP_Dynamic_Base
24: {
25: 26: 27:
28: public $indices;
29:
30: 31: 32:
33: public $js_conf = array();
34:
35: 36: 37:
38: public $js_context = array();
39:
40: 41: 42:
43: public $js_text = array();
44:
45: 46: 47:
48: public $title = '';
49:
50: 51: 52:
53: public $vars;
54:
55: 56: 57:
58: public $view;
59:
60: 61: 62:
63: protected $_pages = array(
64: 'header'
65: );
66:
67: 68:
69: public function __construct(Horde_Variables $vars)
70: {
71: global $page_output;
72:
73: $this->vars = $vars;
74: $this->view = $this->getEmptyView();
75:
76: $this->indices = new IMP_Indices_Mailbox($vars);
77:
78: $this->_addBaseVars();
79:
80: $page_output->addScriptPackage('IMP_Script_Package_DynamicBase');
81:
82: $mimecss = new Horde_Themes_Element('mime.css');
83: $page_output->addStylesheet($mimecss->fs, $mimecss->uri);
84:
85: $page_output->sidebar = $page_output->topbar = false;
86:
87: $this->_init();
88:
89: $page_output->addInlineJsVars(array(
90: 'DimpCore.conf' => $this->js_conf,
91: 'DimpCore.context' => $this->js_context,
92: 'DimpCore.text' => $this->js_text
93: ), array('top' => true));
94: }
95:
96: 97:
98: public function render()
99: {
100: foreach ($this->_pages as $val) {
101: echo $this->view->render($val);
102: }
103: }
104:
105: 106: 107: 108: 109:
110: public function getEmptyView()
111: {
112: $view = new Horde_View(array(
113: 'templatePath' => IMP_TEMPLATES . '/dynamic'
114: ));
115: $view->addHelper('Text');
116: $view->addHelper('IMP_Dynamic_Helper_Base');
117:
118: return $view;
119: }
120:
121: 122: 123:
124: protected function _addBaseVars()
125: {
126: global $prefs, $registry;
127:
128:
129: $this->js_conf = array_filter(array(
130:
131: 'URI_COMPOSE' => strval(IMP_Dynamic_Compose::url()->setRaw(true)),
132: 'URI_VIEW' => strval(Horde::url('view.php')->add(IMP_Contents_View::addToken())),
133:
134:
135: 'disable_compose' => !IMP_Compose::canCompose(),
136: 'pref_prefix' => hash(
137: (PHP_MINOR_VERSION >= 4) ? 'fnv132' : 'sha1',
138: $registry->getAuth() . '|' . $_SERVER['SERVER_NAME']
139: )
140: ));
141:
142: 143: 144: 145: 146: 147: 148:
149: $context = array(
150: 'ctx_contacts' => array(
151:
152: '_sub1' => new stdClass,
153: 'new' => _("New Message"),
154: 'add' => _("Add to Address Book"),
155: 'copy' => _("Copy to Clipboard")
156: ),
157: 'ctx_reply' => array(
158: 'reply' => _("To Sender"),
159: 'reply_all' => _("To All"),
160: 'reply_list' => _("To List")
161: )
162: );
163:
164: if ($registry->hasLink('mail/newEmailFilter')) {
165: $context['ctx_contacts']['addfilter'] = _("Create Filter");
166: }
167:
168:
169: $context['ctx_forward'] = array(
170: 'attach' => _("As Attachment"),
171: 'body' => _("In Body Text"),
172: 'both' => _("Attachment and Body Text"),
173: '_sep1' => null,
174: 'editasnew' => _("Edit as New"),
175: '_sep2' => null,
176: 'redirect' => _("Redirect")
177: );
178: if ($prefs->isLocked('forward_default')) {
179: unset(
180: $context['ctx_forward']['attach'],
181: $context['ctx_forward']['body'],
182: $context['ctx_forward']['both'],
183: $context['ctx_forward']['_sep1']
184: );
185: }
186:
187: $this->js_context = $context;
188:
189:
190: $this->js_text = array(
191: 'allparts_label' => _("Parts"),
192: 'emailcopy' => _("Your browser security settings don't permit direct access to the clipboard.") . "\n" . _("You need to either use the keyboard (Ctrl/Cmd + C) or right click on the selected address to access the Copy command."),
193: 'strip_warn' => _("Are you sure you wish to PERMANENTLY delete this attachment?"),
194: 'verify' => _("Verifying...")
195: );
196: }
197:
198: public static function url(array $opts = array())
199: {
200: throw new Exception('Missing implementation for url method.');
201: }
202:
203: 204:
205: abstract protected function _init();
206:
207: }
208: