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/Legacy/ItemList.php | ItemList.displayPaging | public function displayPaging($script = false, $return = false, $additionalVars = array())
{
$summary = $this->getSummary();
$paginator = $this->getPagination($script, $additionalVars);
if ($summary->pages > 1) {
$html = '<div class="ccm-spacer"></div>';
$html .= '<div class="ccm-pagination">';
$html .= '<span class="ccm-page-left">' . $paginator->getPrevious() . '</span>';
$html .= $paginator->getPages();
$html .= '<span class="ccm-page-right">' . $paginator->getNext() . '</span>';
$html .= '</div>';
}
if (isset($html)) {
if ($return) {
return $html;
} else {
echo $html;
}
}
} | php | public function displayPaging($script = false, $return = false, $additionalVars = array())
{
$summary = $this->getSummary();
$paginator = $this->getPagination($script, $additionalVars);
if ($summary->pages > 1) {
$html = '<div class="ccm-spacer"></div>';
$html .= '<div class="ccm-pagination">';
$html .= '<span class="ccm-page-left">' . $paginator->getPrevious() . '</span>';
$html .= $paginator->getPages();
$html .= '<span class="ccm-page-right">' . $paginator->getNext() . '</span>';
$html .= '</div>';
}
if (isset($html)) {
if ($return) {
return $html;
} else {
echo $html;
}
}
} | [
"public",
"function",
"displayPaging",
"(",
"$",
"script",
"=",
"false",
",",
"$",
"return",
"=",
"false",
",",
"$",
"additionalVars",
"=",
"array",
"(",
")",
")",
"{",
"$",
"summary",
"=",
"$",
"this",
"->",
"getSummary",
"(",
")",
";",
"$",
"paginator",
"=",
"$",
"this",
"->",
"getPagination",
"(",
"$",
"script",
",",
"$",
"additionalVars",
")",
";",
"if",
"(",
"$",
"summary",
"->",
"pages",
">",
"1",
")",
"{",
"$",
"html",
"=",
"'<div class=\"ccm-spacer\"></div>'",
";",
"$",
"html",
".=",
"'<div class=\"ccm-pagination\">'",
";",
"$",
"html",
".=",
"'<span class=\"ccm-page-left\">'",
".",
"$",
"paginator",
"->",
"getPrevious",
"(",
")",
".",
"'</span>'",
";",
"$",
"html",
".=",
"$",
"paginator",
"->",
"getPages",
"(",
")",
";",
"$",
"html",
".=",
"'<span class=\"ccm-page-right\">'",
".",
"$",
"paginator",
"->",
"getNext",
"(",
")",
".",
"'</span>'",
";",
"$",
"html",
".=",
"'</div>'",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"html",
")",
")",
"{",
"if",
"(",
"$",
"return",
")",
"{",
"return",
"$",
"html",
";",
"}",
"else",
"{",
"echo",
"$",
"html",
";",
"}",
"}",
"}"
] | Gets standard HTML to display paging | [
"Gets",
"standard",
"HTML",
"to",
"display",
"paging"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Legacy/ItemList.php#L288-L307 | train |
concrete5/concrete5 | concrete/src/Legacy/ItemList.php | ItemList.getSummary | public function getSummary()
{
$ss = new \stdClass();
$ss->chunk = $this->itemsPerPage;
$ss->order = $this->sortByDirection;
$ss->startAt = $this->start;
$ss->total = $this->getTotal();
$ss->startAt = ($ss->startAt < $ss->chunk) ? '0' : $ss->startAt;
$itc = intval($ss->total / $ss->chunk);
if ($ss->total == $ss->chunk) {
$itc = 0;
}
$ss->pages = $itc + 1;
if ($ss->startAt > 0) {
$ss->current = ($ss->startAt / $ss->chunk) + 1;
} else {
$ss->current = '1';
}
$ss->previous = ($ss->startAt >= $ss->chunk) ? ($ss->current - 2) * $ss->chunk : -1;
$ss->next = (($ss->total - $ss->startAt) >= $ss->chunk) ? $ss->current * $ss->chunk : '';
$ss->last = (($ss->total - $ss->startAt) >= $ss->chunk) ? ($ss->pages - 1) * $ss->chunk : '';
$ss->currentStart = ($ss->current > 1) ? ((($ss->current - 1) * $ss->chunk) + 1) : '1';
$ss->currentEnd = ((($ss->current + $ss->chunk) - 1) <= $ss->last) ? ($ss->currentStart + $ss->chunk) - 1 : $ss->total;
$ss->needsPaging = ($ss->total > $ss->chunk) ? true : false;
return $ss;
} | php | public function getSummary()
{
$ss = new \stdClass();
$ss->chunk = $this->itemsPerPage;
$ss->order = $this->sortByDirection;
$ss->startAt = $this->start;
$ss->total = $this->getTotal();
$ss->startAt = ($ss->startAt < $ss->chunk) ? '0' : $ss->startAt;
$itc = intval($ss->total / $ss->chunk);
if ($ss->total == $ss->chunk) {
$itc = 0;
}
$ss->pages = $itc + 1;
if ($ss->startAt > 0) {
$ss->current = ($ss->startAt / $ss->chunk) + 1;
} else {
$ss->current = '1';
}
$ss->previous = ($ss->startAt >= $ss->chunk) ? ($ss->current - 2) * $ss->chunk : -1;
$ss->next = (($ss->total - $ss->startAt) >= $ss->chunk) ? $ss->current * $ss->chunk : '';
$ss->last = (($ss->total - $ss->startAt) >= $ss->chunk) ? ($ss->pages - 1) * $ss->chunk : '';
$ss->currentStart = ($ss->current > 1) ? ((($ss->current - 1) * $ss->chunk) + 1) : '1';
$ss->currentEnd = ((($ss->current + $ss->chunk) - 1) <= $ss->last) ? ($ss->currentStart + $ss->chunk) - 1 : $ss->total;
$ss->needsPaging = ($ss->total > $ss->chunk) ? true : false;
return $ss;
} | [
"public",
"function",
"getSummary",
"(",
")",
"{",
"$",
"ss",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"$",
"ss",
"->",
"chunk",
"=",
"$",
"this",
"->",
"itemsPerPage",
";",
"$",
"ss",
"->",
"order",
"=",
"$",
"this",
"->",
"sortByDirection",
";",
"$",
"ss",
"->",
"startAt",
"=",
"$",
"this",
"->",
"start",
";",
"$",
"ss",
"->",
"total",
"=",
"$",
"this",
"->",
"getTotal",
"(",
")",
";",
"$",
"ss",
"->",
"startAt",
"=",
"(",
"$",
"ss",
"->",
"startAt",
"<",
"$",
"ss",
"->",
"chunk",
")",
"?",
"'0'",
":",
"$",
"ss",
"->",
"startAt",
";",
"$",
"itc",
"=",
"intval",
"(",
"$",
"ss",
"->",
"total",
"/",
"$",
"ss",
"->",
"chunk",
")",
";",
"if",
"(",
"$",
"ss",
"->",
"total",
"==",
"$",
"ss",
"->",
"chunk",
")",
"{",
"$",
"itc",
"=",
"0",
";",
"}",
"$",
"ss",
"->",
"pages",
"=",
"$",
"itc",
"+",
"1",
";",
"if",
"(",
"$",
"ss",
"->",
"startAt",
">",
"0",
")",
"{",
"$",
"ss",
"->",
"current",
"=",
"(",
"$",
"ss",
"->",
"startAt",
"/",
"$",
"ss",
"->",
"chunk",
")",
"+",
"1",
";",
"}",
"else",
"{",
"$",
"ss",
"->",
"current",
"=",
"'1'",
";",
"}",
"$",
"ss",
"->",
"previous",
"=",
"(",
"$",
"ss",
"->",
"startAt",
">=",
"$",
"ss",
"->",
"chunk",
")",
"?",
"(",
"$",
"ss",
"->",
"current",
"-",
"2",
")",
"*",
"$",
"ss",
"->",
"chunk",
":",
"-",
"1",
";",
"$",
"ss",
"->",
"next",
"=",
"(",
"(",
"$",
"ss",
"->",
"total",
"-",
"$",
"ss",
"->",
"startAt",
")",
">=",
"$",
"ss",
"->",
"chunk",
")",
"?",
"$",
"ss",
"->",
"current",
"*",
"$",
"ss",
"->",
"chunk",
":",
"''",
";",
"$",
"ss",
"->",
"last",
"=",
"(",
"(",
"$",
"ss",
"->",
"total",
"-",
"$",
"ss",
"->",
"startAt",
")",
">=",
"$",
"ss",
"->",
"chunk",
")",
"?",
"(",
"$",
"ss",
"->",
"pages",
"-",
"1",
")",
"*",
"$",
"ss",
"->",
"chunk",
":",
"''",
";",
"$",
"ss",
"->",
"currentStart",
"=",
"(",
"$",
"ss",
"->",
"current",
">",
"1",
")",
"?",
"(",
"(",
"(",
"$",
"ss",
"->",
"current",
"-",
"1",
")",
"*",
"$",
"ss",
"->",
"chunk",
")",
"+",
"1",
")",
":",
"'1'",
";",
"$",
"ss",
"->",
"currentEnd",
"=",
"(",
"(",
"(",
"$",
"ss",
"->",
"current",
"+",
"$",
"ss",
"->",
"chunk",
")",
"-",
"1",
")",
"<=",
"$",
"ss",
"->",
"last",
")",
"?",
"(",
"$",
"ss",
"->",
"currentStart",
"+",
"$",
"ss",
"->",
"chunk",
")",
"-",
"1",
":",
"$",
"ss",
"->",
"total",
";",
"$",
"ss",
"->",
"needsPaging",
"=",
"(",
"$",
"ss",
"->",
"total",
">",
"$",
"ss",
"->",
"chunk",
")",
"?",
"true",
":",
"false",
";",
"return",
"$",
"ss",
";",
"}"
] | Returns an object with properties useful for paging. | [
"Returns",
"an",
"object",
"with",
"properties",
"useful",
"for",
"paging",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Legacy/ItemList.php#L311-L341 | train |
concrete5/concrete5 | concrete/src/Console/Command/ServiceCommand.php | ServiceCommand.parseRuleOptions | protected function parseRuleOptions(InputInterface $input)
{
$ruleOptions = [];
foreach ($input->getArgument('rule-options') as $keyValuePair) {
list($key, $value) = explode('=', $keyValuePair, 2);
$key = trim($key);
if (substr($key, -2) === '[]') {
$isArray = true;
$key = rtrim(substr($key, 0, -2));
} else {
$isArray = false;
}
if ($key === '' || !isset($value)) {
throw new Exception(sprintf("Unable to parse the rule option '%s': it must be in the form of key=value", $keyValuePair));
}
if (isset($ruleOptions[$key])) {
if (!($isArray && is_array($ruleOptions[$key]))) {
throw new Exception(sprintf("Duplicated rule option '%s'", $key));
}
$ruleOptions[$key][] = $value;
} else {
$ruleOptions[$key] = $isArray ? ((array) $value) : $value;
}
}
return $ruleOptions;
} | php | protected function parseRuleOptions(InputInterface $input)
{
$ruleOptions = [];
foreach ($input->getArgument('rule-options') as $keyValuePair) {
list($key, $value) = explode('=', $keyValuePair, 2);
$key = trim($key);
if (substr($key, -2) === '[]') {
$isArray = true;
$key = rtrim(substr($key, 0, -2));
} else {
$isArray = false;
}
if ($key === '' || !isset($value)) {
throw new Exception(sprintf("Unable to parse the rule option '%s': it must be in the form of key=value", $keyValuePair));
}
if (isset($ruleOptions[$key])) {
if (!($isArray && is_array($ruleOptions[$key]))) {
throw new Exception(sprintf("Duplicated rule option '%s'", $key));
}
$ruleOptions[$key][] = $value;
} else {
$ruleOptions[$key] = $isArray ? ((array) $value) : $value;
}
}
return $ruleOptions;
} | [
"protected",
"function",
"parseRuleOptions",
"(",
"InputInterface",
"$",
"input",
")",
"{",
"$",
"ruleOptions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"input",
"->",
"getArgument",
"(",
"'rule-options'",
")",
"as",
"$",
"keyValuePair",
")",
"{",
"list",
"(",
"$",
"key",
",",
"$",
"value",
")",
"=",
"explode",
"(",
"'='",
",",
"$",
"keyValuePair",
",",
"2",
")",
";",
"$",
"key",
"=",
"trim",
"(",
"$",
"key",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"key",
",",
"-",
"2",
")",
"===",
"'[]'",
")",
"{",
"$",
"isArray",
"=",
"true",
";",
"$",
"key",
"=",
"rtrim",
"(",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"-",
"2",
")",
")",
";",
"}",
"else",
"{",
"$",
"isArray",
"=",
"false",
";",
"}",
"if",
"(",
"$",
"key",
"===",
"''",
"||",
"!",
"isset",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"\"Unable to parse the rule option '%s': it must be in the form of key=value\"",
",",
"$",
"keyValuePair",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"ruleOptions",
"[",
"$",
"key",
"]",
")",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"isArray",
"&&",
"is_array",
"(",
"$",
"ruleOptions",
"[",
"$",
"key",
"]",
")",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"\"Duplicated rule option '%s'\"",
",",
"$",
"key",
")",
")",
";",
"}",
"$",
"ruleOptions",
"[",
"$",
"key",
"]",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"ruleOptions",
"[",
"$",
"key",
"]",
"=",
"$",
"isArray",
"?",
"(",
"(",
"array",
")",
"$",
"value",
")",
":",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"ruleOptions",
";",
"}"
] | Parse the rule-options input argument.
@param InputInterface $input
@throws Exception
@return array | [
"Parse",
"the",
"rule",
"-",
"options",
"input",
"argument",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Console/Command/ServiceCommand.php#L201-L227 | train |
concrete5/concrete5 | concrete/src/Updater/Migrations/Configuration.php | Configuration.forceMaxInitialMigration | public function forceMaxInitialMigration()
{
$forcedInitialMigration = null;
foreach (array_reverse($this->getMigrations()) as $migration) {
/* @var \Doctrine\DBAL\Migrations\Version $migration */
if ($migration->isMigrated() && !$migration->getMigration() instanceof RepeatableMigrationInterface) {
break;
}
$forcedInitialMigration = $migration;
}
$this->forcedInitialMigration = $forcedInitialMigration;
} | php | public function forceMaxInitialMigration()
{
$forcedInitialMigration = null;
foreach (array_reverse($this->getMigrations()) as $migration) {
/* @var \Doctrine\DBAL\Migrations\Version $migration */
if ($migration->isMigrated() && !$migration->getMigration() instanceof RepeatableMigrationInterface) {
break;
}
$forcedInitialMigration = $migration;
}
$this->forcedInitialMigration = $forcedInitialMigration;
} | [
"public",
"function",
"forceMaxInitialMigration",
"(",
")",
"{",
"$",
"forcedInitialMigration",
"=",
"null",
";",
"foreach",
"(",
"array_reverse",
"(",
"$",
"this",
"->",
"getMigrations",
"(",
")",
")",
"as",
"$",
"migration",
")",
"{",
"/* @var \\Doctrine\\DBAL\\Migrations\\Version $migration */",
"if",
"(",
"$",
"migration",
"->",
"isMigrated",
"(",
")",
"&&",
"!",
"$",
"migration",
"->",
"getMigration",
"(",
")",
"instanceof",
"RepeatableMigrationInterface",
")",
"{",
"break",
";",
"}",
"$",
"forcedInitialMigration",
"=",
"$",
"migration",
";",
"}",
"$",
"this",
"->",
"forcedInitialMigration",
"=",
"$",
"forcedInitialMigration",
";",
"}"
] | Force the initial migration to be the least recent repeatable one. | [
"Force",
"the",
"initial",
"migration",
"to",
"be",
"the",
"least",
"recent",
"repeatable",
"one",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Updater/Migrations/Configuration.php#L57-L68 | train |
concrete5/concrete5 | concrete/src/Updater/Migrations/Configuration.php | Configuration.forceInitialMigration | public function forceInitialMigration($reference, $criteria = self::FORCEDMIGRATION_INCLUSIVE)
{
$reference = trim((string) $reference);
if ($reference === '') {
throw new Exception(t('Invalid initial migration reference.'));
}
if (!in_array($criteria, [static::FORCEDMIGRATION_INCLUSIVE, static::FORCEDMIGRATION_EXCLUSIVE], true)) {
throw new Exception(t('Invalid initial migration criteria.'));
}
// Remove possible 'Version' prefix from the migration identifier.
// This allows a user to also use VersionXXXXXXXXXXXX, which corresponds with the class name.
$reference = str_replace('Version', '', $reference);
$migration = $this->findInitialMigration($reference, $criteria);
if ($migration === null) {
throw new Exception(t('Unable to find a migration with identifier %s', $reference));
}
$this->forcedInitialMigration = $migration;
} | php | public function forceInitialMigration($reference, $criteria = self::FORCEDMIGRATION_INCLUSIVE)
{
$reference = trim((string) $reference);
if ($reference === '') {
throw new Exception(t('Invalid initial migration reference.'));
}
if (!in_array($criteria, [static::FORCEDMIGRATION_INCLUSIVE, static::FORCEDMIGRATION_EXCLUSIVE], true)) {
throw new Exception(t('Invalid initial migration criteria.'));
}
// Remove possible 'Version' prefix from the migration identifier.
// This allows a user to also use VersionXXXXXXXXXXXX, which corresponds with the class name.
$reference = str_replace('Version', '', $reference);
$migration = $this->findInitialMigration($reference, $criteria);
if ($migration === null) {
throw new Exception(t('Unable to find a migration with identifier %s', $reference));
}
$this->forcedInitialMigration = $migration;
} | [
"public",
"function",
"forceInitialMigration",
"(",
"$",
"reference",
",",
"$",
"criteria",
"=",
"self",
"::",
"FORCEDMIGRATION_INCLUSIVE",
")",
"{",
"$",
"reference",
"=",
"trim",
"(",
"(",
"string",
")",
"$",
"reference",
")",
";",
"if",
"(",
"$",
"reference",
"===",
"''",
")",
"{",
"throw",
"new",
"Exception",
"(",
"t",
"(",
"'Invalid initial migration reference.'",
")",
")",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"criteria",
",",
"[",
"static",
"::",
"FORCEDMIGRATION_INCLUSIVE",
",",
"static",
"::",
"FORCEDMIGRATION_EXCLUSIVE",
"]",
",",
"true",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"t",
"(",
"'Invalid initial migration criteria.'",
")",
")",
";",
"}",
"// Remove possible 'Version' prefix from the migration identifier.",
"// This allows a user to also use VersionXXXXXXXXXXXX, which corresponds with the class name.",
"$",
"reference",
"=",
"str_replace",
"(",
"'Version'",
",",
"''",
",",
"$",
"reference",
")",
";",
"$",
"migration",
"=",
"$",
"this",
"->",
"findInitialMigration",
"(",
"$",
"reference",
",",
"$",
"criteria",
")",
";",
"if",
"(",
"$",
"migration",
"===",
"null",
")",
"{",
"throw",
"new",
"Exception",
"(",
"t",
"(",
"'Unable to find a migration with identifier %s'",
",",
"$",
"reference",
")",
")",
";",
"}",
"$",
"this",
"->",
"forcedInitialMigration",
"=",
"$",
"migration",
";",
"}"
] | Force the initial migration, using a specific point.
@param string $reference A concrete5 version (eg. '8.3.1') or a migration identifier (eg '20171218000000')
@param string $criteria One of the FORCEDMIGRATION_... constants | [
"Force",
"the",
"initial",
"migration",
"using",
"a",
"specific",
"point",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Updater/Migrations/Configuration.php#L76-L95 | train |
concrete5/concrete5 | concrete/src/Updater/Migrations/Configuration.php | Configuration.registerPreviousMigratedVersions | public function registerPreviousMigratedVersions()
{
$app = Application::getFacadeApplication();
$db = $app->make(Connection::class);
try {
$minimum = $db->fetchColumn('select min(version) from SystemDatabaseMigrations');
} catch (Exception $e) {
return;
}
$migrations = $this->getMigrations();
$keys = array_keys($migrations);
if ($keys[0] == $minimum) {
// This is the first migration in concrete5. That means we have already populated this table.
return;
} else {
// We have to populate this table with all the migrations from the very first migration up to
// the $minMigration
foreach ($migrations as $key => $migration) {
if ($key < $minimum) {
$migration->markMigrated();
}
}
}
} | php | public function registerPreviousMigratedVersions()
{
$app = Application::getFacadeApplication();
$db = $app->make(Connection::class);
try {
$minimum = $db->fetchColumn('select min(version) from SystemDatabaseMigrations');
} catch (Exception $e) {
return;
}
$migrations = $this->getMigrations();
$keys = array_keys($migrations);
if ($keys[0] == $minimum) {
// This is the first migration in concrete5. That means we have already populated this table.
return;
} else {
// We have to populate this table with all the migrations from the very first migration up to
// the $minMigration
foreach ($migrations as $key => $migration) {
if ($key < $minimum) {
$migration->markMigrated();
}
}
}
} | [
"public",
"function",
"registerPreviousMigratedVersions",
"(",
")",
"{",
"$",
"app",
"=",
"Application",
"::",
"getFacadeApplication",
"(",
")",
";",
"$",
"db",
"=",
"$",
"app",
"->",
"make",
"(",
"Connection",
"::",
"class",
")",
";",
"try",
"{",
"$",
"minimum",
"=",
"$",
"db",
"->",
"fetchColumn",
"(",
"'select min(version) from SystemDatabaseMigrations'",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
";",
"}",
"$",
"migrations",
"=",
"$",
"this",
"->",
"getMigrations",
"(",
")",
";",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"migrations",
")",
";",
"if",
"(",
"$",
"keys",
"[",
"0",
"]",
"==",
"$",
"minimum",
")",
"{",
"// This is the first migration in concrete5. That means we have already populated this table.",
"return",
";",
"}",
"else",
"{",
"// We have to populate this table with all the migrations from the very first migration up to",
"// the $minMigration",
"foreach",
"(",
"$",
"migrations",
"as",
"$",
"key",
"=>",
"$",
"migration",
")",
"{",
"if",
"(",
"$",
"key",
"<",
"$",
"minimum",
")",
"{",
"$",
"migration",
"->",
"markMigrated",
"(",
")",
";",
"}",
"}",
"}",
"}"
] | This is a stupid requirement, but basically, we grab the lowest version number in our
system database migrations table, and we loop through all migrations in our file system
and for any of those LOWER than the lowest one in the table, we can assume they are included
in this migration. We then manually insert these rows into the SystemDatabaseMigrations table
so Doctrine isn't stupid and attempt to apply them. | [
"This",
"is",
"a",
"stupid",
"requirement",
"but",
"basically",
"we",
"grab",
"the",
"lowest",
"version",
"number",
"in",
"our",
"system",
"database",
"migrations",
"table",
"and",
"we",
"loop",
"through",
"all",
"migrations",
"in",
"our",
"file",
"system",
"and",
"for",
"any",
"of",
"those",
"LOWER",
"than",
"the",
"lowest",
"one",
"in",
"the",
"table",
"we",
"can",
"assume",
"they",
"are",
"included",
"in",
"this",
"migration",
".",
"We",
"then",
"manually",
"insert",
"these",
"rows",
"into",
"the",
"SystemDatabaseMigrations",
"table",
"so",
"Doctrine",
"isn",
"t",
"stupid",
"and",
"attempt",
"to",
"apply",
"them",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Updater/Migrations/Configuration.php#L122-L146 | train |
concrete5/concrete5 | concrete/src/Updater/Migrations/Configuration.php | Configuration.findInitialMigrationByCoreVersion | protected function findInitialMigrationByCoreVersion($coreVersion, $criteria)
{
$coreVersionNormalized = preg_replace('/(\.0+)+$/', '', $coreVersion);
if (version_compare($coreVersionNormalized, '5.7') < 0) {
throw new Exception(t('Invalid version specified (%s).', $coreVersion));
}
$migrations = $this->getMigrations();
$migrationIdentifiers = array_keys($migrations);
$maxMigrationIndex = count($migrationIdentifiers) - 1;
$result = null;
foreach ($migrations as $identifier => $migration) {
$migrationCoreVersionNormalized = preg_replace('/(\.0+)+$/', '', $migration->getMigration()->getDescription());
if ($migrationCoreVersionNormalized !== '') {
$cmp = version_compare($migrationCoreVersionNormalized, $coreVersionNormalized);
if ($cmp <= 0 || $result === null) {
switch ($criteria) {
case static::FORCEDMIGRATION_INCLUSIVE:
$result = $migration;
break;
case static::FORCEDMIGRATION_EXCLUSIVE:
$migrationIndex = array_search($identifier, $migrationIdentifiers, false);
$result = $migrationIndex === $maxMigrationIndex ? null : $migrations[$migrationIdentifiers[$migrationIndex + 1]];
break;
default:
throw new Exception(t('Invalid initial migration criteria.'));
}
}
if ($cmp >= 0) {
break;
}
}
}
return $result;
} | php | protected function findInitialMigrationByCoreVersion($coreVersion, $criteria)
{
$coreVersionNormalized = preg_replace('/(\.0+)+$/', '', $coreVersion);
if (version_compare($coreVersionNormalized, '5.7') < 0) {
throw new Exception(t('Invalid version specified (%s).', $coreVersion));
}
$migrations = $this->getMigrations();
$migrationIdentifiers = array_keys($migrations);
$maxMigrationIndex = count($migrationIdentifiers) - 1;
$result = null;
foreach ($migrations as $identifier => $migration) {
$migrationCoreVersionNormalized = preg_replace('/(\.0+)+$/', '', $migration->getMigration()->getDescription());
if ($migrationCoreVersionNormalized !== '') {
$cmp = version_compare($migrationCoreVersionNormalized, $coreVersionNormalized);
if ($cmp <= 0 || $result === null) {
switch ($criteria) {
case static::FORCEDMIGRATION_INCLUSIVE:
$result = $migration;
break;
case static::FORCEDMIGRATION_EXCLUSIVE:
$migrationIndex = array_search($identifier, $migrationIdentifiers, false);
$result = $migrationIndex === $maxMigrationIndex ? null : $migrations[$migrationIdentifiers[$migrationIndex + 1]];
break;
default:
throw new Exception(t('Invalid initial migration criteria.'));
}
}
if ($cmp >= 0) {
break;
}
}
}
return $result;
} | [
"protected",
"function",
"findInitialMigrationByCoreVersion",
"(",
"$",
"coreVersion",
",",
"$",
"criteria",
")",
"{",
"$",
"coreVersionNormalized",
"=",
"preg_replace",
"(",
"'/(\\.0+)+$/'",
",",
"''",
",",
"$",
"coreVersion",
")",
";",
"if",
"(",
"version_compare",
"(",
"$",
"coreVersionNormalized",
",",
"'5.7'",
")",
"<",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"t",
"(",
"'Invalid version specified (%s).'",
",",
"$",
"coreVersion",
")",
")",
";",
"}",
"$",
"migrations",
"=",
"$",
"this",
"->",
"getMigrations",
"(",
")",
";",
"$",
"migrationIdentifiers",
"=",
"array_keys",
"(",
"$",
"migrations",
")",
";",
"$",
"maxMigrationIndex",
"=",
"count",
"(",
"$",
"migrationIdentifiers",
")",
"-",
"1",
";",
"$",
"result",
"=",
"null",
";",
"foreach",
"(",
"$",
"migrations",
"as",
"$",
"identifier",
"=>",
"$",
"migration",
")",
"{",
"$",
"migrationCoreVersionNormalized",
"=",
"preg_replace",
"(",
"'/(\\.0+)+$/'",
",",
"''",
",",
"$",
"migration",
"->",
"getMigration",
"(",
")",
"->",
"getDescription",
"(",
")",
")",
";",
"if",
"(",
"$",
"migrationCoreVersionNormalized",
"!==",
"''",
")",
"{",
"$",
"cmp",
"=",
"version_compare",
"(",
"$",
"migrationCoreVersionNormalized",
",",
"$",
"coreVersionNormalized",
")",
";",
"if",
"(",
"$",
"cmp",
"<=",
"0",
"||",
"$",
"result",
"===",
"null",
")",
"{",
"switch",
"(",
"$",
"criteria",
")",
"{",
"case",
"static",
"::",
"FORCEDMIGRATION_INCLUSIVE",
":",
"$",
"result",
"=",
"$",
"migration",
";",
"break",
";",
"case",
"static",
"::",
"FORCEDMIGRATION_EXCLUSIVE",
":",
"$",
"migrationIndex",
"=",
"array_search",
"(",
"$",
"identifier",
",",
"$",
"migrationIdentifiers",
",",
"false",
")",
";",
"$",
"result",
"=",
"$",
"migrationIndex",
"===",
"$",
"maxMigrationIndex",
"?",
"null",
":",
"$",
"migrations",
"[",
"$",
"migrationIdentifiers",
"[",
"$",
"migrationIndex",
"+",
"1",
"]",
"]",
";",
"break",
";",
"default",
":",
"throw",
"new",
"Exception",
"(",
"t",
"(",
"'Invalid initial migration criteria.'",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"cmp",
">=",
"0",
")",
"{",
"break",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Get the initial migration starting from a core version.
@param string $coreVersion The core version
@param string $criteria One of the FORCEDMIGRATION_... constants
@throws Exception throws an Exception if $criteria is not valid
@return \Doctrine\DBAL\Migrations\Version|null
@example If looking for version 1.4:
20010101000000 v1.1
20020101000000
20030101000000
20040101000000 v1.3 <- if $criteria is FORCEDMIGRATION_INCLUSIVE
20050101000000 <- if $criteria is FORCEDMIGRATION_EXCLUSIVE
20060101000000
20070101000000 v1.5 | [
"Get",
"the",
"initial",
"migration",
"starting",
"from",
"a",
"core",
"version",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Updater/Migrations/Configuration.php#L260-L294 | train |
concrete5/concrete5 | concrete/src/Page/Sitemap/Element/SitemapPageAlternativeLanguage.php | SitemapPageAlternativeLanguage.getFinalHrefLang | protected function getFinalHrefLang()
{
$result = $this->getOverriddenHrefLang();
if ($result === '') {
$result = strtolower(str_replace('_', '-', $this->getSection()->getLocale()));
}
return $result;
} | php | protected function getFinalHrefLang()
{
$result = $this->getOverriddenHrefLang();
if ($result === '') {
$result = strtolower(str_replace('_', '-', $this->getSection()->getLocale()));
}
return $result;
} | [
"protected",
"function",
"getFinalHrefLang",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getOverriddenHrefLang",
"(",
")",
";",
"if",
"(",
"$",
"result",
"===",
"''",
")",
"{",
"$",
"result",
"=",
"strtolower",
"(",
"str_replace",
"(",
"'_'",
",",
"'-'",
",",
"$",
"this",
"->",
"getSection",
"(",
")",
"->",
"getLocale",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Get the final value of the href lang.
@return string | [
"Get",
"the",
"final",
"value",
"of",
"the",
"href",
"lang",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Sitemap/Element/SitemapPageAlternativeLanguage.php#L201-L209 | train |
concrete5/concrete5 | concrete/src/Gathering/Gathering.php | Gathering.generateGatheringItems | public function generateGatheringItems()
{
$configuredDataSources = $this->getConfiguredGatheringDataSources();
$items = array();
foreach ($configuredDataSources as $configuration) {
$dataSource = $configuration->getGatheringDataSourceObject();
$dataSourceItems = $dataSource->createGatheringItems($configuration);
$items = array_merge($dataSourceItems, $items);
}
// now we loop all the items returned, and assign the batch to those items.
$agiBatchTimestamp = time();
$db = Loader::db();
foreach ($items as $it) {
$it->setGatheringItemBatchTimestamp($agiBatchTimestamp);
$it->setAutomaticGatheringItemSlotWidth();
$it->setAutomaticGatheringItemSlotHeight();
}
// now, we find all the items with that timestamp, and we update their display order.
$agiBatchDisplayOrder = 0;
$r = $db->Execute('select gaiID from GatheringItems where gaID = ? and gaiBatchTimestamp = ? order by gaiPublicDateTime desc', array($this->getGatheringID(), $agiBatchTimestamp));
while ($row = $r->FetchRow()) {
$db->Execute('update GatheringItems set gaiBatchDisplayOrder = ? where gaiID = ?', array($agiBatchDisplayOrder, $row['gaiID']));
++$agiBatchDisplayOrder;
}
$date = Loader::helper('date')->getOverridableNow();
$db->Execute('update Gatherings set gaDateLastUpdated = ? where gaID = ?', array($date, $this->gaID));
} | php | public function generateGatheringItems()
{
$configuredDataSources = $this->getConfiguredGatheringDataSources();
$items = array();
foreach ($configuredDataSources as $configuration) {
$dataSource = $configuration->getGatheringDataSourceObject();
$dataSourceItems = $dataSource->createGatheringItems($configuration);
$items = array_merge($dataSourceItems, $items);
}
// now we loop all the items returned, and assign the batch to those items.
$agiBatchTimestamp = time();
$db = Loader::db();
foreach ($items as $it) {
$it->setGatheringItemBatchTimestamp($agiBatchTimestamp);
$it->setAutomaticGatheringItemSlotWidth();
$it->setAutomaticGatheringItemSlotHeight();
}
// now, we find all the items with that timestamp, and we update their display order.
$agiBatchDisplayOrder = 0;
$r = $db->Execute('select gaiID from GatheringItems where gaID = ? and gaiBatchTimestamp = ? order by gaiPublicDateTime desc', array($this->getGatheringID(), $agiBatchTimestamp));
while ($row = $r->FetchRow()) {
$db->Execute('update GatheringItems set gaiBatchDisplayOrder = ? where gaiID = ?', array($agiBatchDisplayOrder, $row['gaiID']));
++$agiBatchDisplayOrder;
}
$date = Loader::helper('date')->getOverridableNow();
$db->Execute('update Gatherings set gaDateLastUpdated = ? where gaID = ?', array($date, $this->gaID));
} | [
"public",
"function",
"generateGatheringItems",
"(",
")",
"{",
"$",
"configuredDataSources",
"=",
"$",
"this",
"->",
"getConfiguredGatheringDataSources",
"(",
")",
";",
"$",
"items",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"configuredDataSources",
"as",
"$",
"configuration",
")",
"{",
"$",
"dataSource",
"=",
"$",
"configuration",
"->",
"getGatheringDataSourceObject",
"(",
")",
";",
"$",
"dataSourceItems",
"=",
"$",
"dataSource",
"->",
"createGatheringItems",
"(",
"$",
"configuration",
")",
";",
"$",
"items",
"=",
"array_merge",
"(",
"$",
"dataSourceItems",
",",
"$",
"items",
")",
";",
"}",
"// now we loop all the items returned, and assign the batch to those items.",
"$",
"agiBatchTimestamp",
"=",
"time",
"(",
")",
";",
"$",
"db",
"=",
"Loader",
"::",
"db",
"(",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"it",
")",
"{",
"$",
"it",
"->",
"setGatheringItemBatchTimestamp",
"(",
"$",
"agiBatchTimestamp",
")",
";",
"$",
"it",
"->",
"setAutomaticGatheringItemSlotWidth",
"(",
")",
";",
"$",
"it",
"->",
"setAutomaticGatheringItemSlotHeight",
"(",
")",
";",
"}",
"// now, we find all the items with that timestamp, and we update their display order.",
"$",
"agiBatchDisplayOrder",
"=",
"0",
";",
"$",
"r",
"=",
"$",
"db",
"->",
"Execute",
"(",
"'select gaiID from GatheringItems where gaID = ? and gaiBatchTimestamp = ? order by gaiPublicDateTime desc'",
",",
"array",
"(",
"$",
"this",
"->",
"getGatheringID",
"(",
")",
",",
"$",
"agiBatchTimestamp",
")",
")",
";",
"while",
"(",
"$",
"row",
"=",
"$",
"r",
"->",
"FetchRow",
"(",
")",
")",
"{",
"$",
"db",
"->",
"Execute",
"(",
"'update GatheringItems set gaiBatchDisplayOrder = ? where gaiID = ?'",
",",
"array",
"(",
"$",
"agiBatchDisplayOrder",
",",
"$",
"row",
"[",
"'gaiID'",
"]",
")",
")",
";",
"++",
"$",
"agiBatchDisplayOrder",
";",
"}",
"$",
"date",
"=",
"Loader",
"::",
"helper",
"(",
"'date'",
")",
"->",
"getOverridableNow",
"(",
")",
";",
"$",
"db",
"->",
"Execute",
"(",
"'update Gatherings set gaDateLastUpdated = ? where gaID = ?'",
",",
"array",
"(",
"$",
"date",
",",
"$",
"this",
"->",
"gaID",
")",
")",
";",
"}"
] | Runs through all active gathering data sources, creates GatheringItem objects. | [
"Runs",
"through",
"all",
"active",
"gathering",
"data",
"sources",
"creates",
"GatheringItem",
"objects",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Gathering/Gathering.php#L133-L162 | train |
concrete5/concrete5 | concrete/src/Foundation/Repetition/Comparator.php | Comparator.areEqual | public function areEqual(RepetitionInterface $r1, RepetitionInterface $r2)
{
if ($r1->getStartDate() != $r2->getStartDate()) {
return false;
}
if ($r1->getTimezone()->getName() != $r2->getTimezone()->getName()) {
return false;
}
if ($r1->getEndDate() != $r2->getEndDate()) {
return false;
}
if ($r1->isStartDateAllDay() != $r2->isStartDateAllDay()) {
return false;
}
if ($r1->isEndDateAllDay() != $r2->isEndDateAllDay()) {
return false;
}
if ($r1->getRepeatPeriod() != $r2->getRepeatPeriod()) {
return false;
}
if ($r1->getRepeatMonthBy() != $r2->getRepeatMonthBy()) {
return false;
}
if ($r1->getRepeatEveryNum() != $r2->getRepeatEveryNum()) {
return false;
}
if ($r1->getRepeatPeriodEnd() != $r2->getRepeatPeriodEnd()) {
return false;
}
foreach($r1->getRepeatPeriodWeekDays() as $weekDay) {
if (!in_array($weekDay, $r2->getRepeatPeriodWeekDays())) {
return false;
}
}
if ($r1->getRepeatPeriodWeekDays() != $r2->getRepeatPeriodWeekDays()) {
}return true;
} | php | public function areEqual(RepetitionInterface $r1, RepetitionInterface $r2)
{
if ($r1->getStartDate() != $r2->getStartDate()) {
return false;
}
if ($r1->getTimezone()->getName() != $r2->getTimezone()->getName()) {
return false;
}
if ($r1->getEndDate() != $r2->getEndDate()) {
return false;
}
if ($r1->isStartDateAllDay() != $r2->isStartDateAllDay()) {
return false;
}
if ($r1->isEndDateAllDay() != $r2->isEndDateAllDay()) {
return false;
}
if ($r1->getRepeatPeriod() != $r2->getRepeatPeriod()) {
return false;
}
if ($r1->getRepeatMonthBy() != $r2->getRepeatMonthBy()) {
return false;
}
if ($r1->getRepeatEveryNum() != $r2->getRepeatEveryNum()) {
return false;
}
if ($r1->getRepeatPeriodEnd() != $r2->getRepeatPeriodEnd()) {
return false;
}
foreach($r1->getRepeatPeriodWeekDays() as $weekDay) {
if (!in_array($weekDay, $r2->getRepeatPeriodWeekDays())) {
return false;
}
}
if ($r1->getRepeatPeriodWeekDays() != $r2->getRepeatPeriodWeekDays()) {
}return true;
} | [
"public",
"function",
"areEqual",
"(",
"RepetitionInterface",
"$",
"r1",
",",
"RepetitionInterface",
"$",
"r2",
")",
"{",
"if",
"(",
"$",
"r1",
"->",
"getStartDate",
"(",
")",
"!=",
"$",
"r2",
"->",
"getStartDate",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"r1",
"->",
"getTimezone",
"(",
")",
"->",
"getName",
"(",
")",
"!=",
"$",
"r2",
"->",
"getTimezone",
"(",
")",
"->",
"getName",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"r1",
"->",
"getEndDate",
"(",
")",
"!=",
"$",
"r2",
"->",
"getEndDate",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"r1",
"->",
"isStartDateAllDay",
"(",
")",
"!=",
"$",
"r2",
"->",
"isStartDateAllDay",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"r1",
"->",
"isEndDateAllDay",
"(",
")",
"!=",
"$",
"r2",
"->",
"isEndDateAllDay",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"r1",
"->",
"getRepeatPeriod",
"(",
")",
"!=",
"$",
"r2",
"->",
"getRepeatPeriod",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"r1",
"->",
"getRepeatMonthBy",
"(",
")",
"!=",
"$",
"r2",
"->",
"getRepeatMonthBy",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"r1",
"->",
"getRepeatEveryNum",
"(",
")",
"!=",
"$",
"r2",
"->",
"getRepeatEveryNum",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"r1",
"->",
"getRepeatPeriodEnd",
"(",
")",
"!=",
"$",
"r2",
"->",
"getRepeatPeriodEnd",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"r1",
"->",
"getRepeatPeriodWeekDays",
"(",
")",
"as",
"$",
"weekDay",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"weekDay",
",",
"$",
"r2",
"->",
"getRepeatPeriodWeekDays",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"$",
"r1",
"->",
"getRepeatPeriodWeekDays",
"(",
")",
"!=",
"$",
"r2",
"->",
"getRepeatPeriodWeekDays",
"(",
")",
")",
"{",
"}",
"return",
"true",
";",
"}"
] | Returns true if the two repetitions are equal.
@param RepetitionInterface $r1
@param RepetitionInterface $r2 | [
"Returns",
"true",
"if",
"the",
"two",
"repetitions",
"are",
"equal",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Foundation/Repetition/Comparator.php#L12-L58 | train |
concrete5/concrete5 | concrete/src/Http/Middleware/ThumbnailMiddleware.php | ThumbnailMiddleware.process | public function process(Request $request, DelegateInterface $frame)
{
$response = $frame->next($request);
if ($response && $this->app->isInstalled() && $this->config->get('concrete.misc.basic_thumbnailer_generation_strategy') == 'now') {
$responseStatusCode = (int) $response->getStatusCode();
if ($responseStatusCode === 200 || $responseStatusCode === 404) {
$database = $this->tryGetConnection();
if ($database !== null) {
if ($responseStatusCode === 404) {
$searchThumbnailPath = $request->getRequestUri();
} else {
$searchThumbnailPath = null;
}
$thumbnail = $this->getThumbnailToGenerate($database, $searchThumbnailPath);
if ($thumbnail !== null) {
$this->markThumbnailAsBuilt($database, $thumbnail);
if ($this->generateThumbnail($thumbnail)) {
if ($this->couldBeTheRequestedThumbnail($thumbnail, $searchThumbnailPath)) {
$response = $this->buildRedirectToThumbnailResponse($request);
}
}
}
}
}
}
return $response;
} | php | public function process(Request $request, DelegateInterface $frame)
{
$response = $frame->next($request);
if ($response && $this->app->isInstalled() && $this->config->get('concrete.misc.basic_thumbnailer_generation_strategy') == 'now') {
$responseStatusCode = (int) $response->getStatusCode();
if ($responseStatusCode === 200 || $responseStatusCode === 404) {
$database = $this->tryGetConnection();
if ($database !== null) {
if ($responseStatusCode === 404) {
$searchThumbnailPath = $request->getRequestUri();
} else {
$searchThumbnailPath = null;
}
$thumbnail = $this->getThumbnailToGenerate($database, $searchThumbnailPath);
if ($thumbnail !== null) {
$this->markThumbnailAsBuilt($database, $thumbnail);
if ($this->generateThumbnail($thumbnail)) {
if ($this->couldBeTheRequestedThumbnail($thumbnail, $searchThumbnailPath)) {
$response = $this->buildRedirectToThumbnailResponse($request);
}
}
}
}
}
}
return $response;
} | [
"public",
"function",
"process",
"(",
"Request",
"$",
"request",
",",
"DelegateInterface",
"$",
"frame",
")",
"{",
"$",
"response",
"=",
"$",
"frame",
"->",
"next",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"response",
"&&",
"$",
"this",
"->",
"app",
"->",
"isInstalled",
"(",
")",
"&&",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'concrete.misc.basic_thumbnailer_generation_strategy'",
")",
"==",
"'now'",
")",
"{",
"$",
"responseStatusCode",
"=",
"(",
"int",
")",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
";",
"if",
"(",
"$",
"responseStatusCode",
"===",
"200",
"||",
"$",
"responseStatusCode",
"===",
"404",
")",
"{",
"$",
"database",
"=",
"$",
"this",
"->",
"tryGetConnection",
"(",
")",
";",
"if",
"(",
"$",
"database",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"responseStatusCode",
"===",
"404",
")",
"{",
"$",
"searchThumbnailPath",
"=",
"$",
"request",
"->",
"getRequestUri",
"(",
")",
";",
"}",
"else",
"{",
"$",
"searchThumbnailPath",
"=",
"null",
";",
"}",
"$",
"thumbnail",
"=",
"$",
"this",
"->",
"getThumbnailToGenerate",
"(",
"$",
"database",
",",
"$",
"searchThumbnailPath",
")",
";",
"if",
"(",
"$",
"thumbnail",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"markThumbnailAsBuilt",
"(",
"$",
"database",
",",
"$",
"thumbnail",
")",
";",
"if",
"(",
"$",
"this",
"->",
"generateThumbnail",
"(",
"$",
"thumbnail",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"couldBeTheRequestedThumbnail",
"(",
"$",
"thumbnail",
",",
"$",
"searchThumbnailPath",
")",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"buildRedirectToThumbnailResponse",
"(",
"$",
"request",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"return",
"$",
"response",
";",
"}"
] | Process the request and return a response.
@param \Symfony\Component\HttpFoundation\Request $request
@param DelegateInterface $frame
@return \Symfony\Component\HttpFoundation\Response | [
"Process",
"the",
"request",
"and",
"return",
"a",
"response",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Http/Middleware/ThumbnailMiddleware.php#L74-L102 | train |
concrete5/concrete5 | concrete/src/Http/Middleware/ThumbnailMiddleware.php | ThumbnailMiddleware.generateThumbnail | private function generateThumbnail(array $thumbnail)
{
$file = $this->getEntityManager()->find(File::class, $thumbnail['fileID']);
if ($this->attemptBuild($file, $thumbnail)) {
$result = true;
} else {
$this->failBuild($file, $thumbnail);
$result = false;
}
return $result;
} | php | private function generateThumbnail(array $thumbnail)
{
$file = $this->getEntityManager()->find(File::class, $thumbnail['fileID']);
if ($this->attemptBuild($file, $thumbnail)) {
$result = true;
} else {
$this->failBuild($file, $thumbnail);
$result = false;
}
return $result;
} | [
"private",
"function",
"generateThumbnail",
"(",
"array",
"$",
"thumbnail",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"find",
"(",
"File",
"::",
"class",
",",
"$",
"thumbnail",
"[",
"'fileID'",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"attemptBuild",
"(",
"$",
"file",
",",
"$",
"thumbnail",
")",
")",
"{",
"$",
"result",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"failBuild",
"(",
"$",
"file",
",",
"$",
"thumbnail",
")",
";",
"$",
"result",
"=",
"false",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Generate a thumbnail.
@param array $thumbnail
@return bool Returns true if success, false on failure | [
"Generate",
"a",
"thumbnail",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Http/Middleware/ThumbnailMiddleware.php#L184-L196 | train |
concrete5/concrete5 | concrete/src/Http/Middleware/ThumbnailMiddleware.php | ThumbnailMiddleware.markThumbnailAsBuilt | private function markThumbnailAsBuilt(Connection $connection, array $thumbnail, $built = true)
{
$key = $thumbnail;
unset($key['lockID']);
unset($key['lockExpires']);
unset($key['path']);
unset($key['isBuilt']);
$connection->update('FileImageThumbnailPaths', ['isBuilt' => $built ? 1 : 0], $key);
} | php | private function markThumbnailAsBuilt(Connection $connection, array $thumbnail, $built = true)
{
$key = $thumbnail;
unset($key['lockID']);
unset($key['lockExpires']);
unset($key['path']);
unset($key['isBuilt']);
$connection->update('FileImageThumbnailPaths', ['isBuilt' => $built ? 1 : 0], $key);
} | [
"private",
"function",
"markThumbnailAsBuilt",
"(",
"Connection",
"$",
"connection",
",",
"array",
"$",
"thumbnail",
",",
"$",
"built",
"=",
"true",
")",
"{",
"$",
"key",
"=",
"$",
"thumbnail",
";",
"unset",
"(",
"$",
"key",
"[",
"'lockID'",
"]",
")",
";",
"unset",
"(",
"$",
"key",
"[",
"'lockExpires'",
"]",
")",
";",
"unset",
"(",
"$",
"key",
"[",
"'path'",
"]",
")",
";",
"unset",
"(",
"$",
"key",
"[",
"'isBuilt'",
"]",
")",
";",
"$",
"connection",
"->",
"update",
"(",
"'FileImageThumbnailPaths'",
",",
"[",
"'isBuilt'",
"=>",
"$",
"built",
"?",
"1",
":",
"0",
"]",
",",
"$",
"key",
")",
";",
"}"
] | Mark a thumbnail as built or not.
@param Connection $connection
@param array $thumbnail
@param bool $built | [
"Mark",
"a",
"thumbnail",
"as",
"built",
"or",
"not",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Http/Middleware/ThumbnailMiddleware.php#L318-L326 | train |
concrete5/concrete5 | concrete/src/Http/Middleware/ThumbnailMiddleware.php | ThumbnailMiddleware.failBuild | private function failBuild(File $file, array $thumbnail)
{
$this->app->make(LoggerInterface::class)
->critical('Failed to generate or locate the thumbnail for file "' . $file->getFileID() . '"');
} | php | private function failBuild(File $file, array $thumbnail)
{
$this->app->make(LoggerInterface::class)
->critical('Failed to generate or locate the thumbnail for file "' . $file->getFileID() . '"');
} | [
"private",
"function",
"failBuild",
"(",
"File",
"$",
"file",
",",
"array",
"$",
"thumbnail",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"LoggerInterface",
"::",
"class",
")",
"->",
"critical",
"(",
"'Failed to generate or locate the thumbnail for file \"'",
".",
"$",
"file",
"->",
"getFileID",
"(",
")",
".",
"'\"'",
")",
";",
"}"
] | Mark the build failed.
@param \Concrete\Core\Entity\File\File $file
@param array $thumbnail | [
"Mark",
"the",
"build",
"failed",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Http/Middleware/ThumbnailMiddleware.php#L347-L351 | train |
concrete5/concrete5 | concrete/src/View/View.php | View.action | public function action($action)
{
$a = func_get_args();
$controllerPath = $this->controller->getControllerActionPath();
array_unshift($a, $controllerPath);
$ret = call_user_func_array([$this, 'url'], $a);
return $ret;
} | php | public function action($action)
{
$a = func_get_args();
$controllerPath = $this->controller->getControllerActionPath();
array_unshift($a, $controllerPath);
$ret = call_user_func_array([$this, 'url'], $a);
return $ret;
} | [
"public",
"function",
"action",
"(",
"$",
"action",
")",
"{",
"$",
"a",
"=",
"func_get_args",
"(",
")",
";",
"$",
"controllerPath",
"=",
"$",
"this",
"->",
"controller",
"->",
"getControllerActionPath",
"(",
")",
";",
"array_unshift",
"(",
"$",
"a",
",",
"$",
"controllerPath",
")",
";",
"$",
"ret",
"=",
"call_user_func_array",
"(",
"[",
"$",
"this",
",",
"'url'",
"]",
",",
"$",
"a",
")",
";",
"return",
"$",
"ret",
";",
"}"
] | A shortcut to posting back to the current page with a task and optional parameters. Only works in the context of.
@param string $action
@param string $task
@return string $url | [
"A",
"shortcut",
"to",
"posting",
"back",
"to",
"the",
"current",
"page",
"with",
"a",
"task",
"and",
"optional",
"parameters",
".",
"Only",
"works",
"in",
"the",
"context",
"of",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/View/View.php#L120-L128 | train |
concrete5/concrete5 | concrete/src/View/View.php | View.loadViewThemeObject | protected function loadViewThemeObject()
{
$env = Environment::get();
$app = Facade::getFacadeApplication();
$tmpTheme = $app->make(ThemeRouteCollection::class)
->getThemeByRoute($this->getViewPath());
if (isset($tmpTheme[0])) {
$this->themeHandle = $tmpTheme[0];
}
if ($this->themeHandle) {
switch ($this->themeHandle) {
case VIEW_CORE_THEME:
$this->themeObject = new \Concrete\Theme\Concrete\PageTheme();
$this->pkgHandle = false;
break;
case 'dashboard':
$this->themeObject = new \Concrete\Theme\Dashboard\PageTheme();
$this->pkgHandle = false;
break;
default:
if (!isset($this->themeObject)) {
$this->themeObject = PageTheme::getByHandle($this->themeHandle);
$this->themePkgHandle = $this->themeObject->getPackageHandle();
}
}
$this->themeAbsolutePath = $env->getPath(DIRNAME_THEMES.'/'.$this->themeHandle, $this->themePkgHandle);
$this->themeRelativePath = $env->getURL(DIRNAME_THEMES.'/'.$this->themeHandle, $this->themePkgHandle);
}
} | php | protected function loadViewThemeObject()
{
$env = Environment::get();
$app = Facade::getFacadeApplication();
$tmpTheme = $app->make(ThemeRouteCollection::class)
->getThemeByRoute($this->getViewPath());
if (isset($tmpTheme[0])) {
$this->themeHandle = $tmpTheme[0];
}
if ($this->themeHandle) {
switch ($this->themeHandle) {
case VIEW_CORE_THEME:
$this->themeObject = new \Concrete\Theme\Concrete\PageTheme();
$this->pkgHandle = false;
break;
case 'dashboard':
$this->themeObject = new \Concrete\Theme\Dashboard\PageTheme();
$this->pkgHandle = false;
break;
default:
if (!isset($this->themeObject)) {
$this->themeObject = PageTheme::getByHandle($this->themeHandle);
$this->themePkgHandle = $this->themeObject->getPackageHandle();
}
}
$this->themeAbsolutePath = $env->getPath(DIRNAME_THEMES.'/'.$this->themeHandle, $this->themePkgHandle);
$this->themeRelativePath = $env->getURL(DIRNAME_THEMES.'/'.$this->themeHandle, $this->themePkgHandle);
}
} | [
"protected",
"function",
"loadViewThemeObject",
"(",
")",
"{",
"$",
"env",
"=",
"Environment",
"::",
"get",
"(",
")",
";",
"$",
"app",
"=",
"Facade",
"::",
"getFacadeApplication",
"(",
")",
";",
"$",
"tmpTheme",
"=",
"$",
"app",
"->",
"make",
"(",
"ThemeRouteCollection",
"::",
"class",
")",
"->",
"getThemeByRoute",
"(",
"$",
"this",
"->",
"getViewPath",
"(",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"tmpTheme",
"[",
"0",
"]",
")",
")",
"{",
"$",
"this",
"->",
"themeHandle",
"=",
"$",
"tmpTheme",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"themeHandle",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"themeHandle",
")",
"{",
"case",
"VIEW_CORE_THEME",
":",
"$",
"this",
"->",
"themeObject",
"=",
"new",
"\\",
"Concrete",
"\\",
"Theme",
"\\",
"Concrete",
"\\",
"PageTheme",
"(",
")",
";",
"$",
"this",
"->",
"pkgHandle",
"=",
"false",
";",
"break",
";",
"case",
"'dashboard'",
":",
"$",
"this",
"->",
"themeObject",
"=",
"new",
"\\",
"Concrete",
"\\",
"Theme",
"\\",
"Dashboard",
"\\",
"PageTheme",
"(",
")",
";",
"$",
"this",
"->",
"pkgHandle",
"=",
"false",
";",
"break",
";",
"default",
":",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"themeObject",
")",
")",
"{",
"$",
"this",
"->",
"themeObject",
"=",
"PageTheme",
"::",
"getByHandle",
"(",
"$",
"this",
"->",
"themeHandle",
")",
";",
"$",
"this",
"->",
"themePkgHandle",
"=",
"$",
"this",
"->",
"themeObject",
"->",
"getPackageHandle",
"(",
")",
";",
"}",
"}",
"$",
"this",
"->",
"themeAbsolutePath",
"=",
"$",
"env",
"->",
"getPath",
"(",
"DIRNAME_THEMES",
".",
"'/'",
".",
"$",
"this",
"->",
"themeHandle",
",",
"$",
"this",
"->",
"themePkgHandle",
")",
";",
"$",
"this",
"->",
"themeRelativePath",
"=",
"$",
"env",
"->",
"getURL",
"(",
"DIRNAME_THEMES",
".",
"'/'",
".",
"$",
"this",
"->",
"themeHandle",
",",
"$",
"this",
"->",
"themePkgHandle",
")",
";",
"}",
"}"
] | Load all the theme-related variables for which theme to use for this request. May update the themeHandle
property on the view based on themeByRoute settings. | [
"Load",
"all",
"the",
"theme",
"-",
"related",
"variables",
"for",
"which",
"theme",
"to",
"use",
"for",
"this",
"request",
".",
"May",
"update",
"the",
"themeHandle",
"property",
"on",
"the",
"view",
"based",
"on",
"themeByRoute",
"settings",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/View/View.php#L164-L194 | train |
concrete5/concrete5 | concrete/controllers/single_page/dashboard/system/registration/automated_logout.php | AutomatedLogout.view | public function view()
{
$this->set('trustedProxyUrl', $this->urls->resolve(['/dashboard/system/permissions/trusted_proxies']));
$this->set('invalidateOnIPMismatch', $this->config->get(self::ITEM_IP));
$this->set('invalidateOnUserAgentMismatch', $this->config->get(self::ITEM_USER_AGENT));
$this->set('invalidateInactiveUsers', $this->config->get(self::ITEM_INVALIDATE_INACTIVE_USERS));
$this->set('inactiveTime', $this->config->get(self::ITEM_INVALIDATE_INACTIVE_USERS_TIME));
$this->set('saveAction', $this->action('save'));
$this->set('invalidateAction', $this->action('invalidate_sessions', $this->token->generate('invalidate_sessions')));
$this->set('confirmInvalidateString', t('invalidate'));
} | php | public function view()
{
$this->set('trustedProxyUrl', $this->urls->resolve(['/dashboard/system/permissions/trusted_proxies']));
$this->set('invalidateOnIPMismatch', $this->config->get(self::ITEM_IP));
$this->set('invalidateOnUserAgentMismatch', $this->config->get(self::ITEM_USER_AGENT));
$this->set('invalidateInactiveUsers', $this->config->get(self::ITEM_INVALIDATE_INACTIVE_USERS));
$this->set('inactiveTime', $this->config->get(self::ITEM_INVALIDATE_INACTIVE_USERS_TIME));
$this->set('saveAction', $this->action('save'));
$this->set('invalidateAction', $this->action('invalidate_sessions', $this->token->generate('invalidate_sessions')));
$this->set('confirmInvalidateString', t('invalidate'));
} | [
"public",
"function",
"view",
"(",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"'trustedProxyUrl'",
",",
"$",
"this",
"->",
"urls",
"->",
"resolve",
"(",
"[",
"'/dashboard/system/permissions/trusted_proxies'",
"]",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'invalidateOnIPMismatch'",
",",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"self",
"::",
"ITEM_IP",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'invalidateOnUserAgentMismatch'",
",",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"self",
"::",
"ITEM_USER_AGENT",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'invalidateInactiveUsers'",
",",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"self",
"::",
"ITEM_INVALIDATE_INACTIVE_USERS",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'inactiveTime'",
",",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"self",
"::",
"ITEM_INVALIDATE_INACTIVE_USERS_TIME",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'saveAction'",
",",
"$",
"this",
"->",
"action",
"(",
"'save'",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'invalidateAction'",
",",
"$",
"this",
"->",
"action",
"(",
"'invalidate_sessions'",
",",
"$",
"this",
"->",
"token",
"->",
"generate",
"(",
"'invalidate_sessions'",
")",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'confirmInvalidateString'",
",",
"t",
"(",
"'invalidate'",
")",
")",
";",
"}"
] | Main view function for the controller. This method is called when no other action matches the request
@return \Concrete\Core\Http\Response|void | [
"Main",
"view",
"function",
"for",
"the",
"controller",
".",
"This",
"method",
"is",
"called",
"when",
"no",
"other",
"action",
"matches",
"the",
"request"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/controllers/single_page/dashboard/system/registration/automated_logout.php#L56-L68 | train |
concrete5/concrete5 | concrete/controllers/single_page/dashboard/system/registration/automated_logout.php | AutomatedLogout.save | public function save()
{
if (!$this->token->validate('save_automated_logout')) {
$this->error->add($this->token->getErrorMessage());
$this->flash('error', $this->error);
// Redirect away from this save endpoint
return $this->factory->redirect($this->action());
}
$post = $this->request->request;
// Save the posted settings
$this->config->save(self::ITEM_IP, filter_var($post->get('invalidateOnIPMismatch'), FILTER_VALIDATE_BOOLEAN));
$this->config->save(self::ITEM_USER_AGENT, filter_var($post->get('invalidateOnUserAgentMismatch'), FILTER_VALIDATE_BOOLEAN));
$this->config->save(self::ITEM_INVALIDATE_INACTIVE_USERS, filter_var($post->get('invalidateInactiveUsers'), FILTER_VALIDATE_BOOLEAN));
$this->config->save(self::ITEM_INVALIDATE_INACTIVE_USERS_TIME, filter_var($post->get('inactiveTime'), FILTER_VALIDATE_INT));
$this->flash('message', t('Successfully saved Session Security settings'));
// Redirect away from this save endpoint
return $this->factory->redirect($this->action());
} | php | public function save()
{
if (!$this->token->validate('save_automated_logout')) {
$this->error->add($this->token->getErrorMessage());
$this->flash('error', $this->error);
// Redirect away from this save endpoint
return $this->factory->redirect($this->action());
}
$post = $this->request->request;
// Save the posted settings
$this->config->save(self::ITEM_IP, filter_var($post->get('invalidateOnIPMismatch'), FILTER_VALIDATE_BOOLEAN));
$this->config->save(self::ITEM_USER_AGENT, filter_var($post->get('invalidateOnUserAgentMismatch'), FILTER_VALIDATE_BOOLEAN));
$this->config->save(self::ITEM_INVALIDATE_INACTIVE_USERS, filter_var($post->get('invalidateInactiveUsers'), FILTER_VALIDATE_BOOLEAN));
$this->config->save(self::ITEM_INVALIDATE_INACTIVE_USERS_TIME, filter_var($post->get('inactiveTime'), FILTER_VALIDATE_INT));
$this->flash('message', t('Successfully saved Session Security settings'));
// Redirect away from this save endpoint
return $this->factory->redirect($this->action());
} | [
"public",
"function",
"save",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"token",
"->",
"validate",
"(",
"'save_automated_logout'",
")",
")",
"{",
"$",
"this",
"->",
"error",
"->",
"add",
"(",
"$",
"this",
"->",
"token",
"->",
"getErrorMessage",
"(",
")",
")",
";",
"$",
"this",
"->",
"flash",
"(",
"'error'",
",",
"$",
"this",
"->",
"error",
")",
";",
"// Redirect away from this save endpoint",
"return",
"$",
"this",
"->",
"factory",
"->",
"redirect",
"(",
"$",
"this",
"->",
"action",
"(",
")",
")",
";",
"}",
"$",
"post",
"=",
"$",
"this",
"->",
"request",
"->",
"request",
";",
"// Save the posted settings",
"$",
"this",
"->",
"config",
"->",
"save",
"(",
"self",
"::",
"ITEM_IP",
",",
"filter_var",
"(",
"$",
"post",
"->",
"get",
"(",
"'invalidateOnIPMismatch'",
")",
",",
"FILTER_VALIDATE_BOOLEAN",
")",
")",
";",
"$",
"this",
"->",
"config",
"->",
"save",
"(",
"self",
"::",
"ITEM_USER_AGENT",
",",
"filter_var",
"(",
"$",
"post",
"->",
"get",
"(",
"'invalidateOnUserAgentMismatch'",
")",
",",
"FILTER_VALIDATE_BOOLEAN",
")",
")",
";",
"$",
"this",
"->",
"config",
"->",
"save",
"(",
"self",
"::",
"ITEM_INVALIDATE_INACTIVE_USERS",
",",
"filter_var",
"(",
"$",
"post",
"->",
"get",
"(",
"'invalidateInactiveUsers'",
")",
",",
"FILTER_VALIDATE_BOOLEAN",
")",
")",
";",
"$",
"this",
"->",
"config",
"->",
"save",
"(",
"self",
"::",
"ITEM_INVALIDATE_INACTIVE_USERS_TIME",
",",
"filter_var",
"(",
"$",
"post",
"->",
"get",
"(",
"'inactiveTime'",
")",
",",
"FILTER_VALIDATE_INT",
")",
")",
";",
"$",
"this",
"->",
"flash",
"(",
"'message'",
",",
"t",
"(",
"'Successfully saved Session Security settings'",
")",
")",
";",
"// Redirect away from this save endpoint",
"return",
"$",
"this",
"->",
"factory",
"->",
"redirect",
"(",
"$",
"this",
"->",
"action",
"(",
")",
")",
";",
"}"
] | An action for saving the Session Security form
This method will manage saving settings and redirecting to the appropriate results page
@return \Concrete\Core\Http\ResponseFactory|\Symfony\Component\HttpFoundation\Response | [
"An",
"action",
"for",
"saving",
"the",
"Session",
"Security",
"form",
"This",
"method",
"will",
"manage",
"saving",
"settings",
"and",
"redirecting",
"to",
"the",
"appropriate",
"results",
"page"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/controllers/single_page/dashboard/system/registration/automated_logout.php#L76-L98 | train |
concrete5/concrete5 | concrete/controllers/single_page/dashboard/system/registration/automated_logout.php | AutomatedLogout.invalidate_sessions | public function invalidate_sessions($token = '')
{
if (!$this->token->validate('invalidate_sessions', $token)) {
$this->error->add($this->token->getErrorMessage());
$this->flash('error', $this->error);
// Redirect away from this save endpoint
return $this->factory->redirect($this->action());
}
// Invalidate all sessions
$this->invalidateSessions();
// Set a message for the login page
$this->flash('error', t('All sessions have been invalidated. You must log back in to continue.'));
// Redirect to the login page
return $this->factory->redirect($this->urls->resolve(['/login']));
} | php | public function invalidate_sessions($token = '')
{
if (!$this->token->validate('invalidate_sessions', $token)) {
$this->error->add($this->token->getErrorMessage());
$this->flash('error', $this->error);
// Redirect away from this save endpoint
return $this->factory->redirect($this->action());
}
// Invalidate all sessions
$this->invalidateSessions();
// Set a message for the login page
$this->flash('error', t('All sessions have been invalidated. You must log back in to continue.'));
// Redirect to the login page
return $this->factory->redirect($this->urls->resolve(['/login']));
} | [
"public",
"function",
"invalidate_sessions",
"(",
"$",
"token",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"token",
"->",
"validate",
"(",
"'invalidate_sessions'",
",",
"$",
"token",
")",
")",
"{",
"$",
"this",
"->",
"error",
"->",
"add",
"(",
"$",
"this",
"->",
"token",
"->",
"getErrorMessage",
"(",
")",
")",
";",
"$",
"this",
"->",
"flash",
"(",
"'error'",
",",
"$",
"this",
"->",
"error",
")",
";",
"// Redirect away from this save endpoint",
"return",
"$",
"this",
"->",
"factory",
"->",
"redirect",
"(",
"$",
"this",
"->",
"action",
"(",
")",
")",
";",
"}",
"// Invalidate all sessions",
"$",
"this",
"->",
"invalidateSessions",
"(",
")",
";",
"// Set a message for the login page",
"$",
"this",
"->",
"flash",
"(",
"'error'",
",",
"t",
"(",
"'All sessions have been invalidated. You must log back in to continue.'",
")",
")",
";",
"// Redirect to the login page",
"return",
"$",
"this",
"->",
"factory",
"->",
"redirect",
"(",
"$",
"this",
"->",
"urls",
"->",
"resolve",
"(",
"[",
"'/login'",
"]",
")",
")",
";",
"}"
] | An action for invalidating all active sessions
@param string $token The CSRF token used to validate this request
@return \Concrete\Core\Http\Response|void | [
"An",
"action",
"for",
"invalidating",
"all",
"active",
"sessions"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/controllers/single_page/dashboard/system/registration/automated_logout.php#L107-L126 | train |
concrete5/concrete5 | concrete/controllers/single_page/dashboard/system/registration/automated_logout.php | AutomatedLogout.invalidateSessions | protected function invalidateSessions()
{
// Save the configuration that invalidates sessions
$this->config->save(self::ITEM_SESSION_INVALIDATE, Carbon::now('utc')->getTimestamp());
// Invalidate the current session explicitly so that we get back to the login page with a nice error message
$this->app->make('session')->invalidate();
} | php | protected function invalidateSessions()
{
// Save the configuration that invalidates sessions
$this->config->save(self::ITEM_SESSION_INVALIDATE, Carbon::now('utc')->getTimestamp());
// Invalidate the current session explicitly so that we get back to the login page with a nice error message
$this->app->make('session')->invalidate();
} | [
"protected",
"function",
"invalidateSessions",
"(",
")",
"{",
"// Save the configuration that invalidates sessions",
"$",
"this",
"->",
"config",
"->",
"save",
"(",
"self",
"::",
"ITEM_SESSION_INVALIDATE",
",",
"Carbon",
"::",
"now",
"(",
"'utc'",
")",
"->",
"getTimestamp",
"(",
")",
")",
";",
"// Invalidate the current session explicitly so that we get back to the login page with a nice error message",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'session'",
")",
"->",
"invalidate",
"(",
")",
";",
"}"
] | Invalidate all user sessions
@todo move this to a proper service class that manages common user functions
like registration `$user->registration->register()` and locating the logged in user `$user->loggedIn()->getID()` | [
"Invalidate",
"all",
"user",
"sessions"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/controllers/single_page/dashboard/system/registration/automated_logout.php#L134-L141 | train |
concrete5/concrete5 | concrete/src/Page/Collection/Version/GlobalVersionList.php | GlobalVersionList.filterByApprovedAfter | public function filterByApprovedAfter(\DateTime $date)
{
$this->query->andWhere(
'cv.cvDateApproved >= ' . $this->query->createNamedParameter($date->format('Y-m-d H:i-s'))
);
} | php | public function filterByApprovedAfter(\DateTime $date)
{
$this->query->andWhere(
'cv.cvDateApproved >= ' . $this->query->createNamedParameter($date->format('Y-m-d H:i-s'))
);
} | [
"public",
"function",
"filterByApprovedAfter",
"(",
"\\",
"DateTime",
"$",
"date",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"andWhere",
"(",
"'cv.cvDateApproved >= '",
".",
"$",
"this",
"->",
"query",
"->",
"createNamedParameter",
"(",
"$",
"date",
"->",
"format",
"(",
"'Y-m-d H:i-s'",
")",
")",
")",
";",
"}"
] | Filter versions that are approved after a certain date.
@param \DateTime $date | [
"Filter",
"versions",
"that",
"are",
"approved",
"after",
"a",
"certain",
"date",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Version/GlobalVersionList.php#L62-L67 | train |
concrete5/concrete5 | concrete/src/Page/Collection/Version/GlobalVersionList.php | GlobalVersionList.filterByApprovedBefore | public function filterByApprovedBefore(\DateTime $date)
{
$this->query->andWhere(
'cv.cvDateApproved <= ' . $this->query->createNamedParameter($date->format('Y-m-d H:i-s'))
);
} | php | public function filterByApprovedBefore(\DateTime $date)
{
$this->query->andWhere(
'cv.cvDateApproved <= ' . $this->query->createNamedParameter($date->format('Y-m-d H:i-s'))
);
} | [
"public",
"function",
"filterByApprovedBefore",
"(",
"\\",
"DateTime",
"$",
"date",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"andWhere",
"(",
"'cv.cvDateApproved <= '",
".",
"$",
"this",
"->",
"query",
"->",
"createNamedParameter",
"(",
"$",
"date",
"->",
"format",
"(",
"'Y-m-d H:i-s'",
")",
")",
")",
";",
"}"
] | Filter versions that are approved before a certain date.
@param \DateTime $date | [
"Filter",
"versions",
"that",
"are",
"approved",
"before",
"a",
"certain",
"date",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Version/GlobalVersionList.php#L74-L79 | train |
concrete5/concrete5 | concrete/src/File/StorageLocation/StorageLocationFactory.php | StorageLocationFactory.persist | public function persist(StorageLocationEntity $storageLocation)
{
return $this->entityManager->transactional(function (EntityManagerInterface $em) use ($storageLocation) {
if ($storageLocation->isDefault()) {
$qb = $em->createQueryBuilder()->update(StorageLocationEntity::class, 'l')->set('l.fslIsDefault', 0);
if ($storageLocation->getID()) {
$qb->andWhere('l.fslID <> :id')->setParameter('id', $storageLocation->getID());
}
$qb->getQuery()->execute();
}
$em->persist($storageLocation);
return $storageLocation;
});
} | php | public function persist(StorageLocationEntity $storageLocation)
{
return $this->entityManager->transactional(function (EntityManagerInterface $em) use ($storageLocation) {
if ($storageLocation->isDefault()) {
$qb = $em->createQueryBuilder()->update(StorageLocationEntity::class, 'l')->set('l.fslIsDefault', 0);
if ($storageLocation->getID()) {
$qb->andWhere('l.fslID <> :id')->setParameter('id', $storageLocation->getID());
}
$qb->getQuery()->execute();
}
$em->persist($storageLocation);
return $storageLocation;
});
} | [
"public",
"function",
"persist",
"(",
"StorageLocationEntity",
"$",
"storageLocation",
")",
"{",
"return",
"$",
"this",
"->",
"entityManager",
"->",
"transactional",
"(",
"function",
"(",
"EntityManagerInterface",
"$",
"em",
")",
"use",
"(",
"$",
"storageLocation",
")",
"{",
"if",
"(",
"$",
"storageLocation",
"->",
"isDefault",
"(",
")",
")",
"{",
"$",
"qb",
"=",
"$",
"em",
"->",
"createQueryBuilder",
"(",
")",
"->",
"update",
"(",
"StorageLocationEntity",
"::",
"class",
",",
"'l'",
")",
"->",
"set",
"(",
"'l.fslIsDefault'",
",",
"0",
")",
";",
"if",
"(",
"$",
"storageLocation",
"->",
"getID",
"(",
")",
")",
"{",
"$",
"qb",
"->",
"andWhere",
"(",
"'l.fslID <> :id'",
")",
"->",
"setParameter",
"(",
"'id'",
",",
"$",
"storageLocation",
"->",
"getID",
"(",
")",
")",
";",
"}",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"execute",
"(",
")",
";",
"}",
"$",
"em",
"->",
"persist",
"(",
"$",
"storageLocation",
")",
";",
"return",
"$",
"storageLocation",
";",
"}",
")",
";",
"}"
] | Store a created storage location to the database
@param StorageLocationEntity $storageLocation
@return StorageLocationEntity The persisted location, may not be the same as the passed in object | [
"Store",
"a",
"created",
"storage",
"location",
"to",
"the",
"database"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/File/StorageLocation/StorageLocationFactory.php#L46-L60 | train |
concrete5/concrete5 | concrete/src/User/UserServiceProvider.php | UserServiceProvider.bindContainer | protected function bindContainer(Application $app)
{
$this->app->when(PasswordUsageTracker::class)->needs('$maxReuse')->give(function () {
return $this->app['config']->get('concrete.user.password.reuse.track', 5);
});
$this->app->bindShared('user/registration', function () use ($app) {
return $app->make('Concrete\Core\User\RegistrationService');
});
$this->app->bindShared('user/avatar', function () use ($app) {
return $app->make('Concrete\Core\User\Avatar\AvatarService');
});
$this->app->bindShared('user/status', function () use ($app) {
return $app->make('Concrete\Core\User\StatusService');
});
$this->app->bind('Concrete\Core\User\RegistrationServiceInterface', function () use ($app) {
return $app->make('user/registration');
});
$this->app->bind('Concrete\Core\User\StatusServiceInterface', function () use ($app) {
return $app->make('user/status');
});
$this->app->bind('Concrete\Core\User\Avatar\AvatarServiceInterface', function () use ($app) {
return $app->make('user/avatar');
});
} | php | protected function bindContainer(Application $app)
{
$this->app->when(PasswordUsageTracker::class)->needs('$maxReuse')->give(function () {
return $this->app['config']->get('concrete.user.password.reuse.track', 5);
});
$this->app->bindShared('user/registration', function () use ($app) {
return $app->make('Concrete\Core\User\RegistrationService');
});
$this->app->bindShared('user/avatar', function () use ($app) {
return $app->make('Concrete\Core\User\Avatar\AvatarService');
});
$this->app->bindShared('user/status', function () use ($app) {
return $app->make('Concrete\Core\User\StatusService');
});
$this->app->bind('Concrete\Core\User\RegistrationServiceInterface', function () use ($app) {
return $app->make('user/registration');
});
$this->app->bind('Concrete\Core\User\StatusServiceInterface', function () use ($app) {
return $app->make('user/status');
});
$this->app->bind('Concrete\Core\User\Avatar\AvatarServiceInterface', function () use ($app) {
return $app->make('user/avatar');
});
} | [
"protected",
"function",
"bindContainer",
"(",
"Application",
"$",
"app",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"when",
"(",
"PasswordUsageTracker",
"::",
"class",
")",
"->",
"needs",
"(",
"'$maxReuse'",
")",
"->",
"give",
"(",
"function",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'concrete.user.password.reuse.track'",
",",
"5",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bindShared",
"(",
"'user/registration'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"app",
")",
"{",
"return",
"$",
"app",
"->",
"make",
"(",
"'Concrete\\Core\\User\\RegistrationService'",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bindShared",
"(",
"'user/avatar'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"app",
")",
"{",
"return",
"$",
"app",
"->",
"make",
"(",
"'Concrete\\Core\\User\\Avatar\\AvatarService'",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bindShared",
"(",
"'user/status'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"app",
")",
"{",
"return",
"$",
"app",
"->",
"make",
"(",
"'Concrete\\Core\\User\\StatusService'",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'Concrete\\Core\\User\\RegistrationServiceInterface'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"app",
")",
"{",
"return",
"$",
"app",
"->",
"make",
"(",
"'user/registration'",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'Concrete\\Core\\User\\StatusServiceInterface'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"app",
")",
"{",
"return",
"$",
"app",
"->",
"make",
"(",
"'user/status'",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'Concrete\\Core\\User\\Avatar\\AvatarServiceInterface'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"app",
")",
"{",
"return",
"$",
"app",
"->",
"make",
"(",
"'user/avatar'",
")",
";",
"}",
")",
";",
"}"
] | Bind things to the container
@param \Concrete\Core\Application\Application $app | [
"Bind",
"things",
"to",
"the",
"container"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/UserServiceProvider.php#L45-L69 | train |
concrete5/concrete5 | concrete/src/User/UserServiceProvider.php | UserServiceProvider.handleEvent | public function handleEvent(Event $event, UserNotificationEventHandler $service)
{
// If our event is the wrong type, just do a null/void return
if (!$event instanceof DeactivateUser) {
return;
}
$entity = $event->getUserEntity();
if ($entity) {
$service->deactivated($event);
}
} | php | public function handleEvent(Event $event, UserNotificationEventHandler $service)
{
// If our event is the wrong type, just do a null/void return
if (!$event instanceof DeactivateUser) {
return;
}
$entity = $event->getUserEntity();
if ($entity) {
$service->deactivated($event);
}
} | [
"public",
"function",
"handleEvent",
"(",
"Event",
"$",
"event",
",",
"UserNotificationEventHandler",
"$",
"service",
")",
"{",
"// If our event is the wrong type, just do a null/void return",
"if",
"(",
"!",
"$",
"event",
"instanceof",
"DeactivateUser",
")",
"{",
"return",
";",
"}",
"$",
"entity",
"=",
"$",
"event",
"->",
"getUserEntity",
"(",
")",
";",
"if",
"(",
"$",
"entity",
")",
"{",
"$",
"service",
"->",
"deactivated",
"(",
"$",
"event",
")",
";",
"}",
"}"
] | Handle routing bound events
@param \Symfony\Component\EventDispatcher\Event $event
@param \Concrete\Core\User\Notification\UserNotificationEventHandler $service
@internal | [
"Handle",
"routing",
"bound",
"events"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/UserServiceProvider.php#L96-L108 | train |
concrete5/concrete5 | concrete/src/Page/Theme/Theme.php | Theme.getAvailableThemes | public static function getAvailableThemes($filterInstalled = true)
{
$db = Loader::db();
$dh = Loader::helper('file');
$themes = $dh->getDirectoryContents(DIR_FILES_THEMES);
if ($filterInstalled) {
// strip out themes we've already installed
$handles = $db->GetCol('select pThemeHandle from PageThemes');
$themesTemp = [];
foreach ($themes as $t) {
if (!in_array($t, $handles)) {
$themesTemp[] = $t;
}
}
$themes = $themesTemp;
}
if (count($themes) > 0) {
$themesTemp = [];
// get theme objects from the file system
foreach ($themes as $t) {
$th = static::getByFileHandle($t);
if (!empty($th)) {
$themesTemp[] = $th;
}
}
$themes = $themesTemp;
}
return $themes;
} | php | public static function getAvailableThemes($filterInstalled = true)
{
$db = Loader::db();
$dh = Loader::helper('file');
$themes = $dh->getDirectoryContents(DIR_FILES_THEMES);
if ($filterInstalled) {
// strip out themes we've already installed
$handles = $db->GetCol('select pThemeHandle from PageThemes');
$themesTemp = [];
foreach ($themes as $t) {
if (!in_array($t, $handles)) {
$themesTemp[] = $t;
}
}
$themes = $themesTemp;
}
if (count($themes) > 0) {
$themesTemp = [];
// get theme objects from the file system
foreach ($themes as $t) {
$th = static::getByFileHandle($t);
if (!empty($th)) {
$themesTemp[] = $th;
}
}
$themes = $themesTemp;
}
return $themes;
} | [
"public",
"static",
"function",
"getAvailableThemes",
"(",
"$",
"filterInstalled",
"=",
"true",
")",
"{",
"$",
"db",
"=",
"Loader",
"::",
"db",
"(",
")",
";",
"$",
"dh",
"=",
"Loader",
"::",
"helper",
"(",
"'file'",
")",
";",
"$",
"themes",
"=",
"$",
"dh",
"->",
"getDirectoryContents",
"(",
"DIR_FILES_THEMES",
")",
";",
"if",
"(",
"$",
"filterInstalled",
")",
"{",
"// strip out themes we've already installed",
"$",
"handles",
"=",
"$",
"db",
"->",
"GetCol",
"(",
"'select pThemeHandle from PageThemes'",
")",
";",
"$",
"themesTemp",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"themes",
"as",
"$",
"t",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"t",
",",
"$",
"handles",
")",
")",
"{",
"$",
"themesTemp",
"[",
"]",
"=",
"$",
"t",
";",
"}",
"}",
"$",
"themes",
"=",
"$",
"themesTemp",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"themes",
")",
">",
"0",
")",
"{",
"$",
"themesTemp",
"=",
"[",
"]",
";",
"// get theme objects from the file system",
"foreach",
"(",
"$",
"themes",
"as",
"$",
"t",
")",
"{",
"$",
"th",
"=",
"static",
"::",
"getByFileHandle",
"(",
"$",
"t",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"th",
")",
")",
"{",
"$",
"themesTemp",
"[",
"]",
"=",
"$",
"th",
";",
"}",
"}",
"$",
"themes",
"=",
"$",
"themesTemp",
";",
"}",
"return",
"$",
"themes",
";",
"}"
] | scans the directory for available themes. For those who don't want to go through the hassle of uploading.
@param bool $filterInstalled
@return static[] | [
"scans",
"the",
"directory",
"for",
"available",
"themes",
".",
"For",
"those",
"who",
"don",
"t",
"want",
"to",
"go",
"through",
"the",
"hassle",
"of",
"uploading",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Theme/Theme.php#L108-L139 | train |
concrete5/concrete5 | concrete/src/Page/Theme/Theme.php | Theme.getThemeCustomizableStyleList | public function getThemeCustomizableStyleList()
{
if (!isset($this->styleList)) {
$env = Environment::get();
$r = $env->getRecord(
DIRNAME_THEMES.'/'.$this->getThemeHandle(
).'/'.DIRNAME_CSS.'/'.FILENAME_STYLE_CUSTOMIZER_STYLES,
$this->getPackageHandle()
);
$this->styleList = \Concrete\Core\StyleCustomizer\StyleList::loadFromXMLFile($r->file);
}
return $this->styleList;
} | php | public function getThemeCustomizableStyleList()
{
if (!isset($this->styleList)) {
$env = Environment::get();
$r = $env->getRecord(
DIRNAME_THEMES.'/'.$this->getThemeHandle(
).'/'.DIRNAME_CSS.'/'.FILENAME_STYLE_CUSTOMIZER_STYLES,
$this->getPackageHandle()
);
$this->styleList = \Concrete\Core\StyleCustomizer\StyleList::loadFromXMLFile($r->file);
}
return $this->styleList;
} | [
"public",
"function",
"getThemeCustomizableStyleList",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"styleList",
")",
")",
"{",
"$",
"env",
"=",
"Environment",
"::",
"get",
"(",
")",
";",
"$",
"r",
"=",
"$",
"env",
"->",
"getRecord",
"(",
"DIRNAME_THEMES",
".",
"'/'",
".",
"$",
"this",
"->",
"getThemeHandle",
"(",
")",
".",
"'/'",
".",
"DIRNAME_CSS",
".",
"'/'",
".",
"FILENAME_STYLE_CUSTOMIZER_STYLES",
",",
"$",
"this",
"->",
"getPackageHandle",
"(",
")",
")",
";",
"$",
"this",
"->",
"styleList",
"=",
"\\",
"Concrete",
"\\",
"Core",
"\\",
"StyleCustomizer",
"\\",
"StyleList",
"::",
"loadFromXMLFile",
"(",
"$",
"r",
"->",
"file",
")",
";",
"}",
"return",
"$",
"this",
"->",
"styleList",
";",
"}"
] | Gets the style list object for this theme.
@return \Concrete\Core\StyleCustomizer\StyleList | [
"Gets",
"the",
"style",
"list",
"object",
"for",
"this",
"theme",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Theme/Theme.php#L186-L199 | train |
concrete5/concrete5 | concrete/src/Page/Theme/Theme.php | Theme.getThemeCustomizablePreset | public function getThemeCustomizablePreset($handle)
{
$env = Environment::get();
if ($this->isThemeCustomizable()) {
$file = $env->getRecord(
DIRNAME_THEMES.'/'.$this->getThemeHandle(
).'/'.DIRNAME_CSS.'/'.DIRNAME_STYLE_CUSTOMIZER_PRESETS.'/'.$handle.static::THEME_CUSTOMIZABLE_STYLESHEET_EXTENSION,
$this->getPackageHandle()
);
if ($file->exists()) {
$urlroot = $env->getURL(
DIRNAME_THEMES.'/'.$this->getThemeHandle().'/'.DIRNAME_CSS,
$this->getPackageHandle()
);
$preset = Preset::getFromFile($file->file, $urlroot);
return $preset;
}
}
} | php | public function getThemeCustomizablePreset($handle)
{
$env = Environment::get();
if ($this->isThemeCustomizable()) {
$file = $env->getRecord(
DIRNAME_THEMES.'/'.$this->getThemeHandle(
).'/'.DIRNAME_CSS.'/'.DIRNAME_STYLE_CUSTOMIZER_PRESETS.'/'.$handle.static::THEME_CUSTOMIZABLE_STYLESHEET_EXTENSION,
$this->getPackageHandle()
);
if ($file->exists()) {
$urlroot = $env->getURL(
DIRNAME_THEMES.'/'.$this->getThemeHandle().'/'.DIRNAME_CSS,
$this->getPackageHandle()
);
$preset = Preset::getFromFile($file->file, $urlroot);
return $preset;
}
}
} | [
"public",
"function",
"getThemeCustomizablePreset",
"(",
"$",
"handle",
")",
"{",
"$",
"env",
"=",
"Environment",
"::",
"get",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isThemeCustomizable",
"(",
")",
")",
"{",
"$",
"file",
"=",
"$",
"env",
"->",
"getRecord",
"(",
"DIRNAME_THEMES",
".",
"'/'",
".",
"$",
"this",
"->",
"getThemeHandle",
"(",
")",
".",
"'/'",
".",
"DIRNAME_CSS",
".",
"'/'",
".",
"DIRNAME_STYLE_CUSTOMIZER_PRESETS",
".",
"'/'",
".",
"$",
"handle",
".",
"static",
"::",
"THEME_CUSTOMIZABLE_STYLESHEET_EXTENSION",
",",
"$",
"this",
"->",
"getPackageHandle",
"(",
")",
")",
";",
"if",
"(",
"$",
"file",
"->",
"exists",
"(",
")",
")",
"{",
"$",
"urlroot",
"=",
"$",
"env",
"->",
"getURL",
"(",
"DIRNAME_THEMES",
".",
"'/'",
".",
"$",
"this",
"->",
"getThemeHandle",
"(",
")",
".",
"'/'",
".",
"DIRNAME_CSS",
",",
"$",
"this",
"->",
"getPackageHandle",
"(",
")",
")",
";",
"$",
"preset",
"=",
"Preset",
"::",
"getFromFile",
"(",
"$",
"file",
"->",
"file",
",",
"$",
"urlroot",
")",
";",
"return",
"$",
"preset",
";",
"}",
"}",
"}"
] | Gets a preset for this theme by handle. | [
"Gets",
"a",
"preset",
"for",
"this",
"theme",
"by",
"handle",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Theme/Theme.php#L204-L223 | train |
concrete5/concrete5 | concrete/src/Page/Theme/Theme.php | Theme.getThemeCustomizableStylePresets | public function getThemeCustomizableStylePresets()
{
$presets = [];
$env = Environment::get();
if ($this->isThemeCustomizable()) {
$directory = $env->getPath(
DIRNAME_THEMES.'/'.$this->getThemeHandle(
).'/'.DIRNAME_CSS.'/'.DIRNAME_STYLE_CUSTOMIZER_PRESETS,
$this->getPackageHandle()
);
$urlroot = $env->getURL(
DIRNAME_THEMES.'/'.$this->getThemeHandle().'/'.DIRNAME_CSS,
$this->getPackageHandle()
);
$dh = Loader::helper('file');
$files = $dh->getDirectoryContents($directory);
foreach ($files as $f) {
if (strrchr($f, '.') == static::THEME_CUSTOMIZABLE_STYLESHEET_EXTENSION) {
$preset = Preset::getFromFile($directory.'/'.$f, $urlroot);
if (is_object($preset)) {
$presets[] = $preset;
}
}
}
}
usort(
$presets,
function ($a, $b) {
if ($a->isDefaultPreset()) {
return -1;
} else {
return strcasecmp($a->getPresetDisplayName('text'), $b->getPresetDisplayName('text'));
}
}
);
return $presets;
} | php | public function getThemeCustomizableStylePresets()
{
$presets = [];
$env = Environment::get();
if ($this->isThemeCustomizable()) {
$directory = $env->getPath(
DIRNAME_THEMES.'/'.$this->getThemeHandle(
).'/'.DIRNAME_CSS.'/'.DIRNAME_STYLE_CUSTOMIZER_PRESETS,
$this->getPackageHandle()
);
$urlroot = $env->getURL(
DIRNAME_THEMES.'/'.$this->getThemeHandle().'/'.DIRNAME_CSS,
$this->getPackageHandle()
);
$dh = Loader::helper('file');
$files = $dh->getDirectoryContents($directory);
foreach ($files as $f) {
if (strrchr($f, '.') == static::THEME_CUSTOMIZABLE_STYLESHEET_EXTENSION) {
$preset = Preset::getFromFile($directory.'/'.$f, $urlroot);
if (is_object($preset)) {
$presets[] = $preset;
}
}
}
}
usort(
$presets,
function ($a, $b) {
if ($a->isDefaultPreset()) {
return -1;
} else {
return strcasecmp($a->getPresetDisplayName('text'), $b->getPresetDisplayName('text'));
}
}
);
return $presets;
} | [
"public",
"function",
"getThemeCustomizableStylePresets",
"(",
")",
"{",
"$",
"presets",
"=",
"[",
"]",
";",
"$",
"env",
"=",
"Environment",
"::",
"get",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isThemeCustomizable",
"(",
")",
")",
"{",
"$",
"directory",
"=",
"$",
"env",
"->",
"getPath",
"(",
"DIRNAME_THEMES",
".",
"'/'",
".",
"$",
"this",
"->",
"getThemeHandle",
"(",
")",
".",
"'/'",
".",
"DIRNAME_CSS",
".",
"'/'",
".",
"DIRNAME_STYLE_CUSTOMIZER_PRESETS",
",",
"$",
"this",
"->",
"getPackageHandle",
"(",
")",
")",
";",
"$",
"urlroot",
"=",
"$",
"env",
"->",
"getURL",
"(",
"DIRNAME_THEMES",
".",
"'/'",
".",
"$",
"this",
"->",
"getThemeHandle",
"(",
")",
".",
"'/'",
".",
"DIRNAME_CSS",
",",
"$",
"this",
"->",
"getPackageHandle",
"(",
")",
")",
";",
"$",
"dh",
"=",
"Loader",
"::",
"helper",
"(",
"'file'",
")",
";",
"$",
"files",
"=",
"$",
"dh",
"->",
"getDirectoryContents",
"(",
"$",
"directory",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"f",
")",
"{",
"if",
"(",
"strrchr",
"(",
"$",
"f",
",",
"'.'",
")",
"==",
"static",
"::",
"THEME_CUSTOMIZABLE_STYLESHEET_EXTENSION",
")",
"{",
"$",
"preset",
"=",
"Preset",
"::",
"getFromFile",
"(",
"$",
"directory",
".",
"'/'",
".",
"$",
"f",
",",
"$",
"urlroot",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"preset",
")",
")",
"{",
"$",
"presets",
"[",
"]",
"=",
"$",
"preset",
";",
"}",
"}",
"}",
"}",
"usort",
"(",
"$",
"presets",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"if",
"(",
"$",
"a",
"->",
"isDefaultPreset",
"(",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"else",
"{",
"return",
"strcasecmp",
"(",
"$",
"a",
"->",
"getPresetDisplayName",
"(",
"'text'",
")",
",",
"$",
"b",
"->",
"getPresetDisplayName",
"(",
"'text'",
")",
")",
";",
"}",
"}",
")",
";",
"return",
"$",
"presets",
";",
"}"
] | Gets all presets available to this theme. | [
"Gets",
"all",
"presets",
"available",
"to",
"this",
"theme",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Theme/Theme.php#L228-L265 | train |
concrete5/concrete5 | concrete/src/Page/Theme/Theme.php | Theme.getStylesheet | public function getStylesheet($stylesheet)
{
$stylesheet = $this->getStylesheetObject($stylesheet);
$styleValues = $this->getThemeCustomStyleObjectValues();
if (!is_null($styleValues)) {
$stylesheet->setValueList($styleValues);
}
if (!$this->isThemePreviewRequest()) {
if (!$stylesheet->outputFileExists() || !Config::get('concrete.cache.theme_css')) {
$stylesheet->output();
}
}
$path = $stylesheet->getOutputRelativePath();
if ($this->isThemePreviewRequest()) {
$path .= '?ts='.time();
} else {
$path .= '?ts='.filemtime($stylesheet->getOutputPath());
}
return $path;
} | php | public function getStylesheet($stylesheet)
{
$stylesheet = $this->getStylesheetObject($stylesheet);
$styleValues = $this->getThemeCustomStyleObjectValues();
if (!is_null($styleValues)) {
$stylesheet->setValueList($styleValues);
}
if (!$this->isThemePreviewRequest()) {
if (!$stylesheet->outputFileExists() || !Config::get('concrete.cache.theme_css')) {
$stylesheet->output();
}
}
$path = $stylesheet->getOutputRelativePath();
if ($this->isThemePreviewRequest()) {
$path .= '?ts='.time();
} else {
$path .= '?ts='.filemtime($stylesheet->getOutputPath());
}
return $path;
} | [
"public",
"function",
"getStylesheet",
"(",
"$",
"stylesheet",
")",
"{",
"$",
"stylesheet",
"=",
"$",
"this",
"->",
"getStylesheetObject",
"(",
"$",
"stylesheet",
")",
";",
"$",
"styleValues",
"=",
"$",
"this",
"->",
"getThemeCustomStyleObjectValues",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"styleValues",
")",
")",
"{",
"$",
"stylesheet",
"->",
"setValueList",
"(",
"$",
"styleValues",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isThemePreviewRequest",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"stylesheet",
"->",
"outputFileExists",
"(",
")",
"||",
"!",
"Config",
"::",
"get",
"(",
"'concrete.cache.theme_css'",
")",
")",
"{",
"$",
"stylesheet",
"->",
"output",
"(",
")",
";",
"}",
"}",
"$",
"path",
"=",
"$",
"stylesheet",
"->",
"getOutputRelativePath",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isThemePreviewRequest",
"(",
")",
")",
"{",
"$",
"path",
".=",
"'?ts='",
".",
"time",
"(",
")",
";",
"}",
"else",
"{",
"$",
"path",
".=",
"'?ts='",
".",
"filemtime",
"(",
"$",
"stylesheet",
"->",
"getOutputPath",
"(",
")",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] | Looks into the current CSS directory and returns a fully compiled stylesheet
when passed a LESS stylesheet. Also serves up custom value list values for the stylesheet if they exist.
@param string $stylesheet The LESS stylesheet to compile
@return string The path to the stylesheet | [
"Looks",
"into",
"the",
"current",
"CSS",
"directory",
"and",
"returns",
"a",
"fully",
"compiled",
"stylesheet",
"when",
"passed",
"a",
"LESS",
"stylesheet",
".",
"Also",
"serves",
"up",
"custom",
"value",
"list",
"values",
"for",
"the",
"stylesheet",
"if",
"they",
"exist",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Theme/Theme.php#L333-L353 | train |
concrete5/concrete5 | concrete/src/Page/Theme/Theme.php | Theme.getThemeCustomStyleObject | public function getThemeCustomStyleObject()
{
$db = Loader::db();
$row = $db->FetchAssoc('select * from PageThemeCustomStyles where pThemeID = ?', [$this->getThemeID()]);
if (isset($row['pThemeID'])) {
$o = new \Concrete\Core\Page\CustomStyle();
$o->setThemeID($this->getThemeID());
$o->setValueListID($row['scvlID']);
$o->setPresetHandle($row['preset']);
$o->setCustomCssRecordID($row['sccRecordID']);
return $o;
}
} | php | public function getThemeCustomStyleObject()
{
$db = Loader::db();
$row = $db->FetchAssoc('select * from PageThemeCustomStyles where pThemeID = ?', [$this->getThemeID()]);
if (isset($row['pThemeID'])) {
$o = new \Concrete\Core\Page\CustomStyle();
$o->setThemeID($this->getThemeID());
$o->setValueListID($row['scvlID']);
$o->setPresetHandle($row['preset']);
$o->setCustomCssRecordID($row['sccRecordID']);
return $o;
}
} | [
"public",
"function",
"getThemeCustomStyleObject",
"(",
")",
"{",
"$",
"db",
"=",
"Loader",
"::",
"db",
"(",
")",
";",
"$",
"row",
"=",
"$",
"db",
"->",
"FetchAssoc",
"(",
"'select * from PageThemeCustomStyles where pThemeID = ?'",
",",
"[",
"$",
"this",
"->",
"getThemeID",
"(",
")",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"row",
"[",
"'pThemeID'",
"]",
")",
")",
"{",
"$",
"o",
"=",
"new",
"\\",
"Concrete",
"\\",
"Core",
"\\",
"Page",
"\\",
"CustomStyle",
"(",
")",
";",
"$",
"o",
"->",
"setThemeID",
"(",
"$",
"this",
"->",
"getThemeID",
"(",
")",
")",
";",
"$",
"o",
"->",
"setValueListID",
"(",
"$",
"row",
"[",
"'scvlID'",
"]",
")",
";",
"$",
"o",
"->",
"setPresetHandle",
"(",
"$",
"row",
"[",
"'preset'",
"]",
")",
";",
"$",
"o",
"->",
"setCustomCssRecordID",
"(",
"$",
"row",
"[",
"'sccRecordID'",
"]",
")",
";",
"return",
"$",
"o",
";",
"}",
"}"
] | Returns a Custom Style Object for the theme if one exists. | [
"Returns",
"a",
"Custom",
"Style",
"Object",
"for",
"the",
"theme",
"if",
"one",
"exists",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Theme/Theme.php#L358-L371 | train |
concrete5/concrete5 | concrete/src/Page/Theme/Theme.php | Theme.getFilesInTheme | public function getFilesInTheme()
{
$dh = Loader::helper('file');
$templateList = PageTemplate::getList();
$pts = [];
foreach ($templateList as $pt) {
$pts[] = $pt->getPageTemplateHandle();
}
$files = [];
$filesTmp = $dh->getDirectoryContents($this->pThemeDirectory);
foreach ($filesTmp as $f) {
if (strrchr($f, '.') == static::THEME_EXTENSION) {
$fHandle = substr($f, 0, strpos($f, '.'));
if ($f == FILENAME_THEMES_VIEW) {
$type = PageThemeFile::TFTYPE_VIEW;
} elseif ($f == FILENAME_THEMES_CLASS) {
$type = PageThemeFile::TFTYPE_PAGE_CLASS;
} else {
if ($f == FILENAME_THEMES_DEFAULT) {
$type = PageThemeFile::TFTYPE_DEFAULT;
} else {
if (in_array($f, SinglePage::getThemeableCorePages())) {
$type = PageThemeFile::TFTYPE_SINGLE_PAGE;
} else {
if (in_array($fHandle, $pts)) {
$type = PageThemeFile::TFTYPE_PAGE_TEMPLATE_EXISTING;
} else {
$type = PageThemeFile::TFTYPE_PAGE_TEMPLATE_NEW;
}
}
}
}
$pf = new PageThemeFile();
$pf->setFilename($f);
$pf->setType($type);
$files[] = $pf;
}
}
return $files;
} | php | public function getFilesInTheme()
{
$dh = Loader::helper('file');
$templateList = PageTemplate::getList();
$pts = [];
foreach ($templateList as $pt) {
$pts[] = $pt->getPageTemplateHandle();
}
$files = [];
$filesTmp = $dh->getDirectoryContents($this->pThemeDirectory);
foreach ($filesTmp as $f) {
if (strrchr($f, '.') == static::THEME_EXTENSION) {
$fHandle = substr($f, 0, strpos($f, '.'));
if ($f == FILENAME_THEMES_VIEW) {
$type = PageThemeFile::TFTYPE_VIEW;
} elseif ($f == FILENAME_THEMES_CLASS) {
$type = PageThemeFile::TFTYPE_PAGE_CLASS;
} else {
if ($f == FILENAME_THEMES_DEFAULT) {
$type = PageThemeFile::TFTYPE_DEFAULT;
} else {
if (in_array($f, SinglePage::getThemeableCorePages())) {
$type = PageThemeFile::TFTYPE_SINGLE_PAGE;
} else {
if (in_array($fHandle, $pts)) {
$type = PageThemeFile::TFTYPE_PAGE_TEMPLATE_EXISTING;
} else {
$type = PageThemeFile::TFTYPE_PAGE_TEMPLATE_NEW;
}
}
}
}
$pf = new PageThemeFile();
$pf->setFilename($f);
$pf->setType($type);
$files[] = $pf;
}
}
return $files;
} | [
"public",
"function",
"getFilesInTheme",
"(",
")",
"{",
"$",
"dh",
"=",
"Loader",
"::",
"helper",
"(",
"'file'",
")",
";",
"$",
"templateList",
"=",
"PageTemplate",
"::",
"getList",
"(",
")",
";",
"$",
"pts",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"templateList",
"as",
"$",
"pt",
")",
"{",
"$",
"pts",
"[",
"]",
"=",
"$",
"pt",
"->",
"getPageTemplateHandle",
"(",
")",
";",
"}",
"$",
"files",
"=",
"[",
"]",
";",
"$",
"filesTmp",
"=",
"$",
"dh",
"->",
"getDirectoryContents",
"(",
"$",
"this",
"->",
"pThemeDirectory",
")",
";",
"foreach",
"(",
"$",
"filesTmp",
"as",
"$",
"f",
")",
"{",
"if",
"(",
"strrchr",
"(",
"$",
"f",
",",
"'.'",
")",
"==",
"static",
"::",
"THEME_EXTENSION",
")",
"{",
"$",
"fHandle",
"=",
"substr",
"(",
"$",
"f",
",",
"0",
",",
"strpos",
"(",
"$",
"f",
",",
"'.'",
")",
")",
";",
"if",
"(",
"$",
"f",
"==",
"FILENAME_THEMES_VIEW",
")",
"{",
"$",
"type",
"=",
"PageThemeFile",
"::",
"TFTYPE_VIEW",
";",
"}",
"elseif",
"(",
"$",
"f",
"==",
"FILENAME_THEMES_CLASS",
")",
"{",
"$",
"type",
"=",
"PageThemeFile",
"::",
"TFTYPE_PAGE_CLASS",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"f",
"==",
"FILENAME_THEMES_DEFAULT",
")",
"{",
"$",
"type",
"=",
"PageThemeFile",
"::",
"TFTYPE_DEFAULT",
";",
"}",
"else",
"{",
"if",
"(",
"in_array",
"(",
"$",
"f",
",",
"SinglePage",
"::",
"getThemeableCorePages",
"(",
")",
")",
")",
"{",
"$",
"type",
"=",
"PageThemeFile",
"::",
"TFTYPE_SINGLE_PAGE",
";",
"}",
"else",
"{",
"if",
"(",
"in_array",
"(",
"$",
"fHandle",
",",
"$",
"pts",
")",
")",
"{",
"$",
"type",
"=",
"PageThemeFile",
"::",
"TFTYPE_PAGE_TEMPLATE_EXISTING",
";",
"}",
"else",
"{",
"$",
"type",
"=",
"PageThemeFile",
"::",
"TFTYPE_PAGE_TEMPLATE_NEW",
";",
"}",
"}",
"}",
"}",
"$",
"pf",
"=",
"new",
"PageThemeFile",
"(",
")",
";",
"$",
"pf",
"->",
"setFilename",
"(",
"$",
"f",
")",
";",
"$",
"pf",
"->",
"setType",
"(",
"$",
"type",
")",
";",
"$",
"files",
"[",
"]",
"=",
"$",
"pf",
";",
"}",
"}",
"return",
"$",
"files",
";",
"}"
] | lists them out, by type, allowing people to install them as page type, etc... | [
"lists",
"them",
"out",
"by",
"type",
"allowing",
"people",
"to",
"install",
"them",
"as",
"page",
"type",
"etc",
"..."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Theme/Theme.php#L521-L563 | train |
concrete5/concrete5 | concrete/src/Utility/Service/Identifier.php | Identifier.generate | public function generate($table, $key, $length = 12, $lowercase = false)
{
$foundHash = false;
$db = Application::make(Connection::class);
while ($foundHash == false) {
$string = $this->getString($length);
if ($lowercase) {
$string = strtolower($string);
}
$cnt = $db->GetOne("select count(" . $key . ") as total from " . $table . " where " . $key . " = ?",
array($string));
if ($cnt < 1) {
$foundHash = true;
}
}
return $string;
} | php | public function generate($table, $key, $length = 12, $lowercase = false)
{
$foundHash = false;
$db = Application::make(Connection::class);
while ($foundHash == false) {
$string = $this->getString($length);
if ($lowercase) {
$string = strtolower($string);
}
$cnt = $db->GetOne("select count(" . $key . ") as total from " . $table . " where " . $key . " = ?",
array($string));
if ($cnt < 1) {
$foundHash = true;
}
}
return $string;
} | [
"public",
"function",
"generate",
"(",
"$",
"table",
",",
"$",
"key",
",",
"$",
"length",
"=",
"12",
",",
"$",
"lowercase",
"=",
"false",
")",
"{",
"$",
"foundHash",
"=",
"false",
";",
"$",
"db",
"=",
"Application",
"::",
"make",
"(",
"Connection",
"::",
"class",
")",
";",
"while",
"(",
"$",
"foundHash",
"==",
"false",
")",
"{",
"$",
"string",
"=",
"$",
"this",
"->",
"getString",
"(",
"$",
"length",
")",
";",
"if",
"(",
"$",
"lowercase",
")",
"{",
"$",
"string",
"=",
"strtolower",
"(",
"$",
"string",
")",
";",
"}",
"$",
"cnt",
"=",
"$",
"db",
"->",
"GetOne",
"(",
"\"select count(\"",
".",
"$",
"key",
".",
"\") as total from \"",
".",
"$",
"table",
".",
"\" where \"",
".",
"$",
"key",
".",
"\" = ?\"",
",",
"array",
"(",
"$",
"string",
")",
")",
";",
"if",
"(",
"$",
"cnt",
"<",
"1",
")",
"{",
"$",
"foundHash",
"=",
"true",
";",
"}",
"}",
"return",
"$",
"string",
";",
"}"
] | Generates a unique identifier for an item in a database table. Used, among other places, in generating
User hashes for email validation.
@param string $table
@param string $key
@param int $length
@param bool $lowercase
@return string | [
"Generates",
"a",
"unique",
"identifier",
"for",
"an",
"item",
"in",
"a",
"database",
"table",
".",
"Used",
"among",
"other",
"places",
"in",
"generating",
"User",
"hashes",
"for",
"email",
"validation",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Utility/Service/Identifier.php#L68-L85 | train |
concrete5/concrete5 | concrete/src/Utility/Service/Identifier.php | Identifier.getString | public function getString($length = 12)
{
$size = ceil($length / 2);
try {
if (function_exists('random_bytes')) {
$bytes = random_bytes($size);
} else {
$hash = new PasswordHash(8, false);
$bytes = $hash->get_random_bytes($size);
}
} catch (\Exception $e) {
die('Could not generate a random string.');
}
return substr(bin2hex($bytes), 0, $length);
} | php | public function getString($length = 12)
{
$size = ceil($length / 2);
try {
if (function_exists('random_bytes')) {
$bytes = random_bytes($size);
} else {
$hash = new PasswordHash(8, false);
$bytes = $hash->get_random_bytes($size);
}
} catch (\Exception $e) {
die('Could not generate a random string.');
}
return substr(bin2hex($bytes), 0, $length);
} | [
"public",
"function",
"getString",
"(",
"$",
"length",
"=",
"12",
")",
"{",
"$",
"size",
"=",
"ceil",
"(",
"$",
"length",
"/",
"2",
")",
";",
"try",
"{",
"if",
"(",
"function_exists",
"(",
"'random_bytes'",
")",
")",
"{",
"$",
"bytes",
"=",
"random_bytes",
"(",
"$",
"size",
")",
";",
"}",
"else",
"{",
"$",
"hash",
"=",
"new",
"PasswordHash",
"(",
"8",
",",
"false",
")",
";",
"$",
"bytes",
"=",
"$",
"hash",
"->",
"get_random_bytes",
"(",
"$",
"size",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"die",
"(",
"'Could not generate a random string.'",
")",
";",
"}",
"return",
"substr",
"(",
"bin2hex",
"(",
"$",
"bytes",
")",
",",
"0",
",",
"$",
"length",
")",
";",
"}"
] | Generate a cryptographically secure random string
@param int $length
@return string | [
"Generate",
"a",
"cryptographically",
"secure",
"random",
"string"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Utility/Service/Identifier.php#L92-L108 | train |
concrete5/concrete5 | concrete/src/Encryption/EncryptionService.php | EncryptionService.decrypt | public static function decrypt($text)
{
if (function_exists('mcrypt_decrypt')) {
$iv_size = mcrypt_get_iv_size(MCRYPT_XTEA, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$len = mcrypt_get_key_size(MCRYPT_XTEA, MCRYPT_MODE_ECB);
/** @var \Concrete\Core\Config\Repository\Repository $config */
$config = \Core::make('config/database');
$text = trim(mcrypt_decrypt(MCRYPT_XTEA, substr($config->get('concrete.security.token.encryption'), 0, $len), base64_decode($text), MCRYPT_MODE_ECB, $iv));
}
return $text;
} | php | public static function decrypt($text)
{
if (function_exists('mcrypt_decrypt')) {
$iv_size = mcrypt_get_iv_size(MCRYPT_XTEA, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$len = mcrypt_get_key_size(MCRYPT_XTEA, MCRYPT_MODE_ECB);
/** @var \Concrete\Core\Config\Repository\Repository $config */
$config = \Core::make('config/database');
$text = trim(mcrypt_decrypt(MCRYPT_XTEA, substr($config->get('concrete.security.token.encryption'), 0, $len), base64_decode($text), MCRYPT_MODE_ECB, $iv));
}
return $text;
} | [
"public",
"static",
"function",
"decrypt",
"(",
"$",
"text",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'mcrypt_decrypt'",
")",
")",
"{",
"$",
"iv_size",
"=",
"mcrypt_get_iv_size",
"(",
"MCRYPT_XTEA",
",",
"MCRYPT_MODE_ECB",
")",
";",
"$",
"iv",
"=",
"mcrypt_create_iv",
"(",
"$",
"iv_size",
",",
"MCRYPT_RAND",
")",
";",
"$",
"len",
"=",
"mcrypt_get_key_size",
"(",
"MCRYPT_XTEA",
",",
"MCRYPT_MODE_ECB",
")",
";",
"/** @var \\Concrete\\Core\\Config\\Repository\\Repository $config */",
"$",
"config",
"=",
"\\",
"Core",
"::",
"make",
"(",
"'config/database'",
")",
";",
"$",
"text",
"=",
"trim",
"(",
"mcrypt_decrypt",
"(",
"MCRYPT_XTEA",
",",
"substr",
"(",
"$",
"config",
"->",
"get",
"(",
"'concrete.security.token.encryption'",
")",
",",
"0",
",",
"$",
"len",
")",
",",
"base64_decode",
"(",
"$",
"text",
")",
",",
"MCRYPT_MODE_ECB",
",",
"$",
"iv",
")",
")",
";",
"}",
"return",
"$",
"text",
";",
"}"
] | Takes encrypted text and decrypts it.
@param string $text
@return string $text | [
"Takes",
"encrypted",
"text",
"and",
"decrypts",
"it",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Encryption/EncryptionService.php#L15-L28 | train |
concrete5/concrete5 | concrete/src/Encryption/EncryptionService.php | EncryptionService.encrypt | public static function encrypt($text)
{
if (function_exists('mcrypt_encrypt')) {
$iv_size = mcrypt_get_iv_size(MCRYPT_XTEA, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$len = mcrypt_get_key_size(MCRYPT_XTEA, MCRYPT_MODE_ECB);
/** @var \Concrete\Core\Config\Repository\Repository $config */
$config = \Core::make('config/database');
$text = base64_encode(mcrypt_encrypt(MCRYPT_XTEA, substr($config->get('concrete.security.token.encryption'), 0, $len), $text, MCRYPT_MODE_ECB, $iv));
}
return $text;
} | php | public static function encrypt($text)
{
if (function_exists('mcrypt_encrypt')) {
$iv_size = mcrypt_get_iv_size(MCRYPT_XTEA, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$len = mcrypt_get_key_size(MCRYPT_XTEA, MCRYPT_MODE_ECB);
/** @var \Concrete\Core\Config\Repository\Repository $config */
$config = \Core::make('config/database');
$text = base64_encode(mcrypt_encrypt(MCRYPT_XTEA, substr($config->get('concrete.security.token.encryption'), 0, $len), $text, MCRYPT_MODE_ECB, $iv));
}
return $text;
} | [
"public",
"static",
"function",
"encrypt",
"(",
"$",
"text",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'mcrypt_encrypt'",
")",
")",
"{",
"$",
"iv_size",
"=",
"mcrypt_get_iv_size",
"(",
"MCRYPT_XTEA",
",",
"MCRYPT_MODE_ECB",
")",
";",
"$",
"iv",
"=",
"mcrypt_create_iv",
"(",
"$",
"iv_size",
",",
"MCRYPT_RAND",
")",
";",
"$",
"len",
"=",
"mcrypt_get_key_size",
"(",
"MCRYPT_XTEA",
",",
"MCRYPT_MODE_ECB",
")",
";",
"/** @var \\Concrete\\Core\\Config\\Repository\\Repository $config */",
"$",
"config",
"=",
"\\",
"Core",
"::",
"make",
"(",
"'config/database'",
")",
";",
"$",
"text",
"=",
"base64_encode",
"(",
"mcrypt_encrypt",
"(",
"MCRYPT_XTEA",
",",
"substr",
"(",
"$",
"config",
"->",
"get",
"(",
"'concrete.security.token.encryption'",
")",
",",
"0",
",",
"$",
"len",
")",
",",
"$",
"text",
",",
"MCRYPT_MODE_ECB",
",",
"$",
"iv",
")",
")",
";",
"}",
"return",
"$",
"text",
";",
"}"
] | Takes un-encrypted text and encrypts it.
@param string $text
@return string $text | [
"Takes",
"un",
"-",
"encrypted",
"text",
"and",
"encrypts",
"it",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Encryption/EncryptionService.php#L37-L50 | train |
concrete5/concrete5 | concrete/src/User/Password/PasswordUsageTracker.php | PasswordUsageTracker.trackUse | public function trackUse($string, $subject)
{
$id = $this->resolveUserID($subject);
// If the subject is invalid return false
if (!$id) {
return false;
}
if (!is_string($string)) {
throw new \InvalidArgumentException(t('Invalid mixed value provided. Must be a string.'));
}
if ($this->maxReuse) {
// Store the use in the database
$this->entityManager->transactional(function (EntityManagerInterface $em) use ($id, $string) {
$reuse = new UsedString();
$reuse->setDate(Carbon::now());
$reuse->setSubject($id);
$reuse->setUsedString(password_hash($string, PASSWORD_DEFAULT));
$em->persist($reuse);
});
}
// Prune extra tracked uses
$this->pruneUses($id);
return true;
} | php | public function trackUse($string, $subject)
{
$id = $this->resolveUserID($subject);
// If the subject is invalid return false
if (!$id) {
return false;
}
if (!is_string($string)) {
throw new \InvalidArgumentException(t('Invalid mixed value provided. Must be a string.'));
}
if ($this->maxReuse) {
// Store the use in the database
$this->entityManager->transactional(function (EntityManagerInterface $em) use ($id, $string) {
$reuse = new UsedString();
$reuse->setDate(Carbon::now());
$reuse->setSubject($id);
$reuse->setUsedString(password_hash($string, PASSWORD_DEFAULT));
$em->persist($reuse);
});
}
// Prune extra tracked uses
$this->pruneUses($id);
return true;
} | [
"public",
"function",
"trackUse",
"(",
"$",
"string",
",",
"$",
"subject",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"resolveUserID",
"(",
"$",
"subject",
")",
";",
"// If the subject is invalid return false",
"if",
"(",
"!",
"$",
"id",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"string",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"t",
"(",
"'Invalid mixed value provided. Must be a string.'",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"maxReuse",
")",
"{",
"// Store the use in the database",
"$",
"this",
"->",
"entityManager",
"->",
"transactional",
"(",
"function",
"(",
"EntityManagerInterface",
"$",
"em",
")",
"use",
"(",
"$",
"id",
",",
"$",
"string",
")",
"{",
"$",
"reuse",
"=",
"new",
"UsedString",
"(",
")",
";",
"$",
"reuse",
"->",
"setDate",
"(",
"Carbon",
"::",
"now",
"(",
")",
")",
";",
"$",
"reuse",
"->",
"setSubject",
"(",
"$",
"id",
")",
";",
"$",
"reuse",
"->",
"setUsedString",
"(",
"password_hash",
"(",
"$",
"string",
",",
"PASSWORD_DEFAULT",
")",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"reuse",
")",
";",
"}",
")",
";",
"}",
"// Prune extra tracked uses",
"$",
"this",
"->",
"pruneUses",
"(",
"$",
"id",
")",
";",
"return",
"true",
";",
"}"
] | Track a string being used
@param string $string The password that was used
@param int|\Concrete\Core\User\User|\Concrete\Core\User\UserInfo|\Concrete\Core\Entity\User\User $subject The subject that used the password
@return bool | [
"Track",
"a",
"string",
"being",
"used"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/Password/PasswordUsageTracker.php#L43-L72 | train |
concrete5/concrete5 | concrete/src/User/Password/PasswordUsageTracker.php | PasswordUsageTracker.pruneUses | private function pruneUses($subject)
{
$repository = $this->entityManager->getRepository(UsedString::class);
$usedStrings = $repository->findBy(['subject' => $subject], ['id' => 'desc']);
// IF there are extra used strings, prune the extras
if (count($usedStrings) > $this->maxReuse) {
array_map([$this->entityManager, 'remove'], array_slice($usedStrings, $this->maxReuse));
$this->entityManager->flush();
}
} | php | private function pruneUses($subject)
{
$repository = $this->entityManager->getRepository(UsedString::class);
$usedStrings = $repository->findBy(['subject' => $subject], ['id' => 'desc']);
// IF there are extra used strings, prune the extras
if (count($usedStrings) > $this->maxReuse) {
array_map([$this->entityManager, 'remove'], array_slice($usedStrings, $this->maxReuse));
$this->entityManager->flush();
}
} | [
"private",
"function",
"pruneUses",
"(",
"$",
"subject",
")",
"{",
"$",
"repository",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getRepository",
"(",
"UsedString",
"::",
"class",
")",
";",
"$",
"usedStrings",
"=",
"$",
"repository",
"->",
"findBy",
"(",
"[",
"'subject'",
"=>",
"$",
"subject",
"]",
",",
"[",
"'id'",
"=>",
"'desc'",
"]",
")",
";",
"// IF there are extra used strings, prune the extras",
"if",
"(",
"count",
"(",
"$",
"usedStrings",
")",
">",
"$",
"this",
"->",
"maxReuse",
")",
"{",
"array_map",
"(",
"[",
"$",
"this",
"->",
"entityManager",
",",
"'remove'",
"]",
",",
"array_slice",
"(",
"$",
"usedStrings",
",",
"$",
"this",
"->",
"maxReuse",
")",
")",
";",
"$",
"this",
"->",
"entityManager",
"->",
"flush",
"(",
")",
";",
"}",
"}"
] | Prune uses for a specific subject
@param int $subject | [
"Prune",
"uses",
"for",
"a",
"specific",
"subject"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/Password/PasswordUsageTracker.php#L79-L89 | train |
concrete5/concrete5 | concrete/src/Legacy/Avatar.php | Avatar.getImagePath | public function getImagePath($uo, $withNoCacheStr = true)
{
if (!$uo->hasAvatar()) {
return false;
}
$avatar = $uo->getUserAvatar();
return $avatar->getPath();
} | php | public function getImagePath($uo, $withNoCacheStr = true)
{
if (!$uo->hasAvatar()) {
return false;
}
$avatar = $uo->getUserAvatar();
return $avatar->getPath();
} | [
"public",
"function",
"getImagePath",
"(",
"$",
"uo",
",",
"$",
"withNoCacheStr",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"uo",
"->",
"hasAvatar",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"avatar",
"=",
"$",
"uo",
"->",
"getUserAvatar",
"(",
")",
";",
"return",
"$",
"avatar",
"->",
"getPath",
"(",
")",
";",
"}"
] | gets the image path for a users avatar.
@param \UserInfo $uo
@param bool $withNoCacheStr
@return bool|string $src | [
"gets",
"the",
"image",
"path",
"for",
"a",
"users",
"avatar",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Legacy/Avatar.php#L43-L52 | train |
concrete5/concrete5 | concrete/jobs/index_search.php | IndexSearch.pagesToQueue | protected function pagesToQueue()
{
$qb = $this->connection->createQueryBuilder();
$timeout = intval($this->app['config']->get('concrete.misc.page_search_index_lifetime'));
// Find all pages that need indexing
$query = $qb
->select('p.cID')
->from('Pages', 'p')
->leftJoin('p', 'CollectionSearchIndexAttributes', 'a', 'p.cID = a.cID')
->leftJoin('p', 'Collections', 'c', 'p.cID = c.cID')
->leftJoin('p', 'PageSearchIndex', 's', 'p.cID = s.cID')
->where('cIsActive = 1')
->andWhere($qb->expr()->orX(
'a.ak_exclude_search_index is null',
'a.ak_exclude_search_index = 0'
))
->andWhere($qb->expr()->orX(
'cDateModified > s.cDateLastIndexed',
"(UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(s.cDateLastIndexed) > {$timeout})",
's.cID is null',
's.cDateLastIndexed is null'
))->execute();
while ($id = $query->fetchColumn()) {
yield $id;
}
} | php | protected function pagesToQueue()
{
$qb = $this->connection->createQueryBuilder();
$timeout = intval($this->app['config']->get('concrete.misc.page_search_index_lifetime'));
// Find all pages that need indexing
$query = $qb
->select('p.cID')
->from('Pages', 'p')
->leftJoin('p', 'CollectionSearchIndexAttributes', 'a', 'p.cID = a.cID')
->leftJoin('p', 'Collections', 'c', 'p.cID = c.cID')
->leftJoin('p', 'PageSearchIndex', 's', 'p.cID = s.cID')
->where('cIsActive = 1')
->andWhere($qb->expr()->orX(
'a.ak_exclude_search_index is null',
'a.ak_exclude_search_index = 0'
))
->andWhere($qb->expr()->orX(
'cDateModified > s.cDateLastIndexed',
"(UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(s.cDateLastIndexed) > {$timeout})",
's.cID is null',
's.cDateLastIndexed is null'
))->execute();
while ($id = $query->fetchColumn()) {
yield $id;
}
} | [
"protected",
"function",
"pagesToQueue",
"(",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"timeout",
"=",
"intval",
"(",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'concrete.misc.page_search_index_lifetime'",
")",
")",
";",
"// Find all pages that need indexing",
"$",
"query",
"=",
"$",
"qb",
"->",
"select",
"(",
"'p.cID'",
")",
"->",
"from",
"(",
"'Pages'",
",",
"'p'",
")",
"->",
"leftJoin",
"(",
"'p'",
",",
"'CollectionSearchIndexAttributes'",
",",
"'a'",
",",
"'p.cID = a.cID'",
")",
"->",
"leftJoin",
"(",
"'p'",
",",
"'Collections'",
",",
"'c'",
",",
"'p.cID = c.cID'",
")",
"->",
"leftJoin",
"(",
"'p'",
",",
"'PageSearchIndex'",
",",
"'s'",
",",
"'p.cID = s.cID'",
")",
"->",
"where",
"(",
"'cIsActive = 1'",
")",
"->",
"andWhere",
"(",
"$",
"qb",
"->",
"expr",
"(",
")",
"->",
"orX",
"(",
"'a.ak_exclude_search_index is null'",
",",
"'a.ak_exclude_search_index = 0'",
")",
")",
"->",
"andWhere",
"(",
"$",
"qb",
"->",
"expr",
"(",
")",
"->",
"orX",
"(",
"'cDateModified > s.cDateLastIndexed'",
",",
"\"(UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(s.cDateLastIndexed) > {$timeout})\"",
",",
"'s.cID is null'",
",",
"'s.cDateLastIndexed is null'",
")",
")",
"->",
"execute",
"(",
")",
";",
"while",
"(",
"$",
"id",
"=",
"$",
"query",
"->",
"fetchColumn",
"(",
")",
")",
"{",
"yield",
"$",
"id",
";",
"}",
"}"
] | Get Pages to add to the queue
@return \Iterator | [
"Get",
"Pages",
"to",
"add",
"to",
"the",
"queue"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/jobs/index_search.php#L86-L113 | train |
concrete5/concrete5 | concrete/src/Cache/CacheLocal.php | CacheLocal.key | public static function key($group, $id)
{
if (!empty($id)) {
return trim($group, '/') . '/' . trim($id, '/');
} else {
return trim($group, '/');
}
} | php | public static function key($group, $id)
{
if (!empty($id)) {
return trim($group, '/') . '/' . trim($id, '/');
} else {
return trim($group, '/');
}
} | [
"public",
"static",
"function",
"key",
"(",
"$",
"group",
",",
"$",
"id",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"id",
")",
")",
"{",
"return",
"trim",
"(",
"$",
"group",
",",
"'/'",
")",
".",
"'/'",
".",
"trim",
"(",
"$",
"id",
",",
"'/'",
")",
";",
"}",
"else",
"{",
"return",
"trim",
"(",
"$",
"group",
",",
"'/'",
")",
";",
"}",
"}"
] | Creates a cache key based on the group and id by running it through md5.
@param string $group Name of the cache group
@param string $id Name of the cache item ID
@return string The cache key | [
"Creates",
"a",
"cache",
"key",
"based",
"on",
"the",
"group",
"and",
"id",
"by",
"running",
"it",
"through",
"md5",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Cache/CacheLocal.php#L21-L28 | train |
concrete5/concrete5 | concrete/src/Session/Storage/LoggedStorage.php | LoggedStorage.log | protected function log($level, $message, array $context = [])
{
if ($this->logger) {
$metadata = $this->getMetadataBag();
$context['metadata'] = [
'created' => $metadata->getCreated(),
'lifetime' => $metadata->getLifetime(),
'lastused' => $metadata->getLastUsed(),
'name' => $metadata->getName(),
];
if ($this->isStarted()) {
$attributes = $this->getBag('attributes');
if ($attributes instanceof SessionBagProxy) {
$attributes = $attributes->getBag();
}
if ($attributes instanceof AttributeBagInterface) {
$context['metadata']['uID'] = $attributes->get('uID', null);
$context['metadata']['uGroups'] = array_values($attributes->get('uGroups', []));
}
}
$this->logger->log($level, $message, $context);
}
} | php | protected function log($level, $message, array $context = [])
{
if ($this->logger) {
$metadata = $this->getMetadataBag();
$context['metadata'] = [
'created' => $metadata->getCreated(),
'lifetime' => $metadata->getLifetime(),
'lastused' => $metadata->getLastUsed(),
'name' => $metadata->getName(),
];
if ($this->isStarted()) {
$attributes = $this->getBag('attributes');
if ($attributes instanceof SessionBagProxy) {
$attributes = $attributes->getBag();
}
if ($attributes instanceof AttributeBagInterface) {
$context['metadata']['uID'] = $attributes->get('uID', null);
$context['metadata']['uGroups'] = array_values($attributes->get('uGroups', []));
}
}
$this->logger->log($level, $message, $context);
}
} | [
"protected",
"function",
"log",
"(",
"$",
"level",
",",
"$",
"message",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"metadata",
"=",
"$",
"this",
"->",
"getMetadataBag",
"(",
")",
";",
"$",
"context",
"[",
"'metadata'",
"]",
"=",
"[",
"'created'",
"=>",
"$",
"metadata",
"->",
"getCreated",
"(",
")",
",",
"'lifetime'",
"=>",
"$",
"metadata",
"->",
"getLifetime",
"(",
")",
",",
"'lastused'",
"=>",
"$",
"metadata",
"->",
"getLastUsed",
"(",
")",
",",
"'name'",
"=>",
"$",
"metadata",
"->",
"getName",
"(",
")",
",",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"isStarted",
"(",
")",
")",
"{",
"$",
"attributes",
"=",
"$",
"this",
"->",
"getBag",
"(",
"'attributes'",
")",
";",
"if",
"(",
"$",
"attributes",
"instanceof",
"SessionBagProxy",
")",
"{",
"$",
"attributes",
"=",
"$",
"attributes",
"->",
"getBag",
"(",
")",
";",
"}",
"if",
"(",
"$",
"attributes",
"instanceof",
"AttributeBagInterface",
")",
"{",
"$",
"context",
"[",
"'metadata'",
"]",
"[",
"'uID'",
"]",
"=",
"$",
"attributes",
"->",
"get",
"(",
"'uID'",
",",
"null",
")",
";",
"$",
"context",
"[",
"'metadata'",
"]",
"[",
"'uGroups'",
"]",
"=",
"array_values",
"(",
"$",
"attributes",
"->",
"get",
"(",
"'uGroups'",
",",
"[",
"]",
")",
")",
";",
"}",
"}",
"$",
"this",
"->",
"logger",
"->",
"log",
"(",
"$",
"level",
",",
"$",
"message",
",",
"$",
"context",
")",
";",
"}",
"}"
] | Log details if possible
@param $message
@param array $context | [
"Log",
"details",
"if",
"possible"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Session/Storage/LoggedStorage.php#L48-L75 | train |
concrete5/concrete5 | concrete/src/Session/Storage/LoggedStorage.php | LoggedStorage.clear | public function clear()
{
$this->logInfo('Clearing Session.');
$metadata = $this->getMetadataBag();
$lifetime = $metadata->getLifetime();
$lastUsed = $metadata->getLastUsed();
// If the existing session has expired on its own
if ($lifetime && time() > $lastUsed + $lifetime) {
$this->logInfo('Session expired.');
}
return $this->wrappedStorage->clear();
} | php | public function clear()
{
$this->logInfo('Clearing Session.');
$metadata = $this->getMetadataBag();
$lifetime = $metadata->getLifetime();
$lastUsed = $metadata->getLastUsed();
// If the existing session has expired on its own
if ($lifetime && time() > $lastUsed + $lifetime) {
$this->logInfo('Session expired.');
}
return $this->wrappedStorage->clear();
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"$",
"this",
"->",
"logInfo",
"(",
"'Clearing Session.'",
")",
";",
"$",
"metadata",
"=",
"$",
"this",
"->",
"getMetadataBag",
"(",
")",
";",
"$",
"lifetime",
"=",
"$",
"metadata",
"->",
"getLifetime",
"(",
")",
";",
"$",
"lastUsed",
"=",
"$",
"metadata",
"->",
"getLastUsed",
"(",
")",
";",
"// If the existing session has expired on its own",
"if",
"(",
"$",
"lifetime",
"&&",
"time",
"(",
")",
">",
"$",
"lastUsed",
"+",
"$",
"lifetime",
")",
"{",
"$",
"this",
"->",
"logInfo",
"(",
"'Session expired.'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"wrappedStorage",
"->",
"clear",
"(",
")",
";",
"}"
] | Clear all session data in memory. | [
"Clear",
"all",
"session",
"data",
"in",
"memory",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Session/Storage/LoggedStorage.php#L221-L235 | train |
concrete5/concrete5 | concrete/src/Geolocator/GeolocatorController.php | GeolocatorController.getFileRecord | protected function getFileRecord($file)
{
$result = null;
$segment = implode('/', [DIRNAME_GEOLOCATION, $this->geolocator->getGeolocatorHandle(), $file]);
$fileLocator = $this->app->make(FileLocator::class);
/* @var FileLocator $fileLocator */
$package = $this->geolocator->getGeolocatorPackage();
if ($package !== null) {
$fileLocator->addPackageLocation($package->getPackageHandle());
}
return $fileLocator->getRecord($segment);
} | php | protected function getFileRecord($file)
{
$result = null;
$segment = implode('/', [DIRNAME_GEOLOCATION, $this->geolocator->getGeolocatorHandle(), $file]);
$fileLocator = $this->app->make(FileLocator::class);
/* @var FileLocator $fileLocator */
$package = $this->geolocator->getGeolocatorPackage();
if ($package !== null) {
$fileLocator->addPackageLocation($package->getPackageHandle());
}
return $fileLocator->getRecord($segment);
} | [
"protected",
"function",
"getFileRecord",
"(",
"$",
"file",
")",
"{",
"$",
"result",
"=",
"null",
";",
"$",
"segment",
"=",
"implode",
"(",
"'/'",
",",
"[",
"DIRNAME_GEOLOCATION",
",",
"$",
"this",
"->",
"geolocator",
"->",
"getGeolocatorHandle",
"(",
")",
",",
"$",
"file",
"]",
")",
";",
"$",
"fileLocator",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"FileLocator",
"::",
"class",
")",
";",
"/* @var FileLocator $fileLocator */",
"$",
"package",
"=",
"$",
"this",
"->",
"geolocator",
"->",
"getGeolocatorPackage",
"(",
")",
";",
"if",
"(",
"$",
"package",
"!==",
"null",
")",
"{",
"$",
"fileLocator",
"->",
"addPackageLocation",
"(",
"$",
"package",
"->",
"getPackageHandle",
"(",
")",
")",
";",
"}",
"return",
"$",
"fileLocator",
"->",
"getRecord",
"(",
"$",
"segment",
")",
";",
"}"
] | Get the path to a geolocator file.
@param Geolocator $geolocator
@param string $file
@return \Concrete\Core\Filesystem\FileLocator\Record | [
"Get",
"the",
"path",
"to",
"a",
"geolocator",
"file",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Geolocator/GeolocatorController.php#L39-L51 | train |
concrete5/concrete5 | concrete/src/Cache/CacheClearer.php | CacheClearer.getCaches | protected function getCaches()
{
foreach ($this->caches as $key => $cache) {
if (!$cache instanceof FlushableInterface) {
$cache = $this->application->make($cache);
}
if ($cache instanceof FlushableInterface) {
yield $key => $cache;
}
}
} | php | protected function getCaches()
{
foreach ($this->caches as $key => $cache) {
if (!$cache instanceof FlushableInterface) {
$cache = $this->application->make($cache);
}
if ($cache instanceof FlushableInterface) {
yield $key => $cache;
}
}
} | [
"protected",
"function",
"getCaches",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"caches",
"as",
"$",
"key",
"=>",
"$",
"cache",
")",
"{",
"if",
"(",
"!",
"$",
"cache",
"instanceof",
"FlushableInterface",
")",
"{",
"$",
"cache",
"=",
"$",
"this",
"->",
"application",
"->",
"make",
"(",
"$",
"cache",
")",
";",
"}",
"if",
"(",
"$",
"cache",
"instanceof",
"FlushableInterface",
")",
"{",
"yield",
"$",
"key",
"=>",
"$",
"cache",
";",
"}",
"}",
"}"
] | A generator that populates the cache objects from the container
@return \Generator|FlushableInterface[] | [
"A",
"generator",
"that",
"populates",
"the",
"cache",
"objects",
"from",
"the",
"container"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Cache/CacheClearer.php#L129-L140 | train |
concrete5/concrete5 | concrete/src/Cache/CacheClearer.php | CacheClearer.clearCacheDirectory | protected function clearCacheDirectory($directory)
{
foreach ($this->filesToClear($directory) as $file) {
if ($file->isDir()) {
$this->filesystem->deleteDirectory($file->getPathname());
} else {
$this->filesystem->delete($file->getPathname());
}
}
} | php | protected function clearCacheDirectory($directory)
{
foreach ($this->filesToClear($directory) as $file) {
if ($file->isDir()) {
$this->filesystem->deleteDirectory($file->getPathname());
} else {
$this->filesystem->delete($file->getPathname());
}
}
} | [
"protected",
"function",
"clearCacheDirectory",
"(",
"$",
"directory",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"filesToClear",
"(",
"$",
"directory",
")",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"file",
"->",
"isDir",
"(",
")",
")",
"{",
"$",
"this",
"->",
"filesystem",
"->",
"deleteDirectory",
"(",
"$",
"file",
"->",
"getPathname",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"filesystem",
"->",
"delete",
"(",
"$",
"file",
"->",
"getPathname",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Clear out items from the cache directory
@param $directory | [
"Clear",
"out",
"items",
"from",
"the",
"cache",
"directory"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Cache/CacheClearer.php#L156-L165 | train |
concrete5/concrete5 | concrete/blocks/page_attribute_display/controller.php | Controller.getPlaceHolderText | public function getPlaceHolderText($handle)
{
$pageValues = $this->getAvailablePageValues();
if (in_array($handle, array_keys($pageValues))) {
$placeHolder = $pageValues[$handle];
} else {
$attributeKey = CollectionAttributeKey::getByHandle($handle);
if (is_object($attributeKey)) {
$placeHolder = $attributeKey->getAttributeKeyName();
}
}
return "[" . $placeHolder . "]";
} | php | public function getPlaceHolderText($handle)
{
$pageValues = $this->getAvailablePageValues();
if (in_array($handle, array_keys($pageValues))) {
$placeHolder = $pageValues[$handle];
} else {
$attributeKey = CollectionAttributeKey::getByHandle($handle);
if (is_object($attributeKey)) {
$placeHolder = $attributeKey->getAttributeKeyName();
}
}
return "[" . $placeHolder . "]";
} | [
"public",
"function",
"getPlaceHolderText",
"(",
"$",
"handle",
")",
"{",
"$",
"pageValues",
"=",
"$",
"this",
"->",
"getAvailablePageValues",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"handle",
",",
"array_keys",
"(",
"$",
"pageValues",
")",
")",
")",
"{",
"$",
"placeHolder",
"=",
"$",
"pageValues",
"[",
"$",
"handle",
"]",
";",
"}",
"else",
"{",
"$",
"attributeKey",
"=",
"CollectionAttributeKey",
"::",
"getByHandle",
"(",
"$",
"handle",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"attributeKey",
")",
")",
"{",
"$",
"placeHolder",
"=",
"$",
"attributeKey",
"->",
"getAttributeKeyName",
"(",
")",
";",
"}",
"}",
"return",
"\"[\"",
".",
"$",
"placeHolder",
".",
"\"]\"",
";",
"}"
] | Returns a place holder for pages that are new or when editing default page types.
@param string $handle
@return string | [
"Returns",
"a",
"place",
"holder",
"for",
"pages",
"that",
"are",
"new",
"or",
"when",
"editing",
"default",
"page",
"types",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/blocks/page_attribute_display/controller.php#L154-L167 | train |
concrete5/concrete5 | concrete/src/Utility/Service/Validation/Strings.php | Strings.alphanum | public function alphanum($value, $allowSpaces = false, $allowDashes = false)
{
$allowedCharsRegex = 'A-Za-z0-9';
if ($allowSpaces) {
$allowedCharsRegex .= ' ';
}
if ($allowDashes) {
$allowedCharsRegex .= '\-';
}
return $this->notempty($value) && !preg_match('/[^' . $allowedCharsRegex . ']/', $value);
} | php | public function alphanum($value, $allowSpaces = false, $allowDashes = false)
{
$allowedCharsRegex = 'A-Za-z0-9';
if ($allowSpaces) {
$allowedCharsRegex .= ' ';
}
if ($allowDashes) {
$allowedCharsRegex .= '\-';
}
return $this->notempty($value) && !preg_match('/[^' . $allowedCharsRegex . ']/', $value);
} | [
"public",
"function",
"alphanum",
"(",
"$",
"value",
",",
"$",
"allowSpaces",
"=",
"false",
",",
"$",
"allowDashes",
"=",
"false",
")",
"{",
"$",
"allowedCharsRegex",
"=",
"'A-Za-z0-9'",
";",
"if",
"(",
"$",
"allowSpaces",
")",
"{",
"$",
"allowedCharsRegex",
".=",
"' '",
";",
"}",
"if",
"(",
"$",
"allowDashes",
")",
"{",
"$",
"allowedCharsRegex",
".=",
"'\\-'",
";",
"}",
"return",
"$",
"this",
"->",
"notempty",
"(",
"$",
"value",
")",
"&&",
"!",
"preg_match",
"(",
"'/[^'",
".",
"$",
"allowedCharsRegex",
".",
"']/'",
",",
"$",
"value",
")",
";",
"}"
] | Returns true on whether the passed string is completely alpha-numeric, if the value is not a string or is an
empty string false will be returned.
@param string $value
@param bool $allowSpaces whether or not spaces are permitted in the field contents
@param bool $allowDashes whether or not dashes (-) are permitted in the field contents
@return bool | [
"Returns",
"true",
"on",
"whether",
"the",
"passed",
"string",
"is",
"completely",
"alpha",
"-",
"numeric",
"if",
"the",
"value",
"is",
"not",
"a",
"string",
"or",
"is",
"an",
"empty",
"string",
"false",
"will",
"be",
"returned",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Utility/Service/Validation/Strings.php#L49-L60 | train |
concrete5/concrete5 | concrete/src/Utility/Service/Validation/Strings.php | Strings.min | public function min($str, $length)
{
return $this->notempty($str) && strlen(trim($str)) >= $length;
} | php | public function min($str, $length)
{
return $this->notempty($str) && strlen(trim($str)) >= $length;
} | [
"public",
"function",
"min",
"(",
"$",
"str",
",",
"$",
"length",
")",
"{",
"return",
"$",
"this",
"->",
"notempty",
"(",
"$",
"str",
")",
"&&",
"strlen",
"(",
"trim",
"(",
"$",
"str",
")",
")",
">=",
"$",
"length",
";",
"}"
] | Returns true on whether the passed string is larger or equal to the passed length.
@param string $str
@param int $length
@return bool | [
"Returns",
"true",
"on",
"whether",
"the",
"passed",
"string",
"is",
"larger",
"or",
"equal",
"to",
"the",
"passed",
"length",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Utility/Service/Validation/Strings.php#L94-L97 | train |
concrete5/concrete5 | concrete/src/Utility/Service/Validation/Strings.php | Strings.max | public function max($str, $length)
{
return $this->notempty($str) && strlen(trim($str)) <= $length;
} | php | public function max($str, $length)
{
return $this->notempty($str) && strlen(trim($str)) <= $length;
} | [
"public",
"function",
"max",
"(",
"$",
"str",
",",
"$",
"length",
")",
"{",
"return",
"$",
"this",
"->",
"notempty",
"(",
"$",
"str",
")",
"&&",
"strlen",
"(",
"trim",
"(",
"$",
"str",
")",
")",
"<=",
"$",
"length",
";",
"}"
] | Returns true on whether the passed is smaller or equal to the passed length.
@param string $str
@param int $length
@return bool | [
"Returns",
"true",
"on",
"whether",
"the",
"passed",
"is",
"smaller",
"or",
"equal",
"to",
"the",
"passed",
"length",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Utility/Service/Validation/Strings.php#L107-L110 | train |
concrete5/concrete5 | concrete/src/Package/Dependency/DependencyChecker.php | DependencyChecker.setInstalledPackages | public function setInstalledPackages(array $installedPackages)
{
$dictionary = [];
foreach ($installedPackages as $installedPackage) {
$dictionary[$installedPackage->getPackageHandle()] = $installedPackage;
}
$this->installedPackages = $dictionary;
return $this;
} | php | public function setInstalledPackages(array $installedPackages)
{
$dictionary = [];
foreach ($installedPackages as $installedPackage) {
$dictionary[$installedPackage->getPackageHandle()] = $installedPackage;
}
$this->installedPackages = $dictionary;
return $this;
} | [
"public",
"function",
"setInstalledPackages",
"(",
"array",
"$",
"installedPackages",
")",
"{",
"$",
"dictionary",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"installedPackages",
"as",
"$",
"installedPackage",
")",
"{",
"$",
"dictionary",
"[",
"$",
"installedPackage",
"->",
"getPackageHandle",
"(",
")",
"]",
"=",
"$",
"installedPackage",
";",
"}",
"$",
"this",
"->",
"installedPackages",
"=",
"$",
"dictionary",
";",
"return",
"$",
"this",
";",
"}"
] | Set the list of installed packages.
@param Package[] $installedPackages
@return $this | [
"Set",
"the",
"list",
"of",
"installed",
"packages",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Package/Dependency/DependencyChecker.php#L38-L47 | train |
concrete5/concrete5 | concrete/src/Package/Dependency/DependencyChecker.php | DependencyChecker.getInstalledPackages | protected function getInstalledPackages()
{
if ($this->installedPackages === null) {
$installedPackages = [];
$packageService = $this->application->make(PackageService::class);
foreach ($packageService->getInstalledHandles() as $packageHandle) {
$installedPackages[$packageHandle] = $packageService->getClass($packageHandle);
}
$this->installedPackages = $installedPackages;
}
return $this->installedPackages;
} | php | protected function getInstalledPackages()
{
if ($this->installedPackages === null) {
$installedPackages = [];
$packageService = $this->application->make(PackageService::class);
foreach ($packageService->getInstalledHandles() as $packageHandle) {
$installedPackages[$packageHandle] = $packageService->getClass($packageHandle);
}
$this->installedPackages = $installedPackages;
}
return $this->installedPackages;
} | [
"protected",
"function",
"getInstalledPackages",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"installedPackages",
"===",
"null",
")",
"{",
"$",
"installedPackages",
"=",
"[",
"]",
";",
"$",
"packageService",
"=",
"$",
"this",
"->",
"application",
"->",
"make",
"(",
"PackageService",
"::",
"class",
")",
";",
"foreach",
"(",
"$",
"packageService",
"->",
"getInstalledHandles",
"(",
")",
"as",
"$",
"packageHandle",
")",
"{",
"$",
"installedPackages",
"[",
"$",
"packageHandle",
"]",
"=",
"$",
"packageService",
"->",
"getClass",
"(",
"$",
"packageHandle",
")",
";",
"}",
"$",
"this",
"->",
"installedPackages",
"=",
"$",
"installedPackages",
";",
"}",
"return",
"$",
"this",
"->",
"installedPackages",
";",
"}"
] | Get the list of installed packages.
@return Package[] keys are package handles, values are Package instances | [
"Get",
"the",
"list",
"of",
"installed",
"packages",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Package/Dependency/DependencyChecker.php#L107-L119 | train |
concrete5/concrete5 | concrete/src/Package/Dependency/DependencyChecker.php | DependencyChecker.getPackageRequirementsForPackage | protected function getPackageRequirementsForPackage(Package $package, Package $otherPackage)
{
$dependencies = $package->getPackageDependencies();
$otherPackageHandle = $otherPackage->getPackageHandle();
return isset($dependencies[$otherPackageHandle]) ? $dependencies[$otherPackageHandle] : null;
} | php | protected function getPackageRequirementsForPackage(Package $package, Package $otherPackage)
{
$dependencies = $package->getPackageDependencies();
$otherPackageHandle = $otherPackage->getPackageHandle();
return isset($dependencies[$otherPackageHandle]) ? $dependencies[$otherPackageHandle] : null;
} | [
"protected",
"function",
"getPackageRequirementsForPackage",
"(",
"Package",
"$",
"package",
",",
"Package",
"$",
"otherPackage",
")",
"{",
"$",
"dependencies",
"=",
"$",
"package",
"->",
"getPackageDependencies",
"(",
")",
";",
"$",
"otherPackageHandle",
"=",
"$",
"otherPackage",
"->",
"getPackageHandle",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"dependencies",
"[",
"$",
"otherPackageHandle",
"]",
")",
"?",
"$",
"dependencies",
"[",
"$",
"otherPackageHandle",
"]",
":",
"null",
";",
"}"
] | Get the requirements for a package in respect to another package.
@param Package $package
@param Package $otherPackage
@return string[]|string|bool|null | [
"Get",
"the",
"requirements",
"for",
"a",
"package",
"in",
"respect",
"to",
"another",
"package",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Package/Dependency/DependencyChecker.php#L129-L135 | train |
concrete5/concrete5 | concrete/src/Area/Layout/ThemeGridColumn.php | ThemeGridColumn.getAreaLayoutColumnOffsetEditClass | public function getAreaLayoutColumnOffsetEditClass()
{
/*
* @var ThemeGridLayout $this->arLayout
*/
$gf = $this->arLayout->getThemeGridFrameworkObject();
if (is_object($gf)) {
$class = $gf->getPageThemeGridFrameworkColumnAdditionalClasses();
if ($class) {
$class .= ' ';
}
$class .= $gf->getPageThemeGridFrameworkColumnClassForSpan($this->arLayoutColumnOffset);
return $class;
}
} | php | public function getAreaLayoutColumnOffsetEditClass()
{
/*
* @var ThemeGridLayout $this->arLayout
*/
$gf = $this->arLayout->getThemeGridFrameworkObject();
if (is_object($gf)) {
$class = $gf->getPageThemeGridFrameworkColumnAdditionalClasses();
if ($class) {
$class .= ' ';
}
$class .= $gf->getPageThemeGridFrameworkColumnClassForSpan($this->arLayoutColumnOffset);
return $class;
}
} | [
"public",
"function",
"getAreaLayoutColumnOffsetEditClass",
"(",
")",
"{",
"/*\n * @var ThemeGridLayout $this->arLayout\n */",
"$",
"gf",
"=",
"$",
"this",
"->",
"arLayout",
"->",
"getThemeGridFrameworkObject",
"(",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"gf",
")",
")",
"{",
"$",
"class",
"=",
"$",
"gf",
"->",
"getPageThemeGridFrameworkColumnAdditionalClasses",
"(",
")",
";",
"if",
"(",
"$",
"class",
")",
"{",
"$",
"class",
".=",
"' '",
";",
"}",
"$",
"class",
".=",
"$",
"gf",
"->",
"getPageThemeGridFrameworkColumnClassForSpan",
"(",
"$",
"this",
"->",
"arLayoutColumnOffset",
")",
";",
"return",
"$",
"class",
";",
"}",
"}"
] | this returns offsets in the form of spans.
@return string | [
"this",
"returns",
"offsets",
"in",
"the",
"form",
"of",
"spans",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Area/Layout/ThemeGridColumn.php#L114-L130 | train |
concrete5/concrete5 | concrete/controllers/install.php | Install.getInstaller | protected function getInstaller()
{
if ($this->installer === null) {
$this->installer = $this->app->make(Installer::class);
}
return $this->installer;
} | php | protected function getInstaller()
{
if ($this->installer === null) {
$this->installer = $this->app->make(Installer::class);
}
return $this->installer;
} | [
"protected",
"function",
"getInstaller",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"installer",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"installer",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"Installer",
"::",
"class",
")",
";",
"}",
"return",
"$",
"this",
"->",
"installer",
";",
"}"
] | Get the installer instance.
@return Installer | [
"Get",
"the",
"installer",
"instance",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/controllers/install.php#L414-L421 | train |
concrete5/concrete5 | concrete/src/Config/DatabaseLoader.php | DatabaseLoader.load | public function load($environment, $group, $namespace = null)
{
$result = array();
$db = Database::getActiveConnection();
$query = $db->createQueryBuilder();
$query
->select('configValue', 'configItem')
->from('Config', 'c')
->where('configGroup = ?')
->setParameter(0, $group);
if ($namespace) {
$query->andWhere('configNamespace = ?')->setParameter(1, $namespace);
} else {
$query->andWhere('configNamespace = ? OR configNamespace IS NULL')->setParameter(1, '');
}
$results = $query->execute();
while ($row = $results->fetch()) {
array_set($result, $row['configItem'], $row['configValue']);
}
return $result;
} | php | public function load($environment, $group, $namespace = null)
{
$result = array();
$db = Database::getActiveConnection();
$query = $db->createQueryBuilder();
$query
->select('configValue', 'configItem')
->from('Config', 'c')
->where('configGroup = ?')
->setParameter(0, $group);
if ($namespace) {
$query->andWhere('configNamespace = ?')->setParameter(1, $namespace);
} else {
$query->andWhere('configNamespace = ? OR configNamespace IS NULL')->setParameter(1, '');
}
$results = $query->execute();
while ($row = $results->fetch()) {
array_set($result, $row['configItem'], $row['configValue']);
}
return $result;
} | [
"public",
"function",
"load",
"(",
"$",
"environment",
",",
"$",
"group",
",",
"$",
"namespace",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"db",
"=",
"Database",
"::",
"getActiveConnection",
"(",
")",
";",
"$",
"query",
"=",
"$",
"db",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"query",
"->",
"select",
"(",
"'configValue'",
",",
"'configItem'",
")",
"->",
"from",
"(",
"'Config'",
",",
"'c'",
")",
"->",
"where",
"(",
"'configGroup = ?'",
")",
"->",
"setParameter",
"(",
"0",
",",
"$",
"group",
")",
";",
"if",
"(",
"$",
"namespace",
")",
"{",
"$",
"query",
"->",
"andWhere",
"(",
"'configNamespace = ?'",
")",
"->",
"setParameter",
"(",
"1",
",",
"$",
"namespace",
")",
";",
"}",
"else",
"{",
"$",
"query",
"->",
"andWhere",
"(",
"'configNamespace = ? OR configNamespace IS NULL'",
")",
"->",
"setParameter",
"(",
"1",
",",
"''",
")",
";",
"}",
"$",
"results",
"=",
"$",
"query",
"->",
"execute",
"(",
")",
";",
"while",
"(",
"$",
"row",
"=",
"$",
"results",
"->",
"fetch",
"(",
")",
")",
"{",
"array_set",
"(",
"$",
"result",
",",
"$",
"row",
"[",
"'configItem'",
"]",
",",
"$",
"row",
"[",
"'configValue'",
"]",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Load the given configuration group. Because it's the database, we ignore the environment.
@param string $environment
@param string $group
@param string $namespace
@return array | [
"Load",
"the",
"given",
"configuration",
"group",
".",
"Because",
"it",
"s",
"the",
"database",
"we",
"ignore",
"the",
"environment",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Config/DatabaseLoader.php#L18-L44 | train |
concrete5/concrete5 | concrete/src/Config/DatabaseLoader.php | DatabaseLoader.getNamespaces | public function getNamespaces()
{
$db = Database::getActiveConnection();
/** @var PDOStatement $results */
$results = $db->createQueryBuilder()
->select('configNamespace')
->from('Config', 'c')
->where('configNamespace != ""')
->groupBy('configNamespace')
->execute();
return array_map('array_shift', $results->fetchAll());
} | php | public function getNamespaces()
{
$db = Database::getActiveConnection();
/** @var PDOStatement $results */
$results = $db->createQueryBuilder()
->select('configNamespace')
->from('Config', 'c')
->where('configNamespace != ""')
->groupBy('configNamespace')
->execute();
return array_map('array_shift', $results->fetchAll());
} | [
"public",
"function",
"getNamespaces",
"(",
")",
"{",
"$",
"db",
"=",
"Database",
"::",
"getActiveConnection",
"(",
")",
";",
"/** @var PDOStatement $results */",
"$",
"results",
"=",
"$",
"db",
"->",
"createQueryBuilder",
"(",
")",
"->",
"select",
"(",
"'configNamespace'",
")",
"->",
"from",
"(",
"'Config'",
",",
"'c'",
")",
"->",
"where",
"(",
"'configNamespace != \"\"'",
")",
"->",
"groupBy",
"(",
"'configNamespace'",
")",
"->",
"execute",
"(",
")",
";",
"return",
"array_map",
"(",
"'array_shift'",
",",
"$",
"results",
"->",
"fetchAll",
"(",
")",
")",
";",
"}"
] | Returns all registered namespaces with the config
loader.
@return array | [
"Returns",
"all",
"registered",
"namespaces",
"with",
"the",
"config",
"loader",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Config/DatabaseLoader.php#L94-L107 | train |
concrete5/concrete5 | concrete/src/Foundation/Runtime/Boot/DefaultBooter.php | DefaultBooter.boot | public function boot()
{
$app = $this->app;
/*
* ----------------------------------------------------------------------------
* Bind the IOC container to our facades
* Completely indebted to Taylor Otwell & Laravel for this.
* ----------------------------------------------------------------------------
*/
Facade::setFacadeApplication($app);
/**
* ----------------------------------------------------------------------------
* Load path detection for relative assets, URL and path to home.
* ----------------------------------------------------------------------------.
*/
require_once DIR_BASE_CORE . '/bootstrap/paths.php';
/*
* ----------------------------------------------------------------------------
* Add install environment detection
* ----------------------------------------------------------------------------
*/
$this->initializeEnvironmentDetection($app);
/*
* ----------------------------------------------------------------------------
* Enable Configuration
* ----------------------------------------------------------------------------
*/
$config = $this->initializeConfig($app);
/*
* ----------------------------------------------------------------------------
* Set configured error reporting
* ----------------------------------------------------------------------------
*/
$this->setupErrorReporting($config);
/*
* ----------------------------------------------------------------------------
* Enable Localization
* ----------------------------------------------------------------------------
*/
$this->initializeLocalization($app);
/*
* ----------------------------------------------------------------------------
* Finalize paths.
* ----------------------------------------------------------------------------
*/
require DIR_BASE_CORE . '/bootstrap/paths_configured.php';
/*
* ----------------------------------------------------------------------------
* Setup core classes aliases.
* ----------------------------------------------------------------------------
*/
$this->initializeClassAliases($config);
/*
* ----------------------------------------------------------------------------
* Simple legacy constants like APP_CHARSET
* ----------------------------------------------------------------------------
*/
$this->initializeLegacyDefinitions($config, $app);
/*
* ----------------------------------------------------------------------------
* Setup the core service groups.
* ----------------------------------------------------------------------------
*/
$this->initializeServiceProviders($app, $config);
/*
* ----------------------------------------------------------------------------
* Setup file cache directories. Has to come after we define services
* because we use the file service.
* ----------------------------------------------------------------------------
*/
$app->setupFilesystem();
/*
* ----------------------------------------------------------------------------
* Registries for theme paths, assets, routes and file types.
* ----------------------------------------------------------------------------
*/
$this->initializeAssets($config);
$this->initializeRoutes($config);
$this->initializeFileTypes($config);
// If we're not in the CLI SAPI, lets do additional booting for HTTP
if (!$this->app->isRunThroughCommandLineInterface()) {
return $this->bootHttpSapi($config, $app);
}
} | php | public function boot()
{
$app = $this->app;
/*
* ----------------------------------------------------------------------------
* Bind the IOC container to our facades
* Completely indebted to Taylor Otwell & Laravel for this.
* ----------------------------------------------------------------------------
*/
Facade::setFacadeApplication($app);
/**
* ----------------------------------------------------------------------------
* Load path detection for relative assets, URL and path to home.
* ----------------------------------------------------------------------------.
*/
require_once DIR_BASE_CORE . '/bootstrap/paths.php';
/*
* ----------------------------------------------------------------------------
* Add install environment detection
* ----------------------------------------------------------------------------
*/
$this->initializeEnvironmentDetection($app);
/*
* ----------------------------------------------------------------------------
* Enable Configuration
* ----------------------------------------------------------------------------
*/
$config = $this->initializeConfig($app);
/*
* ----------------------------------------------------------------------------
* Set configured error reporting
* ----------------------------------------------------------------------------
*/
$this->setupErrorReporting($config);
/*
* ----------------------------------------------------------------------------
* Enable Localization
* ----------------------------------------------------------------------------
*/
$this->initializeLocalization($app);
/*
* ----------------------------------------------------------------------------
* Finalize paths.
* ----------------------------------------------------------------------------
*/
require DIR_BASE_CORE . '/bootstrap/paths_configured.php';
/*
* ----------------------------------------------------------------------------
* Setup core classes aliases.
* ----------------------------------------------------------------------------
*/
$this->initializeClassAliases($config);
/*
* ----------------------------------------------------------------------------
* Simple legacy constants like APP_CHARSET
* ----------------------------------------------------------------------------
*/
$this->initializeLegacyDefinitions($config, $app);
/*
* ----------------------------------------------------------------------------
* Setup the core service groups.
* ----------------------------------------------------------------------------
*/
$this->initializeServiceProviders($app, $config);
/*
* ----------------------------------------------------------------------------
* Setup file cache directories. Has to come after we define services
* because we use the file service.
* ----------------------------------------------------------------------------
*/
$app->setupFilesystem();
/*
* ----------------------------------------------------------------------------
* Registries for theme paths, assets, routes and file types.
* ----------------------------------------------------------------------------
*/
$this->initializeAssets($config);
$this->initializeRoutes($config);
$this->initializeFileTypes($config);
// If we're not in the CLI SAPI, lets do additional booting for HTTP
if (!$this->app->isRunThroughCommandLineInterface()) {
return $this->bootHttpSapi($config, $app);
}
} | [
"public",
"function",
"boot",
"(",
")",
"{",
"$",
"app",
"=",
"$",
"this",
"->",
"app",
";",
"/*\n * ----------------------------------------------------------------------------\n * Bind the IOC container to our facades\n * Completely indebted to Taylor Otwell & Laravel for this.\n * ----------------------------------------------------------------------------\n */",
"Facade",
"::",
"setFacadeApplication",
"(",
"$",
"app",
")",
";",
"/**\n * ----------------------------------------------------------------------------\n * Load path detection for relative assets, URL and path to home.\n * ----------------------------------------------------------------------------.\n */",
"require_once",
"DIR_BASE_CORE",
".",
"'/bootstrap/paths.php'",
";",
"/*\n * ----------------------------------------------------------------------------\n * Add install environment detection\n * ----------------------------------------------------------------------------\n */",
"$",
"this",
"->",
"initializeEnvironmentDetection",
"(",
"$",
"app",
")",
";",
"/*\n * ----------------------------------------------------------------------------\n * Enable Configuration\n * ----------------------------------------------------------------------------\n */",
"$",
"config",
"=",
"$",
"this",
"->",
"initializeConfig",
"(",
"$",
"app",
")",
";",
"/*\n * ----------------------------------------------------------------------------\n * Set configured error reporting\n * ----------------------------------------------------------------------------\n */",
"$",
"this",
"->",
"setupErrorReporting",
"(",
"$",
"config",
")",
";",
"/*\n * ----------------------------------------------------------------------------\n * Enable Localization\n * ----------------------------------------------------------------------------\n */",
"$",
"this",
"->",
"initializeLocalization",
"(",
"$",
"app",
")",
";",
"/*\n * ----------------------------------------------------------------------------\n * Finalize paths.\n * ----------------------------------------------------------------------------\n */",
"require",
"DIR_BASE_CORE",
".",
"'/bootstrap/paths_configured.php'",
";",
"/*\n * ----------------------------------------------------------------------------\n * Setup core classes aliases.\n * ----------------------------------------------------------------------------\n */",
"$",
"this",
"->",
"initializeClassAliases",
"(",
"$",
"config",
")",
";",
"/*\n * ----------------------------------------------------------------------------\n * Simple legacy constants like APP_CHARSET\n * ----------------------------------------------------------------------------\n */",
"$",
"this",
"->",
"initializeLegacyDefinitions",
"(",
"$",
"config",
",",
"$",
"app",
")",
";",
"/*\n * ----------------------------------------------------------------------------\n * Setup the core service groups.\n * ----------------------------------------------------------------------------\n */",
"$",
"this",
"->",
"initializeServiceProviders",
"(",
"$",
"app",
",",
"$",
"config",
")",
";",
"/*\n * ----------------------------------------------------------------------------\n * Setup file cache directories. Has to come after we define services\n * because we use the file service.\n * ----------------------------------------------------------------------------\n */",
"$",
"app",
"->",
"setupFilesystem",
"(",
")",
";",
"/*\n * ----------------------------------------------------------------------------\n * Registries for theme paths, assets, routes and file types.\n * ----------------------------------------------------------------------------\n */",
"$",
"this",
"->",
"initializeAssets",
"(",
"$",
"config",
")",
";",
"$",
"this",
"->",
"initializeRoutes",
"(",
"$",
"config",
")",
";",
"$",
"this",
"->",
"initializeFileTypes",
"(",
"$",
"config",
")",
";",
"// If we're not in the CLI SAPI, lets do additional booting for HTTP",
"if",
"(",
"!",
"$",
"this",
"->",
"app",
"->",
"isRunThroughCommandLineInterface",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"bootHttpSapi",
"(",
"$",
"config",
",",
"$",
"app",
")",
";",
"}",
"}"
] | Boot up
Return a response if we're ready to output.
@return null|Response | [
"Boot",
"up",
"Return",
"a",
"response",
"if",
"we",
"re",
"ready",
"to",
"output",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Foundation/Runtime/Boot/DefaultBooter.php#L31-L127 | train |
concrete5/concrete5 | concrete/src/Foundation/Runtime/Boot/DefaultBooter.php | DefaultBooter.initializeConfig | private function initializeConfig(Application $app)
{
$config_provider = $app->make('Concrete\Core\Config\ConfigServiceProvider');
$config_provider->register();
/*
* @var \Concrete\Core\Config\Repository\Repository
*/
$config = $app->make('config');
return $config;
} | php | private function initializeConfig(Application $app)
{
$config_provider = $app->make('Concrete\Core\Config\ConfigServiceProvider');
$config_provider->register();
/*
* @var \Concrete\Core\Config\Repository\Repository
*/
$config = $app->make('config');
return $config;
} | [
"private",
"function",
"initializeConfig",
"(",
"Application",
"$",
"app",
")",
"{",
"$",
"config_provider",
"=",
"$",
"app",
"->",
"make",
"(",
"'Concrete\\Core\\Config\\ConfigServiceProvider'",
")",
";",
"$",
"config_provider",
"->",
"register",
"(",
")",
";",
"/*\n * @var \\Concrete\\Core\\Config\\Repository\\Repository\n */",
"$",
"config",
"=",
"$",
"app",
"->",
"make",
"(",
"'config'",
")",
";",
"return",
"$",
"config",
";",
"}"
] | Enable configuration.
@param Application $app
@return Repository | [
"Enable",
"configuration",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Foundation/Runtime/Boot/DefaultBooter.php#L181-L192 | train |
concrete5/concrete5 | concrete/src/Foundation/Runtime/Boot/DefaultBooter.php | DefaultBooter.setupErrorReporting | private function setupErrorReporting(Repository $config)
{
$error_reporting = $config->get('concrete.debug.error_reporting');
if ((string) $error_reporting !== '') {
error_reporting((int) $error_reporting);
}
} | php | private function setupErrorReporting(Repository $config)
{
$error_reporting = $config->get('concrete.debug.error_reporting');
if ((string) $error_reporting !== '') {
error_reporting((int) $error_reporting);
}
} | [
"private",
"function",
"setupErrorReporting",
"(",
"Repository",
"$",
"config",
")",
"{",
"$",
"error_reporting",
"=",
"$",
"config",
"->",
"get",
"(",
"'concrete.debug.error_reporting'",
")",
";",
"if",
"(",
"(",
"string",
")",
"$",
"error_reporting",
"!==",
"''",
")",
"{",
"error_reporting",
"(",
"(",
"int",
")",
"$",
"error_reporting",
")",
";",
"}",
"}"
] | Setup the configured error reporting.
@param Repository $config | [
"Setup",
"the",
"configured",
"error",
"reporting",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Foundation/Runtime/Boot/DefaultBooter.php#L199-L205 | train |
concrete5/concrete5 | concrete/src/Foundation/Runtime/Boot/DefaultBooter.php | DefaultBooter.validateDatabaseDetails | private function validateDatabaseDetails($environment)
{
$db_config = [];
$configFile = DIR_CONFIG_SITE . '/database.php';
$environmentConfig = DIR_CONFIG_SITE . "/{$environment}.database.php";
// If the database.php file exists, load it first
if (file_exists($configFile)) {
$db_config = include DIR_CONFIG_SITE . '/database.php';
}
// If there's an environment specific database file, load that too
if (file_exists($environmentConfig)) {
$db_config = array_merge($db_config, include $environmentConfig);
}
// Make sure the default connection is set
$defaultConnection = array_get($db_config, 'default-connection');
// Make sure we have all the stuff we expect
$connection = array_get($db_config, "connections.{$defaultConnection}");
// Make sure we have all the keys we are expecting
return $defaultConnection && $connection &&
array_get($connection, 'database') &&
array_get($connection, 'username') &&
array_get($connection, 'server');
} | php | private function validateDatabaseDetails($environment)
{
$db_config = [];
$configFile = DIR_CONFIG_SITE . '/database.php';
$environmentConfig = DIR_CONFIG_SITE . "/{$environment}.database.php";
// If the database.php file exists, load it first
if (file_exists($configFile)) {
$db_config = include DIR_CONFIG_SITE . '/database.php';
}
// If there's an environment specific database file, load that too
if (file_exists($environmentConfig)) {
$db_config = array_merge($db_config, include $environmentConfig);
}
// Make sure the default connection is set
$defaultConnection = array_get($db_config, 'default-connection');
// Make sure we have all the stuff we expect
$connection = array_get($db_config, "connections.{$defaultConnection}");
// Make sure we have all the keys we are expecting
return $defaultConnection && $connection &&
array_get($connection, 'database') &&
array_get($connection, 'username') &&
array_get($connection, 'server');
} | [
"private",
"function",
"validateDatabaseDetails",
"(",
"$",
"environment",
")",
"{",
"$",
"db_config",
"=",
"[",
"]",
";",
"$",
"configFile",
"=",
"DIR_CONFIG_SITE",
".",
"'/database.php'",
";",
"$",
"environmentConfig",
"=",
"DIR_CONFIG_SITE",
".",
"\"/{$environment}.database.php\"",
";",
"// If the database.php file exists, load it first",
"if",
"(",
"file_exists",
"(",
"$",
"configFile",
")",
")",
"{",
"$",
"db_config",
"=",
"include",
"DIR_CONFIG_SITE",
".",
"'/database.php'",
";",
"}",
"// If there's an environment specific database file, load that too",
"if",
"(",
"file_exists",
"(",
"$",
"environmentConfig",
")",
")",
"{",
"$",
"db_config",
"=",
"array_merge",
"(",
"$",
"db_config",
",",
"include",
"$",
"environmentConfig",
")",
";",
"}",
"// Make sure the default connection is set",
"$",
"defaultConnection",
"=",
"array_get",
"(",
"$",
"db_config",
",",
"'default-connection'",
")",
";",
"// Make sure we have all the stuff we expect",
"$",
"connection",
"=",
"array_get",
"(",
"$",
"db_config",
",",
"\"connections.{$defaultConnection}\"",
")",
";",
"// Make sure we have all the keys we are expecting",
"return",
"$",
"defaultConnection",
"&&",
"$",
"connection",
"&&",
"array_get",
"(",
"$",
"connection",
",",
"'database'",
")",
"&&",
"array_get",
"(",
"$",
"connection",
",",
"'username'",
")",
"&&",
"array_get",
"(",
"$",
"connection",
",",
"'server'",
")",
";",
"}"
] | Check whether an environment has well formed database credentials defined
@param $environment
@return mixed | [
"Check",
"whether",
"an",
"environment",
"has",
"well",
"formed",
"database",
"credentials",
"defined"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Foundation/Runtime/Boot/DefaultBooter.php#L259-L286 | train |
concrete5/concrete5 | concrete/src/Foundation/Runtime/Boot/DefaultBooter.php | DefaultBooter.checkInstall | private function checkInstall(Application $app, Request $request)
{
if (!$app->isInstalled()) {
if (
!$request->matches('/install/*')
&& $request->getPath() != '/install'
&& !$request->matches('/ccm/assets/localization/*')
) {
$manager = $app->make('Concrete\Core\Url\Resolver\Manager\ResolverManager');
$response = new RedirectResponse($manager->resolve(['install']));
return $response;
}
}
} | php | private function checkInstall(Application $app, Request $request)
{
if (!$app->isInstalled()) {
if (
!$request->matches('/install/*')
&& $request->getPath() != '/install'
&& !$request->matches('/ccm/assets/localization/*')
) {
$manager = $app->make('Concrete\Core\Url\Resolver\Manager\ResolverManager');
$response = new RedirectResponse($manager->resolve(['install']));
return $response;
}
}
} | [
"private",
"function",
"checkInstall",
"(",
"Application",
"$",
"app",
",",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"$",
"app",
"->",
"isInstalled",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"request",
"->",
"matches",
"(",
"'/install/*'",
")",
"&&",
"$",
"request",
"->",
"getPath",
"(",
")",
"!=",
"'/install'",
"&&",
"!",
"$",
"request",
"->",
"matches",
"(",
"'/ccm/assets/localization/*'",
")",
")",
"{",
"$",
"manager",
"=",
"$",
"app",
"->",
"make",
"(",
"'Concrete\\Core\\Url\\Resolver\\Manager\\ResolverManager'",
")",
";",
"$",
"response",
"=",
"new",
"RedirectResponse",
"(",
"$",
"manager",
"->",
"resolve",
"(",
"[",
"'install'",
"]",
")",
")",
";",
"return",
"$",
"response",
";",
"}",
"}",
"}"
] | If we haven't installed and we're not looking at the install directory, redirect.
@param Application $app
@param Request $request
@return null|Response | [
"If",
"we",
"haven",
"t",
"installed",
"and",
"we",
"re",
"not",
"looking",
"at",
"the",
"install",
"directory",
"redirect",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Foundation/Runtime/Boot/DefaultBooter.php#L454-L468 | train |
concrete5/concrete5 | concrete/src/Gathering/Item/Template/Template.php | Template.getGatheringItemTemplateSlotWidth | public function getGatheringItemTemplateSlotWidth(GatheringItem $item)
{
if ($this->getGatheringItemTemplateFixedSlotWidth()) {
return $this->getGatheringItemTemplateFixedSlotWidth();
}
$w = 0;
$handles = $this->getGatheringItemTemplateFeatureHandles();
$assignments = \Concrete\Core\Feature\Assignment\GatheringItemAssignment::getList($item);
foreach ($assignments as $as) {
if (in_array($as->getFeatureDetailHandle(), $handles)) {
$fd = $as->getFeatureDetailObject();
if ($fd->getGatheringItemSuggestedSlotWidth() > 0 && $fd->getGatheringItemSuggestedSlotWidth() > $w) {
$w = $fd->getGatheringItemSuggestedSlotWidth();
}
}
}
if ($w) {
return $w;
}
$wb = $this->getGatheringItemTemplateMinimumSlotWidth($item);
$wt = $this->getGatheringItemTemplateMaximumSlotWidth($item);
return mt_rand($wb, $wt);
} | php | public function getGatheringItemTemplateSlotWidth(GatheringItem $item)
{
if ($this->getGatheringItemTemplateFixedSlotWidth()) {
return $this->getGatheringItemTemplateFixedSlotWidth();
}
$w = 0;
$handles = $this->getGatheringItemTemplateFeatureHandles();
$assignments = \Concrete\Core\Feature\Assignment\GatheringItemAssignment::getList($item);
foreach ($assignments as $as) {
if (in_array($as->getFeatureDetailHandle(), $handles)) {
$fd = $as->getFeatureDetailObject();
if ($fd->getGatheringItemSuggestedSlotWidth() > 0 && $fd->getGatheringItemSuggestedSlotWidth() > $w) {
$w = $fd->getGatheringItemSuggestedSlotWidth();
}
}
}
if ($w) {
return $w;
}
$wb = $this->getGatheringItemTemplateMinimumSlotWidth($item);
$wt = $this->getGatheringItemTemplateMaximumSlotWidth($item);
return mt_rand($wb, $wt);
} | [
"public",
"function",
"getGatheringItemTemplateSlotWidth",
"(",
"GatheringItem",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getGatheringItemTemplateFixedSlotWidth",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getGatheringItemTemplateFixedSlotWidth",
"(",
")",
";",
"}",
"$",
"w",
"=",
"0",
";",
"$",
"handles",
"=",
"$",
"this",
"->",
"getGatheringItemTemplateFeatureHandles",
"(",
")",
";",
"$",
"assignments",
"=",
"\\",
"Concrete",
"\\",
"Core",
"\\",
"Feature",
"\\",
"Assignment",
"\\",
"GatheringItemAssignment",
"::",
"getList",
"(",
"$",
"item",
")",
";",
"foreach",
"(",
"$",
"assignments",
"as",
"$",
"as",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"as",
"->",
"getFeatureDetailHandle",
"(",
")",
",",
"$",
"handles",
")",
")",
"{",
"$",
"fd",
"=",
"$",
"as",
"->",
"getFeatureDetailObject",
"(",
")",
";",
"if",
"(",
"$",
"fd",
"->",
"getGatheringItemSuggestedSlotWidth",
"(",
")",
">",
"0",
"&&",
"$",
"fd",
"->",
"getGatheringItemSuggestedSlotWidth",
"(",
")",
">",
"$",
"w",
")",
"{",
"$",
"w",
"=",
"$",
"fd",
"->",
"getGatheringItemSuggestedSlotWidth",
"(",
")",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"w",
")",
"{",
"return",
"$",
"w",
";",
"}",
"$",
"wb",
"=",
"$",
"this",
"->",
"getGatheringItemTemplateMinimumSlotWidth",
"(",
"$",
"item",
")",
";",
"$",
"wt",
"=",
"$",
"this",
"->",
"getGatheringItemTemplateMaximumSlotWidth",
"(",
"$",
"item",
")",
";",
"return",
"mt_rand",
"(",
"$",
"wb",
",",
"$",
"wt",
")",
";",
"}"
] | This method is called by GatheringItem when setting defaults. | [
"This",
"method",
"is",
"called",
"by",
"GatheringItem",
"when",
"setting",
"defaults",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Gathering/Item/Template/Template.php#L191-L217 | train |
concrete5/concrete5 | concrete/src/Config/FileLoader.php | FileLoader.clearNamespace | public function clearNamespace($namespace)
{
$paths = $this->getNamespaceDefaultPaths($namespace);
foreach ($paths as $path) {
if ($this->files->isDirectory($path)) {
$this->files->deleteDirectory($path);
}
}
} | php | public function clearNamespace($namespace)
{
$paths = $this->getNamespaceDefaultPaths($namespace);
foreach ($paths as $path) {
if ($this->files->isDirectory($path)) {
$this->files->deleteDirectory($path);
}
}
} | [
"public",
"function",
"clearNamespace",
"(",
"$",
"namespace",
")",
"{",
"$",
"paths",
"=",
"$",
"this",
"->",
"getNamespaceDefaultPaths",
"(",
"$",
"namespace",
")",
";",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"files",
"->",
"isDirectory",
"(",
"$",
"path",
")",
")",
"{",
"$",
"this",
"->",
"files",
"->",
"deleteDirectory",
"(",
"$",
"path",
")",
";",
"}",
"}",
"}"
] | Clear groups in a namespace.
@param $namespace | [
"Clear",
"groups",
"in",
"a",
"namespace",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Config/FileLoader.php#L203-L211 | train |
concrete5/concrete5 | concrete/src/User/CsvWriter.php | CsvWriter.projectList | private function projectList(UserList $list)
{
$statement = $list->deliverQueryObject()->execute();
foreach ($statement as $result) {
$user = $list->getResult($result);
yield iterator_to_array($this->projectUser($user));
}
} | php | private function projectList(UserList $list)
{
$statement = $list->deliverQueryObject()->execute();
foreach ($statement as $result) {
$user = $list->getResult($result);
yield iterator_to_array($this->projectUser($user));
}
} | [
"private",
"function",
"projectList",
"(",
"UserList",
"$",
"list",
")",
"{",
"$",
"statement",
"=",
"$",
"list",
"->",
"deliverQueryObject",
"(",
")",
"->",
"execute",
"(",
")",
";",
"foreach",
"(",
"$",
"statement",
"as",
"$",
"result",
")",
"{",
"$",
"user",
"=",
"$",
"list",
"->",
"getResult",
"(",
"$",
"result",
")",
";",
"yield",
"iterator_to_array",
"(",
"$",
"this",
"->",
"projectUser",
"(",
"$",
"user",
")",
")",
";",
"}",
"}"
] | A generator that takes a UserList and converts it to CSV rows
@param \Concrete\Core\User\UserList $list
@return \Generator | [
"A",
"generator",
"that",
"takes",
"a",
"UserList",
"and",
"converts",
"it",
"to",
"CSV",
"rows"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/CsvWriter.php#L56-L64 | train |
concrete5/concrete5 | concrete/src/User/CsvWriter.php | CsvWriter.projectUser | private function projectUser(UserInfo $user)
{
yield $user->getUserName();
yield $user->getUserEmail();
$userRegistrationDate = $user->getUserDateAdded();
yield $this->date->formatCustom(\DateTime::ATOM, $userRegistrationDate);
list($active, $inactive) = $this->getTranslatedStatus();
yield $user->isActive() ? $active : $inactive;
yield $user->getNumLogins();
$attributes = $this->getAttributeKeys();
foreach ($attributes as $attribute) {
$value = $user->getAttributeValueObject($attribute);
yield $value ? $value->getPlainTextValue() : '';
}
} | php | private function projectUser(UserInfo $user)
{
yield $user->getUserName();
yield $user->getUserEmail();
$userRegistrationDate = $user->getUserDateAdded();
yield $this->date->formatCustom(\DateTime::ATOM, $userRegistrationDate);
list($active, $inactive) = $this->getTranslatedStatus();
yield $user->isActive() ? $active : $inactive;
yield $user->getNumLogins();
$attributes = $this->getAttributeKeys();
foreach ($attributes as $attribute) {
$value = $user->getAttributeValueObject($attribute);
yield $value ? $value->getPlainTextValue() : '';
}
} | [
"private",
"function",
"projectUser",
"(",
"UserInfo",
"$",
"user",
")",
"{",
"yield",
"$",
"user",
"->",
"getUserName",
"(",
")",
";",
"yield",
"$",
"user",
"->",
"getUserEmail",
"(",
")",
";",
"$",
"userRegistrationDate",
"=",
"$",
"user",
"->",
"getUserDateAdded",
"(",
")",
";",
"yield",
"$",
"this",
"->",
"date",
"->",
"formatCustom",
"(",
"\\",
"DateTime",
"::",
"ATOM",
",",
"$",
"userRegistrationDate",
")",
";",
"list",
"(",
"$",
"active",
",",
"$",
"inactive",
")",
"=",
"$",
"this",
"->",
"getTranslatedStatus",
"(",
")",
";",
"yield",
"$",
"user",
"->",
"isActive",
"(",
")",
"?",
"$",
"active",
":",
"$",
"inactive",
";",
"yield",
"$",
"user",
"->",
"getNumLogins",
"(",
")",
";",
"$",
"attributes",
"=",
"$",
"this",
"->",
"getAttributeKeys",
"(",
")",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"attribute",
")",
"{",
"$",
"value",
"=",
"$",
"user",
"->",
"getAttributeValueObject",
"(",
"$",
"attribute",
")",
";",
"yield",
"$",
"value",
"?",
"$",
"value",
"->",
"getPlainTextValue",
"(",
")",
":",
"''",
";",
"}",
"}"
] | Turn a user into an array
@param \Concrete\Core\User\UserInfo $user
@return array | [
"Turn",
"a",
"user",
"into",
"an",
"array"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/CsvWriter.php#L71-L88 | train |
concrete5/concrete5 | concrete/src/User/CsvWriter.php | CsvWriter.getAttributeKeys | private function getAttributeKeys()
{
if (!isset($this->attributeKeys)) {
$this->attributeKeys = $this->category->getList();
}
return $this->attributeKeys;
} | php | private function getAttributeKeys()
{
if (!isset($this->attributeKeys)) {
$this->attributeKeys = $this->category->getList();
}
return $this->attributeKeys;
} | [
"private",
"function",
"getAttributeKeys",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"attributeKeys",
")",
")",
"{",
"$",
"this",
"->",
"attributeKeys",
"=",
"$",
"this",
"->",
"category",
"->",
"getList",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"attributeKeys",
";",
"}"
] | Memoize the attribute keys so that we aren't looking them up over and over
@return array | [
"Memoize",
"the",
"attribute",
"keys",
"so",
"that",
"we",
"aren",
"t",
"looking",
"them",
"up",
"over",
"and",
"over"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/CsvWriter.php#L114-L121 | train |
concrete5/concrete5 | concrete/src/User/CsvWriter.php | CsvWriter.getTranslatedStatus | private function getTranslatedStatus()
{
if ($this->status === null) {
$this->status = [t('Active'), t('Inactive')];
}
return $this->status;
} | php | private function getTranslatedStatus()
{
if ($this->status === null) {
$this->status = [t('Active'), t('Inactive')];
}
return $this->status;
} | [
"private",
"function",
"getTranslatedStatus",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"status",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"status",
"=",
"[",
"t",
"(",
"'Active'",
")",
",",
"t",
"(",
"'Inactive'",
")",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"status",
";",
"}"
] | Get the translated status texts
@return string[] | [
"Get",
"the",
"translated",
"status",
"texts"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/CsvWriter.php#L127-L134 | train |
concrete5/concrete5 | concrete/src/Antispam/Service.php | Service.report | public function report($content, $author, $email, $ip, $ua, $additionalArgs = array())
{
$args['content'] = $content;
$args['author'] = $author;
$args['author_email'] = $email;
$args['ip_address'] = $ip;
$args['user_agent'] = $ua;
foreach ($additionalArgs as $key => $value) {
$args[$key] = $value;
}
if (method_exists($this->controller, 'report')) {
$this->controller->report($args);
}
$u = new User();
\Log::info(t('Content %s (author %s, %s) flagged as spam by user %s',
$content,
$author,
$email,
$u->getUserName()
));
} | php | public function report($content, $author, $email, $ip, $ua, $additionalArgs = array())
{
$args['content'] = $content;
$args['author'] = $author;
$args['author_email'] = $email;
$args['ip_address'] = $ip;
$args['user_agent'] = $ua;
foreach ($additionalArgs as $key => $value) {
$args[$key] = $value;
}
if (method_exists($this->controller, 'report')) {
$this->controller->report($args);
}
$u = new User();
\Log::info(t('Content %s (author %s, %s) flagged as spam by user %s',
$content,
$author,
$email,
$u->getUserName()
));
} | [
"public",
"function",
"report",
"(",
"$",
"content",
",",
"$",
"author",
",",
"$",
"email",
",",
"$",
"ip",
",",
"$",
"ua",
",",
"$",
"additionalArgs",
"=",
"array",
"(",
")",
")",
"{",
"$",
"args",
"[",
"'content'",
"]",
"=",
"$",
"content",
";",
"$",
"args",
"[",
"'author'",
"]",
"=",
"$",
"author",
";",
"$",
"args",
"[",
"'author_email'",
"]",
"=",
"$",
"email",
";",
"$",
"args",
"[",
"'ip_address'",
"]",
"=",
"$",
"ip",
";",
"$",
"args",
"[",
"'user_agent'",
"]",
"=",
"$",
"ua",
";",
"foreach",
"(",
"$",
"additionalArgs",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"args",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"if",
"(",
"method_exists",
"(",
"$",
"this",
"->",
"controller",
",",
"'report'",
")",
")",
"{",
"$",
"this",
"->",
"controller",
"->",
"report",
"(",
"$",
"args",
")",
";",
"}",
"$",
"u",
"=",
"new",
"User",
"(",
")",
";",
"\\",
"Log",
"::",
"info",
"(",
"t",
"(",
"'Content %s (author %s, %s) flagged as spam by user %s'",
",",
"$",
"content",
",",
"$",
"author",
",",
"$",
"email",
",",
"$",
"u",
"->",
"getUserName",
"(",
")",
")",
")",
";",
"}"
] | Report some content with the poster's information to the AntiSpam service.
@param string $content
@param UserInfo $ui
@param string $ip
@param string $ua
@param array $additionalArgs | [
"Report",
"some",
"content",
"with",
"the",
"poster",
"s",
"information",
"to",
"the",
"AntiSpam",
"service",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Antispam/Service.php#L46-L68 | train |
concrete5/concrete5 | concrete/src/Foundation/Runtime/Run/CLIRunner.php | CLIRunner.run | public function run()
{
$console = $this->console;
$this->app->instance('console', $console);
$this->loadBootstrap();
$this->initializeSystemTimezone();
$input = new ArgvInput();
if ($input->getFirstArgument() !== 'c5:update') {
if ($this->app->isInstalled()) {
$this->app->setupPackageAutoloaders();
$this->app->setupPackages();
}
}
// Handle legacy backwards compatibility
if (method_exists($console, 'setupDefaultCommands')) {
$console->setupDefaultCommands();
}
\Events::dispatch('on_before_console_run');
$console->run($input);
\Events::dispatch('on_after_console_run');
} | php | public function run()
{
$console = $this->console;
$this->app->instance('console', $console);
$this->loadBootstrap();
$this->initializeSystemTimezone();
$input = new ArgvInput();
if ($input->getFirstArgument() !== 'c5:update') {
if ($this->app->isInstalled()) {
$this->app->setupPackageAutoloaders();
$this->app->setupPackages();
}
}
// Handle legacy backwards compatibility
if (method_exists($console, 'setupDefaultCommands')) {
$console->setupDefaultCommands();
}
\Events::dispatch('on_before_console_run');
$console->run($input);
\Events::dispatch('on_after_console_run');
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"console",
"=",
"$",
"this",
"->",
"console",
";",
"$",
"this",
"->",
"app",
"->",
"instance",
"(",
"'console'",
",",
"$",
"console",
")",
";",
"$",
"this",
"->",
"loadBootstrap",
"(",
")",
";",
"$",
"this",
"->",
"initializeSystemTimezone",
"(",
")",
";",
"$",
"input",
"=",
"new",
"ArgvInput",
"(",
")",
";",
"if",
"(",
"$",
"input",
"->",
"getFirstArgument",
"(",
")",
"!==",
"'c5:update'",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"app",
"->",
"isInstalled",
"(",
")",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"setupPackageAutoloaders",
"(",
")",
";",
"$",
"this",
"->",
"app",
"->",
"setupPackages",
"(",
")",
";",
"}",
"}",
"// Handle legacy backwards compatibility",
"if",
"(",
"method_exists",
"(",
"$",
"console",
",",
"'setupDefaultCommands'",
")",
")",
"{",
"$",
"console",
"->",
"setupDefaultCommands",
"(",
")",
";",
"}",
"\\",
"Events",
"::",
"dispatch",
"(",
"'on_before_console_run'",
")",
";",
"$",
"console",
"->",
"run",
"(",
"$",
"input",
")",
";",
"\\",
"Events",
"::",
"dispatch",
"(",
"'on_after_console_run'",
")",
";",
"}"
] | Run the runtime.
@return mixed | [
"Run",
"the",
"runtime",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Foundation/Runtime/Run/CLIRunner.php#L43-L69 | train |
concrete5/concrete5 | concrete/src/Service/Configuration/HTTP/ApacheConfigurator.php | ApacheConfigurator.getConfiguredRule | protected function getConfiguredRule($configuration, RuleInterface $rule)
{
$configurationNormalized = str_replace(array("\r\n", "\r"), "\n", (string) $configuration);
$rxSearch = '/';
// First of all we have either the start of the file or a line ending
$rxSearch .= '(^|\n)';
$commentsBefore = $rule->getCommentsBefore();
if ($commentsBefore !== '') {
// Then we may have the opening comment line
$rxSearch .= '(\s*'.preg_quote($commentsBefore, '/').'\s*\n+)?';
}
// Then we have the rule itself
$rxSearch .= '\s*'.preg_replace("/\n\s*/", "\\s*\\n\\s*", preg_quote($rule->getCode(), '/')).'\s*';
$commentsAfter = $rule->getCommentsAfter();
if ($commentsAfter !== '') {
// Then we may have the closing comment line
$rxSearch .= '(\n\s*'.preg_quote($commentsAfter, '/').'\s*)?';
}
// Finally we have the end of the file or a line ending
$rxSearch .= '(\n|$)';
$rxSearch .= '/';
return preg_match($rxSearch, $configurationNormalized, $match) ? $match[0] : '';
} | php | protected function getConfiguredRule($configuration, RuleInterface $rule)
{
$configurationNormalized = str_replace(array("\r\n", "\r"), "\n", (string) $configuration);
$rxSearch = '/';
// First of all we have either the start of the file or a line ending
$rxSearch .= '(^|\n)';
$commentsBefore = $rule->getCommentsBefore();
if ($commentsBefore !== '') {
// Then we may have the opening comment line
$rxSearch .= '(\s*'.preg_quote($commentsBefore, '/').'\s*\n+)?';
}
// Then we have the rule itself
$rxSearch .= '\s*'.preg_replace("/\n\s*/", "\\s*\\n\\s*", preg_quote($rule->getCode(), '/')).'\s*';
$commentsAfter = $rule->getCommentsAfter();
if ($commentsAfter !== '') {
// Then we may have the closing comment line
$rxSearch .= '(\n\s*'.preg_quote($commentsAfter, '/').'\s*)?';
}
// Finally we have the end of the file or a line ending
$rxSearch .= '(\n|$)';
$rxSearch .= '/';
return preg_match($rxSearch, $configurationNormalized, $match) ? $match[0] : '';
} | [
"protected",
"function",
"getConfiguredRule",
"(",
"$",
"configuration",
",",
"RuleInterface",
"$",
"rule",
")",
"{",
"$",
"configurationNormalized",
"=",
"str_replace",
"(",
"array",
"(",
"\"\\r\\n\"",
",",
"\"\\r\"",
")",
",",
"\"\\n\"",
",",
"(",
"string",
")",
"$",
"configuration",
")",
";",
"$",
"rxSearch",
"=",
"'/'",
";",
"// First of all we have either the start of the file or a line ending",
"$",
"rxSearch",
".=",
"'(^|\\n)'",
";",
"$",
"commentsBefore",
"=",
"$",
"rule",
"->",
"getCommentsBefore",
"(",
")",
";",
"if",
"(",
"$",
"commentsBefore",
"!==",
"''",
")",
"{",
"// Then we may have the opening comment line",
"$",
"rxSearch",
".=",
"'(\\s*'",
".",
"preg_quote",
"(",
"$",
"commentsBefore",
",",
"'/'",
")",
".",
"'\\s*\\n+)?'",
";",
"}",
"// Then we have the rule itself",
"$",
"rxSearch",
".=",
"'\\s*'",
".",
"preg_replace",
"(",
"\"/\\n\\s*/\"",
",",
"\"\\\\s*\\\\n\\\\s*\"",
",",
"preg_quote",
"(",
"$",
"rule",
"->",
"getCode",
"(",
")",
",",
"'/'",
")",
")",
".",
"'\\s*'",
";",
"$",
"commentsAfter",
"=",
"$",
"rule",
"->",
"getCommentsAfter",
"(",
")",
";",
"if",
"(",
"$",
"commentsAfter",
"!==",
"''",
")",
"{",
"// Then we may have the closing comment line",
"$",
"rxSearch",
".=",
"'(\\n\\s*'",
".",
"preg_quote",
"(",
"$",
"commentsAfter",
",",
"'/'",
")",
".",
"'\\s*)?'",
";",
"}",
"// Finally we have the end of the file or a line ending",
"$",
"rxSearch",
".=",
"'(\\n|$)'",
";",
"$",
"rxSearch",
".=",
"'/'",
";",
"return",
"preg_match",
"(",
"$",
"rxSearch",
",",
"$",
"configurationNormalized",
",",
"$",
"match",
")",
"?",
"$",
"match",
"[",
"0",
"]",
":",
"''",
";",
"}"
] | Gets the rule, if present in a configuration.
@param string $configuration The whole configuration.
@param RuleInterface $rule The rule to be checked.
@return string Returns the whole rule found (or '' if not found) | [
"Gets",
"the",
"rule",
"if",
"present",
"in",
"a",
"configuration",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Service/Configuration/HTTP/ApacheConfigurator.php#L17-L40 | train |
concrete5/concrete5 | concrete/src/Multilingual/Page/Section/Section.php | Section.getByID | public static function getByID($cID, $cvID = 'RECENT')
{
$entity = self::getLocaleFromHomePageID($cID);
if ($entity) {
$obj = parent::getByID($cID, $cvID);
$obj->setLocale($entity);
return $obj;
}
return false;
} | php | public static function getByID($cID, $cvID = 'RECENT')
{
$entity = self::getLocaleFromHomePageID($cID);
if ($entity) {
$obj = parent::getByID($cID, $cvID);
$obj->setLocale($entity);
return $obj;
}
return false;
} | [
"public",
"static",
"function",
"getByID",
"(",
"$",
"cID",
",",
"$",
"cvID",
"=",
"'RECENT'",
")",
"{",
"$",
"entity",
"=",
"self",
"::",
"getLocaleFromHomePageID",
"(",
"$",
"cID",
")",
";",
"if",
"(",
"$",
"entity",
")",
"{",
"$",
"obj",
"=",
"parent",
"::",
"getByID",
"(",
"$",
"cID",
",",
"$",
"cvID",
")",
";",
"$",
"obj",
"->",
"setLocale",
"(",
"$",
"entity",
")",
";",
"return",
"$",
"obj",
";",
"}",
"return",
"false",
";",
"}"
] | Returns an instance of MultilingualSection for the given page ID.
@param int $cID
@param int|string $cvID
@param string $class
@return MultilingualSection|false | [
"Returns",
"an",
"instance",
"of",
"MultilingualSection",
"for",
"the",
"given",
"page",
"ID",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Multilingual/Page/Section/Section.php#L73-L84 | train |
concrete5/concrete5 | concrete/src/Multilingual/Page/Section/Section.php | Section.getCurrentSection | public static function getCurrentSection()
{
static $lang;
if (!isset($lang)) {
$c = Page::getCurrentPage();
if ($c instanceof Page) {
$lang = self::getBySectionOfSite($c);
}
}
return $lang;
} | php | public static function getCurrentSection()
{
static $lang;
if (!isset($lang)) {
$c = Page::getCurrentPage();
if ($c instanceof Page) {
$lang = self::getBySectionOfSite($c);
}
}
return $lang;
} | [
"public",
"static",
"function",
"getCurrentSection",
"(",
")",
"{",
"static",
"$",
"lang",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"lang",
")",
")",
"{",
"$",
"c",
"=",
"Page",
"::",
"getCurrentPage",
"(",
")",
";",
"if",
"(",
"$",
"c",
"instanceof",
"Page",
")",
"{",
"$",
"lang",
"=",
"self",
"::",
"getBySectionOfSite",
"(",
"$",
"c",
")",
";",
"}",
"}",
"return",
"$",
"lang",
";",
"}"
] | Gets the MultilingualSection object for the current section of the site.
@return Section | [
"Gets",
"the",
"MultilingualSection",
"object",
"for",
"the",
"current",
"section",
"of",
"the",
"site",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Multilingual/Page/Section/Section.php#L422-L433 | train |
concrete5/concrete5 | concrete/src/Multilingual/Page/Section/Section.php | Section.getTranslatedPageID | public function getTranslatedPageID($page)
{
$ids = static::getIDList();
if (in_array($page->getCollectionID(), $ids)) {
return $this->locale->getSiteTree()->getSiteHomePageID();
}
$mpRelationID = self::getMultilingualPageRelationID($page->getCollectionID());
if ($mpRelationID) {
$cID = self::getCollectionIDForLocale($mpRelationID, $this->getLocale());
return $cID;
}
} | php | public function getTranslatedPageID($page)
{
$ids = static::getIDList();
if (in_array($page->getCollectionID(), $ids)) {
return $this->locale->getSiteTree()->getSiteHomePageID();
}
$mpRelationID = self::getMultilingualPageRelationID($page->getCollectionID());
if ($mpRelationID) {
$cID = self::getCollectionIDForLocale($mpRelationID, $this->getLocale());
return $cID;
}
} | [
"public",
"function",
"getTranslatedPageID",
"(",
"$",
"page",
")",
"{",
"$",
"ids",
"=",
"static",
"::",
"getIDList",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"page",
"->",
"getCollectionID",
"(",
")",
",",
"$",
"ids",
")",
")",
"{",
"return",
"$",
"this",
"->",
"locale",
"->",
"getSiteTree",
"(",
")",
"->",
"getSiteHomePageID",
"(",
")",
";",
"}",
"$",
"mpRelationID",
"=",
"self",
"::",
"getMultilingualPageRelationID",
"(",
"$",
"page",
"->",
"getCollectionID",
"(",
")",
")",
";",
"if",
"(",
"$",
"mpRelationID",
")",
"{",
"$",
"cID",
"=",
"self",
"::",
"getCollectionIDForLocale",
"(",
"$",
"mpRelationID",
",",
"$",
"this",
"->",
"getLocale",
"(",
")",
")",
";",
"return",
"$",
"cID",
";",
"}",
"}"
] | Receives a page in a different language tree, and tries to return the corresponding page in the current language tree.
@return int|null | [
"Receives",
"a",
"page",
"in",
"a",
"different",
"language",
"tree",
"and",
"tries",
"to",
"return",
"the",
"corresponding",
"page",
"in",
"the",
"current",
"language",
"tree",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Multilingual/Page/Section/Section.php#L615-L629 | train |
concrete5/concrete5 | concrete/src/Multilingual/Page/Section/Section.php | Section.getSectionInterfaceTranslations | public function getSectionInterfaceTranslations($untranslatedFirst = false)
{
$translations = new Translations();
$translations->setLanguage($this->getLocale());
$translations->setPluralForms($this->getNumberOfPluralForms(), $this->getPluralsRule());
$db = \Database::get();
$r = $db->query(
"select *
from MultilingualTranslations
where mtSectionID = ?
order by ".($untranslatedFirst ? "if(ifnull(msgstr, '') = '', 0, 1), " : "")."mtID",
[$this->getCollectionID()]
);
while ($row = $r->fetch()) {
$t = Translation::getByRow($row);
if (isset($t)) {
$translations[] = $t;
}
}
return $translations;
} | php | public function getSectionInterfaceTranslations($untranslatedFirst = false)
{
$translations = new Translations();
$translations->setLanguage($this->getLocale());
$translations->setPluralForms($this->getNumberOfPluralForms(), $this->getPluralsRule());
$db = \Database::get();
$r = $db->query(
"select *
from MultilingualTranslations
where mtSectionID = ?
order by ".($untranslatedFirst ? "if(ifnull(msgstr, '') = '', 0, 1), " : "")."mtID",
[$this->getCollectionID()]
);
while ($row = $r->fetch()) {
$t = Translation::getByRow($row);
if (isset($t)) {
$translations[] = $t;
}
}
return $translations;
} | [
"public",
"function",
"getSectionInterfaceTranslations",
"(",
"$",
"untranslatedFirst",
"=",
"false",
")",
"{",
"$",
"translations",
"=",
"new",
"Translations",
"(",
")",
";",
"$",
"translations",
"->",
"setLanguage",
"(",
"$",
"this",
"->",
"getLocale",
"(",
")",
")",
";",
"$",
"translations",
"->",
"setPluralForms",
"(",
"$",
"this",
"->",
"getNumberOfPluralForms",
"(",
")",
",",
"$",
"this",
"->",
"getPluralsRule",
"(",
")",
")",
";",
"$",
"db",
"=",
"\\",
"Database",
"::",
"get",
"(",
")",
";",
"$",
"r",
"=",
"$",
"db",
"->",
"query",
"(",
"\"select *\n from MultilingualTranslations\n where mtSectionID = ?\n order by \"",
".",
"(",
"$",
"untranslatedFirst",
"?",
"\"if(ifnull(msgstr, '') = '', 0, 1), \"",
":",
"\"\"",
")",
".",
"\"mtID\"",
",",
"[",
"$",
"this",
"->",
"getCollectionID",
"(",
")",
"]",
")",
";",
"while",
"(",
"$",
"row",
"=",
"$",
"r",
"->",
"fetch",
"(",
")",
")",
"{",
"$",
"t",
"=",
"Translation",
"::",
"getByRow",
"(",
"$",
"row",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"t",
")",
")",
"{",
"$",
"translations",
"[",
"]",
"=",
"$",
"t",
";",
"}",
"}",
"return",
"$",
"translations",
";",
"}"
] | Loads the translations of this multilingual section.
@param bool $untranslatedFirst Set to true to have untranslated strings first
@return \Gettext\Translations | [
"Loads",
"the",
"translations",
"of",
"this",
"multilingual",
"section",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Multilingual/Page/Section/Section.php#L638-L659 | train |
concrete5/concrete5 | concrete/src/Page/Sitemap/PageListGenerator.php | PageListGenerator.generatePageList | public function generatePageList()
{
$this->now = new DateTime();
$siteTreeIDList = array_merge([0], $this->getSiteTreesIDList());
$connection = $this->getConnection();
$rs = $connection->executeQuery('select cID from Pages where siteTreeID is null or siteTreeID in (' . implode(', ', $siteTreeIDList) . ')');
while (($cID = $rs->fetchColumn()) !== false) {
$page = Page::getByID($cID, 'ACTIVE');
if ($page && $this->canIncludePageInSitemap($page)) {
yield $page;
}
}
} | php | public function generatePageList()
{
$this->now = new DateTime();
$siteTreeIDList = array_merge([0], $this->getSiteTreesIDList());
$connection = $this->getConnection();
$rs = $connection->executeQuery('select cID from Pages where siteTreeID is null or siteTreeID in (' . implode(', ', $siteTreeIDList) . ')');
while (($cID = $rs->fetchColumn()) !== false) {
$page = Page::getByID($cID, 'ACTIVE');
if ($page && $this->canIncludePageInSitemap($page)) {
yield $page;
}
}
} | [
"public",
"function",
"generatePageList",
"(",
")",
"{",
"$",
"this",
"->",
"now",
"=",
"new",
"DateTime",
"(",
")",
";",
"$",
"siteTreeIDList",
"=",
"array_merge",
"(",
"[",
"0",
"]",
",",
"$",
"this",
"->",
"getSiteTreesIDList",
"(",
")",
")",
";",
"$",
"connection",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
";",
"$",
"rs",
"=",
"$",
"connection",
"->",
"executeQuery",
"(",
"'select cID from Pages where siteTreeID is null or siteTreeID in ('",
".",
"implode",
"(",
"', '",
",",
"$",
"siteTreeIDList",
")",
".",
"')'",
")",
";",
"while",
"(",
"(",
"$",
"cID",
"=",
"$",
"rs",
"->",
"fetchColumn",
"(",
")",
")",
"!==",
"false",
")",
"{",
"$",
"page",
"=",
"Page",
"::",
"getByID",
"(",
"$",
"cID",
",",
"'ACTIVE'",
")",
";",
"if",
"(",
"$",
"page",
"&&",
"$",
"this",
"->",
"canIncludePageInSitemap",
"(",
"$",
"page",
")",
")",
"{",
"yield",
"$",
"page",
";",
"}",
"}",
"}"
] | Generate the list of pages that should be included in the sitemap.
@return \Concrete\Core\Page\Page|\Generator | [
"Generate",
"the",
"list",
"of",
"pages",
"that",
"should",
"be",
"included",
"in",
"the",
"sitemap",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Sitemap/PageListGenerator.php#L105-L117 | train |
concrete5/concrete5 | concrete/src/Page/Sitemap/PageListGenerator.php | PageListGenerator.isMultilingualEnabled | public function isMultilingualEnabled()
{
if ($this->isMultilingualEnabled === null) {
$this->isMultilingualEnabled = count($this->getMultilingualSections()) > 1;
}
return $this->isMultilingualEnabled;
} | php | public function isMultilingualEnabled()
{
if ($this->isMultilingualEnabled === null) {
$this->isMultilingualEnabled = count($this->getMultilingualSections()) > 1;
}
return $this->isMultilingualEnabled;
} | [
"public",
"function",
"isMultilingualEnabled",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isMultilingualEnabled",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"isMultilingualEnabled",
"=",
"count",
"(",
"$",
"this",
"->",
"getMultilingualSections",
"(",
")",
")",
">",
"1",
";",
"}",
"return",
"$",
"this",
"->",
"isMultilingualEnabled",
";",
"}"
] | Check if the current site has more than one multilingual section.
@return bool | [
"Check",
"if",
"the",
"current",
"site",
"has",
"more",
"than",
"one",
"multilingual",
"section",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Sitemap/PageListGenerator.php#L124-L131 | train |
concrete5/concrete5 | concrete/src/Page/Sitemap/PageListGenerator.php | PageListGenerator.getMultilingualSections | public function getMultilingualSections()
{
if ($this->multilingualSections === null) {
$site = $this->getSite();
if ($site === null) {
$this->multilingualSections = [];
} else {
$list = [];
foreach (MultilingualSection::getList($site) as $section) {
$list[$section->getCollectionID()] = $section;
}
$this->multilingualSections = $list;
}
}
return $this->multilingualSections;
} | php | public function getMultilingualSections()
{
if ($this->multilingualSections === null) {
$site = $this->getSite();
if ($site === null) {
$this->multilingualSections = [];
} else {
$list = [];
foreach (MultilingualSection::getList($site) as $section) {
$list[$section->getCollectionID()] = $section;
}
$this->multilingualSections = $list;
}
}
return $this->multilingualSections;
} | [
"public",
"function",
"getMultilingualSections",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"multilingualSections",
"===",
"null",
")",
"{",
"$",
"site",
"=",
"$",
"this",
"->",
"getSite",
"(",
")",
";",
"if",
"(",
"$",
"site",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"multilingualSections",
"=",
"[",
"]",
";",
"}",
"else",
"{",
"$",
"list",
"=",
"[",
"]",
";",
"foreach",
"(",
"MultilingualSection",
"::",
"getList",
"(",
"$",
"site",
")",
"as",
"$",
"section",
")",
"{",
"$",
"list",
"[",
"$",
"section",
"->",
"getCollectionID",
"(",
")",
"]",
"=",
"$",
"section",
";",
"}",
"$",
"this",
"->",
"multilingualSections",
"=",
"$",
"list",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"multilingualSections",
";",
"}"
] | Get the list of multilingual sections defined for the current site.
@return \Concrete\Core\Multilingual\Page\Section\Section[] | [
"Get",
"the",
"list",
"of",
"multilingual",
"sections",
"defined",
"for",
"the",
"current",
"site",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Sitemap/PageListGenerator.php#L162-L178 | train |
concrete5/concrete5 | concrete/src/Page/Sitemap/PageListGenerator.php | PageListGenerator.canIncludePageInSitemap | public function canIncludePageInSitemap(Page $page)
{
$result = false;
if ($this->isPageStandard($page)) {
if ($this->isPagePublished($page)) {
if (!$this->isPageExcludedFromSitemap($page)) {
if ($this->isPageAccessible($page)) {
$result = true;
}
}
}
}
return $result;
} | php | public function canIncludePageInSitemap(Page $page)
{
$result = false;
if ($this->isPageStandard($page)) {
if ($this->isPagePublished($page)) {
if (!$this->isPageExcludedFromSitemap($page)) {
if ($this->isPageAccessible($page)) {
$result = true;
}
}
}
}
return $result;
} | [
"public",
"function",
"canIncludePageInSitemap",
"(",
"Page",
"$",
"page",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"isPageStandard",
"(",
"$",
"page",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isPagePublished",
"(",
"$",
"page",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isPageExcludedFromSitemap",
"(",
"$",
"page",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isPageAccessible",
"(",
"$",
"page",
")",
")",
"{",
"$",
"result",
"=",
"true",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Should a page be included in the sitemap?
@param Page $page
@return bool | [
"Should",
"a",
"page",
"be",
"included",
"in",
"the",
"sitemap?"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Sitemap/PageListGenerator.php#L187-L201 | train |
concrete5/concrete5 | concrete/src/Page/Sitemap/PageListGenerator.php | PageListGenerator.getSite | public function getSite()
{
if ($this->site === false) {
$this->site = $this->app->make('site')->getDefault();
}
return $this->site;
} | php | public function getSite()
{
if ($this->site === false) {
$this->site = $this->app->make('site')->getDefault();
}
return $this->site;
} | [
"public",
"function",
"getSite",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"site",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"site",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'site'",
")",
"->",
"getDefault",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"site",
";",
"}"
] | Get the currently used site.
@return \Concrete\Core\Entity\Site\Site|null | [
"Get",
"the",
"currently",
"used",
"site",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Sitemap/PageListGenerator.php#L208-L215 | train |
concrete5/concrete5 | concrete/src/Page/Sitemap/PageListGenerator.php | PageListGenerator.setSite | public function setSite(Site $site)
{
if ($this->site !== $site) {
$this->site = $site;
$this->multilingualSections = null;
$this->isMultilingualEnabled = null;
}
return $this;
} | php | public function setSite(Site $site)
{
if ($this->site !== $site) {
$this->site = $site;
$this->multilingualSections = null;
$this->isMultilingualEnabled = null;
}
return $this;
} | [
"public",
"function",
"setSite",
"(",
"Site",
"$",
"site",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"site",
"!==",
"$",
"site",
")",
"{",
"$",
"this",
"->",
"site",
"=",
"$",
"site",
";",
"$",
"this",
"->",
"multilingualSections",
"=",
"null",
";",
"$",
"this",
"->",
"isMultilingualEnabled",
"=",
"null",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set the currently used site.
@param Site $site
@return $this | [
"Set",
"the",
"currently",
"used",
"site",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Sitemap/PageListGenerator.php#L224-L233 | train |
concrete5/concrete5 | concrete/src/Package/ContentSwapper.php | ContentSwapper.swapContent | public function swapContent(Package $package, $options)
{
if ($this->validateClearSiteContents($options)) {
\Core::make('cache/request')->disable();
$pl = new PageList();
$pages = $pl->getResults();
foreach ($pages as $c) {
$c->delete();
}
$fl = new FileList();
$files = $fl->getResults();
foreach ($files as $f) {
$f->delete();
}
// clear stacks
$sl = new StackList();
foreach ($sl->get() as $c) {
$c->delete();
}
$home = \Page::getByID(\Page::getHomePageID());
$blocks = $home->getBlocks();
foreach ($blocks as $b) {
$b->deleteBlock();
}
$pageTypes = Type::getList();
foreach ($pageTypes as $ct) {
$ct->delete();
}
// Set the page type of the home page to 0, because
// if it has a type the type will be gone since we just
// deleted it
$home = Page::getByID(\Page::getHomePageID());
$home->setPageType(null);
// now we add in any files that this package has
if (is_dir($package->getPackagePath() . '/content_files')) {
$ch = new ContentImporter();
$computeThumbnails = true;
if ($package->contentProvidesFileThumbnails()) {
$computeThumbnails = false;
}
$ch->importFiles($package->getPackagePath() . '/content_files', $computeThumbnails);
}
// now we parse the content.xml if it exists.
$ci = new ContentImporter();
$ci->importContentFile($package->getPackagePath() . '/content.xml');
\Core::make('cache/request')->enable();
}
} | php | public function swapContent(Package $package, $options)
{
if ($this->validateClearSiteContents($options)) {
\Core::make('cache/request')->disable();
$pl = new PageList();
$pages = $pl->getResults();
foreach ($pages as $c) {
$c->delete();
}
$fl = new FileList();
$files = $fl->getResults();
foreach ($files as $f) {
$f->delete();
}
// clear stacks
$sl = new StackList();
foreach ($sl->get() as $c) {
$c->delete();
}
$home = \Page::getByID(\Page::getHomePageID());
$blocks = $home->getBlocks();
foreach ($blocks as $b) {
$b->deleteBlock();
}
$pageTypes = Type::getList();
foreach ($pageTypes as $ct) {
$ct->delete();
}
// Set the page type of the home page to 0, because
// if it has a type the type will be gone since we just
// deleted it
$home = Page::getByID(\Page::getHomePageID());
$home->setPageType(null);
// now we add in any files that this package has
if (is_dir($package->getPackagePath() . '/content_files')) {
$ch = new ContentImporter();
$computeThumbnails = true;
if ($package->contentProvidesFileThumbnails()) {
$computeThumbnails = false;
}
$ch->importFiles($package->getPackagePath() . '/content_files', $computeThumbnails);
}
// now we parse the content.xml if it exists.
$ci = new ContentImporter();
$ci->importContentFile($package->getPackagePath() . '/content.xml');
\Core::make('cache/request')->enable();
}
} | [
"public",
"function",
"swapContent",
"(",
"Package",
"$",
"package",
",",
"$",
"options",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"validateClearSiteContents",
"(",
"$",
"options",
")",
")",
"{",
"\\",
"Core",
"::",
"make",
"(",
"'cache/request'",
")",
"->",
"disable",
"(",
")",
";",
"$",
"pl",
"=",
"new",
"PageList",
"(",
")",
";",
"$",
"pages",
"=",
"$",
"pl",
"->",
"getResults",
"(",
")",
";",
"foreach",
"(",
"$",
"pages",
"as",
"$",
"c",
")",
"{",
"$",
"c",
"->",
"delete",
"(",
")",
";",
"}",
"$",
"fl",
"=",
"new",
"FileList",
"(",
")",
";",
"$",
"files",
"=",
"$",
"fl",
"->",
"getResults",
"(",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"f",
")",
"{",
"$",
"f",
"->",
"delete",
"(",
")",
";",
"}",
"// clear stacks",
"$",
"sl",
"=",
"new",
"StackList",
"(",
")",
";",
"foreach",
"(",
"$",
"sl",
"->",
"get",
"(",
")",
"as",
"$",
"c",
")",
"{",
"$",
"c",
"->",
"delete",
"(",
")",
";",
"}",
"$",
"home",
"=",
"\\",
"Page",
"::",
"getByID",
"(",
"\\",
"Page",
"::",
"getHomePageID",
"(",
")",
")",
";",
"$",
"blocks",
"=",
"$",
"home",
"->",
"getBlocks",
"(",
")",
";",
"foreach",
"(",
"$",
"blocks",
"as",
"$",
"b",
")",
"{",
"$",
"b",
"->",
"deleteBlock",
"(",
")",
";",
"}",
"$",
"pageTypes",
"=",
"Type",
"::",
"getList",
"(",
")",
";",
"foreach",
"(",
"$",
"pageTypes",
"as",
"$",
"ct",
")",
"{",
"$",
"ct",
"->",
"delete",
"(",
")",
";",
"}",
"// Set the page type of the home page to 0, because",
"// if it has a type the type will be gone since we just",
"// deleted it",
"$",
"home",
"=",
"Page",
"::",
"getByID",
"(",
"\\",
"Page",
"::",
"getHomePageID",
"(",
")",
")",
";",
"$",
"home",
"->",
"setPageType",
"(",
"null",
")",
";",
"// now we add in any files that this package has",
"if",
"(",
"is_dir",
"(",
"$",
"package",
"->",
"getPackagePath",
"(",
")",
".",
"'/content_files'",
")",
")",
"{",
"$",
"ch",
"=",
"new",
"ContentImporter",
"(",
")",
";",
"$",
"computeThumbnails",
"=",
"true",
";",
"if",
"(",
"$",
"package",
"->",
"contentProvidesFileThumbnails",
"(",
")",
")",
"{",
"$",
"computeThumbnails",
"=",
"false",
";",
"}",
"$",
"ch",
"->",
"importFiles",
"(",
"$",
"package",
"->",
"getPackagePath",
"(",
")",
".",
"'/content_files'",
",",
"$",
"computeThumbnails",
")",
";",
"}",
"// now we parse the content.xml if it exists.",
"$",
"ci",
"=",
"new",
"ContentImporter",
"(",
")",
";",
"$",
"ci",
"->",
"importContentFile",
"(",
"$",
"package",
"->",
"getPackagePath",
"(",
")",
".",
"'/content.xml'",
")",
";",
"\\",
"Core",
"::",
"make",
"(",
"'cache/request'",
")",
"->",
"enable",
"(",
")",
";",
"}",
"}"
] | Removes any existing pages, files, stacks, block and page types and installs content from the package.
@param $options | [
"Removes",
"any",
"existing",
"pages",
"files",
"stacks",
"block",
"and",
"page",
"types",
"and",
"installs",
"content",
"from",
"the",
"package",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Package/ContentSwapper.php#L44-L101 | train |
concrete5/concrete5 | concrete/src/Support/Symbol/ClassSymbol/ClassSymbol.php | ClassSymbol.resolveMethods | protected function resolveMethods()
{
$methods = $this->reflectionClass->getMethods();
if ($this->isFacade()) {
$methods = array_merge($methods, $this->getFacadeReflectionClass()->getMethods());
}
foreach ($methods as $method) {
$this->methods[] = new MethodSymbol($this, $method);
}
} | php | protected function resolveMethods()
{
$methods = $this->reflectionClass->getMethods();
if ($this->isFacade()) {
$methods = array_merge($methods, $this->getFacadeReflectionClass()->getMethods());
}
foreach ($methods as $method) {
$this->methods[] = new MethodSymbol($this, $method);
}
} | [
"protected",
"function",
"resolveMethods",
"(",
")",
"{",
"$",
"methods",
"=",
"$",
"this",
"->",
"reflectionClass",
"->",
"getMethods",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isFacade",
"(",
")",
")",
"{",
"$",
"methods",
"=",
"array_merge",
"(",
"$",
"methods",
",",
"$",
"this",
"->",
"getFacadeReflectionClass",
"(",
")",
"->",
"getMethods",
"(",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"method",
")",
"{",
"$",
"this",
"->",
"methods",
"[",
"]",
"=",
"new",
"MethodSymbol",
"(",
"$",
"this",
",",
"$",
"method",
")",
";",
"}",
"}"
] | Get the methods. | [
"Get",
"the",
"methods",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Support/Symbol/ClassSymbol/ClassSymbol.php#L108-L117 | train |
concrete5/concrete5 | concrete/src/Support/Symbol/ClassSymbol/ClassSymbol.php | ClassSymbol.render | public function render($eol = "\n", $padding = ' ', $methodFilter = null)
{
$rendered = '';
$comment = $this->comment;
if ($comment !== false) {
$comment = trim($comment);
if ($comment !== '') {
$rendered .= str_replace($eol . '*', $eol . ' *', implode($eol, array_map('trim', explode("\n", $comment)))) . $eol;
}
}
if ($this->reflectionClass->isAbstract()) {
$rendered .= 'abstract ';
}
$rendered .= 'class ' . $this->aliasBasename . ' extends \\' . $this->fqn . "{$eol}{{$eol}";
$firstMethod = true;
foreach ($this->methods as $method) {
if (is_callable($methodFilter) && (call_user_func($methodFilter, $this, $method) === false)) {
continue;
}
if ($firstMethod) {
$firstMethod = false;
if ($this->isFacade()) {
$rendered .= $padding . '/**' . $eol . $padding . ' * @var ' . $this->fqn . $eol . $padding . ' */' . $eol;
$rendered .= $padding . 'protected static $instance;' . $eol;
}
}
$rendered_method = $method->render($eol, $padding);
if ($rendered_method !== '') {
$rendered .= $padding . rtrim(str_replace($eol, $eol . $padding, $rendered_method)) . $eol;
}
}
$rendered .= "}{$eol}";
return $rendered;
} | php | public function render($eol = "\n", $padding = ' ', $methodFilter = null)
{
$rendered = '';
$comment = $this->comment;
if ($comment !== false) {
$comment = trim($comment);
if ($comment !== '') {
$rendered .= str_replace($eol . '*', $eol . ' *', implode($eol, array_map('trim', explode("\n", $comment)))) . $eol;
}
}
if ($this->reflectionClass->isAbstract()) {
$rendered .= 'abstract ';
}
$rendered .= 'class ' . $this->aliasBasename . ' extends \\' . $this->fqn . "{$eol}{{$eol}";
$firstMethod = true;
foreach ($this->methods as $method) {
if (is_callable($methodFilter) && (call_user_func($methodFilter, $this, $method) === false)) {
continue;
}
if ($firstMethod) {
$firstMethod = false;
if ($this->isFacade()) {
$rendered .= $padding . '/**' . $eol . $padding . ' * @var ' . $this->fqn . $eol . $padding . ' */' . $eol;
$rendered .= $padding . 'protected static $instance;' . $eol;
}
}
$rendered_method = $method->render($eol, $padding);
if ($rendered_method !== '') {
$rendered .= $padding . rtrim(str_replace($eol, $eol . $padding, $rendered_method)) . $eol;
}
}
$rendered .= "}{$eol}";
return $rendered;
} | [
"public",
"function",
"render",
"(",
"$",
"eol",
"=",
"\"\\n\"",
",",
"$",
"padding",
"=",
"' '",
",",
"$",
"methodFilter",
"=",
"null",
")",
"{",
"$",
"rendered",
"=",
"''",
";",
"$",
"comment",
"=",
"$",
"this",
"->",
"comment",
";",
"if",
"(",
"$",
"comment",
"!==",
"false",
")",
"{",
"$",
"comment",
"=",
"trim",
"(",
"$",
"comment",
")",
";",
"if",
"(",
"$",
"comment",
"!==",
"''",
")",
"{",
"$",
"rendered",
".=",
"str_replace",
"(",
"$",
"eol",
".",
"'*'",
",",
"$",
"eol",
".",
"' *'",
",",
"implode",
"(",
"$",
"eol",
",",
"array_map",
"(",
"'trim'",
",",
"explode",
"(",
"\"\\n\"",
",",
"$",
"comment",
")",
")",
")",
")",
".",
"$",
"eol",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"reflectionClass",
"->",
"isAbstract",
"(",
")",
")",
"{",
"$",
"rendered",
".=",
"'abstract '",
";",
"}",
"$",
"rendered",
".=",
"'class '",
".",
"$",
"this",
"->",
"aliasBasename",
".",
"' extends \\\\'",
".",
"$",
"this",
"->",
"fqn",
".",
"\"{$eol}{{$eol}\"",
";",
"$",
"firstMethod",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"methods",
"as",
"$",
"method",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"methodFilter",
")",
"&&",
"(",
"call_user_func",
"(",
"$",
"methodFilter",
",",
"$",
"this",
",",
"$",
"method",
")",
"===",
"false",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"firstMethod",
")",
"{",
"$",
"firstMethod",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"isFacade",
"(",
")",
")",
"{",
"$",
"rendered",
".=",
"$",
"padding",
".",
"'/**'",
".",
"$",
"eol",
".",
"$",
"padding",
".",
"' * @var '",
".",
"$",
"this",
"->",
"fqn",
".",
"$",
"eol",
".",
"$",
"padding",
".",
"' */'",
".",
"$",
"eol",
";",
"$",
"rendered",
".=",
"$",
"padding",
".",
"'protected static $instance;'",
".",
"$",
"eol",
";",
"}",
"}",
"$",
"rendered_method",
"=",
"$",
"method",
"->",
"render",
"(",
"$",
"eol",
",",
"$",
"padding",
")",
";",
"if",
"(",
"$",
"rendered_method",
"!==",
"''",
")",
"{",
"$",
"rendered",
".=",
"$",
"padding",
".",
"rtrim",
"(",
"str_replace",
"(",
"$",
"eol",
",",
"$",
"eol",
".",
"$",
"padding",
",",
"$",
"rendered_method",
")",
")",
".",
"$",
"eol",
";",
"}",
"}",
"$",
"rendered",
".=",
"\"}{$eol}\"",
";",
"return",
"$",
"rendered",
";",
"}"
] | Render Class with methods.
@param string $eol
@param string $padding
@param callable|null $methodFilter
@return string | [
"Render",
"Class",
"with",
"methods",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Support/Symbol/ClassSymbol/ClassSymbol.php#L144-L178 | train |
concrete5/concrete5 | concrete/src/Database/Connection/Timezone.php | Timezone.getCompatibleTimezones | public function getCompatibleTimezones()
{
$validTimezones = [];
foreach ($this->dateHelper->getTimezones() as $timezoneID => $timezoneName) {
if ($this->getDeltaTimezone($timezoneID) === null) {
$validTimezones[$timezoneID] = $timezoneName;
}
}
return $validTimezones;
} | php | public function getCompatibleTimezones()
{
$validTimezones = [];
foreach ($this->dateHelper->getTimezones() as $timezoneID => $timezoneName) {
if ($this->getDeltaTimezone($timezoneID) === null) {
$validTimezones[$timezoneID] = $timezoneName;
}
}
return $validTimezones;
} | [
"public",
"function",
"getCompatibleTimezones",
"(",
")",
"{",
"$",
"validTimezones",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"dateHelper",
"->",
"getTimezones",
"(",
")",
"as",
"$",
"timezoneID",
"=>",
"$",
"timezoneName",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getDeltaTimezone",
"(",
"$",
"timezoneID",
")",
"===",
"null",
")",
"{",
"$",
"validTimezones",
"[",
"$",
"timezoneID",
"]",
"=",
"$",
"timezoneName",
";",
"}",
"}",
"return",
"$",
"validTimezones",
";",
"}"
] | Get a list of time zones that are compatible with the database.
@return array array keys are the time zone IDs (eg: 'Pacific/Pago_Pago'), array values are the localized time zone names | [
"Get",
"a",
"list",
"of",
"time",
"zones",
"that",
"are",
"compatible",
"with",
"the",
"database",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Database/Connection/Timezone.php#L43-L53 | train |
concrete5/concrete5 | concrete/src/Database/Connection/Timezone.php | Timezone.getDeltaTimezone | public function getDeltaTimezone($phpTimezone)
{
if (!($phpTimezone instanceof DateTimeZone)) {
$phpTimezone = new DateTimeZone($phpTimezone);
}
$data = $this->getDatabaseTimestamps();
extract($data);
$sometimesSame = false;
$maxDeltaMinutes = 0;
foreach ($timestamps as $index => $timestamp) {
$databaseValue = new DateTime($databaseDatetimes[$index], $phpTimezone);
$phpValue = DateTime::createFromFormat('U', $timestamp, $phpTimezone);
$deltaMinutes = (int) floor(($phpValue->getTimestamp() - $databaseValue->getTimestamp()) / 60);
if ($deltaMinutes === 0) {
$sometimesSame = true;
} else {
if (abs($deltaMinutes) > abs($maxDeltaMinutes)) {
$maxDeltaMinutes = $deltaMinutes;
}
}
}
if ($maxDeltaMinutes === 0) {
return null;
} else {
return [
'dstProblems' => $sometimesSame,
'maxDeltaMinutes' => $maxDeltaMinutes,
];
}
} | php | public function getDeltaTimezone($phpTimezone)
{
if (!($phpTimezone instanceof DateTimeZone)) {
$phpTimezone = new DateTimeZone($phpTimezone);
}
$data = $this->getDatabaseTimestamps();
extract($data);
$sometimesSame = false;
$maxDeltaMinutes = 0;
foreach ($timestamps as $index => $timestamp) {
$databaseValue = new DateTime($databaseDatetimes[$index], $phpTimezone);
$phpValue = DateTime::createFromFormat('U', $timestamp, $phpTimezone);
$deltaMinutes = (int) floor(($phpValue->getTimestamp() - $databaseValue->getTimestamp()) / 60);
if ($deltaMinutes === 0) {
$sometimesSame = true;
} else {
if (abs($deltaMinutes) > abs($maxDeltaMinutes)) {
$maxDeltaMinutes = $deltaMinutes;
}
}
}
if ($maxDeltaMinutes === 0) {
return null;
} else {
return [
'dstProblems' => $sometimesSame,
'maxDeltaMinutes' => $maxDeltaMinutes,
];
}
} | [
"public",
"function",
"getDeltaTimezone",
"(",
"$",
"phpTimezone",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"phpTimezone",
"instanceof",
"DateTimeZone",
")",
")",
"{",
"$",
"phpTimezone",
"=",
"new",
"DateTimeZone",
"(",
"$",
"phpTimezone",
")",
";",
"}",
"$",
"data",
"=",
"$",
"this",
"->",
"getDatabaseTimestamps",
"(",
")",
";",
"extract",
"(",
"$",
"data",
")",
";",
"$",
"sometimesSame",
"=",
"false",
";",
"$",
"maxDeltaMinutes",
"=",
"0",
";",
"foreach",
"(",
"$",
"timestamps",
"as",
"$",
"index",
"=>",
"$",
"timestamp",
")",
"{",
"$",
"databaseValue",
"=",
"new",
"DateTime",
"(",
"$",
"databaseDatetimes",
"[",
"$",
"index",
"]",
",",
"$",
"phpTimezone",
")",
";",
"$",
"phpValue",
"=",
"DateTime",
"::",
"createFromFormat",
"(",
"'U'",
",",
"$",
"timestamp",
",",
"$",
"phpTimezone",
")",
";",
"$",
"deltaMinutes",
"=",
"(",
"int",
")",
"floor",
"(",
"(",
"$",
"phpValue",
"->",
"getTimestamp",
"(",
")",
"-",
"$",
"databaseValue",
"->",
"getTimestamp",
"(",
")",
")",
"/",
"60",
")",
";",
"if",
"(",
"$",
"deltaMinutes",
"===",
"0",
")",
"{",
"$",
"sometimesSame",
"=",
"true",
";",
"}",
"else",
"{",
"if",
"(",
"abs",
"(",
"$",
"deltaMinutes",
")",
">",
"abs",
"(",
"$",
"maxDeltaMinutes",
")",
")",
"{",
"$",
"maxDeltaMinutes",
"=",
"$",
"deltaMinutes",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"maxDeltaMinutes",
"===",
"0",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"[",
"'dstProblems'",
"=>",
"$",
"sometimesSame",
",",
"'maxDeltaMinutes'",
"=>",
"$",
"maxDeltaMinutes",
",",
"]",
";",
"}",
"}"
] | Check if a PHP time zone is compatible with the database timezone.
@param DateTimeZone|string $phpTimezone
@throws \Exception throws an Exception if $phpTimezone is not recognised as a valid timezone
@return null|array If the time zone matches, we'll return null, otherwise an array with the keys 'dstProblems' (boolean) and 'maxDeltaMinutes' (int) | [
"Check",
"if",
"a",
"PHP",
"time",
"zone",
"is",
"compatible",
"with",
"the",
"database",
"timezone",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Database/Connection/Timezone.php#L64-L94 | train |
concrete5/concrete5 | concrete/src/File/Search/SearchProvider.php | SearchProvider.getItemsPerPageSession | public function getItemsPerPageSession()
{
$variable = 'search/' . $this->getSessionNamespace() . '/items_per_page';
if ($this->session->has($variable)) {
return (int) $this->session->get($variable);
}
return null;
} | php | public function getItemsPerPageSession()
{
$variable = 'search/' . $this->getSessionNamespace() . '/items_per_page';
if ($this->session->has($variable)) {
return (int) $this->session->get($variable);
}
return null;
} | [
"public",
"function",
"getItemsPerPageSession",
"(",
")",
"{",
"$",
"variable",
"=",
"'search/'",
".",
"$",
"this",
"->",
"getSessionNamespace",
"(",
")",
".",
"'/items_per_page'",
";",
"if",
"(",
"$",
"this",
"->",
"session",
"->",
"has",
"(",
"$",
"variable",
")",
")",
"{",
"return",
"(",
"int",
")",
"$",
"this",
"->",
"session",
"->",
"get",
"(",
"$",
"variable",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Retrieve the items per page option from the session.
@return int|null | [
"Retrieve",
"the",
"items",
"per",
"page",
"option",
"from",
"the",
"session",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/File/Search/SearchProvider.php#L162-L170 | train |
concrete5/concrete5 | concrete/controllers/backend/file/thumbnailer.php | Thumbnailer.attemptBuild | private function attemptBuild(File $file, array $thumbnail)
{
try {
// If the file is already built, return early
if ($this->isBuilt($file, $thumbnail)) {
return true;
}
// Otherwise lets attempt to build it
if ($dimensions = $this->getDimensions($thumbnail)) {
list($width, $height, $crop) = $dimensions;
$type = new CustomThumbnail($width, $height, $thumbnail['path'], $crop);
$fv = $file->getVersion($thumbnail['fileVersionID']);
if ($fv->getTypeObject()->supportsThumbnails()) {
$fv->generateThumbnail($type);
$fv->releaseImagineImage();
}
} elseif ($type = Version::getByHandle($thumbnail['thumbnailTypeHandle'])) {
// This is a predefined thumbnail type, lets just call the version->rescan
$fv = $file->getVersion($thumbnail['fileVersionID']);
if ($fv->getTypeObject()->supportsThumbnails()) {
$fv->generateThumbnail($type);
$fv->releaseImagineImage();
}
}
} catch (\Exception $e) {
// Catch any exceptions so we don't break the page and return false
return false;
}
return $this->isBuilt($file, $thumbnail);
} | php | private function attemptBuild(File $file, array $thumbnail)
{
try {
// If the file is already built, return early
if ($this->isBuilt($file, $thumbnail)) {
return true;
}
// Otherwise lets attempt to build it
if ($dimensions = $this->getDimensions($thumbnail)) {
list($width, $height, $crop) = $dimensions;
$type = new CustomThumbnail($width, $height, $thumbnail['path'], $crop);
$fv = $file->getVersion($thumbnail['fileVersionID']);
if ($fv->getTypeObject()->supportsThumbnails()) {
$fv->generateThumbnail($type);
$fv->releaseImagineImage();
}
} elseif ($type = Version::getByHandle($thumbnail['thumbnailTypeHandle'])) {
// This is a predefined thumbnail type, lets just call the version->rescan
$fv = $file->getVersion($thumbnail['fileVersionID']);
if ($fv->getTypeObject()->supportsThumbnails()) {
$fv->generateThumbnail($type);
$fv->releaseImagineImage();
}
}
} catch (\Exception $e) {
// Catch any exceptions so we don't break the page and return false
return false;
}
return $this->isBuilt($file, $thumbnail);
} | [
"private",
"function",
"attemptBuild",
"(",
"File",
"$",
"file",
",",
"array",
"$",
"thumbnail",
")",
"{",
"try",
"{",
"// If the file is already built, return early",
"if",
"(",
"$",
"this",
"->",
"isBuilt",
"(",
"$",
"file",
",",
"$",
"thumbnail",
")",
")",
"{",
"return",
"true",
";",
"}",
"// Otherwise lets attempt to build it",
"if",
"(",
"$",
"dimensions",
"=",
"$",
"this",
"->",
"getDimensions",
"(",
"$",
"thumbnail",
")",
")",
"{",
"list",
"(",
"$",
"width",
",",
"$",
"height",
",",
"$",
"crop",
")",
"=",
"$",
"dimensions",
";",
"$",
"type",
"=",
"new",
"CustomThumbnail",
"(",
"$",
"width",
",",
"$",
"height",
",",
"$",
"thumbnail",
"[",
"'path'",
"]",
",",
"$",
"crop",
")",
";",
"$",
"fv",
"=",
"$",
"file",
"->",
"getVersion",
"(",
"$",
"thumbnail",
"[",
"'fileVersionID'",
"]",
")",
";",
"if",
"(",
"$",
"fv",
"->",
"getTypeObject",
"(",
")",
"->",
"supportsThumbnails",
"(",
")",
")",
"{",
"$",
"fv",
"->",
"generateThumbnail",
"(",
"$",
"type",
")",
";",
"$",
"fv",
"->",
"releaseImagineImage",
"(",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"type",
"=",
"Version",
"::",
"getByHandle",
"(",
"$",
"thumbnail",
"[",
"'thumbnailTypeHandle'",
"]",
")",
")",
"{",
"// This is a predefined thumbnail type, lets just call the version->rescan",
"$",
"fv",
"=",
"$",
"file",
"->",
"getVersion",
"(",
"$",
"thumbnail",
"[",
"'fileVersionID'",
"]",
")",
";",
"if",
"(",
"$",
"fv",
"->",
"getTypeObject",
"(",
")",
"->",
"supportsThumbnails",
"(",
")",
")",
"{",
"$",
"fv",
"->",
"generateThumbnail",
"(",
"$",
"type",
")",
";",
"$",
"fv",
"->",
"releaseImagineImage",
"(",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// Catch any exceptions so we don't break the page and return false",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"isBuilt",
"(",
"$",
"file",
",",
"$",
"thumbnail",
")",
";",
"}"
] | Try building an unbuilt thumbnail.
@param \Concrete\Core\Entity\File\File $file
@param array $thumbnail
@return bool | [
"Try",
"building",
"an",
"unbuilt",
"thumbnail",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/controllers/backend/file/thumbnailer.php#L71-L103 | train |
concrete5/concrete5 | concrete/controllers/backend/file/thumbnailer.php | Thumbnailer.getDimensions | private function getDimensions($thumbnail)
{
$matches = null;
if (preg_match('/^ccm_(\d+)x(\d+)(?:_([10]))?$/', $thumbnail['thumbnailTypeHandle'], $matches)) {
return array_pad(array_slice($matches, 1), 3, 0);
}
} | php | private function getDimensions($thumbnail)
{
$matches = null;
if (preg_match('/^ccm_(\d+)x(\d+)(?:_([10]))?$/', $thumbnail['thumbnailTypeHandle'], $matches)) {
return array_pad(array_slice($matches, 1), 3, 0);
}
} | [
"private",
"function",
"getDimensions",
"(",
"$",
"thumbnail",
")",
"{",
"$",
"matches",
"=",
"null",
";",
"if",
"(",
"preg_match",
"(",
"'/^ccm_(\\d+)x(\\d+)(?:_([10]))?$/'",
",",
"$",
"thumbnail",
"[",
"'thumbnailTypeHandle'",
"]",
",",
"$",
"matches",
")",
")",
"{",
"return",
"array_pad",
"(",
"array_slice",
"(",
"$",
"matches",
",",
"1",
")",
",",
"3",
",",
"0",
")",
";",
"}",
"}"
] | Get the dimensions out of a thumbnail array.
@param array $thumbnail
@return null|array [ width, height, crop ] | [
"Get",
"the",
"dimensions",
"out",
"of",
"a",
"thumbnail",
"array",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/controllers/backend/file/thumbnailer.php#L124-L130 | train |
concrete5/concrete5 | concrete/src/Form/Service/Widget/DateTime.php | DateTime.selectNearestValue | protected function selectNearestValue(array $values, $wantedValue)
{
if (in_array($wantedValue, $values)) {
$result = $wantedValue;
} else {
$result = null;
$minDelta = PHP_INT_MAX;
foreach ($values as $value) {
$delta = abs($value - $wantedValue);
if ($delta < $minDelta) {
$minDelta = $delta;
$result = $value;
}
}
}
return $result;
} | php | protected function selectNearestValue(array $values, $wantedValue)
{
if (in_array($wantedValue, $values)) {
$result = $wantedValue;
} else {
$result = null;
$minDelta = PHP_INT_MAX;
foreach ($values as $value) {
$delta = abs($value - $wantedValue);
if ($delta < $minDelta) {
$minDelta = $delta;
$result = $value;
}
}
}
return $result;
} | [
"protected",
"function",
"selectNearestValue",
"(",
"array",
"$",
"values",
",",
"$",
"wantedValue",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"wantedValue",
",",
"$",
"values",
")",
")",
"{",
"$",
"result",
"=",
"$",
"wantedValue",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"null",
";",
"$",
"minDelta",
"=",
"PHP_INT_MAX",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"delta",
"=",
"abs",
"(",
"$",
"value",
"-",
"$",
"wantedValue",
")",
";",
"if",
"(",
"$",
"delta",
"<",
"$",
"minDelta",
")",
"{",
"$",
"minDelta",
"=",
"$",
"delta",
";",
"$",
"result",
"=",
"$",
"value",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Choose an array value nearest to a specified value.
Useful when we work with time resolutions.
@param int $values
@param int $wantedValue
@return int
@example If the current time is 10 and the time resolution is 15, we have an array of values of [0, 15, 30, 45]: the closest value is 15. | [
"Choose",
"an",
"array",
"value",
"nearest",
"to",
"a",
"specified",
"value",
".",
"Useful",
"when",
"we",
"work",
"with",
"time",
"resolutions",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Form/Service/Widget/DateTime.php#L432-L449 | train |
concrete5/concrete5 | concrete/src/User/RegistrationService.php | RegistrationService.getNewUsernameFromUserDetails | public function getNewUsernameFromUserDetails($email, $suggestedUsername = '', $firstName = '', $lastName = '')
{
$baseUsername = $this->stringToUsernameChunk($suggestedUsername);
if ($baseUsername === '') {
$firstName = $this->stringToUsernameChunk($firstName);
$lastName = $this->stringToUsernameChunk($lastName);
if ($firstName !== '' || $lastName !== '') {
$baseUsername = trim($firstName . '_' . $lastName, '_');
} else {
$mailbox = strstr((string) $email, '@', true);
$baseUsername = $this->stringToUsernameChunk($mailbox);
}
if ($baseUsername === '') {
$baseUsername = 'user';
}
}
$username = $baseUsername;
$suffix = 1;
while ($this->userInfoRepository->getByName($username) !== null) {
$username = $baseUsername . '_' . $suffix;
++$suffix;
}
return $username;
} | php | public function getNewUsernameFromUserDetails($email, $suggestedUsername = '', $firstName = '', $lastName = '')
{
$baseUsername = $this->stringToUsernameChunk($suggestedUsername);
if ($baseUsername === '') {
$firstName = $this->stringToUsernameChunk($firstName);
$lastName = $this->stringToUsernameChunk($lastName);
if ($firstName !== '' || $lastName !== '') {
$baseUsername = trim($firstName . '_' . $lastName, '_');
} else {
$mailbox = strstr((string) $email, '@', true);
$baseUsername = $this->stringToUsernameChunk($mailbox);
}
if ($baseUsername === '') {
$baseUsername = 'user';
}
}
$username = $baseUsername;
$suffix = 1;
while ($this->userInfoRepository->getByName($username) !== null) {
$username = $baseUsername . '_' . $suffix;
++$suffix;
}
return $username;
} | [
"public",
"function",
"getNewUsernameFromUserDetails",
"(",
"$",
"email",
",",
"$",
"suggestedUsername",
"=",
"''",
",",
"$",
"firstName",
"=",
"''",
",",
"$",
"lastName",
"=",
"''",
")",
"{",
"$",
"baseUsername",
"=",
"$",
"this",
"->",
"stringToUsernameChunk",
"(",
"$",
"suggestedUsername",
")",
";",
"if",
"(",
"$",
"baseUsername",
"===",
"''",
")",
"{",
"$",
"firstName",
"=",
"$",
"this",
"->",
"stringToUsernameChunk",
"(",
"$",
"firstName",
")",
";",
"$",
"lastName",
"=",
"$",
"this",
"->",
"stringToUsernameChunk",
"(",
"$",
"lastName",
")",
";",
"if",
"(",
"$",
"firstName",
"!==",
"''",
"||",
"$",
"lastName",
"!==",
"''",
")",
"{",
"$",
"baseUsername",
"=",
"trim",
"(",
"$",
"firstName",
".",
"'_'",
".",
"$",
"lastName",
",",
"'_'",
")",
";",
"}",
"else",
"{",
"$",
"mailbox",
"=",
"strstr",
"(",
"(",
"string",
")",
"$",
"email",
",",
"'@'",
",",
"true",
")",
";",
"$",
"baseUsername",
"=",
"$",
"this",
"->",
"stringToUsernameChunk",
"(",
"$",
"mailbox",
")",
";",
"}",
"if",
"(",
"$",
"baseUsername",
"===",
"''",
")",
"{",
"$",
"baseUsername",
"=",
"'user'",
";",
"}",
"}",
"$",
"username",
"=",
"$",
"baseUsername",
";",
"$",
"suffix",
"=",
"1",
";",
"while",
"(",
"$",
"this",
"->",
"userInfoRepository",
"->",
"getByName",
"(",
"$",
"username",
")",
"!==",
"null",
")",
"{",
"$",
"username",
"=",
"$",
"baseUsername",
".",
"'_'",
".",
"$",
"suffix",
";",
"++",
"$",
"suffix",
";",
"}",
"return",
"$",
"username",
";",
"}"
] | Create an unused username starting from user details.
@param string $email The user's email address
@param string $suggestedUsername A suggestion about the username
@param string $firstName The user's first name
@param string $lastName The user's last name
@return string | [
"Create",
"an",
"unused",
"username",
"starting",
"from",
"user",
"details",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/RegistrationService.php#L180-L204 | train |
concrete5/concrete5 | concrete/src/Search/Index/DefaultManager.php | DefaultManager.getIndexes | public function getIndexes($type, $includeGlobal=true)
{
// Yield all indexes registered against this type
if (isset($this->indexes[$type])) {
foreach ($this->indexes[$type] as $index) {
yield $type => $this->inflateIndex($index);
}
}
$all = self::TYPE_ALL;
if ($type !== $all && $includeGlobal) {
// Yield all indexes registered against ALL types
if (isset($this->indexes[$all])) {
foreach ($this->indexes[$all] as $key => $index) {
yield $all => $this->inflateIndex($index);
}
}
}
} | php | public function getIndexes($type, $includeGlobal=true)
{
// Yield all indexes registered against this type
if (isset($this->indexes[$type])) {
foreach ($this->indexes[$type] as $index) {
yield $type => $this->inflateIndex($index);
}
}
$all = self::TYPE_ALL;
if ($type !== $all && $includeGlobal) {
// Yield all indexes registered against ALL types
if (isset($this->indexes[$all])) {
foreach ($this->indexes[$all] as $key => $index) {
yield $all => $this->inflateIndex($index);
}
}
}
} | [
"public",
"function",
"getIndexes",
"(",
"$",
"type",
",",
"$",
"includeGlobal",
"=",
"true",
")",
"{",
"// Yield all indexes registered against this type",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"indexes",
"[",
"$",
"type",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"indexes",
"[",
"$",
"type",
"]",
"as",
"$",
"index",
")",
"{",
"yield",
"$",
"type",
"=>",
"$",
"this",
"->",
"inflateIndex",
"(",
"$",
"index",
")",
";",
"}",
"}",
"$",
"all",
"=",
"self",
"::",
"TYPE_ALL",
";",
"if",
"(",
"$",
"type",
"!==",
"$",
"all",
"&&",
"$",
"includeGlobal",
")",
"{",
"// Yield all indexes registered against ALL types",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"indexes",
"[",
"$",
"all",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"indexes",
"[",
"$",
"all",
"]",
"as",
"$",
"key",
"=>",
"$",
"index",
")",
"{",
"yield",
"$",
"all",
"=>",
"$",
"this",
"->",
"inflateIndex",
"(",
"$",
"index",
")",
";",
"}",
"}",
"}",
"}"
] | Get the indexes for a type
@param string $type
@param bool $includeGlobal
@return \Concrete\Core\Search\Index\IndexInterface[]|\Concrete\Core\Search\Index\Iterator | [
"Get",
"the",
"indexes",
"for",
"a",
"type"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Search/Index/DefaultManager.php#L36-L54 | train |
concrete5/concrete5 | concrete/src/Search/Index/DefaultManager.php | DefaultManager.inflateIndex | protected function inflateIndex($class)
{
if ($class instanceof IndexInterface) {
return $class;
}
if (!isset($this->inflated[$class])) {
$this->inflated[$class] = $this->app->make($class);
}
return $this->inflated[$class];
} | php | protected function inflateIndex($class)
{
if ($class instanceof IndexInterface) {
return $class;
}
if (!isset($this->inflated[$class])) {
$this->inflated[$class] = $this->app->make($class);
}
return $this->inflated[$class];
} | [
"protected",
"function",
"inflateIndex",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"class",
"instanceof",
"IndexInterface",
")",
"{",
"return",
"$",
"class",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"inflated",
"[",
"$",
"class",
"]",
")",
")",
"{",
"$",
"this",
"->",
"inflated",
"[",
"$",
"class",
"]",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"$",
"class",
")",
";",
"}",
"return",
"$",
"this",
"->",
"inflated",
"[",
"$",
"class",
"]",
";",
"}"
] | Get the proper index from the stored value
@param $class
@return IndexInterface | [
"Get",
"the",
"proper",
"index",
"from",
"the",
"stored",
"value"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Search/Index/DefaultManager.php#L61-L72 | train |
concrete5/concrete5 | concrete/src/Search/Index/DefaultManager.php | DefaultManager.getAllIndexes | public function getAllIndexes()
{
foreach ($this->indexes as $type => $indexList) {
// If we hit the "ALL" type, skip it for now
if ($type == self::TYPE_ALL) {
continue;
}
// Otherwise yield all indexes registered against this type
foreach ($this->getIndexes($type, false) as $index) {
yield $type => $index;
}
}
foreach ($this->getIndexes(self::TYPE_ALL) as $index) {
yield self::TYPE_ALL => $index;
}
} | php | public function getAllIndexes()
{
foreach ($this->indexes as $type => $indexList) {
// If we hit the "ALL" type, skip it for now
if ($type == self::TYPE_ALL) {
continue;
}
// Otherwise yield all indexes registered against this type
foreach ($this->getIndexes($type, false) as $index) {
yield $type => $index;
}
}
foreach ($this->getIndexes(self::TYPE_ALL) as $index) {
yield self::TYPE_ALL => $index;
}
} | [
"public",
"function",
"getAllIndexes",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"indexes",
"as",
"$",
"type",
"=>",
"$",
"indexList",
")",
"{",
"// If we hit the \"ALL\" type, skip it for now",
"if",
"(",
"$",
"type",
"==",
"self",
"::",
"TYPE_ALL",
")",
"{",
"continue",
";",
"}",
"// Otherwise yield all indexes registered against this type",
"foreach",
"(",
"$",
"this",
"->",
"getIndexes",
"(",
"$",
"type",
",",
"false",
")",
"as",
"$",
"index",
")",
"{",
"yield",
"$",
"type",
"=>",
"$",
"index",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getIndexes",
"(",
"self",
"::",
"TYPE_ALL",
")",
"as",
"$",
"index",
")",
"{",
"yield",
"self",
"::",
"TYPE_ALL",
"=>",
"$",
"index",
";",
"}",
"}"
] | Get all indexes registered against this manager
@return \Generator | [
"Get",
"all",
"indexes",
"registered",
"against",
"this",
"manager"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Search/Index/DefaultManager.php#L78-L95 | train |
concrete5/concrete5 | concrete/src/Search/Index/DefaultManager.php | DefaultManager.addIndex | public function addIndex($type, $index)
{
if (!isset($this->indexes[$type])) {
$this->indexes[$type] = [];
}
$this->indexes[$type][] = $index;
} | php | public function addIndex($type, $index)
{
if (!isset($this->indexes[$type])) {
$this->indexes[$type] = [];
}
$this->indexes[$type][] = $index;
} | [
"public",
"function",
"addIndex",
"(",
"$",
"type",
",",
"$",
"index",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"indexes",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"this",
"->",
"indexes",
"[",
"$",
"type",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"indexes",
"[",
"$",
"type",
"]",
"[",
"]",
"=",
"$",
"index",
";",
"}"
] | Add an index to this manager
@param string $type The type to index. Use DefaultManager::TYPE_ALL to apply to all types.
@param IndexInterface|string $index | [
"Add",
"an",
"index",
"to",
"this",
"manager"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Search/Index/DefaultManager.php#L102-L109 | train |
concrete5/concrete5 | concrete/src/Search/Index/DefaultManager.php | DefaultManager.index | public function index($type, $object)
{
foreach ($this->getIndexes($type) as $index) {
$index->index($object);
}
} | php | public function index($type, $object)
{
foreach ($this->getIndexes($type) as $index) {
$index->index($object);
}
} | [
"public",
"function",
"index",
"(",
"$",
"type",
",",
"$",
"object",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getIndexes",
"(",
"$",
"type",
")",
"as",
"$",
"index",
")",
"{",
"$",
"index",
"->",
"index",
"(",
"$",
"object",
")",
";",
"}",
"}"
] | Index an object
@param string $type
@param mixed $object
@return void | [
"Index",
"an",
"object"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Search/Index/DefaultManager.php#L117-L122 | train |
concrete5/concrete5 | concrete/src/Search/Index/DefaultManager.php | DefaultManager.forget | public function forget($type, $object)
{
foreach ($this->getIndexes($type) as $index) {
$index->forget($object);
}
} | php | public function forget($type, $object)
{
foreach ($this->getIndexes($type) as $index) {
$index->forget($object);
}
} | [
"public",
"function",
"forget",
"(",
"$",
"type",
",",
"$",
"object",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getIndexes",
"(",
"$",
"type",
")",
"as",
"$",
"index",
")",
"{",
"$",
"index",
"->",
"forget",
"(",
"$",
"object",
")",
";",
"}",
"}"
] | Forget an object
@param string $type
@param mixed $object
@return void | [
"Forget",
"an",
"object"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Search/Index/DefaultManager.php#L130-L135 | train |
concrete5/concrete5 | concrete/controllers/single_page/dashboard/reports/forms/legacy.php | Legacy.deleteFormAnswers | private function deleteFormAnswers($qsID)
{
$db = Loader::db();
$v = [intval($qsID)];
$q = 'SELECT asID FROM btFormAnswerSet WHERE questionSetId = ?';
$r = $db->query($q, $v);
while ($row = $r->fetchRow()) {
$asID = $row['asID'];
$this->deleteAnswers($asID);
}
} | php | private function deleteFormAnswers($qsID)
{
$db = Loader::db();
$v = [intval($qsID)];
$q = 'SELECT asID FROM btFormAnswerSet WHERE questionSetId = ?';
$r = $db->query($q, $v);
while ($row = $r->fetchRow()) {
$asID = $row['asID'];
$this->deleteAnswers($asID);
}
} | [
"private",
"function",
"deleteFormAnswers",
"(",
"$",
"qsID",
")",
"{",
"$",
"db",
"=",
"Loader",
"::",
"db",
"(",
")",
";",
"$",
"v",
"=",
"[",
"intval",
"(",
"$",
"qsID",
")",
"]",
";",
"$",
"q",
"=",
"'SELECT asID FROM btFormAnswerSet WHERE questionSetId = ?'",
";",
"$",
"r",
"=",
"$",
"db",
"->",
"query",
"(",
"$",
"q",
",",
"$",
"v",
")",
";",
"while",
"(",
"$",
"row",
"=",
"$",
"r",
"->",
"fetchRow",
"(",
")",
")",
"{",
"$",
"asID",
"=",
"$",
"row",
"[",
"'asID'",
"]",
";",
"$",
"this",
"->",
"deleteAnswers",
"(",
"$",
"asID",
")",
";",
"}",
"}"
] | DELETE A FORM ANSWERS | [
"DELETE",
"A",
"FORM",
"ANSWERS"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/controllers/single_page/dashboard/reports/forms/legacy.php#L224-L235 | train |
concrete5/concrete5 | concrete/controllers/single_page/dashboard/reports/forms/legacy.php | Legacy.deleteForm | private function deleteForm($bID, $qsID)
{
$db = Loader::db();
$this->deleteFormAnswers($qsID);
$v = [intval($bID)];
$q = 'DELETE FROM btFormQuestions WHERE bID = ?';
$r = $db->query($q, $v);
$q = 'DELETE FROM btForm WHERE bID = ?';
$r = $db->query($q, $v);
$q = 'DELETE FROM Blocks WHERE bID = ?';
$r = $db->query($q, $v);
} | php | private function deleteForm($bID, $qsID)
{
$db = Loader::db();
$this->deleteFormAnswers($qsID);
$v = [intval($bID)];
$q = 'DELETE FROM btFormQuestions WHERE bID = ?';
$r = $db->query($q, $v);
$q = 'DELETE FROM btForm WHERE bID = ?';
$r = $db->query($q, $v);
$q = 'DELETE FROM Blocks WHERE bID = ?';
$r = $db->query($q, $v);
} | [
"private",
"function",
"deleteForm",
"(",
"$",
"bID",
",",
"$",
"qsID",
")",
"{",
"$",
"db",
"=",
"Loader",
"::",
"db",
"(",
")",
";",
"$",
"this",
"->",
"deleteFormAnswers",
"(",
"$",
"qsID",
")",
";",
"$",
"v",
"=",
"[",
"intval",
"(",
"$",
"bID",
")",
"]",
";",
"$",
"q",
"=",
"'DELETE FROM btFormQuestions WHERE bID = ?'",
";",
"$",
"r",
"=",
"$",
"db",
"->",
"query",
"(",
"$",
"q",
",",
"$",
"v",
")",
";",
"$",
"q",
"=",
"'DELETE FROM btForm WHERE bID = ?'",
";",
"$",
"r",
"=",
"$",
"db",
"->",
"query",
"(",
"$",
"q",
",",
"$",
"v",
")",
";",
"$",
"q",
"=",
"'DELETE FROM Blocks WHERE bID = ?'",
";",
"$",
"r",
"=",
"$",
"db",
"->",
"query",
"(",
"$",
"q",
",",
"$",
"v",
")",
";",
"}"
] | DELETE FORMS AND ALL SUBMISSIONS | [
"DELETE",
"FORMS",
"AND",
"ALL",
"SUBMISSIONS"
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/controllers/single_page/dashboard/reports/forms/legacy.php#L238-L252 | train |
concrete5/concrete5 | concrete/blocks/form/controller.php | Controller.viewRequiresJqueryUI | private function viewRequiresJqueryUI()
{
$whereInputTypes = "inputType = 'date' OR inputType = 'datetime'";
$sql = "SELECT COUNT(*) FROM {$this->btQuestionsTablename} WHERE questionSetID = ? AND bID = ? AND ({$whereInputTypes})";
$vals = [intval($this->questionSetId), intval($this->bID)];
$JQUIFieldCount = Database::connection()->GetOne($sql, $vals);
return (bool) $JQUIFieldCount;
} | php | private function viewRequiresJqueryUI()
{
$whereInputTypes = "inputType = 'date' OR inputType = 'datetime'";
$sql = "SELECT COUNT(*) FROM {$this->btQuestionsTablename} WHERE questionSetID = ? AND bID = ? AND ({$whereInputTypes})";
$vals = [intval($this->questionSetId), intval($this->bID)];
$JQUIFieldCount = Database::connection()->GetOne($sql, $vals);
return (bool) $JQUIFieldCount;
} | [
"private",
"function",
"viewRequiresJqueryUI",
"(",
")",
"{",
"$",
"whereInputTypes",
"=",
"\"inputType = 'date' OR inputType = 'datetime'\"",
";",
"$",
"sql",
"=",
"\"SELECT COUNT(*) FROM {$this->btQuestionsTablename} WHERE questionSetID = ? AND bID = ? AND ({$whereInputTypes})\"",
";",
"$",
"vals",
"=",
"[",
"intval",
"(",
"$",
"this",
"->",
"questionSetId",
")",
",",
"intval",
"(",
"$",
"this",
"->",
"bID",
")",
"]",
";",
"$",
"JQUIFieldCount",
"=",
"Database",
"::",
"connection",
"(",
")",
"->",
"GetOne",
"(",
"$",
"sql",
",",
"$",
"vals",
")",
";",
"return",
"(",
"bool",
")",
"$",
"JQUIFieldCount",
";",
"}"
] | Internal helper function. | [
"Internal",
"helper",
"function",
"."
] | c54c94e4eb6d45696fed85a5b8b415f70ea677b8 | https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/blocks/form/controller.php#L103-L111 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.