[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
| 6 | # Copyright (c) 2003-2010 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 | |
---|
[328] | 17 | $href = !empty($_GET['href']) ? $_GET['href'] : ''; |
---|
| 18 | $hreflang = !empty($_GET['hreflang']) ? $_GET['hreflang'] : ''; |
---|
| 19 | $title = !empty($_GET['title']) ? $_GET['title'] : ''; |
---|
| 20 | $q = !empty($_GET['q']) ? $_GET['q'] : null; |
---|
| 21 | $page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1; |
---|
| 22 | $nb_per_page = 10; |
---|
[0] | 23 | |
---|
[328] | 24 | $params = array(); |
---|
| 25 | $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); |
---|
| 26 | $params['no_content'] = true; |
---|
| 27 | $params['order'] = 'post_dt DESC'; |
---|
| 28 | |
---|
| 29 | if ($q) { |
---|
| 30 | $params['search'] = $q; |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | dcPage::openPopup(__('Add a link'), |
---|
| 34 | dcPage::jsLoad('js/_posts_list.js'). |
---|
| 35 | dcPage::jsLoad('js/tiny_mce/tiny_mce_popup.js'). |
---|
| 36 | dcPage::jsLoad('js/tiny_mce/plugins/dcControls/js/popup_link.js') |
---|
| 37 | ); |
---|
[0] | 38 | |
---|
| 39 | echo '<h2>'.__('Add a link').'</h2>'; |
---|
| 40 | |
---|
| 41 | # Languages combo |
---|
| 42 | $rs = $core->blog->getLangs(array('order'=>'asc')); |
---|
| 43 | $all_langs = l10n::getISOcodes(0,1); |
---|
| 44 | $lang_combo = array('' => '', __('Most used') => array(), __('Available') => l10n::getISOcodes(1,1)); |
---|
| 45 | while ($rs->fetch()) { |
---|
| 46 | if (isset($all_langs[$rs->post_lang])) { |
---|
| 47 | $lang_combo[__('Most used')][$all_langs[$rs->post_lang]] = $rs->post_lang; |
---|
| 48 | unset($lang_combo[__('Available')][$all_langs[$rs->post_lang]]); |
---|
| 49 | } else { |
---|
| 50 | $lang_combo[__('Most used')][$rs->post_lang] = $rs->post_lang; |
---|
| 51 | } |
---|
| 52 | } |
---|
| 53 | unset($all_langs); |
---|
| 54 | unset($rs); |
---|
| 55 | |
---|
| 56 | echo |
---|
| 57 | '<form id="link-insert-form" action="#" method="get">'. |
---|
[328] | 58 | '<h4>'.__('Enter a destination URL').'</h4>'. |
---|
[68] | 59 | '<p><label class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Link URL:').' '. |
---|
[0] | 60 | form::field('href',35,512,html::escapeHTML($href)).'</label></p>'. |
---|
| 61 | '<p><label>'.__('Link title:').' '. |
---|
| 62 | form::field('title',35,512,html::escapeHTML($title)).'</label></p>'. |
---|
| 63 | '<p><label>'.__('Link language:').' '. |
---|
| 64 | form::combo('hreflang',$lang_combo,$hreflang). |
---|
| 65 | '</label></p>'. |
---|
[411] | 66 | '<p><a class="button cancel" href="#" id="link-insert-cancel">'.__('cancel').'</a>'. |
---|
| 67 | '<a class="button insert" href="#" id="link-insert-ok">'.__('insert').'</a></p>'."\n". |
---|
[0] | 68 | |
---|
[328] | 69 | '<div id="div-entries">'. |
---|
| 70 | '<h4>'.__('Or link to existing content').'</h4>'. |
---|
| 71 | '<p class="form-note">'.__('Click on a title to select the link').'</p>'. |
---|
| 72 | '<p><label for="q" class="classic">'.__('Search entry:').' '.form::field('q',30,255,html::escapeHTML($q)).'</label> '. |
---|
| 73 | ' <input type="submit" value="'.__('ok').'" /></p>'; |
---|
| 74 | |
---|
| 75 | try { |
---|
| 76 | $posts = $core->blog->getPosts($params); |
---|
| 77 | $counter = $core->blog->getPosts($params,true); |
---|
| 78 | $post_list = new adminPostMiniList($core,$posts,$counter->f(0)); |
---|
| 79 | } catch (Exception $e) { |
---|
| 80 | $core->error->add($e->getMessage()); |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | echo '<div id="form-entries">'; # I know it's not a form but we just need the ID |
---|
| 84 | $post_list->display($page,$nb_per_page); |
---|
| 85 | echo |
---|
| 86 | '</div>'. |
---|
| 87 | '</div>'. |
---|
| 88 | '</form>'. |
---|
| 89 | |
---|
[0] | 90 | '<script type="text/javascript">'."\n". |
---|
| 91 | '//<![CDATA['."\n". |
---|
| 92 | '$(\'input[name="href"]\').get(0).focus();'."\n". |
---|
| 93 | '//]]>'."\n". |
---|
| 94 | '</script>'."\n"; |
---|
| 95 | |
---|
| 96 | dcPage::closePopup(); |
---|
[328] | 97 | |
---|
[0] | 98 | ?> |
---|