/** * Returns a BfoxRef for the total of all Bible references in the reading plan * @param integer $post_id * @return BfoxRef $total_ref */ function bfox_plan_total_ref($post_id = 0) { $total_ref = new BfoxRef(); $reading_data = bfox_plan_reading_data($post_id); foreach ($reading_data->refs as $ref) { $total_ref->add_ref($ref); } return $total_ref; }
public function replace_cb($matches) { $text = $matches[0]; if (!$this->forward) { $text = strrev($text); } if ($this->forward) { if (!empty($matches[2])) { $synonym = $matches[2]; } else { if (!empty($matches[7])) { $synonym = '1' . $matches[7]; } else { if (!empty($matches[12])) { $synonym = '2' . $matches[12]; } else { if (!empty($matches[17])) { $synonym = '3' . $matches[17]; } } } } } else { if (!empty($matches[19])) { $synonym = $matches[19]; } else { if (!empty($matches[15])) { $synonym = $matches[15] . '1'; } else { if (!empty($matches[10])) { $synonym = $matches[10] . '2'; } else { if (!empty($matches[5])) { $synonym = $matches[5] . '3'; } } } } } if (!$this->forward) { $synonym = strrev($synonym); } $synonym = strtolower(preg_replace('/\\s+/', ' ', $synonym)); if ($book_id = self::$book_id_lookup[$synonym]) { $ref = new BfoxRef(); if ($this->forward) { $cv_str = $matches[18]; } else { $cv_str = strrev($matches[1]); } $cv_str = ltrim(trim($cv_str), '.'); if (!empty($cv_str)) { self::parse_book_str($ref, $book_id, $cv_str); } else { $ref->add_whole_book($book_id); } if ($ref->is_valid()) { if (isset($this->ref_array)) { $this->ref_array[] = $ref; } if (isset($this->total_ref)) { $this->total_ref->add_ref($ref); } if (isset($this->replace_func)) { $text = call_user_func_array($this->replace_func, array($text, $ref)); } if (isset($this->leftovers)) { $text = ''; } } } if (!$this->forward) { $text = strrev($text); } return $text; }
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); } }
/** * 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; }
public static function compact_readings($readings) { $ref = new BfoxRef(); foreach ($readings as $reading) { $ref->add_ref($reading); } return $ref; }
/** * Return the bible references for a given blog post * * @param $post * @return BfoxRef */ function bfox_blog_post_get_refs_for_taxonomies($post) { if (!is_object($post)) { $post = get_post($post); } $refs_for_taxonomies = array(); $taxonomies = bfox_post_type_ref_taxonomies($post->post_type); foreach ($taxonomies as $taxonomy) { if ('post_content' == $taxonomy) { $ref = bfox_ref_from_content($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(bfox_ref_from_tag($term)); } } if ($ref && $ref->is_valid()) { $refs_for_taxonomies[$taxonomy] = $ref; } unset($ref); } return $refs_for_taxonomies; }