EE Development Reference _php Tutorial

Source: Internet
Author: User
Tags vars
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 ' and ' $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 ()) <=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 some of the methods of the tag form submission accepted

Class article_statistics{

var $version = ' 1.0 ';

function __construct ()
{
$this->ee =& get_instance ();
}

Used to correspond to the action in the 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 "
Password: ";
Echo $password;

echo "
msg_id: ";
echo $msg _id;
}



/* END form */
}
?>

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

4.views/menu.html

The display style of tab that can be toggled in the MCP


      foreach ($module _menu as $menu _item):
      $current _method= $this->input->get ("method");
      ?>

    • ">



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

5.libraries/article_statistics_helper.php

Link VIEWS,MCP

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

/**
* Constructor
*
* @access Public
*/
function __construct ()
{
creat EE Instance
$this->ee =& get_instance ();

}
}
?>


Add:

1. If you need to get 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


From Jimbaoyong--renbaoyong--Business value

http://www.bkjia.com/PHPjc/478411.html www.bkjia.com true http://www.bkjia.com/PHPjc/478411.html techarticle 1.upd.article_statistics.php php class Article_statistics_upd {var $version = 1.0; var $module _name = Article_statis Tics function __construct () {$this-ee = Get_instance ();} Fu ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.