백엔드 개발 PHP 튜토리얼 EE开发参考_PHP教程

EE开发参考_PHP教程

Jul 13, 2016 pm 05:48 PM
class php 개발하다

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 --商业价值

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/478411.htmlTechArticle1.upd.article_statistics.php ?php class Article_statistics_upd { var $version = 1.0; var $module_name = Article_statistics; function __construct() { $this-EE = get_instance(); } fu...
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

뜨거운 기사 태그

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

Ubuntu 및 Debian용 PHP 8.4 설치 및 업그레이드 가이드 Ubuntu 및 Debian용 PHP 8.4 설치 및 업그레이드 가이드 Dec 24, 2024 pm 04:42 PM

Ubuntu 및 Debian용 PHP 8.4 설치 및 업그레이드 가이드

CakePHP 날짜 및 시간 CakePHP 날짜 및 시간 Sep 10, 2024 pm 05:27 PM

CakePHP 날짜 및 시간

CakePHP 프로젝트 구성 CakePHP 프로젝트 구성 Sep 10, 2024 pm 05:25 PM

CakePHP 프로젝트 구성

CakePHP 파일 업로드 CakePHP 파일 업로드 Sep 10, 2024 pm 05:27 PM

CakePHP 파일 업로드

CakePHP 라우팅 CakePHP 라우팅 Sep 10, 2024 pm 05:25 PM

CakePHP 라우팅

CakePHP 토론 CakePHP 토론 Sep 10, 2024 pm 05:28 PM

CakePHP 토론

CakePHP 빠른 가이드 CakePHP 빠른 가이드 Sep 10, 2024 pm 05:27 PM

CakePHP 빠른 가이드

PHP 개발을 위해 Visual Studio Code(VS Code)를 설정하는 방법 PHP 개발을 위해 Visual Studio Code(VS Code)를 설정하는 방법 Dec 20, 2024 am 11:31 AM

PHP 개발을 위해 Visual Studio Code(VS Code)를 설정하는 방법

See all articles