/**
  * Service Provider Boot
  *
  * @return void
  */
 public function boot(GateContract $gate)
 {
     $pluginRegister = $this->app['xe.pluginRegister'];
     $pluginRegister->add(MenuType::class);
     $pluginRegister->add(MenuSelect::class);
     $pluginRegister->add(TypeSelect::class);
     $pluginRegister->add(DirectLink::class);
     foreach ($this->policies as $class => $policy) {
         $gate->policy($class, $policy);
     }
     // 메뉴아이템의 링크를 편하게 제공하기 위한 resolver 등록
     MenuItem::setLinkResolver(function (MenuItem $item) {
         $title = xe_trans($item->getAttributeValue('title'));
         if ($item->getRelationValue('basicImage')) {
             if ($item->isSelected()) {
                 $image = $item->getSelectedImage();
             } else {
                 $image = $item->basicImage;
             }
             $hoverImage = $item->getHoverImage();
             return sprintf('<img src="%s" class="__xe_menu_image" data-hover="%s" alt="%s"/>', $image, $hoverImage, $title);
         }
         return $title;
     });
 }
Ejemplo n.º 2
0
 /**
  * render
  *
  * @return string
  */
 public function render()
 {
     $args = $this->arguments;
     if (empty($args['name'])) {
         throw new \Exception();
     }
     if (empty($args['items'])) {
         $args['items'] = [];
     }
     if (empty($args['label'])) {
         $args['label'] = xe_trans('xe::select');
     }
     if (empty($args['value'])) {
         $args['value'] = '';
         $args['text'] = '';
     } else {
         foreach ($args['items'] as $item) {
             if ($item['value'] == $args['value']) {
                 $args['text'] = $item['text'];
             }
         }
     }
     $args['scriptInit'] = false;
     if (self::$loaded === false) {
         self::$loaded = true;
         $args['scriptInit'] = true;
     }
     return View::make('board::views.uiobject.designSelect', $args)->render();
 }
Ejemplo n.º 3
0
 public function update(Request $request, ThemeHandler $themeHandler)
 {
     $editable = session('theme.editable');
     if (!$editable) {
         return redirect()->back()->with('alert', ['type' => 'danger', 'message' => xe_trans('xe::needAuthForEditingTheme')])->withInput();
     }
     $themeId = $request->get('theme');
     $fileName = $request->get('file');
     $reset = $request->get('reset');
     $content = $request->get('content');
     $theme = $themeHandler->getTheme($themeId);
     $files = $theme->getEditFiles();
     $filePath = realpath($files[$fileName]);
     $cachePath = $themeHandler->getCachePath($filePath);
     $cacheDir = dirname($cachePath);
     File::makeDirectory($cacheDir, 0755, true, true);
     try {
         if ($reset === 'Y') {
             File::delete($cachePath);
         } else {
             file_put_contents($cachePath, $content);
         }
     } catch (\Exception $e) {
         throw new FileAccessDeniedHttpException();
     }
     return redirect()->back()->with('alert', ['type' => 'success', 'message' => '저장되었습니다.']);
 }
Ejemplo n.º 4
0
 public function show(Request $request, $section = 'settings')
 {
     // remove & move code
     $settingsSection = ['settings' => ['title' => xe_trans('xe::defaultSettings'), 'content' => function ($member) {
         return $this->memberEditView($member);
     }]];
     // get sections
     $menus = $this->handler->getSettingsSections();
     // add default settings section
     $menus = array_merge($settingsSection, $menus);
     // get Selected section
     if (isset($menus[$section]) === false) {
         throw new NotFoundHttpException();
     }
     $selectedSection = $menus[$section];
     if ($selectedSection === null) {
         $selectedSection = reset($menus);
     }
     // get current member
     $member = $this->member;
     $content = $selectedSection['content'];
     $tabContent = $content instanceof \Closure ? $content($member) : $content;
     app('xe.frontend')->css(['assets/common/css/grid.css', 'assets/common/css/form.css', 'assets/member/setting.css', 'assets/common/css/dropdown.css'])->load();
     app('xe.frontend')->js('assets/member/snb.js')->load();
     return Presenter::make('index', compact('member', 'menus', 'tabContent'));
 }
