- Timestamp:
- 2013/08/26 15:52:37 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_13_0/data/class/plugin/SC_Plugin_Installer.php
r22990 r23126 21 21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 22 22 */ 23 class SC_Plugin_Installer {24 23 class SC_Plugin_Installer 24 { 25 25 protected $exec_func; 26 26 27 27 protected $plugin_code; 28 28 29 29 protected $arrPlugin; 30 30 31 31 protected $arrInstallData; 32 33 public function __construct($exec_func, $arrPlugin) { 32 33 public function __construct($exec_func, $arrPlugin) 34 { 34 35 $this->exec_func = $exec_func; 35 36 $this->plugin_code = $arrPlugin['plugin_code']; … … 45 46 $this->arrInstallData['remove_directory'] = array(); 46 47 } 47 48 public function execPlugin() { 48 49 public function execPlugin() 50 { 49 51 $this->log("start"); 50 52 51 53 $plugin_code = $this->arrPlugin['plugin_code']; 52 54 … … 65 67 } 66 68 } 67 69 68 70 if (count($arrErr) > 0) { 69 71 return $arrErr; 70 72 } 71 73 72 74 $objQuery =& SC_Query_Ex::getSingletonInstance(); 73 75 74 76 // SQLの実行 75 77 foreach ($arrSql as $sql) { … … 77 79 $objQuery->query($sql['sql'], $sql['params']); 78 80 } 79 81 80 82 $arrInsertQuery = $this->arrInstallData['insert']; 81 83 foreach ($arrInsertQuery as $query) { … … 89 91 ); 90 92 } 91 93 92 94 $arrUpdateQuery = $this->arrInstallData['update']; 93 95 foreach ($arrUpdateQuery as $query) { … … 101 103 ); 102 104 } 103 105 104 106 // プラグインのディレクトリコピー 105 107 $arrCopyDirectories = $this->arrInstallData['copy_directory']; … … 122 124 PLUGIN_HTML_REALDIR . $plugin_code . DIRECTORY_SEPARATOR . $file['dist']); 123 125 } 124 125 $this->log("end"); 126 } 127 128 public function copyFile($src, $dist) { 126 127 $this->log("end"); 128 } 129 130 public function copyFile($src, $dist) 131 { 129 132 $this->arrInstallData['copy_file'][] = array( 130 133 'src' => $src, … … 132 135 ); 133 136 } 134 135 public function copyDirectory($src, $dist) { 137 138 public function copyDirectory($src, $dist) 139 { 136 140 $this->arrInstallData['copy_directory'][] = array( 137 141 'src' => $src, 138 142 'dist' => $dist 139 ); 140 } 141 142 public function removeFile($dist) { 143 ); 144 } 145 146 public function removeFile($dist) 147 { 143 148 $this->arrInstallData['remove_file'][] = array( 144 149 'dist' => $dist 145 150 ); 146 151 } 147 148 public function removeDirectory($dist) { 152 153 public function removeDirectory($dist) 154 { 149 155 $this->arrInstallData['remove_directory'][] = array( 150 156 'dist' => $dist 151 ); 152 } 153 154 public function sql($sql, array $params = array()) { 157 ); 158 } 159 160 public function sql($sql, array $params = array()) 161 { 155 162 $this->arrInstallData['sql'][] = array( 156 163 'sql' => $sql, … … 158 165 ); 159 166 } 160 161 protected function log($msg) { 167 168 protected function log($msg) 169 { 162 170 $msg = sprintf("%s %s: %s", $this->plugin_code, $this->exec_func, $msg); 163 171 GC_Utils::gfPrintLog($msg, PLUGIN_LOG_REALFILE); 164 172 } 165 173 166 174 /** 167 175 * カラム追加クエリの追加 168 * 176 * 169 177 * @param type $table 170 178 * @param type $col 171 * @param type $type 179 * @param type $type 172 180 */ 173 function addColumn($table_name, $col_name, $col_type) { 181 public function addColumn($table_name, $col_name, $col_type) 182 { 174 183 $sql = "ALTER TABLE $table_name ADD $col_name $col_type "; 175 184 $this->sql($sql); 176 185 } 177 186 178 187 /** 179 188 * カラム削除クエリの追加 180 * 189 * 181 190 * @param type $table 182 191 * @param type $col 183 * @param type $type 192 * @param type $type 184 193 */ 185 function dropColumn($table_name, $col_name) { 194 public function dropColumn($table_name, $col_name) 195 { 186 196 $sql = "ALTER TABLE $table_name DROP $col_name"; 187 197 $this->sql($sql); 188 198 } 189 190 function insert($table, $arrVal, $arrSql = array(), $arrSqlVal = array(), $from = '', $arrFromVal = array()) { 199 200 public function insert($table, $arrVal, $arrSql = array(), $arrSqlVal = array(), $from = '', $arrFromVal = array()) 201 { 191 202 $this->arrInstallData['insert'][] = array( 192 203 'table' => $table, 193 'arrVal' => $arrVal, 194 'arrSql' => $arrSql, 195 'arrSqlVal' => $arrSqlVal, 204 'arrVal' => $arrVal, 205 'arrSql' => $arrSql, 206 'arrSqlVal' => $arrSqlVal, 196 207 'form' =>$from, 197 208 'arrFromVal' => $arrFromVal 198 209 ); 199 210 } 200 201 function update($table, $arrVal, $where = '', $arrWhereVal = array(), $arrRawSql = array(), $arrRawSqlVal = array()) { 211 212 public function update($table, $arrVal, $where = '', $arrWhereVal = array(), $arrRawSql = array(), $arrRawSqlVal = array()) 213 { 202 214 $this->arrInstallData['update'][] = array( 203 215 'table' => $table, 204 'arrVal' => $arrVal, 205 'where' => $where, 206 'arrWhereVal' => $arrWhereVal, 216 'arrVal' => $arrVal, 217 'where' => $where, 218 'arrWhereVal' => $arrWhereVal, 207 219 'arrRawSql' =>$arrRawSql, 208 220 'arrRawSqlVal' => $arrRawSqlVal 209 221 ); 210 222 } 211 223 212 224 /** 213 * 225 * 214 226 * @param string $sql 215 * @param type $params227 * @param type $params 216 228 */ 217 protected function verifySql($sql, $params) { 229 protected function verifySql($sql, $params) 230 { 218 231 // FIXME $paramsのチェックも行いたい. 219 232 $objQuery =& SC_Query_Ex::getSingletonInstance(); 220 233 221 234 // force runを有効にし, システムエラーを回避する 222 235 $objQuery->force_run = true; … … 228 241 $error_message = $sth->message . ":" . $sth->userinfo; 229 242 $objQuery->force_run = false; 243 230 244 return $error_message; 231 245 } 232 246 233 247 $sth->free(); 234 248 // force_runをもとに戻す. 235 249 $objQuery->force_run = false; 236 250 237 251 return $error_message; 238 252 }
Note: See TracChangeset
for help on using the changeset viewer.