예제 #1
0
function bfox_blog_admin_post_check_refresh($show_settings)
{
    if ($show_settings && $_GET['bfox_post_refresh']) {
        global $wpdb;
        $table = bfox_blog_post_ref_table();
        if ($_GET['page'] == 'bfox-ms') {
            $network_refresh = true;
            $blog_ids = $wpdb->get_col($wpdb->prepare("SELECT blog_id FROM {$wpdb->blogs} WHERE blog_id >= %d AND site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AND archived = '0' ORDER BY blog_id ASC", $_GET['blog_id']));
        } else {
            $network_refresh = false;
            $blog_ids = array($GLOBALS['blog_id']);
        }
        extract(bfox_blog_admin_post_refresh_status($network_refresh));
        // If the previous status is finished, then we must be starting a new complete refresh
        if ($date_finished) {
            $blog_offset = $scan_total = $index_total = $blog_count = $date_finished = 0;
        }
        $limit = (int) $_GET['limit'];
        if (empty($limit)) {
            $limit = 100;
        }
        // Loop until we've reach the limit or run out of blogs to scan
        while ($limit > 0 && !empty($blog_ids)) {
            $blog_id = array_shift($blog_ids);
            if ($network_refresh) {
                switch_to_blog($blog_id);
            }
            if (0 == $blog_offset) {
                $table->check_install();
                $table->delete_all();
            }
            // Refresh this set of blog posts
            extract(BfoxRefDbTable::simple_refresh($table, 'ID', '', $limit, $blog_offset));
            $limit -= $scanned;
            $scan_total += $scanned;
            $index_total += $indexed;
            // If the offset is >= the total posts, then we've finished with this blog
            $blog_offset += $scanned;
            if ($blog_offset >= $total) {
                $blog_offset = 0;
                $blog_id = 0;
                $blog_count++;
            }
            if ($network_refresh) {
                restore_current_blog();
            }
        }
        if (empty($blog_id) && !empty($blog_ids)) {
            $blog_id = array_shift($blog_ids);
        }
        $is_running = $blog_offset || $blog_id;
        $next_url = bfox_blog_admin_post_refresh_url($network_refresh, $is_running);
        if ($is_running) {
            $date_finished = 0;
            $next_url = add_query_arg(compact('blog_id', 'limit'), $next_url);
        } else {
            $date_finished = time();
        }
        bfox_blog_admin_post_refresh_set_status(compact('blog_offset', 'scan_total', 'index_total', 'blog_count', 'date_finished'), $network_refresh);
        ?>
		<h3><?php 
        _e('Refreshing Bible Index...', 'bfox');
        ?>
</h3>
		<?php 
        bfox_blog_admin_post_refresh_output_status($network_refresh);
        ?>

		<p><?php 
        _e("If your browser doesn't start loading the next page automatically click this link:", 'bfox');
        ?>
 <a class="button" href="<?php 
        echo $next_url;
        ?>
"><?php 
        _e("Continue", 'bfox');
        ?>
</a></p>
		<script type='text/javascript'>
		<!--
		function nextpage() {
			location.href = "<?php 
        echo $next_url;
        ?>
";
		}
		setTimeout( "nextpage()", 250 );
		//-->
		</script>
		<?php 
        $show_settings = false;
    }
    return $show_settings;
}
 /**
  * Scans a given number of blog posts for Bible references
  *
  * @param unknown_type $limit
  */
 private function scanPosts($limit)
 {
     $indexedPostTypes = $this->options->value('indexedPostTypes');
     if ($indexedPostTypes != $this->postTypes) {
         // If the configuration has changed, reset the indexes
         $this->options->setValue('indexStatus', array());
         $this->options->setValue('indexedPostTypes', $this->postTypes);
     }
     $status = $this->options->value('indexStatus');
     if (!isset($status['scanned'])) {
         $status = array('scanned' => 0, 'indexed' => 0, 'total' => 0);
     }
     if ($status['scanned'] < $status['total']) {
         extract(BfoxRefDbTable::simple_refresh($table, 'ID', '', $limit, $status['scanned']));
         $status['scanned'] += $scanned;
         $status['indexed'] += $indexed;
         $status['total'] = $total;
         $this->options->setValue('indexStatus', $status);
     }
 }
예제 #3
0
function bfox_bp_admin_activity_check_refresh($show_settings)
{
    if ($show_settings && $_GET['bfox_activity_refresh']) {
        $table = bfox_activity_ref_table();
        // If this is the first page of refreshing, delete all the activities
        $offset = (int) $_GET['offset'];
        if (0 == $offset) {
            $table->delete_all();
        }
        // Refresh this set of activities
        extract(BfoxRefDbTable::simple_refresh($table, 'id', 'content', $_GET['limit'], $offset));
        // Get old values from bfox_bp_admin_activity_refresh_status() and increment them with the new values from BfoxRefDbTable::simple_refresh())
        extract(bfox_bp_admin_activity_refresh_status());
        // If the previous status is finished, then we must be starting a new complete refresh
        if ($date_finished) {
            $blog_offset = $scan_total = $index_total = $blog_count = $date_finished = 0;
        }
        $scan_total += $scanned;
        $index_total += $indexed;
        $offset += $scanned;
        $is_running = $offset < $total;
        if ($is_running) {
            $date_finished = 0;
        } else {
            $date_finished = time();
        }
        bfox_bp_admin_activity_refresh_set_status(compact('scan_total', 'index_total', 'total', 'date_finished'));
        ?>
		<h3><?php 
        _e('Refreshing Bible Index...', 'bfox');
        ?>
</h3>
		<?php 
        bfox_bp_admin_activity_refresh_output_status();
        ?>

		<?php 
        $next_url = add_query_arg(compact('offset'), bfox_bp_admin_activity_refresh_url(true));
        if ($is_running) {
            ?>
		<p><?php 
            _e("If your browser doesn't start loading the next page automatically click this link:", 'bfox');
            ?>
 <a class="button" href="<?php 
            echo $next_url;
            ?>
"><?php 
            _e("Continue", 'bfox');
            ?>
</a></p>
		<script type='text/javascript'>
		<!--
		function nextpage() {
			location.href = "<?php 
            echo $next_url;
            ?>
";
		}
		setTimeout( "nextpage()", 250 );
		//-->
		</script>
		<?php 
        }
        $show_settings = false;
    }
    return $show_settings;
}