From 33163f02adc06c522e4832f8af345c8b9a080c0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaussoin=20Timoth=C3=A9e?= Date: Thu, 12 Dec 2013 23:52:49 +0100 Subject: [PATCH] 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 --- app/models/subscription/Subscription.php | 2 - app/views/conf.tpl | 2 - app/views/nodeconfig.tpl | 1 - app/widgets/Avatar/avatar.tpl | 1 + app/widgets/Bookmark/Bookmark.php | 2 + app/widgets/Bookmark/bookmark.tpl | 4 + app/widgets/Config/config.tpl | 1 - app/widgets/ContactCard/ContactCard.php | 4 +- .../ContactPubsubSubscription.php | 25 ++-- .../contactpubsubsubscription.js | 5 + app/widgets/Location/Location.php | 22 +-- app/widgets/Location/location.js | 2 +- .../PubsubSubscriptionConfig.php | 126 ++++++++++++------ .../_pubsubsubscriptionconfig_list.tpl | 9 ++ .../pubsubsubscriptionconfig.tpl | 5 + app/widgets/Vcard4/Vcard4.php | 16 +++ app/widgets/Vcard4/vcard4.tpl | 59 ++++++-- system/Route.php | 6 +- themes/movim/css/forms.css | 18 ++- themes/movim/css/style.css | 19 ++- themes/movim/img/icons/button/gear.svg | 6 + 21 files changed, 234 insertions(+), 101 deletions(-) create mode 100644 app/widgets/ContactPubsubSubscription/contactpubsubsubscription.js create mode 100644 app/widgets/PubsubSubscriptionConfig/_pubsubsubscriptionconfig_list.tpl create mode 100644 app/widgets/PubsubSubscriptionConfig/pubsubsubscriptionconfig.tpl create mode 100644 themes/movim/img/icons/button/gear.svg diff --git a/app/models/subscription/Subscription.php b/app/models/subscription/Subscription.php index 8d70f39d2..2890adda3 100644 --- a/app/models/subscription/Subscription.php +++ b/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; diff --git a/app/views/conf.tpl b/app/views/conf.tpl index f7c89868f..f9d558f12 100644 --- a/app/views/conf.tpl +++ b/app/views/conf.tpl @@ -14,8 +14,6 @@ widget('Tabs');?>
-
" class="protect white">
- widget('Config');?> widget('ConfigData');?> widget('PubsubSubscriptionConfig');?> diff --git a/app/views/nodeconfig.tpl b/app/views/nodeconfig.tpl index 7c5e476b3..d36b688d7 100644 --- a/app/views/nodeconfig.tpl +++ b/app/views/nodeconfig.tpl @@ -15,7 +15,6 @@ widget('Profile');?> widget('Bookmark');?> widget('Notifs');?> - widget('Location');?>
widget('Tabs');?> diff --git a/app/widgets/Avatar/avatar.tpl b/app/widgets/Avatar/avatar.tpl index f49c7ff9d..0d7503b62 100644 --- a/app/widgets/Avatar/avatar.tpl +++ b/app/widgets/Avatar/avatar.tpl @@ -1,4 +1,5 @@
+
{$c->t('Avatar')} diff --git a/app/widgets/Bookmark/Bookmark.php b/app/widgets/Bookmark/Bookmark.php index f09a8561e..c3b031bfe 100644 --- a/app/widgets/Bookmark/Bookmark.php +++ b/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", "''")); diff --git a/app/widgets/Bookmark/bookmark.tpl b/app/widgets/Bookmark/bookmark.tpl index 10ae2f983..7a11b7d91 100644 --- a/app/widgets/Bookmark/bookmark.tpl +++ b/app/widgets/Bookmark/bookmark.tpl @@ -10,6 +10,10 @@ {$preparebookmark}

+ + {$c->t('Feed Configuration')} -
{$c->t('General')} diff --git a/app/widgets/ContactCard/ContactCard.php b/app/widgets/ContactCard/ContactCard.php index 12a5239f4..2710180f6 100644 --- a/app/widgets/ContactCard/ContactCard.php +++ b/app/widgets/ContactCard/ContactCard.php @@ -41,8 +41,8 @@ class ContactCard extends WidgetCommon $html = ''; $html .= ' -
-

