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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
antonioribeiro/tddd | src/package/Data/Repositories/Support/Suites.php | Suites.getAllFilesFromSuite | protected function getAllFilesFromSuite($suite)
{
if (!file_exists($suite->testsFullPath)) {
die('FATAL ERROR: directory not found: '.$suite->testsFullPath.'.');
}
$files = Finder::create()->files()->in($suite->testsFullPath);
if ($suite->file_mask) {
$files->name($suite->file_mask);
}
return iterator_to_array($files, false);
} | php | protected function getAllFilesFromSuite($suite)
{
if (!file_exists($suite->testsFullPath)) {
die('FATAL ERROR: directory not found: '.$suite->testsFullPath.'.');
}
$files = Finder::create()->files()->in($suite->testsFullPath);
if ($suite->file_mask) {
$files->name($suite->file_mask);
}
return iterator_to_array($files, false);
} | [
"protected",
"function",
"getAllFilesFromSuite",
"(",
"$",
"suite",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"suite",
"->",
"testsFullPath",
")",
")",
"{",
"die",
"(",
"'FATAL ERROR: directory not found: '",
".",
"$",
"suite",
"->",
"testsFullPath",
... | Get all files from a suite.
@param $suite
@return array | [
"Get",
"all",
"files",
"from",
"a",
"suite",
"."
] | f6c69e165bbba870d4a3259c9e6baed2cb5e51fb | https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Suites.php#L137-L150 | train |
antonioribeiro/tddd | src/package/Data/Repositories/Support/Suites.php | Suites.getSuitesForPath | public function getSuitesForPath($path)
{
$projects = $this->getProjects();
// Reduce the collection of projects by those whose path properties
// (should be only 1) are contained in the fullpath of our
// changed file
$filtered_projects = $projects->filter(function ($project) use ($path) {
return substr_count($path, $project->path) > 0;
});
// Get filtered projects dependencies
$depends = $projects->filter(function ($project) use ($filtered_projects) {
if (!is_null($depends = config("tddd.projects.{$project->name}.depends"))) {
return collect($depends)->filter(function ($item) use ($filtered_projects) {
return !is_null($filtered_projects->where('name', $item)->first());
});
}
return false;
});
// At this point we have (hopefully only 1) project. Now we need
// the suite(s) associated with the project.
return Suite::whereIn('project_id', $filtered_projects->merge($depends)->pluck('id'))
->get();
} | php | public function getSuitesForPath($path)
{
$projects = $this->getProjects();
// Reduce the collection of projects by those whose path properties
// (should be only 1) are contained in the fullpath of our
// changed file
$filtered_projects = $projects->filter(function ($project) use ($path) {
return substr_count($path, $project->path) > 0;
});
// Get filtered projects dependencies
$depends = $projects->filter(function ($project) use ($filtered_projects) {
if (!is_null($depends = config("tddd.projects.{$project->name}.depends"))) {
return collect($depends)->filter(function ($item) use ($filtered_projects) {
return !is_null($filtered_projects->where('name', $item)->first());
});
}
return false;
});
// At this point we have (hopefully only 1) project. Now we need
// the suite(s) associated with the project.
return Suite::whereIn('project_id', $filtered_projects->merge($depends)->pluck('id'))
->get();
} | [
"public",
"function",
"getSuitesForPath",
"(",
"$",
"path",
")",
"{",
"$",
"projects",
"=",
"$",
"this",
"->",
"getProjects",
"(",
")",
";",
"// Reduce the collection of projects by those whose path properties",
"// (should be only 1) are contained in the fullpath of our",
"/... | Get all suites for a path.
@param $path
@return mixed | [
"Get",
"all",
"suites",
"for",
"a",
"path",
"."
] | f6c69e165bbba870d4a3259c9e6baed2cb5e51fb | https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Suites.php#L159-L185 | train |
dektrium/yii2-rbac | models/Role.php | Role.formatName | protected function formatName(Item $item)
{
return empty($item->description) ? $item->name : $item->name . ' (' . $item->description . ')';
} | php | protected function formatName(Item $item)
{
return empty($item->description) ? $item->name : $item->name . ' (' . $item->description . ')';
} | [
"protected",
"function",
"formatName",
"(",
"Item",
"$",
"item",
")",
"{",
"return",
"empty",
"(",
"$",
"item",
"->",
"description",
")",
"?",
"$",
"item",
"->",
"name",
":",
"$",
"item",
"->",
"name",
".",
"' ('",
".",
"$",
"item",
"->",
"descriptio... | Formats name.
@param Item $item
@return string | [
"Formats",
"name",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/models/Role.php#L50-L53 | train |
dektrium/yii2-rbac | models/AuthItem.php | AuthItem.updateChildren | protected function updateChildren()
{
$children = $this->manager->getChildren($this->item->name);
$childrenNames = array_keys($children);
if (is_array($this->children)) {
// remove children that
foreach (array_diff($childrenNames, $this->children) as $item) {
$this->manager->removeChild($this->item, $children[$item]);
}
// add new children
foreach (array_diff($this->children, $childrenNames) as $item) {
$this->manager->addChild($this->item, $this->manager->getItem($item));
}
} else {
$this->manager->removeChildren($this->item);
}
} | php | protected function updateChildren()
{
$children = $this->manager->getChildren($this->item->name);
$childrenNames = array_keys($children);
if (is_array($this->children)) {
// remove children that
foreach (array_diff($childrenNames, $this->children) as $item) {
$this->manager->removeChild($this->item, $children[$item]);
}
// add new children
foreach (array_diff($this->children, $childrenNames) as $item) {
$this->manager->addChild($this->item, $this->manager->getItem($item));
}
} else {
$this->manager->removeChildren($this->item);
}
} | [
"protected",
"function",
"updateChildren",
"(",
")",
"{",
"$",
"children",
"=",
"$",
"this",
"->",
"manager",
"->",
"getChildren",
"(",
"$",
"this",
"->",
"item",
"->",
"name",
")",
";",
"$",
"childrenNames",
"=",
"array_keys",
"(",
"$",
"children",
")",... | Updated items children. | [
"Updated",
"items",
"children",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/models/AuthItem.php#L191-L208 | train |
dektrium/yii2-rbac | models/Rule.php | Rule.create | public function create()
{
if ($this->scenario != self::SCENARIO_CREATE) {
return false;
}
if (!$this->validate()) {
return false;
}
$rule = \Yii::createObject([
'class' => $this->class,
'name' => $this->name,
]);
$this->authManager->add($rule);
$this->authManager->invalidateCache();
return true;
} | php | public function create()
{
if ($this->scenario != self::SCENARIO_CREATE) {
return false;
}
if (!$this->validate()) {
return false;
}
$rule = \Yii::createObject([
'class' => $this->class,
'name' => $this->name,
]);
$this->authManager->add($rule);
$this->authManager->invalidateCache();
return true;
} | [
"public",
"function",
"create",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"scenario",
"!=",
"self",
"::",
"SCENARIO_CREATE",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"validate",
"(",
")",
")",
"{",
"return",
"fal... | Creates new auth rule.
@return bool
@throws InvalidConfigException | [
"Creates",
"new",
"auth",
"rule",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/models/Rule.php#L122-L141 | train |
dektrium/yii2-rbac | controllers/ItemControllerAbstract.php | ItemControllerAbstract.actionIndex | public function actionIndex()
{
$filterModel = new Search($this->type);
return $this->render('index', [
'filterModel' => $filterModel,
'dataProvider' => $filterModel->search(\Yii::$app->request->get()),
]);
} | php | public function actionIndex()
{
$filterModel = new Search($this->type);
return $this->render('index', [
'filterModel' => $filterModel,
'dataProvider' => $filterModel->search(\Yii::$app->request->get()),
]);
} | [
"public",
"function",
"actionIndex",
"(",
")",
"{",
"$",
"filterModel",
"=",
"new",
"Search",
"(",
"$",
"this",
"->",
"type",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'index'",
",",
"[",
"'filterModel'",
"=>",
"$",
"filterModel",
",",
"'d... | Lists all created items.
@return string | [
"Lists",
"all",
"created",
"items",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/controllers/ItemControllerAbstract.php#L61-L68 | train |
dektrium/yii2-rbac | controllers/ItemControllerAbstract.php | ItemControllerAbstract.actionDelete | public function actionDelete($name)
{
$item = $this->getItem($name);
\Yii::$app->authManager->remove($item);
return $this->redirect(['index']);
} | php | public function actionDelete($name)
{
$item = $this->getItem($name);
\Yii::$app->authManager->remove($item);
return $this->redirect(['index']);
} | [
"public",
"function",
"actionDelete",
"(",
"$",
"name",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"getItem",
"(",
"$",
"name",
")",
";",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"authManager",
"->",
"remove",
"(",
"$",
"item",
")",
";",
"return",
... | Deletes item.
@param string $name
@return Response
@throws NotFoundHttpException | [
"Deletes",
"item",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/controllers/ItemControllerAbstract.php#L128-L133 | train |
dektrium/yii2-rbac | controllers/RuleController.php | RuleController.actionCreate | public function actionCreate()
{
$model = $this->getModel(Rule::SCENARIO_CREATE);
if (\Yii::$app->request->isAjax && $model->load(\Yii::$app->request->post())) {
\Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
if ($model->load(\Yii::$app->request->post()) && $model->create()) {
\Yii::$app->session->setFlash('success', \Yii::t('rbac', 'Rule has been added'));
return $this->redirect(['index']);
}
return $this->render('create', [
'model' => $model,
]);
} | php | public function actionCreate()
{
$model = $this->getModel(Rule::SCENARIO_CREATE);
if (\Yii::$app->request->isAjax && $model->load(\Yii::$app->request->post())) {
\Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
if ($model->load(\Yii::$app->request->post()) && $model->create()) {
\Yii::$app->session->setFlash('success', \Yii::t('rbac', 'Rule has been added'));
return $this->redirect(['index']);
}
return $this->render('create', [
'model' => $model,
]);
} | [
"public",
"function",
"actionCreate",
"(",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"getModel",
"(",
"Rule",
"::",
"SCENARIO_CREATE",
")",
";",
"if",
"(",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"isAjax",
"&&",
"$",
"model",
"->"... | Shows page where new rule can be added.
@return array|string | [
"Shows",
"page",
"where",
"new",
"rule",
"can",
"be",
"added",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/controllers/RuleController.php#L83-L100 | train |
dektrium/yii2-rbac | controllers/RuleController.php | RuleController.actionDelete | public function actionDelete($name)
{
$rule = $this->findRule($name);
$this->authManager->remove($rule);
$this->authManager->invalidateCache();
\Yii::$app->session->setFlash('success', \Yii::t('rbac', 'Rule has been removed'));
return $this->redirect(['index']);
} | php | public function actionDelete($name)
{
$rule = $this->findRule($name);
$this->authManager->remove($rule);
$this->authManager->invalidateCache();
\Yii::$app->session->setFlash('success', \Yii::t('rbac', 'Rule has been removed'));
return $this->redirect(['index']);
} | [
"public",
"function",
"actionDelete",
"(",
"$",
"name",
")",
"{",
"$",
"rule",
"=",
"$",
"this",
"->",
"findRule",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"authManager",
"->",
"remove",
"(",
"$",
"rule",
")",
";",
"$",
"this",
"->",
"authMan... | Removes rule.
@param string $name
@return string
@throws NotFoundHttpException | [
"Removes",
"rule",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/controllers/RuleController.php#L141-L151 | train |
dektrium/yii2-rbac | controllers/RuleController.php | RuleController.actionSearch | public function actionSearch($q = null)
{
\Yii::$app->response->format = Response::FORMAT_JSON;
return ['results' => $this->getSearchModel()->getRuleNames($q)];
} | php | public function actionSearch($q = null)
{
\Yii::$app->response->format = Response::FORMAT_JSON;
return ['results' => $this->getSearchModel()->getRuleNames($q)];
} | [
"public",
"function",
"actionSearch",
"(",
"$",
"q",
"=",
"null",
")",
"{",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"format",
"=",
"Response",
"::",
"FORMAT_JSON",
";",
"return",
"[",
"'results'",
"=>",
"$",
"this",
"->",
"getSearchModel",... | Searches for rules.
@param string|null $q
@return array | [
"Searches",
"for",
"rules",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/controllers/RuleController.php#L159-L164 | train |
dektrium/yii2-rbac | migrations/Migration.php | Migration.up | public function up()
{
$transaction = $this->authManager->db->beginTransaction();
try {
if ($this->safeUp() === false) {
$transaction->rollBack();
return false;
}
$transaction->commit();
$this->authManager->invalidateCache();
return true;
} catch (\Exception $e) {
echo "Rolling transaction back\n";
echo 'Exception: ' . $e->getMessage() . ' (' . $e->getFile() . ':' . $e->getLine() . ")\n";
echo $e->getTraceAsString() . "\n";
$transaction->rollBack();
return false;
}
} | php | public function up()
{
$transaction = $this->authManager->db->beginTransaction();
try {
if ($this->safeUp() === false) {
$transaction->rollBack();
return false;
}
$transaction->commit();
$this->authManager->invalidateCache();
return true;
} catch (\Exception $e) {
echo "Rolling transaction back\n";
echo 'Exception: ' . $e->getMessage() . ' (' . $e->getFile() . ':' . $e->getLine() . ")\n";
echo $e->getTraceAsString() . "\n";
$transaction->rollBack();
return false;
}
} | [
"public",
"function",
"up",
"(",
")",
"{",
"$",
"transaction",
"=",
"$",
"this",
"->",
"authManager",
"->",
"db",
"->",
"beginTransaction",
"(",
")",
";",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"safeUp",
"(",
")",
"===",
"false",
")",
"{",
"$",
... | This method contains the logic to be executed when applying this migration.
Child classes should not override this method, but use safeUp instead.
@return boolean return a false value to indicate the migration fails
and should not proceed further. All other return values mean the migration succeeds. | [
"This",
"method",
"contains",
"the",
"logic",
"to",
"be",
"executed",
"when",
"applying",
"this",
"migration",
".",
"Child",
"classes",
"should",
"not",
"override",
"this",
"method",
"but",
"use",
"safeUp",
"instead",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/migrations/Migration.php#L53-L72 | train |
dektrium/yii2-rbac | migrations/Migration.php | Migration.createPermission | protected function createPermission($name, $description = '', $ruleName = null, $data = null)
{
echo " > create permission $name ...";
$time = microtime(true);
$permission = $this->authManager->createPermission($name);
$permission->description = $description;
$permission->ruleName = $ruleName;
$permission->data = $data;
$this->authManager->add($permission);
echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
return $permission;
} | php | protected function createPermission($name, $description = '', $ruleName = null, $data = null)
{
echo " > create permission $name ...";
$time = microtime(true);
$permission = $this->authManager->createPermission($name);
$permission->description = $description;
$permission->ruleName = $ruleName;
$permission->data = $data;
$this->authManager->add($permission);
echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
return $permission;
} | [
"protected",
"function",
"createPermission",
"(",
"$",
"name",
",",
"$",
"description",
"=",
"''",
",",
"$",
"ruleName",
"=",
"null",
",",
"$",
"data",
"=",
"null",
")",
"{",
"echo",
"\" > create permission $name ...\"",
";",
"$",
"time",
"=",
"microtime"... | Creates new permission.
@param string $name The name of the permission
@param string $description The description of the permission
@param string|null $ruleName The rule associated with the permission
@param mixed|null $data The additional data associated with the permission
@return Permission | [
"Creates",
"new",
"permission",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/migrations/Migration.php#L133-L147 | train |
dektrium/yii2-rbac | migrations/Migration.php | Migration.createRule | protected function createRule($ruleName, $definition)
{
echo " > create rule $ruleName ...";
$time = microtime(true);
if (is_array($definition)) {
$definition['name'] = $ruleName;
} else {
$definition = [
'class' => $definition,
'name' => $ruleName,
];
}
/** @var Rule $rule */
$rule = \Yii::createObject($definition);
$this->authManager->add($rule);
echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
return $rule;
} | php | protected function createRule($ruleName, $definition)
{
echo " > create rule $ruleName ...";
$time = microtime(true);
if (is_array($definition)) {
$definition['name'] = $ruleName;
} else {
$definition = [
'class' => $definition,
'name' => $ruleName,
];
}
/** @var Rule $rule */
$rule = \Yii::createObject($definition);
$this->authManager->add($rule);
echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
return $rule;
} | [
"protected",
"function",
"createRule",
"(",
"$",
"ruleName",
",",
"$",
"definition",
")",
"{",
"echo",
"\" > create rule $ruleName ...\"",
";",
"$",
"time",
"=",
"microtime",
"(",
"true",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"definition",
")",
")",
... | Creates new rule.
@param string $ruleName The name of the rule
@param string|array $definition The class of the rule
@return Rule | [
"Creates",
"new",
"rule",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/migrations/Migration.php#L181-L202 | train |
dektrium/yii2-rbac | migrations/Migration.php | Migration.findItem | protected function findItem($name)
{
$item = $this->authManager->getRole($name);
if ($item instanceof Role) {
return $item;
}
$item = $this->authManager->getPermission($name);
if ($item instanceof Permission) {
return $item;
}
return null;
} | php | protected function findItem($name)
{
$item = $this->authManager->getRole($name);
if ($item instanceof Role) {
return $item;
}
$item = $this->authManager->getPermission($name);
if ($item instanceof Permission) {
return $item;
}
return null;
} | [
"protected",
"function",
"findItem",
"(",
"$",
"name",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"authManager",
"->",
"getRole",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"item",
"instanceof",
"Role",
")",
"{",
"return",
"$",
"item",
";",
"}... | Finds either role or permission or throws an exception if it is not found.
@param string $name
@return Permission|Role|null | [
"Finds",
"either",
"role",
"or",
"permission",
"or",
"throws",
"an",
"exception",
"if",
"it",
"is",
"not",
"found",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/migrations/Migration.php#L210-L225 | train |
dektrium/yii2-rbac | migrations/Migration.php | Migration.findRole | protected function findRole($name)
{
$role = $this->authManager->getRole($name);
if ($role instanceof Role) {
return $role;
}
return null;
} | php | protected function findRole($name)
{
$role = $this->authManager->getRole($name);
if ($role instanceof Role) {
return $role;
}
return null;
} | [
"protected",
"function",
"findRole",
"(",
"$",
"name",
")",
"{",
"$",
"role",
"=",
"$",
"this",
"->",
"authManager",
"->",
"getRole",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"role",
"instanceof",
"Role",
")",
"{",
"return",
"$",
"role",
";",
"}... | Finds the role or throws an exception if it is not found.
@param string $name
@return Role|null | [
"Finds",
"the",
"role",
"or",
"throws",
"an",
"exception",
"if",
"it",
"is",
"not",
"found",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/migrations/Migration.php#L233-L242 | train |
dektrium/yii2-rbac | migrations/Migration.php | Migration.findPermission | protected function findPermission($name)
{
$permission = $this->authManager->getPermission($name);
if ($permission instanceof Permission) {
return $permission;
}
return null;
} | php | protected function findPermission($name)
{
$permission = $this->authManager->getPermission($name);
if ($permission instanceof Permission) {
return $permission;
}
return null;
} | [
"protected",
"function",
"findPermission",
"(",
"$",
"name",
")",
"{",
"$",
"permission",
"=",
"$",
"this",
"->",
"authManager",
"->",
"getPermission",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"permission",
"instanceof",
"Permission",
")",
"{",
"return"... | Finds the permission or throws an exception if it is not found.
@param string $name
@return Permission|null | [
"Finds",
"the",
"permission",
"or",
"throws",
"an",
"exception",
"if",
"it",
"is",
"not",
"found",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/migrations/Migration.php#L250-L259 | train |
dektrium/yii2-rbac | migrations/Migration.php | Migration.removeItem | protected function removeItem($item)
{
if (is_string($item)) {
$item = $this->findItem($item);
}
echo " > removing $item->name ...";
$time = microtime(true);
$this->authManager->remove($item);
echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
} | php | protected function removeItem($item)
{
if (is_string($item)) {
$item = $this->findItem($item);
}
echo " > removing $item->name ...";
$time = microtime(true);
$this->authManager->remove($item);
echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
} | [
"protected",
"function",
"removeItem",
"(",
"$",
"item",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"item",
")",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"findItem",
"(",
"$",
"item",
")",
";",
"}",
"echo",
"\" > removing $item->name ...\"",
... | Removes auth item.
@param string|Item $item Either item name or item instance to be removed. | [
"Removes",
"auth",
"item",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/migrations/Migration.php#L266-L276 | train |
dektrium/yii2-rbac | migrations/Migration.php | Migration.addChild | protected function addChild($parent, $child)
{
if (is_string($parent)) {
$parent = $this->findItem($parent);
}
if (is_string($child)) {
$child = $this->findItem($child);
}
echo " > adding $child->name as child to $parent->name ...";
$time = microtime(true);
$this->authManager->addChild($parent, $child);
echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
} | php | protected function addChild($parent, $child)
{
if (is_string($parent)) {
$parent = $this->findItem($parent);
}
if (is_string($child)) {
$child = $this->findItem($child);
}
echo " > adding $child->name as child to $parent->name ...";
$time = microtime(true);
$this->authManager->addChild($parent, $child);
echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
} | [
"protected",
"function",
"addChild",
"(",
"$",
"parent",
",",
"$",
"child",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"parent",
")",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"findItem",
"(",
"$",
"parent",
")",
";",
"}",
"if",
"(",
"is_... | Adds child.
@param Item|string $parent Either name or Item instance which is parent
@param Item|string $child Either name or Item instance which is child | [
"Adds",
"child",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/migrations/Migration.php#L284-L298 | train |
dektrium/yii2-rbac | migrations/Migration.php | Migration.updateRole | protected function updateRole($role, $description = '', $ruleName = null, $data = null)
{
if (is_string($role)) {
$role = $this->findRole($role);
}
echo " > update role $role->name ...";
$time = microtime(true);
$role->description = $description;
$role->ruleName = $ruleName;
$role->data = $data;
$this->authManager->update($role->name, $role);
echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
return $role;
} | php | protected function updateRole($role, $description = '', $ruleName = null, $data = null)
{
if (is_string($role)) {
$role = $this->findRole($role);
}
echo " > update role $role->name ...";
$time = microtime(true);
$role->description = $description;
$role->ruleName = $ruleName;
$role->data = $data;
$this->authManager->update($role->name, $role);
echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
return $role;
} | [
"protected",
"function",
"updateRole",
"(",
"$",
"role",
",",
"$",
"description",
"=",
"''",
",",
"$",
"ruleName",
"=",
"null",
",",
"$",
"data",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"role",
")",
")",
"{",
"$",
"role",
"=",
"$... | Updates role.
@param string|Role $role
@param string $description
@param string $ruleName
@param mixed $data
@return Role | [
"Updates",
"role",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/migrations/Migration.php#L327-L344 | train |
dektrium/yii2-rbac | migrations/Migration.php | Migration.updatePermission | protected function updatePermission($permission, $description = '', $ruleName = null, $data = null)
{
if (is_string($permission)) {
$permission = $this->findPermission($permission);
}
echo " > update permission $permission->name ...";
$time = microtime(true);
$permission->description = $description;
$permission->ruleName = $ruleName;
$permission->data = $data;
$this->authManager->update($permission->name, $permission);
echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
return $permission;
} | php | protected function updatePermission($permission, $description = '', $ruleName = null, $data = null)
{
if (is_string($permission)) {
$permission = $this->findPermission($permission);
}
echo " > update permission $permission->name ...";
$time = microtime(true);
$permission->description = $description;
$permission->ruleName = $ruleName;
$permission->data = $data;
$this->authManager->update($permission->name, $permission);
echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
return $permission;
} | [
"protected",
"function",
"updatePermission",
"(",
"$",
"permission",
",",
"$",
"description",
"=",
"''",
",",
"$",
"ruleName",
"=",
"null",
",",
"$",
"data",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"permission",
")",
")",
"{",
"$",
"... | Updates permission.
@param string|Permission $permission
@param string $description
@param string $ruleName
@param mixed $data
@return Permission | [
"Updates",
"permission",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/migrations/Migration.php#L355-L372 | train |
dektrium/yii2-rbac | migrations/Migration.php | Migration.updateRule | protected function updateRule($ruleName, $className)
{
echo " > update rule $ruleName ...";
$time = microtime(true);
/** @var Rule $rule */
$rule = \Yii::createObject([
'class' => $className,
'name' => $ruleName,
]);
$this->authManager->update($ruleName, $rule);
echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
return $rule;
} | php | protected function updateRule($ruleName, $className)
{
echo " > update rule $ruleName ...";
$time = microtime(true);
/** @var Rule $rule */
$rule = \Yii::createObject([
'class' => $className,
'name' => $ruleName,
]);
$this->authManager->update($ruleName, $rule);
echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
return $rule;
} | [
"protected",
"function",
"updateRule",
"(",
"$",
"ruleName",
",",
"$",
"className",
")",
"{",
"echo",
"\" > update rule $ruleName ...\"",
";",
"$",
"time",
"=",
"microtime",
"(",
"true",
")",
";",
"/** @var Rule $rule */",
"$",
"rule",
"=",
"\\",
"Yii",
"::... | Updates rule.
@param string $ruleName
@param string $className
@return Rule | [
"Updates",
"rule",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/migrations/Migration.php#L381-L396 | train |
dektrium/yii2-rbac | models/Search.php | Search.getNameList | public function getNameList()
{
$rows = (new Query)
->select(['name'])
->andWhere(['type' => $this->type])
->from($this->manager->itemTable)
->all();
return ArrayHelper::map($rows, 'name', 'name');
} | php | public function getNameList()
{
$rows = (new Query)
->select(['name'])
->andWhere(['type' => $this->type])
->from($this->manager->itemTable)
->all();
return ArrayHelper::map($rows, 'name', 'name');
} | [
"public",
"function",
"getNameList",
"(",
")",
"{",
"$",
"rows",
"=",
"(",
"new",
"Query",
")",
"->",
"select",
"(",
"[",
"'name'",
"]",
")",
"->",
"andWhere",
"(",
"[",
"'type'",
"=>",
"$",
"this",
"->",
"type",
"]",
")",
"->",
"from",
"(",
"$",... | Returns list of item names.
@return array | [
"Returns",
"list",
"of",
"item",
"names",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/models/Search.php#L99-L108 | train |
dektrium/yii2-rbac | models/Search.php | Search.getRuleList | public function getRuleList()
{
$rows = (new Query())
->select(['name'])
->from($this->manager->ruleTable)
->all();
return ArrayHelper::map($rows, 'name', 'name');
} | php | public function getRuleList()
{
$rows = (new Query())
->select(['name'])
->from($this->manager->ruleTable)
->all();
return ArrayHelper::map($rows, 'name', 'name');
} | [
"public",
"function",
"getRuleList",
"(",
")",
"{",
"$",
"rows",
"=",
"(",
"new",
"Query",
"(",
")",
")",
"->",
"select",
"(",
"[",
"'name'",
"]",
")",
"->",
"from",
"(",
"$",
"this",
"->",
"manager",
"->",
"ruleTable",
")",
"->",
"all",
"(",
")"... | Returns list of rule names.
@return array | [
"Returns",
"list",
"of",
"rule",
"names",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/models/Search.php#L115-L123 | train |
dektrium/yii2-rbac | models/Assignment.php | Assignment.updateAssignments | public function updateAssignments()
{
if (!$this->validate()) {
return false;
}
if (!is_array($this->items)) {
$this->items = [];
}
$assignedItems = $this->manager->getItemsByUser($this->user_id);
$assignedItemsNames = array_keys($assignedItems);
foreach (array_diff($assignedItemsNames, $this->items) as $item) {
$this->manager->revoke($assignedItems[$item], $this->user_id);
}
foreach (array_diff($this->items, $assignedItemsNames) as $item) {
$this->manager->assign($this->manager->getItem($item), $this->user_id);
}
$this->updated = true;
return true;
} | php | public function updateAssignments()
{
if (!$this->validate()) {
return false;
}
if (!is_array($this->items)) {
$this->items = [];
}
$assignedItems = $this->manager->getItemsByUser($this->user_id);
$assignedItemsNames = array_keys($assignedItems);
foreach (array_diff($assignedItemsNames, $this->items) as $item) {
$this->manager->revoke($assignedItems[$item], $this->user_id);
}
foreach (array_diff($this->items, $assignedItemsNames) as $item) {
$this->manager->assign($this->manager->getItem($item), $this->user_id);
}
$this->updated = true;
return true;
} | [
"public",
"function",
"updateAssignments",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validate",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"items",
")",
")",
"{",
"$",
"this",
"->... | Updates auth assignments for user.
@return boolean | [
"Updates",
"auth",
"assignments",
"for",
"user",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/models/Assignment.php#L86-L110 | train |
dektrium/yii2-rbac | models/Assignment.php | Assignment.getAvailableItems | public function getAvailableItems()
{
return ArrayHelper::map($this->manager->getItems(), 'name', function ($item) {
return empty($item->description)
? $item->name
: $item->name . ' (' . $item->description . ')';
});
} | php | public function getAvailableItems()
{
return ArrayHelper::map($this->manager->getItems(), 'name', function ($item) {
return empty($item->description)
? $item->name
: $item->name . ' (' . $item->description . ')';
});
} | [
"public",
"function",
"getAvailableItems",
"(",
")",
"{",
"return",
"ArrayHelper",
"::",
"map",
"(",
"$",
"this",
"->",
"manager",
"->",
"getItems",
"(",
")",
",",
"'name'",
",",
"function",
"(",
"$",
"item",
")",
"{",
"return",
"empty",
"(",
"$",
"ite... | Returns all available auth items to be attached to user.
@return array | [
"Returns",
"all",
"available",
"auth",
"items",
"to",
"be",
"attached",
"to",
"user",
"."
] | a53c498847103ab1904699219b8d67c0ab63f000 | https://github.com/dektrium/yii2-rbac/blob/a53c498847103ab1904699219b8d67c0ab63f000/models/Assignment.php#L116-L123 | train |
codezero-be/laravel-unique-translation | src/UniqueTranslationRule.php | UniqueTranslationRule.ignore | public function ignore($value, $column = 'id')
{
$this->ignoreValue = $value;
$this->ignoreColumn = $column;
return $this;
} | php | public function ignore($value, $column = 'id')
{
$this->ignoreValue = $value;
$this->ignoreColumn = $column;
return $this;
} | [
"public",
"function",
"ignore",
"(",
"$",
"value",
",",
"$",
"column",
"=",
"'id'",
")",
"{",
"$",
"this",
"->",
"ignoreValue",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"ignoreColumn",
"=",
"$",
"column",
";",
"return",
"$",
"this",
";",
"}"
] | Ignore any record that has a column with the given value.
@param mixed $value
@param string $column
@return $this | [
"Ignore",
"any",
"record",
"that",
"has",
"a",
"column",
"with",
"the",
"given",
"value",
"."
] | b39c85d85fbb051243f0b8e65de878bdd729737d | https://github.com/codezero-be/laravel-unique-translation/blob/b39c85d85fbb051243f0b8e65de878bdd729737d/src/UniqueTranslationRule.php#L65-L71 | train |
codezero-be/laravel-unique-translation | src/UniqueTranslationValidator.php | UniqueTranslationValidator.validate | public function validate($attribute, $value, $parameters, $validator)
{
list ($name, $locale) = $this->getAttributeNameAndLocale($attribute);
if ($this->isUnique($value, $name, $locale, $parameters)) {
return true;
}
$this->addErrorsToValidator($validator, $parameters, $name, $locale);
return false;
} | php | public function validate($attribute, $value, $parameters, $validator)
{
list ($name, $locale) = $this->getAttributeNameAndLocale($attribute);
if ($this->isUnique($value, $name, $locale, $parameters)) {
return true;
}
$this->addErrorsToValidator($validator, $parameters, $name, $locale);
return false;
} | [
"public",
"function",
"validate",
"(",
"$",
"attribute",
",",
"$",
"value",
",",
"$",
"parameters",
",",
"$",
"validator",
")",
"{",
"list",
"(",
"$",
"name",
",",
"$",
"locale",
")",
"=",
"$",
"this",
"->",
"getAttributeNameAndLocale",
"(",
"$",
"attr... | Check if the translated value is unique in the database.
@param string $attribute
@param string $value
@param array $parameters
@param \Illuminate\Validation\Validator $validator
@return bool | [
"Check",
"if",
"the",
"translated",
"value",
"is",
"unique",
"in",
"the",
"database",
"."
] | b39c85d85fbb051243f0b8e65de878bdd729737d | https://github.com/codezero-be/laravel-unique-translation/blob/b39c85d85fbb051243f0b8e65de878bdd729737d/src/UniqueTranslationValidator.php#L22-L33 | train |
codezero-be/laravel-unique-translation | src/UniqueTranslationValidator.php | UniqueTranslationValidator.getAttributeNameAndLocale | protected function getAttributeNameAndLocale($attribute)
{
$parts = explode('.', $attribute);
$name = $parts[0];
$locale = $parts[1] ?? App::getLocale();
return [$name, $locale];
} | php | protected function getAttributeNameAndLocale($attribute)
{
$parts = explode('.', $attribute);
$name = $parts[0];
$locale = $parts[1] ?? App::getLocale();
return [$name, $locale];
} | [
"protected",
"function",
"getAttributeNameAndLocale",
"(",
"$",
"attribute",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"attribute",
")",
";",
"$",
"name",
"=",
"$",
"parts",
"[",
"0",
"]",
";",
"$",
"locale",
"=",
"$",
"parts",
"[... | Get the attribute name and locale.
@param string $attribute
@return array | [
"Get",
"the",
"attribute",
"name",
"and",
"locale",
"."
] | b39c85d85fbb051243f0b8e65de878bdd729737d | https://github.com/codezero-be/laravel-unique-translation/blob/b39c85d85fbb051243f0b8e65de878bdd729737d/src/UniqueTranslationValidator.php#L42-L50 | train |
codezero-be/laravel-unique-translation | src/UniqueTranslationValidator.php | UniqueTranslationValidator.getConnectionAndTable | protected function getConnectionAndTable($parameters)
{
$parts = explode('.', $this->getParameter($parameters, 0));
$connection = isset($parts[1])
? $parts[0]
: Config::get('database.default');
$table = $parts[1] ?? $parts[0];
return [$connection, $table];
} | php | protected function getConnectionAndTable($parameters)
{
$parts = explode('.', $this->getParameter($parameters, 0));
$connection = isset($parts[1])
? $parts[0]
: Config::get('database.default');
$table = $parts[1] ?? $parts[0];
return [$connection, $table];
} | [
"protected",
"function",
"getConnectionAndTable",
"(",
"$",
"parameters",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"this",
"->",
"getParameter",
"(",
"$",
"parameters",
",",
"0",
")",
")",
";",
"$",
"connection",
"=",
"isset",
"(",
... | Get the database connection and table name.
@param array $parameters
@return array | [
"Get",
"the",
"database",
"connection",
"and",
"table",
"name",
"."
] | b39c85d85fbb051243f0b8e65de878bdd729737d | https://github.com/codezero-be/laravel-unique-translation/blob/b39c85d85fbb051243f0b8e65de878bdd729737d/src/UniqueTranslationValidator.php#L59-L70 | train |
codezero-be/laravel-unique-translation | src/UniqueTranslationValidator.php | UniqueTranslationValidator.isUnique | protected function isUnique($value, $name, $locale, $parameters)
{
list ($connection, $table) = $this->getConnectionAndTable($parameters);
$column = $this->getParameter($parameters, 1) ?? $name;
$ignoreValue = $this->getParameter($parameters, 2);
$ignoreColumn = $this->getParameter($parameters, 3);
$query = $this->findTranslation($connection, $table, $column, $locale, $value);
$query = $this->ignore($query, $ignoreColumn, $ignoreValue);
$query = $this->addConditions($query, $this->getUniqueExtra($parameters));
$isUnique = $query->count() === 0;
return $isUnique;
} | php | protected function isUnique($value, $name, $locale, $parameters)
{
list ($connection, $table) = $this->getConnectionAndTable($parameters);
$column = $this->getParameter($parameters, 1) ?? $name;
$ignoreValue = $this->getParameter($parameters, 2);
$ignoreColumn = $this->getParameter($parameters, 3);
$query = $this->findTranslation($connection, $table, $column, $locale, $value);
$query = $this->ignore($query, $ignoreColumn, $ignoreValue);
$query = $this->addConditions($query, $this->getUniqueExtra($parameters));
$isUnique = $query->count() === 0;
return $isUnique;
} | [
"protected",
"function",
"isUnique",
"(",
"$",
"value",
",",
"$",
"name",
",",
"$",
"locale",
",",
"$",
"parameters",
")",
"{",
"list",
"(",
"$",
"connection",
",",
"$",
"table",
")",
"=",
"$",
"this",
"->",
"getConnectionAndTable",
"(",
"$",
"paramete... | Check if a translation is unique.
@param mixed $value
@param string $name
@param string $locale
@param array $parameters
@return bool | [
"Check",
"if",
"a",
"translation",
"is",
"unique",
"."
] | b39c85d85fbb051243f0b8e65de878bdd729737d | https://github.com/codezero-be/laravel-unique-translation/blob/b39c85d85fbb051243f0b8e65de878bdd729737d/src/UniqueTranslationValidator.php#L107-L122 | train |
codezero-be/laravel-unique-translation | src/UniqueTranslationValidator.php | UniqueTranslationValidator.findTranslation | protected function findTranslation($connection, $table, $column, $locale, $value)
{
return DB::connection($connection)->table($table)->where("{$column}->{$locale}", '=', $value);
} | php | protected function findTranslation($connection, $table, $column, $locale, $value)
{
return DB::connection($connection)->table($table)->where("{$column}->{$locale}", '=', $value);
} | [
"protected",
"function",
"findTranslation",
"(",
"$",
"connection",
",",
"$",
"table",
",",
"$",
"column",
",",
"$",
"locale",
",",
"$",
"value",
")",
"{",
"return",
"DB",
"::",
"connection",
"(",
"$",
"connection",
")",
"->",
"table",
"(",
"$",
"table... | Find the given translated value in the database.
@param string $connection
@param string $table
@param string $column
@param string $locale
@param mixed $value
@return \Illuminate\Database\Query\Builder | [
"Find",
"the",
"given",
"translated",
"value",
"in",
"the",
"database",
"."
] | b39c85d85fbb051243f0b8e65de878bdd729737d | https://github.com/codezero-be/laravel-unique-translation/blob/b39c85d85fbb051243f0b8e65de878bdd729737d/src/UniqueTranslationValidator.php#L135-L138 | train |
codezero-be/laravel-unique-translation | src/UniqueTranslationValidator.php | UniqueTranslationValidator.ignore | protected function ignore($query, $column = null, $value = null)
{
if ($value !== null && $column === null) {
$column = 'id';
}
if ($column !== null) {
$query = $query->where($column, '!=', $value);
}
return $query;
} | php | protected function ignore($query, $column = null, $value = null)
{
if ($value !== null && $column === null) {
$column = 'id';
}
if ($column !== null) {
$query = $query->where($column, '!=', $value);
}
return $query;
} | [
"protected",
"function",
"ignore",
"(",
"$",
"query",
",",
"$",
"column",
"=",
"null",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"value",
"!==",
"null",
"&&",
"$",
"column",
"===",
"null",
")",
"{",
"$",
"column",
"=",
"'id'",
";"... | Ignore the column with the given value.
@param \Illuminate\Database\Query\Builder $query
@param string|null $column
@param mixed $value
@return \Illuminate\Database\Query\Builder | [
"Ignore",
"the",
"column",
"with",
"the",
"given",
"value",
"."
] | b39c85d85fbb051243f0b8e65de878bdd729737d | https://github.com/codezero-be/laravel-unique-translation/blob/b39c85d85fbb051243f0b8e65de878bdd729737d/src/UniqueTranslationValidator.php#L149-L160 | train |
codezero-be/laravel-unique-translation | src/UniqueTranslationValidator.php | UniqueTranslationValidator.addErrorsToValidator | protected function addErrorsToValidator($validator, $parameters, $name, $locale)
{
$rule = 'unique_translation';
$message = $this->getFormattedMessage($validator, $rule, $parameters, $name, $locale);
$validator->errors()
->add($name, $message)
->add("{$name}.{$locale}", $message);
} | php | protected function addErrorsToValidator($validator, $parameters, $name, $locale)
{
$rule = 'unique_translation';
$message = $this->getFormattedMessage($validator, $rule, $parameters, $name, $locale);
$validator->errors()
->add($name, $message)
->add("{$name}.{$locale}", $message);
} | [
"protected",
"function",
"addErrorsToValidator",
"(",
"$",
"validator",
",",
"$",
"parameters",
",",
"$",
"name",
",",
"$",
"locale",
")",
"{",
"$",
"rule",
"=",
"'unique_translation'",
";",
"$",
"message",
"=",
"$",
"this",
"->",
"getFormattedMessage",
"(",... | Add error messages to the validator.
@param \Illuminate\Validation\Validator $validator
@param array $parameters
@param string $name
@param string $locale
@return void | [
"Add",
"error",
"messages",
"to",
"the",
"validator",
"."
] | b39c85d85fbb051243f0b8e65de878bdd729737d | https://github.com/codezero-be/laravel-unique-translation/blob/b39c85d85fbb051243f0b8e65de878bdd729737d/src/UniqueTranslationValidator.php#L251-L259 | train |
codezero-be/laravel-unique-translation | src/UniqueTranslationValidator.php | UniqueTranslationValidator.getFormattedMessage | protected function getFormattedMessage($validator, $rule, $parameters, $name, $locale)
{
$message = $this->getMessage($validator, $rule, $name, $locale);
return $validator->makeReplacements($message, $name, $rule, $parameters);
} | php | protected function getFormattedMessage($validator, $rule, $parameters, $name, $locale)
{
$message = $this->getMessage($validator, $rule, $name, $locale);
return $validator->makeReplacements($message, $name, $rule, $parameters);
} | [
"protected",
"function",
"getFormattedMessage",
"(",
"$",
"validator",
",",
"$",
"rule",
",",
"$",
"parameters",
",",
"$",
"name",
",",
"$",
"locale",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"getMessage",
"(",
"$",
"validator",
",",
"$",
"rul... | Get the formatted error message.
This will format the placeholders:
e.g. "post_slug" will become "post slug".
@param \Illuminate\Validation\Validator $validator
@param string $rule
@param array $parameters
@param string $name
@param string $locale
@return string | [
"Get",
"the",
"formatted",
"error",
"message",
"."
] | b39c85d85fbb051243f0b8e65de878bdd729737d | https://github.com/codezero-be/laravel-unique-translation/blob/b39c85d85fbb051243f0b8e65de878bdd729737d/src/UniqueTranslationValidator.php#L275-L280 | train |
codezero-be/laravel-unique-translation | src/UniqueTranslationValidator.php | UniqueTranslationValidator.getMessage | protected function getMessage($validator, $rule, $name, $locale)
{
$keys = [
"{$name}.{$rule}",
"{$name}.*.{$rule}",
"{$name}.{$locale}.{$rule}",
];
foreach ($keys as $key) {
if (array_key_exists($key, $validator->customMessages)) {
return $validator->customMessages[$key];
}
}
return trans('validation.unique');
} | php | protected function getMessage($validator, $rule, $name, $locale)
{
$keys = [
"{$name}.{$rule}",
"{$name}.*.{$rule}",
"{$name}.{$locale}.{$rule}",
];
foreach ($keys as $key) {
if (array_key_exists($key, $validator->customMessages)) {
return $validator->customMessages[$key];
}
}
return trans('validation.unique');
} | [
"protected",
"function",
"getMessage",
"(",
"$",
"validator",
",",
"$",
"rule",
",",
"$",
"name",
",",
"$",
"locale",
")",
"{",
"$",
"keys",
"=",
"[",
"\"{$name}.{$rule}\"",
",",
"\"{$name}.*.{$rule}\"",
",",
"\"{$name}.{$locale}.{$rule}\"",
",",
"]",
";",
"... | Get any custom message from the validator or return a default message.
@param \Illuminate\Validation\Validator $validator
@param string $rule
@param string $name
@param string $locale
@return string | [
"Get",
"any",
"custom",
"message",
"from",
"the",
"validator",
"or",
"return",
"a",
"default",
"message",
"."
] | b39c85d85fbb051243f0b8e65de878bdd729737d | https://github.com/codezero-be/laravel-unique-translation/blob/b39c85d85fbb051243f0b8e65de878bdd729737d/src/UniqueTranslationValidator.php#L292-L307 | train |
wp-cli/config-command | src/Config_Command.php | Config_Command.create | public function create( $_, $assoc_args ) {
if ( ! \WP_CLI\Utils\get_flag_value( $assoc_args, 'force' ) && Utils\locate_wp_config() ) {
WP_CLI::error( "The 'wp-config.php' file already exists." );
}
$defaults = [
'dbhost' => 'localhost',
'dbpass' => '',
'dbprefix' => 'wp_',
'dbcharset' => 'utf8',
'dbcollate' => '',
'locale' => self::get_initial_locale(),
];
$assoc_args = array_merge( $defaults, $assoc_args );
if ( preg_match( '|[^a-z0-9_]|i', $assoc_args['dbprefix'] ) ) {
WP_CLI::error( '--dbprefix can only contain numbers, letters, and underscores.' );
}
$mysql_db_connection_args = [
'execute' => ';',
'host' => $assoc_args['dbhost'],
'user' => $assoc_args['dbuser'],
'pass' => $assoc_args['dbpass'],
];
// Check DB connection.
if ( ! Utils\get_flag_value( $assoc_args, 'skip-check' ) ) {
Utils\run_mysql_command( '/usr/bin/env mysql --no-defaults', $mysql_db_connection_args );
}
if ( Utils\get_flag_value( $assoc_args, 'extra-php' ) === true ) {
$assoc_args['extra-php'] = file_get_contents( 'php://stdin' );
}
if ( ! Utils\get_flag_value( $assoc_args, 'skip-salts' ) ) {
try {
$assoc_args['keys-and-salts'] = true;
$assoc_args['auth-key'] = self::unique_key();
$assoc_args['secure-auth-key'] = self::unique_key();
$assoc_args['logged-in-key'] = self::unique_key();
$assoc_args['nonce-key'] = self::unique_key();
$assoc_args['auth-salt'] = self::unique_key();
$assoc_args['secure-auth-salt'] = self::unique_key();
$assoc_args['logged-in-salt'] = self::unique_key();
$assoc_args['nonce-salt'] = self::unique_key();
$assoc_args['wp-cache-key-salt'] = self::unique_key();
} catch ( Exception $e ) {
$assoc_args['keys-and-salts'] = false;
$assoc_args['keys-and-salts-alt'] = self::read_(
'https://api.wordpress.org/secret-key/1.1/salt/'
);
}
}
if ( Utils\wp_version_compare( '4.0', '<' ) ) {
$assoc_args['add-wplang'] = true;
} else {
$assoc_args['add-wplang'] = false;
}
$command_root = Utils\phar_safe_path( dirname( __DIR__ ) );
$out = Utils\mustache_render( "{$command_root}/templates/wp-config.mustache", $assoc_args );
$bytes_written = file_put_contents( ABSPATH . 'wp-config.php', $out );
if ( ! $bytes_written ) {
WP_CLI::error( "Could not create new 'wp-config.php' file." );
} else {
WP_CLI::success( "Generated 'wp-config.php' file." );
}
} | php | public function create( $_, $assoc_args ) {
if ( ! \WP_CLI\Utils\get_flag_value( $assoc_args, 'force' ) && Utils\locate_wp_config() ) {
WP_CLI::error( "The 'wp-config.php' file already exists." );
}
$defaults = [
'dbhost' => 'localhost',
'dbpass' => '',
'dbprefix' => 'wp_',
'dbcharset' => 'utf8',
'dbcollate' => '',
'locale' => self::get_initial_locale(),
];
$assoc_args = array_merge( $defaults, $assoc_args );
if ( preg_match( '|[^a-z0-9_]|i', $assoc_args['dbprefix'] ) ) {
WP_CLI::error( '--dbprefix can only contain numbers, letters, and underscores.' );
}
$mysql_db_connection_args = [
'execute' => ';',
'host' => $assoc_args['dbhost'],
'user' => $assoc_args['dbuser'],
'pass' => $assoc_args['dbpass'],
];
// Check DB connection.
if ( ! Utils\get_flag_value( $assoc_args, 'skip-check' ) ) {
Utils\run_mysql_command( '/usr/bin/env mysql --no-defaults', $mysql_db_connection_args );
}
if ( Utils\get_flag_value( $assoc_args, 'extra-php' ) === true ) {
$assoc_args['extra-php'] = file_get_contents( 'php://stdin' );
}
if ( ! Utils\get_flag_value( $assoc_args, 'skip-salts' ) ) {
try {
$assoc_args['keys-and-salts'] = true;
$assoc_args['auth-key'] = self::unique_key();
$assoc_args['secure-auth-key'] = self::unique_key();
$assoc_args['logged-in-key'] = self::unique_key();
$assoc_args['nonce-key'] = self::unique_key();
$assoc_args['auth-salt'] = self::unique_key();
$assoc_args['secure-auth-salt'] = self::unique_key();
$assoc_args['logged-in-salt'] = self::unique_key();
$assoc_args['nonce-salt'] = self::unique_key();
$assoc_args['wp-cache-key-salt'] = self::unique_key();
} catch ( Exception $e ) {
$assoc_args['keys-and-salts'] = false;
$assoc_args['keys-and-salts-alt'] = self::read_(
'https://api.wordpress.org/secret-key/1.1/salt/'
);
}
}
if ( Utils\wp_version_compare( '4.0', '<' ) ) {
$assoc_args['add-wplang'] = true;
} else {
$assoc_args['add-wplang'] = false;
}
$command_root = Utils\phar_safe_path( dirname( __DIR__ ) );
$out = Utils\mustache_render( "{$command_root}/templates/wp-config.mustache", $assoc_args );
$bytes_written = file_put_contents( ABSPATH . 'wp-config.php', $out );
if ( ! $bytes_written ) {
WP_CLI::error( "Could not create new 'wp-config.php' file." );
} else {
WP_CLI::success( "Generated 'wp-config.php' file." );
}
} | [
"public",
"function",
"create",
"(",
"$",
"_",
",",
"$",
"assoc_args",
")",
"{",
"if",
"(",
"!",
"\\",
"WP_CLI",
"\\",
"Utils",
"\\",
"get_flag_value",
"(",
"$",
"assoc_args",
",",
"'force'",
")",
"&&",
"Utils",
"\\",
"locate_wp_config",
"(",
")",
")",... | Generates a wp-config.php file.
Creates a new wp-config.php with database constants, and verifies that
the database constants are correct.
## OPTIONS
--dbname=<dbname>
: Set the database name.
--dbuser=<dbuser>
: Set the database user.
[--dbpass=<dbpass>]
: Set the database user password.
[--dbhost=<dbhost>]
: Set the database host.
---
default: localhost
---
[--dbprefix=<dbprefix>]
: Set the database table prefix.
---
default: wp_
---
[--dbcharset=<dbcharset>]
: Set the database charset.
---
default: utf8
---
[--dbcollate=<dbcollate>]
: Set the database collation.
---
default:
---
[--locale=<locale>]
: Set the WPLANG constant. Defaults to $wp_local_package variable.
[--extra-php]
: If set, the command copies additional PHP code into wp-config.php from STDIN.
[--skip-salts]
: If set, keys and salts won't be generated, but should instead be passed via `--extra-php`.
[--skip-check]
: If set, the database connection is not checked.
[--force]
: Overwrites existing files, if present.
## EXAMPLES
# Standard wp-config.php file
$ wp config create --dbname=testing --dbuser=wp --dbpass=securepswd --locale=ro_RO
Success: Generated 'wp-config.php' file.
# Enable WP_DEBUG and WP_DEBUG_LOG
$ wp config create --dbname=testing --dbuser=wp --dbpass=securepswd --extra-php <<PHP
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
PHP
Success: Generated 'wp-config.php' file.
# Avoid disclosing password to bash history by reading from password.txt
# Using --prompt=dbpass will prompt for the 'dbpass' argument
$ wp config create --dbname=testing --dbuser=wp --prompt=dbpass < password.txt
Success: Generated 'wp-config.php' file. | [
"Generates",
"a",
"wp",
"-",
"config",
".",
"php",
"file",
"."
] | b7e69946e4ec711d4568d11d2b7e08f5e872567d | https://github.com/wp-cli/config-command/blob/b7e69946e4ec711d4568d11d2b7e08f5e872567d/src/Config_Command.php#L100-L170 | train |
wp-cli/config-command | src/Config_Command.php | Config_Command.edit | public function edit() {
$config_path = $this->get_config_path();
$contents = file_get_contents( $config_path );
$r = Utils\launch_editor_for_input( $contents, 'wp-config.php', 'php' );
if ( false === $r ) {
WP_CLI::warning( 'No changes made to wp-config.php.', 'Aborted' );
} else {
file_put_contents( $config_path, $r );
}
} | php | public function edit() {
$config_path = $this->get_config_path();
$contents = file_get_contents( $config_path );
$r = Utils\launch_editor_for_input( $contents, 'wp-config.php', 'php' );
if ( false === $r ) {
WP_CLI::warning( 'No changes made to wp-config.php.', 'Aborted' );
} else {
file_put_contents( $config_path, $r );
}
} | [
"public",
"function",
"edit",
"(",
")",
"{",
"$",
"config_path",
"=",
"$",
"this",
"->",
"get_config_path",
"(",
")",
";",
"$",
"contents",
"=",
"file_get_contents",
"(",
"$",
"config_path",
")",
";",
"$",
"r",
"=",
"Utils",
"\\",
"launch_editor_for_input"... | Launches system editor to edit the wp-config.php file.
## EXAMPLES
# Launch system editor to edit wp-config.php file
$ wp config edit
# Edit wp-config.php file in a specific editor
$ EDITOR=vim wp config edit
@when before_wp_load | [
"Launches",
"system",
"editor",
"to",
"edit",
"the",
"wp",
"-",
"config",
".",
"php",
"file",
"."
] | b7e69946e4ec711d4568d11d2b7e08f5e872567d | https://github.com/wp-cli/config-command/blob/b7e69946e4ec711d4568d11d2b7e08f5e872567d/src/Config_Command.php#L185-L194 | train |
wp-cli/config-command | src/Config_Command.php | Config_Command.list_ | public function list_( $args, $assoc_args ) {
$path = $this->get_config_path();
$strict = Utils\get_flag_value( $assoc_args, 'strict' );
if ( $strict && empty( $args ) ) {
WP_CLI::error( 'The --strict option can only be used in combination with a filter.' );
}
$default_fields = array(
'name',
'value',
'type',
);
$defaults = array(
'fields' => implode( ',', $default_fields ),
'format' => 'table',
);
$assoc_args = array_merge( $defaults, $assoc_args );
$values = self::get_wp_config_vars();
if ( ! empty( $args ) ) {
$values = $this->filter_values( $values, $args, $strict );
}
if ( empty( $values ) ) {
WP_CLI::error( "No matching entries found in 'wp-config.php'." );
}
Utils\format_items( $assoc_args['format'], $values, $assoc_args['fields'] );
} | php | public function list_( $args, $assoc_args ) {
$path = $this->get_config_path();
$strict = Utils\get_flag_value( $assoc_args, 'strict' );
if ( $strict && empty( $args ) ) {
WP_CLI::error( 'The --strict option can only be used in combination with a filter.' );
}
$default_fields = array(
'name',
'value',
'type',
);
$defaults = array(
'fields' => implode( ',', $default_fields ),
'format' => 'table',
);
$assoc_args = array_merge( $defaults, $assoc_args );
$values = self::get_wp_config_vars();
if ( ! empty( $args ) ) {
$values = $this->filter_values( $values, $args, $strict );
}
if ( empty( $values ) ) {
WP_CLI::error( "No matching entries found in 'wp-config.php'." );
}
Utils\format_items( $assoc_args['format'], $values, $assoc_args['fields'] );
} | [
"public",
"function",
"list_",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"get_config_path",
"(",
")",
";",
"$",
"strict",
"=",
"Utils",
"\\",
"get_flag_value",
"(",
"$",
"assoc_args",
",",
"'strict'",
")",... | Lists variables, constants, and file includes defined in wp-config.php file.
## OPTIONS
[<filter>...]
: Name or partial name to filter the list by.
[--fields=<fields>]
: Limit the output to specific fields. Defaults to all fields.
[--format=<format>]
: Render output in a particular format.
---
default: table
options:
- table
- csv
- json
- yaml
---
[--strict]
: Enforce strict matching when a filter is provided.
## EXAMPLES
# List constants and variables defined in wp-config.php file.
$ wp config list
+------------------+------------------------------------------------------------------+----------+
| key | value | type |
+------------------+------------------------------------------------------------------+----------+
| table_prefix | wp_ | variable |
| DB_NAME | wp_cli_test | constant |
| DB_USER | root | constant |
| DB_PASSWORD | root | constant |
| AUTH_KEY | r6+@shP1yO&$)1gdu.hl[/j;7Zrvmt~o;#WxSsa0mlQOi24j2cR,7i+QM/#7S:o^ | constant |
| SECURE_AUTH_KEY | iO-z!_m--YH$Tx2tf/&V,YW*13Z_HiRLqi)d?$o-tMdY+82pK$`T.NYW~iTLW;xp | constant |
+------------------+------------------------------------------------------------------+----------+
# List only database user and password from wp-config.php file.
$ wp config list DB_USER DB_PASSWORD --strict
+------------------+-------+----------+
| key | value | type |
+------------------+-------+----------+
| DB_USER | root | constant |
| DB_PASSWORD | root | constant |
+------------------+-------+----------+
# List all salts from wp-config.php file.
$ wp config list _SALT
+------------------+------------------------------------------------------------------+----------+
| key | value | type |
+------------------+------------------------------------------------------------------+----------+
| AUTH_SALT | n:]Xditk+_7>Qi=>BmtZHiH-6/Ecrvl(V5ceeGP:{>?;BT^=[B3-0>,~F5z$(+Q$ | constant |
| SECURE_AUTH_SALT | ?Z/p|XhDw3w}?c.z%|+BAr|(Iv*H%%U+Du&kKR y?cJOYyRVRBeB[2zF-`(>+LCC | constant |
| LOGGED_IN_SALT | +$@(1{b~Z~s}Cs>8Y]6[m6~TnoCDpE>O%e75u}&6kUH!>q:7uM4lxbB6[1pa_X,q | constant |
| NONCE_SALT | _x+F li|QL?0OSQns1_JZ{|Ix3Jleox-71km/gifnyz8kmo=w-;@AE8W,(fP<N}2 | constant |
+------------------+------------------------------------------------------------------+----------+
@when before_wp_load
@subcommand list | [
"Lists",
"variables",
"constants",
"and",
"file",
"includes",
"defined",
"in",
"wp",
"-",
"config",
".",
"php",
"file",
"."
] | b7e69946e4ec711d4568d11d2b7e08f5e872567d | https://github.com/wp-cli/config-command/blob/b7e69946e4ec711d4568d11d2b7e08f5e872567d/src/Config_Command.php#L274-L306 | train |
wp-cli/config-command | src/Config_Command.php | Config_Command.get | public function get( $args, $assoc_args ) {
$path = $this->get_config_path();
list( $name ) = $args;
$type = Utils\get_flag_value( $assoc_args, 'type' );
$value = $this->return_value( $name, $type, self::get_wp_config_vars() );
WP_CLI::print_value( $value, $assoc_args );
} | php | public function get( $args, $assoc_args ) {
$path = $this->get_config_path();
list( $name ) = $args;
$type = Utils\get_flag_value( $assoc_args, 'type' );
$value = $this->return_value( $name, $type, self::get_wp_config_vars() );
WP_CLI::print_value( $value, $assoc_args );
} | [
"public",
"function",
"get",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"get_config_path",
"(",
")",
";",
"list",
"(",
"$",
"name",
")",
"=",
"$",
"args",
";",
"$",
"type",
"=",
"Utils",
"\\",
"get_fl... | Gets the value of a specific constant or variable defined in wp-config.php file.
## OPTIONS
<name>
: Name of the wp-config.php constant or variable.
[--type=<type>]
: Type of config value to retrieve. Defaults to 'all'.
---
default: all
options:
- constant
- variable
- all
---
[--format=<format>]
: Get value in a particular format.
---
default: var_export
options:
- var_export
- json
- yaml
---
## EXAMPLES
# Get the table_prefix as defined in wp-config.php file.
$ wp config get table_prefix
wp_
@when before_wp_load | [
"Gets",
"the",
"value",
"of",
"a",
"specific",
"constant",
"or",
"variable",
"defined",
"in",
"wp",
"-",
"config",
".",
"php",
"file",
"."
] | b7e69946e4ec711d4568d11d2b7e08f5e872567d | https://github.com/wp-cli/config-command/blob/b7e69946e4ec711d4568d11d2b7e08f5e872567d/src/Config_Command.php#L344-L352 | train |
wp-cli/config-command | src/Config_Command.php | Config_Command.get_wp_config_vars | private static function get_wp_config_vars() {
$wp_cli_original_defined_constants = get_defined_constants();
$wp_cli_original_defined_vars = get_defined_vars();
$wp_cli_original_includes = get_included_files();
// phpcs:ignore Squiz.PHP.Eval.Discouraged -- Don't have another way.
eval( WP_CLI::get_runner()->get_wp_config_code() );
$wp_config_vars = self::get_wp_config_diff( get_defined_vars(), $wp_cli_original_defined_vars, 'variable', array( 'wp_cli_original_defined_vars' ) );
$wp_config_constants = self::get_wp_config_diff( get_defined_constants(), $wp_cli_original_defined_constants, 'constant' );
foreach ( $wp_config_vars as $name => $value ) {
if ( 'wp_cli_original_includes' === $value['name'] ) {
$name_backup = $name;
break;
}
}
unset( $wp_config_vars[ $name_backup ] );
$wp_config_vars = array_values( $wp_config_vars );
$wp_config_includes = array_diff( get_included_files(), $wp_cli_original_includes );
$wp_config_includes_array = [];
foreach ( $wp_config_includes as $name => $value ) {
$wp_config_includes_array[] = [
'name' => basename( $value ),
'value' => $value,
'type' => 'includes',
];
}
return array_merge( $wp_config_vars, $wp_config_constants, $wp_config_includes_array );
} | php | private static function get_wp_config_vars() {
$wp_cli_original_defined_constants = get_defined_constants();
$wp_cli_original_defined_vars = get_defined_vars();
$wp_cli_original_includes = get_included_files();
// phpcs:ignore Squiz.PHP.Eval.Discouraged -- Don't have another way.
eval( WP_CLI::get_runner()->get_wp_config_code() );
$wp_config_vars = self::get_wp_config_diff( get_defined_vars(), $wp_cli_original_defined_vars, 'variable', array( 'wp_cli_original_defined_vars' ) );
$wp_config_constants = self::get_wp_config_diff( get_defined_constants(), $wp_cli_original_defined_constants, 'constant' );
foreach ( $wp_config_vars as $name => $value ) {
if ( 'wp_cli_original_includes' === $value['name'] ) {
$name_backup = $name;
break;
}
}
unset( $wp_config_vars[ $name_backup ] );
$wp_config_vars = array_values( $wp_config_vars );
$wp_config_includes = array_diff( get_included_files(), $wp_cli_original_includes );
$wp_config_includes_array = [];
foreach ( $wp_config_includes as $name => $value ) {
$wp_config_includes_array[] = [
'name' => basename( $value ),
'value' => $value,
'type' => 'includes',
];
}
return array_merge( $wp_config_vars, $wp_config_constants, $wp_config_includes_array );
} | [
"private",
"static",
"function",
"get_wp_config_vars",
"(",
")",
"{",
"$",
"wp_cli_original_defined_constants",
"=",
"get_defined_constants",
"(",
")",
";",
"$",
"wp_cli_original_defined_vars",
"=",
"get_defined_vars",
"(",
")",
";",
"$",
"wp_cli_original_includes",
"="... | Get the array of wp-config.php constants and variables.
@return array | [
"Get",
"the",
"array",
"of",
"wp",
"-",
"config",
".",
"php",
"constants",
"and",
"variables",
"."
] | b7e69946e4ec711d4568d11d2b7e08f5e872567d | https://github.com/wp-cli/config-command/blob/b7e69946e4ec711d4568d11d2b7e08f5e872567d/src/Config_Command.php#L359-L391 | train |
wp-cli/config-command | src/Config_Command.php | Config_Command.set | public function set( $args, $assoc_args ) {
$path = $this->get_config_path();
list( $name, $value ) = $args;
$type = Utils\get_flag_value( $assoc_args, 'type' );
$options = array();
$option_flags = array(
'raw' => false,
'add' => true,
'anchor' => null,
'placement' => null,
'separator' => null,
);
foreach ( $option_flags as $option => $default ) {
$option_value = Utils\get_flag_value( $assoc_args, $option, $default );
if ( null !== $option_value ) {
$options[ $option ] = $option_value;
if ( 'separator' === $option ) {
$options['separator'] = $this->parse_separator( $options['separator'] );
}
}
}
$adding = false;
try {
$config_transformer = new WPConfigTransformer( $path );
switch ( $type ) {
case 'all':
$has_constant = $config_transformer->exists( 'constant', $name );
$has_variable = $config_transformer->exists( 'variable', $name );
if ( $has_constant && $has_variable ) {
WP_CLI::error( "Found both a constant and a variable '{$name}' in the 'wp-config.php' file. Use --type=<type> to disambiguate." );
}
if ( ! $has_constant && ! $has_variable ) {
if ( ! $options['add'] ) {
$message = "The constant or variable '{$name}' is not defined in the 'wp-config.php' file.";
WP_CLI::error( $message );
}
$type = 'constant';
$adding = true;
} else {
$type = $has_constant ? 'constant' : 'variable';
}
break;
case 'constant':
case 'variable':
if ( ! $config_transformer->exists( $type, $name ) ) {
if ( ! $options['add'] ) {
WP_CLI::error( "The {$type} '{$name}' is not defined in the 'wp-config.php' file." );
}
$adding = true;
}
}
$config_transformer->update( $type, $name, $value, $options );
} catch ( Exception $exception ) {
WP_CLI::error( "Could not process the 'wp-config.php' transformation.\nReason: {$exception->getMessage()}" );
}
$raw = $options['raw'] ? 'raw ' : '';
if ( $adding ) {
$message = "Added the {$type} '{$name}' to the 'wp-config.php' file with the {$raw}value '{$value}'.";
} else {
$message = "Updated the {$type} '{$name}' in the 'wp-config.php' file with the {$raw}value '{$value}'.";
}
WP_CLI::success( $message );
} | php | public function set( $args, $assoc_args ) {
$path = $this->get_config_path();
list( $name, $value ) = $args;
$type = Utils\get_flag_value( $assoc_args, 'type' );
$options = array();
$option_flags = array(
'raw' => false,
'add' => true,
'anchor' => null,
'placement' => null,
'separator' => null,
);
foreach ( $option_flags as $option => $default ) {
$option_value = Utils\get_flag_value( $assoc_args, $option, $default );
if ( null !== $option_value ) {
$options[ $option ] = $option_value;
if ( 'separator' === $option ) {
$options['separator'] = $this->parse_separator( $options['separator'] );
}
}
}
$adding = false;
try {
$config_transformer = new WPConfigTransformer( $path );
switch ( $type ) {
case 'all':
$has_constant = $config_transformer->exists( 'constant', $name );
$has_variable = $config_transformer->exists( 'variable', $name );
if ( $has_constant && $has_variable ) {
WP_CLI::error( "Found both a constant and a variable '{$name}' in the 'wp-config.php' file. Use --type=<type> to disambiguate." );
}
if ( ! $has_constant && ! $has_variable ) {
if ( ! $options['add'] ) {
$message = "The constant or variable '{$name}' is not defined in the 'wp-config.php' file.";
WP_CLI::error( $message );
}
$type = 'constant';
$adding = true;
} else {
$type = $has_constant ? 'constant' : 'variable';
}
break;
case 'constant':
case 'variable':
if ( ! $config_transformer->exists( $type, $name ) ) {
if ( ! $options['add'] ) {
WP_CLI::error( "The {$type} '{$name}' is not defined in the 'wp-config.php' file." );
}
$adding = true;
}
}
$config_transformer->update( $type, $name, $value, $options );
} catch ( Exception $exception ) {
WP_CLI::error( "Could not process the 'wp-config.php' transformation.\nReason: {$exception->getMessage()}" );
}
$raw = $options['raw'] ? 'raw ' : '';
if ( $adding ) {
$message = "Added the {$type} '{$name}' to the 'wp-config.php' file with the {$raw}value '{$value}'.";
} else {
$message = "Updated the {$type} '{$name}' in the 'wp-config.php' file with the {$raw}value '{$value}'.";
}
WP_CLI::success( $message );
} | [
"public",
"function",
"set",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"get_config_path",
"(",
")",
";",
"list",
"(",
"$",
"name",
",",
"$",
"value",
")",
"=",
"$",
"args",
";",
"$",
"type",
"=",
"... | Sets the value of a specific constant or variable defined in wp-config.php file.
## OPTIONS
<name>
: Name of the wp-config.php constant or variable.
<value>
: Value to set the wp-config.php constant or variable to.
[--add]
: Add the value if it doesn't exist yet.
This is the default behavior, override with --no-add.
[--raw]
: Place the value into the wp-config.php file as is, instead of as a quoted string.
[--anchor=<anchor>]
: Anchor string where additions of new values are anchored around.
Defaults to "/* That's all, stop editing!".
[--placement=<placement>]
: Where to place the new values in relation to the anchor string.
---
default: 'before'
options:
- before
- after
---
[--separator=<separator>]
: Separator string to put between an added value and its anchor string.
The following escape sequences will be recognized and properly interpreted: '\n' => newline, '\r' => carriage return, '\t' => tab.
Defaults to a single EOL ("\n" on *nix and "\r\n" on Windows).
[--type=<type>]
: Type of the config value to set. Defaults to 'all'.
---
default: all
options:
- constant
- variable
- all
---
## EXAMPLES
# Set the WP_DEBUG constant to true.
$ wp config set WP_DEBUG true --raw
@when before_wp_load | [
"Sets",
"the",
"value",
"of",
"a",
"specific",
"constant",
"or",
"variable",
"defined",
"in",
"wp",
"-",
"config",
".",
"php",
"file",
"."
] | b7e69946e4ec711d4568d11d2b7e08f5e872567d | https://github.com/wp-cli/config-command/blob/b7e69946e4ec711d4568d11d2b7e08f5e872567d/src/Config_Command.php#L446-L518 | train |
wp-cli/config-command | src/Config_Command.php | Config_Command.delete | public function delete( $args, $assoc_args ) {
$path = $this->get_config_path();
list( $name ) = $args;
$type = Utils\get_flag_value( $assoc_args, 'type' );
try {
$config_transformer = new WPConfigTransformer( $path );
switch ( $type ) {
case 'all':
$has_constant = $config_transformer->exists( 'constant', $name );
$has_variable = $config_transformer->exists( 'variable', $name );
if ( $has_constant && $has_variable ) {
WP_CLI::error( "Found both a constant and a variable '{$name}' in the 'wp-config.php' file. Use --type=<type> to disambiguate." );
}
if ( ! $has_constant && ! $has_variable ) {
WP_CLI::error( "The constant or variable '{$name}' is not defined in the 'wp-config.php' file." );
} else {
$type = $has_constant ? 'constant' : 'variable';
}
break;
case 'constant':
case 'variable':
if ( ! $config_transformer->exists( $type, $name ) ) {
WP_CLI::error( "The {$type} '{$name}' is not defined in the 'wp-config.php' file." );
}
}
$config_transformer->remove( $type, $name );
} catch ( Exception $exception ) {
WP_CLI::error( "Could not process the 'wp-config.php' transformation.\nReason: {$exception->getMessage()}" );
}
WP_CLI::success( "Deleted the {$type} '{$name}' from the 'wp-config.php' file." );
} | php | public function delete( $args, $assoc_args ) {
$path = $this->get_config_path();
list( $name ) = $args;
$type = Utils\get_flag_value( $assoc_args, 'type' );
try {
$config_transformer = new WPConfigTransformer( $path );
switch ( $type ) {
case 'all':
$has_constant = $config_transformer->exists( 'constant', $name );
$has_variable = $config_transformer->exists( 'variable', $name );
if ( $has_constant && $has_variable ) {
WP_CLI::error( "Found both a constant and a variable '{$name}' in the 'wp-config.php' file. Use --type=<type> to disambiguate." );
}
if ( ! $has_constant && ! $has_variable ) {
WP_CLI::error( "The constant or variable '{$name}' is not defined in the 'wp-config.php' file." );
} else {
$type = $has_constant ? 'constant' : 'variable';
}
break;
case 'constant':
case 'variable':
if ( ! $config_transformer->exists( $type, $name ) ) {
WP_CLI::error( "The {$type} '{$name}' is not defined in the 'wp-config.php' file." );
}
}
$config_transformer->remove( $type, $name );
} catch ( Exception $exception ) {
WP_CLI::error( "Could not process the 'wp-config.php' transformation.\nReason: {$exception->getMessage()}" );
}
WP_CLI::success( "Deleted the {$type} '{$name}' from the 'wp-config.php' file." );
} | [
"public",
"function",
"delete",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"get_config_path",
"(",
")",
";",
"list",
"(",
"$",
"name",
")",
"=",
"$",
"args",
";",
"$",
"type",
"=",
"Utils",
"\\",
"get... | Deletes a specific constant or variable from the wp-config.php file.
## OPTIONS
<name>
: Name of the wp-config.php constant or variable.
[--type=<type>]
: Type of the config value to delete. Defaults to 'all'.
---
default: all
options:
- constant
- variable
- all
---
## EXAMPLES
# Delete the COOKIE_DOMAIN constant from the wp-config.php file.
$ wp config delete COOKIE_DOMAIN
@when before_wp_load | [
"Deletes",
"a",
"specific",
"constant",
"or",
"variable",
"from",
"the",
"wp",
"-",
"config",
".",
"php",
"file",
"."
] | b7e69946e4ec711d4568d11d2b7e08f5e872567d | https://github.com/wp-cli/config-command/blob/b7e69946e4ec711d4568d11d2b7e08f5e872567d/src/Config_Command.php#L545-L581 | train |
wp-cli/config-command | src/Config_Command.php | Config_Command.has | public function has( $args, $assoc_args ) {
$path = $this->get_config_path();
list( $name ) = $args;
$type = Utils\get_flag_value( $assoc_args, 'type' );
try {
$config_transformer = new WPConfigTransformer( $path );
switch ( $type ) {
case 'all':
$has_constant = $config_transformer->exists( 'constant', $name );
$has_variable = $config_transformer->exists( 'variable', $name );
if ( $has_constant && $has_variable ) {
WP_CLI::error( "Found both a constant and a variable '{$name}' in the 'wp-config.php' file. Use --type=<type> to disambiguate." );
}
if ( ! $has_constant && ! $has_variable ) {
WP_CLI::halt( 1 );
} else {
WP_CLI::halt( 0 );
}
break;
case 'constant':
case 'variable':
if ( ! $config_transformer->exists( $type, $name ) ) {
WP_CLI::halt( 1 );
}
WP_CLI::halt( 0 );
}
} catch ( Exception $exception ) {
WP_CLI::error( "Could not process the 'wp-config.php' transformation.\nReason: {$exception->getMessage()}" );
}
} | php | public function has( $args, $assoc_args ) {
$path = $this->get_config_path();
list( $name ) = $args;
$type = Utils\get_flag_value( $assoc_args, 'type' );
try {
$config_transformer = new WPConfigTransformer( $path );
switch ( $type ) {
case 'all':
$has_constant = $config_transformer->exists( 'constant', $name );
$has_variable = $config_transformer->exists( 'variable', $name );
if ( $has_constant && $has_variable ) {
WP_CLI::error( "Found both a constant and a variable '{$name}' in the 'wp-config.php' file. Use --type=<type> to disambiguate." );
}
if ( ! $has_constant && ! $has_variable ) {
WP_CLI::halt( 1 );
} else {
WP_CLI::halt( 0 );
}
break;
case 'constant':
case 'variable':
if ( ! $config_transformer->exists( $type, $name ) ) {
WP_CLI::halt( 1 );
}
WP_CLI::halt( 0 );
}
} catch ( Exception $exception ) {
WP_CLI::error( "Could not process the 'wp-config.php' transformation.\nReason: {$exception->getMessage()}" );
}
} | [
"public",
"function",
"has",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"get_config_path",
"(",
")",
";",
"list",
"(",
"$",
"name",
")",
"=",
"$",
"args",
";",
"$",
"type",
"=",
"Utils",
"\\",
"get_fl... | Checks whether a specific constant or variable exists in the wp-config.php file.
## OPTIONS
<name>
: Name of the wp-config.php constant or variable.
[--type=<type>]
: Type of the config value to set. Defaults to 'all'.
---
default: all
options:
- constant
- variable
- all
---
## EXAMPLES
# Check whether the DB_PASSWORD constant exists in the wp-config.php file.
$ wp config has DB_PASSWORD
@when before_wp_load | [
"Checks",
"whether",
"a",
"specific",
"constant",
"or",
"variable",
"exists",
"in",
"the",
"wp",
"-",
"config",
".",
"php",
"file",
"."
] | b7e69946e4ec711d4568d11d2b7e08f5e872567d | https://github.com/wp-cli/config-command/blob/b7e69946e4ec711d4568d11d2b7e08f5e872567d/src/Config_Command.php#L608-L640 | train |
wp-cli/config-command | src/Config_Command.php | Config_Command.shuffle_salts | public function shuffle_salts( $args, $assoc_args ) {
$constant_list = array(
'AUTH_KEY',
'SECURE_AUTH_KEY',
'LOGGED_IN_KEY',
'NONCE_KEY',
'AUTH_SALT',
'SECURE_AUTH_SALT',
'LOGGED_IN_SALT',
'NONCE_SALT',
);
try {
foreach ( $constant_list as $key ) {
$secret_keys[ $key ] = trim( self::unique_key() );
}
} catch ( Exception $ex ) {
$remote_salts = self::read_( 'https://api.wordpress.org/secret-key/1.1/salt/' );
$remote_salts = explode( "\n", $remote_salts );
foreach ( $remote_salts as $k => $salt ) {
if ( ! empty( $salt ) ) {
$key = $constant_list[ $k ];
$secret_keys[ $key ] = trim( substr( $salt, 28, 64 ) );
}
}
}
$path = $this->get_config_path();
try {
$config_transformer = new WPConfigTransformer( $path );
foreach ( $secret_keys as $constant => $key ) {
$config_transformer->update( 'constant', $constant, (string) $key );
}
} catch ( Exception $exception ) {
WP_CLI::error( "Could not process the 'wp-config.php' transformation.\nReason: {$exception->getMessage()}" );
}
WP_CLI::success( 'Shuffled the salt keys.' );
} | php | public function shuffle_salts( $args, $assoc_args ) {
$constant_list = array(
'AUTH_KEY',
'SECURE_AUTH_KEY',
'LOGGED_IN_KEY',
'NONCE_KEY',
'AUTH_SALT',
'SECURE_AUTH_SALT',
'LOGGED_IN_SALT',
'NONCE_SALT',
);
try {
foreach ( $constant_list as $key ) {
$secret_keys[ $key ] = trim( self::unique_key() );
}
} catch ( Exception $ex ) {
$remote_salts = self::read_( 'https://api.wordpress.org/secret-key/1.1/salt/' );
$remote_salts = explode( "\n", $remote_salts );
foreach ( $remote_salts as $k => $salt ) {
if ( ! empty( $salt ) ) {
$key = $constant_list[ $k ];
$secret_keys[ $key ] = trim( substr( $salt, 28, 64 ) );
}
}
}
$path = $this->get_config_path();
try {
$config_transformer = new WPConfigTransformer( $path );
foreach ( $secret_keys as $constant => $key ) {
$config_transformer->update( 'constant', $constant, (string) $key );
}
} catch ( Exception $exception ) {
WP_CLI::error( "Could not process the 'wp-config.php' transformation.\nReason: {$exception->getMessage()}" );
}
WP_CLI::success( 'Shuffled the salt keys.' );
} | [
"public",
"function",
"shuffle_salts",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"$",
"constant_list",
"=",
"array",
"(",
"'AUTH_KEY'",
",",
"'SECURE_AUTH_KEY'",
",",
"'LOGGED_IN_KEY'",
",",
"'NONCE_KEY'",
",",
"'AUTH_SALT'",
",",
"'SECURE_AUTH_SALT'",
... | Refreshes the salts defined in the wp-config.php file.
## OPTIONS
## EXAMPLES
# Get new salts for your wp-config.php file
$ wp config shuffle-salts
Success: Shuffled the salt keys.
@subcommand shuffle-salts
@when before_wp_load | [
"Refreshes",
"the",
"salts",
"defined",
"in",
"the",
"wp",
"-",
"config",
".",
"php",
"file",
"."
] | b7e69946e4ec711d4568d11d2b7e08f5e872567d | https://github.com/wp-cli/config-command/blob/b7e69946e4ec711d4568d11d2b7e08f5e872567d/src/Config_Command.php#L656-L698 | train |
wp-cli/config-command | src/Config_Command.php | Config_Command.get_wp_config_diff | private static function get_wp_config_diff( $list, $previous_list, $type, $exclude_list = array() ) {
$result = array();
foreach ( $list as $name => $val ) {
if ( array_key_exists( $name, $previous_list ) || in_array( $name, $exclude_list, true ) ) {
continue;
}
$out = [];
$out['name'] = $name;
$out['value'] = $val;
$out['type'] = $type;
$result[] = $out;
}
return $result;
} | php | private static function get_wp_config_diff( $list, $previous_list, $type, $exclude_list = array() ) {
$result = array();
foreach ( $list as $name => $val ) {
if ( array_key_exists( $name, $previous_list ) || in_array( $name, $exclude_list, true ) ) {
continue;
}
$out = [];
$out['name'] = $name;
$out['value'] = $val;
$out['type'] = $type;
$result[] = $out;
}
return $result;
} | [
"private",
"static",
"function",
"get_wp_config_diff",
"(",
"$",
"list",
",",
"$",
"previous_list",
",",
"$",
"type",
",",
"$",
"exclude_list",
"=",
"array",
"(",
")",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"list",
... | Filters wp-config.php file configurations.
@param array $list
@param array $previous_list
@param string $type
@param array $exclude_list
@return array | [
"Filters",
"wp",
"-",
"config",
".",
"php",
"file",
"configurations",
"."
] | b7e69946e4ec711d4568d11d2b7e08f5e872567d | https://github.com/wp-cli/config-command/blob/b7e69946e4ec711d4568d11d2b7e08f5e872567d/src/Config_Command.php#L709-L722 | train |
wp-cli/config-command | src/Config_Command.php | Config_Command.return_value | private function return_value( $name, $type, $values ) {
$results = array();
foreach ( $values as $value ) {
if ( $name === $value['name'] && ( 'all' === $type || $type === $value['type'] ) ) {
$results[] = $value;
}
}
if ( count( $results ) > 1 ) {
WP_CLI::error( "Found both a constant and a variable '{$name}' in the 'wp-config.php' file. Use --type=<type> to disambiguate." );
}
if ( ! empty( $results ) ) {
return $results[0]['value'];
}
$type = 'all' === $type ? 'constant or variable' : $type;
$names = array_column( $values, 'name' );
$candidate = Utils\get_suggestion( $name, $names );
if ( ! empty( $candidate ) && $candidate !== $name ) {
WP_CLI::error( "The {$type} '{$name}' is not defined in the 'wp-config.php' file.\nDid you mean '{$candidate}'?" );
}
WP_CLI::error( "The {$type} '{$name}' is not defined in the 'wp-config.php' file." );
} | php | private function return_value( $name, $type, $values ) {
$results = array();
foreach ( $values as $value ) {
if ( $name === $value['name'] && ( 'all' === $type || $type === $value['type'] ) ) {
$results[] = $value;
}
}
if ( count( $results ) > 1 ) {
WP_CLI::error( "Found both a constant and a variable '{$name}' in the 'wp-config.php' file. Use --type=<type> to disambiguate." );
}
if ( ! empty( $results ) ) {
return $results[0]['value'];
}
$type = 'all' === $type ? 'constant or variable' : $type;
$names = array_column( $values, 'name' );
$candidate = Utils\get_suggestion( $name, $names );
if ( ! empty( $candidate ) && $candidate !== $name ) {
WP_CLI::error( "The {$type} '{$name}' is not defined in the 'wp-config.php' file.\nDid you mean '{$candidate}'?" );
}
WP_CLI::error( "The {$type} '{$name}' is not defined in the 'wp-config.php' file." );
} | [
"private",
"function",
"return_value",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"values",
")",
"{",
"$",
"results",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"$",... | Prints the value of a constant or variable defined in the wp-config.php file.
If the constant or variable is not defined in the wp-config.php file then an error will be returned.
@param string $name
@param string $type
@param array $values
@return string The value of the requested constant or variable as defined in the wp-config.php file; if the
requested constant or variable is not defined then the function will print an error and exit. | [
"Prints",
"the",
"value",
"of",
"a",
"constant",
"or",
"variable",
"defined",
"in",
"the",
"wp",
"-",
"config",
".",
"php",
"file",
"."
] | b7e69946e4ec711d4568d11d2b7e08f5e872567d | https://github.com/wp-cli/config-command/blob/b7e69946e4ec711d4568d11d2b7e08f5e872567d/src/Config_Command.php#L746-L771 | train |
wp-cli/config-command | src/Config_Command.php | Config_Command.filter_values | private function filter_values( $values, $filters, $strict ) {
$result = array();
foreach ( $values as $value ) {
foreach ( $filters as $filter ) {
if ( $strict && $filter !== $value['name'] ) {
continue;
}
if ( false === strpos( $value['name'], $filter ) ) {
continue;
}
$result[] = $value;
}
}
return $result;
} | php | private function filter_values( $values, $filters, $strict ) {
$result = array();
foreach ( $values as $value ) {
foreach ( $filters as $filter ) {
if ( $strict && $filter !== $value['name'] ) {
continue;
}
if ( false === strpos( $value['name'], $filter ) ) {
continue;
}
$result[] = $value;
}
}
return $result;
} | [
"private",
"function",
"filter_values",
"(",
"$",
"values",
",",
"$",
"filters",
",",
"$",
"strict",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"filters",
... | Filters the values based on a provider filter key.
@param array $values
@param array $filters
@param bool $strict
@return array | [
"Filters",
"the",
"values",
"based",
"on",
"a",
"provider",
"filter",
"key",
"."
] | b7e69946e4ec711d4568d11d2b7e08f5e872567d | https://github.com/wp-cli/config-command/blob/b7e69946e4ec711d4568d11d2b7e08f5e872567d/src/Config_Command.php#L805-L823 | train |
ezsystems/ezpublish-legacy | lib/ezfile/classes/ezdir.php | eZDir.recursiveDelete | static function recursiveDelete( $dir, $rootCheck = true )
{
// RecursiveDelete fails if ...
// $dir is not a directory
if ( !is_dir( $dir ) )
{
eZDebug::writeError( "The path: $dir is not a folder" , __METHOD__ );
return false;
}
if ( $rootCheck )
{
// rootCheck is enabled, check if $dir is part of authorized directories
$allowedDirs = eZINI::instance()->variable( 'FileSettings', 'AllowedDeletionDirs' );
// Also adding eZ Publish root dir.
$rootDir = eZSys::rootDir() . DIRECTORY_SEPARATOR;
array_unshift( $allowedDirs, $rootDir );
$dirRealPath = dirname( realpath( $dir ) ) . DIRECTORY_SEPARATOR;
$canDelete = false;
foreach ( $allowedDirs as $allowedDir )
{
if ( strpos( $dirRealPath, realpath( $allowedDir ) ) === 0 )
{
$canDelete = true;
break;
}
}
if ( !$canDelete )
{
eZDebug::writeError(
"Recursive delete denied for '$dir' as its realpath '$dirRealPath' is outside eZ Publish root and not registered in AllowedDeletionDirs."
);
return false;
}
}
// the directory cannot be opened
if ( ! ( $handle = @opendir( $dir ) ) )
{
eZDebug::writeError( "Cannot access folder:". dirname( $dir) , __METHOD__ );
return false;
}
while ( ( $file = readdir( $handle ) ) !== false )
{
if ( ( $file == "." ) || ( $file == ".." ) )
{
continue;
}
if ( is_dir( $dir . '/' . $file ) )
{
eZDir::recursiveDelete( $dir . '/' . $file, false );
}
else
{
unlink( $dir . '/' . $file );
}
}
@closedir( $handle );
return rmdir( $dir );
} | php | static function recursiveDelete( $dir, $rootCheck = true )
{
// RecursiveDelete fails if ...
// $dir is not a directory
if ( !is_dir( $dir ) )
{
eZDebug::writeError( "The path: $dir is not a folder" , __METHOD__ );
return false;
}
if ( $rootCheck )
{
// rootCheck is enabled, check if $dir is part of authorized directories
$allowedDirs = eZINI::instance()->variable( 'FileSettings', 'AllowedDeletionDirs' );
// Also adding eZ Publish root dir.
$rootDir = eZSys::rootDir() . DIRECTORY_SEPARATOR;
array_unshift( $allowedDirs, $rootDir );
$dirRealPath = dirname( realpath( $dir ) ) . DIRECTORY_SEPARATOR;
$canDelete = false;
foreach ( $allowedDirs as $allowedDir )
{
if ( strpos( $dirRealPath, realpath( $allowedDir ) ) === 0 )
{
$canDelete = true;
break;
}
}
if ( !$canDelete )
{
eZDebug::writeError(
"Recursive delete denied for '$dir' as its realpath '$dirRealPath' is outside eZ Publish root and not registered in AllowedDeletionDirs."
);
return false;
}
}
// the directory cannot be opened
if ( ! ( $handle = @opendir( $dir ) ) )
{
eZDebug::writeError( "Cannot access folder:". dirname( $dir) , __METHOD__ );
return false;
}
while ( ( $file = readdir( $handle ) ) !== false )
{
if ( ( $file == "." ) || ( $file == ".." ) )
{
continue;
}
if ( is_dir( $dir . '/' . $file ) )
{
eZDir::recursiveDelete( $dir . '/' . $file, false );
}
else
{
unlink( $dir . '/' . $file );
}
}
@closedir( $handle );
return rmdir( $dir );
} | [
"static",
"function",
"recursiveDelete",
"(",
"$",
"dir",
",",
"$",
"rootCheck",
"=",
"true",
")",
"{",
"// RecursiveDelete fails if ...",
"// $dir is not a directory",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"eZDebug",
"::",
"writeError",
"(... | Removes a directory and all it's contents, recursively.
@param string $dir Directory to remove
@param bool $rootCheck Check whether $dir is supposed to be contained in
eZ Publish root directory
@return bool True if the operation succeeded, false otherwise | [
"Removes",
"a",
"directory",
"and",
"all",
"it",
"s",
"contents",
"recursively",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezfile/classes/ezdir.php#L264-L326 | train |
ezsystems/ezpublish-legacy | lib/ezdb/classes/ezmysqlidb.php | eZMySQLiDB.setError | function setError( $connection = false )
{
if ( $this->IsConnected )
{
if ( $connection === false )
$connection = $this->DBConnection;
if ( $connection instanceof MySQLi )
{
$this->ErrorMessage = mysqli_error( $connection );
$this->ErrorNumber = mysqli_errno( $connection );
}
}
else
{
$this->ErrorMessage = mysqli_connect_error();
$this->ErrorNumber = mysqli_connect_errno();
}
} | php | function setError( $connection = false )
{
if ( $this->IsConnected )
{
if ( $connection === false )
$connection = $this->DBConnection;
if ( $connection instanceof MySQLi )
{
$this->ErrorMessage = mysqli_error( $connection );
$this->ErrorNumber = mysqli_errno( $connection );
}
}
else
{
$this->ErrorMessage = mysqli_connect_error();
$this->ErrorNumber = mysqli_connect_errno();
}
} | [
"function",
"setError",
"(",
"$",
"connection",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"IsConnected",
")",
"{",
"if",
"(",
"$",
"connection",
"===",
"false",
")",
"$",
"connection",
"=",
"$",
"this",
"->",
"DBConnection",
";",
"if",
"(... | Sets the internal error messages & number
@param MySQLi $connection database connection handle, overrides the current one if given | [
"Sets",
"the",
"internal",
"error",
"messages",
"&",
"number"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezdb/classes/ezmysqlidb.php#L883-L901 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentobjecttrashnode.php | eZContentObjectTrashNode.createFromNode | static function createFromNode( $node )
{
$row = array( 'node_id' => $node->attribute( 'node_id' ),
'parent_node_id' => $node->attribute( 'parent_node_id' ),
'main_node_id' => $node->attribute( 'main_node_id' ),
'contentobject_id' => $node->attribute( 'contentobject_id' ),
'contentobject_version' => $node->attribute( 'contentobject_version' ),
'contentobject_is_published' => $node->attribute( 'contentobject_is_published' ),
'depth' => $node->attribute( 'depth' ),
'sort_field' => $node->attribute( 'sort_field' ),
'sort_order' => $node->attribute( 'sort_order' ),
'priority' => $node->attribute( 'priority' ),
'modified_subnode' => $node->attribute( 'modified_subnode' ),
'path_string' => $node->attribute( 'path_string' ),
'path_identification_string' => $node->attribute( 'path_identification_string' ),
'remote_id' => $node->attribute( 'remote_id' ),
'is_hidden' => $node->attribute( 'is_hidden' ),
'is_invisible' => $node->attribute( 'is_invisible' ),
'trashed' => time() );
$trashNode = new eZContentObjectTrashNode( $row );
return $trashNode;
} | php | static function createFromNode( $node )
{
$row = array( 'node_id' => $node->attribute( 'node_id' ),
'parent_node_id' => $node->attribute( 'parent_node_id' ),
'main_node_id' => $node->attribute( 'main_node_id' ),
'contentobject_id' => $node->attribute( 'contentobject_id' ),
'contentobject_version' => $node->attribute( 'contentobject_version' ),
'contentobject_is_published' => $node->attribute( 'contentobject_is_published' ),
'depth' => $node->attribute( 'depth' ),
'sort_field' => $node->attribute( 'sort_field' ),
'sort_order' => $node->attribute( 'sort_order' ),
'priority' => $node->attribute( 'priority' ),
'modified_subnode' => $node->attribute( 'modified_subnode' ),
'path_string' => $node->attribute( 'path_string' ),
'path_identification_string' => $node->attribute( 'path_identification_string' ),
'remote_id' => $node->attribute( 'remote_id' ),
'is_hidden' => $node->attribute( 'is_hidden' ),
'is_invisible' => $node->attribute( 'is_invisible' ),
'trashed' => time() );
$trashNode = new eZContentObjectTrashNode( $row );
return $trashNode;
} | [
"static",
"function",
"createFromNode",
"(",
"$",
"node",
")",
"{",
"$",
"row",
"=",
"array",
"(",
"'node_id'",
"=>",
"$",
"node",
"->",
"attribute",
"(",
"'node_id'",
")",
",",
"'parent_node_id'",
"=>",
"$",
"node",
"->",
"attribute",
"(",
"'parent_node_i... | Creates a new eZContentObjectTrashNode based on an eZContentObjectTreeNode
@param eZContentObjectTreeNode $node
@return eZContentObjectTrashNode | [
"Creates",
"a",
"new",
"eZContentObjectTrashNode",
"based",
"on",
"an",
"eZContentObjectTreeNode"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentobjecttrashnode.php#L120-L142 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentobjecttrashnode.php | eZContentObjectTrashNode.storeToTrash | function storeToTrash()
{
$this->store();
$db = eZDB::instance();
$db->begin();
/** @var eZContentObject $contentObject */
$contentObject = $this->attribute( 'object' );
$offset = 0;
$limit = 20;
while (
$contentobjectAttributes = $contentObject->allContentObjectAttributes(
$contentObject->attribute( 'id' ), true,
array( 'limit' => $limit, 'offset' => $offset )
)
)
{
foreach ( $contentobjectAttributes as $contentobjectAttribute )
{
$dataType = $contentobjectAttribute->dataType();
if ( !$dataType )
continue;
$dataType->trashStoredObjectAttribute( $contentobjectAttribute );
}
$offset += $limit;
}
$db->commit();
} | php | function storeToTrash()
{
$this->store();
$db = eZDB::instance();
$db->begin();
/** @var eZContentObject $contentObject */
$contentObject = $this->attribute( 'object' );
$offset = 0;
$limit = 20;
while (
$contentobjectAttributes = $contentObject->allContentObjectAttributes(
$contentObject->attribute( 'id' ), true,
array( 'limit' => $limit, 'offset' => $offset )
)
)
{
foreach ( $contentobjectAttributes as $contentobjectAttribute )
{
$dataType = $contentobjectAttribute->dataType();
if ( !$dataType )
continue;
$dataType->trashStoredObjectAttribute( $contentobjectAttribute );
}
$offset += $limit;
}
$db->commit();
} | [
"function",
"storeToTrash",
"(",
")",
"{",
"$",
"this",
"->",
"store",
"(",
")",
";",
"$",
"db",
"=",
"eZDB",
"::",
"instance",
"(",
")",
";",
"$",
"db",
"->",
"begin",
"(",
")",
";",
"/** @var eZContentObject $contentObject */",
"$",
"contentObject",
"=... | Stores this object to the trash
Loops through all attributes of the object and stores them to the trash
@see eZDataType::trashStoredObjectAttribute() | [
"Stores",
"this",
"object",
"to",
"the",
"trash"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentobjecttrashnode.php#L151-L180 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentobjecttrashnode.php | eZContentObjectTrashNode.purgeForObject | static function purgeForObject( $contentObjectID )
{
if ( !is_numeric( $contentObjectID ) )
return false;
$db = eZDB::instance();
$db->begin();
$db->query( "DELETE FROM ezcontentobject_trash WHERE contentobject_id='$contentObjectID'" );
$db->commit();
} | php | static function purgeForObject( $contentObjectID )
{
if ( !is_numeric( $contentObjectID ) )
return false;
$db = eZDB::instance();
$db->begin();
$db->query( "DELETE FROM ezcontentobject_trash WHERE contentobject_id='$contentObjectID'" );
$db->commit();
} | [
"static",
"function",
"purgeForObject",
"(",
"$",
"contentObjectID",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"contentObjectID",
")",
")",
"return",
"false",
";",
"$",
"db",
"=",
"eZDB",
"::",
"instance",
"(",
")",
";",
"$",
"db",
"->",
"begin... | Purges an object from the trash, effectively deleting it from the database
@param int $contentObjectID
@return bool | [
"Purges",
"an",
"object",
"from",
"the",
"trash",
"effectively",
"deleting",
"it",
"from",
"the",
"database"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentobjecttrashnode.php#L188-L196 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentobjecttrashnode.php | eZContentObjectTrashNode.originalParentPathIdentificationString | function originalParentPathIdentificationString()
{
$originalParent = $this->originalParent();
if ( $originalParent )
{
return $originalParent->attribute( 'path_identification_string' );
}
// original parent was moved or does not exist, return original parent path
$path = $this->attribute( 'path_identification_string' );
$path = substr( $path, 0, strrpos( $path, '/') );
return $path;
} | php | function originalParentPathIdentificationString()
{
$originalParent = $this->originalParent();
if ( $originalParent )
{
return $originalParent->attribute( 'path_identification_string' );
}
// original parent was moved or does not exist, return original parent path
$path = $this->attribute( 'path_identification_string' );
$path = substr( $path, 0, strrpos( $path, '/') );
return $path;
} | [
"function",
"originalParentPathIdentificationString",
"(",
")",
"{",
"$",
"originalParent",
"=",
"$",
"this",
"->",
"originalParent",
"(",
")",
";",
"if",
"(",
"$",
"originalParent",
")",
"{",
"return",
"$",
"originalParent",
"->",
"attribute",
"(",
"'path_ident... | Returns the path identification string of the node's parent, if available. Otherwise returns
the node's path identification string
@see originalParent()
@return string | [
"Returns",
"the",
"path",
"identification",
"string",
"of",
"the",
"node",
"s",
"parent",
"if",
"available",
".",
"Otherwise",
"returns",
"the",
"node",
"s",
"path",
"identification",
"string"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentobjecttrashnode.php#L365-L376 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentobjecttrashnode.php | eZContentObjectTrashNode.fetchByContentObjectID | public static function fetchByContentObjectID( $contentObjectID, $asObject = true, $contentObjectVersion = false )
{
$conds = array( 'contentobject_id' => $contentObjectID );
if ( $contentObjectVersion !== false )
{
$conds['contentobject_version'] = $contentObjectVersion;
}
return self::fetchObject(
self::definition(),
null,
$conds,
$asObject
);
} | php | public static function fetchByContentObjectID( $contentObjectID, $asObject = true, $contentObjectVersion = false )
{
$conds = array( 'contentobject_id' => $contentObjectID );
if ( $contentObjectVersion !== false )
{
$conds['contentobject_version'] = $contentObjectVersion;
}
return self::fetchObject(
self::definition(),
null,
$conds,
$asObject
);
} | [
"public",
"static",
"function",
"fetchByContentObjectID",
"(",
"$",
"contentObjectID",
",",
"$",
"asObject",
"=",
"true",
",",
"$",
"contentObjectVersion",
"=",
"false",
")",
"{",
"$",
"conds",
"=",
"array",
"(",
"'contentobject_id'",
"=>",
"$",
"contentObjectID... | Fetches a trash node by its content object id
@param int $contentObjectID
@param bool $asObject
@param int|bool $contentObjectVersion
@return eZContentObjectTrashNode|null | [
"Fetches",
"a",
"trash",
"node",
"by",
"its",
"content",
"object",
"id"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentobjecttrashnode.php#L386-L400 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezxmltext/ezxmlinputparser.php | eZXMLInputParser.processBySchemaPresence | function processBySchemaPresence( $element )
{
$parent = $element->parentNode;
if ( $parent instanceof DOMElement )
{
// If this is a foreign element, remove it
if ( !$this->XMLSchema->exists( $element ) )
{
if ( $element->nodeName == 'custom' )
{
$this->handleError( self::ERROR_SCHEMA,
ezpI18n::tr( 'kernel/classes/datatypes/ezxmltext', "Custom tag '%1' is not allowed.",
false, array( $element->getAttribute( 'name' ) ) ) );
}
$element = $parent->removeChild( $element );
return false;
}
// Delete if children required and no children
// If this is an auto-added element, then do not throw error
if ( $element->nodeType == XML_ELEMENT_NODE && ( $this->XMLSchema->childrenRequired( $element ) || $element->getAttribute( 'children_required' ) )
&& !$element->hasChildNodes() )
{
$element = $parent->removeChild( $element );
if ( !$element->getAttributeNS( 'http://ez.no/namespaces/ezpublish3/temporary/', 'new-element' ) )
{
$this->handleError( self::ERROR_SCHEMA, ezpI18n::tr( 'kernel/classes/datatypes/ezxmltext', "<%1> tag can't be empty.",
false, array( $element->nodeName ) ) );
return false;
}
}
}
// TODO: break processing of any node that doesn't have parent
// and is not a root node.
elseif ( $element->nodeName != 'section' )
{
return false;
}
return true;
} | php | function processBySchemaPresence( $element )
{
$parent = $element->parentNode;
if ( $parent instanceof DOMElement )
{
// If this is a foreign element, remove it
if ( !$this->XMLSchema->exists( $element ) )
{
if ( $element->nodeName == 'custom' )
{
$this->handleError( self::ERROR_SCHEMA,
ezpI18n::tr( 'kernel/classes/datatypes/ezxmltext', "Custom tag '%1' is not allowed.",
false, array( $element->getAttribute( 'name' ) ) ) );
}
$element = $parent->removeChild( $element );
return false;
}
// Delete if children required and no children
// If this is an auto-added element, then do not throw error
if ( $element->nodeType == XML_ELEMENT_NODE && ( $this->XMLSchema->childrenRequired( $element ) || $element->getAttribute( 'children_required' ) )
&& !$element->hasChildNodes() )
{
$element = $parent->removeChild( $element );
if ( !$element->getAttributeNS( 'http://ez.no/namespaces/ezpublish3/temporary/', 'new-element' ) )
{
$this->handleError( self::ERROR_SCHEMA, ezpI18n::tr( 'kernel/classes/datatypes/ezxmltext', "<%1> tag can't be empty.",
false, array( $element->nodeName ) ) );
return false;
}
}
}
// TODO: break processing of any node that doesn't have parent
// and is not a root node.
elseif ( $element->nodeName != 'section' )
{
return false;
}
return true;
} | [
"function",
"processBySchemaPresence",
"(",
"$",
"element",
")",
"{",
"$",
"parent",
"=",
"$",
"element",
"->",
"parentNode",
";",
"if",
"(",
"$",
"parent",
"instanceof",
"DOMElement",
")",
"{",
"// If this is a foreign element, remove it",
"if",
"(",
"!",
"$",
... | Check if the element is allowed to exist in this document and remove it if not. | [
"Check",
"if",
"the",
"element",
"is",
"allowed",
"to",
"exist",
"in",
"this",
"document",
"and",
"remove",
"it",
"if",
"not",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezxmltext/ezxmlinputparser.php#L998-L1038 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezxmltext/ezxmlinputparser.php | eZXMLInputParser.processBySchemaTree | function processBySchemaTree( $element )
{
$parent = $element->parentNode;
if ( $parent instanceof DOMElement )
{
$schemaCheckResult = $this->XMLSchema->check( $parent, $element );
if ( !$schemaCheckResult )
{
if ( $schemaCheckResult === false )
{
// Remove indenting spaces
if ( $element->nodeType == XML_TEXT_NODE && !trim( $element->textContent ) )
{
$element = $parent->removeChild( $element );
return false;
}
$elementName = $element->nodeType == XML_ELEMENT_NODE ? '<' . $element->nodeName . '>' : $element->nodeName;
$this->handleError( self::ERROR_SCHEMA, ezpI18n::tr( 'kernel/classes/datatypes/ezxmltext', "%1 is not allowed to be a child of <%2>.",
false, array( $elementName, $parent->nodeName ) ) );
}
$this->fixSubtree( $element, $element );
return false;
}
}
// TODO: break processing of any node that doesn't have parent
// and is not a root node.
elseif ( $element->nodeName != 'section' )
{
return false;
}
return true;
} | php | function processBySchemaTree( $element )
{
$parent = $element->parentNode;
if ( $parent instanceof DOMElement )
{
$schemaCheckResult = $this->XMLSchema->check( $parent, $element );
if ( !$schemaCheckResult )
{
if ( $schemaCheckResult === false )
{
// Remove indenting spaces
if ( $element->nodeType == XML_TEXT_NODE && !trim( $element->textContent ) )
{
$element = $parent->removeChild( $element );
return false;
}
$elementName = $element->nodeType == XML_ELEMENT_NODE ? '<' . $element->nodeName . '>' : $element->nodeName;
$this->handleError( self::ERROR_SCHEMA, ezpI18n::tr( 'kernel/classes/datatypes/ezxmltext', "%1 is not allowed to be a child of <%2>.",
false, array( $elementName, $parent->nodeName ) ) );
}
$this->fixSubtree( $element, $element );
return false;
}
}
// TODO: break processing of any node that doesn't have parent
// and is not a root node.
elseif ( $element->nodeName != 'section' )
{
return false;
}
return true;
} | [
"function",
"processBySchemaTree",
"(",
"$",
"element",
")",
"{",
"$",
"parent",
"=",
"$",
"element",
"->",
"parentNode",
";",
"if",
"(",
"$",
"parent",
"instanceof",
"DOMElement",
")",
"{",
"$",
"schemaCheckResult",
"=",
"$",
"this",
"->",
"XMLSchema",
"-... | Check that element has a correct position in the tree and fix it if not. | [
"Check",
"that",
"element",
"has",
"a",
"correct",
"position",
"in",
"the",
"tree",
"and",
"fix",
"it",
"if",
"not",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezxmltext/ezxmlinputparser.php#L1041-L1074 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezxmltext/ezxmlinputparser.php | eZXMLInputParser.createAndPublishElement | function createAndPublishElement( $elementName, &$ret )
{
$element = $this->Document->createElement( $elementName );
$element->setAttributeNS( 'http://ez.no/namespaces/ezpublish3/temporary/', 'tmp:new-element', 'true' );
if ( !isset( $ret['new_elements'] ) )
{
$ret['new_elements'] = array();
}
$ret['new_elements'][] = $element;
return $element;
} | php | function createAndPublishElement( $elementName, &$ret )
{
$element = $this->Document->createElement( $elementName );
$element->setAttributeNS( 'http://ez.no/namespaces/ezpublish3/temporary/', 'tmp:new-element', 'true' );
if ( !isset( $ret['new_elements'] ) )
{
$ret['new_elements'] = array();
}
$ret['new_elements'][] = $element;
return $element;
} | [
"function",
"createAndPublishElement",
"(",
"$",
"elementName",
",",
"&",
"$",
"ret",
")",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"Document",
"->",
"createElement",
"(",
"$",
"elementName",
")",
";",
"$",
"element",
"->",
"setAttributeNS",
"(",
"'htt... | and call 'structure' and 'publish' handlers) | [
"and",
"call",
"structure",
"and",
"publish",
"handlers",
")"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezxmltext/ezxmlinputparser.php#L1204-L1216 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezhttptool.php | eZHTTPTool.instance | static function instance()
{
if ( !isset( $GLOBALS["eZHTTPToolInstance"] ) ||
!( $GLOBALS["eZHTTPToolInstance"] instanceof eZHTTPTool ) )
{
$GLOBALS["eZHTTPToolInstance"] = new eZHTTPTool();
$GLOBALS["eZHTTPToolInstance"]->createPostVarsFromImageButtons();
}
return $GLOBALS["eZHTTPToolInstance"];
} | php | static function instance()
{
if ( !isset( $GLOBALS["eZHTTPToolInstance"] ) ||
!( $GLOBALS["eZHTTPToolInstance"] instanceof eZHTTPTool ) )
{
$GLOBALS["eZHTTPToolInstance"] = new eZHTTPTool();
$GLOBALS["eZHTTPToolInstance"]->createPostVarsFromImageButtons();
}
return $GLOBALS["eZHTTPToolInstance"];
} | [
"static",
"function",
"instance",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"GLOBALS",
"[",
"\"eZHTTPToolInstance\"",
"]",
")",
"||",
"!",
"(",
"$",
"GLOBALS",
"[",
"\"eZHTTPToolInstance\"",
"]",
"instanceof",
"eZHTTPTool",
")",
")",
"{",
"$",
"G... | Return a unique instance of the eZHTTPTool class
@return eZHTTPTool | [
"Return",
"a",
"unique",
"instance",
"of",
"the",
"eZHTTPTool",
"class"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezhttptool.php#L185-L195 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezhttptool.php | eZHTTPTool.redirect | static function redirect( $path, $parameters = array(), $status = false, $encodeURL = true, $returnRedirectObject = false )
{
$url = eZHTTPTool::createRedirectUrl( $path, $parameters );
if ( strlen( $status ) > 0 )
{
header( $_SERVER['SERVER_PROTOCOL'] . " " . $status );
eZHTTPTool::headerVariable( "Status", $status );
}
if ( $encodeURL )
{
$url = eZURI::encodeURL( $url );
}
eZHTTPTool::headerVariable( 'Location', $url );
/* Fix for redirecting using workflows and apache 2 */
$escapedUrl = htmlspecialchars( $url );
$content = <<<EOT
<HTML><HEAD>
<META HTTP-EQUIV="Refresh" Content="0;URL=$escapedUrl">
<META HTTP-EQUIV="Location" Content="$escapedUrl">
</HEAD><BODY></BODY></HTML>
EOT;
if ( $returnRedirectObject )
{
return new ezpKernelRedirect( $url, $status ?: null, $content );
}
echo $content;
} | php | static function redirect( $path, $parameters = array(), $status = false, $encodeURL = true, $returnRedirectObject = false )
{
$url = eZHTTPTool::createRedirectUrl( $path, $parameters );
if ( strlen( $status ) > 0 )
{
header( $_SERVER['SERVER_PROTOCOL'] . " " . $status );
eZHTTPTool::headerVariable( "Status", $status );
}
if ( $encodeURL )
{
$url = eZURI::encodeURL( $url );
}
eZHTTPTool::headerVariable( 'Location', $url );
/* Fix for redirecting using workflows and apache 2 */
$escapedUrl = htmlspecialchars( $url );
$content = <<<EOT
<HTML><HEAD>
<META HTTP-EQUIV="Refresh" Content="0;URL=$escapedUrl">
<META HTTP-EQUIV="Location" Content="$escapedUrl">
</HEAD><BODY></BODY></HTML>
EOT;
if ( $returnRedirectObject )
{
return new ezpKernelRedirect( $url, $status ?: null, $content );
}
echo $content;
} | [
"static",
"function",
"redirect",
"(",
"$",
"path",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
",",
"$",
"status",
"=",
"false",
",",
"$",
"encodeURL",
"=",
"true",
",",
"$",
"returnRedirectObject",
"=",
"false",
")",
"{",
"$",
"url",
"=",
"eZHT... | Performs an HTTP redirect.
@param string $path The path to redirect to
@param array $parameters See createRedirectUrl(). Defaults to empty array.
@param bool $status The HTTP status code as a string (code + text, e.g. "302 Found"). Defaults to false.
@param bool $encodeURL Encodes the URL.
This should normally be true, but may be set to false to avoid double encoding when redirect() is called twice.
Defaults to true
@param bool $returnRedirectObject If true, will return an ezpKernelRedirect object.
@return null|ezpKernelRedirect | [
"Performs",
"an",
"HTTP",
"redirect",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezhttptool.php#L589-L619 | train |
ezsystems/ezpublish-legacy | lib/eztemplate/classes/eztemplatecacheblock.php | eZTemplateCacheBlock.filterKeys | static private function filterKeys( array &$keys )
{
if ( isset( $GLOBALS['eZRequestError'] ) && $GLOBALS['eZRequestError'] === true )
{
$requestUri = eZSys::requestURI();
foreach ( $keys as $i => &$key )
{
if ( is_array( $key ) )
{
self::filterKeys( $key );
}
else if ( $key === $requestUri )
{
unset( $keys[$i] );
}
}
}
} | php | static private function filterKeys( array &$keys )
{
if ( isset( $GLOBALS['eZRequestError'] ) && $GLOBALS['eZRequestError'] === true )
{
$requestUri = eZSys::requestURI();
foreach ( $keys as $i => &$key )
{
if ( is_array( $key ) )
{
self::filterKeys( $key );
}
else if ( $key === $requestUri )
{
unset( $keys[$i] );
}
}
}
} | [
"static",
"private",
"function",
"filterKeys",
"(",
"array",
"&",
"$",
"keys",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'eZRequestError'",
"]",
")",
"&&",
"$",
"GLOBALS",
"[",
"'eZRequestError'",
"]",
"===",
"true",
")",
"{",
"$",
"requ... | Filters cache keys when needed.
Useful to avoid having current URI as a cache key if an error has occurred and has been caught by error module.
@param array $keys | [
"Filters",
"cache",
"keys",
"when",
"needed",
".",
"Useful",
"to",
"avoid",
"having",
"current",
"URI",
"as",
"a",
"cache",
"key",
"if",
"an",
"error",
"has",
"occurred",
"and",
"has",
"been",
"caught",
"by",
"error",
"module",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/eztemplate/classes/eztemplatecacheblock.php#L65-L82 | train |
ezsystems/ezpublish-legacy | kernel/private/oauth/classes/restauthorizedclient.php | ezpRestAuthorizedClient.fetchForClientUser | public static function fetchForClientUser( ezpRestClient $client, eZUser $user )
{
$session = ezcPersistentSessionInstance::get();
$q = $session->createFindQuery( __CLASS__ );
$q->where( $q->expr->eq( 'rest_client_id', $q->bindValue( $client->id ) ) )
->where( $q->expr->eq( 'user_id', $q->bindValue( $user->attribute( 'contentobject_id' ) ) ) );
$results = $session->find( $q, __CLASS__ );
if ( count( $results ) != 1 )
return false;
else
return array_shift( $results );
} | php | public static function fetchForClientUser( ezpRestClient $client, eZUser $user )
{
$session = ezcPersistentSessionInstance::get();
$q = $session->createFindQuery( __CLASS__ );
$q->where( $q->expr->eq( 'rest_client_id', $q->bindValue( $client->id ) ) )
->where( $q->expr->eq( 'user_id', $q->bindValue( $user->attribute( 'contentobject_id' ) ) ) );
$results = $session->find( $q, __CLASS__ );
if ( count( $results ) != 1 )
return false;
else
return array_shift( $results );
} | [
"public",
"static",
"function",
"fetchForClientUser",
"(",
"ezpRestClient",
"$",
"client",
",",
"eZUser",
"$",
"user",
")",
"{",
"$",
"session",
"=",
"ezcPersistentSessionInstance",
"::",
"get",
"(",
")",
";",
"$",
"q",
"=",
"$",
"session",
"->",
"createFind... | Returns the authorization object for a user & application
@param ezpRestClient $client
@param eZUser $user | [
"Returns",
"the",
"authorization",
"object",
"for",
"a",
"user",
"&",
"application"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/oauth/classes/restauthorizedclient.php#L60-L75 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezworkflowevent.php | eZWorkflowEvent.create | static function create( $workflowID, $typeString )
{
$row = array(
"id" => null,
"version" => 1,
"workflow_id" => $workflowID,
"workflow_type_string" => $typeString,
"description" => "",
"placement" => eZPersistentObject::newObjectOrder( eZWorkflowEvent::definition(),
"placement",
array( "version" => 1,
"workflow_id" => $workflowID ) ) );
return new eZWorkflowEvent( $row );
} | php | static function create( $workflowID, $typeString )
{
$row = array(
"id" => null,
"version" => 1,
"workflow_id" => $workflowID,
"workflow_type_string" => $typeString,
"description" => "",
"placement" => eZPersistentObject::newObjectOrder( eZWorkflowEvent::definition(),
"placement",
array( "version" => 1,
"workflow_id" => $workflowID ) ) );
return new eZWorkflowEvent( $row );
} | [
"static",
"function",
"create",
"(",
"$",
"workflowID",
",",
"$",
"typeString",
")",
"{",
"$",
"row",
"=",
"array",
"(",
"\"id\"",
"=>",
"null",
",",
"\"version\"",
"=>",
"1",
",",
"\"workflow_id\"",
"=>",
"$",
"workflowID",
",",
"\"workflow_type_string\"",
... | Creates a new workflow event
@param int $workflowID
@param string $typeString
@return eZWorkflowEvent | [
"Creates",
"a",
"new",
"workflow",
"event"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezworkflowevent.php#L122-L135 | train |
ezsystems/ezpublish-legacy | kernel/private/classes/ezptopologicalsort.php | ezpTopologicalSort.sort | function sort()
{
$rootNodes = $this->getRootNodes();
$sorted = array();
while ( count( $this->nodes ) > 0 ) {
// check for circular reference
if ( count( $rootNodes ) === 0 )
return false;
// remove this node from rootNodes and add it to the output
$current = array_shift( $rootNodes );
$sorted[] = $current->name;
// for each of its children queue the new node and remove the original
while ( $child = $current->popChild() )
{
$child->unregisterParent( $this->nodes[$current->name] );
// if this child has no more parents, add it to the root nodes list
if ( $child->parentCount() === 0 )
$rootNodes[] = $child;
}
unset( $this->nodes[$current->name] );
}
return $sorted;
} | php | function sort()
{
$rootNodes = $this->getRootNodes();
$sorted = array();
while ( count( $this->nodes ) > 0 ) {
// check for circular reference
if ( count( $rootNodes ) === 0 )
return false;
// remove this node from rootNodes and add it to the output
$current = array_shift( $rootNodes );
$sorted[] = $current->name;
// for each of its children queue the new node and remove the original
while ( $child = $current->popChild() )
{
$child->unregisterParent( $this->nodes[$current->name] );
// if this child has no more parents, add it to the root nodes list
if ( $child->parentCount() === 0 )
$rootNodes[] = $child;
}
unset( $this->nodes[$current->name] );
}
return $sorted;
} | [
"function",
"sort",
"(",
")",
"{",
"$",
"rootNodes",
"=",
"$",
"this",
"->",
"getRootNodes",
"(",
")",
";",
"$",
"sorted",
"=",
"array",
"(",
")",
";",
"while",
"(",
"count",
"(",
"$",
"this",
"->",
"nodes",
")",
">",
"0",
")",
"{",
"// check for... | Performs the topological linear ordering.
@return sorted array | [
"Performs",
"the",
"topological",
"linear",
"ordering",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/ezptopologicalsort.php#L55-L81 | train |
ezsystems/ezpublish-legacy | kernel/private/classes/ezptopologicalsort.php | ezpTopologicalSort.getRootNodes | private function getRootNodes()
{
$output = array();
foreach( $this->nodes as $node )
if (! $node->parentCount() )
$output[] = $node;
return $output;
} | php | private function getRootNodes()
{
$output = array();
foreach( $this->nodes as $node )
if (! $node->parentCount() )
$output[] = $node;
return $output;
} | [
"private",
"function",
"getRootNodes",
"(",
")",
"{",
"$",
"output",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"if",
"(",
"!",
"$",
"node",
"->",
"parentCount",
"(",
")",
")",
"$",
"output",
... | Returns a list of node objects that do not have parents.
@return array of node objects | [
"Returns",
"a",
"list",
"of",
"node",
"objects",
"that",
"do",
"not",
"have",
"parents",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/ezptopologicalsort.php#L88-L95 | train |
ezsystems/ezpublish-legacy | kernel/classes/notification/handler/ezgeneraldigest/ezgeneraldigestusersettings.php | eZGeneralDigestUserSettings.address | protected function address()
{
$user = eZUser::fetch( $this->UserID );
if ( $user instanceof eZUser )
{
return $user->attribute( 'email' );
}
return '';
} | php | protected function address()
{
$user = eZUser::fetch( $this->UserID );
if ( $user instanceof eZUser )
{
return $user->attribute( 'email' );
}
return '';
} | [
"protected",
"function",
"address",
"(",
")",
"{",
"$",
"user",
"=",
"eZUser",
"::",
"fetch",
"(",
"$",
"this",
"->",
"UserID",
")",
";",
"if",
"(",
"$",
"user",
"instanceof",
"eZUser",
")",
"{",
"return",
"$",
"user",
"->",
"attribute",
"(",
"'email... | Returns the email address of the user associated with the digest
settings.
@return string | [
"Returns",
"the",
"email",
"address",
"of",
"the",
"user",
"associated",
"with",
"the",
"digest",
"settings",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/notification/handler/ezgeneraldigest/ezgeneraldigestusersettings.php#L66-L74 | train |
ezsystems/ezpublish-legacy | kernel/classes/notification/handler/ezgeneraldigest/ezgeneraldigestusersettings.php | eZGeneralDigestUserSettings.fetchByUserId | static function fetchByUserId( $userId, $asObject = true )
{
return eZPersistentObject::fetchObject(
self::definition(), null,
array( 'user_id' => $userId ), $asObject
);
} | php | static function fetchByUserId( $userId, $asObject = true )
{
return eZPersistentObject::fetchObject(
self::definition(), null,
array( 'user_id' => $userId ), $asObject
);
} | [
"static",
"function",
"fetchByUserId",
"(",
"$",
"userId",
",",
"$",
"asObject",
"=",
"true",
")",
"{",
"return",
"eZPersistentObject",
"::",
"fetchObject",
"(",
"self",
"::",
"definition",
"(",
")",
",",
"null",
",",
"array",
"(",
"'user_id'",
"=>",
"$",
... | Returns the digest settings object for the user
@since 5.0
@param int $userId the user id
@param bool $asObject
@return eZGeneralDigestUserSettings | [
"Returns",
"the",
"digest",
"settings",
"object",
"for",
"the",
"user"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/notification/handler/ezgeneraldigest/ezgeneraldigestusersettings.php#L115-L121 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezuri.php | eZURI.decodeIRI | public static function decodeIRI( $str )
{
$str = urldecode( $str ); // Decode %xx entries, we now have a utf-8 string
$codec = eZTextCodec::instance( 'utf-8' ); // Make sure string is converted from utf-8 to internal encoding
return $codec->convertString( $str );
} | php | public static function decodeIRI( $str )
{
$str = urldecode( $str ); // Decode %xx entries, we now have a utf-8 string
$codec = eZTextCodec::instance( 'utf-8' ); // Make sure string is converted from utf-8 to internal encoding
return $codec->convertString( $str );
} | [
"public",
"static",
"function",
"decodeIRI",
"(",
"$",
"str",
")",
"{",
"$",
"str",
"=",
"urldecode",
"(",
"$",
"str",
")",
";",
"// Decode %xx entries, we now have a utf-8 string",
"$",
"codec",
"=",
"eZTextCodec",
"::",
"instance",
"(",
"'utf-8'",
")",
";",
... | Decodes a path string which is in IRI format and returns the new path in the internal encoding.
More info on IRI here: {@link http://www.w3.org/International/O-URL-and-ident.html}
@param string $str the string to decode
@return string decoded version of $str | [
"Decodes",
"a",
"path",
"string",
"which",
"is",
"in",
"IRI",
"format",
"and",
"returns",
"the",
"new",
"path",
"in",
"the",
"internal",
"encoding",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezuri.php#L87-L92 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezuri.php | eZURI.encodeIRI | public static function encodeIRI( $str )
{
$codec = eZTextCodec::instance( false, 'utf-8' );
$str = $codec->convertString( $str ); // Make sure the string is in utf-8
$out = explode( "/", $str ); // Don't encode the slashes
foreach ( $out as $i => $o )
{
if ( preg_match( "#^[\(]([a-zA-Z0-9_]+)[\)]#", $o, $m ) )
{
// Don't encode '(' and ')' in user parameters
$out[$i] = '(' . urlencode( $m[1] ) . ')';
}
else
{
$out[$i] = urlencode( $o ); // Let PHP do the rest
}
}
$tmp = join( "/", $out );
// Don't encode '~' in URLs
$tmp = str_replace( '%7E', '~', $tmp );
return $tmp;
} | php | public static function encodeIRI( $str )
{
$codec = eZTextCodec::instance( false, 'utf-8' );
$str = $codec->convertString( $str ); // Make sure the string is in utf-8
$out = explode( "/", $str ); // Don't encode the slashes
foreach ( $out as $i => $o )
{
if ( preg_match( "#^[\(]([a-zA-Z0-9_]+)[\)]#", $o, $m ) )
{
// Don't encode '(' and ')' in user parameters
$out[$i] = '(' . urlencode( $m[1] ) . ')';
}
else
{
$out[$i] = urlencode( $o ); // Let PHP do the rest
}
}
$tmp = join( "/", $out );
// Don't encode '~' in URLs
$tmp = str_replace( '%7E', '~', $tmp );
return $tmp;
} | [
"public",
"static",
"function",
"encodeIRI",
"(",
"$",
"str",
")",
"{",
"$",
"codec",
"=",
"eZTextCodec",
"::",
"instance",
"(",
"false",
",",
"'utf-8'",
")",
";",
"$",
"str",
"=",
"$",
"codec",
"->",
"convertString",
"(",
"$",
"str",
")",
";",
"// M... | Encodes path string in internal encoding to a new string which conforms to the IRI specification.
More info on IRI here: {@link http://www.w3.org/International/O-URL-and-ident.html}
@param string $str the IRI to encode
@return string $str encoded as IRU | [
"Encodes",
"path",
"string",
"in",
"internal",
"encoding",
"to",
"a",
"new",
"string",
"which",
"conforms",
"to",
"the",
"IRI",
"specification",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezuri.php#L102-L123 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezuri.php | eZURI.setURIString | public function setURIString( $uri, $fullInitialize = true )
{
if ( strlen( $uri ) > 0 and
$uri[0] == '/' )
$uri = substr( $uri, 1 );
$uri = eZURI::decodeIRI( $uri );
$this->URI = $uri;
$this->URIArray = explode( '/', $uri );
$this->Index = 0;
if ( !$fullInitialize )
return;
$this->OriginalURI = $uri;
$this->UserArray = array();
unset( $paramName, $paramValue );
foreach ( array_keys( $this->URIArray ) as $key )
{
if ( !isset( $this->URIArray[$key] ) )
continue;
if ( preg_match( "/^[\(][a-zA-Z0-9_]+[\)]/", $this->URIArray[$key] ) )
{
if ( isset( $paramName, $paramValue ) )
{
$this->UserArray[ $paramName ] = $paramValue;
unset( $paramName, $paramValue );
}
$paramName = substr( $this->URIArray[$key], 1, strlen( $this->URIArray[$key] ) - 2 );
if ( isset( $this->URIArray[$key+1] ) )
{
$this->UserArray[ $paramName ] = $this->URIArray[$key+1];
unset( $this->URIArray[$key+1] );
}
else
$this->UserArray[ $paramName ] = "";
unset( $this->URIArray[$key] );
}
else if ( isset( $paramName ) )
{
$this->UserArray[ $paramName ] .= '/' . $this->URIArray[$key];
unset( $this->URIArray[$key] );
}
}
// Remake the URI without any user parameters
$this->URI = implode( '/', $this->URIArray );
if ( eZINI::instance( 'template.ini' )->variable( 'ControlSettings', 'AllowUserVariables' ) == 'false' )
{
$this->UserArray = array();
}
// Convert filter string to current locale
$this->convertFilterString();
} | php | public function setURIString( $uri, $fullInitialize = true )
{
if ( strlen( $uri ) > 0 and
$uri[0] == '/' )
$uri = substr( $uri, 1 );
$uri = eZURI::decodeIRI( $uri );
$this->URI = $uri;
$this->URIArray = explode( '/', $uri );
$this->Index = 0;
if ( !$fullInitialize )
return;
$this->OriginalURI = $uri;
$this->UserArray = array();
unset( $paramName, $paramValue );
foreach ( array_keys( $this->URIArray ) as $key )
{
if ( !isset( $this->URIArray[$key] ) )
continue;
if ( preg_match( "/^[\(][a-zA-Z0-9_]+[\)]/", $this->URIArray[$key] ) )
{
if ( isset( $paramName, $paramValue ) )
{
$this->UserArray[ $paramName ] = $paramValue;
unset( $paramName, $paramValue );
}
$paramName = substr( $this->URIArray[$key], 1, strlen( $this->URIArray[$key] ) - 2 );
if ( isset( $this->URIArray[$key+1] ) )
{
$this->UserArray[ $paramName ] = $this->URIArray[$key+1];
unset( $this->URIArray[$key+1] );
}
else
$this->UserArray[ $paramName ] = "";
unset( $this->URIArray[$key] );
}
else if ( isset( $paramName ) )
{
$this->UserArray[ $paramName ] .= '/' . $this->URIArray[$key];
unset( $this->URIArray[$key] );
}
}
// Remake the URI without any user parameters
$this->URI = implode( '/', $this->URIArray );
if ( eZINI::instance( 'template.ini' )->variable( 'ControlSettings', 'AllowUserVariables' ) == 'false' )
{
$this->UserArray = array();
}
// Convert filter string to current locale
$this->convertFilterString();
} | [
"public",
"function",
"setURIString",
"(",
"$",
"uri",
",",
"$",
"fullInitialize",
"=",
"true",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"uri",
")",
">",
"0",
"and",
"$",
"uri",
"[",
"0",
"]",
"==",
"'/'",
")",
"$",
"uri",
"=",
"substr",
"(",
"... | Sets uri string for instance
Sets the current URI string to $uri, the URI is then split into array elements
and index reset to 1.
@param string $uri
@param boolean $fullInitialize
@return void | [
"Sets",
"uri",
"string",
"for",
"instance"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezuri.php#L218-L275 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezuri.php | eZURI.element | public function element( $index = 0, $relative = true )
{
$pos = $index;
if ( $relative )
$pos += $this->Index;
if ( isset( $this->URIArray[$pos] ) )
return $this->URIArray[$pos];
$ret = null;
return $ret;
} | php | public function element( $index = 0, $relative = true )
{
$pos = $index;
if ( $relative )
$pos += $this->Index;
if ( isset( $this->URIArray[$pos] ) )
return $this->URIArray[$pos];
$ret = null;
return $ret;
} | [
"public",
"function",
"element",
"(",
"$",
"index",
"=",
"0",
",",
"$",
"relative",
"=",
"true",
")",
"{",
"$",
"pos",
"=",
"$",
"index",
";",
"if",
"(",
"$",
"relative",
")",
"$",
"pos",
"+=",
"$",
"this",
"->",
"Index",
";",
"if",
"(",
"isset... | Get element index from uri
@param integer $index the index of URI to return
@param boolean $relative if index is relative to the internal pointer
@return string|null the element at $index | [
"Get",
"element",
"index",
"from",
"uri"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezuri.php#L326-L335 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezuri.php | eZURI.elements | public function elements( $as_text = true )
{
$elements = array_slice( $this->URIArray, $this->Index );
if ( $as_text )
{
$retValue = implode( '/', $elements );
return $retValue;
}
else
return $elements;
} | php | public function elements( $as_text = true )
{
$elements = array_slice( $this->URIArray, $this->Index );
if ( $as_text )
{
$retValue = implode( '/', $elements );
return $retValue;
}
else
return $elements;
} | [
"public",
"function",
"elements",
"(",
"$",
"as_text",
"=",
"true",
")",
"{",
"$",
"elements",
"=",
"array_slice",
"(",
"$",
"this",
"->",
"URIArray",
",",
"$",
"this",
"->",
"Index",
")",
";",
"if",
"(",
"$",
"as_text",
")",
"{",
"$",
"retValue",
... | Return all URI elements
@param boolean $as_text return the elements as string
@return array|string all elements as string/array depending on $as_text | [
"Return",
"all",
"URI",
"elements"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezuri.php#L343-L353 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezuri.php | eZURI.dropBase | public function dropBase()
{
$elements = array_slice( $this->URIArray, $this->Index );
$this->URIArray = $elements;
$this->URI = implode( '/', $this->URIArray );
$uri = $this->URI;
foreach ( $this->UserArray as $name => $value )
{
$uri .= '/(' . $name . ')/' . $value;
}
$this->OriginalURI = $uri;
$this->Index = 0;
} | php | public function dropBase()
{
$elements = array_slice( $this->URIArray, $this->Index );
$this->URIArray = $elements;
$this->URI = implode( '/', $this->URIArray );
$uri = $this->URI;
foreach ( $this->UserArray as $name => $value )
{
$uri .= '/(' . $name . ')/' . $value;
}
$this->OriginalURI = $uri;
$this->Index = 0;
} | [
"public",
"function",
"dropBase",
"(",
")",
"{",
"$",
"elements",
"=",
"array_slice",
"(",
"$",
"this",
"->",
"URIArray",
",",
"$",
"this",
"->",
"Index",
")",
";",
"$",
"this",
"->",
"URIArray",
"=",
"$",
"elements",
";",
"$",
"this",
"->",
"URI",
... | Removes all elements below the current index, recreates the URI string
and sets index to 0.
@return void | [
"Removes",
"all",
"elements",
"below",
"the",
"current",
"index",
"recreates",
"the",
"URI",
"string",
"and",
"sets",
"index",
"to",
"0",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezuri.php#L427-L439 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezuri.php | eZURI.base | public function base( $as_text = true )
{
$elements = array_slice( $this->URIArray, 0, $this->Index );
if ( $as_text )
{
$baseAsText = '/' . implode( '/', $elements );
return $baseAsText;
}
else
return $elements;
} | php | public function base( $as_text = true )
{
$elements = array_slice( $this->URIArray, 0, $this->Index );
if ( $as_text )
{
$baseAsText = '/' . implode( '/', $elements );
return $baseAsText;
}
else
return $elements;
} | [
"public",
"function",
"base",
"(",
"$",
"as_text",
"=",
"true",
")",
"{",
"$",
"elements",
"=",
"array_slice",
"(",
"$",
"this",
"->",
"URIArray",
",",
"0",
",",
"$",
"this",
"->",
"Index",
")",
";",
"if",
"(",
"$",
"as_text",
")",
"{",
"$",
"bas... | Return the elements before pointer
@param type $as_text return as text or array
@return string|array the base string or the base elements as an array if $as_text is true. | [
"Return",
"the",
"elements",
"before",
"pointer"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezuri.php#L457-L467 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezuri.php | eZURI.attribute | public function attribute( $attr )
{
switch ( $attr )
{
case 'element':
return $this->element();
break;
case 'tail':
return $this->elements();
break;
case 'base':
return $this->base();
break;
case 'index':
return $this->index();
break;
case 'uri':
return $this->uriString();
break;
case 'original_uri':
return $this->originalURIString();
break;
case 'query_string':
return eZSys::queryString();
break;
default:
{
eZDebug::writeError( "Attribute '$attr' does not exist", __METHOD__ );
return null;
} break;
}
} | php | public function attribute( $attr )
{
switch ( $attr )
{
case 'element':
return $this->element();
break;
case 'tail':
return $this->elements();
break;
case 'base':
return $this->base();
break;
case 'index':
return $this->index();
break;
case 'uri':
return $this->uriString();
break;
case 'original_uri':
return $this->originalURIString();
break;
case 'query_string':
return eZSys::queryString();
break;
default:
{
eZDebug::writeError( "Attribute '$attr' does not exist", __METHOD__ );
return null;
} break;
}
} | [
"public",
"function",
"attribute",
"(",
"$",
"attr",
")",
"{",
"switch",
"(",
"$",
"attr",
")",
"{",
"case",
"'element'",
":",
"return",
"$",
"this",
"->",
"element",
"(",
")",
";",
"break",
";",
"case",
"'tail'",
":",
"return",
"$",
"this",
"->",
... | Get value for an attribute
@param string $attr
@return boolean the value for attribute $attr or null if it does not exist. | [
"Get",
"value",
"for",
"an",
"attribute"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezuri.php#L532-L563 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezuri.php | eZURI.transformURI | public static function transformURI( &$href, $ignoreIndexDir = false, $serverURL = null, $htmlEscape = true )
{
// When using ezroot, immediately stop if the linked element is external
if ( $ignoreIndexDir )
{
// The initial / needs to be removed as it is not expected by the cluster handler,
// but we must use a temp variable since $href is required later
$trimmedHref = ltrim( $href, '/' );
$modifiedHref = eZClusterFileHandler::instance()->applyServerUri( $trimmedHref );
if ( $modifiedHref != $trimmedHref )
{
$href = $htmlEscape ? self::escapeHtmlTransformUri( $href ) : $href;
return true;
}
unset( $modifiedHref );
}
if ( $serverURL === null )
{
$serverURL = self::$transformURIMode;
}
if ( preg_match( "#^[a-zA-Z0-9]+:#", $href ) || substr( $href, 0, 2 ) == '//' )
return false;
if ( strlen( $href ) == 0 )
$href = '/';
else if ( $href[0] == '#' )
{
$href = $htmlEscape ? htmlspecialchars( $href ) : $href;
return true;
}
else if ( $href[0] != '/' )
{
$href = '/' . $href;
}
$sys = eZSys::instance();
$dir = !$ignoreIndexDir ? $sys->indexDir() : $sys->wwwDir();
$serverURL = $serverURL === 'full' ? $sys->serverURL() : '' ;
$href = $serverURL . $dir . $href;
if ( !$ignoreIndexDir )
{
$href = preg_replace( "#^(//)#", "/", $href );
$href = preg_replace( "#(^.*)(/+)$#", "\$1", $href );
}
$href = $htmlEscape ? self::escapeHtmlTransformUri( $href ) : $href;
if ( $href == "" )
$href = "/";
return true;
} | php | public static function transformURI( &$href, $ignoreIndexDir = false, $serverURL = null, $htmlEscape = true )
{
// When using ezroot, immediately stop if the linked element is external
if ( $ignoreIndexDir )
{
// The initial / needs to be removed as it is not expected by the cluster handler,
// but we must use a temp variable since $href is required later
$trimmedHref = ltrim( $href, '/' );
$modifiedHref = eZClusterFileHandler::instance()->applyServerUri( $trimmedHref );
if ( $modifiedHref != $trimmedHref )
{
$href = $htmlEscape ? self::escapeHtmlTransformUri( $href ) : $href;
return true;
}
unset( $modifiedHref );
}
if ( $serverURL === null )
{
$serverURL = self::$transformURIMode;
}
if ( preg_match( "#^[a-zA-Z0-9]+:#", $href ) || substr( $href, 0, 2 ) == '//' )
return false;
if ( strlen( $href ) == 0 )
$href = '/';
else if ( $href[0] == '#' )
{
$href = $htmlEscape ? htmlspecialchars( $href ) : $href;
return true;
}
else if ( $href[0] != '/' )
{
$href = '/' . $href;
}
$sys = eZSys::instance();
$dir = !$ignoreIndexDir ? $sys->indexDir() : $sys->wwwDir();
$serverURL = $serverURL === 'full' ? $sys->serverURL() : '' ;
$href = $serverURL . $dir . $href;
if ( !$ignoreIndexDir )
{
$href = preg_replace( "#^(//)#", "/", $href );
$href = preg_replace( "#(^.*)(/+)$#", "\$1", $href );
}
$href = $htmlEscape ? self::escapeHtmlTransformUri( $href ) : $href;
if ( $href == "" )
$href = "/";
return true;
} | [
"public",
"static",
"function",
"transformURI",
"(",
"&",
"$",
"href",
",",
"$",
"ignoreIndexDir",
"=",
"false",
",",
"$",
"serverURL",
"=",
"null",
",",
"$",
"htmlEscape",
"=",
"true",
")",
"{",
"// When using ezroot, immediately stop if the linked element is exter... | Implementation of an 'ezurl' template operator
Makes valid eZ Publish urls to use in links
@param string &$href
@param boolean $ignoreIndexDir
@param string $serverURL full|relative
@param boolean $htmlEscape true to html escape the result for HTML
@return string the link to use | [
"Implementation",
"of",
"an",
"ezurl",
"template",
"operator",
"Makes",
"valid",
"eZ",
"Publish",
"urls",
"to",
"use",
"in",
"links"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezuri.php#L597-L649 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.initialize | function initialize( $path, $file, $moduleName, $checkFileExistence = true )
{
if ( $checkFileExistence === false || file_exists( $file ) )
{
unset( $FunctionList );
unset( $Module );
unset( $ViewList );
include( $file );
$this->Functions = $ViewList;
if ( isset( $FunctionList ) and
is_array( $FunctionList ) and
count( $FunctionList ) > 0 )
{
ksort( $FunctionList, SORT_STRING );
$this->FunctionList = $FunctionList;
}
else
{
$this->FunctionList = array();
}
if ( empty( $Module ) )
{
$Module = array( "name" => "null",
"variable_params" => false,
"function" => array() );
}
$this->Module = $Module;
$this->Name = $moduleName;
$this->Path = $path;
$this->Title = "";
$this->UIContext = 'navigation';
$this->UIComponent = $moduleName;
$uiComponentMatch = 'module';
if ( isset( $this->Module['ui_component_match'] ) )
{
$uiComponentMatch = $this->Module['ui_component_match'];
}
$this->UIComponentMatch = $uiComponentMatch;
foreach( $this->Functions as $key => $dummy)
{
$this->Functions[$key]["uri"] = "/$moduleName/$key";
}
}
else
{
$this->Functions = array();
$this->Module = array( "name" => "null",
"variable_params" => false,
"function" => array() );
$this->Name = $moduleName;
$this->Path = $path;
$this->Title = "";
$this->UIContext = 'navigation';
$this->UIComponent = $moduleName;
$this->UIComponentMatch = 'module';
}
$this->HookList = array();
$this->ExitStatus = self::STATUS_IDLE;
$this->ErrorCode = 0;
$this->ViewActions = array();
$this->OriginalParameters = null;
$this->UserParameters = array();
// Load in navigation part overrides
$ini = eZINI::instance( 'module.ini' );
$this->NavigationParts = $ini->variable( 'ModuleOverrides', 'NavigationPart' );
} | php | function initialize( $path, $file, $moduleName, $checkFileExistence = true )
{
if ( $checkFileExistence === false || file_exists( $file ) )
{
unset( $FunctionList );
unset( $Module );
unset( $ViewList );
include( $file );
$this->Functions = $ViewList;
if ( isset( $FunctionList ) and
is_array( $FunctionList ) and
count( $FunctionList ) > 0 )
{
ksort( $FunctionList, SORT_STRING );
$this->FunctionList = $FunctionList;
}
else
{
$this->FunctionList = array();
}
if ( empty( $Module ) )
{
$Module = array( "name" => "null",
"variable_params" => false,
"function" => array() );
}
$this->Module = $Module;
$this->Name = $moduleName;
$this->Path = $path;
$this->Title = "";
$this->UIContext = 'navigation';
$this->UIComponent = $moduleName;
$uiComponentMatch = 'module';
if ( isset( $this->Module['ui_component_match'] ) )
{
$uiComponentMatch = $this->Module['ui_component_match'];
}
$this->UIComponentMatch = $uiComponentMatch;
foreach( $this->Functions as $key => $dummy)
{
$this->Functions[$key]["uri"] = "/$moduleName/$key";
}
}
else
{
$this->Functions = array();
$this->Module = array( "name" => "null",
"variable_params" => false,
"function" => array() );
$this->Name = $moduleName;
$this->Path = $path;
$this->Title = "";
$this->UIContext = 'navigation';
$this->UIComponent = $moduleName;
$this->UIComponentMatch = 'module';
}
$this->HookList = array();
$this->ExitStatus = self::STATUS_IDLE;
$this->ErrorCode = 0;
$this->ViewActions = array();
$this->OriginalParameters = null;
$this->UserParameters = array();
// Load in navigation part overrides
$ini = eZINI::instance( 'module.ini' );
$this->NavigationParts = $ini->variable( 'ModuleOverrides', 'NavigationPart' );
} | [
"function",
"initialize",
"(",
"$",
"path",
",",
"$",
"file",
",",
"$",
"moduleName",
",",
"$",
"checkFileExistence",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"checkFileExistence",
"===",
"false",
"||",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"un... | Initializes the module object.
@param string $path
Directory where the module is declared, without the modulename
component
@param string $file
Full (relative) path to the module.php file describing the module
@param string $moduleName
The module name (content, user...)
@param bool $checkFileExistence
Wether or not $file's existence should be checked
@return void | [
"Initializes",
"the",
"module",
"object",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L276-L344 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.functionURI | function functionURI( $function )
{
if ( $this->singleFunction() or
$function == '' )
return $this->uri();
if ( isset( $this->Functions[$function] ) )
return $this->Functions[$function]["uri"];
else
return null;
} | php | function functionURI( $function )
{
if ( $this->singleFunction() or
$function == '' )
return $this->uri();
if ( isset( $this->Functions[$function] ) )
return $this->Functions[$function]["uri"];
else
return null;
} | [
"function",
"functionURI",
"(",
"$",
"function",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"singleFunction",
"(",
")",
"or",
"$",
"function",
"==",
"''",
")",
"return",
"$",
"this",
"->",
"uri",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
... | Returns the URI to a module's function
@param string $function The function to return the URI for
@return string|null
- the function's URI (content/edit, user/login, etc)
- if $function is empty or the module is a singleView one,
the module's uri (content/, user/...)
- null if the function's not found
@see uri() | [
"Returns",
"the",
"URI",
"to",
"a",
"module",
"s",
"function"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L369-L378 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.setCurrentName | function setCurrentName( $name )
{
$this->Name = $name;
foreach( $this->Functions as $key => $dummy )
{
$this->Functions[$key]["uri"] = "/$name/$key";
}
} | php | function setCurrentName( $name )
{
$this->Name = $name;
foreach( $this->Functions as $key => $dummy )
{
$this->Functions[$key]["uri"] = "/$name/$key";
}
} | [
"function",
"setCurrentName",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"Name",
"=",
"$",
"name",
";",
"foreach",
"(",
"$",
"this",
"->",
"Functions",
"as",
"$",
"key",
"=>",
"$",
"dummy",
")",
"{",
"$",
"this",
"->",
"Functions",
"[",
"$",
... | Sets the name of the currently running module. The URIs will be updated
accordingly
@param string $name The name to be set
@return void
@see uri(), functionURI() | [
"Sets",
"the",
"name",
"of",
"the",
"currently",
"running",
"module",
".",
"The",
"URIs",
"will",
"be",
"updated",
"accordingly"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L415-L422 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.handleError | function handleError( $errorCode, $errorType = false, $parameters = array(), $userParameters = false )
{
if ( self::$useExceptions && $errorType === "kernel" )
{
switch ( $errorCode )
{
case eZError::KERNEL_MODULE_NOT_FOUND:
throw new ezpModuleNotFound( $parameters["module"] );
case eZError::KERNEL_MODULE_DISABLED:
if ( $parameters["check"]["view_checked"] )
throw new ezpModuleViewDisabled( $parameters["check"]['module'], $parameters["check"]['view'] );
throw new ezpModuleDisabled( $parameters["check"]['module'] );
case eZError::KERNEL_MODULE_VIEW_NOT_FOUND:
throw new ezpModuleViewNotFound( $parameters["check"]['module'], $parameters["check"]['view'] );
case eZError::KERNEL_ACCESS_DENIED:
throw new ezpAccessDenied;
//case eZError::KERNEL_MOVED:
// @todo ?
case eZError::KERNEL_NOT_AVAILABLE:
case eZError::KERNEL_NOT_FOUND:
throw new ezpContentNotFoundException( "" );
case eZError::KERNEL_LANGUAGE_NOT_FOUND:
throw new ezpLanguageNotFound;
}
}
if ( !$errorType )
{
eZDebug::writeWarning( "No error type specified for error code $errorCode, assuming kernel.\nA specific error type should be supplied, please check your code.", __METHOD__ );
$errorType = 'kernel';
}
$errorModule = $this->errorModule();
$module = self::findModule( $errorModule['module'], $this );
if ( $module === null )
{
return false;
}
$result = $module->run( $errorModule['view'], array( $errorType, $errorCode, $parameters, $userParameters ) );
// The error module may want to redirect to another URL, see error.ini
if ( $this->exitStatus() != self::STATUS_REDIRECT and
$this->exitStatus() != self::STATUS_RERUN )
{
$this->setExitStatus( self::STATUS_FAILED );
$this->setErrorCode( $errorCode );
}
return $result;
} | php | function handleError( $errorCode, $errorType = false, $parameters = array(), $userParameters = false )
{
if ( self::$useExceptions && $errorType === "kernel" )
{
switch ( $errorCode )
{
case eZError::KERNEL_MODULE_NOT_FOUND:
throw new ezpModuleNotFound( $parameters["module"] );
case eZError::KERNEL_MODULE_DISABLED:
if ( $parameters["check"]["view_checked"] )
throw new ezpModuleViewDisabled( $parameters["check"]['module'], $parameters["check"]['view'] );
throw new ezpModuleDisabled( $parameters["check"]['module'] );
case eZError::KERNEL_MODULE_VIEW_NOT_FOUND:
throw new ezpModuleViewNotFound( $parameters["check"]['module'], $parameters["check"]['view'] );
case eZError::KERNEL_ACCESS_DENIED:
throw new ezpAccessDenied;
//case eZError::KERNEL_MOVED:
// @todo ?
case eZError::KERNEL_NOT_AVAILABLE:
case eZError::KERNEL_NOT_FOUND:
throw new ezpContentNotFoundException( "" );
case eZError::KERNEL_LANGUAGE_NOT_FOUND:
throw new ezpLanguageNotFound;
}
}
if ( !$errorType )
{
eZDebug::writeWarning( "No error type specified for error code $errorCode, assuming kernel.\nA specific error type should be supplied, please check your code.", __METHOD__ );
$errorType = 'kernel';
}
$errorModule = $this->errorModule();
$module = self::findModule( $errorModule['module'], $this );
if ( $module === null )
{
return false;
}
$result = $module->run( $errorModule['view'], array( $errorType, $errorCode, $parameters, $userParameters ) );
// The error module may want to redirect to another URL, see error.ini
if ( $this->exitStatus() != self::STATUS_REDIRECT and
$this->exitStatus() != self::STATUS_RERUN )
{
$this->setExitStatus( self::STATUS_FAILED );
$this->setErrorCode( $errorCode );
}
return $result;
} | [
"function",
"handleError",
"(",
"$",
"errorCode",
",",
"$",
"errorType",
"=",
"false",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
",",
"$",
"userParameters",
"=",
"false",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"useExceptions",
"&&",
"$",
"errorT... | Runs the defined error module
Sets the state of the module object to \c failed and sets the error code.
@param mixed $errorCode
@param mixed $errorType
@param array $parameters
@param mixed $userParameters
@see setErrorModule(), errorModule() | [
"Runs",
"the",
"defined",
"error",
"module",
"Sets",
"the",
"state",
"of",
"the",
"module",
"object",
"to",
"\\",
"c",
"failed",
"and",
"sets",
"the",
"error",
"code",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L589-L645 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.redirectToView | function redirectToView( $viewName = '', $parameters = array(),
$unorderedParameters = null, $userParameters = false,
$anchor = false )
{
return $this->redirectModule( $this, $viewName, $parameters,
$unorderedParameters, $userParameters, $anchor );
} | php | function redirectToView( $viewName = '', $parameters = array(),
$unorderedParameters = null, $userParameters = false,
$anchor = false )
{
return $this->redirectModule( $this, $viewName, $parameters,
$unorderedParameters, $userParameters, $anchor );
} | [
"function",
"redirectToView",
"(",
"$",
"viewName",
"=",
"''",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
",",
"$",
"unorderedParameters",
"=",
"null",
",",
"$",
"userParameters",
"=",
"false",
",",
"$",
"anchor",
"=",
"false",
")",
"{",
"return",
... | Redirects to another view in the current module
@see redirectionURI(), redirectModule(), redirect()
@param string $viewName Target view name
@param array $parameters View parameters
@param array $unorderedParameters Unordered view parameters
@param array $userParameters User parameters
@param string $anchor Redirection URI anchor
@return boolean true if successful, false if the view isn't found | [
"Redirects",
"to",
"another",
"view",
"in",
"the",
"current",
"module"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L694-L700 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.currentRedirectionURI | function currentRedirectionURI()
{
$module = $this;
$viewName = self::currentView();
$parameters = $this->OriginalViewParameters;
$unorderedParameters = $this->OriginalUnorderedParameters;
$userParameters = $this->UserParameters;
return $this->redirectionURIForModule( $module, $viewName, $parameters,
$unorderedParameters, $userParameters );
} | php | function currentRedirectionURI()
{
$module = $this;
$viewName = self::currentView();
$parameters = $this->OriginalViewParameters;
$unorderedParameters = $this->OriginalUnorderedParameters;
$userParameters = $this->UserParameters;
return $this->redirectionURIForModule( $module, $viewName, $parameters,
$unorderedParameters, $userParameters );
} | [
"function",
"currentRedirectionURI",
"(",
")",
"{",
"$",
"module",
"=",
"$",
"this",
";",
"$",
"viewName",
"=",
"self",
"::",
"currentView",
"(",
")",
";",
"$",
"parameters",
"=",
"$",
"this",
"->",
"OriginalViewParameters",
";",
"$",
"unorderedParameters",
... | Creates the redirection URI for the current module, view & parameters
@return string The redirection URI
@see redirectionURIForModule() | [
"Creates",
"the",
"redirection",
"URI",
"for",
"the",
"current",
"module",
"view",
"&",
"parameters"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L766-L775 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.parameters | function parameters( $viewName = '' )
{
if ( $viewName == '' )
$viewName = self::currentView();
$viewData = $this->viewData( $viewName );
if ( isset( $viewData['params'] ) )
{
return $viewData['params'];
}
return null;
} | php | function parameters( $viewName = '' )
{
if ( $viewName == '' )
$viewName = self::currentView();
$viewData = $this->viewData( $viewName );
if ( isset( $viewData['params'] ) )
{
return $viewData['params'];
}
return null;
} | [
"function",
"parameters",
"(",
"$",
"viewName",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"viewName",
"==",
"''",
")",
"$",
"viewName",
"=",
"self",
"::",
"currentView",
"(",
")",
";",
"$",
"viewData",
"=",
"$",
"this",
"->",
"viewData",
"(",
"$",
"view... | Returns the defined parameter for a view.
@param string $viewName
The view to get parameters for. If not specified, the current view
is used
@return array The parameters definition
@see unorderedParameters(), viewData(), currentView(), currentModule() | [
"Returns",
"the",
"defined",
"parameter",
"for",
"a",
"view",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L887-L897 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.unorderedParameters | function unorderedParameters( $viewName = '' )
{
if ( $viewName == '' )
$viewName = self::currentView();
$viewData = $this->viewData( $viewName );
if ( isset( $viewData['unordered_params'] ) )
{
return $viewData['unordered_params'];
}
return null;
} | php | function unorderedParameters( $viewName = '' )
{
if ( $viewName == '' )
$viewName = self::currentView();
$viewData = $this->viewData( $viewName );
if ( isset( $viewData['unordered_params'] ) )
{
return $viewData['unordered_params'];
}
return null;
} | [
"function",
"unorderedParameters",
"(",
"$",
"viewName",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"viewName",
"==",
"''",
")",
"$",
"viewName",
"=",
"self",
"::",
"currentView",
"(",
")",
";",
"$",
"viewData",
"=",
"$",
"this",
"->",
"viewData",
"(",
"$"... | Returns the unordered parameters definition.
@param string $viewName
The view to return parameters for. If npt specified, the current
view is used
@return the unordered parameter definition for the requested view
@see parameters(), viewData(), currentView(), currentModule() | [
"Returns",
"the",
"unordered",
"parameters",
"definition",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L910-L920 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.viewData | function viewData( $viewName = '' )
{
if ( $viewName == '' )
$viewName = self::currentView();
if ( $this->singleFunction() )
$viewData = $this->Module["function"];
else
$viewData = $this->Functions[$viewName];
return $viewData;
} | php | function viewData( $viewName = '' )
{
if ( $viewName == '' )
$viewName = self::currentView();
if ( $this->singleFunction() )
$viewData = $this->Module["function"];
else
$viewData = $this->Functions[$viewName];
return $viewData;
} | [
"function",
"viewData",
"(",
"$",
"viewName",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"viewName",
"==",
"''",
")",
"$",
"viewName",
"=",
"self",
"::",
"currentView",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"singleFunction",
"(",
")",
")",
"$",
... | Returns data for a view
@param string $viewName
The view to return data for. If omited, the current view is used
@see parameters(), unorderedParameters(), currentView(), currentModule()
@return array | [
"Returns",
"data",
"for",
"a",
"view"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L931-L940 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.redirectTo | function redirectTo( $uri )
{
$originalURI = $uri;
$uri = preg_replace( "#(^.*)(/+)$#", "\$1", $uri );
if ( strlen( $originalURI ) != 0 and
strlen( $uri ) == 0 )
$uri = '/';
$urlComponents = parse_url( $uri );
// eZSys::hostname() can contain port if present.
// So parsing it with parse_url() as well to only get host.
$currentHostname = eZSys::hostname();
$currentHostnameParsed = parse_url( $currentHostname, PHP_URL_HOST );
$currentHostname = $currentHostnameParsed ? $currentHostnameParsed : $currentHostname;
if ( isset( $urlComponents['host'] ) && $urlComponents['host'] !== $currentHostname )
{
$allowedHosts = $this->getAllowedRedirectHosts();
if ( !isset( $allowedHosts[$urlComponents['host']] ) )
{
// Non-authorized host, return only the URI (without host) + query string and fragment if present.
eZDebug::writeError( "Redirection requested on non-authorized host '{$urlComponents['host']}'" );
header( $_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden' );
echo "Redirection requested on non-authorized host";
eZDB::checkTransactionCounter();
eZExecution::cleanExit();
}
}
$this->RedirectURI = $uri;
$this->setExitStatus( self::STATUS_REDIRECT );
} | php | function redirectTo( $uri )
{
$originalURI = $uri;
$uri = preg_replace( "#(^.*)(/+)$#", "\$1", $uri );
if ( strlen( $originalURI ) != 0 and
strlen( $uri ) == 0 )
$uri = '/';
$urlComponents = parse_url( $uri );
// eZSys::hostname() can contain port if present.
// So parsing it with parse_url() as well to only get host.
$currentHostname = eZSys::hostname();
$currentHostnameParsed = parse_url( $currentHostname, PHP_URL_HOST );
$currentHostname = $currentHostnameParsed ? $currentHostnameParsed : $currentHostname;
if ( isset( $urlComponents['host'] ) && $urlComponents['host'] !== $currentHostname )
{
$allowedHosts = $this->getAllowedRedirectHosts();
if ( !isset( $allowedHosts[$urlComponents['host']] ) )
{
// Non-authorized host, return only the URI (without host) + query string and fragment if present.
eZDebug::writeError( "Redirection requested on non-authorized host '{$urlComponents['host']}'" );
header( $_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden' );
echo "Redirection requested on non-authorized host";
eZDB::checkTransactionCounter();
eZExecution::cleanExit();
}
}
$this->RedirectURI = $uri;
$this->setExitStatus( self::STATUS_REDIRECT );
} | [
"function",
"redirectTo",
"(",
"$",
"uri",
")",
"{",
"$",
"originalURI",
"=",
"$",
"uri",
";",
"$",
"uri",
"=",
"preg_replace",
"(",
"\"#(^.*)(/+)$#\"",
",",
"\"\\$1\"",
",",
"$",
"uri",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"originalURI",
")",
"!... | Sets the module to redirect at the end of the execution
@param string $uri the URI to redirect to
@see setRedirectURI(), setExitStatus()
@return void | [
"Sets",
"the",
"module",
"to",
"redirect",
"at",
"the",
"end",
"of",
"the",
"execution"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L951-L981 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.getAllowedRedirectHosts | private function getAllowedRedirectHosts()
{
$ini = eZINI::instance();
$allowedHosts = array_fill_keys( $ini->variable( 'SiteSettings', 'AllowedRedirectHosts' ), true );
// Adding HostMatchMapItems from siteaccess match if present
if ( $ini->hasVariable( 'SiteAccessSettings', 'HostMatchMapItems' ) )
{
$hostMatchMapItems = $ini->variable( 'SiteAccessSettings', 'HostMatchMapItems' );
foreach ( $hostMatchMapItems as $item )
{
list( $host, $sa ) = explode( ';', $item );
$allowedHosts[$host] = true;
}
}
// Adding HostUriMatchMapItems
foreach ( $ini->variable( 'SiteAccessSettings', 'HostUriMatchMapItems' ) as $item )
{
list( $host, $uri, $sa ) = explode( ';', $item );
$allowedHosts[$host] = true;
}
return $allowedHosts;
} | php | private function getAllowedRedirectHosts()
{
$ini = eZINI::instance();
$allowedHosts = array_fill_keys( $ini->variable( 'SiteSettings', 'AllowedRedirectHosts' ), true );
// Adding HostMatchMapItems from siteaccess match if present
if ( $ini->hasVariable( 'SiteAccessSettings', 'HostMatchMapItems' ) )
{
$hostMatchMapItems = $ini->variable( 'SiteAccessSettings', 'HostMatchMapItems' );
foreach ( $hostMatchMapItems as $item )
{
list( $host, $sa ) = explode( ';', $item );
$allowedHosts[$host] = true;
}
}
// Adding HostUriMatchMapItems
foreach ( $ini->variable( 'SiteAccessSettings', 'HostUriMatchMapItems' ) as $item )
{
list( $host, $uri, $sa ) = explode( ';', $item );
$allowedHosts[$host] = true;
}
return $allowedHosts;
} | [
"private",
"function",
"getAllowedRedirectHosts",
"(",
")",
"{",
"$",
"ini",
"=",
"eZINI",
"::",
"instance",
"(",
")",
";",
"$",
"allowedHosts",
"=",
"array_fill_keys",
"(",
"$",
"ini",
"->",
"variable",
"(",
"'SiteSettings'",
",",
"'AllowedRedirectHosts'",
")... | Returns the set of hosts that are allowed for absolute redirection
@return array | [
"Returns",
"the",
"set",
"of",
"hosts",
"that",
"are",
"allowed",
"for",
"absolute",
"redirection"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L988-L1011 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.attribute | function attribute( $attr )
{
switch( $attr )
{
case "uri":
return $this->uri();
break;
case "functions":
return $this->Functions;
case "views":
return $this->Functions;
case "name":
return $this->Name;
case "path":
return $this->Path;
case "info":
return $this->Module;
case 'aviable_functions':
case 'available_functions':
return $this->FunctionList;
default:
{
eZDebug::writeError( "Attribute '$attr' does not exist", __METHOD__ );
return null;
}
break;
}
} | php | function attribute( $attr )
{
switch( $attr )
{
case "uri":
return $this->uri();
break;
case "functions":
return $this->Functions;
case "views":
return $this->Functions;
case "name":
return $this->Name;
case "path":
return $this->Path;
case "info":
return $this->Module;
case 'aviable_functions':
case 'available_functions':
return $this->FunctionList;
default:
{
eZDebug::writeError( "Attribute '$attr' does not exist", __METHOD__ );
return null;
}
break;
}
} | [
"function",
"attribute",
"(",
"$",
"attr",
")",
"{",
"switch",
"(",
"$",
"attr",
")",
"{",
"case",
"\"uri\"",
":",
"return",
"$",
"this",
"->",
"uri",
"(",
")",
";",
"break",
";",
"case",
"\"functions\"",
":",
"return",
"$",
"this",
"->",
"Functions"... | Returns the value of an attribute
@param string $attr Attribute name
@return mixed The attribute value. If the attribute doesn't exist, a
warning is thrown, and false is returned | [
"Returns",
"the",
"value",
"of",
"an",
"attribute"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L1098-L1125 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.setCurrentAction | function setCurrentAction( $actionName, $view = '' )
{
if ( $view == '' )
$view = self::currentView();
if ( $view == '' or $actionName == '' )
return false;
$this->ViewActions[$view] = $actionName;
} | php | function setCurrentAction( $actionName, $view = '' )
{
if ( $view == '' )
$view = self::currentView();
if ( $view == '' or $actionName == '' )
return false;
$this->ViewActions[$view] = $actionName;
} | [
"function",
"setCurrentAction",
"(",
"$",
"actionName",
",",
"$",
"view",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"view",
"==",
"''",
")",
"$",
"view",
"=",
"self",
"::",
"currentView",
"(",
")",
";",
"if",
"(",
"$",
"view",
"==",
"''",
"or",
"$",
... | Sets the current action for a view
@param string $actionName The action to make current
@param string $view
The view to set the action for. If omited, the current view is used
@return void
@see currentAction(), isCurrentAction() | [
"Sets",
"the",
"current",
"action",
"for",
"a",
"view"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L1138-L1145 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.currentAction | function currentAction( $view = '' )
{
if ( $view == '' )
$view = self::currentView();
if ( isset( $this->ViewActions[$view] ) )
return $this->ViewActions[$view];
$http = eZHTTPTool::instance();
if ( isset( $this->Functions[$view]['default_action'] ) )
{
$defaultAction = $this->Functions[$view]['default_action'];
foreach ( $defaultAction as $defaultActionStructure )
{
$actionName = $defaultActionStructure['name'];
$type = $defaultActionStructure['type'];
if ( $type == 'post' )
{
$parameters = array();
if ( isset( $defaultActionStructure['parameters'] ) )
$parameters = $defaultActionStructure['parameters'];
$hasParameters = true;
foreach ( $parameters as $parameterName )
{
if ( !$http->hasPostVariable( $parameterName ) )
{
$hasParameters = false;
break;
}
}
if ( $hasParameters )
{
$this->ViewActions[$view] = $actionName;
return $this->ViewActions[$view];
}
}
else
{
eZDebug::writeWarning( 'Unknown default action type: ' . $type, __METHOD__ );
}
}
}
if ( isset( $this->Functions[$view]['single_post_actions'] ) )
{
$singlePostActions = $this->Functions[$view]['single_post_actions'];
foreach( $singlePostActions as $postActionName => $realActionName )
{
if ( $http->hasPostVariable( $postActionName ) )
{
$this->ViewActions[$view] = $realActionName;
return $this->ViewActions[$view];
}
}
}
if ( isset( $this->Functions[$view]['post_actions'] ) )
{
$postActions = $this->Functions[$view]['post_actions'];
foreach( $postActions as $postActionName )
{
if ( $http->hasPostVariable( $postActionName ) )
{
$this->ViewActions[$view] = $http->postVariable( $postActionName );
return $this->ViewActions[$view];
}
}
}
$this->ViewActions[$view] = false;
return false;
} | php | function currentAction( $view = '' )
{
if ( $view == '' )
$view = self::currentView();
if ( isset( $this->ViewActions[$view] ) )
return $this->ViewActions[$view];
$http = eZHTTPTool::instance();
if ( isset( $this->Functions[$view]['default_action'] ) )
{
$defaultAction = $this->Functions[$view]['default_action'];
foreach ( $defaultAction as $defaultActionStructure )
{
$actionName = $defaultActionStructure['name'];
$type = $defaultActionStructure['type'];
if ( $type == 'post' )
{
$parameters = array();
if ( isset( $defaultActionStructure['parameters'] ) )
$parameters = $defaultActionStructure['parameters'];
$hasParameters = true;
foreach ( $parameters as $parameterName )
{
if ( !$http->hasPostVariable( $parameterName ) )
{
$hasParameters = false;
break;
}
}
if ( $hasParameters )
{
$this->ViewActions[$view] = $actionName;
return $this->ViewActions[$view];
}
}
else
{
eZDebug::writeWarning( 'Unknown default action type: ' . $type, __METHOD__ );
}
}
}
if ( isset( $this->Functions[$view]['single_post_actions'] ) )
{
$singlePostActions = $this->Functions[$view]['single_post_actions'];
foreach( $singlePostActions as $postActionName => $realActionName )
{
if ( $http->hasPostVariable( $postActionName ) )
{
$this->ViewActions[$view] = $realActionName;
return $this->ViewActions[$view];
}
}
}
if ( isset( $this->Functions[$view]['post_actions'] ) )
{
$postActions = $this->Functions[$view]['post_actions'];
foreach( $postActions as $postActionName )
{
if ( $http->hasPostVariable( $postActionName ) )
{
$this->ViewActions[$view] = $http->postVariable( $postActionName );
return $this->ViewActions[$view];
}
}
}
$this->ViewActions[$view] = false;
return false;
} | [
"function",
"currentAction",
"(",
"$",
"view",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"view",
"==",
"''",
")",
"$",
"view",
"=",
"self",
"::",
"currentView",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"ViewActions",
"[",
"$",
"view"... | Returns the current action name.
If the current action is not yet determined it will use the definitions in
module.php in order to find out the current action. It first looks trough
the \c single_post_actions array in the selected view mode, the key to
each element is the name of the post-variable to match, if it matches the
element value is set as the action.
\code
'single_post_actions' => array( 'PreviewButton' => 'Preview',
'PublishButton' => 'Publish' )
\endcode
If none of these matches it will use the elements from the \c post_actions
array to find a match. It uses the element value for each element to match
agains a post-variable, if it is found the contents of the post-variable
is set as the action.
\code
'post_actions' => array( 'BrowseActionName' )
\endcode
@return string The current action, or false if not set nor found
@see setCurrentAction(), isCurrentAction() | [
"Returns",
"the",
"current",
"action",
"name",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L1171-L1238 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.setActionParameter | function setActionParameter( $parameterName, $parameterValue, $view = '' )
{
if ( $view == '' )
$view = self::currentView();
$this->ViewActionParameters[$view][$parameterName] = $parameterValue;
} | php | function setActionParameter( $parameterName, $parameterValue, $view = '' )
{
if ( $view == '' )
$view = self::currentView();
$this->ViewActionParameters[$view][$parameterName] = $parameterValue;
} | [
"function",
"setActionParameter",
"(",
"$",
"parameterName",
",",
"$",
"parameterValue",
",",
"$",
"view",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"view",
"==",
"''",
")",
"$",
"view",
"=",
"self",
"::",
"currentView",
"(",
")",
";",
"$",
"this",
"->",
... | Sets an action parameter value
@param string $parameterName
@param mixed $parameterValue
@param string $view
The view to set the action parameter for. If omited, the current
view is used
@return void
@see actionParameter(), hasActionParameter() | [
"Sets",
"an",
"action",
"parameter",
"value"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L1251-L1256 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.actionParameter | function actionParameter( $parameterName, $view = '' )
{
if ( $view == '' )
$view = self::currentView();
if ( isset( $this->ViewActionParameters[$view][$parameterName] ) )
return $this->ViewActionParameters[$view][$parameterName];
$currentAction = $this->currentAction( $view );
$http = eZHTTPTool::instance();
if ( isset( $this->Functions[$view]['post_action_parameters'][$currentAction] ) )
{
$postParameters = $this->Functions[$view]['post_action_parameters'][$currentAction];
if ( isset( $postParameters[$parameterName] ) &&
$http->hasPostVariable( $postParameters[$parameterName] ) )
{
return $http->postVariable( $postParameters[$parameterName] );
}
eZDebug::writeError( "No such action parameter: $parameterName", __METHOD__ );
}
if ( isset( $this->Functions[$view]['post_value_action_parameters'][$currentAction] ) )
{
$postParameters = $this->Functions[$view]['post_value_action_parameters'][$currentAction];
if ( isset( $postParameters[$parameterName] ) )
{
$postVariables = $http->attribute( 'post' );
$postVariableNameMatch = $postParameters[$parameterName];
$regMatch = "/^" . $postVariableNameMatch . "_(.+)$/";
foreach ( $postVariables as $postVariableName => $postVariableValue )
{
if ( preg_match( $regMatch, $postVariableName, $matches ) )
{
$parameterValue = $matches[1];
$this->ViewActionParameters[$view][$parameterName] = $parameterValue;
return $parameterValue;
}
}
eZDebug::writeError( "No such action parameter: $parameterName", __METHOD__ );
}
}
return null;
} | php | function actionParameter( $parameterName, $view = '' )
{
if ( $view == '' )
$view = self::currentView();
if ( isset( $this->ViewActionParameters[$view][$parameterName] ) )
return $this->ViewActionParameters[$view][$parameterName];
$currentAction = $this->currentAction( $view );
$http = eZHTTPTool::instance();
if ( isset( $this->Functions[$view]['post_action_parameters'][$currentAction] ) )
{
$postParameters = $this->Functions[$view]['post_action_parameters'][$currentAction];
if ( isset( $postParameters[$parameterName] ) &&
$http->hasPostVariable( $postParameters[$parameterName] ) )
{
return $http->postVariable( $postParameters[$parameterName] );
}
eZDebug::writeError( "No such action parameter: $parameterName", __METHOD__ );
}
if ( isset( $this->Functions[$view]['post_value_action_parameters'][$currentAction] ) )
{
$postParameters = $this->Functions[$view]['post_value_action_parameters'][$currentAction];
if ( isset( $postParameters[$parameterName] ) )
{
$postVariables = $http->attribute( 'post' );
$postVariableNameMatch = $postParameters[$parameterName];
$regMatch = "/^" . $postVariableNameMatch . "_(.+)$/";
foreach ( $postVariables as $postVariableName => $postVariableValue )
{
if ( preg_match( $regMatch, $postVariableName, $matches ) )
{
$parameterValue = $matches[1];
$this->ViewActionParameters[$view][$parameterName] = $parameterValue;
return $parameterValue;
}
}
eZDebug::writeError( "No such action parameter: $parameterName", __METHOD__ );
}
}
return null;
} | [
"function",
"actionParameter",
"(",
"$",
"parameterName",
",",
"$",
"view",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"view",
"==",
"''",
")",
"$",
"view",
"=",
"self",
"::",
"currentView",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"V... | Returns an action parameter value
@param string $parameterName
@param string $view
The view to return the parameter for. If omited, uses the current view
@return mixed The parameter value, or null + error if not found
@see setActionParameter(), hasActionParameter() | [
"Returns",
"an",
"action",
"parameter",
"value"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L1268-L1307 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.hasActionParameter | function hasActionParameter( $parameterName, $view = '' )
{
if ( $view == '' )
$view = self::currentView();
if ( isset( $this->ViewActionParameters[$view][$parameterName] ) )
return true;
$currentAction = $this->currentAction( $view );
$http = eZHTTPTool::instance();
if ( isset( $this->Functions[$view]['post_action_parameters'][$currentAction] ) )
{
$postParameters = $this->Functions[$view]['post_action_parameters'][$currentAction];
if ( isset( $postParameters[$parameterName] ) and
$http->hasPostVariable( $postParameters[$parameterName] ) )
{
return true;
}
}
if ( isset( $this->Functions[$view]['post_value_action_parameters'][$currentAction] ) )
{
$postParameters = $this->Functions[$view]['post_value_action_parameters'][$currentAction];
if ( isset( $postParameters[$parameterName] ) )
{
$postVariables = $http->attribute( 'post' );
$postVariableNameMatch = $postParameters[$parameterName];
$regMatch = "/^" . $postVariableNameMatch . "_(.+)$/";
foreach ( $postVariables as $postVariableName => $postVariableValue )
{
if ( preg_match( $regMatch, $postVariableName, $matches ) )
{
$parameterValue = $matches[1];
$this->ViewActionParameters[$view][$parameterName] = $parameterValue;
return true;
}
}
}
}
return false;
} | php | function hasActionParameter( $parameterName, $view = '' )
{
if ( $view == '' )
$view = self::currentView();
if ( isset( $this->ViewActionParameters[$view][$parameterName] ) )
return true;
$currentAction = $this->currentAction( $view );
$http = eZHTTPTool::instance();
if ( isset( $this->Functions[$view]['post_action_parameters'][$currentAction] ) )
{
$postParameters = $this->Functions[$view]['post_action_parameters'][$currentAction];
if ( isset( $postParameters[$parameterName] ) and
$http->hasPostVariable( $postParameters[$parameterName] ) )
{
return true;
}
}
if ( isset( $this->Functions[$view]['post_value_action_parameters'][$currentAction] ) )
{
$postParameters = $this->Functions[$view]['post_value_action_parameters'][$currentAction];
if ( isset( $postParameters[$parameterName] ) )
{
$postVariables = $http->attribute( 'post' );
$postVariableNameMatch = $postParameters[$parameterName];
$regMatch = "/^" . $postVariableNameMatch . "_(.+)$/";
foreach ( $postVariables as $postVariableName => $postVariableValue )
{
if ( preg_match( $regMatch, $postVariableName, $matches ) )
{
$parameterValue = $matches[1];
$this->ViewActionParameters[$view][$parameterName] = $parameterValue;
return true;
}
}
}
}
return false;
} | [
"function",
"hasActionParameter",
"(",
"$",
"parameterName",
",",
"$",
"view",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"view",
"==",
"''",
")",
"$",
"view",
"=",
"self",
"::",
"currentView",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
... | Checks if an action parameter is defined for a view
@param string $parameterName
@param string $view
The view to check the parameter for. If omited, uses the current view
@return bool
@see setActionParameter(), actionParameter() | [
"Checks",
"if",
"an",
"action",
"parameter",
"is",
"defined",
"for",
"a",
"view"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L1320-L1357 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.isCurrentAction | function isCurrentAction( $actionName, $view = '' )
{
if ( $view == '' )
$view = self::currentView();
if ( $view == '' or $actionName == '' )
return false;
return $this->currentAction( $view ) == $actionName;
} | php | function isCurrentAction( $actionName, $view = '' )
{
if ( $view == '' )
$view = self::currentView();
if ( $view == '' or $actionName == '' )
return false;
return $this->currentAction( $view ) == $actionName;
} | [
"function",
"isCurrentAction",
"(",
"$",
"actionName",
",",
"$",
"view",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"view",
"==",
"''",
")",
"$",
"view",
"=",
"self",
"::",
"currentView",
"(",
")",
";",
"if",
"(",
"$",
"view",
"==",
"''",
"or",
"$",
... | Checks if the current action is the given one
@param string $actionName The action to check
@param string $view The view to check the action for. Current view if omited.
@return bool
@see currentAction(), setCurrentAction() | [
"Checks",
"if",
"the",
"current",
"action",
"is",
"the",
"given",
"one"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L1369-L1376 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.setViewResult | function setViewResult( $result, $view = '' )
{
if ( $view == '' )
$view = $this->currentView();
$this->ViewResult[$view] = $result;
} | php | function setViewResult( $result, $view = '' )
{
if ( $view == '' )
$view = $this->currentView();
$this->ViewResult[$view] = $result;
} | [
"function",
"setViewResult",
"(",
"$",
"result",
",",
"$",
"view",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"view",
"==",
"''",
")",
"$",
"view",
"=",
"$",
"this",
"->",
"currentView",
"(",
")",
";",
"$",
"this",
"->",
"ViewResult",
"[",
"$",
"view",... | Sets the view result
@param string $result The (usually HTML) view result
@param string $view
The view to set the result for. If omited, the current view is used
@return void
@see hasViewResult(), viewResult() | [
"Sets",
"the",
"view",
"result"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L1544-L1549 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.hasViewResult | function hasViewResult( $view = '' )
{
if ( $view == '' )
$view = $this->currentView();
return isset( $this->ViewResult[$view] );
} | php | function hasViewResult( $view = '' )
{
if ( $view == '' )
$view = $this->currentView();
return isset( $this->ViewResult[$view] );
} | [
"function",
"hasViewResult",
"(",
"$",
"view",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"view",
"==",
"''",
")",
"$",
"view",
"=",
"$",
"this",
"->",
"currentView",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"ViewResult",
"[",
"$",
"vi... | Checks if a view has a result set
@param string $view The view to test for. If omited, uses the current view
@return bool | [
"Checks",
"if",
"a",
"view",
"has",
"a",
"result",
"set"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L1557-L1562 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.viewResult | function viewResult( $view = '' )
{
if ( $view == '' )
$view = $this->currentView();
if ( isset( $this->ViewResult[$view] ) )
{
return $this->ViewResult[$view];
}
return null;
} | php | function viewResult( $view = '' )
{
if ( $view == '' )
$view = $this->currentView();
if ( isset( $this->ViewResult[$view] ) )
{
return $this->ViewResult[$view];
}
return null;
} | [
"function",
"viewResult",
"(",
"$",
"view",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"view",
"==",
"''",
")",
"$",
"view",
"=",
"$",
"this",
"->",
"currentView",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"ViewResult",
"[",
"$",
"vi... | Returns the view result
@param string $view
The view to return the result for, or the current one if omited
@return string|null The view result, or null if not set | [
"Returns",
"the",
"view",
"result"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L1572-L1581 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.activeModuleRepositories | static function activeModuleRepositories( $useExtensions = true )
{
$moduleINI = eZINI::instance( 'module.ini' );
$moduleRepositories = $moduleINI->variable( 'ModuleSettings', 'ModuleRepositories' );
if ( $useExtensions )
{
$extensionRepositories = $moduleINI->variable( 'ModuleSettings', 'ExtensionRepositories' );
$extensionDirectory = eZExtension::baseDirectory();
$activeExtensions = eZExtension::activeExtensions();
$globalExtensionRepositories = array();
foreach ( $extensionRepositories as $extensionRepository )
{
$extPath = $extensionDirectory . '/' . $extensionRepository;
$modulePath = $extPath . '/modules';
if ( !in_array( $extensionRepository, $activeExtensions ) )
{
eZDebug::writeWarning( "Extension '$extensionRepository' was reported to have modules but has not yet been activated.\n" .
"Check the setting ModuleSettings/ExtensionRepositories in module.ini for your extensions\n" .
"or make sure it is activated in the setting ExtensionSettings/ActiveExtensions in site.ini." );
}
else if ( file_exists( $modulePath ) )
{
$globalExtensionRepositories[] = $modulePath;
}
else if ( !file_exists( $extPath ) )
{
eZDebug::writeWarning( "Extension '$extensionRepository' was reported to have modules but the extension itself does not exist.\n" .
"Check the setting ModuleSettings/ExtensionRepositories in module.ini for your extensions.\n" .
"You should probably remove this extension from the list." );
}
else
{
eZDebug::writeWarning( "Extension '$extensionRepository' does not have the subdirectory 'modules' allthough it reported it had modules.\n" .
"Looked for directory '" . $modulePath . "'\n" .
"Check the setting ModuleSettings/ExtensionRepositories in module.ini for your extension." );
}
}
$moduleRepositories = array_merge( $moduleRepositories, $globalExtensionRepositories );
}
return $moduleRepositories;
} | php | static function activeModuleRepositories( $useExtensions = true )
{
$moduleINI = eZINI::instance( 'module.ini' );
$moduleRepositories = $moduleINI->variable( 'ModuleSettings', 'ModuleRepositories' );
if ( $useExtensions )
{
$extensionRepositories = $moduleINI->variable( 'ModuleSettings', 'ExtensionRepositories' );
$extensionDirectory = eZExtension::baseDirectory();
$activeExtensions = eZExtension::activeExtensions();
$globalExtensionRepositories = array();
foreach ( $extensionRepositories as $extensionRepository )
{
$extPath = $extensionDirectory . '/' . $extensionRepository;
$modulePath = $extPath . '/modules';
if ( !in_array( $extensionRepository, $activeExtensions ) )
{
eZDebug::writeWarning( "Extension '$extensionRepository' was reported to have modules but has not yet been activated.\n" .
"Check the setting ModuleSettings/ExtensionRepositories in module.ini for your extensions\n" .
"or make sure it is activated in the setting ExtensionSettings/ActiveExtensions in site.ini." );
}
else if ( file_exists( $modulePath ) )
{
$globalExtensionRepositories[] = $modulePath;
}
else if ( !file_exists( $extPath ) )
{
eZDebug::writeWarning( "Extension '$extensionRepository' was reported to have modules but the extension itself does not exist.\n" .
"Check the setting ModuleSettings/ExtensionRepositories in module.ini for your extensions.\n" .
"You should probably remove this extension from the list." );
}
else
{
eZDebug::writeWarning( "Extension '$extensionRepository' does not have the subdirectory 'modules' allthough it reported it had modules.\n" .
"Looked for directory '" . $modulePath . "'\n" .
"Check the setting ModuleSettings/ExtensionRepositories in module.ini for your extension." );
}
}
$moduleRepositories = array_merge( $moduleRepositories, $globalExtensionRepositories );
}
return $moduleRepositories;
} | [
"static",
"function",
"activeModuleRepositories",
"(",
"$",
"useExtensions",
"=",
"true",
")",
"{",
"$",
"moduleINI",
"=",
"eZINI",
"::",
"instance",
"(",
"'module.ini'",
")",
";",
"$",
"moduleRepositories",
"=",
"$",
"moduleINI",
"->",
"variable",
"(",
"'Modu... | Returns the list of active module repositories, as defined in module.ini
@param boolean $useExtensions
If true, module.ini files in extensions will be scanned as well.
If false, only the module.ini overrides in settings will be.
@return array a path list of currently active modules | [
"Returns",
"the",
"list",
"of",
"active",
"module",
"repositories",
"as",
"defined",
"in",
"module",
".",
"ini"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L1893-L1937 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.addGlobalPathList | static function addGlobalPathList( $pathList )
{
if ( !is_array( $GLOBALS['eZModuleGlobalPathList'] ) )
{
$GLOBALS['eZModuleGlobalPathList'] = array();
}
if ( !is_array( $pathList ) )
{
$pathList = array( $pathList );
}
$GLOBALS['eZModuleGlobalPathList'] = array_merge( $GLOBALS['eZModuleGlobalPathList'], $pathList );
} | php | static function addGlobalPathList( $pathList )
{
if ( !is_array( $GLOBALS['eZModuleGlobalPathList'] ) )
{
$GLOBALS['eZModuleGlobalPathList'] = array();
}
if ( !is_array( $pathList ) )
{
$pathList = array( $pathList );
}
$GLOBALS['eZModuleGlobalPathList'] = array_merge( $GLOBALS['eZModuleGlobalPathList'], $pathList );
} | [
"static",
"function",
"addGlobalPathList",
"(",
"$",
"pathList",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"GLOBALS",
"[",
"'eZModuleGlobalPathList'",
"]",
")",
")",
"{",
"$",
"GLOBALS",
"[",
"'eZModuleGlobalPathList'",
"]",
"=",
"array",
"(",
")",
"... | Adds a new entry to the global path list
@param array|string $pathList
Either an array of path or a single path string
@return void
@see setGlobalPathList(), globalPathList() | [
"Adds",
"a",
"new",
"entry",
"to",
"the",
"global",
"path",
"list"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L1960-L1971 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezmodule.php | eZModule.exists | static function exists( $moduleName, $pathList = null, $showError = false )
{
$module = null;
return self::findModule( $moduleName, $module, $pathList, $showError );
} | php | static function exists( $moduleName, $pathList = null, $showError = false )
{
$module = null;
return self::findModule( $moduleName, $module, $pathList, $showError );
} | [
"static",
"function",
"exists",
"(",
"$",
"moduleName",
",",
"$",
"pathList",
"=",
"null",
",",
"$",
"showError",
"=",
"false",
")",
"{",
"$",
"module",
"=",
"null",
";",
"return",
"self",
"::",
"findModule",
"(",
"$",
"moduleName",
",",
"$",
"module",... | Loads a module object by name
@param string $moduleName The name of the module to find (ex: content)
@param array|string
Either an array of path or a single path string. These will be
used as additionnal locations that will be looked into
@param boolean $showError
If true an error will be shown if the module it not found.
@return eZModule The eZModule object, or null if the module wasn't found
@see findModule() | [
"Loads",
"a",
"module",
"object",
"by",
"name"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezmodule.php#L1985-L1989 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezhttpfile.php | eZHTTPFile.canFetch | static function canFetch( $httpName, $maxSize = false )
{
if ( !isset( $GLOBALS["eZHTTPFile-$httpName"] ) ||
!( $GLOBALS["eZHTTPFile-$httpName"] instanceof eZHTTPFile ) )
{
if ( $maxSize === false )
{
return isset( $_FILES[$httpName] ) and $_FILES[$httpName]['name'] != "" and $_FILES[$httpName]['error'] == 0;
}
if ( isset( $_FILES[$httpName] ) and $_FILES[$httpName]['name'] != "" )
{
switch ( $_FILES[$httpName]['error'] )
{
case ( UPLOAD_ERR_NO_FILE ):
{
return eZHTTPFile::UPLOADEDFILE_DOES_NOT_EXIST;
}break;
case ( UPLOAD_ERR_INI_SIZE ):
{
return eZHTTPFile::UPLOADEDFILE_EXCEEDS_PHP_LIMIT;
}break;
case ( UPLOAD_ERR_FORM_SIZE ):
{
return eZHTTPFile::UPLOADEDFILE_EXCEEDS_MAX_SIZE;
}break;
case ( UPLOAD_ERR_NO_TMP_DIR ):
{
return eZHTTPFile::UPLOADEDFILE_MISSING_TMP_DIR;
}break;
case ( UPLOAD_ERR_CANT_WRITE ):
{
return eZHTTPFile::UPLOADEDFILE_CANT_WRITE;
}break;
case ( 0 ):
{
return ( $maxSize == 0 || $_FILES[$httpName]['size'] <= $maxSize )? eZHTTPFile::UPLOADEDFILE_OK:
eZHTTPFile::UPLOADEDFILE_EXCEEDS_MAX_SIZE;
}break;
default:
{
return eZHTTPFile::UPLOADEDFILE_UNKNOWN_ERROR;
}
}
}
else
{
return eZHTTPFile::UPLOADEDFILE_DOES_NOT_EXIST;
}
}
if ( $maxSize === false )
return eZHTTPFile::UPLOADEDFILE_OK;
else
return true;
} | php | static function canFetch( $httpName, $maxSize = false )
{
if ( !isset( $GLOBALS["eZHTTPFile-$httpName"] ) ||
!( $GLOBALS["eZHTTPFile-$httpName"] instanceof eZHTTPFile ) )
{
if ( $maxSize === false )
{
return isset( $_FILES[$httpName] ) and $_FILES[$httpName]['name'] != "" and $_FILES[$httpName]['error'] == 0;
}
if ( isset( $_FILES[$httpName] ) and $_FILES[$httpName]['name'] != "" )
{
switch ( $_FILES[$httpName]['error'] )
{
case ( UPLOAD_ERR_NO_FILE ):
{
return eZHTTPFile::UPLOADEDFILE_DOES_NOT_EXIST;
}break;
case ( UPLOAD_ERR_INI_SIZE ):
{
return eZHTTPFile::UPLOADEDFILE_EXCEEDS_PHP_LIMIT;
}break;
case ( UPLOAD_ERR_FORM_SIZE ):
{
return eZHTTPFile::UPLOADEDFILE_EXCEEDS_MAX_SIZE;
}break;
case ( UPLOAD_ERR_NO_TMP_DIR ):
{
return eZHTTPFile::UPLOADEDFILE_MISSING_TMP_DIR;
}break;
case ( UPLOAD_ERR_CANT_WRITE ):
{
return eZHTTPFile::UPLOADEDFILE_CANT_WRITE;
}break;
case ( 0 ):
{
return ( $maxSize == 0 || $_FILES[$httpName]['size'] <= $maxSize )? eZHTTPFile::UPLOADEDFILE_OK:
eZHTTPFile::UPLOADEDFILE_EXCEEDS_MAX_SIZE;
}break;
default:
{
return eZHTTPFile::UPLOADEDFILE_UNKNOWN_ERROR;
}
}
}
else
{
return eZHTTPFile::UPLOADEDFILE_DOES_NOT_EXIST;
}
}
if ( $maxSize === false )
return eZHTTPFile::UPLOADEDFILE_OK;
else
return true;
} | [
"static",
"function",
"canFetch",
"(",
"$",
"httpName",
",",
"$",
"maxSize",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"GLOBALS",
"[",
"\"eZHTTPFile-$httpName\"",
"]",
")",
"||",
"!",
"(",
"$",
"GLOBALS",
"[",
"\"eZHTTPFile-$httpName\"",
... | Returns whether a file can be fetched.
@param string $httpName Name of the file.
@param bool|int Whether a maximum file size applies or size in bytes of the maximum allowed.
@return bool|int true if the HTTP file $httpName can be fetched. If $maxSize is given,
the function returns
eZHTTPFile::UPLOADEDFILE_OK if the file can be fetched,
eZHTTPFile::UPLOADEDFILE_DOES_NOT_EXIST if there has been no file uploaded,
eZHTTPFile::UPLOADEDFILE_EXCEEDS_PHP_LIMIT if the file was uploaded but size
exceeds the upload_max_size limit (set in the PHP configuration),
eZHTTPFile::UPLOADEDFILE_EXCEEDS_MAX_SIZE if the file was uploaded but size
exceeds $maxSize or MAX_FILE_SIZE variable in the form.
eZHTTPFile::UPLOADEDFILE_MISSING_TMP_DIR if the temporary directory is missing
eZHTTPFile::UPLOADEDFILE_CANT_WRITE if the file can't be written
eZHTTPFile::UPLOADEDFILE_UNKNOWN_ERROR if an unknown error occured | [
"Returns",
"whether",
"a",
"file",
"can",
"be",
"fetched",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezhttpfile.php#L203-L263 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.