2015-08-07 16:05:11 +02:00
|
|
|
<?php
|
2011-12-13 12:29:05 +01:00
|
|
|
|
|
|
|
if (IN_serendipity !== true) {
|
|
|
|
die ("Don't hack!");
|
|
|
|
}
|
|
|
|
|
2016-04-13 12:36:24 +02:00
|
|
|
@serendipity_plugin_api::load_language(dirname(__FILE__));
|
2011-12-13 12:29:05 +01:00
|
|
|
|
|
|
|
class serendipity_plugin_multilingual extends serendipity_event
|
|
|
|
{
|
|
|
|
var $title = PLUGIN_SIDEBAR_MULTILINGUAL_TITLE;
|
|
|
|
|
|
|
|
function introspect(&$propbag)
|
|
|
|
{
|
|
|
|
global $serendipity;
|
|
|
|
|
|
|
|
$propbag->add('name', PLUGIN_SIDEBAR_MULTILINGUAL_TITLE);
|
|
|
|
$propbag->add('description', PLUGIN_SIDEBAR_MULTILINGUAL_DESC);
|
|
|
|
$propbag->add('stackable', false);
|
|
|
|
$propbag->add('author', 'Garvin Hicking, Wesley Hwang-Chung');
|
|
|
|
$propbag->add('requirements', array(
|
2016-04-13 12:36:24 +02:00
|
|
|
'serendipity' => '1.6',
|
2011-12-13 12:29:05 +01:00
|
|
|
'smarty' => '2.6.7',
|
|
|
|
'php' => '4.1.0'
|
|
|
|
));
|
|
|
|
|
|
|
|
$conf = array('title', 'show_submit', 'size');
|
|
|
|
foreach($serendipity['languages'] AS $lkey => $lval) {
|
|
|
|
$conf[] = $lkey;
|
|
|
|
}
|
|
|
|
$propbag->add('configuration', $conf);
|
2016-05-12 10:04:49 +02:00
|
|
|
$propbag->add('version', '1.14');
|
2011-12-13 12:29:05 +01:00
|
|
|
$propbag->add('groups', array('FRONTEND_VIEWS'));
|
|
|
|
$this->dependencies = array('serendipity_event_multilingual' => 'remove');
|
|
|
|
}
|
|
|
|
|
2016-04-13 12:36:24 +02:00
|
|
|
function introspect_config_item($name, &$propbag)
|
|
|
|
{
|
2011-12-13 12:29:05 +01:00
|
|
|
global $serendipity;
|
2015-08-07 16:05:11 +02:00
|
|
|
|
2011-12-13 12:29:05 +01:00
|
|
|
foreach($serendipity['languages'] AS $lkey => $lval) {
|
|
|
|
if ($name == $lkey) {
|
2015-08-07 16:05:11 +02:00
|
|
|
$propbag->add('type', 'boolean');
|
|
|
|
$propbag->add('name', $lval);
|
|
|
|
$propbag->add('default', 'true');
|
2016-05-12 10:04:49 +02:00
|
|
|
return true; // keep!
|
2011-12-13 12:29:05 +01:00
|
|
|
}
|
|
|
|
}
|
2015-08-07 16:05:11 +02:00
|
|
|
|
2011-12-13 12:29:05 +01:00
|
|
|
switch($name) {
|
|
|
|
case 'title':
|
|
|
|
$propbag->add('type', 'string');
|
|
|
|
$propbag->add('name', TITLE);
|
|
|
|
$propbag->add('description', TITLE);
|
|
|
|
$propbag->add('default', '');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'show_submit':
|
|
|
|
$propbag->add('type', 'boolean');
|
|
|
|
$propbag->add('name', PLUGIN_SIDEBAR_MULTILINGUAL_SUBMIT);
|
|
|
|
$propbag->add('description', PLUGIN_SIDEBAR_MULTILINGUAL_SUBMIT_DESC);
|
|
|
|
$propbag->add('default', 'false');
|
|
|
|
break;
|
|
|
|
|
2015-08-07 16:05:11 +02:00
|
|
|
case 'size':
|
2011-12-13 12:29:05 +01:00
|
|
|
$propbag->add('type', 'string');
|
|
|
|
$propbag->add('name', PLUGIN_SIDEBAR_MULTILINGUAL_SIZE);
|
|
|
|
$propbag->add('default', '9');
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2015-08-07 16:05:11 +02:00
|
|
|
return false;
|
2011-12-13 12:29:05 +01:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-04-13 12:36:24 +02:00
|
|
|
function generate_content(&$title)
|
|
|
|
{
|
2011-12-13 12:29:05 +01:00
|
|
|
global $serendipity;
|
|
|
|
|
|
|
|
$title = $this->get_config('title', $this->title);
|
2015-08-07 16:05:11 +02:00
|
|
|
$url = serendipity_currentURL(true);
|
2011-12-13 12:29:05 +01:00
|
|
|
|
|
|
|
echo '<form id="language_chooser" action="' . $url . '" method="post"><div>';
|
|
|
|
echo '<select style="font-size: ' . $this->get_config('size', '9') . 'px" name="user_language" onchange="document.getElementById(\'language_chooser\').submit();">';
|
2015-08-07 16:05:11 +02:00
|
|
|
// echo '<option value=""> </option>'."\n";
|
2011-12-13 12:29:05 +01:00
|
|
|
foreach ($serendipity['languages'] as $lang_key => $language) {
|
2015-08-07 16:05:11 +02:00
|
|
|
if (serendipity_db_bool($this->get_config($lang_key, 'false'))) {
|
|
|
|
echo '<option value="' . $lang_key . '" ' . ($serendipity['lang'] == $lang_key ? 'selected="selected"' : '') . '>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($language) : htmlspecialchars($language, ENT_COMPAT, LANG_CHARSET)) . '</option>';
|
2011-12-13 12:29:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
echo '</select>';
|
|
|
|
|
2015-08-07 16:05:11 +02:00
|
|
|
if (serendipity_db_bool($this->get_config('show_submit', 'false'))) {
|
2011-12-13 12:29:05 +01:00
|
|
|
echo '<input type="submit" name="submit" value="' . GO . '" size="4" />';
|
|
|
|
}
|
|
|
|
echo '</div></form>';
|
|
|
|
}
|
2016-04-13 12:36:24 +02:00
|
|
|
|
2011-12-13 12:29:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* vim: set sts=4 ts=4 expandtab : */
|
|
|
|
?>
|