哪个组件的控制器处理NEW项目的表单请求? [英] Which component's controller handle the form request of NEW item?

查看:118
本文介绍了哪个组件的控制器处理NEW项目的表单请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

选中此 发布 ,我知道Joomla使用task=X.Y来调用控制器来处理请求.

After checking this post, I know that Joomla use task=X.Y to call the controller to handle the request.

但是,如果我单击com_categories组件上的NEW按钮,它将访问/administrator/index.php?option=com_categories&view=items的URL,并包含POST数据,如下所示:

But if I click NEW button on com_categories component, it will access the URL of /administrator/index.php?option=com_categories&view=items and containing the POST data as below:

然后将URL重定向到/administrator/index.php?option=com_categories&view=item&layout=edit.

Then the URL get redirected to /administrator/index.php?option=com_categories&view=item&layout=edit.

我的问题是为什么URL /administrator/index.php?option=com_categories&view=items没有task=X.Y并且可以重定向到/administrator/index.php?option=com_categories&view=item&layout=edit?

My question is why the URL /administrator/index.php?option=com_categories&view=items don't have the task=X.Y and it can redirect to /administrator/index.php?option=com_categories&view=item&layout=edit?

我知道它包含task=item.add的POST数据,但是哪个控制器将此POST数据转换为目标URL并重定向到该目标URL?

I know that it contains the POST data with task=item.add, but which controller convert this POST data to the destination URL and get redirected to that?

谢谢.

推荐答案

实际上(在2.5.14上),当您在类别管理器"视图中单击新建"按钮时,第一个请求将生成POST:

Actually (on 2.5.14), when you click on the "New" button in the Category Manger view, the first request generates a POST:

POST /administrator/index.php?option=com_categories&view=categories HTTP/1.1

POST请求通常在HTTP消息正文中发送查询字符串,而不仅仅是在URL中,在这种情况下,POST请求在正文中具有以下 form 数据:

POST requests usually send query strings in the HTTP message body not just in the URL, in this case the POST request has the following form data in the body:

filter_search   
filter_level    
filter_published    
filter_access   
filter_language 
limit   5
limitstart  0
order[] 1
order[] 1
order[] 1
order[] 1
order[] 2
batch[assetgroup_id]    
batch[language_id]  
batch[category_id]  
batch[move_copy]    m
extension   com_content
task    category.add
boxchecked  0
filter_order    a.lft
filter_order_Dir    asc
original_order_values   1,1,1,1,2
796194955f38a0d8db484c92d92ca5ce    1

您会注意到它具有一个task参数,该参数的值为category.add(不是item.add ),当getInstance($prefix, $config)为在com_categories入口点文件中调用:

You will notice this has a task parameter that has the value category.add (not item.add), this is taken into account by the JController class when getInstance($prefix, $config) is called in the com_categories entry point file:

$controller = JControllerLegacy::getInstance('Categories');

JController类将category.add转换为category$typeadd$task. $type值用于将组件的基本路径(在本例中为/pathto/site/administrator/components/com_categories)组合到控制器的路径.

The JController class converts category.add into a $type of category and a $task of add. The $type value is used to assemble the path to the controller in conjunction with the components base path ( in this case /pathto/site/administrator/components/com_categories ).

因此,当实例化的JController类在com_categories/categories.php入口点文件中接收到->execute($task)消息时:

So, when the instantiated JController class receives the ->execute($task) message in com_categories/categories.php entry point file:

$controller->execute(JRequest::getVar('task'));

它实际上已经是类型为CategoriesControllerCategory的控制器,这就是您希望处理New按钮​​请求的控制器.

it's actually already a controller of type CategoriesControllerCategory which is the what you would expect to handle the New button request.

这篇关于哪个组件的控制器处理NEW项目的表单请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