| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | * @brief pages, 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_CONTEXT_ADMIN')) {return;} |
|---|
| 13 | |
|---|
| 14 | $version = $core->plugins->moduleInfo('pages', 'version'); |
|---|
| 15 | if (version_compare($core->getVersion('pages'), $version, '>=')) { |
|---|
| 16 | return; |
|---|
| 17 | } |
|---|
| 18 | |
|---|
| 19 | $core->blog->settings->addNamespace('pages'); |
|---|
| 20 | |
|---|
| 21 | if ($core->getVersion('pages') == null) { |
|---|
| 22 | |
|---|
| 23 | // Create a first pending page, only on a new installation of this plugin |
|---|
| 24 | $params = [ |
|---|
| 25 | 'post_type' => 'page', |
|---|
| 26 | 'no_content' => true |
|---|
| 27 | ]; |
|---|
| 28 | $counter = $core->blog->getPosts($params, true); |
|---|
| 29 | |
|---|
| 30 | if ($counter->f(0) == 0 && $core->blog->settings->pages->firstpage == null) { |
|---|
| 31 | |
|---|
| 32 | $core->blog->settings->pages->put('firstpage', true, 'boolean'); |
|---|
| 33 | |
|---|
| 34 | $cur = $core->con->openCursor($core->prefix . 'post'); |
|---|
| 35 | $cur->user_id = $core->auth->userID(); |
|---|
| 36 | $cur->post_type = 'page'; |
|---|
| 37 | $cur->post_format = 'xhtml'; |
|---|
| 38 | $cur->post_lang = $core->blog->settings->system->lang; |
|---|
| 39 | $cur->post_title = __('My first page'); |
|---|
| 40 | $cur->post_content = '<p>' . __('This is your first page. When you\'re ready to blog, log in to edit or delete it.') . '</p>'; |
|---|
| 41 | $cur->post_content_xhtml = $cur->post_content; |
|---|
| 42 | $cur->post_excerpt = ''; |
|---|
| 43 | $cur->post_excerpt_xhtml = $cur->post_excerpt; |
|---|
| 44 | $cur->post_status = -2; // Pending status |
|---|
| 45 | $cur->post_open_comment = 0; |
|---|
| 46 | $cur->post_open_tb = 0; |
|---|
| 47 | $post_id = $core->blog->addPost($cur); |
|---|
| 48 | } |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | $core->setVersion('pages', $version); |
|---|
| 52 | return true; |
|---|