Commit f7f9054d authored by JosephK's avatar JosephK
Browse files

Simplification ShaarliRoot + i18n des js

parent 3d5143f5
......@@ -64,8 +64,15 @@ function t($txt){
// Import $t variable from locale/lg.php files in each plugin
// The 'i18n' plugin is one of them and contains the main file
foreach($GLOBALS['config']['ENABLED_PLUGINS'] as $plugin) {
if (is_file( PluginManager::$PLUGINS_PATH . '/' . $plugin . '/locale/'.$_SESSION['lang'].'.php') ) {
require( PluginManager::$PLUGINS_PATH . '/' . $plugin . '/locale/'.$_SESSION['lang'].'.php');
if(class_exists( 'PluginManager' )) {
// Call from index.php
$locale = PluginManager::$PLUGINS_PATH . '/' . $plugin . '/locale/'.$_SESSION['lang'].'.php';
} else {
// Call from a plugin file
$locale = '../' . $plugin . '/locale/'.$_SESSION['lang'].'.php';
}
if (is_file( $locale ) ) {
require( $locale );
}
}
$txt = (isset($t[$txt]) && !empty($t[$txt])) ? $t[$txt] : $txt;
......
<?php
// myframa.js
$t['Hide links descriptions'] = 'Masquer la description des liens';
$t['Show links descriptions'] = 'Afficher la description des liens';
$t['Close'] = 'Fermer';
$t['Your account has been successfully created. You can sign in now.'] = 'Votre compte MyFrama a bien été créé. Vous pouvez à présent vous y connecter.';
?>
\ No newline at end of file
<?php
require_once str_replace('/plugins/myframa', '', dirname($_SERVER['SCRIPT_FILENAME'])) . '/data/config.php';
// I18n
if(!in_array('i18n',$GLOBALS['config']['ENABLED_PLUGINS']) && !function_exists(t)) {
function t($txt) { return $txt; }
}
$ShaarliRoot = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
// Pré-remplissage Login
$account = explode('/', str_replace('/plugins/myframa', '', dirname($_SERVER['SCRIPT_FILENAME'])));
require_once $ShaarliRoot . '/data/config.php';
// I18n
if(!in_array('i18n',$GLOBALS['config']['ENABLED_PLUGINS']) && !function_exists(t)) {
function t($txt) { return $txt; }
} else {
require_once $ShaarliRoot . '/plugins/i18n/i18n.php';
}
// Pré-remplissage Login
$account = explode('/', $ShaarliRoot);
?>
jQuery(document).ready(function(){
// Button Show/Hide link description ~~> to move in link filter menu
if(/do=daily|login/i.test(window.location.href) || !(/=/i.test(window.location.href))) {
jQuery('.sl-menu .list-inline.pull-right').prepend(
'<li><a id="descToggle" href="javascript:void(0);" title="Hide links descriptions">'+
'<i class="fa fa-fw fa-lg fa-toggle-on"></i><span class="sr-only">Hide links descriptions</span>'+
'<li><a id="descToggle" href="javascript:void(0);" title="<?php echo t('Hide links descriptions'); ?>">'+
'<i class="fa fa-fw fa-lg fa-toggle-on"></i><span class="sr-only"><?php echo t('Hide links descriptions'); ?></span>'+
'</a></li>'
);
jQuery('#descToggle').click(
function(){
if(jQuery(this).children('i').hasClass('fa-toggle-on')) {
jQuery('.link-description').hide();
jQuery('#descToggle').attr('title', 'Show links descriptions');
jQuery('#descToggle').attr('title', '<?php echo t('Show links descriptions'); ?>');
jQuery('#descToggle').children('i').addClass('fa-toggle-off').removeClass('fa-toggle-on');
jQuery('#descToggle').children('.sr-only').text('Show links descriptions');
jQuery('#descToggle').children('.sr-only').text('<?php echo t('Show links descriptions'); ?>');
} else {
jQuery('.link-description').show();
jQuery('#descToggle').attr('title', 'Hide links descriptions');
jQuery('#descToggle').attr('title', '<?php echo t('Hide links descriptions'); ?>');
jQuery('#descToggle').children('i').removeClass('fa-toggle-off').addClass('fa-toggle-on');
jQuery('#descToggle').children('.sr-only').text('Hide links descriptions');
jQuery('#descToggle').children('.sr-only').text('<?php echo t('Hide links descriptions'); ?>');
}
}
);
......@@ -62,7 +65,7 @@ jQuery(document).ready(function(){
if(/do=login/i.test(window.location.href)) {
// After registration
if(/do=login\&r/i.test(window.location.href)) {
jQuery('#loginform').prepend('<div class="alert alert-info text-center"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><b>Votre compte MyFrama a bien été créé. Vous pouvez à présent vous y connecter.</b></div>');
jQuery('#loginform').prepend('<div class="alert alert-info text-center"><button type="button" class="close" data-dismiss="alert" aria-label="<?php echo t('Close'); ?>"><span aria-hidden="true">&times;</span></button><b><?php echo t('Your account has been successfully created. You can sign in now.'); ?></b></div>');
jQuery('[name="returnurl"]').val('');
}
......
<?php
$ShaarliRoot = str_replace('plugins/recovery', '', dirname($_SERVER['SCRIPT_FILENAME']));
$ShaarliRoot = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
require_once $ShaarliRoot . 'data/config.php';
require_once $ShaarliRoot . 'application/Config.php';
......
<?php
// recovery.js
$t['Password recovery'] = 'Récupération de mot de passe';
$t['Email'] = 'Courriel';
$t['Recover'] = 'Récupérer';
$t['I lost my password'] = 'J’ai perdu mon mot de passe';
// tools.html
$t['Change email'] = 'Changer le courriel';
$t['Change your recovery email'] = 'Changer votre courriel de restauration de compte';
$t['Close'] = 'Fermer';
......
<?php
$ShaarliRoot = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
require_once $ShaarliRoot . '/data/config.php';
// I18n
if(!in_array('i18n',$GLOBALS['config']['ENABLED_PLUGINS']) && !function_exists(t)) {
function t($txt) { return $txt; }
} else {
require_once $ShaarliRoot . '/plugins/i18n/i18n.php';
}
?>
if(/do=login/i.test(window.location.href)) {
var rForm = document.createElement('div');
......@@ -5,12 +17,12 @@ if(/do=login/i.test(window.location.href)) {
rForm.id = 'rForm';
rForm.innerHTML =
'<form class="col-md-6 col-md-offset-3 ombre clearfix">'+
'<h2>Password recovery</h2>'+
'<h2><?php echo t('Password recovery'); ?></h2>'+
'<div class="form-group">'+
'<label for="email">Email</label>'+
'<label for="email"><?php echo t('Email'); ?></label>'+
'<input type="email" id="email" name="email" placeholder="@" class="form-control">'+
'</div>'+
'<button type="submit" value="Recover" class="btn btn-warning pull-right">Recover</button>'+
'<button type="submit" value="Recover" class="btn btn-warning pull-right"><?php echo t('Recover'); ?></button>'+
'</form>';
document.loginform.parentNode.insertBefore(rForm, this.nextSibling)
......@@ -26,7 +38,7 @@ if(/do=login/i.test(window.location.href)) {
var rLink = document.createElement('p');
rLink.className = 'help-block text-right';
rLink.id = 'rLink';
rLink.innerHTML = '<a href="javascript:void(0);" onclick="recoveryForm();return false;" class="text-muted">I lost my password</a>';
rLink.innerHTML = '<a href="javascript:void(0);" onclick="recoveryForm();return false;" class="text-muted"><?php echo t('I lost my password'); ?></a>';
document.loginform.password.parentNode.insertBefore(rLink, this.nextSibling)
......
......@@ -7,7 +7,7 @@ if(!in_array('i18n',$GLOBALS['config']['ENABLED_PLUGINS']) && !function_exists(t
function hook_recovery_render_footer($data)
{
if ($data['_LOGGEDIN_'] === false ) {
$data['js_files'][] = PluginManager::$PLUGINS_PATH . '/recovery/recovery.js';
$data['js_files'][] = PluginManager::$PLUGINS_PATH . '/recovery/recovery.js.php';
}
return $data;
......
<?php
$ShaarliRoot = str_replace('plugins/recovery', '', dirname($_SERVER['SCRIPT_FILENAME']));
$ShaarliRoot = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
require_once $ShaarliRoot . 'data/config.php';
require_once $ShaarliRoot . 'application/Config.php';
$ShaarliURL = str_replace('plugins/recovery', '', dirname($_SERVER['SCRIPT_FILENAME']));
$ShaarliURL = str_replace('plugins/recovery', '', dirname($_SERVER['SCRIPT_FILENAME'])); // To change
$c = $GLOBALS;
......
<?php
$ShaarliRoot = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
session_name('shaarli');
if (session_id() == '') {
......@@ -9,7 +9,7 @@ if (session_id() == '') {
if( isset($_POST['saveTags']) && isset($_POST['token']) ) {
$token = $_POST['token'];
$taFile = str_replace('plugins/tags_advanced', '', dirname($_SERVER['SCRIPT_FILENAME'])) . '/data/tags_advanced.php';
$taFile = $ShaarliRoot . '/data/tags_advanced.php';
// = tokenOk() from shaarli/index.php
if (isset($_SESSION['tokens'][$token])) {
......@@ -48,7 +48,7 @@ if( isset($_POST['saveTags']) && isset($_POST['token']) ) {
if(isset($_SERVER['HTTP_REFERER'])) {
header('Location: '.$_SERVER['HTTP_REFERER']);
} else {
header('Location: '.str_replace('plugins/tags_advanced', '', dirname($_SERVER['SCRIPT_FILENAME'])));
header('Location: '.$ShaarliRoot);
}
}
}
......
<?php
$ShaarliRoot = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
// I18n
if(!in_array('i18n',$GLOBALS['config']['ENABLED_PLUGINS']) && !function_exists(t)) {
function t($txt) { return $txt; }
......@@ -74,7 +75,7 @@ function tags_advanced_config($taData)
*/
function hook_tags_advanced_render_linklist($data)
{
require_once str_replace('plugins/tags_advanced', '', dirname($_SERVER['SCRIPT_FILENAME'])) . '/data/tags_advanced.php';
require_once 'data/tags_advanced.php';
if(isset($taData) && !empty($taData)) {
......@@ -116,7 +117,7 @@ function hook_tags_advanced_render_tools($data)
<p class="list-group-item-text">'.t('Keep visible some important tags and define filters to automatically add tags to your links').'</p>
</a>';
require_once str_replace('plugins/tags_advanced', '', dirname($_SERVER['SCRIPT_FILENAME'])) . '/data/tags_advanced.php';
require_once 'data/tags_advanced.php';
$data['tools_plugin'][] = $html . tags_advanced_config($taData);
......@@ -139,7 +140,7 @@ function hook_tags_advanced_render_tagcloud($data)
*/
function hook_tags_advanced_save_link($data)
{
require_once str_replace('plugins/tags_advanced', '', dirname($_SERVER['SCRIPT_FILENAME'])) . '/data/tags_advanced.php';
require_once 'data/tags_advanced.php';
$tagsList = '';
foreach($taData as $k => $v) {
......@@ -153,8 +154,6 @@ function hook_tags_advanced_save_link($data)
$data['tags'] .= (empty($data['tags'])) ? ltrim($tagsList, ' ') : $tagsList;
file_put_contents(str_replace('plugins/tags_advanced', '', dirname($_SERVER['SCRIPT_FILENAME'])) . '/data/test.php', $data);
return $data;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment