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