PHP version 5
Author: XE Developers (developers@xpressengine.com)
Inheritance: extends Illuminate\Http\Request
 public function install(Request $request, PluginHandler $handler, PluginProvider $provider, ComposerFileWriter $writer, SessionManager $session)
 {
     $id = $request->get('pluginId');
     $handler->getAllPlugins(true);
     if ($handler->getPlugin($id) !== null) {
         throw new HttpException(422, 'Plugin already installed.');
     }
     // 자료실에서 플러그인 정보 조회
     $pluginData = $provider->find($id);
     if ($pluginData === null) {
         throw new HttpException(422, "Can not find the plugin(" . $id . ") that should be installed from the Market-place.");
     }
     $title = $pluginData->title;
     $name = $pluginData->name;
     $version = $pluginData->latest_release->version;
     $operation = $handler->getOperation($writer);
     if ($operation['status'] === ComposerFileWriter::STATUS_RUNNING) {
         throw new HttpException(422, "이미 진행중인 요청이 있습니다.");
     }
     $timeLimit = config('xe.plugin.operation.time_limit');
     $writer->reset()->cleanOperation();
     $writer->install($name, $version, Carbon::now()->addSeconds($timeLimit)->toDateTimeString())->write();
     $this->reserveOperation($writer, $timeLimit);
     $session->flash('alert', ['type' => 'success', 'message' => '새로운 플러그인을 설치중입니다.']);
     return XePresenter::makeApi(['type' => 'success', 'message' => '새로운 플러그인을 설치중입니다.']);
 }
 public function updateConfig(Request $request)
 {
     /** @var \Xpressengine\Config\ConfigManager $configManager */
     $configManager = app('xe.config');
     $configManager->put('openseminar', ['document_point' => $request->get('document_point'), 'comment_point' => $request->get('comment_point')]);
     return Redirect::to(route('manage.openseminar_1212.index'));
 }
 /**
  * update Common setting
  *
  * @param Request        $request
  * @param CaptchaManager $captcha
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function updateCommon(Request $request, CaptchaManager $captcha)
 {
     $inputs = $request->only(['useCaptcha', 'webmasterName', 'webmasterEmail', 'agreement', 'privacy']);
     if ($inputs['useCaptcha'] === 'true' && !$captcha->available()) {
         throw new ConfigurationNotExistsException();
     }
     app('xe.config')->put('user.common', $inputs);
     return redirect()->back()->with('alert', ['type' => 'success', 'message' => '저장되었습니다.']);
 }
 public function update(Request $request)
 {
     $inputs = $request->all();
     $items = [];
     foreach ($inputs['items'] as $key) {
         $items[] = $key;
     }
     XeConfig::put(Share::CONFIG_NAME, $items);
     return redirect()->to(route('manage.board.share.edit'));
 }
 public function update(Request $request, $provider)
 {
     $inputs = $request->only('activate', 'client_id', 'client_secret', 'title');
     $inputs['activate'] = $inputs['activate'] === 'Y' ? true : false;
     $config = app('xe.config')->get('social_login');
     $providers = $config->get('providers');
     $providers[$provider] = $inputs;
     app('xe.config')->setVal('social_login.providers', $providers);
     $url = route('social_login::settings.provider.show', ['provider' => $provider]);
     return XePresenter::makeApi(['type' => 'success', 'message' => '수정되었습니다.', 'url' => $url, 'provider' => $provider]);
 }
 public function disconnect(Request $request, $provider)
 {
     // execute auth
     $namespace = 'Xpressengine\\Plugins\\SocialLogin\\Authenticators\\';
     $className = $namespace . studly_case($provider) . 'Auth';
     $auth = new $className($provider);
     $param = $auth->getCallbackParameter();
     $hasCode = $request->has($param);
     $auth->disconnect($hasCode);
     return redirect()->back()->with('alert', ['type' => 'success', 'message' => '연결해제 되었습니다']);
 }
 public function postCommonSetting(Request $request)
 {
     $inputs = $request->only(['useCaptcha', 'webmasterName', 'webmasterEmail']);
     if ($inputs['useCaptcha'] === 'true') {
         if (config('captcha.apis.google.siteKey') === null) {
             throw new ConfigurationNotExistsException();
         }
     }
     app('xe.config')->put('member.common', $inputs);
     return redirect()->back()->with('alert', ['type' => 'success', 'message' => '저장되었습니다.']);
 }
 /**
  * update Common setting
  *
  * @param Request $request
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function updateCommon(Request $request)
 {
     $inputs = $request->only(['useCaptcha', 'webmasterName', 'webmasterEmail', 'agreement', 'privacy']);
     if ($inputs['useCaptcha'] === 'true') {
         $driver = config('captcha.driver');
         $captcha = config("captcha.apis.{$driver}.siteKey");
         if (!$captcha) {
             throw new ConfigurationNotExistsException();
         }
     }
     app('xe.config')->put('user.common', $inputs);
     return redirect()->back()->with('alert', ['type' => 'success', 'message' => '저장되었습니다.']);
 }
 public function index(Request $request)
 {
     // filter input
     $field = [];
     $field['component'] = $request->get('component');
     $field['status'] = $request->get('status');
     $field['keyword'] = $request->get('query');
     if ($field['keyword'] === '') {
         $field['keyword'] = null;
     }
     $collection = Plugin::getAllPlugins(true);
     $plugins = $collection->fetch($field);
     $componentTypes = $this->getComponentTypes();
     return Presenter::make('index', ['plugins' => $plugins, 'componentTypes' => $componentTypes]);
 }
Example #10
0
 public function createSetting(Request $request, ThemeHandler $themeHandler)
 {
     $instanceId = $request->get('theme');
     $title = $request->get('title');
     $theme = $themeHandler->getTheme($instanceId);
     $configs = $themeHandler->getThemeConfigList($theme->getId());
     $last = array_pop($configs);
     $lastId = $last->name;
     $prefix = $themeHandler->getConfigId($theme->getId());
     $id = str_replace([$prefix, $themeHandler->configDelimiter], '', $lastId);
     $id = (int) $id + 1;
     $newId = $instanceId . $themeHandler->configDelimiter . $id;
     $themeHandler->setThemeConfig($newId, '_configTitle', $title);
     return redirect()->route('settings.theme.config', ['theme' => $newId])->with('alert', ['type' => 'success', 'message' => '생성되었습니다.']);
 }
 /**
  * Register any application services.
  *
  * @return void
  */
 public function register()
 {
     /** @var \Illuminate\Http\Request $request */
     $request = $this->app['request'];
     if (!$request instanceof \Xpressengine\Http\Request) {
         $this->app->instance('request', \Xpressengine\Http\Request::createFromBase($request));
     }
 }
