예제 #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_plan_reading_shortcode($atts)
{
    // [bible-reading plan="cbr" intersects="old"]
    extract(shortcode_atts(array('post_id' => 0, 'reading' => 'latest', 'intersects' => '', 'tool' => ''), $atts));
    if (empty($post_id)) {
        return;
    }
    if ($reading == 'latest') {
        $reading = bfox_plan_latest_reading($post_id);
    }
    $reading_id = intval($reading);
    if ($reading_id >= bfox_plan_reading_count($post_id)) {
        return;
    }
    $ref_str = bfox_plan_reading_ref_str($reading_id, $post_id);
    if (!empty($intersects)) {
        $ref = new BfoxRef($ref_str);
        $sub = new BibleGroupPassage('bible');
        $sub->sub_ref(new BibleGroupPassage($intersects));
        $ref->sub_ref($sub);
        $ref_str = $ref->get_string();
    }
    $link = bfox_ref_link($ref_str);
    $content = $link;
    if (!empty($tool)) {
        $passage = bfox_tool_shortcode(array('tool' => $tool, 'ref' => $ref_str));
        $content = "{$link} {$passage}";
    }
    return $content;
}
예제 #4
0
/**
 * Returns a WP_Query object with the posts that contain the given BfoxRef
 *
 * @param BfoxRef $ref
 * @return WP_Query
 */
function bfox_blog_query_for_ref(BfoxRef $ref)
{
    return new WP_Query('s=' . urlencode($ref->get_string()));
}
예제 #5
0
 public function test_add_ref()
 {
     $start = 'eze 14:10';
     $adds = array('eze 14:8-9', 'eze 14:6-7', 'eze 14:5-8', 'eze 14:4', 'eze 14:4-11', 'eze 14:5', 'eze 14:4-11', 'eze 14:4-5', 'eze 14:10-11', 'eze 14:1-2', 'eze 14:3-12', 'eze 13', 'eze 14:13-22', 'eze 15:1-100', 'eze 14:23');
     //$adds = array('eze 14:10');
     $ref = new BfoxRef($start);
     pre("start:" . $ref->get_string());
     foreach ($adds as $add) {
         $add_ref = new BfoxRef($add);
         $is_modified = $ref->add_ref($add_ref);
         pre(" + " . $add_ref->get_string() . " = " . $ref->get_string() . ' modified? ' . ($is_modified ? 'yes' : 'no'));
         //pre($ref);
     }
 }
예제 #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;
     }
 }
예제 #7
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;
 }
 function linkForTextAndRef($text, BfoxRef $ref)
 {
     return $this->linkForRefStr($ref->get_string(), array('text' => $text));
 }
예제 #9
0
 function linkForTextAndRef($text, BfoxRef $ref, $attributes = array())
 {
     $attributes['text'] = $text;
     return $this->linkForRefStr($ref->get_string(), $attributes);
 }
예제 #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;
    }
}