[dev] IMP login template...
Marko Djukic
marko at oblo.com
Sat Jul 26 08:20:50 PDT 2003
Quoting Nuno Loureiro <nuno at co.sapo.pt>:
> Here's the first patch for converting IMP to Horde Templates...
> Attached is the diff against HEAD and the new file
> (imp/templates/login/login.html).
>
> I did some tests with ab with and without Horde Templates, and concluded
> the overhead of using Horde Templates is about 15% (on this specific
> page).
this does sound a bit too much, but just looking briefly at the template setting
up code it does look like it can be optimised a bit too, eg:
these i'd say you can do without setting up individual template tags
+$template->set('selected_imap', ($_form_protocol == 'imap') ? '
selected="selected"' : '');
+$template->set('selected_imap_notls', ($_form_protocol == 'imap/notls') ? '
selected="selected"' : '');
+$template->set('selected_imap_ssl', ($_form_protocol == 'imap/ssl') ? '
selected="selected"' : '');
+$template->set('selected_imap_ssl_novalidcert', ($_form_protocol ==
'imap/ssl/novalidate-cert') ? ' selected="selected"' : '');
+$template->set('selected_pop3', ($_form_protocol == 'pop3') ? '
selected="selected"' : '');
do a foreach on the protocol list and plug into each array element the whole
<option....> string appending selected="selected" when you hit the right key,
or default to $protocol_list = array() if $conf['server']['change_protocol'] is
false. something like:
$protocol_list = array();
if ($conf['server']['change_protocol']) {
$protocols = array('imap' => 'IMAP', 'imap/notls' => _("IMAP, no TLS"),
'imap/ssl' => _("IMAP over SSL"), 'imap/ssl/novalidate-cert' => _("IMAP over
SSL (self-signed)", 'pop3' => 'POP3', 'pop3/ssl/novalidate-cert' => _("POP3
over SSL (self-signed)"));
foreach ($protocols as $key => $val) {
$procotol_list[] = '<option value="' . $key . '" . ($protocol == $key ?
' selected="selected"' : '') . '>' . $val . '</option>';
}
}
$template->set('protocol_list', $protocol_list, true);
and you eliminate also the change_protocol tag before it. in the html you'd put:
<if:protocol_list>
<select tabindex="3" name="protocol" onchange="updatePort();">
<loop:protocol_list>
<tag:protocol_list />
</loop:protocol_list>
</select>
<else:protocol_list>
<input type="hidden" name="protocol" value="<tag:protocol_value />" />
</else:protocol_list>
</if:protocol_list>
renders the template a lot more readable too.
marko
More information about the dev
mailing list