Commit d2bcc198 authored by Robert Lyon's avatar Robert Lyon

Bug 1409546: Allowing plugin page to show plugin name

Instead of the plugin's directory name so that we can change the
plugin's displayed name without having to move/change the directory
name.

Change-Id: Iacafb89dc8aaaa284ec57323f7e889679385c567
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent c479f2c3
......@@ -43,10 +43,12 @@ foreach (array_keys($plugins) as $plugin) {
continue;
}
$classname = generate_class_name($plugin, $key);
$plugins[$plugin]['installed'][$key] = array(
'active' => $i->active,
'disableable' => call_static_method(generate_class_name($plugin, $key), 'can_be_disabled'),
'deprecated' => method_exists(generate_class_name($plugin, $key), 'is_deprecated') ? call_static_method(generate_class_name($plugin, $key), 'is_deprecated') : 0,
'disableable' => call_static_method($classname, 'can_be_disabled'),
'deprecated' => method_exists($classname, 'is_deprecated') ? call_static_method($classname, 'is_deprecated') : 0,
'name' => method_exists($classname, 'get_plugin_name') ? call_static_method($classname, 'get_plugin_name') : null,
);
if ($plugins[$plugin]['installed'][$key]['disableable'] || !$i->active) {
$plugins[$plugin]['installed'][$key]['activateform'] = activate_plugin_form($plugin, $i);
......@@ -100,6 +102,10 @@ foreach (array_keys($plugins) as $plugin) {
validate_plugin($plugin, $dir);
$classname = generate_class_name($plugin, $dir);
$classname::sanity_check();
if (method_exists($classname, 'get_plugin_name')) {
$name = call_static_method($classname, 'get_plugin_name');
$plugins[$plugin]['notinstalled'][$dir]['name'] = $name;
}
}
catch (InstallationException $e) {
$plugins[$plugin]['notinstalled'][$dir]['notinstallable'] = $e->GetMessage();
......
......@@ -4728,6 +4728,20 @@ function pieform($data) {
return Pieform::process($data);
}
/**
* Wrapper for setting up Pieform headdata.
* When there is no pieforms on the page but pieforms are called via ajax
*
* @param array $elements A Piefrom element array if one needs to set element specific headdata js files
*/
function pieform_setup_headdata($elements = null) {
$elements = is_null($elements) ? array('dummy' => array('type' => 'hidden', 'value' => 0)) : $elements;
if (empty($GLOBALS['_PIEFORM_REGISTRY'])) {
$fakeform = pieform_instance(array('name' => 'fakeform', 'elements' => $elements));
}
}
/**
* Check if the given input is a serialized string
* @param varied $sstr
......
......@@ -237,6 +237,9 @@ function check_upgrades($name=null) {
$classname = generate_class_name($plugintype, $pluginname);
safe_require($plugintype, $pluginname);
// Check if there is a displayname
$plugininfo->displayname = method_exists($classname, 'get_plugin_name') ? call_static_method($classname, 'get_plugin_name') : null;
try {
$classname::sanity_check();
}
......@@ -280,6 +283,8 @@ function check_upgrades($name=null) {
$classname = generate_class_name($plugintype, $pluginname);
safe_require($plugintype, $pluginname);
// Check if there is a displayname
$plugininfo->displayname = method_exists($classname, 'get_plugin_name') ? call_static_method($classname, 'get_plugin_name') : null;
try {
$classname::sanity_check();
}
......@@ -1411,6 +1416,10 @@ function set_antispam_defaults() {
}
function activate_plugin_form($plugintype, $plugin) {
// Check if there is a displayname
$classname = generate_class_name($plugintype, $plugin->name);
$plugin->displayname = method_exists($classname, 'get_plugin_name') ? call_static_method($classname, 'get_plugin_name') : null;
return pieform(array(
'name' => 'activate_' . $plugintype . '_' . $plugin->name,
'renderer' => 'div',
......@@ -1428,7 +1437,7 @@ function activate_plugin_form($plugintype, $plugin) {
'type' => 'button',
'usebuttontag' => true,
'class' => 'btn-default',
'title' => ($plugin->active ? get_string('hide') : get_string('show')) . ' ' . $plugintype . ' ' . $plugin->name,
'title' => ($plugin->active ? get_string('hide') : get_string('show')) . ' ' . $plugintype . ' ' . (($plugin->displayname) ? $plugin->displayname : $plugin->name),
'hiddenlabel' => true,
'value' => $plugin->active ? get_string('hide') : get_string('show')
),
......
......@@ -34,7 +34,7 @@ class PluginModuleFramework extends PluginModule {
* @return string ShortName of the plugin
*/
public static function get_plugin_name() {
return 'framework';
return 'smartevidence';
}
public static function postinst($prevversion) {
......
......@@ -22,6 +22,8 @@ require_once(get_config('libroot') . 'institution.php');
safe_require('module', 'framework');
safe_require('artefact', 'comment');
pieform_setup_headdata();
// This page should only be viewable if:
// 1). The collection has_framework() return true
// 2). The institution the collection owner belongs to has 'Smart Evidence' turned on.
......
......@@ -15,11 +15,12 @@
</li>
{foreach from=$notinstalled key='plugin' item='data'}
<li class="list-group-item list-group-item-danger" id="{$plugintype}.{$plugin}">{$plugin}
<li class="list-group-item list-group-item-danger" id="{$plugintype}.{$plugin}">
{if $data.name}{$data.name}{else}{$plugin}{/if}
{if $data.notinstallable}
{str tag='notinstallable'}: {$data.notinstallable}
{else}
<span id="{$plugintype}.{$plugin}.install">(<a href="" onClick="{$installlink}('{$plugintype}.{$plugin}'); return false;">{str tag='install' section='admin'} <span class="accessible-hidden sr-only">{$plugintype} {$plugin}</span></a>)</span>
<span id="{$plugintype}.{$plugin}.install">(<a href="" onClick="{$installlink}('{$plugintype}.{$plugin}'); return false;">{str tag='install' section='admin'} <span class="accessible-hidden sr-only">{$plugintype} {if $data.name}{$data.name}{else}{$plugin}{/if}</span></a>)</span>
{/if}
<span id="{$plugintype}.{$plugin}.message"></span>
</li>
......@@ -35,12 +36,13 @@
{foreach from=$installed key='plugin' item='data'}
<li class="list-group-item{if !$data.active} list-group-item-warning{/if}" id="{$plugintype}.{$plugin}">
<div class="list-group-item-heading">
{$plugin} {if $data.deprecated}{str tag=deprecated section=admin}{/if}
{if $data.name}{$data.name}{else}{$plugin}{/if}
{if $data.deprecated}{str tag=deprecated section=admin}{/if}
<div class="btn-group btn-group-top">
{if $data.config}
<a class="btn btn-default pull-left btn-group-item" title="{str tag='configfor'} {$plugintype} {$plugin}" href="pluginconfig.php?plugintype={$plugintype}&amp;pluginname={$plugin}">
<a class="btn btn-default pull-left btn-group-item" title="{str tag='configfor'} {$plugintype} {if $data.name}{$data.name}{else}{$plugin}{/if}" href="pluginconfig.php?plugintype={$plugintype}&amp;pluginname={$plugin}">
<span class="icon icon-cog icon-lg" role="presentation" aria-hidden="true"></span>
<span class="accessible-hidden sr-only ">{str tag='configfor'} {$plugintype} {$plugin}</span>
<span class="accessible-hidden sr-only ">{str tag='configfor'} {$plugintype} {if $data.name}{$data.name}{else}{$plugin}{/if}</span>
</a>
{/if}
{if $data.activateform}
......@@ -56,9 +58,9 @@
<li>
{$type}
{if $config}
<a class="btn btn-default btn-xs btn-group pull-right" title="{str tag='configfor'} {$plugintype} {$plugin}" href="pluginconfig.php?plugintype={$plugintype}&amp;pluginname={$plugin}&amp;type={$type}">
<a class="btn btn-default btn-xs btn-group pull-right" title="{str tag='configfor'} {$plugintype} {if $data.name}{$data.name}{else}{$plugin}{/if}" href="pluginconfig.php?plugintype={$plugintype}&amp;pluginname={$plugin}&amp;type={$type}">
<span class="icon icon-cog icon-lg" role="presentation" aria-hidden="true"></span>
<span class="accessible-hidden sr-only">{str tag='configfor'} {$plugintype} {$plugin}</span>
<span class="accessible-hidden sr-only">{str tag='configfor'} {$plugintype} {if $data.name}{$data.name}{else}{$plugin}{/if}</span>
</a>
{/if}
</li>
......
......@@ -28,7 +28,7 @@
{foreach from=$upgrades key=key item=upgrade}
{if $key != 'settings' && $upgrade->upgrade}
<tr>
<td><strong>{$key}</strong></td>
<td><strong>{if $upgrade->displayname}{$upgrade->displayname}{else}{$key}{/if}</strong></td>
<td>{$upgrade->fromrelease} ({$upgrade->from})</td>
<td>{$upgrade->torelease} ({$upgrade->to})</td>
</tr>
......@@ -57,7 +57,7 @@
<tbody>
{foreach from=$upgrades['settings']['newinstalls'] key=key item=upgrade}
<tr>
<td><strong>{$key}</strong></td>
<td><strong>{if $upgrade->displayname}{$upgrade->displayname}{else}{$key}{/if}</strong></td>
<td>{$upgrade->fromrelease}</td>
<td>{$upgrade->torelease} ({$upgrade->to})</td>
</tr>
......
......@@ -27,13 +27,14 @@ Scenario: Installing framework module and activating for an institution
Given I log in as "admin" with password "Kupuhipa1"
And I follow "Administration"
And I choose "Plugin administration" in "Extensions"
Then I should see "Hide" in the "form#activate_module_framework" "css_element"
Then I should see "smartevidence"
And I should see "Hide" in the "form#activate_module_framework" "css_element"
# Also make sure the annotation blocktype plugin is active
And I press "Show" in the "form#activate_blocktype_annotation" "css_element"
# Make sure we have a matrix config form
And I scroll to the base of id "module.framework"
And I follow "Configuration for module framework"
And I follow "Configuration for module smartevidence"
Then I should see "Name of matrix file"
# Activate smartevidence in an institution
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment