Author: XE Developers (developers@xpressengine.com)
Inheritance: extends Xpressengine\Support\Entity, implements IteratorAggregat\IteratorAggregate
 public function set(array $data)
 {
     $this->config = $this->cfg->set($this->key, $data);
     if (!$this->config->get('uuid')) {
         $this->config->set('uuid', $this->keygen->generate());
         $this->cfg->modify($this->config);
     }
 }
Beispiel #2
0
 /**
  * Dynamic Field 설정 페이지에서 각 fieldType 에 필요한 설정 등록 페이지 반환
  * return html tag string
  *
  * @param ConfigEntity $config config entity
  * @return string
  */
 public function getSettingsView(ConfigEntity $config = null)
 {
     $category = null;
     if ($config != null) {
         $category = CategoryModel::find($config->get('categoryId'));
     }
     XeFrontend::rule('dynamicFieldSection', $this->getSettingsRules());
     return View::make('dynamicField/category/createType', ['config' => $config, 'category' => $category])->render();
 }
 public function index()
 {
     /** @var \Xpressengine\Config\ConfigManager $configManager */
     $configManager = app('xe.config');
     $config = $configManager->get('openseminar');
     if ($config === null) {
         $config = new ConfigEntity();
         $config->set('document_point', 2);
         $config->set('comment_point', 1);
         $configManager->add('openseminar', $config->getPureAll());
     }
     return XePresenter::make('openseminar_1212::views.manager.index', ['config' => $config]);
 }
 /**
  * 전달된 rule 에 다이나믹필드 의 rule 을 추가해서 반환
  *
  * @param ConfigEntity $config board config entity
  * @param array        $rules  rule
  * @return array
  */
 public function makeRule(ConfigEntity $config, array $rules = null)
 {
     if ($rules === null) {
         $rules = $this->basic();
     }
     if ($config->get('category') === true) {
         $rules = array_merge($rules, $this->category());
     }
     // add dynamic field rule
     /** @var \Xpressengine\Config\ConfigEntity $dynamicFieldConfig */
     foreach ($this->configHandler->getDynamicFields($config) as $dynamicFieldConfig) {
         /** @var \Xpressengine\DynamicField\AbstractType $type */
         $rules = array_merge($rules, $this->dynamicField->getRules($dynamicFieldConfig));
     }
     return $rules;
 }
Beispiel #5
0
 /**
  * inputs
  *
  * @param ConfigEntity $config board config entity
  * @param array        $inputs request parameters
  * @param array        $wheres 검색 조건
  * @param array        $addons 정렬 조건
  * @return void
  */
 public function make(ConfigEntity $config, array $inputs, array &$wheres, array &$addons)
 {
     $addons = [];
     $boardAddon = null;
     if (empty($inputs['orderType'])) {
         $boardAddon = $this->get($config->get('addon'));
     } else {
         $boardAddon = $this->get($inputs['addonType']);
     }
     if ($boardAddon !== null) {
         $boardAddon->make($wheres, $addons);
     } else {
         // 어떤 걸로 하면 decode 했을 때 array 가 될 수 있는걸 문자열로 넘길 수있나
         // $inputs['addonType'] 으로 $addons 를 변환 할 수 있나
     }
 }
Beispiel #6
0
 /**
  * inputs
  *
  * @param ConfigEntity $config board config entity
  * @param array        $inputs request parameters
  * @param array        $wheres 검색 조건
  * @param array        $orders 정렬 조건
  * @return void
  */
 public function make(ConfigEntity $config, array $inputs, array &$wheres, array &$orders)
 {
     $orders = [];
     $boardOrder = null;
     if (empty($inputs['orderType'])) {
         $boardOrder = $this->get($config->get('order'));
     } else {
         $boardOrder = $this->get($inputs['orderType']);
     }
     if ($boardOrder !== null) {
         $boardOrder->make($wheres, $orders);
     } else {
         // 어떤 걸로 하면 decode 했을 때 array 가 될 수 있는걸 문자열로 넘길 수있나
         // $inputs['orderType'] 으로 $orders 를 변환 할 수 있나
     }
 }
 /**
  * get slug url by document id
  * document 에서 지원하는 slug 주소 반환
  *
  * @param string $id document id
  * @return string
  */
 public function getSlugById($id)
 {
     $slug = Slug::where(id, $id)->where('instanceId', $this->config->get('boardId'));
     if ($slug === null) {
         return '';
     }
     return $this->getSlug($slug->slug);
 }
