1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17: 18: 19: 20: 21: 22:
23: class IMP_Compose_Ui
24: {
25: 26: 27: 28: 29:
30: protected $_spellInit = false;
31:
32: 33: 34: 35: 36:
37: public function attachSpellChecker()
38: {
39: global $conf, $injector, $registry;
40:
41: if (empty($conf['spell']['driver'])) {
42: return false;
43: } elseif ($this->_spellInit) {
44: return true;
45: }
46:
47: if ($registry->getView() == Horde_Registry::VIEW_BASIC) {
48: $spell_img = '<span class="iconImg spellcheckImg"></span>';
49: $br = '<br />';
50: } else {
51: $spell_img = $br = '';
52: }
53:
54: $injector->getInstance('Horde_Core_Factory_Imple')->create('SpellChecker', array(
55: 'id' => 'spellcheck',
56: 'states' => array(
57: 'CheckSpelling' => $spell_img . $br . _("Check Spelling"),
58: 'Checking' => $spell_img . $br . _("Checking..."),
59: 'Error' => $spell_img . $br . _("Spell Check Failed"),
60: 'ResumeEdit' => $spell_img . $br . _("Resume Editing")
61: ),
62: 'targetId' => 'composeMessage'
63: ));
64:
65: $this->_spellInit = true;
66:
67: return true;
68: }
69:
70: 71: 72: 73: 74: 75:
76: public function passphraseDialog($type, $cacheid = null)
77: {
78: $params = array('onload' => true);
79:
80: switch ($type) {
81: case 'pgp':
82: $type = 'pgpPersonal';
83: break;
84:
85: case 'pgp_symm':
86: $params = array('symmetricid' => 'imp_compose_' . $cacheid);
87: $type = 'pgpSymmetric';
88: break;
89:
90: case 'smime':
91: $type = 'smimePersonal';
92: break;
93: }
94:
95: $GLOBALS['injector']->getInstance('Horde_Core_Factory_Imple')->create('IMP_Ajax_Imple_PassphraseDialog', array(
96: 'onload' => true,
97: 'params' => $params,
98: 'type' => $type
99: ));
100: }
101:
102: 103:
104: public function addIdentityJs()
105: {
106: global $injector, $page_output;
107:
108: $identities = array();
109: $identity = $injector->getInstance('IMP_Identity');
110:
111: $sigs = $identity->hasSignature(true);
112:
113: foreach (array_keys(iterator_to_array($identity)) as $ident) {
114: $sm = $identity->getValue(IMP_Mailbox::MBOX_SENT, $ident);
115:
116: $entry = array(
117:
118: 'sm_name' => $sm ? $sm->form_to : '',
119:
120: 'sm_save' => (bool)$identity->saveSentmail($ident),
121:
122: 'sm_display' => $sm ? $sm->display_html : '',
123:
124: 'bcc' => strval($identity->getBccAddresses($ident))
125: );
126:
127: if ($sigs) {
128: $sig = $identity->getSignature('text', $ident);
129: $html_sig = $identity->getSignature('html', $ident);
130: if (!strlen($html_sig) && strlen($sig)) {
131: $html_sig = IMP_Compose::text2html($sig);
132: }
133: $sig_dom = new Horde_Domhtml($html_sig, 'UTF-8');
134: $html_sig = '';
135: foreach ($sig_dom->getBody()->childNodes as $child) {
136: $html_sig .= $sig_dom->dom->saveXml($child);
137: }
138:
139: $entry['sig'] = trim($sig);
140: $entry['hsig'] = $html_sig;
141: }
142:
143: $identities[] = $entry;
144: }
145:
146: $page_output->addInlineJsVars(array(
147: 'ImpComposeBase.identities' => $identities
148: ));
149: }
150:
151: 152: 153: 154: 155: 156: 157: 158:
159: public function convertComposeText($data, $to)
160: {
161: switch ($to) {
162: case 'html':
163: return IMP_Compose::text2html($data);
164:
165: case 'text':
166: return $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter($data, 'Html2text', array(
167: 'wrap' => false
168: ));
169: }
170: }
171:
172: 173: 174: 175: 176: 177: 178: 179: 180: 181:
182: public function encryptList($default = null, $returnList = false)
183: {
184: global $conf, $injector, $prefs;
185:
186: if (is_null($default)) {
187: $default = $prefs->getValue('default_encrypt');
188: }
189:
190: $enc_opts = array();
191: $output = '';
192:
193: if (!empty($conf['gnupg']['path']) && $prefs->getValue('use_pgp')) {
194: $enc_opts += $injector->getInstance('IMP_Crypt_Pgp')->encryptList();
195: }
196:
197: if ($prefs->getValue('use_smime')) {
198: $enc_opts += $injector->getInstance('IMP_Crypt_Smime')->encryptList();
199: }
200:
201: if (!empty($enc_opts)) {
202: $enc_opts = array_merge(
203: array(IMP::ENCRYPT_NONE => _("None")),
204: $enc_opts
205: );
206: }
207:
208: if ($returnList) {
209: return $enc_opts;
210: }
211:
212: foreach ($enc_opts as $key => $val) {
213: $output .= '<option value="' . $key . '"' . (($default == $key) ? ' selected="selected"' : '') . '>' . $val . "</option>\n";
214: }
215:
216: return $output;
217: }
218:
219: }
220: