10 changed files with 97 additions and 77 deletions
-
1app/views/community.tpl
-
35app/widgets/Communities/Communities.php
-
35app/widgets/Communities/_communities.tpl
-
2app/widgets/CommunitiesDiscover/communitiesdiscover.tpl
-
55app/widgets/CommunitiesServers/CommunitiesServers.php
-
30app/widgets/CommunitiesServers/_communitiesservers.tpl
-
3app/widgets/CommunitiesServers/communitiesservers.js
-
1app/widgets/CommunitiesServers/communitiesservers.tpl
-
4src/Movim/Bootstrap.php
-
8themes/material/css/block.css
@ -1,4 +1,4 @@ |
|||||
<div id="communitiesdiscover" class="tabelem" title="{$c->__('button.discover')}"> |
|
||||
|
<div id="communities_discover" class="tabelem" title="{$c->__('button.discover')}"> |
||||
<ul class="list active middle card flex third"> |
<ul class="list active middle card flex third"> |
||||
{$posts} |
{$posts} |
||||
</ul> |
</ul> |
||||
|
|||||
@ -0,0 +1,55 @@ |
|||||
|
<?php |
||||
|
|
||||
|
use Moxl\Xec\Action\Disco\Items; |
||||
|
use Respect\Validation\Validator; |
||||
|
|
||||
|
class CommunitiesServers extends \Movim\Widget\Base |
||||
|
{ |
||||
|
public function load() |
||||
|
{ |
||||
|
$this->registerEvent('disco_items_handle', 'onDisco', 'community'); |
||||
|
$this->addjs('communitiesservers.js'); |
||||
|
} |
||||
|
|
||||
|
function onDisco($packet) |
||||
|
{ |
||||
|
$this->ajaxGet(); |
||||
|
} |
||||
|
|
||||
|
function ajaxDisco($origin) |
||||
|
{ |
||||
|
if(!$this->validateServer($origin)) { |
||||
|
Notification::append(null, $this->__('communities.disco_error')); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
$r = new Items; |
||||
|
$r->setTo($origin)->request(); |
||||
|
} |
||||
|
|
||||
|
function ajaxGet() |
||||
|
{ |
||||
|
$this->rpc('MovimTpl.fill', '#communities_servers', $this->prepareCommunities()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @brief Validate the server |
||||
|
* |
||||
|
* @param string $origin |
||||
|
*/ |
||||
|
private function validateServer($origin) |
||||
|
{ |
||||
|
$validate_server = Validator::noWhitespace()->alnum('.-_')->length(6, 40); |
||||
|
return ($validate_server->validate($origin)); |
||||
|
} |
||||
|
|
||||
|
function prepareCommunities() |
||||
|
{ |
||||
|
$id = new \Modl\InfoDAO; |
||||
|
|
||||
|
$view = $this->tpl(); |
||||
|
$view->assign('servers', $id->getGroupServers()); |
||||
|
|
||||
|
return $view->draw('_communitiesservers', true); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
<ul class="list flex third middle active"> |
||||
|
{loop="$servers"} |
||||
|
{if="!filter_var($value->server, FILTER_VALIDATE_EMAIL)"} |
||||
|
<li class="block |
||||
|
{if="empty($value->number)"}faded{/if}" |
||||
|
onclick="MovimUtils.redirect('{$c->route('community', $value->server)}')"> |
||||
|
<span class="primary icon bubble color {$value->server|stringToColor}"> |
||||
|
{$value->server|firstLetterCapitalize} |
||||
|
</span> |
||||
|
<p class="line" title="{$value->server} - {$value->name}"> |
||||
|
{$value->server} |
||||
|
<span class="second">{$value->name}</span> |
||||
|
</p> |
||||
|
<p>{$c->__('communities.counter', (empty($value->number)) ? 0 : $value->number)}</p> |
||||
|
</li> |
||||
|
{/if} |
||||
|
{/loop} |
||||
|
<li class="block large"> |
||||
|
<span class="primary icon"> |
||||
|
<i class="zmdi zmdi-search-for"></i> |
||||
|
</span> |
||||
|
<form> |
||||
|
<div> |
||||
|
<input placeholder="pubsub.server.com" onkeypress=" |
||||
|
if(event.keyCode == 13) { CommunitiesServers_ajaxDisco(this.value); return false; }" > |
||||
|
<label>{$c->__('communities.search_server')}</label> |
||||
|
</div> |
||||
|
</form> |
||||
|
</li> |
||||
|
</ul> |
||||
@ -0,0 +1,3 @@ |
|||||
|
MovimWebsocket.attach(function() { |
||||
|
CommunitiesServers_ajaxGet(); |
||||
|
}); |
||||
@ -0,0 +1 @@ |
|||||
|
<div id="communities_servers" class="tabelem" title="{$c->__('communities.servers')}"></div> |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue