A while back I started the "adminhandler branch" which became impossible
to keep in sync with trunk due to the number of changes made. I'd like
to propose something similar to what I started there.
Each page of the admin (eg, dashboard, posts, post, comments, etc.) will
be handled by it's own "AdminPage" class, a child of the parent
AdminPage. When an admin page is requested, the associated AdminPage
class is instantiated, and the appropriate method, based on the "action"
and "request_method" is called. eg. When dashboard is requested using
the GET method, AdminPageDashboard is instantiated and the act_get()
method is called. When the addModule ajax action is called via POST, the
act_ajax_addModule_post() method is called.
I'd like to further extend this to a more REST/CRUD type system. So make
a POST or PUT request to /post would CREATE a new post. PUT request
to /post/$id would UPDATE given post, DELETE would delete. Basically,
allowing us to tie the admin system closer to the ACL CRUD system. (I
believe browsers will allow us to submit forms with action="DELETE|
PUT".)
A small table of HTTP -> CRUD:
HTTP | CRUD
-------+---------
POST | Create
GET | Read
PUT | Update, Create
DELETE | Delete
Originally what I did was to default to act_request_$method() instead of
just act_$method(), which was confusing. Also I put all the adminpage
classes in system/admin/classes which is confusing since the admin
folder is the "View" folder. I would also rename class as
"AdminPage{$page}" instead of "{$page}AdminPage".
For the basics of what I started, please see the following:
Parent AdminPage:
https://trac.habariproject.org/habari/browser/branches/adminhandler/htdocs/system/admin/classes/adminpage.php
AdminHandler:
https://trac.habariproject.org/habari/browser/branches/adminhandler/htdocs/system/classes/adminhandler.php
and an example AdminPageDashboard:
https://trac.habariproject.org/habari/browser/branches/adminhandler/htdocs/system/admin/classes/dashboardadminpage.php
I would also like to see a standardized way for ajax methods to return
information. See bug #898.
Also a common API to the "itemManage" JS library, which most pages could
use (posts, comments, logs, plugins, themes). Providing a "grid like"
approach to populating the lists. Allowing for adding/removing rows,
headings, columns, etc., and changing the "view style"/template used for
displaying each object. Also allowing for easier integration with ACL
and adding/removing actions in the "dropbutton" thing.
I'd like to hear some other ideas anyone has, and try to make a written
standard of our admin system, before we start cannibalizing things. I've
kinda started a _very_, _very_ rough "sketch of ideas" (haven't had much
time recently to improve it) on my wiki page. Please feel free to add
anything.
http://wiki.habariproject.org/en/User:MattRead/adminhandler
http://wiki.habariproject.org/en/User:MattRead/adminhandler#Item_Manage
I would also like to note, that in order to implement such massive
changes it would require a "freeze" on adminhandler changes, until we
can get everything moved over to the new system (whatever it is we come
up with). (unless SVN is truly magical, and can merge something like
that).
(I
believe browsers will allow us to submit forms with action="DELETE|
PUT".)
I'm somewhat less attached to the HTTP -> CRUD idea. It would definitely depend upon how the implementation panned out in regards to browser support.
> I'd like to further extend this to a more REST/CRUD type system. So
> make
> a POST or PUT request to /post would CREATE a new post. PUT request
> to /post/$id would UPDATE given post, DELETE would delete. Basically,
> allowing us to tie the admin system closer to the ACL CRUD system. (I
> believe browsers will allow us to submit forms with action="DELETE|
> PUT".)
I'd follow APP's (Atom Publishing Protocol) example for consistency's
sake. (Quite what APP does I don't know.) I also presume you mean
@method and not @action. My understanding is that browsers allow GET,
POST, PUT, and DELETE (these are matched case-insensitively, but
should probably be given in uppercase for consistency with HTTP
itself) and map anything else to GET.
--
Geoffrey Sneddon
<http://gsnedders.com/>
Is there a reference that confirms that all of these verbs work in all
browsers we intend to support in our admin?
Owen
Adminhandler.php, as it stands, is an unholy beast which we must slay.
I would recommend that we create some sort of standardized "AJAX"
class in both PHP *and* JS. The PHP AJAX class would be called by
AdminPages (and possible ItemManage). The JS class would handle
interpreting errors, executing data, etc.
I would caution that we shouldn't limit the AJAX class to *only* HTML.
You should also be able to map a "success" function which would
receive data (not necessarily html) and process it. Ex.
{
notice: ['Notice number one','Notice nubmer two'],
error: ['Error number one', 'Error number two'],
data: {
name: "james"
}
}
$.habariAjax(habari.url.ajaxWhatever, values, success: function(data)
{ alert(data.name); } );
In regards to the CRUD aspect, I'm not an expert. However, it does
seem a little complicated and constraining to me. I'd have to see an
actual implementation before I'm convinced. Maybe we'd be better off
starting by transferring everything into classes, then pursuing such
alternate plans. Consider me skeptical but open to persuasion.
I'm still a little fuzzy about the ItemManage class, but it does seem
like a good idea. We were trying to do something like this with the
JS, but standardization (of html) would definitely help. However, I
don't think we need to *require* that every itemset has all the html
sections. Not all sections make sense for all of them.
Instead, there should be a customizable addition list. We'd
*standardize* the types (just like FormUI), but not require that every
itemset has all of them. In fact, there might also be some ability to
define where the values *come from* (it'll be different for different
objects). Ex.
$items->add_sections(array(
'title' => 'title',
'description' => 'content'
));
In that case, it'd only display the "title" and "description" fields.
These would be populated according to the passed source. Ex. $object-
>{$source}. We'd also include some defaults, so you could do
something like this:
$items->add_sections(array('title', 'description'));
Ideally, all of this would also be extendable by plugins, in a similar
way to FormUI. The $items class would simply be passed to an action
before given to the theme.
Here's some hooks I'd like to include:
$items->remove_sections();
$items->add_sections(array($name => $source)); // Allow sections to be
remapped in this way as well, as above
$items->move_section_after($name, $preceding);
$items->move_section_before($name, $proceeding);
I'd be willing to help out in whatever capacity I can (especially the
JS), but I've been less involved of late. I'm also not sure certain
people want my code touching any of this.
~Arthus
I'm definitely in favour of cleaning up the admin handler.
[snip]
> Parent AdminPage:
> https://trac.habariproject.org/habari/browser/branches/adminhandler/htdocs/system/admin/classes/adminpage.php
>
> AdminHandler:
> https://trac.habariproject.org/habari/browser/branches/adminhandler/htdocs/system/classes/adminhandler.php
>
> and an example AdminPageDashboard:
> https://trac.habariproject.org/habari/browser/branches/adminhandler/htdocs/system/admin/classes/dashboardadminpage.php
It may be that other handlers become similarly monolithic in the
future. I think putting things in /admin may lose us flexibility and
cause problems in the future. What about moving the handlers to
/system/handlers/{admin,user,atom,etc}.php, and have handler-specific
things in a subdirectory, /system/handlers/admin/dashboard.php, for
example ?
--
Michael C. Harris, School of CS&IT, RMIT University
http://twofishcreative.com/michael/blog
IRC: michaeltwofish #habari
<snip>
It may be that other handlers become similarly monolithic in the
> Parent AdminPage:
> https://trac.habariproject.org/habari/browser/branches/adminhandler/htdocs/system/admin/classes/adminpage.php
>
> AdminHandler:
> https://trac.habariproject.org/habari/browser/branches/adminhandler/htdocs/system/classes/adminhandler.php
>
> and an example AdminPageDashboard:
> https://trac.habariproject.org/habari/browser/branches/adminhandler/htdocs/system/admin/classes/dashboardadminpage.php
future. I think putting things in /admin may lose us flexibility and
cause problems in the future. What about moving the handlers to
/system/handlers/{admin,user,atom,etc}.php, and have handler-specific
things in a subdirectory, /system/handlers/admin/dashboard.php, for
example ?
Like Chris, I am very much in favor of splitting the adminhandler
On Apr 6, 4:43 pm, Chris Meller <ch...@doesnthaveone.com> wrote:
> I haven't looked at your branch in depth, but I still love the idea of
> splitting out each page into its own class.
>
> I'm somewhat less attached to the HTTP -> CRUD idea. It would definitely
> depend upon how the implementation panned out in regards to browser support.
>
class into subsections.
I am a little more confused about your HTTP->CRUD proposal. What
exactly does your HTTP to CRUD mapping buy us?
The admin JS is also a bit of a mess. I understand the desire for an
itemManage API, but even before that I'd like to see a little general
clean-up. For instance, we should be using descriptive CSS class-hooks
to generate behavior rather than lists of CSS IDs (eg. add a
"draggable" class to relevant HTML entities rather than list the IDs
of every entity we want to be draggable).
Also, we use the jQuery
library, but otherwise we use a very non-jQuery-like JS style.
This change seems to mesh well with implementing SPL autoload and the
bootstrap stuff we were talking about on IRC.
For those not present, we were discussing how it would be nice if you
could include the Habari system without it actually processing the output.
A potential solution is to create a system/bootstrap directory in which
a series of purpose-related modules could include their components.
Example components include running the installer, initializing the
database, and loading plugins.
The index.php file would be reduced to a series of includes that pull
from that bootstrap directory. Other applications could create their
own index.php-like files that include only the desired components of
Habari by including just those bootstrap files. This would make it
easier to, for example, embed Habari functionality within some other
page or application.
SPL autoload would simply use the SPL autoload features directly insteda
of implying them like we do now. It would also need to be augmented to
support loading handlers from a different place than class libraries.
Owen
I couldn't find a reference, and I was going to check myself that they
do. However, Anne van Kesteren said they did, so hopefully he's right.