source: branches/camp/camp-2_5-E/data/plugin/TestPlugin1/TestPlugin1.php @ 19567

Revision 19567, 1.8 KB checked in by miningbrownie, 13 years ago (diff)
Line 
1<?php
2require_once CLASS_PATH."/SC_Plugin.php";
3
4class TestPlugin1 extends SC_Plugin {
5
6
7
8    function enable(String $classname){
9        return preg_match('/shopping|payment|products/',$classname)?
10        !preg_match('/list/', $classname)
11        :false
12        ;
13    }
14
15    function init(){
16
17    }
18
19
20    function getVersion(){
21        return "0.0.1";
22    }
23
24    function getName(){
25        return "TestPlugin1";
26    }
27
28    function process(){
29
30    }
31
32    function mobileprocess(){
33
34    }
35
36    public function install(){
37        $objQuery = new SC_Query();
38        $arrPlugins = $objQuery->get("dtb_plugin", "plugin_id", "plugin_name = ?",array($name));
39        $data = array(
40          'plugin_name' => $objForm->getValue('plugin_name'),
41          'path' => realpath(DATA_DIR.'/plugin/'.$objForm->getValue('plugin_name').'/'),
42          'enable' => '1',
43          'del_flg' => '0',
44          'class_name' => $objForm->getValue('plugin_name'),
45          'version' => $this->getVersion()
46        );
47        if($this->getInstallSQL() != null){
48            $objQuery->query($this->getInstallSQL());
49        }
50
51        if(count($arrPlugins) == 0){
52            $objQuery->insert("dtb_plugin", $data);
53        }else{
54            $objQuery->update('dtb_plugin',$data,'plugin_id = ?',array($arrPlugins[0]['plugin_id']));
55        }
56
57
58    }
59
60    public function uninstall($plugin_id){
61        $objQuery = new SC_Query();
62        $sql = $this->getUninstallSQL();
63        if($sql != null){
64            $objQuery->query($sql);
65        }
66        return $objQuery->update('dtb_plugin', array('del_flg'=>1), 'plugin_id = ?', $plugin_id);
67       
68    }
69
70    /**
71     *
72     * @return String インストール用のSQL
73     */
74    protected function getInstallSQL(){
75
76    }
77
78
79    protected function getUninstallSQL(){
80
81    }
82
83}
Note: See TracBrowser for help on using the repository browser.