Merge branch 'pull'
This commit is contained in:
commit
b03df35b02
14 changed files with 360 additions and 275 deletions
|
@ -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.='
|
||||
<div class="settings-block">
|
||||
<h3 class="settings-heading">OEmbed</h3>
|
||||
<div id="settings-username-wrapper">
|
||||
<label for="oembed_use_for_youtube">'
|
||||
.t('Use OEmbed for YouTube videos: ')
|
||||
.'</label><input type="checkbox" id="oembed_use_for_youtube" name="oembed_use_for_youtube" value="1"'
|
||||
. ($uofy==1?'checked="true"':'')
|
||||
.' />
|
||||
</div>
|
||||
<div id="settings-username-end"></div>
|
||||
<div class="settings-submit-wrapper">
|
||||
<input type="submit" value="'.t('Submit').'" class="settings-submit" name="oembed-submit" />
|
||||
</div>
|
||||
</div>';
|
||||
$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, ""),
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
7
addon/oembed/settings.tpl
Normal file
7
addon/oembed/settings.tpl
Normal file
|
@ -0,0 +1,7 @@
|
|||
<div class="settings-block">
|
||||
<h3 class="settings-heading">$title</h3>
|
||||
{{ inc field_checkbox.tpl with $field=$useoembed }}{{ endinc }}
|
||||
<div class="settings-submit-wrapper">
|
||||
<input type="submit" value="$submit" class="settings-submit" name="oembed-submit" />
|
||||
</div>
|
||||
</div>
|
|
@ -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 .= '<input type="radio" name="statusnet-preconf-apiurl" value="'. $asn['apiurl'] .'">'. $asn['sitename'] .'<br />';
|
||||
}
|
||||
$s .= '<p></p><div class="clear"></div></div>';
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="statusnet-submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
|
||||
}
|
||||
$s .= '<h4>' . t('Provide your own OAuth Credentials') . '</h4>';
|
||||
$s .= '<p>'. 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.<br />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.') .'</p>';
|
||||
|
@ -231,7 +234,7 @@ function statusnet_settings(&$a,&$s) {
|
|||
$s .= '<label id="statusnet-baseapi-label" for="statusnet-baseapi">'. t("Base API Path \x28remember the trailing /\x29") .'</label>';
|
||||
$s .= '<input id="statusnet-baseapi" type="text" name="statusnet-baseapi" size="35" /><br />';
|
||||
$s .= '<p></p><div class="clear"></div></div>';
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="statusnet-submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
|
||||
} else {
|
||||
/***
|
||||
* ok we have a consumer key pair now look into the OAuth stuff
|
||||
|
@ -256,15 +259,15 @@ function statusnet_settings(&$a,&$s) {
|
|||
$s .= '<input id="statusnet-pin" type="text" name="statusnet-pin" />';
|
||||
$s .= '<input id="statusnet-token" type="hidden" name="statusnet-token" value="'.$token.'" />';
|
||||
$s .= '<input id="statusnet-token2" type="hidden" name="statusnet-token2" value="'.$request_token['oauth_token_secret'].'" />';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
|
||||
$s .= '<h4>'.t('Cancel Connection Process').'</h4>';
|
||||
$s .= '<div id="statusnet-cancel-wrapper">';
|
||||
$s .= '<p>'.t('Current StatusNet API is').': '.$api.'</p>';
|
||||
$s .= '<label id="statusnet-cancel-label" for="statusnet-cancel">'. t('Cancel StatusNet Connection') . '</label>';
|
||||
$s .= '<input id="statusnet-cancel" type="checkbox" name="statusnet-disconnect" value="1" />';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
|
||||
$s .= '<h4>'.t('Cancel Connection Process').'</h4>';
|
||||
$s .= '<div id="statusnet-cancel-wrapper">';
|
||||
$s .= '<p>'.t('Current StatusNet API is').': '.$api.'</p>';
|
||||
$s .= '<label id="statusnet-cancel-label" for="statusnet-cancel">'. t('Cancel StatusNet Connection') . '</label>';
|
||||
$s .= '<input id="statusnet-cancel" type="checkbox" name="statusnet-disconnect" value="1" />';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="statusnet-submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
|
||||
} else {
|
||||
/***
|
||||
* we have an OAuth key / secret pair for the user
|
||||
|
@ -286,7 +289,7 @@ function statusnet_settings(&$a,&$s) {
|
|||
$s .= '<label id="statusnet-disconnect-label" for="statusnet-disconnect">'. t('Clear OAuth configuration') .'</label>';
|
||||
$s .= '<input id="statusnet-disconnect" type="checkbox" name="statusnet-disconnect" value="1" />';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="statusnet-submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
|
||||
}
|
||||
}
|
||||
$s .= '</div><div class="clear"></div></div>';
|
||||
|
|
|
@ -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 .= '<input id="twitter-token" type="hidden" name="twitter-token" value="'.$token.'" />';
|
||||
$s .= '<input id="twitter-token2" type="hidden" name="twitter-token2" value="'.$request_token['oauth_token_secret'].'" />';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="twitter-submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
|
||||
} else {
|
||||
/***
|
||||
* we have an OAuth key / secret pair for the user
|
||||
|
@ -178,7 +181,7 @@ function twitter_settings(&$a,&$s) {
|
|||
$s .= '<label id="twitter-disconnect-label" for="twitter-disconnect">'. t('Clear OAuth configuration') .'</label>';
|
||||
$s .= '<input id="twitter-disconnect" type="checkbox" name="twitter-disconnect" value="1" />';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="twitter-submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
|
||||
}
|
||||
}
|
||||
$s .= '</div><div class="clear"></div></div>';
|
||||
|
|
19
addon/widgets/settings.tpl
Normal file
19
addon/widgets/settings.tpl
Normal file
|
@ -0,0 +1,19 @@
|
|||
<div class="settings-block">
|
||||
<h3 class="settings-heading">$title</h3>
|
||||
<div class='field noedit'>
|
||||
<label>$label</label>
|
||||
<tt>$key</tt>
|
||||
</div>
|
||||
|
||||
<div class="settings-submit-wrapper">
|
||||
<input type="submit" value="$submit" class="settings-submit" name="widgets-submit" />
|
||||
</div>
|
||||
|
||||
<h4>$widgets_h</h4>
|
||||
<ul>
|
||||
{{ for $widgets as $w }}
|
||||
<li><a href="$baseurl/widgets/$w.0/?k=$key&p=1">$w.1</a></li>
|
||||
{{ endfor }}
|
||||
</ul>
|
||||
|
||||
</div>
|
|
@ -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 .='<h3 class="settings-heading">Widgets</h3>';
|
||||
|
||||
|
||||
$o.='
|
||||
<div id="settings-username-wrapper">
|
||||
'. t('Widgets key: ') .'<strong>'.$key.'</strong>
|
||||
</div>
|
||||
<div id="settings-username-end"></div>
|
||||
<div class="settings-submit-wrapper">
|
||||
<input type="submit" value="'.t('Generate new key').'" class="settings-submit" name="widgets-submit">
|
||||
</div>';
|
||||
|
||||
|
||||
$o.='<h4>Widgets:</h4>';
|
||||
$o .= '<ul>';
|
||||
|
||||
$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.='<li><a href="'.$a->get_baseurl().'/widgets/'.$w.'/?k='.$key.'&p=1">'. call_user_func($w."_widget_name") .'</a></li>';
|
||||
$widgets[] = array($w, call_user_func($w."_widget_name"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$o .= '</ul>';
|
||||
|
||||
|
||||
|
||||
$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() {
|
||||
|
|
2
boot.php
2
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);
|
||||
|
||||
|
|
|
@ -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.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");rep(/<font>(.*?)<\/font>/gi,"$1");rep(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]");rep(/<code>(.*?)<\/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 style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]");rep(/<u>/gi,"[u]");rep(/<blockquote[^>]*>/gi,"[quote]");rep(/<\/blockquote>/gi,"[/quote]");rep(/<br \/>/gi,"\n");rep(/<br\/>/gi,"\n");rep(/<br>/gi,"\n");rep(/<p>/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,"<br />");rep(/\[b\]/gi,"<strong>");rep(/\[\/b\]/gi,"</strong>");rep(/\[i\]/gi,"<em>");rep(/\[\/i\]/gi,"</em>");rep(/\[u\]/gi,"<u>");rep(/\[\/u\]/gi,"</u>");rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"<font color=\"$1\">$2</font>");rep(/\[code\](.*?)\[\/code\]/gi,"<code>$1</code>");rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"<blockquote>$1</blockquote>");return s}});tinymce.PluginManager.add('bbcode',tinymce.plugins.BBCodePlugin)})();
|
||||
/**
|
||||
* 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(/<span class=\"oembed(.*?)<\/span>/gi, _h2b_cb);
|
||||
/* /oembed */
|
||||
|
||||
|
||||
// example: <strong> to [b]
|
||||
rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
|
||||
rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");
|
||||
rep(/<span style=\"color:(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]");
|
||||
rep(/<font>(.*?)<\/font>/gi,"$1");
|
||||
rep(/<img.*?width=\"(.*?)\".*?height=\"(.*?)\".*?src=\"(.*?)\".*?\/>/gi,"[img=$1x$2]$3[/img]");
|
||||
rep(/<img.*?height=\"(.*?)\".*?width=\"(.*?)\".*?src=\"(.*?)\".*?\/>/gi,"[img=$2x$1]$3[/img]");
|
||||
rep(/<img.*?src=\"(.*?)\".*?height=\"(.*?)\".*?width=\"(.*?)\".*?\/>/gi,"[img=$3x$2]$1[/img]");
|
||||
rep(/<img.*?src=\"(.*?)\".*?width=\"(.*?)\".*?height=\"(.*?)\".*?\/>/gi,"[img=$2x$3]$1[/img]");
|
||||
rep(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]");
|
||||
rep(/<code>(.*?)<\/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 style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]");
|
||||
rep(/<u>/gi,"[u]");
|
||||
rep(/<blockquote[^>]*>/gi,"[quote]");
|
||||
rep(/<\/blockquote>/gi,"[/quote]");
|
||||
rep(/<br \/>/gi,"\n\n");
|
||||
rep(/<br\/>/gi,"\n\n");
|
||||
rep(/<br>/gi,"\n");
|
||||
rep(/<p>/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 <strong>
|
||||
rep(/\n/gi,"<br />");
|
||||
rep(/\[b\]/gi,"<strong>");
|
||||
rep(/\[\/b\]/gi,"</strong>");
|
||||
rep(/\[i\]/gi,"<em>");
|
||||
rep(/\[\/i\]/gi,"</em>");
|
||||
rep(/\[u\]/gi,"<u>");
|
||||
rep(/\[\/u\]/gi,"</u>");
|
||||
rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");
|
||||
rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");
|
||||
rep(/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/gi,"<img width=\"$1\" height=\"$2\" src=\"$3\" />");
|
||||
rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");
|
||||
rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"<span style=\"color: $1;\">$2</span>");
|
||||
rep(/\[size=(.*?)\](.*?)\[\/size\]/gi,"<span style=\"font-size: $1;\">$2</span>");
|
||||
rep(/\[code\](.*?)\[\/code\]/gi,"<code>$1</code>");
|
||||
rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"<blockquote>$1</blockquote>");
|
||||
|
||||
/* 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);
|
||||
})();
|
1
library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_cmp.js
vendored
Normal file
1
library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_cmp.js
vendored
Normal file
|
@ -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.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");rep(/<font>(.*?)<\/font>/gi,"$1");rep(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]");rep(/<code>(.*?)<\/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 style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]");rep(/<u>/gi,"[u]");rep(/<blockquote[^>]*>/gi,"[quote]");rep(/<\/blockquote>/gi,"[/quote]");rep(/<br \/>/gi,"\n");rep(/<br\/>/gi,"\n");rep(/<br>/gi,"\n");rep(/<p>/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,"<br />");rep(/\[b\]/gi,"<strong>");rep(/\[\/b\]/gi,"</strong>");rep(/\[i\]/gi,"<em>");rep(/\[\/i\]/gi,"</em>");rep(/\[u\]/gi,"<u>");rep(/\[\/u\]/gi,"</u>");rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"<font color=\"$1\">$2</font>");rep(/\[code\](.*?)\[\/code\]/gi,"<code>$1</code>");rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"<blockquote>$1</blockquote>");return s}});tinymce.PluginManager.add('bbcode',tinymce.plugins.BBCodePlugin)})();
|
|
@ -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(/<span class=\"oembed(.*?)<\/span>/gi, _h2b_cb);
|
||||
/* /oembed */
|
||||
|
||||
|
||||
// example: <strong> to [b]
|
||||
rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
|
||||
rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");
|
||||
rep(/<span style=\"color:(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]");
|
||||
rep(/<font>(.*?)<\/font>/gi,"$1");
|
||||
rep(/<img.*?width=\"(.*?)\".*?height=\"(.*?)\".*?src=\"(.*?)\".*?\/>/gi,"[img=$1x$2]$3[/img]");
|
||||
rep(/<img.*?height=\"(.*?)\".*?width=\"(.*?)\".*?src=\"(.*?)\".*?\/>/gi,"[img=$2x$1]$3[/img]");
|
||||
rep(/<img.*?src=\"(.*?)\".*?height=\"(.*?)\".*?width=\"(.*?)\".*?\/>/gi,"[img=$3x$2]$1[/img]");
|
||||
rep(/<img.*?src=\"(.*?)\".*?width=\"(.*?)\".*?height=\"(.*?)\".*?\/>/gi,"[img=$2x$3]$1[/img]");
|
||||
rep(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]");
|
||||
rep(/<code>(.*?)<\/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 style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]");
|
||||
rep(/<u>/gi,"[u]");
|
||||
rep(/<blockquote[^>]*>/gi,"[quote]");
|
||||
rep(/<\/blockquote>/gi,"[/quote]");
|
||||
rep(/<br \/>/gi,"\n\n");
|
||||
rep(/<br\/>/gi,"\n\n");
|
||||
rep(/<br>/gi,"\n");
|
||||
rep(/<p>/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 <strong>
|
||||
rep(/\n/gi,"<br />");
|
||||
rep(/\[b\]/gi,"<strong>");
|
||||
rep(/\[\/b\]/gi,"</strong>");
|
||||
rep(/\[i\]/gi,"<em>");
|
||||
rep(/\[\/i\]/gi,"</em>");
|
||||
rep(/\[u\]/gi,"<u>");
|
||||
rep(/\[\/u\]/gi,"</u>");
|
||||
rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");
|
||||
rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");
|
||||
rep(/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/gi,"<img width=\"$1\" height=\"$2\" src=\"$3\" />");
|
||||
rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");
|
||||
rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"<span style=\"color: $1;\">$2</span>");
|
||||
rep(/\[size=(.*?)\](.*?)\[\/size\]/gi,"<span style=\"font-size: $1;\">$2</span>");
|
||||
rep(/\[code\](.*?)\[\/code\]/gi,"<code>$1</code>");
|
||||
rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"<blockquote>$1</blockquote>");
|
||||
|
||||
/* 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);
|
||||
})();
|
|
@ -2,6 +2,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<title><?php if(x($page,'title')) echo $page['title'] ?></title>
|
||||
<script>var baseurl="<?php echo $a->get_baseurl() ?>";</script>
|
||||
<?php if(x($page,'htmlhead')) echo $page['htmlhead'] ?>
|
||||
</head>
|
||||
<body>
|
||||
|
|
44
view/field_richtext.tpl
Normal file
44
view/field_richtext.tpl
Normal file
|
@ -0,0 +1,44 @@
|
|||
|
||||
<div class='field richtext'>
|
||||
<label for='id_$field.0'>$field.1</label>
|
||||
<textarea name='$field.0' id='id_$field.0' class="fieldRichtext">$field.2</textarea>
|
||||
<span class='field_help'>$field.3</span>
|
||||
<script>
|
||||
console.log(typeof tinyMCE);
|
||||
if(typeof tinyMCE == "undefined") {
|
||||
tinyMCE="loading";
|
||||
window.tinyMCEPreInit = {
|
||||
suffix:"",
|
||||
base: baseurl+"/library/tinymce/jscripts/tiny_mce/",
|
||||
query:"",
|
||||
};
|
||||
$(function(){
|
||||
$.getScript(baseurl +"/library/tinymce/jscripts/tiny_mce/tiny_mce_src.js", function(){
|
||||
tinyMCE.init({
|
||||
theme : "advanced",
|
||||
mode : "specific_textareas",
|
||||
editor_selector: "fieldRichtext",
|
||||
plugins : "bbcode,paste",
|
||||
theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
|
||||
theme_advanced_buttons2 : "",
|
||||
theme_advanced_buttons3 : "",
|
||||
theme_advanced_toolbar_location : "top",
|
||||
theme_advanced_toolbar_align : "center",
|
||||
theme_advanced_blockformats : "blockquote,code",
|
||||
paste_text_sticky : true,
|
||||
entity_encoding : "raw",
|
||||
add_unload_trigger : false,
|
||||
remove_linebreaks : false,
|
||||
force_p_newlines : false,
|
||||
force_br_newlines : true,
|
||||
forced_root_block : '',
|
||||
convert_urls: false,
|
||||
content_css: baseurl+"/view/custom_tinymce.css",
|
||||
theme_advanced_path : false,
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
</div>
|
|
@ -2541,6 +2541,43 @@ a.mail-list-link {
|
|||
filter:alpha(opacity=100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugins settings
|
||||
*/
|
||||
|
||||
.settings-block > h3,
|
||||
.settings-heading {
|
||||
border-bottom: 1px solid #babdb6
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Form fields
|
||||
*/
|
||||
.field {
|
||||
clear: left;
|
||||
margin-bottom: 5px;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
.field label {
|
||||
float: left;
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.field input,
|
||||
.field textarea {
|
||||
width: 400px;
|
||||
}
|
||||
.field textarea { height: 100px; }
|
||||
.field_help {
|
||||
display: block;
|
||||
margin-left: 200px;
|
||||
color: #666666;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ADMIN
|
||||
*/
|
||||
|
@ -2567,34 +2604,12 @@ 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;
|
||||
}
|
||||
|
||||
#adminpage .field label {
|
||||
font-weight: bold;
|
||||
}
|
||||
#adminpage .submit {
|
||||
clear:left;
|
||||
text-align: right;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue