Commit 8a444512 authored by Penny Leach's avatar Penny Leach
Browse files

beginnings of adminplugins stuffs. plugins can be installed now from

there, but there needs to be a bit more javascript niceness to move them
from notinstalled to installed on successful install
parent ff39f9f3
......@@ -27,6 +27,7 @@
define('INTERNAL', 1);
define('ADMIN', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require('upgrade.php');
$plugins = array();
......@@ -38,17 +39,18 @@ foreach (plugin_types() as $plugin) {
foreach ($installed as $i) {
$plugins[$plugin]['installed'][$i->name] = array();
if ($plugin == 'artefact') {
safe_require('artefact','internal');
$types = call_static_method(generate_class_name('artefact', $i->name), 'get_artefact_types');
$plugins[$plugin]['installed'][$i->name]['types'] = array();
foreach ($types as $t) {
$classname = generate_artefact_class_name($t);
if ($collapseto = call_static_method($classname, 'collapse_config')) {
$plugins[$plugin]['installed'][$i->name]['types'][$collapseto] = true;
}
else {
$plugins[$plugin]['installed'][$i->name]['types'][$t] =
call_static_method($classname, 'has_config');
safe_require('artefact',$i->name);
if ($types = call_static_method(generate_class_name('artefact', $i->name), 'get_artefact_types')) {
foreach ($types as $t) {
$classname = generate_artefact_class_name($t);
if ($collapseto = call_static_method($classname, 'collapse_config')) {
$plugins[$plugin]['installed'][$i->name]['types'][$collapseto] = true;
}
else {
$plugins[$plugin]['installed'][$i->name]['types'][$t] =
call_static_method($classname, 'has_config');
}
}
}
}
......@@ -73,12 +75,63 @@ foreach (plugin_types() as $plugin) {
if (array_key_exists($dir, $plugins[$plugin]['installed'])) {
continue;
}
$plugins[$plugin]['notinstalled'][] = $dir;
$plugins[$plugin]['notinstalled'][$dir] = array();
safe_require($plugin, $dir);
$funname = $plugin . '_check_plugin_sanity';
if (function_exists($funname)) {
try {
$funname($dir);
}
catch (InstallationException $e) {
$plugins[$plugin]['notinstalled'][$dir]['notinstallable'] = $e->GetMessage();
}
}
}
}
$loadingicon = theme_get_image_path('loading.gif');
$successicon = theme_get_image_path('success.gif');
$failureicon = theme_get_image_path('failure.gif');
$loadingstring = get_string('upgradeloading', 'admin');
$successstring = get_string('upgradesuccess', 'admin');
$failurestring = get_string('upgradefailure', 'admin');
$javascript = <<<JAVASCRIPT
function installplugin(name) {
var d = loadJSONDoc('../upgrade.json.php', { 'name': name });
$(name).innerHTML = '<img src="{$loadingicon}" alt="{$loadingstring}" />';
d.addCallbacks(function (data) {
if (data.success) {
var message = '{$successstring}' + data.newversion;
$(name).innerHTML = '<img src="{$successicon}" alt=":)" /> ' + message;
}
if (data.error) {
var message = '';
if (data.errormessage) {
message = data.errormessage;
}
else {
message = '{$failurestring}';
}
$(name).innerHTML = '<img src="{$failureicon}" alt=":(" /> ' + message;
}
},
function () {
message = '{$failurestring}';
$(name).innerHTML = message;
});
}
JAVASCRIPT;
$smarty = smarty();
$smarty->assign('INLINEJAVASCRIPT', $javascript);
$smarty->assign('plugins', $plugins);
$smarty->assign('installlink', 'installplugin');
$smarty->display('admin/plugins/index.tpl');
?>
<?php
/**
* This program is part of Mahara
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage admin
* @author Penny Leach <penny@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('ADMIN', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
$plugintype = param_alpha('plugintype');
$pluginname = param_alpha('pluginname');
$type = param_alpha('type', null);
if ($plugintype == 'artefact' && empty($type)) {
}
?>
\ No newline at end of file
......@@ -229,4 +229,9 @@ $string['save'] = 'Save';
$string['update'] = 'Update';
$string['config'] = 'Config';
$string['notinstallable'] = 'Not installable!';
$string['installedplugins'] = 'Installed plugins';
$string['notinstalledplugins'] = 'Not installed plugins';
$string['plugintype'] = 'Plugin type';
?>
......@@ -3,13 +3,14 @@
<h2>Administration</h2>
{foreach from=$plugins key='plugintype' item='plugins'}
<h4>{$plugintype}</h4>
<h4>{str tag='plugintype'}: {$plugintype}</h4>
{assign var="installed" value=$plugins.installed}
{assign var="notinstalled" value=$plugins.notinstalled}
{assign var="notinstalled" value=$plugins.notinstalled}
<p><b>{str tag='installedplugins'}</b></p>
{foreach from=$installed key='plugin' item='data'}
{$plugin}
{if $data.config}
(<a href="pluginconfig.php?plugintype={$plugintype}&amp;pluginname={$plugin}">{str tag='config'}</a>
(<a href="pluginconfig.php?plugintype={$plugintype}&amp;pluginname={$plugin}">{str tag='config'}</a>)
{/if}<br />
{if $data.types}
{foreach from=$data.types key='type' item='config'}
......@@ -18,9 +19,15 @@
{/foreach}
{/if}
{/foreach}
{foreach from=$notinstalled item='plugin}
{$plugin}<br />
{/foreach}
{if $notinstalled}
<p><b>{str tag='notinstalledplugins'}</b></p>
{foreach from=$notinstalled key='plugin' item='data'}
{$plugin} {if $data.notinstallable} {str tag='notinstallable'} {$data.notinstallable}
{else} (<a href="" onClick="{$installlink}('{$plugintype}.{$plugin}'); return false;">install</a>)
{/if}
<div id="{$plugintype}.{$plugin}"></div>
{/foreach}
{/if}
{/foreach}
{include file='footer.tpl'}
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