--- loncom/interface/londocs.pm 2008/12/21 15:48:43 1.314.2.3 +++ loncom/interface/londocs.pm 2008/12/11 14:55:15 1.319 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.314.2.3 2008/12/21 15:48:43 raeburn Exp $ +# $Id: londocs.pm,v 1.319 2008/12/11 14:55:15 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -26,6 +26,8 @@ # http://www.lon-capa.org/ # + + package Apache::londocs; use strict; @@ -53,15 +55,10 @@ my %alreadyseen=(); my $hadchanges; -# Available help topics my %help=(); -# Mapread read maps into LONCAPA::map:: global arrays -# @order and @resources, determines status -# sets @order - pointer to resources in right order -# sets @resources - array with the resources with correct idx -# + sub mapread { my ($coursenum,$coursedom,$map)=@_; @@ -81,7 +78,7 @@ sub storemap { return ($errtext,0); } -# ----------------------------------------- Return hash with valid author names + sub authorhosts { my %outhash=(); @@ -116,7 +113,7 @@ sub authorhosts { } return ($home,$other,%outhash); } -# ------------------------------------------------------ Generate "dump" button + sub dumpbutton { my ($home,$other,%outhash)=&authorhosts(); @@ -141,7 +138,8 @@ sub clean { $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs; return $title; } -# -------------------------------------------------------- Actually dump course + + sub dumpcourse { my ($r) = @_; @@ -263,7 +261,7 @@ sub dumpcourse { } } -# ------------------------------------------------------ Generate "export" button + sub exportbutton { my $type = &Apache::loncommon::course_type(); @@ -273,6 +271,8 @@ sub exportbutton { &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').''; } + + sub exportcourse { my $r=shift; my $type = &Apache::loncommon::course_type(); @@ -911,8 +911,7 @@ sub store_template { } } -# Imports the given (name, url) resources into the course -# coursenum, coursedom, and folder must precede the list + sub group_import { my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_; @@ -1074,9 +1073,9 @@ sub log_docs { } -# -# Docs Change Log -# + + + sub docs_change_log { my ($r)=@_; my $folder=$env{'form.folder'}; @@ -1279,33 +1278,9 @@ sub do_paste_from_buffer { # Maps need to be copied first if (($url=~/\.(page|sequence)$/) && ($url=~/^\/uploaded\//)) { $title=&mt('Copy of').' '.$title; - my $newid=$$.int(rand(100)).time; - my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/); - if ($oldid =~ m{^(/uploaded/\Q$coursedom\E/\Q$coursenum\E/)(\D+)(\d+)$}) { - my $path = $1; - my $prefix = $2; - my $ancestor = $3; - if (length($ancestor) > 10) { - $ancestor = substr($ancestor,-10,10); - } - $oldid = $path.$prefix.$ancestor; - } - my $counter = 0; - my $newurl=$oldid.$newid.'.'.$ext; - my $is_unique = &uniqueness_check($newurl); - while (!$is_unique && $counter < 100) { - $counter ++; - $newid ++; - $newurl = $oldid.$newid; - $is_unique = &uniqueness_check($newurl); - } - if (!$is_unique) { - if ($url=~/\.page$/) { - return &mt('Paste failed: an error occurred creating a unique URL for the composite page'); - } else { - return &mt('Paste failed: an error occurred creating a unique URL for the folder'); - } - } + my $newid=$$.time; + $url=~/^(.+)\.(\w+)$/; + my $newurl=$1.$newid.'.'.$2; my $storefn=$newurl; $storefn=~s{^/\w+/$match_domain/$match_username/}{}; &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn, @@ -1354,20 +1329,6 @@ sub do_paste_from_buffer { # Store the result } -sub uniqueness_check { - my ($newurl) = @_; - my $unique = 1; - foreach my $res (@LONCAPA::map::order) { - my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]); - $url=&LONCAPA::map::qtescape($url); - if ($newurl eq $url) { - $unique = 0; - last; - } - } - return $unique; -} - my %parameter_type = ( 'randompick' => 'int_pos', 'hiddenresource' => 'string_yesno', 'encrypturl' => 'string_yesno', @@ -1942,7 +1903,7 @@ END my $ro_set= ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':''); $rand_order_text =' -'; +'; } if ($ispage) { my $pagename=&escape($pagetitle); @@ -2002,7 +1963,13 @@ ENDPARMS return $line; } -# ---------------------------------------------------------------- tie the hash +=pod + +=item tiehash() + +tie the hash + +=cut sub tiehash { my ($mode)=@_; @@ -2028,7 +1995,8 @@ sub untiehash { return OK; } -# --------------------------------------------------------------- check on this + + sub checkonthis { my ($r,$url,$level,$title)=@_; @@ -2102,9 +2070,15 @@ sub checkonthis { } -# -# ----------------------------------------------------------------- List Symbs -# + +=pod + +=item list_symbs() + +List Symbs + +=cut + sub list_symbs { my ($r) = @_; @@ -2120,9 +2094,7 @@ sub list_symbs { } -# -# -------------------------------------------------------------- Verify Content -# + sub verifycontent { my ($r) = @_; my $type = &Apache::loncommon::course_type(); @@ -2153,8 +2125,6 @@ sub verifycontent { } -# -------------------------------------------------------------- Check Versions - sub devalidateversioncache { my $src=shift; &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'. @@ -2457,7 +2427,6 @@ sub changewarning { $help{'Caching'}.''."\n\n"); } -# =========================================== Breadcrumbs for special functions sub init_breadcrumbs { my ($form,$text)=@_; @@ -2473,7 +2442,9 @@ sub init_breadcrumbs { bug=>'Instructor Interface'}); } -# ================================================================ Main Handler + + + sub handler { my $r = shift; &Apache::loncommon::content_type($r,'text/html'); @@ -2607,8 +2578,9 @@ sub handler { } # -------------------------------------------------------------------- Body tag $script = ''; + my @brcrum = [{href=>"/adm/createuser",text=>"$type Documents"}]; $r->print(&Apache::loncommon::start_page("$type Documents", $script, - {'force_register' => $showdoc,}). + {'force_register' => $showdoc, bread_crumbs => @brcrum}). &Apache::loncommon::help_open_menu('','',273,'RAT')); my %allfiles = (); @@ -3378,3 +3350,126 @@ ENDNEWSCRIPT } 1; __END__ + + +=head1 NAME + +Apache::londocs.pm + +=head1 SYNOPSIS + +This is part of the LearningOnline Network with CAPA project +described at http://www.lon-capa.org. + +=head1 SUBROUTINES + +=over + +=item %help=() + +Available help topics + +=item mapread() + +Mapread read maps into LONCAPA::map:: global arrays +@order and @resources, determines status +sets @order - pointer to resources in right order +sets @resources - array with the resources with correct idx + +=item authorhosts() + +Return hash with valid author names + +=item dumpbutton() + +Generate "dump" button + +=item clean() + +=item dumpcourse() + + Actually dump course + + +=item exportbutton() + + Generate "export" button + +=item exportcourse() + +=item create_ims_store() + +=item build_package() + +=item get_dependencies() + +=item process_content() + +=item replicate_content() + +=item extract_media() + +=item store_template() + +=item group_import() + + Imports the given (name, url) resources into the course + coursenum, coursedom, and folder must precede the list + +=item breadcrumbs() + +=item log_docs() + +=item docs_change_log() + +=item update_paste_buffer() + +=item print_paste_buffer() + +=item do_paste_from_buffer() + +=item update_parameter() + +=item handle_edit_cmd() + +=item editor() + +=item process_file_upload() + +=item process_secondary_uploads() + +=item is_supplemental_title() + +=item parse_supplemental_title() + +=item entryline() + +=item tiehash() + +=item untiehash() + +=item checkonthis() + +check on this + +=item verifycontent() + +Verify Content + +=item devalidateversioncache() & checkversions() + +Check Versions + +=item mark_hash_old() + +=item is_hash_old() + +=item changewarning() + +=item init_breadcrumbs() + +Breadcrumbs for special functions + +=back + +=cut