Compare commits

..

1 Commits
master ... 0.1

Author SHA1 Message Date
R. Eric Wheeler 2aaedb8f59 fixed background-contain 2017-05-22 06:00:13 -07:00
6 changed files with 135 additions and 18 deletions

View File

@ -1,8 +1,11 @@
{% if form is defined %}
{% form_theme form with [_self, 'form_errors.html.twig'] %}
{% endif %}
{% if app.environment == 'dev' %}
{% set bucket = '' %}
{% else %}
{% set bucket = 'https://storage.googleapis.com/zgluzzkwodfky2m0ytbhmjhmmzqzntq2ngy3ndjmntyxmzg4' %}
{% endif %}
<!DOCTYPE html>
<html lang="en-us">
<head>

View File

@ -37,16 +37,11 @@ monolog:
# type: chromephp
# level: info
vich_uploader:
storage: gaufrette
storage: file_system
mappings:
gallery_image:
upload_destination: cloud
uri_prefix: /
#storage: file_system
#mappings:
# gallery_image:
# uri_prefix: /images/gallery
# upload_destination: '%kernel.root_dir%/../web/images/gallery'
uri_prefix: /images/gallery
upload_destination: '%kernel.root_dir%/../web/gallery/images/gallery'
swiftmailer:
transport: null

View File

@ -57,8 +57,10 @@ services:
arguments: ['@router', '@monolog.logger']
doughnutwedding.uikit.template:
class: Sikofitt\DoughnutWeddingBundle\Pager\View\UIkitTemplate
arguments: ['@service_container']
pagerfanta.view.default:
class: Pagerfanta\View\DefaultView
arguments: ['@doughnutwedding.uikit.template']
public: false
tags: [{ name: pagerfanta.view, alias: default }]

View File

@ -261,9 +261,12 @@ class GalleryController extends Controller
->get('doctrine.orm.entity_manager')
->getRepository('SikofittDoughnutWeddingBundle:Image')
->findImageByTag($tag);
$adapter = new ArrayAdapter($images);
$pager = new Pagerfanta($adapter);
$pager->setMaxPerPage(12);
$pager->setCurrentPage($number);
$chunks = array_chunk($images, 12);
return $this
@ -291,9 +294,11 @@ class GalleryController extends Controller
->getRepository('SikofittDoughnutWeddingBundle:Image')
->findImageByCategory($category);
$adapter = new ArrayAdapter($images);
$pager = new Pagerfanta($adapter);
$pager->setMaxPerPage(12);
$pager->setCurrentPage($number);
$chunks = array_chunk($images, 12);
return $this

View File

