| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package VikBooking |
| 4 |
* @subpackage core |
| 5 |
* @author Alessio Gaggii - E4J s.r.l. |
| 6 |
* @copyright Copyright (C) 2022 E4J s.r.l. All Rights Reserved. |
| 7 |
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 |
* @link https://vikwp.com |
| 9 |
*/ |
| 10 |
|
| 11 |
// No direct access |
| 12 |
defined('ABSPATH') or die('No script kiddies please!'); |
| 13 |
|
| 14 |
/** |
| 15 |
* Defines a data registry container for the admin widgets |
| 16 |
* being rendered in the multitask panel for encapsulation. |
| 17 |
* |
| 18 |
* @since 1.15.0 (J) - 1.5.0 (WP) |
| 19 |
*/ |
| 20 |
final class VBOMultitaskData extends JObject |
| 21 |
{ |
| 22 |
/** |
| 23 |
* @var array multitask data options list. |
| 24 |
* |
| 25 |
* @since 1.16.5 (J) - 1.6.5 (WP) |
| 26 |
*/ |
| 27 |
protected $data_options = []; |
| 28 |
|
| 29 |
/** |
| 30 |
* Gets the current name of the view/task. |
| 31 |
* |
| 32 |
* @return string |
| 33 |
*/ |
| 34 |
public function getPage() |
| 35 |
{ |
| 36 |
return $this->get('page_name', null); |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Sets the current name of the view/task. |
| 41 |
* |
| 42 |
* @param string $page the name of the view/task. |
| 43 |
* |
| 44 |
* @return self |
| 45 |
*/ |
| 46 |
public function setPage($page = '') |
| 47 |
{ |
| 48 |
$this->set('page_name', (string)$page); |
| 49 |
|
| 50 |
return $this; |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Gets the current page URI. |
| 55 |
* |
| 56 |
* @return string |
| 57 |
*/ |
| 58 |
public function getURI() |
| 59 |
{ |
| 60 |
return $this->get('page_uri', null); |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* Sets the current page URI. |
| 65 |
* |
| 66 |
* @param string $uri the current page URI. |
| 67 |
* |
| 68 |
* @return self |
| 69 |
*/ |
| 70 |
public function setURI($uri = '') |
| 71 |
{ |
| 72 |
$this->set('page_uri', (string)$uri); |
| 73 |
|
| 74 |
return $this; |
| 75 |
} |
| 76 |
|
| 77 |
/** |
| 78 |
* Gets the current page query. |
| 79 |
* |
| 80 |
* @return array |
| 81 |
*/ |
| 82 |
public function getQuery() |
| 83 |
{ |
| 84 |
return $this->get('page_query', []); |
| 85 |
} |
| 86 |
|
| 87 |
/** |
| 88 |
* Sets the current page query. |
| 89 |
* |
| 90 |
* @param array $query the current page query. |
| 91 |
* |
| 92 |
* @return self |
| 93 |
*/ |
| 94 |
public function setQuery($query = array()) |
| 95 |
{ |
| 96 |
$this->set('page_query', (array)$query); |
| 97 |
|
| 98 |
return $this; |
| 99 |
} |
| 100 |
|
| 101 |
/** |
| 102 |
* Gets the current booking id. |
| 103 |
* |
| 104 |
* @return int the booking id. |
| 105 |
*/ |
| 106 |
public function getBookingId() |
| 107 |
{ |
| 108 |
$bid = $this->get('booking_id', 0); |
| 109 |
|
| 110 |
if ($bid) { |
| 111 |
return $bid; |
| 112 |
} |
| 113 |
|
| 114 |
return $this->get('id_order', 0); |
| 115 |
} |
| 116 |
|
| 117 |
/** |
| 118 |
* Sets the current booking id. |
| 119 |
* |
| 120 |
* @param int $bid the reservation id. |
| 121 |
* |
| 122 |
* @return self |
| 123 |
*/ |
| 124 |
public function setBookingId($bid = 0) |
| 125 |
{ |
| 126 |
$this->set('booking_id', (int)$bid); |
| 127 |
|
| 128 |
return $this; |
| 129 |
} |
| 130 |
|
| 131 |
/** |
| 132 |
* Tells whether the admin widget is being rendered within a modal. |
| 133 |
* |
| 134 |
* @return bool |
| 135 |
* |
| 136 |
* @since 1.16.0 (J) - 1.6.0 (WP) |
| 137 |
*/ |
| 138 |
public function isModalRendering() |
| 139 |
{ |
| 140 |
return (bool)$this->get('_modalRendering', false); |
| 141 |
} |
| 142 |
|
| 143 |
/** |
| 144 |
* If the admin widget is being rendered within a modal, some |
| 145 |
* additional data for the JS events may be attached to an ID. |
| 146 |
* Useful for the admin widget to clear intervals through JS. |
| 147 |
* |
| 148 |
* @return string |
| 149 |
* |
| 150 |
* @since 1.16.0 (J) - 1.6.0 (WP) |
| 151 |
*/ |
| 152 |
public function getModalJsIdentifier() |
| 153 |
{ |
| 154 |
return $this->get('_modalJsId', ''); |
| 155 |
} |
| 156 |
|
| 157 |
/** |
| 158 |
* Registers custom multitask options for rendering an admin widget. |
| 159 |
* Options are usually set when rendering a widget within a modal. |
| 160 |
* |
| 161 |
* @param array $options associative list of options. |
| 162 |
* |
| 163 |
* @return self |
| 164 |
* |
| 165 |
* @since 1.16.5 (J) - 1.6.5 (WP) |
| 166 |
*/ |
| 167 |
public function registerDataOptions(array $options = []) |
| 168 |
{ |
| 169 |
$this->data_options = $options; |
| 170 |
|
| 171 |
return $this; |
| 172 |
} |
| 173 |
|
| 174 |
/** |
| 175 |
* Returns the available custom options for rendering an admin widget. |
| 176 |
* Useful to have a top-layer set of options that differs from regular data. |
| 177 |
* |
| 178 |
* @return array |
| 179 |
* |
| 180 |
* @since 1.16.5 (J) - 1.6.5 (WP) |
| 181 |
*/ |
| 182 |
public function getDataOptions() |
| 183 |
{ |
| 184 |
return $this->data_options; |
| 185 |
} |
| 186 |
} |
| 187 |
|