Beispiel #8
0
 /**
  * get slug url by document id
  * document 에서 지원하는 slug 주소 반환
  *
  * @param string $id document id
  * @return string
  */
 public function getSlugById($id)
 {
     $slug = $this->slug->findById($id, $this->config->get('boardId'));
     if ($slug === null) {
         return '';
     }
     return $this->getSlug($slug->slug);
 }
 /**
  * 리스트에서 검색할 때 검색 form 에 사용될 html 코드 반환
  * return html tag string
  *
  * @param array $args arguments
  * @return string
  */
 public function search(array $args)
 {
     if ($this->config->get('searchable') !== true) {
         return '';
     }
     list($data, $key) = $this->filter($args);
     $viewFactory = $this->handler->getViewFactory();
     return $viewFactory->make($this->getViewPath('search'), ['config' => $this->config, 'data' => array_merge($data, $this->mergeData), 'key' => $key])->render();
 }
 /**
  * make hierarchy to upper
  *
  * @param ConfigEntity $ancestor config object
  * @return void
  * @throws NoParentException
  */
 public function setParent(ConfigEntity $ancestor)
 {
     if ($this->isAdjacency($ancestor->name, $this->name)) {
         $this->parent = $ancestor;
     } else {
         if (is_null($this->parent)) {
             throw new NoParentException();
         }
         $this->parent->setParent($ancestor);
     }
 }
 /**
  * 투표 정보
  *
  * @param Request $request request
  * @return \Xpressengine\Presenter\RendererInterface
  */
 public function showVote(Request $request, $id)
 {
     // display 설정
     $display = ['assent' => true, 'dissent' => true];
     if ($this->config->get('assent') !== true) {
         $display['assent'] = false;
     }
     if ($this->config->get('dissent') !== true) {
         $display['dissent'] = false;
     }
     $user = Auth::user();
     $board = $this->handler->getModel($this->config)->find($id);
     $this->handler->setModelConfig($board, $this->config);
     $voteCounter = $this->handler->getVoteCounter();
     $vote = $voteCounter->getByName($id, $user);
     return XePresenter::makeApi(['display' => $display, 'id' => $id, 'counts' => ['assent' => $board->assentCount, 'dissent' => $board->dissentCount], 'voteAt' => $vote['counterOption']]);
 }
 /**
  * 투표 정보
  *
  * @param $boardId
  * @return \Xpressengine\Presenter\RendererInterface
  */
 public function showVote($boardId)
 {
     // display 설정
     $display = ['assent' => true, 'dissent' => true];
     if ($this->config->get('assent') !== true) {
         $display['assent'] = false;
     }
     if ($this->config->get('dissent') !== true) {
         $display['dissent'] = false;
     }
     $id = Input::get('id');
     $author = Auth::user();
     $voteHandler = app('xe.board.vote');
     $counts = $voteHandler->count($id);
     $vote = $voteHandler->get($id, $author);
     return Presenter::makeApi(['display' => $display, 'id' => $id, 'counts' => $counts, 'voteAt' => $vote['counterOption']]);
 }
 /**
  * 생성된 Dynamic Field revision 테이블에 데이터 입력
  *
  * @param array $args parameters
  * @return void
  */
 public function insertRevision(array $args)
 {
     if (isset($args['id']) === false) {
         throw new Exceptions\RequiredDynamicFieldException();
     }
     $insertParam = [];
     $insertParam['dynamicFieldTargetId'] = $args['id'];
     $insertParam['revisionId'] = $args['revisionId'];
     $insertParam['revisionNo'] = $args['revisionNo'];
     foreach ($this->getColumns() as $column) {
         $key = camel_case($this->config->get('id') . '_' . $column->name);
         if ($this->config->get('required') && (isset($args[$key]) === false || $args[$key] === '')) {
             throw new Exceptions\RequiredDynamicFieldException(['key' => $key]);
         }
         if (isset($args[$key])) {
             $insertParam[$key] = $args[$key];
         }
     }
     $this->handler->connection()->table($this->handler->getConfigHandler()->getRevisionTableName($this->config))->insert($insertParam);
 }
 /**
  * Get an iterator for the items.
  *
  * @return ArrayIterator
  */
 public function getIterator()
 {
     $parentAttributes = $this->parent !== null ? $this->parent->getIterator()->getArrayCopy() : [];
     return new ArrayIterator(array_merge($parentAttributes, $this->vo->getAttributes()));
 }
 /**
  * get rules by dynamic field config entity
  *
  * @param ConfigEntity $config dynamic field config entity
  * @return array
  */
 public function getRules(ConfigEntity $config)
 {
     // 필수 입력이 아니면 처리하지 않음
     if ($config->get('required') === false) {
         return [];
     }
     $type = $this->getByConfig($config);
     $rules = [];
     foreach ($type->getRules() as $columnName => $rule) {
         $key = camel_case($config->get('id') . '_' . $columnName);
         $rules[$key] = $rule;
     }
     return $rules;
 }
 /**
  * update document instance config
  * * Cannot changed 'division', 'revision' configure.
  *
  * @param ConfigEntity $config document instance config
  * @return ConfigEntity
  */
 public function put(ConfigEntity $config)
 {
     if ($this->get($config->get('instanceId')) === null) {
         throw new ConfigNotFoundException(['instanceId' => $config->get('instanceId')]);
     }
     $this->configManager->put(sprintf('%s.%s', self::CONFIG_NAME, $config->get('instanceId')), $config->getPureAll());
     return $config;
 }
