Skip to content

Commit 3aed1c6

Browse files
committed
renamed mopa paginator to mopabootstrap bundle and included bootstrap like flash messages as macros
0 parents  commit 3aed1c6

File tree

7 files changed

+137
-0
lines changed

7 files changed

+137
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Mopa\BootstrapBundle\DependencyInjection;
4+
5+
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6+
use Symfony\Component\Config\Definition\ConfigurationInterface;
7+
8+
/**
9+
* This is the class that validates and merges configuration from your app/config files
10+
*
11+
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
12+
*/
13+
class Configuration implements ConfigurationInterface
14+
{
15+
/**
16+
* {@inheritDoc}
17+
*/
18+
public function getConfigTreeBuilder()
19+
{
20+
$treeBuilder = new TreeBuilder();
21+
$rootNode = $treeBuilder->root('mopa_bootstrap');
22+
23+
// Here you should define the parameters that are allowed to
24+
// configure your bundle. See the documentation linked above for
25+
// more information on that topic.
26+
27+
return $treeBuilder;
28+
}
29+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Mopa\BootstrapBundle\DependencyInjection;
4+
5+
use Symfony\Component\DependencyInjection\ContainerBuilder;
6+
use Symfony\Component\Config\FileLocator;
7+
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
8+
use Symfony\Component\DependencyInjection\Loader;
9+
10+
/**
11+
* This is the class that loads and manages your bundle configuration
12+
*
13+
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
14+
*/
15+
class MopaBootstrapExtension extends Extension
16+
{
17+
/**
18+
* {@inheritDoc}
19+
*/
20+
public function load(array $configs, ContainerBuilder $container)
21+
{
22+
$configuration = new Configuration();
23+
$config = $this->processConfiguration($configuration, $configs);
24+
25+
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
26+
$loader->load('services.xml');
27+
}
28+
}

MopaBootstrapBundle.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Mopa\BootstrapBundle;
4+
5+
use Symfony\Component\HttpKernel\Bundle\Bundle;
6+
7+
class MopaBootstrapBundle extends Bundle
8+
{
9+
public function getParent()
10+
{
11+
return 'KnpPaginatorBundle';
12+
}
13+
}

Resources/config/services.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" ?>
2+
3+
<container xmlns="http://symfony.com/schema/dic/services"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
6+
7+
<!--
8+
<parameters>
9+
<parameter key="mopa_pagination.example.class">Mopa\PaginationBundle\Example</parameter>
10+
</parameters>
11+
12+
<services>
13+
<service id="mopa_pagination.example" class="%mopa_pagination.example.class%">
14+
<argument type="service" id="service_id" />
15+
<argument>plain_value</argument>
16+
<argument>%parameter_name%</argument>
17+
</service>
18+
</services>
19+
-->
20+
</container>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{# bootstrap compatible Sliding pagination control implementation #}
2+
{% if pageCount > 1 %}
3+
<div class="pagination">
4+
<ul>
5+
<li class="first {{ (first is defined and current == first) ? 'disabled' : ''}}">
6+
<a href="{{ path(route, query|merge({'page': first})) }}">&lt;&lt;</a>
7+
</li>
8+
9+
<li class="prev {{ (previous is not defined) ? 'disabled': ''}}">
10+
<a href="{{ previous is defined ? path(route, query|merge({'page': previous})) :'#' }}">&larr; Previous</a>
11+
</li>
12+
13+
{% for page in pagesInRange %}
14+
<li class="{{ (page == current) ? 'active':''}}">
15+
<a href="{{ path(route, query|merge({'page': page})) }}">{{ page }}</a>
16+
</li>
17+
{% endfor %}
18+
19+
<li class="next {{ (next is not defined) ? 'disabled': ''}}">
20+
<a href="{{ (next is defined) ? path(route, query|merge({'page': next})) :'#' }}">&gt;</a>
21+
</li>
22+
23+
<li class="last {{ (last is defined and current == last) ? 'disabled' : ''}}">
24+
<a href="{{ (last is defined and current == last) ? '#' : path(route, query|merge({'page': last})) }}">Next &rarr;</a>
25+
</li>
26+
</ul>
27+
</div>
28+
{% endif %}
29+
<script type="text/javascript">
30+
$(document).ready(function(){
31+
$('.pagination li.disabled a').click(function (e) {
32+
e.preventDefault()
33+
});
34+
});
35+
</script>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{% set link = "" %}
2+
{% for attr, value in options %}
3+
{% set link = link ~ " " ~ attr ~ "=" ~ value %}
4+
{% endfor %}
5+
6+
<a {{ link }}>{{ title }}</a>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{% macro show(type) %}
2+
<div class="alert-message {{ type }}" data-alert="alert">
3+
<a class="close" href="#">×</a>
4+
<p>{{ app.session.flash(type) }}</p>
5+
</div>
6+
{% endmacro %}

0 commit comments

Comments
 (0)