function getBibleData($bible_id) { # Get bible object $bible_object = getBible($bible_id); # Define bible data $bible_data = ['code' => ['default' => $bible_object->getCode(), 'formatted' => strtoupper($bible_object->getCode())], 'id' => $bible_object->getId(), 'name' => $bible_object->getName()]; # 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; }
<?php if (isset($_POST['type'])) { switch ($_POST['type']) { case "bible": if (isset($_POST['extra'])) { $extra = $_POST['extra']; getBible($extra); } break; case "progress": getProgress(); break; } } function getBible($extra) { $user = $extra['user']; echo "\n <div class=\"content-block\">\n <div class=\"content-block-inner\">\n <p>Username: {$user}</p>\n <p>Extra: {$extra}</p>\n </div>\n </div>\n "; } /** Usage Guide: * Data Syntax: * { 'type': "bible/progress", 'extra': { 'user': *, ... } } **/
function getTagHighlighterByTagId($tag_id, $bible_id = false, $bible_code = false) { # Get bible object if ($bible_id) { $bible_object = getBible($bible_id); } elseif ($bible_code) { $bible_object = getBibleByCode($bible_code); } # Get tag highlighter object $tag_highlighter_object = TagHighlighterQuery::create()->filterByTagId($tag_id)->filterByBible($bible_object)->findOne(); # Return tag highlighter object return $tag_highlighter_object; }