Example #12
0
 /**
  * get log by name
  * 옵션을 사용하는 Counter 에서 로그를 확인 할 때
  * 등록된 옵션은 제외하고 확인하려고 할 수 있음
  *
  * @param string             $targetId target id
  * @param UserInterface|null $user     user instance
  * @return CounterLog|null
  */
 public function getByName($targetId, UserInterface $user = null)
 {
     if ($this->guest == true && ($user == null || $user instanceof Guest)) {
         return $this->newModel()->where('targetId', $targetId)->where('ipaddress', $this->request->ip())->where('counterName', $this->name)->first();
     } else {
         return $this->newModel()->where('targetId', $targetId)->where('userId', $user->getId())->where('counterName', $this->name)->first();
     }
 }
Example #13
0
 public function handle(Request $request, Closure $next)
 {
     app('events')->listen('locale.changed', function ($locale) {
         app('xe.translator')->setLocale($locale);
     });
     // check locale at request & set locale
     $locale = $request->get('_l');
     if (!$locale) {
         $locale = $request->cookie('locale', app('xe.translator')->getLocale());
     }
     app()->setLocale($locale);
     app('cookie')->queue(cookie()->forever('locale', $locale));
     app('router')->matched(function ($route, $request) use($locale) {
         $key = self::class . '://' . $request->method() . '/' . $route->getPath() . '/' . $locale;
         app('xe.translator')->setCurrentCacheKey($key);
     });
     if ($request->has('xe_use_request_preprocessor') && $this->available()) {
         $this->prepare($request);
     }
     /** @var Response $response */
     $response = $next($request);
     if ($request->has('xe_use_request_preprocessor') && $this->available()) {
         $this->conduct($request);
     }
     return $response;
 }
 public function update(Request $request)
 {
     $config = $request->only(['title', 'mainmenu', 'submenu1', 'submenu1_title', 'submenu2', 'submenu2_title', 'slide_img1', 'slide_img2', 'slide_img3', 'slide_video', 'sub_bg', 'sidemenu2', 'sidemenu_title', 'mode', 'no_snb', 'bg_none', 'header_scroll']);
     $oldConfig = \Theme::getThemeConfig($this->configId);
     // process images
     /** @var \Xpressengine\Storage\Storage $storage */
     $storage = app('xe.storage');
     /** @var MediaManager $media */
     $media = app('xe.media');
     $imageInputs = ['slide_img1', 'slide_img2', 'slide_img3', 'slide_video', 'sub_bg'];
     foreach ($imageInputs as $key) {
         $uploadedFile = array_get($config, $key);
         $configId = $key . 'Id';
         $configPath = $key . 'Path';
         if ($uploadedFile !== null) {
             // remove old logo file
             if (isset($oldConfig[$configId])) {
                 $oldFileId = $oldConfig[$configId];
                 $oldFile = $storage->get($oldFileId);
                 if ($oldFile) {
                     $storage->remove($oldFile);
                 }
             }
             $file = $storage->upload($uploadedFile, Alice::getId(), null, 'plugin');
             $mediaFile = $media->make($file);
             $fileId = $file->getId();
             $filePath = $mediaFile->url();
             $config[$configId] = $fileId;
             $config[$configPath] = $filePath;
         } else {
             $config[$configId] = array_get($oldConfig, $configId);
             $config[$configPath] = array_get($oldConfig, $configPath);
         }
     }
     \Theme::setThemeConfig($this->configId, $config);
     return \Redirect::back()->with('alert', ['type' => 'success', 'message' => '저장되었습니다.']);
 }
 /**
  * set current page
  *
  * @param Request       $request       request
  * @param Handler       $handler       handler
  * @param ConfigHandler $configHandler config handler
  * @param BoardSlug     $slug          slug model
  * @return void
  */
 protected function setCurrentPage(Request $request, Handler $handler, ConfigHandler $configHandler, BoardSlug $slug)
 {
     $instanceId = $slug->instanceId;
     // 이 slug 가 포함된 페이지 출력
     $config = $configHandler->get($instanceId);
     $query = $handler->getModel($config)->where('instanceId', $instanceId)->visible();
     $orderType = $request->get('orderType', '');
     if ($orderType === '' && $config->get('orderType') != null) {
         $orderType = $config->get('orderType', '');
     }
     if ($orderType == '') {
         $query->where('head', '>=', $slug->board->head);
     } elseif ($orderType == 'assentCount') {
         $query->where('assentCount', '>', $slug->board->assentCount)->orWhere(function ($query) use($slug) {
             $query->where('assentCount', '=', $slug->board->assentCount);
             $query->where('head', '>=', $slug->board->head);
         });
     } elseif ($orderType == 'recentlyCreated') {
         $query->where(Board::CREATED_AT, '>', $slug->board->{Board::CREATED_AT})->orWhere(function ($query) use($slug) {
             $query->where(Board::CREATED_AT, '=', $slug->board->{Board::CREATED_AT});
             $query->where('head', '>=', $slug->board->head);
         });
     } elseif ($orderType == 'recentlyUpdated') {
         $query->where(Board::UPDATED_AT, '>', $slug->board->{Board::UPDATED_AT})->orWhere(function ($query) use($slug) {
             $query->where(Board::UPDATED_AT, '=', $slug->board->{Board::UPDATED_AT});
             $query->where('head', '>=', $slug->board->head);
         });
     }
     Event::fire('xe.plugin.board.archive', [$query, $slug->board]);
     $count = $query->count() ?: 1;
     $page = (int) ($count / $config->get('perPage'));
     if ($count % $config->get('perPage') != 0) {
         ++$page;
     }
     $request->query->set('page', $page);
 }
 public function getEdit(Request $request)
 {
     $themeId = $request->get('theme');
     $fileName = $request->get('file');
     $type = $request->get('type', 'template');
     // TODO: validate themeid, fileName
     if ($themeId === null) {
         $e = new InvalidArgumentHttpException();
         $e->setMessage('잘못된 요청입니다.');
         throw $e;
     }
     $theme = \Theme::getTheme($themeId);
     /** @var ThemeEntity $theme */
     $files = $theme->getEditFiles();
     if ($fileName === null) {
         $fileName = key($files[$type]);
     }
     if (!is_writable($files[$type][$fileName])) {
         \View::share('_alert', ['type' => 'danger', 'message' => '파일을 수정할 권한이 없습니다. 웹서버의 계정이 편집할 파일의 쓰기(w)권한을 가지고 있어야 합니다.']);
     }
     $fileContent = file_get_contents($files[$type][$fileName]);
     $editFile = ['fileName' => $fileName, 'path' => $files[$type][$fileName], 'content' => $fileContent];
     return \Presenter::make('theme.edit', ['theme' => $theme, 'files' => $files, 'editFile' => $editFile, 'type' => $type]);
 }
 /**
  * preview
  *
  * @param Request     $request
  * @param PageHandler $pageHandler page handler
  *
  * @return \Xpressengine\Presenter\RendererInterface
  */
 public function preview(Request $request, PageHandler $pageHandler)
 {
     $pageId = $this->pageId;
     $config = $pageHandler->getPageConfig($pageId);
     $user = $request->user();
     /** @var \Illuminate\Http\Request $request */
     $request = app('request');
     $title = $request->get('pageTitle');
     $mode = $request->get('mode');
     $documentInputs = $request->except('_token', 'certifyKey_confirmation', 'anonymity', 'queryString', 'notice', '_codes', '_links', '_hashTags', '_mentions', '_files');
     $previewDoc = new Document($documentInputs);
     $previewDoc->id = 'preview-' . app('xe.keygen')->generate();
     $previewDoc->instanceId = $pageId;
     $previewDoc->user()->associate($user);
     $page = new PageEntity(['pageId' => $pageId, 'uid' => $previewDoc->id, 'content' => $previewDoc]);
     $content = $previewDoc->content;
     return XePresenter::make('show', ['pageId' => $pageId, 'page' => $page, 'title' => $title, 'content' => $content, 'config' => $config]);
 }
