Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
3c7e6aa1
Commit
3c7e6aa1
authored
Nov 06, 2006
by
Nigel McNie
Committed by
Nigel McNie
Nov 06, 2006
Browse files
Merge with
git+ssh://git.catalyst.net.nz/var/git/mahara.git#master
parents
bcc14ffa
0f202abe
Changes
4
Hide whitespace changes
Inline
Side-by-side
htdocs/js/mahara.js
View file @
3c7e6aa1
// Expects strings array
function
get_string
(
s
)
{
// @todo Still need to sprintf these strings.
var
flatargs
=
flattenArguments
(
arguments
);
if
(
arguments
.
length
>
1
)
{
argstr
=
'
(
'
+
flatargs
.
slice
(
1
).
join
(
'
,
'
)
+
'
)
'
;
}
else
{
argstr
=
''
;
}
var
args
=
flattenArguments
(
arguments
).
slice
(
1
);
if
(
typeof
(
strings
)
==
'
undefined
'
||
typeof
(
strings
[
s
])
==
'
undefined
'
)
{
return
'
[[[
'
+
s
+
argstr
+
'
]]]
'
;
return
'
[[[
'
+
s
+
((
args
.
length
>
0
)
?
(
'
(
'
+
args
.
join
(
'
,
'
)
+
'
)
'
)
:
''
)
+
'
]]]
'
;
}
var
str
=
strings
[
s
];
// @todo Need to sprintf these strings properly.
for
(
var
i
=
0
;
i
<
args
.
length
;
i
++
)
{
str
=
str
.
replace
(
'
%s
'
,
args
[
i
]);
}
return
str
ings
[
s
]
+
argstr
;
return
str
;
}
// Appends a status message to the end of elemid
...
...
@@ -39,7 +38,7 @@ function testRequired(e,formid) {
var
labels
=
getElementsByTagAndClassName
(
'
label
'
,
null
,
formid
);
for
(
var
j
=
0
;
j
<
labels
.
length
;
j
++
)
{
if
(
getNodeAttribute
(
labels
[
j
],
'
for
'
)
==
e
.
name
)
{
displayMessage
({
'
message
'
:
get_string
(
'
requir
edfieldempty
'
,
scrapeText
(
labels
[
j
])),
displayMessage
({
'
message
'
:
get_string
(
'
nam
edfieldempty
'
,
scrapeText
(
labels
[
j
])),
'
type
'
:
'
error
'
});
return
false
;
}
...
...
htdocs/lang/en.utf8/mahara.php
View file @
3c7e6aa1
...
...
@@ -55,6 +55,7 @@ $string['pagename'] = 'Page name';
$string
[
'pagetext'
]
=
'Page text'
;
// mahara.js
$string
[
'namedfieldempty'
]
=
'The required field "%s" is empty'
;
$string
[
'processingform'
]
=
'Processing form'
;
$string
[
'requiredfieldempty'
]
=
'A required field is empty'
;
$string
[
'unknownerror'
]
=
'An unknown error occurred (0x20f91a0)'
;
...
...
htdocs/lib/mahara.php
View file @
3c7e6aa1
...
...
@@ -142,15 +142,6 @@ function ensure_internal_plugins_exist() {
function
get_string
(
$identifier
,
$section
=
'mahara'
)
{
$langconfigstrs
=
array
(
'parentlanguage'
,
'strftimedate'
,
'strftimedateshort'
,
'strftimedatetime'
,
'strftimedaydate'
,
'strftimedaydatetime'
,
'strftimedayshort'
,
'strftimedaytime'
,
'strftimemonthyear'
,
'strftimerecent'
,
'strftimerecentfull'
,
'strftimetime'
,
'thislanguage'
);
if
(
in_array
(
$identifier
,
$langconfigstrs
))
{
$section
=
'langconfig'
;
}
$variables
=
func_get_args
();
if
(
count
(
$variables
)
>
2
)
{
// we have some stuff we need to sprintf
array_shift
(
$variables
);
...
...
@@ -160,6 +151,40 @@ function get_string($identifier, $section='mahara') {
$variables
=
array
();
}
return
get_string_location
(
$identifier
,
$section
,
$variables
);
}
// get a string without sprintfing it.
function
get_raw_string
(
$identifier
,
$section
=
'mahara'
)
{
// For a raw string we don't want to format any arguments using
// sprintf, so the replace function passed to get_string_location
// should just return the first argument and ignore the second.
return
get_string_location
(
$identifier
,
$section
,
array
(),
create_function
(
'$a,$b'
,
'return $a;'
));
}
/**
* This function gets a language string identified by $identifier from
* an appropriate location, and formats the string and any arguments
* in $variables using the function $replacefunc.
*
* @param string $identifier
* @param string $section
* @param array $variables
* @param function $replacefunc
* @return string
*/
function
get_string_location
(
$identifier
,
$section
,
$variables
,
$replacefunc
=
'format_langstring'
)
{
$langconfigstrs
=
array
(
'parentlanguage'
,
'strftimedate'
,
'strftimedateshort'
,
'strftimedatetime'
,
'strftimedaydate'
,
'strftimedaydatetime'
,
'strftimedayshort'
,
'strftimedaytime'
,
'strftimemonthyear'
,
'strftimerecent'
,
'strftimerecentfull'
,
'strftimetime'
,
'thislanguage'
);
if
(
in_array
(
$identifier
,
$langconfigstrs
))
{
$section
=
'langconfig'
;
}
$lang
=
current_language
();
// Define the locations of language strings for this section
...
...
@@ -185,7 +210,7 @@ function get_string($identifier, $section='mahara') {
$langfile
=
$location
.
$lang
.
'/'
.
$section
.
'.php'
;
if
(
is_readable
(
$langfile
))
{
if
(
$result
=
get_string_from_file
(
$identifier
,
$langfile
))
{
return
format_langstring
(
$result
,
$variables
);
return
$replacefunc
(
$result
,
$variables
);
}
}
}
...
...
@@ -197,7 +222,6 @@ function get_string($identifier, $section='mahara') {
}
// Is a parent language defined? If so, try to find this string in a parent language file
foreach
(
$locations
as
$location
)
{
$langfile
=
$location
.
$lang
.
'/langconfig.php'
;
if
(
is_readable
(
$langfile
))
{
...
...
@@ -205,7 +229,7 @@ function get_string($identifier, $section='mahara') {
$langfile
=
$location
.
$parentlang
.
'/'
.
$section
.
'.php'
;
if
(
is_readable
(
$langfile
))
{
if
(
$result
=
get_string_from_file
(
$identifier
,
$langfile
))
{
return
format_langstring
(
$result
,
$variables
);
return
$replacefunc
(
$result
,
$variables
);
}
}
}
...
...
@@ -218,7 +242,7 @@ function get_string($identifier, $section='mahara') {
$langfile
=
$location
.
'en.utf8/'
.
$section
.
'.php'
;
if
(
is_readable
(
$langfile
))
{
if
(
$result
=
get_string_from_file
(
$identifier
,
$langfile
))
{
return
format_langstring
(
$result
,
$variables
);
return
$replacefunc
(
$result
,
$variables
);
}
}
}
...
...
@@ -227,7 +251,6 @@ function get_string($identifier, $section='mahara') {
}
/**
* This function is only used from {@link get_string()}.
*
...
...
htdocs/lib/web.php
View file @
3c7e6aa1
...
...
@@ -87,7 +87,7 @@ function &smarty($javascript = array(), $headers = array(), $strings = array())
}
if
(
!
empty
(
$strings
))
{
foreach
(
$strings
as
&
$string
)
{
$string
=
'"'
.
$string
.
'":"'
.
addslashes
(
get_string
(
$string
))
.
'"'
;
$string
=
'"'
.
$string
.
'":"'
.
addslashes
(
get_
raw_
string
(
$string
))
.
'"'
;
}
$stringjs
=
'<script language="javascript" type="text/javascript">'
;
$stringjs
.
=
'var strings={'
.
implode
(
','
,
$strings
)
.
'};'
;
...
...
@@ -123,7 +123,8 @@ function &smarty($javascript = array(), $headers = array(), $strings = array())
}
function
maharajsstrings
()
{
return
array
(
'processingform'
,
return
array
(
'namedfieldempty'
,
'processingform'
,
'requiredfieldempty'
,
'unknownerror'
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment