Browse Source

Huge commit

- Rewrite the whole PubsubSubscriptionConfig widget to make it more readable
- Fix lot of UI issues fixed
- Get automaticaly the contact pubsub subscription list
- Fix location submition widget
- Add a tab parameter to the Route::urlize() function
pull/16/head
Jaussoin Timothée 12 years ago
parent
commit
33163f02ad
  1. 2
      app/models/subscription/Subscription.php
  2. 2
      app/views/conf.tpl
  3. 1
      app/views/nodeconfig.tpl
  4. 1
      app/widgets/Avatar/avatar.tpl
  5. 2
      app/widgets/Bookmark/Bookmark.php
  6. 4
      app/widgets/Bookmark/bookmark.tpl
  7. 1
      app/widgets/Config/config.tpl
  8. 4
      app/widgets/ContactCard/ContactCard.php
  9. 25
      app/widgets/ContactPubsubSubscription/ContactPubsubSubscription.php
  10. 5
      app/widgets/ContactPubsubSubscription/contactpubsubsubscription.js
  11. 22
      app/widgets/Location/Location.php
  12. 2
      app/widgets/Location/location.js
  13. 126
      app/widgets/PubsubSubscriptionConfig/PubsubSubscriptionConfig.php
  14. 9
      app/widgets/PubsubSubscriptionConfig/_pubsubsubscriptionconfig_list.tpl
  15. 5
      app/widgets/PubsubSubscriptionConfig/pubsubsubscriptionconfig.tpl
  16. 16
      app/widgets/Vcard4/Vcard4.php
  17. 59
      app/widgets/Vcard4/vcard4.tpl
  18. 6
      system/Route.php
  19. 18
      themes/movim/css/forms.css
  20. 19
      themes/movim/css/style.css
  21. 6
      themes/movim/img/icons/button/gear.svg

2
app/models/subscription/Subscription.php

