/** * setting * * @param VirtualConnectionInterface $conn database connection * @param bool $revision 리비전 처리 * @return \Illuminate\View\View */ public function setting(VirtualConnectionInterface $conn, $revision = false) { /** @var \Xpressengine\DynamicField\DynamicFieldHandler $dynamicField */ $dynamicField = app('xe.dynamicField'); $parent = $dynamicField->getConfigHandler()->parent($this->group); $configs = []; if ($parent !== null) { /** * @var ConfigEntity $config */ foreach (Cfg::children($parent) as $config) { if ($config->get('use') === true) { $configs[$config->get('id')] = $config; } } } /** * @var \Xpressengine\DynamicField\RegisterHandler $registerHandler */ $dynamicFieldHandler = app('xe.dynamicField'); $registerHandler = $dynamicFieldHandler->getRegisterHandler(); $types = $registerHandler->getTypes($dynamicFieldHandler); $fieldTypes = []; foreach ($types as $types) { $fieldTypes[] = $types; } \Frontend::rule('dynamicFieldSection', $this->getRules()); return View::make('dynamicField.setting', ['databaseName' => $conn->getName(), 'group' => $this->group, 'configs' => $configs, 'fieldTypes' => $fieldTypes, 'revision' => $revision]); }
/** * countByInstanceId * * @param string $instanceId instance Id * @param callable $filter filter * * @return int */ public function countByInstanceId($instanceId, callable $filter = null) { $query = $this->conn->table($this->table)->where('instanceId', '=', $instanceId); if ($filter !== null) { $query->where($filter); } return $query->count(); }
/** * affiliated to another registered * * @param Permission $item permission instance * @param string $to parent name * * @return void */ public function affiliate(Permission $item, $to) { if ($to !== null) { $this->conn->table($this->table)->where('siteKey', $item->siteKey)->where(function ($query) use($item) { $query->where('name', $item->name)->orWhere('name', 'like', $item->name . '.%'); })->update(['name' => $this->conn->raw("concat('{$to}', '.', `name`)")]); } }
/** * document 의 덧글 리스트 반환 * * @param DocumentEntity $doc document entity * @return array */ public function getReplies(DocumentEntity $doc) { $query = $this->connection->table($this->table)->where('head', $doc->head); if ($doc->reply != null) { $query = $query->where('reply', 'like', $doc->reply . '%'); } return $query->get(); }
/** * affiliated to another config * * @param ConfigEntity $config config object * @param string|null $to parent name * * @return void */ public function affiliate(ConfigEntity $config, $to = null) { if ($to !== null) { $this->conn->table($this->table)->where('siteKey', $config->siteKey)->where(function ($query) use($config) { $query->where('name', $config->name)->orWhere('name', 'like', $config->name . '.%'); })->update(['name' => $this->conn->raw("concat('{$to}', '.', `name`)")]); } }
/** * DynamicField 제거 * * @param ConfigEntity $config config entity * @return void */ public function drop(ConfigEntity $config) { $this->connection->beginTransaction(); $this->configHandler->remove($config); $type = $this->registerHandler->getType($this, $config->get('typeId')); $type->setConfig($config); $type->drop(); $this->connection->commit(); }
/** * fetch slugs * * @param string|array $ids ids * @param string|array $instanceIds instance ids * @return SlugEntity[] */ public function fetchByIdsInstanceIds($ids, $instanceIds) { $slugs = $this->connection->table($this->table)->whereIn('id', $ids)->whereIn('instanceId', $instanceIds)->get(); foreach ($slugs as $key => $row) { $slugs[$key] = new SlugEntity($row); $this->putCache($slugs[$key]); } return $slugs; }
/** * get proxy manager * * @return ProxyManager|null */ public function getProxyManager() { if ($this->dynamic === false) { return null; } $proxyManager = $this->connector->getProxyManager(); $proxyManager->set($this->connector, $this->options); return $proxyManager; }
/** * userId 리스트 반환 * 최근 counter log에 insert 된 userId 를 보기 위해 * * @param array $wheres make where query list * @param array $orders make order query list * @param int $limit number of list * @return mixed */ public function fetchByUserIds(array $wheres, array $orders, $limit = null) { $query = $this->conn->table($this->table); $query = $this->wheres($query, $wheres); $query = $this->orders($query, $orders); if ($limit !== null) { $query = $query->take($limit); } return $query->lists('userId'); }
/** * Retrieve the "count" result of the query by groupBy * * @param string $groupBy groupBy column * @param array $wheres where clause * @return array groupBy => count format */ public function countGroupBy($groupBy, array $wheres = []) { $rows = $this->buildWhere($this->conn->table($this->table), $wheres)->selectRaw("`{$groupBy}`, count(*) as cnt")->groupBy($groupBy)->get(); $array = []; foreach ($rows as $row) { $row = (array) $row; $array[$row[$groupBy]] = $row['cnt']; } return $array; }
/** * Specific word used target information * * return sample * ['freeboard' => ['xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx']] * * @param string $word specific word * @param string $instanceId instance id * @return array */ public function getUsed($word, $instanceId) { $query = $this->conn->table($this->usedTable . ' as used')->leftJoin($this->itemTable . ' as item', 'used.itemId', '=', 'item.id')->select(['item.instanceId', 'used.targetId'])->where('item.word', $word); if ($instanceId !== null) { $query->where('item.instanceId', $instanceId); } $rows = $query->get(); $data = []; foreach ($rows as $row) { $row = (array) $row; if (isset($data[$row['instanceId']]) !== true) { $data[$row['instanceId']] = []; } $data[$row['instanceId']][] = $row['targetId']; } return empty($data) ? $data : ($instanceId === null ? $data : array_pop($data)); }
/** * fetch node list tree type * * @param NodeInterface $top node instance * @param int $depth want get depth * * @return TreeCollection */ public function fetchTree(NodeInterface $top, $depth = 0) { $prefix = $this->conn->getTablePrefix(); $query = $this->conn->table($this->nodeTable . " as t")->selectRaw("{$prefix}t.*, {$prefix}h.`depth`, GROUP_CONCAT({$prefix}crumbs.`ancestor` " . "order by {$prefix}crumbs.`depth` desc) AS breadcrumbs")->join($this->hierarchyTable . ' as h', 't.id', '=', 'h.descendant')->join($this->hierarchyTable . ' as crumbs', 'crumbs.descendant', '=', 'h.descendant')->where('h.ancestor', $top->id); if ($depth > 0) { $query->where('h.depth', '<', $depth); } $rows = $query->groupBy('t.id')->orderBy('breadcrumbs')->orderBy('t.ordering')->get(); $nodes = []; foreach ($rows as $row) { $row = (array) $row; $node = $this->createNodeModel(array_diff_key($row, array_flip(['depth', 'breadcrumbs']))); $node->setdepth($row['depth']); $node->setTreeNodePath($row['breadcrumbs']); $nodes[$node->id] = $node; } return new TreeCollection($nodes); }
/** * 게시판 제거 * * @param string $boardId board id * @return void */ public function destroy($boardId) { $config = $this->configHandler->get($boardId); if ($config === null) { throw new Exceptions\InvalidConfigException(); } $this->conn->beginTransaction(); // get document config $this->document->destroyInstance($boardId); $this->comment->drop($boardId); // remove board config $this->configHandler->remove($config); // 연결된 df 제거 foreach ($this->configHandler->getDynamicFields($config) as $config) { $this->dynamicField->drop($config); } $this->conn->commit(); }
/** * Get the evaluated contents of the object. * * @return string */ public function render() { /** @var \Xpressengine\DynamicField\DynamicFieldHandler $dynamicField */ $dynamicField = app('xe.dynamicField'); $parent = $dynamicField->getConfigHandler()->parent($this->group); $configs = []; if ($parent !== null) { /** * @var ConfigEntity $config */ foreach (XeConfig::children($parent) as $config) { if ($config->get('use') === true) { $configs[$config->get('id')] = $config; } } } /** * @var \Xpressengine\DynamicField\RegisterHandler $registerHandler */ $dynamicFieldHandler = app('xe.dynamicField'); $registerHandler = $dynamicFieldHandler->getRegisterHandler(); $types = $registerHandler->getTypes($dynamicFieldHandler); $fieldTypes = []; foreach ($types as $types) { $fieldTypes[] = $types; } XeFrontend::rule('dynamicFieldSection', static::getRules()); // 다국어 입력 필드 XeFrontend::js('/assets/vendor/jqueryui/jquery-ui.js')->appendTo('head')->load(); XeFrontend::css('/assets/vendor/jqueryui/jquery-ui.css')->load(); XeFrontend::js('/assets/vendor/expanding/expanding.js')->appendTo('head')->load(); // XeFrontend::js('/assets/vendor/vendor.bundle.js')->appendTo('head')->load(); XeFrontend::js('/assets/core/lang/langEditorBox.bundle.js')->appendTo('head')->load(); XeFrontend::css('/assets/core/lang/langEditorBox.css')->load(); XeFrontend::css('/assets/core/xe-ui-component/xe-ui-component.css')->load(); return View::make('dynamicField.setting', ['databaseName' => $this->conn->getName(), 'group' => $this->group, 'configs' => $configs, 'fieldTypes' => $fieldTypes, 'revision' => $this->revision]); }
/** * drop document instance * * ex) 게시판 삭제 * * @param ConfigEntity $config 현제 설정 되어 있는 config * @return void */ public function dropDivisionTable(ConfigEntity $config) { if ($config->get('division') === true) { $this->connection->delete(sprintf("DROP TABLE `%s%s`", $this->connection()->getTablePrefix(), $this->document->divisionTable($config))); } }
/** * 같은 depth 에 가장 마지막 자식노드의 reply 코드 값 * * @param CommentEntity $comment comment object * @return string */ public function getLastChildReply(CommentEntity $comment) { $reply = $this->conn->table($this->table)->where('head', $comment->head)->where('reply', 'like', $comment->reply . str_repeat('_', CommentEntity::getReplyCharlen()))->max('reply'); return $reply; }
/** * delete document * * @param Document $doc document model * @return bool */ public function remove(Document $doc) { $this->conn->beginTransaction(); $result = $doc->delete(); $this->conn->commit(); return $result; }
/** * 임시저장 데이터 삭제 * * @param DraftEntity $draft 임시저장 객체 * @return int 삭제된 레코드 수(정상적인 경우 '1') */ public function delete(DraftEntity $draft) { return $this->conn->table($this->table)->where('id', $draft->id)->delete(); }
/** * delete revision by document id * * @param string $id document id * @return void */ public function deleteByDocumentId($id) { $this->connection->table($this->table)->where('id', $id)->delete(); }
/** * 임시저장 데이터 삭제 * * @param TemporaryEntity $temporary 임시저장 객체 * @return int 삭제된 레코드 수(정상적인 경우 '1') */ public function delete(TemporaryEntity $temporary) { return $this->conn->table($this->table)->where('id', $temporary->id)->delete(); }
/** * Delete by origin * * @param string $originId origin id * @return int */ public function deleteByOriginId($originId) { return $this->conn->table($this->table)->where('originId', $originId)->delete(); }
/** * Delete * * @param Meta $meta meta instance * @return int */ public function delete(Meta $meta) { return $this->conn->table($this->table)->where('id', $meta->id)->delete(); }
/** * instance 내 모든 데이터 삭제 * * @param string $instanceId instance identifier * @return void */ public function dropInstance($instanceId) { $this->conn->table($this->table)->where('instanceId', $instanceId)->delete(); }
/** * 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))); } }
/** * get last table record * * @return array|null */ private function lastRecord() { $row = $this->conn->table($this->table)->orderBy('createdAt', 'desc')->first(); return $row ? (array) $row : null; }
/** * count * * @param string $host site unique host * * @return int */ public function count($host) { return $this->conn->table($this->table)->where('host', $host)->count(); }
/** * drop document instance * * @param ConfigEntity $config 현제 설정 되어 있는 config * @return void */ protected function dropDivisionTable(ConfigEntity $config) { if ($config->get('division') === true) { $this->connection->getSchemaBuilder()->drop($this->getDivisionTableName($config)); } }