后台列表页面list中每行数据的操作actions


             当登录后台页面的时候,除了controller和token2个参数,
             而没有其他的参数传递的时候,流程如下:
            initContent() ,$this->renderList()   进入数据列表页面list
===数据列表页面list end=====


===每行数据的操作actions,首先是生成按钮 start======
       $this->renderList()中,
       使用数据列表助手$helper = new HelperList();
       $this->setHelperDisplay($helper);
       设置助手的参数,如:$helper->actions = $this->actions;
                                      $helper->_default_pagination = $this->_default_pagination;
                                     $helper->_pagination = $this->_pagination;
                                        $helper->tpl_vars = $this->getTemplateListVars();
                                        $helper->tpl_delete_link_vars = $this->tpl_delete_link_vars;
                                        $list = $helper->generateList($this->_list, $this->fields_list);
       这样,得到数据列表助手的方法:
                                         generateList($list, $fields_display)    
                                         这个方法中,定义了smarty的tpl模板,
                                         布局,头,内容,尾4个模板,       
                                          其中,'content' => $this->displayListContent(), // Show the content of the table
                                          数据列表内容显示模板 displayListContent方法中,
                                         处理了每行的操作按钮 foreach ($this->actions as $action)
                                               $method_name = 'display'.ucfirst($action).'Link';
                                               模板:list_action_edit.tpl
                                               如:
                                               /**
     * Display edit action link
     */
    public function displayEditLink($token = null, $id, $name = null)
    {
        $tpl = $this->createTemplate('list_action_edit.tpl');
        if (!array_key_exists('Edit', self::$cache_lang))
            self::$cache_lang['Edit'] = $this->l('Edit', 'Helper');

        $tpl->assign(array(
            'href' => $this->currentIndex.'&'.$this->identifier.'='.
            $id.'&update'.$this->table.($this->page && $this->page > 1 ?
             '&page='.(int)$this->page : '').'&token='.($token != null ? $token : $this->token),
            'action' => self::$cache_lang['Edit'],
            'id' => $id
        ));

        return $tpl->fetch();
    }

       
       
     
       


===每行数据的操作actions,首先是生成按钮 end======




===每行数据的操作actions按钮提交后的操作处理 start====
     第一,在控制器 class AdminControllerCore extends Controller中定义了数组变量
              /** @var array List of required actions for each list row */
              protected $actions = array();
              /** @var string Action to perform : 'edit', 'view', 'add', ... */
              protected $action;

    第二, 在页面控制器的构造器中设置成员变量
                class AdminA9MController extends ModuleAdminController
               // Declare an action to use for each row in the list
                $this->addRowAction('edit');
                $this->addRowAction('delete');
                操作的名称转换为小写字符存入到数组$this->actions[] = $action;
                 这个addRowAction方法也是在后台控制器中AdminController
                 
                 
    第三, 在控制器 class AdminControllerCore extends Controller中
               定义了 postProcess()方法,处理$actions数组
               方法中有2个处理流程:
                           首先是ajax流程;
                           其次是一般流程:
                                 商家入驻的【入驻管理】是一般流程     
                                 if (!empty($this->action) && method_exists($this, 'process'.ucfirst(Tools::toCamelCase($this->action))))
                                 
                                 如果有操作提交,并且这个方法存在
                                 则执行下面操作,并返回
                                 Hook::exec('actionAdmin'.ucfirst($this->action).'Before', array('controller' => $this));
                    Hook::exec('action'.get_class($this).ucfirst($this->action).'Before', array('controller' => $this));
                    // Call process
                    $return = $this->{'process'.Tools::toCamelCase($this->action)}();
                    // Hook After Action
                    Hook::exec('actionAdmin'.ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));
                    Hook::exec('action'.get_class($this).ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));
                    return $return;
                                 
                                 


===每行数据的操作actions按钮提交后的操作处理 end====


======后台模板(jquery,css,path,var,smarty)     start
--------------------------------------------------
1.  分为控制器与助手
    控制器中的助手模板继承上级的助手模板
2.  后台列表页面模板:
     2.1 后台默认模板中,助手中列表content中的数据
           分为三段
           2.1.1 前段 批量操作选择checkbox可加入【+】,以显示下级类目
           2.1.2 中段 foreach,显示表中数据(控制器中的构造器),
                   点击后,有下级的话,通过控制器的renderview呈现
           2.1.3后段 action,对应控制器中的renderlist
           
    2.2header中的数据
          2.2.1   加载的脚本-》建议区域-》hook
          2.2.2   数据表的前两行,在foreach前后
          
    2.3 footer中的数据       
         2.3.1最下面,还有批量处理的功能,对应的是哪个还需要分析????????????      
====================end========

转载于:https://my.oschina.net/u/2615982/blog/610607

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值