Commit 69ec5036 authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files
parents 8965ccb5 af1f763e
......@@ -59,7 +59,7 @@ function FileBrowser(element, changedircallback) {
}
var deleteb = INPUT({'type':'button', 'value':get_string('delete')});
deleteb.onclick = function () {
if (confirm(get_string(r.artefacttype == 'folder' ? 'deletefolderandcontents?' : 'deletefile?'))) {
if (confirm(get_string(r.artefacttype == 'folder' ? 'deletefolder?' : 'deletefile?'))) {
sendjsonrequest('delete.json.php', {'id': r.id}, self.refresh);
}
};
......
......@@ -139,11 +139,11 @@ function FileUploader(element, foldername, folderid, uploadcallback, fileexists)
this.getresult = function(data) {
if (!data.error) {
var image = 'success.gif';
var message = get_string('Upload complete');
var message = get_string('uploadcomplete');
}
else {
var image = 'failure.gif';
var message = get_string('Upload failed');
var message = get_string('uploadfailed');
}
replaceChildNodes($('uploadstatusline'+data.uploadnumber),
IMG({'src':config.themeurl+image}), message);
......
......@@ -26,9 +26,34 @@
defined('INTERNAL') || die();
$string['create'] = 'Create';
$string['createfolder'] = 'Create folder';
$string['deletefile?'] = 'Are you sure you want to delete this file?';
$string['deletefolderandcontents?'] = 'Are you sure you want to delete this folder and all its contents?';
$string['description'] = 'Description';
$string['destination'] = 'Destination';
$string['editfile'] = 'Edit file';
$string['editfolder'] = 'Edit folder';
$string['file'] = 'file';
$string['File'] = 'File';
$string['fileexistsoverwritecancel'] = 'A file with that name already exists. You can rename the file you are about to upload, or overwrite the existing file.';
$string['filenamefieldisrequired'] = 'File field is required';
$string['folder'] = 'folder';
$string['home'] = 'Home';
$string['image'] = 'image';
$string['myfiles'] = 'My Files';
$string['name'] = 'Name';
$string['namefieldisrequired'] = 'Name field is required';
$string['nofilesfound'] = 'No files found';
$string['overwrite'] = 'Overwrite';
$string['savechanges'] = 'Save changes';
$string['title'] = 'Name';
$string['titlefieldisrequired'] = 'Name field is required';
$string['upload'] = 'Upload';
$string['uploadcomplete'] = 'Upload complete';
$string['uploadfailed'] = 'Upload failed';
$string['uploadfile'] = 'Upload file';
$string['uploadfileexistsoverwritecancel'] = 'A file with that name already exists. You can rename the file you are about to upload, or overwrite the existing file.';
$string['uploading'] = 'Uploading';
?>
......@@ -63,6 +63,48 @@ class PluginArtefactFile extends PluginArtefact {
return strnatcasecmp($a->text, $b->text);
}
public static function jsstrings($type) {
static $jsstrings = array(
'uploader' => array(
'cancel' => 'mahara',
'description' => 'artefact.file',
'destination' => 'artefact.file',
'file' => 'artefact.file',
'filenamefieldisrequired' => 'artefact.file',
'home' => 'artefact.file',
'overwrite' => 'artefact.file',
'title' => 'artefact.file',
'titlefieldisrequired' => 'artefact.file',
'upload' => 'artefact.file',
'uploadcomplete' => 'artefact.file',
'uploadfailed' => 'artefact.file',
'uploadfile' => 'artefact.file',
'uploadfileexistsoverwritecancel' => 'artefact.file',
'uploading' => 'artefact.file',
),
'filebrowser' => array(
'cancel' => 'mahara',
'create' => 'artefact.file',
'createfolder' => 'artefact.file',
'delete' => 'mahara',
'deletefile?' => 'artefact.file',
'deletefolder?' => 'artefact.file',
'description' => 'artefact.file',
'destination' => 'artefact.file',
'edit' => 'mahara',
'editfile' => 'artefact.file',
'editfolder' => 'artefact.file',
'fileexistsoverwritecancel' => 'artefact.file',
'home' => 'artefact.file',
'name' => 'artefact.file',
'namefieldisrequired' => 'artefact.file',
'nofilesfound' => 'artefact.file',
'overwrite' => 'artefact.file',
'savechanges' => 'artefact.file',
)
);
return $jsstrings[$type];
}
}
......@@ -130,7 +172,7 @@ class ArtefactTypeFileBase extends ArtefactType {
}
else {
foreach ($filedata as $item) {
$item->mtime = strftime(get_string('strftimedate'),strtotime($item->mtime));
$item->mtime = strftime(get_string('strfdaymonthyearshort'),strtotime($item->mtime));
}
}
......
......@@ -172,7 +172,7 @@ MochiKit.Base.update(MochiKit.Style, {
elem = MochiKit.DOM.getElement(elem);
var self = MochiKit.Style;
if (o == 1) {
var toSet = /Gecko/.test(navigator.userAgent) && !(/Konqueror|Safari|KHTML/.test(navigator.userAgent));
var toSet = /Gecko/.test(navigator.userAgent) && !(/Konqueror|AppleWebKit|KHTML/.test(navigator.userAgent));
elem.style["opacity"] = toSet ? 0.999999 : 1.0;
if (/MSIE/.test(navigator.userAgent)) {
elem.style['filter'] =
......@@ -265,7 +265,7 @@ MochiKit.Base.update(MochiKit.Style, {
var ua = navigator.userAgent.toLowerCase();
if ((typeof(opera) != 'undefined' &&
parseFloat(opera.version()) < 9) ||
(ua.indexOf('safari') != -1 &&
(ua.indexOf('AppleWebKit') != -1 &&
self.getStyle(elem, 'position') == 'absolute')) {
c.x -= b.offsetLeft;
......
......@@ -90,6 +90,26 @@ function sendjsonrequest(script, data, successcallback, errorcallback) {
});
}
// Rename a file by appending numbers
function newfilename(oldname, fileexistsfunc) {
var dotpos = oldname.indexOf('.');
if (dotpos == -1) {
var begin = oldname;
var end = '';
}
else {
var begin = oldname.substring(0, dotpos);
var end = oldname.substring(dotpos, oldname.length);
}
var i = 1;
var newname = begin + i + end;
while (fileexistsfunc(newname)) {
i++;
newname = begin + i + end;
}
return newname;
}
// Autofocus the first element with a class of 'autofocus' on page load
// Also, connect input elements with the 'emptyonfocus' class to work properly
addLoadEvent(function() {
......
......@@ -38,6 +38,7 @@ $string['strftimemonthyear'] = '%%B %%Y';
$string['strftimerecent'] = '%%d %%b, %%H:%%M';
$string['strftimerecentfull'] = '%%a, %%d %%b %%Y, %%I:%%M %%p';
$string['strftimetime'] = '%%I:%%M %%p';
$string['strfdaymonthyearshort'] = '%%d/%%m/%%Y';
$string['thislanguage'] = 'English';
......
......@@ -35,6 +35,7 @@ $string['save'] = 'Save';
$string['submit'] = 'Submit';
$string['update'] = 'Update';
$string['change'] = 'Change';
$string['go'] = 'Go';
$string['no'] = 'no';
$string['yes'] = 'yes';
......@@ -261,6 +262,13 @@ $string['views'] = 'Views';
$string['viewsubmitted'] = 'View submitted';
$string['viewsubmittedto'] = 'This view has been submitted to %s';
// access levels
$string['public'] = 'Public';
$string['loggedin'] = 'Logged In Users';
$string['friends'] = 'Friends';
$string['communities'] = 'Communities';
$string['users'] = 'Users';
// view user
$string['fullname'] = 'Full name';
$string['displayname'] = 'Display name';
......
<?php
/**
* This program is part of Mahara
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage lang
* @author Martyn Smith <martyn@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
$string['createviewstep1'] = 'Create View - Step 1 of 4';
$string['editmetadata'] = 'Edit View Information';
$string['createviewstep2'] = 'Create View - Step 2 of 4';
$string['createviewstep3'] = 'Create View - Step 3 of 4';
$string['createviewstep4'] = 'Create View - Step 4 of 4';
$string['next'] = 'Next';
$string['back'] = 'Back';
$string['createview'] = 'Create View';
$string['title'] = 'View Title';
$string['description'] = 'View Description';
$string['startdate'] = 'Access Start Date/Time';
$string['stopdate'] = 'Access End Date/Time';
$string['stopdate'] = 'Access End Date/Time';
$string['ownerformat'] = 'Owner Format';
$string['ownerformatdescription'] = 'This field controls what appears in the author field for the template you select in step 2';
$string['category.all'] = 'All Templates';
$string['category.resume'] = 'Resume Templates';
$string['category.blog'] = 'Blog Templates';
$string['category.gallery'] = 'Gallery Templates';
$string['category.academic'] = 'Academic Templates';
$string['category.professionaldevelopment'] = 'Professional Development Templates';
$string['category.personaldevelopment'] = 'Personal Development Templates';
$string['usethistemplate'] = 'Select this template';
$string['emptylabel'] = 'Click here to enter text for this label';
$string['empty_block'] = 'Select an artefact from the tree on the left to place here';
$string['viewinformationsaved'] = 'View information saved successfully';
$string['canteditdontown'] = 'You can\'t edit this view because you don\'t own it';
......@@ -181,7 +181,7 @@ function get_string_location($identifier, $section, $variables, $replacefunc='fo
$langconfigstrs = array('parentlanguage', 'strftimedate', 'strftimedateshort', 'strftimedatetime',
'strftimedaydate', 'strftimedaydatetime', 'strftimedayshort', 'strftimedaytime',
'strftimemonthyear', 'strftimerecent', 'strftimerecentfull', 'strftimetime',
'thislanguage');
'strfdaymonthyearshort', 'thislanguage');
if (in_array($identifier, $langconfigstrs)) {
$section = 'langconfig';
......@@ -220,7 +220,7 @@ function get_string_location($identifier, $section, $variables, $replacefunc='fo
// If the preferred language was English (utf8) we can abort now
// saving some checks beacuse it's the only "root" lang
if ($lang == 'en.utf8') {
return '[[' . $identifier . ']]';
return '[[' . $identifier . '/' . $section . ']]';
}
// Is a parent language defined? If so, try to find this string in a parent language file
......@@ -249,7 +249,7 @@ function get_string_location($identifier, $section, $variables, $replacefunc='fo
}
}
return '[[' . $identifier . ']]'; // Last resort
return '[[' . $identifier . '/' . $section . ']]'; // Last resort
}
......
......@@ -38,7 +38,7 @@ function pieform_render_calendar($element, Pieform $form) {
$id = $form->get_name() . '_' . $element['name'];
$result = '<input type="text"'
. $form->element_attributes($element)
. ' value="' . Pieform::hsc($form->get_value($element)) . '">';
. ' value="' . ( $form->get_value($element) ? Pieform::hsc(strftime($element['caloptions']['ifFormat'],$form->get_value($element))) : '' ) . '">';
if (isset($element['imagefile'])) {
$result .= '<a href="" id="'. $id . '_btn" onclick="return false;" class="pieform-calendar-toggle">'
. '<img src="' . $element['imagefile'] . '" alt=""></a>';
......@@ -64,7 +64,7 @@ function pieform_render_calendar_set_attributes($element) {
$element['theme'] = isset($element['theme']) ? $element['theme'] : 'calendar-win2k-2';
$element['caloptions']['ifFormat'] = isset($element['caloptions']['ifFormat']) ? $element['caloptions']['ifFormat'] : '%Y/%m/%d';
$element['caloptions']['daFormat'] = isset($element['caloptions']['daFormat']) ? $element['caloptions']['daFormat'] : '%Y/%m/%d';
$element['rules']['regex'] = isset($element['rules']['regex']) ? $element['rules']['regex'] : '#^((\d{4}/\d{2}/\d{2})( \d{2}:\d{2})?)?$#';
#$element['rules']['regex'] = isset($element['rules']['regex']) ? $element['rules']['regex'] : '#^((\d{4}/\d{2}/\d{2})( \d{2}:\d{2})?)?$#';
return $element;
}
......@@ -91,7 +91,36 @@ function pieform_get_headdata_calendar($element) {
return $result;
}
function pieform_get_value_calendar($element, Pieform $form) {
$name = $element['name'];
// TODO: use the get_value function to do strtotime? (possibly, also might need the javascript version for ajax forms)
$global = ($form->get_method() == 'get') ? $_GET : $_POST;
if (isset($element['value'])) {
return $element['value'];
}
if (isset($global[$name])) {
if (trim($global[$name]) == '') {
return null;
}
$value = strtotime($global[$name]);
if ($value === false) {
$form->set_error($name, 'TODO');
return null;
}
return $value;
}
if (isset($element['defaultvalue'])) {
return $element['defaultvalue'];
}
return null;
}
// TODO: (possibly, also might need the javascript version for ajax forms)
?>
......@@ -52,7 +52,7 @@ defined('INTERNAL') || die();
*/
//smarty(array('js/tablerenderer.js', 'artefact/file/js/filebrowser.js'))
function &smarty($javascript = array(), $headers = array(), $strings = array()) {
function &smarty($javascript = array(), $headers = array(), $pagestrings = array()) {
global $USER, $SESSION;
require_once(get_config('libroot') . 'smarty/Smarty.class.php');
......@@ -95,6 +95,11 @@ EOF;
$javascript_array[] = $jsroot . 'MochiKit/MochiKit.js';
$strings = array();
foreach ($pagestrings as $string => $section) {
$strings[$string] = '"' . $string . '":"' . addslashes(get_raw_string($string, $section)) . '"';
}
$jsstrings = jsstrings();
foreach ($javascript as $jsfile) {
......@@ -102,16 +107,35 @@ EOF;
// $jsroot and append '.js' to the name. Later we may want to
// ensure all smarty() calls include the full path to the js
// file, with the proper extension.
if (strpos($jsfile,'/') === false) {
if (strpos($jsfile, '/') === false) {
$javascript_array[] = $jsroot . $jsfile . '.js';
if (isset($jsstrings[$jsfile])) {
foreach ($jsstrings[$jsfile] as $string => $section) {
if (!isset($strings[$string])) {
$strings[$string] = '"' . $string . '":"'
. addslashes(get_raw_string($string, $section)) . '"';
}
}
}
}
else {
// A .js file with a fully specified path
$javascript_array[] = $wwwroot . $jsfile;
}
if (isset($jsstrings[$jsfile])) {
foreach ($jsstrings[$jsfile] as $string) {
if (!in_array($string, $strings)) {
$strings[] = $string;
// If $jsfile is from a plugin (i.e. plugintype/pluginname/js/foo.js)
// Then get js strings from static function jsstrings in plugintype/pluginname/lib.php
$bits = explode('/', $jsfile);
if (count($bits) == 4) {
safe_require($bits[0], $bits[1]);
$pluginclass = generate_class_name($bits[0], $bits[1]);
if (is_callable(array($pluginclass, 'jsstrings'))) {
$name = substr($bits[3], 0, strpos($bits[3], '.js'));
$tempstrings = call_static_method($pluginclass, 'jsstrings', $name);
foreach ($tempstrings as $string => $section) {
if (!isset($strings[$string])) {
$strings[$string] = '"' . $string . '":"'
. addslashes(get_raw_string($string, $section)) . '"';
}
}
}
}
}
......@@ -120,16 +144,12 @@ EOF;
$javascript_array[] = $jsroot . 'mahara.js';
$javascript_array[] = $jsroot . 'debug.js';
foreach ($jsstrings['mahara'] as $string) {
if (!in_array($string, $strings)) {
$strings[] = $string;
foreach ($jsstrings['mahara'] as $string => $section) {
if (!isset($strings[$string])) {
$strings[$string] = '"' . $string . '":"' . addslashes(get_raw_string($string, $section)) . '"';
}
}
// Add language strings for the javascript
foreach ($strings as &$string) {
$string = '"' . $string . '":"' . addslashes(get_raw_string($string)) . '"';
}
$stringjs = '<script type="text/javascript">';
$stringjs .= 'var strings={' . implode(',', $strings) . '};';
$stringjs .= '</script>';
......@@ -179,19 +199,18 @@ EOF;
function jsstrings() {
return array(
'mahara' => array(
'namedfieldempty',
'processingform',
'requiredfieldempty',
'unknownerror',
'loading',
'namedfieldempty' => 'mahara',
'processingform' => 'mahara',
'requiredfieldempty' => 'mahara',
'unknownerror' => 'mahara',
'loading' => 'mahara',
),
'tablerenderer' => array(
'firstpage',
'nextpage',
'prevpage',
'lastpage',
),
'fileuploader' => array(),
'firstpage' => 'mahara',
'nextpage' => 'mahara',
'prevpage' => 'mahara',
'lastpage' => 'mahara',
)
);
}
......
......@@ -9,7 +9,11 @@
<div class="box-cnrs"><span class="cnr-tl"><span class="cnr-tr"><span class="cnr-bl"><span class="cnr-br">
<div class="maincontent">
<h2>{str tag="createviewstep1"}</h2>
{if $EDITMODE}
<h2>{str tag="editmetadata" section="view"}</h2>
{else}
<h2>{str tag="createviewstep1" section="view"}</h2>
{/if}
{$createview1}
</div>
......
......@@ -9,7 +9,7 @@
<div class="box-cnrs"><span class="cnr-tl"><span class="cnr-tr"><span class="cnr-bl"><span class="cnr-br">
<div class="maincontent">
<h2>{str tag="createviewstep2"}</h2>
<h2>{str tag="createviewstep2" section="view"}</h2>
<div id="createview2">
{literal}
<select onchange="templates.doupdate({'offset': 0, 'category': this.options[this.selectedIndex].value });">
......@@ -26,8 +26,8 @@
</table>
</form>
<button type="button" onclick="document.location='create1.php?createid={$createid}';">{str tag=Back}</button>
<button type="button" onclick="document.location='./';">{str tag=Cancel}</button>
<button type="button" onclick="document.location='create1.php?createid={$createid}';">{str tag="back" section="view"}</button>
<button type="button" onclick="document.location='./';">{str tag="cancel"}</button>
</div>
</div>
......
......@@ -5,7 +5,7 @@
<div class="box-cnrs"><span class="cnr-tl"><span class="cnr-tr"><span class="cnr-bl"><span class="cnr-br">
<div class="maincontent">
<h2>{str tag=createviewstep3}</h2>
<h2>{str tag=createviewstep3 section=view}</h2>
{literal}
<style type="text/css">
......@@ -16,8 +16,8 @@
<form action="" method="post">
{$template}
<input type="submit" name="cancel" value="{str tag=cancel}">
<input type="submit" name="back" value="{str tag=back}">
<input type="submit" name="submit" value="{str tag=next}">
<input type="submit" name="back" value="{str tag=back section=view}">
<input type="submit" name="submit" value="{str tag=next section=view}">
</form>
</div>
<script type="text/javascript">
......
......@@ -4,7 +4,7 @@
<div class="content">
<div class="box-cnrs"><span class="cnr-tl"><span class="cnr-tr"><span class="cnr-bl"><span class="cnr-br">
<div class="maincontent">
<h2>{str tag=createviewstep4}</h2>
<h2>{str tag=createviewstep4 section="view"}</h2>
{$createview4form}
</div>
......
......@@ -45,11 +45,6 @@ if ($createid === null) {
$data = $SESSION->get('create_' . $createid);
$tmpuser = new StdClass;
$tmpuser->firstname = $USER->get('firstname');
$tmpuser->lastname = $USER->get('lastname');
$tmpuser->preferredname = $USER->get('preferredname');
$formatstring = '%s (%s)';
$ownerformatoptions = array(
FORMAT_NAME_FIRSTNAME => sprintf($formatstring, get_string('firstname'), $USER->get('firstname')),
......@@ -65,7 +60,7 @@ $studentid = (string)get_field('artefact', 'title', 'owner', $USER->get('id'), '
if ($studentid !== '') {
$ownerformatoptions[FORMAT_NAME_STUDENTID] = sprintf($formatstring, get_string('studentid'), $studentid);
}
$ownerformatoptions[FORMAT_NAME_DISPLAYNAME] = sprintf($formatstring, get_string('displayname'), display_name($tmpuser));
$ownerformatoptions[FORMAT_NAME_DISPLAYNAME] = sprintf($formatstring, get_string('displayname'), display_name($USER));
$createview1 = pieform(array(
'name' => 'createview1',
......@@ -78,13 +73,13 @@ $createview1 = pieform(array(
),
'title' => array(
'type' => 'text',
'title' => get_string('title'),
'title' => get_string('title','view'),
'defaultvalue' => isset($data['title']) ? $data['title'] : null,
'rules' => array( 'required' => true ),
),
'startdate' => array(
'type' => 'calendar',
'title' => get_string('startdate'),
'title' => get_string('startdate','view'),
'defaultvalue' => isset($data['startdate']) ? $data['startdate'] : null,
'caloptions' => array(
'dateStatusFunc' => 'startDateDisallowed',
......@@ -95,7 +90,7 @@ $createview1 = pieform(array(
),
'stopdate' => array(
'type' => 'calendar',
'title' => get_string('stopdate'),
'title' => get_string('stopdate','view'),
'defaultvalue' => isset($data['stopdate']) ? $data['stopdate'] : null,
'caloptions' => array(
'dateStatusFunc' => 'stopDateDisallowed',
......@@ -106,22 +101,22 @@ $createview1 = pieform(array(
),
'description' => array(
'type' => 'wysiwyg',
'title' => get_string('description'),
'title' => get_string('description','view'),
'rows' => 10,
'cols' => 80,
'defaultvalue' => isset($data['description']) ? $data['description'] : null,
),
'ownerformat' => array(
'type' => 'select',
'title' => get_string('ownerformat'),
'description' => get_string('ownerformatdescription'),
'title' => get_string('ownerformat','view'),
'description' => get_string('ownerformatdescription','view'),
'options' => $ownerformatoptions,
'defaultvalue' => isset($data['ownerformat']) ? $data['ownerformat'] : FORMAT_NAME_DISPLAYNAME,
'rules' => array('required' => true)
),
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('next'), get_string('cancel')),
'value' => array(get_string('next','view'), get_string('cancel')),
),
),
));
......
......@@ -44,7 +44,7 @@ $form = array(
),
'submit' => array(
'type' => 'cancelbackcreate',