[1802] | 1 | <?php |
---|
[3731] | 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 | */ |
---|
[1802] | 11 | |
---|
[3730] | 12 | if (!defined('DC_CONTEXT_ADMIN')) {return;} |
---|
[1802] | 13 | |
---|
[3730] | 14 | $version = $core->plugins->moduleInfo('pages', 'version'); |
---|
| 15 | if (version_compare($core->getVersion('pages'), $version, '>=')) { |
---|
| 16 | return; |
---|
[1802] | 17 | } |
---|
| 18 | |
---|
| 19 | $core->blog->settings->addNamespace('pages'); |
---|
| 20 | |
---|
[1939] | 21 | if ($core->getVersion('pages') == null) { |
---|
[1802] | 22 | |
---|
[3730] | 23 | // Create a first pending page, only on a new installation of this plugin |
---|
[3874] | 24 | $params = [ |
---|
[3730] | 25 | 'post_type' => 'page', |
---|
| 26 | 'no_content' => true |
---|
[3874] | 27 | ]; |
---|
[3730] | 28 | $counter = $core->blog->getPosts($params, true); |
---|
[1802] | 29 | |
---|
[3730] | 30 | if ($counter->f(0) == 0 && $core->blog->settings->pages->firstpage == null) { |
---|
[1939] | 31 | |
---|
[3730] | 32 | $core->blog->settings->pages->put('firstpage', true, 'boolean'); |
---|
[1939] | 33 | |
---|
[3730] | 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 | } |
---|
[1802] | 49 | } |
---|
| 50 | |
---|
[3730] | 51 | $core->setVersion('pages', $version); |
---|
[1802] | 52 | return true; |
---|