Commit c3c58400 authored by Dave Lane's avatar Dave Lane

checkpoint commit, converting to jquery-ui dialogs and internationalising strings

parent edc862e2
......@@ -5,7 +5,9 @@ require ORE_PATH . 'includes/ore_base.php';
//require ORE_PATH . 'includes/ore_countries.php';
require ORE_PATH . 'includes/country_selector.php';
// get the modal dialogue definitions
require ORE_PATH . 'includes/ore_modals.php';
require ORE_PATH . 'includes/ore_dialogs.php';
// get the form validation messages
require ORE_PATH . 'includes/ore_validation.php';
class OREMain extends OREBase {
public static $instance = NULL; // this instance
......@@ -69,9 +71,11 @@ class OREMain extends OREBase {
'un_min' => ORE_MIN_USERNAME_LENGTH,
'login_status' => ORE_LOGIN_STATUS,
'menu_label' => ORE_DEFAULT_MENU_LABEL,
'menus' => $this->get_menus(),
'user' => $user_array,
'modals' => $this->get_modals(),
'country_select' => $this->get_country_selector($user_country)
'dialogs' => $this->get_dialogs(),
'country_select' => $this->get_country_selector($user_country),
'validation_messages' => $this->get_validation_messages()
);
// if there're errors, include that.
if (is_array($this->errors) || is_object($this->errors)) {
......@@ -107,7 +111,7 @@ class OREMain extends OREBase {
// give realtime info on whether or not a username is unique in the system
public function ajax_username_check() {
if ( ! wp_verify_nonce(sanitize_text_field($_POST['nonce_submit']), 'ore-submit-nonce') ) {
die ("Busted - someone's trying something funny in submit!");
die ("Dang it - someone's trying something funny in submit!");
} else {
//$this->log('ore-submit-nonce all good.');
}
......@@ -126,7 +130,7 @@ class OREMain extends OREBase {
//$this->log('in ajax_submit: '.print_r($_POST, true));
// check if the submitted nonce matches the generated nonce created in the auth_init functionality
if ( ! wp_verify_nonce(sanitize_text_field($_POST['nonce_submit']), 'ore-submit-nonce') ) {
die ("Busted - someone's trying something funny in submit!");
die ("Drat and blast - someone's trying something funny in submit!");
} else {
//$this->log('ore-submit-nonce all good.');
}
......@@ -825,22 +829,41 @@ class OREMain extends OREBase {
return false;
}
public function get_menus() {
$this->log('in get_menus');
global $menus;
if (!is_array($menus)) {
return false;
}
$menu_data = array();
foreach($menus as $menu => $val) {
$menu_data[$menu][] = $val;
}
return $menu_data;
}
public function get_validation_messages() {
global $validation_messages;
return $validation_messages;
}
// get modal dialogues in a form that can be injected by javascript
public function get_modals() {
global $modals;
public function get_dialogs() {
global $dialog_definitions;
if (!is_array($modals)) {
return false;
}
$dialogs = array();
foreach($modals as $index => $val) {
foreach($dialog_definitions as $index => $val) {
// create the markup
$markup = '<div id="ore-modal-'.$val['token'].'" class="ore-modal modal fade">';
$markup .= '<div class="modal-dialog"><form class="ore-form modal-body ore-body"><fieldset class="modal-content">';
if (isset($val['title'])) {
//$this->log('getting the modal: "'.$val['title'].'"');
$markup .= '<div class="modal-header">';
$markup .= '<button class="close" type="button" data-dismiss="modal" aria-label="Close"><span class="close" aria-hidden="true" title="This will close this window, and any changes will be lost...">&nbsp;</span></button>';
$markup .= '<button class="close" type="button" data-dismiss="modal" aria-label="Close"><span class="close" aria-hidden="true" title="'.__('This will close this window, and any changes will be lost...').'">&nbsp;</span></button>';
$markup .= '<legend class="ore-title">'.$val['title'].'</legend>';
$markup .= '</div><!-- modal-header -->';
}
......
This diff is collapsed.
......@@ -18,18 +18,51 @@
*
*
*/
static $modals = array(
static $dialogs = array(
'visitor' =>
'title' => _('Welcome!'),
'markup' => '<div class="ore-menu-block ore-left"><p>'.
__('Don\'t have an account? We invite you to').'</p>'.
'<p style="text-align: center;">&nbsp;<button id="ore-register-button" class="button ore-button"
data-toggle="modal" data-target="#ore-modal">'.
__('Create account').'</button></p></div>'.
'<div class="ore-menu-block ore-right"><p>'.
__('Already have an account? Please').'</p>'.
'<p style="text-align: center;"><button id="ore-login-button" class="button ore-button" data-toggle="modal"
data-target="#ore-modal">'.
__('Log In').'</button></p></div>',
'authenticated' => array(
'markup' => '<p>'.
__('You are logged in as {{user.display_name}} ({{user.username}})').'</p>'.
'<button id="ore-edit-profile-button" class="button ore-button" data-toggle="modal"
data-target="#ore-modal">'.
__('Edit Profile').
'</button>&nbsp;<button id="ore-update-password-button" class="button ore-button">'.
__('Update Password').
'</button>&nbsp;&nbsp;&nbsp;<button id="ore-log-out-button" class="button ore-button">'.
__('Log Out').'</button>',
'enrolled' => array('cat' => 'leave', 'label' => __('Leave {{user.course.course_tag}}'),
'extra' => '<span class="ore-extra">'.
__('Add your <a target="_blank" title="Opens the Blog Feed Finder in a new tab or window!" href="/blog-feed-finder">blog feed</a> for scanning!').
'</span>', 'course_text' => '<p>'.
__('You are <strong>enrolled</strong> in "{{user.course.course_title}}"').'</p>'
),
'not_enrolled' => array('cat' => 'enrol', 'label' => __('Enrol in {{user.course.course_tag}}'),
'course_text' => '<p>'.
__('You are <strong>not enrolled</strong> in "{{user.course.course_title}}"').'</p>'
)
),
'login' => array(
'title' => 'Log in to OERu Course site',
'title' => __('Log in to OERu Course site'),
'token' => 'login',
'auth' => false,
'markup' => '<div class="form-group">'.
'<label for="credential">Username or Email</label>'.
'<input type="text" class="form-control" id="credential" name="credential" placeholder="username or user@email" aria-describedby="helpCredential" value="{email}">'.
'<span id="helpCredential" class="help-block">Either is acceptable, because both uniquely identify you in this system.</span>'.
'<label for="credential">'.__('Username or Email').'</label>'.
'<input type="text" class="form-control" id="credential" name="credential" placeholder="'.__('username or user@email').'" aria-describedby="helpCredential" value="{email}">'.
'<span id="helpCredential" class="help-block">'.__('Either is acceptable, because both uniquely identify you in this system.').'</span>'.
'</div>'.
'<div class="form-group">'.
'<label for="password">Password</label>'.
'<label for="password">'.__('Password').'</label>'.
'<input type="password" class="form-control" id="password" name="password" aria-describedby="helpPassword">'.
'<span id="helpPassword" class="help-block">Make sure no one is watching as you type this.<br/><br/>Problems? You can do a <span id="ore-password-reset-auxillary-button" class="link ore-button">Password Reset</span><br/><br/>(The OERu encourages you to use "password manager" software to store your passwords and help you create a strong and unique one for each website!)</span>'.
'</div>',
......
<?php
$validation_messages = array(
'register' => array(
'first_name' => array(
'required' => __('We require you specify your first or given name.')
),
'last_name' => array(
'required' => __('We require you specify your last or family name.')
),
'username' => array(
'required' => __('You must enter a username. It must be at least {{ore_data.un_min}} characters long.')
),
'display_name' => array(
'required' => __('You must supply a display name - it can be a nickname - this will be shown publicly alongside any of your posts. Your Display Name must be at least {{ore_data.dn_min}} characters long.')
),
'password' => array(
'required' => __('You must enter a password'),
'minlength' => __('Your password must be at least {{ore_data.pw_min}} characters long.')
),
'confirm_password' => array(
'required' => __('You must enter the same password again to confirm it'),
'minlength' => __('Your password must be at least {{ore_data.pw_min}} characters long.'),
'equalTo' => __('Your confirmation password is different from your first password. They must be the same. Please try re-entering one or both.')
),
'email' => array(
'required' => __('You must enter a valid email'),
'unique' => __('Each user email must be unique. No two accounts can share the same email address.')
),
'country' => array(
'value_not_default' => __('Your confirmation is different from your password. They must be the same. Please try re-entering one or both.')
),
),
'edit_profile' => array(
'first_name' => array(
'required' => __('We require you specify your first or given name.')
),
'last_name' => array(
'required' => __('We require you specify your last or family name.')
),
'display_name' => array(
'required' => __('You must supply a display name - it can be a nickname - this will be shown publicly alongside any of your posts. Your Display Name must be at least {{ore_data.dn_min}} characters long.')
),
'email' => array(
'required' => __('You must enter a valid email'),
'unique' => __('Each user email must be unique. No two accounts can share the same email address.')
),
'country' => array(
'value_not_default' => __('Your confirmation is different from your password. They must be the same. Please try re-entering one or both.')
),
),
'update_password' => array(
'current_password' => array(
'required' => __("You must enter your current password - this is a security precaution. If you don't know it, please do a ").
"<button id='ore-password-reset-auxillary-button' class='link ore-button'>".__('Password Reset').'</button>'.__(' instead.'),
),
'new_password' => array(
'required' => __('You must enter a password'),
'minlength' => __('Your password must be at least {{ore_data.pw_min}} characters long.')
),
'confirm_password' => array(
'required' => __('You must enter the same password again to confirm it'),
'minlength' => __('Your password must be at least {{ore_data.pw_min}} characters long.'),
'equalTo' => __('Your confirmation password is different from your first password. They must be the same. Please try re-entering one or both.')
),
),
);
This diff is collapsed.
# Copyright (C) 2020 Dave Lane
# This file is distributed under the same license as the OERu Register Enrol plugin.
msgid ""
msgstr ""
"Project-Id-Version: OERu Register Enrol 1.1.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/register-enrol\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2020-10-05T13:58:46+13:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.4.0\n"
"X-Domain: register-enrol\n"
#. Plugin Name of the plugin
msgid "OERu Register Enrol"
msgstr ""
#. Plugin URI of the plugin
msgid "https://github.com/oeru/register-enrol"
msgstr ""
#. Description of the plugin
msgid "Provides a widget that helps a user figure out the valid URL for"
msgstr ""
#. Author of the plugin
msgid "Dave Lane"
msgstr ""
#. Author URI of the plugin
msgid "https://oeru.org, http://WikiEducator.org/User:Davelane"
msgstr ""
......@@ -5,10 +5,12 @@
/*
Plugin Name: OERu Register Enrol
Plugin URI: https://github.com/oeru/register-enrol
Description: Provides a widget that helps a user figure out the valid URL for
their personal course blog feed. Parts are adapted from Login with Ajax by
Markus Sykes - http://wordpress.org/extend/plugins/login-with-ajax/
Version: 1.1.0
Description: Provides a flexible, user-friendly (accessible, localisable,
providing good feedback) mobile-friendly interface for creating (registering)
new user accounts, logging in (including password recovery), and
enrolling/unenrolling in/from OERu courses (https://oeru.org/courses).
Version: 2.0.0
Text Domain: ore
Author: Dave Lane
Author URI: https://oeru.org, http://WikiEducator.org/User:Davelane
License: GPLv3 or later
......@@ -32,9 +34,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
define( 'ORE_VERSION', '1.1.0' );
define( 'ORE_VERSION', '2.0.0' );
// plugin computer name
define('ORE_NAME', 'ORE');
// text Domain
define('ORE_TEXT_DOMAIN', 'ore');
// current version
// the path to this file
define('ORE_FILE', __FILE__);
......@@ -84,10 +88,6 @@ require ORE_PATH . 'includes/ore_app.php';
if ( function_exists( 'add_action' ) ) {
// this starts everything up!
add_action('plugins_loaded', array(OREMain::get_instance(), 'init'));
/*if (is_admin()) {
include_once(ORE_PATH.'includes/ore_admin.php');
add_action('plugins_loaded', array(OREAdmin::get_instance(), 'init'));
}*/
} else {
echo 'This only works as a WordPress plugin.';
exit;
......
Markdown is supported
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