Ejemplo n.º 5
0
 /**
  * Get the evaluated contents of the object.
  *
  * @return string
  */
 public function render()
 {
     $this->loadFrontend();
     $user = \Auth::user();
     $isSuper = $user->getRating() === Rating::SUPER;
     $menu = \Settings::getSettingsMenus($isSuper);
     $siteTitle = app('xe.site')->getSiteConfigValue('site_title');
     $siteTitle = $siteTitle !== null ? xe_trans($siteTitle) : 'XpressEngine';
     $selectedMenu = \Settings::getSelectedMenu($isSuper);
     return \View::make('themes.settings', compact('menu', 'selectedMenu', 'user', 'siteTitle'));
 }
Ejemplo n.º 6
0
 /**
  * get text
  *
  * @return string
  */
 public function getText()
 {
     /** @var Handler $handler */
     $handler = app('xe.claim.handler');
     $handler->set($this->componentType);
     $count = $handler->count($this->identifier);
     $invoked = $handler->has($this->identifier, Auth::user());
     $text = 'xe::claim';
     if ($invoked === true) {
         $text = 'xe::cancelClaim';
     }
     if ($count > 0) {
         $text = sprintf('%s (%s)', xe_trans($text), $count);
     } else {
         $text = xe_trans($text);
     }
     return $text;
 }
 /**
  * index
  *
  * @return \Xpressengine\Presenter\RendererInterface
  */
 public function index(Request $request)
 {
     /**
      * @var \Xpressengine\DynamicField\DynamicFieldHandler $dynamicField
      */
     $dynamicField = app('xe.dynamicField');
     $list = [];
     $configs = $dynamicField->getConfigHandler()->gets($request->get('group'));
     /**
      * @var ConfigEntity $config
      */
     foreach ($configs as $config) {
         $info = $config->getPureAll();
         /**
          * @var \Xpressengine\DynamicField\TypeInterface $fieldType
          */
         $fieldType = $dynamicField->get($config->get('group'), $config->get('id'));
         $info['typeName'] = $fieldType->name();
         $info['skinName'] = $fieldType->getSkin()->name();
         $info['label'] = xe_trans($info['label']);
         $list[] = $info;
     }
     return XePresenter::makeApi(['list' => $list]);
 }
Ejemplo n.º 8
0
 /**
  * exception filter
  *
  * @param \Exception $e exception
  *
  * @return \Exception
  */
 private function filter(Exception $e)
 {
     $responseException = null;
     /*
      * make responseException
      */
     // token mismatch
     if ($e instanceof TokenMismatchException) {
         $responseException = new HttpXpressengineException([], Response::HTTP_FORBIDDEN);
         $responseException->setMessage(xe_trans('xe::tokenMismatch'));
     } elseif ($e instanceof NotFoundHttpException) {
         $responseException = new HttpXpressengineException([], Response::HTTP_NOT_FOUND);
         $responseException->setMessage(xe_trans('xe::pageNotFound'));
     } elseif ($e instanceof AccessDeniedHttpException) {
         // Redirect is not returned(redirection is not executed). only set current uri to session
         $e->setMessage(xe_trans('xe::accessDenied'));
         $responseException = $e;
     } elseif ($e instanceof HttpException) {
         $responseException = $e;
     } elseif ($e instanceof HttpXpressengineException) {
         $e->setMessage(xe_trans($e->getMessage(), $e->getArgs()));
         $responseException = $e;
     } elseif ($e instanceof XpressengineException) {
         // plugin cache 삭제
         if ($e instanceof PluginFileNotFoundException) {
             $cache = app('cache');
             Event::fire('cache:clearing', ['plugins']);
             $cache->store('plugins')->flush();
             Event::fire('cache:cleared', ['plugins']);
         }
         $responseException = new HttpXpressengineException([], Response::HTTP_INTERNAL_SERVER_ERROR);
         $message = xe_trans($e->getMessage(), $e->getArgs());
         if ('' === $message) {
             $message = get_class($e);
         } elseif ($message == $e->getMessage()) {
             $message = $e->getMessage();
         }
         $responseException->setMessage($message);
     } else {
         $responseException = new HttpXpressengineException([], Response::HTTP_INTERNAL_SERVER_ERROR);
         $responseException->setMessage(xe_trans('xe::systemError'));
     }
     if ($responseException->getMessage() == '') {
         $responseException->setMessage(xe_trans('xe::systemError'));
     }
     return $responseException;
 }
