[LON-CAPA-cvs] cvs: modules /gerd/harvesting lonrecommender.pm

www www at source.lon-capa.org
Sun Jul 15 08:22:17 EDT 2012


www		Sun Jul 15 12:22:17 2012 EDT

  Modified files:              
    /modules/gerd/harvesting	lonrecommender.pm 
  Log:
  A post-submitting link (needed throughout)
  
  
Index: modules/gerd/harvesting/lonrecommender.pm
diff -u modules/gerd/harvesting/lonrecommender.pm:1.6 modules/gerd/harvesting/lonrecommender.pm:1.7
--- modules/gerd/harvesting/lonrecommender.pm:1.6	Sun Jul 15 10:29:24 2012
+++ modules/gerd/harvesting/lonrecommender.pm	Sun Jul 15 12:22:17 2012
@@ -5,7 +5,7 @@
 #
 # MODIFY $datapath VARIABLE FOR LOCATION OF DATA FILES
 #
-# $Id: lonrecommender.pm,v 1.6 2012/07/15 10:29:24 www Exp $
+# $Id: lonrecommender.pm,v 1.7 2012/07/15 12:22:17 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -53,7 +53,7 @@
 use Apache::groupsort();
 use LONCAPA::map();
 use GDBM_File;
-use LONCAPA qw(:match);
+use LONCAPA;
 
 # PROTOTYPE ROUTINES --- These are the routines needed to run the prototype
 # Accessing the data files in $datapath
@@ -378,7 +378,7 @@
 }
 
 # =================================================================================
-# Execute any edit commands (at the moment only remove)
+# Execute any edit commands (at the moment only add and remove)
 #
 
 sub edit_commands {
@@ -387,9 +387,29 @@
    return @urls;
 }
 
+# =================================================================================
+# A display line for a URL
+# Edit flag: remove instead of add
+
+sub display_line {
+   my ($url,$editflag)=@_;
+   return "\n<tr><td>".
+          "</td></tr>\n";
+}
+
+
+# =================================================================================
+# A submitting link
+# 
+
+sub submit_link {
+   my ($link,$arg)=@_;
+   return '<a href="javascript:document.forms.recom.cmd.value=\''.
+          &escape($arg).
+          '\';document.forms.recom.submit();">'.$link.'</a>';
+}
 
 # =================================================================================
-#
 
 sub handle_request {
     my ($r,$c)=@_;
@@ -437,10 +457,10 @@
 
 # ------ Start the page and the form, store backetcache from londocs
     $r->print(&Apache::loncommon::start_page("Recommender"));
-    $r->print('<form method="post">');
+    $r->print('<form method="post" name="recom">');
     $r->print('<input type="hidden" name="basket" value="cached" />');
     $r->print('<input type="hidden" name="basketcache" value="'.$basketcache.'" />');
-
+    $r->print('<input type="hidden" name="cmd" value="" />');
     $r->print("<h1>Hello World!</h1>");
 
     my %taxos=&taxoids(3,5,8,90,900,1450,13624,31415);
@@ -451,6 +471,8 @@
        $r->print($key.' '.$urls{$key}.' '.$counts{$key}.' => '.$taxos{$key}.' '.$taxonomy_categories{'cleartext_'.$taxos{$key}}."<br />\n");
     }
 
+    $r->print('<br />Got: '.$env{'form.cmd'}.'<br />');
+    $r->print(&submit_link('My link','res_1234'));
 # ------ Close form, done with page
     $r->print('</form>');
     $r->print(&Apache::loncommon::end_page());




More information about the LON-CAPA-cvs mailing list