Esempio n. 1
0
 /**
  * 휴지통 패키지에서 각 휴지통의 상태를 알 수 있도록 정보를 반환
  * 휴지통에 얼마만큼의 정보가 있는지 알려주기 위한 인터페이스
  *
  * @return string
  */
 public static function summary()
 {
     $count = BoardModel::where('status', 'trash')->where('type', BoardModule::getId())->count();
     // todo: translation
     return sprintf('휴지통에 %s건의 문서가 있습니다.', $count);
 }
Esempio n. 2
0
 /**
  * bind classes
  *
  * @return void
  */
 private function bindClasses()
 {
     /** @var \Illuminate\Foundation\Application $app */
     $app = app();
     $app->singleton('xe.plugin.board', function ($app) {
         return $this;
     });
     $app->bind('Xpressengine\\Plugins\\Board\\Plugin', 'xe.plugin.board');
     // Handler
     $app->singleton('xe.board.handler', function ($app) {
         /** @var Handler $proxyHandler */
         $proxyHandler = $app['xe.interception']->proxy(Handler::class);
         $readCounter = app('xe.counter')->make($app['request'], 'read');
         $readCounter->setGuest();
         $voteCounter = app('xe.counter')->make($app['request'], 'vote', ['assent', 'dissent']);
         $handler = new $proxyHandler(app('xe.document'), app('xe.storage'), app('xe.tag'), $readCounter, $voteCounter);
         return $handler;
     });
     $app->bind('Xpressengine\\Plugins\\Board\\Handler', 'xe.board.handler');
     // ConfigHandler
     $app->singleton('xe.board.config', function ($app) {
         /**
          * @var $configManager ConfigManager
          * @var $dynamicFieldHandler DynamicFieldHandler
          * @var $documentHandler DocumentHandler
          */
         $configManager = app('xe.config');
         $dynamicFieldHandler = app('xe.dynamicField');
         $documentHandler = app('xe.document');
         return new ConfigHandler($configManager, $dynamicFieldHandler->getConfigHandler(), $documentHandler->getConfigHandler());
     });
     $app->bind('Xpressengine\\Plugins\\Board\\ConfigHandler', 'xe.board.config');
     // UrlHandler
     $app->singleton('xe.board.url', function ($app) {
         return new UrlHandler();
     });
     $app->bind('Xpressengine\\Plugins\\Board\\UrlHandler', 'xe.board.url');
     // Vlidator
     $app->singleton('xe.board.validator', function ($app) {
         return new Validator($app['xe.board.config'], $app['xe.dynamicField']);
     });
     $app->bind('Xpressengine\\Plugins\\Board\\Validator', 'xe.board.validator');
     // IdentifyManager
     $app->singleton('xe.board.identify', function ($app) {
         /**
          * @var $session \Illuminate\Session\SessionManager
          * @var $documentHandler DocumentHandler
          */
         $session = app('session');
         $documentHandler = app('xe.document');
         return new IdentifyManager($session, $documentHandler, app('hash'));
     });
     $app->bind('Xpressengine\\Plugins\\Board\\IdentifyManager', 'xe.board.identify');
     $app->singleton('xe.board.instance', function ($app) {
         /**
          * @var $documentHandler DocumentHandler
          * @var $dynamicFieldHandler DynamicFieldHandler
          */
         $documentHandler = app('xe.document');
         $dynamicFieldHandler = app('xe.dynamicField');
         return new InstanceManager($app['xe.db']->connection('document'), $documentHandler, $dynamicFieldHandler, $app['xe.board.config'], $app['xe.board.permission'], $app['xe.plugin.comment']->getHandler());
     });
     $app->bind('Xpressengine\\Plugins\\Board\\InstanceManager', 'xe.board.instance');
     // BoardPermissionHandler
     $app->singleton('xe.board.permission', function ($app) {
         $boardPermission = new BoardPermissionHandler($app['xe.permission'], $app['xe.board.config']);
         $boardPermission->setPrefix(BoardModule::getId());
         return $boardPermission;
     });
     $app->bind('Xpressengine\\Plugins\\Board\\BoardPermissionHandler', 'xe.board.permission');
 }
