Added Help button functionality.

Signed-off-by: Gergely POLONKAI <polesz@w00d5t0ck.info>
This commit is contained in:
Gergely POLONKAI 2012-08-17 18:22:13 +02:00
parent aed588e5e2
commit 528c373ad9
6 changed files with 101 additions and 1 deletions

View File

@ -28,6 +28,15 @@ class BookController extends Controller
); );
} }
/**
* @Route("/sugo/konyvtar-lista.html", name="KekRozsakFrontBundle_bookListHelp")
* @Template()
*/
public function listHelpAction()
{
return array();
}
/** /**
* @Route("/konyvadat/{id}/ajax.{_format}", name="KekRozsakFrontBundle_bookAjaxData", defaults={"_format": "html"}, options={"expose": true}) * @Route("/konyvadat/{id}/ajax.{_format}", name="KekRozsakFrontBundle_bookAjaxData", defaults={"_format": "html"}, options={"expose": true})
* @Template() * @Template()

View File

@ -92,3 +92,8 @@ h3 a {
clear: both; clear: both;
float: none; float: none;
} }
#help-button {
display: block;
float: right;
}

View File

@ -25,7 +25,7 @@ function doPopup(title, content, url, w, h, callback)
} }
}).error(function() }).error(function()
{ {
$('#popup-content').html('Nem sikerült betölteni a könyv adatait.'); $('#popup-content').html('Szerver-oldali hiba!');
}); });
} }
@ -102,4 +102,12 @@ $(document).ready(function() {
$('#news-button').show(); $('#news-button').show();
resizeBoxes(); resizeBoxes();
}); });
$('#help-button a').click(function()
{
helpUrl = $(this).attr('href');
doPopup('Súgó', null, helpUrl, 400, 300, null);
return false;
})
}); });

View File

@ -0,0 +1,5 @@
<p>
A könyvek részletes adatait a szerzőre, címre vagy a kiadás évére kattintva
tudhatod meg. Az ekkor felbukkanó ablakban tudod bejelölni, ha neked is van
egy példányod, vagy ha pl. szeretnél kölcsönkérni egyet.
<p>

View File

@ -56,6 +56,7 @@
</div> </div>
<div id="wrapper"> <div id="wrapper">
<div id="menu"> <div id="menu">
{# TODO: Dynamically generate menu #}
<ul> <ul>
<li><a href="{{ path('KekRozsakFrontBundle_homepage') }}">Főoldal - Aktuális</a></li> <li><a href="{{ path('KekRozsakFrontBundle_homepage') }}">Főoldal - Aktuális</a></li>
<li><a href="{{ path('KekRozsakFrontBundle_articleView', { slug: 'rolunk' }) }}">Rólunk</a></li> <li><a href="{{ path('KekRozsakFrontBundle_articleView', { slug: 'rolunk' }) }}">Rólunk</a></li>
@ -75,6 +76,9 @@
<div id="content-wrapper"> <div id="content-wrapper">
<div id="content-outline"> <div id="content-outline">
<div id="content"> <div id="content">
{% if helpUrl is not null %}
<span id="help-button"><a href="{{ helpUrl }}">[Súgó]</a></span><br class="clear" />
{% endif %}
{% block content %}{% endblock %} {% block content %}{% endblock %}
</div> </div>
</div> </div>

View File

@ -0,0 +1,69 @@
<?php
namespace KekRozsak\FrontBundle\Twig;
use JMS\DiExtraBundle\Annotation as DI;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
/**
* Description of HelpUrlExtension
*
* @author Gergely Polonkai
*
* @DI\Service
* @DI\Tag("twig.extension")
*/
class HelpUrlExtension extends \Twig_Extension
{
/**
* @var Symfony\Component\DependencyInjection\ContainerInterface $container
*/
private $container;
/**
* @DI\InjectParams({
* "container" = @DI\Inject("service_container")
* })
*/
public function __construct(ContainerInterface $container) {
$this->container = $container;
}
public function getGlobals() {
parent::getGlobals();
$request = $this->container->get('request');
$router = $this->container->get('router');
$currentRoute = $request->get('_route');
$m = array();
$helpRoutes = array($currentRoute . 'Help');
$helpUrl = null;
if (preg_match('/^([^_]+)_([a-z]+)/', $currentRoute, $m)) {
$helpRoutes[] = $m[1] . '_' . $m[2] . 'Help';
}
foreach ($helpRoutes as $helpRoute) {
try {
$helpUrl = $router->generate($helpRoute);
} catch (RouteNotFoundException $e) {
$helpUrl = null;
}
if ($helpUrl !== null) {
break;
}
}
return array(
'helpUrl' => $helpUrl,
);
}
public function getName()
{
return 'HelpUrl';
}
}