| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | * @brief importExport, a plugin for Dotclear 2 |
|---|
| 4 | * |
|---|
| 5 | * @package Dotclear |
|---|
| 6 | * @subpackage Plugins |
|---|
| 7 | * |
|---|
| 8 | * @copyright Olivier Meunier & Association Dotclear |
|---|
| 9 | * @copyright GPL-2.0-only |
|---|
| 10 | */ |
|---|
| 11 | |
|---|
| 12 | if (!defined('DC_RC_PATH')) { |
|---|
| 13 | return; |
|---|
| 14 | } |
|---|
| 15 | |
|---|
| 16 | abstract class dcIeModule |
|---|
| 17 | { |
|---|
| 18 | public $type; |
|---|
| 19 | public $id; |
|---|
| 20 | public $name; |
|---|
| 21 | public $description; |
|---|
| 22 | |
|---|
| 23 | protected $import_url; |
|---|
| 24 | protected $export_url; |
|---|
| 25 | protected $core; |
|---|
| 26 | |
|---|
| 27 | public function __construct($core) |
|---|
| 28 | { |
|---|
| 29 | $this->core = &$core; |
|---|
| 30 | $this->setInfo(); |
|---|
| 31 | |
|---|
| 32 | if (!in_array($this->type, ['import', 'export'])) { |
|---|
| 33 | throw new Exception(sprintf('Unknow type for module %s', get_class($this))); |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | if (!$this->name) { |
|---|
| 37 | $this->name = get_class($this); |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | $this->id = get_class($this); |
|---|
| 41 | $this->url = sprintf('plugin.php?p=importExport&type=%s&module=%s', $this->type, $this->id); |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | public function init() |
|---|
| 45 | { |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | abstract protected function setInfo(); |
|---|
| 49 | |
|---|
| 50 | final public function getURL($escape = false) |
|---|
| 51 | { |
|---|
| 52 | return $escape ? html::escapeHTML($this->url) : $this->url; |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | abstract public function process($do); |
|---|
| 56 | |
|---|
| 57 | abstract public function gui(); |
|---|
| 58 | |
|---|
| 59 | protected function progressBar($percent) |
|---|
| 60 | { |
|---|
| 61 | $percent = ceil($percent); |
|---|
| 62 | if ($percent > 100) { |
|---|
| 63 | $percent = 100; |
|---|
| 64 | } |
|---|
| 65 | return '<div class="ie-progress"><div style="width:' . $percent . '%">' . $percent . ' %</div></div>'; |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | protected function autoSubmit() |
|---|
| 69 | { |
|---|
| 70 | return form::hidden(['autosubmit'], 1); |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | protected function congratMessage() |
|---|
| 74 | { |
|---|
| 75 | return |
|---|
| 76 | '<h3>' . __('Congratulation!') . '</h3>' . |
|---|
| 77 | '<p class="success">' . __('Your blog has been successfully imported. Welcome on Dotclear 2!') . '</p>' . |
|---|
| 78 | '<ul><li><strong><a href="' . $this->core->adminurl->decode('admin.post') . '">' . __('Why don\'t you blog this now?') . '</a></strong></li>' . |
|---|
| 79 | '<li>' . __('or') . ' <a href="' . $this->core->adminurl->decode('admin.home') . '">' . __('visit your dashboard') . '</a></li></ul>'; |
|---|
| 80 | } |
|---|
| 81 | } |
|---|