1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK ---------------------------------- |
---|
3 | # This file is part of dcWikipedia, a plugin for Dotclear. |
---|
4 | # |
---|
5 | # Copyright (c) 2009 Tomtom |
---|
6 | # http://blog.zenstyle.fr/ |
---|
7 | # |
---|
8 | # Licensed under the GPL version 2.0 license. |
---|
9 | # A copy of this license is available in LICENSE file or at |
---|
10 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
11 | # -- END LICENSE BLOCK ------------------------------------ |
---|
12 | |
---|
13 | $value = isset($_GET['value']) ? rawurldecode($_GET['value']) : ''; |
---|
14 | $lang = isset($_GET['lang']) ? rawurldecode($_GET['lang']) : ''; |
---|
15 | |
---|
16 | $parser = dcWikipediaReader::quickParse('http://'.$lang.'.wikipedia.org/w/api.php?action=opensearch&format=xml&search='.rawurlencode($value),DC_TPL_CACHE); |
---|
17 | |
---|
18 | ?> |
---|
19 | |
---|
20 | <html> |
---|
21 | <head> |
---|
22 | <title><?php echo __('dcWikipedia'); ?></title> |
---|
23 | <?php echo dcPage::jsLoad(DC_ADMIN_URL.'?pf=dcWikipedia/js/popup.min.js'); ?> |
---|
24 | <style type="text/css">@import '<?php echo DC_ADMIN_URL; ?>?pf=dcWikipedia/style.min.css';</style> |
---|
25 | </head> |
---|
26 | |
---|
27 | <body> |
---|
28 | <h2><?php echo __('Add a Wikipedia link'); ?></h2> |
---|
29 | |
---|
30 | <?php |
---|
31 | |
---|
32 | $rs = $core->blog->getLangs(array('order'=>'asc')); |
---|
33 | $all_langs = l10n::getISOcodes(0,1); |
---|
34 | $lang_combo = array('' => '', __('Most used') => array(), __('Available') => l10n::getISOcodes(1,1)); |
---|
35 | while ($rs->fetch()) { |
---|
36 | if (isset($all_langs[$rs->post_lang])) { |
---|
37 | $lang_combo[__('Most used')][$all_langs[$rs->post_lang]] = $rs->post_lang; |
---|
38 | unset($lang_combo[__('Available')][$all_langs[$rs->post_lang]]); |
---|
39 | } else { |
---|
40 | $lang_combo[__('Most used')][$rs->post_lang] = $rs->post_lang; |
---|
41 | } |
---|
42 | } |
---|
43 | unset($rs); |
---|
44 | |
---|
45 | echo |
---|
46 | '<form id="dcwikipedia-lang-form" action="'.DC_ADMIN_URL.'plugin.php" method="get">'. |
---|
47 | form::hidden('p','dcWikipedia'). |
---|
48 | form::hidden('popup','1'). |
---|
49 | form::hidden('value',$value). |
---|
50 | '<p><label for="lang">'.__('Lang:').''. |
---|
51 | form::combo('lang',$lang_combo,$lang). |
---|
52 | '</label></p>'. |
---|
53 | $core->formNonce(). |
---|
54 | '</form>'; |
---|
55 | |
---|
56 | if (count($parser->getItems()) == 0) { |
---|
57 | echo |
---|
58 | '<p>'.sprintf( |
---|
59 | __('No suggestion found for : %s in %s'), |
---|
60 | '<strong><q>'.$value.'</q></strong>', |
---|
61 | '<em>'.$all_langs[$lang].'</em>' |
---|
62 | ).'</p>'; |
---|
63 | } |
---|
64 | else { |
---|
65 | echo '<form id="dcwikipedia-insert-form" action="#" method="get">'; |
---|
66 | foreach($parser->getItems() as $v => $k) { |
---|
67 | echo |
---|
68 | '<div class="dcwikipedia_item">'. |
---|
69 | '<p class="wikipedia_value">'. |
---|
70 | form::radio(array('dcwikipedia_uri'),$k['uri']). |
---|
71 | $k['value'].' <a href="'.$k['uri']. |
---|
72 | '" class="wikipedia_uri">('.__('Read more...').')</a></p>'. |
---|
73 | '<p class="wikipedia_desc">'.$k['desc'].'</p>'. |
---|
74 | '</div>'."\n"; |
---|
75 | } |
---|
76 | echo |
---|
77 | '<input type="hidden" name="dcwikipedia_value" value="'.$value.'" />'. |
---|
78 | '</form>'. |
---|
79 | '<p><a class="button" href="#" id="dcwikipedia-insert-cancel">'.__('cancel').'</a> - '. |
---|
80 | '<strong><a class="button" href="#" id="dcwikipedia-insert-ok">'.__('insert').'</a></strong></p>'."\n"; |
---|
81 | } |
---|
82 | |
---|
83 | ?> |
---|
84 | |
---|
85 | </body> |
---|
86 | </html> |
---|