Skip to content

Commit

Permalink
added reset buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahY committed Mar 26, 2012
1 parent b309319 commit 7f42bc7
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 44 deletions.
1 change: 1 addition & 0 deletions README.rst
Expand Up @@ -12,6 +12,7 @@ Features
- turns admin submenu into drop-down
- execute php commands from plugin page (option to require password, see `Password`_ below)
- adds "top" links to each plugin in admin
- adds "r" buttons to reset values of plugin options
- shows notice to admin if updates for plugins are available
- allows emails to be sent to admin for answer and comment posts.

Expand Down
16 changes: 16 additions & 0 deletions qa-admin-layer.php
Expand Up @@ -113,11 +113,27 @@ function main_parts($content)
'html' => '',
);

$moduletypes=qa_list_module_types();
foreach ($moduletypes as $moduletype)
$plugins[]=qa_load_modules_with($moduletype, 'option_default');

$anchors = array();
foreach ($content as $key => $part) {
if (strpos($key, 'form_')===0) {
$content[$key]['title'] .= ' <font size="1" style="cursor:pointer; color:blue" onclick="jQuery(document).scrollTop(0)">top</font>';
foreach($content[$key]['fields'] as $idx => $field) {
if(isset($field['tags']) && preg_match('|name="([^"]+)"|i',$field['tags'],$name)) {
$name = $name[1];
error_log($name);
foreach($plugins as $modules)
foreach ($modules as $module) {
$value=$module->option_default($name);
$value = preg_replace('|\n|','\\\n',$value);
if (strlen($value))
$content[$key]['fields'][$idx]['label'] = @$content[$key]['fields'][$idx]['label'].'&nbsp;<input type="button" onclick="$(\'[name='.$name.']\').val(\''.$value.'\')" value="r" style="font-size:8pt; width:10px" title="reset to default value">';
}
}
}
}
}

Expand Down
88 changes: 44 additions & 44 deletions qa-plugin.php
@@ -1,45 +1,45 @@
<?php

/*
Plugin Name: Admin
Plugin URI: https://github.com/NoahY/q2a-admin-plus
<?php

/*
Plugin Name: Admin
Plugin URI: https://github.com/NoahY/q2a-admin-plus
Plugin Update Check URI: https://github.com/NoahY/q2a-admin-plus/raw/master/qa-plugin.php
Plugin Description: Provides admin additions
Plugin Version: 1.3
Plugin Date: 2011-08-10
Plugin Author: NoahY
Plugin Author URI: http://www.question2answer.org/qa/user/NoahY
Plugin License: GPLv2
Plugin Minimum Question2Answer Version: 1.4
*/


if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}

qa_register_plugin_layer('qa-admin-layer.php', 'Admin Layer');

qa_register_plugin_module('module', 'qa-php-widget.php', 'qa_admin_plus_admin', 'Admin Plus');

qa_register_plugin_module('event', 'qa-admin-check.php', 'qa_admin_plus_check', 'Admin Plus Check');

if(function_exists('qa_register_plugin_phrases'))
qa_register_plugin_phrases('qa-admin-lang-*.php', 'admin_plus');


// dev dump

function qa_error_log($x) {
ob_start();
var_dump($x);
$contents = ob_get_contents();
ob_end_clean();
error_log($contents);
}


/*
Omit PHP closing tag to help avoid accidental output
*/
Plugin Description: Provides admin additions
Plugin Version: 1.4
Plugin Date: 2011-08-10
Plugin Author: NoahY
Plugin Author URI: http://www.question2answer.org/qa/user/NoahY
Plugin License: GPLv2
Plugin Minimum Question2Answer Version: 1.4
*/


if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}

qa_register_plugin_layer('qa-admin-layer.php', 'Admin Layer');

qa_register_plugin_module('module', 'qa-php-widget.php', 'qa_admin_plus_admin', 'Admin Plus');

qa_register_plugin_module('event', 'qa-admin-check.php', 'qa_admin_plus_check', 'Admin Plus Check');

if(function_exists('qa_register_plugin_phrases'))
qa_register_plugin_phrases('qa-admin-lang-*.php', 'admin_plus');


// dev dump

function qa_error_log($x) {
ob_start();
var_dump($x);
$contents = ob_get_contents();
ob_end_clean();
error_log($contents);
}


/*
Omit PHP closing tag to help avoid accidental output
*/

0 comments on commit 7f42bc7

Please sign in to comment.