September 24, 2008

BC or AD - a zend view helper

Apologies for the lack of posting on the blogs recently. I'm currently engaged in rebuilding the Scheme database to make it more usable and also more joined up. This is going to take a while and I'm using Zend Framework as the base. I think I should share some code and here's a view helper for changing negative integers to a BC date and positive integers to an AD date. The class is shown below:

PHP:
  1. <?php
  2. class DEJP_View_Helper_ADBC
  3. {
  4. public function ADBC($string="", $suffix="BC", $prefix="AD")
  5. {
  6.  
  7. if ($string  <0) {
  8. return  abs($string). ' ' .$suffix;
  9.  
  10. //BC calendar dates are displayed with the BC as a suffix - eg 2600 BC
  11. }
  12. else
  13. return $prefix.' '. abs($string);
  14.  
  15. //AD calendar dates are displayed with AD as a prefix - eg. AD 410
  16. }
  17. }
  18.  
  19. ?>

And it would be used as such within your view script:

PHP:
  1. <?php echo $this->ADBC($table->field);?>

If I create anymore that might be useful, I'll add them.

OpenCalais helped to tag this with:

Possibly related posts: Quick search database fields/ plugin constructionMonitoring eBay for illicit antiquitiesNeil MacGregor to chair ‘World Collections Programme’, to share British Cultural Excellence with Africa and Asia

2 Comments »

  1. BCE and CE, surely? ;)

    Comment by Andrew Larcombe — September 24, 2008 @ 11:55 pm

  2. I don’t go for that :)

    Comment by Daniel Pett — September 25, 2008 @ 8:02 am

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

The content contained within the Blog's pages do not represent an official position from any of the organisations associated with the Portable Antiquities Scheme. They are solely those of the post's author.

The British Museum, Great Russell Street, London WC1B 3DG | Disclaimer | Privacy Policy | © 2006
E: T: +44 (0)20 7323 8611