| 1 | <?php |
|---|
| 2 | require_once CLASS_REALDIR."/SC_Plugin.php"; |
|---|
| 3 | |
|---|
| 4 | class 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 | function install(){ |
|---|
| 37 | $objQuery = new SC_Query(); |
|---|
| 38 | $arrPlugins = $objQuery->select("plugin_id", "dtb_plugin", "name = ?",array($this->getName())); |
|---|
| 39 | $data = array( |
|---|
| 40 | 'plugin_name' => $this->getName(), |
|---|
| 41 | 'path' => realpath(DATA_DIR.'/plugin/'.$this->getName().'/'), |
|---|
| 42 | 'enable' => '1', |
|---|
| 43 | 'del_flg' => '0', |
|---|
| 44 | 'class_name' => $this->getName(), |
|---|
| 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 | 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 | function getInstallSQL(){ |
|---|
| 75 | |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | function getUninstallSQL(){ |
|---|
| 80 | |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | } |
|---|