Dotclear

source: admin/popup_posts.php @ 3874:ab8368569446

Revision 3874:ab8368569446, 2.4 KB checked in by franck <carnet.franck.paul@…>, 6 years ago (diff)

short notation for array (array() → [])

Line 
1<?php
2/**
3 * @package Dotclear
4 * @subpackage Backend
5 *
6 * @copyright Olivier Meunier & Association Dotclear
7 * @copyright GPL-2.0-only
8 */
9
10require dirname(__FILE__) . '/../inc/admin/prepend.php';
11
12dcPage::check('usage,contentadmin');
13
14$q         = !empty($_GET['q']) ? $_GET['q'] : null;
15$plugin_id = !empty($_GET['plugin_id']) ? html::sanitizeURL($_GET['plugin_id']) : '';
16
17$page        = !empty($_GET['page']) ? max(1, (integer) $_GET['page']) : 1;
18$nb_per_page = 10;
19
20$type = !empty($_GET['type']) ? $_GET['type'] : null;
21
22$post_types = $core->getPostTypes();
23foreach ($post_types as $k => $v) {
24    $type_combo[__($k)] = (string) $k;
25}
26if (!in_array($type, $type_combo)) {
27    $type = null;
28}
29
30$params               = [];
31$params['limit']      = [(($page - 1) * $nb_per_page), $nb_per_page];
32$params['no_content'] = true;
33$params['order']      = 'post_dt DESC';
34
35if ($q) {
36    $params['search'] = $q;
37}
38
39if ($type) {
40    $params['post_type'] = $type;
41}
42
43dcPage::openPopup(__('Add a link to an entry'),
44    dcPage::jsLoad('js/_posts_list.js') .
45    dcPage::jsLoad('js/_popup_posts.js') .
46    $core->callBehavior('adminPopupPosts', $plugin_id));
47
48echo '<h2 class="page-title">' . __('Add a link to an entry') . '</h2>';
49
50echo '<form action="' . $core->adminurl->get('admin.popup_posts') . '" method="get">' .
51'<p><label for="type" class="classic">' . __('Entry type:') . '</label> ' . form::combo('type', $type_combo, $type) . '' .
52'<noscript><div><input type="submit" value="' . __('Ok') . '" /></div></noscript>' .
53form::hidden('plugin_id', html::escapeHTML($plugin_id)) . '</p>' .
54    '</form>';
55
56echo '<form action="' . $core->adminurl->get('admin.popup_posts') . '" method="get">' .
57'<p><label for="q" class="classic">' . __('Search entry:') . '</label> ' . form::field('q', 30, 255, html::escapeHTML($q)) .
58' <input type="submit" value="' . __('Search') . '" />' .
59form::hidden('plugin_id', html::escapeHTML($plugin_id)) .
60form::hidden('type', html::escapeHTML($type)) .
61    '</p></form>';
62
63try {
64    $posts     = $core->blog->getPosts($params);
65    $counter   = $core->blog->getPosts($params, true);
66    $post_list = new adminPostMiniList($core, $posts, $counter->f(0));
67} catch (Exception $e) {
68    $core->error->add($e->getMessage());
69}
70
71echo '<div id="form-entries">'; # I know it's not a form but we just need the ID
72$post_list->display($page, $nb_per_page);
73echo '</div>';
74
75echo '<p><button type="button" id="link-insert-cancel">' . __('cancel') . '</button></p>';
76
77dcPage::closePopup();
Note: See TracBrowser for help on using the repository browser.

Sites map