From 81e7535914414d0ef6c709ef2cdabc00382ee917 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Thu, 30 Jun 2011 16:42:27 +0200 Subject: [PATCH 1/6] Add javascript var "baseurl" Add field_richtext template --- view/default.php | 1 + view/field_richtext.tpl | 44 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 view/field_richtext.tpl diff --git a/view/default.php b/view/default.php index 60bda26695..0d4a690541 100644 --- a/view/default.php +++ b/view/default.php @@ -2,6 +2,7 @@ <?php if(x($page,'title')) echo $page['title'] ?> + diff --git a/view/field_richtext.tpl b/view/field_richtext.tpl new file mode 100644 index 0000000000..a5a453d32f --- /dev/null +++ b/view/field_richtext.tpl @@ -0,0 +1,44 @@ + +
+ + + $field.3 + + +
From 779292077c99c7693da78be4a53e25f039bedd8b Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Thu, 30 Jun 2011 16:43:04 +0200 Subject: [PATCH 2/6] style template field outside admin pages --- view/theme/duepuntozero/style.css | 53 +++++++++++++++++-------------- view/theme/loozah/style.css | 51 +++++++++++++++-------------- 2 files changed, 56 insertions(+), 48 deletions(-) diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index 0c4b710c0b..dc54398dc0 100644 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -2541,6 +2541,35 @@ a.mail-list-link { filter:alpha(opacity=100); } + +/** + * Form fields + */ +.field { + clear: left; + margin-bottom: 5px; + padding-bottom: 5px; +} + +.field label { + float: left; + width: 200px; + font-weight: bold; +} + +.field input, +.field textarea { + width: 400px; +} +.field textarea { height: 100px; } +.field_help { + display: block; + margin-left: 200px; + color: #666666; + +} + + /** * ADMIN */ @@ -2567,30 +2596,6 @@ a.mail-list-link { margin-left: 200px; } -#adminpage .field { - clear: left; - margin-bottom: 5px; - padding-bottom: 5px; -} - -#adminpage .field label { - float: left; - width: 200px; - font-weight: bold; -} - -#adminpage .field input, -#adminpage .field textarea { - width: 400px; -} -#adminpage .field textarea { height: 100px; } -#adminpage .field_help { - display: block; - margin-left: 200px; - color: #666666; - -} - #adminpage h3 { border-bottom: 1px solid #cccccc; } diff --git a/view/theme/loozah/style.css b/view/theme/loozah/style.css index c68e38b68e..7802d176d2 100644 --- a/view/theme/loozah/style.css +++ b/view/theme/loozah/style.css @@ -2559,6 +2559,33 @@ a.mail-list-link { left: 0px; top: 0px; } +/** + * Form fields + */ +.field { + clear: left; + margin-bottom: 5px; + padding-bottom: 5px; +} + +.field label { + float: left; + width: 200px; + font-weight: bold; +} + +.field input, +.field textarea { + width: 400px; +} +.field textarea { height: 100px; } +.field_help { + display: block; + margin-left: 200px; + color: #666666; + +} + /** * ADMIN @@ -2586,30 +2613,6 @@ a.mail-list-link { margin-left: 200px; } -#adminpage .field { - clear: left; - margin-bottom: 5px; - padding-bottom: 5px; -} - -#adminpage .field label { - float: left; - width: 200px; - font-weight: bold; -} - -#adminpage .field input, -#adminpage .field textarea { - width: 400px; -} -#adminpage .field textarea { height: 100px; } -#adminpage .field_help { - display: block; - margin-left: 200px; - color: #666666; - -} - #adminpage h3 { border-bottom: 1px solid #cccccc; } From a07282ea6f79a28e09c0855c22effabf22b7dcd3 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Thu, 30 Jun 2011 16:44:06 +0200 Subject: [PATCH 3/6] tinyMCE loads "source" version of bbcode plugin istead of "compressed" one --- .../tiny_mce/plugins/bbcode/editor_plugin.js | 156 +++++++++++++++++- .../plugins/bbcode/editor_plugin_cmp.js | 1 + .../plugins/bbcode/editor_plugin_src.js | 155 ----------------- 3 files changed, 156 insertions(+), 156 deletions(-) create mode 100644 library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_cmp.js delete mode 100644 library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js diff --git a/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin.js b/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin.js index b0926c92a8..db676cd908 100644 --- a/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin.js +++ b/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin.js @@ -1 +1,155 @@ -(function(){tinymce.create('tinymce.plugins.BBCodePlugin',{init:function(ed,url){var t=this,dialect=ed.getParam('bbcode_dialect','dfrn').toLowerCase();ed.onBeforeSetContent.add(function(ed,o){o.content=t['_'+dialect+'_bbcode2html'](o.content)});ed.onPostProcess.add(function(ed,o){if(o.set)o.content=t['_'+dialect+'_bbcode2html'](o.content);if(o.get)o.content=t['_'+dialect+'_html2bbcode'](o.content)})},getInfo:function(){return{longname:'BBCode Plugin',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/bbcode',version:tinymce.majorVersion+"."+tinymce.minorVersion version:tinymce.majorVersion+"."+tinymce.minorVersion}},_dfrn_html2bbcode:function(s){s=tinymce.trim(s);function rep(re,str){s=s.replace(re,str)};rep(/(.*?)<\/a>/gi,"[url=$1]$2[/url]");rep(/(.*?)<\/span>/gi,"[size=$1]$2[/size]");rep(/(.*?)<\/font>/gi,"$1");rep(//gi,"[img]$1[/img]");rep(/(.*?)<\/code>/gi,"[code]$1[/code]");rep(/<\/(strong|b)>/gi,"[/b]");rep(/<(strong|b)>/gi,"[b]");rep(/<\/(em|i)>/gi,"[/i]");rep(/<(em|i)>/gi,"[i]");rep(/<\/u>/gi,"[/u]");rep(/(.*?)<\/span>/gi,"[u]$1[/u]");rep(//gi,"[u]");rep(/]*>/gi,"[quote]");rep(/<\/blockquote>/gi,"[/quote]");rep(/
/gi,"\n");rep(//gi,"\n");rep(/
/gi,"\n");rep(/

/gi,"");rep(/<\/p>/gi,"\n");rep(/ /gi," ");rep(/"/gi,"\"");rep(/</gi,"<");rep(/>/gi,">");rep(/&/gi,"&");return s},_dfrn_bbcode2html:function(s){s=tinymce.trim(s);function rep(re,str){s=s.replace(re,str)};rep(/\n/gi,"
");rep(/\[b\]/gi,"");rep(/\[\/b\]/gi,"");rep(/\[i\]/gi,"");rep(/\[\/i\]/gi,"");rep(/\[u\]/gi,"");rep(/\[\/u\]/gi,"");rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"$2");rep(/\[url\](.*?)\[\/url\]/gi,"$1");rep(/\[img\](.*?)\[\/img\]/gi,"");rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"$2");rep(/\[code\](.*?)\[\/code\]/gi,"$1");rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"

$1
");return s}});tinymce.PluginManager.add('bbcode',tinymce.plugins.BBCodePlugin)})(); \ No newline at end of file +/** + * editor_plugin_src.js + * + * Copyright 2009, Moxiecode Systems AB + * Released under LGPL License. + * + * License: http://tinymce.moxiecode.com/license + * Contributing: http://tinymce.moxiecode.com/contributing + */ + +/* Macgirvin Aug-2010 changed from punbb to dfrn dialect */ + +(function() { + tinymce.create('tinymce.plugins.BBCodePlugin', { + init : function(ed, url) { + var t = this, dialect = ed.getParam('bbcode_dialect', 'dfrn').toLowerCase(); + + ed.onBeforeSetContent.add(function(ed, o) { + o.content = t['_' + dialect + '_bbcode2html'](o.content); + }); + + ed.onPostProcess.add(function(ed, o) { + if (o.set) + o.content = t['_' + dialect + '_bbcode2html'](o.content); + + if (o.get) + o.content = t['_' + dialect + '_html2bbcode'](o.content); + }); + }, + + getInfo : function() { + return { + longname : 'BBCode Plugin', + author : 'Moxiecode Systems AB', + authorurl : 'http://tinymce.moxiecode.com', + infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/bbcode', + version : tinymce.majorVersion + "." + tinymce.minorVersion + }; + }, + + // Private methods + + // HTML -> BBCode in DFRN dialect + _dfrn_html2bbcode : function(s) { + s = tinymce.trim(s); + + function rep(re, str) { + s = s.replace(re, str); + }; + + + + + /* oembed */ + function _h2b_cb(match) { + text = bin2hex(match); + function s_h2b(data) { + match = data; + } + $.ajax({ + url: 'oembed/h2b?text=' + text, + async: false, + success: s_h2b, + dataType: 'html' + }); + return match; + } + s = s.replace(//gi, _h2b_cb); + /* /oembed */ + + + // example: to [b] + rep(/(.*?)<\/a>/gi,"[url=$1]$2[/url]"); + rep(/(.*?)<\/span>/gi,"[size=$1]$2[/size]"); + rep(/(.*?)<\/span>/gi,"[color=$1]$2[/color]"); + rep(/(.*?)<\/font>/gi,"$1"); + rep(//gi,"[img=$1x$2]$3[/img]"); + rep(//gi,"[img=$2x$1]$3[/img]"); + rep(//gi,"[img=$3x$2]$1[/img]"); + rep(//gi,"[img=$2x$3]$1[/img]"); + rep(//gi,"[img]$1[/img]"); + rep(/(.*?)<\/code>/gi,"[code]$1[/code]"); + rep(/<\/(strong|b)>/gi,"[/b]"); + rep(/<(strong|b)>/gi,"[b]"); + rep(/<\/(em|i)>/gi,"[/i]"); + rep(/<(em|i)>/gi,"[i]"); + rep(/<\/u>/gi,"[/u]"); + rep(/(.*?)<\/span>/gi,"[u]$1[/u]"); + rep(//gi,"[u]"); + rep(/]*>/gi,"[quote]"); + rep(/<\/blockquote>/gi,"[/quote]"); + rep(/
/gi,"\n\n"); + rep(//gi,"\n\n"); + rep(/
/gi,"\n"); + rep(/

/gi,""); + rep(/<\/p>/gi,"\n"); + rep(/ /gi," "); + rep(/"/gi,"\""); + rep(/</gi,"<"); + rep(/>/gi,">"); + rep(/&/gi,"&"); + + return s; + }, + + // BBCode -> HTML from DFRN dialect + _dfrn_bbcode2html : function(s) { + s = tinymce.trim(s); + + function rep(re, str) { + s = s.replace(re, str); + }; + + // example: [b] to + rep(/\n/gi,"
"); + rep(/\[b\]/gi,""); + rep(/\[\/b\]/gi,""); + rep(/\[i\]/gi,""); + rep(/\[\/i\]/gi,""); + rep(/\[u\]/gi,""); + rep(/\[\/u\]/gi,""); + rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"$2"); + rep(/\[url\](.*?)\[\/url\]/gi,"$1"); + rep(/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/gi,""); + rep(/\[img\](.*?)\[\/img\]/gi,""); + rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"$2"); + rep(/\[size=(.*?)\](.*?)\[\/size\]/gi,"$2"); + rep(/\[code\](.*?)\[\/code\]/gi,"$1"); + rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"

