function getBibleDataByCode($bible_code) { # Get bible object $bible_object = getBibleByCode($bible_code); # Get bible data $bible_data = getBibleData($bible_object->getId()); # Return bible data return $bible_data; }
function getPassageHTML($passage_html_data = []) { # Get bible object if ($passage_html_data['bible_id']) { $bible_object = getBible($passage_html_data['bible_id']); } elseif ($passage_html_data['bible_code']) { $bible_object = getBibleByCode($passage_html_data['bible_code']); } else { $bible_object = getBibleByCode('kjv'); } # Get bible data $bible_data = getBibleData($bible_object->getId()); if ($passage_html_data['verse_id']) { # Get verse object $tag_verses_objects = [getVerse($passage_html_data['verse_id'])]; } elseif ($passage_html_data['tag_id']) { # Get tag object $tag_object = getTag($passage_html_data['tag_id']); # Get tag data $tag_data = getTagData($tag_object->getId()); # Get tag highlighter object $tag_highlighter_object = getTagHighlighter($passage_html_data['tag_highlighter_id']); # Get tag highlighter data $tag_highlighter_data = getTagHighlighterData($tag_highlighter_object->getId()); # Get tag verses ids $tag_verses_ids = $tag_object->getTagVerses()->getPrimaryKeys(); # Get verses objects $verses_objects = VerseQuery::create()->useTagVerseQuery()->filterByPrimaryKeys($tag_verses_ids)->endUse()->find(); } else { # Get verses by reference $verses_objects = getVersesByReference($passage_html_data['reference_string']); } # Start passage HTML $passage_html = <<<s <blockquote class="passage" data-tag-highlighter="{$tag_highlighter_data['id']}" data-tag-id="{$tag_data['id']}"> \t<div class="text"> s; # Add each verse to passage HTML foreach ($verses_objects as $verse_object) { $verse_data = getVerseData($verse_object->getId()); $verse_translation_object = getVerseTranslationByVerseId($verse_object->getId(), $bible_object->getId()); $verse_translation_data = getVerseTranslationData($verse_translation_object->getId()); $word_number = $verse_translation_data['previous_verses_word_count'] + 1; $passage_html .= <<<s \t\t<p> \t\t\t<sup>{$verse_data['number']}</sup> s; foreach ($verse_translation_data['words'] as $word_value) { $passage_html .= <<<s \t\t\t<span class="word" data-word="{$word_number}">{$word_value}</span> s; $word_number++; } if ($passage_html_data['show_tags']) { $verse_tags_objects = LessonTagQuery::create()->useTagQuery()->useTagVerseQuery()->filterByVerse($verse_object)->endUse()->endUse()->useLessonQuery()->orderById()->endUse()->find(); if ($verse_tags_objects) { $passage_html .= <<<s \t\t\t<span class="tags"> s; foreach ($verse_tags_objects as $verse_tag_object) { $lesson_data = getLessonData($verse_tag_object->getLessonId()); $tag_highlighter_object = getTagHighlighterByTagId($verse_tag_object->getTagId(), false, 'kjv'); $tag_highlighter_data = getTagHighlighterData($tag_highlighter_object->getId()); $passage_html .= <<<s \t\t\t\t<a class="tag" href="lesson.php?id={$lesson_data['Id']}" data-relevant-words="{$tag_highlighter_data['relevant_words']}" target="_blank" title="Lesson: {$lesson_data['Summary']}"></a> s; } $passage_html .= <<<s \t\t\t</span> s; } } $passage_html .= <<<s \t\t</p> s; } $passage_html .= <<<s \t</div> \t<div class="footer"> \t\t<cite> \t\t\t<span class="reference">{$passage_html_data['reference_string']}</span> · \t\t\t<span class="bible">{$bible_data['code']['formatted']}</span> \t\t</cite> s; # Add tag elements (if applicable) if ($passage_html_data['tag_id']) { $passage_html .= <<<s \t\t<div class="votes"> \t\t\t<span class="vote_count">{$tag_data['vote_count']}</span> votes \t\t\t<span class="vote_up icon-arrow-up"></span> \t\t\t<span class="vote_down icon-arrow-down"></span> \t\t</div> \t\t<div class="relevant_words"> \t\t\t<span class="edit icon-pencil" onclick="editTagHighlighter({$tag_highlighter_data['id']});"></span> \t\t\t<span class="confirm icon-tick" onclick="updateTagHighlighter({$tag_highlighter_data['id']});"></span> \t\t</div> \t\t<div class="tag"> \t\t\t<span class="delete icon-close" onclick="deleteTag({$passage_html_data['tag_id']});"></span> \t\t</div> \t\t<div class="handle">Move</div> s; } # Continue passage HTML $passage_html .= <<<s \t</div> </blockquote> s; # Add highlighting (if applicable) if ($passage_html_data['tag_highlighter_id']) { # Add words to highlight javascript $passage_html .= <<<s <script> \t\$(document).ready(function() { \t\tapplyTagHighlighter({$tag_highlighter_data['id']}, '{$tag_highlighter_data['relevant_words']}'); \t}); </script> s; } # Return passage HTML return $passage_html; }
function getTagHighlighterData($tag_id) { # Get tag highlighter object $tag_highlighter_object = getTagHighlighter($tag_id); # Get bible object $bible_object = $tag_highlighter_object->getBible(); # Get bible data $bible_data = getBibleData($bible_object->getId()); # Define tag highlighter data $tag_highlighter_data = ['id' => $tag_highlighter_object->getId(), 'bible' => $bible_data, 'relevant_words' => $tag_highlighter_object->getRelevantWords()]; # Return tag highlighter data return $tag_highlighter_data; }