Page 1 of 12

[2.0] Smartifying the backend

Posted: Thu Feb 16, 2012 3:51 pm
by onli
This is a support effort for Restructuring the backend.

All those php-files in include/admin/ emit html-code. They should be converted to use smarty-templates, like in this example:
  • category.inc.php (DONE)
  • export.inc.php (DONE)
  • installer.inc.php (DONE)
  • upgrader.inc.php (DONE)
  • comments.inc.php (DONE)
  • groups.inc.php (DONE)
  • overview.inc.php (DONE)
  • users.inc.php (DONE)
  • configuration.inc.php (DONE)
  • images.inc.php (DONE)
  • personal.inc.php (DONE)
  • entries.inc.php (DONE)
  • plugins.inc.php (DONE)
  • entries_overview.inc.php (DONE)
  • import.inc.php (DONE)
  • templates.inc.php (DONE)
Commit finished files please to the 2.0-branch or show them here.

Re: [2.0] Smartifying the backend

Posted: Thu Feb 16, 2012 4:08 pm
by Timbalu
Yes, but smartifying configuration.inc.php, personal.inc.php and overview.inc.php do not really need to, since they contain to less html code to smartify, as is (maybe the last somewhere else).

Re: [2.0] Smartifying the backend

Posted: Fri Feb 17, 2012 11:01 am
by yellowled
Could you drop me a note via email once you're done with this? I'm probably going to lose track pulling the 2.0 branch. Thank you. :)

YL

Re: [2.0] Smartifying the backend

Posted: Fri Feb 17, 2012 2:22 pm
by onli
Sure.

Ian: That's true, some pages use internal function which emit html-code as well. In the long run, we should probably smartify them too. In the beginning, every page should have a template anyway, since we don't know what will be added to them.

I already used ob_start() and ob_get_content() as a workaround for serendipity_plugin_config.

Re: [2.0] Smartifying the backend

Posted: Tue Feb 21, 2012 5:06 pm
by onli
After extracting the html from the php, some steps need to be repeated again and again. This script should help.

Re: [2.0] Smartifying the backend

Posted: Tue Feb 28, 2012 5:53 pm
by Timbalu
Malte, I found this script erroring...
I did have to take the sed regexes line by line, except one, I do not remember, which errored.
But it would be nice to have inner single quotes like #{serendipity_getFile file=\'\1\'}#g instead of #{serendipity_getFile file=\"\1\"}#g on the onehand and #{\1|escape:\'html\'}#g instead of #{\1|escape:\"html\"}#g.
I dont think we need $foo|escape:'html' either, as we are just rebuilding php's htmlspecialchars, which should be single |escape in Smarty.

Btw is it still possible to use ob_get_contents on function outputs, which throw some error notices with printf and return true/false at the end?

Re: [2.0] Smartifying the backend

Posted: Tue Feb 28, 2012 8:36 pm
by onli
The very first line is wrong, it should be

Code: Select all

cp "$1" "$1"_backup
That's probably why the second didn't work.
But it would be nice to have inner single quotes
Why? That's not the way i convert it manually.
I dont think we need $foo|escape:'html' either, as we are just rebuilding php's htmlspecialchars, which should be single |escape in Smarty.
It never hurts to state the default explicit.
Btw is it still possible to use ob_get_contents on function outputs, which throw some error notices with printf and return true/false at the end?
Possible in technical terms? I think so, why shouldn't it?

Re: [2.0] Smartifying the backend

Posted: Tue Feb 28, 2012 9:57 pm
by Timbalu
onli wrote:Why? That's not the way i convert it manually.
Well, its just of cosmetical nature I think:

Code: Select all

<img src="{serendipity_getFile file='/admin/img/error.png'}" alt="" />
:wink:
I finished another three files and uploaded them to the 2.0 branch. It might be good testing them carefully as some of them are complicated though.

Re: [2.0] Smartifying the backend

Posted: Tue Feb 28, 2012 11:09 pm
by onli
Well, its just of cosmetical nature I think:
Na, that's not worth it. First of all it's not that way where i got it from, and i don't think it's prettier ;)
I finished another three files
Great :)
All of those files will need testing. But it will be tested at least when the new adminarea gets build. Just make sure they don't throw errors when only loading the page or following the easy-to-test options.

Re: [2.0] Smartifying the backend

Posted: Sat Mar 03, 2012 2:34 pm
by onli
That'd be it. All files have been smartified. Thank you very much for the help, Ian!

Work to be done: Some admin-files use functions to emit html-code, which themselves don't use smarty. They probably should get transformed too. A probably incomplete list:
  • show_plugins (functions_plugins_admin.inc.php)
  • serendipity_plugin_config (functions_plugins_admin.inc.php)
  • serendipity_printConfigTemplate
  • showMediaLibrary
  • serendipity_killPath
  • serendipity_moveMediaDirectory
Most important: Testing. I guess that most of the testing will be done anyway or would become invalid when the new backend gets build. But some events won't work at all, some forms not as expected, all that has to be fixed before this gets into any release.

It should now be possible to modify the admin-area more easily.

Re: [2.0] Smartifying the backend

Posted: Sat Mar 03, 2012 3:38 pm
by yellowled
onli wrote:That'd be it. All files have been smartified. Thank you very much for the help, Ian!
And thanks to both of you for the effort. :-)

Not quite sure as to how to proceed now, to be honest. Obviously, first of all all the .tpl files required for the backend need to be rewritten, but this only makes sense if we also rewrite those not placed in /include/admin/tpl/. Should I edit the ones in /templates/default/ or create a whole new directory or …? Can we go completely nuts in the 2.0 branch and try everything or should we first test it before committing to the core repo?

Garvin?

YL

Re: [2.0] Smartifying the backend

Posted: Sat Mar 03, 2012 4:00 pm
by yellowled
yellowled wrote:Should I edit the ones in /templates/default/ or create a whole new directory or …? Can we go completely nuts in the 2.0 branch and try everything or should we first test it before committing to the core repo?
As for the first part, I think it makes sense to do that in 2k11. It doesn't have an admin theme yet, it will likely become the default or at least standard theme at some point, so it makes sense to add one, I guess.

YL

Re: [2.0] Smartifying the backend

Posted: Sat Mar 03, 2012 4:02 pm
by onli
I personally would be very happy if the code in default would eventually vanish.

Re: [2.0] Smartifying the backend

Posted: Sat Mar 03, 2012 4:25 pm
by yellowled
Me too, but that might be a long shot. However, given the fact that these tpl files are supposed to be "locked", we're gonna have to move them at some point anyway.

YL

Re: [2.0] Smartifying the backend

Posted: Sat Mar 03, 2012 4:41 pm
by Timbalu
Well, moving the /tpl dir files to the templates/default/admin/ is no big deal, but this might be discussed later, as this is the point of Garvins concerns having a full public admin template spread out to the wild....
To keep this in our hands, we really should leave it where it is for the moment. And yes, default is the right place, as we did not smartify the files to have a fallback case.

So you have 3 or 4 possible points to work with:
  • - /include/tpl/ (internally smartified before)
    These could also keep smarty blocks for the upper mentioned functions in future.
  • - /include/admin/tpl/ (the ones now smartified by Malte and me)
  • - /templates/default/admin/ (index, entries, media*)
    and possibly at some time
  • -/include/admin/importers/tpl/
Going completely nuts is no good, a little bit of testing would be good to have before pushing! ;-)