Example #18
0
| loading any of our classes later on. It feels nice to relax.
|
*/
require __DIR__ . '/bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = (require_once __DIR__ . '/bootstrap/app.php');
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle($request = \Xpressengine\Http\Request::capture());
$response->send();
$kernel->terminate($request, $response);
 /**
  * destroy
  *
  * @return \Xpressengine\Presenter\RendererInterface
  */
 public function destroy(Request $request)
 {
     /**
      * @var \Xpressengine\DynamicField\DynamicFieldHandler $dynamicField
      */
     $dynamicField = app('xe.dynamicField');
     /**
      * @var \Xpressengine\DynamicField\ConfigHandler $configHandler
      */
     $configHandler = $dynamicField->getConfigHandler();
     $config = $configHandler->get($request->get('group'), $request->get('id'));
     $dynamicField->setConnection(XeDB::connection($request->get('databaseName')));
     $dynamicField->drop($config);
     return XePresenter::makeApi(['id' => $request->get('id')]);
 }
Example #20
0
<?php

use Xpressengine\Http\Request;
/*
 * Define Xpressengine Version
 */
if (!defined('__XE_VERSION__')) {
    define('__XE_VERSION__', '3.0.0-beta.9');
}
/*
 * Set RequestFactory so that make all of generated request to Xpressengine's request
 * Request에 RequestFactory를 지정한다.
 * XE에서 새로운 request가 생성될 때에는 이 ReqeustFactory는 사용되어 항상 Xpressengine\Http\Request를 생성하도록 한다
 */
