Changeset 22034 for branches/version-2_12-dev/data/class/pages/admin/ownersstore/LC_Page_Admin_OwnersStore.php
- Timestamp:
- 2012/09/19 19:21:32 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/class/pages/admin/ownersstore/LC_Page_Admin_OwnersStore.php
r22033 r22034 82 82 $this->arrErr = $this->checkUploadFile($file_key); 83 83 if ($this->isError($this->arrErr) === false) { 84 $upload_file = $_FILES[$file_key]; 85 $upload_file_file_name = $upload_file['name']; 84 $archive_file_name = $_FILES[$file_key]['name']; 86 85 // インストール処理. 87 $this->arrErr = $this->installPlugin($ upload_file_file_name, 'plugin_file');86 $this->arrErr = $this->installPlugin($archive_file_name, 'plugin_file'); 88 87 if ($this->isError($this->arrErr) === false) { 89 88 // コンパイルファイルのクリア処理 … … 112 111 // 有効化 113 112 case 'enable': 114 115 113 // エラーチェック 116 114 $this->arrErr = $objFormParam->checkError(); … … 315 313 */ 316 314 function getHtmlPluginDir($plugin_code) { 317 $plugin_ dir_path = PLUGIN_HTML_REALDIR . $plugin_code . '/';318 return $plugin_ dir_path;315 $plugin_html_dir_path = PLUGIN_HTML_REALDIR . $plugin_code . '/'; 316 return $plugin_html_dir_path; 319 317 } 320 318 … … 323 321 * 324 322 * @param string $plugin_code プラグインコード 323 * @param string $plugin_class プラグインクラス名 325 324 * @return string $plugin_file_path クラスファイルのパス. 326 325 */ 327 function getPluginFilePath($plugin_code ) {328 $plugin_file_path = $this->getPluginDir($plugin_code) . $plugin_c ode. '.php';326 function getPluginFilePath($plugin_code , $plugin_class) { 327 $plugin_file_path = $this->getPluginDir($plugin_code) . $plugin_class . '.php'; 329 328 return $plugin_file_path; 330 329 } … … 333 332 * プラグインをインストールします. 334 333 * 335 * @param string $ plugin_code プラグインコード.334 * @param string $archive_file_name アーカイブファイル名. 336 335 * @param string $key キー. 337 336 * @return array エラー情報を格納した連想配列. 338 337 */ 339 function installPlugin($upload_file_file_name, $key) { 340 // インストール前に不要なファイルを消しておきます. 341 SC_Helper_FileManager_Ex::deleteFile(DOWNLOADS_TEMP_PLUGIN_INSTALL_DIR, false); 342 338 function installPlugin($archive_file_name, $key) { 339 // 一時展開ディレクトリにファイルがある場合は事前に削除. 340 $arrFileHash = SC_Helper_FileManager_Ex::sfGetFileList(DOWNLOADS_TEMP_PLUGIN_INSTALL_DIR); 341 if(count($arrFileHash) > 0) { 342 SC_Helper_FileManager_Ex::deleteFile(DOWNLOADS_TEMP_PLUGIN_INSTALL_DIR, false); 343 } 344 343 345 //シンタックスエラーがあるtar.gzをアップ後、削除するとたまにディレクトリが消えるので追加 344 346 $this->makeDir(PLUGIN_UPLOAD_REALDIR); … … 351 353 } 352 354 // ファイルをチェックし一時展開用ディレクトリに展開します. 353 $arrErr = $this->unpackPluginFile($ upload_file_file_name, DOWNLOADS_TEMP_PLUGIN_INSTALL_DIR, $key);355 $arrErr = $this->unpackPluginFile($archive_file_name, DOWNLOADS_TEMP_PLUGIN_INSTALL_DIR, $key); 354 356 if ($this->isError($arrErr) === true) { 355 357 return $arrErr; … … 372 374 } 373 375 374 // プラグインコード375 $plugin_code = $arrPluginInfo['PLUGIN_CODE'];376 // プラグイン名377 $plugin_name = $arrPluginInfo['PLUGIN_NAME'];378 379 376 // 既にインストールされていないかを判定. 380 if ($this->isInstalledPlugin($ plugin_code) === true) {377 if ($this->isInstalledPlugin($arrPluginInfo['PLUGIN_CODE']) === true) { 381 378 $this->rollBack(DOWNLOADS_TEMP_PLUGIN_INSTALL_DIR); 382 $arrErr['plugin_file'] = '※ ' . $ plugin_name. 'は既にインストールされています。<br/>';379 $arrErr['plugin_file'] = '※ ' . $arrPluginInfo['PLUGIN_NAME'] . 'は既にインストールされています。<br/>'; 383 380 return $arrErr; 384 381 } … … 392 389 393 390 // プラグイン保存ディレクトリを作成し、一時展開用ディレクトリから移動します. 394 $plugin_dir_path = PLUGIN_UPLOAD_REALDIR . $plugin_code . '/';391 $plugin_dir_path = $this->getPluginDir($arrPluginInfo['PLUGIN_CODE']); 395 392 $this->makeDir($plugin_dir_path); 396 393 SC_Utils_Ex::copyDirectory(DOWNLOADS_TEMP_PLUGIN_INSTALL_DIR, $plugin_dir_path); 397 394 398 395 // プラグイン情報を取得 399 $plugin = SC_Plugin_Util_Ex::getPluginByPluginCode($ plugin_code);396 $plugin = SC_Plugin_Util_Ex::getPluginByPluginCode($arrPluginInfo['PLUGIN_CODE']); 400 397 401 398 // クラスファイルを読み込み. 402 $plugin_class_file_path = $ plugin_dir_path . $plugin['class_name'] . '.php';399 $plugin_class_file_path = $this->getPluginFilePath($plugin['plugin_code'], $plugin['class_name']); 403 400 $arrErr = $this->requirePluginFile($plugin_class_file_path, $key); 404 401 if ($this->isError($arrErr) === true) { … … 407 404 } 408 405 // プラグインhtmlディレクトリ作成 409 $plugin_html_dir = PLUGIN_HTML_REALDIR . $plugin_code;410 $this->makeDir($plugin_html_dir );406 $plugin_html_dir_path = $this->getHtmlPluginDir($plugin['plugin_code']); 407 $this->makeDir($plugin_html_dir_path); 411 408 412 409 $arrErr = $this->execPlugin($plugin, $plugin['class_name'], 'install'); 413 410 if ($this->isError($arrErr) === true) { 414 $this->rollBack(DOWNLOADS_TEMP_PLUGIN_INSTALL_DIR, $plugin['plugin_id'], $plugin_html_dir );411 $this->rollBack(DOWNLOADS_TEMP_PLUGIN_INSTALL_DIR, $plugin['plugin_id'], $plugin_html_dir_path); 415 412 return $arrErr; 416 413 } … … 427 424 * @param string $temp_dir インストール・アップデート時の一時展開用ディレクトリのパス. 428 425 * @param string $plugin_id プラグインID. 429 * @param string $plugin_html_dir プラグイン毎に生成されるhtmlディレクトリのパス.430 */ 431 function rollBack($temp_dir, $plugin_id = '', $plugin_html_dir ='') {426 * @param string $plugin_html_dir_path プラグイン毎に生成されるhtmlディレクトリのパス. 427 */ 428 function rollBack($temp_dir, $plugin_id = '', $plugin_html_dir_path ='') { 432 429 // 一時ディレクトリを削除. 433 430 SC_Helper_FileManager_Ex::deleteFile($temp_dir, false); … … 437 434 } 438 435 // htmlディレクトリを削除 439 if (empty($plugin_html_dir ) === false) {440 SC_Helper_FileManager_Ex::deleteFile($plugin_html_dir , true);436 if (empty($plugin_html_dir_path) === false) { 437 SC_Helper_FileManager_Ex::deleteFile($plugin_html_dir_path, true); 441 438 } 442 439 } … … 483 480 * 484 481 * @param ReflectionClass $objReflection リフレクションオブジェクト 482 * @param string $dir_path チェックするプラグインディレクトリ 485 483 * @return array エラー情報を格納した連想配列. 486 484 */ 487 function checkPluginConstants(ReflectionClass $objReflection, $ unpack_dir) {485 function checkPluginConstants(ReflectionClass $objReflection, $dir_path) { 488 486 $arrErr = array(); 489 487 // プラグイン情報を取得 … … 502 500 return $arrErr; 503 501 } 504 $ class_path = $unpack_dir. $arrPluginInfo['CLASS_NAME'] . '.php';505 if (file_exists($ class_path) === false) {502 $plugin_class_file_path = $dir_path . $arrPluginInfo['CLASS_NAME'] . '.php'; 503 if (file_exists($plugin_class_file_path) === false) { 506 504 $arrErr['plugin_file'] = '※ CLASS_NAMEが正しく定義されていません。<br/>'; 507 505 return $arrErr; … … 550 548 * プラグインをアップデートします. 551 549 * 552 * @param string $target_plugin アップデートするプラグインコード.550 * @param array $target_plugin アップデートするプラグイン情報の配列. 553 551 * @param string $upload_file_name アップロードファイル名. 554 552 * @return array エラー情報を格納した連想配列. … … 598 596 * 599 597 * @param string $unpack_file_name 解凍ファイル名 600 * @param string $unpack_dir 解凍先ディレクトリ598 * @param string $unpack_dir_path 解凍先ディレクトリパス 601 599 * @param string $file_key ファイルキー 602 600 * @return array エラー情報を格納した連想配列. 603 601 */ 604 function unpackPluginFile($unpack_file_name, $unpack_dir , $file_key) {602 function unpackPluginFile($unpack_file_name, $unpack_dir_path, $file_key) { 605 603 $arrErr = array(); 606 604 // 解凍ディレクトリディレクトリを作成し、一時ディレクトリからファイルを移動 607 $objUpFile = new SC_UploadFile_Ex(PLUGIN_TEMP_REALDIR, $unpack_dir );605 $objUpFile = new SC_UploadFile_Ex(PLUGIN_TEMP_REALDIR, $unpack_dir_path); 608 606 $this->initUploadFile($objUpFile, $file_key); 609 607 $arrErr = $objUpFile->makeTempFile($file_key, false); … … 619 617 $objUpFile->moveTempFile(); 620 618 // 解凍 621 $u pdate_plugin_file_path = $unpack_dir. $unpack_file_name;622 if (!$this->unpackPluginArchive($u pdate_plugin_file_path)) {619 $unpack_file_path = $unpack_dir_path . $unpack_file_name; 620 if (!$this->unpackPluginArchive($unpack_file_path)) { 623 621 $arrErr['plugin_file'] = '※ 解凍に失敗しました。<br/>'; 624 622 return $arrErr; … … 636 634 $arrErr = array(); 637 635 // プラグインファイルを読み込みます. 638 $plugin_class_file_path = PLUGIN_UPLOAD_REALDIR . $plugin['plugin_code'] . '/' . $plugin['class_name'] . '.php';636 $plugin_class_file_path = $this->getPluginFilePath($plugin['plugin_code'], $plugin['class_name']); 639 637 $arrErr = $this->requirePluginFile($plugin_class_file_path, 'plugin_error'); 640 638 if ($this->isError($arrErr) === true) { … … 670 668 $arrErr = array(); 671 669 // クラスファイルを読み込み. 672 $plugin_class_file_path = PLUGIN_UPLOAD_REALDIR . $plugin['plugin_code'] . '/' . $plugin['class_name'] . '.php';670 $plugin_class_file_path = $this->getPluginFilePath($plugin['plugin_code'], $plugin['class_name']); 673 671 $arrErr = $this->requirePluginFile($plugin_class_file_path, 'plugin_error'); 674 672 if ($this->isError($arrErr) === true) { … … 695 693 $arrErr = array(); 696 694 // クラスファイルを読み込み. 697 $plugin_class_file_path = PLUGIN_UPLOAD_REALDIR . $plugin['plugin_code'] . '/' . $plugin['class_name'] . '.php';695 $plugin_class_file_path =$this->getPluginFilePath($plugin['plugin_code'], $plugin['class_name']); 698 696 $arrErr = $this->requirePluginFile($plugin_class_file_path, 'plugin_error'); 699 697 if ($this->isError($arrErr) === true) {
Note: See TracChangeset
for help on using the changeset viewer.