$1
"); + + /* oembed */ + function _b2h_cb(match, url) { + url = bin2hex(url); + function s_b2h(data) { + match = data; + } + $.ajax({ + url: 'oembed/b2h?url=' + url, + async: false, + success: s_b2h, + dataType: 'html' + }); + return match; + } + s = s.replace(/\[embed\](.*?)\[\/embed\]/gi, _b2h_cb); + + /* /oembed */ + + return s; + } + }); + + // Register plugin + tinymce.PluginManager.add('bbcode', tinymce.plugins.BBCodePlugin); +})(); \ No newline at end of file diff --git a/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_cmp.js b/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_cmp.js new file mode 100644 index 0000000000..b0926c92a8 --- /dev/null +++ b/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_cmp.js @@ -0,0 +1 @@ +(function(){tinymce.create('tinymce.plugins.BBCodePlugin',{init:function(ed,url){var t=this,dialect=ed.getParam('bbcode_dialect','dfrn').toLowerCase();ed.onBeforeSetContent.add(function(ed,o){o.content=t['_'+dialect+'_bbcode2html'](o.content)});ed.onPostProcess.add(function(ed,o){if(o.set)o.content=t['_'+dialect+'_bbcode2html'](o.content);if(o.get)o.content=t['_'+dialect+'_html2bbcode'](o.content)})},getInfo:function(){return{longname:'BBCode Plugin',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/bbcode',version:tinymce.majorVersion+"."+tinymce.minorVersion version:tinymce.majorVersion+"."+tinymce.minorVersion}},_dfrn_html2bbcode:function(s){s=tinymce.trim(s);function rep(re,str){s=s.replace(re,str)};rep(/(.*?)<\/a>/gi,"[url=$1]$2[/url]");rep(/(.*?)<\/span>/gi,"[size=$1]$2[/size]");rep(/(.*?)<\/font>/gi,"$1");rep(//gi,"[img]$1[/img]");rep(/(.*?)<\/code>/gi,"[code]$1[/code]");rep(/<\/(strong|b)>/gi,"[/b]");rep(/<(strong|b)>/gi,"[b]");rep(/<\/(em|i)>/gi,"[/i]");rep(/<(em|i)>/gi,"[i]");rep(/<\/u>/gi,"[/u]");rep(/(.*?)<\/span>/gi,"[u]$1[/u]");rep(//gi,"[u]");rep(/]*>/gi,"[quote]");rep(/<\/blockquote>/gi,"[/quote]");rep(/
/gi,"\n");rep(//gi,"\n");rep(/
/gi,"\n");rep(/

/gi,"");rep(/<\/p>/gi,"\n");rep(/ /gi," ");rep(/"/gi,"\"");rep(/</gi,"<");rep(/>/gi,">");rep(/&/gi,"&");return s},_dfrn_bbcode2html:function(s){s=tinymce.trim(s);function rep(re,str){s=s.replace(re,str)};rep(/\n/gi,"
");rep(/\[b\]/gi,"");rep(/\[\/b\]/gi,"");rep(/\[i\]/gi,"");rep(/\[\/i\]/gi,"");rep(/\[u\]/gi,"");rep(/\[\/u\]/gi,"");rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"$2");rep(/\[url\](.*?)\[\/url\]/gi,"$1");rep(/\[img\](.*?)\[\/img\]/gi,"");rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"$2");rep(/\[code\](.*?)\[\/code\]/gi,"$1");rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"

$1
");return s}});tinymce.PluginManager.add('bbcode',tinymce.plugins.BBCodePlugin)})(); \ No newline at end of file diff --git a/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js b/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js deleted file mode 100644 index db676cd908..0000000000 --- a/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js +++ /dev/null @@ -1,155 +0,0 @@ -/** - * editor_plugin_src.js - * - * Copyright 2009, Moxiecode Systems AB - * Released under LGPL License. - * - * License: http://tinymce.moxiecode.com/license - * Contributing: http://tinymce.moxiecode.com/contributing - */ - -/* Macgirvin Aug-2010 changed from punbb to dfrn dialect */ - -(function() { - tinymce.create('tinymce.plugins.BBCodePlugin', { - init : function(ed, url) { - var t = this, dialect = ed.getParam('bbcode_dialect', 'dfrn').toLowerCase(); - - ed.onBeforeSetContent.add(function(ed, o) { - o.content = t['_' + dialect + '_bbcode2html'](o.content); - }); - - ed.onPostProcess.add(function(ed, o) { - if (o.set) - o.content = t['_' + dialect + '_bbcode2html'](o.content); - - if (o.get) - o.content = t['_' + dialect + '_html2bbcode'](o.content); - }); - }, - - getInfo : function() { - return { - longname : 'BBCode Plugin', - author : 'Moxiecode Systems AB', - authorurl : 'http://tinymce.moxiecode.com', - infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/bbcode', - version : tinymce.majorVersion + "." + tinymce.minorVersion - }; - }, - - // Private methods - - // HTML -> BBCode in DFRN dialect - _dfrn_html2bbcode : function(s) { - s = tinymce.trim(s); - - function rep(re, str) { - s = s.replace(re, str); - }; - - - - - /* oembed */ - function _h2b_cb(match) { - text = bin2hex(match); - function s_h2b(data) { - match = data; - } - $.ajax({ - url: 'oembed/h2b?text=' + text, - async: false, - success: s_h2b, - dataType: 'html' - }); - return match; - } - s = s.replace(//gi, _h2b_cb); - /* /oembed */ - - - // example: to [b] - rep(/(.*?)<\/a>/gi,"[url=$1]$2[/url]"); - rep(/(.*?)<\/span>/gi,"[size=$1]$2[/size]"); - rep(/(.*?)<\/span>/gi,"[color=$1]$2[/color]"); - rep(/(.*?)<\/font>/gi,"$1"); - rep(//gi,"[img=$1x$2]$3[/img]"); - rep(//gi,"[img=$2x$1]$3[/img]"); - rep(//gi,"[img=$3x$2]$1[/img]"); - rep(//gi,"[img=$2x$3]$1[/img]"); - rep(//gi,"[img]$1[/img]"); - rep(/(.*?)<\/code>/gi,"[code]$1[/code]"); - rep(/<\/(strong|b)>/gi,"[/b]"); - rep(/<(strong|b)>/gi,"[b]"); - rep(/<\/(em|i)>/gi,"[/i]"); - rep(/<(em|i)>/gi,"[i]"); - rep(/<\/u>/gi,"[/u]"); - rep(/(.*?)<\/span>/gi,"[u]$1[/u]"); - rep(//gi,"[u]"); - rep(/]*>/gi,"[quote]"); - rep(/<\/blockquote>/gi,"[/quote]"); - rep(/
/gi,"\n\n"); - rep(//gi,"\n\n"); - rep(/
/gi,"\n"); - rep(/

/gi,""); - rep(/<\/p>/gi,"\n"); - rep(/ /gi," "); - rep(/"/gi,"\""); - rep(/</gi,"<"); - rep(/>/gi,">"); - rep(/&/gi,"&"); - - return s; - }, - - // BBCode -> HTML from DFRN dialect - _dfrn_bbcode2html : function(s) { - s = tinymce.trim(s); - - function rep(re, str) { - s = s.replace(re, str); - }; - - // example: [b] to - rep(/\n/gi,"
"); - rep(/\[b\]/gi,""); - rep(/\[\/b\]/gi,""); - rep(/\[i\]/gi,""); - rep(/\[\/i\]/gi,""); - rep(/\[u\]/gi,""); - rep(/\[\/u\]/gi,""); - rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"$2"); - rep(/\[url\](.*?)\[\/url\]/gi,"$1"); - rep(/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/gi,""); - rep(/\[img\](.*?)\[\/img\]/gi,""); - rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"$2"); - rep(/\[size=(.*?)\](.*?)\[\/size\]/gi,"$2"); - rep(/\[code\](.*?)\[\/code\]/gi,"$1"); - rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"

