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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
silverstripe/silverstripe-framework | src/Core/Extensible.php | Extensible.add_extension | public static function add_extension($classOrExtension, $extension = null)
{
if ($extension) {
$class = $classOrExtension;
} else {
$class = get_called_class();
$extension = $classOrExtension;
}
if (!preg_match('/^([^(]*)/', $extension, $matches))... | php | public static function add_extension($classOrExtension, $extension = null)
{
if ($extension) {
$class = $classOrExtension;
} else {
$class = get_called_class();
$extension = $classOrExtension;
}
if (!preg_match('/^([^(]*)/', $extension, $matches))... | [
"public",
"static",
"function",
"add_extension",
"(",
"$",
"classOrExtension",
",",
"$",
"extension",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"extension",
")",
"{",
"$",
"class",
"=",
"$",
"classOrExtension",
";",
"}",
"else",
"{",
"$",
"class",
"=",
"g... | Add an extension to a specific class.
The preferred method for adding extensions is through YAML config,
since it avoids autoloading the class, and is easier to override in
more specific configurations.
As an alternative, extensions can be added to a specific class
directly in the {@link Object::$extensions} array.
S... | [
"Add",
"an",
"extension",
"to",
"a",
"specific",
"class",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Extensible.php#L172-L216 | train |
silverstripe/silverstripe-framework | src/Core/Extensible.php | Extensible.get_extra_config_sources | public static function get_extra_config_sources($class = null)
{
if (!$class) {
$class = get_called_class();
}
// If this class is unextendable, NOP
if (in_array($class, self::$unextendable_classes)) {
return null;
}
// Variable to hold sourc... | php | public static function get_extra_config_sources($class = null)
{
if (!$class) {
$class = get_called_class();
}
// If this class is unextendable, NOP
if (in_array($class, self::$unextendable_classes)) {
return null;
}
// Variable to hold sourc... | [
"public",
"static",
"function",
"get_extra_config_sources",
"(",
"$",
"class",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"class",
")",
"{",
"$",
"class",
"=",
"get_called_class",
"(",
")",
";",
"}",
"// If this class is unextendable, NOP",
"if",
"(",
"in_a... | Get extra config sources for this class
@param string $class Name of class. If left null will return for the current class
@return array|null | [
"Get",
"extra",
"config",
"sources",
"for",
"this",
"class"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Extensible.php#L312-L359 | train |
silverstripe/silverstripe-framework | src/Core/Extensible.php | Extensible.extend | public function extend($method, &$a1 = null, &$a2 = null, &$a3 = null, &$a4 = null, &$a5 = null, &$a6 = null, &$a7 = null)
{
$values = array();
if (!empty($this->beforeExtendCallbacks[$method])) {
foreach (array_reverse($this->beforeExtendCallbacks[$method]) as $callback) {
... | php | public function extend($method, &$a1 = null, &$a2 = null, &$a3 = null, &$a4 = null, &$a5 = null, &$a6 = null, &$a7 = null)
{
$values = array();
if (!empty($this->beforeExtendCallbacks[$method])) {
foreach (array_reverse($this->beforeExtendCallbacks[$method]) as $callback) {
... | [
"public",
"function",
"extend",
"(",
"$",
"method",
",",
"&",
"$",
"a1",
"=",
"null",
",",
"&",
"$",
"a2",
"=",
"null",
",",
"&",
"$",
"a3",
"=",
"null",
",",
"&",
"$",
"a4",
"=",
"null",
",",
"&",
"$",
"a5",
"=",
"null",
",",
"&",
"$",
"... | Run the given function on all of this object's extensions. Note that this method originally returned void, so if
you wanted to return results, you're hosed
Currently returns an array, with an index resulting every time the function is called. Only adds returns if
they're not NULL, to avoid bogus results from methods j... | [
"Run",
"the",
"given",
"function",
"on",
"all",
"of",
"this",
"object",
"s",
"extensions",
".",
"Note",
"that",
"this",
"method",
"originally",
"returned",
"void",
"so",
"if",
"you",
"wanted",
"to",
"return",
"results",
"you",
"re",
"hosed"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Extensible.php#L450-L489 | train |
silverstripe/silverstripe-framework | src/Core/Extensible.php | Extensible.getExtensionInstance | public function getExtensionInstance($extension)
{
$instances = $this->getExtensionInstances();
if (array_key_exists($extension, $instances)) {
return $instances[$extension];
}
// in case Injector has been used to replace an extension
foreach ($instances as $insta... | php | public function getExtensionInstance($extension)
{
$instances = $this->getExtensionInstances();
if (array_key_exists($extension, $instances)) {
return $instances[$extension];
}
// in case Injector has been used to replace an extension
foreach ($instances as $insta... | [
"public",
"function",
"getExtensionInstance",
"(",
"$",
"extension",
")",
"{",
"$",
"instances",
"=",
"$",
"this",
"->",
"getExtensionInstances",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"extension",
",",
"$",
"instances",
")",
")",
"{",
"re... | Get an extension instance attached to this object by name.
@param string $extension
@return Extension|null | [
"Get",
"an",
"extension",
"instance",
"attached",
"to",
"this",
"object",
"by",
"name",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Extensible.php#L497-L510 | train |
silverstripe/silverstripe-framework | src/Security/LogoutForm.php | LogoutForm.getFormFields | protected function getFormFields()
{
$fields = FieldList::create();
$controller = $this->getController();
$backURL = $controller->getBackURL()
?: $controller->getReturnReferer();
// Protect against infinite redirection back to the logout URL after logging out
if... | php | protected function getFormFields()
{
$fields = FieldList::create();
$controller = $this->getController();
$backURL = $controller->getBackURL()
?: $controller->getReturnReferer();
// Protect against infinite redirection back to the logout URL after logging out
if... | [
"protected",
"function",
"getFormFields",
"(",
")",
"{",
"$",
"fields",
"=",
"FieldList",
"::",
"create",
"(",
")",
";",
"$",
"controller",
"=",
"$",
"this",
"->",
"getController",
"(",
")",
";",
"$",
"backURL",
"=",
"$",
"controller",
"->",
"getBackURL"... | Build the FieldList for the logout form
@return FieldList | [
"Build",
"the",
"FieldList",
"for",
"the",
"logout",
"form"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Security/LogoutForm.php#L50-L66 | train |
silverstripe/silverstripe-framework | src/Control/HTTP.php | HTTP.filename2url | public static function filename2url($filename)
{
$filename = realpath($filename);
if (!$filename) {
return null;
}
// Filter files outside of the webroot
$base = realpath(BASE_PATH);
$baseLength = strlen($base);
if (substr($filename, 0, $baseLengt... | php | public static function filename2url($filename)
{
$filename = realpath($filename);
if (!$filename) {
return null;
}
// Filter files outside of the webroot
$base = realpath(BASE_PATH);
$baseLength = strlen($base);
if (substr($filename, 0, $baseLengt... | [
"public",
"static",
"function",
"filename2url",
"(",
"$",
"filename",
")",
"{",
"$",
"filename",
"=",
"realpath",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"!",
"$",
"filename",
")",
"{",
"return",
"null",
";",
"}",
"// Filter files outside of the webroot",... | Turns a local system filename into a URL by comparing it to the script filename.
@param string $filename
@return string | [
"Turns",
"a",
"local",
"system",
"filename",
"into",
"a",
"URL",
"by",
"comparing",
"it",
"to",
"the",
"script",
"filename",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/HTTP.php#L96-L112 | train |
silverstripe/silverstripe-framework | src/Control/HTTP.php | HTTP.absoluteURLs | public static function absoluteURLs($html)
{
$html = str_replace('$CurrentPageURL', Controller::curr()->getRequest()->getURL(), $html);
return HTTP::urlRewriter($html, function ($url) {
//no need to rewrite, if uri has a protocol (determined here by existence of reserved URI character ":... | php | public static function absoluteURLs($html)
{
$html = str_replace('$CurrentPageURL', Controller::curr()->getRequest()->getURL(), $html);
return HTTP::urlRewriter($html, function ($url) {
//no need to rewrite, if uri has a protocol (determined here by existence of reserved URI character ":... | [
"public",
"static",
"function",
"absoluteURLs",
"(",
"$",
"html",
")",
"{",
"$",
"html",
"=",
"str_replace",
"(",
"'$CurrentPageURL'",
",",
"Controller",
"::",
"curr",
"(",
")",
"->",
"getRequest",
"(",
")",
"->",
"getURL",
"(",
")",
",",
"$",
"html",
... | Turn all relative URLs in the content to absolute URLs.
@param string $html
@return string | [
"Turn",
"all",
"relative",
"URLs",
"in",
"the",
"content",
"to",
"absolute",
"URLs",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/HTTP.php#L121-L131 | train |
silverstripe/silverstripe-framework | src/Control/HTTP.php | HTTP.urlRewriter | public static function urlRewriter($content, $code)
{
if (!is_callable($code)) {
throw new InvalidArgumentException(
'HTTP::urlRewriter expects a callable as the second parameter'
);
}
// Replace attributes
$attribs = ["src", "background", "a"... | php | public static function urlRewriter($content, $code)
{
if (!is_callable($code)) {
throw new InvalidArgumentException(
'HTTP::urlRewriter expects a callable as the second parameter'
);
}
// Replace attributes
$attribs = ["src", "background", "a"... | [
"public",
"static",
"function",
"urlRewriter",
"(",
"$",
"content",
",",
"$",
"code",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"code",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'HTTP::urlRewriter expects a callable as the second pa... | Rewrite all the URLs in the given content, evaluating the given string as PHP code.
Put $URL where you want the URL to appear, however, you can't embed $URL in strings, for example:
<ul>
<li><code>'"../../" . $URL'</code></li>
<li><code>'myRewriter($URL)'</code></li>
<li><code>'(substr($URL, 0, 1)=="/") ? "../" . subs... | [
"Rewrite",
"all",
"the",
"URLs",
"in",
"the",
"given",
"content",
"evaluating",
"the",
"given",
"string",
"as",
"PHP",
"code",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/HTTP.php#L157-L202 | train |
silverstripe/silverstripe-framework | src/Control/HTTP.php | HTTP.findByTagAndAttribute | public static function findByTagAndAttribute($content, $attributes)
{
$regexes = [];
foreach ($attributes as $tag => $attribute) {
$regexes[] = "/<{$tag} [^>]*$attribute *= *([\"'])(.*?)\\1[^>]*>/i";
$regexes[] = "/<{$tag} [^>]*$attribute *= *([^ \"'>]+)/i";
}
... | php | public static function findByTagAndAttribute($content, $attributes)
{
$regexes = [];
foreach ($attributes as $tag => $attribute) {
$regexes[] = "/<{$tag} [^>]*$attribute *= *([\"'])(.*?)\\1[^>]*>/i";
$regexes[] = "/<{$tag} [^>]*$attribute *= *([^ \"'>]+)/i";
}
... | [
"public",
"static",
"function",
"findByTagAndAttribute",
"(",
"$",
"content",
",",
"$",
"attributes",
")",
"{",
"$",
"regexes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"tag",
"=>",
"$",
"attribute",
")",
"{",
"$",
"regexes",
"... | Search for all tags with a specific attribute, then return the value of that attribute in a
flat array.
@param string $content
@param array $attributes An array of tags to attributes, for example "[a] => 'href', [div] => 'id'"
@return array | [
"Search",
"for",
"all",
"tags",
"with",
"a",
"specific",
"attribute",
"then",
"return",
"the",
"value",
"of",
"that",
"attribute",
"in",
"a",
"flat",
"array",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/HTTP.php#L299-L319 | train |
silverstripe/silverstripe-framework | src/Control/HTTP.php | HTTP.get_mime_type | public static function get_mime_type($filename)
{
// If the finfo module is compiled into PHP, use it.
$path = BASE_PATH . DIRECTORY_SEPARATOR . $filename;
if (class_exists('finfo') && file_exists($path)) {
$finfo = new finfo(FILEINFO_MIME_TYPE);
return $finfo->file($... | php | public static function get_mime_type($filename)
{
// If the finfo module is compiled into PHP, use it.
$path = BASE_PATH . DIRECTORY_SEPARATOR . $filename;
if (class_exists('finfo') && file_exists($path)) {
$finfo = new finfo(FILEINFO_MIME_TYPE);
return $finfo->file($... | [
"public",
"static",
"function",
"get_mime_type",
"(",
"$",
"filename",
")",
"{",
"// If the finfo module is compiled into PHP, use it.",
"$",
"path",
"=",
"BASE_PATH",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"filename",
";",
"if",
"(",
"class_exists",
"(",
"'finfo'",
... | Get the MIME type based on a file's extension. If the finfo class exists in PHP, and the file
exists relative to the project root, then use that extension, otherwise fallback to a list of
commonly known MIME types.
@param string $filename
@return string | [
"Get",
"the",
"MIME",
"type",
"based",
"on",
"a",
"file",
"s",
"extension",
".",
"If",
"the",
"finfo",
"class",
"exists",
"in",
"PHP",
"and",
"the",
"file",
"exists",
"relative",
"to",
"the",
"project",
"root",
"then",
"use",
"that",
"extension",
"otherw... | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/HTTP.php#L349-L370 | train |
silverstripe/silverstripe-framework | src/Control/HTTP.php | HTTP.set_cache_age | public static function set_cache_age($age)
{
Deprecation::notice('5.0', 'Use HTTPCacheControlMiddleware::singleton()->setMaxAge($age) instead');
self::$cache_age = $age;
HTTPCacheControlMiddleware::singleton()->setMaxAge($age);
} | php | public static function set_cache_age($age)
{
Deprecation::notice('5.0', 'Use HTTPCacheControlMiddleware::singleton()->setMaxAge($age) instead');
self::$cache_age = $age;
HTTPCacheControlMiddleware::singleton()->setMaxAge($age);
} | [
"public",
"static",
"function",
"set_cache_age",
"(",
"$",
"age",
")",
"{",
"Deprecation",
"::",
"notice",
"(",
"'5.0'",
",",
"'Use HTTPCacheControlMiddleware::singleton()->setMaxAge($age) instead'",
")",
";",
"self",
"::",
"$",
"cache_age",
"=",
"$",
"age",
";",
... | Set the maximum age of this page in web caches, in seconds.
@deprecated 4.2.0:5.0.0 Use HTTPCacheControlMiddleware::singleton()->setMaxAge($age) instead
@param int $age | [
"Set",
"the",
"maximum",
"age",
"of",
"this",
"page",
"in",
"web",
"caches",
"in",
"seconds",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/HTTP.php#L378-L383 | train |
silverstripe/silverstripe-framework | src/Control/HTTP.php | HTTP.augmentState | public static function augmentState(HTTPRequest $request, HTTPResponse $response)
{
// Skip if deprecated API is disabled
$config = Config::forClass(HTTP::class);
if ($config->get('ignoreDeprecatedCaching')) {
return;
}
$cacheControlMiddleware = HTTPCacheControlM... | php | public static function augmentState(HTTPRequest $request, HTTPResponse $response)
{
// Skip if deprecated API is disabled
$config = Config::forClass(HTTP::class);
if ($config->get('ignoreDeprecatedCaching')) {
return;
}
$cacheControlMiddleware = HTTPCacheControlM... | [
"public",
"static",
"function",
"augmentState",
"(",
"HTTPRequest",
"$",
"request",
",",
"HTTPResponse",
"$",
"response",
")",
"{",
"// Skip if deprecated API is disabled",
"$",
"config",
"=",
"Config",
"::",
"forClass",
"(",
"HTTP",
"::",
"class",
")",
";",
"if... | Ensure that all deprecated HTTP cache settings are respected
@deprecated 4.2.0:5.0.0 Use HTTPCacheControlMiddleware instead
@throws \LogicException
@param HTTPRequest $request
@param HTTPResponse $response | [
"Ensure",
"that",
"all",
"deprecated",
"HTTP",
"cache",
"settings",
"are",
"respected"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/HTTP.php#L481-L556 | train |
silverstripe/silverstripe-framework | src/ORM/Filters/ComparisonFilter.php | ComparisonFilter.applyOne | protected function applyOne(DataQuery $query)
{
$this->model = $query->applyRelation($this->relation);
$predicate = sprintf("%s %s ?", $this->getDbName(), $this->getOperator());
$clause = [$predicate => $this->getDbFormattedValue()];
return $this->aggregate ?
$this->app... | php | protected function applyOne(DataQuery $query)
{
$this->model = $query->applyRelation($this->relation);
$predicate = sprintf("%s %s ?", $this->getDbName(), $this->getOperator());
$clause = [$predicate => $this->getDbFormattedValue()];
return $this->aggregate ?
$this->app... | [
"protected",
"function",
"applyOne",
"(",
"DataQuery",
"$",
"query",
")",
"{",
"$",
"this",
"->",
"model",
"=",
"$",
"query",
"->",
"applyRelation",
"(",
"$",
"this",
"->",
"relation",
")",
";",
"$",
"predicate",
"=",
"sprintf",
"(",
"\"%s %s ?\"",
",",
... | Applies a comparison filter to the query
Handles SQL escaping for both numeric and string values
@param DataQuery $query
@return DataQuery | [
"Applies",
"a",
"comparison",
"filter",
"to",
"the",
"query",
"Handles",
"SQL",
"escaping",
"for",
"both",
"numeric",
"and",
"string",
"values"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/Filters/ComparisonFilter.php#L42-L52 | train |
silverstripe/silverstripe-framework | src/ORM/ArrayList.php | ArrayList.dataClass | public function dataClass()
{
if ($this->dataClass) {
return $this->dataClass;
}
if (count($this->items) > 0) {
return get_class($this->items[0]);
}
return null;
} | php | public function dataClass()
{
if ($this->dataClass) {
return $this->dataClass;
}
if (count($this->items) > 0) {
return get_class($this->items[0]);
}
return null;
} | [
"public",
"function",
"dataClass",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"dataClass",
")",
"{",
"return",
"$",
"this",
"->",
"dataClass",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"items",
")",
">",
"0",
")",
"{",
"return",
"ge... | Return the class of items in this list, by looking at the first item inside it.
@return string | [
"Return",
"the",
"class",
"of",
"items",
"in",
"this",
"list",
"by",
"looking",
"at",
"the",
"first",
"item",
"inside",
"it",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/ArrayList.php#L59-L68 | train |
silverstripe/silverstripe-framework | src/ORM/ArrayList.php | ArrayList.toNestedArray | public function toNestedArray()
{
$result = [];
foreach ($this->items as $item) {
if (is_object($item)) {
if (method_exists($item, 'toMap')) {
$result[] = $item->toMap();
} else {
$result[] = (array) $item;
... | php | public function toNestedArray()
{
$result = [];
foreach ($this->items as $item) {
if (is_object($item)) {
if (method_exists($item, 'toMap')) {
$result[] = $item->toMap();
} else {
$result[] = (array) $item;
... | [
"public",
"function",
"toNestedArray",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"item",
")",
")",
"{",
"if",
"(",
"method_exists",
... | Return this list as an array and every object it as an sub array as well
@return array | [
"Return",
"this",
"list",
"as",
"an",
"array",
"and",
"every",
"object",
"it",
"as",
"an",
"sub",
"array",
"as",
"well"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/ArrayList.php#L158-L175 | train |
silverstripe/silverstripe-framework | src/ORM/ArrayList.php | ArrayList.limit | public function limit($length, $offset = 0)
{
// Type checking: designed for consistency with DataList::limit()
if (!is_numeric($length) || !is_numeric($offset)) {
Deprecation::notice(
'4.3',
'Arguments to ArrayList::limit() should be numeric'
... | php | public function limit($length, $offset = 0)
{
// Type checking: designed for consistency with DataList::limit()
if (!is_numeric($length) || !is_numeric($offset)) {
Deprecation::notice(
'4.3',
'Arguments to ArrayList::limit() should be numeric'
... | [
"public",
"function",
"limit",
"(",
"$",
"length",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"// Type checking: designed for consistency with DataList::limit()",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"length",
")",
"||",
"!",
"is_numeric",
"(",
"$",
"offset",
... | Get a sub-range of this dataobjectset as an array
@param int $length
@param int $offset
@return static | [
"Get",
"a",
"sub",
"-",
"range",
"of",
"this",
"dataobjectset",
"as",
"an",
"array"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/ArrayList.php#L184-L216 | train |
silverstripe/silverstripe-framework | src/ORM/ArrayList.php | ArrayList.remove | public function remove($item)
{
$renumberKeys = false;
foreach ($this->items as $key => $value) {
if ($item === $value) {
$renumberKeys = true;
unset($this->items[$key]);
}
}
if ($renumberKeys) {
$this->items = array... | php | public function remove($item)
{
$renumberKeys = false;
foreach ($this->items as $key => $value) {
if ($item === $value) {
$renumberKeys = true;
unset($this->items[$key]);
}
}
if ($renumberKeys) {
$this->items = array... | [
"public",
"function",
"remove",
"(",
"$",
"item",
")",
"{",
"$",
"renumberKeys",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"item",
"===",
"$",
"value",
")",
"{",... | Remove this item from this list
@param mixed $item | [
"Remove",
"this",
"item",
"from",
"this",
"list"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/ArrayList.php#L233-L245 | train |
silverstripe/silverstripe-framework | src/ORM/ArrayList.php | ArrayList.replace | public function replace($item, $with)
{
foreach ($this->items as $key => $candidate) {
if ($candidate === $item) {
$this->items[$key] = $with;
return;
}
}
} | php | public function replace($item, $with)
{
foreach ($this->items as $key => $candidate) {
if ($candidate === $item) {
$this->items[$key] = $with;
return;
}
}
} | [
"public",
"function",
"replace",
"(",
"$",
"item",
",",
"$",
"with",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"key",
"=>",
"$",
"candidate",
")",
"{",
"if",
"(",
"$",
"candidate",
"===",
"$",
"item",
")",
"{",
"$",
"this",... | Replaces an item in this list with another item.
@param array|object $item
@param array|object $with
@return void; | [
"Replaces",
"an",
"item",
"in",
"this",
"list",
"with",
"another",
"item",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/ArrayList.php#L254-L262 | train |
silverstripe/silverstripe-framework | src/ORM/ArrayList.php | ArrayList.removeDuplicates | public function removeDuplicates($field = 'ID')
{
$seen = [];
$renumberKeys = false;
foreach ($this->items as $key => $item) {
$value = $this->extractValue($item, $field);
if (array_key_exists($value, $seen)) {
$renumberKeys = true;
u... | php | public function removeDuplicates($field = 'ID')
{
$seen = [];
$renumberKeys = false;
foreach ($this->items as $key => $item) {
$value = $this->extractValue($item, $field);
if (array_key_exists($value, $seen)) {
$renumberKeys = true;
u... | [
"public",
"function",
"removeDuplicates",
"(",
"$",
"field",
"=",
"'ID'",
")",
"{",
"$",
"seen",
"=",
"[",
"]",
";",
"$",
"renumberKeys",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
... | Removes items from this list which have a duplicate value for a certain
field. This is especially useful when combining lists.
@param string $field
@return $this | [
"Removes",
"items",
"from",
"this",
"list",
"which",
"have",
"a",
"duplicate",
"value",
"for",
"a",
"certain",
"field",
".",
"This",
"is",
"especially",
"useful",
"when",
"combining",
"lists",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/ArrayList.php#L284-L305 | train |
silverstripe/silverstripe-framework | src/ORM/ArrayList.php | ArrayList.find | public function find($key, $value)
{
foreach ($this->items as $item) {
if ($this->extractValue($item, $key) == $value) {
return $item;
}
}
return null;
} | php | public function find($key, $value)
{
foreach ($this->items as $item) {
if ($this->extractValue($item, $key) == $value) {
return $item;
}
}
return null;
} | [
"public",
"function",
"find",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"extractValue",
"(",
"$",
"item",
",",
"$",
"key",
")",
"==",
"$"... | Find the first item of this list where the given key = value
@param string $key
@param string $value
@return mixed | [
"Find",
"the",
"first",
"item",
"of",
"this",
"list",
"where",
"the",
"given",
"key",
"=",
"value"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/ArrayList.php#L395-L403 | train |
silverstripe/silverstripe-framework | src/ORM/ArrayList.php | ArrayList.column | public function column($colName = 'ID')
{
$result = [];
foreach ($this->items as $item) {
$result[] = $this->extractValue($item, $colName);
}
return $result;
} | php | public function column($colName = 'ID')
{
$result = [];
foreach ($this->items as $item) {
$result[] = $this->extractValue($item, $colName);
}
return $result;
} | [
"public",
"function",
"column",
"(",
"$",
"colName",
"=",
"'ID'",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"extractValue... | Returns an array of a single field value for all items in the list.
@param string $colName
@return array | [
"Returns",
"an",
"array",
"of",
"a",
"single",
"field",
"value",
"for",
"all",
"items",
"in",
"the",
"list",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/ArrayList.php#L411-L420 | train |
silverstripe/silverstripe-framework | src/ORM/ArrayList.php | ArrayList.sort | public function sort()
{
$args = func_get_args();
if (count($args)==0) {
return $this;
}
if (count($args)>2) {
throw new InvalidArgumentException('This method takes zero, one or two arguments');
}
$columnsToSort = [];
// One argument ... | php | public function sort()
{
$args = func_get_args();
if (count($args)==0) {
return $this;
}
if (count($args)>2) {
throw new InvalidArgumentException('This method takes zero, one or two arguments');
}
$columnsToSort = [];
// One argument ... | [
"public",
"function",
"sort",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"args",
")",
"==",
"0",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"args",
")",
">",
"2... | Sorts this list by one or more fields. You can either pass in a single
field name and direction, or a map of field names to sort directions.
Note that columns may be double quoted as per ANSI sql standard
@return static
@see SS_List::sort()
@example $list->sort('Name'); // default ASC sorting
@example $list->sort('Na... | [
"Sorts",
"this",
"list",
"by",
"one",
"or",
"more",
"fields",
".",
"You",
"can",
"either",
"pass",
"in",
"a",
"single",
"field",
"name",
"and",
"direction",
"or",
"a",
"map",
"of",
"field",
"names",
"to",
"sort",
"directions",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/ArrayList.php#L508-L573 | train |
silverstripe/silverstripe-framework | src/ORM/ArrayList.php | ArrayList.canFilterBy | public function canFilterBy($by)
{
if (empty($this->items)) {
return false;
}
$firstRecord = $this->first();
return array_key_exists($by, $firstRecord);
} | php | public function canFilterBy($by)
{
if (empty($this->items)) {
return false;
}
$firstRecord = $this->first();
return array_key_exists($by, $firstRecord);
} | [
"public",
"function",
"canFilterBy",
"(",
"$",
"by",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"items",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"firstRecord",
"=",
"$",
"this",
"->",
"first",
"(",
")",
";",
"return",
"array_key... | Returns true if the given column can be used to filter the records.
It works by checking the fields available in the first record of the list.
@param string $by
@return bool | [
"Returns",
"true",
"if",
"the",
"given",
"column",
"can",
"be",
"used",
"to",
"filter",
"the",
"records",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/ArrayList.php#L583-L592 | train |
silverstripe/silverstripe-framework | src/ORM/ArrayList.php | ArrayList.filter | public function filter()
{
$keepUs = call_user_func_array([$this, 'normaliseFilterArgs'], func_get_args());
$itemsToKeep = [];
foreach ($this->items as $item) {
$keepItem = true;
foreach ($keepUs as $column => $value) {
if ((is_array($value) && !in_a... | php | public function filter()
{
$keepUs = call_user_func_array([$this, 'normaliseFilterArgs'], func_get_args());
$itemsToKeep = [];
foreach ($this->items as $item) {
$keepItem = true;
foreach ($keepUs as $column => $value) {
if ((is_array($value) && !in_a... | [
"public",
"function",
"filter",
"(",
")",
"{",
"$",
"keepUs",
"=",
"call_user_func_array",
"(",
"[",
"$",
"this",
",",
"'normaliseFilterArgs'",
"]",
",",
"func_get_args",
"(",
")",
")",
";",
"$",
"itemsToKeep",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
... | Filter the list to include items with these charactaristics
@return ArrayList
@see SS_List::filter()
@example $list->filter('Name', 'bob'); // only bob in the list
@example $list->filter('Name', array('aziz', 'bob'); // aziz and bob in list
@example $list->filter(array('Name'=>'bob, 'Age'=>21)); // bob with the Age 21... | [
"Filter",
"the",
"list",
"to",
"include",
"items",
"with",
"these",
"charactaristics"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/ArrayList.php#L606-L630 | train |
silverstripe/silverstripe-framework | src/ORM/ArrayList.php | ArrayList.filterAny | public function filterAny()
{
$keepUs = $this->normaliseFilterArgs(...func_get_args());
$itemsToKeep = [];
foreach ($this->items as $item) {
foreach ($keepUs as $column => $value) {
$extractedValue = $this->extractValue($item, $column);
$matches ... | php | public function filterAny()
{
$keepUs = $this->normaliseFilterArgs(...func_get_args());
$itemsToKeep = [];
foreach ($this->items as $item) {
foreach ($keepUs as $column => $value) {
$extractedValue = $this->extractValue($item, $column);
$matches ... | [
"public",
"function",
"filterAny",
"(",
")",
"{",
"$",
"keepUs",
"=",
"$",
"this",
"->",
"normaliseFilterArgs",
"(",
"...",
"func_get_args",
"(",
")",
")",
";",
"$",
"itemsToKeep",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
... | Return a copy of this list which contains items matching any of these charactaristics.
@example // only bob in the list
$list = $list->filterAny('Name', 'bob');
@example // azis or bob in the list
$list = $list->filterAny('Name', array('aziz', 'bob');
@example // bob or anyone aged 21 in the list
$list = $list->filter... | [
"Return",
"a",
"copy",
"of",
"this",
"list",
"which",
"contains",
"items",
"matching",
"any",
"of",
"these",
"charactaristics",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/ArrayList.php#L649-L669 | train |
silverstripe/silverstripe-framework | src/ORM/ArrayList.php | ArrayList.exclude | public function exclude()
{
$removeUs = $this->normaliseFilterArgs(...func_get_args());
$hitsRequiredToRemove = count($removeUs);
$matches = [];
foreach ($removeUs as $column => $excludeValue) {
foreach ($this->items as $key => $item) {
if (!is_array($exc... | php | public function exclude()
{
$removeUs = $this->normaliseFilterArgs(...func_get_args());
$hitsRequiredToRemove = count($removeUs);
$matches = [];
foreach ($removeUs as $column => $excludeValue) {
foreach ($this->items as $key => $item) {
if (!is_array($exc... | [
"public",
"function",
"exclude",
"(",
")",
"{",
"$",
"removeUs",
"=",
"$",
"this",
"->",
"normaliseFilterArgs",
"(",
"...",
"func_get_args",
"(",
")",
")",
";",
"$",
"hitsRequiredToRemove",
"=",
"count",
"(",
"$",
"removeUs",
")",
";",
"$",
"matches",
"=... | Exclude the list to not contain items with these charactaristics
@return ArrayList
@see SS_List::exclude()
@example $list->exclude('Name', 'bob'); // exclude bob from list
@example $list->exclude('Name', array('aziz', 'bob'); // exclude aziz and bob from list
@example $list->exclude(array('Name'=>'bob, 'Age'=>21)); //... | [
"Exclude",
"the",
"list",
"to",
"not",
"contain",
"items",
"with",
"these",
"charactaristics"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/ArrayList.php#L767-L795 | train |
silverstripe/silverstripe-framework | src/ORM/UnsavedRelationList.php | UnsavedRelationList.changeToList | public function changeToList(RelationList $list)
{
foreach ($this->items as $key => $item) {
$list->add($item, $this->extraFields[$key]);
}
} | php | public function changeToList(RelationList $list)
{
foreach ($this->items as $key => $item) {
$list->add($item, $this->extraFields[$key]);
}
} | [
"public",
"function",
"changeToList",
"(",
"RelationList",
"$",
"list",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"$",
"list",
"->",
"add",
"(",
"$",
"item",
",",
"$",
"this",
"->",
"extraF... | Save all the items in this list into the RelationList
@param RelationList $list | [
"Save",
"all",
"the",
"items",
"in",
"this",
"list",
"into",
"the",
"RelationList"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/UnsavedRelationList.php#L82-L87 | train |
silverstripe/silverstripe-framework | src/ORM/UnsavedRelationList.php | UnsavedRelationList.push | public function push($item, $extraFields = null)
{
if ((is_object($item) && !$item instanceof $this->dataClass)
|| (!is_object($item) && !is_numeric($item))) {
throw new InvalidArgumentException(
"UnsavedRelationList::add() expecting a $this->dataClass object, or ID v... | php | public function push($item, $extraFields = null)
{
if ((is_object($item) && !$item instanceof $this->dataClass)
|| (!is_object($item) && !is_numeric($item))) {
throw new InvalidArgumentException(
"UnsavedRelationList::add() expecting a $this->dataClass object, or ID v... | [
"public",
"function",
"push",
"(",
"$",
"item",
",",
"$",
"extraFields",
"=",
"null",
")",
"{",
"if",
"(",
"(",
"is_object",
"(",
"$",
"item",
")",
"&&",
"!",
"$",
"item",
"instanceof",
"$",
"this",
"->",
"dataClass",
")",
"||",
"(",
"!",
"is_objec... | Pushes an item onto the end of this list.
@param array|object $item
@param array $extraFields | [
"Pushes",
"an",
"item",
"onto",
"the",
"end",
"of",
"this",
"list",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/UnsavedRelationList.php#L95-L109 | train |
silverstripe/silverstripe-framework | src/ORM/UnsavedRelationList.php | UnsavedRelationList.toArray | public function toArray()
{
$items = array();
foreach ($this->items as $key => $item) {
if (is_numeric($item)) {
$item = DataObject::get_by_id($this->dataClass, $item);
}
if (!empty($this->extraFields[$key])) {
$item->update($this->... | php | public function toArray()
{
$items = array();
foreach ($this->items as $key => $item) {
if (is_numeric($item)) {
$item = DataObject::get_by_id($this->dataClass, $item);
}
if (!empty($this->extraFields[$key])) {
$item->update($this->... | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"items",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"item",
")",
")",
"{",
"$",... | Return an array of the actual items that this relation contains at this stage.
This is when the query is actually executed.
@return array | [
"Return",
"an",
"array",
"of",
"the",
"actual",
"items",
"that",
"this",
"relation",
"contains",
"at",
"this",
"stage",
".",
"This",
"is",
"when",
"the",
"query",
"is",
"actually",
"executed",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/UnsavedRelationList.php#L137-L150 | train |
silverstripe/silverstripe-framework | src/ORM/UnsavedRelationList.php | UnsavedRelationList.first | public function first()
{
$item = reset($this->items);
if (is_numeric($item)) {
$item = DataObject::get_by_id($this->dataClass, $item);
}
if (!empty($this->extraFields[key($this->items)])) {
$item->update($this->extraFields[key($this->items)]);
}
... | php | public function first()
{
$item = reset($this->items);
if (is_numeric($item)) {
$item = DataObject::get_by_id($this->dataClass, $item);
}
if (!empty($this->extraFields[key($this->items)])) {
$item->update($this->extraFields[key($this->items)]);
}
... | [
"public",
"function",
"first",
"(",
")",
"{",
"$",
"item",
"=",
"reset",
"(",
"$",
"this",
"->",
"items",
")",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"item",
")",
")",
"{",
"$",
"item",
"=",
"DataObject",
"::",
"get_by_id",
"(",
"$",
"this",
"->... | Returns the first item in the list
@return mixed | [
"Returns",
"the",
"first",
"item",
"in",
"the",
"list"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/UnsavedRelationList.php#L240-L250 | train |
silverstripe/silverstripe-framework | src/ORM/UnsavedRelationList.php | UnsavedRelationList.last | public function last()
{
$item = end($this->items);
if (!empty($this->extraFields[key($this->items)])) {
$item->update($this->extraFields[key($this->items)]);
}
return $item;
} | php | public function last()
{
$item = end($this->items);
if (!empty($this->extraFields[key($this->items)])) {
$item->update($this->extraFields[key($this->items)]);
}
return $item;
} | [
"public",
"function",
"last",
"(",
")",
"{",
"$",
"item",
"=",
"end",
"(",
"$",
"this",
"->",
"items",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"extraFields",
"[",
"key",
"(",
"$",
"this",
"->",
"items",
")",
"]",
")",
")",
... | Returns the last item in the list
@return mixed | [
"Returns",
"the",
"last",
"item",
"in",
"the",
"list"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/UnsavedRelationList.php#L257-L264 | train |
silverstripe/silverstripe-framework | src/ORM/UnsavedRelationList.php | UnsavedRelationList.forForeignID | public function forForeignID($id)
{
$singleton = DataObject::singleton($this->baseClass);
/** @var Relation $relation */
$relation = $singleton->{$this->relationName}($id);
return $relation;
} | php | public function forForeignID($id)
{
$singleton = DataObject::singleton($this->baseClass);
/** @var Relation $relation */
$relation = $singleton->{$this->relationName}($id);
return $relation;
} | [
"public",
"function",
"forForeignID",
"(",
"$",
"id",
")",
"{",
"$",
"singleton",
"=",
"DataObject",
"::",
"singleton",
"(",
"$",
"this",
"->",
"baseClass",
")",
";",
"/** @var Relation $relation */",
"$",
"relation",
"=",
"$",
"singleton",
"->",
"{",
"$",
... | Returns a copy of this list with the relationship linked to the given foreign ID.
@param int|array $id An ID or an array of IDs.
@return Relation | [
"Returns",
"a",
"copy",
"of",
"this",
"list",
"with",
"the",
"relationship",
"linked",
"to",
"the",
"given",
"foreign",
"ID",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/UnsavedRelationList.php#L295-L301 | train |
silverstripe/silverstripe-framework | src/Forms/GridField/GridFieldPageCount.php | GridFieldPageCount.getPaginator | protected function getPaginator($gridField)
{
/** @var GridFieldPaginator $paginator */
$paginator = $gridField->getConfig()->getComponentByType(GridFieldPaginator::class);
if (!$paginator && GridFieldPageCount::config()->uninherited('require_paginator')) {
throw new LogicExcept... | php | protected function getPaginator($gridField)
{
/** @var GridFieldPaginator $paginator */
$paginator = $gridField->getConfig()->getComponentByType(GridFieldPaginator::class);
if (!$paginator && GridFieldPageCount::config()->uninherited('require_paginator')) {
throw new LogicExcept... | [
"protected",
"function",
"getPaginator",
"(",
"$",
"gridField",
")",
"{",
"/** @var GridFieldPaginator $paginator */",
"$",
"paginator",
"=",
"$",
"gridField",
"->",
"getConfig",
"(",
")",
"->",
"getComponentByType",
"(",
"GridFieldPaginator",
"::",
"class",
")",
";... | Retrieves an instance of a GridFieldPaginator attached to the same control
@param GridField $gridField The parent gridfield
@return GridFieldPaginator The attached GridFieldPaginator, if found.
@throws LogicException | [
"Retrieves",
"an",
"instance",
"of",
"a",
"GridFieldPaginator",
"attached",
"to",
"the",
"same",
"control"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/GridField/GridFieldPageCount.php#L47-L59 | train |
silverstripe/silverstripe-framework | src/ORM/FieldType/DBClassName.php | DBClassName.getBaseClass | public function getBaseClass()
{
// Use explicit base class
if ($this->baseClass) {
return $this->baseClass;
}
// Default to the basename of the record
$schema = DataObject::getSchema();
if ($this->record) {
return $schema->baseDataClass($this-... | php | public function getBaseClass()
{
// Use explicit base class
if ($this->baseClass) {
return $this->baseClass;
}
// Default to the basename of the record
$schema = DataObject::getSchema();
if ($this->record) {
return $schema->baseDataClass($this-... | [
"public",
"function",
"getBaseClass",
"(",
")",
"{",
"// Use explicit base class",
"if",
"(",
"$",
"this",
"->",
"baseClass",
")",
"{",
"return",
"$",
"this",
"->",
"baseClass",
";",
"}",
"// Default to the basename of the record",
"$",
"schema",
"=",
"DataObject"... | Get the base dataclass for the list of subclasses
@return string | [
"Get",
"the",
"base",
"dataclass",
"for",
"the",
"list",
"of",
"subclasses"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/FieldType/DBClassName.php#L86-L104 | train |
silverstripe/silverstripe-framework | src/ORM/FieldType/DBClassName.php | DBClassName.getShortName | public function getShortName()
{
$value = $this->getValue();
if (empty($value) || !ClassInfo::exists($value)) {
return null;
}
return ClassInfo::shortName($value);
} | php | public function getShortName()
{
$value = $this->getValue();
if (empty($value) || !ClassInfo::exists($value)) {
return null;
}
return ClassInfo::shortName($value);
} | [
"public",
"function",
"getShortName",
"(",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
"||",
"!",
"ClassInfo",
"::",
"exists",
"(",
"$",
"value",
")",
")",
"{",
"return",
... | Get the base name of the current class
Useful as a non-fully qualified CSS Class name in templates.
@return string|null | [
"Get",
"the",
"base",
"name",
"of",
"the",
"current",
"class",
"Useful",
"as",
"a",
"non",
"-",
"fully",
"qualified",
"CSS",
"Class",
"name",
"in",
"templates",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/FieldType/DBClassName.php#L112-L119 | train |
silverstripe/silverstripe-framework | src/ORM/FieldType/DBClassName.php | DBClassName.getEnum | public function getEnum()
{
$classNames = ClassInfo::subclassesFor($this->getBaseClass());
$dataobject = strtolower(DataObject::class);
unset($classNames[$dataobject]);
return array_values($classNames);
} | php | public function getEnum()
{
$classNames = ClassInfo::subclassesFor($this->getBaseClass());
$dataobject = strtolower(DataObject::class);
unset($classNames[$dataobject]);
return array_values($classNames);
} | [
"public",
"function",
"getEnum",
"(",
")",
"{",
"$",
"classNames",
"=",
"ClassInfo",
"::",
"subclassesFor",
"(",
"$",
"this",
"->",
"getBaseClass",
"(",
")",
")",
";",
"$",
"dataobject",
"=",
"strtolower",
"(",
"DataObject",
"::",
"class",
")",
";",
"uns... | Get list of classnames that should be selectable
@return array | [
"Get",
"list",
"of",
"classnames",
"that",
"should",
"be",
"selectable"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/FieldType/DBClassName.php#L138-L144 | train |
silverstripe/silverstripe-framework | src/Forms/FormField.php | FormField.name_to_label | public static function name_to_label($fieldName)
{
// Handle dot delimiters
if (strpos($fieldName, '.') !== false) {
$parts = explode('.', $fieldName);
// Ensure that any letter following a dot is uppercased, so that the regex below can break it up
// into words
... | php | public static function name_to_label($fieldName)
{
// Handle dot delimiters
if (strpos($fieldName, '.') !== false) {
$parts = explode('.', $fieldName);
// Ensure that any letter following a dot is uppercased, so that the regex below can break it up
// into words
... | [
"public",
"static",
"function",
"name_to_label",
"(",
"$",
"fieldName",
")",
"{",
"// Handle dot delimiters",
"if",
"(",
"strpos",
"(",
"$",
"fieldName",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"fiel... | Takes a field name and converts camelcase to spaced words. Also resolves combined field
names with dot syntax to spaced words.
Examples:
- 'TotalAmount' will return 'Total amount'
- 'Organisation.ZipCode' will return 'Organisation zip code'
@param string $fieldName
@return string | [
"Takes",
"a",
"field",
"name",
"and",
"converts",
"camelcase",
"to",
"spaced",
"words",
".",
"Also",
"resolves",
"combined",
"field",
"names",
"with",
"dot",
"syntax",
"to",
"spaced",
"words",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/FormField.php#L305-L328 | train |
silverstripe/silverstripe-framework | src/Forms/FormField.php | FormField.Link | public function Link($action = null)
{
if (!$this->form) {
throw new LogicException(
'Field must be associated with a form to call Link(). Please use $field->setForm($form);'
);
}
$link = Controller::join_links($this->form->FormAction(), 'field/' . $t... | php | public function Link($action = null)
{
if (!$this->form) {
throw new LogicException(
'Field must be associated with a form to call Link(). Please use $field->setForm($form);'
);
}
$link = Controller::join_links($this->form->FormAction(), 'field/' . $t... | [
"public",
"function",
"Link",
"(",
"$",
"action",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"form",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Field must be associated with a form to call Link(). Please use $field->setForm($form);'",
")",
";"... | Return a link to this field
@param string $action
@return string
@throws LogicException If no form is set yet | [
"Return",
"a",
"link",
"to",
"this",
"field"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/FormField.php#L377-L388 | train |
silverstripe/silverstripe-framework | src/Forms/FormField.php | FormField.getAttributes | public function getAttributes()
{
$attributes = array(
'type' => $this->getInputType(),
'name' => $this->getName(),
'value' => $this->Value(),
'class' => $this->extraClass(),
'id' => $this->ID(),
'disabled' => $this->isDisabled(),
... | php | public function getAttributes()
{
$attributes = array(
'type' => $this->getInputType(),
'name' => $this->getName(),
'value' => $this->Value(),
'class' => $this->extraClass(),
'id' => $this->ID(),
'disabled' => $this->isDisabled(),
... | [
"public",
"function",
"getAttributes",
"(",
")",
"{",
"$",
"attributes",
"=",
"array",
"(",
"'type'",
"=>",
"$",
"this",
"->",
"getInputType",
"(",
")",
",",
"'name'",
"=>",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"'value'",
"=>",
"$",
"this",
"... | Allows customization through an 'updateAttributes' hook on the base class.
Existing attributes are passed in as the first argument and can be manipulated,
but any attributes added through a subclass implementation won't be included.
@return array | [
"Allows",
"customization",
"through",
"an",
"updateAttributes",
"hook",
"on",
"the",
"base",
"class",
".",
"Existing",
"attributes",
"are",
"passed",
"in",
"as",
"the",
"first",
"argument",
"and",
"can",
"be",
"manipulated",
"but",
"any",
"attributes",
"added",
... | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/FormField.php#L679-L702 | train |
silverstripe/silverstripe-framework | src/Forms/FormField.php | FormField.Field | public function Field($properties = array())
{
$context = $this;
$this->extend('onBeforeRender', $context, $properties);
if (count($properties)) {
$context = $context->customise($properties);
}
$result = $context->renderWith($this->getTemplates());
// ... | php | public function Field($properties = array())
{
$context = $this;
$this->extend('onBeforeRender', $context, $properties);
if (count($properties)) {
$context = $context->customise($properties);
}
$result = $context->renderWith($this->getTemplates());
// ... | [
"public",
"function",
"Field",
"(",
"$",
"properties",
"=",
"array",
"(",
")",
")",
"{",
"$",
"context",
"=",
"$",
"this",
";",
"$",
"this",
"->",
"extend",
"(",
"'onBeforeRender'",
",",
"$",
"context",
",",
"$",
"properties",
")",
";",
"if",
"(",
... | Returns the form field.
Although FieldHolder is generally what is inserted into templates, all of the field holder
templates make use of $Field. It's expected that FieldHolder will give you the "complete"
representation of the field on the form, whereas Field will give you the core editing widget,
such as an input tag... | [
"Returns",
"the",
"form",
"field",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/FormField.php#L1000-L1020 | train |
silverstripe/silverstripe-framework | src/Forms/FormField.php | FormField.FieldHolder | public function FieldHolder($properties = array())
{
$context = $this;
if (count($properties)) {
$context = $this->customise($properties);
}
return $context->renderWith($this->getFieldHolderTemplates());
} | php | public function FieldHolder($properties = array())
{
$context = $this;
if (count($properties)) {
$context = $this->customise($properties);
}
return $context->renderWith($this->getFieldHolderTemplates());
} | [
"public",
"function",
"FieldHolder",
"(",
"$",
"properties",
"=",
"array",
"(",
")",
")",
"{",
"$",
"context",
"=",
"$",
"this",
";",
"if",
"(",
"count",
"(",
"$",
"properties",
")",
")",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"customise",
"(... | Returns a "field holder" for this field.
Forms are constructed by concatenating a number of these field holders.
The default field holder is a label and a form field inside a div.
@see FieldHolder.ss
@param array $properties
@return DBHTMLText | [
"Returns",
"a",
"field",
"holder",
"for",
"this",
"field",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/FormField.php#L1035-L1044 | train |
silverstripe/silverstripe-framework | src/Forms/FormField.php | FormField._templates | protected function _templates($customTemplate = null, $customTemplateSuffix = null)
{
$templates = SSViewer::get_templates_by_class(static::class, $customTemplateSuffix, __CLASS__);
// Prefer any custom template
if ($customTemplate) {
// Prioritise direct template
arr... | php | protected function _templates($customTemplate = null, $customTemplateSuffix = null)
{
$templates = SSViewer::get_templates_by_class(static::class, $customTemplateSuffix, __CLASS__);
// Prefer any custom template
if ($customTemplate) {
// Prioritise direct template
arr... | [
"protected",
"function",
"_templates",
"(",
"$",
"customTemplate",
"=",
"null",
",",
"$",
"customTemplateSuffix",
"=",
"null",
")",
"{",
"$",
"templates",
"=",
"SSViewer",
"::",
"get_templates_by_class",
"(",
"static",
"::",
"class",
",",
"$",
"customTemplateSuf... | Generate an array of class name strings to use for rendering this form field into HTML.
@param string $customTemplate
@param string $customTemplateSuffix
@return array | [
"Generate",
"an",
"array",
"of",
"class",
"name",
"strings",
"to",
"use",
"for",
"rendering",
"this",
"form",
"field",
"into",
"HTML",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/FormField.php#L1109-L1118 | train |
silverstripe/silverstripe-framework | src/Forms/FormField.php | FormField.performReadonlyTransformation | public function performReadonlyTransformation()
{
$readonlyClassName = static::class . '_Readonly';
if (ClassInfo::exists($readonlyClassName)) {
$clone = $this->castedCopy($readonlyClassName);
} else {
$clone = $this->castedCopy(ReadonlyField::class);
}
... | php | public function performReadonlyTransformation()
{
$readonlyClassName = static::class . '_Readonly';
if (ClassInfo::exists($readonlyClassName)) {
$clone = $this->castedCopy($readonlyClassName);
} else {
$clone = $this->castedCopy(ReadonlyField::class);
}
... | [
"public",
"function",
"performReadonlyTransformation",
"(",
")",
"{",
"$",
"readonlyClassName",
"=",
"static",
"::",
"class",
".",
"'_Readonly'",
";",
"if",
"(",
"ClassInfo",
"::",
"exists",
"(",
"$",
"readonlyClassName",
")",
")",
"{",
"$",
"clone",
"=",
"$... | Returns a read-only version of this field.
@return FormField | [
"Returns",
"a",
"read",
"-",
"only",
"version",
"of",
"this",
"field",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/FormField.php#L1224-L1237 | train |
silverstripe/silverstripe-framework | src/Forms/FormField.php | FormField.performDisabledTransformation | public function performDisabledTransformation()
{
$disabledClassName = static::class . '_Disabled';
if (ClassInfo::exists($disabledClassName)) {
$clone = $this->castedCopy($disabledClassName);
} else {
$clone = clone $this;
}
$clone->setDisabled(true... | php | public function performDisabledTransformation()
{
$disabledClassName = static::class . '_Disabled';
if (ClassInfo::exists($disabledClassName)) {
$clone = $this->castedCopy($disabledClassName);
} else {
$clone = clone $this;
}
$clone->setDisabled(true... | [
"public",
"function",
"performDisabledTransformation",
"(",
")",
"{",
"$",
"disabledClassName",
"=",
"static",
"::",
"class",
".",
"'_Disabled'",
";",
"if",
"(",
"ClassInfo",
"::",
"exists",
"(",
"$",
"disabledClassName",
")",
")",
"{",
"$",
"clone",
"=",
"$... | Return a disabled version of this field.
Tries to find a class of the class name of this field suffixed with "_Disabled", failing
that, finds a method {@link setDisabled()}.
@return FormField | [
"Return",
"a",
"disabled",
"version",
"of",
"this",
"field",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/FormField.php#L1247-L1260 | train |
silverstripe/silverstripe-framework | src/Forms/FormField.php | FormField.hasClass | public function hasClass($class)
{
$classes = explode(' ', strtolower($this->extraClass()));
return in_array(strtolower(trim($class)), $classes);
} | php | public function hasClass($class)
{
$classes = explode(' ', strtolower($this->extraClass()));
return in_array(strtolower(trim($class)), $classes);
} | [
"public",
"function",
"hasClass",
"(",
"$",
"class",
")",
"{",
"$",
"classes",
"=",
"explode",
"(",
"' '",
",",
"strtolower",
"(",
"$",
"this",
"->",
"extraClass",
"(",
")",
")",
")",
";",
"return",
"in_array",
"(",
"strtolower",
"(",
"trim",
"(",
"$... | Returns whether the current field has the given class added
@param string $class
@return bool | [
"Returns",
"whether",
"the",
"current",
"field",
"has",
"the",
"given",
"class",
"added"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/FormField.php#L1279-L1283 | train |
silverstripe/silverstripe-framework | src/Forms/FormField.php | FormField.castedCopy | public function castedCopy($classOrCopy)
{
$field = $classOrCopy;
if (!is_object($field)) {
$field = $classOrCopy::create($this->name);
}
$field
->setValue($this->value)
->setForm($this->form)
->setTitle($this->Title())
->... | php | public function castedCopy($classOrCopy)
{
$field = $classOrCopy;
if (!is_object($field)) {
$field = $classOrCopy::create($this->name);
}
$field
->setValue($this->value)
->setForm($this->form)
->setTitle($this->Title())
->... | [
"public",
"function",
"castedCopy",
"(",
"$",
"classOrCopy",
")",
"{",
"$",
"field",
"=",
"$",
"classOrCopy",
";",
"if",
"(",
"!",
"is_object",
"(",
"$",
"field",
")",
")",
"{",
"$",
"field",
"=",
"$",
"classOrCopy",
"::",
"create",
"(",
"$",
"this",... | Returns another instance of this field, but "cast" to a different class. The logic tries to
retain all of the instance properties, and may be overloaded by subclasses to set additional
ones.
Assumes the standard FormField parameter signature with its name as the only mandatory
argument. Mainly geared towards creating ... | [
"Returns",
"another",
"instance",
"of",
"this",
"field",
"but",
"cast",
"to",
"a",
"different",
"class",
".",
"The",
"logic",
"tries",
"to",
"retain",
"all",
"of",
"the",
"instance",
"properties",
"and",
"may",
"be",
"overloaded",
"by",
"subclasses",
"to",
... | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/FormField.php#L1434-L1458 | train |
silverstripe/silverstripe-framework | src/Forms/FormField.php | FormField.getSchemaData | public function getSchemaData()
{
$defaults = $this->getSchemaDataDefaults();
return array_replace_recursive($defaults, array_intersect_key($this->schemaData, $defaults));
} | php | public function getSchemaData()
{
$defaults = $this->getSchemaDataDefaults();
return array_replace_recursive($defaults, array_intersect_key($this->schemaData, $defaults));
} | [
"public",
"function",
"getSchemaData",
"(",
")",
"{",
"$",
"defaults",
"=",
"$",
"this",
"->",
"getSchemaDataDefaults",
"(",
")",
";",
"return",
"array_replace_recursive",
"(",
"$",
"defaults",
",",
"array_intersect_key",
"(",
"$",
"this",
"->",
"schemaData",
... | Gets the schema data used to render the FormField on the front-end.
@return array | [
"Gets",
"the",
"schema",
"data",
"used",
"to",
"render",
"the",
"FormField",
"on",
"the",
"front",
"-",
"end",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/FormField.php#L1515-L1519 | train |
silverstripe/silverstripe-framework | src/Forms/FormField.php | FormField.getSchemaState | public function getSchemaState()
{
$defaults = $this->getSchemaStateDefaults();
return array_merge($defaults, array_intersect_key($this->schemaState, $defaults));
} | php | public function getSchemaState()
{
$defaults = $this->getSchemaStateDefaults();
return array_merge($defaults, array_intersect_key($this->schemaState, $defaults));
} | [
"public",
"function",
"getSchemaState",
"(",
")",
"{",
"$",
"defaults",
"=",
"$",
"this",
"->",
"getSchemaStateDefaults",
"(",
")",
";",
"return",
"array_merge",
"(",
"$",
"defaults",
",",
"array_intersect_key",
"(",
"$",
"this",
"->",
"schemaState",
",",
"$... | Gets the schema state used to render the FormField on the front-end.
@return array | [
"Gets",
"the",
"schema",
"state",
"used",
"to",
"render",
"the",
"FormField",
"on",
"the",
"front",
"-",
"end",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/FormField.php#L1586-L1590 | train |
silverstripe/silverstripe-framework | src/ORM/PaginatedList.php | PaginatedList.getPageStart | public function getPageStart()
{
$request = $this->getRequest();
if ($this->pageStart === null) {
if ($request
&& isset($request[$this->getPaginationGetVar()])
&& $request[$this->getPaginationGetVar()] > 0
) {
$this->pageStart =... | php | public function getPageStart()
{
$request = $this->getRequest();
if ($this->pageStart === null) {
if ($request
&& isset($request[$this->getPaginationGetVar()])
&& $request[$this->getPaginationGetVar()] > 0
) {
$this->pageStart =... | [
"public",
"function",
"getPageStart",
"(",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"pageStart",
"===",
"null",
")",
"{",
"if",
"(",
"$",
"request",
"&&",
"isset",
"(",
"$",
"reque... | Returns the offset of the item the current page starts at.
@return int | [
"Returns",
"the",
"offset",
"of",
"the",
"item",
"the",
"current",
"page",
"starts",
"at",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/PaginatedList.php#L111-L126 | train |
silverstripe/silverstripe-framework | src/ORM/PaginatedList.php | PaginatedList.getTotalItems | public function getTotalItems()
{
if ($this->totalItems === null) {
$this->totalItems = count($this->list);
}
return $this->totalItems;
} | php | public function getTotalItems()
{
if ($this->totalItems === null) {
$this->totalItems = count($this->list);
}
return $this->totalItems;
} | [
"public",
"function",
"getTotalItems",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"totalItems",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"totalItems",
"=",
"count",
"(",
"$",
"this",
"->",
"list",
")",
";",
"}",
"return",
"$",
"this",
"->",
"t... | Returns the total number of items in the unpaginated list.
@return int | [
"Returns",
"the",
"total",
"number",
"of",
"items",
"in",
"the",
"unpaginated",
"list",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/PaginatedList.php#L146-L153 | train |
silverstripe/silverstripe-framework | src/ORM/PaginatedList.php | PaginatedList.setPaginationFromQuery | public function setPaginationFromQuery(SQLSelect $query)
{
if ($limit = $query->getLimit()) {
$this->setPageLength($limit['limit']);
$this->setPageStart($limit['start']);
$this->setTotalItems($query->unlimitedRowCount());
}
return $this;
} | php | public function setPaginationFromQuery(SQLSelect $query)
{
if ($limit = $query->getLimit()) {
$this->setPageLength($limit['limit']);
$this->setPageStart($limit['start']);
$this->setTotalItems($query->unlimitedRowCount());
}
return $this;
} | [
"public",
"function",
"setPaginationFromQuery",
"(",
"SQLSelect",
"$",
"query",
")",
"{",
"if",
"(",
"$",
"limit",
"=",
"$",
"query",
"->",
"getLimit",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setPageLength",
"(",
"$",
"limit",
"[",
"'limit'",
"]",
")",... | Sets the page length, page start and total items from a query object's
limit, offset and unlimited count. The query MUST have a limit clause.
@param SQLSelect $query
@return $this | [
"Sets",
"the",
"page",
"length",
"page",
"start",
"and",
"total",
"items",
"from",
"a",
"query",
"object",
"s",
"limit",
"offset",
"and",
"unlimited",
"count",
".",
"The",
"query",
"MUST",
"have",
"a",
"limit",
"clause",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/PaginatedList.php#L175-L183 | train |
silverstripe/silverstripe-framework | src/ORM/PaginatedList.php | PaginatedList.Pages | public function Pages($max = null)
{
$result = new ArrayList();
if ($max) {
$start = ($this->CurrentPage() - floor($max / 2)) - 1;
$end = $this->CurrentPage() + floor($max / 2);
if ($start < 0) {
$start = 0;
$end = $max;
... | php | public function Pages($max = null)
{
$result = new ArrayList();
if ($max) {
$start = ($this->CurrentPage() - floor($max / 2)) - 1;
$end = $this->CurrentPage() + floor($max / 2);
if ($start < 0) {
$start = 0;
$end = $max;
... | [
"public",
"function",
"Pages",
"(",
"$",
"max",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"new",
"ArrayList",
"(",
")",
";",
"if",
"(",
"$",
"max",
")",
"{",
"$",
"start",
"=",
"(",
"$",
"this",
"->",
"CurrentPage",
"(",
")",
"-",
"floor",
"("... | Returns a set of links to all the pages in the list. This is useful for
basic pagination.
By default it returns links to every page, but if you pass the $max
parameter the number of pages will be limited to that number, centered
around the current page.
@param int $max
@return SS_List | [
"Returns",
"a",
"set",
"of",
"links",
"to",
"all",
"the",
"pages",
"in",
"the",
"list",
".",
"This",
"is",
"useful",
"for",
"basic",
"pagination",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/PaginatedList.php#L238-L273 | train |
silverstripe/silverstripe-framework | src/ORM/PaginatedList.php | PaginatedList.PaginationSummary | public function PaginationSummary($context = 4)
{
$result = new ArrayList();
$current = $this->CurrentPage();
$total = $this->TotalPages();
// Make the number even for offset calculations.
if ($context % 2) {
$context--;
}
// If the first or last... | php | public function PaginationSummary($context = 4)
{
$result = new ArrayList();
$current = $this->CurrentPage();
$total = $this->TotalPages();
// Make the number even for offset calculations.
if ($context % 2) {
$context--;
}
// If the first or last... | [
"public",
"function",
"PaginationSummary",
"(",
"$",
"context",
"=",
"4",
")",
"{",
"$",
"result",
"=",
"new",
"ArrayList",
"(",
")",
";",
"$",
"current",
"=",
"$",
"this",
"->",
"CurrentPage",
"(",
")",
";",
"$",
"total",
"=",
"$",
"this",
"->",
"... | Returns a summarised pagination which limits the number of pages shown
around the current page for visually balanced.
Example: 25 pages total, currently on page 6, context of 4 pages
[prev] [1] ... [4] [5] [[6]] [7] [8] ... [25] [next]
Example template usage:
<code>
<% if MyPages.MoreThanOnePage %>
<% if MyPages.NotF... | [
"Returns",
"a",
"summarised",
"pagination",
"which",
"limits",
"the",
"number",
"of",
"pages",
"shown",
"around",
"the",
"current",
"page",
"for",
"visually",
"balanced",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/PaginatedList.php#L310-L365 | train |
silverstripe/silverstripe-framework | src/ORM/PaginatedList.php | PaginatedList.LastItem | public function LastItem()
{
$pageLength = $this->getPageLength();
if (!$pageLength) {
return $this->getTotalItems();
} elseif ($start = $this->getPageStart()) {
return min($start + $pageLength, $this->getTotalItems());
} else {
return min($pageLen... | php | public function LastItem()
{
$pageLength = $this->getPageLength();
if (!$pageLength) {
return $this->getTotalItems();
} elseif ($start = $this->getPageStart()) {
return min($start + $pageLength, $this->getTotalItems());
} else {
return min($pageLen... | [
"public",
"function",
"LastItem",
"(",
")",
"{",
"$",
"pageLength",
"=",
"$",
"this",
"->",
"getPageLength",
"(",
")",
";",
"if",
"(",
"!",
"$",
"pageLength",
")",
"{",
"return",
"$",
"this",
"->",
"getTotalItems",
"(",
")",
";",
"}",
"elseif",
"(",
... | Returns the number of the last item being displayed on this page.
@return int | [
"Returns",
"the",
"number",
"of",
"the",
"last",
"item",
"being",
"displayed",
"on",
"this",
"page",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/PaginatedList.php#L429-L439 | train |
silverstripe/silverstripe-framework | src/ORM/PaginatedList.php | PaginatedList.FirstLink | public function FirstLink()
{
return HTTP::setGetVar(
$this->getPaginationGetVar(),
0,
($this->request instanceof HTTPRequest) ? $this->request->getURL(true) : null
);
} | php | public function FirstLink()
{
return HTTP::setGetVar(
$this->getPaginationGetVar(),
0,
($this->request instanceof HTTPRequest) ? $this->request->getURL(true) : null
);
} | [
"public",
"function",
"FirstLink",
"(",
")",
"{",
"return",
"HTTP",
"::",
"setGetVar",
"(",
"$",
"this",
"->",
"getPaginationGetVar",
"(",
")",
",",
"0",
",",
"(",
"$",
"this",
"->",
"request",
"instanceof",
"HTTPRequest",
")",
"?",
"$",
"this",
"->",
... | Returns a link to the first page.
@return string | [
"Returns",
"a",
"link",
"to",
"the",
"first",
"page",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/PaginatedList.php#L446-L453 | train |
silverstripe/silverstripe-framework | src/ORM/PaginatedList.php | PaginatedList.LastLink | public function LastLink()
{
return HTTP::setGetVar(
$this->getPaginationGetVar(),
($this->TotalPages() - 1) * $this->getPageLength(),
($this->request instanceof HTTPRequest) ? $this->request->getURL(true) : null
);
} | php | public function LastLink()
{
return HTTP::setGetVar(
$this->getPaginationGetVar(),
($this->TotalPages() - 1) * $this->getPageLength(),
($this->request instanceof HTTPRequest) ? $this->request->getURL(true) : null
);
} | [
"public",
"function",
"LastLink",
"(",
")",
"{",
"return",
"HTTP",
"::",
"setGetVar",
"(",
"$",
"this",
"->",
"getPaginationGetVar",
"(",
")",
",",
"(",
"$",
"this",
"->",
"TotalPages",
"(",
")",
"-",
"1",
")",
"*",
"$",
"this",
"->",
"getPageLength",
... | Returns a link to the last page.
@return string | [
"Returns",
"a",
"link",
"to",
"the",
"last",
"page",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/PaginatedList.php#L460-L467 | train |
silverstripe/silverstripe-framework | src/ORM/PaginatedList.php | PaginatedList.NextLink | public function NextLink()
{
if ($this->NotLastPage()) {
return HTTP::setGetVar(
$this->getPaginationGetVar(),
$this->getPageStart() + $this->getPageLength(),
($this->request instanceof HTTPRequest) ? $this->request->getURL(true) : null
... | php | public function NextLink()
{
if ($this->NotLastPage()) {
return HTTP::setGetVar(
$this->getPaginationGetVar(),
$this->getPageStart() + $this->getPageLength(),
($this->request instanceof HTTPRequest) ? $this->request->getURL(true) : null
... | [
"public",
"function",
"NextLink",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"NotLastPage",
"(",
")",
")",
"{",
"return",
"HTTP",
"::",
"setGetVar",
"(",
"$",
"this",
"->",
"getPaginationGetVar",
"(",
")",
",",
"$",
"this",
"->",
"getPageStart",
"(",... | Returns a link to the next page, if there is another page after the
current one.
@return string | [
"Returns",
"a",
"link",
"to",
"the",
"next",
"page",
"if",
"there",
"is",
"another",
"page",
"after",
"the",
"current",
"one",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/PaginatedList.php#L475-L484 | train |
silverstripe/silverstripe-framework | src/ORM/PaginatedList.php | PaginatedList.PrevLink | public function PrevLink()
{
if ($this->NotFirstPage()) {
return HTTP::setGetVar(
$this->getPaginationGetVar(),
$this->getPageStart() - $this->getPageLength(),
($this->request instanceof HTTPRequest) ? $this->request->getURL(true) : null
... | php | public function PrevLink()
{
if ($this->NotFirstPage()) {
return HTTP::setGetVar(
$this->getPaginationGetVar(),
$this->getPageStart() - $this->getPageLength(),
($this->request instanceof HTTPRequest) ? $this->request->getURL(true) : null
... | [
"public",
"function",
"PrevLink",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"NotFirstPage",
"(",
")",
")",
"{",
"return",
"HTTP",
"::",
"setGetVar",
"(",
"$",
"this",
"->",
"getPaginationGetVar",
"(",
")",
",",
"$",
"this",
"->",
"getPageStart",
"("... | Returns a link to the previous page, if the first page is not currently
active.
@return string | [
"Returns",
"a",
"link",
"to",
"the",
"previous",
"page",
"if",
"the",
"first",
"page",
"is",
"not",
"currently",
"active",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/PaginatedList.php#L492-L501 | train |
silverstripe/silverstripe-framework | src/Forms/FormScaffolder.php | FormScaffolder.addManyManyRelationshipFields | public static function addManyManyRelationshipFields(
FieldList &$fields,
$relationship,
$overrideFieldClass,
$tabbed,
DataObject $dataObject
) {
if ($tabbed) {
$fields->findOrMakeTab(
"Root.$relationship",
$dataObject->fiel... | php | public static function addManyManyRelationshipFields(
FieldList &$fields,
$relationship,
$overrideFieldClass,
$tabbed,
DataObject $dataObject
) {
if ($tabbed) {
$fields->findOrMakeTab(
"Root.$relationship",
$dataObject->fiel... | [
"public",
"static",
"function",
"addManyManyRelationshipFields",
"(",
"FieldList",
"&",
"$",
"fields",
",",
"$",
"relationship",
",",
"$",
"overrideFieldClass",
",",
"$",
"tabbed",
",",
"DataObject",
"$",
"dataObject",
")",
"{",
"if",
"(",
"$",
"tabbed",
")",
... | Adds the default many-many relation fields for the relationship provided.
@param FieldList $fields Reference to the @FieldList to add fields to.
@param string $relationship The relationship identifier.
@param mixed $overrideFieldClass Specify the field class to use here or leave as null to use default.
@param bool $ta... | [
"Adds",
"the",
"default",
"many",
"-",
"many",
"relation",
"fields",
"for",
"the",
"relationship",
"provided",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/FormScaffolder.php#L199-L229 | train |
silverstripe/silverstripe-framework | src/View/Parsers/ShortcodeParser.php | ShortcodeParser.register | public function register($shortcode, $callback)
{
if (is_callable($callback)) {
$this->shortcodes[$shortcode] = $callback;
} else {
throw new InvalidArgumentException("Callback is not callable");
}
return $this;
} | php | public function register($shortcode, $callback)
{
if (is_callable($callback)) {
$this->shortcodes[$shortcode] = $callback;
} else {
throw new InvalidArgumentException("Callback is not callable");
}
return $this;
} | [
"public",
"function",
"register",
"(",
"$",
"shortcode",
",",
"$",
"callback",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"$",
"this",
"->",
"shortcodes",
"[",
"$",
"shortcode",
"]",
"=",
"$",
"callback",
";",
"}",
"else... | Register a shortcode, and attach it to a PHP callback.
The callback for a shortcode will have the following arguments passed to it:
- Any parameters attached to the shortcode as an associative array (keys are lower-case).
- Any content enclosed within the shortcode (if it is an enclosing shortcode). Note that any cont... | [
"Register",
"a",
"shortcode",
"and",
"attach",
"it",
"to",
"a",
"PHP",
"callback",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/View/Parsers/ShortcodeParser.php#L105-L113 | train |
silverstripe/silverstripe-framework | src/View/Parsers/ShortcodeParser.php | ShortcodeParser.callShortcode | public function callShortcode($tag, $attributes, $content, $extra = array())
{
if (!$tag || !isset($this->shortcodes[$tag])) {
return false;
}
return call_user_func($this->shortcodes[$tag], $attributes, $content, $this, $tag, $extra);
} | php | public function callShortcode($tag, $attributes, $content, $extra = array())
{
if (!$tag || !isset($this->shortcodes[$tag])) {
return false;
}
return call_user_func($this->shortcodes[$tag], $attributes, $content, $this, $tag, $extra);
} | [
"public",
"function",
"callShortcode",
"(",
"$",
"tag",
",",
"$",
"attributes",
",",
"$",
"content",
",",
"$",
"extra",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"tag",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"shortcodes",
"[",
"... | Call a shortcode and return its replacement text
Returns false if the shortcode isn't registered
@param string $tag
@param array $attributes
@param string $content
@param array $extra
@return mixed | [
"Call",
"a",
"shortcode",
"and",
"return",
"its",
"replacement",
"text",
"Returns",
"false",
"if",
"the",
"shortcode",
"isn",
"t",
"registered"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/View/Parsers/ShortcodeParser.php#L166-L172 | train |
silverstripe/silverstripe-framework | src/View/Parsers/ShortcodeParser.php | ShortcodeParser.replaceTagsWithText | protected function replaceTagsWithText($content, $tags, $generator)
{
// The string with tags replaced with markers
$str = '';
// The start index of the next tag, remembered as we step backwards through the list
$li = null;
$i = count($tags);
while ($i--) {
... | php | protected function replaceTagsWithText($content, $tags, $generator)
{
// The string with tags replaced with markers
$str = '';
// The start index of the next tag, remembered as we step backwards through the list
$li = null;
$i = count($tags);
while ($i--) {
... | [
"protected",
"function",
"replaceTagsWithText",
"(",
"$",
"content",
",",
"$",
"tags",
",",
"$",
"generator",
")",
"{",
"// The string with tags replaced with markers",
"$",
"str",
"=",
"''",
";",
"// The start index of the next tag, remembered as we step backwards through th... | Replaces the shortcode tags extracted by extractTags with HTML element "markers", so that
we can parse the resulting string as HTML and easily mutate the shortcodes in the DOM
@param string $content The HTML string with [tag] style shortcodes embedded
@param array $tags The tags extracted by extractTags
@param callabl... | [
"Replaces",
"the",
"shortcode",
"tags",
"extracted",
"by",
"extractTags",
"with",
"HTML",
"element",
"markers",
"so",
"that",
"we",
"can",
"parse",
"the",
"resulting",
"string",
"as",
"HTML",
"and",
"easily",
"mutate",
"the",
"shortcodes",
"in",
"the",
"DOM"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/View/Parsers/ShortcodeParser.php#L432-L457 | train |
silverstripe/silverstripe-framework | src/View/Parsers/ShortcodeParser.php | ShortcodeParser.replaceAttributeTagsWithContent | protected function replaceAttributeTagsWithContent($htmlvalue)
{
$attributes = $htmlvalue->query('//@*[contains(.,"[")][contains(.,"]")]');
$parser = $this;
for ($i = 0; $i < $attributes->length; $i++) {
$node = $attributes->item($i);
$tags = $this->extractTags($node... | php | protected function replaceAttributeTagsWithContent($htmlvalue)
{
$attributes = $htmlvalue->query('//@*[contains(.,"[")][contains(.,"]")]');
$parser = $this;
for ($i = 0; $i < $attributes->length; $i++) {
$node = $attributes->item($i);
$tags = $this->extractTags($node... | [
"protected",
"function",
"replaceAttributeTagsWithContent",
"(",
"$",
"htmlvalue",
")",
"{",
"$",
"attributes",
"=",
"$",
"htmlvalue",
"->",
"query",
"(",
"'//@*[contains(.,\"[\")][contains(.,\"]\")]'",
")",
";",
"$",
"parser",
"=",
"$",
"this",
";",
"for",
"(",
... | Replace the shortcodes in attribute values with the calculated content
We don't use markers with attributes because there's no point, it's easier to do all the matching
in-DOM after the XML parse
@param HTMLValue $htmlvalue | [
"Replace",
"the",
"shortcodes",
"in",
"attribute",
"values",
"with",
"the",
"calculated",
"content"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/View/Parsers/ShortcodeParser.php#L467-L487 | train |
silverstripe/silverstripe-framework | src/View/Parsers/ShortcodeParser.php | ShortcodeParser.replaceElementTagsWithMarkers | protected function replaceElementTagsWithMarkers($content)
{
$tags = $this->extractTags($content);
if ($tags) {
$markerClass = self::$marker_class;
$content = $this->replaceTagsWithText($content, $tags, function ($idx, $tag) use ($markerClass) {
return '<img... | php | protected function replaceElementTagsWithMarkers($content)
{
$tags = $this->extractTags($content);
if ($tags) {
$markerClass = self::$marker_class;
$content = $this->replaceTagsWithText($content, $tags, function ($idx, $tag) use ($markerClass) {
return '<img... | [
"protected",
"function",
"replaceElementTagsWithMarkers",
"(",
"$",
"content",
")",
"{",
"$",
"tags",
"=",
"$",
"this",
"->",
"extractTags",
"(",
"$",
"content",
")",
";",
"if",
"(",
"$",
"tags",
")",
"{",
"$",
"markerClass",
"=",
"self",
"::",
"$",
"m... | Replace the element-scoped tags with markers
@param string $content
@return array | [
"Replace",
"the",
"element",
"-",
"scoped",
"tags",
"with",
"markers"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/View/Parsers/ShortcodeParser.php#L495-L508 | train |
silverstripe/silverstripe-framework | src/View/Parsers/ShortcodeParser.php | ShortcodeParser.moveMarkerToCompliantHome | protected function moveMarkerToCompliantHome($node, $parent, $location)
{
// Move before block parent
if ($location == self::BEFORE) {
if (isset($parent->parentNode)) {
$parent->parentNode->insertBefore($node, $parent);
}
} elseif ($location == self::A... | php | protected function moveMarkerToCompliantHome($node, $parent, $location)
{
// Move before block parent
if ($location == self::BEFORE) {
if (isset($parent->parentNode)) {
$parent->parentNode->insertBefore($node, $parent);
}
} elseif ($location == self::A... | [
"protected",
"function",
"moveMarkerToCompliantHome",
"(",
"$",
"node",
",",
"$",
"parent",
",",
"$",
"location",
")",
"{",
"// Move before block parent",
"if",
"(",
"$",
"location",
"==",
"self",
"::",
"BEFORE",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"pa... | Given a node with represents a shortcode marker and a location string, mutates the DOM to put the
marker in the compliant location
For shortcodes inserted BEFORE, that location is just before the block container that
the marker is in
For shortcodes inserted AFTER, that location is just after the block container that
... | [
"Given",
"a",
"node",
"with",
"represents",
"a",
"shortcode",
"marker",
"and",
"a",
"location",
"string",
"mutates",
"the",
"DOM",
"to",
"put",
"the",
"marker",
"in",
"the",
"compliant",
"location"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/View/Parsers/ShortcodeParser.php#L566-L608 | train |
silverstripe/silverstripe-framework | src/View/Parsers/ShortcodeParser.php | ShortcodeParser.replaceMarkerWithContent | protected function replaceMarkerWithContent($node, $tag)
{
$content = $this->getShortcodeReplacementText($tag);
if ($content) {
/** @var HTMLValue $parsed */
$parsed = HTMLValue::create($content);
$body = $parsed->getBody();
if ($body) {
... | php | protected function replaceMarkerWithContent($node, $tag)
{
$content = $this->getShortcodeReplacementText($tag);
if ($content) {
/** @var HTMLValue $parsed */
$parsed = HTMLValue::create($content);
$body = $parsed->getBody();
if ($body) {
... | [
"protected",
"function",
"replaceMarkerWithContent",
"(",
"$",
"node",
",",
"$",
"tag",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"getShortcodeReplacementText",
"(",
"$",
"tag",
")",
";",
"if",
"(",
"$",
"content",
")",
"{",
"/** @var HTMLValue $pars... | Given a node with represents a shortcode marker and some information about the shortcode, call the
shortcode handler & replace the marker with the actual content
@param DOMElement $node
@param array $tag | [
"Given",
"a",
"node",
"with",
"represents",
"a",
"shortcode",
"marker",
"and",
"some",
"information",
"about",
"the",
"shortcode",
"call",
"the",
"shortcode",
"handler",
"&",
"replace",
"the",
"marker",
"with",
"the",
"actual",
"content"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/View/Parsers/ShortcodeParser.php#L617-L631 | train |
silverstripe/silverstripe-framework | src/View/Parsers/ShortcodeParser.php | ShortcodeParser.parse | public function parse($content)
{
$this->extend('onBeforeParse', $content);
$continue = true;
// If no shortcodes defined, don't try and parse any
if (!$this->shortcodes) {
$continue = false;
} elseif (!trim($content)) {
// If no content, don't try a... | php | public function parse($content)
{
$this->extend('onBeforeParse', $content);
$continue = true;
// If no shortcodes defined, don't try and parse any
if (!$this->shortcodes) {
$continue = false;
} elseif (!trim($content)) {
// If no content, don't try a... | [
"public",
"function",
"parse",
"(",
"$",
"content",
")",
"{",
"$",
"this",
"->",
"extend",
"(",
"'onBeforeParse'",
",",
"$",
"content",
")",
";",
"$",
"continue",
"=",
"true",
";",
"// If no shortcodes defined, don't try and parse any",
"if",
"(",
"!",
"$",
... | Parse a string, and replace any registered shortcodes within it with the result of the mapped callback.
@param string $content
@return string | [
"Parse",
"a",
"string",
"and",
"replace",
"any",
"registered",
"shortcodes",
"within",
"it",
"with",
"the",
"result",
"of",
"the",
"mapped",
"callback",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/View/Parsers/ShortcodeParser.php#L639-L740 | train |
silverstripe/silverstripe-framework | src/View/ArrayData.php | ArrayData.getField | public function getField($field)
{
$value = $this->array[$field];
if (is_object($value) && !$value instanceof ViewableData) {
return new ArrayData($value);
} elseif (ArrayLib::is_associative($value)) {
return new ArrayData($value);
} else {
return ... | php | public function getField($field)
{
$value = $this->array[$field];
if (is_object($value) && !$value instanceof ViewableData) {
return new ArrayData($value);
} elseif (ArrayLib::is_associative($value)) {
return new ArrayData($value);
} else {
return ... | [
"public",
"function",
"getField",
"(",
"$",
"field",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"array",
"[",
"$",
"field",
"]",
";",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
"&&",
"!",
"$",
"value",
"instanceof",
"ViewableData",
")",
"... | Gets a field from this object.
If the value is an object but not an instance of
ViewableData, it will be converted recursively to an
ArrayData.
If the value is an associative array, it will likewise be
converted recursively to an ArrayData.
@param string $field
@return mixed | [
"Gets",
"a",
"field",
"from",
"this",
"object",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/View/ArrayData.php#L71-L81 | train |
silverstripe/silverstripe-framework | src/View/ArrayData.php | ArrayData.array_to_object | public static function array_to_object($arr = null)
{
$obj = new stdClass();
if ($arr) {
foreach ($arr as $name => $value) {
$obj->$name = $value;
}
}
return $obj;
} | php | public static function array_to_object($arr = null)
{
$obj = new stdClass();
if ($arr) {
foreach ($arr as $name => $value) {
$obj->$name = $value;
}
}
return $obj;
} | [
"public",
"static",
"function",
"array_to_object",
"(",
"$",
"arr",
"=",
"null",
")",
"{",
"$",
"obj",
"=",
"new",
"stdClass",
"(",
")",
";",
"if",
"(",
"$",
"arr",
")",
"{",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"name",
"=>",
"$",
"value",
")",... | Converts an associative array to a simple object
@param array
@return stdClass $obj | [
"Converts",
"an",
"associative",
"array",
"to",
"a",
"simple",
"object"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/View/ArrayData.php#L112-L121 | train |
silverstripe/silverstripe-framework | src/Core/Manifest/ClassManifest.php | ClassManifest.getParser | public function getParser()
{
if (!$this->parser) {
$this->parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7);
}
return $this->parser;
} | php | public function getParser()
{
if (!$this->parser) {
$this->parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7);
}
return $this->parser;
} | [
"public",
"function",
"getParser",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"parser",
")",
"{",
"$",
"this",
"->",
"parser",
"=",
"(",
"new",
"ParserFactory",
")",
"->",
"create",
"(",
"ParserFactory",
"::",
"PREFER_PHP7",
")",
";",
"}",
"re... | Get or create active parser
@return Parser | [
"Get",
"or",
"create",
"active",
"parser"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Manifest/ClassManifest.php#L218-L225 | train |
silverstripe/silverstripe-framework | src/Core/Manifest/ClassManifest.php | ClassManifest.getTraverser | public function getTraverser()
{
if (!$this->traverser) {
$this->traverser = new NodeTraverser;
$this->traverser->addVisitor(new NameResolver);
$this->traverser->addVisitor($this->getVisitor());
}
return $this->traverser;
} | php | public function getTraverser()
{
if (!$this->traverser) {
$this->traverser = new NodeTraverser;
$this->traverser->addVisitor(new NameResolver);
$this->traverser->addVisitor($this->getVisitor());
}
return $this->traverser;
} | [
"public",
"function",
"getTraverser",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"traverser",
")",
"{",
"$",
"this",
"->",
"traverser",
"=",
"new",
"NodeTraverser",
";",
"$",
"this",
"->",
"traverser",
"->",
"addVisitor",
"(",
"new",
"NameResolver... | Get node traverser for parsing class files
@return NodeTraverser | [
"Get",
"node",
"traverser",
"for",
"parsing",
"class",
"files"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Manifest/ClassManifest.php#L232-L241 | train |
silverstripe/silverstripe-framework | src/Core/Manifest/ClassManifest.php | ClassManifest.getItemPath | public function getItemPath($name)
{
$lowerName = strtolower($name);
foreach ([
$this->classes,
$this->interfaces,
$this->traits,
] as $source) {
if (isset($source[$lowerName]) && file_exists($source[$lowerName])) {
return $... | php | public function getItemPath($name)
{
$lowerName = strtolower($name);
foreach ([
$this->classes,
$this->interfaces,
$this->traits,
] as $source) {
if (isset($source[$lowerName]) && file_exists($source[$lowerName])) {
return $... | [
"public",
"function",
"getItemPath",
"(",
"$",
"name",
")",
"{",
"$",
"lowerName",
"=",
"strtolower",
"(",
"$",
"name",
")",
";",
"foreach",
"(",
"[",
"$",
"this",
"->",
"classes",
",",
"$",
"this",
"->",
"interfaces",
",",
"$",
"this",
"->",
"traits... | Returns the file path to a class or interface if it exists in the
manifest.
@param string $name
@return string|null | [
"Returns",
"the",
"file",
"path",
"to",
"a",
"class",
"or",
"interface",
"if",
"it",
"exists",
"in",
"the",
"manifest",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Manifest/ClassManifest.php#L264-L277 | train |
silverstripe/silverstripe-framework | src/Core/Manifest/ClassManifest.php | ClassManifest.getItemName | public function getItemName($name)
{
$lowerName = strtolower($name);
foreach ([
$this->classNames,
$this->interfaceNames,
$this->traitNames,
] as $source) {
if (isset($source[$lowerName])) {
return $source[$lowerName];
... | php | public function getItemName($name)
{
$lowerName = strtolower($name);
foreach ([
$this->classNames,
$this->interfaceNames,
$this->traitNames,
] as $source) {
if (isset($source[$lowerName])) {
return $source[$lowerName];
... | [
"public",
"function",
"getItemName",
"(",
"$",
"name",
")",
"{",
"$",
"lowerName",
"=",
"strtolower",
"(",
"$",
"name",
")",
";",
"foreach",
"(",
"[",
"$",
"this",
"->",
"classNames",
",",
"$",
"this",
"->",
"interfaceNames",
",",
"$",
"this",
"->",
... | Return correct case name
@param string $name
@return string Correct case name | [
"Return",
"correct",
"case",
"name"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Manifest/ClassManifest.php#L285-L298 | train |
silverstripe/silverstripe-framework | src/Core/Manifest/ClassManifest.php | ClassManifest.getImplementorsOf | public function getImplementorsOf($interface)
{
$lowerInterface = strtolower($interface);
if (array_key_exists($lowerInterface, $this->implementors)) {
return $this->implementors[$lowerInterface];
} else {
return array();
}
} | php | public function getImplementorsOf($interface)
{
$lowerInterface = strtolower($interface);
if (array_key_exists($lowerInterface, $this->implementors)) {
return $this->implementors[$lowerInterface];
} else {
return array();
}
} | [
"public",
"function",
"getImplementorsOf",
"(",
"$",
"interface",
")",
"{",
"$",
"lowerInterface",
"=",
"strtolower",
"(",
"$",
"interface",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"lowerInterface",
",",
"$",
"this",
"->",
"implementors",
")",
")"... | Returns an array containing the class names that implement a certain
interface.
@param string $interface
@return array | [
"Returns",
"an",
"array",
"containing",
"the",
"class",
"names",
"that",
"implement",
"a",
"certain",
"interface",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Manifest/ClassManifest.php#L409-L417 | train |
silverstripe/silverstripe-framework | src/Core/Manifest/ClassManifest.php | ClassManifest.regenerate | public function regenerate($includeTests)
{
// Reset the manifest so stale info doesn't cause errors.
$this->loadState([]);
$this->roots = [];
$this->children = [];
$finder = new ManifestFileFinder();
$finder->setOptions(array(
'name_regex' => '/^[^_].*\\... | php | public function regenerate($includeTests)
{
// Reset the manifest so stale info doesn't cause errors.
$this->loadState([]);
$this->roots = [];
$this->children = [];
$finder = new ManifestFileFinder();
$finder->setOptions(array(
'name_regex' => '/^[^_].*\\... | [
"public",
"function",
"regenerate",
"(",
"$",
"includeTests",
")",
"{",
"// Reset the manifest so stale info doesn't cause errors.",
"$",
"this",
"->",
"loadState",
"(",
"[",
"]",
")",
";",
"$",
"this",
"->",
"roots",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"... | Completely regenerates the manifest file.
@param bool $includeTests | [
"Completely",
"regenerates",
"the",
"manifest",
"file",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Manifest/ClassManifest.php#L436-L462 | train |
silverstripe/silverstripe-framework | src/Core/Manifest/ClassManifest.php | ClassManifest.coalesceDescendants | protected function coalesceDescendants($class)
{
// Reset descendents to immediate children initially
$lowerClass = strtolower($class);
if (empty($this->children[$lowerClass])) {
return [];
}
// Coalasce children into descendent list
$this->descendants[$l... | php | protected function coalesceDescendants($class)
{
// Reset descendents to immediate children initially
$lowerClass = strtolower($class);
if (empty($this->children[$lowerClass])) {
return [];
}
// Coalasce children into descendent list
$this->descendants[$l... | [
"protected",
"function",
"coalesceDescendants",
"(",
"$",
"class",
")",
"{",
"// Reset descendents to immediate children initially",
"$",
"lowerClass",
"=",
"strtolower",
"(",
"$",
"class",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"children",
"[",
"... | Recursively coalesces direct child information into full descendant
information.
@param string $class
@return array | [
"Recursively",
"coalesces",
"direct",
"child",
"information",
"into",
"full",
"descendant",
"information",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Manifest/ClassManifest.php#L587-L605 | train |
silverstripe/silverstripe-framework | src/Core/Manifest/ClassManifest.php | ClassManifest.loadState | protected function loadState($data)
{
$success = true;
foreach ($this->serialisedProperties as $property) {
if (!isset($data[$property]) || !is_array($data[$property])) {
$success = false;
$value = [];
} else {
$value = $data[$p... | php | protected function loadState($data)
{
$success = true;
foreach ($this->serialisedProperties as $property) {
if (!isset($data[$property]) || !is_array($data[$property])) {
$success = false;
$value = [];
} else {
$value = $data[$p... | [
"protected",
"function",
"loadState",
"(",
"$",
"data",
")",
"{",
"$",
"success",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"serialisedProperties",
"as",
"$",
"property",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"$",
"prop... | Reload state from given cache data
@param array $data
@return bool True if cache was valid and successfully loaded | [
"Reload",
"state",
"from",
"given",
"cache",
"data"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Manifest/ClassManifest.php#L613-L626 | train |
silverstripe/silverstripe-framework | src/Core/Manifest/ClassManifest.php | ClassManifest.getState | protected function getState()
{
$data = [];
foreach ($this->serialisedProperties as $property) {
$data[$property] = $this->$property;
}
return $data;
} | php | protected function getState()
{
$data = [];
foreach ($this->serialisedProperties as $property) {
$data[$property] = $this->$property;
}
return $data;
} | [
"protected",
"function",
"getState",
"(",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"serialisedProperties",
"as",
"$",
"property",
")",
"{",
"$",
"data",
"[",
"$",
"property",
"]",
"=",
"$",
"this",
"->",
"$",
"p... | Load current state into an array of data
@return array | [
"Load",
"current",
"state",
"into",
"an",
"array",
"of",
"data"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Manifest/ClassManifest.php#L633-L640 | train |
silverstripe/silverstripe-framework | src/Core/Manifest/ClassManifest.php | ClassManifest.validateItemCache | protected function validateItemCache($data)
{
if (!$data || !is_array($data)) {
return false;
}
foreach (['classes', 'interfaces', 'traits'] as $key) {
// Must be set
if (!isset($data[$key])) {
return false;
}
// and... | php | protected function validateItemCache($data)
{
if (!$data || !is_array($data)) {
return false;
}
foreach (['classes', 'interfaces', 'traits'] as $key) {
// Must be set
if (!isset($data[$key])) {
return false;
}
// and... | [
"protected",
"function",
"validateItemCache",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"$",
"data",
"||",
"!",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"[",
"'classes'",
",",
"'interfaces'",
",",
"'... | Verify that cached data is valid for a single item
@param array $data
@return bool | [
"Verify",
"that",
"cached",
"data",
"is",
"valid",
"for",
"a",
"single",
"item"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Manifest/ClassManifest.php#L648-L669 | train |
silverstripe/silverstripe-framework | src/View/Parsers/HTMLValue.php | HTMLValue.getDocument | public function getDocument()
{
if (!$this->valid) {
return false;
} elseif ($this->document) {
return $this->document;
} else {
$this->document = new DOMDocument('1.0', 'UTF-8');
$this->document->strictErrorChecking = false;
$this-... | php | public function getDocument()
{
if (!$this->valid) {
return false;
} elseif ($this->document) {
return $this->document;
} else {
$this->document = new DOMDocument('1.0', 'UTF-8');
$this->document->strictErrorChecking = false;
$this-... | [
"public",
"function",
"getDocument",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"valid",
")",
"{",
"return",
"false",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"document",
")",
"{",
"return",
"$",
"this",
"->",
"document",
";",
"}",
"else"... | Get the DOMDocument for the passed content
@return DOMDocument | false - Return false if HTML not valid, the DOMDocument instance otherwise | [
"Get",
"the",
"DOMDocument",
"for",
"the",
"passed",
"content"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/View/Parsers/HTMLValue.php#L99-L112 | train |
silverstripe/silverstripe-framework | src/Forms/GridField/GridField.php | GridField.getModelClass | public function getModelClass()
{
if ($this->modelClassName) {
return $this->modelClassName;
}
/** @var DataList|ArrayList $list */
$list = $this->list;
if ($list && $list->hasMethod('dataClass')) {
$class = $list->dataClass();
if ($class... | php | public function getModelClass()
{
if ($this->modelClassName) {
return $this->modelClassName;
}
/** @var DataList|ArrayList $list */
$list = $this->list;
if ($list && $list->hasMethod('dataClass')) {
$class = $list->dataClass();
if ($class... | [
"public",
"function",
"getModelClass",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"modelClassName",
")",
"{",
"return",
"$",
"this",
"->",
"modelClassName",
";",
"}",
"/** @var DataList|ArrayList $list */",
"$",
"list",
"=",
"$",
"this",
"->",
"list",
";",... | Returns a data class that is a DataObject type that this GridField should look like.
@return string
@throws LogicException | [
"Returns",
"a",
"data",
"class",
"that",
"is",
"a",
"DataObject",
"type",
"that",
"this",
"GridField",
"should",
"look",
"like",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/GridField/GridField.php#L199-L218 | train |
silverstripe/silverstripe-framework | src/Forms/GridField/GridField.php | GridField.performReadonlyTransformation | public function performReadonlyTransformation()
{
$copy = clone $this;
$copy->setReadonly(true);
$copyConfig = $copy->getConfig();
// get the whitelist for allowable readonly components
$allowedComponents = $this->getReadonlyComponents();
foreach ($this->getConfig()-... | php | public function performReadonlyTransformation()
{
$copy = clone $this;
$copy->setReadonly(true);
$copyConfig = $copy->getConfig();
// get the whitelist for allowable readonly components
$allowedComponents = $this->getReadonlyComponents();
foreach ($this->getConfig()-... | [
"public",
"function",
"performReadonlyTransformation",
"(",
")",
"{",
"$",
"copy",
"=",
"clone",
"$",
"this",
";",
"$",
"copy",
"->",
"setReadonly",
"(",
"true",
")",
";",
"$",
"copyConfig",
"=",
"$",
"copy",
"->",
"getConfig",
"(",
")",
";",
"// get the... | Custom Readonly transformation to remove actions which shouldn't be present for a readonly state.
@return GridField | [
"Custom",
"Readonly",
"transformation",
"to",
"remove",
"actions",
"which",
"shouldn",
"t",
"be",
"present",
"for",
"a",
"readonly",
"state",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/GridField/GridField.php#L245-L266 | train |
silverstripe/silverstripe-framework | src/Forms/GridField/GridField.php | GridField.getColumns | public function getColumns()
{
$columns = array();
foreach ($this->getComponents() as $item) {
if ($item instanceof GridField_ColumnProvider) {
$item->augmentColumns($this, $columns);
}
}
return $columns;
} | php | public function getColumns()
{
$columns = array();
foreach ($this->getComponents() as $item) {
if ($item instanceof GridField_ColumnProvider) {
$item->augmentColumns($this, $columns);
}
}
return $columns;
} | [
"public",
"function",
"getColumns",
"(",
")",
"{",
"$",
"columns",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getComponents",
"(",
")",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"instanceof",
"GridField_ColumnProvider",
... | Get the columns of this GridField, they are provided by attached GridField_ColumnProvider.
@return array | [
"Get",
"the",
"columns",
"of",
"this",
"GridField",
"they",
"are",
"provided",
"by",
"attached",
"GridField_ColumnProvider",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/GridField/GridField.php#L758-L769 | train |
silverstripe/silverstripe-framework | src/Forms/GridField/GridField.php | GridField.getColumnContent | public function getColumnContent($record, $column)
{
if (!$this->columnDispatch) {
$this->buildColumnDispatch();
}
if (!empty($this->columnDispatch[$column])) {
$content = '';
foreach ($this->columnDispatch[$column] as $handler) {
/**
... | php | public function getColumnContent($record, $column)
{
if (!$this->columnDispatch) {
$this->buildColumnDispatch();
}
if (!empty($this->columnDispatch[$column])) {
$content = '';
foreach ($this->columnDispatch[$column] as $handler) {
/**
... | [
"public",
"function",
"getColumnContent",
"(",
"$",
"record",
",",
"$",
"column",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"columnDispatch",
")",
"{",
"$",
"this",
"->",
"buildColumnDispatch",
"(",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$"... | Get the value from a column.
@param DataObject $record
@param string $column
@return string
@throws InvalidArgumentException | [
"Get",
"the",
"value",
"from",
"a",
"column",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/GridField/GridField.php#L781-L804 | train |
silverstripe/silverstripe-framework | src/Forms/GridField/GridField.php | GridField.addDataFields | public function addDataFields($fields)
{
if ($this->customDataFields) {
$this->customDataFields = array_merge($this->customDataFields, $fields);
} else {
$this->customDataFields = $fields;
}
} | php | public function addDataFields($fields)
{
if ($this->customDataFields) {
$this->customDataFields = array_merge($this->customDataFields, $fields);
} else {
$this->customDataFields = $fields;
}
} | [
"public",
"function",
"addDataFields",
"(",
"$",
"fields",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"customDataFields",
")",
"{",
"$",
"this",
"->",
"customDataFields",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"customDataFields",
",",
"$",
"fields",
")",... | Add additional calculated data fields to be used on this GridField
@param array $fields a map of fieldname to callback. The callback will
be passed the record as an argument. | [
"Add",
"additional",
"calculated",
"data",
"fields",
"to",
"be",
"used",
"on",
"this",
"GridField"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/GridField/GridField.php#L812-L819 | train |
silverstripe/silverstripe-framework | src/Forms/GridField/GridField.php | GridField.getDataFieldValue | public function getDataFieldValue($record, $fieldName)
{
if (isset($this->customDataFields[$fieldName])) {
$callback = $this->customDataFields[$fieldName];
return $callback($record);
}
if ($record->hasMethod('relField')) {
return $record->relField($field... | php | public function getDataFieldValue($record, $fieldName)
{
if (isset($this->customDataFields[$fieldName])) {
$callback = $this->customDataFields[$fieldName];
return $callback($record);
}
if ($record->hasMethod('relField')) {
return $record->relField($field... | [
"public",
"function",
"getDataFieldValue",
"(",
"$",
"record",
",",
"$",
"fieldName",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"customDataFields",
"[",
"$",
"fieldName",
"]",
")",
")",
"{",
"$",
"callback",
"=",
"$",
"this",
"->",
"customD... | Get the value of a named field on the given record.
Use of this method ensures that any special rules around the data for this gridfield are
followed.
@param DataObject $record
@param string $fieldName
@return mixed | [
"Get",
"the",
"value",
"of",
"a",
"named",
"field",
"on",
"the",
"given",
"record",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/GridField/GridField.php#L832-L849 | train |
silverstripe/silverstripe-framework | src/Forms/GridField/GridField.php | GridField.getColumnAttributes | public function getColumnAttributes($record, $column)
{
if (!$this->columnDispatch) {
$this->buildColumnDispatch();
}
if (!empty($this->columnDispatch[$column])) {
$attributes = array();
foreach ($this->columnDispatch[$column] as $handler) {
... | php | public function getColumnAttributes($record, $column)
{
if (!$this->columnDispatch) {
$this->buildColumnDispatch();
}
if (!empty($this->columnDispatch[$column])) {
$attributes = array();
foreach ($this->columnDispatch[$column] as $handler) {
... | [
"public",
"function",
"getColumnAttributes",
"(",
"$",
"record",
",",
"$",
"column",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"columnDispatch",
")",
"{",
"$",
"this",
"->",
"buildColumnDispatch",
"(",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
... | Get extra columns attributes used as HTML attributes.
@param DataObject $record
@param string $column
@return array
@throws LogicException
@throws InvalidArgumentException | [
"Get",
"extra",
"columns",
"attributes",
"used",
"as",
"HTML",
"attributes",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/GridField/GridField.php#L862-L895 | train |
silverstripe/silverstripe-framework | src/Forms/GridField/GridField.php | GridField.getColumnMetadata | public function getColumnMetadata($column)
{
if (!$this->columnDispatch) {
$this->buildColumnDispatch();
}
if (!empty($this->columnDispatch[$column])) {
$metaData = array();
foreach ($this->columnDispatch[$column] as $handler) {
/**
... | php | public function getColumnMetadata($column)
{
if (!$this->columnDispatch) {
$this->buildColumnDispatch();
}
if (!empty($this->columnDispatch[$column])) {
$metaData = array();
foreach ($this->columnDispatch[$column] as $handler) {
/**
... | [
"public",
"function",
"getColumnMetadata",
"(",
"$",
"column",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"columnDispatch",
")",
"{",
"$",
"this",
"->",
"buildColumnDispatch",
"(",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"co... | Get metadata for a column.
@example "array('Title'=>'Email address')"
@param string $column
@return array
@throws LogicException
@throws InvalidArgumentException | [
"Get",
"metadata",
"for",
"a",
"column",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/GridField/GridField.php#L909-L942 | train |
silverstripe/silverstripe-framework | src/Forms/GridField/GridField.php | GridField.buildColumnDispatch | protected function buildColumnDispatch()
{
$this->columnDispatch = array();
foreach ($this->getComponents() as $item) {
if ($item instanceof GridField_ColumnProvider) {
$columns = $item->getColumnsHandled($this);
foreach ($columns as $column) {
... | php | protected function buildColumnDispatch()
{
$this->columnDispatch = array();
foreach ($this->getComponents() as $item) {
if ($item instanceof GridField_ColumnProvider) {
$columns = $item->getColumnsHandled($this);
foreach ($columns as $column) {
... | [
"protected",
"function",
"buildColumnDispatch",
"(",
")",
"{",
"$",
"this",
"->",
"columnDispatch",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getComponents",
"(",
")",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"instanc... | Build an columnDispatch that maps a GridField_ColumnProvider to a column for reference later. | [
"Build",
"an",
"columnDispatch",
"that",
"maps",
"a",
"GridField_ColumnProvider",
"to",
"a",
"column",
"for",
"reference",
"later",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/GridField/GridField.php#L961-L974 | train |
silverstripe/silverstripe-framework | src/Forms/GridField/GridField.php | GridField.gridFieldAlterAction | public function gridFieldAlterAction($data, $form, HTTPRequest $request)
{
$data = $request->requestVars();
// Protection against CSRF attacks
$token = $this
->getForm()
->getSecurityToken();
if (!$token->checkRequest($request)) {
$this->httpError... | php | public function gridFieldAlterAction($data, $form, HTTPRequest $request)
{
$data = $request->requestVars();
// Protection against CSRF attacks
$token = $this
->getForm()
->getSecurityToken();
if (!$token->checkRequest($request)) {
$this->httpError... | [
"public",
"function",
"gridFieldAlterAction",
"(",
"$",
"data",
",",
"$",
"form",
",",
"HTTPRequest",
"$",
"request",
")",
"{",
"$",
"data",
"=",
"$",
"request",
"->",
"requestVars",
"(",
")",
";",
"// Protection against CSRF attacks",
"$",
"token",
"=",
"$"... | This is the action that gets executed when a GridField_AlterAction gets clicked.
@param array $data
@param Form $form
@param HTTPRequest $request
@return string | [
"This",
"is",
"the",
"action",
"that",
"gets",
"executed",
"when",
"a",
"GridField_AlterAction",
"gets",
"clicked",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/GridField/GridField.php#L985-L1047 | train |
silverstripe/silverstripe-framework | src/Forms/GridField/GridField.php | GridField.handleRequest | public function handleRequest(HTTPRequest $request)
{
if ($this->brokenOnConstruct) {
user_error(
sprintf(
"parent::__construct() needs to be called on %s::__construct()",
__CLASS__
),
E_USER_WARNING
... | php | public function handleRequest(HTTPRequest $request)
{
if ($this->brokenOnConstruct) {
user_error(
sprintf(
"parent::__construct() needs to be called on %s::__construct()",
__CLASS__
),
E_USER_WARNING
... | [
"public",
"function",
"handleRequest",
"(",
"HTTPRequest",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"brokenOnConstruct",
")",
"{",
"user_error",
"(",
"sprintf",
"(",
"\"parent::__construct() needs to be called on %s::__construct()\"",
",",
"__CLASS__",
... | Custom request handler that will check component handlers before proceeding to the default
implementation.
@todo copy less code from RequestHandler.
@param HTTPRequest $request
@return array|RequestHandler|HTTPResponse|string
@throws HTTPResponse_Exception | [
"Custom",
"request",
"handler",
"that",
"will",
"check",
"component",
"handlers",
"before",
"proceeding",
"to",
"the",
"default",
"implementation",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/GridField/GridField.php#L1090-L1180 | train |
silverstripe/silverstripe-framework | src/Security/DefaultAdminService.php | DefaultAdminService.setDefaultAdmin | public static function setDefaultAdmin($username, $password)
{
// don't overwrite if already set
if (static::hasDefaultAdmin()) {
throw new BadMethodCallException(
"Default admin already exists. Use clearDefaultAdmin() first."
);
}
if (empty($... | php | public static function setDefaultAdmin($username, $password)
{
// don't overwrite if already set
if (static::hasDefaultAdmin()) {
throw new BadMethodCallException(
"Default admin already exists. Use clearDefaultAdmin() first."
);
}
if (empty($... | [
"public",
"static",
"function",
"setDefaultAdmin",
"(",
"$",
"username",
",",
"$",
"password",
")",
"{",
"// don't overwrite if already set",
"if",
"(",
"static",
"::",
"hasDefaultAdmin",
"(",
")",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"\"Defaul... | Set the default admin credentials
@param string $username
@param string $password | [
"Set",
"the",
"default",
"admin",
"credentials"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Security/DefaultAdminService.php#L49-L65 | train |
silverstripe/silverstripe-framework | src/Security/DefaultAdminService.php | DefaultAdminService.hasDefaultAdmin | public static function hasDefaultAdmin()
{
// Check environment if not explicitly set
if (!isset(static::$has_default_admin)) {
return !empty(Environment::getEnv('SS_DEFAULT_ADMIN_USERNAME'))
&& !empty(Environment::getEnv('SS_DEFAULT_ADMIN_PASSWORD'));
}
r... | php | public static function hasDefaultAdmin()
{
// Check environment if not explicitly set
if (!isset(static::$has_default_admin)) {
return !empty(Environment::getEnv('SS_DEFAULT_ADMIN_USERNAME'))
&& !empty(Environment::getEnv('SS_DEFAULT_ADMIN_PASSWORD'));
}
r... | [
"public",
"static",
"function",
"hasDefaultAdmin",
"(",
")",
"{",
"// Check environment if not explicitly set",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"has_default_admin",
")",
")",
"{",
"return",
"!",
"empty",
"(",
"Environment",
"::",
"getEnv",
"("... | Check if there is a default admin
@return bool | [
"Check",
"if",
"there",
"is",
"a",
"default",
"admin"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Security/DefaultAdminService.php#L100-L108 | train |
silverstripe/silverstripe-framework | src/Security/DefaultAdminService.php | DefaultAdminService.findOrCreateAdmin | public function findOrCreateAdmin($email, $name = null)
{
$this->extend('beforeFindOrCreateAdmin', $email, $name);
// Find member
/** @var Member $admin */
$admin = Member::get()
->filter('Email', $email)
->first();
// Find or create admin group
... | php | public function findOrCreateAdmin($email, $name = null)
{
$this->extend('beforeFindOrCreateAdmin', $email, $name);
// Find member
/** @var Member $admin */
$admin = Member::get()
->filter('Email', $email)
->first();
// Find or create admin group
... | [
"public",
"function",
"findOrCreateAdmin",
"(",
"$",
"email",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"extend",
"(",
"'beforeFindOrCreateAdmin'",
",",
"$",
"email",
",",
"$",
"name",
")",
";",
"// Find member",
"/** @var Member $admin */",
... | Find or create a Member with admin permissions
@skipUpgrade
@param string $email
@param string $name
@return Member | [
"Find",
"or",
"create",
"a",
"Member",
"with",
"admin",
"permissions"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Security/DefaultAdminService.php#L151-L190 | train |
silverstripe/silverstripe-framework | src/Security/DefaultAdminService.php | DefaultAdminService.findOrCreateAdminGroup | protected function findOrCreateAdminGroup()
{
// Check pre-existing group
$adminGroup = Permission::get_groups_by_permission('ADMIN')->first();
if ($adminGroup) {
return $adminGroup;
}
// Check if default records create the group
Group::singleton()->requi... | php | protected function findOrCreateAdminGroup()
{
// Check pre-existing group
$adminGroup = Permission::get_groups_by_permission('ADMIN')->first();
if ($adminGroup) {
return $adminGroup;
}
// Check if default records create the group
Group::singleton()->requi... | [
"protected",
"function",
"findOrCreateAdminGroup",
"(",
")",
"{",
"// Check pre-existing group",
"$",
"adminGroup",
"=",
"Permission",
"::",
"get_groups_by_permission",
"(",
"'ADMIN'",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"adminGroup",
")",
"{",
"r... | Ensure a Group exists with admin permission
@return Group | [
"Ensure",
"a",
"Group",
"exists",
"with",
"admin",
"permission"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Security/DefaultAdminService.php#L197-L220 | train |
silverstripe/silverstripe-framework | src/Security/MemberAuthenticator/LostPasswordHandler.php | LostPasswordHandler.redirectToLostPassword | public function redirectToLostPassword()
{
$lostPasswordLink = Security::singleton()->Link('lostpassword');
return $this->redirect($this->addBackURLParam($lostPasswordLink));
} | php | public function redirectToLostPassword()
{
$lostPasswordLink = Security::singleton()->Link('lostpassword');
return $this->redirect($this->addBackURLParam($lostPasswordLink));
} | [
"public",
"function",
"redirectToLostPassword",
"(",
")",
"{",
"$",
"lostPasswordLink",
"=",
"Security",
"::",
"singleton",
"(",
")",
"->",
"Link",
"(",
"'lostpassword'",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"addBackURLP... | Redirect to password recovery form
@return HTTPResponse | [
"Redirect",
"to",
"password",
"recovery",
"form"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Security/MemberAuthenticator/LostPasswordHandler.php#L142-L147 | train |
silverstripe/silverstripe-framework | src/Security/MemberAuthenticator/LostPasswordHandler.php | LostPasswordHandler.forgotPassword | public function forgotPassword($data, $form)
{
// Run a first pass validation check on the data
$dataValidation = $this->validateForgotPasswordData($data, $form);
if ($dataValidation instanceof HTTPResponse) {
return $dataValidation;
}
/** @var Member $member */
... | php | public function forgotPassword($data, $form)
{
// Run a first pass validation check on the data
$dataValidation = $this->validateForgotPasswordData($data, $form);
if ($dataValidation instanceof HTTPResponse) {
return $dataValidation;
}
/** @var Member $member */
... | [
"public",
"function",
"forgotPassword",
"(",
"$",
"data",
",",
"$",
"form",
")",
"{",
"// Run a first pass validation check on the data",
"$",
"dataValidation",
"=",
"$",
"this",
"->",
"validateForgotPasswordData",
"(",
"$",
"data",
",",
"$",
"form",
")",
";",
"... | Forgot password form handler method.
Called when the user clicks on "I've lost my password".
Extensions can use the 'forgotPassword' method to veto executing
the logic, by returning FALSE. In this case, the user will be redirected back
to the form without further action. It is recommended to set a message
in the form d... | [
"Forgot",
"password",
"form",
"handler",
"method",
".",
"Called",
"when",
"the",
"user",
"clicks",
"on",
"I",
"ve",
"lost",
"my",
"password",
".",
"Extensions",
"can",
"use",
"the",
"forgotPassword",
"method",
"to",
"veto",
"executing",
"the",
"logic",
"by",... | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Security/MemberAuthenticator/LostPasswordHandler.php#L162-L186 | train |
silverstripe/silverstripe-framework | src/Security/MemberAuthenticator/LostPasswordHandler.php | LostPasswordHandler.validateForgotPasswordData | protected function validateForgotPasswordData(array $data, LostPasswordForm $form)
{
if (empty($data['Email'])) {
$form->sessionMessage(
_t(
'SilverStripe\\Security\\Member.ENTEREMAIL',
'Please enter an email address to get a password reset... | php | protected function validateForgotPasswordData(array $data, LostPasswordForm $form)
{
if (empty($data['Email'])) {
$form->sessionMessage(
_t(
'SilverStripe\\Security\\Member.ENTEREMAIL',
'Please enter an email address to get a password reset... | [
"protected",
"function",
"validateForgotPasswordData",
"(",
"array",
"$",
"data",
",",
"LostPasswordForm",
"$",
"form",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"'Email'",
"]",
")",
")",
"{",
"$",
"form",
"->",
"sessionMessage",
"(",
"_t",
"(... | Ensure that the user has provided an email address. Note that the "Email" key is specific to this
implementation, but child classes can override this method to use another unique identifier field
for validation.
@param array $data
@param LostPasswordForm $form
@return HTTPResponse|null | [
"Ensure",
"that",
"the",
"user",
"has",
"provided",
"an",
"email",
"address",
".",
"Note",
"that",
"the",
"Email",
"key",
"is",
"specific",
"to",
"this",
"implementation",
"but",
"child",
"classes",
"can",
"override",
"this",
"method",
"to",
"use",
"another"... | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Security/MemberAuthenticator/LostPasswordHandler.php#L197-L210 | train |
silverstripe/silverstripe-framework | src/Security/MemberAuthenticator/LostPasswordHandler.php | LostPasswordHandler.getMemberFromData | protected function getMemberFromData(array $data)
{
if (!empty($data['Email'])) {
$uniqueIdentifier = Member::config()->get('unique_identifier_field');
return Member::get()->filter([$uniqueIdentifier => $data['Email']])->first();
}
} | php | protected function getMemberFromData(array $data)
{
if (!empty($data['Email'])) {
$uniqueIdentifier = Member::config()->get('unique_identifier_field');
return Member::get()->filter([$uniqueIdentifier => $data['Email']])->first();
}
} | [
"protected",
"function",
"getMemberFromData",
"(",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"'Email'",
"]",
")",
")",
"{",
"$",
"uniqueIdentifier",
"=",
"Member",
"::",
"config",
"(",
")",
"->",
"get",
"(",
"'un... | Load an existing Member from the provided data
@param array $data
@return Member|null | [
"Load",
"an",
"existing",
"Member",
"from",
"the",
"provided",
"data"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Security/MemberAuthenticator/LostPasswordHandler.php#L218-L224 | train |
silverstripe/silverstripe-framework | src/Security/MemberAuthenticator/LostPasswordHandler.php | LostPasswordHandler.sendEmail | protected function sendEmail($member, $token)
{
/** @var Email $email */
$email = Email::create()
->setHTMLTemplate('SilverStripe\\Control\\Email\\ForgotPasswordEmail')
->setData($member)
->setSubject(_t(
'SilverStripe\\Security\\Member.SUBJECTPASS... | php | protected function sendEmail($member, $token)
{
/** @var Email $email */
$email = Email::create()
->setHTMLTemplate('SilverStripe\\Control\\Email\\ForgotPasswordEmail')
->setData($member)
->setSubject(_t(
'SilverStripe\\Security\\Member.SUBJECTPASS... | [
"protected",
"function",
"sendEmail",
"(",
"$",
"member",
",",
"$",
"token",
")",
"{",
"/** @var Email $email */",
"$",
"email",
"=",
"Email",
"::",
"create",
"(",
")",
"->",
"setHTMLTemplate",
"(",
"'SilverStripe\\\\Control\\\\Email\\\\ForgotPasswordEmail'",
")",
"... | Send the email to the member that requested a reset link
@param Member $member
@param string $token
@return bool | [
"Send",
"the",
"email",
"to",
"the",
"member",
"that",
"requested",
"a",
"reset",
"link"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Security/MemberAuthenticator/LostPasswordHandler.php#L232-L246 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.