'.t('Profile').'


+ +

'.t('Profile').'

'.t('General Informations').''; diff --git a/app/widgets/ContactPubsubSubscription/ContactPubsubSubscription.php b/app/widgets/ContactPubsubSubscription/ContactPubsubSubscription.php index 700074da3..aa69aa0b3 100644 --- a/app/widgets/ContactPubsubSubscription/ContactPubsubSubscription.php +++ b/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 = '
    '; foreach($list as $item){ @@ -37,9 +38,9 @@ class ContactPubsubSubscription extends WidgetBase $html .= '
'; 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() { ?> -
-
- this.style.display = 'none'"> - - -
+
+
+

+ +
-
'.$data.'
+
'.$data.'
+ style="display: none; margin-top: 1em; float: right;" + class="button color green icon yes merged left" + onclick="'.$submit.' hidePositionChoice();">'.t('Accept').'
'; return $html; @@ -119,7 +114,14 @@ class Location extends WidgetBase { ?>
- prepareProfileData(); ?> +
+ +
+ +
+ prepareProfileData(); ?> +
+
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 = '
    '; - foreach($list as $item){ - $delete = $this->genCallAjax('ajaxDeleteFromGroupSubscribedList', "'".$item[0]."'", "'".$item[1]."'"); - $html .= ' -
  • - '.t('Delete').' - '.$item[2].' + 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 .= ' +
  • + +
    + + +
    +
    + '. + $name.' +
  • '; } - $html .= '
'; - 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() - { - ?> -
-
- - - -
-
- +} diff --git a/app/widgets/PubsubSubscriptionConfig/_pubsubsubscriptionconfig_list.tpl b/app/widgets/PubsubSubscriptionConfig/_pubsubsubscriptionconfig_list.tpl new file mode 100644 index 000000000..4c2496dd8 --- /dev/null +++ b/app/widgets/PubsubSubscriptionConfig/_pubsubsubscriptionconfig_list.tpl @@ -0,0 +1,9 @@ + diff --git a/app/widgets/PubsubSubscriptionConfig/pubsubsubscriptionconfig.tpl b/app/widgets/PubsubSubscriptionConfig/pubsubsubscriptionconfig.tpl new file mode 100644 index 000000000..fb15f2385 --- /dev/null +++ b/app/widgets/PubsubSubscriptionConfig/pubsubsubscriptionconfig.tpl @@ -0,0 +1,5 @@ +
+ +
diff --git a/app/widgets/Vcard4/Vcard4.php b/app/widgets/Vcard4/Vcard4.php index 46daeb9c1..177e88aea 100644 --- a/app/widgets/Vcard4/Vcard4.php +++ b/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'); + } + } } diff --git a/app/widgets/Vcard4/vcard4.tpl b/app/widgets/Vcard4/vcard4.tpl index d196e317a..678b22e45 100644 --- a/app/widgets/Vcard4/vcard4.tpl +++ b/app/widgets/Vcard4/vcard4.tpl @@ -100,19 +100,50 @@
- {$c->t('Submit')} - {$c->t('Reset')} + +
+ {$c->t('Submit')} + {$c->t('Reset')} +
+ +
+ {$c->t('Privacy Level')} +
+ +
+ + +
+
+
+
+ {$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.')} +
+
+ +
diff --git a/system/Route.php b/system/Route.php index a198685d4..ba4bcdbfb 100644 --- a/system/Route.php +++ b/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)); diff --git a/themes/movim/css/forms.css b/themes/movim/css/forms.css index 2d487d881..4f0772b1d 100644 --- a/themes/movim/css/forms.css +++ b/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); } diff --git a/themes/movim/css/style.css b/themes/movim/css/style.css index 4a5376500..226f96c93 100644 --- a/themes/movim/css/style.css +++ b/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; } diff --git a/themes/movim/img/icons/button/gear.svg b/themes/movim/img/icons/button/gear.svg new file mode 100644 index 000000000..a3b28fc68 --- /dev/null +++ b/themes/movim/img/icons/button/gear.svg @@ -0,0 +1,6 @@ + + + + + +