Esempio n. 3
0
 /**
  * 게시판에 글 등록 시 핸들러를 통해서 처리
  * Interception 을 통해 다양한 서드파티 기능이 추가될 수 있다.
  *
  * @param array         $args arguments
  * @param UserInterface $user
  * @return Board
  */
 public function add(array $args, UserInterface $user, ConfigEntity $config)
 {
     $model = $this->getModel($config);
     $model->getConnection()->beginTransaction();
     $args['type'] = BoardModule::getId();
     $args['userId'] = $user->getId();
     if ($args['userId'] === null) {
         $args['userId'] = '';
     }
     if (empty($args['writer'])) {
         $args['writer'] = $user->getDisplayName();
     }
     if ($user instanceof Guest) {
         $args['userType'] = Board::USER_TYPE_GUEST;
     }
     if ($config->get('anonymity') === true) {
         $args['writer'] = $config->get('anonymityName');
         $args['userType'] = Board::USER_TYPE_ANONYMITY;
     }
     // save Document
     $doc = $this->documentHandler->add($args);
     $model = $this->getModel($config);
     $board = $model->find($doc->id);
     $this->setModelConfig($board, $config);
     $this->saveSlug($board, $args);
     $this->saveCategory($board, $args);
     $this->setFiles($board, $args);
     $this->setTags($board, $args);
     $this->saveData($board, $args);
     $model->getConnection()->commit();
     return $board;
 }
 /**
  * UserController constructor.
  *
  * @param Handler $handler
  * @param ConfigHandler $configHandler
  * @param UrlHandler $urlHandler
  * @param BoardPermissionHandler $boardPermission
  */
 public function __construct(Handler $handler, ConfigHandler $configHandler, UrlHandler $urlHandler, BoardPermissionHandler $boardPermission)
 {
     $instanceConfig = InstanceConfig::instance();
     $this->instanceId = $instanceConfig->getInstanceId();
     $this->handler = $handler;
     $this->configHandler = $configHandler;
     $this->urlHandler = $urlHandler;
     $this->config = $configHandler->get($this->instanceId);
     if ($this->config !== null) {
         $urlHandler->setConfig($this->config);
         $this->isManager = false;
         if (Gate::allows(BoardPermissionHandler::ACTION_MANAGE, new Instance($boardPermission->name($this->instanceId)))) {
             $this->isManager = true;
         }
     }
     // set Skin
     XePresenter::setSkinTargetId(BoardModule::getId());
     XePresenter::share('handler', $handler);
     XePresenter::share('configHandler', $configHandler);
     XePresenter::share('urlHandler', $urlHandler);
     XePresenter::share('isManager', $this->isManager);
     XePresenter::share('instanceId', $this->instanceId);
     XePresenter::share('config', $this->config);
 }
 /**
  * document manager
  *
  * @return \Xpressengine\Presenter\RendererInterface
  */
 public function docsTrash(Request $request, RouteRepository $routeRepository)
 {
     $instances = [];
     $instanceIds = [];
     $urls = [];
     $instanceRoutes = $routeRepository->fetchByModule(BoardModule::getId());
     foreach ($instanceRoutes as $route) {
         $instanceIds[] = $route->instanceId;
         $urls[$route->instanceId] = $route->url;
         $instances[] = ['id' => $route->instanceId, 'name' => $route->url];
     }
     $wheres = ['status' => Board::STATUS_TRASH, 'instanceIds' => $instanceIds];
     // keyword 검색 처리
     if ($request->get('searchKeyword') != '') {
         $searchTarget = $request->get('searchTarget');
         $searchKeyword = $request->get('searchKeyword');
         if ($searchTarget == 'title_content') {
             $wheres[$searchTarget] = $searchKeyword;
         } else {
             $wheres[$searchTarget] = $searchKeyword;
         }
     }
     // 상세 검색 처리
     foreach ($request->all() as $key => $value) {
         if ($value != '') {
             $wheres[$key] = $value;
         }
     }
     $query = Board::whereIn('instanceId', $instanceIds)->where('status', Board::STATUS_TRASH);
     $query->orderBy('createdAt', 'desc');
     $documents = $query->paginate(15)->appends($request->except('page'));
     return $this->presenter->make('docs.trash', compact('documents', 'instances', 'urls'));
 }