Browse Source

- Fix the DateHelper (tomorrow issue)

- Use Moxl Packets 
- Fix a fatal error in presence subscription handling
- Fix XMPPtoForm
pull/16/head
Jaussoin Timothée 11 years ago
parent
commit
8c9e426091
  1. 63
      app/helpers/DateHelper.php
  2. 5
      app/widgets/AdminMain/AdminMain.php
  3. 12
      app/widgets/AdminMain/adminmain.tpl
  4. 6
      app/widgets/Chat/Chat.php
  5. 2
      app/widgets/Notifs/Notifs.php
  6. 3
      app/widgets/Roster/Roster.php
  7. 3
      bootstrap.php
  8. 5
      lib/XMPPtoForm.php
  9. 69
      themes/movim/css/forms.css

63
app/helpers/DateHelper.php

@ -38,50 +38,41 @@ function getTimezoneCorrection() {
$timezones = getTimezoneList();
return $timezones[date_default_timezone_get()];
}
/**
* Return a human-readable date
*
* @param timestamp $string
* @return string
*/
function prepareDate($time, $hours = true) {
$dotw = getDays();
$moty = getMonths();
$today = strtotime(date('M j, Y'));
// We fix the timezone
$time = $time + 3600*(int)getTimezoneCorrection();
$reldays = ($time - $today)/86400;
if ($reldays >= 0 && $reldays < 1) { //$reldays == 0 ?
$date = __('date.today');
} else if ($reldays >= 1 && $reldays < 2) { //$reldays == 1 ?
$date = __('date.tomorrow');
} else if ($reldays >= -1 && $reldays < 0) { //$reldays == -1 ?
$date = __('date.yesterday');
} else {
if (abs($reldays) < 7) {
if ($reldays > 0) { //=> $reldays > 1
$reldays = floor($reldays);
$date = 'In ' . $reldays . ' '.__('date.day') . ($reldays != 1 ? 's' : ''); //you always have s
} else {
$reldays = abs(floor($reldays));
$date = __('date.ago', $reldays);
}
} else {
$date = $dotw[date('N',$time ? $time : time())] .', '.date('j',$time ? $time : time()).' '.$moty[date('n',$time ? $time : time())] ;
if (abs($reldays) > 182)
$date .= date(', Y',$time ? $time : time());
function prepareDate($time, $hours = true) {
$t = $time ? $time : time();
$reldays = ((time() - $t)-(time()%86400))/86400;
// if $time is within a week
if($reldays < 7 && $reldays >= -2){
//if $time is today or yesterday
if($reldays < -1) {
$date = __('date.tomorrow');
} else if ($reldays <= 0) {
$date = __('date.today');
} else if ($reldays <= 1) {
$date = __('date.yesterday');
}
//else print date "ago"
else {
$date = __('date.ago', ceil($reldays));
}
}
//else print full date
else {
$date = __('day.'.strtolower(date('l', $t))) .', '.date('j', $t).' '.__('month.'.strtolower(date('F', $t))) ;
//if over 6months print year
if (abs($reldays) > 182)
$date .= date(', Y', $t);
}
//if $hours option print the time
if($hours)
$date .= ' - '. date('H:i', $time);
if($time)
return $date;
return $date;
}

5
app/widgets/AdminMain/AdminMain.php

@ -33,12 +33,13 @@ class AdminMain extends WidgetBase
}
unset($form['repassword']);
foreach($form as $key => $value) {
$config->$key = $value;
}
$cd->set($config);
//set timezone
date_default_timezone_set($form['timezone']);
}
}

12
app/widgets/AdminMain/adminmain.tpl

@ -120,12 +120,10 @@
<legend>{$c->__('whitelist.title')}</legend>
<div class="clear"></div>
<p>{$c->__('whitelist.info1')}</p>
<p>{$c->__('whitelist.info2')}</p>
<div class="element large">
<label for="xmppwhiteiist">{$c->__('whitelist.label')}</label>
<p>{$c->__('whitelist.info1')}</p>
<p>{$c->__('whitelist.info2')}</p>
<input type="text" name="xmppwhitelist" id="xmppwhitelist" value="{$conf->xmppwhitelist}" />
</div>
</fieldset>
@ -141,12 +139,10 @@
</div>
<div class="clear"></div>
<p>{$c->__('information.info1')}</p>
<p>{$c->__('information.info2')}</p>
<div class="element large">
<label for="info">{$c->__('information.label')}</label>
<p>{$c->__('information.info1')}</p>
<p>{$c->__('information.info2')}</p>
<textarea type="text" name="info" id="info" />{$conf->info}</textarea>
</div>
</fieldset>

6
app/widgets/Chat/Chat.php

