.htaccess
1 year ago
Abilities.php
1 day ago
Blog.php
1 year ago
Helper.php
5 months ago
Init.php
5 months ago
Installer.php
7 months ago
MySQL.php
1 year ago
UI.php
4 months ago
Update.php
1 year ago
Wordpress.php
1 day ago
index.html
1 year ago
web.config
1 year ago
Blog.php
47 lines
| 1 | <?php |
| 2 | |
| 3 | namespace JetBackup\Wordpress; |
| 4 | |
| 5 | use JetBackup\Data\ArrayData; |
| 6 | |
| 7 | if (!defined( '__JETBACKUP__')) die('Direct access is not allowed'); |
| 8 | |
| 9 | class Blog extends ArrayData { |
| 10 | |
| 11 | const ID = 'id'; |
| 12 | const DOMAIN = 'domain'; |
| 13 | const DATABASE_TABLES = 'database_tables'; |
| 14 | |
| 15 | const MAIN_BLOG_ID = 1; |
| 16 | |
| 17 | public function __construct($data=[]) { |
| 18 | $this->setData($data); |
| 19 | } |
| 20 | |
| 21 | public function setId(int $id):void { $this->set(self::ID, $id); } |
| 22 | public function getId():int { return $this->get(self::ID, 0); } |
| 23 | |
| 24 | public function setDomain(string $domain):void { $this->set(self::DOMAIN, $domain); } |
| 25 | public function getDomain():string { return $this->get(self::DOMAIN); } |
| 26 | |
| 27 | public function setDatabaseTables(array $tables):void { $this->set(self::DATABASE_TABLES, $tables); } |
| 28 | public function getDatabaseTables():array { return $this->get(self::DATABASE_TABLES, []); } |
| 29 | public function addDatabaseTable(string $table):void { |
| 30 | $tables = $this->getDatabaseTables(); |
| 31 | $tables[] = $table; |
| 32 | $this->setDatabaseTables($tables); |
| 33 | } |
| 34 | |
| 35 | public function getPaths():array { |
| 36 | if(!$this->isMain()) return []; |
| 37 | return [ |
| 38 | "wp-content/blogs.dir/{$this->getId()}/files", // Legacy |
| 39 | "wp-content/uploads/sites/{$this->getId()}", |
| 40 | "wp-content/uploads/{$this->getId()}", |
| 41 | "wp-content/{$this->getId()}", |
| 42 | ]; |
| 43 | } |
| 44 | |
| 45 | public function isMain():bool { return $this->getId() == self::MAIN_BLOG_ID; } |
| 46 | } |
| 47 |