[LON-CAPA-cvs] cvs: loncom /interface lonindexer.pm lonsearchcat.pm

wenzelju wenzelju@source.lon-capa.org
Fri, 13 Aug 2010 13:32:37 -0000


This is a MIME encoded message

--wenzelju1281706357
Content-Type: text/plain

wenzelju		Fri Aug 13 13:32:37 2010 EDT

  Modified files:              
    /loncom/interface	lonindexer.pm lonsearchcat.pm 
  Log:
  Added icon for "Set a link for this resource/folder to wishlist". Therefor added a new column in "Browse Resources" containing the icon. In "Search" the icon is just printed after the resource-title. These aren't optimal position for the wishlistlink-icon. The best would be to create a kind of header for resource-previews. There you could place icons like "Set link to wishlist" and "Printout".
  
  
--wenzelju1281706357
Content-Type: text/plain
Content-Disposition: attachment; filename="wenzelju-20100813133237.txt"

Index: loncom/interface/lonindexer.pm
diff -u loncom/interface/lonindexer.pm:1.207 loncom/interface/lonindexer.pm:1.208
--- loncom/interface/lonindexer.pm:1.207	Sun Jun  6 02:40:30 2010
+++ loncom/interface/lonindexer.pm	Fri Aug 13 13:32:36 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Directory Indexer
 #
-# $Id: lonindexer.pm,v 1.207 2010/06/06 02:40:30 raeburn Exp $
+# $Id: lonindexer.pm,v 1.208 2010/08/13 13:32:36 wenzelju Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -588,6 +588,7 @@
         $r->print(&Apache::loncommon::start_data_table("LC_tableBrowseRes")
                  .&Apache::loncommon::start_data_table_header_row());
 	$r->print("<th $colspan>".&mt('Name')."</th>\n");
+	$r->print("<th></th>\n");
 	$r->print("<th>".&mt('Title')."</th>\n") 
 	    if ($hash{'display_attrs_0'} == 1);
 	$r->print('<th class="LC_right">'.&mt("Size")." (".&mt("bytes").") ".
@@ -922,7 +923,7 @@
 	$r->print ('<a href="#" onclick="document.dirpathUP.submit()"><img src="'.$iconpath.'arrow.up.gif"');
 	$r->print (' alt="'.$msg.'" class="LC_fileicon" />'.
 		   "\n");
-	$r->print(&mt("Up")."</a></form>$tabtag");
+	$r->print(&mt("Up")."</a></form></td><td>$tabtag");
         $r->print(&Apache::loncommon::end_data_table_row());
 	return OK;
     }
@@ -957,7 +958,7 @@
 	    $r->print("<br />(".&Apache::lonnet::domain($listname,'description').
 		      ")");
 	}
-	$r->print("</form>$tabtag");
+	$r->print("</form></td><td>$tabtag");
          $r->print(&Apache::loncommon::end_data_table_row());
 	return OK;
 
@@ -989,7 +990,12 @@
         $r->print ($listname.'</a>');
 
         if (defined($plainname) && $plainname) { $r->print(" ($plainname) "); }
-        $r->print('</form>'.$tabtag);
+# Wishlistlink
+        $r->print('</form></td><td><a href="javascript:;" '.
+                  'title="'.&mt('Set a link for this folder to wishlist').'" '.
+                  'onclick="set_wishlistlink('."'$plainname','$startdir$listname'".')">'.
+                  '<img class="LC_icon" src="/res/adm/pages/wishlist.png" '.
+                  'alt="'.&mt('set wishlistlink').'" style="width:22px;"/></a>'.$tabtag);
         $r->print(&Apache::loncommon::end_data_table_row());
         return OK;
     }
@@ -1084,6 +1090,12 @@
 	    $r->print('</form>');
 	}
 	$r->print("</td>\n");
+# Wishlistlink
+        $r->print('<td><a href="javascript:;" title="'.&mt('Set a link for this resource to wishlist').'" '.
+                  'onclick="set_wishlistlink('."'".&Apache::lonnet::gettitle($filelink).
+                  "','$startdir$listname'".')">'.
+                  '<img class="LC_icon" src="/res/adm/pages/wishlist.png" '.
+                  'alt="'.&mt('set wishlistlink').'" style="width:22px;"/></a></td>');
 	if ($hash{'display_attrs_0'} == 1) {
 	    $r->print('<td> '.($title eq '' ? '&nbsp;' : $title).
 		      ' </td>'."\n");
@@ -1231,7 +1243,13 @@
                   .'<img class="LC_fileicon" alt="'.&mt('Open Folder').'" src="'
                   .$location.'/'.$icon.'" />'
                   ."\n");
