The SSH host key has changed on 8 April, 2022 to this one: SHA256:573uTBSeh74kvOo0HJXi5ijdzRm8me27suzNEDlGyrQ

Added the UserDataSpan Twig extension

This Twig extension can filter User entities, creating a HTML <span>
element from them with the class userdata, which can later be converted
to an AJAX tooltip with jquery.cluetip

Signed-off-by: Gergely Polonkai <polesz@w00d5t0ck.info>
master
Polonkai Gergely 10 years ago
parent fe41e755f7
commit ac6467f649
  1. 2
      src/KekRozsak/AdminBundle/Resources/views/Default/groupJoinRequests.html.twig
  2. 2
      src/KekRozsak/AdminBundle/Resources/views/Default/manageRegs.html.twig
  3. 2
      src/KekRozsak/FrontBundle/Resources/views/Article/view.html.twig
  4. 2
      src/KekRozsak/FrontBundle/Resources/views/Document/view.html.twig
  5. 4
      src/KekRozsak/FrontBundle/Resources/views/Event/view.html.twig
  6. 2
      src/KekRozsak/FrontBundle/Resources/views/Forum/postList.html.twig
  7. 2
      src/KekRozsak/FrontBundle/Resources/views/Forum/topicGroupList.html.twig
  8. 2
      src/KekRozsak/FrontBundle/Resources/views/Forum/topicList.html.twig
  9. 2
      src/KekRozsak/FrontBundle/Resources/views/Group/documents.html.twig
  10. 4
      src/KekRozsak/FrontBundle/Resources/views/Group/join.html.twig
  11. 2
      src/KekRozsak/FrontBundle/Resources/views/Group/list.html.twig
  12. 2
      src/KekRozsak/FrontBundle/Resources/views/Group/members.html.twig
  13. 15
      src/KekRozsak/SecurityBundle/Controller/DefaultController.php
  14. 5
      src/KekRozsak/SecurityBundle/Resources/config/services.xml
  15. 10
      src/KekRozsak/SecurityBundle/Resources/views/Default/ajaxUserdata.html.twig
  16. 41
      src/KekRozsak/SecurityBundle/Twig/UserDataSpanExtension.php

@ -21,7 +21,7 @@
{% for request in group.members %}
{% if not group.isMember(request.user) %}
<tr>
<td colspan="2">{{ request.user.displayName }}</td>
<td colspan="2">{{ request.user|userdataspan }}</td>
<td>
<form method="post" action="{{ path('KekRozsakAdminBundle_groupJoinRequests') }}">
<input type="hidden" name="user" value="{{ request.user.id }}" />

@ -19,7 +19,7 @@
<tr>
<td>{{ user.username }}</td>
<td>{{ user.email }}</td>
<td>{{ user.displayName }}</td>
<td>{{ user|userdataspan }}</td>
<td>{{ user.registeredAt|date('Y-m-d H:i') }}</td>
<td>
<form method="post" action="">

@ -8,6 +8,6 @@
<p class="forras">Forrás: {{ article.source }}</p>
{% endif %}
{% if app.user %}
<p class="szerzo">{{ article.createdBy.displayName }}</p>
<p class="szerzo">{{ article.createdBy|userdataspan }}</p>
{% endif %}
{% endblock content %}

@ -7,5 +7,5 @@
{{ document.title }}{% if document.createdBy == app.user %} [ <a href="{{ path('KekRozsakFrontBundle_documentEdit', {slug: document.slug}) }}">Szerkesztés</a> ] {% endif %}
</h3>
{{ document.content|raw }}
<div class="szerzo">{{ document.createdBy.displayName }}</div>
<div class="szerzo">{{ document.createdBy|userdataspan }}</div>
{% endblock content %}

@ -5,14 +5,14 @@
{% block content %}
<h3>Esemény - {{ event.title }}</h3>
<p class="esemeny-idopont">{{ event.startDate|date('Y-m-d') }} {{ event.startTime|date('H:i') }}{% if event.endDate or event.endTime %} - {% endif %}{% if event.endDate is not null %} {{ event.endDate|date('Y-m-d') }}{% endif %}{% if event.endTime is not null %} {{ event.endTime|date('H:i') }}{% endif %}</p>
<p class="esemeny-szervezo">Az eseményt szervezi: {{ event.createdBy.displayName }}</p>
<p class="esemeny-szervezo">Az eseményt szervezi: {{ event.createdBy|userdataspan }}</p>
<p>
{{ event.description }}
</p>
<h4>Eddigi résztvevők</h4>
<ul>
{% for attendee in event.attendees %}
<li>{{ attendee.displayName }}</li>
<li>{{ attendee|userdataspan }}</li>
{% endfor %}
</ul>
{% if not event.isAttending(app.user) %}

@ -33,7 +33,7 @@
{{ post.createdAt|date('Y-m-d') }}<br />
{{ post.createdAt|date('H:i') }}<br />
[avatar]<br />
{{ post.createdBy.displayName }}<br />
{{ post.createdBy|userdataspan }}<br />
Szint<br />
<br />
Tagság kezdete:<br />

