[0] | 1 | <?php |
---|
[3731] | 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 | |
---|
[3944] | 12 | if (!defined('DC_RC_PATH')) { |
---|
| 13 | return; |
---|
| 14 | } |
---|
[0] | 15 | |
---|
[840] | 16 | abstract class dcIeModule |
---|
[0] | 17 | { |
---|
[3730] | 18 | public $type; |
---|
| 19 | public $id; |
---|
| 20 | public $name; |
---|
| 21 | public $description; |
---|
[2566] | 22 | |
---|
[3730] | 23 | protected $import_url; |
---|
| 24 | protected $export_url; |
---|
| 25 | protected $core; |
---|
[2566] | 26 | |
---|
[3730] | 27 | public function __construct($core) |
---|
| 28 | { |
---|
| 29 | $this->core = &$core; |
---|
| 30 | $this->setInfo(); |
---|
[2566] | 31 | |
---|
[3874] | 32 | if (!in_array($this->type, ['import', 'export'])) { |
---|
[3730] | 33 | throw new Exception(sprintf('Unknow type for module %s', get_class($this))); |
---|
| 34 | } |
---|
[2566] | 35 | |
---|
[3730] | 36 | if (!$this->name) { |
---|
| 37 | $this->name = get_class($this); |
---|
| 38 | } |
---|
[2566] | 39 | |
---|
[3730] | 40 | $this->id = get_class($this); |
---|
| 41 | $this->url = sprintf('plugin.php?p=importExport&type=%s&module=%s', $this->type, $this->id); |
---|
| 42 | } |
---|
[2566] | 43 | |
---|
[3730] | 44 | public function init() |
---|
| 45 | { |
---|
| 46 | } |
---|
[2566] | 47 | |
---|
[3730] | 48 | abstract protected function setInfo(); |
---|
[2566] | 49 | |
---|
[3730] | 50 | final public function getURL($escape = false) |
---|
| 51 | { |
---|
| 52 | return $escape ? html::escapeHTML($this->url) : $this->url; |
---|
| 53 | } |
---|
[2566] | 54 | |
---|
[3730] | 55 | abstract public function process($do); |
---|
[2566] | 56 | |
---|
[3730] | 57 | abstract public function gui(); |
---|
[2566] | 58 | |
---|
[3730] | 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 | } |
---|
[2566] | 67 | |
---|
[3730] | 68 | protected function autoSubmit() |
---|
| 69 | { |
---|
[3874] | 70 | return form::hidden(['autosubmit'], 1); |
---|
[3730] | 71 | } |
---|
[2566] | 72 | |
---|
[3730] | 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>' . |
---|
[3944] | 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>'; |
---|
[3730] | 80 | } |
---|
[0] | 81 | } |
---|