-	$r->print ("$listname</a></form></td>\n");
+	$r->print ("$listname</a></form>");
+# Wishlistlink
+        $r->print('</td><td><a href="javascript:;" '.
+                  'title="'.&mt('Set a link for this folder to wishlist').'" '.
+                  'onclick="set_wishlistlink('."'$listname','$startdir$listname'".')">'.
+                  '<img class="LC_icon" src="/res/adm/pages/wishlist.png" '.
+                  'alt="'.&mt('set wishlistlink').'" style="width:22px;"/></a></td>');
 # Attributes
 	my $filelink = $startdir.$filecom[0].'/default';
 
Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.324 loncom/interface/lonsearchcat.pm:1.325
--- loncom/interface/lonsearchcat.pm:1.324	Sun Jun  6 02:40:30 2010
+++ loncom/interface/lonsearchcat.pm	Fri Aug 13 13:32:36 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Search Catalog
 #
-# $Id: lonsearchcat.pm,v 1.324 2010/06/06 02:40:30 raeburn Exp $
+# $Id: lonsearchcat.pm,v 1.325 2010/08/13 13:32:36 wenzelju Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3364,6 +3364,85 @@
 </script>
 SCRIPT
 
+    # HTML-Markup for 'Set a link for this resource to wishlist'
+    # this is written via JavaScript document.write (function set_wishlistlink) 
+    # it is split into 3 parts and the inputfields for title and path are left out
+    # these fields are inserted later to set the values for title and path
+    # automatically via JavaScript (document.title and location.pathname) 
+    my $start_page_wishlistlink = 
+        &Apache::loncommon::start_page('Set link to wishlist',undef,
+				       {'only_body' => 1,
+					'js_ready'  => 1,
+					'bgcolor'   => '#FFFFFF',});
+
+    my $warningLink = &mt('You must insert a title!');
+
+    my $in_page_wishlistlink1 = '<h1>'.&mt('Set a link to wishlist').'</h1>'.
+                                '<form method="post" name="newlink" action="/adm/wishlist?mode=set" '.
+                                'onsubmit="return newlinksubmit();" >'.
+                                &Apache::lonhtmlcommon::start_pick_box().
+                                &Apache::lonhtmlcommon::row_title(&mt('Link Title'));
+
+    my $in_page_wishlistlink2 = &Apache::lonhtmlcommon::row_closure().
+                                &Apache::lonhtmlcommon::row_title(&mt('Path'));
+
+    my $in_page_wishlistlink3 = &Apache::lonhtmlcommon::row_closure().
+                                &Apache::lonhtmlcommon::row_title(&mt('Note')).
+                                '<textarea name="note" rows="3" cols="35" style="width:100%"></textarea>'.
+                                &Apache::lonhtmlcommon::row_closure(1).
+                                &Apache::lonhtmlcommon::end_pick_box().
+                                '<br/><br/>'.
+                                '<input type="submit" value="'.&mt('Save in').'" />'.
+                                '<select name="folders">'.
+                                &Apache::lonwishlist::getfoldersOption().
+                                '</select>'.
+                                '<input type="button" value="'.&mt('cancel').'" onclick="javascript:window.close();" />'.
+                                '</form>';
+
+    # remove all \n for inserting on javascript document.write
+    $in_page_wishlistlink1 =~ s/\n//g;
+    $in_page_wishlistlink2 =~ s/\n//g;
+    $in_page_wishlistlink3 =~ s/\n//g;
+
+    my $end_page_wishlistlink = 
+       &Apache::loncommon::end_page({'js_ready' => 1});
+
+    # Add JavaScript-function to set link for a ressource to wishlist
+    $js.=<<SCRIPT;
+<script type="text/javascript">
+// <![CDATA[
+function set_wishlistlink(title, path){
+   if(!title){
+       title=document.title;
+   }
+   if(!path){
+       path=location.pathname;
+   }
+   wishlistlink=window.open('','wishlistNewLink','width=560,height=350,scrollbars=0');
+   wishlistlink.document.write(
+   '$start_page_wishlistlink'
+   +'<script type="text\/javascript">'
+   +'function newlinksubmit(){'
+   +'var title = document.getElementsByName("title")[0].value;'
+   +'if (!title) {'
+   +'alert("$warningLink");'
+   +'return false;}'
+   +'return true;}'
+   +'<\/scr'+'ipt>'
+   +'$in_page_wishlistlink1'
+   +'<input type="text" name="title" size="45" value="'+title+'"/>'
+   +'$in_page_wishlistlink2'
+   +'<input type="text" name="path" size="45" value="'+path+'" '
+   +'readonly="readonly" style="background-color: #DDDDDD"/>'
+   +'$in_page_wishlistlink3'
+   +'$end_page_wishlistlink' );
+   wishlistlink.document.close();
+}
+
+// ]]>
+</script>
+SCRIPT
+
     my $start_page  = &Apache::loncommon::start_page(undef,$js,
 						     {'only_body' =>1});
     my $result=<<END;