Ejemplo n.º 9
0
 /**
  * show user editing page
  *
  * @param $id
  *
  * @return \Xpressengine\Presenter\RendererInterface
  */
 public function edit($id)
 {
     $user = $this->handler->users()->with('groups', 'emails', 'accounts')->find($id);
     if ($user === null) {
         $e = new InvalidArgumentHttpException();
         $e->setMessage('존재하지 않는 회원입니다.');
         throw $e;
     }
     $ratings = Rating::getUsableAll();
     $ratingNames = ['member' => xe_trans('xe::memberRatingNormal'), 'manager' => xe_trans('xe::memberRatingManager'), 'super' => xe_trans('xe::memberRatingAdministrator')];
     foreach ($ratings as $key => $rating) {
         $ratings[$key] = ['value' => $rating, 'text' => $ratingNames[$rating]];
         if ($rating === $user->rating) {
             $ratings[$key]['selected'] = 'selected';
         }
     }
     $groupList = $this->handler->groups()->all();
     $groups = $this->getGroupInfo($groupList);
     foreach ($user->groups as $group) {
         $groups[$group->id]['checked'] = 'checked';
     }
     $status = [\XeUser::STATUS_ACTIVATED => ['value' => \XeUser::STATUS_ACTIVATED, 'text' => xe_trans('xe::permitted')], \XeUser::STATUS_DENIED => ['value' => \XeUser::STATUS_DENIED, 'text' => xe_trans('xe::rejected')]];
     $status[$user->status]['selected'] = 'selected';
     // profileImage config
     $profileImgSize = config('xe.user.profileImage.size');
     // dynamic field
     $dynamicField = app('xe.dynamicField');
     $fieldTypes = $dynamicField->gets('user');
     $defaultAccount = null;
     if (isset($user->accounts)) {
         foreach ($user->accounts as $account) {
             if ($account->provider === \XeUser::PROVIDER_DEFAULT) {
                 $defaultAccount = $account;
             }
         }
     }
     return XePresenter::make('member.settings.member.edit', compact('user', 'ratings', 'groups', 'status', 'defaultAccount', 'fieldTypes', 'profileImgSize'));
 }
Ejemplo n.º 10
0
 /**
  * set board order items
  *
  * @return void
  */
 protected function setBoardOrderItems()
 {
     $items = [];
     foreach ($this->data['boardOrders'] as $id => $instance) {
         $items[] = ['value' => $id, 'text' => xe_trans($instance->name())];
     }
     $this->data['boardOrderItems'] = $items;
 }
Ejemplo n.º 11
0
 /**
  * add email
  *
  * @param Request $request
  *
  * @return \Xpressengine\Presenter\RendererInterface
  * @throws Exception
  */
 public function addMail(Request $request)
 {
     $input = $request->only('address');
     // validation
     $this->validate($request, ['address' => 'email|required'], [], ['address' => xe_trans('xe::email')]);
     // 이미 인증 요청중인 이메일이 있는지 확인한다.
     $useEmailConfirm = $this->handler->usingEmailConfirm();
     if ($useEmailConfirm) {
         if ($this->user->getPendingEmail() !== null) {
             $e = new PendingEmailAlreadyExistsException();
             throw new HttpException(400, $e->getMessage(), $e);
         }
     }
     // 이미 존재하는 이메일이 있는지 확인한다.
     if ($this->emails->findByAddress($input['address'])) {
         $e = new MailAlreadyExistsException();
         throw new HttpException(400, $e->getMessage(), $e);
     }
     //array_set($input, 'userId', $this->user->getId());
     XeDB::beginTransaction();
     try {
         $mail = $this->handler->createEmail($this->user, $input, !$useEmailConfirm);
         if ($useEmailConfirm) {
             /** @var EmailBroker $broker */
             $broker = app('xe.auth.email');
             $broker->sendEmailForConfirmation($mail);
         }
     } catch (\Exception $e) {
         XeDB::rollback();
         throw $e;
     }
     XeDB::commit();
     \Session::flash('alert', ['type' => 'success', 'message' => '추가되었습니다.']);
     return XePresenter::makeApi(['message' => '추가되었습니다']);
 }
