Home Backend Development PHP Tutorial EE Development Reference_PHP Tutorial

EE Development Reference_PHP Tutorial

Jul 13, 2016 pm 05:48 PM
class php develop

1.upd.article_statistics.php

<?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

<?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)) <=c.comment_date
                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

Specific implementation of some tags and methods of form submission in some tags are accepted

<?php
class Article_statistics{

var $version = '1.0';

Function __construct()
{
$this->EE =& get_instance();
}
 
//Used to correspond to action
in upd 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 "<br>password:";
echo $password;
                         
echo "<br>msg_id:";
echo $msg_id;
}
 
 
         
/* END form */
}
?>

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

4.views/menu.html

The display style of tabs that can be switched between each other called in MCP

<ul id="tab_menu_tabs" class="tab_menu">
<?php
foreach($module_menu AS $menu_item) :
$current_method=$this->input->get("method");
?>
<li class="content_tab <?php if($menu_item['tab_index']==$current_method) echo 'current';?>" >
             <a href="<?php echo $menu_item['link'];?>"><?php echo $menu_item['title'];?></a>
                         
</li>
<?php endforeach; ?>
</ul>

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

5.libraries/ Article_statistics_helper.php

Link Views,MCP

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

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

/**
     * Constructor
     *
     * @access public
    */
Function __construct()
{
              // Create EE Instance
$this->EE =& get_instance();

}
}
?>


Supplement:

1. If you need to obtain action_id, you can call it directly in 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. If you need to set a jump in the form, you need to set the corresponding jump path for 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...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

CakePHP Date and Time

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

CakePHP Project Configuration

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

CakePHP File upload

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

CakePHP Routing

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

Discuss CakePHP

CakePHP Quick Guide CakePHP Quick Guide Sep 10, 2024 pm 05:27 PM

CakePHP Quick Guide

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

How To Set Up Visual Studio Code (VS Code) for PHP Development

See all articles