@ -40,7 +40,8 @@ class Chat extends WidgetBase {
$this->view->assign('chats', $this->prepareChats());
}
function onPresence($presence) {
function onPresence($packet) {
$presence = $packet->content;
$arr = $presence->getPresence();
$txt = getPresences();
@ -161,7 +162,8 @@ class Chat extends WidgetBase {
}
}
function onAttention($jid) {
function onAttention($packet) {
$jid = $packet->from;
$rc = new \Modl\ContactDAO();
$contact = $rc->getRosterItem(echapJid($jid));
$html = '

2
app/widgets/Notifs/Notifs.php

@ -18,7 +18,7 @@
* See COPYING for licensing information.
*/
use Moxl\Xec\Action\Presence\Subscribed;
use Moxl\Xec\Action\Presence\Unsuscribed;
use Moxl\Xec\Action\Presence\Unsubscribed;
use Moxl\Xec\Action\Roster\AddItem;
use Moxl\Xec\Action\Presence\Subscribe;

3
app/widgets/Roster/Roster.php

@ -55,8 +55,9 @@ class Roster extends WidgetBase
$this->view->assign('rosterlist', $this->prepareRoster());
}
function onPresence($presence)
function onPresence($packet)
{
$presence = $packet->content;
$arr = $presence->getPresence();
$cd = new \Modl\ContactDAO();

3
bootstrap.php

@ -239,8 +239,7 @@ class Bootstrap {
$cd = new \Modl\ConfigDAO();
$config = $cd->get();
//date_default_timezone_set($config->timezone);
date_default_timezone_set(date_default_timezone_get());
date_default_timezone_set($config->timezone);
}
private function setLogLevel() {

5
lib/XMPPtoForm.php

@ -298,9 +298,10 @@ class FormtoXMPP{
} else{
$field = $node->addChild('field');
if($value == 'true' || $value == 1)
\movim_log(serialize($value));
if($value == 'true' || $value === 1)
$value = '1';
if($value == 'false' || $value == 0)
if($value == 'false' || $value === 0)
$value = '0';
$field->addChild('value', trim($value));

69
themes/movim/css/forms.css

@ -40,7 +40,7 @@ legend {
display: block;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-moz-box-sizing: border-box;
overflow-y: hidden;
}
@ -58,18 +58,9 @@ legend {
min-height: 0;
}
.element.mini > input {
min-height: 2em;
margin-bottom: 0.5em;
}
.element > label {
display: block;
margin: 1em 0px;
font-weight: bold;
}
.element > *:not(label):not(img):not(span):not(a):not(dl) {
/*.element > *:not(label):not(img):not(span):not(a):not(dl) {*/
.element > input,
.element > textarea {
display: inline-block;
width: 100%;
border: 1px solid #DDD;
@ -80,9 +71,21 @@ legend {
padding: 0% 0.5em;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-moz-box-sizing: border-box;
}
.element.mini > input {
min-height: 2em;
margin-bottom: 0.5em;
}
.element > label {
display: block;
margin: 1em 0px;
font-weight: bold;
}
.element > *:not(label):not(img):focus {
border: 1px solid gray;
outline: none;
@ -154,7 +157,7 @@ legend {
margin-right: 2%;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-moz-box-sizing: border-box;
}
.element input[type="radio"] + label:hover {
@ -172,7 +175,7 @@ legend {
border-radius: 0.1em;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-moz-box-sizing: border-box;
}
.element input[type="radio"]:checked + label .preview {
@ -186,11 +189,11 @@ legend {
}
.checkbox {
width: 6em;
max-width: 6em;
width: 6em;
max-width: 6em;
overflow: hidden;
position: relative;
position: relative;
height: 2em;
border-radius: 0.1em;
@ -200,7 +203,7 @@ legend {
}
.checkbox:after {
content: 'NO';
content: 'NO';
display: block;
position: absolute;
@ -214,11 +217,11 @@ legend {
color: white;
background-color: #D92727;
font-weight: bold;
font-weight: bold;
}
.checkbox:before {
content: 'YES';
content: 'YES';
display: block;
position: absolute;
left: 0px;
@ -229,21 +232,21 @@ legend {
background-color: #333;
text-align: center;
color: white;
font-weight: bold;
font-weight: bold;
}
.checkbox > input[type="checkbox"] + label {
display: block;
width: 3.3em;
height: 2em;
display: block;
width: 3.3em;
height: 2em;
transition: left 0.5s ease;
cursor: pointer;
position: absolute;
top: 0px;
left: 0px;
z-index: 1;
cursor: pointer;
position: absolute;
top: 0px;
left: 0px;
z-index: 1;
border-left: none;
@ -251,7 +254,7 @@ legend {
}
.checkbox > input[type="checkbox"]:checked + label {
left: 2.8em;
left: 2.8em;
border-right: none;
}
@ -262,7 +265,7 @@ legend {
border: 1px solid transparent;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-moz-box-sizing: border-box;
padding: 0 0.7em;
text-decoration: none;

Loading…
Cancel
Save