2015-08-26 16:18:58 +09:30
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* This file is part of Flarum.
|
|
|
|
*
|
|
|
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Flarum\Events;
|
2015-07-18 22:59:47 +09:30
|
|
|
|
|
|
|
use Flarum\Support\ClientAction;
|
|
|
|
use Flarum\Support\ClientView;
|
2015-07-20 18:08:28 +09:30
|
|
|
use Flarum\Forum\Actions\ClientAction as ForumClientAction;
|
2015-07-31 20:13:13 +09:30
|
|
|
use Flarum\Admin\Actions\ClientAction as AdminClientAction;
|
2015-07-18 22:59:47 +09:30
|
|
|
|
|
|
|
class BuildClientView
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var ClientAction
|
|
|
|
*/
|
2015-07-20 18:08:28 +09:30
|
|
|
public $action;
|
2015-07-18 22:59:47 +09:30
|
|
|
|
|
|
|
/**
|
|
|
|
* @var ClientView
|
|
|
|
*/
|
2015-07-20 18:08:28 +09:30
|
|
|
public $view;
|
2015-07-18 22:59:47 +09:30
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
2015-07-20 18:08:28 +09:30
|
|
|
public $keys;
|
2015-07-18 22:59:47 +09:30
|
|
|
|
|
|
|
/**
|
|
|
|
* @param ClientAction $action
|
|
|
|
* @param ClientView $view
|
|
|
|
* @param array $keys
|
|
|
|
*/
|
|
|
|
public function __construct($action, $view, &$keys)
|
|
|
|
{
|
|
|
|
$this->action = $action;
|
|
|
|
$this->view = $view;
|
|
|
|
$this->keys = &$keys;
|
|
|
|
}
|
2015-07-20 18:08:28 +09:30
|
|
|
|
|
|
|
public function forumAssets($files)
|
|
|
|
{
|
|
|
|
if ($this->action instanceof ForumClientAction) {
|
|
|
|
$this->view->getAssets()->addFiles((array) $files);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function forumBootstrapper($bootstrapper)
|
|
|
|
{
|
|
|
|
if ($this->action instanceof ForumClientAction) {
|
|
|
|
$this->view->addBootstrapper($bootstrapper);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function forumTranslations(array $keys)
|
|
|
|
{
|
|
|
|
if ($this->action instanceof ForumClientAction) {
|
|
|
|
foreach ($keys as $key) {
|
|
|
|
$this->keys[] = $key;
|
|
|
|
}
|
|
|
|
}
|
2015-07-31 20:13:13 +09:30
|
|
|
}
|
|
|
|
|
|
|
|
public function adminAssets($files)
|
|
|
|
{
|
|
|
|
if ($this->action instanceof AdminClientAction) {
|
|
|
|
$this->view->getAssets()->addFiles((array) $files);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function adminBootstrapper($bootstrapper)
|
|
|
|
{
|
|
|
|
if ($this->action instanceof AdminClientAction) {
|
|
|
|
$this->view->addBootstrapper($bootstrapper);
|
|
|
|
}
|
|
|
|
}
|
2015-08-04 17:16:34 +09:30
|
|
|
|
|
|
|
public function adminTranslations(array $keys)
|
|
|
|
{
|
|
|
|
if ($this->action instanceof AdminClientAction) {
|
|
|
|
foreach ($keys as $key) {
|
|
|
|
$this->keys[] = $key;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-07-31 20:13:13 +09:30
|
|
|
}
|