version 1.1159, 2013/11/25 20:18:55
|
version 1.1165, 2013/12/24 19:15:10
|
Line 1750 RESIZE
|
Line 1750 RESIZE
|
|
|
=head1 Excel and CSV file utility routines |
=head1 Excel and CSV file utility routines |
|
|
=over 4 |
|
|
|
=cut |
=cut |
|
|
############################################################### |
############################################################### |
Line 1759 RESIZE
|
Line 1757 RESIZE
|
|
|
=pod |
=pod |
|
|
|
=over 4 |
|
|
=item * &csv_translate($text) |
=item * &csv_translate($text) |
|
|
Translate $text to allow it to be output as a 'comma separated values' |
Translate $text to allow it to be output as a 'comma separated values' |
Line 7282 sub headtag {
|
Line 7282 sub headtag {
|
|
|
my $result = |
my $result = |
'<head>'. |
'<head>'. |
&font_settings(); |
&font_settings($args); |
|
|
my $inhibitprint = &print_suppression(); |
my $inhibitprint = &print_suppression(); |
|
|
Line 7347 ADDMETA
|
Line 7347 ADDMETA
|
|
|
Returns neccessary <meta> to set the proper encoding |
Returns neccessary <meta> to set the proper encoding |
|
|
Inputs: none |
Inputs: optional reference to HASH -- $args passed to &headtag() |
|
|
=cut |
=cut |
|
|
sub font_settings { |
sub font_settings { |
|
my ($args) = @_; |
my $headerstring=''; |
my $headerstring=''; |
if (!$env{'browser.mathml'} && $env{'browser.unicode'}) { |
if ((!$env{'browser.mathml'} && $env{'browser.unicode'}) || |
|
((ref($args) eq 'HASH') && ($args->{'browser.unicode'}))) { |
$headerstring.= |
$headerstring.= |
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'."\n"; |
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'."\n"; |
} |
} |
Line 8691 Incoming parameters:
|
Line 8693 Incoming parameters:
|
2. user's domain |
2. user's domain |
3. quota name - portfolio, author, or course |
3. quota name - portfolio, author, or course |
(if no quota name provided, defaults to portfolio). |
(if no quota name provided, defaults to portfolio). |
4. crstype - official, unofficial or community, if quota name is |
4. crstype - official, unofficial, textbook or community, if quota name is |
course |
course |
|
|
Returns: |
Returns: |
1. Disk quota (in Mb) assigned to student. |
1. Disk quota (in MB) assigned to student. |
2. (Optional) Type of setting: custom or default |
2. (Optional) Type of setting: custom or default |
(individually assigned or default for user's |
(individually assigned or default for user's |
institutional status). |
institutional status). |
Line 8765 sub get_user_quota {
|
Line 8767 sub get_user_quota {
|
if ($quota eq '' || wantarray) { |
if ($quota eq '' || wantarray) { |
if ($quotaname eq 'course') { |
if ($quotaname eq 'course') { |
my %domdefs = &Apache::lonnet::get_domain_defaults($udom); |
my %domdefs = &Apache::lonnet::get_domain_defaults($udom); |
if (($crstype eq 'official') || ($crstype eq 'unofficial') || ($crstype eq 'community')) { |
if (($crstype eq 'official') || ($crstype eq 'unofficial') || |
|
($crstype eq 'community') || ($crstype eq 'textbook')) { |
$defquota = $domdefs{$crstype.'quota'}; |
$defquota = $domdefs{$crstype.'quota'}; |
} |
} |
if ($defquota eq '') { |
if ($defquota eq '') { |
Line 8811 Incoming parameters:
|
Line 8814 Incoming parameters:
|
|
|
Returns: |
Returns: |
|
|
1. Default disk quota (in Mb) for user portfolios in the domain. |
1. Default disk quota (in MB) for user portfolios in the domain. |
2. (Optional) institutional type which determined the value of the |
2. (Optional) institutional type which determined the value of the |
default quota. |
default quota. |
|
|
If a value has been stored in the domain's configuration db, |
If a value has been stored in the domain's configuration db, |
it will return that, otherwise it returns 20 (for backwards |
it will return that, otherwise it returns 20 (for backwards |
compatibility with domains which have not set up a configuration |
compatibility with domains which have not set up a configuration |
db file; the original statically defined portfolio quota was 20 Mb). |
db file; the original statically defined portfolio quota was 20 MB). |
|
|
If the user's status includes multiple types (e.g., staff and student), |
If the user's status includes multiple types (e.g., staff and student), |
the largest default quota which applies to the user determines the |
the largest default quota which applies to the user determines the |
Line 8906 space to be exceeded.
|
Line 8909 space to be exceeded.
|
Same, if upload of a file directly to a course/community via Course Editor |
Same, if upload of a file directly to a course/community via Course Editor |
will cause quota for uploaded content for the course to be exceeded. |
will cause quota for uploaded content for the course to be exceeded. |
|
|
Inputs: 6 |
Inputs: 7 |
1. username or coursenum |
1. username or coursenum |
2. domain |
2. domain |
3. context ('author' or 'course') |
3. context ('author' or 'course') |
4. filename of file for which action is being requested |
4. filename of file for which action is being requested |
5. filesize (kB) of file |
5. filesize (kB) of file |
6. action being taken: copy or upload. |
6. action being taken: copy or upload. |
|
7. quotatype (in course context -- official, unofficial, community or textbook). |
|
|
Returns: 1 scalar: HTML to display containing warning if quota would be exceeded, |
Returns: 1 scalar: HTML to display containing warning if quota would be exceeded, |
otherwise return null. |
otherwise return null. |
Line 8922 Returns: 1 scalar: HTML to display conta
|
Line 8926 Returns: 1 scalar: HTML to display conta
|
=cut |
=cut |
|
|
sub excess_filesize_warning { |
sub excess_filesize_warning { |
my ($uname,$udom,$context,$filename,$filesize,$action) = @_; |
my ($uname,$udom,$context,$filename,$filesize,$action,$quotatype) = @_; |
my $current_disk_usage = 0; |
my $current_disk_usage = 0; |
my $disk_quota = &get_user_quota($uname,$udom,$context); #expressed in MB |
my $disk_quota = &get_user_quota($uname,$udom,$context,$quotatype); #expressed in MB |
if ($context eq 'author') { |
if ($context eq 'author') { |
my $authorspace = $Apache::lonnet::perlvar{'lonDocRoot'}."/priv/$udom/$uname"; |
my $authorspace = $Apache::lonnet::perlvar{'lonDocRoot'}."/priv/$udom/$uname"; |
$current_disk_usage = &Apache::lonnet::diskusage($udom,$uname,$authorspace); |
$current_disk_usage = &Apache::lonnet::diskusage($udom,$uname,$authorspace); |
Line 11003 sub decompress_form {
|
Line 11007 sub decompress_form {
|
} |
} |
} |
} |
if ($mimetype =~ m{^application/(x\-)?(compressed|zip)}) { |
if ($mimetype =~ m{^application/(x\-)?(compressed|zip)}) { |
my @camtasia = ("$topdir/","$topdir/index.html", |
my @camtasia6 = ("$topdir/","$topdir/index.html", |
"$topdir/media/", |
"$topdir/media/", |
"$topdir/media/$topdir.mp4", |
"$topdir/media/$topdir.mp4", |
"$topdir/media/FirstFrame.png", |
"$topdir/media/FirstFrame.png", |
"$topdir/media/player.swf", |
"$topdir/media/player.swf", |
"$topdir/media/swfobject.js", |
"$topdir/media/swfobject.js", |
"$topdir/media/expressInstall.swf"); |
"$topdir/media/expressInstall.swf"); |
my @diffs = &compare_arrays(\@paths,\@camtasia); |
my @camtasia8 = ("$topdir/","$topdir/$topdir.html", |
|
"$topdir/$topdir.mp4", |
|
"$topdir/$topdir\_config.xml", |
|
"$topdir/$topdir\_controller.swf", |
|
"$topdir/$topdir\_embed.css", |
|
"$topdir/$topdir\_First_Frame.png", |
|
"$topdir/$topdir\_player.html", |
|
"$topdir/$topdir\_Thumbnails.png", |
|
"$topdir/playerProductInstall.swf", |
|
"$topdir/scripts/", |
|
"$topdir/scripts/config_xml.js", |
|
"$topdir/scripts/handlebars.js", |
|
"$topdir/scripts/jquery-1.7.1.min.js", |
|
"$topdir/scripts/jquery-ui-1.8.15.custom.min.js", |
|
"$topdir/scripts/modernizr.js", |
|
"$topdir/scripts/player-min.js", |
|
"$topdir/scripts/swfobject.js", |
|
"$topdir/skins/", |
|
"$topdir/skins/configuration_express.xml", |
|
"$topdir/skins/express_show/", |
|
"$topdir/skins/express_show/player-min.css", |
|
"$topdir/skins/express_show/spritesheet.png"); |
|
my @diffs = &compare_arrays(\@paths,\@camtasia6); |
if (@diffs == 0) { |
if (@diffs == 0) { |
$is_camtasia = 1; |
$is_camtasia = 6; |
|
} else { |
|
@diffs = &compare_arrays(\@paths,\@camtasia8); |
|
if (@diffs == 0) { |
|
$is_camtasia = 8; |
|
} |
} |
} |
} |
} |
my $output; |
my $output; |
Line 11024 sub decompress_form {
|
Line 11055 sub decompress_form {
|
function camtasiaToggle() { |
function camtasiaToggle() { |
for (var i=0; i<document.uploaded_decompress.autoextract_camtasia.length; i++) { |
for (var i=0; i<document.uploaded_decompress.autoextract_camtasia.length; i++) { |
if (document.uploaded_decompress.autoextract_camtasia[i].checked) { |
if (document.uploaded_decompress.autoextract_camtasia[i].checked) { |
if (document.uploaded_decompress.autoextract_camtasia[i].value == 1) { |
if (document.uploaded_decompress.autoextract_camtasia[i].value == $is_camtasia) { |
|
|
document.getElementById('camtasia_titles').style.display='block'; |
document.getElementById('camtasia_titles').style.display='block'; |
} else { |
} else { |
Line 11087 ENDCAM
|
Line 11118 ENDCAM
|
if ($is_camtasia) { |
if ($is_camtasia) { |
$output .= $lt{'auto'}.'<br />'. |
$output .= $lt{'auto'}.'<br />'. |
'<span class="LC_nobreak">'.$lt{'proa'}.'<label>'. |
'<span class="LC_nobreak">'.$lt{'proa'}.'<label>'. |
'<input type="radio" name="autoextract_camtasia" value="1" onclick="javascript:camtasiaToggle();" checked="checked" />'. |
'<input type="radio" name="autoextract_camtasia" value="'.$is_camtasia.'" onclick="javascript:camtasiaToggle();" checked="checked" />'. |
$lt{'yes'}.'</label> <label>'. |
$lt{'yes'}.'</label> <label>'. |
'<input type="radio" name="autoextract_camtasia" value="0" onclick="javascript:camtasiaToggle();" />'. |
'<input type="radio" name="autoextract_camtasia" value="0" onclick="javascript:camtasiaToggle();" />'. |
$lt{'no'}.'</label></span><br />'. |
$lt{'no'}.'</label></span><br />'. |
Line 11320 sub process_decompression {
|
Line 11351 sub process_decompression {
|
\%titles,\%children); |
\%titles,\%children); |
} |
} |
if ($env{'form.autoextract_camtasia'}) { |
if ($env{'form.autoextract_camtasia'}) { |
|
my $version = $env{'form.autoextract_camtasia'}; |
my %displayed; |
my %displayed; |
my $total = 1; |
my $total = 1; |
$env{'form.archive_directory'} = []; |
$env{'form.archive_directory'} = []; |
Line 11338 sub process_decompression {
|
Line 11370 sub process_decompression {
|
$env{'form.archive_'.$i} = 'display'; |
$env{'form.archive_'.$i} = 'display'; |
$env{'form.archive_title_'.$i} = $env{'form.camtasia_foldername'}; |
$env{'form.archive_title_'.$i} = $env{'form.camtasia_foldername'}; |
$displayed{'folder'} = $i; |
$displayed{'folder'} = $i; |
} elsif ($item eq "$contents[0]/index.html") { |
} elsif ((($item eq "$contents[0]/index.html") && ($version == 6)) || |
|
(($item eq "$contents[0]/$contents[0]".'.html') && ($version == 8))) { |
$env{'form.archive_'.$i} = 'display'; |
$env{'form.archive_'.$i} = 'display'; |
$env{'form.archive_title_'.$i} = $env{'form.camtasia_moviename'}; |
$env{'form.archive_title_'.$i} = $env{'form.camtasia_moviename'}; |
$displayed{'web'} = $i; |
$displayed{'web'} = $i; |
} else { |
} else { |
if ($item eq "$contents[0]/media") { |
if ((($item eq "$contents[0]/media") && ($version == 6)) || |
|
((($item eq "$contents[0]/scripts") || ($item eq "$contents[0]/skins") || |
|
($item eq "$contents[0]/skins/express_show")) && ($version == 8))) { |
push(@{$env{'form.archive_directory'}},$i); |
push(@{$env{'form.archive_directory'}},$i); |
} |
} |
$env{'form.archive_'.$i} = 'dependency'; |
$env{'form.archive_'.$i} = 'dependency'; |
Line 12070 sub cleanup_empty_dirs {
|
Line 12105 sub cleanup_empty_dirs {
|
|
|
=pod |
=pod |
|
|
=item &get_folder_hierarchy() |
=item * &get_folder_hierarchy() |
|
|
Provides hierarchy of names of folders/sub-folders containing the current |
Provides hierarchy of names of folders/sub-folders containing the current |
item, |
item, |
Line 13383 sub extract_categories {
|
Line 13418 sub extract_categories {
|
|
|
=pod |
=pod |
|
|
=item *&recurse_categories() |
=item * &recurse_categories() |
|
|
Recursively used to generate breadcrumb trails for course categories. |
Recursively used to generate breadcrumb trails for course categories. |
|
|
Line 13454 sub recurse_categories {
|
Line 13489 sub recurse_categories {
|
|
|
=pod |
=pod |
|
|
=item *&assign_categories_table() |
=item * &assign_categories_table() |
|
|
Create a datatable for display of hierarchical categories in a domain, |
Create a datatable for display of hierarchical categories in a domain, |
with checkboxes to allow a course to be categorized. |
with checkboxes to allow a course to be categorized. |
Line 13531 sub assign_categories_table {
|
Line 13566 sub assign_categories_table {
|
|
|
=pod |
=pod |
|
|
=item *&assign_category_rows() |
=item * &assign_category_rows() |
|
|
Create a datatable row for display of nested categories in a domain, |
Create a datatable row for display of nested categories in a domain, |
with checkboxes to allow a course to be categorized,called recursively. |
with checkboxes to allow a course to be categorized,called recursively. |
Line 14226 sub group_term {
|
Line 14261 sub group_term {
|
} |
} |
|
|
sub course_types { |
sub course_types { |
my @types = ('official','unofficial','community'); |
my @types = ('official','unofficial','community','textbook'); |
my %typename = ( |
my %typename = ( |
official => 'Official course', |
official => 'Official course', |
unofficial => 'Unofficial course', |
unofficial => 'Unofficial course', |
community => 'Community', |
community => 'Community', |
|
textbook => 'Textbook course', |
); |
); |
return (\@types,\%typename); |
return (\@types,\%typename); |
} |
} |
Line 14433 sub init_user_environment {
|
Line 14469 sub init_user_environment {
|
undef,\%userenv,\%domdef,\%is_adv); |
undef,\%userenv,\%domdef,\%is_adv); |
} |
} |
|
|
foreach my $crstype ('official','unofficial','community') { |
foreach my $crstype ('official','unofficial','community','textbook') { |
$userenv{'canrequest.'.$crstype} = |
$userenv{'canrequest.'.$crstype} = |
&Apache::lonnet::usertools_access($username,$domain,$crstype, |
&Apache::lonnet::usertools_access($username,$domain,$crstype, |
'reload','requestcourses', |
'reload','requestcourses', |
Line 14908 sub check_recaptcha {
|
Line 14944 sub check_recaptcha {
|
return $captcha_chk; |
return $captcha_chk; |
} |
} |
|
|
|
sub cleanup_html { |
|
my ($incoming) = @_; |
|
my $outgoing; |
|
if ($incoming ne '') { |
|
$outgoing = $incoming; |
|
$outgoing =~ s/;/;/g; |
|
$outgoing =~ s/\#/#/g; |
|
$outgoing =~ s/\&/&/g; |
|
$outgoing =~ s/</</g; |
|
$outgoing =~ s/>/>/g; |
|
$outgoing =~ s/\(/(/g; |
|
$outgoing =~ s/\)/)/g; |
|
$outgoing =~ s/"/"/g; |
|
$outgoing =~ s/'/'/g; |
|
$outgoing =~ s/\$/$/g; |
|
$outgoing =~ s{/}{/}g; |
|
$outgoing =~ s/=/=/g; |
|
$outgoing =~ s/\\/\/g |
|
} |
|
return $outgoing; |
|
} |
|
|
=pod |
=pod |
|
|
=back |
=back |