You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.1 KiB

  1. <?php
  2. use Respect\Validation\Validator;
  3. class CommunityHeader extends \Movim\Widget\Base
  4. {
  5. public function load()
  6. {
  7. $this->registerEvent('pubsub_getmetadata_handle', 'onMetadata');
  8. }
  9. function onMetadata($packet)
  10. {
  11. list($server, $node) = $packet->content;
  12. RPC::call('MovimTpl.fill', '#community_header', $this->prepareHeader($server, $node));
  13. }
  14. public function prepareHeader($server, $node)
  15. {
  16. $id = new \Modl\ItemDAO;
  17. $item = $id->getItem($server, $node);
  18. if($item && !$item->logo) {
  19. $item->setPicture();
  20. $id->set($item);
  21. }
  22. $pd = new \Modl\SubscriptionDAO;
  23. $subscription = $pd->get($server, $node);
  24. $view = $this->tpl();
  25. $view->assign('item', $item);
  26. $view->assign('subscription', $subscription);
  27. $view->assign('node', $node);
  28. $view->assign('server', $server);
  29. return $view->draw('_communityheader', true);
  30. }
  31. public function display()
  32. {
  33. $this->view->assign('server', $this->get('s'));
  34. $this->view->assign('node', $this->get('n'));
  35. }
  36. }