From 3a5bb69a589adc6da7909e0f47f321a12a72fe5e Mon Sep 17 00:00:00 2001
From: Lucas Bartholemy
Date: Sun, 29 Jun 2014 13:22:48 +0200
Subject: [PATCH] Show modules README.md file in admin -> module area
---
.../admin/controllers/ModuleController.php | 47 ++++++++++++++++++-
.../modules_core/admin/views/module/info.php | 29 ++++++++++++
.../modules_core/admin/views/module/list.php | 2 +
.../admin/views/module/listOnline.php | 4 +-
.../admin/views/module/listUpdates.php | 1 +
5 files changed, 80 insertions(+), 3 deletions(-)
create mode 100644 protected/modules_core/admin/views/module/info.php
diff --git a/protected/modules_core/admin/controllers/ModuleController.php b/protected/modules_core/admin/controllers/ModuleController.php
index d5d89c5557..6674d4cdb0 100644
--- a/protected/modules_core/admin/controllers/ModuleController.php
+++ b/protected/modules_core/admin/controllers/ModuleController.php
@@ -187,10 +187,10 @@ class ModuleController extends Controller
throw new CHttpException(500, Yii::t('AdminModule.modules', 'Could not find requested module!'));
}
- if (Yii::app()->moduleManager->canUninstall($moduleId)) {
+ if (!Yii::app()->moduleManager->canUninstall($moduleId)) {
throw new CHttpException(500, Yii::t('AdminModule.modules', 'Could not uninstall module first! Module is protected.'));
}
-
+
// Remove old module files
$module->removeModuleFolder();
$this->install($moduleId);
@@ -231,6 +231,49 @@ class ModuleController extends Controller
$this->render('listUpdates', array('modules' => $updates));
}
+ /**
+ * Returns more information about an installed module.
+ *
+ * @throws CHttpException
+ */
+ public function actionInfo()
+ {
+
+ $moduleId = Yii::app()->request->getQuery('moduleId');
+ $module = Yii::app()->moduleManager->getModule($moduleId);
+
+ if ($module == null) {
+ throw new CHttpException(500, Yii::t('AdminModule.modules', 'Could not find requested module!'));
+ }
+
+ $readmeMd = "";
+ $readmeMdFile = $module->getPath() . DIRECTORY_SEPARATOR . 'README.md';
+ if (file_exists($readmeMdFile)) {
+ $readmeMd = file_get_contents($readmeMdFile);
+ }
+
+ $this->renderPartial('info', array('name' => $module->getName(), 'description' => $module->getDescription(), 'content' => $readmeMd), false, true);
+ }
+
+ /**
+ * Returns informations about a online not installed module
+ *
+ * @throws CHttpException
+ */
+ public function actionInfoOnline()
+ {
+
+ $moduleId = Yii::app()->request->getQuery('moduleId');
+
+ $moduleInfo = $this->getOnlineModuleInfo($moduleId);
+
+ if (!isset($moduleInfo['latestVersion'])) {
+ throw new CException(Yii::t('AdminModule.modules', "No module version found!"));
+ }
+
+ $this->renderPartial('info', array('name' => $moduleInfo['latestVersion']['name'], 'description' => $moduleInfo['latestVersion']['description'], 'content' => $moduleInfo['latestVersion']['README.md']), false, true);
+ }
+
/**
* Installs latest compatible module version
*
diff --git a/protected/modules_core/admin/views/module/info.php b/protected/modules_core/admin/views/module/info.php
new file mode 100644
index 0000000000..c20d86e969
--- /dev/null
+++ b/protected/modules_core/admin/views/module/info.php
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+ beginWidget('CMarkdown'); ?>
+
+ endWidget(); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/protected/modules_core/admin/views/module/list.php b/protected/modules_core/admin/views/module/list.php
index f1f682d06d..a3f98fbd0b 100644
--- a/protected/modules_core/admin/views/module/list.php
+++ b/protected/modules_core/admin/views/module/list.php
@@ -40,6 +40,8 @@
· $moduleId), array('confirm' => Yii::t('AdminModule.modules', 'Are you sure? - All module data will be lost!'))); ?>
+ · $moduleId), array('data-target'=>'#globalModal', 'data-toggle'=>'modal')); ?>
+
diff --git a/protected/modules_core/admin/views/module/listOnline.php b/protected/modules_core/admin/views/module/listOnline.php
index bd0b3db64b..df96da186e 100644
--- a/protected/modules_core/admin/views/module/listOnline.php
+++ b/protected/modules_core/admin/views/module/listOnline.php
@@ -36,7 +36,9 @@
·
-
+
+ · $module['id']), array('data-target'=>'#globalModal', 'data-toggle'=>'modal')); ?>
+
diff --git a/protected/modules_core/admin/views/module/listUpdates.php b/protected/modules_core/admin/views/module/listUpdates.php
index 0d196f30ce..63b06ad16b 100644
--- a/protected/modules_core/admin/views/module/listUpdates.php
+++ b/protected/modules_core/admin/views/module/listUpdates.php
@@ -26,6 +26,7 @@
moduleManager->getModule($module['id'])->getVersion(); ?>
·
· createUrl('update', array('moduleId' => $module['id']))); ?>
+ · $module['id']), array('data-target'=>'#globalModal', 'data-toggle'=>'modal')); ?>