[wp-hackers] 2.4 idea: query/display logic split in admin tools

Jacob wordpress at santosj.name
Sun Nov 18 05:34:04 GMT 2007


Stephane Daury wrote:
>
> Working on WPhone, I often wished that the query and display logics 
> were separated, or the recordset returned, in some of the admin 
> listing tools.
>
> For example, in /wp-admin/categories.php, the tools makes use of the 
> cat_rows() convenience function. The latter both fetches and echos the 
> recordset in the desired html format.
>
> As convenient as the above is, making the unformatted recordset 
> available to 3rd-party developers would let us further process the 
> information, and extend features, without having to replicate the same 
> query. Definitely better for performance/security, and so much more.
>
> Same goes for the WP_User_Search class in /wp-admin/users.php, which 
> could be so useful to others if not so *aggressive* (echos only) in 
> its constructor.
>
> This would be immediately be very helpful to our plugin, but I would 
> say would also open the door to other features, such as visualization 
> (graphs, img generation, etc).
>
> Opinions? Ideas? Worth a patch/ticket?
>
> Stephane
>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
I'll say.

One problem that I think I might have brought up before was that the 
business and presentation logic was both in the files, which made it 
extremely difficult to use the functionality outside of the 
administration. That is being fixed, although, probably not because 
whether or not I bought it up (which I might have just said to myself, 
"Damn you WordPress with your business and presentation logic combined 
code!" and not said anything to WP-Hackers, but I bitch a lot so it is 
highly possible I might actually had).

Dare I say, the PEAR Calendar is so damn sexy, I think every library 
should be built like it. Oh yes, it is awesome!

It basically keeps all of the presentation logic completely separated 
from its functionality, and just does the calendar stuff. It doesn't 
even allow you to plug in functionality, but basically by iteration, you 
can build the output yourself. So if you wanted to say, do XML, you can 
do that, or if you want HTML, etc you do it.

Basically, I would totally support the separation, but I won't help. 
I'll tell you straight up right now.

It would probably be difficult, since you would have to have two (or 
more) classes or two or more functions where one was used previously. 
You would also have to keep the original function behavior as it was and 
build a companion for what you are proposing. In this way, you can have 
single functionality separate of both functions but used in both. If 
that makes any sense.

Good luck.

PS: I don't like how print_r() works, so anything that just returns and 
gives you complete control is awesome to me.

-- 

Jacob Santos

http://www.santosj.name - blog
http://wordpress.svn.dragonu.net/unittest/ - unofficial WP unit test suite.

Also known as darkdragon and santosj on WP trac.



More information about the wp-hackers mailing list