repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6 values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1 value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
reactphp/filesystem | src/ChildProcess/Adapter.php | Adapter.appendContents | public function appendContents($path, $content)
{
return $this->invoker->invokeCall('putContents', [
'path' => $path,
'chunk' => base64_encode($content),
'flags' => FILE_APPEND,
])->then(function ($payload) {
return \React\Promise\resolve($payload['written']);
});
} | php | public function appendContents($path, $content)
{
return $this->invoker->invokeCall('putContents', [
'path' => $path,
'chunk' => base64_encode($content),
'flags' => FILE_APPEND,
])->then(function ($payload) {
return \React\Promise\resolve($payload['written']);
});
} | [
"public",
"function",
"appendContents",
"(",
"$",
"path",
",",
"$",
"content",
")",
"{",
"return",
"$",
"this",
"->",
"invoker",
"->",
"invokeCall",
"(",
"'putContents'",
",",
"[",
"'path'",
"=>",
"$",
"path",
",",
"'chunk'",
"=>",
"base64_encode",
"(",
"$",
"content",
")",
",",
"'flags'",
"=>",
"FILE_APPEND",
",",
"]",
")",
"->",
"then",
"(",
"function",
"(",
"$",
"payload",
")",
"{",
"return",
"\\",
"React",
"\\",
"Promise",
"\\",
"resolve",
"(",
"$",
"payload",
"[",
"'written'",
"]",
")",
";",
"}",
")",
";",
"}"
] | Appends the given content to the specified file.
If the file does not exist, the file will be created.
This is an optimization for adapters which can optimize
the open -> write -> close sequence into one call.
@param string $path
@param string $content
@return PromiseInterface
@see AdapterInterface::putContents() | [
"Appends",
"the",
"given",
"content",
"to",
"the",
"specified",
"file",
".",
"If",
"the",
"file",
"does",
"not",
"exist",
"the",
"file",
"will",
"be",
"created",
"."
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/ChildProcess/Adapter.php#L347-L356 |
reactphp/filesystem | src/Node/File.php | File.time | public function time()
{
return $this->adapter->stat($this->path)->then(function ($result) {
return [
'atime' => $result['atime'],
'ctime' => $result['ctime'],
'mtime' => $result['mtime'],
];
});
} | php | public function time()
{
return $this->adapter->stat($this->path)->then(function ($result) {
return [
'atime' => $result['atime'],
'ctime' => $result['ctime'],
'mtime' => $result['mtime'],
];
});
} | [
"public",
"function",
"time",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"adapter",
"->",
"stat",
"(",
"$",
"this",
"->",
"path",
")",
"->",
"then",
"(",
"function",
"(",
"$",
"result",
")",
"{",
"return",
"[",
"'atime'",
"=>",
"$",
"result",
"[",
"'atime'",
"]",
",",
"'ctime'",
"=>",
"$",
"result",
"[",
"'ctime'",
"]",
",",
"'mtime'",
"=>",
"$",
"result",
"[",
"'mtime'",
"]",
",",
"]",
";",
"}",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Node/File.php#L71-L80 |
reactphp/filesystem | src/Node/File.php | File.rename | public function rename($toFilename)
{
return $this->adapter->rename($this->path, $toFilename)->then(function () use ($toFilename) {
return $this->filesystem->file($toFilename);
});
} | php | public function rename($toFilename)
{
return $this->adapter->rename($this->path, $toFilename)->then(function () use ($toFilename) {
return $this->filesystem->file($toFilename);
});
} | [
"public",
"function",
"rename",
"(",
"$",
"toFilename",
")",
"{",
"return",
"$",
"this",
"->",
"adapter",
"->",
"rename",
"(",
"$",
"this",
"->",
"path",
",",
"$",
"toFilename",
")",
"->",
"then",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"toFilename",
")",
"{",
"return",
"$",
"this",
"->",
"filesystem",
"->",
"file",
"(",
"$",
"toFilename",
")",
";",
"}",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Node/File.php#L85-L90 |
reactphp/filesystem | src/Node/File.php | File.create | public function create($mode = AdapterInterface::CREATION_MODE, $time = null)
{
return $this->stat()->then(function () {
throw new \Exception('File exists already');
}, function () use ($mode, $time) {
return $this->adapter->touch($this->path, $mode, $time);
});
} | php | public function create($mode = AdapterInterface::CREATION_MODE, $time = null)
{
return $this->stat()->then(function () {
throw new \Exception('File exists already');
}, function () use ($mode, $time) {
return $this->adapter->touch($this->path, $mode, $time);
});
} | [
"public",
"function",
"create",
"(",
"$",
"mode",
"=",
"AdapterInterface",
"::",
"CREATION_MODE",
",",
"$",
"time",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"stat",
"(",
")",
"->",
"then",
"(",
"function",
"(",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'File exists already'",
")",
";",
"}",
",",
"function",
"(",
")",
"use",
"(",
"$",
"mode",
",",
"$",
"time",
")",
"{",
"return",
"$",
"this",
"->",
"adapter",
"->",
"touch",
"(",
"$",
"this",
"->",
"path",
",",
"$",
"mode",
",",
"$",
"time",
")",
";",
"}",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Node/File.php#L95-L102 |
reactphp/filesystem | src/Node/File.php | File.touch | public function touch($mode = AdapterInterface::CREATION_MODE, $time = null)
{
return $this->adapter->touch($this->path, $mode, $time);
} | php | public function touch($mode = AdapterInterface::CREATION_MODE, $time = null)
{
return $this->adapter->touch($this->path, $mode, $time);
} | [
"public",
"function",
"touch",
"(",
"$",
"mode",
"=",
"AdapterInterface",
"::",
"CREATION_MODE",
",",
"$",
"time",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"adapter",
"->",
"touch",
"(",
"$",
"this",
"->",
"path",
",",
"$",
"mode",
",",
"$",
"time",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Node/File.php#L107-L110 |
reactphp/filesystem | src/Node/File.php | File.open | public function open($flags, $mode = AdapterInterface::CREATION_MODE)
{
if ($this->open === true) {
return \React\Promise\reject(new Exception('File is already open'));
}
return $this->adapter->open($this->path, $flags, $mode)->then(function ($fd) use ($flags) {
$this->open = true;
$this->fileDescriptor = $fd;
return StreamFactory::create($this->path, $fd, $flags, $this->adapter);
});
} | php | public function open($flags, $mode = AdapterInterface::CREATION_MODE)
{
if ($this->open === true) {
return \React\Promise\reject(new Exception('File is already open'));
}
return $this->adapter->open($this->path, $flags, $mode)->then(function ($fd) use ($flags) {
$this->open = true;
$this->fileDescriptor = $fd;
return StreamFactory::create($this->path, $fd, $flags, $this->adapter);
});
} | [
"public",
"function",
"open",
"(",
"$",
"flags",
",",
"$",
"mode",
"=",
"AdapterInterface",
"::",
"CREATION_MODE",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"open",
"===",
"true",
")",
"{",
"return",
"\\",
"React",
"\\",
"Promise",
"\\",
"reject",
"(",
"new",
"Exception",
"(",
"'File is already open'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"adapter",
"->",
"open",
"(",
"$",
"this",
"->",
"path",
",",
"$",
"flags",
",",
"$",
"mode",
")",
"->",
"then",
"(",
"function",
"(",
"$",
"fd",
")",
"use",
"(",
"$",
"flags",
")",
"{",
"$",
"this",
"->",
"open",
"=",
"true",
";",
"$",
"this",
"->",
"fileDescriptor",
"=",
"$",
"fd",
";",
"return",
"StreamFactory",
"::",
"create",
"(",
"$",
"this",
"->",
"path",
",",
"$",
"fd",
",",
"$",
"flags",
",",
"$",
"this",
"->",
"adapter",
")",
";",
"}",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Node/File.php#L115-L126 |
reactphp/filesystem | src/Node/File.php | File.close | public function close()
{
if ($this->open === false) {
return \React\Promise\reject(new Exception('File is already closed'));
}
return $this->adapter->close($this->fileDescriptor)->then(function () {
$this->open = false;
$this->fileDescriptor = null;
});
} | php | public function close()
{
if ($this->open === false) {
return \React\Promise\reject(new Exception('File is already closed'));
}
return $this->adapter->close($this->fileDescriptor)->then(function () {
$this->open = false;
$this->fileDescriptor = null;
});
} | [
"public",
"function",
"close",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"open",
"===",
"false",
")",
"{",
"return",
"\\",
"React",
"\\",
"Promise",
"\\",
"reject",
"(",
"new",
"Exception",
"(",
"'File is already closed'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"adapter",
"->",
"close",
"(",
"$",
"this",
"->",
"fileDescriptor",
")",
"->",
"then",
"(",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"open",
"=",
"false",
";",
"$",
"this",
"->",
"fileDescriptor",
"=",
"null",
";",
"}",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Node/File.php#L131-L141 |
reactphp/filesystem | src/Node/File.php | File.putContents | public function putContents($contents)
{
return $this->open('cw')->then(function (WritableStreamInterface $stream) use ($contents) {
$stream->write($contents);
return $this->close();
});
} | php | public function putContents($contents)
{
return $this->open('cw')->then(function (WritableStreamInterface $stream) use ($contents) {
$stream->write($contents);
return $this->close();
});
} | [
"public",
"function",
"putContents",
"(",
"$",
"contents",
")",
"{",
"return",
"$",
"this",
"->",
"open",
"(",
"'cw'",
")",
"->",
"then",
"(",
"function",
"(",
"WritableStreamInterface",
"$",
"stream",
")",
"use",
"(",
"$",
"contents",
")",
"{",
"$",
"stream",
"->",
"write",
"(",
"$",
"contents",
")",
";",
"return",
"$",
"this",
"->",
"close",
"(",
")",
";",
"}",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Node/File.php#L156-L162 |
reactphp/filesystem | src/Eio/Adapter.php | Adapter.setFilesystem | public function setFilesystem(FilesystemInterface $filesystem)
{
$this->filesystem = $filesystem;
$this->typeDetectors = [
new ConstTypeDetector($this->filesystem),
new ModeTypeDetector($this->filesystem),
];
} | php | public function setFilesystem(FilesystemInterface $filesystem)
{
$this->filesystem = $filesystem;
$this->typeDetectors = [
new ConstTypeDetector($this->filesystem),
new ModeTypeDetector($this->filesystem),
];
} | [
"public",
"function",
"setFilesystem",
"(",
"FilesystemInterface",
"$",
"filesystem",
")",
"{",
"$",
"this",
"->",
"filesystem",
"=",
"$",
"filesystem",
";",
"$",
"this",
"->",
"typeDetectors",
"=",
"[",
"new",
"ConstTypeDetector",
"(",
"$",
"this",
"->",
"filesystem",
")",
",",
"new",
"ModeTypeDetector",
"(",
"$",
"this",
"->",
"filesystem",
")",
",",
"]",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Eio/Adapter.php#L148-L156 |
reactphp/filesystem | src/Eio/Adapter.php | Adapter.lsStream | public function lsStream($path)
{
$stream = new ObjectStream();
$this->readDirInvoker->invokeCall('eio_readdir', [$path, $this->options['lsFlags']], false)->then(function ($result) use ($path, $stream) {
$this->processLsContents($path, $result, $stream);
});
return $stream;
} | php | public function lsStream($path)
{
$stream = new ObjectStream();
$this->readDirInvoker->invokeCall('eio_readdir', [$path, $this->options['lsFlags']], false)->then(function ($result) use ($path, $stream) {
$this->processLsContents($path, $result, $stream);
});
return $stream;
} | [
"public",
"function",
"lsStream",
"(",
"$",
"path",
")",
"{",
"$",
"stream",
"=",
"new",
"ObjectStream",
"(",
")",
";",
"$",
"this",
"->",
"readDirInvoker",
"->",
"invokeCall",
"(",
"'eio_readdir'",
",",
"[",
"$",
"path",
",",
"$",
"this",
"->",
"options",
"[",
"'lsFlags'",
"]",
"]",
",",
"false",
")",
"->",
"then",
"(",
"function",
"(",
"$",
"result",
")",
"use",
"(",
"$",
"path",
",",
"$",
"stream",
")",
"{",
"$",
"this",
"->",
"processLsContents",
"(",
"$",
"path",
",",
"$",
"result",
",",
"$",
"stream",
")",
";",
"}",
")",
";",
"return",
"$",
"stream",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Eio/Adapter.php#L223-L232 |
reactphp/filesystem | src/Eio/Adapter.php | Adapter.open | public function open($path, $flags, $mode = self::CREATION_MODE)
{
$eioFlags = $this->openFlagResolver->resolve($flags);
$mode = $this->permissionFlagResolver->resolve($mode);
return $this->openFileLimiter->open()->then(function () use ($path, $eioFlags, $mode) {
return $this->invoker->invokeCall('eio_open', [
$path,
$eioFlags,
$mode,
]);
})->otherwise(function ($error) {
$this->openFileLimiter->close();
return \React\Promise\reject($error);
});
} | php | public function open($path, $flags, $mode = self::CREATION_MODE)
{
$eioFlags = $this->openFlagResolver->resolve($flags);
$mode = $this->permissionFlagResolver->resolve($mode);
return $this->openFileLimiter->open()->then(function () use ($path, $eioFlags, $mode) {
return $this->invoker->invokeCall('eio_open', [
$path,
$eioFlags,
$mode,
]);
})->otherwise(function ($error) {
$this->openFileLimiter->close();
return \React\Promise\reject($error);
});
} | [
"public",
"function",
"open",
"(",
"$",
"path",
",",
"$",
"flags",
",",
"$",
"mode",
"=",
"self",
"::",
"CREATION_MODE",
")",
"{",
"$",
"eioFlags",
"=",
"$",
"this",
"->",
"openFlagResolver",
"->",
"resolve",
"(",
"$",
"flags",
")",
";",
"$",
"mode",
"=",
"$",
"this",
"->",
"permissionFlagResolver",
"->",
"resolve",
"(",
"$",
"mode",
")",
";",
"return",
"$",
"this",
"->",
"openFileLimiter",
"->",
"open",
"(",
")",
"->",
"then",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"path",
",",
"$",
"eioFlags",
",",
"$",
"mode",
")",
"{",
"return",
"$",
"this",
"->",
"invoker",
"->",
"invokeCall",
"(",
"'eio_open'",
",",
"[",
"$",
"path",
",",
"$",
"eioFlags",
",",
"$",
"mode",
",",
"]",
")",
";",
"}",
")",
"->",
"otherwise",
"(",
"function",
"(",
"$",
"error",
")",
"{",
"$",
"this",
"->",
"openFileLimiter",
"->",
"close",
"(",
")",
";",
"return",
"\\",
"React",
"\\",
"Promise",
"\\",
"reject",
"(",
"$",
"error",
")",
";",
"}",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Eio/Adapter.php#L286-L300 |
reactphp/filesystem | src/Eio/Adapter.php | Adapter.close | public function close($fd)
{
return $this->invoker->invokeCall('eio_close', [$fd])->always(function () {
$this->openFileLimiter->close();
});
} | php | public function close($fd)
{
return $this->invoker->invokeCall('eio_close', [$fd])->always(function () {
$this->openFileLimiter->close();
});
} | [
"public",
"function",
"close",
"(",
"$",
"fd",
")",
"{",
"return",
"$",
"this",
"->",
"invoker",
"->",
"invokeCall",
"(",
"'eio_close'",
",",
"[",
"$",
"fd",
"]",
")",
"->",
"always",
"(",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"openFileLimiter",
"->",
"close",
"(",
")",
";",
"}",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Eio/Adapter.php#L305-L310 |
reactphp/filesystem | src/Eio/Adapter.php | Adapter.getContents | public function getContents($path, $offset = 0, $length = null)
{
if ($length === null) {
return $this->stat($path)->then(function ($stat) use ($path, $offset) {
return $this->getContents($path, $offset, $stat['size']);
});
}
return $this->open($path, 'r')->then(function ($fd) use ($offset, $length) {
return $this->read($fd, $length, $offset)->always(function () use ($fd) {
return $this->close($fd);
});
});
} | php | public function getContents($path, $offset = 0, $length = null)
{
if ($length === null) {
return $this->stat($path)->then(function ($stat) use ($path, $offset) {
return $this->getContents($path, $offset, $stat['size']);
});
}
return $this->open($path, 'r')->then(function ($fd) use ($offset, $length) {
return $this->read($fd, $length, $offset)->always(function () use ($fd) {
return $this->close($fd);
});
});
} | [
"public",
"function",
"getContents",
"(",
"$",
"path",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"length",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"length",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"stat",
"(",
"$",
"path",
")",
"->",
"then",
"(",
"function",
"(",
"$",
"stat",
")",
"use",
"(",
"$",
"path",
",",
"$",
"offset",
")",
"{",
"return",
"$",
"this",
"->",
"getContents",
"(",
"$",
"path",
",",
"$",
"offset",
",",
"$",
"stat",
"[",
"'size'",
"]",
")",
";",
"}",
")",
";",
"}",
"return",
"$",
"this",
"->",
"open",
"(",
"$",
"path",
",",
"'r'",
")",
"->",
"then",
"(",
"function",
"(",
"$",
"fd",
")",
"use",
"(",
"$",
"offset",
",",
"$",
"length",
")",
"{",
"return",
"$",
"this",
"->",
"read",
"(",
"$",
"fd",
",",
"$",
"length",
",",
"$",
"offset",
")",
"->",
"always",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"fd",
")",
"{",
"return",
"$",
"this",
"->",
"close",
"(",
"$",
"fd",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | Reads the entire file.
This is an optimization for adapters which can optimize
the open -> (seek ->) read -> close sequence into one call.
@param string $path
@param int $offset
@param int|null $length
@return PromiseInterface | [
"Reads",
"the",
"entire",
"file",
"."
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Eio/Adapter.php#L323-L336 |
reactphp/filesystem | src/Eio/Adapter.php | Adapter.putContents | public function putContents($path, $content)
{
return $this->open($path, 'cw')->then(function ($fd) use ($content) {
return $this->write($fd, $content, strlen($content), 0)->always(function () use ($fd) {
return $this->close($fd);
});
});
} | php | public function putContents($path, $content)
{
return $this->open($path, 'cw')->then(function ($fd) use ($content) {
return $this->write($fd, $content, strlen($content), 0)->always(function () use ($fd) {
return $this->close($fd);
});
});
} | [
"public",
"function",
"putContents",
"(",
"$",
"path",
",",
"$",
"content",
")",
"{",
"return",
"$",
"this",
"->",
"open",
"(",
"$",
"path",
",",
"'cw'",
")",
"->",
"then",
"(",
"function",
"(",
"$",
"fd",
")",
"use",
"(",
"$",
"content",
")",
"{",
"return",
"$",
"this",
"->",
"write",
"(",
"$",
"fd",
",",
"$",
"content",
",",
"strlen",
"(",
"$",
"content",
")",
",",
"0",
")",
"->",
"always",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"fd",
")",
"{",
"return",
"$",
"this",
"->",
"close",
"(",
"$",
"fd",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | Writes the given content to the specified file.
If the file exists, the file is truncated.
If the file does not exist, the file will be created.
This is an optimization for adapters which can optimize
the open -> write -> close sequence into one call.
@param string $path
@param string $content
@return PromiseInterface
@see AdapterInterface::appendContents() | [
"Writes",
"the",
"given",
"content",
"to",
"the",
"specified",
"file",
".",
"If",
"the",
"file",
"exists",
"the",
"file",
"is",
"truncated",
".",
"If",
"the",
"file",
"does",
"not",
"exist",
"the",
"file",
"will",
"be",
"created",
"."
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Eio/Adapter.php#L351-L358 |
reactphp/filesystem | src/Eio/Adapter.php | Adapter.touch | public function touch($path, $mode = self::CREATION_MODE, $time = null)
{
return $this->stat($path)->then(function () use ($path, $time) {
if ($time === null) {
$time = microtime(true);
}
return $this->invoker->invokeCall('eio_utime', [
$path,
$time,
$time,
]);
}, function () use ($path, $mode) {
return $this->openFileLimiter->open()->then(function () use ($path, $mode) {
return $this->invoker->invokeCall('eio_open', [
$path,
EIO_O_CREAT,
$this->permissionFlagResolver->resolve($mode),
]);
})->then(function ($fd) use ($path) {
return $this->close($fd);
});
});
} | php | public function touch($path, $mode = self::CREATION_MODE, $time = null)
{
return $this->stat($path)->then(function () use ($path, $time) {
if ($time === null) {
$time = microtime(true);
}
return $this->invoker->invokeCall('eio_utime', [
$path,
$time,
$time,
]);
}, function () use ($path, $mode) {
return $this->openFileLimiter->open()->then(function () use ($path, $mode) {
return $this->invoker->invokeCall('eio_open', [
$path,
EIO_O_CREAT,
$this->permissionFlagResolver->resolve($mode),
]);
})->then(function ($fd) use ($path) {
return $this->close($fd);
});
});
} | [
"public",
"function",
"touch",
"(",
"$",
"path",
",",
"$",
"mode",
"=",
"self",
"::",
"CREATION_MODE",
",",
"$",
"time",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"stat",
"(",
"$",
"path",
")",
"->",
"then",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"path",
",",
"$",
"time",
")",
"{",
"if",
"(",
"$",
"time",
"===",
"null",
")",
"{",
"$",
"time",
"=",
"microtime",
"(",
"true",
")",
";",
"}",
"return",
"$",
"this",
"->",
"invoker",
"->",
"invokeCall",
"(",
"'eio_utime'",
",",
"[",
"$",
"path",
",",
"$",
"time",
",",
"$",
"time",
",",
"]",
")",
";",
"}",
",",
"function",
"(",
")",
"use",
"(",
"$",
"path",
",",
"$",
"mode",
")",
"{",
"return",
"$",
"this",
"->",
"openFileLimiter",
"->",
"open",
"(",
")",
"->",
"then",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"path",
",",
"$",
"mode",
")",
"{",
"return",
"$",
"this",
"->",
"invoker",
"->",
"invokeCall",
"(",
"'eio_open'",
",",
"[",
"$",
"path",
",",
"EIO_O_CREAT",
",",
"$",
"this",
"->",
"permissionFlagResolver",
"->",
"resolve",
"(",
"$",
"mode",
")",
",",
"]",
")",
";",
"}",
")",
"->",
"then",
"(",
"function",
"(",
"$",
"fd",
")",
"use",
"(",
"$",
"path",
")",
"{",
"return",
"$",
"this",
"->",
"close",
"(",
"$",
"fd",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Eio/Adapter.php#L384-L406 |
reactphp/filesystem | src/Eio/Adapter.php | Adapter.read | public function read($fileDescriptor, $length, $offset)
{
return $this->invoker->invokeCall('eio_read', [
$fileDescriptor,
$length,
$offset,
]);
} | php | public function read($fileDescriptor, $length, $offset)
{
return $this->invoker->invokeCall('eio_read', [
$fileDescriptor,
$length,
$offset,
]);
} | [
"public",
"function",
"read",
"(",
"$",
"fileDescriptor",
",",
"$",
"length",
",",
"$",
"offset",
")",
"{",
"return",
"$",
"this",
"->",
"invoker",
"->",
"invokeCall",
"(",
"'eio_read'",
",",
"[",
"$",
"fileDescriptor",
",",
"$",
"length",
",",
"$",
"offset",
",",
"]",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Eio/Adapter.php#L411-L418 |
reactphp/filesystem | src/Eio/Adapter.php | Adapter.write | public function write($fileDescriptor, $data, $length, $offset)
{
return $this->invoker->invokeCall('eio_write', [
$fileDescriptor,
$data,
$length,
$offset,
]);
} | php | public function write($fileDescriptor, $data, $length, $offset)
{
return $this->invoker->invokeCall('eio_write', [
$fileDescriptor,
$data,
$length,
$offset,
]);
} | [
"public",
"function",
"write",
"(",
"$",
"fileDescriptor",
",",
"$",
"data",
",",
"$",
"length",
",",
"$",
"offset",
")",
"{",
"return",
"$",
"this",
"->",
"invoker",
"->",
"invokeCall",
"(",
"'eio_write'",
",",
"[",
"$",
"fileDescriptor",
",",
"$",
"data",
",",
"$",
"length",
",",
"$",
"offset",
",",
"]",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Eio/Adapter.php#L423-L431 |
reactphp/filesystem | src/Node/Directory.php | Directory.size | public function size($recursive = false)
{
return $this->ls()->then(function ($result) use ($recursive) {
return $this->processSizeContents($result, $recursive);
});
} | php | public function size($recursive = false)
{
return $this->ls()->then(function ($result) use ($recursive) {
return $this->processSizeContents($result, $recursive);
});
} | [
"public",
"function",
"size",
"(",
"$",
"recursive",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"ls",
"(",
")",
"->",
"then",
"(",
"function",
"(",
"$",
"result",
")",
"use",
"(",
"$",
"recursive",
")",
"{",
"return",
"$",
"this",
"->",
"processSizeContents",
"(",
"$",
"result",
",",
"$",
"recursive",
")",
";",
"}",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Node/Directory.php#L86-L91 |
reactphp/filesystem | src/Node/Directory.php | Directory.create | public function create($mode = AdapterInterface::CREATION_MODE)
{
return $this->adapter->mkdir($this->path, $mode)->then(function () {
$deferred = new Deferred();
$check = function () use (&$check, $deferred) {
$this->stat()->then(function () use ($deferred) {
$deferred->resolve();
}, function () use (&$check) {
$this->adapter->getLoop()->addTimer(0.1, $check);
});
};
$check();
return $deferred->promise();
});
} | php | public function create($mode = AdapterInterface::CREATION_MODE)
{
return $this->adapter->mkdir($this->path, $mode)->then(function () {
$deferred = new Deferred();
$check = function () use (&$check, $deferred) {
$this->stat()->then(function () use ($deferred) {
$deferred->resolve();
}, function () use (&$check) {
$this->adapter->getLoop()->addTimer(0.1, $check);
});
};
$check();
return $deferred->promise();
});
} | [
"public",
"function",
"create",
"(",
"$",
"mode",
"=",
"AdapterInterface",
"::",
"CREATION_MODE",
")",
"{",
"return",
"$",
"this",
"->",
"adapter",
"->",
"mkdir",
"(",
"$",
"this",
"->",
"path",
",",
"$",
"mode",
")",
"->",
"then",
"(",
"function",
"(",
")",
"{",
"$",
"deferred",
"=",
"new",
"Deferred",
"(",
")",
";",
"$",
"check",
"=",
"function",
"(",
")",
"use",
"(",
"&",
"$",
"check",
",",
"$",
"deferred",
")",
"{",
"$",
"this",
"->",
"stat",
"(",
")",
"->",
"then",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"deferred",
")",
"{",
"$",
"deferred",
"->",
"resolve",
"(",
")",
";",
"}",
",",
"function",
"(",
")",
"use",
"(",
"&",
"$",
"check",
")",
"{",
"$",
"this",
"->",
"adapter",
"->",
"getLoop",
"(",
")",
"->",
"addTimer",
"(",
"0.1",
",",
"$",
"check",
")",
";",
"}",
")",
";",
"}",
";",
"$",
"check",
"(",
")",
";",
"return",
"$",
"deferred",
"->",
"promise",
"(",
")",
";",
"}",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Node/Directory.php#L136-L153 |
reactphp/filesystem | src/Node/Directory.php | Directory.rename | public function rename($toDirectoryName)
{
return $this->adapter->rename($this->path, $toDirectoryName)->then(function () use ($toDirectoryName) {
return $this->filesystem->dir($toDirectoryName);
});
} | php | public function rename($toDirectoryName)
{
return $this->adapter->rename($this->path, $toDirectoryName)->then(function () use ($toDirectoryName) {
return $this->filesystem->dir($toDirectoryName);
});
} | [
"public",
"function",
"rename",
"(",
"$",
"toDirectoryName",
")",
"{",
"return",
"$",
"this",
"->",
"adapter",
"->",
"rename",
"(",
"$",
"this",
"->",
"path",
",",
"$",
"toDirectoryName",
")",
"->",
"then",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"toDirectoryName",
")",
"{",
"return",
"$",
"this",
"->",
"filesystem",
"->",
"dir",
"(",
"$",
"toDirectoryName",
")",
";",
"}",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Node/Directory.php#L167-L172 |
reactphp/filesystem | src/Node/Directory.php | Directory.createRecursive | public function createRecursive($mode = AdapterInterface::CREATION_MODE)
{
$parentPath = explode(DIRECTORY_SEPARATOR, $this->path);
array_pop($parentPath);
$parentPath = implode(DIRECTORY_SEPARATOR, $parentPath);
$parentDirectory = $this->filesystem->dir($parentPath);
return $parentDirectory->stat()->then(null, function () use ($parentDirectory, $mode) {
return $parentDirectory->createRecursive($mode);
})->then(function () use ($mode) {
return $this->create($mode);
})->then(function () {
return null;
});
} | php | public function createRecursive($mode = AdapterInterface::CREATION_MODE)
{
$parentPath = explode(DIRECTORY_SEPARATOR, $this->path);
array_pop($parentPath);
$parentPath = implode(DIRECTORY_SEPARATOR, $parentPath);
$parentDirectory = $this->filesystem->dir($parentPath);
return $parentDirectory->stat()->then(null, function () use ($parentDirectory, $mode) {
return $parentDirectory->createRecursive($mode);
})->then(function () use ($mode) {
return $this->create($mode);
})->then(function () {
return null;
});
} | [
"public",
"function",
"createRecursive",
"(",
"$",
"mode",
"=",
"AdapterInterface",
"::",
"CREATION_MODE",
")",
"{",
"$",
"parentPath",
"=",
"explode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"this",
"->",
"path",
")",
";",
"array_pop",
"(",
"$",
"parentPath",
")",
";",
"$",
"parentPath",
"=",
"implode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"parentPath",
")",
";",
"$",
"parentDirectory",
"=",
"$",
"this",
"->",
"filesystem",
"->",
"dir",
"(",
"$",
"parentPath",
")",
";",
"return",
"$",
"parentDirectory",
"->",
"stat",
"(",
")",
"->",
"then",
"(",
"null",
",",
"function",
"(",
")",
"use",
"(",
"$",
"parentDirectory",
",",
"$",
"mode",
")",
"{",
"return",
"$",
"parentDirectory",
"->",
"createRecursive",
"(",
"$",
"mode",
")",
";",
"}",
")",
"->",
"then",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"mode",
")",
"{",
"return",
"$",
"this",
"->",
"create",
"(",
"$",
"mode",
")",
";",
"}",
")",
"->",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"null",
";",
"}",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Node/Directory.php#L177-L191 |
reactphp/filesystem | src/Node/GenericOperationTrait.php | GenericOperationTrait.chown | public function chown($uid = -1, $gid = -1)
{
return $this->adapter->chown($this->getPath(), $uid, $gid);
} | php | public function chown($uid = -1, $gid = -1)
{
return $this->adapter->chown($this->getPath(), $uid, $gid);
} | [
"public",
"function",
"chown",
"(",
"$",
"uid",
"=",
"-",
"1",
",",
"$",
"gid",
"=",
"-",
"1",
")",
"{",
"return",
"$",
"this",
"->",
"adapter",
"->",
"chown",
"(",
"$",
"this",
"->",
"getPath",
"(",
")",
",",
"$",
"uid",
",",
"$",
"gid",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Node/GenericOperationTrait.php#L99-L102 |
theiconic/name-parser | src/Mapper/SuffixMapper.php | SuffixMapper.map | public function map(array $parts): array
{
if ($this->isMatchingSinglePart($parts)) {
$parts[0] = new Suffix($parts[0], $this->suffixes[$this->getKey($parts[0])]);
return $parts;
}
$start = count($parts) - 1;
for ($k = $start; $k > 1; $k--) {
$part = $parts[$k];
if (!$this->isSuffix($part)) {
break;
}
$parts[$k] = new Suffix($part, $this->suffixes[$this->getKey($part)]);
}
return $parts;
} | php | public function map(array $parts): array
{
if ($this->isMatchingSinglePart($parts)) {
$parts[0] = new Suffix($parts[0], $this->suffixes[$this->getKey($parts[0])]);
return $parts;
}
$start = count($parts) - 1;
for ($k = $start; $k > 1; $k--) {
$part = $parts[$k];
if (!$this->isSuffix($part)) {
break;
}
$parts[$k] = new Suffix($part, $this->suffixes[$this->getKey($part)]);
}
return $parts;
} | [
"public",
"function",
"map",
"(",
"array",
"$",
"parts",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"isMatchingSinglePart",
"(",
"$",
"parts",
")",
")",
"{",
"$",
"parts",
"[",
"0",
"]",
"=",
"new",
"Suffix",
"(",
"$",
"parts",
"[",
"0",
"]",
",",
"$",
"this",
"->",
"suffixes",
"[",
"$",
"this",
"->",
"getKey",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
"]",
")",
";",
"return",
"$",
"parts",
";",
"}",
"$",
"start",
"=",
"count",
"(",
"$",
"parts",
")",
"-",
"1",
";",
"for",
"(",
"$",
"k",
"=",
"$",
"start",
";",
"$",
"k",
">",
"1",
";",
"$",
"k",
"--",
")",
"{",
"$",
"part",
"=",
"$",
"parts",
"[",
"$",
"k",
"]",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isSuffix",
"(",
"$",
"part",
")",
")",
"{",
"break",
";",
"}",
"$",
"parts",
"[",
"$",
"k",
"]",
"=",
"new",
"Suffix",
"(",
"$",
"part",
",",
"$",
"this",
"->",
"suffixes",
"[",
"$",
"this",
"->",
"getKey",
"(",
"$",
"part",
")",
"]",
")",
";",
"}",
"return",
"$",
"parts",
";",
"}"
] | map suffixes in the parts array
@param array $parts the name parts
@return array the mapped parts | [
"map",
"suffixes",
"in",
"the",
"parts",
"array"
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Mapper/SuffixMapper.php#L26-L46 |
theiconic/name-parser | src/Parser.php | Parser.parse | public function parse($name): Name
{
$name = $this->normalize($name);
$segments = explode(',', $name);
if (1 < count($segments)) {
return $this->parseSplitName($segments[0], $segments[1], $segments[2] ?? '');
}
$parts = explode(' ', $name);
foreach ($this->getMappers() as $mapper) {
$parts = $mapper->map($parts);
}
return new Name($parts);
} | php | public function parse($name): Name
{
$name = $this->normalize($name);
$segments = explode(',', $name);
if (1 < count($segments)) {
return $this->parseSplitName($segments[0], $segments[1], $segments[2] ?? '');
}
$parts = explode(' ', $name);
foreach ($this->getMappers() as $mapper) {
$parts = $mapper->map($parts);
}
return new Name($parts);
} | [
"public",
"function",
"parse",
"(",
"$",
"name",
")",
":",
"Name",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"normalize",
"(",
"$",
"name",
")",
";",
"$",
"segments",
"=",
"explode",
"(",
"','",
",",
"$",
"name",
")",
";",
"if",
"(",
"1",
"<",
"count",
"(",
"$",
"segments",
")",
")",
"{",
"return",
"$",
"this",
"->",
"parseSplitName",
"(",
"$",
"segments",
"[",
"0",
"]",
",",
"$",
"segments",
"[",
"1",
"]",
",",
"$",
"segments",
"[",
"2",
"]",
"??",
"''",
")",
";",
"}",
"$",
"parts",
"=",
"explode",
"(",
"' '",
",",
"$",
"name",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getMappers",
"(",
")",
"as",
"$",
"mapper",
")",
"{",
"$",
"parts",
"=",
"$",
"mapper",
"->",
"map",
"(",
"$",
"parts",
")",
";",
"}",
"return",
"new",
"Name",
"(",
"$",
"parts",
")",
";",
"}"
] | split full names into the following parts:
- prefix / salutation (Mr., Mrs., etc)
- given name / first name
- middle initials
- surname / last name
- suffix (II, Phd, Jr, etc)
@param string $name
@return Name | [
"split",
"full",
"names",
"into",
"the",
"following",
"parts",
":",
"-",
"prefix",
"/",
"salutation",
"(",
"Mr",
".",
"Mrs",
".",
"etc",
")",
"-",
"given",
"name",
"/",
"first",
"name",
"-",
"middle",
"initials",
"-",
"surname",
"/",
"last",
"name",
"-",
"suffix",
"(",
"II",
"Phd",
"Jr",
"etc",
")"
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Parser.php#L61-L78 |
theiconic/name-parser | src/Parser.php | Parser.parseSplitName | protected function parseSplitName($first, $second, $third): Name
{
$parts = array_merge(
$this->getFirstSegmentParser()->parse($first)->getParts(),
$this->getSecondSegmentParser()->parse($second)->getParts(),
$this->getThirdSegmentParser()->parse($third)->getParts()
);
return new Name($parts);
} | php | protected function parseSplitName($first, $second, $third): Name
{
$parts = array_merge(
$this->getFirstSegmentParser()->parse($first)->getParts(),
$this->getSecondSegmentParser()->parse($second)->getParts(),
$this->getThirdSegmentParser()->parse($third)->getParts()
);
return new Name($parts);
} | [
"protected",
"function",
"parseSplitName",
"(",
"$",
"first",
",",
"$",
"second",
",",
"$",
"third",
")",
":",
"Name",
"{",
"$",
"parts",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"getFirstSegmentParser",
"(",
")",
"->",
"parse",
"(",
"$",
"first",
")",
"->",
"getParts",
"(",
")",
",",
"$",
"this",
"->",
"getSecondSegmentParser",
"(",
")",
"->",
"parse",
"(",
"$",
"second",
")",
"->",
"getParts",
"(",
")",
",",
"$",
"this",
"->",
"getThirdSegmentParser",
"(",
")",
"->",
"parse",
"(",
"$",
"third",
")",
"->",
"getParts",
"(",
")",
")",
";",
"return",
"new",
"Name",
"(",
"$",
"parts",
")",
";",
"}"
] | handles split-parsing of comma-separated name parts
@param $left - the name part left of the comma
@param $right - the name part right of the comma
@return Name | [
"handles",
"split",
"-",
"parsing",
"of",
"comma",
"-",
"separated",
"name",
"parts"
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Parser.php#L88-L97 |
theiconic/name-parser | src/Parser.php | Parser.getMappers | public function getMappers(): array
{
if (empty($this->mappers)) {
$this->setMappers([
new NicknameMapper($this->getNicknameDelimiters()),
new SalutationMapper($this->getSalutations(), $this->getMaxSalutationIndex()),
new SuffixMapper($this->getSuffixes()),
new InitialMapper(),
new LastnameMapper($this->getPrefixes()),
new FirstnameMapper(),
new MiddlenameMapper(),
]);
}
return $this->mappers;
} | php | public function getMappers(): array
{
if (empty($this->mappers)) {
$this->setMappers([
new NicknameMapper($this->getNicknameDelimiters()),
new SalutationMapper($this->getSalutations(), $this->getMaxSalutationIndex()),
new SuffixMapper($this->getSuffixes()),
new InitialMapper(),
new LastnameMapper($this->getPrefixes()),
new FirstnameMapper(),
new MiddlenameMapper(),
]);
}
return $this->mappers;
} | [
"public",
"function",
"getMappers",
"(",
")",
":",
"array",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"mappers",
")",
")",
"{",
"$",
"this",
"->",
"setMappers",
"(",
"[",
"new",
"NicknameMapper",
"(",
"$",
"this",
"->",
"getNicknameDelimiters",
"(",
")",
")",
",",
"new",
"SalutationMapper",
"(",
"$",
"this",
"->",
"getSalutations",
"(",
")",
",",
"$",
"this",
"->",
"getMaxSalutationIndex",
"(",
")",
")",
",",
"new",
"SuffixMapper",
"(",
"$",
"this",
"->",
"getSuffixes",
"(",
")",
")",
",",
"new",
"InitialMapper",
"(",
")",
",",
"new",
"LastnameMapper",
"(",
"$",
"this",
"->",
"getPrefixes",
"(",
")",
")",
",",
"new",
"FirstnameMapper",
"(",
")",
",",
"new",
"MiddlenameMapper",
"(",
")",
",",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"mappers",
";",
"}"
] | get the mappers for this parser
@return array | [
"get",
"the",
"mappers",
"for",
"this",
"parser"
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Parser.php#L152-L167 |
theiconic/name-parser | src/Parser.php | Parser.normalize | protected function normalize(string $name): string
{
$whitespace = $this->getWhitespace();
$name = trim($name);
return preg_replace('/[' . preg_quote($whitespace) . ']+/', ' ', $name);
} | php | protected function normalize(string $name): string
{
$whitespace = $this->getWhitespace();
$name = trim($name);
return preg_replace('/[' . preg_quote($whitespace) . ']+/', ' ', $name);
} | [
"protected",
"function",
"normalize",
"(",
"string",
"$",
"name",
")",
":",
"string",
"{",
"$",
"whitespace",
"=",
"$",
"this",
"->",
"getWhitespace",
"(",
")",
";",
"$",
"name",
"=",
"trim",
"(",
"$",
"name",
")",
";",
"return",
"preg_replace",
"(",
"'/['",
".",
"preg_quote",
"(",
"$",
"whitespace",
")",
".",
"']+/'",
",",
"' '",
",",
"$",
"name",
")",
";",
"}"
] | normalize the name
@param string $name
@return string | [
"normalize",
"the",
"name"
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Parser.php#L188-L195 |
theiconic/name-parser | src/Mapper/FirstnameMapper.php | FirstnameMapper.map | public function map(array $parts): array
{
if (count($parts) < 2) {
return [$this->handleSinglePart($parts[0])];
}
$pos = $this->findFirstnamePosition($parts);
if (null !== $pos) {
$parts[$pos] = new Firstname($parts[$pos]);
}
return $parts;
} | php | public function map(array $parts): array
{
if (count($parts) < 2) {
return [$this->handleSinglePart($parts[0])];
}
$pos = $this->findFirstnamePosition($parts);
if (null !== $pos) {
$parts[$pos] = new Firstname($parts[$pos]);
}
return $parts;
} | [
"public",
"function",
"map",
"(",
"array",
"$",
"parts",
")",
":",
"array",
"{",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
"<",
"2",
")",
"{",
"return",
"[",
"$",
"this",
"->",
"handleSinglePart",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
"]",
";",
"}",
"$",
"pos",
"=",
"$",
"this",
"->",
"findFirstnamePosition",
"(",
"$",
"parts",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"pos",
")",
"{",
"$",
"parts",
"[",
"$",
"pos",
"]",
"=",
"new",
"Firstname",
"(",
"$",
"parts",
"[",
"$",
"pos",
"]",
")",
";",
"}",
"return",
"$",
"parts",
";",
"}"
] | map firstnames in parts array
@param array $parts the parts
@return array the mapped parts | [
"map",
"firstnames",
"in",
"parts",
"array"
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Mapper/FirstnameMapper.php#L19-L32 |
theiconic/name-parser | src/Mapper/SalutationMapper.php | SalutationMapper.map | public function map(array $parts): array
{
$max = ($this->maxIndex > 0) ? $this->maxIndex : floor(count($parts) / 2);
for ($k = 0; $k < $max; $k++) {
$part = $parts[$k];
if ($part instanceof AbstractPart) {
break;
}
if ($this->isSalutation($part)) {
$parts[$k] = new Salutation($part, $this->salutations[$this->getKey($part)]);
}
}
return $parts;
} | php | public function map(array $parts): array
{
$max = ($this->maxIndex > 0) ? $this->maxIndex : floor(count($parts) / 2);
for ($k = 0; $k < $max; $k++) {
$part = $parts[$k];
if ($part instanceof AbstractPart) {
break;
}
if ($this->isSalutation($part)) {
$parts[$k] = new Salutation($part, $this->salutations[$this->getKey($part)]);
}
}
return $parts;
} | [
"public",
"function",
"map",
"(",
"array",
"$",
"parts",
")",
":",
"array",
"{",
"$",
"max",
"=",
"(",
"$",
"this",
"->",
"maxIndex",
">",
"0",
")",
"?",
"$",
"this",
"->",
"maxIndex",
":",
"floor",
"(",
"count",
"(",
"$",
"parts",
")",
"/",
"2",
")",
";",
"for",
"(",
"$",
"k",
"=",
"0",
";",
"$",
"k",
"<",
"$",
"max",
";",
"$",
"k",
"++",
")",
"{",
"$",
"part",
"=",
"$",
"parts",
"[",
"$",
"k",
"]",
";",
"if",
"(",
"$",
"part",
"instanceof",
"AbstractPart",
")",
"{",
"break",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isSalutation",
"(",
"$",
"part",
")",
")",
"{",
"$",
"parts",
"[",
"$",
"k",
"]",
"=",
"new",
"Salutation",
"(",
"$",
"part",
",",
"$",
"this",
"->",
"salutations",
"[",
"$",
"this",
"->",
"getKey",
"(",
"$",
"part",
")",
"]",
")",
";",
"}",
"}",
"return",
"$",
"parts",
";",
"}"
] | map salutations in the parts array
@param array $parts the name parts
@return array the mapped parts | [
"map",
"salutations",
"in",
"the",
"parts",
"array"
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Mapper/SalutationMapper.php#L26-L43 |
theiconic/name-parser | src/Mapper/NicknameMapper.php | NicknameMapper.map | public function map(array $parts): array
{
$isEncapsulated = false;
$regexp = $this->buildRegexp();
$closingDelimiter = '';
foreach ($parts as $k => $part) {
if ($part instanceof AbstractPart) {
continue;
}
if (preg_match($regexp, $part, $matches)) {
$isEncapsulated = true;
$part = substr($part, 1);
$closingDelimiter = $this->delimiters[$matches[1]];
}
if (!$isEncapsulated) {
continue;
}
if ($closingDelimiter === substr($part, -1)) {
$isEncapsulated = false;
$part = substr($part, 0, -1);
}
$parts[$k] = new Nickname(str_replace(['"', '\''], '', $part));
}
return $parts;
} | php | public function map(array $parts): array
{
$isEncapsulated = false;
$regexp = $this->buildRegexp();
$closingDelimiter = '';
foreach ($parts as $k => $part) {
if ($part instanceof AbstractPart) {
continue;
}
if (preg_match($regexp, $part, $matches)) {
$isEncapsulated = true;
$part = substr($part, 1);
$closingDelimiter = $this->delimiters[$matches[1]];
}
if (!$isEncapsulated) {
continue;
}
if ($closingDelimiter === substr($part, -1)) {
$isEncapsulated = false;
$part = substr($part, 0, -1);
}
$parts[$k] = new Nickname(str_replace(['"', '\''], '', $part));
}
return $parts;
} | [
"public",
"function",
"map",
"(",
"array",
"$",
"parts",
")",
":",
"array",
"{",
"$",
"isEncapsulated",
"=",
"false",
";",
"$",
"regexp",
"=",
"$",
"this",
"->",
"buildRegexp",
"(",
")",
";",
"$",
"closingDelimiter",
"=",
"''",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"k",
"=>",
"$",
"part",
")",
"{",
"if",
"(",
"$",
"part",
"instanceof",
"AbstractPart",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"preg_match",
"(",
"$",
"regexp",
",",
"$",
"part",
",",
"$",
"matches",
")",
")",
"{",
"$",
"isEncapsulated",
"=",
"true",
";",
"$",
"part",
"=",
"substr",
"(",
"$",
"part",
",",
"1",
")",
";",
"$",
"closingDelimiter",
"=",
"$",
"this",
"->",
"delimiters",
"[",
"$",
"matches",
"[",
"1",
"]",
"]",
";",
"}",
"if",
"(",
"!",
"$",
"isEncapsulated",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"closingDelimiter",
"===",
"substr",
"(",
"$",
"part",
",",
"-",
"1",
")",
")",
"{",
"$",
"isEncapsulated",
"=",
"false",
";",
"$",
"part",
"=",
"substr",
"(",
"$",
"part",
",",
"0",
",",
"-",
"1",
")",
";",
"}",
"$",
"parts",
"[",
"$",
"k",
"]",
"=",
"new",
"Nickname",
"(",
"str_replace",
"(",
"[",
"'\"'",
",",
"'\\''",
"]",
",",
"''",
",",
"$",
"part",
")",
")",
";",
"}",
"return",
"$",
"parts",
";",
"}"
] | map nicknames in the parts array
@param array $parts the name parts
@return array the mapped parts | [
"map",
"nicknames",
"in",
"the",
"parts",
"array"
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Mapper/NicknameMapper.php#L35-L67 |
theiconic/name-parser | src/Mapper/InitialMapper.php | InitialMapper.map | public function map(array $parts): array
{
$last = count($parts) - 1;
foreach ($parts as $k => $part) {
if ($part instanceof AbstractPart) {
continue;
}
if (!$this->matchLastPart && $k === $last) {
continue;
}
if ($this->isInitial($part)) {
$parts[$k] = new Initial($part);
}
}
return $parts;
} | php | public function map(array $parts): array
{
$last = count($parts) - 1;
foreach ($parts as $k => $part) {
if ($part instanceof AbstractPart) {
continue;
}
if (!$this->matchLastPart && $k === $last) {
continue;
}
if ($this->isInitial($part)) {
$parts[$k] = new Initial($part);
}
}
return $parts;
} | [
"public",
"function",
"map",
"(",
"array",
"$",
"parts",
")",
":",
"array",
"{",
"$",
"last",
"=",
"count",
"(",
"$",
"parts",
")",
"-",
"1",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"k",
"=>",
"$",
"part",
")",
"{",
"if",
"(",
"$",
"part",
"instanceof",
"AbstractPart",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"matchLastPart",
"&&",
"$",
"k",
"===",
"$",
"last",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isInitial",
"(",
"$",
"part",
")",
")",
"{",
"$",
"parts",
"[",
"$",
"k",
"]",
"=",
"new",
"Initial",
"(",
"$",
"part",
")",
";",
"}",
"}",
"return",
"$",
"parts",
";",
"}"
] | map intials in parts array
@param array $parts the name parts
@return array the mapped parts | [
"map",
"intials",
"in",
"parts",
"array"
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Mapper/InitialMapper.php#L26-L45 |
theiconic/name-parser | src/Mapper/LastnameMapper.php | LastnameMapper.map | public function map(array $parts): array
{
if (!$this->matchSinglePart && count($parts) < 2) {
return $parts;
}
return $this->mapParts($parts);
} | php | public function map(array $parts): array
{
if (!$this->matchSinglePart && count($parts) < 2) {
return $parts;
}
return $this->mapParts($parts);
} | [
"public",
"function",
"map",
"(",
"array",
"$",
"parts",
")",
":",
"array",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"matchSinglePart",
"&&",
"count",
"(",
"$",
"parts",
")",
"<",
"2",
")",
"{",
"return",
"$",
"parts",
";",
"}",
"return",
"$",
"this",
"->",
"mapParts",
"(",
"$",
"parts",
")",
";",
"}"
] | map lastnames in the parts array
@param array $parts the name parts
@return array the mapped parts | [
"map",
"lastnames",
"in",
"the",
"parts",
"array"
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Mapper/LastnameMapper.php#L31-L38 |
theiconic/name-parser | src/Mapper/LastnameMapper.php | LastnameMapper.mapParts | protected function mapParts(array $parts): array
{
$k = $this->skipIgnoredParts($parts) + 1;
$remapIgnored = true;
while (--$k >= 0) {
$part = $parts[$k];
if ($part instanceof AbstractPart) {
break;
}
if ($this->isFollowedByLastnamePart($parts, $k)) {
if ($this->isApplicablePrefix($parts, $k)) {
$parts[$k] = new LastnamePrefix($part, $this->prefixes[$this->getKey($part)]);
continue;
}
if ($this->shouldStopMapping($parts, $k)) {
break;
}
}
$parts[$k] = new Lastname($part);
$remapIgnored = false;
}
if ($remapIgnored) {
$parts = $this->remapIgnored($parts);
}
return $parts;
} | php | protected function mapParts(array $parts): array
{
$k = $this->skipIgnoredParts($parts) + 1;
$remapIgnored = true;
while (--$k >= 0) {
$part = $parts[$k];
if ($part instanceof AbstractPart) {
break;
}
if ($this->isFollowedByLastnamePart($parts, $k)) {
if ($this->isApplicablePrefix($parts, $k)) {
$parts[$k] = new LastnamePrefix($part, $this->prefixes[$this->getKey($part)]);
continue;
}
if ($this->shouldStopMapping($parts, $k)) {
break;
}
}
$parts[$k] = new Lastname($part);
$remapIgnored = false;
}
if ($remapIgnored) {
$parts = $this->remapIgnored($parts);
}
return $parts;
} | [
"protected",
"function",
"mapParts",
"(",
"array",
"$",
"parts",
")",
":",
"array",
"{",
"$",
"k",
"=",
"$",
"this",
"->",
"skipIgnoredParts",
"(",
"$",
"parts",
")",
"+",
"1",
";",
"$",
"remapIgnored",
"=",
"true",
";",
"while",
"(",
"--",
"$",
"k",
">=",
"0",
")",
"{",
"$",
"part",
"=",
"$",
"parts",
"[",
"$",
"k",
"]",
";",
"if",
"(",
"$",
"part",
"instanceof",
"AbstractPart",
")",
"{",
"break",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isFollowedByLastnamePart",
"(",
"$",
"parts",
",",
"$",
"k",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isApplicablePrefix",
"(",
"$",
"parts",
",",
"$",
"k",
")",
")",
"{",
"$",
"parts",
"[",
"$",
"k",
"]",
"=",
"new",
"LastnamePrefix",
"(",
"$",
"part",
",",
"$",
"this",
"->",
"prefixes",
"[",
"$",
"this",
"->",
"getKey",
"(",
"$",
"part",
")",
"]",
")",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"shouldStopMapping",
"(",
"$",
"parts",
",",
"$",
"k",
")",
")",
"{",
"break",
";",
"}",
"}",
"$",
"parts",
"[",
"$",
"k",
"]",
"=",
"new",
"Lastname",
"(",
"$",
"part",
")",
";",
"$",
"remapIgnored",
"=",
"false",
";",
"}",
"if",
"(",
"$",
"remapIgnored",
")",
"{",
"$",
"parts",
"=",
"$",
"this",
"->",
"remapIgnored",
"(",
"$",
"parts",
")",
";",
"}",
"return",
"$",
"parts",
";",
"}"
] | we map the parts in reverse order because it makes more
sense to parse for the lastname starting from the end
@param array $parts
@return array | [
"we",
"map",
"the",
"parts",
"in",
"reverse",
"order",
"because",
"it",
"makes",
"more",
"sense",
"to",
"parse",
"for",
"the",
"lastname",
"starting",
"from",
"the",
"end"
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Mapper/LastnameMapper.php#L47-L79 |
theiconic/name-parser | src/Mapper/LastnameMapper.php | LastnameMapper.skipIgnoredParts | protected function skipIgnoredParts(array $parts): int
{
$k = count($parts);
while (--$k >= 0) {
if (!$this->isIgnoredPart($parts[$k])) {
break;
}
}
return $k;
} | php | protected function skipIgnoredParts(array $parts): int
{
$k = count($parts);
while (--$k >= 0) {
if (!$this->isIgnoredPart($parts[$k])) {
break;
}
}
return $k;
} | [
"protected",
"function",
"skipIgnoredParts",
"(",
"array",
"$",
"parts",
")",
":",
"int",
"{",
"$",
"k",
"=",
"count",
"(",
"$",
"parts",
")",
";",
"while",
"(",
"--",
"$",
"k",
">=",
"0",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isIgnoredPart",
"(",
"$",
"parts",
"[",
"$",
"k",
"]",
")",
")",
"{",
"break",
";",
"}",
"}",
"return",
"$",
"k",
";",
"}"
] | skip through the parts we want to ignore and return the start index
@param array $parts
@return int | [
"skip",
"through",
"the",
"parts",
"we",
"want",
"to",
"ignore",
"and",
"return",
"the",
"start",
"index"
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Mapper/LastnameMapper.php#L87-L98 |
theiconic/name-parser | src/Mapper/LastnameMapper.php | LastnameMapper.shouldStopMapping | protected function shouldStopMapping(array $parts, int $k): bool
{
if ($k < 1) {
return true;
}
if ($parts[$k + 1] instanceof LastnamePrefix) {
return true;
}
return strlen($parts[$k + 1]->getValue()) >= 3;
} | php | protected function shouldStopMapping(array $parts, int $k): bool
{
if ($k < 1) {
return true;
}
if ($parts[$k + 1] instanceof LastnamePrefix) {
return true;
}
return strlen($parts[$k + 1]->getValue()) >= 3;
} | [
"protected",
"function",
"shouldStopMapping",
"(",
"array",
"$",
"parts",
",",
"int",
"$",
"k",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"k",
"<",
"1",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"parts",
"[",
"$",
"k",
"+",
"1",
"]",
"instanceof",
"LastnamePrefix",
")",
"{",
"return",
"true",
";",
"}",
"return",
"strlen",
"(",
"$",
"parts",
"[",
"$",
"k",
"+",
"1",
"]",
"->",
"getValue",
"(",
")",
")",
">=",
"3",
";",
"}"
] | indicates if we should stop mapping at the give index $k
the assumption is that lastname parts have already been found
but we want to see if we should add more parts
@param array $parts
@param int $k
@return bool | [
"indicates",
"if",
"we",
"should",
"stop",
"mapping",
"at",
"the",
"give",
"index",
"$k"
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Mapper/LastnameMapper.php#L110-L121 |
theiconic/name-parser | src/Mapper/LastnameMapper.php | LastnameMapper.remapIgnored | protected function remapIgnored(array $parts): array
{
$k = count($parts);
while (--$k >= 0) {
$part = $parts[$k];
if (!$this->isIgnoredPart($part)) {
break;
}
$parts[$k] = new Lastname($part);
}
return $parts;
} | php | protected function remapIgnored(array $parts): array
{
$k = count($parts);
while (--$k >= 0) {
$part = $parts[$k];
if (!$this->isIgnoredPart($part)) {
break;
}
$parts[$k] = new Lastname($part);
}
return $parts;
} | [
"protected",
"function",
"remapIgnored",
"(",
"array",
"$",
"parts",
")",
":",
"array",
"{",
"$",
"k",
"=",
"count",
"(",
"$",
"parts",
")",
";",
"while",
"(",
"--",
"$",
"k",
">=",
"0",
")",
"{",
"$",
"part",
"=",
"$",
"parts",
"[",
"$",
"k",
"]",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isIgnoredPart",
"(",
"$",
"part",
")",
")",
"{",
"break",
";",
"}",
"$",
"parts",
"[",
"$",
"k",
"]",
"=",
"new",
"Lastname",
"(",
"$",
"part",
")",
";",
"}",
"return",
"$",
"parts",
";",
"}"
] | remap ignored parts as lastname
if the mapping did not derive any lastname this is called to transform
any previously ignored parts into lastname parts
the parts array is still reversed at this point
@param array $parts
@return array | [
"remap",
"ignored",
"parts",
"as",
"lastname"
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Mapper/LastnameMapper.php#L143-L158 |
theiconic/name-parser | src/Mapper/LastnameMapper.php | LastnameMapper.isApplicablePrefix | protected function isApplicablePrefix(array $parts, int $index): bool
{
if (!$this->isPrefix($parts[$index])) {
return false;
}
return $this->hasUnmappedPartsBefore($parts, $index);
} | php | protected function isApplicablePrefix(array $parts, int $index): bool
{
if (!$this->isPrefix($parts[$index])) {
return false;
}
return $this->hasUnmappedPartsBefore($parts, $index);
} | [
"protected",
"function",
"isApplicablePrefix",
"(",
"array",
"$",
"parts",
",",
"int",
"$",
"index",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isPrefix",
"(",
"$",
"parts",
"[",
"$",
"index",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"hasUnmappedPartsBefore",
"(",
"$",
"parts",
",",
"$",
"index",
")",
";",
"}"
] | Assuming that the part at the given index is matched as a prefix,
determines if the prefix should be applied to the lastname.
We only apply it to the lastname if we already have at least one
lastname part and there are other parts left in
the name (this effectively prioritises firstname over prefix matching).
This expects the parts array and index to be in the original order.
@param array $parts
@param int $index
@return bool | [
"Assuming",
"that",
"the",
"part",
"at",
"the",
"given",
"index",
"is",
"matched",
"as",
"a",
"prefix",
"determines",
"if",
"the",
"prefix",
"should",
"be",
"applied",
"to",
"the",
"lastname",
"."
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Mapper/LastnameMapper.php#L186-L193 |
theiconic/name-parser | src/Mapper/LastnameMapper.php | LastnameMapper.skipNicknameParts | protected function skipNicknameParts($parts, $startIndex)
{
$total = count($parts);
for ($i = $startIndex; $i < $total; $i++) {
if (!($parts[$i] instanceof Nickname)) {
return $i;
}
}
return $total - 1;
} | php | protected function skipNicknameParts($parts, $startIndex)
{
$total = count($parts);
for ($i = $startIndex; $i < $total; $i++) {
if (!($parts[$i] instanceof Nickname)) {
return $i;
}
}
return $total - 1;
} | [
"protected",
"function",
"skipNicknameParts",
"(",
"$",
"parts",
",",
"$",
"startIndex",
")",
"{",
"$",
"total",
"=",
"count",
"(",
"$",
"parts",
")",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"startIndex",
";",
"$",
"i",
"<",
"$",
"total",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"parts",
"[",
"$",
"i",
"]",
"instanceof",
"Nickname",
")",
")",
"{",
"return",
"$",
"i",
";",
"}",
"}",
"return",
"$",
"total",
"-",
"1",
";",
"}"
] | find the next non-nickname index in parts
@param $parts
@param $startIndex
@return int|void | [
"find",
"the",
"next",
"non",
"-",
"nickname",
"index",
"in",
"parts"
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Mapper/LastnameMapper.php#L213-L224 |
theiconic/name-parser | src/Part/AbstractPart.php | AbstractPart.setValue | public function setValue($value): AbstractPart
{
if ($value instanceof AbstractPart) {
$value = $value->getValue();
}
$this->value = $value;
return $this;
} | php | public function setValue($value): AbstractPart
{
if ($value instanceof AbstractPart) {
$value = $value->getValue();
}
$this->value = $value;
return $this;
} | [
"public",
"function",
"setValue",
"(",
"$",
"value",
")",
":",
"AbstractPart",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"AbstractPart",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"->",
"getValue",
"(",
")",
";",
"}",
"$",
"this",
"->",
"value",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] | set the value to wrap
(can take string or part instance)
@param string|AbstractPart $value
@return $this | [
"set",
"the",
"value",
"to",
"wrap",
"(",
"can",
"take",
"string",
"or",
"part",
"instance",
")"
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Part/AbstractPart.php#L29-L38 |
theiconic/name-parser | src/Part/AbstractPart.php | AbstractPart.camelcaseReplace | protected function camelcaseReplace($matches): string
{
if (function_exists('mb_convert_case')) {
return mb_convert_case($matches[0], MB_CASE_TITLE, "UTF-8");
}
return ucfirst(strtolower($matches[0]));
} | php | protected function camelcaseReplace($matches): string
{
if (function_exists('mb_convert_case')) {
return mb_convert_case($matches[0], MB_CASE_TITLE, "UTF-8");
}
return ucfirst(strtolower($matches[0]));
} | [
"protected",
"function",
"camelcaseReplace",
"(",
"$",
"matches",
")",
":",
"string",
"{",
"if",
"(",
"function_exists",
"(",
"'mb_convert_case'",
")",
")",
"{",
"return",
"mb_convert_case",
"(",
"$",
"matches",
"[",
"0",
"]",
",",
"MB_CASE_TITLE",
",",
"\"UTF-8\"",
")",
";",
"}",
"return",
"ucfirst",
"(",
"strtolower",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
")",
";",
"}"
] | camelcasing callback
@param $matches
@return string | [
"camelcasing",
"callback"
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Part/AbstractPart.php#L82-L89 |
theiconic/name-parser | src/Mapper/AbstractMapper.php | AbstractMapper.hasUnmappedPartsBefore | protected function hasUnmappedPartsBefore(array $parts, $index): bool
{
foreach ($parts as $k => $part) {
if ($k === $index) {
break;
}
if (!($part instanceof AbstractPart)) {
return true;
}
}
return false;
} | php | protected function hasUnmappedPartsBefore(array $parts, $index): bool
{
foreach ($parts as $k => $part) {
if ($k === $index) {
break;
}
if (!($part instanceof AbstractPart)) {
return true;
}
}
return false;
} | [
"protected",
"function",
"hasUnmappedPartsBefore",
"(",
"array",
"$",
"parts",
",",
"$",
"index",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"k",
"=>",
"$",
"part",
")",
"{",
"if",
"(",
"$",
"k",
"===",
"$",
"index",
")",
"{",
"break",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"part",
"instanceof",
"AbstractPart",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | checks if there are still unmapped parts left before the given position
@param array $parts
@param $index
@return bool | [
"checks",
"if",
"there",
"are",
"still",
"unmapped",
"parts",
"left",
"before",
"the",
"given",
"position"
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Mapper/AbstractMapper.php#L25-L38 |
theiconic/name-parser | src/Name.php | Name.getNickname | public function getNickname(bool $wrap = false): string
{
if ($wrap) {
return sprintf('(%s)', $this->export('Nickname'));
}
return $this->export('Nickname');
} | php | public function getNickname(bool $wrap = false): string
{
if ($wrap) {
return sprintf('(%s)', $this->export('Nickname'));
}
return $this->export('Nickname');
} | [
"public",
"function",
"getNickname",
"(",
"bool",
"$",
"wrap",
"=",
"false",
")",
":",
"string",
"{",
"if",
"(",
"$",
"wrap",
")",
"{",
"return",
"sprintf",
"(",
"'(%s)'",
",",
"$",
"this",
"->",
"export",
"(",
"'Nickname'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"export",
"(",
"'Nickname'",
")",
";",
"}"
] | get the nick name(s)
@param bool $wrap
@return string | [
"get",
"the",
"nick",
"name",
"(",
"s",
")"
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Name.php#L153-L160 |
theiconic/name-parser | src/Name.php | Name.export | protected function export(string $type, bool $strict = false): string
{
$matched = [];
foreach ($this->parts as $part) {
if ($part instanceof AbstractPart && $this->isType($part, $type, $strict)) {
$matched[] = $part->normalize();
}
}
return implode(' ', $matched);
} | php | protected function export(string $type, bool $strict = false): string
{
$matched = [];
foreach ($this->parts as $part) {
if ($part instanceof AbstractPart && $this->isType($part, $type, $strict)) {
$matched[] = $part->normalize();
}
}
return implode(' ', $matched);
} | [
"protected",
"function",
"export",
"(",
"string",
"$",
"type",
",",
"bool",
"$",
"strict",
"=",
"false",
")",
":",
"string",
"{",
"$",
"matched",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"parts",
"as",
"$",
"part",
")",
"{",
"if",
"(",
"$",
"part",
"instanceof",
"AbstractPart",
"&&",
"$",
"this",
"->",
"isType",
"(",
"$",
"part",
",",
"$",
"type",
",",
"$",
"strict",
")",
")",
"{",
"$",
"matched",
"[",
"]",
"=",
"$",
"part",
"->",
"normalize",
"(",
")",
";",
"}",
"}",
"return",
"implode",
"(",
"' '",
",",
"$",
"matched",
")",
";",
"}"
] | helper method used by getters to extract and format relevant name parts
@param string $type
@param bool $pure
@return string | [
"helper",
"method",
"used",
"by",
"getters",
"to",
"extract",
"and",
"format",
"relevant",
"name",
"parts"
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Name.php#L179-L190 |
theiconic/name-parser | src/Name.php | Name.isType | protected function isType(AbstractPart $part, string $type, bool $strict = false): bool
{
$className = sprintf('%s\\%s', self::PARTS_NAMESPACE, $type);
if ($strict) {
return get_class($part) === $className;
}
return is_a($part, $className);
} | php | protected function isType(AbstractPart $part, string $type, bool $strict = false): bool
{
$className = sprintf('%s\\%s', self::PARTS_NAMESPACE, $type);
if ($strict) {
return get_class($part) === $className;
}
return is_a($part, $className);
} | [
"protected",
"function",
"isType",
"(",
"AbstractPart",
"$",
"part",
",",
"string",
"$",
"type",
",",
"bool",
"$",
"strict",
"=",
"false",
")",
":",
"bool",
"{",
"$",
"className",
"=",
"sprintf",
"(",
"'%s\\\\%s'",
",",
"self",
"::",
"PARTS_NAMESPACE",
",",
"$",
"type",
")",
";",
"if",
"(",
"$",
"strict",
")",
"{",
"return",
"get_class",
"(",
"$",
"part",
")",
"===",
"$",
"className",
";",
"}",
"return",
"is_a",
"(",
"$",
"part",
",",
"$",
"className",
")",
";",
"}"
] | helper method to check if a part is of the given type
@param AbstractPart $part
@param string $type
@param bool $strict
@return bool | [
"helper",
"method",
"to",
"check",
"if",
"a",
"part",
"is",
"of",
"the",
"given",
"type"
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Name.php#L200-L209 |
theiconic/name-parser | src/Mapper/MiddlenameMapper.php | MiddlenameMapper.map | public function map(array $parts): array
{
// If we don't expect a lastname, match a mimimum of 2 parts
$minumumParts = ($this->mapWithoutLastname ? 2 : 3);
if (count($parts) < $minumumParts) {
return $parts;
}
$start = $this->findFirstMapped(Firstname::class, $parts);
if (false === $start) {
return $parts;
}
return $this->mapFrom($start, $parts);
} | php | public function map(array $parts): array
{
// If we don't expect a lastname, match a mimimum of 2 parts
$minumumParts = ($this->mapWithoutLastname ? 2 : 3);
if (count($parts) < $minumumParts) {
return $parts;
}
$start = $this->findFirstMapped(Firstname::class, $parts);
if (false === $start) {
return $parts;
}
return $this->mapFrom($start, $parts);
} | [
"public",
"function",
"map",
"(",
"array",
"$",
"parts",
")",
":",
"array",
"{",
"// If we don't expect a lastname, match a mimimum of 2 parts",
"$",
"minumumParts",
"=",
"(",
"$",
"this",
"->",
"mapWithoutLastname",
"?",
"2",
":",
"3",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
"<",
"$",
"minumumParts",
")",
"{",
"return",
"$",
"parts",
";",
"}",
"$",
"start",
"=",
"$",
"this",
"->",
"findFirstMapped",
"(",
"Firstname",
"::",
"class",
",",
"$",
"parts",
")",
";",
"if",
"(",
"false",
"===",
"$",
"start",
")",
"{",
"return",
"$",
"parts",
";",
"}",
"return",
"$",
"this",
"->",
"mapFrom",
"(",
"$",
"start",
",",
"$",
"parts",
")",
";",
"}"
] | map middlenames in the parts array
@param array $parts the name parts
@return array the mapped parts | [
"map",
"middlenames",
"in",
"the",
"parts",
"array"
] | train | https://github.com/theiconic/name-parser/blob/9a2599397d1cd0a9f69bec81286bb0c6b2782c6f/src/Mapper/MiddlenameMapper.php#L25-L41 |
TYPO3-extensions/gridelements | Classes/Hooks/DrawItem.php | DrawItem.cleanupCollapsedStatesInUC | public function cleanupCollapsedStatesInUC()
{
$backendUser = $this->getBackendUser();
if (is_array($backendUser->uc['moduleData']['page']['gridelementsCollapsedColumns'])) {
$collapsedGridelementColumns = $backendUser->uc['moduleData']['page']['gridelementsCollapsedColumns'];
foreach ($collapsedGridelementColumns as $item => $collapsed) {
if (empty($collapsed)) {
unset($collapsedGridelementColumns[$item]);
}
}
$backendUser->uc['moduleData']['page']['gridelementsCollapsedColumns'] = $collapsedGridelementColumns;
$backendUser->writeUC($backendUser->uc);
}
} | php | public function cleanupCollapsedStatesInUC()
{
$backendUser = $this->getBackendUser();
if (is_array($backendUser->uc['moduleData']['page']['gridelementsCollapsedColumns'])) {
$collapsedGridelementColumns = $backendUser->uc['moduleData']['page']['gridelementsCollapsedColumns'];
foreach ($collapsedGridelementColumns as $item => $collapsed) {
if (empty($collapsed)) {
unset($collapsedGridelementColumns[$item]);
}
}
$backendUser->uc['moduleData']['page']['gridelementsCollapsedColumns'] = $collapsedGridelementColumns;
$backendUser->writeUC($backendUser->uc);
}
} | [
"public",
"function",
"cleanupCollapsedStatesInUC",
"(",
")",
"{",
"$",
"backendUser",
"=",
"$",
"this",
"->",
"getBackendUser",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"backendUser",
"->",
"uc",
"[",
"'moduleData'",
"]",
"[",
"'page'",
"]",
"[",
"'gridelementsCollapsedColumns'",
"]",
")",
")",
"{",
"$",
"collapsedGridelementColumns",
"=",
"$",
"backendUser",
"->",
"uc",
"[",
"'moduleData'",
"]",
"[",
"'page'",
"]",
"[",
"'gridelementsCollapsedColumns'",
"]",
";",
"foreach",
"(",
"$",
"collapsedGridelementColumns",
"as",
"$",
"item",
"=>",
"$",
"collapsed",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"collapsed",
")",
")",
"{",
"unset",
"(",
"$",
"collapsedGridelementColumns",
"[",
"$",
"item",
"]",
")",
";",
"}",
"}",
"$",
"backendUser",
"->",
"uc",
"[",
"'moduleData'",
"]",
"[",
"'page'",
"]",
"[",
"'gridelementsCollapsedColumns'",
"]",
"=",
"$",
"collapsedGridelementColumns",
";",
"$",
"backendUser",
"->",
"writeUC",
"(",
"$",
"backendUser",
"->",
"uc",
")",
";",
"}",
"}"
] | Processes the collapsed states of Gridelements columns and removes columns with 0 values | [
"Processes",
"the",
"collapsed",
"states",
"of",
"Gridelements",
"columns",
"and",
"removes",
"columns",
"with",
"0",
"values"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/DrawItem.php#L116-L129 |
TYPO3-extensions/gridelements | Classes/Hooks/DrawItem.php | DrawItem.preProcess | public function preProcess(PageLayoutView &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row)
{
if ($row['CType']) {
$this->showHidden = $parentObject->tt_contentConfig['showHidden'] ? true : false;
if ($this->helper->getBackendUser()->uc['hideContentPreview']) {
$itemContent = '';
$drawItem = false;
}
switch ($row['CType']) {
case 'gridelements_pi1':
$drawItem = false;
$itemContent .= $this->renderCTypeGridelements($parentObject, $row);
$refIndexObj = GeneralUtility::makeInstance(ReferenceIndex::class);
/* @var $refIndexObj \TYPO3\CMS\Core\Database\ReferenceIndex */
$refIndexObj->updateRefIndexTable('tt_content', (int)$row['uid']);
break;
case 'shortcut':
$drawItem = false;
$itemContent .= $this->renderCTypeShortcut($parentObject, $row);
break;
}
}
$listType = $row['list_type'] && $row['CType'] === 'list' ? ' data-list_type="' . $row['list_type'] . '"' : '';
$gridType = $row['tx_gridelements_backend_layout'] && $row['CType'] === 'gridelements_pi1' ? ' data-tx_gridelements_backend_layout="' . $row['tx_gridelements_backend_layout'] . '"' : '';
$headerContent = '<div id="element-tt_content-' . $row['uid'] . '" class="t3-ctype-identifier " data-ctype="' . $row['CType'] . '" ' . $listType . $gridType . '>' . $headerContent . '</div>';
} | php | public function preProcess(PageLayoutView &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row)
{
if ($row['CType']) {
$this->showHidden = $parentObject->tt_contentConfig['showHidden'] ? true : false;
if ($this->helper->getBackendUser()->uc['hideContentPreview']) {
$itemContent = '';
$drawItem = false;
}
switch ($row['CType']) {
case 'gridelements_pi1':
$drawItem = false;
$itemContent .= $this->renderCTypeGridelements($parentObject, $row);
$refIndexObj = GeneralUtility::makeInstance(ReferenceIndex::class);
/* @var $refIndexObj \TYPO3\CMS\Core\Database\ReferenceIndex */
$refIndexObj->updateRefIndexTable('tt_content', (int)$row['uid']);
break;
case 'shortcut':
$drawItem = false;
$itemContent .= $this->renderCTypeShortcut($parentObject, $row);
break;
}
}
$listType = $row['list_type'] && $row['CType'] === 'list' ? ' data-list_type="' . $row['list_type'] . '"' : '';
$gridType = $row['tx_gridelements_backend_layout'] && $row['CType'] === 'gridelements_pi1' ? ' data-tx_gridelements_backend_layout="' . $row['tx_gridelements_backend_layout'] . '"' : '';
$headerContent = '<div id="element-tt_content-' . $row['uid'] . '" class="t3-ctype-identifier " data-ctype="' . $row['CType'] . '" ' . $listType . $gridType . '>' . $headerContent . '</div>';
} | [
"public",
"function",
"preProcess",
"(",
"PageLayoutView",
"&",
"$",
"parentObject",
",",
"&",
"$",
"drawItem",
",",
"&",
"$",
"headerContent",
",",
"&",
"$",
"itemContent",
",",
"array",
"&",
"$",
"row",
")",
"{",
"if",
"(",
"$",
"row",
"[",
"'CType'",
"]",
")",
"{",
"$",
"this",
"->",
"showHidden",
"=",
"$",
"parentObject",
"->",
"tt_contentConfig",
"[",
"'showHidden'",
"]",
"?",
"true",
":",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"helper",
"->",
"getBackendUser",
"(",
")",
"->",
"uc",
"[",
"'hideContentPreview'",
"]",
")",
"{",
"$",
"itemContent",
"=",
"''",
";",
"$",
"drawItem",
"=",
"false",
";",
"}",
"switch",
"(",
"$",
"row",
"[",
"'CType'",
"]",
")",
"{",
"case",
"'gridelements_pi1'",
":",
"$",
"drawItem",
"=",
"false",
";",
"$",
"itemContent",
".=",
"$",
"this",
"->",
"renderCTypeGridelements",
"(",
"$",
"parentObject",
",",
"$",
"row",
")",
";",
"$",
"refIndexObj",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"ReferenceIndex",
"::",
"class",
")",
";",
"/* @var $refIndexObj \\TYPO3\\CMS\\Core\\Database\\ReferenceIndex */",
"$",
"refIndexObj",
"->",
"updateRefIndexTable",
"(",
"'tt_content'",
",",
"(",
"int",
")",
"$",
"row",
"[",
"'uid'",
"]",
")",
";",
"break",
";",
"case",
"'shortcut'",
":",
"$",
"drawItem",
"=",
"false",
";",
"$",
"itemContent",
".=",
"$",
"this",
"->",
"renderCTypeShortcut",
"(",
"$",
"parentObject",
",",
"$",
"row",
")",
";",
"break",
";",
"}",
"}",
"$",
"listType",
"=",
"$",
"row",
"[",
"'list_type'",
"]",
"&&",
"$",
"row",
"[",
"'CType'",
"]",
"===",
"'list'",
"?",
"' data-list_type=\"'",
".",
"$",
"row",
"[",
"'list_type'",
"]",
".",
"'\"'",
":",
"''",
";",
"$",
"gridType",
"=",
"$",
"row",
"[",
"'tx_gridelements_backend_layout'",
"]",
"&&",
"$",
"row",
"[",
"'CType'",
"]",
"===",
"'gridelements_pi1'",
"?",
"' data-tx_gridelements_backend_layout=\"'",
".",
"$",
"row",
"[",
"'tx_gridelements_backend_layout'",
"]",
".",
"'\"'",
":",
"''",
";",
"$",
"headerContent",
"=",
"'<div id=\"element-tt_content-'",
".",
"$",
"row",
"[",
"'uid'",
"]",
".",
"'\" class=\"t3-ctype-identifier \" data-ctype=\"'",
".",
"$",
"row",
"[",
"'CType'",
"]",
".",
"'\" '",
".",
"$",
"listType",
".",
"$",
"gridType",
".",
"'>'",
".",
"$",
"headerContent",
".",
"'</div>'",
";",
"}"
] | Processes the item to be rendered before the actual example content gets rendered
Deactivates the original example content output
@param PageLayoutView $parentObject : The parent object that triggered this hook
@param bool $drawItem : A switch to tell the parent object, if the item still must be drawn
@param string $headerContent : The content of the item header
@param string $itemContent : The content of the item itself
@param array $row : The current data row for this item
@return void | [
"Processes",
"the",
"item",
"to",
"be",
"rendered",
"before",
"the",
"actual",
"example",
"content",
"gets",
"rendered",
"Deactivates",
"the",
"original",
"example",
"content",
"output"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/DrawItem.php#L151-L178 |
TYPO3-extensions/gridelements | Classes/Hooks/DrawItem.php | DrawItem.renderCTypeGridelements | protected function renderCTypeGridelements(PageLayoutView $parentObject, &$row)
{
$head = [];
$gridContent = [];
$editUidList = [];
$colPosValues = [];
$singleColumn = false;
// get the layout record for the selected backend layout if any
$gridContainerId = $row['uid'];
if ($row['pid'] < 0) {
$originalRecord = BackendUtility::getRecord('tt_content', $row['t3ver_oid']);
} else {
$originalRecord = $row;
}
/** @var $layoutSetup LayoutSetup */
$layoutSetup = GeneralUtility::makeInstance(LayoutSetup::class)->init($originalRecord['pid']);
$gridElement = $layoutSetup->cacheCurrentParent($gridContainerId, true);
$layoutUid = $gridElement['tx_gridelements_backend_layout'];
$layout = $layoutSetup->getLayoutSetup($layoutUid);
$parserRows = null;
if (isset($layout['config']) && isset($layout['config']['rows.'])) {
$parserRows = $layout['config']['rows.'];
}
// if there is anything to parse, lets check for existing columns in the layout
if (is_array($parserRows) && !empty($parserRows)) {
$this->setMultipleColPosValues($parserRows, $colPosValues, $layout);
} else {
$singleColumn = true;
$this->setSingleColPosItems($parentObject, $colPosValues, $gridElement);
}
// if there are any columns, lets build the content for them
$outerTtContentDataArray = $parentObject->tt_contentData['nextThree'];
if (!empty($colPosValues)) {
$this->renderGridColumns(
$parentObject,
$colPosValues,
$gridContent,
$gridElement,
$editUidList,
$singleColumn,
$head
);
}
$parentObject->tt_contentData['nextThree'] = $outerTtContentDataArray;
// if we got a selected backend layout, we have to create the layout table now
if ($layoutUid && isset($layout['config'])) {
$itemContent = $this->renderGridLayoutTable($layout, $gridElement, $head, $gridContent, $parentObject);
} else {
$itemContent = '<div class="t3-grid-container t3-grid-element-container">';
$itemContent .= '<table border="0" cellspacing="0" cellpadding="0" width="100%" class="t3-page-columns t3-grid-table">';
$itemContent .= '<tr><td valign="top" class="t3-grid-cell t3-page-column t3-page-column-0">' . $gridContent[0] . '</td></tr>';
$itemContent .= '</table></div>';
}
return $itemContent;
} | php | protected function renderCTypeGridelements(PageLayoutView $parentObject, &$row)
{
$head = [];
$gridContent = [];
$editUidList = [];
$colPosValues = [];
$singleColumn = false;
// get the layout record for the selected backend layout if any
$gridContainerId = $row['uid'];
if ($row['pid'] < 0) {
$originalRecord = BackendUtility::getRecord('tt_content', $row['t3ver_oid']);
} else {
$originalRecord = $row;
}
/** @var $layoutSetup LayoutSetup */
$layoutSetup = GeneralUtility::makeInstance(LayoutSetup::class)->init($originalRecord['pid']);
$gridElement = $layoutSetup->cacheCurrentParent($gridContainerId, true);
$layoutUid = $gridElement['tx_gridelements_backend_layout'];
$layout = $layoutSetup->getLayoutSetup($layoutUid);
$parserRows = null;
if (isset($layout['config']) && isset($layout['config']['rows.'])) {
$parserRows = $layout['config']['rows.'];
}
// if there is anything to parse, lets check for existing columns in the layout
if (is_array($parserRows) && !empty($parserRows)) {
$this->setMultipleColPosValues($parserRows, $colPosValues, $layout);
} else {
$singleColumn = true;
$this->setSingleColPosItems($parentObject, $colPosValues, $gridElement);
}
// if there are any columns, lets build the content for them
$outerTtContentDataArray = $parentObject->tt_contentData['nextThree'];
if (!empty($colPosValues)) {
$this->renderGridColumns(
$parentObject,
$colPosValues,
$gridContent,
$gridElement,
$editUidList,
$singleColumn,
$head
);
}
$parentObject->tt_contentData['nextThree'] = $outerTtContentDataArray;
// if we got a selected backend layout, we have to create the layout table now
if ($layoutUid && isset($layout['config'])) {
$itemContent = $this->renderGridLayoutTable($layout, $gridElement, $head, $gridContent, $parentObject);
} else {
$itemContent = '<div class="t3-grid-container t3-grid-element-container">';
$itemContent .= '<table border="0" cellspacing="0" cellpadding="0" width="100%" class="t3-page-columns t3-grid-table">';
$itemContent .= '<tr><td valign="top" class="t3-grid-cell t3-page-column t3-page-column-0">' . $gridContent[0] . '</td></tr>';
$itemContent .= '</table></div>';
}
return $itemContent;
} | [
"protected",
"function",
"renderCTypeGridelements",
"(",
"PageLayoutView",
"$",
"parentObject",
",",
"&",
"$",
"row",
")",
"{",
"$",
"head",
"=",
"[",
"]",
";",
"$",
"gridContent",
"=",
"[",
"]",
";",
"$",
"editUidList",
"=",
"[",
"]",
";",
"$",
"colPosValues",
"=",
"[",
"]",
";",
"$",
"singleColumn",
"=",
"false",
";",
"// get the layout record for the selected backend layout if any",
"$",
"gridContainerId",
"=",
"$",
"row",
"[",
"'uid'",
"]",
";",
"if",
"(",
"$",
"row",
"[",
"'pid'",
"]",
"<",
"0",
")",
"{",
"$",
"originalRecord",
"=",
"BackendUtility",
"::",
"getRecord",
"(",
"'tt_content'",
",",
"$",
"row",
"[",
"'t3ver_oid'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"originalRecord",
"=",
"$",
"row",
";",
"}",
"/** @var $layoutSetup LayoutSetup */",
"$",
"layoutSetup",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"LayoutSetup",
"::",
"class",
")",
"->",
"init",
"(",
"$",
"originalRecord",
"[",
"'pid'",
"]",
")",
";",
"$",
"gridElement",
"=",
"$",
"layoutSetup",
"->",
"cacheCurrentParent",
"(",
"$",
"gridContainerId",
",",
"true",
")",
";",
"$",
"layoutUid",
"=",
"$",
"gridElement",
"[",
"'tx_gridelements_backend_layout'",
"]",
";",
"$",
"layout",
"=",
"$",
"layoutSetup",
"->",
"getLayoutSetup",
"(",
"$",
"layoutUid",
")",
";",
"$",
"parserRows",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"layout",
"[",
"'config'",
"]",
")",
"&&",
"isset",
"(",
"$",
"layout",
"[",
"'config'",
"]",
"[",
"'rows.'",
"]",
")",
")",
"{",
"$",
"parserRows",
"=",
"$",
"layout",
"[",
"'config'",
"]",
"[",
"'rows.'",
"]",
";",
"}",
"// if there is anything to parse, lets check for existing columns in the layout",
"if",
"(",
"is_array",
"(",
"$",
"parserRows",
")",
"&&",
"!",
"empty",
"(",
"$",
"parserRows",
")",
")",
"{",
"$",
"this",
"->",
"setMultipleColPosValues",
"(",
"$",
"parserRows",
",",
"$",
"colPosValues",
",",
"$",
"layout",
")",
";",
"}",
"else",
"{",
"$",
"singleColumn",
"=",
"true",
";",
"$",
"this",
"->",
"setSingleColPosItems",
"(",
"$",
"parentObject",
",",
"$",
"colPosValues",
",",
"$",
"gridElement",
")",
";",
"}",
"// if there are any columns, lets build the content for them",
"$",
"outerTtContentDataArray",
"=",
"$",
"parentObject",
"->",
"tt_contentData",
"[",
"'nextThree'",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"colPosValues",
")",
")",
"{",
"$",
"this",
"->",
"renderGridColumns",
"(",
"$",
"parentObject",
",",
"$",
"colPosValues",
",",
"$",
"gridContent",
",",
"$",
"gridElement",
",",
"$",
"editUidList",
",",
"$",
"singleColumn",
",",
"$",
"head",
")",
";",
"}",
"$",
"parentObject",
"->",
"tt_contentData",
"[",
"'nextThree'",
"]",
"=",
"$",
"outerTtContentDataArray",
";",
"// if we got a selected backend layout, we have to create the layout table now",
"if",
"(",
"$",
"layoutUid",
"&&",
"isset",
"(",
"$",
"layout",
"[",
"'config'",
"]",
")",
")",
"{",
"$",
"itemContent",
"=",
"$",
"this",
"->",
"renderGridLayoutTable",
"(",
"$",
"layout",
",",
"$",
"gridElement",
",",
"$",
"head",
",",
"$",
"gridContent",
",",
"$",
"parentObject",
")",
";",
"}",
"else",
"{",
"$",
"itemContent",
"=",
"'<div class=\"t3-grid-container t3-grid-element-container\">'",
";",
"$",
"itemContent",
".=",
"'<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" class=\"t3-page-columns t3-grid-table\">'",
";",
"$",
"itemContent",
".=",
"'<tr><td valign=\"top\" class=\"t3-grid-cell t3-page-column t3-page-column-0\">'",
".",
"$",
"gridContent",
"[",
"0",
"]",
".",
"'</td></tr>'",
";",
"$",
"itemContent",
".=",
"'</table></div>'",
";",
"}",
"return",
"$",
"itemContent",
";",
"}"
] | renders the HTML output for elements of the CType gridelements_pi1
@param PageLayoutView $parentObject : The parent object that triggered this hook
@param array $row : The current data row for this item
@return string $itemContent: The HTML output for elements of the CType gridelements_pi1 | [
"renders",
"the",
"HTML",
"output",
"for",
"elements",
"of",
"the",
"CType",
"gridelements_pi1"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/DrawItem.php#L188-L246 |
TYPO3-extensions/gridelements | Classes/Hooks/DrawItem.php | DrawItem.setMultipleColPosValues | protected function setMultipleColPosValues($parserRows, &$colPosValues, $layout)
{
if (is_array($parserRows)) {
foreach ($parserRows as $parserRow) {
if (is_array($parserRow['columns.']) && !empty($parserRow['columns.'])) {
foreach ($parserRow['columns.'] as $parserColumns) {
$name = $this->languageService->sL($parserColumns['name']);
if (isset($parserColumns['colPos']) && $parserColumns['colPos'] !== '') {
$columnKey = (int)$parserColumns['colPos'];
$colPosValues[$columnKey] = [
'name' => $name,
'allowed' => $layout['allowed'][$columnKey],
'disallowed' => $layout['disallowed'][$columnKey],
'maxitems' => $layout['maxitems'][$columnKey],
];
} else {
$colPosValues[32768] = [
'name' => $this->languageService->getLL('notAssigned'),
'allowed' => '',
'disallowed' => '*',
'maxitems' => 0,
];
}
}
}
}
}
} | php | protected function setMultipleColPosValues($parserRows, &$colPosValues, $layout)
{
if (is_array($parserRows)) {
foreach ($parserRows as $parserRow) {
if (is_array($parserRow['columns.']) && !empty($parserRow['columns.'])) {
foreach ($parserRow['columns.'] as $parserColumns) {
$name = $this->languageService->sL($parserColumns['name']);
if (isset($parserColumns['colPos']) && $parserColumns['colPos'] !== '') {
$columnKey = (int)$parserColumns['colPos'];
$colPosValues[$columnKey] = [
'name' => $name,
'allowed' => $layout['allowed'][$columnKey],
'disallowed' => $layout['disallowed'][$columnKey],
'maxitems' => $layout['maxitems'][$columnKey],
];
} else {
$colPosValues[32768] = [
'name' => $this->languageService->getLL('notAssigned'),
'allowed' => '',
'disallowed' => '*',
'maxitems' => 0,
];
}
}
}
}
}
} | [
"protected",
"function",
"setMultipleColPosValues",
"(",
"$",
"parserRows",
",",
"&",
"$",
"colPosValues",
",",
"$",
"layout",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"parserRows",
")",
")",
"{",
"foreach",
"(",
"$",
"parserRows",
"as",
"$",
"parserRow",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"parserRow",
"[",
"'columns.'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"parserRow",
"[",
"'columns.'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"parserRow",
"[",
"'columns.'",
"]",
"as",
"$",
"parserColumns",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"languageService",
"->",
"sL",
"(",
"$",
"parserColumns",
"[",
"'name'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"parserColumns",
"[",
"'colPos'",
"]",
")",
"&&",
"$",
"parserColumns",
"[",
"'colPos'",
"]",
"!==",
"''",
")",
"{",
"$",
"columnKey",
"=",
"(",
"int",
")",
"$",
"parserColumns",
"[",
"'colPos'",
"]",
";",
"$",
"colPosValues",
"[",
"$",
"columnKey",
"]",
"=",
"[",
"'name'",
"=>",
"$",
"name",
",",
"'allowed'",
"=>",
"$",
"layout",
"[",
"'allowed'",
"]",
"[",
"$",
"columnKey",
"]",
",",
"'disallowed'",
"=>",
"$",
"layout",
"[",
"'disallowed'",
"]",
"[",
"$",
"columnKey",
"]",
",",
"'maxitems'",
"=>",
"$",
"layout",
"[",
"'maxitems'",
"]",
"[",
"$",
"columnKey",
"]",
",",
"]",
";",
"}",
"else",
"{",
"$",
"colPosValues",
"[",
"32768",
"]",
"=",
"[",
"'name'",
"=>",
"$",
"this",
"->",
"languageService",
"->",
"getLL",
"(",
"'notAssigned'",
")",
",",
"'allowed'",
"=>",
"''",
",",
"'disallowed'",
"=>",
"'*'",
",",
"'maxitems'",
"=>",
"0",
",",
"]",
";",
"}",
"}",
"}",
"}",
"}",
"}"
] | Sets column positions based on a selected gridelement layout
@param array $parserRows : The parsed rows of the gridelement layout
@param array $colPosValues : The column positions that have been found for that layout
@param array $layout
@return void | [
"Sets",
"column",
"positions",
"based",
"on",
"a",
"selected",
"gridelement",
"layout"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/DrawItem.php#L256-L283 |
TYPO3-extensions/gridelements | Classes/Hooks/DrawItem.php | DrawItem.setSingleColPosItems | protected function setSingleColPosItems(PageLayoutView $parentObject, &$colPosValues, &$row)
{
$specificIds = $this->helper->getSpecificIds($row);
/** @var $expressionBuilder ExpressionBuilder */
$expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tt_content')
->expr();
$queryBuilder = $parentObject->getQueryBuilder(
'tt_content',
$specificIds['pid'],
[
$expressionBuilder->eq('colPos', -1),
$expressionBuilder->in('tx_gridelements_container', [(int)$row['uid'], $specificIds['uid']]),
]
);
$restrictions = $queryBuilder->getRestrictions();
if ($this->showHidden) {
$restrictions->removeByType(HiddenRestriction::class);
}
$restrictions->removeByType(StartTimeRestriction::class);
$restrictions->removeByType(EndTimeRestriction::class);
$queryBuilder->setRestrictions($restrictions);
$colPosValues[] = [0, ''];
return $parentObject->getResult($queryBuilder->execute());
} | php | protected function setSingleColPosItems(PageLayoutView $parentObject, &$colPosValues, &$row)
{
$specificIds = $this->helper->getSpecificIds($row);
/** @var $expressionBuilder ExpressionBuilder */
$expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tt_content')
->expr();
$queryBuilder = $parentObject->getQueryBuilder(
'tt_content',
$specificIds['pid'],
[
$expressionBuilder->eq('colPos', -1),
$expressionBuilder->in('tx_gridelements_container', [(int)$row['uid'], $specificIds['uid']]),
]
);
$restrictions = $queryBuilder->getRestrictions();
if ($this->showHidden) {
$restrictions->removeByType(HiddenRestriction::class);
}
$restrictions->removeByType(StartTimeRestriction::class);
$restrictions->removeByType(EndTimeRestriction::class);
$queryBuilder->setRestrictions($restrictions);
$colPosValues[] = [0, ''];
return $parentObject->getResult($queryBuilder->execute());
} | [
"protected",
"function",
"setSingleColPosItems",
"(",
"PageLayoutView",
"$",
"parentObject",
",",
"&",
"$",
"colPosValues",
",",
"&",
"$",
"row",
")",
"{",
"$",
"specificIds",
"=",
"$",
"this",
"->",
"helper",
"->",
"getSpecificIds",
"(",
"$",
"row",
")",
";",
"/** @var $expressionBuilder ExpressionBuilder */",
"$",
"expressionBuilder",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"ConnectionPool",
"::",
"class",
")",
"->",
"getQueryBuilderForTable",
"(",
"'tt_content'",
")",
"->",
"expr",
"(",
")",
";",
"$",
"queryBuilder",
"=",
"$",
"parentObject",
"->",
"getQueryBuilder",
"(",
"'tt_content'",
",",
"$",
"specificIds",
"[",
"'pid'",
"]",
",",
"[",
"$",
"expressionBuilder",
"->",
"eq",
"(",
"'colPos'",
",",
"-",
"1",
")",
",",
"$",
"expressionBuilder",
"->",
"in",
"(",
"'tx_gridelements_container'",
",",
"[",
"(",
"int",
")",
"$",
"row",
"[",
"'uid'",
"]",
",",
"$",
"specificIds",
"[",
"'uid'",
"]",
"]",
")",
",",
"]",
")",
";",
"$",
"restrictions",
"=",
"$",
"queryBuilder",
"->",
"getRestrictions",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"showHidden",
")",
"{",
"$",
"restrictions",
"->",
"removeByType",
"(",
"HiddenRestriction",
"::",
"class",
")",
";",
"}",
"$",
"restrictions",
"->",
"removeByType",
"(",
"StartTimeRestriction",
"::",
"class",
")",
";",
"$",
"restrictions",
"->",
"removeByType",
"(",
"EndTimeRestriction",
"::",
"class",
")",
";",
"$",
"queryBuilder",
"->",
"setRestrictions",
"(",
"$",
"restrictions",
")",
";",
"$",
"colPosValues",
"[",
"]",
"=",
"[",
"0",
",",
"''",
"]",
";",
"return",
"$",
"parentObject",
"->",
"getResult",
"(",
"$",
"queryBuilder",
"->",
"execute",
"(",
")",
")",
";",
"}"
] | Directly returns the items for a single column if the rendering mode is set to single columns only
@param PageLayoutView $parentObject : The parent object that triggered this hook
@param array $colPosValues : The column positions that have been found for that layout
@param array $row : The current data row for the container item
@return array collected items for this column | [
"Directly",
"returns",
"the",
"items",
"for",
"a",
"single",
"column",
"if",
"the",
"rendering",
"mode",
"is",
"set",
"to",
"single",
"columns",
"only"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/DrawItem.php#L294-L321 |
TYPO3-extensions/gridelements | Classes/Hooks/DrawItem.php | DrawItem.renderGridColumns | protected function renderGridColumns(
PageLayoutView $parentObject,
&$colPosValues,
&$gridContent,
&$row,
&$editUidList,
&$singleColumn,
&$head
) {
$collectedItems = $this->collectItemsForColumns($parentObject, $colPosValues, $row);
$workspace = $this->helper->getBackendUser()->workspace;
if ($workspace > 0) {
$workspacePreparedItems = [];
$moveUids = [];
foreach ($collectedItems as $item) {
if ($item['t3ver_state'] === 3) {
$moveUids[] = (int)$item['t3ver_move_id'];
$item = BackendUtility::getRecordWSOL('tt_content', (int)$item['uid']);
$movePlaceholder = BackendUtility::getMovePlaceholder(
'tt_content',
(int)$item['uid'],
'*',
$workspace
);
if (!empty($movePlaceholder)) {
$item['sorting'] = $movePlaceholder['sorting'];
$item['tx_gridelements_columns'] = $movePlaceholder['tx_gridelements_columns'];
$item['tx_gridelements_container'] = $movePlaceholder['tx_gridelements_container'];
}
} else {
$item = BackendUtility::getRecordWSOL('tt_content', (int)$item['uid']);
if ($item['t3ver_state'] === 4) {
$movePlaceholder = BackendUtility::getMovePlaceholder(
'tt_content',
(int)$item['uid'],
'*',
$workspace
);
if (!empty($movePlaceholder)) {
$item['sorting'] = $movePlaceholder['sorting'];
$item['tx_gridelements_columns'] = $movePlaceholder['tx_gridelements_columns'];
$item['tx_gridelements_container'] = $movePlaceholder['tx_gridelements_container'];
}
}
}
$workspacePreparedItems[] = $item;
}
$moveUids = array_flip($moveUids);
$collectedItems = $workspacePreparedItems;
foreach ($collectedItems as $key => $item) {
if (isset($moveUids[$item['uid']]) && !$item['_MOVE_PLH']) {
unset($collectedItems[$key]);
}
}
} else {
foreach ($collectedItems as $key => $item) {
$item = BackendUtility::getRecordWSOL('tt_content', (int)$item['uid']);
if ($item['t3ver_state'] > 0) {
unset($collectedItems[$key]);
}
}
}
foreach ($colPosValues as $colPos => $values) {
// first we have to create the column content separately for each column
// so we can check for the first and the last element to provide proper sorting
$counter = 0;
if ($singleColumn === false) {
$items = [];
foreach ($collectedItems as $item) {
if ((int)$item['tx_gridelements_columns'] === $colPos && (int)$item['tx_gridelements_container'] === (int)$row['uid']) {
if (
$row['sys_language_uid'] === $item['sys_language_uid'] ||
($row['sys_language_uid'] === -1 && $item['sys_language_uid'] === 0)
) {
$counter++;
}
$items[] = $item;
}
}
} else {
$items = [];
}
usort($items, function ($a, $b) {
if ($a['sorting'] === $b['sorting']) {
return 0;
}
return $a['sorting'] > $b['sorting'] ? 1 : -1;
});
// if there are any items, we can create the HTML for them just like in the original TCEform
$gridContent['numberOfItems'][$colPos] = $counter;
$this->renderSingleGridColumn($parentObject, $items, $colPos, $values, $gridContent, $row, $editUidList);
// we will need a header for each of the columns to activate mass editing for elements of that column
$expanded = $this->helper->getBackendUser()->uc['moduleData']['page']['gridelementsCollapsedColumns'][$row['uid'] . '_' . $colPos] ? false : true;
$this->setColumnHeader($parentObject, $head, $colPos, $values['name'], $editUidList, $expanded);
}
} | php | protected function renderGridColumns(
PageLayoutView $parentObject,
&$colPosValues,
&$gridContent,
&$row,
&$editUidList,
&$singleColumn,
&$head
) {
$collectedItems = $this->collectItemsForColumns($parentObject, $colPosValues, $row);
$workspace = $this->helper->getBackendUser()->workspace;
if ($workspace > 0) {
$workspacePreparedItems = [];
$moveUids = [];
foreach ($collectedItems as $item) {
if ($item['t3ver_state'] === 3) {
$moveUids[] = (int)$item['t3ver_move_id'];
$item = BackendUtility::getRecordWSOL('tt_content', (int)$item['uid']);
$movePlaceholder = BackendUtility::getMovePlaceholder(
'tt_content',
(int)$item['uid'],
'*',
$workspace
);
if (!empty($movePlaceholder)) {
$item['sorting'] = $movePlaceholder['sorting'];
$item['tx_gridelements_columns'] = $movePlaceholder['tx_gridelements_columns'];
$item['tx_gridelements_container'] = $movePlaceholder['tx_gridelements_container'];
}
} else {
$item = BackendUtility::getRecordWSOL('tt_content', (int)$item['uid']);
if ($item['t3ver_state'] === 4) {
$movePlaceholder = BackendUtility::getMovePlaceholder(
'tt_content',
(int)$item['uid'],
'*',
$workspace
);
if (!empty($movePlaceholder)) {
$item['sorting'] = $movePlaceholder['sorting'];
$item['tx_gridelements_columns'] = $movePlaceholder['tx_gridelements_columns'];
$item['tx_gridelements_container'] = $movePlaceholder['tx_gridelements_container'];
}
}
}
$workspacePreparedItems[] = $item;
}
$moveUids = array_flip($moveUids);
$collectedItems = $workspacePreparedItems;
foreach ($collectedItems as $key => $item) {
if (isset($moveUids[$item['uid']]) && !$item['_MOVE_PLH']) {
unset($collectedItems[$key]);
}
}
} else {
foreach ($collectedItems as $key => $item) {
$item = BackendUtility::getRecordWSOL('tt_content', (int)$item['uid']);
if ($item['t3ver_state'] > 0) {
unset($collectedItems[$key]);
}
}
}
foreach ($colPosValues as $colPos => $values) {
// first we have to create the column content separately for each column
// so we can check for the first and the last element to provide proper sorting
$counter = 0;
if ($singleColumn === false) {
$items = [];
foreach ($collectedItems as $item) {
if ((int)$item['tx_gridelements_columns'] === $colPos && (int)$item['tx_gridelements_container'] === (int)$row['uid']) {
if (
$row['sys_language_uid'] === $item['sys_language_uid'] ||
($row['sys_language_uid'] === -1 && $item['sys_language_uid'] === 0)
) {
$counter++;
}
$items[] = $item;
}
}
} else {
$items = [];
}
usort($items, function ($a, $b) {
if ($a['sorting'] === $b['sorting']) {
return 0;
}
return $a['sorting'] > $b['sorting'] ? 1 : -1;
});
// if there are any items, we can create the HTML for them just like in the original TCEform
$gridContent['numberOfItems'][$colPos] = $counter;
$this->renderSingleGridColumn($parentObject, $items, $colPos, $values, $gridContent, $row, $editUidList);
// we will need a header for each of the columns to activate mass editing for elements of that column
$expanded = $this->helper->getBackendUser()->uc['moduleData']['page']['gridelementsCollapsedColumns'][$row['uid'] . '_' . $colPos] ? false : true;
$this->setColumnHeader($parentObject, $head, $colPos, $values['name'], $editUidList, $expanded);
}
} | [
"protected",
"function",
"renderGridColumns",
"(",
"PageLayoutView",
"$",
"parentObject",
",",
"&",
"$",
"colPosValues",
",",
"&",
"$",
"gridContent",
",",
"&",
"$",
"row",
",",
"&",
"$",
"editUidList",
",",
"&",
"$",
"singleColumn",
",",
"&",
"$",
"head",
")",
"{",
"$",
"collectedItems",
"=",
"$",
"this",
"->",
"collectItemsForColumns",
"(",
"$",
"parentObject",
",",
"$",
"colPosValues",
",",
"$",
"row",
")",
";",
"$",
"workspace",
"=",
"$",
"this",
"->",
"helper",
"->",
"getBackendUser",
"(",
")",
"->",
"workspace",
";",
"if",
"(",
"$",
"workspace",
">",
"0",
")",
"{",
"$",
"workspacePreparedItems",
"=",
"[",
"]",
";",
"$",
"moveUids",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"collectedItems",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"[",
"'t3ver_state'",
"]",
"===",
"3",
")",
"{",
"$",
"moveUids",
"[",
"]",
"=",
"(",
"int",
")",
"$",
"item",
"[",
"'t3ver_move_id'",
"]",
";",
"$",
"item",
"=",
"BackendUtility",
"::",
"getRecordWSOL",
"(",
"'tt_content'",
",",
"(",
"int",
")",
"$",
"item",
"[",
"'uid'",
"]",
")",
";",
"$",
"movePlaceholder",
"=",
"BackendUtility",
"::",
"getMovePlaceholder",
"(",
"'tt_content'",
",",
"(",
"int",
")",
"$",
"item",
"[",
"'uid'",
"]",
",",
"'*'",
",",
"$",
"workspace",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"movePlaceholder",
")",
")",
"{",
"$",
"item",
"[",
"'sorting'",
"]",
"=",
"$",
"movePlaceholder",
"[",
"'sorting'",
"]",
";",
"$",
"item",
"[",
"'tx_gridelements_columns'",
"]",
"=",
"$",
"movePlaceholder",
"[",
"'tx_gridelements_columns'",
"]",
";",
"$",
"item",
"[",
"'tx_gridelements_container'",
"]",
"=",
"$",
"movePlaceholder",
"[",
"'tx_gridelements_container'",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"item",
"=",
"BackendUtility",
"::",
"getRecordWSOL",
"(",
"'tt_content'",
",",
"(",
"int",
")",
"$",
"item",
"[",
"'uid'",
"]",
")",
";",
"if",
"(",
"$",
"item",
"[",
"'t3ver_state'",
"]",
"===",
"4",
")",
"{",
"$",
"movePlaceholder",
"=",
"BackendUtility",
"::",
"getMovePlaceholder",
"(",
"'tt_content'",
",",
"(",
"int",
")",
"$",
"item",
"[",
"'uid'",
"]",
",",
"'*'",
",",
"$",
"workspace",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"movePlaceholder",
")",
")",
"{",
"$",
"item",
"[",
"'sorting'",
"]",
"=",
"$",
"movePlaceholder",
"[",
"'sorting'",
"]",
";",
"$",
"item",
"[",
"'tx_gridelements_columns'",
"]",
"=",
"$",
"movePlaceholder",
"[",
"'tx_gridelements_columns'",
"]",
";",
"$",
"item",
"[",
"'tx_gridelements_container'",
"]",
"=",
"$",
"movePlaceholder",
"[",
"'tx_gridelements_container'",
"]",
";",
"}",
"}",
"}",
"$",
"workspacePreparedItems",
"[",
"]",
"=",
"$",
"item",
";",
"}",
"$",
"moveUids",
"=",
"array_flip",
"(",
"$",
"moveUids",
")",
";",
"$",
"collectedItems",
"=",
"$",
"workspacePreparedItems",
";",
"foreach",
"(",
"$",
"collectedItems",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"moveUids",
"[",
"$",
"item",
"[",
"'uid'",
"]",
"]",
")",
"&&",
"!",
"$",
"item",
"[",
"'_MOVE_PLH'",
"]",
")",
"{",
"unset",
"(",
"$",
"collectedItems",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"collectedItems",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"$",
"item",
"=",
"BackendUtility",
"::",
"getRecordWSOL",
"(",
"'tt_content'",
",",
"(",
"int",
")",
"$",
"item",
"[",
"'uid'",
"]",
")",
";",
"if",
"(",
"$",
"item",
"[",
"'t3ver_state'",
"]",
">",
"0",
")",
"{",
"unset",
"(",
"$",
"collectedItems",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}",
"foreach",
"(",
"$",
"colPosValues",
"as",
"$",
"colPos",
"=>",
"$",
"values",
")",
"{",
"// first we have to create the column content separately for each column",
"// so we can check for the first and the last element to provide proper sorting",
"$",
"counter",
"=",
"0",
";",
"if",
"(",
"$",
"singleColumn",
"===",
"false",
")",
"{",
"$",
"items",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"collectedItems",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"(",
"int",
")",
"$",
"item",
"[",
"'tx_gridelements_columns'",
"]",
"===",
"$",
"colPos",
"&&",
"(",
"int",
")",
"$",
"item",
"[",
"'tx_gridelements_container'",
"]",
"===",
"(",
"int",
")",
"$",
"row",
"[",
"'uid'",
"]",
")",
"{",
"if",
"(",
"$",
"row",
"[",
"'sys_language_uid'",
"]",
"===",
"$",
"item",
"[",
"'sys_language_uid'",
"]",
"||",
"(",
"$",
"row",
"[",
"'sys_language_uid'",
"]",
"===",
"-",
"1",
"&&",
"$",
"item",
"[",
"'sys_language_uid'",
"]",
"===",
"0",
")",
")",
"{",
"$",
"counter",
"++",
";",
"}",
"$",
"items",
"[",
"]",
"=",
"$",
"item",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"items",
"=",
"[",
"]",
";",
"}",
"usort",
"(",
"$",
"items",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"if",
"(",
"$",
"a",
"[",
"'sorting'",
"]",
"===",
"$",
"b",
"[",
"'sorting'",
"]",
")",
"{",
"return",
"0",
";",
"}",
"return",
"$",
"a",
"[",
"'sorting'",
"]",
">",
"$",
"b",
"[",
"'sorting'",
"]",
"?",
"1",
":",
"-",
"1",
";",
"}",
")",
";",
"// if there are any items, we can create the HTML for them just like in the original TCEform",
"$",
"gridContent",
"[",
"'numberOfItems'",
"]",
"[",
"$",
"colPos",
"]",
"=",
"$",
"counter",
";",
"$",
"this",
"->",
"renderSingleGridColumn",
"(",
"$",
"parentObject",
",",
"$",
"items",
",",
"$",
"colPos",
",",
"$",
"values",
",",
"$",
"gridContent",
",",
"$",
"row",
",",
"$",
"editUidList",
")",
";",
"// we will need a header for each of the columns to activate mass editing for elements of that column",
"$",
"expanded",
"=",
"$",
"this",
"->",
"helper",
"->",
"getBackendUser",
"(",
")",
"->",
"uc",
"[",
"'moduleData'",
"]",
"[",
"'page'",
"]",
"[",
"'gridelementsCollapsedColumns'",
"]",
"[",
"$",
"row",
"[",
"'uid'",
"]",
".",
"'_'",
".",
"$",
"colPos",
"]",
"?",
"false",
":",
"true",
";",
"$",
"this",
"->",
"setColumnHeader",
"(",
"$",
"parentObject",
",",
"$",
"head",
",",
"$",
"colPos",
",",
"$",
"values",
"[",
"'name'",
"]",
",",
"$",
"editUidList",
",",
"$",
"expanded",
")",
";",
"}",
"}"
] | renders the columns of a grid layout
@param PageLayoutView $parentObject : The parent object that triggered this hook
@param array $colPosValues : The column positions we want to get the content for
@param array $gridContent : The rendered content data of the grid columns
@param array $row : The current data row for the container item
@param array $editUidList : determines if we will get edit icons or not
@param bool $singleColumn : Determines if we are in single column mode or not
@param array $head : An array of headers for each of the columns
@return void | [
"renders",
"the",
"columns",
"of",
"a",
"grid",
"layout"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/DrawItem.php#L336-L432 |
TYPO3-extensions/gridelements | Classes/Hooks/DrawItem.php | DrawItem.collectItemsForColumns | protected function collectItemsForColumns(PageLayoutView $parentObject, &$colPosValues, &$row)
{
$colPosList = array_keys($colPosValues);
$specificIds = $this->helper->getSpecificIds($row);
$queryBuilder = $this->getQueryBuilder();
$constraints = [
$queryBuilder->expr()->in(
'pid',
$queryBuilder->createNamedParameter(
[(int)$row['pid'], $specificIds['pid']],
Connection::PARAM_INT_ARRAY
)
),
$queryBuilder->expr()->eq('colPos', $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT)),
$queryBuilder->expr()->in(
'tx_gridelements_container',
$queryBuilder->createNamedParameter(
[(int)$row['uid'], $specificIds['uid']],
Connection::PARAM_INT_ARRAY
)
),
$queryBuilder->expr()->in(
'tx_gridelements_columns',
$queryBuilder->createNamedParameter($colPosList, Connection::PARAM_INT_ARRAY)
),
];
if (!$parentObject->tt_contentConfig['languageMode']) {
$constraints[] = $queryBuilder->expr()->orX(
$queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT)),
$queryBuilder->expr()->eq(
'sys_language_uid',
$queryBuilder->createNamedParameter(
(int)$parentObject->tt_contentConfig['sys_language_uid'],
\PDO::PARAM_INT
)
)
);
} elseif ($row['sys_language_uid'] > 0) {
$constraints[] = $queryBuilder->expr()->eq(
'sys_language_uid',
$queryBuilder->createNamedParameter((int)$row['sys_language_uid'], \PDO::PARAM_INT)
);
}
if ($this->helper->getBackendUser()->workspace > 0) {
if ($row['t3ver_wsid'] > 0) {
$constraints[] = $queryBuilder->expr()->eq(
't3ver_wsid',
$queryBuilder->createNamedParameter((int)$row['t3ver_wsid'], \PDO::PARAM_INT)
);
} else {
$constraints[] = $queryBuilder->expr()->orX(
$queryBuilder->expr()->eq(
't3ver_wsid',
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
),
$queryBuilder->expr()->eq(
't3ver_wsid',
$queryBuilder->createNamedParameter(
$this->helper->getBackendUser()->workspace,
\PDO::PARAM_INT
)
)
);
}
}
$queryBuilder
->select('*')
->from('tt_content')
->where(
...$constraints
)
->orderBy('sorting');
$restrictions = $queryBuilder->getRestrictions();
if ($this->showHidden) {
$restrictions->removeByType(HiddenRestriction::class);
}
$restrictions->removeByType(StartTimeRestriction::class);
$restrictions->removeByType(EndTimeRestriction::class);
$queryBuilder->setRestrictions($restrictions);
return $queryBuilder->execute()->fetchAll();
} | php | protected function collectItemsForColumns(PageLayoutView $parentObject, &$colPosValues, &$row)
{
$colPosList = array_keys($colPosValues);
$specificIds = $this->helper->getSpecificIds($row);
$queryBuilder = $this->getQueryBuilder();
$constraints = [
$queryBuilder->expr()->in(
'pid',
$queryBuilder->createNamedParameter(
[(int)$row['pid'], $specificIds['pid']],
Connection::PARAM_INT_ARRAY
)
),
$queryBuilder->expr()->eq('colPos', $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT)),
$queryBuilder->expr()->in(
'tx_gridelements_container',
$queryBuilder->createNamedParameter(
[(int)$row['uid'], $specificIds['uid']],
Connection::PARAM_INT_ARRAY
)
),
$queryBuilder->expr()->in(
'tx_gridelements_columns',
$queryBuilder->createNamedParameter($colPosList, Connection::PARAM_INT_ARRAY)
),
];
if (!$parentObject->tt_contentConfig['languageMode']) {
$constraints[] = $queryBuilder->expr()->orX(
$queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT)),
$queryBuilder->expr()->eq(
'sys_language_uid',
$queryBuilder->createNamedParameter(
(int)$parentObject->tt_contentConfig['sys_language_uid'],
\PDO::PARAM_INT
)
)
);
} elseif ($row['sys_language_uid'] > 0) {
$constraints[] = $queryBuilder->expr()->eq(
'sys_language_uid',
$queryBuilder->createNamedParameter((int)$row['sys_language_uid'], \PDO::PARAM_INT)
);
}
if ($this->helper->getBackendUser()->workspace > 0) {
if ($row['t3ver_wsid'] > 0) {
$constraints[] = $queryBuilder->expr()->eq(
't3ver_wsid',
$queryBuilder->createNamedParameter((int)$row['t3ver_wsid'], \PDO::PARAM_INT)
);
} else {
$constraints[] = $queryBuilder->expr()->orX(
$queryBuilder->expr()->eq(
't3ver_wsid',
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
),
$queryBuilder->expr()->eq(
't3ver_wsid',
$queryBuilder->createNamedParameter(
$this->helper->getBackendUser()->workspace,
\PDO::PARAM_INT
)
)
);
}
}
$queryBuilder
->select('*')
->from('tt_content')
->where(
...$constraints
)
->orderBy('sorting');
$restrictions = $queryBuilder->getRestrictions();
if ($this->showHidden) {
$restrictions->removeByType(HiddenRestriction::class);
}
$restrictions->removeByType(StartTimeRestriction::class);
$restrictions->removeByType(EndTimeRestriction::class);
$queryBuilder->setRestrictions($restrictions);
return $queryBuilder->execute()->fetchAll();
} | [
"protected",
"function",
"collectItemsForColumns",
"(",
"PageLayoutView",
"$",
"parentObject",
",",
"&",
"$",
"colPosValues",
",",
"&",
"$",
"row",
")",
"{",
"$",
"colPosList",
"=",
"array_keys",
"(",
"$",
"colPosValues",
")",
";",
"$",
"specificIds",
"=",
"$",
"this",
"->",
"helper",
"->",
"getSpecificIds",
"(",
"$",
"row",
")",
";",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
";",
"$",
"constraints",
"=",
"[",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"in",
"(",
"'pid'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"[",
"(",
"int",
")",
"$",
"row",
"[",
"'pid'",
"]",
",",
"$",
"specificIds",
"[",
"'pid'",
"]",
"]",
",",
"Connection",
"::",
"PARAM_INT_ARRAY",
")",
")",
",",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'colPos'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"-",
"1",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
")",
",",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"in",
"(",
"'tx_gridelements_container'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"[",
"(",
"int",
")",
"$",
"row",
"[",
"'uid'",
"]",
",",
"$",
"specificIds",
"[",
"'uid'",
"]",
"]",
",",
"Connection",
"::",
"PARAM_INT_ARRAY",
")",
")",
",",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"in",
"(",
"'tx_gridelements_columns'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"$",
"colPosList",
",",
"Connection",
"::",
"PARAM_INT_ARRAY",
")",
")",
",",
"]",
";",
"if",
"(",
"!",
"$",
"parentObject",
"->",
"tt_contentConfig",
"[",
"'languageMode'",
"]",
")",
"{",
"$",
"constraints",
"[",
"]",
"=",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"orX",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'sys_language_uid'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"-",
"1",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
")",
",",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'sys_language_uid'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"(",
"int",
")",
"$",
"parentObject",
"->",
"tt_contentConfig",
"[",
"'sys_language_uid'",
"]",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"row",
"[",
"'sys_language_uid'",
"]",
">",
"0",
")",
"{",
"$",
"constraints",
"[",
"]",
"=",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'sys_language_uid'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"(",
"int",
")",
"$",
"row",
"[",
"'sys_language_uid'",
"]",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"helper",
"->",
"getBackendUser",
"(",
")",
"->",
"workspace",
">",
"0",
")",
"{",
"if",
"(",
"$",
"row",
"[",
"'t3ver_wsid'",
"]",
">",
"0",
")",
"{",
"$",
"constraints",
"[",
"]",
"=",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'t3ver_wsid'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"(",
"int",
")",
"$",
"row",
"[",
"'t3ver_wsid'",
"]",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
")",
";",
"}",
"else",
"{",
"$",
"constraints",
"[",
"]",
"=",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"orX",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'t3ver_wsid'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"0",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
")",
",",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'t3ver_wsid'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"$",
"this",
"->",
"helper",
"->",
"getBackendUser",
"(",
")",
"->",
"workspace",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
")",
")",
";",
"}",
"}",
"$",
"queryBuilder",
"->",
"select",
"(",
"'*'",
")",
"->",
"from",
"(",
"'tt_content'",
")",
"->",
"where",
"(",
"...",
"$",
"constraints",
")",
"->",
"orderBy",
"(",
"'sorting'",
")",
";",
"$",
"restrictions",
"=",
"$",
"queryBuilder",
"->",
"getRestrictions",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"showHidden",
")",
"{",
"$",
"restrictions",
"->",
"removeByType",
"(",
"HiddenRestriction",
"::",
"class",
")",
";",
"}",
"$",
"restrictions",
"->",
"removeByType",
"(",
"StartTimeRestriction",
"::",
"class",
")",
";",
"$",
"restrictions",
"->",
"removeByType",
"(",
"EndTimeRestriction",
"::",
"class",
")",
";",
"$",
"queryBuilder",
"->",
"setRestrictions",
"(",
"$",
"restrictions",
")",
";",
"return",
"$",
"queryBuilder",
"->",
"execute",
"(",
")",
"->",
"fetchAll",
"(",
")",
";",
"}"
] | Collects tt_content data from a single tt_content element
@param PageLayoutView $parentObject : The paren object that triggered this hook
@param array $colPosValues : The column position to collect the items for
@param array $row : The current data row for the container item
@return mixed collected items for the given column | [
"Collects",
"tt_content",
"data",
"from",
"a",
"single",
"tt_content",
"element"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/DrawItem.php#L443-L527 |
TYPO3-extensions/gridelements | Classes/Hooks/DrawItem.php | DrawItem.renderSingleGridColumn | protected function renderSingleGridColumn(
PageLayoutView $parentObject,
&$items,
&$colPos,
$values,
&$gridContent,
$row,
&$editUidList
) {
$specificIds = $this->helper->getSpecificIds($row);
$allowed = base64_encode(json_encode($values['allowed']));
$disallowed = base64_encode(json_encode($values['disallowed']));
$maxItems = (int)$values['maxitems'];
$url = '';
$pageinfo = BackendUtility::readPageAccess($parentObject->id, '');
if (!empty($this->getPageLayoutController()) && get_class($this->getPageLayoutController()) === PageLayoutController::class) {
$contentIsNotLockedForEditors = $this->getPageLayoutController()->contentIsNotLockedForEditors();
} else {
$contentIsNotLockedForEditors = true;
}
if ($colPos < 32768) {
if ($contentIsNotLockedForEditors
&& $this->getBackendUser()->doesUserHaveAccess($pageinfo, Permission::CONTENT_EDIT)
&& (!$this->checkIfTranslationsExistInLanguage($items, $row['sys_language_uid'], $parentObject))
) {
if ($parentObject->option_newWizard) {
$urlParameters = [
'id' => $parentObject->id,
'sys_language_uid' => $row['sys_language_uid'],
'tx_gridelements_allowed' => $allowed,
'tx_gridelements_disallowed' => $disallowed,
'tx_gridelements_container' => $specificIds['uid'],
'tx_gridelements_columns' => $colPos,
'colPos' => -1,
'uid_pid' => $parentObject->id,
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'),
];
$routeName = BackendUtility::getPagesTSconfig($parentObject->id)['mod.']['newContentElementWizard.']['override']
?? 'new_content_element_wizard';
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$url = (string)$uriBuilder->buildUriFromRoute($routeName, $urlParameters);
} else {
$urlParameters = [
'edit' => [
'tt_content' => [
$parentObject->id => 'new',
],
],
'defVals' => [
'tt_content' => [
'sys_language_uid' => $row['sys_language_uid'],
'tx_gridelements_allowed' => $allowed,
'tx_gridelements_disallowed' => $disallowed,
'tx_gridelements_container' => $specificIds['uid'],
'tx_gridelements_columns' => $colPos,
'colPos' => -1,
],
],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'),
];
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
}
}
}
$iconsArray = [];
if ($colPos !== '' && $colPos !== null && $colPos < 32768 && $url) {
$iconsArray = [
'new' => '<a
href="#"
data-url="' . htmlspecialchars($url) . '"
data-title="' . htmlspecialchars($this->getLanguageService()->getLL('newContentElement')) . '"
title="' . htmlspecialchars($this->getLanguageService()->getLL('newContentElement')) . '"
class="btn btn-default btn-sm t3js-toggle-new-content-element-wizard">' .
$this->iconFactory->getIcon('actions-add', 'small') . ' ' .
$this->languageService->getLL('content') .
'</a>',
];
}
$gridContent[$colPos] .= '<div class="t3-page-ce gridelements-collapsed-column-marker">' .
$this->languageService->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_contentcollapsed') .
'</div>';
$gridContent[$colPos] .= '
<div data-colpos="' . $colPos . '"
data-language-uid="' . $row['sys_language_uid'] . '"
class="t3js-sortable t3js-sortable-lang t3js-sortable-lang-' . $row['sys_language_uid'] . ' t3-page-ce-wrapper ui-sortable">
<div class="t3-page-ce t3js-page-ce"
data-container="' . $row['uid'] . '"
id="' . str_replace('.', '', uniqid('', true)) . '">
<div class="t3js-page-new-ce t3js-page-new-ce-allowed t3-page-ce-wrapper-new-ce btn-group btn-group-sm"
id="colpos-' . $colPos . '-' . str_replace('.', '', uniqid('', true)) . '">' .
implode('', $iconsArray) . '
</div>
<div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div>
</div>';
if (!empty($items)) {
$counter = 0;
foreach ($items as $item) {
if (
$row['sys_language_uid'] === $item['sys_language_uid'] ||
($row['sys_language_uid'] === -1 && $item['sys_language_uid'] === 0)
) {
$counter++;
}
if ((int)$item['t3ver_state'] === VersionState::DELETE_PLACEHOLDER) {
continue;
}
if (is_array($item)) {
$uid = (int)$item['uid'];
$pid = (int)$item['pid'];
$container = (int)$item['tx_gridelements_container'];
$gridColumn = (int)$item['tx_gridelements_columns'];
$language = (int)$item['sys_language_uid'];
$statusHidden = $parentObject->isDisabled('tt_content', $item) ? ' t3-page-ce-hidden' : '';
$maxItemsReached = $counter > $maxItems && $maxItems > 0 ? ' t3-page-ce-danger' : '';
$gridContent[$colPos] .= '
<div class="t3-page-ce t3js-page-ce t3js-page-ce-sortable' . $statusHidden . $maxItemsReached . '"
data-table="tt_content" id="element-tt_content-' . $uid . '"
data-uid="' . $uid . '"
data-container="' . $container . '"
data-ctype="' . $item['CType'] . '">' .
$this->renderSingleElementHTML($parentObject, $item) .
'</div>';
if ($contentIsNotLockedForEditors
&& $this->getBackendUser()->doesUserHaveAccess($pageinfo, Permission::CONTENT_EDIT)
&& (!$this->checkIfTranslationsExistInLanguage($items, $row['sys_language_uid'], $parentObject))
) {
// New content element:
$specificIds = $this->helper->getSpecificIds($item);
if ($parentObject->option_newWizard) {
$urlParameters = [
'id' => $parentObject->id,
'sys_language_uid' => $language,
'tx_gridelements_allowed' => $allowed,
'tx_gridelements_disallowed' => $disallowed,
'tx_gridelements_container' => $container,
'tx_gridelements_columns' => $gridColumn,
'colPos' => -1,
'uid_pid' => -$specificIds['uid'],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'),
];
$routeName = BackendUtility::getPagesTSconfig($pid)['mod.']['newContentElementWizard.']['override']
?? 'new_content_element_wizard';
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$url = (string)$uriBuilder->buildUriFromRoute($routeName, $urlParameters);
} else {
$urlParameters = [
'edit' => [
'tt_content' => [
-$specificIds['uid'] => 'new',
],
],
'defVals' => [
'tt_content' => [
'sys_language_uid' => $language,
'tx_gridelements_allowed' => $allowed,
'tx_gridelements_disallowed' => $disallowed,
'tx_gridelements_container' => $container,
'tx_gridelements_columns' => $gridColumn,
'colPos' => -1,
],
],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'),
];
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
}
$iconsArray = [
'new' => '<a
href="#"
data-url="' . htmlspecialchars($url) . '"
data-title="' . htmlspecialchars($this->getLanguageService()->getLL('newContentElement')) . '"
title="' . htmlspecialchars($this->getLanguageService()->getLL('newContentElement')) . '"
class="btn btn-default btn-sm btn t3js-toggle-new-content-element-wizard">' .
$this->iconFactory->getIcon('actions-add', 'small') . ' ' .
$this->languageService->getLL('content') .
'</a>',
];
}
$gridContent[$colPos] .= '
<div class="t3-page-ce">
<div class="t3js-page-new-ce t3js-page-new-ce-allowed t3-page-ce-wrapper-new-ce btn-group btn-group-sm"
id="colpos-' . $gridColumn .
'-page-' . $pid .
'-gridcontainer-' . $container .
'-' . str_replace('.', '', uniqid('', true)) . '">' .
implode('', $iconsArray) . '
</div>
</div>
<div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div>
</div>
';
$editUidList[$colPos] .= $editUidList[$colPos] ? ',' . $uid : $uid;
}
}
}
$gridContent[$colPos] .= '</div>';
} | php | protected function renderSingleGridColumn(
PageLayoutView $parentObject,
&$items,
&$colPos,
$values,
&$gridContent,
$row,
&$editUidList
) {
$specificIds = $this->helper->getSpecificIds($row);
$allowed = base64_encode(json_encode($values['allowed']));
$disallowed = base64_encode(json_encode($values['disallowed']));
$maxItems = (int)$values['maxitems'];
$url = '';
$pageinfo = BackendUtility::readPageAccess($parentObject->id, '');
if (!empty($this->getPageLayoutController()) && get_class($this->getPageLayoutController()) === PageLayoutController::class) {
$contentIsNotLockedForEditors = $this->getPageLayoutController()->contentIsNotLockedForEditors();
} else {
$contentIsNotLockedForEditors = true;
}
if ($colPos < 32768) {
if ($contentIsNotLockedForEditors
&& $this->getBackendUser()->doesUserHaveAccess($pageinfo, Permission::CONTENT_EDIT)
&& (!$this->checkIfTranslationsExistInLanguage($items, $row['sys_language_uid'], $parentObject))
) {
if ($parentObject->option_newWizard) {
$urlParameters = [
'id' => $parentObject->id,
'sys_language_uid' => $row['sys_language_uid'],
'tx_gridelements_allowed' => $allowed,
'tx_gridelements_disallowed' => $disallowed,
'tx_gridelements_container' => $specificIds['uid'],
'tx_gridelements_columns' => $colPos,
'colPos' => -1,
'uid_pid' => $parentObject->id,
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'),
];
$routeName = BackendUtility::getPagesTSconfig($parentObject->id)['mod.']['newContentElementWizard.']['override']
?? 'new_content_element_wizard';
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$url = (string)$uriBuilder->buildUriFromRoute($routeName, $urlParameters);
} else {
$urlParameters = [
'edit' => [
'tt_content' => [
$parentObject->id => 'new',
],
],
'defVals' => [
'tt_content' => [
'sys_language_uid' => $row['sys_language_uid'],
'tx_gridelements_allowed' => $allowed,
'tx_gridelements_disallowed' => $disallowed,
'tx_gridelements_container' => $specificIds['uid'],
'tx_gridelements_columns' => $colPos,
'colPos' => -1,
],
],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'),
];
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
}
}
}
$iconsArray = [];
if ($colPos !== '' && $colPos !== null && $colPos < 32768 && $url) {
$iconsArray = [
'new' => '<a
href="#"
data-url="' . htmlspecialchars($url) . '"
data-title="' . htmlspecialchars($this->getLanguageService()->getLL('newContentElement')) . '"
title="' . htmlspecialchars($this->getLanguageService()->getLL('newContentElement')) . '"
class="btn btn-default btn-sm t3js-toggle-new-content-element-wizard">' .
$this->iconFactory->getIcon('actions-add', 'small') . ' ' .
$this->languageService->getLL('content') .
'</a>',
];
}
$gridContent[$colPos] .= '<div class="t3-page-ce gridelements-collapsed-column-marker">' .
$this->languageService->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_contentcollapsed') .
'</div>';
$gridContent[$colPos] .= '
<div data-colpos="' . $colPos . '"
data-language-uid="' . $row['sys_language_uid'] . '"
class="t3js-sortable t3js-sortable-lang t3js-sortable-lang-' . $row['sys_language_uid'] . ' t3-page-ce-wrapper ui-sortable">
<div class="t3-page-ce t3js-page-ce"
data-container="' . $row['uid'] . '"
id="' . str_replace('.', '', uniqid('', true)) . '">
<div class="t3js-page-new-ce t3js-page-new-ce-allowed t3-page-ce-wrapper-new-ce btn-group btn-group-sm"
id="colpos-' . $colPos . '-' . str_replace('.', '', uniqid('', true)) . '">' .
implode('', $iconsArray) . '
</div>
<div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div>
</div>';
if (!empty($items)) {
$counter = 0;
foreach ($items as $item) {
if (
$row['sys_language_uid'] === $item['sys_language_uid'] ||
($row['sys_language_uid'] === -1 && $item['sys_language_uid'] === 0)
) {
$counter++;
}
if ((int)$item['t3ver_state'] === VersionState::DELETE_PLACEHOLDER) {
continue;
}
if (is_array($item)) {
$uid = (int)$item['uid'];
$pid = (int)$item['pid'];
$container = (int)$item['tx_gridelements_container'];
$gridColumn = (int)$item['tx_gridelements_columns'];
$language = (int)$item['sys_language_uid'];
$statusHidden = $parentObject->isDisabled('tt_content', $item) ? ' t3-page-ce-hidden' : '';
$maxItemsReached = $counter > $maxItems && $maxItems > 0 ? ' t3-page-ce-danger' : '';
$gridContent[$colPos] .= '
<div class="t3-page-ce t3js-page-ce t3js-page-ce-sortable' . $statusHidden . $maxItemsReached . '"
data-table="tt_content" id="element-tt_content-' . $uid . '"
data-uid="' . $uid . '"
data-container="' . $container . '"
data-ctype="' . $item['CType'] . '">' .
$this->renderSingleElementHTML($parentObject, $item) .
'</div>';
if ($contentIsNotLockedForEditors
&& $this->getBackendUser()->doesUserHaveAccess($pageinfo, Permission::CONTENT_EDIT)
&& (!$this->checkIfTranslationsExistInLanguage($items, $row['sys_language_uid'], $parentObject))
) {
// New content element:
$specificIds = $this->helper->getSpecificIds($item);
if ($parentObject->option_newWizard) {
$urlParameters = [
'id' => $parentObject->id,
'sys_language_uid' => $language,
'tx_gridelements_allowed' => $allowed,
'tx_gridelements_disallowed' => $disallowed,
'tx_gridelements_container' => $container,
'tx_gridelements_columns' => $gridColumn,
'colPos' => -1,
'uid_pid' => -$specificIds['uid'],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'),
];
$routeName = BackendUtility::getPagesTSconfig($pid)['mod.']['newContentElementWizard.']['override']
?? 'new_content_element_wizard';
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$url = (string)$uriBuilder->buildUriFromRoute($routeName, $urlParameters);
} else {
$urlParameters = [
'edit' => [
'tt_content' => [
-$specificIds['uid'] => 'new',
],
],
'defVals' => [
'tt_content' => [
'sys_language_uid' => $language,
'tx_gridelements_allowed' => $allowed,
'tx_gridelements_disallowed' => $disallowed,
'tx_gridelements_container' => $container,
'tx_gridelements_columns' => $gridColumn,
'colPos' => -1,
],
],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'),
];
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
}
$iconsArray = [
'new' => '<a
href="#"
data-url="' . htmlspecialchars($url) . '"
data-title="' . htmlspecialchars($this->getLanguageService()->getLL('newContentElement')) . '"
title="' . htmlspecialchars($this->getLanguageService()->getLL('newContentElement')) . '"
class="btn btn-default btn-sm btn t3js-toggle-new-content-element-wizard">' .
$this->iconFactory->getIcon('actions-add', 'small') . ' ' .
$this->languageService->getLL('content') .
'</a>',
];
}
$gridContent[$colPos] .= '
<div class="t3-page-ce">
<div class="t3js-page-new-ce t3js-page-new-ce-allowed t3-page-ce-wrapper-new-ce btn-group btn-group-sm"
id="colpos-' . $gridColumn .
'-page-' . $pid .
'-gridcontainer-' . $container .
'-' . str_replace('.', '', uniqid('', true)) . '">' .
implode('', $iconsArray) . '
</div>
</div>
<div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div>
</div>
';
$editUidList[$colPos] .= $editUidList[$colPos] ? ',' . $uid : $uid;
}
}
}
$gridContent[$colPos] .= '</div>';
} | [
"protected",
"function",
"renderSingleGridColumn",
"(",
"PageLayoutView",
"$",
"parentObject",
",",
"&",
"$",
"items",
",",
"&",
"$",
"colPos",
",",
"$",
"values",
",",
"&",
"$",
"gridContent",
",",
"$",
"row",
",",
"&",
"$",
"editUidList",
")",
"{",
"$",
"specificIds",
"=",
"$",
"this",
"->",
"helper",
"->",
"getSpecificIds",
"(",
"$",
"row",
")",
";",
"$",
"allowed",
"=",
"base64_encode",
"(",
"json_encode",
"(",
"$",
"values",
"[",
"'allowed'",
"]",
")",
")",
";",
"$",
"disallowed",
"=",
"base64_encode",
"(",
"json_encode",
"(",
"$",
"values",
"[",
"'disallowed'",
"]",
")",
")",
";",
"$",
"maxItems",
"=",
"(",
"int",
")",
"$",
"values",
"[",
"'maxitems'",
"]",
";",
"$",
"url",
"=",
"''",
";",
"$",
"pageinfo",
"=",
"BackendUtility",
"::",
"readPageAccess",
"(",
"$",
"parentObject",
"->",
"id",
",",
"''",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"getPageLayoutController",
"(",
")",
")",
"&&",
"get_class",
"(",
"$",
"this",
"->",
"getPageLayoutController",
"(",
")",
")",
"===",
"PageLayoutController",
"::",
"class",
")",
"{",
"$",
"contentIsNotLockedForEditors",
"=",
"$",
"this",
"->",
"getPageLayoutController",
"(",
")",
"->",
"contentIsNotLockedForEditors",
"(",
")",
";",
"}",
"else",
"{",
"$",
"contentIsNotLockedForEditors",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"colPos",
"<",
"32768",
")",
"{",
"if",
"(",
"$",
"contentIsNotLockedForEditors",
"&&",
"$",
"this",
"->",
"getBackendUser",
"(",
")",
"->",
"doesUserHaveAccess",
"(",
"$",
"pageinfo",
",",
"Permission",
"::",
"CONTENT_EDIT",
")",
"&&",
"(",
"!",
"$",
"this",
"->",
"checkIfTranslationsExistInLanguage",
"(",
"$",
"items",
",",
"$",
"row",
"[",
"'sys_language_uid'",
"]",
",",
"$",
"parentObject",
")",
")",
")",
"{",
"if",
"(",
"$",
"parentObject",
"->",
"option_newWizard",
")",
"{",
"$",
"urlParameters",
"=",
"[",
"'id'",
"=>",
"$",
"parentObject",
"->",
"id",
",",
"'sys_language_uid'",
"=>",
"$",
"row",
"[",
"'sys_language_uid'",
"]",
",",
"'tx_gridelements_allowed'",
"=>",
"$",
"allowed",
",",
"'tx_gridelements_disallowed'",
"=>",
"$",
"disallowed",
",",
"'tx_gridelements_container'",
"=>",
"$",
"specificIds",
"[",
"'uid'",
"]",
",",
"'tx_gridelements_columns'",
"=>",
"$",
"colPos",
",",
"'colPos'",
"=>",
"-",
"1",
",",
"'uid_pid'",
"=>",
"$",
"parentObject",
"->",
"id",
",",
"'returnUrl'",
"=>",
"GeneralUtility",
"::",
"getIndpEnv",
"(",
"'REQUEST_URI'",
")",
",",
"]",
";",
"$",
"routeName",
"=",
"BackendUtility",
"::",
"getPagesTSconfig",
"(",
"$",
"parentObject",
"->",
"id",
")",
"[",
"'mod.'",
"]",
"[",
"'newContentElementWizard.'",
"]",
"[",
"'override'",
"]",
"??",
"'new_content_element_wizard'",
";",
"$",
"uriBuilder",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"UriBuilder",
"::",
"class",
")",
";",
"$",
"url",
"=",
"(",
"string",
")",
"$",
"uriBuilder",
"->",
"buildUriFromRoute",
"(",
"$",
"routeName",
",",
"$",
"urlParameters",
")",
";",
"}",
"else",
"{",
"$",
"urlParameters",
"=",
"[",
"'edit'",
"=>",
"[",
"'tt_content'",
"=>",
"[",
"$",
"parentObject",
"->",
"id",
"=>",
"'new'",
",",
"]",
",",
"]",
",",
"'defVals'",
"=>",
"[",
"'tt_content'",
"=>",
"[",
"'sys_language_uid'",
"=>",
"$",
"row",
"[",
"'sys_language_uid'",
"]",
",",
"'tx_gridelements_allowed'",
"=>",
"$",
"allowed",
",",
"'tx_gridelements_disallowed'",
"=>",
"$",
"disallowed",
",",
"'tx_gridelements_container'",
"=>",
"$",
"specificIds",
"[",
"'uid'",
"]",
",",
"'tx_gridelements_columns'",
"=>",
"$",
"colPos",
",",
"'colPos'",
"=>",
"-",
"1",
",",
"]",
",",
"]",
",",
"'returnUrl'",
"=>",
"GeneralUtility",
"::",
"getIndpEnv",
"(",
"'REQUEST_URI'",
")",
",",
"]",
";",
"$",
"uriBuilder",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"UriBuilder",
"::",
"class",
")",
";",
"$",
"url",
"=",
"(",
"string",
")",
"$",
"uriBuilder",
"->",
"buildUriFromRoute",
"(",
"'record_edit'",
",",
"$",
"urlParameters",
")",
";",
"}",
"}",
"}",
"$",
"iconsArray",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"colPos",
"!==",
"''",
"&&",
"$",
"colPos",
"!==",
"null",
"&&",
"$",
"colPos",
"<",
"32768",
"&&",
"$",
"url",
")",
"{",
"$",
"iconsArray",
"=",
"[",
"'new'",
"=>",
"'<a \n href=\"#\" \n data-url=\"'",
".",
"htmlspecialchars",
"(",
"$",
"url",
")",
".",
"'\" \n data-title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"'newContentElement'",
")",
")",
".",
"'\" \n title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"'newContentElement'",
")",
")",
".",
"'\" \n class=\"btn btn-default btn-sm t3js-toggle-new-content-element-wizard\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-add'",
",",
"'small'",
")",
".",
"' '",
".",
"$",
"this",
"->",
"languageService",
"->",
"getLL",
"(",
"'content'",
")",
".",
"'</a>'",
",",
"]",
";",
"}",
"$",
"gridContent",
"[",
"$",
"colPos",
"]",
".=",
"'<div class=\"t3-page-ce gridelements-collapsed-column-marker\">'",
".",
"$",
"this",
"->",
"languageService",
"->",
"sL",
"(",
"'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_contentcollapsed'",
")",
".",
"'</div>'",
";",
"$",
"gridContent",
"[",
"$",
"colPos",
"]",
".=",
"'\n\t\t\t<div data-colpos=\"'",
".",
"$",
"colPos",
".",
"'\" \n\t\t\t data-language-uid=\"'",
".",
"$",
"row",
"[",
"'sys_language_uid'",
"]",
".",
"'\" \n\t\t\t class=\"t3js-sortable t3js-sortable-lang t3js-sortable-lang-'",
".",
"$",
"row",
"[",
"'sys_language_uid'",
"]",
".",
"' t3-page-ce-wrapper ui-sortable\">\n\t\t\t <div class=\"t3-page-ce t3js-page-ce\" \n\t\t\t data-container=\"'",
".",
"$",
"row",
"[",
"'uid'",
"]",
".",
"'\" \n\t\t\t id=\"'",
".",
"str_replace",
"(",
"'.'",
",",
"''",
",",
"uniqid",
"(",
"''",
",",
"true",
")",
")",
".",
"'\">\n\t\t\t\t\t<div class=\"t3js-page-new-ce t3js-page-new-ce-allowed t3-page-ce-wrapper-new-ce btn-group btn-group-sm\" \n\t\t\t\t\t id=\"colpos-'",
".",
"$",
"colPos",
".",
"'-'",
".",
"str_replace",
"(",
"'.'",
",",
"''",
",",
"uniqid",
"(",
"''",
",",
"true",
")",
")",
".",
"'\">'",
".",
"implode",
"(",
"''",
",",
"$",
"iconsArray",
")",
".",
"'\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"t3-page-ce-dropzone-available t3js-page-ce-dropzone-available\"></div>\n\t\t\t\t</div>'",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"items",
")",
")",
"{",
"$",
"counter",
"=",
"0",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"row",
"[",
"'sys_language_uid'",
"]",
"===",
"$",
"item",
"[",
"'sys_language_uid'",
"]",
"||",
"(",
"$",
"row",
"[",
"'sys_language_uid'",
"]",
"===",
"-",
"1",
"&&",
"$",
"item",
"[",
"'sys_language_uid'",
"]",
"===",
"0",
")",
")",
"{",
"$",
"counter",
"++",
";",
"}",
"if",
"(",
"(",
"int",
")",
"$",
"item",
"[",
"'t3ver_state'",
"]",
"===",
"VersionState",
"::",
"DELETE_PLACEHOLDER",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"item",
")",
")",
"{",
"$",
"uid",
"=",
"(",
"int",
")",
"$",
"item",
"[",
"'uid'",
"]",
";",
"$",
"pid",
"=",
"(",
"int",
")",
"$",
"item",
"[",
"'pid'",
"]",
";",
"$",
"container",
"=",
"(",
"int",
")",
"$",
"item",
"[",
"'tx_gridelements_container'",
"]",
";",
"$",
"gridColumn",
"=",
"(",
"int",
")",
"$",
"item",
"[",
"'tx_gridelements_columns'",
"]",
";",
"$",
"language",
"=",
"(",
"int",
")",
"$",
"item",
"[",
"'sys_language_uid'",
"]",
";",
"$",
"statusHidden",
"=",
"$",
"parentObject",
"->",
"isDisabled",
"(",
"'tt_content'",
",",
"$",
"item",
")",
"?",
"' t3-page-ce-hidden'",
":",
"''",
";",
"$",
"maxItemsReached",
"=",
"$",
"counter",
">",
"$",
"maxItems",
"&&",
"$",
"maxItems",
">",
"0",
"?",
"' t3-page-ce-danger'",
":",
"''",
";",
"$",
"gridContent",
"[",
"$",
"colPos",
"]",
".=",
"'\n\t\t\t\t<div class=\"t3-page-ce t3js-page-ce t3js-page-ce-sortable'",
".",
"$",
"statusHidden",
".",
"$",
"maxItemsReached",
".",
"'\" \n\t\t\t\t data-table=\"tt_content\" id=\"element-tt_content-'",
".",
"$",
"uid",
".",
"'\" \n\t\t\t\t data-uid=\"'",
".",
"$",
"uid",
".",
"'\" \n\t\t\t\t data-container=\"'",
".",
"$",
"container",
".",
"'\" \n\t\t\t\t data-ctype=\"'",
".",
"$",
"item",
"[",
"'CType'",
"]",
".",
"'\">'",
".",
"$",
"this",
"->",
"renderSingleElementHTML",
"(",
"$",
"parentObject",
",",
"$",
"item",
")",
".",
"'</div>'",
";",
"if",
"(",
"$",
"contentIsNotLockedForEditors",
"&&",
"$",
"this",
"->",
"getBackendUser",
"(",
")",
"->",
"doesUserHaveAccess",
"(",
"$",
"pageinfo",
",",
"Permission",
"::",
"CONTENT_EDIT",
")",
"&&",
"(",
"!",
"$",
"this",
"->",
"checkIfTranslationsExistInLanguage",
"(",
"$",
"items",
",",
"$",
"row",
"[",
"'sys_language_uid'",
"]",
",",
"$",
"parentObject",
")",
")",
")",
"{",
"// New content element:",
"$",
"specificIds",
"=",
"$",
"this",
"->",
"helper",
"->",
"getSpecificIds",
"(",
"$",
"item",
")",
";",
"if",
"(",
"$",
"parentObject",
"->",
"option_newWizard",
")",
"{",
"$",
"urlParameters",
"=",
"[",
"'id'",
"=>",
"$",
"parentObject",
"->",
"id",
",",
"'sys_language_uid'",
"=>",
"$",
"language",
",",
"'tx_gridelements_allowed'",
"=>",
"$",
"allowed",
",",
"'tx_gridelements_disallowed'",
"=>",
"$",
"disallowed",
",",
"'tx_gridelements_container'",
"=>",
"$",
"container",
",",
"'tx_gridelements_columns'",
"=>",
"$",
"gridColumn",
",",
"'colPos'",
"=>",
"-",
"1",
",",
"'uid_pid'",
"=>",
"-",
"$",
"specificIds",
"[",
"'uid'",
"]",
",",
"'returnUrl'",
"=>",
"GeneralUtility",
"::",
"getIndpEnv",
"(",
"'REQUEST_URI'",
")",
",",
"]",
";",
"$",
"routeName",
"=",
"BackendUtility",
"::",
"getPagesTSconfig",
"(",
"$",
"pid",
")",
"[",
"'mod.'",
"]",
"[",
"'newContentElementWizard.'",
"]",
"[",
"'override'",
"]",
"??",
"'new_content_element_wizard'",
";",
"$",
"uriBuilder",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"UriBuilder",
"::",
"class",
")",
";",
"$",
"url",
"=",
"(",
"string",
")",
"$",
"uriBuilder",
"->",
"buildUriFromRoute",
"(",
"$",
"routeName",
",",
"$",
"urlParameters",
")",
";",
"}",
"else",
"{",
"$",
"urlParameters",
"=",
"[",
"'edit'",
"=>",
"[",
"'tt_content'",
"=>",
"[",
"-",
"$",
"specificIds",
"[",
"'uid'",
"]",
"=>",
"'new'",
",",
"]",
",",
"]",
",",
"'defVals'",
"=>",
"[",
"'tt_content'",
"=>",
"[",
"'sys_language_uid'",
"=>",
"$",
"language",
",",
"'tx_gridelements_allowed'",
"=>",
"$",
"allowed",
",",
"'tx_gridelements_disallowed'",
"=>",
"$",
"disallowed",
",",
"'tx_gridelements_container'",
"=>",
"$",
"container",
",",
"'tx_gridelements_columns'",
"=>",
"$",
"gridColumn",
",",
"'colPos'",
"=>",
"-",
"1",
",",
"]",
",",
"]",
",",
"'returnUrl'",
"=>",
"GeneralUtility",
"::",
"getIndpEnv",
"(",
"'REQUEST_URI'",
")",
",",
"]",
";",
"$",
"uriBuilder",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"UriBuilder",
"::",
"class",
")",
";",
"$",
"url",
"=",
"(",
"string",
")",
"$",
"uriBuilder",
"->",
"buildUriFromRoute",
"(",
"'record_edit'",
",",
"$",
"urlParameters",
")",
";",
"}",
"$",
"iconsArray",
"=",
"[",
"'new'",
"=>",
"'<a \n href=\"#\"\n data-url=\"'",
".",
"htmlspecialchars",
"(",
"$",
"url",
")",
".",
"'\" \n data-title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"'newContentElement'",
")",
")",
".",
"'\" \n title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"'newContentElement'",
")",
")",
".",
"'\" \n class=\"btn btn-default btn-sm btn t3js-toggle-new-content-element-wizard\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-add'",
",",
"'small'",
")",
".",
"' '",
".",
"$",
"this",
"->",
"languageService",
"->",
"getLL",
"(",
"'content'",
")",
".",
"'</a>'",
",",
"]",
";",
"}",
"$",
"gridContent",
"[",
"$",
"colPos",
"]",
".=",
"'\n <div class=\"t3-page-ce\">\n <div class=\"t3js-page-new-ce t3js-page-new-ce-allowed t3-page-ce-wrapper-new-ce btn-group btn-group-sm\" \n id=\"colpos-'",
".",
"$",
"gridColumn",
".",
"'-page-'",
".",
"$",
"pid",
".",
"'-gridcontainer-'",
".",
"$",
"container",
".",
"'-'",
".",
"str_replace",
"(",
"'.'",
",",
"''",
",",
"uniqid",
"(",
"''",
",",
"true",
")",
")",
".",
"'\">'",
".",
"implode",
"(",
"''",
",",
"$",
"iconsArray",
")",
".",
"'\n </div>\n </div>\n <div class=\"t3-page-ce-dropzone-available t3js-page-ce-dropzone-available\"></div>\n </div>\n\t\t\t\t\t'",
";",
"$",
"editUidList",
"[",
"$",
"colPos",
"]",
".=",
"$",
"editUidList",
"[",
"$",
"colPos",
"]",
"?",
"','",
".",
"$",
"uid",
":",
"$",
"uid",
";",
"}",
"}",
"}",
"$",
"gridContent",
"[",
"$",
"colPos",
"]",
".=",
"'</div>'",
";",
"}"
] | renders a single column of a grid layout and sets the edit uid list
@param PageLayoutView $parentObject : The parent object that triggered this hook
@param array $items : The content data of the column to be rendered
@param int $colPos : The column position we want to get the content for
@param array $values : The layout configuration values for the grid column
@param array $gridContent : The rendered content data of the grid column
@param $row
@param array $editUidList : determines if we will get edit icons or not | [
"renders",
"a",
"single",
"column",
"of",
"a",
"grid",
"layout",
"and",
"sets",
"the",
"edit",
"uid",
"list"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/DrawItem.php#L555-L760 |
TYPO3-extensions/gridelements | Classes/Hooks/DrawItem.php | DrawItem.checkIfTranslationsExistInLanguage | protected function checkIfTranslationsExistInLanguage(
array $contentElements,
$language,
PageLayoutView $parentObject
) {
// If in default language, you may always create new entries
// Also, you may override this strict behavior via user TS Config
// If you do so, you're on your own and cannot rely on any support by the TYPO3 core
// We jump out here since we don't need to do the expensive loop operations
$allowInconsistentLanguageHandling = BackendUtility::getPagesTSconfig($parentObject->id)['mod.']['web_layout.']['allowInconsistentLanguageHandling'] ?? [];
if ($language === 0 || $language === -1 || $allowInconsistentLanguageHandling['value'] === '1') {
return false;
}
/**
* Build up caches
*/
if (!isset($this->languageHasTranslationsCache[$language])) {
foreach ($contentElements as $contentElement) {
if ((int)$contentElement['l18n_parent'] === 0) {
$this->languageHasTranslationsCache[$language]['hasStandAloneContent'] = true;
}
if ((int)$contentElement['l18n_parent'] > 0) {
$this->languageHasTranslationsCache[$language]['hasTranslations'] = true;
}
}
// Check whether we have a mix of both
if ($this->languageHasTranslationsCache[$language]['hasStandAloneContent']
&& $this->languageHasTranslationsCache[$language]['hasTranslations']
) {
/** @var $message FlashMessage */
$message = GeneralUtility::makeInstance(
FlashMessage::class,
sprintf(
$this->getLanguageService()->getLL('staleTranslationWarning'),
$parentObject->languageIconTitles[$language]['title']
),
sprintf(
$this->getLanguageService()->getLL('staleTranslationWarningTitle'),
$parentObject->languageIconTitles[$language]['title']
),
FlashMessage::WARNING
);
$service = GeneralUtility::makeInstance(FlashMessageService::class);
/** @var $queue FlashMessageQueue */
$queue = $service->getMessageQueueByIdentifier();
$queue->enqueue($message);
}
}
if ($this->languageHasTranslationsCache[$language]['hasTranslations']) {
return true;
}
return false;
} | php | protected function checkIfTranslationsExistInLanguage(
array $contentElements,
$language,
PageLayoutView $parentObject
) {
// If in default language, you may always create new entries
// Also, you may override this strict behavior via user TS Config
// If you do so, you're on your own and cannot rely on any support by the TYPO3 core
// We jump out here since we don't need to do the expensive loop operations
$allowInconsistentLanguageHandling = BackendUtility::getPagesTSconfig($parentObject->id)['mod.']['web_layout.']['allowInconsistentLanguageHandling'] ?? [];
if ($language === 0 || $language === -1 || $allowInconsistentLanguageHandling['value'] === '1') {
return false;
}
/**
* Build up caches
*/
if (!isset($this->languageHasTranslationsCache[$language])) {
foreach ($contentElements as $contentElement) {
if ((int)$contentElement['l18n_parent'] === 0) {
$this->languageHasTranslationsCache[$language]['hasStandAloneContent'] = true;
}
if ((int)$contentElement['l18n_parent'] > 0) {
$this->languageHasTranslationsCache[$language]['hasTranslations'] = true;
}
}
// Check whether we have a mix of both
if ($this->languageHasTranslationsCache[$language]['hasStandAloneContent']
&& $this->languageHasTranslationsCache[$language]['hasTranslations']
) {
/** @var $message FlashMessage */
$message = GeneralUtility::makeInstance(
FlashMessage::class,
sprintf(
$this->getLanguageService()->getLL('staleTranslationWarning'),
$parentObject->languageIconTitles[$language]['title']
),
sprintf(
$this->getLanguageService()->getLL('staleTranslationWarningTitle'),
$parentObject->languageIconTitles[$language]['title']
),
FlashMessage::WARNING
);
$service = GeneralUtility::makeInstance(FlashMessageService::class);
/** @var $queue FlashMessageQueue */
$queue = $service->getMessageQueueByIdentifier();
$queue->enqueue($message);
}
}
if ($this->languageHasTranslationsCache[$language]['hasTranslations']) {
return true;
}
return false;
} | [
"protected",
"function",
"checkIfTranslationsExistInLanguage",
"(",
"array",
"$",
"contentElements",
",",
"$",
"language",
",",
"PageLayoutView",
"$",
"parentObject",
")",
"{",
"// If in default language, you may always create new entries",
"// Also, you may override this strict behavior via user TS Config",
"// If you do so, you're on your own and cannot rely on any support by the TYPO3 core",
"// We jump out here since we don't need to do the expensive loop operations",
"$",
"allowInconsistentLanguageHandling",
"=",
"BackendUtility",
"::",
"getPagesTSconfig",
"(",
"$",
"parentObject",
"->",
"id",
")",
"[",
"'mod.'",
"]",
"[",
"'web_layout.'",
"]",
"[",
"'allowInconsistentLanguageHandling'",
"]",
"??",
"[",
"]",
";",
"if",
"(",
"$",
"language",
"===",
"0",
"||",
"$",
"language",
"===",
"-",
"1",
"||",
"$",
"allowInconsistentLanguageHandling",
"[",
"'value'",
"]",
"===",
"'1'",
")",
"{",
"return",
"false",
";",
"}",
"/**\n * Build up caches\n */",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"languageHasTranslationsCache",
"[",
"$",
"language",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"contentElements",
"as",
"$",
"contentElement",
")",
"{",
"if",
"(",
"(",
"int",
")",
"$",
"contentElement",
"[",
"'l18n_parent'",
"]",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"languageHasTranslationsCache",
"[",
"$",
"language",
"]",
"[",
"'hasStandAloneContent'",
"]",
"=",
"true",
";",
"}",
"if",
"(",
"(",
"int",
")",
"$",
"contentElement",
"[",
"'l18n_parent'",
"]",
">",
"0",
")",
"{",
"$",
"this",
"->",
"languageHasTranslationsCache",
"[",
"$",
"language",
"]",
"[",
"'hasTranslations'",
"]",
"=",
"true",
";",
"}",
"}",
"// Check whether we have a mix of both",
"if",
"(",
"$",
"this",
"->",
"languageHasTranslationsCache",
"[",
"$",
"language",
"]",
"[",
"'hasStandAloneContent'",
"]",
"&&",
"$",
"this",
"->",
"languageHasTranslationsCache",
"[",
"$",
"language",
"]",
"[",
"'hasTranslations'",
"]",
")",
"{",
"/** @var $message FlashMessage */",
"$",
"message",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"FlashMessage",
"::",
"class",
",",
"sprintf",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"'staleTranslationWarning'",
")",
",",
"$",
"parentObject",
"->",
"languageIconTitles",
"[",
"$",
"language",
"]",
"[",
"'title'",
"]",
")",
",",
"sprintf",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"'staleTranslationWarningTitle'",
")",
",",
"$",
"parentObject",
"->",
"languageIconTitles",
"[",
"$",
"language",
"]",
"[",
"'title'",
"]",
")",
",",
"FlashMessage",
"::",
"WARNING",
")",
";",
"$",
"service",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"FlashMessageService",
"::",
"class",
")",
";",
"/** @var $queue FlashMessageQueue */",
"$",
"queue",
"=",
"$",
"service",
"->",
"getMessageQueueByIdentifier",
"(",
")",
";",
"$",
"queue",
"->",
"enqueue",
"(",
"$",
"message",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"languageHasTranslationsCache",
"[",
"$",
"language",
"]",
"[",
"'hasTranslations'",
"]",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Checks whether translated Content Elements exist in the desired language
If so, deny creating new ones via the UI
@param array $contentElements
@param int $language
@param PageLayoutView $parentObject
@return bool
@throws \TYPO3\CMS\Core\Exception | [
"Checks",
"whether",
"translated",
"Content",
"Elements",
"exist",
"in",
"the",
"desired",
"language",
"If",
"so",
"deny",
"creating",
"new",
"ones",
"via",
"the",
"UI"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/DrawItem.php#L781-L833 |
TYPO3-extensions/gridelements | Classes/Hooks/DrawItem.php | DrawItem.renderSingleElementHTML | protected function renderSingleElementHTML(PageLayoutView $parentObject, $item)
{
$singleElementHTML = '';
$unset = false;
if (!isset($parentObject->tt_contentData['nextThree'][$item['uid']])) {
$unset = true;
$parentObject->tt_contentData['nextThree'][$item['uid']] = $item['uid'];
}
if (!$parentObject->tt_contentConfig['languageMode']) {
$singleElementHTML .= '<div class="t3-page-ce-dragitem" id="' . StringUtility::getUniqueId() . '">';
}
$singleElementHTML .= $parentObject->tt_content_drawHeader(
$item,
$parentObject->tt_contentConfig['showInfo'] ? 15 : 5,
$parentObject->defLangBinding,
true,
true
);
$singleElementHTML .= (!empty($item['_ORIG_uid']) ? '<div class="ver-element">' : '')
. '<div class="t3-page-ce-body-inner t3-page-ce-body-inner-' . $item['CType'] . '">'
. $parentObject->tt_content_drawItem($item)
. '</div>'
. (!empty($item['_ORIG_uid']) ? '</div>' : '');
$singleElementHTML .= $this->tt_content_drawFooter($parentObject, $item);
if (!$parentObject->tt_contentConfig['languageMode']) {
$singleElementHTML .= '</div>';
}
if ($unset) {
unset($parentObject->tt_contentData['nextThree'][$item['uid']]);
}
return $singleElementHTML;
} | php | protected function renderSingleElementHTML(PageLayoutView $parentObject, $item)
{
$singleElementHTML = '';
$unset = false;
if (!isset($parentObject->tt_contentData['nextThree'][$item['uid']])) {
$unset = true;
$parentObject->tt_contentData['nextThree'][$item['uid']] = $item['uid'];
}
if (!$parentObject->tt_contentConfig['languageMode']) {
$singleElementHTML .= '<div class="t3-page-ce-dragitem" id="' . StringUtility::getUniqueId() . '">';
}
$singleElementHTML .= $parentObject->tt_content_drawHeader(
$item,
$parentObject->tt_contentConfig['showInfo'] ? 15 : 5,
$parentObject->defLangBinding,
true,
true
);
$singleElementHTML .= (!empty($item['_ORIG_uid']) ? '<div class="ver-element">' : '')
. '<div class="t3-page-ce-body-inner t3-page-ce-body-inner-' . $item['CType'] . '">'
. $parentObject->tt_content_drawItem($item)
. '</div>'
. (!empty($item['_ORIG_uid']) ? '</div>' : '');
$singleElementHTML .= $this->tt_content_drawFooter($parentObject, $item);
if (!$parentObject->tt_contentConfig['languageMode']) {
$singleElementHTML .= '</div>';
}
if ($unset) {
unset($parentObject->tt_contentData['nextThree'][$item['uid']]);
}
return $singleElementHTML;
} | [
"protected",
"function",
"renderSingleElementHTML",
"(",
"PageLayoutView",
"$",
"parentObject",
",",
"$",
"item",
")",
"{",
"$",
"singleElementHTML",
"=",
"''",
";",
"$",
"unset",
"=",
"false",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"parentObject",
"->",
"tt_contentData",
"[",
"'nextThree'",
"]",
"[",
"$",
"item",
"[",
"'uid'",
"]",
"]",
")",
")",
"{",
"$",
"unset",
"=",
"true",
";",
"$",
"parentObject",
"->",
"tt_contentData",
"[",
"'nextThree'",
"]",
"[",
"$",
"item",
"[",
"'uid'",
"]",
"]",
"=",
"$",
"item",
"[",
"'uid'",
"]",
";",
"}",
"if",
"(",
"!",
"$",
"parentObject",
"->",
"tt_contentConfig",
"[",
"'languageMode'",
"]",
")",
"{",
"$",
"singleElementHTML",
".=",
"'<div class=\"t3-page-ce-dragitem\" id=\"'",
".",
"StringUtility",
"::",
"getUniqueId",
"(",
")",
".",
"'\">'",
";",
"}",
"$",
"singleElementHTML",
".=",
"$",
"parentObject",
"->",
"tt_content_drawHeader",
"(",
"$",
"item",
",",
"$",
"parentObject",
"->",
"tt_contentConfig",
"[",
"'showInfo'",
"]",
"?",
"15",
":",
"5",
",",
"$",
"parentObject",
"->",
"defLangBinding",
",",
"true",
",",
"true",
")",
";",
"$",
"singleElementHTML",
".=",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"'_ORIG_uid'",
"]",
")",
"?",
"'<div class=\"ver-element\">'",
":",
"''",
")",
".",
"'<div class=\"t3-page-ce-body-inner t3-page-ce-body-inner-'",
".",
"$",
"item",
"[",
"'CType'",
"]",
".",
"'\">'",
".",
"$",
"parentObject",
"->",
"tt_content_drawItem",
"(",
"$",
"item",
")",
".",
"'</div>'",
".",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"'_ORIG_uid'",
"]",
")",
"?",
"'</div>'",
":",
"''",
")",
";",
"$",
"singleElementHTML",
".=",
"$",
"this",
"->",
"tt_content_drawFooter",
"(",
"$",
"parentObject",
",",
"$",
"item",
")",
";",
"if",
"(",
"!",
"$",
"parentObject",
"->",
"tt_contentConfig",
"[",
"'languageMode'",
"]",
")",
"{",
"$",
"singleElementHTML",
".=",
"'</div>'",
";",
"}",
"if",
"(",
"$",
"unset",
")",
"{",
"unset",
"(",
"$",
"parentObject",
"->",
"tt_contentData",
"[",
"'nextThree'",
"]",
"[",
"$",
"item",
"[",
"'uid'",
"]",
"]",
")",
";",
"}",
"return",
"$",
"singleElementHTML",
";",
"}"
] | Renders the HTML code for a single tt_content element
@param PageLayoutView $parentObject : The parent object that triggered this hook
@param array $item : The data row to be rendered as HTML
@return string | [
"Renders",
"the",
"HTML",
"code",
"for",
"a",
"single",
"tt_content",
"element"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/DrawItem.php#L865-L897 |
TYPO3-extensions/gridelements | Classes/Hooks/DrawItem.php | DrawItem.tt_content_drawFooter | protected function tt_content_drawFooter(PageLayoutView $parentObject, array $row)
{
$content = '';
// Get processed values:
$info = [];
$parentObject->getProcessedValue('tt_content', 'starttime,endtime,fe_group,space_before_class,space_after_class', $row, $info);
// Content element annotation
if (!empty($GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn']) && !empty($row[$GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn']])) {
$info[] = htmlspecialchars($row[$GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn']]);
}
// Call drawFooter hooks
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawFooter'] ?? [] as $className) {
$hookObject = GeneralUtility::makeInstance($className);
if (!$hookObject instanceof PageLayoutViewDrawFooterHookInterface) {
throw new \UnexpectedValueException($className . ' must implement interface ' . PageLayoutViewDrawFooterHookInterface::class, 1404378171);
}
$hookObject->preProcess($parentObject, $info, $row);
}
// Display info from records fields:
if (!empty($info)) {
$content = '<div class="t3-page-ce-info">
' . implode('<br>', $info) . '
</div>';
}
// Wrap it
if (!empty($content)) {
$content = '<div class="t3-page-ce-footer">' . $content . '</div>';
}
return $content;
} | php | protected function tt_content_drawFooter(PageLayoutView $parentObject, array $row)
{
$content = '';
// Get processed values:
$info = [];
$parentObject->getProcessedValue('tt_content', 'starttime,endtime,fe_group,space_before_class,space_after_class', $row, $info);
// Content element annotation
if (!empty($GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn']) && !empty($row[$GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn']])) {
$info[] = htmlspecialchars($row[$GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn']]);
}
// Call drawFooter hooks
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawFooter'] ?? [] as $className) {
$hookObject = GeneralUtility::makeInstance($className);
if (!$hookObject instanceof PageLayoutViewDrawFooterHookInterface) {
throw new \UnexpectedValueException($className . ' must implement interface ' . PageLayoutViewDrawFooterHookInterface::class, 1404378171);
}
$hookObject->preProcess($parentObject, $info, $row);
}
// Display info from records fields:
if (!empty($info)) {
$content = '<div class="t3-page-ce-info">
' . implode('<br>', $info) . '
</div>';
}
// Wrap it
if (!empty($content)) {
$content = '<div class="t3-page-ce-footer">' . $content . '</div>';
}
return $content;
} | [
"protected",
"function",
"tt_content_drawFooter",
"(",
"PageLayoutView",
"$",
"parentObject",
",",
"array",
"$",
"row",
")",
"{",
"$",
"content",
"=",
"''",
";",
"// Get processed values:",
"$",
"info",
"=",
"[",
"]",
";",
"$",
"parentObject",
"->",
"getProcessedValue",
"(",
"'tt_content'",
",",
"'starttime,endtime,fe_group,space_before_class,space_after_class'",
",",
"$",
"row",
",",
"$",
"info",
")",
";",
"// Content element annotation",
"if",
"(",
"!",
"empty",
"(",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"'tt_content'",
"]",
"[",
"'ctrl'",
"]",
"[",
"'descriptionColumn'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"row",
"[",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"'tt_content'",
"]",
"[",
"'ctrl'",
"]",
"[",
"'descriptionColumn'",
"]",
"]",
")",
")",
"{",
"$",
"info",
"[",
"]",
"=",
"htmlspecialchars",
"(",
"$",
"row",
"[",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"'tt_content'",
"]",
"[",
"'ctrl'",
"]",
"[",
"'descriptionColumn'",
"]",
"]",
")",
";",
"}",
"// Call drawFooter hooks",
"foreach",
"(",
"$",
"GLOBALS",
"[",
"'TYPO3_CONF_VARS'",
"]",
"[",
"'SC_OPTIONS'",
"]",
"[",
"'cms/layout/class.tx_cms_layout.php'",
"]",
"[",
"'tt_content_drawFooter'",
"]",
"??",
"[",
"]",
"as",
"$",
"className",
")",
"{",
"$",
"hookObject",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"$",
"className",
")",
";",
"if",
"(",
"!",
"$",
"hookObject",
"instanceof",
"PageLayoutViewDrawFooterHookInterface",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"$",
"className",
".",
"' must implement interface '",
".",
"PageLayoutViewDrawFooterHookInterface",
"::",
"class",
",",
"1404378171",
")",
";",
"}",
"$",
"hookObject",
"->",
"preProcess",
"(",
"$",
"parentObject",
",",
"$",
"info",
",",
"$",
"row",
")",
";",
"}",
"// Display info from records fields:",
"if",
"(",
"!",
"empty",
"(",
"$",
"info",
")",
")",
"{",
"$",
"content",
"=",
"'<div class=\"t3-page-ce-info\">\n\t\t\t\t'",
".",
"implode",
"(",
"'<br>'",
",",
"$",
"info",
")",
".",
"'\n\t\t\t\t</div>'",
";",
"}",
"// Wrap it",
"if",
"(",
"!",
"empty",
"(",
"$",
"content",
")",
")",
"{",
"$",
"content",
"=",
"'<div class=\"t3-page-ce-footer\">'",
".",
"$",
"content",
".",
"'</div>'",
";",
"}",
"return",
"$",
"content",
";",
"}"
] | Draw the footer for a single tt_content element
@param PageLayoutView $parentObject : The parent object that triggered this hook
@param array $row Record array
@return string HTML of the footer
@throws \UnexpectedValueException | [
"Draw",
"the",
"footer",
"for",
"a",
"single",
"tt_content",
"element"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/DrawItem.php#L907-L939 |
TYPO3-extensions/gridelements | Classes/Hooks/DrawItem.php | DrawItem.setColumnHeader | protected function setColumnHeader(
PageLayoutView $parentObject,
&$head,
&$colPos,
&$name,
&$editUidList,
$expanded = true
) {
$head[$colPos] = $this->tt_content_drawColHeader(
$name,
($parentObject->doEdit && $editUidList[$colPos]) ? '&edit[tt_content][' . $editUidList[$colPos] . ']=edit' : '',
$parentObject,
$expanded
);
} | php | protected function setColumnHeader(
PageLayoutView $parentObject,
&$head,
&$colPos,
&$name,
&$editUidList,
$expanded = true
) {
$head[$colPos] = $this->tt_content_drawColHeader(
$name,
($parentObject->doEdit && $editUidList[$colPos]) ? '&edit[tt_content][' . $editUidList[$colPos] . ']=edit' : '',
$parentObject,
$expanded
);
} | [
"protected",
"function",
"setColumnHeader",
"(",
"PageLayoutView",
"$",
"parentObject",
",",
"&",
"$",
"head",
",",
"&",
"$",
"colPos",
",",
"&",
"$",
"name",
",",
"&",
"$",
"editUidList",
",",
"$",
"expanded",
"=",
"true",
")",
"{",
"$",
"head",
"[",
"$",
"colPos",
"]",
"=",
"$",
"this",
"->",
"tt_content_drawColHeader",
"(",
"$",
"name",
",",
"(",
"$",
"parentObject",
"->",
"doEdit",
"&&",
"$",
"editUidList",
"[",
"$",
"colPos",
"]",
")",
"?",
"'&edit[tt_content]['",
".",
"$",
"editUidList",
"[",
"$",
"colPos",
"]",
".",
"']=edit'",
":",
"''",
",",
"$",
"parentObject",
",",
"$",
"expanded",
")",
";",
"}"
] | Sets the headers for a grid before content and headers are put together
@param PageLayoutView $parentObject : The parent object that triggered this hook
@param array $head : The collected item data rows
@param int $colPos : The column position we want to get a header for
@param string $name : The name of the header
@param array $editUidList : determines if we will get edit icons or not
@param bool $expanded
@internal param array $row : The current data row for the container item | [
"Sets",
"the",
"headers",
"for",
"a",
"grid",
"before",
"content",
"and",
"headers",
"are",
"put",
"together"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/DrawItem.php#L953-L967 |
TYPO3-extensions/gridelements | Classes/Hooks/DrawItem.php | DrawItem.tt_content_drawColHeader | protected function tt_content_drawColHeader($colName, $editParams, PageLayoutView $parentObject, $expanded = true)
{
$iconsArr = [];
// Create command links:
if ($parentObject->tt_contentConfig['showCommands']) {
// Edit whole of column:
if ($editParams) {
$iconsArr['edit'] = '<a
class="btn btn-default"
href="#"
onclick="' . htmlspecialchars(BackendUtility::editOnClick($editParams)) . '"
title="' . $this->getLanguageService()->getLL('editColumn') . '">' .
$this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() .
'</a>';
}
}
if ($expanded) {
$state = 'expanded';
$title = $this->languageService->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_collapsecontent');
$toggleTitle = $this->languageService->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_expandcontent');
} else {
$state = 'collapsed';
$title = $this->languageService->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_expandcontent');
$toggleTitle = $this->languageService->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_collapsecontent');
}
$iconsArr['toggleContent'] = '<a href="#" class="btn btn-default t3js-toggle-gridelements-column toggle-content" title="' . $title . '" data-toggle-title="' . $toggleTitle . '" data-state="' . $state . '">' . $this->iconFactory->getIcon(
'actions-view-list-collapse',
'small'
) . $this->iconFactory->getIcon(
'actions-view-list-expand',
'small'
) . '</a>';
$icons = '<div class="t3-page-column-header-icons btn-group btn-group-sm">' . implode(
'',
$iconsArr
) . '</div>';
// Create header row:
$out = '<div class="t3-page-column-header">
' . $icons . '
<div class="t3-page-column-header-label">' . htmlspecialchars($colName) . '</div>
</div>';
return $out;
} | php | protected function tt_content_drawColHeader($colName, $editParams, PageLayoutView $parentObject, $expanded = true)
{
$iconsArr = [];
// Create command links:
if ($parentObject->tt_contentConfig['showCommands']) {
// Edit whole of column:
if ($editParams) {
$iconsArr['edit'] = '<a
class="btn btn-default"
href="#"
onclick="' . htmlspecialchars(BackendUtility::editOnClick($editParams)) . '"
title="' . $this->getLanguageService()->getLL('editColumn') . '">' .
$this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() .
'</a>';
}
}
if ($expanded) {
$state = 'expanded';
$title = $this->languageService->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_collapsecontent');
$toggleTitle = $this->languageService->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_expandcontent');
} else {
$state = 'collapsed';
$title = $this->languageService->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_expandcontent');
$toggleTitle = $this->languageService->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_collapsecontent');
}
$iconsArr['toggleContent'] = '<a href="#" class="btn btn-default t3js-toggle-gridelements-column toggle-content" title="' . $title . '" data-toggle-title="' . $toggleTitle . '" data-state="' . $state . '">' . $this->iconFactory->getIcon(
'actions-view-list-collapse',
'small'
) . $this->iconFactory->getIcon(
'actions-view-list-expand',
'small'
) . '</a>';
$icons = '<div class="t3-page-column-header-icons btn-group btn-group-sm">' . implode(
'',
$iconsArr
) . '</div>';
// Create header row:
$out = '<div class="t3-page-column-header">
' . $icons . '
<div class="t3-page-column-header-label">' . htmlspecialchars($colName) . '</div>
</div>';
return $out;
} | [
"protected",
"function",
"tt_content_drawColHeader",
"(",
"$",
"colName",
",",
"$",
"editParams",
",",
"PageLayoutView",
"$",
"parentObject",
",",
"$",
"expanded",
"=",
"true",
")",
"{",
"$",
"iconsArr",
"=",
"[",
"]",
";",
"// Create command links:",
"if",
"(",
"$",
"parentObject",
"->",
"tt_contentConfig",
"[",
"'showCommands'",
"]",
")",
"{",
"// Edit whole of column:",
"if",
"(",
"$",
"editParams",
")",
"{",
"$",
"iconsArr",
"[",
"'edit'",
"]",
"=",
"'<a \n class=\"btn btn-default\" \n href=\"#\" \n onclick=\"'",
".",
"htmlspecialchars",
"(",
"BackendUtility",
"::",
"editOnClick",
"(",
"$",
"editParams",
")",
")",
".",
"'\" \n title=\"'",
".",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"'editColumn'",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-document-open'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"}",
"}",
"if",
"(",
"$",
"expanded",
")",
"{",
"$",
"state",
"=",
"'expanded'",
";",
"$",
"title",
"=",
"$",
"this",
"->",
"languageService",
"->",
"sL",
"(",
"'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_collapsecontent'",
")",
";",
"$",
"toggleTitle",
"=",
"$",
"this",
"->",
"languageService",
"->",
"sL",
"(",
"'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_expandcontent'",
")",
";",
"}",
"else",
"{",
"$",
"state",
"=",
"'collapsed'",
";",
"$",
"title",
"=",
"$",
"this",
"->",
"languageService",
"->",
"sL",
"(",
"'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_expandcontent'",
")",
";",
"$",
"toggleTitle",
"=",
"$",
"this",
"->",
"languageService",
"->",
"sL",
"(",
"'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_collapsecontent'",
")",
";",
"}",
"$",
"iconsArr",
"[",
"'toggleContent'",
"]",
"=",
"'<a href=\"#\" class=\"btn btn-default t3js-toggle-gridelements-column toggle-content\" title=\"'",
".",
"$",
"title",
".",
"'\" data-toggle-title=\"'",
".",
"$",
"toggleTitle",
".",
"'\" data-state=\"'",
".",
"$",
"state",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-view-list-collapse'",
",",
"'small'",
")",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-view-list-expand'",
",",
"'small'",
")",
".",
"'</a>'",
";",
"$",
"icons",
"=",
"'<div class=\"t3-page-column-header-icons btn-group btn-group-sm\">'",
".",
"implode",
"(",
"''",
",",
"$",
"iconsArr",
")",
".",
"'</div>'",
";",
"// Create header row:",
"$",
"out",
"=",
"'<div class=\"t3-page-column-header\">\n\t\t\t\t\t'",
".",
"$",
"icons",
".",
"'\n\t\t\t\t\t<div class=\"t3-page-column-header-label\">'",
".",
"htmlspecialchars",
"(",
"$",
"colName",
")",
".",
"'</div>\n\t\t\t\t</div>'",
";",
"return",
"$",
"out",
";",
"}"
] | Draw header for a content element column:
@param string $colName Column name
@param string $editParams Edit params (Syntax: &edit[...] for FormEngine)
@param \TYPO3\CMS\Backend\View\PageLayoutView $parentObject
@param bool $expanded
@return string HTML table | [
"Draw",
"header",
"for",
"a",
"content",
"element",
"column",
":"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/DrawItem.php#L979-L1024 |
TYPO3-extensions/gridelements | Classes/Hooks/DrawItem.php | DrawItem.renderGridLayoutTable | protected function renderGridLayoutTable($layout, $row, $head, $gridContent, PageLayoutView $parentObject)
{
$specificIds = $this->helper->getSpecificIds($row);
$grid = '<div class="t3-grid-container t3-grid-element-container' . ($layout['frame'] ? ' t3-grid-container-framed t3-grid-container-' . htmlspecialchars($layout['frame']) : '') . ($layout['top_level_layout'] ? ' t3-grid-tl-container' : '') . '">';
if ($layout['frame'] || (int)$this->helper->getBackendUser()->uc['showGridInformation'] === 1) {
$grid .= '<h4 class="t3-grid-container-title-' . ($layout['frame'] ? htmlspecialchars($layout['frame']) : '0') . '">' .
BackendUtility::wrapInHelp(
'tx_gridelements_backend_layouts',
'title',
$this->languageService->sL($layout['title']),
[
'title' => $this->languageService->sL($layout['title']),
'description' => $this->languageService->sL($layout['description']),
]
) . '</h4>';
}
$grid .= '<table border="0" cellspacing="0" cellpadding="0" width="100%" class="t3-page-columns t3-grid-table">';
// add colgroups
$colCount = 0;
$rowCount = 0;
if (isset($layout['config'])) {
if (isset($layout['config']['colCount'])) {
$colCount = (int)$layout['config']['colCount'];
}
if (isset($layout['config']['rowCount'])) {
$rowCount = (int)$layout['config']['rowCount'];
}
}
$grid .= '<colgroup>';
for ($i = 0; $i < $colCount; $i++) {
$grid .= '<col style="width:' . (100 / $colCount) . '%" />';
}
$grid .= '</colgroup>';
// cycle through rows
for ($layoutRow = 1; $layoutRow <= $rowCount; $layoutRow++) {
$rowConfig = $layout['config']['rows.'][$layoutRow . '.'];
if (!isset($rowConfig) || !isset($rowConfig['columns.'])) {
continue;
}
$grid .= '<tr>';
foreach ($rowConfig['columns.'] as $column => $columnConfig) {
if (!isset($columnConfig)) {
continue;
}
// which column should be displayed inside this cell
$columnKey = isset($columnConfig['colPos']) && $columnConfig['colPos'] !== '' ? (int)$columnConfig['colPos'] : 32768;
// first get disallowed CTypes
$disallowedContentTypes = $layout['disallowed'][$columnKey]['CType'];
if (!isset($disallowedContentTypes['*']) && !empty($disallowedContentTypes)) {
foreach ($disallowedContentTypes as $key => &$ctype) {
$ctype = $key;
}
} else {
if (isset($disallowedContentTypes['*'])) {
$disallowedGridTypes['*'] = '*';
} else {
$disallowedContentTypes = [];
}
}
// when everything is disallowed, no further checks are necessary
if (!isset($disallowedContentTypes['*'])) {
$allowedContentTypes = $layout['allowed'][$columnKey]['CType'];
if (!isset($allowedContentTypes['*']) && !empty($allowedContentTypes)) {
// set allowed CTypes unless they are disallowed
foreach ($allowedContentTypes as $key => &$ctype) {
if (isset($disallowedContentTypes[$key])) {
unset($allowedContentTypes[$key]);
unset($disallowedContentTypes[$key]);
} else {
$ctype = $key;
}
}
} else {
$allowedContentTypes = [];
}
// get disallowed list types
$disallowedListTypes = $layout['disallowed'][$columnKey]['list_type'];
if (!isset($disallowedListTypes['*']) && !empty($disallowedListTypes)) {
foreach ($disallowedListTypes as $key => &$ctype) {
$ctype = $key;
}
} else {
if (isset($disallowedListTypes['*'])) {
// when each list type is disallowed, no CType list is necessary anymore
$disallowedListTypes['*'] = '*';
unset($allowedContentTypes['list']);
} else {
$disallowedListTypes = [];
}
}
// when each list type is disallowed, no further list type checks are necessary
if (!isset($disallowedListTypes['*'])) {
$allowedListTypes = $layout['allowed'][$columnKey]['list_type'];
if (!isset($allowedListTypes['*']) && !empty($allowedListTypes)) {
foreach ($allowedListTypes as $listType => &$listTypeData) {
// set allowed list types unless they are disallowed
if (isset($disallowedListTypes[$listType])) {
unset($allowedListTypes[$listType]);
unset($disallowedListTypes[$listType]);
} else {
$listTypeData = $listType;
}
}
} else {
if (!empty($allowedContentTypes) && !empty($allowedListTypes)) {
$allowedContentTypes['list'] = 'list';
}
unset($allowedListTypes);
}
} else {
$allowedListTypes = [];
}
// get disallowed grid types
$disallowedGridTypes = $layout['disallowed'][$columnKey]['tx_gridelements_backend_layout'];
if (!isset($disallowedGridTypes['*']) && !empty($disallowedGridTypes)) {
foreach ($disallowedGridTypes as $key => &$ctype) {
$ctype = $key;
}
} else {
if (isset($disallowedGridTypes['*'])) {
// when each list type is disallowed, no CType gridelements_pi1 is necessary anymore
$disallowedGridTypes['*'] = '*';
unset($allowedContentTypes['gridelements_pi1']);
} else {
$disallowedGridTypes = [];
}
}
// when each list type is disallowed, no further grid types checks are necessary
if (!isset($disallowedGridTypes['*'])) {
$allowedGridTypes = $layout['allowed'][$columnKey]['tx_gridelements_backend_layout'];
if (!isset($allowedGridTypes['*']) && !empty($allowedGridTypes)) {
foreach ($allowedGridTypes as $gridType => &$gridTypeData) {
// set allowed grid types unless they are disallowed
if (isset($disallowedGridTypes[$gridType])) {
unset($allowedGridTypes[$gridType]);
unset($disallowedGridTypes[$gridType]);
} else {
$gridTypeData = $gridType;
}
}
} else {
if (!empty($allowedContentTypes) && !empty($allowedGridTypes)) {
$allowedContentTypes['gridelements_pi1'] = 'gridelements_pi1';
}
unset($allowedGridTypes);
}
} else {
$allowedGridTypes = [];
}
} else {
$allowedContentTypes = [];
}
// render the grid cell
$colSpan = (int)$columnConfig['colspan'];
$rowSpan = (int)$columnConfig['rowspan'];
$maxItems = (int)$columnConfig['maxitems'];
$disableNewContent = $gridContent['numberOfItems'][$columnKey] >= $maxItems && $maxItems > 0;
$tooManyItems = $gridContent['numberOfItems'][$columnKey] > $maxItems && $maxItems > 0;
$expanded = $this->helper->getBackendUser()->uc['moduleData']['page']['gridelementsCollapsedColumns'][$row['uid'] . '_' . $columnKey] ? 'collapsed' : 'expanded';
if (!empty($columnConfig['name']) && $columnKey === 32768) {
$columnHead = $this->tt_content_drawColHeader(
htmlspecialchars($columnConfig['name']) . ' (' . $this->languageService->getLL('notAssigned') . ')',
'',
$parentObject
);
} else {
$columnHead = $head[$columnKey];
}
$grid .= '<td valign="top"' .
(isset($columnConfig['colspan']) ? ' colspan="' . $colSpan . '"' : '') .
(isset($columnConfig['rowspan']) ? ' rowspan="' . $rowSpan . '"' : '') .
'data-colpos="' . $columnKey . '" data-columnkey="' . $specificIds['uid'] . '_' . $columnKey . '"
class="t3-grid-cell t3js-page-column t3-page-column t3-page-column-' . $columnKey .
(!isset($columnConfig['colPos']) || $columnConfig['colPos'] === '' ? ' t3-grid-cell-unassigned' : '') .
(isset($columnConfig['colspan']) && $columnConfig['colPos'] !== '' ? ' t3-grid-cell-width' . $colSpan : '') .
(isset($columnConfig['rowspan']) && $columnConfig['colPos'] !== '' ? ' t3-grid-cell-height' . $rowSpan : '') .
($disableNewContent ? ' t3-page-ce-disable-new-ce' : '') .
($layout['horizontal'] ? ' t3-grid-cell-horizontal' : '') . ' ' . $expanded . '"' .
' data-allowed-ctype="' . (!empty($allowedContentTypes) ? implode(
',',
$allowedContentTypes
) : '*') . '"' .
(!empty($disallowedContentTypes) ? ' data-disallowed-ctype="' . implode(
',',
$disallowedContentTypes
) . '"' : '') .
(!empty($allowedListTypes) ? ' data-allowed-list_type="' . implode(
',',
$allowedListTypes
) . '"' : '') .
(!empty($disallowedListTypes) ? ' data-disallowed-list_type="' . implode(
',',
$disallowedListTypes
) . '"' : '') .
(!empty($allowedGridTypes) ? ' data-allowed-tx_gridelements_backend_layout="' . implode(
',',
$allowedGridTypes
) . '"' : '') .
(!empty($disallowedGridTypes) ? ' data-disallowed-tx_gridelements_backend_layout="' . implode(
',',
$disallowedGridTypes
) . '"' : '') .
(!empty($maxItems) ? ' data-maxitems="' . $maxItems . '"' : '') .
' data-state="' . $expanded . '">';
$grid .= ($this->helper->getBackendUser()->uc['hideColumnHeaders'] ? '' : $columnHead);
if ($maxItems > 0) {
$maxItemsClass = ($disableNewContent ? ' warning' : ' success');
$maxItemsClass = ($tooManyItems ? ' danger' : $maxItemsClass);
$grid .= '<span class="t3-grid-cell-number-of-items' . $maxItemsClass . '">' .
$gridContent['numberOfItems'][$columnKey] . '/' . $maxItems . ($maxItemsClass === ' danger' ? '!' : '') .
'</span>';
}
$grid .= $gridContent[$columnKey];
$grid .= '</td>';
}
$grid .= '</tr>';
}
$grid .= '</table></div>';
return $grid;
} | php | protected function renderGridLayoutTable($layout, $row, $head, $gridContent, PageLayoutView $parentObject)
{
$specificIds = $this->helper->getSpecificIds($row);
$grid = '<div class="t3-grid-container t3-grid-element-container' . ($layout['frame'] ? ' t3-grid-container-framed t3-grid-container-' . htmlspecialchars($layout['frame']) : '') . ($layout['top_level_layout'] ? ' t3-grid-tl-container' : '') . '">';
if ($layout['frame'] || (int)$this->helper->getBackendUser()->uc['showGridInformation'] === 1) {
$grid .= '<h4 class="t3-grid-container-title-' . ($layout['frame'] ? htmlspecialchars($layout['frame']) : '0') . '">' .
BackendUtility::wrapInHelp(
'tx_gridelements_backend_layouts',
'title',
$this->languageService->sL($layout['title']),
[
'title' => $this->languageService->sL($layout['title']),
'description' => $this->languageService->sL($layout['description']),
]
) . '</h4>';
}
$grid .= '<table border="0" cellspacing="0" cellpadding="0" width="100%" class="t3-page-columns t3-grid-table">';
// add colgroups
$colCount = 0;
$rowCount = 0;
if (isset($layout['config'])) {
if (isset($layout['config']['colCount'])) {
$colCount = (int)$layout['config']['colCount'];
}
if (isset($layout['config']['rowCount'])) {
$rowCount = (int)$layout['config']['rowCount'];
}
}
$grid .= '<colgroup>';
for ($i = 0; $i < $colCount; $i++) {
$grid .= '<col style="width:' . (100 / $colCount) . '%" />';
}
$grid .= '</colgroup>';
// cycle through rows
for ($layoutRow = 1; $layoutRow <= $rowCount; $layoutRow++) {
$rowConfig = $layout['config']['rows.'][$layoutRow . '.'];
if (!isset($rowConfig) || !isset($rowConfig['columns.'])) {
continue;
}
$grid .= '<tr>';
foreach ($rowConfig['columns.'] as $column => $columnConfig) {
if (!isset($columnConfig)) {
continue;
}
// which column should be displayed inside this cell
$columnKey = isset($columnConfig['colPos']) && $columnConfig['colPos'] !== '' ? (int)$columnConfig['colPos'] : 32768;
// first get disallowed CTypes
$disallowedContentTypes = $layout['disallowed'][$columnKey]['CType'];
if (!isset($disallowedContentTypes['*']) && !empty($disallowedContentTypes)) {
foreach ($disallowedContentTypes as $key => &$ctype) {
$ctype = $key;
}
} else {
if (isset($disallowedContentTypes['*'])) {
$disallowedGridTypes['*'] = '*';
} else {
$disallowedContentTypes = [];
}
}
// when everything is disallowed, no further checks are necessary
if (!isset($disallowedContentTypes['*'])) {
$allowedContentTypes = $layout['allowed'][$columnKey]['CType'];
if (!isset($allowedContentTypes['*']) && !empty($allowedContentTypes)) {
// set allowed CTypes unless they are disallowed
foreach ($allowedContentTypes as $key => &$ctype) {
if (isset($disallowedContentTypes[$key])) {
unset($allowedContentTypes[$key]);
unset($disallowedContentTypes[$key]);
} else {
$ctype = $key;
}
}
} else {
$allowedContentTypes = [];
}
// get disallowed list types
$disallowedListTypes = $layout['disallowed'][$columnKey]['list_type'];
if (!isset($disallowedListTypes['*']) && !empty($disallowedListTypes)) {
foreach ($disallowedListTypes as $key => &$ctype) {
$ctype = $key;
}
} else {
if (isset($disallowedListTypes['*'])) {
// when each list type is disallowed, no CType list is necessary anymore
$disallowedListTypes['*'] = '*';
unset($allowedContentTypes['list']);
} else {
$disallowedListTypes = [];
}
}
// when each list type is disallowed, no further list type checks are necessary
if (!isset($disallowedListTypes['*'])) {
$allowedListTypes = $layout['allowed'][$columnKey]['list_type'];
if (!isset($allowedListTypes['*']) && !empty($allowedListTypes)) {
foreach ($allowedListTypes as $listType => &$listTypeData) {
// set allowed list types unless they are disallowed
if (isset($disallowedListTypes[$listType])) {
unset($allowedListTypes[$listType]);
unset($disallowedListTypes[$listType]);
} else {
$listTypeData = $listType;
}
}
} else {
if (!empty($allowedContentTypes) && !empty($allowedListTypes)) {
$allowedContentTypes['list'] = 'list';
}
unset($allowedListTypes);
}
} else {
$allowedListTypes = [];
}
// get disallowed grid types
$disallowedGridTypes = $layout['disallowed'][$columnKey]['tx_gridelements_backend_layout'];
if (!isset($disallowedGridTypes['*']) && !empty($disallowedGridTypes)) {
foreach ($disallowedGridTypes as $key => &$ctype) {
$ctype = $key;
}
} else {
if (isset($disallowedGridTypes['*'])) {
// when each list type is disallowed, no CType gridelements_pi1 is necessary anymore
$disallowedGridTypes['*'] = '*';
unset($allowedContentTypes['gridelements_pi1']);
} else {
$disallowedGridTypes = [];
}
}
// when each list type is disallowed, no further grid types checks are necessary
if (!isset($disallowedGridTypes['*'])) {
$allowedGridTypes = $layout['allowed'][$columnKey]['tx_gridelements_backend_layout'];
if (!isset($allowedGridTypes['*']) && !empty($allowedGridTypes)) {
foreach ($allowedGridTypes as $gridType => &$gridTypeData) {
// set allowed grid types unless they are disallowed
if (isset($disallowedGridTypes[$gridType])) {
unset($allowedGridTypes[$gridType]);
unset($disallowedGridTypes[$gridType]);
} else {
$gridTypeData = $gridType;
}
}
} else {
if (!empty($allowedContentTypes) && !empty($allowedGridTypes)) {
$allowedContentTypes['gridelements_pi1'] = 'gridelements_pi1';
}
unset($allowedGridTypes);
}
} else {
$allowedGridTypes = [];
}
} else {
$allowedContentTypes = [];
}
// render the grid cell
$colSpan = (int)$columnConfig['colspan'];
$rowSpan = (int)$columnConfig['rowspan'];
$maxItems = (int)$columnConfig['maxitems'];
$disableNewContent = $gridContent['numberOfItems'][$columnKey] >= $maxItems && $maxItems > 0;
$tooManyItems = $gridContent['numberOfItems'][$columnKey] > $maxItems && $maxItems > 0;
$expanded = $this->helper->getBackendUser()->uc['moduleData']['page']['gridelementsCollapsedColumns'][$row['uid'] . '_' . $columnKey] ? 'collapsed' : 'expanded';
if (!empty($columnConfig['name']) && $columnKey === 32768) {
$columnHead = $this->tt_content_drawColHeader(
htmlspecialchars($columnConfig['name']) . ' (' . $this->languageService->getLL('notAssigned') . ')',
'',
$parentObject
);
} else {
$columnHead = $head[$columnKey];
}
$grid .= '<td valign="top"' .
(isset($columnConfig['colspan']) ? ' colspan="' . $colSpan . '"' : '') .
(isset($columnConfig['rowspan']) ? ' rowspan="' . $rowSpan . '"' : '') .
'data-colpos="' . $columnKey . '" data-columnkey="' . $specificIds['uid'] . '_' . $columnKey . '"
class="t3-grid-cell t3js-page-column t3-page-column t3-page-column-' . $columnKey .
(!isset($columnConfig['colPos']) || $columnConfig['colPos'] === '' ? ' t3-grid-cell-unassigned' : '') .
(isset($columnConfig['colspan']) && $columnConfig['colPos'] !== '' ? ' t3-grid-cell-width' . $colSpan : '') .
(isset($columnConfig['rowspan']) && $columnConfig['colPos'] !== '' ? ' t3-grid-cell-height' . $rowSpan : '') .
($disableNewContent ? ' t3-page-ce-disable-new-ce' : '') .
($layout['horizontal'] ? ' t3-grid-cell-horizontal' : '') . ' ' . $expanded . '"' .
' data-allowed-ctype="' . (!empty($allowedContentTypes) ? implode(
',',
$allowedContentTypes
) : '*') . '"' .
(!empty($disallowedContentTypes) ? ' data-disallowed-ctype="' . implode(
',',
$disallowedContentTypes
) . '"' : '') .
(!empty($allowedListTypes) ? ' data-allowed-list_type="' . implode(
',',
$allowedListTypes
) . '"' : '') .
(!empty($disallowedListTypes) ? ' data-disallowed-list_type="' . implode(
',',
$disallowedListTypes
) . '"' : '') .
(!empty($allowedGridTypes) ? ' data-allowed-tx_gridelements_backend_layout="' . implode(
',',
$allowedGridTypes
) . '"' : '') .
(!empty($disallowedGridTypes) ? ' data-disallowed-tx_gridelements_backend_layout="' . implode(
',',
$disallowedGridTypes
) . '"' : '') .
(!empty($maxItems) ? ' data-maxitems="' . $maxItems . '"' : '') .
' data-state="' . $expanded . '">';
$grid .= ($this->helper->getBackendUser()->uc['hideColumnHeaders'] ? '' : $columnHead);
if ($maxItems > 0) {
$maxItemsClass = ($disableNewContent ? ' warning' : ' success');
$maxItemsClass = ($tooManyItems ? ' danger' : $maxItemsClass);
$grid .= '<span class="t3-grid-cell-number-of-items' . $maxItemsClass . '">' .
$gridContent['numberOfItems'][$columnKey] . '/' . $maxItems . ($maxItemsClass === ' danger' ? '!' : '') .
'</span>';
}
$grid .= $gridContent[$columnKey];
$grid .= '</td>';
}
$grid .= '</tr>';
}
$grid .= '</table></div>';
return $grid;
} | [
"protected",
"function",
"renderGridLayoutTable",
"(",
"$",
"layout",
",",
"$",
"row",
",",
"$",
"head",
",",
"$",
"gridContent",
",",
"PageLayoutView",
"$",
"parentObject",
")",
"{",
"$",
"specificIds",
"=",
"$",
"this",
"->",
"helper",
"->",
"getSpecificIds",
"(",
"$",
"row",
")",
";",
"$",
"grid",
"=",
"'<div class=\"t3-grid-container t3-grid-element-container'",
".",
"(",
"$",
"layout",
"[",
"'frame'",
"]",
"?",
"' t3-grid-container-framed t3-grid-container-'",
".",
"htmlspecialchars",
"(",
"$",
"layout",
"[",
"'frame'",
"]",
")",
":",
"''",
")",
".",
"(",
"$",
"layout",
"[",
"'top_level_layout'",
"]",
"?",
"' t3-grid-tl-container'",
":",
"''",
")",
".",
"'\">'",
";",
"if",
"(",
"$",
"layout",
"[",
"'frame'",
"]",
"||",
"(",
"int",
")",
"$",
"this",
"->",
"helper",
"->",
"getBackendUser",
"(",
")",
"->",
"uc",
"[",
"'showGridInformation'",
"]",
"===",
"1",
")",
"{",
"$",
"grid",
".=",
"'<h4 class=\"t3-grid-container-title-'",
".",
"(",
"$",
"layout",
"[",
"'frame'",
"]",
"?",
"htmlspecialchars",
"(",
"$",
"layout",
"[",
"'frame'",
"]",
")",
":",
"'0'",
")",
".",
"'\">'",
".",
"BackendUtility",
"::",
"wrapInHelp",
"(",
"'tx_gridelements_backend_layouts'",
",",
"'title'",
",",
"$",
"this",
"->",
"languageService",
"->",
"sL",
"(",
"$",
"layout",
"[",
"'title'",
"]",
")",
",",
"[",
"'title'",
"=>",
"$",
"this",
"->",
"languageService",
"->",
"sL",
"(",
"$",
"layout",
"[",
"'title'",
"]",
")",
",",
"'description'",
"=>",
"$",
"this",
"->",
"languageService",
"->",
"sL",
"(",
"$",
"layout",
"[",
"'description'",
"]",
")",
",",
"]",
")",
".",
"'</h4>'",
";",
"}",
"$",
"grid",
".=",
"'<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" class=\"t3-page-columns t3-grid-table\">'",
";",
"// add colgroups",
"$",
"colCount",
"=",
"0",
";",
"$",
"rowCount",
"=",
"0",
";",
"if",
"(",
"isset",
"(",
"$",
"layout",
"[",
"'config'",
"]",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"layout",
"[",
"'config'",
"]",
"[",
"'colCount'",
"]",
")",
")",
"{",
"$",
"colCount",
"=",
"(",
"int",
")",
"$",
"layout",
"[",
"'config'",
"]",
"[",
"'colCount'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"layout",
"[",
"'config'",
"]",
"[",
"'rowCount'",
"]",
")",
")",
"{",
"$",
"rowCount",
"=",
"(",
"int",
")",
"$",
"layout",
"[",
"'config'",
"]",
"[",
"'rowCount'",
"]",
";",
"}",
"}",
"$",
"grid",
".=",
"'<colgroup>'",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"colCount",
";",
"$",
"i",
"++",
")",
"{",
"$",
"grid",
".=",
"'<col style=\"width:'",
".",
"(",
"100",
"/",
"$",
"colCount",
")",
".",
"'%\" />'",
";",
"}",
"$",
"grid",
".=",
"'</colgroup>'",
";",
"// cycle through rows",
"for",
"(",
"$",
"layoutRow",
"=",
"1",
";",
"$",
"layoutRow",
"<=",
"$",
"rowCount",
";",
"$",
"layoutRow",
"++",
")",
"{",
"$",
"rowConfig",
"=",
"$",
"layout",
"[",
"'config'",
"]",
"[",
"'rows.'",
"]",
"[",
"$",
"layoutRow",
".",
"'.'",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"rowConfig",
")",
"||",
"!",
"isset",
"(",
"$",
"rowConfig",
"[",
"'columns.'",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"grid",
".=",
"'<tr>'",
";",
"foreach",
"(",
"$",
"rowConfig",
"[",
"'columns.'",
"]",
"as",
"$",
"column",
"=>",
"$",
"columnConfig",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"columnConfig",
")",
")",
"{",
"continue",
";",
"}",
"// which column should be displayed inside this cell",
"$",
"columnKey",
"=",
"isset",
"(",
"$",
"columnConfig",
"[",
"'colPos'",
"]",
")",
"&&",
"$",
"columnConfig",
"[",
"'colPos'",
"]",
"!==",
"''",
"?",
"(",
"int",
")",
"$",
"columnConfig",
"[",
"'colPos'",
"]",
":",
"32768",
";",
"// first get disallowed CTypes",
"$",
"disallowedContentTypes",
"=",
"$",
"layout",
"[",
"'disallowed'",
"]",
"[",
"$",
"columnKey",
"]",
"[",
"'CType'",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"disallowedContentTypes",
"[",
"'*'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"disallowedContentTypes",
")",
")",
"{",
"foreach",
"(",
"$",
"disallowedContentTypes",
"as",
"$",
"key",
"=>",
"&",
"$",
"ctype",
")",
"{",
"$",
"ctype",
"=",
"$",
"key",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"disallowedContentTypes",
"[",
"'*'",
"]",
")",
")",
"{",
"$",
"disallowedGridTypes",
"[",
"'*'",
"]",
"=",
"'*'",
";",
"}",
"else",
"{",
"$",
"disallowedContentTypes",
"=",
"[",
"]",
";",
"}",
"}",
"// when everything is disallowed, no further checks are necessary",
"if",
"(",
"!",
"isset",
"(",
"$",
"disallowedContentTypes",
"[",
"'*'",
"]",
")",
")",
"{",
"$",
"allowedContentTypes",
"=",
"$",
"layout",
"[",
"'allowed'",
"]",
"[",
"$",
"columnKey",
"]",
"[",
"'CType'",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"allowedContentTypes",
"[",
"'*'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"allowedContentTypes",
")",
")",
"{",
"// set allowed CTypes unless they are disallowed",
"foreach",
"(",
"$",
"allowedContentTypes",
"as",
"$",
"key",
"=>",
"&",
"$",
"ctype",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"disallowedContentTypes",
"[",
"$",
"key",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"allowedContentTypes",
"[",
"$",
"key",
"]",
")",
";",
"unset",
"(",
"$",
"disallowedContentTypes",
"[",
"$",
"key",
"]",
")",
";",
"}",
"else",
"{",
"$",
"ctype",
"=",
"$",
"key",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"allowedContentTypes",
"=",
"[",
"]",
";",
"}",
"// get disallowed list types",
"$",
"disallowedListTypes",
"=",
"$",
"layout",
"[",
"'disallowed'",
"]",
"[",
"$",
"columnKey",
"]",
"[",
"'list_type'",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"disallowedListTypes",
"[",
"'*'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"disallowedListTypes",
")",
")",
"{",
"foreach",
"(",
"$",
"disallowedListTypes",
"as",
"$",
"key",
"=>",
"&",
"$",
"ctype",
")",
"{",
"$",
"ctype",
"=",
"$",
"key",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"disallowedListTypes",
"[",
"'*'",
"]",
")",
")",
"{",
"// when each list type is disallowed, no CType list is necessary anymore",
"$",
"disallowedListTypes",
"[",
"'*'",
"]",
"=",
"'*'",
";",
"unset",
"(",
"$",
"allowedContentTypes",
"[",
"'list'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"disallowedListTypes",
"=",
"[",
"]",
";",
"}",
"}",
"// when each list type is disallowed, no further list type checks are necessary",
"if",
"(",
"!",
"isset",
"(",
"$",
"disallowedListTypes",
"[",
"'*'",
"]",
")",
")",
"{",
"$",
"allowedListTypes",
"=",
"$",
"layout",
"[",
"'allowed'",
"]",
"[",
"$",
"columnKey",
"]",
"[",
"'list_type'",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"allowedListTypes",
"[",
"'*'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"allowedListTypes",
")",
")",
"{",
"foreach",
"(",
"$",
"allowedListTypes",
"as",
"$",
"listType",
"=>",
"&",
"$",
"listTypeData",
")",
"{",
"// set allowed list types unless they are disallowed",
"if",
"(",
"isset",
"(",
"$",
"disallowedListTypes",
"[",
"$",
"listType",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"allowedListTypes",
"[",
"$",
"listType",
"]",
")",
";",
"unset",
"(",
"$",
"disallowedListTypes",
"[",
"$",
"listType",
"]",
")",
";",
"}",
"else",
"{",
"$",
"listTypeData",
"=",
"$",
"listType",
";",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"allowedContentTypes",
")",
"&&",
"!",
"empty",
"(",
"$",
"allowedListTypes",
")",
")",
"{",
"$",
"allowedContentTypes",
"[",
"'list'",
"]",
"=",
"'list'",
";",
"}",
"unset",
"(",
"$",
"allowedListTypes",
")",
";",
"}",
"}",
"else",
"{",
"$",
"allowedListTypes",
"=",
"[",
"]",
";",
"}",
"// get disallowed grid types",
"$",
"disallowedGridTypes",
"=",
"$",
"layout",
"[",
"'disallowed'",
"]",
"[",
"$",
"columnKey",
"]",
"[",
"'tx_gridelements_backend_layout'",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"disallowedGridTypes",
"[",
"'*'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"disallowedGridTypes",
")",
")",
"{",
"foreach",
"(",
"$",
"disallowedGridTypes",
"as",
"$",
"key",
"=>",
"&",
"$",
"ctype",
")",
"{",
"$",
"ctype",
"=",
"$",
"key",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"disallowedGridTypes",
"[",
"'*'",
"]",
")",
")",
"{",
"// when each list type is disallowed, no CType gridelements_pi1 is necessary anymore",
"$",
"disallowedGridTypes",
"[",
"'*'",
"]",
"=",
"'*'",
";",
"unset",
"(",
"$",
"allowedContentTypes",
"[",
"'gridelements_pi1'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"disallowedGridTypes",
"=",
"[",
"]",
";",
"}",
"}",
"// when each list type is disallowed, no further grid types checks are necessary",
"if",
"(",
"!",
"isset",
"(",
"$",
"disallowedGridTypes",
"[",
"'*'",
"]",
")",
")",
"{",
"$",
"allowedGridTypes",
"=",
"$",
"layout",
"[",
"'allowed'",
"]",
"[",
"$",
"columnKey",
"]",
"[",
"'tx_gridelements_backend_layout'",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"allowedGridTypes",
"[",
"'*'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"allowedGridTypes",
")",
")",
"{",
"foreach",
"(",
"$",
"allowedGridTypes",
"as",
"$",
"gridType",
"=>",
"&",
"$",
"gridTypeData",
")",
"{",
"// set allowed grid types unless they are disallowed",
"if",
"(",
"isset",
"(",
"$",
"disallowedGridTypes",
"[",
"$",
"gridType",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"allowedGridTypes",
"[",
"$",
"gridType",
"]",
")",
";",
"unset",
"(",
"$",
"disallowedGridTypes",
"[",
"$",
"gridType",
"]",
")",
";",
"}",
"else",
"{",
"$",
"gridTypeData",
"=",
"$",
"gridType",
";",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"allowedContentTypes",
")",
"&&",
"!",
"empty",
"(",
"$",
"allowedGridTypes",
")",
")",
"{",
"$",
"allowedContentTypes",
"[",
"'gridelements_pi1'",
"]",
"=",
"'gridelements_pi1'",
";",
"}",
"unset",
"(",
"$",
"allowedGridTypes",
")",
";",
"}",
"}",
"else",
"{",
"$",
"allowedGridTypes",
"=",
"[",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"allowedContentTypes",
"=",
"[",
"]",
";",
"}",
"// render the grid cell",
"$",
"colSpan",
"=",
"(",
"int",
")",
"$",
"columnConfig",
"[",
"'colspan'",
"]",
";",
"$",
"rowSpan",
"=",
"(",
"int",
")",
"$",
"columnConfig",
"[",
"'rowspan'",
"]",
";",
"$",
"maxItems",
"=",
"(",
"int",
")",
"$",
"columnConfig",
"[",
"'maxitems'",
"]",
";",
"$",
"disableNewContent",
"=",
"$",
"gridContent",
"[",
"'numberOfItems'",
"]",
"[",
"$",
"columnKey",
"]",
">=",
"$",
"maxItems",
"&&",
"$",
"maxItems",
">",
"0",
";",
"$",
"tooManyItems",
"=",
"$",
"gridContent",
"[",
"'numberOfItems'",
"]",
"[",
"$",
"columnKey",
"]",
">",
"$",
"maxItems",
"&&",
"$",
"maxItems",
">",
"0",
";",
"$",
"expanded",
"=",
"$",
"this",
"->",
"helper",
"->",
"getBackendUser",
"(",
")",
"->",
"uc",
"[",
"'moduleData'",
"]",
"[",
"'page'",
"]",
"[",
"'gridelementsCollapsedColumns'",
"]",
"[",
"$",
"row",
"[",
"'uid'",
"]",
".",
"'_'",
".",
"$",
"columnKey",
"]",
"?",
"'collapsed'",
":",
"'expanded'",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"columnConfig",
"[",
"'name'",
"]",
")",
"&&",
"$",
"columnKey",
"===",
"32768",
")",
"{",
"$",
"columnHead",
"=",
"$",
"this",
"->",
"tt_content_drawColHeader",
"(",
"htmlspecialchars",
"(",
"$",
"columnConfig",
"[",
"'name'",
"]",
")",
".",
"' ('",
".",
"$",
"this",
"->",
"languageService",
"->",
"getLL",
"(",
"'notAssigned'",
")",
".",
"')'",
",",
"''",
",",
"$",
"parentObject",
")",
";",
"}",
"else",
"{",
"$",
"columnHead",
"=",
"$",
"head",
"[",
"$",
"columnKey",
"]",
";",
"}",
"$",
"grid",
".=",
"'<td valign=\"top\"'",
".",
"(",
"isset",
"(",
"$",
"columnConfig",
"[",
"'colspan'",
"]",
")",
"?",
"' colspan=\"'",
".",
"$",
"colSpan",
".",
"'\"'",
":",
"''",
")",
".",
"(",
"isset",
"(",
"$",
"columnConfig",
"[",
"'rowspan'",
"]",
")",
"?",
"' rowspan=\"'",
".",
"$",
"rowSpan",
".",
"'\"'",
":",
"''",
")",
".",
"'data-colpos=\"'",
".",
"$",
"columnKey",
".",
"'\" data-columnkey=\"'",
".",
"$",
"specificIds",
"[",
"'uid'",
"]",
".",
"'_'",
".",
"$",
"columnKey",
".",
"'\"\n\t\t\t\t\tclass=\"t3-grid-cell t3js-page-column t3-page-column t3-page-column-'",
".",
"$",
"columnKey",
".",
"(",
"!",
"isset",
"(",
"$",
"columnConfig",
"[",
"'colPos'",
"]",
")",
"||",
"$",
"columnConfig",
"[",
"'colPos'",
"]",
"===",
"''",
"?",
"' t3-grid-cell-unassigned'",
":",
"''",
")",
".",
"(",
"isset",
"(",
"$",
"columnConfig",
"[",
"'colspan'",
"]",
")",
"&&",
"$",
"columnConfig",
"[",
"'colPos'",
"]",
"!==",
"''",
"?",
"' t3-grid-cell-width'",
".",
"$",
"colSpan",
":",
"''",
")",
".",
"(",
"isset",
"(",
"$",
"columnConfig",
"[",
"'rowspan'",
"]",
")",
"&&",
"$",
"columnConfig",
"[",
"'colPos'",
"]",
"!==",
"''",
"?",
"' t3-grid-cell-height'",
".",
"$",
"rowSpan",
":",
"''",
")",
".",
"(",
"$",
"disableNewContent",
"?",
"' t3-page-ce-disable-new-ce'",
":",
"''",
")",
".",
"(",
"$",
"layout",
"[",
"'horizontal'",
"]",
"?",
"' t3-grid-cell-horizontal'",
":",
"''",
")",
".",
"' '",
".",
"$",
"expanded",
".",
"'\"'",
".",
"' data-allowed-ctype=\"'",
".",
"(",
"!",
"empty",
"(",
"$",
"allowedContentTypes",
")",
"?",
"implode",
"(",
"','",
",",
"$",
"allowedContentTypes",
")",
":",
"'*'",
")",
".",
"'\"'",
".",
"(",
"!",
"empty",
"(",
"$",
"disallowedContentTypes",
")",
"?",
"' data-disallowed-ctype=\"'",
".",
"implode",
"(",
"','",
",",
"$",
"disallowedContentTypes",
")",
".",
"'\"'",
":",
"''",
")",
".",
"(",
"!",
"empty",
"(",
"$",
"allowedListTypes",
")",
"?",
"' data-allowed-list_type=\"'",
".",
"implode",
"(",
"','",
",",
"$",
"allowedListTypes",
")",
".",
"'\"'",
":",
"''",
")",
".",
"(",
"!",
"empty",
"(",
"$",
"disallowedListTypes",
")",
"?",
"' data-disallowed-list_type=\"'",
".",
"implode",
"(",
"','",
",",
"$",
"disallowedListTypes",
")",
".",
"'\"'",
":",
"''",
")",
".",
"(",
"!",
"empty",
"(",
"$",
"allowedGridTypes",
")",
"?",
"' data-allowed-tx_gridelements_backend_layout=\"'",
".",
"implode",
"(",
"','",
",",
"$",
"allowedGridTypes",
")",
".",
"'\"'",
":",
"''",
")",
".",
"(",
"!",
"empty",
"(",
"$",
"disallowedGridTypes",
")",
"?",
"' data-disallowed-tx_gridelements_backend_layout=\"'",
".",
"implode",
"(",
"','",
",",
"$",
"disallowedGridTypes",
")",
".",
"'\"'",
":",
"''",
")",
".",
"(",
"!",
"empty",
"(",
"$",
"maxItems",
")",
"?",
"' data-maxitems=\"'",
".",
"$",
"maxItems",
".",
"'\"'",
":",
"''",
")",
".",
"' data-state=\"'",
".",
"$",
"expanded",
".",
"'\">'",
";",
"$",
"grid",
".=",
"(",
"$",
"this",
"->",
"helper",
"->",
"getBackendUser",
"(",
")",
"->",
"uc",
"[",
"'hideColumnHeaders'",
"]",
"?",
"''",
":",
"$",
"columnHead",
")",
";",
"if",
"(",
"$",
"maxItems",
">",
"0",
")",
"{",
"$",
"maxItemsClass",
"=",
"(",
"$",
"disableNewContent",
"?",
"' warning'",
":",
"' success'",
")",
";",
"$",
"maxItemsClass",
"=",
"(",
"$",
"tooManyItems",
"?",
"' danger'",
":",
"$",
"maxItemsClass",
")",
";",
"$",
"grid",
".=",
"'<span class=\"t3-grid-cell-number-of-items'",
".",
"$",
"maxItemsClass",
".",
"'\">'",
".",
"$",
"gridContent",
"[",
"'numberOfItems'",
"]",
"[",
"$",
"columnKey",
"]",
".",
"'/'",
".",
"$",
"maxItems",
".",
"(",
"$",
"maxItemsClass",
"===",
"' danger'",
"?",
"'!'",
":",
"''",
")",
".",
"'</span>'",
";",
"}",
"$",
"grid",
".=",
"$",
"gridContent",
"[",
"$",
"columnKey",
"]",
";",
"$",
"grid",
".=",
"'</td>'",
";",
"}",
"$",
"grid",
".=",
"'</tr>'",
";",
"}",
"$",
"grid",
".=",
"'</table></div>'",
";",
"return",
"$",
"grid",
";",
"}"
] | Renders the grid layout table after the HTML content for the single elements has been rendered
@param array $layout : The setup of the layout that is selected for the grid we are going to render
@param array $row : The current data row for the container item
@param array $head : The data for the column headers of the grid we are going to render
@param array $gridContent : The content data of the grid we are going to render
@param PageLayoutView $parentObject
@return string | [
"Renders",
"the",
"grid",
"layout",
"table",
"after",
"the",
"HTML",
"content",
"for",
"the",
"single",
"elements",
"has",
"been",
"rendered"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/DrawItem.php#L1037-L1257 |
TYPO3-extensions/gridelements | Classes/Hooks/DrawItem.php | DrawItem.renderCTypeShortcut | protected function renderCTypeShortcut(PageLayoutView $parentObject, &$row)
{
$shortcutContent = '';
if ($row['records']) {
$shortcutItems = explode(',', $row['records']);
$collectedItems = [];
foreach ($shortcutItems as $shortcutItem) {
$shortcutItem = trim($shortcutItem);
if (strpos($shortcutItem, 'pages_') !== false) {
$this->collectContentDataFromPages(
$shortcutItem,
$collectedItems,
$row['recursive'],
$row['uid'],
$row['sys_language_uid']
);
} else {
if (strpos($shortcutItem, '_') === false || strpos($shortcutItem, 'tt_content_') !== false) {
$this->collectContentData(
$shortcutItem,
$collectedItems,
$row['uid'],
$row['sys_language_uid']
);
}
}
}
if (!empty($collectedItems)) {
foreach ($collectedItems as $item) {
if ($item) {
$className = $item['tx_gridelements_reference_container'] ? 'reference container_reference' : 'reference';
$shortcutContent .= '<div class="' . $className . '">';
$shortcutContent .= $this->renderSingleElementHTML($parentObject, $item);
// NOTE: this is the end tag for <div class="t3-page-ce-body">
// because of bad (historic) conception, starting tag has to be placed inside tt_content_drawHeader()
$shortcutContent .= '<div class="reference-overlay"></div></div></div>';
}
}
}
}
return $shortcutContent;
} | php | protected function renderCTypeShortcut(PageLayoutView $parentObject, &$row)
{
$shortcutContent = '';
if ($row['records']) {
$shortcutItems = explode(',', $row['records']);
$collectedItems = [];
foreach ($shortcutItems as $shortcutItem) {
$shortcutItem = trim($shortcutItem);
if (strpos($shortcutItem, 'pages_') !== false) {
$this->collectContentDataFromPages(
$shortcutItem,
$collectedItems,
$row['recursive'],
$row['uid'],
$row['sys_language_uid']
);
} else {
if (strpos($shortcutItem, '_') === false || strpos($shortcutItem, 'tt_content_') !== false) {
$this->collectContentData(
$shortcutItem,
$collectedItems,
$row['uid'],
$row['sys_language_uid']
);
}
}
}
if (!empty($collectedItems)) {
foreach ($collectedItems as $item) {
if ($item) {
$className = $item['tx_gridelements_reference_container'] ? 'reference container_reference' : 'reference';
$shortcutContent .= '<div class="' . $className . '">';
$shortcutContent .= $this->renderSingleElementHTML($parentObject, $item);
// NOTE: this is the end tag for <div class="t3-page-ce-body">
// because of bad (historic) conception, starting tag has to be placed inside tt_content_drawHeader()
$shortcutContent .= '<div class="reference-overlay"></div></div></div>';
}
}
}
}
return $shortcutContent;
} | [
"protected",
"function",
"renderCTypeShortcut",
"(",
"PageLayoutView",
"$",
"parentObject",
",",
"&",
"$",
"row",
")",
"{",
"$",
"shortcutContent",
"=",
"''",
";",
"if",
"(",
"$",
"row",
"[",
"'records'",
"]",
")",
"{",
"$",
"shortcutItems",
"=",
"explode",
"(",
"','",
",",
"$",
"row",
"[",
"'records'",
"]",
")",
";",
"$",
"collectedItems",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"shortcutItems",
"as",
"$",
"shortcutItem",
")",
"{",
"$",
"shortcutItem",
"=",
"trim",
"(",
"$",
"shortcutItem",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"shortcutItem",
",",
"'pages_'",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"collectContentDataFromPages",
"(",
"$",
"shortcutItem",
",",
"$",
"collectedItems",
",",
"$",
"row",
"[",
"'recursive'",
"]",
",",
"$",
"row",
"[",
"'uid'",
"]",
",",
"$",
"row",
"[",
"'sys_language_uid'",
"]",
")",
";",
"}",
"else",
"{",
"if",
"(",
"strpos",
"(",
"$",
"shortcutItem",
",",
"'_'",
")",
"===",
"false",
"||",
"strpos",
"(",
"$",
"shortcutItem",
",",
"'tt_content_'",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"collectContentData",
"(",
"$",
"shortcutItem",
",",
"$",
"collectedItems",
",",
"$",
"row",
"[",
"'uid'",
"]",
",",
"$",
"row",
"[",
"'sys_language_uid'",
"]",
")",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"collectedItems",
")",
")",
"{",
"foreach",
"(",
"$",
"collectedItems",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
")",
"{",
"$",
"className",
"=",
"$",
"item",
"[",
"'tx_gridelements_reference_container'",
"]",
"?",
"'reference container_reference'",
":",
"'reference'",
";",
"$",
"shortcutContent",
".=",
"'<div class=\"'",
".",
"$",
"className",
".",
"'\">'",
";",
"$",
"shortcutContent",
".=",
"$",
"this",
"->",
"renderSingleElementHTML",
"(",
"$",
"parentObject",
",",
"$",
"item",
")",
";",
"// NOTE: this is the end tag for <div class=\"t3-page-ce-body\">",
"// because of bad (historic) conception, starting tag has to be placed inside tt_content_drawHeader()",
"$",
"shortcutContent",
".=",
"'<div class=\"reference-overlay\"></div></div></div>'",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"shortcutContent",
";",
"}"
] | renders the HTML output for elements of the CType shortcut
@param PageLayoutView $parentObject : The parent object that triggered this hook
@param array $row : The current data row for this item
@return string $shortcutContent: The HTML output for elements of the CType shortcut | [
"renders",
"the",
"HTML",
"output",
"for",
"elements",
"of",
"the",
"CType",
"shortcut"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/DrawItem.php#L1267-L1309 |
TYPO3-extensions/gridelements | Classes/Hooks/DrawItem.php | DrawItem.collectContentDataFromPages | protected function collectContentDataFromPages(
$shortcutItem,
&$collectedItems,
$recursive = 0,
$parentUid = 0,
$language = 0
) {
$itemList = str_replace('pages_', '', $shortcutItem);
if ($recursive) {
if (!$this->tree instanceof QueryGenerator) {
$this->tree = GeneralUtility::makeInstance(QueryGenerator::class);
}
$itemList = $this->tree->getTreeList($itemList, (int)$recursive, 0, 1);
}
$itemList = GeneralUtility::intExplode(',', $itemList);
$queryBuilder = $this->getQueryBuilder();
$items = $queryBuilder
->select('*')
->addSelectLiteral($queryBuilder->expr()->inSet(
'pid',
$queryBuilder->createNamedParameter($itemList, Connection::PARAM_INT_ARRAY)
) . ' AS inSet')
->from('tt_content')
->where(
$queryBuilder->expr()->neq(
'uid',
$queryBuilder->createNamedParameter((int)$parentUid, \PDO::PARAM_INT)
),
$queryBuilder->expr()->in(
'pid',
$queryBuilder->createNamedParameter($itemList, Connection::PARAM_INT_ARRAY)
),
$queryBuilder->expr()->gte('colPos', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)),
$queryBuilder->expr()->in(
'sys_language_uid',
$queryBuilder->createNamedParameter([0, -1], Connection::PARAM_INT_ARRAY)
)
)
->orderBy('inSet')
->addOrderBy('colPos')
->addOrderBy('sorting')
->execute()
->fetchAll();
foreach ($items as $item) {
if (!empty($this->extentensionConfiguration['overlayShortcutTranslation']) && $language > 0) {
$translatedItem = BackendUtility::getRecordLocalization('tt_content', $item['uid'], $language);
if (!empty($translatedItem)) {
$item = array_shift($translatedItem);
}
}
if ($this->helper->getBackendUser()->workspace > 0) {
BackendUtility::workspaceOL('tt_content', $item, $this->helper->getBackendUser()->workspace);
}
$item['tx_gridelements_reference_container'] = $item['pid'];
$collectedItems[] = $item;
}
} | php | protected function collectContentDataFromPages(
$shortcutItem,
&$collectedItems,
$recursive = 0,
$parentUid = 0,
$language = 0
) {
$itemList = str_replace('pages_', '', $shortcutItem);
if ($recursive) {
if (!$this->tree instanceof QueryGenerator) {
$this->tree = GeneralUtility::makeInstance(QueryGenerator::class);
}
$itemList = $this->tree->getTreeList($itemList, (int)$recursive, 0, 1);
}
$itemList = GeneralUtility::intExplode(',', $itemList);
$queryBuilder = $this->getQueryBuilder();
$items = $queryBuilder
->select('*')
->addSelectLiteral($queryBuilder->expr()->inSet(
'pid',
$queryBuilder->createNamedParameter($itemList, Connection::PARAM_INT_ARRAY)
) . ' AS inSet')
->from('tt_content')
->where(
$queryBuilder->expr()->neq(
'uid',
$queryBuilder->createNamedParameter((int)$parentUid, \PDO::PARAM_INT)
),
$queryBuilder->expr()->in(
'pid',
$queryBuilder->createNamedParameter($itemList, Connection::PARAM_INT_ARRAY)
),
$queryBuilder->expr()->gte('colPos', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)),
$queryBuilder->expr()->in(
'sys_language_uid',
$queryBuilder->createNamedParameter([0, -1], Connection::PARAM_INT_ARRAY)
)
)
->orderBy('inSet')
->addOrderBy('colPos')
->addOrderBy('sorting')
->execute()
->fetchAll();
foreach ($items as $item) {
if (!empty($this->extentensionConfiguration['overlayShortcutTranslation']) && $language > 0) {
$translatedItem = BackendUtility::getRecordLocalization('tt_content', $item['uid'], $language);
if (!empty($translatedItem)) {
$item = array_shift($translatedItem);
}
}
if ($this->helper->getBackendUser()->workspace > 0) {
BackendUtility::workspaceOL('tt_content', $item, $this->helper->getBackendUser()->workspace);
}
$item['tx_gridelements_reference_container'] = $item['pid'];
$collectedItems[] = $item;
}
} | [
"protected",
"function",
"collectContentDataFromPages",
"(",
"$",
"shortcutItem",
",",
"&",
"$",
"collectedItems",
",",
"$",
"recursive",
"=",
"0",
",",
"$",
"parentUid",
"=",
"0",
",",
"$",
"language",
"=",
"0",
")",
"{",
"$",
"itemList",
"=",
"str_replace",
"(",
"'pages_'",
",",
"''",
",",
"$",
"shortcutItem",
")",
";",
"if",
"(",
"$",
"recursive",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"tree",
"instanceof",
"QueryGenerator",
")",
"{",
"$",
"this",
"->",
"tree",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"QueryGenerator",
"::",
"class",
")",
";",
"}",
"$",
"itemList",
"=",
"$",
"this",
"->",
"tree",
"->",
"getTreeList",
"(",
"$",
"itemList",
",",
"(",
"int",
")",
"$",
"recursive",
",",
"0",
",",
"1",
")",
";",
"}",
"$",
"itemList",
"=",
"GeneralUtility",
"::",
"intExplode",
"(",
"','",
",",
"$",
"itemList",
")",
";",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
";",
"$",
"items",
"=",
"$",
"queryBuilder",
"->",
"select",
"(",
"'*'",
")",
"->",
"addSelectLiteral",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"inSet",
"(",
"'pid'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"$",
"itemList",
",",
"Connection",
"::",
"PARAM_INT_ARRAY",
")",
")",
".",
"' AS inSet'",
")",
"->",
"from",
"(",
"'tt_content'",
")",
"->",
"where",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"neq",
"(",
"'uid'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"(",
"int",
")",
"$",
"parentUid",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
")",
",",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"in",
"(",
"'pid'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"$",
"itemList",
",",
"Connection",
"::",
"PARAM_INT_ARRAY",
")",
")",
",",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"gte",
"(",
"'colPos'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"0",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
")",
",",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"in",
"(",
"'sys_language_uid'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"[",
"0",
",",
"-",
"1",
"]",
",",
"Connection",
"::",
"PARAM_INT_ARRAY",
")",
")",
")",
"->",
"orderBy",
"(",
"'inSet'",
")",
"->",
"addOrderBy",
"(",
"'colPos'",
")",
"->",
"addOrderBy",
"(",
"'sorting'",
")",
"->",
"execute",
"(",
")",
"->",
"fetchAll",
"(",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"extentensionConfiguration",
"[",
"'overlayShortcutTranslation'",
"]",
")",
"&&",
"$",
"language",
">",
"0",
")",
"{",
"$",
"translatedItem",
"=",
"BackendUtility",
"::",
"getRecordLocalization",
"(",
"'tt_content'",
",",
"$",
"item",
"[",
"'uid'",
"]",
",",
"$",
"language",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"translatedItem",
")",
")",
"{",
"$",
"item",
"=",
"array_shift",
"(",
"$",
"translatedItem",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"helper",
"->",
"getBackendUser",
"(",
")",
"->",
"workspace",
">",
"0",
")",
"{",
"BackendUtility",
"::",
"workspaceOL",
"(",
"'tt_content'",
",",
"$",
"item",
",",
"$",
"this",
"->",
"helper",
"->",
"getBackendUser",
"(",
")",
"->",
"workspace",
")",
";",
"}",
"$",
"item",
"[",
"'tx_gridelements_reference_container'",
"]",
"=",
"$",
"item",
"[",
"'pid'",
"]",
";",
"$",
"collectedItems",
"[",
"]",
"=",
"$",
"item",
";",
"}",
"}"
] | Collects tt_content data from a single page or a page tree starting at a given page
@param string $shortcutItem : The single page to be used as the tree root
@param array $collectedItems : The collected item data rows ordered by parent position, column position and sorting
@param int $recursive : The number of levels for the recursion
@param int $parentUid : uid of the referencing tt_content record
@param int $language : sys_language_uid of the referencing tt_content record
@return void | [
"Collects",
"tt_content",
"data",
"from",
"a",
"single",
"page",
"or",
"a",
"page",
"tree",
"starting",
"at",
"a",
"given",
"page"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/DrawItem.php#L1322-L1381 |
TYPO3-extensions/gridelements | Classes/Hooks/DrawItem.php | DrawItem.collectContentData | protected function collectContentData($shortcutItem, &$collectedItems, $parentUid, $language)
{
$shortcutItem = str_replace('tt_content_', '', $shortcutItem);
if ((int)$shortcutItem !== (int)$parentUid) {
$queryBuilder = $this->getQueryBuilder();
if ($this->showHidden) {
$queryBuilder->getRestrictions()->removeByType(HiddenRestriction::class);
}
$item = $queryBuilder
->select('*')
->from('tt_content')
->where(
$queryBuilder->expr()->eq(
'uid',
$queryBuilder->createNamedParameter((int)$shortcutItem, \PDO::PARAM_INT)
)
)
->setMaxResults(1)
->execute()
->fetch();
if (!empty($this->extentensionConfiguration['overlayShortcutTranslation']) && $language > 0) {
$translatedItem = BackendUtility::getRecordLocalization('tt_content', $item['uid'], $language);
if (!empty($translatedItem)) {
$item = array_shift($translatedItem);
}
}
if ($this->helper->getBackendUser()->workspace > 0) {
BackendUtility::workspaceOL(
'tt_content',
$item,
$this->helper->getBackendUser()->workspace
);
}
$collectedItems[] = $item;
}
} | php | protected function collectContentData($shortcutItem, &$collectedItems, $parentUid, $language)
{
$shortcutItem = str_replace('tt_content_', '', $shortcutItem);
if ((int)$shortcutItem !== (int)$parentUid) {
$queryBuilder = $this->getQueryBuilder();
if ($this->showHidden) {
$queryBuilder->getRestrictions()->removeByType(HiddenRestriction::class);
}
$item = $queryBuilder
->select('*')
->from('tt_content')
->where(
$queryBuilder->expr()->eq(
'uid',
$queryBuilder->createNamedParameter((int)$shortcutItem, \PDO::PARAM_INT)
)
)
->setMaxResults(1)
->execute()
->fetch();
if (!empty($this->extentensionConfiguration['overlayShortcutTranslation']) && $language > 0) {
$translatedItem = BackendUtility::getRecordLocalization('tt_content', $item['uid'], $language);
if (!empty($translatedItem)) {
$item = array_shift($translatedItem);
}
}
if ($this->helper->getBackendUser()->workspace > 0) {
BackendUtility::workspaceOL(
'tt_content',
$item,
$this->helper->getBackendUser()->workspace
);
}
$collectedItems[] = $item;
}
} | [
"protected",
"function",
"collectContentData",
"(",
"$",
"shortcutItem",
",",
"&",
"$",
"collectedItems",
",",
"$",
"parentUid",
",",
"$",
"language",
")",
"{",
"$",
"shortcutItem",
"=",
"str_replace",
"(",
"'tt_content_'",
",",
"''",
",",
"$",
"shortcutItem",
")",
";",
"if",
"(",
"(",
"int",
")",
"$",
"shortcutItem",
"!==",
"(",
"int",
")",
"$",
"parentUid",
")",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"showHidden",
")",
"{",
"$",
"queryBuilder",
"->",
"getRestrictions",
"(",
")",
"->",
"removeByType",
"(",
"HiddenRestriction",
"::",
"class",
")",
";",
"}",
"$",
"item",
"=",
"$",
"queryBuilder",
"->",
"select",
"(",
"'*'",
")",
"->",
"from",
"(",
"'tt_content'",
")",
"->",
"where",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'uid'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"(",
"int",
")",
"$",
"shortcutItem",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
")",
")",
"->",
"setMaxResults",
"(",
"1",
")",
"->",
"execute",
"(",
")",
"->",
"fetch",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"extentensionConfiguration",
"[",
"'overlayShortcutTranslation'",
"]",
")",
"&&",
"$",
"language",
">",
"0",
")",
"{",
"$",
"translatedItem",
"=",
"BackendUtility",
"::",
"getRecordLocalization",
"(",
"'tt_content'",
",",
"$",
"item",
"[",
"'uid'",
"]",
",",
"$",
"language",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"translatedItem",
")",
")",
"{",
"$",
"item",
"=",
"array_shift",
"(",
"$",
"translatedItem",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"helper",
"->",
"getBackendUser",
"(",
")",
"->",
"workspace",
">",
"0",
")",
"{",
"BackendUtility",
"::",
"workspaceOL",
"(",
"'tt_content'",
",",
"$",
"item",
",",
"$",
"this",
"->",
"helper",
"->",
"getBackendUser",
"(",
")",
"->",
"workspace",
")",
";",
"}",
"$",
"collectedItems",
"[",
"]",
"=",
"$",
"item",
";",
"}",
"}"
] | Collects tt_content data from a single tt_content element
@param string $shortcutItem : The tt_content element to fetch the data from
@param array $collectedItems : The collected item data row
@param int $parentUid : uid of the referencing tt_content record
@param int $language : sys_language_uid of the referencing tt_content record
@return void | [
"Collects",
"tt_content",
"data",
"from",
"a",
"single",
"tt_content",
"element"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/DrawItem.php#L1393-L1430 |
TYPO3-extensions/gridelements | Classes/Hooks/DatabaseRecordList.php | DatabaseRecordList.checkChildren | public function checkChildren($table, array $row, $level, array &$theData, DatabaseRecordListXclass $parentObj)
{
if ($table === 'tt_content' && $row['CType'] === 'gridelements_pi1') {
$elementChildren = Helper::getInstance()->getChildren(
$table,
$row['uid'],
$row['pid'],
'',
0,
$parentObj->selFieldList
);
if (!empty($elementChildren)) {
$theData['_EXPANDABLE_'] = true;
$theData['_EXPAND_ID_'] = $table . ':' . $row['uid'];
$theData['_EXPAND_TABLE_'] = $table;
$theData['_LEVEL_'] = $level;
$theData['_CHILDREN_'] = $elementChildren;
}
}
} | php | public function checkChildren($table, array $row, $level, array &$theData, DatabaseRecordListXclass $parentObj)
{
if ($table === 'tt_content' && $row['CType'] === 'gridelements_pi1') {
$elementChildren = Helper::getInstance()->getChildren(
$table,
$row['uid'],
$row['pid'],
'',
0,
$parentObj->selFieldList
);
if (!empty($elementChildren)) {
$theData['_EXPANDABLE_'] = true;
$theData['_EXPAND_ID_'] = $table . ':' . $row['uid'];
$theData['_EXPAND_TABLE_'] = $table;
$theData['_LEVEL_'] = $level;
$theData['_CHILDREN_'] = $elementChildren;
}
}
} | [
"public",
"function",
"checkChildren",
"(",
"$",
"table",
",",
"array",
"$",
"row",
",",
"$",
"level",
",",
"array",
"&",
"$",
"theData",
",",
"DatabaseRecordListXclass",
"$",
"parentObj",
")",
"{",
"if",
"(",
"$",
"table",
"===",
"'tt_content'",
"&&",
"$",
"row",
"[",
"'CType'",
"]",
"===",
"'gridelements_pi1'",
")",
"{",
"$",
"elementChildren",
"=",
"Helper",
"::",
"getInstance",
"(",
")",
"->",
"getChildren",
"(",
"$",
"table",
",",
"$",
"row",
"[",
"'uid'",
"]",
",",
"$",
"row",
"[",
"'pid'",
"]",
",",
"''",
",",
"0",
",",
"$",
"parentObj",
"->",
"selFieldList",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"elementChildren",
")",
")",
"{",
"$",
"theData",
"[",
"'_EXPANDABLE_'",
"]",
"=",
"true",
";",
"$",
"theData",
"[",
"'_EXPAND_ID_'",
"]",
"=",
"$",
"table",
".",
"':'",
".",
"$",
"row",
"[",
"'uid'",
"]",
";",
"$",
"theData",
"[",
"'_EXPAND_TABLE_'",
"]",
"=",
"$",
"table",
";",
"$",
"theData",
"[",
"'_LEVEL_'",
"]",
"=",
"$",
"level",
";",
"$",
"theData",
"[",
"'_CHILDREN_'",
"]",
"=",
"$",
"elementChildren",
";",
"}",
"}",
"}"
] | check if current row has child elements and add info to $theData array
@param string $table
@param array $row
@param int $level
@param array $theData
@param DatabaseRecordListXclass $parentObj | [
"check",
"if",
"current",
"row",
"has",
"child",
"elements",
"and",
"add",
"info",
"to",
"$theData",
"array"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/DatabaseRecordList.php#L131-L150 |
TYPO3-extensions/gridelements | Classes/Hooks/DatabaseRecordList.php | DatabaseRecordList.contentCollapseIcon | public function contentCollapseIcon(
array &$data,
$sortField,
$level,
&$contentCollapseIcon,
DatabaseRecordListXclass $parentObj
) {
if ($data['_EXPAND_TABLE_'] === 'tt_content') {
$expandTitle = $this->languageService->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xlf:list.expandElement');
$collapseTitle = $this->languageService->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xlf:list.collapseElement');
$expandedGridelements = $parentObj->getExpandedGridelements();
if ($expandedGridelements[$data['uid']]) {
$href = htmlspecialchars(($parentObj->listURL() . '&gridelementsExpand[' . (int)$data['uid'] . ']=0'));
$contentCollapseIcon = '<a class="btn btn-default t3js-toggle-gridelements-list open-gridelements-container" data-state="expanded" href="' . $href .
'" id="t3-gridelements-' . $data['uid'] . '" title="' . $collapseTitle
. '" data-toggle-title="' . $expandTitle . '">'
. $this->getIconFactory()->getIcon('actions-view-list-expand', 'small')->render()
. $this->getIconFactory()->getIcon('actions-view-list-collapse', 'small')->render() . '</a>';
} else {
$href = htmlspecialchars(($parentObj->listURL() . '&gridelementsExpand[' . (int)$data['uid'] . ']=1'));
$contentCollapseIcon = '<a class="btn btn-default t3js-toggle-gridelements-list" data-state="collapsed" href="' . $href .
'" id="t3-gridelements-' . $data['uid'] . '" title="' . $expandTitle
. '" data-toggle-title="' . $collapseTitle . '">'
. $this->getIconFactory()->getIcon('actions-view-list-expand', 'small')->render()
. $this->getIconFactory()->getIcon('actions-view-list-collapse', 'small')->render() . '</a>';
}
}
} | php | public function contentCollapseIcon(
array &$data,
$sortField,
$level,
&$contentCollapseIcon,
DatabaseRecordListXclass $parentObj
) {
if ($data['_EXPAND_TABLE_'] === 'tt_content') {
$expandTitle = $this->languageService->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xlf:list.expandElement');
$collapseTitle = $this->languageService->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xlf:list.collapseElement');
$expandedGridelements = $parentObj->getExpandedGridelements();
if ($expandedGridelements[$data['uid']]) {
$href = htmlspecialchars(($parentObj->listURL() . '&gridelementsExpand[' . (int)$data['uid'] . ']=0'));
$contentCollapseIcon = '<a class="btn btn-default t3js-toggle-gridelements-list open-gridelements-container" data-state="expanded" href="' . $href .
'" id="t3-gridelements-' . $data['uid'] . '" title="' . $collapseTitle
. '" data-toggle-title="' . $expandTitle . '">'
. $this->getIconFactory()->getIcon('actions-view-list-expand', 'small')->render()
. $this->getIconFactory()->getIcon('actions-view-list-collapse', 'small')->render() . '</a>';
} else {
$href = htmlspecialchars(($parentObj->listURL() . '&gridelementsExpand[' . (int)$data['uid'] . ']=1'));
$contentCollapseIcon = '<a class="btn btn-default t3js-toggle-gridelements-list" data-state="collapsed" href="' . $href .
'" id="t3-gridelements-' . $data['uid'] . '" title="' . $expandTitle
. '" data-toggle-title="' . $collapseTitle . '">'
. $this->getIconFactory()->getIcon('actions-view-list-expand', 'small')->render()
. $this->getIconFactory()->getIcon('actions-view-list-collapse', 'small')->render() . '</a>';
}
}
} | [
"public",
"function",
"contentCollapseIcon",
"(",
"array",
"&",
"$",
"data",
",",
"$",
"sortField",
",",
"$",
"level",
",",
"&",
"$",
"contentCollapseIcon",
",",
"DatabaseRecordListXclass",
"$",
"parentObj",
")",
"{",
"if",
"(",
"$",
"data",
"[",
"'_EXPAND_TABLE_'",
"]",
"===",
"'tt_content'",
")",
"{",
"$",
"expandTitle",
"=",
"$",
"this",
"->",
"languageService",
"->",
"sL",
"(",
"'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xlf:list.expandElement'",
")",
";",
"$",
"collapseTitle",
"=",
"$",
"this",
"->",
"languageService",
"->",
"sL",
"(",
"'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xlf:list.collapseElement'",
")",
";",
"$",
"expandedGridelements",
"=",
"$",
"parentObj",
"->",
"getExpandedGridelements",
"(",
")",
";",
"if",
"(",
"$",
"expandedGridelements",
"[",
"$",
"data",
"[",
"'uid'",
"]",
"]",
")",
"{",
"$",
"href",
"=",
"htmlspecialchars",
"(",
"(",
"$",
"parentObj",
"->",
"listURL",
"(",
")",
".",
"'&gridelementsExpand['",
".",
"(",
"int",
")",
"$",
"data",
"[",
"'uid'",
"]",
".",
"']=0'",
")",
")",
";",
"$",
"contentCollapseIcon",
"=",
"'<a class=\"btn btn-default t3js-toggle-gridelements-list open-gridelements-container\" data-state=\"expanded\" href=\"'",
".",
"$",
"href",
".",
"'\" id=\"t3-gridelements-'",
".",
"$",
"data",
"[",
"'uid'",
"]",
".",
"'\" title=\"'",
".",
"$",
"collapseTitle",
".",
"'\" data-toggle-title=\"'",
".",
"$",
"expandTitle",
".",
"'\">'",
".",
"$",
"this",
"->",
"getIconFactory",
"(",
")",
"->",
"getIcon",
"(",
"'actions-view-list-expand'",
",",
"'small'",
")",
"->",
"render",
"(",
")",
".",
"$",
"this",
"->",
"getIconFactory",
"(",
")",
"->",
"getIcon",
"(",
"'actions-view-list-collapse'",
",",
"'small'",
")",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"}",
"else",
"{",
"$",
"href",
"=",
"htmlspecialchars",
"(",
"(",
"$",
"parentObj",
"->",
"listURL",
"(",
")",
".",
"'&gridelementsExpand['",
".",
"(",
"int",
")",
"$",
"data",
"[",
"'uid'",
"]",
".",
"']=1'",
")",
")",
";",
"$",
"contentCollapseIcon",
"=",
"'<a class=\"btn btn-default t3js-toggle-gridelements-list\" data-state=\"collapsed\" href=\"'",
".",
"$",
"href",
".",
"'\" id=\"t3-gridelements-'",
".",
"$",
"data",
"[",
"'uid'",
"]",
".",
"'\" title=\"'",
".",
"$",
"expandTitle",
".",
"'\" data-toggle-title=\"'",
".",
"$",
"collapseTitle",
".",
"'\">'",
".",
"$",
"this",
"->",
"getIconFactory",
"(",
")",
"->",
"getIcon",
"(",
"'actions-view-list-expand'",
",",
"'small'",
")",
"->",
"render",
"(",
")",
".",
"$",
"this",
"->",
"getIconFactory",
"(",
")",
"->",
"getIcon",
"(",
"'actions-view-list-collapse'",
",",
"'small'",
")",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"}",
"}",
"}"
] | return content collapse icon
@param array $data
@param string $sortField
@param int $level
@param string $contentCollapseIcon
@param DatabaseRecordListXclass $parentObj | [
"return",
"content",
"collapse",
"icon"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/DatabaseRecordList.php#L161-L188 |
TYPO3-extensions/gridelements | Classes/Backend/ItemsProcFuncs/SysLanguageUidList.php | SysLanguageUidList.itemsProcFunc | public function itemsProcFunc(array &$params)
{
if ((int)$params['row']['pid'] > 0 && (int)$params['row']['tx_gridelements_container'] > 0 && isset($params['items'])) {
$this->checkForAllowedLanguages($params['items'], $params['row']['tx_gridelements_container']);
}
} | php | public function itemsProcFunc(array &$params)
{
if ((int)$params['row']['pid'] > 0 && (int)$params['row']['tx_gridelements_container'] > 0 && isset($params['items'])) {
$this->checkForAllowedLanguages($params['items'], $params['row']['tx_gridelements_container']);
}
} | [
"public",
"function",
"itemsProcFunc",
"(",
"array",
"&",
"$",
"params",
")",
"{",
"if",
"(",
"(",
"int",
")",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'pid'",
"]",
">",
"0",
"&&",
"(",
"int",
")",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'tx_gridelements_container'",
"]",
">",
"0",
"&&",
"isset",
"(",
"$",
"params",
"[",
"'items'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"checkForAllowedLanguages",
"(",
"$",
"params",
"[",
"'items'",
"]",
",",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'tx_gridelements_container'",
"]",
")",
";",
"}",
"}"
] | ItemProcFunc for CType items
@param array $params The array of parameters that is used to render the item list | [
"ItemProcFunc",
"for",
"CType",
"items"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/ItemsProcFuncs/SysLanguageUidList.php#L37-L42 |
TYPO3-extensions/gridelements | Classes/Backend/ItemsProcFuncs/SysLanguageUidList.php | SysLanguageUidList.checkForAllowedLanguages | public function checkForAllowedLanguages(array &$items, $gridContainerId)
{
if (!$gridContainerId) {
return;
}
$parentContainer = BackendUtility::getRecordWSOL('tt_content', $gridContainerId);
if (!empty($items) && (int)$parentContainer['uid'] > 0) {
foreach ($items as $item => $valueArray) {
if ((int)$parentContainer['sys_language_uid'] > -1 && (int)$valueArray[1] !== (int)$parentContainer['sys_language_uid']) {
unset($items[$item]);
}
}
}
} | php | public function checkForAllowedLanguages(array &$items, $gridContainerId)
{
if (!$gridContainerId) {
return;
}
$parentContainer = BackendUtility::getRecordWSOL('tt_content', $gridContainerId);
if (!empty($items) && (int)$parentContainer['uid'] > 0) {
foreach ($items as $item => $valueArray) {
if ((int)$parentContainer['sys_language_uid'] > -1 && (int)$valueArray[1] !== (int)$parentContainer['sys_language_uid']) {
unset($items[$item]);
}
}
}
} | [
"public",
"function",
"checkForAllowedLanguages",
"(",
"array",
"&",
"$",
"items",
",",
"$",
"gridContainerId",
")",
"{",
"if",
"(",
"!",
"$",
"gridContainerId",
")",
"{",
"return",
";",
"}",
"$",
"parentContainer",
"=",
"BackendUtility",
"::",
"getRecordWSOL",
"(",
"'tt_content'",
",",
"$",
"gridContainerId",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"items",
")",
"&&",
"(",
"int",
")",
"$",
"parentContainer",
"[",
"'uid'",
"]",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
"=>",
"$",
"valueArray",
")",
"{",
"if",
"(",
"(",
"int",
")",
"$",
"parentContainer",
"[",
"'sys_language_uid'",
"]",
">",
"-",
"1",
"&&",
"(",
"int",
")",
"$",
"valueArray",
"[",
"1",
"]",
"!==",
"(",
"int",
")",
"$",
"parentContainer",
"[",
"'sys_language_uid'",
"]",
")",
"{",
"unset",
"(",
"$",
"items",
"[",
"$",
"item",
"]",
")",
";",
"}",
"}",
"}",
"}"
] | Checks if a language is allowed in this particular container - only this one container defines the allowed languages regardless of any parent
@param array $items The items of the current language list
@param int $gridContainerId The ID of the current container | [
"Checks",
"if",
"a",
"language",
"is",
"allowed",
"in",
"this",
"particular",
"container",
"-",
"only",
"this",
"one",
"container",
"defines",
"the",
"allowed",
"languages",
"regardless",
"of",
"any",
"parent"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/ItemsProcFuncs/SysLanguageUidList.php#L50-L63 |
TYPO3-extensions/gridelements | Classes/Backend/TtContent.php | TtContent.columnsItemsProcFunc | public function columnsItemsProcFunc(array &$params)
{
$this->init($params['row']['pid']);
$gridContainerId = is_array($params['row']['tx_gridelements_container'])
? (int)$params['row']['tx_gridelements_container'][0]
: (int)$params['row']['tx_gridelements_container'];
if ($gridContainerId > 0) {
$gridElement = $this->layoutSetup->cacheCurrentParent($gridContainerId, true);
$params['items'] = $this->layoutSetup->getLayoutColumnsSelectItems($gridElement['tx_gridelements_backend_layout']);
$ContentType = is_array($params['row']['CType']) ? $params['row']['CType'][0] : $params['row']['CType'];
if (!empty($ContentType) && is_array($params['items'])) {
foreach ($params['items'] as $itemKey => $itemArray) {
if ($itemArray[3] !== '' && $itemArray[3] !== '*'
&& !GeneralUtility::inList($itemArray[3], $ContentType)
) {
unset($params['items'][$itemKey]);
}
}
}
}
} | php | public function columnsItemsProcFunc(array &$params)
{
$this->init($params['row']['pid']);
$gridContainerId = is_array($params['row']['tx_gridelements_container'])
? (int)$params['row']['tx_gridelements_container'][0]
: (int)$params['row']['tx_gridelements_container'];
if ($gridContainerId > 0) {
$gridElement = $this->layoutSetup->cacheCurrentParent($gridContainerId, true);
$params['items'] = $this->layoutSetup->getLayoutColumnsSelectItems($gridElement['tx_gridelements_backend_layout']);
$ContentType = is_array($params['row']['CType']) ? $params['row']['CType'][0] : $params['row']['CType'];
if (!empty($ContentType) && is_array($params['items'])) {
foreach ($params['items'] as $itemKey => $itemArray) {
if ($itemArray[3] !== '' && $itemArray[3] !== '*'
&& !GeneralUtility::inList($itemArray[3], $ContentType)
) {
unset($params['items'][$itemKey]);
}
}
}
}
} | [
"public",
"function",
"columnsItemsProcFunc",
"(",
"array",
"&",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"init",
"(",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'pid'",
"]",
")",
";",
"$",
"gridContainerId",
"=",
"is_array",
"(",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'tx_gridelements_container'",
"]",
")",
"?",
"(",
"int",
")",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'tx_gridelements_container'",
"]",
"[",
"0",
"]",
":",
"(",
"int",
")",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'tx_gridelements_container'",
"]",
";",
"if",
"(",
"$",
"gridContainerId",
">",
"0",
")",
"{",
"$",
"gridElement",
"=",
"$",
"this",
"->",
"layoutSetup",
"->",
"cacheCurrentParent",
"(",
"$",
"gridContainerId",
",",
"true",
")",
";",
"$",
"params",
"[",
"'items'",
"]",
"=",
"$",
"this",
"->",
"layoutSetup",
"->",
"getLayoutColumnsSelectItems",
"(",
"$",
"gridElement",
"[",
"'tx_gridelements_backend_layout'",
"]",
")",
";",
"$",
"ContentType",
"=",
"is_array",
"(",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'CType'",
"]",
")",
"?",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'CType'",
"]",
"[",
"0",
"]",
":",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'CType'",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"ContentType",
")",
"&&",
"is_array",
"(",
"$",
"params",
"[",
"'items'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"params",
"[",
"'items'",
"]",
"as",
"$",
"itemKey",
"=>",
"$",
"itemArray",
")",
"{",
"if",
"(",
"$",
"itemArray",
"[",
"3",
"]",
"!==",
"''",
"&&",
"$",
"itemArray",
"[",
"3",
"]",
"!==",
"'*'",
"&&",
"!",
"GeneralUtility",
"::",
"inList",
"(",
"$",
"itemArray",
"[",
"3",
"]",
",",
"$",
"ContentType",
")",
")",
"{",
"unset",
"(",
"$",
"params",
"[",
"'items'",
"]",
"[",
"$",
"itemKey",
"]",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | ItemProcFunc for columns items
@param array $params An array containing the items and parameters for the list of items | [
"ItemProcFunc",
"for",
"columns",
"items"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/TtContent.php#L48-L70 |
TYPO3-extensions/gridelements | Classes/Backend/TtContent.php | TtContent.init | public function init($pageId)
{
if (!$this->layoutSetup instanceof LayoutSetup) {
$this->injectLayoutSetup(GeneralUtility::makeInstance(LayoutSetup::class)->init($pageId));
}
} | php | public function init($pageId)
{
if (!$this->layoutSetup instanceof LayoutSetup) {
$this->injectLayoutSetup(GeneralUtility::makeInstance(LayoutSetup::class)->init($pageId));
}
} | [
"public",
"function",
"init",
"(",
"$",
"pageId",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"layoutSetup",
"instanceof",
"LayoutSetup",
")",
"{",
"$",
"this",
"->",
"injectLayoutSetup",
"(",
"GeneralUtility",
"::",
"makeInstance",
"(",
"LayoutSetup",
"::",
"class",
")",
"->",
"init",
"(",
"$",
"pageId",
")",
")",
";",
"}",
"}"
] | initializes this class
@param int $pageId | [
"initializes",
"this",
"class"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/TtContent.php#L77-L82 |
TYPO3-extensions/gridelements | Classes/Backend/TtContent.php | TtContent.containerItemsProcFunc | public function containerItemsProcFunc(array &$params)
{
$this->init($params['row']['pid']);
$possibleContainers = [];
$this->removeItemsFromListOfSelectableContainers($params, $possibleContainers);
if (!empty($possibleContainers)) {
$params['items'] = array_merge($params['items'], $possibleContainers);
}
$itemUidList = '';
if (count($params['items']) > 1) {
foreach ($params['items'] as $container) {
if ($container[1] > 0) {
$itemUidList .= $itemUidList ? ',' . $container[1] : $container[1];
}
}
}
if ($itemUidList) {
$this->deleteDisallowedContainers($params, $itemUidList);
}
} | php | public function containerItemsProcFunc(array &$params)
{
$this->init($params['row']['pid']);
$possibleContainers = [];
$this->removeItemsFromListOfSelectableContainers($params, $possibleContainers);
if (!empty($possibleContainers)) {
$params['items'] = array_merge($params['items'], $possibleContainers);
}
$itemUidList = '';
if (count($params['items']) > 1) {
foreach ($params['items'] as $container) {
if ($container[1] > 0) {
$itemUidList .= $itemUidList ? ',' . $container[1] : $container[1];
}
}
}
if ($itemUidList) {
$this->deleteDisallowedContainers($params, $itemUidList);
}
} | [
"public",
"function",
"containerItemsProcFunc",
"(",
"array",
"&",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"init",
"(",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'pid'",
"]",
")",
";",
"$",
"possibleContainers",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"removeItemsFromListOfSelectableContainers",
"(",
"$",
"params",
",",
"$",
"possibleContainers",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"possibleContainers",
")",
")",
"{",
"$",
"params",
"[",
"'items'",
"]",
"=",
"array_merge",
"(",
"$",
"params",
"[",
"'items'",
"]",
",",
"$",
"possibleContainers",
")",
";",
"}",
"$",
"itemUidList",
"=",
"''",
";",
"if",
"(",
"count",
"(",
"$",
"params",
"[",
"'items'",
"]",
")",
">",
"1",
")",
"{",
"foreach",
"(",
"$",
"params",
"[",
"'items'",
"]",
"as",
"$",
"container",
")",
"{",
"if",
"(",
"$",
"container",
"[",
"1",
"]",
">",
"0",
")",
"{",
"$",
"itemUidList",
".=",
"$",
"itemUidList",
"?",
"','",
".",
"$",
"container",
"[",
"1",
"]",
":",
"$",
"container",
"[",
"1",
"]",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"itemUidList",
")",
"{",
"$",
"this",
"->",
"deleteDisallowedContainers",
"(",
"$",
"params",
",",
"$",
"itemUidList",
")",
";",
"}",
"}"
] | ItemProcFunc for container items
removes items of the children chain from the list of selectable containers
if the element itself already is a container
@param array $params An array containing the items and parameters for the list of items | [
"ItemProcFunc",
"for",
"container",
"items",
"removes",
"items",
"of",
"the",
"children",
"chain",
"from",
"the",
"list",
"of",
"selectable",
"containers",
"if",
"the",
"element",
"itself",
"already",
"is",
"a",
"container"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/TtContent.php#L101-L122 |
TYPO3-extensions/gridelements | Classes/Backend/TtContent.php | TtContent.removeItemsFromListOfSelectableContainers | public function removeItemsFromListOfSelectableContainers(array &$params, array &$possibleContainers)
{
$contentType = is_array($params['row']['CType']) ? $params['row']['CType'][0] : $params['row']['CType'];
if ($contentType === 'gridelements_pi1' && count($params['items']) > 1) {
$items = $params['items'];
$params['items'] = [0 => array_shift($items)];
foreach ($items as $item) {
$possibleContainers[$item['1']] = $item;
}
if ($params['row']['uid'] > 0) {
$this->lookForChildContainersRecursively((int)$params['row']['uid'], $possibleContainers);
}
}
} | php | public function removeItemsFromListOfSelectableContainers(array &$params, array &$possibleContainers)
{
$contentType = is_array($params['row']['CType']) ? $params['row']['CType'][0] : $params['row']['CType'];
if ($contentType === 'gridelements_pi1' && count($params['items']) > 1) {
$items = $params['items'];
$params['items'] = [0 => array_shift($items)];
foreach ($items as $item) {
$possibleContainers[$item['1']] = $item;
}
if ($params['row']['uid'] > 0) {
$this->lookForChildContainersRecursively((int)$params['row']['uid'], $possibleContainers);
}
}
} | [
"public",
"function",
"removeItemsFromListOfSelectableContainers",
"(",
"array",
"&",
"$",
"params",
",",
"array",
"&",
"$",
"possibleContainers",
")",
"{",
"$",
"contentType",
"=",
"is_array",
"(",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'CType'",
"]",
")",
"?",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'CType'",
"]",
"[",
"0",
"]",
":",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'CType'",
"]",
";",
"if",
"(",
"$",
"contentType",
"===",
"'gridelements_pi1'",
"&&",
"count",
"(",
"$",
"params",
"[",
"'items'",
"]",
")",
">",
"1",
")",
"{",
"$",
"items",
"=",
"$",
"params",
"[",
"'items'",
"]",
";",
"$",
"params",
"[",
"'items'",
"]",
"=",
"[",
"0",
"=>",
"array_shift",
"(",
"$",
"items",
")",
"]",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"possibleContainers",
"[",
"$",
"item",
"[",
"'1'",
"]",
"]",
"=",
"$",
"item",
";",
"}",
"if",
"(",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'uid'",
"]",
">",
"0",
")",
"{",
"$",
"this",
"->",
"lookForChildContainersRecursively",
"(",
"(",
"int",
")",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'uid'",
"]",
",",
"$",
"possibleContainers",
")",
";",
"}",
"}",
"}"
] | removes items of the children chain from the list of selectable containers
@param array $params
@param array $possibleContainers | [
"removes",
"items",
"of",
"the",
"children",
"chain",
"from",
"the",
"list",
"of",
"selectable",
"containers"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/TtContent.php#L130-L145 |
TYPO3-extensions/gridelements | Classes/Backend/TtContent.php | TtContent.lookForChildContainersRecursively | public function lookForChildContainersRecursively($containerIds, array &$possibleContainers)
{
if (!$containerIds) {
return;
}
$containerIds = GeneralUtility::intExplode(',', $containerIds);
$queryBuilder = $this->getQueryBuilder();
$childrenOnNextLevel = $queryBuilder
->select('uid', 'tx_gridelements_container')
->from('tt_content')
->where(
$queryBuilder->expr()->andX(
$queryBuilder->expr()->eq('CType', $queryBuilder->createNamedParameter('gridelements_pi1')),
$queryBuilder->expr()->in(
'tx_gridelements_container',
$queryBuilder->createNamedParameter($containerIds, Connection::PARAM_INT_ARRAY)
)
)
)
->execute()
->fetchAll();
if (!empty($childrenOnNextLevel) && !empty($possibleContainers)) {
$containerIds = '';
foreach ($childrenOnNextLevel as $childOnNextLevel) {
if (isset($possibleContainers[$childOnNextLevel['uid']])) {
unset($possibleContainers[$childOnNextLevel['uid']]);
}
$containerIds .= $containerIds ? ',' . (int)$childOnNextLevel['uid'] : (int)$childOnNextLevel['uid'];
if ($containerIds !== '') {
$this->lookForChildContainersRecursively($containerIds, $possibleContainers);
}
}
}
} | php | public function lookForChildContainersRecursively($containerIds, array &$possibleContainers)
{
if (!$containerIds) {
return;
}
$containerIds = GeneralUtility::intExplode(',', $containerIds);
$queryBuilder = $this->getQueryBuilder();
$childrenOnNextLevel = $queryBuilder
->select('uid', 'tx_gridelements_container')
->from('tt_content')
->where(
$queryBuilder->expr()->andX(
$queryBuilder->expr()->eq('CType', $queryBuilder->createNamedParameter('gridelements_pi1')),
$queryBuilder->expr()->in(
'tx_gridelements_container',
$queryBuilder->createNamedParameter($containerIds, Connection::PARAM_INT_ARRAY)
)
)
)
->execute()
->fetchAll();
if (!empty($childrenOnNextLevel) && !empty($possibleContainers)) {
$containerIds = '';
foreach ($childrenOnNextLevel as $childOnNextLevel) {
if (isset($possibleContainers[$childOnNextLevel['uid']])) {
unset($possibleContainers[$childOnNextLevel['uid']]);
}
$containerIds .= $containerIds ? ',' . (int)$childOnNextLevel['uid'] : (int)$childOnNextLevel['uid'];
if ($containerIds !== '') {
$this->lookForChildContainersRecursively($containerIds, $possibleContainers);
}
}
}
} | [
"public",
"function",
"lookForChildContainersRecursively",
"(",
"$",
"containerIds",
",",
"array",
"&",
"$",
"possibleContainers",
")",
"{",
"if",
"(",
"!",
"$",
"containerIds",
")",
"{",
"return",
";",
"}",
"$",
"containerIds",
"=",
"GeneralUtility",
"::",
"intExplode",
"(",
"','",
",",
"$",
"containerIds",
")",
";",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
";",
"$",
"childrenOnNextLevel",
"=",
"$",
"queryBuilder",
"->",
"select",
"(",
"'uid'",
",",
"'tx_gridelements_container'",
")",
"->",
"from",
"(",
"'tt_content'",
")",
"->",
"where",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"andX",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'CType'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"'gridelements_pi1'",
")",
")",
",",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"in",
"(",
"'tx_gridelements_container'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"$",
"containerIds",
",",
"Connection",
"::",
"PARAM_INT_ARRAY",
")",
")",
")",
")",
"->",
"execute",
"(",
")",
"->",
"fetchAll",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"childrenOnNextLevel",
")",
"&&",
"!",
"empty",
"(",
"$",
"possibleContainers",
")",
")",
"{",
"$",
"containerIds",
"=",
"''",
";",
"foreach",
"(",
"$",
"childrenOnNextLevel",
"as",
"$",
"childOnNextLevel",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"possibleContainers",
"[",
"$",
"childOnNextLevel",
"[",
"'uid'",
"]",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"possibleContainers",
"[",
"$",
"childOnNextLevel",
"[",
"'uid'",
"]",
"]",
")",
";",
"}",
"$",
"containerIds",
".=",
"$",
"containerIds",
"?",
"','",
".",
"(",
"int",
")",
"$",
"childOnNextLevel",
"[",
"'uid'",
"]",
":",
"(",
"int",
")",
"$",
"childOnNextLevel",
"[",
"'uid'",
"]",
";",
"if",
"(",
"$",
"containerIds",
"!==",
"''",
")",
"{",
"$",
"this",
"->",
"lookForChildContainersRecursively",
"(",
"$",
"containerIds",
",",
"$",
"possibleContainers",
")",
";",
"}",
"}",
"}",
"}"
] | Recursive function to remove any container from the list of possible containers
that is already a subcontainer on any level of the current container
@param string $containerIds : A list determining containers that should be checked
@param array $possibleContainers : The result list containing the remaining containers after the check | [
"Recursive",
"function",
"to",
"remove",
"any",
"container",
"from",
"the",
"list",
"of",
"possible",
"containers",
"that",
"is",
"already",
"a",
"subcontainer",
"on",
"any",
"level",
"of",
"the",
"current",
"container"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/TtContent.php#L154-L191 |
TYPO3-extensions/gridelements | Classes/Backend/TtContent.php | TtContent.deleteDisallowedContainers | public function deleteDisallowedContainers(array &$params, $itemUidList = '')
{
$contentType = is_array($params['row']['CType']) ? $params['row']['CType'][0] : $params['row']['CType'];
$listType = '';
if ($contentType === 'list') {
$listType = is_array($params['row']['list_type']) ? $params['row']['list_type'][0] : $params['row']['list_type'];
}
$layoutSetups = $this->layoutSetup->getLayoutSetup();
if ($itemUidList) {
$itemUidList = GeneralUtility::intExplode(',', $itemUidList);
$queryBuilder = $this->getQueryBuilder();
$containerQuery = $queryBuilder
->select('uid', 'tx_gridelements_backend_layout')
->from('tt_content')
->where(
$queryBuilder->expr()->in(
'uid',
$queryBuilder->createNamedParameter($itemUidList, Connection::PARAM_INT_ARRAY)
)
)
->execute();
$containers = [];
while ($container = $containerQuery->fetch()) {
$containers[$container['uid']] = $container;
}
foreach ($params['items'] as $key => $container) {
$backendLayout = $containers[$container[1]]['tx_gridelements_backend_layout'];
$gridColumn = $params['row']['tx_gridelements_columns'];
$allowed = $layoutSetups[$backendLayout]['allowed'][$gridColumn];
$disallowed = $layoutSetups[$backendLayout]['disallowed'][$gridColumn];
if ($container[1] > 0 && (!empty($allowed) || !empty($disallowed))) {
if ((
!empty($allowed) &&
!isset($allowed['CType']['*']) &&
!isset($allowed['CType'][$contentType])
) ||
(
!empty($disallowed) &&
(
isset($disallowed['CType']['*']) ||
isset($disallowed['CType'][$contentType])
)
)) {
unset($params['items'][$key]);
}
if (!empty($listType)) {
if ((
!empty($allowed) &&
!isset($allowed['CType']['*']) &&
!(
isset($allowed['list_type']['*']) ||
isset($allowed['list_type'][$listType])
)
) ||
(
!empty($disallowed) &&
(
isset($disallowed['CType']['*']) ||
isset($disallowed['list_type']['*']) ||
isset($disallowed['list_type'][$listType])
)
)) {
unset($params['items'][$key]);
}
}
}
}
}
} | php | public function deleteDisallowedContainers(array &$params, $itemUidList = '')
{
$contentType = is_array($params['row']['CType']) ? $params['row']['CType'][0] : $params['row']['CType'];
$listType = '';
if ($contentType === 'list') {
$listType = is_array($params['row']['list_type']) ? $params['row']['list_type'][0] : $params['row']['list_type'];
}
$layoutSetups = $this->layoutSetup->getLayoutSetup();
if ($itemUidList) {
$itemUidList = GeneralUtility::intExplode(',', $itemUidList);
$queryBuilder = $this->getQueryBuilder();
$containerQuery = $queryBuilder
->select('uid', 'tx_gridelements_backend_layout')
->from('tt_content')
->where(
$queryBuilder->expr()->in(
'uid',
$queryBuilder->createNamedParameter($itemUidList, Connection::PARAM_INT_ARRAY)
)
)
->execute();
$containers = [];
while ($container = $containerQuery->fetch()) {
$containers[$container['uid']] = $container;
}
foreach ($params['items'] as $key => $container) {
$backendLayout = $containers[$container[1]]['tx_gridelements_backend_layout'];
$gridColumn = $params['row']['tx_gridelements_columns'];
$allowed = $layoutSetups[$backendLayout]['allowed'][$gridColumn];
$disallowed = $layoutSetups[$backendLayout]['disallowed'][$gridColumn];
if ($container[1] > 0 && (!empty($allowed) || !empty($disallowed))) {
if ((
!empty($allowed) &&
!isset($allowed['CType']['*']) &&
!isset($allowed['CType'][$contentType])
) ||
(
!empty($disallowed) &&
(
isset($disallowed['CType']['*']) ||
isset($disallowed['CType'][$contentType])
)
)) {
unset($params['items'][$key]);
}
if (!empty($listType)) {
if ((
!empty($allowed) &&
!isset($allowed['CType']['*']) &&
!(
isset($allowed['list_type']['*']) ||
isset($allowed['list_type'][$listType])
)
) ||
(
!empty($disallowed) &&
(
isset($disallowed['CType']['*']) ||
isset($disallowed['list_type']['*']) ||
isset($disallowed['list_type'][$listType])
)
)) {
unset($params['items'][$key]);
}
}
}
}
}
} | [
"public",
"function",
"deleteDisallowedContainers",
"(",
"array",
"&",
"$",
"params",
",",
"$",
"itemUidList",
"=",
"''",
")",
"{",
"$",
"contentType",
"=",
"is_array",
"(",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'CType'",
"]",
")",
"?",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'CType'",
"]",
"[",
"0",
"]",
":",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'CType'",
"]",
";",
"$",
"listType",
"=",
"''",
";",
"if",
"(",
"$",
"contentType",
"===",
"'list'",
")",
"{",
"$",
"listType",
"=",
"is_array",
"(",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'list_type'",
"]",
")",
"?",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'list_type'",
"]",
"[",
"0",
"]",
":",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'list_type'",
"]",
";",
"}",
"$",
"layoutSetups",
"=",
"$",
"this",
"->",
"layoutSetup",
"->",
"getLayoutSetup",
"(",
")",
";",
"if",
"(",
"$",
"itemUidList",
")",
"{",
"$",
"itemUidList",
"=",
"GeneralUtility",
"::",
"intExplode",
"(",
"','",
",",
"$",
"itemUidList",
")",
";",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
";",
"$",
"containerQuery",
"=",
"$",
"queryBuilder",
"->",
"select",
"(",
"'uid'",
",",
"'tx_gridelements_backend_layout'",
")",
"->",
"from",
"(",
"'tt_content'",
")",
"->",
"where",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"in",
"(",
"'uid'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"$",
"itemUidList",
",",
"Connection",
"::",
"PARAM_INT_ARRAY",
")",
")",
")",
"->",
"execute",
"(",
")",
";",
"$",
"containers",
"=",
"[",
"]",
";",
"while",
"(",
"$",
"container",
"=",
"$",
"containerQuery",
"->",
"fetch",
"(",
")",
")",
"{",
"$",
"containers",
"[",
"$",
"container",
"[",
"'uid'",
"]",
"]",
"=",
"$",
"container",
";",
"}",
"foreach",
"(",
"$",
"params",
"[",
"'items'",
"]",
"as",
"$",
"key",
"=>",
"$",
"container",
")",
"{",
"$",
"backendLayout",
"=",
"$",
"containers",
"[",
"$",
"container",
"[",
"1",
"]",
"]",
"[",
"'tx_gridelements_backend_layout'",
"]",
";",
"$",
"gridColumn",
"=",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'tx_gridelements_columns'",
"]",
";",
"$",
"allowed",
"=",
"$",
"layoutSetups",
"[",
"$",
"backendLayout",
"]",
"[",
"'allowed'",
"]",
"[",
"$",
"gridColumn",
"]",
";",
"$",
"disallowed",
"=",
"$",
"layoutSetups",
"[",
"$",
"backendLayout",
"]",
"[",
"'disallowed'",
"]",
"[",
"$",
"gridColumn",
"]",
";",
"if",
"(",
"$",
"container",
"[",
"1",
"]",
">",
"0",
"&&",
"(",
"!",
"empty",
"(",
"$",
"allowed",
")",
"||",
"!",
"empty",
"(",
"$",
"disallowed",
")",
")",
")",
"{",
"if",
"(",
"(",
"!",
"empty",
"(",
"$",
"allowed",
")",
"&&",
"!",
"isset",
"(",
"$",
"allowed",
"[",
"'CType'",
"]",
"[",
"'*'",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"allowed",
"[",
"'CType'",
"]",
"[",
"$",
"contentType",
"]",
")",
")",
"||",
"(",
"!",
"empty",
"(",
"$",
"disallowed",
")",
"&&",
"(",
"isset",
"(",
"$",
"disallowed",
"[",
"'CType'",
"]",
"[",
"'*'",
"]",
")",
"||",
"isset",
"(",
"$",
"disallowed",
"[",
"'CType'",
"]",
"[",
"$",
"contentType",
"]",
")",
")",
")",
")",
"{",
"unset",
"(",
"$",
"params",
"[",
"'items'",
"]",
"[",
"$",
"key",
"]",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"listType",
")",
")",
"{",
"if",
"(",
"(",
"!",
"empty",
"(",
"$",
"allowed",
")",
"&&",
"!",
"isset",
"(",
"$",
"allowed",
"[",
"'CType'",
"]",
"[",
"'*'",
"]",
")",
"&&",
"!",
"(",
"isset",
"(",
"$",
"allowed",
"[",
"'list_type'",
"]",
"[",
"'*'",
"]",
")",
"||",
"isset",
"(",
"$",
"allowed",
"[",
"'list_type'",
"]",
"[",
"$",
"listType",
"]",
")",
")",
")",
"||",
"(",
"!",
"empty",
"(",
"$",
"disallowed",
")",
"&&",
"(",
"isset",
"(",
"$",
"disallowed",
"[",
"'CType'",
"]",
"[",
"'*'",
"]",
")",
"||",
"isset",
"(",
"$",
"disallowed",
"[",
"'list_type'",
"]",
"[",
"'*'",
"]",
")",
"||",
"isset",
"(",
"$",
"disallowed",
"[",
"'list_type'",
"]",
"[",
"$",
"listType",
"]",
")",
")",
")",
")",
"{",
"unset",
"(",
"$",
"params",
"[",
"'items'",
"]",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}"
] | delete containers from params which are not allowed
@param array $params
@param string $itemUidList comma separated list of uids | [
"delete",
"containers",
"from",
"params",
"which",
"are",
"not",
"allowed"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/TtContent.php#L215-L283 |
TYPO3-extensions/gridelements | Classes/Backend/TtContent.php | TtContent.layoutItemsProcFunc | public function layoutItemsProcFunc(array &$params)
{
$this->init($params['row']['pid']);
$layoutSelectItems = $this->layoutSetup->getLayoutSelectItems(
isset($params['row']['colPos'][0]) ? $params['row']['colPos'][0] : $params['row']['colPos'],
$params['row']['tx_gridelements_columns'],
$params['row']['tx_gridelements_container'],
$this->layoutSetup->getRealPid()
);
$params['items'] = ArrayUtility::keepItemsInArray($layoutSelectItems, $params['items'], true);
} | php | public function layoutItemsProcFunc(array &$params)
{
$this->init($params['row']['pid']);
$layoutSelectItems = $this->layoutSetup->getLayoutSelectItems(
isset($params['row']['colPos'][0]) ? $params['row']['colPos'][0] : $params['row']['colPos'],
$params['row']['tx_gridelements_columns'],
$params['row']['tx_gridelements_container'],
$this->layoutSetup->getRealPid()
);
$params['items'] = ArrayUtility::keepItemsInArray($layoutSelectItems, $params['items'], true);
} | [
"public",
"function",
"layoutItemsProcFunc",
"(",
"array",
"&",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"init",
"(",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'pid'",
"]",
")",
";",
"$",
"layoutSelectItems",
"=",
"$",
"this",
"->",
"layoutSetup",
"->",
"getLayoutSelectItems",
"(",
"isset",
"(",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'colPos'",
"]",
"[",
"0",
"]",
")",
"?",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'colPos'",
"]",
"[",
"0",
"]",
":",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'colPos'",
"]",
",",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'tx_gridelements_columns'",
"]",
",",
"$",
"params",
"[",
"'row'",
"]",
"[",
"'tx_gridelements_container'",
"]",
",",
"$",
"this",
"->",
"layoutSetup",
"->",
"getRealPid",
"(",
")",
")",
";",
"$",
"params",
"[",
"'items'",
"]",
"=",
"ArrayUtility",
"::",
"keepItemsInArray",
"(",
"$",
"layoutSelectItems",
",",
"$",
"params",
"[",
"'items'",
"]",
",",
"true",
")",
";",
"}"
] | ItemProcFunc for layout items
removes items that are available for grid boxes on the first level only
and items that are excluded for a certain branch or user
@param array $params An array containing the items and parameters for the list of items | [
"ItemProcFunc",
"for",
"layout",
"items",
"removes",
"items",
"that",
"are",
"available",
"for",
"grid",
"boxes",
"on",
"the",
"first",
"level",
"only",
"and",
"items",
"that",
"are",
"excluded",
"for",
"a",
"certain",
"branch",
"or",
"user"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/TtContent.php#L292-L302 |
TYPO3-extensions/gridelements | Classes/Backend/LayoutSetup.php | LayoutSetup.init | public function init($pageId, array $typoScriptSetup = [])
{
$this->setLanguageService($GLOBALS['LANG']);
$pageId = (strpos($pageId, 'NEW') === 0) ? 0 : (int)$pageId;
if ((int)$pageId < 0) {
$pageId = Helper::getInstance()->getPidFromUid($pageId);
}
$this->realPid = $pageId;
$this->loadLayoutSetup($pageId);
foreach ($this->layoutSetup as $key => $setup) {
$columns = $this->getLayoutColumns($key);
if ($columns['allowed'] || $columns['disallowed'] || $columns['maxitems']) {
$this->layoutSetup[$key]['columns'] = $columns;
unset($this->layoutSetup[$key]['columns']['allowed']);
$this->layoutSetup[$key]['allowed'] = $columns['allowed'] ?: [];
$this->layoutSetup[$key]['disallowed'] = $columns['disallowed'] ?: [];
$this->layoutSetup[$key]['maxitems'] = $columns['maxitems'] ?: [];
}
}
$this->setTypoScriptSetup($typoScriptSetup);
return $this;
} | php | public function init($pageId, array $typoScriptSetup = [])
{
$this->setLanguageService($GLOBALS['LANG']);
$pageId = (strpos($pageId, 'NEW') === 0) ? 0 : (int)$pageId;
if ((int)$pageId < 0) {
$pageId = Helper::getInstance()->getPidFromUid($pageId);
}
$this->realPid = $pageId;
$this->loadLayoutSetup($pageId);
foreach ($this->layoutSetup as $key => $setup) {
$columns = $this->getLayoutColumns($key);
if ($columns['allowed'] || $columns['disallowed'] || $columns['maxitems']) {
$this->layoutSetup[$key]['columns'] = $columns;
unset($this->layoutSetup[$key]['columns']['allowed']);
$this->layoutSetup[$key]['allowed'] = $columns['allowed'] ?: [];
$this->layoutSetup[$key]['disallowed'] = $columns['disallowed'] ?: [];
$this->layoutSetup[$key]['maxitems'] = $columns['maxitems'] ?: [];
}
}
$this->setTypoScriptSetup($typoScriptSetup);
return $this;
} | [
"public",
"function",
"init",
"(",
"$",
"pageId",
",",
"array",
"$",
"typoScriptSetup",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"setLanguageService",
"(",
"$",
"GLOBALS",
"[",
"'LANG'",
"]",
")",
";",
"$",
"pageId",
"=",
"(",
"strpos",
"(",
"$",
"pageId",
",",
"'NEW'",
")",
"===",
"0",
")",
"?",
"0",
":",
"(",
"int",
")",
"$",
"pageId",
";",
"if",
"(",
"(",
"int",
")",
"$",
"pageId",
"<",
"0",
")",
"{",
"$",
"pageId",
"=",
"Helper",
"::",
"getInstance",
"(",
")",
"->",
"getPidFromUid",
"(",
"$",
"pageId",
")",
";",
"}",
"$",
"this",
"->",
"realPid",
"=",
"$",
"pageId",
";",
"$",
"this",
"->",
"loadLayoutSetup",
"(",
"$",
"pageId",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"layoutSetup",
"as",
"$",
"key",
"=>",
"$",
"setup",
")",
"{",
"$",
"columns",
"=",
"$",
"this",
"->",
"getLayoutColumns",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"columns",
"[",
"'allowed'",
"]",
"||",
"$",
"columns",
"[",
"'disallowed'",
"]",
"||",
"$",
"columns",
"[",
"'maxitems'",
"]",
")",
"{",
"$",
"this",
"->",
"layoutSetup",
"[",
"$",
"key",
"]",
"[",
"'columns'",
"]",
"=",
"$",
"columns",
";",
"unset",
"(",
"$",
"this",
"->",
"layoutSetup",
"[",
"$",
"key",
"]",
"[",
"'columns'",
"]",
"[",
"'allowed'",
"]",
")",
";",
"$",
"this",
"->",
"layoutSetup",
"[",
"$",
"key",
"]",
"[",
"'allowed'",
"]",
"=",
"$",
"columns",
"[",
"'allowed'",
"]",
"?",
":",
"[",
"]",
";",
"$",
"this",
"->",
"layoutSetup",
"[",
"$",
"key",
"]",
"[",
"'disallowed'",
"]",
"=",
"$",
"columns",
"[",
"'disallowed'",
"]",
"?",
":",
"[",
"]",
";",
"$",
"this",
"->",
"layoutSetup",
"[",
"$",
"key",
"]",
"[",
"'maxitems'",
"]",
"=",
"$",
"columns",
"[",
"'maxitems'",
"]",
"?",
":",
"[",
"]",
";",
"}",
"}",
"$",
"this",
"->",
"setTypoScriptSetup",
"(",
"$",
"typoScriptSetup",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Load page TSconfig
@param int $pageId The current page ID
@param array $typoScriptSetup The PlugIn configuration
@return LayoutSetup | [
"Load",
"page",
"TSconfig"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/LayoutSetup.php#L82-L103 |
TYPO3-extensions/gridelements | Classes/Backend/LayoutSetup.php | LayoutSetup.loadLayoutSetup | protected function loadLayoutSetup($pageId)
{
// Load page TSconfig.
if (\TYPO3_MODE === 'FE') {
$pageTSconfig = $GLOBALS['TSFE']->getPagesTSconfig();
} else {
$pageTSconfig = BackendUtility::getPagesTSconfig($pageId);
}
$excludeLayoutIds = !empty($pageTSconfig['tx_gridelements.']['excludeLayoutIds'])
? array_flip(GeneralUtility::trimExplode(',', $pageTSconfig['tx_gridelements.']['excludeLayoutIds']))
: [];
$overruleRecords = isset($pageTSconfig['tx_gridelements.']['overruleRecords'])
&& (int)$pageTSconfig['tx_gridelements.']['overruleRecords'] === 1;
$gridLayoutConfig = [];
if (!empty($pageTSconfig['tx_gridelements.']['setup.'])) {
foreach ($pageTSconfig['tx_gridelements.']['setup.'] as $layoutId => $item) {
// remove tailing dot of layout ID
$layoutId = rtrim($layoutId, '.');
// Continue if layout is excluded.
if (isset($excludeLayoutIds[$layoutId])) {
continue;
}
// Parse icon path for records.
if ($item['icon']) {
$icons = explode(',', $item['icon']);
foreach ($icons as &$icon) {
$icon = trim($icon);
if (strpos($icon, 'EXT:') === 0) {
$icon = str_replace(PATH_site, '../', GeneralUtility::getFileAbsFileName($icon));
}
}
$item['icon'] = $icons;
}
// remove tailing dot of config
if (isset($item['config.'])) {
$item['config'] = $item['config.'];
unset($item['config.']);
if (isset($item['backend_layout.'])) {
$item['config'] = $item['backend_layout.'];
}
unset($item['backend_layout.']);
}
// Change topLevelLayout to top_level_layout.
$item['top_level_layout'] = $item['topLevelLayout'];
unset($item['topLevelLayout']);
// Change flexformDS to pi_flexform_ds.
$item['pi_flexform_ds'] = $item['flexformDS'];
unset($item['flexformDS']);
$gridLayoutConfig[$layoutId] = $item;
}
}
$storagePid = isset($pageTSconfig['TCEFORM.']['pages.']['_STORAGE_PID'])
? (int)$pageTSconfig['TCEFORM.']['pages.']['_STORAGE_PID']
: 0;
$pageTSconfigId = isset($pageTSconfig['TCEFORM.']['tt_content.']['tx_gridelements_backend_layout.']['PAGE_TSCONFIG_ID'])
? implode(',', GeneralUtility::intExplode(
',',
$pageTSconfig['TCEFORM.']['tt_content.']['tx_gridelements_backend_layout.']['PAGE_TSCONFIG_ID']
))
: 0;
// Load records.
$queryBuilder = $this->getQueryBuilder();
$layoutQuery = $queryBuilder
->select('*')
->from('tx_gridelements_backend_layout')
->where(
$queryBuilder->expr()->orX(
$queryBuilder->expr()->andX(
$queryBuilder->expr()->comparison($pageTSconfigId, '=', 0),
$queryBuilder->expr()->comparison($storagePid, '=', 0)
),
$queryBuilder->expr()->orX(
$queryBuilder->expr()->eq(
'pid',
$queryBuilder->createNamedParameter((int)$pageTSconfigId, \PDO::PARAM_INT)
),
$queryBuilder->expr()->eq(
'pid',
$queryBuilder->createNamedParameter((int)$storagePid, \PDO::PARAM_INT)
)
),
$queryBuilder->expr()->andX(
$queryBuilder->expr()->comparison($pageTSconfigId, '=', 0),
$queryBuilder->expr()->eq(
'pid',
$queryBuilder->createNamedParameter((int)$pageId, \PDO::PARAM_INT)
)
)
)
)
->orderBy('sorting', 'ASC');
$layoutItems = $layoutQuery->execute()->fetchAll();
$gridLayoutRecords = [];
foreach ($layoutItems as $item) {
if (isset($item['alias']) && (string)$item['alias'] !== '') {
$layoutId = $item['alias'];
} else {
$layoutId = $item['uid'];
}
// Continue if layout is excluded.
if (isset($excludeLayoutIds[$layoutId])) {
continue;
}
// Prepend icon path for records.
if ($item['icon']) {
$icons = explode(',', $item['icon']);
foreach ($icons as &$icon) {
$icon = '../' . $GLOBALS['TCA']['tx_gridelements_backend_layout']['ctrl']['selicon_field_path'] . '/' . htmlspecialchars(trim($icon));
}
$item['icon'] = $icons;
}
// parse config
if ($item['config']) {
$parser = GeneralUtility::makeInstance(TypoScriptParser::class);
$parser->parse($parser->checkIncludeLines($item['config']));
if (isset($parser->setup['backend_layout.'])) {
$item['config'] = $parser->setup['backend_layout.'];
}
}
$gridLayoutRecords[$layoutId] = $item;
}
if ($overruleRecords === true) {
ArrayUtility::mergeRecursiveWithOverrule($gridLayoutRecords, $gridLayoutConfig, true, false);
$this->setLayoutSetup($gridLayoutRecords);
} else {
ArrayUtility::mergeRecursiveWithOverrule($gridLayoutConfig, $gridLayoutRecords, true, false);
$this->setLayoutSetup($gridLayoutConfig);
}
} | php | protected function loadLayoutSetup($pageId)
{
// Load page TSconfig.
if (\TYPO3_MODE === 'FE') {
$pageTSconfig = $GLOBALS['TSFE']->getPagesTSconfig();
} else {
$pageTSconfig = BackendUtility::getPagesTSconfig($pageId);
}
$excludeLayoutIds = !empty($pageTSconfig['tx_gridelements.']['excludeLayoutIds'])
? array_flip(GeneralUtility::trimExplode(',', $pageTSconfig['tx_gridelements.']['excludeLayoutIds']))
: [];
$overruleRecords = isset($pageTSconfig['tx_gridelements.']['overruleRecords'])
&& (int)$pageTSconfig['tx_gridelements.']['overruleRecords'] === 1;
$gridLayoutConfig = [];
if (!empty($pageTSconfig['tx_gridelements.']['setup.'])) {
foreach ($pageTSconfig['tx_gridelements.']['setup.'] as $layoutId => $item) {
// remove tailing dot of layout ID
$layoutId = rtrim($layoutId, '.');
// Continue if layout is excluded.
if (isset($excludeLayoutIds[$layoutId])) {
continue;
}
// Parse icon path for records.
if ($item['icon']) {
$icons = explode(',', $item['icon']);
foreach ($icons as &$icon) {
$icon = trim($icon);
if (strpos($icon, 'EXT:') === 0) {
$icon = str_replace(PATH_site, '../', GeneralUtility::getFileAbsFileName($icon));
}
}
$item['icon'] = $icons;
}
// remove tailing dot of config
if (isset($item['config.'])) {
$item['config'] = $item['config.'];
unset($item['config.']);
if (isset($item['backend_layout.'])) {
$item['config'] = $item['backend_layout.'];
}
unset($item['backend_layout.']);
}
// Change topLevelLayout to top_level_layout.
$item['top_level_layout'] = $item['topLevelLayout'];
unset($item['topLevelLayout']);
// Change flexformDS to pi_flexform_ds.
$item['pi_flexform_ds'] = $item['flexformDS'];
unset($item['flexformDS']);
$gridLayoutConfig[$layoutId] = $item;
}
}
$storagePid = isset($pageTSconfig['TCEFORM.']['pages.']['_STORAGE_PID'])
? (int)$pageTSconfig['TCEFORM.']['pages.']['_STORAGE_PID']
: 0;
$pageTSconfigId = isset($pageTSconfig['TCEFORM.']['tt_content.']['tx_gridelements_backend_layout.']['PAGE_TSCONFIG_ID'])
? implode(',', GeneralUtility::intExplode(
',',
$pageTSconfig['TCEFORM.']['tt_content.']['tx_gridelements_backend_layout.']['PAGE_TSCONFIG_ID']
))
: 0;
// Load records.
$queryBuilder = $this->getQueryBuilder();
$layoutQuery = $queryBuilder
->select('*')
->from('tx_gridelements_backend_layout')
->where(
$queryBuilder->expr()->orX(
$queryBuilder->expr()->andX(
$queryBuilder->expr()->comparison($pageTSconfigId, '=', 0),
$queryBuilder->expr()->comparison($storagePid, '=', 0)
),
$queryBuilder->expr()->orX(
$queryBuilder->expr()->eq(
'pid',
$queryBuilder->createNamedParameter((int)$pageTSconfigId, \PDO::PARAM_INT)
),
$queryBuilder->expr()->eq(
'pid',
$queryBuilder->createNamedParameter((int)$storagePid, \PDO::PARAM_INT)
)
),
$queryBuilder->expr()->andX(
$queryBuilder->expr()->comparison($pageTSconfigId, '=', 0),
$queryBuilder->expr()->eq(
'pid',
$queryBuilder->createNamedParameter((int)$pageId, \PDO::PARAM_INT)
)
)
)
)
->orderBy('sorting', 'ASC');
$layoutItems = $layoutQuery->execute()->fetchAll();
$gridLayoutRecords = [];
foreach ($layoutItems as $item) {
if (isset($item['alias']) && (string)$item['alias'] !== '') {
$layoutId = $item['alias'];
} else {
$layoutId = $item['uid'];
}
// Continue if layout is excluded.
if (isset($excludeLayoutIds[$layoutId])) {
continue;
}
// Prepend icon path for records.
if ($item['icon']) {
$icons = explode(',', $item['icon']);
foreach ($icons as &$icon) {
$icon = '../' . $GLOBALS['TCA']['tx_gridelements_backend_layout']['ctrl']['selicon_field_path'] . '/' . htmlspecialchars(trim($icon));
}
$item['icon'] = $icons;
}
// parse config
if ($item['config']) {
$parser = GeneralUtility::makeInstance(TypoScriptParser::class);
$parser->parse($parser->checkIncludeLines($item['config']));
if (isset($parser->setup['backend_layout.'])) {
$item['config'] = $parser->setup['backend_layout.'];
}
}
$gridLayoutRecords[$layoutId] = $item;
}
if ($overruleRecords === true) {
ArrayUtility::mergeRecursiveWithOverrule($gridLayoutRecords, $gridLayoutConfig, true, false);
$this->setLayoutSetup($gridLayoutRecords);
} else {
ArrayUtility::mergeRecursiveWithOverrule($gridLayoutConfig, $gridLayoutRecords, true, false);
$this->setLayoutSetup($gridLayoutConfig);
}
} | [
"protected",
"function",
"loadLayoutSetup",
"(",
"$",
"pageId",
")",
"{",
"// Load page TSconfig.",
"if",
"(",
"\\",
"TYPO3_MODE",
"===",
"'FE'",
")",
"{",
"$",
"pageTSconfig",
"=",
"$",
"GLOBALS",
"[",
"'TSFE'",
"]",
"->",
"getPagesTSconfig",
"(",
")",
";",
"}",
"else",
"{",
"$",
"pageTSconfig",
"=",
"BackendUtility",
"::",
"getPagesTSconfig",
"(",
"$",
"pageId",
")",
";",
"}",
"$",
"excludeLayoutIds",
"=",
"!",
"empty",
"(",
"$",
"pageTSconfig",
"[",
"'tx_gridelements.'",
"]",
"[",
"'excludeLayoutIds'",
"]",
")",
"?",
"array_flip",
"(",
"GeneralUtility",
"::",
"trimExplode",
"(",
"','",
",",
"$",
"pageTSconfig",
"[",
"'tx_gridelements.'",
"]",
"[",
"'excludeLayoutIds'",
"]",
")",
")",
":",
"[",
"]",
";",
"$",
"overruleRecords",
"=",
"isset",
"(",
"$",
"pageTSconfig",
"[",
"'tx_gridelements.'",
"]",
"[",
"'overruleRecords'",
"]",
")",
"&&",
"(",
"int",
")",
"$",
"pageTSconfig",
"[",
"'tx_gridelements.'",
"]",
"[",
"'overruleRecords'",
"]",
"===",
"1",
";",
"$",
"gridLayoutConfig",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"pageTSconfig",
"[",
"'tx_gridelements.'",
"]",
"[",
"'setup.'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"pageTSconfig",
"[",
"'tx_gridelements.'",
"]",
"[",
"'setup.'",
"]",
"as",
"$",
"layoutId",
"=>",
"$",
"item",
")",
"{",
"// remove tailing dot of layout ID",
"$",
"layoutId",
"=",
"rtrim",
"(",
"$",
"layoutId",
",",
"'.'",
")",
";",
"// Continue if layout is excluded.",
"if",
"(",
"isset",
"(",
"$",
"excludeLayoutIds",
"[",
"$",
"layoutId",
"]",
")",
")",
"{",
"continue",
";",
"}",
"// Parse icon path for records.",
"if",
"(",
"$",
"item",
"[",
"'icon'",
"]",
")",
"{",
"$",
"icons",
"=",
"explode",
"(",
"','",
",",
"$",
"item",
"[",
"'icon'",
"]",
")",
";",
"foreach",
"(",
"$",
"icons",
"as",
"&",
"$",
"icon",
")",
"{",
"$",
"icon",
"=",
"trim",
"(",
"$",
"icon",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"icon",
",",
"'EXT:'",
")",
"===",
"0",
")",
"{",
"$",
"icon",
"=",
"str_replace",
"(",
"PATH_site",
",",
"'../'",
",",
"GeneralUtility",
"::",
"getFileAbsFileName",
"(",
"$",
"icon",
")",
")",
";",
"}",
"}",
"$",
"item",
"[",
"'icon'",
"]",
"=",
"$",
"icons",
";",
"}",
"// remove tailing dot of config",
"if",
"(",
"isset",
"(",
"$",
"item",
"[",
"'config.'",
"]",
")",
")",
"{",
"$",
"item",
"[",
"'config'",
"]",
"=",
"$",
"item",
"[",
"'config.'",
"]",
";",
"unset",
"(",
"$",
"item",
"[",
"'config.'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"item",
"[",
"'backend_layout.'",
"]",
")",
")",
"{",
"$",
"item",
"[",
"'config'",
"]",
"=",
"$",
"item",
"[",
"'backend_layout.'",
"]",
";",
"}",
"unset",
"(",
"$",
"item",
"[",
"'backend_layout.'",
"]",
")",
";",
"}",
"// Change topLevelLayout to top_level_layout.",
"$",
"item",
"[",
"'top_level_layout'",
"]",
"=",
"$",
"item",
"[",
"'topLevelLayout'",
"]",
";",
"unset",
"(",
"$",
"item",
"[",
"'topLevelLayout'",
"]",
")",
";",
"// Change flexformDS to pi_flexform_ds.",
"$",
"item",
"[",
"'pi_flexform_ds'",
"]",
"=",
"$",
"item",
"[",
"'flexformDS'",
"]",
";",
"unset",
"(",
"$",
"item",
"[",
"'flexformDS'",
"]",
")",
";",
"$",
"gridLayoutConfig",
"[",
"$",
"layoutId",
"]",
"=",
"$",
"item",
";",
"}",
"}",
"$",
"storagePid",
"=",
"isset",
"(",
"$",
"pageTSconfig",
"[",
"'TCEFORM.'",
"]",
"[",
"'pages.'",
"]",
"[",
"'_STORAGE_PID'",
"]",
")",
"?",
"(",
"int",
")",
"$",
"pageTSconfig",
"[",
"'TCEFORM.'",
"]",
"[",
"'pages.'",
"]",
"[",
"'_STORAGE_PID'",
"]",
":",
"0",
";",
"$",
"pageTSconfigId",
"=",
"isset",
"(",
"$",
"pageTSconfig",
"[",
"'TCEFORM.'",
"]",
"[",
"'tt_content.'",
"]",
"[",
"'tx_gridelements_backend_layout.'",
"]",
"[",
"'PAGE_TSCONFIG_ID'",
"]",
")",
"?",
"implode",
"(",
"','",
",",
"GeneralUtility",
"::",
"intExplode",
"(",
"','",
",",
"$",
"pageTSconfig",
"[",
"'TCEFORM.'",
"]",
"[",
"'tt_content.'",
"]",
"[",
"'tx_gridelements_backend_layout.'",
"]",
"[",
"'PAGE_TSCONFIG_ID'",
"]",
")",
")",
":",
"0",
";",
"// Load records.",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
";",
"$",
"layoutQuery",
"=",
"$",
"queryBuilder",
"->",
"select",
"(",
"'*'",
")",
"->",
"from",
"(",
"'tx_gridelements_backend_layout'",
")",
"->",
"where",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"orX",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"andX",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"comparison",
"(",
"$",
"pageTSconfigId",
",",
"'='",
",",
"0",
")",
",",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"comparison",
"(",
"$",
"storagePid",
",",
"'='",
",",
"0",
")",
")",
",",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"orX",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'pid'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"(",
"int",
")",
"$",
"pageTSconfigId",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
")",
",",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'pid'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"(",
"int",
")",
"$",
"storagePid",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
")",
")",
",",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"andX",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"comparison",
"(",
"$",
"pageTSconfigId",
",",
"'='",
",",
"0",
")",
",",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'pid'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"(",
"int",
")",
"$",
"pageId",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
")",
")",
")",
")",
"->",
"orderBy",
"(",
"'sorting'",
",",
"'ASC'",
")",
";",
"$",
"layoutItems",
"=",
"$",
"layoutQuery",
"->",
"execute",
"(",
")",
"->",
"fetchAll",
"(",
")",
";",
"$",
"gridLayoutRecords",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"layoutItems",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"item",
"[",
"'alias'",
"]",
")",
"&&",
"(",
"string",
")",
"$",
"item",
"[",
"'alias'",
"]",
"!==",
"''",
")",
"{",
"$",
"layoutId",
"=",
"$",
"item",
"[",
"'alias'",
"]",
";",
"}",
"else",
"{",
"$",
"layoutId",
"=",
"$",
"item",
"[",
"'uid'",
"]",
";",
"}",
"// Continue if layout is excluded.",
"if",
"(",
"isset",
"(",
"$",
"excludeLayoutIds",
"[",
"$",
"layoutId",
"]",
")",
")",
"{",
"continue",
";",
"}",
"// Prepend icon path for records.",
"if",
"(",
"$",
"item",
"[",
"'icon'",
"]",
")",
"{",
"$",
"icons",
"=",
"explode",
"(",
"','",
",",
"$",
"item",
"[",
"'icon'",
"]",
")",
";",
"foreach",
"(",
"$",
"icons",
"as",
"&",
"$",
"icon",
")",
"{",
"$",
"icon",
"=",
"'../'",
".",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"'tx_gridelements_backend_layout'",
"]",
"[",
"'ctrl'",
"]",
"[",
"'selicon_field_path'",
"]",
".",
"'/'",
".",
"htmlspecialchars",
"(",
"trim",
"(",
"$",
"icon",
")",
")",
";",
"}",
"$",
"item",
"[",
"'icon'",
"]",
"=",
"$",
"icons",
";",
"}",
"// parse config",
"if",
"(",
"$",
"item",
"[",
"'config'",
"]",
")",
"{",
"$",
"parser",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"TypoScriptParser",
"::",
"class",
")",
";",
"$",
"parser",
"->",
"parse",
"(",
"$",
"parser",
"->",
"checkIncludeLines",
"(",
"$",
"item",
"[",
"'config'",
"]",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"parser",
"->",
"setup",
"[",
"'backend_layout.'",
"]",
")",
")",
"{",
"$",
"item",
"[",
"'config'",
"]",
"=",
"$",
"parser",
"->",
"setup",
"[",
"'backend_layout.'",
"]",
";",
"}",
"}",
"$",
"gridLayoutRecords",
"[",
"$",
"layoutId",
"]",
"=",
"$",
"item",
";",
"}",
"if",
"(",
"$",
"overruleRecords",
"===",
"true",
")",
"{",
"ArrayUtility",
"::",
"mergeRecursiveWithOverrule",
"(",
"$",
"gridLayoutRecords",
",",
"$",
"gridLayoutConfig",
",",
"true",
",",
"false",
")",
";",
"$",
"this",
"->",
"setLayoutSetup",
"(",
"$",
"gridLayoutRecords",
")",
";",
"}",
"else",
"{",
"ArrayUtility",
"::",
"mergeRecursiveWithOverrule",
"(",
"$",
"gridLayoutConfig",
",",
"$",
"gridLayoutRecords",
",",
"true",
",",
"false",
")",
";",
"$",
"this",
"->",
"setLayoutSetup",
"(",
"$",
"gridLayoutConfig",
")",
";",
"}",
"}"
] | Returns the page TSconfig merged with the grid layout records
@param int $pageId The uid of the page we are currently working on | [
"Returns",
"the",
"page",
"TSconfig",
"merged",
"with",
"the",
"grid",
"layout",
"records"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/LayoutSetup.php#L110-L255 |
TYPO3-extensions/gridelements | Classes/Backend/LayoutSetup.php | LayoutSetup.getQueryBuilder | public function getQueryBuilder()
{
/** @var $queryBuilder QueryBuilder */
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_gridelements_backend_layout');
$queryBuilder->getRestrictions()
->removeAll()
->add(GeneralUtility::makeInstance(DeletedRestriction::class))
->add(GeneralUtility::makeInstance(HiddenRestriction::class));
return $queryBuilder;
} | php | public function getQueryBuilder()
{
/** @var $queryBuilder QueryBuilder */
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_gridelements_backend_layout');
$queryBuilder->getRestrictions()
->removeAll()
->add(GeneralUtility::makeInstance(DeletedRestriction::class))
->add(GeneralUtility::makeInstance(HiddenRestriction::class));
return $queryBuilder;
} | [
"public",
"function",
"getQueryBuilder",
"(",
")",
"{",
"/** @var $queryBuilder QueryBuilder */",
"$",
"queryBuilder",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"ConnectionPool",
"::",
"class",
")",
"->",
"getQueryBuilderForTable",
"(",
"'tx_gridelements_backend_layout'",
")",
";",
"$",
"queryBuilder",
"->",
"getRestrictions",
"(",
")",
"->",
"removeAll",
"(",
")",
"->",
"add",
"(",
"GeneralUtility",
"::",
"makeInstance",
"(",
"DeletedRestriction",
"::",
"class",
")",
")",
"->",
"add",
"(",
"GeneralUtility",
"::",
"makeInstance",
"(",
"HiddenRestriction",
"::",
"class",
")",
")",
";",
"return",
"$",
"queryBuilder",
";",
"}"
] | getter for queryBuilder
@return QueryBuilder queryBuilder | [
"getter",
"for",
"queryBuilder"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/LayoutSetup.php#L262-L272 |
TYPO3-extensions/gridelements | Classes/Backend/LayoutSetup.php | LayoutSetup.getLayoutColumns | public function getLayoutColumns($layoutId)
{
if (!isset($this->layoutSetup[$layoutId])) {
return [];
}
if (empty($GLOBALS['tx_gridelements']['ceBackendLayoutData'][$layoutId])) {
if (!empty($this->layoutSetup[$layoutId]['config']['rows.'])) {
$GLOBALS['tx_gridelements']['ceBackendLayoutData'][$layoutId] = $this->checkAvailableColumns($this->layoutSetup[$layoutId]);
}
}
return $GLOBALS['tx_gridelements']['ceBackendLayoutData'][$layoutId];
} | php | public function getLayoutColumns($layoutId)
{
if (!isset($this->layoutSetup[$layoutId])) {
return [];
}
if (empty($GLOBALS['tx_gridelements']['ceBackendLayoutData'][$layoutId])) {
if (!empty($this->layoutSetup[$layoutId]['config']['rows.'])) {
$GLOBALS['tx_gridelements']['ceBackendLayoutData'][$layoutId] = $this->checkAvailableColumns($this->layoutSetup[$layoutId]);
}
}
return $GLOBALS['tx_gridelements']['ceBackendLayoutData'][$layoutId];
} | [
"public",
"function",
"getLayoutColumns",
"(",
"$",
"layoutId",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"layoutSetup",
"[",
"$",
"layoutId",
"]",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"GLOBALS",
"[",
"'tx_gridelements'",
"]",
"[",
"'ceBackendLayoutData'",
"]",
"[",
"$",
"layoutId",
"]",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"layoutSetup",
"[",
"$",
"layoutId",
"]",
"[",
"'config'",
"]",
"[",
"'rows.'",
"]",
")",
")",
"{",
"$",
"GLOBALS",
"[",
"'tx_gridelements'",
"]",
"[",
"'ceBackendLayoutData'",
"]",
"[",
"$",
"layoutId",
"]",
"=",
"$",
"this",
"->",
"checkAvailableColumns",
"(",
"$",
"this",
"->",
"layoutSetup",
"[",
"$",
"layoutId",
"]",
")",
";",
"}",
"}",
"return",
"$",
"GLOBALS",
"[",
"'tx_gridelements'",
"]",
"[",
"'ceBackendLayoutData'",
"]",
"[",
"$",
"layoutId",
"]",
";",
"}"
] | fetches all available columns for a certain grid container
@param string $layoutId The selected backend layout of the grid container
@return array first key is 'CSV' The columns available for the selected layout as CSV list and the allowed elements for each of the columns | [
"fetches",
"all",
"available",
"columns",
"for",
"a",
"certain",
"grid",
"container"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/LayoutSetup.php#L281-L294 |
TYPO3-extensions/gridelements | Classes/Backend/LayoutSetup.php | LayoutSetup.getTypoScriptSetup | public function getTypoScriptSetup($layoutId)
{
$typoScriptSetup = [];
if ($layoutId == '0' && isset($this->typoScriptSetup['setup.']['default.'])) {
$typoScriptSetup = $this->typoScriptSetup['setup.']['default.'];
} elseif ($layoutId && isset($this->typoScriptSetup['setup.'][$layoutId . '.'])) {
$typoScriptSetup = $this->typoScriptSetup['setup.'][$layoutId . '.'];
} elseif ($layoutId) {
$typoScriptSetup = $this->typoScriptSetup['setup.']['default.'];
}
// if there is none, we will use a reference to the tt_content setup as a default renderObj
// without additional stdWrap functionality
if (empty($typoScriptSetup)) {
$typoScriptSetup['columns.']['default.']['renderObj'] = '<tt_content';
}
return $typoScriptSetup;
} | php | public function getTypoScriptSetup($layoutId)
{
$typoScriptSetup = [];
if ($layoutId == '0' && isset($this->typoScriptSetup['setup.']['default.'])) {
$typoScriptSetup = $this->typoScriptSetup['setup.']['default.'];
} elseif ($layoutId && isset($this->typoScriptSetup['setup.'][$layoutId . '.'])) {
$typoScriptSetup = $this->typoScriptSetup['setup.'][$layoutId . '.'];
} elseif ($layoutId) {
$typoScriptSetup = $this->typoScriptSetup['setup.']['default.'];
}
// if there is none, we will use a reference to the tt_content setup as a default renderObj
// without additional stdWrap functionality
if (empty($typoScriptSetup)) {
$typoScriptSetup['columns.']['default.']['renderObj'] = '<tt_content';
}
return $typoScriptSetup;
} | [
"public",
"function",
"getTypoScriptSetup",
"(",
"$",
"layoutId",
")",
"{",
"$",
"typoScriptSetup",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"layoutId",
"==",
"'0'",
"&&",
"isset",
"(",
"$",
"this",
"->",
"typoScriptSetup",
"[",
"'setup.'",
"]",
"[",
"'default.'",
"]",
")",
")",
"{",
"$",
"typoScriptSetup",
"=",
"$",
"this",
"->",
"typoScriptSetup",
"[",
"'setup.'",
"]",
"[",
"'default.'",
"]",
";",
"}",
"elseif",
"(",
"$",
"layoutId",
"&&",
"isset",
"(",
"$",
"this",
"->",
"typoScriptSetup",
"[",
"'setup.'",
"]",
"[",
"$",
"layoutId",
".",
"'.'",
"]",
")",
")",
"{",
"$",
"typoScriptSetup",
"=",
"$",
"this",
"->",
"typoScriptSetup",
"[",
"'setup.'",
"]",
"[",
"$",
"layoutId",
".",
"'.'",
"]",
";",
"}",
"elseif",
"(",
"$",
"layoutId",
")",
"{",
"$",
"typoScriptSetup",
"=",
"$",
"this",
"->",
"typoScriptSetup",
"[",
"'setup.'",
"]",
"[",
"'default.'",
"]",
";",
"}",
"// if there is none, we will use a reference to the tt_content setup as a default renderObj",
"// without additional stdWrap functionality",
"if",
"(",
"empty",
"(",
"$",
"typoScriptSetup",
")",
")",
"{",
"$",
"typoScriptSetup",
"[",
"'columns.'",
"]",
"[",
"'default.'",
"]",
"[",
"'renderObj'",
"]",
"=",
"'<tt_content'",
";",
"}",
"return",
"$",
"typoScriptSetup",
";",
"}"
] | fetches the setup for each of the columns
assigns a default setup if there is none available
@param string $layoutId The selected backend layout of the grid container
@return array The adjusted TypoScript setup for the container or a default setup | [
"fetches",
"the",
"setup",
"for",
"each",
"of",
"the",
"columns",
"assigns",
"a",
"default",
"setup",
"if",
"there",
"is",
"none",
"available"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/LayoutSetup.php#L361-L380 |
TYPO3-extensions/gridelements | Classes/Backend/LayoutSetup.php | LayoutSetup.getLayoutSelectItems | public function getLayoutSelectItems($colPos, $gridColPos = 0, $containerId = 0, $pageId = 0)
{
$allowed = ['*' => '*'];
$disallowed = [];
$selectItems = [];
if ($containerId > 0) {
$container = $this->cacheCurrentParent((int)$containerId, true);
if (!empty($container)) {
$containerLayout = $this->layoutSetup[$container['tx_gridelements_backend_layout']];
$allowed = $containerLayout['allowed'][$gridColPos]['tx_gridelements_backend_layout'];
$disallowed = $containerLayout['disallowed'][$gridColPos]['tx_gridelements_backend_layout'];
}
} elseif ($pageId > 0) {
$pageLayout = Helper::getInstance()->getSelectedBackendLayout($pageId);
if (!empty($pageLayout)) {
$allowed = $pageLayout['allowed'][$colPos]['tx_gridelements_backend_layout'];
$disallowed = $pageLayout['disallowed'][$colPos]['tx_gridelements_backend_layout'];
}
}
foreach ($this->layoutSetup as $layoutId => $item) {
if ((
(int)$colPos === -1 &&
$item['top_level_layout']
) ||
(
!empty($allowed) &&
!isset($allowed['*']) &&
!isset($allowed[$layoutId])
) ||
(
!empty($disallowed) &&
(
isset($disallowed['*']) ||
isset($disallowed[$layoutId])
)
)) {
continue;
}
$icon = 'gridelements-default';
if ($item['iconIdentifier']) {
$icon = $item['iconIdentifier'];
} elseif (!empty($item['icon'])) {
if (is_array($item['icon']) && !empty($item['icon'][0])) {
$icon = $item['icon'][0];
} else {
$icon = $item['icon'];
}
if (StringUtility::beginsWith($icon, '../')) {
$icon = PATH_site . str_replace('../', '', $icon);
}
}
$selectItems[] = [$this->languageService->sL($item['title']), $layoutId, $icon];
}
return $selectItems;
} | php | public function getLayoutSelectItems($colPos, $gridColPos = 0, $containerId = 0, $pageId = 0)
{
$allowed = ['*' => '*'];
$disallowed = [];
$selectItems = [];
if ($containerId > 0) {
$container = $this->cacheCurrentParent((int)$containerId, true);
if (!empty($container)) {
$containerLayout = $this->layoutSetup[$container['tx_gridelements_backend_layout']];
$allowed = $containerLayout['allowed'][$gridColPos]['tx_gridelements_backend_layout'];
$disallowed = $containerLayout['disallowed'][$gridColPos]['tx_gridelements_backend_layout'];
}
} elseif ($pageId > 0) {
$pageLayout = Helper::getInstance()->getSelectedBackendLayout($pageId);
if (!empty($pageLayout)) {
$allowed = $pageLayout['allowed'][$colPos]['tx_gridelements_backend_layout'];
$disallowed = $pageLayout['disallowed'][$colPos]['tx_gridelements_backend_layout'];
}
}
foreach ($this->layoutSetup as $layoutId => $item) {
if ((
(int)$colPos === -1 &&
$item['top_level_layout']
) ||
(
!empty($allowed) &&
!isset($allowed['*']) &&
!isset($allowed[$layoutId])
) ||
(
!empty($disallowed) &&
(
isset($disallowed['*']) ||
isset($disallowed[$layoutId])
)
)) {
continue;
}
$icon = 'gridelements-default';
if ($item['iconIdentifier']) {
$icon = $item['iconIdentifier'];
} elseif (!empty($item['icon'])) {
if (is_array($item['icon']) && !empty($item['icon'][0])) {
$icon = $item['icon'][0];
} else {
$icon = $item['icon'];
}
if (StringUtility::beginsWith($icon, '../')) {
$icon = PATH_site . str_replace('../', '', $icon);
}
}
$selectItems[] = [$this->languageService->sL($item['title']), $layoutId, $icon];
}
return $selectItems;
} | [
"public",
"function",
"getLayoutSelectItems",
"(",
"$",
"colPos",
",",
"$",
"gridColPos",
"=",
"0",
",",
"$",
"containerId",
"=",
"0",
",",
"$",
"pageId",
"=",
"0",
")",
"{",
"$",
"allowed",
"=",
"[",
"'*'",
"=>",
"'*'",
"]",
";",
"$",
"disallowed",
"=",
"[",
"]",
";",
"$",
"selectItems",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"containerId",
">",
"0",
")",
"{",
"$",
"container",
"=",
"$",
"this",
"->",
"cacheCurrentParent",
"(",
"(",
"int",
")",
"$",
"containerId",
",",
"true",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"container",
")",
")",
"{",
"$",
"containerLayout",
"=",
"$",
"this",
"->",
"layoutSetup",
"[",
"$",
"container",
"[",
"'tx_gridelements_backend_layout'",
"]",
"]",
";",
"$",
"allowed",
"=",
"$",
"containerLayout",
"[",
"'allowed'",
"]",
"[",
"$",
"gridColPos",
"]",
"[",
"'tx_gridelements_backend_layout'",
"]",
";",
"$",
"disallowed",
"=",
"$",
"containerLayout",
"[",
"'disallowed'",
"]",
"[",
"$",
"gridColPos",
"]",
"[",
"'tx_gridelements_backend_layout'",
"]",
";",
"}",
"}",
"elseif",
"(",
"$",
"pageId",
">",
"0",
")",
"{",
"$",
"pageLayout",
"=",
"Helper",
"::",
"getInstance",
"(",
")",
"->",
"getSelectedBackendLayout",
"(",
"$",
"pageId",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"pageLayout",
")",
")",
"{",
"$",
"allowed",
"=",
"$",
"pageLayout",
"[",
"'allowed'",
"]",
"[",
"$",
"colPos",
"]",
"[",
"'tx_gridelements_backend_layout'",
"]",
";",
"$",
"disallowed",
"=",
"$",
"pageLayout",
"[",
"'disallowed'",
"]",
"[",
"$",
"colPos",
"]",
"[",
"'tx_gridelements_backend_layout'",
"]",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"layoutSetup",
"as",
"$",
"layoutId",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"(",
"(",
"int",
")",
"$",
"colPos",
"===",
"-",
"1",
"&&",
"$",
"item",
"[",
"'top_level_layout'",
"]",
")",
"||",
"(",
"!",
"empty",
"(",
"$",
"allowed",
")",
"&&",
"!",
"isset",
"(",
"$",
"allowed",
"[",
"'*'",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"allowed",
"[",
"$",
"layoutId",
"]",
")",
")",
"||",
"(",
"!",
"empty",
"(",
"$",
"disallowed",
")",
"&&",
"(",
"isset",
"(",
"$",
"disallowed",
"[",
"'*'",
"]",
")",
"||",
"isset",
"(",
"$",
"disallowed",
"[",
"$",
"layoutId",
"]",
")",
")",
")",
")",
"{",
"continue",
";",
"}",
"$",
"icon",
"=",
"'gridelements-default'",
";",
"if",
"(",
"$",
"item",
"[",
"'iconIdentifier'",
"]",
")",
"{",
"$",
"icon",
"=",
"$",
"item",
"[",
"'iconIdentifier'",
"]",
";",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"'icon'",
"]",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"item",
"[",
"'icon'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"item",
"[",
"'icon'",
"]",
"[",
"0",
"]",
")",
")",
"{",
"$",
"icon",
"=",
"$",
"item",
"[",
"'icon'",
"]",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"$",
"icon",
"=",
"$",
"item",
"[",
"'icon'",
"]",
";",
"}",
"if",
"(",
"StringUtility",
"::",
"beginsWith",
"(",
"$",
"icon",
",",
"'../'",
")",
")",
"{",
"$",
"icon",
"=",
"PATH_site",
".",
"str_replace",
"(",
"'../'",
",",
"''",
",",
"$",
"icon",
")",
";",
"}",
"}",
"$",
"selectItems",
"[",
"]",
"=",
"[",
"$",
"this",
"->",
"languageService",
"->",
"sL",
"(",
"$",
"item",
"[",
"'title'",
"]",
")",
",",
"$",
"layoutId",
",",
"$",
"icon",
"]",
";",
"}",
"return",
"$",
"selectItems",
";",
"}"
] | Returns the item array for form field selection.
@param int $colPos The selected content column position.
@param int $gridColPos
@param int $containerId
@param int $pageId
@return array | [
"Returns",
"the",
"item",
"array",
"for",
"form",
"field",
"selection",
"."
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/LayoutSetup.php#L423-L478 |
TYPO3-extensions/gridelements | Classes/Backend/LayoutSetup.php | LayoutSetup.cacheCurrentParent | public function cacheCurrentParent($gridContainerId = 0, $doReturn = false)
{
if ($gridContainerId > 0) {
if (empty($GLOBALS['tx_gridelements']['parentElement'][$gridContainerId])) {
$GLOBALS['tx_gridelements']['parentElement'][$gridContainerId] = BackendUtility::getRecordWSOL(
'tt_content',
$gridContainerId
);
}
}
if ($doReturn) {
return $GLOBALS['tx_gridelements']['parentElement'][$gridContainerId];
}
return null;
} | php | public function cacheCurrentParent($gridContainerId = 0, $doReturn = false)
{
if ($gridContainerId > 0) {
if (empty($GLOBALS['tx_gridelements']['parentElement'][$gridContainerId])) {
$GLOBALS['tx_gridelements']['parentElement'][$gridContainerId] = BackendUtility::getRecordWSOL(
'tt_content',
$gridContainerId
);
}
}
if ($doReturn) {
return $GLOBALS['tx_gridelements']['parentElement'][$gridContainerId];
}
return null;
} | [
"public",
"function",
"cacheCurrentParent",
"(",
"$",
"gridContainerId",
"=",
"0",
",",
"$",
"doReturn",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"gridContainerId",
">",
"0",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"GLOBALS",
"[",
"'tx_gridelements'",
"]",
"[",
"'parentElement'",
"]",
"[",
"$",
"gridContainerId",
"]",
")",
")",
"{",
"$",
"GLOBALS",
"[",
"'tx_gridelements'",
"]",
"[",
"'parentElement'",
"]",
"[",
"$",
"gridContainerId",
"]",
"=",
"BackendUtility",
"::",
"getRecordWSOL",
"(",
"'tt_content'",
",",
"$",
"gridContainerId",
")",
";",
"}",
"}",
"if",
"(",
"$",
"doReturn",
")",
"{",
"return",
"$",
"GLOBALS",
"[",
"'tx_gridelements'",
"]",
"[",
"'parentElement'",
"]",
"[",
"$",
"gridContainerId",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Caches Container-Records and their setup to avoid multiple selects of the same record during a single request
@param int $gridContainerId The ID of the current grid container
@param bool $doReturn
@return array|null | [
"Caches",
"Container",
"-",
"Records",
"and",
"their",
"setup",
"to",
"avoid",
"multiple",
"selects",
"of",
"the",
"same",
"record",
"during",
"a",
"single",
"request"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/LayoutSetup.php#L488-L503 |
TYPO3-extensions/gridelements | Classes/Backend/LayoutSetup.php | LayoutSetup.getLayoutColumnsSelectItems | public function getLayoutColumnsSelectItems($layoutId)
{
$setup = $this->getLayoutSetup($layoutId);
if (empty($setup['config']['rows.'])) {
return [];
}
$selectItems = [];
foreach ($setup['config']['rows.'] as $row) {
if (empty($row['columns.'])) {
continue;
}
foreach ($row['columns.'] as $column) {
$selectItems[] = [
$this->languageService->sL($column['name']),
$column['colPos'],
null,
$column['allowed'] ? $column['allowed'] : '*',
];
}
}
return $selectItems;
} | php | public function getLayoutColumnsSelectItems($layoutId)
{
$setup = $this->getLayoutSetup($layoutId);
if (empty($setup['config']['rows.'])) {
return [];
}
$selectItems = [];
foreach ($setup['config']['rows.'] as $row) {
if (empty($row['columns.'])) {
continue;
}
foreach ($row['columns.'] as $column) {
$selectItems[] = [
$this->languageService->sL($column['name']),
$column['colPos'],
null,
$column['allowed'] ? $column['allowed'] : '*',
];
}
}
return $selectItems;
} | [
"public",
"function",
"getLayoutColumnsSelectItems",
"(",
"$",
"layoutId",
")",
"{",
"$",
"setup",
"=",
"$",
"this",
"->",
"getLayoutSetup",
"(",
"$",
"layoutId",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"setup",
"[",
"'config'",
"]",
"[",
"'rows.'",
"]",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"selectItems",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"setup",
"[",
"'config'",
"]",
"[",
"'rows.'",
"]",
"as",
"$",
"row",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"row",
"[",
"'columns.'",
"]",
")",
")",
"{",
"continue",
";",
"}",
"foreach",
"(",
"$",
"row",
"[",
"'columns.'",
"]",
"as",
"$",
"column",
")",
"{",
"$",
"selectItems",
"[",
"]",
"=",
"[",
"$",
"this",
"->",
"languageService",
"->",
"sL",
"(",
"$",
"column",
"[",
"'name'",
"]",
")",
",",
"$",
"column",
"[",
"'colPos'",
"]",
",",
"null",
",",
"$",
"column",
"[",
"'allowed'",
"]",
"?",
"$",
"column",
"[",
"'allowed'",
"]",
":",
"'*'",
",",
"]",
";",
"}",
"}",
"return",
"$",
"selectItems",
";",
"}"
] | Returns the item array for form field selection
@param string $layoutId : The selected layout ID of the grid container
@return array | [
"Returns",
"the",
"item",
"array",
"for",
"form",
"field",
"selection"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/LayoutSetup.php#L512-L535 |
TYPO3-extensions/gridelements | Classes/Backend/LayoutSetup.php | LayoutSetup.getLayoutSetup | public function getLayoutSetup($layoutId = '')
{
// Continue only if setup for given layout ID found.
if (isset($this->layoutSetup[$layoutId])) {
return $this->layoutSetup[$layoutId];
}
return $this->layoutSetup;
} | php | public function getLayoutSetup($layoutId = '')
{
// Continue only if setup for given layout ID found.
if (isset($this->layoutSetup[$layoutId])) {
return $this->layoutSetup[$layoutId];
}
return $this->layoutSetup;
} | [
"public",
"function",
"getLayoutSetup",
"(",
"$",
"layoutId",
"=",
"''",
")",
"{",
"// Continue only if setup for given layout ID found.",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"layoutSetup",
"[",
"$",
"layoutId",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"layoutSetup",
"[",
"$",
"layoutId",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"layoutSetup",
";",
"}"
] | Returns the grid layout setup
@param string $layoutId If set only requested layout setup, else all layout setups will be returned.
@return array | [
"Returns",
"the",
"grid",
"layout",
"setup"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/LayoutSetup.php#L544-L552 |
TYPO3-extensions/gridelements | Classes/Backend/LayoutSetup.php | LayoutSetup.getLayoutWizardItems | public function getLayoutWizardItems(
$colPos,
$excludeLayouts = '',
array $allowedGridTypes = [],
array $disallowedGridTypes = []
) {
$wizardItems = [];
$excludeLayouts = array_flip(explode(',', $excludeLayouts));
foreach ($this->layoutSetup as $layoutId => $item) {
if ((
!empty($allowedGridTypes) &&
!isset($allowedGridTypes[$layoutId])
) ||
isset($disallowedGridTypes[$layoutId])
) {
continue;
}
if (isset($excludeLayouts[$item['uid']]) || (int)$colPos === -1 && $item['top_level_layout']) {
continue;
}
$wizardItems[] = [
'uid' => $layoutId,
'title' => $this->languageService->sL($item['title']),
'description' => $this->languageService->sL($item['description']),
'icon' => $item['icon'],
'iconIdentifier' => $item['iconIdentifier'],
'tll' => $item['top_level_layout'],
];
}
return $wizardItems;
} | php | public function getLayoutWizardItems(
$colPos,
$excludeLayouts = '',
array $allowedGridTypes = [],
array $disallowedGridTypes = []
) {
$wizardItems = [];
$excludeLayouts = array_flip(explode(',', $excludeLayouts));
foreach ($this->layoutSetup as $layoutId => $item) {
if ((
!empty($allowedGridTypes) &&
!isset($allowedGridTypes[$layoutId])
) ||
isset($disallowedGridTypes[$layoutId])
) {
continue;
}
if (isset($excludeLayouts[$item['uid']]) || (int)$colPos === -1 && $item['top_level_layout']) {
continue;
}
$wizardItems[] = [
'uid' => $layoutId,
'title' => $this->languageService->sL($item['title']),
'description' => $this->languageService->sL($item['description']),
'icon' => $item['icon'],
'iconIdentifier' => $item['iconIdentifier'],
'tll' => $item['top_level_layout'],
];
}
return $wizardItems;
} | [
"public",
"function",
"getLayoutWizardItems",
"(",
"$",
"colPos",
",",
"$",
"excludeLayouts",
"=",
"''",
",",
"array",
"$",
"allowedGridTypes",
"=",
"[",
"]",
",",
"array",
"$",
"disallowedGridTypes",
"=",
"[",
"]",
")",
"{",
"$",
"wizardItems",
"=",
"[",
"]",
";",
"$",
"excludeLayouts",
"=",
"array_flip",
"(",
"explode",
"(",
"','",
",",
"$",
"excludeLayouts",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"layoutSetup",
"as",
"$",
"layoutId",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"(",
"!",
"empty",
"(",
"$",
"allowedGridTypes",
")",
"&&",
"!",
"isset",
"(",
"$",
"allowedGridTypes",
"[",
"$",
"layoutId",
"]",
")",
")",
"||",
"isset",
"(",
"$",
"disallowedGridTypes",
"[",
"$",
"layoutId",
"]",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"excludeLayouts",
"[",
"$",
"item",
"[",
"'uid'",
"]",
"]",
")",
"||",
"(",
"int",
")",
"$",
"colPos",
"===",
"-",
"1",
"&&",
"$",
"item",
"[",
"'top_level_layout'",
"]",
")",
"{",
"continue",
";",
"}",
"$",
"wizardItems",
"[",
"]",
"=",
"[",
"'uid'",
"=>",
"$",
"layoutId",
",",
"'title'",
"=>",
"$",
"this",
"->",
"languageService",
"->",
"sL",
"(",
"$",
"item",
"[",
"'title'",
"]",
")",
",",
"'description'",
"=>",
"$",
"this",
"->",
"languageService",
"->",
"sL",
"(",
"$",
"item",
"[",
"'description'",
"]",
")",
",",
"'icon'",
"=>",
"$",
"item",
"[",
"'icon'",
"]",
",",
"'iconIdentifier'",
"=>",
"$",
"item",
"[",
"'iconIdentifier'",
"]",
",",
"'tll'",
"=>",
"$",
"item",
"[",
"'top_level_layout'",
"]",
",",
"]",
";",
"}",
"return",
"$",
"wizardItems",
";",
"}"
] | Returns the item array for form field selection
@param int $colPos
@param string $excludeLayouts
@param array $allowedGridTypes
@param array $disallowedGridTypes
@return array | [
"Returns",
"the",
"item",
"array",
"for",
"form",
"field",
"selection"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/LayoutSetup.php#L585-L617 |
TYPO3-extensions/gridelements | Classes/Backend/LayoutSetup.php | LayoutSetup.getFlexformConfiguration | public function getFlexformConfiguration($layoutId)
{
$layoutSetup = $this->getLayoutSetup($layoutId);
// Get flexform file from pi_flexform_ds if pi_flexform_ds_file not set and "FILE:" found in pi_flexform_ds for backward compatibility.
if ($layoutSetup['pi_flexform_ds_file']) {
$flexformConfiguration = GeneralUtility::getUrl(GeneralUtility::getFileAbsFileName($layoutSetup['pi_flexform_ds_file']));
} elseif (strpos($layoutSetup['pi_flexform_ds'], 'FILE:') === 0) {
$flexformConfiguration = GeneralUtility::getUrl(GeneralUtility::getFileAbsFileName(substr(
$layoutSetup['pi_flexform_ds'],
5
)));
} elseif ($layoutSetup['pi_flexform_ds']) {
$flexformConfiguration = $layoutSetup['pi_flexform_ds'];
} else {
$flexformConfiguration = GeneralUtility::getUrl(GeneralUtility::getFileAbsFileName($this->flexformConfigurationPathAndFileName));
}
return $flexformConfiguration;
} | php | public function getFlexformConfiguration($layoutId)
{
$layoutSetup = $this->getLayoutSetup($layoutId);
// Get flexform file from pi_flexform_ds if pi_flexform_ds_file not set and "FILE:" found in pi_flexform_ds for backward compatibility.
if ($layoutSetup['pi_flexform_ds_file']) {
$flexformConfiguration = GeneralUtility::getUrl(GeneralUtility::getFileAbsFileName($layoutSetup['pi_flexform_ds_file']));
} elseif (strpos($layoutSetup['pi_flexform_ds'], 'FILE:') === 0) {
$flexformConfiguration = GeneralUtility::getUrl(GeneralUtility::getFileAbsFileName(substr(
$layoutSetup['pi_flexform_ds'],
5
)));
} elseif ($layoutSetup['pi_flexform_ds']) {
$flexformConfiguration = $layoutSetup['pi_flexform_ds'];
} else {
$flexformConfiguration = GeneralUtility::getUrl(GeneralUtility::getFileAbsFileName($this->flexformConfigurationPathAndFileName));
}
return $flexformConfiguration;
} | [
"public",
"function",
"getFlexformConfiguration",
"(",
"$",
"layoutId",
")",
"{",
"$",
"layoutSetup",
"=",
"$",
"this",
"->",
"getLayoutSetup",
"(",
"$",
"layoutId",
")",
";",
"// Get flexform file from pi_flexform_ds if pi_flexform_ds_file not set and \"FILE:\" found in pi_flexform_ds for backward compatibility.",
"if",
"(",
"$",
"layoutSetup",
"[",
"'pi_flexform_ds_file'",
"]",
")",
"{",
"$",
"flexformConfiguration",
"=",
"GeneralUtility",
"::",
"getUrl",
"(",
"GeneralUtility",
"::",
"getFileAbsFileName",
"(",
"$",
"layoutSetup",
"[",
"'pi_flexform_ds_file'",
"]",
")",
")",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"layoutSetup",
"[",
"'pi_flexform_ds'",
"]",
",",
"'FILE:'",
")",
"===",
"0",
")",
"{",
"$",
"flexformConfiguration",
"=",
"GeneralUtility",
"::",
"getUrl",
"(",
"GeneralUtility",
"::",
"getFileAbsFileName",
"(",
"substr",
"(",
"$",
"layoutSetup",
"[",
"'pi_flexform_ds'",
"]",
",",
"5",
")",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"layoutSetup",
"[",
"'pi_flexform_ds'",
"]",
")",
"{",
"$",
"flexformConfiguration",
"=",
"$",
"layoutSetup",
"[",
"'pi_flexform_ds'",
"]",
";",
"}",
"else",
"{",
"$",
"flexformConfiguration",
"=",
"GeneralUtility",
"::",
"getUrl",
"(",
"GeneralUtility",
"::",
"getFileAbsFileName",
"(",
"$",
"this",
"->",
"flexformConfigurationPathAndFileName",
")",
")",
";",
"}",
"return",
"$",
"flexformConfiguration",
";",
"}"
] | Returns the FlexForm configuration of a grid layout
@param string $layoutId The current layout ID of the grid container
@return string | [
"Returns",
"the",
"FlexForm",
"configuration",
"of",
"a",
"grid",
"layout"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/LayoutSetup.php#L626-L644 |
TYPO3-extensions/gridelements | Classes/Backend/LayoutSetup.php | LayoutSetup.setLanguageService | public function setLanguageService(LanguageService $languageService = null)
{
$this->languageService = $languageService instanceof LanguageService ? $languageService : GeneralUtility::makeInstance(LanguageService::class);
if ($this->getBackendUser()) {
$this->languageService->init($this->getBackendUser()->uc['lang']);
}
} | php | public function setLanguageService(LanguageService $languageService = null)
{
$this->languageService = $languageService instanceof LanguageService ? $languageService : GeneralUtility::makeInstance(LanguageService::class);
if ($this->getBackendUser()) {
$this->languageService->init($this->getBackendUser()->uc['lang']);
}
} | [
"public",
"function",
"setLanguageService",
"(",
"LanguageService",
"$",
"languageService",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"languageService",
"=",
"$",
"languageService",
"instanceof",
"LanguageService",
"?",
"$",
"languageService",
":",
"GeneralUtility",
"::",
"makeInstance",
"(",
"LanguageService",
"::",
"class",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getBackendUser",
"(",
")",
")",
"{",
"$",
"this",
"->",
"languageService",
"->",
"init",
"(",
"$",
"this",
"->",
"getBackendUser",
"(",
")",
"->",
"uc",
"[",
"'lang'",
"]",
")",
";",
"}",
"}"
] | setter for languageService object
@param LanguageService $languageService | [
"setter",
"for",
"languageService",
"object"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/LayoutSetup.php#L671-L677 |
TYPO3-extensions/gridelements | Classes/Hooks/DataHandler.php | DataHandler.processDatamap_preProcessFieldArray | public function processDatamap_preProcessFieldArray(
&$fieldArray,
$table,
$id,
\TYPO3\CMS\Core\DataHandling\DataHandler $parentObj
) {
if (($table === 'tt_content' || $table === 'pages') && !$parentObj->isImporting) {
/** @var $hook PreProcessFieldArray */
$hook = GeneralUtility::makeInstance(PreProcessFieldArray::class);
$hook->execute_preProcessFieldArray($fieldArray, $table, $id, $parentObj);
}
} | php | public function processDatamap_preProcessFieldArray(
&$fieldArray,
$table,
$id,
\TYPO3\CMS\Core\DataHandling\DataHandler $parentObj
) {
if (($table === 'tt_content' || $table === 'pages') && !$parentObj->isImporting) {
/** @var $hook PreProcessFieldArray */
$hook = GeneralUtility::makeInstance(PreProcessFieldArray::class);
$hook->execute_preProcessFieldArray($fieldArray, $table, $id, $parentObj);
}
} | [
"public",
"function",
"processDatamap_preProcessFieldArray",
"(",
"&",
"$",
"fieldArray",
",",
"$",
"table",
",",
"$",
"id",
",",
"\\",
"TYPO3",
"\\",
"CMS",
"\\",
"Core",
"\\",
"DataHandling",
"\\",
"DataHandler",
"$",
"parentObj",
")",
"{",
"if",
"(",
"(",
"$",
"table",
"===",
"'tt_content'",
"||",
"$",
"table",
"===",
"'pages'",
")",
"&&",
"!",
"$",
"parentObj",
"->",
"isImporting",
")",
"{",
"/** @var $hook PreProcessFieldArray */",
"$",
"hook",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"PreProcessFieldArray",
"::",
"class",
")",
";",
"$",
"hook",
"->",
"execute_preProcessFieldArray",
"(",
"$",
"fieldArray",
",",
"$",
"table",
",",
"$",
"id",
",",
"$",
"parentObj",
")",
";",
"}",
"}"
] | Function to set the colPos of an element depending on
whether it is a child of a parent container or not
will set colPos according to availability of the current grid column of an element
0 = no column at all
-1 = grid element column
-2 = non used elements column
changes are applied to the field array of the parent object by reference
@param array $fieldArray : The array of fields and values that have been saved to the datamap
@param string $table : The name of the table the data should be saved to
@param int $id : The uid of the page we are currently working on
@param \TYPO3\CMS\Core\DataHandling\DataHandler $parentObj : The parent object that triggered this hook
@return void | [
"Function",
"to",
"set",
"the",
"colPos",
"of",
"an",
"element",
"depending",
"on",
"whether",
"it",
"is",
"a",
"child",
"of",
"a",
"parent",
"container",
"or",
"not",
"will",
"set",
"colPos",
"according",
"to",
"availability",
"of",
"the",
"current",
"grid",
"column",
"of",
"an",
"element",
"0",
"=",
"no",
"column",
"at",
"all",
"-",
"1",
"=",
"grid",
"element",
"column",
"-",
"2",
"=",
"non",
"used",
"elements",
"column",
"changes",
"are",
"applied",
"to",
"the",
"field",
"array",
"of",
"the",
"parent",
"object",
"by",
"reference"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/DataHandler.php#L56-L67 |
TYPO3-extensions/gridelements | Classes/Hooks/DataHandler.php | DataHandler.processDatamap_afterDatabaseOperations | public function processDatamap_afterDatabaseOperations(
&$status,
&$table,
&$id,
&$fieldArray,
\TYPO3\CMS\Core\DataHandling\DataHandler $parentObj
) {
if (($table === 'tt_content' || $table === 'pages') && !$parentObj->isImporting) {
/** @var AfterDatabaseOperations $hook */
$hook = GeneralUtility::makeInstance(AfterDatabaseOperations::class);
if (strpos($id, 'NEW') !== false) {
$id = $parentObj->substNEWwithIDs[$id];
} else {
if ($table === 'tt_content' && $status === 'update') {
$hook->adjustValuesAfterWorkspaceOperations($fieldArray, $id, $parentObj);
}
}
$hook->execute_afterDatabaseOperations($fieldArray, $table, $id, $parentObj);
}
} | php | public function processDatamap_afterDatabaseOperations(
&$status,
&$table,
&$id,
&$fieldArray,
\TYPO3\CMS\Core\DataHandling\DataHandler $parentObj
) {
if (($table === 'tt_content' || $table === 'pages') && !$parentObj->isImporting) {
/** @var AfterDatabaseOperations $hook */
$hook = GeneralUtility::makeInstance(AfterDatabaseOperations::class);
if (strpos($id, 'NEW') !== false) {
$id = $parentObj->substNEWwithIDs[$id];
} else {
if ($table === 'tt_content' && $status === 'update') {
$hook->adjustValuesAfterWorkspaceOperations($fieldArray, $id, $parentObj);
}
}
$hook->execute_afterDatabaseOperations($fieldArray, $table, $id, $parentObj);
}
} | [
"public",
"function",
"processDatamap_afterDatabaseOperations",
"(",
"&",
"$",
"status",
",",
"&",
"$",
"table",
",",
"&",
"$",
"id",
",",
"&",
"$",
"fieldArray",
",",
"\\",
"TYPO3",
"\\",
"CMS",
"\\",
"Core",
"\\",
"DataHandling",
"\\",
"DataHandler",
"$",
"parentObj",
")",
"{",
"if",
"(",
"(",
"$",
"table",
"===",
"'tt_content'",
"||",
"$",
"table",
"===",
"'pages'",
")",
"&&",
"!",
"$",
"parentObj",
"->",
"isImporting",
")",
"{",
"/** @var AfterDatabaseOperations $hook */",
"$",
"hook",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"AfterDatabaseOperations",
"::",
"class",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"id",
",",
"'NEW'",
")",
"!==",
"false",
")",
"{",
"$",
"id",
"=",
"$",
"parentObj",
"->",
"substNEWwithIDs",
"[",
"$",
"id",
"]",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"table",
"===",
"'tt_content'",
"&&",
"$",
"status",
"===",
"'update'",
")",
"{",
"$",
"hook",
"->",
"adjustValuesAfterWorkspaceOperations",
"(",
"$",
"fieldArray",
",",
"$",
"id",
",",
"$",
"parentObj",
")",
";",
"}",
"}",
"$",
"hook",
"->",
"execute_afterDatabaseOperations",
"(",
"$",
"fieldArray",
",",
"$",
"table",
",",
"$",
"id",
",",
"$",
"parentObj",
")",
";",
"}",
"}"
] | @param string $status
@param string $table : The name of the table the data should be saved to
@param int $id : The uid of the page we are currently working on
@param array $fieldArray : The array of fields and values that have been saved to the datamap
@param \TYPO3\CMS\Core\DataHandling\DataHandler $parentObj : The parent object that triggered this hook
@return void | [
"@param",
"string",
"$status",
"@param",
"string",
"$table",
":",
"The",
"name",
"of",
"the",
"table",
"the",
"data",
"should",
"be",
"saved",
"to",
"@param",
"int",
"$id",
":",
"The",
"uid",
"of",
"the",
"page",
"we",
"are",
"currently",
"working",
"on",
"@param",
"array",
"$fieldArray",
":",
"The",
"array",
"of",
"fields",
"and",
"values",
"that",
"have",
"been",
"saved",
"to",
"the",
"datamap",
"@param",
"\\",
"TYPO3",
"\\",
"CMS",
"\\",
"Core",
"\\",
"DataHandling",
"\\",
"DataHandler",
"$parentObj",
":",
"The",
"parent",
"object",
"that",
"triggered",
"this",
"hook"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/DataHandler.php#L78-L97 |
TYPO3-extensions/gridelements | Classes/Hooks/DataHandler.php | DataHandler.processCmdmap | public function processCmdmap(
$command,
$table,
$id,
$value,
&$commandIsProcessed,
\TYPO3\CMS\Core\DataHandling\DataHandler &$parentObj,
$pasteUpdate
) {
if (!$parentObj->isImporting) {
/** @var ProcessCmdmap $hook */
$hook = GeneralUtility::makeInstance(ProcessCmdmap::class);
$hook->execute_processCmdmap($command, $table, $id, $value, $commandIsProcessed, $parentObj, $pasteUpdate);
}
} | php | public function processCmdmap(
$command,
$table,
$id,
$value,
&$commandIsProcessed,
\TYPO3\CMS\Core\DataHandling\DataHandler &$parentObj,
$pasteUpdate
) {
if (!$parentObj->isImporting) {
/** @var ProcessCmdmap $hook */
$hook = GeneralUtility::makeInstance(ProcessCmdmap::class);
$hook->execute_processCmdmap($command, $table, $id, $value, $commandIsProcessed, $parentObj, $pasteUpdate);
}
} | [
"public",
"function",
"processCmdmap",
"(",
"$",
"command",
",",
"$",
"table",
",",
"$",
"id",
",",
"$",
"value",
",",
"&",
"$",
"commandIsProcessed",
",",
"\\",
"TYPO3",
"\\",
"CMS",
"\\",
"Core",
"\\",
"DataHandling",
"\\",
"DataHandler",
"&",
"$",
"parentObj",
",",
"$",
"pasteUpdate",
")",
"{",
"if",
"(",
"!",
"$",
"parentObj",
"->",
"isImporting",
")",
"{",
"/** @var ProcessCmdmap $hook */",
"$",
"hook",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"ProcessCmdmap",
"::",
"class",
")",
";",
"$",
"hook",
"->",
"execute_processCmdmap",
"(",
"$",
"command",
",",
"$",
"table",
",",
"$",
"id",
",",
"$",
"value",
",",
"$",
"commandIsProcessed",
",",
"$",
"parentObj",
",",
"$",
"pasteUpdate",
")",
";",
"}",
"}"
] | Function to process the drag & drop copy action
@param string $command The command to be handled by the command map
@param string $table The name of the table we are working on
@param int $id The id of the record that is going to be copied
@param string $value The value that has been sent with the copy command
@param bool $commandIsProcessed A switch to tell the parent object, if the record has been copied
@param \TYPO3\CMS\Core\DataHandling\DataHandler $parentObj The parent object that triggered this hook
@param array|bool $pasteUpdate Values to be updated after the record is pasted | [
"Function",
"to",
"process",
"the",
"drag",
"&",
"drop",
"copy",
"action"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/DataHandler.php#L110-L124 |
TYPO3-extensions/gridelements | Classes/Xclass/DatabaseRecordList.php | DatabaseRecordList.getButtons | public function getButtons()
{
$module = $this->getModule();
$backendUser = $this->getBackendUserAuthentication();
$lang = $this->getLanguageService();
$buttons = [
'csh' => '',
'view' => '',
'edit' => '',
'hide_unhide' => '',
'move' => '',
'new_record' => '',
'paste' => '',
'level_up' => '',
'cache' => '',
'reload' => '',
'shortcut' => '',
'back' => '',
'csv' => '',
'export' => '',
];
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
// Get users permissions for this page record:
$localCalcPerms = $backendUser->calcPerms($this->pageRow);
// CSH
if ((string)$this->id === '') {
$buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'list_module_noId');
} elseif (!$this->id) {
$buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'list_module_root');
} else {
$buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'list_module');
}
if (isset($this->id)) {
// View Exclude doktypes 254,255 Configuration:
// mod.web_list.noViewWithDokTypes = 254,255
if (isset($module->modTSconfig['properties']['noViewWithDokTypes'])) {
$noViewDokTypes = GeneralUtility::trimExplode(
',',
$module->modTSconfig['properties']['noViewWithDokTypes'],
true
);
} else {
//default exclusion: doktype 254 (folder), 255 (recycler)
$noViewDokTypes = [
PageRepository::DOKTYPE_SYSFOLDER,
PageRepository::DOKTYPE_RECYCLER,
];
}
if (!in_array($this->pageRow['doktype'], $noViewDokTypes)) {
$onClick = htmlspecialchars(BackendUtility::viewOnClick(
$this->id,
'',
BackendUtility::BEgetRootLine($this->id)
));
$buttons['view'] = '<a href="#" onclick="' . $onClick . '" title="'
. htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')) . '">'
. $this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL)->render() . '</a>';
}
// New record on pages that are not locked by editlock
if (!$module->modTSconfig['properties']['noCreateRecordsLink'] && $this->editLockPermissions()) {
$onClick = htmlspecialchars('return jumpExt(' . GeneralUtility::quoteJSvalue((string)$uriBuilder->buildUriFromRoute(
'db_new',
['id' => $this->id]
)) . ');');
$buttons['new_record'] = '<a href="#" onclick="' . $onClick . '" title="'
. htmlspecialchars($lang->getLL('newRecordGeneral')) . '">'
. $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL)->render() . '</a>';
}
// If edit permissions are set, see
// \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
if ($localCalcPerms & Permission::PAGE_EDIT && !empty($this->id) && $this->editLockPermissions() && $this->getBackendUserAuthentication()->checkLanguageAccess(0)) {
// Edit
$params = '&edit[pages][' . $this->pageRow['uid'] . ']=edit';
$onClick = htmlspecialchars(BackendUtility::editOnClick($params, '', -1));
$buttons['edit'] = '<a href="#" onclick="' . $onClick . '" title="' . htmlspecialchars($lang->getLL('editPage')) . '">'
. $this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL)->render()
. '</a>';
}
// Paste
if (($localCalcPerms & Permission::PAGE_NEW || $localCalcPerms & Permission::CONTENT_EDIT) && $this->editLockPermissions()) {
$elFromTable = $this->clipObj->elFromTable('');
if (!empty($elFromTable)) {
$confirmText = $this->clipObj->confirmMsgText('pages', $this->pageRow, 'into', $elFromTable);
$buttons['paste'] = '<a'
. ' href="' . htmlspecialchars($this->clipObj->pasteUrl('', $this->id)) . '"'
. ' title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
. ' class="t3js-modal-trigger"'
. ' data-severity="warning"'
. ' data-title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
. ' data-content="' . htmlspecialchars($confirmText) . '"'
. '>'
. $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render()
. '</a>';
}
}
// Cache
$buttons['cache'] = '<a href="' . htmlspecialchars($this->listURL() . '&clear_cache=1') . '" title="'
. htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.clear_cache')) . '">'
. $this->iconFactory->getIcon('actions-system-cache-clear', Icon::SIZE_SMALL)->render() . '</a>';
if ($this->table && (!isset($module->modTSconfig['properties']['noExportRecordsLinks'])
|| (isset($module->modTSconfig['properties']['noExportRecordsLinks'])
&& !$module->modTSconfig['properties']['noExportRecordsLinks']))
) {
// CSV
$buttons['csv'] = '<a href="' . htmlspecialchars($this->listURL() . '&csv=1') . '" title="'
. htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.csv')) . '">'
. $this->iconFactory->getIcon('actions-document-export-csv', Icon::SIZE_SMALL)->render() . '</a>';
// Export
if (ExtensionManagementUtility::isLoaded('impexp')) {
$url = (string)$uriBuilder->buildUriFromRoute('xMOD_tximpexp', ['tx_impexp[action]' => 'export']);
$buttons['export'] = '<a href="' . htmlspecialchars($url . '&tx_impexp[list][]='
. rawurlencode($this->table . ':' . $this->id)) . '" title="'
. htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:rm.export')) . '">'
. $this->iconFactory->getIcon(
'actions-document-export-t3d',
Icon::SIZE_SMALL
)->render() . '</a>';
}
}
// Reload
$buttons['reload'] = '<a href="' . htmlspecialchars($this->listURL()) . '" title="'
. htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.reload')) . '">'
. $this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL)->render() . '</a>';
// Shortcut
if ($backendUser->mayMakeShortcut()) {
$buttons['shortcut'] = $this->getDocumentTemplate()->makeShortcutIcon(
'id, M, imagemode, pointer, table, search_field, search_levels, showLimit, sortField, sortRev',
implode(',', array_keys($this->MOD_MENU)),
'web_list'
);
}
// Back
if ($this->returnUrl) {
$href = htmlspecialchars(GeneralUtility::linkThisUrl($this->returnUrl, ['id' => $this->id]));
$buttons['back'] = '<a href="' . $href . '" class="typo3-goBack" title="'
. htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.goBack')) . '">'
. $this->iconFactory->getIcon('actions-view-go-back', Icon::SIZE_SMALL)->render() . '</a>';
}
}
return $buttons;
} | php | public function getButtons()
{
$module = $this->getModule();
$backendUser = $this->getBackendUserAuthentication();
$lang = $this->getLanguageService();
$buttons = [
'csh' => '',
'view' => '',
'edit' => '',
'hide_unhide' => '',
'move' => '',
'new_record' => '',
'paste' => '',
'level_up' => '',
'cache' => '',
'reload' => '',
'shortcut' => '',
'back' => '',
'csv' => '',
'export' => '',
];
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
// Get users permissions for this page record:
$localCalcPerms = $backendUser->calcPerms($this->pageRow);
// CSH
if ((string)$this->id === '') {
$buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'list_module_noId');
} elseif (!$this->id) {
$buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'list_module_root');
} else {
$buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'list_module');
}
if (isset($this->id)) {
// View Exclude doktypes 254,255 Configuration:
// mod.web_list.noViewWithDokTypes = 254,255
if (isset($module->modTSconfig['properties']['noViewWithDokTypes'])) {
$noViewDokTypes = GeneralUtility::trimExplode(
',',
$module->modTSconfig['properties']['noViewWithDokTypes'],
true
);
} else {
//default exclusion: doktype 254 (folder), 255 (recycler)
$noViewDokTypes = [
PageRepository::DOKTYPE_SYSFOLDER,
PageRepository::DOKTYPE_RECYCLER,
];
}
if (!in_array($this->pageRow['doktype'], $noViewDokTypes)) {
$onClick = htmlspecialchars(BackendUtility::viewOnClick(
$this->id,
'',
BackendUtility::BEgetRootLine($this->id)
));
$buttons['view'] = '<a href="#" onclick="' . $onClick . '" title="'
. htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')) . '">'
. $this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL)->render() . '</a>';
}
// New record on pages that are not locked by editlock
if (!$module->modTSconfig['properties']['noCreateRecordsLink'] && $this->editLockPermissions()) {
$onClick = htmlspecialchars('return jumpExt(' . GeneralUtility::quoteJSvalue((string)$uriBuilder->buildUriFromRoute(
'db_new',
['id' => $this->id]
)) . ');');
$buttons['new_record'] = '<a href="#" onclick="' . $onClick . '" title="'
. htmlspecialchars($lang->getLL('newRecordGeneral')) . '">'
. $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL)->render() . '</a>';
}
// If edit permissions are set, see
// \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
if ($localCalcPerms & Permission::PAGE_EDIT && !empty($this->id) && $this->editLockPermissions() && $this->getBackendUserAuthentication()->checkLanguageAccess(0)) {
// Edit
$params = '&edit[pages][' . $this->pageRow['uid'] . ']=edit';
$onClick = htmlspecialchars(BackendUtility::editOnClick($params, '', -1));
$buttons['edit'] = '<a href="#" onclick="' . $onClick . '" title="' . htmlspecialchars($lang->getLL('editPage')) . '">'
. $this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL)->render()
. '</a>';
}
// Paste
if (($localCalcPerms & Permission::PAGE_NEW || $localCalcPerms & Permission::CONTENT_EDIT) && $this->editLockPermissions()) {
$elFromTable = $this->clipObj->elFromTable('');
if (!empty($elFromTable)) {
$confirmText = $this->clipObj->confirmMsgText('pages', $this->pageRow, 'into', $elFromTable);
$buttons['paste'] = '<a'
. ' href="' . htmlspecialchars($this->clipObj->pasteUrl('', $this->id)) . '"'
. ' title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
. ' class="t3js-modal-trigger"'
. ' data-severity="warning"'
. ' data-title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
. ' data-content="' . htmlspecialchars($confirmText) . '"'
. '>'
. $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render()
. '</a>';
}
}
// Cache
$buttons['cache'] = '<a href="' . htmlspecialchars($this->listURL() . '&clear_cache=1') . '" title="'
. htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.clear_cache')) . '">'
. $this->iconFactory->getIcon('actions-system-cache-clear', Icon::SIZE_SMALL)->render() . '</a>';
if ($this->table && (!isset($module->modTSconfig['properties']['noExportRecordsLinks'])
|| (isset($module->modTSconfig['properties']['noExportRecordsLinks'])
&& !$module->modTSconfig['properties']['noExportRecordsLinks']))
) {
// CSV
$buttons['csv'] = '<a href="' . htmlspecialchars($this->listURL() . '&csv=1') . '" title="'
. htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.csv')) . '">'
. $this->iconFactory->getIcon('actions-document-export-csv', Icon::SIZE_SMALL)->render() . '</a>';
// Export
if (ExtensionManagementUtility::isLoaded('impexp')) {
$url = (string)$uriBuilder->buildUriFromRoute('xMOD_tximpexp', ['tx_impexp[action]' => 'export']);
$buttons['export'] = '<a href="' . htmlspecialchars($url . '&tx_impexp[list][]='
. rawurlencode($this->table . ':' . $this->id)) . '" title="'
. htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:rm.export')) . '">'
. $this->iconFactory->getIcon(
'actions-document-export-t3d',
Icon::SIZE_SMALL
)->render() . '</a>';
}
}
// Reload
$buttons['reload'] = '<a href="' . htmlspecialchars($this->listURL()) . '" title="'
. htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.reload')) . '">'
. $this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL)->render() . '</a>';
// Shortcut
if ($backendUser->mayMakeShortcut()) {
$buttons['shortcut'] = $this->getDocumentTemplate()->makeShortcutIcon(
'id, M, imagemode, pointer, table, search_field, search_levels, showLimit, sortField, sortRev',
implode(',', array_keys($this->MOD_MENU)),
'web_list'
);
}
// Back
if ($this->returnUrl) {
$href = htmlspecialchars(GeneralUtility::linkThisUrl($this->returnUrl, ['id' => $this->id]));
$buttons['back'] = '<a href="' . $href . '" class="typo3-goBack" title="'
. htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.goBack')) . '">'
. $this->iconFactory->getIcon('actions-view-go-back', Icon::SIZE_SMALL)->render() . '</a>';
}
}
return $buttons;
} | [
"public",
"function",
"getButtons",
"(",
")",
"{",
"$",
"module",
"=",
"$",
"this",
"->",
"getModule",
"(",
")",
";",
"$",
"backendUser",
"=",
"$",
"this",
"->",
"getBackendUserAuthentication",
"(",
")",
";",
"$",
"lang",
"=",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
";",
"$",
"buttons",
"=",
"[",
"'csh'",
"=>",
"''",
",",
"'view'",
"=>",
"''",
",",
"'edit'",
"=>",
"''",
",",
"'hide_unhide'",
"=>",
"''",
",",
"'move'",
"=>",
"''",
",",
"'new_record'",
"=>",
"''",
",",
"'paste'",
"=>",
"''",
",",
"'level_up'",
"=>",
"''",
",",
"'cache'",
"=>",
"''",
",",
"'reload'",
"=>",
"''",
",",
"'shortcut'",
"=>",
"''",
",",
"'back'",
"=>",
"''",
",",
"'csv'",
"=>",
"''",
",",
"'export'",
"=>",
"''",
",",
"]",
";",
"/** @var \\TYPO3\\CMS\\Backend\\Routing\\UriBuilder $uriBuilder */",
"$",
"uriBuilder",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"\\",
"TYPO3",
"\\",
"CMS",
"\\",
"Backend",
"\\",
"Routing",
"\\",
"UriBuilder",
"::",
"class",
")",
";",
"// Get users permissions for this page record:",
"$",
"localCalcPerms",
"=",
"$",
"backendUser",
"->",
"calcPerms",
"(",
"$",
"this",
"->",
"pageRow",
")",
";",
"// CSH",
"if",
"(",
"(",
"string",
")",
"$",
"this",
"->",
"id",
"===",
"''",
")",
"{",
"$",
"buttons",
"[",
"'csh'",
"]",
"=",
"BackendUtility",
"::",
"cshItem",
"(",
"'xMOD_csh_corebe'",
",",
"'list_module_noId'",
")",
";",
"}",
"elseif",
"(",
"!",
"$",
"this",
"->",
"id",
")",
"{",
"$",
"buttons",
"[",
"'csh'",
"]",
"=",
"BackendUtility",
"::",
"cshItem",
"(",
"'xMOD_csh_corebe'",
",",
"'list_module_root'",
")",
";",
"}",
"else",
"{",
"$",
"buttons",
"[",
"'csh'",
"]",
"=",
"BackendUtility",
"::",
"cshItem",
"(",
"'xMOD_csh_corebe'",
",",
"'list_module'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"id",
")",
")",
"{",
"// View Exclude doktypes 254,255 Configuration:",
"// mod.web_list.noViewWithDokTypes = 254,255",
"if",
"(",
"isset",
"(",
"$",
"module",
"->",
"modTSconfig",
"[",
"'properties'",
"]",
"[",
"'noViewWithDokTypes'",
"]",
")",
")",
"{",
"$",
"noViewDokTypes",
"=",
"GeneralUtility",
"::",
"trimExplode",
"(",
"','",
",",
"$",
"module",
"->",
"modTSconfig",
"[",
"'properties'",
"]",
"[",
"'noViewWithDokTypes'",
"]",
",",
"true",
")",
";",
"}",
"else",
"{",
"//default exclusion: doktype 254 (folder), 255 (recycler)",
"$",
"noViewDokTypes",
"=",
"[",
"PageRepository",
"::",
"DOKTYPE_SYSFOLDER",
",",
"PageRepository",
"::",
"DOKTYPE_RECYCLER",
",",
"]",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"this",
"->",
"pageRow",
"[",
"'doktype'",
"]",
",",
"$",
"noViewDokTypes",
")",
")",
"{",
"$",
"onClick",
"=",
"htmlspecialchars",
"(",
"BackendUtility",
"::",
"viewOnClick",
"(",
"$",
"this",
"->",
"id",
",",
"''",
",",
"BackendUtility",
"::",
"BEgetRootLine",
"(",
"$",
"this",
"->",
"id",
")",
")",
")",
";",
"$",
"buttons",
"[",
"'view'",
"]",
"=",
"'<a href=\"#\" onclick=\"'",
".",
"$",
"onClick",
".",
"'\" title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"lang",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage'",
")",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-document-view'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"}",
"// New record on pages that are not locked by editlock",
"if",
"(",
"!",
"$",
"module",
"->",
"modTSconfig",
"[",
"'properties'",
"]",
"[",
"'noCreateRecordsLink'",
"]",
"&&",
"$",
"this",
"->",
"editLockPermissions",
"(",
")",
")",
"{",
"$",
"onClick",
"=",
"htmlspecialchars",
"(",
"'return jumpExt('",
".",
"GeneralUtility",
"::",
"quoteJSvalue",
"(",
"(",
"string",
")",
"$",
"uriBuilder",
"->",
"buildUriFromRoute",
"(",
"'db_new'",
",",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"id",
"]",
")",
")",
".",
"');'",
")",
";",
"$",
"buttons",
"[",
"'new_record'",
"]",
"=",
"'<a href=\"#\" onclick=\"'",
".",
"$",
"onClick",
".",
"'\" title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"lang",
"->",
"getLL",
"(",
"'newRecordGeneral'",
")",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-add'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"}",
"// If edit permissions are set, see",
"// \\TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication",
"if",
"(",
"$",
"localCalcPerms",
"&",
"Permission",
"::",
"PAGE_EDIT",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"id",
")",
"&&",
"$",
"this",
"->",
"editLockPermissions",
"(",
")",
"&&",
"$",
"this",
"->",
"getBackendUserAuthentication",
"(",
")",
"->",
"checkLanguageAccess",
"(",
"0",
")",
")",
"{",
"// Edit",
"$",
"params",
"=",
"'&edit[pages]['",
".",
"$",
"this",
"->",
"pageRow",
"[",
"'uid'",
"]",
".",
"']=edit'",
";",
"$",
"onClick",
"=",
"htmlspecialchars",
"(",
"BackendUtility",
"::",
"editOnClick",
"(",
"$",
"params",
",",
"''",
",",
"-",
"1",
")",
")",
";",
"$",
"buttons",
"[",
"'edit'",
"]",
"=",
"'<a href=\"#\" onclick=\"'",
".",
"$",
"onClick",
".",
"'\" title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"lang",
"->",
"getLL",
"(",
"'editPage'",
")",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-page-open'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"}",
"// Paste",
"if",
"(",
"(",
"$",
"localCalcPerms",
"&",
"Permission",
"::",
"PAGE_NEW",
"||",
"$",
"localCalcPerms",
"&",
"Permission",
"::",
"CONTENT_EDIT",
")",
"&&",
"$",
"this",
"->",
"editLockPermissions",
"(",
")",
")",
"{",
"$",
"elFromTable",
"=",
"$",
"this",
"->",
"clipObj",
"->",
"elFromTable",
"(",
"''",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"elFromTable",
")",
")",
"{",
"$",
"confirmText",
"=",
"$",
"this",
"->",
"clipObj",
"->",
"confirmMsgText",
"(",
"'pages'",
",",
"$",
"this",
"->",
"pageRow",
",",
"'into'",
",",
"$",
"elFromTable",
")",
";",
"$",
"buttons",
"[",
"'paste'",
"]",
"=",
"'<a'",
".",
"' href=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"clipObj",
"->",
"pasteUrl",
"(",
"''",
",",
"$",
"this",
"->",
"id",
")",
")",
".",
"'\"'",
".",
"' title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"lang",
"->",
"getLL",
"(",
"'clip_paste'",
")",
")",
".",
"'\"'",
".",
"' class=\"t3js-modal-trigger\"'",
".",
"' data-severity=\"warning\"'",
".",
"' data-title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"lang",
"->",
"getLL",
"(",
"'clip_paste'",
")",
")",
".",
"'\"'",
".",
"' data-content=\"'",
".",
"htmlspecialchars",
"(",
"$",
"confirmText",
")",
".",
"'\"'",
".",
"'>'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-document-paste-into'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"}",
"}",
"// Cache",
"$",
"buttons",
"[",
"'cache'",
"]",
"=",
"'<a href=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"listURL",
"(",
")",
".",
"'&clear_cache=1'",
")",
".",
"'\" title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"lang",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.clear_cache'",
")",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-system-cache-clear'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"if",
"(",
"$",
"this",
"->",
"table",
"&&",
"(",
"!",
"isset",
"(",
"$",
"module",
"->",
"modTSconfig",
"[",
"'properties'",
"]",
"[",
"'noExportRecordsLinks'",
"]",
")",
"||",
"(",
"isset",
"(",
"$",
"module",
"->",
"modTSconfig",
"[",
"'properties'",
"]",
"[",
"'noExportRecordsLinks'",
"]",
")",
"&&",
"!",
"$",
"module",
"->",
"modTSconfig",
"[",
"'properties'",
"]",
"[",
"'noExportRecordsLinks'",
"]",
")",
")",
")",
"{",
"// CSV",
"$",
"buttons",
"[",
"'csv'",
"]",
"=",
"'<a href=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"listURL",
"(",
")",
".",
"'&csv=1'",
")",
".",
"'\" title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"lang",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.csv'",
")",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-document-export-csv'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"// Export",
"if",
"(",
"ExtensionManagementUtility",
"::",
"isLoaded",
"(",
"'impexp'",
")",
")",
"{",
"$",
"url",
"=",
"(",
"string",
")",
"$",
"uriBuilder",
"->",
"buildUriFromRoute",
"(",
"'xMOD_tximpexp'",
",",
"[",
"'tx_impexp[action]'",
"=>",
"'export'",
"]",
")",
";",
"$",
"buttons",
"[",
"'export'",
"]",
"=",
"'<a href=\"'",
".",
"htmlspecialchars",
"(",
"$",
"url",
".",
"'&tx_impexp[list][]='",
".",
"rawurlencode",
"(",
"$",
"this",
"->",
"table",
".",
"':'",
".",
"$",
"this",
"->",
"id",
")",
")",
".",
"'\" title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"lang",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:rm.export'",
")",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-document-export-t3d'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"}",
"}",
"// Reload",
"$",
"buttons",
"[",
"'reload'",
"]",
"=",
"'<a href=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"listURL",
"(",
")",
")",
".",
"'\" title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"lang",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.reload'",
")",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-refresh'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"// Shortcut",
"if",
"(",
"$",
"backendUser",
"->",
"mayMakeShortcut",
"(",
")",
")",
"{",
"$",
"buttons",
"[",
"'shortcut'",
"]",
"=",
"$",
"this",
"->",
"getDocumentTemplate",
"(",
")",
"->",
"makeShortcutIcon",
"(",
"'id, M, imagemode, pointer, table, search_field, search_levels, showLimit, sortField, sortRev'",
",",
"implode",
"(",
"','",
",",
"array_keys",
"(",
"$",
"this",
"->",
"MOD_MENU",
")",
")",
",",
"'web_list'",
")",
";",
"}",
"// Back",
"if",
"(",
"$",
"this",
"->",
"returnUrl",
")",
"{",
"$",
"href",
"=",
"htmlspecialchars",
"(",
"GeneralUtility",
"::",
"linkThisUrl",
"(",
"$",
"this",
"->",
"returnUrl",
",",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"id",
"]",
")",
")",
";",
"$",
"buttons",
"[",
"'back'",
"]",
"=",
"'<a href=\"'",
".",
"$",
"href",
".",
"'\" class=\"typo3-goBack\" title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"lang",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.goBack'",
")",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-view-go-back'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"}",
"}",
"return",
"$",
"buttons",
";",
"}"
] | Create the panel of buttons for submitting the form or otherwise perform
operations.
@return string[] All available buttons as an assoc. array
@throws RouteNotFoundException | [
"Create",
"the",
"panel",
"of",
"buttons",
"for",
"submitting",
"the",
"form",
"or",
"otherwise",
"perform",
"operations",
"."
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Xclass/DatabaseRecordList.php#L259-L400 |
TYPO3-extensions/gridelements | Classes/Xclass/DatabaseRecordList.php | DatabaseRecordList.getDocHeaderButtons | public function getDocHeaderButtons(ModuleTemplate $moduleTemplate)
{
$buttonBar = $moduleTemplate->getDocHeaderComponent()->getButtonBar();
$module = $this->getModule();
$backendUser = $this->getBackendUserAuthentication();
$lang = $this->getLanguageService();
// Get users permissions for this page record:
$localCalcPerms = $backendUser->calcPerms($this->pageRow);
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
// CSH
if ((string)$this->id === '') {
$fieldName = 'list_module_noId';
} elseif (!$this->id) {
$fieldName = 'list_module_root';
} else {
$fieldName = 'list_module';
}
$cshButton = $buttonBar->makeHelpButton()
->setModuleName('xMOD_csh_corebe')
->setFieldName($fieldName);
$buttonBar->addButton($cshButton);
if (isset($this->id)) {
// View Exclude doktypes 254,255 Configuration:
// mod.web_list.noViewWithDokTypes = 254,255
if (isset($module->modTSconfig['properties']['noViewWithDokTypes'])) {
$noViewDokTypes = GeneralUtility::trimExplode(
',',
$module->modTSconfig['properties']['noViewWithDokTypes'],
true
);
} else {
//default exclusion: doktype 254 (folder), 255 (recycler)
$noViewDokTypes = [
PageRepository::DOKTYPE_SYSFOLDER,
PageRepository::DOKTYPE_RECYCLER,
];
}
// New record on pages that are not locked by editlock
if (!$module->modTSconfig['properties']['noCreateRecordsLink'] && $this->editLockPermissions()) {
$onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue((string)$uriBuilder->buildUriFromRoute(
'db_new',
['id' => $this->id]
)) . ');';
$newRecordButton = $buttonBar->makeLinkButton()
->setHref('#')
->setOnClick($onClick)
->setTitle($lang->getLL('newRecordGeneral'))
->setIcon($this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL));
$buttonBar->addButton($newRecordButton, ButtonBar::BUTTON_POSITION_LEFT, 10);
}
if (!in_array($this->pageRow['doktype'], $noViewDokTypes)) {
$onClick = BackendUtility::viewOnClick($this->id, '', BackendUtility::BEgetRootLine($this->id));
$viewButton = $buttonBar->makeLinkButton()
->setHref('#')
->setOnClick($onClick)
->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage'))
->setIcon($this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL));
$buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 20);
}
// If edit permissions are set, see
// \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
if ($localCalcPerms & Permission::PAGE_EDIT && !empty($this->id) && $this->editLockPermissions()) {
// Edit
$params = '&edit[pages][' . $this->pageRow['uid'] . ']=edit';
$onClick = BackendUtility::editOnClick($params, '', -1);
$editButton = $buttonBar->makeLinkButton()
->setHref('#')
->setOnClick($onClick)
->setTitle($lang->getLL('editPage'))
->setIcon($this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL));
$buttonBar->addButton($editButton, ButtonBar::BUTTON_POSITION_LEFT, 20);
}
// Paste
if ($this->showClipboard && ($localCalcPerms & Permission::PAGE_NEW || $localCalcPerms & Permission::CONTENT_EDIT) && $this->editLockPermissions()) {
$elFromTable = $this->clipObj->elFromTable('');
if (!empty($elFromTable)) {
$confirmMessage = $this->clipObj->confirmMsgText('pages', $this->pageRow, 'into', $elFromTable);
$pasteButton = $buttonBar->makeLinkButton()
->setHref($this->clipObj->pasteUrl('', $this->id))
->setTitle($lang->getLL('clip_paste'))
->setClasses('t3js-modal-trigger')
->setDataAttributes([
'severity' => 'warning',
'content' => $confirmMessage,
'title' => $lang->getLL('clip_paste'),
])
->setIcon($this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL));
$buttonBar->addButton($pasteButton, ButtonBar::BUTTON_POSITION_LEFT, 40);
}
}
// Cache
$clearCacheButton = $buttonBar->makeLinkButton()
->setHref($this->listURL() . '&clear_cache=1')
->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.clear_cache'))
->setIcon($this->iconFactory->getIcon('actions-system-cache-clear', Icon::SIZE_SMALL));
$buttonBar->addButton($clearCacheButton, ButtonBar::BUTTON_POSITION_RIGHT);
if ($this->table && (!isset($module->modTSconfig['properties']['noExportRecordsLinks'])
|| (isset($module->modTSconfig['properties']['noExportRecordsLinks'])
&& !$module->modTSconfig['properties']['noExportRecordsLinks']))
) {
// CSV
$csvButton = $buttonBar->makeLinkButton()
->setHref($this->listURL() . '&csv=1')
->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.csv'))
->setIcon($this->iconFactory->getIcon('actions-document-export-csv', Icon::SIZE_SMALL));
$buttonBar->addButton($csvButton, ButtonBar::BUTTON_POSITION_LEFT, 40);
// Export
if (ExtensionManagementUtility::isLoaded('impexp')) {
$url = (string)$uriBuilder->buildUriFromRoute('xMOD_tximpexp', ['tx_impexp[action]' => 'export']);
$exportButton = $buttonBar->makeLinkButton()
->setHref($url . '&tx_impexp[list][]=' . rawurlencode($this->table . ':' . $this->id))
->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:rm.export'))
->setIcon($this->iconFactory->getIcon('actions-document-export-t3d', Icon::SIZE_SMALL));
$buttonBar->addButton($exportButton, ButtonBar::BUTTON_POSITION_LEFT, 40);
}
}
// Reload
$reloadButton = $buttonBar->makeLinkButton()
->setHref($this->listURL())
->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.reload'))
->setIcon($this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL));
$buttonBar->addButton($reloadButton, ButtonBar::BUTTON_POSITION_RIGHT);
// Shortcut
if ($backendUser->mayMakeShortcut()) {
$shortCutButton = $buttonBar->makeShortcutButton()
->setModuleName('web_list')
->setGetVariables([
'id',
'route',
'imagemode',
'pointer',
'table',
'search_field',
'search_levels',
'showLimit',
'sortField',
'sortRev',
])
->setSetVariables(array_keys($this->MOD_MENU));
$buttonBar->addButton($shortCutButton, ButtonBar::BUTTON_POSITION_RIGHT);
}
// Back
if ($this->returnUrl) {
$backButton = $buttonBar->makeLinkButton()
->setHref($this->returnUrl)
->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.goBack'))
->setIcon($this->iconFactory->getIcon('actions-view-go-back', Icon::SIZE_SMALL));
$buttonBar->addButton($backButton, ButtonBar::BUTTON_POSITION_LEFT);
}
}
} | php | public function getDocHeaderButtons(ModuleTemplate $moduleTemplate)
{
$buttonBar = $moduleTemplate->getDocHeaderComponent()->getButtonBar();
$module = $this->getModule();
$backendUser = $this->getBackendUserAuthentication();
$lang = $this->getLanguageService();
// Get users permissions for this page record:
$localCalcPerms = $backendUser->calcPerms($this->pageRow);
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
// CSH
if ((string)$this->id === '') {
$fieldName = 'list_module_noId';
} elseif (!$this->id) {
$fieldName = 'list_module_root';
} else {
$fieldName = 'list_module';
}
$cshButton = $buttonBar->makeHelpButton()
->setModuleName('xMOD_csh_corebe')
->setFieldName($fieldName);
$buttonBar->addButton($cshButton);
if (isset($this->id)) {
// View Exclude doktypes 254,255 Configuration:
// mod.web_list.noViewWithDokTypes = 254,255
if (isset($module->modTSconfig['properties']['noViewWithDokTypes'])) {
$noViewDokTypes = GeneralUtility::trimExplode(
',',
$module->modTSconfig['properties']['noViewWithDokTypes'],
true
);
} else {
//default exclusion: doktype 254 (folder), 255 (recycler)
$noViewDokTypes = [
PageRepository::DOKTYPE_SYSFOLDER,
PageRepository::DOKTYPE_RECYCLER,
];
}
// New record on pages that are not locked by editlock
if (!$module->modTSconfig['properties']['noCreateRecordsLink'] && $this->editLockPermissions()) {
$onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue((string)$uriBuilder->buildUriFromRoute(
'db_new',
['id' => $this->id]
)) . ');';
$newRecordButton = $buttonBar->makeLinkButton()
->setHref('#')
->setOnClick($onClick)
->setTitle($lang->getLL('newRecordGeneral'))
->setIcon($this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL));
$buttonBar->addButton($newRecordButton, ButtonBar::BUTTON_POSITION_LEFT, 10);
}
if (!in_array($this->pageRow['doktype'], $noViewDokTypes)) {
$onClick = BackendUtility::viewOnClick($this->id, '', BackendUtility::BEgetRootLine($this->id));
$viewButton = $buttonBar->makeLinkButton()
->setHref('#')
->setOnClick($onClick)
->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage'))
->setIcon($this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL));
$buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 20);
}
// If edit permissions are set, see
// \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
if ($localCalcPerms & Permission::PAGE_EDIT && !empty($this->id) && $this->editLockPermissions()) {
// Edit
$params = '&edit[pages][' . $this->pageRow['uid'] . ']=edit';
$onClick = BackendUtility::editOnClick($params, '', -1);
$editButton = $buttonBar->makeLinkButton()
->setHref('#')
->setOnClick($onClick)
->setTitle($lang->getLL('editPage'))
->setIcon($this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL));
$buttonBar->addButton($editButton, ButtonBar::BUTTON_POSITION_LEFT, 20);
}
// Paste
if ($this->showClipboard && ($localCalcPerms & Permission::PAGE_NEW || $localCalcPerms & Permission::CONTENT_EDIT) && $this->editLockPermissions()) {
$elFromTable = $this->clipObj->elFromTable('');
if (!empty($elFromTable)) {
$confirmMessage = $this->clipObj->confirmMsgText('pages', $this->pageRow, 'into', $elFromTable);
$pasteButton = $buttonBar->makeLinkButton()
->setHref($this->clipObj->pasteUrl('', $this->id))
->setTitle($lang->getLL('clip_paste'))
->setClasses('t3js-modal-trigger')
->setDataAttributes([
'severity' => 'warning',
'content' => $confirmMessage,
'title' => $lang->getLL('clip_paste'),
])
->setIcon($this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL));
$buttonBar->addButton($pasteButton, ButtonBar::BUTTON_POSITION_LEFT, 40);
}
}
// Cache
$clearCacheButton = $buttonBar->makeLinkButton()
->setHref($this->listURL() . '&clear_cache=1')
->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.clear_cache'))
->setIcon($this->iconFactory->getIcon('actions-system-cache-clear', Icon::SIZE_SMALL));
$buttonBar->addButton($clearCacheButton, ButtonBar::BUTTON_POSITION_RIGHT);
if ($this->table && (!isset($module->modTSconfig['properties']['noExportRecordsLinks'])
|| (isset($module->modTSconfig['properties']['noExportRecordsLinks'])
&& !$module->modTSconfig['properties']['noExportRecordsLinks']))
) {
// CSV
$csvButton = $buttonBar->makeLinkButton()
->setHref($this->listURL() . '&csv=1')
->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.csv'))
->setIcon($this->iconFactory->getIcon('actions-document-export-csv', Icon::SIZE_SMALL));
$buttonBar->addButton($csvButton, ButtonBar::BUTTON_POSITION_LEFT, 40);
// Export
if (ExtensionManagementUtility::isLoaded('impexp')) {
$url = (string)$uriBuilder->buildUriFromRoute('xMOD_tximpexp', ['tx_impexp[action]' => 'export']);
$exportButton = $buttonBar->makeLinkButton()
->setHref($url . '&tx_impexp[list][]=' . rawurlencode($this->table . ':' . $this->id))
->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:rm.export'))
->setIcon($this->iconFactory->getIcon('actions-document-export-t3d', Icon::SIZE_SMALL));
$buttonBar->addButton($exportButton, ButtonBar::BUTTON_POSITION_LEFT, 40);
}
}
// Reload
$reloadButton = $buttonBar->makeLinkButton()
->setHref($this->listURL())
->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.reload'))
->setIcon($this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL));
$buttonBar->addButton($reloadButton, ButtonBar::BUTTON_POSITION_RIGHT);
// Shortcut
if ($backendUser->mayMakeShortcut()) {
$shortCutButton = $buttonBar->makeShortcutButton()
->setModuleName('web_list')
->setGetVariables([
'id',
'route',
'imagemode',
'pointer',
'table',
'search_field',
'search_levels',
'showLimit',
'sortField',
'sortRev',
])
->setSetVariables(array_keys($this->MOD_MENU));
$buttonBar->addButton($shortCutButton, ButtonBar::BUTTON_POSITION_RIGHT);
}
// Back
if ($this->returnUrl) {
$backButton = $buttonBar->makeLinkButton()
->setHref($this->returnUrl)
->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.goBack'))
->setIcon($this->iconFactory->getIcon('actions-view-go-back', Icon::SIZE_SMALL));
$buttonBar->addButton($backButton, ButtonBar::BUTTON_POSITION_LEFT);
}
}
} | [
"public",
"function",
"getDocHeaderButtons",
"(",
"ModuleTemplate",
"$",
"moduleTemplate",
")",
"{",
"$",
"buttonBar",
"=",
"$",
"moduleTemplate",
"->",
"getDocHeaderComponent",
"(",
")",
"->",
"getButtonBar",
"(",
")",
";",
"$",
"module",
"=",
"$",
"this",
"->",
"getModule",
"(",
")",
";",
"$",
"backendUser",
"=",
"$",
"this",
"->",
"getBackendUserAuthentication",
"(",
")",
";",
"$",
"lang",
"=",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
";",
"// Get users permissions for this page record:",
"$",
"localCalcPerms",
"=",
"$",
"backendUser",
"->",
"calcPerms",
"(",
"$",
"this",
"->",
"pageRow",
")",
";",
"/** @var \\TYPO3\\CMS\\Backend\\Routing\\UriBuilder $uriBuilder */",
"$",
"uriBuilder",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"\\",
"TYPO3",
"\\",
"CMS",
"\\",
"Backend",
"\\",
"Routing",
"\\",
"UriBuilder",
"::",
"class",
")",
";",
"// CSH",
"if",
"(",
"(",
"string",
")",
"$",
"this",
"->",
"id",
"===",
"''",
")",
"{",
"$",
"fieldName",
"=",
"'list_module_noId'",
";",
"}",
"elseif",
"(",
"!",
"$",
"this",
"->",
"id",
")",
"{",
"$",
"fieldName",
"=",
"'list_module_root'",
";",
"}",
"else",
"{",
"$",
"fieldName",
"=",
"'list_module'",
";",
"}",
"$",
"cshButton",
"=",
"$",
"buttonBar",
"->",
"makeHelpButton",
"(",
")",
"->",
"setModuleName",
"(",
"'xMOD_csh_corebe'",
")",
"->",
"setFieldName",
"(",
"$",
"fieldName",
")",
";",
"$",
"buttonBar",
"->",
"addButton",
"(",
"$",
"cshButton",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"id",
")",
")",
"{",
"// View Exclude doktypes 254,255 Configuration:",
"// mod.web_list.noViewWithDokTypes = 254,255",
"if",
"(",
"isset",
"(",
"$",
"module",
"->",
"modTSconfig",
"[",
"'properties'",
"]",
"[",
"'noViewWithDokTypes'",
"]",
")",
")",
"{",
"$",
"noViewDokTypes",
"=",
"GeneralUtility",
"::",
"trimExplode",
"(",
"','",
",",
"$",
"module",
"->",
"modTSconfig",
"[",
"'properties'",
"]",
"[",
"'noViewWithDokTypes'",
"]",
",",
"true",
")",
";",
"}",
"else",
"{",
"//default exclusion: doktype 254 (folder), 255 (recycler)",
"$",
"noViewDokTypes",
"=",
"[",
"PageRepository",
"::",
"DOKTYPE_SYSFOLDER",
",",
"PageRepository",
"::",
"DOKTYPE_RECYCLER",
",",
"]",
";",
"}",
"// New record on pages that are not locked by editlock",
"if",
"(",
"!",
"$",
"module",
"->",
"modTSconfig",
"[",
"'properties'",
"]",
"[",
"'noCreateRecordsLink'",
"]",
"&&",
"$",
"this",
"->",
"editLockPermissions",
"(",
")",
")",
"{",
"$",
"onClick",
"=",
"'return jumpExt('",
".",
"GeneralUtility",
"::",
"quoteJSvalue",
"(",
"(",
"string",
")",
"$",
"uriBuilder",
"->",
"buildUriFromRoute",
"(",
"'db_new'",
",",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"id",
"]",
")",
")",
".",
"');'",
";",
"$",
"newRecordButton",
"=",
"$",
"buttonBar",
"->",
"makeLinkButton",
"(",
")",
"->",
"setHref",
"(",
"'#'",
")",
"->",
"setOnClick",
"(",
"$",
"onClick",
")",
"->",
"setTitle",
"(",
"$",
"lang",
"->",
"getLL",
"(",
"'newRecordGeneral'",
")",
")",
"->",
"setIcon",
"(",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-add'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
")",
";",
"$",
"buttonBar",
"->",
"addButton",
"(",
"$",
"newRecordButton",
",",
"ButtonBar",
"::",
"BUTTON_POSITION_LEFT",
",",
"10",
")",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"this",
"->",
"pageRow",
"[",
"'doktype'",
"]",
",",
"$",
"noViewDokTypes",
")",
")",
"{",
"$",
"onClick",
"=",
"BackendUtility",
"::",
"viewOnClick",
"(",
"$",
"this",
"->",
"id",
",",
"''",
",",
"BackendUtility",
"::",
"BEgetRootLine",
"(",
"$",
"this",
"->",
"id",
")",
")",
";",
"$",
"viewButton",
"=",
"$",
"buttonBar",
"->",
"makeLinkButton",
"(",
")",
"->",
"setHref",
"(",
"'#'",
")",
"->",
"setOnClick",
"(",
"$",
"onClick",
")",
"->",
"setTitle",
"(",
"$",
"lang",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage'",
")",
")",
"->",
"setIcon",
"(",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-view-page'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
")",
";",
"$",
"buttonBar",
"->",
"addButton",
"(",
"$",
"viewButton",
",",
"ButtonBar",
"::",
"BUTTON_POSITION_LEFT",
",",
"20",
")",
";",
"}",
"// If edit permissions are set, see",
"// \\TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication",
"if",
"(",
"$",
"localCalcPerms",
"&",
"Permission",
"::",
"PAGE_EDIT",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"id",
")",
"&&",
"$",
"this",
"->",
"editLockPermissions",
"(",
")",
")",
"{",
"// Edit",
"$",
"params",
"=",
"'&edit[pages]['",
".",
"$",
"this",
"->",
"pageRow",
"[",
"'uid'",
"]",
".",
"']=edit'",
";",
"$",
"onClick",
"=",
"BackendUtility",
"::",
"editOnClick",
"(",
"$",
"params",
",",
"''",
",",
"-",
"1",
")",
";",
"$",
"editButton",
"=",
"$",
"buttonBar",
"->",
"makeLinkButton",
"(",
")",
"->",
"setHref",
"(",
"'#'",
")",
"->",
"setOnClick",
"(",
"$",
"onClick",
")",
"->",
"setTitle",
"(",
"$",
"lang",
"->",
"getLL",
"(",
"'editPage'",
")",
")",
"->",
"setIcon",
"(",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-page-open'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
")",
";",
"$",
"buttonBar",
"->",
"addButton",
"(",
"$",
"editButton",
",",
"ButtonBar",
"::",
"BUTTON_POSITION_LEFT",
",",
"20",
")",
";",
"}",
"// Paste",
"if",
"(",
"$",
"this",
"->",
"showClipboard",
"&&",
"(",
"$",
"localCalcPerms",
"&",
"Permission",
"::",
"PAGE_NEW",
"||",
"$",
"localCalcPerms",
"&",
"Permission",
"::",
"CONTENT_EDIT",
")",
"&&",
"$",
"this",
"->",
"editLockPermissions",
"(",
")",
")",
"{",
"$",
"elFromTable",
"=",
"$",
"this",
"->",
"clipObj",
"->",
"elFromTable",
"(",
"''",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"elFromTable",
")",
")",
"{",
"$",
"confirmMessage",
"=",
"$",
"this",
"->",
"clipObj",
"->",
"confirmMsgText",
"(",
"'pages'",
",",
"$",
"this",
"->",
"pageRow",
",",
"'into'",
",",
"$",
"elFromTable",
")",
";",
"$",
"pasteButton",
"=",
"$",
"buttonBar",
"->",
"makeLinkButton",
"(",
")",
"->",
"setHref",
"(",
"$",
"this",
"->",
"clipObj",
"->",
"pasteUrl",
"(",
"''",
",",
"$",
"this",
"->",
"id",
")",
")",
"->",
"setTitle",
"(",
"$",
"lang",
"->",
"getLL",
"(",
"'clip_paste'",
")",
")",
"->",
"setClasses",
"(",
"'t3js-modal-trigger'",
")",
"->",
"setDataAttributes",
"(",
"[",
"'severity'",
"=>",
"'warning'",
",",
"'content'",
"=>",
"$",
"confirmMessage",
",",
"'title'",
"=>",
"$",
"lang",
"->",
"getLL",
"(",
"'clip_paste'",
")",
",",
"]",
")",
"->",
"setIcon",
"(",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-document-paste-into'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
")",
";",
"$",
"buttonBar",
"->",
"addButton",
"(",
"$",
"pasteButton",
",",
"ButtonBar",
"::",
"BUTTON_POSITION_LEFT",
",",
"40",
")",
";",
"}",
"}",
"// Cache",
"$",
"clearCacheButton",
"=",
"$",
"buttonBar",
"->",
"makeLinkButton",
"(",
")",
"->",
"setHref",
"(",
"$",
"this",
"->",
"listURL",
"(",
")",
".",
"'&clear_cache=1'",
")",
"->",
"setTitle",
"(",
"$",
"lang",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.clear_cache'",
")",
")",
"->",
"setIcon",
"(",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-system-cache-clear'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
")",
";",
"$",
"buttonBar",
"->",
"addButton",
"(",
"$",
"clearCacheButton",
",",
"ButtonBar",
"::",
"BUTTON_POSITION_RIGHT",
")",
";",
"if",
"(",
"$",
"this",
"->",
"table",
"&&",
"(",
"!",
"isset",
"(",
"$",
"module",
"->",
"modTSconfig",
"[",
"'properties'",
"]",
"[",
"'noExportRecordsLinks'",
"]",
")",
"||",
"(",
"isset",
"(",
"$",
"module",
"->",
"modTSconfig",
"[",
"'properties'",
"]",
"[",
"'noExportRecordsLinks'",
"]",
")",
"&&",
"!",
"$",
"module",
"->",
"modTSconfig",
"[",
"'properties'",
"]",
"[",
"'noExportRecordsLinks'",
"]",
")",
")",
")",
"{",
"// CSV",
"$",
"csvButton",
"=",
"$",
"buttonBar",
"->",
"makeLinkButton",
"(",
")",
"->",
"setHref",
"(",
"$",
"this",
"->",
"listURL",
"(",
")",
".",
"'&csv=1'",
")",
"->",
"setTitle",
"(",
"$",
"lang",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.csv'",
")",
")",
"->",
"setIcon",
"(",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-document-export-csv'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
")",
";",
"$",
"buttonBar",
"->",
"addButton",
"(",
"$",
"csvButton",
",",
"ButtonBar",
"::",
"BUTTON_POSITION_LEFT",
",",
"40",
")",
";",
"// Export",
"if",
"(",
"ExtensionManagementUtility",
"::",
"isLoaded",
"(",
"'impexp'",
")",
")",
"{",
"$",
"url",
"=",
"(",
"string",
")",
"$",
"uriBuilder",
"->",
"buildUriFromRoute",
"(",
"'xMOD_tximpexp'",
",",
"[",
"'tx_impexp[action]'",
"=>",
"'export'",
"]",
")",
";",
"$",
"exportButton",
"=",
"$",
"buttonBar",
"->",
"makeLinkButton",
"(",
")",
"->",
"setHref",
"(",
"$",
"url",
".",
"'&tx_impexp[list][]='",
".",
"rawurlencode",
"(",
"$",
"this",
"->",
"table",
".",
"':'",
".",
"$",
"this",
"->",
"id",
")",
")",
"->",
"setTitle",
"(",
"$",
"lang",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:rm.export'",
")",
")",
"->",
"setIcon",
"(",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-document-export-t3d'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
")",
";",
"$",
"buttonBar",
"->",
"addButton",
"(",
"$",
"exportButton",
",",
"ButtonBar",
"::",
"BUTTON_POSITION_LEFT",
",",
"40",
")",
";",
"}",
"}",
"// Reload",
"$",
"reloadButton",
"=",
"$",
"buttonBar",
"->",
"makeLinkButton",
"(",
")",
"->",
"setHref",
"(",
"$",
"this",
"->",
"listURL",
"(",
")",
")",
"->",
"setTitle",
"(",
"$",
"lang",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.reload'",
")",
")",
"->",
"setIcon",
"(",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-refresh'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
")",
";",
"$",
"buttonBar",
"->",
"addButton",
"(",
"$",
"reloadButton",
",",
"ButtonBar",
"::",
"BUTTON_POSITION_RIGHT",
")",
";",
"// Shortcut",
"if",
"(",
"$",
"backendUser",
"->",
"mayMakeShortcut",
"(",
")",
")",
"{",
"$",
"shortCutButton",
"=",
"$",
"buttonBar",
"->",
"makeShortcutButton",
"(",
")",
"->",
"setModuleName",
"(",
"'web_list'",
")",
"->",
"setGetVariables",
"(",
"[",
"'id'",
",",
"'route'",
",",
"'imagemode'",
",",
"'pointer'",
",",
"'table'",
",",
"'search_field'",
",",
"'search_levels'",
",",
"'showLimit'",
",",
"'sortField'",
",",
"'sortRev'",
",",
"]",
")",
"->",
"setSetVariables",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"MOD_MENU",
")",
")",
";",
"$",
"buttonBar",
"->",
"addButton",
"(",
"$",
"shortCutButton",
",",
"ButtonBar",
"::",
"BUTTON_POSITION_RIGHT",
")",
";",
"}",
"// Back",
"if",
"(",
"$",
"this",
"->",
"returnUrl",
")",
"{",
"$",
"backButton",
"=",
"$",
"buttonBar",
"->",
"makeLinkButton",
"(",
")",
"->",
"setHref",
"(",
"$",
"this",
"->",
"returnUrl",
")",
"->",
"setTitle",
"(",
"$",
"lang",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.goBack'",
")",
")",
"->",
"setIcon",
"(",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-view-go-back'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
")",
";",
"$",
"buttonBar",
"->",
"addButton",
"(",
"$",
"backButton",
",",
"ButtonBar",
"::",
"BUTTON_POSITION_LEFT",
")",
";",
"}",
"}",
"}"
] | Create the panel of buttons for submitting the form or otherwise perform
operations.
@param ModuleTemplate $moduleTemplate
@throws RouteNotFoundException | [
"Create",
"the",
"panel",
"of",
"buttons",
"for",
"submitting",
"the",
"form",
"or",
"otherwise",
"perform",
"operations",
"."
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Xclass/DatabaseRecordList.php#L436-L587 |
TYPO3-extensions/gridelements | Classes/Xclass/DatabaseRecordList.php | DatabaseRecordList.getTable | public function getTable($table, $id, $rowList = '')
{
$backendLayout = $this->getBackendLayoutView()->getSelectedBackendLayout($id);
$backendLayoutColumns = [];
if (is_array($backendLayout['__items'])) {
foreach ($backendLayout['__items'] as $backendLayoutItem) {
$backendLayoutColumns[$backendLayoutItem[1]] = htmlspecialchars($backendLayoutItem[0]);
}
}
$rowListArray = GeneralUtility::trimExplode(',', $rowList, true);
// if no columns have been specified, show description (if configured)
if (!empty($GLOBALS['TCA'][$table]['ctrl']['descriptionColumn']) && empty($rowListArray)) {
$rowListArray[] = $GLOBALS['TCA'][$table]['ctrl']['descriptionColumn'];
}
$backendUser = $this->getBackendUserAuthentication();
$lang = $this->getLanguageService();
// Init
$addWhere = '';
/** @var $queryBuilder QueryBuilder */
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
$titleCol = $GLOBALS['TCA'][$table]['ctrl']['label'];
$thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
$this->l10nEnabled = $GLOBALS['TCA'][$table]['ctrl']['languageField']
&& $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']
&& $table !== 'pages_language_overlay';
$tableCollapsed = (bool)$this->tablesCollapsed[$table];
// prepare space icon
$this->spaceIcon = '<span class="btn btn-default disabled">' . $this->iconFactory->getIcon(
'empty-empty',
Icon::SIZE_SMALL
)->render() . '</span>';
// Cleaning rowlist for duplicates and place the $titleCol as the first column always!
$this->fieldArray = [];
// title Column
// Add title column
$this->fieldArray[] = $titleCol;
// Control-Panel
if (!GeneralUtility::inList($rowList, '_CONTROL_')) {
$this->fieldArray[] = '_CONTROL_';
}
// Clipboard
if ($this->showClipboard) {
$this->fieldArray[] = '_CLIPBOARD_';
}
// Ref
if (!$this->dontShowClipControlPanels) {
$this->fieldArray[] = '_REF_';
}
// Path
if ($this->searchLevels) {
$this->fieldArray[] = '_PATH_';
}
// Localization
if ($this->l10nEnabled) {
$this->fieldArray[] = '_LOCALIZATION_';
// Do not show the "Localize to:" field when only translated records should be shown
if (!$this->showOnlyTranslatedRecords) {
$this->fieldArray[] = '_LOCALIZATION_b';
}
// Only restrict to the default language if no search request is in place
// And if only translations should be shown
if ($this->searchString === '' && !$this->showOnlyTranslatedRecords) {
$addWhere = (string)$queryBuilder->expr()->orX(
$queryBuilder->expr()->lte($GLOBALS['TCA'][$table]['ctrl']['languageField'], 0),
$queryBuilder->expr()->eq($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'], 0)
);
}
}
// Cleaning up:
$this->fieldArray = array_unique(array_merge($this->fieldArray, $rowListArray));
if ($this->noControlPanels) {
$tempArray = array_flip($this->fieldArray);
unset($tempArray['_CONTROL_']);
unset($tempArray['_CLIPBOARD_']);
$this->fieldArray = array_keys($tempArray);
}
// Creating the list of fields to include in the SQL query:
$selectFields = $this->fieldArray;
$selectFields[] = 'uid';
$selectFields[] = 'pid';
// adding column for thumbnails
if ($thumbsCol) {
$selectFields[] = $thumbsCol;
}
if ($table === 'pages') {
$selectFields[] = 'module';
$selectFields[] = 'extendToSubpages';
$selectFields[] = 'nav_hide';
$selectFields[] = 'doktype';
$selectFields[] = 'shortcut';
$selectFields[] = 'shortcut_mode';
$selectFields[] = 'mount_pid';
}
if ($table === 'tt_content') {
$selectFields[] = 'CType';
$selectFields[] = 'colPos';
$selectFields[] = 'tx_gridelements_container';
$selectFields[] = 'tx_gridelements_columns';
}
if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
$selectFields = array_merge($selectFields, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']);
}
foreach (['type', 'typeicon_column', 'editlock'] as $field) {
if ($GLOBALS['TCA'][$table]['ctrl'][$field]) {
$selectFields[] = $GLOBALS['TCA'][$table]['ctrl'][$field];
}
}
if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
$selectFields[] = 't3ver_id';
$selectFields[] = 't3ver_state';
$selectFields[] = 't3ver_wsid';
}
if ($this->l10nEnabled) {
$selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
$selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
}
if ($GLOBALS['TCA'][$table]['ctrl']['label_alt']) {
$selectFields = array_merge(
$selectFields,
GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['label_alt'], true)
);
}
// Unique list!
$selectFields = array_unique($selectFields);
$fieldListFields = $this->makeFieldList($table, 1);
if (empty($fieldListFields) && $GLOBALS['TYPO3_CONF_VARS']['BE']['debug']) {
$message = sprintf(
$lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:missingTcaColumnsMessage'),
$table,
$table
);
$messageTitle = $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:missingTcaColumnsMessageTitle');
/** @var FlashMessage $flashMessage */
$flashMessage = GeneralUtility::makeInstance(
FlashMessage::class,
$message,
$messageTitle,
FlashMessage::WARNING,
true
);
/** @var $flashMessageService FlashMessageService */
$flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
/** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
$defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
$defaultFlashMessageQueue->enqueue($flashMessage);
}
// Making sure that the fields in the field-list ARE in the field-list from TCA!
$selectFields = array_intersect($selectFields, $fieldListFields);
// Implode it into a list of fields for the SQL-statement.
$selFieldList = implode(',', $selectFields);
$this->selFieldList = $selFieldList;
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'] ?? [] as $className) {
$hookObject = GeneralUtility::makeInstance($className);
if (!$hookObject instanceof RecordListGetTableHookInterface) {
throw new \UnexpectedValueException(
$className . ' must implement interface ' . RecordListGetTableHookInterface::class,
1195114460
);
}
$hookObject->getDBlistQuery($table, $id, $addWhere, $selFieldList, $this);
}
$additionalConstraints = empty($addWhere) ? [] : [QueryHelper::stripLogicalOperatorPrefix($addWhere)];
if ($table === 'tt_content') {
$additionalConstraints[] = (string)$queryBuilder->expr()->andX(
$queryBuilder->expr()->neq('colPos', -1)
);
}
$selFieldList = GeneralUtility::trimExplode(',', $selFieldList, true);
// Create the SQL query for selecting the elements in the listing:
// do not do paging when outputting as CSV
if ($this->csvOutput) {
$this->iLimit = 0;
}
if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
// Get the two previous rows for sorting if displaying page > 1
$this->firstElementNumber -= 2;
$this->iLimit += 2;
// (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
$queryBuilder = $this->getQueryBuilder($table, $id, $additionalConstraints);
$this->firstElementNumber += 2;
$this->iLimit -= 2;
} else {
// (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
$queryBuilder = $this->getQueryBuilder($table, $id, $additionalConstraints);
}
if ($table === 'tt_content') {
array_pop($additionalConstraints);
}
// Finding the total amount of records on the page
// (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
$this->setTotalItems($table, $id, $additionalConstraints);
// Init:
$queryResult = $queryBuilder->execute();
$dbCount = 0;
$out = '';
$tableHeader = '';
$listOnlyInSingleTableMode = $this->listOnlyInSingleTableMode && !$this->table;
// If the count query returned any number of records, we perform the real query,
// selecting records.
if ($this->totalItems) {
// Fetch records only if not in single table mode
if ($listOnlyInSingleTableMode) {
$dbCount = $this->totalItems;
} else {
// Set the showLimit to the number of records when outputting as CSV
if ($this->csvOutput) {
$this->showLimit = $this->totalItems;
$this->iLimit = $this->totalItems;
$dbCount = $this->totalItems;
} else {
if ($this->firstElementNumber + $this->showLimit <= $this->totalItems) {
$dbCount = $this->showLimit + 2;
} else {
$dbCount = $this->totalItems - $this->firstElementNumber + 2;
}
}
}
}
// If any records was selected, render the list:
if ($dbCount) {
// Use a custom table title for translated pages
if ($table == 'pages' && $this->showOnlyTranslatedRecords) {
$tableTitle = htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:pageTranslation'));
} else {
$tableTitle = htmlspecialchars($lang->sL($GLOBALS['TCA'][$table]['ctrl']['title']));
if ($tableTitle === '') {
$tableTitle = $table;
}
}
// Header line is drawn
$theData = [];
if ($this->disableSingleTableView) {
$theData[$titleCol] = '<span class="c-table">' . BackendUtility::wrapInHelp($table, '', $tableTitle)
. '</span> (<span class="t3js-table-total-items">' . $this->totalItems . '</span>)';
} else {
$icon = $this->table
? '<span title="' . htmlspecialchars($lang->getLL('contractView')) . '">' . $this->iconFactory->getIcon(
'actions-view-table-collapse',
Icon::SIZE_SMALL
)->render() . '</span>'
: '<span title="' . htmlspecialchars($lang->getLL('expandView')) . '">' . $this->iconFactory->getIcon(
'actions-view-table-expand',
Icon::SIZE_SMALL
)->render() . '</span>';
$theData[$titleCol] = $this->linkWrapTable(
$table,
$tableTitle . ' (<span class="t3js-table-total-items">' . $this->totalItems . '</span>) ' . $icon
);
}
if ($listOnlyInSingleTableMode) {
$tableHeader .= BackendUtility::wrapInHelp($table, '', $theData[$titleCol]);
} else {
// Render collapse button if in multi table mode
$collapseIcon = '';
if (!$this->table) {
$href = htmlspecialchars($this->listURL() . '&collapse[' . $table . ']=' . ($tableCollapsed ? '0' : '1'));
$title = $tableCollapsed
? htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.expandTable'))
: htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.collapseTable'));
$icon = '<span class="collapseIcon">' . $this->iconFactory->getIcon(
($tableCollapsed ? 'actions-view-list-expand' : 'actions-view-list-collapse'),
Icon::SIZE_SMALL
)->render() . '</span>';
$collapseIcon = '<a href="' . $href . '" title="' . $title . '" class="pull-right t3js-toggle-recordlist" data-table="' . htmlspecialchars($table) . '" data-toggle="collapse" data-target="#recordlist-' . htmlspecialchars($table) . '">' . $icon . '</a>';
}
$tableHeader .= $theData[$titleCol] . $collapseIcon;
}
// Check if gridelements containers are expanded or collapsed
if ($table === 'tt_content') {
$this->expandedGridelements = [];
$backendUser = $this->getBackendUserAuthentication();
if (is_array($backendUser->uc['moduleData']['list']['gridelementsExpanded'])) {
$this->expandedGridelements = $backendUser->uc['moduleData']['list']['gridelementsExpanded'];
}
$expandOverride = GeneralUtility::_GP('gridelementsExpand');
if (is_array($expandOverride)) {
foreach ($expandOverride as $expandContainer => $expandValue) {
if ($expandValue) {
$this->expandedGridelements[$expandContainer] = 1;
} else {
unset($this->expandedGridelements[$expandContainer]);
}
}
$backendUser->uc['moduleData']['list']['gridelementsExpanded'] = $this->expandedGridelements;
// Save modified user uc
$backendUser->writeUC($backendUser->uc);
$returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
if ($returnUrl !== '') {
HttpUtility::redirect($returnUrl);
}
}
}
// Render table rows only if in multi table view or if in single table view
$rowOutput = '';
if (!$listOnlyInSingleTableMode || $this->table) {
// Fixing an order table for sortby tables
$this->currentTable = [];
$this->currentIdList = [];
$doSort = $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField;
$prevUid = 0;
$prevPrevUid = 0;
// Get first two rows and initialize prevPrevUid and prevUid if on page > 1
if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
$row = $queryResult->fetch();
$prevPrevUid = -((int)$row['uid']);
$row = $queryResult->fetch();
$prevUid = $row['uid'];
}
$accRows = [];
// Accumulate rows here
while ($row = $queryResult->fetch()) {
if (!$this->isRowListingConditionFulfilled($table, $row)) {
continue;
}
// In offline workspace, look for alternative record:
BackendUtility::workspaceOL($table, $row, $backendUser->workspace, true);
if (is_array($row)) {
$accRows[] = $row;
$this->currentIdList[] = $row['uid'];
if ($row['CType'] === 'gridelements_pi1') {
$this->currentContainerIdList[] = $row['uid'];
}
if ($doSort) {
if ($prevUid) {
$this->currentTable['prev'][$row['uid']] = $prevPrevUid;
$this->currentTable['next'][$prevUid] = '-' . $row['uid'];
$this->currentTable['prevUid'][$row['uid']] = $prevUid;
}
$prevPrevUid = isset($this->currentTable['prev'][$row['uid']]) ? -$prevUid : $row['pid'];
$prevUid = $row['uid'];
}
}
}
$this->totalRowCount = count($accRows);
// CSV initiated
if ($this->csvOutput) {
$this->initCSV();
}
// Render items:
$this->CBnames = [];
$this->duplicateStack = [];
$this->eCounter = $this->firstElementNumber;
$cc = 0;
$lastColPos = 0;
// The header row for the table is now created:
$out .= $this->renderListHeader($table, $this->currentIdList);
foreach ($accRows as $key => $row) {
// Render item row if counter < limit
if ($cc < $this->iLimit) {
$cc++;
$this->translations = false;
if (isset($row['colPos']) && ($row['colPos'] != $lastColPos)) {
$lastColPos = $row['colPos'];
$this->showMoveUp = false;
$rowOutput .= '<tr>
<td colspan="2"></td>
<td colspan="' . (count($this->fieldArray) - 1 + $this->maxDepth) . '" style="padding:5px;">
<br />
<strong>'
. $this->getLanguageService()->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:list.columnName')
. ' ' . ($backendLayoutColumns[$row['colPos']] ? $backendLayoutColumns[$row['colPos']] : (int)$row['colPos']) . '</strong>
</td>
</tr>';
} else {
$this->showMoveUp = true;
}
$this->showMoveDown = !isset($row['colPos']) || !isset($accRows[$key + 1])
|| $row['colPos'] == $accRows[$key + 1]['colPos'];
$rowOutput .= $this->renderListRow($table, $row, $cc, $titleCol, $thumbsCol);
// If no search happened it means that the selected
// records are either default or All language and here we will not select translations
// which point to the main record:
if ($this->l10nEnabled && $this->searchString === '') {
// For each available translation, render the record:
if (is_array($this->translations)) {
foreach ($this->translations as $lRow) {
// $lRow isn't always what we want - if record was moved we've to work with the
// placeholder records otherwise the list is messed up a bit
if ($row['_MOVE_PLH_uid'] && $row['_MOVE_PLH_pid']) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable($table);
$queryBuilder->getRestrictions()
->removeAll()
->add(GeneralUtility::makeInstance(DeletedRestriction::class));
$predicates = [
$queryBuilder->expr()->eq(
't3ver_move_id',
$queryBuilder->createNamedParameter((int)$lRow['uid'], \PDO::PARAM_INT)
),
$queryBuilder->expr()->eq(
'pid',
$queryBuilder->createNamedParameter(
(int)$row['_MOVE_PLH_pid'],
\PDO::PARAM_INT
)
),
$queryBuilder->expr()->eq(
't3ver_wsid',
$queryBuilder->createNamedParameter(
(int)$row['t3ver_wsid'],
\PDO::PARAM_INT
)
),
];
$tmpRow = $queryBuilder
->select(...$selFieldList)
->from($table)
->andWhere(...$predicates)
->execute()
->fetch();
$lRow = is_array($tmpRow) ? $tmpRow : $lRow;
}
// In offline workspace, look for alternative record:
BackendUtility::workspaceOL($table, $lRow, $backendUser->workspace, true);
if (is_array($lRow) && $backendUser->checkLanguageAccess($lRow[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) {
$this->currentIdList[] = $lRow['uid'];
$rowOutput .= $this->renderListRow(
$table,
$lRow,
$cc,
$titleCol,
$thumbsCol,
18
);
}
}
}
}
}
// Counter of total rows incremented:
$this->eCounter++;
}
// Record navigation is added to the beginning and end of the table if in single
// table mode
if ($this->table) {
$rowOutput = $this->renderListNavigation('top') . $rowOutput . $this->renderListNavigation('bottom');
} else {
// Show that there are more records than shown
if ($this->totalItems > $this->itemsLimitPerTable) {
$countOnFirstPage = $this->totalItems > $this->itemsLimitSingleTable
? $this->itemsLimitSingleTable
: $this->totalItems;
$hasMore = $this->totalItems > $this->itemsLimitSingleTable;
$colspan = $this->showIcon
? count($this->fieldArray) + 1 + $this->maxDepth
: count($this->fieldArray);
$rowOutput .= '<tr><td colspan="' . $colspan . '">
<a href="' . htmlspecialchars(($this->listURL() . '&table=' . rawurlencode($table)))
. '" class="btn btn-default">'
. '<span class="t3-icon fa fa-chevron-down"></span> <i>[1 - '
. $countOnFirstPage . ($hasMore ? '+' : '') . ']</i></a>
</td></tr>';
}
}
}
$collapseClass = $tableCollapsed && !$this->table ? 'collapse' : 'collapse in';
$dataState = $tableCollapsed && !$this->table ? 'collapsed' : 'expanded';
// The list of records is added after the header:
$out .= $rowOutput;
// ... and it is all wrapped in a table:
$out = '
<!--
DB listing of elements: "' . htmlspecialchars($table) . '"
-->
<div class="panel panel-space panel-default recordlist">
<div class="panel-heading">
' . $tableHeader . '
</div>
<div class="' . $collapseClass . '" data-state="' . $dataState . '" id="recordlist-' . htmlspecialchars($table) . '">
<div class="table-fit">
<table data-table="' . htmlspecialchars($table) . '" class="table table-striped table-hover' . ($listOnlyInSingleTableMode ? ' typo3-dblist-overview' : '') . '">
' . $out . '
</table>
</div>
</div>
</div>
';
// Output csv if...
// This ends the page with exit.
if ($this->csvOutput) {
$this->outputCSV($table);
}
}
// Return content:
return $out;
} | php | public function getTable($table, $id, $rowList = '')
{
$backendLayout = $this->getBackendLayoutView()->getSelectedBackendLayout($id);
$backendLayoutColumns = [];
if (is_array($backendLayout['__items'])) {
foreach ($backendLayout['__items'] as $backendLayoutItem) {
$backendLayoutColumns[$backendLayoutItem[1]] = htmlspecialchars($backendLayoutItem[0]);
}
}
$rowListArray = GeneralUtility::trimExplode(',', $rowList, true);
// if no columns have been specified, show description (if configured)
if (!empty($GLOBALS['TCA'][$table]['ctrl']['descriptionColumn']) && empty($rowListArray)) {
$rowListArray[] = $GLOBALS['TCA'][$table]['ctrl']['descriptionColumn'];
}
$backendUser = $this->getBackendUserAuthentication();
$lang = $this->getLanguageService();
// Init
$addWhere = '';
/** @var $queryBuilder QueryBuilder */
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
$titleCol = $GLOBALS['TCA'][$table]['ctrl']['label'];
$thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
$this->l10nEnabled = $GLOBALS['TCA'][$table]['ctrl']['languageField']
&& $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']
&& $table !== 'pages_language_overlay';
$tableCollapsed = (bool)$this->tablesCollapsed[$table];
// prepare space icon
$this->spaceIcon = '<span class="btn btn-default disabled">' . $this->iconFactory->getIcon(
'empty-empty',
Icon::SIZE_SMALL
)->render() . '</span>';
// Cleaning rowlist for duplicates and place the $titleCol as the first column always!
$this->fieldArray = [];
// title Column
// Add title column
$this->fieldArray[] = $titleCol;
// Control-Panel
if (!GeneralUtility::inList($rowList, '_CONTROL_')) {
$this->fieldArray[] = '_CONTROL_';
}
// Clipboard
if ($this->showClipboard) {
$this->fieldArray[] = '_CLIPBOARD_';
}
// Ref
if (!$this->dontShowClipControlPanels) {
$this->fieldArray[] = '_REF_';
}
// Path
if ($this->searchLevels) {
$this->fieldArray[] = '_PATH_';
}
// Localization
if ($this->l10nEnabled) {
$this->fieldArray[] = '_LOCALIZATION_';
// Do not show the "Localize to:" field when only translated records should be shown
if (!$this->showOnlyTranslatedRecords) {
$this->fieldArray[] = '_LOCALIZATION_b';
}
// Only restrict to the default language if no search request is in place
// And if only translations should be shown
if ($this->searchString === '' && !$this->showOnlyTranslatedRecords) {
$addWhere = (string)$queryBuilder->expr()->orX(
$queryBuilder->expr()->lte($GLOBALS['TCA'][$table]['ctrl']['languageField'], 0),
$queryBuilder->expr()->eq($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'], 0)
);
}
}
// Cleaning up:
$this->fieldArray = array_unique(array_merge($this->fieldArray, $rowListArray));
if ($this->noControlPanels) {
$tempArray = array_flip($this->fieldArray);
unset($tempArray['_CONTROL_']);
unset($tempArray['_CLIPBOARD_']);
$this->fieldArray = array_keys($tempArray);
}
// Creating the list of fields to include in the SQL query:
$selectFields = $this->fieldArray;
$selectFields[] = 'uid';
$selectFields[] = 'pid';
// adding column for thumbnails
if ($thumbsCol) {
$selectFields[] = $thumbsCol;
}
if ($table === 'pages') {
$selectFields[] = 'module';
$selectFields[] = 'extendToSubpages';
$selectFields[] = 'nav_hide';
$selectFields[] = 'doktype';
$selectFields[] = 'shortcut';
$selectFields[] = 'shortcut_mode';
$selectFields[] = 'mount_pid';
}
if ($table === 'tt_content') {
$selectFields[] = 'CType';
$selectFields[] = 'colPos';
$selectFields[] = 'tx_gridelements_container';
$selectFields[] = 'tx_gridelements_columns';
}
if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
$selectFields = array_merge($selectFields, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']);
}
foreach (['type', 'typeicon_column', 'editlock'] as $field) {
if ($GLOBALS['TCA'][$table]['ctrl'][$field]) {
$selectFields[] = $GLOBALS['TCA'][$table]['ctrl'][$field];
}
}
if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
$selectFields[] = 't3ver_id';
$selectFields[] = 't3ver_state';
$selectFields[] = 't3ver_wsid';
}
if ($this->l10nEnabled) {
$selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
$selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
}
if ($GLOBALS['TCA'][$table]['ctrl']['label_alt']) {
$selectFields = array_merge(
$selectFields,
GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['label_alt'], true)
);
}
// Unique list!
$selectFields = array_unique($selectFields);
$fieldListFields = $this->makeFieldList($table, 1);
if (empty($fieldListFields) && $GLOBALS['TYPO3_CONF_VARS']['BE']['debug']) {
$message = sprintf(
$lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:missingTcaColumnsMessage'),
$table,
$table
);
$messageTitle = $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:missingTcaColumnsMessageTitle');
/** @var FlashMessage $flashMessage */
$flashMessage = GeneralUtility::makeInstance(
FlashMessage::class,
$message,
$messageTitle,
FlashMessage::WARNING,
true
);
/** @var $flashMessageService FlashMessageService */
$flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
/** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
$defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
$defaultFlashMessageQueue->enqueue($flashMessage);
}
// Making sure that the fields in the field-list ARE in the field-list from TCA!
$selectFields = array_intersect($selectFields, $fieldListFields);
// Implode it into a list of fields for the SQL-statement.
$selFieldList = implode(',', $selectFields);
$this->selFieldList = $selFieldList;
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'] ?? [] as $className) {
$hookObject = GeneralUtility::makeInstance($className);
if (!$hookObject instanceof RecordListGetTableHookInterface) {
throw new \UnexpectedValueException(
$className . ' must implement interface ' . RecordListGetTableHookInterface::class,
1195114460
);
}
$hookObject->getDBlistQuery($table, $id, $addWhere, $selFieldList, $this);
}
$additionalConstraints = empty($addWhere) ? [] : [QueryHelper::stripLogicalOperatorPrefix($addWhere)];
if ($table === 'tt_content') {
$additionalConstraints[] = (string)$queryBuilder->expr()->andX(
$queryBuilder->expr()->neq('colPos', -1)
);
}
$selFieldList = GeneralUtility::trimExplode(',', $selFieldList, true);
// Create the SQL query for selecting the elements in the listing:
// do not do paging when outputting as CSV
if ($this->csvOutput) {
$this->iLimit = 0;
}
if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
// Get the two previous rows for sorting if displaying page > 1
$this->firstElementNumber -= 2;
$this->iLimit += 2;
// (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
$queryBuilder = $this->getQueryBuilder($table, $id, $additionalConstraints);
$this->firstElementNumber += 2;
$this->iLimit -= 2;
} else {
// (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
$queryBuilder = $this->getQueryBuilder($table, $id, $additionalConstraints);
}
if ($table === 'tt_content') {
array_pop($additionalConstraints);
}
// Finding the total amount of records on the page
// (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
$this->setTotalItems($table, $id, $additionalConstraints);
// Init:
$queryResult = $queryBuilder->execute();
$dbCount = 0;
$out = '';
$tableHeader = '';
$listOnlyInSingleTableMode = $this->listOnlyInSingleTableMode && !$this->table;
// If the count query returned any number of records, we perform the real query,
// selecting records.
if ($this->totalItems) {
// Fetch records only if not in single table mode
if ($listOnlyInSingleTableMode) {
$dbCount = $this->totalItems;
} else {
// Set the showLimit to the number of records when outputting as CSV
if ($this->csvOutput) {
$this->showLimit = $this->totalItems;
$this->iLimit = $this->totalItems;
$dbCount = $this->totalItems;
} else {
if ($this->firstElementNumber + $this->showLimit <= $this->totalItems) {
$dbCount = $this->showLimit + 2;
} else {
$dbCount = $this->totalItems - $this->firstElementNumber + 2;
}
}
}
}
// If any records was selected, render the list:
if ($dbCount) {
// Use a custom table title for translated pages
if ($table == 'pages' && $this->showOnlyTranslatedRecords) {
$tableTitle = htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:pageTranslation'));
} else {
$tableTitle = htmlspecialchars($lang->sL($GLOBALS['TCA'][$table]['ctrl']['title']));
if ($tableTitle === '') {
$tableTitle = $table;
}
}
// Header line is drawn
$theData = [];
if ($this->disableSingleTableView) {
$theData[$titleCol] = '<span class="c-table">' . BackendUtility::wrapInHelp($table, '', $tableTitle)
. '</span> (<span class="t3js-table-total-items">' . $this->totalItems . '</span>)';
} else {
$icon = $this->table
? '<span title="' . htmlspecialchars($lang->getLL('contractView')) . '">' . $this->iconFactory->getIcon(
'actions-view-table-collapse',
Icon::SIZE_SMALL
)->render() . '</span>'
: '<span title="' . htmlspecialchars($lang->getLL('expandView')) . '">' . $this->iconFactory->getIcon(
'actions-view-table-expand',
Icon::SIZE_SMALL
)->render() . '</span>';
$theData[$titleCol] = $this->linkWrapTable(
$table,
$tableTitle . ' (<span class="t3js-table-total-items">' . $this->totalItems . '</span>) ' . $icon
);
}
if ($listOnlyInSingleTableMode) {
$tableHeader .= BackendUtility::wrapInHelp($table, '', $theData[$titleCol]);
} else {
// Render collapse button if in multi table mode
$collapseIcon = '';
if (!$this->table) {
$href = htmlspecialchars($this->listURL() . '&collapse[' . $table . ']=' . ($tableCollapsed ? '0' : '1'));
$title = $tableCollapsed
? htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.expandTable'))
: htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.collapseTable'));
$icon = '<span class="collapseIcon">' . $this->iconFactory->getIcon(
($tableCollapsed ? 'actions-view-list-expand' : 'actions-view-list-collapse'),
Icon::SIZE_SMALL
)->render() . '</span>';
$collapseIcon = '<a href="' . $href . '" title="' . $title . '" class="pull-right t3js-toggle-recordlist" data-table="' . htmlspecialchars($table) . '" data-toggle="collapse" data-target="#recordlist-' . htmlspecialchars($table) . '">' . $icon . '</a>';
}
$tableHeader .= $theData[$titleCol] . $collapseIcon;
}
// Check if gridelements containers are expanded or collapsed
if ($table === 'tt_content') {
$this->expandedGridelements = [];
$backendUser = $this->getBackendUserAuthentication();
if (is_array($backendUser->uc['moduleData']['list']['gridelementsExpanded'])) {
$this->expandedGridelements = $backendUser->uc['moduleData']['list']['gridelementsExpanded'];
}
$expandOverride = GeneralUtility::_GP('gridelementsExpand');
if (is_array($expandOverride)) {
foreach ($expandOverride as $expandContainer => $expandValue) {
if ($expandValue) {
$this->expandedGridelements[$expandContainer] = 1;
} else {
unset($this->expandedGridelements[$expandContainer]);
}
}
$backendUser->uc['moduleData']['list']['gridelementsExpanded'] = $this->expandedGridelements;
// Save modified user uc
$backendUser->writeUC($backendUser->uc);
$returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
if ($returnUrl !== '') {
HttpUtility::redirect($returnUrl);
}
}
}
// Render table rows only if in multi table view or if in single table view
$rowOutput = '';
if (!$listOnlyInSingleTableMode || $this->table) {
// Fixing an order table for sortby tables
$this->currentTable = [];
$this->currentIdList = [];
$doSort = $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField;
$prevUid = 0;
$prevPrevUid = 0;
// Get first two rows and initialize prevPrevUid and prevUid if on page > 1
if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
$row = $queryResult->fetch();
$prevPrevUid = -((int)$row['uid']);
$row = $queryResult->fetch();
$prevUid = $row['uid'];
}
$accRows = [];
// Accumulate rows here
while ($row = $queryResult->fetch()) {
if (!$this->isRowListingConditionFulfilled($table, $row)) {
continue;
}
// In offline workspace, look for alternative record:
BackendUtility::workspaceOL($table, $row, $backendUser->workspace, true);
if (is_array($row)) {
$accRows[] = $row;
$this->currentIdList[] = $row['uid'];
if ($row['CType'] === 'gridelements_pi1') {
$this->currentContainerIdList[] = $row['uid'];
}
if ($doSort) {
if ($prevUid) {
$this->currentTable['prev'][$row['uid']] = $prevPrevUid;
$this->currentTable['next'][$prevUid] = '-' . $row['uid'];
$this->currentTable['prevUid'][$row['uid']] = $prevUid;
}
$prevPrevUid = isset($this->currentTable['prev'][$row['uid']]) ? -$prevUid : $row['pid'];
$prevUid = $row['uid'];
}
}
}
$this->totalRowCount = count($accRows);
// CSV initiated
if ($this->csvOutput) {
$this->initCSV();
}
// Render items:
$this->CBnames = [];
$this->duplicateStack = [];
$this->eCounter = $this->firstElementNumber;
$cc = 0;
$lastColPos = 0;
// The header row for the table is now created:
$out .= $this->renderListHeader($table, $this->currentIdList);
foreach ($accRows as $key => $row) {
// Render item row if counter < limit
if ($cc < $this->iLimit) {
$cc++;
$this->translations = false;
if (isset($row['colPos']) && ($row['colPos'] != $lastColPos)) {
$lastColPos = $row['colPos'];
$this->showMoveUp = false;
$rowOutput .= '<tr>
<td colspan="2"></td>
<td colspan="' . (count($this->fieldArray) - 1 + $this->maxDepth) . '" style="padding:5px;">
<br />
<strong>'
. $this->getLanguageService()->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:list.columnName')
. ' ' . ($backendLayoutColumns[$row['colPos']] ? $backendLayoutColumns[$row['colPos']] : (int)$row['colPos']) . '</strong>
</td>
</tr>';
} else {
$this->showMoveUp = true;
}
$this->showMoveDown = !isset($row['colPos']) || !isset($accRows[$key + 1])
|| $row['colPos'] == $accRows[$key + 1]['colPos'];
$rowOutput .= $this->renderListRow($table, $row, $cc, $titleCol, $thumbsCol);
// If no search happened it means that the selected
// records are either default or All language and here we will not select translations
// which point to the main record:
if ($this->l10nEnabled && $this->searchString === '') {
// For each available translation, render the record:
if (is_array($this->translations)) {
foreach ($this->translations as $lRow) {
// $lRow isn't always what we want - if record was moved we've to work with the
// placeholder records otherwise the list is messed up a bit
if ($row['_MOVE_PLH_uid'] && $row['_MOVE_PLH_pid']) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable($table);
$queryBuilder->getRestrictions()
->removeAll()
->add(GeneralUtility::makeInstance(DeletedRestriction::class));
$predicates = [
$queryBuilder->expr()->eq(
't3ver_move_id',
$queryBuilder->createNamedParameter((int)$lRow['uid'], \PDO::PARAM_INT)
),
$queryBuilder->expr()->eq(
'pid',
$queryBuilder->createNamedParameter(
(int)$row['_MOVE_PLH_pid'],
\PDO::PARAM_INT
)
),
$queryBuilder->expr()->eq(
't3ver_wsid',
$queryBuilder->createNamedParameter(
(int)$row['t3ver_wsid'],
\PDO::PARAM_INT
)
),
];
$tmpRow = $queryBuilder
->select(...$selFieldList)
->from($table)
->andWhere(...$predicates)
->execute()
->fetch();
$lRow = is_array($tmpRow) ? $tmpRow : $lRow;
}
// In offline workspace, look for alternative record:
BackendUtility::workspaceOL($table, $lRow, $backendUser->workspace, true);
if (is_array($lRow) && $backendUser->checkLanguageAccess($lRow[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) {
$this->currentIdList[] = $lRow['uid'];
$rowOutput .= $this->renderListRow(
$table,
$lRow,
$cc,
$titleCol,
$thumbsCol,
18
);
}
}
}
}
}
// Counter of total rows incremented:
$this->eCounter++;
}
// Record navigation is added to the beginning and end of the table if in single
// table mode
if ($this->table) {
$rowOutput = $this->renderListNavigation('top') . $rowOutput . $this->renderListNavigation('bottom');
} else {
// Show that there are more records than shown
if ($this->totalItems > $this->itemsLimitPerTable) {
$countOnFirstPage = $this->totalItems > $this->itemsLimitSingleTable
? $this->itemsLimitSingleTable
: $this->totalItems;
$hasMore = $this->totalItems > $this->itemsLimitSingleTable;
$colspan = $this->showIcon
? count($this->fieldArray) + 1 + $this->maxDepth
: count($this->fieldArray);
$rowOutput .= '<tr><td colspan="' . $colspan . '">
<a href="' . htmlspecialchars(($this->listURL() . '&table=' . rawurlencode($table)))
. '" class="btn btn-default">'
. '<span class="t3-icon fa fa-chevron-down"></span> <i>[1 - '
. $countOnFirstPage . ($hasMore ? '+' : '') . ']</i></a>
</td></tr>';
}
}
}
$collapseClass = $tableCollapsed && !$this->table ? 'collapse' : 'collapse in';
$dataState = $tableCollapsed && !$this->table ? 'collapsed' : 'expanded';
// The list of records is added after the header:
$out .= $rowOutput;
// ... and it is all wrapped in a table:
$out = '
<!--
DB listing of elements: "' . htmlspecialchars($table) . '"
-->
<div class="panel panel-space panel-default recordlist">
<div class="panel-heading">
' . $tableHeader . '
</div>
<div class="' . $collapseClass . '" data-state="' . $dataState . '" id="recordlist-' . htmlspecialchars($table) . '">
<div class="table-fit">
<table data-table="' . htmlspecialchars($table) . '" class="table table-striped table-hover' . ($listOnlyInSingleTableMode ? ' typo3-dblist-overview' : '') . '">
' . $out . '
</table>
</div>
</div>
</div>
';
// Output csv if...
// This ends the page with exit.
if ($this->csvOutput) {
$this->outputCSV($table);
}
}
// Return content:
return $out;
} | [
"public",
"function",
"getTable",
"(",
"$",
"table",
",",
"$",
"id",
",",
"$",
"rowList",
"=",
"''",
")",
"{",
"$",
"backendLayout",
"=",
"$",
"this",
"->",
"getBackendLayoutView",
"(",
")",
"->",
"getSelectedBackendLayout",
"(",
"$",
"id",
")",
";",
"$",
"backendLayoutColumns",
"=",
"[",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"backendLayout",
"[",
"'__items'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"backendLayout",
"[",
"'__items'",
"]",
"as",
"$",
"backendLayoutItem",
")",
"{",
"$",
"backendLayoutColumns",
"[",
"$",
"backendLayoutItem",
"[",
"1",
"]",
"]",
"=",
"htmlspecialchars",
"(",
"$",
"backendLayoutItem",
"[",
"0",
"]",
")",
";",
"}",
"}",
"$",
"rowListArray",
"=",
"GeneralUtility",
"::",
"trimExplode",
"(",
"','",
",",
"$",
"rowList",
",",
"true",
")",
";",
"// if no columns have been specified, show description (if configured)",
"if",
"(",
"!",
"empty",
"(",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'descriptionColumn'",
"]",
")",
"&&",
"empty",
"(",
"$",
"rowListArray",
")",
")",
"{",
"$",
"rowListArray",
"[",
"]",
"=",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'descriptionColumn'",
"]",
";",
"}",
"$",
"backendUser",
"=",
"$",
"this",
"->",
"getBackendUserAuthentication",
"(",
")",
";",
"$",
"lang",
"=",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
";",
"// Init",
"$",
"addWhere",
"=",
"''",
";",
"/** @var $queryBuilder QueryBuilder */",
"$",
"queryBuilder",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"ConnectionPool",
"::",
"class",
")",
"->",
"getQueryBuilderForTable",
"(",
"$",
"table",
")",
";",
"$",
"titleCol",
"=",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'label'",
"]",
";",
"$",
"thumbsCol",
"=",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'thumbnail'",
"]",
";",
"$",
"this",
"->",
"l10nEnabled",
"=",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'languageField'",
"]",
"&&",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'transOrigPointerField'",
"]",
"&&",
"$",
"table",
"!==",
"'pages_language_overlay'",
";",
"$",
"tableCollapsed",
"=",
"(",
"bool",
")",
"$",
"this",
"->",
"tablesCollapsed",
"[",
"$",
"table",
"]",
";",
"// prepare space icon",
"$",
"this",
"->",
"spaceIcon",
"=",
"'<span class=\"btn btn-default disabled\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'empty-empty'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</span>'",
";",
"// Cleaning rowlist for duplicates and place the $titleCol as the first column always!",
"$",
"this",
"->",
"fieldArray",
"=",
"[",
"]",
";",
"// title Column",
"// Add title column",
"$",
"this",
"->",
"fieldArray",
"[",
"]",
"=",
"$",
"titleCol",
";",
"// Control-Panel",
"if",
"(",
"!",
"GeneralUtility",
"::",
"inList",
"(",
"$",
"rowList",
",",
"'_CONTROL_'",
")",
")",
"{",
"$",
"this",
"->",
"fieldArray",
"[",
"]",
"=",
"'_CONTROL_'",
";",
"}",
"// Clipboard",
"if",
"(",
"$",
"this",
"->",
"showClipboard",
")",
"{",
"$",
"this",
"->",
"fieldArray",
"[",
"]",
"=",
"'_CLIPBOARD_'",
";",
"}",
"// Ref",
"if",
"(",
"!",
"$",
"this",
"->",
"dontShowClipControlPanels",
")",
"{",
"$",
"this",
"->",
"fieldArray",
"[",
"]",
"=",
"'_REF_'",
";",
"}",
"// Path",
"if",
"(",
"$",
"this",
"->",
"searchLevels",
")",
"{",
"$",
"this",
"->",
"fieldArray",
"[",
"]",
"=",
"'_PATH_'",
";",
"}",
"// Localization",
"if",
"(",
"$",
"this",
"->",
"l10nEnabled",
")",
"{",
"$",
"this",
"->",
"fieldArray",
"[",
"]",
"=",
"'_LOCALIZATION_'",
";",
"// Do not show the \"Localize to:\" field when only translated records should be shown",
"if",
"(",
"!",
"$",
"this",
"->",
"showOnlyTranslatedRecords",
")",
"{",
"$",
"this",
"->",
"fieldArray",
"[",
"]",
"=",
"'_LOCALIZATION_b'",
";",
"}",
"// Only restrict to the default language if no search request is in place",
"// And if only translations should be shown",
"if",
"(",
"$",
"this",
"->",
"searchString",
"===",
"''",
"&&",
"!",
"$",
"this",
"->",
"showOnlyTranslatedRecords",
")",
"{",
"$",
"addWhere",
"=",
"(",
"string",
")",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"orX",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"lte",
"(",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'languageField'",
"]",
",",
"0",
")",
",",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'transOrigPointerField'",
"]",
",",
"0",
")",
")",
";",
"}",
"}",
"// Cleaning up:",
"$",
"this",
"->",
"fieldArray",
"=",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"fieldArray",
",",
"$",
"rowListArray",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"noControlPanels",
")",
"{",
"$",
"tempArray",
"=",
"array_flip",
"(",
"$",
"this",
"->",
"fieldArray",
")",
";",
"unset",
"(",
"$",
"tempArray",
"[",
"'_CONTROL_'",
"]",
")",
";",
"unset",
"(",
"$",
"tempArray",
"[",
"'_CLIPBOARD_'",
"]",
")",
";",
"$",
"this",
"->",
"fieldArray",
"=",
"array_keys",
"(",
"$",
"tempArray",
")",
";",
"}",
"// Creating the list of fields to include in the SQL query:",
"$",
"selectFields",
"=",
"$",
"this",
"->",
"fieldArray",
";",
"$",
"selectFields",
"[",
"]",
"=",
"'uid'",
";",
"$",
"selectFields",
"[",
"]",
"=",
"'pid'",
";",
"// adding column for thumbnails",
"if",
"(",
"$",
"thumbsCol",
")",
"{",
"$",
"selectFields",
"[",
"]",
"=",
"$",
"thumbsCol",
";",
"}",
"if",
"(",
"$",
"table",
"===",
"'pages'",
")",
"{",
"$",
"selectFields",
"[",
"]",
"=",
"'module'",
";",
"$",
"selectFields",
"[",
"]",
"=",
"'extendToSubpages'",
";",
"$",
"selectFields",
"[",
"]",
"=",
"'nav_hide'",
";",
"$",
"selectFields",
"[",
"]",
"=",
"'doktype'",
";",
"$",
"selectFields",
"[",
"]",
"=",
"'shortcut'",
";",
"$",
"selectFields",
"[",
"]",
"=",
"'shortcut_mode'",
";",
"$",
"selectFields",
"[",
"]",
"=",
"'mount_pid'",
";",
"}",
"if",
"(",
"$",
"table",
"===",
"'tt_content'",
")",
"{",
"$",
"selectFields",
"[",
"]",
"=",
"'CType'",
";",
"$",
"selectFields",
"[",
"]",
"=",
"'colPos'",
";",
"$",
"selectFields",
"[",
"]",
"=",
"'tx_gridelements_container'",
";",
"$",
"selectFields",
"[",
"]",
"=",
"'tx_gridelements_columns'",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'enablecolumns'",
"]",
")",
")",
"{",
"$",
"selectFields",
"=",
"array_merge",
"(",
"$",
"selectFields",
",",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'enablecolumns'",
"]",
")",
";",
"}",
"foreach",
"(",
"[",
"'type'",
",",
"'typeicon_column'",
",",
"'editlock'",
"]",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"$",
"field",
"]",
")",
"{",
"$",
"selectFields",
"[",
"]",
"=",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"$",
"field",
"]",
";",
"}",
"}",
"if",
"(",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'versioningWS'",
"]",
")",
"{",
"$",
"selectFields",
"[",
"]",
"=",
"'t3ver_id'",
";",
"$",
"selectFields",
"[",
"]",
"=",
"'t3ver_state'",
";",
"$",
"selectFields",
"[",
"]",
"=",
"'t3ver_wsid'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"l10nEnabled",
")",
"{",
"$",
"selectFields",
"[",
"]",
"=",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'languageField'",
"]",
";",
"$",
"selectFields",
"[",
"]",
"=",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'transOrigPointerField'",
"]",
";",
"}",
"if",
"(",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'label_alt'",
"]",
")",
"{",
"$",
"selectFields",
"=",
"array_merge",
"(",
"$",
"selectFields",
",",
"GeneralUtility",
"::",
"trimExplode",
"(",
"','",
",",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'label_alt'",
"]",
",",
"true",
")",
")",
";",
"}",
"// Unique list!",
"$",
"selectFields",
"=",
"array_unique",
"(",
"$",
"selectFields",
")",
";",
"$",
"fieldListFields",
"=",
"$",
"this",
"->",
"makeFieldList",
"(",
"$",
"table",
",",
"1",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"fieldListFields",
")",
"&&",
"$",
"GLOBALS",
"[",
"'TYPO3_CONF_VARS'",
"]",
"[",
"'BE'",
"]",
"[",
"'debug'",
"]",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"$",
"lang",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:missingTcaColumnsMessage'",
")",
",",
"$",
"table",
",",
"$",
"table",
")",
";",
"$",
"messageTitle",
"=",
"$",
"lang",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:missingTcaColumnsMessageTitle'",
")",
";",
"/** @var FlashMessage $flashMessage */",
"$",
"flashMessage",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"FlashMessage",
"::",
"class",
",",
"$",
"message",
",",
"$",
"messageTitle",
",",
"FlashMessage",
"::",
"WARNING",
",",
"true",
")",
";",
"/** @var $flashMessageService FlashMessageService */",
"$",
"flashMessageService",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"FlashMessageService",
"::",
"class",
")",
";",
"/** @var $defaultFlashMessageQueue \\TYPO3\\CMS\\Core\\Messaging\\FlashMessageQueue */",
"$",
"defaultFlashMessageQueue",
"=",
"$",
"flashMessageService",
"->",
"getMessageQueueByIdentifier",
"(",
")",
";",
"$",
"defaultFlashMessageQueue",
"->",
"enqueue",
"(",
"$",
"flashMessage",
")",
";",
"}",
"// Making sure that the fields in the field-list ARE in the field-list from TCA!",
"$",
"selectFields",
"=",
"array_intersect",
"(",
"$",
"selectFields",
",",
"$",
"fieldListFields",
")",
";",
"// Implode it into a list of fields for the SQL-statement.",
"$",
"selFieldList",
"=",
"implode",
"(",
"','",
",",
"$",
"selectFields",
")",
";",
"$",
"this",
"->",
"selFieldList",
"=",
"$",
"selFieldList",
";",
"foreach",
"(",
"$",
"GLOBALS",
"[",
"'TYPO3_CONF_VARS'",
"]",
"[",
"'SC_OPTIONS'",
"]",
"[",
"'typo3/class.db_list_extra.inc'",
"]",
"[",
"'getTable'",
"]",
"??",
"[",
"]",
"as",
"$",
"className",
")",
"{",
"$",
"hookObject",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"$",
"className",
")",
";",
"if",
"(",
"!",
"$",
"hookObject",
"instanceof",
"RecordListGetTableHookInterface",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"$",
"className",
".",
"' must implement interface '",
".",
"RecordListGetTableHookInterface",
"::",
"class",
",",
"1195114460",
")",
";",
"}",
"$",
"hookObject",
"->",
"getDBlistQuery",
"(",
"$",
"table",
",",
"$",
"id",
",",
"$",
"addWhere",
",",
"$",
"selFieldList",
",",
"$",
"this",
")",
";",
"}",
"$",
"additionalConstraints",
"=",
"empty",
"(",
"$",
"addWhere",
")",
"?",
"[",
"]",
":",
"[",
"QueryHelper",
"::",
"stripLogicalOperatorPrefix",
"(",
"$",
"addWhere",
")",
"]",
";",
"if",
"(",
"$",
"table",
"===",
"'tt_content'",
")",
"{",
"$",
"additionalConstraints",
"[",
"]",
"=",
"(",
"string",
")",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"andX",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"neq",
"(",
"'colPos'",
",",
"-",
"1",
")",
")",
";",
"}",
"$",
"selFieldList",
"=",
"GeneralUtility",
"::",
"trimExplode",
"(",
"','",
",",
"$",
"selFieldList",
",",
"true",
")",
";",
"// Create the SQL query for selecting the elements in the listing:",
"// do not do paging when outputting as CSV",
"if",
"(",
"$",
"this",
"->",
"csvOutput",
")",
"{",
"$",
"this",
"->",
"iLimit",
"=",
"0",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"firstElementNumber",
">",
"2",
"&&",
"$",
"this",
"->",
"iLimit",
">",
"0",
")",
"{",
"// Get the two previous rows for sorting if displaying page > 1",
"$",
"this",
"->",
"firstElementNumber",
"-=",
"2",
";",
"$",
"this",
"->",
"iLimit",
"+=",
"2",
";",
"// (API function from TYPO3\\CMS\\Recordlist\\RecordList\\AbstractDatabaseRecordList)",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
"$",
"table",
",",
"$",
"id",
",",
"$",
"additionalConstraints",
")",
";",
"$",
"this",
"->",
"firstElementNumber",
"+=",
"2",
";",
"$",
"this",
"->",
"iLimit",
"-=",
"2",
";",
"}",
"else",
"{",
"// (API function from TYPO3\\CMS\\Recordlist\\RecordList\\AbstractDatabaseRecordList)",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
"$",
"table",
",",
"$",
"id",
",",
"$",
"additionalConstraints",
")",
";",
"}",
"if",
"(",
"$",
"table",
"===",
"'tt_content'",
")",
"{",
"array_pop",
"(",
"$",
"additionalConstraints",
")",
";",
"}",
"// Finding the total amount of records on the page",
"// (API function from TYPO3\\CMS\\Recordlist\\RecordList\\AbstractDatabaseRecordList)",
"$",
"this",
"->",
"setTotalItems",
"(",
"$",
"table",
",",
"$",
"id",
",",
"$",
"additionalConstraints",
")",
";",
"// Init:",
"$",
"queryResult",
"=",
"$",
"queryBuilder",
"->",
"execute",
"(",
")",
";",
"$",
"dbCount",
"=",
"0",
";",
"$",
"out",
"=",
"''",
";",
"$",
"tableHeader",
"=",
"''",
";",
"$",
"listOnlyInSingleTableMode",
"=",
"$",
"this",
"->",
"listOnlyInSingleTableMode",
"&&",
"!",
"$",
"this",
"->",
"table",
";",
"// If the count query returned any number of records, we perform the real query,",
"// selecting records.",
"if",
"(",
"$",
"this",
"->",
"totalItems",
")",
"{",
"// Fetch records only if not in single table mode",
"if",
"(",
"$",
"listOnlyInSingleTableMode",
")",
"{",
"$",
"dbCount",
"=",
"$",
"this",
"->",
"totalItems",
";",
"}",
"else",
"{",
"// Set the showLimit to the number of records when outputting as CSV",
"if",
"(",
"$",
"this",
"->",
"csvOutput",
")",
"{",
"$",
"this",
"->",
"showLimit",
"=",
"$",
"this",
"->",
"totalItems",
";",
"$",
"this",
"->",
"iLimit",
"=",
"$",
"this",
"->",
"totalItems",
";",
"$",
"dbCount",
"=",
"$",
"this",
"->",
"totalItems",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"firstElementNumber",
"+",
"$",
"this",
"->",
"showLimit",
"<=",
"$",
"this",
"->",
"totalItems",
")",
"{",
"$",
"dbCount",
"=",
"$",
"this",
"->",
"showLimit",
"+",
"2",
";",
"}",
"else",
"{",
"$",
"dbCount",
"=",
"$",
"this",
"->",
"totalItems",
"-",
"$",
"this",
"->",
"firstElementNumber",
"+",
"2",
";",
"}",
"}",
"}",
"}",
"// If any records was selected, render the list:",
"if",
"(",
"$",
"dbCount",
")",
"{",
"// Use a custom table title for translated pages",
"if",
"(",
"$",
"table",
"==",
"'pages'",
"&&",
"$",
"this",
"->",
"showOnlyTranslatedRecords",
")",
"{",
"$",
"tableTitle",
"=",
"htmlspecialchars",
"(",
"$",
"lang",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:pageTranslation'",
")",
")",
";",
"}",
"else",
"{",
"$",
"tableTitle",
"=",
"htmlspecialchars",
"(",
"$",
"lang",
"->",
"sL",
"(",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'title'",
"]",
")",
")",
";",
"if",
"(",
"$",
"tableTitle",
"===",
"''",
")",
"{",
"$",
"tableTitle",
"=",
"$",
"table",
";",
"}",
"}",
"// Header line is drawn",
"$",
"theData",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"disableSingleTableView",
")",
"{",
"$",
"theData",
"[",
"$",
"titleCol",
"]",
"=",
"'<span class=\"c-table\">'",
".",
"BackendUtility",
"::",
"wrapInHelp",
"(",
"$",
"table",
",",
"''",
",",
"$",
"tableTitle",
")",
".",
"'</span> (<span class=\"t3js-table-total-items\">'",
".",
"$",
"this",
"->",
"totalItems",
".",
"'</span>)'",
";",
"}",
"else",
"{",
"$",
"icon",
"=",
"$",
"this",
"->",
"table",
"?",
"'<span title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"lang",
"->",
"getLL",
"(",
"'contractView'",
")",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-view-table-collapse'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</span>'",
":",
"'<span title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"lang",
"->",
"getLL",
"(",
"'expandView'",
")",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-view-table-expand'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</span>'",
";",
"$",
"theData",
"[",
"$",
"titleCol",
"]",
"=",
"$",
"this",
"->",
"linkWrapTable",
"(",
"$",
"table",
",",
"$",
"tableTitle",
".",
"' (<span class=\"t3js-table-total-items\">'",
".",
"$",
"this",
"->",
"totalItems",
".",
"'</span>) '",
".",
"$",
"icon",
")",
";",
"}",
"if",
"(",
"$",
"listOnlyInSingleTableMode",
")",
"{",
"$",
"tableHeader",
".=",
"BackendUtility",
"::",
"wrapInHelp",
"(",
"$",
"table",
",",
"''",
",",
"$",
"theData",
"[",
"$",
"titleCol",
"]",
")",
";",
"}",
"else",
"{",
"// Render collapse button if in multi table mode",
"$",
"collapseIcon",
"=",
"''",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"table",
")",
"{",
"$",
"href",
"=",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"listURL",
"(",
")",
".",
"'&collapse['",
".",
"$",
"table",
".",
"']='",
".",
"(",
"$",
"tableCollapsed",
"?",
"'0'",
":",
"'1'",
")",
")",
";",
"$",
"title",
"=",
"$",
"tableCollapsed",
"?",
"htmlspecialchars",
"(",
"$",
"lang",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.expandTable'",
")",
")",
":",
"htmlspecialchars",
"(",
"$",
"lang",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.collapseTable'",
")",
")",
";",
"$",
"icon",
"=",
"'<span class=\"collapseIcon\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"(",
"$",
"tableCollapsed",
"?",
"'actions-view-list-expand'",
":",
"'actions-view-list-collapse'",
")",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</span>'",
";",
"$",
"collapseIcon",
"=",
"'<a href=\"'",
".",
"$",
"href",
".",
"'\" title=\"'",
".",
"$",
"title",
".",
"'\" class=\"pull-right t3js-toggle-recordlist\" data-table=\"'",
".",
"htmlspecialchars",
"(",
"$",
"table",
")",
".",
"'\" data-toggle=\"collapse\" data-target=\"#recordlist-'",
".",
"htmlspecialchars",
"(",
"$",
"table",
")",
".",
"'\">'",
".",
"$",
"icon",
".",
"'</a>'",
";",
"}",
"$",
"tableHeader",
".=",
"$",
"theData",
"[",
"$",
"titleCol",
"]",
".",
"$",
"collapseIcon",
";",
"}",
"// Check if gridelements containers are expanded or collapsed",
"if",
"(",
"$",
"table",
"===",
"'tt_content'",
")",
"{",
"$",
"this",
"->",
"expandedGridelements",
"=",
"[",
"]",
";",
"$",
"backendUser",
"=",
"$",
"this",
"->",
"getBackendUserAuthentication",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"backendUser",
"->",
"uc",
"[",
"'moduleData'",
"]",
"[",
"'list'",
"]",
"[",
"'gridelementsExpanded'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"expandedGridelements",
"=",
"$",
"backendUser",
"->",
"uc",
"[",
"'moduleData'",
"]",
"[",
"'list'",
"]",
"[",
"'gridelementsExpanded'",
"]",
";",
"}",
"$",
"expandOverride",
"=",
"GeneralUtility",
"::",
"_GP",
"(",
"'gridelementsExpand'",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"expandOverride",
")",
")",
"{",
"foreach",
"(",
"$",
"expandOverride",
"as",
"$",
"expandContainer",
"=>",
"$",
"expandValue",
")",
"{",
"if",
"(",
"$",
"expandValue",
")",
"{",
"$",
"this",
"->",
"expandedGridelements",
"[",
"$",
"expandContainer",
"]",
"=",
"1",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"this",
"->",
"expandedGridelements",
"[",
"$",
"expandContainer",
"]",
")",
";",
"}",
"}",
"$",
"backendUser",
"->",
"uc",
"[",
"'moduleData'",
"]",
"[",
"'list'",
"]",
"[",
"'gridelementsExpanded'",
"]",
"=",
"$",
"this",
"->",
"expandedGridelements",
";",
"// Save modified user uc",
"$",
"backendUser",
"->",
"writeUC",
"(",
"$",
"backendUser",
"->",
"uc",
")",
";",
"$",
"returnUrl",
"=",
"GeneralUtility",
"::",
"sanitizeLocalUrl",
"(",
"GeneralUtility",
"::",
"_GP",
"(",
"'returnUrl'",
")",
")",
";",
"if",
"(",
"$",
"returnUrl",
"!==",
"''",
")",
"{",
"HttpUtility",
"::",
"redirect",
"(",
"$",
"returnUrl",
")",
";",
"}",
"}",
"}",
"// Render table rows only if in multi table view or if in single table view",
"$",
"rowOutput",
"=",
"''",
";",
"if",
"(",
"!",
"$",
"listOnlyInSingleTableMode",
"||",
"$",
"this",
"->",
"table",
")",
"{",
"// Fixing an order table for sortby tables",
"$",
"this",
"->",
"currentTable",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"currentIdList",
"=",
"[",
"]",
";",
"$",
"doSort",
"=",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'sortby'",
"]",
"&&",
"!",
"$",
"this",
"->",
"sortField",
";",
"$",
"prevUid",
"=",
"0",
";",
"$",
"prevPrevUid",
"=",
"0",
";",
"// Get first two rows and initialize prevPrevUid and prevUid if on page > 1",
"if",
"(",
"$",
"this",
"->",
"firstElementNumber",
">",
"2",
"&&",
"$",
"this",
"->",
"iLimit",
">",
"0",
")",
"{",
"$",
"row",
"=",
"$",
"queryResult",
"->",
"fetch",
"(",
")",
";",
"$",
"prevPrevUid",
"=",
"-",
"(",
"(",
"int",
")",
"$",
"row",
"[",
"'uid'",
"]",
")",
";",
"$",
"row",
"=",
"$",
"queryResult",
"->",
"fetch",
"(",
")",
";",
"$",
"prevUid",
"=",
"$",
"row",
"[",
"'uid'",
"]",
";",
"}",
"$",
"accRows",
"=",
"[",
"]",
";",
"// Accumulate rows here",
"while",
"(",
"$",
"row",
"=",
"$",
"queryResult",
"->",
"fetch",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isRowListingConditionFulfilled",
"(",
"$",
"table",
",",
"$",
"row",
")",
")",
"{",
"continue",
";",
"}",
"// In offline workspace, look for alternative record:",
"BackendUtility",
"::",
"workspaceOL",
"(",
"$",
"table",
",",
"$",
"row",
",",
"$",
"backendUser",
"->",
"workspace",
",",
"true",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"row",
")",
")",
"{",
"$",
"accRows",
"[",
"]",
"=",
"$",
"row",
";",
"$",
"this",
"->",
"currentIdList",
"[",
"]",
"=",
"$",
"row",
"[",
"'uid'",
"]",
";",
"if",
"(",
"$",
"row",
"[",
"'CType'",
"]",
"===",
"'gridelements_pi1'",
")",
"{",
"$",
"this",
"->",
"currentContainerIdList",
"[",
"]",
"=",
"$",
"row",
"[",
"'uid'",
"]",
";",
"}",
"if",
"(",
"$",
"doSort",
")",
"{",
"if",
"(",
"$",
"prevUid",
")",
"{",
"$",
"this",
"->",
"currentTable",
"[",
"'prev'",
"]",
"[",
"$",
"row",
"[",
"'uid'",
"]",
"]",
"=",
"$",
"prevPrevUid",
";",
"$",
"this",
"->",
"currentTable",
"[",
"'next'",
"]",
"[",
"$",
"prevUid",
"]",
"=",
"'-'",
".",
"$",
"row",
"[",
"'uid'",
"]",
";",
"$",
"this",
"->",
"currentTable",
"[",
"'prevUid'",
"]",
"[",
"$",
"row",
"[",
"'uid'",
"]",
"]",
"=",
"$",
"prevUid",
";",
"}",
"$",
"prevPrevUid",
"=",
"isset",
"(",
"$",
"this",
"->",
"currentTable",
"[",
"'prev'",
"]",
"[",
"$",
"row",
"[",
"'uid'",
"]",
"]",
")",
"?",
"-",
"$",
"prevUid",
":",
"$",
"row",
"[",
"'pid'",
"]",
";",
"$",
"prevUid",
"=",
"$",
"row",
"[",
"'uid'",
"]",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"totalRowCount",
"=",
"count",
"(",
"$",
"accRows",
")",
";",
"// CSV initiated",
"if",
"(",
"$",
"this",
"->",
"csvOutput",
")",
"{",
"$",
"this",
"->",
"initCSV",
"(",
")",
";",
"}",
"// Render items:",
"$",
"this",
"->",
"CBnames",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"duplicateStack",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"eCounter",
"=",
"$",
"this",
"->",
"firstElementNumber",
";",
"$",
"cc",
"=",
"0",
";",
"$",
"lastColPos",
"=",
"0",
";",
"// The header row for the table is now created:",
"$",
"out",
".=",
"$",
"this",
"->",
"renderListHeader",
"(",
"$",
"table",
",",
"$",
"this",
"->",
"currentIdList",
")",
";",
"foreach",
"(",
"$",
"accRows",
"as",
"$",
"key",
"=>",
"$",
"row",
")",
"{",
"// Render item row if counter < limit",
"if",
"(",
"$",
"cc",
"<",
"$",
"this",
"->",
"iLimit",
")",
"{",
"$",
"cc",
"++",
";",
"$",
"this",
"->",
"translations",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"row",
"[",
"'colPos'",
"]",
")",
"&&",
"(",
"$",
"row",
"[",
"'colPos'",
"]",
"!=",
"$",
"lastColPos",
")",
")",
"{",
"$",
"lastColPos",
"=",
"$",
"row",
"[",
"'colPos'",
"]",
";",
"$",
"this",
"->",
"showMoveUp",
"=",
"false",
";",
"$",
"rowOutput",
".=",
"'<tr>\n <td colspan=\"2\"></td>\n <td colspan=\"'",
".",
"(",
"count",
"(",
"$",
"this",
"->",
"fieldArray",
")",
"-",
"1",
"+",
"$",
"this",
"->",
"maxDepth",
")",
".",
"'\" style=\"padding:5px;\">\n <br />\n <strong>'",
".",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"sL",
"(",
"'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:list.columnName'",
")",
".",
"' '",
".",
"(",
"$",
"backendLayoutColumns",
"[",
"$",
"row",
"[",
"'colPos'",
"]",
"]",
"?",
"$",
"backendLayoutColumns",
"[",
"$",
"row",
"[",
"'colPos'",
"]",
"]",
":",
"(",
"int",
")",
"$",
"row",
"[",
"'colPos'",
"]",
")",
".",
"'</strong>\n </td>\n </tr>'",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"showMoveUp",
"=",
"true",
";",
"}",
"$",
"this",
"->",
"showMoveDown",
"=",
"!",
"isset",
"(",
"$",
"row",
"[",
"'colPos'",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"accRows",
"[",
"$",
"key",
"+",
"1",
"]",
")",
"||",
"$",
"row",
"[",
"'colPos'",
"]",
"==",
"$",
"accRows",
"[",
"$",
"key",
"+",
"1",
"]",
"[",
"'colPos'",
"]",
";",
"$",
"rowOutput",
".=",
"$",
"this",
"->",
"renderListRow",
"(",
"$",
"table",
",",
"$",
"row",
",",
"$",
"cc",
",",
"$",
"titleCol",
",",
"$",
"thumbsCol",
")",
";",
"// If no search happened it means that the selected",
"// records are either default or All language and here we will not select translations",
"// which point to the main record:",
"if",
"(",
"$",
"this",
"->",
"l10nEnabled",
"&&",
"$",
"this",
"->",
"searchString",
"===",
"''",
")",
"{",
"// For each available translation, render the record:",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"translations",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"translations",
"as",
"$",
"lRow",
")",
"{",
"// $lRow isn't always what we want - if record was moved we've to work with the",
"// placeholder records otherwise the list is messed up a bit",
"if",
"(",
"$",
"row",
"[",
"'_MOVE_PLH_uid'",
"]",
"&&",
"$",
"row",
"[",
"'_MOVE_PLH_pid'",
"]",
")",
"{",
"$",
"queryBuilder",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"ConnectionPool",
"::",
"class",
")",
"->",
"getQueryBuilderForTable",
"(",
"$",
"table",
")",
";",
"$",
"queryBuilder",
"->",
"getRestrictions",
"(",
")",
"->",
"removeAll",
"(",
")",
"->",
"add",
"(",
"GeneralUtility",
"::",
"makeInstance",
"(",
"DeletedRestriction",
"::",
"class",
")",
")",
";",
"$",
"predicates",
"=",
"[",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'t3ver_move_id'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"(",
"int",
")",
"$",
"lRow",
"[",
"'uid'",
"]",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
")",
",",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'pid'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"(",
"int",
")",
"$",
"row",
"[",
"'_MOVE_PLH_pid'",
"]",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
")",
",",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'t3ver_wsid'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"(",
"int",
")",
"$",
"row",
"[",
"'t3ver_wsid'",
"]",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
")",
",",
"]",
";",
"$",
"tmpRow",
"=",
"$",
"queryBuilder",
"->",
"select",
"(",
"...",
"$",
"selFieldList",
")",
"->",
"from",
"(",
"$",
"table",
")",
"->",
"andWhere",
"(",
"...",
"$",
"predicates",
")",
"->",
"execute",
"(",
")",
"->",
"fetch",
"(",
")",
";",
"$",
"lRow",
"=",
"is_array",
"(",
"$",
"tmpRow",
")",
"?",
"$",
"tmpRow",
":",
"$",
"lRow",
";",
"}",
"// In offline workspace, look for alternative record:",
"BackendUtility",
"::",
"workspaceOL",
"(",
"$",
"table",
",",
"$",
"lRow",
",",
"$",
"backendUser",
"->",
"workspace",
",",
"true",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"lRow",
")",
"&&",
"$",
"backendUser",
"->",
"checkLanguageAccess",
"(",
"$",
"lRow",
"[",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'languageField'",
"]",
"]",
")",
")",
"{",
"$",
"this",
"->",
"currentIdList",
"[",
"]",
"=",
"$",
"lRow",
"[",
"'uid'",
"]",
";",
"$",
"rowOutput",
".=",
"$",
"this",
"->",
"renderListRow",
"(",
"$",
"table",
",",
"$",
"lRow",
",",
"$",
"cc",
",",
"$",
"titleCol",
",",
"$",
"thumbsCol",
",",
"18",
")",
";",
"}",
"}",
"}",
"}",
"}",
"// Counter of total rows incremented:",
"$",
"this",
"->",
"eCounter",
"++",
";",
"}",
"// Record navigation is added to the beginning and end of the table if in single",
"// table mode",
"if",
"(",
"$",
"this",
"->",
"table",
")",
"{",
"$",
"rowOutput",
"=",
"$",
"this",
"->",
"renderListNavigation",
"(",
"'top'",
")",
".",
"$",
"rowOutput",
".",
"$",
"this",
"->",
"renderListNavigation",
"(",
"'bottom'",
")",
";",
"}",
"else",
"{",
"// Show that there are more records than shown",
"if",
"(",
"$",
"this",
"->",
"totalItems",
">",
"$",
"this",
"->",
"itemsLimitPerTable",
")",
"{",
"$",
"countOnFirstPage",
"=",
"$",
"this",
"->",
"totalItems",
">",
"$",
"this",
"->",
"itemsLimitSingleTable",
"?",
"$",
"this",
"->",
"itemsLimitSingleTable",
":",
"$",
"this",
"->",
"totalItems",
";",
"$",
"hasMore",
"=",
"$",
"this",
"->",
"totalItems",
">",
"$",
"this",
"->",
"itemsLimitSingleTable",
";",
"$",
"colspan",
"=",
"$",
"this",
"->",
"showIcon",
"?",
"count",
"(",
"$",
"this",
"->",
"fieldArray",
")",
"+",
"1",
"+",
"$",
"this",
"->",
"maxDepth",
":",
"count",
"(",
"$",
"this",
"->",
"fieldArray",
")",
";",
"$",
"rowOutput",
".=",
"'<tr><td colspan=\"'",
".",
"$",
"colspan",
".",
"'\">\n\t\t\t\t\t\t\t\t<a href=\"'",
".",
"htmlspecialchars",
"(",
"(",
"$",
"this",
"->",
"listURL",
"(",
")",
".",
"'&table='",
".",
"rawurlencode",
"(",
"$",
"table",
")",
")",
")",
".",
"'\" class=\"btn btn-default\">'",
".",
"'<span class=\"t3-icon fa fa-chevron-down\"></span> <i>[1 - '",
".",
"$",
"countOnFirstPage",
".",
"(",
"$",
"hasMore",
"?",
"'+'",
":",
"''",
")",
".",
"']</i></a>\n\t\t\t\t\t\t\t\t</td></tr>'",
";",
"}",
"}",
"}",
"$",
"collapseClass",
"=",
"$",
"tableCollapsed",
"&&",
"!",
"$",
"this",
"->",
"table",
"?",
"'collapse'",
":",
"'collapse in'",
";",
"$",
"dataState",
"=",
"$",
"tableCollapsed",
"&&",
"!",
"$",
"this",
"->",
"table",
"?",
"'collapsed'",
":",
"'expanded'",
";",
"// The list of records is added after the header:",
"$",
"out",
".=",
"$",
"rowOutput",
";",
"// ... and it is all wrapped in a table:",
"$",
"out",
"=",
"'\n\n\n\n\t\t\t<!--\n\t\t\t\tDB listing of elements:\t\"'",
".",
"htmlspecialchars",
"(",
"$",
"table",
")",
".",
"'\"\n\t\t\t-->\n\t\t\t\t<div class=\"panel panel-space panel-default recordlist\">\n\t\t\t\t\t<div class=\"panel-heading\">\n\t\t\t\t\t'",
".",
"$",
"tableHeader",
".",
"'\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"'",
".",
"$",
"collapseClass",
".",
"'\" data-state=\"'",
".",
"$",
"dataState",
".",
"'\" id=\"recordlist-'",
".",
"htmlspecialchars",
"(",
"$",
"table",
")",
".",
"'\">\n\t\t\t\t\t\t<div class=\"table-fit\">\n\t\t\t\t\t\t\t<table data-table=\"'",
".",
"htmlspecialchars",
"(",
"$",
"table",
")",
".",
"'\" class=\"table table-striped table-hover'",
".",
"(",
"$",
"listOnlyInSingleTableMode",
"?",
"' typo3-dblist-overview'",
":",
"''",
")",
".",
"'\">\n\t\t\t\t\t\t\t\t'",
".",
"$",
"out",
".",
"'\n\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t'",
";",
"// Output csv if...",
"// This ends the page with exit.",
"if",
"(",
"$",
"this",
"->",
"csvOutput",
")",
"{",
"$",
"this",
"->",
"outputCSV",
"(",
"$",
"table",
")",
";",
"}",
"}",
"// Return content:",
"return",
"$",
"out",
";",
"}"
] | Creates the listing of records from a single table
@param string $table Table name
@param int $id Page id
@param string $rowList List of fields to show in the listing. Pseudo fields will be added including the record header.
@return string HTML table with the listing for the record.
@throws Exception | [
"Creates",
"the",
"listing",
"of",
"records",
"from",
"a",
"single",
"table"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Xclass/DatabaseRecordList.php#L598-L1094 |
TYPO3-extensions/gridelements | Classes/Xclass/DatabaseRecordList.php | DatabaseRecordList.renderListNavigation | protected function renderListNavigation($renderPart = 'top')
{
$totalPages = ceil($this->totalItems / $this->iLimit);
// Show page selector if not all records fit into one page
if ($totalPages <= 1) {
return '';
}
$content = '';
$listURL = $this->listURL('', $this->table);
// 1 = first page
// 0 = first element
$currentPage = floor($this->firstElementNumber / $this->iLimit) + 1;
// Compile first, previous, next, last and refresh buttons
if ($currentPage > 1) {
$labelFirst = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:first'));
$labelPrevious = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:previous'));
$first = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage(1) . '" title="' . $labelFirst . '">'
. $this->iconFactory->getIcon('actions-view-paging-first', Icon::SIZE_SMALL)->render() . '</a></li>';
$previous = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($currentPage - 1) . '" title="' . $labelPrevious . '">'
. $this->iconFactory->getIcon('actions-view-paging-previous', Icon::SIZE_SMALL)->render() . '</a></li>';
} else {
$first = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-first', Icon::SIZE_SMALL)->render() . '</span></li>';
$previous = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-previous', Icon::SIZE_SMALL)->render() . '</span></li>';
}
if ($currentPage < $totalPages) {
$labelNext = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:next'));
$labelLast = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:last'));
$next = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($currentPage + 1) . '" title="' . $labelNext . '">'
. $this->iconFactory->getIcon('actions-view-paging-next', Icon::SIZE_SMALL)->render() . '</a></li>';
$last = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($totalPages) . '" title="' . $labelLast . '">'
. $this->iconFactory->getIcon('actions-view-paging-last', Icon::SIZE_SMALL)->render() . '</a></li>';
} else {
$next = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-next', Icon::SIZE_SMALL)->render() . '</span></li>';
$last = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-last', Icon::SIZE_SMALL)->render() . '</span></li>';
}
$reload = '<li><a href="#" onclick="document.dblistForm.action=' . GeneralUtility::quoteJSvalue($listURL
. '&pointer=') . '+calculatePointer(document.getElementById(' . GeneralUtility::quoteJSvalue('jumpPage-' . $renderPart)
. ').value); document.dblistForm.submit(); return true;" title="'
. htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:reload')) . '">'
. $this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL)->render() . '</a></li>';
if ($renderPart === 'top') {
// Add js to traverse a page select input to a pointer value
$content = '
<script type="text/javascript">
/*<![CDATA[*/
function calculatePointer(page) {
if (page > ' . $totalPages . ') {
page = ' . $totalPages . ';
}
if (page < 1) {
page = 1;
}
return (page - 1) * ' . $this->iLimit . ';
}
/*]]>*/
</script>
';
}
$pageNumberInput = '
<input type="number" min="1" max="' . $totalPages . '" value="' . $currentPage . '" size="3" class="form-control input-sm paginator-input" id="jumpPage-' . $renderPart . '" name="jumpPage-'
. $renderPart . '" onkeyup="if (event.keyCode == 13) { document.dblistForm.action=' . htmlspecialchars(GeneralUtility::quoteJSvalue($listURL . '&pointer='))
. '+calculatePointer(this.value); document.dblistForm.submit(); } return true;" />
';
$pageIndicatorText = sprintf(
$this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:pageIndicator'),
$pageNumberInput,
$totalPages
);
$pageIndicator = '<li><span>' . $pageIndicatorText . '</span></li>';
if ($this->totalItems > $this->firstElementNumber + $this->iLimit) {
$lastElementNumber = $this->firstElementNumber + $this->iLimit;
} else {
$lastElementNumber = $this->totalItems;
}
$rangeIndicator = '<li><span>' . sprintf(
$this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:rangeIndicator'),
$this->firstElementNumber + 1,
$lastElementNumber
) . '</span></li>';
$titleColumn = $this->fieldArray[0];
$data = [
$titleColumn => $content . '
<nav class="pagination-wrap">
<ul class="pagination pagination-block">
' . $first . '
' . $previous . '
' . $rangeIndicator . '
' . $pageIndicator . '
' . $next . '
' . $last . '
' . $reload . '
</ul>
</nav>
'
];
return $this->addElement(1, '', $data, '', '', '', 'pagination');
} | php | protected function renderListNavigation($renderPart = 'top')
{
$totalPages = ceil($this->totalItems / $this->iLimit);
// Show page selector if not all records fit into one page
if ($totalPages <= 1) {
return '';
}
$content = '';
$listURL = $this->listURL('', $this->table);
// 1 = first page
// 0 = first element
$currentPage = floor($this->firstElementNumber / $this->iLimit) + 1;
// Compile first, previous, next, last and refresh buttons
if ($currentPage > 1) {
$labelFirst = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:first'));
$labelPrevious = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:previous'));
$first = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage(1) . '" title="' . $labelFirst . '">'
. $this->iconFactory->getIcon('actions-view-paging-first', Icon::SIZE_SMALL)->render() . '</a></li>';
$previous = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($currentPage - 1) . '" title="' . $labelPrevious . '">'
. $this->iconFactory->getIcon('actions-view-paging-previous', Icon::SIZE_SMALL)->render() . '</a></li>';
} else {
$first = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-first', Icon::SIZE_SMALL)->render() . '</span></li>';
$previous = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-previous', Icon::SIZE_SMALL)->render() . '</span></li>';
}
if ($currentPage < $totalPages) {
$labelNext = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:next'));
$labelLast = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:last'));
$next = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($currentPage + 1) . '" title="' . $labelNext . '">'
. $this->iconFactory->getIcon('actions-view-paging-next', Icon::SIZE_SMALL)->render() . '</a></li>';
$last = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($totalPages) . '" title="' . $labelLast . '">'
. $this->iconFactory->getIcon('actions-view-paging-last', Icon::SIZE_SMALL)->render() . '</a></li>';
} else {
$next = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-next', Icon::SIZE_SMALL)->render() . '</span></li>';
$last = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-last', Icon::SIZE_SMALL)->render() . '</span></li>';
}
$reload = '<li><a href="#" onclick="document.dblistForm.action=' . GeneralUtility::quoteJSvalue($listURL
. '&pointer=') . '+calculatePointer(document.getElementById(' . GeneralUtility::quoteJSvalue('jumpPage-' . $renderPart)
. ').value); document.dblistForm.submit(); return true;" title="'
. htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:reload')) . '">'
. $this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL)->render() . '</a></li>';
if ($renderPart === 'top') {
// Add js to traverse a page select input to a pointer value
$content = '
<script type="text/javascript">
/*<![CDATA[*/
function calculatePointer(page) {
if (page > ' . $totalPages . ') {
page = ' . $totalPages . ';
}
if (page < 1) {
page = 1;
}
return (page - 1) * ' . $this->iLimit . ';
}
/*]]>*/
</script>
';
}
$pageNumberInput = '
<input type="number" min="1" max="' . $totalPages . '" value="' . $currentPage . '" size="3" class="form-control input-sm paginator-input" id="jumpPage-' . $renderPart . '" name="jumpPage-'
. $renderPart . '" onkeyup="if (event.keyCode == 13) { document.dblistForm.action=' . htmlspecialchars(GeneralUtility::quoteJSvalue($listURL . '&pointer='))
. '+calculatePointer(this.value); document.dblistForm.submit(); } return true;" />
';
$pageIndicatorText = sprintf(
$this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:pageIndicator'),
$pageNumberInput,
$totalPages
);
$pageIndicator = '<li><span>' . $pageIndicatorText . '</span></li>';
if ($this->totalItems > $this->firstElementNumber + $this->iLimit) {
$lastElementNumber = $this->firstElementNumber + $this->iLimit;
} else {
$lastElementNumber = $this->totalItems;
}
$rangeIndicator = '<li><span>' . sprintf(
$this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:rangeIndicator'),
$this->firstElementNumber + 1,
$lastElementNumber
) . '</span></li>';
$titleColumn = $this->fieldArray[0];
$data = [
$titleColumn => $content . '
<nav class="pagination-wrap">
<ul class="pagination pagination-block">
' . $first . '
' . $previous . '
' . $rangeIndicator . '
' . $pageIndicator . '
' . $next . '
' . $last . '
' . $reload . '
</ul>
</nav>
'
];
return $this->addElement(1, '', $data, '', '', '', 'pagination');
} | [
"protected",
"function",
"renderListNavigation",
"(",
"$",
"renderPart",
"=",
"'top'",
")",
"{",
"$",
"totalPages",
"=",
"ceil",
"(",
"$",
"this",
"->",
"totalItems",
"/",
"$",
"this",
"->",
"iLimit",
")",
";",
"// Show page selector if not all records fit into one page",
"if",
"(",
"$",
"totalPages",
"<=",
"1",
")",
"{",
"return",
"''",
";",
"}",
"$",
"content",
"=",
"''",
";",
"$",
"listURL",
"=",
"$",
"this",
"->",
"listURL",
"(",
"''",
",",
"$",
"this",
"->",
"table",
")",
";",
"// 1 = first page",
"// 0 = first element",
"$",
"currentPage",
"=",
"floor",
"(",
"$",
"this",
"->",
"firstElementNumber",
"/",
"$",
"this",
"->",
"iLimit",
")",
"+",
"1",
";",
"// Compile first, previous, next, last and refresh buttons",
"if",
"(",
"$",
"currentPage",
">",
"1",
")",
"{",
"$",
"labelFirst",
"=",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:first'",
")",
")",
";",
"$",
"labelPrevious",
"=",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:previous'",
")",
")",
";",
"$",
"first",
"=",
"'<li><a href=\"'",
".",
"$",
"listURL",
".",
"'&pointer='",
".",
"$",
"this",
"->",
"getPointerForPage",
"(",
"1",
")",
".",
"'\" title=\"'",
".",
"$",
"labelFirst",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-view-paging-first'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a></li>'",
";",
"$",
"previous",
"=",
"'<li><a href=\"'",
".",
"$",
"listURL",
".",
"'&pointer='",
".",
"$",
"this",
"->",
"getPointerForPage",
"(",
"$",
"currentPage",
"-",
"1",
")",
".",
"'\" title=\"'",
".",
"$",
"labelPrevious",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-view-paging-previous'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a></li>'",
";",
"}",
"else",
"{",
"$",
"first",
"=",
"'<li class=\"disabled\"><span>'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-view-paging-first'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</span></li>'",
";",
"$",
"previous",
"=",
"'<li class=\"disabled\"><span>'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-view-paging-previous'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</span></li>'",
";",
"}",
"if",
"(",
"$",
"currentPage",
"<",
"$",
"totalPages",
")",
"{",
"$",
"labelNext",
"=",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:next'",
")",
")",
";",
"$",
"labelLast",
"=",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:last'",
")",
")",
";",
"$",
"next",
"=",
"'<li><a href=\"'",
".",
"$",
"listURL",
".",
"'&pointer='",
".",
"$",
"this",
"->",
"getPointerForPage",
"(",
"$",
"currentPage",
"+",
"1",
")",
".",
"'\" title=\"'",
".",
"$",
"labelNext",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-view-paging-next'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a></li>'",
";",
"$",
"last",
"=",
"'<li><a href=\"'",
".",
"$",
"listURL",
".",
"'&pointer='",
".",
"$",
"this",
"->",
"getPointerForPage",
"(",
"$",
"totalPages",
")",
".",
"'\" title=\"'",
".",
"$",
"labelLast",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-view-paging-last'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a></li>'",
";",
"}",
"else",
"{",
"$",
"next",
"=",
"'<li class=\"disabled\"><span>'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-view-paging-next'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</span></li>'",
";",
"$",
"last",
"=",
"'<li class=\"disabled\"><span>'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-view-paging-last'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</span></li>'",
";",
"}",
"$",
"reload",
"=",
"'<li><a href=\"#\" onclick=\"document.dblistForm.action='",
".",
"GeneralUtility",
"::",
"quoteJSvalue",
"(",
"$",
"listURL",
".",
"'&pointer='",
")",
".",
"'+calculatePointer(document.getElementById('",
".",
"GeneralUtility",
"::",
"quoteJSvalue",
"(",
"'jumpPage-'",
".",
"$",
"renderPart",
")",
".",
"').value); document.dblistForm.submit(); return true;\" title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:reload'",
")",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-refresh'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a></li>'",
";",
"if",
"(",
"$",
"renderPart",
"===",
"'top'",
")",
"{",
"// Add js to traverse a page select input to a pointer value",
"$",
"content",
"=",
"'\n<script type=\"text/javascript\">\n/*<![CDATA[*/\n\tfunction calculatePointer(page) {\n\t\tif (page > '",
".",
"$",
"totalPages",
".",
"') {\n\t\t\tpage = '",
".",
"$",
"totalPages",
".",
"';\n\t\t}\n\t\tif (page < 1) {\n\t\t\tpage = 1;\n\t\t}\n\t\treturn (page - 1) * '",
".",
"$",
"this",
"->",
"iLimit",
".",
"';\n\t}\n/*]]>*/\n</script>\n'",
";",
"}",
"$",
"pageNumberInput",
"=",
"'\n\t\t\t<input type=\"number\" min=\"1\" max=\"'",
".",
"$",
"totalPages",
".",
"'\" value=\"'",
".",
"$",
"currentPage",
".",
"'\" size=\"3\" class=\"form-control input-sm paginator-input\" id=\"jumpPage-'",
".",
"$",
"renderPart",
".",
"'\" name=\"jumpPage-'",
".",
"$",
"renderPart",
".",
"'\" onkeyup=\"if (event.keyCode == 13) { document.dblistForm.action='",
".",
"htmlspecialchars",
"(",
"GeneralUtility",
"::",
"quoteJSvalue",
"(",
"$",
"listURL",
".",
"'&pointer='",
")",
")",
".",
"'+calculatePointer(this.value); document.dblistForm.submit(); } return true;\" />\n\t\t\t'",
";",
"$",
"pageIndicatorText",
"=",
"sprintf",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:pageIndicator'",
")",
",",
"$",
"pageNumberInput",
",",
"$",
"totalPages",
")",
";",
"$",
"pageIndicator",
"=",
"'<li><span>'",
".",
"$",
"pageIndicatorText",
".",
"'</span></li>'",
";",
"if",
"(",
"$",
"this",
"->",
"totalItems",
">",
"$",
"this",
"->",
"firstElementNumber",
"+",
"$",
"this",
"->",
"iLimit",
")",
"{",
"$",
"lastElementNumber",
"=",
"$",
"this",
"->",
"firstElementNumber",
"+",
"$",
"this",
"->",
"iLimit",
";",
"}",
"else",
"{",
"$",
"lastElementNumber",
"=",
"$",
"this",
"->",
"totalItems",
";",
"}",
"$",
"rangeIndicator",
"=",
"'<li><span>'",
".",
"sprintf",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:rangeIndicator'",
")",
",",
"$",
"this",
"->",
"firstElementNumber",
"+",
"1",
",",
"$",
"lastElementNumber",
")",
".",
"'</span></li>'",
";",
"$",
"titleColumn",
"=",
"$",
"this",
"->",
"fieldArray",
"[",
"0",
"]",
";",
"$",
"data",
"=",
"[",
"$",
"titleColumn",
"=>",
"$",
"content",
".",
"'\n\t\t\t\t<nav class=\"pagination-wrap\">\n\t\t\t\t\t<ul class=\"pagination pagination-block\">\n\t\t\t\t\t\t'",
".",
"$",
"first",
".",
"'\n\t\t\t\t\t\t'",
".",
"$",
"previous",
".",
"'\n\t\t\t\t\t\t'",
".",
"$",
"rangeIndicator",
".",
"'\n\t\t\t\t\t\t'",
".",
"$",
"pageIndicator",
".",
"'\n\t\t\t\t\t\t'",
".",
"$",
"next",
".",
"'\n\t\t\t\t\t\t'",
".",
"$",
"last",
".",
"'\n\t\t\t\t\t\t'",
".",
"$",
"reload",
".",
"'\n\t\t\t\t\t</ul>\n\t\t\t\t</nav>\n\t\t\t'",
"]",
";",
"return",
"$",
"this",
"->",
"addElement",
"(",
"1",
",",
"''",
",",
"$",
"data",
",",
"''",
",",
"''",
",",
"''",
",",
"'pagination'",
")",
";",
"}"
] | Creates a page browser for tables with many records
@param string $renderPart Distinguish between 'top' and 'bottom' part of the navigation (above or below the records)
@return string Navigation HTML | [
"Creates",
"a",
"page",
"browser",
"for",
"tables",
"with",
"many",
"records"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Xclass/DatabaseRecordList.php#L1102-L1199 |
TYPO3-extensions/gridelements | Classes/Xclass/DatabaseRecordList.php | DatabaseRecordList.addHeaderRowToCSV | protected function addHeaderRowToCSV()
{
$fieldArray = array_combine($this->fieldArray, $this->fieldArray);
$hooks = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][__CLASS__]['customizeCsvHeader'] ?? [];
if (!empty($hooks)) {
$hookParameters = [
'fields' => &$fieldArray,
];
foreach ($hooks as $hookFunction) {
GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
}
}
// Add header row, control fields will be reduced inside addToCSV()
$this->addToCSV($fieldArray);
} | php | protected function addHeaderRowToCSV()
{
$fieldArray = array_combine($this->fieldArray, $this->fieldArray);
$hooks = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][__CLASS__]['customizeCsvHeader'] ?? [];
if (!empty($hooks)) {
$hookParameters = [
'fields' => &$fieldArray,
];
foreach ($hooks as $hookFunction) {
GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
}
}
// Add header row, control fields will be reduced inside addToCSV()
$this->addToCSV($fieldArray);
} | [
"protected",
"function",
"addHeaderRowToCSV",
"(",
")",
"{",
"$",
"fieldArray",
"=",
"array_combine",
"(",
"$",
"this",
"->",
"fieldArray",
",",
"$",
"this",
"->",
"fieldArray",
")",
";",
"$",
"hooks",
"=",
"$",
"GLOBALS",
"[",
"'TYPO3_CONF_VARS'",
"]",
"[",
"'SC_OPTIONS'",
"]",
"[",
"__CLASS__",
"]",
"[",
"'customizeCsvHeader'",
"]",
"??",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"hooks",
")",
")",
"{",
"$",
"hookParameters",
"=",
"[",
"'fields'",
"=>",
"&",
"$",
"fieldArray",
",",
"]",
";",
"foreach",
"(",
"$",
"hooks",
"as",
"$",
"hookFunction",
")",
"{",
"GeneralUtility",
"::",
"callUserFunction",
"(",
"$",
"hookFunction",
",",
"$",
"hookParameters",
",",
"$",
"this",
")",
";",
"}",
"}",
"// Add header row, control fields will be reduced inside addToCSV()",
"$",
"this",
"->",
"addToCSV",
"(",
"$",
"fieldArray",
")",
";",
"}"
] | Add header line with field names as CSV line | [
"Add",
"header",
"line",
"with",
"field",
"names",
"as",
"CSV",
"line"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Xclass/DatabaseRecordList.php#L1240-L1254 |
TYPO3-extensions/gridelements | Classes/Xclass/DatabaseRecordList.php | DatabaseRecordList.addToCSV | protected function addToCSV(array $row = [])
{
$rowReducedByControlFields = self::removeControlFieldsFromFieldRow($row);
// Get an field array without control fields but in the expected order
$fieldArray = array_intersect_key(array_flip($this->fieldArray), $rowReducedByControlFields);
// Overwrite fieldArray to keep the order with an array of needed fields
$rowReducedToSelectedColumns = array_replace(
$fieldArray,
array_intersect_key($rowReducedByControlFields, $fieldArray)
);
$this->setCsvRow($rowReducedToSelectedColumns);
} | php | protected function addToCSV(array $row = [])
{
$rowReducedByControlFields = self::removeControlFieldsFromFieldRow($row);
// Get an field array without control fields but in the expected order
$fieldArray = array_intersect_key(array_flip($this->fieldArray), $rowReducedByControlFields);
// Overwrite fieldArray to keep the order with an array of needed fields
$rowReducedToSelectedColumns = array_replace(
$fieldArray,
array_intersect_key($rowReducedByControlFields, $fieldArray)
);
$this->setCsvRow($rowReducedToSelectedColumns);
} | [
"protected",
"function",
"addToCSV",
"(",
"array",
"$",
"row",
"=",
"[",
"]",
")",
"{",
"$",
"rowReducedByControlFields",
"=",
"self",
"::",
"removeControlFieldsFromFieldRow",
"(",
"$",
"row",
")",
";",
"// Get an field array without control fields but in the expected order",
"$",
"fieldArray",
"=",
"array_intersect_key",
"(",
"array_flip",
"(",
"$",
"this",
"->",
"fieldArray",
")",
",",
"$",
"rowReducedByControlFields",
")",
";",
"// Overwrite fieldArray to keep the order with an array of needed fields",
"$",
"rowReducedToSelectedColumns",
"=",
"array_replace",
"(",
"$",
"fieldArray",
",",
"array_intersect_key",
"(",
"$",
"rowReducedByControlFields",
",",
"$",
"fieldArray",
")",
")",
";",
"$",
"this",
"->",
"setCsvRow",
"(",
"$",
"rowReducedToSelectedColumns",
")",
";",
"}"
] | Adds selected columns of one table row as CSV line.
@param mixed[] $row Record array, from which the values of fields found in $this->fieldArray will be listed in the CSV output. | [
"Adds",
"selected",
"columns",
"of",
"one",
"table",
"row",
"as",
"CSV",
"line",
"."
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Xclass/DatabaseRecordList.php#L1267-L1278 |
TYPO3-extensions/gridelements | Classes/Xclass/DatabaseRecordList.php | DatabaseRecordList.setCsvRow | public function setCsvRow($csvRow)
{
$csvDelimiter = $this->modTSconfig['properties']['csvDelimiter'] ?? ',';
$csvQuote = $this->modTSconfig['properties']['csvQuote'] ?? '"';
$this->csvLines[] = CsvUtility::csvValues($csvRow, $csvDelimiter, $csvQuote);
} | php | public function setCsvRow($csvRow)
{
$csvDelimiter = $this->modTSconfig['properties']['csvDelimiter'] ?? ',';
$csvQuote = $this->modTSconfig['properties']['csvQuote'] ?? '"';
$this->csvLines[] = CsvUtility::csvValues($csvRow, $csvDelimiter, $csvQuote);
} | [
"public",
"function",
"setCsvRow",
"(",
"$",
"csvRow",
")",
"{",
"$",
"csvDelimiter",
"=",
"$",
"this",
"->",
"modTSconfig",
"[",
"'properties'",
"]",
"[",
"'csvDelimiter'",
"]",
"??",
"','",
";",
"$",
"csvQuote",
"=",
"$",
"this",
"->",
"modTSconfig",
"[",
"'properties'",
"]",
"[",
"'csvQuote'",
"]",
"??",
"'\"'",
";",
"$",
"this",
"->",
"csvLines",
"[",
"]",
"=",
"CsvUtility",
"::",
"csvValues",
"(",
"$",
"csvRow",
",",
"$",
"csvDelimiter",
",",
"$",
"csvQuote",
")",
";",
"}"
] | Adds input row of values to the internal csvLines array as a CSV formatted line
@param mixed[] $csvRow Array with values to be listed. | [
"Adds",
"input",
"row",
"of",
"values",
"to",
"the",
"internal",
"csvLines",
"array",
"as",
"a",
"CSV",
"formatted",
"line"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Xclass/DatabaseRecordList.php#L1305-L1311 |
TYPO3-extensions/gridelements | Classes/Xclass/DatabaseRecordList.php | DatabaseRecordList.renderListRow | public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent = 0, $level = 0, $triggerContainer = 0, $expanded = '')
{
if (!is_array($row)) {
return '';
}
$rowOutput = '';
$id_orig = null;
// If in search mode, make sure the preview will show the correct page
if ((string)$this->searchString !== '') {
$id_orig = $this->id;
$this->id = $row['pid'];
}
$tagAttributes = [
'class' => ['t3js-entity'],
'data-table' => $table,
'title' => 'id=' . $row['uid'],
];
// Add active class to record of current link
if (
isset($this->currentLink['tableNames'])
&& (int)$this->currentLink['uid'] === (int)$row['uid']
&& GeneralUtility::inList($this->currentLink['tableNames'], $table)
) {
$tagAttributes['class'][] = 'active';
}
// Add special classes for first and last row
if ($cc == 1 && $indent == 0) {
$tagAttributes['class'][] = 'firstcol';
}
if ($cc == $this->totalRowCount || $cc == $this->iLimit) {
$tagAttributes['class'][] = 'lastcol';
}
// Overriding with versions background color if any:
if (!empty($row['_CSSCLASS'])) {
$tagAttributes['class'] = [$row['_CSSCLASS']];
}
// Incr. counter.
$this->counter++;
// The icon with link
$toolTip = BackendUtility::getRecordToolTip($row, $table);
$additionalStyle = $indent ? ' style="margin-left: ' . $indent . 'px;"' : '';
$iconImg = '<span ' . $toolTip . ' ' . $additionalStyle . '>'
. $this->iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render()
. '</span>';
$theIcon = $this->clickMenuEnabled ? BackendUtility::wrapClickMenuOnIcon(
$iconImg,
$table,
$row['uid']
) : $iconImg;
// Preparing and getting the data-array
$theData = [];
$localizationMarkerClass = '';
$lC2 = '';
foreach ($this->fieldArray as $fCol) {
if ($fCol == $titleCol) {
$recTitle = BackendUtility::getRecordTitle($table, $row, false, true);
$warning = '';
// If the record is edit-locked by another user, we will show a little warning sign:
$lockInfo = BackendUtility::isRecordLocked($table, $row['uid']);
if ($lockInfo) {
$warning = '<span data-toggle="tooltip" data-placement="right" data-title="' . htmlspecialchars($lockInfo['msg']) . '">'
. $this->iconFactory->getIcon('warning-in-use', Icon::SIZE_SMALL)->render() . '</span>';
}
$theData[$fCol] = $theData['__label'] = $warning . $this->linkWrapItems(
$table,
$row['uid'],
$recTitle,
$row
);
// Render thumbnails, if:
// - a thumbnail column exists
// - there is content in it
// - the thumbnail column is visible for the current type
$type = 0;
if (isset($GLOBALS['TCA'][$table]['ctrl']['type'])) {
$typeColumn = $GLOBALS['TCA'][$table]['ctrl']['type'];
$type = $row[$typeColumn];
}
// If current type doesn't exist, set it to 0 (or to 1 for historical reasons,
// if 0 doesn't exist)
if (!isset($GLOBALS['TCA'][$table]['types'][$type])) {
$type = isset($GLOBALS['TCA'][$table]['types'][0]) ? 0 : 1;
}
$visibleColumns = $this->getVisibleColumns($GLOBALS['TCA'][$table], $type);
if ($this->thumbs &&
trim($row[$thumbsCol]) &&
preg_match('/(^|(.*(;|,)?))' . $thumbsCol . '(((;|,).*)|$)/', $visibleColumns) === 1
) {
$thumbCode = '<br />' . $this->thumbCode($row, $table, $thumbsCol);
$theData[$fCol] .= $thumbCode;
$theData['__label'] .= $thumbCode;
}
if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
&& $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0
&& $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0
) {
// It's a translated record with a language parent
$localizationMarkerClass = ' localization';
}
} elseif ($fCol === 'pid') {
$theData[$fCol] = $row[$fCol];
} elseif ($fCol === '_PATH_') {
$theData[$fCol] = $this->recPath($row['pid']);
} elseif ($fCol === '_REF_') {
$theData[$fCol] = $this->createReferenceHtml($table, $row['uid']);
} elseif ($fCol === '_CONTROL_') {
$theData[$fCol] = $this->makeControl($table, $row);
} elseif ($fCol === '_CLIPBOARD_') {
$theData[$fCol] = $this->makeClip($table, $row);
} elseif ($fCol === '_LOCALIZATION_') {
list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row);
$theData[$fCol] = $lC1;
} elseif ($fCol !== '_LOCALIZATION_b') {
$tmpProc = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid']);
$theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
if ($this->csvOutput) {
$row[$fCol] = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
}
} elseif ($fCol === '_LOCALIZATION_b') {
$theData[$fCol] = $lC2;
} else {
$theData[$fCol] = htmlspecialchars(BackendUtility::getProcessedValueExtra(
$table,
$fCol,
$row[$fCol],
0,
$row['uid']
));
}
}
// Reset the ID if it was overwritten
if ((string)$this->searchString !== '') {
$this->id = $id_orig;
}
// Add row to CSV list:
if ($this->csvOutput) {
$hooks = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][__CLASS__]['customizeCsvRow'] ?? [];
if (!empty($hooks)) {
$hookParameters = [
'databaseRow' => &$row,
'tableName' => $table,
'pageId' => $this->id,
];
foreach ($hooks as $hookFunction) {
GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
}
}
$this->addToCSV($row);
}
// Add classes to table cells
$this->addElement_tdCssClass[$titleCol] = 'col-title col-responsive' . $localizationMarkerClass;
$this->addElement_tdCssClass['__label'] = $this->addElement_tdCssClass[$titleCol];
$this->addElement_tdCssClass['_CONTROL_'] = 'col-control';
if ($this->getModule()->MOD_SETTINGS['clipBoard']) {
$this->addElement_tdCssClass['_CLIPBOARD_'] = 'col-clipboard';
}
$this->addElement_tdCssClass['_PATH_'] = 'col-path';
$this->addElement_tdCssClass['_LOCALIZATION_'] = 'col-localizationa';
$this->addElement_tdCssClass['_LOCALIZATION_b'] = 'col-localizationb';
/**
* @hook checkChildren
* @date 2014-02-11
* @request Alexander Grein <alexander.grein@in2code.de>
*/
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ?? [] as $className) {
$hookObject = GeneralUtility::makeInstance($className);
if (is_object($hookObject) && method_exists($hookObject, 'checkChildren')) {
$hookObject->checkChildren($table, $row, $level, $theData, $this);
}
}
// Create element in table cells:
$theData['uid'] = $row['uid'];
if ($table === 'tt_content') {
$theData['tx_gridelements_container'] = (int)$row['tx_gridelements_container'];
}
if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
&& isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'])
) {
$theData['parent'] = $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']];
}
$tagAttributes = array_map(
function ($attributeValue) {
if (is_array($attributeValue)) {
return implode(' ', $attributeValue);
}
return $attributeValue;
},
$tagAttributes
);
if ($triggerContainer) {
$theData['_triggerContainer'] = $triggerContainer;
}
$rowOutput .= $this->addElement(1, $theIcon, $theData, GeneralUtility::implodeAttributes($tagAttributes, true));
if ($this->l10nEnabled) {
// For each available translation, render the record:
if (is_array($this->translations)) {
foreach ($this->translations as $lRow) {
// $lRow isn't always what we want - if record was moved we've to work with the
// placeholder records otherwise the list is messed up a bit
if ($row['_MOVE_PLH_uid'] && $row['_MOVE_PLH_pid']) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable($table);
$queryBuilder->getRestrictions()
->removeAll()
->add(GeneralUtility::makeInstance(DeletedRestriction::class));
$predicates = [
$queryBuilder->expr()->eq(
't3ver_move_id',
$queryBuilder->createNamedParameter((int)$lRow['uid'], \PDO::PARAM_INT)
),
$queryBuilder->expr()->eq(
'pid',
$queryBuilder->createNamedParameter((int)$row['_MOVE_PLH_pid'], \PDO::PARAM_INT)
),
$queryBuilder->expr()->eq(
't3ver_wsid',
$queryBuilder->createNamedParameter((int)$row['t3ver_wsid'], \PDO::PARAM_INT)
),
];
$tmpRow = $queryBuilder
->select(...$this->selFieldList)
->from($table)
->andWhere(...$predicates)
->execute()
->fetch();
$lRow = is_array($tmpRow) ? $tmpRow : $lRow;
}
// In offline workspace, look for alternative record:
BackendUtility::workspaceOL($table, $lRow, $this->getBackendUserAuthentication()->workspace, true);
if (is_array($lRow) && $this->getBackendUserAuthentication()->checkLanguageAccess($lRow[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) {
$this->currentIdList[] = $lRow['uid'];
if ($row['tx_gridelements_container']) {
$lRow['_CSSCLASS'] = 't3-gridelements-child' . $expanded;
}
$rowOutput .= $this->renderListRow($table, $lRow, $cc, $titleCol, $thumbsCol, 20, $level, $row['tx_gridelements_container'], $expanded);
}
}
}
}
if ($theData['_EXPANDABLE_'] && $level < 8 && ($row['l18n_parent'] == 0 || !$this->localizationView) && !empty($theData['_CHILDREN_'])) {
$expanded = $this->expandedGridelements[$row['uid']] && (($this->expandedGridelements[$row['tx_gridelements_container']] && $expanded) || $row['tx_gridelements_container'] === 0)? ' expanded' : '';
$previousGridColumn = '';
$originalMoveUp = $this->showMoveUp;
$originalMoveDown = $this->showMoveDown;
foreach ($theData['_CHILDREN_'] as $key => $child) {
if (isset($child['tx_gridelements_columns']) && ($child['tx_gridelements_columns'] !== $previousGridColumn)) {
$previousGridColumn = $child['tx_gridelements_columns'];
$this->currentTable['prev'][$child['uid']] = (int)$row['pid'];
} else {
if (isset($theData['_CHILDREN_'][$key - 2]) && $theData['_CHILDREN_'][$key - 2]['tx_gridelements_columns'] === $child['tx_gridelements_columns']) {
$this->currentTable['prev'][$child['uid']] = -(int)$theData['_CHILDREN_'][$key - 2]['uid'];
} else {
$this->currentTable['prev'][$child['uid']] = (int)$row['pid'];
}
}
if (isset($theData['_CHILDREN_'][$key + 1]) && $theData['_CHILDREN_'][$key + 1]['tx_gridelements_columns'] === $child['tx_gridelements_columns']) {
$this->currentTable['next'][$child['uid']] = -(int)$theData['_CHILDREN_'][$key + 1]['uid'];
}
}
$previousGridColumn = '';
foreach ($theData['_CHILDREN_'] as $key => $child) {
if (isset($child['tx_gridelements_columns']) && ($child['tx_gridelements_columns'] !== $previousGridColumn)) {
$previousGridColumn = $child['tx_gridelements_columns'];
$this->showMoveUp = false;
$rowOutput .= '<tr class="t3-gridelements-child' . $expanded . '" data-trigger-container="'
. ($this->localizationView && $row['l18n_parent'] ? $row['l18n_parent'] : $row['uid'])
. '" data-grid-container="' . $row['uid'] . '">
<td colspan="' . ($level + 2) . '"></td>
<td colspan="' . (count($this->fieldArray) - $level - 2 + $this->maxDepth) . '" style="padding:5px;">
<br />
<strong>' . $this->getLanguageService()->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:list.columnName')
. ' ' . (int)$child['tx_gridelements_columns'] . '</strong>
</td>
</tr>';
} else {
$this->showMoveUp = true;
}
$this->showMoveDown = !isset($child['tx_gridelements_columns']) || !isset($theData['_CHILDREN_'][$key + 1])
|| (int)$child['tx_gridelements_columns'] === (int)$theData['_CHILDREN_'][$key + 1]['tx_gridelements_columns'];
$this->currentIdList[] = $child['uid'];
if ($row['CType'] === 'gridelements_pi1') {
$this->currentContainerIdList[] = $row['uid'];
}
$child['_CSSCLASS'] = 't3-gridelements-child' . $expanded;
$rowOutput .= $this->renderListRow($table, $child, $cc, $titleCol, $thumbsCol, 0, $level + 1, $row['uid'], $expanded);
}
$this->showMoveUp = $originalMoveUp;
$this->showMoveDown = $originalMoveDown;
}
// Finally, return table row element:
return $rowOutput;
} | php | public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent = 0, $level = 0, $triggerContainer = 0, $expanded = '')
{
if (!is_array($row)) {
return '';
}
$rowOutput = '';
$id_orig = null;
// If in search mode, make sure the preview will show the correct page
if ((string)$this->searchString !== '') {
$id_orig = $this->id;
$this->id = $row['pid'];
}
$tagAttributes = [
'class' => ['t3js-entity'],
'data-table' => $table,
'title' => 'id=' . $row['uid'],
];
// Add active class to record of current link
if (
isset($this->currentLink['tableNames'])
&& (int)$this->currentLink['uid'] === (int)$row['uid']
&& GeneralUtility::inList($this->currentLink['tableNames'], $table)
) {
$tagAttributes['class'][] = 'active';
}
// Add special classes for first and last row
if ($cc == 1 && $indent == 0) {
$tagAttributes['class'][] = 'firstcol';
}
if ($cc == $this->totalRowCount || $cc == $this->iLimit) {
$tagAttributes['class'][] = 'lastcol';
}
// Overriding with versions background color if any:
if (!empty($row['_CSSCLASS'])) {
$tagAttributes['class'] = [$row['_CSSCLASS']];
}
// Incr. counter.
$this->counter++;
// The icon with link
$toolTip = BackendUtility::getRecordToolTip($row, $table);
$additionalStyle = $indent ? ' style="margin-left: ' . $indent . 'px;"' : '';
$iconImg = '<span ' . $toolTip . ' ' . $additionalStyle . '>'
. $this->iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render()
. '</span>';
$theIcon = $this->clickMenuEnabled ? BackendUtility::wrapClickMenuOnIcon(
$iconImg,
$table,
$row['uid']
) : $iconImg;
// Preparing and getting the data-array
$theData = [];
$localizationMarkerClass = '';
$lC2 = '';
foreach ($this->fieldArray as $fCol) {
if ($fCol == $titleCol) {
$recTitle = BackendUtility::getRecordTitle($table, $row, false, true);
$warning = '';
// If the record is edit-locked by another user, we will show a little warning sign:
$lockInfo = BackendUtility::isRecordLocked($table, $row['uid']);
if ($lockInfo) {
$warning = '<span data-toggle="tooltip" data-placement="right" data-title="' . htmlspecialchars($lockInfo['msg']) . '">'
. $this->iconFactory->getIcon('warning-in-use', Icon::SIZE_SMALL)->render() . '</span>';
}
$theData[$fCol] = $theData['__label'] = $warning . $this->linkWrapItems(
$table,
$row['uid'],
$recTitle,
$row
);
// Render thumbnails, if:
// - a thumbnail column exists
// - there is content in it
// - the thumbnail column is visible for the current type
$type = 0;
if (isset($GLOBALS['TCA'][$table]['ctrl']['type'])) {
$typeColumn = $GLOBALS['TCA'][$table]['ctrl']['type'];
$type = $row[$typeColumn];
}
// If current type doesn't exist, set it to 0 (or to 1 for historical reasons,
// if 0 doesn't exist)
if (!isset($GLOBALS['TCA'][$table]['types'][$type])) {
$type = isset($GLOBALS['TCA'][$table]['types'][0]) ? 0 : 1;
}
$visibleColumns = $this->getVisibleColumns($GLOBALS['TCA'][$table], $type);
if ($this->thumbs &&
trim($row[$thumbsCol]) &&
preg_match('/(^|(.*(;|,)?))' . $thumbsCol . '(((;|,).*)|$)/', $visibleColumns) === 1
) {
$thumbCode = '<br />' . $this->thumbCode($row, $table, $thumbsCol);
$theData[$fCol] .= $thumbCode;
$theData['__label'] .= $thumbCode;
}
if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
&& $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0
&& $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0
) {
// It's a translated record with a language parent
$localizationMarkerClass = ' localization';
}
} elseif ($fCol === 'pid') {
$theData[$fCol] = $row[$fCol];
} elseif ($fCol === '_PATH_') {
$theData[$fCol] = $this->recPath($row['pid']);
} elseif ($fCol === '_REF_') {
$theData[$fCol] = $this->createReferenceHtml($table, $row['uid']);
} elseif ($fCol === '_CONTROL_') {
$theData[$fCol] = $this->makeControl($table, $row);
} elseif ($fCol === '_CLIPBOARD_') {
$theData[$fCol] = $this->makeClip($table, $row);
} elseif ($fCol === '_LOCALIZATION_') {
list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row);
$theData[$fCol] = $lC1;
} elseif ($fCol !== '_LOCALIZATION_b') {
$tmpProc = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid']);
$theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
if ($this->csvOutput) {
$row[$fCol] = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
}
} elseif ($fCol === '_LOCALIZATION_b') {
$theData[$fCol] = $lC2;
} else {
$theData[$fCol] = htmlspecialchars(BackendUtility::getProcessedValueExtra(
$table,
$fCol,
$row[$fCol],
0,
$row['uid']
));
}
}
// Reset the ID if it was overwritten
if ((string)$this->searchString !== '') {
$this->id = $id_orig;
}
// Add row to CSV list:
if ($this->csvOutput) {
$hooks = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][__CLASS__]['customizeCsvRow'] ?? [];
if (!empty($hooks)) {
$hookParameters = [
'databaseRow' => &$row,
'tableName' => $table,
'pageId' => $this->id,
];
foreach ($hooks as $hookFunction) {
GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
}
}
$this->addToCSV($row);
}
// Add classes to table cells
$this->addElement_tdCssClass[$titleCol] = 'col-title col-responsive' . $localizationMarkerClass;
$this->addElement_tdCssClass['__label'] = $this->addElement_tdCssClass[$titleCol];
$this->addElement_tdCssClass['_CONTROL_'] = 'col-control';
if ($this->getModule()->MOD_SETTINGS['clipBoard']) {
$this->addElement_tdCssClass['_CLIPBOARD_'] = 'col-clipboard';
}
$this->addElement_tdCssClass['_PATH_'] = 'col-path';
$this->addElement_tdCssClass['_LOCALIZATION_'] = 'col-localizationa';
$this->addElement_tdCssClass['_LOCALIZATION_b'] = 'col-localizationb';
/**
* @hook checkChildren
* @date 2014-02-11
* @request Alexander Grein <alexander.grein@in2code.de>
*/
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ?? [] as $className) {
$hookObject = GeneralUtility::makeInstance($className);
if (is_object($hookObject) && method_exists($hookObject, 'checkChildren')) {
$hookObject->checkChildren($table, $row, $level, $theData, $this);
}
}
// Create element in table cells:
$theData['uid'] = $row['uid'];
if ($table === 'tt_content') {
$theData['tx_gridelements_container'] = (int)$row['tx_gridelements_container'];
}
if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
&& isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'])
) {
$theData['parent'] = $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']];
}
$tagAttributes = array_map(
function ($attributeValue) {
if (is_array($attributeValue)) {
return implode(' ', $attributeValue);
}
return $attributeValue;
},
$tagAttributes
);
if ($triggerContainer) {
$theData['_triggerContainer'] = $triggerContainer;
}
$rowOutput .= $this->addElement(1, $theIcon, $theData, GeneralUtility::implodeAttributes($tagAttributes, true));
if ($this->l10nEnabled) {
// For each available translation, render the record:
if (is_array($this->translations)) {
foreach ($this->translations as $lRow) {
// $lRow isn't always what we want - if record was moved we've to work with the
// placeholder records otherwise the list is messed up a bit
if ($row['_MOVE_PLH_uid'] && $row['_MOVE_PLH_pid']) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable($table);
$queryBuilder->getRestrictions()
->removeAll()
->add(GeneralUtility::makeInstance(DeletedRestriction::class));
$predicates = [
$queryBuilder->expr()->eq(
't3ver_move_id',
$queryBuilder->createNamedParameter((int)$lRow['uid'], \PDO::PARAM_INT)
),
$queryBuilder->expr()->eq(
'pid',
$queryBuilder->createNamedParameter((int)$row['_MOVE_PLH_pid'], \PDO::PARAM_INT)
),
$queryBuilder->expr()->eq(
't3ver_wsid',
$queryBuilder->createNamedParameter((int)$row['t3ver_wsid'], \PDO::PARAM_INT)
),
];
$tmpRow = $queryBuilder
->select(...$this->selFieldList)
->from($table)
->andWhere(...$predicates)
->execute()
->fetch();
$lRow = is_array($tmpRow) ? $tmpRow : $lRow;
}
// In offline workspace, look for alternative record:
BackendUtility::workspaceOL($table, $lRow, $this->getBackendUserAuthentication()->workspace, true);
if (is_array($lRow) && $this->getBackendUserAuthentication()->checkLanguageAccess($lRow[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) {
$this->currentIdList[] = $lRow['uid'];
if ($row['tx_gridelements_container']) {
$lRow['_CSSCLASS'] = 't3-gridelements-child' . $expanded;
}
$rowOutput .= $this->renderListRow($table, $lRow, $cc, $titleCol, $thumbsCol, 20, $level, $row['tx_gridelements_container'], $expanded);
}
}
}
}
if ($theData['_EXPANDABLE_'] && $level < 8 && ($row['l18n_parent'] == 0 || !$this->localizationView) && !empty($theData['_CHILDREN_'])) {
$expanded = $this->expandedGridelements[$row['uid']] && (($this->expandedGridelements[$row['tx_gridelements_container']] && $expanded) || $row['tx_gridelements_container'] === 0)? ' expanded' : '';
$previousGridColumn = '';
$originalMoveUp = $this->showMoveUp;
$originalMoveDown = $this->showMoveDown;
foreach ($theData['_CHILDREN_'] as $key => $child) {
if (isset($child['tx_gridelements_columns']) && ($child['tx_gridelements_columns'] !== $previousGridColumn)) {
$previousGridColumn = $child['tx_gridelements_columns'];
$this->currentTable['prev'][$child['uid']] = (int)$row['pid'];
} else {
if (isset($theData['_CHILDREN_'][$key - 2]) && $theData['_CHILDREN_'][$key - 2]['tx_gridelements_columns'] === $child['tx_gridelements_columns']) {
$this->currentTable['prev'][$child['uid']] = -(int)$theData['_CHILDREN_'][$key - 2]['uid'];
} else {
$this->currentTable['prev'][$child['uid']] = (int)$row['pid'];
}
}
if (isset($theData['_CHILDREN_'][$key + 1]) && $theData['_CHILDREN_'][$key + 1]['tx_gridelements_columns'] === $child['tx_gridelements_columns']) {
$this->currentTable['next'][$child['uid']] = -(int)$theData['_CHILDREN_'][$key + 1]['uid'];
}
}
$previousGridColumn = '';
foreach ($theData['_CHILDREN_'] as $key => $child) {
if (isset($child['tx_gridelements_columns']) && ($child['tx_gridelements_columns'] !== $previousGridColumn)) {
$previousGridColumn = $child['tx_gridelements_columns'];
$this->showMoveUp = false;
$rowOutput .= '<tr class="t3-gridelements-child' . $expanded . '" data-trigger-container="'
. ($this->localizationView && $row['l18n_parent'] ? $row['l18n_parent'] : $row['uid'])
. '" data-grid-container="' . $row['uid'] . '">
<td colspan="' . ($level + 2) . '"></td>
<td colspan="' . (count($this->fieldArray) - $level - 2 + $this->maxDepth) . '" style="padding:5px;">
<br />
<strong>' . $this->getLanguageService()->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:list.columnName')
. ' ' . (int)$child['tx_gridelements_columns'] . '</strong>
</td>
</tr>';
} else {
$this->showMoveUp = true;
}
$this->showMoveDown = !isset($child['tx_gridelements_columns']) || !isset($theData['_CHILDREN_'][$key + 1])
|| (int)$child['tx_gridelements_columns'] === (int)$theData['_CHILDREN_'][$key + 1]['tx_gridelements_columns'];
$this->currentIdList[] = $child['uid'];
if ($row['CType'] === 'gridelements_pi1') {
$this->currentContainerIdList[] = $row['uid'];
}
$child['_CSSCLASS'] = 't3-gridelements-child' . $expanded;
$rowOutput .= $this->renderListRow($table, $child, $cc, $titleCol, $thumbsCol, 0, $level + 1, $row['uid'], $expanded);
}
$this->showMoveUp = $originalMoveUp;
$this->showMoveDown = $originalMoveDown;
}
// Finally, return table row element:
return $rowOutput;
} | [
"public",
"function",
"renderListRow",
"(",
"$",
"table",
",",
"$",
"row",
",",
"$",
"cc",
",",
"$",
"titleCol",
",",
"$",
"thumbsCol",
",",
"$",
"indent",
"=",
"0",
",",
"$",
"level",
"=",
"0",
",",
"$",
"triggerContainer",
"=",
"0",
",",
"$",
"expanded",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"row",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"rowOutput",
"=",
"''",
";",
"$",
"id_orig",
"=",
"null",
";",
"// If in search mode, make sure the preview will show the correct page",
"if",
"(",
"(",
"string",
")",
"$",
"this",
"->",
"searchString",
"!==",
"''",
")",
"{",
"$",
"id_orig",
"=",
"$",
"this",
"->",
"id",
";",
"$",
"this",
"->",
"id",
"=",
"$",
"row",
"[",
"'pid'",
"]",
";",
"}",
"$",
"tagAttributes",
"=",
"[",
"'class'",
"=>",
"[",
"'t3js-entity'",
"]",
",",
"'data-table'",
"=>",
"$",
"table",
",",
"'title'",
"=>",
"'id='",
".",
"$",
"row",
"[",
"'uid'",
"]",
",",
"]",
";",
"// Add active class to record of current link",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"currentLink",
"[",
"'tableNames'",
"]",
")",
"&&",
"(",
"int",
")",
"$",
"this",
"->",
"currentLink",
"[",
"'uid'",
"]",
"===",
"(",
"int",
")",
"$",
"row",
"[",
"'uid'",
"]",
"&&",
"GeneralUtility",
"::",
"inList",
"(",
"$",
"this",
"->",
"currentLink",
"[",
"'tableNames'",
"]",
",",
"$",
"table",
")",
")",
"{",
"$",
"tagAttributes",
"[",
"'class'",
"]",
"[",
"]",
"=",
"'active'",
";",
"}",
"// Add special classes for first and last row",
"if",
"(",
"$",
"cc",
"==",
"1",
"&&",
"$",
"indent",
"==",
"0",
")",
"{",
"$",
"tagAttributes",
"[",
"'class'",
"]",
"[",
"]",
"=",
"'firstcol'",
";",
"}",
"if",
"(",
"$",
"cc",
"==",
"$",
"this",
"->",
"totalRowCount",
"||",
"$",
"cc",
"==",
"$",
"this",
"->",
"iLimit",
")",
"{",
"$",
"tagAttributes",
"[",
"'class'",
"]",
"[",
"]",
"=",
"'lastcol'",
";",
"}",
"// Overriding with versions background color if any:",
"if",
"(",
"!",
"empty",
"(",
"$",
"row",
"[",
"'_CSSCLASS'",
"]",
")",
")",
"{",
"$",
"tagAttributes",
"[",
"'class'",
"]",
"=",
"[",
"$",
"row",
"[",
"'_CSSCLASS'",
"]",
"]",
";",
"}",
"// Incr. counter.",
"$",
"this",
"->",
"counter",
"++",
";",
"// The icon with link",
"$",
"toolTip",
"=",
"BackendUtility",
"::",
"getRecordToolTip",
"(",
"$",
"row",
",",
"$",
"table",
")",
";",
"$",
"additionalStyle",
"=",
"$",
"indent",
"?",
"' style=\"margin-left: '",
".",
"$",
"indent",
".",
"'px;\"'",
":",
"''",
";",
"$",
"iconImg",
"=",
"'<span '",
".",
"$",
"toolTip",
".",
"' '",
".",
"$",
"additionalStyle",
".",
"'>'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIconForRecord",
"(",
"$",
"table",
",",
"$",
"row",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</span>'",
";",
"$",
"theIcon",
"=",
"$",
"this",
"->",
"clickMenuEnabled",
"?",
"BackendUtility",
"::",
"wrapClickMenuOnIcon",
"(",
"$",
"iconImg",
",",
"$",
"table",
",",
"$",
"row",
"[",
"'uid'",
"]",
")",
":",
"$",
"iconImg",
";",
"// Preparing and getting the data-array",
"$",
"theData",
"=",
"[",
"]",
";",
"$",
"localizationMarkerClass",
"=",
"''",
";",
"$",
"lC2",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"fieldArray",
"as",
"$",
"fCol",
")",
"{",
"if",
"(",
"$",
"fCol",
"==",
"$",
"titleCol",
")",
"{",
"$",
"recTitle",
"=",
"BackendUtility",
"::",
"getRecordTitle",
"(",
"$",
"table",
",",
"$",
"row",
",",
"false",
",",
"true",
")",
";",
"$",
"warning",
"=",
"''",
";",
"// If the record is edit-locked\tby another user, we will show a little warning sign:",
"$",
"lockInfo",
"=",
"BackendUtility",
"::",
"isRecordLocked",
"(",
"$",
"table",
",",
"$",
"row",
"[",
"'uid'",
"]",
")",
";",
"if",
"(",
"$",
"lockInfo",
")",
"{",
"$",
"warning",
"=",
"'<span data-toggle=\"tooltip\" data-placement=\"right\" data-title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"lockInfo",
"[",
"'msg'",
"]",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'warning-in-use'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</span>'",
";",
"}",
"$",
"theData",
"[",
"$",
"fCol",
"]",
"=",
"$",
"theData",
"[",
"'__label'",
"]",
"=",
"$",
"warning",
".",
"$",
"this",
"->",
"linkWrapItems",
"(",
"$",
"table",
",",
"$",
"row",
"[",
"'uid'",
"]",
",",
"$",
"recTitle",
",",
"$",
"row",
")",
";",
"// Render thumbnails, if:",
"// - a thumbnail column exists",
"// - there is content in it",
"// - the thumbnail column is visible for the current type",
"$",
"type",
"=",
"0",
";",
"if",
"(",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'type'",
"]",
")",
")",
"{",
"$",
"typeColumn",
"=",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'type'",
"]",
";",
"$",
"type",
"=",
"$",
"row",
"[",
"$",
"typeColumn",
"]",
";",
"}",
"// If current type doesn't exist, set it to 0 (or to 1 for historical reasons,",
"// if 0 doesn't exist)",
"if",
"(",
"!",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'types'",
"]",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"type",
"=",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'types'",
"]",
"[",
"0",
"]",
")",
"?",
"0",
":",
"1",
";",
"}",
"$",
"visibleColumns",
"=",
"$",
"this",
"->",
"getVisibleColumns",
"(",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
",",
"$",
"type",
")",
";",
"if",
"(",
"$",
"this",
"->",
"thumbs",
"&&",
"trim",
"(",
"$",
"row",
"[",
"$",
"thumbsCol",
"]",
")",
"&&",
"preg_match",
"(",
"'/(^|(.*(;|,)?))'",
".",
"$",
"thumbsCol",
".",
"'(((;|,).*)|$)/'",
",",
"$",
"visibleColumns",
")",
"===",
"1",
")",
"{",
"$",
"thumbCode",
"=",
"'<br />'",
".",
"$",
"this",
"->",
"thumbCode",
"(",
"$",
"row",
",",
"$",
"table",
",",
"$",
"thumbsCol",
")",
";",
"$",
"theData",
"[",
"$",
"fCol",
"]",
".=",
"$",
"thumbCode",
";",
"$",
"theData",
"[",
"'__label'",
"]",
".=",
"$",
"thumbCode",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'languageField'",
"]",
")",
"&&",
"$",
"row",
"[",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'languageField'",
"]",
"]",
"!=",
"0",
"&&",
"$",
"row",
"[",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'transOrigPointerField'",
"]",
"]",
"!=",
"0",
")",
"{",
"// It's a translated record with a language parent",
"$",
"localizationMarkerClass",
"=",
"' localization'",
";",
"}",
"}",
"elseif",
"(",
"$",
"fCol",
"===",
"'pid'",
")",
"{",
"$",
"theData",
"[",
"$",
"fCol",
"]",
"=",
"$",
"row",
"[",
"$",
"fCol",
"]",
";",
"}",
"elseif",
"(",
"$",
"fCol",
"===",
"'_PATH_'",
")",
"{",
"$",
"theData",
"[",
"$",
"fCol",
"]",
"=",
"$",
"this",
"->",
"recPath",
"(",
"$",
"row",
"[",
"'pid'",
"]",
")",
";",
"}",
"elseif",
"(",
"$",
"fCol",
"===",
"'_REF_'",
")",
"{",
"$",
"theData",
"[",
"$",
"fCol",
"]",
"=",
"$",
"this",
"->",
"createReferenceHtml",
"(",
"$",
"table",
",",
"$",
"row",
"[",
"'uid'",
"]",
")",
";",
"}",
"elseif",
"(",
"$",
"fCol",
"===",
"'_CONTROL_'",
")",
"{",
"$",
"theData",
"[",
"$",
"fCol",
"]",
"=",
"$",
"this",
"->",
"makeControl",
"(",
"$",
"table",
",",
"$",
"row",
")",
";",
"}",
"elseif",
"(",
"$",
"fCol",
"===",
"'_CLIPBOARD_'",
")",
"{",
"$",
"theData",
"[",
"$",
"fCol",
"]",
"=",
"$",
"this",
"->",
"makeClip",
"(",
"$",
"table",
",",
"$",
"row",
")",
";",
"}",
"elseif",
"(",
"$",
"fCol",
"===",
"'_LOCALIZATION_'",
")",
"{",
"list",
"(",
"$",
"lC1",
",",
"$",
"lC2",
")",
"=",
"$",
"this",
"->",
"makeLocalizationPanel",
"(",
"$",
"table",
",",
"$",
"row",
")",
";",
"$",
"theData",
"[",
"$",
"fCol",
"]",
"=",
"$",
"lC1",
";",
"}",
"elseif",
"(",
"$",
"fCol",
"!==",
"'_LOCALIZATION_b'",
")",
"{",
"$",
"tmpProc",
"=",
"BackendUtility",
"::",
"getProcessedValueExtra",
"(",
"$",
"table",
",",
"$",
"fCol",
",",
"$",
"row",
"[",
"$",
"fCol",
"]",
",",
"100",
",",
"$",
"row",
"[",
"'uid'",
"]",
")",
";",
"$",
"theData",
"[",
"$",
"fCol",
"]",
"=",
"$",
"this",
"->",
"linkUrlMail",
"(",
"htmlspecialchars",
"(",
"$",
"tmpProc",
")",
",",
"$",
"row",
"[",
"$",
"fCol",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"csvOutput",
")",
"{",
"$",
"row",
"[",
"$",
"fCol",
"]",
"=",
"BackendUtility",
"::",
"getProcessedValueExtra",
"(",
"$",
"table",
",",
"$",
"fCol",
",",
"$",
"row",
"[",
"$",
"fCol",
"]",
",",
"0",
",",
"$",
"row",
"[",
"'uid'",
"]",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"fCol",
"===",
"'_LOCALIZATION_b'",
")",
"{",
"$",
"theData",
"[",
"$",
"fCol",
"]",
"=",
"$",
"lC2",
";",
"}",
"else",
"{",
"$",
"theData",
"[",
"$",
"fCol",
"]",
"=",
"htmlspecialchars",
"(",
"BackendUtility",
"::",
"getProcessedValueExtra",
"(",
"$",
"table",
",",
"$",
"fCol",
",",
"$",
"row",
"[",
"$",
"fCol",
"]",
",",
"0",
",",
"$",
"row",
"[",
"'uid'",
"]",
")",
")",
";",
"}",
"}",
"// Reset the ID if it was overwritten",
"if",
"(",
"(",
"string",
")",
"$",
"this",
"->",
"searchString",
"!==",
"''",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"$",
"id_orig",
";",
"}",
"// Add row to CSV list:",
"if",
"(",
"$",
"this",
"->",
"csvOutput",
")",
"{",
"$",
"hooks",
"=",
"$",
"GLOBALS",
"[",
"'TYPO3_CONF_VARS'",
"]",
"[",
"'SC_OPTIONS'",
"]",
"[",
"__CLASS__",
"]",
"[",
"'customizeCsvRow'",
"]",
"??",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"hooks",
")",
")",
"{",
"$",
"hookParameters",
"=",
"[",
"'databaseRow'",
"=>",
"&",
"$",
"row",
",",
"'tableName'",
"=>",
"$",
"table",
",",
"'pageId'",
"=>",
"$",
"this",
"->",
"id",
",",
"]",
";",
"foreach",
"(",
"$",
"hooks",
"as",
"$",
"hookFunction",
")",
"{",
"GeneralUtility",
"::",
"callUserFunction",
"(",
"$",
"hookFunction",
",",
"$",
"hookParameters",
",",
"$",
"this",
")",
";",
"}",
"}",
"$",
"this",
"->",
"addToCSV",
"(",
"$",
"row",
")",
";",
"}",
"// Add classes to table cells",
"$",
"this",
"->",
"addElement_tdCssClass",
"[",
"$",
"titleCol",
"]",
"=",
"'col-title col-responsive'",
".",
"$",
"localizationMarkerClass",
";",
"$",
"this",
"->",
"addElement_tdCssClass",
"[",
"'__label'",
"]",
"=",
"$",
"this",
"->",
"addElement_tdCssClass",
"[",
"$",
"titleCol",
"]",
";",
"$",
"this",
"->",
"addElement_tdCssClass",
"[",
"'_CONTROL_'",
"]",
"=",
"'col-control'",
";",
"if",
"(",
"$",
"this",
"->",
"getModule",
"(",
")",
"->",
"MOD_SETTINGS",
"[",
"'clipBoard'",
"]",
")",
"{",
"$",
"this",
"->",
"addElement_tdCssClass",
"[",
"'_CLIPBOARD_'",
"]",
"=",
"'col-clipboard'",
";",
"}",
"$",
"this",
"->",
"addElement_tdCssClass",
"[",
"'_PATH_'",
"]",
"=",
"'col-path'",
";",
"$",
"this",
"->",
"addElement_tdCssClass",
"[",
"'_LOCALIZATION_'",
"]",
"=",
"'col-localizationa'",
";",
"$",
"this",
"->",
"addElement_tdCssClass",
"[",
"'_LOCALIZATION_b'",
"]",
"=",
"'col-localizationb'",
";",
"/**\n * @hook checkChildren\n * @date 2014-02-11\n * @request Alexander Grein <alexander.grein@in2code.de>\n */",
"foreach",
"(",
"$",
"GLOBALS",
"[",
"'TYPO3_CONF_VARS'",
"]",
"[",
"'SC_OPTIONS'",
"]",
"[",
"'typo3/class.db_list_extra.inc'",
"]",
"[",
"'actions'",
"]",
"??",
"[",
"]",
"as",
"$",
"className",
")",
"{",
"$",
"hookObject",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"$",
"className",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"hookObject",
")",
"&&",
"method_exists",
"(",
"$",
"hookObject",
",",
"'checkChildren'",
")",
")",
"{",
"$",
"hookObject",
"->",
"checkChildren",
"(",
"$",
"table",
",",
"$",
"row",
",",
"$",
"level",
",",
"$",
"theData",
",",
"$",
"this",
")",
";",
"}",
"}",
"// Create element in table cells:",
"$",
"theData",
"[",
"'uid'",
"]",
"=",
"$",
"row",
"[",
"'uid'",
"]",
";",
"if",
"(",
"$",
"table",
"===",
"'tt_content'",
")",
"{",
"$",
"theData",
"[",
"'tx_gridelements_container'",
"]",
"=",
"(",
"int",
")",
"$",
"row",
"[",
"'tx_gridelements_container'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'languageField'",
"]",
")",
"&&",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'transOrigPointerField'",
"]",
")",
")",
"{",
"$",
"theData",
"[",
"'parent'",
"]",
"=",
"$",
"row",
"[",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'transOrigPointerField'",
"]",
"]",
";",
"}",
"$",
"tagAttributes",
"=",
"array_map",
"(",
"function",
"(",
"$",
"attributeValue",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"attributeValue",
")",
")",
"{",
"return",
"implode",
"(",
"' '",
",",
"$",
"attributeValue",
")",
";",
"}",
"return",
"$",
"attributeValue",
";",
"}",
",",
"$",
"tagAttributes",
")",
";",
"if",
"(",
"$",
"triggerContainer",
")",
"{",
"$",
"theData",
"[",
"'_triggerContainer'",
"]",
"=",
"$",
"triggerContainer",
";",
"}",
"$",
"rowOutput",
".=",
"$",
"this",
"->",
"addElement",
"(",
"1",
",",
"$",
"theIcon",
",",
"$",
"theData",
",",
"GeneralUtility",
"::",
"implodeAttributes",
"(",
"$",
"tagAttributes",
",",
"true",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"l10nEnabled",
")",
"{",
"// For each available translation, render the record:",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"translations",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"translations",
"as",
"$",
"lRow",
")",
"{",
"// $lRow isn't always what we want - if record was moved we've to work with the",
"// placeholder records otherwise the list is messed up a bit",
"if",
"(",
"$",
"row",
"[",
"'_MOVE_PLH_uid'",
"]",
"&&",
"$",
"row",
"[",
"'_MOVE_PLH_pid'",
"]",
")",
"{",
"$",
"queryBuilder",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"ConnectionPool",
"::",
"class",
")",
"->",
"getQueryBuilderForTable",
"(",
"$",
"table",
")",
";",
"$",
"queryBuilder",
"->",
"getRestrictions",
"(",
")",
"->",
"removeAll",
"(",
")",
"->",
"add",
"(",
"GeneralUtility",
"::",
"makeInstance",
"(",
"DeletedRestriction",
"::",
"class",
")",
")",
";",
"$",
"predicates",
"=",
"[",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'t3ver_move_id'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"(",
"int",
")",
"$",
"lRow",
"[",
"'uid'",
"]",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
")",
",",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'pid'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"(",
"int",
")",
"$",
"row",
"[",
"'_MOVE_PLH_pid'",
"]",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
")",
",",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'t3ver_wsid'",
",",
"$",
"queryBuilder",
"->",
"createNamedParameter",
"(",
"(",
"int",
")",
"$",
"row",
"[",
"'t3ver_wsid'",
"]",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
")",
",",
"]",
";",
"$",
"tmpRow",
"=",
"$",
"queryBuilder",
"->",
"select",
"(",
"...",
"$",
"this",
"->",
"selFieldList",
")",
"->",
"from",
"(",
"$",
"table",
")",
"->",
"andWhere",
"(",
"...",
"$",
"predicates",
")",
"->",
"execute",
"(",
")",
"->",
"fetch",
"(",
")",
";",
"$",
"lRow",
"=",
"is_array",
"(",
"$",
"tmpRow",
")",
"?",
"$",
"tmpRow",
":",
"$",
"lRow",
";",
"}",
"// In offline workspace, look for alternative record:",
"BackendUtility",
"::",
"workspaceOL",
"(",
"$",
"table",
",",
"$",
"lRow",
",",
"$",
"this",
"->",
"getBackendUserAuthentication",
"(",
")",
"->",
"workspace",
",",
"true",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"lRow",
")",
"&&",
"$",
"this",
"->",
"getBackendUserAuthentication",
"(",
")",
"->",
"checkLanguageAccess",
"(",
"$",
"lRow",
"[",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'languageField'",
"]",
"]",
")",
")",
"{",
"$",
"this",
"->",
"currentIdList",
"[",
"]",
"=",
"$",
"lRow",
"[",
"'uid'",
"]",
";",
"if",
"(",
"$",
"row",
"[",
"'tx_gridelements_container'",
"]",
")",
"{",
"$",
"lRow",
"[",
"'_CSSCLASS'",
"]",
"=",
"'t3-gridelements-child'",
".",
"$",
"expanded",
";",
"}",
"$",
"rowOutput",
".=",
"$",
"this",
"->",
"renderListRow",
"(",
"$",
"table",
",",
"$",
"lRow",
",",
"$",
"cc",
",",
"$",
"titleCol",
",",
"$",
"thumbsCol",
",",
"20",
",",
"$",
"level",
",",
"$",
"row",
"[",
"'tx_gridelements_container'",
"]",
",",
"$",
"expanded",
")",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"$",
"theData",
"[",
"'_EXPANDABLE_'",
"]",
"&&",
"$",
"level",
"<",
"8",
"&&",
"(",
"$",
"row",
"[",
"'l18n_parent'",
"]",
"==",
"0",
"||",
"!",
"$",
"this",
"->",
"localizationView",
")",
"&&",
"!",
"empty",
"(",
"$",
"theData",
"[",
"'_CHILDREN_'",
"]",
")",
")",
"{",
"$",
"expanded",
"=",
"$",
"this",
"->",
"expandedGridelements",
"[",
"$",
"row",
"[",
"'uid'",
"]",
"]",
"&&",
"(",
"(",
"$",
"this",
"->",
"expandedGridelements",
"[",
"$",
"row",
"[",
"'tx_gridelements_container'",
"]",
"]",
"&&",
"$",
"expanded",
")",
"||",
"$",
"row",
"[",
"'tx_gridelements_container'",
"]",
"===",
"0",
")",
"?",
"' expanded'",
":",
"''",
";",
"$",
"previousGridColumn",
"=",
"''",
";",
"$",
"originalMoveUp",
"=",
"$",
"this",
"->",
"showMoveUp",
";",
"$",
"originalMoveDown",
"=",
"$",
"this",
"->",
"showMoveDown",
";",
"foreach",
"(",
"$",
"theData",
"[",
"'_CHILDREN_'",
"]",
"as",
"$",
"key",
"=>",
"$",
"child",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"child",
"[",
"'tx_gridelements_columns'",
"]",
")",
"&&",
"(",
"$",
"child",
"[",
"'tx_gridelements_columns'",
"]",
"!==",
"$",
"previousGridColumn",
")",
")",
"{",
"$",
"previousGridColumn",
"=",
"$",
"child",
"[",
"'tx_gridelements_columns'",
"]",
";",
"$",
"this",
"->",
"currentTable",
"[",
"'prev'",
"]",
"[",
"$",
"child",
"[",
"'uid'",
"]",
"]",
"=",
"(",
"int",
")",
"$",
"row",
"[",
"'pid'",
"]",
";",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"theData",
"[",
"'_CHILDREN_'",
"]",
"[",
"$",
"key",
"-",
"2",
"]",
")",
"&&",
"$",
"theData",
"[",
"'_CHILDREN_'",
"]",
"[",
"$",
"key",
"-",
"2",
"]",
"[",
"'tx_gridelements_columns'",
"]",
"===",
"$",
"child",
"[",
"'tx_gridelements_columns'",
"]",
")",
"{",
"$",
"this",
"->",
"currentTable",
"[",
"'prev'",
"]",
"[",
"$",
"child",
"[",
"'uid'",
"]",
"]",
"=",
"-",
"(",
"int",
")",
"$",
"theData",
"[",
"'_CHILDREN_'",
"]",
"[",
"$",
"key",
"-",
"2",
"]",
"[",
"'uid'",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"currentTable",
"[",
"'prev'",
"]",
"[",
"$",
"child",
"[",
"'uid'",
"]",
"]",
"=",
"(",
"int",
")",
"$",
"row",
"[",
"'pid'",
"]",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"theData",
"[",
"'_CHILDREN_'",
"]",
"[",
"$",
"key",
"+",
"1",
"]",
")",
"&&",
"$",
"theData",
"[",
"'_CHILDREN_'",
"]",
"[",
"$",
"key",
"+",
"1",
"]",
"[",
"'tx_gridelements_columns'",
"]",
"===",
"$",
"child",
"[",
"'tx_gridelements_columns'",
"]",
")",
"{",
"$",
"this",
"->",
"currentTable",
"[",
"'next'",
"]",
"[",
"$",
"child",
"[",
"'uid'",
"]",
"]",
"=",
"-",
"(",
"int",
")",
"$",
"theData",
"[",
"'_CHILDREN_'",
"]",
"[",
"$",
"key",
"+",
"1",
"]",
"[",
"'uid'",
"]",
";",
"}",
"}",
"$",
"previousGridColumn",
"=",
"''",
";",
"foreach",
"(",
"$",
"theData",
"[",
"'_CHILDREN_'",
"]",
"as",
"$",
"key",
"=>",
"$",
"child",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"child",
"[",
"'tx_gridelements_columns'",
"]",
")",
"&&",
"(",
"$",
"child",
"[",
"'tx_gridelements_columns'",
"]",
"!==",
"$",
"previousGridColumn",
")",
")",
"{",
"$",
"previousGridColumn",
"=",
"$",
"child",
"[",
"'tx_gridelements_columns'",
"]",
";",
"$",
"this",
"->",
"showMoveUp",
"=",
"false",
";",
"$",
"rowOutput",
".=",
"'<tr class=\"t3-gridelements-child'",
".",
"$",
"expanded",
".",
"'\" data-trigger-container=\"'",
".",
"(",
"$",
"this",
"->",
"localizationView",
"&&",
"$",
"row",
"[",
"'l18n_parent'",
"]",
"?",
"$",
"row",
"[",
"'l18n_parent'",
"]",
":",
"$",
"row",
"[",
"'uid'",
"]",
")",
".",
"'\" data-grid-container=\"'",
".",
"$",
"row",
"[",
"'uid'",
"]",
".",
"'\">\n <td colspan=\"'",
".",
"(",
"$",
"level",
"+",
"2",
")",
".",
"'\"></td>\n <td colspan=\"'",
".",
"(",
"count",
"(",
"$",
"this",
"->",
"fieldArray",
")",
"-",
"$",
"level",
"-",
"2",
"+",
"$",
"this",
"->",
"maxDepth",
")",
".",
"'\" style=\"padding:5px;\">\n <br />\n <strong>'",
".",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"sL",
"(",
"'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:list.columnName'",
")",
".",
"' '",
".",
"(",
"int",
")",
"$",
"child",
"[",
"'tx_gridelements_columns'",
"]",
".",
"'</strong>\n </td>\n </tr>'",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"showMoveUp",
"=",
"true",
";",
"}",
"$",
"this",
"->",
"showMoveDown",
"=",
"!",
"isset",
"(",
"$",
"child",
"[",
"'tx_gridelements_columns'",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"theData",
"[",
"'_CHILDREN_'",
"]",
"[",
"$",
"key",
"+",
"1",
"]",
")",
"||",
"(",
"int",
")",
"$",
"child",
"[",
"'tx_gridelements_columns'",
"]",
"===",
"(",
"int",
")",
"$",
"theData",
"[",
"'_CHILDREN_'",
"]",
"[",
"$",
"key",
"+",
"1",
"]",
"[",
"'tx_gridelements_columns'",
"]",
";",
"$",
"this",
"->",
"currentIdList",
"[",
"]",
"=",
"$",
"child",
"[",
"'uid'",
"]",
";",
"if",
"(",
"$",
"row",
"[",
"'CType'",
"]",
"===",
"'gridelements_pi1'",
")",
"{",
"$",
"this",
"->",
"currentContainerIdList",
"[",
"]",
"=",
"$",
"row",
"[",
"'uid'",
"]",
";",
"}",
"$",
"child",
"[",
"'_CSSCLASS'",
"]",
"=",
"'t3-gridelements-child'",
".",
"$",
"expanded",
";",
"$",
"rowOutput",
".=",
"$",
"this",
"->",
"renderListRow",
"(",
"$",
"table",
",",
"$",
"child",
",",
"$",
"cc",
",",
"$",
"titleCol",
",",
"$",
"thumbsCol",
",",
"0",
",",
"$",
"level",
"+",
"1",
",",
"$",
"row",
"[",
"'uid'",
"]",
",",
"$",
"expanded",
")",
";",
"}",
"$",
"this",
"->",
"showMoveUp",
"=",
"$",
"originalMoveUp",
";",
"$",
"this",
"->",
"showMoveDown",
"=",
"$",
"originalMoveDown",
";",
"}",
"// Finally, return table row element:",
"return",
"$",
"rowOutput",
";",
"}"
] | Rendering a single row for the list
@param string $table Table name
@param mixed[] $row Current record
@param int $cc Counter, counting for each time an element is rendered (used for alternating colors)
@param string $titleCol Table field (column) where header value is found
@param string $thumbsCol Table field (column) where (possible) thumbnails can be found
@param int $indent Indent from left.
@param int $level
@param int $triggerContainer
@param string $expanded
@return string Table row for the element
@see getTable() | [
"Rendering",
"a",
"single",
"row",
"for",
"the",
"list"
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Xclass/DatabaseRecordList.php#L1328-L1629 |
TYPO3-extensions/gridelements | Classes/Xclass/DatabaseRecordList.php | DatabaseRecordList.recPath | public function recPath($pid)
{
if (!isset($this->recPath_cache[$pid])) {
$this->recPath_cache[$pid] = BackendUtility::getRecordPath($pid, $this->perms_clause, 20);
}
return $this->recPath_cache[$pid];
} | php | public function recPath($pid)
{
if (!isset($this->recPath_cache[$pid])) {
$this->recPath_cache[$pid] = BackendUtility::getRecordPath($pid, $this->perms_clause, 20);
}
return $this->recPath_cache[$pid];
} | [
"public",
"function",
"recPath",
"(",
"$",
"pid",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"recPath_cache",
"[",
"$",
"pid",
"]",
")",
")",
"{",
"$",
"this",
"->",
"recPath_cache",
"[",
"$",
"pid",
"]",
"=",
"BackendUtility",
"::",
"getRecordPath",
"(",
"$",
"pid",
",",
"$",
"this",
"->",
"perms_clause",
",",
"20",
")",
";",
"}",
"return",
"$",
"this",
"->",
"recPath_cache",
"[",
"$",
"pid",
"]",
";",
"}"
] | Returns the path for a certain pid
The result is cached internally for the session, thus you can call
this function as much as you like without performance problems.
@param int $pid The page id for which to get the path
@return mixed[] The path. | [
"Returns",
"the",
"path",
"for",
"a",
"certain",
"pid",
"The",
"result",
"is",
"cached",
"internally",
"for",
"the",
"session",
"thus",
"you",
"can",
"call",
"this",
"function",
"as",
"much",
"as",
"you",
"like",
"without",
"performance",
"problems",
"."
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Xclass/DatabaseRecordList.php#L1639-L1645 |
TYPO3-extensions/gridelements | Classes/Xclass/DatabaseRecordList.php | DatabaseRecordList.createReferenceHtml | protected function createReferenceHtml($tableName, $uid)
{
$referenceCount = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('sys_refindex')
->count(
'*',
'sys_refindex',
[
'ref_table' => $tableName,
'ref_uid' => (int)$uid,
'deleted' => 0,
]
);
return $this->generateReferenceToolTip(
$referenceCount,
GeneralUtility::quoteJSvalue($tableName) . ', ' . GeneralUtility::quoteJSvalue($uid)
);
} | php | protected function createReferenceHtml($tableName, $uid)
{
$referenceCount = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('sys_refindex')
->count(
'*',
'sys_refindex',
[
'ref_table' => $tableName,
'ref_uid' => (int)$uid,
'deleted' => 0,
]
);
return $this->generateReferenceToolTip(
$referenceCount,
GeneralUtility::quoteJSvalue($tableName) . ', ' . GeneralUtility::quoteJSvalue($uid)
);
} | [
"protected",
"function",
"createReferenceHtml",
"(",
"$",
"tableName",
",",
"$",
"uid",
")",
"{",
"$",
"referenceCount",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"ConnectionPool",
"::",
"class",
")",
"->",
"getConnectionForTable",
"(",
"'sys_refindex'",
")",
"->",
"count",
"(",
"'*'",
",",
"'sys_refindex'",
",",
"[",
"'ref_table'",
"=>",
"$",
"tableName",
",",
"'ref_uid'",
"=>",
"(",
"int",
")",
"$",
"uid",
",",
"'deleted'",
"=>",
"0",
",",
"]",
")",
";",
"return",
"$",
"this",
"->",
"generateReferenceToolTip",
"(",
"$",
"referenceCount",
",",
"GeneralUtility",
"::",
"quoteJSvalue",
"(",
"$",
"tableName",
")",
".",
"', '",
".",
"GeneralUtility",
"::",
"quoteJSvalue",
"(",
"$",
"uid",
")",
")",
";",
"}"
] | Creates the HTML for a reference count for the record with the UID $uid
in the table $tableName.
@param string $tableName
@param int $uid
@return string HTML of reference a link, will be empty if there are no | [
"Creates",
"the",
"HTML",
"for",
"a",
"reference",
"count",
"for",
"the",
"record",
"with",
"the",
"UID",
"$uid",
"in",
"the",
"table",
"$tableName",
"."
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Xclass/DatabaseRecordList.php#L1661-L1679 |
TYPO3-extensions/gridelements | Classes/Xclass/DatabaseRecordList.php | DatabaseRecordList.makeControl | public function makeControl($table, $row)
{
$module = $this->getModule();
$rowUid = $row['uid'];
if (ExtensionManagementUtility::isLoaded('workspaces') && isset($row['_ORIG_uid'])) {
$rowUid = $row['_ORIG_uid'];
}
$cells = [
'primary' => [],
'secondary' => [],
];
// Enables to hide the move elements for localized records - doesn't make much sense to perform these options for them
// For page translations these icons should never be shown
$isL10nOverlay = $table === 'pages' && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0;
// If the listed table is 'pages' we have to request the permission settings for each page:
$localCalcPerms = 0;
if ($table === 'pages') {
$localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord(
'pages',
$row['uid']
));
}
$permsEdit = $table === 'pages'
&& $this->getBackendUserAuthentication()->checkLanguageAccess(0)
&& $localCalcPerms & Permission::PAGE_EDIT
|| $table !== 'pages'
&& $this->calcPerms & Permission::CONTENT_EDIT
&& $this->getBackendUserAuthentication()->recordEditAccessInternals($table, $row);
$permsEdit = $this->overlayEditLockPermissions($table, $row, $permsEdit);
// "Show" link (only pages and tt_content elements)
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
if ($table === 'pages' || $table === 'tt_content') {
$onClick = $this->getOnClickForRow($table, $row);
$viewAction = '<a class="btn btn-default" href="#" onclick="'
. htmlspecialchars(
$onClick
) . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')) . '">';
if ($table === 'pages') {
$viewAction .= $this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)->render();
} else {
$viewAction .= $this->iconFactory->getIcon('actions-view', Icon::SIZE_SMALL)->render();
}
$viewAction .= '</a>';
$this->addActionToCellGroup($cells, $viewAction, 'view');
}
// "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
if ($permsEdit) {
$params = '&edit[' . $table . '][' . $row['uid'] . ']=edit';
$iconIdentifier = 'actions-open';
if ($table === 'pages') {
$iconIdentifier = 'actions-page-open';
}
$overlayIdentifier = !$this->isEditable($table) ? 'overlay-readonly' : null;
$editAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick(
$params,
'',
-1
))
. '" title="' . htmlspecialchars($this->getLanguageService()->getLL('edit')) . '">' . $this->iconFactory->getIcon(
$iconIdentifier,
Icon::SIZE_SMALL,
$overlayIdentifier
)->render() . '</a>';
} else {
$editAction = $this->spaceIcon;
}
$this->addActionToCellGroup($cells, $editAction, 'edit');
// "Info": (All records)
$onClick = 'top.TYPO3.InfoWindow.showItem(' . GeneralUtility::quoteJSvalue($table) . ', ' . (int)$row['uid'] . '); return false;';
$viewBigAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('showInfo')) . '">'
. $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL)->render() . '</a>';
$this->addActionToCellGroup($cells, $viewBigAction, 'viewBig');
// "Move" wizard link for pages/tt_content elements:
if ($permsEdit && ($table === 'tt_content' || $table === 'pages')) {
if ($isL10nOverlay) {
$moveAction = $this->spaceIcon;
} else {
$onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue((string)$uriBuilder->buildUriFromRoute('move_element') . '&table=' . $table . '&uid=' . $row['uid']) . ');';
$linkTitleLL = htmlspecialchars($this->getLanguageService()->getLL('move_' . ($table === 'tt_content' ? 'record' : 'page')));
$icon = ($table === 'pages' ? $this->iconFactory->getIcon(
'actions-page-move',
Icon::SIZE_SMALL
) : $this->iconFactory->getIcon('actions-document-move', Icon::SIZE_SMALL));
$moveAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $linkTitleLL . '">' . $icon->render() . '</a>';
}
$this->addActionToCellGroup($cells, $moveAction, 'move');
}
// If the table is NOT a read-only table, then show these links:
if ($this->isEditable($table)) {
// "Revert" link (history/undo)
if ((bool)\trim($userTsConfig['options.']['showHistory.'][$table] ?? $userTsConfig['options.']['showHistory'] ?? '1')) {
$moduleUrl = (string)$uriBuilder->buildUriFromRoute(
'record_history',
['element' => $table . ':' . $row['uid']]
);
$onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue($moduleUrl) . ',\'#latest\');';
$historyAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
. htmlspecialchars($this->getLanguageService()->getLL('history')) . '">'
. $this->iconFactory->getIcon('actions-document-history-open', Icon::SIZE_SMALL)->render() . '</a>';
$this->addActionToCellGroup($cells, $historyAction, 'history');
}
// "Edit Perms" link:
if ($table === 'pages' && $this->getBackendUserAuthentication()->check(
'modules',
'system_BeuserTxPermission'
) && ExtensionManagementUtility::isLoaded('beuser')) {
if ($isL10nOverlay) {
$permsAction = $this->spaceIcon;
} else {
$href = (string)$uriBuilder->buildUriFromRoute('system_BeuserTxPermission') . '&id=' . $row['uid'] . '&tx_beuser_system_beusertxpermission[action]=edit' . $this->makeReturnUrl();
$permsAction = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="'
. htmlspecialchars($this->getLanguageService()->getLL('permissions')) . '">'
. $this->iconFactory->getIcon('actions-lock', Icon::SIZE_SMALL)->render() . '</a>';
}
$this->addActionToCellGroup($cells, $permsAction, 'perms');
}
// "New record after" link (ONLY if the records in the table are sorted by a "sortby"-row
// or if default values can depend on previous record):
if (($GLOBALS['TCA'][$table]['ctrl']['sortby'] || $GLOBALS['TCA'][$table]['ctrl']['useColumnsForDefaultValues']) && $permsEdit) {
if ($table !== 'pages' && $this->calcPerms & Permission::CONTENT_EDIT || $table === 'pages' && $this->calcPerms & Permission::PAGE_NEW) {
if ($table === 'pages' && $isL10nOverlay) {
$this->addActionToCellGroup($cells, $this->spaceIcon, 'new');
} elseif ($this->showNewRecLink($table)) {
$params = '&edit[' . $table . '][' . -($row['_MOVE_PLH'] ? $row['_MOVE_PLH_uid'] : $row['uid']) . ']=new';
$icon = ($table === 'pages' ? $this->iconFactory->getIcon(
'actions-page-new',
Icon::SIZE_SMALL
) : $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL));
$titleLabel = 'new';
if ($GLOBALS['TCA'][$table]['ctrl']['sortby']) {
$titleLabel .= ($table === 'pages' ? 'Page' : 'Record');
}
$newAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick(
$params,
'',
-1
))
. '" title="' . htmlspecialchars($this->getLanguageService()->getLL($titleLabel)) . '">'
. $icon->render() . '</a>';
$this->addActionToCellGroup($cells, $newAction, 'new');
}
}
}
// "Up/Down" links
if ($permsEdit && $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField && !$this->searchLevels) {
if (isset($this->currentTable['prev'][$row['uid']]) && $this->showMoveUp === true && !$isL10nOverlay) {
// Up
$params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['prev'][$row['uid']];
$moveUpAction = '<a class="btn btn-default" href="#" onclick="'
. htmlspecialchars('return jumpToUrl(' . BackendUtility::getLinkToDataHandlerAction(
$params,
-1
) . ');')
. '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveUp')) . '">'
. $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render() . '</a>';
} else {
$moveUpAction = $this->spaceIcon;
}
$this->addActionToCellGroup($cells, $moveUpAction, 'moveUp');
if ($this->currentTable['next'][$row['uid']] && $this->showMoveDown === true && !$isL10nOverlay) {
// Down
$params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['next'][$row['uid']];
$moveDownAction = '<a class="btn btn-default" href="#" onclick="'
. htmlspecialchars('return jumpToUrl(' . BackendUtility::getLinkToDataHandlerAction(
$params,
-1
) . ');')
. '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveDown')) . '">'
. $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render() . '</a>';
} else {
$moveDownAction = $this->spaceIcon;
}
$this->addActionToCellGroup($cells, $moveDownAction, 'moveDown');
}
// "Hide/Unhide" links:
$hiddenField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
if (
!empty($GLOBALS['TCA'][$table]['columns'][$hiddenField])
&& (empty($GLOBALS['TCA'][$table]['columns'][$hiddenField]['exclude'])
|| $this->getBackendUserAuthentication()->check('non_exclude_fields', $table . ':' . $hiddenField))
) {
if (!$permsEdit || $this->isRecordCurrentBackendUser($table, $row)) {
$hideAction = $this->spaceIcon;
} else {
$hideTitle = htmlspecialchars($this->getLanguageService()->getLL('hide' . ($table === 'pages' ? 'Page' : '')));
$unhideTitle = htmlspecialchars($this->getLanguageService()->getLL('unHide' . ($table === 'pages' ? 'Page' : '')));
if ($row[$hiddenField]) {
$params = 'data[' . $table . '][' . $rowUid . '][' . $hiddenField . ']=0';
$hideAction = '<a class="btn btn-default t3js-record-hide" data-state="hidden" href="#"'
. ' data-params="' . htmlspecialchars($params) . '"'
. ' title="' . $unhideTitle . '"'
. ' data-toggle-title="' . $hideTitle . '">'
. $this->iconFactory->getIcon('actions-edit-unhide', Icon::SIZE_SMALL)->render() . '</a>';
} else {
$params = 'data[' . $table . '][' . $rowUid . '][' . $hiddenField . ']=1';
$hideAction = '<a class="btn btn-default t3js-record-hide" data-state="visible" href="#"'
. ' data-params="' . htmlspecialchars($params) . '"'
. ' title="' . $hideTitle . '"'
. ' data-toggle-title="' . $unhideTitle . '">'
. $this->iconFactory->getIcon('actions-edit-hide', Icon::SIZE_SMALL)->render() . '</a>';
}
}
$this->addActionToCellGroup($cells, $hideAction, 'hide');
}
// "Delete" link:
$disableDelete = (bool)\trim($userTsConfig['options.']['disableDelete.'][$table] ?? $userTsConfig['options.']['disableDelete'] ?? '0');
if ($permsEdit && !$disableDelete && ($table === 'pages' && $localCalcPerms & Permission::PAGE_DELETE || $table !== 'pages' && $this->calcPerms & Permission::CONTENT_EDIT)) {
// Check if the record version is in "deleted" state, because that will switch the action to "restore"
if ($this->getBackendUserAuthentication()->workspace > 0 && isset($row['t3ver_state']) && (int)$row['t3ver_state'] === 2) {
$actionName = 'restore';
$refCountMsg = '';
} else {
$actionName = 'delete';
$refCountMsg = BackendUtility::referenceCount(
$table,
$row['uid'],
' ' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.referencesToRecord'),
$this->getReferenceCount($table, $row['uid'])
) . BackendUtility::translationCount(
$table,
$row['uid'],
' ' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.translationsOfRecord')
);
}
if ($this->isRecordCurrentBackendUser($table, $row)) {
$deleteAction = $this->spaceIcon;
} else {
$title = BackendUtility::getRecordTitle($table, $row);
$warningText = $this->getLanguageService()->getLL($actionName . 'Warning') . ' "' . $title . '" ' . '[' . $table . ':' . $row['uid'] . ']' . $refCountMsg;
$params = 'cmd[' . $table . '][' . $row['uid'] . '][delete]=1';
$icon = $this->iconFactory->getIcon('actions-edit-' . $actionName, Icon::SIZE_SMALL)->render();
$linkTitle = htmlspecialchars($this->getLanguageService()->getLL($actionName));
$l10nParentField = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] ?? '';
$deleteAction = '<a class="btn btn-default t3js-record-delete" href="#" '
. ' data-l10parent="' . ($l10nParentField ? htmlspecialchars($row[$l10nParentField]) : '') . '"'
. ' data-params="' . htmlspecialchars($params) . '" data-title="' . htmlspecialchars($title) . '"'
. ' data-message="' . htmlspecialchars($warningText) . '" title="' . $linkTitle . '"'
. '>' . $icon . '</a>';
}
} else {
$deleteAction = $this->spaceIcon;
}
$this->addActionToCellGroup($cells, $deleteAction, 'delete');
// "Levels" links: Moving pages into new levels...
if ($permsEdit && $table === 'pages' && !$this->searchLevels) {
// Up (Paste as the page right after the current parent page)
if ($this->calcPerms & Permission::PAGE_NEW) {
$params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . -$this->id;
$moveLeftAction = '<a class="btn btn-default" href="#" onclick="'
. htmlspecialchars('return jumpToUrl(' . BackendUtility::getLinkToDataHandlerAction(
$params,
-1
) . ');')
. '" title="' . htmlspecialchars($this->getLanguageService()->getLL('prevLevel')) . '">'
. $this->iconFactory->getIcon('actions-move-left', Icon::SIZE_SMALL)->render() . '</a>';
$this->addActionToCellGroup(
$cells,
$isL10nOverlay ? $this->spaceIcon : $moveLeftAction,
'moveLeft'
);
}
// Down (Paste as subpage to the page right above)
if (!$isL10nOverlay && $this->currentTable['prevUid'][$row['uid']]) {
$localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord(
'pages',
$this->currentTable['prevUid'][$row['uid']]
));
if ($localCalcPerms & Permission::PAGE_NEW) {
$params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['prevUid'][$row['uid']];
$moveRightAction = '<a class="btn btn-default" href="#" onclick="'
. htmlspecialchars('return jumpToUrl(' . BackendUtility::getLinkToDataHandlerAction(
$params,
-1
) . ');')
. '" title="' . htmlspecialchars($this->getLanguageService()->getLL('nextLevel')) . '">'
. $this->iconFactory->getIcon('actions-move-right', Icon::SIZE_SMALL)->render() . '</a>';
} else {
$moveRightAction = $this->spaceIcon;
}
} else {
$moveRightAction = $this->spaceIcon;
}
$this->addActionToCellGroup($cells, $moveRightAction, 'moveRight');
}
}
/*
* hook: recStatInfoHooks: Allows to insert HTML before record icons on various places
*/
$hooks = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] ?? [];
if (!empty($hooks)) {
$stat = '';
$_params = [$table, $row['uid']];
foreach ($hooks as $_funcRef) {
$stat .= GeneralUtility::callUserFunction($_funcRef, $_params, $this);
}
$this->addActionToCellGroup($cells, $stat, 'stat');
}
/*
* hook: makeControl: Allows to change control icons of records in list-module
* usage: This hook method gets passed the current $cells array as third parameter.
* This array contains values for the icons/actions generated for each record in Web>List.
* Each array entry is accessible by an index-key.
* The order of the icons is depending on the order of those array entries.
*/
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ?? false)) {
// for compatibility reason, we move all icons to the rootlevel
// before calling the hooks
foreach ($cells as $section => $actions) {
foreach ($actions as $actionKey => $action) {
$cells[$actionKey] = $action;
}
}
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $className) {
$hookObject = GeneralUtility::makeInstance($className);
if (!$hookObject instanceof RecordListHookInterface) {
throw new \UnexpectedValueException(
$className . ' must implement interface ' . RecordListHookInterface::class,
1195567840
);
}
$cells = $hookObject->makeControl($table, $row, $cells, $this);
}
// now sort icons again into primary and secondary sections
// after all hooks are processed
$hookCells = $cells;
foreach ($hookCells as $key => $value) {
if ($key === 'primary' || $key === 'secondary') {
continue;
}
$this->addActionToCellGroup($cells, $value, $key);
}
}
$output = '<!-- CONTROL PANEL: ' . $table . ':' . $row['uid'] . ' -->';
foreach ($cells as $classification => $actions) {
$visibilityClass = ($classification !== 'primary' && !$module->MOD_SETTINGS['bigControlPanel'] ? 'collapsed' : 'expanded');
if ($visibilityClass === 'collapsed') {
$cellOutput = '';
foreach ($actions as $action) {
$cellOutput .= $action;
}
$output .= ' <div class="btn-group">' .
'<span id="actions_' . $table . '_' . $row['uid'] . '" class="btn-group collapse collapse-horizontal width">' . $cellOutput . '</span>' .
'<a href="#actions_' . $table . '_' . $row['uid'] . '" class="btn btn-default collapsed" data-toggle="collapse" aria-expanded="false"><span class="t3-icon fa fa-ellipsis-h"></span></a>' .
'</div>';
} else {
$output .= ' <div class="btn-group" role="group">' . implode('', $actions) . '</div>';
}
}
return $output;
} | php | public function makeControl($table, $row)
{
$module = $this->getModule();
$rowUid = $row['uid'];
if (ExtensionManagementUtility::isLoaded('workspaces') && isset($row['_ORIG_uid'])) {
$rowUid = $row['_ORIG_uid'];
}
$cells = [
'primary' => [],
'secondary' => [],
];
// Enables to hide the move elements for localized records - doesn't make much sense to perform these options for them
// For page translations these icons should never be shown
$isL10nOverlay = $table === 'pages' && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0;
// If the listed table is 'pages' we have to request the permission settings for each page:
$localCalcPerms = 0;
if ($table === 'pages') {
$localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord(
'pages',
$row['uid']
));
}
$permsEdit = $table === 'pages'
&& $this->getBackendUserAuthentication()->checkLanguageAccess(0)
&& $localCalcPerms & Permission::PAGE_EDIT
|| $table !== 'pages'
&& $this->calcPerms & Permission::CONTENT_EDIT
&& $this->getBackendUserAuthentication()->recordEditAccessInternals($table, $row);
$permsEdit = $this->overlayEditLockPermissions($table, $row, $permsEdit);
// "Show" link (only pages and tt_content elements)
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
if ($table === 'pages' || $table === 'tt_content') {
$onClick = $this->getOnClickForRow($table, $row);
$viewAction = '<a class="btn btn-default" href="#" onclick="'
. htmlspecialchars(
$onClick
) . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')) . '">';
if ($table === 'pages') {
$viewAction .= $this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)->render();
} else {
$viewAction .= $this->iconFactory->getIcon('actions-view', Icon::SIZE_SMALL)->render();
}
$viewAction .= '</a>';
$this->addActionToCellGroup($cells, $viewAction, 'view');
}
// "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
if ($permsEdit) {
$params = '&edit[' . $table . '][' . $row['uid'] . ']=edit';
$iconIdentifier = 'actions-open';
if ($table === 'pages') {
$iconIdentifier = 'actions-page-open';
}
$overlayIdentifier = !$this->isEditable($table) ? 'overlay-readonly' : null;
$editAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick(
$params,
'',
-1
))
. '" title="' . htmlspecialchars($this->getLanguageService()->getLL('edit')) . '">' . $this->iconFactory->getIcon(
$iconIdentifier,
Icon::SIZE_SMALL,
$overlayIdentifier
)->render() . '</a>';
} else {
$editAction = $this->spaceIcon;
}
$this->addActionToCellGroup($cells, $editAction, 'edit');
// "Info": (All records)
$onClick = 'top.TYPO3.InfoWindow.showItem(' . GeneralUtility::quoteJSvalue($table) . ', ' . (int)$row['uid'] . '); return false;';
$viewBigAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('showInfo')) . '">'
. $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL)->render() . '</a>';
$this->addActionToCellGroup($cells, $viewBigAction, 'viewBig');
// "Move" wizard link for pages/tt_content elements:
if ($permsEdit && ($table === 'tt_content' || $table === 'pages')) {
if ($isL10nOverlay) {
$moveAction = $this->spaceIcon;
} else {
$onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue((string)$uriBuilder->buildUriFromRoute('move_element') . '&table=' . $table . '&uid=' . $row['uid']) . ');';
$linkTitleLL = htmlspecialchars($this->getLanguageService()->getLL('move_' . ($table === 'tt_content' ? 'record' : 'page')));
$icon = ($table === 'pages' ? $this->iconFactory->getIcon(
'actions-page-move',
Icon::SIZE_SMALL
) : $this->iconFactory->getIcon('actions-document-move', Icon::SIZE_SMALL));
$moveAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $linkTitleLL . '">' . $icon->render() . '</a>';
}
$this->addActionToCellGroup($cells, $moveAction, 'move');
}
// If the table is NOT a read-only table, then show these links:
if ($this->isEditable($table)) {
// "Revert" link (history/undo)
if ((bool)\trim($userTsConfig['options.']['showHistory.'][$table] ?? $userTsConfig['options.']['showHistory'] ?? '1')) {
$moduleUrl = (string)$uriBuilder->buildUriFromRoute(
'record_history',
['element' => $table . ':' . $row['uid']]
);
$onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue($moduleUrl) . ',\'#latest\');';
$historyAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
. htmlspecialchars($this->getLanguageService()->getLL('history')) . '">'
. $this->iconFactory->getIcon('actions-document-history-open', Icon::SIZE_SMALL)->render() . '</a>';
$this->addActionToCellGroup($cells, $historyAction, 'history');
}
// "Edit Perms" link:
if ($table === 'pages' && $this->getBackendUserAuthentication()->check(
'modules',
'system_BeuserTxPermission'
) && ExtensionManagementUtility::isLoaded('beuser')) {
if ($isL10nOverlay) {
$permsAction = $this->spaceIcon;
} else {
$href = (string)$uriBuilder->buildUriFromRoute('system_BeuserTxPermission') . '&id=' . $row['uid'] . '&tx_beuser_system_beusertxpermission[action]=edit' . $this->makeReturnUrl();
$permsAction = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="'
. htmlspecialchars($this->getLanguageService()->getLL('permissions')) . '">'
. $this->iconFactory->getIcon('actions-lock', Icon::SIZE_SMALL)->render() . '</a>';
}
$this->addActionToCellGroup($cells, $permsAction, 'perms');
}
// "New record after" link (ONLY if the records in the table are sorted by a "sortby"-row
// or if default values can depend on previous record):
if (($GLOBALS['TCA'][$table]['ctrl']['sortby'] || $GLOBALS['TCA'][$table]['ctrl']['useColumnsForDefaultValues']) && $permsEdit) {
if ($table !== 'pages' && $this->calcPerms & Permission::CONTENT_EDIT || $table === 'pages' && $this->calcPerms & Permission::PAGE_NEW) {
if ($table === 'pages' && $isL10nOverlay) {
$this->addActionToCellGroup($cells, $this->spaceIcon, 'new');
} elseif ($this->showNewRecLink($table)) {
$params = '&edit[' . $table . '][' . -($row['_MOVE_PLH'] ? $row['_MOVE_PLH_uid'] : $row['uid']) . ']=new';
$icon = ($table === 'pages' ? $this->iconFactory->getIcon(
'actions-page-new',
Icon::SIZE_SMALL
) : $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL));
$titleLabel = 'new';
if ($GLOBALS['TCA'][$table]['ctrl']['sortby']) {
$titleLabel .= ($table === 'pages' ? 'Page' : 'Record');
}
$newAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick(
$params,
'',
-1
))
. '" title="' . htmlspecialchars($this->getLanguageService()->getLL($titleLabel)) . '">'
. $icon->render() . '</a>';
$this->addActionToCellGroup($cells, $newAction, 'new');
}
}
}
// "Up/Down" links
if ($permsEdit && $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField && !$this->searchLevels) {
if (isset($this->currentTable['prev'][$row['uid']]) && $this->showMoveUp === true && !$isL10nOverlay) {
// Up
$params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['prev'][$row['uid']];
$moveUpAction = '<a class="btn btn-default" href="#" onclick="'
. htmlspecialchars('return jumpToUrl(' . BackendUtility::getLinkToDataHandlerAction(
$params,
-1
) . ');')
. '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveUp')) . '">'
. $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render() . '</a>';
} else {
$moveUpAction = $this->spaceIcon;
}
$this->addActionToCellGroup($cells, $moveUpAction, 'moveUp');
if ($this->currentTable['next'][$row['uid']] && $this->showMoveDown === true && !$isL10nOverlay) {
// Down
$params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['next'][$row['uid']];
$moveDownAction = '<a class="btn btn-default" href="#" onclick="'
. htmlspecialchars('return jumpToUrl(' . BackendUtility::getLinkToDataHandlerAction(
$params,
-1
) . ');')
. '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveDown')) . '">'
. $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render() . '</a>';
} else {
$moveDownAction = $this->spaceIcon;
}
$this->addActionToCellGroup($cells, $moveDownAction, 'moveDown');
}
// "Hide/Unhide" links:
$hiddenField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
if (
!empty($GLOBALS['TCA'][$table]['columns'][$hiddenField])
&& (empty($GLOBALS['TCA'][$table]['columns'][$hiddenField]['exclude'])
|| $this->getBackendUserAuthentication()->check('non_exclude_fields', $table . ':' . $hiddenField))
) {
if (!$permsEdit || $this->isRecordCurrentBackendUser($table, $row)) {
$hideAction = $this->spaceIcon;
} else {
$hideTitle = htmlspecialchars($this->getLanguageService()->getLL('hide' . ($table === 'pages' ? 'Page' : '')));
$unhideTitle = htmlspecialchars($this->getLanguageService()->getLL('unHide' . ($table === 'pages' ? 'Page' : '')));
if ($row[$hiddenField]) {
$params = 'data[' . $table . '][' . $rowUid . '][' . $hiddenField . ']=0';
$hideAction = '<a class="btn btn-default t3js-record-hide" data-state="hidden" href="#"'
. ' data-params="' . htmlspecialchars($params) . '"'
. ' title="' . $unhideTitle . '"'
. ' data-toggle-title="' . $hideTitle . '">'
. $this->iconFactory->getIcon('actions-edit-unhide', Icon::SIZE_SMALL)->render() . '</a>';
} else {
$params = 'data[' . $table . '][' . $rowUid . '][' . $hiddenField . ']=1';
$hideAction = '<a class="btn btn-default t3js-record-hide" data-state="visible" href="#"'
. ' data-params="' . htmlspecialchars($params) . '"'
. ' title="' . $hideTitle . '"'
. ' data-toggle-title="' . $unhideTitle . '">'
. $this->iconFactory->getIcon('actions-edit-hide', Icon::SIZE_SMALL)->render() . '</a>';
}
}
$this->addActionToCellGroup($cells, $hideAction, 'hide');
}
// "Delete" link:
$disableDelete = (bool)\trim($userTsConfig['options.']['disableDelete.'][$table] ?? $userTsConfig['options.']['disableDelete'] ?? '0');
if ($permsEdit && !$disableDelete && ($table === 'pages' && $localCalcPerms & Permission::PAGE_DELETE || $table !== 'pages' && $this->calcPerms & Permission::CONTENT_EDIT)) {
// Check if the record version is in "deleted" state, because that will switch the action to "restore"
if ($this->getBackendUserAuthentication()->workspace > 0 && isset($row['t3ver_state']) && (int)$row['t3ver_state'] === 2) {
$actionName = 'restore';
$refCountMsg = '';
} else {
$actionName = 'delete';
$refCountMsg = BackendUtility::referenceCount(
$table,
$row['uid'],
' ' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.referencesToRecord'),
$this->getReferenceCount($table, $row['uid'])
) . BackendUtility::translationCount(
$table,
$row['uid'],
' ' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.translationsOfRecord')
);
}
if ($this->isRecordCurrentBackendUser($table, $row)) {
$deleteAction = $this->spaceIcon;
} else {
$title = BackendUtility::getRecordTitle($table, $row);
$warningText = $this->getLanguageService()->getLL($actionName . 'Warning') . ' "' . $title . '" ' . '[' . $table . ':' . $row['uid'] . ']' . $refCountMsg;
$params = 'cmd[' . $table . '][' . $row['uid'] . '][delete]=1';
$icon = $this->iconFactory->getIcon('actions-edit-' . $actionName, Icon::SIZE_SMALL)->render();
$linkTitle = htmlspecialchars($this->getLanguageService()->getLL($actionName));
$l10nParentField = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] ?? '';
$deleteAction = '<a class="btn btn-default t3js-record-delete" href="#" '
. ' data-l10parent="' . ($l10nParentField ? htmlspecialchars($row[$l10nParentField]) : '') . '"'
. ' data-params="' . htmlspecialchars($params) . '" data-title="' . htmlspecialchars($title) . '"'
. ' data-message="' . htmlspecialchars($warningText) . '" title="' . $linkTitle . '"'
. '>' . $icon . '</a>';
}
} else {
$deleteAction = $this->spaceIcon;
}
$this->addActionToCellGroup($cells, $deleteAction, 'delete');
// "Levels" links: Moving pages into new levels...
if ($permsEdit && $table === 'pages' && !$this->searchLevels) {
// Up (Paste as the page right after the current parent page)
if ($this->calcPerms & Permission::PAGE_NEW) {
$params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . -$this->id;
$moveLeftAction = '<a class="btn btn-default" href="#" onclick="'
. htmlspecialchars('return jumpToUrl(' . BackendUtility::getLinkToDataHandlerAction(
$params,
-1
) . ');')
. '" title="' . htmlspecialchars($this->getLanguageService()->getLL('prevLevel')) . '">'
. $this->iconFactory->getIcon('actions-move-left', Icon::SIZE_SMALL)->render() . '</a>';
$this->addActionToCellGroup(
$cells,
$isL10nOverlay ? $this->spaceIcon : $moveLeftAction,
'moveLeft'
);
}
// Down (Paste as subpage to the page right above)
if (!$isL10nOverlay && $this->currentTable['prevUid'][$row['uid']]) {
$localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord(
'pages',
$this->currentTable['prevUid'][$row['uid']]
));
if ($localCalcPerms & Permission::PAGE_NEW) {
$params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['prevUid'][$row['uid']];
$moveRightAction = '<a class="btn btn-default" href="#" onclick="'
. htmlspecialchars('return jumpToUrl(' . BackendUtility::getLinkToDataHandlerAction(
$params,
-1
) . ');')
. '" title="' . htmlspecialchars($this->getLanguageService()->getLL('nextLevel')) . '">'
. $this->iconFactory->getIcon('actions-move-right', Icon::SIZE_SMALL)->render() . '</a>';
} else {
$moveRightAction = $this->spaceIcon;
}
} else {
$moveRightAction = $this->spaceIcon;
}
$this->addActionToCellGroup($cells, $moveRightAction, 'moveRight');
}
}
/*
* hook: recStatInfoHooks: Allows to insert HTML before record icons on various places
*/
$hooks = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] ?? [];
if (!empty($hooks)) {
$stat = '';
$_params = [$table, $row['uid']];
foreach ($hooks as $_funcRef) {
$stat .= GeneralUtility::callUserFunction($_funcRef, $_params, $this);
}
$this->addActionToCellGroup($cells, $stat, 'stat');
}
/*
* hook: makeControl: Allows to change control icons of records in list-module
* usage: This hook method gets passed the current $cells array as third parameter.
* This array contains values for the icons/actions generated for each record in Web>List.
* Each array entry is accessible by an index-key.
* The order of the icons is depending on the order of those array entries.
*/
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ?? false)) {
// for compatibility reason, we move all icons to the rootlevel
// before calling the hooks
foreach ($cells as $section => $actions) {
foreach ($actions as $actionKey => $action) {
$cells[$actionKey] = $action;
}
}
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $className) {
$hookObject = GeneralUtility::makeInstance($className);
if (!$hookObject instanceof RecordListHookInterface) {
throw new \UnexpectedValueException(
$className . ' must implement interface ' . RecordListHookInterface::class,
1195567840
);
}
$cells = $hookObject->makeControl($table, $row, $cells, $this);
}
// now sort icons again into primary and secondary sections
// after all hooks are processed
$hookCells = $cells;
foreach ($hookCells as $key => $value) {
if ($key === 'primary' || $key === 'secondary') {
continue;
}
$this->addActionToCellGroup($cells, $value, $key);
}
}
$output = '<!-- CONTROL PANEL: ' . $table . ':' . $row['uid'] . ' -->';
foreach ($cells as $classification => $actions) {
$visibilityClass = ($classification !== 'primary' && !$module->MOD_SETTINGS['bigControlPanel'] ? 'collapsed' : 'expanded');
if ($visibilityClass === 'collapsed') {
$cellOutput = '';
foreach ($actions as $action) {
$cellOutput .= $action;
}
$output .= ' <div class="btn-group">' .
'<span id="actions_' . $table . '_' . $row['uid'] . '" class="btn-group collapse collapse-horizontal width">' . $cellOutput . '</span>' .
'<a href="#actions_' . $table . '_' . $row['uid'] . '" class="btn btn-default collapsed" data-toggle="collapse" aria-expanded="false"><span class="t3-icon fa fa-ellipsis-h"></span></a>' .
'</div>';
} else {
$output .= ' <div class="btn-group" role="group">' . implode('', $actions) . '</div>';
}
}
return $output;
} | [
"public",
"function",
"makeControl",
"(",
"$",
"table",
",",
"$",
"row",
")",
"{",
"$",
"module",
"=",
"$",
"this",
"->",
"getModule",
"(",
")",
";",
"$",
"rowUid",
"=",
"$",
"row",
"[",
"'uid'",
"]",
";",
"if",
"(",
"ExtensionManagementUtility",
"::",
"isLoaded",
"(",
"'workspaces'",
")",
"&&",
"isset",
"(",
"$",
"row",
"[",
"'_ORIG_uid'",
"]",
")",
")",
"{",
"$",
"rowUid",
"=",
"$",
"row",
"[",
"'_ORIG_uid'",
"]",
";",
"}",
"$",
"cells",
"=",
"[",
"'primary'",
"=>",
"[",
"]",
",",
"'secondary'",
"=>",
"[",
"]",
",",
"]",
";",
"// Enables to hide the move elements for localized records - doesn't make much sense to perform these options for them",
"// For page translations these icons should never be shown",
"$",
"isL10nOverlay",
"=",
"$",
"table",
"===",
"'pages'",
"&&",
"$",
"row",
"[",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'transOrigPointerField'",
"]",
"]",
"!=",
"0",
";",
"// If the listed table is 'pages' we have to request the permission settings for each page:",
"$",
"localCalcPerms",
"=",
"0",
";",
"if",
"(",
"$",
"table",
"===",
"'pages'",
")",
"{",
"$",
"localCalcPerms",
"=",
"$",
"this",
"->",
"getBackendUserAuthentication",
"(",
")",
"->",
"calcPerms",
"(",
"BackendUtility",
"::",
"getRecord",
"(",
"'pages'",
",",
"$",
"row",
"[",
"'uid'",
"]",
")",
")",
";",
"}",
"$",
"permsEdit",
"=",
"$",
"table",
"===",
"'pages'",
"&&",
"$",
"this",
"->",
"getBackendUserAuthentication",
"(",
")",
"->",
"checkLanguageAccess",
"(",
"0",
")",
"&&",
"$",
"localCalcPerms",
"&",
"Permission",
"::",
"PAGE_EDIT",
"||",
"$",
"table",
"!==",
"'pages'",
"&&",
"$",
"this",
"->",
"calcPerms",
"&",
"Permission",
"::",
"CONTENT_EDIT",
"&&",
"$",
"this",
"->",
"getBackendUserAuthentication",
"(",
")",
"->",
"recordEditAccessInternals",
"(",
"$",
"table",
",",
"$",
"row",
")",
";",
"$",
"permsEdit",
"=",
"$",
"this",
"->",
"overlayEditLockPermissions",
"(",
"$",
"table",
",",
"$",
"row",
",",
"$",
"permsEdit",
")",
";",
"// \"Show\" link (only pages and tt_content elements)",
"/** @var \\TYPO3\\CMS\\Backend\\Routing\\UriBuilder $uriBuilder */",
"$",
"uriBuilder",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"\\",
"TYPO3",
"\\",
"CMS",
"\\",
"Backend",
"\\",
"Routing",
"\\",
"UriBuilder",
"::",
"class",
")",
";",
"if",
"(",
"$",
"table",
"===",
"'pages'",
"||",
"$",
"table",
"===",
"'tt_content'",
")",
"{",
"$",
"onClick",
"=",
"$",
"this",
"->",
"getOnClickForRow",
"(",
"$",
"table",
",",
"$",
"row",
")",
";",
"$",
"viewAction",
"=",
"'<a class=\"btn btn-default\" href=\"#\" onclick=\"'",
".",
"htmlspecialchars",
"(",
"$",
"onClick",
")",
".",
"'\" title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage'",
")",
")",
".",
"'\">'",
";",
"if",
"(",
"$",
"table",
"===",
"'pages'",
")",
"{",
"$",
"viewAction",
".=",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-view-page'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
";",
"}",
"else",
"{",
"$",
"viewAction",
".=",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-view'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
";",
"}",
"$",
"viewAction",
".=",
"'</a>'",
";",
"$",
"this",
"->",
"addActionToCellGroup",
"(",
"$",
"cells",
",",
"$",
"viewAction",
",",
"'view'",
")",
";",
"}",
"// \"Edit\" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)",
"if",
"(",
"$",
"permsEdit",
")",
"{",
"$",
"params",
"=",
"'&edit['",
".",
"$",
"table",
".",
"']['",
".",
"$",
"row",
"[",
"'uid'",
"]",
".",
"']=edit'",
";",
"$",
"iconIdentifier",
"=",
"'actions-open'",
";",
"if",
"(",
"$",
"table",
"===",
"'pages'",
")",
"{",
"$",
"iconIdentifier",
"=",
"'actions-page-open'",
";",
"}",
"$",
"overlayIdentifier",
"=",
"!",
"$",
"this",
"->",
"isEditable",
"(",
"$",
"table",
")",
"?",
"'overlay-readonly'",
":",
"null",
";",
"$",
"editAction",
"=",
"'<a class=\"btn btn-default\" href=\"#\" onclick=\"'",
".",
"htmlspecialchars",
"(",
"BackendUtility",
"::",
"editOnClick",
"(",
"$",
"params",
",",
"''",
",",
"-",
"1",
")",
")",
".",
"'\" title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"'edit'",
")",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"$",
"iconIdentifier",
",",
"Icon",
"::",
"SIZE_SMALL",
",",
"$",
"overlayIdentifier",
")",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"}",
"else",
"{",
"$",
"editAction",
"=",
"$",
"this",
"->",
"spaceIcon",
";",
"}",
"$",
"this",
"->",
"addActionToCellGroup",
"(",
"$",
"cells",
",",
"$",
"editAction",
",",
"'edit'",
")",
";",
"// \"Info\": (All records)",
"$",
"onClick",
"=",
"'top.TYPO3.InfoWindow.showItem('",
".",
"GeneralUtility",
"::",
"quoteJSvalue",
"(",
"$",
"table",
")",
".",
"', '",
".",
"(",
"int",
")",
"$",
"row",
"[",
"'uid'",
"]",
".",
"'); return false;'",
";",
"$",
"viewBigAction",
"=",
"'<a class=\"btn btn-default\" href=\"#\" onclick=\"'",
".",
"htmlspecialchars",
"(",
"$",
"onClick",
")",
".",
"'\" title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"'showInfo'",
")",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-document-info'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"$",
"this",
"->",
"addActionToCellGroup",
"(",
"$",
"cells",
",",
"$",
"viewBigAction",
",",
"'viewBig'",
")",
";",
"// \"Move\" wizard link for pages/tt_content elements:",
"if",
"(",
"$",
"permsEdit",
"&&",
"(",
"$",
"table",
"===",
"'tt_content'",
"||",
"$",
"table",
"===",
"'pages'",
")",
")",
"{",
"if",
"(",
"$",
"isL10nOverlay",
")",
"{",
"$",
"moveAction",
"=",
"$",
"this",
"->",
"spaceIcon",
";",
"}",
"else",
"{",
"$",
"onClick",
"=",
"'return jumpExt('",
".",
"GeneralUtility",
"::",
"quoteJSvalue",
"(",
"(",
"string",
")",
"$",
"uriBuilder",
"->",
"buildUriFromRoute",
"(",
"'move_element'",
")",
".",
"'&table='",
".",
"$",
"table",
".",
"'&uid='",
".",
"$",
"row",
"[",
"'uid'",
"]",
")",
".",
"');'",
";",
"$",
"linkTitleLL",
"=",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"'move_'",
".",
"(",
"$",
"table",
"===",
"'tt_content'",
"?",
"'record'",
":",
"'page'",
")",
")",
")",
";",
"$",
"icon",
"=",
"(",
"$",
"table",
"===",
"'pages'",
"?",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-page-move'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
":",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-document-move'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
")",
";",
"$",
"moveAction",
"=",
"'<a class=\"btn btn-default\" href=\"#\" onclick=\"'",
".",
"htmlspecialchars",
"(",
"$",
"onClick",
")",
".",
"'\" title=\"'",
".",
"$",
"linkTitleLL",
".",
"'\">'",
".",
"$",
"icon",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"}",
"$",
"this",
"->",
"addActionToCellGroup",
"(",
"$",
"cells",
",",
"$",
"moveAction",
",",
"'move'",
")",
";",
"}",
"// If the table is NOT a read-only table, then show these links:",
"if",
"(",
"$",
"this",
"->",
"isEditable",
"(",
"$",
"table",
")",
")",
"{",
"// \"Revert\" link (history/undo)",
"if",
"(",
"(",
"bool",
")",
"\\",
"trim",
"(",
"$",
"userTsConfig",
"[",
"'options.'",
"]",
"[",
"'showHistory.'",
"]",
"[",
"$",
"table",
"]",
"??",
"$",
"userTsConfig",
"[",
"'options.'",
"]",
"[",
"'showHistory'",
"]",
"??",
"'1'",
")",
")",
"{",
"$",
"moduleUrl",
"=",
"(",
"string",
")",
"$",
"uriBuilder",
"->",
"buildUriFromRoute",
"(",
"'record_history'",
",",
"[",
"'element'",
"=>",
"$",
"table",
".",
"':'",
".",
"$",
"row",
"[",
"'uid'",
"]",
"]",
")",
";",
"$",
"onClick",
"=",
"'return jumpExt('",
".",
"GeneralUtility",
"::",
"quoteJSvalue",
"(",
"$",
"moduleUrl",
")",
".",
"',\\'#latest\\');'",
";",
"$",
"historyAction",
"=",
"'<a class=\"btn btn-default\" href=\"#\" onclick=\"'",
".",
"htmlspecialchars",
"(",
"$",
"onClick",
")",
".",
"'\" title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"'history'",
")",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-document-history-open'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"$",
"this",
"->",
"addActionToCellGroup",
"(",
"$",
"cells",
",",
"$",
"historyAction",
",",
"'history'",
")",
";",
"}",
"// \"Edit Perms\" link:",
"if",
"(",
"$",
"table",
"===",
"'pages'",
"&&",
"$",
"this",
"->",
"getBackendUserAuthentication",
"(",
")",
"->",
"check",
"(",
"'modules'",
",",
"'system_BeuserTxPermission'",
")",
"&&",
"ExtensionManagementUtility",
"::",
"isLoaded",
"(",
"'beuser'",
")",
")",
"{",
"if",
"(",
"$",
"isL10nOverlay",
")",
"{",
"$",
"permsAction",
"=",
"$",
"this",
"->",
"spaceIcon",
";",
"}",
"else",
"{",
"$",
"href",
"=",
"(",
"string",
")",
"$",
"uriBuilder",
"->",
"buildUriFromRoute",
"(",
"'system_BeuserTxPermission'",
")",
".",
"'&id='",
".",
"$",
"row",
"[",
"'uid'",
"]",
".",
"'&tx_beuser_system_beusertxpermission[action]=edit'",
".",
"$",
"this",
"->",
"makeReturnUrl",
"(",
")",
";",
"$",
"permsAction",
"=",
"'<a class=\"btn btn-default\" href=\"'",
".",
"htmlspecialchars",
"(",
"$",
"href",
")",
".",
"'\" title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"'permissions'",
")",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-lock'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"}",
"$",
"this",
"->",
"addActionToCellGroup",
"(",
"$",
"cells",
",",
"$",
"permsAction",
",",
"'perms'",
")",
";",
"}",
"// \"New record after\" link (ONLY if the records in the table are sorted by a \"sortby\"-row",
"// or if default values can depend on previous record):",
"if",
"(",
"(",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'sortby'",
"]",
"||",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'useColumnsForDefaultValues'",
"]",
")",
"&&",
"$",
"permsEdit",
")",
"{",
"if",
"(",
"$",
"table",
"!==",
"'pages'",
"&&",
"$",
"this",
"->",
"calcPerms",
"&",
"Permission",
"::",
"CONTENT_EDIT",
"||",
"$",
"table",
"===",
"'pages'",
"&&",
"$",
"this",
"->",
"calcPerms",
"&",
"Permission",
"::",
"PAGE_NEW",
")",
"{",
"if",
"(",
"$",
"table",
"===",
"'pages'",
"&&",
"$",
"isL10nOverlay",
")",
"{",
"$",
"this",
"->",
"addActionToCellGroup",
"(",
"$",
"cells",
",",
"$",
"this",
"->",
"spaceIcon",
",",
"'new'",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"showNewRecLink",
"(",
"$",
"table",
")",
")",
"{",
"$",
"params",
"=",
"'&edit['",
".",
"$",
"table",
".",
"']['",
".",
"-",
"(",
"$",
"row",
"[",
"'_MOVE_PLH'",
"]",
"?",
"$",
"row",
"[",
"'_MOVE_PLH_uid'",
"]",
":",
"$",
"row",
"[",
"'uid'",
"]",
")",
".",
"']=new'",
";",
"$",
"icon",
"=",
"(",
"$",
"table",
"===",
"'pages'",
"?",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-page-new'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
":",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-add'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
")",
";",
"$",
"titleLabel",
"=",
"'new'",
";",
"if",
"(",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'sortby'",
"]",
")",
"{",
"$",
"titleLabel",
".=",
"(",
"$",
"table",
"===",
"'pages'",
"?",
"'Page'",
":",
"'Record'",
")",
";",
"}",
"$",
"newAction",
"=",
"'<a class=\"btn btn-default\" href=\"#\" onclick=\"'",
".",
"htmlspecialchars",
"(",
"BackendUtility",
"::",
"editOnClick",
"(",
"$",
"params",
",",
"''",
",",
"-",
"1",
")",
")",
".",
"'\" title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"$",
"titleLabel",
")",
")",
".",
"'\">'",
".",
"$",
"icon",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"$",
"this",
"->",
"addActionToCellGroup",
"(",
"$",
"cells",
",",
"$",
"newAction",
",",
"'new'",
")",
";",
"}",
"}",
"}",
"// \"Up/Down\" links",
"if",
"(",
"$",
"permsEdit",
"&&",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'sortby'",
"]",
"&&",
"!",
"$",
"this",
"->",
"sortField",
"&&",
"!",
"$",
"this",
"->",
"searchLevels",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"currentTable",
"[",
"'prev'",
"]",
"[",
"$",
"row",
"[",
"'uid'",
"]",
"]",
")",
"&&",
"$",
"this",
"->",
"showMoveUp",
"===",
"true",
"&&",
"!",
"$",
"isL10nOverlay",
")",
"{",
"// Up",
"$",
"params",
"=",
"'&cmd['",
".",
"$",
"table",
".",
"']['",
".",
"$",
"row",
"[",
"'uid'",
"]",
".",
"'][move]='",
".",
"$",
"this",
"->",
"currentTable",
"[",
"'prev'",
"]",
"[",
"$",
"row",
"[",
"'uid'",
"]",
"]",
";",
"$",
"moveUpAction",
"=",
"'<a class=\"btn btn-default\" href=\"#\" onclick=\"'",
".",
"htmlspecialchars",
"(",
"'return jumpToUrl('",
".",
"BackendUtility",
"::",
"getLinkToDataHandlerAction",
"(",
"$",
"params",
",",
"-",
"1",
")",
".",
"');'",
")",
".",
"'\" title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"'moveUp'",
")",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-move-up'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"}",
"else",
"{",
"$",
"moveUpAction",
"=",
"$",
"this",
"->",
"spaceIcon",
";",
"}",
"$",
"this",
"->",
"addActionToCellGroup",
"(",
"$",
"cells",
",",
"$",
"moveUpAction",
",",
"'moveUp'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"currentTable",
"[",
"'next'",
"]",
"[",
"$",
"row",
"[",
"'uid'",
"]",
"]",
"&&",
"$",
"this",
"->",
"showMoveDown",
"===",
"true",
"&&",
"!",
"$",
"isL10nOverlay",
")",
"{",
"// Down",
"$",
"params",
"=",
"'&cmd['",
".",
"$",
"table",
".",
"']['",
".",
"$",
"row",
"[",
"'uid'",
"]",
".",
"'][move]='",
".",
"$",
"this",
"->",
"currentTable",
"[",
"'next'",
"]",
"[",
"$",
"row",
"[",
"'uid'",
"]",
"]",
";",
"$",
"moveDownAction",
"=",
"'<a class=\"btn btn-default\" href=\"#\" onclick=\"'",
".",
"htmlspecialchars",
"(",
"'return jumpToUrl('",
".",
"BackendUtility",
"::",
"getLinkToDataHandlerAction",
"(",
"$",
"params",
",",
"-",
"1",
")",
".",
"');'",
")",
".",
"'\" title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"'moveDown'",
")",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-move-down'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"}",
"else",
"{",
"$",
"moveDownAction",
"=",
"$",
"this",
"->",
"spaceIcon",
";",
"}",
"$",
"this",
"->",
"addActionToCellGroup",
"(",
"$",
"cells",
",",
"$",
"moveDownAction",
",",
"'moveDown'",
")",
";",
"}",
"// \"Hide/Unhide\" links:",
"$",
"hiddenField",
"=",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'enablecolumns'",
"]",
"[",
"'disabled'",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'columns'",
"]",
"[",
"$",
"hiddenField",
"]",
")",
"&&",
"(",
"empty",
"(",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'columns'",
"]",
"[",
"$",
"hiddenField",
"]",
"[",
"'exclude'",
"]",
")",
"||",
"$",
"this",
"->",
"getBackendUserAuthentication",
"(",
")",
"->",
"check",
"(",
"'non_exclude_fields'",
",",
"$",
"table",
".",
"':'",
".",
"$",
"hiddenField",
")",
")",
")",
"{",
"if",
"(",
"!",
"$",
"permsEdit",
"||",
"$",
"this",
"->",
"isRecordCurrentBackendUser",
"(",
"$",
"table",
",",
"$",
"row",
")",
")",
"{",
"$",
"hideAction",
"=",
"$",
"this",
"->",
"spaceIcon",
";",
"}",
"else",
"{",
"$",
"hideTitle",
"=",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"'hide'",
".",
"(",
"$",
"table",
"===",
"'pages'",
"?",
"'Page'",
":",
"''",
")",
")",
")",
";",
"$",
"unhideTitle",
"=",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"'unHide'",
".",
"(",
"$",
"table",
"===",
"'pages'",
"?",
"'Page'",
":",
"''",
")",
")",
")",
";",
"if",
"(",
"$",
"row",
"[",
"$",
"hiddenField",
"]",
")",
"{",
"$",
"params",
"=",
"'data['",
".",
"$",
"table",
".",
"']['",
".",
"$",
"rowUid",
".",
"']['",
".",
"$",
"hiddenField",
".",
"']=0'",
";",
"$",
"hideAction",
"=",
"'<a class=\"btn btn-default t3js-record-hide\" data-state=\"hidden\" href=\"#\"'",
".",
"' data-params=\"'",
".",
"htmlspecialchars",
"(",
"$",
"params",
")",
".",
"'\"'",
".",
"' title=\"'",
".",
"$",
"unhideTitle",
".",
"'\"'",
".",
"' data-toggle-title=\"'",
".",
"$",
"hideTitle",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-edit-unhide'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"}",
"else",
"{",
"$",
"params",
"=",
"'data['",
".",
"$",
"table",
".",
"']['",
".",
"$",
"rowUid",
".",
"']['",
".",
"$",
"hiddenField",
".",
"']=1'",
";",
"$",
"hideAction",
"=",
"'<a class=\"btn btn-default t3js-record-hide\" data-state=\"visible\" href=\"#\"'",
".",
"' data-params=\"'",
".",
"htmlspecialchars",
"(",
"$",
"params",
")",
".",
"'\"'",
".",
"' title=\"'",
".",
"$",
"hideTitle",
".",
"'\"'",
".",
"' data-toggle-title=\"'",
".",
"$",
"unhideTitle",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-edit-hide'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"}",
"}",
"$",
"this",
"->",
"addActionToCellGroup",
"(",
"$",
"cells",
",",
"$",
"hideAction",
",",
"'hide'",
")",
";",
"}",
"// \"Delete\" link:",
"$",
"disableDelete",
"=",
"(",
"bool",
")",
"\\",
"trim",
"(",
"$",
"userTsConfig",
"[",
"'options.'",
"]",
"[",
"'disableDelete.'",
"]",
"[",
"$",
"table",
"]",
"??",
"$",
"userTsConfig",
"[",
"'options.'",
"]",
"[",
"'disableDelete'",
"]",
"??",
"'0'",
")",
";",
"if",
"(",
"$",
"permsEdit",
"&&",
"!",
"$",
"disableDelete",
"&&",
"(",
"$",
"table",
"===",
"'pages'",
"&&",
"$",
"localCalcPerms",
"&",
"Permission",
"::",
"PAGE_DELETE",
"||",
"$",
"table",
"!==",
"'pages'",
"&&",
"$",
"this",
"->",
"calcPerms",
"&",
"Permission",
"::",
"CONTENT_EDIT",
")",
")",
"{",
"// Check if the record version is in \"deleted\" state, because that will switch the action to \"restore\"",
"if",
"(",
"$",
"this",
"->",
"getBackendUserAuthentication",
"(",
")",
"->",
"workspace",
">",
"0",
"&&",
"isset",
"(",
"$",
"row",
"[",
"'t3ver_state'",
"]",
")",
"&&",
"(",
"int",
")",
"$",
"row",
"[",
"'t3ver_state'",
"]",
"===",
"2",
")",
"{",
"$",
"actionName",
"=",
"'restore'",
";",
"$",
"refCountMsg",
"=",
"''",
";",
"}",
"else",
"{",
"$",
"actionName",
"=",
"'delete'",
";",
"$",
"refCountMsg",
"=",
"BackendUtility",
"::",
"referenceCount",
"(",
"$",
"table",
",",
"$",
"row",
"[",
"'uid'",
"]",
",",
"' '",
".",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.referencesToRecord'",
")",
",",
"$",
"this",
"->",
"getReferenceCount",
"(",
"$",
"table",
",",
"$",
"row",
"[",
"'uid'",
"]",
")",
")",
".",
"BackendUtility",
"::",
"translationCount",
"(",
"$",
"table",
",",
"$",
"row",
"[",
"'uid'",
"]",
",",
"' '",
".",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"sL",
"(",
"'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.translationsOfRecord'",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isRecordCurrentBackendUser",
"(",
"$",
"table",
",",
"$",
"row",
")",
")",
"{",
"$",
"deleteAction",
"=",
"$",
"this",
"->",
"spaceIcon",
";",
"}",
"else",
"{",
"$",
"title",
"=",
"BackendUtility",
"::",
"getRecordTitle",
"(",
"$",
"table",
",",
"$",
"row",
")",
";",
"$",
"warningText",
"=",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"$",
"actionName",
".",
"'Warning'",
")",
".",
"' \"'",
".",
"$",
"title",
".",
"'\" '",
".",
"'['",
".",
"$",
"table",
".",
"':'",
".",
"$",
"row",
"[",
"'uid'",
"]",
".",
"']'",
".",
"$",
"refCountMsg",
";",
"$",
"params",
"=",
"'cmd['",
".",
"$",
"table",
".",
"']['",
".",
"$",
"row",
"[",
"'uid'",
"]",
".",
"'][delete]=1'",
";",
"$",
"icon",
"=",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-edit-'",
".",
"$",
"actionName",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
";",
"$",
"linkTitle",
"=",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"$",
"actionName",
")",
")",
";",
"$",
"l10nParentField",
"=",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'transOrigPointerField'",
"]",
"??",
"''",
";",
"$",
"deleteAction",
"=",
"'<a class=\"btn btn-default t3js-record-delete\" href=\"#\" '",
".",
"' data-l10parent=\"'",
".",
"(",
"$",
"l10nParentField",
"?",
"htmlspecialchars",
"(",
"$",
"row",
"[",
"$",
"l10nParentField",
"]",
")",
":",
"''",
")",
".",
"'\"'",
".",
"' data-params=\"'",
".",
"htmlspecialchars",
"(",
"$",
"params",
")",
".",
"'\" data-title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"title",
")",
".",
"'\"'",
".",
"' data-message=\"'",
".",
"htmlspecialchars",
"(",
"$",
"warningText",
")",
".",
"'\" title=\"'",
".",
"$",
"linkTitle",
".",
"'\"'",
".",
"'>'",
".",
"$",
"icon",
".",
"'</a>'",
";",
"}",
"}",
"else",
"{",
"$",
"deleteAction",
"=",
"$",
"this",
"->",
"spaceIcon",
";",
"}",
"$",
"this",
"->",
"addActionToCellGroup",
"(",
"$",
"cells",
",",
"$",
"deleteAction",
",",
"'delete'",
")",
";",
"// \"Levels\" links: Moving pages into new levels...",
"if",
"(",
"$",
"permsEdit",
"&&",
"$",
"table",
"===",
"'pages'",
"&&",
"!",
"$",
"this",
"->",
"searchLevels",
")",
"{",
"// Up (Paste as the page right after the current parent page)",
"if",
"(",
"$",
"this",
"->",
"calcPerms",
"&",
"Permission",
"::",
"PAGE_NEW",
")",
"{",
"$",
"params",
"=",
"'&cmd['",
".",
"$",
"table",
".",
"']['",
".",
"$",
"row",
"[",
"'uid'",
"]",
".",
"'][move]='",
".",
"-",
"$",
"this",
"->",
"id",
";",
"$",
"moveLeftAction",
"=",
"'<a class=\"btn btn-default\" href=\"#\" onclick=\"'",
".",
"htmlspecialchars",
"(",
"'return jumpToUrl('",
".",
"BackendUtility",
"::",
"getLinkToDataHandlerAction",
"(",
"$",
"params",
",",
"-",
"1",
")",
".",
"');'",
")",
".",
"'\" title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"'prevLevel'",
")",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-move-left'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"$",
"this",
"->",
"addActionToCellGroup",
"(",
"$",
"cells",
",",
"$",
"isL10nOverlay",
"?",
"$",
"this",
"->",
"spaceIcon",
":",
"$",
"moveLeftAction",
",",
"'moveLeft'",
")",
";",
"}",
"// Down (Paste as subpage to the page right above)",
"if",
"(",
"!",
"$",
"isL10nOverlay",
"&&",
"$",
"this",
"->",
"currentTable",
"[",
"'prevUid'",
"]",
"[",
"$",
"row",
"[",
"'uid'",
"]",
"]",
")",
"{",
"$",
"localCalcPerms",
"=",
"$",
"this",
"->",
"getBackendUserAuthentication",
"(",
")",
"->",
"calcPerms",
"(",
"BackendUtility",
"::",
"getRecord",
"(",
"'pages'",
",",
"$",
"this",
"->",
"currentTable",
"[",
"'prevUid'",
"]",
"[",
"$",
"row",
"[",
"'uid'",
"]",
"]",
")",
")",
";",
"if",
"(",
"$",
"localCalcPerms",
"&",
"Permission",
"::",
"PAGE_NEW",
")",
"{",
"$",
"params",
"=",
"'&cmd['",
".",
"$",
"table",
".",
"']['",
".",
"$",
"row",
"[",
"'uid'",
"]",
".",
"'][move]='",
".",
"$",
"this",
"->",
"currentTable",
"[",
"'prevUid'",
"]",
"[",
"$",
"row",
"[",
"'uid'",
"]",
"]",
";",
"$",
"moveRightAction",
"=",
"'<a class=\"btn btn-default\" href=\"#\" onclick=\"'",
".",
"htmlspecialchars",
"(",
"'return jumpToUrl('",
".",
"BackendUtility",
"::",
"getLinkToDataHandlerAction",
"(",
"$",
"params",
",",
"-",
"1",
")",
".",
"');'",
")",
".",
"'\" title=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"'nextLevel'",
")",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"iconFactory",
"->",
"getIcon",
"(",
"'actions-move-right'",
",",
"Icon",
"::",
"SIZE_SMALL",
")",
"->",
"render",
"(",
")",
".",
"'</a>'",
";",
"}",
"else",
"{",
"$",
"moveRightAction",
"=",
"$",
"this",
"->",
"spaceIcon",
";",
"}",
"}",
"else",
"{",
"$",
"moveRightAction",
"=",
"$",
"this",
"->",
"spaceIcon",
";",
"}",
"$",
"this",
"->",
"addActionToCellGroup",
"(",
"$",
"cells",
",",
"$",
"moveRightAction",
",",
"'moveRight'",
")",
";",
"}",
"}",
"/*\n * hook: recStatInfoHooks: Allows to insert HTML before record icons on various places\n */",
"$",
"hooks",
"=",
"$",
"GLOBALS",
"[",
"'TYPO3_CONF_VARS'",
"]",
"[",
"'SC_OPTIONS'",
"]",
"[",
"'GLOBAL'",
"]",
"[",
"'recStatInfoHooks'",
"]",
"??",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"hooks",
")",
")",
"{",
"$",
"stat",
"=",
"''",
";",
"$",
"_params",
"=",
"[",
"$",
"table",
",",
"$",
"row",
"[",
"'uid'",
"]",
"]",
";",
"foreach",
"(",
"$",
"hooks",
"as",
"$",
"_funcRef",
")",
"{",
"$",
"stat",
".=",
"GeneralUtility",
"::",
"callUserFunction",
"(",
"$",
"_funcRef",
",",
"$",
"_params",
",",
"$",
"this",
")",
";",
"}",
"$",
"this",
"->",
"addActionToCellGroup",
"(",
"$",
"cells",
",",
"$",
"stat",
",",
"'stat'",
")",
";",
"}",
"/*\n * hook: makeControl: Allows to change control icons of records in list-module\n * usage: This hook method gets passed the current $cells array as third parameter.\n * This array contains values for the icons/actions generated for each record in Web>List.\n * Each array entry is accessible by an index-key.\n * The order of the icons is depending on the order of those array entries.\n */",
"if",
"(",
"is_array",
"(",
"$",
"GLOBALS",
"[",
"'TYPO3_CONF_VARS'",
"]",
"[",
"'SC_OPTIONS'",
"]",
"[",
"'typo3/class.db_list_extra.inc'",
"]",
"[",
"'actions'",
"]",
"??",
"false",
")",
")",
"{",
"// for compatibility reason, we move all icons to the rootlevel",
"// before calling the hooks",
"foreach",
"(",
"$",
"cells",
"as",
"$",
"section",
"=>",
"$",
"actions",
")",
"{",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"actionKey",
"=>",
"$",
"action",
")",
"{",
"$",
"cells",
"[",
"$",
"actionKey",
"]",
"=",
"$",
"action",
";",
"}",
"}",
"foreach",
"(",
"$",
"GLOBALS",
"[",
"'TYPO3_CONF_VARS'",
"]",
"[",
"'SC_OPTIONS'",
"]",
"[",
"'typo3/class.db_list_extra.inc'",
"]",
"[",
"'actions'",
"]",
"as",
"$",
"className",
")",
"{",
"$",
"hookObject",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"$",
"className",
")",
";",
"if",
"(",
"!",
"$",
"hookObject",
"instanceof",
"RecordListHookInterface",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"$",
"className",
".",
"' must implement interface '",
".",
"RecordListHookInterface",
"::",
"class",
",",
"1195567840",
")",
";",
"}",
"$",
"cells",
"=",
"$",
"hookObject",
"->",
"makeControl",
"(",
"$",
"table",
",",
"$",
"row",
",",
"$",
"cells",
",",
"$",
"this",
")",
";",
"}",
"// now sort icons again into primary and secondary sections",
"// after all hooks are processed",
"$",
"hookCells",
"=",
"$",
"cells",
";",
"foreach",
"(",
"$",
"hookCells",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"===",
"'primary'",
"||",
"$",
"key",
"===",
"'secondary'",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"addActionToCellGroup",
"(",
"$",
"cells",
",",
"$",
"value",
",",
"$",
"key",
")",
";",
"}",
"}",
"$",
"output",
"=",
"'<!-- CONTROL PANEL: '",
".",
"$",
"table",
".",
"':'",
".",
"$",
"row",
"[",
"'uid'",
"]",
".",
"' -->'",
";",
"foreach",
"(",
"$",
"cells",
"as",
"$",
"classification",
"=>",
"$",
"actions",
")",
"{",
"$",
"visibilityClass",
"=",
"(",
"$",
"classification",
"!==",
"'primary'",
"&&",
"!",
"$",
"module",
"->",
"MOD_SETTINGS",
"[",
"'bigControlPanel'",
"]",
"?",
"'collapsed'",
":",
"'expanded'",
")",
";",
"if",
"(",
"$",
"visibilityClass",
"===",
"'collapsed'",
")",
"{",
"$",
"cellOutput",
"=",
"''",
";",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"action",
")",
"{",
"$",
"cellOutput",
".=",
"$",
"action",
";",
"}",
"$",
"output",
".=",
"' <div class=\"btn-group\">'",
".",
"'<span id=\"actions_'",
".",
"$",
"table",
".",
"'_'",
".",
"$",
"row",
"[",
"'uid'",
"]",
".",
"'\" class=\"btn-group collapse collapse-horizontal width\">'",
".",
"$",
"cellOutput",
".",
"'</span>'",
".",
"'<a href=\"#actions_'",
".",
"$",
"table",
".",
"'_'",
".",
"$",
"row",
"[",
"'uid'",
"]",
".",
"'\" class=\"btn btn-default collapsed\" data-toggle=\"collapse\" aria-expanded=\"false\"><span class=\"t3-icon fa fa-ellipsis-h\"></span></a>'",
".",
"'</div>'",
";",
"}",
"else",
"{",
"$",
"output",
".=",
"' <div class=\"btn-group\" role=\"group\">'",
".",
"implode",
"(",
"''",
",",
"$",
"actions",
")",
".",
"'</div>'",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] | Creates the control panel for a single record in the listing.
@param string $table The table
@param mixed[] $row The record for which to make the control panel.
@throws \UnexpectedValueException
@throws RouteNotFoundException
@return string HTML table with the control panel (unless disabled) | [
"Creates",
"the",
"control",
"panel",
"for",
"a",
"single",
"record",
"in",
"the",
"listing",
"."
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Xclass/DatabaseRecordList.php#L1690-L2045 |
TYPO3-extensions/gridelements | Classes/Xclass/DatabaseRecordList.php | DatabaseRecordList.overlayEditLockPermissions | protected function overlayEditLockPermissions($table, $row = [], $editPermission = true)
{
if ($editPermission && !$this->getBackendUserAuthentication()->isAdmin()) {
// If no $row is submitted we only check for general edit lock of current page (except for table "pages")
if (empty($row)) {
return $table === 'pages' ? true : !$this->pageRow['editlock'];
}
if (($table === 'pages' && $row['editlock']) || ($table !== 'pages' && $this->pageRow['editlock'])) {
$editPermission = false;
} elseif (isset($GLOBALS['TCA'][$table]['ctrl']['editlock']) && $row[$GLOBALS['TCA'][$table]['ctrl']['editlock']]) {
$editPermission = false;
}
}
return $editPermission;
} | php | protected function overlayEditLockPermissions($table, $row = [], $editPermission = true)
{
if ($editPermission && !$this->getBackendUserAuthentication()->isAdmin()) {
// If no $row is submitted we only check for general edit lock of current page (except for table "pages")
if (empty($row)) {
return $table === 'pages' ? true : !$this->pageRow['editlock'];
}
if (($table === 'pages' && $row['editlock']) || ($table !== 'pages' && $this->pageRow['editlock'])) {
$editPermission = false;
} elseif (isset($GLOBALS['TCA'][$table]['ctrl']['editlock']) && $row[$GLOBALS['TCA'][$table]['ctrl']['editlock']]) {
$editPermission = false;
}
}
return $editPermission;
} | [
"protected",
"function",
"overlayEditLockPermissions",
"(",
"$",
"table",
",",
"$",
"row",
"=",
"[",
"]",
",",
"$",
"editPermission",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"editPermission",
"&&",
"!",
"$",
"this",
"->",
"getBackendUserAuthentication",
"(",
")",
"->",
"isAdmin",
"(",
")",
")",
"{",
"// If no $row is submitted we only check for general edit lock of current page (except for table \"pages\")",
"if",
"(",
"empty",
"(",
"$",
"row",
")",
")",
"{",
"return",
"$",
"table",
"===",
"'pages'",
"?",
"true",
":",
"!",
"$",
"this",
"->",
"pageRow",
"[",
"'editlock'",
"]",
";",
"}",
"if",
"(",
"(",
"$",
"table",
"===",
"'pages'",
"&&",
"$",
"row",
"[",
"'editlock'",
"]",
")",
"||",
"(",
"$",
"table",
"!==",
"'pages'",
"&&",
"$",
"this",
"->",
"pageRow",
"[",
"'editlock'",
"]",
")",
")",
"{",
"$",
"editPermission",
"=",
"false",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'editlock'",
"]",
")",
"&&",
"$",
"row",
"[",
"$",
"GLOBALS",
"[",
"'TCA'",
"]",
"[",
"$",
"table",
"]",
"[",
"'ctrl'",
"]",
"[",
"'editlock'",
"]",
"]",
")",
"{",
"$",
"editPermission",
"=",
"false",
";",
"}",
"}",
"return",
"$",
"editPermission",
";",
"}"
] | Check if the current record is locked by editlock. Pages are locked if their editlock flag is set,
records are if they are locked themselves or if the page they are on is locked (a page’s editlock
is transitive for its content elements).
@param string $table
@param array $row
@param bool $editPermission
@return bool | [
"Check",
"if",
"the",
"current",
"record",
"is",
"locked",
"by",
"editlock",
".",
"Pages",
"are",
"locked",
"if",
"their",
"editlock",
"flag",
"is",
"set",
"records",
"are",
"if",
"they",
"are",
"locked",
"themselves",
"or",
"if",
"the",
"page",
"they",
"are",
"on",
"is",
"locked",
"(",
"a",
"page’s",
"editlock",
"is",
"transitive",
"for",
"its",
"content",
"elements",
")",
"."
] | train | https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Xclass/DatabaseRecordList.php#L2057-L2071 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.