@ -34,8 +34,6 @@ class Subscription extends ModlModel {
parent::__construct();
}
function set($jid, $server, $node, $s) {
$this->jid = $jid;
$this->server = $server;

2
app/views/conf.tpl

@ -14,8 +14,6 @@
</div>
<?php $this->widget('Tabs');?>
<div id="center">
<div title="<?php echo getFlagTitle("white"); ?>" class="protect white"></div>
<?php $this->widget('Config');?>
<?php $this->widget('ConfigData');?>
<?php $this->widget('PubsubSubscriptionConfig');?>

1
app/views/nodeconfig.tpl

@ -15,7 +15,6 @@
<?php $this->widget('Profile');?>
<?php $this->widget('Bookmark');?>
<?php $this->widget('Notifs');?>
<?php $this->widget('Location');?>
</div>
<?php $this->widget('Tabs');?>

1
app/widgets/Avatar/avatar.tpl

@ -1,4 +1,5 @@
<div class="tabelem padded" title="{$c->t('Avatar')}" id="avatar" >
<div class="protect orange"></div>
<form name="avatarform" id="avatarform">
<fieldset>
<legend>{$c->t('Avatar')}</legend>

2
app/widgets/Bookmark/Bookmark.php

@ -28,6 +28,8 @@ class Bookmark extends WidgetBase
$this->registerEvent('groupsubscribed', 'onGroupSubscribed');
$this->registerEvent('groupunsubscribed', 'onGroupUnsubscribed');
$this->view->assign('subscriptionconfig', Route::urlize('conf', false, 'groupsubscribedlistconfig'));
$this->view->assign('getbookmark', $this->genCallAjax("ajaxGetBookmark"));
$this->view->assign('setbookmark', $this->genCallAjax("ajaxSetBookmark", "''"));

4
app/widgets/Bookmark/bookmark.tpl

@ -10,6 +10,10 @@
{$preparebookmark}
</div>
<br />
<a class="button black alone icon gear"
href="{$subscriptionconfig}"
title="{$c->t('Configure')}"></a>
<a class="button color blue icon users alone merged right"
style="float: right;"
title="{$c->t('Add a new Chat Room')}"

1
app/widgets/Config/config.tpl

@ -5,7 +5,6 @@
style="float: right;">
{$c->t('Feed Configuration')}
</a>
<div class="clear"></div>
<form enctype="multipart/form-data" method="post" action="index.php" name="general">
<fieldset>
<legend>{$c->t('General')}</legend>

4
app/widgets/ContactCard/ContactCard.php

@ -41,8 +41,8 @@ class ContactCard extends WidgetCommon
$html = '';
$html .= '
<form name="vcard" id="vcardform"><br />
<h1>'.t('Profile').'</h1><br />
<form name="vcard" id="vcardform">
<h1>'.t('Profile').'</h1>
<fieldset>
<legend>'.t('General Informations').'</legend>';

25
app/widgets/ContactPubsubSubscription/ContactPubsubSubscription.php

@ -25,10 +25,11 @@ class ContactPubsubSubscription extends WidgetBase
{
$this->registerEvent('groupsubscribedlist', 'onGroupSubscribedList');
$this->registerEvent('groupsubscribedlisterror', 'onGroupSubscribedListError');
$this->addjs('contactpubsubsubscription.js');
}
function prepareList($list) {
if(is_array($list[0])){
if(is_array(array_slice($list, 0, 1))){
$html = '<ul class="list">';
foreach($list as $item){
@ -37,9 +38,9 @@ class ContactPubsubSubscription extends WidgetBase
$html .= '</ul>';
return $html;
} else {
Notification::appendNotification(t('No public groups found'), 'info');
}
Notification::appendNotification(t('No public groups found'), 'info');
}
function onGroupSubscribedList($list) {
@ -49,7 +50,8 @@ class ContactPubsubSubscription extends WidgetBase
function onGroupSubscribedListError($error)
{
Notification::appendNotification($error, 'error');
//Notification::appendNotification($error, 'error');
RPC::call('hidePubsubSubscription');
}
function ajaxGetGroupSubscribedList($to){
@ -60,14 +62,13 @@ class ContactPubsubSubscription extends WidgetBase
function build()
{
?>
<div class="tabelem padded" title="<?php echo t('Public groups'); ?>" id="groupsubscribedlistfromfriend">
<div style="position:relative;top:-1.5em;right:-1.5em;" class="protect red" title="<?php echo getFlagTitle('red'); ?>"></div>
<a
class="button icon yes color green"
onclick="<?php echo $this->genCallAjax('ajaxGetGroupSubscribedList', "'".$_GET['f']."'"); ?> this.style.display = 'none'">
<?php echo t("Get public groups");?>
</a>
<div id="publicgroups"></div>
<div class="tabelem" title="<?php echo t('Public groups'); ?>" id="groupsubscribedlistfromfriend">
<div class="protect red" title="<?php echo getFlagTitle('red'); ?>"></div>
<h1><?php echo t('Public groups'); ?></h1>
<script type="text/javascript">
<?php echo $this->genCallAjax('ajaxGetGroupSubscribedList', "'".$_GET['f']."'"); ?>
</script>
<div id="publicgroups" class="paddedtop"></div>
</div>
<?php
}

5
app/widgets/ContactPubsubSubscription/contactpubsubsubscription.js

@ -0,0 +1,5 @@
function hidePubsubSubscription() {
wall = document.querySelector("#groupsubscribedlistfromfriend");
wall.parentNode.removeChild(wall);
createTabs();
}

22
app/widgets/Location/Location.php

@ -61,7 +61,6 @@ class Location extends WidgetBase
RPC::call('movim_fill', 'mapdata', $html);
Notification::appendNotification(t('Location updated'), 'success');
RPC::call('movim_delete', 'mapdiv');
RPC::commit();
}
@ -92,7 +91,7 @@ class Location extends WidgetBase
$html .= '
<div id="location">
<div id="mapdata" style="margin-bottom: 10px;">'.$data.'</div>
<div id="mapdata" style="margin: 1em 0;">'.$data.'</div>
<div id="mapdiv" style="width: auto; height: 250px; display: none;"></div>
<div class="clear"></div>
<a
@ -103,13 +102,9 @@ class Location extends WidgetBase
</a>
<a
id="mypossubmit"
style="display: none;"
class="button color green icon yes"
onclick="'.$submit.' hidePositionChoice();">'.t('Accept').'</a><a
style="display: none; margin-top: 1em;"
id="myposrefuse"
onclick="hidePositionChoice();"
class="button tiny icon alone no merged right"></a>
style="display: none; margin-top: 1em; float: right;"
class="button color green icon yes merged left"
onclick="'.$submit.' hidePositionChoice();">'.t('Accept').'</a>
</div>';
return $html;
@ -119,7 +114,14 @@ class Location extends WidgetBase
{
?>
<div class="tabelem padded" title="<?php echo t('Location'); ?>" id="location" >
<?php echo $this->prepareProfileData(); ?>
<div class="protect orange" title="<?php echo getFlagTitle($color); ?>"></div>
<form>
<fieldset>
<legend><?php echo t('Location'); ?></legend>
<div class="clear"></div>
<?php echo $this->prepareProfileData(); ?>
</fieldset>
</form>
</div>
<?php
}

2
app/widgets/Location/location.js

@ -32,7 +32,7 @@ function getMyPosition() {
s.src = 'http://nominatim.openstreetmap.org/reverse?json_callback=cb&format=json&lat='+position.coords.latitude+'&lon='+position.coords.longitude+'&zoom=27&addressdetails=1';
document.getElementsByTagName('head')[0].appendChild(s);
document.querySelector("#mypossubmit").style.display = 'block';
document.querySelector("#mypossubmit").style.display = 'inline-block';
},
// next function is the error callback
function (error)

126
app/widgets/PubsubSubscriptionConfig/PubsubSubscriptionConfig.php

@ -24,64 +24,102 @@ class PubsubSubscriptionConfig extends WidgetBase
function WidgetLoad()
{
$this->registerEvent('groupsubscribedlist', 'onGroupSubscribedList');
$this->registerEvent('groupadded', 'onGroupAdded');
$this->registerEvent('groupremoved', 'onGroupRemoved');
$this->view->assign(
'getsubscribedlist',
$this->genCallAjax('ajaxGetGroupSubscribedList')
);
}
function prepareList($list) {
if(isset($list) && is_array($list[0])){
$html = '<ul class="list">';
foreach($list as $item){
$delete = $this->genCallAjax('ajaxDeleteFromGroupSubscribedList', "'".$item[0]."'", "'".$item[1]."'");
$html .= '
<li id="group'.$item[0].'">
<a class="action" onclick="'.$delete.'">'.t('Delete').'</a>
<a href="'.Route::urlize('node', array($item[1],$item[0])).'">'.$item[2].'</a>
function onGroupSubscribedList($list) {
$html = $this->prepareList($list);
RPC::call('movim_fill', 'groupsubscribedlistconfig', $html);
}
function prepareList($list) {
$configlist = $this->tpl();
$sd = new \modl\SubscriptionDAO();
$listhtml = '';
//if($sd != null && $sd->getSubscribed() != null) {
foreach($sd->getSubscribed() as $s) {
if($s->name != null)
$name = $s->name;
else
$name = $s->node;
if(isset($list[$s->server.$s->node]))
$checked = 'checked';
else
$checked = '';
$switch = $this->genCallAjax(
'ajaxChangeSubscribed',
"'".$s->server."'",
"'".$s->node."'",
"this.checked",
"'".$name."'");
$listhtml .= '
<li>
<a class="action">
<div class="checkbox">
<input
type="checkbox"
id="privacy'.$s->node.'"
name="privacy'.$s->node.'"
'.$checked.'
onchange="'.$switch.'"/>
<label for="privacy'.$s->node.'"></label>
</div>
</a>
<a href="'.Route::urlize('node', array($s->server, $s->node)).'">'.
$name.'
</a>
</li>';
}
$html .= '</ul>';
return $html;
}
else return t('No public groups found');
$configlist->assign('list', $listhtml);
return $configlist->draw('_pubsubsubscriptionconfig_list', true);
//} else return t('No public groups found');
}
function onGroupRemoved($node) {
RPC::call('movim_delete', 'group'.$node);
Notification::appendNotification(t('%s has been removed from your public groups', $node), 'success');
function onGroupAdded($node) {
Notification::appendNotification(t('%s has been added to your public groups', $node), 'success');
RPC::commit();
}
function onGroupSubscribedList($list) {
$html = $this->prepareList($list);
RPC::call('movim_fill', 'listconfig', $html);
function onGroupRemoved($node) {
Notification::appendNotification(t('%s has been removed from your public groups', $node), 'success');
RPC::commit();
}
function ajaxDeleteFromGroupSubscribedList($node, $server){
$r = new moxl\PubsubSubscriptionListRemove();
$r->setNode($node)
->setTo($server)
->setFrom($this->user->getLogin())
->request();
function ajaxChangeSubscribed($server, $node, $state, $name) {
$data = array('title' => $name);
if($state) {
$r = new moxl\PubsubSubscriptionListAdd();
$r->setNode($node)
->setTo($server)
->setFrom($this->user->getLogin())
->setData($data)
->request();
} else {
$r = new moxl\PubsubSubscriptionListRemove();
$r->setNode($node)
->setTo($server)
->setFrom($this->user->getLogin())
->request();
}
}
function ajaxGetGroupSubscribedList(){
$r = new moxl\PubsubSubscriptionListGet();
$r->request();
}
function build()
{
?>
<div class="tabelem padded" title="<?php echo t('Public Groups'); ?>" id="groupsubscribedlistconfig">
<div id="listconfig">
<a
class="button icon yes color green"
onclick="<?php echo $this->genCallAjax('ajaxGetGroupSubscribedList'); ?> this.style.display = 'none';">
<?php echo t("Get your public groups");?>
</a>
</div>
</div>
<?php
}
}
?>
}

9
app/widgets/PubsubSubscriptionConfig/_pubsubsubscriptionconfig_list.tpl

@ -0,0 +1,9 @@
<ul class="list">
<li class="title">
<a class="action">
{$c->t('Shared')}
</a>
{$c->t('Name')}
</li>
{$list}
</ul>

5
app/widgets/PubsubSubscriptionConfig/pubsubsubscriptionconfig.tpl

@ -0,0 +1,5 @@
<div class="tabelem padded" title="{$c->t('Public Groups')}" id="groupsubscribedlistconfig">
<script type="text/javascript">
{$getsubscribedlist}
</script>
</div>

16
app/widgets/Vcard4/Vcard4.php

@ -33,6 +33,11 @@ class Vcard4 extends WidgetBase
'submit',
$this->genCallAjax('ajaxVcardSubmit', "movim_form_to_json('vcard4')")
);
$this->view->assign(
'privacy',
$this->genCallAjax('ajaxChangePrivacy', "this.checked")
);
// The datepicker arrays
$days = $months = $years = array();
@ -122,4 +127,15 @@ class Vcard4 extends WidgetBase
$r = new moxl\VcardSet();
$r->setData($vcard)->request();
}
function ajaxChangePrivacy($value)
{
if($value == true) {
\modl\Privacy::set($this->user->getLogin(), 1);
Notification::appendNotification(t('Your profile is now public'), 'success');
} else {
\modl\Privacy::set($this->user->getLogin(), 0);
Notification::appendNotification(t('Your profile is now restricted'), 'success');
}
}
}

59
app/widgets/Vcard4/vcard4.tpl

@ -100,19 +100,50 @@
</div>
</fieldset>
<a
onclick="
{$submit}
movim_button_save('#vcard4validate');
this.value = '{$c->t('Submitting')}';
this.className='button color orange icon loading merged right inactive';"
class="button icon merged right color green yes"
style="float: right;"
id="vcard4validate"
>{$c->t('Submit')}</a>
<a
onclick="document.querySelector('#vcard4form').reset();"
class="button icon no merged left color orange"
style="float: right;">{$c->t('Reset')}</a>
<fieldset>
<a
onclick="
{$submit}
movim_button_save('#vcard4validate');
this.value = '{$c->t('Submitting')}';
this.className='button color orange icon loading merged right inactive';"
class="button icon merged right color green yes"
style="float: right;"
id="vcard4validate"
>{$c->t('Submit')}</a>
<a
onclick="document.querySelector('#vcard4form').reset();"
class="button icon no merged left color orange"
style="float: right;">{$c->t('Reset')}</a>
</fieldset>
<fieldset>
<legend>{$c->t('Privacy Level')}</legend>
<div class="element">
<label>{$c->t('Is this profile public ?')}</label>
<div class="checkbox">
<input
type="checkbox"
id="privacy"
name="privacy"
{if="$me->privacy"}
checked
{/if}
onchange="{$privacy}"/>
<label for="privacy"></label>
</div>
</div>
<div class="element">
<div class="message info">
{$c->t('Please pay attention ! By making your profile public, all the information listed above will be available for all the Movim users and on the whole Internet.')}
</div>
</div>
<!--<div class="element">
</div>-->
</fieldset>
</form>
</div>

6
system/Route.php

@ -71,7 +71,7 @@ class Route extends \BaseController {
return false;
}
public static function urlize($page, $params = false) {
public static function urlize($page, $params = false, $tab = false) {
$r = new Route();
$routes = $r->_routes;
@ -79,6 +79,8 @@ class Route extends \BaseController {
if($params != false && count($routes[$page]) != count($params))
\system\Logs\Logger::log(t('Route error, please set all the parameters for the page %s', $page));
else {
if($tab != false)
$tab = '#'.$tab;
//We construct a classic URL if the rewriting is disabled
if(!isset($_SERVER['HTTP_MOD_REWRITE']) || !$_SERVER['HTTP_MOD_REWRITE']) {
$uri = BASE_URI.'?q='.$page;
@ -102,7 +104,7 @@ class Route extends \BaseController {
elseif($params != false)
$uri .= '/'.$params;
}
return $uri;
return $uri.$tab;
}
} else
\system\Logs\Logger::log(t('Route not set for the page %s', $page));

18
themes/movim/css/forms.css

@ -21,7 +21,7 @@ legend {
display: block;
width: 51%;
border-bottom: 1px solid rgb(220, 220, 220) !important;
line-height: 2em !important;
line-height: 3em !important;
}
@ -173,12 +173,13 @@ legend {
/* Checkbox element */
.element .checkbox > input[type="checkbox"] {
.checkbox > input[type="checkbox"] {
display: none;
}
.element .checkbox {
.checkbox {
width: 6em;
max-width: 6em;
overflow: hidden;
position: relative;
@ -186,9 +187,11 @@ legend {
height: 2em;
border-radius: 0.1em;
background-color: white;
border: 1px solid #DDD;
}
.element .checkbox:after {
.checkbox:after {
content: 'NO';
display: block;
@ -206,7 +209,7 @@ legend {
font-weight: bold;
}
.element .checkbox:before {
.checkbox:before {
content: 'YES';
display: block;
position: absolute;
@ -221,7 +224,7 @@ legend {
font-weight: bold;
}
.element .checkbox > input[type="checkbox"] + label {
.checkbox > input[type="checkbox"] + label {
display: block;
width: 3.3em;
height: 2em;
@ -239,7 +242,7 @@ legend {
background-color: white;
}
.element .checkbox > input[type="checkbox"]:checked + label {
.checkbox > input[type="checkbox"]:checked + label {
left: 2.8em;
border-right: none;
}
@ -371,4 +374,5 @@ legend {
.icon.call:before { background-image: url(../img/icons/button/call.svg); }
.icon.hang-up:before{ background-image: url(../img/icons/button/hang-up.svg); }
.icon.expand:before { background-image: url(../img/icons/button/expand.svg); }
.icon.gear:before { background-image: url(../img/icons/button/gear.svg); }
.icon.contract:before{ background-image: url(../img/icons/button/contract.svg); }

19
themes/movim/css/style.css

@ -616,19 +616,32 @@ ul.list {
ul.list li {
border-bottom: 1px solid #EEE;
clear: both;
}
ul.list li:last-child {
border-bottom: 0px;
}
ul.list li.title {
padding: 1em 0;
border-bottom: 1px solid #CCC;
margin-top: -0.5em;
}
ul.list li.title a.action {
padding: 0;
padding-right: 1em;
}
ul.list li a {
padding: 0.7em;
padding: 1em 0em;
display: block;
}
ul.list li a.action {
float: right;
padding: 0.4em;
}
ul.list li a.action:hover {
@ -644,10 +657,10 @@ ul.list li span.tag {
min-width: 3em;
border-radius: 2px;
text-align: center;
line-height: 1.8em;
line-height: 2.2em;
font-size: 0.8em;
float: right;
margin-top: -0.3em;
margin-top: -0.5em;
}
ul.list li span.tag.red { background-color: #D92727; }

6
themes/movim/img/icons/button/gear.svg

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generated by IcoMoon.io -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32" viewBox="0 0 32 32">
<path d="M29.181 19.070c-1.679-2.908-0.669-6.634 2.255-8.328l-3.145-5.447c-0.898 0.527-1.943 0.829-3.058 0.829-3.361 0-6.085-2.742-6.085-6.125h-6.289c0.008 1.044-0.252 2.103-0.811 3.070-1.679 2.908-5.411 3.897-8.339 2.211l-3.144 5.447c0.905 0.515 1.689 1.268 2.246 2.234 1.676 2.903 0.672 6.623-2.241 8.319l3.145 5.447c0.895-0.522 1.935-0.82 3.044-0.82 3.35 0 6.067 2.725 6.084 6.092h6.289c-0.003-1.034 0.259-2.080 0.811-3.038 1.676-2.903 5.399-3.894 8.325-2.219l3.145-5.447c-0.899-0.515-1.678-1.266-2.232-2.226zM16 22.479c-3.578 0-6.479-2.901-6.479-6.479 0-3.578 2.901-6.479 6.479-6.479 3.578 0 6.479 2.901 6.479 6.479-0 3.578-2.901 6.479-6.479 6.479z" fill="#ffffff" />
</svg>
Loading…
Cancel
Save