$1
"); - - /* oembed */ - function _b2h_cb(match, url) { - url = bin2hex(url); - function s_b2h(data) { - match = data; - } - $.ajax({ - url: 'oembed/b2h?url=' + url, - async: false, - success: s_b2h, - dataType: 'html' - }); - return match; - } - s = s.replace(/\[embed\](.*?)\[\/embed\]/gi, _b2h_cb); - - /* /oembed */ - - return s; - } - }); - - // Register plugin - tinymce.PluginManager.add('bbcode', tinymce.plugins.BBCodePlugin); -})(); \ No newline at end of file From c5cddc742810c03ab86f6e99b0c4d52071c4b523 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Thu, 30 Jun 2011 16:44:54 +0200 Subject: [PATCH 4/6] profile_sidebar hook use byref values in second argument array --- boot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot.php b/boot.php index ff036c3dfa..768493e443 100644 --- a/boot.php +++ b/boot.php @@ -2430,7 +2430,7 @@ function profile_sidebar($profile) { )); - $arr = array('profile' => $profile, 'entry' => $o); + $arr = array('profile' => &$profile, 'entry' => &$o); call_hooks('profile_sidebar', $arr); From 762bb8de795f8bb455da969d287397b2fa6a2f82 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Thu, 30 Jun 2011 17:00:26 +0200 Subject: [PATCH 5/6] update oembed and widgets plugins settings form --- addon/oembed/oembed.php | 28 +++++++++--------------- addon/oembed/settings.tpl | 7 ++++++ addon/widgets/settings.tpl | 19 ++++++++++++++++ addon/widgets/widgets.php | 36 +++++++++++++++---------------- view/theme/duepuntozero/style.css | 14 ++++++++++-- 5 files changed, 65 insertions(+), 39 deletions(-) create mode 100644 addon/oembed/settings.tpl create mode 100644 addon/widgets/settings.tpl diff --git a/addon/oembed/oembed.php b/addon/oembed/oembed.php index 7e677fd6f5..880e4992f5 100644 --- a/addon/oembed/oembed.php +++ b/addon/oembed/oembed.php @@ -25,9 +25,9 @@ function oembed_uninstall() { function oembed_settings_post($a,$b){ if(! local_user()) return; - if (isset($_POST['oembed-submit'])){ - set_pconfig(local_user(), 'oembed', 'use_for_youtube', (isset($_POST['oembed_use_for_youtube'])? intval($_POST['oembed_use_for_youtube']):0)); - notice( t('OEmbed settings updated') . EOL); + if (x($_POST,'oembed-submit')){ + set_pconfig(local_user(), 'oembed', 'use_for_youtube', (x($_POST,'oembed_use_for_youtube')? intval($_POST['oembed_use_for_youtube']):0)); + info( t('OEmbed settings updated') . EOL); } } @@ -36,21 +36,13 @@ function oembed_settings(&$a,&$o) { return; $uofy = intval(get_pconfig(local_user(), 'oembed', 'use_for_youtube' )); - $o.=' -
-

