[dev] IMP login template...

Nuno Loureiro nuno at co.sapo.pt
Fri Aug 1 08:16:56 PDT 2003


Actually I did better than that.

I just constructed a string with the <option>s stuff and set it for the
templates. I avoid a template loop, and the template itself is more
clean in terms of viewing it in a browser or HTML editor.

I also removed the <select ...> and </select> from $langs and put it in
the template itself. That way, if you edit the html template in a HTML
editor, it knows there's a <select> there.

I didn't benchmark this again, but anyway I think it's really possible
to put every page as fast or faster with horde templates than without. I
imagine here a way of pre-compiling the templates and transform them to
PHP, just like Smarty does. And mailbox.php with this will be faster
than now for sure..

Right now, I'm more concerned in having a more clean template, so you
can view it and change it easily in an HTML editor.

We just have to start from somewhere, and maintain a local copy of all
pages converted to horde templates and the optimization stuff will not
be easy.

Nuno

On Sat, 2003-07-26 at 16:20, Marko Djukic wrote:
> 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
-- 
Nuno Loureiro <nuno at co.sapo.pt>
PTM.com - http://www.sapo.pt/
PGP fingerprint = 8A32 5174 E80C 2D40 9075 405E C107 6592 054A 4D05



More information about the dev mailing list