Newer
Older
Digital_Repository / Repositories / Misc / cgi / latest_local
  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::Session;
  28. use EPrints::EPrint;
  29. use EPrints::SearchExpression;
  30.  
  31. use strict;
  32. my $session = new EPrints::Session;
  33. exit( 0 ) unless( defined $session );
  34.  
  35. my $ds = $session->get_archive()->get_dataset( "archive" );
  36. my $page=$session->make_doc_fragment();
  37.  
  38. $page->appendChild( $session->html_phrase( "cgi/latest:intro" ) );
  39.  
  40. my $citation = $session->get_archive->get_conf( "latest_citation" );
  41.  
  42. my $seensome = 0;
  43. for( my $d=0; $d<7; ++$d )
  44. {
  45. my $t = time-60*60*24*$d;
  46. my $searchexp = new EPrints::SearchExpression(
  47. session => $session,
  48. dataset => $ds );
  49.  
  50. my $date = EPrints::Utils::get_datestamp( $t );
  51. $searchexp->add_field( $ds->get_field( "datestamp" ), $date );
  52. $searchexp->perform_search();
  53.  
  54. if( $searchexp->count() )
  55. {
  56. $seensome = 1;
  57.  
  58. my $day;
  59. if( $d == 0 )
  60. {
  61. $day = $session->html_phrase( "cgi/latest:today" );
  62. }
  63. elsif( $d == 1 )
  64. {
  65. $day = $session->html_phrase( "cgi/latest:yesterday" );
  66. }
  67. else
  68. {
  69. my $dow = (localtime($t))[6];
  70. $day = $session->html_phrase( "cgi/latest:day_".$dow );
  71. }
  72.  
  73. my $h2= $session->make_element( "h2" );
  74. $h2->appendChild( $day );
  75. $page->appendChild( $h2 );
  76. $searchexp->map( sub{
  77. my( $session, $dataset, $item, $info ) = @_;
  78. my $p = $session->make_element( "p" );
  79. $p->appendChild( $item->render_citation_link( $citation ) );
  80. $page->appendChild( $p );
  81. } );
  82. }
  83. $searchexp->dispose();
  84. }
  85. unless( $seensome )
  86. {
  87. $page->appendChild( $session->html_phrase( "cgi/latest:none" ) );
  88. }
  89.  
  90. $page->appendChild( $session->render_ruler() );
  91.  
  92. $page->appendChild( $session->html_phrase( "general:frontpage_link" ) );
  93. my $title = $session->html_phrase( "cgi/latest:title" );
  94. $session->build_page( $title, $page, "latest" );
  95. $session->send_page();
  96.  
  97. $session->terminate;