首页 > php教程 > php手册 > 正文

EE开发参考

php中文网
发布: 2016-06-13 10:47:23
原创
1072人浏览过

1.upd.article_statistics.php

class Article_statistics_upd {

    var $version        = '1.0';
    var $module_name        = 'Article_statistics'; 
    function __construct()
    {
        $this->EE =& get_instance();
    }
   
    function install()
    {
        $this->EE->load->dbforge();
         $data = array(
            'module_name' => $this->module_name ,
            'module_version' => $this->version,
            'has_cp_backend' => 'y',
            'has_publish_fields' => 'n'
        );
   
        $this->EE->db->insert('modules', $data);
       
        $data = array(
            'class'        => $this->module_name ,
            'method'    => 'add'
        );
        $this->EE->db->insert('actions', $data);
        return TRUE;
    }
   
        
   
    function uninstall()
    {
        $this->EE->load->dbforge();
    
        $this->EE->db->where('module_name', $this->module_name);
        $this->EE->db->delete('modules');
   
        $this->EE->db->where('class', $this->module_name);
        $this->EE->db->delete('actions');
    
        
        return TRUE;
    }

    function update($current = '')
    {
        return FALSE;
    }
}
?>

----------------------------------------------------------------------------------------

2.mcp.article_statitics.php

class Article_statistics_mcp {

    var $version        = '1.0';
    var $module_name    = 'Article_statistics';  
    var $cached_vars    = array();
    function __construct()
    {
        $this->EE =& get_instance();
        $this->EE->load->library('table');
        // Some Globals
        $this->base_url = BASE.AMP.'C=addons_modules'.AMP.'M=show_module_cp'.AMP.'module=article_statistics';
         $menu    = array(                                       
            'module_index'            => array(   
                'link'  => $this->base_url,
                'tab_index'  => "",
                'title' => $this->EE->lang->line('module_index')
            ),
        
            'test_list'    => array(
                'link'    => $this->base_url .AMP. 'method=show_list',
                'tab_index'  => "show_list",
                'title' => $this->EE->lang->line('show_list')
            )
        );
       
        $this->cached_vars['module_menu']             = $menu;       

    }
     
    public function index()
    {
        $this->_set_nav_title($this->EE->lang->line("article_statistics_module_name"),$vars);
        return $this->EE->load->view('index', $vars, TRUE);
    }
 
    public function show_list()
    {
        $this->EE->load->library('article_statistics_helper');
       
        $this->_set_nav_title($this->EE->lang->line("article_statistics_module_name"),$data);
       
        $sql="SELECT *
                FROM bv_comments c
               
                WHERE UNIX_TIMESTAMP(DATE_SUB(CURDATE(),INTERVAL 30 DAY))                 ORDER BY c.comment_date DESC";
        $query=$this->EE->db->query($sql);
       
        $data["results"]=$query;

        return $this->EE->load->view('show_list', $data,TRUE);
    }
 
    function _set_nav_title($title='',&$data)
    {
        $this->EE->cp->set_variable('cp_page_title',$title);
        $data['module_menu']        = $this->cached_vars['module_menu'];
    }
 
//Class End
}

?>

 

----------------------------------------------------------------------------------------

3.mod.article_statistics.php

具体实现一些tag和一些tag中的form提交的方法接受

class Article_statistics{

    var $version        = '1.0';
  
    function __construct()
    {
        $this->EE =& get_instance();
    }
   
    //用于对应upd 中的action
    function add()
    {
        $username= $this->EE->input->post("username");
        $password= $this->EE->input->post("password");
       
        $msg_id= $this->EE->input->get("msg_id");
        echo $username;
        echo "
password:";
        echo $password;
       
        echo "
msg_id:";
        echo $msg_id;
    }
   
   
      
    /* END form */
}
?>

 

----------------------------------------------------------------------------------------

4.views/menu.html

在MCP中调用的可以互相切换的tab的显示样式


    foreach($module_menu AS $menu_item) : 
        $current_method=$this->input->get("method");
    ?>
       

  •        
           
       


----------------------------------------------------------------------------------------

5.libraries/ Article_statistics_helper.php

链接Views,MCP

/**
 * Iserver API Helper File
 *
 */
class Article_statistics_helper
{

    /**
     * Constructor
     *
     * @access public
     */
    function __construct()
    {
        // Creat EE Instance
        $this->EE =& get_instance();
 
    }
}
?>


补充:

1.如果需要获取action_id可以在mod.module_name.php中直接调用

$this->form_data['ACT']                        = $this->EE->functions->fetch_action_id('Test', 'add');

 'action'        => "?ACT=".$this->form_data['ACT'].AMP."msg_id=333",

2.如果需要在form中设置跳转,则需要设置redirect的相应跳转路径


摘自 任宝永--renbaoyong --商业价值
最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号