public static function run($refresh = FALSE) { global $wpdb; $msgs = array(); // If this is a full refresh, then start by dropping all the possible translation tables if ($refresh) { $installed = BfoxTrans::get_installed(); $msgs[] = 'Refresh: Dropping all installed translation tables'; foreach ($installed as $trans) { $wpdb->query("DROP TABLE IF EXISTS {$trans->table}"); $msgs[] = "Dropped {$trans->table}"; } } // Get the translation files $files = array(); $trans_ids = BfoxTrans::get_ids_by_short_name(); $translations_dir = opendir(self::dir); if ($translations_dir) { while (($file_name = readdir($translations_dir)) !== false) { if (substr($file_name, -9) == '-usfx.xml') { $trans_name = strtoupper(substr($file_name, 0, -9)); if (isset($trans_ids[$trans_name])) { $files[$trans_ids[$trans_name]] = $file_name; $msgs[] = "Found translations file: {$file_name}"; } } } } @closedir($translations_dir); $installed = BfoxTrans::get_installed(); $done_installing = FALSE; // Loop through all the translation files we have, and if not installed, install them foreach ($files as $id => $file) { if (!isset($installed[$id])) { if (!$done_installing) { $trans = new BfoxTrans($id); self::create_translation_table($trans); self::load_usfx($trans, $file); $msgs[] = "Installed: {$file} ({$trans->short_name} (ID: {$trans->id}) - {$trans->long_name})"; $installed[$id] = $trans; $done_installing = TRUE; } else { $msgs[] = "NOTE: Still need to install: {$file}"; } } else { $msgs[] = "Skipped: {$file} (already installed)"; } } // Enable all the installed translations BfoxTrans::set_enabled($installed); return $msgs; }
/** * Create the translation index table * */ public static function refresh_search_index() { global $wpdb; $wpdb->query('DROP TABLE IF EXISTS ' . self::index_table); // Note this function creates the table with dbDelta() which apparently has some pickiness // See http://codex.wordpress.org/Creating_Tables_with_Plugins#Creating_or_Updating_the_Table require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta("CREATE TABLE " . self::index_table . " (\n\t\t\t\tunique_id MEDIUMINT UNSIGNED NOT NULL,\n\t\t\t\tbook_id TINYINT UNSIGNED NOT NULL,\n\t\t\t\ttrans_id SMALLINT UNSIGNED NOT NULL,\n\t\t\t\tindex_text TEXT NOT NULL,\n\t\t\t\tFULLTEXT (index_text),\n\t\t\t\tINDEX (unique_id)\n\t\t\t);"); $msg = "Dropped and recreated the index table.<br/>"; // Loop through each enabled bible translation and refresh their index data $translations = BfoxTrans::get_enabled(); foreach ($translations as $translation) { $msg .= "Refreshing {$translation->long_name} (ID: {$translation->id})...<br/>"; self::refresh_translation_index($translation); } $msg .= 'Finished<br/>'; return $status; }
<?php // Limit the ref to 10 chapters $input_ref = new BfoxRef($_REQUEST['bfoxp']); list($ref) = $input_ref->get_sections(10, 1); $trans_ids = BfoxTrans::get_ids_by_short_name(); $trans = new BfoxTrans($trans_ids[$_REQUEST['trans']]); // Get the show options param (default is to show options) $show_options = !(isset($_REQUEST['opts']) && !$_REQUEST['opts']); $allow_tooltips = !!$_REQUEST['allow_tooltips']; // TODO: We shouldn't really use tooltips on the print screen, but use inline scriptures if (!$allow_tooltips) { wp_deregister_script('bfox-blog'); } // All we need are the scripture styles and script // TODO: Buddypress is adding a few other syles which we don't need to load here wp_enqueue_script('bfox-theme-print', BFOX_TRANS_URL . '/theme/print.js', array('jquery')); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?> > <head profile="http://gmpg.org/xfn/11"> <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?> ; charset=<?php