summaryrefslogtreecommitdiff
path: root/lib/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'lib/plugins')
-rw-r--r--lib/plugins/config/admin.php78
-rw-r--r--lib/plugins/config/settings/config.class.php120
-rw-r--r--lib/plugins/config/style.css30
-rw-r--r--lib/plugins/plugin/admin.php318
-rw-r--r--lib/plugins/plugin/style.css72
5 files changed, 309 insertions, 309 deletions
diff --git a/lib/plugins/config/admin.php b/lib/plugins/config/admin.php
index 5f628e687..1859c45fa 100644
--- a/lib/plugins/config/admin.php
+++ b/lib/plugins/config/admin.php
@@ -54,15 +54,15 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
*/
function handle() {
global $ID;
-
+
if (!$this->_restore_session()) return $this->_close_session();
if (!isset($_REQUEST['save']) || ($_REQUEST['save'] != 1)) return $this->_close_session();
-
+
if (is_null($this->_config)) { $this->_config = new configuration($this->_file); }
-
+
// don't go any further if the configuration is locked
if ($this->_config->_locked) return $this->_close_session();
-
+
$this->_input = $_REQUEST['config'];
while (list($key) = each($this->_config->setting)) {
@@ -72,101 +72,101 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
}
if ($this->_config->setting[$key]->error()) $this->_error = true;
}
-
+
if ($this->_changed && !$this->_error) {
$this->_config->save_settings($this->getPluginName());
-
+
// save state & force a page reload to get the new settings to take effect
$_SESSION['PLUGIN_CONFIG'] = array('state' => 'updated', 'time' => time());
$this->_close_session();
header("Location: ".wl($ID,array('do'=>'admin','page'=>'config'),true,'&'));
exit();
}
-
+
$this->_close_session();
}
/**
* output appropriate html
*/
- function html() {
+ function html() {
global $lang;
global $ID;
-
+
if (is_null($this->_config)) { $this->_config = new configuration($this->_file); }
$this->setupLocale(true);
print $this->locale_xhtml('intro');
-
- ptln('<div id="configmanager">');
-
+
+ ptln('<div id="config__manager">');
+
if ($this->_config->locked)
ptln('<p class="info">'.$this->getLang('locked').'</p>');
- elseif ($this->_error)
+ elseif ($this->_error)
ptln('<p class="error">'.$this->getLang('error').'</p>');
elseif ($this->_changed)
ptln('<p class="ok">'.$this->getLang('updated').'</p>');
-
+
ptln('<form action="'.wl($ID).'" method="post">');
ptln(' <table class="inline">');
-
+
foreach($this->_config->setting as $setting) {
-
+
list($label,$input) = $setting->html($this, $this->_error);
-
- $class = $setting->is_default() ? ' class="default"' : ($setting->is_protected() ? ' class="protected"' : '');
+
+ $class = $setting->is_default() ? ' class="default"' : ($setting->is_protected() ? ' class="protected"' : '');
$error = $setting->error() ? ' class="error"' : '';
-
+
ptln(' <tr'.$class.'>');
ptln(' <td>'.$label.'</td>');
ptln(' <td'.$error.'>'.$input.'</td>');
ptln(' </tr>');
}
-
+
ptln(' </table>');
-
+
ptln('<p>');
ptln(' <input type="hidden" name="do" value="admin" />');
ptln(' <input type="hidden" name="page" value="config" />');
-
+
if (!$this->_config->locked) {
ptln(' <input type="hidden" name="save" value="1" />');
ptln(' <input type="submit" name="submit" value="'.$lang['btn_save'].'" />');
ptln(' <input type="reset" value="'.$lang['btn_reset'].'" />');
}
-
+
ptln('</p>');
-
+
ptln('</form>');
ptln('</div>');
}
-
+
/**
* @return boolean true - proceed with handle, false - don't proceed
*/
function _restore_session() {
-
- // dokuwiki closes the session before act_dispatch. $_SESSION variables are all set,
- // however they can't be changed without starting the session again
+
+ // dokuwiki closes the session before act_dispatch. $_SESSION variables are all set,
+ // however they can't be changed without starting the session again
if (!headers_sent()) {
session_start();
$this->_session_started = true;
- }
-
+ }
+
if (!isset($_SESSION['PLUGIN_CONFIG'])) return true;
-
+
$session = $_SESSION['PLUGIN_CONFIG'];
unset($_SESSION['PLUGIN_CONFIG']);
-
+
// still valid?
if (time() - $session['time'] > 120) return true;
-
+
switch ($session['state']) {
case 'updated' :
$this->_changed = true;
return false;
}
-
+
return true;
}
@@ -186,12 +186,12 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
function _setup_localised_plugin_prompts() {
global $conf;
-
+
$langfile = '/lang/'.$conf[lang].'/settings.php';
$enlangfile = '/lang/en/settings.php';
-
+
$lang = array();
-
+
if ($dh = opendir(DOKU_PLUGIN)) {
while (false !== ($plugin = readdir($dh))) {
if ($plugin == '.' || $plugin == '..' || $plugin == 'tmp' || $plugin == 'config') continue;
@@ -199,7 +199,7 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
if (@file_exists(DOKU_PLUGIN.$plugin.$enlangfile)){
@include(DOKU_PLUGIN.$plugin.$enlangfile);
- if ($conf['lang'] != 'en') @include(DOKU_PLUGIN.$plugin.$langfile);
+ if ($conf['lang'] != 'en') @include(DOKU_PLUGIN.$plugin.$langfile);
}
}
closedir($dh);
@@ -209,5 +209,5 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
return true;
}
-
+
}
diff --git a/lib/plugins/config/settings/config.class.php b/lib/plugins/config/settings/config.class.php
index 86bb4e9fa..620d9c3b2 100644
--- a/lib/plugins/config/settings/config.class.php
+++ b/lib/plugins/config/settings/config.class.php
@@ -12,11 +12,11 @@ if (!class_exists('configuration')) {
var $_name = 'conf'; // name of the config variable found in the files (overridden by $config['varname'])
var $_format = 'php'; // format of the config file, supported formats - php (overridden by $config['format'])
var $_heading = ''; // heading string written at top of config file - don't include comment indicators
- var $_loaded = false; // set to true after configuration files are loaded
+ var $_loaded = false; // set to true after configuration files are loaded
var $_metadata = array(); // holds metadata describing the settings
var $setting = array(); // array of setting objects
var $locked = false; // configuration is considered locked if it can't be updated
-
+
// filenames, these will be eval()'d prior to use so maintain any constants in output
var $_default_file = '';
var $_local_file = '';
@@ -42,7 +42,7 @@ if (!class_exists('configuration')) {
if (isset($file['protected'])) $this->_protected_file = $file['protected'];
$this->locked = $this->_is_locked();
-
+
$this->_metadata = array_merge($meta, $this->get_plugin_metadata());
$this->retrieve_settings();
@@ -70,16 +70,16 @@ if (!class_exists('configuration')) {
$param = NULL;
}
- $this->setting[$key] = new $class($key,$param);
- $this->setting[$key]->initialize($default[$key],$local[$key],$protected[$key]);
+ $this->setting[$key] = new $class($key,$param);
+ $this->setting[$key]->initialize($default[$key],$local[$key],$protected[$key]);
}
-
+
$this->_loaded = true;
- }
+ }
}
-
+
function save_settings($id, $header='', $backup=true) {
-
+
if ($this->locked) return false;
$file = eval('return '.$this->_local_file.';');
@@ -93,23 +93,23 @@ if (!class_exists('configuration')) {
if (!$fh = @fopen($file, 'wb')) {
@rename($file.'.bak', $file); // problem opening, restore the backup
return false;
- }
+ }
if (empty($header)) $header = $this->_heading;
$out = $this->_out_header($id,$header);
-
+
foreach ($this->setting as $setting) {
$out .= $setting->out($this->_name, $this->_format);
}
-
+
$out .= $this->_out_footer();
@fwrite($fh, $out);
fclose($fh);
return true;
}
-
+
/**
* return an array of config settings
*/
@@ -119,7 +119,7 @@ if (!class_exists('configuration')) {
$config = array();
$file = eval('return '.$file.';');
-
+
if ($this->_format == 'php') {
$contents = @php_strip_whitespace($file);
@@ -143,7 +143,7 @@ if (!class_exists('configuration')) {
return $config;
}
-
+
function _out_header($id, $header) {
$out = '';
if ($this->_format == 'php') {
@@ -155,10 +155,10 @@ if (!class_exists('configuration')) {
" * Date: ".date('r')."\n".
" */\n\n";
}
-
+
return $out;
}
-
+
function _out_footer() {
$out = '';
if ($this->_format == 'php') {
@@ -167,7 +167,7 @@ if (!class_exists('configuration')) {
}
$out .= "\n// end auto-generated content\n";
}
-
+
return $out;
}
@@ -196,7 +196,7 @@ if (!class_exists('configuration')) {
if (!is_array($value)) {
$out[$prefix.$key] = $value;
continue;
- }
+ }
$tmp = $this->_flatten($value,$prefix.$key.CM_KEYMARKER);
$out = array_merge($out,$tmp);
@@ -218,7 +218,7 @@ if (!class_exists('configuration')) {
if (is_file(DOKU_PLUGIN.$plugin)) continue;
if (@file_exists(DOKU_PLUGIN.$plugin.$file)){
- @include(DOKU_PLUGIN.$plugin.$file);
+ @include(DOKU_PLUGIN.$plugin.$file);
}
}
closedir($dh);
@@ -243,7 +243,7 @@ if (!class_exists('configuration')) {
}
return $default;
}
-
+
}
}
@@ -300,12 +300,12 @@ if (!class_exists('setting')) {
$this->_local = $input;
return true;
}
-
+
/**
* @return array(string $label_html, string $input_html)
*/
function html(&$plugin, $echo=false) {
-
+
$value = '';
$disable = '';
@@ -321,11 +321,11 @@ if (!class_exists('setting')) {
}
$key = htmlspecialchars($this->_key);
- $value = htmlspecialchars($value);
+ $value = htmlspecialchars($value);
- $label = '<label for="config_'.$key.'">'.$this->prompt($plugin).'</label>';
- $input = '<input id="config_'.$key.'" name="config['.$key.']" type="text" class="text" value="'.$value.'" '.$disable.'/>';
- return array($label,$input);
+ $label = '<label for="config__'.$key.'">'.$this->prompt($plugin).'</label>';
+ $input = '<input id="config__'.$key.'" name="config['.$key.']" type="text" class="text" value="'.$value.'" '.$disable.'/>';
+ return array($label,$input);
}
/**
@@ -347,19 +347,19 @@ if (!class_exists('setting')) {
return $out;
}
-
- function prompt(&$plugin) {
+
+ function prompt(&$plugin) {
$prompt = $plugin->getLang($this->_key);
if (!$prompt) $prompt = str_replace(array('____','_'),' ',$this->_key);
return htmlspecialchars($prompt);
}
-
+
function is_protected() { return !is_null($this->_protected); }
function is_default() { return !$this->is_protected() && is_null($this->_local); }
function error() { return $this->_error; }
-
- function _out_key() { return str_replace(CM_KEYMARKER,"']['",$this->_key); }
- }
+
+ function _out_key() { return str_replace(CM_KEYMARKER,"']['",$this->_key); }
+ }
}
if (!class_exists('setting_password')) {
@@ -386,9 +386,9 @@ if (!class_exists('setting_password')) {
$key = htmlspecialchars($this->_key);
- $label = '<label for="config_'.$key.'">'.$this->prompt($plugin).'</label>';
- $input = '<input id="config_'.$key.'" name="config['.$key.']" type="password" class="text" value="" '.$disable.'/>';
- return array($label,$input);
+ $label = '<label for="config__'.$key.'">'.$this->prompt($plugin).'</label>';
+ $input = '<input id="config__'.$key.'" name="config['.$key.']" type="password" class="text" value="" '.$disable.'/>';
+ return array($label,$input);
}
}
}
@@ -402,9 +402,9 @@ if (!class_exists('setting_email')) {
if (!class_exists('setting_numeric')) {
class setting_numeric extends setting {
var $_pattern = '/^[-+\/*0-9 ]*$/';
-
+
function out($var, $fmt='php') {
-
+
if ($this->is_protected()) return '';
if (is_null($this->_local) || ($this->_default == $this->_local)) return '';
@@ -431,25 +431,25 @@ if (!class_exists('setting_onoff')) {
$disable = ' disabled="disabled"';
} else {
$value = is_null($this->_local) ? $this->_default : $this->_local;
- }
+ }
$key = htmlspecialchars($this->_key);
- $checked = ($value) ? ' checked="checked"' : '';
+ $checked = ($value) ? ' checked="checked"' : '';
$label = '<label for="config_'.$key.'">'.$this->prompt($plugin).'</label>';
$input = '<div class="input"><input id="config_'.$key.'" name="config['.$key.']" type="checkbox" class="checkbox" value="1"'.$checked.$disable.'/></div>';
- return array($label,$input);
+ return array($label,$input);
}
function update($input) {
if ($this->is_protected()) return false;
- $input = ($input) ? 1 : 0;
+ $input = ($input) ? 1 : 0;
$value = is_null($this->_local) ? $this->_default : $this->_local;
if ($value == $input) return false;
$this->_local = $input;
- return true;
+ return true;
}
}
}
@@ -467,7 +467,7 @@ if (!class_exists('setting_mulitchoice')) {
$value = $this->_protected;
$disable = ' disabled="disabled"';
} else {
- $value = is_null($this->_local) ? $this->_default : $this->_local;
+ $value = is_null($this->_local) ? $this->_default : $this->_local;
}
// ensure current value is included
@@ -478,14 +478,14 @@ if (!class_exists('setting_mulitchoice')) {
if (!$this->is_protected() && count($this->_choices) <= 1) {
$disable = ' disabled="disabled"';
$nochoice = $plugin->getLang('nochoice');
- }
+ }
$key = htmlspecialchars($this->_key);
$label = '<label for="config_'.$key.'">'.$this->prompt($plugin).'</label>';
$input = "<div class=\"input\">\n";
- $input .= '<select id="config_'.$key.'" name="config['.$key.']"'.$disable.'>'."\n";
+ $input .= '<select id="config__'.$key.'" name="config['.$key.']"'.$disable.'>'."\n";
foreach ($this->_choices as $choice) {
$selected = ($value == $choice) ? ' selected="selected"' : '';
$option = $plugin->getLang($this->_key.'_o_'.$choice);
@@ -498,7 +498,7 @@ if (!class_exists('setting_mulitchoice')) {
$input .= "</select> $nochoice \n";
$input .= "</div>\n";
- return array($label,$input);
+ return array($label,$input);
}
function update($input) {
@@ -527,26 +527,26 @@ if (!class_exists('setting_dirchoice')) {
// populate $this->_choices with a list of available templates
$list = array();
- if ($dh = @opendir($this->_dir)) {
+ if ($dh = @opendir($this->_dir)) {
while (false !== ($entry = readdir($dh))) {
if ($entry == '.' || $entry == '..') continue;
- $file = (is_link($this->_dir.$entry)) ? readlink($this->_dir.$entry) : $entry;
- if (is_dir($this->_dir.$file)) $list[] = $entry;
+ $file = (is_link($this->_dir.$entry)) ? readlink($this->_dir.$entry) : $entry;
+ if (is_dir($this->_dir.$file)) $list[] = $entry;
}
closedir($dh);
}
sort($list);
$this->_choices = $list;
-
+
parent::initialize($default,$local,$protected);
}
- }
+ }
}
/**
- * Provide php_strip_whitespace (php5 function) functionality
+ * Provide php_strip_whitespace (php5 function) functionality
*
* @author Chris Smith <chris@jalakai.co.uk>
*/
@@ -567,11 +567,11 @@ if (!function_exists('php_strip_whitespace')) {
function php_strip_whitespace($file) {
if (!@is_readable($file)) return '';
- $in = join('',@file($file));
+ $in = join('',@file($file));
$out = '';
$tokens = token_get_all($in);
-
+
foreach ($tokens as $token) {
if (is_string ($token)) {
$out .= $token;
@@ -580,13 +580,13 @@ if (!function_exists('php_strip_whitespace')) {
switch ($id) {
case T_COMMENT : // fall thru
case T_ML_COMMENT : // fall thru
- case T_DOC_COMMENT : // fall thru
- case T_WHITESPACE :
+ case T_DOC_COMMENT : // fall thru
+ case T_WHITESPACE :
break;
default : $out .= $text; break;
}
}
- }
+ }
return ($out);
}
@@ -614,7 +614,7 @@ if (!function_exists('php_strip_whitespace')) {
if (!@is_readable($file)) return '';
- $contents = join('',@file($file));
+ $contents = join('',@file($file));
$out = '';
$state = 0;
@@ -636,5 +636,5 @@ if (!function_exists('php_strip_whitespace')) {
return $out;
}
- }
+ }
}
diff --git a/lib/plugins/config/style.css b/lib/plugins/config/style.css
index ab8d20060..d10a7c0e4 100644
--- a/lib/plugins/config/style.css
+++ b/lib/plugins/config/style.css
@@ -1,25 +1,25 @@
/* plugin:configmanager */
-#configmanager {margin: 1em;}
-#configmanager p.error {border: 1px solid red; background-color: #c66; color: white; padding: 0.5em; text-align:center}
-#configmanager p.ok {border: 1px solid green; background-color: #6c6; color: black; padding: 0.5em; text-align:center}
-#configmanager p.info {border: 1px solid __dark__; background-color: __medium__; color: black; padding: 0.5em; text-align:center}
-#configmanager form { }
-#configmanager table {margin: 1em 0;}
-#configmanager td input.text {width: 30em; border: 1px solid __medium__;}
-#configmanager td select {border: 1px solid __medium__;}
+#config__manager {margin: 1em;}
+#config__manager p.error {border: 1px solid red; background-color: #c66; color: white; padding: 0.5em; text-align:center}
+#config__manager p.ok {border: 1px solid green; background-color: #6c6; color: black; padding: 0.5em; text-align:center}
+#config__manager p.info {border: 1px solid __dark__; background-color: __medium__; color: black; padding: 0.5em; text-align:center}
+#config__manager form { }
+#config__manager table {margin: 1em 0;}
+#config__manager td input.text {width: 30em; border: 1px solid __medium__;}
+#config__manager td select {border: 1px solid __medium__;}
-#configmanager tr.default .input,
-#configmanager tr.default input,
-#configmanager tr.default select {
+#config__manager tr.default .input,
+#config__manager tr.default input,
+#config__manager tr.default select {
background-color: #ccddff;
}
-#configmanager tr.protected .input,
-#configmanager tr.protected input,
-#configmanager tr.protected select {
+#config__manager tr.protected .input,
+#config__manager tr.protected input,
+#config__manager tr.protected select {
background-color: #ffcccc;
}
-#configmanager td.error {background-color: red;}
+#config__manager td.error {background-color: red;}
/* end plugin:configmanager */
diff --git a/lib/plugins/plugin/admin.php b/lib/plugins/plugin/admin.php
index 92df52b61..cebd4e786 100644
--- a/lib/plugins/plugin/admin.php
+++ b/lib/plugins/plugin/admin.php
@@ -5,16 +5,16 @@
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Christopher Smith <chris@jalakai.co.uk>
*/
-
+
// todo
// - maintain a history of file modified
// - allow a plugin to contain extras to be copied to the current template (extra/tpl/)
// - to images (lib/images/) [ not needed, should go in lib/plugin/images/ ]
-
+
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'admin.php');
-
+
//--------------------------[ GLOBALS ]------------------------------------------------
// note: probably should be dokuwiki wide globals, where they can be accessed by pluginutils.php
global $common_plugin_types;
@@ -30,25 +30,25 @@ class admin_plugin_plugin extends DokuWiki_Admin_Plugin {
var $plugin = '';
var $cmd = '';
var $handler = NULL;
-
+
var $functions = array('delete','update',/*'settings',*/'info'); // require a plugin name
var $commands = array('manage','download'); // don't require a plugin name
var $plugin_list = array();
-
+
var $msg = '';
var $error = '';
-
+
function admin_plugin_plugin() {
global $conf;
$this->disabled = (isset($conf['pluginmanager']) && ($conf['pluginmanager'] == 0));
}
-
+
/**
* return some info
*/
function getInfo(){
$disabled = ($this->disabled) ? '(disabled)' : '';
-
+
return array(
'author' => 'Christopher Smith',
'email' => 'chris@jalakai.co.uk',
@@ -58,41 +58,41 @@ class admin_plugin_plugin extends DokuWiki_Admin_Plugin {
'url' => 'http://wiki.splitbrain.org/plugin:adminplugin',
);
}
-
+
/**
* return prompt for admin menu
*/
function getMenuText($language) {
- if (!$this->disabled)
+ if (!$this->disabled)
return parent::getMenuText($language);
return '';
}
-
+
/**
* return sort order for position in admin menu
*/
function getMenuSort() {
return 20;
}
-
+
/**
* handle user request
*/
function handle() {
-
+
if ($this->disabled) return;
-
+
// enable direct access to language strings
$this->setupLocale();
-
+
$this->plugin = $_REQUEST['plugin'];
$this->cmd = $_REQUEST['fn'];
if (is_array($this->cmd)) $this->cmd = key($this->cmd);
-
+
sort($this->plugin_list = plugin_list());
-
+
// verify $_REQUEST vars
if (in_array($this->cmd, $this->commands)) {
$this->plugin = '';
@@ -100,63 +100,63 @@ class admin_plugin_plugin extends DokuWiki_Admin_Plugin {
$this->cmd = 'manage';
$this->plugin = '';
}
-
+
// create object to handle the command
$class = "ap_".$this->cmd;
if (!class_exists($class)) $class = 'ap_manage';
-
+
$this->handler = & new $class($this, $this->plugin);
$this->msg = $this->handler->process();
}
-
+
/**
* output appropriate html
*/
function html() {
-
+
if ($this->disabled) return;
// enable direct access to language strings
$this->setupLocale();
-
+
if ($this->handler === NULL) $this->handler = & new ap_manage($this, $this->plugin);
if (!$this->plugin_list) sort($this->plugin_list = plugin_list());
-
- ptln('<div id="plugin_manager">');
- $this->handler->html();
+
+ ptln('<div id="plugin__manager">');
+ $this->handler->html();
ptln('</div><!-- #plugin_manager -->');
}
-
+
}
class ap_manage {
-
+
var $manager = NULL;
var $lang = array();
var $plugin = '';
var $downloaded = array();
-
+
function ap_manage(&$manager, $plugin) {
$this->manager = & $manager;
$this->plugin = $plugin;
- $this->lang = & $manager->lang;
+ $this->lang = & $manager->lang;
}
function process() {
return '';
}
-
- function html() {
+
+ function html() {
print $this->manager->locale_xhtml('admin_plugin');
- $this->html_menu();
+ $this->html_menu();
}
-
+
// build our standard menu
function html_menu($listPlugins = true) {
global $ID;
-
+
ptln('<div class="pm_menu">');
-
+
ptln('<div class="common">');
ptln(' <form action="'.wl($ID).'" method="post">');
ptln(' <fieldset class="hidden">',4);
@@ -167,28 +167,28 @@ class ap_manage {
ptln(' <legend>'.$this->lang['download'].'</legend>');
ptln(' <h3 class="legend">'.$this->lang['download'].'</h3>');
ptln(' <input type="submit" class="button" name="fn[download]" value="'.$this->lang['btn_download'].'" />');
- ptln(' <label for="url">'.$this->lang['url'].'<input name="url" id="url" class="field" type="text" maxlength="200" /></label>');
+ ptln(' <label for="dw__url">'.$this->lang['url'].'<input name="url" id="dw__url" class="field" type="text" maxlength="200" /></label>');
ptln(' </fieldset>');
ptln(' </form>');
ptln('</div>');
-
+
if ($listPlugins) {
ptln('<h2>'.$this->lang['manage'].'</h2>');
ptln('<div class="plugins">');
$this->html_pluginlist();
ptln('</div>');
}
-
+
ptln('</div>');
}
-
+
function html_pluginlist() {
global $ID;
foreach ($this->manager->plugin_list as $plugin) {
-
+
$new = (in_array($plugin, $this->downloaded)) ? ' class="new"' : '';
-
+
ptln(' <form action="'.wl($ID).'" method="post" '.$new.'>');
ptln(' <h3 class="legend">'.$plugin.'</h3>');
ptln(' <fieldset>');
@@ -196,62 +196,62 @@ class ap_manage {
ptln(' <input type="hidden" name="do" value="admin" />');
ptln(' <input type="hidden" name="page" value="plugin" />');
ptln(' <input type="hidden" name="plugin" value="'.$plugin.'" />');
-
+
$this->html_button('info', false, 6);
if (in_array('settings', $this->manager->functions)) {
$this->html_button('settings', !@file_exists(DOKU_PLUGIN.$plugin.'/settings.php'), 6);
}
$this->html_button('update', !$this->plugin_readlog($plugin, 'url'), 6);
$this->html_button('delete', false, 6);
-
+
ptln(' </fieldset>');
ptln(' </form>');
}
}
-
+
function html_button($btn, $disabled=false, $indent=0) {
$disabled = ($disabled) ? 'disabled="disabled"' : '';
ptln('<input type="submit" class="button" '.$disabled.' name="fn['.$btn.']" value="'.$this->lang['btn_'.$btn].'" />',$indent);
}
-
+
/**
* Refresh plugin list
*/
function refresh() {
-
+
sort($this->manager->plugin_list = plugin_list());
-
- // update latest plugin date - FIXME
+
+ // update latest plugin date - FIXME
return (!$this->manager->error);
}
-
+
function download($url, $overwrite=false) {
global $lang;
-
+
// check the url
- $matches = array();
+ $matches = array();
if (!preg_match("/[^\/]*$/", $url, $matches) || !$matches[0]) {
$this->manager->error = $this->lang['error_badurl']."\n";
return false;
}
-
+
$file = $matches[0];
$folder = "p".md5($file.date('r')); // tmp folder name - will be empty (should really make sure it doesn't already exist)
$tmp = DOKU_PLUGIN."tmp/$folder";
-
+
if (!ap_mkdir($tmp)) {
$this->manager->error = $this->lang['error_dir_create']."\n";
return false;
}
-
+
if (!$file = io_download($url, "$tmp/", true, $file)) {
$this->manager->error = sprintf($this->lang['error_download'],$url)."\n";
}
-
+
if (!$this->manager->error && !ap_decompress("$tmp/$file", $tmp)) {
$this->manager->error = sprintf($this->lang['error_decompress'],$file)."\n";
}
-
+
// search tmp/$folder for the folder(s) that has been created
// move that folder(s) to lib/plugins/
if (!$this->manager->error) {
@@ -259,31 +259,31 @@ class ap_manage {
while (false !== ($f = readdir($dh))) {
if ($f == '.' || $f == '..' || $f == 'tmp') continue;
if (!is_dir("$tmp/$f")) continue;
-
+
// check to make sure we aren't overwriting anything
if (!$overwrite && @file_exists(DOKU_PLUGIN."/$f")) {
// remember our settings, ask the user to confirm overwrite, FIXME
continue;
}
-
+
$instruction = @file_exists(DOKU_PLUGIN."/$f") ? 'update' : 'install';
-
+
if (ap_copy("$tmp/$f", DOKU_PLUGIN.$f)) {
$this->downloaded[] = $f;
$this->plugin_writelog($f, $instruction, array($url));
} else {
$this->manager->error .= sprintf($lang['error_copy']."\n", $f);
}
- }
+ }
closedir($dh);
} else {
$this->manager->error = $this->lang['error']."\n";
}
}
-
+
// cleanup
if ($folder && is_dir(DOKU_PLUGIN."tmp/$folder")) ap_delete(DOKU_PLUGIN."tmp/$folder");
-
+
if (!$this->manager->error) {
$this->refresh();
return true;
@@ -291,12 +291,12 @@ class ap_manage {
return false;
}
-
- // log
+
+ // log
function plugin_writelog($plugin, $cmd, $data) {
-
+
$file = DOKU_PLUGIN.$plugin.'/manager.dat';
-
+
switch ($cmd) {
case 'install' :
$url = $data[0];
@@ -305,7 +305,7 @@ class ap_manage {
fwrite($fp, "installed=$date\nurl=$url\n");
fclose($fp);
break;
-
+
case 'update' :
$date = date('r');
if (!$fp = @fopen($file, 'a')) return;
@@ -314,47 +314,47 @@ class ap_manage {
break;
}
}
-
+
function plugin_readlog($plugin, $field) {
static $log = array();
$file = DOKU_PLUGIN.$plugin.'/manager.dat';
-
+
if (!isset($log[$plugin])) {
$tmp = @file_get_contents($file);
if (!$tmp) return '';
$log[$plugin] = & $tmp;
}
-
+
if ($field == 'ALL') {
return $log[$plugin];
}
-
- $match = array();
+
+ $match = array();
if (preg_match_all('/'.$field.'=(.*)$/m',$log[$plugin], $match))
return implode("\n", $match[1]);
-
+
return '';
}
}
-
+
class ap_download extends ap_manage {
-
+
var $overwrite = false;
-
+
function process() {
global $lang;
-
+
$plugin_url = $_REQUEST['url'];
$this->download($plugin_url, $this->overwrite);
return '';
}
-
+
function html() {
parent::html();
-
+
ptln('<div class="pm_info">');
ptln('<h2>'.$this->lang['downloading'].'</h2>');
-
+
if ($this->manager->error) {
ptln('<div class="error">'.str_replace("\n","<br />",$this->manager->error).'</div>');
} else if (count($this->downloaded) == 1) {
@@ -371,26 +371,26 @@ class ap_manage {
}
ptln('</div>');
}
-
+
}
-
+
class ap_delete extends ap_manage {
-
- function process() {
-
+
+ function process() {
+
if (!ap_delete(DOKU_PLUGIN.$this->manager->plugin)) {
$this->manager->error = sprintf($this->lang['error_delete'],$this->manager->plugin);
} else {
$this->refresh();
}
}
-
+
function html() {
parent::html();
-
+
ptln('<div class="pm_info">');
ptln('<h2>'.$this->lang['deleting'].'</h2>');
-
+
if ($this->manager->error) {
ptln('<div class="error">'.str_replace("\n","<br />",$this->manager->error).'</div>');
} else {
@@ -399,63 +399,63 @@ class ap_manage {
ptln('</div>');
}
}
-
+
class ap_info extends ap_manage {
-
+
var $plugin_info = array(); // the plugin itself
var $details = array(); // any component plugins
- function process() {
-
+ function process() {
+
// sanity check
if (!$this->manager->plugin) { return; }
-
+
$component_list = ap_plugin_components($this->manager->plugin);
usort($component_list, ap_component_sort);
-
+
foreach ($component_list as $component) {
if ($obj = & plugin_load($component['type'],$component['name']) === NULL) continue;
-
+
$this->details[] = array_merge($obj->getInfo(), array('type' => $component['type']));
unset($obj);
}
-
+
// review details to simplify things
foreach($this->details as $info) {
foreach($info as $item => $value) {
if (!isset($this->plugin_info[$item])) { $this->plugin_info[$item] = $value; continue; }
if ($this->plugin_info[$item] != $value) $this->plugin_info[$item] = '';
- }
- }
- }
-
+ }
+ }
+ }
+
function html() {
-
+
// output the standard menu stuff
parent::html();
-
+
// sanity check
if (!$this->manager->plugin) { return; }
-
+
ptln('<div class="pm_info">');
ptln("<h2>".$this->manager->getLang('plugin')." {$this->manager->plugin}</h2>");
// collect pertinent information from the log
$installed = $this->plugin_readlog($this->manager->plugin, 'installed');
- $source = $this->plugin_readlog($this->manager->plugin, 'url');
+ $source = $this->plugin_readlog($this->manager->plugin, 'url');
$updated = $this->plugin_readlog($this->manager->plugin, 'updated');
if (strrpos($updated, "\n") !== false) $updated = substr($updated, strrpos($updated, "\n")+1);
-
+
ptln("<dl>",2);
ptln("<dt>".$this->manager->getLang('source').'</dt><dd>'.($source ? $source : $this->manager->getLang('unknown'))."</dd>",4);
ptln("<dt>".$this->manager->getLang('installed').'</dt><dd>'.($installed ? $installed : $this->manager->getLang('unknown'))."</dd>",4);
if ($updated) ptln("<dt>".$this->manager->getLang('lastupdate').'</dt><dd>'.$updated."</dd>",4);
ptln("</dl>",2);
-
+
if (count($this->details) == 0) {
ptln("<p>".$this->manager->getLang('noinfo')."</p>",2);
} else {
-
+
ptln("<dl>",2);
if ($this->plugin_info['name']) ptln("<dt>".$this->manager->getLang('name')."</dt><dd>".$this->out($this->plugin_info['name'])."</dd>",4);
if ($this->plugin_info['date']) ptln("<dt>".$this->manager->getLang('date')."</dt><dd>".$this->out($this->plugin_info['date'])."</dd>",4);
@@ -464,55 +464,55 @@ class ap_manage {
if ($this->plugin_info['author']) ptln("<dt>".$this->manager->getLang('author')."</dt><dd>".$this->manager->email($this->plugin_info['email'], $this->plugin_info['author'])."</dd>",4);
if ($this->plugin_info['url']) ptln("<dt>".$this->manager->getLang('www')."</dt><dd>".$this->manager->external_link($this->plugin_info['url'], '', 'urlextern')."</dd>",4);
ptln("</dl>",2);
-
+
if (count($this->details) > 1) {
ptln("<h3>".$this->manager->getLang('components')."</h3>",2);
ptln("<div>",2);
-
+
foreach ($this->details as $info) {
-
+
ptln("<dl>",4);
- ptln("<dt>".$this->manager->getLang('name')."</dt><dd>".$this->out($info['name'])."</dd>",6);
+ ptln("<dt>".$this->manager->getLang('name')."</dt><dd>".$this->out($info['name'])."</dd>",6);
if (!$this->plugin_info['date']) ptln("<dt>".$this->manager->getLang('date')."</dt><dd>".$this->out($info['date'])."</dd>",6);
if (!$this->plugin_info['type']) ptln("<dt>".$this->manager->getLang('type')."</dt><dd>".$this->out($info['type'])."</dd>",6);
if (!$this->plugin_info['desc']) ptln("<dt>".$this->manager->getLang('desc')."</dt><dd>".$this->out($info['desc'])."</dd>",6);
if (!$this->plugin_info['author']) ptln("<dt>".$this->manager->getLang('author')."</dt><dd>".$this->manager->email($info['email'], $info['author'])."</dd>",6);
if (!$this->plugin_info['url']) ptln("<dt>".$this->manager->getLang('www')."</dt><dd>".$this->manager->external_link($info['url'], '', 'urlextern')."</dd>",6);
ptln("</dl>",4);
-
+
}
ptln("</div>",2);
}
}
ptln("</div>");
}
-
+
// simple output filter, make html entities safe and convert new lines to <br />
function out($text) {
return str_replace("\n",'<br />',htmlentities($text));
}
-
+
}
-
+
//--------------[ to do ]---------------------------------------
class ap_update extends ap_manage {
-
+
var $overwrite = true;
-
+
function process() {
global $lang;
-
+
$plugin_url = $this->plugin_readlog($this->plugin, 'url');
$this->download($plugin_url, $this->overwrite);
return '';
}
-
+
function html() {
parent::html();
-
+
ptln('<div class="pm_info">');
ptln('<h2>'.$this->lang['updating'].'</h2>');
-
+
if ($this->manager->error) {
ptln('<div class="error">'.str_replace("\n","<br />", $this->manager->error).'</div>');
} else if (count($this->downloaded) == 1) {
@@ -531,58 +531,58 @@ class ap_manage {
}
}
class ap_settings extends ap_manage {}
-
+
//--------------[ utilities ]-----------------------------------
-
+
function is_css($f) { return (substr($f, -4) == '.css'); }
-
- // generate an admin plugin href
- function apl($pl, $fn) {
- global $ID;
+
+ // generate an admin plugin href
+ function apl($pl, $fn) {
+ global $ID;
return wl($ID,"do=admin&amp;page=plugin".($pl?"&amp;plugin=$pl":"").($fn?"&amp;fn=$fn":""));
}
-
+
// decompress wrapper
function ap_decompress($file, $target) {
-
+
// decompression library doesn't like target folders ending in "/"
if (substr($target, -1) == "/") $target = substr($target, 0, -1);
$ext = substr($file, strrpos($file,'.')+1);
-
+
// .tar, .tar.bz, .tar.gz, .tgz
if (in_array($ext, array('tar','bz','bz2','gz','tgz'))) {
-
+
require_once(DOKU_PLUGIN."plugin/inc/tarlib.class.php");
-
+
if (strpos($ext, 'bz') !== false) $compress_type = COMPRESS_BZIP;
else if (strpos($ext,'gz') !== false) $compress_type = COMPRESS_GZIP;
else $compress_type = COMPRESS_NONE;
$tar = new CompTar($file, $compress_type);
$ok = $tar->Extract(FULL_ARCHIVE, $target, '', 0777);
-
- // FIXME sort something out for handling tar error messages meaningfully
+
+ // FIXME sort something out for handling tar error messages meaningfully
return ($ok<0?false:true);
-
+
} else if ($ext == 'zip') {
require_once(DOKU_PLUGIN."plugin/inc/zip.lib.php");
-
+
$zip = new zip();
$ok = $zip->Extract($file, $target);
-
- // FIXME sort something out for handling zip error messages meaningfully
+
+ // FIXME sort something out for handling zip error messages meaningfully
return ($ok==-1?false:true);
-
+
} else if ($ext == "rar") {
// not yet supported -- fix me
return false;
}
-
+
// unsupported file type
return false;
}
-
+
// possibly should use io_MakeFileDir, not sure about using its method of error handling
function ap_mkdir($d) {
global $conf;
@@ -593,36 +593,36 @@ class ap_manage {
// copy with recursive sub-directory support
function ap_copy($src, $dst) {
-
+
if (is_dir($src)) {
if (!$dh = @opendir($src)) return false;
-
- if ($ok = ap_mkdir($dst)) {
+
+ if ($ok = ap_mkdir($dst)) {
while ($ok && $f = readdir($dh)) {
if ($f == '..' || $f == '.') continue;
$ok = ap_copy("$src/$f", "$dst/$f");
}
- }
-
+ }
+
closedir($dh);
return $ok;
-
+
} else {
if (!@copy($src,$dst)) return false;
touch($dst,filemtime($src));
}
-
+
return true;
}
-
+
// delete, with recursive sub-directory support
function ap_delete($path) {
-
+
if (!is_string($path) || $path == "") return false;
-
+
if (is_dir($path)) {
if (!$dh = @opendir($path)) return false;
-
+
while ($f = readdir($dh)) {
if ($f == '..' || $f == '.') continue;
ap_delete("$path/$f");
@@ -635,31 +635,31 @@ class ap_manage {
}
return false;
- }
-
+ }
+
// return a list (name & type) of all the component plugins that make up this plugin
// can this move to pluginutils?
function ap_plugin_components($plugin) {
global $common_plugin_types;
-
+
$components = array();
$path = DOKU_PLUGIN.$plugin.'/';
-
+
foreach ($common_plugin_types as $type) {
if (file_exists($path.$type.'.php')) { $components[] = array('name'=>$plugin, 'type'=>$type); continue; }
-
+
if ($dh = @opendir($path.$type.'/')) {
while (false !== ($cp = readdir($dh))) {
if ($cp == '.' || $cp == '..' || strtolower(substr($cp,-4)) != '.php') continue;
$components[] = array('name'=>$plugin.'_'.substr($cp, 0, -4), 'type'=>$type);
}
closedir($dh);
- }
+ }
}
return $components;
}
-
+
function ap_component_sort($a, $b) {
if ($a['name'] == $b['name']) return 0;
return ($a['name'] < $b['name']) ? -1 : 1;
diff --git a/lib/plugins/plugin/style.css b/lib/plugins/plugin/style.css
index f9d496f2e..03f8ace19 100644
--- a/lib/plugins/plugin/style.css
+++ b/lib/plugins/plugin/style.css
@@ -6,42 +6,42 @@
*/
/* overall containing div */
-#plugin_manager {}
-
-#plugin_manager h2 { margin-left: 0;}
-#plugin_manager form { display: block; margin: 0; padding: 0;}
-#plugin_manager legend { display: none;}
-#plugin_manager .legend { color: black; display: block; margin: 0; padding: 0; font-size: 1em; line-height: 1.4em; font-weight: normal; text-align: left;}
-#plugin_manager fieldset { border: 0; width: auto;}
-#plugin_manager .button { margin: 0 0.3em 2px 0;}
-#plugin_manager p, #plugin_manager label { text-align: left;}
-#plugin_manager .hidden { display: none;}
-#plugin_manager .new { background: __medium__;}
-#plugin_manager input[disabled] { color: __mediumgray__; border-color: __mediumgray__;} /* IE won't understand but doesn't require it */
-
-#plugin_manager .pm_menu, #plugin_manager .pm_info { margin-left: 0; text-align: left; }
-#plugin_manager .pm_menu { float: left; width: 48%; }
-#plugin_manager .pm_info { float: right; width: 50%; }
-
-#plugin_manager .common { border-bottom: 1px solid __dark__; margin-top: 1em;}
-#plugin_manager .common form { border: 1px solid __dark__; border-bottom: 0;}
-#plugin_manager .common fieldset { margin: 0; padding: 0;}
-#plugin_manager .common .legend { background: __medium__; margin-bottom: 0.3em; padding-left: 0.5em;}
-#plugin_manager .common label { padding: 0 0 0.5em 0.5em; }
-#plugin_manager .common input { width: auto; margin: 0 1em;}
-#plugin_manager .common .button { float: right; width: 6em; }
-#plugin_manager .common p { border-bottom: 1px solid __dark__; padding: 0 0 0.5em 0.5em; margin-bottom: 0;}
-
-#plugin_manager .plugins { border-bottom: 1px solid __dark__;}
-#plugin_manager .plugins form { border: 1px solid __dark__; border-bottom: 0;}
-#plugin_manager .plugins fieldset { text-align: right; }
-#plugin_manager .plugins .legend { float: left; padding: 5px 0 0 5px;}
-#plugin_manager .plugins .button { width: 5em; font-size: 95%;}
-
-#plugin_manager .pm_info h3 { margin-left: 0; }
-#plugin_manager .pm_info dl { margin: 1em 0; padding: 0;}
-#plugin_manager .pm_info dt { width: 6em; float: left; clear: left; margin:0; padding: 0;}
-#plugin_manager .pm_info dd { margin:0 0 0 7em; padding: 0;}
+#plugin__manager {}
+
+#plugin__manager h2 { margin-left: 0;}
+#plugin__manager form { display: block; margin: 0; padding: 0;}
+#plugin__manager legend { display: none;}
+#plugin__manager .legend { color: black; display: block; margin: 0; padding: 0; font-size: 1em; line-height: 1.4em; font-weight: normal; text-align: left;}
+#plugin__manager fieldset { border: 0; width: auto;}
+#plugin__manager .button { margin: 0 0.3em 2px 0;}
+#plugin__manager p, #plugin__manager label { text-align: left;}
+#plugin__manager .hidden { display: none;}
+#plugin__manager .new { background: __medium__;}
+#plugin__manager input[disabled] { color: __mediumgray__; border-color: __mediumgray__;} /* IE won't understand but doesn't require it */
+
+#plugin__manager .pm_menu, #plugin__manager .pm_info { margin-left: 0; text-align: left; }
+#plugin__manager .pm_menu { float: left; width: 48%; }
+#plugin__manager .pm_info { float: right; width: 50%; }
+
+#plugin__manager .common { border-bottom: 1px solid __dark__; margin-top: 1em;}
+#plugin__manager .common form { border: 1px solid __dark__; border-bottom: 0;}
+#plugin__manager .common fieldset { margin: 0; padding: 0;}
+#plugin__manager .common .legend { background: __medium__; margin-bottom: 0.3em; padding-left: 0.5em;}
+#plugin__manager .common label { padding: 0 0 0.5em 0.5em; }
+#plugin__manager .common input { width: auto; margin: 0 1em;}
+#plugin__manager .common .button { float: right; width: 6em; }
+#plugin__manager .common p { border-bottom: 1px solid __dark__; padding: 0 0 0.5em 0.5em; margin-bottom: 0;}
+
+#plugin__manager .plugins { border-bottom: 1px solid __dark__;}
+#plugin__manager .plugins form { border: 1px solid __dark__; border-bottom: 0;}
+#plugin__manager .plugins fieldset { text-align: right; }
+#plugin__manager .plugins .legend { float: left; padding: 5px 0 0 5px;}
+#plugin__manager .plugins .button { width: 5em; font-size: 95%;}
+
+#plugin__manager .pm_info h3 { margin-left: 0; }
+#plugin__manager .pm_info dl { margin: 1em 0; padding: 0;}
+#plugin__manager .pm_info dt { width: 6em; float: left; clear: left; margin:0; padding: 0;}
+#plugin__manager .pm_info dd { margin:0 0 0 7em; padding: 0;}
/* end admin plugin styles */