Skip to content

Commit

Permalink
Merge branch 'release/3.4.6' into v3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineAugusti committed May 20, 2015
2 parents 6f8eb8a + 2559e04 commit bed591e
Show file tree
Hide file tree
Showing 338 changed files with 22,581 additions and 20,915 deletions.
11 changes: 11 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

use Symfony\CS\Config\Config;
use Symfony\CS\Finder\DefaultFinder;

$finder = DefaultFinder::create()
->in([__DIR__.'/app', __DIR__.'/tests']);

return Config::create()
->fixers(['-empty_return', 'short_array_syntax', 'ordered_use'])
->finder($finder);
116 changes: 59 additions & 57 deletions app/TeenQuotes/AdminPanel/AdminPanelServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,66 +1,68 @@
<?php namespace TeenQuotes\AdminPanel;
<?php

use Illuminate\Support\ServiceProvider;
namespace TeenQuotes\AdminPanel;

class AdminPanelServiceProvider extends ServiceProvider {
use Illuminate\Support\ServiceProvider;

/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;
class AdminPanelServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->registerRoutes();
$this->registerViewComposers();
}
/**
* Register the service provider.
*/
public function register()
{
$this->registerRoutes();
$this->registerViewComposers();
}

private function registerRoutes()
{
$this->app['router']->pattern('decision', 'approve|unapprove|alert');
private function registerRoutes()
{
$this->app['router']->pattern('decision', 'approve|unapprove|alert');

$this->app['router']->group($this->getRouteGroupParams(), function() {
$this->app['router']->get('/', ['uses' => $this->getController().'@index', 'as' => 'admin.quotes.index']);
$this->app['router']->get('edit/{quote_id}', ['uses' => $this->getController().'@edit', 'as' => 'admin.quotes.edit']);
$this->app['router']->put('update/{quote_id}', ['uses' => $this->getController().'@update', 'as' => 'admin.quotes.update']);
$this->app['router']->post('moderate/{quote_id}/{decision}', ['uses' => $this->getController().'@postModerate', 'as' => 'admin.quotes.moderate']);
});
}
$this->app['router']->group($this->getRouteGroupParams(), function () {
$this->app['router']->get('/', ['uses' => $this->getController().'@index', 'as' => 'admin.quotes.index']);
$this->app['router']->get('edit/{quote_id}', ['uses' => $this->getController().'@edit', 'as' => 'admin.quotes.edit']);
$this->app['router']->put('update/{quote_id}', ['uses' => $this->getController().'@update', 'as' => 'admin.quotes.update']);
$this->app['router']->post('moderate/{quote_id}/{decision}', ['uses' => $this->getController().'@postModerate', 'as' => 'admin.quotes.moderate']);
});
}

private function registerViewComposers()
{
// JS variables used when moderating quotes
$this->app['view']->composer([
'admin.index'
], 'TeenQuotes\AdminPanel\Composers\ModerationIndexComposer');
}
private function registerViewComposers()
{
// JS variables used when moderating quotes
$this->app['view']->composer([
'admin.index',
], 'TeenQuotes\AdminPanel\Composers\ModerationIndexComposer');
}

/**
* Parameters for the group of routes
* @return array
*/
private function getRouteGroupParams()
{
return [
'domain' => $this->app['config']->get('app.domainAdmin'),
'namespace' => 'TeenQuotes\AdminPanel\Controllers',
'before' => 'admin',
];
}
/**
* Parameters for the group of routes.
*
* @return array
*/
private function getRouteGroupParams()
{
return [
'domain' => $this->app['config']->get('app.domainAdmin'),
'namespace' => 'TeenQuotes\AdminPanel\Controllers',
'before' => 'admin',
];
}

/**
* The controller name to handle requests
* @return string
*/
private function getController()
{
return 'QuotesAdminController';
}
}
/**
* The controller name to handle requests.
*
* @return string
*/
private function getController()
{
return 'QuotesAdminController';
}
}
97 changes: 61 additions & 36 deletions app/TeenQuotes/AdminPanel/Composers/ModerationIndexComposer.php
Original file line number Diff line number Diff line change
@@ -1,36 +1,61 @@
<?php namespace TeenQuotes\AdminPanel\Composers;

use Config, JavaScript, Lang;

class ModerationIndexComposer {

public function compose($view)
{
$data = $view->getData();

// The number of days required to publish waiting quotes
$nbDays = $this->getNbdaysToPublishQuotes($data['nbQuotesPending'], $data['nbQuotesPerDay']);
$view->with('nbDays', $nbDays);

// The page title
$view->with('pageTitle', 'Admin | '.Lang::get('layout.nameWebsite'));

// Useful JS variables
JavaScript::put([
'nbQuotesPerDay' => Config::get('app.quotes.nbQuotesToPublishPerDay'),
'quotesPlural' => Lang::choice('quotes.quotesText', 2),
'daysPlural' => Lang::choice('quotes.daysText', 2),
]);
}

/**
* Compute the number of days required to publish the current waiting number of quotes
* @param int $nbPending
* @param int $nbPublishedPerDay
* @return int
*/
private function getNbdaysToPublishQuotes($nbPending, $nbPublishedPerDay)
{
return ceil($nbPending / $nbPublishedPerDay);
}
}
<?php

namespace TeenQuotes\AdminPanel\Composers;

use Config;
use JavaScript;
use Lang;
use TeenQuotes\Tools\Colors\ColorGeneratorInterface;

class ModerationIndexComposer
{
/**
* @var ColorGeneratorInterface
*/
private $colorGenerator;

public function __construct(ColorGeneratorInterface $colorGenerator)
{
$this->colorGenerator = $colorGenerator;
}

/**
* Add data to the view.
*
* @param \Illuminate\View\View $view
*/
public function compose($view)
{
$data = $view->getData();

// The number of days required to publish waiting quotes
$nbDays = $this->getNbdaysToPublishQuotes($data['nbQuotesPending'], $data['nbQuotesPerDay']);
$view->with('nbDays', $nbDays);

// The page title
$view->with('pageTitle', 'Admin | '.Lang::get('layout.nameWebsite'));

// The color generator
$view->with('colorGenerator', $this->colorGenerator);

// Useful JS variables
JavaScript::put([
'nbQuotesPerDay' => Config::get('app.quotes.nbQuotesToPublishPerDay'),
'quotesPlural' => Lang::choice('quotes.quotesText', 2),
'daysPlural' => Lang::choice('quotes.daysText', 2),
]);
}

/**
* Compute the number of days required to publish the current waiting number of quotes.
*
* @param int $nbPending
* @param int $nbPublishedPerDay
*
* @return int
*/
private function getNbdaysToPublishQuotes($nbPending, $nbPublishedPerDay)
{
return ceil($nbPending / $nbPublishedPerDay);
}
}
Loading

0 comments on commit bed591e

Please sign in to comment.