mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 17:29:21 +02:00
* save detected country on create account in session
* warning about leaving news page with changes
This commit is contained in:
parent
01c0d021b2
commit
4a948b8ba2
@ -206,36 +206,43 @@ if($save)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$country_recognized = null;
|
$country_recognized = null;
|
||||||
if($config['account_country_recognize']) {
|
if($config['account_country_recognize']) {
|
||||||
|
$country_session = getSession('country');
|
||||||
|
if($country_session !== false) { // get from session
|
||||||
|
$country_recognized = $country_session;
|
||||||
|
}
|
||||||
|
else {
|
||||||
$info = json_decode(@file_get_contents('http://ipinfo.io/' . $_SERVER['REMOTE_ADDR'] . '/geo'), true);
|
$info = json_decode(@file_get_contents('http://ipinfo.io/' . $_SERVER['REMOTE_ADDR'] . '/geo'), true);
|
||||||
if(isset($info['country'])) {
|
if(isset($info['country'])) {
|
||||||
$country_recognized = strtolower($info['country']);
|
$country_recognized = strtolower($info['country']);
|
||||||
|
setSession('country', $country_recognized);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!empty($errors))
|
if(!empty($errors))
|
||||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||||
|
|
||||||
if($config['account_country']) {
|
if($config['account_country']) {
|
||||||
$countries = array();
|
$countries = array();
|
||||||
foreach (array('pl', 'se', 'br', 'us', 'gb') as $c)
|
foreach (array('pl', 'se', 'br', 'us', 'gb') as $c)
|
||||||
$countries[$c] = $config['countries'][$c];
|
$countries[$c] = $config['countries'][$c];
|
||||||
|
|
||||||
$countries['--'] = '----------';
|
$countries['--'] = '----------';
|
||||||
foreach ($config['countries'] as $code => $c)
|
foreach ($config['countries'] as $code => $c)
|
||||||
$countries[$code] = $c;
|
$countries[$code] = $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $twig->render('account.create.js.html.twig');
|
echo $twig->render('account.create.js.html.twig');
|
||||||
echo $twig->render('account.create.html.twig', array(
|
echo $twig->render('account.create.html.twig', array(
|
||||||
'account' => isset($_POST['account']) ? $_POST['account'] : '',
|
'account' => isset($_POST['account']) ? $_POST['account'] : '',
|
||||||
'email' => isset($_POST['email']) ? $_POST['email'] : '',
|
'email' => isset($_POST['email']) ? $_POST['email'] : '',
|
||||||
'countries' => isset($countries) ? $countries : null,
|
'countries' => isset($countries) ? $countries : null,
|
||||||
'accept_rules' => isset($_POST['accept_rules']) ? $_POST['accept_rules'] : false,
|
'accept_rules' => isset($_POST['accept_rules']) ? $_POST['accept_rules'] : false,
|
||||||
'country_recognized' => $country_recognized,
|
'country_recognized' => $country_recognized,
|
||||||
'country' => isset($country) ? $country : null,
|
'country' => isset($country) ? $country : null,
|
||||||
'errors' => $errors,
|
'errors' => $errors,
|
||||||
'save' => $save
|
'save' => $save
|
||||||
));
|
));
|
||||||
?>
|
?>
|
@ -1,13 +1,3 @@
|
|||||||
<script type="text/javascript" src="{{ constant('BASE_URL') }}tools/tinymce/tinymce.min.js"></script>
|
|
||||||
<script type="text/javascript">
|
|
||||||
tinymce.init({
|
|
||||||
selector : "#body",
|
|
||||||
theme : "modern",
|
|
||||||
plugins: 'print preview searchreplace autolink directionality visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor toc insertdatetime advlist lists textcolor wordcount spellchecker imagetools contextmenu colorpicker textpattern help code',
|
|
||||||
toolbar1: 'formatselect | bold italic strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat code',
|
|
||||||
image_advtab: true
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% if action != 'edit' %}
|
{% if action != 'edit' %}
|
||||||
<a id="news-button" href="#">Add news</a>
|
<a id="news-button" href="#">Add news</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -121,7 +111,7 @@
|
|||||||
<input type="submit" value="Submit"/>
|
<input type="submit" value="Submit"/>
|
||||||
</td>
|
</td>
|
||||||
<td align="left">
|
<td align="left">
|
||||||
<input type="button" onclick="window.location = '{{ news_link }}';" value="Cancel"/>
|
<input id="cancel" type="button" value="Cancel"/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@ -151,3 +141,44 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<script type="text/javascript" src="{{ constant('BASE_URL') }}tools/tinymce/tinymce.min.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var unsaved = false;
|
||||||
|
var lastContent = '';
|
||||||
|
|
||||||
|
tinymce.init({
|
||||||
|
selector : "#body",
|
||||||
|
theme : "modern",
|
||||||
|
plugins: 'print preview searchreplace autolink directionality visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor toc insertdatetime advlist lists textcolor wordcount spellchecker imagetools contextmenu colorpicker textpattern help code',
|
||||||
|
toolbar1: 'formatselect | bold italic strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat code',
|
||||||
|
image_advtab: true,
|
||||||
|
setup: function(ed){
|
||||||
|
ed.on('NodeChange', function(e) {
|
||||||
|
if(ed.getContent() != lastContent) {
|
||||||
|
unsaved = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
$(":input").change(function(){ //trigers change in all input fields including text type
|
||||||
|
unsaved = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#cancel").click(function( event ) {
|
||||||
|
unsaved = false;
|
||||||
|
window.location = '{{ news_link }}';
|
||||||
|
});
|
||||||
|
|
||||||
|
lastContent = $("#body").val();
|
||||||
|
});
|
||||||
|
|
||||||
|
function unloadPage(){
|
||||||
|
if(unsaved){
|
||||||
|
return "You have unsaved changes on this page. Do you want to leave this page and discard your changes or stay on this page?";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.onbeforeunload = unloadPage;
|
||||||
|
</script>
|
Loading…
x
Reference in New Issue
Block a user