EE開發參考_PHP教程

來源:互聯網
上載者:User
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)) <=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

具體實現一些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 --商業價值

http://www.bkjia.com/PHPjc/478411.htmlwww.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...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.