/** * Subtract bible references specified by a string * * @param string $ref_str */ public function sub_string($ref_str) { $this->sub_ref(BfoxRefParser::simple($ref_str)); }
/** * Returns a BfoxRef for the given tag string * * @param string $tag * @return BfoxRef */ function refFromTag($tag) { return BfoxRefParser::simple($tag); }
/** * Returns a BfoxRef for the given tag string * * @param string $tag * @return BfoxRef */ function bfox_ref_from_tag($tag) { return BfoxRefParser::simple($tag); }
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; }