Ejemplo n.º 12
0
 /**
  * Get a content html tag string
  *
  * @return string
  */
 protected function getContentHtml()
 {
     $args = $this->getArguments();
     $html = '<textarea ' . 'name="' . $args['contentDomName'] . '" ' . 'id="' . $args['contentDomId'] . '" ' . $this->getContentDomHtmlOption($args['contentDomOptions']) . ' placeholder="' . xe_trans('xe::content') . '" ' . 'style="width:100%;">' . $args['content'] . '</textarea>';
     return $html;
 }
Ejemplo n.º 13
0
 /**
  * show
  *
  * @param Request $request
  * @param string  $section
  *
  * @return \Xpressengine\Presenter\RendererInterface
  */
 public function show(Request $request, $section = 'settings')
 {
     // remove & move code
     $settingsSection = ['settings' => ['title' => xe_trans('xe::defaultSettings'), 'content' => function ($user) {
         return $this->userEditView($user);
     }]];
     // get sections
     $menus = $this->handler->getSettingsSections();
     // add default settings section
     $menus = array_merge($settingsSection, $menus);
     // get Selected section
     if (isset($menus[$section]) === false) {
         throw new NotFoundHttpException();
     }
     $selectedSection = $menus[$section];
     if ($selectedSection === null) {
         $selectedSection = reset($menus);
     }
     // get current user
     $user = $this->user;
     $content = $selectedSection['content'];
     $tabContent = $content instanceof \Closure ? $content($user) : $content;
     return XePresenter::make('index', compact('user', 'menus', 'tabContent'));
 }
Ejemplo n.º 14
0
 /**
  * trash
  *
  * @param Request $request request
  * @return mixed
  */
 public function trash(Request $request)
 {
     $user = Auth::user();
     $id = $request->get('id');
     $item = $this->handler->getModel($this->config)->find($id);
     $this->handler->setModelConfig($item, $this->config);
     if ($user->getRating() != 'super' && $user->getId() != $item->id) {
         throw new AccessDeniedHttpException();
     }
     $id = $request->get('id');
     $author = Auth::user();
     $item = $this->handler->getModel($this->config)->find($id);
     $this->handler->setModelConfig($item, $this->config);
     // 관리자 또는 본인 글이 아니면 접근 할 수 없음
     if ($author->getRating() !== 'super' && $author->getId() != $item->id) {
         throw new NotFoundDocumentException();
     }
     $this->handler->trash($item, $this->config);
     return redirect()->to($this->urlHandler->get('index'))->with(['alert' => ['type' => 'success', 'message' => xe_trans('xe::complete')]]);
 }