Beispiel #17
0
 /**
  * Move entity hierarchy to new parent or root
  *
  * @param ConfigEntity $config config object
  * @param string|null  $to     parent name
  * @return ConfigEntity
  * @throws InvalidArgumentException
  * @throws NoParentException
  */
 public function move(ConfigEntity $config, $to = null)
 {
     if ($to !== null && $this->repo->find($config->siteKey, $to) === null) {
         throw new InvalidArgumentException(['arg' => $to]);
     }
     $parent = $config->getParent();
     if ($parent === null) {
         if ($config->getDepth() !== 1) {
             throw new NoParentException();
         }
         $this->repo->affiliate($config, $to);
     } else {
         $this->repo->foster($config, $to);
     }
     $arrName = explode('.', $config->name);
     $key = array_pop($arrName);
     if ($to !== null) {
         $key = $to . '.' . $key;
     }
     return $this->get($key, false, $config->siteKey);
 }
 /**
  * createDocumentInstance
  *
  * @param string $pageId    page instance id
  * @param string $pageTitle page title
  *
  * @return void
  */
 protected function createDocumentInstance($pageId, $pageTitle)
 {
     $documentConfig = new ConfigEntity();
     $documentConfig->set('instanceId', $pageId);
     $documentConfig->set('instanceName', $pageTitle);
     $this->document->getInstanceManager()->add($documentConfig);
 }
Beispiel #19
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;
 }
