repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
luyadev/luya-module-admin | src/ngrest/base/actions/IndexAction.php | IndexAction.prepareDataProvider | protected function prepareDataProvider()
{
$requestParams = Yii::$app->getRequest()->getBodyParams();
if (empty($requestParams)) {
$requestParams = Yii::$app->getRequest()->getQueryParams();
}
$filter = null;
if ($this->dataFilter !== null) {
$this->dataFilter = Yii::createObject($this->dataFilter);
if ($this->dataFilter->load($requestParams)) {
$filter = $this->dataFilter->build();
if ($filter === false) {
return $this->dataFilter;
}
}
}
$query = call_user_func($this->prepareActiveDataQuery);
if (!empty($filter)) {
$query->andWhere($filter);
}
$dataProvider = Yii::createObject([
'class' => ActiveDataProvider::class,
'query' => $query,
'pagination' => $this->controller->pagination,
'sort' => [
'attributes' => $this->controller->generateSortAttributes($this->controller->model->getNgRestConfig()),
'params' => $requestParams,
],
]);
if ($this->isCachable() && $this->controller->cacheDependency) {
Yii::$app->db->cache(function () use ($dataProvider) {
$dataProvider->prepare();
}, 0, Yii::createObject($this->controller->cacheDependency));
}
return $dataProvider;
} | php | protected function prepareDataProvider()
{
$requestParams = Yii::$app->getRequest()->getBodyParams();
if (empty($requestParams)) {
$requestParams = Yii::$app->getRequest()->getQueryParams();
}
$filter = null;
if ($this->dataFilter !== null) {
$this->dataFilter = Yii::createObject($this->dataFilter);
if ($this->dataFilter->load($requestParams)) {
$filter = $this->dataFilter->build();
if ($filter === false) {
return $this->dataFilter;
}
}
}
$query = call_user_func($this->prepareActiveDataQuery);
if (!empty($filter)) {
$query->andWhere($filter);
}
$dataProvider = Yii::createObject([
'class' => ActiveDataProvider::class,
'query' => $query,
'pagination' => $this->controller->pagination,
'sort' => [
'attributes' => $this->controller->generateSortAttributes($this->controller->model->getNgRestConfig()),
'params' => $requestParams,
],
]);
if ($this->isCachable() && $this->controller->cacheDependency) {
Yii::$app->db->cache(function () use ($dataProvider) {
$dataProvider->prepare();
}, 0, Yii::createObject($this->controller->cacheDependency));
}
return $dataProvider;
} | [
"protected",
"function",
"prepareDataProvider",
"(",
")",
"{",
"$",
"requestParams",
"=",
"Yii",
"::",
"$",
"app",
"->",
"getRequest",
"(",
")",
"->",
"getBodyParams",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"requestParams",
")",
")",
"{",
"$",
"r... | Prepare the data models based on the ngrest find query.
{@inheritDoc}
@see \yii\rest\IndexAction::prepareDataProvider() | [
"Prepare",
"the",
"data",
"models",
"based",
"on",
"the",
"ngrest",
"find",
"query",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/base/actions/IndexAction.php#L36-L76 | train |
luyadev/luya-module-admin | src/apis/ProxyController.php | ProxyController.actionIndex | public function actionIndex($identifier, $token)
{
$machine = ProxyMachine::findOne(['identifier' => $identifier, 'is_deleted' => false]);
if (!$machine) {
throw new ForbiddenHttpException("Unable to acccess the proxy api.");
}
if (sha1($machine->access_token) !== $token) {
throw new ForbiddenHttpException("Unable to acccess the proxy api due to invalid token.");
}
$rowsPerRequest = $this->module->proxyRowsPerRequest;
$config = [
'rowsPerRequest' => $rowsPerRequest,
'tables' => [],
'storageFilesCount' => StorageFile::find()->count(),
];
foreach (Yii::$app->db->schema->tableNames as $table) {
if (in_array($table, $this->ignoreTables)) {
continue;
}
$schema = Yii::$app->db->getTableSchema($table);
$rows = (new Query())->from($table)->count();
$config['tables'][$table] = [
'pks' => $schema->primaryKey,
'name' => $table,
'rows' => $rows,
'fields' => $schema->columnNames,
'offset_total' => ceil($rows/$rowsPerRequest),
];
}
$buildToken = Yii::$app->security->generateRandomString(16);
$build = new ProxyBuild();
$build->detachBehavior('LogBehavior');
$build->attributes = [
'machine_id' => $machine->id,
'timestamp' => time(),
'build_token' => sha1($buildToken),
'config' => Json::encode($config),
'is_complet' => 0,
'expiration_time' => time() + $this->module->proxyExpirationTime
];
if ($build->save()) {
return [
'providerUrl' => Url::base(true) . '/admin/api-admin-proxy/data-provider',
'requestCloseUrl' => Url::base(true) . '/admin/api-admin-proxy/close',
'fileProviderUrl' => Url::base(true) . '/admin/api-admin-proxy/file-provider',
'imageProviderUrl' => Url::base(true) . '/admin/api-admin-proxy/image-provider',
'buildToken' => $buildToken,
'config' => $config,
];
}
return $build->getErrors();
} | php | public function actionIndex($identifier, $token)
{
$machine = ProxyMachine::findOne(['identifier' => $identifier, 'is_deleted' => false]);
if (!$machine) {
throw new ForbiddenHttpException("Unable to acccess the proxy api.");
}
if (sha1($machine->access_token) !== $token) {
throw new ForbiddenHttpException("Unable to acccess the proxy api due to invalid token.");
}
$rowsPerRequest = $this->module->proxyRowsPerRequest;
$config = [
'rowsPerRequest' => $rowsPerRequest,
'tables' => [],
'storageFilesCount' => StorageFile::find()->count(),
];
foreach (Yii::$app->db->schema->tableNames as $table) {
if (in_array($table, $this->ignoreTables)) {
continue;
}
$schema = Yii::$app->db->getTableSchema($table);
$rows = (new Query())->from($table)->count();
$config['tables'][$table] = [
'pks' => $schema->primaryKey,
'name' => $table,
'rows' => $rows,
'fields' => $schema->columnNames,
'offset_total' => ceil($rows/$rowsPerRequest),
];
}
$buildToken = Yii::$app->security->generateRandomString(16);
$build = new ProxyBuild();
$build->detachBehavior('LogBehavior');
$build->attributes = [
'machine_id' => $machine->id,
'timestamp' => time(),
'build_token' => sha1($buildToken),
'config' => Json::encode($config),
'is_complet' => 0,
'expiration_time' => time() + $this->module->proxyExpirationTime
];
if ($build->save()) {
return [
'providerUrl' => Url::base(true) . '/admin/api-admin-proxy/data-provider',
'requestCloseUrl' => Url::base(true) . '/admin/api-admin-proxy/close',
'fileProviderUrl' => Url::base(true) . '/admin/api-admin-proxy/file-provider',
'imageProviderUrl' => Url::base(true) . '/admin/api-admin-proxy/image-provider',
'buildToken' => $buildToken,
'config' => $config,
];
}
return $build->getErrors();
} | [
"public",
"function",
"actionIndex",
"(",
"$",
"identifier",
",",
"$",
"token",
")",
"{",
"$",
"machine",
"=",
"ProxyMachine",
"::",
"findOne",
"(",
"[",
"'identifier'",
"=>",
"$",
"identifier",
",",
"'is_deleted'",
"=>",
"false",
"]",
")",
";",
"if",
"(... | Gathers basic informations about the build.
@param string $identifier
@param string $token
@throws ForbiddenHttpException
@return array | [
"Gathers",
"basic",
"informations",
"about",
"the",
"build",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/ProxyController.php#L47-L108 | train |
luyadev/luya-module-admin | src/apis/ProxyController.php | ProxyController.ensureBuild | private function ensureBuild($machine, $buildToken)
{
$build = ProxyBuild::findOne(['build_token' => $buildToken, 'is_complet' => 0]);
if (!$build) {
throw new ForbiddenHttpException("Unable to find a ProxyBuild for the provided token.");
}
if (time() > $build->expiration_time) {
throw new ForbiddenHttpException("The expiration time ".date("d.m.Y H:i:s", $build->expiration_time)." has exceeded.");
}
if ($build->proxyMachine->identifier !== $machine) {
throw new ForbiddenHttpException("Invalid machine identifier for current build.");
}
return $build;
} | php | private function ensureBuild($machine, $buildToken)
{
$build = ProxyBuild::findOne(['build_token' => $buildToken, 'is_complet' => 0]);
if (!$build) {
throw new ForbiddenHttpException("Unable to find a ProxyBuild for the provided token.");
}
if (time() > $build->expiration_time) {
throw new ForbiddenHttpException("The expiration time ".date("d.m.Y H:i:s", $build->expiration_time)." has exceeded.");
}
if ($build->proxyMachine->identifier !== $machine) {
throw new ForbiddenHttpException("Invalid machine identifier for current build.");
}
return $build;
} | [
"private",
"function",
"ensureBuild",
"(",
"$",
"machine",
",",
"$",
"buildToken",
")",
"{",
"$",
"build",
"=",
"ProxyBuild",
"::",
"findOne",
"(",
"[",
"'build_token'",
"=>",
"$",
"buildToken",
",",
"'is_complet'",
"=>",
"0",
"]",
")",
";",
"if",
"(",
... | Make sure the machine and token are valid.
@param string $machine
@param string $buildToken
@throws ForbiddenHttpException
@return \luya\admin\models\ProxyBuild | [
"Make",
"sure",
"the",
"machine",
"and",
"token",
"are",
"valid",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/ProxyController.php#L118-L135 | train |
luyadev/luya-module-admin | src/apis/ProxyController.php | ProxyController.actionDataProvider | public function actionDataProvider($machine, $buildToken, $table, $offset)
{
$build = $this->ensureBuild($machine, $buildToken);
$config = $build->getTableConfig($table);
$offsetNummeric = $offset * $build->rowsPerRequest;
$query = (new Query())
->select($config['fields'])
->from($config['name'])
->offset($offsetNummeric)
->limit($build->rowsPerRequest);
if (!empty($config['pks']) && is_array($config['pks'])) {
$orders = [];
foreach ($config['pks'] as $pk) {
$orders[$pk] = SORT_ASC;
}
$query->orderBy($orders);
}
return $query->all();
} | php | public function actionDataProvider($machine, $buildToken, $table, $offset)
{
$build = $this->ensureBuild($machine, $buildToken);
$config = $build->getTableConfig($table);
$offsetNummeric = $offset * $build->rowsPerRequest;
$query = (new Query())
->select($config['fields'])
->from($config['name'])
->offset($offsetNummeric)
->limit($build->rowsPerRequest);
if (!empty($config['pks']) && is_array($config['pks'])) {
$orders = [];
foreach ($config['pks'] as $pk) {
$orders[$pk] = SORT_ASC;
}
$query->orderBy($orders);
}
return $query->all();
} | [
"public",
"function",
"actionDataProvider",
"(",
"$",
"machine",
",",
"$",
"buildToken",
",",
"$",
"table",
",",
"$",
"offset",
")",
"{",
"$",
"build",
"=",
"$",
"this",
"->",
"ensureBuild",
"(",
"$",
"machine",
",",
"$",
"buildToken",
")",
";",
"$",
... | Return sql table data.
@param string $machine
@param string $buildToken
@param string $table
@param integer $offset
@return array | [
"Return",
"sql",
"table",
"data",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/ProxyController.php#L146-L169 | train |
luyadev/luya-module-admin | src/apis/ProxyController.php | ProxyController.actionFileProvider | public function actionFileProvider($machine, $buildToken, $fileId)
{
$build = $this->ensureBuild($machine, $buildToken);
if ($build) {
if (!is_numeric($fileId)) {
throw new ForbiddenHttpException("Invalid file id input.");
}
$file = Yii::$app->storage->getFile($fileId);
/* @var $file \luya\admin\file\Item */
if ($file->fileExists) {
return Yii::$app->response->sendFile($file->serverSource, null, ['mimeType' => $file->mimeType])->send();
}
throw new NotFoundHttpException("The requested file '".$file->serverSource."' does not exist in the storage folder.");
}
} | php | public function actionFileProvider($machine, $buildToken, $fileId)
{
$build = $this->ensureBuild($machine, $buildToken);
if ($build) {
if (!is_numeric($fileId)) {
throw new ForbiddenHttpException("Invalid file id input.");
}
$file = Yii::$app->storage->getFile($fileId);
/* @var $file \luya\admin\file\Item */
if ($file->fileExists) {
return Yii::$app->response->sendFile($file->serverSource, null, ['mimeType' => $file->mimeType])->send();
}
throw new NotFoundHttpException("The requested file '".$file->serverSource."' does not exist in the storage folder.");
}
} | [
"public",
"function",
"actionFileProvider",
"(",
"$",
"machine",
",",
"$",
"buildToken",
",",
"$",
"fileId",
")",
"{",
"$",
"build",
"=",
"$",
"this",
"->",
"ensureBuild",
"(",
"$",
"machine",
",",
"$",
"buildToken",
")",
";",
"if",
"(",
"$",
"build",
... | Return file storage data.
@param string $machine
@param string $buildToken
@param integer $fileId
@throws ForbiddenHttpException
@throws NotFoundHttpException | [
"Return",
"file",
"storage",
"data",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/ProxyController.php#L180-L197 | train |
luyadev/luya-module-admin | src/apis/ProxyController.php | ProxyController.actionImageProvider | public function actionImageProvider($machine, $buildToken, $imageId)
{
$build = $this->ensureBuild($machine, $buildToken);
if ($build) {
if (!is_numeric($imageId)) {
throw new ForbiddenHttpException("Invalid image id input.");
}
$image = Yii::$app->storage->getImage($imageId);
/* @var $image \luya\admin\image\Item */
if ($image->fileExists) {
return Yii::$app->response->sendFile($image->serverSource)->send();
}
throw new NotFoundHttpException("The requested image '".$image->serverSource."' does not exist in the storage folder.");
}
} | php | public function actionImageProvider($machine, $buildToken, $imageId)
{
$build = $this->ensureBuild($machine, $buildToken);
if ($build) {
if (!is_numeric($imageId)) {
throw new ForbiddenHttpException("Invalid image id input.");
}
$image = Yii::$app->storage->getImage($imageId);
/* @var $image \luya\admin\image\Item */
if ($image->fileExists) {
return Yii::$app->response->sendFile($image->serverSource)->send();
}
throw new NotFoundHttpException("The requested image '".$image->serverSource."' does not exist in the storage folder.");
}
} | [
"public",
"function",
"actionImageProvider",
"(",
"$",
"machine",
",",
"$",
"buildToken",
",",
"$",
"imageId",
")",
"{",
"$",
"build",
"=",
"$",
"this",
"->",
"ensureBuild",
"(",
"$",
"machine",
",",
"$",
"buildToken",
")",
";",
"if",
"(",
"$",
"build"... | Return image storage data.
@param string $machine
@param string $buildToken
@param integer $imageId
@throws ForbiddenHttpException
@throws NotFoundHttpException | [
"Return",
"image",
"storage",
"data",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/ProxyController.php#L208-L225 | train |
luyadev/luya-module-admin | src/apis/ProxyController.php | ProxyController.actionClose | public function actionClose($buildToken)
{
$build = ProxyBuild::findOne(['build_token' => $buildToken, 'is_complet' => 0]);
if (!$build) {
throw new ForbiddenHttpException("Unable to find build from token.");
}
$build->updateAttributes(['is_complet' => 1]);
} | php | public function actionClose($buildToken)
{
$build = ProxyBuild::findOne(['build_token' => $buildToken, 'is_complet' => 0]);
if (!$build) {
throw new ForbiddenHttpException("Unable to find build from token.");
}
$build->updateAttributes(['is_complet' => 1]);
} | [
"public",
"function",
"actionClose",
"(",
"$",
"buildToken",
")",
"{",
"$",
"build",
"=",
"ProxyBuild",
"::",
"findOne",
"(",
"[",
"'build_token'",
"=>",
"$",
"buildToken",
",",
"'is_complet'",
"=>",
"0",
"]",
")",
";",
"if",
"(",
"!",
"$",
"build",
")... | Close the current build.
@param string $buildToken
@throws ForbiddenHttpException | [
"Close",
"the",
"current",
"build",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/ProxyController.php#L233-L242 | train |
luyadev/luya-module-admin | src/ngrest/render/RenderCrud.php | RenderCrud.generateDownloadAttributes | public function generateDownloadAttributes()
{
$attributes = [];
foreach ($this->model->attributes() as $key) {
$attributes[$key] = $this->model->getAttributeLabel($key) . ' ('.$key.')';
}
return $attributes;
} | php | public function generateDownloadAttributes()
{
$attributes = [];
foreach ($this->model->attributes() as $key) {
$attributes[$key] = $this->model->getAttributeLabel($key) . ' ('.$key.')';
}
return $attributes;
} | [
"public",
"function",
"generateDownloadAttributes",
"(",
")",
"{",
"$",
"attributes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"model",
"->",
"attributes",
"(",
")",
"as",
"$",
"key",
")",
"{",
"$",
"attributes",
"[",
"$",
"key",
"]",
"... | Generates an array with all attributes an the corresponding label.
@return array
@since 1.2.2 | [
"Generates",
"an",
"array",
"with",
"all",
"attributes",
"an",
"the",
"corresponding",
"label",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/render/RenderCrud.php#L122-L130 | train |
luyadev/luya-module-admin | src/ngrest/render/RenderCrud.php | RenderCrud.isSortable | public function isSortable(array $item)
{
$config = Config::createField($item);
return $config->getSortField() ? true : false;
} | php | public function isSortable(array $item)
{
$config = Config::createField($item);
return $config->getSortField() ? true : false;
} | [
"public",
"function",
"isSortable",
"(",
"array",
"$",
"item",
")",
"{",
"$",
"config",
"=",
"Config",
"::",
"createField",
"(",
"$",
"item",
")",
";",
"return",
"$",
"config",
"->",
"getSortField",
"(",
")",
"?",
"true",
":",
"false",
";",
"}"
] | Indicates whether the current plugin config is sortable or not.
@param array $item
@return boolean
@since 2.0.0 | [
"Indicates",
"whether",
"the",
"current",
"plugin",
"config",
"is",
"sortable",
"or",
"not",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/render/RenderCrud.php#L260-L265 | train |
luyadev/luya-module-admin | src/ngrest/render/RenderCrud.php | RenderCrud.getOrderBy | public function getOrderBy()
{
if ($this->getConfig()->getDefaultOrderField() === false) {
return false;
}
return $this->getConfig()->getDefaultOrderDirection() . $this->getConfig()->getDefaultOrderField();
} | php | public function getOrderBy()
{
if ($this->getConfig()->getDefaultOrderField() === false) {
return false;
}
return $this->getConfig()->getDefaultOrderDirection() . $this->getConfig()->getDefaultOrderField();
} | [
"public",
"function",
"getOrderBy",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getConfig",
"(",
")",
"->",
"getDefaultOrderField",
"(",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"getConfig",
"(",
")",
... | Returns the current order by state.
@return string angular order by statements like `+id` or `-name`. | [
"Returns",
"the",
"current",
"order",
"by",
"state",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/render/RenderCrud.php#L296-L303 | train |
luyadev/luya-module-admin | src/ngrest/render/RenderCrud.php | RenderCrud.getApiEndpoint | public function getApiEndpoint($append = null)
{
if ($append) {
$append = '/' . ltrim($append, '/');
}
return 'admin/'.$this->getConfig()->getApiEndpoint() . $append;
} | php | public function getApiEndpoint($append = null)
{
if ($append) {
$append = '/' . ltrim($append, '/');
}
return 'admin/'.$this->getConfig()->getApiEndpoint() . $append;
} | [
"public",
"function",
"getApiEndpoint",
"(",
"$",
"append",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"append",
")",
"{",
"$",
"append",
"=",
"'/'",
".",
"ltrim",
"(",
"$",
"append",
",",
"'/'",
")",
";",
"}",
"return",
"'admin/'",
".",
"$",
"this",
... | Returns the api endpoint, but can add appendix.
@return string | [
"Returns",
"the",
"api",
"endpoint",
"but",
"can",
"add",
"appendix",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/render/RenderCrud.php#L320-L327 | train |
luyadev/luya-module-admin | src/ngrest/render/RenderCrud.php | RenderCrud.can | protected function can($type)
{
if (!array_key_exists($type, $this->_canTypes)) {
$this->_canTypes[$type] = Yii::$app->auth->matchApi(Yii::$app->adminuser->getId(), $this->config->apiEndpoint, $type);
}
return $this->_canTypes[$type];
} | php | protected function can($type)
{
if (!array_key_exists($type, $this->_canTypes)) {
$this->_canTypes[$type] = Yii::$app->auth->matchApi(Yii::$app->adminuser->getId(), $this->config->apiEndpoint, $type);
}
return $this->_canTypes[$type];
} | [
"protected",
"function",
"can",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"type",
",",
"$",
"this",
"->",
"_canTypes",
")",
")",
"{",
"$",
"this",
"->",
"_canTypes",
"[",
"$",
"type",
"]",
"=",
"Yii",
"::",
"$",
"a... | Checks whether a given type can or can not.
@param string $type
@return boolean | [
"Checks",
"whether",
"a",
"given",
"type",
"can",
"or",
"can",
"not",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/render/RenderCrud.php#L339-L346 | train |
luyadev/luya-module-admin | src/ngrest/render/RenderCrud.php | RenderCrud.getButtons | public function getButtons()
{
// if already assigned return the resutl
if ($this->_buttons) {
return $this->_buttons;
}
$buttons = [];
// ngrest relation buttons
foreach ($this->getConfig()->getRelations() as $rel) {
$api = Yii::$app->adminmenu->getApiDetail($rel['apiEndpoint']);
if (!$api) {
throw new InvalidConfigException("The configured api relation '{$rel['apiEndpoint']}' does not exists in the menu elements. Maybe you have no permissions to access this API.");
}
$label = empty($rel['tabLabelAttribute']) ? "'{$rel['label']}'" : 'item.'.$rel['tabLabelAttribute'];
$buttons[] = [
'ngClick' => 'addAndswitchToTab(item.'.$this->getPrimaryKey().', \''.$api['route'].'\', \''.$rel['arrayIndex'].'\', '.$label.', \''.$rel['modelClass'].'\')',
'icon' => 'chrome_reader_mode',
'label' => $rel['label'],
];
}
if ($this->can(Auth::CAN_UPDATE)) {
// get all activeWindows assign to the crud
foreach ($this->getActiveWindows() as $hash => $config) {
$buttons[] = [
'ngClick' => 'getActiveWindow(\''.$hash.'\', '.$this->getCompositionKeysForButtonActions('item').')',
'icon' => isset($config['objectConfig']['icon']) ? $config['objectConfig']['icon'] : $config['icon'],
'label' => isset($config['objectConfig']['label']) ? $config['objectConfig']['label'] : $config['label'],
];
}
// add active buttons.
foreach ($this->config->getActiveButtons() as $btn) {
$buttons[] = [
'ngClick' => "callActiveButton('{$btn['hash']}', ".$this->getCompositionKeysForButtonActions('item').", \$event)",
'icon' => $btn['icon'],
'label' => $btn['label'],
];
}
}
// check if deletable is enabled
if ($this->config->isDeletable() && $this->can(Auth::CAN_DELETE)) {
$buttons[] = [
'ngClick' => 'deleteItem('.$this->getCompositionKeysForButtonActions('item').')',
'icon' => 'delete',
'label' => '',
];
}
// do we have an edit button
if (count($this->getFields('update')) > 0 && $this->can(Auth::CAN_UPDATE)) {
$buttons[] = [
'ngClick' => 'toggleUpdate('.$this->getCompositionKeysForButtonActions('item').')',
'icon' => 'mode_edit',
'label' => '',
];
}
$this->_buttons = $buttons;
return $buttons;
} | php | public function getButtons()
{
// if already assigned return the resutl
if ($this->_buttons) {
return $this->_buttons;
}
$buttons = [];
// ngrest relation buttons
foreach ($this->getConfig()->getRelations() as $rel) {
$api = Yii::$app->adminmenu->getApiDetail($rel['apiEndpoint']);
if (!$api) {
throw new InvalidConfigException("The configured api relation '{$rel['apiEndpoint']}' does not exists in the menu elements. Maybe you have no permissions to access this API.");
}
$label = empty($rel['tabLabelAttribute']) ? "'{$rel['label']}'" : 'item.'.$rel['tabLabelAttribute'];
$buttons[] = [
'ngClick' => 'addAndswitchToTab(item.'.$this->getPrimaryKey().', \''.$api['route'].'\', \''.$rel['arrayIndex'].'\', '.$label.', \''.$rel['modelClass'].'\')',
'icon' => 'chrome_reader_mode',
'label' => $rel['label'],
];
}
if ($this->can(Auth::CAN_UPDATE)) {
// get all activeWindows assign to the crud
foreach ($this->getActiveWindows() as $hash => $config) {
$buttons[] = [
'ngClick' => 'getActiveWindow(\''.$hash.'\', '.$this->getCompositionKeysForButtonActions('item').')',
'icon' => isset($config['objectConfig']['icon']) ? $config['objectConfig']['icon'] : $config['icon'],
'label' => isset($config['objectConfig']['label']) ? $config['objectConfig']['label'] : $config['label'],
];
}
// add active buttons.
foreach ($this->config->getActiveButtons() as $btn) {
$buttons[] = [
'ngClick' => "callActiveButton('{$btn['hash']}', ".$this->getCompositionKeysForButtonActions('item').", \$event)",
'icon' => $btn['icon'],
'label' => $btn['label'],
];
}
}
// check if deletable is enabled
if ($this->config->isDeletable() && $this->can(Auth::CAN_DELETE)) {
$buttons[] = [
'ngClick' => 'deleteItem('.$this->getCompositionKeysForButtonActions('item').')',
'icon' => 'delete',
'label' => '',
];
}
// do we have an edit button
if (count($this->getFields('update')) > 0 && $this->can(Auth::CAN_UPDATE)) {
$buttons[] = [
'ngClick' => 'toggleUpdate('.$this->getCompositionKeysForButtonActions('item').')',
'icon' => 'mode_edit',
'label' => '',
];
}
$this->_buttons = $buttons;
return $buttons;
} | [
"public",
"function",
"getButtons",
"(",
")",
"{",
"// if already assigned return the resutl",
"if",
"(",
"$",
"this",
"->",
"_buttons",
")",
"{",
"return",
"$",
"this",
"->",
"_buttons",
";",
"}",
"$",
"buttons",
"=",
"[",
"]",
";",
"// ngrest relation button... | collection all the buttons in the crud list.
each items required the following keys (ngClick, icon, label):
```php
return [
['ngClick' => 'toggle(...)', 'icon' => 'fa fa-fw fa-edit', 'label' => 'Button Label']
];
```
@return array An array with all buttons for this crud
@throws InvalidConfigException | [
"collection",
"all",
"the",
"buttons",
"in",
"the",
"crud",
"list",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/render/RenderCrud.php#L381-L445 | train |
luyadev/luya-module-admin | src/ngrest/render/RenderCrud.php | RenderCrud.apiQueryString | public function apiQueryString($type)
{
// basic query
$query = ['ngrestCallType' => $type];
$fields = [];
foreach ($this->model->primaryKey() as $n) {
$fields[] = $n;
}
// see if we have fields for this type
if (count($this->getFields($type)) > 0) {
foreach ($this->getFields($type) as $field) {
$fields[] = $field;
}
}
// do we have extra fields to expand
if (count($this->config->getPointerExtraFields($type)) > 0) {
$query['expand'] = implode(',', $this->config->getPointerExtraFields($type));
}
array_unique($fields);
$query['fields'] = implode(",", $fields);
if (Yii::$app->request->get('pool')) {
$query['pool'] = Yii::$app->request->get('pool');
}
// return url decoded string from http_build_query
return http_build_query($query, '', '&');
} | php | public function apiQueryString($type)
{
// basic query
$query = ['ngrestCallType' => $type];
$fields = [];
foreach ($this->model->primaryKey() as $n) {
$fields[] = $n;
}
// see if we have fields for this type
if (count($this->getFields($type)) > 0) {
foreach ($this->getFields($type) as $field) {
$fields[] = $field;
}
}
// do we have extra fields to expand
if (count($this->config->getPointerExtraFields($type)) > 0) {
$query['expand'] = implode(',', $this->config->getPointerExtraFields($type));
}
array_unique($fields);
$query['fields'] = implode(",", $fields);
if (Yii::$app->request->get('pool')) {
$query['pool'] = Yii::$app->request->get('pool');
}
// return url decoded string from http_build_query
return http_build_query($query, '', '&');
} | [
"public",
"function",
"apiQueryString",
"(",
"$",
"type",
")",
"{",
"// basic query",
"$",
"query",
"=",
"[",
"'ngrestCallType'",
"=>",
"$",
"type",
"]",
";",
"$",
"fields",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"model",
"->",
"primary... | Generate the api query string for a certain context type
@param string $type
@return string | [
"Generate",
"the",
"api",
"query",
"string",
"for",
"a",
"certain",
"context",
"type"
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/render/RenderCrud.php#L463-L492 | train |
luyadev/luya-module-admin | src/ngrest/render/RenderCrud.php | RenderCrud.getFields | public function getFields($type)
{
if (!array_key_exists($type, $this->_fields)) {
$fields = [];
if ($this->config->hasPointer($type)) {
foreach ($this->config->getPointer($type) as $item) {
$fields[] = $item['name'];
}
}
$this->_fields[$type] = $fields;
}
return $this->_fields[$type];
} | php | public function getFields($type)
{
if (!array_key_exists($type, $this->_fields)) {
$fields = [];
if ($this->config->hasPointer($type)) {
foreach ($this->config->getPointer($type) as $item) {
$fields[] = $item['name'];
}
}
$this->_fields[$type] = $fields;
}
return $this->_fields[$type];
} | [
"public",
"function",
"getFields",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"type",
",",
"$",
"this",
"->",
"_fields",
")",
")",
"{",
"$",
"fields",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"config",
"->"... | Short hand method to get all fields for a certain type context
@param string $type
@return array | [
"Short",
"hand",
"method",
"to",
"get",
"all",
"fields",
"for",
"a",
"certain",
"type",
"context"
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/render/RenderCrud.php#L502-L515 | train |
luyadev/luya-module-admin | src/ngrest/render/RenderCrud.php | RenderCrud.generatePluginHtml | public function generatePluginHtml(array $element, $configContext)
{
if ($element['i18n'] && $configContext !== self::TYPE_LIST) {
return $this->view->render('_crudform_i18n_pluginhtml', [
'element' => $element,
'configContext' => $configContext,
'languages' => Lang::getQuery(),
'helpButtonHtml' => $this->createFieldHelpButton($element, $configContext),
]);
}
$ngModel = $this->ngModelString($configContext, $element['name']);
return $this->createFieldHelpButton($element, $configContext) .
$this->renderElementPlugins($configContext, $element['type'], Inflector::slug($ngModel), $element['name'], $ngModel, $element['alias'], false);
} | php | public function generatePluginHtml(array $element, $configContext)
{
if ($element['i18n'] && $configContext !== self::TYPE_LIST) {
return $this->view->render('_crudform_i18n_pluginhtml', [
'element' => $element,
'configContext' => $configContext,
'languages' => Lang::getQuery(),
'helpButtonHtml' => $this->createFieldHelpButton($element, $configContext),
]);
}
$ngModel = $this->ngModelString($configContext, $element['name']);
return $this->createFieldHelpButton($element, $configContext) .
$this->renderElementPlugins($configContext, $element['type'], Inflector::slug($ngModel), $element['name'], $ngModel, $element['alias'], false);
} | [
"public",
"function",
"generatePluginHtml",
"(",
"array",
"$",
"element",
",",
"$",
"configContext",
")",
"{",
"if",
"(",
"$",
"element",
"[",
"'i18n'",
"]",
"&&",
"$",
"configContext",
"!==",
"self",
"::",
"TYPE_LIST",
")",
"{",
"return",
"$",
"this",
"... | Generate the HTML code for the plugin element based on the current context.
@param array $element
@param string $configContext
@return string
@since 2.0 | [
"Generate",
"the",
"HTML",
"code",
"for",
"the",
"plugin",
"element",
"based",
"on",
"the",
"current",
"context",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/render/RenderCrud.php#L556-L572 | train |
luyadev/luya-module-admin | src/ngrest/render/RenderCrud.php | RenderCrud.renderElementPlugins | public function renderElementPlugins($configContext, $typeConfig, $uniqueId, $attribute, $ngRestModel, $label, $elmni18n)
{
$args = $typeConfig['args'];
$args['renderContext'] = $this;
$obj = NgRest::createPluginObject($typeConfig['class'], $attribute, $label, $elmni18n, $args);
$method = 'render'.ucfirst($configContext);
$html = $obj->$method($uniqueId, $ngRestModel);
// parsed the element output content to a string
$content = is_array($html) ? implode(" ", $html) : $html;
// wrapp a new tag around fields which are required.
if ($configContext !== self::TYPE_LIST) {
$isRequired = $this->getModel()->isAttributeRequired($attribute);
if ($isRequired) {
$content = '<span class="bold-form-label">'.$content.'</span>';
}
}
return $content;
} | php | public function renderElementPlugins($configContext, $typeConfig, $uniqueId, $attribute, $ngRestModel, $label, $elmni18n)
{
$args = $typeConfig['args'];
$args['renderContext'] = $this;
$obj = NgRest::createPluginObject($typeConfig['class'], $attribute, $label, $elmni18n, $args);
$method = 'render'.ucfirst($configContext);
$html = $obj->$method($uniqueId, $ngRestModel);
// parsed the element output content to a string
$content = is_array($html) ? implode(" ", $html) : $html;
// wrapp a new tag around fields which are required.
if ($configContext !== self::TYPE_LIST) {
$isRequired = $this->getModel()->isAttributeRequired($attribute);
if ($isRequired) {
$content = '<span class="bold-form-label">'.$content.'</span>';
}
}
return $content;
} | [
"public",
"function",
"renderElementPlugins",
"(",
"$",
"configContext",
",",
"$",
"typeConfig",
",",
"$",
"uniqueId",
",",
"$",
"attribute",
",",
"$",
"ngRestModel",
",",
"$",
"label",
",",
"$",
"elmni18n",
")",
"{",
"$",
"args",
"=",
"$",
"typeConfig",
... | Render the input element
@param string $configContext
@param array $typeConfig
@param string $uniqueId Example unique field id: id="id-50eef582a7330e93b86b55ffed379965"
@param string $attribute
@param string $ngRestModel
@param string $label
@param boolean $elmni18n
@return string The rendered element | [
"Render",
"the",
"input",
"element"
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/render/RenderCrud.php#L586-L606 | train |
luyadev/luya-module-admin | src/ngrest/render/RenderCrud.php | RenderCrud.i18nNgModelString | public function i18nNgModelString($configContext, $attribute, $lang)
{
$context = $configContext == self::TYPE_LIST ? "item." : "data.{$configContext}.";
return $context . $attribute.'[\''.$lang.'\']';
} | php | public function i18nNgModelString($configContext, $attribute, $lang)
{
$context = $configContext == self::TYPE_LIST ? "item." : "data.{$configContext}.";
return $context . $attribute.'[\''.$lang.'\']';
} | [
"public",
"function",
"i18nNgModelString",
"(",
"$",
"configContext",
",",
"$",
"attribute",
",",
"$",
"lang",
")",
"{",
"$",
"context",
"=",
"$",
"configContext",
"==",
"self",
"::",
"TYPE_LIST",
"?",
"\"item.\"",
":",
"\"data.{$configContext}.\"",
";",
"retu... | Generate the ngrest model for an i18n field
@param string $configContext
@param string $attribute
@param string $lang
@return string | [
"Generate",
"the",
"ngrest",
"model",
"for",
"an",
"i18n",
"field"
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/render/RenderCrud.php#L628-L632 | train |
luyadev/luya-module-admin | src/ngrest/render/RenderCrud.php | RenderCrud.evalGroupFields | private function evalGroupFields($pointerElements)
{
if (!$pointerElements) {
return [];
}
$names = [];
foreach ($pointerElements as $elmn) {
$names[$elmn['name']] = $elmn['name'];
}
foreach ($this->getConfig()->getAttributeGroups()as $group) {
foreach ($group[0] as $item) {
if (in_array($item, $names)) {
unset($names[$item]);
}
}
}
$groups[] = [$names, '__default', 'collapsed' => true, 'is_default' => true];
return array_merge($groups, $this->getConfig()->getAttributeGroups());
} | php | private function evalGroupFields($pointerElements)
{
if (!$pointerElements) {
return [];
}
$names = [];
foreach ($pointerElements as $elmn) {
$names[$elmn['name']] = $elmn['name'];
}
foreach ($this->getConfig()->getAttributeGroups()as $group) {
foreach ($group[0] as $item) {
if (in_array($item, $names)) {
unset($names[$item]);
}
}
}
$groups[] = [$names, '__default', 'collapsed' => true, 'is_default' => true];
return array_merge($groups, $this->getConfig()->getAttributeGroups());
} | [
"private",
"function",
"evalGroupFields",
"(",
"$",
"pointerElements",
")",
"{",
"if",
"(",
"!",
"$",
"pointerElements",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"names",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"pointerElements",
"as",
"$",
"elmn"... | Generate an array for every group withing the given pointer elemenets.
If there is no group defintion, it will generate a "default" group.
@param [type] $pointerElements
@return array | [
"Generate",
"an",
"array",
"for",
"every",
"group",
"withing",
"the",
"given",
"pointer",
"elemenets",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/render/RenderCrud.php#L656-L679 | train |
luyadev/luya-module-admin | src/commands/TagController.php | TagController.actionFixTableNames | public function actionFixTableNames()
{
$batch = TagRelation::find()->batch();
$i = 0;
$fixed = 0;
$errors = 0;
foreach ($batch as $rows) {
foreach ($rows as $relation) {
$i++;
$tableName = TaggableTrait::cleanBaseTableName($relation->table_name);
if ($relation->table_name !== $tableName) {
// if the new name exists already as combination, we can just delete the old one.
/*
// maybe use configuration option to delete entries by default.
if (TagRelation::find()->where(['table_name' => $tableName, 'pk_id' => $relation->pk_id, 'tag_id' => $relation->tag_id])->exists()) {
$relation->delete();
$fixed++;
continue;
}
*/
$relation->table_name = $tableName;
if ($relation->save()) {
$fixed++;
} else {
$errors++;
}
}
unset($tableName, $relation);
}
}
return $this->outputSuccess("{$i} items checked and {$fixed} items fixed with {$errors} errors.");
} | php | public function actionFixTableNames()
{
$batch = TagRelation::find()->batch();
$i = 0;
$fixed = 0;
$errors = 0;
foreach ($batch as $rows) {
foreach ($rows as $relation) {
$i++;
$tableName = TaggableTrait::cleanBaseTableName($relation->table_name);
if ($relation->table_name !== $tableName) {
// if the new name exists already as combination, we can just delete the old one.
/*
// maybe use configuration option to delete entries by default.
if (TagRelation::find()->where(['table_name' => $tableName, 'pk_id' => $relation->pk_id, 'tag_id' => $relation->tag_id])->exists()) {
$relation->delete();
$fixed++;
continue;
}
*/
$relation->table_name = $tableName;
if ($relation->save()) {
$fixed++;
} else {
$errors++;
}
}
unset($tableName, $relation);
}
}
return $this->outputSuccess("{$i} items checked and {$fixed} items fixed with {$errors} errors.");
} | [
"public",
"function",
"actionFixTableNames",
"(",
")",
"{",
"$",
"batch",
"=",
"TagRelation",
"::",
"find",
"(",
")",
"->",
"batch",
"(",
")",
";",
"$",
"i",
"=",
"0",
";",
"$",
"fixed",
"=",
"0",
";",
"$",
"errors",
"=",
"0",
";",
"foreach",
"("... | Handle wrong declared table names and try to cleanup not existing relations.
@return integer | [
"Handle",
"wrong",
"declared",
"table",
"names",
"and",
"try",
"to",
"cleanup",
"not",
"existing",
"relations",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/commands/TagController.php#L25-L60 | train |
luyadev/luya-module-admin | src/commands/TagController.php | TagController.actionCleanup | public function actionCleanup()
{
$tagIds = Tag::find()->select(['id'])->column();
$batch = TagRelation::find()->batch();
$i = 0;
$delete = 0;
foreach ($batch as $rows) {
foreach ($rows as $relation) {
$i++;
// check if tag id exists in table
if (!in_array($relation->tag_id, $tagIds)) {
$relation->delete();
$delete++;
continue;
}
$prefixedTableName = '{{%'.$relation->table_name.'}}';
$pk = $this->tableSchema($prefixedTableName)->primaryKey;
$query = (new Query())
->from($prefixedTableName)
->where([current($pk) => $relation->pk_id]) // provide model mapping or read pk name from schema
->exists();
if (!$query) {
$relation->delete();
$delete++;
}
unset($relation, $prefixedTableName, $pk, $query);
}
}
return $this->outputSuccess("{$i} items checked and {$delete} items deleted.");
} | php | public function actionCleanup()
{
$tagIds = Tag::find()->select(['id'])->column();
$batch = TagRelation::find()->batch();
$i = 0;
$delete = 0;
foreach ($batch as $rows) {
foreach ($rows as $relation) {
$i++;
// check if tag id exists in table
if (!in_array($relation->tag_id, $tagIds)) {
$relation->delete();
$delete++;
continue;
}
$prefixedTableName = '{{%'.$relation->table_name.'}}';
$pk = $this->tableSchema($prefixedTableName)->primaryKey;
$query = (new Query())
->from($prefixedTableName)
->where([current($pk) => $relation->pk_id]) // provide model mapping or read pk name from schema
->exists();
if (!$query) {
$relation->delete();
$delete++;
}
unset($relation, $prefixedTableName, $pk, $query);
}
}
return $this->outputSuccess("{$i} items checked and {$delete} items deleted.");
} | [
"public",
"function",
"actionCleanup",
"(",
")",
"{",
"$",
"tagIds",
"=",
"Tag",
"::",
"find",
"(",
")",
"->",
"select",
"(",
"[",
"'id'",
"]",
")",
"->",
"column",
"(",
")",
";",
"$",
"batch",
"=",
"TagRelation",
"::",
"find",
"(",
")",
"->",
"b... | Handle not existing relations, tags which does not exists or relation entries which does not exists in the table.
@return integer | [
"Handle",
"not",
"existing",
"relations",
"tags",
"which",
"does",
"not",
"exists",
"or",
"relation",
"entries",
"which",
"does",
"not",
"exists",
"in",
"the",
"table",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/commands/TagController.php#L67-L101 | train |
luyadev/luya-module-admin | src/Module.php | Module.getJsTranslations | public function getJsTranslations()
{
$translations = [];
foreach ($this->_jsTranslations as $module => $data) {
foreach ($data as $key) {
$translations[$key] = Yii::t($module, $key, [], Yii::$app->language);
}
}
return $translations;
} | php | public function getJsTranslations()
{
$translations = [];
foreach ($this->_jsTranslations as $module => $data) {
foreach ($data as $key) {
$translations[$key] = Yii::t($module, $key, [], Yii::$app->language);
}
}
return $translations;
} | [
"public",
"function",
"getJsTranslations",
"(",
")",
"{",
"$",
"translations",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"_jsTranslations",
"as",
"$",
"module",
"=>",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
... | Getter method for the js translations array.
@return array An array with all translated messages to store in the and access from the admin js scripts. | [
"Getter",
"method",
"for",
"the",
"js",
"translations",
"array",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/Module.php#L315-L324 | train |
luyadev/luya-module-admin | src/Module.php | Module.getMenu | public function getMenu()
{
return (new AdminMenuBuilder($this))
->nodeRoute('menu_node_filemanager', 'cloud_upload', 'admin/storage/index')
->node('menu_node_system', 'settings_applications')
->group('menu_group_access')
->itemApi('menu_access_item_user', 'admin/user/index', 'person', 'api-admin-user')
->itemApi('menu_access_item_apiuser', 'admin/api-user/index', 'device_hub', 'api-admin-apiuser')
->itemApi('menu_access_item_group', 'admin/group/index', 'group', 'api-admin-group')
->group('menu_group_system')
->itemApi('menu_system_item_config', 'admin/config/index', 'storage', 'api-admin-config')
->itemApi('menu_system_item_language', 'admin/lang/index', 'language', 'api-admin-lang')
->itemApi('menu_system_item_tags', 'admin/tag/index', 'view_list', 'api-admin-tag')
->itemApi('menu_system_logger', 'admin/logger/index', 'notifications', 'api-admin-logger')
->itemApi('Queue', 'admin/queue-log/index', 'schedule', 'api-admin-queuelog')
->group('menu_group_images')
->itemApi('menu_images_item_effects', 'admin/effect/index', 'blur_circular', 'api-admin-effect')
->itemApi('menu_images_item_filters', 'admin/filter/index', 'adjust', 'api-admin-filter')
->group('menu_group_contentproxy')
->itemApi('menu_group_contentproxy_machines', 'admin/proxy-machine/index', 'devices', 'api-admin-proxymachine')
->itemApi('menu_group_contentproxy_builds', 'admin/proxy-build/index', 'import_export', 'api-admin-proxybuild');
} | php | public function getMenu()
{
return (new AdminMenuBuilder($this))
->nodeRoute('menu_node_filemanager', 'cloud_upload', 'admin/storage/index')
->node('menu_node_system', 'settings_applications')
->group('menu_group_access')
->itemApi('menu_access_item_user', 'admin/user/index', 'person', 'api-admin-user')
->itemApi('menu_access_item_apiuser', 'admin/api-user/index', 'device_hub', 'api-admin-apiuser')
->itemApi('menu_access_item_group', 'admin/group/index', 'group', 'api-admin-group')
->group('menu_group_system')
->itemApi('menu_system_item_config', 'admin/config/index', 'storage', 'api-admin-config')
->itemApi('menu_system_item_language', 'admin/lang/index', 'language', 'api-admin-lang')
->itemApi('menu_system_item_tags', 'admin/tag/index', 'view_list', 'api-admin-tag')
->itemApi('menu_system_logger', 'admin/logger/index', 'notifications', 'api-admin-logger')
->itemApi('Queue', 'admin/queue-log/index', 'schedule', 'api-admin-queuelog')
->group('menu_group_images')
->itemApi('menu_images_item_effects', 'admin/effect/index', 'blur_circular', 'api-admin-effect')
->itemApi('menu_images_item_filters', 'admin/filter/index', 'adjust', 'api-admin-filter')
->group('menu_group_contentproxy')
->itemApi('menu_group_contentproxy_machines', 'admin/proxy-machine/index', 'devices', 'api-admin-proxymachine')
->itemApi('menu_group_contentproxy_builds', 'admin/proxy-build/index', 'import_export', 'api-admin-proxybuild');
} | [
"public",
"function",
"getMenu",
"(",
")",
"{",
"return",
"(",
"new",
"AdminMenuBuilder",
"(",
"$",
"this",
")",
")",
"->",
"nodeRoute",
"(",
"'menu_node_filemanager'",
",",
"'cloud_upload'",
",",
"'admin/storage/index'",
")",
"->",
"node",
"(",
"'menu_node_syst... | Get the admin module interface menu.
@see \luya\admin\base\Module::getMenu()
@return \luya\admin\components\AdminMenuBuilderInterface Get the menu builder object. | [
"Get",
"the",
"admin",
"module",
"interface",
"menu",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/Module.php#L344-L365 | train |
luyadev/luya-module-admin | src/Module.php | Module.t | public static function t($message, array $params = [], $language = null)
{
return parent::baseT('admin', $message, $params, $language);
} | php | public static function t($message, array $params = [], $language = null)
{
return parent::baseT('admin', $message, $params, $language);
} | [
"public",
"static",
"function",
"t",
"(",
"$",
"message",
",",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"language",
"=",
"null",
")",
"{",
"return",
"parent",
"::",
"baseT",
"(",
"'admin'",
",",
"$",
"message",
",",
"$",
"params",
",",
"$",... | Admin Module translation helper.
@param string $message The message key to translation
@param array $params Optional parameters to pass to the translation.
@return string The translated message. | [
"Admin",
"Module",
"translation",
"helper",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/Module.php#L424-L427 | train |
luyadev/luya-module-admin | src/apis/UserController.php | UserController.actionSession | public function actionSession()
{
$user = Yii::$app->adminuser->identity;
$session = [
'packages' => [],
'user' => $user->toArray(['title', 'firstname', 'lastname', 'email', 'id', 'email_verification_token_timestamp']),
'activities' => ['open_email_validation' => $this->hasOpenEmailValidation($user)],
'settings' => Yii::$app->adminuser->identity->setting->getArray([
User::USER_SETTING_ISDEVELOPER, User::USER_SETTING_UILANGUAGE, User::USER_SETTING_NEWUSEREMAIL
], [
User::USER_SETTING_UILANGUAGE => $this->module->interfaceLanguage,
]),
];
// if developer option is enabled provide package infos
if ($session['settings'][User::USER_SETTING_ISDEVELOPER]) {
$session['packages'] = Yii::$app->getPackageInstaller()->getConfigs();
}
return $session;
} | php | public function actionSession()
{
$user = Yii::$app->adminuser->identity;
$session = [
'packages' => [],
'user' => $user->toArray(['title', 'firstname', 'lastname', 'email', 'id', 'email_verification_token_timestamp']),
'activities' => ['open_email_validation' => $this->hasOpenEmailValidation($user)],
'settings' => Yii::$app->adminuser->identity->setting->getArray([
User::USER_SETTING_ISDEVELOPER, User::USER_SETTING_UILANGUAGE, User::USER_SETTING_NEWUSEREMAIL
], [
User::USER_SETTING_UILANGUAGE => $this->module->interfaceLanguage,
]),
];
// if developer option is enabled provide package infos
if ($session['settings'][User::USER_SETTING_ISDEVELOPER]) {
$session['packages'] = Yii::$app->getPackageInstaller()->getConfigs();
}
return $session;
} | [
"public",
"function",
"actionSession",
"(",
")",
"{",
"$",
"user",
"=",
"Yii",
"::",
"$",
"app",
"->",
"adminuser",
"->",
"identity",
";",
"$",
"session",
"=",
"[",
"'packages'",
"=>",
"[",
"]",
",",
"'user'",
"=>",
"$",
"user",
"->",
"toArray",
"(",... | Dump the current data from your user session.
@return array | [
"Dump",
"the",
"current",
"data",
"from",
"your",
"user",
"session",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/UserController.php#L31-L51 | train |
luyadev/luya-module-admin | src/apis/UserController.php | UserController.hasOpenEmailValidation | private function hasOpenEmailValidation(User $user)
{
$ts = $user->email_verification_token_timestamp;
if (!empty($ts) && (time() - $this->module->emailVerificationTokenExpirationTime) <= $ts) {
return true;
}
return false;
} | php | private function hasOpenEmailValidation(User $user)
{
$ts = $user->email_verification_token_timestamp;
if (!empty($ts) && (time() - $this->module->emailVerificationTokenExpirationTime) <= $ts) {
return true;
}
return false;
} | [
"private",
"function",
"hasOpenEmailValidation",
"(",
"User",
"$",
"user",
")",
"{",
"$",
"ts",
"=",
"$",
"user",
"->",
"email_verification_token_timestamp",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"ts",
")",
"&&",
"(",
"time",
"(",
")",
"-",
"$",
"thi... | Ensure whether the current user has an active email verification token or not.
@param User $user The user object to evaluate.
@return boolean | [
"Ensure",
"whether",
"the",
"current",
"user",
"has",
"an",
"active",
"email",
"verification",
"token",
"or",
"not",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/UserController.php#L59-L67 | train |
luyadev/luya-module-admin | src/apis/UserController.php | UserController.actionChangePassword | public function actionChangePassword()
{
$model = new UserChangePassword();
$model->setUser(Yii::$app->adminuser->identity);
$model->attributes = Yii::$app->request->bodyParams;
if ($this->module->strongPasswordPolicy) {
$model->validators->append(StrengthValidator::createValidator(StrengthValidator::class, $model, ['newpass']));
}
if ($model->validate()) {
$model->checkAndStore();
}
return $model;
} | php | public function actionChangePassword()
{
$model = new UserChangePassword();
$model->setUser(Yii::$app->adminuser->identity);
$model->attributes = Yii::$app->request->bodyParams;
if ($this->module->strongPasswordPolicy) {
$model->validators->append(StrengthValidator::createValidator(StrengthValidator::class, $model, ['newpass']));
}
if ($model->validate()) {
$model->checkAndStore();
}
return $model;
} | [
"public",
"function",
"actionChangePassword",
"(",
")",
"{",
"$",
"model",
"=",
"new",
"UserChangePassword",
"(",
")",
";",
"$",
"model",
"->",
"setUser",
"(",
"Yii",
"::",
"$",
"app",
"->",
"adminuser",
"->",
"identity",
")",
";",
"$",
"model",
"->",
... | Action to change the password for the given User.
@return \luya\admin\models\UserChangePassword | [
"Action",
"to",
"change",
"the",
"password",
"for",
"the",
"given",
"User",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/UserController.php#L74-L89 | train |
luyadev/luya-module-admin | src/apis/UserController.php | UserController.actionChangeEmail | public function actionChangeEmail()
{
$token = Yii::$app->request->getBodyParam('token');
$user = Yii::$app->adminuser->identity;
if (!empty($token) && sha1($token) == $user->email_verification_token && $this->hasOpenEmailValidation($user)) {
$newEmail = $user->setting->get(User::USER_SETTING_NEWUSEREMAIL);
$user->email = $newEmail;
if ($user->update(true, ['email'])) {
$user->resetEmailVerification();
$newEmail = $user->setting->remove(User::USER_SETTING_NEWUSEREMAIL);
return ['success' => true];
} else {
return $this->sendModelError($user);
}
}
return $this->sendArrayError(['email' => Module::t('account_changeemail_wrongtokenorempty')]);
} | php | public function actionChangeEmail()
{
$token = Yii::$app->request->getBodyParam('token');
$user = Yii::$app->adminuser->identity;
if (!empty($token) && sha1($token) == $user->email_verification_token && $this->hasOpenEmailValidation($user)) {
$newEmail = $user->setting->get(User::USER_SETTING_NEWUSEREMAIL);
$user->email = $newEmail;
if ($user->update(true, ['email'])) {
$user->resetEmailVerification();
$newEmail = $user->setting->remove(User::USER_SETTING_NEWUSEREMAIL);
return ['success' => true];
} else {
return $this->sendModelError($user);
}
}
return $this->sendArrayError(['email' => Module::t('account_changeemail_wrongtokenorempty')]);
} | [
"public",
"function",
"actionChangeEmail",
"(",
")",
"{",
"$",
"token",
"=",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"getBodyParam",
"(",
"'token'",
")",
";",
"$",
"user",
"=",
"Yii",
"::",
"$",
"app",
"->",
"adminuser",
"->",
"identity",
";",
... | Action to change the email based on token input.
@return boolean
@since 1.2.0 | [
"Action",
"to",
"change",
"the",
"email",
"based",
"on",
"token",
"input",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/UserController.php#L97-L116 | train |
luyadev/luya-module-admin | src/apis/UserController.php | UserController.actionSessionUpdate | public function actionSessionUpdate()
{
$identity = Yii::$app->adminuser->identity;
$user = clone Yii::$app->adminuser->identity;
$user->attributes = Yii::$app->request->bodyParams;
$verify = ['title', 'firstname', 'lastname', 'id'];
// check if email has changed, if yes send secure token and temp store new value in user settings table.
if ($user->validate(['email']) && $user->email !== $identity->email && $this->module->emailVerification) {
$token = $user->getAndStoreEmailVerificationToken();
$mail = Yii::$app->mail->compose(Module::t('account_changeemail_subject'), Module::t('account_changeemail_body', ['url' => Url::base(true), 'token' => $token]))
->address($identity->email, $identity->firstname . ' '. $identity->lastname)
->send();
if ($mail) {
$identity->setting->set(User::USER_SETTING_NEWUSEREMAIL, $user->email);
} else {
$user->addError('email', Module::t('account_changeemail_tokensenterror', ['email' => $identity->email]));
$identity->resetEmailVerification();
}
}
if (!$this->module->emailVerification) {
$verify[] = 'email';
}
if (!$user->hasErrors() && $user->update(true, $verify) !== false) {
return $user;
}
return $this->sendModelError($user);
} | php | public function actionSessionUpdate()
{
$identity = Yii::$app->adminuser->identity;
$user = clone Yii::$app->adminuser->identity;
$user->attributes = Yii::$app->request->bodyParams;
$verify = ['title', 'firstname', 'lastname', 'id'];
// check if email has changed, if yes send secure token and temp store new value in user settings table.
if ($user->validate(['email']) && $user->email !== $identity->email && $this->module->emailVerification) {
$token = $user->getAndStoreEmailVerificationToken();
$mail = Yii::$app->mail->compose(Module::t('account_changeemail_subject'), Module::t('account_changeemail_body', ['url' => Url::base(true), 'token' => $token]))
->address($identity->email, $identity->firstname . ' '. $identity->lastname)
->send();
if ($mail) {
$identity->setting->set(User::USER_SETTING_NEWUSEREMAIL, $user->email);
} else {
$user->addError('email', Module::t('account_changeemail_tokensenterror', ['email' => $identity->email]));
$identity->resetEmailVerification();
}
}
if (!$this->module->emailVerification) {
$verify[] = 'email';
}
if (!$user->hasErrors() && $user->update(true, $verify) !== false) {
return $user;
}
return $this->sendModelError($user);
} | [
"public",
"function",
"actionSessionUpdate",
"(",
")",
"{",
"$",
"identity",
"=",
"Yii",
"::",
"$",
"app",
"->",
"adminuser",
"->",
"identity",
";",
"$",
"user",
"=",
"clone",
"Yii",
"::",
"$",
"app",
"->",
"adminuser",
"->",
"identity",
";",
"$",
"use... | Update data for the current session user.
@return array | [
"Update",
"data",
"for",
"the",
"current",
"session",
"user",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/UserController.php#L123-L155 | train |
luyadev/luya-module-admin | src/apis/UserController.php | UserController.actionChangeSettings | public function actionChangeSettings()
{
$params = Yii::$app->request->bodyParams;
foreach ($params as $param => $value) {
Yii::$app->adminuser->identity->setting->set($param, $value);
}
return true;
} | php | public function actionChangeSettings()
{
$params = Yii::$app->request->bodyParams;
foreach ($params as $param => $value) {
Yii::$app->adminuser->identity->setting->set($param, $value);
}
return true;
} | [
"public",
"function",
"actionChangeSettings",
"(",
")",
"{",
"$",
"params",
"=",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"bodyParams",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"param",
"=>",
"$",
"value",
")",
"{",
"Yii",
"::",
"$",
"ap... | Change user settings.
@return boolean | [
"Change",
"user",
"settings",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/UserController.php#L162-L171 | train |
luyadev/luya-module-admin | src/commands/StorageController.php | StorageController.actionCleanup | public function actionCleanup()
{
$fileList = StorageImporter::getOrphanedFileList();
if ($fileList === false) {
return $this->outputError("Could not find the storage folder to clean up.");
}
if (count($fileList) > 0) {
foreach ($fileList as $fileName) {
$this->output($fileName);
}
$this->outputInfo(count($fileList) . " files to remove.");
}
if (count($fileList) !== 0) {
$success = true;
if ($this->confirm("Do you want to delete " . count($fileList) . " files which are not referenced in the database any more? (can not be undon, maybe create a backup first!)")) {
foreach ($fileList as $file) {
if (is_file($file) && @unlink($file)) {
$this->outputSuccess($file . " successful deleted.");
} elseif (is_file($file)) {
$this->outputError($file . " could not be deleted!");
$success = false;
} else {
$this->outputError($file . " could not be found!");
$success = false;
}
}
}
if ($success) {
return $this->outputSuccess(count($fileList) . " files successful deleted.");
}
return $this->outputError("Cleanup could not be completed. Please look into error above.");
}
return $this->outputSuccess("No orphaned files found.");
} | php | public function actionCleanup()
{
$fileList = StorageImporter::getOrphanedFileList();
if ($fileList === false) {
return $this->outputError("Could not find the storage folder to clean up.");
}
if (count($fileList) > 0) {
foreach ($fileList as $fileName) {
$this->output($fileName);
}
$this->outputInfo(count($fileList) . " files to remove.");
}
if (count($fileList) !== 0) {
$success = true;
if ($this->confirm("Do you want to delete " . count($fileList) . " files which are not referenced in the database any more? (can not be undon, maybe create a backup first!)")) {
foreach ($fileList as $file) {
if (is_file($file) && @unlink($file)) {
$this->outputSuccess($file . " successful deleted.");
} elseif (is_file($file)) {
$this->outputError($file . " could not be deleted!");
$success = false;
} else {
$this->outputError($file . " could not be found!");
$success = false;
}
}
}
if ($success) {
return $this->outputSuccess(count($fileList) . " files successful deleted.");
}
return $this->outputError("Cleanup could not be completed. Please look into error above.");
}
return $this->outputSuccess("No orphaned files found.");
} | [
"public",
"function",
"actionCleanup",
"(",
")",
"{",
"$",
"fileList",
"=",
"StorageImporter",
"::",
"getOrphanedFileList",
"(",
")",
";",
"if",
"(",
"$",
"fileList",
"===",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"outputError",
"(",
"\"Could not fin... | Delete orphaned files, but requires user confirmation to ensure delete process. | [
"Delete",
"orphaned",
"files",
"but",
"requires",
"user",
"confirmation",
"to",
"ensure",
"delete",
"process",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/commands/StorageController.php#L23-L60 | train |
luyadev/luya-module-admin | src/commands/StorageController.php | StorageController.actionProcessThumbnails | public function actionProcessThumbnails()
{
$response = Yii::$app->storage->processThumbnails();
if ($response) {
return $this->outputSuccess('Successful generated storage thumbnails.');
}
return $this->outputError('Error while creating the storage thumbnails.');
} | php | public function actionProcessThumbnails()
{
$response = Yii::$app->storage->processThumbnails();
if ($response) {
return $this->outputSuccess('Successful generated storage thumbnails.');
}
return $this->outputError('Error while creating the storage thumbnails.');
} | [
"public",
"function",
"actionProcessThumbnails",
"(",
")",
"{",
"$",
"response",
"=",
"Yii",
"::",
"$",
"app",
"->",
"storage",
"->",
"processThumbnails",
"(",
")",
";",
"if",
"(",
"$",
"response",
")",
"{",
"return",
"$",
"this",
"->",
"outputSuccess",
... | Create all thumbnails for filemanager preview. Otherwhise they are created on request load. | [
"Create",
"all",
"thumbnails",
"for",
"filemanager",
"preview",
".",
"Otherwhise",
"they",
"are",
"created",
"on",
"request",
"load",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/commands/StorageController.php#L65-L74 | train |
luyadev/luya-module-admin | src/commands/StorageController.php | StorageController.actionCleanupImageTable | public function actionCleanupImageTable()
{
$rows = Yii::$app->db->createCommand('SELECT file_id, filter_id, COUNT(*) as count FROM {{%admin_storage_image}} GROUP BY file_id, filter_id HAVING COUNT(*) > 1')->queryAll();
if (empty($rows)) {
return $this->outputInfo("no dublications has been detected.");
}
$this->outputInfo("dublicated image files detected:");
foreach ($rows as $row) {
$this->output("> file {$row['file_id']} with filter {$row['filter_id']} found {$row['count']} duplicates.");
}
if ($this->confirm("Do you want to delte the duplicated files in the image storage table?")) {
foreach ($rows as $key => $row) {
// get the lowest entrie
$keep = Yii::$app->db->createCommand('SELECT id FROM {{%admin_storage_image}} WHERE file_id=:fileId AND filter_id=:filterId ORDER BY id LIMIT 1', [
':fileId' => $row['file_id'],
':filterId' => $row['filter_id'],
])->queryOne();
if (!$keep) {
$this->outputError('Unable to find the first row for this delete request. Skip this one');
continue;
}
$remove = Yii::$app->db->createCommand()->delete('{{%admin_storage_image}}', 'file_id=:fileId AND filter_id=:filterId AND id!=:id', [
':fileId' => $row['file_id'],
':filterId' => $row['filter_id'],
':id' => $keep['id'],
])->execute();
if ($remove) {
$this->outputSuccess("< Remove {$row['count']} duplications for file {$row['file_id']} with filter {$row['filter_id']}.");
}
}
}
return $this->outputSuccess("all duplications has been removed.");
} | php | public function actionCleanupImageTable()
{
$rows = Yii::$app->db->createCommand('SELECT file_id, filter_id, COUNT(*) as count FROM {{%admin_storage_image}} GROUP BY file_id, filter_id HAVING COUNT(*) > 1')->queryAll();
if (empty($rows)) {
return $this->outputInfo("no dublications has been detected.");
}
$this->outputInfo("dublicated image files detected:");
foreach ($rows as $row) {
$this->output("> file {$row['file_id']} with filter {$row['filter_id']} found {$row['count']} duplicates.");
}
if ($this->confirm("Do you want to delte the duplicated files in the image storage table?")) {
foreach ($rows as $key => $row) {
// get the lowest entrie
$keep = Yii::$app->db->createCommand('SELECT id FROM {{%admin_storage_image}} WHERE file_id=:fileId AND filter_id=:filterId ORDER BY id LIMIT 1', [
':fileId' => $row['file_id'],
':filterId' => $row['filter_id'],
])->queryOne();
if (!$keep) {
$this->outputError('Unable to find the first row for this delete request. Skip this one');
continue;
}
$remove = Yii::$app->db->createCommand()->delete('{{%admin_storage_image}}', 'file_id=:fileId AND filter_id=:filterId AND id!=:id', [
':fileId' => $row['file_id'],
':filterId' => $row['filter_id'],
':id' => $keep['id'],
])->execute();
if ($remove) {
$this->outputSuccess("< Remove {$row['count']} duplications for file {$row['file_id']} with filter {$row['filter_id']}.");
}
}
}
return $this->outputSuccess("all duplications has been removed.");
} | [
"public",
"function",
"actionCleanupImageTable",
"(",
")",
"{",
"$",
"rows",
"=",
"Yii",
"::",
"$",
"app",
"->",
"db",
"->",
"createCommand",
"(",
"'SELECT file_id, filter_id, COUNT(*) as count FROM {{%admin_storage_image}} GROUP BY file_id, filter_id HAVING COUNT(*) > 1'",
")"... | See image duplications exists of filter and file id combination and remove them execept of the first created.
@return number | [
"See",
"image",
"duplications",
"exists",
"of",
"filter",
"and",
"file",
"id",
"combination",
"and",
"remove",
"them",
"execept",
"of",
"the",
"first",
"created",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/commands/StorageController.php#L81-L120 | train |
luyadev/luya-module-admin | src/base/RestController.php | RestController.checkRouteAccess | public function checkRouteAccess($route)
{
UserOnline::refreshUser($this->userAuthClass()->identity, $route);
if (!Yii::$app->auth->matchRoute($this->userAuthClass()->identity->id, $route)) {
throw new ForbiddenHttpException('Unable to access this action due to insufficient permissions.');
}
} | php | public function checkRouteAccess($route)
{
UserOnline::refreshUser($this->userAuthClass()->identity, $route);
if (!Yii::$app->auth->matchRoute($this->userAuthClass()->identity->id, $route)) {
throw new ForbiddenHttpException('Unable to access this action due to insufficient permissions.');
}
} | [
"public",
"function",
"checkRouteAccess",
"(",
"$",
"route",
")",
"{",
"UserOnline",
"::",
"refreshUser",
"(",
"$",
"this",
"->",
"userAuthClass",
"(",
")",
"->",
"identity",
",",
"$",
"route",
")",
";",
"if",
"(",
"!",
"Yii",
"::",
"$",
"app",
"->",
... | Shorthand method to check whether the current use exists for the given route, otherwise throw forbidden http exception.
@throws ForbiddenHttpException::
@since 1.1.0 | [
"Shorthand",
"method",
"to",
"check",
"whether",
"the",
"current",
"use",
"exists",
"for",
"the",
"given",
"route",
"otherwise",
"throw",
"forbidden",
"http",
"exception",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/base/RestController.php#L60-L67 | train |
luyadev/luya-module-admin | src/controllers/DefaultController.php | DefaultController.actionIndex | public function actionIndex()
{
$tags = [];
foreach (TagParser::getInstantiatedTagObjects() as $name => $object) {
$tags[] = [
'name' => $name,
'example' => $object->example(),
'readme' => Markdown::process($object->readme()),
];
}
// register i18n
$this->view->registerJs('var i18n=' . Json::encode($this->module->jsTranslations), View::POS_HEAD);
$authToken = UserLogin::find()->select(['auth_token'])->where(['user_id' => Yii::$app->adminuser->id, 'ip' => Yii::$app->request->userIP, 'is_destroyed' => false])->scalar();
$this->view->registerJs('zaa.run([\'$rootScope\', function($rootScope) { $rootScope.luyacfg = ' . Json::encode([
'authToken' => $authToken,
'homeUrl' => Url::home(true),
'i18n' => $this->module->jsTranslations,
'helptags' => $tags,
]). '; }]);', View::POS_END);
return $this->render('index');
} | php | public function actionIndex()
{
$tags = [];
foreach (TagParser::getInstantiatedTagObjects() as $name => $object) {
$tags[] = [
'name' => $name,
'example' => $object->example(),
'readme' => Markdown::process($object->readme()),
];
}
// register i18n
$this->view->registerJs('var i18n=' . Json::encode($this->module->jsTranslations), View::POS_HEAD);
$authToken = UserLogin::find()->select(['auth_token'])->where(['user_id' => Yii::$app->adminuser->id, 'ip' => Yii::$app->request->userIP, 'is_destroyed' => false])->scalar();
$this->view->registerJs('zaa.run([\'$rootScope\', function($rootScope) { $rootScope.luyacfg = ' . Json::encode([
'authToken' => $authToken,
'homeUrl' => Url::home(true),
'i18n' => $this->module->jsTranslations,
'helptags' => $tags,
]). '; }]);', View::POS_END);
return $this->render('index');
} | [
"public",
"function",
"actionIndex",
"(",
")",
"{",
"$",
"tags",
"=",
"[",
"]",
";",
"foreach",
"(",
"TagParser",
"::",
"getInstantiatedTagObjects",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"object",
")",
"{",
"$",
"tags",
"[",
"]",
"=",
"[",
"'name'"... | Render the admin index page.
@return string | [
"Render",
"the",
"admin",
"index",
"page",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/controllers/DefaultController.php#L52-L76 | train |
luyadev/luya-module-admin | src/controllers/DefaultController.php | DefaultController.actionLogout | public function actionLogout()
{
if (!Yii::$app->adminuser->logout(false)) {
Yii::$app->session->destroy();
}
return $this->redirect(['/admin/login/index', 'logout' => true]);
} | php | public function actionLogout()
{
if (!Yii::$app->adminuser->logout(false)) {
Yii::$app->session->destroy();
}
return $this->redirect(['/admin/login/index', 'logout' => true]);
} | [
"public",
"function",
"actionLogout",
"(",
")",
"{",
"if",
"(",
"!",
"Yii",
"::",
"$",
"app",
"->",
"adminuser",
"->",
"logout",
"(",
"false",
")",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"destroy",
"(",
")",
";",
"}",
"return",
... | Trigger user logout.
@return \yii\web\Response | [
"Trigger",
"user",
"logout",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/controllers/DefaultController.php#L102-L109 | train |
luyadev/luya-module-admin | src/controllers/DefaultController.php | DefaultController.colorizeValue | public function colorizeValue($value, $displayValue = false)
{
$text = ($displayValue) ? $value : Module::t('debug_state_on');
if ($value) {
return '<span style="color:green;">'.$text.'</span>';
}
return '<span style="color:red;">'.Module::t('debug_state_off').'</span>';
} | php | public function colorizeValue($value, $displayValue = false)
{
$text = ($displayValue) ? $value : Module::t('debug_state_on');
if ($value) {
return '<span style="color:green;">'.$text.'</span>';
}
return '<span style="color:red;">'.Module::t('debug_state_off').'</span>';
} | [
"public",
"function",
"colorizeValue",
"(",
"$",
"value",
",",
"$",
"displayValue",
"=",
"false",
")",
"{",
"$",
"text",
"=",
"(",
"$",
"displayValue",
")",
"?",
"$",
"value",
":",
"Module",
"::",
"t",
"(",
"'debug_state_on'",
")",
";",
"if",
"(",
"$... | Context helper for layout main.php in order to colorize debug informations.
@param string $value
@param boolean $displayValue
@return string | [
"Context",
"helper",
"for",
"layout",
"main",
".",
"php",
"in",
"order",
"to",
"colorize",
"debug",
"informations",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/controllers/DefaultController.php#L118-L125 | train |
luyadev/luya-module-admin | src/helpers/Storage.php | Storage.getUploadErrorMessages | public static function getUploadErrorMessages()
{
return [
UPLOAD_ERR_OK => Module::t('upload_err_message_0'),
UPLOAD_ERR_INI_SIZE => Module::t('upload_err_message_1'),
UPLOAD_ERR_FORM_SIZE => Module::t('upload_err_message_2'),
UPLOAD_ERR_PARTIAL => Module::t('upload_err_message_3'),
UPLOAD_ERR_NO_FILE => Module::t('upload_err_message_4'),
UPLOAD_ERR_NO_TMP_DIR => Module::t('upload_err_message_6'),
UPLOAD_ERR_CANT_WRITE => Module::t('upload_err_message_7'),
UPLOAD_ERR_EXTENSION => Module::t('upload_err_message_8'),
];
} | php | public static function getUploadErrorMessages()
{
return [
UPLOAD_ERR_OK => Module::t('upload_err_message_0'),
UPLOAD_ERR_INI_SIZE => Module::t('upload_err_message_1'),
UPLOAD_ERR_FORM_SIZE => Module::t('upload_err_message_2'),
UPLOAD_ERR_PARTIAL => Module::t('upload_err_message_3'),
UPLOAD_ERR_NO_FILE => Module::t('upload_err_message_4'),
UPLOAD_ERR_NO_TMP_DIR => Module::t('upload_err_message_6'),
UPLOAD_ERR_CANT_WRITE => Module::t('upload_err_message_7'),
UPLOAD_ERR_EXTENSION => Module::t('upload_err_message_8'),
];
} | [
"public",
"static",
"function",
"getUploadErrorMessages",
"(",
")",
"{",
"return",
"[",
"UPLOAD_ERR_OK",
"=>",
"Module",
"::",
"t",
"(",
"'upload_err_message_0'",
")",
",",
"UPLOAD_ERR_INI_SIZE",
"=>",
"Module",
"::",
"t",
"(",
"'upload_err_message_1'",
")",
",",
... | Get the file upload error messages.
@return array All possible error codes when uploading files with its given message and meaning. | [
"Get",
"the",
"file",
"upload",
"error",
"messages",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/helpers/Storage.php#L29-L41 | train |
luyadev/luya-module-admin | src/helpers/Storage.php | Storage.removeFile | public static function removeFile($fileId, $cleanup = false)
{
$model = StorageFile::find()->where(['id' => $fileId, 'is_deleted' => false])->one();
if ($model) {
if ($cleanup) {
foreach (Yii::$app->storage->findImages(['file_id' => $fileId]) as $imageItem) {
StorageImage::findOne($imageItem->id)->delete();
}
}
$response = $model->delete();
Yii::$app->storage->flushArrays();
return $response;
}
return true;
} | php | public static function removeFile($fileId, $cleanup = false)
{
$model = StorageFile::find()->where(['id' => $fileId, 'is_deleted' => false])->one();
if ($model) {
if ($cleanup) {
foreach (Yii::$app->storage->findImages(['file_id' => $fileId]) as $imageItem) {
StorageImage::findOne($imageItem->id)->delete();
}
}
$response = $model->delete();
Yii::$app->storage->flushArrays();
return $response;
}
return true;
} | [
"public",
"static",
"function",
"removeFile",
"(",
"$",
"fileId",
",",
"$",
"cleanup",
"=",
"false",
")",
"{",
"$",
"model",
"=",
"StorageFile",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'id'",
"=>",
"$",
"fileId",
",",
"'is_deleted'",
"=>",
... | Remove a file from the storage system.
@param integer $fileId The file id to delete
@param boolean $cleanup If cleanup is enabled, also all images will be deleted, this is by default turned off because
casual you want to remove the large source file but not the images where used in several tables and situations.
@return boolean | [
"Remove",
"a",
"file",
"from",
"the",
"storage",
"system",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/helpers/Storage.php#L63-L78 | train |
luyadev/luya-module-admin | src/helpers/Storage.php | Storage.removeImage | public static function removeImage($imageId, $cleanup = false)
{
Yii::$app->storage->flushArrays();
$image = Yii::$app->storage->getImage($imageId);
if ($cleanup && $image) {
$fileId = $image->fileId;
foreach (Yii::$app->storage->findImages(['file_id' => $fileId]) as $imageItem) {
$storageImage = StorageImage::findOne($imageItem->id);
if ($storageImage) {
$storageImage->delete();
}
}
}
$file = StorageImage::findOne($imageId);
if ($file) {
return $file->delete();
}
return false;
} | php | public static function removeImage($imageId, $cleanup = false)
{
Yii::$app->storage->flushArrays();
$image = Yii::$app->storage->getImage($imageId);
if ($cleanup && $image) {
$fileId = $image->fileId;
foreach (Yii::$app->storage->findImages(['file_id' => $fileId]) as $imageItem) {
$storageImage = StorageImage::findOne($imageItem->id);
if ($storageImage) {
$storageImage->delete();
}
}
}
$file = StorageImage::findOne($imageId);
if ($file) {
return $file->delete();
}
return false;
} | [
"public",
"static",
"function",
"removeImage",
"(",
"$",
"imageId",
",",
"$",
"cleanup",
"=",
"false",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"storage",
"->",
"flushArrays",
"(",
")",
";",
"$",
"image",
"=",
"Yii",
"::",
"$",
"app",
"->",
"storage"... | Remove an image from the storage system and database.
@param integer $imageId The corresponding imageId for the {{\luya\admin\models\StorageImage}} Model to remove.
@param boolean $cleanup If cleanup is enabled, all other images will be deleted. Even the {{\luya\admin\models\StorageFile}} will be removed
from the database and filesystem. By default cleanup is disabled and will only remove the provided $imageId itself from {{\luya\admin\models\StorageImage}}.
@return boolean | [
"Remove",
"an",
"image",
"from",
"the",
"storage",
"system",
"and",
"database",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/helpers/Storage.php#L88-L108 | train |
luyadev/luya-module-admin | src/helpers/Storage.php | Storage.getImageResolution | public static function getImageResolution($filePath, $throwException = false)
{
$dimensions = @getimagesize(Yii::getAlias($filePath));
$width = 0;
$height = 0;
if (isset($dimensions[0]) && isset($dimensions[1])) {
$width = (int)$dimensions[0];
$height = (int)$dimensions[1];
} elseif ($throwException) {
throw new Exception("Unable to determine the resoltuions of the file $filePath.");
}
return [
'width' => $width,
'height' => $height,
];
} | php | public static function getImageResolution($filePath, $throwException = false)
{
$dimensions = @getimagesize(Yii::getAlias($filePath));
$width = 0;
$height = 0;
if (isset($dimensions[0]) && isset($dimensions[1])) {
$width = (int)$dimensions[0];
$height = (int)$dimensions[1];
} elseif ($throwException) {
throw new Exception("Unable to determine the resoltuions of the file $filePath.");
}
return [
'width' => $width,
'height' => $height,
];
} | [
"public",
"static",
"function",
"getImageResolution",
"(",
"$",
"filePath",
",",
"$",
"throwException",
"=",
"false",
")",
"{",
"$",
"dimensions",
"=",
"@",
"getimagesize",
"(",
"Yii",
"::",
"getAlias",
"(",
"$",
"filePath",
")",
")",
";",
"$",
"width",
... | Get the image resolution of a given file path.
@param string $filePath
@param bool $throwException
@return array
@throws Exception | [
"Get",
"the",
"image",
"resolution",
"of",
"a",
"given",
"file",
"path",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/helpers/Storage.php#L118-L136 | train |
luyadev/luya-module-admin | src/helpers/Storage.php | Storage.moveFileToFolder | public static function moveFileToFolder($fileId, $folderId)
{
$file = StorageFile::findOne($fileId);
if ($file) {
$file->updateAttributes(['folder_id' => $folderId]);
Yii::$app->storage->flushArrays();
return true;
}
return false;
} | php | public static function moveFileToFolder($fileId, $folderId)
{
$file = StorageFile::findOne($fileId);
if ($file) {
$file->updateAttributes(['folder_id' => $folderId]);
Yii::$app->storage->flushArrays();
return true;
}
return false;
} | [
"public",
"static",
"function",
"moveFileToFolder",
"(",
"$",
"fileId",
",",
"$",
"folderId",
")",
"{",
"$",
"file",
"=",
"StorageFile",
"::",
"findOne",
"(",
"$",
"fileId",
")",
";",
"if",
"(",
"$",
"file",
")",
"{",
"$",
"file",
"->",
"updateAttribut... | Move a storage file to another folder.
@param string|int $fileId
@param string|int $folderId
@return boolean | [
"Move",
"a",
"storage",
"file",
"to",
"another",
"folder",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/helpers/Storage.php#L158-L169 | train |
luyadev/luya-module-admin | src/helpers/Storage.php | Storage.replaceFile | public static function replaceFile($fileName, $newFileSource, $newFileName)
{
try {
Yii::$app->storage->ensureFileUpload($newFileSource, $newFileName);
} catch (\Exception $e) {
return false;
}
return Yii::$app->storage->fileSystemReplaceFile($fileName, $newFileSource);
} | php | public static function replaceFile($fileName, $newFileSource, $newFileName)
{
try {
Yii::$app->storage->ensureFileUpload($newFileSource, $newFileName);
} catch (\Exception $e) {
return false;
}
return Yii::$app->storage->fileSystemReplaceFile($fileName, $newFileSource);
} | [
"public",
"static",
"function",
"replaceFile",
"(",
"$",
"fileName",
",",
"$",
"newFileSource",
",",
"$",
"newFileName",
")",
"{",
"try",
"{",
"Yii",
"::",
"$",
"app",
"->",
"storage",
"->",
"ensureFileUpload",
"(",
"$",
"newFileSource",
",",
"$",
"newFile... | Replace the source of a file on the webeserver based on new and old source path informations.
The replaced file will have the name of the $oldFileSource but the file will be the content of the $newFileSource.
@param string $fileName The filename identifier key in order to find the file based on the locale files system.
@param string $newFileSource The path to the new file which is going to have the same name as the old file e.g. `path/of/new.jpg`. $_FILES['tmp_name']
@param string $newFileName The new name of the file which is uploaded, mostly given from $_FILES['name']
@return boolean Whether moving was successfull or not. | [
"Replace",
"the",
"source",
"of",
"a",
"file",
"on",
"the",
"webeserver",
"based",
"on",
"new",
"and",
"old",
"source",
"path",
"informations",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/helpers/Storage.php#L181-L190 | train |
luyadev/luya-module-admin | src/proxy/ClientBuild.php | ClientBuild.isSkippableTable | private function isSkippableTable($tableName, array $filters)
{
$skip = true;
foreach ($filters as $filter) {
$exclude = false;
if (substr($filter, 0, 1) == "!") {
$exclude = true;
$skip = false;
$filter = substr($filter, 1);
}
if ($filter == $tableName || StringHelper::startsWithWildcard($tableName, $filter)) {
return $exclude;
}
}
return $skip;
} | php | private function isSkippableTable($tableName, array $filters)
{
$skip = true;
foreach ($filters as $filter) {
$exclude = false;
if (substr($filter, 0, 1) == "!") {
$exclude = true;
$skip = false;
$filter = substr($filter, 1);
}
if ($filter == $tableName || StringHelper::startsWithWildcard($tableName, $filter)) {
return $exclude;
}
}
return $skip;
} | [
"private",
"function",
"isSkippableTable",
"(",
"$",
"tableName",
",",
"array",
"$",
"filters",
")",
"{",
"$",
"skip",
"=",
"true",
";",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"filter",
")",
"{",
"$",
"exclude",
"=",
"false",
";",
"if",
"(",
"sub... | Compare the tableName with the given filters.
Example filters:
"cms_*" include only cms_* tables
"cms_*,admin_*" include only cms_* and admin_* tables
"!cms_*" exclude all cms_* tables
"!cms_*,!admin_*" exclude all cms_*and admin_* tables
"cms_*,!admin_*" include all cms_* tables but exclude all admin_* tables
Only first match is relevant:
"cms_*,!admin_*,admin_*" include all cms_* tables but exclude all admin_* tables (last match has no effect)
"cms_*,admin_*,!admin_*" include all cms_* and admin_* tables (last match has no effect)
@param $tableName
@param array $filters Array of tables which should skipped.
@return bool True if table can be skipped.
@since 1.2.1 | [
"Compare",
"the",
"tableName",
"with",
"the",
"given",
"filters",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/proxy/ClientBuild.php#L114-L133 | train |
luyadev/luya-module-admin | src/models/Tag.php | Tag.findRelations | public static function findRelations($tableName, $pkId)
{
return self::find()
->innerJoin(TagRelation::tableName(), '{{%admin_tag_relation}}.tag_id={{%admin_tag}}.id')
->where(['pk_id' => $pkId, 'table_name' => TaggableTrait::cleanBaseTableName($tableName)])
->indexBy('name')
->all();
} | php | public static function findRelations($tableName, $pkId)
{
return self::find()
->innerJoin(TagRelation::tableName(), '{{%admin_tag_relation}}.tag_id={{%admin_tag}}.id')
->where(['pk_id' => $pkId, 'table_name' => TaggableTrait::cleanBaseTableName($tableName)])
->indexBy('name')
->all();
} | [
"public",
"static",
"function",
"findRelations",
"(",
"$",
"tableName",
",",
"$",
"pkId",
")",
"{",
"return",
"self",
"::",
"find",
"(",
")",
"->",
"innerJoin",
"(",
"TagRelation",
"::",
"tableName",
"(",
")",
",",
"'{{%admin_tag_relation}}.tag_id={{%admin_tag}}... | Get all primary key assigned tags for a table name.
@param string $tableName
@param integer $pkId
@return \yii\db\ActiveRecord | [
"Get",
"all",
"primary",
"key",
"assigned",
"tags",
"for",
"a",
"table",
"name",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/Tag.php#L118-L125 | train |
luyadev/luya-module-admin | src/models/Tag.php | Tag.findRelationsTable | public static function findRelationsTable($tableName)
{
return self::find()
->innerJoin(TagRelation::tableName(), '{{%admin_tag_relation}}.tag_id={{%admin_tag}}.id')
->where(['table_name' => TaggableTrait::cleanBaseTableName($tableName)])
->indexBy('name')
->distinct()
->all();
} | php | public static function findRelationsTable($tableName)
{
return self::find()
->innerJoin(TagRelation::tableName(), '{{%admin_tag_relation}}.tag_id={{%admin_tag}}.id')
->where(['table_name' => TaggableTrait::cleanBaseTableName($tableName)])
->indexBy('name')
->distinct()
->all();
} | [
"public",
"static",
"function",
"findRelationsTable",
"(",
"$",
"tableName",
")",
"{",
"return",
"self",
"::",
"find",
"(",
")",
"->",
"innerJoin",
"(",
"TagRelation",
"::",
"tableName",
"(",
")",
",",
"'{{%admin_tag_relation}}.tag_id={{%admin_tag}}.id'",
")",
"->... | Get all assigned tags for table name.
@param string $tableName
@return \yii\db\ActiveRecord | [
"Get",
"all",
"assigned",
"tags",
"for",
"table",
"name",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/Tag.php#L133-L141 | train |
luyadev/luya-module-admin | src/proxy/ClientTable.php | ClientTable.syncData | public function syncData()
{
if (Yii::$app->controller->interactive && $this->getRows() > self::LARGE_TABLE_PROMPT) {
if (Console::confirm("{$this->getName()} has {$this->getRows()} entries. Do you want continue table sync?", true) === false) {
return;
}
}
$sqlMode = $this->prepare();
try {
Yii::$app->db->createCommand()->truncateTable($this->getName())->execute();
$this->syncDataInternal();
} finally {
$this->cleanup($sqlMode);
}
} | php | public function syncData()
{
if (Yii::$app->controller->interactive && $this->getRows() > self::LARGE_TABLE_PROMPT) {
if (Console::confirm("{$this->getName()} has {$this->getRows()} entries. Do you want continue table sync?", true) === false) {
return;
}
}
$sqlMode = $this->prepare();
try {
Yii::$app->db->createCommand()->truncateTable($this->getName())->execute();
$this->syncDataInternal();
} finally {
$this->cleanup($sqlMode);
}
} | [
"public",
"function",
"syncData",
"(",
")",
"{",
"if",
"(",
"Yii",
"::",
"$",
"app",
"->",
"controller",
"->",
"interactive",
"&&",
"$",
"this",
"->",
"getRows",
"(",
")",
">",
"self",
"::",
"LARGE_TABLE_PROMPT",
")",
"{",
"if",
"(",
"Console",
"::",
... | Sync the data from remote table to local table.
@throws \yii\db\Exception | [
"Sync",
"the",
"data",
"from",
"remote",
"table",
"to",
"local",
"table",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/proxy/ClientTable.php#L123-L140 | train |
luyadev/luya-module-admin | src/proxy/ClientTable.php | ClientTable.prepare | protected function prepare()
{
$sqlMode = null;
if (Yii::$app->db->schema instanceof \yii\db\mysql\Schema) {
Yii::$app->db->createCommand('SET FOREIGN_KEY_CHECKS = 0;')->execute();
Yii::$app->db->createCommand('SET UNIQUE_CHECKS = 0;')->execute();
$sqlMode = Yii::$app->db->createCommand('SELECT @@SQL_MODE;')->queryScalar();
Yii::$app->db->createCommand('SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";')->execute();
}
return $sqlMode;
} | php | protected function prepare()
{
$sqlMode = null;
if (Yii::$app->db->schema instanceof \yii\db\mysql\Schema) {
Yii::$app->db->createCommand('SET FOREIGN_KEY_CHECKS = 0;')->execute();
Yii::$app->db->createCommand('SET UNIQUE_CHECKS = 0;')->execute();
$sqlMode = Yii::$app->db->createCommand('SELECT @@SQL_MODE;')->queryScalar();
Yii::$app->db->createCommand('SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";')->execute();
}
return $sqlMode;
} | [
"protected",
"function",
"prepare",
"(",
")",
"{",
"$",
"sqlMode",
"=",
"null",
";",
"if",
"(",
"Yii",
"::",
"$",
"app",
"->",
"db",
"->",
"schema",
"instanceof",
"\\",
"yii",
"\\",
"db",
"\\",
"mysql",
"\\",
"Schema",
")",
"{",
"Yii",
"::",
"$",
... | Prepare database for data sync and set system variables.
Disable the foreign key and unique check. Also set the sql mode to "NO_AUTO_VALUE_ON_ZERO".
Currently only for MySql and MariaDB.
@return false|null|string The old sql mode.
@throws \yii\db\Exception
@since 1.2.1 | [
"Prepare",
"database",
"for",
"data",
"sync",
"and",
"set",
"system",
"variables",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/proxy/ClientTable.php#L152-L165 | train |
luyadev/luya-module-admin | src/proxy/ClientTable.php | ClientTable.cleanup | protected function cleanup($sqlMode)
{
if (Yii::$app->db->schema instanceof \yii\db\mysql\Schema) {
Yii::$app->db->createCommand('SET FOREIGN_KEY_CHECKS = 1;')->execute();
Yii::$app->db->createCommand('SET UNIQUE_CHECKS = 1;')->execute();
if ($sqlMode !== null) {
Yii::$app->db->createCommand('SET SQL_MODE=:sqlMode;', [':sqlMode' => $sqlMode])->execute();
}
}
} | php | protected function cleanup($sqlMode)
{
if (Yii::$app->db->schema instanceof \yii\db\mysql\Schema) {
Yii::$app->db->createCommand('SET FOREIGN_KEY_CHECKS = 1;')->execute();
Yii::$app->db->createCommand('SET UNIQUE_CHECKS = 1;')->execute();
if ($sqlMode !== null) {
Yii::$app->db->createCommand('SET SQL_MODE=:sqlMode;', [':sqlMode' => $sqlMode])->execute();
}
}
} | [
"protected",
"function",
"cleanup",
"(",
"$",
"sqlMode",
")",
"{",
"if",
"(",
"Yii",
"::",
"$",
"app",
"->",
"db",
"->",
"schema",
"instanceof",
"\\",
"yii",
"\\",
"db",
"\\",
"mysql",
"\\",
"Schema",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"db",
... | Revert database system variables.
Enable the foreign key and unique check. Also set the sql mode to the given value.
Currently only for MySql and MariaDB.
@param $sqlMode string|null The old sql mode value from @see \luya\admin\proxy\ClientTable::prepare()
@see \luya\admin\proxy\ClientTable::prepare()
@throws \yii\db\Exception
@since 1.2.1 | [
"Revert",
"database",
"system",
"variables",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/proxy/ClientTable.php#L178-L188 | train |
luyadev/luya-module-admin | src/proxy/ClientTable.php | ClientTable.syncDataInternal | private function syncDataInternal()
{
Console::startProgress(0, $this->getOffsetTotal(), 'Fetch: ' . $this->getName() . ' ');
$this->_contentRowsCount = 0;
$dataChunk = [];
for ($i = 0; $i < $this->getOffsetTotal(); ++$i) {
$requestData = $this->request($i);
if (!$requestData) {
continue;
}
if (0 === $i % $this->build->syncRequestsCount) {
$inserted = $this->insertData($dataChunk);
$this->_contentRowsCount += $inserted;
$dataChunk = [];
}
Console::updateProgress($i + 1, $this->getOffsetTotal());
$dataChunk = array_merge($requestData, $dataChunk);
gc_collect_cycles();
}
if (!empty($dataChunk)) {
$this->insertData($dataChunk);
}
Console::endProgress();
} | php | private function syncDataInternal()
{
Console::startProgress(0, $this->getOffsetTotal(), 'Fetch: ' . $this->getName() . ' ');
$this->_contentRowsCount = 0;
$dataChunk = [];
for ($i = 0; $i < $this->getOffsetTotal(); ++$i) {
$requestData = $this->request($i);
if (!$requestData) {
continue;
}
if (0 === $i % $this->build->syncRequestsCount) {
$inserted = $this->insertData($dataChunk);
$this->_contentRowsCount += $inserted;
$dataChunk = [];
}
Console::updateProgress($i + 1, $this->getOffsetTotal());
$dataChunk = array_merge($requestData, $dataChunk);
gc_collect_cycles();
}
if (!empty($dataChunk)) {
$this->insertData($dataChunk);
}
Console::endProgress();
} | [
"private",
"function",
"syncDataInternal",
"(",
")",
"{",
"Console",
"::",
"startProgress",
"(",
"0",
",",
"$",
"this",
"->",
"getOffsetTotal",
"(",
")",
",",
"'Fetch: '",
".",
"$",
"this",
"->",
"getName",
"(",
")",
".",
"' '",
")",
";",
"$",
"this",
... | Start the data sync.
Fetch the data from remote url and write into the database.
@throws \yii\db\Exception
@see \luya\admin\proxy\ClientBuild::$syncRequestsCount
@since 1.2.1 | [
"Start",
"the",
"data",
"sync",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/proxy/ClientTable.php#L199-L229 | train |
luyadev/luya-module-admin | src/proxy/ClientTable.php | ClientTable.request | private function request($offset)
{
$curl = new Curl();
$curl->get($this->build->requestUrl, [
'machine' => $this->build->machineIdentifier,
'buildToken' => $this->build->buildToken,
'table' => $this->name,
'offset' => $offset
]);
if (!$curl->error) {
$response = Json::decode($curl->response);
$curl->close();
unset($curl);
return $response;
} else {
$this->build->command->outputError('Error while collecting data from server: ' . $curl->error_message);
}
return false;
} | php | private function request($offset)
{
$curl = new Curl();
$curl->get($this->build->requestUrl, [
'machine' => $this->build->machineIdentifier,
'buildToken' => $this->build->buildToken,
'table' => $this->name,
'offset' => $offset
]);
if (!$curl->error) {
$response = Json::decode($curl->response);
$curl->close();
unset($curl);
return $response;
} else {
$this->build->command->outputError('Error while collecting data from server: ' . $curl->error_message);
}
return false;
} | [
"private",
"function",
"request",
"(",
"$",
"offset",
")",
"{",
"$",
"curl",
"=",
"new",
"Curl",
"(",
")",
";",
"$",
"curl",
"->",
"get",
"(",
"$",
"this",
"->",
"build",
"->",
"requestUrl",
",",
"[",
"'machine'",
"=>",
"$",
"this",
"->",
"build",
... | Send request for this table and return the JSON data.
@param $offset
@return bool|mixed JSON response, false if failed. | [
"Send",
"request",
"for",
"this",
"table",
"and",
"return",
"the",
"JSON",
"data",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/proxy/ClientTable.php#L237-L258 | train |
luyadev/luya-module-admin | src/proxy/ClientTable.php | ClientTable.insertData | private function insertData($data)
{
$inserted = Yii::$app->db->createCommand()->batchInsert(
$this->getName(),
$this->cleanUpBatchInsertFields($this->getFields()),
$this->cleanUpMatchRow($data)
)->execute();
return $inserted;
} | php | private function insertData($data)
{
$inserted = Yii::$app->db->createCommand()->batchInsert(
$this->getName(),
$this->cleanUpBatchInsertFields($this->getFields()),
$this->cleanUpMatchRow($data)
)->execute();
return $inserted;
} | [
"private",
"function",
"insertData",
"(",
"$",
"data",
")",
"{",
"$",
"inserted",
"=",
"Yii",
"::",
"$",
"app",
"->",
"db",
"->",
"createCommand",
"(",
")",
"->",
"batchInsert",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"... | Write the given data to the database.
@param $data
@throws \yii\db\Exception
@return int | [
"Write",
"the",
"given",
"data",
"to",
"the",
"database",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/proxy/ClientTable.php#L267-L276 | train |
luyadev/luya-module-admin | src/components/Auth.php | Auth.getPermissionTable | public function getPermissionTable($userId)
{
if ($this->_permissionTable === null) {
$this->_permissionTable = (new Query())
->select(['*'])
->from('{{%admin_user_group}}')
->innerJoin('{{%admin_group_auth}}', '{{%admin_user_group}}.group_id={{%admin_group_auth}}.group_id')
->innerJoin('{{%admin_auth}}', '{{%admin_group_auth}}.auth_id = {{%admin_auth}}.id')
->where(['{{%admin_user_group}}.user_id' => $userId])
->all();
}
return $this->_permissionTable;
} | php | public function getPermissionTable($userId)
{
if ($this->_permissionTable === null) {
$this->_permissionTable = (new Query())
->select(['*'])
->from('{{%admin_user_group}}')
->innerJoin('{{%admin_group_auth}}', '{{%admin_user_group}}.group_id={{%admin_group_auth}}.group_id')
->innerJoin('{{%admin_auth}}', '{{%admin_group_auth}}.auth_id = {{%admin_auth}}.id')
->where(['{{%admin_user_group}}.user_id' => $userId])
->all();
}
return $this->_permissionTable;
} | [
"public",
"function",
"getPermissionTable",
"(",
"$",
"userId",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_permissionTable",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_permissionTable",
"=",
"(",
"new",
"Query",
"(",
")",
")",
"->",
"select",
"(",
"[... | Get all permissions entries for the given User.
@param integer $userId The user id to retrieve the data for.
@return array | [
"Get",
"all",
"permissions",
"entries",
"for",
"the",
"given",
"User",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/components/Auth.php#L50-L63 | train |
luyadev/luya-module-admin | src/components/Auth.php | Auth.getApiTable | public function getApiTable($userId, $apiEndpoint)
{
$data = [];
foreach ($this->getPermissionTable($userId) as $item) {
if ($item['api'] == $apiEndpoint && $item['user_id'] == $userId) {
$data[] = $item;
}
}
return $data;
} | php | public function getApiTable($userId, $apiEndpoint)
{
$data = [];
foreach ($this->getPermissionTable($userId) as $item) {
if ($item['api'] == $apiEndpoint && $item['user_id'] == $userId) {
$data[] = $item;
}
}
return $data;
} | [
"public",
"function",
"getApiTable",
"(",
"$",
"userId",
",",
"$",
"apiEndpoint",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getPermissionTable",
"(",
"$",
"userId",
")",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"... | Get the data for a given api and user.
@param integer $userId The user id the find the data from.
@param string $apiEndpoint The api endpoint to find from the permission system.
@return array | [
"Get",
"the",
"data",
"for",
"a",
"given",
"api",
"and",
"user",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/components/Auth.php#L85-L94 | train |
luyadev/luya-module-admin | src/components/Auth.php | Auth.getRouteTable | public function getRouteTable($userId, $route)
{
$data = [];
foreach ($this->getPermissionTable($userId) as $item) {
if ($item['route'] == $route && $item['user_id'] == $userId) {
$data[] = $item;
}
}
return $data;
} | php | public function getRouteTable($userId, $route)
{
$data = [];
foreach ($this->getPermissionTable($userId) as $item) {
if ($item['route'] == $route && $item['user_id'] == $userId) {
$data[] = $item;
}
}
return $data;
} | [
"public",
"function",
"getRouteTable",
"(",
"$",
"userId",
",",
"$",
"route",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getPermissionTable",
"(",
"$",
"userId",
")",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
... | Get the data for a given route and user.
@param integer $userId The user id the find the data from.
@param string $route The route to find from the permission system.
@return array | [
"Get",
"the",
"data",
"for",
"a",
"given",
"route",
"and",
"user",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/components/Auth.php#L103-L112 | train |
luyadev/luya-module-admin | src/components/Auth.php | Auth.permissionVerify | public function permissionVerify($type, $permissionWeight)
{
$numbers = [];
switch ($type) {
case self::CAN_CREATE:
$numbers = [1, 4, 6, 9];
break;
case self::CAN_UPDATE:
$numbers = [3, 4, 8, 9];
break;
case self::CAN_DELETE:
$numbers = [5, 6, 8, 9];
break;
}
return in_array($permissionWeight, $numbers);
} | php | public function permissionVerify($type, $permissionWeight)
{
$numbers = [];
switch ($type) {
case self::CAN_CREATE:
$numbers = [1, 4, 6, 9];
break;
case self::CAN_UPDATE:
$numbers = [3, 4, 8, 9];
break;
case self::CAN_DELETE:
$numbers = [5, 6, 8, 9];
break;
}
return in_array($permissionWeight, $numbers);
} | [
"public",
"function",
"permissionVerify",
"(",
"$",
"type",
",",
"$",
"permissionWeight",
")",
"{",
"$",
"numbers",
"=",
"[",
"]",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"self",
"::",
"CAN_CREATE",
":",
"$",
"numbers",
"=",
"[",
"1",
",",... | Verify a permission type against its calculated `weight`.
In order to calculate the permissions weight see {{\luya\admin\components\Auth::permissionWeight}}.
@param string $type The type of permission (1,2,3 see constants)
@param integer $permissionWeight A weight of the permssions which is value between 1 - 9, see [[app-admin-module-permission.md]].
@return boolean | [
"Verify",
"a",
"permission",
"type",
"against",
"its",
"calculated",
"weight",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/components/Auth.php#L140-L157 | train |
luyadev/luya-module-admin | src/components/Auth.php | Auth.matchApi | public function matchApi($userId, $apiEndpoint, $typeVerification = false)
{
$groups = $this->getApiTable($userId, $apiEndpoint);
if ($typeVerification === false || $typeVerification === self::CAN_VIEW) {
return (count($groups) > 0) ? true : false;
}
foreach ($groups as $row) {
if ($this->permissionVerify($typeVerification, $this->permissionWeight($row['crud_create'], $row['crud_update'], $row['crud_delete']))) {
return true;
}
}
return false;
} | php | public function matchApi($userId, $apiEndpoint, $typeVerification = false)
{
$groups = $this->getApiTable($userId, $apiEndpoint);
if ($typeVerification === false || $typeVerification === self::CAN_VIEW) {
return (count($groups) > 0) ? true : false;
}
foreach ($groups as $row) {
if ($this->permissionVerify($typeVerification, $this->permissionWeight($row['crud_create'], $row['crud_update'], $row['crud_delete']))) {
return true;
}
}
return false;
} | [
"public",
"function",
"matchApi",
"(",
"$",
"userId",
",",
"$",
"apiEndpoint",
",",
"$",
"typeVerification",
"=",
"false",
")",
"{",
"$",
"groups",
"=",
"$",
"this",
"->",
"getApiTable",
"(",
"$",
"userId",
",",
"$",
"apiEndpoint",
")",
";",
"if",
"(",... | See if a User have rights to access this api.
@param integer $userId
@param string $apiEndpoint As defined in the Module.php like (api-admin-user) which is a unique identifiere
@param integer|string $typeVerification The CONST number provided from CAN_*
@return bool | [
"See",
"if",
"a",
"User",
"have",
"rights",
"to",
"access",
"this",
"api",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/components/Auth.php#L167-L182 | train |
luyadev/luya-module-admin | src/components/Auth.php | Auth.matchRoute | public function matchRoute($userId, $route)
{
$groups = $this->getRouteTable($userId, $route);
if (is_array($groups) && count($groups) > 0) {
return true;
}
return false;
} | php | public function matchRoute($userId, $route)
{
$groups = $this->getRouteTable($userId, $route);
if (is_array($groups) && count($groups) > 0) {
return true;
}
return false;
} | [
"public",
"function",
"matchRoute",
"(",
"$",
"userId",
",",
"$",
"route",
")",
"{",
"$",
"groups",
"=",
"$",
"this",
"->",
"getRouteTable",
"(",
"$",
"userId",
",",
"$",
"route",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"groups",
")",
"&&",
"cou... | See if the user has permitted the provided route.
@param integer $userId The user id from admin users
@param string $route The route to test.
@return boolean | [
"See",
"if",
"the",
"user",
"has",
"permitted",
"the",
"provided",
"route",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/components/Auth.php#L191-L200 | train |
luyadev/luya-module-admin | src/components/Auth.php | Auth.getDatabaseAuths | public function getDatabaseAuths()
{
// define response structure of array
$data = [
'routes' => [],
'apis' => [],
];
// get all auth data
foreach ((new Query())->select('*')->from('{{%admin_auth}}')->all() as $item) {
// allocate if its an api or route. More differences?
if (empty($item['api'])) {
$data['routes'][] = $item;
} else {
$data['apis'][] = $item;
}
}
return $data;
} | php | public function getDatabaseAuths()
{
// define response structure of array
$data = [
'routes' => [],
'apis' => [],
];
// get all auth data
foreach ((new Query())->select('*')->from('{{%admin_auth}}')->all() as $item) {
// allocate if its an api or route. More differences?
if (empty($item['api'])) {
$data['routes'][] = $item;
} else {
$data['apis'][] = $item;
}
}
return $data;
} | [
"public",
"function",
"getDatabaseAuths",
"(",
")",
"{",
"// define response structure of array",
"$",
"data",
"=",
"[",
"'routes'",
"=>",
"[",
"]",
",",
"'apis'",
"=>",
"[",
"]",
",",
"]",
";",
"// get all auth data",
"foreach",
"(",
"(",
"new",
"Query",
"(... | Returns the current available auth rules inside the admin_auth table splied into routes and apis.
@return array | [
"Returns",
"the",
"current",
"available",
"auth",
"rules",
"inside",
"the",
"admin_auth",
"table",
"splied",
"into",
"routes",
"and",
"apis",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/components/Auth.php#L264-L282 | train |
luyadev/luya-module-admin | src/components/Auth.php | Auth.executeCleanup | public function executeCleanup(array $data)
{
foreach ($data as $rule) {
Yii::$app->db->createCommand()->delete('{{%admin_auth}}', 'id=:id', ['id' => $rule['id']])->execute();
Yii::$app->db->createCommand()->delete('{{%admin_group_auth}}', 'auth_id=:id', ['id' => $rule['id']])->execute();
}
return true;
} | php | public function executeCleanup(array $data)
{
foreach ($data as $rule) {
Yii::$app->db->createCommand()->delete('{{%admin_auth}}', 'id=:id', ['id' => $rule['id']])->execute();
Yii::$app->db->createCommand()->delete('{{%admin_group_auth}}', 'auth_id=:id', ['id' => $rule['id']])->execute();
}
return true;
} | [
"public",
"function",
"executeCleanup",
"(",
"array",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"rule",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"db",
"->",
"createCommand",
"(",
")",
"->",
"delete",
"(",
"'{{%admin_auth}}'",
",",
... | Execute the data to delete based on an array containing a key 'id' with the corresponding value from the Database.
@param array $data
@return bool | [
"Execute",
"the",
"data",
"to",
"delete",
"based",
"on",
"an",
"array",
"containing",
"a",
"key",
"id",
"with",
"the",
"corresponding",
"value",
"from",
"the",
"Database",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/components/Auth.php#L311-L319 | train |
luyadev/luya-module-admin | src/aws/ImageSelectCollectionActiveWindow.php | ImageSelectCollectionActiveWindow.callbackLoadAllImages | public function callbackLoadAllImages()
{
$query = (new Query())
->select(['image_id' => $this->imageIdFieldName])
->where([$this->refFieldName => $this->getItemId()])
->from($this->refTableName);
if ($this->isSortEnabled()) {
$query->orderBy([$this->sortIndexFieldName => SORT_ASC]);
}
$data = $query->all();
$images = [];
foreach ($data as $image) {
$images[] = $this->getImageArray($image['image_id']);
}
return $images;
} | php | public function callbackLoadAllImages()
{
$query = (new Query())
->select(['image_id' => $this->imageIdFieldName])
->where([$this->refFieldName => $this->getItemId()])
->from($this->refTableName);
if ($this->isSortEnabled()) {
$query->orderBy([$this->sortIndexFieldName => SORT_ASC]);
}
$data = $query->all();
$images = [];
foreach ($data as $image) {
$images[] = $this->getImageArray($image['image_id']);
}
return $images;
} | [
"public",
"function",
"callbackLoadAllImages",
"(",
")",
"{",
"$",
"query",
"=",
"(",
"new",
"Query",
"(",
")",
")",
"->",
"select",
"(",
"[",
"'image_id'",
"=>",
"$",
"this",
"->",
"imageIdFieldName",
"]",
")",
"->",
"where",
"(",
"[",
"$",
"this",
... | Load all images.
@return array | [
"Load",
"all",
"images",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/aws/ImageSelectCollectionActiveWindow.php#L116-L134 | train |
luyadev/luya-module-admin | src/aws/ImageSelectCollectionActiveWindow.php | ImageSelectCollectionActiveWindow.getImageArray | private function getImageArray($imageId)
{
$array = Yii::$app->storage->getImage($imageId)->applyFilter(MediumCrop::identifier())->toArray();
$array['originalImageId'] = $imageId;
return $array;
} | php | private function getImageArray($imageId)
{
$array = Yii::$app->storage->getImage($imageId)->applyFilter(MediumCrop::identifier())->toArray();
$array['originalImageId'] = $imageId;
return $array;
} | [
"private",
"function",
"getImageArray",
"(",
"$",
"imageId",
")",
"{",
"$",
"array",
"=",
"Yii",
"::",
"$",
"app",
"->",
"storage",
"->",
"getImage",
"(",
"$",
"imageId",
")",
"->",
"applyFilter",
"(",
"MediumCrop",
"::",
"identifier",
"(",
")",
")",
"... | Get the image array for a given image id.
@param integer $imageId
@return array | [
"Get",
"the",
"image",
"array",
"for",
"a",
"given",
"image",
"id",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/aws/ImageSelectCollectionActiveWindow.php#L142-L149 | train |
luyadev/luya-module-admin | src/aws/ImageSelectCollectionActiveWindow.php | ImageSelectCollectionActiveWindow.callbackRemoveFromIndex | public function callbackRemoveFromIndex($imageId)
{
return Yii::$app->db->createCommand()->delete($this->refTableName, [
$this->imageIdFieldName => (int) $imageId,
$this->refFieldName => (int) $this->getItemId(),
])->execute();
} | php | public function callbackRemoveFromIndex($imageId)
{
return Yii::$app->db->createCommand()->delete($this->refTableName, [
$this->imageIdFieldName => (int) $imageId,
$this->refFieldName => (int) $this->getItemId(),
])->execute();
} | [
"public",
"function",
"callbackRemoveFromIndex",
"(",
"$",
"imageId",
")",
"{",
"return",
"Yii",
"::",
"$",
"app",
"->",
"db",
"->",
"createCommand",
"(",
")",
"->",
"delete",
"(",
"$",
"this",
"->",
"refTableName",
",",
"[",
"$",
"this",
"->",
"imageIdF... | Remove a given image id from the index.
@param integer $imageId The image to delete from the index.
@return number | [
"Remove",
"a",
"given",
"image",
"id",
"from",
"the",
"index",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/aws/ImageSelectCollectionActiveWindow.php#L175-L181 | train |
luyadev/luya-module-admin | src/aws/ImageSelectCollectionActiveWindow.php | ImageSelectCollectionActiveWindow.callbackAddImageToIndex | public function callbackAddImageToIndex($fileId)
{
$image = Yii::$app->storage->addImage($fileId);
if (!$image) {
return $this->sendError("Unable to create image from given file Id.");
}
Yii::$app->db->createCommand()->insert($this->refTableName, $this->prepareInsertFields([
$this->imageIdFieldName => (int) $image->id,
$this->refFieldName => (int) $this->itemId,
]))->execute();
return $this->getImageArray($image->id);
} | php | public function callbackAddImageToIndex($fileId)
{
$image = Yii::$app->storage->addImage($fileId);
if (!$image) {
return $this->sendError("Unable to create image from given file Id.");
}
Yii::$app->db->createCommand()->insert($this->refTableName, $this->prepareInsertFields([
$this->imageIdFieldName => (int) $image->id,
$this->refFieldName => (int) $this->itemId,
]))->execute();
return $this->getImageArray($image->id);
} | [
"public",
"function",
"callbackAddImageToIndex",
"(",
"$",
"fileId",
")",
"{",
"$",
"image",
"=",
"Yii",
"::",
"$",
"app",
"->",
"storage",
"->",
"addImage",
"(",
"$",
"fileId",
")",
";",
"if",
"(",
"!",
"$",
"image",
")",
"{",
"return",
"$",
"this",... | Generate an image for a given file id and store the image in the index.
@param integer $fileId The file id to create the image from and store the image id in the database.
@return array | [
"Generate",
"an",
"image",
"for",
"a",
"given",
"file",
"id",
"and",
"store",
"the",
"image",
"in",
"the",
"index",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/aws/ImageSelectCollectionActiveWindow.php#L189-L203 | train |
luyadev/luya-module-admin | src/aws/ImageSelectCollectionActiveWindow.php | ImageSelectCollectionActiveWindow.callbackChangeSortIndex | public function callbackChangeSortIndex($new, $old)
{
// get old position
$newPos = (new Query)->select([$this->sortIndexFieldName])->from($this->refTableName)->where([$this->imageIdFieldName => $new['originalImageId']])->scalar();
$oldPos = (new Query)->select([$this->sortIndexFieldName])->from($this->refTableName)->where([$this->imageIdFieldName => $old['originalImageId']])->scalar();
// switch positions
$changeNewPos = Yii::$app->db->createCommand()->update($this->refTableName, [$this->sortIndexFieldName => $oldPos], [
$this->imageIdFieldName => $new['originalImageId'],
$this->refFieldName => $this->itemId,
])->execute();
$changeOldPos = Yii::$app->db->createCommand()->update($this->refTableName, [$this->sortIndexFieldName => $newPos], [
$this->imageIdFieldName => $old['originalImageId'],
$this->refFieldName => $this->itemId,
])->execute();
return true;
} | php | public function callbackChangeSortIndex($new, $old)
{
// get old position
$newPos = (new Query)->select([$this->sortIndexFieldName])->from($this->refTableName)->where([$this->imageIdFieldName => $new['originalImageId']])->scalar();
$oldPos = (new Query)->select([$this->sortIndexFieldName])->from($this->refTableName)->where([$this->imageIdFieldName => $old['originalImageId']])->scalar();
// switch positions
$changeNewPos = Yii::$app->db->createCommand()->update($this->refTableName, [$this->sortIndexFieldName => $oldPos], [
$this->imageIdFieldName => $new['originalImageId'],
$this->refFieldName => $this->itemId,
])->execute();
$changeOldPos = Yii::$app->db->createCommand()->update($this->refTableName, [$this->sortIndexFieldName => $newPos], [
$this->imageIdFieldName => $old['originalImageId'],
$this->refFieldName => $this->itemId,
])->execute();
return true;
} | [
"public",
"function",
"callbackChangeSortIndex",
"(",
"$",
"new",
",",
"$",
"old",
")",
"{",
"// get old position",
"$",
"newPos",
"=",
"(",
"new",
"Query",
")",
"->",
"select",
"(",
"[",
"$",
"this",
"->",
"sortIndexFieldName",
"]",
")",
"->",
"from",
"... | Switch position between two images.
@param integer $new
@param integer $old
@return boolean | [
"Switch",
"position",
"between",
"two",
"images",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/aws/ImageSelectCollectionActiveWindow.php#L212-L230 | train |
luyadev/luya-module-admin | src/aws/ImageSelectCollectionActiveWindow.php | ImageSelectCollectionActiveWindow.prepareInsertFields | public function prepareInsertFields(array $fields)
{
if ($this->isSortEnabled()) {
$fields[$this->sortIndexFieldName] = $this->getMaxSortIndex() + 1;
}
return $fields;
} | php | public function prepareInsertFields(array $fields)
{
if ($this->isSortEnabled()) {
$fields[$this->sortIndexFieldName] = $this->getMaxSortIndex() + 1;
}
return $fields;
} | [
"public",
"function",
"prepareInsertFields",
"(",
"array",
"$",
"fields",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isSortEnabled",
"(",
")",
")",
"{",
"$",
"fields",
"[",
"$",
"this",
"->",
"sortIndexFieldName",
"]",
"=",
"$",
"this",
"->",
"getMaxSortIn... | Prepare and parse the insert fields for a given array.
if sort is enabled, the latest sort index is provided.
@param array $fields
@return number | [
"Prepare",
"and",
"parse",
"the",
"insert",
"fields",
"for",
"a",
"given",
"array",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/aws/ImageSelectCollectionActiveWindow.php#L240-L247 | train |
luyadev/luya-module-admin | src/helpers/AngularObject.php | AngularObject.render | public function render()
{
$html = null;
if ($this->_hint) {
$html = '<span class="help-button btn btn-icon btn-help" tooltip tooltip-text="'.$this->_hint.'" tooltip-position="left"></span>';
}
$html .= Angular::directive($this->type, $this->options);
return $html;
} | php | public function render()
{
$html = null;
if ($this->_hint) {
$html = '<span class="help-button btn btn-icon btn-help" tooltip tooltip-text="'.$this->_hint.'" tooltip-position="left"></span>';
}
$html .= Angular::directive($this->type, $this->options);
return $html;
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"html",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"_hint",
")",
"{",
"$",
"html",
"=",
"'<span class=\"help-button btn btn-icon btn-help\" tooltip tooltip-text=\"'",
".",
"$",
"this",
"->",
"_hint",
"."... | Render the Angular Object element
@return string | [
"Render",
"the",
"Angular",
"Object",
"element"
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/helpers/AngularObject.php#L94-L104 | train |
luyadev/luya-module-admin | src/file/Item.php | Item.getCaption | public function getCaption()
{
if ($this->_caption === null) {
// if its a none json value, it has been observed by bind()
if (!Json::isJson($this->getKey('caption', false))) {
$this->_caption = $this->getKey('caption');
} else {
$this->_caption = I18n::findActive($this->getCaptionArray());
}
}
return $this->_caption;
} | php | public function getCaption()
{
if ($this->_caption === null) {
// if its a none json value, it has been observed by bind()
if (!Json::isJson($this->getKey('caption', false))) {
$this->_caption = $this->getKey('caption');
} else {
$this->_caption = I18n::findActive($this->getCaptionArray());
}
}
return $this->_caption;
} | [
"public",
"function",
"getCaption",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_caption",
"===",
"null",
")",
"{",
"// if its a none json value, it has been observed by bind()",
"if",
"(",
"!",
"Json",
"::",
"isJson",
"(",
"$",
"this",
"->",
"getKey",
"(",
... | Return the caption text for this file, if not defined the item array will be collected
@return string The caption text for this image | [
"Return",
"the",
"caption",
"text",
"for",
"this",
"file",
"if",
"not",
"defined",
"the",
"item",
"array",
"will",
"be",
"collected"
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/file/Item.php#L95-L107 | train |
luyadev/luya-module-admin | src/file/Item.php | Item.getSource | public function getSource($scheme = false)
{
return $scheme ? Yii::$app->storage->fileAbsoluteHttpPath($this->getKey('name_new_compound')) : Yii::$app->storage->fileHttpPath($this->getKey('name_new_compound'));
} | php | public function getSource($scheme = false)
{
return $scheme ? Yii::$app->storage->fileAbsoluteHttpPath($this->getKey('name_new_compound')) : Yii::$app->storage->fileHttpPath($this->getKey('name_new_compound'));
} | [
"public",
"function",
"getSource",
"(",
"$",
"scheme",
"=",
"false",
")",
"{",
"return",
"$",
"scheme",
"?",
"Yii",
"::",
"$",
"app",
"->",
"storage",
"->",
"fileAbsoluteHttpPath",
"(",
"$",
"this",
"->",
"getKey",
"(",
"'name_new_compound'",
")",
")",
"... | Get the absolute source path to the file location on the webserver.
This will return raw the path to the storage file inside the sotorage folder without readable urls.
@param boolean $scheme Whether the source path should be absolute or not.
@return string The raw path to the file inside the storage folder. | [
"Get",
"the",
"absolute",
"source",
"path",
"to",
"the",
"file",
"location",
"on",
"the",
"webserver",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/file/Item.php#L302-L305 | train |
luyadev/luya-module-admin | src/file/Item.php | Item.getLink | public function getLink($scheme = false)
{
return Url::toRoute(['/admin/file/download', 'id' => $this->getId(), 'hash' => $this->getHashName(), 'fileName' => $this->getName()], $scheme);
} | php | public function getLink($scheme = false)
{
return Url::toRoute(['/admin/file/download', 'id' => $this->getId(), 'hash' => $this->getHashName(), 'fileName' => $this->getName()], $scheme);
} | [
"public",
"function",
"getLink",
"(",
"$",
"scheme",
"=",
"false",
")",
"{",
"return",
"Url",
"::",
"toRoute",
"(",
"[",
"'/admin/file/download'",
",",
"'id'",
"=>",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"'hash'",
"=>",
"$",
"this",
"->",
"getHash... | Get the link to a file.
The is the most common method when implementing the file object. This method allows you to generate links to the request file. For
example you may want users to see the file (assuming its a PDF).
```php
echo '<a href="{Yii::$app->storage->getFile(123)->link}">Download PDF</a>'; // you could also us href instead in order to be more semantic.
```
The output of source is a url which is provided by a UrlRUle of the admin module and returns nice readable source links:
```
/file/<ID>/<HASH>/<ORIGINAL_NAME>.<EXTENSION>
```
which could look like this when fille up:
```
/public_html/en/file/123/e976e224/foobar.png
```
@return string The relative source url to the file inside the storage folder with nice Urls. | [
"Get",
"the",
"link",
"to",
"a",
"file",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/file/Item.php#L341-L344 | train |
luyadev/luya-module-admin | src/filesystem/DummyFileSystem.php | DummyFileSystem.addDummyFile | public function addDummyFile(array $config)
{
$keys = ['id', 'is_hidden', 'is_deleted', 'folder_id', 'name_original', 'name_new', 'name_new_compound', 'mime_type', 'extension', 'hash_name', 'hash_file', 'upload_timestamp', 'file_size', 'upload_user_id', 'caption'];
$item = array_flip($keys);
$data = array_merge($item, $config);
$this->_files[$data['id']] = $data;
} | php | public function addDummyFile(array $config)
{
$keys = ['id', 'is_hidden', 'is_deleted', 'folder_id', 'name_original', 'name_new', 'name_new_compound', 'mime_type', 'extension', 'hash_name', 'hash_file', 'upload_timestamp', 'file_size', 'upload_user_id', 'caption'];
$item = array_flip($keys);
$data = array_merge($item, $config);
$this->_files[$data['id']] = $data;
} | [
"public",
"function",
"addDummyFile",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"keys",
"=",
"[",
"'id'",
",",
"'is_hidden'",
",",
"'is_deleted'",
",",
"'folder_id'",
",",
"'name_original'",
",",
"'name_new'",
",",
"'name_new_compound'",
",",
"'mime_type'",
... | Add a dummy file.
Do not forget to call `insertDummyFiles()` afterwards.
@param array $config
@since 1.1.1 | [
"Add",
"a",
"dummy",
"file",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/filesystem/DummyFileSystem.php#L100-L106 | train |
luyadev/luya-module-admin | src/filesystem/DummyFileSystem.php | DummyFileSystem.addDummyImage | public function addDummyImage(array $config)
{
$keys = ['id', 'file_id', 'filter_id', 'resolution_width', 'resolution_height'];
$item = array_flip($keys);
$data = array_merge($item, $config);
$this->_images[$data['id']] = $data;
} | php | public function addDummyImage(array $config)
{
$keys = ['id', 'file_id', 'filter_id', 'resolution_width', 'resolution_height'];
$item = array_flip($keys);
$data = array_merge($item, $config);
$this->_images[$data['id']] = $data;
} | [
"public",
"function",
"addDummyImage",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"keys",
"=",
"[",
"'id'",
",",
"'file_id'",
",",
"'filter_id'",
",",
"'resolution_width'",
",",
"'resolution_height'",
"]",
";",
"$",
"item",
"=",
"array_flip",
"(",
"$",
"k... | Add dummy image.
Do not forget to call `insertDummyImages()` afterwards.
@param array $config
@since 1.1.1 | [
"Add",
"dummy",
"image",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/filesystem/DummyFileSystem.php#L128-L134 | train |
luyadev/luya-module-admin | src/models/Lang.php | Lang.findActive | public static function findActive()
{
if (self::$_langInstanceFindActive === null) {
$langShortCode = Yii::$app->composition->getKey('langShortCode');
if (!$langShortCode) {
self::$_langInstanceFindActive = self::getDefault();
} else {
self::$_langInstanceFindActive = self::find()->where(['short_code' => $langShortCode, 'is_deleted' => false])->asArray()->one();
}
}
return self::$_langInstanceFindActive;
} | php | public static function findActive()
{
if (self::$_langInstanceFindActive === null) {
$langShortCode = Yii::$app->composition->getKey('langShortCode');
if (!$langShortCode) {
self::$_langInstanceFindActive = self::getDefault();
} else {
self::$_langInstanceFindActive = self::find()->where(['short_code' => $langShortCode, 'is_deleted' => false])->asArray()->one();
}
}
return self::$_langInstanceFindActive;
} | [
"public",
"static",
"function",
"findActive",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"_langInstanceFindActive",
"===",
"null",
")",
"{",
"$",
"langShortCode",
"=",
"Yii",
"::",
"$",
"app",
"->",
"composition",
"->",
"getKey",
"(",
"'langShortCode'",
... | Get the active langauge array
@return array | [
"Get",
"the",
"active",
"langauge",
"array"
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/Lang.php#L171-L184 | train |
luyadev/luya-module-admin | src/ngrest/base/actions/ViewAction.php | ViewAction.run | public function run($id)
{
$model = $this->findModel($id);
if ($this->checkAccess) {
call_user_func($this->checkAccess, $this->id, $model);
}
if (!Yii::$app->adminuser->identity->is_api_user) {
$modelClass = $this->modelClass;
$table = $modelClass::tableName();
$alias = Yii::$app->adminmenu->getApiDetail($modelClass::ngRestApiEndpoint());
UserOnline::lock(Yii::$app->adminuser->id, $table, $id, 'lock_admin_edit_crud_item', ['table' => $alias['alias'], 'id' => $id, 'module' => $alias['module']['alias']]);
}
return $model;
} | php | public function run($id)
{
$model = $this->findModel($id);
if ($this->checkAccess) {
call_user_func($this->checkAccess, $this->id, $model);
}
if (!Yii::$app->adminuser->identity->is_api_user) {
$modelClass = $this->modelClass;
$table = $modelClass::tableName();
$alias = Yii::$app->adminmenu->getApiDetail($modelClass::ngRestApiEndpoint());
UserOnline::lock(Yii::$app->adminuser->id, $table, $id, 'lock_admin_edit_crud_item', ['table' => $alias['alias'], 'id' => $id, 'module' => $alias['module']['alias']]);
}
return $model;
} | [
"public",
"function",
"run",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"this",
"->",
"checkAccess",
")",
"{",
"call_user_func",
"(",
"$",
"this",
"->",
"checkAccess",
",",... | Return the model for a given resource id.
@return yii\db\ActiveRecordInterface | [
"Return",
"the",
"model",
"for",
"a",
"given",
"resource",
"id",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/base/actions/ViewAction.php#L58-L74 | train |
luyadev/luya-module-admin | src/apis/StorageController.php | StorageController.flushApiCache | protected function flushApiCache($folderId = 0, $page = 0)
{
Yii::$app->storage->flushArrays();
$this->deleteHasCache('storageApiDataFolders');
$this->deleteHasCache(['storageApiDataFiles', (int) $folderId, (int) $page]);
} | php | protected function flushApiCache($folderId = 0, $page = 0)
{
Yii::$app->storage->flushArrays();
$this->deleteHasCache('storageApiDataFolders');
$this->deleteHasCache(['storageApiDataFiles', (int) $folderId, (int) $page]);
} | [
"protected",
"function",
"flushApiCache",
"(",
"$",
"folderId",
"=",
"0",
",",
"$",
"page",
"=",
"0",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"storage",
"->",
"flushArrays",
"(",
")",
";",
"$",
"this",
"->",
"deleteHasCache",
"(",
"'storageApiDataFolder... | Flush the storage caching data. | [
"Flush",
"the",
"storage",
"caching",
"data",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/StorageController.php#L47-L52 | train |
luyadev/luya-module-admin | src/apis/StorageController.php | StorageController.actionDataFolders | public function actionDataFolders()
{
return $this->getOrSetHasCache('storageApiDataFolders', function () {
$folders = [];
foreach (Yii::$app->storage->findFolders() as $key => $folder) {
$folders[$key] = $folder->toArray();
$folders[$key]['toggle_open'] = (int) Yii::$app->adminuser->identity->setting->get('foldertree.'.$folder->id);
$folders[$key]['subfolder'] = Yii::$app->storage->getFolder($folder->id)->hasChild();
}
return $folders;
}, 0, new DbDependency(['sql' => 'SELECT MAX(id) FROM {{%admin_storage_folder}} WHERE is_deleted=false']));
} | php | public function actionDataFolders()
{
return $this->getOrSetHasCache('storageApiDataFolders', function () {
$folders = [];
foreach (Yii::$app->storage->findFolders() as $key => $folder) {
$folders[$key] = $folder->toArray();
$folders[$key]['toggle_open'] = (int) Yii::$app->adminuser->identity->setting->get('foldertree.'.$folder->id);
$folders[$key]['subfolder'] = Yii::$app->storage->getFolder($folder->id)->hasChild();
}
return $folders;
}, 0, new DbDependency(['sql' => 'SELECT MAX(id) FROM {{%admin_storage_folder}} WHERE is_deleted=false']));
} | [
"public",
"function",
"actionDataFolders",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"getOrSetHasCache",
"(",
"'storageApiDataFolders'",
",",
"function",
"(",
")",
"{",
"$",
"folders",
"=",
"[",
"]",
";",
"foreach",
"(",
"Yii",
"::",
"$",
"app",
"->",
... | Get all folders from the storage component.
@return array | [
"Get",
"all",
"folders",
"from",
"the",
"storage",
"component",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/StorageController.php#L61-L72 | train |
luyadev/luya-module-admin | src/apis/StorageController.php | StorageController.actionDataFiles | public function actionDataFiles($folderId = 0, $search = null)
{
$query = StorageFile::find()
->select(['id', 'name_original', 'extension', 'upload_timestamp', 'file_size', 'mime_type'])
->where(['is_hidden' => false, 'is_deleted' => false])
->with(['images.file']);
if (!empty($search)) {
$query->andFilterWhere(['or',
['like', 'name_original', $search],
['like', 'caption', $search],
['=', 'id', $search],
]);
} else {
$query->andWhere(['folder_id' => $folderId]);
}
return new ActiveDataProvider([
'query' => $query,
]);
} | php | public function actionDataFiles($folderId = 0, $search = null)
{
$query = StorageFile::find()
->select(['id', 'name_original', 'extension', 'upload_timestamp', 'file_size', 'mime_type'])
->where(['is_hidden' => false, 'is_deleted' => false])
->with(['images.file']);
if (!empty($search)) {
$query->andFilterWhere(['or',
['like', 'name_original', $search],
['like', 'caption', $search],
['=', 'id', $search],
]);
} else {
$query->andWhere(['folder_id' => $folderId]);
}
return new ActiveDataProvider([
'query' => $query,
]);
} | [
"public",
"function",
"actionDataFiles",
"(",
"$",
"folderId",
"=",
"0",
",",
"$",
"search",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"StorageFile",
"::",
"find",
"(",
")",
"->",
"select",
"(",
"[",
"'id'",
",",
"'name_original'",
",",
"'extension'",
... | Get all files from the storage container.
@return array | [
"Get",
"all",
"files",
"from",
"the",
"storage",
"container",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/StorageController.php#L79-L99 | train |
luyadev/luya-module-admin | src/apis/StorageController.php | StorageController.actionToggleFileTag | public function actionToggleFileTag()
{
$tagId = Yii::$app->request->getBodyParam('tagId');
$fileId = Yii::$app->request->getBodyParam('fileId');
$file = StorageFile::findOne($fileId);
if (!$file) {
throw new NotFoundHttpException("Unable to find the given file to toggle the tag.");
}
$relation = TagRelation::find()->where(['table_name' => TaggableTrait::cleanBaseTableName(StorageFile::tableName()), 'pk_id' => $fileId, 'tag_id' => $tagId])->one();
if ($relation) {
$relation->delete();
return $file->tags;
}
$model = new TagRelation();
$model->table_name = TaggableTrait::cleanBaseTableName(StorageFile::tableName());
$model->pk_id = $fileId;
$model->tag_id = $tagId;
$model->save();
return $file->tags;
} | php | public function actionToggleFileTag()
{
$tagId = Yii::$app->request->getBodyParam('tagId');
$fileId = Yii::$app->request->getBodyParam('fileId');
$file = StorageFile::findOne($fileId);
if (!$file) {
throw new NotFoundHttpException("Unable to find the given file to toggle the tag.");
}
$relation = TagRelation::find()->where(['table_name' => TaggableTrait::cleanBaseTableName(StorageFile::tableName()), 'pk_id' => $fileId, 'tag_id' => $tagId])->one();
if ($relation) {
$relation->delete();
return $file->tags;
}
$model = new TagRelation();
$model->table_name = TaggableTrait::cleanBaseTableName(StorageFile::tableName());
$model->pk_id = $fileId;
$model->tag_id = $tagId;
$model->save();
return $file->tags;
} | [
"public",
"function",
"actionToggleFileTag",
"(",
")",
"{",
"$",
"tagId",
"=",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"getBodyParam",
"(",
"'tagId'",
")",
";",
"$",
"fileId",
"=",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"getBodyParam",
... | Toggle Tags for a given file.
If a relation exists, remove, otherwise add.
@return The array of associated tags for the given file.
@since 2.0.0 | [
"Toggle",
"Tags",
"for",
"a",
"given",
"file",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/StorageController.php#L111-L137 | train |
luyadev/luya-module-admin | src/apis/StorageController.php | StorageController.actionFileInfo | public function actionFileInfo($id)
{
$model = StorageFile::find()->where(['id' => $id])->with(['user', 'images', 'tags'])->one();
if (!$model) {
throw new NotFoundHttpException("Unable to find the given storage file.");
}
return $model->toArray([], ['user', 'file', 'images', 'source', 'tags']);
} | php | public function actionFileInfo($id)
{
$model = StorageFile::find()->where(['id' => $id])->with(['user', 'images', 'tags'])->one();
if (!$model) {
throw new NotFoundHttpException("Unable to find the given storage file.");
}
return $model->toArray([], ['user', 'file', 'images', 'source', 'tags']);
} | [
"public",
"function",
"actionFileInfo",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"StorageFile",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'id'",
"=>",
"$",
"id",
"]",
")",
"->",
"with",
"(",
"[",
"'user'",
",",
"'images'",
",",
"'tags'"... | Get all storage file informations for a given ID.
@param integer $fileId
@throws NotFoundHttpException
@return array
@since 1.2.0 | [
"Get",
"all",
"storage",
"file",
"informations",
"for",
"a",
"given",
"ID",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/StorageController.php#L147-L156 | train |
luyadev/luya-module-admin | src/apis/StorageController.php | StorageController.actionFile | public function actionFile($id)
{
$model = StorageFile::find()->where(['id' => $id])->one();
if (!$model) {
throw new NotFoundHttpException("Unable to find the given storage file.");
}
return $model;
} | php | public function actionFile($id)
{
$model = StorageFile::find()->where(['id' => $id])->one();
if (!$model) {
throw new NotFoundHttpException("Unable to find the given storage file.");
}
return $model;
} | [
"public",
"function",
"actionFile",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"StorageFile",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'id'",
"=>",
"$",
"id",
"]",
")",
"->",
"one",
"(",
")",
";",
"if",
"(",
"!",
"$",
"model",
")",
... | Get file model.
This is mainly used for external api access.
@param integer $id
@return StorageFile
@since 1.2.3 | [
"Get",
"file",
"model",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/StorageController.php#L167-L176 | train |
luyadev/luya-module-admin | src/apis/StorageController.php | StorageController.actionImage | public function actionImage($id)
{
$model = StorageImage::find()->where(['id' => $id])->with(['file'])->one();
if (!$model) {
throw new NotFoundHttpException("Unable to find the given storage image.");
}
return $model;
} | php | public function actionImage($id)
{
$model = StorageImage::find()->where(['id' => $id])->with(['file'])->one();
if (!$model) {
throw new NotFoundHttpException("Unable to find the given storage image.");
}
return $model;
} | [
"public",
"function",
"actionImage",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"StorageImage",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'id'",
"=>",
"$",
"id",
"]",
")",
"->",
"with",
"(",
"[",
"'file'",
"]",
")",
"->",
"one",
"(",
... | Get image model.
This is mainly used for external api access.
@param integer $id
@return StorageImage
@since 1.2.3 | [
"Get",
"image",
"model",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/StorageController.php#L187-L196 | train |
luyadev/luya-module-admin | src/apis/StorageController.php | StorageController.actionImagesInfo | public function actionImagesInfo()
{
$ids = Yii::$app->request->getBodyParam('ids', []);
$ids = array_unique($ids);
return new ActiveDataProvider([
'query' => StorageImage::find()->where(['in', 'id', $ids])->with(['file', 'tinyCropImage.file']),
'pagination' => false,
]);
} | php | public function actionImagesInfo()
{
$ids = Yii::$app->request->getBodyParam('ids', []);
$ids = array_unique($ids);
return new ActiveDataProvider([
'query' => StorageImage::find()->where(['in', 'id', $ids])->with(['file', 'tinyCropImage.file']),
'pagination' => false,
]);
} | [
"public",
"function",
"actionImagesInfo",
"(",
")",
"{",
"$",
"ids",
"=",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"getBodyParam",
"(",
"'ids'",
",",
"[",
"]",
")",
";",
"$",
"ids",
"=",
"array_unique",
"(",
"$",
"ids",
")",
";",
"return",
"... | A post request with an array of images to load!
@since 1.2.2.1 | [
"A",
"post",
"request",
"with",
"an",
"array",
"of",
"images",
"to",
"load!"
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/StorageController.php#L230-L238 | train |
luyadev/luya-module-admin | src/apis/StorageController.php | StorageController.actionFilemanagerUpdateCaption | public function actionFilemanagerUpdateCaption()
{
$this->checkRouteAccess(self::PERMISSION_ROUTE);
$fileId = Yii::$app->request->post('id', false);
$captionsText = Yii::$app->request->post('captionsText', false);
$pageId = Yii::$app->request->post('pageId', 0);
if ($fileId && is_scalar($fileId) && $captionsText) {
$model = StorageFile::findOne($fileId);
if ($model) {
$model->updateAttributes([
'caption' => I18n::encode($captionsText),
]);
$this->flushApiCache($model->folder_id, $pageId);
return true;
}
}
return false;
} | php | public function actionFilemanagerUpdateCaption()
{
$this->checkRouteAccess(self::PERMISSION_ROUTE);
$fileId = Yii::$app->request->post('id', false);
$captionsText = Yii::$app->request->post('captionsText', false);
$pageId = Yii::$app->request->post('pageId', 0);
if ($fileId && is_scalar($fileId) && $captionsText) {
$model = StorageFile::findOne($fileId);
if ($model) {
$model->updateAttributes([
'caption' => I18n::encode($captionsText),
]);
$this->flushApiCache($model->folder_id, $pageId);
return true;
}
}
return false;
} | [
"public",
"function",
"actionFilemanagerUpdateCaption",
"(",
")",
"{",
"$",
"this",
"->",
"checkRouteAccess",
"(",
"self",
"::",
"PERMISSION_ROUTE",
")",
";",
"$",
"fileId",
"=",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
"'id'",
",",
"fa... | Update the caption of storage file.
@return boolean | [
"Update",
"the",
"caption",
"of",
"storage",
"file",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/StorageController.php#L271-L293 | train |
luyadev/luya-module-admin | src/apis/StorageController.php | StorageController.actionImageFilter | public function actionImageFilter()
{
$this->checkRouteAccess(self::PERMISSION_ROUTE);
$image = Yii::$app->storage->createImage(Yii::$app->request->post('fileId', null), Yii::$app->request->post('filterId', null));
if ($image) {
return [
'error' => false,
'id' => $image->id,
'image' => $image
];
}
return $this->sendArrayError([
'error' => true,
'message' => Module::t('api_storage_image_upload_error', ['error' => 'Unable to create the filter for the given image. Maybe the file source is not readable.']),
]);
} | php | public function actionImageFilter()
{
$this->checkRouteAccess(self::PERMISSION_ROUTE);
$image = Yii::$app->storage->createImage(Yii::$app->request->post('fileId', null), Yii::$app->request->post('filterId', null));
if ($image) {
return [
'error' => false,
'id' => $image->id,
'image' => $image
];
}
return $this->sendArrayError([
'error' => true,
'message' => Module::t('api_storage_image_upload_error', ['error' => 'Unable to create the filter for the given image. Maybe the file source is not readable.']),
]);
} | [
"public",
"function",
"actionImageFilter",
"(",
")",
"{",
"$",
"this",
"->",
"checkRouteAccess",
"(",
"self",
"::",
"PERMISSION_ROUTE",
")",
";",
"$",
"image",
"=",
"Yii",
"::",
"$",
"app",
"->",
"storage",
"->",
"createImage",
"(",
"Yii",
"::",
"$",
"ap... | Upload an image to the filemanager.
@return array An array with
- error: Whether an error occured or not.
- id: The id of the image
- image: The image object (since 2.0) | [
"Upload",
"an",
"image",
"to",
"the",
"filemanager",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/StorageController.php#L303-L319 | train |
luyadev/luya-module-admin | src/apis/StorageController.php | StorageController.actionFileReplace | public function actionFileReplace()
{
$this->checkRouteAccess(self::PERMISSION_ROUTE);
$fileId = Yii::$app->request->post('fileId', false);
$pageId = Yii::$app->request->post('pageId', 0);
Yii::warning('replace request for file id' . $fileId, __METHOD__);
$raw = $_FILES['file'];
/** @var $file \luya\admin\file\Item */
if ($file = Yii::$app->storage->getFile($fileId)) {
$newFileSource = $raw['tmp_name'];
if (is_uploaded_file($newFileSource)) {
// check for same extension / mimeType
$fileData = Yii::$app->storage->ensureFileUpload($raw['tmp_name'], $raw['name']);
if ($fileData['mimeType'] != $file->mimeType) {
throw new BadRequestHttpException("The type must be the same as the original file in order to replace.");
}
if (Storage::replaceFile($file->systemFileName, $newFileSource, $raw['name'])) {
foreach (StorageImage::find()->where(['file_id' => $file->id])->all() as $img) {
$removal = Storage::removeImage($img->id, false);
}
// calculate new file files based on new file
$model = StorageFile::findOne((int) $fileId);
$fileHash = FileHelper::md5sum($newFileSource);
$fileSize = @filesize($newFileSource);
$model->updateAttributes([
'hash_file' => $fileHash,
'file_size' => $fileSize,
'upload_timestamp' => time(),
]);
$this->flushApiCache($model->folder_id, $pageId);
return true;
}
}
}
return false;
} | php | public function actionFileReplace()
{
$this->checkRouteAccess(self::PERMISSION_ROUTE);
$fileId = Yii::$app->request->post('fileId', false);
$pageId = Yii::$app->request->post('pageId', 0);
Yii::warning('replace request for file id' . $fileId, __METHOD__);
$raw = $_FILES['file'];
/** @var $file \luya\admin\file\Item */
if ($file = Yii::$app->storage->getFile($fileId)) {
$newFileSource = $raw['tmp_name'];
if (is_uploaded_file($newFileSource)) {
// check for same extension / mimeType
$fileData = Yii::$app->storage->ensureFileUpload($raw['tmp_name'], $raw['name']);
if ($fileData['mimeType'] != $file->mimeType) {
throw new BadRequestHttpException("The type must be the same as the original file in order to replace.");
}
if (Storage::replaceFile($file->systemFileName, $newFileSource, $raw['name'])) {
foreach (StorageImage::find()->where(['file_id' => $file->id])->all() as $img) {
$removal = Storage::removeImage($img->id, false);
}
// calculate new file files based on new file
$model = StorageFile::findOne((int) $fileId);
$fileHash = FileHelper::md5sum($newFileSource);
$fileSize = @filesize($newFileSource);
$model->updateAttributes([
'hash_file' => $fileHash,
'file_size' => $fileSize,
'upload_timestamp' => time(),
]);
$this->flushApiCache($model->folder_id, $pageId);
return true;
}
}
}
return false;
} | [
"public",
"function",
"actionFileReplace",
"(",
")",
"{",
"$",
"this",
"->",
"checkRouteAccess",
"(",
"self",
"::",
"PERMISSION_ROUTE",
")",
";",
"$",
"fileId",
"=",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
"'fileId'",
",",
"false",
"... | Action to replace a current file with a new.
@return boolean | [
"Action",
"to",
"replace",
"a",
"current",
"file",
"with",
"a",
"new",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/StorageController.php#L336-L377 | train |
luyadev/luya-module-admin | src/apis/StorageController.php | StorageController.actionFilemanagerMoveFiles | public function actionFilemanagerMoveFiles()
{
$this->checkRouteAccess(self::PERMISSION_ROUTE);
$toFolderId = Yii::$app->request->post('toFolderId', 0);
$fileIds = Yii::$app->request->post('fileIds', []);
$currentPageId = Yii::$app->request->post('currentPageId', 0);
$currentFolderId = Yii::$app->request->post('currentFolderId', 0);
$response = Storage::moveFilesToFolder($fileIds, $toFolderId);
$this->flushApiCache($currentFolderId, $currentPageId);
$this->flushApiCache($toFolderId, $currentPageId);
$this->flushHasCache($toFolderId, 0);
return $response;
} | php | public function actionFilemanagerMoveFiles()
{
$this->checkRouteAccess(self::PERMISSION_ROUTE);
$toFolderId = Yii::$app->request->post('toFolderId', 0);
$fileIds = Yii::$app->request->post('fileIds', []);
$currentPageId = Yii::$app->request->post('currentPageId', 0);
$currentFolderId = Yii::$app->request->post('currentFolderId', 0);
$response = Storage::moveFilesToFolder($fileIds, $toFolderId);
$this->flushApiCache($currentFolderId, $currentPageId);
$this->flushApiCache($toFolderId, $currentPageId);
$this->flushHasCache($toFolderId, 0);
return $response;
} | [
"public",
"function",
"actionFilemanagerMoveFiles",
"(",
")",
"{",
"$",
"this",
"->",
"checkRouteAccess",
"(",
"self",
"::",
"PERMISSION_ROUTE",
")",
";",
"$",
"toFolderId",
"=",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
"'toFolderId'",
",... | Move files into another folder.
@return boolean | [
"Move",
"files",
"into",
"another",
"folder",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/StorageController.php#L459-L474 | train |
luyadev/luya-module-admin | src/apis/StorageController.php | StorageController.actionFilemanagerRemoveFiles | public function actionFilemanagerRemoveFiles()
{
$this->checkRouteAccess(self::PERMISSION_ROUTE);
$pageId = Yii::$app->request->post('pageId', 0);
$folderId = Yii::$app->request->post('folderId', 0);
foreach (Yii::$app->request->post('ids', []) as $id) {
if (!Storage::removeFile($id)) {
return false;
}
}
$this->flushApiCache($folderId, $pageId);
return true;
} | php | public function actionFilemanagerRemoveFiles()
{
$this->checkRouteAccess(self::PERMISSION_ROUTE);
$pageId = Yii::$app->request->post('pageId', 0);
$folderId = Yii::$app->request->post('folderId', 0);
foreach (Yii::$app->request->post('ids', []) as $id) {
if (!Storage::removeFile($id)) {
return false;
}
}
$this->flushApiCache($folderId, $pageId);
return true;
} | [
"public",
"function",
"actionFilemanagerRemoveFiles",
"(",
")",
"{",
"$",
"this",
"->",
"checkRouteAccess",
"(",
"self",
"::",
"PERMISSION_ROUTE",
")",
";",
"$",
"pageId",
"=",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
"'pageId'",
",",
"... | Remove files from the storage component.
@todo make permission check.
@return boolean | [
"Remove",
"files",
"from",
"the",
"storage",
"component",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/StorageController.php#L482-L494 | train |
luyadev/luya-module-admin | src/apis/StorageController.php | StorageController.actionIsFolderEmpty | public function actionIsFolderEmpty($folderId)
{
$count = StorageFile::find()->where(['folder_id' => $folderId, 'is_deleted' => false])->count();
return [
'count' => $count,
'empty' => $count > 0 ? false : true,
];
} | php | public function actionIsFolderEmpty($folderId)
{
$count = StorageFile::find()->where(['folder_id' => $folderId, 'is_deleted' => false])->count();
return [
'count' => $count,
'empty' => $count > 0 ? false : true,
];
} | [
"public",
"function",
"actionIsFolderEmpty",
"(",
"$",
"folderId",
")",
"{",
"$",
"count",
"=",
"StorageFile",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'folder_id'",
"=>",
"$",
"folderId",
",",
"'is_deleted'",
"=>",
"false",
"]",
")",
"->",
"cou... | Check whether a folder is empty or not in order to delete this folder.
@param integer $folderId The folder id to check whether it has files or not.
@return boolean | [
"Check",
"whether",
"a",
"folder",
"is",
"empty",
"or",
"not",
"in",
"order",
"to",
"delete",
"this",
"folder",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/StorageController.php#L502-L510 | train |
luyadev/luya-module-admin | src/apis/StorageController.php | StorageController.actionFolderDelete | public function actionFolderDelete($folderId)
{
$this->checkRouteAccess(self::PERMISSION_ROUTE);
// find all subfolders
$matchingChildFolders = StorageFolder::find()->where(['parent_id' => $folderId])->asArray()->all();
foreach ($matchingChildFolders as $matchingChildFolder) {
$this->actionFolderDelete($matchingChildFolder['id']);
}
// find all attached files and delete them
$folderFiles = StorageFile::find()->where(['folder_id' => $folderId])->all();
foreach ($folderFiles as $folderFile) {
$folderFile->delete();
}
// delete folder
$model = StorageFolder::findOne($folderId);
if (!$model) {
return false;
}
$model->is_deleted = true;
$this->flushApiCache();
return $model->update();
} | php | public function actionFolderDelete($folderId)
{
$this->checkRouteAccess(self::PERMISSION_ROUTE);
// find all subfolders
$matchingChildFolders = StorageFolder::find()->where(['parent_id' => $folderId])->asArray()->all();
foreach ($matchingChildFolders as $matchingChildFolder) {
$this->actionFolderDelete($matchingChildFolder['id']);
}
// find all attached files and delete them
$folderFiles = StorageFile::find()->where(['folder_id' => $folderId])->all();
foreach ($folderFiles as $folderFile) {
$folderFile->delete();
}
// delete folder
$model = StorageFolder::findOne($folderId);
if (!$model) {
return false;
}
$model->is_deleted = true;
$this->flushApiCache();
return $model->update();
} | [
"public",
"function",
"actionFolderDelete",
"(",
"$",
"folderId",
")",
"{",
"$",
"this",
"->",
"checkRouteAccess",
"(",
"self",
"::",
"PERMISSION_ROUTE",
")",
";",
"// find all subfolders",
"$",
"matchingChildFolders",
"=",
"StorageFolder",
"::",
"find",
"(",
")",... | delete folder, all subfolders and all included files.
1. search another folders with matching parentIds and call deleteFolder on them
2. get all included files and delete them
3. delete folder
@param integer $folderId The folder to delete.
@todo move to storage helpers?
@return boolean | [
"delete",
"folder",
"all",
"subfolders",
"and",
"all",
"included",
"files",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/StorageController.php#L523-L549 | train |
luyadev/luya-module-admin | src/apis/StorageController.php | StorageController.actionFolderUpdate | public function actionFolderUpdate($folderId)
{
$this->checkRouteAccess(self::PERMISSION_ROUTE);
$model = StorageFolder::findOne($folderId);
if (!$model) {
return false;
}
$model->attributes = Yii::$app->request->post();
$this->flushApiCache();
return $model->update();
} | php | public function actionFolderUpdate($folderId)
{
$this->checkRouteAccess(self::PERMISSION_ROUTE);
$model = StorageFolder::findOne($folderId);
if (!$model) {
return false;
}
$model->attributes = Yii::$app->request->post();
$this->flushApiCache();
return $model->update();
} | [
"public",
"function",
"actionFolderUpdate",
"(",
"$",
"folderId",
")",
"{",
"$",
"this",
"->",
"checkRouteAccess",
"(",
"self",
"::",
"PERMISSION_ROUTE",
")",
";",
"$",
"model",
"=",
"StorageFolder",
"::",
"findOne",
"(",
"$",
"folderId",
")",
";",
"if",
"... | Update the folder model data.
@param integer $folderId The folder id.
@return boolean | [
"Update",
"the",
"folder",
"model",
"data",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/StorageController.php#L557-L570 | train |
luyadev/luya-module-admin | src/apis/StorageController.php | StorageController.actionFolderCreate | public function actionFolderCreate()
{
$this->checkRouteAccess(self::PERMISSION_ROUTE);
$folderName = Yii::$app->request->post('folderName', null);
$parentFolderId = Yii::$app->request->post('parentFolderId', 0);
$response = Yii::$app->storage->addFolder($folderName, $parentFolderId);
$this->flushApiCache();
return $response;
} | php | public function actionFolderCreate()
{
$this->checkRouteAccess(self::PERMISSION_ROUTE);
$folderName = Yii::$app->request->post('folderName', null);
$parentFolderId = Yii::$app->request->post('parentFolderId', 0);
$response = Yii::$app->storage->addFolder($folderName, $parentFolderId);
$this->flushApiCache();
return $response;
} | [
"public",
"function",
"actionFolderCreate",
"(",
")",
"{",
"$",
"this",
"->",
"checkRouteAccess",
"(",
"self",
"::",
"PERMISSION_ROUTE",
")",
";",
"$",
"folderName",
"=",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
"'folderName'",
",",
"nu... | Create a new folder pased on post data.
@return boolean | [
"Create",
"a",
"new",
"folder",
"pased",
"on",
"post",
"data",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/StorageController.php#L577-L587 | train |
luyadev/luya-module-admin | src/base/Controller.php | Controller.getRules | public function getRules()
{
return [
[
'allow' => true,
'actions' => [], // apply to all actions by default
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
// see if a controller property has been defined to disabled the permission checks
if ($action->controller->disablePermissionCheck) {
return true;
}
// get the route based on the current $action object
$route = implode('/', [$action->controller->module->id, $action->controller->id, $action->id]);
UserOnline::refreshUser($this->user->identity, $route);
// check the access inside auth->matchRoute and return true/false.
return Yii::$app->auth->matchRoute($this->user->id, $route);
},
],
];
} | php | public function getRules()
{
return [
[
'allow' => true,
'actions' => [], // apply to all actions by default
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
// see if a controller property has been defined to disabled the permission checks
if ($action->controller->disablePermissionCheck) {
return true;
}
// get the route based on the current $action object
$route = implode('/', [$action->controller->module->id, $action->controller->id, $action->id]);
UserOnline::refreshUser($this->user->identity, $route);
// check the access inside auth->matchRoute and return true/false.
return Yii::$app->auth->matchRoute($this->user->id, $route);
},
],
];
} | [
"public",
"function",
"getRules",
"(",
")",
"{",
"return",
"[",
"[",
"'allow'",
"=>",
"true",
",",
"'actions'",
"=>",
"[",
"]",
",",
"// apply to all actions by default",
"'roles'",
"=>",
"[",
"'@'",
"]",
",",
"'matchCallback'",
"=>",
"function",
"(",
"$",
... | Returns the rules for the AccessControl filter behavior.
The rules are applied as following:
1. Administration User must be logged in, this is by default for all actions inside the controller.
2. Check the current given route against {{luya\admin\components\Auth::matchRoute()}}.
2a. If {{luya\admin\base\Controller::$disabledPermissionCheck}} enabled, the match route behavior is disabled.
@return array A list of rules.
@see yii\filters\AccessControl | [
"Returns",
"the",
"rules",
"for",
"the",
"AccessControl",
"filter",
"behavior",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/base/Controller.php#L73-L95 | train |
luyadev/luya-module-admin | src/base/Controller.php | Controller.behaviors | public function behaviors()
{
$behaviors = [
'access' => [
'class' => AccessControl::className(),
'user' => Yii::$app->adminuser,
'rules' => $this->getRules(),
],
];
if (!empty($this->apiResponseActions)) {
$behaviors['negotiator'] = [
'class' => ContentNegotiator::className(),
'only' => $this->apiResponseActions,
'formats' => [
'application/json' => Response::FORMAT_JSON,
],
];
}
return $behaviors;
} | php | public function behaviors()
{
$behaviors = [
'access' => [
'class' => AccessControl::className(),
'user' => Yii::$app->adminuser,
'rules' => $this->getRules(),
],
];
if (!empty($this->apiResponseActions)) {
$behaviors['negotiator'] = [
'class' => ContentNegotiator::className(),
'only' => $this->apiResponseActions,
'formats' => [
'application/json' => Response::FORMAT_JSON,
],
];
}
return $behaviors;
} | [
"public",
"function",
"behaviors",
"(",
")",
"{",
"$",
"behaviors",
"=",
"[",
"'access'",
"=>",
"[",
"'class'",
"=>",
"AccessControl",
"::",
"className",
"(",
")",
",",
"'user'",
"=>",
"Yii",
"::",
"$",
"app",
"->",
"adminuser",
",",
"'rules'",
"=>",
"... | Attach the AccessControl filter behavior for the controler.
@return array | [
"Attach",
"the",
"AccessControl",
"filter",
"behavior",
"for",
"the",
"controler",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/base/Controller.php#L102-L123 | train |
luyadev/luya-module-admin | src/base/Module.php | Module.getAuthApis | public function getAuthApis()
{
$menu = $this->getMenu();
if (!$menu) {
return $this->extendPermissionApis();
}
return ArrayHelper::merge($this->extendPermissionApis(), $menu->getPermissionApis());
} | php | public function getAuthApis()
{
$menu = $this->getMenu();
if (!$menu) {
return $this->extendPermissionApis();
}
return ArrayHelper::merge($this->extendPermissionApis(), $menu->getPermissionApis());
} | [
"public",
"function",
"getAuthApis",
"(",
")",
"{",
"$",
"menu",
"=",
"$",
"this",
"->",
"getMenu",
"(",
")",
";",
"if",
"(",
"!",
"$",
"menu",
")",
"{",
"return",
"$",
"this",
"->",
"extendPermissionApis",
"(",
")",
";",
"}",
"return",
"ArrayHelper"... | Get an array with all api routes based on the menu builder.
@return array | [
"Get",
"an",
"array",
"with",
"all",
"api",
"routes",
"based",
"on",
"the",
"menu",
"builder",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/base/Module.php#L197-L206 | train |
luyadev/luya-module-admin | src/base/Module.php | Module.getAuthRoutes | public function getAuthRoutes()
{
$menu = $this->getMenu();
if (!$menu) {
return $this->extendPermissionRoutes();
}
return ArrayHelper::merge($this->extendPermissionRoutes(), $menu->getPermissionRoutes());
} | php | public function getAuthRoutes()
{
$menu = $this->getMenu();
if (!$menu) {
return $this->extendPermissionRoutes();
}
return ArrayHelper::merge($this->extendPermissionRoutes(), $menu->getPermissionRoutes());
} | [
"public",
"function",
"getAuthRoutes",
"(",
")",
"{",
"$",
"menu",
"=",
"$",
"this",
"->",
"getMenu",
"(",
")",
";",
"if",
"(",
"!",
"$",
"menu",
")",
"{",
"return",
"$",
"this",
"->",
"extendPermissionRoutes",
"(",
")",
";",
"}",
"return",
"ArrayHel... | Get an array with all routes based on the menu builder.
@return array | [
"Get",
"an",
"array",
"with",
"all",
"routes",
"based",
"on",
"the",
"menu",
"builder",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/base/Module.php#L213-L222 | train |
luyadev/luya-module-admin | src/apis/TimestampController.php | TimestampController.actionIndex | public function actionIndex()
{
$userId = Yii::$app->adminuser->id;
// clear user online list
UserOnline::clearList($this->module->userIdleTimeout);
$userOnlineModel = UserOnline::findOne(['user_id' => Yii::$app->adminuser->id]);
if (!$userOnlineModel) {
Yii::$app->response->statusCode = 401;
return Yii::$app->response->send();
}
// run internal worker
$this->getOrSetHasCache(['timestamp', 'queue', 'run'], function() {
Yii::$app->adminqueue->run(false);
Config::set(Config::CONFIG_QUEUE_TIMESTAMP, time());
}, 60*5);
// update keystrokes
$lastKeyStroke = Yii::$app->request->getBodyParam('lastKeyStroke');
if (Yii::$app->session->get('__lastKeyStroke') != $lastKeyStroke) {
// refresh the user timestamp
$userOnlineModel->last_timestamp = time();
$userOnlineModel->update(true, ['last_timestamp']);
}
Yii::$app->session->set('__lastKeyStroke', $lastKeyStroke);
// if developer is enabled, check if vendor has changed and run the required commands and force reload
// @TODO: its a concept
/*
if (!YII_ENV_PROD) {
$config = (int) Config::get(Config::CONFIG_INSTALLER_VENDOR_TIMESTAMP, null);
$ts = Yii::$app->packageInstaller->timestamp;
if ($config !== $ts) {
// run migration and import process for developer usage.
}
}
*/
// get the stroke-dashoffset for the given user, this indicates the time he is idling
// stroke-dashoffset="88px" = 0 // which means 0 percent of time has elapsed
// stroke-dashoffset="0px" => 100 // which means 100 percent of time has elpased, auto logout will redirect the user
$seconds = (time() - $userOnlineModel->last_timestamp);
$percentage = round(($seconds / $this->module->userIdleTimeout) * 100);
$offsetPercent = round((81/100) * $percentage);
$strokeOffset = 81 - $offsetPercent;
// return users, verify force reload.
$data = [
'lastKeyStroke' => $lastKeyStroke,
'idleSeconds' => $seconds,
'idleTimeRelative' => round(($this->module->userIdleTimeout-$seconds) / 60),
'idlePercentage' => $percentage,
'idleStrokeDashoffset' => $strokeOffset,
'useronline' => UserOnline::getList(),
'forceReload' => Yii::$app->adminuser->identity->force_reload,
'locked' => UserOnline::find()->select(['lock_pk', 'lock_table', 'last_timestamp', 'u.firstname', 'u.lastname', 'u.id'])->where(['!=', 'u.id', $userId])->joinWith('user as u')->createCommand()->queryAll(),
];
return $data;
} | php | public function actionIndex()
{
$userId = Yii::$app->adminuser->id;
// clear user online list
UserOnline::clearList($this->module->userIdleTimeout);
$userOnlineModel = UserOnline::findOne(['user_id' => Yii::$app->adminuser->id]);
if (!$userOnlineModel) {
Yii::$app->response->statusCode = 401;
return Yii::$app->response->send();
}
// run internal worker
$this->getOrSetHasCache(['timestamp', 'queue', 'run'], function() {
Yii::$app->adminqueue->run(false);
Config::set(Config::CONFIG_QUEUE_TIMESTAMP, time());
}, 60*5);
// update keystrokes
$lastKeyStroke = Yii::$app->request->getBodyParam('lastKeyStroke');
if (Yii::$app->session->get('__lastKeyStroke') != $lastKeyStroke) {
// refresh the user timestamp
$userOnlineModel->last_timestamp = time();
$userOnlineModel->update(true, ['last_timestamp']);
}
Yii::$app->session->set('__lastKeyStroke', $lastKeyStroke);
// if developer is enabled, check if vendor has changed and run the required commands and force reload
// @TODO: its a concept
/*
if (!YII_ENV_PROD) {
$config = (int) Config::get(Config::CONFIG_INSTALLER_VENDOR_TIMESTAMP, null);
$ts = Yii::$app->packageInstaller->timestamp;
if ($config !== $ts) {
// run migration and import process for developer usage.
}
}
*/
// get the stroke-dashoffset for the given user, this indicates the time he is idling
// stroke-dashoffset="88px" = 0 // which means 0 percent of time has elapsed
// stroke-dashoffset="0px" => 100 // which means 100 percent of time has elpased, auto logout will redirect the user
$seconds = (time() - $userOnlineModel->last_timestamp);
$percentage = round(($seconds / $this->module->userIdleTimeout) * 100);
$offsetPercent = round((81/100) * $percentage);
$strokeOffset = 81 - $offsetPercent;
// return users, verify force reload.
$data = [
'lastKeyStroke' => $lastKeyStroke,
'idleSeconds' => $seconds,
'idleTimeRelative' => round(($this->module->userIdleTimeout-$seconds) / 60),
'idlePercentage' => $percentage,
'idleStrokeDashoffset' => $strokeOffset,
'useronline' => UserOnline::getList(),
'forceReload' => Yii::$app->adminuser->identity->force_reload,
'locked' => UserOnline::find()->select(['lock_pk', 'lock_table', 'last_timestamp', 'u.firstname', 'u.lastname', 'u.id'])->where(['!=', 'u.id', $userId])->joinWith('user as u')->createCommand()->queryAll(),
];
return $data;
} | [
"public",
"function",
"actionIndex",
"(",
")",
"{",
"$",
"userId",
"=",
"Yii",
"::",
"$",
"app",
"->",
"adminuser",
"->",
"id",
";",
"// clear user online list",
"UserOnline",
"::",
"clearList",
"(",
"$",
"this",
"->",
"module",
"->",
"userIdleTimeout",
")",... | The timestamp action provider informations about currenct only users and if the ui needs to be refreshed.
@return array | [
"The",
"timestamp",
"action",
"provider",
"informations",
"about",
"currenct",
"only",
"users",
"and",
"if",
"the",
"ui",
"needs",
"to",
"be",
"refreshed",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/TimestampController.php#L26-L90 | train |
luyadev/luya-module-admin | src/ngrest/base/ActiveWindow.php | ActiveWindow.getModel | public function getModel()
{
if ($this->_model === null && $this->ngRestModelClass !== null) {
$this->_model = call_user_func_array([$this->ngRestModelClass, 'findOne'], $this->itemIds);
}
return $this->_model;
} | php | public function getModel()
{
if ($this->_model === null && $this->ngRestModelClass !== null) {
$this->_model = call_user_func_array([$this->ngRestModelClass, 'findOne'], $this->itemIds);
}
return $this->_model;
} | [
"public",
"function",
"getModel",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_model",
"===",
"null",
"&&",
"$",
"this",
"->",
"ngRestModelClass",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"_model",
"=",
"call_user_func_array",
"(",
"[",
"$",
"this... | Get the model object from where the Active Window is attached to.
@return \luya\admin\ngrest\base\NgRestModel Get the model of the called ngrest model ActiveRecord by it's itemId. | [
"Get",
"the",
"model",
"object",
"from",
"where",
"the",
"Active",
"Window",
"is",
"attached",
"to",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/base/ActiveWindow.php#L64-L71 | train |
luyadev/luya-module-admin | src/ngrest/base/ActiveWindow.php | ActiveWindow.createCallbackUrl | public function createCallbackUrl($callback)
{
return Url::to([
'/admin/'.$this->model->ngRestApiEndpoint().'/active-window-callback',
'activeWindowCallback' => Inflector::camel2id($callback),
'ngrestConfigHash' => $this->getConfigHash(),
'activeWindowHash' => $this->getActiveWindowHash(),
], true);
} | php | public function createCallbackUrl($callback)
{
return Url::to([
'/admin/'.$this->model->ngRestApiEndpoint().'/active-window-callback',
'activeWindowCallback' => Inflector::camel2id($callback),
'ngrestConfigHash' => $this->getConfigHash(),
'activeWindowHash' => $this->getActiveWindowHash(),
], true);
} | [
"public",
"function",
"createCallbackUrl",
"(",
"$",
"callback",
")",
"{",
"return",
"Url",
"::",
"to",
"(",
"[",
"'/admin/'",
".",
"$",
"this",
"->",
"model",
"->",
"ngRestApiEndpoint",
"(",
")",
".",
"'/active-window-callback'",
",",
"'activeWindowCallback'",
... | Create an absolute link to a callback.
This method is commonly used when returing data directly to the browser, there for the abolute url to a callback is required. Only logged in
users can view the callback url, but there is no other security about callbacks.
@param string $callback The name of the callback without the callback prefix exmaple `createPdf` if the callback is `callbackCreatePdf()`.
@return string The absolute url to the callback. | [
"Create",
"an",
"absolute",
"link",
"to",
"a",
"callback",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/base/ActiveWindow.php#L121-L129 | train |
luyadev/luya-module-admin | src/ngrest/base/ActiveWindow.php | ActiveWindow.getName | public function getName()
{
if ($this->_name === null) {
$this->_name = ((new \ReflectionClass($this))->getShortName());
}
return $this->_name;
} | php | public function getName()
{
if ($this->_name === null) {
$this->_name = ((new \ReflectionClass($this))->getShortName());
}
return $this->_name;
} | [
"public",
"function",
"getName",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_name",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_name",
"=",
"(",
"(",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
")",
")",
"->",
"getShortName",
"(",
")",
... | Get the ActiveWindow name based on its class short name.
@return string | [
"Get",
"the",
"ActiveWindow",
"name",
"based",
"on",
"its",
"class",
"short",
"name",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/base/ActiveWindow.php#L245-L252 | train |
luyadev/luya-module-admin | src/ngrest/base/ActiveWindow.php | ActiveWindow.getViewFolderName | public function getViewFolderName()
{
if ($this->_viewFolderName === null) {
$name = $this->getName();
if (StringHelper::endsWith($name, $this->suffix, false)) {
$name = substr($name, 0, -(strlen($this->suffix)));
}
$this->_viewFolderName = strtolower($name);
}
return $this->_viewFolderName;
} | php | public function getViewFolderName()
{
if ($this->_viewFolderName === null) {
$name = $this->getName();
if (StringHelper::endsWith($name, $this->suffix, false)) {
$name = substr($name, 0, -(strlen($this->suffix)));
}
$this->_viewFolderName = strtolower($name);
}
return $this->_viewFolderName;
} | [
"public",
"function",
"getViewFolderName",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_viewFolderName",
"===",
"null",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"StringHelper",
"::",
"endsWith",
"(",
"$",
... | Get the folder name where the views for this ActiveWindow should be stored.
@return string | [
"Get",
"the",
"folder",
"name",
"where",
"the",
"views",
"for",
"this",
"ActiveWindow",
"should",
"be",
"stored",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/base/ActiveWindow.php#L261-L274 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.