Ejemplo n.º 15
0
 /**
  * file upload
  *
  * @param Request       $request      request
  * @param EditorHandler $handler      editor handler
  * @param Storage       $storage      storage
  * @param MediaManager  $mediaManager media manager
  * @param string        $instanceId   instance id
  * @return RendererInterface
  */
 public function fileUpload(Request $request, EditorHandler $handler, Storage $storage, MediaManager $mediaManager, $instanceId)
 {
     $uploadedFile = null;
     if ($request->file('file') !== null) {
         $uploadedFile = $request->file('file');
     } elseif ($request->file('image') !== null) {
         $uploadedFile = $request->file('image');
     }
     if ($uploadedFile === null) {
         throw new InvalidArgumentException();
     }
     $config = $handler->get($instanceId)->getConfig();
     if (!$config->get('uploadActive') || Gate::denies('upload', new Instance($handler->getPermKey($instanceId)))) {
         throw new AccessDeniedHttpException();
     }
     if ($config->get('fileMaxSize') * 1024 * 1024 < $uploadedFile->getSize()) {
         throw new HttpException(Response::HTTP_REQUEST_ENTITY_TOO_LARGE, xe_trans('xe::msgMaxFileSize', ['fileMaxSize' => $config->get('fileMaxSize'), 'uploadFileName' => $uploadedFile->getClientOriginalName()]));
     }
     $extensions = array_map(function ($v) {
         return trim($v);
     }, explode(',', $config->get('extensions', '')));
     if (array_search('*', $extensions) === false && !in_array(strtolower($uploadedFile->getClientOriginalExtension()), $extensions)) {
         throw new HttpException(Response::HTTP_NOT_ACCEPTABLE, xe_trans('xe::msgAvailableUploadingFiles', ['extensions' => $config->get('extensions'), 'uploadFileName' => $uploadedFile->getClientOriginalName()]));
     }
     $file = $storage->upload($uploadedFile, EditorHandler::FILE_UPLOAD_PATH);
     $media = null;
     $thumbnails = null;
     if ($mediaManager->is($file) === true) {
         $media = $mediaManager->make($file);
         $thumbnails = $mediaManager->createThumbnails($media, EditorHandler::THUMBNAIL_TYPE);
         $media = $media->toArray();
         if (!empty($thumbnails)) {
             $info['thumbnails'] = $thumbnails;
         }
     }
     return XePresenter::makeApi(['file' => $file->toArray(), 'media' => $media, 'thumbnails' => $thumbnails]);
 }
Ejemplo n.º 16
0
 /**
  * move to copy
  *
  * @return \Illuminate\Http\RedirectResponse|Redirect
  */
 public function copy(Request $request)
 {
     $documentIds = $request->get('id');
     $documentIds = is_array($documentIds) ? $documentIds : [$documentIds];
     $instanceId = $request->get('instanceId');
     $config = $this->configHandler->get($instanceId);
     if ($config === null) {
         throw new NotFoundConfigHttpException(['instanceId' => $instanceId]);
     }
     $items = Board::find($documentIds);
     foreach ($items as $item) {
         $this->handler->setModelConfig($item, $this->configHandler->get($item->instanceId));
         $user = new Guest();
         if ($item->userId != '') {
             $user = User::find($item->userId);
         }
         $this->handler->copy($item, $user, $config);
     }
     Session::flash('alert', ['type' => 'success', 'message' => xe_trans('xe::processed')]);
     return $this->presenter->makeApi([]);
 }
Ejemplo n.º 17
0
 /**
  * summary
  *
  * @param string $instanceId instance id
  * @return string
  */
 public function summary($instanceId)
 {
     return xe_trans('board::destroySummary', app('xe.board.instance')->summary($instanceId, app('xe.board.handler')));
 }
Ejemplo n.º 18
0
 /**
  * @param string $name
  * @param array $args
  */
 public function output($name, array $args)
 {
     $key = $name . 'ItemId';
     if (isset($args[$key]) === false || $args[$key] == '') {
         return null;
     }
     return xe_trans(CategoryItem::find($args[$key])->word);
 }
 public function children(Request $request, $id)
 {
     if ($request->get('id') === null) {
         $children = Category::find($id)->getProgenitors();
     } else {
         /** @var CategoryItem $item */
         if (!($item = CategoryItem::find($request->get('id')))) {
             throw new InvalidArgumentHttpException();
         }
         $children = $item->getChildren();
     }
     foreach ($children as $child) {
         $child->readableWord = xe_trans($child->word);
     }
     return XePresenter::makeApi($children->toArray());
 }
Ejemplo n.º 20
0
 /**
  * register phone number validator
  *
  * @return void
  */
 protected function registerValidator()
 {
     app('validator')->extend('cell_phone_number', function ($attribute, $value, $parameters) {
         $value = str_replace(['-', ' '], '', $value);
         if (is_numeric($value) === false) {
             return false;
         }
     }, xe_trans('mngCellPhoneNumberValidate'));
 }