Completed
Push — develop ( aad3f3...839a66 )
by Zack
15:14 queued 02:19
created

render_frontend()   B

Complexity

Conditions 5
Paths 7

Size

Total Lines 39
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 5.0342

Importance

Changes 0
Metric Value
cc 5
eloc 17
nc 7
nop 3
dl 0
loc 39
ccs 16
cts 18
cp 0.8889
crap 5.0342
rs 8.439
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 9 and the first side effect is on line 73.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
4
/**
5
 * Widget to display pagination info
6
 *
7
 * @extends GravityView_Widget
8
 */
9
class GravityView_Widget_Pagination_Info extends \GV\Widget {
10
11
	/**
12
	 * Does this get displayed on a single entry?
13
	 * @var boolean
14
	 */
15
	protected $show_on_single = false;
16
17 2
	function __construct() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
18
19 2
		$this->widget_description = __('Summary of the number of visible entries out of the total results.', 'gravityview' );
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
20
21
		$default_values = array(
22 2
			'header' => 1,
23
			'footer' => 1,
24
		);
25
26 2
		$settings = array();
27
28 2
		parent::__construct( __( 'Show Pagination Info', 'gravityview' ) , 'page_info', $default_values, $settings );
29 2
	}
30
31 1
	public function render_frontend( $widget_args, $content = '', $context = '') {
32 1
		$gravityview_view = GravityView_View::getInstance();
33
34 1
		if( !$this->pre_render_frontend() ) {
0 ignored issues
show
introduced by
Expected 1 space after "!"; 0 found
Loading history...
35
			return;
36
		}
37
38 1
		if( !empty( $widget_args['title'] ) ) {
0 ignored issues
show
introduced by
Expected 1 space after "!"; 0 found
Loading history...
39
			echo $widget_args['title'];
0 ignored issues
show
introduced by
Expected next thing to be a escaping function, not '$widget_args'
Loading history...
40
		}
41
42 1
		$pagination_counts = $gravityview_view->getPaginationCounts();
43
44 1
		$total = $first = $last = null;
45
46 1
		$output = '';
47
48 1
		if( ! empty( $pagination_counts ) ) {
49
50 1
			$first = $pagination_counts['first'];
51 1
			$last = $pagination_counts['last'];
52 1
			$total = $pagination_counts['total'];
53
54 1
			$class = !empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : '';
0 ignored issues
show
introduced by
Expected 1 space after "!"; 0 found
Loading history...
55 1
			$class = gravityview_sanitize_html_class( $class );
56
57 1
			$output = '<div class="gv-widget-pagination '.$class.'"><p>'. sprintf(__( 'Displaying %1$s - %2$s of %3$s', 'gravityview' ), number_format_i18n( $first ), number_format_i18n( $last ), number_format_i18n( $total ) ) . '</p></div>';
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
58
		}
59
60
		/**
61
		 * @filter `gravityview_pagination_output` Modify the pagination widget output
62
		 * @param string $output HTML output
63
		 * @param int $first First entry #
64
		 * @param int $last Last entry #
65
		 * @param int $total Total entries #
66
		 */
67 1
		echo apply_filters( 'gravityview_pagination_output', $output, $first, $last, $total );
0 ignored issues
show
introduced by
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'apply_filters'
Loading history...
68
69 1
	}
70
71
}
72
73
new GravityView_Widget_Pagination_Info;