Request::setFactory(function ($query, $request, $attributes, $cookies, $files, $server, $content) {
    return new Request($query, $request, $attributes, $cookies, $files, $server, $content);
});
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/
$app = new Illuminate\Foundation\Application(realpath(__DIR__ . '/../'));
/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
 /**
  * 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([]);
 }
Example #22
0
 /**
  * delete group
  *
  * @param Request $request
  *
  * @return \Illuminate\Http\RedirectResponse
  * @throws Exception
  */
 public function destroy(Request $request)
 {
     $groupIds = $request->get('id');
     $joinConfig = \app('xe.config')->get('user.join');
     $joinGroup = $joinConfig->get('joinGroup');
     $groups = $this->groups->query()->whereIn('id', $groupIds)->get();
     XeDB::beginTransaction();
     try {
         foreach ($groups as $group) {
             if ($joinGroup !== $group->id) {
                 $this->groups->delete($group);
             }
         }
     } catch (Exception $e) {
         XeDB::rollBack();
         throw $e;
     }
     XeDB::commit();
     return redirect()->back()->with('alert', ['type' => 'success', 'message' => '삭제되었습니다.']);
 }
Example #23
0
 /**
  * 인터셥센을 이용해 서드파티가 처리할 수 있도록 메소드 사용
  *
  * @param Builder      $query   board model query builder
  * @param Request      $request request
  * @param ConfigEntity $config  board config entity
  * @return Builder
  */
 public function makeOrder(Builder $query, Request $request, ConfigEntity $config)
 {
     $orderType = $request->get('orderType', '');
     if ($orderType === '' && $config->get('orderType') != null) {
         $orderType = $config->get('orderType', '');
     }
     if ($orderType == '') {
         $query->orderBy('head', 'desc');
     } elseif ($orderType == 'assentCount') {
         $query->orderBy('assentCount', 'desc')->orderBy('head', 'desc');
     } elseif ($orderType == 'recentlyCreated') {
         $query->orderBy(Board::CREATED_AT, 'desc')->orderBy('head', 'desc');
     } elseif ($orderType == 'recentlyUpdated') {
         $query->orderBy(Board::UPDATED_AT, 'desc')->orderBy('head', 'desc');
     }
     $query->getProxyManager()->orders($query->getQuery(), $request->all());
     return $query;
 }
 /**
  * 멘션 suggestion 리스트
  *
  * @param Request $request
  * @return mixed
  */
 public function mention(Request $request)
 {
     $suggestions = [];
     $string = $request->get('string');
     $users = User::where('displayName', 'like', $string . '%')->where('id', '<>', Auth::user()->getId())->get();
     foreach ($users as $user) {
         $suggestions[] = ['id' => $user->getId(), 'displayName' => $user->getDisplayName(), 'profileImage' => $user->profileImage];
     }
     return XePresenter::makeApi($suggestions);
 }
 /**
  * get voted user list
  *
  * @param Request $request
  * @param $menuUrl
  * @param $option
  * @param $id
  * @return mixed
  */
 public function votedUserList(Request $request, $menuUrl, $option, $id)
 {
     $startId = $request->get('startId');
     $limit = $request->get('limit', 10);
     $item = $this->handler->getModel($this->config)->find($id);
     $this->handler->setModelConfig($item, $this->config);
     $counter = $this->handler->getVoteCounter();
     $logModel = $counter->newModel();
     $query = $logModel->where('counterName', $counter->getName())->where('targetId', $id)->where('counterOption', $option);
     if ($startId != null) {
         $query->where('id', '<', $startId);
     }
     $logs = $query->orderBy('id', 'desc')->take($limit)->get();
     $list = [];
     foreach ($logs as $log) {
         /** @var User $user */
         $user = $log->user;
         $profilePage = '#';
         if ($user->getId() != '') {
             $profilePage = route('member.profile', ['member' => $user->getId()]);
         }
         $list[] = ['id' => $user->getId(), 'displayName' => $user->getDisplayName(), 'profileImage' => $user->getProfileImage(), 'createdAt' => (string) $log->createdAt, 'profilePage' => $profilePage];
     }
     $nextStartId = 0;
     if (count($logs) == $limit) {
         $nextStartId = $logs->last()->id;
     }
     return XePresenter::makeApi(['item' => $item, 'list' => $list, 'nextStartId' => $nextStartId]);
 }
