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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
concrete5/concrete5 | concrete/src/User/Login/LoginAttemptService.php | LoginAttemptService.trackAttempt | public function trackAttempt($username, $password)
{
if (!$this->config->get('concrete.user.deactivation.authentication_failure.enabled', false)) {
return $this;
}
$user = $this->resolveUser($username);
if (!$user) {
return;
}
$attempt = new LoginAttempt();
$attempt->setUtcDate(Carbon::now('UTC'));
$attempt->setUserId($user->getUserID());
$this->entityManager->persist($attempt);
// Make sure we get flushed with the next batch
$this->batch[] = $attempt;
// Prune old attempts
$this->pruneAttempts();
return $this;
} | php | public function trackAttempt($username, $password)
{
if (!$this->config->get('concrete.user.deactivation.authentication_failure.enabled', false)) {
return $this;
}
$user = $this->resolveUser($username);
if (!$user) {
return;
}
$attempt = new LoginAttempt();
$attempt->setUtcDate(Carbon::now('UTC'));
$attempt->setUserId($user->getUserID());
$this->entityManager->persist($attempt);
// Make sure we get flushed with the next batch
$this->batch[] = $attempt;
// Prune old attempts
$this->pruneAttempts();
return $this;
} | [
"public",
"function",
"trackAttempt",
"(",
"$",
"username",
",",
"$",
"password",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'concrete.user.deactivation.authentication_failure.enabled'",
",",
"false",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"user",
"=",
"$",
"this",
"->",
"resolveUser",
"(",
"$",
"username",
")",
";",
"if",
"(",
"!",
"$",
"user",
")",
"{",
"return",
";",
"}",
"$",
"attempt",
"=",
"new",
"LoginAttempt",
"(",
")",
";",
"$",
"attempt",
"->",
"setUtcDate",
"(",
"Carbon",
"::",
"now",
"(",
"'UTC'",
")",
")",
";",
"$",
"attempt",
"->",
"setUserId",
"(",
"$",
"user",
"->",
"getUserID",
"(",
")",
")",
";",
"$",
"this",
"->",
"entityManager",
"->",
"persist",
"(",
"$",
"attempt",
")",
";",
"// Make sure we get flushed with the next batch",
"$",
"this",
"->",
"batch",
"[",
"]",
"=",
"$",
"attempt",
";",
"// Prune old attempts",
"$",
"this",
"->",
"pruneAttempts",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Track a login attempt for a user
@param string $username
@param string $password
@return $this | [
"Track",
"a",
"login",
"attempt",
"for",
"a",
"user"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/Login/LoginAttemptService.php#L76-L99 | train |
concrete5/concrete5 | concrete/src/User/Login/LoginAttemptService.php | LoginAttemptService.remainingAttempts | public function remainingAttempts($username)
{
$config = $this->config->get('concrete.user.deactivation.authentication_failure');
$allowed = (int) array_get($config, 'amount', 0);
$duration = (int) array_get($config, 'duration', 0);
$after = Carbon::now('UTC')->subSeconds($duration);
$user = $this->resolveUser($username);
if (!$user) {
return $allowed;
}
/** @var \Concrete\Core\Entity\User\LoginAttemptRepository $repository */
$repository = $this->entityManager->getRepository(LoginAttempt::class);
$attempts = $repository->after($after, $user, true);
return max(0, $allowed - $attempts);
} | php | public function remainingAttempts($username)
{
$config = $this->config->get('concrete.user.deactivation.authentication_failure');
$allowed = (int) array_get($config, 'amount', 0);
$duration = (int) array_get($config, 'duration', 0);
$after = Carbon::now('UTC')->subSeconds($duration);
$user = $this->resolveUser($username);
if (!$user) {
return $allowed;
}
/** @var \Concrete\Core\Entity\User\LoginAttemptRepository $repository */
$repository = $this->entityManager->getRepository(LoginAttempt::class);
$attempts = $repository->after($after, $user, true);
return max(0, $allowed - $attempts);
} | [
"public",
"function",
"remainingAttempts",
"(",
"$",
"username",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'concrete.user.deactivation.authentication_failure'",
")",
";",
"$",
"allowed",
"=",
"(",
"int",
")",
"array_get",
"(",
"$",
"config",
",",
"'amount'",
",",
"0",
")",
";",
"$",
"duration",
"=",
"(",
"int",
")",
"array_get",
"(",
"$",
"config",
",",
"'duration'",
",",
"0",
")",
";",
"$",
"after",
"=",
"Carbon",
"::",
"now",
"(",
"'UTC'",
")",
"->",
"subSeconds",
"(",
"$",
"duration",
")",
";",
"$",
"user",
"=",
"$",
"this",
"->",
"resolveUser",
"(",
"$",
"username",
")",
";",
"if",
"(",
"!",
"$",
"user",
")",
"{",
"return",
"$",
"allowed",
";",
"}",
"/** @var \\Concrete\\Core\\Entity\\User\\LoginAttemptRepository $repository */",
"$",
"repository",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getRepository",
"(",
"LoginAttempt",
"::",
"class",
")",
";",
"$",
"attempts",
"=",
"$",
"repository",
"->",
"after",
"(",
"$",
"after",
",",
"$",
"user",
",",
"true",
")",
";",
"return",
"max",
"(",
"0",
",",
"$",
"allowed",
"-",
"$",
"attempts",
")",
";",
"}"
] | Determine the amount of attempts remaining for a username
@param $username
@return int | [
"Determine",
"the",
"amount",
"of",
"attempts",
"remaining",
"for",
"a",
"username"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/Login/LoginAttemptService.php#L107-L125 | train |
concrete5/concrete5 | concrete/src/User/Login/LoginAttemptService.php | LoginAttemptService.deactivate | public function deactivate($username)
{
if (!$this->config->get('concrete.user.deactivation.authentication_failure.enabled', false)) {
return;
}
$user = $this->resolveUser($username);
if (!$user) {
throw new InvalidArgumentException(t('Unable to find and deactivate given user'));
}
$event = DeactivateUser::create($user);
$this->director->dispatch('on_before_user_deactivate', $event);
// Here we could retrieve the user entity from the event and allow an event handler to change which user gets
// deactivated, but we don't want to support that at the moment
// $user = $event->getUserEntity();
// Set the user to inactive
$this->entityManager->transactional(function(EntityManagerInterface $localManager) use ($user) {
$user = $localManager->merge($user);
$user->setUserIsActive(false);
});
// Send out a `user_deactivate` event
$this->director->dispatch('on_after_user_deactivate', $event);
} | php | public function deactivate($username)
{
if (!$this->config->get('concrete.user.deactivation.authentication_failure.enabled', false)) {
return;
}
$user = $this->resolveUser($username);
if (!$user) {
throw new InvalidArgumentException(t('Unable to find and deactivate given user'));
}
$event = DeactivateUser::create($user);
$this->director->dispatch('on_before_user_deactivate', $event);
// Here we could retrieve the user entity from the event and allow an event handler to change which user gets
// deactivated, but we don't want to support that at the moment
// $user = $event->getUserEntity();
// Set the user to inactive
$this->entityManager->transactional(function(EntityManagerInterface $localManager) use ($user) {
$user = $localManager->merge($user);
$user->setUserIsActive(false);
});
// Send out a `user_deactivate` event
$this->director->dispatch('on_after_user_deactivate', $event);
} | [
"public",
"function",
"deactivate",
"(",
"$",
"username",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'concrete.user.deactivation.authentication_failure.enabled'",
",",
"false",
")",
")",
"{",
"return",
";",
"}",
"$",
"user",
"=",
"$",
"this",
"->",
"resolveUser",
"(",
"$",
"username",
")",
";",
"if",
"(",
"!",
"$",
"user",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"t",
"(",
"'Unable to find and deactivate given user'",
")",
")",
";",
"}",
"$",
"event",
"=",
"DeactivateUser",
"::",
"create",
"(",
"$",
"user",
")",
";",
"$",
"this",
"->",
"director",
"->",
"dispatch",
"(",
"'on_before_user_deactivate'",
",",
"$",
"event",
")",
";",
"// Here we could retrieve the user entity from the event and allow an event handler to change which user gets",
"// deactivated, but we don't want to support that at the moment",
"// $user = $event->getUserEntity();",
"// Set the user to inactive",
"$",
"this",
"->",
"entityManager",
"->",
"transactional",
"(",
"function",
"(",
"EntityManagerInterface",
"$",
"localManager",
")",
"use",
"(",
"$",
"user",
")",
"{",
"$",
"user",
"=",
"$",
"localManager",
"->",
"merge",
"(",
"$",
"user",
")",
";",
"$",
"user",
"->",
"setUserIsActive",
"(",
"false",
")",
";",
"}",
")",
";",
"// Send out a `user_deactivate` event",
"$",
"this",
"->",
"director",
"->",
"dispatch",
"(",
"'on_after_user_deactivate'",
",",
"$",
"event",
")",
";",
"}"
] | Deactivate a given username
@param $username | [
"Deactivate",
"a",
"given",
"username"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/Login/LoginAttemptService.php#L132-L158 | train |
concrete5/concrete5 | concrete/src/User/Login/LoginAttemptService.php | LoginAttemptService.pruneAttempts | public function pruneAttempts(DateTime $before = null)
{
if (!$before) {
$duration = (int) $this->config->get('concrete.user.deactivation.authentication_failure.duration');
$before = Carbon::now('UTC')->subSeconds($duration);
}
// Load our repository and get entries before our date
$repository = $this->entityManager->getRepository(LoginAttempt::class);
$results = $repository->before($before);
// Loop through and remove those entries
$batch = [];
$max = 50;
foreach ($results as $result) {
$this->entityManager->remove($result);
$batch[] = $result;
// Handle the batch
$batch = $this->manageBatch($batch, $max);
}
// Close off the batch
$this->manageBatch($batch);
} | php | public function pruneAttempts(DateTime $before = null)
{
if (!$before) {
$duration = (int) $this->config->get('concrete.user.deactivation.authentication_failure.duration');
$before = Carbon::now('UTC')->subSeconds($duration);
}
// Load our repository and get entries before our date
$repository = $this->entityManager->getRepository(LoginAttempt::class);
$results = $repository->before($before);
// Loop through and remove those entries
$batch = [];
$max = 50;
foreach ($results as $result) {
$this->entityManager->remove($result);
$batch[] = $result;
// Handle the batch
$batch = $this->manageBatch($batch, $max);
}
// Close off the batch
$this->manageBatch($batch);
} | [
"public",
"function",
"pruneAttempts",
"(",
"DateTime",
"$",
"before",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"before",
")",
"{",
"$",
"duration",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'concrete.user.deactivation.authentication_failure.duration'",
")",
";",
"$",
"before",
"=",
"Carbon",
"::",
"now",
"(",
"'UTC'",
")",
"->",
"subSeconds",
"(",
"$",
"duration",
")",
";",
"}",
"// Load our repository and get entries before our date",
"$",
"repository",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getRepository",
"(",
"LoginAttempt",
"::",
"class",
")",
";",
"$",
"results",
"=",
"$",
"repository",
"->",
"before",
"(",
"$",
"before",
")",
";",
"// Loop through and remove those entries",
"$",
"batch",
"=",
"[",
"]",
";",
"$",
"max",
"=",
"50",
";",
"foreach",
"(",
"$",
"results",
"as",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"entityManager",
"->",
"remove",
"(",
"$",
"result",
")",
";",
"$",
"batch",
"[",
"]",
"=",
"$",
"result",
";",
"// Handle the batch",
"$",
"batch",
"=",
"$",
"this",
"->",
"manageBatch",
"(",
"$",
"batch",
",",
"$",
"max",
")",
";",
"}",
"// Close off the batch",
"$",
"this",
"->",
"manageBatch",
"(",
"$",
"batch",
")",
";",
"}"
] | Prune old login attempts
@param \DateTime|null $before The date to prune before. This MUST be in UTC, if not passed this value is derived
from config | [
"Prune",
"old",
"login",
"attempts"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/Login/LoginAttemptService.php#L166-L191 | train |
concrete5/concrete5 | concrete/src/User/Login/LoginAttemptService.php | LoginAttemptService.manageBatch | private function manageBatch(array $batch, $max = 0)
{
if (count($batch) >= $max) {
$this->entityManager->flush();
$batch = [];
}
return $batch;
} | php | private function manageBatch(array $batch, $max = 0)
{
if (count($batch) >= $max) {
$this->entityManager->flush();
$batch = [];
}
return $batch;
} | [
"private",
"function",
"manageBatch",
"(",
"array",
"$",
"batch",
",",
"$",
"max",
"=",
"0",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"batch",
")",
">=",
"$",
"max",
")",
"{",
"$",
"this",
"->",
"entityManager",
"->",
"flush",
"(",
")",
";",
"$",
"batch",
"=",
"[",
"]",
";",
"}",
"return",
"$",
"batch",
";",
"}"
] | Manage a batched ORM operation
@param array $batch
@param int $max
@return array | [
"Manage",
"a",
"batched",
"ORM",
"operation"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/Login/LoginAttemptService.php#L201-L209 | train |
concrete5/concrete5 | concrete/src/Cache/Driver/FileSystemStashDriver.php | FileSystemStashDriver.storeData | public function storeData($key, $data, $expiration)
{
$path = $this->makePath($key);
// MAX_PATH is 260 - http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx
if (strlen($path) > 259 && stripos(PHP_OS, 'WIN') === 0) {
throw new WindowsPathMaxLengthException();
}
if (!file_exists($path)) {
$dirname = dirname($path);
if (!is_dir($dirname)) {
if (!@mkdir($dirname, $this->dirPermissions, true)) {
if (!is_dir($dirname)) {
return false;
}
}
}
if (!(touch($path) && chmod($path, $this->filePermissions))) {
return false;
}
}
$storeString = $this->getEncoder()->serialize($this->makeKeyString($key), $data, $expiration);
$result = file_put_contents($path, $storeString, LOCK_EX);
// If opcache is switched on, it will try to cache the PHP data file
// The new php opcode caching system only revalidates against the source files once every few seconds,
// so some changes will not be caught.
// This fix immediately invalidates that opcode cache after a file is written,
// so that future includes are not using the stale opcode cached file.
if (function_exists('opcache_invalidate')) {
$invalidate = true;
if ($restrictedDirectory = ini_get('opcache.restrict_api')) {
if (strpos(__FILE__, $restrictedDirectory) !== 0) {
$invalidate = false;
}
}
if ($invalidate) {
@opcache_invalidate($path, true);
}
}
return false !== $result;
} | php | public function storeData($key, $data, $expiration)
{
$path = $this->makePath($key);
// MAX_PATH is 260 - http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx
if (strlen($path) > 259 && stripos(PHP_OS, 'WIN') === 0) {
throw new WindowsPathMaxLengthException();
}
if (!file_exists($path)) {
$dirname = dirname($path);
if (!is_dir($dirname)) {
if (!@mkdir($dirname, $this->dirPermissions, true)) {
if (!is_dir($dirname)) {
return false;
}
}
}
if (!(touch($path) && chmod($path, $this->filePermissions))) {
return false;
}
}
$storeString = $this->getEncoder()->serialize($this->makeKeyString($key), $data, $expiration);
$result = file_put_contents($path, $storeString, LOCK_EX);
// If opcache is switched on, it will try to cache the PHP data file
// The new php opcode caching system only revalidates against the source files once every few seconds,
// so some changes will not be caught.
// This fix immediately invalidates that opcode cache after a file is written,
// so that future includes are not using the stale opcode cached file.
if (function_exists('opcache_invalidate')) {
$invalidate = true;
if ($restrictedDirectory = ini_get('opcache.restrict_api')) {
if (strpos(__FILE__, $restrictedDirectory) !== 0) {
$invalidate = false;
}
}
if ($invalidate) {
@opcache_invalidate($path, true);
}
}
return false !== $result;
} | [
"public",
"function",
"storeData",
"(",
"$",
"key",
",",
"$",
"data",
",",
"$",
"expiration",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"makePath",
"(",
"$",
"key",
")",
";",
"// MAX_PATH is 260 - http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx",
"if",
"(",
"strlen",
"(",
"$",
"path",
")",
">",
"259",
"&&",
"stripos",
"(",
"PHP_OS",
",",
"'WIN'",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"WindowsPathMaxLengthException",
"(",
")",
";",
"}",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"$",
"dirname",
"=",
"dirname",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dirname",
")",
")",
"{",
"if",
"(",
"!",
"@",
"mkdir",
"(",
"$",
"dirname",
",",
"$",
"this",
"->",
"dirPermissions",
",",
"true",
")",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dirname",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"(",
"touch",
"(",
"$",
"path",
")",
"&&",
"chmod",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"filePermissions",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"$",
"storeString",
"=",
"$",
"this",
"->",
"getEncoder",
"(",
")",
"->",
"serialize",
"(",
"$",
"this",
"->",
"makeKeyString",
"(",
"$",
"key",
")",
",",
"$",
"data",
",",
"$",
"expiration",
")",
";",
"$",
"result",
"=",
"file_put_contents",
"(",
"$",
"path",
",",
"$",
"storeString",
",",
"LOCK_EX",
")",
";",
"// If opcache is switched on, it will try to cache the PHP data file",
"// The new php opcode caching system only revalidates against the source files once every few seconds,",
"// so some changes will not be caught.",
"// This fix immediately invalidates that opcode cache after a file is written,",
"// so that future includes are not using the stale opcode cached file.",
"if",
"(",
"function_exists",
"(",
"'opcache_invalidate'",
")",
")",
"{",
"$",
"invalidate",
"=",
"true",
";",
"if",
"(",
"$",
"restrictedDirectory",
"=",
"ini_get",
"(",
"'opcache.restrict_api'",
")",
")",
"{",
"if",
"(",
"strpos",
"(",
"__FILE__",
",",
"$",
"restrictedDirectory",
")",
"!==",
"0",
")",
"{",
"$",
"invalidate",
"=",
"false",
";",
"}",
"}",
"if",
"(",
"$",
"invalidate",
")",
"{",
"@",
"opcache_invalidate",
"(",
"$",
"path",
",",
"true",
")",
";",
"}",
"}",
"return",
"false",
"!==",
"$",
"result",
";",
"}"
] | This function takes the data and stores it to the path specified. If the directory leading up to the path does
not exist, it creates it.
We overrode this function because calls to opcache_invalidate will sometimes throw fatals
See https://github.com/tedious/Stash/issues/350
{@inheritdoc}
@throws \Stash\Exception\WindowsPathMaxLengthException | [
"This",
"function",
"takes",
"the",
"data",
"and",
"stores",
"it",
"to",
"the",
"path",
"specified",
".",
"If",
"the",
"directory",
"leading",
"up",
"to",
"the",
"path",
"does",
"not",
"exist",
"it",
"creates",
"it",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Cache/Driver/FileSystemStashDriver.php#L21-L68 | train |
concrete5/concrete5 | concrete/src/Updater/Update.php | Update.getApplicationUpdateInformation | public static function getApplicationUpdateInformation()
{
$app = Application::getFacadeApplication();
$cache = $app->make('cache');
$r = $cache->getItem('APP_UPDATE_INFO');
if ($r->isMiss()) {
$r->lock();
$result = static::getLatestAvailableUpdate();
$r->set($result)->save();
} else {
$result = $r->get();
}
return $result;
} | php | public static function getApplicationUpdateInformation()
{
$app = Application::getFacadeApplication();
$cache = $app->make('cache');
$r = $cache->getItem('APP_UPDATE_INFO');
if ($r->isMiss()) {
$r->lock();
$result = static::getLatestAvailableUpdate();
$r->set($result)->save();
} else {
$result = $r->get();
}
return $result;
} | [
"public",
"static",
"function",
"getApplicationUpdateInformation",
"(",
")",
"{",
"$",
"app",
"=",
"Application",
"::",
"getFacadeApplication",
"(",
")",
";",
"$",
"cache",
"=",
"$",
"app",
"->",
"make",
"(",
"'cache'",
")",
";",
"$",
"r",
"=",
"$",
"cache",
"->",
"getItem",
"(",
"'APP_UPDATE_INFO'",
")",
";",
"if",
"(",
"$",
"r",
"->",
"isMiss",
"(",
")",
")",
"{",
"$",
"r",
"->",
"lock",
"(",
")",
";",
"$",
"result",
"=",
"static",
"::",
"getLatestAvailableUpdate",
"(",
")",
";",
"$",
"r",
"->",
"set",
"(",
"$",
"result",
")",
"->",
"save",
"(",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"$",
"r",
"->",
"get",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Retrieves the info about the latest available information.
The effective request to the remote server is done just once per request.
@return RemoteApplicationUpdate|null | [
"Retrieves",
"the",
"info",
"about",
"the",
"latest",
"available",
"information",
".",
"The",
"effective",
"request",
"to",
"the",
"remote",
"server",
"is",
"done",
"just",
"once",
"per",
"request",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Updater/Update.php#L89-L103 | train |
concrete5/concrete5 | concrete/src/Updater/Update.php | Update.getLocalAvailableUpdates | public function getLocalAvailableUpdates()
{
$app = Application::getFacadeApplication();
$fh = $app->make('helper/file');
$updates = [];
$contents = @$fh->getDirectoryContents(DIR_CORE_UPDATES);
foreach ($contents as $con) {
if (is_dir(DIR_CORE_UPDATES . '/' . $con)) {
$obj = ApplicationUpdate::get($con);
if (is_object($obj)) {
if (version_compare($obj->getUpdateVersion(), APP_VERSION, '>')) {
$updates[] = $obj;
}
}
}
}
usort(
$updates,
function ($a, $b) {
return version_compare($a->getUpdateVersion(), $b->getUpdateVersion());
}
);
return $updates;
} | php | public function getLocalAvailableUpdates()
{
$app = Application::getFacadeApplication();
$fh = $app->make('helper/file');
$updates = [];
$contents = @$fh->getDirectoryContents(DIR_CORE_UPDATES);
foreach ($contents as $con) {
if (is_dir(DIR_CORE_UPDATES . '/' . $con)) {
$obj = ApplicationUpdate::get($con);
if (is_object($obj)) {
if (version_compare($obj->getUpdateVersion(), APP_VERSION, '>')) {
$updates[] = $obj;
}
}
}
}
usort(
$updates,
function ($a, $b) {
return version_compare($a->getUpdateVersion(), $b->getUpdateVersion());
}
);
return $updates;
} | [
"public",
"function",
"getLocalAvailableUpdates",
"(",
")",
"{",
"$",
"app",
"=",
"Application",
"::",
"getFacadeApplication",
"(",
")",
";",
"$",
"fh",
"=",
"$",
"app",
"->",
"make",
"(",
"'helper/file'",
")",
";",
"$",
"updates",
"=",
"[",
"]",
";",
"$",
"contents",
"=",
"@",
"$",
"fh",
"->",
"getDirectoryContents",
"(",
"DIR_CORE_UPDATES",
")",
";",
"foreach",
"(",
"$",
"contents",
"as",
"$",
"con",
")",
"{",
"if",
"(",
"is_dir",
"(",
"DIR_CORE_UPDATES",
".",
"'/'",
".",
"$",
"con",
")",
")",
"{",
"$",
"obj",
"=",
"ApplicationUpdate",
"::",
"get",
"(",
"$",
"con",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"obj",
")",
")",
"{",
"if",
"(",
"version_compare",
"(",
"$",
"obj",
"->",
"getUpdateVersion",
"(",
")",
",",
"APP_VERSION",
",",
"'>'",
")",
")",
"{",
"$",
"updates",
"[",
"]",
"=",
"$",
"obj",
";",
"}",
"}",
"}",
"}",
"usort",
"(",
"$",
"updates",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"return",
"version_compare",
"(",
"$",
"a",
"->",
"getUpdateVersion",
"(",
")",
",",
"$",
"b",
"->",
"getUpdateVersion",
"(",
")",
")",
";",
"}",
")",
";",
"return",
"$",
"updates",
";",
"}"
] | Looks in the designated updates location for all directories, ascertains what
version they represent, and finds all versions greater than the currently installed version of
concrete5.
@return ApplicationUpdate[] | [
"Looks",
"in",
"the",
"designated",
"updates",
"location",
"for",
"all",
"directories",
"ascertains",
"what",
"version",
"they",
"represent",
"and",
"finds",
"all",
"versions",
"greater",
"than",
"the",
"currently",
"installed",
"version",
"of",
"concrete5",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Updater/Update.php#L112-L136 | train |
concrete5/concrete5 | concrete/src/Updater/Update.php | Update.isCurrentVersionNewerThanDatabaseVersion | public static function isCurrentVersionNewerThanDatabaseVersion()
{
$app = Application::getFacadeApplication();
$db = $app->make(Connection::class);
$config = $app->make('config');
$database = $db->fetchColumn('select max(version) from SystemDatabaseMigrations');
$code = $config->get('concrete.version_db');
return $database < $code;
} | php | public static function isCurrentVersionNewerThanDatabaseVersion()
{
$app = Application::getFacadeApplication();
$db = $app->make(Connection::class);
$config = $app->make('config');
$database = $db->fetchColumn('select max(version) from SystemDatabaseMigrations');
$code = $config->get('concrete.version_db');
return $database < $code;
} | [
"public",
"static",
"function",
"isCurrentVersionNewerThanDatabaseVersion",
"(",
")",
"{",
"$",
"app",
"=",
"Application",
"::",
"getFacadeApplication",
"(",
")",
";",
"$",
"db",
"=",
"$",
"app",
"->",
"make",
"(",
"Connection",
"::",
"class",
")",
";",
"$",
"config",
"=",
"$",
"app",
"->",
"make",
"(",
"'config'",
")",
";",
"$",
"database",
"=",
"$",
"db",
"->",
"fetchColumn",
"(",
"'select max(version) from SystemDatabaseMigrations'",
")",
";",
"$",
"code",
"=",
"$",
"config",
"->",
"get",
"(",
"'concrete.version_db'",
")",
";",
"return",
"$",
"database",
"<",
"$",
"code",
";",
"}"
] | Checks migrations to see if the current code DB version is greater than that registered in the database. | [
"Checks",
"migrations",
"to",
"see",
"if",
"the",
"current",
"code",
"DB",
"version",
"is",
"greater",
"than",
"that",
"registered",
"in",
"the",
"database",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Updater/Update.php#L141-L150 | train |
concrete5/concrete5 | concrete/src/Database/EntityManager/Provider/AbstractPackageProvider.php | AbstractPackageProvider.getAnnotationReader | protected function getAnnotationReader()
{
if ($this->packageSupportsLegacyCore()) {
$reader = $this->getLegacyAnnotationReader();
} else {
$reader = $this->getStandardAnnotationReader();
}
return $reader;
} | php | protected function getAnnotationReader()
{
if ($this->packageSupportsLegacyCore()) {
$reader = $this->getLegacyAnnotationReader();
} else {
$reader = $this->getStandardAnnotationReader();
}
return $reader;
} | [
"protected",
"function",
"getAnnotationReader",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"packageSupportsLegacyCore",
"(",
")",
")",
"{",
"$",
"reader",
"=",
"$",
"this",
"->",
"getLegacyAnnotationReader",
"(",
")",
";",
"}",
"else",
"{",
"$",
"reader",
"=",
"$",
"this",
"->",
"getStandardAnnotationReader",
"(",
")",
";",
"}",
"return",
"$",
"reader",
";",
"}"
] | Get the correct AnnotationReader based on the packages support for LegacyCore
@return \Doctrine\Common\Annotations\CachedReader | [
"Get",
"the",
"correct",
"AnnotationReader",
"based",
"on",
"the",
"packages",
"support",
"for",
"LegacyCore"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Database/EntityManager/Provider/AbstractPackageProvider.php#L61-L69 | train |
concrete5/concrete5 | concrete/src/User/User.php | User.recordLogin | public function recordLogin()
{
$app = Application::getFacadeApplication();
$db = $app['database']->connection();
$uLastLogin = $db->getOne("select uLastLogin from Users where uID = ?", array($this->uID));
/** @var \Concrete\Core\Permission\IPService $iph */
$iph = $app->make('helper/validation/ip');
$ip = $iph->getRequestIP();
$db->query("update Users set uLastIP = ?, uLastLogin = ?, uPreviousLogin = ?, uNumLogins = uNumLogins + 1 where uID = ?", array(($ip === false) ? ('') : ($ip->getIp()), time(), $uLastLogin, $this->uID));
} | php | public function recordLogin()
{
$app = Application::getFacadeApplication();
$db = $app['database']->connection();
$uLastLogin = $db->getOne("select uLastLogin from Users where uID = ?", array($this->uID));
/** @var \Concrete\Core\Permission\IPService $iph */
$iph = $app->make('helper/validation/ip');
$ip = $iph->getRequestIP();
$db->query("update Users set uLastIP = ?, uLastLogin = ?, uPreviousLogin = ?, uNumLogins = uNumLogins + 1 where uID = ?", array(($ip === false) ? ('') : ($ip->getIp()), time(), $uLastLogin, $this->uID));
} | [
"public",
"function",
"recordLogin",
"(",
")",
"{",
"$",
"app",
"=",
"Application",
"::",
"getFacadeApplication",
"(",
")",
";",
"$",
"db",
"=",
"$",
"app",
"[",
"'database'",
"]",
"->",
"connection",
"(",
")",
";",
"$",
"uLastLogin",
"=",
"$",
"db",
"->",
"getOne",
"(",
"\"select uLastLogin from Users where uID = ?\"",
",",
"array",
"(",
"$",
"this",
"->",
"uID",
")",
")",
";",
"/** @var \\Concrete\\Core\\Permission\\IPService $iph */",
"$",
"iph",
"=",
"$",
"app",
"->",
"make",
"(",
"'helper/validation/ip'",
")",
";",
"$",
"ip",
"=",
"$",
"iph",
"->",
"getRequestIP",
"(",
")",
";",
"$",
"db",
"->",
"query",
"(",
"\"update Users set uLastIP = ?, uLastLogin = ?, uPreviousLogin = ?, uNumLogins = uNumLogins + 1 where uID = ?\"",
",",
"array",
"(",
"(",
"$",
"ip",
"===",
"false",
")",
"?",
"(",
"''",
")",
":",
"(",
"$",
"ip",
"->",
"getIp",
"(",
")",
")",
",",
"time",
"(",
")",
",",
"$",
"uLastLogin",
",",
"$",
"this",
"->",
"uID",
")",
")",
";",
"}"
] | Increment number of logins and update login timestamps.
@throws \Exception | [
"Increment",
"number",
"of",
"logins",
"and",
"update",
"login",
"timestamps",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/User.php#L271-L281 | train |
concrete5/concrete5 | concrete/src/User/User.php | User.setUserDefaultLanguage | public function setUserDefaultLanguage($lang)
{
$app = Application::getFacadeApplication();
$db = $app['database']->connection();
$session = $app['session'];
$this->uDefaultLanguage = $lang;
$session->set('uDefaultLanguage', $lang);
$db->Execute('update Users set uDefaultLanguage = ? where uID = ?', array($lang, $this->getUserID()));
} | php | public function setUserDefaultLanguage($lang)
{
$app = Application::getFacadeApplication();
$db = $app['database']->connection();
$session = $app['session'];
$this->uDefaultLanguage = $lang;
$session->set('uDefaultLanguage', $lang);
$db->Execute('update Users set uDefaultLanguage = ? where uID = ?', array($lang, $this->getUserID()));
} | [
"public",
"function",
"setUserDefaultLanguage",
"(",
"$",
"lang",
")",
"{",
"$",
"app",
"=",
"Application",
"::",
"getFacadeApplication",
"(",
")",
";",
"$",
"db",
"=",
"$",
"app",
"[",
"'database'",
"]",
"->",
"connection",
"(",
")",
";",
"$",
"session",
"=",
"$",
"app",
"[",
"'session'",
"]",
";",
"$",
"this",
"->",
"uDefaultLanguage",
"=",
"$",
"lang",
";",
"$",
"session",
"->",
"set",
"(",
"'uDefaultLanguage'",
",",
"$",
"lang",
")",
";",
"$",
"db",
"->",
"Execute",
"(",
"'update Users set uDefaultLanguage = ? where uID = ?'",
",",
"array",
"(",
"$",
"lang",
",",
"$",
"this",
"->",
"getUserID",
"(",
")",
")",
")",
";",
"}"
] | Sets a default language for a user record.
@param string $lang | [
"Sets",
"a",
"default",
"language",
"for",
"a",
"user",
"record",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/User.php#L531-L540 | train |
concrete5/concrete5 | concrete/src/User/User.php | User.getUserLanguageToDisplay | public function getUserLanguageToDisplay()
{
if ($this->getUserDefaultLanguage() != '') {
return $this->getUserDefaultLanguage();
} else {
$app = Application::getFacadeApplication();
$config = $app['config'];
return $config->get('concrete.locale');
}
} | php | public function getUserLanguageToDisplay()
{
if ($this->getUserDefaultLanguage() != '') {
return $this->getUserDefaultLanguage();
} else {
$app = Application::getFacadeApplication();
$config = $app['config'];
return $config->get('concrete.locale');
}
} | [
"public",
"function",
"getUserLanguageToDisplay",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getUserDefaultLanguage",
"(",
")",
"!=",
"''",
")",
"{",
"return",
"$",
"this",
"->",
"getUserDefaultLanguage",
"(",
")",
";",
"}",
"else",
"{",
"$",
"app",
"=",
"Application",
"::",
"getFacadeApplication",
"(",
")",
";",
"$",
"config",
"=",
"$",
"app",
"[",
"'config'",
"]",
";",
"return",
"$",
"config",
"->",
"get",
"(",
"'concrete.locale'",
")",
";",
"}",
"}"
] | Checks to see if the current user object is registered. If so, it queries that records
default language. Otherwise, it falls back to sitewide settings.
@return string | [
"Checks",
"to",
"see",
"if",
"the",
"current",
"user",
"object",
"is",
"registered",
".",
"If",
"so",
"it",
"queries",
"that",
"records",
"default",
"language",
".",
"Otherwise",
"it",
"falls",
"back",
"to",
"sitewide",
"settings",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/User.php#L568-L578 | train |
concrete5/concrete5 | concrete/src/User/User.php | User.inGroup | public function inGroup($g)
{
$app = Application::getFacadeApplication();
$db = $app['database']->connection();
$v = array($this->uID);
$cnt = $db->GetOne("select Groups.gID from UserGroups inner join " . $db->getDatabasePlatform()->quoteSingleIdentifier('Groups') . " on UserGroups.gID = Groups.gID where uID = ? and gPath like " . $db->quote($g->getGroupPath() . '%'), $v);
return $cnt > 0;
} | php | public function inGroup($g)
{
$app = Application::getFacadeApplication();
$db = $app['database']->connection();
$v = array($this->uID);
$cnt = $db->GetOne("select Groups.gID from UserGroups inner join " . $db->getDatabasePlatform()->quoteSingleIdentifier('Groups') . " on UserGroups.gID = Groups.gID where uID = ? and gPath like " . $db->quote($g->getGroupPath() . '%'), $v);
return $cnt > 0;
} | [
"public",
"function",
"inGroup",
"(",
"$",
"g",
")",
"{",
"$",
"app",
"=",
"Application",
"::",
"getFacadeApplication",
"(",
")",
";",
"$",
"db",
"=",
"$",
"app",
"[",
"'database'",
"]",
"->",
"connection",
"(",
")",
";",
"$",
"v",
"=",
"array",
"(",
"$",
"this",
"->",
"uID",
")",
";",
"$",
"cnt",
"=",
"$",
"db",
"->",
"GetOne",
"(",
"\"select Groups.gID from UserGroups inner join \"",
".",
"$",
"db",
"->",
"getDatabasePlatform",
"(",
")",
"->",
"quoteSingleIdentifier",
"(",
"'Groups'",
")",
".",
"\" on UserGroups.gID = Groups.gID where uID = ? and gPath like \"",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"g",
"->",
"getGroupPath",
"(",
")",
".",
"'%'",
")",
",",
"$",
"v",
")",
";",
"return",
"$",
"cnt",
">",
"0",
";",
"}"
] | Return true if user is in Group.
@param Group $g
@return bool | [
"Return",
"true",
"if",
"user",
"is",
"in",
"Group",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/User.php#L740-L749 | train |
concrete5/concrete5 | concrete/src/User/User.php | User.loadCollectionEdit | public function loadCollectionEdit(&$c)
{
$c->refreshCache();
// can only load one page into edit mode at a time.
if ($c->isCheckedOut()) {
return false;
}
$app = Application::getFacadeApplication();
$db = $app['database']->connection();
$cID = $c->getCollectionID();
// first, we check to see if we have a collection in edit mode. If we do, we relinquish it
$this->unloadCollectionEdit(false);
$q = 'select cIsCheckedOut, cCheckedOutDatetime from Pages where cID = ?';
$r = $db->executeQuery($q, array($cID));
if ($r) {
$row = $r->fetchRow();
if (!$row['cIsCheckedOut']) {
$app['session']->set('editCID', $cID);
$uID = $this->getUserID();
$dh = $app->make('helper/date');
$datetime = $dh->getOverridableNow();
$q2 = 'update Pages set cIsCheckedOut = ?, cCheckedOutUID = ?, cCheckedOutDatetime = ?, cCheckedOutDatetimeLastEdit = ? where cID = ?';
$r2 = $db->executeQuery($q2, array(1, $uID, $datetime, $datetime, $cID));
$c->cIsCheckedOut = 1;
$c->cCheckedOutUID = $uID;
$c->cCheckedOutDatetime = $datetime;
$c->cCheckedOutDatetimeLastEdit = $datetime;
}
}
return true;
} | php | public function loadCollectionEdit(&$c)
{
$c->refreshCache();
// can only load one page into edit mode at a time.
if ($c->isCheckedOut()) {
return false;
}
$app = Application::getFacadeApplication();
$db = $app['database']->connection();
$cID = $c->getCollectionID();
// first, we check to see if we have a collection in edit mode. If we do, we relinquish it
$this->unloadCollectionEdit(false);
$q = 'select cIsCheckedOut, cCheckedOutDatetime from Pages where cID = ?';
$r = $db->executeQuery($q, array($cID));
if ($r) {
$row = $r->fetchRow();
if (!$row['cIsCheckedOut']) {
$app['session']->set('editCID', $cID);
$uID = $this->getUserID();
$dh = $app->make('helper/date');
$datetime = $dh->getOverridableNow();
$q2 = 'update Pages set cIsCheckedOut = ?, cCheckedOutUID = ?, cCheckedOutDatetime = ?, cCheckedOutDatetimeLastEdit = ? where cID = ?';
$r2 = $db->executeQuery($q2, array(1, $uID, $datetime, $datetime, $cID));
$c->cIsCheckedOut = 1;
$c->cCheckedOutUID = $uID;
$c->cCheckedOutDatetime = $datetime;
$c->cCheckedOutDatetimeLastEdit = $datetime;
}
}
return true;
} | [
"public",
"function",
"loadCollectionEdit",
"(",
"&",
"$",
"c",
")",
"{",
"$",
"c",
"->",
"refreshCache",
"(",
")",
";",
"// can only load one page into edit mode at a time.",
"if",
"(",
"$",
"c",
"->",
"isCheckedOut",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"app",
"=",
"Application",
"::",
"getFacadeApplication",
"(",
")",
";",
"$",
"db",
"=",
"$",
"app",
"[",
"'database'",
"]",
"->",
"connection",
"(",
")",
";",
"$",
"cID",
"=",
"$",
"c",
"->",
"getCollectionID",
"(",
")",
";",
"// first, we check to see if we have a collection in edit mode. If we do, we relinquish it",
"$",
"this",
"->",
"unloadCollectionEdit",
"(",
"false",
")",
";",
"$",
"q",
"=",
"'select cIsCheckedOut, cCheckedOutDatetime from Pages where cID = ?'",
";",
"$",
"r",
"=",
"$",
"db",
"->",
"executeQuery",
"(",
"$",
"q",
",",
"array",
"(",
"$",
"cID",
")",
")",
";",
"if",
"(",
"$",
"r",
")",
"{",
"$",
"row",
"=",
"$",
"r",
"->",
"fetchRow",
"(",
")",
";",
"if",
"(",
"!",
"$",
"row",
"[",
"'cIsCheckedOut'",
"]",
")",
"{",
"$",
"app",
"[",
"'session'",
"]",
"->",
"set",
"(",
"'editCID'",
",",
"$",
"cID",
")",
";",
"$",
"uID",
"=",
"$",
"this",
"->",
"getUserID",
"(",
")",
";",
"$",
"dh",
"=",
"$",
"app",
"->",
"make",
"(",
"'helper/date'",
")",
";",
"$",
"datetime",
"=",
"$",
"dh",
"->",
"getOverridableNow",
"(",
")",
";",
"$",
"q2",
"=",
"'update Pages set cIsCheckedOut = ?, cCheckedOutUID = ?, cCheckedOutDatetime = ?, cCheckedOutDatetimeLastEdit = ? where cID = ?'",
";",
"$",
"r2",
"=",
"$",
"db",
"->",
"executeQuery",
"(",
"$",
"q2",
",",
"array",
"(",
"1",
",",
"$",
"uID",
",",
"$",
"datetime",
",",
"$",
"datetime",
",",
"$",
"cID",
")",
")",
";",
"$",
"c",
"->",
"cIsCheckedOut",
"=",
"1",
";",
"$",
"c",
"->",
"cCheckedOutUID",
"=",
"$",
"uID",
";",
"$",
"c",
"->",
"cCheckedOutDatetime",
"=",
"$",
"datetime",
";",
"$",
"c",
"->",
"cCheckedOutDatetimeLastEdit",
"=",
"$",
"datetime",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Loads a page in edit mode.
@param Page $c
@return bool | [
"Loads",
"a",
"page",
"in",
"edit",
"mode",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/User.php#L771-L807 | train |
concrete5/concrete5 | concrete/src/User/User.php | User.persist | public function persist($cache_interface = true)
{
$this->refreshUserGroups();
$app = Application::getFacadeApplication();
/** @var \Symfony\Component\HttpFoundation\Session\Session $session */
$session = $app['session'];
$session->set('uID', $this->getUserID());
$session->set('uName', $this->getUserName());
$session->set('uBlockTypesSet', false);
$session->set('uGroups', $this->getUserGroups());
$session->set('uLastOnline', $this->getLastOnline());
$session->set('uTimezone', $this->getUserTimezone());
$session->set('uDefaultLanguage', $this->getUserDefaultLanguage());
$session->set('uLastPasswordChange', $this->getLastPasswordChange());
$cookie = $app['cookie'];
$cookie->set(sprintf('%s_LOGIN', $app['config']->get('concrete.session.name')), 1);
if ($cache_interface) {
$app->make('helper/concrete/ui')->cacheInterfaceItems();
}
} | php | public function persist($cache_interface = true)
{
$this->refreshUserGroups();
$app = Application::getFacadeApplication();
/** @var \Symfony\Component\HttpFoundation\Session\Session $session */
$session = $app['session'];
$session->set('uID', $this->getUserID());
$session->set('uName', $this->getUserName());
$session->set('uBlockTypesSet', false);
$session->set('uGroups', $this->getUserGroups());
$session->set('uLastOnline', $this->getLastOnline());
$session->set('uTimezone', $this->getUserTimezone());
$session->set('uDefaultLanguage', $this->getUserDefaultLanguage());
$session->set('uLastPasswordChange', $this->getLastPasswordChange());
$cookie = $app['cookie'];
$cookie->set(sprintf('%s_LOGIN', $app['config']->get('concrete.session.name')), 1);
if ($cache_interface) {
$app->make('helper/concrete/ui')->cacheInterfaceItems();
}
} | [
"public",
"function",
"persist",
"(",
"$",
"cache_interface",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"refreshUserGroups",
"(",
")",
";",
"$",
"app",
"=",
"Application",
"::",
"getFacadeApplication",
"(",
")",
";",
"/** @var \\Symfony\\Component\\HttpFoundation\\Session\\Session $session */",
"$",
"session",
"=",
"$",
"app",
"[",
"'session'",
"]",
";",
"$",
"session",
"->",
"set",
"(",
"'uID'",
",",
"$",
"this",
"->",
"getUserID",
"(",
")",
")",
";",
"$",
"session",
"->",
"set",
"(",
"'uName'",
",",
"$",
"this",
"->",
"getUserName",
"(",
")",
")",
";",
"$",
"session",
"->",
"set",
"(",
"'uBlockTypesSet'",
",",
"false",
")",
";",
"$",
"session",
"->",
"set",
"(",
"'uGroups'",
",",
"$",
"this",
"->",
"getUserGroups",
"(",
")",
")",
";",
"$",
"session",
"->",
"set",
"(",
"'uLastOnline'",
",",
"$",
"this",
"->",
"getLastOnline",
"(",
")",
")",
";",
"$",
"session",
"->",
"set",
"(",
"'uTimezone'",
",",
"$",
"this",
"->",
"getUserTimezone",
"(",
")",
")",
";",
"$",
"session",
"->",
"set",
"(",
"'uDefaultLanguage'",
",",
"$",
"this",
"->",
"getUserDefaultLanguage",
"(",
")",
")",
";",
"$",
"session",
"->",
"set",
"(",
"'uLastPasswordChange'",
",",
"$",
"this",
"->",
"getLastPasswordChange",
"(",
")",
")",
";",
"$",
"cookie",
"=",
"$",
"app",
"[",
"'cookie'",
"]",
";",
"$",
"cookie",
"->",
"set",
"(",
"sprintf",
"(",
"'%s_LOGIN'",
",",
"$",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'concrete.session.name'",
")",
")",
",",
"1",
")",
";",
"if",
"(",
"$",
"cache_interface",
")",
"{",
"$",
"app",
"->",
"make",
"(",
"'helper/concrete/ui'",
")",
"->",
"cacheInterfaceItems",
"(",
")",
";",
"}",
"}"
] | Manage user session writing.
@param bool $cache_interface | [
"Manage",
"user",
"session",
"writing",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/User.php#L937-L960 | train |
concrete5/concrete5 | concrete/src/Conversation/Rating/Type.php | Type.getList | public static function getList()
{
$db = Database::connection();
$handles = $db->GetCol('select cnvRatingTypeHandle from ConversationRatingTypes order by cnvRatingTypeHandle asc');
$types = array();
foreach ($handles as $handle) {
$ratingType = static::getByHandle($handle);
if (is_object($ratingType)) {
$types[] = $ratingType;
}
}
return $types;
} | php | public static function getList()
{
$db = Database::connection();
$handles = $db->GetCol('select cnvRatingTypeHandle from ConversationRatingTypes order by cnvRatingTypeHandle asc');
$types = array();
foreach ($handles as $handle) {
$ratingType = static::getByHandle($handle);
if (is_object($ratingType)) {
$types[] = $ratingType;
}
}
return $types;
} | [
"public",
"static",
"function",
"getList",
"(",
")",
"{",
"$",
"db",
"=",
"Database",
"::",
"connection",
"(",
")",
";",
"$",
"handles",
"=",
"$",
"db",
"->",
"GetCol",
"(",
"'select cnvRatingTypeHandle from ConversationRatingTypes order by cnvRatingTypeHandle asc'",
")",
";",
"$",
"types",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"handles",
"as",
"$",
"handle",
")",
"{",
"$",
"ratingType",
"=",
"static",
"::",
"getByHandle",
"(",
"$",
"handle",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"ratingType",
")",
")",
"{",
"$",
"types",
"[",
"]",
"=",
"$",
"ratingType",
";",
"}",
"}",
"return",
"$",
"types",
";",
"}"
] | Returns the list of all conversation rating types
@return array[Type] | [
"Returns",
"the",
"list",
"of",
"all",
"conversation",
"rating",
"types"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Conversation/Rating/Type.php#L27-L40 | train |
concrete5/concrete5 | concrete/src/Activity/Newsflow.php | Newsflow.getEditionByID | public function getEditionByID($cID)
{
if (!$this->hasConnectionError()) {
$fileService = new File();
$appVersion = Config::get('concrete.version');
$cfToken = Marketplace::getSiteToken();
$path = Config::get('concrete.urls.newsflow') . '/' . DISPATCHER_FILENAME . '/?_ccm_view_external=1&appVersion=' . $appVersion . '&cID=' . rawurlencode($cID) . '&cfToken=' . rawurlencode($cfToken);
$response = $fileService->getContents($path);
$ni = new NewsflowItem();
$obj = $ni->parseResponse($response);
return $obj;
}
return false;
} | php | public function getEditionByID($cID)
{
if (!$this->hasConnectionError()) {
$fileService = new File();
$appVersion = Config::get('concrete.version');
$cfToken = Marketplace::getSiteToken();
$path = Config::get('concrete.urls.newsflow') . '/' . DISPATCHER_FILENAME . '/?_ccm_view_external=1&appVersion=' . $appVersion . '&cID=' . rawurlencode($cID) . '&cfToken=' . rawurlencode($cfToken);
$response = $fileService->getContents($path);
$ni = new NewsflowItem();
$obj = $ni->parseResponse($response);
return $obj;
}
return false;
} | [
"public",
"function",
"getEditionByID",
"(",
"$",
"cID",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasConnectionError",
"(",
")",
")",
"{",
"$",
"fileService",
"=",
"new",
"File",
"(",
")",
";",
"$",
"appVersion",
"=",
"Config",
"::",
"get",
"(",
"'concrete.version'",
")",
";",
"$",
"cfToken",
"=",
"Marketplace",
"::",
"getSiteToken",
"(",
")",
";",
"$",
"path",
"=",
"Config",
"::",
"get",
"(",
"'concrete.urls.newsflow'",
")",
".",
"'/'",
".",
"DISPATCHER_FILENAME",
".",
"'/?_ccm_view_external=1&appVersion='",
".",
"$",
"appVersion",
".",
"'&cID='",
".",
"rawurlencode",
"(",
"$",
"cID",
")",
".",
"'&cfToken='",
".",
"rawurlencode",
"(",
"$",
"cfToken",
")",
";",
"$",
"response",
"=",
"$",
"fileService",
"->",
"getContents",
"(",
"$",
"path",
")",
";",
"$",
"ni",
"=",
"new",
"NewsflowItem",
"(",
")",
";",
"$",
"obj",
"=",
"$",
"ni",
"->",
"parseResponse",
"(",
"$",
"response",
")",
";",
"return",
"$",
"obj",
";",
"}",
"return",
"false",
";",
"}"
] | Retrieves a NewsflowItem object for a given collection ID.
@param int $cID
@return bool|NewsflowItem Returns a NewsflowItem object, false if there was an error or one could not be located. | [
"Retrieves",
"a",
"NewsflowItem",
"object",
"for",
"a",
"given",
"collection",
"ID",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Activity/Newsflow.php#L69-L84 | train |
concrete5/concrete5 | concrete/src/Activity/Newsflow.php | Newsflow.getSlotContents | public function getSlotContents()
{
if ($this->slots === null) {
$fileService = new File();
$appVersion = Config::get('concrete.version');
$cfToken = Marketplace::getSiteToken();
$url = Config::get('concrete.urls.newsflow') . Config::get('concrete.urls.paths.newsflow_slot_content');
$path = $url . '?cfToken=' . rawurlencode($cfToken) . '&appVersion=' . $appVersion;
$response = $fileService->getContents($path);
$nsi = new NewsflowSlotItem();
$this->slots = $nsi->parseResponse($response);
}
return $this->slots;
} | php | public function getSlotContents()
{
if ($this->slots === null) {
$fileService = new File();
$appVersion = Config::get('concrete.version');
$cfToken = Marketplace::getSiteToken();
$url = Config::get('concrete.urls.newsflow') . Config::get('concrete.urls.paths.newsflow_slot_content');
$path = $url . '?cfToken=' . rawurlencode($cfToken) . '&appVersion=' . $appVersion;
$response = $fileService->getContents($path);
$nsi = new NewsflowSlotItem();
$this->slots = $nsi->parseResponse($response);
}
return $this->slots;
} | [
"public",
"function",
"getSlotContents",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"slots",
"===",
"null",
")",
"{",
"$",
"fileService",
"=",
"new",
"File",
"(",
")",
";",
"$",
"appVersion",
"=",
"Config",
"::",
"get",
"(",
"'concrete.version'",
")",
";",
"$",
"cfToken",
"=",
"Marketplace",
"::",
"getSiteToken",
"(",
")",
";",
"$",
"url",
"=",
"Config",
"::",
"get",
"(",
"'concrete.urls.newsflow'",
")",
".",
"Config",
"::",
"get",
"(",
"'concrete.urls.paths.newsflow_slot_content'",
")",
";",
"$",
"path",
"=",
"$",
"url",
".",
"'?cfToken='",
".",
"rawurlencode",
"(",
"$",
"cfToken",
")",
".",
"'&appVersion='",
".",
"$",
"appVersion",
";",
"$",
"response",
"=",
"$",
"fileService",
"->",
"getContents",
"(",
"$",
"path",
")",
";",
"$",
"nsi",
"=",
"new",
"NewsflowSlotItem",
"(",
")",
";",
"$",
"this",
"->",
"slots",
"=",
"$",
"nsi",
"->",
"parseResponse",
"(",
"$",
"response",
")",
";",
"}",
"return",
"$",
"this",
"->",
"slots",
";",
"}"
] | Retrieves an array of NewsflowSlotItems.
@return NewsflowSlotItem[]|null | [
"Retrieves",
"an",
"array",
"of",
"NewsflowSlotItems",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Activity/Newsflow.php#L116-L130 | train |
concrete5/concrete5 | concrete/src/Asset/Asset.php | Asset.getAssetContentsByRoute | protected static function getAssetContentsByRoute($route)
{
$result = null;
try {
$app = Application::getFacadeApplication();
$router = $app->make(RouterInterface::class);
$context = new RequestContext();
$context->fromRequest($app->make(Request::class));
$context->setMethod('GET');
$matched = $router->getRouteByPath($route, $context);
$controller = $matched->getAction();
$callable = null;
if (is_string($controller)) {
$chunks = explode('::', $controller, 2);
if (count($chunks) === 2) {
if (class_exists($chunks[0])) {
$array = [$app->make($chunks[0]), $chunks[1]];
if (is_callable($array)) {
$callable = $array;
}
}
} else {
if (class_exists($controller) && method_exists($controller, '__invoke')) {
$callable = $app->make($controller);
}
}
} elseif (is_callable($controller)) {
$callable = $controller;
}
if ($callable !== null) {
ob_start();
$r = call_user_func($callable, false);
if ($r instanceof Response) {
$result = $r->getContent();
} elseif ($r !== false) {
$result = ob_get_contents();
}
ob_end_clean();
}
} catch (Exception $x) {
}
return $result;
} | php | protected static function getAssetContentsByRoute($route)
{
$result = null;
try {
$app = Application::getFacadeApplication();
$router = $app->make(RouterInterface::class);
$context = new RequestContext();
$context->fromRequest($app->make(Request::class));
$context->setMethod('GET');
$matched = $router->getRouteByPath($route, $context);
$controller = $matched->getAction();
$callable = null;
if (is_string($controller)) {
$chunks = explode('::', $controller, 2);
if (count($chunks) === 2) {
if (class_exists($chunks[0])) {
$array = [$app->make($chunks[0]), $chunks[1]];
if (is_callable($array)) {
$callable = $array;
}
}
} else {
if (class_exists($controller) && method_exists($controller, '__invoke')) {
$callable = $app->make($controller);
}
}
} elseif (is_callable($controller)) {
$callable = $controller;
}
if ($callable !== null) {
ob_start();
$r = call_user_func($callable, false);
if ($r instanceof Response) {
$result = $r->getContent();
} elseif ($r !== false) {
$result = ob_get_contents();
}
ob_end_clean();
}
} catch (Exception $x) {
}
return $result;
} | [
"protected",
"static",
"function",
"getAssetContentsByRoute",
"(",
"$",
"route",
")",
"{",
"$",
"result",
"=",
"null",
";",
"try",
"{",
"$",
"app",
"=",
"Application",
"::",
"getFacadeApplication",
"(",
")",
";",
"$",
"router",
"=",
"$",
"app",
"->",
"make",
"(",
"RouterInterface",
"::",
"class",
")",
";",
"$",
"context",
"=",
"new",
"RequestContext",
"(",
")",
";",
"$",
"context",
"->",
"fromRequest",
"(",
"$",
"app",
"->",
"make",
"(",
"Request",
"::",
"class",
")",
")",
";",
"$",
"context",
"->",
"setMethod",
"(",
"'GET'",
")",
";",
"$",
"matched",
"=",
"$",
"router",
"->",
"getRouteByPath",
"(",
"$",
"route",
",",
"$",
"context",
")",
";",
"$",
"controller",
"=",
"$",
"matched",
"->",
"getAction",
"(",
")",
";",
"$",
"callable",
"=",
"null",
";",
"if",
"(",
"is_string",
"(",
"$",
"controller",
")",
")",
"{",
"$",
"chunks",
"=",
"explode",
"(",
"'::'",
",",
"$",
"controller",
",",
"2",
")",
";",
"if",
"(",
"count",
"(",
"$",
"chunks",
")",
"===",
"2",
")",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"chunks",
"[",
"0",
"]",
")",
")",
"{",
"$",
"array",
"=",
"[",
"$",
"app",
"->",
"make",
"(",
"$",
"chunks",
"[",
"0",
"]",
")",
",",
"$",
"chunks",
"[",
"1",
"]",
"]",
";",
"if",
"(",
"is_callable",
"(",
"$",
"array",
")",
")",
"{",
"$",
"callable",
"=",
"$",
"array",
";",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"controller",
")",
"&&",
"method_exists",
"(",
"$",
"controller",
",",
"'__invoke'",
")",
")",
"{",
"$",
"callable",
"=",
"$",
"app",
"->",
"make",
"(",
"$",
"controller",
")",
";",
"}",
"}",
"}",
"elseif",
"(",
"is_callable",
"(",
"$",
"controller",
")",
")",
"{",
"$",
"callable",
"=",
"$",
"controller",
";",
"}",
"if",
"(",
"$",
"callable",
"!==",
"null",
")",
"{",
"ob_start",
"(",
")",
";",
"$",
"r",
"=",
"call_user_func",
"(",
"$",
"callable",
",",
"false",
")",
";",
"if",
"(",
"$",
"r",
"instanceof",
"Response",
")",
"{",
"$",
"result",
"=",
"$",
"r",
"->",
"getContent",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"r",
"!==",
"false",
")",
"{",
"$",
"result",
"=",
"ob_get_contents",
"(",
")",
";",
"}",
"ob_end_clean",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"x",
")",
"{",
"}",
"return",
"$",
"result",
";",
"}"
] | Get the contents of an asset given its route.
@param string $route
@return string|null | [
"Get",
"the",
"contents",
"of",
"an",
"asset",
"given",
"its",
"route",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Asset/Asset.php#L496-L539 | train |
concrete5/concrete5 | concrete/src/Http/DefaultServer.php | DefaultServer.addMiddleware | public function addMiddleware(MiddlewareInterface $middleware, $priority = 10)
{
$this->stack = $this->stack->withMiddleware($middleware, $priority);
return $this;
} | php | public function addMiddleware(MiddlewareInterface $middleware, $priority = 10)
{
$this->stack = $this->stack->withMiddleware($middleware, $priority);
return $this;
} | [
"public",
"function",
"addMiddleware",
"(",
"MiddlewareInterface",
"$",
"middleware",
",",
"$",
"priority",
"=",
"10",
")",
"{",
"$",
"this",
"->",
"stack",
"=",
"$",
"this",
"->",
"stack",
"->",
"withMiddleware",
"(",
"$",
"middleware",
",",
"$",
"priority",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add a middleware to the stack
@param \Concrete\Core\Http\Middleware\MiddlewareInterface $middleware
@param int $priority
@return self | [
"Add",
"a",
"middleware",
"to",
"the",
"stack"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Http/DefaultServer.php#L56-L60 | train |
concrete5/concrete5 | concrete/src/Http/DefaultServer.php | DefaultServer.removeMiddleware | public function removeMiddleware(MiddlewareInterface $middleware)
{
$this->stack = $this->stack->withoutMiddleware($middleware);
return $this;
} | php | public function removeMiddleware(MiddlewareInterface $middleware)
{
$this->stack = $this->stack->withoutMiddleware($middleware);
return $this;
} | [
"public",
"function",
"removeMiddleware",
"(",
"MiddlewareInterface",
"$",
"middleware",
")",
"{",
"$",
"this",
"->",
"stack",
"=",
"$",
"this",
"->",
"stack",
"->",
"withoutMiddleware",
"(",
"$",
"middleware",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Remove a middleware from the stack
@param \Concrete\Core\Http\Middleware\MiddlewareInterface $middleware
@return self | [
"Remove",
"a",
"middleware",
"from",
"the",
"stack"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Http/DefaultServer.php#L67-L71 | train |
concrete5/concrete5 | concrete/src/Http/DefaultServer.php | DefaultServer.handleRequest | public function handleRequest(SymfonyRequest $request)
{
$stack = $this->stack;
if ($stack instanceof MiddlewareStack) {
$stack = $stack->withDispatcher($this->app->make(DispatcherDelegate::class, [$this->dispatcher]));
}
return $stack->process($request);
} | php | public function handleRequest(SymfonyRequest $request)
{
$stack = $this->stack;
if ($stack instanceof MiddlewareStack) {
$stack = $stack->withDispatcher($this->app->make(DispatcherDelegate::class, [$this->dispatcher]));
}
return $stack->process($request);
} | [
"public",
"function",
"handleRequest",
"(",
"SymfonyRequest",
"$",
"request",
")",
"{",
"$",
"stack",
"=",
"$",
"this",
"->",
"stack",
";",
"if",
"(",
"$",
"stack",
"instanceof",
"MiddlewareStack",
")",
"{",
"$",
"stack",
"=",
"$",
"stack",
"->",
"withDispatcher",
"(",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"DispatcherDelegate",
"::",
"class",
",",
"[",
"$",
"this",
"->",
"dispatcher",
"]",
")",
")",
";",
"}",
"return",
"$",
"stack",
"->",
"process",
"(",
"$",
"request",
")",
";",
"}"
] | Take a request and pass it through middleware, then return the response
@param SymfonyRequest $request
@return SymfonyResponse | [
"Take",
"a",
"request",
"and",
"pass",
"it",
"through",
"middleware",
"then",
"return",
"the",
"response"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Http/DefaultServer.php#L78-L86 | train |
concrete5/concrete5 | concrete/src/Page/Stack/UsageTracker.php | UsageTracker.forgetCollection | private function forgetCollection(Collection $collection)
{
$query_builder = $this->manager->createQueryBuilder();
$query_builder
->delete(StackUsageRecord::class, 'r')
->where('r.collection_id = :collection_id')
->setParameter('collection_id', $collection->getCollectionID())
->getQuery()->execute();
} | php | private function forgetCollection(Collection $collection)
{
$query_builder = $this->manager->createQueryBuilder();
$query_builder
->delete(StackUsageRecord::class, 'r')
->where('r.collection_id = :collection_id')
->setParameter('collection_id', $collection->getCollectionID())
->getQuery()->execute();
} | [
"private",
"function",
"forgetCollection",
"(",
"Collection",
"$",
"collection",
")",
"{",
"$",
"query_builder",
"=",
"$",
"this",
"->",
"manager",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"query_builder",
"->",
"delete",
"(",
"StackUsageRecord",
"::",
"class",
",",
"'r'",
")",
"->",
"where",
"(",
"'r.collection_id = :collection_id'",
")",
"->",
"setParameter",
"(",
"'collection_id'",
",",
"$",
"collection",
"->",
"getCollectionID",
"(",
")",
")",
"->",
"getQuery",
"(",
")",
"->",
"execute",
"(",
")",
";",
"}"
] | Forget about a collection object
@param \Concrete\Core\Page\Collection\Collection $collection | [
"Forget",
"about",
"a",
"collection",
"object"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Stack/UsageTracker.php#L96-L104 | train |
concrete5/concrete5 | concrete/src/Api/OAuth/Validator/DefaultValidator.php | DefaultValidator.validateAuthorization | public function validateAuthorization(ServerRequestInterface $request)
{
$user = $this->app->make(User::class);
// Allow logged in users to bypass API authentication entirely if the route allows it
// This functionality is NOT READY. We will not allow this yet.
/*
$route = $request->getAttribute('_route');
if ($user->checkLogin()) {
// Return the request with additional attributes
return $request
->withAttribute('oauth_access_token_id', null)
->withAttribute('oauth_client_id', null)
->withAttribute('oauth_user_id', null)
->withAttribute('oauth_scopes', 'session');
return $request;
}
*/
// Delegate the rest to the passed in validator
return $this->validator->validateAuthorization($request);
} | php | public function validateAuthorization(ServerRequestInterface $request)
{
$user = $this->app->make(User::class);
// Allow logged in users to bypass API authentication entirely if the route allows it
// This functionality is NOT READY. We will not allow this yet.
/*
$route = $request->getAttribute('_route');
if ($user->checkLogin()) {
// Return the request with additional attributes
return $request
->withAttribute('oauth_access_token_id', null)
->withAttribute('oauth_client_id', null)
->withAttribute('oauth_user_id', null)
->withAttribute('oauth_scopes', 'session');
return $request;
}
*/
// Delegate the rest to the passed in validator
return $this->validator->validateAuthorization($request);
} | [
"public",
"function",
"validateAuthorization",
"(",
"ServerRequestInterface",
"$",
"request",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"User",
"::",
"class",
")",
";",
"// Allow logged in users to bypass API authentication entirely if the route allows it",
"// This functionality is NOT READY. We will not allow this yet.",
"/*\n $route = $request->getAttribute('_route');\n\n if ($user->checkLogin()) {\n // Return the request with additional attributes\n return $request\n ->withAttribute('oauth_access_token_id', null)\n ->withAttribute('oauth_client_id', null)\n ->withAttribute('oauth_user_id', null)\n ->withAttribute('oauth_scopes', 'session');\n\n return $request;\n }\n */",
"// Delegate the rest to the passed in validator",
"return",
"$",
"this",
"->",
"validator",
"->",
"validateAuthorization",
"(",
"$",
"request",
")",
";",
"}"
] | Determine the access token in the authorization header and append OAUth properties to the request
as attributes.
@param ServerRequestInterface $request
@return ServerRequestInterface | [
"Determine",
"the",
"access",
"token",
"in",
"the",
"authorization",
"header",
"and",
"append",
"OAUth",
"properties",
"to",
"the",
"request",
"as",
"attributes",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Api/OAuth/Validator/DefaultValidator.php#L35-L58 | train |
concrete5/concrete5 | concrete/src/Workflow/Progress/Progress.php | Progress.getWorkflowObject | public function getWorkflowObject()
{
if ($this->wfID > 0) {
$wf = Workflow::getByID($this->wfID);
} else {
$wf = new EmptyWorkflow();
}
return $wf;
} | php | public function getWorkflowObject()
{
if ($this->wfID > 0) {
$wf = Workflow::getByID($this->wfID);
} else {
$wf = new EmptyWorkflow();
}
return $wf;
} | [
"public",
"function",
"getWorkflowObject",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"wfID",
">",
"0",
")",
"{",
"$",
"wf",
"=",
"Workflow",
"::",
"getByID",
"(",
"$",
"this",
"->",
"wfID",
")",
";",
"}",
"else",
"{",
"$",
"wf",
"=",
"new",
"EmptyWorkflow",
"(",
")",
";",
"}",
"return",
"$",
"wf",
";",
"}"
] | Gets the Workflow object attached to this WorkflowProgress object.
@return Workflow | [
"Gets",
"the",
"Workflow",
"object",
"attached",
"to",
"this",
"WorkflowProgress",
"object",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Workflow/Progress/Progress.php#L46-L55 | train |
concrete5/concrete5 | concrete/src/Workflow/Progress/Progress.php | Progress.getWorkflowRequestObject | public function getWorkflowRequestObject()
{
if ($this->wrID > 0) {
$cat = WorkflowProgressCategory::getByID($this->wpCategoryID);
$handle = $cat->getWorkflowProgressCategoryHandle();
$class = '\\Core\\Workflow\\Request\\' . Core::make('helper/text')->camelcase($handle) . 'Request';
$pkHandle = $cat->getPackageHandle();
$class = core_class($class, $pkHandle);
$wr = $class::getByID($this->wrID);
if (is_object($wr)) {
$wr->setCurrentWorkflowProgressObject($this);
return $wr;
}
}
} | php | public function getWorkflowRequestObject()
{
if ($this->wrID > 0) {
$cat = WorkflowProgressCategory::getByID($this->wpCategoryID);
$handle = $cat->getWorkflowProgressCategoryHandle();
$class = '\\Core\\Workflow\\Request\\' . Core::make('helper/text')->camelcase($handle) . 'Request';
$pkHandle = $cat->getPackageHandle();
$class = core_class($class, $pkHandle);
$wr = $class::getByID($this->wrID);
if (is_object($wr)) {
$wr->setCurrentWorkflowProgressObject($this);
return $wr;
}
}
} | [
"public",
"function",
"getWorkflowRequestObject",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"wrID",
">",
"0",
")",
"{",
"$",
"cat",
"=",
"WorkflowProgressCategory",
"::",
"getByID",
"(",
"$",
"this",
"->",
"wpCategoryID",
")",
";",
"$",
"handle",
"=",
"$",
"cat",
"->",
"getWorkflowProgressCategoryHandle",
"(",
")",
";",
"$",
"class",
"=",
"'\\\\Core\\\\Workflow\\\\Request\\\\'",
".",
"Core",
"::",
"make",
"(",
"'helper/text'",
")",
"->",
"camelcase",
"(",
"$",
"handle",
")",
".",
"'Request'",
";",
"$",
"pkHandle",
"=",
"$",
"cat",
"->",
"getPackageHandle",
"(",
")",
";",
"$",
"class",
"=",
"core_class",
"(",
"$",
"class",
",",
"$",
"pkHandle",
")",
";",
"$",
"wr",
"=",
"$",
"class",
"::",
"getByID",
"(",
"$",
"this",
"->",
"wrID",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"wr",
")",
")",
"{",
"$",
"wr",
"->",
"setCurrentWorkflowProgressObject",
"(",
"$",
"this",
")",
";",
"return",
"$",
"wr",
";",
"}",
"}",
"}"
] | Get the WorkflowRequest object for the current WorkflowProgress object.
@return WorkflowRequest | [
"Get",
"the",
"WorkflowRequest",
"object",
"for",
"the",
"current",
"WorkflowProgress",
"object",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Workflow/Progress/Progress.php#L117-L132 | train |
concrete5/concrete5 | concrete/src/Workflow/Progress/Progress.php | Progress.create | public static function create($wpCategoryHandle, Workflow $wf, WorkflowRequest $wr)
{
$db = Database::connection();
$wpDateAdded = Core::make('helper/date')->getOverridableNow();
$wpCategoryID = $db->fetchColumn('select wpCategoryID from WorkflowProgressCategories where wpCategoryHandle = ?', array($wpCategoryHandle));
$db->executeQuery('insert into WorkflowProgress (wfID, wrID, wpDateAdded, wpCategoryID) values (?, ?, ?, ?)', array(
$wf->getWorkflowID(), $wr->getWorkflowRequestID(), $wpDateAdded, $wpCategoryID,
));
$wp = self::getByID($db->lastInsertId());
$wp->addWorkflowProgressHistoryObject($wr);
if (!($wf instanceof EmptyWorkflow)) {
$application = \Core::getFacadeApplication();
$type = $application->make('manager/notification/types')->driver('workflow_progress');
$notifier = $type->getNotifier();
$subscription = $type->getSubscription($wp);
$notified = $notifier->getUsersToNotify($subscription, $wp);
$notification = $type->createNotification($wp);
$notifier->notify($notified, $notification);
}
return $wp;
} | php | public static function create($wpCategoryHandle, Workflow $wf, WorkflowRequest $wr)
{
$db = Database::connection();
$wpDateAdded = Core::make('helper/date')->getOverridableNow();
$wpCategoryID = $db->fetchColumn('select wpCategoryID from WorkflowProgressCategories where wpCategoryHandle = ?', array($wpCategoryHandle));
$db->executeQuery('insert into WorkflowProgress (wfID, wrID, wpDateAdded, wpCategoryID) values (?, ?, ?, ?)', array(
$wf->getWorkflowID(), $wr->getWorkflowRequestID(), $wpDateAdded, $wpCategoryID,
));
$wp = self::getByID($db->lastInsertId());
$wp->addWorkflowProgressHistoryObject($wr);
if (!($wf instanceof EmptyWorkflow)) {
$application = \Core::getFacadeApplication();
$type = $application->make('manager/notification/types')->driver('workflow_progress');
$notifier = $type->getNotifier();
$subscription = $type->getSubscription($wp);
$notified = $notifier->getUsersToNotify($subscription, $wp);
$notification = $type->createNotification($wp);
$notifier->notify($notified, $notification);
}
return $wp;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"wpCategoryHandle",
",",
"Workflow",
"$",
"wf",
",",
"WorkflowRequest",
"$",
"wr",
")",
"{",
"$",
"db",
"=",
"Database",
"::",
"connection",
"(",
")",
";",
"$",
"wpDateAdded",
"=",
"Core",
"::",
"make",
"(",
"'helper/date'",
")",
"->",
"getOverridableNow",
"(",
")",
";",
"$",
"wpCategoryID",
"=",
"$",
"db",
"->",
"fetchColumn",
"(",
"'select wpCategoryID from WorkflowProgressCategories where wpCategoryHandle = ?'",
",",
"array",
"(",
"$",
"wpCategoryHandle",
")",
")",
";",
"$",
"db",
"->",
"executeQuery",
"(",
"'insert into WorkflowProgress (wfID, wrID, wpDateAdded, wpCategoryID) values (?, ?, ?, ?)'",
",",
"array",
"(",
"$",
"wf",
"->",
"getWorkflowID",
"(",
")",
",",
"$",
"wr",
"->",
"getWorkflowRequestID",
"(",
")",
",",
"$",
"wpDateAdded",
",",
"$",
"wpCategoryID",
",",
")",
")",
";",
"$",
"wp",
"=",
"self",
"::",
"getByID",
"(",
"$",
"db",
"->",
"lastInsertId",
"(",
")",
")",
";",
"$",
"wp",
"->",
"addWorkflowProgressHistoryObject",
"(",
"$",
"wr",
")",
";",
"if",
"(",
"!",
"(",
"$",
"wf",
"instanceof",
"EmptyWorkflow",
")",
")",
"{",
"$",
"application",
"=",
"\\",
"Core",
"::",
"getFacadeApplication",
"(",
")",
";",
"$",
"type",
"=",
"$",
"application",
"->",
"make",
"(",
"'manager/notification/types'",
")",
"->",
"driver",
"(",
"'workflow_progress'",
")",
";",
"$",
"notifier",
"=",
"$",
"type",
"->",
"getNotifier",
"(",
")",
";",
"$",
"subscription",
"=",
"$",
"type",
"->",
"getSubscription",
"(",
"$",
"wp",
")",
";",
"$",
"notified",
"=",
"$",
"notifier",
"->",
"getUsersToNotify",
"(",
"$",
"subscription",
",",
"$",
"wp",
")",
";",
"$",
"notification",
"=",
"$",
"type",
"->",
"createNotification",
"(",
"$",
"wp",
")",
";",
"$",
"notifier",
"->",
"notify",
"(",
"$",
"notified",
",",
"$",
"notification",
")",
";",
"}",
"return",
"$",
"wp",
";",
"}"
] | Creates a WorkflowProgress object (which will be assigned to a Page, File, etc... in our system.
@param string $wpCategoryHandle
@param Workflow $wf
@param WorkflowRequest $wr
@return self | [
"Creates",
"a",
"WorkflowProgress",
"object",
"(",
"which",
"will",
"be",
"assigned",
"to",
"a",
"Page",
"File",
"etc",
"...",
"in",
"our",
"system",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Workflow/Progress/Progress.php#L151-L174 | train |
concrete5/concrete5 | concrete/src/Workflow/Progress/Progress.php | Progress.start | public function start()
{
$wf = $this->getWorkflowObject();
if (is_object($wf)) {
$r = $wf->start($this);
$this->updateOnAction($wf);
}
return $r;
} | php | public function start()
{
$wf = $this->getWorkflowObject();
if (is_object($wf)) {
$r = $wf->start($this);
$this->updateOnAction($wf);
}
return $r;
} | [
"public",
"function",
"start",
"(",
")",
"{",
"$",
"wf",
"=",
"$",
"this",
"->",
"getWorkflowObject",
"(",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"wf",
")",
")",
"{",
"$",
"r",
"=",
"$",
"wf",
"->",
"start",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"updateOnAction",
"(",
"$",
"wf",
")",
";",
"}",
"return",
"$",
"r",
";",
"}"
] | The function that is automatically run when a workflowprogress object is started. | [
"The",
"function",
"that",
"is",
"automatically",
"run",
"when",
"a",
"workflowprogress",
"object",
"is",
"started",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Workflow/Progress/Progress.php#L235-L244 | train |
concrete5/concrete5 | concrete/src/Workflow/Progress/Progress.php | Progress.runTask | public function runTask($task, $args = array())
{
$wf = $this->getWorkflowObject();
if (in_array($task, $wf->getAllowedTasks())) {
$wpr = call_user_func_array(array($wf, $task), array($this, $args));
$this->updateOnAction($wf);
}
if (!($wpr instanceof Response)) {
$wpr = new Response();
}
$event = new GenericEvent();
$event->setArgument('response', $wpr);
Events::dispatch('workflow_progressed', $event);
return $wpr;
} | php | public function runTask($task, $args = array())
{
$wf = $this->getWorkflowObject();
if (in_array($task, $wf->getAllowedTasks())) {
$wpr = call_user_func_array(array($wf, $task), array($this, $args));
$this->updateOnAction($wf);
}
if (!($wpr instanceof Response)) {
$wpr = new Response();
}
$event = new GenericEvent();
$event->setArgument('response', $wpr);
Events::dispatch('workflow_progressed', $event);
return $wpr;
} | [
"public",
"function",
"runTask",
"(",
"$",
"task",
",",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"wf",
"=",
"$",
"this",
"->",
"getWorkflowObject",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"task",
",",
"$",
"wf",
"->",
"getAllowedTasks",
"(",
")",
")",
")",
"{",
"$",
"wpr",
"=",
"call_user_func_array",
"(",
"array",
"(",
"$",
"wf",
",",
"$",
"task",
")",
",",
"array",
"(",
"$",
"this",
",",
"$",
"args",
")",
")",
";",
"$",
"this",
"->",
"updateOnAction",
"(",
"$",
"wf",
")",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"wpr",
"instanceof",
"Response",
")",
")",
"{",
"$",
"wpr",
"=",
"new",
"Response",
"(",
")",
";",
"}",
"$",
"event",
"=",
"new",
"GenericEvent",
"(",
")",
";",
"$",
"event",
"->",
"setArgument",
"(",
"'response'",
",",
"$",
"wpr",
")",
";",
"Events",
"::",
"dispatch",
"(",
"'workflow_progressed'",
",",
"$",
"event",
")",
";",
"return",
"$",
"wpr",
";",
"}"
] | Attempts to run a workflow task on the bound WorkflowRequest object first, then if that doesn't exist, attempts to run
it on the current WorkflowProgress object.
@return WorkflowProgressResponse | [
"Attempts",
"to",
"run",
"a",
"workflow",
"task",
"on",
"the",
"bound",
"WorkflowRequest",
"object",
"first",
"then",
"if",
"that",
"doesn",
"t",
"exist",
"attempts",
"to",
"run",
"it",
"on",
"the",
"current",
"WorkflowProgress",
"object",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Workflow/Progress/Progress.php#L260-L277 | train |
concrete5/concrete5 | concrete/src/Form/Service/Form.php | Form.action | public function action($action, $task = null)
{
return $this->app->make(ResolverManagerInterface::class)->resolve(func_get_args());
} | php | public function action($action, $task = null)
{
return $this->app->make(ResolverManagerInterface::class)->resolve(func_get_args());
} | [
"public",
"function",
"action",
"(",
"$",
"action",
",",
"$",
"task",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"ResolverManagerInterface",
"::",
"class",
")",
"->",
"resolve",
"(",
"func_get_args",
"(",
")",
")",
";",
"}"
] | Returns an action suitable for including in a form action property.
@param string $action
@param string $task
@return \League\URL\URLInterface | [
"Returns",
"an",
"action",
"suitable",
"for",
"including",
"in",
"a",
"form",
"action",
"property",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Form/Service/Form.php#L108-L111 | train |
concrete5/concrete5 | concrete/src/Form/Service/Form.php | Form.hidden | public function hidden($key, $value = null, $miscFields = [])
{
$requestValue = $this->getRequestValue($key);
if ($requestValue !== false && (!is_array($requestValue))) {
$value = $requestValue;
}
return '<input type="hidden" id="' . $key . '" name="' . $key . '"' . $this->parseMiscFields('', $miscFields) . ' value="' . $value . '" />';
} | php | public function hidden($key, $value = null, $miscFields = [])
{
$requestValue = $this->getRequestValue($key);
if ($requestValue !== false && (!is_array($requestValue))) {
$value = $requestValue;
}
return '<input type="hidden" id="' . $key . '" name="' . $key . '"' . $this->parseMiscFields('', $miscFields) . ' value="' . $value . '" />';
} | [
"public",
"function",
"hidden",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
",",
"$",
"miscFields",
"=",
"[",
"]",
")",
"{",
"$",
"requestValue",
"=",
"$",
"this",
"->",
"getRequestValue",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"requestValue",
"!==",
"false",
"&&",
"(",
"!",
"is_array",
"(",
"$",
"requestValue",
")",
")",
")",
"{",
"$",
"value",
"=",
"$",
"requestValue",
";",
"}",
"return",
"'<input type=\"hidden\" id=\"'",
".",
"$",
"key",
".",
"'\" name=\"'",
".",
"$",
"key",
".",
"'\"'",
".",
"$",
"this",
"->",
"parseMiscFields",
"(",
"''",
",",
"$",
"miscFields",
")",
".",
"' value=\"'",
".",
"$",
"value",
".",
"'\" />'",
";",
"}"
] | Creates a hidden form field.
@param string $key the name/id of the element
@param string $value the value of the element (overriden if we received some data in POST or GET)
@param array $miscFields additional fields appended to the element (a hash array of attributes name => value), possibly including 'class'
@return string | [
"Creates",
"a",
"hidden",
"form",
"field",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Form/Service/Form.php#L179-L187 | train |
concrete5/concrete5 | concrete/src/Form/Service/Form.php | Form.checkbox | public function checkbox($key, $value, $isChecked = false, $miscFields = [])
{
if (substr($key, -2) == '[]') {
$_field = substr($key, 0, -2);
$id = $_field . '_' . $value;
} else {
$_field = $key;
$id = $key;
}
$checked = false;
if ($isChecked && $this->getRequest()->get($_field) === null && $this->getRequest()->getMethod() !== 'POST') {
$checked = true;
} else {
$requestValue = $this->getRequestValue($key);
if ($requestValue !== false) {
if (is_array($requestValue)) {
if (in_array($value, $requestValue)) {
$checked = true;
}
} elseif ($requestValue == $value) {
$checked = true;
}
}
}
$checked = $checked ? ' checked="checked"' : '';
return '<input type="checkbox" id="' . $id . '" name="' . $key . '"' . $this->parseMiscFields('ccm-input-checkbox', $miscFields) . ' value="' . $value . '"' . $checked . ' />';
} | php | public function checkbox($key, $value, $isChecked = false, $miscFields = [])
{
if (substr($key, -2) == '[]') {
$_field = substr($key, 0, -2);
$id = $_field . '_' . $value;
} else {
$_field = $key;
$id = $key;
}
$checked = false;
if ($isChecked && $this->getRequest()->get($_field) === null && $this->getRequest()->getMethod() !== 'POST') {
$checked = true;
} else {
$requestValue = $this->getRequestValue($key);
if ($requestValue !== false) {
if (is_array($requestValue)) {
if (in_array($value, $requestValue)) {
$checked = true;
}
} elseif ($requestValue == $value) {
$checked = true;
}
}
}
$checked = $checked ? ' checked="checked"' : '';
return '<input type="checkbox" id="' . $id . '" name="' . $key . '"' . $this->parseMiscFields('ccm-input-checkbox', $miscFields) . ' value="' . $value . '"' . $checked . ' />';
} | [
"public",
"function",
"checkbox",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"isChecked",
"=",
"false",
",",
"$",
"miscFields",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"key",
",",
"-",
"2",
")",
"==",
"'[]'",
")",
"{",
"$",
"_field",
"=",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"-",
"2",
")",
";",
"$",
"id",
"=",
"$",
"_field",
".",
"'_'",
".",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"_field",
"=",
"$",
"key",
";",
"$",
"id",
"=",
"$",
"key",
";",
"}",
"$",
"checked",
"=",
"false",
";",
"if",
"(",
"$",
"isChecked",
"&&",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"get",
"(",
"$",
"_field",
")",
"===",
"null",
"&&",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getMethod",
"(",
")",
"!==",
"'POST'",
")",
"{",
"$",
"checked",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"requestValue",
"=",
"$",
"this",
"->",
"getRequestValue",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"requestValue",
"!==",
"false",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"requestValue",
")",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"value",
",",
"$",
"requestValue",
")",
")",
"{",
"$",
"checked",
"=",
"true",
";",
"}",
"}",
"elseif",
"(",
"$",
"requestValue",
"==",
"$",
"value",
")",
"{",
"$",
"checked",
"=",
"true",
";",
"}",
"}",
"}",
"$",
"checked",
"=",
"$",
"checked",
"?",
"' checked=\"checked\"'",
":",
"''",
";",
"return",
"'<input type=\"checkbox\" id=\"'",
".",
"$",
"id",
".",
"'\" name=\"'",
".",
"$",
"key",
".",
"'\"'",
".",
"$",
"this",
"->",
"parseMiscFields",
"(",
"'ccm-input-checkbox'",
",",
"$",
"miscFields",
")",
".",
"' value=\"'",
".",
"$",
"value",
".",
"'\"'",
".",
"$",
"checked",
".",
"' />'",
";",
"}"
] | Generates a checkbox.
@param string $key The name/id of the element. It should end with '[]' if it's to return an array on submit.
@param string $value String value sent to server, if checkbox is checked, on submit
@param string $isChecked "Checked" value (subject to be overridden by $_REQUEST). Checkbox is checked if value is true (string). Note that 'false' (string) evaluates to true (boolean)!
@param array $miscFields additional fields appended to the element (a hash array of attributes name => value), possibly including 'class'
@return string | [
"Generates",
"a",
"checkbox",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Form/Service/Form.php#L199-L227 | train |
concrete5/concrete5 | concrete/src/Form/Service/Form.php | Form.textarea | public function textarea($key, $valueOrMiscFields = '', $miscFields = [])
{
if (is_array($valueOrMiscFields)) {
$value = '';
$miscFields = $valueOrMiscFields;
} else {
$value = $valueOrMiscFields;
}
$requestValue = $this->getRequestValue($key);
if (is_string($requestValue)) {
$value = $requestValue;
}
return '<textarea id="' . $key . '" name="' . $key . '"' . $this->parseMiscFields('form-control', $miscFields) . '>' . $value . '</textarea>';
} | php | public function textarea($key, $valueOrMiscFields = '', $miscFields = [])
{
if (is_array($valueOrMiscFields)) {
$value = '';
$miscFields = $valueOrMiscFields;
} else {
$value = $valueOrMiscFields;
}
$requestValue = $this->getRequestValue($key);
if (is_string($requestValue)) {
$value = $requestValue;
}
return '<textarea id="' . $key . '" name="' . $key . '"' . $this->parseMiscFields('form-control', $miscFields) . '>' . $value . '</textarea>';
} | [
"public",
"function",
"textarea",
"(",
"$",
"key",
",",
"$",
"valueOrMiscFields",
"=",
"''",
",",
"$",
"miscFields",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"valueOrMiscFields",
")",
")",
"{",
"$",
"value",
"=",
"''",
";",
"$",
"miscFields",
"=",
"$",
"valueOrMiscFields",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"$",
"valueOrMiscFields",
";",
"}",
"$",
"requestValue",
"=",
"$",
"this",
"->",
"getRequestValue",
"(",
"$",
"key",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"requestValue",
")",
")",
"{",
"$",
"value",
"=",
"$",
"requestValue",
";",
"}",
"return",
"'<textarea id=\"'",
".",
"$",
"key",
".",
"'\" name=\"'",
".",
"$",
"key",
".",
"'\"'",
".",
"$",
"this",
"->",
"parseMiscFields",
"(",
"'form-control'",
",",
"$",
"miscFields",
")",
".",
"'>'",
".",
"$",
"value",
".",
"'</textarea>'",
";",
"}"
] | Creates a textarea field.
@param string $key the name/id of the element
@param string|array $valueOrMiscFields the value of the element or an array with additional fields appended to the element (a hash array of attributes name => value), possibly including 'class'
@param array $miscFields (used if $valueOrMiscFields is not an array) Additional fields appended to the element (a hash array of attributes name => value), possibly including 'class'
@return string | [
"Creates",
"a",
"textarea",
"field",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Form/Service/Form.php#L238-L252 | train |
concrete5/concrete5 | concrete/src/Form/Service/Form.php | Form.radio | public function radio($key, $value, $checkedValueOrMiscFields = '', $miscFields = [])
{
if (is_array($checkedValueOrMiscFields)) {
$checkedValue = '';
$miscFields = $checkedValueOrMiscFields;
} else {
$checkedValue = $checkedValueOrMiscFields;
}
$checked = false;
$requestValue = $this->getRequestValue($key);
if ($requestValue !== false) {
if ($requestValue == $value) {
$checked = true;
}
} else {
if ($checkedValue == $value) {
$checked = true;
}
}
$id = null;
if (isset($miscFields['id'])) {
$id = $miscFields['id'];
unset($miscFields['id']);
}
$id = $id ?: $key . $this->radioIndex;
$str = '<input type="radio" id="' . $id . '" name="' . $key . '" value="' . $value . '"';
$str .= $this->parseMiscFields('ccm-input-radio', $miscFields);
if ($checked) {
$str .= ' checked="checked"';
}
$str .= ' />';
++$this->radioIndex;
return $str;
} | php | public function radio($key, $value, $checkedValueOrMiscFields = '', $miscFields = [])
{
if (is_array($checkedValueOrMiscFields)) {
$checkedValue = '';
$miscFields = $checkedValueOrMiscFields;
} else {
$checkedValue = $checkedValueOrMiscFields;
}
$checked = false;
$requestValue = $this->getRequestValue($key);
if ($requestValue !== false) {
if ($requestValue == $value) {
$checked = true;
}
} else {
if ($checkedValue == $value) {
$checked = true;
}
}
$id = null;
if (isset($miscFields['id'])) {
$id = $miscFields['id'];
unset($miscFields['id']);
}
$id = $id ?: $key . $this->radioIndex;
$str = '<input type="radio" id="' . $id . '" name="' . $key . '" value="' . $value . '"';
$str .= $this->parseMiscFields('ccm-input-radio', $miscFields);
if ($checked) {
$str .= ' checked="checked"';
}
$str .= ' />';
++$this->radioIndex;
return $str;
} | [
"public",
"function",
"radio",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"checkedValueOrMiscFields",
"=",
"''",
",",
"$",
"miscFields",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"checkedValueOrMiscFields",
")",
")",
"{",
"$",
"checkedValue",
"=",
"''",
";",
"$",
"miscFields",
"=",
"$",
"checkedValueOrMiscFields",
";",
"}",
"else",
"{",
"$",
"checkedValue",
"=",
"$",
"checkedValueOrMiscFields",
";",
"}",
"$",
"checked",
"=",
"false",
";",
"$",
"requestValue",
"=",
"$",
"this",
"->",
"getRequestValue",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"requestValue",
"!==",
"false",
")",
"{",
"if",
"(",
"$",
"requestValue",
"==",
"$",
"value",
")",
"{",
"$",
"checked",
"=",
"true",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"checkedValue",
"==",
"$",
"value",
")",
"{",
"$",
"checked",
"=",
"true",
";",
"}",
"}",
"$",
"id",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"miscFields",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"id",
"=",
"$",
"miscFields",
"[",
"'id'",
"]",
";",
"unset",
"(",
"$",
"miscFields",
"[",
"'id'",
"]",
")",
";",
"}",
"$",
"id",
"=",
"$",
"id",
"?",
":",
"$",
"key",
".",
"$",
"this",
"->",
"radioIndex",
";",
"$",
"str",
"=",
"'<input type=\"radio\" id=\"'",
".",
"$",
"id",
".",
"'\" name=\"'",
".",
"$",
"key",
".",
"'\" value=\"'",
".",
"$",
"value",
".",
"'\"'",
";",
"$",
"str",
".=",
"$",
"this",
"->",
"parseMiscFields",
"(",
"'ccm-input-radio'",
",",
"$",
"miscFields",
")",
";",
"if",
"(",
"$",
"checked",
")",
"{",
"$",
"str",
".=",
"' checked=\"checked\"'",
";",
"}",
"$",
"str",
".=",
"' />'",
";",
"++",
"$",
"this",
"->",
"radioIndex",
";",
"return",
"$",
"str",
";",
"}"
] | Generates a radio button.
@param string $key the name of the element (its id will start with $key but will have a progressive unique number added)
@param string $value the value of the radio button
@param string|array $checkedValueOrMiscFields the value of the element (if it should be initially checked) or an array with additional fields appended to the element (a hash array of attributes name => value), possibly including 'class'
@param array $miscFields (used if $checkedValueOrMiscFields is not an array) Additional fields appended to the element (a hash array of attributes name => value), possibly including 'class'
@return string | [
"Generates",
"a",
"radio",
"button",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Form/Service/Form.php#L264-L300 | train |
concrete5/concrete5 | concrete/src/Form/Service/Form.php | Form.select | public function select($key, $optionValues, $valueOrMiscFields = '', $miscFields = [])
{
if (!is_array($optionValues)) {
$optionValues = [];
}
if (is_array($valueOrMiscFields)) {
$selectedValue = '';
$miscFields = $valueOrMiscFields;
} else {
$selectedValue = (string) $valueOrMiscFields;
}
if ($selectedValue !== '') {
$miscFields['ccm-passed-value'] = h($selectedValue);
}
$requestValue = $this->getRequestValue($key);
if (is_array($requestValue) && isset($requestValue[0]) && is_string($requestValue[0])) {
$selectedValue = (string) $requestValue[0];
} elseif ($requestValue !== false) {
if (!is_array($requestValue)) {
$selectedValue = (string) $requestValue;
} else {
$selectedValue = '';
}
}
if (substr($key, -2) == '[]') {
$_key = substr($key, 0, -2);
$id = $_key . $this->selectIndex;
++$this->selectIndex;
} else {
$id = $key;
}
$str = '<select id="' . $id . '" name="' . $key . '"' . $this->parseMiscFields('form-control', $miscFields) . '>';
foreach ($optionValues as $k => $text) {
if (is_array($text)) {
$str .= '<optgroup label="' . h($k) . '">';
foreach ($text as $optionValue => $optionText) {
$str .= '<option value="' . h($optionValue) . '"';
if ((string) $optionValue === (string) $selectedValue) {
$str .= ' selected="selected"';
}
$str .= '>' . h($optionText) . '</option>';
}
$str .= '</optgroup>';
} else {
$str .= '<option value="' . h($k) . '"';
if ((string) $k === (string) $selectedValue) {
$str .= ' selected="selected"';
}
$str .= '>' . $text . '</option>';
}
}
$str .= '</select>';
return $str;
} | php | public function select($key, $optionValues, $valueOrMiscFields = '', $miscFields = [])
{
if (!is_array($optionValues)) {
$optionValues = [];
}
if (is_array($valueOrMiscFields)) {
$selectedValue = '';
$miscFields = $valueOrMiscFields;
} else {
$selectedValue = (string) $valueOrMiscFields;
}
if ($selectedValue !== '') {
$miscFields['ccm-passed-value'] = h($selectedValue);
}
$requestValue = $this->getRequestValue($key);
if (is_array($requestValue) && isset($requestValue[0]) && is_string($requestValue[0])) {
$selectedValue = (string) $requestValue[0];
} elseif ($requestValue !== false) {
if (!is_array($requestValue)) {
$selectedValue = (string) $requestValue;
} else {
$selectedValue = '';
}
}
if (substr($key, -2) == '[]') {
$_key = substr($key, 0, -2);
$id = $_key . $this->selectIndex;
++$this->selectIndex;
} else {
$id = $key;
}
$str = '<select id="' . $id . '" name="' . $key . '"' . $this->parseMiscFields('form-control', $miscFields) . '>';
foreach ($optionValues as $k => $text) {
if (is_array($text)) {
$str .= '<optgroup label="' . h($k) . '">';
foreach ($text as $optionValue => $optionText) {
$str .= '<option value="' . h($optionValue) . '"';
if ((string) $optionValue === (string) $selectedValue) {
$str .= ' selected="selected"';
}
$str .= '>' . h($optionText) . '</option>';
}
$str .= '</optgroup>';
} else {
$str .= '<option value="' . h($k) . '"';
if ((string) $k === (string) $selectedValue) {
$str .= ' selected="selected"';
}
$str .= '>' . $text . '</option>';
}
}
$str .= '</select>';
return $str;
} | [
"public",
"function",
"select",
"(",
"$",
"key",
",",
"$",
"optionValues",
",",
"$",
"valueOrMiscFields",
"=",
"''",
",",
"$",
"miscFields",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"optionValues",
")",
")",
"{",
"$",
"optionValues",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"valueOrMiscFields",
")",
")",
"{",
"$",
"selectedValue",
"=",
"''",
";",
"$",
"miscFields",
"=",
"$",
"valueOrMiscFields",
";",
"}",
"else",
"{",
"$",
"selectedValue",
"=",
"(",
"string",
")",
"$",
"valueOrMiscFields",
";",
"}",
"if",
"(",
"$",
"selectedValue",
"!==",
"''",
")",
"{",
"$",
"miscFields",
"[",
"'ccm-passed-value'",
"]",
"=",
"h",
"(",
"$",
"selectedValue",
")",
";",
"}",
"$",
"requestValue",
"=",
"$",
"this",
"->",
"getRequestValue",
"(",
"$",
"key",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"requestValue",
")",
"&&",
"isset",
"(",
"$",
"requestValue",
"[",
"0",
"]",
")",
"&&",
"is_string",
"(",
"$",
"requestValue",
"[",
"0",
"]",
")",
")",
"{",
"$",
"selectedValue",
"=",
"(",
"string",
")",
"$",
"requestValue",
"[",
"0",
"]",
";",
"}",
"elseif",
"(",
"$",
"requestValue",
"!==",
"false",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"requestValue",
")",
")",
"{",
"$",
"selectedValue",
"=",
"(",
"string",
")",
"$",
"requestValue",
";",
"}",
"else",
"{",
"$",
"selectedValue",
"=",
"''",
";",
"}",
"}",
"if",
"(",
"substr",
"(",
"$",
"key",
",",
"-",
"2",
")",
"==",
"'[]'",
")",
"{",
"$",
"_key",
"=",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"-",
"2",
")",
";",
"$",
"id",
"=",
"$",
"_key",
".",
"$",
"this",
"->",
"selectIndex",
";",
"++",
"$",
"this",
"->",
"selectIndex",
";",
"}",
"else",
"{",
"$",
"id",
"=",
"$",
"key",
";",
"}",
"$",
"str",
"=",
"'<select id=\"'",
".",
"$",
"id",
".",
"'\" name=\"'",
".",
"$",
"key",
".",
"'\"'",
".",
"$",
"this",
"->",
"parseMiscFields",
"(",
"'form-control'",
",",
"$",
"miscFields",
")",
".",
"'>'",
";",
"foreach",
"(",
"$",
"optionValues",
"as",
"$",
"k",
"=>",
"$",
"text",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"text",
")",
")",
"{",
"$",
"str",
".=",
"'<optgroup label=\"'",
".",
"h",
"(",
"$",
"k",
")",
".",
"'\">'",
";",
"foreach",
"(",
"$",
"text",
"as",
"$",
"optionValue",
"=>",
"$",
"optionText",
")",
"{",
"$",
"str",
".=",
"'<option value=\"'",
".",
"h",
"(",
"$",
"optionValue",
")",
".",
"'\"'",
";",
"if",
"(",
"(",
"string",
")",
"$",
"optionValue",
"===",
"(",
"string",
")",
"$",
"selectedValue",
")",
"{",
"$",
"str",
".=",
"' selected=\"selected\"'",
";",
"}",
"$",
"str",
".=",
"'>'",
".",
"h",
"(",
"$",
"optionText",
")",
".",
"'</option>'",
";",
"}",
"$",
"str",
".=",
"'</optgroup>'",
";",
"}",
"else",
"{",
"$",
"str",
".=",
"'<option value=\"'",
".",
"h",
"(",
"$",
"k",
")",
".",
"'\"'",
";",
"if",
"(",
"(",
"string",
")",
"$",
"k",
"===",
"(",
"string",
")",
"$",
"selectedValue",
")",
"{",
"$",
"str",
".=",
"' selected=\"selected\"'",
";",
"}",
"$",
"str",
".=",
"'>'",
".",
"$",
"text",
".",
"'</option>'",
";",
"}",
"}",
"$",
"str",
".=",
"'</select>'",
";",
"return",
"$",
"str",
";",
"}"
] | Renders a select field.
@param string $key The name of the element. If $key denotes an array, the ID will start with $key but will have a progressive unique number added; if $key does not denotes an array, the ID attribute will be $key.
@param array $optionValues an associative array of key => display
@param string|array $valueOrMiscFields the value of the field to be selected or an array with additional fields appended to the element (a hash array of attributes name => value), possibly including 'class'
@param array $miscFields (used if $valueOrMiscFields is not an array) Additional fields appended to the element (a hash array of attributes name => value), possibly including 'class'
@return $html | [
"Renders",
"a",
"select",
"field",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Form/Service/Form.php#L416-L470 | train |
concrete5/concrete5 | concrete/src/Form/Service/Form.php | Form.selectMultiple | public function selectMultiple($key, $optionValues, $defaultValues = false, $miscFields = [])
{
$requestValue = $this->getRequestValue($key . '[]');
if ($requestValue !== false) {
$selectedValues = $requestValue;
} else {
$selectedValues = $defaultValues;
}
if (!is_array($selectedValues)) {
if (isset($selectedValues) && ($selectedValues !== false)) {
$selectedValues = (array) $selectedValues;
} else {
$selectedValues = [];
}
}
if (!is_array($optionValues)) {
$optionValues = [];
}
$str = "<select id=\"$key\" name=\"{$key}[]\" multiple=\"multiple\"" . $this->parseMiscFields('form-control', $miscFields) . '>';
foreach ($optionValues as $k => $text) {
$str .= '<option value="' . h($k) . '"';
if (in_array($k, $selectedValues)) {
$str .= ' selected="selected"';
}
$str .= '>' . $text . '</option>';
}
$str .= '</select>';
return $str;
} | php | public function selectMultiple($key, $optionValues, $defaultValues = false, $miscFields = [])
{
$requestValue = $this->getRequestValue($key . '[]');
if ($requestValue !== false) {
$selectedValues = $requestValue;
} else {
$selectedValues = $defaultValues;
}
if (!is_array($selectedValues)) {
if (isset($selectedValues) && ($selectedValues !== false)) {
$selectedValues = (array) $selectedValues;
} else {
$selectedValues = [];
}
}
if (!is_array($optionValues)) {
$optionValues = [];
}
$str = "<select id=\"$key\" name=\"{$key}[]\" multiple=\"multiple\"" . $this->parseMiscFields('form-control', $miscFields) . '>';
foreach ($optionValues as $k => $text) {
$str .= '<option value="' . h($k) . '"';
if (in_array($k, $selectedValues)) {
$str .= ' selected="selected"';
}
$str .= '>' . $text . '</option>';
}
$str .= '</select>';
return $str;
} | [
"public",
"function",
"selectMultiple",
"(",
"$",
"key",
",",
"$",
"optionValues",
",",
"$",
"defaultValues",
"=",
"false",
",",
"$",
"miscFields",
"=",
"[",
"]",
")",
"{",
"$",
"requestValue",
"=",
"$",
"this",
"->",
"getRequestValue",
"(",
"$",
"key",
".",
"'[]'",
")",
";",
"if",
"(",
"$",
"requestValue",
"!==",
"false",
")",
"{",
"$",
"selectedValues",
"=",
"$",
"requestValue",
";",
"}",
"else",
"{",
"$",
"selectedValues",
"=",
"$",
"defaultValues",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"selectedValues",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"selectedValues",
")",
"&&",
"(",
"$",
"selectedValues",
"!==",
"false",
")",
")",
"{",
"$",
"selectedValues",
"=",
"(",
"array",
")",
"$",
"selectedValues",
";",
"}",
"else",
"{",
"$",
"selectedValues",
"=",
"[",
"]",
";",
"}",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"optionValues",
")",
")",
"{",
"$",
"optionValues",
"=",
"[",
"]",
";",
"}",
"$",
"str",
"=",
"\"<select id=\\\"$key\\\" name=\\\"{$key}[]\\\" multiple=\\\"multiple\\\"\"",
".",
"$",
"this",
"->",
"parseMiscFields",
"(",
"'form-control'",
",",
"$",
"miscFields",
")",
".",
"'>'",
";",
"foreach",
"(",
"$",
"optionValues",
"as",
"$",
"k",
"=>",
"$",
"text",
")",
"{",
"$",
"str",
".=",
"'<option value=\"'",
".",
"h",
"(",
"$",
"k",
")",
".",
"'\"'",
";",
"if",
"(",
"in_array",
"(",
"$",
"k",
",",
"$",
"selectedValues",
")",
")",
"{",
"$",
"str",
".=",
"' selected=\"selected\"'",
";",
"}",
"$",
"str",
".=",
"'>'",
".",
"$",
"text",
".",
"'</option>'",
";",
"}",
"$",
"str",
".=",
"'</select>'",
";",
"return",
"$",
"str",
";",
"}"
] | Renders a multiple select box.
@param string $key The ID of the element. The name attribute will be $key followed by '[].
@param array $optionValues Hash array with name/value as the select's option value/text
@param array|string $defaultValues Default value(s) which match with the option values; overridden by $_REQUEST
@param array $miscFields additional fields appended to the element (a hash array of attributes name => value), possibly including 'class'
@return $html | [
"Renders",
"a",
"multiple",
"select",
"box",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Form/Service/Form.php#L567-L596 | train |
concrete5/concrete5 | concrete/src/Form/Service/Form.php | Form.parseMiscFields | protected function parseMiscFields($defaultClass, $attributes)
{
$attributes = (array) $attributes;
if ($defaultClass) {
$attributes['class'] = trim((isset($attributes['class']) ? $attributes['class'] : '') . ' ' . $defaultClass);
}
$attr = '';
foreach ($attributes as $k => $v) {
$attr .= " $k=\"$v\"";
}
return $attr;
} | php | protected function parseMiscFields($defaultClass, $attributes)
{
$attributes = (array) $attributes;
if ($defaultClass) {
$attributes['class'] = trim((isset($attributes['class']) ? $attributes['class'] : '') . ' ' . $defaultClass);
}
$attr = '';
foreach ($attributes as $k => $v) {
$attr .= " $k=\"$v\"";
}
return $attr;
} | [
"protected",
"function",
"parseMiscFields",
"(",
"$",
"defaultClass",
",",
"$",
"attributes",
")",
"{",
"$",
"attributes",
"=",
"(",
"array",
")",
"$",
"attributes",
";",
"if",
"(",
"$",
"defaultClass",
")",
"{",
"$",
"attributes",
"[",
"'class'",
"]",
"=",
"trim",
"(",
"(",
"isset",
"(",
"$",
"attributes",
"[",
"'class'",
"]",
")",
"?",
"$",
"attributes",
"[",
"'class'",
"]",
":",
"''",
")",
".",
"' '",
".",
"$",
"defaultClass",
")",
";",
"}",
"$",
"attr",
"=",
"''",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"attr",
".=",
"\" $k=\\\"$v\\\"\"",
";",
"}",
"return",
"$",
"attr",
";",
"}"
] | Create an HTML fragment of attribute values, merging any CSS class names as necessary.
@param string $defaultClass Default CSS class name
@param array $attributes a hash array of attributes (name => value), possibly including 'class'
@return string A fragment of attributes suitable to put inside of an HTML tag | [
"Create",
"an",
"HTML",
"fragment",
"of",
"attribute",
"values",
"merging",
"any",
"CSS",
"class",
"names",
"as",
"necessary",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Form/Service/Form.php#L714-L726 | train |
concrete5/concrete5 | concrete/src/Updater/ApplicationUpdate.php | ApplicationUpdate.getByVersionNumber | public static function getByVersionNumber($version)
{
$updates = id(new Update())->getLocalAvailableUpdates();
foreach ($updates as $up) {
if ($up->getUpdateVersion() == $version) {
return $up;
}
}
} | php | public static function getByVersionNumber($version)
{
$updates = id(new Update())->getLocalAvailableUpdates();
foreach ($updates as $up) {
if ($up->getUpdateVersion() == $version) {
return $up;
}
}
} | [
"public",
"static",
"function",
"getByVersionNumber",
"(",
"$",
"version",
")",
"{",
"$",
"updates",
"=",
"id",
"(",
"new",
"Update",
"(",
")",
")",
"->",
"getLocalAvailableUpdates",
"(",
")",
";",
"foreach",
"(",
"$",
"updates",
"as",
"$",
"up",
")",
"{",
"if",
"(",
"$",
"up",
"->",
"getUpdateVersion",
"(",
")",
"==",
"$",
"version",
")",
"{",
"return",
"$",
"up",
";",
"}",
"}",
"}"
] | Returns an ApplicationUpdate instance given its version string.
@param string $version
@return ApplicationUpdate|null Returns null if there's no update with $version, or an ApplicationUpdate instance if $version is ok | [
"Returns",
"an",
"ApplicationUpdate",
"instance",
"given",
"its",
"version",
"string",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Updater/ApplicationUpdate.php#L63-L71 | train |
concrete5/concrete5 | concrete/src/Updater/ApplicationUpdate.php | ApplicationUpdate.get | public static function get($dir)
{
$version_file = DIR_CORE_UPDATES . "/{$dir}/" . DIRNAME_CORE . '/config/concrete.php';
$concrete = @include $version_file;
if ($concrete['version'] != false) {
$obj = new self();
$obj->version = $concrete['version'];
$obj->identifier = $dir;
return $obj;
}
} | php | public static function get($dir)
{
$version_file = DIR_CORE_UPDATES . "/{$dir}/" . DIRNAME_CORE . '/config/concrete.php';
$concrete = @include $version_file;
if ($concrete['version'] != false) {
$obj = new self();
$obj->version = $concrete['version'];
$obj->identifier = $dir;
return $obj;
}
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"dir",
")",
"{",
"$",
"version_file",
"=",
"DIR_CORE_UPDATES",
".",
"\"/{$dir}/\"",
".",
"DIRNAME_CORE",
".",
"'/config/concrete.php'",
";",
"$",
"concrete",
"=",
"@",
"include",
"$",
"version_file",
";",
"if",
"(",
"$",
"concrete",
"[",
"'version'",
"]",
"!=",
"false",
")",
"{",
"$",
"obj",
"=",
"new",
"self",
"(",
")",
";",
"$",
"obj",
"->",
"version",
"=",
"$",
"concrete",
"[",
"'version'",
"]",
";",
"$",
"obj",
"->",
"identifier",
"=",
"$",
"dir",
";",
"return",
"$",
"obj",
";",
"}",
"}"
] | Parse an update dir and returns an ApplicationUpdate instance.
@param string $dir The base name of the directory under the updates directory
@return ApplicationUpdate|null Returns null if there's no update in the $dir directory, or an ApplicationUpdate instance if $dir is ok | [
"Parse",
"an",
"update",
"dir",
"and",
"returns",
"an",
"ApplicationUpdate",
"instance",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Updater/ApplicationUpdate.php#L106-L118 | train |
concrete5/concrete5 | concrete/src/Updater/ApplicationUpdate.php | ApplicationUpdate.getDiagnosticObject | public function getDiagnosticObject()
{
$app = Application::getFacadeApplication();
$client = $app->make('http/client');
$request = $client->getRequest();
$request->setUri(Config::get('concrete.updates.services.inspect_update'));
$request->setMethod('POST');
$request->getPost()->set('current_version', Config::get('concrete.version_installed'));
$request->getPost()->set('requested_version', $this->getVersion());
$request->getPost()->set('site_url', (string) \Core::getApplicationURL());
$mi = Marketplace::getInstance();
if ($mi->isConnected() && !$mi->hasConnectionError()) {
$config = \Core::make('config/database');
$request->getPost()->set('marketplace_token', $config->get('concrete.marketplace.token'));
$list = Package::getInstalledList();
$packages = [];
foreach ($list as $pkg) {
$packages[] = ['version' => $pkg->getPackageVersion(), 'handle' => $pkg->getPackageHandle()];
}
$request->getPost()->set('packages', $packages);
}
$info = \Core::make('\Concrete\Core\System\Info');
$overrides = $info->getOverrideList();
$request->getPost()->set('overrides', $overrides);
$info = $info->getJSONOBject();
$request->getPost()->set('environment', json_encode($info));
$client->setMethod('POST');
$response = $client->send();
$body = $response->getBody();
$diagnostic = DiagnosticFactory::getFromJSON($body);
return $diagnostic;
} | php | public function getDiagnosticObject()
{
$app = Application::getFacadeApplication();
$client = $app->make('http/client');
$request = $client->getRequest();
$request->setUri(Config::get('concrete.updates.services.inspect_update'));
$request->setMethod('POST');
$request->getPost()->set('current_version', Config::get('concrete.version_installed'));
$request->getPost()->set('requested_version', $this->getVersion());
$request->getPost()->set('site_url', (string) \Core::getApplicationURL());
$mi = Marketplace::getInstance();
if ($mi->isConnected() && !$mi->hasConnectionError()) {
$config = \Core::make('config/database');
$request->getPost()->set('marketplace_token', $config->get('concrete.marketplace.token'));
$list = Package::getInstalledList();
$packages = [];
foreach ($list as $pkg) {
$packages[] = ['version' => $pkg->getPackageVersion(), 'handle' => $pkg->getPackageHandle()];
}
$request->getPost()->set('packages', $packages);
}
$info = \Core::make('\Concrete\Core\System\Info');
$overrides = $info->getOverrideList();
$request->getPost()->set('overrides', $overrides);
$info = $info->getJSONOBject();
$request->getPost()->set('environment', json_encode($info));
$client->setMethod('POST');
$response = $client->send();
$body = $response->getBody();
$diagnostic = DiagnosticFactory::getFromJSON($body);
return $diagnostic;
} | [
"public",
"function",
"getDiagnosticObject",
"(",
")",
"{",
"$",
"app",
"=",
"Application",
"::",
"getFacadeApplication",
"(",
")",
";",
"$",
"client",
"=",
"$",
"app",
"->",
"make",
"(",
"'http/client'",
")",
";",
"$",
"request",
"=",
"$",
"client",
"->",
"getRequest",
"(",
")",
";",
"$",
"request",
"->",
"setUri",
"(",
"Config",
"::",
"get",
"(",
"'concrete.updates.services.inspect_update'",
")",
")",
";",
"$",
"request",
"->",
"setMethod",
"(",
"'POST'",
")",
";",
"$",
"request",
"->",
"getPost",
"(",
")",
"->",
"set",
"(",
"'current_version'",
",",
"Config",
"::",
"get",
"(",
"'concrete.version_installed'",
")",
")",
";",
"$",
"request",
"->",
"getPost",
"(",
")",
"->",
"set",
"(",
"'requested_version'",
",",
"$",
"this",
"->",
"getVersion",
"(",
")",
")",
";",
"$",
"request",
"->",
"getPost",
"(",
")",
"->",
"set",
"(",
"'site_url'",
",",
"(",
"string",
")",
"\\",
"Core",
"::",
"getApplicationURL",
"(",
")",
")",
";",
"$",
"mi",
"=",
"Marketplace",
"::",
"getInstance",
"(",
")",
";",
"if",
"(",
"$",
"mi",
"->",
"isConnected",
"(",
")",
"&&",
"!",
"$",
"mi",
"->",
"hasConnectionError",
"(",
")",
")",
"{",
"$",
"config",
"=",
"\\",
"Core",
"::",
"make",
"(",
"'config/database'",
")",
";",
"$",
"request",
"->",
"getPost",
"(",
")",
"->",
"set",
"(",
"'marketplace_token'",
",",
"$",
"config",
"->",
"get",
"(",
"'concrete.marketplace.token'",
")",
")",
";",
"$",
"list",
"=",
"Package",
"::",
"getInstalledList",
"(",
")",
";",
"$",
"packages",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"pkg",
")",
"{",
"$",
"packages",
"[",
"]",
"=",
"[",
"'version'",
"=>",
"$",
"pkg",
"->",
"getPackageVersion",
"(",
")",
",",
"'handle'",
"=>",
"$",
"pkg",
"->",
"getPackageHandle",
"(",
")",
"]",
";",
"}",
"$",
"request",
"->",
"getPost",
"(",
")",
"->",
"set",
"(",
"'packages'",
",",
"$",
"packages",
")",
";",
"}",
"$",
"info",
"=",
"\\",
"Core",
"::",
"make",
"(",
"'\\Concrete\\Core\\System\\Info'",
")",
";",
"$",
"overrides",
"=",
"$",
"info",
"->",
"getOverrideList",
"(",
")",
";",
"$",
"request",
"->",
"getPost",
"(",
")",
"->",
"set",
"(",
"'overrides'",
",",
"$",
"overrides",
")",
";",
"$",
"info",
"=",
"$",
"info",
"->",
"getJSONOBject",
"(",
")",
";",
"$",
"request",
"->",
"getPost",
"(",
")",
"->",
"set",
"(",
"'environment'",
",",
"json_encode",
"(",
"$",
"info",
")",
")",
";",
"$",
"client",
"->",
"setMethod",
"(",
"'POST'",
")",
";",
"$",
"response",
"=",
"$",
"client",
"->",
"send",
"(",
")",
";",
"$",
"body",
"=",
"$",
"response",
"->",
"getBody",
"(",
")",
";",
"$",
"diagnostic",
"=",
"DiagnosticFactory",
"::",
"getFromJSON",
"(",
"$",
"body",
")",
";",
"return",
"$",
"diagnostic",
";",
"}"
] | Given the current update object, sends information to concrete5.org to determine updatability.
@return \Concrete\Core\Updater\ApplicationUpdate\Diagnostic | [
"Given",
"the",
"current",
"update",
"object",
"sends",
"information",
"to",
"concrete5",
".",
"org",
"to",
"determine",
"updatability",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Updater/ApplicationUpdate.php#L135-L170 | train |
concrete5/concrete5 | concrete/src/Search/Field/Manager.php | Manager.addGroup | public function addGroup($name, $fields = [])
{
$group = new Group();
$group->setName($name);
$group->setFields($fields);
$this->addGroupObject($group);
} | php | public function addGroup($name, $fields = [])
{
$group = new Group();
$group->setName($name);
$group->setFields($fields);
$this->addGroupObject($group);
} | [
"public",
"function",
"addGroup",
"(",
"$",
"name",
",",
"$",
"fields",
"=",
"[",
"]",
")",
"{",
"$",
"group",
"=",
"new",
"Group",
"(",
")",
";",
"$",
"group",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"$",
"group",
"->",
"setFields",
"(",
"$",
"fields",
")",
";",
"$",
"this",
"->",
"addGroupObject",
"(",
"$",
"group",
")",
";",
"}"
] | Add a group of fields.
@param string $name the group name
@param FieldInterface[] $fields | [
"Add",
"a",
"group",
"of",
"fields",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Search/Field/Manager.php#L31-L37 | train |
concrete5/concrete5 | concrete/authentication/external_concrete5/controller.php | Controller.saveAuthenticationType | public function saveAuthenticationType($args)
{
$passedUrl = trim($args['url']);
if ($passedUrl) {
try {
$url = Url::createFromUrl($passedUrl);
if (!(string)$url->getScheme() || !(string)$url->getHost()) {
throw new InvalidArgumentException('No scheme or host provided.');
}
} catch (\Exception $e) {
throw new InvalidArgumentException('Invalid URL.');
}
}
$passedName = trim($args['displayName']);
if (!$passedName) {
throw new InvalidArgumentException('Invalid display name');
}
$this->authenticationType->setAuthenticationTypeName($passedName);
$config = $this->app->make(Repository::class);
$config->save('auth.external_concrete5.url', $args['url']);
$config->save('auth.external_concrete5.appid', $args['apikey']);
$config->save('auth.external_concrete5.secret', $args['apisecret']);
$config->save('auth.external_concrete5.registration.enabled', (bool) $args['registration_enabled']);
$config->save('auth.external_concrete5.registration.group', intval($args['registration_group'], 10));
} | php | public function saveAuthenticationType($args)
{
$passedUrl = trim($args['url']);
if ($passedUrl) {
try {
$url = Url::createFromUrl($passedUrl);
if (!(string)$url->getScheme() || !(string)$url->getHost()) {
throw new InvalidArgumentException('No scheme or host provided.');
}
} catch (\Exception $e) {
throw new InvalidArgumentException('Invalid URL.');
}
}
$passedName = trim($args['displayName']);
if (!$passedName) {
throw new InvalidArgumentException('Invalid display name');
}
$this->authenticationType->setAuthenticationTypeName($passedName);
$config = $this->app->make(Repository::class);
$config->save('auth.external_concrete5.url', $args['url']);
$config->save('auth.external_concrete5.appid', $args['apikey']);
$config->save('auth.external_concrete5.secret', $args['apisecret']);
$config->save('auth.external_concrete5.registration.enabled', (bool) $args['registration_enabled']);
$config->save('auth.external_concrete5.registration.group', intval($args['registration_group'], 10));
} | [
"public",
"function",
"saveAuthenticationType",
"(",
"$",
"args",
")",
"{",
"$",
"passedUrl",
"=",
"trim",
"(",
"$",
"args",
"[",
"'url'",
"]",
")",
";",
"if",
"(",
"$",
"passedUrl",
")",
"{",
"try",
"{",
"$",
"url",
"=",
"Url",
"::",
"createFromUrl",
"(",
"$",
"passedUrl",
")",
";",
"if",
"(",
"!",
"(",
"string",
")",
"$",
"url",
"->",
"getScheme",
"(",
")",
"||",
"!",
"(",
"string",
")",
"$",
"url",
"->",
"getHost",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'No scheme or host provided.'",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid URL.'",
")",
";",
"}",
"}",
"$",
"passedName",
"=",
"trim",
"(",
"$",
"args",
"[",
"'displayName'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"passedName",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid display name'",
")",
";",
"}",
"$",
"this",
"->",
"authenticationType",
"->",
"setAuthenticationTypeName",
"(",
"$",
"passedName",
")",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"Repository",
"::",
"class",
")",
";",
"$",
"config",
"->",
"save",
"(",
"'auth.external_concrete5.url'",
",",
"$",
"args",
"[",
"'url'",
"]",
")",
";",
"$",
"config",
"->",
"save",
"(",
"'auth.external_concrete5.appid'",
",",
"$",
"args",
"[",
"'apikey'",
"]",
")",
";",
"$",
"config",
"->",
"save",
"(",
"'auth.external_concrete5.secret'",
",",
"$",
"args",
"[",
"'apisecret'",
"]",
")",
";",
"$",
"config",
"->",
"save",
"(",
"'auth.external_concrete5.registration.enabled'",
",",
"(",
"bool",
")",
"$",
"args",
"[",
"'registration_enabled'",
"]",
")",
";",
"$",
"config",
"->",
"save",
"(",
"'auth.external_concrete5.registration.group'",
",",
"intval",
"(",
"$",
"args",
"[",
"'registration_group'",
"]",
",",
"10",
")",
")",
";",
"}"
] | Save data for this authentication type
This method is called when the type_form.php submits. It stores client details and configuration for connecting
@param array|\Traversable $args | [
"Save",
"data",
"for",
"this",
"authentication",
"type",
"This",
"method",
"is",
"called",
"when",
"the",
"type_form",
".",
"php",
"submits",
".",
"It",
"stores",
"client",
"details",
"and",
"configuration",
"for",
"connecting"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/authentication/external_concrete5/controller.php#L101-L130 | train |
concrete5/concrete5 | concrete/authentication/external_concrete5/controller.php | Controller.edit | public function edit()
{
$config = $this->app->make(Repository::class);
$this->set('form', $this->app->make('helper/form'));
$this->set('data', $config->get('auth.external_concrete5', []));
$this->set('redirectUri', $this->urlResolver->resolve(['/ccm/system/authentication/oauth2/external_concrete5/callback']));
$list = $this->app->make(GroupList::class);
$list->includeAllGroups();
$this->set('groups', $list->getResults());
} | php | public function edit()
{
$config = $this->app->make(Repository::class);
$this->set('form', $this->app->make('helper/form'));
$this->set('data', $config->get('auth.external_concrete5', []));
$this->set('redirectUri', $this->urlResolver->resolve(['/ccm/system/authentication/oauth2/external_concrete5/callback']));
$list = $this->app->make(GroupList::class);
$list->includeAllGroups();
$this->set('groups', $list->getResults());
} | [
"public",
"function",
"edit",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"Repository",
"::",
"class",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'form'",
",",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'helper/form'",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'data'",
",",
"$",
"config",
"->",
"get",
"(",
"'auth.external_concrete5'",
",",
"[",
"]",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'redirectUri'",
",",
"$",
"this",
"->",
"urlResolver",
"->",
"resolve",
"(",
"[",
"'/ccm/system/authentication/oauth2/external_concrete5/callback'",
"]",
")",
")",
";",
"$",
"list",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"GroupList",
"::",
"class",
")",
";",
"$",
"list",
"->",
"includeAllGroups",
"(",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'groups'",
",",
"$",
"list",
"->",
"getResults",
"(",
")",
")",
";",
"}"
] | Controller method for type_form
This method is called just before rendering type_form.php, use it to set data for that template | [
"Controller",
"method",
"for",
"type_form",
"This",
"method",
"is",
"called",
"just",
"before",
"rendering",
"type_form",
".",
"php",
"use",
"it",
"to",
"set",
"data",
"for",
"that",
"template"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/authentication/external_concrete5/controller.php#L136-L146 | train |
concrete5/concrete5 | concrete/authentication/external_concrete5/controller.php | Controller.setData | private function setData()
{
$data = $this->config->get('auth.external_concrete5', '');
$authUrl = $this->urlResolver->resolve(['/ccm/system/authentication/oauth2/external_concrete5/attempt_auth']);
$attachUrl = $this->urlResolver->resolve(['/ccm/system/authentication/oauth2/external_concrete5/attempt_attach']);
$baseUrl = $this->urlResolver->resolve(['/']);
$path = $baseUrl->getPath();
$path->remove('index.php');
$name = trim((string) array_get($data, 'name', t('External concrete5')));
$this->set('data', $data);
$this->set('authUrl', $authUrl);
$this->set('attachUrl', $attachUrl);
$this->set('baseUrl', $baseUrl);
$this->set('assetBase', $baseUrl->setPath($path));
$this->set('name', $name);
$this->set('user', $this->app->make(User::class));
} | php | private function setData()
{
$data = $this->config->get('auth.external_concrete5', '');
$authUrl = $this->urlResolver->resolve(['/ccm/system/authentication/oauth2/external_concrete5/attempt_auth']);
$attachUrl = $this->urlResolver->resolve(['/ccm/system/authentication/oauth2/external_concrete5/attempt_attach']);
$baseUrl = $this->urlResolver->resolve(['/']);
$path = $baseUrl->getPath();
$path->remove('index.php');
$name = trim((string) array_get($data, 'name', t('External concrete5')));
$this->set('data', $data);
$this->set('authUrl', $authUrl);
$this->set('attachUrl', $attachUrl);
$this->set('baseUrl', $baseUrl);
$this->set('assetBase', $baseUrl->setPath($path));
$this->set('name', $name);
$this->set('user', $this->app->make(User::class));
} | [
"private",
"function",
"setData",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'auth.external_concrete5'",
",",
"''",
")",
";",
"$",
"authUrl",
"=",
"$",
"this",
"->",
"urlResolver",
"->",
"resolve",
"(",
"[",
"'/ccm/system/authentication/oauth2/external_concrete5/attempt_auth'",
"]",
")",
";",
"$",
"attachUrl",
"=",
"$",
"this",
"->",
"urlResolver",
"->",
"resolve",
"(",
"[",
"'/ccm/system/authentication/oauth2/external_concrete5/attempt_attach'",
"]",
")",
";",
"$",
"baseUrl",
"=",
"$",
"this",
"->",
"urlResolver",
"->",
"resolve",
"(",
"[",
"'/'",
"]",
")",
";",
"$",
"path",
"=",
"$",
"baseUrl",
"->",
"getPath",
"(",
")",
";",
"$",
"path",
"->",
"remove",
"(",
"'index.php'",
")",
";",
"$",
"name",
"=",
"trim",
"(",
"(",
"string",
")",
"array_get",
"(",
"$",
"data",
",",
"'name'",
",",
"t",
"(",
"'External concrete5'",
")",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'data'",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'authUrl'",
",",
"$",
"authUrl",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'attachUrl'",
",",
"$",
"attachUrl",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'baseUrl'",
",",
"$",
"baseUrl",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'assetBase'",
",",
"$",
"baseUrl",
"->",
"setPath",
"(",
"$",
"path",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'name'",
",",
"$",
"name",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'user'",
",",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"User",
"::",
"class",
")",
")",
";",
"}"
] | Method for setting general data for all views | [
"Method",
"for",
"setting",
"general",
"data",
"for",
"all",
"views"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/authentication/external_concrete5/controller.php#L178-L195 | train |
concrete5/concrete5 | concrete/src/User/Password/PasswordChangeEventHandler.php | PasswordChangeEventHandler.handleEvent | public function handleEvent(Event $event)
{
if (!$event instanceof UserInfoWithPassword) {
throw new InvalidArgumentException(t('Invalid event type provided. Event type must be "UserInfoWithPassword".'));
}
// Track the password use
$this->tracker->trackUse($event->getUserPassword(), $event->getUserInfoObject());
} | php | public function handleEvent(Event $event)
{
if (!$event instanceof UserInfoWithPassword) {
throw new InvalidArgumentException(t('Invalid event type provided. Event type must be "UserInfoWithPassword".'));
}
// Track the password use
$this->tracker->trackUse($event->getUserPassword(), $event->getUserInfoObject());
} | [
"public",
"function",
"handleEvent",
"(",
"Event",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"$",
"event",
"instanceof",
"UserInfoWithPassword",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"t",
"(",
"'Invalid event type provided. Event type must be \"UserInfoWithPassword\".'",
")",
")",
";",
"}",
"// Track the password use",
"$",
"this",
"->",
"tracker",
"->",
"trackUse",
"(",
"$",
"event",
"->",
"getUserPassword",
"(",
")",
",",
"$",
"event",
"->",
"getUserInfoObject",
"(",
")",
")",
";",
"}"
] | Event handler for `on_user_change_password` events
@param \Symfony\Component\EventDispatcher\Event $event
@throws \InvalidArgumentException If the given event is not the proper subclass type. Must be `UserInfoWithPassword` | [
"Event",
"handler",
"for",
"on_user_change_password",
"events"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/Password/PasswordChangeEventHandler.php#L32-L40 | train |
concrete5/concrete5 | concrete/src/Service/Detector/HTTP/ApacheDetector.php | ApacheDetector.detectFromPHPInfo | private function detectFromPHPInfo($value)
{
$result = null;
if (is_string($value) && preg_match('/\bApache\/(\d+(\.\d+)+)/i', $value, $m)) {
$result = $m[1];
}
return $result;
} | php | private function detectFromPHPInfo($value)
{
$result = null;
if (is_string($value) && preg_match('/\bApache\/(\d+(\.\d+)+)/i', $value, $m)) {
$result = $m[1];
}
return $result;
} | [
"private",
"function",
"detectFromPHPInfo",
"(",
"$",
"value",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
"&&",
"preg_match",
"(",
"'/\\bApache\\/(\\d+(\\.\\d+)+)/i'",
",",
"$",
"value",
",",
"$",
"m",
")",
")",
"{",
"$",
"result",
"=",
"$",
"m",
"[",
"1",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Detect using PHPInfo.
@param string $value
@return null|string | [
"Detect",
"using",
"PHPInfo",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Service/Detector/HTTP/ApacheDetector.php#L110-L118 | train |
concrete5/concrete5 | concrete/src/Routing/Router.php | Router.route | public function route($data)
{
if (is_array($data)) {
$path = $data[0];
$pkg = $data[1];
} else {
$path = $data;
}
$path = trim($path, '/');
$pkgHandle = null;
if ($pkg) {
if (is_object($pkg)) {
$pkgHandle = $pkg->getPackageHandle();
} else {
$pkgHandle = $pkg;
}
}
$route = '/ccm';
if ($pkgHandle) {
$route .= "/{$pkgHandle}";
} else {
$route .= '/system';
}
$route .= "/{$path}";
return $route;
} | php | public function route($data)
{
if (is_array($data)) {
$path = $data[0];
$pkg = $data[1];
} else {
$path = $data;
}
$path = trim($path, '/');
$pkgHandle = null;
if ($pkg) {
if (is_object($pkg)) {
$pkgHandle = $pkg->getPackageHandle();
} else {
$pkgHandle = $pkg;
}
}
$route = '/ccm';
if ($pkgHandle) {
$route .= "/{$pkgHandle}";
} else {
$route .= '/system';
}
$route .= "/{$path}";
return $route;
} | [
"public",
"function",
"route",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"$",
"path",
"=",
"$",
"data",
"[",
"0",
"]",
";",
"$",
"pkg",
"=",
"$",
"data",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"$",
"path",
"=",
"$",
"data",
";",
"}",
"$",
"path",
"=",
"trim",
"(",
"$",
"path",
",",
"'/'",
")",
";",
"$",
"pkgHandle",
"=",
"null",
";",
"if",
"(",
"$",
"pkg",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"pkg",
")",
")",
"{",
"$",
"pkgHandle",
"=",
"$",
"pkg",
"->",
"getPackageHandle",
"(",
")",
";",
"}",
"else",
"{",
"$",
"pkgHandle",
"=",
"$",
"pkg",
";",
"}",
"}",
"$",
"route",
"=",
"'/ccm'",
";",
"if",
"(",
"$",
"pkgHandle",
")",
"{",
"$",
"route",
".=",
"\"/{$pkgHandle}\"",
";",
"}",
"else",
"{",
"$",
"route",
".=",
"'/system'",
";",
"}",
"$",
"route",
".=",
"\"/{$path}\"",
";",
"return",
"$",
"route",
";",
"}"
] | Returns a route string based on data. DO NOT USE THIS.
@deprecated
@param $data
@return string | [
"Returns",
"a",
"route",
"string",
"based",
"on",
"data",
".",
"DO",
"NOT",
"USE",
"THIS",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Routing/Router.php#L272-L301 | train |
concrete5/concrete5 | concrete/src/Cache/Page/PageCache.php | PageCache.deliver | public function deliver(PageCacheRecord $record)
{
$response = new Response();
$headers = [];
if (defined('APP_CHARSET')) {
$headers['Content-Type'] = 'text/html; charset=' . APP_CHARSET;
}
$headers = array_merge($headers, $record->getCacheRecordHeaders());
$response->headers->add($headers);
$response->setContent($record->getCacheRecordContent());
return $response;
} | php | public function deliver(PageCacheRecord $record)
{
$response = new Response();
$headers = [];
if (defined('APP_CHARSET')) {
$headers['Content-Type'] = 'text/html; charset=' . APP_CHARSET;
}
$headers = array_merge($headers, $record->getCacheRecordHeaders());
$response->headers->add($headers);
$response->setContent($record->getCacheRecordContent());
return $response;
} | [
"public",
"function",
"deliver",
"(",
"PageCacheRecord",
"$",
"record",
")",
"{",
"$",
"response",
"=",
"new",
"Response",
"(",
")",
";",
"$",
"headers",
"=",
"[",
"]",
";",
"if",
"(",
"defined",
"(",
"'APP_CHARSET'",
")",
")",
"{",
"$",
"headers",
"[",
"'Content-Type'",
"]",
"=",
"'text/html; charset='",
".",
"APP_CHARSET",
";",
"}",
"$",
"headers",
"=",
"array_merge",
"(",
"$",
"headers",
",",
"$",
"record",
"->",
"getCacheRecordHeaders",
"(",
")",
")",
";",
"$",
"response",
"->",
"headers",
"->",
"add",
"(",
"$",
"headers",
")",
";",
"$",
"response",
"->",
"setContent",
"(",
"$",
"record",
"->",
"getCacheRecordContent",
"(",
")",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Build a Response object starting from a cached page.
@param \Concrete\Core\Cache\Page\PageCacheRecord $record the cache record containing the cached page data
@return \Concrete\Core\Http\Response | [
"Build",
"a",
"Response",
"object",
"starting",
"from",
"a",
"cached",
"page",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Cache/Page/PageCache.php#L30-L43 | train |
concrete5/concrete5 | concrete/src/Cache/Page/PageCache.php | PageCache.getLibrary | public static function getLibrary()
{
if (!self::$library) {
$app = Application::getFacadeApplication();
$config = $app->make('config');
$adapter = $config->get('concrete.cache.page.adapter');
$class = overrideable_core_class(
'Core\\Cache\\Page\\' . camelcase($adapter) . 'PageCache',
DIRNAME_CLASSES . '/Cache/Page/' . camelcase($adapter) . 'PageCache.php'
);
self::$library = $app->build($class);
}
return self::$library;
} | php | public static function getLibrary()
{
if (!self::$library) {
$app = Application::getFacadeApplication();
$config = $app->make('config');
$adapter = $config->get('concrete.cache.page.adapter');
$class = overrideable_core_class(
'Core\\Cache\\Page\\' . camelcase($adapter) . 'PageCache',
DIRNAME_CLASSES . '/Cache/Page/' . camelcase($adapter) . 'PageCache.php'
);
self::$library = $app->build($class);
}
return self::$library;
} | [
"public",
"static",
"function",
"getLibrary",
"(",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"library",
")",
"{",
"$",
"app",
"=",
"Application",
"::",
"getFacadeApplication",
"(",
")",
";",
"$",
"config",
"=",
"$",
"app",
"->",
"make",
"(",
"'config'",
")",
";",
"$",
"adapter",
"=",
"$",
"config",
"->",
"get",
"(",
"'concrete.cache.page.adapter'",
")",
";",
"$",
"class",
"=",
"overrideable_core_class",
"(",
"'Core\\\\Cache\\\\Page\\\\'",
".",
"camelcase",
"(",
"$",
"adapter",
")",
".",
"'PageCache'",
",",
"DIRNAME_CLASSES",
".",
"'/Cache/Page/'",
".",
"camelcase",
"(",
"$",
"adapter",
")",
".",
"'PageCache.php'",
")",
";",
"self",
"::",
"$",
"library",
"=",
"$",
"app",
"->",
"build",
"(",
"$",
"class",
")",
";",
"}",
"return",
"self",
"::",
"$",
"library",
";",
"}"
] | Get the page cache library.
@return \Concrete\Core\Cache\Page\PageCache | [
"Get",
"the",
"page",
"cache",
"library",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Cache/Page/PageCache.php#L50-L64 | train |
concrete5/concrete5 | concrete/src/Cache/Page/PageCache.php | PageCache.shouldCheckCache | public function shouldCheckCache(Request $req)
{
if ($req->getMethod() === $req::METHOD_POST) {
return false;
}
$app = Application::getFacadeApplication();
$config = $app->make('config');
$cookie = $app->make('cookie');
$loginCookie = sprintf('%s_LOGIN', $config->get('concrete.session.name'));
if ($cookie->has($loginCookie) && $cookie->get($loginCookie)) {
return false;
}
return true;
} | php | public function shouldCheckCache(Request $req)
{
if ($req->getMethod() === $req::METHOD_POST) {
return false;
}
$app = Application::getFacadeApplication();
$config = $app->make('config');
$cookie = $app->make('cookie');
$loginCookie = sprintf('%s_LOGIN', $config->get('concrete.session.name'));
if ($cookie->has($loginCookie) && $cookie->get($loginCookie)) {
return false;
}
return true;
} | [
"public",
"function",
"shouldCheckCache",
"(",
"Request",
"$",
"req",
")",
"{",
"if",
"(",
"$",
"req",
"->",
"getMethod",
"(",
")",
"===",
"$",
"req",
"::",
"METHOD_POST",
")",
"{",
"return",
"false",
";",
"}",
"$",
"app",
"=",
"Application",
"::",
"getFacadeApplication",
"(",
")",
";",
"$",
"config",
"=",
"$",
"app",
"->",
"make",
"(",
"'config'",
")",
";",
"$",
"cookie",
"=",
"$",
"app",
"->",
"make",
"(",
"'cookie'",
")",
";",
"$",
"loginCookie",
"=",
"sprintf",
"(",
"'%s_LOGIN'",
",",
"$",
"config",
"->",
"get",
"(",
"'concrete.session.name'",
")",
")",
";",
"if",
"(",
"$",
"cookie",
"->",
"has",
"(",
"$",
"loginCookie",
")",
"&&",
"$",
"cookie",
"->",
"get",
"(",
"$",
"loginCookie",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Determine if we should check if a page is in the cache.
@param \Concrete\Core\Http\Request $req
@return bool | [
"Determine",
"if",
"we",
"should",
"check",
"if",
"a",
"page",
"is",
"in",
"the",
"cache",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Cache/Page/PageCache.php#L73-L88 | train |
concrete5/concrete5 | concrete/src/Cache/Page/PageCache.php | PageCache.outputCacheHeaders | public function outputCacheHeaders(ConcretePage $c)
{
foreach ($this->getCacheHeaders($c) as $header) {
header($header);
}
} | php | public function outputCacheHeaders(ConcretePage $c)
{
foreach ($this->getCacheHeaders($c) as $header) {
header($header);
}
} | [
"public",
"function",
"outputCacheHeaders",
"(",
"ConcretePage",
"$",
"c",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getCacheHeaders",
"(",
"$",
"c",
")",
"as",
"$",
"header",
")",
"{",
"header",
"(",
"$",
"header",
")",
";",
"}",
"}"
] | Send the cache-related HTTP headers for a page to the current response.
@deprecated Headers are no longer set directly. Instead, use the
<code>$pageCache->deliver()</code>
method to retrieve a response object and either return it from a controller method or, if you must, use
<code>$response->prepare($request)->send()</code>
@param \Concrete\Core\Page\Page $c | [
"Send",
"the",
"cache",
"-",
"related",
"HTTP",
"headers",
"for",
"a",
"page",
"to",
"the",
"current",
"response",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Cache/Page/PageCache.php#L100-L105 | train |
concrete5/concrete5 | concrete/src/Cache/Page/PageCache.php | PageCache.getCacheHeaders | public function getCacheHeaders(ConcretePage $c)
{
$lifetime = $c->getCollectionFullPageCachingLifetimeValue();
$expires = gmdate('D, d M Y H:i:s', time() + $lifetime) . ' GMT';
$headers = [
'Pragma' => 'public',
'Cache-Control' => 'max-age=' . $lifetime . ',s-maxage=' . $lifetime,
'Expires' => $expires,
];
return $headers;
} | php | public function getCacheHeaders(ConcretePage $c)
{
$lifetime = $c->getCollectionFullPageCachingLifetimeValue();
$expires = gmdate('D, d M Y H:i:s', time() + $lifetime) . ' GMT';
$headers = [
'Pragma' => 'public',
'Cache-Control' => 'max-age=' . $lifetime . ',s-maxage=' . $lifetime,
'Expires' => $expires,
];
return $headers;
} | [
"public",
"function",
"getCacheHeaders",
"(",
"ConcretePage",
"$",
"c",
")",
"{",
"$",
"lifetime",
"=",
"$",
"c",
"->",
"getCollectionFullPageCachingLifetimeValue",
"(",
")",
";",
"$",
"expires",
"=",
"gmdate",
"(",
"'D, d M Y H:i:s'",
",",
"time",
"(",
")",
"+",
"$",
"lifetime",
")",
".",
"' GMT'",
";",
"$",
"headers",
"=",
"[",
"'Pragma'",
"=>",
"'public'",
",",
"'Cache-Control'",
"=>",
"'max-age='",
".",
"$",
"lifetime",
".",
"',s-maxage='",
".",
"$",
"lifetime",
",",
"'Expires'",
"=>",
"$",
"expires",
",",
"]",
";",
"return",
"$",
"headers",
";",
"}"
] | Get the cache-related HTTP headers for a page.
@param \Concrete\Core\Page\Page $c
@return array Keys are the header names; values are the header values | [
"Get",
"the",
"cache",
"-",
"related",
"HTTP",
"headers",
"for",
"a",
"page",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Cache/Page/PageCache.php#L114-L126 | train |
concrete5/concrete5 | concrete/src/Cache/Page/PageCache.php | PageCache.shouldAddToCache | public function shouldAddToCache(PageView $v)
{
$c = $v->getPageObject();
if (!is_object($c)) {
return false;
}
$cp = new Checker($c);
if (!$cp->canViewPage()) {
return false;
}
if (is_object($v->controller)) {
$allowedControllerActions = ['view'];
if (!in_array($v->controller->getAction(), $allowedControllerActions)) {
return false;
}
if ($c->isGeneratedCollection() && !$v->controller->supportsPageCache()) {
return false;
}
}
if (!$c->getCollectionFullPageCaching()) {
return false;
}
$app = Application::getFacadeApplication();
$request = $app->make(Request::class);
if ($request->getMethod() === $request::METHOD_POST) {
return false;
}
$u = $app->make(User::class);
if ($u->isRegistered()) {
return false;
}
$config = $app->make('config');
if ($c->getCollectionFullPageCaching() == 1 || $config->get('concrete.cache.pages') === 'all') {
// this cache page at the page level
// this overrides any global settings
return true;
}
if ($config->get('concrete.cache.pages') !== 'blocks') {
// we are NOT specifically caching this page, and we don't
return false;
}
$blocks = $c->getBlocks();
$blocks = array_merge($c->getGlobalBlocks(), $blocks);
foreach ($blocks as $b) {
if (!$b->cacheBlockOutput()) {
return false;
}
}
return true;
} | php | public function shouldAddToCache(PageView $v)
{
$c = $v->getPageObject();
if (!is_object($c)) {
return false;
}
$cp = new Checker($c);
if (!$cp->canViewPage()) {
return false;
}
if (is_object($v->controller)) {
$allowedControllerActions = ['view'];
if (!in_array($v->controller->getAction(), $allowedControllerActions)) {
return false;
}
if ($c->isGeneratedCollection() && !$v->controller->supportsPageCache()) {
return false;
}
}
if (!$c->getCollectionFullPageCaching()) {
return false;
}
$app = Application::getFacadeApplication();
$request = $app->make(Request::class);
if ($request->getMethod() === $request::METHOD_POST) {
return false;
}
$u = $app->make(User::class);
if ($u->isRegistered()) {
return false;
}
$config = $app->make('config');
if ($c->getCollectionFullPageCaching() == 1 || $config->get('concrete.cache.pages') === 'all') {
// this cache page at the page level
// this overrides any global settings
return true;
}
if ($config->get('concrete.cache.pages') !== 'blocks') {
// we are NOT specifically caching this page, and we don't
return false;
}
$blocks = $c->getBlocks();
$blocks = array_merge($c->getGlobalBlocks(), $blocks);
foreach ($blocks as $b) {
if (!$b->cacheBlockOutput()) {
return false;
}
}
return true;
} | [
"public",
"function",
"shouldAddToCache",
"(",
"PageView",
"$",
"v",
")",
"{",
"$",
"c",
"=",
"$",
"v",
"->",
"getPageObject",
"(",
")",
";",
"if",
"(",
"!",
"is_object",
"(",
"$",
"c",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"cp",
"=",
"new",
"Checker",
"(",
"$",
"c",
")",
";",
"if",
"(",
"!",
"$",
"cp",
"->",
"canViewPage",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"v",
"->",
"controller",
")",
")",
"{",
"$",
"allowedControllerActions",
"=",
"[",
"'view'",
"]",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"v",
"->",
"controller",
"->",
"getAction",
"(",
")",
",",
"$",
"allowedControllerActions",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"c",
"->",
"isGeneratedCollection",
"(",
")",
"&&",
"!",
"$",
"v",
"->",
"controller",
"->",
"supportsPageCache",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"c",
"->",
"getCollectionFullPageCaching",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"app",
"=",
"Application",
"::",
"getFacadeApplication",
"(",
")",
";",
"$",
"request",
"=",
"$",
"app",
"->",
"make",
"(",
"Request",
"::",
"class",
")",
";",
"if",
"(",
"$",
"request",
"->",
"getMethod",
"(",
")",
"===",
"$",
"request",
"::",
"METHOD_POST",
")",
"{",
"return",
"false",
";",
"}",
"$",
"u",
"=",
"$",
"app",
"->",
"make",
"(",
"User",
"::",
"class",
")",
";",
"if",
"(",
"$",
"u",
"->",
"isRegistered",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"config",
"=",
"$",
"app",
"->",
"make",
"(",
"'config'",
")",
";",
"if",
"(",
"$",
"c",
"->",
"getCollectionFullPageCaching",
"(",
")",
"==",
"1",
"||",
"$",
"config",
"->",
"get",
"(",
"'concrete.cache.pages'",
")",
"===",
"'all'",
")",
"{",
"// this cache page at the page level",
"// this overrides any global settings",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"config",
"->",
"get",
"(",
"'concrete.cache.pages'",
")",
"!==",
"'blocks'",
")",
"{",
"// we are NOT specifically caching this page, and we don't",
"return",
"false",
";",
"}",
"$",
"blocks",
"=",
"$",
"c",
"->",
"getBlocks",
"(",
")",
";",
"$",
"blocks",
"=",
"array_merge",
"(",
"$",
"c",
"->",
"getGlobalBlocks",
"(",
")",
",",
"$",
"blocks",
")",
";",
"foreach",
"(",
"$",
"blocks",
"as",
"$",
"b",
")",
"{",
"if",
"(",
"!",
"$",
"b",
"->",
"cacheBlockOutput",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Check if a page contained in a PageView should be stored in the cache.
@param \Concrete\Core\Page\View\PageView $v
@return bool | [
"Check",
"if",
"a",
"page",
"contained",
"in",
"a",
"PageView",
"should",
"be",
"stored",
"in",
"the",
"cache",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Cache/Page/PageCache.php#L135-L194 | train |
concrete5/concrete5 | concrete/src/Cache/Page/PageCache.php | PageCache.getCacheKey | public function getCacheKey($mixed)
{
if ($mixed instanceof ConcretePage) {
$collectionPath = trim((string) $mixed->getCollectionPath(), '/');
if ($collectionPath !== '') {
return urlencode($collectionPath);
}
$cID = $mixed->getCollectionID();
if ($cID && $cID == ConcretePage::getHomePageID()) {
return '!' . $cID;
}
} elseif ($mixed instanceof Request) {
$path = trim((string) $mixed->getPath(), '/');
if ($path !== '') {
return urlencode($path);
}
return '!' . ConcretePage::getHomePageID();
} elseif ($mixed instanceof PageCacheRecord) {
return $mixed->getCacheRecordKey();
}
} | php | public function getCacheKey($mixed)
{
if ($mixed instanceof ConcretePage) {
$collectionPath = trim((string) $mixed->getCollectionPath(), '/');
if ($collectionPath !== '') {
return urlencode($collectionPath);
}
$cID = $mixed->getCollectionID();
if ($cID && $cID == ConcretePage::getHomePageID()) {
return '!' . $cID;
}
} elseif ($mixed instanceof Request) {
$path = trim((string) $mixed->getPath(), '/');
if ($path !== '') {
return urlencode($path);
}
return '!' . ConcretePage::getHomePageID();
} elseif ($mixed instanceof PageCacheRecord) {
return $mixed->getCacheRecordKey();
}
} | [
"public",
"function",
"getCacheKey",
"(",
"$",
"mixed",
")",
"{",
"if",
"(",
"$",
"mixed",
"instanceof",
"ConcretePage",
")",
"{",
"$",
"collectionPath",
"=",
"trim",
"(",
"(",
"string",
")",
"$",
"mixed",
"->",
"getCollectionPath",
"(",
")",
",",
"'/'",
")",
";",
"if",
"(",
"$",
"collectionPath",
"!==",
"''",
")",
"{",
"return",
"urlencode",
"(",
"$",
"collectionPath",
")",
";",
"}",
"$",
"cID",
"=",
"$",
"mixed",
"->",
"getCollectionID",
"(",
")",
";",
"if",
"(",
"$",
"cID",
"&&",
"$",
"cID",
"==",
"ConcretePage",
"::",
"getHomePageID",
"(",
")",
")",
"{",
"return",
"'!'",
".",
"$",
"cID",
";",
"}",
"}",
"elseif",
"(",
"$",
"mixed",
"instanceof",
"Request",
")",
"{",
"$",
"path",
"=",
"trim",
"(",
"(",
"string",
")",
"$",
"mixed",
"->",
"getPath",
"(",
")",
",",
"'/'",
")",
";",
"if",
"(",
"$",
"path",
"!==",
"''",
")",
"{",
"return",
"urlencode",
"(",
"$",
"path",
")",
";",
"}",
"return",
"'!'",
".",
"ConcretePage",
"::",
"getHomePageID",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"mixed",
"instanceof",
"PageCacheRecord",
")",
"{",
"return",
"$",
"mixed",
"->",
"getCacheRecordKey",
"(",
")",
";",
"}",
"}"
] | Get the key that identifies the cache entry for a page or a request.
@param \Concrete\Core\Page\Page|\Concrete\Core\Http\Request|\Concrete\Core\Cache\Page\PageCacheRecord|mixed $mixed
@return string|null Returns NULL if $mixed is not a recognized type, a string otherwise | [
"Get",
"the",
"key",
"that",
"identifies",
"the",
"cache",
"entry",
"for",
"a",
"page",
"or",
"a",
"request",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Cache/Page/PageCache.php#L203-L224 | train |
concrete5/concrete5 | concrete/controllers/single_page/dashboard/blocks/stacks.php | Stacks.canMoveStacks | protected function canMoveStacks($parent)
{
$page = ($parent instanceof \Concrete\Core\Page\Page) ? $parent : $parent->getPage();
$cpc = new Permissions($page);
return (bool) $cpc->canMoveOrCopyPage();
} | php | protected function canMoveStacks($parent)
{
$page = ($parent instanceof \Concrete\Core\Page\Page) ? $parent : $parent->getPage();
$cpc = new Permissions($page);
return (bool) $cpc->canMoveOrCopyPage();
} | [
"protected",
"function",
"canMoveStacks",
"(",
"$",
"parent",
")",
"{",
"$",
"page",
"=",
"(",
"$",
"parent",
"instanceof",
"\\",
"Concrete",
"\\",
"Core",
"\\",
"Page",
"\\",
"Page",
")",
"?",
"$",
"parent",
":",
"$",
"parent",
"->",
"getPage",
"(",
")",
";",
"$",
"cpc",
"=",
"new",
"Permissions",
"(",
"$",
"page",
")",
";",
"return",
"(",
"bool",
")",
"$",
"cpc",
"->",
"canMoveOrCopyPage",
"(",
")",
";",
"}"
] | Check if stacks in a Page or StackFolder can be moved.
@param Page|StackFolder $parent
@return bool | [
"Check",
"if",
"stacks",
"in",
"a",
"Page",
"or",
"StackFolder",
"can",
"be",
"moved",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/controllers/single_page/dashboard/blocks/stacks.php#L230-L236 | train |
concrete5/concrete5 | concrete/src/Logging/Entry/User/LoginAttempt.php | LoginAttempt.getContext | public function getContext()
{
return [
'username' => $this->username,
'requestPath' => $this->requestPath,
'errors' => $this->errors,
'groups' => $this->groups,
'successful' => !$this->errors
];
} | php | public function getContext()
{
return [
'username' => $this->username,
'requestPath' => $this->requestPath,
'errors' => $this->errors,
'groups' => $this->groups,
'successful' => !$this->errors
];
} | [
"public",
"function",
"getContext",
"(",
")",
"{",
"return",
"[",
"'username'",
"=>",
"$",
"this",
"->",
"username",
",",
"'requestPath'",
"=>",
"$",
"this",
"->",
"requestPath",
",",
"'errors'",
"=>",
"$",
"this",
"->",
"errors",
",",
"'groups'",
"=>",
"$",
"this",
"->",
"groups",
",",
"'successful'",
"=>",
"!",
"$",
"this",
"->",
"errors",
"]",
";",
"}"
] | Get the added context for the log entry
Ex: ["username": "...", "email": "...", "id": "...", "created_by": "..."]
@return array | [
"Get",
"the",
"added",
"context",
"for",
"the",
"log",
"entry"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Logging/Entry/User/LoginAttempt.php#L75-L84 | train |
concrete5/concrete5 | concrete/src/Page/PageList.php | PageList.filterByPageTemplate | public function filterByPageTemplate(TemplateEntity $template)
{
$this->query->andWhere('cv.pTemplateID = :pTemplateID');
$this->query->setParameter('pTemplateID', $template->getPageTemplateID());
} | php | public function filterByPageTemplate(TemplateEntity $template)
{
$this->query->andWhere('cv.pTemplateID = :pTemplateID');
$this->query->setParameter('pTemplateID', $template->getPageTemplateID());
} | [
"public",
"function",
"filterByPageTemplate",
"(",
"TemplateEntity",
"$",
"template",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"andWhere",
"(",
"'cv.pTemplateID = :pTemplateID'",
")",
";",
"$",
"this",
"->",
"query",
"->",
"setParameter",
"(",
"'pTemplateID'",
",",
"$",
"template",
"->",
"getPageTemplateID",
"(",
")",
")",
";",
"}"
] | Filters by page template.
@param mixed $ptHandle | [
"Filters",
"by",
"page",
"template",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/PageList.php#L403-L407 | train |
concrete5/concrete5 | concrete/src/Page/PageList.php | PageList.filterByNumberOfChildren | public function filterByNumberOfChildren($number, $comparison = '>')
{
$number = intval($number);
if ($this->includeAliases) {
$this->query->andWhere(
$this->query->expr()->orX(
$this->query->expr()->comparison('p.cChildren', $comparison, ':cChildren'),
$this->query->expr()->comparison('pa.cChildren', $comparison, ':cChildren')
)
);
} else {
$this->query->andWhere($this->query->expr()->comparison('p.cChildren', $comparison, ':cChildren'));
}
$this->query->setParameter('cChildren', $number);
} | php | public function filterByNumberOfChildren($number, $comparison = '>')
{
$number = intval($number);
if ($this->includeAliases) {
$this->query->andWhere(
$this->query->expr()->orX(
$this->query->expr()->comparison('p.cChildren', $comparison, ':cChildren'),
$this->query->expr()->comparison('pa.cChildren', $comparison, ':cChildren')
)
);
} else {
$this->query->andWhere($this->query->expr()->comparison('p.cChildren', $comparison, ':cChildren'));
}
$this->query->setParameter('cChildren', $number);
} | [
"public",
"function",
"filterByNumberOfChildren",
"(",
"$",
"number",
",",
"$",
"comparison",
"=",
"'>'",
")",
"{",
"$",
"number",
"=",
"intval",
"(",
"$",
"number",
")",
";",
"if",
"(",
"$",
"this",
"->",
"includeAliases",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"andWhere",
"(",
"$",
"this",
"->",
"query",
"->",
"expr",
"(",
")",
"->",
"orX",
"(",
"$",
"this",
"->",
"query",
"->",
"expr",
"(",
")",
"->",
"comparison",
"(",
"'p.cChildren'",
",",
"$",
"comparison",
",",
"':cChildren'",
")",
",",
"$",
"this",
"->",
"query",
"->",
"expr",
"(",
")",
"->",
"comparison",
"(",
"'pa.cChildren'",
",",
"$",
"comparison",
",",
"':cChildren'",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"query",
"->",
"andWhere",
"(",
"$",
"this",
"->",
"query",
"->",
"expr",
"(",
")",
"->",
"comparison",
"(",
"'p.cChildren'",
",",
"$",
"comparison",
",",
"':cChildren'",
")",
")",
";",
"}",
"$",
"this",
"->",
"query",
"->",
"setParameter",
"(",
"'cChildren'",
",",
"$",
"number",
")",
";",
"}"
] | Filter by number of children.
@param $number
@param string $comparison | [
"Filter",
"by",
"number",
"of",
"children",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/PageList.php#L425-L439 | train |
concrete5/concrete5 | concrete/src/Page/PageList.php | PageList.filterByDateLastModified | public function filterByDateLastModified($date, $comparison = '=')
{
$this->query->andWhere($this->query->expr()->comparison('c.cDateModified', $comparison, $this->query->createNamedParameter($date)));
} | php | public function filterByDateLastModified($date, $comparison = '=')
{
$this->query->andWhere($this->query->expr()->comparison('c.cDateModified', $comparison, $this->query->createNamedParameter($date)));
} | [
"public",
"function",
"filterByDateLastModified",
"(",
"$",
"date",
",",
"$",
"comparison",
"=",
"'='",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"andWhere",
"(",
"$",
"this",
"->",
"query",
"->",
"expr",
"(",
")",
"->",
"comparison",
"(",
"'c.cDateModified'",
",",
"$",
"comparison",
",",
"$",
"this",
"->",
"query",
"->",
"createNamedParameter",
"(",
"$",
"date",
")",
")",
")",
";",
"}"
] | Filter by last modified date.
@param $date
@param string $comparison | [
"Filter",
"by",
"last",
"modified",
"date",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/PageList.php#L447-L450 | train |
concrete5/concrete5 | concrete/src/Page/PageList.php | PageList.filterByPageTypeID | public function filterByPageTypeID($ptID)
{
$db = \Database::get();
if (is_array($ptID)) {
$this->query->andWhere(
$this->query->expr()->in('pt.ptID', array_map([$db, 'quote'], $ptID))
);
} else {
$this->query->andWhere($this->query->expr()->comparison('pt.ptID', '=', ':ptID'));
$this->query->setParameter('ptID', $ptID, \PDO::PARAM_INT);
}
} | php | public function filterByPageTypeID($ptID)
{
$db = \Database::get();
if (is_array($ptID)) {
$this->query->andWhere(
$this->query->expr()->in('pt.ptID', array_map([$db, 'quote'], $ptID))
);
} else {
$this->query->andWhere($this->query->expr()->comparison('pt.ptID', '=', ':ptID'));
$this->query->setParameter('ptID', $ptID, \PDO::PARAM_INT);
}
} | [
"public",
"function",
"filterByPageTypeID",
"(",
"$",
"ptID",
")",
"{",
"$",
"db",
"=",
"\\",
"Database",
"::",
"get",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"ptID",
")",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"andWhere",
"(",
"$",
"this",
"->",
"query",
"->",
"expr",
"(",
")",
"->",
"in",
"(",
"'pt.ptID'",
",",
"array_map",
"(",
"[",
"$",
"db",
",",
"'quote'",
"]",
",",
"$",
"ptID",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"query",
"->",
"andWhere",
"(",
"$",
"this",
"->",
"query",
"->",
"expr",
"(",
")",
"->",
"comparison",
"(",
"'pt.ptID'",
",",
"'='",
",",
"':ptID'",
")",
")",
";",
"$",
"this",
"->",
"query",
"->",
"setParameter",
"(",
"'ptID'",
",",
"$",
"ptID",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
";",
"}",
"}"
] | Filters by page type ID.
@param array | integer $cParentID | [
"Filters",
"by",
"page",
"type",
"ID",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/PageList.php#L500-L511 | train |
concrete5/concrete5 | concrete/src/Page/PageList.php | PageList.filterByParentID | public function filterByParentID($cParentID)
{
$db = \Database::get();
if (is_array($cParentID)) {
$this->query->andWhere(
$this->query->expr()->in('p.cParentID', array_map([$db, 'quote'], $cParentID))
);
} else {
$this->query->andWhere('p.cParentID = :cParentID');
$this->query->setParameter('cParentID', $cParentID, \PDO::PARAM_INT);
}
} | php | public function filterByParentID($cParentID)
{
$db = \Database::get();
if (is_array($cParentID)) {
$this->query->andWhere(
$this->query->expr()->in('p.cParentID', array_map([$db, 'quote'], $cParentID))
);
} else {
$this->query->andWhere('p.cParentID = :cParentID');
$this->query->setParameter('cParentID', $cParentID, \PDO::PARAM_INT);
}
} | [
"public",
"function",
"filterByParentID",
"(",
"$",
"cParentID",
")",
"{",
"$",
"db",
"=",
"\\",
"Database",
"::",
"get",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"cParentID",
")",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"andWhere",
"(",
"$",
"this",
"->",
"query",
"->",
"expr",
"(",
")",
"->",
"in",
"(",
"'p.cParentID'",
",",
"array_map",
"(",
"[",
"$",
"db",
",",
"'quote'",
"]",
",",
"$",
"cParentID",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"query",
"->",
"andWhere",
"(",
"'p.cParentID = :cParentID'",
")",
";",
"$",
"this",
"->",
"query",
"->",
"setParameter",
"(",
"'cParentID'",
",",
"$",
"cParentID",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
";",
"}",
"}"
] | Filters by parent ID.
@param array | integer $cParentID | [
"Filters",
"by",
"parent",
"ID",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/PageList.php#L518-L529 | train |
concrete5/concrete5 | concrete/src/Page/PageList.php | PageList.filterByName | public function filterByName($name, $exact = false)
{
if ($exact) {
$this->query->andWhere('cv.cvName = :cvName');
$this->query->setParameter('cvName', $name);
} else {
$this->query->andWhere(
$this->query->expr()->like('cv.cvName', ':cvName')
);
$this->query->setParameter('cvName', '%' . $name . '%');
}
} | php | public function filterByName($name, $exact = false)
{
if ($exact) {
$this->query->andWhere('cv.cvName = :cvName');
$this->query->setParameter('cvName', $name);
} else {
$this->query->andWhere(
$this->query->expr()->like('cv.cvName', ':cvName')
);
$this->query->setParameter('cvName', '%' . $name . '%');
}
} | [
"public",
"function",
"filterByName",
"(",
"$",
"name",
",",
"$",
"exact",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"exact",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"andWhere",
"(",
"'cv.cvName = :cvName'",
")",
";",
"$",
"this",
"->",
"query",
"->",
"setParameter",
"(",
"'cvName'",
",",
"$",
"name",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"query",
"->",
"andWhere",
"(",
"$",
"this",
"->",
"query",
"->",
"expr",
"(",
")",
"->",
"like",
"(",
"'cv.cvName'",
",",
"':cvName'",
")",
")",
";",
"$",
"this",
"->",
"query",
"->",
"setParameter",
"(",
"'cvName'",
",",
"'%'",
".",
"$",
"name",
".",
"'%'",
")",
";",
"}",
"}"
] | Filters a list by page name.
@param $name
@param bool $exact | [
"Filters",
"a",
"list",
"by",
"page",
"name",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/PageList.php#L537-L548 | train |
concrete5/concrete5 | concrete/src/Page/PageList.php | PageList.filterByPath | public function filterByPath($path, $includeAllChildren = true)
{
if (!$includeAllChildren) {
$this->query->andWhere('pp.cPath = :cPath');
$this->query->setParameter('cPath', $path);
} else {
$this->query->andWhere(
$this->query->expr()->like('pp.cPath', ':cPath')
);
$this->query->setParameter('cPath', $path . '/%');
}
$this->query->andWhere('pp.ppIsCanonical = 1');
} | php | public function filterByPath($path, $includeAllChildren = true)
{
if (!$includeAllChildren) {
$this->query->andWhere('pp.cPath = :cPath');
$this->query->setParameter('cPath', $path);
} else {
$this->query->andWhere(
$this->query->expr()->like('pp.cPath', ':cPath')
);
$this->query->setParameter('cPath', $path . '/%');
}
$this->query->andWhere('pp.ppIsCanonical = 1');
} | [
"public",
"function",
"filterByPath",
"(",
"$",
"path",
",",
"$",
"includeAllChildren",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"includeAllChildren",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"andWhere",
"(",
"'pp.cPath = :cPath'",
")",
";",
"$",
"this",
"->",
"query",
"->",
"setParameter",
"(",
"'cPath'",
",",
"$",
"path",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"query",
"->",
"andWhere",
"(",
"$",
"this",
"->",
"query",
"->",
"expr",
"(",
")",
"->",
"like",
"(",
"'pp.cPath'",
",",
"':cPath'",
")",
")",
";",
"$",
"this",
"->",
"query",
"->",
"setParameter",
"(",
"'cPath'",
",",
"$",
"path",
".",
"'/%'",
")",
";",
"}",
"$",
"this",
"->",
"query",
"->",
"andWhere",
"(",
"'pp.ppIsCanonical = 1'",
")",
";",
"}"
] | Filter a list by page path.
@param $path
@param bool $includeAllChildren | [
"Filter",
"a",
"list",
"by",
"page",
"path",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/PageList.php#L556-L568 | train |
concrete5/concrete5 | concrete/src/Page/PageList.php | PageList.filterByKeywords | public function filterByKeywords($keywords)
{
$expressions = [
$this->query->expr()->like('psi.cName', ':keywords'),
$this->query->expr()->like('psi.cDescription', ':keywords'),
$this->query->expr()->like('psi.content', ':keywords'),
];
$keys = \CollectionAttributeKey::getSearchableIndexedList();
foreach ($keys as $ak) {
$cnt = $ak->getController();
$expressions[] = $cnt->searchKeywords($keywords, $this->query);
}
$expr = $this->query->expr();
$this->query->andWhere(call_user_func_array([$expr, 'orX'], $expressions));
$this->query->setParameter('keywords', '%' . $keywords . '%');
} | php | public function filterByKeywords($keywords)
{
$expressions = [
$this->query->expr()->like('psi.cName', ':keywords'),
$this->query->expr()->like('psi.cDescription', ':keywords'),
$this->query->expr()->like('psi.content', ':keywords'),
];
$keys = \CollectionAttributeKey::getSearchableIndexedList();
foreach ($keys as $ak) {
$cnt = $ak->getController();
$expressions[] = $cnt->searchKeywords($keywords, $this->query);
}
$expr = $this->query->expr();
$this->query->andWhere(call_user_func_array([$expr, 'orX'], $expressions));
$this->query->setParameter('keywords', '%' . $keywords . '%');
} | [
"public",
"function",
"filterByKeywords",
"(",
"$",
"keywords",
")",
"{",
"$",
"expressions",
"=",
"[",
"$",
"this",
"->",
"query",
"->",
"expr",
"(",
")",
"->",
"like",
"(",
"'psi.cName'",
",",
"':keywords'",
")",
",",
"$",
"this",
"->",
"query",
"->",
"expr",
"(",
")",
"->",
"like",
"(",
"'psi.cDescription'",
",",
"':keywords'",
")",
",",
"$",
"this",
"->",
"query",
"->",
"expr",
"(",
")",
"->",
"like",
"(",
"'psi.content'",
",",
"':keywords'",
")",
",",
"]",
";",
"$",
"keys",
"=",
"\\",
"CollectionAttributeKey",
"::",
"getSearchableIndexedList",
"(",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"ak",
")",
"{",
"$",
"cnt",
"=",
"$",
"ak",
"->",
"getController",
"(",
")",
";",
"$",
"expressions",
"[",
"]",
"=",
"$",
"cnt",
"->",
"searchKeywords",
"(",
"$",
"keywords",
",",
"$",
"this",
"->",
"query",
")",
";",
"}",
"$",
"expr",
"=",
"$",
"this",
"->",
"query",
"->",
"expr",
"(",
")",
";",
"$",
"this",
"->",
"query",
"->",
"andWhere",
"(",
"call_user_func_array",
"(",
"[",
"$",
"expr",
",",
"'orX'",
"]",
",",
"$",
"expressions",
")",
")",
";",
"$",
"this",
"->",
"query",
"->",
"setParameter",
"(",
"'keywords'",
",",
"'%'",
".",
"$",
"keywords",
".",
"'%'",
")",
";",
"}"
] | Filters keyword fields by keywords (including name, description, content, and attributes.
@param $keywords | [
"Filters",
"keyword",
"fields",
"by",
"keywords",
"(",
"including",
"name",
"description",
"content",
"and",
"attributes",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/PageList.php#L575-L591 | train |
concrete5/concrete5 | concrete/src/Http/Client/Factory.php | Factory.getOptions | protected function getOptions(Repository $config)
{
$result = $config->get('app.http_client');
if (!is_array($result)) {
$result = [];
}
$result['proxyhost'] = $config->get('concrete.proxy.host');
$result['proxyport'] = $config->get('concrete.proxy.port');
$result['proxyuser'] = $config->get('concrete.proxy.user');
$result['proxypass'] = $config->get('concrete.proxy.password');
return $result;
} | php | protected function getOptions(Repository $config)
{
$result = $config->get('app.http_client');
if (!is_array($result)) {
$result = [];
}
$result['proxyhost'] = $config->get('concrete.proxy.host');
$result['proxyport'] = $config->get('concrete.proxy.port');
$result['proxyuser'] = $config->get('concrete.proxy.user');
$result['proxypass'] = $config->get('concrete.proxy.password');
return $result;
} | [
"protected",
"function",
"getOptions",
"(",
"Repository",
"$",
"config",
")",
"{",
"$",
"result",
"=",
"$",
"config",
"->",
"get",
"(",
"'app.http_client'",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"result",
")",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"}",
"$",
"result",
"[",
"'proxyhost'",
"]",
"=",
"$",
"config",
"->",
"get",
"(",
"'concrete.proxy.host'",
")",
";",
"$",
"result",
"[",
"'proxyport'",
"]",
"=",
"$",
"config",
"->",
"get",
"(",
"'concrete.proxy.port'",
")",
";",
"$",
"result",
"[",
"'proxyuser'",
"]",
"=",
"$",
"config",
"->",
"get",
"(",
"'concrete.proxy.user'",
")",
";",
"$",
"result",
"[",
"'proxypass'",
"]",
"=",
"$",
"config",
"->",
"get",
"(",
"'concrete.proxy.password'",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Read the HTTP Client configuration.
@param Repository $config
@return array {
@var bool $sslverifypeer [always]
@var string $proxyhost [optional]
@var int $proxyport [optional]
@var string $proxyuser [optional]
@var string $proxypass [optional]
... and all other options set in app.curl
} | [
"Read",
"the",
"HTTP",
"Client",
"configuration",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Http/Client/Factory.php#L38-L50 | train |
concrete5/concrete5 | concrete/src/Site/Config/Liaison.php | Liaison.transformKey | protected function transformKey($key)
{
$key = sprintf('site.sites.%s.%s', $this->site->getSiteHandle(), $key);
return parent::transformKey($key);
} | php | protected function transformKey($key)
{
$key = sprintf('site.sites.%s.%s', $this->site->getSiteHandle(), $key);
return parent::transformKey($key);
} | [
"protected",
"function",
"transformKey",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"sprintf",
"(",
"'site.sites.%s.%s'",
",",
"$",
"this",
"->",
"site",
"->",
"getSiteHandle",
"(",
")",
",",
"$",
"key",
")",
";",
"return",
"parent",
"::",
"transformKey",
"(",
"$",
"key",
")",
";",
"}"
] | Prepend the "site" config group and the current site handle
@param $key
@return string | [
"Prepend",
"the",
"site",
"config",
"group",
"and",
"the",
"current",
"site",
"handle"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Site/Config/Liaison.php#L27-L31 | train |
concrete5/concrete5 | concrete/src/Device/Device.php | Device.getViewportHTML | public function getViewportHTML()
{
$added_data = array(
'handle',
'name',
'brand',
'width',
'height',
'ratio',
'agent', );
$datas = array();
foreach ($added_data as $key) {
$datas[] = sprintf('data-device-%s="%s"', $key, h($this->{$key}));
}
return sprintf(
'<div class="ccm-device-viewport" %s style="width:%spx;height:%spx">%s</div>',
implode(' ', $datas),
floor($this->getWidth() / $this->getPixelRatio()),
floor($this->getHeight() / $this->getPixelRatio()),
'<iframe class="ccm-display-frame"></iframe>');
} | php | public function getViewportHTML()
{
$added_data = array(
'handle',
'name',
'brand',
'width',
'height',
'ratio',
'agent', );
$datas = array();
foreach ($added_data as $key) {
$datas[] = sprintf('data-device-%s="%s"', $key, h($this->{$key}));
}
return sprintf(
'<div class="ccm-device-viewport" %s style="width:%spx;height:%spx">%s</div>',
implode(' ', $datas),
floor($this->getWidth() / $this->getPixelRatio()),
floor($this->getHeight() / $this->getPixelRatio()),
'<iframe class="ccm-display-frame"></iframe>');
} | [
"public",
"function",
"getViewportHTML",
"(",
")",
"{",
"$",
"added_data",
"=",
"array",
"(",
"'handle'",
",",
"'name'",
",",
"'brand'",
",",
"'width'",
",",
"'height'",
",",
"'ratio'",
",",
"'agent'",
",",
")",
";",
"$",
"datas",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"added_data",
"as",
"$",
"key",
")",
"{",
"$",
"datas",
"[",
"]",
"=",
"sprintf",
"(",
"'data-device-%s=\"%s\"'",
",",
"$",
"key",
",",
"h",
"(",
"$",
"this",
"->",
"{",
"$",
"key",
"}",
")",
")",
";",
"}",
"return",
"sprintf",
"(",
"'<div class=\"ccm-device-viewport\" %s style=\"width:%spx;height:%spx\">%s</div>'",
",",
"implode",
"(",
"' '",
",",
"$",
"datas",
")",
",",
"floor",
"(",
"$",
"this",
"->",
"getWidth",
"(",
")",
"/",
"$",
"this",
"->",
"getPixelRatio",
"(",
")",
")",
",",
"floor",
"(",
"$",
"this",
"->",
"getHeight",
"(",
")",
"/",
"$",
"this",
"->",
"getPixelRatio",
"(",
")",
")",
",",
"'<iframe class=\"ccm-display-frame\"></iframe>'",
")",
";",
"}"
] | Get the HTML for this device's viewport.
@return string | [
"Get",
"the",
"HTML",
"for",
"this",
"device",
"s",
"viewport",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Device/Device.php#L176-L198 | train |
concrete5/concrete5 | concrete/src/Page/Search/Index/PageIndexer.php | PageIndexer.index | public function index($page)
{
if ($page = $this->getPage($page)) {
if ($page->getVersionObject()) {
return $page->reindex($this->search, true);
}
}
return false;
} | php | public function index($page)
{
if ($page = $this->getPage($page)) {
if ($page->getVersionObject()) {
return $page->reindex($this->search, true);
}
}
return false;
} | [
"public",
"function",
"index",
"(",
"$",
"page",
")",
"{",
"if",
"(",
"$",
"page",
"=",
"$",
"this",
"->",
"getPage",
"(",
"$",
"page",
")",
")",
"{",
"if",
"(",
"$",
"page",
"->",
"getVersionObject",
"(",
")",
")",
"{",
"return",
"$",
"page",
"->",
"reindex",
"(",
"$",
"this",
"->",
"search",
",",
"true",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Add a page to the index
@param string|int|Page $page Page to index. String is path, int is cID
@return bool Success or fail | [
"Add",
"a",
"page",
"to",
"the",
"index"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Search/Index/PageIndexer.php#L38-L47 | train |
concrete5/concrete5 | concrete/src/Page/Search/Index/PageIndexer.php | PageIndexer.forget | public function forget($page)
{
if ($page = $this->getPage($page)) {
/** @todo Implement forgetting pages completely */
/** @var Connection $database */
$database = $this->app['database']->connection();
$database->executeQuery('DELETE FROM PageSearchIndex WHERE cID=?', [$page->getCollectionID()]);
}
return false;
} | php | public function forget($page)
{
if ($page = $this->getPage($page)) {
/** @todo Implement forgetting pages completely */
/** @var Connection $database */
$database = $this->app['database']->connection();
$database->executeQuery('DELETE FROM PageSearchIndex WHERE cID=?', [$page->getCollectionID()]);
}
return false;
} | [
"public",
"function",
"forget",
"(",
"$",
"page",
")",
"{",
"if",
"(",
"$",
"page",
"=",
"$",
"this",
"->",
"getPage",
"(",
"$",
"page",
")",
")",
"{",
"/** @todo Implement forgetting pages completely */",
"/** @var Connection $database */",
"$",
"database",
"=",
"$",
"this",
"->",
"app",
"[",
"'database'",
"]",
"->",
"connection",
"(",
")",
";",
"$",
"database",
"->",
"executeQuery",
"(",
"'DELETE FROM PageSearchIndex WHERE cID=?'",
",",
"[",
"$",
"page",
"->",
"getCollectionID",
"(",
")",
"]",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Remove a page from the index
@param string|int|Page $page. String is path, int is cID
@return bool Success or fail | [
"Remove",
"a",
"page",
"from",
"the",
"index"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Search/Index/PageIndexer.php#L54-L65 | train |
concrete5/concrete5 | concrete/src/Page/Search/Index/PageIndexer.php | PageIndexer.getPage | protected function getPage($page)
{
// Handle passed cID
if (is_numeric($page)) {
return Page::getByID($page);
}
// Handle passed /path/to/collection
if (is_string($page)) {
return Page::getByPath($page);
}
// If it's a page, just return the page
if ($page instanceof Page) {
return $page;
}
// If it's not a page but it's a collection, lets try getting a page by id
if ($page instanceof Collection) {
return $this->getPage($page->getCollectionID());
}
} | php | protected function getPage($page)
{
// Handle passed cID
if (is_numeric($page)) {
return Page::getByID($page);
}
// Handle passed /path/to/collection
if (is_string($page)) {
return Page::getByPath($page);
}
// If it's a page, just return the page
if ($page instanceof Page) {
return $page;
}
// If it's not a page but it's a collection, lets try getting a page by id
if ($page instanceof Collection) {
return $this->getPage($page->getCollectionID());
}
} | [
"protected",
"function",
"getPage",
"(",
"$",
"page",
")",
"{",
"// Handle passed cID",
"if",
"(",
"is_numeric",
"(",
"$",
"page",
")",
")",
"{",
"return",
"Page",
"::",
"getByID",
"(",
"$",
"page",
")",
";",
"}",
"// Handle passed /path/to/collection",
"if",
"(",
"is_string",
"(",
"$",
"page",
")",
")",
"{",
"return",
"Page",
"::",
"getByPath",
"(",
"$",
"page",
")",
";",
"}",
"// If it's a page, just return the page",
"if",
"(",
"$",
"page",
"instanceof",
"Page",
")",
"{",
"return",
"$",
"page",
";",
"}",
"// If it's not a page but it's a collection, lets try getting a page by id",
"if",
"(",
"$",
"page",
"instanceof",
"Collection",
")",
"{",
"return",
"$",
"this",
"->",
"getPage",
"(",
"$",
"page",
"->",
"getCollectionID",
"(",
")",
")",
";",
"}",
"}"
] | Get a page based on criteria
@param string|int|Page|Collection $page
@return \Concrete\Core\Page\Page | [
"Get",
"a",
"page",
"based",
"on",
"criteria"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Search/Index/PageIndexer.php#L72-L93 | train |
concrete5/concrete5 | concrete/src/Page/Controller/DashboardExpressEntriesPageController.php | DashboardExpressEntriesPageController.csv_export | public function csv_export($treeNodeParentID = null)
{
$me = $this;
$parent = $me->getParentNode($treeNodeParentID);
$entity = $me->getEntity($parent);
$permissions = new \Permissions($entity);
if (!$permissions->canViewExpressEntries()) {
throw new \Exception(t('Access Denied'));
}
$headers = [
'Content-Type' => 'text/csv',
'Content-Disposition' => 'attachment; filename=' . $entity->getHandle() . '.csv',
];
$config = $this->app->make('config');
$bom = $config->get('concrete.export.csv.include_bom') ? $config->get('concrete.charset_bom') : '';
return StreamedResponse::create(function () use ($entity, $me, $bom) {
$entryList = new EntryList($entity);
$writer = new CsvWriter($this->app->make(WriterFactory::class)->createFromPath('php://output', 'w'), new Date());
echo $bom;
$writer->insertHeaders($entity);
$writer->insertEntryList($entryList);
}, 200, $headers);
} | php | public function csv_export($treeNodeParentID = null)
{
$me = $this;
$parent = $me->getParentNode($treeNodeParentID);
$entity = $me->getEntity($parent);
$permissions = new \Permissions($entity);
if (!$permissions->canViewExpressEntries()) {
throw new \Exception(t('Access Denied'));
}
$headers = [
'Content-Type' => 'text/csv',
'Content-Disposition' => 'attachment; filename=' . $entity->getHandle() . '.csv',
];
$config = $this->app->make('config');
$bom = $config->get('concrete.export.csv.include_bom') ? $config->get('concrete.charset_bom') : '';
return StreamedResponse::create(function () use ($entity, $me, $bom) {
$entryList = new EntryList($entity);
$writer = new CsvWriter($this->app->make(WriterFactory::class)->createFromPath('php://output', 'w'), new Date());
echo $bom;
$writer->insertHeaders($entity);
$writer->insertEntryList($entryList);
}, 200, $headers);
} | [
"public",
"function",
"csv_export",
"(",
"$",
"treeNodeParentID",
"=",
"null",
")",
"{",
"$",
"me",
"=",
"$",
"this",
";",
"$",
"parent",
"=",
"$",
"me",
"->",
"getParentNode",
"(",
"$",
"treeNodeParentID",
")",
";",
"$",
"entity",
"=",
"$",
"me",
"->",
"getEntity",
"(",
"$",
"parent",
")",
";",
"$",
"permissions",
"=",
"new",
"\\",
"Permissions",
"(",
"$",
"entity",
")",
";",
"if",
"(",
"!",
"$",
"permissions",
"->",
"canViewExpressEntries",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"t",
"(",
"'Access Denied'",
")",
")",
";",
"}",
"$",
"headers",
"=",
"[",
"'Content-Type'",
"=>",
"'text/csv'",
",",
"'Content-Disposition'",
"=>",
"'attachment; filename='",
".",
"$",
"entity",
"->",
"getHandle",
"(",
")",
".",
"'.csv'",
",",
"]",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'config'",
")",
";",
"$",
"bom",
"=",
"$",
"config",
"->",
"get",
"(",
"'concrete.export.csv.include_bom'",
")",
"?",
"$",
"config",
"->",
"get",
"(",
"'concrete.charset_bom'",
")",
":",
"''",
";",
"return",
"StreamedResponse",
"::",
"create",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"entity",
",",
"$",
"me",
",",
"$",
"bom",
")",
"{",
"$",
"entryList",
"=",
"new",
"EntryList",
"(",
"$",
"entity",
")",
";",
"$",
"writer",
"=",
"new",
"CsvWriter",
"(",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"WriterFactory",
"::",
"class",
")",
"->",
"createFromPath",
"(",
"'php://output'",
",",
"'w'",
")",
",",
"new",
"Date",
"(",
")",
")",
";",
"echo",
"$",
"bom",
";",
"$",
"writer",
"->",
"insertHeaders",
"(",
"$",
"entity",
")",
";",
"$",
"writer",
"->",
"insertEntryList",
"(",
"$",
"entryList",
")",
";",
"}",
",",
"200",
",",
"$",
"headers",
")",
";",
"}"
] | Export Express entries into a CSV.
@param int|null $treeNodeParentID
@return \Symfony\Component\HttpFoundation\Response | [
"Export",
"Express",
"entries",
"into",
"a",
"CSV",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Controller/DashboardExpressEntriesPageController.php#L89-L114 | train |
concrete5/concrete5 | concrete/src/Csv/Export/AbstractExporter.php | AbstractExporter.insertObject | public function insertObject(ObjectInterface $object)
{
$this->writer->insertOne(iterator_to_array($this->projectObject($object)));
return $this;
} | php | public function insertObject(ObjectInterface $object)
{
$this->writer->insertOne(iterator_to_array($this->projectObject($object)));
return $this;
} | [
"public",
"function",
"insertObject",
"(",
"ObjectInterface",
"$",
"object",
")",
"{",
"$",
"this",
"->",
"writer",
"->",
"insertOne",
"(",
"iterator_to_array",
"(",
"$",
"this",
"->",
"projectObject",
"(",
"$",
"object",
")",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Insert a row for a specific object instance.
@param ObjectInterface $object
@return $this | [
"Insert",
"a",
"row",
"for",
"a",
"specific",
"object",
"instance",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Csv/Export/AbstractExporter.php#L130-L135 | train |
concrete5/concrete5 | concrete/src/Csv/Export/AbstractExporter.php | AbstractExporter.insertList | public function insertList(ItemList $list)
{
$this->writer->insertAll($this->projectList($list));
return $this;
} | php | public function insertList(ItemList $list)
{
$this->writer->insertAll($this->projectList($list));
return $this;
} | [
"public",
"function",
"insertList",
"(",
"ItemList",
"$",
"list",
")",
"{",
"$",
"this",
"->",
"writer",
"->",
"insertAll",
"(",
"$",
"this",
"->",
"projectList",
"(",
"$",
"list",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Insert one row for every object in a database list.
@param ItemList $list
@return $this | [
"Insert",
"one",
"row",
"for",
"every",
"object",
"in",
"a",
"database",
"list",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Csv/Export/AbstractExporter.php#L144-L149 | train |
concrete5/concrete5 | concrete/src/Csv/Export/AbstractExporter.php | AbstractExporter.projectHeaders | protected function projectHeaders()
{
foreach ($this->getStaticHeaders() as $header) {
yield $header;
}
foreach ($this->getAttributeKeysAndControllers() as list($attributeKey, $attributeController)) {
/* @var \Concrete\Core\Attribute\AttributeKeyInterface $attributeKey */
/* @var \Concrete\Core\Attribute\Controller $attributeController */
$handle = 'a:' . $attributeKey->getAttributeKeyHandle();
if ($attributeController instanceof SimpleTextExportableAttributeInterface) {
yield $handle;
} elseif ($attributeController instanceof MulticolumnTextExportableAttributeInterface) {
foreach ($attributeController->getAttributeTextRepresentationHeaders() as $subHeader) {
yield $handle . '[' . $subHeader . ']';
}
}
}
} | php | protected function projectHeaders()
{
foreach ($this->getStaticHeaders() as $header) {
yield $header;
}
foreach ($this->getAttributeKeysAndControllers() as list($attributeKey, $attributeController)) {
/* @var \Concrete\Core\Attribute\AttributeKeyInterface $attributeKey */
/* @var \Concrete\Core\Attribute\Controller $attributeController */
$handle = 'a:' . $attributeKey->getAttributeKeyHandle();
if ($attributeController instanceof SimpleTextExportableAttributeInterface) {
yield $handle;
} elseif ($attributeController instanceof MulticolumnTextExportableAttributeInterface) {
foreach ($attributeController->getAttributeTextRepresentationHeaders() as $subHeader) {
yield $handle . '[' . $subHeader . ']';
}
}
}
} | [
"protected",
"function",
"projectHeaders",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getStaticHeaders",
"(",
")",
"as",
"$",
"header",
")",
"{",
"yield",
"$",
"header",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getAttributeKeysAndControllers",
"(",
")",
"as",
"list",
"(",
"$",
"attributeKey",
",",
"$",
"attributeController",
")",
")",
"{",
"/* @var \\Concrete\\Core\\Attribute\\AttributeKeyInterface $attributeKey */",
"/* @var \\Concrete\\Core\\Attribute\\Controller $attributeController */",
"$",
"handle",
"=",
"'a:'",
".",
"$",
"attributeKey",
"->",
"getAttributeKeyHandle",
"(",
")",
";",
"if",
"(",
"$",
"attributeController",
"instanceof",
"SimpleTextExportableAttributeInterface",
")",
"{",
"yield",
"$",
"handle",
";",
"}",
"elseif",
"(",
"$",
"attributeController",
"instanceof",
"MulticolumnTextExportableAttributeInterface",
")",
"{",
"foreach",
"(",
"$",
"attributeController",
"->",
"getAttributeTextRepresentationHeaders",
"(",
")",
"as",
"$",
"subHeader",
")",
"{",
"yield",
"$",
"handle",
".",
"'['",
".",
"$",
"subHeader",
".",
"']'",
";",
"}",
"}",
"}",
"}"
] | A generator that returns all headers.
@return string[]|\Generator | [
"A",
"generator",
"that",
"returns",
"all",
"headers",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Csv/Export/AbstractExporter.php#L234-L252 | train |
concrete5/concrete5 | concrete/src/Csv/Export/AbstractExporter.php | AbstractExporter.projectObject | protected function projectObject(ObjectInterface $object)
{
foreach ($this->getStaticFieldValues($object) as $value) {
yield $value;
}
foreach ($this->getAttributeKeysAndControllers() as list($attributeKey, $attributeController)) {
/* @var \Concrete\Core\Attribute\AttributeKeyInterface $attributeKey */
/* @var \Concrete\Core\Attribute\Controller $attributeController */
$value = $object->getAttributeValueObject($attributeKey, false);
$attributeController->setAttributeValue($value);
if ($attributeController instanceof SimpleTextExportableAttributeInterface) {
yield $attributeController->getAttributeValueTextRepresentation();
} elseif ($attributeController instanceof MulticolumnTextExportableAttributeInterface) {
foreach ($attributeController->getAttributeValueTextRepresentation() as $part) {
yield $part;
}
}
}
} | php | protected function projectObject(ObjectInterface $object)
{
foreach ($this->getStaticFieldValues($object) as $value) {
yield $value;
}
foreach ($this->getAttributeKeysAndControllers() as list($attributeKey, $attributeController)) {
/* @var \Concrete\Core\Attribute\AttributeKeyInterface $attributeKey */
/* @var \Concrete\Core\Attribute\Controller $attributeController */
$value = $object->getAttributeValueObject($attributeKey, false);
$attributeController->setAttributeValue($value);
if ($attributeController instanceof SimpleTextExportableAttributeInterface) {
yield $attributeController->getAttributeValueTextRepresentation();
} elseif ($attributeController instanceof MulticolumnTextExportableAttributeInterface) {
foreach ($attributeController->getAttributeValueTextRepresentation() as $part) {
yield $part;
}
}
}
} | [
"protected",
"function",
"projectObject",
"(",
"ObjectInterface",
"$",
"object",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getStaticFieldValues",
"(",
"$",
"object",
")",
"as",
"$",
"value",
")",
"{",
"yield",
"$",
"value",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getAttributeKeysAndControllers",
"(",
")",
"as",
"list",
"(",
"$",
"attributeKey",
",",
"$",
"attributeController",
")",
")",
"{",
"/* @var \\Concrete\\Core\\Attribute\\AttributeKeyInterface $attributeKey */",
"/* @var \\Concrete\\Core\\Attribute\\Controller $attributeController */",
"$",
"value",
"=",
"$",
"object",
"->",
"getAttributeValueObject",
"(",
"$",
"attributeKey",
",",
"false",
")",
";",
"$",
"attributeController",
"->",
"setAttributeValue",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"attributeController",
"instanceof",
"SimpleTextExportableAttributeInterface",
")",
"{",
"yield",
"$",
"attributeController",
"->",
"getAttributeValueTextRepresentation",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"attributeController",
"instanceof",
"MulticolumnTextExportableAttributeInterface",
")",
"{",
"foreach",
"(",
"$",
"attributeController",
"->",
"getAttributeValueTextRepresentation",
"(",
")",
"as",
"$",
"part",
")",
"{",
"yield",
"$",
"part",
";",
"}",
"}",
"}",
"}"
] | A generator that returns all fields of an object instance.
@param ObjectInterface $object
@return string[]|\Generator | [
"A",
"generator",
"that",
"returns",
"all",
"fields",
"of",
"an",
"object",
"instance",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Csv/Export/AbstractExporter.php#L261-L280 | train |
concrete5/concrete5 | concrete/src/Csv/Export/AbstractExporter.php | AbstractExporter.projectList | protected function projectList(ItemList $list)
{
$sth = $list->deliverQueryObject()->execute();
foreach ($sth as $row) {
$listResult = $list->getResult($row);
$object = $this->getObjectFromListResult($list, $listResult);
yield iterator_to_array($this->projectObject($object));
$this->tick();
}
} | php | protected function projectList(ItemList $list)
{
$sth = $list->deliverQueryObject()->execute();
foreach ($sth as $row) {
$listResult = $list->getResult($row);
$object = $this->getObjectFromListResult($list, $listResult);
yield iterator_to_array($this->projectObject($object));
$this->tick();
}
} | [
"protected",
"function",
"projectList",
"(",
"ItemList",
"$",
"list",
")",
"{",
"$",
"sth",
"=",
"$",
"list",
"->",
"deliverQueryObject",
"(",
")",
"->",
"execute",
"(",
")",
";",
"foreach",
"(",
"$",
"sth",
"as",
"$",
"row",
")",
"{",
"$",
"listResult",
"=",
"$",
"list",
"->",
"getResult",
"(",
"$",
"row",
")",
";",
"$",
"object",
"=",
"$",
"this",
"->",
"getObjectFromListResult",
"(",
"$",
"list",
",",
"$",
"listResult",
")",
";",
"yield",
"iterator_to_array",
"(",
"$",
"this",
"->",
"projectObject",
"(",
"$",
"object",
")",
")",
";",
"$",
"this",
"->",
"tick",
"(",
")",
";",
"}",
"}"
] | A generator that returns all the rows for an object list.
@param ItemList $list
@return string[][]\Generator | [
"A",
"generator",
"that",
"returns",
"all",
"the",
"rows",
"for",
"an",
"object",
"list",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Csv/Export/AbstractExporter.php#L289-L299 | train |
concrete5/concrete5 | concrete/src/Csv/Export/AbstractExporter.php | AbstractExporter.unloadDoctrineEntities | protected function unloadDoctrineEntities()
{
$this->attributeKeysAndControllers = null;
$app = Application::getFacadeApplication();
$entityManager = $app->make(EntityManagerInterface::class);
$entityManager->clear();
$category = $this->getCategory();
if ($category !== null) {
$categoryClass = ClassUtils::getClass($category);
if (!$entityManager->getMetadataFactory()->isTransient($categoryClass)) {
$entityManager->merge($category);
}
}
} | php | protected function unloadDoctrineEntities()
{
$this->attributeKeysAndControllers = null;
$app = Application::getFacadeApplication();
$entityManager = $app->make(EntityManagerInterface::class);
$entityManager->clear();
$category = $this->getCategory();
if ($category !== null) {
$categoryClass = ClassUtils::getClass($category);
if (!$entityManager->getMetadataFactory()->isTransient($categoryClass)) {
$entityManager->merge($category);
}
}
} | [
"protected",
"function",
"unloadDoctrineEntities",
"(",
")",
"{",
"$",
"this",
"->",
"attributeKeysAndControllers",
"=",
"null",
";",
"$",
"app",
"=",
"Application",
"::",
"getFacadeApplication",
"(",
")",
";",
"$",
"entityManager",
"=",
"$",
"app",
"->",
"make",
"(",
"EntityManagerInterface",
"::",
"class",
")",
";",
"$",
"entityManager",
"->",
"clear",
"(",
")",
";",
"$",
"category",
"=",
"$",
"this",
"->",
"getCategory",
"(",
")",
";",
"if",
"(",
"$",
"category",
"!==",
"null",
")",
"{",
"$",
"categoryClass",
"=",
"ClassUtils",
"::",
"getClass",
"(",
"$",
"category",
")",
";",
"if",
"(",
"!",
"$",
"entityManager",
"->",
"getMetadataFactory",
"(",
")",
"->",
"isTransient",
"(",
"$",
"categoryClass",
")",
")",
"{",
"$",
"entityManager",
"->",
"merge",
"(",
"$",
"category",
")",
";",
"}",
"}",
"}"
] | Unload every Doctrine entites, and reset the state of this instance. | [
"Unload",
"every",
"Doctrine",
"entites",
"and",
"reset",
"the",
"state",
"of",
"this",
"instance",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Csv/Export/AbstractExporter.php#L325-L338 | train |
concrete5/concrete5 | concrete/src/User/PostLoginLocation.php | PostLoginLocation.setSessionPostLoginUrl | public function setSessionPostLoginUrl($url)
{
$normalized = null;
if ($url instanceof Page) {
if (!$url->isError()) {
$cID = (int) $url->getCollectionID();
if ($cID > 0) {
$normalized = $cID;
}
}
} elseif ($this->valn->integer($url, 1)) {
$normalized = (int) $url;
} else {
$url = (string) $url;
if (strpos($url, '/') !== false) {
$normalized = $url;
}
}
$this->resetSessionPostLoginUrl();
if ($normalized !== null) {
$this->session->set(static::POSTLOGIN_SESSION_KEY, $normalized);
}
} | php | public function setSessionPostLoginUrl($url)
{
$normalized = null;
if ($url instanceof Page) {
if (!$url->isError()) {
$cID = (int) $url->getCollectionID();
if ($cID > 0) {
$normalized = $cID;
}
}
} elseif ($this->valn->integer($url, 1)) {
$normalized = (int) $url;
} else {
$url = (string) $url;
if (strpos($url, '/') !== false) {
$normalized = $url;
}
}
$this->resetSessionPostLoginUrl();
if ($normalized !== null) {
$this->session->set(static::POSTLOGIN_SESSION_KEY, $normalized);
}
} | [
"public",
"function",
"setSessionPostLoginUrl",
"(",
"$",
"url",
")",
"{",
"$",
"normalized",
"=",
"null",
";",
"if",
"(",
"$",
"url",
"instanceof",
"Page",
")",
"{",
"if",
"(",
"!",
"$",
"url",
"->",
"isError",
"(",
")",
")",
"{",
"$",
"cID",
"=",
"(",
"int",
")",
"$",
"url",
"->",
"getCollectionID",
"(",
")",
";",
"if",
"(",
"$",
"cID",
">",
"0",
")",
"{",
"$",
"normalized",
"=",
"$",
"cID",
";",
"}",
"}",
"}",
"elseif",
"(",
"$",
"this",
"->",
"valn",
"->",
"integer",
"(",
"$",
"url",
",",
"1",
")",
")",
"{",
"$",
"normalized",
"=",
"(",
"int",
")",
"$",
"url",
";",
"}",
"else",
"{",
"$",
"url",
"=",
"(",
"string",
")",
"$",
"url",
";",
"if",
"(",
"strpos",
"(",
"$",
"url",
",",
"'/'",
")",
"!==",
"false",
")",
"{",
"$",
"normalized",
"=",
"$",
"url",
";",
"}",
"}",
"$",
"this",
"->",
"resetSessionPostLoginUrl",
"(",
")",
";",
"if",
"(",
"$",
"normalized",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"session",
"->",
"set",
"(",
"static",
"::",
"POSTLOGIN_SESSION_KEY",
",",
"$",
"normalized",
")",
";",
"}",
"}"
] | Store in the session the post-login URL or page.
@param string|\League\URL\URLInterface|\Concrete\Core\Page\Page|int $url the URL to redirect users to after login | [
"Store",
"in",
"the",
"session",
"the",
"post",
"-",
"login",
"URL",
"or",
"page",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/PostLoginLocation.php#L82-L104 | train |
concrete5/concrete5 | concrete/src/User/PostLoginLocation.php | PostLoginLocation.getSessionPostLoginUrl | public function getSessionPostLoginUrl($resetSessionPostLoginUrl = false)
{
$result = '';
$normalized = $this->session->get(static::POSTLOGIN_SESSION_KEY);
if ($this->valn->integer($normalized, 1)) {
$page = Page::getByID($normalized);
if ($page && !$page->isError()) {
$result = (string) $this->resolverManager->resolve([$page]);
}
} elseif (strpos((string) $normalized, '/') !== false) {
$result = $normalized;
}
if ($resetSessionPostLoginUrl) {
$this->resetSessionPostLoginUrl();
}
return $result;
} | php | public function getSessionPostLoginUrl($resetSessionPostLoginUrl = false)
{
$result = '';
$normalized = $this->session->get(static::POSTLOGIN_SESSION_KEY);
if ($this->valn->integer($normalized, 1)) {
$page = Page::getByID($normalized);
if ($page && !$page->isError()) {
$result = (string) $this->resolverManager->resolve([$page]);
}
} elseif (strpos((string) $normalized, '/') !== false) {
$result = $normalized;
}
if ($resetSessionPostLoginUrl) {
$this->resetSessionPostLoginUrl();
}
return $result;
} | [
"public",
"function",
"getSessionPostLoginUrl",
"(",
"$",
"resetSessionPostLoginUrl",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"''",
";",
"$",
"normalized",
"=",
"$",
"this",
"->",
"session",
"->",
"get",
"(",
"static",
"::",
"POSTLOGIN_SESSION_KEY",
")",
";",
"if",
"(",
"$",
"this",
"->",
"valn",
"->",
"integer",
"(",
"$",
"normalized",
",",
"1",
")",
")",
"{",
"$",
"page",
"=",
"Page",
"::",
"getByID",
"(",
"$",
"normalized",
")",
";",
"if",
"(",
"$",
"page",
"&&",
"!",
"$",
"page",
"->",
"isError",
"(",
")",
")",
"{",
"$",
"result",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"resolverManager",
"->",
"resolve",
"(",
"[",
"$",
"page",
"]",
")",
";",
"}",
"}",
"elseif",
"(",
"strpos",
"(",
"(",
"string",
")",
"$",
"normalized",
",",
"'/'",
")",
"!==",
"false",
")",
"{",
"$",
"result",
"=",
"$",
"normalized",
";",
"}",
"if",
"(",
"$",
"resetSessionPostLoginUrl",
")",
"{",
"$",
"this",
"->",
"resetSessionPostLoginUrl",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Get the post-login URL as stored in the session.
@param bool $resetSessionPostLoginUrl Should the post-login-related data stored in session be cleared?
@return string Empty string if unavailable | [
"Get",
"the",
"post",
"-",
"login",
"URL",
"as",
"stored",
"in",
"the",
"session",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/PostLoginLocation.php#L113-L131 | train |
concrete5/concrete5 | concrete/src/User/PostLoginLocation.php | PostLoginLocation.getDefaultPostLoginUrl | public function getDefaultPostLoginUrl()
{
$result = '';
$loginRedirectMode = (string) $this->config->get('concrete.misc.login_redirect');
switch ($loginRedirectMode) {
case 'CUSTOM':
$loginRedirectCollectionID = $this->config->get('concrete.misc.login_redirect_cid');
if ($this->valn->integer($loginRedirectCollectionID, 1)) {
$page = Page::getByID($loginRedirectCollectionID);
if ($page && !$page->isError()) {
$result = (string) $this->resolverManager->resolve([$page]);
}
}
break;
case 'DESKTOP':
$desktop = DesktopList::getMyDesktop();
if ($desktop && !$desktop->isError()) {
$result = (string) $this->resolverManager->resolve([$desktop]);
}
break;
}
return $result;
} | php | public function getDefaultPostLoginUrl()
{
$result = '';
$loginRedirectMode = (string) $this->config->get('concrete.misc.login_redirect');
switch ($loginRedirectMode) {
case 'CUSTOM':
$loginRedirectCollectionID = $this->config->get('concrete.misc.login_redirect_cid');
if ($this->valn->integer($loginRedirectCollectionID, 1)) {
$page = Page::getByID($loginRedirectCollectionID);
if ($page && !$page->isError()) {
$result = (string) $this->resolverManager->resolve([$page]);
}
}
break;
case 'DESKTOP':
$desktop = DesktopList::getMyDesktop();
if ($desktop && !$desktop->isError()) {
$result = (string) $this->resolverManager->resolve([$desktop]);
}
break;
}
return $result;
} | [
"public",
"function",
"getDefaultPostLoginUrl",
"(",
")",
"{",
"$",
"result",
"=",
"''",
";",
"$",
"loginRedirectMode",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'concrete.misc.login_redirect'",
")",
";",
"switch",
"(",
"$",
"loginRedirectMode",
")",
"{",
"case",
"'CUSTOM'",
":",
"$",
"loginRedirectCollectionID",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'concrete.misc.login_redirect_cid'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"valn",
"->",
"integer",
"(",
"$",
"loginRedirectCollectionID",
",",
"1",
")",
")",
"{",
"$",
"page",
"=",
"Page",
"::",
"getByID",
"(",
"$",
"loginRedirectCollectionID",
")",
";",
"if",
"(",
"$",
"page",
"&&",
"!",
"$",
"page",
"->",
"isError",
"(",
")",
")",
"{",
"$",
"result",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"resolverManager",
"->",
"resolve",
"(",
"[",
"$",
"page",
"]",
")",
";",
"}",
"}",
"break",
";",
"case",
"'DESKTOP'",
":",
"$",
"desktop",
"=",
"DesktopList",
"::",
"getMyDesktop",
"(",
")",
";",
"if",
"(",
"$",
"desktop",
"&&",
"!",
"$",
"desktop",
"->",
"isError",
"(",
")",
")",
"{",
"$",
"result",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"resolverManager",
"->",
"resolve",
"(",
"[",
"$",
"desktop",
"]",
")",
";",
"}",
"break",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Get the default post-login URL.
@return string Empty string if unavailable | [
"Get",
"the",
"default",
"post",
"-",
"login",
"URL",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/PostLoginLocation.php#L138-L161 | train |
concrete5/concrete5 | concrete/src/User/PostLoginLocation.php | PostLoginLocation.getPostLoginUrl | public function getPostLoginUrl($resetSessionPostLoginUrl = false)
{
$result = $this->getSessionPostLoginUrl($resetSessionPostLoginUrl);
if ($result === '') {
$result = $this->getDefaultPostLoginUrl();
if ($result === '') {
$result = $this->getFallbackPostLoginUrl();
}
}
return $result;
} | php | public function getPostLoginUrl($resetSessionPostLoginUrl = false)
{
$result = $this->getSessionPostLoginUrl($resetSessionPostLoginUrl);
if ($result === '') {
$result = $this->getDefaultPostLoginUrl();
if ($result === '') {
$result = $this->getFallbackPostLoginUrl();
}
}
return $result;
} | [
"public",
"function",
"getPostLoginUrl",
"(",
"$",
"resetSessionPostLoginUrl",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getSessionPostLoginUrl",
"(",
"$",
"resetSessionPostLoginUrl",
")",
";",
"if",
"(",
"$",
"result",
"===",
"''",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getDefaultPostLoginUrl",
"(",
")",
";",
"if",
"(",
"$",
"result",
"===",
"''",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getFallbackPostLoginUrl",
"(",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Get the post-login URL.
@param bool $resetSessionPostLoginUrl Should the post-login-related data stored in session be cleared?
@return string | [
"Get",
"the",
"post",
"-",
"login",
"URL",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/PostLoginLocation.php#L188-L199 | train |
concrete5/concrete5 | concrete/src/User/PostLoginLocation.php | PostLoginLocation.getPostLoginRedirectResponse | public function getPostLoginRedirectResponse($resetSessionPostLoginUrl = false)
{
$result = $this->responseFactory->redirect(
$this->getPostLoginUrl($resetSessionPostLoginUrl),
Response::HTTP_FOUND
);
// Disable caching for response
$result = $result->setMaxAge(0)->setSharedMaxAge(0)->setPrivate();
$result->headers->addCacheControlDirective('must-revalidate', true);
$result->headers->addCacheControlDirective('no-store', true);
return $result;
} | php | public function getPostLoginRedirectResponse($resetSessionPostLoginUrl = false)
{
$result = $this->responseFactory->redirect(
$this->getPostLoginUrl($resetSessionPostLoginUrl),
Response::HTTP_FOUND
);
// Disable caching for response
$result = $result->setMaxAge(0)->setSharedMaxAge(0)->setPrivate();
$result->headers->addCacheControlDirective('must-revalidate', true);
$result->headers->addCacheControlDirective('no-store', true);
return $result;
} | [
"public",
"function",
"getPostLoginRedirectResponse",
"(",
"$",
"resetSessionPostLoginUrl",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"responseFactory",
"->",
"redirect",
"(",
"$",
"this",
"->",
"getPostLoginUrl",
"(",
"$",
"resetSessionPostLoginUrl",
")",
",",
"Response",
"::",
"HTTP_FOUND",
")",
";",
"// Disable caching for response",
"$",
"result",
"=",
"$",
"result",
"->",
"setMaxAge",
"(",
"0",
")",
"->",
"setSharedMaxAge",
"(",
"0",
")",
"->",
"setPrivate",
"(",
")",
";",
"$",
"result",
"->",
"headers",
"->",
"addCacheControlDirective",
"(",
"'must-revalidate'",
",",
"true",
")",
";",
"$",
"result",
"->",
"headers",
"->",
"addCacheControlDirective",
"(",
"'no-store'",
",",
"true",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Create a Response that redirects the user to the configured URL.
@param bool $resetSessionPostLoginUrl Should the post-login-related data stored in session be cleared?
@return \Symfony\Component\HttpFoundation\Response | [
"Create",
"a",
"Response",
"that",
"redirects",
"the",
"user",
"to",
"the",
"configured",
"URL",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/PostLoginLocation.php#L208-L220 | train |
concrete5/concrete5 | concrete/src/Backup/ContentImporter/Importer/Manager.php | Manager.registerImporterRoutine | public function registerImporterRoutine(RoutineInterface $routine)
{
if (in_array($routine, $this->routines)) {
$this->routines[array_search($routine, $this->routines)] = $routine;
} else {
$this->routines[] = $routine;
}
} | php | public function registerImporterRoutine(RoutineInterface $routine)
{
if (in_array($routine, $this->routines)) {
$this->routines[array_search($routine, $this->routines)] = $routine;
} else {
$this->routines[] = $routine;
}
} | [
"public",
"function",
"registerImporterRoutine",
"(",
"RoutineInterface",
"$",
"routine",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"routine",
",",
"$",
"this",
"->",
"routines",
")",
")",
"{",
"$",
"this",
"->",
"routines",
"[",
"array_search",
"(",
"$",
"routine",
",",
"$",
"this",
"->",
"routines",
")",
"]",
"=",
"$",
"routine",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"routines",
"[",
"]",
"=",
"$",
"routine",
";",
"}",
"}"
] | Registers a core importer routine. Add-on developers should use addImporterRoutine
You can use this if you want to swap out a core routine.
@param RoutineInterface $routine | [
"Registers",
"a",
"core",
"importer",
"routine",
".",
"Add",
"-",
"on",
"developers",
"should",
"use",
"addImporterRoutine",
"You",
"can",
"use",
"this",
"if",
"you",
"want",
"to",
"swap",
"out",
"a",
"core",
"routine",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Backup/ContentImporter/Importer/Manager.php#L17-L24 | train |
concrete5/concrete5 | concrete/src/Attribute/Value/Value.php | Value.validateAttributeValue | public function validateAttributeValue()
{
$at = $this->attributeType;
$at->getController()->setAttributeKey($this->attributeKey);
$e = true;
if (method_exists($at->getController(), 'validateValue')) {
$e = $at->getController()->validateValue();
}
return $e;
} | php | public function validateAttributeValue()
{
$at = $this->attributeType;
$at->getController()->setAttributeKey($this->attributeKey);
$e = true;
if (method_exists($at->getController(), 'validateValue')) {
$e = $at->getController()->validateValue();
}
return $e;
} | [
"public",
"function",
"validateAttributeValue",
"(",
")",
"{",
"$",
"at",
"=",
"$",
"this",
"->",
"attributeType",
";",
"$",
"at",
"->",
"getController",
"(",
")",
"->",
"setAttributeKey",
"(",
"$",
"this",
"->",
"attributeKey",
")",
";",
"$",
"e",
"=",
"true",
";",
"if",
"(",
"method_exists",
"(",
"$",
"at",
"->",
"getController",
"(",
")",
",",
"'validateValue'",
")",
")",
"{",
"$",
"e",
"=",
"$",
"at",
"->",
"getController",
"(",
")",
"->",
"validateValue",
"(",
")",
";",
"}",
"return",
"$",
"e",
";",
"}"
] | Validates the current attribute value to see if it fulfills the "requirement" portion of an attribute.
@return bool|\Concrete\Core\Error\Error | [
"Validates",
"the",
"current",
"attribute",
"value",
"to",
"see",
"if",
"it",
"fulfills",
"the",
"requirement",
"portion",
"of",
"an",
"attribute",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Attribute/Value/Value.php#L72-L81 | train |
concrete5/concrete5 | concrete/src/Csv/EscapeFormula.php | EscapeFormula.filterSpecialCharacters | protected function filterSpecialCharacters(array $characters)
{
foreach ($characters as $str) {
if (1 != strlen($str)) {
throw new InvalidArgumentException(sprintf('The submitted string %s must be a single character', $str));
}
}
return $characters;
} | php | protected function filterSpecialCharacters(array $characters)
{
foreach ($characters as $str) {
if (1 != strlen($str)) {
throw new InvalidArgumentException(sprintf('The submitted string %s must be a single character', $str));
}
}
return $characters;
} | [
"protected",
"function",
"filterSpecialCharacters",
"(",
"array",
"$",
"characters",
")",
"{",
"foreach",
"(",
"$",
"characters",
"as",
"$",
"str",
")",
"{",
"if",
"(",
"1",
"!=",
"strlen",
"(",
"$",
"str",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The submitted string %s must be a single character'",
",",
"$",
"str",
")",
")",
";",
"}",
"}",
"return",
"$",
"characters",
";",
"}"
] | Filter submitted special characters.
@param string[] $characters
@throws InvalidArgumentException if the string is not a single character
@return string[] | [
"Filter",
"submitted",
"special",
"characters",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Csv/EscapeFormula.php#L74-L82 | train |
concrete5/concrete5 | concrete/src/Csv/EscapeFormula.php | EscapeFormula.escapeField | protected function escapeField($cell)
{
if (!$this->isStringable($cell)) {
return $cell;
}
$str_cell = (string) $cell;
if (isset($str_cell[0], $this->special_chars[$str_cell[0]])) {
return $this->escape.$str_cell;
}
return $cell;
} | php | protected function escapeField($cell)
{
if (!$this->isStringable($cell)) {
return $cell;
}
$str_cell = (string) $cell;
if (isset($str_cell[0], $this->special_chars[$str_cell[0]])) {
return $this->escape.$str_cell;
}
return $cell;
} | [
"protected",
"function",
"escapeField",
"(",
"$",
"cell",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isStringable",
"(",
"$",
"cell",
")",
")",
"{",
"return",
"$",
"cell",
";",
"}",
"$",
"str_cell",
"=",
"(",
"string",
")",
"$",
"cell",
";",
"if",
"(",
"isset",
"(",
"$",
"str_cell",
"[",
"0",
"]",
",",
"$",
"this",
"->",
"special_chars",
"[",
"$",
"str_cell",
"[",
"0",
"]",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"escape",
".",
"$",
"str_cell",
";",
"}",
"return",
"$",
"cell",
";",
"}"
] | Escape a CSV cell.
@return string | [
"Escape",
"a",
"CSV",
"cell",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Csv/EscapeFormula.php#L129-L139 | train |
concrete5/concrete5 | concrete/src/Console/Command/CompareSchemaCommand.php | CompareSchemaCommand.filterQueries | protected function filterQueries($queries)
{
$app = Application::getFacadeApplication();
$config = $app->make('config');
$textIndexDrops = [];
foreach ($config->get('database.text_indexes') as $indexTable => $indexDefinition) {
foreach (array_keys($indexDefinition) as $indexName) {
$textIndexDrops[] = strtolower("DROP INDEX {$indexName} ON {$indexTable}");
}
}
$returnQueries = [];
foreach ($queries as $query) {
$queryLowerCase = strtolower($query);
if (!in_array($queryLowerCase, $textIndexDrops, true)) {
$returnQueries[] = $query;
}
}
return $returnQueries;
} | php | protected function filterQueries($queries)
{
$app = Application::getFacadeApplication();
$config = $app->make('config');
$textIndexDrops = [];
foreach ($config->get('database.text_indexes') as $indexTable => $indexDefinition) {
foreach (array_keys($indexDefinition) as $indexName) {
$textIndexDrops[] = strtolower("DROP INDEX {$indexName} ON {$indexTable}");
}
}
$returnQueries = [];
foreach ($queries as $query) {
$queryLowerCase = strtolower($query);
if (!in_array($queryLowerCase, $textIndexDrops, true)) {
$returnQueries[] = $query;
}
}
return $returnQueries;
} | [
"protected",
"function",
"filterQueries",
"(",
"$",
"queries",
")",
"{",
"$",
"app",
"=",
"Application",
"::",
"getFacadeApplication",
"(",
")",
";",
"$",
"config",
"=",
"$",
"app",
"->",
"make",
"(",
"'config'",
")",
";",
"$",
"textIndexDrops",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"config",
"->",
"get",
"(",
"'database.text_indexes'",
")",
"as",
"$",
"indexTable",
"=>",
"$",
"indexDefinition",
")",
"{",
"foreach",
"(",
"array_keys",
"(",
"$",
"indexDefinition",
")",
"as",
"$",
"indexName",
")",
"{",
"$",
"textIndexDrops",
"[",
"]",
"=",
"strtolower",
"(",
"\"DROP INDEX {$indexName} ON {$indexTable}\"",
")",
";",
"}",
"}",
"$",
"returnQueries",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"queries",
"as",
"$",
"query",
")",
"{",
"$",
"queryLowerCase",
"=",
"strtolower",
"(",
"$",
"query",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"queryLowerCase",
",",
"$",
"textIndexDrops",
",",
"true",
")",
")",
"{",
"$",
"returnQueries",
"[",
"]",
"=",
"$",
"query",
";",
"}",
"}",
"return",
"$",
"returnQueries",
";",
"}"
] | Filter out all the queries that are platform specific that
Doctrine doens't give us a good way to deal with. This is mostly
index lengths that are set in installation that Doctrine doesn't
support.
@param string[] $queries
@return string[] | [
"Filter",
"out",
"all",
"the",
"queries",
"that",
"are",
"platform",
"specific",
"that",
"Doctrine",
"doens",
"t",
"give",
"us",
"a",
"good",
"way",
"to",
"deal",
"with",
".",
"This",
"is",
"mostly",
"index",
"lengths",
"that",
"are",
"set",
"in",
"installation",
"that",
"Doctrine",
"doesn",
"t",
"support",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Console/Command/CompareSchemaCommand.php#L108-L129 | train |
concrete5/concrete5 | concrete/src/Utility/Service/Number.php | Number.trim | public function trim($value)
{
$result = '';
$value = (string) $value;
if ($value !== '') {
// Temporarily remove leadin sign
$sign = $value[0];
if ($sign === '-' || $sign === '+') {
$value = substr($value, 1);
} else {
$sign = '';
}
if ($value !== '') {
// Remove initial zeroes
$value = ltrim($value, '0');
if ($value === '' || $value[0] === '.') {
$value = '0' . $value;
}
if (strpos($value, '.') !== false) {
// Remove trailing zeroes after the dot
$value = rtrim(rtrim($value, '0'), '.');
}
$result = $sign . $value;
}
}
return $result;
} | php | public function trim($value)
{
$result = '';
$value = (string) $value;
if ($value !== '') {
// Temporarily remove leadin sign
$sign = $value[0];
if ($sign === '-' || $sign === '+') {
$value = substr($value, 1);
} else {
$sign = '';
}
if ($value !== '') {
// Remove initial zeroes
$value = ltrim($value, '0');
if ($value === '' || $value[0] === '.') {
$value = '0' . $value;
}
if (strpos($value, '.') !== false) {
// Remove trailing zeroes after the dot
$value = rtrim(rtrim($value, '0'), '.');
}
$result = $sign . $value;
}
}
return $result;
} | [
"public",
"function",
"trim",
"(",
"$",
"value",
")",
"{",
"$",
"result",
"=",
"''",
";",
"$",
"value",
"=",
"(",
"string",
")",
"$",
"value",
";",
"if",
"(",
"$",
"value",
"!==",
"''",
")",
"{",
"// Temporarily remove leadin sign",
"$",
"sign",
"=",
"$",
"value",
"[",
"0",
"]",
";",
"if",
"(",
"$",
"sign",
"===",
"'-'",
"||",
"$",
"sign",
"===",
"'+'",
")",
"{",
"$",
"value",
"=",
"substr",
"(",
"$",
"value",
",",
"1",
")",
";",
"}",
"else",
"{",
"$",
"sign",
"=",
"''",
";",
"}",
"if",
"(",
"$",
"value",
"!==",
"''",
")",
"{",
"// Remove initial zeroes",
"$",
"value",
"=",
"ltrim",
"(",
"$",
"value",
",",
"'0'",
")",
";",
"if",
"(",
"$",
"value",
"===",
"''",
"||",
"$",
"value",
"[",
"0",
"]",
"===",
"'.'",
")",
"{",
"$",
"value",
"=",
"'0'",
".",
"$",
"value",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"// Remove trailing zeroes after the dot",
"$",
"value",
"=",
"rtrim",
"(",
"rtrim",
"(",
"$",
"value",
",",
"'0'",
")",
",",
"'.'",
")",
";",
"}",
"$",
"result",
"=",
"$",
"sign",
".",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Remove superfluous zeroes from a string containing a number.
@param string $value (decimal separator is dot)
@return string | [
"Remove",
"superfluous",
"zeroes",
"from",
"a",
"string",
"containing",
"a",
"number",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Utility/Service/Number.php#L25-L52 | train |
concrete5/concrete5 | concrete/src/Entity/OAuth/AccessTokenRepository.php | AccessTokenRepository.getNewToken | public function getNewToken(ClientEntityInterface $clientEntity, array $scopes, $userIdentifier = null)
{
$token = new AccessToken();
$token->setUserIdentifier($userIdentifier);
return $token;
} | php | public function getNewToken(ClientEntityInterface $clientEntity, array $scopes, $userIdentifier = null)
{
$token = new AccessToken();
$token->setUserIdentifier($userIdentifier);
return $token;
} | [
"public",
"function",
"getNewToken",
"(",
"ClientEntityInterface",
"$",
"clientEntity",
",",
"array",
"$",
"scopes",
",",
"$",
"userIdentifier",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"new",
"AccessToken",
"(",
")",
";",
"$",
"token",
"->",
"setUserIdentifier",
"(",
"$",
"userIdentifier",
")",
";",
"return",
"$",
"token",
";",
"}"
] | Create a new access token
@param ClientEntityInterface $clientEntity
@param ScopeEntityInterface[] $scopes
@param mixed $userIdentifier
@return AccessTokenEntityInterface | [
"Create",
"a",
"new",
"access",
"token"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/OAuth/AccessTokenRepository.php#L24-L31 | train |
concrete5/concrete5 | concrete/src/Entity/OAuth/AccessTokenRepository.php | AccessTokenRepository.persistNewAccessToken | public function persistNewAccessToken(AccessTokenEntityInterface $accessTokenEntity)
{
$this->getEntityManager()->transactional(function(EntityManagerInterface $em) use ($accessTokenEntity) {
$em->persist($accessTokenEntity);
});
} | php | public function persistNewAccessToken(AccessTokenEntityInterface $accessTokenEntity)
{
$this->getEntityManager()->transactional(function(EntityManagerInterface $em) use ($accessTokenEntity) {
$em->persist($accessTokenEntity);
});
} | [
"public",
"function",
"persistNewAccessToken",
"(",
"AccessTokenEntityInterface",
"$",
"accessTokenEntity",
")",
"{",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"transactional",
"(",
"function",
"(",
"EntityManagerInterface",
"$",
"em",
")",
"use",
"(",
"$",
"accessTokenEntity",
")",
"{",
"$",
"em",
"->",
"persist",
"(",
"$",
"accessTokenEntity",
")",
";",
"}",
")",
";",
"}"
] | Persists a new access token to permanent storage.
@param AccessTokenEntityInterface $accessTokenEntity
@throws \Exception | [
"Persists",
"a",
"new",
"access",
"token",
"to",
"permanent",
"storage",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/OAuth/AccessTokenRepository.php#L39-L44 | train |
concrete5/concrete5 | concrete/src/Entity/OAuth/AccessTokenRepository.php | AccessTokenRepository.isAccessTokenRevoked | public function isAccessTokenRevoked($tokenId)
{
/** @var \Concrete\Core\Entity\OAuth\AccessToken $token */
$token = $this->find($tokenId);
if (!$token) {
// The token was manually removed.
return true;
}
$now = new \DateTime('now');
// If we have a token and it has expired...
if ($token && $token->getExpiryDateTime() < $now) {
return true;
}
return false;
} | php | public function isAccessTokenRevoked($tokenId)
{
/** @var \Concrete\Core\Entity\OAuth\AccessToken $token */
$token = $this->find($tokenId);
if (!$token) {
// The token was manually removed.
return true;
}
$now = new \DateTime('now');
// If we have a token and it has expired...
if ($token && $token->getExpiryDateTime() < $now) {
return true;
}
return false;
} | [
"public",
"function",
"isAccessTokenRevoked",
"(",
"$",
"tokenId",
")",
"{",
"/** @var \\Concrete\\Core\\Entity\\OAuth\\AccessToken $token */",
"$",
"token",
"=",
"$",
"this",
"->",
"find",
"(",
"$",
"tokenId",
")",
";",
"if",
"(",
"!",
"$",
"token",
")",
"{",
"// The token was manually removed.",
"return",
"true",
";",
"}",
"$",
"now",
"=",
"new",
"\\",
"DateTime",
"(",
"'now'",
")",
";",
"// If we have a token and it has expired...",
"if",
"(",
"$",
"token",
"&&",
"$",
"token",
"->",
"getExpiryDateTime",
"(",
")",
"<",
"$",
"now",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Check if the access token has been revoked.
@param string $tokenId
@return bool Return true if this token has been revoked | [
"Check",
"if",
"the",
"access",
"token",
"has",
"been",
"revoked",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/OAuth/AccessTokenRepository.php#L68-L84 | train |
concrete5/concrete5 | concrete/src/Multilingual/Service/Detector.php | Detector.setupSiteInterfaceLocalization | public function setupSiteInterfaceLocalization(Page $c = null)
{
$app = Facade::getFacadeApplication();
$loc = $app->make(Localization::class);
$locale = null;
if ($c === null) {
$c = Page::getCurrentPage();
}
if ($c) {
$pageController = $c->getPageController();
if (is_callable([$pageController, 'useUserLocale'])) {
$useUserLocale = $pageController->useUserLocale();
} else {
$dh = $app->make('helper/concrete/dashboard');
$useUserLocale = $dh->inDashboard($c);
}
if ($useUserLocale) {
$u = new User();
$locale = $u->getUserLanguageToDisplay();
} else {
if ($this->isEnabled()) {
$ms = Section::getBySectionOfSite($c);
if (!$ms) {
$ms = static::getPreferredSection();
}
if ($ms) {
$locale = $ms->getLocale();
if ($this->canSetSessionValue()) {
$app->make('session')->set('multilingual_default_locale', $locale);
}
}
}
if (!$locale) {
$siteTree = $c->getSiteTreeObject();
if ($siteTree) {
$locale = $siteTree->getLocale()->getLocale();
}
}
}
}
if (!$locale) {
$locale = $app->make('config')->get('concrete.locale');
}
$loc->setContextLocale(Localization::CONTEXT_SITE, $locale);
} | php | public function setupSiteInterfaceLocalization(Page $c = null)
{
$app = Facade::getFacadeApplication();
$loc = $app->make(Localization::class);
$locale = null;
if ($c === null) {
$c = Page::getCurrentPage();
}
if ($c) {
$pageController = $c->getPageController();
if (is_callable([$pageController, 'useUserLocale'])) {
$useUserLocale = $pageController->useUserLocale();
} else {
$dh = $app->make('helper/concrete/dashboard');
$useUserLocale = $dh->inDashboard($c);
}
if ($useUserLocale) {
$u = new User();
$locale = $u->getUserLanguageToDisplay();
} else {
if ($this->isEnabled()) {
$ms = Section::getBySectionOfSite($c);
if (!$ms) {
$ms = static::getPreferredSection();
}
if ($ms) {
$locale = $ms->getLocale();
if ($this->canSetSessionValue()) {
$app->make('session')->set('multilingual_default_locale', $locale);
}
}
}
if (!$locale) {
$siteTree = $c->getSiteTreeObject();
if ($siteTree) {
$locale = $siteTree->getLocale()->getLocale();
}
}
}
}
if (!$locale) {
$locale = $app->make('config')->get('concrete.locale');
}
$loc->setContextLocale(Localization::CONTEXT_SITE, $locale);
} | [
"public",
"function",
"setupSiteInterfaceLocalization",
"(",
"Page",
"$",
"c",
"=",
"null",
")",
"{",
"$",
"app",
"=",
"Facade",
"::",
"getFacadeApplication",
"(",
")",
";",
"$",
"loc",
"=",
"$",
"app",
"->",
"make",
"(",
"Localization",
"::",
"class",
")",
";",
"$",
"locale",
"=",
"null",
";",
"if",
"(",
"$",
"c",
"===",
"null",
")",
"{",
"$",
"c",
"=",
"Page",
"::",
"getCurrentPage",
"(",
")",
";",
"}",
"if",
"(",
"$",
"c",
")",
"{",
"$",
"pageController",
"=",
"$",
"c",
"->",
"getPageController",
"(",
")",
";",
"if",
"(",
"is_callable",
"(",
"[",
"$",
"pageController",
",",
"'useUserLocale'",
"]",
")",
")",
"{",
"$",
"useUserLocale",
"=",
"$",
"pageController",
"->",
"useUserLocale",
"(",
")",
";",
"}",
"else",
"{",
"$",
"dh",
"=",
"$",
"app",
"->",
"make",
"(",
"'helper/concrete/dashboard'",
")",
";",
"$",
"useUserLocale",
"=",
"$",
"dh",
"->",
"inDashboard",
"(",
"$",
"c",
")",
";",
"}",
"if",
"(",
"$",
"useUserLocale",
")",
"{",
"$",
"u",
"=",
"new",
"User",
"(",
")",
";",
"$",
"locale",
"=",
"$",
"u",
"->",
"getUserLanguageToDisplay",
"(",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"isEnabled",
"(",
")",
")",
"{",
"$",
"ms",
"=",
"Section",
"::",
"getBySectionOfSite",
"(",
"$",
"c",
")",
";",
"if",
"(",
"!",
"$",
"ms",
")",
"{",
"$",
"ms",
"=",
"static",
"::",
"getPreferredSection",
"(",
")",
";",
"}",
"if",
"(",
"$",
"ms",
")",
"{",
"$",
"locale",
"=",
"$",
"ms",
"->",
"getLocale",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"canSetSessionValue",
"(",
")",
")",
"{",
"$",
"app",
"->",
"make",
"(",
"'session'",
")",
"->",
"set",
"(",
"'multilingual_default_locale'",
",",
"$",
"locale",
")",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"$",
"locale",
")",
"{",
"$",
"siteTree",
"=",
"$",
"c",
"->",
"getSiteTreeObject",
"(",
")",
";",
"if",
"(",
"$",
"siteTree",
")",
"{",
"$",
"locale",
"=",
"$",
"siteTree",
"->",
"getLocale",
"(",
")",
"->",
"getLocale",
"(",
")",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"!",
"$",
"locale",
")",
"{",
"$",
"locale",
"=",
"$",
"app",
"->",
"make",
"(",
"'config'",
")",
"->",
"get",
"(",
"'concrete.locale'",
")",
";",
"}",
"$",
"loc",
"->",
"setContextLocale",
"(",
"Localization",
"::",
"CONTEXT_SITE",
",",
"$",
"locale",
")",
";",
"}"
] | Set the locale associated to the 'site' localization context.
@param Page $c The page to be used to determine the site locale (if null we'll use the current page) | [
"Set",
"the",
"locale",
"associated",
"to",
"the",
"site",
"localization",
"context",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Multilingual/Service/Detector.php#L102-L147 | train |
concrete5/concrete5 | concrete/src/Multilingual/Service/Detector.php | Detector.isEnabled | public static function isEnabled()
{
$app = Facade::getFacadeApplication();
$cache = $app->make('cache/request');
$item = $cache->getItem('multilingual/enabled');
if (!$item->isMiss()) {
return $item->get();
}
$item->lock();
$result = false;
if ($app->isInstalled()) {
$site = $app->make('site')->getSite();
if (count($site->getLocales()) > 1) {
$result = true;
}
}
$cache->save($item->set($result));
return $result;
} | php | public static function isEnabled()
{
$app = Facade::getFacadeApplication();
$cache = $app->make('cache/request');
$item = $cache->getItem('multilingual/enabled');
if (!$item->isMiss()) {
return $item->get();
}
$item->lock();
$result = false;
if ($app->isInstalled()) {
$site = $app->make('site')->getSite();
if (count($site->getLocales()) > 1) {
$result = true;
}
}
$cache->save($item->set($result));
return $result;
} | [
"public",
"static",
"function",
"isEnabled",
"(",
")",
"{",
"$",
"app",
"=",
"Facade",
"::",
"getFacadeApplication",
"(",
")",
";",
"$",
"cache",
"=",
"$",
"app",
"->",
"make",
"(",
"'cache/request'",
")",
";",
"$",
"item",
"=",
"$",
"cache",
"->",
"getItem",
"(",
"'multilingual/enabled'",
")",
";",
"if",
"(",
"!",
"$",
"item",
"->",
"isMiss",
"(",
")",
")",
"{",
"return",
"$",
"item",
"->",
"get",
"(",
")",
";",
"}",
"$",
"item",
"->",
"lock",
"(",
")",
";",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"$",
"app",
"->",
"isInstalled",
"(",
")",
")",
"{",
"$",
"site",
"=",
"$",
"app",
"->",
"make",
"(",
"'site'",
")",
"->",
"getSite",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"site",
"->",
"getLocales",
"(",
")",
")",
">",
"1",
")",
"{",
"$",
"result",
"=",
"true",
";",
"}",
"}",
"$",
"cache",
"->",
"save",
"(",
"$",
"item",
"->",
"set",
"(",
"$",
"result",
")",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Check if there's some multilingual section.
@return bool | [
"Check",
"if",
"there",
"s",
"some",
"multilingual",
"section",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Multilingual/Service/Detector.php#L154-L175 | train |
concrete5/concrete5 | concrete/src/Mail/Transport/LimitedSmtp.php | LimitedSmtp.trackLimit | private function trackLimit()
{
++$this->sent;
if ($this->sent >= $this->limit) {
$this->sent = 0;
$this->transport->disconnect();
}
} | php | private function trackLimit()
{
++$this->sent;
if ($this->sent >= $this->limit) {
$this->sent = 0;
$this->transport->disconnect();
}
} | [
"private",
"function",
"trackLimit",
"(",
")",
"{",
"++",
"$",
"this",
"->",
"sent",
";",
"if",
"(",
"$",
"this",
"->",
"sent",
">=",
"$",
"this",
"->",
"limit",
")",
"{",
"$",
"this",
"->",
"sent",
"=",
"0",
";",
"$",
"this",
"->",
"transport",
"->",
"disconnect",
"(",
")",
";",
"}",
"}"
] | Increment the counter of sent messages and disconnect the underlying transport if needed. | [
"Increment",
"the",
"counter",
"of",
"sent",
"messages",
"and",
"disconnect",
"the",
"underlying",
"transport",
"if",
"needed",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Mail/Transport/LimitedSmtp.php#L68-L75 | train |
concrete5/concrete5 | concrete/src/Validator/AbstractTranslatableValidator.php | AbstractTranslatableValidator.getErrorString | protected function getErrorString($code, $value, $default = null)
{
if (array_key_exists($code, $this->translatable_errors)) {
$resolver = $this->translatable_errors[$code];
if ($resolver instanceof Closure) {
return $resolver($this, $code, $value);
} else {
return $resolver;
}
}
return $default;
} | php | protected function getErrorString($code, $value, $default = null)
{
if (array_key_exists($code, $this->translatable_errors)) {
$resolver = $this->translatable_errors[$code];
if ($resolver instanceof Closure) {
return $resolver($this, $code, $value);
} else {
return $resolver;
}
}
return $default;
} | [
"protected",
"function",
"getErrorString",
"(",
"$",
"code",
",",
"$",
"value",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"code",
",",
"$",
"this",
"->",
"translatable_errors",
")",
")",
"{",
"$",
"resolver",
"=",
"$",
"this",
"->",
"translatable_errors",
"[",
"$",
"code",
"]",
";",
"if",
"(",
"$",
"resolver",
"instanceof",
"Closure",
")",
"{",
"return",
"$",
"resolver",
"(",
"$",
"this",
",",
"$",
"code",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"return",
"$",
"resolver",
";",
"}",
"}",
"return",
"$",
"default",
";",
"}"
] | Get an error string given a code and a passed value.
@param int $code
@param mixed $value
@param mixed $default
@return string|mixed Returns a string or $default | [
"Get",
"an",
"error",
"string",
"given",
"a",
"code",
"and",
"a",
"passed",
"value",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Validator/AbstractTranslatableValidator.php#L77-L89 | train |
concrete5/concrete5 | concrete/src/User/PrivateMessage/PrivateMessage.php | PrivateMessage.getFormattedMessageBody | public function getFormattedMessageBody()
{
$msgBody = $this->getMessageBody();
$txt = Loader::helper('text');
$repliedPos = strpos($msgBody, $this->getMessageDelimiter());
if ($repliedPos > -1) {
$repliedText = substr($msgBody, $repliedPos);
$messageText = substr($msgBody, 0, $repliedPos);
$msgBody = $messageText . '<div class="ccm-profile-message-replied">' . nl2br($txt->entities($repliedText)) . '</div>';
$msgBody = str_replace($this->getMessageDelimiter(), '<hr />', $msgBody);
} else {
$msgBody = nl2br($txt->entities($msgBody));
}
return $msgBody;
} | php | public function getFormattedMessageBody()
{
$msgBody = $this->getMessageBody();
$txt = Loader::helper('text');
$repliedPos = strpos($msgBody, $this->getMessageDelimiter());
if ($repliedPos > -1) {
$repliedText = substr($msgBody, $repliedPos);
$messageText = substr($msgBody, 0, $repliedPos);
$msgBody = $messageText . '<div class="ccm-profile-message-replied">' . nl2br($txt->entities($repliedText)) . '</div>';
$msgBody = str_replace($this->getMessageDelimiter(), '<hr />', $msgBody);
} else {
$msgBody = nl2br($txt->entities($msgBody));
}
return $msgBody;
} | [
"public",
"function",
"getFormattedMessageBody",
"(",
")",
"{",
"$",
"msgBody",
"=",
"$",
"this",
"->",
"getMessageBody",
"(",
")",
";",
"$",
"txt",
"=",
"Loader",
"::",
"helper",
"(",
"'text'",
")",
";",
"$",
"repliedPos",
"=",
"strpos",
"(",
"$",
"msgBody",
",",
"$",
"this",
"->",
"getMessageDelimiter",
"(",
")",
")",
";",
"if",
"(",
"$",
"repliedPos",
">",
"-",
"1",
")",
"{",
"$",
"repliedText",
"=",
"substr",
"(",
"$",
"msgBody",
",",
"$",
"repliedPos",
")",
";",
"$",
"messageText",
"=",
"substr",
"(",
"$",
"msgBody",
",",
"0",
",",
"$",
"repliedPos",
")",
";",
"$",
"msgBody",
"=",
"$",
"messageText",
".",
"'<div class=\"ccm-profile-message-replied\">'",
".",
"nl2br",
"(",
"$",
"txt",
"->",
"entities",
"(",
"$",
"repliedText",
")",
")",
".",
"'</div>'",
";",
"$",
"msgBody",
"=",
"str_replace",
"(",
"$",
"this",
"->",
"getMessageDelimiter",
"(",
")",
",",
"'<hr />'",
",",
"$",
"msgBody",
")",
";",
"}",
"else",
"{",
"$",
"msgBody",
"=",
"nl2br",
"(",
"$",
"txt",
"->",
"entities",
"(",
"$",
"msgBody",
")",
")",
";",
"}",
"return",
"$",
"msgBody",
";",
"}"
] | Responsible for converting line breaks to br tags, perhaps running bbcode, as well as making the older replied-to messages gray. | [
"Responsible",
"for",
"converting",
"line",
"breaks",
"to",
"br",
"tags",
"perhaps",
"running",
"bbcode",
"as",
"well",
"as",
"making",
"the",
"older",
"replied",
"-",
"to",
"messages",
"gray",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/PrivateMessage/PrivateMessage.php#L132-L148 | train |
concrete5/concrete5 | concrete/src/Statistics/UsageTracker/AggregateTracker.php | AggregateTracker.addTracker | public function addTracker($tracker, callable $creator)
{
$this->creators[$tracker] = $creator;
$this->map[] = $tracker;
if (isset($this->trackers[$tracker])) {
unset($this->trackers[$tracker]);
}
return $this;
} | php | public function addTracker($tracker, callable $creator)
{
$this->creators[$tracker] = $creator;
$this->map[] = $tracker;
if (isset($this->trackers[$tracker])) {
unset($this->trackers[$tracker]);
}
return $this;
} | [
"public",
"function",
"addTracker",
"(",
"$",
"tracker",
",",
"callable",
"$",
"creator",
")",
"{",
"$",
"this",
"->",
"creators",
"[",
"$",
"tracker",
"]",
"=",
"$",
"creator",
";",
"$",
"this",
"->",
"map",
"[",
"]",
"=",
"$",
"tracker",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"trackers",
"[",
"$",
"tracker",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"trackers",
"[",
"$",
"tracker",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Register a custom tracker creator Closure.
@param string $tracker The handle of the tracker
@param callable $creator The closure responsible for returning the new tracker instance
@return static | [
"Register",
"a",
"custom",
"tracker",
"creator",
"Closure",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Statistics/UsageTracker/AggregateTracker.php#L64-L74 | train |
concrete5/concrete5 | concrete/src/Statistics/UsageTracker/AggregateTracker.php | AggregateTracker.tracker | public function tracker($tracker)
{
// We've already made this tracker, so just return it.
if ($cached = array_get($this->trackers, $tracker)) {
return $cached;
}
// We've got a creator, lets create the tracker
if ($creator = array_get($this->creators, $tracker)) {
// Create through Container
$created = $this->app->call($creator);
$this->trackers[$tracker] = $created;
unset($this->creators[$tracker]);
return $created;
}
throw new InvalidArgumentException("Tracker [$tracker] not supported.");
} | php | public function tracker($tracker)
{
// We've already made this tracker, so just return it.
if ($cached = array_get($this->trackers, $tracker)) {
return $cached;
}
// We've got a creator, lets create the tracker
if ($creator = array_get($this->creators, $tracker)) {
// Create through Container
$created = $this->app->call($creator);
$this->trackers[$tracker] = $created;
unset($this->creators[$tracker]);
return $created;
}
throw new InvalidArgumentException("Tracker [$tracker] not supported.");
} | [
"public",
"function",
"tracker",
"(",
"$",
"tracker",
")",
"{",
"// We've already made this tracker, so just return it.",
"if",
"(",
"$",
"cached",
"=",
"array_get",
"(",
"$",
"this",
"->",
"trackers",
",",
"$",
"tracker",
")",
")",
"{",
"return",
"$",
"cached",
";",
"}",
"// We've got a creator, lets create the tracker",
"if",
"(",
"$",
"creator",
"=",
"array_get",
"(",
"$",
"this",
"->",
"creators",
",",
"$",
"tracker",
")",
")",
"{",
"// Create through Container",
"$",
"created",
"=",
"$",
"this",
"->",
"app",
"->",
"call",
"(",
"$",
"creator",
")",
";",
"$",
"this",
"->",
"trackers",
"[",
"$",
"tracker",
"]",
"=",
"$",
"created",
";",
"unset",
"(",
"$",
"this",
"->",
"creators",
"[",
"$",
"tracker",
"]",
")",
";",
"return",
"$",
"created",
";",
"}",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Tracker [$tracker] not supported.\"",
")",
";",
"}"
] | Get a tracker by handle
@param $tracker
@return TrackerInterface | [
"Get",
"a",
"tracker",
"by",
"handle"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Statistics/UsageTracker/AggregateTracker.php#L81-L100 | train |
concrete5/concrete5 | concrete/src/Database/DatabaseManager.php | DatabaseManager.reconnect | public function reconnect($name = null)
{
$this->disconnect($name = $name ?: $this->getDefaultConnection());
if (!isset($this->connections[$name])) {
return $this->connection($name);
} else {
return $this->refreshPdoConnections($name);
}
} | php | public function reconnect($name = null)
{
$this->disconnect($name = $name ?: $this->getDefaultConnection());
if (!isset($this->connections[$name])) {
return $this->connection($name);
} else {
return $this->refreshPdoConnections($name);
}
} | [
"public",
"function",
"reconnect",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"disconnect",
"(",
"$",
"name",
"=",
"$",
"name",
"?",
":",
"$",
"this",
"->",
"getDefaultConnection",
"(",
")",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"connections",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"connection",
"(",
"$",
"name",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"refreshPdoConnections",
"(",
"$",
"name",
")",
";",
"}",
"}"
] | Reconnect to the given database.
@param string $name
@return \Concrete\Core\Database\Connection\Connection | [
"Reconnect",
"to",
"the",
"given",
"database",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Database/DatabaseManager.php#L133-L142 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.