@ -21,6 +21,7 @@
namespace Sikofitt\DoughnutWeddingBundle\Pager\View;
use Pagerfanta\View\Template\Template;
use Symfony\Component\DependencyInjection\ContainerInterface;
class UIkitTemplate extends Template
{
@ -39,6 +40,14 @@ class UIkitTemplate extends Template
'rel_next' => 'next',
];
private $serviceContainer;
public function __construct(ContainerInterface $serviceContainer)
{
$this->serviceContainer = $serviceContainer;
parent::__construct();
}
/**
* Renders the container for the pagination.
*
@ -51,6 +60,81 @@ class UIkitTemplate extends Template
return sprintf('<ul class="%s" uk-margin>%s</ul>', static::$defaultOptions['css_container_class'], '%pages%');
}
public function categoryPage($page, $path) {
$args = explode('/', $path);
array_shift($args);
if(is_int(count($args)-1)) {
$args[count($args)-1] = $page;
}
if((int)$args[count($args) - 1] === 1) {
array_pop($args);
}
$path = implode('/', $args);
return sprintf('<li><a href="/%s">%s</a></li>', $path, $page);
}
public function categoryPageNext($page, $path) {
$args = explode('/', $path);
array_shift($args);
$args[count($args) - 1] = $page;
$path = implode('/', $args);
return sprintf('<li><a href="/%s">Next <span class="uk-margin-small-right" uk-pagination-next></span></a></li>', $path);
}
public function categoryPagePrevious($page, $path) {
$args = explode('/', $path);
array_shift($args);
if (1 === (int) $page) {
array_pop($args);
$path = implode('/', $args);
return '<li><a href="/'.$path.'"><span class="uk-margin-small-right" uk-pagination-previous></span> Previous</a></li>';
}
$args[count($args)-1] = $page;
$path = implode('/', $args);
return '<li><a href="/'.$path.'"><span class="uk-margin-small-right" uk-pagination-previous></span> Previous</a></li>';
}
public function tagPage($page, $path) {
$args = explode('/', $path);
array_shift($args);
if(count($args) === 3) {
$args[] = $page;
} elseif(count($args) === 4) {
$args[count($args) -1] = $page;
}
if(1 === $page) {
array_pop($args);
}
$path = implode('/', $args);
return sprintf('<li><a href="/%s">%s</a></li>', $path, $page);
}
public function tagPageNext($page, $path) {
$args = explode('/', $path);
array_shift($args);
if(count($args) === 3) {
$args[] = $page;
} else {
$args[count($args) - 1] = $page;
}
$path = implode('/', $args);
return sprintf('<li><a href="/%s">Next <span class="uk-margin-small-right" uk-pagination-next></span></a></li>', $path);
}
public function tagPagePrevious($page, $path) {
$args = explode('/', $path);
array_shift($args);
if (1 === (int) $page) {
array_pop($args);
$path = implode('/', $args);
return '<li><a href="/'.$path.'"><span class="uk-margin-small-right" uk-pagination-previous></span> Previous</a></li>';
}
$args[count($args)-1] = $page;
$path = implode('/', $args);
return '<li><a href="/'.$path.'"><span class="uk-margin-small-right" uk-pagination-previous></span> Previous</a></li>';
}
/**
* Renders a given page.
*
@ -60,13 +144,22 @@ class UIkitTemplate extends Template
*/
public function page($page)
{
if (1 === (int) $page) {
return '<li><a href="/gallery">'.$page.'</a></li>';
$path = $this->serviceContainer->get('request_stack')->getCurrentRequest()->getRequestUri();
if(
false !== strpos($path, 'tag') ||
false !== strpos($path, 'category')
) {
return $this->tagPage($page, $path);
}
return '<li><a href="/gallery/page/'.$page.'">'.$page.'</a></li>';
if (1 === (int)$page) {
return '<li><a href="/gallery">' . $page . '</a></li>';
}
return '<li><a href="/gallery/page/' . $page . '">' . $page . '</a></li>';
}
/**
* Renders a given page with a specified text.
*
@ -99,6 +192,14 @@ class UIkitTemplate extends Template
*/
public function previousEnabled($page)
{
$path = $this->serviceContainer->get('request_stack')->getCurrentRequest()->getRequestUri();
if(
false !== strpos($path, 'tag') ||
false !== strpos($path, 'category')
) {
return $this->tagPagePrevious($page, $path);
}
if (1 === (int) $page) {
return '<li><a href="/gallery"><span class="uk-margin-small-right" uk-pagination-previous></span> Previous</a></li>';
}
@ -125,6 +226,14 @@ class UIkitTemplate extends Template
*/
public function nextEnabled($page)
{
$path = $this->serviceContainer->get('request_stack')->getCurrentRequest()->getRequestUri();
if(
false !== strpos($path, 'tag') ||
false !== strpos($path, 'category')
) {
return $this->tagPageNext($page, $path);
}
return '<li class=""><a href="/gallery/page/'.$page.'">Next <span class="uk-margin-small-left" uk-pagination-next></span></a></li>';
}

View File

@ -15,8 +15,11 @@
<div class="uk-child-width-1-2@s uk-child-width-1-4@m uk-grid-small uk-grid-match uk-flex-middle" uk-grid>
{% if images is not null and images is not empty %}
{% for image in images %}
{% if app.environment == 'dev' %}
{% set imageUrl = '/gallery/' ~ vich_uploader_asset(image, 'imageFile')|trim('/', 'left') %}
{% else %}
{% set imageUrl = bucket ~ '/gallery/' ~ vich_uploader_asset(image, 'imageFile')|trim('/', 'left') %}
{% endif %}
<div class=" uk-height-small uk-overflow-hidden uk-cover-container">
<a class="uk-inline-clip uk-background-cover" style="background-image:url({{ imageUrl }})" href="#modal-full-{{ image.id }}" uk-cover uk-toggle></a>