diff --git a/app/appadmin/modules/System/block/extensioninstalled/Manager.php b/app/appadmin/modules/System/block/extensioninstalled/Manager.php index 5732787e50ad254188d2e342ded54cb4f6b0f2b4..7f9d370acca5c797c00986319c7feed7a0896214 100644 --- a/app/appadmin/modules/System/block/extensioninstalled/Manager.php +++ b/app/appadmin/modules/System/block/extensioninstalled/Manager.php @@ -24,6 +24,7 @@ class Manager extends AppadminbaseBlock implements AppadminbaseBlockInterface { public $_enableUrl; public $_disableUrl; + public $_viewUrl; /** * init param function ,execute in construct. */ @@ -33,6 +34,7 @@ class Manager extends AppadminbaseBlock implements AppadminbaseBlockInterface * edit data url */ $this->_editUrl = CUrl::getUrl('system/extensioninstalled/manageredit'); + $this->_viewUrl = CUrl::getUrl('system/extensioninstalled/managerview'); /* * delete data url */ @@ -173,6 +175,13 @@ class Manager extends AppadminbaseBlock implements AppadminbaseBlockInterface 'align' => 'center', 'convert' => ['int' => 'datetime'], ], + + [ + 'orderField' => 'priority', + 'label' => Yii::$service->page->translate->__('Priority'), + 'width' => '50', + 'align' => 'left', + ], [ 'orderField' => 'updated_at', 'label' => Yii::$service->page->translate->__('Updated At'), @@ -264,8 +273,10 @@ class Manager extends AppadminbaseBlock implements AppadminbaseBlockInterface $str .= ''.$val.''; } $str .= ' - - '; + + + + '; $str .= ''; } diff --git a/app/appadmin/modules/System/block/extensioninstalled/Manageredit.php b/app/appadmin/modules/System/block/extensioninstalled/Manageredit.php index 6f18fd2281399f6fa807099781b50836726575bf..2745f5231abb7a8fa2063f70c2ac73657d5a25eb 100644 --- a/app/appadmin/modules/System/block/extensioninstalled/Manageredit.php +++ b/app/appadmin/modules/System/block/extensioninstalled/Manageredit.php @@ -49,30 +49,6 @@ class Manageredit extends AppadminbaseBlockEdit implements AppadminbaseBlockEdit public function getEditArr() { return [ - [ - 'label' => Yii::$service->page->translate->__('Extension Name'), - 'name' => 'name', - 'display' => [ - 'type' => 'inputString', - ], - 'require' => 1, - ], - [ - 'label' => Yii::$service->page->translate->__('Extension Package'), - 'name' => 'package', - 'display' => [ - 'type' => 'inputString', - ], - 'require' => 1, - ], - [ - 'label' => Yii::$service->page->translate->__('Extension Folder'), - 'name' => 'folder', - 'display' => [ - 'type' => 'inputString', - ], - 'require' => 1, - ], [ 'label' => Yii::$service->page->translate->__('Status'), 'name' => 'status', @@ -86,43 +62,6 @@ class Manageredit extends AppadminbaseBlockEdit implements AppadminbaseBlockEdit 'require' => 1, 'default' => 1, ], - [ - 'label' => Yii::$service->page->translate->__('Extension Type'), - 'name' => 'type', - 'display' => [ - 'type' => 'select', - 'data' => Yii::$service->extension->getTypeArr(), - ], - 'require' => 1, - 'default' => 1, - ], - [ - 'label' => Yii::$service->page->translate->__('Namespace'), - 'name' => 'namespace', - 'display' => [ - 'type' => 'inputString', - ], - 'require' => 1, - ], - - - [ - 'label' => Yii::$service->page->translate->__('Config File Path'), - 'name' => 'config_file_path', - 'display' => [ - 'type' => 'inputString', - ], - 'require' => 1, - ], - - [ - 'label' => Yii::$service->page->translate->__('Extension Version'), - 'name' => 'version', - 'display' => [ - 'type' => 'inputString', - ], - 'require' => 1, - ], [ 'label' => Yii::$service->page->translate->__('Priority'), @@ -132,16 +71,6 @@ class Manageredit extends AppadminbaseBlockEdit implements AppadminbaseBlockEdit ], 'require' => 1, ], - [ - 'label' => Yii::$service->page->translate->__('Installed Status'), - 'name' => 'installed_status', - 'display' => [ - 'type' => 'select', - 'data' => Yii::$service->extension->getInstallStatusArr(), - ], - 'require' => 1, - 'default' => 1, - ], ]; } @@ -157,21 +86,49 @@ class Manageredit extends AppadminbaseBlockEdit implements AppadminbaseBlockEdit * if attribute is date or date time , db storage format is int ,by frontend pass param is int , * you must convert string datetime to time , use strtotime function. */ - $this->_service->save($this->_param, 'cms/article/index'); - $errors = Yii::$service->helper->errors->get(); - if (!$errors) { + $status = $this->_param['status']; + $priority = $this->_param['priority']; + $id = $this->_param['id']; + if (!$status) { echo json_encode([ - 'statusCode' => '200', - 'message' => Yii::$service->page->translate->__('Save Success'), + 'statusCode' => '300', + 'message' => Yii::$service->page->translate->__('status can not empty'), ]); exit; - } else { + } + if (!$priority) { + echo json_encode([ + 'statusCode' => '300', + 'message' => Yii::$service->page->translate->__('priority can not empty'), + ]); + exit; + } + if (!$id) { + echo json_encode([ + 'statusCode' => '300', + 'message' => Yii::$service->page->translate->__('id can not empty'), + ]); + exit; + } + $saveStatus = $this->_service->save([ + 'id' => $id, + 'priority' => $priority, + 'status' => $status, + ]); + if (!$saveStatus) { + $errors = Yii::$service->helper->errors->get(); echo json_encode([ 'statusCode' => '300', 'message' => $errors, ]); exit; } + + echo json_encode([ + 'statusCode' => '200', + 'message' => Yii::$service->page->translate->__('Save Success'), + ]); + exit; } // 插件激活 public function extensionEnable() diff --git a/app/appadmin/modules/System/block/extensioninstalled/Managerview.php b/app/appadmin/modules/System/block/extensioninstalled/Managerview.php new file mode 100644 index 0000000000000000000000000000000000000000..8e211ae367d835d07e19561398e85e539cbf8789 --- /dev/null +++ b/app/appadmin/modules/System/block/extensioninstalled/Managerview.php @@ -0,0 +1,240 @@ + + * @since 1.0 + */ +class Managerview extends AppadminbaseBlockEdit implements AppadminbaseBlockEditInterface +{ + public $_saveUrl; + + public function init() + { + $this->_saveUrl = CUrl::getUrl('system/extensioninstalled/managereditsave'); + parent::init(); + } + + // 传递给前端的数据 显示编辑form + public function getLastData() + { + return [ + 'editBar' => $this->getEditBar(), + 'textareas' => $this->_textareas, + 'lang_attr' => $this->_lang_attr, + 'saveUrl' => $this->_saveUrl, + ]; + } + + public function setService() + { + $this->_service = Yii::$service->extension; + } + + public function getEditArr() + { + return [ + [ + 'label' => Yii::$service->page->translate->__('Extension Name'), + 'name' => 'name', + 'display' => [ + 'type' => 'inputString', + ], + 'require' => 1, + ], + [ + 'label' => Yii::$service->page->translate->__('Extension Package'), + 'name' => 'package', + 'display' => [ + 'type' => 'inputString', + ], + 'require' => 1, + ], + [ + 'label' => Yii::$service->page->translate->__('Extension Folder'), + 'name' => 'folder', + 'display' => [ + 'type' => 'inputString', + ], + 'require' => 1, + ], + [ + 'label' => Yii::$service->page->translate->__('Status'), + 'name' => 'status', + 'display' => [ + 'type' => 'select', + 'data' => [ + 1 => Yii::$service->page->translate->__('Enable'), + 2 => Yii::$service->page->translate->__('Disable'), + ], + ], + 'require' => 1, + 'default' => 1, + ], + [ + 'label' => Yii::$service->page->translate->__('Extension Type'), + 'name' => 'type', + 'display' => [ + 'type' => 'select', + 'data' => Yii::$service->extension->getTypeArr(), + ], + 'require' => 1, + 'default' => 1, + ], + [ + 'label' => Yii::$service->page->translate->__('Namespace'), + 'name' => 'namespace', + 'display' => [ + 'type' => 'inputString', + ], + 'require' => 1, + ], + + + [ + 'label' => Yii::$service->page->translate->__('Config File Path'), + 'name' => 'config_file_path', + 'display' => [ + 'type' => 'inputString', + ], + 'require' => 1, + ], + + [ + 'label' => Yii::$service->page->translate->__('Extension Version'), + 'name' => 'version', + 'display' => [ + 'type' => 'inputString', + ], + 'require' => 1, + ], + + [ + 'label' => Yii::$service->page->translate->__('Priority'), + 'name' => 'priority', + 'display' => [ + 'type' => 'inputString', + ], + 'require' => 1, + ], + [ + 'label' => Yii::$service->page->translate->__('Installed Status'), + 'name' => 'installed_status', + 'display' => [ + 'type' => 'select', + 'data' => Yii::$service->extension->getInstallStatusArr(), + ], + 'require' => 1, + 'default' => 1, + ], + + ]; + } + + /** + * save article data, get rewrite url and save to article url key. + */ + public function save() + { + $request_param = CRequest::param(); + $this->_param = $request_param[$this->_editFormData]; + /* + * if attribute is date or date time , db storage format is int ,by frontend pass param is int , + * you must convert string datetime to time , use strtotime function. + */ + $this->_service->save($this->_param, 'cms/article/index'); + $errors = Yii::$service->helper->errors->get(); + if (!$errors) { + echo json_encode([ + 'statusCode' => '200', + 'message' => Yii::$service->page->translate->__('Save Success'), + ]); + exit; + } else { + echo json_encode([ + 'statusCode' => '300', + 'message' => $errors, + ]); + exit; + } + } + // 插件激活 + public function extensionEnable() + { + $ids = Yii::$app->request->post('ids'); + $idArr = explode(',', $ids); + if (!Yii::$service->extension->enableAddons($idArr)) { + echo json_encode([ + 'statusCode' => '300', + 'message' => Yii::$service->page->translate->__('Enable Extension fail'), + ]); + exit; + } + echo json_encode([ + 'statusCode' => '200', + 'message' => Yii::$service->page->translate->__('Enable Extension Success') , + ]); + exit; + } + // 插件关闭 + public function extensionDisable() + { + $ids = Yii::$app->request->post('ids'); + $idArr = explode(',', $ids); + if (!Yii::$service->extension->disableAddons($idArr)) { + echo json_encode([ + 'statusCode' => '300', + 'message' => Yii::$service->page->translate->__('Enable Extension fail'), + ]); + exit; + } + echo json_encode([ + 'statusCode' => '200', + 'message' => Yii::$service->page->translate->__('Enable Extension Success') , + ]); + exit; + + + } + + // 批量删除 + public function delete() + { + $ids = ''; + if ($id = CRequest::param($this->_primaryKey)) { + $ids = $id; + } elseif ($ids = CRequest::param($this->_primaryKey.'s')) { + $ids = explode(',', $ids); + } + $this->_service->remove($ids); + $errors = Yii::$service->helper->errors->get(); + if (!$errors) { + echo json_encode([ + 'statusCode' => '200', + 'message' => Yii::$service->page->translate->__('Remove Success') , + ]); + exit; + } else { + echo json_encode([ + 'statusCode' => '300', + 'message' => $errors, + ]); + exit; + } + } +} diff --git a/app/appadmin/modules/System/controllers/ExtensioninstalledController.php b/app/appadmin/modules/System/controllers/ExtensioninstalledController.php index 43ed1c148f2370b02754c93a1a47ef7e7f294878..84fdab2ac073aa5118c90ff58298742f86fa3ee6 100644 --- a/app/appadmin/modules/System/controllers/ExtensioninstalledController.php +++ b/app/appadmin/modules/System/controllers/ExtensioninstalledController.php @@ -34,6 +34,13 @@ class ExtensioninstalledController extends SystemController return $this->render($this->action->id, $data); } + public function actionManagerview() + { + $data = $this->getBlock()->getLastData(); + + return $this->render($this->action->id, $data); + } + public function actionManagerenable() { $data = $this->getBlock('manageredit')->extensionEnable(); @@ -46,12 +53,12 @@ class ExtensioninstalledController extends SystemController - /* + public function actionManagereditsave() { $data = $this->getBlock('manageredit')->save(); } - + /* public function actionManagerdelete() { $this->getBlock('manageredit')->delete(); diff --git a/app/appadmin/theme/base/default/system/extensioninstalled/manageredit.php b/app/appadmin/theme/base/default/system/extensioninstalled/manageredit.php index cc6d8d3b42cf94503c31f88415fae2138130485a..2786e5bcdba516ec7d346713b2a0706ec7271b75 100644 --- a/app/appadmin/theme/base/default/system/extensioninstalled/manageredit.php +++ b/app/appadmin/theme/base/default/system/extensioninstalled/manageredit.php @@ -35,7 +35,17 @@ use fecadmin\models\AdminRole; - +
+ +
diff --git a/app/appadmin/theme/base/default/system/extensioninstalled/managerview.php b/app/appadmin/theme/base/default/system/extensioninstalled/managerview.php new file mode 100644 index 0000000000000000000000000000000000000000..ea5d6772c6ce2bd2295812c61f703b902fa76b1f --- /dev/null +++ b/app/appadmin/theme/base/default/system/extensioninstalled/managerview.php @@ -0,0 +1,49 @@ + + * @since 1.0 + */ +?> + + +
+
+ +
+ +
+ page->translate->__('Edit Info') ?> +
+ +
+
+ + + +
+ +
+
+ +