Dotclear

source: admin/popup_link.php @ 328:134b65a90d17

Revision 328:134b65a90d17, 3.2 KB checked in by Tomtom33 <tbouron@…>, 14 years ago (diff)

Merge popup_link.php and popup_posts.php for TinyMCE popup

Line 
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
13require dirname(__FILE__).'/../inc/admin/prepend.php';
14
15dcPage::check('usage,contentadmin');
16
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;
23
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
29if ($q) {
30     $params['search'] = $q;
31}
32
33dcPage::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);
38
39echo '<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));
45while ($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}
53unset($all_langs);
54unset($rs);
55
56echo
57'<form id="link-insert-form" action="#" method="get">'.
58'<h4>'.__('Enter a destination URL').'</h4>'.
59'<p><label class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Link URL:').' '.
60form::field('href',35,512,html::escapeHTML($href)).'</label></p>'.
61'<p><label>'.__('Link title:').' '. 
62form::field('title',35,512,html::escapeHTML($title)).'</label></p>'. 
63'<p><label>'.__('Link language:').' '.
64form::combo('hreflang',$lang_combo,$hreflang).
65'</label></p>'.
66'<p><a class="button reset" href="#" id="link-insert-cancel">'.__('cancel').'</a> - '.
67'<strong><a class="button" href="#" id="link-insert-ok">'.__('insert').'</a></strong></p>'."\n".
68
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
75try {
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
83echo '<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);
85echo
86'</div>'.
87'</div>'.
88'</form>'.
89
90'<script type="text/javascript">'."\n".
91'//<![CDATA['."\n".
92'$(\'input[name="href"]\').get(0).focus();'."\n".
93'//]]>'."\n".
94'</script>'."\n";
95
96dcPage::closePopup();
97
98?>
Note: See TracBrowser for help on using the repository browser.

Sites map