/** * Filters tags for bible references and changes their slugs to be bible reference friendly * * @param $term * @return object $term */ function bfox_blog_get_post_tag($term) { if ($ref = BfoxRefParser::no_leftovers($term->name)) { $term->slug = urlencode($ref->get_string()); } return $term; }
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; }
/** * Subtract bible references specified by a string * * @param string $ref_str */ public function sub_string($ref_str) { $this->sub_ref(BfoxRefParser::simple($ref_str)); }
/** * Parses HTML content for Bible references. Returns content modified by the optional $replace_func callback * * Optionally stores the total BfoxRef in $total_ref parameter * Optionally modifies the content using the $replace_func parameter * * @param string $html * @param BfoxRef $total_ref * @param function $replace_func * @return string HTML content modified by the optional $replace_func callback */ public static function simple_html($html, BfoxRef $total_ref = null, $replace_func = null) { $parser = new BfoxRefParser(); $parser->total_ref = $total_ref; // Save total_ref $parser->replace_func = $replace_func; // Modify string with the replace_func callback $parser->max_level = 1; // Include 2 letter book abbreviations, but not the risky ones (like so, is, ex, am) $parser->add_whole_books = false; // Don't allow whole book references return $parser->parse_string_html($html); }
/** * Returns a BfoxRef for the given content string * * @param string $content * @return BfoxRef */ function bfox_ref_from_content($content) { $ref = new BfoxRef(); BfoxRefParser::simple_html($content, $ref); return $ref; }
private function footnote_replace($match) { $this->footnote_index++; $note = "<a name='footnote_{$this->footnote_index}' href='#footnote_ref_{$this->footnote_index}'>[{$this->footnote_index}]</a> " . BfoxRefParser::simple_html($match[1]); $link = " <a name='footnote_ref_{$this->footnote_index}' href='#footnote_{$this->footnote_index}' title='" . strip_tags($match[1]) . "' class='ref_foot_link'>[{$this->footnote_index}]</a> "; $this->footnotes[] = $note; return $link; }
/** * Returns a BfoxRef for the given post content string * * @param string $content * @return BfoxRef */ function refFromPostContent($content) { $ref = new BfoxRef(); BfoxRefParser::simple_html($content, $ref); return $ref; }
<?php /* Note: For this script to work you have to modify parser.php: Make regex() public Make regex() return the book_regex as soon as it has been calculated */ require_once '../biblefox-ref.php'; for ($level = 0; $level < 3; $level++) { $p = new BfoxRefParser(); $p->max_level = $level; $p->forward = true; echo '"BfoxBookRegexForwardLevel' . ($level + 1) . '" = "' . addslashes($p->regex()) . '";'; echo "\n\n"; } for ($level = 0; $level < 3; $level++) { $p = new BfoxRefParser(); $p->max_level = $level; $p->forward = false; echo '"BfoxBookRegexReverseLevel' . ($level + 1) . '" = "' . addslashes($p->regex()) . '";'; echo "\n\n"; }
/** * Replaces bible references with bible links in a given html string * @param string $content * @return string */ function bfox_ref_replace_html($content, $callback = 'bfox_ref_replace_html_cb') { return BfoxRefParser::simple_html($content, null, $callback); }
function bfox_bp_activity_get_sql($sql) { // Check to see if this SQL has any search terms if (preg_match("/a.content LIKE '%(.*?)%'/i", $sql, $matches)) { // Check the search terms to see if there are any Bible references $leftovers = true; $ref = BfoxRefParser::simple($matches[1], $leftovers); if ($ref->is_valid()) { // Remove the bible references from the search terms if (!empty($leftovers)) { $leftovers = "a.content LIKE '%{$leftovers}%'"; } else { $leftovers = "1=1"; } $sql = str_replace($matches[0], $leftovers, $sql); // Modify the sql to have use the bible references table if (preg_match('/(SELECT)(.*)(WHERE.*)(ORDER.*)$/i', $sql, $matches)) { $table = bfox_activity_ref_table(); array_shift($matches); // Get rid of the first match which is the entire string $matches[0] .= ' SQL_CALC_FOUND_ROWS '; $matches[1] .= ' ' . $table->join_sql('a.id') . ' '; $matches[2] .= ' AND ' . $table->seqs_where($ref) . ' GROUP BY a.id '; $sql = implode('', $matches); // Make sure that we change the total SQL to use FOUND_ROWS() add_filter('bp_activity_get_total_sql', 'bfox_bp_activity_get_total_sql'); } } } return $sql; }