Show modules README.md file in admin -> module area

This commit is contained in:
Lucas Bartholemy 2014-06-29 13:22:48 +02:00
parent 5c83ee389a
commit 3a5bb69a58
5 changed files with 80 additions and 3 deletions

View File

@ -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
*

View File

@ -0,0 +1,29 @@
<div class="modal-dialog modal-dialog-small animated fadeIn">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title"
id="myModalLabel"><?php echo Yii::t('AdminModule.modules', 'More information: %moduleName%', array('%moduleName%' => $name)); ?></h4>
</div>
<div class="modal-body">
<?php if ($content != ""): ?>
<?php $this->beginWidget('CMarkdown'); ?>
<?php echo $content; ?>
<?php $this->endWidget(); ?>
<?php else: ?>
<?php echo $description; ?>
<br />
<br />
<?php echo Yii::t('AdminModule.modules', 'This module doesn\'t provide further informations.'); ?>
<?php endif; ?>
</div>
</div>
</div>

View File

@ -40,6 +40,8 @@
&middot; <?php echo HHtml::postLink(Yii::t('AdminModule.modules', 'Uninstall'), array('//admin/module/uninstall', 'moduleId' => $moduleId), array('confirm' => Yii::t('AdminModule.modules', 'Are you sure? - All module data will be lost!'))); ?>
<?php endif; ?>
&middot; <?php echo HHtml::link(Yii::t('AdminModule.modules', 'More info'), array('//admin/module/info', 'moduleId' => $moduleId), array('data-target'=>'#globalModal', 'data-toggle'=>'modal')); ?>
</small></p>
</div>

View File

@ -36,7 +36,9 @@
<?php else : ?>
&middot; <span style="color:red"><?php echo Yii::t('AdminModule.modules', 'No compatible module version found!'); ?></span>
<?php endif; ?>
&middot; <?php echo HHtml::link(Yii::t('AdminModule.modules', 'More info'), array('//admin/module/infoOnline', 'moduleId' => $module['id']), array('data-target'=>'#globalModal', 'data-toggle'=>'modal')); ?>
</small>
</p>
</div>

View File

@ -26,6 +26,7 @@
<?php echo Yii::t('AdminModule.modules', 'Installed version:'); ?> <?php echo Yii::app()->moduleManager->getModule($module['id'])->getVersion(); ?>
&middot; <?php echo Yii::t('AdminModule.modules', 'Latest compatible Version:'); ?> <?php echo $module['latestCompatibleVersion']; ?>
&middot; <?php echo HHtml::postLink(Yii::t('AdminModule.modules', 'Update'), $this->createUrl('update', array('moduleId' => $module['id']))); ?>
&middot; <?php echo HHtml::link(Yii::t('AdminModule.modules', 'More info'), array('//admin/module/infoOnline', 'moduleId' => $module['id']), array('data-target'=>'#globalModal', 'data-toggle'=>'modal')); ?>
<?php endif; ?>
</small>
</p>