/mostrequested-digital.php

https://github.com/tmacon/test_myrcpl · PHP · 88 lines · 59 code · 15 blank · 14 comment · 4 complexity · 3903aa006bd36c5dfe4f5d6829ecbd5b MD5 · raw file

  1. <?php
  2. require('sycom.inc');
  3. require('feedcreator.class.php');
  4. # RSS file name
  5. define('RSS_FILENAME', 'mostrequested-digital');
  6. # date function
  7. $date_string = gmstrftime('%Y-%m-%dT%T-08:00', gmmktime());
  8. # end date function
  9. $rss = new UniversalFeedCreator();
  10. # Prep the RSS.
  11. $rss->title = 'Most requested digital items at the Richland County Public Library';
  12. $rss->description = 'List of the digital items from our catalog with the most hold requests';
  13. $rss->link = 'http://hip.myrcpl.com';
  14. $rss->lastBuildDate = $date_string;
  15. $rss->pubDate = $date_string;
  16. $rss->copyright = 'Copyright 2009-2011, Richland County Public Library';
  17. sycom('SET ROWCOUNT 50');
  18. $sdbh = sycom("select distinct a15.title title,
  19. a11.author author,
  20. a14.processed processed,
  21. a12.creation_date creation_day,
  22. a13.collection collection,
  23. a13.item_status status,
  24. a16.descr descr
  25. from rv_bib_author a11,
  26. rv_bib_control a12,
  27. rv_item a13,
  28. rv_isbn a14,
  29. rv_title_inverted a15,
  30. collection a16
  31. where a11.bib_id = a12.bib_id and
  32. a11.bib_id = a13.bib_id and
  33. a11.bib_id = a14.bib_id and
  34. a11.bib_id = a15.bib_id and
  35. a13.collection = a16.collection and
  36. (a13.collection in('bd','c','cd','cf','dvd','lebd','ledvd','letb','letbf', 'mp3cd','mp3cdf','ply','romc','tb','tbf','tcd','tcdf','vc','vg')and
  37. a12.creation_date between '10/01/2009' and '05/30/2019') and
  38. a14.processed = (select min(processed) from rv_isbn where bib_id = a11.bib_id) and
  39. a13.item_status = (select min(item_status) from rv_item where bib_id = a11.bib_id)
  40. order by a12.creation_date desc
  41. ");
  42. if($sdbh != NULL)
  43. {
  44. while($srow = sybase_fetch_array($sdbh))
  45. { var_dump($srow);
  46. # Replace '&' characters with '&amp;'
  47. $srow = str_replace('&', '&amp;', $srow);
  48. /* foreach($srow as $scolumn)
  49. {
  50. # Remove non-text characters
  51. $scolumn = ereg_replace('[^[:xdigit:]]', '', $scolumn);
  52. var_dump($scolumn);
  53. } */
  54. $srow[3] = preg_replace('/\x1f[a-z]|\x1e/', '', $srow[3]);
  55. $item = new FeedItem();
  56. if($srow[3] == '')
  57. {
  58. $item->title = 'Title Not Available';
  59. }
  60. else
  61. {
  62. $item->title = $srow[3];
  63. }
  64. $item->link = 'http://myrcpl.ipac.sirsidynix.net/ipac20/ipac.jsp?profile=int&full=3100001~!' . $srow[4].'~!3';
  65. $item->description = '<img src="http://www.syndetics.com/index.aspx?type=xw12&isbn=' . trim($srow[5]) . '/SC.GIF&client=richlandcpubl" align="left"><p>&nbsp;&nbsp; '.$srow[1] . ' requests,</p><p>&nbsp;&nbsp; ' . $srow[0] . ' copies. </p><p class="clear"></p>';
  66. $rss->addItem($item);
  67. }
  68. }
  69. $rss->saveFeed('RSS0.92', RSS_FILENAME . '.rss');
  70. ?>