OEmbed

-
- -
-
-
- -
-
'; + $t = file_get_contents( dirname(__file__). "/settings.tpl" ); + $o .= replace_macros($t, array( + '$submit' => t('Submit'), + '$title' => "OEmbed", + '$useoembed' => array('oembed_use_for_youtube', t('Use OEmbed for YouTube videos'), $uofy, ""), + )); + } diff --git a/addon/oembed/settings.tpl b/addon/oembed/settings.tpl new file mode 100644 index 0000000000..5a65ef8e5d --- /dev/null +++ b/addon/oembed/settings.tpl @@ -0,0 +1,7 @@ +
+

$title

+ {{ inc field_checkbox.tpl with $field=$useoembed }}{{ endinc }} +
+ +
+
diff --git a/addon/widgets/settings.tpl b/addon/widgets/settings.tpl new file mode 100644 index 0000000000..9d0f21d296 --- /dev/null +++ b/addon/widgets/settings.tpl @@ -0,0 +1,19 @@ +
+

$title

+
+ + $key +
+ +
+ +
+ +

$widgets_h

+
    + {{ for $widgets as $w }} +
  • $w.1
  • + {{ endfor }} +
+ +
diff --git a/addon/widgets/widgets.php b/addon/widgets/widgets.php index f5f8682223..13c4f93bb2 100644 --- a/addon/widgets/widgets.php +++ b/addon/widgets/widgets.php @@ -33,34 +33,32 @@ function widgets_settings(&$a,&$o) { $key = get_pconfig(local_user(), 'widgets', 'key' ); if ($key=='') { $key = mt_rand(); set_pconfig(local_user(), 'widgets', 'key', $key); } - - $o .='

Widgets

'; - - - $o.=' -
- '. t('Widgets key: ') .''.$key.' -
-
-
- -
'; - - - $o.='

Widgets:

'; - $o .= '
    '; + + $widgets = array(); $d = dir(dirname(__file__)); while(false !== ($f = $d->read())) { if(substr($f,0,7)=="widget_") { preg_match("|widget_([^.]+).php|", $f, $m); $w=$m[1]; require_once($f); - $o.='
  • '. call_user_func($w."_widget_name") .'
  • '; + $widgets[] = array($w, call_user_func($w."_widget_name")); + } } - $o .= '
'; - + + + $t = file_get_contents( dirname(__file__). "/settings.tpl" ); + $o .= replace_macros($t, array( + '$submit' => t('Generate new key'), + '$baseurl' => $a->get_baseurl(), + '$title' => "Widgets", + '$label' => t('Widgets key'), + '$key' => $key, + '$widgets_h' => t('Widgets available'), + '$widgets' => $widgets, + )); + } function widgets_module() { diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index dc54398dc0..67a1546eed 100644 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -2541,6 +2541,15 @@ a.mail-list-link { filter:alpha(opacity=100); } +/** + * Plugins settings + */ + +.settings-block > h3, +.settings-heading { + border-bottom: 1px solid #babdb6 +} + /** * Form fields @@ -2554,7 +2563,6 @@ a.mail-list-link { .field label { float: left; width: 200px; - font-weight: bold; } .field input, @@ -2599,7 +2607,9 @@ a.mail-list-link { #adminpage h3 { border-bottom: 1px solid #cccccc; } - +#adminpage .field label { + font-weight: bold; +} #adminpage .submit { clear:left; text-align: right; From 7778dbb67b2c033473b0da9b34df01d28162b5ee Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Thu, 30 Jun 2011 17:01:26 +0200 Subject: [PATCH 6/6] twitter and statusnet plugin settings are not parsed on post if their respective submit buttons was not clicked by user --- addon/statusnet/statusnet.php | 63 ++++++++++++++++++----------------- addon/twitter/twitter.php | 7 ++-- 2 files changed, 38 insertions(+), 32 deletions(-) diff --git a/addon/statusnet/statusnet.php b/addon/statusnet/statusnet.php index 22f7dc8f9e..9357b0ebd9 100644 --- a/addon/statusnet/statusnet.php +++ b/addon/statusnet/statusnet.php @@ -89,6 +89,9 @@ function statusnet_jot_nets(&$a,&$b) { function statusnet_settings_post ($a,$post) { if(! local_user()) return; + // don't check statusnet settings if statusnet submit button is not clicked + if (!x($_POST,'statusnet-submit')) return; + if (isset($_POST['statusnet-disconnect'])) { /*** * if the statusnet-disconnect checkbox is set, clear the statusnet configuration @@ -152,28 +155,28 @@ function statusnet_settings_post ($a,$post) { goaway($a->get_baseurl().'/settings/addon'); } else { if (isset($_POST['statusnet-pin'])) { - // if the user supplied us with a PIN from Twitter, let the magic of OAuth happen - logger('got a StatusNet security code'); + // if the user supplied us with a PIN from Twitter, let the magic of OAuth happen + logger('got a StatusNet security code'); $api = get_pconfig(local_user(), 'statusnet', 'baseapi'); - $ckey = get_pconfig(local_user(), 'statusnet', 'consumerkey' ); - $csecret = get_pconfig(local_user(), 'statusnet', 'consumersecret' ); - // the token and secret for which the PIN was generated were hidden in the settings - // form as token and token2, we need a new connection to Twitter using these token - // and secret to request a Access Token with the PIN - $connection = new StatusNetOAuth($api, $ckey, $csecret, $_POST['statusnet-token'], $_POST['statusnet-token2']); - $token = $connection->getAccessToken( $_POST['statusnet-pin'] ); - // ok, now that we have the Access Token, save them in the user config - set_pconfig(local_user(),'statusnet', 'oauthtoken', $token['oauth_token']); - set_pconfig(local_user(),'statusnet', 'oauthsecret', $token['oauth_token_secret']); + $ckey = get_pconfig(local_user(), 'statusnet', 'consumerkey' ); + $csecret = get_pconfig(local_user(), 'statusnet', 'consumersecret' ); + // the token and secret for which the PIN was generated were hidden in the settings + // form as token and token2, we need a new connection to Twitter using these token + // and secret to request a Access Token with the PIN + $connection = new StatusNetOAuth($api, $ckey, $csecret, $_POST['statusnet-token'], $_POST['statusnet-token2']); + $token = $connection->getAccessToken( $_POST['statusnet-pin'] ); + // ok, now that we have the Access Token, save them in the user config + set_pconfig(local_user(),'statusnet', 'oauthtoken', $token['oauth_token']); + set_pconfig(local_user(),'statusnet', 'oauthsecret', $token['oauth_token_secret']); set_pconfig(local_user(),'statusnet', 'post', 1); // reload the Addon Settings page, if we don't do it see Bug #42 goaway($a->get_baseurl().'/settings/addon'); - } else { - // if no PIN is supplied in the POST variables, the user has changed the setting - // to post a tweet for every new __public__ posting to the wall - set_pconfig(local_user(),'statusnet','post',intval($_POST['statusnet-enable'])); - set_pconfig(local_user(),'statusnet','post_by_default',intval($_POST['statusnet-default'])); - info( t('StatusNet settings updated.') . EOL); + } else { + // if no PIN is supplied in the POST variables, the user has changed the setting + // to post a tweet for every new __public__ posting to the wall + set_pconfig(local_user(),'statusnet','post',intval($_POST['statusnet-enable'])); + set_pconfig(local_user(),'statusnet','post_by_default',intval($_POST['statusnet-default'])); + info( t('StatusNet settings updated.') . EOL); }}}} } function statusnet_settings(&$a,&$s) { @@ -217,7 +220,7 @@ function statusnet_settings(&$a,&$s) { $s .= ''. $asn['sitename'] .'
'; } $s .= '

'; - $s .= '
'; + $s .= '
'; } $s .= '

' . t('Provide your own OAuth Credentials') . '

'; $s .= '

'. t('No consumer key pair for StatusNet found. Register your Friendika Account as an desktop client on your StatusNet account, copy the consumer key pair here and enter the API base root.
Before you register your own OAuth key pair ask the administrator if there is already a key pair for this Friendika installation at your favorited StatusNet installation.') .'

'; @@ -231,7 +234,7 @@ function statusnet_settings(&$a,&$s) { $s .= ''; $s .= '
'; $s .= '

'; - $s .= '
'; + $s .= '
'; } else { /*** * ok we have a consumer key pair now look into the OAuth stuff @@ -256,15 +259,15 @@ function statusnet_settings(&$a,&$s) { $s .= ''; $s .= ''; $s .= ''; - $s .= '
'; - $s .= '
'; - $s .= '

'.t('Cancel Connection Process').'

'; - $s .= '
'; - $s .= '

'.t('Current StatusNet API is').': '.$api.'

'; - $s .= ''; - $s .= ''; - $s .= '
'; - $s .= '
'; + $s .= '
'; + $s .= '
'; + $s .= '

'.t('Cancel Connection Process').'

'; + $s .= '
'; + $s .= '

'.t('Current StatusNet API is').': '.$api.'

'; + $s .= ''; + $s .= ''; + $s .= '
'; + $s .= '
'; } else { /*** * we have an OAuth key / secret pair for the user @@ -286,7 +289,7 @@ function statusnet_settings(&$a,&$s) { $s .= ''; $s .= ''; $s .= '
'; - $s .= '
'; + $s .= '
'; } } $s .= '
'; diff --git a/addon/twitter/twitter.php b/addon/twitter/twitter.php index 7829799bc1..183c71126f 100644 --- a/addon/twitter/twitter.php +++ b/addon/twitter/twitter.php @@ -76,6 +76,9 @@ function twitter_jot_nets(&$a,&$b) { function twitter_settings_post ($a,$post) { if(! local_user()) return; + // don't check twitter settings if twitter submit button is not clicked + if (!x($_POST,'twitter-submit')) return; + if (isset($_POST['twitter-disconnect'])) { /*** * if the twitter-disconnect checkbox is set, clear the OAuth key/secret pair @@ -159,7 +162,7 @@ function twitter_settings(&$a,&$s) { $s .= ''; $s .= ''; $s .= '
'; - $s .= '
'; + $s .= '
'; } else { /*** * we have an OAuth key / secret pair for the user @@ -178,7 +181,7 @@ function twitter_settings(&$a,&$s) { $s .= ''; $s .= ''; $s .= '
'; - $s .= '
'; + $s .= '
'; } } $s .= '
';