| 1 |
<?php |
| 2 |
/** |
| 3 |
* Handle form template view skin. |
| 4 |
* |
| 5 |
* @package Give |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace Give\Views; |
| 9 |
|
| 10 |
/** |
| 11 |
* Class IframeView |
| 12 |
* |
| 13 |
* @since 2.7.0 |
| 14 |
* @package Give |
| 15 |
*/ |
| 16 |
class IframeContentView { |
| 17 |
/** |
| 18 |
* Document page title. |
| 19 |
* |
| 20 |
* This will be use to setup title tag. |
| 21 |
* |
| 22 |
* @since 2.7.0 |
| 23 |
* @var string |
| 24 |
*/ |
| 25 |
protected $title; |
| 26 |
|
| 27 |
/** |
| 28 |
* Document page body. |
| 29 |
* |
| 30 |
* This will be use to setup content of body tag. |
| 31 |
* |
| 32 |
* @since 2.7.0 |
| 33 |
* @var string |
| 34 |
*/ |
| 35 |
protected $body; |
| 36 |
|
| 37 |
/** |
| 38 |
* Body classes. |
| 39 |
* |
| 40 |
* This will be use to setup body tag classes. |
| 41 |
* |
| 42 |
* @since 2.7.0 |
| 43 |
* @var array |
| 44 |
*/ |
| 45 |
protected $bodyClasses = [ 'give-form-templates' ]; |
| 46 |
|
| 47 |
/** |
| 48 |
* Set document page title. |
| 49 |
* |
| 50 |
* @param string $title |
| 51 |
* |
| 52 |
* @return IframeContentView $this |
| 53 |
*/ |
| 54 |
public function setTitle( $title ) { |
| 55 |
$this->title = $title; |
| 56 |
|
| 57 |
return $this; |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Set document page title. |
| 62 |
* |
| 63 |
* @param string $body |
| 64 |
* |
| 65 |
* @return IframeContentView $this |
| 66 |
*/ |
| 67 |
public function setBody( $body ) { |
| 68 |
$this->body = $body; |
| 69 |
|
| 70 |
return $this; |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Set document page title. |
| 75 |
* |
| 76 |
* @param array $classes |
| 77 |
* |
| 78 |
* @return IframeContentView $this |
| 79 |
*/ |
| 80 |
public function setBodyClasses( $classes ) { |
| 81 |
$this->bodyClasses = array_merge( $this->bodyClasses, (array) $classes ); |
| 82 |
|
| 83 |
return $this; |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
* Render view. |
| 88 |
* |
| 89 |
* Note: if you want to overwrite this function then do not forget to add action hook in footer and header. |
| 90 |
* We use these hooks to manipulated donation form related actions. |
| 91 |
* |
| 92 |
* @since 2.7.0 |
| 93 |
*/ |
| 94 |
public function render() { |
| 95 |
ob_start(); |
| 96 |
?> |
| 97 |
<!DOCTYPE html> |
| 98 |
<html <?php language_attributes(); ?>> |
| 99 |
<head> |
| 100 |
<meta charset="utf-8"> |
| 101 |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 102 |
<title><?php echo apply_filters( 'the_title', $this->title ); ?></title> |
| 103 |
<?php |
| 104 |
/** |
| 105 |
* Fire the action hook in header |
| 106 |
*/ |
| 107 |
do_action( 'give_embed_head' ); |
| 108 |
?> |
| 109 |
</head> |
| 110 |
<body class="<?php echo implode( ' ', $this->bodyClasses ); ?>"> |
| 111 |
<?php |
| 112 |
echo $this->body; |
| 113 |
|
| 114 |
/** |
| 115 |
* Fire the action hook in footer |
| 116 |
*/ |
| 117 |
do_action( 'give_embed_footer' ); |
| 118 |
?> |
| 119 |
</body> |
| 120 |
</html> |
| 121 |
<?php |
| 122 |
return ob_get_clean(); |
| 123 |
} |
| 124 |
|
| 125 |
/** |
| 126 |
* Render only body html tag children of view. |
| 127 |
* |
| 128 |
* @since 2.7.0 |
| 129 |
*/ |
| 130 |
public function renderBody() { |
| 131 |
return $this->body; |
| 132 |
} |
| 133 |
} |
| 134 |
|