@@ -3484,7 +3563,11 @@
     $result .= '<b>'.$prefix.
         '<img src="'.&Apache::loncommon::icon($values{'url'}).'" alt="" />'.'&nbsp;'.
         '<a href="'.$jumpurl.'?inhibitmenu=yes" '.
-        'target="preview">'.$values{'title'}."</a></b>\n";
+        'target="preview">'.$values{'title'}."</a></b>\n".
+        '<a href="javascript:;" onclick="set_wishlistlink('."'$values{'title'}','$jumpurl'".')" '.
+        'title="'.&mt('Set link to wishlist').'">'.
+        '<img class="LC_icon" src="/res/adm/pages/wishlist.png" '.
+        'alt="set wishlistlink" style="width:22px;"/></a>';
     $result .= "<p>\n";
     $result .= '<b>'.$values{'author'}.'</b>,'.
         ' <i>'.$values{'owner'}.'</i><br />';
@@ -3615,9 +3698,16 @@
     $jumpurl=~s|^/ext/|http://|;
     my $link = '<br />'.&display_url($jumpurl,1).'<br />';
 
+    my $titleWL = &mt('Set link to wishlist');
     $result.=<<END;
 <a href="$jumpurl?inhibitmenu=yes" 
-   target="preview">$values{'title'}</a><br />
+   target="preview">$values{'title'}</a>
+<a href="javascript:;" onclick="set_wishlistlink('$values{'title'}','$jumpurl')" 
+   title="$titleWL">
+   <img class="LC_icon" src="/res/adm/pages/wishlist.png"
+        alt="set wishlistlink" style="width:22px;"/>
+</a>
+<br />
 $link<br />
 $values{'author'}, $values{'owner'} -- $values{'lastrevisiondate'}<br />
 $values{'copyrighttag'}<br />
@@ -3663,6 +3753,11 @@
     $result.=' <span class="LC_nobreak">'.
 	'<a href="'.$jumpurl.'?inhibitmenu=yes" target="preview">'.
         &HTML::Entities::encode($values{'title'},'<>&"').'</a></span> '.
+        '<a href="javascript:;" onclick="set_wishlistlink('."'$values{'title'}','$jumpurl'".')" '.
+        'title="'.&mt('Set link to wishlist').'">'.
+        '<img class="LC_icon" src="/res/adm/pages/wishlist.png" '.
+        'alt="set wishlistlink" style="width:22px;"/>'.
+        '</a>'.
 	$link.' <b>'.$values{'author'}.'</b> ('.$values{'domain'}.')';
     return $result;
 }
@@ -3704,12 +3799,19 @@
     my $jumpurl=$values{'url'};
     $jumpurl=~s|^/ext/|http://|;
 
+    my $titleWL = ('Set link to wishlist');
     my $result=<<END;
 $prefix <img src="$icon" alt="" />
 <dl>
 <dt>URL:</dt>
     <dd><a href="$jumpurl?inhibitmenu=yes" 
-         target='preview'>$values{'url'}</a></dd>
+         target='preview'>$values{'url'}</a>
+         <a href="javascript:;" onclick="set_wishlistlink('$values{'title'}','$jumpurl')"
+            title="$titleWL">
+            <img class="LC_icon" src="/res/adm/pages/wishlist.png"
+            alt="set wishlistlink" style="width:22px;"/>
+         </a>
+    </dd>
 END
     foreach my $field ('title','author','domain','subject','keywords','notes',
                        'mimetag','language','creationdate','lastrevisiondate',

--wenzelju1281706357--