This commit is contained in:
Paul Charsley
2012-08-21 14:39:26 +12:00
2500 changed files with 32654 additions and 82857 deletions
+17 -16
View File
@@ -71,22 +71,23 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
$ADMIN->add('appearance', $temp);
// blog
$temp = new admin_settingpage('blog', new lang_string('blog','blog'));
$temp->add(new admin_setting_configcheckbox('useblogassociations', new lang_string('useblogassociations', 'blog'), new lang_string('configuseblogassociations','blog'), 1));
$temp->add(new admin_setting_bloglevel('bloglevel', new lang_string('bloglevel', 'admin'), new lang_string('configbloglevel', 'admin'), 4, array(BLOG_GLOBAL_LEVEL => new lang_string('worldblogs','blog'),
BLOG_SITE_LEVEL => new lang_string('siteblogs','blog'),
BLOG_USER_LEVEL => new lang_string('personalblogs','blog'),
0 => new lang_string('disableblogs','blog'))));
$temp->add(new admin_setting_configcheckbox('useexternalblogs', new lang_string('useexternalblogs', 'blog'), new lang_string('configuseexternalblogs','blog'), 1));
$temp->add(new admin_setting_configselect('externalblogcrontime', new lang_string('externalblogcrontime', 'blog'), new lang_string('configexternalblogcrontime', 'blog'), 86400,
array(43200 => new lang_string('numhours', '', 12),
86400 => new lang_string('numhours', '', 24),
172800 => new lang_string('numdays', '', 2),
604800 => new lang_string('numdays', '', 7))));
$temp->add(new admin_setting_configtext('maxexternalblogsperuser', new lang_string('maxexternalblogsperuser','blog'), new lang_string('configmaxexternalblogsperuser', 'blog'), 1));
$temp->add(new admin_setting_configcheckbox('blogusecomments', new lang_string('enablecomments', 'admin'), new lang_string('configenablecomments', 'admin'), 1));
$temp->add(new admin_setting_configcheckbox('blogshowcommentscount', new lang_string('showcommentscount', 'admin'), new lang_string('configshowcommentscount', 'admin'), 1));
$ADMIN->add('appearance', $temp);
if (!empty($CFG->enableblogs)) {
$temp = new admin_settingpage('blog', new lang_string('blog','blog'));
$temp->add(new admin_setting_configcheckbox('useblogassociations', new lang_string('useblogassociations', 'blog'), new lang_string('configuseblogassociations','blog'), 1));
$temp->add(new admin_setting_bloglevel('bloglevel', new lang_string('bloglevel', 'admin'), new lang_string('configbloglevel', 'admin'), 4, array(BLOG_GLOBAL_LEVEL => new lang_string('worldblogs','blog'),
BLOG_SITE_LEVEL => new lang_string('siteblogs','blog'),
BLOG_USER_LEVEL => new lang_string('personalblogs','blog'))));
$temp->add(new admin_setting_configcheckbox('useexternalblogs', new lang_string('useexternalblogs', 'blog'), new lang_string('configuseexternalblogs','blog'), 1));
$temp->add(new admin_setting_configselect('externalblogcrontime', new lang_string('externalblogcrontime', 'blog'), new lang_string('configexternalblogcrontime', 'blog'), 86400,
array(43200 => new lang_string('numhours', '', 12),
86400 => new lang_string('numhours', '', 24),
172800 => new lang_string('numdays', '', 2),
604800 => new lang_string('numdays', '', 7))));
$temp->add(new admin_setting_configtext('maxexternalblogsperuser', new lang_string('maxexternalblogsperuser','blog'), new lang_string('configmaxexternalblogsperuser', 'blog'), 1));
$temp->add(new admin_setting_configcheckbox('blogusecomments', new lang_string('enablecomments', 'admin'), new lang_string('configenablecomments', 'admin'), 1));
$temp->add(new admin_setting_configcheckbox('blogshowcommentscount', new lang_string('showcommentscount', 'admin'), new lang_string('configshowcommentscount', 'admin'), 1));
$ADMIN->add('appearance', $temp);
}
// Navigation settings
$temp = new admin_settingpage('navigation', new lang_string('navigation'));
+1 -5
View File
@@ -26,11 +26,7 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
$optionalsubsystems->add(new admin_setting_configcheckbox('enablerssfeeds', new lang_string('enablerssfeeds', 'admin'), new lang_string('configenablerssfeeds', 'admin'), 0));
$optionalsubsystems->add(new admin_setting_bloglevel('bloglevel', new lang_string('bloglevel', 'admin'),
new lang_string('configbloglevel', 'admin'), 4, array(5 => new lang_string('worldblogs','blog'),
4 => new lang_string('siteblogs','blog'),
1 => new lang_string('personalblogs','blog'),
0 => new lang_string('disableblogs','blog'))));
$optionalsubsystems->add(new admin_setting_configcheckbox('enableblogs', new lang_string('enableblogs', 'admin'), new lang_string('configenableblogs', 'admin'), 1));
$options = array('off'=>new lang_string('off', 'mnet'), 'strict'=>new lang_string('on', 'mnet'));
$optionalsubsystems->add(new admin_setting_configselect('mnet_dispatcher_mode', new lang_string('net', 'mnet'), new lang_string('configmnet', 'mnet'), 'off', $options));
-174
View File
@@ -1,174 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Create "blog" forums in each course and copy blog entries from these courses' participants in these forums
*
* @package tool
* @subpackage bloglevelupgrade
* @copyright 2009 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_OUTPUT_BUFFERING', true);
require('../../../config.php');
require_once($CFG->dirroot.'/course/lib.php');
require_once($CFG->dirroot.'/blog/lib.php');
require_once($CFG->dirroot.'/mod/forum/lib.php');
require_once($CFG->libdir.'/adminlib.php');
admin_externalpage_setup('toolbloglevelupgrade');
$PAGE->set_pagelayout('maintenance');
$go = optional_param('go', 0, PARAM_BOOL);
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('pluginname', 'tool_bloglevelupgrade'));
$strbloglevelupgrade = get_string('bloglevelupgradeinfo', 'tool_bloglevelupgrade');
if (!$go or !data_submitted() or !confirm_sesskey()) { /// Print a form
$optionsyes = array('go'=>1, 'sesskey'=>sesskey());
echo $OUTPUT->confirm($strbloglevelupgrade, new moodle_url('/admin/tool/bloglevelupgrade/index.php', $optionsyes), new moodle_url('/admin/index.php'));
echo $OUTPUT->footer();
die;
}
echo $OUTPUT->box_start();
/// Turn off time limits, sometimes upgrades can be slow.
set_time_limit(0);
$i = 0;
// If $CFG->bloglevel is set to BLOG_GROUP_LEVEL or BLOG_COURSE_LEVEL, create a new "blog" forum in each course
// whose enrolled students have written blog entries, copy these entries in that forum and switch off blogs at site level
if ($CFG->bloglevel == BLOG_COURSE_LEVEL || $CFG->bloglevel == BLOG_GROUP_LEVEL) {
$pbar = new progress_bar('toolbloglevelupgrade', 500, true);
$bloggers = $DB->get_records_sql("SELECT userid FROM {post} WHERE module = 'blog' GROUP BY userid");
require_once($CFG->dirroot.'/mod/forum/lib.php');
$a = new stdClass();
$a->userscount = 0;
$a->blogcount = 0;
foreach ($bloggers as $blogger) {
$courses = enrol_get_users_courses($blogger->userid, true, 'groupmode,groupmodeforce');
$blogentries = $DB->get_records('post', array('module' => 'blog', 'userid' => $blogger->userid));
foreach ($courses as $course) {
$forum = forum_get_course_forum($course->id, 'blog');
$cm = get_coursemodule_from_instance('forum', $forum->id);
if ($CFG->bloglevel == BLOG_GROUP_LEVEL && $course->groupmode != NOGROUPS) {
// Unless the course is set to separate groups forced, force the forum to Separate groups
if (!($course->groupmode == SEPARATEGROUPS && $course->groupmodeforce)) {
$cm->groupmode = SEPARATEGROUPS;
$DB->update_record('course_modules', $cm);
}
$groups = groups_get_user_groups($course->id, $blogger->userid);
foreach ($groups[0] as $groupid) { // [0] is for all groupings combined
$a->blogcount += bloglevelupgrade_entries($blogentries, $forum, $cm, $groupid);
}
} else {
$a->blogcount += bloglevelupgrade_entries($blogentries, $forum, $cm);
}
}
$a->userscount = $i . '/' . count($bloggers);
$pbar->update($i, count($bloggers), get_string('bloglevelupgradeprogress', 'tool_bloglevelupgrade', $a));
$i++;
}
}
function bloglevelupgrade_entries($blogentries, $forum, $cm, $groupid=-1) {
$count = 0;
$forumcontext = context_module::instance($cm->id);
$sitecontext = context_system::instance();
foreach ($blogentries as $blogentry) {
$discussion = new stdClass();
$discussion->course = $forum->course;
$discussion->forum = $forum->id;
$discussion->name = $blogentry->subject;
$discussion->assessed = $forum->assessed;
$discussion->message = $blogentry->summary;
$discussion->messageformat = $blogentry->summaryformat;
$discussion->messagetrust = 0;
$discussion->attachments = 0;
$discussion->mailnow = false;
$discussion->timemodified = $blogentry->created;
$discussion->itemid = null;
$discussion->groupid = $groupid;
$message = '';
$discussionid = forum_add_discussion($discussion, null, $message, $blogentry->userid);
// Copy file attachment records
$fs = get_file_storage();
$files = $fs->get_area_files($sitecontext->id, 'blog', 'attachment', $blogentry->id);
if (!empty($files)) {
foreach ($files as $storedfile) {
$newfile = new stdClass();
$newfile->component = 'mod_forum';
$newfile->filearea = 'attachment';
$newfile->itemid = $discussion->firstpost;
$newfile->contextid = $forumcontext->id;
$fs->create_file_from_storedfile($newfile, $storedfile->get_id());
}
}
$files = $fs->get_area_files($sitecontext->id, 'blog', 'post', $blogentry->id);
if (!empty($files)) {
foreach ($files as $storedfile) {
$newfile = new stdClass();
$newfile->component = 'mod_forum';
$newfile->filearea = 'post';
$newfile->itemid = $discussion->firstpost;
$newfile->contextid = $forumcontext->id;
$fs->create_file_from_storedfile($newfile, $storedfile->get_id());
}
}
$count++;
}
return $count;
}
// END OF LOOP
// set conversion flag - switches to new plugin automatically
unset_config('tool_bloglevelupgrade_pending');
// Finally switch bloglevel to 0 (disabled)
set_config('bloglevel', 0);
echo $OUTPUT->box_end();
/// Rebuild course cache which might be incorrect now
echo $OUTPUT->notification('Rebuilding course cache...', 'notifysuccess');
rebuild_course_cache();
echo $OUTPUT->notification('...finished', 'notifysuccess');
echo $OUTPUT->continue_button(new moodle_url('/admin/index.php'));
echo $OUTPUT->footer();
die;
@@ -1,33 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'tool_bloglevelupgrade', language 'en', branch 'MOODLE_22_STABLE'
*
* @package tool
* @subpackage bloglevelupgrade
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['bloglevelupgradedescription'] = '<p>This site has recently been upgraded to Moodle 2.0.</p>
<p>Blog visibility was simplified in 2.0, but your site still uses one of the old visibility types. </p>
<p>To preserve the course-based or group-based visibility of the blog entries on your site, you need to run the following upgrade script, which will create a special "blog" type forum in each course whose enrolled users have posted blog entries, and will copy these blog entries in this special forum. </p>
<p>Blogs will then be entirely switched off at the site level. No blog entries will be deleted in the process.</p>
<p>You can run the script by visiting <a href="{$a->fixurl}">the blog level upgrade page</a>.</p>';
$string['bloglevelupgradeinfo'] = 'Blog visibility was simplified in 2.0, but your site still uses one of the old visibility types. To preserve the course-based or group-based visibility of the blog entries on your site, the following upgrade script will create a special "blog" type forum in each course whose enrolled users have posted blog entries, and will copy these blog entries in this special forum. Blogs will then be entirely switched off at the site level. No blog entries will be deleted in the process.';
$string['bloglevelupgradeprogress'] = 'Conversion progress: {$a->userscount} users reviewed, {$a->blogcount} entries converted.';
$string['pluginname'] = 'Blog visibility upgrade';
@@ -508,7 +508,18 @@ abstract class backup_cron_automated_helper {
if (!empty($dir) && ($storage == 1 || $storage == 2)) {
// Calculate backup filename regex, ignoring the date/time/info parts that can be
// variable, depending of languages, formats and automated backup settings
$filename = $backupword . '-' . backup::FORMAT_MOODLE . '-' . backup::TYPE_1COURSE . '-' .$course->id . '-';
// MDL-33531: use different filenames depending on backup_shortname option
if ( !empty($config->backup_shortname) ) {
$context = get_context_instance(CONTEXT_COURSE, $course->id);
$courseref = format_string($course->shortname, true, array('context' => $context));
$courseref = str_replace(' ', '_', $courseref);
$courseref = textlib::strtolower(trim(clean_filename($courseref), '_'));
} else {
$courseref = $course->id;
}
$filename = $backupword . '-' . backup::FORMAT_MOODLE . '-' . backup::TYPE_1COURSE . '-' .$courseref . '-';
$regex = '#^'.preg_quote($filename, '#').'.*\.mbz$#';
// Store all the matching files into fullpath => timemodified array
-168
View File
@@ -1,168 +0,0 @@
// backup files tree
// Author: Dongsheng Cai <[email protected]>
M.core_backup_files_tree = {
y3: null,
api: M.cfg.wwwroot+'/files/filebrowser_ajax.php',
request: function(url, node, cb) {
var api = this.api + '?action=getfiletree';
var params = [];
params['contextid'] = this.get_param(url, 'contextid', -1);
params['component'] = this.get_param(url, 'component', null);
params['filearea'] = this.get_param(url, 'filearea', null);
params['itemid'] = this.get_param(url, 'itemid', -1);
params['filepath'] = this.get_param(url, 'filepath', null);
params['filename'] = this.get_param(url, 'filename', null);
if (params['filearea'] == 'backup' && params['component'] == 'user') {
// XXX: the id in params['contextid'] is current context
// request file list, so should be user context
params['contextid'] = this.usercontextid;
}
var scope = this;
params['sesskey']=M.cfg.sesskey;
var cfg = {
method: 'POST',
on: {
complete: function(id,o,p) {
try {
var data = this.y3.JSON.parse(o.responseText);
} catch(e) {
alert(e.toString());
return;
}
if (data && data.length==0) {
node.isLeaf = true;
} else {
for (i in data) {
if (data[i].isdir) {
var info = {label: data[i].filename, href: data[i].url};
var n = new YAHOO.widget.TextNode(info, node, false);
YAHOO.util.Event.addListener(n.labelElId, "click", function(e) {
YAHOO.util.Event.preventDefault(e);
});
n.isLeaf = false;
} else {
var params = data[i].params;
if (params['filearea'] == 'backup' && params['component'] == 'user') {
// XXX: display the restore link, so should be context id
params['contextid'] = scope.currentcontextid;
}
params.action = 'choosebackupfile';
var restoreurl = M.cfg.wwwroot+'/backup/restorefile.php?'+build_querystring(params);
var info = {label: data[i].filename, 'href': data[i].url, 'restoreurl': restoreurl};
params['filename'] = data[i].filename;
var n = new YAHOO.widget.RestoreNode(info, node, false);
n.isLeaf = true;
}
}
}
cb();
}
},
arguments: {
scope: scope
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
},
data: build_querystring(params),
context: this
};
this.y3.io(api, cfg);
},
init : function(Y, options){
var htmlid = options.htmlid;
this.usercontextid = options.usercontextid;
this.currentcontextid = options.currentcontextid;
var tree = new YAHOO.widget.TreeView(htmlid);
tree.setDynamicLoad(this.dynload);
var root = tree.getRoot();
var children = root.children;
tree.subscribe("clickEvent", function(e) {
if(!e.node.isLeaf){
e.node.toggle();
}
});
for (i in children) {
var node = children[i];
if (node.className == 'file-tree-folder') {
node.isLeaf = false;
// prevent link
YAHOO.util.Event.addListener(node.labelElId, "click", function(e) {
YAHOO.util.Event.preventDefault(e);
});
} else {
node.isLeaf = true;
}
}
tree.render();
this.y3 = Y;
},
dynload: function(node, oncompletecb) {
M.core_backup_files_tree.request(node.href, node, oncompletecb);
},
get_param: function(url, name, val) {
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec(url);
if( results == null ) {
return val;
} else {
return unescape(results[1]);
}
}
}
YAHOO.widget.RestoreNode = function(oData, oParent, expanded) {
if (oData) {
if (YAHOO.lang.isString(oData)) {
oData = { label: oData };
}
this.init(oData, oParent, expanded);
this.setUpLabel(oData);
}
};
YAHOO.extend(YAHOO.widget.RestoreNode, YAHOO.widget.TextNode, {
labelStyle: "ygtvlabel",
labelElId: null,
label: null,
title: null,
href: null,
target: "_blank",
_type: "RestoreNode",
setUpLabel: function(oData) {
if (YAHOO.lang.isString(oData)) {
oData = {
label: oData
};
} else {
if (oData.style) {
this.labelStyle = oData.style;
}
}
this.label = oData.label;
this.restoreurl = oData.restoreurl;
this.labelElId = "ygtvlabelel" + this.index;
},
getContentHtml: function() {
var sb = [];
sb[sb.length] = '<a';
sb[sb.length] = ' id="' + this.labelElId + '"';
sb[sb.length] = ' class="' + this.labelStyle + '"';
if (this.href) {
sb[sb.length] = ' href="' + this.href + '"';
sb[sb.length] = ' target="' + this.target + '"';
}
if (this.title) {
sb[sb.length] = ' title="' + this.title + '"';
}
sb[sb.length] = ' >';
sb[sb.length] = this.label;
sb[sb.length] = '</a>';
sb[sb.length] = ' <a href="'+this.restoreurl+'">'+M.str.moodle.restore+'</a>';
return sb.join("");
}
});
+1 -1
View File
@@ -58,7 +58,7 @@ class block_blog_menu extends block_base {
return $this->content;
}
if (empty($CFG->bloglevel)) {
if (empty($CFG->enableblogs)) {
$this->content = new stdClass();
$this->content->text = '';
if ($this->page->user_is_editing()) {
+1 -1
View File
@@ -52,7 +52,7 @@ class block_blog_recent extends block_base {
}
// verify blog is enabled
if (empty($CFG->bloglevel)) {
if (empty($CFG->enableblogs)) {
$this->content = new stdClass();
$this->content->text = '';
if ($this->page->user_is_editing()) {
+1 -1
View File
@@ -125,7 +125,7 @@ function block_course_overview_get_sorted_courses() {
$limit = block_course_overview_get_max_user_courses();
$courses = enrol_get_my_courses('id, shortname, fullname, modinfo');
$courses = enrol_get_my_courses('id, shortname, fullname, modinfo, sectioncache');
$site = get_site();
if (array_key_exists($site->id,$courses)) {
+1 -1
View File
@@ -25,7 +25,7 @@ M.block_private_files = {};
M.block_private_files.init_tree = function(Y, expand_all, htmlid) {
Y.use('yui2-treeview', function(Y) {
var tree = new YAHOO.widget.TreeView(htmlid);
var tree = new Y.YUI2.widget.TreeView(htmlid);
tree.subscribe("clickEvent", function(node, event) {
// we want normal clicking which redirects to url
+9 -2
View File
@@ -69,7 +69,7 @@ if ($action == 'edit') {
$id = required_param('entryid', PARAM_INT);
}
if (empty($CFG->bloglevel)) {
if (empty($CFG->enableblogs)) {
print_error('blogdisable', 'blog');
}
@@ -105,6 +105,9 @@ if ($id) {
}
$returnurl->param('userid', $userid);
// Blog renderer.
$output = $PAGE->get_renderer('blog');
$strblogs = get_string('blogs','blog');
if ($action === 'delete'){
@@ -125,7 +128,11 @@ if ($action === 'delete'){
$PAGE->set_title("$SITE->shortname: $strblogs");
$PAGE->set_heading($SITE->fullname);
echo $OUTPUT->header();
$entry->print_html();
// Output the entry.
$entry->prepare_render();
echo $output->render($entry);
echo '<br />';
echo $OUTPUT->confirm(get_string('blogdeleteconfirm', 'blog'), new moodle_url('edit.php', $optionsyes),new moodle_url( 'index.php', $optionsno));
echo $OUTPUT->footer();
+19 -12
View File
@@ -71,24 +71,28 @@ class blog_edit_form extends moodleform {
$allmodnames = array();
if (!empty($CFG->useblogassociations)) {
if ((!empty($entry->courseassoc) || (!empty($courseid) && empty($modid))) && has_capability('moodle/blog:associatecourse', $sitecontext)) {
if ((!empty($entry->courseassoc) || (!empty($courseid) && empty($modid)))) {
if (!empty($courseid)) {
$course = $DB->get_record('course', array('id' => $courseid));
$mform->addElement('header', 'assochdr', get_string('associations', 'blog'));
$context = context_course::instance($courseid);
$a = new stdClass();
$a->coursename = format_string($course->fullname, true, array('context' => $context));
$contextid = $context->id;
} else {
$context = context::instance_by_id($entry->courseassoc);
$sql = 'SELECT fullname FROM {course} cr LEFT JOIN {context} ct ON ct.instanceid = cr.id WHERE ct.id = ?';
$a = new stdClass();
$a->coursename = $DB->get_field_sql($sql, array($entry->courseassoc));
$contextid = $entry->courseassoc;
}
$mform->addElement('advcheckbox', 'courseassoc', get_string('associatewithcourse', 'blog', $a), null, null, array(0, $contextid));
$mform->setDefault('courseassoc', $contextid);
} else if ((!empty($entry->modassoc) || !empty($modid)) && has_capability('moodle/blog:associatemodule', $sitecontext)) {
if (has_capability('moodle/blog:associatecourse', $context)) {
$mform->addElement('header', 'assochdr', get_string('associations', 'blog'));
$mform->addElement('advcheckbox', 'courseassoc', get_string('associatewithcourse', 'blog', $a), null, null, array(0, $contextid));
$mform->setDefault('courseassoc', $contextid);
}
} else if ((!empty($entry->modassoc) || !empty($modid))) {
if (!empty($modid)) {
$mod = get_coursemodule_from_id(false, $modid);
$a = new stdClass();
@@ -104,9 +108,11 @@ class blog_edit_form extends moodleform {
$modid = $context->instanceid;
}
$mform->addElement('header', 'assochdr', get_string('associations', 'blog'));
$mform->addElement('advcheckbox', 'modassoc', get_string('associatewithmodule', 'blog', $a), null, null, array(0, $context->id));
$mform->setDefault('modassoc', $context->id);
if (has_capability('moodle/blog:associatemodule', $context)) {
$mform->addElement('header', 'assochdr', get_string('associations', 'blog'));
$mform->addElement('advcheckbox', 'modassoc', get_string('associatewithmodule', 'blog', $a), null, null, array(0, $context->id));
$mform->setDefault('modassoc', $context->id);
}
}
}
@@ -132,13 +138,13 @@ class blog_edit_form extends moodleform {
global $CFG, $DB, $USER;
$errors = array();
$sitecontext = context_system::instance();
// validate course association
if (!empty($data['courseassoc']) && has_capability('moodle/blog:associatecourse', $sitecontext)) {
if (!empty($data['courseassoc'])) {
$coursecontext = context::instance_by_id($data['courseassoc'], IGNORE_MISSING);
if ($coursecontext and $coursecontext->contextlevel == CONTEXT_COURSE) {
$canassociatecourse = has_capability('moodle/blog:associatecourse', $coursecontext);
if ($coursecontext->contextlevel == CONTEXT_COURSE && $canassociatecourse) {
if (!is_enrolled($coursecontext) and !is_viewing($coursecontext)) {
$errors['courseassoc'] = get_string('studentnotallowed', '', fullname($USER, true));
}
@@ -152,7 +158,8 @@ class blog_edit_form extends moodleform {
$modcontextid = $data['modassoc'];
$modcontext = context::instance_by_id($modcontextid, IGNORE_MISSING);
if ($modcontext and $modcontext->contextlevel == CONTEXT_MODULE) {
$canassociatemodule = has_capability('moodle/blog:associatecourse', $modcontext);
if ($modcontext->contextlevel == CONTEXT_MODULE && $canassociatemodule) {
// get context of the mod's course
$coursecontext = $modcontext->get_course_context(true);
+1 -1
View File
@@ -34,7 +34,7 @@ foreach ($url_params as $var => $val) {
}
$PAGE->set_url('/blog/index.php', $url_params);
if (empty($CFG->bloglevel)) {
if (empty($CFG->enableblogs)) {
print_error('blogdisable', 'blog');
}
+10 -9
View File
@@ -64,7 +64,7 @@ function blog_user_can_edit_entry($blogentry) {
function blog_user_can_view_user_entry($targetuserid, $blogentry=null) {
global $CFG, $USER, $DB;
if (empty($CFG->bloglevel)) {
if (empty($CFG->enableblogs)) {
return false; // blog system disabled
}
@@ -349,8 +349,7 @@ function blog_get_context_url($context=null) {
*/
function blog_is_enabled_for_user() {
global $CFG;
//return (!empty($CFG->bloglevel) && $CFG->bloglevel <= BLOG_GLOBAL_LEVEL && isloggedin() && !isguestuser());
return (!empty($CFG->bloglevel) && (isloggedin() || ($CFG->bloglevel == BLOG_GLOBAL_LEVEL)));
return (!empty($CFG->enableblogs) && (isloggedin() || ($CFG->bloglevel == BLOG_GLOBAL_LEVEL)));
}
/**
@@ -406,7 +405,7 @@ function blog_get_all_options(moodle_page $page, stdClass $userid = null) {
}
// If blog level is global then display a link to view all site entries
if (!empty($CFG->bloglevel) && $CFG->bloglevel >= BLOG_GLOBAL_LEVEL && has_capability('moodle/blog:view', context_system::instance())) {
if (!empty($CFG->enableblogs) && $CFG->bloglevel >= BLOG_GLOBAL_LEVEL && has_capability('moodle/blog:view', context_system::instance())) {
$options[CONTEXT_SYSTEM] = array('viewsite' => array(
'string' => get_string('viewsiteentries', 'blog'),
'link' => new moodle_url('/blog/index.php')
@@ -511,7 +510,8 @@ function blog_get_options_for_course(stdClass $course, stdClass $user=null) {
// Check that the user can associate with the course
$sitecontext = context_system::instance();
if (!has_capability('moodle/blog:associatecourse', $sitecontext)) {
$coursecontext = context_course::instance($course->id);
if (!has_capability('moodle/blog:associatecourse', $coursecontext)) {
return $options;
}
// Generate the cache key
@@ -526,7 +526,6 @@ function blog_get_options_for_course(stdClass $course, stdClass $user=null) {
return $courseoptions[$key];
}
$coursecontext = context_course::instance($course->id, IGNORE_MISSING);
$canparticipate = (is_enrolled($coursecontext) or is_viewing($coursecontext));
if (has_capability('moodle/blog:view', $coursecontext)) {
@@ -587,8 +586,9 @@ function blog_get_options_for_module($module, $user=null) {
}
// Check the user can associate with the module
$modcontext = context_module::instance($module->id);
$sitecontext = context_system::instance();
if (!has_capability('moodle/blog:associatemodule', $sitecontext)) {
if (!has_capability('moodle/blog:associatemodule', $modcontext)) {
return $options;
}
@@ -604,7 +604,6 @@ function blog_get_options_for_module($module, $user=null) {
return $moduleoptions[$module->id];
}
$modcontext = context_module::instance($module->id, IGNORE_MISSING);
$canparticipate = (is_enrolled($modcontext) or is_viewing($modcontext));
if (has_capability('moodle/blog:view', $modcontext)) {
@@ -743,7 +742,9 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$PAGE->set_pagelayout('standard');
if (!empty($modid) && $CFG->useblogassociations && has_capability('moodle/blog:associatemodule', $sitecontext)) { // modid always overrides courseid, so the $course object may be reset here
// modid always overrides courseid, so the $course object may be reset here
if (!empty($modid) && $CFG->useblogassociations) {
$headers['filters']['module'] = $modid;
// A groupid param may conflict with this coursemod's courseid. Ignore groupid in that case
$courseid = $DB->get_field('course_modules', 'course', array('id'=>$modid));
+137 -277
View File
@@ -39,7 +39,7 @@ require_once($CFG->libdir . '/filelib.php');
* @copyright 2009 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class blog_entry {
class blog_entry implements renderable {
// Public Database fields
public $id;
public $userid;
@@ -66,6 +66,9 @@ class blog_entry {
public $form;
public $tags = array();
/** @var StdClass Data needed to render the entry */
public $renderable;
// Methods
/**
* Constructor. If given an id, will fetch the corresponding record from the DB.
@@ -89,242 +92,126 @@ class blog_entry {
$this->form = $form;
}
/**
* Prints or returns the HTML for this blog entry.
*
* @param bool $return
* @return string
* Gets the required data to print the entry
*/
public function print_html($return=false) {
public function prepare_render() {
global $USER, $CFG, $COURSE, $DB, $OUTPUT, $PAGE;
global $DB, $CFG, $PAGE;
$user = $DB->get_record('user', array('id'=>$this->userid));
$cmttext = '';
if (!empty($CFG->usecomments) and $CFG->blogusecomments) {
$this->renderable = new StdClass();
$this->renderable->user = $DB->get_record('user', array('id'=>$this->userid));
// Entry comments.
if (!empty($CFG->usecomments) and $CFG->blogusecomments) {
require_once($CFG->dirroot . '/comment/lib.php');
// Comments
$cmt = new stdClass();
$cmt->context = context_user::instance($user->id);
$cmt->courseid = $PAGE->course->id;
$cmt->area = 'format_blog';
$cmt->itemid = $this->id;
$cmt->showcount = $CFG->blogshowcommentscount;
$cmt->component = 'blog';
$comment = new comment($cmt);
$cmttext = $comment->output(true);
$cmt = new stdClass();
$cmt->context = context_user::instance($this->userid);
$cmt->courseid = $PAGE->course->id;
$cmt->area = 'format_blog';
$cmt->itemid = $this->id;
$cmt->showcount = $CFG->blogshowcommentscount;
$cmt->component = 'blog';
$this->renderable->comment = new comment($cmt);
}
$this->summary = file_rewrite_pluginfile_urls($this->summary, 'pluginfile.php', SYSCONTEXTID, 'blog', 'post', $this->id);
$this->summary = file_rewrite_pluginfile_urls($this->summary, 'pluginfile.php', SYSCONTEXTID, 'blog', 'post', $this->id);
$options = array('overflowdiv'=>true);
$template['body'] = format_text($this->summary, $this->summaryformat, $options);
$template['title'] = format_string($this->subject);
$template['userid'] = $user->id;
$template['author'] = fullname($user);
$template['created'] = userdate($this->created);
if ($this->created != $this->lastmodified) {
$template['lastmod'] = userdate($this->lastmodified);
// External blog link.
if ($this->uniquehash && $this->content) {
if ($externalblog = $DB->get_record('blog_external', array('id' => $this->content))) {
$urlparts = parse_url($externalblog->url);
$this->renderable->externalblogtext = get_string('retrievedfrom', 'blog') . get_string('labelsep', 'langconfig');
$this->renderable->externalblogtext .= html_writer::link($urlparts['scheme'] . '://'.$urlparts['host'], $externalblog->name);
}
}
$template['publishstate'] = $this->publishstate;
$stredit = get_string('edit');
$strdelete = get_string('delete');
// Check to see if the entry is unassociated with group/course level access
$unassociatedentry = false;
if (!empty($CFG->useblogassociations) && ($this->publishstate == 'group' || $this->publishstate == 'course')) {
if (!$DB->record_exists('blog_association', array('blogid' => $this->id))) {
$unassociatedentry = true;
}
}
// Start printing of the blog
$table = new html_table();
$table->cellspacing = 0;
$table->attributes['class'] = 'forumpost blog_entry blog'. ($unassociatedentry ? 'draft' : $template['publishstate']);
$table->attributes['id'] = 'b'.$this->id;
$table->width = '100%';
$picturecell = new html_table_cell();
$picturecell->attributes['class'] = 'picture left';
$picturecell->text = $OUTPUT->user_picture($user);
$table->head[] = $picturecell;
$topiccell = new html_table_cell();
$topiccell->attributes['class'] = 'topic starter';
$titlelink = html_writer::link(new moodle_url('/blog/index.php', array('entryid' => $this->id)), $template['title']);
$topiccell->text = $OUTPUT->container($titlelink, 'subject');
$topiccell->text .= $OUTPUT->container_start('author');
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', context_course::instance($PAGE->course->id)));
$by = new stdClass();
$by->name = html_writer::link(new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $PAGE->course->id)), $fullname);
$by->date = $template['created'];
$topiccell->text .= get_string('bynameondate', 'forum', $by);
$topiccell->text .= $OUTPUT->container_end();
if ($this->uniquehash && $this->content) {
if ($externalblog = $DB->get_record('blog_external', array('id' => $this->content))) {
$urlparts = parse_url($externalblog->url);
$topiccell->text .= $OUTPUT->container(get_string('retrievedfrom', 'blog').get_string('labelsep', 'langconfig').html_writer::link($urlparts['scheme'].'://'.$urlparts['host'], $externalblog->name), 'externalblog');
}
}
$topiccell->header = false;
$table->head[] = $topiccell;
// Actual content
$mainrow = new html_table_row();
$leftsidecell = new html_table_cell();
$leftsidecell->attributes['class'] = 'left side';
$mainrow->cells[] = $leftsidecell;
$contentcell = new html_table_cell();
$contentcell->attributes['class'] = 'content';
$attachedimages = $OUTPUT->container($this->print_attachments(), 'attachments');
// retrieve associations in case they're needed early
$blogassociations = $DB->get_records('blog_association', array('blogid' => $this->id));
// determine text for publish state
switch ($template['publishstate']) {
case 'draft':
$blogtype = get_string('publishtonoone', 'blog');
break;
case 'site':
$blogtype = get_string('publishtosite', 'blog');
break;
case 'public':
$blogtype = get_string('publishtoworld', 'blog');
break;
default:
$blogtype = '';
break;
}
$contentcell->text .= $OUTPUT->container($blogtype, 'audience');
$contentcell->text .= $template['body'];
$contentcell->text .= $attachedimages;
// Uniquehash is used as a link to an external blog
if (!empty($this->uniquehash)) {
$contentcell->text .= $OUTPUT->container_start('externalblog');
$contentcell->text .= html_writer::link($this->uniquehash, get_string('linktooriginalentry', 'blog'));
$contentcell->text .= $OUTPUT->container_end();
}
// Links to tags
$officialtags = tag_get_tags_csv('post', $this->id, TAG_RETURN_HTML, 'official');
$defaulttags = tag_get_tags_csv('post', $this->id, TAG_RETURN_HTML, 'default');
if (!empty($CFG->usetags) && ($officialtags || $defaulttags) ) {
$contentcell->text .= $OUTPUT->container_start('tags');
if ($officialtags) {
$contentcell->text .= get_string('tags', 'tag') .': '. $OUTPUT->container($officialtags, 'officialblogtags');
if ($defaulttags) {
$contentcell->text .= ', ';
// Retrieve associations
$this->renderable->unassociatedentry = false;
if (!empty($CFG->useblogassociations)) {
// Adding the entry associations data.
if ($associations = $associations = $DB->get_records('blog_association', array('blogid' => $this->id))) {
// Check to see if the entry is unassociated with group/course level access.
if ($this->publishstate == 'group' || $this->publishstate == 'course') {
$this->renderable->unassociatedentry = true;
}
}
$contentcell->text .= $defaulttags;
$contentcell->text .= $OUTPUT->container_end();
}
foreach ($associations as $key => $assocrec) {
// Add associations
if (!empty($CFG->useblogassociations) && $blogassociations) {
$contentcell->text .= $OUTPUT->container_start('tags');
$assocstr = '';
$hascourseassocs = false;
$assoctype = '';
// First find and show the associated course
foreach ($blogassociations as $assocrec) {
$context = context::instance_by_id($assocrec->contextid);
if ($context->contextlevel == CONTEXT_COURSE) {
$assocurl = new moodle_url('/course/view.php', array('id' => $context->instanceid));
$text = $DB->get_field('course', 'shortname', array('id' => $context->instanceid)); //TODO: performance!!!!
$assocstr .= $OUTPUT->action_icon($assocurl, new pix_icon('i/course', $text), null, array(), true);
$hascourseassocs = true;
$assoctype = get_string('course');
}
}
// Now show mod association
foreach ($blogassociations as $assocrec) {
$context = context::instance_by_id($assocrec->contextid);
if ($context->contextlevel == CONTEXT_MODULE) {
if ($hascourseassocs) {
$assocstr .= ', ';
$hascourseassocs = false;
if (!$context = context::instance_by_id($assocrec->contextid, IGNORE_MISSING)) {
unset($associations[$key]);
continue;
}
$modinfo = $DB->get_record('course_modules', array('id' => $context->instanceid));
$modname = $DB->get_field('modules', 'name', array('id' => $modinfo->module));
// The renderer will need the contextlevel of the association.
$associations[$key]->contextlevel = $context->contextlevel;
// Course associations.
if ($context->contextlevel == CONTEXT_COURSE) {
$instancename = $DB->get_field('course', 'shortname', array('id' => $context->instanceid)); //TODO: performance!!!!
$assocurl = new moodle_url('/mod/'.$modname.'/view.php', array('id' => $modinfo->id));
$text = $DB->get_field($modname, 'name', array('id' => $modinfo->instance)); //TODO: performance!!!!
$assocstr .= $OUTPUT->action_icon($assocurl, new pix_icon('icon', $text, $modname), null, array(), true);
$assocstr .= ', ';
$assoctype = get_string('modulename', $modname);
$associations[$key]->url = $assocurl = new moodle_url('/course/view.php', array('id' => $context->instanceid));
$associations[$key]->text = $instancename;
$associations[$key]->icon = new pix_icon('i/course', $associations[$key]->text);
}
// Mod associations.
if ($context->contextlevel == CONTEXT_MODULE) {
// Getting the activity type and the activity instance id
$sql = 'SELECT cm.instance, m.name FROM {course_modules} cm
JOIN {modules} m ON m.id = cm.module
WHERE cm.id = :cmid';
$modinfo = $DB->get_record_sql($sql, array('cmid' => $context->instanceid));
$instancename = $DB->get_field($modinfo->name, 'name', array('id' => $modinfo->instance)); //TODO: performance!!!!
$associations[$key]->type = get_string('modulename', $modinfo->name);
$associations[$key]->url = new moodle_url('/mod/' . $modinfo->name . '/view.php', array('id' => $context->instanceid));
$associations[$key]->text = $instancename;
$associations[$key]->icon = new pix_icon('icon', $associations[$key]->text, $modinfo->name);
}
}
}
$assocstr = substr($assocstr, 0, -2);
$contentcell->text .= get_string('associated', 'blog', $assoctype) . ': '. $assocstr;
$this->renderable->blogassociations = $associations;
}
$contentcell->text .= $OUTPUT->container_end();
}
// Entry attachments.
$this->renderable->attachments = $this->get_attachments();
if ($unassociatedentry) {
$contentcell->text .= $OUTPUT->container(get_string('associationunviewable', 'blog'), 'noticebox');
}
$this->renderable->usercanedit = blog_user_can_edit_entry($this);
}
/// Commands
$contentcell->text .= $OUTPUT->container_start('commands');
/**
* Gets the entry attachments list
* @return array List of blog_entry_attachment instances
*/
function get_attachments() {
if (blog_user_can_edit_entry($this)) {
if (empty($this->uniquehash)) {
//External blog entries should not be edited
$contentcell->text .= html_writer::link(new moodle_url('/blog/edit.php',
array('action' => 'edit', 'entryid' => $this->id)),
$stredit) . ' | ';
global $CFG;
require_once($CFG->libdir.'/filelib.php');
$syscontext = context_system::instance();
$fs = get_file_storage();
$files = $fs->get_area_files($syscontext->id, 'blog', 'attachment', $this->id);
// Adding a blog_entry_attachment for each non-directory file.
$attachments = array();
foreach ($files as $file) {
if ($file->is_directory()) {
continue;
}
$contentcell->text .= html_writer::link(new moodle_url('/blog/edit.php',
array('action' => 'delete', 'entryid' => $this->id)),
$strdelete) . ' | ';
}
$attachments[] = new blog_entry_attachment($file, $this->id);
}
$contentcell->text .= html_writer::link(new moodle_url('/blog/index.php', array('entryid' => $this->id)), get_string('permalink', 'blog'));
$contentcell->text .= $OUTPUT->container_end();
if (isset($template['lastmod']) ){
$contentcell->text .= '<div style="font-size: 55%;">';
$contentcell->text .= ' [ '.get_string('modified').': '.$template['lastmod'].' ]';
$contentcell->text .= '</div>';
}
//add comments under everything
$contentcell->text .= $cmttext;
$mainrow->cells[] = $contentcell;
$table->data = array($mainrow);
if ($return) {
return html_writer::table($table);
} else {
echo html_writer::table($table);
}
return $attachments;
}
/**
@@ -480,66 +367,6 @@ class blog_entry {
$fs->delete_area_files(SYSCONTEXTID, 'blog', 'post', $this->id);
}
/**
* if return=html, then return a html string.
* if return=text, then return a text-only string.
* otherwise, print HTML for non-images, and return image HTML
*
* @param bool $return Whether to return or print the generated code
* @return void
*/
public function print_attachments($return=false) {
global $CFG, $OUTPUT;
require_once($CFG->libdir.'/filelib.php');
$fs = get_file_storage();
$syscontext = context_system::instance();
$files = $fs->get_area_files($syscontext->id, 'blog', 'attachment', $this->id);
$imagereturn = "";
$output = "";
$strattachment = get_string("attachment", "forum");
foreach ($files as $file) {
if ($file->is_directory()) {
continue;
}
$filename = $file->get_filename();
$ffurl = file_encode_url($CFG->wwwroot.'/pluginfile.php', '/'.SYSCONTEXTID.'/blog/attachment/'.$this->id.'/'.$filename);
$mimetype = $file->get_mimetype();
$image = $OUTPUT->pix_icon(file_file_icon($file), $filename, 'moodle', array('class'=>'icon'));
if ($return == "html") {
$output .= html_writer::link($ffurl, $image);
$output .= html_writer::link($ffurl, $filename);
} else if ($return == "text") {
$output .= "$strattachment $filename:\n$ffurl\n";
} else {
if (file_mimetype_in_typegroup($file->get_mimetype(), 'web_image')) { // Image attachments don't get printed as links
$imagereturn .= '<br /><img src="'.$ffurl.'" alt="" />';
} else {
$imagereturn .= html_writer::link($ffurl, $image);
$imagereturn .= format_text(html_writer::link($ffurl, $filename), FORMAT_HTML, array('context'=>$syscontext));
}
}
}
if ($return) {
return $output;
}
return $imagereturn;
}
/**
* function to attach tags into an entry
* @return void
@@ -602,7 +429,7 @@ class blog_entry {
global $CFG, $USER, $DB;
$sitecontext = context_system::instance();
if (empty($CFG->bloglevel) || !has_capability('moodle/blog:view', $sitecontext)) {
if (empty($CFG->enableblogs) || !has_capability('moodle/blog:view', $sitecontext)) {
return false; // blog system disabled or user has no blog view capability
}
@@ -807,9 +634,12 @@ class blog_listing {
* @return void
*/
public function print_entries() {
global $CFG, $USER, $DB, $OUTPUT;
global $CFG, $USER, $DB, $OUTPUT, $PAGE;
$sitecontext = context_system::instance();
// Blog renderer
$output = $PAGE->get_renderer('blog');
$page = optional_param('blogpage', 0, PARAM_INT);
$limit = optional_param('limit', get_user_preferences('blogpagesize', 10), PARAM_INT);
$start = $page * $limit;
@@ -860,10 +690,13 @@ class blog_listing {
if ($entries) {
$count = 0;
foreach ($entries as $entry) {
$blogentry = new blog_entry(null, $entry);
$blogentry->print_html();
// Get the required blog entry data to render it
$blogentry->prepare_render();
echo $output->render($blogentry);
$count++;
}
@@ -1161,3 +994,30 @@ class blog_filter_search extends blog_filter {
$this->params[] = "%$searchterm%";
}
}
/**
* Renderable class to represent an entry attachment
*/
class blog_entry_attachment implements renderable {
public $filename;
public $url;
public $file;
/**
* Gets the file data
*
* @param stored_file $file
* @param int $entryid Attachment entry id
*/
public function __construct($file, $entryid) {
global $CFG;
$this->file = $file;
$this->filename = $file->get_filename();
$this->url = file_encode_url($CFG->wwwroot.'/pluginfile.php', '/'.SYSCONTEXTID.'/blog/attachment/'.$entryid.'/'.$this->filename);
}
}
+1 -1
View File
@@ -64,7 +64,7 @@ if ($courseid == SITEID) {
$context = context_course::instance($courseid);
}
if (empty($CFG->bloglevel)) {
if (empty($CFG->enableblogs)) {
print_error('blogdisable', 'blog');
}
+252
View File
@@ -0,0 +1,252 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Renderers for outputting blog data
*
* @package core_blog
* @subpackage blog
* @copyright 2012 David Monllaó
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Blog renderer
*/
class core_blog_renderer extends plugin_renderer_base {
/**
* Renders a blog entry
*
* @param blog_entry $entry
* @return string The table HTML
*/
public function render_blog_entry(blog_entry $entry) {
global $CFG;
$syscontext = context_system::instance();
$stredit = get_string('edit');
$strdelete = get_string('delete');
// Header.
$mainclass = 'forumpost blog_entry blog clearfix ';
if ($entry->renderable->unassociatedentry) {
$mainclass .= 'draft';
} else {
$mainclass .= $entry->publishstate;
}
$o = $this->output->container_start($mainclass, 'b' . $entry->id);
$o .= $this->output->container_start('row header clearfix');
// User picture.
$o .= $this->output->container_start('left picture header');
$o .= $this->output->user_picture($entry->renderable->user);
$o .= $this->output->container_end();
$o .= $this->output->container_start('topic starter header clearfix');
// Title.
$titlelink = html_writer::link(new moodle_url('/blog/index.php', array('entryid' => $entry->id)), format_string($entry->subject));
$o .= $this->output->container($titlelink, 'subject');
// Post by.
$by = new stdClass();
$fullname = fullname($entry->renderable->user, has_capability('moodle/site:viewfullnames', $syscontext));
$userurlparams = array('id' => $entry->renderable->user->id, 'course' => $this->page->course->id);
$by->name = html_writer::link(new moodle_url('/user/view.php', $userurlparams), $fullname);
$by->date = userdate($entry->created);
$o .= $this->output->container(get_string('bynameondate', 'forum', $by), 'author');
// Adding external blog link.
if (!empty($entry->renderable->externalblogtext)) {
$o .= $this->output->container($entry->renderable->externalblogtext, 'externalblog');
}
// Closing subject tag and header tag.
$o .= $this->output->container_end();
$o .= $this->output->container_end();
// Post content.
$o .= $this->output->container_start('row maincontent clearfix');
// Entry.
$o .= $this->output->container_start('no-overflow content ');
// Determine text for publish state.
switch ($entry->publishstate) {
case 'draft':
$blogtype = get_string('publishtonoone', 'blog');
break;
case 'site':
$blogtype = get_string('publishtosite', 'blog');
break;
case 'public':
$blogtype = get_string('publishtoworld', 'blog');
break;
default:
$blogtype = '';
break;
}
$o .= $this->output->container($blogtype, 'audience');
// Attachments.
$attachmentsoutputs = array();
if ($entry->renderable->attachments) {
foreach ($entry->renderable->attachments as $attachment) {
$o .= $this->render($attachment, false);
}
}
// Body.
$o .= format_text($entry->summary, $entry->summaryformat, array('overflowdiv' => true));
// Uniquehash is used as a link to an external blog.
if (!empty($entry->uniquehash)) {
$o .= $this->output->container_start('externalblog');
$o .= html_writer::link($entry->uniquehash, get_string('linktooriginalentry', 'blog'));
$o .= $this->output->container_end();
}
// Links to tags.
$officialtags = tag_get_tags_csv('post', $entry->id, TAG_RETURN_HTML, 'official');
$defaulttags = tag_get_tags_csv('post', $entry->id, TAG_RETURN_HTML, 'default');
if (!empty($CFG->usetags) && ($officialtags || $defaulttags) ) {
$o .= $this->output->container_start('tags');
if ($officialtags) {
$o .= get_string('tags', 'tag') .': '. $this->output->container($officialtags, 'officialblogtags');
if ($defaulttags) {
$o .= ', ';
}
}
$o .= $defaulttags;
$o .= $this->output->container_end();
}
// Add associations.
if (!empty($CFG->useblogassociations) && !empty($entry->renderable->blogassociations)) {
// First find and show the associated course.
$assocstr = '';
$coursesarray = array();
foreach ($entry->renderable->blogassociations as $assocrec) {
if ($assocrec->contextlevel == CONTEXT_COURSE) {
$coursesarray[] = $this->output->action_icon($assocrec->url, $assocrec->icon, null, array(), true);
}
}
if (!empty($coursesarray)) {
$assocstr .= get_string('associated', 'blog', get_string('course')) . ': ' . implode(', ', $coursesarray);
}
// Now show mod association.
$modulesarray = array();
foreach ($entry->renderable->blogassociations as $assocrec) {
if ($assocrec->contextlevel == CONTEXT_MODULE) {
$str = get_string('associated', 'blog', $assocrec->type) . ': ';
$str .= $this->output->action_icon($assocrec->url, $assocrec->icon, null, array(), true);
$modulesarray[] = $str;
}
}
if (!empty($modulesarray)) {
if (!empty($coursesarray)) {
$assocstr .= '<br/>';
}
$assocstr .= implode('<br/>', $modulesarray);
}
// Adding the asociations to the output.
$o .= $this->output->container($assocstr, 'tags');
}
if ($entry->renderable->unassociatedentry) {
$o .= $this->output->container(get_string('associationunviewable', 'blog'), 'noticebox');
}
// Commands.
$o .= $this->output->container_start('commands');
if ($entry->renderable->usercanedit) {
// External blog entries should not be edited.
if (empty($entry->uniquehash)) {
$o .= html_writer::link(new moodle_url('/blog/edit.php',
array('action' => 'edit', 'entryid' => $entry->id)),
$stredit) . ' | ';
}
$o .= html_writer::link(new moodle_url('/blog/edit.php',
array('action' => 'delete', 'entryid' => $entry->id)),
$strdelete) . ' | ';
}
$entryurl = new moodle_url('/blog/index.php', array('entryid' => $entry->id));
$o .= html_writer::link($entryurl, get_string('permalink', 'blog'));
$o .= $this->output->container_end();
// Last modification.
if ($entry->created != $entry->lastmodified) {
$o .= $this->output->container(' [ '.get_string('modified').': '.userdate($entry->lastmodified).' ]');
}
// Comments.
if (!empty($entry->renderable->comment)) {
$o .= $entry->renderable->comment->output(true);
}
$o .= $this->output->container_end();
// Closing maincontent div.
$o .= $this->output->container('&nbsp;', 'side options');
$o .= $this->output->container_end();
$o .= $this->output->container_end();
return $o;
}
/**
* Renders an entry attachment
*
* Print link for non-images and returns images as HTML
*
* @param blog_entry_attachment $attachment
* @return string List of attachments depending on the $return input
*/
public function render_blog_entry_attachment(blog_entry_attachment $attachment) {
$syscontext = context_system::instance();
// Image attachments don't get printed as links.
if (file_mimetype_in_typegroup($attachment->file->get_mimetype(), 'web_image')) {
$attrs = array('src' => $attachment->url, 'alt' => '');
$o = html_writer::empty_tag('img', $attrs);
$class = 'attachedimages';
} else {
$image = $this->output->pix_icon(file_file_icon($attachment->file), $attachment->filename, 'moodle', array('class'=>'icon'));
$o = html_writer::link($attachment->url, $image);
$o .= format_text(html_writer::link($attachment->url, $attachment->filename), FORMAT_HTML, array('context' => $syscontext));
$class = 'attachments';
}
return $this->output->container($o, $class);
}
}
+3 -3
View File
@@ -95,7 +95,7 @@ bodyContent: '<div class="comment-delete-confirm"><a href="#" id="confirmdelete-
color: { to: '#06e' },
backgroundColor: { to: '#FFE390' }
};
var anim = new YAHOO.util.ColorAnim(ids[i], attributes);
var anim = new Y.YUI2.util.ColorAnim(ids[i], attributes);
anim.animate();
}
scope.register_pagination();
@@ -106,7 +106,7 @@ bodyContent: '<div class="comment-delete-confirm"><a href="#" id="confirmdelete-
var attributes = {
backgroundColor: { from: '#FFE390', to:'#FFFFFF' }
};
var anim = new YAHOO.util.ColorAnim('dlg-content-'+cid, attributes);
var anim = new Y.YUI2.util.ColorAnim('dlg-content-'+cid, attributes);
anim.animate();
}
},
@@ -255,7 +255,7 @@ bodyContent: '<div class="comment-delete-confirm"><a href="#" id="confirmdelete-
};
var cmt = Y.one('#'+htmlid);
cmt.setStyle('overflow', 'hidden');
var anim = new YAHOO.util.Anim(htmlid, attributes, 1, YAHOO.util.Easing.easeOut);
var anim = new Y.YUI2.util.Anim(htmlid, attributes, 1, Y.YUI2.util.Easing.easeOut);
anim.onComplete.subscribe(remove_dom, cmt, this);
anim.animate();
}
+1 -1
View File
@@ -46,7 +46,7 @@ if (($marker >=0) && has_capability('moodle/course:setcurrentsection', $context)
$renderer = $PAGE->get_renderer('format_topics');
if (!empty($displaysection) && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
if (!empty($displaysection)) {
$renderer->print_single_section_page($course, $sections, $mods, $modnames, $modnamesused, $displaysection);
} else {
$renderer->print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused);
+1 -1
View File
@@ -39,7 +39,7 @@ if ($week = optional_param('week', 0, PARAM_INT)) {
$renderer = $PAGE->get_renderer('format_weeks');
if (!empty($displaysection) && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
if (!empty($displaysection)) {
$renderer->print_single_section_page($course, $sections, $mods, $modnames, $modnamesused, $displaysection);
} else {
$renderer->print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused);
+1 -1
View File
@@ -97,7 +97,7 @@
$logparam = 'id='. $course->id;
$loglabel = 'view';
$infoid = $course->id;
if(!empty($section)) {
if ($section and $section > 0) {
$loglabel = 'view section';
// Get section details and check it exists.
+2 -1
View File
@@ -863,7 +863,8 @@ class course_enrolment_manager {
$period = get_string('periodend', 'enrol', userdate($ue->timeend));
$periodoutside = ($ue->timeend && $now > $ue->timeend);
} else {
$period = '';
// If there is no start or end show when user was enrolled.
$period = get_string('periodnone', 'enrol', userdate($ue->timecreated));
$periodoutside = false;
}
$details['enrolments'][$ue->id] = array(
+4 -2
View File
@@ -46,9 +46,11 @@ class enrol_manual_user_enrolment_form extends moodleform {
$mform->addElement('select', 'status', get_string('participationstatus', 'enrol'), $options);
}
$mform->addElement('date_selector', 'timestart', get_string('enroltimestart', 'enrol'), array('optional' => true));
$mform->addElement('date_time_selector', 'timestart', get_string('enroltimestart', 'enrol'), array('optional' => true));
$mform->addElement('date_selector', 'timeend', get_string('enroltimeend', 'enrol'), array('optional' => true));
$mform->addElement('date_time_selector', 'timeend', get_string('enroltimeend', 'enrol'), array('optional' => true));
$mform->addElement('static', 'timecreated', get_string('enroltimecreated', 'enrol'), userdate($ue->timecreated));
$mform->addElement('hidden', 'ue');
$mform->setType('ue', PARAM_INT);
+4 -2
View File
@@ -46,9 +46,11 @@ class enrol_self_user_enrolment_form extends moodleform {
$mform->addElement('select', 'status', get_string('participationstatus', 'enrol'), $options);
}
$mform->addElement('date_selector', 'timestart', get_string('enroltimestart', 'enrol'), array('optional' => true));
$mform->addElement('date_time_selector', 'timestart', get_string('enroltimestart', 'enrol'), array('optional' => true));
$mform->addElement('date_selector', 'timeend', get_string('enroltimeend', 'enrol'), array('optional' => true));
$mform->addElement('date_time_selector', 'timeend', get_string('enroltimeend', 'enrol'), array('optional' => true));
$mform->addElement('static', 'timecreated', get_string('enroltimecreated', 'enrol'), userdate($ue->timecreated));
$mform->addElement('hidden', 'ue');
$mform->setType('ue', PARAM_INT);
-85
View File
@@ -1,85 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* File manager support
*
* @package core
* @subpackage file
* @copyright 2010 Dongsheng Cai <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('AJAX_SCRIPT', true);
require('../config.php');
require_once($CFG->libdir.'/filelib.php');
$action = optional_param('action', 'list', PARAM_ALPHA);
$PAGE->set_context(get_system_context());
require_login();
echo $OUTPUT->header(); // send headers
$err = new stdClass();
if (isguestuser()) {
$err->error = get_string('noguest');
die(json_encode($err));
}
switch ($action) {
// used by course file tree viewer
case 'getfiletree':
$contextid = required_param('contextid', PARAM_INT);
$component = required_param('component', PARAM_COMPONENT);
$filearea = required_param('filearea', PARAM_AREA);
$itemid = required_param('itemid', PARAM_INT);
$filepath = required_param('filepath', PARAM_PATH);
$browser = get_file_browser();
$fileinfo = $browser->get_file_info(get_context_instance_by_id($contextid), $component, $filearea, $itemid, $filepath);
$children = $fileinfo->get_children();
$tree = array();
foreach ($children as $child) {
$filedate = $child->get_timemodified();
$filesize = $child->get_filesize();
$mimetype = $child->get_mimetype();
$params = $child->get_params();
$url = new moodle_url('/files/index.php', $params);
$fileitem = array(
'params'=>$params,
'filename'=>$child->get_visible_name(),
'filedate'=>$filedate ? userdate($filedate) : '',
'filesize'=>$filesize ? display_size($filesize) : '',
);
if ($child->is_directory()) {
$fileitem['isdir'] = true;
$fileitem['url'] = $url->out(false);
$fileitem['icon'] = $OUTPUT->pix_icon(file_folder_icon(), get_string('icon'));
} else {
$fileitem['url'] = $child->get_url();
$fileitem['icon'] = $OUTPUT->pix_icon(file_file_icon($child), get_string('icon'));
}
$tree[] = $fileitem;
}
echo json_encode($tree);
break;
default:
break;
}
-101
View File
@@ -1,101 +0,0 @@
// File Tree Viewer
// Author: Dongsheng Cai <[email protected]>
M.core_filetree = {
y3: null,
api: M.cfg.wwwroot+'/files/filebrowser_ajax.php',
request: function(url, node, cb) {
var api = this.api + '?action=getfiletree';
var params = [];
params['contextid'] = this.get_param(url, 'contextid', -1);
params['component'] = this.get_param(url, 'component', null);
params['filearea'] = this.get_param(url, 'filearea', null);
params['itemid'] = this.get_param(url, 'itemid', -1);
params['filepath'] = this.get_param(url, 'filepath', null);
params['filename'] = this.get_param(url, 'filename', null);
var scope = this;
params['sesskey']=M.cfg.sesskey;
var cfg = {
method: 'POST',
on: {
complete: function(id,o,p) {
try {
var data = this.y3.JSON.parse(o.responseText);
} catch(e) {
alert(e.toString());
return;
}
if (data && data.length==0) {
node.isLeaf = true;
} else {
for (i in data) {
var tmp = new YAHOO.widget.HTMLNode('<div>'+data[i].icon+'&nbsp;<a href="'+data[i].url+'">'+data[i].filename+'</a></div>', node, false);
if (data[i].isdir) {
tmp.isLeaf = false;
tmp.isDir = true;
} else {
tmp.isLeaf = true;
tmp.isFile = true;
}
}
}
cb();
}
},
arguments: {
scope: scope
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
},
data: build_querystring(params),
context: this
};
this.y3.io(api, cfg);
},
init : function(Y){
var tree = new YAHOO.widget.TreeView('course-file-tree-view');
tree.setDynamicLoad(this.dynload);
tree.subscribe("clickEvent", this.onclick);
var root = tree.getRoot();
var children = root.children;
for (i in children) {
if (children[i].className == 'file-tree-folder') {
children[i].isLeaf = false;
children[i].isDir = true;
} else {
children[i].isLeaf = true;
children[i].isFile = true;
}
}
tree.render();
this.y3 = Y;
},
dynload: function(node, oncompletecb) {
var tmp = document.createElement('p');
tmp.innerHTML = node.html;
var links = tmp.getElementsByTagName('a');
var link = links[0].href;
M.core_filetree.request(link, node, oncompletecb);
},
onclick: function(e) {
YAHOO.util.Event.preventDefault(e);
if (e.node.isFile) {
var tmp = document.createElement('p');
tmp.innerHTML = e.node.html;
var links = tmp.getElementsByTagName('a');
var link = links[0].href;
window.location = link;
}
},
get_param: function(url, name, val) {
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec(url);
if( results == null ) {
return val;
} else {
return unescape(results[1]);
}
}
};
+51 -32
View File
@@ -2,10 +2,12 @@
* Toggles the selection checkboxes of all grade items children of the given eid (a category id)
*/
function togglecheckboxes(event, args) {
var rows = YAHOO.util.Dom.getElementsByClassName(args.eid);
YUI().use('yui2-dom', 'yui2-element', function (Y) {
var rows = Y.YUI2.util.Dom.getElementsByClassName(args.eid);
for (var i = 0; i < rows.length; i++) {
var element = new YAHOO.util.Element(rows[i]);
var element = new Y.YUI2.util.Element(rows[i]);
var checkboxes = element.getElementsByClassName('itemselect');
if (checkboxes[0]) {
checkboxes[0].checked=args.check;
@@ -14,42 +16,68 @@ function togglecheckboxes(event, args) {
toggleCategorySelector();
});
}
function toggle_advanced_columns() {
var advEls = YAHOO.util.Dom.getElementsByClassName("advanced");
var shownAdvEls = YAHOO.util.Dom.getElementsByClassName("advancedshown");
YUI().use('yui2-dom', function (Y) {
var advEls = Y.YUI2.util.Dom.getElementsByClassName("advanced");
var shownAdvEls = Y.YUI2.util.Dom.getElementsByClassName("advancedshown");
for (var i = 0; i < advEls.length; i++) {
YAHOO.util.Dom.replaceClass(advEls[i], "advanced", "advancedshown");
Y.YUI2.util.Dom.replaceClass(advEls[i], "advanced", "advancedshown");
}
for (var i = 0; i < shownAdvEls.length; i++) {
YAHOO.util.Dom.replaceClass(shownAdvEls[i], "advancedshown", "advanced");
Y.YUI2.util.Dom.replaceClass(shownAdvEls[i], "advancedshown", "advanced");
}
});
}
/**
* Check if any of the grade item checkboxes is ticked. If yes, enable the dropdown. Otherwise, disable it
*/
function toggleCategorySelector() {
var itemboxes = YAHOO.util.Dom.getElementsByClassName('itemselect');
YUI().use('yui2-dom', function (Y) {
var menumoveafter = document.getElementById('menumoveafter');
if (!menumoveafter) {
return;
}
var itemboxes = Y.YUI2.util.Dom.getElementsByClassName('itemselect');
for (var i = 0; i < itemboxes.length; i++) {
if (itemboxes[i].checked) {
document.getElementById('menumoveafter').disabled = false;
menumoveafter.disabled = false;
return true;
}
}
document.getElementById('menumoveafter').disabled = 'disabled';
menumoveafter.disabled = 'disabled';
});
}
YAHOO.namespace('grade_edit_tree');
function submit_bulk_move(e, args) {
document.getElementById('bulkmoveinput').value = 1;
document.getElementById('gradetreeform').submit();
}
function update_category_aggregation(e, args) {
var selectmenu = e.target;
window.location = 'index.php?id='+args.courseid+'&category='+args.category+'&aggregationtype='+selectmenu.get('value')+'&sesskey='+args.sesskey;
}
/* TODO: finish and rewrite for YUI3...
Y.YUI2.namespace('grade_edit_tree');
(function() {
var Dom = YAHOO.util.Dom;
var DDM = YAHOO.util.DragDropMgr;
var Event = YAHOO.util.Event;
var gretree = YAHOO.grade_edit_tree;
var Dom = Y.YUI2.util.Dom;
var DDM = Y.YUI2.util.DragDropMgr;
var Event = Y.YUI2.util.Event;
var gretree = Y.YUI2.grade_edit_tree;
gretree.DDApp = {
@@ -60,7 +88,7 @@ YAHOO.namespace('grade_edit_tree');
var item_rows = edit_tree_table.getElementsByClassName('item', 'tr');
var category_rows = edit_tree_table.getElementsByClassName('category', 'tr');
new YAHOO.util.DDTarget('grade_edit_tree_table');
new Y.YUI2.util.DDTarget('grade_edit_tree_table');
for (i = 0; i < item_rows.length; i++) {
if (!Dom.hasClass(item_rows[i],'categoryitem')) {
@@ -85,8 +113,8 @@ YAHOO.namespace('grade_edit_tree');
}
}
YAHOO.util.Event.on("showButton", "click", this.showOrder);
YAHOO.util.Event.on("switchButton", "click", this.switchStyles);
Y.YUI2.util.Event.on("showButton", "click", this.showOrder);
Y.YUI2.util.Event.on("switchButton", "click", this.switchStyles);
},
showOrder: function() {
@@ -112,7 +140,7 @@ YAHOO.namespace('grade_edit_tree');
gretree.DDList = function(id, sGroup, config) {
gretree.DDList.superclass.constructor.call(this, id, sGroup, config);
this.logger = this.logger || YAHOO;
this.logger = this.logger || Y.YUI2;
var el = this.getDragEl();
Dom.setStyle(el, 'opacity', 0.67);
@@ -120,7 +148,7 @@ YAHOO.namespace('grade_edit_tree');
this.lastY = 0;
};
YAHOO.extend(gretree.DDList, YAHOO.util.DDProxy, {
Y.YUI2.extend(gretree.DDList, Y.YUI2.util.DDProxy, {
startDrag: function(x, y) {
this.logger.log(this.id + ' startDrag');
@@ -145,7 +173,7 @@ YAHOO.namespace('grade_edit_tree');
// Show the proxy element and adnimate it to the src element's location
Dom.setStyle(proxy, 'visibility', '');
var a = new YAHOO.util.Motion(proxy, { points: { to: Dom.getXY(srcEl) } }, 0.2, YAHOO.util.Easing.easeOut);
var a = new Y.YUI2.util.Motion(proxy, { points: { to: Dom.getXY(srcEl) } }, 0.2, Y.YUI2.util.Easing.easeOut);
var proxyid = proxy.id;
var thisid = this.id;
@@ -164,7 +192,7 @@ YAHOO.namespace('grade_edit_tree');
// If there is one drop interaction, the tr was dropped either on the table, or it was dropped on the current location of the source element
if (DDM.interactionInfo.drop.length === 1) {
// The position of the cursor at the time of the drop (YAHOO.util.Point)
// The position of the cursor at the time of the drop (Y.YUI2.util.Point)
var pt = DDM.interactionInfo.point;
// The region occupied by the source element at the time of the drop
@@ -214,15 +242,6 @@ YAHOO.namespace('grade_edit_tree');
}
}
});
// YAHOO.util.Event.onDOMReady(gretree.DDApp.init, gretree.DDApp, true); // Uncomment this line when dragdrop is fully implemented
// Y.YUI2.util.Event.onDOMReady(gretree.DDApp.init, gretree.DDApp, true); // Uncomment this line when dragdrop is fully implemented
})();
function submit_bulk_move(e, args) {
document.getElementById('bulkmoveinput').value = 1;
document.getElementById('gradetreeform').submit();
}
function update_category_aggregation(e, args) {
var selectmenu = e.target;
window.location = 'index.php?id='+args.courseid+'&category='+args.category+'&aggregationtype='+selectmenu.get('value')+'&sesskey='+args.sesskey;
}
*/
-7
View File
@@ -51,13 +51,6 @@ $context = context_course::instance($course->id);
require_capability('moodle/grade:manage', $context);
// todo $PAGE->requires->js_module() should be used here instead
$PAGE->requires->yui2_lib('event');
$PAGE->requires->yui2_lib('json');
$PAGE->requires->yui2_lib('connection');
$PAGE->requires->yui2_lib('dragdrop');
$PAGE->requires->yui2_lib('element');
$PAGE->requires->yui2_lib('container');
$PAGE->requires->yui2_lib('animation');
$PAGE->requires->js('/grade/edit/tree/functions.js');
/// return tracking object
+10 -3
View File
@@ -77,7 +77,9 @@ function UpdatableGroupsCombo(wwwRoot, courseId) {
*/
// Hide the updategroups input since AJAX will take care of this.
YAHOO.util.Dom.setStyle("updategroups", "display", "none");
YUI().use('yui2-dom', function (Y) {
Y.YUI2.util.Dom.setStyle("updategroups", "display", "none");
});
}
@@ -129,7 +131,9 @@ function UpdatableMembersCombo(wwwRoot, courseId) {
};
// Hide the updatemembers input since AJAX will take care of this.
YAHOO.util.Dom.setStyle("updatemembers", "display", "none");
YUI().use('yui2-dom', function (Y) {
Y.YUI2.util.Dom.setStyle("updatemembers", "display", "none");
});
}
/**
@@ -181,7 +185,10 @@ UpdatableMembersCombo.prototype.refreshMembers = function () {
if(singleSelection) {
var sUrl = this.wwwRoot+"/group/index.php?id="+this.courseId+"&group="+groupId+"&act_ajax_getmembersingroup";
YAHOO.util.Connect.asyncRequest("GET", sUrl, this.connectCallback, null);
var callback = this.connectCallback;
YUI().use('yui2-connection', function (Y) {
Y.YUI2.util.Connect.asyncRequest("GET", sUrl, callback, null);
});
}
};
-1
View File
@@ -56,7 +56,6 @@ $PAGE->set_url($url);
// Make sure that the user has permissions to manage groups.
require_login($course);
$PAGE->requires->yui2_lib('connection');
$PAGE->requires->js('/group/clientlib.js');
$context = context_course::instance($course->id);
-1
View File
@@ -84,7 +84,6 @@ $strusergroupmembership = get_string('usergroupmembership', 'group');
$groupname = format_string($group->name);
$PAGE->requires->yui2_lib('connection');
$PAGE->requires->js('/group/clientlib.js');
$PAGE->navbar->add($strparticipants, new moodle_url('/user/index.php', array('id'=>$course->id)));
$PAGE->navbar->add($strgroups, new moodle_url('/group/index.php', array('id'=>$course->id)));
+3
View File
@@ -36,5 +36,8 @@ $string['cliincorrectvalueerror'] = 'Villa, ótækt gildi "{$a->value}" fyrir "{
$string['cliincorrectvalueretry'] = 'Rangt gildi, vinsamlegast reyndu aftur';
$string['clitypevalue'] = 'Sláðu inn gildi';
$string['clitypevaluedefault'] = 'Sláðu inn gildi, sláðu á Enter hnappinn á lyklaborðinu til að nota sjálfgefið gildi ({$a})';
$string['cliunknowoption'] = 'Óþekktir valkostir:
{$a}
Vinsamlegast notaðu --help valkostinn.';
$string['environmentrequireinstall'] = 'verður að vera uppsett og virkjað';
$string['environmentrequireversion'] = 'krafist er útgáfu {$a->needed} en þú notast við útgáfu {$a->current}';
+2 -1
View File
@@ -30,6 +30,7 @@
defined('MOODLE_INTERNAL') || die();
$string['clianswerno'] = 'n';
$string['cliansweryes'] = 't';
$string['cliincorrectvalueerror'] = 'Klaida, klaidinga "{$a->option}" reikšmė "{$a->value}"';
$string['cliincorrectvalueretry'] = 'Klaidinga reikšmė, bandykite dar kartą';
@@ -38,4 +39,4 @@ $string['clitypevaluedefault'] = 'tipo reikšmė, paspauskite „Enter“, jei n
$string['cliunknowoption'] = 'Neatpažintos parinktys: {$a} naudokite --žinyno parinktį.';
$string['cliyesnoprompt'] = 'įveskite t (taip) arba n (ne)';
$string['environmentrequireinstall'] = 'turi būti įdiegta ir įgalinta';
$string['environmentrequireversion'] = 'reikalinga $a-needed, o Jūs turite $a-current';
$string['environmentrequireversion'] = 'reikalinga {$a->needed} versija, o Jūs turite {$a->current}';
+2
View File
@@ -180,6 +180,7 @@ $string['configdefaultuserroleid'] = 'All logged in users will be given the capa
$string['configdeleteincompleteusers'] = 'After this period, old not fully setup accounts are deleted.';
$string['configdeleteunconfirmed'] = 'If you are using email authentication, this is the period within which a response will be accepted from users. After this period, old unconfirmed accounts are deleted.';
$string['configdenyemailaddresses'] = 'To deny email addresses from particular domains list them here in the same way. All other domains will be accepted. To deny subdomains add the domain with a preceding \'.\'. eg <strong>hotmail.com yahoo.co.uk .live.com</strong>';
$string['configenableblogs'] = 'This switch provides all site users with their own blog.';
$string['configenabledevicedetection'] = 'Enables detection of mobiles, smartphones, tablets or default devices (desktop PCs, laptops, etc) for the application of themes and other features.';
$string['configdisableuserimages'] = 'Disable the ability for users to change user profile images.';
$string['configdisplayloginfailures'] = 'This will display information to selected users about previous failed logins.';
@@ -464,6 +465,7 @@ $string['emoticons_desc'] = 'This form defines the emoticons (or smileys) used a
$string['emoticonsreset'] = 'Reset emoticons setting to default values';
$string['emptysettingvalue'] = 'Empty';
$string['enableajax'] = 'Enable AJAX';
$string['enableblogs'] = 'Enable blogs';
$string['enablecalendarexport'] = 'Enable calendar export';
$string['enablecomments'] = 'Enable comments';
$string['enablecourserequests'] = 'Enable course requests';
-1
View File
@@ -74,7 +74,6 @@ $string['deleteexternalblog'] = 'Unregister this external blog';
$string['deleteotagswarn'] = 'Are you sure you want to remove these tags from all blog posts and remove it from the system?';
$string['description'] = 'Description';
$string['description_help'] = 'Enter a sentence or two summarising the contents of your external blog. (If no description is supplied, the description recorded in your external blog will be used).';
$string['disableblogs'] = 'Disable blog system completely';
$string['donothaveblog'] = 'You do not have your own blog, sorry.';
$string['editentry'] = 'Edit a blog entry';
$string['editexternalblog'] = 'Edit this external blog';
+2
View File
@@ -55,6 +55,7 @@ $string['enrolnotpermitted'] = 'You do not have permission or are not allowed to
$string['enrolperiod'] = 'Enrolment duration';
$string['enrolusage'] = 'Instances / enrolments';
$string['enrolusers'] = 'Enrol users';
$string['enroltimecreated'] = 'Enrolment created';
$string['enroltimeend'] = 'Enrolment ends';
$string['enroltimestart'] = 'Enrolment starts';
$string['errajaxfailedenrol'] = 'Failed to enrol user';
@@ -79,6 +80,7 @@ $string['participationactive'] = 'Active';
$string['participationstatus'] = 'Status';
$string['participationsuspended'] = 'Suspended';
$string['periodend'] = 'until {$a}';
$string['periodnone'] = 'enrolled {$a}';
$string['periodstart'] = 'from {$a}';
$string['periodstartend'] = 'from {$a->start} until {$a->end}';
$string['recovergrades'] = 'Recover user\'s old grades if possible';
+5 -4
View File
@@ -123,11 +123,12 @@ define('INSECURE_DATAROOT_ERROR', 2);
function uninstall_plugin($type, $name) {
global $CFG, $DB, $OUTPUT;
// recursively uninstall all module subplugins first
if ($type === 'mod') {
if (file_exists("$CFG->dirroot/mod/$name/db/subplugins.php")) {
// recursively uninstall all module/editor subplugins first
if ($type === 'mod' || $type === 'editor') {
$base = get_component_directory($type . '_' . $name);
if (file_exists("$base/db/subplugins.php")) {
$subplugins = array();
include("$CFG->dirroot/mod/$name/db/subplugins.php");
include("$base/db/subplugins.php");
foreach ($subplugins as $subplugintype=>$dir) {
$instances = get_plugin_list($subplugintype);
foreach ($instances as $subpluginname => $notusedpluginpath) {
+2 -2
View File
@@ -352,7 +352,7 @@ function cron_run() {
// Run external blog cron if needed
if ($CFG->useexternalblogs) {
if (!empty($CFG->enableblogs) && $CFG->useexternalblogs) {
require_once($CFG->dirroot . '/blog/lib.php');
mtrace("Fetching external blog entries...", '');
$sql = "timefetched < ? OR timefetched = 0";
@@ -364,7 +364,7 @@ function cron_run() {
mtrace('done.');
}
// Run blog associations cleanup
if ($CFG->useblogassociations) {
if (!empty($CFG->enableblogs) && $CFG->useblogassociations) {
require_once($CFG->dirroot . '/blog/lib.php');
// delete entries whose contextids no longer exists
mtrace("Deleting blog associations linked to non-existent contexts...", '');
+19
View File
@@ -1094,5 +1094,24 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2012080200.02);
}
if ($oldversion < 2012081400.01) {
// Move the ability to disable blogs to its own setting MDL-25012.
if (isset($CFG->bloglevel)) {
// Only change settings if existing setting was set.
if (empty($CFG->bloglevel)) {
set_config('enableblogs', 0);
// Now set the bloglevel to a valid setting as the disabled setting has been removed.
// This prevents confusing results when users enable the blog system in future.
set_config('bloglevel', BLOG_USER_LEVEL);
} else {
set_config('enableblogs', 1);
}
}
// Main savepoint reached
upgrade_main_savepoint(true, 2012081400.01);
}
return true;
}
+17
View File
@@ -68,6 +68,23 @@ function upgrade_mysql_fix_unsigned_columns() {
$column = (object)array_change_key_case((array)$column, CASE_LOWER);
if (stripos($column->type, 'unsigned') !== false) {
$maxvalue = 0;
if (preg_match('/^int/i', $column->type)) {
$maxvalue = 2147483647;
} else if (preg_match('/^medium/i', $column->type)) {
$maxvalue = 8388607;
} else if (preg_match('/^smallint/i', $column->type)) {
$maxvalue = 32767;
} else if (preg_match('/^tinyint/i', $column->type)) {
$maxvalue = 127;
}
if ($maxvalue) {
// Make sure nobody is abusing our integer ranges - moodle int sizes are in digits, not bytes!!!
$invalidcount = $DB->get_field_sql("SELECT COUNT('x') FROM `{{$table}}` WHERE `$column->field` > :maxnumber", array('maxnumber'=>$maxvalue));
if ($invalidcount) {
throw new moodle_exception('notlocalisederrormessage', 'error', new moodle_url('/admin/'), "Database table '{$table}'' contains unsigned column '{$column->field}' with $invalidcount values that are out of allowed range, upgrade can not continue.");
}
}
$type = preg_replace('/unsigned/i', 'signed', $column->type);
$notnull = ($column->null === 'NO') ? 'NOT NULL' : 'NULL';
$default = (!is_null($column->default) and $column->default !== '') ? "DEFAULT '$column->default'" : '';
+1 -21
View File
@@ -859,27 +859,7 @@ function use_html_editor($name='', $editorhidebuttons='', $id='') {
* 2. and 3. lead to a call $PAGE->requires->js('/lib/javascript-static.js').
*/
function require_js($lib) {
global $CFG, $PAGE;
// Add the lib to the list of libs to be loaded, if it isn't already
// in the list.
if (is_array($lib)) {
foreach($lib as $singlelib) {
require_js($singlelib);
}
return;
}
debugging('Call to deprecated function require_js. Please use $PAGE->requires->js_module() instead.', DEBUG_DEVELOPER);
if (strpos($lib, 'yui_') === 0) {
$PAGE->requires->yui2_lib(substr($lib, 4));
} else {
if ($PAGE->requires->is_head_done()) {
echo html_writer::script('', $lib);
} else {
$PAGE->requires->js(new moodle_url($lib));
}
}
throw new coding_exception('require_js() was removed, use new JS api');
}
/**
+323
View File
@@ -0,0 +1,323 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
/**
* TinyMCE text editor plugin base class.
*
* This is a base class for TinyMCE plugins implemented within Moodle. These
* plugins can optionally provide new buttons/plugins within TinyMCE itself,
* or configure the TinyMCE options.
*
* As well as overridable functions, other utility functions in this class
* can be used when writing the plugins.
*
* Finally, a static function in this class is used to call into all the
* plugins when required.
*
* @package editor_tinymce
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class editor_tinymce_plugin {
/** @var string Plugin folder */
protected $plugin;
/**
* @param string $plugin Name of folder
*/
public function __construct($plugin) {
$this->plugin = $plugin;
}
/**
* Adjusts TinyMCE init parameters for this plugin.
*
* Subclasses must implement this function in order to carry out changes
* to the TinyMCE settings.
*
* @param array $params TinyMCE init parameters array
* @param context $context Context where editor is being shown
* @param array $options Options for this editor
*/
protected abstract function update_init_params(array &$params, context $context,
array $options = null);
/**
* Gets the order in which to run this plugin. Order usually only matters if
* (a) the place you add your button might depend on another plugin, or
* (b) you want to make some changes to layout etc. that should happen last.
* The default order is 100; within that, plugins are sorted alphabetically.
* Return a lower number if you want this plugin to run earlier, or a higher
* number if you want it to run later.
*/
protected function get_sort_order() {
return 100;
}
/**
* Adds a button to the editor, after another button (or at the end).
*
* Specify the location of this button using the $after variable. If you
* leave this blank, the button will be added at the end.
*
* If you want to try different possible locations depending on existing
* plugins you can set $alwaysadd to false and check the return value
* to see if it succeeded.
*
* @param array $params TinyMCE init parameters array
* @param int $row Row to add button to (1 to 3)
* @param string $button Identifier of button/plugin
* @param string $after Adds button directly after the named plugin
* @param bool $alwaysadd If specified $after string not found, add at end
* @return bool True if added
*/
protected function add_button_after(array &$params, $row, $button,
$after = '', $alwaysadd = true) {
$this->check_row($row);
$field = 'theme_advanced_buttons' . $row;
$old = $params[$field];
// Empty = add at end.
if ($after === '') {
$params[$field] = $old . ',' . $button;
return true;
}
// Try to add after given plugin.
$params[$field] = preg_replace('~(,|^)(' . preg_quote($after) . ')(,|$)~',
'$1$2,' . $button . '$3', $old);
if ($params[$field] !== $old) {
return true;
}
// If always adding, recurse to add it empty.
if ($alwaysadd) {
return $this->add_button_after($params, $row, $button);
}
// Otherwise return false (failed to add).
return false;
}
/**
* Adds a button to the editor.
*
* Specify the location of this button using the $before variable. If you
* leave this blank, the button will be added at the start.
*
* If you want to try different possible locations depending on existing
* plugins you can set $alwaysadd to false and check the return value
* to see if it succeeded.
*
* @param array $params TinyMCE init parameters array
* @param int $row Row to add button to (1 to 3)
* @param string $button Identifier of button/plugin
* @param string $before Adds button directly before the named plugin
* @param bool $alwaysadd If specified $after string not found, add at start
* @return bool True if added
*/
protected function add_button_before(array &$params, $row, $button,
$before = '', $alwaysadd = true) {
$this->check_row($row);
$field = 'theme_advanced_buttons' . $row;
$old = $params[$field];
// Empty = add at start.
if ($before === '') {
$params[$field] = $button . ',' . $old;
return true;
}
// Try to add after given plugin.
$params[$field] = preg_replace('~(,|^)(' . preg_quote($before) . ')(,|$)~',
'$1' . $button . ',$2$3', $old);
if ($params[$field] !== $old) {
return true;
}
// If always adding, recurse to add it empty.
if ($alwaysadd) {
return $this->add_button_before($params, $row, $button);
}
// Otherwise return false (failed to add).
return false;
}
/**
* Checks the row value is valid.
*
* @param int $row Row to add button to (1 to 3)
* @throws coding_exception If row value is outside the range 1-3
*/
private function check_row($row) {
if ($row < 1 || $row > 3) {
throw new coding_exception("Invalid row option: $row");
}
}
/**
* Adds a JavaScript plugin into TinyMCE. Note that adding a plugin does
* not by itself add a button; you must do both.
*
* If you leave $pluginname blank (default) it uses the folder name.
*
* @param array $params TinyMCE init parameters array
* @param string $pluginname Identifier for plugin within TinyMCE
* @param string $jsfile Name of JS file (within plugin 'tinymce' directory)
*/
protected function add_js_plugin(&$params, $pluginname='', $jsfile='editor_plugin.js') {
global $CFG;
// Set default plugin name.
if ($pluginname === '') {
$pluginname = $this->plugin;
}
// Add plugin to list in params, so it doesn't try to load it again.
$params['plugins'] .= ',-' . $pluginname;
// Add special param that causes Moodle TinyMCE init to load the plugin.
if (!isset($params['moodle_init_plugins'])) {
$params['moodle_init_plugins'] = '';
} else {
$params['moodle_init_plugins'] .= ',';
}
// Get URL of main JS file and store in params.
$jsurl = $this->get_tinymce_file_url($jsfile, false);
$params['moodle_init_plugins'] .= $pluginname . ':' . $jsurl;
}
/**
* Returns URL to files in the TinyMCE folder within this plugin, suitable
* for client-side use such as loading JavaScript files. (This URL normally
* goes through loader.php and contains the plugin version to ensure
* correct and long-term cacheing.)
*
* @param string $file Filename or path within the folder
* @param bool $absolute Set false to get relative URL from plugins folder
*/
public function get_tinymce_file_url($file='', $absolute=true) {
global $CFG;
// Version number comes from plugin version.php, except in developer
// mode where the special string 'dev' is used (prevents cacheing and
// serves unminified JS).
if (debugging('', DEBUG_DEVELOPER)) {
$version = '-1';
} else {
$version = $this->get_version();
}
// Calculate the JS url (relative to the TinyMCE plugins folder - using
// relative URL saves a few bytes in each HTML page).
if ($CFG->slasharguments) {
// URL is usually from loader.php...
$jsurl = 'loader.php/' . $this->plugin . '/' . $version . '/' . $file;
} else {
// ...except when slash arguments are turned off it serves direct.
// In this situation there is no version details and it is up to
// the browser and server to negotiate cacheing, which will mean
// requesting the JS files frequently (reduced performance).
$jsurl = $this->plugin . '/tinymce/' . $file;
}
if ($absolute) {
$jsurl = $CFG->wwwroot . '/lib/editor/tinymce/plugins/' . $jsurl;
}
return $jsurl;
}
/**
* Obtains version number from version.php for this plugin.
*
* @return string Version number
*/
protected function get_version() {
global $CFG;
$plugin = new stdClass;
require($CFG->dirroot . '/lib/editor/tinymce/plugins/' . $this->plugin . '/version.php');
return $plugin->version;
}
/**
* Calls all available plugins to adjust the TinyMCE init parameters.
*
* @param array $params TinyMCE init parameters array
* @param context $context Context where editor is being shown
* @param array $options Options for this editor
*/
public static function all_update_init_params(array &$params,
context $context, array $options = null) {
global $CFG;
// Get list of plugin directories.
$plugins = get_plugin_list('tinymce');
// Construct all the plugins.
$pluginobjects = array();
foreach ($plugins as $plugin => $dir) {
require_once($dir . '/lib.php');
$classname = 'tinymce_' . $plugin;
$pluginobjects[] = new $classname($plugin);
}
// Sort plugins by sort order and name.
usort($pluginobjects, array('editor_tinymce_plugin', 'compare_plugins'));
// Run the function for each plugin.
foreach ($pluginobjects as $obj) {
$obj->update_init_params($params, $context, $options);
}
}
/**
* Gets a named plugin object. Will cause fatal error if plugin doesn't exist.
*
* @param string $plugin Name of plugin e.g. 'moodleemoticon'
* @return editor_tinymce_plugin Plugin object
*/
public static function get($plugin) {
$dir = get_component_directory('tinymce_' . $plugin);
require_once($dir . '/lib.php');
$classname = 'tinymce_' . $plugin;
return new $classname($plugin);
}
/**
* Compares two plugins.
* @param editor_tinymce_plugin $a
* @param editor_tinymce_plugin $b
* @return Negative number if $a is before $b
*/
public static function compare_plugins(editor_tinymce_plugin $a, editor_tinymce_plugin $b) {
// Use sort order first.
$order = $a->get_sort_order() - $b->get_sort_order();
if ($order != 0) {
return $order;
}
// Then sort alphabetically.
return strcmp($a->plugin, $b->plugin);
}
}
@@ -15,19 +15,13 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Post installation and migration code.
* TinyMCE subplugin type declaration.
*
* @package tool
* @subpackage bloglevelupgrade
* @copyright 2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package editor_tinymce
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
function xmldb_tool_bloglevelupgrade_install() {
global $CFG, $OUTPUT;
}
defined('MOODLE_INTERNAL') || die();
$subplugins = array('tinymce' => 'lib/editor/tinymce/plugins');
+25 -6
View File
@@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@@ -18,8 +17,7 @@
/**
* On-the-fly conversion of Moodle lang strings to TinyMCE expected JS format.
*
* @package editor
* @subpackage tinymce
* @package editor_tinymce
* @copyright 2009 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -27,30 +25,51 @@
define('NO_MOODLE_COOKIES', true);
define('NO_UPGRADE_CHECK', true);
require_once('../../../../config.php');
require('../../../../config.php');
$lang = optional_param('elanguage', 'en', PARAM_SAFEDIR);
$theme = optional_param('etheme', 'advanced', PARAM_SAFEDIR);
$PAGE->set_context(context_system::instance());
$PAGE->set_url('/lib/editor/tinymce/extra/strings.php');
if (!get_string_manager()->translation_exists($lang, false)) {
$lang = 'en';
}
$string = get_string_manager()->load_component_strings('editor_tinymce', $lang);
//process the $strings to match expected tinymce lang array structure
// Process the $strings to match expected tinymce lang array structure.
$result = array();
foreach ($string as $key=>$value) {
$parts = explode(':', $key);
if (count($parts) != 2) {
// incorrect string - ignore
// Ignore non-TinyMCE strings.
continue;
}
$result[$parts[0]][$parts[1]] = $value;
}
// Add subplugin strings, accept only those with proper pluginname prefix with colon.
foreach (get_plugin_list('tinymce') as $component => $ignored) {
$componentstrings = get_string_manager()->load_component_strings(
'tinymce_' . $component, $lang);
foreach ($componentstrings as $key => $value) {
if (strpos($key, "$component:") !== 0) {
// Ignore normal lang strings.
continue;
}
$parts = explode(':', $key);
if (count($parts) != 2) {
// Ignore malformed strings with more colons.
continue;
}
$result[$parts[0]][$parts[1]] = $value;
}
}
$output = 'tinyMCE.addI18n({'.$lang.':'.json_encode($result).'});';
$lifetime = '10'; // TODO: increase later
@@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@@ -18,25 +17,24 @@
/**
* This script imports TinyMCE lang strings into Moodle lang packs.
*
* @package editor
* @subpackage tinymce
* @package editor_tinymce
* @copyright 2009 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('CLI_SCRIPT', true);
require_once dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))).'/config.php';
require dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))).'/config.php';
if (!debugging('', DEBUG_DEVELOPER)) {
die('Only for developers!!!!!');
}
$langconversion = array(
// mapping of TinyMCE lang codes to Moodle codes
// Mapping of TinyMCE lang codes to Moodle codes.
'nb' => 'no',
'sr' => 'sr_lt',
// ignore the following files due to known errors
// Ignore the following files due to known errors.
'ch' => false, // XML parsing error, Moodle does not seem to have Chamorro yet anyway
'zh' => false, // XML parsing error, use 'zh' => 'zh_tw' when sorted out
);
@@ -46,17 +44,17 @@ $tempdir = "$CFG->dirroot/lib/editor/tinymce/extra/tools/temp/tinylangs";
$enfile = "$CFG->dirroot/lib/editor/tinymce/lang/en/editor_tinymce.php";
/// first update English lang pack
/// First update English lang pack.
if (!file_exists("$tempdir/en.xml")) {
die('Missing temp/tinylangs/en.xml! Did you download langs?');
}
$old_strings = editor_tinymce_get_all_strings('en');
ksort($old_strings);
// our modifications and upstream changes in existing strings
// Our modifications and upstream changes in existing strings.
$tweaked = array();
//detect changes and new additions
// Detect changes and new additions.
$parsed = editor_tinymce_parse_xml_lang("$tempdir/en.xml");
ksort($parsed);
foreach ($parsed as $key=>$value) {
@@ -76,7 +74,6 @@ if (!$handle = fopen($enfile, 'w')) {
$header = <<<EOT
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@@ -93,10 +90,9 @@ $header = <<<EOT
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'editor_tinymce', language 'en', branch 'MOODLE_20_STABLE'
* Strings for component 'editor_tinymce', language 'en'
*
* @package editor
* @subpackage tinymce
* @package editor_tinymce
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -110,7 +106,7 @@ foreach ($old_strings as $key=>$value) {
fwrite($handle, editor_tinymce_encode_stringline($key, $value));
}
fwrite($handle, "\n\n// == TinyMCE upstream lang strings from all plugins ==\n");
fwrite($handle, "\n\n// == TinyMCE upstream lang strings from all standard upstream plugins ==\n");
foreach ($parsed as $key=>$value) {
fwrite($handle, editor_tinymce_encode_stringline($key, $value));
}
@@ -124,7 +120,7 @@ if ($tweaked) {
fclose($handle);
//now update all other langs
// Now update all other langs.
$en_strings = editor_tinymce_get_all_strings('en');
if (!file_exists($targetlangdir)) {
echo "Can not find target lang dir: $targetlangdir !!";
+3 -10
View File
@@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@@ -16,10 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'editor_tinymce', language 'en', branch 'MOODLE_20_STABLE'
* Strings for component 'editor_tinymce', language 'en'
*
* @package editor
* @subpackage tinymce
* @package editor_tinymce
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -28,17 +26,12 @@
//== Custom Moodle strings that are not part of upstream TinyMCE ==
$string['common:browseimage'] = 'Find or upload an image...';
$string['common:browsemedia'] = 'Find or upload a sound, video or applet...';
$string['dragmath:dragmath_desc'] = 'Insert equation';
$string['dragmath:dragmath_javaneeded'] = 'To use this page you need a Java-enabled browser. Download the latest Java plug-in from {$a}.';
$string['dragmath:dragmath_title'] = 'DragMath Equation Editor';
$string['fontselectlist'] = 'Available fonts list';
$string['media_dlg:filename'] = 'Filename';
$string['moodleemoticon:desc'] = 'Insert emoticon';
$string['moodlenolink:desc'] = 'Prevent automatic linking';
$string['pluginname'] = 'TinyMCE HTML editor';
// == TinyMCE upstream lang strings from all plugins ==
// == TinyMCE upstream lang strings from all standard upstream plugins ==
$string['advanced:address'] = 'Address';
$string['advanced:anchor_delta_height'] = '';
$string['advanced:anchor_delta_width'] = '';
+100 -75
View File
@@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@@ -27,9 +26,13 @@
defined('MOODLE_INTERNAL') || die();
class tinymce_texteditor extends texteditor {
/** @var string active version - directory name */
public $version = '3.5.4.1';
/** @var string active version - this is the directory name where to find tinymce code */
public $version = '3.6.0';
/**
* Is the current browser supported by this editor?
* @return bool
*/
public function supported_by_browser() {
if (check_browser_version('MSIE', 6)) {
return true;
@@ -53,21 +56,44 @@ class tinymce_texteditor extends texteditor {
return false;
}
/**
* Returns array of supported text formats.
* @return array
*/
public function get_supported_formats() {
// FORMAT_MOODLE is not supported here, sorry.
return array(FORMAT_HTML => FORMAT_HTML);
}
/**
* Returns text format preferred by this editor.
* @return int
*/
public function get_preferred_format() {
return FORMAT_HTML;
}
/**
* Does this editor support picking from repositories?
* @return bool
*/
public function supports_repositories() {
return true;
}
/**
* Sets up head code if necessary.
*/
public function head_setup() {
}
/**
* Use this editor for give element.
*
* @param string $elementid
* @param array $options
* @param null $fpoptions
*/
public function use_editor($elementid, array $options=null, $fpoptions=null) {
global $PAGE;
if (debugging('', DEBUG_DEVELOPER)) {
@@ -83,6 +109,7 @@ class tinymce_texteditor extends texteditor {
protected function get_init_params($elementid, array $options=null) {
global $CFG, $PAGE, $OUTPUT;
require_once($CFG->dirroot . '/lib/editor/tinymce/classes/plugin.php');
//TODO: we need to implement user preferences that affect the editor setup too
@@ -96,82 +123,49 @@ class tinymce_texteditor extends texteditor {
$config = get_config('editor_tinymce');
$spelllanguagelist = empty($config->spelllanguagelist) ? '' : $config->spelllanguagelist;
$spellbutton = ($spelllanguagelist === '') ? '' : ',spellchecker';
$fontselectlist = empty($config->fontselectlist) ? '' : $config->fontselectlist;
$fontbutton = ($fontselectlist === '') ? '' : 'fontselect,';
$xmedia = 'moodlemedia,'; // HQ thinks it should be always on, so it is no matter if it will actually work or not
/*
if (!empty($options['legacy'])) {
$xmedia = 'moodlemedia,';
} else {
if (!empty($options['noclean']) or !empty($options['trusted'])) {
}
}*/
$filters = filter_get_active_in_context($context);
if (array_key_exists('filter/tex', $filters)) {
$xdragmath = 'dragmath,';
} else {
$xdragmath = '';
}
if (array_key_exists('filter/emoticon', $filters)) {
$xemoticon = 'moodleemoticon,';
} else {
$xemoticon = '';
}
$params = array(
'mode' => "exact",
'elements' => $elementid,
'relative_urls' => false,
'document_base_url' => $CFG->httpswwwroot,
'content_css' => $contentcss,
'language' => $lang,
'directionality' => $directionality,
'plugin_insertdate_dateFormat ' => $strdate,
'plugin_insertdate_timeFormat ' => $strtime,
'theme' => "advanced",
'skin' => "o2k7",
'skin_variant' => "silver",
'apply_source_formatting' => true,
'remove_script_host' => false,
'entity_encoding' => "raw",
'plugins' => "{$xmedia}advimage,safari,table,style,layer,advhr,advlink,emotions,inlinepopups,searchreplace,paste,directionality,fullscreen,moodlenolink,{$xemoticon}{$xdragmath}nonbreaking,contextmenu,insertdatetime,save,iespell,preview,print,noneditable,visualchars,xhtmlxtras,template,pagebreak,spellchecker",
'theme_advanced_font_sizes' => "1,2,3,4,5,6,7",
'theme_advanced_layout_manager' => "SimpleLayout",
'theme_advanced_toolbar_align' => "left",
'theme_advanced_buttons1' => "{$fontbutton}fontsizeselect,formatselect",
'theme_advanced_buttons1_add' => "|,undo,redo,|,search,replace,|,fullscreen",
'theme_advanced_buttons2' => "bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright",
'theme_advanced_buttons2_add' => "|,cleanup,removeformat,pastetext,pasteword,|,forecolor,backcolor,|,ltr,rtl",
'theme_advanced_buttons3' => "bullist,numlist,outdent,indent,|,link,unlink,moodlenolink,|,image,{$xemoticon}{$xmedia}{$xdragmath}nonbreaking,charmap",
'theme_advanced_buttons3_add' => "table,|,code{$spellbutton}",
'theme_advanced_fonts' => $fontselectlist,
'theme_advanced_resize_horizontal' => true,
'theme_advanced_resizing' => true,
'theme_advanced_resizing_min_height' => 30,
'min_height' => 30,
'theme_advanced_toolbar_location' => "top",
'theme_advanced_statusbar_location' => "bottom",
'spellchecker_rpc_url' => $CFG->httpswwwroot."/lib/editor/tinymce/tiny_mce/$this->version/plugins/spellchecker/rpc.php",
'spellchecker_languages' => $spelllanguagelist
);
if ($xemoticon) {
$manager = get_emoticon_manager();
$emoticons = $manager->get_emoticons();
$imgs = array();
// see the TinyMCE plugin moodleemoticon for how the emoticon index is (ab)used :-S
$index = 0;
foreach ($emoticons as $emoticon) {
$imgs[$emoticon->text] = $OUTPUT->render(
$manager->prepare_renderable_emoticon($emoticon, array('class' => 'emoticon emoticon-index-'.$index++)));
}
$params['moodleemoticon_emoticons'] = json_encode($imgs);
}
'moodle_config' => $config,
'mode' => "exact",
'elements' => $elementid,
'relative_urls' => false,
'document_base_url' => $CFG->httpswwwroot,
'moodle_plugin_base' => "$CFG->httpswwwroot/lib/editor/tinymce/plugins/",
'content_css' => $contentcss,
'language' => $lang,
'directionality' => $directionality,
'plugin_insertdate_dateFormat ' => $strdate,
'plugin_insertdate_timeFormat ' => $strtime,
'theme' => "advanced",
'skin' => "o2k7",
'skin_variant' => "silver",
'apply_source_formatting' => true,
'remove_script_host' => false,
'entity_encoding' => "raw",
'plugins' => 'safari,table,style,layer,advhr,advlink,emotions,inlinepopups,' .
'searchreplace,paste,directionality,fullscreen,nonbreaking,contextmenu,' .
'insertdatetime,save,iespell,preview,print,noneditable,visualchars,' .
'xhtmlxtras,template,pagebreak',
'theme_advanced_font_sizes' => "1,2,3,4,5,6,7",
'theme_advanced_layout_manager' => "SimpleLayout",
'theme_advanced_toolbar_align' => "left",
'theme_advanced_buttons1' => $fontbutton . 'fontsizeselect,formatselect,|,' .
'undo,redo,|,search,replace,|,fullscreen',
'theme_advanced_buttons2' => 'bold,italic,underline,strikethrough,sub,sup,|,' .
'justifyleft,justifycenter,justifyright,|,' .
'cleanup,removeformat,pastetext,pasteword,|,forecolor,backcolor,|,ltr,rtl',
'theme_advanced_buttons3' => 'bullist,numlist,outdent,indent,|,' .
'link,unlink,|,image,nonbreaking,charmap,table,|,code',
'theme_advanced_fonts' => $fontselectlist,
'theme_advanced_resize_horizontal' => true,
'theme_advanced_resizing' => true,
'theme_advanced_resizing_min_height' => 30,
'min_height' => 30,
'theme_advanced_toolbar_location' => "top",
'theme_advanced_statusbar_location' => "bottom",
);
if (!empty($options['legacy']) or !empty($options['noclean']) or !empty($options['trusted'])) {
// now deal somehow with non-standard tags, people scream when we do not make moodle code xtml strict,
@@ -192,6 +186,37 @@ class tinymce_texteditor extends texteditor {
if (!empty($options['required'])) {
$params['init_instance_callback'] = 'M.editor_tinymce.onblur_event';
}
// Allow plugins to adjust parameters.
editor_tinymce_plugin::all_update_init_params($params, $context, $options);
// Remove temporary parameters.
unset($params['moodle_config']);
return $params;
}
/**
* Gets a named plugin object. Will cause fatal error if plugin doesn't
* exist. This is intended for use by plugin files themselves.
*
* @param string $plugin Name of plugin e.g. 'moodleemoticon'
* @return editor_tinymce_plugin Plugin object
*/
public function get_plugin($plugin) {
global $CFG;
require_once($CFG->dirroot . '/lib/editor/tinymce/classes/plugin.php');
return editor_tinymce_plugin::get($plugin);
}
/**
* Equivalent to tinyMCE.baseURL value available from JavaScript,
* always use instead of /../ when referencing tinymce core code from moodle plugins!
*
* @return moodle_url url pointing to the root of TinyMCE javascript code.
*/
public function get_tinymce_base_url() {
global $CFG;
return new moodle_url("$CFG->httpswwwroot/lib/editor/tinymce/tiny_mce/$this->version/");
}
}
+21 -11
View File
@@ -14,10 +14,10 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* TinyMCE helper javascript functions
* TinyMCE helper javascript functions.
*
* @package editor_tinymce
* @copyright 2010 Petr Skoda (skodak) info@skoda.org
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -28,6 +28,16 @@ M.editor_tinymce.filepicker_options = M.editor_tinymce.filepicker_options || {};
M.editor_tinymce.init_editor = function(Y, editorid, options) {
M.editor_tinymce.editor_options[editorid] = options;
// Load necessary Moodle plugins into editor.
if (options.moodle_init_plugins) {
var extraplugins = options.moodle_init_plugins.split(',');
for (var i=0; i<extraplugins.length; i++) {
var filedetails = extraplugins[i].split(':');
tinyMCE.PluginManager.load(filedetails[0],
M.cfg.wwwroot + '/lib/editor/tinymce/plugins/' + filedetails[1]);
}
}
tinyMCE.init(options);
var item = document.getElementById(editorid+'_filemanager');
@@ -48,20 +58,20 @@ M.editor_tinymce.filepicker_callback = function(args) {
};
M.editor_tinymce.filepicker = function(target_id, url, type, win) {
YUI(M.yui.loader).use('core_filepicker', function (Y) {
YUI().use('core_filepicker', function (Y) {
var editor_id = tinyMCE.selectedInstance.editorId;
if (editor_id == 'mce_fullscreen') {
editor_id = tinyMCE.selectedInstance.settings.elements;
}
var options = null;
if (type == 'media') {
// when mediaw button clicked
// When media button clicked.
options = M.editor_tinymce.filepicker_options[editor_id]['media'];
} else if (type == 'file') {
// when link button clicked
// When link button clicked.
options = M.editor_tinymce.filepicker_options[editor_id]['link'];
} else if (type == 'image') {
// when image button clicked
// When image button clicked.
options = M.editor_tinymce.filepicker_options[editor_id]['image'];
}
@@ -73,17 +83,17 @@ M.editor_tinymce.filepicker = function(target_id, url, type, win) {
};
M.editor_tinymce.onblur_event = function(ed) {
//Attach event only after tinymce is intialized.
// Attach event only after tinymce is initialized.
if (ed.onInit != undefined) {
var s = ed.settings;
//Save before event is attached, so that if this event is not generated then textarea should
//have loaded contents and submitting form should not throw error.
// Save before event is attached, so that if this event is not generated then textarea should
// have loaded contents and submitting form should not throw error.
ed.save();
//Attach blur event for tinymce to save contents to textarea
// Attach blur event for tinymce to save contents to textarea.
var doc = s.content_editable ? ed.getBody() : (tinymce.isGecko ? ed.getDoc() : ed.getWin());
tinymce.dom.Event.add(doc, 'blur', function() {
//save contents to textarea before calling validation script.
// Save contents to textarea before calling validation script.
ed.save();
});
};
@@ -0,0 +1,86 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* DragMath equation editor popup.
*
* @package tinymce_dragmath
* @copyright 2008 Mauno Korpelainen
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_MOODLE_COOKIES', true);
require('../../../../../config.php');
$PAGE->set_context(context_system::instance());
$PAGE->set_url('/lib/editor/tinymce/plugins/dragmath/dragmath.php');
if (isset($SESSION->lang)) {
// Language is set via page url param.
$lang = $SESSION->lang;
} else {
$lang = 'en';
}
// Find DragMath language.
$langmapping = array('cs'=>'cz', 'pt_br'=>'pt-br');
// Fix non-standard lang names.
if (array_key_exists($lang, $langmapping)) {
$lang = $langmapping[$lang];
}
if (!file_exists("$CFG->dirroot/lib/dragmath/applet/lang/$lang.xml")) {
$lang = 'en';
}
$editor = get_texteditor('tinymce');
$plugin = $editor->get_plugin('dragmath');
// Prevent https security problems.
$relroot = preg_replace('|^http.?://[^/]+|', '', $CFG->wwwroot);
$htmllang = get_html_lang();
header('Content-Type: text/html; charset=utf-8');
?>
<!DOCTYPE html>
<html <?php echo $htmllang ?>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title><?php print_string('title', 'tinymce_dragmath')?></title>
<script type="text/javascript" src="<?php echo $editor->get_tinymce_base_url(); ?>tiny_mce_popup.js"></script>
<script type="text/javascript" src="<?php echo $plugin->get_tinymce_file_url('js/dragmath.js'); ?>"></script>
</head>
<body>
<object type="application/x-java-applet" id="dragmath" width="520" height="300">
<param name="java_codebase" value="<?php echo $relroot.'/lib/dragmath/applet/' ?>" />
<param name="java_code" value="Display/MainApplet.class" />
<param name="java_archive" value="DragMath.jar,lib/AbsoluteLayout.jar,lib/swing-layout-1.0.jar,lib/jdom.jar,lib/jep.jar" />
<param name="language" value="<?php echo $lang; ?>" />
<param name="outputFormat" value="MoodleTex" />
<?php print_string('javaneeded', 'tinymce_dragmath', '<a href="http://www.java.com">Java.com</a>')?>
</object>
<form name="form" action="#">
<div class="mceActionPanel">
<input type="submit" id="insert" name="insert" value="{#insert}" onclick="return DragMathDialog.insert();" />
<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="return tinyMCEPopup.close();" />
</div>
</form>
</body>
</html>
@@ -0,0 +1,30 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for DragMath editor integration plugin.
*
* @package tinymce_dragmath
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['javaneeded'] = 'To use this page you need a Java-enabled browser. Download the latest Java plug-in from {$a}.';
$string['pluginname'] = 'Insert equation';
$string['title'] = 'DragMath Equation Editor';
/* All lang strings used from TinyMCE JavaScript code must be named 'pluginname:stringname', no need to create langs/en_dlg.js */
$string['dragmath:desc'] = 'Insert equation';
@@ -0,0 +1,42 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
/**
* Plugin for DragMath equation editor (for use with TeX filter).
*
* @package tinymce_dragmath
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tinymce_dragmath extends editor_tinymce_plugin {
protected function update_init_params(array &$params, context $context,
array $options = null) {
// If TeX filter is disabled, do not add button.
$filters = filter_get_active_in_context($context);
if (!array_key_exists('filter/tex', $filters)) {
return;
}
// Add button before 'nonbreaking' in advancedbuttons3.
$this->add_button_before($params, 3, 'dragmath', 'nonbreaking');
// Add JS file, which uses default name.
$this->add_js_plugin($params);
}
}
@@ -0,0 +1,77 @@
(function() {
// Do not load plugin language packs in moodle plugins.
tinymce.create('tinymce.plugins.DragMathPlugin', {
/**
* Initializes the plugin, this will be executed after the plugin has been created.
* This call is done before the editor instance has finished it's initialization so use the onInit event
* of the editor instance to intercept that event.
*
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
* @param {string} url Absolute URL to where the plugin is located.
*/
init : function(ed, url) {
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
lang = tinyMCE.activeEditor.getParam('language');
ed.addCommand('mceDragMath', function() {
ed.windowManager.open({
file : ed.getParam("moodle_plugin_base") + 'dragmath/dragmath.php?lang=' + lang,
width : 540,
height : 380,
inline : 1
}, {
plugin_url : url, // Plugin absolute URL
some_custom_arg : 'custom arg' // Custom argument
});
});
// Register example button.
ed.addButton('dragmath', {
title : 'dragmath.desc',
cmd : 'mceDragMath',
image : url + '/img/dragmath.gif'
});
// Add a node change handler, selects the button in the UI when a image is selected.
ed.onNodeChange.add(function(ed, cm, n) {
cm.setActive('dragmath', n.nodeName == 'IMG');
});
},
/**
* Creates control instances based in the incomming name. This method is normally not
* needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
* but you sometimes need to create more complex controls like listboxes, split buttons etc then this
* method can be used to create those.
*
* @param {String} n Name of the control to create.
* @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
* @return {tinymce.ui.Control} New control instance or null if no control was created.
*/
createControl : function(n, cm) {
return null;
},
/**
* Returns information about the plugin as a name/value array.
* The current keys are longname, author, authorurl, infourl and version.
*
* @return {Object} Name/value array containing information about the plugin.
*/
getInfo : function() {
return {
longname : 'Moodle Dragmath plugin',
author : 'Glen Davies',
authorurl : 'http://www.canterbury.ac.nz',
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/example',
version : "1.0"
};
}
});
// Register plugin.
tinymce.PluginManager.add('dragmath', tinymce.plugins.DragMathPlugin);
})();

Before

Width:  |  Height:  |  Size: 166 B

After

Width:  |  Height:  |  Size: 166 B

@@ -1,14 +1,12 @@
tinyMCEPopup.requireLangPack();
var DragMathDialog = {
init : function(ed) {
},
insert : function(file, title) {
var ed = tinyMCEPopup.editor;
var tex = document.dragmath.getMathExpression();
var tex = document.getElementById('dragmath').getMathExpression();
// convert < and > to entities
// Convert < and > to entities.
tex = tex.replace('<', '&lt;');
tex = tex.replace('>', '&gt;');
@@ -15,16 +15,18 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Version details.
* TinyMCE DragMath plugin version details.
*
* @package tool
* @subpackage bloglevelupgrade
* @copyright 2011 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package tinymce_dragmath
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2012061700; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2012061700; // Requires this Moodle version
$plugin->component = 'tool_bloglevelupgrade'; // Full name of the plugin (used for diagnostics)
// The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2012051700;
// Required Moodle version.
$plugin->requires = 2011112900;
// Full name of the plugin (used for diagnostics).
$plugin->component = 'tinymce_dragmath';
+96
View File
@@ -0,0 +1,96 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Loader for resource files within TinyMCE plugins.
*
* This loader handles requests which have the plugin version number in. These
* requests are set to never expire from cache, to improve performance. Only
* files within the 'tinymce' folder of the plugin will be served.
*
* Note there are no access checks in this script - you do not have to be
* logged in to retrieve the plugin resource files.
*
* @package editor_tinymce
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_MOODLE_COOKIES', true);
require_once('../../../../config.php');
require_once($CFG->dirroot . '/lib/filelib.php');
require_once($CFG->dirroot . '/lib/jslib.php');
// Safely get slash params (cleaned using PARAM_PATH, without /../).
$path = get_file_argument();
// Param must be of the form [plugin]/[version]/[path] where path is a relative
// path inside the plugin tinymce folder.
$matches = array();
if (!preg_match('~^/([a-z0-9_]+)/((?:[0-9.]+)|-1)(/.*)$~', $path, $matches)) {
print_error('filenotfound');
}
list($junk, $tinymceplugin, $version, $innerpath) = $matches;
// Note that version number is totally ignored, user can specify anything,
// except for the difference between '-1' and anything else.
// Check the file exists.
$pluginfolder = $CFG->dirroot . '/lib/editor/tinymce/plugins/' . $tinymceplugin;
$file = $pluginfolder . '/tinymce' .$innerpath;
if (!file_exists($file)) {
print_error('filenotfound');
}
// We don't actually care what the version number is but there is a special
// case for '-1' which means, set the files to not be cached.
$allowcache = ($version !== '-1');
if ($allowcache) {
// Set it to expire a year later. Note that this means we should never get
// If-Modified-Since requests so there is no need to handle them specially.
header('Expires: ' . date('r', time() + 365 * 24 * 3600));
header('Cache-Control: max-age=' . 365 * 24 * 3600);
// Pragma is set to no-cache by default so must be overridden.
header('Pragma:');
}
// Get the right MIME type.
$mimetype = mimeinfo('type', $file);
// For JS files, these can be minified and stored in cache.
if ($mimetype === 'application/x-javascript' && $allowcache) {
// The cached file is stored without version number etc. This is okay
// because $CFG->cachedir is cleared each time there is a plugin update,
// such as a new version of a tinymce plugin.
// Flatten filename and include cache location.
$cache = $CFG->cachedir . '/editor_tinymce/pluginjs';
$cachefile = $cache . '/' . $tinymceplugin .
str_replace('/', '_', $innerpath);
// If it doesn't exist, minify it and save to that location.
if (!file_exists($cachefile)) {
$content = js_minify(array($file));
js_write_cache_file_content($cachefile, $content);
}
$file = $cachefile;
}
// Serve file.
header('Content-Length: ' . filesize($file));
header('Content-Type: ' . $mimetype);
readfile($file);
@@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@@ -18,31 +17,33 @@
/**
* Displays the TinyMCE popup window to insert a Moodle emoticon
*
* @package tinymceplugin
* @subpackage moodleemoticon
* @copyright 2010 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package tinymce_moodleemoticon
* @copyright 2010 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_MOODLE_COOKIES', true); // Session not used here
define('NO_UPGRADE_CHECK', true); // Ignore upgrade check
define('NO_MOODLE_COOKIES', true); // Session not used here.
require_once(dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))))) . '/config.php');
require(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . '/config.php');
$PAGE->set_context(get_system_context());
$PAGE->set_context(context_system::instance());
$PAGE->set_url('/lib/editor/tinymce/plugins/moodleemoticon/dialog.php');
$emoticonmanager = get_emoticon_manager();
$stringmanager = get_string_manager();
$editor = get_texteditor('tinymce');
$plugin = $editor->get_plugin('moodleemoticon');
$htmllang = get_html_lang();
header('Content-Type: text/html; charset=utf-8');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!DOCTYPE html>
<html <?php echo $htmllang ?>
<head>
<title><?php print_string('moodleemoticon:desc', 'editor_tinymce'); ?></title>
<script type="text/javascript" src="../../tiny_mce_popup.js?v=<?php echo $editor->version ?>"></script>
<script type="text/javascript" src="js/dialog.js?v=<?php echo $editor->version ?>"></script>
<title><?php print_string('moodleemoticon:desc', 'tinymce_moodleemoticon'); ?></title>
<script type="text/javascript" src="<?php echo $editor->get_tinymce_base_url(); ?>/tiny_mce_popup.js"></script>
<script type="text/javascript" src="<?php echo $plugin->get_tinymce_file_url('js/dialog.js'); ?>"></script>
</head>
<body>
@@ -50,7 +51,7 @@ $editor = get_texteditor('tinymce');
<?php
$emoticons = $emoticonmanager->get_emoticons();
// this is tricky - we must somehow include the information about the original
// This is tricky - we must somehow include the information about the original
// emoticon text so that we can replace the image back with it on editor save.
// so we are going to encode the index of the emoticon. this will break when the
// admin changes the mapping table while the user has the editor opened
@@ -15,16 +15,14 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Capability overview settings
* Strings for Moodle emoticon plugin.
*
* @package tool
* @subpackage bloglevelupgrade
* @copyright 2011 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package tinymce_moodleemoticon
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
$string['pluginname'] = 'Insert emoticon';
if ($hassiteconfig) {
$ADMIN->add('root', new admin_externalpage('toolbloglevelupgrade', get_string('pluginname', 'tool_bloglevelupgrade'), $CFG->wwwroot.'/'.$CFG->admin.'/tool/bloglevelupgrade/index.php', 'moodle/site:config', empty($CFG->tool_bloglevelupgrade_pending)));
}
/* All lang strings used from TinyMCE JavaScript code must be named 'pluginname:stringname', no need to create langs/en_dlg.js */
$string['moodleemoticon:desc'] = 'Insert emoticon';
@@ -0,0 +1,55 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
/**
* Plugin for Moodle emoticons.
*
* @package tinymce_moodleemoticon
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tinymce_moodleemoticon extends editor_tinymce_plugin {
protected function update_init_params(array &$params, context $context,
array $options = null) {
global $OUTPUT;
// If emoticon filter is disabled, do not add button.
$filters = filter_get_active_in_context($context);
if (!array_key_exists('filter/emoticon', $filters)) {
return;
}
// Add button after 'image' in advancedbuttons3.
$this->add_button_after($params, 3, 'moodleemoticon', 'image');
// Add JS file, which uses default name.
$this->add_js_plugin($params);
// Extra params specifically for emoticon plugin.
$manager = get_emoticon_manager();
$emoticons = $manager->get_emoticons();
$imgs = array();
// See the TinyMCE plugin moodleemoticon for how the emoticon index is (ab)used.
$index = 0;
foreach ($emoticons as $emoticon) {
$imgs[$emoticon->text] = $OUTPUT->render($manager->prepare_renderable_emoticon(
$emoticon, array('class' => 'emoticon emoticon-index-'.$index++)));
}
$params['moodleemoticon_emoticons'] = json_encode($imgs);
}
}
@@ -1,7 +1,7 @@
/**
* TinyMCE plugin MoodleEmoticon - provides GUI to insert emoticon images
* TinyMCE plugin MoodleEmoticon - provides GUI to insert emoticon images.
*
* Based on the example plugin (c) 2009 Moxiecode Systems AB
* Based on the example plugin (c) 2009 Moxiecode Systems AB.
*
* @author David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -11,7 +11,7 @@
tinymce.create('tinymce.plugins.MoodleEmoticon', {
/**
* Holds the list of emoticons provided by emoticon_manager
* Holds the list of emoticons provided by emoticon_manager.
*
* @private
*/
@@ -30,7 +30,7 @@
ed.addCommand('mceMoodleEmoticon', function() {
lang = ed.getParam('language');
ed.windowManager.open({
file : url + '/dialog.php?lang=' + lang ,
file : ed.getParam("moodle_plugin_base") + 'moodleemoticon/dialog.php?lang=' + lang ,
width : 250 + parseInt(ed.getLang('moodleemoticon.delta_width', 0)),
height : 400 + parseInt(ed.getLang('moodleemoticon.delta_height', 0)),
inline : 1
@@ -39,7 +39,7 @@
});
});
// Add an observer to the onInit event to convert emoticon texts to images
// Add an observer to the onInit event to convert emoticon texts to images.
ed.onInit.add(function(ed) {
var data = ed.getContent();
this._emoticons = tinymce.util.JSON.parse(ed.getParam('moodleemoticon_emoticons'));
@@ -54,7 +54,7 @@
ed.setContent(data);
});
// Add an observer to the onPreProcess event to convert emoticon images to texts
// Add an observer to the onPreProcess event to convert emoticon images to texts.
ed.onPreProcess.add(function(ed, o) {
if (o.save) {
tinymce.each(ed.dom.select('img.emoticon', o.node), function(image) {
@@ -80,7 +80,7 @@
}
});
// Register moodleemoticon button
// Register moodleemoticon button.
ed.addButton('moodleemoticon', {
title : 'moodleemoticon.desc',
cmd : 'mceMoodleEmoticon',
@@ -119,6 +119,6 @@
}
});
// Register plugin
// Register plugin.
tinymce.PluginManager.add('moodleemoticon', tinymce.plugins.MoodleEmoticon);
})();

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

@@ -1,7 +1,7 @@
var MoodleEmoticonDialog = {
init : function() {
// register event handlers for the table rows
// Register event handlers for the table rows.
tinymce.each(tinymce.DOM.select('tr.emoticoninfo', document), function(row) {
tinymce.dom.Event.add(row, 'mouseover', function(e) {
@@ -0,0 +1,32 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* TinyMCE emoticon plugin version details.
*
* @package tinymce_moodleemoticon
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
// The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2012051700;
// Required Moodle version.
$plugin->requires = 2011112900;
// Full name of the plugin (used for diagnostics).
$plugin->component = 'tinymce_moodleemoticon';
@@ -0,0 +1,27 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for Moodle Media plugin.
*
* @package tinymce_moodleimage
* @copyright 2012 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['pluginname'] = 'Insert image';
/* This plugin abuses strings from the standard TinyMCE advimage plugin, there is no need to duplicate them here. */
@@ -0,0 +1,39 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
/**
* Plugin for inserting and editing of images with Moodle file picker support.
*
* @package tinymce_moodleimage
* @copyright 2012 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tinymce_moodleimage extends editor_tinymce_plugin {
protected function update_init_params(array &$params, context $context,
array $options = null) {
// This plugin overrides standard 'image' button, no need to insert new button.
// Add JS file, which uses default name.
$this->add_js_plugin($params);
}
protected function get_sort_order() {
return 110;
}
}
@@ -6,7 +6,7 @@
padding: 3px 3px 3px 1.5em;
border:1px solid #ccc;
text-decoration:none;
background: url(../../../../../../../../pix/a/search.png) .2em .3em no-repeat;
background: url(search.png) .2em .3em no-repeat;
}
.moodlebutton:hover {background: #ccc}
.alignPreview {border:1px solid #000; width:140px; height:140px; overflow:hidden; padding:5px;}
Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

@@ -0,0 +1,50 @@
/**
* Based on 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
*/
(function() {
tinymce.create('tinymce.plugins.MoodleImagePlugin', {
init : function(ed, url) {
// Register commands
ed.addCommand('mceMoodleImage', function() {
// Internal image object like a flash placeholder
if (ed.dom.getAttrib(ed.selection.getNode(), 'class', '').indexOf('mceItem') != -1)
return;
ed.windowManager.open({
file : url + '/image.htm',
width : 480 + parseInt(ed.getLang('advimage.delta_width', 0)),
height : 385 + parseInt(ed.getLang('advimage.delta_height', 0)),
inline : 1
}, {
plugin_url : url
});
});
// Register buttons
ed.addButton('image', {
title : 'advimage.image_desc',
cmd : 'mceMoodleImage'
});
},
getInfo : function() {
return {
longname : 'Moodle image',
author : 'Moodle.com - based on AdvImage by Moxiecode Systems AB',
authorurl : 'http://moodle.org',
infourl : 'http://moodle.org',
version : '3.6.0' // Version of AdvImage plugin this plugin is based on.
};
}
});
// Register plugin
tinymce.PluginManager.add('moodleimage', tinymce.plugins.MoodleImagePlugin);
})();
@@ -1,16 +1,42 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{#advimage_dlg.dialog_title}</title>
<script type="text/javascript" src="../../tiny_mce_popup.js?v={tinymce_version}"></script>
<script type="text/javascript" src="../../utils/mctabs.js?v={tinymce_version}"></script>
<script type="text/javascript" src="../../utils/form_utils.js?v={tinymce_version}"></script>
<script type="text/javascript" src="../../utils/validate.js?v={tinymce_version}"></script>
<script type="text/javascript" src="../../utils/editable_selects.js?v={tinymce_version}"></script>
<script type="text/javascript" src="js/image.js?v={tinymce_version}"></script>
<link href="css/advimage.css?v={tinymce_version}" rel="stylesheet" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>{#advimage_dlg.dialog_title}</title>
<script type="text/javascript">
// Because there is no relative path to TinyMCE, we have to use JavaScript
// to work out correct path from the .js files from TinyMCE. Only files
// inside this plugin can be included with relative path (below).
var editor_tinymce_include = function(path) {
document.write('<script type="text/javascript" src="' +
parent.tinyMCE.baseURL + '/' + path + '"></' + 'script>');
};
editor_tinymce_include('tiny_mce_popup.js');
editor_tinymce_include('utils/mctabs.js');
editor_tinymce_include('utils/validate.js');
editor_tinymce_include('utils/form_utils.js');
editor_tinymce_include('utils/editable_selects.js');
var getImageBrowserHTML = function(id, target_form_element, type, prefix) {
var option = prefix + "_" + type + "_browser_callback", cb, html;
cb = tinyMCEPopup.getParam(option, tinyMCEPopup.getParam("file_browser_callback"));
if (!cb)
return "";
html = '<a class="moodlebutton" id="' + id + '_link" href="javascript:openBrowser(\'' + id + '\',\'' + target_form_element + '\', \'' + type + '\',\'' + option + '\');" onmousedown="return false;">';
html += '<span id="' + id + '">' + tinyMCEPopup.getLang('browseimage') + '</span>';
html += '</a>';
return html;
}
</script>
<script type="text/javascript" src="js/image.js"></script>
<link href="css/image.css" rel="stylesheet" type="text/css" />
</head>
<body id="advimage" style="display: none" role="application" aria-labelledby="app_title">
<body id="moodleimage" style="display: none" role="application" aria-labelledby="app_title">
<span id="app_title" style="display:none">{#advimage_dlg.dialog_title}</span>
<form onsubmit="ImageDialog.insert();return false;" action="#">
<div class="tabs">

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

@@ -0,0 +1,464 @@
var ImageDialog = {
preInit : function() {
var url;
tinyMCEPopup.requireLangPack();
if (url = tinyMCEPopup.getParam("external_image_list_url"))
document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
},
init : function(ed) {
var f = document.forms[0], nl = f.elements, ed = tinyMCEPopup.editor, dom = ed.dom, n = ed.selection.getNode(), fl = tinyMCEPopup.getParam('external_image_list', 'tinyMCEImageList');
tinyMCEPopup.resizeToInnerSize();
this.fillClassList('class_list');
this.fillFileList('src_list', fl);
this.fillFileList('over_list', fl);
this.fillFileList('out_list', fl);
TinyMCE_EditableSelects.init();
if (n.nodeName == 'IMG') {
nl.src.value = dom.getAttrib(n, 'src');
nl.width.value = dom.getAttrib(n, 'width');
nl.height.value = dom.getAttrib(n, 'height');
nl.alt.value = dom.getAttrib(n, 'alt');
nl.title.value = dom.getAttrib(n, 'title');
nl.vspace.value = this.getAttrib(n, 'vspace');
nl.hspace.value = this.getAttrib(n, 'hspace');
nl.border.value = this.getAttrib(n, 'border');
selectByValue(f, 'align', this.getAttrib(n, 'align'));
selectByValue(f, 'class_list', dom.getAttrib(n, 'class'), true, true);
nl.style.value = dom.getAttrib(n, 'style');
nl.id.value = dom.getAttrib(n, 'id');
nl.dir.value = dom.getAttrib(n, 'dir');
nl.lang.value = dom.getAttrib(n, 'lang');
nl.usemap.value = dom.getAttrib(n, 'usemap');
nl.longdesc.value = dom.getAttrib(n, 'longdesc');
nl.insert.value = ed.getLang('update');
if (/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/.test(dom.getAttrib(n, 'onmouseover')))
nl.onmouseoversrc.value = dom.getAttrib(n, 'onmouseover').replace(/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/, '$1');
if (/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/.test(dom.getAttrib(n, 'onmouseout')))
nl.onmouseoutsrc.value = dom.getAttrib(n, 'onmouseout').replace(/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/, '$1');
if (ed.settings.inline_styles) {
// Move attribs to styles
if (dom.getAttrib(n, 'align'))
this.updateStyle('align');
if (dom.getAttrib(n, 'hspace'))
this.updateStyle('hspace');
if (dom.getAttrib(n, 'border'))
this.updateStyle('border');
if (dom.getAttrib(n, 'vspace'))
this.updateStyle('vspace');
}
}
// Setup browse button
document.getElementById('srcbrowsercontainer').innerHTML = getImageBrowserHTML('srcbrowser','src','image','theme_advanced_image'); // Moodle hack
if (isVisible('srcbrowser'))
document.getElementById('src').style.width = '260px';
// Setup browse button
document.getElementById('onmouseoversrccontainer').innerHTML = getBrowserHTML('overbrowser','onmouseoversrc','image','theme_advanced_image');
if (isVisible('overbrowser'))
document.getElementById('onmouseoversrc').style.width = '260px';
// Setup browse button
document.getElementById('onmouseoutsrccontainer').innerHTML = getBrowserHTML('outbrowser','onmouseoutsrc','image','theme_advanced_image');
if (isVisible('outbrowser'))
document.getElementById('onmouseoutsrc').style.width = '260px';
// If option enabled default contrain proportions to checked
if (ed.getParam("advimage_constrain_proportions", true))
f.constrain.checked = true;
// Check swap image if valid data
if (nl.onmouseoversrc.value || nl.onmouseoutsrc.value)
this.setSwapImage(true);
else
this.setSwapImage(false);
this.changeAppearance();
this.showPreviewImage(nl.src.value, 1);
},
insert : function(file, title) {
var ed = tinyMCEPopup.editor, t = this, f = document.forms[0];
if (f.src.value === '') {
if (ed.selection.getNode().nodeName == 'IMG') {
ed.dom.remove(ed.selection.getNode());
ed.execCommand('mceRepaint');
}
tinyMCEPopup.close();
return;
}
if (tinyMCEPopup.getParam("accessibility_warnings", 1)) {
if (!f.alt.value) {
tinyMCEPopup.confirm(tinyMCEPopup.getLang('advimage_dlg.missing_alt'), function(s) {
if (s)
t.insertAndClose();
});
return;
}
}
t.insertAndClose();
},
insertAndClose : function() {
var ed = tinyMCEPopup.editor, f = document.forms[0], nl = f.elements, v, args = {}, el;
tinyMCEPopup.restoreSelection();
// Fixes crash in Safari
if (tinymce.isWebKit)
ed.getWin().focus();
if (!ed.settings.inline_styles) {
args = {
vspace : nl.vspace.value,
hspace : nl.hspace.value,
border : nl.border.value,
align : getSelectValue(f, 'align')
};
} else {
// Remove deprecated values
args = {
vspace : '',
hspace : '',
border : '',
align : ''
};
}
tinymce.extend(args, {
src : nl.src.value.replace(/ /g, '%20'),
width : nl.width.value,
height : nl.height.value,
alt : nl.alt.value,
title : nl.title.value,
'class' : getSelectValue(f, 'class_list'),
style : nl.style.value,
id : nl.id.value,
dir : nl.dir.value,
lang : nl.lang.value,
usemap : nl.usemap.value,
longdesc : nl.longdesc.value
});
args.onmouseover = args.onmouseout = '';
if (f.onmousemovecheck.checked) {
if (nl.onmouseoversrc.value)
args.onmouseover = "this.src='" + nl.onmouseoversrc.value + "';";
if (nl.onmouseoutsrc.value)
args.onmouseout = "this.src='" + nl.onmouseoutsrc.value + "';";
}
el = ed.selection.getNode();
if (el && el.nodeName == 'IMG') {
ed.dom.setAttribs(el, args);
} else {
tinymce.each(args, function(value, name) {
if (value === "") {
delete args[name];
}
});
ed.execCommand('mceInsertContent', false, tinyMCEPopup.editor.dom.createHTML('img', args), {skip_undo : 1});
ed.undoManager.add();
}
tinyMCEPopup.editor.execCommand('mceRepaint');
tinyMCEPopup.editor.focus();
tinyMCEPopup.close();
},
getAttrib : function(e, at) {
var ed = tinyMCEPopup.editor, dom = ed.dom, v, v2;
if (ed.settings.inline_styles) {
switch (at) {
case 'align':
if (v = dom.getStyle(e, 'float'))
return v;
if (v = dom.getStyle(e, 'vertical-align'))
return v;
break;
case 'hspace':
v = dom.getStyle(e, 'margin-left')
v2 = dom.getStyle(e, 'margin-right');
if (v && v == v2)
return parseInt(v.replace(/[^0-9]/g, ''));
break;
case 'vspace':
v = dom.getStyle(e, 'margin-top')
v2 = dom.getStyle(e, 'margin-bottom');
if (v && v == v2)
return parseInt(v.replace(/[^0-9]/g, ''));
break;
case 'border':
v = 0;
tinymce.each(['top', 'right', 'bottom', 'left'], function(sv) {
sv = dom.getStyle(e, 'border-' + sv + '-width');
// False or not the same as prev
if (!sv || (sv != v && v !== 0)) {
v = 0;
return false;
}
if (sv)
v = sv;
});
if (v)
return parseInt(v.replace(/[^0-9]/g, ''));
break;
}
}
if (v = dom.getAttrib(e, at))
return v;
return '';
},
setSwapImage : function(st) {
var f = document.forms[0];
f.onmousemovecheck.checked = st;
setBrowserDisabled('overbrowser', !st);
setBrowserDisabled('outbrowser', !st);
if (f.over_list)
f.over_list.disabled = !st;
if (f.out_list)
f.out_list.disabled = !st;
f.onmouseoversrc.disabled = !st;
f.onmouseoutsrc.disabled = !st;
},
fillClassList : function(id) {
var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl;
if (v = tinyMCEPopup.getParam('theme_advanced_styles')) {
cl = [];
tinymce.each(v.split(';'), function(v) {
var p = v.split('=');
cl.push({'title' : p[0], 'class' : p[1]});
});
} else
cl = tinyMCEPopup.editor.dom.getClasses();
if (cl.length > 0) {
lst.options.length = 0;
lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), '');
tinymce.each(cl, function(o) {
lst.options[lst.options.length] = new Option(o.title || o['class'], o['class']);
});
} else
dom.remove(dom.getParent(id, 'tr'));
},
fillFileList : function(id, l) {
var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl;
l = typeof(l) === 'function' ? l() : window[l];
lst.options.length = 0;
if (l && l.length > 0) {
lst.options[lst.options.length] = new Option('', '');
tinymce.each(l, function(o) {
lst.options[lst.options.length] = new Option(o[0], o[1]);
});
} else
dom.remove(dom.getParent(id, 'tr'));
},
resetImageData : function() {
var f = document.forms[0];
f.elements.width.value = f.elements.height.value = '';
},
updateImageData : function(img, st) {
var f = document.forms[0];
if (!st) {
f.elements.width.value = img.width;
f.elements.height.value = img.height;
}
this.preloadImg = img;
},
changeAppearance : function() {
var ed = tinyMCEPopup.editor, f = document.forms[0], img = document.getElementById('alignSampleImg');
if (img) {
if (ed.getParam('inline_styles')) {
ed.dom.setAttrib(img, 'style', f.style.value);
} else {
img.align = f.align.value;
img.border = f.border.value;
img.hspace = f.hspace.value;
img.vspace = f.vspace.value;
}
}
},
changeHeight : function() {
var f = document.forms[0], tp, t = this;
if (!f.constrain.checked || !t.preloadImg) {
return;
}
if (f.width.value == "" || f.height.value == "")
return;
tp = (parseInt(f.width.value) / parseInt(t.preloadImg.width)) * t.preloadImg.height;
f.height.value = tp.toFixed(0);
},
changeWidth : function() {
var f = document.forms[0], tp, t = this;
if (!f.constrain.checked || !t.preloadImg) {
return;
}
if (f.width.value == "" || f.height.value == "")
return;
tp = (parseInt(f.height.value) / parseInt(t.preloadImg.height)) * t.preloadImg.width;
f.width.value = tp.toFixed(0);
},
updateStyle : function(ty) {
var dom = tinyMCEPopup.dom, b, bStyle, bColor, v, isIE = tinymce.isIE, f = document.forms[0], img = dom.create('img', {style : dom.get('style').value});
if (tinyMCEPopup.editor.settings.inline_styles) {
// Handle align
if (ty == 'align') {
dom.setStyle(img, 'float', '');
dom.setStyle(img, 'vertical-align', '');
v = getSelectValue(f, 'align');
if (v) {
if (v == 'left' || v == 'right')
dom.setStyle(img, 'float', v);
else
img.style.verticalAlign = v;
}
}
// Handle border
if (ty == 'border') {
b = img.style.border ? img.style.border.split(' ') : [];
bStyle = dom.getStyle(img, 'border-style');
bColor = dom.getStyle(img, 'border-color');
dom.setStyle(img, 'border', '');
v = f.border.value;
if (v || v == '0') {
if (v == '0')
img.style.border = isIE ? '0' : '0 none none';
else {
var isOldIE = tinymce.isIE && (!document.documentMode || document.documentMode < 9);
if (b.length == 3 && b[isOldIE ? 2 : 1])
bStyle = b[isOldIE ? 2 : 1];
else if (!bStyle || bStyle == 'none')
bStyle = 'solid';
if (b.length == 3 && b[isIE ? 0 : 2])
bColor = b[isOldIE ? 0 : 2];
else if (!bColor || bColor == 'none')
bColor = 'black';
img.style.border = v + 'px ' + bStyle + ' ' + bColor;
}
}
}
// Handle hspace
if (ty == 'hspace') {
dom.setStyle(img, 'marginLeft', '');
dom.setStyle(img, 'marginRight', '');
v = f.hspace.value;
if (v) {
img.style.marginLeft = v + 'px';
img.style.marginRight = v + 'px';
}
}
// Handle vspace
if (ty == 'vspace') {
dom.setStyle(img, 'marginTop', '');
dom.setStyle(img, 'marginBottom', '');
v = f.vspace.value;
if (v) {
img.style.marginTop = v + 'px';
img.style.marginBottom = v + 'px';
}
}
// Merge
dom.get('style').value = dom.serializeStyle(dom.parseStyle(img.style.cssText), 'img');
}
},
changeMouseMove : function() {
},
showPreviewImage : function(u, st) {
if (!u) {
tinyMCEPopup.dom.setHTML('prev', '');
return;
}
if (!st && tinyMCEPopup.getParam("advimage_update_dimensions_onchange", true))
this.resetImageData();
u = tinyMCEPopup.editor.documentBaseURI.toAbsolute(u);
if (!st)
tinyMCEPopup.dom.setHTML('prev', '<img id="previewImg" src="' + u + '" border="0" onload="ImageDialog.updateImageData(this);" onerror="ImageDialog.resetImageData();" />');
else
tinyMCEPopup.dom.setHTML('prev', '<img id="previewImg" src="' + u + '" border="0" onload="ImageDialog.updateImageData(this, 1);" />');
}
};
ImageDialog.preInit();
tinyMCEPopup.onInit.add(ImageDialog.init, ImageDialog);
@@ -0,0 +1,32 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* TinyMCE image insert/edit plugin version details.
*
* @package tinymce_moodleimage
* @copyright 2012 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
// The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2012081000;
// Required Moodle version.
$plugin->requires = 2011112900;
// Full name of the plugin (used for diagnostics).
$plugin->component = 'tinymce_moodleimage';
@@ -0,0 +1,29 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for Moodle Media plugin.
*
* @package tinymce_moodlemedia
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['nopreview'] = 'Can not preview media.';
$string['pluginname'] = 'Insert media';
/* All lang strings used from TinyMCE JavaScript code must be named 'pluginname:stringname', no need to create langs/en_dlg.js */
$string['moodlemedia:desc'] = 'Insert Moodle media';
@@ -0,0 +1,47 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
/**
* Plugin for Moodle media (audio/video) insertion dialog.
*
* @package tinymce_moodlemedia
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tinymce_moodlemedia extends editor_tinymce_plugin {
protected function update_init_params(array &$params, context $context,
array $options = null) {
// Add button after emoticon button in advancedbuttons3.
$added = $this->add_button_after($params, 3, 'moodlemedia', 'moodleemoticon', false);
// Note: We know that the emoticon button has already been added, if it
// exists, because I set the sort order higher for this. So, if no
// emoticon, add after 'image'.
if (!$added) {
$this->add_button_after($params, 3, 'moodlemedia', 'image');
}
// Add JS file, which uses default name.
$this->add_js_plugin($params);
}
protected function get_sort_order() {
return 110;
}
}
@@ -17,29 +17,24 @@
/**
* Provides A/V preview features for the TinyMCE editor Moodle Media plugin.
* The preview is included in an iframe within the popup dialog.
* @package editor
* @subpackage tinymce
*
* @package tinymce_moodlemedia
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require(dirname(__FILE__) . '/../../../../../../../config.php');
require(dirname(__FILE__) . '/../../../../../config.php');
require_once($CFG->libdir . '/filelib.php');
require_once($CFG->libdir . '/editorlib.php');
require_once($CFG->libdir . '/editor/tinymce/lib.php');
// Must be logged in
require_login();
// Require path to draftfile.php file
$path = required_param('path', PARAM_PATH);
$editor = new tinymce_texteditor();
// Decode the url - it can not be passed around unencoded because security filters might block it.
$media = required_param('media', PARAM_RAW);
$media = base64_decode($media);
$url = clean_param($media, PARAM_URL);
$url = new moodle_url($url);
// Now output this file which is super-simple
$PAGE->set_pagelayout('embedded');
$PAGE->set_url(new moodle_url('/lib/editor/tinymce/tiny_mce/'.$editor->version.'/plugins/moodlemedia/preview.php',
array('path' => $path)));
$PAGE->set_url(new moodle_url('/lib/editor/tinymce/plugins/moodlemedia/preview.php'));
$PAGE->set_context(context_system::instance());
$PAGE->add_body_class('core_media_preview');
@@ -47,16 +42,11 @@ echo $OUTPUT->header();
$mediarenderer = $PAGE->get_renderer('core', 'media');
$path = '/'.trim($path, '/');
if (empty($CFG->slasharguments)) {
$url = new moodle_url('/draftfile.php', array('file'=>$path));
} else {
$url = new moodle_url('/draftfile.php');
$url->set_slashargument($path);
}
if ($mediarenderer->can_embed_url($url)) {
if (isloggedin() and !isguestuser() and $mediarenderer->can_embed_url($url)) {
require_sesskey();
echo $mediarenderer->embed_url($url);
} else {
print_string('nopreview', 'tinymce_moodlemedia');
}
echo $OUTPUT->footer();
@@ -1,11 +1,11 @@
#id, #name, #hspace, #vspace, #class_name, #align { width: 100px }
#id, #name, #hspace, #vspace, #class_name, #align { width: 100px }
.moodlebutton {
font-size: 1.5em;
font-weight:bold;
padding: 3px 3px 3px 1.5em;
border:1px solid #ccc;
text-decoration:none;
background: url(../../../../../../../../pix/a/search.png) .2em .3em no-repeat;
background: url(search.png) .2em .3em no-repeat;
}
.moodlebutton:hover {background: #ccc}
#hspace, #vspace { width: 50px }
@@ -14,8 +14,11 @@
#width, #height { width: 40px }
#src, #media_type { width: 250px }
#class { width: 120px }
#prev {margin: 0; border: 1px solid black; width: 380px; height: 230px; overflow: hidden }
.panel_wrapper div.current { height: 390px; overflow: auto }
#prev {margin: 0; border: 1px solid black; width: 430px; height: 330px; overflow: hidden }
.panel_wrapper div.current { height: 410px}
.panel_wrapper {border-top-style: solid}
.panel_wrapper {border-top-width: 1px}
.panel_wrapper {border-top-color: rgb(145, 155, 156)}
#flash_options, #shockwave_options, #qt_options, #wmp_options, #rmp_options { display: none }
.mceAddSelectValue { background-color: #DDDDDD }
#qt_starttime, #qt_endtime, #qt_fov, #qt_href, #qt_moveid, #qt_moviename, #qt_node, #qt_pan, #qt_qtsrc, #qt_qtsrcchokespeed, #qt_target, #qt_tilt, #qt_urlsubstituten, #qt_volume { width: 70px }
Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

@@ -0,0 +1,53 @@
/**
* @author Dongsheng Cai <[email protected]>
*/
(function() {
var each = tinymce.each;
tinymce.PluginManager.requireLangPack('moodlemedia');
tinymce.create('tinymce.plugins.MoodlemediaPlugin', {
init : function(ed, url) {
var t = this;
t.editor = ed;
t.url = url;
// Register commands.
ed.addCommand('mceMoodleMedia', function() {
ed.windowManager.open({
file : url + '/moodlemedia.htm',
width : 480 + parseInt(ed.getLang('media.delta_width', 0)),
height : 480 + parseInt(ed.getLang('media.delta_height', 0)),
inline : 1
}, {
plugin_url : url
});
});
// Register buttons.
ed.addButton('moodlemedia', {
title : 'moodlemedia.desc',
image : url + '/img/icon.gif',
cmd : 'mceMoodleMedia'});
},
_parse : function(s) {
return tinymce.util.JSON.parse('{' + s + '}');
},
getInfo : function() {
return {
longname : 'Moodle media',
author : 'Dongsheng Cai <[email protected]>',
version : "1.0"
};
}
});
// Register plugin.
tinymce.PluginManager.add('moodlemedia', tinymce.plugins.MoodlemediaPlugin);
})();

Before

Width:  |  Height:  |  Size: 910 B

After

Width:  |  Height:  |  Size: 910 B

@@ -0,0 +1,146 @@
/**
* @author Dongsheng Cai <[email protected]>
*/
// No need to require lang packs in moodle plugins.
var ed, url;
if (url = tinyMCEPopup.getParam("media_external_list_url")) {
document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
}
function init() {
ed = tinyMCEPopup.editor;
document.getElementById('filebrowsercontainer').innerHTML = getFileBrowserHTML('filebrowser','src','media','media');
}
function insertMedia() {
var f = document.forms[0];
var url = f.filename.value;
var linkname = url.substring(url.lastIndexOf('/')+1);
var h = '<a href="'+f.src.value+'">'+linkname+'</a>';
ed.execCommand('mceInsertContent', false, h);
tinyMCEPopup.close();
}
function serializeParameters() {
var d = document, s = '';
s += getStr(null, 'src');
// delete the tail comma
s = s.length > 0 ? s.substring(0, s.length - 1) : s;
return s;
}
function getStr(p, n, d) {
var e = document.forms[0].elements[(p != null ? p + "_" : "") + n];
var v = e.type == "hidden" ? e.value : e.options[e.selectedIndex].value;
if (n == 'src')
v = tinyMCEPopup.editor.convertURL(v, 'src', null);
return ((n == d || v == '') ? '' : n + ":'" + jsEncode(v) + "',");
}
function jsEncode(s) {
s = s.replace(new RegExp('\\\\', 'g'), '\\\\');
s = s.replace(new RegExp('"', 'g'), '\\"');
s = s.replace(new RegExp("'", 'g'), "\\'");
return s;
}
function generatePreview(c) {
var f = document.forms[0], p = document.getElementById('prev');
p.innerHTML = '<!-- x --->';
var re = new RegExp("(.+)\#(.+)", "i");
var result = f.src.value.match(re);
if (result) {
f.src.value = result[1];
f.filename.value = result[2];
} else {
f.src.value = f.src.value;
f.filename.value = f.src.value;
}
// After constrain
var pl = serializeParameters();
if (pl == '') {
p.innerHTML = '';
return;
}
pl = tinyMCEPopup.editor.plugins.moodlemedia._parse(pl);
if (!pl.src) {
p.innerHTML = '';
return;
}
pl.src = tinyMCEPopup.editor.documentBaseURI.toAbsolute(pl.src);
// NOTE: Do not try to prevent https security popups here - users would get them later on real page anyway!
// We can not include URL directly in parameters because some security filters might block it.
p.innerHTML = '<iframe src="' + tinyMCEPopup.editor.getParam("moodle_plugin_base") + 'moodlemedia/preview.php'
+ '?media=' + encodeURIComponent(encode64(pl.src.toString()))
+ '&sesskey=' + encodeURIComponent(parent.M.cfg.sesskey)
+ '" width="100%" height="100%"></iframe>';
}
function encode64(input) {
/*
CryptoMX Tools
Copyright (C) 2004 - 2006 Derek Buitenhuis
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var output = "";
var chr1, chr2, chr3 = "";
var enc1, enc2, enc3, enc4 = "";
var i = 0;
do {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output +
keyStr.charAt(enc1) +
keyStr.charAt(enc2) +
keyStr.charAt(enc3) +
keyStr.charAt(enc4);
chr1 = chr2 = chr3 = "";
enc1 = enc2 = enc3 = enc4 = "";
} while (i < input.length);
return output;
}
tinyMCEPopup.onInit.add(init);
@@ -0,0 +1,73 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>{#moodlemedia.desc}</title>
<script type="text/javascript">
// Because there is no relative path to TinyMCE, we have to use JavaScript
// to work out correct path from the .js files from TinyMCE. Only files
// inside this plugin can be included with relative path (below).
var editor_tinymce_include = function(path) {
document.write('<script type="text/javascript" src="' +
parent.tinyMCE.baseURL + '/' + path + '"></' + 'script>');
};
editor_tinymce_include('tiny_mce_popup.js');
editor_tinymce_include('utils/validate.js');
editor_tinymce_include('utils/form_utils.js');
editor_tinymce_include('utils/editable_selects.js');
var getFileBrowserHTML = function(id, target_form_element, type, prefix) {
var option = prefix + "_" + type + "_browser_callback", cb, html;
cb = tinyMCEPopup.getParam(option, tinyMCEPopup.getParam("file_browser_callback"));
if (!cb)
return "";
html = '<a class="moodlebutton" id="' + id + '_link" href="javascript:openBrowser(\'' + id + '\',\'' + target_form_element + '\', \'' + type + '\',\'' + option + '\');" onmousedown="return false;">';
html += '<span id="' + id + '">' + tinyMCEPopup.getLang('browsemedia') + '</span>';
html += '</a>';
return html;
}
</script>
<script type="text/javascript" src="js/media.js"></script>
<link href="css/media.css" rel="stylesheet" type="text/css" />
</head>
<body style="display: none">
<form onsubmit="insertMedia();return false;" action="#">
<div class="panel_wrapper">
<div id="general_panel" class="panel current">
<input id="src" name="src" type="hidden" value="" class="mceFocus" onchange="generatePreview();" />
<input id="filename" name="filename" type="hidden" value="" />
<fieldset>
<legend>{#media_dlg.general}</legend>
<table align="center" border="0" cellpadding="4" cellspacing="0">
<tr align="center">
<td colspan='2' id="filebrowsercontainer">&nbsp;</td>
</tr>
</table>
</fieldset>
<fieldset>
<legend>{#media_dlg.preview}</legend>
<div id="prev"></div>
</fieldset>
</div>
</div>
<div class="mceActionPanel">
<div style="float: left">
<input type="submit" id="insert" name="insert" value="{#insert}" />
</div>
<div style="float: right">
<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
</div>
</div>
</form>
</body>
</html>
@@ -0,0 +1,32 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* TinyMCE media insert plugin version details.
*
* @package tinymce_moodlemedia
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
// The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2012051701;
// Required Moodle version.
$plugin->requires = 2011112900;
// Full name of the plugin (used for diagnostics).
$plugin->component = 'tinymce_moodlemedia';
@@ -0,0 +1,28 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for 'no link' plugin.
*
* @package tinymce_moodlenolink
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['pluginname'] = 'Prevent automatic linking';
/* All lang strings used from TinyMCE JavaScript code must be named 'pluginname:stringname', no need to create langs/en_dlg.js */
$string['moodlenolink:desc'] = 'Prevent automatic linking';
@@ -0,0 +1,36 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
/**
* Plugin for Moodle 'no link' button.
*
* @package tinymce_moodlenolink
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tinymce_moodlenolink extends editor_tinymce_plugin {
protected function update_init_params(array &$params, context $context,
array $options = null) {
// Add button after 'unlink' in advancedbuttons3.
$this->add_button_after($params, 3, 'moodlenolink', 'unlink');
// Add JS file, which uses default name.
$this->add_js_plugin($params);
}
}
@@ -0,0 +1,77 @@
/**
* @author Mathieu Petit-Clair
*/
(function() {
// Do not load language pack in moodle plugins.
tinymce.create('tinymce.plugins.moodlenolinkPlugin', {
/**
* Initializes the plugin, this will be executed after the plugin has been created.
* This call is done before the editor instance has finished it's initialization so use the onInit event
* of the editor instance to intercept that event.
*
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
* @param {string} url Absolute URL to where the plugin is located.
*/
init : function(ed, url) {
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceMoodleNolink');
ed.addCommand('mceMoodleNolink', function() {
var n, p;
n = ed.selection.getNode();
p = ed.dom.getParent(n, function(t) {
return ed.dom.getAttrib(t, 'class') == 'nolink';
});
if (p) {
ed.dom.remove(p, true);
} else {
ed.selection.setContent('<span class="nolink">' + ed.selection.getContent() + '</span>');
}
});
// Register moodlenolink button
ed.addButton('moodlenolink', {
title : 'moodlenolink.desc',
cmd : 'mceMoodleNolink',
image : url + '/img/ed_nolink.gif'
});
// Add a node change handler, selects the button in the UI when a image is selected
ed.onNodeChange.add(function(ed, cm, n) {
var p, c;
c = cm.get('moodlenolink');
p = ed.dom.getParent(n, 'SPAN');
c.setActive(p && ed.dom.hasClass(p, 'nolink'));
if (p && ed.dom.hasClass(p, 'nolink') || ed.selection.getContent()) {
c.setDisabled(false);
} else {
c.setDisabled(true);
}
});
},
/**
* Returns information about the plugin as a name/value array.
* The current keys are longname, author, authorurl, infourl and version.
*
* @return {Object} Name/value array containing information about the plugin.
*/
getInfo : function() {
return {
longname : 'moodlenolink plugin',
author : 'Mathieu Petit-Clair',
authorurl : 'http://moodle.com/hq',
infourl : 'http://docs.moodle.org/en/TinyMCE',
version : "1.0"
};
}
});
// Register plugin.
tinymce.PluginManager.add('moodlenolink', tinymce.plugins.moodlenolinkPlugin);
})();

Before

Width:  |  Height:  |  Size: 180 B

After

Width:  |  Height:  |  Size: 180 B

@@ -0,0 +1,32 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* TinyMCE no-link marker plugin version details.
*
* @package tinymce_moodlenolink
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
// The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2012051700;
// Required Moodle version.
$plugin->requires = 2011112900;
// Full name of the plugin (used for diagnostics).
$plugin->component = 'tinymce_moodlenolink';
@@ -0,0 +1,51 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Spellchecker configuration. (Has been rewritten for Moodle.)
*
* @package tinymce_spellchecker
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require('../../../../../config.php');
@error_reporting(E_ALL ^ E_NOTICE); // Hide notices even if Moodle is configured to show them.
// General settings
$config['general.engine'] = get_config('editor_tinymce', 'spellengine') ?
get_config('editor_tinymce', 'spellengine') : 'GoogleSpell';
// GoogleSpell settings
$config['GoogleSpell.proxyhost'] = isset($CFG->proxyhost) ? $CFG->proxyhost : '';
$config['GoogleSpell.proxyport'] = isset($CFG->proxyport) ? $CFG->proxyport : '';
$config['GoogleSpell.proxytype'] = isset($CFG->proxytype) ? $CFG->proxytype : 'HTML';
$config['GoogleSpell.proxyuser'] = isset($CFG->proxyuser) ? $CFG->proxyuser : '';
$config['GoogleSpell.proxypassword'] = isset($CFG->proxypassword) ? $CFG->proxypassword : '';
if ($config['general.engine'] === 'PSpell' || $config['general.engine'] === 'PSpellShell') {
// PSpell settings
$config['PSpell.mode'] = PSPELL_FAST;
$config['PSpell.spelling'] = "";
$config['PSpell.jargon'] = "";
$config['PSpell.encoding'] = "";
// PSpellShell settings
$config['PSpellShell.mode'] = PSPELL_FAST;
$config['PSpellShell.aspell'] = $CFG->aspellpath;
$config['PSpellShell.tmp'] = '/tmp';
}
@@ -0,0 +1,27 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for Moodle Media plugin.
*
* @package tinymce_spellchecker
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['pluginname'] = 'Check spelling';
/* This plugin abuses strings from the standard TinyMCE spellchecker plugin, there is no need to duplicate them here. */
@@ -0,0 +1,46 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
/**
* Plugin for spell checking (Moodle custom replacement for standard TinyMCE
* plugin, but with same name, which seems a bit unhelpful).
*
* @package tinymce_spellchecker
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tinymce_spellchecker extends editor_tinymce_plugin {
protected function update_init_params(array &$params, context $context,
array $options = null) {
global $CFG;
// Check at least one language is supported.
$config = $params['moodle_config'];
$spelllanguagelist = empty($config->spelllanguagelist) ? '' : $config->spelllanguagelist;
if ($spelllanguagelist !== '') {
// Add button after code button in advancedbuttons3.
$added = $this->add_button_after($params, 3, 'spellchecker', 'code', false);
// Add JS file, which uses default name.
$this->add_js_plugin($params);
$params['spellchecker_rpc_url'] = $CFG->httpswwwroot .
'/lib/editor/tinymce/plugins/spellchecker/rpc.php';
$params['spellchecker_languages'] = $spelllanguagelist;
}
}
}

Some files were not shown because too many files have changed in this diff Show More