Beispiel #1
0
 public function get_string($name = '')
 {
     $str = BibleMeta::get_book_name($this->book, $name);
     if (!empty($this->num_str)) {
         $str .= ' ' . $this->num_str;
     }
     return $str;
 }
 /**
  * Create an array of values to use in place of variables in template strings
  *
  * @param BfoxRef $ref
  * @return array
  */
 private static function template_vars(BfoxRef $ref)
 {
     $book_name = '';
     $ch1 = $vs1 = 0;
     if ($ref->is_valid()) {
         $bcvs = BfoxRef::get_bcvs($ref->get_seqs());
         $books = array_keys($bcvs);
         $book_name = BibleMeta::get_book_name($books[0]);
         $cvs = array_shift($bcvs);
         $cv = array_shift($cvs);
         list($ch1, $vs1) = $cv->start;
     }
     return array('%ref%' => urlencode($ref->get_string()), '%book%' => urlencode($book_name), '%chapter%' => $ch1, '%verse%' => $vs1);
 }
 function setRef(BfoxRef $ref)
 {
     $this->_ref = $ref;
     $this->_bookName = '';
     $this->_chapterNum = $this->_verseNum = 0;
     if ($this->_ref->is_valid()) {
         $bcvs = BfoxRef::get_bcvs($this->_ref->get_seqs());
         $books = array_keys($bcvs);
         $this->_bookName = BibleMeta::get_book_name($books[0]);
         $cvs = array_shift($bcvs);
         $cv = array_shift($cvs);
         list($this->_chapterNum, $this->_verseNum) = $cv->start;
     }
     foreach ($this->varCallbacks as $var => $callback) {
         $params = array();
         if (isset($this->varCallbackParams[$var])) {
             $params = (array) $this->varCallbackParams[$var];
         }
         $this->varValues[$var] = call_user_func_array($callback, $params);
     }
 }
 /**
  * String for a value at a certain level
  *
  * The string is either a book name, a chapter number, or a verse number
  */
 function stringForValueAtLevel($value, $level)
 {
     if (0 == $level) {
         return BibleMeta::get_book_name($value, $this->bookNameFormat);
     }
     return $value;
 }
Beispiel #5
0
 function open_book($data)
 {
     $this->save_verse();
     unset($this->vs['book']);
     // Try to get the book's name from the 'id' attribute
     // If we can't the ID attribute is invalid
     if ($book_id = self::get_book_id($this->get_attribute('id'))) {
         $this->vs['book'] = $book_id;
         $this->vs['book_name'] = BibleMeta::get_book_name($book_id);
     } else {
         $this->invalidate_attribute('id');
         $this->vs['book_name'] = 'Chapter';
     }
     $this->vs['chapter'] = 0;
     $this->vs['verse'] = 0;
     return $data;
 }
 public function get_string($name = '')
 {
     return BibleMeta::get_book_name($this->group, $name);
 }
    if (1 != $book) {
        echo ", ";
    }
    echo "BfoxBook{$book_name}MaxVerseCounts";
}
echo " };\n";
echo "\n\n\n";
foreach (BibleMeta::$min_verse_counts as $book => $array) {
    if ($book > 66) {
        break;
    }
    $book_name = BibleMeta::get_book_name($book);
    $book_name = preg_replace('/\\s+/', '', $book_name);
    echo "BfoxBook{$book_name},\n";
}
echo "\n\n\n";
foreach (BibleMeta::$min_verse_counts as $book => $array) {
    if ($book > 66) {
        break;
    }
    $book_name = BibleMeta::get_book_name($book);
    echo "\"BfoxBookNameDefaultForBook{$book}\" = \"{$book_name}\";\n\n";
}
echo "\n\n\n";
foreach (BibleMeta::$min_verse_counts as $book => $array) {
    if ($book > 66) {
        break;
    }
    $book_name = BibleMeta::get_book_name($book, BibleMeta::name_short);
    echo "\"BfoxBookNameShortForBook{$book}\" = \"{$book_name}\";\n\n";
}
 /**
  * Creates an output string with a table row for each verse in the $verses data
  *
  * @param array $verses results from get_results() select statement with verse data
  * @param array $words the list of words to highlight as having been used in the search
  * @return string
  */
 function chapter_content($verses)
 {
     $chapter_content = array();
     if ('ESV' == $this->display_translation->short_name) {
         foreach ($verses as $unique_id => $match) {
             list($book, $chapter, $verse) = BibleVerse::calc_ref($unique_id);
             $book_name = BibleMeta::get_book_name($book);
             $chap_name = "{$book_name} {$chapter}";
             $ref_str = "{$chap_name}:{$verse}";
             $chapter_content[$chap_name][$ref_str] = $this->display_translation->get_javascript_placeholder($ref_str, __('Loading...', 'bfox'));
         }
         return $chapter_content;
     }
     $count = count($verses);
     if (0 < $count) {
         global $wpdb;
         // Get the verse data for these verses (from the global bible translation)
         $queries = array();
         foreach ($verses as $unique_id => $match) {
             $queries[] = $wpdb->prepare('unique_id = %d', $unique_id);
         }
         $verses = $wpdb->get_results("SELECT * FROM {$this->display_translation->table} WHERE " . implode(' OR ', $queries));
         unset($queries);
         // Turn the words into keys
         $words = array_fill_keys($this->words, TRUE);
         $book = 0;
         $chapter = 0;
         foreach ($verses as $verse) {
             if ($book != $verse->book_id || $chapter != $verse->chapter_id) {
                 $book = $verse->book_id;
                 $chapter = $verse->chapter_id;
                 $book_name = BibleMeta::get_book_name($book);
                 $chap_name = "{$book_name} {$chapter}";
                 $chapter_content[$chap_name] = array();
             }
             // TODO3: Find a good way to display footnotes in search (until then, just get rid of them)
             $verse->verse = preg_replace('/<footnote>.*<\\/footnote>/Ui', '', $verse->verse);
             // Get the words in the verse as an associative array (use '_' as a part of a word)
             $verse_words = str_word_count($verse->verse, 2, '_');
             // For each word in the verse that is also a search word, bold it
             foreach (array_reverse($verse_words, TRUE) as $pos => $verse_word) {
                 if ($words[strtolower($verse_word)]) {
                     $verse->verse = substr_replace($verse->verse, "<strong>{$verse_word}</strong>", $pos, strlen($verse_word));
                 }
             }
             $ref_str = "{$chap_name}:{$verse->verse_id}";
             $chapter_content[$chap_name][$ref_str] = $verse->verse;
         }
     }
     return $chapter_content;
 }