Example #26
0
 /**
  * setInstanceConfig
  *
  * @param InstanceRoute $instanceRoute instance route
  * @param XeRequest     $request       xpressengine request
  *
  * @return void
  */
 private function setInstanceConfig(InstanceRoute $instanceRoute, XeRequest $request)
 {
     $item = $this->menuHandler->getItem($instanceRoute->instanceId);
     $menuConfig = $this->menuHandler->getMenuItemTheme($item);
     if ($request->isMobile()) {
         $theme = $menuConfig->get('mobileTheme');
     } else {
         $theme = $menuConfig->get('desktopTheme');
     }
     $instanceId = $instanceRoute->instanceId;
     $module = $instanceRoute->module;
     $url = $instanceRoute->url;
     $instanceConfig = InstanceConfig::instance();
     $instanceConfig->setTheme($theme);
     $instanceConfig->setInstanceId($instanceId);
     $instanceConfig->setModule($module);
     $instanceConfig->setUrl($url);
     $themeHandler = $this->themeHandler;
     $themeHandler->selectTheme($theme);
 }
 public function updatePermission(PermissionHandler $permissionHandler, Request $request, $permissionId)
 {
     $permissionHandler->register($permissionId, $this->createAccessGrant($request->only(['accessRating', 'accessGroup', 'accessUser', 'accessExcept'])));
     return redirect()->back()->with('alert', ['type' => 'success', 'message' => '저장되었습니다.']);
 }
 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());
 }
 public function storeCategory(Request $request, CategoryHandler $categoryHandler)
 {
     $input = ['name' => $request->get('categoryName')];
     $category = $categoryHandler->create($input);
     return XePresenter::makeApi($category->getAttributes());
 }