Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

started Moodle 2.0 integration work.

--HG--
extra : convert_revision : svn%3Afc1ba2b4-ac28-11dd-a772-7fcde58d38e6/trunk%40107
  • Loading branch information...
commit 2956dd4d9a896abcbcdfdc8732e456c253f5e6d2 1 parent 089b1c0
mihai.sucan authored
View
17 CHANGES
@@ -1,3 +1,20 @@
+2009-08-10:
+===========
+
+- Started work on Moodle 2.0 integration. Moodle 1.9 integration has been
+postponed for a number of reasons. Further details in an upcoming blog post at
+robodesign.ro/mihai.
+
+- New script for localization integration specific to Moodle 2.0 - see
+update_tinymcelang.pnp.
+
+- Improved/fixed gen_moodlelang.php.
+
+- Moved the TODO file to the Google Code wiki:
+http://code.google.com/p/paintweb/wiki/TODO
+
+The wiki page includes new items and some fixes.
+
2009-08-03:
===========
View
96 TODO
@@ -1,96 +0,0 @@
-$Author: Mihai Şucan $
-$URL: http://code.google.com/p/paintweb $
-$Date: 2009-07-30 14:35:21 +0300 $
-
-Until the end of GSOC:
-
-- Integrate into TinyMCE and Moodle.
-- Color theme for the OLPC XO.
-
-As quick as possible, after GSOC 2009:
-
-- report browser bugs:
- - when strokeText() is used shadows do not render (Webkit, needs recheck).
- - elem.hasAttribute('data-whatever') fails to return true when it should do
- so. The problem affects Webkit.
- - outlines are drawn irrespective of z-index in Opera 9.6 and Opera 10.
- - serious redraw issues with the color mixer when the colormixer_selector tab
- panel has some width set. The problem affects Opera 9.6 and Opera 10.
- - globalCompositeOperation + gradients renders mildly different in Google
- Chrome 2 on Windows, compared to the other browsers. To see this, test the RGB
- color space visualisation in the color mixer. I cannot reproduce the issue
- with Google Chrome 3 on Linux.
- - images cannot be selected in editable content, on Webkit - in some special
- cases.
- - images with data URL are considered external, and thus when drawn on Canvas
- they cause security violations, in Webkit and Gecko 1.9.0 (fixed in 1.9.1).
-
-- implement the GUI improvements suggested by Olli Savolainen.
-- new tools: bucket, pencil v2 (avec pression).
-- toolRegister creates instances of tool objects automatically.
- - cleanup interface script from having hard-coded stuff related to tools.
-- investigate the use of an iframe to hold the whole PaintWeb interface because
-I can have style sandboxing and other advantages.
-- allow integration by specifying a form input to replace.
-- provide API to load language strings on demand.
-- provide API to load configurations on demand.
-- viewport resize handle.
-- double-click on the tab bar to hide its content and only show a minimal list
-of tabs.
-- allow canvas resize on the right and at the bottom - not just the south-east
-resize handle.
-- allow single click on the image size, in the status bar to bring-up a panel
-which shows the image dimensions, where the user can crop and resize the image.
-- implement a GUI option to allow live changing of background color.
-- flip and rotate image.
-- some issues when middle/right clicking instead of simple left click on the
-canvas, with some drawing tools.
-- maybe selection rotate.
-- maybe use .scale() and .translate() for selection manipulation.
-- more per-tool settings. For example, do not share the lineWidth option between
-tools.
-- css 3 animations for the GUI.
-- make the color mixer resizable.
-- attempt color mixer code organization / code quality improvements.
-- look into performance improvement specific to the color mixer.
-- allow mousewheel scrolling on the color mixer slider.
-- allow the user to focus the color mixer slider, to press up/down keys.
-- allow the user to press Enter in the color mixer in an input to simply accept
-the current color.
-- (maybe) allow the user to press Escape in an input from the color mixer to
-close/cancel the color change.
-- retest overall performance and see if more things can be improved. More
-importantly, try initialization performance improvements.
-- allow mousewheel scroll to increase/decrease the numeric value in an input of
-type=number.
-- allow permanent color save in the color mixer.
-- add a checkbox into the color mixer which allows the user to enable realtime
-color changes, such that, without clicking accept, the user can test the new
-color using some drawing tool.
-- tab reordering and grouping.
-
-Each and every item is doable pretty "easy", but it takes a lot of time to do
-all of the above. Some of the items might get dropped. On request, I can
-prioritize any item from the list during GSOC.
-
-Further down the road:
-
-* allow editing of multiple images in a single paintweb instance;
-* hybrid undo system, not like now (storing ImageDatas);
-* hybrid drawing: vectorial + bitmap drawing;
-* layers;
-* non-destructive filters;
-* color gradients and fill patterns;
-* macros: look into the possibility of implementing a scripting API compatible
- with that of Photoshop. Photoshop can run JavaScript. PaintWeb can run
- JavaScript: just provide the same API. Obviously, PaintWeb could implement
- only a subset, but it would be very good if this kind of work would be
- successful.
-
-That should be all for now. Huh, lots of work to do.
-
-Volunteers are needed! Please contact me if you want to help. Thank you! ;)
-
---
-vim:set spell spl=en fenc=utf-8 ff=unix:
-
View
19 ext/moodle/gen_moodlelang.php
@@ -18,7 +18,7 @@
* along with PaintWeb. If not, see <http://www.gnu.org/licenses/>.
*
* $URL: http://code.google.com/p/paintweb $
- * $Date: 2009-08-03 19:46:27 +0300 $
+ * $Date: 2009-08-10 20:41:45 +0300 $
*/
// This script allows you to convert PaintWeb JSON language files into Moodle
@@ -36,6 +36,8 @@
// Warning: running this script will overwrite "paintweb.php" in your Moodle
// lang/*/ folders.
+// This script works with Moodle 1.9 and Moodle 2.0.
+
$paintweblangdir = '../../build/lang';
$moodlelangdir = '../../../../lang';
$moodlelangfile = 'paintweb.php';
@@ -72,17 +74,19 @@
* Convert a PaintWeb JSON language file to a Moodle PHP language file.
*
* @param string $file The file you want to convert.
+ * @return boolean True if the operation executed successfully, or false
+ * otherwise.
*/
function paintweb_convert_json_file($file) {
global $moodlelangdir, $moodlelangfile, $paintweblangdir;
- $lang = str_replace('.json', '', $file);
+ $lang = basename($file, '.json');
$outputfolder = $moodlelangdir . '/' . ($lang === 'en' ? 'en_utf8' : $lang);
if (!is_dir($outputfolder)) {
echo "Skipping $file because $outputfolder was not found.\n";
- continue;
+ return false;
}
$langparsed = file_get_contents($paintweblangdir . '/' . $file);
@@ -91,7 +95,7 @@ function paintweb_convert_json_file($file) {
$langparsed = json_decode($langparsed, true);
if (!$langparsed) {
echo "Parsing $file failed. \n";
- continue;
+ return false;
}
$output = "<?php\n". paintweb_json2php($langparsed);
@@ -101,6 +105,8 @@ function paintweb_convert_json_file($file) {
} else {
echo "Failed to write $outputfolder/$moodlelangfile\n";
}
+
+ return true;
}
/**
@@ -118,8 +124,9 @@ function paintweb_json2php($obj, $prefix='') {
if (is_array($val)) {
$result .= paintweb_json2php($val, $prefix . $key . ':');
} else {
- $val = str_replace("'", "\\'", $val);
- $result .= "\$string['$prefix$key'] = '" . $val . "';\n";
+ $key = var_export($prefix . $key, true);
+ $val = var_export($val, true);
+ $result .= "\$string[$key] = $val;\n";
}
}
View
4 ext/moodle/gen_paintweblang.php
@@ -18,7 +18,7 @@
* along with PaintWeb. If not, see <http://www.gnu.org/licenses/>.
*
* $URL: http://code.google.com/p/paintweb $
- * $Date: 2009-08-03 19:35:04 +0300 $
+ * $Date: 2009-08-10 15:58:48 +0300 $
*/
// This script allows you to convert a Moodle PHP language file into a PaintWeb
@@ -32,6 +32,8 @@
// Warning: running this script will overwrite the JSON language file from the
// PaintWeb language folder.
+// This script works with Moodle 1.9 and Moodle 2.0.
+
$paintweblangdir = '../../build/lang';
$moodlelangdir = '../../../../lang';
$moodlelangfile = 'paintweb.php';
View
5 ext/moodle/lang.json.php
@@ -18,12 +18,15 @@
* along with PaintWeb. If not, see <http://www.gnu.org/licenses/>.
*
* $URL: http://code.google.com/p/paintweb $
- * $Date: 2009-08-03 21:17:30 +0300 $
+ * $Date: 2009-08-10 21:55:57 +0300 $
*/
// This script generates the PaintWeb JSON language file dynamically using the
// Moodle language files. The language picked is the one configured in Moodle.
+
+// This script works with Moodle 1.9 and Moodle 2.0.
+
require_once('../../../../config.php');
$moodlelangdir = '../../../../lang';
View
175 ext/moodle/update_tinymcelang.php
@@ -0,0 +1,175 @@
+<?php
+/*
+ * Copyright (C) 2009 Mihai Şucan
+ *
+ * This file is part of PaintWeb.
+ *
+ * PaintWeb 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.
+ *
+ * PaintWeb 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 PaintWeb. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * $URL: http://code.google.com/p/paintweb $
+ * $Date: 2009-08-10 21:12:30 +0300 $
+ */
+
+// This script allows you to update the TinyMCE language files from Moodle to
+// hold the new strings of the TinyMCE plugin provided by PaintWeb.
+
+// In a typical setup, Moodle holds PaintWeb in lib/paintweb.
+
+// If you execute this script without any arguments, all the language files
+// found in the TinyMCE plugin folder will be converted to the Moodle PHP
+// language file format. The new strings will be appended to the
+// editor_tinymce.php file from the Moodle languages folder.
+//
+// Optionally, you can give this script one argument, to tell it which language
+// you want to update. This allows you to update only one language file, instead
+// of all at once.
+
+// This script works only with Moodle 2.0.
+
+$pluginlangdir = '../tinymce-plugin/paintweb/langs';
+$moodlelangdir = '../../../../lang';
+$tinymcelangfile = 'editor_tinymce.php';
+
+if (!is_dir($pluginlangdir)) {
+ echo "The TinyMCE plugin folder could not be found: $paintweblangdir\n";
+ return 1;
+}
+
+if (!is_dir($moodlelangdir)) {
+ echo "The Moodle folder could not be found: $moodlelangdir\n";
+ return 1;
+}
+
+if (isset($_SERVER['argv'][1])) {
+ $file = $_SERVER['argv'][1] . '.js';
+
+ if (!file_exists($pluginlangdir . '/' . $file)) {
+ echo "The TinyMCE plugin language file was not found: $pluginlangdir/$file\n";
+ return 1;
+ }
+
+ if (!paintweb_update_tinymcelang($file)) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+$files = glob($pluginlangdir . '/*.js');
+foreach ($files as $file) {
+ echo "Reading $file.\n";
+ paintweb_update_tinymcelang($file);
+}
+
+/**
+ * Update a TinyMCE language file from the Moodle language folder
+ * (editor_tinymce.php) to include the language strings from the TinyMCE plugin
+ * provided by PaintWeb (see ext/tinymce-plugin/paintweb/langs).
+ *
+ * @param string $file The TinyMCE plugin language file (for example en.js) you
+ * want to read in order to update the associated editor_tinymce.php file from
+ * the Moodle language folder.
+ *
+ * @return boolean True if the operation was successful or false otherwise.
+ */
+function paintweb_update_tinymcelang($file) {
+ global $moodlelangdir, $tinymcelangfile, $pluginlangdir;
+
+ if (empty($file)) {
+ return false;
+ }
+
+ $file = basename($file);
+ $lang = substr($file, 0, 2);
+
+ $content = file_get_contents($pluginlangdir . '/' . $file);
+ if (empty($content)) {
+ echo "Failed to read $pluginlangdir/$file\n";
+ return false;
+ }
+
+ if ($lang === 'en') {
+ $filephp = "$moodlelangdir/en_utf8/$tinymcelangfile";
+ } else {
+ $filephp = "$moodlelangdir/$lang/$tinymcelangfile";
+ }
+
+ if (!file_exists($filephp)) {
+ echo "Skipping $lang. File not found: $filephp\n";
+ return false;
+ }
+
+ $output = file_get_contents($filephp);
+ if (empty($output)) {
+ echo "Failed to read $filephp\n";
+ return false;
+ }
+ include($filephp);
+
+ $group = '';
+ $content = explode("\n", $content);
+ $json = '';
+ foreach ($content as $line) {
+ $matches = array();
+
+ if (empty($line)) {
+ continue;
+ }
+
+ if (preg_match('/tinymce\.addi18n\s*\([\'"][a-z]+\.([^\']+)[\'"]\s*,\s*\{/i', $line, $matches)) {
+ $group = $matches[1];
+
+ } else if (!empty($group) && preg_match('/}\s*\)\s*;*/', $line)) {
+ $group = '';
+
+ } else if (!empty($group) && preg_match('/^\s*([\'"]*)(.+?)\1\s*:\s*([\'"])(.+?)\3\s*,?/', $line, $matches)) {
+ $json .= ',"' . $group . ':' . $matches[2] .'": "' . $matches[4] . "\"";
+ }
+ }
+
+ if (empty($json)) {
+ echo "No string was found in the language file $pluginlangdir/$file\n";
+ return false;
+ }
+
+ $json = json_decode('{' . substr($json, 1) . '}');
+
+ if (empty($json)) {
+ echo "Failed to parse the language file $pluginlangdir/$file\n";
+ return false;
+ }
+
+ foreach ($json as $key => $val) {
+ $key2 = var_export($key, true);
+ $val = var_export($val, true);
+ $line = "\$string[$key2] = $val;\n";
+
+ if (isset($string[$key])) {
+ $output = preg_replace('/^\$string[' . $key2 . '].+$/', $line, $output);
+ } else {
+ $output .= $line;
+ }
+ }
+
+ if (file_put_contents($filephp, $output)) {
+ echo "Updated $filephp.\n";
+ return true;
+ } else {
+ echo "Failed to update $filephp.\n";
+ return false;
+ }
+}
+
+// vim:set spell spl=en fo=tanqrowcb tw=80 ts=4 sw=4 sts=4 sta et noai nocin fenc=utf-8 ff=unix:
+
View
16 src/includes/lib.js
@@ -2,7 +2,7 @@
* © 2009 ROBO Design
* http://www.robodesign.ro
*
- * $Date: 2009-07-30 19:20:27 +0300 $
+ * $Date: 2009-08-04 19:34:48 +0300 $
*/
/**
@@ -185,15 +185,18 @@ pwlib.jsonParse = function (str) {
*
* @param {String} [method="GET"] The HTTP method to use for loading the URL.
*
- * @param {String} [send] The string you want to send in an HTTP POST request.
+ * @param {String} [send=null] The string you want to send in an HTTP POST
+ * request.
*
* @param {Object} [headers] An object holding the header names and values you
* want to set for the request.
*
* @returns {XMLHttpRequest} The XMLHttpRequest object created by this method.
+ *
+ * @throws {TypeError} If the <var>url</var> is not a string.
*/
pwlib.xhrLoad = function (url, handler, method, send, headers) {
- if (!url) {
+ if (typeof url !== 'string') {
throw new TypeError('The first argument must be a string!');
}
@@ -209,7 +212,9 @@ pwlib.xhrLoad = function (url, handler, method, send, headers) {
send = null;
}
+ /** @ignore */
var xhr = new XMLHttpRequest();
+ /** @ignore */
xhr.onreadystatechange = function () { handler(xhr); };
xhr.open(method, url);
@@ -2144,12 +2149,15 @@ pwlib.dom.KeyboardEventListener = function (elem_, handlers_) {
} else {
// This happens when the keydown event tries to dispatch a keypress event.
- // FIXME: I could use createEvent() ... food for thought for later
+ // FIXME: I could use createEvent() ... food for thought for later.
+
+ /** @ignore */
var ev_new = {};
pwlib.extend(ev_new, ev);
ev_new.type = type;
// Make sure preventDefault() is not borked...
+ /** @ignore */
ev_new.preventDefault = function () {
ev.preventDefault();
};
View
5 src/paintweb.js
@@ -17,7 +17,7 @@
* along with PaintWeb. If not, see <http://www.gnu.org/licenses/>.
*
* $URL: http://code.google.com/p/paintweb $
- * $Date: 2009-07-30 20:50:13 +0300 $
+ * $Date: 2009-08-04 19:46:19 +0300 $
*/
/**
@@ -2308,8 +2308,11 @@ function PaintWeb (win, doc) {
// huh, use XHR then eval() the code.
// browsers do not dispatch the 'load' event reliably for script elements.
+
+ /** @ignore */
var xhr = new XMLHttpRequest();
+ /** @ignore */
xhr.onreadystatechange = function () {
if (!xhr || xhr.readyState !== 4) {
return;
Please sign in to comment.
Something went wrong with that request. Please try again.