Verse by Verse recitation

nbz - July 30, 2009 - 19:15
Project:Quran
Version:6.x-4.0
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

Just adding here that that would be a good feature - I have managed to get this hacked up onto my site: http://www.therevival.co.uk/quran , but it can probably be done better - it looks ugly and the play button seems to be in not the best location.

I used http://versebyversequran.com/ to provide the verse by verse recitation and use the recitation by Qari Mishari Al Afasy: http://www.versebyversequran.com/data/Alafasy_128kbps/

#1

nbz - August 5, 2009 - 18:08

Here is the modified fuinction that I am using on my site:

<?php
function _quran_unite($chapter_number, $verse_number, $arabic, $translation, $activate_url = FALSE, $highlighted_words = array(), $found_on_arabic = FALSE) {
 
// We highlight around non-indexable or CJK characters. // taken from Drupal search.module
 
$boundary = '(?:(?<=['. QURAN_PREG_CLASS_SEARCH_EXCLUDE . QURAN_PREG_CLASS_CJK .'])|(?=['. QURAN_PREG_CLASS_SEARCH_EXCLUDE .QURAN_PREG_CLASS_CJK .']))';

  if (
_quran_local_settings('activate_player')) {
   
drupal_add_js(drupal_get_path('module', 'quran') .'/external.js', 'module');
  }

 
$audio_url = 'http://www.versebyversequran.com/data/Alafasy_128kbps/' . str_pad($chapter_number, 3, '0', STR_PAD_LEFT) . str_pad($verse_number, 3, '0', STR_PAD_LEFT) . '.mp3';

  if (!empty(
$highlighted_words)) {
    if (
$found_on_arabic) {
     
$arabic = preg_replace('/'. $boundary .'('. implode('|', $highlighted_words) .')'. $boundary .'/iu', '<strong>\0</strong>', $arabic);
    } else {
     
$translation = preg_replace('/'. $boundary .'('. implode('|', $highlighted_words) .')'. $boundary .'/iu', '<strong>\0</strong>', $translation);
    }
  }

 
// Prepare the rendering result
 
$render = '<a name="verse'. $verse_number .'"></a><div style="margin:0.5em 0 0 0;">'. $verse_number .'';
 
$render .= '<div style="font-size:1.5em;text-align:right"><a href="'. $audio_url .'" title="'. $translation .'">'. $arabic .'</a></div>';
  if (
$activate_url) {
   
$url = 'quran/'. $chapter_number;
   
$page = _quran_number_to_page($verse_number);

   
$render .= '<div style="text-align:left">'. l($translation, $url, array('html' => TRUE, 'query' => 'page='. $page .'#verse'. $verse_number)) .'</div>';
  } else {
   
$render .= '<div style="text-align:left">'. $translation .'</div>';
  }
 
$render .= '</div>';

  return
$render;
}
?>

You can see it in action at http://www.therevival.co.uk/quran

 
 

Drupal is a registered trademark of Dries Buytaert.