Beispiel #20
0
 /**
  * set config
  *
  * @param ConfigEntity $config document config entity
  * @param string|null  $table  table name
  * @return void
  */
 public function setConfig(ConfigEntity $config, $table = null)
 {
     $this->config = $config;
     $this->division = $config->get('division');
     $this->setProxyOptions(['id' => $config->get('instanceId'), 'group' => $config->get('group')]);
     if ($table !== null) {
         $this->table = $table;
     }
 }
 /**
  * get database proxy options
  *
  * @param ConfigEntity $config config entity
  * @return array
  */
 public function proxyOption(ConfigEntity $config = null)
 {
     $options = [];
     if ($config != null) {
         $options['id'] = $config->get('instanceId');
     }
     return $options;
 }
 /**
  * get type by dynamic field config entity
  *
  * @param ConfigEntity $config dynamic field config entity
  * @return AbstractType
  */
 public function getByConfig(ConfigEntity $config)
 {
     $type = $this->registerHandler->getType($this, $config->get('typeId'));
     $type->setConfig($config);
     $skin = $this->registerHandler->getSkin($this, $config->get('skinId'));
     $skin->setConfig($config);
     $type->setSkin($skin);
     return $type;
 }
 /**
  * division table 이름 반환
  *
  * @param ConfigEntity $config config entity
  * @return string
  */
 public function divisionTable(ConfigEntity $config = null)
 {
     $table = $this->table;
     if ($config != null && $config->get('division') === true) {
         $table = sprintf('%s_division_%s', $this->table, $config->get('instanceId'));
     }
     return $table;
 }
 /**
  * board config 에서 extension class 반환
  *
  * @param ConfigEntity $config board config entity
  * @return array
  */
 public function gets(ConfigEntity $config)
 {
     $names = $config->get('extensions');
     $classes = [];
     if (count($names) > 0) {
         foreach ($names as $name) {
             $className = '\\' . $name;
             $classes[] = new $className();
         }
     }
     return $classes;
 }
 /**
  * get dynamic field config list
  *
  * @param ConfigEntity $config board config entity
  * @return array
  */
 public function getDynamicFields(ConfigEntity $config)
 {
     $configs = $this->dynamicField->gets($config->get('documentGroup'));
     if (count($configs) == 0) {
         return [];
     }
     return $configs;
 }
 /**
  * Get activated tool's identifier for the editor
  *
  * @return array
  */
 public function getActivateToolIds()
 {
     return $this->config->get('tools', []);
 }
 /**
  * 생성된 Dynamic Field 가 테이블 생성 방식인지 확인
  *
  * @param ConfigEntity $config config entity
  * @return bool
  */
 public function isTableMethodCreate(ConfigEntity $config)
 {
     return $config->get('tableMethod') === self::CREATE_TABLE_METHOD;
 }
 /**
  * update document instance config
  * * division, revision 설정 변경 불가.
  *      - 이 설정에 대한 변경은 core 에서 제공 안함.
  *
  * @param ConfigEntity $config document instance config
  * @return ConfigEntity
  */
 public function put(ConfigEntity $config)
 {
     if ($this->get($config->get('instanceId')) === null) {
         throw new Exceptions\ConfigException();
     }
     $diff = $config->diff();
     if (isset($diff['instanceId']) === null) {
         throw new Exceptions\ConfigException();
     }
     $this->configManager->put(sprintf('%s.%s', self::CONFIG_NAME, $config->get('instanceId')), $config->getPureAll());
     return $config;
 }
 /**
  * update
  *
  * @param ConfigEntity $config config object
  *
  * @return ConfigEntity
  */
 protected function update(ConfigEntity $config)
 {
     $diff = $config->getDirty();
     if (count($diff) > 0) {
         $this->conn->table($this->table)->where('siteKey', $config->siteKey)->where('name', $config->name)->update($diff);
     }
     return $this->createModel(array_merge($config->getOriginal(), $diff));
 }
 /**
  * drop document instance
  *
  * @param ConfigEntity $config 현제 설정 되어 있는 config
  * @return void
  */
 protected function dropDivisionTable(ConfigEntity $config)
 {
     if ($config->get('division') === true) {
         $this->connection->getSchemaBuilder()->drop(sprintf("%s%s", $this->connection->getTablePrefix(), $this->getDivisionTableName($config)));
     }
 }