Commit 86b8b7b2 authored by Dave Lane's avatar Dave Lane
Browse files

added admin interface for implementation-specific settings, added full...

added admin interface for implementation-specific settings, added full language support for all user visible text strings, bumped version to 2.0.0
parent df05b2bf
......@@ -7,7 +7,7 @@ Plugin Name: Blog Feed Finder
Plugin URI: https://github.com/oeru/bff
Description: Provides a widget that helps a user figure out the valid URL for
their personal course blog feed
Version: 1.0.3
Version: 2.0.0
Author: Dave Lane
Author URI: https://oeru.org, http://WikiEducator.org/User:Davelane
License: AGPLv3 or later
......@@ -30,7 +30,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
define( 'BFF_VERSION', '1.0.3' );
define( 'BFF_VERSION', '2.0.0' );
// plugin computer name
define('BFF_NAME', 'BFF');
// current version
......@@ -50,13 +50,18 @@ define('BFF_ID', 'blog-feed-finder');
define('BFF_CLASS', 'bff-form');
define('BFF_OERU_THEME_NAME', 'OERu Course');
define('BFF_REGISTER_ENROL_PLUGIN', 'register-enrol/register-enrol.php');
define('BFF_PREFIX', 'bff_');
// support link for users of this plugin...
define('BFF_ORG_NAME', 'OERu');
define('BFF_ORG_PREFIX', false); // this should be true if the org's name starts with "The"
define('BFF_SUPPORT_FORUM', 'https://forums.oeru.org/t/blog-feed-finder');
define('BFF_SUPPORT_BLOG', 'https://course.oeru.org/support/studying-courses/course-blog/');
// admin details
define('BFF_ADMIN_SLUG', 'BFF_settings');
define('BFF_ADMIN_TITLE', 'Blog Feed Finder Settings');
define('BFF_ADMIN_MENU', 'BFF Settings');
define('BFF_ADMIN_SCRIPT', 'bff-admin-script');
define('BFF_ADMIN_STYLE', 'bff-admin-style');
// other useful parameters
define('BFF_MAX_FILE_READ_CHAR', 1000000); // limit max size of the file to read to 1mb
// turn on debugging with true, off with false
......@@ -68,7 +73,7 @@ require BFF_PATH . '/includes/bff-app.php';
if ( function_exists( 'add_action' ) ) {
// this starts everything up!
add_action('plugins_loaded', array(BFFForm::get_instance(), 'init'));
add_action('wp_loaded', array(BFFForm::get_instance(), 'init'));
} else {
echo 'This only works as a WordPress plugin.';
exit;
......
This diff is collapsed.
......@@ -17,15 +17,17 @@ class BFFCourse extends BFFFinder {
// show the user info if they're not logged in...
public function alert_anon_user() {
$message = '<p class="bff-notice">You are not currently logged in. As such, you will not be able to link any blog feed addresses you find to your profile.</p>';
$message = '<p class="bff-notice">'.__('You are not currently logged in. As such, you will not be able to link any blog feed addresses you find to your profile.', 'oeru-bff').'</p>';
// if this is a multisite, recommend a user log in to get the most functionality from the plugin.
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
if ($this->is_using_oeru_theme() && is_plugin_active(BFF_REGISTER_ENROL_PLUGIN)) {
$message .= '<p class="bff-notice">You can <a data-toggle="modal" title="Click to log in or register for Courses" href="/'.BFF_SLUG.'#login" onclick="login();"><span
class="glyphicon glyphicon-user"></span>log in</a> to link your feed(s) to any courses for which you\'re registered.</p>';
// translators: the %s is the web address required to log into this site
$message .= '<p class="bff-notice">'.sprintf(__('You can <a data-toggle="modal" title="Click to log in or register for Courses" href="%s#login" onclick="login();"><span
class="glyphicon glyphicon-user"></span>log in</a> to link your feed(s) to any courses for which you\'re registered.', 'oeru-bff'), BFF_SLUG).'</p>';
} else {
$message .= '<p class="bff-notice">You can <a title="Click to log in or register for Courses" href="'.wp_login_url(BFF_SLUG).'"><span
class="glyphicon glyphicon-user"></span>log in or register</a> to link your feed(s) to any courses for which you\'re registered.</p>';
// translators: the %s is the web address required to log into this site
$message .= '<p class="bff-notice">'.sprintf(__('You can <a title="Click to log in or register for Courses" href="%s"><span
class="glyphicon glyphicon-user"></span>log in or register</a> to link your feed(s) to any courses for which you\'re registered.', 'oeru-bff'), wp_login_url(BFF_SLUG)).'</p>';
}
}
// put out
......@@ -47,7 +49,7 @@ class BFFCourse extends BFFFinder {
public function inform_auth_user() {
?>
<div id="bff-auth-notice" class="bff-auth bff-info bff-alert-box">
<p class="bff-notice">You can link any blog feeds addresses you find to any courses for which you are registered.</p>
<p class="bff-notice"><?php _e('You can link any blog feeds addresses you find to any courses for which you are registered.'); ?></p>
</div>
<?php
}
......@@ -98,7 +100,7 @@ class BFFCourse extends BFFFinder {
'url' => $url,
'type' => $type
);
do_action('bff_update_user_feed', $args);
//do_action('bff_update_user_feed', $args);
//
return true;
} else {
......@@ -125,4 +127,21 @@ class BFFCourse extends BFFFinder {
return strtolower(substr($site->path,1,-1));
}
// this is from blog-feed-finder plugin - git.oeru.org/oeru/blog-feed-finder !! See includes/bff-course.php
public function cleanup_user_feed_meta($user_id, $site_id) {
if (delete_user_meta($user_id, 'url_'.$site_id)) {
delete_user_meta($user_id, 'feedtype_'.$site_id);
$this->log('tidying up after ourselves, removed associated user meta data');
}
}
// this is from blog-feed-finder plugin - git.oeru.org/oeru/blog-feed-finder !! See includes/bff-course.php
/*public function update_user_feed_meta($user_id, $site_id, $url, $type) {
if (update_user_meta($user_id, 'url_'.$site_id, $url)) {
delete_user_meta($user_id, 'feedtype_'.$site_id);
$this->log('tidying up after ourselves, removed associated user meta data');
}
}*/
}
This diff is collapsed.
/* created by Dave Lane, dave@oerfoundation.org, https://oeru.org */
var BFF_DEBUG = true; // set to false to disable debugging
var BFF_DEBUG = false; // set to false to disable debugging
function LOG() { if (BFF_DEBUG) { console.log.apply(this, arguments); }}
LOG('BFF DEBUG =', BFF_DEBUG); // only prints if DEBUG = true
......@@ -29,9 +29,9 @@ function get_url(data) {
function compile_feeds(feeds, types, classes, authenticated) {
cnt = feeds.length;
msg = '';
msg += '<p class="instruction">We have identified the following supported feeds. ';
msg += '<p class="instruction">'+bff_data.strings.supported_feeds_found;
if (authenticated) {
msg += 'Please select the one you think the best choice:';
msg += bff_data.strings.select_best_choice;
}
msg += '</p>';
msg += '<ul>';
......@@ -41,13 +41,13 @@ function compile_feeds(feeds, types, classes, authenticated) {
msg += '<li>';
msg += '<a href="' + feed.url + '">' + feed.url + '</a>';
if (feed.title != '') {
msg += ', entitled "' + feed.title +'" ';
msg += ', '+bff_data.strings.entitled+' "' + feed.title +'" ';
}
//msg += ' (' + content_type + ' format)';
msg += '<span class="bff-feed '+content_class+'" title="'+content_type+' Format"></span>';
msg += '<span class="bff-feed '+content_class+'" title="'+content_type+' '+bff_data.strings.format+'"></span>';
if (authenticated) {
LOG('user is authenticated');
msg += ' <button id="bff-select-' + num + '" class="bff-select">Select Feed</button>';
msg += ' <button id="bff-select-' + num + '" class="bff-select">'+bff_data.strings.selected_feed+'</button>';
} else {
LOG('user is NOT authenticated');
}
......@@ -65,18 +65,18 @@ function selected_feed(feeds, types, classes) {
feed = feeds[feeds.selected];
content_type = types[feed.type];
content_classes = classes[feed.type];
msg += '<p class="instruction"><span class="bff-feed '+content_classes+'" title="' + content_type + ' feed"></span>';
end = ' selected</p>';
msg += '<p class="instruction"><span class="bff-feed '+content_classes+'" title="'+content_type+' '+bff_data.strings.feed+'"></span>';
end = ' '+bff_data.strings.selected+'.</p>';
} else if (cnt == 1) {
feed = feeds[0];
content_type = types[feed.type];
content_classes = classes[feed.type];
msg += '<p class="instruction"><span class="bff-feed '+content_classes+'" title="' + content_type + ' feed"></span> We found a feed - ';
msg += '<p class="instruction"><span class="bff-feed '+content_classes+'" title="'+content_type+' '+bff_data.strings.feed+'."></span> '+bff_data.strings.we_found_a_feed+' - ';
end = '</p>';
}
msg += '<a href="' + feed.url +'">' + feed.url + '</a>';
if (feed.title != '') {
msg += ', entitled "' + feed.title +'"';
msg += ', '+bff_data.strings.entitled+' "'+feed.title+'"';
}
msg += end;
return msg;
......@@ -90,26 +90,26 @@ function compile_courses(courses, newfeed) {
msg += '<li class="'+site.tag+'"><a href="' + site.path +'">' + site.name + '</a> (' + site.tag +')';
if (site.feed) {
if (site.feed == newfeed) {
msg += ' - blog feed already set to <a href="' + site.feed + '">'+newfeed+'</a>';
msg += ' - '+bff_data.strings.blog_feed_already_set_to+' <a href="' + site.feed + '">'+newfeed+'</a>';
} else {
msg += ' - <span id="bff-original-'+ site.tag + '">existing blog feed: <a href="' + site.feed + '">' + site.feed + '</a></span>';
msg += ' - <span id="bff-original-'+ site.tag + '">'+bff_data.strings.existing_blog_feed+': <a href="' + site.feed + '">' + site.feed + '</a></span>';
msg += ' <button id="bff-set-' + site.tag + '-' + site.id +
'" class="bff-set">Replace</button>';
'" class="bff-set">'+bff_data.strings.replace+'</button>';
settable = true;
}
} else {
msg += ' - <span id="bff-original-'+ site.tag + '">no url specified</span>';
msg += ' <button id="bff-set-' + site.tag + '-' + site.id +
'" class="bff-set">Assign</button>';
'" class="bff-set">'+bff_data.strings.assign+'</button>';
settable = true;
}
msg += '</li>';
});
msg += '</ul>';
if (settable) {
msg = '<p class="instruction">You can assign this blog feed to any of your OERu courses, or use it to replace any existing assignments:</p>' + msg;
msg = '<p class="instruction">'+bff_data.strings.assign_blog_feed_to_any_courses+'</p>' + msg;
} else {
msg = '<p>All of your blog feeds are already set to this feed! There\'s nothing you need to do. Well done!</p>' + msg;
msg = '<p>'+bff_data.strings.all_your_blog_feeds_already_set_to_this_feed+'</p>' + msg;
}
return msg;
}
......@@ -135,7 +135,7 @@ function get_course_id(str) {
// https://stackoverflow.com/questions/13770741/reload-page-with-different-anchor
function login() {
console.log('reload this window with #login');
LOG('reload this window with #login');
window.location.hash = '#login';
window.location.reload(true);
}
......@@ -153,7 +153,7 @@ jQuery(document).ready(function() {
$(window).on('load', function() {
LOG('in load');
$('#bff-submit').attr('disabled', false);
$('#bff-feedback').html('Ready...');
$('#bff-feedback').html(bff_data.strings.ready+'...');
$('#bff-course-list').attr('hidden', true);
});
......@@ -272,8 +272,8 @@ jQuery(document).ready(function() {
// show that a course has been updated
function update_course_feed(tag, id, url) {
LOG('course '+tag+' updated to '+url);
$('#bff-original-'+tag).html('updated blog feed to <a href="'+url+'">'+url+'</a>&nbsp;&nbsp;<span class="bff-success">Success</span>');
LOG('course '+tag+' '+bff_data.strings.updated_to+' '+url);
$('#bff-original-'+tag).html(bff_data.strings.updated_blog_feed_to+' <a href="'+url+'">'+url+'</a>&nbsp;&nbsp;<span class="bff-success">'+bff_data.strings.success+'</span>');
$('#bff-original-'+tag).addClass('updated');
selector = '#bff-set-'+tag+'-'+id;
LOG('turning off button: "'+selector+'"');
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment