Newer
Older
Digital_Repository / OARiNZ / DIY / deb_package / eprints-3.0 / cgi / latest
nstanger on 7 Jun 2007 3 KB - Added debian package source.
  1. ######################################################################
  2. #
  3. # Show EPrints modified or added in the past 7 days
  4. #
  5. ######################################################################
  6. #
  7. # This file is part of GNU EPrints 2.
  8. #
  9. # Copyright (c) 2000-2004 University of Southampton, UK. SO17 1BJ.
  10. #
  11. # EPrints 2 is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; either version 2 of the License, or
  14. # (at your option) any later version.
  15. #
  16. # EPrints 2 is distributed in the hope that it will be useful,
  17. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. # GNU General Public License for more details.
  20. #
  21. # You should have received a copy of the GNU General Public License
  22. # along with EPrints 2; if not, write to the Free Software
  23. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. #
  25. ######################################################################
  26.  
  27. use EPrints;
  28.  
  29. use strict;
  30. my $session = new EPrints::Session;
  31. exit( 0 ) unless( defined $session );
  32.  
  33. my $ds = $session->get_repository->get_dataset( "archive" );
  34. my $page=$session->make_doc_fragment();
  35.  
  36. $page->appendChild( $session->html_phrase( "cgi/latest:intro" ) );
  37.  
  38. my $citation = $session->get_repository->get_conf( "latest_citation" );
  39.  
  40. my $seensome = 0;
  41. for( my $d=0; $d<7; ++$d )
  42. {
  43. my $t = time-60*60*24*$d;
  44. my $search = new EPrints::Search(
  45. filters => [
  46. {
  47. meta_fields=>[ 'metadata_visibility' ],
  48. value=>'show',
  49. match=>'EX',
  50. describe=>0,
  51. },
  52. ],
  53. custom_order => "-datestamp",
  54. session => $session,
  55. dataset => $ds,
  56. );
  57.  
  58. my $date = EPrints::Time::get_iso_date( $t );
  59. $search->add_field( $ds->get_field( "datestamp" ), $date );
  60. my $list = $search->perform_search();
  61.  
  62. if( $list->count() )
  63. {
  64. $seensome = 1;
  65.  
  66. my $day;
  67. if( $d == 0 )
  68. {
  69. $day = $session->html_phrase( "cgi/latest:today" );
  70. }
  71. elsif( $d == 1 )
  72. {
  73. $day = $session->html_phrase( "cgi/latest:yesterday" );
  74. }
  75. else
  76. {
  77. my $dow = (localtime($t))[6];
  78. $day = $session->html_phrase( "cgi/latest:day_".$dow );
  79. }
  80.  
  81. my $h2= $session->make_element( "h2" );
  82. $h2->appendChild( $day );
  83. $page->appendChild( $h2 );
  84.  
  85. my $type = $session->get_citation_type( $ds, $citation );
  86. my $container;
  87. if( $type eq "table_row" )
  88. {
  89. $container = $session->make_element(
  90. "table",
  91. class=>"ep_latest_list" );
  92. }
  93. else
  94. {
  95. $container = $session->make_element(
  96. "div",
  97. class=>"ep_latest_list" );
  98. }
  99. $page->appendChild( $container );
  100. my $n = 1;
  101. $search->map( sub{
  102. my( $session, $dataset, $item, $info ) = @_;
  103. my $row = $item->render_citation_link(
  104. $citation,
  105. n => [$n++, "INTEGER"] );
  106. if( $type eq "table_row" )
  107. {
  108. $container->appendChild( $row );
  109. }
  110. else
  111. {
  112. my $div = $session->make_element(
  113. "div",
  114. class=>"ep_latest_result" );
  115. $div->appendChild( $row );
  116. $container->appendChild( $div );
  117. }
  118. } );
  119. $page->appendChild( $session->render_ruler() );
  120. }
  121. $search->dispose();
  122. }
  123. unless( $seensome )
  124. {
  125. $page->appendChild( $session->html_phrase( "cgi/latest:none" ) );
  126. }
  127.  
  128. $page->appendChild( $session->html_phrase( "general:frontpage_link" ) );
  129. my $title = $session->html_phrase( "cgi/latest:title" );
  130. $session->build_page( $title, $page, "latest" );
  131. $session->send_page();
  132.  
  133. $session->terminate;