pollpress_filter('the_content'); $this->factory = new pollpress_poll_factory(); } function generate_page($matches) { $page = ''; // Strip down to the base URL $base_url = $_SERVER['REQUEST_URI']; $base_url = preg_replace('/[\?|\&]offset=\d+/', '', $base_url); $base_url = preg_replace('/[\?|\&]op=edit/', '', $base_url); $base_url = preg_replace('/[\?|\&]id=\d+/', '', $base_url); $append_option = '?'; if ( strstr($base_url, '?') ) $append_option = '&'; if ( isset( $_GET['id'] ) && isset( $_GET['op'] ) && $_GET['op'] == 'edit') { $id = (int) $_GET['id']; $page = $this->generate_voting_booth($base_url, $append_option, $id); } else { $page = $this->generate_poll_list($base_url, $append_option); } return $page; } function generate_voting_booth($base_url, $append_option, $poll_id) { $page = get_pollpress_voting_booth($poll_id, false); return $page; } function generate_poll_list($base_url, $append_option) { $page = ''; // Figure out what page we're on $polls = $this->factory->get_all_published_polls_by_date(); $poll_count = count($polls); if ( isset( $_GET['offset'] ) ) { $this->current_page = (int)$_GET['offset']; } $poll_start_index = $this->current_page * $this->polls_per_page; $poll_stop_index = $poll_start_index + $this->polls_per_page; if ( $poll_stop_index > $poll_count ) $poll_stop_index = $poll_count; // Now that we know the indices, strip down the array $polls = array_slice($polls, $poll_start_index, $poll_stop_index - $poll_start_index); // Iterate all the polls and output them if ( $poll_count ) { $page .= ''; $page .= '
' . __('On ') . mysql2date('l F d\, \@g:i:sa', $post->post_date) . '
'; $page .= '' . __('Votes: ') . $total_votes . '
'; $page .= '