.htaccess
1 year ago
Progress.php
1 year ago
Queue.php
5 months ago
QueueItem.php
2 days ago
QueueItemBackup.php
5 months ago
QueueItemDownload.php
1 year ago
QueueItemExport.php
1 year ago
QueueItemExtract.php
1 year ago
QueueItemReindex.php
1 year ago
QueueItemRestore.php
1 year ago
QueueItemRetentionCleanup.php
1 year ago
QueueItemSystem.php
1 year ago
aQueueItem.php
1 year ago
index.html
1 year ago
web.config
1 year ago
Progress.php
67 lines
| 1 | <?php |
| 2 | |
| 3 | namespace JetBackup\Queue; |
| 4 | |
| 5 | use JetBackup\Data\ArrayData; |
| 6 | |
| 7 | if (!defined( '__JETBACKUP__')) die('Direct access is not allowed'); |
| 8 | |
| 9 | class Progress extends ArrayData { |
| 10 | |
| 11 | const MESSAGE = 'message'; |
| 12 | const TOTAL_ITEMS = 'total_items'; |
| 13 | const CURRENT_ITEM = 'current_item'; |
| 14 | const SUB_MESSAGE = 'sub_message'; |
| 15 | const TOTAL_SUB_ITEMS = 'total_sub_items'; |
| 16 | const CURRENT_SUB_ITEM = 'current_sub_item'; |
| 17 | const PERCENTAGE = 'percentage'; |
| 18 | const SUB_PERCENTAGE = 'sub_percentage'; |
| 19 | |
| 20 | public function __construct(array $data=[]) { |
| 21 | $this->setData($data); |
| 22 | } |
| 23 | |
| 24 | public function setMessage(string $message):void { $this->set(self::MESSAGE, $message); } |
| 25 | public function getMessage():string { return $this->get(self::MESSAGE); } |
| 26 | |
| 27 | public function setTotalItems(int $items):void { $this->set(self::TOTAL_ITEMS, $items); } |
| 28 | public function getTotalItems():int { return $this->get(self::TOTAL_ITEMS, 1); } |
| 29 | |
| 30 | public function setCurrentItem(int $current):void { $this->set(self::CURRENT_ITEM, $current); } |
| 31 | public function getCurrentItem():int { return $this->get(self::CURRENT_ITEM, 0); } |
| 32 | |
| 33 | public function setSubMessage(string $message):void { $this->set(self::SUB_MESSAGE, $message); } |
| 34 | public function getSubMessage():string { return $this->get(self::SUB_MESSAGE); } |
| 35 | |
| 36 | public function setTotalSubItems(int $items):void { $this->set(self::TOTAL_SUB_ITEMS, $items); } |
| 37 | public function getTotalSubItems():int { return $this->get(self::TOTAL_SUB_ITEMS, 0); } |
| 38 | |
| 39 | public function setCurrentSubItem(int $current):void { $this->set(self::CURRENT_SUB_ITEM, $current); } |
| 40 | public function getCurrentSubItem():int { return $this->get(self::CURRENT_SUB_ITEM, 0); } |
| 41 | |
| 42 | public function increaseCurrentItem():void { $this->setCurrentItem($this->getCurrentItem() + 1); } |
| 43 | public function increaseCurrentSubItem():void { $this->setCurrentSubItem($this->getCurrentSubItem() + 1); } |
| 44 | |
| 45 | public function getPercentage():int { return $this->getTotalItems() > 0 ? min(100, floor(($this->getCurrentItem() / $this->getTotalItems()) * 100)) : 0; } |
| 46 | public function getSubPercentage():int { return $this->getTotalSubItems() > 0 ? min(100, floor(($this->getCurrentSubItem() / $this->getTotalSubItems()) * 100)) : 0; } |
| 47 | |
| 48 | public function resetSub() { |
| 49 | $this->setSubMessage(''); |
| 50 | $this->setTotalSubItems(0); |
| 51 | $this->setCurrentSubItem(0); |
| 52 | } |
| 53 | |
| 54 | public function getDisplay() { |
| 55 | return [ |
| 56 | self::MESSAGE => $this->getMessage(), |
| 57 | self::TOTAL_ITEMS => $this->getTotalItems(), |
| 58 | self::CURRENT_ITEM => $this->getCurrentItem(), |
| 59 | self::PERCENTAGE => $this->getPercentage(), |
| 60 | self::SUB_MESSAGE => $this->getSubMessage(), |
| 61 | self::TOTAL_SUB_ITEMS => $this->getTotalSubItems(), |
| 62 | self::CURRENT_SUB_ITEM => $this->getCurrentSubItem(), |
| 63 | self::SUB_PERCENTAGE => $this->getSubPercentage(), |
| 64 | ]; |
| 65 | } |
| 66 | } |
| 67 |