Skip to content

Commit

Permalink
Merge pull request #9 from bluzphp/develop
Browse files Browse the repository at this point in the history
Updated `bluzphp/composer-plugin` version
  • Loading branch information
Anton authored Oct 12, 2017
2 parents 14fdc03 + 4c1abfb commit 96700c5
Show file tree
Hide file tree
Showing 9 changed files with 165 additions and 186 deletions.
18 changes: 11 additions & 7 deletions application/modules/media/controllers/crud.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
* @var Controller $this
*/
Session::start();

$this->useLayout('dashboard.phtml');
if (!Request::isXmlHttpRequest()) {
$this->useLayout('dashboard.phtml');
}
Layout::breadCrumbs(
[
Layout::ahref('Dashboard', ['dashboard', 'index']),
Expand All @@ -55,11 +56,14 @@

$result = $crudController->run();

// FIXME: workaround
// check result for instance of Media\Row
if ((Request::isPost() || Request::isPut()) && !$result) {
// all ok, go to grid
Response::redirectTo('media', 'grid');
// back to grid after create or update media file
if (Request::isPost() || Request::isPut()) {
if ($rollback = Session::get('rollback')) {
Response::redirectTo(...$rollback);
} else {
// all ok, go to grid
Response::redirectTo('media', 'grid');
}
}

return $result;
Expand Down
2 changes: 2 additions & 0 deletions application/modules/media/controllers/grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Bluz\Proxy\Layout;
use Bluz\Proxy\Request;
use Bluz\Proxy\Response;
use Bluz\Proxy\Session;

/**
* @privilege Management
Expand All @@ -24,6 +25,7 @@
/**
* @var Controller $this
*/
Session::set('rollback', ['media', 'grid']);
Layout::setTemplate('dashboard.phtml');
Layout::breadCrumbs(
[
Expand Down
2 changes: 2 additions & 0 deletions application/modules/media/controllers/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Application\Media\Table;
use Bluz\Controller\Controller;
use Bluz\Proxy\Session;

/**
* @return array
Expand All @@ -21,6 +22,7 @@
/**
* @var Controller $this
*/
Session::set('rollback', ['media', 'manager']);

return ['images' => Table::getInstance()->getImages()];
};
93 changes: 47 additions & 46 deletions application/modules/media/views/crud.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,66 +5,67 @@
?>
<?php $uid = uniqid('form_', false); ?>
<form id="<?=$uid?>" action="<?=$this->url('media', 'crud')?>" class="form-horizontal" method="POST" enctype="multipart/form-data">
<input type="hidden" name="_method" value="<?=$method?>"/>
<input type="hidden" name="id" value="<?=$row->id?>"/>
<div>
<h3><?=__('Media')?></h3>
<input type="hidden" name="_method" value="<?=$method?>"/>
<input type="hidden" name="id" value="<?=$row->id?>"/>
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><?= __('Media') ?></h4>
<button type="button" class="close" data-dismiss="modal" aria-label="<?=__('Close')?>">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="row">
<div class="col-lg-8">
<div class="form-group">
<label class="control-label col-lg-2" for="name"><?=__('Title')?></label>
<div class="col-lg-10">
<input type="text" class="form-control" id="name" name="title" value="<?=($row->title)?>" required />
</div>
<div class="modal-body">
<div class="media">
<div class="media-body">
<div class="form-group row">
<label class="col-form-label col-lg-2" for="name"><?=__('Title')?></label>
<div class="col-lg-10">
<input type="text" class="form-control" id="name" name="title" value="<?=($row->title)?>" required />
</div>
<?php if ($method === 'POST') : ?>
<div class="form-group">
<label class="control-label col-lg-2"><?=__('File')?></label>
</div>
<?php if ($method === 'POST') : ?>
<div class="form-group row">
<label class="col-form-label col-lg-2"><?=__('File')?></label>
<div class="col-lg-10">
<input type="file" name="file" accept="image/*" required />
<input type="file" name="file" accept="image/*" required />
</div>
</div>
<?php else: ?>
<div class="form-group">
<label class="control-label col-lg-2"><?=__('File')?></label>
</div>
<?php else: ?>
<div class="form-group row">
<label class="col-form-label col-lg-2"><?=__('File')?></label>
<div class="col-lg-10">
<input type="text" class="form-control" readonly name="file" value="<?=($row->file)?>" />
<input type="text" class="form-control" readonly name="file" value="<?=($row->file)?>" />
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-2"><?=__('Type')?></label>
</div>
<div class="form-group row">
<label class="col-form-label col-lg-2"><?=__('Type')?></label>
<div class="col-lg-10">
<input type="text" class="form-control" readonly name="type" value="<?=($row->type)?>" />
<input type="text" class="form-control" readonly name="type" value="<?=($row->type)?>" />
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-2"><?=__('Link')?></label>
</div>
<div class="form-group row">
<label class="col-form-label col-lg-2"><?=__('Link')?></label>
<div class="col-lg-10">
<p class="form-control-static">
<a href="<?=$this->baseUrl($row->file)?>">
<?=\Bluz\Proxy\Router::getFullUrl().($row->file)?>
</a>
</p>
<p class="form-control-static">
<a href="<?=$this->baseUrl($row->file)?>">
<?=\Bluz\Proxy\Router::getFullUrl().($row->file)?>
</a>
</p>
</div>
</div>
<?php
if (0 === strpos($row->type, 'image')) :
?>
</div>
<div class="form-group col-lg-2">
<a href="<?=$this->baseUrl($row->file)?>" class="thumbnail bluz-preview">
<img src="<?=$this->baseUrl($row->thumb?:$row->file)?>" class="img-polaroid" alt="<?=$row->title?>" />
</a>
<?php
endif;
?>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<?php if (0 === strpos($row->type, 'image')) : ?>
<a href="<?=$this->baseUrl($row->file)?>" class="thumbnail bluz-preview">
<img src="<?=$this->baseUrl($row->thumb?:$row->file)?>" class="d-flex ml-3" alt="<?=$row->title?>" />
</a>
<?php endif; ?>
</div>
</div>
<div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary"><?=__('Save')?></button>
</div>
</div>
</form>
<?php
// need for plain request
Expand Down
128 changes: 52 additions & 76 deletions application/modules/media/views/grid.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,85 +13,61 @@ if (!$grid) {
</script>
<div class="clearfix" data-spy="grid" data-grid="<?= $grid->getUid() ?>">

<nav class="navbar navbar-default">
<div class="col-lg-6">
<a href="<?= $this->url('media', 'crud') ?>" class="btn btn-primary navbar-btn"><?= __('Create') ?></a>
</div>
<div class="col-lg-6">
<form action="<?= $this->url('media', 'grid') ?>" class="navbar-form filter-form pull-right">
<div class="input-group">
<?php echo
$this->partial(
'grid/filter-search.phtml',
[
'grid' => $grid,
'filters' => [
'title' => __('Title'),
'file' => __('File'),
]
]
)
?>
<span class="input-group-btn">
<button class="btn btn-default"><?= __("Search") ?></button>
</span>
</div>
</form>
</div>
<nav class="navbar navbar-light bg-light justify-content-between">
<a href="<?= $this->url('media', 'crud') ?>" class="btn btn-primary navbar-btn"><?= __('Create') ?></a>
<form action="<?= $this->url('media', 'grid') ?>" class="form-inline filter-form">
<div class="input-group">
<?php echo
$this->partial(
'grid/filter-search.phtml',
[
'grid' => $grid,
'filters' => [
'title' => __('Title'),
'file' => __('File'),
]
]
)
?>
<span class="input-group-btn">
<button class="btn btn-secondary"><?= __("Search") ?></button>
</span>
</div>
</form>
</nav>
<hr/>

<div class="row">
<div class="col-lg-4">
<?= $this->partial('grid/total.phtml', ['grid' => $grid]) ?>
</div>
<div class="col-lg-8">
<?= $this->partial('grid/limit.phtml', ['grid' => $grid]) ?>
</div>
</div>

<div class="media-grid clearfix">
<?php foreach ($grid->getData() as $row) : ?>
<div class="pull-left">
<div class="panel panel-default">
<div class="panel-heading">
<div class="row">
<div class="col-lg-7 text-overflow">
<?= esc($row['title']) ?>
</div>
<div class="col-lg-5 text-right">
<a href="<?= $this->url('media', 'crud', ['id' => $row['id']]) ?>" class="btn btn-xs btn-primary ">
<i class="fa fa-pencil"></i>
</a>
<a href="<?= $this->url('media', 'crud', ['id' => $row['id']]) ?>"
class="confirm btn btn-xs btn-danger ajax" data-ajax-method="delete">
<i class="fa fa-trash-o"></i>
</a>
</div>
</div>
</div>
<div class="panel-body" style="background: url(<?= $this->baseUrl($row['thumb']) ?>) 50% 50% no-repeat;">
<!-- use image as background -->
<a href="<?= $this->baseUrl($row['file']) ?>" class="bluz-preview"></a>
</div>
<div class="panel-footer">

<a href="<?= $this->url('users', 'profile', ['id' => $row['userId']]) ?>">
<?= $row['login'] ?>
</a>
<div class="pull-right"><?= substr($row['created'], 0, -9) ?></div>
</div>
</div>
<?= $this->partial('grid/total.phtml', ['grid' => $grid]) ?>
<?= $this->partial('grid/limit.phtml', ['grid' => $grid]) ?>
<hr style="display: block; clear: both"/>
<div class="card-deck">
<?php foreach ($grid->getData() as $row) : ?>
<div class="card mb-3" style="min-width: 240px; max-width: 240px">
<a href="<?= $this->baseUrl($row['file']) ?>" class="bluz-preview">
<img class="card-img-top" src="<?= $this->baseUrl($row['thumb']) ?>" alt="<?= esc($row['title']) ?>">
</a>
<div class="card-body">
<div class="d-flex justify-content-end">
<h4 class="card-title mr-auto p-2"><?= esc($row['title']) ?></h4>
<a href="<?= $this->url('media', 'crud', ['id' => $row['id']]) ?>"
class="btn btn-xs btn-primary dialog align-self-start mr-2"
data-ajax-method="get" data-modal-style="modal-lg">
<i class="fa fa-pencil"></i>
</a>
<a href="<?= $this->url('media', 'crud', ['id' => $row['id']]) ?>"
class="confirm btn btn-xs btn-danger ajax align-self-start" data-ajax-method="delete">
<i class="fa fa-trash-o"></i>
</a>
</div>
<?php endforeach; ?>
</div>

<div class="row">
<div class="col-lg-4">
<?= $this->partial('grid/total.phtml', ['grid' => $grid]) ?>
</div>
<div class="col-lg-8">
<?= $this->partial('grid/pagination.phtml', ['grid' => $grid]) ?>
<p class="card-text">
<small class="text-muted">
Uploaded by <a href="<?= $this->url('users', 'profile', ['id' => $row['userId']]) ?>"><?= $row['login'] ?></a>
at <?= substr($row['created'], 0, -9) ?></small></p>
</div>
</div>
<?php endforeach; ?>
</div>

<hr style="display: block; clear: both"/>
<?= $this->partial('grid/total.phtml', ['grid' => $grid]) ?>
<?= $this->partial('grid/pagination.phtml', ['grid' => $grid]) ?>
</div>
Loading

0 comments on commit 96700c5

Please sign in to comment.