예제 #1
0
 function setRef(BfoxRef $ref)
 {
     if ($ref->is_valid()) {
         $this->ref = $ref;
         $this->setLastViewedRefStr($ref->get_string());
     }
 }
예제 #2
0
 /**
  * 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);
 }
예제 #3
0
function bfox_tool_shortcode($atts)
{
    // [bible-tool tool="esv" ref="Matthew 1"]
    extract(shortcode_atts(array('tool' => '', 'ref' => ''), $atts));
    $bfoxTools = BfoxBibleToolController::sharedInstance();
    $tool = $bfoxTools->toolForShortName($tool);
    if (is_null($tool)) {
        return;
    }
    $ref = new BfoxRef($ref);
    if (!$ref->is_valid()) {
        return;
    }
    ob_start();
    $tool->echoContentForRef($ref);
    $content = ob_get_clean();
    return $content;
}
예제 #4
0
 function parsePassagesIntoReadings($passages, $readingSize, $allowPassageGroups = true)
 {
     $readingSize = max(1, $readingSize);
     if ($allowPassageGroups) {
         $ref = BfoxRefParser::with_groups($passages);
     } else {
         $ref = new BfoxRef($passages);
     }
     if ($ref->is_valid()) {
         $readingRefs = $ref->get_sections($readingSize);
         foreach ($readingRefs as $readingRef) {
             if ($readingRef->is_valid()) {
                 $this->addReading($readingRef);
             }
         }
     }
     return $readings;
 }
예제 #5
0
function bfox_bp_bible_directory_before_activity_loop()
{
    $ref = bfox_ref();
    // Try to get a ref from the REQUEST params if there isn't already an active ref
    if (!empty($_REQUEST['bfox_ref']) && !$ref->is_valid()) {
        $ref = new BfoxRef(urldecode($_REQUEST['bfox_ref']));
        if ($ref->is_valid()) {
            set_bfox_ref($ref);
        }
    }
    if ($ref->is_valid()) {
        // Make sure our bible references get added to the search terms
        add_filter('bp_ajax_querystring', 'bfox_bp_bible_directory_querystring', 20, 2);
        // Enable search term refs
        bfox_bp_activity_enable_search_term_refs();
        // Disable the search term refs after the activity loop
        add_action('bp_after_activity_loop', 'bfox_bp_activity_disable_search_term_refs');
    }
}
예제 #6
0
 public function set_ref(BfoxRef $ref)
 {
     if ($ref->is_valid()) {
         $this->ref_str = $ref->get_string();
         $this->ref_where = 'AND ' . $ref->sql_where();
         $this->description .= ' in ' . $this->ref_str;
     }
 }
 /**
  * Return the bible references for a given blog post
  *
  * @param $post
  * @return BfoxRef
  */
 function refsForTaxonomiesOfPost($post)
 {
     if (!is_object($post)) {
         $post = get_post($post);
     }
     $refs_for_taxonomies = array();
     if (!$post) {
         return $refs_for_taxonomies;
     }
     $taxonomies = $this->indexedTaxonomiesForPostType($post->post_type);
     foreach ($taxonomies as $taxonomy) {
         if ('post_content' == $taxonomy) {
             $ref = $this->core->refs->refFromPostContent($post->post_content);
         } else {
             $ref = new BfoxRef();
             $terms = wp_get_post_terms($post->ID, $taxonomy, array('fields' => 'names'));
             foreach ($terms as $term) {
                 $ref->add_ref($this->core->refs->refFromTag($term));
             }
         }
         if ($ref && $ref->is_valid()) {
             $refs_for_taxonomies[$taxonomy] = $ref;
         }
         unset($ref);
     }
     return $refs_for_taxonomies;
 }
예제 #8
0
 public static function readings_from_passages($passages, $chunk_size)
 {
     $chunk_size = max(1, $chunk_size);
     $ref = new BfoxRef($passages);
     $readings = array();
     if ($ref->is_valid()) {
         $chunks = $ref->get_sections($chunk_size);
         foreach ($chunks as $chunk) {
             if ($chunk->is_valid()) {
                 $readings[] = $chunk;
             }
         }
     }
     return $readings;
 }
예제 #9
0
 function bfox_wp_get_object_terms($terms)
 {
     $hidden_ref = new BfoxRef($_REQUEST['bfox_ref']);
     if ($hidden_ref->is_valid()) {
         $term = new stdClass();
         $term->name = $hidden_ref->get_string();
         $terms = array($term);
     }
     return $terms;
 }
예제 #10
0
/**
 * Calculates the bible references for an activity before it is saved
 *
 * @param $activity
 */
function bfox_bp_activity_before_save($activity)
{
    global $bp;
    // For blog posts, index the full post content and tags
    if ($activity->component == $bp->blogs->id && $activity->type == 'new_blog_post') {
        switch_to_blog($activity->item_id);
        $ref = bfox_blog_post_get_ref($activity->secondary_item_id);
        restore_current_blog();
    } elseif ($activity->component == $bp->groups->id && ($activity->type == 'new_forum_post' || $activity->type == 'new_forum_topic')) {
        // Get the forum post
        if ($activity->type == 'new_forum_topic') {
            list($post) = bp_forums_get_topic_posts(array('topic_id' => $activity->secondary_item_id, 'per_page' => 1));
        } else {
            $post = bp_forums_get_post($activity->secondary_item_id);
        }
        // Index the post text
        $ref = bfox_ref_from_content($post->post_text);
        // Only index the tags for the first post in a topic
        if ($activity->type == 'new_forum_topic') {
            $tags = bb_get_topic_tags($post->topic_id, array('fields' => 'names'));
            foreach ($tags as $tag) {
                $ref->add_ref(bfox_ref_from_tag($tag));
            }
        }
    } else {
        $ref = bfox_ref_from_content($activity->content);
    }
    // Add any 'Bible Tag' read passage strings
    if ('activity_update' == $activity->type && isset($_REQUEST['bfox_read_ref_str'])) {
        $tag_ref = new BfoxRef($_REQUEST['bfox_read_ref_str']);
        if ($tag_ref->is_valid()) {
            $activity->bfox_read_ref_str = $tag_ref->get_string();
            $activity->action = str_replace('posted an update', __('posted an update about ', 'bfox') . $activity->bfox_read_ref_str, $activity->action);
            $ref->add_ref($tag_ref);
        }
    }
    if ($ref->is_valid()) {
        $activity->bfox_ref = $ref;
    }
}