-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/3.4.6' into v3.0
- Loading branch information
Showing
338 changed files
with
22,581 additions
and
20,915 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
116
app/TeenQuotes/AdminPanel/AdminPanelServiceProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
97
app/TeenQuotes/AdminPanel/Composers/ModerationIndexComposer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.