@ -22,7 +22,7 @@
<td></td>
<td>
{% if topic.lastPost %}
{{ topic.lastPost.createdBy.displayName }}<br />
{{ topic.lastPost.createdBy|userdataspan }}<br />
{{ topic.lastPost.createdAt|date('Y-m-d H:i') }}
{% else %}
&nbsp;<br />&nbsp;

@ -20,7 +20,7 @@
<td></td>
<td>
{% if topic.lastPost %}
{{ topic.lastPost.createdBy.displayName }}<br />
{{ topic.lastPost.createdBy|userdataspan }}<br />
{{ topic.lastPost.createdAt|date('Y-m-d H:i') }}
{% else %}
&nbsp;<br />&nbsp;

@ -23,7 +23,7 @@
<td>[ikon]</td>
<td><a href="{{ path('KekRozsakFrontBundle_documentView', {slug: document.slug}) }}">{{ document.title }}</a></td>
<td>
{{ document.createdBy.displayName }}<br />
{{ document.createdBy|userdataspan }}<br />
{{ document.createdAt|date('Y-m-d H:i') }}
</td>
</tr>

@ -5,9 +5,9 @@
{% block content %}
<h3>Jelentkezés</h3>
{% if isRequested %}
Már jelentkeztél ebbe a csoportba ({{ group.name }}), de {{ group.leader.displayName }} még nem hagyta jóvá a belépésedet.
Már jelentkeztél ebbe a csoportba ({{ group.name }}), de {{ group.leader|userdataspan }} még nem hagyta jóvá a belépésedet.
{% endif %}
{% if needApproval %}
A csoportba való jelentkezésedről a csoport vezetőjét ({{ group.leader.displayName }}) értesítettük.
A csoportba való jelentkezésedről a csoport vezetőjét ({{ group.leader|userdataspan }}) értesítettük.
{% endif %}
{% endblock content %}

@ -34,7 +34,7 @@
{% endif %}
{% endif %}
</td>
<td>{% if group.leader %}{{ group.leader.displayName }}{% else %}Nincs{% endif %}</td>
<td>{% if group.leader %}{{ group.leader|userdataspan }}{% else %}Nincs{% endif %}</td>
</tr>
{% endfor %}
</tbody>

@ -14,7 +14,7 @@
<ul>
{% for user in group.members %}
{% if group.isMember(user.user) %}
<li>{{ user.user.displayName }}</li>
<li>{{ user.user|userdataspan }}</li>
{% endif %}
{% endfor %}
</ul>

@ -4,7 +4,9 @@ namespace KekRozsak\SecurityBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\Security\Core\SecurityContext;
use Symfony\Component\Security\Core\User\UserInterface;
@ -121,4 +123,17 @@ class DefaultController extends Controller
return array(
);
}
/**
* @Route("/profil/{id}/ajax-felhasznalo-info.{_format}", name="KekRozsakSecurityBundle_ajaxUserdata", requirements={"_format": "html"})
* @Method({"GET"})
* @Template()
* @ParamConverter("user")
*/
public function ajaxUserdataAction(User $user)
{
return array(
'user' => $user,
);
}
}

@ -8,5 +8,10 @@
<argument type="service" id="doctrine" />
<tag name="kernel.event_listener" event="security.authentication.success" />
</service>
<service id="kek_rozsak_security.twig_extension.userdataspan" class="KekRozsak\SecurityBundle\Twig\UserDataSpanExtension">
<argument type="service" id="service_container" />
<argument type="service" id="security.context" />
<tag name="twig.extension" />
</service>
</services>
</container>

@ -0,0 +1,10 @@
{# vim: ft=htmljinja
#}
<html>
<head>
<title>{{ user.displayName }}</title>
</head>
<body>
Tagság kezdete: {{ user.registeredAt|date('Y-m-d') }}
</body>
</html>

@ -0,0 +1,41 @@
<?php
namespace KekRozsak\SecurityBundle\Twig;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use KekRozsak\SecurityBundle\Entity\User;
class UserDataSpanExtension extends \Twig_Extension
{
protected $_securityContext;
protected $_serviceContainer;
public function __construct(ContainerInterface $container, SecurityContextInterface $security)
{
$this->_serviceContainer = $container;
$this->_securityContext = $security;
}
public function getFilters()
{
return array(
'userdataspan' => new \Twig_Filter_Method($this, 'getUserDataSpan', array('is_safe' => array('html'))),
);
}
public function getUserDataSpan(User $user)
{
if (!is_object($this->_securityContext->getToken()) || !is_object($this->_securityContext->getToken()->getUser()))
return '<span class="userdata-secret" title="|Felhasználó|A felhasználóink kiléte szigorúan bizalmas, csak a tagok számára elérhető.">[nem jelenhet meg]</span>';
return '<span class="userdata" rel="' . $this->_serviceContainer->get('router')->generate('KekRozsakSecurityBundle_ajaxUserdata', array('id' => $user->getId(), '_format' => 'html')) . '">' . $user->getDisplayName() . '</span>';
}
public function getName()
{
return 'twig_userdataspan';
}
}
Loading…
Cancel
Save