Browse Source

Display the full path when displaying a Post in News + fix the routes

pull/238/head
Timothée Jaussoin 9 years ago
parent
commit
50c080d07f
  1. 6
      app/controllers/NewsController.php
  2. 22
      app/models/postn/Postn.php
  3. 46
      app/models/postn/PostnDAO.php
  4. 8
      app/widgets/Group/Group.php
  5. 2
      app/widgets/Group/_group_posts.tpl
  6. 2
      app/widgets/Group/group.js
  7. 4
      app/widgets/Menu/menu.js
  8. 6
      app/widgets/Post/Post.php
  9. 6
      app/widgets/Post/_post.tpl
  10. 6
      app/widgets/Post/post.js
  11. 10
      app/widgets/Publish/Publish.php
  12. 32
      system/Route.php

6
app/controllers/NewsController.php

@ -13,7 +13,11 @@ class NewsController extends Base
$user = new User();
if(!$user->isLogged()) {
$pd = new \Modl\PostnDAO;
$p = $pd->getItem($this->fetchGet('n'));
$p = $pd->get(
$this->fetchGet('s'),
$this->fetchGet('n'),
$this->fetchGet('i')
);
if($p) {
if($p->isMicroblog()) {

22
app/models/postn/Postn.php

@ -428,6 +428,15 @@ class Postn extends Model {
return $p->get($this->origin.$this->node, 120);
}
public function getUUID()
{
if(substr($this->nodeid, 10) == 'urn:uuid:') {
return $this->nodeid;
} else {
return 'urn:uuid:'.generateUUID($this->nodeid);
}
}
public function isMine()
{
$user = new \User();
@ -436,13 +445,8 @@ class Postn extends Model {
|| $this->origin == $user->getLogin());
}
public function getUUID()
{
if(substr($this->nodeid, 10) == 'urn:uuid:') {
return $this->nodeid;
} else {
return 'urn:uuid:'.generateUUID($this->nodeid);
}
public function isPublic() {
return ($this->open);
}
public function isMicroblog()
@ -487,10 +491,6 @@ class Postn extends Model {
return implode(', ', $tags);
}
}
public function isPublic() {
return ($this->open);
}
}
class ContactPostn extends Postn {

46
app/models/postn/PostnDAO.php

@ -172,6 +172,29 @@ class PostnDAO extends SQL {
}
}
function get($origin, $node, $nodeid) {
$this->_sql = '
select *, postn.aid from postn
left outer join contact on postn.aid = contact.jid
left outer join item
on postn.origin = item.server
and postn.node = item.node
where postn.origin = :origin
and postn.node = :node
and postn.nodeid = :nodeid';
$this->prepare(
'Postn',
[
'origin' => $origin,
'node' => $node,
'nodeid' => $nodeid,
]
);
return $this->run('ContactPostn', 'item');
}
function delete($nodeid) {
$this->_sql = '
delete from postn
@ -321,25 +344,6 @@ class PostnDAO extends SQL {
return $this->run('Postn', 'item');
}
function getItem($id) {
$this->_sql = '
select *, postn.aid from postn
left outer join contact on postn.aid = contact.jid
left outer join item
on postn.origin = item.server
and postn.node = item.node
where postn.nodeid = :nodeid';
$this->prepare(
'Postn',
array(
'nodeid' => $id
)
);
return $this->run('ContactPostn', 'item');
}
function getAllPosts($jid = false, $limitf = false, $limitr = false) {
$this->_sql = '
select *, postn.aid from postn
@ -474,11 +478,11 @@ class PostnDAO extends SQL {
$this->prepare(
'Postn',
array(
[
'origin' => $origin,
'node' => $node,
'nodeid' => $nodeid,
)
]
);
return $this->run('ContactPostn');

8
app/widgets/Group/Group.php

@ -303,8 +303,8 @@ class Group extends \Movim\Widget\Base
$view->assign('server', $server);
$view->assign('node', $node);
$pd = new \Modl\ItemDAO;
$item = $pd->getItem($server, $node);
$id = new \Modl\ItemDAO;
$item = $id->getItem($server, $node);
if(isset($item)) {
$view->assign('item', $item);
@ -336,8 +336,8 @@ class Group extends \Movim\Widget\Base
$view->assign('server', $server);
$view->assign('node', $node);
$pd = new \Modl\ItemDAO;
$item = $pd->getItem($server, $node);
$id = new \Modl\ItemDAO;
$item = $id->getItem($server, $node);
if(isset($item)) {
$view->assign('item', $item);

2
app/widgets/Group/_group_posts.tpl

@ -12,7 +12,7 @@
<ul class="list card active flex shadow">
{loop="$posts"}
<li class="block" onclick="MovimUtils.redirect('{$c->route('news', $value->nodeid)}')">
<li class="block" onclick="MovimUtils.redirect('{$c->route('news', [$value->origin, $value->node, $value->nodeid])}')">
{$picture = $value->getPicture()}
{if="$picture != null"}
<span class="icon top" style="background-image: url({$picture});"></span>

2
app/widgets/Group/group.js

@ -12,7 +12,7 @@ var Group = {
MovimWebsocket.attach(function() {
var parts = MovimUtils.urlParts();
if(parts.params.length) {
if(parts.params.length > 0) {
Group_ajaxGetItems(parts.params[0], parts.params[1]);
}
});

4
app/widgets/Menu/menu.js

@ -9,7 +9,7 @@ var Menu = {
items[i].onclick = function(e) {
if(this.dataset.id) {
MovimTpl.showPanel();
Post_ajaxGetPost(this.dataset.id);
Post_ajaxGetPost(this.dataset.server, this.dataset.node, this.dataset.id);
//Menu_ajaxGetNode(this.dataset.server, this.dataset.node);
MovimUtils.removeClassInList('active', items);
MovimUtils.addClass(this, 'active');
@ -25,4 +25,4 @@ MovimWebsocket.attach(function() {
Notification_ajaxClear('news');
Notification.current('news');
Menu.refresh();
});
});

6
app/widgets/Post/Post.php

@ -92,10 +92,10 @@ class Post extends \Movim\Widget\Base
$c->ajaxGetDrawer($jid);
}
function ajaxGetPost($id)
function ajaxGetPost($origin, $node, $id)
{
$pd = new \Modl\PostnDAO;
$p = $pd->getItem($id);
$p = $pd->get($origin, $node, $id);
$gi = new GetItem;
$gi->setTo($p->origin)
@ -105,7 +105,7 @@ class Post extends \Movim\Widget\Base
$html = $this->preparePost($p);
RPC::call('MovimUtils.pushState', $this->route('news', $id));
RPC::call('MovimUtils.pushState', $this->route('news', [$p->origin, $p->node, $p->nodeid]));
RPC::call('MovimTpl.fill', '#post_widget', $html);
RPC::call('MovimUtils.enableVideos');

6
app/widgets/Post/_post.tpl

@ -85,12 +85,12 @@
<p {if="$post->title != null"}title="{$post->title|strip_tags}"{/if}>
<a {if="$public"}
{if="$post->isMicroblog()"}
href="{$c->route('blog', array($post->origin, $post->nodeid))}"
href="{$c->route('blog', [$post->origin, $post->nodeid])}"
{else}
href="{$c->route('node', array($post->origin, $post->node, $post->nodeid))}"
href="{$c->route('node', [$post->origin, $post->node, $post->nodeid])}"
{/if}
{else}
href="{$c->route('news', $post->nodeid)}"
href="{$c->route('news', [$post->origin, $post->node, $post->nodeid])}"
{/if}
>
{if="$post->title != null"}

6
app/widgets/Post/post.js

@ -1,8 +1,8 @@
MovimWebsocket.attach(function() {
var nodeid = MovimUtils.urlParts().params[0];
if(nodeid) {
var parts = MovimUtils.urlParts();
if(parts.params.length) {
document.querySelector('#post_widget').innerHTML = '';
Post_ajaxGetPost(nodeid);
Post_ajaxGetPost(parts.params[0], parts.params[1], parts.params[2]);
MovimTpl.showPanel();
}
});

10
app/widgets/Publish/Publish.php

@ -53,7 +53,7 @@ class Publish extends \Movim\Widget\Base
if($id) {
$pd = new \modl\PostnDAO();
$p = $pd->getItem($id);
$p = $pd->get($server, $node, $id);
if($p->isEditable()) {
$post = $p;
}
@ -144,6 +144,11 @@ class Publish extends \Movim\Widget\Base
->request();
}
function ajaxRepost($server, $node, $id)
{
if(!$this->validateServerNode($server, $node)) return;
}
function ajaxPublish($form)
{
RPC::call('Publish.disableSend');
@ -155,7 +160,6 @@ class Publish extends \Movim\Widget\Base
->setTitle(htmlspecialchars($form->title->value))
->setNode($form->node->value);
//->setLocation($geo)
//->enableComments()
// Still usefull ? Check line 44
if($form->node->value == 'urn:xmpp:microblog:0') {
@ -173,7 +177,7 @@ class Publish extends \Movim\Widget\Base
$p->setId($form->id->value);
$pd = new \modl\PostnDAO();
$post = $pd->getItem($form->id->value);
$post = $pd->get($form->to->value, $form->node->value, $form->id->value);
if(isset($post)) {
$p->setPublished(strtotime($post->published));

32
system/Route.php

@ -6,29 +6,29 @@ class Route extends Base {
private $_page;
public function __construct() {
$this->_routes = array(
'about' => array('x'),
$this->_routes = [
'about' => ['x'],
'account' => false,
'accountnext' => array('s', 'err'),
'accountnext' => ['s', 'err'],
'admin' => false,
'blog' => array('f', 'i'),
'tag' => array('t', 'i'),
'chat' => array('f'),
'blog' => ['f', 'i'],
'tag' => ['t', 'i'],
'chat' => ['f'],
'conf' => false,
'contact' => array('f'),
'disconnect' => array('err'),
'feed' => array('s', 'n'),
'contact' => ['f'],
'disconnect' => ['err'],
'feed' => ['s', 'n'],
'main' => false,
'node' => array('s', 'n', 'i'),
'group' => array('s', 'n', 'i'),
'node' => ['s', 'n', 'i'],
'group' => ['s', 'n', 'i'],
'help' => false,
'infos' => false,
'login' => array('err'),
'news' => array('n'),
'room' => array('r'),
'share' => array('url'),
'login' => ['err'],
'news' => ['s', 'n', 'i'],
'room' => ['r'],
'share' => ['url'],
'visio' => false
);
];
}
public function find() {

Loading…
Cancel
Save