Dotclear

source: plugins/dcWikipedia/popup.php @ 1124

Revision 1124, 2.7 KB checked in by Tomtom33, 14 years ago (diff)

dcWikipedia 0.2 :

  • Added language combo to change language search (closes #167)
  • Changed locales
  • Property svn:executable set to *
Line 
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));
35while ($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}
43unset($rs);
44
45echo 
46'<form id="dcwikipedia-lang-form" action="'.DC_ADMIN_URL.'plugin.php" method="get">'.
47form::hidden('p','dcWikipedia').
48form::hidden('popup','1').
49form::hidden('value',$value).
50'<p><label for="lang">'.__('Lang:').''.
51form::combo('lang',$lang_combo,$lang).
52'</label></p>'.
53$core->formNonce().
54'</form>';
55
56if (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}
64else {
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'].'&nbsp;<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>
Note: See TracBrowser for help on using the repository browser.

Sites map