id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
24,200
|
heidelpay/PhpDoc
|
src/phpDocumentor/Parser/File.php
|
File.parse
|
public function parse($filename, ProjectDescriptorBuilder $builder)
{
if (class_exists('phpDocumentor\Event\Dispatcher')) {
Dispatcher::getInstance()->dispatch(
'parser.file.pre',
PreFileEvent::createInstance($this)->setFile($filename)
);
}
$this->log('Starting to parse file: ' . $filename);
try {
$file = $this->createFileReflector($builder, $filename);
if (!$file) {
$this->log('>> Skipped file ' . $filename . ' as no modifications were detected');
return;
}
$file->process();
$builder->buildFileUsingSourceData($file);
$this->logErrorsForDescriptor($builder->getProjectDescriptor()->getFiles()->get($file->getFilename()));
} catch (Exception $e) {
$this->log(
' Unable to parse file "' . $filename . '", an error was detected: ' . $e->getMessage(),
LogLevel::ALERT
);
}
}
|
php
|
public function parse($filename, ProjectDescriptorBuilder $builder)
{
if (class_exists('phpDocumentor\Event\Dispatcher')) {
Dispatcher::getInstance()->dispatch(
'parser.file.pre',
PreFileEvent::createInstance($this)->setFile($filename)
);
}
$this->log('Starting to parse file: ' . $filename);
try {
$file = $this->createFileReflector($builder, $filename);
if (!$file) {
$this->log('>> Skipped file ' . $filename . ' as no modifications were detected');
return;
}
$file->process();
$builder->buildFileUsingSourceData($file);
$this->logErrorsForDescriptor($builder->getProjectDescriptor()->getFiles()->get($file->getFilename()));
} catch (Exception $e) {
$this->log(
' Unable to parse file "' . $filename . '", an error was detected: ' . $e->getMessage(),
LogLevel::ALERT
);
}
}
|
[
"public",
"function",
"parse",
"(",
"$",
"filename",
",",
"ProjectDescriptorBuilder",
"$",
"builder",
")",
"{",
"if",
"(",
"class_exists",
"(",
"'phpDocumentor\\Event\\Dispatcher'",
")",
")",
"{",
"Dispatcher",
"::",
"getInstance",
"(",
")",
"->",
"dispatch",
"(",
"'parser.file.pre'",
",",
"PreFileEvent",
"::",
"createInstance",
"(",
"$",
"this",
")",
"->",
"setFile",
"(",
"$",
"filename",
")",
")",
";",
"}",
"$",
"this",
"->",
"log",
"(",
"'Starting to parse file: '",
".",
"$",
"filename",
")",
";",
"try",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"createFileReflector",
"(",
"$",
"builder",
",",
"$",
"filename",
")",
";",
"if",
"(",
"!",
"$",
"file",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'>> Skipped file '",
".",
"$",
"filename",
".",
"' as no modifications were detected'",
")",
";",
"return",
";",
"}",
"$",
"file",
"->",
"process",
"(",
")",
";",
"$",
"builder",
"->",
"buildFileUsingSourceData",
"(",
"$",
"file",
")",
";",
"$",
"this",
"->",
"logErrorsForDescriptor",
"(",
"$",
"builder",
"->",
"getProjectDescriptor",
"(",
")",
"->",
"getFiles",
"(",
")",
"->",
"get",
"(",
"$",
"file",
"->",
"getFilename",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"' Unable to parse file \"'",
".",
"$",
"filename",
".",
"'\", an error was detected: '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"LogLevel",
"::",
"ALERT",
")",
";",
"}",
"}"
] |
Parses the file identified by the given filename and passes the resulting FileDescriptor to the ProjectBuilder.
@param string $filename
@param ProjectDescriptorBuilder $builder
@return void
|
[
"Parses",
"the",
"file",
"identified",
"by",
"the",
"given",
"filename",
"and",
"passes",
"the",
"resulting",
"FileDescriptor",
"to",
"the",
"ProjectBuilder",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Parser/File.php#L49-L75
|
24,201
|
heidelpay/PhpDoc
|
src/phpDocumentor/Parser/File.php
|
File.createFileReflector
|
protected function createFileReflector(ProjectDescriptorBuilder $builder, $filename)
{
$file = new FileReflector($filename, $this->parser->doValidation(), $this->parser->getEncoding());
$file->setDefaultPackageName($this->parser->getDefaultPackageName());
$file->setMarkers($this->parser->getMarkers());
$file->setFilename($this->getRelativeFilename($filename));
$cachedFiles = $builder->getProjectDescriptor()->getFiles();
$hash = $cachedFiles->get($file->getFilename())
? $cachedFiles->get($file->getFilename())->getHash()
: null;
return $hash === $file->getHash() && !$this->parser->isForced()
? null
: $file;
}
|
php
|
protected function createFileReflector(ProjectDescriptorBuilder $builder, $filename)
{
$file = new FileReflector($filename, $this->parser->doValidation(), $this->parser->getEncoding());
$file->setDefaultPackageName($this->parser->getDefaultPackageName());
$file->setMarkers($this->parser->getMarkers());
$file->setFilename($this->getRelativeFilename($filename));
$cachedFiles = $builder->getProjectDescriptor()->getFiles();
$hash = $cachedFiles->get($file->getFilename())
? $cachedFiles->get($file->getFilename())->getHash()
: null;
return $hash === $file->getHash() && !$this->parser->isForced()
? null
: $file;
}
|
[
"protected",
"function",
"createFileReflector",
"(",
"ProjectDescriptorBuilder",
"$",
"builder",
",",
"$",
"filename",
")",
"{",
"$",
"file",
"=",
"new",
"FileReflector",
"(",
"$",
"filename",
",",
"$",
"this",
"->",
"parser",
"->",
"doValidation",
"(",
")",
",",
"$",
"this",
"->",
"parser",
"->",
"getEncoding",
"(",
")",
")",
";",
"$",
"file",
"->",
"setDefaultPackageName",
"(",
"$",
"this",
"->",
"parser",
"->",
"getDefaultPackageName",
"(",
")",
")",
";",
"$",
"file",
"->",
"setMarkers",
"(",
"$",
"this",
"->",
"parser",
"->",
"getMarkers",
"(",
")",
")",
";",
"$",
"file",
"->",
"setFilename",
"(",
"$",
"this",
"->",
"getRelativeFilename",
"(",
"$",
"filename",
")",
")",
";",
"$",
"cachedFiles",
"=",
"$",
"builder",
"->",
"getProjectDescriptor",
"(",
")",
"->",
"getFiles",
"(",
")",
";",
"$",
"hash",
"=",
"$",
"cachedFiles",
"->",
"get",
"(",
"$",
"file",
"->",
"getFilename",
"(",
")",
")",
"?",
"$",
"cachedFiles",
"->",
"get",
"(",
"$",
"file",
"->",
"getFilename",
"(",
")",
")",
"->",
"getHash",
"(",
")",
":",
"null",
";",
"return",
"$",
"hash",
"===",
"$",
"file",
"->",
"getHash",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"parser",
"->",
"isForced",
"(",
")",
"?",
"null",
":",
"$",
"file",
";",
"}"
] |
Creates a new FileReflector for the given filename or null if the file contains no modifications.
@param ProjectDescriptorBuilder $builder
@param string $filename
@return FileReflector|null Returns a new FileReflector or null if no modifications were detected for the given
filename.
|
[
"Creates",
"a",
"new",
"FileReflector",
"for",
"the",
"given",
"filename",
"or",
"null",
"if",
"the",
"file",
"contains",
"no",
"modifications",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Parser/File.php#L86-L101
|
24,202
|
heidelpay/PhpDoc
|
src/phpDocumentor/Parser/File.php
|
File.logErrorsForDescriptor
|
protected function logErrorsForDescriptor(FileDescriptor $fileDescriptor)
{
$errors = $fileDescriptor->getAllErrors();
/** @var Error $error */
foreach ($errors as $error) {
$this->log($error->getCode(), $error->getSeverity(), $error->getContext());
}
}
|
php
|
protected function logErrorsForDescriptor(FileDescriptor $fileDescriptor)
{
$errors = $fileDescriptor->getAllErrors();
/** @var Error $error */
foreach ($errors as $error) {
$this->log($error->getCode(), $error->getSeverity(), $error->getContext());
}
}
|
[
"protected",
"function",
"logErrorsForDescriptor",
"(",
"FileDescriptor",
"$",
"fileDescriptor",
")",
"{",
"$",
"errors",
"=",
"$",
"fileDescriptor",
"->",
"getAllErrors",
"(",
")",
";",
"/** @var Error $error */",
"foreach",
"(",
"$",
"errors",
"as",
"$",
"error",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"$",
"error",
"->",
"getCode",
"(",
")",
",",
"$",
"error",
"->",
"getSeverity",
"(",
")",
",",
"$",
"error",
"->",
"getContext",
"(",
")",
")",
";",
"}",
"}"
] |
Writes the errors found in the Descriptor to the log.
@param FileDescriptor $fileDescriptor
@return void
|
[
"Writes",
"the",
"errors",
"found",
"in",
"the",
"Descriptor",
"to",
"the",
"log",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Parser/File.php#L110-L118
|
24,203
|
heidelpay/PhpDoc
|
src/phpDocumentor/Parser/File.php
|
File.getRelativeFilename
|
public function getRelativeFilename($filename)
{
// strip path from filename
$result = ltrim(substr($filename, strlen($this->parser->getPath())), DIRECTORY_SEPARATOR);
if ($result === '') {
throw new \InvalidArgumentException(
'File is not present in the given project path: ' . $filename
);
}
return $result;
}
|
php
|
public function getRelativeFilename($filename)
{
// strip path from filename
$result = ltrim(substr($filename, strlen($this->parser->getPath())), DIRECTORY_SEPARATOR);
if ($result === '') {
throw new \InvalidArgumentException(
'File is not present in the given project path: ' . $filename
);
}
return $result;
}
|
[
"public",
"function",
"getRelativeFilename",
"(",
"$",
"filename",
")",
"{",
"// strip path from filename",
"$",
"result",
"=",
"ltrim",
"(",
"substr",
"(",
"$",
"filename",
",",
"strlen",
"(",
"$",
"this",
"->",
"parser",
"->",
"getPath",
"(",
")",
")",
")",
",",
"DIRECTORY_SEPARATOR",
")",
";",
"if",
"(",
"$",
"result",
"===",
"''",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'File is not present in the given project path: '",
".",
"$",
"filename",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns the filename, relative to the root of the project directory.
@param string $filename The filename to make relative.
@throws \InvalidArgumentException if file is not in the project root.
@return string
|
[
"Returns",
"the",
"filename",
"relative",
"to",
"the",
"root",
"of",
"the",
"project",
"directory",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Parser/File.php#L129-L140
|
24,204
|
frdl/webfan
|
.ApplicationComposer/lib/frdl/Compress/Zip/Helper.php
|
Helper.zip
|
public static function zip($i, $o, $del = false, $afilename = null, $s = 0){
$i = str_replace('\\', '/', $i);
$zp = new \ZipArchive();
if(file_exists($o)){
$flags = 0;
}else{
$flags = \ZipArchive::CREATE;
}
$zp->open($o, $flags);
$afilename = (is_string($afilename)) ? $afilename : basename($i);
$success = $zp->addFile($i, $afilename);
$zp->close();
if(true===$del)unlink($afilename);
if($success){
if($s > 0){
return self::split($o, $s);
}
}else{
return false;
}
}
|
php
|
public static function zip($i, $o, $del = false, $afilename = null, $s = 0){
$i = str_replace('\\', '/', $i);
$zp = new \ZipArchive();
if(file_exists($o)){
$flags = 0;
}else{
$flags = \ZipArchive::CREATE;
}
$zp->open($o, $flags);
$afilename = (is_string($afilename)) ? $afilename : basename($i);
$success = $zp->addFile($i, $afilename);
$zp->close();
if(true===$del)unlink($afilename);
if($success){
if($s > 0){
return self::split($o, $s);
}
}else{
return false;
}
}
|
[
"public",
"static",
"function",
"zip",
"(",
"$",
"i",
",",
"$",
"o",
",",
"$",
"del",
"=",
"false",
",",
"$",
"afilename",
"=",
"null",
",",
"$",
"s",
"=",
"0",
")",
"{",
"$",
"i",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"i",
")",
";",
"$",
"zp",
"=",
"new",
"\\",
"ZipArchive",
"(",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"o",
")",
")",
"{",
"$",
"flags",
"=",
"0",
";",
"}",
"else",
"{",
"$",
"flags",
"=",
"\\",
"ZipArchive",
"::",
"CREATE",
";",
"}",
"$",
"zp",
"->",
"open",
"(",
"$",
"o",
",",
"$",
"flags",
")",
";",
"$",
"afilename",
"=",
"(",
"is_string",
"(",
"$",
"afilename",
")",
")",
"?",
"$",
"afilename",
":",
"basename",
"(",
"$",
"i",
")",
";",
"$",
"success",
"=",
"$",
"zp",
"->",
"addFile",
"(",
"$",
"i",
",",
"$",
"afilename",
")",
";",
"$",
"zp",
"->",
"close",
"(",
")",
";",
"if",
"(",
"true",
"===",
"$",
"del",
")",
"unlink",
"(",
"$",
"afilename",
")",
";",
"if",
"(",
"$",
"success",
")",
"{",
"if",
"(",
"$",
"s",
">",
"0",
")",
"{",
"return",
"self",
"::",
"split",
"(",
"$",
"o",
",",
"$",
"s",
")",
";",
"}",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Compact a file in multipart zip archive.
@param string $i The file to compact.
@param string $o The zip archive (*.zip).
@param integer $s The mnax size (in byte) for the parts. 0 to no parts.
@return boolean Return number of parts created.
|
[
"Compact",
"a",
"file",
"in",
"multipart",
"zip",
"archive",
"."
] |
84d270377685224e891cd9d571b103b36f05b845
|
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/frdl/Compress/Zip/Helper.php#L202-L230
|
24,205
|
frdl/webfan
|
.ApplicationComposer/lib/frdl/Compress/Zip/Helper.php
|
Helper.split
|
protected static function split($i, $s){
$fs = filesize($i);
//$bn = basename($i);
//$dn = dirname($i).DIRECTORY_SEPARATOR;
$p = 1;
for($c = 0; $c < $fs; $c = $c + $s){
$data = file_get_contents($i, FILE_BINARY, null, $c, $s);
//$fn = "$dn$bn.$p";
$fn = "$i.$p";
file_put_contents($fn, $data);
$p++;
unset($data);
}
unlink($i);
return $p - 1;
}
|
php
|
protected static function split($i, $s){
$fs = filesize($i);
//$bn = basename($i);
//$dn = dirname($i).DIRECTORY_SEPARATOR;
$p = 1;
for($c = 0; $c < $fs; $c = $c + $s){
$data = file_get_contents($i, FILE_BINARY, null, $c, $s);
//$fn = "$dn$bn.$p";
$fn = "$i.$p";
file_put_contents($fn, $data);
$p++;
unset($data);
}
unlink($i);
return $p - 1;
}
|
[
"protected",
"static",
"function",
"split",
"(",
"$",
"i",
",",
"$",
"s",
")",
"{",
"$",
"fs",
"=",
"filesize",
"(",
"$",
"i",
")",
";",
"//$bn = basename($i);",
"//$dn = dirname($i).DIRECTORY_SEPARATOR;",
"$",
"p",
"=",
"1",
";",
"for",
"(",
"$",
"c",
"=",
"0",
";",
"$",
"c",
"<",
"$",
"fs",
";",
"$",
"c",
"=",
"$",
"c",
"+",
"$",
"s",
")",
"{",
"$",
"data",
"=",
"file_get_contents",
"(",
"$",
"i",
",",
"FILE_BINARY",
",",
"null",
",",
"$",
"c",
",",
"$",
"s",
")",
";",
"//$fn = \"$dn$bn.$p\";",
"$",
"fn",
"=",
"\"$i.$p\"",
";",
"file_put_contents",
"(",
"$",
"fn",
",",
"$",
"data",
")",
";",
"$",
"p",
"++",
";",
"unset",
"(",
"$",
"data",
")",
";",
"}",
"unlink",
"(",
"$",
"i",
")",
";",
"return",
"$",
"p",
"-",
"1",
";",
"}"
] |
Split the zip archive.
@param string $i The zip archive.
@param integer $s The max size for the parts.
@return integer Return the number of parts created.
|
[
"Split",
"the",
"zip",
"archive",
"."
] |
84d270377685224e891cd9d571b103b36f05b845
|
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/frdl/Compress/Zip/Helper.php#L327-L343
|
24,206
|
frdl/webfan
|
.ApplicationComposer/lib/frdl/Compress/Zip/Helper.php
|
Helper.unzip
|
public static function unzip($i, $o, $p = 0){
$success = true;
if($p > 0){
$success = self::merge($i, $p);
}
if($success == false){
return false;
}
$zp = new \ZipArchive();
$zp->open($i);
if($zp->extractTo($o)){
$zp->close();
unset($zp);
// unlink($i);
return true;
}else{
return false;
}
}
|
php
|
public static function unzip($i, $o, $p = 0){
$success = true;
if($p > 0){
$success = self::merge($i, $p);
}
if($success == false){
return false;
}
$zp = new \ZipArchive();
$zp->open($i);
if($zp->extractTo($o)){
$zp->close();
unset($zp);
// unlink($i);
return true;
}else{
return false;
}
}
|
[
"public",
"static",
"function",
"unzip",
"(",
"$",
"i",
",",
"$",
"o",
",",
"$",
"p",
"=",
"0",
")",
"{",
"$",
"success",
"=",
"true",
";",
"if",
"(",
"$",
"p",
">",
"0",
")",
"{",
"$",
"success",
"=",
"self",
"::",
"merge",
"(",
"$",
"i",
",",
"$",
"p",
")",
";",
"}",
"if",
"(",
"$",
"success",
"==",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"zp",
"=",
"new",
"\\",
"ZipArchive",
"(",
")",
";",
"$",
"zp",
"->",
"open",
"(",
"$",
"i",
")",
";",
"if",
"(",
"$",
"zp",
"->",
"extractTo",
"(",
"$",
"o",
")",
")",
"{",
"$",
"zp",
"->",
"close",
"(",
")",
";",
"unset",
"(",
"$",
"zp",
")",
";",
"// unlink($i);",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Decompact the zip archive.
@param string $i The zip archive (*.zip).
@param string $o The directory name for extract.
@param integer $p Number of parts of the zip archive.
@return boolean Return TRUE for success or FALSE for fail.
|
[
"Decompact",
"the",
"zip",
"archive",
"."
] |
84d270377685224e891cd9d571b103b36f05b845
|
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/frdl/Compress/Zip/Helper.php#L355-L375
|
24,207
|
frdl/webfan
|
.ApplicationComposer/lib/frdl/Compress/Zip/Helper.php
|
Helper.merge
|
protected static function merge($i, $p){
for($c = 1; $c <= $p; $c++){
$data = file_get_contents("$i.$c");
file_put_contents($i, $data, FILE_APPEND);
unset($data);
}
return true;
}
|
php
|
protected static function merge($i, $p){
for($c = 1; $c <= $p; $c++){
$data = file_get_contents("$i.$c");
file_put_contents($i, $data, FILE_APPEND);
unset($data);
}
return true;
}
|
[
"protected",
"static",
"function",
"merge",
"(",
"$",
"i",
",",
"$",
"p",
")",
"{",
"for",
"(",
"$",
"c",
"=",
"1",
";",
"$",
"c",
"<=",
"$",
"p",
";",
"$",
"c",
"++",
")",
"{",
"$",
"data",
"=",
"file_get_contents",
"(",
"\"$i.$c\"",
")",
";",
"file_put_contents",
"(",
"$",
"i",
",",
"$",
"data",
",",
"FILE_APPEND",
")",
";",
"unset",
"(",
"$",
"data",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Merge the parts of zip archive.
@param string $i The zip archive (*.zip).
@param integer $p Number of parts of the zip archive.
@return boolean Return TRUE for success or FALSE for fail.
|
[
"Merge",
"the",
"parts",
"of",
"zip",
"archive",
"."
] |
84d270377685224e891cd9d571b103b36f05b845
|
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/frdl/Compress/Zip/Helper.php#L383-L390
|
24,208
|
frdl/webfan
|
.ApplicationComposer/lib/frdl/Compress/Zip/Helper.php
|
Helper.isEncryptedZip
|
public static function isEncryptedZip( $pathToArchive ) {
$fp = @fopen( $pathToArchive, 'r' );
$encrypted = false;
if ( $fp && fseek( $fp, 6 ) == 0 ) {
$string = fread( $fp, 2 );
if ( false !== $string ) {
$data = unpack("vgeneral", $string);
$encrypted = $data[ 'general' ] & 0x01 ? true : false;
}
fclose( $fp );
}
return $encrypted;
}
|
php
|
public static function isEncryptedZip( $pathToArchive ) {
$fp = @fopen( $pathToArchive, 'r' );
$encrypted = false;
if ( $fp && fseek( $fp, 6 ) == 0 ) {
$string = fread( $fp, 2 );
if ( false !== $string ) {
$data = unpack("vgeneral", $string);
$encrypted = $data[ 'general' ] & 0x01 ? true : false;
}
fclose( $fp );
}
return $encrypted;
}
|
[
"public",
"static",
"function",
"isEncryptedZip",
"(",
"$",
"pathToArchive",
")",
"{",
"$",
"fp",
"=",
"@",
"fopen",
"(",
"$",
"pathToArchive",
",",
"'r'",
")",
";",
"$",
"encrypted",
"=",
"false",
";",
"if",
"(",
"$",
"fp",
"&&",
"fseek",
"(",
"$",
"fp",
",",
"6",
")",
"==",
"0",
")",
"{",
"$",
"string",
"=",
"fread",
"(",
"$",
"fp",
",",
"2",
")",
";",
"if",
"(",
"false",
"!==",
"$",
"string",
")",
"{",
"$",
"data",
"=",
"unpack",
"(",
"\"vgeneral\"",
",",
"$",
"string",
")",
";",
"$",
"encrypted",
"=",
"$",
"data",
"[",
"'general'",
"]",
"&",
"0x01",
"?",
"true",
":",
"false",
";",
"}",
"fclose",
"(",
"$",
"fp",
")",
";",
"}",
"return",
"$",
"encrypted",
";",
"}"
] |
Check if the file is encrypted
Notice: if file doesn't exists or cannot be opened, function
also return false.
@param string $pathToArchive
@return boolean return true if file is encrypted
|
[
"Check",
"if",
"the",
"file",
"is",
"encrypted"
] |
84d270377685224e891cd9d571b103b36f05b845
|
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/frdl/Compress/Zip/Helper.php#L411-L423
|
24,209
|
netvlies/NetvliesFormBundle
|
Admin/FieldAdmin.php
|
FieldAdmin.generateObjectUrl
|
public function generateObjectUrl($name, $object, array $parameters = array(), $absolute = false)
{
if ($name != 'list') {
return parent::generateObjectUrl($name, $object, $parameters, $absolute);
}
return parent::generateObjectUrl($name, $object->getForm(), $parameters, $absolute);
}
|
php
|
public function generateObjectUrl($name, $object, array $parameters = array(), $absolute = false)
{
if ($name != 'list') {
return parent::generateObjectUrl($name, $object, $parameters, $absolute);
}
return parent::generateObjectUrl($name, $object->getForm(), $parameters, $absolute);
}
|
[
"public",
"function",
"generateObjectUrl",
"(",
"$",
"name",
",",
"$",
"object",
",",
"array",
"$",
"parameters",
"=",
"array",
"(",
")",
",",
"$",
"absolute",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"name",
"!=",
"'list'",
")",
"{",
"return",
"parent",
"::",
"generateObjectUrl",
"(",
"$",
"name",
",",
"$",
"object",
",",
"$",
"parameters",
",",
"$",
"absolute",
")",
";",
"}",
"return",
"parent",
"::",
"generateObjectUrl",
"(",
"$",
"name",
",",
"$",
"object",
"->",
"getForm",
"(",
")",
",",
"$",
"parameters",
",",
"$",
"absolute",
")",
";",
"}"
] |
This is to create the correct route when going back to the form edit instead of the field list.
@param string $name
@param mixed $object
@param array $parameters
@return string return a complete url
|
[
"This",
"is",
"to",
"create",
"the",
"correct",
"route",
"when",
"going",
"back",
"to",
"the",
"form",
"edit",
"instead",
"of",
"the",
"field",
"list",
"."
] |
93f9a3321d9925040111374e7c1014a6400a2d08
|
https://github.com/netvlies/NetvliesFormBundle/blob/93f9a3321d9925040111374e7c1014a6400a2d08/Admin/FieldAdmin.php#L149-L156
|
24,210
|
netvlies/NetvliesFormBundle
|
Admin/FieldAdmin.php
|
FieldAdmin.validate
|
public function validate(ErrorElement $errorElement, $field)
{
if ($field->getType() == 'date') {
$formatter = new IntlDateFormatter(null, null, null);
$formatter->setPattern('d-M-y');
if (!$formatter->parse($field->getDefault())) {
$errorElement->with('default')->addViolation('Dit is geen geldige standaardwaarde voor datum volgens formaat dag-maand-jaar');
}
}
}
|
php
|
public function validate(ErrorElement $errorElement, $field)
{
if ($field->getType() == 'date') {
$formatter = new IntlDateFormatter(null, null, null);
$formatter->setPattern('d-M-y');
if (!$formatter->parse($field->getDefault())) {
$errorElement->with('default')->addViolation('Dit is geen geldige standaardwaarde voor datum volgens formaat dag-maand-jaar');
}
}
}
|
[
"public",
"function",
"validate",
"(",
"ErrorElement",
"$",
"errorElement",
",",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"field",
"->",
"getType",
"(",
")",
"==",
"'date'",
")",
"{",
"$",
"formatter",
"=",
"new",
"IntlDateFormatter",
"(",
"null",
",",
"null",
",",
"null",
")",
";",
"$",
"formatter",
"->",
"setPattern",
"(",
"'d-M-y'",
")",
";",
"if",
"(",
"!",
"$",
"formatter",
"->",
"parse",
"(",
"$",
"field",
"->",
"getDefault",
"(",
")",
")",
")",
"{",
"$",
"errorElement",
"->",
"with",
"(",
"'default'",
")",
"->",
"addViolation",
"(",
"'Dit is geen geldige standaardwaarde voor datum volgens formaat dag-maand-jaar'",
")",
";",
"}",
"}",
"}"
] |
Add specific validation when default for type = date is entered.
|
[
"Add",
"specific",
"validation",
"when",
"default",
"for",
"type",
"=",
"date",
"is",
"entered",
"."
] |
93f9a3321d9925040111374e7c1014a6400a2d08
|
https://github.com/netvlies/NetvliesFormBundle/blob/93f9a3321d9925040111374e7c1014a6400a2d08/Admin/FieldAdmin.php#L161-L171
|
24,211
|
grozzzny/catalog
|
models/Properties.php
|
Properties.getCategory
|
public function getCategory()
{
$categoryModel = static::getCategoryModel();
return ($this->type == self::TYPE_CATEGORY) ? $this->hasOne($categoryModel::className(), ['id' => $this->options->category_id]) : null;
}
|
php
|
public function getCategory()
{
$categoryModel = static::getCategoryModel();
return ($this->type == self::TYPE_CATEGORY) ? $this->hasOne($categoryModel::className(), ['id' => $this->options->category_id]) : null;
}
|
[
"public",
"function",
"getCategory",
"(",
")",
"{",
"$",
"categoryModel",
"=",
"static",
"::",
"getCategoryModel",
"(",
")",
";",
"return",
"(",
"$",
"this",
"->",
"type",
"==",
"self",
"::",
"TYPE_CATEGORY",
")",
"?",
"$",
"this",
"->",
"hasOne",
"(",
"$",
"categoryModel",
"::",
"className",
"(",
")",
",",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"options",
"->",
"category_id",
"]",
")",
":",
"null",
";",
"}"
] |
Only type "TYPE_CATEGORY"
@return null|\yii\db\ActiveQuery
|
[
"Only",
"type",
"TYPE_CATEGORY"
] |
ff1cac10a5f3a89f3ef2767f9ede6b2d74e1849a
|
https://github.com/grozzzny/catalog/blob/ff1cac10a5f3a89f3ef2767f9ede6b2d74e1849a/models/Properties.php#L251-L255
|
24,212
|
bit3archive/php-remote-objects
|
src/RemoteObjects/Transport/HttpServer.php
|
HttpServer.receive
|
public function receive()
{
$input = file_get_contents('php://input');
if (
$this->logger !== null &&
$this->logger->isHandling(Logger::DEBUG)
) {
$this->logger->addDebug(
'Receive request',
array(
'request' => ctype_print($input) ? $input : 'base64:' . base64_encode($input)
)
);
}
return $input;
}
|
php
|
public function receive()
{
$input = file_get_contents('php://input');
if (
$this->logger !== null &&
$this->logger->isHandling(Logger::DEBUG)
) {
$this->logger->addDebug(
'Receive request',
array(
'request' => ctype_print($input) ? $input : 'base64:' . base64_encode($input)
)
);
}
return $input;
}
|
[
"public",
"function",
"receive",
"(",
")",
"{",
"$",
"input",
"=",
"file_get_contents",
"(",
"'php://input'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"logger",
"!==",
"null",
"&&",
"$",
"this",
"->",
"logger",
"->",
"isHandling",
"(",
"Logger",
"::",
"DEBUG",
")",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"addDebug",
"(",
"'Receive request'",
",",
"array",
"(",
"'request'",
"=>",
"ctype_print",
"(",
"$",
"input",
")",
"?",
"$",
"input",
":",
"'base64:'",
".",
"base64_encode",
"(",
"$",
"input",
")",
")",
")",
";",
"}",
"return",
"$",
"input",
";",
"}"
] |
Receive the serialized json request.
@return stdClass
|
[
"Receive",
"the",
"serialized",
"json",
"request",
"."
] |
0a917cdb261d83b1e89bdbdce3627584823bff5f
|
https://github.com/bit3archive/php-remote-objects/blob/0a917cdb261d83b1e89bdbdce3627584823bff5f/src/RemoteObjects/Transport/HttpServer.php#L61-L78
|
24,213
|
PHPPowertools/HTML5
|
src/PowerTools/HTML5/Parser/TreeBuildingRules.php
|
HTML5_Parser_TreeBuildingRules.evaluate
|
public function evaluate($new, $current) {
switch ($new->tagName) {
case 'li':
return $this->handleLI($new, $current);
case 'dt':
case 'dd':
return $this->handleDT($new, $current);
case 'rt':
case 'rp':
return $this->handleRT($new, $current);
case 'optgroup':
return $this->closeIfCurrentMatches($new, $current, array(
'optgroup'
));
case 'option':
return $this->closeIfCurrentMatches($new, $current, array(
'option',
'optgroup'
));
case 'tr':
return $this->closeIfCurrentMatches($new, $current, array(
'tr'
));
case 'td':
case 'th':
return $this->closeIfCurrentMatches($new, $current, array(
'th',
'td'
));
case 'tbody':
case 'thead':
case 'tfoot':
case 'table': // Spec isn't explicit about this, but it's necessary.
return $this->closeIfCurrentMatches($new, $current, array(
'thead',
'tfoot',
'tbody'
));
}
return $current;
}
|
php
|
public function evaluate($new, $current) {
switch ($new->tagName) {
case 'li':
return $this->handleLI($new, $current);
case 'dt':
case 'dd':
return $this->handleDT($new, $current);
case 'rt':
case 'rp':
return $this->handleRT($new, $current);
case 'optgroup':
return $this->closeIfCurrentMatches($new, $current, array(
'optgroup'
));
case 'option':
return $this->closeIfCurrentMatches($new, $current, array(
'option',
'optgroup'
));
case 'tr':
return $this->closeIfCurrentMatches($new, $current, array(
'tr'
));
case 'td':
case 'th':
return $this->closeIfCurrentMatches($new, $current, array(
'th',
'td'
));
case 'tbody':
case 'thead':
case 'tfoot':
case 'table': // Spec isn't explicit about this, but it's necessary.
return $this->closeIfCurrentMatches($new, $current, array(
'thead',
'tfoot',
'tbody'
));
}
return $current;
}
|
[
"public",
"function",
"evaluate",
"(",
"$",
"new",
",",
"$",
"current",
")",
"{",
"switch",
"(",
"$",
"new",
"->",
"tagName",
")",
"{",
"case",
"'li'",
":",
"return",
"$",
"this",
"->",
"handleLI",
"(",
"$",
"new",
",",
"$",
"current",
")",
";",
"case",
"'dt'",
":",
"case",
"'dd'",
":",
"return",
"$",
"this",
"->",
"handleDT",
"(",
"$",
"new",
",",
"$",
"current",
")",
";",
"case",
"'rt'",
":",
"case",
"'rp'",
":",
"return",
"$",
"this",
"->",
"handleRT",
"(",
"$",
"new",
",",
"$",
"current",
")",
";",
"case",
"'optgroup'",
":",
"return",
"$",
"this",
"->",
"closeIfCurrentMatches",
"(",
"$",
"new",
",",
"$",
"current",
",",
"array",
"(",
"'optgroup'",
")",
")",
";",
"case",
"'option'",
":",
"return",
"$",
"this",
"->",
"closeIfCurrentMatches",
"(",
"$",
"new",
",",
"$",
"current",
",",
"array",
"(",
"'option'",
",",
"'optgroup'",
")",
")",
";",
"case",
"'tr'",
":",
"return",
"$",
"this",
"->",
"closeIfCurrentMatches",
"(",
"$",
"new",
",",
"$",
"current",
",",
"array",
"(",
"'tr'",
")",
")",
";",
"case",
"'td'",
":",
"case",
"'th'",
":",
"return",
"$",
"this",
"->",
"closeIfCurrentMatches",
"(",
"$",
"new",
",",
"$",
"current",
",",
"array",
"(",
"'th'",
",",
"'td'",
")",
")",
";",
"case",
"'tbody'",
":",
"case",
"'thead'",
":",
"case",
"'tfoot'",
":",
"case",
"'table'",
":",
"// Spec isn't explicit about this, but it's necessary.",
"return",
"$",
"this",
"->",
"closeIfCurrentMatches",
"(",
"$",
"new",
",",
"$",
"current",
",",
"array",
"(",
"'thead'",
",",
"'tfoot'",
",",
"'tbody'",
")",
")",
";",
"}",
"return",
"$",
"current",
";",
"}"
] |
Evaluate the rule for the current tag name.
This may modify the existing DOM.
@return \DOMElement The new Current DOM element.
|
[
"Evaluate",
"the",
"rule",
"for",
"the",
"current",
"tag",
"name",
"."
] |
4ea8caf5b2618a82ca5061dcbb7421b31065c1c7
|
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Parser/TreeBuildingRules.php#L142-L184
|
24,214
|
heidelpay/PhpDoc
|
src/phpDocumentor/Command/Phar/UpdateCommand.php
|
UpdateCommand.createManager
|
private function createManager(OutputInterface $output)
{
try {
return new Manager(Manifest::loadFile(self::MANIFEST_FILE));
} catch (FileException $e) {
$output->writeln('<error>Unable to search for updates.</error>');
exit(1);
}
}
|
php
|
private function createManager(OutputInterface $output)
{
try {
return new Manager(Manifest::loadFile(self::MANIFEST_FILE));
} catch (FileException $e) {
$output->writeln('<error>Unable to search for updates.</error>');
exit(1);
}
}
|
[
"private",
"function",
"createManager",
"(",
"OutputInterface",
"$",
"output",
")",
"{",
"try",
"{",
"return",
"new",
"Manager",
"(",
"Manifest",
"::",
"loadFile",
"(",
"self",
"::",
"MANIFEST_FILE",
")",
")",
";",
"}",
"catch",
"(",
"FileException",
"$",
"e",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"'<error>Unable to search for updates.</error>'",
")",
";",
"exit",
"(",
"1",
")",
";",
"}",
"}"
] |
Returns manager instance or exit with status code 1 on failure.
@param OutputInterface $output
@return \Herrera\Phar\Update\Manager
|
[
"Returns",
"manager",
"instance",
"or",
"exit",
"with",
"status",
"code",
"1",
"on",
"failure",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Command/Phar/UpdateCommand.php#L89-L98
|
24,215
|
heidelpay/PhpDoc
|
src/phpDocumentor/Command/Phar/UpdateCommand.php
|
UpdateCommand.updateCurrentVersion
|
private function updateCurrentVersion(
Manager $manager,
$version,
$allowMajor,
$allowPreRelease,
OutputInterface $output
) {
if ($manager->update($version, $allowMajor, $allowPreRelease)) {
$output->writeln('<info>Updated to latest version.</info>');
} else {
$output->writeln('<comment>Already up-to-date.</comment>');
}
}
|
php
|
private function updateCurrentVersion(
Manager $manager,
$version,
$allowMajor,
$allowPreRelease,
OutputInterface $output
) {
if ($manager->update($version, $allowMajor, $allowPreRelease)) {
$output->writeln('<info>Updated to latest version.</info>');
} else {
$output->writeln('<comment>Already up-to-date.</comment>');
}
}
|
[
"private",
"function",
"updateCurrentVersion",
"(",
"Manager",
"$",
"manager",
",",
"$",
"version",
",",
"$",
"allowMajor",
",",
"$",
"allowPreRelease",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"if",
"(",
"$",
"manager",
"->",
"update",
"(",
"$",
"version",
",",
"$",
"allowMajor",
",",
"$",
"allowPreRelease",
")",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"'<info>Updated to latest version.</info>'",
")",
";",
"}",
"else",
"{",
"$",
"output",
"->",
"writeln",
"(",
"'<comment>Already up-to-date.</comment>'",
")",
";",
"}",
"}"
] |
Updates current version.
@param Manager $manager
@param string $version
@param bool|null $allowMajor
@param bool|null $allowPreRelease
@param OutputInterface $output
@return void
|
[
"Updates",
"current",
"version",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Command/Phar/UpdateCommand.php#L111-L123
|
24,216
|
nabab/bbn
|
src/bbn/html/input.php
|
input.html_with_label
|
public function html_with_label($with_script=1)
{
$s = $this->html();
if ( !empty($s) ){
if ( BBN_IS_DEV ){
$title = str_replace('"', '', print_r (bbn\str::make_readable($this->cfg), true));
}
else if ( isset($this->attr['title']) ){
$title = $this->attr['title'];
}
else{
$title = isset($this->label) ? $this->label : '';
}
if ( !isset($this->cfg['field']) || $this->cfg['field'] !== 'hidden' ){
$s = '<label class="bbn-form-label" title="'.$title.'" for="'.$this->attr['id'].'">'.$this->label.'</label><div class="bbn-form-field">'.$s.'</div>';
}
}
return $s;
}
|
php
|
public function html_with_label($with_script=1)
{
$s = $this->html();
if ( !empty($s) ){
if ( BBN_IS_DEV ){
$title = str_replace('"', '', print_r (bbn\str::make_readable($this->cfg), true));
}
else if ( isset($this->attr['title']) ){
$title = $this->attr['title'];
}
else{
$title = isset($this->label) ? $this->label : '';
}
if ( !isset($this->cfg['field']) || $this->cfg['field'] !== 'hidden' ){
$s = '<label class="bbn-form-label" title="'.$title.'" for="'.$this->attr['id'].'">'.$this->label.'</label><div class="bbn-form-field">'.$s.'</div>';
}
}
return $s;
}
|
[
"public",
"function",
"html_with_label",
"(",
"$",
"with_script",
"=",
"1",
")",
"{",
"$",
"s",
"=",
"$",
"this",
"->",
"html",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"s",
")",
")",
"{",
"if",
"(",
"BBN_IS_DEV",
")",
"{",
"$",
"title",
"=",
"str_replace",
"(",
"'\"'",
",",
"''",
",",
"print_r",
"(",
"bbn",
"\\",
"str",
"::",
"make_readable",
"(",
"$",
"this",
"->",
"cfg",
")",
",",
"true",
")",
")",
";",
"}",
"else",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"attr",
"[",
"'title'",
"]",
")",
")",
"{",
"$",
"title",
"=",
"$",
"this",
"->",
"attr",
"[",
"'title'",
"]",
";",
"}",
"else",
"{",
"$",
"title",
"=",
"isset",
"(",
"$",
"this",
"->",
"label",
")",
"?",
"$",
"this",
"->",
"label",
":",
"''",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"cfg",
"[",
"'field'",
"]",
")",
"||",
"$",
"this",
"->",
"cfg",
"[",
"'field'",
"]",
"!==",
"'hidden'",
")",
"{",
"$",
"s",
"=",
"'<label class=\"bbn-form-label\" title=\"'",
".",
"$",
"title",
".",
"'\" for=\"'",
".",
"$",
"this",
"->",
"attr",
"[",
"'id'",
"]",
".",
"'\">'",
".",
"$",
"this",
"->",
"label",
".",
"'</label><div class=\"bbn-form-field\">'",
".",
"$",
"s",
".",
"'</div>'",
";",
"}",
"}",
"return",
"$",
"s",
";",
"}"
] |
Returns the element with its label and inside a div
@return string
|
[
"Returns",
"the",
"element",
"with",
"its",
"label",
"and",
"inside",
"a",
"div"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/html/input.php#L203-L221
|
24,217
|
mvccore/ext-router-module
|
src/MvcCore/Ext/Routers/Module/DomainRouting.php
|
DomainRouting.domainRouting
|
protected function domainRouting () {
$request = & $this->request;
if ($this->routeGetRequestsOnly) {
$selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__;
trigger_error("[".$selfClass."] Routing only GET requests with special media "
."site version or localization conditions is not allowed in module router.",
E_USER_WARNING);
$this->routeGetRequestsOnly = FALSE;
}
/** @var $route \MvcCore\Ext\Routers\Modules\Route */
$allMatchedParams = [];
foreach ($this->domainRoutes as & $route) {
$allMatchedParams = $route->Matches($request);
if ($allMatchedParams !== NULL) {
$this->currentDomainRoute = clone $route;
$this->currentModule = $this->currentDomainRoute->GetModule();
$this->currentDomainRoute->SetMatchedParams($allMatchedParams);
$this->domainRoutingSetRequestedAndDefaultParams($allMatchedParams);
$break = $this->domainRoutingFilterParams($allMatchedParams);
$this->domainRoutingSetUpRouterByDomainRoute();
if ($break) break;
}
}
}
|
php
|
protected function domainRouting () {
$request = & $this->request;
if ($this->routeGetRequestsOnly) {
$selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__;
trigger_error("[".$selfClass."] Routing only GET requests with special media "
."site version or localization conditions is not allowed in module router.",
E_USER_WARNING);
$this->routeGetRequestsOnly = FALSE;
}
/** @var $route \MvcCore\Ext\Routers\Modules\Route */
$allMatchedParams = [];
foreach ($this->domainRoutes as & $route) {
$allMatchedParams = $route->Matches($request);
if ($allMatchedParams !== NULL) {
$this->currentDomainRoute = clone $route;
$this->currentModule = $this->currentDomainRoute->GetModule();
$this->currentDomainRoute->SetMatchedParams($allMatchedParams);
$this->domainRoutingSetRequestedAndDefaultParams($allMatchedParams);
$break = $this->domainRoutingFilterParams($allMatchedParams);
$this->domainRoutingSetUpRouterByDomainRoute();
if ($break) break;
}
}
}
|
[
"protected",
"function",
"domainRouting",
"(",
")",
"{",
"$",
"request",
"=",
"&",
"$",
"this",
"->",
"request",
";",
"if",
"(",
"$",
"this",
"->",
"routeGetRequestsOnly",
")",
"{",
"$",
"selfClass",
"=",
"version_compare",
"(",
"PHP_VERSION",
",",
"'5.5'",
",",
"'>'",
")",
"?",
"self",
"::",
"class",
":",
"__CLASS__",
";",
"trigger_error",
"(",
"\"[\"",
".",
"$",
"selfClass",
".",
"\"] Routing only GET requests with special media \"",
".",
"\"site version or localization conditions is not allowed in module router.\"",
",",
"E_USER_WARNING",
")",
";",
"$",
"this",
"->",
"routeGetRequestsOnly",
"=",
"FALSE",
";",
"}",
"/** @var $route \\MvcCore\\Ext\\Routers\\Modules\\Route */",
"$",
"allMatchedParams",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"domainRoutes",
"as",
"&",
"$",
"route",
")",
"{",
"$",
"allMatchedParams",
"=",
"$",
"route",
"->",
"Matches",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"allMatchedParams",
"!==",
"NULL",
")",
"{",
"$",
"this",
"->",
"currentDomainRoute",
"=",
"clone",
"$",
"route",
";",
"$",
"this",
"->",
"currentModule",
"=",
"$",
"this",
"->",
"currentDomainRoute",
"->",
"GetModule",
"(",
")",
";",
"$",
"this",
"->",
"currentDomainRoute",
"->",
"SetMatchedParams",
"(",
"$",
"allMatchedParams",
")",
";",
"$",
"this",
"->",
"domainRoutingSetRequestedAndDefaultParams",
"(",
"$",
"allMatchedParams",
")",
";",
"$",
"break",
"=",
"$",
"this",
"->",
"domainRoutingFilterParams",
"(",
"$",
"allMatchedParams",
")",
";",
"$",
"this",
"->",
"domainRoutingSetUpRouterByDomainRoute",
"(",
")",
";",
"if",
"(",
"$",
"break",
")",
"break",
";",
"}",
"}",
"}"
] |
Process routing by defined module domain routes. If any module domain
route matches the request, complete current domain route property and
current domain module property and set up requested domain params and
default domain params by matched domain route params.
@throws \LogicException Route configuration property is missing.
@throws \InvalidArgumentException Wrong route pattern format.
@return void
|
[
"Process",
"routing",
"by",
"defined",
"module",
"domain",
"routes",
".",
"If",
"any",
"module",
"domain",
"route",
"matches",
"the",
"request",
"complete",
"current",
"domain",
"route",
"property",
"and",
"current",
"domain",
"module",
"property",
"and",
"set",
"up",
"requested",
"domain",
"params",
"and",
"default",
"domain",
"params",
"by",
"matched",
"domain",
"route",
"params",
"."
] |
7695784a451db86cca6a43c98d076803cd0a50a7
|
https://github.com/mvccore/ext-router-module/blob/7695784a451db86cca6a43c98d076803cd0a50a7/src/MvcCore/Ext/Routers/Module/DomainRouting.php#L27-L50
|
24,218
|
mikebarlow/html-helper
|
src/Services/CometPHP/Router.php
|
Router.getUrl
|
public function getUrl($url)
{
if (is_array($url) && ! empty($url['route'])) {
try {
$Comet = \CometPHP\Comet::getInstance();
} catch (\CometPHP\Exceptions\CometNotBooted $e) {
return null;
}
$routeName = $url['route'];
unset($url['route']);
$generatedUrl = $Comet['routeGenerator']->generate(
$routeName,
$url
);
return $generatedUrl;
}
return $url;
}
|
php
|
public function getUrl($url)
{
if (is_array($url) && ! empty($url['route'])) {
try {
$Comet = \CometPHP\Comet::getInstance();
} catch (\CometPHP\Exceptions\CometNotBooted $e) {
return null;
}
$routeName = $url['route'];
unset($url['route']);
$generatedUrl = $Comet['routeGenerator']->generate(
$routeName,
$url
);
return $generatedUrl;
}
return $url;
}
|
[
"public",
"function",
"getUrl",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"url",
")",
"&&",
"!",
"empty",
"(",
"$",
"url",
"[",
"'route'",
"]",
")",
")",
"{",
"try",
"{",
"$",
"Comet",
"=",
"\\",
"CometPHP",
"\\",
"Comet",
"::",
"getInstance",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"CometPHP",
"\\",
"Exceptions",
"\\",
"CometNotBooted",
"$",
"e",
")",
"{",
"return",
"null",
";",
"}",
"$",
"routeName",
"=",
"$",
"url",
"[",
"'route'",
"]",
";",
"unset",
"(",
"$",
"url",
"[",
"'route'",
"]",
")",
";",
"$",
"generatedUrl",
"=",
"$",
"Comet",
"[",
"'routeGenerator'",
"]",
"->",
"generate",
"(",
"$",
"routeName",
",",
"$",
"url",
")",
";",
"return",
"$",
"generatedUrl",
";",
"}",
"return",
"$",
"url",
";",
"}"
] |
base function to return the url for the link method
@param mixed url data received from the link method
@return string url to pass to href
|
[
"base",
"function",
"to",
"return",
"the",
"url",
"for",
"the",
"link",
"method"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Services/CometPHP/Router.php#L13-L34
|
24,219
|
hametuha/wpametu
|
src/WPametu/Assets/Library.php
|
Library.build_src
|
private function build_src( $src ) {
if ( ! preg_match( '/^(https?:)?\/\//u', $src ) ) {
// O.K. This is a library in WPametu!
$src = trailingslashit( $this->get_root_uri() ) . ltrim( $src, '/' );
}
return $src;
}
|
php
|
private function build_src( $src ) {
if ( ! preg_match( '/^(https?:)?\/\//u', $src ) ) {
// O.K. This is a library in WPametu!
$src = trailingslashit( $this->get_root_uri() ) . ltrim( $src, '/' );
}
return $src;
}
|
[
"private",
"function",
"build_src",
"(",
"$",
"src",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/^(https?:)?\\/\\//u'",
",",
"$",
"src",
")",
")",
"{",
"// O.K. This is a library in WPametu!",
"$",
"src",
"=",
"trailingslashit",
"(",
"$",
"this",
"->",
"get_root_uri",
"(",
")",
")",
".",
"ltrim",
"(",
"$",
"src",
",",
"'/'",
")",
";",
"}",
"return",
"$",
"src",
";",
"}"
] |
Build URL for library
@param string $src
@return string
|
[
"Build",
"URL",
"for",
"library"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Assets/Library.php#L189-L196
|
24,220
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Template/String.php
|
Dwoo_Template_String.getCachedTemplate
|
public function getCachedTemplate(Dwoo $dwoo)
{
if ($this->cacheTime !== null) {
$cacheLength = $this->cacheTime;
} else {
$cacheLength = $dwoo->getCacheTime();
}
// file is not cacheable
if ($cacheLength === 0) {
return false;
}
$cachedFile = $this->getCacheFilename($dwoo);
if (isset(self::$cache['cached'][$this->cacheId]) === true && file_exists($cachedFile)) {
// already checked, return cache file
return $cachedFile;
} elseif ($this->compilationEnforced !== true && file_exists($cachedFile) && ($cacheLength === -1 || filemtime($cachedFile) > ($_SERVER['REQUEST_TIME'] - $cacheLength)) && $this->isValidCompiledFile($this->getCompiledFilename($dwoo))) {
// cache is still valid and can be loaded
self::$cache['cached'][$this->cacheId] = true;
return $cachedFile;
} else {
// file is cacheable
return true;
}
}
|
php
|
public function getCachedTemplate(Dwoo $dwoo)
{
if ($this->cacheTime !== null) {
$cacheLength = $this->cacheTime;
} else {
$cacheLength = $dwoo->getCacheTime();
}
// file is not cacheable
if ($cacheLength === 0) {
return false;
}
$cachedFile = $this->getCacheFilename($dwoo);
if (isset(self::$cache['cached'][$this->cacheId]) === true && file_exists($cachedFile)) {
// already checked, return cache file
return $cachedFile;
} elseif ($this->compilationEnforced !== true && file_exists($cachedFile) && ($cacheLength === -1 || filemtime($cachedFile) > ($_SERVER['REQUEST_TIME'] - $cacheLength)) && $this->isValidCompiledFile($this->getCompiledFilename($dwoo))) {
// cache is still valid and can be loaded
self::$cache['cached'][$this->cacheId] = true;
return $cachedFile;
} else {
// file is cacheable
return true;
}
}
|
[
"public",
"function",
"getCachedTemplate",
"(",
"Dwoo",
"$",
"dwoo",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cacheTime",
"!==",
"null",
")",
"{",
"$",
"cacheLength",
"=",
"$",
"this",
"->",
"cacheTime",
";",
"}",
"else",
"{",
"$",
"cacheLength",
"=",
"$",
"dwoo",
"->",
"getCacheTime",
"(",
")",
";",
"}",
"// file is not cacheable",
"if",
"(",
"$",
"cacheLength",
"===",
"0",
")",
"{",
"return",
"false",
";",
"}",
"$",
"cachedFile",
"=",
"$",
"this",
"->",
"getCacheFilename",
"(",
"$",
"dwoo",
")",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"cache",
"[",
"'cached'",
"]",
"[",
"$",
"this",
"->",
"cacheId",
"]",
")",
"===",
"true",
"&&",
"file_exists",
"(",
"$",
"cachedFile",
")",
")",
"{",
"// already checked, return cache file",
"return",
"$",
"cachedFile",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"compilationEnforced",
"!==",
"true",
"&&",
"file_exists",
"(",
"$",
"cachedFile",
")",
"&&",
"(",
"$",
"cacheLength",
"===",
"-",
"1",
"||",
"filemtime",
"(",
"$",
"cachedFile",
")",
">",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_TIME'",
"]",
"-",
"$",
"cacheLength",
")",
")",
"&&",
"$",
"this",
"->",
"isValidCompiledFile",
"(",
"$",
"this",
"->",
"getCompiledFilename",
"(",
"$",
"dwoo",
")",
")",
")",
"{",
"// cache is still valid and can be loaded",
"self",
"::",
"$",
"cache",
"[",
"'cached'",
"]",
"[",
"$",
"this",
"->",
"cacheId",
"]",
"=",
"true",
";",
"return",
"$",
"cachedFile",
";",
"}",
"else",
"{",
"// file is cacheable",
"return",
"true",
";",
"}",
"}"
] |
returns the cached template output file name, true if it's cache-able but not cached
or false if it's not cached
@param Dwoo $dwoo the dwoo instance that requests it
@return string|bool
|
[
"returns",
"the",
"cached",
"template",
"output",
"file",
"name",
"true",
"if",
"it",
"s",
"cache",
"-",
"able",
"but",
"not",
"cached",
"or",
"false",
"if",
"it",
"s",
"not",
"cached"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Template/String.php#L248-L274
|
24,221
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Template/String.php
|
Dwoo_Template_String.cache
|
public function cache(Dwoo $dwoo, $output)
{
$cacheDir = $dwoo->getCacheDir();
$cachedFile = $this->getCacheFilename($dwoo);
// the code below is courtesy of Rasmus Schultz,
// thanks for his help on avoiding concurency issues
$temp = tempnam($cacheDir, 'temp');
if (!($file = @fopen($temp, 'wb'))) {
$temp = $cacheDir . uniqid('temp');
if (!($file = @fopen($temp, 'wb'))) {
trigger_error('Error writing temporary file \''.$temp.'\'', E_USER_WARNING);
return false;
}
}
fwrite($file, $output);
fclose($file);
$this->makeDirectory(dirname($cachedFile), $cacheDir);
if (!@rename($temp, $cachedFile)) {
@unlink($cachedFile);
@rename($temp, $cachedFile);
}
if ($this->chmod !== null) {
chmod($cachedFile, $this->chmod);
}
self::$cache['cached'][$this->cacheId] = true;
return $cachedFile;
}
|
php
|
public function cache(Dwoo $dwoo, $output)
{
$cacheDir = $dwoo->getCacheDir();
$cachedFile = $this->getCacheFilename($dwoo);
// the code below is courtesy of Rasmus Schultz,
// thanks for his help on avoiding concurency issues
$temp = tempnam($cacheDir, 'temp');
if (!($file = @fopen($temp, 'wb'))) {
$temp = $cacheDir . uniqid('temp');
if (!($file = @fopen($temp, 'wb'))) {
trigger_error('Error writing temporary file \''.$temp.'\'', E_USER_WARNING);
return false;
}
}
fwrite($file, $output);
fclose($file);
$this->makeDirectory(dirname($cachedFile), $cacheDir);
if (!@rename($temp, $cachedFile)) {
@unlink($cachedFile);
@rename($temp, $cachedFile);
}
if ($this->chmod !== null) {
chmod($cachedFile, $this->chmod);
}
self::$cache['cached'][$this->cacheId] = true;
return $cachedFile;
}
|
[
"public",
"function",
"cache",
"(",
"Dwoo",
"$",
"dwoo",
",",
"$",
"output",
")",
"{",
"$",
"cacheDir",
"=",
"$",
"dwoo",
"->",
"getCacheDir",
"(",
")",
";",
"$",
"cachedFile",
"=",
"$",
"this",
"->",
"getCacheFilename",
"(",
"$",
"dwoo",
")",
";",
"// the code below is courtesy of Rasmus Schultz,",
"// thanks for his help on avoiding concurency issues",
"$",
"temp",
"=",
"tempnam",
"(",
"$",
"cacheDir",
",",
"'temp'",
")",
";",
"if",
"(",
"!",
"(",
"$",
"file",
"=",
"@",
"fopen",
"(",
"$",
"temp",
",",
"'wb'",
")",
")",
")",
"{",
"$",
"temp",
"=",
"$",
"cacheDir",
".",
"uniqid",
"(",
"'temp'",
")",
";",
"if",
"(",
"!",
"(",
"$",
"file",
"=",
"@",
"fopen",
"(",
"$",
"temp",
",",
"'wb'",
")",
")",
")",
"{",
"trigger_error",
"(",
"'Error writing temporary file \\''",
".",
"$",
"temp",
".",
"'\\''",
",",
"E_USER_WARNING",
")",
";",
"return",
"false",
";",
"}",
"}",
"fwrite",
"(",
"$",
"file",
",",
"$",
"output",
")",
";",
"fclose",
"(",
"$",
"file",
")",
";",
"$",
"this",
"->",
"makeDirectory",
"(",
"dirname",
"(",
"$",
"cachedFile",
")",
",",
"$",
"cacheDir",
")",
";",
"if",
"(",
"!",
"@",
"rename",
"(",
"$",
"temp",
",",
"$",
"cachedFile",
")",
")",
"{",
"@",
"unlink",
"(",
"$",
"cachedFile",
")",
";",
"@",
"rename",
"(",
"$",
"temp",
",",
"$",
"cachedFile",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"chmod",
"!==",
"null",
")",
"{",
"chmod",
"(",
"$",
"cachedFile",
",",
"$",
"this",
"->",
"chmod",
")",
";",
"}",
"self",
"::",
"$",
"cache",
"[",
"'cached'",
"]",
"[",
"$",
"this",
"->",
"cacheId",
"]",
"=",
"true",
";",
"return",
"$",
"cachedFile",
";",
"}"
] |
caches the provided output into the cache file
@param Dwoo $dwoo the dwoo instance that requests it
@param string $output the template output
@return mixed full path of the cached file or false upon failure
|
[
"caches",
"the",
"provided",
"output",
"into",
"the",
"cache",
"file"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Template/String.php#L283-L315
|
24,222
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Template/String.php
|
Dwoo_Template_String.clearCache
|
public function clearCache(Dwoo $dwoo, $olderThan = -1)
{
$cachedFile = $this->getCacheFilename($dwoo);
return !file_exists($cachedFile) || (filectime($cachedFile) < (time() - $olderThan) && unlink($cachedFile));
}
|
php
|
public function clearCache(Dwoo $dwoo, $olderThan = -1)
{
$cachedFile = $this->getCacheFilename($dwoo);
return !file_exists($cachedFile) || (filectime($cachedFile) < (time() - $olderThan) && unlink($cachedFile));
}
|
[
"public",
"function",
"clearCache",
"(",
"Dwoo",
"$",
"dwoo",
",",
"$",
"olderThan",
"=",
"-",
"1",
")",
"{",
"$",
"cachedFile",
"=",
"$",
"this",
"->",
"getCacheFilename",
"(",
"$",
"dwoo",
")",
";",
"return",
"!",
"file_exists",
"(",
"$",
"cachedFile",
")",
"||",
"(",
"filectime",
"(",
"$",
"cachedFile",
")",
"<",
"(",
"time",
"(",
")",
"-",
"$",
"olderThan",
")",
"&&",
"unlink",
"(",
"$",
"cachedFile",
")",
")",
";",
"}"
] |
clears the cached template if it's older than the given time
@param Dwoo $dwoo the dwoo instance that was used to cache that template
@param int $olderThan minimum time (in seconds) required for the cache to be cleared
@return bool true if the cache was not present or if it was deleted, false if it remains there
|
[
"clears",
"the",
"cached",
"template",
"if",
"it",
"s",
"older",
"than",
"the",
"given",
"time"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Template/String.php#L324-L329
|
24,223
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Template/String.php
|
Dwoo_Template_String.getCompiledTemplate
|
public function getCompiledTemplate(Dwoo $dwoo, Dwoo_ICompiler $compiler = null)
{
$compiledFile = $this->getCompiledFilename($dwoo);
if ($this->compilationEnforced !== true && isset(self::$cache['compiled'][$this->compileId]) === true) {
// already checked, return compiled file
} elseif ($this->compilationEnforced !== true && $this->isValidCompiledFile($compiledFile)) {
// template is compiled
self::$cache['compiled'][$this->compileId] = true;
} else {
// compiles the template
$this->compilationEnforced = false;
if ($compiler === null) {
$compiler = $dwoo->getDefaultCompilerFactory($this->getResourceName());
if ($compiler === null || $compiler === array('Dwoo_Compiler', 'compilerFactory')) {
if (class_exists('Dwoo_Compiler', false) === false) {
include DWOO_DIRECTORY . 'Dwoo/Compiler.php';
}
$compiler = Dwoo_Compiler::compilerFactory();
} else {
$compiler = call_user_func($compiler);
}
}
$this->compiler = $compiler;
$compiler->setCustomPlugins($dwoo->getCustomPlugins());
$compiler->setSecurityPolicy($dwoo->getSecurityPolicy());
$this->makeDirectory(dirname($compiledFile), $dwoo->getCompileDir());
file_put_contents($compiledFile, $compiler->compile($dwoo, $this));
if ($this->chmod !== null) {
chmod($compiledFile, $this->chmod);
}
self::$cache['compiled'][$this->compileId] = true;
}
return $compiledFile;
}
|
php
|
public function getCompiledTemplate(Dwoo $dwoo, Dwoo_ICompiler $compiler = null)
{
$compiledFile = $this->getCompiledFilename($dwoo);
if ($this->compilationEnforced !== true && isset(self::$cache['compiled'][$this->compileId]) === true) {
// already checked, return compiled file
} elseif ($this->compilationEnforced !== true && $this->isValidCompiledFile($compiledFile)) {
// template is compiled
self::$cache['compiled'][$this->compileId] = true;
} else {
// compiles the template
$this->compilationEnforced = false;
if ($compiler === null) {
$compiler = $dwoo->getDefaultCompilerFactory($this->getResourceName());
if ($compiler === null || $compiler === array('Dwoo_Compiler', 'compilerFactory')) {
if (class_exists('Dwoo_Compiler', false) === false) {
include DWOO_DIRECTORY . 'Dwoo/Compiler.php';
}
$compiler = Dwoo_Compiler::compilerFactory();
} else {
$compiler = call_user_func($compiler);
}
}
$this->compiler = $compiler;
$compiler->setCustomPlugins($dwoo->getCustomPlugins());
$compiler->setSecurityPolicy($dwoo->getSecurityPolicy());
$this->makeDirectory(dirname($compiledFile), $dwoo->getCompileDir());
file_put_contents($compiledFile, $compiler->compile($dwoo, $this));
if ($this->chmod !== null) {
chmod($compiledFile, $this->chmod);
}
self::$cache['compiled'][$this->compileId] = true;
}
return $compiledFile;
}
|
[
"public",
"function",
"getCompiledTemplate",
"(",
"Dwoo",
"$",
"dwoo",
",",
"Dwoo_ICompiler",
"$",
"compiler",
"=",
"null",
")",
"{",
"$",
"compiledFile",
"=",
"$",
"this",
"->",
"getCompiledFilename",
"(",
"$",
"dwoo",
")",
";",
"if",
"(",
"$",
"this",
"->",
"compilationEnforced",
"!==",
"true",
"&&",
"isset",
"(",
"self",
"::",
"$",
"cache",
"[",
"'compiled'",
"]",
"[",
"$",
"this",
"->",
"compileId",
"]",
")",
"===",
"true",
")",
"{",
"// already checked, return compiled file",
"}",
"elseif",
"(",
"$",
"this",
"->",
"compilationEnforced",
"!==",
"true",
"&&",
"$",
"this",
"->",
"isValidCompiledFile",
"(",
"$",
"compiledFile",
")",
")",
"{",
"// template is compiled",
"self",
"::",
"$",
"cache",
"[",
"'compiled'",
"]",
"[",
"$",
"this",
"->",
"compileId",
"]",
"=",
"true",
";",
"}",
"else",
"{",
"// compiles the template",
"$",
"this",
"->",
"compilationEnforced",
"=",
"false",
";",
"if",
"(",
"$",
"compiler",
"===",
"null",
")",
"{",
"$",
"compiler",
"=",
"$",
"dwoo",
"->",
"getDefaultCompilerFactory",
"(",
"$",
"this",
"->",
"getResourceName",
"(",
")",
")",
";",
"if",
"(",
"$",
"compiler",
"===",
"null",
"||",
"$",
"compiler",
"===",
"array",
"(",
"'Dwoo_Compiler'",
",",
"'compilerFactory'",
")",
")",
"{",
"if",
"(",
"class_exists",
"(",
"'Dwoo_Compiler'",
",",
"false",
")",
"===",
"false",
")",
"{",
"include",
"DWOO_DIRECTORY",
".",
"'Dwoo/Compiler.php'",
";",
"}",
"$",
"compiler",
"=",
"Dwoo_Compiler",
"::",
"compilerFactory",
"(",
")",
";",
"}",
"else",
"{",
"$",
"compiler",
"=",
"call_user_func",
"(",
"$",
"compiler",
")",
";",
"}",
"}",
"$",
"this",
"->",
"compiler",
"=",
"$",
"compiler",
";",
"$",
"compiler",
"->",
"setCustomPlugins",
"(",
"$",
"dwoo",
"->",
"getCustomPlugins",
"(",
")",
")",
";",
"$",
"compiler",
"->",
"setSecurityPolicy",
"(",
"$",
"dwoo",
"->",
"getSecurityPolicy",
"(",
")",
")",
";",
"$",
"this",
"->",
"makeDirectory",
"(",
"dirname",
"(",
"$",
"compiledFile",
")",
",",
"$",
"dwoo",
"->",
"getCompileDir",
"(",
")",
")",
";",
"file_put_contents",
"(",
"$",
"compiledFile",
",",
"$",
"compiler",
"->",
"compile",
"(",
"$",
"dwoo",
",",
"$",
"this",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"chmod",
"!==",
"null",
")",
"{",
"chmod",
"(",
"$",
"compiledFile",
",",
"$",
"this",
"->",
"chmod",
")",
";",
"}",
"self",
"::",
"$",
"cache",
"[",
"'compiled'",
"]",
"[",
"$",
"this",
"->",
"compileId",
"]",
"=",
"true",
";",
"}",
"return",
"$",
"compiledFile",
";",
"}"
] |
returns the compiled template file name
@param Dwoo $dwoo the dwoo instance that requests it
@param Dwoo_ICompiler $compiler the compiler that must be used
@return string
|
[
"returns",
"the",
"compiled",
"template",
"file",
"name"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Template/String.php#L338-L378
|
24,224
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Template/String.php
|
Dwoo_Template_String.templateFactory
|
public static function templateFactory(Dwoo $dwoo, $resourceId, $cacheTime = null, $cacheId = null, $compileId = null, Dwoo_ITemplate $parentTemplate = null)
{
return new self($resourceId, $cacheTime, $cacheId, $compileId);
}
|
php
|
public static function templateFactory(Dwoo $dwoo, $resourceId, $cacheTime = null, $cacheId = null, $compileId = null, Dwoo_ITemplate $parentTemplate = null)
{
return new self($resourceId, $cacheTime, $cacheId, $compileId);
}
|
[
"public",
"static",
"function",
"templateFactory",
"(",
"Dwoo",
"$",
"dwoo",
",",
"$",
"resourceId",
",",
"$",
"cacheTime",
"=",
"null",
",",
"$",
"cacheId",
"=",
"null",
",",
"$",
"compileId",
"=",
"null",
",",
"Dwoo_ITemplate",
"$",
"parentTemplate",
"=",
"null",
")",
"{",
"return",
"new",
"self",
"(",
"$",
"resourceId",
",",
"$",
"cacheTime",
",",
"$",
"cacheId",
",",
"$",
"compileId",
")",
";",
"}"
] |
returns a new template string object with the resource id being the template source code
@param Dwoo $dwoo the dwoo instance requiring it
@param mixed $resourceId the filename (relative to this template's dir) of the template to include
@param int $cacheTime duration of the cache validity for this template,
if null it defaults to the Dwoo instance that will
render this template
@param string $cacheId the unique cache identifier of this page or anything else that
makes this template's content unique, if null it defaults
to the current url
@param string $compileId the unique compiled identifier, which is used to distinguish this
template from others, if null it defaults to the filename+bits of the path
@param Dwoo_ITemplate $parentTemplate the template that is requesting a new template object (through
an include, extends or any other plugin)
@return Dwoo_Template_String
|
[
"returns",
"a",
"new",
"template",
"string",
"object",
"with",
"the",
"resource",
"id",
"being",
"the",
"template",
"source",
"code"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Template/String.php#L407-L410
|
24,225
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Template/String.php
|
Dwoo_Template_String.getCacheFilename
|
protected function getCacheFilename(Dwoo $dwoo)
{
// no cache id provided, use request_uri as default
if ($this->cacheId === null) {
if (isset($_SERVER['REQUEST_URI']) === true) {
$cacheId = $_SERVER['REQUEST_URI'];
} elseif (isset($_SERVER['SCRIPT_FILENAME']) && isset($_SERVER['argv'])) {
$cacheId = $_SERVER['SCRIPT_FILENAME'].'-'.implode('-', $_SERVER['argv']);
} else {
$cacheId = '';
}
// force compiled id generation
$this->getCompiledFilename($dwoo);
$this->cacheId = str_replace('../', '__', $this->compileId . strtr($cacheId, '\\%?=!:;'.PATH_SEPARATOR, '/-------'));
}
return $dwoo->getCacheDir() . $this->cacheId.'.html';
}
|
php
|
protected function getCacheFilename(Dwoo $dwoo)
{
// no cache id provided, use request_uri as default
if ($this->cacheId === null) {
if (isset($_SERVER['REQUEST_URI']) === true) {
$cacheId = $_SERVER['REQUEST_URI'];
} elseif (isset($_SERVER['SCRIPT_FILENAME']) && isset($_SERVER['argv'])) {
$cacheId = $_SERVER['SCRIPT_FILENAME'].'-'.implode('-', $_SERVER['argv']);
} else {
$cacheId = '';
}
// force compiled id generation
$this->getCompiledFilename($dwoo);
$this->cacheId = str_replace('../', '__', $this->compileId . strtr($cacheId, '\\%?=!:;'.PATH_SEPARATOR, '/-------'));
}
return $dwoo->getCacheDir() . $this->cacheId.'.html';
}
|
[
"protected",
"function",
"getCacheFilename",
"(",
"Dwoo",
"$",
"dwoo",
")",
"{",
"// no cache id provided, use request_uri as default",
"if",
"(",
"$",
"this",
"->",
"cacheId",
"===",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
")",
"===",
"true",
")",
"{",
"$",
"cacheId",
"=",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'SCRIPT_FILENAME'",
"]",
")",
"&&",
"isset",
"(",
"$",
"_SERVER",
"[",
"'argv'",
"]",
")",
")",
"{",
"$",
"cacheId",
"=",
"$",
"_SERVER",
"[",
"'SCRIPT_FILENAME'",
"]",
".",
"'-'",
".",
"implode",
"(",
"'-'",
",",
"$",
"_SERVER",
"[",
"'argv'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"cacheId",
"=",
"''",
";",
"}",
"// force compiled id generation",
"$",
"this",
"->",
"getCompiledFilename",
"(",
"$",
"dwoo",
")",
";",
"$",
"this",
"->",
"cacheId",
"=",
"str_replace",
"(",
"'../'",
",",
"'__'",
",",
"$",
"this",
"->",
"compileId",
".",
"strtr",
"(",
"$",
"cacheId",
",",
"'\\\\%?=!:;'",
".",
"PATH_SEPARATOR",
",",
"'/-------'",
")",
")",
";",
"}",
"return",
"$",
"dwoo",
"->",
"getCacheDir",
"(",
")",
".",
"$",
"this",
"->",
"cacheId",
".",
"'.html'",
";",
"}"
] |
returns the full cached file name and assigns a default value to it if
required
@param Dwoo $dwoo the dwoo instance that requests the file name
@return string the full path to the cached file
|
[
"returns",
"the",
"full",
"cached",
"file",
"name",
"and",
"assigns",
"a",
"default",
"value",
"to",
"it",
"if",
"required"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Template/String.php#L435-L452
|
24,226
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Template/String.php
|
Dwoo_Template_String.makeDirectory
|
protected function makeDirectory($path, $baseDir = null)
{
if (is_dir($path) === true) {
return;
}
if ($this->chmod === null) {
$chmod = 0777;
} else {
$chmod = $this->chmod;
}
mkdir($path, $chmod, true);
// enforce the correct mode for all directories created
if (strpos(PHP_OS, 'WIN') !== 0 && $baseDir !== null) {
$path = strtr(str_replace($baseDir, '', $path), '\\', '/');
$folders = explode('/', trim($path, '/'));
foreach ($folders as $folder) {
$baseDir .= $folder . DIRECTORY_SEPARATOR;
chmod($baseDir, $chmod);
}
}
}
|
php
|
protected function makeDirectory($path, $baseDir = null)
{
if (is_dir($path) === true) {
return;
}
if ($this->chmod === null) {
$chmod = 0777;
} else {
$chmod = $this->chmod;
}
mkdir($path, $chmod, true);
// enforce the correct mode for all directories created
if (strpos(PHP_OS, 'WIN') !== 0 && $baseDir !== null) {
$path = strtr(str_replace($baseDir, '', $path), '\\', '/');
$folders = explode('/', trim($path, '/'));
foreach ($folders as $folder) {
$baseDir .= $folder . DIRECTORY_SEPARATOR;
chmod($baseDir, $chmod);
}
}
}
|
[
"protected",
"function",
"makeDirectory",
"(",
"$",
"path",
",",
"$",
"baseDir",
"=",
"null",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"path",
")",
"===",
"true",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"chmod",
"===",
"null",
")",
"{",
"$",
"chmod",
"=",
"0777",
";",
"}",
"else",
"{",
"$",
"chmod",
"=",
"$",
"this",
"->",
"chmod",
";",
"}",
"mkdir",
"(",
"$",
"path",
",",
"$",
"chmod",
",",
"true",
")",
";",
"// enforce the correct mode for all directories created",
"if",
"(",
"strpos",
"(",
"PHP_OS",
",",
"'WIN'",
")",
"!==",
"0",
"&&",
"$",
"baseDir",
"!==",
"null",
")",
"{",
"$",
"path",
"=",
"strtr",
"(",
"str_replace",
"(",
"$",
"baseDir",
",",
"''",
",",
"$",
"path",
")",
",",
"'\\\\'",
",",
"'/'",
")",
";",
"$",
"folders",
"=",
"explode",
"(",
"'/'",
",",
"trim",
"(",
"$",
"path",
",",
"'/'",
")",
")",
";",
"foreach",
"(",
"$",
"folders",
"as",
"$",
"folder",
")",
"{",
"$",
"baseDir",
".=",
"$",
"folder",
".",
"DIRECTORY_SEPARATOR",
";",
"chmod",
"(",
"$",
"baseDir",
",",
"$",
"chmod",
")",
";",
"}",
"}",
"}"
] |
ensures the given path exists
@param string $path any path
@param string $baseDir the base directory where the directory is created
($path must still contain the full path, $baseDir
is only used for unix permissions)
|
[
"ensures",
"the",
"given",
"path",
"exists"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Template/String.php#L474-L496
|
24,227
|
bpolaszek/simple-dbal
|
src/Model/Adapter/Mysqli/Result.php
|
Result.resetResultset
|
private function resetResultset()
{
if (null !== $this->stmt) {
$this->stmt->execute();
$this->result = $this->stmt->get_result();
}
}
|
php
|
private function resetResultset()
{
if (null !== $this->stmt) {
$this->stmt->execute();
$this->result = $this->stmt->get_result();
}
}
|
[
"private",
"function",
"resetResultset",
"(",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"stmt",
")",
"{",
"$",
"this",
"->",
"stmt",
"->",
"execute",
"(",
")",
";",
"$",
"this",
"->",
"result",
"=",
"$",
"this",
"->",
"stmt",
"->",
"get_result",
"(",
")",
";",
"}",
"}"
] |
Reset the resultset.
|
[
"Reset",
"the",
"resultset",
"."
] |
52cb50d326ba5854191814b470f5e84950ebb6e6
|
https://github.com/bpolaszek/simple-dbal/blob/52cb50d326ba5854191814b470f5e84950ebb6e6/src/Model/Adapter/Mysqli/Result.php#L226-L232
|
24,228
|
Smile-SA/EzUICronBundle
|
Controller/CronController.php
|
CronController.cronAction
|
public function cronAction($tabItem)
{
$this->performAccessChecks();
return $this->render('SmileEzUICronBundle:cron:index.html.twig', [
'tab_items' => $this->tabItems,
'tab_item_selected' => $tabItem,
'params' => array(),
'hasErrors' => false
]);
}
|
php
|
public function cronAction($tabItem)
{
$this->performAccessChecks();
return $this->render('SmileEzUICronBundle:cron:index.html.twig', [
'tab_items' => $this->tabItems,
'tab_item_selected' => $tabItem,
'params' => array(),
'hasErrors' => false
]);
}
|
[
"public",
"function",
"cronAction",
"(",
"$",
"tabItem",
")",
"{",
"$",
"this",
"->",
"performAccessChecks",
"(",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'SmileEzUICronBundle:cron:index.html.twig'",
",",
"[",
"'tab_items'",
"=>",
"$",
"this",
"->",
"tabItems",
",",
"'tab_item_selected'",
"=>",
"$",
"tabItem",
",",
"'params'",
"=>",
"array",
"(",
")",
",",
"'hasErrors'",
"=>",
"false",
"]",
")",
";",
"}"
] |
Render tab item content
@param string $tabItem tab item name
@return \Symfony\Component\HttpFoundation\Response
|
[
"Render",
"tab",
"item",
"content"
] |
c62fc6a3ab0b39e3f911742d9affe4aade90cf66
|
https://github.com/Smile-SA/EzUICronBundle/blob/c62fc6a3ab0b39e3f911742d9affe4aade90cf66/Controller/CronController.php#L31-L41
|
24,229
|
wenbinye/PhalconX
|
src/Text/LineEditor.php
|
LineEditor.get
|
public function get($line)
{
return isset($this->lines[$line-1]) ? $this->lines[$line-1] : null;
}
|
php
|
public function get($line)
{
return isset($this->lines[$line-1]) ? $this->lines[$line-1] : null;
}
|
[
"public",
"function",
"get",
"(",
"$",
"line",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"lines",
"[",
"$",
"line",
"-",
"1",
"]",
")",
"?",
"$",
"this",
"->",
"lines",
"[",
"$",
"line",
"-",
"1",
"]",
":",
"null",
";",
"}"
] |
Gets content of the line
@return string return null if content deleted
|
[
"Gets",
"content",
"of",
"the",
"line"
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Text/LineEditor.php#L92-L95
|
24,230
|
AOEpeople/Aoe_Layout
|
app/code/local/Aoe/Layout/Block/Widget/Grid/Column/Renderer/Select.php
|
Aoe_Layout_Block_Widget_Grid_Column_Renderer_Select.render
|
public function render(Varien_Object $row)
{
$name = trim($this->getColumn()->getNamePattern());
if (!empty($name)) {
$nameParams = array_map('trim', array_filter(explode(',', $this->getColumn()->getNameParams())));
if (count($nameParams)) {
$params = [$name];
foreach ($nameParams as $key) {
$params[] = $row->getDataUsingMethod($key);
}
$name = call_user_func_array([$this, '__'], $params);
}
$this->getColumn()->setName($name);
}
return parent::render($row);
}
|
php
|
public function render(Varien_Object $row)
{
$name = trim($this->getColumn()->getNamePattern());
if (!empty($name)) {
$nameParams = array_map('trim', array_filter(explode(',', $this->getColumn()->getNameParams())));
if (count($nameParams)) {
$params = [$name];
foreach ($nameParams as $key) {
$params[] = $row->getDataUsingMethod($key);
}
$name = call_user_func_array([$this, '__'], $params);
}
$this->getColumn()->setName($name);
}
return parent::render($row);
}
|
[
"public",
"function",
"render",
"(",
"Varien_Object",
"$",
"row",
")",
"{",
"$",
"name",
"=",
"trim",
"(",
"$",
"this",
"->",
"getColumn",
"(",
")",
"->",
"getNamePattern",
"(",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"$",
"nameParams",
"=",
"array_map",
"(",
"'trim'",
",",
"array_filter",
"(",
"explode",
"(",
"','",
",",
"$",
"this",
"->",
"getColumn",
"(",
")",
"->",
"getNameParams",
"(",
")",
")",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"nameParams",
")",
")",
"{",
"$",
"params",
"=",
"[",
"$",
"name",
"]",
";",
"foreach",
"(",
"$",
"nameParams",
"as",
"$",
"key",
")",
"{",
"$",
"params",
"[",
"]",
"=",
"$",
"row",
"->",
"getDataUsingMethod",
"(",
"$",
"key",
")",
";",
"}",
"$",
"name",
"=",
"call_user_func_array",
"(",
"[",
"$",
"this",
",",
"'__'",
"]",
",",
"$",
"params",
")",
";",
"}",
"$",
"this",
"->",
"getColumn",
"(",
")",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"}",
"return",
"parent",
"::",
"render",
"(",
"$",
"row",
")",
";",
"}"
] |
Renders grid column
@param Varien_Object $row
@return string
|
[
"Renders",
"grid",
"column"
] |
d88ba3406cf12dbaf09548477133c3cb27d155ed
|
https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Block/Widget/Grid/Column/Renderer/Select.php#L12-L29
|
24,231
|
mothership-ec/composer
|
src/Composer/Json/JsonFile.php
|
JsonFile.validateSchema
|
public function validateSchema($schema = self::STRICT_SCHEMA)
{
$content = file_get_contents($this->path);
$data = json_decode($content);
if (null === $data && 'null' !== $content) {
self::validateSyntax($content, $this->path);
}
$schemaFile = __DIR__ . '/../../../res/composer-schema.json';
$schemaData = json_decode(file_get_contents($schemaFile));
if ($schema === self::LAX_SCHEMA) {
$schemaData->additionalProperties = true;
$schemaData->required = array();
}
$validator = new Validator();
$validator->check($data, $schemaData);
// TODO add more validation like check version constraints and such, perhaps build that into the arrayloader?
if (!$validator->isValid()) {
$errors = array();
foreach ((array) $validator->getErrors() as $error) {
$errors[] = ($error['property'] ? $error['property'].' : ' : '').$error['message'];
}
throw new JsonValidationException('"'.$this->path.'" does not match the expected JSON schema', $errors);
}
return true;
}
|
php
|
public function validateSchema($schema = self::STRICT_SCHEMA)
{
$content = file_get_contents($this->path);
$data = json_decode($content);
if (null === $data && 'null' !== $content) {
self::validateSyntax($content, $this->path);
}
$schemaFile = __DIR__ . '/../../../res/composer-schema.json';
$schemaData = json_decode(file_get_contents($schemaFile));
if ($schema === self::LAX_SCHEMA) {
$schemaData->additionalProperties = true;
$schemaData->required = array();
}
$validator = new Validator();
$validator->check($data, $schemaData);
// TODO add more validation like check version constraints and such, perhaps build that into the arrayloader?
if (!$validator->isValid()) {
$errors = array();
foreach ((array) $validator->getErrors() as $error) {
$errors[] = ($error['property'] ? $error['property'].' : ' : '').$error['message'];
}
throw new JsonValidationException('"'.$this->path.'" does not match the expected JSON schema', $errors);
}
return true;
}
|
[
"public",
"function",
"validateSchema",
"(",
"$",
"schema",
"=",
"self",
"::",
"STRICT_SCHEMA",
")",
"{",
"$",
"content",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"path",
")",
";",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"content",
")",
";",
"if",
"(",
"null",
"===",
"$",
"data",
"&&",
"'null'",
"!==",
"$",
"content",
")",
"{",
"self",
"::",
"validateSyntax",
"(",
"$",
"content",
",",
"$",
"this",
"->",
"path",
")",
";",
"}",
"$",
"schemaFile",
"=",
"__DIR__",
".",
"'/../../../res/composer-schema.json'",
";",
"$",
"schemaData",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"$",
"schemaFile",
")",
")",
";",
"if",
"(",
"$",
"schema",
"===",
"self",
"::",
"LAX_SCHEMA",
")",
"{",
"$",
"schemaData",
"->",
"additionalProperties",
"=",
"true",
";",
"$",
"schemaData",
"->",
"required",
"=",
"array",
"(",
")",
";",
"}",
"$",
"validator",
"=",
"new",
"Validator",
"(",
")",
";",
"$",
"validator",
"->",
"check",
"(",
"$",
"data",
",",
"$",
"schemaData",
")",
";",
"// TODO add more validation like check version constraints and such, perhaps build that into the arrayloader?",
"if",
"(",
"!",
"$",
"validator",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"errors",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"validator",
"->",
"getErrors",
"(",
")",
"as",
"$",
"error",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"(",
"$",
"error",
"[",
"'property'",
"]",
"?",
"$",
"error",
"[",
"'property'",
"]",
".",
"' : '",
":",
"''",
")",
".",
"$",
"error",
"[",
"'message'",
"]",
";",
"}",
"throw",
"new",
"JsonValidationException",
"(",
"'\"'",
".",
"$",
"this",
"->",
"path",
".",
"'\" does not match the expected JSON schema'",
",",
"$",
"errors",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Validates the schema of the current json file according to composer-schema.json rules
@param int $schema a JsonFile::*_SCHEMA constant
@return bool true on success
@throws JsonValidationException
|
[
"Validates",
"the",
"schema",
"of",
"the",
"current",
"json",
"file",
"according",
"to",
"composer",
"-",
"schema",
".",
"json",
"rules"
] |
fa6ad031a939d8d33b211e428fdbdd28cfce238c
|
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Json/JsonFile.php#L143-L174
|
24,232
|
mvccore/ext-router-module
|
src/MvcCore/Ext/Routers/Module/PreAndPostRouting.php
|
PreAndPostRouting.routeDetectStrategy
|
protected function routeDetectStrategy () {
list($requestCtrlName, $requestActionName) = parent::routeDetectStrategy();
if (!$this->internalRequest) $this->domainRouting();
return [$requestCtrlName, $requestActionName];
}
|
php
|
protected function routeDetectStrategy () {
list($requestCtrlName, $requestActionName) = parent::routeDetectStrategy();
if (!$this->internalRequest) $this->domainRouting();
return [$requestCtrlName, $requestActionName];
}
|
[
"protected",
"function",
"routeDetectStrategy",
"(",
")",
"{",
"list",
"(",
"$",
"requestCtrlName",
",",
"$",
"requestActionName",
")",
"=",
"parent",
"::",
"routeDetectStrategy",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"internalRequest",
")",
"$",
"this",
"->",
"domainRouting",
"(",
")",
";",
"return",
"[",
"$",
"requestCtrlName",
",",
"$",
"requestActionName",
"]",
";",
"}"
] |
Process normal route strategy detection from core router and than process
domain routing, if request is not internal.
Return array with possible query string controller name and action.
@throws \LogicException Route configuration property is missing.
@throws \InvalidArgumentException Wrong route pattern format.
@return array
|
[
"Process",
"normal",
"route",
"strategy",
"detection",
"from",
"core",
"router",
"and",
"than",
"process",
"domain",
"routing",
"if",
"request",
"is",
"not",
"internal",
".",
"Return",
"array",
"with",
"possible",
"query",
"string",
"controller",
"name",
"and",
"action",
"."
] |
7695784a451db86cca6a43c98d076803cd0a50a7
|
https://github.com/mvccore/ext-router-module/blob/7695784a451db86cca6a43c98d076803cd0a50a7/src/MvcCore/Ext/Routers/Module/PreAndPostRouting.php#L26-L30
|
24,233
|
superjimpupcake/Pupcake
|
src/Pupcake/Router.php
|
Router.routeMatched
|
public function routeMatched($request_type, $route_pattern, $query_path)
{
$matched = $this->app->trigger(
'system.request.route.matching',
array($this, 'processRouteMatching'),
array(
'request_type'=> $request_type,
'query_path' => $query_path,
'route_pattern' => $route_pattern
)
);
return $matched;
}
|
php
|
public function routeMatched($request_type, $route_pattern, $query_path)
{
$matched = $this->app->trigger(
'system.request.route.matching',
array($this, 'processRouteMatching'),
array(
'request_type'=> $request_type,
'query_path' => $query_path,
'route_pattern' => $route_pattern
)
);
return $matched;
}
|
[
"public",
"function",
"routeMatched",
"(",
"$",
"request_type",
",",
"$",
"route_pattern",
",",
"$",
"query_path",
")",
"{",
"$",
"matched",
"=",
"$",
"this",
"->",
"app",
"->",
"trigger",
"(",
"'system.request.route.matching'",
",",
"array",
"(",
"$",
"this",
",",
"'processRouteMatching'",
")",
",",
"array",
"(",
"'request_type'",
"=>",
"$",
"request_type",
",",
"'query_path'",
"=>",
"$",
"query_path",
",",
"'route_pattern'",
"=>",
"$",
"route_pattern",
")",
")",
";",
"return",
"$",
"matched",
";",
"}"
] |
check if a route is matched given a query path
|
[
"check",
"if",
"a",
"route",
"is",
"matched",
"given",
"a",
"query",
"path"
] |
2f962818646e4e1d65f5d008eeb953cb41ebb3e0
|
https://github.com/superjimpupcake/Pupcake/blob/2f962818646e4e1d65f5d008eeb953cb41ebb3e0/src/Pupcake/Router.php#L86-L99
|
24,234
|
superjimpupcake/Pupcake
|
src/Pupcake/Router.php
|
Router.findMatchedRoute
|
public function findMatchedRoute($request_method = "", $query_path = "", $route_map)
{
$query_path = $this->normalize($query_path);
$request_matched = false;
$output = "";
if (count($route_map) > 0) {
$request_types = array_keys($route_map);
$request_types_to_lookup = array();
foreach ($request_types as $request_type) {
if ($request_type == $request_method || $request_type == "*") {
$request_types_to_lookup[] = $request_type;
}
}
foreach ($request_types_to_lookup as $request_type) {
if (isset($route_map[$request_type]) && count($route_map[$request_type]) > 0) {
foreach ($route_map[$request_type] as $route_pattern => $route) {
//once we found there is a matched route, stop
$matched = $this->routeMatched($request_type, $route_pattern, $query_path);
if ($matched) {
$request_matched = true;
break 2;
}
}
}
}
}
return $request_matched;
}
|
php
|
public function findMatchedRoute($request_method = "", $query_path = "", $route_map)
{
$query_path = $this->normalize($query_path);
$request_matched = false;
$output = "";
if (count($route_map) > 0) {
$request_types = array_keys($route_map);
$request_types_to_lookup = array();
foreach ($request_types as $request_type) {
if ($request_type == $request_method || $request_type == "*") {
$request_types_to_lookup[] = $request_type;
}
}
foreach ($request_types_to_lookup as $request_type) {
if (isset($route_map[$request_type]) && count($route_map[$request_type]) > 0) {
foreach ($route_map[$request_type] as $route_pattern => $route) {
//once we found there is a matched route, stop
$matched = $this->routeMatched($request_type, $route_pattern, $query_path);
if ($matched) {
$request_matched = true;
break 2;
}
}
}
}
}
return $request_matched;
}
|
[
"public",
"function",
"findMatchedRoute",
"(",
"$",
"request_method",
"=",
"\"\"",
",",
"$",
"query_path",
"=",
"\"\"",
",",
"$",
"route_map",
")",
"{",
"$",
"query_path",
"=",
"$",
"this",
"->",
"normalize",
"(",
"$",
"query_path",
")",
";",
"$",
"request_matched",
"=",
"false",
";",
"$",
"output",
"=",
"\"\"",
";",
"if",
"(",
"count",
"(",
"$",
"route_map",
")",
">",
"0",
")",
"{",
"$",
"request_types",
"=",
"array_keys",
"(",
"$",
"route_map",
")",
";",
"$",
"request_types_to_lookup",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"request_types",
"as",
"$",
"request_type",
")",
"{",
"if",
"(",
"$",
"request_type",
"==",
"$",
"request_method",
"||",
"$",
"request_type",
"==",
"\"*\"",
")",
"{",
"$",
"request_types_to_lookup",
"[",
"]",
"=",
"$",
"request_type",
";",
"}",
"}",
"foreach",
"(",
"$",
"request_types_to_lookup",
"as",
"$",
"request_type",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"route_map",
"[",
"$",
"request_type",
"]",
")",
"&&",
"count",
"(",
"$",
"route_map",
"[",
"$",
"request_type",
"]",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"route_map",
"[",
"$",
"request_type",
"]",
"as",
"$",
"route_pattern",
"=>",
"$",
"route",
")",
"{",
"//once we found there is a matched route, stop",
"$",
"matched",
"=",
"$",
"this",
"->",
"routeMatched",
"(",
"$",
"request_type",
",",
"$",
"route_pattern",
",",
"$",
"query_path",
")",
";",
"if",
"(",
"$",
"matched",
")",
"{",
"$",
"request_matched",
"=",
"true",
";",
"break",
"2",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"$",
"request_matched",
";",
"}"
] |
find a route
|
[
"find",
"a",
"route"
] |
2f962818646e4e1d65f5d008eeb953cb41ebb3e0
|
https://github.com/superjimpupcake/Pupcake/blob/2f962818646e4e1d65f5d008eeb953cb41ebb3e0/src/Pupcake/Router.php#L104-L133
|
24,235
|
superjimpupcake/Pupcake
|
src/Pupcake/Router.php
|
Router.processRouteMatchingNative
|
public function processRouteMatchingNative($event)
{
$request_type = $event->props('request_type');
$uri = $event->props('query_path');
$route_pattern= $event->props('route_pattern');
$result = false;
$params = array();
$route_pattern_length = strlen($route_pattern);
$path_pos = strpos($route_pattern, "*path"); //see if there is *path exists
if ($path_pos !== FALSE) {
$first_part_of_path = substr($route_pattern, 0, $path_pos);
if (substr($uri, 0, $path_pos) == $first_part_of_path) {
$uri_length = strlen($uri);
$params[":path"] = substr($uri, $path_pos, $uri_length - $path_pos);
$route = $this->getRoute($request_type, $route_pattern);
$route->setParams($params);
$this->setMatchedRoute($route);
$result = true;
return $result;
}
}
$uri_comps = explode("/", $uri);
$uri_comps_count = count($uri_comps);
$route_pattern_comps = explode("/", $route_pattern);
$route_pattern_comps_count = count($route_pattern_comps);
if ($uri_comps_count == $route_pattern_comps_count) {
for ($k=1;$k<$route_pattern_comps_count;$k++ ) { //we should start from index 1 since index 0 is the /
if ($route_pattern_comps[$k][0] == ":") {
$token = $route_pattern_comps[$k];
$params[$token] = $uri_comps[$k];
$route_pattern_comps[$k] = "";
$uri_comps[$k] = "";
}
}
$uri_reformed = implode("/",$uri_comps);
$route_pattern_reformed = implode("/",$route_pattern_comps);
$route = $this->getRoute($request_type, $route_pattern);
$route->setParams($params);
if ($uri_reformed == $route_pattern_reformed) {
$results = $this->app->trigger("system.routing.route.matched", "", array('route' => $route));
//the result can be either a boolean or an array
$result = true;
if ( is_array($results) && count($results) > 0 ) { //the result is an array
foreach ($results as $matched) {
if (!$matched) {
$result = false;
break;
}
}
}
else if ($results === FALSE) {
$result = false;
}
if ($result) {
$this->setMatchedRoute($route);
}
}
}
return $result;
}
|
php
|
public function processRouteMatchingNative($event)
{
$request_type = $event->props('request_type');
$uri = $event->props('query_path');
$route_pattern= $event->props('route_pattern');
$result = false;
$params = array();
$route_pattern_length = strlen($route_pattern);
$path_pos = strpos($route_pattern, "*path"); //see if there is *path exists
if ($path_pos !== FALSE) {
$first_part_of_path = substr($route_pattern, 0, $path_pos);
if (substr($uri, 0, $path_pos) == $first_part_of_path) {
$uri_length = strlen($uri);
$params[":path"] = substr($uri, $path_pos, $uri_length - $path_pos);
$route = $this->getRoute($request_type, $route_pattern);
$route->setParams($params);
$this->setMatchedRoute($route);
$result = true;
return $result;
}
}
$uri_comps = explode("/", $uri);
$uri_comps_count = count($uri_comps);
$route_pattern_comps = explode("/", $route_pattern);
$route_pattern_comps_count = count($route_pattern_comps);
if ($uri_comps_count == $route_pattern_comps_count) {
for ($k=1;$k<$route_pattern_comps_count;$k++ ) { //we should start from index 1 since index 0 is the /
if ($route_pattern_comps[$k][0] == ":") {
$token = $route_pattern_comps[$k];
$params[$token] = $uri_comps[$k];
$route_pattern_comps[$k] = "";
$uri_comps[$k] = "";
}
}
$uri_reformed = implode("/",$uri_comps);
$route_pattern_reformed = implode("/",$route_pattern_comps);
$route = $this->getRoute($request_type, $route_pattern);
$route->setParams($params);
if ($uri_reformed == $route_pattern_reformed) {
$results = $this->app->trigger("system.routing.route.matched", "", array('route' => $route));
//the result can be either a boolean or an array
$result = true;
if ( is_array($results) && count($results) > 0 ) { //the result is an array
foreach ($results as $matched) {
if (!$matched) {
$result = false;
break;
}
}
}
else if ($results === FALSE) {
$result = false;
}
if ($result) {
$this->setMatchedRoute($route);
}
}
}
return $result;
}
|
[
"public",
"function",
"processRouteMatchingNative",
"(",
"$",
"event",
")",
"{",
"$",
"request_type",
"=",
"$",
"event",
"->",
"props",
"(",
"'request_type'",
")",
";",
"$",
"uri",
"=",
"$",
"event",
"->",
"props",
"(",
"'query_path'",
")",
";",
"$",
"route_pattern",
"=",
"$",
"event",
"->",
"props",
"(",
"'route_pattern'",
")",
";",
"$",
"result",
"=",
"false",
";",
"$",
"params",
"=",
"array",
"(",
")",
";",
"$",
"route_pattern_length",
"=",
"strlen",
"(",
"$",
"route_pattern",
")",
";",
"$",
"path_pos",
"=",
"strpos",
"(",
"$",
"route_pattern",
",",
"\"*path\"",
")",
";",
"//see if there is *path exists",
"if",
"(",
"$",
"path_pos",
"!==",
"FALSE",
")",
"{",
"$",
"first_part_of_path",
"=",
"substr",
"(",
"$",
"route_pattern",
",",
"0",
",",
"$",
"path_pos",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"uri",
",",
"0",
",",
"$",
"path_pos",
")",
"==",
"$",
"first_part_of_path",
")",
"{",
"$",
"uri_length",
"=",
"strlen",
"(",
"$",
"uri",
")",
";",
"$",
"params",
"[",
"\":path\"",
"]",
"=",
"substr",
"(",
"$",
"uri",
",",
"$",
"path_pos",
",",
"$",
"uri_length",
"-",
"$",
"path_pos",
")",
";",
"$",
"route",
"=",
"$",
"this",
"->",
"getRoute",
"(",
"$",
"request_type",
",",
"$",
"route_pattern",
")",
";",
"$",
"route",
"->",
"setParams",
"(",
"$",
"params",
")",
";",
"$",
"this",
"->",
"setMatchedRoute",
"(",
"$",
"route",
")",
";",
"$",
"result",
"=",
"true",
";",
"return",
"$",
"result",
";",
"}",
"}",
"$",
"uri_comps",
"=",
"explode",
"(",
"\"/\"",
",",
"$",
"uri",
")",
";",
"$",
"uri_comps_count",
"=",
"count",
"(",
"$",
"uri_comps",
")",
";",
"$",
"route_pattern_comps",
"=",
"explode",
"(",
"\"/\"",
",",
"$",
"route_pattern",
")",
";",
"$",
"route_pattern_comps_count",
"=",
"count",
"(",
"$",
"route_pattern_comps",
")",
";",
"if",
"(",
"$",
"uri_comps_count",
"==",
"$",
"route_pattern_comps_count",
")",
"{",
"for",
"(",
"$",
"k",
"=",
"1",
";",
"$",
"k",
"<",
"$",
"route_pattern_comps_count",
";",
"$",
"k",
"++",
")",
"{",
"//we should start from index 1 since index 0 is the /",
"if",
"(",
"$",
"route_pattern_comps",
"[",
"$",
"k",
"]",
"[",
"0",
"]",
"==",
"\":\"",
")",
"{",
"$",
"token",
"=",
"$",
"route_pattern_comps",
"[",
"$",
"k",
"]",
";",
"$",
"params",
"[",
"$",
"token",
"]",
"=",
"$",
"uri_comps",
"[",
"$",
"k",
"]",
";",
"$",
"route_pattern_comps",
"[",
"$",
"k",
"]",
"=",
"\"\"",
";",
"$",
"uri_comps",
"[",
"$",
"k",
"]",
"=",
"\"\"",
";",
"}",
"}",
"$",
"uri_reformed",
"=",
"implode",
"(",
"\"/\"",
",",
"$",
"uri_comps",
")",
";",
"$",
"route_pattern_reformed",
"=",
"implode",
"(",
"\"/\"",
",",
"$",
"route_pattern_comps",
")",
";",
"$",
"route",
"=",
"$",
"this",
"->",
"getRoute",
"(",
"$",
"request_type",
",",
"$",
"route_pattern",
")",
";",
"$",
"route",
"->",
"setParams",
"(",
"$",
"params",
")",
";",
"if",
"(",
"$",
"uri_reformed",
"==",
"$",
"route_pattern_reformed",
")",
"{",
"$",
"results",
"=",
"$",
"this",
"->",
"app",
"->",
"trigger",
"(",
"\"system.routing.route.matched\"",
",",
"\"\"",
",",
"array",
"(",
"'route'",
"=>",
"$",
"route",
")",
")",
";",
"//the result can be either a boolean or an array ",
"$",
"result",
"=",
"true",
";",
"if",
"(",
"is_array",
"(",
"$",
"results",
")",
"&&",
"count",
"(",
"$",
"results",
")",
">",
"0",
")",
"{",
"//the result is an array",
"foreach",
"(",
"$",
"results",
"as",
"$",
"matched",
")",
"{",
"if",
"(",
"!",
"$",
"matched",
")",
"{",
"$",
"result",
"=",
"false",
";",
"break",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"$",
"results",
"===",
"FALSE",
")",
"{",
"$",
"result",
"=",
"false",
";",
"}",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"setMatchedRoute",
"(",
"$",
"route",
")",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
process route matching
@param Event the event object
@return boolean whether the route matched the uri or not
|
[
"process",
"route",
"matching"
] |
2f962818646e4e1d65f5d008eeb953cb41ebb3e0
|
https://github.com/superjimpupcake/Pupcake/blob/2f962818646e4e1d65f5d008eeb953cb41ebb3e0/src/Pupcake/Router.php#L140-L207
|
24,236
|
nabab/bbn
|
src/bbn/html/element.php
|
element.check_config
|
public static function check_config($cfg){
if ( !\is_array($cfg) ){
self::$error = "The configuration is not a valid array";
return false;
}
self::$validator->check(bbn\x::to_object($cfg), static::$schema);
self::$error = '';
if ( self::$validator->isValid() ){
return 1;
}
foreach ( self::$validator->getErrors() as $error ){
self::$error .= sprintf("[%s] %s",$error['property'], $error['message']);
var_dump($cfg);
}
return false;
}
|
php
|
public static function check_config($cfg){
if ( !\is_array($cfg) ){
self::$error = "The configuration is not a valid array";
return false;
}
self::$validator->check(bbn\x::to_object($cfg), static::$schema);
self::$error = '';
if ( self::$validator->isValid() ){
return 1;
}
foreach ( self::$validator->getErrors() as $error ){
self::$error .= sprintf("[%s] %s",$error['property'], $error['message']);
var_dump($cfg);
}
return false;
}
|
[
"public",
"static",
"function",
"check_config",
"(",
"$",
"cfg",
")",
"{",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"cfg",
")",
")",
"{",
"self",
"::",
"$",
"error",
"=",
"\"The configuration is not a valid array\"",
";",
"return",
"false",
";",
"}",
"self",
"::",
"$",
"validator",
"->",
"check",
"(",
"bbn",
"\\",
"x",
"::",
"to_object",
"(",
"$",
"cfg",
")",
",",
"static",
"::",
"$",
"schema",
")",
";",
"self",
"::",
"$",
"error",
"=",
"''",
";",
"if",
"(",
"self",
"::",
"$",
"validator",
"->",
"isValid",
"(",
")",
")",
"{",
"return",
"1",
";",
"}",
"foreach",
"(",
"self",
"::",
"$",
"validator",
"->",
"getErrors",
"(",
")",
"as",
"$",
"error",
")",
"{",
"self",
"::",
"$",
"error",
".=",
"sprintf",
"(",
"\"[%s] %s\"",
",",
"$",
"error",
"[",
"'property'",
"]",
",",
"$",
"error",
"[",
"'message'",
"]",
")",
";",
"var_dump",
"(",
"$",
"cfg",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Confront the JSON schema object with the current configuration
@param array $cfg Configuration
@return bool
|
[
"Confront",
"the",
"JSON",
"schema",
"object",
"with",
"the",
"current",
"configuration"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/html/element.php#L232-L247
|
24,237
|
nabab/bbn
|
src/bbn/html/element.php
|
element.css_to_string
|
public static function css_to_string($css){
if ( \is_string($css) ){
return ' style="'.bbn\str::escape_dquotes($css).'"';
}
else if ( \is_array($css) && \count($css) > 0 ){
$st = '';
foreach ( $css as $prop => $val ){
$st .= $prop.':'.$val.';';
}
return ' style="'.bbn\str::escape_dquotes($st).'"';
}
}
|
php
|
public static function css_to_string($css){
if ( \is_string($css) ){
return ' style="'.bbn\str::escape_dquotes($css).'"';
}
else if ( \is_array($css) && \count($css) > 0 ){
$st = '';
foreach ( $css as $prop => $val ){
$st .= $prop.':'.$val.';';
}
return ' style="'.bbn\str::escape_dquotes($st).'"';
}
}
|
[
"public",
"static",
"function",
"css_to_string",
"(",
"$",
"css",
")",
"{",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"css",
")",
")",
"{",
"return",
"' style=\"'",
".",
"bbn",
"\\",
"str",
"::",
"escape_dquotes",
"(",
"$",
"css",
")",
".",
"'\"'",
";",
"}",
"else",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"css",
")",
"&&",
"\\",
"count",
"(",
"$",
"css",
")",
">",
"0",
")",
"{",
"$",
"st",
"=",
"''",
";",
"foreach",
"(",
"$",
"css",
"as",
"$",
"prop",
"=>",
"$",
"val",
")",
"{",
"$",
"st",
".=",
"$",
"prop",
".",
"':'",
".",
"$",
"val",
".",
"';'",
";",
"}",
"return",
"' style=\"'",
".",
"bbn",
"\\",
"str",
"::",
"escape_dquotes",
"(",
"$",
"st",
")",
".",
"'\"'",
";",
"}",
"}"
] |
Generates style string for a HTML tag
@param array|string $css CSS properties/values array
@return string
|
[
"Generates",
"style",
"string",
"for",
"a",
"HTML",
"tag"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/html/element.php#L266-L277
|
24,238
|
nabab/bbn
|
src/bbn/html/element.php
|
element.update
|
protected function update()
{
$this->cfg = [];
foreach ( $this as $key => $var ){
if ( $key !== 'cfg' && !\is_null($var) ){
if ( \is_array($var) ){
foreach ( $var as $k => $v ){
if ( !isset($this->cfg[$key]) ){
$this->cfg[$key] = [];
}
if ( !\is_null($v) ){
$this->cfg[$key][$k] = $v;
}
}
}
else{
$this->cfg[$key] = $var;
}
}
}
return $this;
}
|
php
|
protected function update()
{
$this->cfg = [];
foreach ( $this as $key => $var ){
if ( $key !== 'cfg' && !\is_null($var) ){
if ( \is_array($var) ){
foreach ( $var as $k => $v ){
if ( !isset($this->cfg[$key]) ){
$this->cfg[$key] = [];
}
if ( !\is_null($v) ){
$this->cfg[$key][$k] = $v;
}
}
}
else{
$this->cfg[$key] = $var;
}
}
}
return $this;
}
|
[
"protected",
"function",
"update",
"(",
")",
"{",
"$",
"this",
"->",
"cfg",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"key",
"=>",
"$",
"var",
")",
"{",
"if",
"(",
"$",
"key",
"!==",
"'cfg'",
"&&",
"!",
"\\",
"is_null",
"(",
"$",
"var",
")",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"var",
")",
")",
"{",
"foreach",
"(",
"$",
"var",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"cfg",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"cfg",
"[",
"$",
"key",
"]",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"!",
"\\",
"is_null",
"(",
"$",
"v",
")",
")",
"{",
"$",
"this",
"->",
"cfg",
"[",
"$",
"key",
"]",
"[",
"$",
"k",
"]",
"=",
"$",
"v",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"cfg",
"[",
"$",
"key",
"]",
"=",
"$",
"var",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets the configuration property according to the current configuration
@return bbn\html\element
|
[
"Sets",
"the",
"configuration",
"property",
"according",
"to",
"the",
"current",
"configuration"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/html/element.php#L375-L396
|
24,239
|
nabab/bbn
|
src/bbn/html/element.php
|
element.append
|
public function append($ele)
{
$args = \func_get_args();
foreach ( $args as $ele ){
if ( !isset($this->content) ){
if ( \is_array($ele) && isset($ele[0]) ){
$this->content = $ele;
}
else{
$this->content = \is_object($ele) ? [$ele] : $ele;
}
}
else if ( \is_array($this->content) ){
if ( \is_array($ele) ){
array_merge($this->content, $ele);
}
else{
array_push($this->content, $ele);
}
}
else if ( \is_string($this->content) ){
if ( \is_array($ele) ){
foreach ( $ele as $e ){
$this->content .= $e->html();
}
}
else{
$this->content .= \is_object($ele) ? $ele->html() : $ele;
}
}
}
return $this;
}
|
php
|
public function append($ele)
{
$args = \func_get_args();
foreach ( $args as $ele ){
if ( !isset($this->content) ){
if ( \is_array($ele) && isset($ele[0]) ){
$this->content = $ele;
}
else{
$this->content = \is_object($ele) ? [$ele] : $ele;
}
}
else if ( \is_array($this->content) ){
if ( \is_array($ele) ){
array_merge($this->content, $ele);
}
else{
array_push($this->content, $ele);
}
}
else if ( \is_string($this->content) ){
if ( \is_array($ele) ){
foreach ( $ele as $e ){
$this->content .= $e->html();
}
}
else{
$this->content .= \is_object($ele) ? $ele->html() : $ele;
}
}
}
return $this;
}
|
[
"public",
"function",
"append",
"(",
"$",
"ele",
")",
"{",
"$",
"args",
"=",
"\\",
"func_get_args",
"(",
")",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"ele",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"content",
")",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"ele",
")",
"&&",
"isset",
"(",
"$",
"ele",
"[",
"0",
"]",
")",
")",
"{",
"$",
"this",
"->",
"content",
"=",
"$",
"ele",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"content",
"=",
"\\",
"is_object",
"(",
"$",
"ele",
")",
"?",
"[",
"$",
"ele",
"]",
":",
"$",
"ele",
";",
"}",
"}",
"else",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"this",
"->",
"content",
")",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"ele",
")",
")",
"{",
"array_merge",
"(",
"$",
"this",
"->",
"content",
",",
"$",
"ele",
")",
";",
"}",
"else",
"{",
"array_push",
"(",
"$",
"this",
"->",
"content",
",",
"$",
"ele",
")",
";",
"}",
"}",
"else",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"this",
"->",
"content",
")",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"ele",
")",
")",
"{",
"foreach",
"(",
"$",
"ele",
"as",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"content",
".=",
"$",
"e",
"->",
"html",
"(",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"content",
".=",
"\\",
"is_object",
"(",
"$",
"ele",
")",
"?",
"$",
"ele",
"->",
"html",
"(",
")",
":",
"$",
"ele",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add an element to the content, or a string if it's one
@param string|bbn\html\element $ele
|
[
"Add",
"an",
"element",
"to",
"the",
"content",
"or",
"a",
"string",
"if",
"it",
"s",
"one"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/html/element.php#L403-L435
|
24,240
|
nabab/bbn
|
src/bbn/html/element.php
|
element.get_config
|
public function get_config()
{
$this->update();
$tmp = bbn\x::remove_empty($this->cfg);
if ( isset($tmp['content']) && \is_array($tmp['content']) ){
foreach ( $tmp['content'] as $i => $c ){
if ( \is_object($c) ){
if (method_exists($c, 'get_config') ){
$tmp['content'][$i] = $c->get_config();
}
}
}
}
return $tmp;
}
|
php
|
public function get_config()
{
$this->update();
$tmp = bbn\x::remove_empty($this->cfg);
if ( isset($tmp['content']) && \is_array($tmp['content']) ){
foreach ( $tmp['content'] as $i => $c ){
if ( \is_object($c) ){
if (method_exists($c, 'get_config') ){
$tmp['content'][$i] = $c->get_config();
}
}
}
}
return $tmp;
}
|
[
"public",
"function",
"get_config",
"(",
")",
"{",
"$",
"this",
"->",
"update",
"(",
")",
";",
"$",
"tmp",
"=",
"bbn",
"\\",
"x",
"::",
"remove_empty",
"(",
"$",
"this",
"->",
"cfg",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"tmp",
"[",
"'content'",
"]",
")",
"&&",
"\\",
"is_array",
"(",
"$",
"tmp",
"[",
"'content'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"tmp",
"[",
"'content'",
"]",
"as",
"$",
"i",
"=>",
"$",
"c",
")",
"{",
"if",
"(",
"\\",
"is_object",
"(",
"$",
"c",
")",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"c",
",",
"'get_config'",
")",
")",
"{",
"$",
"tmp",
"[",
"'content'",
"]",
"[",
"$",
"i",
"]",
"=",
"$",
"c",
"->",
"get_config",
"(",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"tmp",
";",
"}"
] |
Returns the current configuration.
@return array Current configuration
|
[
"Returns",
"the",
"current",
"configuration",
"."
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/html/element.php#L441-L455
|
24,241
|
nabab/bbn
|
src/bbn/html/element.php
|
element.script
|
public function script($with_ele=1)
{
$this->update();
$r = '';
if ( isset($this->attr['id']) ){
if ( isset($this->cfg['events']) ){
foreach ( $this->cfg['events'] as $event => $fn ){
$r .= '.'.$event.'('.
( strpos($fn, 'function') === 0 ? $fn : 'function(e){'.$fn.'}' ).
')';
}
}
if ( isset($this->cfg['widget'], $this->cfg['widget']['name']) ){
$r .= '.'.$this->cfg['widget']['name'].'(';
if ( isset($this->cfg['widget']['options']) ){
$r .= '{';
foreach ( $this->cfg['widget']['options'] as $n => $o ){
$r .= '"'.$n.'":';
if ( \is_string($o) ){
$o = trim($o);
if ( (strpos($o, 'function(') === 0) ){
$r .= $o;
}
else{
$r .= '"'.bbn\str::escape_dquotes($o).'"';
}
}
else if ( \is_bool($o) ){
$r .= $o ? 'true' : 'false';
}
else{
$r .= json_encode($o);
}
$r .= ',';
}
$r .= '}';
}
$r .= ')';
}
if ( !empty($this->help) ){
// tooltip
}
if ( !empty($r) ){
if ( $with_ele ){
$r = '$("#'.$this->attr['id'].'")'.$r.';'.PHP_EOL;
}
else{
$r = $r.';'.PHP_EOL;
}
}
}
if ( !empty($this->script) ){
$r .= $this->script.PHP_EOL;
}
if ( \is_array($this->content) ){
foreach ( $this->content as $c ){
if ( \is_array($c) ){
$c = new bbn\html\element($c);
}
if (\is_object($c) && method_exists($c, 'script') ){
$r .= $c->script();
}
}
}
return $r;
}
|
php
|
public function script($with_ele=1)
{
$this->update();
$r = '';
if ( isset($this->attr['id']) ){
if ( isset($this->cfg['events']) ){
foreach ( $this->cfg['events'] as $event => $fn ){
$r .= '.'.$event.'('.
( strpos($fn, 'function') === 0 ? $fn : 'function(e){'.$fn.'}' ).
')';
}
}
if ( isset($this->cfg['widget'], $this->cfg['widget']['name']) ){
$r .= '.'.$this->cfg['widget']['name'].'(';
if ( isset($this->cfg['widget']['options']) ){
$r .= '{';
foreach ( $this->cfg['widget']['options'] as $n => $o ){
$r .= '"'.$n.'":';
if ( \is_string($o) ){
$o = trim($o);
if ( (strpos($o, 'function(') === 0) ){
$r .= $o;
}
else{
$r .= '"'.bbn\str::escape_dquotes($o).'"';
}
}
else if ( \is_bool($o) ){
$r .= $o ? 'true' : 'false';
}
else{
$r .= json_encode($o);
}
$r .= ',';
}
$r .= '}';
}
$r .= ')';
}
if ( !empty($this->help) ){
// tooltip
}
if ( !empty($r) ){
if ( $with_ele ){
$r = '$("#'.$this->attr['id'].'")'.$r.';'.PHP_EOL;
}
else{
$r = $r.';'.PHP_EOL;
}
}
}
if ( !empty($this->script) ){
$r .= $this->script.PHP_EOL;
}
if ( \is_array($this->content) ){
foreach ( $this->content as $c ){
if ( \is_array($c) ){
$c = new bbn\html\element($c);
}
if (\is_object($c) && method_exists($c, 'script') ){
$r .= $c->script();
}
}
}
return $r;
}
|
[
"public",
"function",
"script",
"(",
"$",
"with_ele",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"update",
"(",
")",
";",
"$",
"r",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"attr",
"[",
"'id'",
"]",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cfg",
"[",
"'events'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"cfg",
"[",
"'events'",
"]",
"as",
"$",
"event",
"=>",
"$",
"fn",
")",
"{",
"$",
"r",
".=",
"'.'",
".",
"$",
"event",
".",
"'('",
".",
"(",
"strpos",
"(",
"$",
"fn",
",",
"'function'",
")",
"===",
"0",
"?",
"$",
"fn",
":",
"'function(e){'",
".",
"$",
"fn",
".",
"'}'",
")",
".",
"')'",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cfg",
"[",
"'widget'",
"]",
",",
"$",
"this",
"->",
"cfg",
"[",
"'widget'",
"]",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"r",
".=",
"'.'",
".",
"$",
"this",
"->",
"cfg",
"[",
"'widget'",
"]",
"[",
"'name'",
"]",
".",
"'('",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cfg",
"[",
"'widget'",
"]",
"[",
"'options'",
"]",
")",
")",
"{",
"$",
"r",
".=",
"'{'",
";",
"foreach",
"(",
"$",
"this",
"->",
"cfg",
"[",
"'widget'",
"]",
"[",
"'options'",
"]",
"as",
"$",
"n",
"=>",
"$",
"o",
")",
"{",
"$",
"r",
".=",
"'\"'",
".",
"$",
"n",
".",
"'\":'",
";",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"o",
")",
")",
"{",
"$",
"o",
"=",
"trim",
"(",
"$",
"o",
")",
";",
"if",
"(",
"(",
"strpos",
"(",
"$",
"o",
",",
"'function('",
")",
"===",
"0",
")",
")",
"{",
"$",
"r",
".=",
"$",
"o",
";",
"}",
"else",
"{",
"$",
"r",
".=",
"'\"'",
".",
"bbn",
"\\",
"str",
"::",
"escape_dquotes",
"(",
"$",
"o",
")",
".",
"'\"'",
";",
"}",
"}",
"else",
"if",
"(",
"\\",
"is_bool",
"(",
"$",
"o",
")",
")",
"{",
"$",
"r",
".=",
"$",
"o",
"?",
"'true'",
":",
"'false'",
";",
"}",
"else",
"{",
"$",
"r",
".=",
"json_encode",
"(",
"$",
"o",
")",
";",
"}",
"$",
"r",
".=",
"','",
";",
"}",
"$",
"r",
".=",
"'}'",
";",
"}",
"$",
"r",
".=",
"')'",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"help",
")",
")",
"{",
"// tooltip",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"r",
")",
")",
"{",
"if",
"(",
"$",
"with_ele",
")",
"{",
"$",
"r",
"=",
"'$(\"#'",
".",
"$",
"this",
"->",
"attr",
"[",
"'id'",
"]",
".",
"'\")'",
".",
"$",
"r",
".",
"';'",
".",
"PHP_EOL",
";",
"}",
"else",
"{",
"$",
"r",
"=",
"$",
"r",
".",
"';'",
".",
"PHP_EOL",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"script",
")",
")",
"{",
"$",
"r",
".=",
"$",
"this",
"->",
"script",
".",
"PHP_EOL",
";",
"}",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"this",
"->",
"content",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"content",
"as",
"$",
"c",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"c",
")",
")",
"{",
"$",
"c",
"=",
"new",
"bbn",
"\\",
"html",
"\\",
"element",
"(",
"$",
"c",
")",
";",
"}",
"if",
"(",
"\\",
"is_object",
"(",
"$",
"c",
")",
"&&",
"method_exists",
"(",
"$",
"c",
",",
"'script'",
")",
")",
"{",
"$",
"r",
".=",
"$",
"c",
"->",
"script",
"(",
")",
";",
"}",
"}",
"}",
"return",
"$",
"r",
";",
"}"
] |
Returns the javascript coming with the object
@return string javascript string
|
[
"Returns",
"the",
"javascript",
"coming",
"with",
"the",
"object"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/html/element.php#L482-L547
|
24,242
|
nabab/bbn
|
src/bbn/html/element.php
|
element.html
|
public function html($with_js = 1)
{
$html = '';
if ( $this->tag ){
$this->update();
// TAG
$html .= '<'.$this->tag;
foreach ( $this->attr as $key => $val ){
if ( \is_string($key) ){
$html .= ' '.htmlspecialchars($key).'="';
if ( is_numeric($val) ){
$html .= $val;
}
else if (\is_string($val) ){
$html .= htmlspecialchars($val);
}
$html .= '"';
}
}
if ( \count($this->css) > 0 ){
$html .= self::css_to_string($this->css);
}
if ( $this->xhtml ){
$html .= ' /';
}
$html .= '>';
if ( !\in_array($this->tag, self::$self_closing_tags) ){
if ( isset($this->text) ){
$html .= $this->text;
}
if ( isset($this->content) ){
// @todo: Add the ability to imbricate elements
if ( \is_string($this->content) ){
$html .= $this->content;
}
else if ( \is_array($this->content) ){
foreach ( $this->content as $c ){
if ( \is_array($c) ){
$c = new bbn\html\element($c);
}
$html .= $c->html($with_js);
}
}
}
$html .= '</'.$this->tag.'>';
}
if ( isset($this->placeholder) && strpos($this->placeholder,'%s') !== false ){
$html = sprintf($this->placeholder, $html);
}
}
return $html;
}
|
php
|
public function html($with_js = 1)
{
$html = '';
if ( $this->tag ){
$this->update();
// TAG
$html .= '<'.$this->tag;
foreach ( $this->attr as $key => $val ){
if ( \is_string($key) ){
$html .= ' '.htmlspecialchars($key).'="';
if ( is_numeric($val) ){
$html .= $val;
}
else if (\is_string($val) ){
$html .= htmlspecialchars($val);
}
$html .= '"';
}
}
if ( \count($this->css) > 0 ){
$html .= self::css_to_string($this->css);
}
if ( $this->xhtml ){
$html .= ' /';
}
$html .= '>';
if ( !\in_array($this->tag, self::$self_closing_tags) ){
if ( isset($this->text) ){
$html .= $this->text;
}
if ( isset($this->content) ){
// @todo: Add the ability to imbricate elements
if ( \is_string($this->content) ){
$html .= $this->content;
}
else if ( \is_array($this->content) ){
foreach ( $this->content as $c ){
if ( \is_array($c) ){
$c = new bbn\html\element($c);
}
$html .= $c->html($with_js);
}
}
}
$html .= '</'.$this->tag.'>';
}
if ( isset($this->placeholder) && strpos($this->placeholder,'%s') !== false ){
$html = sprintf($this->placeholder, $html);
}
}
return $html;
}
|
[
"public",
"function",
"html",
"(",
"$",
"with_js",
"=",
"1",
")",
"{",
"$",
"html",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"tag",
")",
"{",
"$",
"this",
"->",
"update",
"(",
")",
";",
"// TAG",
"$",
"html",
".=",
"'<'",
".",
"$",
"this",
"->",
"tag",
";",
"foreach",
"(",
"$",
"this",
"->",
"attr",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"$",
"html",
".=",
"' '",
".",
"htmlspecialchars",
"(",
"$",
"key",
")",
".",
"'=\"'",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"val",
")",
")",
"{",
"$",
"html",
".=",
"$",
"val",
";",
"}",
"else",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"val",
")",
")",
"{",
"$",
"html",
".=",
"htmlspecialchars",
"(",
"$",
"val",
")",
";",
"}",
"$",
"html",
".=",
"'\"'",
";",
"}",
"}",
"if",
"(",
"\\",
"count",
"(",
"$",
"this",
"->",
"css",
")",
">",
"0",
")",
"{",
"$",
"html",
".=",
"self",
"::",
"css_to_string",
"(",
"$",
"this",
"->",
"css",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"xhtml",
")",
"{",
"$",
"html",
".=",
"' /'",
";",
"}",
"$",
"html",
".=",
"'>'",
";",
"if",
"(",
"!",
"\\",
"in_array",
"(",
"$",
"this",
"->",
"tag",
",",
"self",
"::",
"$",
"self_closing_tags",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"text",
")",
")",
"{",
"$",
"html",
".=",
"$",
"this",
"->",
"text",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"content",
")",
")",
"{",
"// @todo: Add the ability to imbricate elements",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"this",
"->",
"content",
")",
")",
"{",
"$",
"html",
".=",
"$",
"this",
"->",
"content",
";",
"}",
"else",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"this",
"->",
"content",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"content",
"as",
"$",
"c",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"c",
")",
")",
"{",
"$",
"c",
"=",
"new",
"bbn",
"\\",
"html",
"\\",
"element",
"(",
"$",
"c",
")",
";",
"}",
"$",
"html",
".=",
"$",
"c",
"->",
"html",
"(",
"$",
"with_js",
")",
";",
"}",
"}",
"}",
"$",
"html",
".=",
"'</'",
".",
"$",
"this",
"->",
"tag",
".",
"'>'",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"placeholder",
")",
"&&",
"strpos",
"(",
"$",
"this",
"->",
"placeholder",
",",
"'%s'",
")",
"!==",
"false",
")",
"{",
"$",
"html",
"=",
"sprintf",
"(",
"$",
"this",
"->",
"placeholder",
",",
"$",
"html",
")",
";",
"}",
"}",
"return",
"$",
"html",
";",
"}"
] |
Returns the corresponding HTML string
@param bool $with_js Includes the javascript
@return string HTML string
|
[
"Returns",
"the",
"corresponding",
"HTML",
"string"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/html/element.php#L601-L660
|
24,243
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/mbox/mbox_set.php
|
ezcMailMboxSet.getNextLine
|
public function getNextLine()
{
if ( $this->currentMessagePosition === 0 )
{
$this->nextMail();
}
if ( $this->hasMoreMailData )
{
$data = fgets( $this->fh );
if ( feof( $this->fh ) || substr( $data, 0, 5 ) === "From " )
{
$this->hasMoreMailData = false;
return null;
}
return $data;
}
return null;
}
|
php
|
public function getNextLine()
{
if ( $this->currentMessagePosition === 0 )
{
$this->nextMail();
}
if ( $this->hasMoreMailData )
{
$data = fgets( $this->fh );
if ( feof( $this->fh ) || substr( $data, 0, 5 ) === "From " )
{
$this->hasMoreMailData = false;
return null;
}
return $data;
}
return null;
}
|
[
"public",
"function",
"getNextLine",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"currentMessagePosition",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"nextMail",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"hasMoreMailData",
")",
"{",
"$",
"data",
"=",
"fgets",
"(",
"$",
"this",
"->",
"fh",
")",
";",
"if",
"(",
"feof",
"(",
"$",
"this",
"->",
"fh",
")",
"||",
"substr",
"(",
"$",
"data",
",",
"0",
",",
"5",
")",
"===",
"\"From \"",
")",
"{",
"$",
"this",
"->",
"hasMoreMailData",
"=",
"false",
";",
"return",
"null",
";",
"}",
"return",
"$",
"data",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns one line of data from the current mail in the set
including the ending linebreak.
Null is returned if there is no current mail in the set or
the end of the mail is reached.
@return string
|
[
"Returns",
"one",
"line",
"of",
"data",
"from",
"the",
"current",
"mail",
"in",
"the",
"set",
"including",
"the",
"ending",
"linebreak",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/mbox/mbox_set.php#L101-L119
|
24,244
|
artscorestudio/document-bundle
|
Controller/PostController.php
|
PostController.deleteAction
|
public function deleteAction($id)
{
$this->denyAccessUnlessGranted('ROLE_ADMIN', null, 'Unable to access this page !');
$postManager = $this->get('asf_document.post.manager');
$post = $postManager->getRepository()->findOneBy(array('id' => $id));
try {
if ( is_null($post) )
throw new \Exception($this->get('translator')->trans('An error occurs when deleting the post', array(), 'asf_document'));
$postManager->getEntityManager()->remove($post);
$postManager->getEntityManager()->flush();
if ( $this->has('asf_layout.flash_message') ) {
$this->get('asf_layout.flash_message')->success($this->get('translator')->trans('The post "%name%" successfully deleted', array('%name%' => $post->getTitle()), 'asf_document'));
}
} catch (\Exception $e) {
if ( $this->has('asf_layout.flash_message') ) {
$this->get('asf_layout.flash_message')->danger($e->getMessage());
}
}
return $this->redirect($this->get('router')->generate('asf_document_post_list'));
}
|
php
|
public function deleteAction($id)
{
$this->denyAccessUnlessGranted('ROLE_ADMIN', null, 'Unable to access this page !');
$postManager = $this->get('asf_document.post.manager');
$post = $postManager->getRepository()->findOneBy(array('id' => $id));
try {
if ( is_null($post) )
throw new \Exception($this->get('translator')->trans('An error occurs when deleting the post', array(), 'asf_document'));
$postManager->getEntityManager()->remove($post);
$postManager->getEntityManager()->flush();
if ( $this->has('asf_layout.flash_message') ) {
$this->get('asf_layout.flash_message')->success($this->get('translator')->trans('The post "%name%" successfully deleted', array('%name%' => $post->getTitle()), 'asf_document'));
}
} catch (\Exception $e) {
if ( $this->has('asf_layout.flash_message') ) {
$this->get('asf_layout.flash_message')->danger($e->getMessage());
}
}
return $this->redirect($this->get('router')->generate('asf_document_post_list'));
}
|
[
"public",
"function",
"deleteAction",
"(",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"denyAccessUnlessGranted",
"(",
"'ROLE_ADMIN'",
",",
"null",
",",
"'Unable to access this page !'",
")",
";",
"$",
"postManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'asf_document.post.manager'",
")",
";",
"$",
"post",
"=",
"$",
"postManager",
"->",
"getRepository",
"(",
")",
"->",
"findOneBy",
"(",
"array",
"(",
"'id'",
"=>",
"$",
"id",
")",
")",
";",
"try",
"{",
"if",
"(",
"is_null",
"(",
"$",
"post",
")",
")",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"this",
"->",
"get",
"(",
"'translator'",
")",
"->",
"trans",
"(",
"'An error occurs when deleting the post'",
",",
"array",
"(",
")",
",",
"'asf_document'",
")",
")",
";",
"$",
"postManager",
"->",
"getEntityManager",
"(",
")",
"->",
"remove",
"(",
"$",
"post",
")",
";",
"$",
"postManager",
"->",
"getEntityManager",
"(",
")",
"->",
"flush",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"'asf_layout.flash_message'",
")",
")",
"{",
"$",
"this",
"->",
"get",
"(",
"'asf_layout.flash_message'",
")",
"->",
"success",
"(",
"$",
"this",
"->",
"get",
"(",
"'translator'",
")",
"->",
"trans",
"(",
"'The post \"%name%\" successfully deleted'",
",",
"array",
"(",
"'%name%'",
"=>",
"$",
"post",
"->",
"getTitle",
"(",
")",
")",
",",
"'asf_document'",
")",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"'asf_layout.flash_message'",
")",
")",
"{",
"$",
"this",
"->",
"get",
"(",
"'asf_layout.flash_message'",
")",
"->",
"danger",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"get",
"(",
"'router'",
")",
"->",
"generate",
"(",
"'asf_document_post_list'",
")",
")",
";",
"}"
] |
Delete a post
@param integer $id ASFDocumentBundle:Post Entity ID
@throws AccessDeniedException If user does not have ACL's rights for delete the post
@throws \Exception Error on post not found or on removing element from DB
@return \Symfony\Component\HttpFoundation\RedirectResponse
|
[
"Delete",
"a",
"post"
] |
3aceab0f75de8f7dd0fad0d0db83d7940bf565c8
|
https://github.com/artscorestudio/document-bundle/blob/3aceab0f75de8f7dd0fad0d0db83d7940bf565c8/Controller/PostController.php#L206-L231
|
24,245
|
kenphp/ken
|
src/Helpers/View.php
|
View.render
|
public static function render(ResponseInterface $response, $view, array $params = [])
{
return Application::getInstance()->view->render($response, $view, $params);
}
|
php
|
public static function render(ResponseInterface $response, $view, array $params = [])
{
return Application::getInstance()->view->render($response, $view, $params);
}
|
[
"public",
"static",
"function",
"render",
"(",
"ResponseInterface",
"$",
"response",
",",
"$",
"view",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"return",
"Application",
"::",
"getInstance",
"(",
")",
"->",
"view",
"->",
"render",
"(",
"$",
"response",
",",
"$",
"view",
",",
"$",
"params",
")",
";",
"}"
] |
Render a view file.
@param ResponseInterface $response
@param string $view Path of view file started from 'views' directory
@param array $params Assosiative array containing parameters to be passed to view
@return ResponseInterface
|
[
"Render",
"a",
"view",
"file",
"."
] |
c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb
|
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Helpers/View.php#L22-L25
|
24,246
|
mustardandrew/muan-laravel-acl
|
src/Traits/HasPermissionsTrait.php
|
HasPermissionsTrait.hasPermissionThroughRole
|
public function hasPermissionThroughRole($permission)
{
if (! $this->isMethodRolesExists()) {
return false;
}
if (! $permission = $this->preparePermission($permission)) {
return false;
}
foreach ($permission->roles as $role) {
if ($this->roles->contains($role)) {
return true;
}
}
return false;
}
|
php
|
public function hasPermissionThroughRole($permission)
{
if (! $this->isMethodRolesExists()) {
return false;
}
if (! $permission = $this->preparePermission($permission)) {
return false;
}
foreach ($permission->roles as $role) {
if ($this->roles->contains($role)) {
return true;
}
}
return false;
}
|
[
"public",
"function",
"hasPermissionThroughRole",
"(",
"$",
"permission",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isMethodRolesExists",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"permission",
"=",
"$",
"this",
"->",
"preparePermission",
"(",
"$",
"permission",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"permission",
"->",
"roles",
"as",
"$",
"role",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"roles",
"->",
"contains",
"(",
"$",
"role",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Has permission through role
@param Permission|string $permission
@return boolean
|
[
"Has",
"permission",
"through",
"role"
] |
b5f23340b5536babb98d9fd0d727a7a3371c97d5
|
https://github.com/mustardandrew/muan-laravel-acl/blob/b5f23340b5536babb98d9fd0d727a7a3371c97d5/src/Traits/HasPermissionsTrait.php#L32-L49
|
24,247
|
mustardandrew/muan-laravel-acl
|
src/Traits/HasPermissionsTrait.php
|
HasPermissionsTrait.hasDirectPermission
|
public function hasDirectPermission($permission)
{
$name = $permission instanceof Permission ? $permission->name : $permission;
return (bool) $this->permissions->where('name', $name)->count();
}
|
php
|
public function hasDirectPermission($permission)
{
$name = $permission instanceof Permission ? $permission->name : $permission;
return (bool) $this->permissions->where('name', $name)->count();
}
|
[
"public",
"function",
"hasDirectPermission",
"(",
"$",
"permission",
")",
"{",
"$",
"name",
"=",
"$",
"permission",
"instanceof",
"Permission",
"?",
"$",
"permission",
"->",
"name",
":",
"$",
"permission",
";",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"permissions",
"->",
"where",
"(",
"'name'",
",",
"$",
"name",
")",
"->",
"count",
"(",
")",
";",
"}"
] |
Has direct permission
@param Permission|string $permission
@return boolean
|
[
"Has",
"direct",
"permission"
] |
b5f23340b5536babb98d9fd0d727a7a3371c97d5
|
https://github.com/mustardandrew/muan-laravel-acl/blob/b5f23340b5536babb98d9fd0d727a7a3371c97d5/src/Traits/HasPermissionsTrait.php#L57-L61
|
24,248
|
mustardandrew/muan-laravel-acl
|
src/Traits/HasPermissionsTrait.php
|
HasPermissionsTrait.eachPermission
|
public function eachPermission(array $permissions, callable $callback)
{
$permissions = array_flatten($permissions);
foreach ($permissions as $permission) {
if ($permission = $this->preparePermission($permission)) {
$callback($permission);
}
}
}
|
php
|
public function eachPermission(array $permissions, callable $callback)
{
$permissions = array_flatten($permissions);
foreach ($permissions as $permission) {
if ($permission = $this->preparePermission($permission)) {
$callback($permission);
}
}
}
|
[
"public",
"function",
"eachPermission",
"(",
"array",
"$",
"permissions",
",",
"callable",
"$",
"callback",
")",
"{",
"$",
"permissions",
"=",
"array_flatten",
"(",
"$",
"permissions",
")",
";",
"foreach",
"(",
"$",
"permissions",
"as",
"$",
"permission",
")",
"{",
"if",
"(",
"$",
"permission",
"=",
"$",
"this",
"->",
"preparePermission",
"(",
"$",
"permission",
")",
")",
"{",
"$",
"callback",
"(",
"$",
"permission",
")",
";",
"}",
"}",
"}"
] |
Calc each permission
@param array $permissions
@param callable $callback
|
[
"Calc",
"each",
"permission"
] |
b5f23340b5536babb98d9fd0d727a7a3371c97d5
|
https://github.com/mustardandrew/muan-laravel-acl/blob/b5f23340b5536babb98d9fd0d727a7a3371c97d5/src/Traits/HasPermissionsTrait.php#L144-L153
|
24,249
|
bit3archive/php-remote-objects
|
src/RemoteObjects/Server.php
|
Server.handle
|
public function handle()
{
try {
$request = $this->transport->receive();
list($method, $params) = $this->encoder->decodeMethod($request);
if (!$method) {
$result = null;
}
else {
if (
$this->logger !== null &&
$this->logger->isHandling(\Monolog\Logger::DEBUG)
) {
$this->logger->addDebug(
'Receive remote method invocation',
array(
'method' => $method,
'params' => $params
)
);
}
$result = $this->invoke(
$this->target,
$method,
$params
);
}
$response = $this->encoder->encodeResult($result);
$this->transport->respond($response);
}
catch (\Exception $e) {
$response = $this->encoder->encodeException($e);
$this->transport->respond($response);
}
}
|
php
|
public function handle()
{
try {
$request = $this->transport->receive();
list($method, $params) = $this->encoder->decodeMethod($request);
if (!$method) {
$result = null;
}
else {
if (
$this->logger !== null &&
$this->logger->isHandling(\Monolog\Logger::DEBUG)
) {
$this->logger->addDebug(
'Receive remote method invocation',
array(
'method' => $method,
'params' => $params
)
);
}
$result = $this->invoke(
$this->target,
$method,
$params
);
}
$response = $this->encoder->encodeResult($result);
$this->transport->respond($response);
}
catch (\Exception $e) {
$response = $this->encoder->encodeException($e);
$this->transport->respond($response);
}
}
|
[
"public",
"function",
"handle",
"(",
")",
"{",
"try",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"transport",
"->",
"receive",
"(",
")",
";",
"list",
"(",
"$",
"method",
",",
"$",
"params",
")",
"=",
"$",
"this",
"->",
"encoder",
"->",
"decodeMethod",
"(",
"$",
"request",
")",
";",
"if",
"(",
"!",
"$",
"method",
")",
"{",
"$",
"result",
"=",
"null",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"logger",
"!==",
"null",
"&&",
"$",
"this",
"->",
"logger",
"->",
"isHandling",
"(",
"\\",
"Monolog",
"\\",
"Logger",
"::",
"DEBUG",
")",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"addDebug",
"(",
"'Receive remote method invocation'",
",",
"array",
"(",
"'method'",
"=>",
"$",
"method",
",",
"'params'",
"=>",
"$",
"params",
")",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"invoke",
"(",
"$",
"this",
"->",
"target",
",",
"$",
"method",
",",
"$",
"params",
")",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"encoder",
"->",
"encodeResult",
"(",
"$",
"result",
")",
";",
"$",
"this",
"->",
"transport",
"->",
"respond",
"(",
"$",
"response",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"encoder",
"->",
"encodeException",
"(",
"$",
"e",
")",
";",
"$",
"this",
"->",
"transport",
"->",
"respond",
"(",
"$",
"response",
")",
";",
"}",
"}"
] |
Handle a remote invokation request.
@return mixed
|
[
"Handle",
"a",
"remote",
"invokation",
"request",
"."
] |
0a917cdb261d83b1e89bdbdce3627584823bff5f
|
https://github.com/bit3archive/php-remote-objects/blob/0a917cdb261d83b1e89bdbdce3627584823bff5f/src/RemoteObjects/Server.php#L138-L178
|
24,250
|
rhosocial/yii2-user
|
rbac/DbManager.php
|
DbManager.getRolesByUser
|
public function getRolesByUser($userGuid)
{
if (!isset($userGuid) || $userGuid === '') {
return [];
}
if ($userGuid instanceof User) {
$userGuid = $userGuid->getGUID();
}
$query = (new Query)->select('b.*')
->from(['a' => $this->assignmentTable, 'b' => $this->itemTable])
->where('{{a}}.[[item_name]]={{b}}.[[name]]')
->andWhere(['a.user_guid' => (string) $userGuid])
->andWhere(['b.type' => Item::TYPE_ROLE]);
$roles = [];
foreach ($query->all($this->db) as $row) {
$roles[$row['name']] = $this->populateItem($row);
}
return $roles;
}
|
php
|
public function getRolesByUser($userGuid)
{
if (!isset($userGuid) || $userGuid === '') {
return [];
}
if ($userGuid instanceof User) {
$userGuid = $userGuid->getGUID();
}
$query = (new Query)->select('b.*')
->from(['a' => $this->assignmentTable, 'b' => $this->itemTable])
->where('{{a}}.[[item_name]]={{b}}.[[name]]')
->andWhere(['a.user_guid' => (string) $userGuid])
->andWhere(['b.type' => Item::TYPE_ROLE]);
$roles = [];
foreach ($query->all($this->db) as $row) {
$roles[$row['name']] = $this->populateItem($row);
}
return $roles;
}
|
[
"public",
"function",
"getRolesByUser",
"(",
"$",
"userGuid",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"userGuid",
")",
"||",
"$",
"userGuid",
"===",
"''",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"$",
"userGuid",
"instanceof",
"User",
")",
"{",
"$",
"userGuid",
"=",
"$",
"userGuid",
"->",
"getGUID",
"(",
")",
";",
"}",
"$",
"query",
"=",
"(",
"new",
"Query",
")",
"->",
"select",
"(",
"'b.*'",
")",
"->",
"from",
"(",
"[",
"'a'",
"=>",
"$",
"this",
"->",
"assignmentTable",
",",
"'b'",
"=>",
"$",
"this",
"->",
"itemTable",
"]",
")",
"->",
"where",
"(",
"'{{a}}.[[item_name]]={{b}}.[[name]]'",
")",
"->",
"andWhere",
"(",
"[",
"'a.user_guid'",
"=>",
"(",
"string",
")",
"$",
"userGuid",
"]",
")",
"->",
"andWhere",
"(",
"[",
"'b.type'",
"=>",
"Item",
"::",
"TYPE_ROLE",
"]",
")",
";",
"$",
"roles",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"query",
"->",
"all",
"(",
"$",
"this",
"->",
"db",
")",
"as",
"$",
"row",
")",
"{",
"$",
"roles",
"[",
"$",
"row",
"[",
"'name'",
"]",
"]",
"=",
"$",
"this",
"->",
"populateItem",
"(",
"$",
"row",
")",
";",
"}",
"return",
"$",
"roles",
";",
"}"
] |
Get roles by user.
@param string|User $userGuid
@return array
|
[
"Get",
"roles",
"by",
"user",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/rbac/DbManager.php#L148-L169
|
24,251
|
rhosocial/yii2-user
|
rbac/DbManager.php
|
DbManager.getInheritedPermissionsByUser
|
protected function getInheritedPermissionsByUser($userGuid)
{
$query = (new Query)->select('item_name')
->from($this->assignmentTable)
->where(['user_guid' => (string) $userGuid]);
$childrenList = $this->getChildrenList();
$result = [];
foreach ($query->column($this->db) as $roleName) {
$this->getChildrenRecursive($roleName, $childrenList, $result);
}
if (empty($result)) {
return [];
}
$query = (new Query)->from($this->itemTable)->where([
'type' => Item::TYPE_PERMISSION,
'name' => array_keys($result),
]);
$permissions = [];
foreach ($query->all($this->db) as $row) {
$permissions[$row['name']] = $this->populateItem($row);
}
return $permissions;
}
|
php
|
protected function getInheritedPermissionsByUser($userGuid)
{
$query = (new Query)->select('item_name')
->from($this->assignmentTable)
->where(['user_guid' => (string) $userGuid]);
$childrenList = $this->getChildrenList();
$result = [];
foreach ($query->column($this->db) as $roleName) {
$this->getChildrenRecursive($roleName, $childrenList, $result);
}
if (empty($result)) {
return [];
}
$query = (new Query)->from($this->itemTable)->where([
'type' => Item::TYPE_PERMISSION,
'name' => array_keys($result),
]);
$permissions = [];
foreach ($query->all($this->db) as $row) {
$permissions[$row['name']] = $this->populateItem($row);
}
return $permissions;
}
|
[
"protected",
"function",
"getInheritedPermissionsByUser",
"(",
"$",
"userGuid",
")",
"{",
"$",
"query",
"=",
"(",
"new",
"Query",
")",
"->",
"select",
"(",
"'item_name'",
")",
"->",
"from",
"(",
"$",
"this",
"->",
"assignmentTable",
")",
"->",
"where",
"(",
"[",
"'user_guid'",
"=>",
"(",
"string",
")",
"$",
"userGuid",
"]",
")",
";",
"$",
"childrenList",
"=",
"$",
"this",
"->",
"getChildrenList",
"(",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"query",
"->",
"column",
"(",
"$",
"this",
"->",
"db",
")",
"as",
"$",
"roleName",
")",
"{",
"$",
"this",
"->",
"getChildrenRecursive",
"(",
"$",
"roleName",
",",
"$",
"childrenList",
",",
"$",
"result",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"query",
"=",
"(",
"new",
"Query",
")",
"->",
"from",
"(",
"$",
"this",
"->",
"itemTable",
")",
"->",
"where",
"(",
"[",
"'type'",
"=>",
"Item",
"::",
"TYPE_PERMISSION",
",",
"'name'",
"=>",
"array_keys",
"(",
"$",
"result",
")",
",",
"]",
")",
";",
"$",
"permissions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"query",
"->",
"all",
"(",
"$",
"this",
"->",
"db",
")",
"as",
"$",
"row",
")",
"{",
"$",
"permissions",
"[",
"$",
"row",
"[",
"'name'",
"]",
"]",
"=",
"$",
"this",
"->",
"populateItem",
"(",
"$",
"row",
")",
";",
"}",
"return",
"$",
"permissions",
";",
"}"
] |
Returns all permissions that the user inherits from the roles assigned to him.
@param string|User $userGuid the user GUID (see [[\rhosocial\user\User::guid]])
@return Permission[] all inherited permissions that the user has. The array is indexed by the permission names.
|
[
"Returns",
"all",
"permissions",
"that",
"the",
"user",
"inherits",
"from",
"the",
"roles",
"assigned",
"to",
"him",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/rbac/DbManager.php#L196-L221
|
24,252
|
rhosocial/yii2-user
|
rbac/DbManager.php
|
DbManager.revokeFailedAssignment
|
protected function revokeFailedAssignment(Assignment $assignment)
{
if ($assignment->failedAt === null) {
return false;
}
if (strtotime($assignment->failedAt) < strtotime(gmdate('Y-m-d H:i:s'))) {
$role = $this->getRole($assignment->roleName);
if (!$role) {
return true;
}
$this->revoke($role->name, $assignment->userGuid);
return true;
}
return false;
}
|
php
|
protected function revokeFailedAssignment(Assignment $assignment)
{
if ($assignment->failedAt === null) {
return false;
}
if (strtotime($assignment->failedAt) < strtotime(gmdate('Y-m-d H:i:s'))) {
$role = $this->getRole($assignment->roleName);
if (!$role) {
return true;
}
$this->revoke($role->name, $assignment->userGuid);
return true;
}
return false;
}
|
[
"protected",
"function",
"revokeFailedAssignment",
"(",
"Assignment",
"$",
"assignment",
")",
"{",
"if",
"(",
"$",
"assignment",
"->",
"failedAt",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"strtotime",
"(",
"$",
"assignment",
"->",
"failedAt",
")",
"<",
"strtotime",
"(",
"gmdate",
"(",
"'Y-m-d H:i:s'",
")",
")",
")",
"{",
"$",
"role",
"=",
"$",
"this",
"->",
"getRole",
"(",
"$",
"assignment",
"->",
"roleName",
")",
";",
"if",
"(",
"!",
"$",
"role",
")",
"{",
"return",
"true",
";",
"}",
"$",
"this",
"->",
"revoke",
"(",
"$",
"role",
"->",
"name",
",",
"$",
"assignment",
"->",
"userGuid",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Revoke failed assignment.
If assignment's `failedAt` attribute is `null`, false will be given directly.
@param Assignment $assignment
@return boolean
|
[
"Revoke",
"failed",
"assignment",
".",
"If",
"assignment",
"s",
"failedAt",
"attribute",
"is",
"null",
"false",
"will",
"be",
"given",
"directly",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/rbac/DbManager.php#L264-L278
|
24,253
|
rhosocial/yii2-user
|
rbac/DbManager.php
|
DbManager.getUserGuidsByRole
|
public function getUserGuidsByRole($roleName)
{
if (empty($roleName)) {
return [];
}
return (new Query)->select('[[user_guid]]')
->from($this->assignmentTable)
->where(['item_name' => $roleName])->column($this->db);
}
|
php
|
public function getUserGuidsByRole($roleName)
{
if (empty($roleName)) {
return [];
}
return (new Query)->select('[[user_guid]]')
->from($this->assignmentTable)
->where(['item_name' => $roleName])->column($this->db);
}
|
[
"public",
"function",
"getUserGuidsByRole",
"(",
"$",
"roleName",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"roleName",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"(",
"new",
"Query",
")",
"->",
"select",
"(",
"'[[user_guid]]'",
")",
"->",
"from",
"(",
"$",
"this",
"->",
"assignmentTable",
")",
"->",
"where",
"(",
"[",
"'item_name'",
"=>",
"$",
"roleName",
"]",
")",
"->",
"column",
"(",
"$",
"this",
"->",
"db",
")",
";",
"}"
] |
Returns all role assignment information for the specified role.
@param string $roleName
@return Assignment[] the assignments. An empty array will be
returned if role is not assigned to any user.
@since 2.0.7
|
[
"Returns",
"all",
"role",
"assignment",
"information",
"for",
"the",
"specified",
"role",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/rbac/DbManager.php#L387-L396
|
24,254
|
PhrozenByte/pico-parse-pages-content
|
PicoParsePagesContent.php
|
PicoParsePagesContent.onSinglePageLoaded
|
public function onSinglePageLoaded(array &$pageData)
{
if (!isset($pageData['content'])) {
$pageData['content'] = $this->prepareFileContent($pageData['raw_content'], $pageData['meta']);
$pageData['content'] = $this->parseFileContent($pageData['content']);
}
}
|
php
|
public function onSinglePageLoaded(array &$pageData)
{
if (!isset($pageData['content'])) {
$pageData['content'] = $this->prepareFileContent($pageData['raw_content'], $pageData['meta']);
$pageData['content'] = $this->parseFileContent($pageData['content']);
}
}
|
[
"public",
"function",
"onSinglePageLoaded",
"(",
"array",
"&",
"$",
"pageData",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"pageData",
"[",
"'content'",
"]",
")",
")",
"{",
"$",
"pageData",
"[",
"'content'",
"]",
"=",
"$",
"this",
"->",
"prepareFileContent",
"(",
"$",
"pageData",
"[",
"'raw_content'",
"]",
",",
"$",
"pageData",
"[",
"'meta'",
"]",
")",
";",
"$",
"pageData",
"[",
"'content'",
"]",
"=",
"$",
"this",
"->",
"parseFileContent",
"(",
"$",
"pageData",
"[",
"'content'",
"]",
")",
";",
"}",
"}"
] |
Parses the contents of all pages
@see DummyPlugin::onSinglePageLoaded()
|
[
"Parses",
"the",
"contents",
"of",
"all",
"pages"
] |
fda8266f04d5bf523de1a07665a8d4c268099130
|
https://github.com/PhrozenByte/pico-parse-pages-content/blob/fda8266f04d5bf523de1a07665a8d4c268099130/PicoParsePagesContent.php#L48-L54
|
24,255
|
oroinc/OroLayoutComponent
|
LayoutItem.php
|
LayoutItem.initialize
|
public function initialize($id, $alias = null)
{
$this->id = $id;
$this->alias = $alias;
}
|
php
|
public function initialize($id, $alias = null)
{
$this->id = $id;
$this->alias = $alias;
}
|
[
"public",
"function",
"initialize",
"(",
"$",
"id",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"$",
"id",
";",
"$",
"this",
"->",
"alias",
"=",
"$",
"alias",
";",
"}"
] |
Initializes the state of this object
@param string $id The layout item id
@param string|null $alias The layout item alias
|
[
"Initializes",
"the",
"state",
"of",
"this",
"object"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/LayoutItem.php#L37-L41
|
24,256
|
trunda/SmfMenu
|
src/Smf/Menu/MenuExtension.php
|
MenuExtension.buildOptions
|
public function buildOptions(array $options)
{
$options = array_merge(
array(
'link' => null,
'icon' => null,
),
$options
);
if (isset($options['link']) && $options['link'] !== null) {
$options['extras']['link'] = (array) $options['link'];
}
$options['extras']['icon'] = $options['icon'];
return $options;
}
|
php
|
public function buildOptions(array $options)
{
$options = array_merge(
array(
'link' => null,
'icon' => null,
),
$options
);
if (isset($options['link']) && $options['link'] !== null) {
$options['extras']['link'] = (array) $options['link'];
}
$options['extras']['icon'] = $options['icon'];
return $options;
}
|
[
"public",
"function",
"buildOptions",
"(",
"array",
"$",
"options",
")",
"{",
"$",
"options",
"=",
"array_merge",
"(",
"array",
"(",
"'link'",
"=>",
"null",
",",
"'icon'",
"=>",
"null",
",",
")",
",",
"$",
"options",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'link'",
"]",
")",
"&&",
"$",
"options",
"[",
"'link'",
"]",
"!==",
"null",
")",
"{",
"$",
"options",
"[",
"'extras'",
"]",
"[",
"'link'",
"]",
"=",
"(",
"array",
")",
"$",
"options",
"[",
"'link'",
"]",
";",
"}",
"$",
"options",
"[",
"'extras'",
"]",
"[",
"'icon'",
"]",
"=",
"$",
"options",
"[",
"'icon'",
"]",
";",
"return",
"$",
"options",
";",
"}"
] |
Builds the full option array used to configure the item.
@param array $options The options processed by the previous extensions
@return array
|
[
"Builds",
"the",
"full",
"option",
"array",
"used",
"to",
"configure",
"the",
"item",
"."
] |
739e74fb664c1f018b4a74142bd28d20c004bac6
|
https://github.com/trunda/SmfMenu/blob/739e74fb664c1f018b4a74142bd28d20c004bac6/src/Smf/Menu/MenuExtension.php#L18-L33
|
24,257
|
phPoirot/psr7
|
Uri.php
|
Uri._filterHost
|
function _filterHost($host)
{
if (strstr($host, ':') !== false)
throw new \InvalidArgumentException('Host name can`t contains port number.');
$host = strtolower($host);
return $host;
}
|
php
|
function _filterHost($host)
{
if (strstr($host, ':') !== false)
throw new \InvalidArgumentException('Host name can`t contains port number.');
$host = strtolower($host);
return $host;
}
|
[
"function",
"_filterHost",
"(",
"$",
"host",
")",
"{",
"if",
"(",
"strstr",
"(",
"$",
"host",
",",
"':'",
")",
"!==",
"false",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Host name can`t contains port number.'",
")",
";",
"$",
"host",
"=",
"strtolower",
"(",
"$",
"host",
")",
";",
"return",
"$",
"host",
";",
"}"
] |
Validate and Filter host value
@param string $host
@return string normalized value
|
[
"Validate",
"and",
"Filter",
"host",
"value"
] |
e90295e806dc2eb0cc422f315075f673c63a0780
|
https://github.com/phPoirot/psr7/blob/e90295e806dc2eb0cc422f315075f673c63a0780/Uri.php#L550-L557
|
24,258
|
WScore/Validation
|
src/Verify.php
|
Verify.is
|
public function is($value, $rules)
{
$valTO = $this->apply($value, $rules);
if ($valTO->fails()) {
return false;
}
return $valTO->getValue();
}
|
php
|
public function is($value, $rules)
{
$valTO = $this->apply($value, $rules);
if ($valTO->fails()) {
return false;
}
return $valTO->getValue();
}
|
[
"public",
"function",
"is",
"(",
"$",
"value",
",",
"$",
"rules",
")",
"{",
"$",
"valTO",
"=",
"$",
"this",
"->",
"apply",
"(",
"$",
"value",
",",
"$",
"rules",
")",
";",
"if",
"(",
"$",
"valTO",
"->",
"fails",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"valTO",
"->",
"getValue",
"(",
")",
";",
"}"
] |
validates a text value, or an array of text values.
returns the filtered value, or false if validation fails.
@param string|array $value
@param array|Rules $rules
@return bool|string
|
[
"validates",
"a",
"text",
"value",
"or",
"an",
"array",
"of",
"text",
"values",
".",
"returns",
"the",
"filtered",
"value",
"or",
"false",
"if",
"validation",
"fails",
"."
] |
25c0dca37d624bb0bb22f8e79ba54db2f69e0950
|
https://github.com/WScore/Validation/blob/25c0dca37d624bb0bb22f8e79ba54db2f69e0950/src/Verify.php#L54-L62
|
24,259
|
WScore/Validation
|
src/Verify.php
|
Verify.applyFilters
|
public function applyFilters($value, $rules = array())
{
$valueTO = $this->valueTO->forge($value);
// loop through all the rules to validate $value.
foreach ($rules as $rule => $parameter) {
// skip rules with option as FALSE.
if ($parameter === false) {
continue;
}
$this->filter->apply($rule, $valueTO, $parameter);
// loop break.
if ($valueTO->getBreak()) {
break;
}
}
return $valueTO;
}
|
php
|
public function applyFilters($value, $rules = array())
{
$valueTO = $this->valueTO->forge($value);
// loop through all the rules to validate $value.
foreach ($rules as $rule => $parameter) {
// skip rules with option as FALSE.
if ($parameter === false) {
continue;
}
$this->filter->apply($rule, $valueTO, $parameter);
// loop break.
if ($valueTO->getBreak()) {
break;
}
}
return $valueTO;
}
|
[
"public",
"function",
"applyFilters",
"(",
"$",
"value",
",",
"$",
"rules",
"=",
"array",
"(",
")",
")",
"{",
"$",
"valueTO",
"=",
"$",
"this",
"->",
"valueTO",
"->",
"forge",
"(",
"$",
"value",
")",
";",
"// loop through all the rules to validate $value.",
"foreach",
"(",
"$",
"rules",
"as",
"$",
"rule",
"=>",
"$",
"parameter",
")",
"{",
"// skip rules with option as FALSE.",
"if",
"(",
"$",
"parameter",
"===",
"false",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"filter",
"->",
"apply",
"(",
"$",
"rule",
",",
"$",
"valueTO",
",",
"$",
"parameter",
")",
";",
"// loop break.",
"if",
"(",
"$",
"valueTO",
"->",
"getBreak",
"(",
")",
")",
"{",
"break",
";",
"}",
"}",
"return",
"$",
"valueTO",
";",
"}"
] |
apply filters on a single value.
@param string $value
@param array|Rules $rules
@return ValueTO
|
[
"apply",
"filters",
"on",
"a",
"single",
"value",
"."
] |
25c0dca37d624bb0bb22f8e79ba54db2f69e0950
|
https://github.com/WScore/Validation/blob/25c0dca37d624bb0bb22f8e79ba54db2f69e0950/src/Verify.php#L94-L112
|
24,260
|
heidelpay/PhpDoc
|
src/phpDocumentor/Configuration/Merger.php
|
Merger.run
|
public function run($destination, $source, $default = null)
{
$result = null;
if (is_object($destination) && is_object($source) && get_class($destination) == get_class($source)) {
$result = $this->mergeObject($destination, $source);
} elseif (is_array($source) && is_array($destination)) {
$result = $this->mergeArray($destination, $source);
} elseif (!is_null($source) && $source !== $default) {
$result = $source;
}
return $result;
}
|
php
|
public function run($destination, $source, $default = null)
{
$result = null;
if (is_object($destination) && is_object($source) && get_class($destination) == get_class($source)) {
$result = $this->mergeObject($destination, $source);
} elseif (is_array($source) && is_array($destination)) {
$result = $this->mergeArray($destination, $source);
} elseif (!is_null($source) && $source !== $default) {
$result = $source;
}
return $result;
}
|
[
"public",
"function",
"run",
"(",
"$",
"destination",
",",
"$",
"source",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"is_object",
"(",
"$",
"destination",
")",
"&&",
"is_object",
"(",
"$",
"source",
")",
"&&",
"get_class",
"(",
"$",
"destination",
")",
"==",
"get_class",
"(",
"$",
"source",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"mergeObject",
"(",
"$",
"destination",
",",
"$",
"source",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"source",
")",
"&&",
"is_array",
"(",
"$",
"destination",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"mergeArray",
"(",
"$",
"destination",
",",
"$",
"source",
")",
";",
"}",
"elseif",
"(",
"!",
"is_null",
"(",
"$",
"source",
")",
"&&",
"$",
"source",
"!==",
"$",
"default",
")",
"{",
"$",
"result",
"=",
"$",
"source",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Merges the source on top of the destination and returns the result.
@param mixed $destination The destination variable that will be overwritten with the data from the source.
@param mixed $source The source variable that should be merged over the destination.
@param mixed $default For normal variables; only replace that variable if the provided source does
not equal this value.
@return mixed the merged variable.
|
[
"Merges",
"the",
"source",
"on",
"top",
"of",
"the",
"destination",
"and",
"returns",
"the",
"result",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Configuration/Merger.php#L48-L61
|
24,261
|
heidelpay/PhpDoc
|
src/phpDocumentor/Configuration/Merger.php
|
Merger.mergeObject
|
private function mergeObject($destinationObject, $sourceObject)
{
$reflectedDestination = new \ReflectionObject($destinationObject);
$reflectedSource = new \ReflectionObject($sourceObject);
$defaultPropertyValues = $reflectedDestination->getDefaultProperties();
foreach ($reflectedSource->getProperties() as $sourceProperty) {
$destinationObject = $this->mergeProperty(
$destinationObject,
$reflectedDestination->getProperty($sourceProperty->getName()),
$sourceObject,
$sourceProperty,
$defaultPropertyValues
);
}
return $destinationObject;
}
|
php
|
private function mergeObject($destinationObject, $sourceObject)
{
$reflectedDestination = new \ReflectionObject($destinationObject);
$reflectedSource = new \ReflectionObject($sourceObject);
$defaultPropertyValues = $reflectedDestination->getDefaultProperties();
foreach ($reflectedSource->getProperties() as $sourceProperty) {
$destinationObject = $this->mergeProperty(
$destinationObject,
$reflectedDestination->getProperty($sourceProperty->getName()),
$sourceObject,
$sourceProperty,
$defaultPropertyValues
);
}
return $destinationObject;
}
|
[
"private",
"function",
"mergeObject",
"(",
"$",
"destinationObject",
",",
"$",
"sourceObject",
")",
"{",
"$",
"reflectedDestination",
"=",
"new",
"\\",
"ReflectionObject",
"(",
"$",
"destinationObject",
")",
";",
"$",
"reflectedSource",
"=",
"new",
"\\",
"ReflectionObject",
"(",
"$",
"sourceObject",
")",
";",
"$",
"defaultPropertyValues",
"=",
"$",
"reflectedDestination",
"->",
"getDefaultProperties",
"(",
")",
";",
"foreach",
"(",
"$",
"reflectedSource",
"->",
"getProperties",
"(",
")",
"as",
"$",
"sourceProperty",
")",
"{",
"$",
"destinationObject",
"=",
"$",
"this",
"->",
"mergeProperty",
"(",
"$",
"destinationObject",
",",
"$",
"reflectedDestination",
"->",
"getProperty",
"(",
"$",
"sourceProperty",
"->",
"getName",
"(",
")",
")",
",",
"$",
"sourceObject",
",",
"$",
"sourceProperty",
",",
"$",
"defaultPropertyValues",
")",
";",
"}",
"return",
"$",
"destinationObject",
";",
"}"
] |
Deep-merge the source object over the destination object and return the results.
@param object $destinationObject
@param object $sourceObject
@return object
|
[
"Deep",
"-",
"merge",
"the",
"source",
"object",
"over",
"the",
"destination",
"object",
"and",
"return",
"the",
"results",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Configuration/Merger.php#L71-L88
|
24,262
|
heidelpay/PhpDoc
|
src/phpDocumentor/Configuration/Merger.php
|
Merger.mergeArray
|
private function mergeArray($destinationArray, $sourceArray)
{
$result = array();
foreach ($destinationArray as $key => $destinationArrayItem) {
if (is_int($key)) {
$result[] = $destinationArrayItem;
} else {
$result[$key] = $destinationArrayItem;
}
}
foreach ($sourceArray as $key => $sourceArrayItem) {
if (is_int($key)) {
$result[] = $sourceArrayItem;
} else {
$result[$key] = $this->run($result[$key], $sourceArrayItem);
}
}
return $result;
}
|
php
|
private function mergeArray($destinationArray, $sourceArray)
{
$result = array();
foreach ($destinationArray as $key => $destinationArrayItem) {
if (is_int($key)) {
$result[] = $destinationArrayItem;
} else {
$result[$key] = $destinationArrayItem;
}
}
foreach ($sourceArray as $key => $sourceArrayItem) {
if (is_int($key)) {
$result[] = $sourceArrayItem;
} else {
$result[$key] = $this->run($result[$key], $sourceArrayItem);
}
}
return $result;
}
|
[
"private",
"function",
"mergeArray",
"(",
"$",
"destinationArray",
",",
"$",
"sourceArray",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"destinationArray",
"as",
"$",
"key",
"=>",
"$",
"destinationArrayItem",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"key",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"destinationArrayItem",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"destinationArrayItem",
";",
"}",
"}",
"foreach",
"(",
"$",
"sourceArray",
"as",
"$",
"key",
"=>",
"$",
"sourceArrayItem",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"key",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"sourceArrayItem",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"run",
"(",
"$",
"result",
"[",
"$",
"key",
"]",
",",
"$",
"sourceArrayItem",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Deep-merges the source array over the destination array.
@param array $destinationArray
@param array $sourceArray
@return array
|
[
"Deep",
"-",
"merges",
"the",
"source",
"array",
"over",
"the",
"destination",
"array",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Configuration/Merger.php#L98-L118
|
24,263
|
heidelpay/PhpDoc
|
src/phpDocumentor/Configuration/Merger.php
|
Merger.mergeProperty
|
private function mergeProperty(
$destinationObject,
\ReflectionProperty $destinationProperty,
$sourceObject,
\ReflectionProperty $sourceProperty,
array $defaultPropertyValues
) {
// Allow the source and destination properties to be readable
$sourceProperty->setAccessible(true);
$destinationProperty->setAccessible(true);
// Retrieve the current value for both the destination and source
$destinationValue = $destinationProperty->getValue($destinationObject);
$sourceValue = $sourceProperty->getValue($sourceObject);
// Find out what the default value for this property is
$sourcePropertyDefaultValue = isset($defaultPropertyValues[$sourceProperty->getName()])
? $defaultPropertyValues[$sourceProperty->getName()]
: null;
// if a property is annotated with the 'Replace' annotation then we null the destination location,
// causing the value from source to be copied as-is to the destination object instead of merging it.
// but only if the value that is to-be-copied is actually copied
if ($this->shouldPropertyBeReplaced($destinationProperty)) {
$destinationValue = null;
}
// Merge the values of the two properties!
$result = $this->run($destinationValue, $sourceValue, $sourcePropertyDefaultValue);
// No result? No save. We only update the destination if the resulting merge is a value
if ($result !== null) {
$destinationProperty->setValue($destinationObject, $result);
}
// Make protected and private properties inaccessible again
$destinationProperty->setAccessible($destinationProperty->isPublic());
$sourceProperty->setAccessible($sourceProperty->isPublic());
return $destinationObject;
}
|
php
|
private function mergeProperty(
$destinationObject,
\ReflectionProperty $destinationProperty,
$sourceObject,
\ReflectionProperty $sourceProperty,
array $defaultPropertyValues
) {
// Allow the source and destination properties to be readable
$sourceProperty->setAccessible(true);
$destinationProperty->setAccessible(true);
// Retrieve the current value for both the destination and source
$destinationValue = $destinationProperty->getValue($destinationObject);
$sourceValue = $sourceProperty->getValue($sourceObject);
// Find out what the default value for this property is
$sourcePropertyDefaultValue = isset($defaultPropertyValues[$sourceProperty->getName()])
? $defaultPropertyValues[$sourceProperty->getName()]
: null;
// if a property is annotated with the 'Replace' annotation then we null the destination location,
// causing the value from source to be copied as-is to the destination object instead of merging it.
// but only if the value that is to-be-copied is actually copied
if ($this->shouldPropertyBeReplaced($destinationProperty)) {
$destinationValue = null;
}
// Merge the values of the two properties!
$result = $this->run($destinationValue, $sourceValue, $sourcePropertyDefaultValue);
// No result? No save. We only update the destination if the resulting merge is a value
if ($result !== null) {
$destinationProperty->setValue($destinationObject, $result);
}
// Make protected and private properties inaccessible again
$destinationProperty->setAccessible($destinationProperty->isPublic());
$sourceProperty->setAccessible($sourceProperty->isPublic());
return $destinationObject;
}
|
[
"private",
"function",
"mergeProperty",
"(",
"$",
"destinationObject",
",",
"\\",
"ReflectionProperty",
"$",
"destinationProperty",
",",
"$",
"sourceObject",
",",
"\\",
"ReflectionProperty",
"$",
"sourceProperty",
",",
"array",
"$",
"defaultPropertyValues",
")",
"{",
"// Allow the source and destination properties to be readable",
"$",
"sourceProperty",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"destinationProperty",
"->",
"setAccessible",
"(",
"true",
")",
";",
"// Retrieve the current value for both the destination and source",
"$",
"destinationValue",
"=",
"$",
"destinationProperty",
"->",
"getValue",
"(",
"$",
"destinationObject",
")",
";",
"$",
"sourceValue",
"=",
"$",
"sourceProperty",
"->",
"getValue",
"(",
"$",
"sourceObject",
")",
";",
"// Find out what the default value for this property is",
"$",
"sourcePropertyDefaultValue",
"=",
"isset",
"(",
"$",
"defaultPropertyValues",
"[",
"$",
"sourceProperty",
"->",
"getName",
"(",
")",
"]",
")",
"?",
"$",
"defaultPropertyValues",
"[",
"$",
"sourceProperty",
"->",
"getName",
"(",
")",
"]",
":",
"null",
";",
"// if a property is annotated with the 'Replace' annotation then we null the destination location,",
"// causing the value from source to be copied as-is to the destination object instead of merging it.",
"// but only if the value that is to-be-copied is actually copied",
"if",
"(",
"$",
"this",
"->",
"shouldPropertyBeReplaced",
"(",
"$",
"destinationProperty",
")",
")",
"{",
"$",
"destinationValue",
"=",
"null",
";",
"}",
"// Merge the values of the two properties!",
"$",
"result",
"=",
"$",
"this",
"->",
"run",
"(",
"$",
"destinationValue",
",",
"$",
"sourceValue",
",",
"$",
"sourcePropertyDefaultValue",
")",
";",
"// No result? No save. We only update the destination if the resulting merge is a value",
"if",
"(",
"$",
"result",
"!==",
"null",
")",
"{",
"$",
"destinationProperty",
"->",
"setValue",
"(",
"$",
"destinationObject",
",",
"$",
"result",
")",
";",
"}",
"// Make protected and private properties inaccessible again",
"$",
"destinationProperty",
"->",
"setAccessible",
"(",
"$",
"destinationProperty",
"->",
"isPublic",
"(",
")",
")",
";",
"$",
"sourceProperty",
"->",
"setAccessible",
"(",
"$",
"sourceProperty",
"->",
"isPublic",
"(",
")",
")",
";",
"return",
"$",
"destinationObject",
";",
"}"
] |
Merges the two properties over eachother.
@param object $destinationObject
@param \ReflectionProperty $destinationProperty
@param object $sourceObject
@param \ReflectionProperty $sourceProperty
@param mixed[] $defaultPropertyValues
@return object
|
[
"Merges",
"the",
"two",
"properties",
"over",
"eachother",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Configuration/Merger.php#L131-L171
|
24,264
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Mail/src/parts/fileparts/stream_file.php
|
ezcMailStreamFile.generateBody
|
public function generateBody()
{
$contents = stream_get_contents( $this->stream );
return chunk_split( base64_encode( $contents ), 76, ezcMailTools::lineBreak() );
}
|
php
|
public function generateBody()
{
$contents = stream_get_contents( $this->stream );
return chunk_split( base64_encode( $contents ), 76, ezcMailTools::lineBreak() );
}
|
[
"public",
"function",
"generateBody",
"(",
")",
"{",
"$",
"contents",
"=",
"stream_get_contents",
"(",
"$",
"this",
"->",
"stream",
")",
";",
"return",
"chunk_split",
"(",
"base64_encode",
"(",
"$",
"contents",
")",
",",
"76",
",",
"ezcMailTools",
"::",
"lineBreak",
"(",
")",
")",
";",
"}"
] |
Returns the contents of the file with the correct encoding.
The stream might become unusable after this if it doesn't support seek.
@return string
|
[
"Returns",
"the",
"contents",
"of",
"the",
"file",
"with",
"the",
"correct",
"encoding",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parts/fileparts/stream_file.php#L123-L127
|
24,265
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.boot
|
protected static function boot()
{
parent::boot();
static::addGlobalScope(new MailingScope);
static::creating(function ($node)
{
if (empty($node->published_at))
{
$node->published_at = Carbon::now();
}
$node->fireNodeEvent('creating');
});
static::created(function ($node)
{
$node->propagateIdToSources(false);
$node->fireNodeEvent('created');
});
static::saving(function ($node)
{
$node->validateCanHaveParentOfType();
$node->fireNodeEvent('saving');
});
foreach (['updating', 'updated', 'deleting', 'deleted', 'saved'] as $event)
{
static::$event(function ($node) use ($event)
{
$node->fireNodeEvent($event);
});
}
}
|
php
|
protected static function boot()
{
parent::boot();
static::addGlobalScope(new MailingScope);
static::creating(function ($node)
{
if (empty($node->published_at))
{
$node->published_at = Carbon::now();
}
$node->fireNodeEvent('creating');
});
static::created(function ($node)
{
$node->propagateIdToSources(false);
$node->fireNodeEvent('created');
});
static::saving(function ($node)
{
$node->validateCanHaveParentOfType();
$node->fireNodeEvent('saving');
});
foreach (['updating', 'updated', 'deleting', 'deleted', 'saved'] as $event)
{
static::$event(function ($node) use ($event)
{
$node->fireNodeEvent($event);
});
}
}
|
[
"protected",
"static",
"function",
"boot",
"(",
")",
"{",
"parent",
"::",
"boot",
"(",
")",
";",
"static",
"::",
"addGlobalScope",
"(",
"new",
"MailingScope",
")",
";",
"static",
"::",
"creating",
"(",
"function",
"(",
"$",
"node",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"node",
"->",
"published_at",
")",
")",
"{",
"$",
"node",
"->",
"published_at",
"=",
"Carbon",
"::",
"now",
"(",
")",
";",
"}",
"$",
"node",
"->",
"fireNodeEvent",
"(",
"'creating'",
")",
";",
"}",
")",
";",
"static",
"::",
"created",
"(",
"function",
"(",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"propagateIdToSources",
"(",
"false",
")",
";",
"$",
"node",
"->",
"fireNodeEvent",
"(",
"'created'",
")",
";",
"}",
")",
";",
"static",
"::",
"saving",
"(",
"function",
"(",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"validateCanHaveParentOfType",
"(",
")",
";",
"$",
"node",
"->",
"fireNodeEvent",
"(",
"'saving'",
")",
";",
"}",
")",
";",
"foreach",
"(",
"[",
"'updating'",
",",
"'updated'",
",",
"'deleting'",
",",
"'deleted'",
",",
"'saved'",
"]",
"as",
"$",
"event",
")",
"{",
"static",
"::",
"$",
"event",
"(",
"function",
"(",
"$",
"node",
")",
"use",
"(",
"$",
"event",
")",
"{",
"$",
"node",
"->",
"fireNodeEvent",
"(",
"$",
"event",
")",
";",
"}",
")",
";",
"}",
"}"
] |
Boot model events
|
[
"Boot",
"model",
"events"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L184-L221
|
24,266
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.propagateIdToSources
|
public function propagateIdToSources($save = true)
{
foreach ($this->translations as $source)
{
$source->setExtensionNodeId($this->getKey(), $save);
}
}
|
php
|
public function propagateIdToSources($save = true)
{
foreach ($this->translations as $source)
{
$source->setExtensionNodeId($this->getKey(), $save);
}
}
|
[
"public",
"function",
"propagateIdToSources",
"(",
"$",
"save",
"=",
"true",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"translations",
"as",
"$",
"source",
")",
"{",
"$",
"source",
"->",
"setExtensionNodeId",
"(",
"$",
"this",
"->",
"getKey",
"(",
")",
",",
"$",
"save",
")",
";",
"}",
"}"
] |
Propagates self id to sources
The save parameter is to prevent saving sources prematurely
@param bool $save
|
[
"Propagates",
"self",
"id",
"to",
"sources"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L239-L245
|
24,267
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.validateCanHaveParentOfType
|
public function validateCanHaveParentOfType()
{
if (is_null($this->parent))
{
return;
}
$allowedNodeTypes = json_decode($this->parent->getNodeType()->allowed_children);
if (empty($allowedNodeTypes) || in_array($this->getNodeTypeKey(), $allowedNodeTypes))
{
return;
}
throw new InvalidParentNodeTypeException('Parent does not allow node type of name "' . $this->getNodeTypeName() . '" as child.');
}
|
php
|
public function validateCanHaveParentOfType()
{
if (is_null($this->parent))
{
return;
}
$allowedNodeTypes = json_decode($this->parent->getNodeType()->allowed_children);
if (empty($allowedNodeTypes) || in_array($this->getNodeTypeKey(), $allowedNodeTypes))
{
return;
}
throw new InvalidParentNodeTypeException('Parent does not allow node type of name "' . $this->getNodeTypeName() . '" as child.');
}
|
[
"public",
"function",
"validateCanHaveParentOfType",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"parent",
")",
")",
"{",
"return",
";",
"}",
"$",
"allowedNodeTypes",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"parent",
"->",
"getNodeType",
"(",
")",
"->",
"allowed_children",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"allowedNodeTypes",
")",
"||",
"in_array",
"(",
"$",
"this",
"->",
"getNodeTypeKey",
"(",
")",
",",
"$",
"allowedNodeTypes",
")",
")",
"{",
"return",
";",
"}",
"throw",
"new",
"InvalidParentNodeTypeException",
"(",
"'Parent does not allow node type of name \"'",
".",
"$",
"this",
"->",
"getNodeTypeName",
"(",
")",
".",
"'\" as child.'",
")",
";",
"}"
] |
Validates parent type
|
[
"Validates",
"parent",
"type"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L251-L266
|
24,268
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.getNodeType
|
public function getNodeType()
{
$bag = hierarchy_bag('nodetype');
if ($this->relationLoaded('nodeType'))
{
$nodeType = $this->getRelation('nodeType');
} elseif ($nodeType = $bag->getNodeType($this->getNodeTypeKey()))
{
$this->setRelation('nodeType', $nodeType);
} else
{
$nodeType = $this->load('nodeType')->getRelation('nodeType');
}
if ($nodeType)
{
$bag->addNodeType($nodeType);
return $nodeType;
}
return null;
}
|
php
|
public function getNodeType()
{
$bag = hierarchy_bag('nodetype');
if ($this->relationLoaded('nodeType'))
{
$nodeType = $this->getRelation('nodeType');
} elseif ($nodeType = $bag->getNodeType($this->getNodeTypeKey()))
{
$this->setRelation('nodeType', $nodeType);
} else
{
$nodeType = $this->load('nodeType')->getRelation('nodeType');
}
if ($nodeType)
{
$bag->addNodeType($nodeType);
return $nodeType;
}
return null;
}
|
[
"public",
"function",
"getNodeType",
"(",
")",
"{",
"$",
"bag",
"=",
"hierarchy_bag",
"(",
"'nodetype'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"relationLoaded",
"(",
"'nodeType'",
")",
")",
"{",
"$",
"nodeType",
"=",
"$",
"this",
"->",
"getRelation",
"(",
"'nodeType'",
")",
";",
"}",
"elseif",
"(",
"$",
"nodeType",
"=",
"$",
"bag",
"->",
"getNodeType",
"(",
"$",
"this",
"->",
"getNodeTypeKey",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"setRelation",
"(",
"'nodeType'",
",",
"$",
"nodeType",
")",
";",
"}",
"else",
"{",
"$",
"nodeType",
"=",
"$",
"this",
"->",
"load",
"(",
"'nodeType'",
")",
"->",
"getRelation",
"(",
"'nodeType'",
")",
";",
"}",
"if",
"(",
"$",
"nodeType",
")",
"{",
"$",
"bag",
"->",
"addNodeType",
"(",
"$",
"nodeType",
")",
";",
"return",
"$",
"nodeType",
";",
"}",
"return",
"null",
";",
"}"
] |
Getter for node type
@return NodeType
|
[
"Getter",
"for",
"node",
"type"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L295-L318
|
24,269
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.getNodeTypeName
|
public function getNodeTypeName()
{
return $this->nodeTypeName ?:
(is_null($this->getNodeType()) ? null : $this->getNodeType()->getName());
}
|
php
|
public function getNodeTypeName()
{
return $this->nodeTypeName ?:
(is_null($this->getNodeType()) ? null : $this->getNodeType()->getName());
}
|
[
"public",
"function",
"getNodeTypeName",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"nodeTypeName",
"?",
":",
"(",
"is_null",
"(",
"$",
"this",
"->",
"getNodeType",
"(",
")",
")",
"?",
"null",
":",
"$",
"this",
"->",
"getNodeType",
"(",
")",
"->",
"getName",
"(",
")",
")",
";",
"}"
] |
Gets the node type name
@return int $id
|
[
"Gets",
"the",
"node",
"type",
"name"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L335-L339
|
24,270
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.setNodeTypeByKey
|
public function setNodeTypeByKey($id)
{
$nodeType = NodeType::findOrFail($id);
$this->nodeType()->associate($nodeType);
$this->mailing = $nodeType->isTypeMailing();
}
|
php
|
public function setNodeTypeByKey($id)
{
$nodeType = NodeType::findOrFail($id);
$this->nodeType()->associate($nodeType);
$this->mailing = $nodeType->isTypeMailing();
}
|
[
"public",
"function",
"setNodeTypeByKey",
"(",
"$",
"id",
")",
"{",
"$",
"nodeType",
"=",
"NodeType",
"::",
"findOrFail",
"(",
"$",
"id",
")",
";",
"$",
"this",
"->",
"nodeType",
"(",
")",
"->",
"associate",
"(",
"$",
"nodeType",
")",
";",
"$",
"this",
"->",
"mailing",
"=",
"$",
"nodeType",
"->",
"isTypeMailing",
"(",
")",
";",
"}"
] |
Sets the node type by key and validates it
@param int $id
@return NodeType
|
[
"Sets",
"the",
"node",
"type",
"by",
"key",
"and",
"validates",
"it"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L367-L374
|
24,271
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.isTranslationAttribute
|
public function isTranslationAttribute($key)
{
if ($this->isSpecialAttribute($key))
{
return false;
}
// When there is no node type we exclude source attributes
return $this->_isTranslationAttribute($key) ||
(is_null($this->getNodeTypeName()) ? false : $this->isSourceAttribute($key));
}
|
php
|
public function isTranslationAttribute($key)
{
if ($this->isSpecialAttribute($key))
{
return false;
}
// When there is no node type we exclude source attributes
return $this->_isTranslationAttribute($key) ||
(is_null($this->getNodeTypeName()) ? false : $this->isSourceAttribute($key));
}
|
[
"public",
"function",
"isTranslationAttribute",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isSpecialAttribute",
"(",
"$",
"key",
")",
")",
"{",
"return",
"false",
";",
"}",
"// When there is no node type we exclude source attributes",
"return",
"$",
"this",
"->",
"_isTranslationAttribute",
"(",
"$",
"key",
")",
"||",
"(",
"is_null",
"(",
"$",
"this",
"->",
"getNodeTypeName",
"(",
")",
")",
"?",
"false",
":",
"$",
"this",
"->",
"isSourceAttribute",
"(",
"$",
"key",
")",
")",
";",
"}"
] |
Checks if key is a translation attribute
@param string $key
@return bool
|
[
"Checks",
"if",
"key",
"is",
"a",
"translation",
"attribute"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L382-L392
|
24,272
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.isSourceAttribute
|
protected function isSourceAttribute($key)
{
$modelName = source_model_name($this->getNodeTypeName(), true);
return in_array($key, call_user_func([$modelName, 'getSourceFields']));
}
|
php
|
protected function isSourceAttribute($key)
{
$modelName = source_model_name($this->getNodeTypeName(), true);
return in_array($key, call_user_func([$modelName, 'getSourceFields']));
}
|
[
"protected",
"function",
"isSourceAttribute",
"(",
"$",
"key",
")",
"{",
"$",
"modelName",
"=",
"source_model_name",
"(",
"$",
"this",
"->",
"getNodeTypeName",
"(",
")",
",",
"true",
")",
";",
"return",
"in_array",
"(",
"$",
"key",
",",
"call_user_func",
"(",
"[",
"$",
"modelName",
",",
"'getSourceFields'",
"]",
")",
")",
";",
"}"
] |
Checks if a key is a node source attribute
@param $key
@return bool
|
[
"Checks",
"if",
"a",
"key",
"is",
"a",
"node",
"source",
"attribute"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L417-L422
|
24,273
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.getNewTranslation
|
public function getNewTranslation($locale)
{
$nodeSource = NodeSource::newWithType(
$locale,
$this->getNodeTypeName()
);
$this->translations->add($nodeSource);
return $nodeSource;
}
|
php
|
public function getNewTranslation($locale)
{
$nodeSource = NodeSource::newWithType(
$locale,
$this->getNodeTypeName()
);
$this->translations->add($nodeSource);
return $nodeSource;
}
|
[
"public",
"function",
"getNewTranslation",
"(",
"$",
"locale",
")",
"{",
"$",
"nodeSource",
"=",
"NodeSource",
"::",
"newWithType",
"(",
"$",
"locale",
",",
"$",
"this",
"->",
"getNodeTypeName",
"(",
")",
")",
";",
"$",
"this",
"->",
"translations",
"->",
"add",
"(",
"$",
"nodeSource",
")",
";",
"return",
"$",
"nodeSource",
";",
"}"
] |
Overloading default Translatable functionality for
creating a new translation
@param string $locale
@return Model
|
[
"Overloading",
"default",
"Translatable",
"functionality",
"for",
"creating",
"a",
"new",
"translation"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L477-L487
|
24,274
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.translateOrFirst
|
public function translateOrFirst($locale = null)
{
$translation = $this->translate($locale, true);
if ( ! $translation)
{
$translation = $this->translations->first();
}
return $translation;
}
|
php
|
public function translateOrFirst($locale = null)
{
$translation = $this->translate($locale, true);
if ( ! $translation)
{
$translation = $this->translations->first();
}
return $translation;
}
|
[
"public",
"function",
"translateOrFirst",
"(",
"$",
"locale",
"=",
"null",
")",
"{",
"$",
"translation",
"=",
"$",
"this",
"->",
"translate",
"(",
"$",
"locale",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"translation",
")",
"{",
"$",
"translation",
"=",
"$",
"this",
"->",
"translations",
"->",
"first",
"(",
")",
";",
"}",
"return",
"$",
"translation",
";",
"}"
] |
Get source or fallback to first found translation
@param string|null $locale
@return NodeSource
|
[
"Get",
"source",
"or",
"fallback",
"to",
"first",
"found",
"translation"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L531-L541
|
24,275
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.determineSortableKey
|
protected function determineSortableKey($key)
{
// We need to allow source attributes here
if (in_array($key, $this->sortableColumns) || $this->isTranslationAttribute($key))
{
return $key;
}
return $this->getDefaultSortableKey();
}
|
php
|
protected function determineSortableKey($key)
{
// We need to allow source attributes here
if (in_array($key, $this->sortableColumns) || $this->isTranslationAttribute($key))
{
return $key;
}
return $this->getDefaultSortableKey();
}
|
[
"protected",
"function",
"determineSortableKey",
"(",
"$",
"key",
")",
"{",
"// We need to allow source attributes here",
"if",
"(",
"in_array",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"sortableColumns",
")",
"||",
"$",
"this",
"->",
"isTranslationAttribute",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"key",
";",
"}",
"return",
"$",
"this",
"->",
"getDefaultSortableKey",
"(",
")",
";",
"}"
] |
Determines the sortable key from the map
@param string $key
@return string
|
[
"Determines",
"the",
"sortable",
"key",
"from",
"the",
"map"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L569-L578
|
24,276
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.scopeSortedBySourceAttribute
|
public function scopeSortedBySourceAttribute(Builder $query, $attribute, $direction = 'ASC')
{
return $this->orderQueryBySourceAttribute($query, $attribute, $direction);
}
|
php
|
public function scopeSortedBySourceAttribute(Builder $query, $attribute, $direction = 'ASC')
{
return $this->orderQueryBySourceAttribute($query, $attribute, $direction);
}
|
[
"public",
"function",
"scopeSortedBySourceAttribute",
"(",
"Builder",
"$",
"query",
",",
"$",
"attribute",
",",
"$",
"direction",
"=",
"'ASC'",
")",
"{",
"return",
"$",
"this",
"->",
"orderQueryBySourceAttribute",
"(",
"$",
"query",
",",
"$",
"attribute",
",",
"$",
"direction",
")",
";",
"}"
] |
Sorts by source attribute
@param Builder $query
@param string $attribute
@param string $direction
@return Builder
|
[
"Sorts",
"by",
"source",
"attribute"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L588-L591
|
24,277
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.scopeWithName
|
public function scopeWithName(Builder $query, $name, $locale = null)
{
return $this->scopeWhereTranslation($query, 'node_name', $name, $locale);
}
|
php
|
public function scopeWithName(Builder $query, $name, $locale = null)
{
return $this->scopeWhereTranslation($query, 'node_name', $name, $locale);
}
|
[
"public",
"function",
"scopeWithName",
"(",
"Builder",
"$",
"query",
",",
"$",
"name",
",",
"$",
"locale",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"scopeWhereTranslation",
"(",
"$",
"query",
",",
"'node_name'",
",",
"$",
"name",
",",
"$",
"locale",
")",
";",
"}"
] |
Scope for selecting with name
@param Builder $query
@param string $name
@param string|null $locale
@return Builder
|
[
"Scope",
"for",
"selecting",
"with",
"name"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L621-L624
|
24,278
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.scopeWithType
|
public function scopeWithType(Builder $query, $type)
{
// We do this for querying, searching and sorting with source attributes
$this->setNodeTypeName($type);
return $this->scopeWhereTranslation($query, 'source_type', $type, null);
}
|
php
|
public function scopeWithType(Builder $query, $type)
{
// We do this for querying, searching and sorting with source attributes
$this->setNodeTypeName($type);
return $this->scopeWhereTranslation($query, 'source_type', $type, null);
}
|
[
"public",
"function",
"scopeWithType",
"(",
"Builder",
"$",
"query",
",",
"$",
"type",
")",
"{",
"// We do this for querying, searching and sorting with source attributes",
"$",
"this",
"->",
"setNodeTypeName",
"(",
"$",
"type",
")",
";",
"return",
"$",
"this",
"->",
"scopeWhereTranslation",
"(",
"$",
"query",
",",
"'source_type'",
",",
"$",
"type",
",",
"null",
")",
";",
"}"
] |
Scope for selecting with type
@param Builder $query
@param string $type
@return Builder
|
[
"Scope",
"for",
"selecting",
"with",
"type"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L633-L639
|
24,279
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.scopeFilteredByStatus
|
public function scopeFilteredByStatus(Builder $query, $status = null)
{
$status = is_null($status) ? request('f', 'all') : $status;
if (in_array($status, ['published', 'withheld', 'draft', 'pending', 'archived', 'invisible', 'locked']))
{
$query->{$status}();
}
return $query;
}
|
php
|
public function scopeFilteredByStatus(Builder $query, $status = null)
{
$status = is_null($status) ? request('f', 'all') : $status;
if (in_array($status, ['published', 'withheld', 'draft', 'pending', 'archived', 'invisible', 'locked']))
{
$query->{$status}();
}
return $query;
}
|
[
"public",
"function",
"scopeFilteredByStatus",
"(",
"Builder",
"$",
"query",
",",
"$",
"status",
"=",
"null",
")",
"{",
"$",
"status",
"=",
"is_null",
"(",
"$",
"status",
")",
"?",
"request",
"(",
"'f'",
",",
"'all'",
")",
":",
"$",
"status",
";",
"if",
"(",
"in_array",
"(",
"$",
"status",
",",
"[",
"'published'",
",",
"'withheld'",
",",
"'draft'",
",",
"'pending'",
",",
"'archived'",
",",
"'invisible'",
",",
"'locked'",
"]",
")",
")",
"{",
"$",
"query",
"->",
"{",
"$",
"status",
"}",
"(",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] |
Status filter scope
@param Builder $query
@param string $status
@return Builder
|
[
"Status",
"filter",
"scope"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L648-L658
|
24,280
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.getOrderedChildren
|
public function getOrderedChildren($perPage = null)
{
$children = $this->children();
$this->determineChildrenSorting($children);
return $this->determineChildrenPagination($perPage, $children);
}
|
php
|
public function getOrderedChildren($perPage = null)
{
$children = $this->children();
$this->determineChildrenSorting($children);
return $this->determineChildrenPagination($perPage, $children);
}
|
[
"public",
"function",
"getOrderedChildren",
"(",
"$",
"perPage",
"=",
"null",
")",
"{",
"$",
"children",
"=",
"$",
"this",
"->",
"children",
"(",
")",
";",
"$",
"this",
"->",
"determineChildrenSorting",
"(",
"$",
"children",
")",
";",
"return",
"$",
"this",
"->",
"determineChildrenPagination",
"(",
"$",
"perPage",
",",
"$",
"children",
")",
";",
"}"
] |
Get ordered children
@param int|null $perPage
@return Collection|LengthAwarePaginator
|
[
"Get",
"ordered",
"children"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L772-L779
|
24,281
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.getPublishedOrderedChildren
|
public function getPublishedOrderedChildren($perPage = null)
{
$children = $this->children()
->published();
$this->determineChildrenSorting($children);
return $this->determineChildrenPagination($perPage, $children);
}
|
php
|
public function getPublishedOrderedChildren($perPage = null)
{
$children = $this->children()
->published();
$this->determineChildrenSorting($children);
return $this->determineChildrenPagination($perPage, $children);
}
|
[
"public",
"function",
"getPublishedOrderedChildren",
"(",
"$",
"perPage",
"=",
"null",
")",
"{",
"$",
"children",
"=",
"$",
"this",
"->",
"children",
"(",
")",
"->",
"published",
"(",
")",
";",
"$",
"this",
"->",
"determineChildrenSorting",
"(",
"$",
"children",
")",
";",
"return",
"$",
"this",
"->",
"determineChildrenPagination",
"(",
"$",
"perPage",
",",
"$",
"children",
")",
";",
"}"
] |
Returns all published children with parameter ordered
@param int|null $perPage
@return Collection|LengthAwarePaginator
|
[
"Returns",
"all",
"published",
"children",
"with",
"parameter",
"ordered"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L787-L795
|
24,282
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.determineChildrenSorting
|
public function determineChildrenSorting(HasMany $children)
{
if (in_array($this->children_order, $this->translatedAttributes))
{
$children->sortedBySourceAttribute(
$this->children_order,
$this->children_order_direction
);
} else
{
$children->orderBy(
$this->children_order, $this->children_order_direction
);
};
}
|
php
|
public function determineChildrenSorting(HasMany $children)
{
if (in_array($this->children_order, $this->translatedAttributes))
{
$children->sortedBySourceAttribute(
$this->children_order,
$this->children_order_direction
);
} else
{
$children->orderBy(
$this->children_order, $this->children_order_direction
);
};
}
|
[
"public",
"function",
"determineChildrenSorting",
"(",
"HasMany",
"$",
"children",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"this",
"->",
"children_order",
",",
"$",
"this",
"->",
"translatedAttributes",
")",
")",
"{",
"$",
"children",
"->",
"sortedBySourceAttribute",
"(",
"$",
"this",
"->",
"children_order",
",",
"$",
"this",
"->",
"children_order_direction",
")",
";",
"}",
"else",
"{",
"$",
"children",
"->",
"orderBy",
"(",
"$",
"this",
"->",
"children_order",
",",
"$",
"this",
"->",
"children_order_direction",
")",
";",
"}",
";",
"}"
] |
Determines the children sorting
@param HasMany $children
|
[
"Determines",
"the",
"children",
"sorting"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L802-L816
|
24,283
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.determineChildrenPagination
|
public function determineChildrenPagination($perPage, HasMany $children)
{
if ($perPage === false)
{
return $children;
}
return is_null($perPage) ?
$children->get() :
$children->paginate($perPage);
}
|
php
|
public function determineChildrenPagination($perPage, HasMany $children)
{
if ($perPage === false)
{
return $children;
}
return is_null($perPage) ?
$children->get() :
$children->paginate($perPage);
}
|
[
"public",
"function",
"determineChildrenPagination",
"(",
"$",
"perPage",
",",
"HasMany",
"$",
"children",
")",
"{",
"if",
"(",
"$",
"perPage",
"===",
"false",
")",
"{",
"return",
"$",
"children",
";",
"}",
"return",
"is_null",
"(",
"$",
"perPage",
")",
"?",
"$",
"children",
"->",
"get",
"(",
")",
":",
"$",
"children",
"->",
"paginate",
"(",
"$",
"perPage",
")",
";",
"}"
] |
Determines the pagination of children
@param mixed $perPage
@param HasMany $children
@return mixed
|
[
"Determines",
"the",
"pagination",
"of",
"children"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L825-L835
|
24,284
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.getPositionOrderedChildren
|
public function getPositionOrderedChildren($perPage = null)
{
$children = $this->children()
->defaultOrder();
return $this->determineChildrenPagination($perPage, $children);
}
|
php
|
public function getPositionOrderedChildren($perPage = null)
{
$children = $this->children()
->defaultOrder();
return $this->determineChildrenPagination($perPage, $children);
}
|
[
"public",
"function",
"getPositionOrderedChildren",
"(",
"$",
"perPage",
"=",
"null",
")",
"{",
"$",
"children",
"=",
"$",
"this",
"->",
"children",
"(",
")",
"->",
"defaultOrder",
"(",
")",
";",
"return",
"$",
"this",
"->",
"determineChildrenPagination",
"(",
"$",
"perPage",
",",
"$",
"children",
")",
";",
"}"
] |
Returns all children ordered by position
@param int|null $perPage
@return Collection|LengthAwarePaginator
|
[
"Returns",
"all",
"children",
"ordered",
"by",
"position"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L843-L849
|
24,285
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.getPublishedPositionOrderedChildren
|
public function getPublishedPositionOrderedChildren($perPage = null)
{
$children = $this->children()
->published()
->defaultOrder();
return $this->determineChildrenPagination($perPage, $children);
}
|
php
|
public function getPublishedPositionOrderedChildren($perPage = null)
{
$children = $this->children()
->published()
->defaultOrder();
return $this->determineChildrenPagination($perPage, $children);
}
|
[
"public",
"function",
"getPublishedPositionOrderedChildren",
"(",
"$",
"perPage",
"=",
"null",
")",
"{",
"$",
"children",
"=",
"$",
"this",
"->",
"children",
"(",
")",
"->",
"published",
"(",
")",
"->",
"defaultOrder",
"(",
")",
";",
"return",
"$",
"this",
"->",
"determineChildrenPagination",
"(",
"$",
"perPage",
",",
"$",
"children",
")",
";",
"}"
] |
Returns all published children position ordered
@param int|null $perPage
@return Collection|LengthAwarePaginator
|
[
"Returns",
"all",
"published",
"children",
"position",
"ordered"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L857-L864
|
24,286
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.hasTranslatedChildren
|
public function hasTranslatedChildren($locale = null)
{
foreach ($this->getChildren() as $child)
{
if ($child->hasTranslation($locale))
{
return true;
}
}
return false;
}
|
php
|
public function hasTranslatedChildren($locale = null)
{
foreach ($this->getChildren() as $child)
{
if ($child->hasTranslation($locale))
{
return true;
}
}
return false;
}
|
[
"public",
"function",
"hasTranslatedChildren",
"(",
"$",
"locale",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getChildren",
"(",
")",
"as",
"$",
"child",
")",
"{",
"if",
"(",
"$",
"child",
"->",
"hasTranslation",
"(",
"$",
"locale",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Filters children by locale
@param string $locale
@return Collection
|
[
"Filters",
"children",
"by",
"locale"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L872-L883
|
24,287
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.deleteTranslation
|
public function deleteTranslation($locale)
{
if ($this->hasTranslation($locale))
{
if ($deleted = $this->getTranslation($locale)->delete())
{
$this->load('translations');
return true;
}
}
return false;
}
|
php
|
public function deleteTranslation($locale)
{
if ($this->hasTranslation($locale))
{
if ($deleted = $this->getTranslation($locale)->delete())
{
$this->load('translations');
return true;
}
}
return false;
}
|
[
"public",
"function",
"deleteTranslation",
"(",
"$",
"locale",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasTranslation",
"(",
"$",
"locale",
")",
")",
"{",
"if",
"(",
"$",
"deleted",
"=",
"$",
"this",
"->",
"getTranslation",
"(",
"$",
"locale",
")",
"->",
"delete",
"(",
")",
")",
"{",
"$",
"this",
"->",
"load",
"(",
"'translations'",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Deletes a translation
@param string $locale
@return bool
|
[
"Deletes",
"a",
"translation"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L891-L904
|
24,288
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.isPublished
|
public function isPublished()
{
return ($this->status >= Node::PUBLISHED)
|| ($this->status >= Node::PENDING && $this->published_at <= Carbon::now());
}
|
php
|
public function isPublished()
{
return ($this->status >= Node::PUBLISHED)
|| ($this->status >= Node::PENDING && $this->published_at <= Carbon::now());
}
|
[
"public",
"function",
"isPublished",
"(",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"status",
">=",
"Node",
"::",
"PUBLISHED",
")",
"||",
"(",
"$",
"this",
"->",
"status",
">=",
"Node",
"::",
"PENDING",
"&&",
"$",
"this",
"->",
"published_at",
"<=",
"Carbon",
"::",
"now",
"(",
")",
")",
";",
"}"
] |
Checks if the node is published
@return bool
|
[
"Checks",
"if",
"the",
"node",
"is",
"published"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L1034-L1038
|
24,289
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.transformInto
|
public function transformInto($id)
{
$newType = NodeType::find($id);
if (is_null($newType))
{
throw new \RuntimeException('Node type does not exist');
}
$sourceAttributes = $this->parseSourceAttributes();
$this->flushSources();
$this->transformNodeType($newType);
$this->remakeSources($newType);
$this->fill($sourceAttributes);
$this->save();
}
|
php
|
public function transformInto($id)
{
$newType = NodeType::find($id);
if (is_null($newType))
{
throw new \RuntimeException('Node type does not exist');
}
$sourceAttributes = $this->parseSourceAttributes();
$this->flushSources();
$this->transformNodeType($newType);
$this->remakeSources($newType);
$this->fill($sourceAttributes);
$this->save();
}
|
[
"public",
"function",
"transformInto",
"(",
"$",
"id",
")",
"{",
"$",
"newType",
"=",
"NodeType",
"::",
"find",
"(",
"$",
"id",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"newType",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Node type does not exist'",
")",
";",
"}",
"$",
"sourceAttributes",
"=",
"$",
"this",
"->",
"parseSourceAttributes",
"(",
")",
";",
"$",
"this",
"->",
"flushSources",
"(",
")",
";",
"$",
"this",
"->",
"transformNodeType",
"(",
"$",
"newType",
")",
";",
"$",
"this",
"->",
"remakeSources",
"(",
"$",
"newType",
")",
";",
"$",
"this",
"->",
"fill",
"(",
"$",
"sourceAttributes",
")",
";",
"$",
"this",
"->",
"save",
"(",
")",
";",
"}"
] |
Transforms the node type with to given type
@param int $id
@throws \RuntimeException
|
[
"Transforms",
"the",
"node",
"type",
"with",
"to",
"given",
"type"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L1086-L1106
|
24,290
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.parseSourceAttributes
|
public function parseSourceAttributes()
{
$attributes = [];
foreach ($this->translations as $translation)
{
$attributes[$translation->locale] = $translation->source->toArray();
}
return $attributes;
}
|
php
|
public function parseSourceAttributes()
{
$attributes = [];
foreach ($this->translations as $translation)
{
$attributes[$translation->locale] = $translation->source->toArray();
}
return $attributes;
}
|
[
"public",
"function",
"parseSourceAttributes",
"(",
")",
"{",
"$",
"attributes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"translations",
"as",
"$",
"translation",
")",
"{",
"$",
"attributes",
"[",
"$",
"translation",
"->",
"locale",
"]",
"=",
"$",
"translation",
"->",
"source",
"->",
"toArray",
"(",
")",
";",
"}",
"return",
"$",
"attributes",
";",
"}"
] |
Parses source attributes
@return array
|
[
"Parses",
"source",
"attributes"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L1113-L1123
|
24,291
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.flushSources
|
protected function flushSources()
{
foreach ($this->translations as $translation)
{
$translation->source->delete();
$translation->flushTemporarySource();
unset($translation->relations['source']);
}
}
|
php
|
protected function flushSources()
{
foreach ($this->translations as $translation)
{
$translation->source->delete();
$translation->flushTemporarySource();
unset($translation->relations['source']);
}
}
|
[
"protected",
"function",
"flushSources",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"translations",
"as",
"$",
"translation",
")",
"{",
"$",
"translation",
"->",
"source",
"->",
"delete",
"(",
")",
";",
"$",
"translation",
"->",
"flushTemporarySource",
"(",
")",
";",
"unset",
"(",
"$",
"translation",
"->",
"relations",
"[",
"'source'",
"]",
")",
";",
"}",
"}"
] |
Flushes the source attributes
|
[
"Flushes",
"the",
"source",
"attributes"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L1128-L1137
|
24,292
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.transformNodeType
|
protected function transformNodeType(NodeType $nodeType)
{
$this->setNodeTypeByKey($nodeType->getKey());
foreach ($this->translations as $translation)
{
$translation->source_type = $nodeType->getName();
}
}
|
php
|
protected function transformNodeType(NodeType $nodeType)
{
$this->setNodeTypeByKey($nodeType->getKey());
foreach ($this->translations as $translation)
{
$translation->source_type = $nodeType->getName();
}
}
|
[
"protected",
"function",
"transformNodeType",
"(",
"NodeType",
"$",
"nodeType",
")",
"{",
"$",
"this",
"->",
"setNodeTypeByKey",
"(",
"$",
"nodeType",
"->",
"getKey",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"translations",
"as",
"$",
"translation",
")",
"{",
"$",
"translation",
"->",
"source_type",
"=",
"$",
"nodeType",
"->",
"getName",
"(",
")",
";",
"}",
"}"
] |
Transforms the node type
@param NodeType $nodeType
|
[
"Transforms",
"the",
"node",
"type"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L1144-L1152
|
24,293
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.scopeMostVisited
|
public function scopeMostVisited(Builder $query, $limit = null)
{
$query->select(\DB::raw('nodes.*, count(*) as `aggregate`'))
->join('node_site_view', 'nodes.id', '=', 'node_site_view.node_id')
->groupBy('nodes.id')
->orderBy('aggregate', 'desc');
if ($limit)
{
$query->limit($limit);
}
return $query;
}
|
php
|
public function scopeMostVisited(Builder $query, $limit = null)
{
$query->select(\DB::raw('nodes.*, count(*) as `aggregate`'))
->join('node_site_view', 'nodes.id', '=', 'node_site_view.node_id')
->groupBy('nodes.id')
->orderBy('aggregate', 'desc');
if ($limit)
{
$query->limit($limit);
}
return $query;
}
|
[
"public",
"function",
"scopeMostVisited",
"(",
"Builder",
"$",
"query",
",",
"$",
"limit",
"=",
"null",
")",
"{",
"$",
"query",
"->",
"select",
"(",
"\\",
"DB",
"::",
"raw",
"(",
"'nodes.*, count(*) as `aggregate`'",
")",
")",
"->",
"join",
"(",
"'node_site_view'",
",",
"'nodes.id'",
",",
"'='",
",",
"'node_site_view.node_id'",
")",
"->",
"groupBy",
"(",
"'nodes.id'",
")",
"->",
"orderBy",
"(",
"'aggregate'",
",",
"'desc'",
")",
";",
"if",
"(",
"$",
"limit",
")",
"{",
"$",
"query",
"->",
"limit",
"(",
"$",
"limit",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] |
Most visited scope
@param Builder $query
@param int|null $limit
@return Builder
|
[
"Most",
"visited",
"scope"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L1177-L1190
|
24,294
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.scopeRecentlyEdited
|
public function scopeRecentlyEdited(Builder $query, $limit = null)
{
$query->orderBy('updated_at', 'desc');
if ($limit)
{
$query->limit($limit);
}
return $query;
}
|
php
|
public function scopeRecentlyEdited(Builder $query, $limit = null)
{
$query->orderBy('updated_at', 'desc');
if ($limit)
{
$query->limit($limit);
}
return $query;
}
|
[
"public",
"function",
"scopeRecentlyEdited",
"(",
"Builder",
"$",
"query",
",",
"$",
"limit",
"=",
"null",
")",
"{",
"$",
"query",
"->",
"orderBy",
"(",
"'updated_at'",
",",
"'desc'",
")",
";",
"if",
"(",
"$",
"limit",
")",
"{",
"$",
"query",
"->",
"limit",
"(",
"$",
"limit",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] |
Recently edited scope
@param Builder $query
@param int|null $limit
@return Builder
|
[
"Recently",
"edited",
"scope"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L1222-L1232
|
24,295
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.scopeRecentlyCreated
|
public function scopeRecentlyCreated(Builder $query, $limit = null)
{
$query->orderBy('created_at', 'desc');
if ($limit)
{
$query->limit($limit);
}
return $query;
}
|
php
|
public function scopeRecentlyCreated(Builder $query, $limit = null)
{
$query->orderBy('created_at', 'desc');
if ($limit)
{
$query->limit($limit);
}
return $query;
}
|
[
"public",
"function",
"scopeRecentlyCreated",
"(",
"Builder",
"$",
"query",
",",
"$",
"limit",
"=",
"null",
")",
"{",
"$",
"query",
"->",
"orderBy",
"(",
"'created_at'",
",",
"'desc'",
")",
";",
"if",
"(",
"$",
"limit",
")",
"{",
"$",
"query",
"->",
"limit",
"(",
"$",
"limit",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] |
Recently created scope
@param Builder $query
@param int|null $limit
@return Builder
|
[
"Recently",
"created",
"scope"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L1241-L1251
|
24,296
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.getSiteURL
|
public function getSiteURL($locale = null)
{
$node = $this;
$uri = '';
do
{
$uri = '/' . $node->getTranslationAttribute('node_name', $locale) . $uri;
$node = is_null($node->parent_id) ? null : node_bag($node->parent_id, false);
} while ( ! is_null($node) && $node->home != '1');
return url($uri);
}
|
php
|
public function getSiteURL($locale = null)
{
$node = $this;
$uri = '';
do
{
$uri = '/' . $node->getTranslationAttribute('node_name', $locale) . $uri;
$node = is_null($node->parent_id) ? null : node_bag($node->parent_id, false);
} while ( ! is_null($node) && $node->home != '1');
return url($uri);
}
|
[
"public",
"function",
"getSiteURL",
"(",
"$",
"locale",
"=",
"null",
")",
"{",
"$",
"node",
"=",
"$",
"this",
";",
"$",
"uri",
"=",
"''",
";",
"do",
"{",
"$",
"uri",
"=",
"'/'",
".",
"$",
"node",
"->",
"getTranslationAttribute",
"(",
"'node_name'",
",",
"$",
"locale",
")",
".",
"$",
"uri",
";",
"$",
"node",
"=",
"is_null",
"(",
"$",
"node",
"->",
"parent_id",
")",
"?",
"null",
":",
"node_bag",
"(",
"$",
"node",
"->",
"parent_id",
",",
"false",
")",
";",
"}",
"while",
"(",
"!",
"is_null",
"(",
"$",
"node",
")",
"&&",
"$",
"node",
"->",
"home",
"!=",
"'1'",
")",
";",
"return",
"url",
"(",
"$",
"uri",
")",
";",
"}"
] |
Gets the full url for node
@param string $locale
@return string
|
[
"Gets",
"the",
"full",
"url",
"for",
"node"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L1270-L1282
|
24,297
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.getPreviewURL
|
public function getPreviewURL($locale = null)
{
$token = app()->make(TokenManager::class)
->makeNewToken('preview_nodes');
$url = $this->getSiteURL($locale);
return $url . '?preview_nodes=' . $token;
}
|
php
|
public function getPreviewURL($locale = null)
{
$token = app()->make(TokenManager::class)
->makeNewToken('preview_nodes');
$url = $this->getSiteURL($locale);
return $url . '?preview_nodes=' . $token;
}
|
[
"public",
"function",
"getPreviewURL",
"(",
"$",
"locale",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"app",
"(",
")",
"->",
"make",
"(",
"TokenManager",
"::",
"class",
")",
"->",
"makeNewToken",
"(",
"'preview_nodes'",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"getSiteURL",
"(",
"$",
"locale",
")",
";",
"return",
"$",
"url",
".",
"'?preview_nodes='",
".",
"$",
"token",
";",
"}"
] |
Returns the preview url
@param string $locale
@return string
|
[
"Returns",
"the",
"preview",
"url"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L1290-L1298
|
24,298
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.getDefaultEditUrl
|
public function getDefaultEditUrl($locale = null)
{
$parameters = [
$this->getKey(),
$this->translateOrFirst($locale)->getKey()
];
if ($this->hidesChildren())
{
if ($this->children_display_mode === 'tree')
{
$parameters = current($parameters);
}
return route('reactor.nodes.children.' . $this->children_display_mode,
$parameters);
}
return route('reactor.nodes.edit',
$parameters);
}
|
php
|
public function getDefaultEditUrl($locale = null)
{
$parameters = [
$this->getKey(),
$this->translateOrFirst($locale)->getKey()
];
if ($this->hidesChildren())
{
if ($this->children_display_mode === 'tree')
{
$parameters = current($parameters);
}
return route('reactor.nodes.children.' . $this->children_display_mode,
$parameters);
}
return route('reactor.nodes.edit',
$parameters);
}
|
[
"public",
"function",
"getDefaultEditUrl",
"(",
"$",
"locale",
"=",
"null",
")",
"{",
"$",
"parameters",
"=",
"[",
"$",
"this",
"->",
"getKey",
"(",
")",
",",
"$",
"this",
"->",
"translateOrFirst",
"(",
"$",
"locale",
")",
"->",
"getKey",
"(",
")",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"hidesChildren",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"children_display_mode",
"===",
"'tree'",
")",
"{",
"$",
"parameters",
"=",
"current",
"(",
"$",
"parameters",
")",
";",
"}",
"return",
"route",
"(",
"'reactor.nodes.children.'",
".",
"$",
"this",
"->",
"children_display_mode",
",",
"$",
"parameters",
")",
";",
"}",
"return",
"route",
"(",
"'reactor.nodes.edit'",
",",
"$",
"parameters",
")",
";",
"}"
] |
Determines the default edit link for node
@param null|string $locale
@return string
|
[
"Determines",
"the",
"default",
"edit",
"link",
"for",
"node"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L1306-L1326
|
24,299
|
NuclearCMS/Hierarchy
|
src/Node.php
|
Node.getSearchable
|
public function getSearchable()
{
// When there is no node type we exclude source attributes
if (is_null($this->getNodeTypeName()))
{
return $this->searchable;
}
$modelName = source_model_name($this->getNodeTypeName(), true);
return array_merge_recursive(
$this->searchable,
call_user_func([$modelName, 'getSearchable'])
);
}
|
php
|
public function getSearchable()
{
// When there is no node type we exclude source attributes
if (is_null($this->getNodeTypeName()))
{
return $this->searchable;
}
$modelName = source_model_name($this->getNodeTypeName(), true);
return array_merge_recursive(
$this->searchable,
call_user_func([$modelName, 'getSearchable'])
);
}
|
[
"public",
"function",
"getSearchable",
"(",
")",
"{",
"// When there is no node type we exclude source attributes",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"getNodeTypeName",
"(",
")",
")",
")",
"{",
"return",
"$",
"this",
"->",
"searchable",
";",
"}",
"$",
"modelName",
"=",
"source_model_name",
"(",
"$",
"this",
"->",
"getNodeTypeName",
"(",
")",
",",
"true",
")",
";",
"return",
"array_merge_recursive",
"(",
"$",
"this",
"->",
"searchable",
",",
"call_user_func",
"(",
"[",
"$",
"modelName",
",",
"'getSearchable'",
"]",
")",
")",
";",
"}"
] |
It returns the searchable
@return array
|
[
"It",
"returns",
"the",
"searchable"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L1333-L1347
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.