Kaynağa Gözat

Admin: add translatable strings, remove 'rino' settings, invert 'no'-setings, add "plugin_admin" hook for global plugins settings. add settings to twitter connector as example.

tags/2.3beta1
fabrixxm 9 yıl önce
ebeveyn
işleme
23931ab719
7 değiştirilmiş dosya ile 77 ekleme ve 26 silme
  1. +2
    -3
      addon/poormancron/poormancron.php
  2. +3
    -0
      addon/twitter/admin.tpl
  3. +18
    -1
      addon/twitter/twitter.php
  4. +2
    -1
      include/template_processor.php
  5. +40
    -14
      mod/admin.php
  6. +7
    -1
      view/admin_plugins_details.tpl
  7. +5
    -6
      view/admin_site.tpl

+ 2
- 3
addon/poormancron/poormancron.php Dosyayı Görüntüle

@@ -20,7 +20,7 @@ function poormancron_uninstall() {



function poormancron_hook($a,&$b) {
function poormancron_hook(&$a,&$b) {
$now = time();
$lastupdate = get_config('poormancron', 'lastupdate');

@@ -31,7 +31,7 @@ function poormancron_hook($a,&$b) {
}
}

function poormancron_procrun($a, $argv) {
function poormancron_procrun(&$a, $argv) {
logger("poormancron procrun ".implode(", ",$argv));
array_shift($argv);
$argc = count($argv);
@@ -43,5 +43,4 @@ function poormancron_procrun($a, $argv) {
}



?>

+ 3
- 0
addon/twitter/admin.tpl Dosyayı Görüntüle

@@ -0,0 +1,3 @@
{{ inc field_input.tpl with $field=$consumerkey }}{{ endinc }}
{{ inc field_input.tpl with $field=$consumersecret }}{{ endinc }}
<div class="submit"><input type="submit" name="page_site" value="$submit" /></div>

+ 18
- 1
addon/twitter/twitter.php Dosyayı Görüntüle

@@ -47,6 +47,7 @@ function twitter_install() {
register_hook('plugin_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
register_hook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook');
register_hook('jot_networks', 'addon/twitter/twitter.php', 'twitter_jot_nets');
register_hook('plugin_admin', 'addon/twitter/twitter.php', 'plugin_admin');
logger("installed twitter");
}

@@ -56,6 +57,7 @@ function twitter_uninstall() {
unregister_hook('plugin_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
unregister_hook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook');
unregister_hook('jot_networks', 'addon/twitter/twitter.php', 'twitter_jot_nets');
unregister_hook('plugin_admin', 'addon/twitter/twitter.php', 'plugin_admin');
}

function twitter_jot_nets(&$a,&$b) {
@@ -240,4 +242,19 @@ function twitter_post_hook(&$a,&$b) {
}
}
}

function plugin_admin_post(&$a){
$consumerkey = ((x($_POST,'consumerkey')) ? notags(trim($_POST['consumerkey'])) : '');
$consumersecret = ((x($_POST,'consumersecret')) ? notags(trim($_POST['consumersecret'])): '');
set_config('twitter','consumerkey',$consumerkey);
set_config('twitter','consumersecret',$consumersecret);
info( t('Settings updated.'). EOL );
}
function plugin_admin(&$a, &$o){
$t = file_get_contents( dirname(__file__). "/admin.tpl" );
$o = replace_macros($t, array(
'$submit' => t('Submit'),
// name, label, value, help, [extra values]
'$consumerkey' => array('consumerkey', t('Consumer key'), get_config('twitter', 'consumerkey' ), ''),
'$consumersecret' => array('consumersecret', t('Consumer secret'), get_config('twitter', 'consumersecret' ), '')
));
}

+ 2
- 1
include/template_processor.php Dosyayı Görüntüle

@@ -16,7 +16,8 @@
case PREG_BAD_UTF8_ERROR: die('PREG_BAD_UTF8_ERROR'); break;
case PREG_BAD_UTF8_OFFSET_ERROR: die('PREG_BAD_UTF8_OFFSET_ERROR'); break;
default:
die("Unknown preg error.");
//die("Unknown preg error.");
return;
}
}


+ 40
- 14
mod/admin.php Dosyayı Görüntüle

@@ -24,7 +24,18 @@ function admin_post(&$a){
break;
case 'users':
admin_page_users_post($a);
break;
break;
case 'plugins':
if ($a->argc > 2 &&
is_file("addon/".$a->argv[2]."/".$a->argv[2].".php")){
@include_once("addon/".$a->argv[2]."/".$a->argv[2].".php");
if(function_exists('plugin_admin_post')) {
plugin_admin_post($a);
}
}
goaway($a->get_baseurl() . '/admin/plugins/' . $a->argv[2] );
return; // NOTREACHED
break;
case 'logs':
admin_page_logs_post($a);
break;
@@ -59,6 +70,8 @@ function admin_content(&$a) {
foreach ($r as $h){
$plugin = explode("/",$h['file']); $plugin = $plugin[1];
$aside['plugins_admin'][] = Array($a->get_baseurl()."/admin/plugins/".$plugin, $plugin, "plugin");
// temp plugins with admin
$a->plugins_admin[] = $plugin;
}
$aside['logs'] = Array($a->get_baseurl()."/admin/logs/", t("Logs"), "logs");
@@ -164,11 +177,10 @@ function admin_page_site_post(&$a){
$global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : '');
$global_search_url = ((x($_POST,'directory_search_url'))? notags(trim($_POST['directory_search_url'])) : '');
$no_multi_reg = ((x($_POST,'no_multi_reg')) ? True : False);
$no_openid = ((x($_POST,'no_openid')) ? True : False);
$no_gravatar = ((x($_POST,'no_gravatar')) ? True : False);
$no_regfullname = ((x($_POST,'no_regfullname')) ? True : False);
$no_utf = ((x($_POST,'no_utf')) ? True : False);
$rino_enc = ((x($_POST,'rino_enc')) ? True : False);
$no_openid = !((x($_POST,'no_openid')) ? True : False);
$no_gravatar = !((x($_POST,'no_gravatar')) ? True : False);
$no_regfullname = !((x($_POST,'no_regfullname')) ? True : False);
$no_utf = !((x($_POST,'no_utf')) ? True : False);
$verifyssl = ((x($_POST,'verifyssl')) ? True : False);
$proxyuser = ((x($_POST,'proxyuser')) ? notags(trim($_POST['global_search_url'])) : '');
$proxy = ((x($_POST,'proxy')) ? notags(trim($_POST['global_search_url'])) : '');
@@ -210,13 +222,13 @@ function admin_page_site_post(&$a){
set_config('system','no_gravatar', $no_gravatar);
set_config('system','no_regfullname', $no_regfullname);
set_config('system','proxy', $no_utf);
set_config('system','rino_encrypt', $rino_enc);
set_config('system','verifyssl', $verifyssl);
set_config('system','proxyuser', $proxyuser);
set_config('system','proxy', $proxy);
set_config('system','curl_timeout', $timeout);


info( t('Site settings updated.') . EOL);
goaway($a->get_baseurl() . '/admin/site' );
return; // NOTREACHED
@@ -269,8 +281,12 @@ function admin_page_site(&$a) {
'$title' => t('Administration'),
'$page' => t('Site'),
'$submit' => t('Submit'),
'$registration' => t('Registration'),
'$upload' => t('File upload'),
'$corporate' => t('Corporate/Edu'),
'$advanced' => t('Advanced'),
'$baseurl' => $a->get_baseurl(),
// name, label, value, help string, extra data...
'$sitename' => array('sitename', t("Site name"), $a->config['sitename'], ""),
'$banner' => array('banner', t("Banner/Logo"), $banner, ""),
@@ -290,12 +306,11 @@ function admin_page_site(&$a) {
'$no_multi_reg' => array('no_multi_reg', t("Block multiple registrations"), get_config('system','block_extended_register'), "Disallow users to register additional accounts for use as pages."),
'$no_openid' => array('no_openid', t("No OpenID support"), get_config('system','no_openid'), "Disable OpenID support for registration and logins."),
'$no_gravatar' => array('no_gravatar', t("No Gravatar support"), get_config('system','no_gravatar'), ""),
'$no_regfullname' => array('no_regfullname', t("No fullname check"), get_config('system','no_regfullname'), "If unchecked, force users to registrate with a space between his firsname and lastname in Full name, as an antispam measure"),
'$no_utf' => array('no_utf', t("No UTF-8 Regular expressions"), get_config('system','proxy'), "Default is false (meaning UTF8 regular expressions are supported and working)"),
'$no_openid' => array('no_openid', t("OpenID support"), !get_config('system','no_openid'), "OpenID support for registration and logins."),
'$no_gravatar' => array('no_gravatar', t("Gravatar support"), !get_config('system','no_gravatar'), "Search new user's photo on Gravatar."),
'$no_regfullname' => array('no_regfullname', t("Fullname check"), !get_config('system','no_regfullname'), "Force users to registrate with a space between his firsname and lastname in Full name, as an antispam measure"),
'$no_utf' => array('no_utf', t("UTF-8 Regular expressions"), !get_config('system','proxy'), "Use PHP UTF8 regular expressions"),
'$rino_enc' => array('rino_enc', t("Enable Rino encrypt"), get_config('system','rino_encrypt'),""),
'$verifyssl' => array('verifyssl', t("Verify SSL"), get_config('system','verifyssl'), "If you wish, you can turn on strict certificate checking. This will mean you cannot connect (at all) to self-signed SSL sites."),
'$proxyuser' => array('proxyuser', t("Proxy user"), get_config('system','proxyuser'), ""),
'$proxy' => array('proxy', t("Proxy URL"), get_config('system','proxy'), ""),
@@ -323,7 +338,7 @@ function admin_page_users_post(&$a){
intval( $uid )
);
}
notice( sprintf( tt("%s user blocked", "%s users blocked", count($users)), count($users)) );
notice( sprintf( tt("%s user blocked", "%s users blocked/unblocked", count($users)), count($users)) );
}
if (x($_POST,'page_users_delete')){
require_once("include/Contact.php");
@@ -371,6 +386,7 @@ function admin_page_users(&$a){
intval( 1-$user[0]['blocked'] ),
intval( $uid )
);
notice( sprintf( ($user[0]['blocked']?t("User '%s' unblocked"):t("User '%s' blocked")) , $user[0]['username']) . EOL);
}; break;
}
goaway($a->get_baseurl() . '/admin/users' );
@@ -481,9 +497,11 @@ function admin_page_plugins(&$a){
if ($idx){
unset($a->plugins[$idx]);
uninstall_plugin($plugin);
info( sprintf( t("Plugin %s disabled."), $plugin ) );
} else {
$a->plugins[] = $plugin;
install_plugin($plugin);
info( sprintf( t("Plugin %s enabled."), $plugin ) );
}
set_config("system","addon", implode(", ",$a->plugins));
goaway($a->get_baseurl() . '/admin/plugins' );
@@ -506,6 +524,11 @@ function admin_page_plugins(&$a){
$readme = "<pre>". file_get_contents("addon/$plugin/README") ."</pre>";
}
$admin_form="";
if (in_array($plugin, $a->plugins_admin)){
call_hooks('plugin_admin', $admin_form);
}
$t = get_markup_template("admin_plugins_details.tpl");
return replace_macros($t, array(
'$title' => t('Administration'),
@@ -517,6 +540,8 @@ function admin_page_plugins(&$a){
'$status' => $status,
'$action' => $action,
'$info' => get_plugin_info($plugin),
'$admin_form' => $admin_form,
'$readme' => $readme
));
@@ -570,6 +595,7 @@ function admin_page_logs_post(&$a) {
}

info( t("Log settings updated.") );
goaway($a->get_baseurl() . '/admin/logs' );
return; // NOTREACHED
}


+ 7
- 1
view/admin_plugins_details.tpl Dosyayı Görüntüle

@@ -10,7 +10,13 @@
{{ endfor }}
</p>

{{ if $admin_form }}
<h3>Settings</h3>
<form method="post" action="$baseurl/admin/plugins/$plugin/">
$admin_form
</form>
{{ endif }}

{{ if $readme }}
<h3>Readme</h3>


+ 5
- 6
view/admin_site.tpl Dosyayı Görüntüle

@@ -10,7 +10,7 @@
<div class="submit"><input type="submit" name="page_site" value="$submit" /></div>
<h3>Registration</h3>
<h3>$registration</h3>
{{ inc field_input.tpl with $field=$register_text }}{{ endinc }}
{{ inc field_select.tpl with $field=$register_policy }}{{ endinc }}
@@ -18,14 +18,13 @@
{{ inc field_checkbox.tpl with $field=$no_openid }}{{ endinc }}
{{ inc field_checkbox.tpl with $field=$no_gravatar }}{{ endinc }}
{{ inc field_checkbox.tpl with $field=$no_regfullname }}{{ endinc }}
{{ inc field_checkbox.tpl with $field=$no_utf }}{{ endinc }}
<div class="submit"><input type="submit" name="page_site" value="$submit" /></div>

<h3>Upload</h3>
<h3>$upload</h3>
{{ inc field_input.tpl with $field=$maximagesize }}{{ endinc }}
<h3>Corporate/Edu</h3>
<h3>$corporate</h3>
{{ inc field_input.tpl with $field=$allowed_sites }}{{ endinc }}
{{ inc field_input.tpl with $field=$allowed_email }}{{ endinc }}
{{ inc field_checkbox.tpl with $field=$block_public }}{{ endinc }}
@@ -35,8 +34,8 @@
<div class="submit"><input type="submit" name="page_site" value="$submit" /></div>
<h3>Advanced</h3>
{{ inc field_checkbox.tpl with $field=$rino_enc }}{{ endinc }}
<h3>$advanced</h3>
{{ inc field_checkbox.tpl with $field=$no_utf }}{{ endinc }}
{{ inc field_checkbox.tpl with $field=$verifyssl }}{{ endinc }}
{{ inc field_input.tpl with $field=$proxy }}{{ endinc }}
{{ inc field_input.tpl with $field=$proxyuser }}{{ endinc }}


Yükleniyor…
İptal
Kaydet