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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
223,200
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
|
ClassMetadataFactory.addInheritedNamedQueries
|
private function addInheritedNamedQueries(ClassMetadata $subClass, ClassMetadata $parentClass)
{
foreach ($parentClass->namedQueries as $name => $query) {
if ( ! isset ($subClass->namedQueries[$name])) {
$subClass->addNamedQuery(array(
'name' => $query['name'],
'query' => $query['query']
));
}
}
}
|
php
|
private function addInheritedNamedQueries(ClassMetadata $subClass, ClassMetadata $parentClass)
{
foreach ($parentClass->namedQueries as $name => $query) {
if ( ! isset ($subClass->namedQueries[$name])) {
$subClass->addNamedQuery(array(
'name' => $query['name'],
'query' => $query['query']
));
}
}
}
|
[
"private",
"function",
"addInheritedNamedQueries",
"(",
"ClassMetadata",
"$",
"subClass",
",",
"ClassMetadata",
"$",
"parentClass",
")",
"{",
"foreach",
"(",
"$",
"parentClass",
"->",
"namedQueries",
"as",
"$",
"name",
"=>",
"$",
"query",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"subClass",
"->",
"namedQueries",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"subClass",
"->",
"addNamedQuery",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"query",
"[",
"'name'",
"]",
",",
"'query'",
"=>",
"$",
"query",
"[",
"'query'",
"]",
")",
")",
";",
"}",
"}",
"}"
] |
Adds inherited named queries to the subclass mapping.
@since 2.2
@param \Doctrine\ORM\Mapping\ClassMetadata $subClass
@param \Doctrine\ORM\Mapping\ClassMetadata $parentClass
@return void
|
[
"Adds",
"inherited",
"named",
"queries",
"to",
"the",
"subclass",
"mapping",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php#L532-L542
|
223,201
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
|
ClassMetadataFactory.addInheritedNamedNativeQueries
|
private function addInheritedNamedNativeQueries(ClassMetadata $subClass, ClassMetadata $parentClass)
{
foreach ($parentClass->namedNativeQueries as $name => $query) {
if ( ! isset ($subClass->namedNativeQueries[$name])) {
$subClass->addNamedNativeQuery(array(
'name' => $query['name'],
'query' => $query['query'],
'isSelfClass' => $query['isSelfClass'],
'resultSetMapping' => $query['resultSetMapping'],
'resultClass' => $query['isSelfClass'] ? $subClass->name : $query['resultClass'],
));
}
}
}
|
php
|
private function addInheritedNamedNativeQueries(ClassMetadata $subClass, ClassMetadata $parentClass)
{
foreach ($parentClass->namedNativeQueries as $name => $query) {
if ( ! isset ($subClass->namedNativeQueries[$name])) {
$subClass->addNamedNativeQuery(array(
'name' => $query['name'],
'query' => $query['query'],
'isSelfClass' => $query['isSelfClass'],
'resultSetMapping' => $query['resultSetMapping'],
'resultClass' => $query['isSelfClass'] ? $subClass->name : $query['resultClass'],
));
}
}
}
|
[
"private",
"function",
"addInheritedNamedNativeQueries",
"(",
"ClassMetadata",
"$",
"subClass",
",",
"ClassMetadata",
"$",
"parentClass",
")",
"{",
"foreach",
"(",
"$",
"parentClass",
"->",
"namedNativeQueries",
"as",
"$",
"name",
"=>",
"$",
"query",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"subClass",
"->",
"namedNativeQueries",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"subClass",
"->",
"addNamedNativeQuery",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"query",
"[",
"'name'",
"]",
",",
"'query'",
"=>",
"$",
"query",
"[",
"'query'",
"]",
",",
"'isSelfClass'",
"=>",
"$",
"query",
"[",
"'isSelfClass'",
"]",
",",
"'resultSetMapping'",
"=>",
"$",
"query",
"[",
"'resultSetMapping'",
"]",
",",
"'resultClass'",
"=>",
"$",
"query",
"[",
"'isSelfClass'",
"]",
"?",
"$",
"subClass",
"->",
"name",
":",
"$",
"query",
"[",
"'resultClass'",
"]",
",",
")",
")",
";",
"}",
"}",
"}"
] |
Adds inherited named native queries to the subclass mapping.
@since 2.3
@param \Doctrine\ORM\Mapping\ClassMetadata $subClass
@param \Doctrine\ORM\Mapping\ClassMetadata $parentClass
@return void
|
[
"Adds",
"inherited",
"named",
"native",
"queries",
"to",
"the",
"subclass",
"mapping",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php#L554-L567
|
223,202
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
|
ClassMetadataFactory.addInheritedSqlResultSetMappings
|
private function addInheritedSqlResultSetMappings(ClassMetadata $subClass, ClassMetadata $parentClass)
{
foreach ($parentClass->sqlResultSetMappings as $name => $mapping) {
if ( ! isset ($subClass->sqlResultSetMappings[$name])) {
$entities = array();
foreach ($mapping['entities'] as $entity) {
$entities[] = array(
'fields' => $entity['fields'],
'isSelfClass' => $entity['isSelfClass'],
'discriminatorColumn' => $entity['discriminatorColumn'],
'entityClass' => $entity['isSelfClass'] ? $subClass->name : $entity['entityClass'],
);
}
$subClass->addSqlResultSetMapping(array(
'name' => $mapping['name'],
'columns' => $mapping['columns'],
'entities' => $entities,
));
}
}
}
|
php
|
private function addInheritedSqlResultSetMappings(ClassMetadata $subClass, ClassMetadata $parentClass)
{
foreach ($parentClass->sqlResultSetMappings as $name => $mapping) {
if ( ! isset ($subClass->sqlResultSetMappings[$name])) {
$entities = array();
foreach ($mapping['entities'] as $entity) {
$entities[] = array(
'fields' => $entity['fields'],
'isSelfClass' => $entity['isSelfClass'],
'discriminatorColumn' => $entity['discriminatorColumn'],
'entityClass' => $entity['isSelfClass'] ? $subClass->name : $entity['entityClass'],
);
}
$subClass->addSqlResultSetMapping(array(
'name' => $mapping['name'],
'columns' => $mapping['columns'],
'entities' => $entities,
));
}
}
}
|
[
"private",
"function",
"addInheritedSqlResultSetMappings",
"(",
"ClassMetadata",
"$",
"subClass",
",",
"ClassMetadata",
"$",
"parentClass",
")",
"{",
"foreach",
"(",
"$",
"parentClass",
"->",
"sqlResultSetMappings",
"as",
"$",
"name",
"=>",
"$",
"mapping",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"subClass",
"->",
"sqlResultSetMappings",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"entities",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"mapping",
"[",
"'entities'",
"]",
"as",
"$",
"entity",
")",
"{",
"$",
"entities",
"[",
"]",
"=",
"array",
"(",
"'fields'",
"=>",
"$",
"entity",
"[",
"'fields'",
"]",
",",
"'isSelfClass'",
"=>",
"$",
"entity",
"[",
"'isSelfClass'",
"]",
",",
"'discriminatorColumn'",
"=>",
"$",
"entity",
"[",
"'discriminatorColumn'",
"]",
",",
"'entityClass'",
"=>",
"$",
"entity",
"[",
"'isSelfClass'",
"]",
"?",
"$",
"subClass",
"->",
"name",
":",
"$",
"entity",
"[",
"'entityClass'",
"]",
",",
")",
";",
"}",
"$",
"subClass",
"->",
"addSqlResultSetMapping",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"mapping",
"[",
"'name'",
"]",
",",
"'columns'",
"=>",
"$",
"mapping",
"[",
"'columns'",
"]",
",",
"'entities'",
"=>",
"$",
"entities",
",",
")",
")",
";",
"}",
"}",
"}"
] |
Adds inherited sql result set mappings to the subclass mapping.
@since 2.3
@param \Doctrine\ORM\Mapping\ClassMetadata $subClass
@param \Doctrine\ORM\Mapping\ClassMetadata $parentClass
@return void
|
[
"Adds",
"inherited",
"sql",
"result",
"set",
"mappings",
"to",
"the",
"subclass",
"mapping",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php#L579-L600
|
223,203
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Query/Parser.php
|
Parser.isInternalFunction
|
static public function isInternalFunction($functionName)
{
$functionName = strtolower($functionName);
return isset(self::$_STRING_FUNCTIONS[$functionName])
|| isset(self::$_DATETIME_FUNCTIONS[$functionName])
|| isset(self::$_NUMERIC_FUNCTIONS[$functionName]);
}
|
php
|
static public function isInternalFunction($functionName)
{
$functionName = strtolower($functionName);
return isset(self::$_STRING_FUNCTIONS[$functionName])
|| isset(self::$_DATETIME_FUNCTIONS[$functionName])
|| isset(self::$_NUMERIC_FUNCTIONS[$functionName]);
}
|
[
"static",
"public",
"function",
"isInternalFunction",
"(",
"$",
"functionName",
")",
"{",
"$",
"functionName",
"=",
"strtolower",
"(",
"$",
"functionName",
")",
";",
"return",
"isset",
"(",
"self",
"::",
"$",
"_STRING_FUNCTIONS",
"[",
"$",
"functionName",
"]",
")",
"||",
"isset",
"(",
"self",
"::",
"$",
"_DATETIME_FUNCTIONS",
"[",
"$",
"functionName",
"]",
")",
"||",
"isset",
"(",
"self",
"::",
"$",
"_NUMERIC_FUNCTIONS",
"[",
"$",
"functionName",
"]",
")",
";",
"}"
] |
Checks if a function is internally defined. Used to prevent overwriting
of built-in functions through user-defined functions.
@param string $functionName
@return bool
|
[
"Checks",
"if",
"a",
"function",
"is",
"internally",
"defined",
".",
"Used",
"to",
"prevent",
"overwriting",
"of",
"built",
"-",
"in",
"functions",
"through",
"user",
"-",
"defined",
"functions",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Query/Parser.php#L181-L188
|
223,204
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Query/Parser.php
|
Parser.getAST
|
public function getAST()
{
// Parse & build AST
$AST = $this->QueryLanguage();
// Process any deferred validations of some nodes in the AST.
// This also allows post-processing of the AST for modification purposes.
$this->processDeferredIdentificationVariables();
if ($this->deferredPartialObjectExpressions) {
$this->processDeferredPartialObjectExpressions();
}
if ($this->deferredPathExpressions) {
$this->processDeferredPathExpressions($AST);
}
if ($this->deferredResultVariables) {
$this->processDeferredResultVariables();
}
if ($this->deferredNewObjectExpressions) {
$this->processDeferredNewObjectExpressions($AST);
}
$this->processRootEntityAliasSelected();
// TODO: Is there a way to remove this? It may impact the mixed hydration resultset a lot!
$this->fixIdentificationVariableOrder($AST);
return $AST;
}
|
php
|
public function getAST()
{
// Parse & build AST
$AST = $this->QueryLanguage();
// Process any deferred validations of some nodes in the AST.
// This also allows post-processing of the AST for modification purposes.
$this->processDeferredIdentificationVariables();
if ($this->deferredPartialObjectExpressions) {
$this->processDeferredPartialObjectExpressions();
}
if ($this->deferredPathExpressions) {
$this->processDeferredPathExpressions($AST);
}
if ($this->deferredResultVariables) {
$this->processDeferredResultVariables();
}
if ($this->deferredNewObjectExpressions) {
$this->processDeferredNewObjectExpressions($AST);
}
$this->processRootEntityAliasSelected();
// TODO: Is there a way to remove this? It may impact the mixed hydration resultset a lot!
$this->fixIdentificationVariableOrder($AST);
return $AST;
}
|
[
"public",
"function",
"getAST",
"(",
")",
"{",
"// Parse & build AST",
"$",
"AST",
"=",
"$",
"this",
"->",
"QueryLanguage",
"(",
")",
";",
"// Process any deferred validations of some nodes in the AST.",
"// This also allows post-processing of the AST for modification purposes.",
"$",
"this",
"->",
"processDeferredIdentificationVariables",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"deferredPartialObjectExpressions",
")",
"{",
"$",
"this",
"->",
"processDeferredPartialObjectExpressions",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"deferredPathExpressions",
")",
"{",
"$",
"this",
"->",
"processDeferredPathExpressions",
"(",
"$",
"AST",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"deferredResultVariables",
")",
"{",
"$",
"this",
"->",
"processDeferredResultVariables",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"deferredNewObjectExpressions",
")",
"{",
"$",
"this",
"->",
"processDeferredNewObjectExpressions",
"(",
"$",
"AST",
")",
";",
"}",
"$",
"this",
"->",
"processRootEntityAliasSelected",
"(",
")",
";",
"// TODO: Is there a way to remove this? It may impact the mixed hydration resultset a lot!",
"$",
"this",
"->",
"fixIdentificationVariableOrder",
"(",
"$",
"AST",
")",
";",
"return",
"$",
"AST",
";",
"}"
] |
Parses and builds AST for the given Query.
@return \Doctrine\ORM\Query\AST\SelectStatement |
\Doctrine\ORM\Query\AST\UpdateStatement |
\Doctrine\ORM\Query\AST\DeleteStatement
|
[
"Parses",
"and",
"builds",
"AST",
"for",
"the",
"given",
"Query",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Query/Parser.php#L265-L296
|
223,205
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Query/Parser.php
|
Parser.parse
|
public function parse()
{
$AST = $this->getAST();
if (($customWalkers = $this->query->getHint(Query::HINT_CUSTOM_TREE_WALKERS)) !== false) {
$this->customTreeWalkers = $customWalkers;
}
if (($customOutputWalker = $this->query->getHint(Query::HINT_CUSTOM_OUTPUT_WALKER)) !== false) {
$this->customOutputWalker = $customOutputWalker;
}
// Run any custom tree walkers over the AST
if ($this->customTreeWalkers) {
$treeWalkerChain = new TreeWalkerChain($this->query, $this->parserResult, $this->queryComponents);
foreach ($this->customTreeWalkers as $walker) {
$treeWalkerChain->addTreeWalker($walker);
}
switch (true) {
case ($AST instanceof AST\UpdateStatement):
$treeWalkerChain->walkUpdateStatement($AST);
break;
case ($AST instanceof AST\DeleteStatement):
$treeWalkerChain->walkDeleteStatement($AST);
break;
case ($AST instanceof AST\SelectStatement):
default:
$treeWalkerChain->walkSelectStatement($AST);
}
$this->queryComponents = $treeWalkerChain->getQueryComponents();
}
$outputWalkerClass = $this->customOutputWalker ?: __NAMESPACE__ . '\SqlWalker';
$outputWalker = new $outputWalkerClass($this->query, $this->parserResult, $this->queryComponents);
// Assign an SQL executor to the parser result
$this->parserResult->setSqlExecutor($outputWalker->getExecutor($AST));
return $this->parserResult;
}
|
php
|
public function parse()
{
$AST = $this->getAST();
if (($customWalkers = $this->query->getHint(Query::HINT_CUSTOM_TREE_WALKERS)) !== false) {
$this->customTreeWalkers = $customWalkers;
}
if (($customOutputWalker = $this->query->getHint(Query::HINT_CUSTOM_OUTPUT_WALKER)) !== false) {
$this->customOutputWalker = $customOutputWalker;
}
// Run any custom tree walkers over the AST
if ($this->customTreeWalkers) {
$treeWalkerChain = new TreeWalkerChain($this->query, $this->parserResult, $this->queryComponents);
foreach ($this->customTreeWalkers as $walker) {
$treeWalkerChain->addTreeWalker($walker);
}
switch (true) {
case ($AST instanceof AST\UpdateStatement):
$treeWalkerChain->walkUpdateStatement($AST);
break;
case ($AST instanceof AST\DeleteStatement):
$treeWalkerChain->walkDeleteStatement($AST);
break;
case ($AST instanceof AST\SelectStatement):
default:
$treeWalkerChain->walkSelectStatement($AST);
}
$this->queryComponents = $treeWalkerChain->getQueryComponents();
}
$outputWalkerClass = $this->customOutputWalker ?: __NAMESPACE__ . '\SqlWalker';
$outputWalker = new $outputWalkerClass($this->query, $this->parserResult, $this->queryComponents);
// Assign an SQL executor to the parser result
$this->parserResult->setSqlExecutor($outputWalker->getExecutor($AST));
return $this->parserResult;
}
|
[
"public",
"function",
"parse",
"(",
")",
"{",
"$",
"AST",
"=",
"$",
"this",
"->",
"getAST",
"(",
")",
";",
"if",
"(",
"(",
"$",
"customWalkers",
"=",
"$",
"this",
"->",
"query",
"->",
"getHint",
"(",
"Query",
"::",
"HINT_CUSTOM_TREE_WALKERS",
")",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"customTreeWalkers",
"=",
"$",
"customWalkers",
";",
"}",
"if",
"(",
"(",
"$",
"customOutputWalker",
"=",
"$",
"this",
"->",
"query",
"->",
"getHint",
"(",
"Query",
"::",
"HINT_CUSTOM_OUTPUT_WALKER",
")",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"customOutputWalker",
"=",
"$",
"customOutputWalker",
";",
"}",
"// Run any custom tree walkers over the AST",
"if",
"(",
"$",
"this",
"->",
"customTreeWalkers",
")",
"{",
"$",
"treeWalkerChain",
"=",
"new",
"TreeWalkerChain",
"(",
"$",
"this",
"->",
"query",
",",
"$",
"this",
"->",
"parserResult",
",",
"$",
"this",
"->",
"queryComponents",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"customTreeWalkers",
"as",
"$",
"walker",
")",
"{",
"$",
"treeWalkerChain",
"->",
"addTreeWalker",
"(",
"$",
"walker",
")",
";",
"}",
"switch",
"(",
"true",
")",
"{",
"case",
"(",
"$",
"AST",
"instanceof",
"AST",
"\\",
"UpdateStatement",
")",
":",
"$",
"treeWalkerChain",
"->",
"walkUpdateStatement",
"(",
"$",
"AST",
")",
";",
"break",
";",
"case",
"(",
"$",
"AST",
"instanceof",
"AST",
"\\",
"DeleteStatement",
")",
":",
"$",
"treeWalkerChain",
"->",
"walkDeleteStatement",
"(",
"$",
"AST",
")",
";",
"break",
";",
"case",
"(",
"$",
"AST",
"instanceof",
"AST",
"\\",
"SelectStatement",
")",
":",
"default",
":",
"$",
"treeWalkerChain",
"->",
"walkSelectStatement",
"(",
"$",
"AST",
")",
";",
"}",
"$",
"this",
"->",
"queryComponents",
"=",
"$",
"treeWalkerChain",
"->",
"getQueryComponents",
"(",
")",
";",
"}",
"$",
"outputWalkerClass",
"=",
"$",
"this",
"->",
"customOutputWalker",
"?",
":",
"__NAMESPACE__",
".",
"'\\SqlWalker'",
";",
"$",
"outputWalker",
"=",
"new",
"$",
"outputWalkerClass",
"(",
"$",
"this",
"->",
"query",
",",
"$",
"this",
"->",
"parserResult",
",",
"$",
"this",
"->",
"queryComponents",
")",
";",
"// Assign an SQL executor to the parser result",
"$",
"this",
"->",
"parserResult",
"->",
"setSqlExecutor",
"(",
"$",
"outputWalker",
"->",
"getExecutor",
"(",
"$",
"AST",
")",
")",
";",
"return",
"$",
"this",
"->",
"parserResult",
";",
"}"
] |
Parses a query string.
@return ParserResult
|
[
"Parses",
"a",
"query",
"string",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Query/Parser.php#L349-L393
|
223,206
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Query/Parser.php
|
Parser.fixIdentificationVariableOrder
|
private function fixIdentificationVariableOrder($AST)
{
if (count($this->identVariableExpressions) <= 1) {
return;
}
foreach ($this->queryComponents as $dqlAlias => $qComp) {
if ( ! isset($this->identVariableExpressions[$dqlAlias])) {
continue;
}
$expr = $this->identVariableExpressions[$dqlAlias];
$key = array_search($expr, $AST->selectClause->selectExpressions);
unset($AST->selectClause->selectExpressions[$key]);
$AST->selectClause->selectExpressions[] = $expr;
}
}
|
php
|
private function fixIdentificationVariableOrder($AST)
{
if (count($this->identVariableExpressions) <= 1) {
return;
}
foreach ($this->queryComponents as $dqlAlias => $qComp) {
if ( ! isset($this->identVariableExpressions[$dqlAlias])) {
continue;
}
$expr = $this->identVariableExpressions[$dqlAlias];
$key = array_search($expr, $AST->selectClause->selectExpressions);
unset($AST->selectClause->selectExpressions[$key]);
$AST->selectClause->selectExpressions[] = $expr;
}
}
|
[
"private",
"function",
"fixIdentificationVariableOrder",
"(",
"$",
"AST",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"identVariableExpressions",
")",
"<=",
"1",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"queryComponents",
"as",
"$",
"dqlAlias",
"=>",
"$",
"qComp",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"identVariableExpressions",
"[",
"$",
"dqlAlias",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"expr",
"=",
"$",
"this",
"->",
"identVariableExpressions",
"[",
"$",
"dqlAlias",
"]",
";",
"$",
"key",
"=",
"array_search",
"(",
"$",
"expr",
",",
"$",
"AST",
"->",
"selectClause",
"->",
"selectExpressions",
")",
";",
"unset",
"(",
"$",
"AST",
"->",
"selectClause",
"->",
"selectExpressions",
"[",
"$",
"key",
"]",
")",
";",
"$",
"AST",
"->",
"selectClause",
"->",
"selectExpressions",
"[",
"]",
"=",
"$",
"expr",
";",
"}",
"}"
] |
Fixes order of identification variables.
They have to appear in the select clause in the same order as the
declarations (from ... x join ... y join ... z ...) appear in the query
as the hydration process relies on that order for proper operation.
@param AST\SelectStatement|AST\DeleteStatement|AST\UpdateStatement $AST
@return void
|
[
"Fixes",
"order",
"of",
"identification",
"variables",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Query/Parser.php#L406-L424
|
223,207
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Query/Parser.php
|
Parser.isAggregateFunction
|
private function isAggregateFunction($tokenType)
{
return in_array($tokenType, array(Lexer::T_AVG, Lexer::T_MIN, Lexer::T_MAX, Lexer::T_SUM, Lexer::T_COUNT));
}
|
php
|
private function isAggregateFunction($tokenType)
{
return in_array($tokenType, array(Lexer::T_AVG, Lexer::T_MIN, Lexer::T_MAX, Lexer::T_SUM, Lexer::T_COUNT));
}
|
[
"private",
"function",
"isAggregateFunction",
"(",
"$",
"tokenType",
")",
"{",
"return",
"in_array",
"(",
"$",
"tokenType",
",",
"array",
"(",
"Lexer",
"::",
"T_AVG",
",",
"Lexer",
"::",
"T_MIN",
",",
"Lexer",
"::",
"T_MAX",
",",
"Lexer",
"::",
"T_SUM",
",",
"Lexer",
"::",
"T_COUNT",
")",
")",
";",
"}"
] |
Checks whether the given token type indicates an aggregate function.
@param int $tokenType
@return boolean TRUE if the token type is an aggregate function, FALSE otherwise.
|
[
"Checks",
"whether",
"the",
"given",
"token",
"type",
"indicates",
"an",
"aggregate",
"function",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Query/Parser.php#L556-L559
|
223,208
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Query/Parser.php
|
Parser.isNextAllAnySome
|
private function isNextAllAnySome()
{
return in_array($this->lexer->lookahead['type'], array(Lexer::T_ALL, Lexer::T_ANY, Lexer::T_SOME));
}
|
php
|
private function isNextAllAnySome()
{
return in_array($this->lexer->lookahead['type'], array(Lexer::T_ALL, Lexer::T_ANY, Lexer::T_SOME));
}
|
[
"private",
"function",
"isNextAllAnySome",
"(",
")",
"{",
"return",
"in_array",
"(",
"$",
"this",
"->",
"lexer",
"->",
"lookahead",
"[",
"'type'",
"]",
",",
"array",
"(",
"Lexer",
"::",
"T_ALL",
",",
"Lexer",
"::",
"T_ANY",
",",
"Lexer",
"::",
"T_SOME",
")",
")",
";",
"}"
] |
Checks whether the current lookahead token of the lexer has the type T_ALL, T_ANY or T_SOME.
@return boolean
|
[
"Checks",
"whether",
"the",
"current",
"lookahead",
"token",
"of",
"the",
"lexer",
"has",
"the",
"type",
"T_ALL",
"T_ANY",
"or",
"T_SOME",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Query/Parser.php#L566-L569
|
223,209
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Query/Parser.php
|
Parser.PathExpression
|
public function PathExpression($expectedTypes)
{
$identVariable = $this->IdentificationVariable();
$field = null;
if ($this->lexer->isNextToken(Lexer::T_DOT)) {
$this->match(Lexer::T_DOT);
$this->match(Lexer::T_IDENTIFIER);
$field = $this->lexer->token['value'];
while ($this->lexer->isNextToken(Lexer::T_DOT)) {
$this->match(Lexer::T_DOT);
$this->match(Lexer::T_IDENTIFIER);
$field .= '.'.$this->lexer->token['value'];
}
}
// Creating AST node
$pathExpr = new AST\PathExpression($expectedTypes, $identVariable, $field);
// Defer PathExpression validation if requested to be deferred
$this->deferredPathExpressions[] = array(
'expression' => $pathExpr,
'nestingLevel' => $this->nestingLevel,
'token' => $this->lexer->token,
);
return $pathExpr;
}
|
php
|
public function PathExpression($expectedTypes)
{
$identVariable = $this->IdentificationVariable();
$field = null;
if ($this->lexer->isNextToken(Lexer::T_DOT)) {
$this->match(Lexer::T_DOT);
$this->match(Lexer::T_IDENTIFIER);
$field = $this->lexer->token['value'];
while ($this->lexer->isNextToken(Lexer::T_DOT)) {
$this->match(Lexer::T_DOT);
$this->match(Lexer::T_IDENTIFIER);
$field .= '.'.$this->lexer->token['value'];
}
}
// Creating AST node
$pathExpr = new AST\PathExpression($expectedTypes, $identVariable, $field);
// Defer PathExpression validation if requested to be deferred
$this->deferredPathExpressions[] = array(
'expression' => $pathExpr,
'nestingLevel' => $this->nestingLevel,
'token' => $this->lexer->token,
);
return $pathExpr;
}
|
[
"public",
"function",
"PathExpression",
"(",
"$",
"expectedTypes",
")",
"{",
"$",
"identVariable",
"=",
"$",
"this",
"->",
"IdentificationVariable",
"(",
")",
";",
"$",
"field",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"lexer",
"->",
"isNextToken",
"(",
"Lexer",
"::",
"T_DOT",
")",
")",
"{",
"$",
"this",
"->",
"match",
"(",
"Lexer",
"::",
"T_DOT",
")",
";",
"$",
"this",
"->",
"match",
"(",
"Lexer",
"::",
"T_IDENTIFIER",
")",
";",
"$",
"field",
"=",
"$",
"this",
"->",
"lexer",
"->",
"token",
"[",
"'value'",
"]",
";",
"while",
"(",
"$",
"this",
"->",
"lexer",
"->",
"isNextToken",
"(",
"Lexer",
"::",
"T_DOT",
")",
")",
"{",
"$",
"this",
"->",
"match",
"(",
"Lexer",
"::",
"T_DOT",
")",
";",
"$",
"this",
"->",
"match",
"(",
"Lexer",
"::",
"T_IDENTIFIER",
")",
";",
"$",
"field",
".=",
"'.'",
".",
"$",
"this",
"->",
"lexer",
"->",
"token",
"[",
"'value'",
"]",
";",
"}",
"}",
"// Creating AST node",
"$",
"pathExpr",
"=",
"new",
"AST",
"\\",
"PathExpression",
"(",
"$",
"expectedTypes",
",",
"$",
"identVariable",
",",
"$",
"field",
")",
";",
"// Defer PathExpression validation if requested to be deferred",
"$",
"this",
"->",
"deferredPathExpressions",
"[",
"]",
"=",
"array",
"(",
"'expression'",
"=>",
"$",
"pathExpr",
",",
"'nestingLevel'",
"=>",
"$",
"this",
"->",
"nestingLevel",
",",
"'token'",
"=>",
"$",
"this",
"->",
"lexer",
"->",
"token",
",",
")",
";",
"return",
"$",
"pathExpr",
";",
"}"
] |
Parses an arbitrary path expression and defers semantical validation
based on expected types.
PathExpression ::= IdentificationVariable {"." identifier}*
@param integer $expectedTypes
@return \Doctrine\ORM\Query\AST\PathExpression
|
[
"Parses",
"an",
"arbitrary",
"path",
"expression",
"and",
"defers",
"semantical",
"validation",
"based",
"on",
"expected",
"types",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Query/Parser.php#L1058-L1087
|
223,210
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Query/Parser.php
|
Parser.CustomFunctionDeclaration
|
private function CustomFunctionDeclaration()
{
$token = $this->lexer->lookahead;
$funcName = strtolower($token['value']);
// Check for custom functions afterwards
$config = $this->em->getConfiguration();
switch (true) {
case ($config->getCustomStringFunction($funcName) !== null):
return $this->CustomFunctionsReturningStrings();
case ($config->getCustomNumericFunction($funcName) !== null):
return $this->CustomFunctionsReturningNumerics();
case ($config->getCustomDatetimeFunction($funcName) !== null):
return $this->CustomFunctionsReturningDatetime();
default:
$this->syntaxError('known function', $token);
}
}
|
php
|
private function CustomFunctionDeclaration()
{
$token = $this->lexer->lookahead;
$funcName = strtolower($token['value']);
// Check for custom functions afterwards
$config = $this->em->getConfiguration();
switch (true) {
case ($config->getCustomStringFunction($funcName) !== null):
return $this->CustomFunctionsReturningStrings();
case ($config->getCustomNumericFunction($funcName) !== null):
return $this->CustomFunctionsReturningNumerics();
case ($config->getCustomDatetimeFunction($funcName) !== null):
return $this->CustomFunctionsReturningDatetime();
default:
$this->syntaxError('known function', $token);
}
}
|
[
"private",
"function",
"CustomFunctionDeclaration",
"(",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"lexer",
"->",
"lookahead",
";",
"$",
"funcName",
"=",
"strtolower",
"(",
"$",
"token",
"[",
"'value'",
"]",
")",
";",
"// Check for custom functions afterwards",
"$",
"config",
"=",
"$",
"this",
"->",
"em",
"->",
"getConfiguration",
"(",
")",
";",
"switch",
"(",
"true",
")",
"{",
"case",
"(",
"$",
"config",
"->",
"getCustomStringFunction",
"(",
"$",
"funcName",
")",
"!==",
"null",
")",
":",
"return",
"$",
"this",
"->",
"CustomFunctionsReturningStrings",
"(",
")",
";",
"case",
"(",
"$",
"config",
"->",
"getCustomNumericFunction",
"(",
"$",
"funcName",
")",
"!==",
"null",
")",
":",
"return",
"$",
"this",
"->",
"CustomFunctionsReturningNumerics",
"(",
")",
";",
"case",
"(",
"$",
"config",
"->",
"getCustomDatetimeFunction",
"(",
"$",
"funcName",
")",
"!==",
"null",
")",
":",
"return",
"$",
"this",
"->",
"CustomFunctionsReturningDatetime",
"(",
")",
";",
"default",
":",
"$",
"this",
"->",
"syntaxError",
"(",
"'known function'",
",",
"$",
"token",
")",
";",
"}",
"}"
] |
Helper function for FunctionDeclaration grammar rule.
@return \Doctrine\ORM\Query\AST\Functions\FunctionNode
|
[
"Helper",
"function",
"for",
"FunctionDeclaration",
"grammar",
"rule",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Query/Parser.php#L3360-L3381
|
223,211
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Query/FilterCollection.php
|
FilterCollection.getFilter
|
public function getFilter($name)
{
if ( ! $this->isEnabled($name)) {
throw new \InvalidArgumentException("Filter '" . $name . "' is not enabled.");
}
return $this->enabledFilters[$name];
}
|
php
|
public function getFilter($name)
{
if ( ! $this->isEnabled($name)) {
throw new \InvalidArgumentException("Filter '" . $name . "' is not enabled.");
}
return $this->enabledFilters[$name];
}
|
[
"public",
"function",
"getFilter",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isEnabled",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Filter '\"",
".",
"$",
"name",
".",
"\"' is not enabled.\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"enabledFilters",
"[",
"$",
"name",
"]",
";",
"}"
] |
Gets an enabled filter from the collection.
@param string $name Name of the filter.
@return \Doctrine\ORM\Query\Filter\SQLFilter The filter.
@throws \InvalidArgumentException If the filter is not enabled.
|
[
"Gets",
"an",
"enabled",
"filter",
"from",
"the",
"collection",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Query/FilterCollection.php#L156-L163
|
223,212
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Query/FilterCollection.php
|
FilterCollection.getHash
|
public function getHash()
{
// If there are only clean filters, the previous hash can be returned
if (self::FILTERS_STATE_CLEAN === $this->filtersState) {
return $this->filterHash;
}
$filterHash = '';
foreach ($this->enabledFilters as $name => $filter) {
$filterHash .= $name . $filter;
}
return $filterHash;
}
|
php
|
public function getHash()
{
// If there are only clean filters, the previous hash can be returned
if (self::FILTERS_STATE_CLEAN === $this->filtersState) {
return $this->filterHash;
}
$filterHash = '';
foreach ($this->enabledFilters as $name => $filter) {
$filterHash .= $name . $filter;
}
return $filterHash;
}
|
[
"public",
"function",
"getHash",
"(",
")",
"{",
"// If there are only clean filters, the previous hash can be returned",
"if",
"(",
"self",
"::",
"FILTERS_STATE_CLEAN",
"===",
"$",
"this",
"->",
"filtersState",
")",
"{",
"return",
"$",
"this",
"->",
"filterHash",
";",
"}",
"$",
"filterHash",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"enabledFilters",
"as",
"$",
"name",
"=>",
"$",
"filter",
")",
"{",
"$",
"filterHash",
".=",
"$",
"name",
".",
"$",
"filter",
";",
"}",
"return",
"$",
"filterHash",
";",
"}"
] |
Generates a string of currently enabled filters to use for the cache id.
@return string
|
[
"Generates",
"a",
"string",
"of",
"currently",
"enabled",
"filters",
"to",
"use",
"for",
"the",
"cache",
"id",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Query/FilterCollection.php#L202-L216
|
223,213
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/Builder/EntityListenerBuilder.php
|
EntityListenerBuilder.bindEntityListener
|
static public function bindEntityListener(ClassMetadata $metadata, $className)
{
$class = $metadata->fullyQualifiedClassName($className);
if ( ! class_exists($class)) {
throw MappingException::entityListenerClassNotFound($class, $className);
}
foreach (get_class_methods($class) as $method) {
if ( ! isset(self::$events[$method])) {
continue;
}
$metadata->addEntityListener($method, $class, $method);
}
}
|
php
|
static public function bindEntityListener(ClassMetadata $metadata, $className)
{
$class = $metadata->fullyQualifiedClassName($className);
if ( ! class_exists($class)) {
throw MappingException::entityListenerClassNotFound($class, $className);
}
foreach (get_class_methods($class) as $method) {
if ( ! isset(self::$events[$method])) {
continue;
}
$metadata->addEntityListener($method, $class, $method);
}
}
|
[
"static",
"public",
"function",
"bindEntityListener",
"(",
"ClassMetadata",
"$",
"metadata",
",",
"$",
"className",
")",
"{",
"$",
"class",
"=",
"$",
"metadata",
"->",
"fullyQualifiedClassName",
"(",
"$",
"className",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"MappingException",
"::",
"entityListenerClassNotFound",
"(",
"$",
"class",
",",
"$",
"className",
")",
";",
"}",
"foreach",
"(",
"get_class_methods",
"(",
"$",
"class",
")",
"as",
"$",
"method",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"events",
"[",
"$",
"method",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"metadata",
"->",
"addEntityListener",
"(",
"$",
"method",
",",
"$",
"class",
",",
"$",
"method",
")",
";",
"}",
"}"
] |
Lookup the entity class to find methods that match to event lifecycle names
@param \Doctrine\ORM\Mapping\ClassMetadata $metadata The entity metadata.
@param string $className The listener class name.
@throws \Doctrine\ORM\Mapping\MappingException When the listener class not found.
|
[
"Lookup",
"the",
"entity",
"class",
"to",
"find",
"methods",
"that",
"match",
"to",
"event",
"lifecycle",
"names"
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Builder/EntityListenerBuilder.php#L56-L71
|
223,214
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Cache/EntityCacheEntry.php
|
EntityCacheEntry.resolveAssociationEntries
|
public function resolveAssociationEntries(EntityManagerInterface $em)
{
return array_map(function($value) use ($em) {
if ( ! ($value instanceof AssociationCacheEntry)) {
return $value;
}
return $em->getReference($value->class, $value->identifier);
}, $this->data);
}
|
php
|
public function resolveAssociationEntries(EntityManagerInterface $em)
{
return array_map(function($value) use ($em) {
if ( ! ($value instanceof AssociationCacheEntry)) {
return $value;
}
return $em->getReference($value->class, $value->identifier);
}, $this->data);
}
|
[
"public",
"function",
"resolveAssociationEntries",
"(",
"EntityManagerInterface",
"$",
"em",
")",
"{",
"return",
"array_map",
"(",
"function",
"(",
"$",
"value",
")",
"use",
"(",
"$",
"em",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"value",
"instanceof",
"AssociationCacheEntry",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"return",
"$",
"em",
"->",
"getReference",
"(",
"$",
"value",
"->",
"class",
",",
"$",
"value",
"->",
"identifier",
")",
";",
"}",
",",
"$",
"this",
"->",
"data",
")",
";",
"}"
] |
Retrieves the entity data resolving cache entries
@param \Doctrine\ORM\EntityManagerInterfac $em
@return array
|
[
"Retrieves",
"the",
"entity",
"data",
"resolving",
"cache",
"entries"
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Cache/EntityCacheEntry.php#L76-L85
|
223,215
|
kontoulis/rabbitmq-laravel
|
src/Broker/Broker.php
|
Broker.listenToQueue
|
public function listenToQueue(array $handlers , $routingKey = null, $options =[] )
{
/* Look for handlers */
$handlersMap = array();
foreach ($handlers as $handlerClassPath) {
if (!class_exists($handlerClassPath)) {
$handlerClassPath = "Kontoulis\\RabbitMQLaravel\\Handlers\\DefaultHandler";
if (!class_exists($handlerClassPath)) {
throw new BrokerException(
"Class $handlerClassPath was not found!"
);
}
}
$handlerOb = new $handlerClassPath();
$classPathParts = explode("\\", $handlerClassPath);
$handlersMap[$classPathParts[count($classPathParts) - 1]] = $handlerOb;
}
$this->queueDeclareBind($routingKey);
/* Start consuming */
$this->basic_qos(
(isset($options["prefetch_size"]) ? $options["prefetch_size"] : null),
(isset($options["prefetch_count"]) ? $options["prefetch_count"] : 1),
(isset($options["a_global"]) ? $options["a_global"] : null)
);
$this->basic_consume(
$routingKey,
(isset($options["consumer_tag"]) ? $options["consumer_tag"] : ''),
(isset($options["no_local"]) ? (bool)$options["no_local"] : false),
(isset($options["no_ack"]) ? (bool)$options["no_ack"] : false),
(isset($options["exclusive"]) ? (bool)$options["exclusive"] : false),
(isset($options["no_wait"]) ? (bool)$options["no_wait"] : false),
function (AMQPMessage $amqpMsg) use($handlersMap) {
$msg = Message::fromAMQPMessage($amqpMsg);
$this->handleMessage($msg, $handlersMap);
}
);
return $this->waitConsume($options);
}
|
php
|
public function listenToQueue(array $handlers , $routingKey = null, $options =[] )
{
/* Look for handlers */
$handlersMap = array();
foreach ($handlers as $handlerClassPath) {
if (!class_exists($handlerClassPath)) {
$handlerClassPath = "Kontoulis\\RabbitMQLaravel\\Handlers\\DefaultHandler";
if (!class_exists($handlerClassPath)) {
throw new BrokerException(
"Class $handlerClassPath was not found!"
);
}
}
$handlerOb = new $handlerClassPath();
$classPathParts = explode("\\", $handlerClassPath);
$handlersMap[$classPathParts[count($classPathParts) - 1]] = $handlerOb;
}
$this->queueDeclareBind($routingKey);
/* Start consuming */
$this->basic_qos(
(isset($options["prefetch_size"]) ? $options["prefetch_size"] : null),
(isset($options["prefetch_count"]) ? $options["prefetch_count"] : 1),
(isset($options["a_global"]) ? $options["a_global"] : null)
);
$this->basic_consume(
$routingKey,
(isset($options["consumer_tag"]) ? $options["consumer_tag"] : ''),
(isset($options["no_local"]) ? (bool)$options["no_local"] : false),
(isset($options["no_ack"]) ? (bool)$options["no_ack"] : false),
(isset($options["exclusive"]) ? (bool)$options["exclusive"] : false),
(isset($options["no_wait"]) ? (bool)$options["no_wait"] : false),
function (AMQPMessage $amqpMsg) use($handlersMap) {
$msg = Message::fromAMQPMessage($amqpMsg);
$this->handleMessage($msg, $handlersMap);
}
);
return $this->waitConsume($options);
}
|
[
"public",
"function",
"listenToQueue",
"(",
"array",
"$",
"handlers",
",",
"$",
"routingKey",
"=",
"null",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"/* Look for handlers */",
"$",
"handlersMap",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"handlers",
"as",
"$",
"handlerClassPath",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"handlerClassPath",
")",
")",
"{",
"$",
"handlerClassPath",
"=",
"\"Kontoulis\\\\RabbitMQLaravel\\\\Handlers\\\\DefaultHandler\"",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"handlerClassPath",
")",
")",
"{",
"throw",
"new",
"BrokerException",
"(",
"\"Class $handlerClassPath was not found!\"",
")",
";",
"}",
"}",
"$",
"handlerOb",
"=",
"new",
"$",
"handlerClassPath",
"(",
")",
";",
"$",
"classPathParts",
"=",
"explode",
"(",
"\"\\\\\"",
",",
"$",
"handlerClassPath",
")",
";",
"$",
"handlersMap",
"[",
"$",
"classPathParts",
"[",
"count",
"(",
"$",
"classPathParts",
")",
"-",
"1",
"]",
"]",
"=",
"$",
"handlerOb",
";",
"}",
"$",
"this",
"->",
"queueDeclareBind",
"(",
"$",
"routingKey",
")",
";",
"/* Start consuming */",
"$",
"this",
"->",
"basic_qos",
"(",
"(",
"isset",
"(",
"$",
"options",
"[",
"\"prefetch_size\"",
"]",
")",
"?",
"$",
"options",
"[",
"\"prefetch_size\"",
"]",
":",
"null",
")",
",",
"(",
"isset",
"(",
"$",
"options",
"[",
"\"prefetch_count\"",
"]",
")",
"?",
"$",
"options",
"[",
"\"prefetch_count\"",
"]",
":",
"1",
")",
",",
"(",
"isset",
"(",
"$",
"options",
"[",
"\"a_global\"",
"]",
")",
"?",
"$",
"options",
"[",
"\"a_global\"",
"]",
":",
"null",
")",
")",
";",
"$",
"this",
"->",
"basic_consume",
"(",
"$",
"routingKey",
",",
"(",
"isset",
"(",
"$",
"options",
"[",
"\"consumer_tag\"",
"]",
")",
"?",
"$",
"options",
"[",
"\"consumer_tag\"",
"]",
":",
"''",
")",
",",
"(",
"isset",
"(",
"$",
"options",
"[",
"\"no_local\"",
"]",
")",
"?",
"(",
"bool",
")",
"$",
"options",
"[",
"\"no_local\"",
"]",
":",
"false",
")",
",",
"(",
"isset",
"(",
"$",
"options",
"[",
"\"no_ack\"",
"]",
")",
"?",
"(",
"bool",
")",
"$",
"options",
"[",
"\"no_ack\"",
"]",
":",
"false",
")",
",",
"(",
"isset",
"(",
"$",
"options",
"[",
"\"exclusive\"",
"]",
")",
"?",
"(",
"bool",
")",
"$",
"options",
"[",
"\"exclusive\"",
"]",
":",
"false",
")",
",",
"(",
"isset",
"(",
"$",
"options",
"[",
"\"no_wait\"",
"]",
")",
"?",
"(",
"bool",
")",
"$",
"options",
"[",
"\"no_wait\"",
"]",
":",
"false",
")",
",",
"function",
"(",
"AMQPMessage",
"$",
"amqpMsg",
")",
"use",
"(",
"$",
"handlersMap",
")",
"{",
"$",
"msg",
"=",
"Message",
"::",
"fromAMQPMessage",
"(",
"$",
"amqpMsg",
")",
";",
"$",
"this",
"->",
"handleMessage",
"(",
"$",
"msg",
",",
"$",
"handlersMap",
")",
";",
"}",
")",
";",
"return",
"$",
"this",
"->",
"waitConsume",
"(",
"$",
"options",
")",
";",
"}"
] |
Starts to listen to a queue for incoming messages.
@param array $handlers Array of handler class instances
@param null $routingKey
@param array $options
@return bool
@internal param string $queueName The AMQP queue
|
[
"Starts",
"to",
"listen",
"to",
"a",
"queue",
"for",
"incoming",
"messages",
"."
] |
f677b3b447be63dd14732309193d26c3b841c5fc
|
https://github.com/kontoulis/rabbitmq-laravel/blob/f677b3b447be63dd14732309193d26c3b841c5fc/src/Broker/Broker.php#L176-L214
|
223,216
|
mespronos/mespronos
|
src/Entity/Getters/LeagueGettersTrait.php
|
LeagueGettersTrait.getDays
|
public function getDays() {
$query = \Drupal::entityQuery('day');
$query->condition('league', $this->id());
$query->sort('id', 'ASC');
$ids = $query->execute();
return Day::loadMultiple($ids);
}
|
php
|
public function getDays() {
$query = \Drupal::entityQuery('day');
$query->condition('league', $this->id());
$query->sort('id', 'ASC');
$ids = $query->execute();
return Day::loadMultiple($ids);
}
|
[
"public",
"function",
"getDays",
"(",
")",
"{",
"$",
"query",
"=",
"\\",
"Drupal",
"::",
"entityQuery",
"(",
"'day'",
")",
";",
"$",
"query",
"->",
"condition",
"(",
"'league'",
",",
"$",
"this",
"->",
"id",
"(",
")",
")",
";",
"$",
"query",
"->",
"sort",
"(",
"'id'",
",",
"'ASC'",
")",
";",
"$",
"ids",
"=",
"$",
"query",
"->",
"execute",
"(",
")",
";",
"return",
"Day",
"::",
"loadMultiple",
"(",
"$",
"ids",
")",
";",
"}"
] |
Return all days for league
@return \Drupal\mespronos\Entity\Day[]
|
[
"Return",
"all",
"days",
"for",
"league"
] |
73757663581ed9040944768073d1d9abc761196b
|
https://github.com/mespronos/mespronos/blob/73757663581ed9040944768073d1d9abc761196b/src/Entity/Getters/LeagueGettersTrait.php#L30-L37
|
223,217
|
efficiently/jquery-laravel
|
src/Efficiently/JqueryLaravel/VerifyJavascriptResponse.php
|
VerifyJavascriptResponse.shouldPassThrough
|
protected function shouldPassThrough($request)
{
foreach ($this->except as $except) {
if ($request->is($except)) {
return true;
}
}
return false;
}
|
php
|
protected function shouldPassThrough($request)
{
foreach ($this->except as $except) {
if ($request->is($except)) {
return true;
}
}
return false;
}
|
[
"protected",
"function",
"shouldPassThrough",
"(",
"$",
"request",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"except",
"as",
"$",
"except",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"is",
"(",
"$",
"except",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Determine if the request has a URI that should pass through cross origin verification.
@param \Illuminate\Http\Request $request
@return bool
|
[
"Determine",
"if",
"the",
"request",
"has",
"a",
"URI",
"that",
"should",
"pass",
"through",
"cross",
"origin",
"verification",
"."
] |
30e3953e51ac8644e13d90150e2cf56012ce8f6b
|
https://github.com/efficiently/jquery-laravel/blob/30e3953e51ac8644e13d90150e2cf56012ce8f6b/src/Efficiently/JqueryLaravel/VerifyJavascriptResponse.php#L61-L69
|
223,218
|
mmerian/phpcrawl
|
libs/Utils/PHPCrawlerUtils.class.php
|
PHPCrawlerUtils.buildURLFromParts
|
public static function buildURLFromParts($url_parts, $normalize = false)
{
// Host has to be set aat least
if (!isset($url_parts["host"]))
{
throw new Exception("Cannot generate URL, host not specified!");
}
if (!isset($url_parts["protocol"]) || $url_parts["protocol"] == "") $url_parts["protocol"] = "http://";
if (!isset($url_parts["port"])) $url_parts["port"]= 80;
if (!isset($url_parts["path"])) $url_parts["path"] = "";
if (!isset($url_parts["file"])) $url_parts["file"] = "";
if (!isset($url_parts["query"])) $url_parts["query"]= "";
if (!isset($url_parts["auth_username"])) $url_parts["auth_username"]= "";
if (!isset($url_parts["auth_password"])) $url_parts["auth_password"]= "";
// Autentication-part
$auth_part = "";
if ($url_parts["auth_username"] != "" && $url_parts["auth_password"] != "")
{
$auth_part = $url_parts["auth_username"].":".$url_parts["auth_password"]."@";
}
// Port-part
$port_part = ":" . $url_parts["port"];
// Normalize
if ($normalize == true)
{
if ($url_parts["protocol"] == "http://" && $url_parts["port"] == 80 ||
$url_parts["protocol"] == "https://" && $url_parts["port"] == 443)
{
$port_part = "";
}
// Don't add port to links other than "http://" or "https://"
if ($url_parts["protocol"] != "http://" && $url_parts["protocol"] != "https://")
{
$port_part = "";
}
}
// If path is just a "/" -> remove it ("www.site.com/" -> "www.site.com")
if ($url_parts["path"] == "/" && $url_parts["file"] == "" && $url_parts["query"] == "") $url_parts["path"] = "";
// Put together the url
$url = $url_parts["protocol"] . $auth_part . $url_parts["host"]. $port_part . $url_parts["path"] . $url_parts["file"] . $url_parts["query"];
return $url;
}
|
php
|
public static function buildURLFromParts($url_parts, $normalize = false)
{
// Host has to be set aat least
if (!isset($url_parts["host"]))
{
throw new Exception("Cannot generate URL, host not specified!");
}
if (!isset($url_parts["protocol"]) || $url_parts["protocol"] == "") $url_parts["protocol"] = "http://";
if (!isset($url_parts["port"])) $url_parts["port"]= 80;
if (!isset($url_parts["path"])) $url_parts["path"] = "";
if (!isset($url_parts["file"])) $url_parts["file"] = "";
if (!isset($url_parts["query"])) $url_parts["query"]= "";
if (!isset($url_parts["auth_username"])) $url_parts["auth_username"]= "";
if (!isset($url_parts["auth_password"])) $url_parts["auth_password"]= "";
// Autentication-part
$auth_part = "";
if ($url_parts["auth_username"] != "" && $url_parts["auth_password"] != "")
{
$auth_part = $url_parts["auth_username"].":".$url_parts["auth_password"]."@";
}
// Port-part
$port_part = ":" . $url_parts["port"];
// Normalize
if ($normalize == true)
{
if ($url_parts["protocol"] == "http://" && $url_parts["port"] == 80 ||
$url_parts["protocol"] == "https://" && $url_parts["port"] == 443)
{
$port_part = "";
}
// Don't add port to links other than "http://" or "https://"
if ($url_parts["protocol"] != "http://" && $url_parts["protocol"] != "https://")
{
$port_part = "";
}
}
// If path is just a "/" -> remove it ("www.site.com/" -> "www.site.com")
if ($url_parts["path"] == "/" && $url_parts["file"] == "" && $url_parts["query"] == "") $url_parts["path"] = "";
// Put together the url
$url = $url_parts["protocol"] . $auth_part . $url_parts["host"]. $port_part . $url_parts["path"] . $url_parts["file"] . $url_parts["query"];
return $url;
}
|
[
"public",
"static",
"function",
"buildURLFromParts",
"(",
"$",
"url_parts",
",",
"$",
"normalize",
"=",
"false",
")",
"{",
"// Host has to be set aat least\r",
"if",
"(",
"!",
"isset",
"(",
"$",
"url_parts",
"[",
"\"host\"",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Cannot generate URL, host not specified!\"",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"url_parts",
"[",
"\"protocol\"",
"]",
")",
"||",
"$",
"url_parts",
"[",
"\"protocol\"",
"]",
"==",
"\"\"",
")",
"$",
"url_parts",
"[",
"\"protocol\"",
"]",
"=",
"\"http://\"",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"url_parts",
"[",
"\"port\"",
"]",
")",
")",
"$",
"url_parts",
"[",
"\"port\"",
"]",
"=",
"80",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"url_parts",
"[",
"\"path\"",
"]",
")",
")",
"$",
"url_parts",
"[",
"\"path\"",
"]",
"=",
"\"\"",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"url_parts",
"[",
"\"file\"",
"]",
")",
")",
"$",
"url_parts",
"[",
"\"file\"",
"]",
"=",
"\"\"",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"url_parts",
"[",
"\"query\"",
"]",
")",
")",
"$",
"url_parts",
"[",
"\"query\"",
"]",
"=",
"\"\"",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"url_parts",
"[",
"\"auth_username\"",
"]",
")",
")",
"$",
"url_parts",
"[",
"\"auth_username\"",
"]",
"=",
"\"\"",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"url_parts",
"[",
"\"auth_password\"",
"]",
")",
")",
"$",
"url_parts",
"[",
"\"auth_password\"",
"]",
"=",
"\"\"",
";",
"// Autentication-part\r",
"$",
"auth_part",
"=",
"\"\"",
";",
"if",
"(",
"$",
"url_parts",
"[",
"\"auth_username\"",
"]",
"!=",
"\"\"",
"&&",
"$",
"url_parts",
"[",
"\"auth_password\"",
"]",
"!=",
"\"\"",
")",
"{",
"$",
"auth_part",
"=",
"$",
"url_parts",
"[",
"\"auth_username\"",
"]",
".",
"\":\"",
".",
"$",
"url_parts",
"[",
"\"auth_password\"",
"]",
".",
"\"@\"",
";",
"}",
"// Port-part\r",
"$",
"port_part",
"=",
"\":\"",
".",
"$",
"url_parts",
"[",
"\"port\"",
"]",
";",
"// Normalize\r",
"if",
"(",
"$",
"normalize",
"==",
"true",
")",
"{",
"if",
"(",
"$",
"url_parts",
"[",
"\"protocol\"",
"]",
"==",
"\"http://\"",
"&&",
"$",
"url_parts",
"[",
"\"port\"",
"]",
"==",
"80",
"||",
"$",
"url_parts",
"[",
"\"protocol\"",
"]",
"==",
"\"https://\"",
"&&",
"$",
"url_parts",
"[",
"\"port\"",
"]",
"==",
"443",
")",
"{",
"$",
"port_part",
"=",
"\"\"",
";",
"}",
"// Don't add port to links other than \"http://\" or \"https://\"\r",
"if",
"(",
"$",
"url_parts",
"[",
"\"protocol\"",
"]",
"!=",
"\"http://\"",
"&&",
"$",
"url_parts",
"[",
"\"protocol\"",
"]",
"!=",
"\"https://\"",
")",
"{",
"$",
"port_part",
"=",
"\"\"",
";",
"}",
"}",
"// If path is just a \"/\" -> remove it (\"www.site.com/\" -> \"www.site.com\")\r",
"if",
"(",
"$",
"url_parts",
"[",
"\"path\"",
"]",
"==",
"\"/\"",
"&&",
"$",
"url_parts",
"[",
"\"file\"",
"]",
"==",
"\"\"",
"&&",
"$",
"url_parts",
"[",
"\"query\"",
"]",
"==",
"\"\"",
")",
"$",
"url_parts",
"[",
"\"path\"",
"]",
"=",
"\"\"",
";",
"// Put together the url\r",
"$",
"url",
"=",
"$",
"url_parts",
"[",
"\"protocol\"",
"]",
".",
"$",
"auth_part",
".",
"$",
"url_parts",
"[",
"\"host\"",
"]",
".",
"$",
"port_part",
".",
"$",
"url_parts",
"[",
"\"path\"",
"]",
".",
"$",
"url_parts",
"[",
"\"file\"",
"]",
".",
"$",
"url_parts",
"[",
"\"query\"",
"]",
";",
"return",
"$",
"url",
";",
"}"
] |
Builds an URL from it's single parts.
@param array $url_parts Array conatining the URL-parts.
The keys should be:
"protocol" (z.B. "http://") OPTIONAL
"host" (z.B. "www.bla.de")
"path" (z.B. "/test/palimm/") OPTIONAL
"file" (z.B. "index.htm") OPTIONAL
"port" (z.B. 80) OPTIONAL
"auth_username" OPTIONAL
"auth_password" OPTIONAL
@param bool $normalize If TRUE, the URL will be returned normalized.
(I.e. http://www.foo.com/path/ insetad of http://www.foo.com:80/path/)
@return string The URL
|
[
"Builds",
"an",
"URL",
"from",
"it",
"s",
"single",
"parts",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/Utils/PHPCrawlerUtils.class.php#L126-L175
|
223,219
|
mmerian/phpcrawl
|
libs/Utils/PHPCrawlerUtils.class.php
|
PHPCrawlerUtils.normalizeURL
|
public static function normalizeURL($url)
{
$url_parts = self::splitURL($url);
if ($url_parts == null) return null;
$url_normalized = self::buildURLFromParts($url_parts, true);
return $url_normalized;
}
|
php
|
public static function normalizeURL($url)
{
$url_parts = self::splitURL($url);
if ($url_parts == null) return null;
$url_normalized = self::buildURLFromParts($url_parts, true);
return $url_normalized;
}
|
[
"public",
"static",
"function",
"normalizeURL",
"(",
"$",
"url",
")",
"{",
"$",
"url_parts",
"=",
"self",
"::",
"splitURL",
"(",
"$",
"url",
")",
";",
"if",
"(",
"$",
"url_parts",
"==",
"null",
")",
"return",
"null",
";",
"$",
"url_normalized",
"=",
"self",
"::",
"buildURLFromParts",
"(",
"$",
"url_parts",
",",
"true",
")",
";",
"return",
"$",
"url_normalized",
";",
"}"
] |
Normalizes an URL
I.e. converts http://www.foo.com:80/path/ to http://www.foo.com/path/
@param string $url
@return string OR NULL on failure
|
[
"Normalizes",
"an",
"URL"
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/Utils/PHPCrawlerUtils.class.php#L185-L193
|
223,220
|
mmerian/phpcrawl
|
libs/Utils/PHPCrawlerUtils.class.php
|
PHPCrawlerUtils.checkRegexPattern
|
public static function checkRegexPattern($pattern)
{
$check = @preg_match($pattern, "anything"); // thats the easy way to check a pattern ;)
if (is_integer($check) == false) return false;
else return true;
}
|
php
|
public static function checkRegexPattern($pattern)
{
$check = @preg_match($pattern, "anything"); // thats the easy way to check a pattern ;)
if (is_integer($check) == false) return false;
else return true;
}
|
[
"public",
"static",
"function",
"checkRegexPattern",
"(",
"$",
"pattern",
")",
"{",
"$",
"check",
"=",
"@",
"preg_match",
"(",
"$",
"pattern",
",",
"\"anything\"",
")",
";",
"// thats the easy way to check a pattern ;)\r",
"if",
"(",
"is_integer",
"(",
"$",
"check",
")",
"==",
"false",
")",
"return",
"false",
";",
"else",
"return",
"true",
";",
"}"
] |
Checks whether a given RegEx-pattern is valid or not.
@return bool
|
[
"Checks",
"whether",
"a",
"given",
"RegEx",
"-",
"pattern",
"is",
"valid",
"or",
"not",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/Utils/PHPCrawlerUtils.class.php#L200-L205
|
223,221
|
mmerian/phpcrawl
|
libs/Utils/PHPCrawlerUtils.class.php
|
PHPCrawlerUtils.getHTTPStatusCode
|
public static function getHTTPStatusCode($header)
{
$first_line = strtok($header, "\n");
preg_match("# [0-9]{3}#", $first_line, $match);
if (isset($match[0]))
return (int)trim($match[0]);
else
return null;
}
|
php
|
public static function getHTTPStatusCode($header)
{
$first_line = strtok($header, "\n");
preg_match("# [0-9]{3}#", $first_line, $match);
if (isset($match[0]))
return (int)trim($match[0]);
else
return null;
}
|
[
"public",
"static",
"function",
"getHTTPStatusCode",
"(",
"$",
"header",
")",
"{",
"$",
"first_line",
"=",
"strtok",
"(",
"$",
"header",
",",
"\"\\n\"",
")",
";",
"preg_match",
"(",
"\"# [0-9]{3}#\"",
",",
"$",
"first_line",
",",
"$",
"match",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"match",
"[",
"0",
"]",
")",
")",
"return",
"(",
"int",
")",
"trim",
"(",
"$",
"match",
"[",
"0",
"]",
")",
";",
"else",
"return",
"null",
";",
"}"
] |
Gets the HTTP-statuscode from a given response-header.
@param string $header The response-header
@return int The status-code or NULL if no status-code was found.
|
[
"Gets",
"the",
"HTTP",
"-",
"statuscode",
"from",
"a",
"given",
"response",
"-",
"header",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/Utils/PHPCrawlerUtils.class.php#L213-L223
|
223,222
|
mmerian/phpcrawl
|
libs/Utils/PHPCrawlerUtils.class.php
|
PHPCrawlerUtils.buildURLFromLink
|
public static function buildURLFromLink($link, PHPCrawlerUrlPartsDescriptor $BaseUrl)
{
$url_parts = $BaseUrl->toArray();
// Dedoce HTML-entities
$link = PHPCrawlerEncodingUtils::decodeHtmlEntities($link);
// Remove anchor ("#..."), but ONLY at the end, not if # is at the beginning !
$link = preg_replace("/^(.{1,})#.{0,}$/", "\\1", $link);
// Cases
// Strange link like "//foo.htm" -> make it to "http://foo.html"
if (substr($link, 0, 2) == "//")
{
$link = "http:".$link;
}
// 1. relative link starts with "/" --> doc_root
// "/index.html" -> "http://www.foo.com/index.html"
elseif (substr($link,0,1)=="/")
{
$link = $url_parts["protocol"].$url_parts["host"].":".$url_parts["port"].$link;
}
// 2. "./foo.htm" -> "foo.htm"
elseif (substr($link,0,2)=="./")
{
$link=$url_parts["protocol"].$url_parts["host"].":".$url_parts["port"].$url_parts["path"].substr($link, 2);
}
// 3. Link is an absolute Link with a given protocol and host (f.e. "http://..." or "android-app://...)
// DO NOTHING
elseif (preg_match("#^[a-z0-9-]{1,}(:\/\/)# i", $link))
{
$link = $link;
}
// 4. Link is stuff like "javascript: ..." or something
elseif (preg_match("/^[a-zA-Z]{0,}:[^\/]{0,1}/", $link))
{
$link = "";
}
// 5. "../../foo.html" -> remove the last path from our actual path
// and remove "../" from link at the same time until there are
// no more "../" at the beginning of the link
elseif (substr($link, 0, 3)=="../")
{
$new_path = $url_parts["path"];
while (substr($link, 0, 3) == "../")
{
$new_path = preg_replace('/\/[^\/]{0,}\/$/',"/", $new_path);
$link = substr($link, 3);
}
$link = $url_parts["protocol"].$url_parts["host"].":".$url_parts["port"].$new_path.$link;
}
// 6. link starts with #
// -> leads to the same site as we are on, trash
elseif (substr($link,0,1) == "#")
{
$link="";
}
// 7. link starts with "?"
elseif (substr($link,0,1)=="?")
{
$link = $url_parts["protocol"].$url_parts["host"].":".$url_parts["port"].$url_parts["path"].$url_parts["file"].$link;
}
// 7. thats it, else the abs_path is simply PATH.LINK ...
else
{
$link = $url_parts["protocol"].$url_parts["host"].":".$url_parts["port"].$url_parts["path"].$link;
}
if ($link == "") return null;
// Now, at least, replace all HTMLENTITIES with normal text.
// I.E.: HTML-Code of the link is: <a href="index.php?x=1&y=2">
// -> Link has to be "index.php?x=1&y=2"
//$link = PHPCrawlerEncodingUtils::decodeHtmlEntities($link);
// Replace linebreaks in the link with "" (happens if a link in the sourcecode
// linebreaks)
$link = str_replace(array("\n", "\r"), "", $link);
// "Normalize" URL
$link = self::normalizeUrl($link);
return $link;
}
|
php
|
public static function buildURLFromLink($link, PHPCrawlerUrlPartsDescriptor $BaseUrl)
{
$url_parts = $BaseUrl->toArray();
// Dedoce HTML-entities
$link = PHPCrawlerEncodingUtils::decodeHtmlEntities($link);
// Remove anchor ("#..."), but ONLY at the end, not if # is at the beginning !
$link = preg_replace("/^(.{1,})#.{0,}$/", "\\1", $link);
// Cases
// Strange link like "//foo.htm" -> make it to "http://foo.html"
if (substr($link, 0, 2) == "//")
{
$link = "http:".$link;
}
// 1. relative link starts with "/" --> doc_root
// "/index.html" -> "http://www.foo.com/index.html"
elseif (substr($link,0,1)=="/")
{
$link = $url_parts["protocol"].$url_parts["host"].":".$url_parts["port"].$link;
}
// 2. "./foo.htm" -> "foo.htm"
elseif (substr($link,0,2)=="./")
{
$link=$url_parts["protocol"].$url_parts["host"].":".$url_parts["port"].$url_parts["path"].substr($link, 2);
}
// 3. Link is an absolute Link with a given protocol and host (f.e. "http://..." or "android-app://...)
// DO NOTHING
elseif (preg_match("#^[a-z0-9-]{1,}(:\/\/)# i", $link))
{
$link = $link;
}
// 4. Link is stuff like "javascript: ..." or something
elseif (preg_match("/^[a-zA-Z]{0,}:[^\/]{0,1}/", $link))
{
$link = "";
}
// 5. "../../foo.html" -> remove the last path from our actual path
// and remove "../" from link at the same time until there are
// no more "../" at the beginning of the link
elseif (substr($link, 0, 3)=="../")
{
$new_path = $url_parts["path"];
while (substr($link, 0, 3) == "../")
{
$new_path = preg_replace('/\/[^\/]{0,}\/$/',"/", $new_path);
$link = substr($link, 3);
}
$link = $url_parts["protocol"].$url_parts["host"].":".$url_parts["port"].$new_path.$link;
}
// 6. link starts with #
// -> leads to the same site as we are on, trash
elseif (substr($link,0,1) == "#")
{
$link="";
}
// 7. link starts with "?"
elseif (substr($link,0,1)=="?")
{
$link = $url_parts["protocol"].$url_parts["host"].":".$url_parts["port"].$url_parts["path"].$url_parts["file"].$link;
}
// 7. thats it, else the abs_path is simply PATH.LINK ...
else
{
$link = $url_parts["protocol"].$url_parts["host"].":".$url_parts["port"].$url_parts["path"].$link;
}
if ($link == "") return null;
// Now, at least, replace all HTMLENTITIES with normal text.
// I.E.: HTML-Code of the link is: <a href="index.php?x=1&y=2">
// -> Link has to be "index.php?x=1&y=2"
//$link = PHPCrawlerEncodingUtils::decodeHtmlEntities($link);
// Replace linebreaks in the link with "" (happens if a link in the sourcecode
// linebreaks)
$link = str_replace(array("\n", "\r"), "", $link);
// "Normalize" URL
$link = self::normalizeUrl($link);
return $link;
}
|
[
"public",
"static",
"function",
"buildURLFromLink",
"(",
"$",
"link",
",",
"PHPCrawlerUrlPartsDescriptor",
"$",
"BaseUrl",
")",
"{",
"$",
"url_parts",
"=",
"$",
"BaseUrl",
"->",
"toArray",
"(",
")",
";",
"// Dedoce HTML-entities\r",
"$",
"link",
"=",
"PHPCrawlerEncodingUtils",
"::",
"decodeHtmlEntities",
"(",
"$",
"link",
")",
";",
"// Remove anchor (\"#...\"), but ONLY at the end, not if # is at the beginning !\r",
"$",
"link",
"=",
"preg_replace",
"(",
"\"/^(.{1,})#.{0,}$/\"",
",",
"\"\\\\1\"",
",",
"$",
"link",
")",
";",
"// Cases\r",
"// Strange link like \"//foo.htm\" -> make it to \"http://foo.html\"\r",
"if",
"(",
"substr",
"(",
"$",
"link",
",",
"0",
",",
"2",
")",
"==",
"\"//\"",
")",
"{",
"$",
"link",
"=",
"\"http:\"",
".",
"$",
"link",
";",
"}",
"// 1. relative link starts with \"/\" --> doc_root\r",
"// \"/index.html\" -> \"http://www.foo.com/index.html\" \r",
"elseif",
"(",
"substr",
"(",
"$",
"link",
",",
"0",
",",
"1",
")",
"==",
"\"/\"",
")",
"{",
"$",
"link",
"=",
"$",
"url_parts",
"[",
"\"protocol\"",
"]",
".",
"$",
"url_parts",
"[",
"\"host\"",
"]",
".",
"\":\"",
".",
"$",
"url_parts",
"[",
"\"port\"",
"]",
".",
"$",
"link",
";",
"}",
"// 2. \"./foo.htm\" -> \"foo.htm\"\r",
"elseif",
"(",
"substr",
"(",
"$",
"link",
",",
"0",
",",
"2",
")",
"==",
"\"./\"",
")",
"{",
"$",
"link",
"=",
"$",
"url_parts",
"[",
"\"protocol\"",
"]",
".",
"$",
"url_parts",
"[",
"\"host\"",
"]",
".",
"\":\"",
".",
"$",
"url_parts",
"[",
"\"port\"",
"]",
".",
"$",
"url_parts",
"[",
"\"path\"",
"]",
".",
"substr",
"(",
"$",
"link",
",",
"2",
")",
";",
"}",
"// 3. Link is an absolute Link with a given protocol and host (f.e. \"http://...\" or \"android-app://...)\r",
"// DO NOTHING\r",
"elseif",
"(",
"preg_match",
"(",
"\"#^[a-z0-9-]{1,}(:\\/\\/)# i\"",
",",
"$",
"link",
")",
")",
"{",
"$",
"link",
"=",
"$",
"link",
";",
"}",
"// 4. Link is stuff like \"javascript: ...\" or something\r",
"elseif",
"(",
"preg_match",
"(",
"\"/^[a-zA-Z]{0,}:[^\\/]{0,1}/\"",
",",
"$",
"link",
")",
")",
"{",
"$",
"link",
"=",
"\"\"",
";",
"}",
"// 5. \"../../foo.html\" -> remove the last path from our actual path\r",
"// and remove \"../\" from link at the same time until there are\r",
"// no more \"../\" at the beginning of the link\r",
"elseif",
"(",
"substr",
"(",
"$",
"link",
",",
"0",
",",
"3",
")",
"==",
"\"../\"",
")",
"{",
"$",
"new_path",
"=",
"$",
"url_parts",
"[",
"\"path\"",
"]",
";",
"while",
"(",
"substr",
"(",
"$",
"link",
",",
"0",
",",
"3",
")",
"==",
"\"../\"",
")",
"{",
"$",
"new_path",
"=",
"preg_replace",
"(",
"'/\\/[^\\/]{0,}\\/$/'",
",",
"\"/\"",
",",
"$",
"new_path",
")",
";",
"$",
"link",
"=",
"substr",
"(",
"$",
"link",
",",
"3",
")",
";",
"}",
"$",
"link",
"=",
"$",
"url_parts",
"[",
"\"protocol\"",
"]",
".",
"$",
"url_parts",
"[",
"\"host\"",
"]",
".",
"\":\"",
".",
"$",
"url_parts",
"[",
"\"port\"",
"]",
".",
"$",
"new_path",
".",
"$",
"link",
";",
"}",
"// 6. link starts with #\r",
"// -> leads to the same site as we are on, trash\r",
"elseif",
"(",
"substr",
"(",
"$",
"link",
",",
"0",
",",
"1",
")",
"==",
"\"#\"",
")",
"{",
"$",
"link",
"=",
"\"\"",
";",
"}",
"// 7. link starts with \"?\"\r",
"elseif",
"(",
"substr",
"(",
"$",
"link",
",",
"0",
",",
"1",
")",
"==",
"\"?\"",
")",
"{",
"$",
"link",
"=",
"$",
"url_parts",
"[",
"\"protocol\"",
"]",
".",
"$",
"url_parts",
"[",
"\"host\"",
"]",
".",
"\":\"",
".",
"$",
"url_parts",
"[",
"\"port\"",
"]",
".",
"$",
"url_parts",
"[",
"\"path\"",
"]",
".",
"$",
"url_parts",
"[",
"\"file\"",
"]",
".",
"$",
"link",
";",
"}",
"// 7. thats it, else the abs_path is simply PATH.LINK ...\r",
"else",
"{",
"$",
"link",
"=",
"$",
"url_parts",
"[",
"\"protocol\"",
"]",
".",
"$",
"url_parts",
"[",
"\"host\"",
"]",
".",
"\":\"",
".",
"$",
"url_parts",
"[",
"\"port\"",
"]",
".",
"$",
"url_parts",
"[",
"\"path\"",
"]",
".",
"$",
"link",
";",
"}",
"if",
"(",
"$",
"link",
"==",
"\"\"",
")",
"return",
"null",
";",
"// Now, at least, replace all HTMLENTITIES with normal text.\r",
"// I.E.: HTML-Code of the link is: <a href=\"index.php?x=1&y=2\">\r",
"// -> Link has to be \"index.php?x=1&y=2\"\r",
"//$link = PHPCrawlerEncodingUtils::decodeHtmlEntities($link);\r",
"// Replace linebreaks in the link with \"\" (happens if a link in the sourcecode\r",
"// linebreaks)\r",
"$",
"link",
"=",
"str_replace",
"(",
"array",
"(",
"\"\\n\"",
",",
"\"\\r\"",
")",
",",
"\"\"",
",",
"$",
"link",
")",
";",
"// \"Normalize\" URL\r",
"$",
"link",
"=",
"self",
"::",
"normalizeUrl",
"(",
"$",
"link",
")",
";",
"return",
"$",
"link",
";",
"}"
] |
Reconstructs a full qualified and normalized URL from a given link relating to the URL the link was found in.
@param string $link The link (i.e. "../page.htm")
@param PHPCrawlerUrlPartsDescriptor $BaseUrl The base-URL the link was found in as PHPCrawlerUrlPartsDescriptor-object
@return string The rebuild, full qualified and normilazed URL the link is leading to (i.e. "http://www.foo.com/page.htm"),
or NULL if the link couldn't be rebuild correctly.
|
[
"Reconstructs",
"a",
"full",
"qualified",
"and",
"normalized",
"URL",
"from",
"a",
"given",
"link",
"relating",
"to",
"the",
"URL",
"the",
"link",
"was",
"found",
"in",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/Utils/PHPCrawlerUtils.class.php#L234-L328
|
223,223
|
mmerian/phpcrawl
|
libs/Utils/PHPCrawlerUtils.class.php
|
PHPCrawlerUtils.getBaseUrlFromMetaTag
|
public static function getBaseUrlFromMetaTag(&$html_source)
{
preg_match("#<{1}[ ]{0,}((?i)base){1}[ ]{1,}((?i)href|src)[ ]{0,}=[ ]{0,}(\"|'){0,1}([^\"'><\n ]{0,})(\"|'|>|<|\n| )# i", $html_source, $match);
if (isset($match[4]))
{
$match[4] = trim($match[4]);
return $match[4];
}
else return null;
}
|
php
|
public static function getBaseUrlFromMetaTag(&$html_source)
{
preg_match("#<{1}[ ]{0,}((?i)base){1}[ ]{1,}((?i)href|src)[ ]{0,}=[ ]{0,}(\"|'){0,1}([^\"'><\n ]{0,})(\"|'|>|<|\n| )# i", $html_source, $match);
if (isset($match[4]))
{
$match[4] = trim($match[4]);
return $match[4];
}
else return null;
}
|
[
"public",
"static",
"function",
"getBaseUrlFromMetaTag",
"(",
"&",
"$",
"html_source",
")",
"{",
"preg_match",
"(",
"\"#<{1}[ ]{0,}((?i)base){1}[ ]{1,}((?i)href|src)[ ]{0,}=[ ]{0,}(\\\"|'){0,1}([^\\\"'><\\n ]{0,})(\\\"|'|>|<|\\n| )# i\"",
",",
"$",
"html_source",
",",
"$",
"match",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"match",
"[",
"4",
"]",
")",
")",
"{",
"$",
"match",
"[",
"4",
"]",
"=",
"trim",
"(",
"$",
"match",
"[",
"4",
"]",
")",
";",
"return",
"$",
"match",
"[",
"4",
"]",
";",
"}",
"else",
"return",
"null",
";",
"}"
] |
Returns the base-URL specified in a meta-tag in the given HTML-source
@return string The base-URL or NULL if not found.
|
[
"Returns",
"the",
"base",
"-",
"URL",
"specified",
"in",
"a",
"meta",
"-",
"tag",
"in",
"the",
"given",
"HTML",
"-",
"source"
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/Utils/PHPCrawlerUtils.class.php#L335-L345
|
223,224
|
mmerian/phpcrawl
|
libs/Utils/PHPCrawlerUtils.class.php
|
PHPCrawlerUtils.getRedirectURLFromHeader
|
public static function getRedirectURLFromHeader(&$header)
{
// Get redirect-link from header
preg_match("/((?i)location:|content-location:)(.{0,})[\n]/", $header, $match);
if (isset($match[2]))
{
$redirect = trim($match[2]);
return $redirect;
}
else return null;
}
|
php
|
public static function getRedirectURLFromHeader(&$header)
{
// Get redirect-link from header
preg_match("/((?i)location:|content-location:)(.{0,})[\n]/", $header, $match);
if (isset($match[2]))
{
$redirect = trim($match[2]);
return $redirect;
}
else return null;
}
|
[
"public",
"static",
"function",
"getRedirectURLFromHeader",
"(",
"&",
"$",
"header",
")",
"{",
"// Get redirect-link from header\r",
"preg_match",
"(",
"\"/((?i)location:|content-location:)(.{0,})[\\n]/\"",
",",
"$",
"header",
",",
"$",
"match",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"match",
"[",
"2",
"]",
")",
")",
"{",
"$",
"redirect",
"=",
"trim",
"(",
"$",
"match",
"[",
"2",
"]",
")",
";",
"return",
"$",
"redirect",
";",
"}",
"else",
"return",
"null",
";",
"}"
] |
Returns the redirect-URL from the given HTML-header
@return string The redirect-URL or NULL if not found.
|
[
"Returns",
"the",
"redirect",
"-",
"URL",
"from",
"the",
"given",
"HTML",
"-",
"header"
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/Utils/PHPCrawlerUtils.class.php#L352-L363
|
223,225
|
mmerian/phpcrawl
|
libs/Utils/PHPCrawlerUtils.class.php
|
PHPCrawlerUtils.checkStringAgainstRegexArray
|
public static function checkStringAgainstRegexArray(&$string, $regex_array)
{
if (count($regex_array) == 0) return true;
$cnt = count($regex_array);
for ($x=0; $x<$cnt; $x++)
{
if (preg_match($regex_array[$x], $string))
{
return true;
}
}
return false;
}
|
php
|
public static function checkStringAgainstRegexArray(&$string, $regex_array)
{
if (count($regex_array) == 0) return true;
$cnt = count($regex_array);
for ($x=0; $x<$cnt; $x++)
{
if (preg_match($regex_array[$x], $string))
{
return true;
}
}
return false;
}
|
[
"public",
"static",
"function",
"checkStringAgainstRegexArray",
"(",
"&",
"$",
"string",
",",
"$",
"regex_array",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"regex_array",
")",
"==",
"0",
")",
"return",
"true",
";",
"$",
"cnt",
"=",
"count",
"(",
"$",
"regex_array",
")",
";",
"for",
"(",
"$",
"x",
"=",
"0",
";",
"$",
"x",
"<",
"$",
"cnt",
";",
"$",
"x",
"++",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"regex_array",
"[",
"$",
"x",
"]",
",",
"$",
"string",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Checks whether a given string matches with one of the given regular-expressions.
@param &string $string The string
@param array $regex_array Numerich array containing the regular-expressions to check against.
@return bool TRUE if one of the regexes matches the string, otherwise FALSE.
|
[
"Checks",
"whether",
"a",
"given",
"string",
"matches",
"with",
"one",
"of",
"the",
"given",
"regular",
"-",
"expressions",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/Utils/PHPCrawlerUtils.class.php#L373-L387
|
223,226
|
mmerian/phpcrawl
|
libs/Utils/PHPCrawlerUtils.class.php
|
PHPCrawlerUtils.getHeaderValue
|
public static function getHeaderValue($header, $directive)
{
preg_match("#[\r\n]".$directive.":(.*)[\r\n\;]# Ui", $header, $match);
if (isset($match[1]) && trim($match[1]) != "")
{
return trim($match[1]);
}
else return null;
}
|
php
|
public static function getHeaderValue($header, $directive)
{
preg_match("#[\r\n]".$directive.":(.*)[\r\n\;]# Ui", $header, $match);
if (isset($match[1]) && trim($match[1]) != "")
{
return trim($match[1]);
}
else return null;
}
|
[
"public",
"static",
"function",
"getHeaderValue",
"(",
"$",
"header",
",",
"$",
"directive",
")",
"{",
"preg_match",
"(",
"\"#[\\r\\n]\"",
".",
"$",
"directive",
".",
"\":(.*)[\\r\\n\\;]# Ui\"",
",",
"$",
"header",
",",
"$",
"match",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"match",
"[",
"1",
"]",
")",
"&&",
"trim",
"(",
"$",
"match",
"[",
"1",
"]",
")",
"!=",
"\"\"",
")",
"{",
"return",
"trim",
"(",
"$",
"match",
"[",
"1",
"]",
")",
";",
"}",
"else",
"return",
"null",
";",
"}"
] |
Gets the value of an header-directive from the given HTTP-header.
Example:
<code>PHPCrawlerUtils::getHeaderValue($header, "content-type");</code>
@param string $header The HTTP-header
@param string $directive The header-directive
@return string The value of the given directive found in the header.
Or NULL if not found.
|
[
"Gets",
"the",
"value",
"of",
"an",
"header",
"-",
"directive",
"from",
"the",
"given",
"HTTP",
"-",
"header",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/Utils/PHPCrawlerUtils.class.php#L401-L411
|
223,227
|
mmerian/phpcrawl
|
libs/Utils/PHPCrawlerUtils.class.php
|
PHPCrawlerUtils.getCookiesFromHeader
|
public static function getCookiesFromHeader($header, $source_url)
{
$cookies = array();
$hits = preg_match_all("#[\r\n]set-cookie:(.*)[\r\n]# Ui", $header, $matches);
if ($hits && $hits != 0)
{
for ($x=0; $x<count($matches[1]); $x++)
{
$cookies[] = PHPCrawlerCookieDescriptor::getFromHeaderLine($matches[1][$x], $source_url);
}
}
return $cookies;
}
|
php
|
public static function getCookiesFromHeader($header, $source_url)
{
$cookies = array();
$hits = preg_match_all("#[\r\n]set-cookie:(.*)[\r\n]# Ui", $header, $matches);
if ($hits && $hits != 0)
{
for ($x=0; $x<count($matches[1]); $x++)
{
$cookies[] = PHPCrawlerCookieDescriptor::getFromHeaderLine($matches[1][$x], $source_url);
}
}
return $cookies;
}
|
[
"public",
"static",
"function",
"getCookiesFromHeader",
"(",
"$",
"header",
",",
"$",
"source_url",
")",
"{",
"$",
"cookies",
"=",
"array",
"(",
")",
";",
"$",
"hits",
"=",
"preg_match_all",
"(",
"\"#[\\r\\n]set-cookie:(.*)[\\r\\n]# Ui\"",
",",
"$",
"header",
",",
"$",
"matches",
")",
";",
"if",
"(",
"$",
"hits",
"&&",
"$",
"hits",
"!=",
"0",
")",
"{",
"for",
"(",
"$",
"x",
"=",
"0",
";",
"$",
"x",
"<",
"count",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"$",
"x",
"++",
")",
"{",
"$",
"cookies",
"[",
"]",
"=",
"PHPCrawlerCookieDescriptor",
"::",
"getFromHeaderLine",
"(",
"$",
"matches",
"[",
"1",
"]",
"[",
"$",
"x",
"]",
",",
"$",
"source_url",
")",
";",
"}",
"}",
"return",
"$",
"cookies",
";",
"}"
] |
Returns all cookies from the give response-header.
@param string $header The response-header
@param string $source_url URL the cookie was send from.
@return array Numeric array containing all cookies as PHPCrawlerCookieDescriptor-objects.
|
[
"Returns",
"all",
"cookies",
"from",
"the",
"give",
"response",
"-",
"header",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/Utils/PHPCrawlerUtils.class.php#L420-L435
|
223,228
|
mmerian/phpcrawl
|
libs/Utils/PHPCrawlerUtils.class.php
|
PHPCrawlerUtils.getRootUrl
|
public static function getRootUrl($url)
{
$url_parts = self::splitURL($url);
$root_url = $url_parts["protocol"].$url_parts["host"].":".$url_parts["port"];
return self::normalizeURL($root_url);
}
|
php
|
public static function getRootUrl($url)
{
$url_parts = self::splitURL($url);
$root_url = $url_parts["protocol"].$url_parts["host"].":".$url_parts["port"];
return self::normalizeURL($root_url);
}
|
[
"public",
"static",
"function",
"getRootUrl",
"(",
"$",
"url",
")",
"{",
"$",
"url_parts",
"=",
"self",
"::",
"splitURL",
"(",
"$",
"url",
")",
";",
"$",
"root_url",
"=",
"$",
"url_parts",
"[",
"\"protocol\"",
"]",
".",
"$",
"url_parts",
"[",
"\"host\"",
"]",
".",
"\":\"",
".",
"$",
"url_parts",
"[",
"\"port\"",
"]",
";",
"return",
"self",
"::",
"normalizeURL",
"(",
"$",
"root_url",
")",
";",
"}"
] |
Returns the normalized root-URL of the given URL
@param string $url The URL, e.g. "www.foo.con/something/index.html"
@return string The root-URL, e.g. "http://www.foo.com"
|
[
"Returns",
"the",
"normalized",
"root",
"-",
"URL",
"of",
"the",
"given",
"URL"
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/Utils/PHPCrawlerUtils.class.php#L443-L449
|
223,229
|
mmerian/phpcrawl
|
libs/Utils/PHPCrawlerUtils.class.php
|
PHPCrawlerUtils.deserializeFromFile
|
public static function deserializeFromFile($file)
{
if (file_exists($file))
{
$serialized_data = file_get_contents($file);
return unserialize($serialized_data);
}
else return null;
}
|
php
|
public static function deserializeFromFile($file)
{
if (file_exists($file))
{
$serialized_data = file_get_contents($file);
return unserialize($serialized_data);
}
else return null;
}
|
[
"public",
"static",
"function",
"deserializeFromFile",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"$",
"serialized_data",
"=",
"file_get_contents",
"(",
"$",
"file",
")",
";",
"return",
"unserialize",
"(",
"$",
"serialized_data",
")",
";",
"}",
"else",
"return",
"null",
";",
"}"
] |
Returns deserialized data that is stored in a file.
@param string $file The file containing the serialized data
@return mixed The data or NULL if the file doesn't exist
|
[
"Returns",
"deserialized",
"data",
"that",
"is",
"stored",
"in",
"a",
"file",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/Utils/PHPCrawlerUtils.class.php#L491-L499
|
223,230
|
mmerian/phpcrawl
|
libs/Utils/PHPCrawlerUtils.class.php
|
PHPCrawlerUtils.sort2dArray
|
public static function sort2dArray(&$array, $sort_args)
{
$args = func_get_args();
// Für jedes zu sortierende Feld ein eigenes Array bilden
@reset($array);
while (list($field) = @each($array))
{
for ($x=1; $x<count($args); $x++)
{
// Ist das Argument ein String, sprich ein Sortier-Feld?
if (is_string($args[$x]))
{
$value = $array[$field][$args[$x]];
${$args[$x]}[] = $value;
}
}
}
// Argumente für array_multisort bilden
for ($x=1; $x<count($args); $x++)
{
if (is_string($args[$x]))
{
// Argument ist ein TMP-Array
$params[] = &${$args[$x]};
}
else
{
// Argument ist ein Sort-Flag so wie z.B. "SORT_ASC"
$params[] = &$args[$x];
}
}
// Der letzte Parameter ist immer das zu sortierende Array (Referenz!)
$params[] = &$array;
// Array sortieren
call_user_func_array("array_multisort", $params);
@reset($array);
}
|
php
|
public static function sort2dArray(&$array, $sort_args)
{
$args = func_get_args();
// Für jedes zu sortierende Feld ein eigenes Array bilden
@reset($array);
while (list($field) = @each($array))
{
for ($x=1; $x<count($args); $x++)
{
// Ist das Argument ein String, sprich ein Sortier-Feld?
if (is_string($args[$x]))
{
$value = $array[$field][$args[$x]];
${$args[$x]}[] = $value;
}
}
}
// Argumente für array_multisort bilden
for ($x=1; $x<count($args); $x++)
{
if (is_string($args[$x]))
{
// Argument ist ein TMP-Array
$params[] = &${$args[$x]};
}
else
{
// Argument ist ein Sort-Flag so wie z.B. "SORT_ASC"
$params[] = &$args[$x];
}
}
// Der letzte Parameter ist immer das zu sortierende Array (Referenz!)
$params[] = &$array;
// Array sortieren
call_user_func_array("array_multisort", $params);
@reset($array);
}
|
[
"public",
"static",
"function",
"sort2dArray",
"(",
"&",
"$",
"array",
",",
"$",
"sort_args",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"// Für jedes zu sortierende Feld ein eigenes Array bilden\r",
"@",
"reset",
"(",
"$",
"array",
")",
";",
"while",
"(",
"list",
"(",
"$",
"field",
")",
"=",
"@",
"each",
"(",
"$",
"array",
")",
")",
"{",
"for",
"(",
"$",
"x",
"=",
"1",
";",
"$",
"x",
"<",
"count",
"(",
"$",
"args",
")",
";",
"$",
"x",
"++",
")",
"{",
"// Ist das Argument ein String, sprich ein Sortier-Feld?\r",
"if",
"(",
"is_string",
"(",
"$",
"args",
"[",
"$",
"x",
"]",
")",
")",
"{",
"$",
"value",
"=",
"$",
"array",
"[",
"$",
"field",
"]",
"[",
"$",
"args",
"[",
"$",
"x",
"]",
"]",
";",
"$",
"{",
"$",
"args",
"[",
"$",
"x",
"]",
"}",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"}",
"// Argumente für array_multisort bilden\r",
"for",
"(",
"$",
"x",
"=",
"1",
";",
"$",
"x",
"<",
"count",
"(",
"$",
"args",
")",
";",
"$",
"x",
"++",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"args",
"[",
"$",
"x",
"]",
")",
")",
"{",
"// Argument ist ein TMP-Array\r",
"$",
"params",
"[",
"]",
"=",
"&",
"$",
"{",
"$",
"args",
"[",
"$",
"x",
"]",
"}",
";",
"}",
"else",
"{",
"// Argument ist ein Sort-Flag so wie z.B. \"SORT_ASC\"\r",
"$",
"params",
"[",
"]",
"=",
"&",
"$",
"args",
"[",
"$",
"x",
"]",
";",
"}",
"}",
"// Der letzte Parameter ist immer das zu sortierende Array (Referenz!)\r",
"$",
"params",
"[",
"]",
"=",
"&",
"$",
"array",
";",
"// Array sortieren\r",
"call_user_func_array",
"(",
"\"array_multisort\"",
",",
"$",
"params",
")",
";",
"@",
"reset",
"(",
"$",
"array",
")",
";",
"}"
] |
Sorts a twodimensiolnal array.
|
[
"Sorts",
"a",
"twodimensiolnal",
"array",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/Utils/PHPCrawlerUtils.class.php#L504-L546
|
223,231
|
mmerian/phpcrawl
|
libs/Utils/PHPCrawlerUtils.class.php
|
PHPCrawlerUtils.getMetaTagAttributes
|
public static function getMetaTagAttributes(&$html_source)
{
preg_match_all("#<\s*meta\s+".
"name\s*=\s*(?|\"([^\"]+)\"|'([^']+)'|([^\s><'\"]+))\s+".
"content\s*=\s*(?|\"([^\"]+)\"|'([^']+)'|([^\s><'\"]+))".
".*># Uis", $html_source, $matches);
$tags = array();
for ($x=0; $x<count($matches[0]); $x++)
{
$meta_name = strtolower(trim($matches[1][$x]));
$meta_value = strtolower(trim($matches[2][$x]));
$tags[$meta_name] = $meta_value;
}
return $tags;
}
|
php
|
public static function getMetaTagAttributes(&$html_source)
{
preg_match_all("#<\s*meta\s+".
"name\s*=\s*(?|\"([^\"]+)\"|'([^']+)'|([^\s><'\"]+))\s+".
"content\s*=\s*(?|\"([^\"]+)\"|'([^']+)'|([^\s><'\"]+))".
".*># Uis", $html_source, $matches);
$tags = array();
for ($x=0; $x<count($matches[0]); $x++)
{
$meta_name = strtolower(trim($matches[1][$x]));
$meta_value = strtolower(trim($matches[2][$x]));
$tags[$meta_name] = $meta_value;
}
return $tags;
}
|
[
"public",
"static",
"function",
"getMetaTagAttributes",
"(",
"&",
"$",
"html_source",
")",
"{",
"preg_match_all",
"(",
"\"#<\\s*meta\\s+\"",
".",
"\"name\\s*=\\s*(?|\\\"([^\\\"]+)\\\"|'([^']+)'|([^\\s><'\\\"]+))\\s+\"",
".",
"\"content\\s*=\\s*(?|\\\"([^\\\"]+)\\\"|'([^']+)'|([^\\s><'\\\"]+))\"",
".",
"\".*># Uis\"",
",",
"$",
"html_source",
",",
"$",
"matches",
")",
";",
"$",
"tags",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"x",
"=",
"0",
";",
"$",
"x",
"<",
"count",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
";",
"$",
"x",
"++",
")",
"{",
"$",
"meta_name",
"=",
"strtolower",
"(",
"trim",
"(",
"$",
"matches",
"[",
"1",
"]",
"[",
"$",
"x",
"]",
")",
")",
";",
"$",
"meta_value",
"=",
"strtolower",
"(",
"trim",
"(",
"$",
"matches",
"[",
"2",
"]",
"[",
"$",
"x",
"]",
")",
")",
";",
"$",
"tags",
"[",
"$",
"meta_name",
"]",
"=",
"$",
"meta_value",
";",
"}",
"return",
"$",
"tags",
";",
"}"
] |
Gets all meta-tag atteributes from the given HTML-source.
@param &string &$html_source
@return array Assoziative array conatining all found meta-attributes.
The keys are the meta-names, the values the content of the attributes.
(like $tags["robots"] = "nofollow")
|
[
"Gets",
"all",
"meta",
"-",
"tag",
"atteributes",
"from",
"the",
"given",
"HTML",
"-",
"source",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/Utils/PHPCrawlerUtils.class.php#L568-L585
|
223,232
|
mmerian/phpcrawl
|
libs/Utils/PHPCrawlerUtils.class.php
|
PHPCrawlerUtils.getURIContent
|
public static function getURIContent($uri, $request_user_agent_string = null, $throw_exception = false)
{
$UriParts = PHPCrawlerUrlPartsDescriptor::fromURL($uri);
$error_str = "";
// If protocol is "file"
if ($UriParts->protocol == "file://")
{
$file = preg_replace("#^file://#", "", $uri);
if (file_exists($file) && is_readable($file))
return file_get_contents($file);
else
$error_str = "Error reading from file '".$file."'";
}
// If protocol is "http" or "https"
elseif ($UriParts->protocol == "http://" || $UriParts->protocol == "https://")
{
$uri = self::normalizeURL($uri);
$Request = new PHPCrawlerHTTPRequest();
$Request->setUrl(new PHPCrawlerURLDescriptor($uri));
if ($request_user_agent_string !== null)
$Request->userAgentString = $request_user_agent_string;
$DocInfo = $Request->sendRequest();
if ($DocInfo->received == true)
return $DocInfo->source;
else
$error_str = "Error reading from URL '".$uri."'";
}
// if protocol is not supported
else
{
$error_str = "Unsupported protocol-type '".$UriParts->protocol."'";
}
// Throw exception?
if ($throw_exception == true)
throw new Exception($error_str);
return null;
}
|
php
|
public static function getURIContent($uri, $request_user_agent_string = null, $throw_exception = false)
{
$UriParts = PHPCrawlerUrlPartsDescriptor::fromURL($uri);
$error_str = "";
// If protocol is "file"
if ($UriParts->protocol == "file://")
{
$file = preg_replace("#^file://#", "", $uri);
if (file_exists($file) && is_readable($file))
return file_get_contents($file);
else
$error_str = "Error reading from file '".$file."'";
}
// If protocol is "http" or "https"
elseif ($UriParts->protocol == "http://" || $UriParts->protocol == "https://")
{
$uri = self::normalizeURL($uri);
$Request = new PHPCrawlerHTTPRequest();
$Request->setUrl(new PHPCrawlerURLDescriptor($uri));
if ($request_user_agent_string !== null)
$Request->userAgentString = $request_user_agent_string;
$DocInfo = $Request->sendRequest();
if ($DocInfo->received == true)
return $DocInfo->source;
else
$error_str = "Error reading from URL '".$uri."'";
}
// if protocol is not supported
else
{
$error_str = "Unsupported protocol-type '".$UriParts->protocol."'";
}
// Throw exception?
if ($throw_exception == true)
throw new Exception($error_str);
return null;
}
|
[
"public",
"static",
"function",
"getURIContent",
"(",
"$",
"uri",
",",
"$",
"request_user_agent_string",
"=",
"null",
",",
"$",
"throw_exception",
"=",
"false",
")",
"{",
"$",
"UriParts",
"=",
"PHPCrawlerUrlPartsDescriptor",
"::",
"fromURL",
"(",
"$",
"uri",
")",
";",
"$",
"error_str",
"=",
"\"\"",
";",
"// If protocol is \"file\"\r",
"if",
"(",
"$",
"UriParts",
"->",
"protocol",
"==",
"\"file://\"",
")",
"{",
"$",
"file",
"=",
"preg_replace",
"(",
"\"#^file://#\"",
",",
"\"\"",
",",
"$",
"uri",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"file",
")",
"&&",
"is_readable",
"(",
"$",
"file",
")",
")",
"return",
"file_get_contents",
"(",
"$",
"file",
")",
";",
"else",
"$",
"error_str",
"=",
"\"Error reading from file '\"",
".",
"$",
"file",
".",
"\"'\"",
";",
"}",
"// If protocol is \"http\" or \"https\"\r",
"elseif",
"(",
"$",
"UriParts",
"->",
"protocol",
"==",
"\"http://\"",
"||",
"$",
"UriParts",
"->",
"protocol",
"==",
"\"https://\"",
")",
"{",
"$",
"uri",
"=",
"self",
"::",
"normalizeURL",
"(",
"$",
"uri",
")",
";",
"$",
"Request",
"=",
"new",
"PHPCrawlerHTTPRequest",
"(",
")",
";",
"$",
"Request",
"->",
"setUrl",
"(",
"new",
"PHPCrawlerURLDescriptor",
"(",
"$",
"uri",
")",
")",
";",
"if",
"(",
"$",
"request_user_agent_string",
"!==",
"null",
")",
"$",
"Request",
"->",
"userAgentString",
"=",
"$",
"request_user_agent_string",
";",
"$",
"DocInfo",
"=",
"$",
"Request",
"->",
"sendRequest",
"(",
")",
";",
"if",
"(",
"$",
"DocInfo",
"->",
"received",
"==",
"true",
")",
"return",
"$",
"DocInfo",
"->",
"source",
";",
"else",
"$",
"error_str",
"=",
"\"Error reading from URL '\"",
".",
"$",
"uri",
".",
"\"'\"",
";",
"}",
"// if protocol is not supported\r",
"else",
"{",
"$",
"error_str",
"=",
"\"Unsupported protocol-type '\"",
".",
"$",
"UriParts",
"->",
"protocol",
".",
"\"'\"",
";",
"}",
"// Throw exception?\r",
"if",
"(",
"$",
"throw_exception",
"==",
"true",
")",
"throw",
"new",
"Exception",
"(",
"$",
"error_str",
")",
";",
"return",
"null",
";",
"}"
] |
Gets the content from the given file or URL
@param string $uri The URI (like "file://../myfile.txt" or "http://foo.com")
@param string $request_user_agent_string The UrserAgent-string to use for URL-requests
@param bool $throw_exception If set to true, an exception will get thrown in case of an IO-error
@return string The content of thr URI or NULL if the content couldn't be read
|
[
"Gets",
"the",
"content",
"from",
"the",
"given",
"file",
"or",
"URL"
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/Utils/PHPCrawlerUtils.class.php#L607-L653
|
223,233
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php
|
ClassMetadataBuilder.setMappedSuperClass
|
public function setMappedSuperClass()
{
$this->cm->isMappedSuperclass = true;
$this->cm->isEmbeddedClass = false;
return $this;
}
|
php
|
public function setMappedSuperClass()
{
$this->cm->isMappedSuperclass = true;
$this->cm->isEmbeddedClass = false;
return $this;
}
|
[
"public",
"function",
"setMappedSuperClass",
"(",
")",
"{",
"$",
"this",
"->",
"cm",
"->",
"isMappedSuperclass",
"=",
"true",
";",
"$",
"this",
"->",
"cm",
"->",
"isEmbeddedClass",
"=",
"false",
";",
"return",
"$",
"this",
";",
"}"
] |
Marks the class as mapped superclass.
@return ClassMetadataBuilder
|
[
"Marks",
"the",
"class",
"as",
"mapped",
"superclass",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php#L62-L68
|
223,234
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php
|
ClassMetadataBuilder.setEmbeddable
|
public function setEmbeddable()
{
$this->cm->isEmbeddedClass = true;
$this->cm->isMappedSuperclass = false;
return $this;
}
|
php
|
public function setEmbeddable()
{
$this->cm->isEmbeddedClass = true;
$this->cm->isMappedSuperclass = false;
return $this;
}
|
[
"public",
"function",
"setEmbeddable",
"(",
")",
"{",
"$",
"this",
"->",
"cm",
"->",
"isEmbeddedClass",
"=",
"true",
";",
"$",
"this",
"->",
"cm",
"->",
"isMappedSuperclass",
"=",
"false",
";",
"return",
"$",
"this",
";",
"}"
] |
Marks the class as embeddable.
@return ClassMetadataBuilder
|
[
"Marks",
"the",
"class",
"as",
"embeddable",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php#L75-L81
|
223,235
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php
|
ClassMetadataBuilder.addEmbedded
|
public function addEmbedded($fieldName, $class, $columnPrefix = null)
{
$this->cm->mapEmbedded(array(
'fieldName' => $fieldName,
'class' => $class,
'columnPrefix' => $columnPrefix
));
return $this;
}
|
php
|
public function addEmbedded($fieldName, $class, $columnPrefix = null)
{
$this->cm->mapEmbedded(array(
'fieldName' => $fieldName,
'class' => $class,
'columnPrefix' => $columnPrefix
));
return $this;
}
|
[
"public",
"function",
"addEmbedded",
"(",
"$",
"fieldName",
",",
"$",
"class",
",",
"$",
"columnPrefix",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"cm",
"->",
"mapEmbedded",
"(",
"array",
"(",
"'fieldName'",
"=>",
"$",
"fieldName",
",",
"'class'",
"=>",
"$",
"class",
",",
"'columnPrefix'",
"=>",
"$",
"columnPrefix",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds and embedded class
@param string $fieldName
@param string $class
@param string|null $columnPrefix
@return $this
|
[
"Adds",
"and",
"embedded",
"class"
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php#L92-L101
|
223,236
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php
|
ClassMetadataBuilder.addIndex
|
public function addIndex(array $columns, $name)
{
if (!isset($this->cm->table['indexes'])) {
$this->cm->table['indexes'] = array();
}
$this->cm->table['indexes'][$name] = array('columns' => $columns);
return $this;
}
|
php
|
public function addIndex(array $columns, $name)
{
if (!isset($this->cm->table['indexes'])) {
$this->cm->table['indexes'] = array();
}
$this->cm->table['indexes'][$name] = array('columns' => $columns);
return $this;
}
|
[
"public",
"function",
"addIndex",
"(",
"array",
"$",
"columns",
",",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"cm",
"->",
"table",
"[",
"'indexes'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"cm",
"->",
"table",
"[",
"'indexes'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"cm",
"->",
"table",
"[",
"'indexes'",
"]",
"[",
"$",
"name",
"]",
"=",
"array",
"(",
"'columns'",
"=>",
"$",
"columns",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds Index.
@param array $columns
@param string $name
@return ClassMetadataBuilder
|
[
"Adds",
"Index",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php#L151-L160
|
223,237
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php
|
ClassMetadataBuilder.addUniqueConstraint
|
public function addUniqueConstraint(array $columns, $name)
{
if ( ! isset($this->cm->table['uniqueConstraints'])) {
$this->cm->table['uniqueConstraints'] = array();
}
$this->cm->table['uniqueConstraints'][$name] = array('columns' => $columns);
return $this;
}
|
php
|
public function addUniqueConstraint(array $columns, $name)
{
if ( ! isset($this->cm->table['uniqueConstraints'])) {
$this->cm->table['uniqueConstraints'] = array();
}
$this->cm->table['uniqueConstraints'][$name] = array('columns' => $columns);
return $this;
}
|
[
"public",
"function",
"addUniqueConstraint",
"(",
"array",
"$",
"columns",
",",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"cm",
"->",
"table",
"[",
"'uniqueConstraints'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"cm",
"->",
"table",
"[",
"'uniqueConstraints'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"cm",
"->",
"table",
"[",
"'uniqueConstraints'",
"]",
"[",
"$",
"name",
"]",
"=",
"array",
"(",
"'columns'",
"=>",
"$",
"columns",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds Unique Constraint.
@param array $columns
@param string $name
@return ClassMetadataBuilder
|
[
"Adds",
"Unique",
"Constraint",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php#L170-L179
|
223,238
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php
|
ClassMetadataBuilder.setDiscriminatorColumn
|
public function setDiscriminatorColumn($name, $type = 'string', $length = 255)
{
$this->cm->setDiscriminatorColumn(array(
'name' => $name,
'type' => $type,
'length' => $length,
));
return $this;
}
|
php
|
public function setDiscriminatorColumn($name, $type = 'string', $length = 255)
{
$this->cm->setDiscriminatorColumn(array(
'name' => $name,
'type' => $type,
'length' => $length,
));
return $this;
}
|
[
"public",
"function",
"setDiscriminatorColumn",
"(",
"$",
"name",
",",
"$",
"type",
"=",
"'string'",
",",
"$",
"length",
"=",
"255",
")",
"{",
"$",
"this",
"->",
"cm",
"->",
"setDiscriminatorColumn",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"name",
",",
"'type'",
"=>",
"$",
"type",
",",
"'length'",
"=>",
"$",
"length",
",",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the discriminator column details.
@param string $name
@param string $type
@param int $length
@return ClassMetadataBuilder
|
[
"Sets",
"the",
"discriminator",
"column",
"details",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php#L232-L241
|
223,239
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php
|
ClassMetadataBuilder.addField
|
public function addField($name, $type, array $mapping = array())
{
$mapping['fieldName'] = $name;
$mapping['type'] = $type;
$this->cm->mapField($mapping);
return $this;
}
|
php
|
public function addField($name, $type, array $mapping = array())
{
$mapping['fieldName'] = $name;
$mapping['type'] = $type;
$this->cm->mapField($mapping);
return $this;
}
|
[
"public",
"function",
"addField",
"(",
"$",
"name",
",",
"$",
"type",
",",
"array",
"$",
"mapping",
"=",
"array",
"(",
")",
")",
"{",
"$",
"mapping",
"[",
"'fieldName'",
"]",
"=",
"$",
"name",
";",
"$",
"mapping",
"[",
"'type'",
"]",
"=",
"$",
"type",
";",
"$",
"this",
"->",
"cm",
"->",
"mapField",
"(",
"$",
"mapping",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds Field.
@param string $name
@param string $type
@param array $mapping
@return ClassMetadataBuilder
|
[
"Adds",
"Field",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php#L306-L314
|
223,240
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php
|
ClassMetadataBuilder.addManyToOne
|
public function addManyToOne($name, $targetEntity, $inversedBy = null)
{
$builder = $this->createManyToOne($name, $targetEntity);
if ($inversedBy) {
$builder->inversedBy($inversedBy);
}
return $builder->build();
}
|
php
|
public function addManyToOne($name, $targetEntity, $inversedBy = null)
{
$builder = $this->createManyToOne($name, $targetEntity);
if ($inversedBy) {
$builder->inversedBy($inversedBy);
}
return $builder->build();
}
|
[
"public",
"function",
"addManyToOne",
"(",
"$",
"name",
",",
"$",
"targetEntity",
",",
"$",
"inversedBy",
"=",
"null",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"createManyToOne",
"(",
"$",
"name",
",",
"$",
"targetEntity",
")",
";",
"if",
"(",
"$",
"inversedBy",
")",
"{",
"$",
"builder",
"->",
"inversedBy",
"(",
"$",
"inversedBy",
")",
";",
"}",
"return",
"$",
"builder",
"->",
"build",
"(",
")",
";",
"}"
] |
Adds a simple many to one association, optionally with the inversed by field.
@param string $name
@param string $targetEntity
@param string|null $inversedBy
@return ClassMetadataBuilder
|
[
"Adds",
"a",
"simple",
"many",
"to",
"one",
"association",
"optionally",
"with",
"the",
"inversed",
"by",
"field",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php#L364-L373
|
223,241
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php
|
ClassMetadataBuilder.addInverseOneToOne
|
public function addInverseOneToOne($name, $targetEntity, $mappedBy)
{
$builder = $this->createOneToOne($name, $targetEntity);
$builder->mappedBy($mappedBy);
return $builder->build();
}
|
php
|
public function addInverseOneToOne($name, $targetEntity, $mappedBy)
{
$builder = $this->createOneToOne($name, $targetEntity);
$builder->mappedBy($mappedBy);
return $builder->build();
}
|
[
"public",
"function",
"addInverseOneToOne",
"(",
"$",
"name",
",",
"$",
"targetEntity",
",",
"$",
"mappedBy",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"createOneToOne",
"(",
"$",
"name",
",",
"$",
"targetEntity",
")",
";",
"$",
"builder",
"->",
"mappedBy",
"(",
"$",
"mappedBy",
")",
";",
"return",
"$",
"builder",
"->",
"build",
"(",
")",
";",
"}"
] |
Adds simple inverse one-to-one association.
@param string $name
@param string $targetEntity
@param string $mappedBy
@return ClassMetadataBuilder
|
[
"Adds",
"simple",
"inverse",
"one",
"-",
"to",
"-",
"one",
"association",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php#L426-L432
|
223,242
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php
|
ClassMetadataBuilder.addOwningOneToOne
|
public function addOwningOneToOne($name, $targetEntity, $inversedBy = null)
{
$builder = $this->createOneToOne($name, $targetEntity);
if ($inversedBy) {
$builder->inversedBy($inversedBy);
}
return $builder->build();
}
|
php
|
public function addOwningOneToOne($name, $targetEntity, $inversedBy = null)
{
$builder = $this->createOneToOne($name, $targetEntity);
if ($inversedBy) {
$builder->inversedBy($inversedBy);
}
return $builder->build();
}
|
[
"public",
"function",
"addOwningOneToOne",
"(",
"$",
"name",
",",
"$",
"targetEntity",
",",
"$",
"inversedBy",
"=",
"null",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"createOneToOne",
"(",
"$",
"name",
",",
"$",
"targetEntity",
")",
";",
"if",
"(",
"$",
"inversedBy",
")",
"{",
"$",
"builder",
"->",
"inversedBy",
"(",
"$",
"inversedBy",
")",
";",
"}",
"return",
"$",
"builder",
"->",
"build",
"(",
")",
";",
"}"
] |
Adds simple owning one-to-one association.
@param string $name
@param string $targetEntity
@param string|null $inversedBy
@return ClassMetadataBuilder
|
[
"Adds",
"simple",
"owning",
"one",
"-",
"to",
"-",
"one",
"association",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php#L443-L452
|
223,243
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php
|
ClassMetadataBuilder.addOwningManyToMany
|
public function addOwningManyToMany($name, $targetEntity, $inversedBy = null)
{
$builder = $this->createManyToMany($name, $targetEntity);
if ($inversedBy) {
$builder->inversedBy($inversedBy);
}
return $builder->build();
}
|
php
|
public function addOwningManyToMany($name, $targetEntity, $inversedBy = null)
{
$builder = $this->createManyToMany($name, $targetEntity);
if ($inversedBy) {
$builder->inversedBy($inversedBy);
}
return $builder->build();
}
|
[
"public",
"function",
"addOwningManyToMany",
"(",
"$",
"name",
",",
"$",
"targetEntity",
",",
"$",
"inversedBy",
"=",
"null",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"createManyToMany",
"(",
"$",
"name",
",",
"$",
"targetEntity",
")",
";",
"if",
"(",
"$",
"inversedBy",
")",
"{",
"$",
"builder",
"->",
"inversedBy",
"(",
"$",
"inversedBy",
")",
";",
"}",
"return",
"$",
"builder",
"->",
"build",
"(",
")",
";",
"}"
] |
Adds a simple owning many to many association.
@param string $name
@param string $targetEntity
@param string|null $inversedBy
@return ClassMetadataBuilder
|
[
"Adds",
"a",
"simple",
"owning",
"many",
"to",
"many",
"association",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php#L483-L492
|
223,244
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php
|
ClassMetadataBuilder.addInverseManyToMany
|
public function addInverseManyToMany($name, $targetEntity, $mappedBy)
{
$builder = $this->createManyToMany($name, $targetEntity);
$builder->mappedBy($mappedBy);
return $builder->build();
}
|
php
|
public function addInverseManyToMany($name, $targetEntity, $mappedBy)
{
$builder = $this->createManyToMany($name, $targetEntity);
$builder->mappedBy($mappedBy);
return $builder->build();
}
|
[
"public",
"function",
"addInverseManyToMany",
"(",
"$",
"name",
",",
"$",
"targetEntity",
",",
"$",
"mappedBy",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"createManyToMany",
"(",
"$",
"name",
",",
"$",
"targetEntity",
")",
";",
"$",
"builder",
"->",
"mappedBy",
"(",
"$",
"mappedBy",
")",
";",
"return",
"$",
"builder",
"->",
"build",
"(",
")",
";",
"}"
] |
Adds a simple inverse many to many association.
@param string $name
@param string $targetEntity
@param string $mappedBy
@return ClassMetadataBuilder
|
[
"Adds",
"a",
"simple",
"inverse",
"many",
"to",
"many",
"association",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php#L503-L509
|
223,245
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php
|
ClassMetadataBuilder.addOneToMany
|
public function addOneToMany($name, $targetEntity, $mappedBy)
{
$builder = $this->createOneToMany($name, $targetEntity);
$builder->mappedBy($mappedBy);
return $builder->build();
}
|
php
|
public function addOneToMany($name, $targetEntity, $mappedBy)
{
$builder = $this->createOneToMany($name, $targetEntity);
$builder->mappedBy($mappedBy);
return $builder->build();
}
|
[
"public",
"function",
"addOneToMany",
"(",
"$",
"name",
",",
"$",
"targetEntity",
",",
"$",
"mappedBy",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"createOneToMany",
"(",
"$",
"name",
",",
"$",
"targetEntity",
")",
";",
"$",
"builder",
"->",
"mappedBy",
"(",
"$",
"mappedBy",
")",
";",
"return",
"$",
"builder",
"->",
"build",
"(",
")",
";",
"}"
] |
Adds simple OneToMany association.
@param string $name
@param string $targetEntity
@param string $mappedBy
@return ClassMetadataBuilder
|
[
"Adds",
"simple",
"OneToMany",
"association",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php#L540-L546
|
223,246
|
mespronos/mespronos
|
src/Entity/Game.php
|
Game.removeBets
|
public function removeBets() {
$query = \Drupal::entityQuery('bet');
$query->condition('game', $this->id());
$ids = $query->execute();
$bets = Bet::loadMultiple($ids);
foreach ($bets as $bet) {
$bet->delete();
}
\Drupal::logger('mespronos')->notice(t('Bets removed on game #@id (@game_label) : @nb_bets removed', [
'@id' => $this->id(),
'@game_label' => $this->label(),
'@nb_bets' => \count($ids),
]));
return \count($ids);
}
|
php
|
public function removeBets() {
$query = \Drupal::entityQuery('bet');
$query->condition('game', $this->id());
$ids = $query->execute();
$bets = Bet::loadMultiple($ids);
foreach ($bets as $bet) {
$bet->delete();
}
\Drupal::logger('mespronos')->notice(t('Bets removed on game #@id (@game_label) : @nb_bets removed', [
'@id' => $this->id(),
'@game_label' => $this->label(),
'@nb_bets' => \count($ids),
]));
return \count($ids);
}
|
[
"public",
"function",
"removeBets",
"(",
")",
"{",
"$",
"query",
"=",
"\\",
"Drupal",
"::",
"entityQuery",
"(",
"'bet'",
")",
";",
"$",
"query",
"->",
"condition",
"(",
"'game'",
",",
"$",
"this",
"->",
"id",
"(",
")",
")",
";",
"$",
"ids",
"=",
"$",
"query",
"->",
"execute",
"(",
")",
";",
"$",
"bets",
"=",
"Bet",
"::",
"loadMultiple",
"(",
"$",
"ids",
")",
";",
"foreach",
"(",
"$",
"bets",
"as",
"$",
"bet",
")",
"{",
"$",
"bet",
"->",
"delete",
"(",
")",
";",
"}",
"\\",
"Drupal",
"::",
"logger",
"(",
"'mespronos'",
")",
"->",
"notice",
"(",
"t",
"(",
"'Bets removed on game #@id (@game_label) : @nb_bets removed'",
",",
"[",
"'@id'",
"=>",
"$",
"this",
"->",
"id",
"(",
")",
",",
"'@game_label'",
"=>",
"$",
"this",
"->",
"label",
"(",
")",
",",
"'@nb_bets'",
"=>",
"\\",
"count",
"(",
"$",
"ids",
")",
",",
"]",
")",
")",
";",
"return",
"\\",
"count",
"(",
"$",
"ids",
")",
";",
"}"
] |
Remove bets on current day
@return integer number of deleted bets
|
[
"Remove",
"bets",
"on",
"current",
"day"
] |
73757663581ed9040944768073d1d9abc761196b
|
https://github.com/mespronos/mespronos/blob/73757663581ed9040944768073d1d9abc761196b/src/Entity/Game.php#L123-L137
|
223,247
|
imanee/imanee
|
src/PixelMath.php
|
PixelMath.getPlacementCoordinates
|
public static function getPlacementCoordinates(
$resourceSize = [],
$size = [],
$place_constant = Imanee::IM_POS_TOP_LEFT
) {
$x = 0;
$y = 0;
switch ($place_constant) {
case Imanee::IM_POS_TOP_CENTER:
$x = ($size['width'] / 2) - ($resourceSize['width'] / 2);
break;
case Imanee::IM_POS_TOP_RIGHT:
$x = ($size['width']) - ($resourceSize['width']);
break;
case Imanee::IM_POS_MID_LEFT:
$y = ($size['height'] / 2) - ($resourceSize['height'] / 2);
break;
case Imanee::IM_POS_MID_CENTER:
$x = ($size['width'] / 2) - ($resourceSize['width'] / 2);
$y = ($size['height'] / 2) - ($resourceSize['height'] / 2);
break;
case Imanee::IM_POS_MID_RIGHT:
$x = ($size['width']) - ($resourceSize['width']);
$y = ($size['height'] / 2) - ($resourceSize['height'] / 2);
break;
case Imanee::IM_POS_BOTTOM_LEFT:
$y = ($size['height']) - ($resourceSize['height']);
break;
case Imanee::IM_POS_BOTTOM_CENTER:
$x = ($size['width'] / 2) - ($resourceSize['width'] / 2);
$y = ($size['height']) - ($resourceSize['height']);
break;
case Imanee::IM_POS_BOTTOM_RIGHT:
$x = ($size['width']) - ($resourceSize['width']);
$y = ($size['height']) - ($resourceSize['height']);
break;
}
return [
(int) floor($x),
(int) floor($y)
];
}
|
php
|
public static function getPlacementCoordinates(
$resourceSize = [],
$size = [],
$place_constant = Imanee::IM_POS_TOP_LEFT
) {
$x = 0;
$y = 0;
switch ($place_constant) {
case Imanee::IM_POS_TOP_CENTER:
$x = ($size['width'] / 2) - ($resourceSize['width'] / 2);
break;
case Imanee::IM_POS_TOP_RIGHT:
$x = ($size['width']) - ($resourceSize['width']);
break;
case Imanee::IM_POS_MID_LEFT:
$y = ($size['height'] / 2) - ($resourceSize['height'] / 2);
break;
case Imanee::IM_POS_MID_CENTER:
$x = ($size['width'] / 2) - ($resourceSize['width'] / 2);
$y = ($size['height'] / 2) - ($resourceSize['height'] / 2);
break;
case Imanee::IM_POS_MID_RIGHT:
$x = ($size['width']) - ($resourceSize['width']);
$y = ($size['height'] / 2) - ($resourceSize['height'] / 2);
break;
case Imanee::IM_POS_BOTTOM_LEFT:
$y = ($size['height']) - ($resourceSize['height']);
break;
case Imanee::IM_POS_BOTTOM_CENTER:
$x = ($size['width'] / 2) - ($resourceSize['width'] / 2);
$y = ($size['height']) - ($resourceSize['height']);
break;
case Imanee::IM_POS_BOTTOM_RIGHT:
$x = ($size['width']) - ($resourceSize['width']);
$y = ($size['height']) - ($resourceSize['height']);
break;
}
return [
(int) floor($x),
(int) floor($y)
];
}
|
[
"public",
"static",
"function",
"getPlacementCoordinates",
"(",
"$",
"resourceSize",
"=",
"[",
"]",
",",
"$",
"size",
"=",
"[",
"]",
",",
"$",
"place_constant",
"=",
"Imanee",
"::",
"IM_POS_TOP_LEFT",
")",
"{",
"$",
"x",
"=",
"0",
";",
"$",
"y",
"=",
"0",
";",
"switch",
"(",
"$",
"place_constant",
")",
"{",
"case",
"Imanee",
"::",
"IM_POS_TOP_CENTER",
":",
"$",
"x",
"=",
"(",
"$",
"size",
"[",
"'width'",
"]",
"/",
"2",
")",
"-",
"(",
"$",
"resourceSize",
"[",
"'width'",
"]",
"/",
"2",
")",
";",
"break",
";",
"case",
"Imanee",
"::",
"IM_POS_TOP_RIGHT",
":",
"$",
"x",
"=",
"(",
"$",
"size",
"[",
"'width'",
"]",
")",
"-",
"(",
"$",
"resourceSize",
"[",
"'width'",
"]",
")",
";",
"break",
";",
"case",
"Imanee",
"::",
"IM_POS_MID_LEFT",
":",
"$",
"y",
"=",
"(",
"$",
"size",
"[",
"'height'",
"]",
"/",
"2",
")",
"-",
"(",
"$",
"resourceSize",
"[",
"'height'",
"]",
"/",
"2",
")",
";",
"break",
";",
"case",
"Imanee",
"::",
"IM_POS_MID_CENTER",
":",
"$",
"x",
"=",
"(",
"$",
"size",
"[",
"'width'",
"]",
"/",
"2",
")",
"-",
"(",
"$",
"resourceSize",
"[",
"'width'",
"]",
"/",
"2",
")",
";",
"$",
"y",
"=",
"(",
"$",
"size",
"[",
"'height'",
"]",
"/",
"2",
")",
"-",
"(",
"$",
"resourceSize",
"[",
"'height'",
"]",
"/",
"2",
")",
";",
"break",
";",
"case",
"Imanee",
"::",
"IM_POS_MID_RIGHT",
":",
"$",
"x",
"=",
"(",
"$",
"size",
"[",
"'width'",
"]",
")",
"-",
"(",
"$",
"resourceSize",
"[",
"'width'",
"]",
")",
";",
"$",
"y",
"=",
"(",
"$",
"size",
"[",
"'height'",
"]",
"/",
"2",
")",
"-",
"(",
"$",
"resourceSize",
"[",
"'height'",
"]",
"/",
"2",
")",
";",
"break",
";",
"case",
"Imanee",
"::",
"IM_POS_BOTTOM_LEFT",
":",
"$",
"y",
"=",
"(",
"$",
"size",
"[",
"'height'",
"]",
")",
"-",
"(",
"$",
"resourceSize",
"[",
"'height'",
"]",
")",
";",
"break",
";",
"case",
"Imanee",
"::",
"IM_POS_BOTTOM_CENTER",
":",
"$",
"x",
"=",
"(",
"$",
"size",
"[",
"'width'",
"]",
"/",
"2",
")",
"-",
"(",
"$",
"resourceSize",
"[",
"'width'",
"]",
"/",
"2",
")",
";",
"$",
"y",
"=",
"(",
"$",
"size",
"[",
"'height'",
"]",
")",
"-",
"(",
"$",
"resourceSize",
"[",
"'height'",
"]",
")",
";",
"break",
";",
"case",
"Imanee",
"::",
"IM_POS_BOTTOM_RIGHT",
":",
"$",
"x",
"=",
"(",
"$",
"size",
"[",
"'width'",
"]",
")",
"-",
"(",
"$",
"resourceSize",
"[",
"'width'",
"]",
")",
";",
"$",
"y",
"=",
"(",
"$",
"size",
"[",
"'height'",
"]",
")",
"-",
"(",
"$",
"resourceSize",
"[",
"'height'",
"]",
")",
";",
"break",
";",
"}",
"return",
"[",
"(",
"int",
")",
"floor",
"(",
"$",
"x",
")",
",",
"(",
"int",
")",
"floor",
"(",
"$",
"y",
")",
"]",
";",
"}"
] |
Gets the coordinates for a relative placement using the IM_POS constants.
@param array $resourceSize An array with the keys 'width' and 'height' from the image to be
placed.
@param array $size An array with they keys 'width' and 'height' from the original,
base image.
@param int $place_constant An Imanee::IM_POS_* constant.
@return int[] Returns an array with the first position representing the X coordinate and the
second position representing the Y coordinate for placing the image.
|
[
"Gets",
"the",
"coordinates",
"for",
"a",
"relative",
"placement",
"using",
"the",
"IM_POS",
"constants",
"."
] |
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
|
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/PixelMath.php#L73-L124
|
223,248
|
mmerian/phpcrawl
|
libs/PHPCrawler.class.php
|
PHPCrawler.initCrawlerProcess
|
protected function initCrawlerProcess()
{
// Create working directory
$this->createWorkingDirectory();
// Setup url-cache
if ($this->url_cache_type == PHPCrawlerUrlCacheTypes::URLCACHE_SQLITE)
$this->LinkCache = new PHPCrawlerSQLiteURLCache($this->working_directory."urlcache.db3", true);
else
$this->LinkCache = new PHPCrawlerMemoryURLCache();
// Perge/cleanup SQLite-urlcache for resumed crawling-processes (only ONCE!)
if ($this->url_cache_type == PHPCrawlerUrlCacheTypes::URLCACHE_SQLITE && $this->urlcache_purged == false)
{
$this->LinkCache->purgeCache();
$this->urlcache_purged = true;
}
// Setup cookie-cache (use SQLite-cache if crawler runs multi-processed)
if ($this->url_cache_type == PHPCrawlerUrlCacheTypes::URLCACHE_SQLITE)
$this->CookieCache = new PHPCrawlerSQLiteCookieCache($this->working_directory."cookiecache.db3", true);
else $this->CookieCache = new PHPCrawlerMemoryCookieCache();
// ProcessHandler
$this->ProcessHandler = new PHPCrawlerProcessHandler($this->crawler_uniqid, $this->working_directory);
// Setup PHPCrawlerStatusHandler
$this->CrawlerStatusHandler = new PHPCrawlerStatusHandler($this->crawler_uniqid, $this->working_directory);
$this->setupCrawlerStatusHandler();
// DocumentInfo-Queue
if ($this->multiprocess_mode == PHPCrawlerMultiProcessModes::MPMODE_PARENT_EXECUTES_USERCODE)
$this->DocumentInfoQueue = new PHPCrawlerDocumentInfoQueue($this->working_directory."doc_queue.db3", true);
// Set tmp-file for PageRequest
$this->PageRequest->setTmpFile($this->working_directory."phpcrawl_".getmypid().".tmp");
// Pass url-priorities to link-cache
$this->LinkCache->addLinkPriorities($this->link_priority_array);
// Pass base-URL to the UrlFilter
$this->UrlFilter->setBaseURL($this->starting_url);
// Add the starting-URL to the url-cache with link-depth 0
$url_descriptor = new PHPCrawlerURLDescriptor($this->starting_url);
$url_descriptor->url_link_depth = 0;
$this->LinkCache->addUrl($url_descriptor);
}
|
php
|
protected function initCrawlerProcess()
{
// Create working directory
$this->createWorkingDirectory();
// Setup url-cache
if ($this->url_cache_type == PHPCrawlerUrlCacheTypes::URLCACHE_SQLITE)
$this->LinkCache = new PHPCrawlerSQLiteURLCache($this->working_directory."urlcache.db3", true);
else
$this->LinkCache = new PHPCrawlerMemoryURLCache();
// Perge/cleanup SQLite-urlcache for resumed crawling-processes (only ONCE!)
if ($this->url_cache_type == PHPCrawlerUrlCacheTypes::URLCACHE_SQLITE && $this->urlcache_purged == false)
{
$this->LinkCache->purgeCache();
$this->urlcache_purged = true;
}
// Setup cookie-cache (use SQLite-cache if crawler runs multi-processed)
if ($this->url_cache_type == PHPCrawlerUrlCacheTypes::URLCACHE_SQLITE)
$this->CookieCache = new PHPCrawlerSQLiteCookieCache($this->working_directory."cookiecache.db3", true);
else $this->CookieCache = new PHPCrawlerMemoryCookieCache();
// ProcessHandler
$this->ProcessHandler = new PHPCrawlerProcessHandler($this->crawler_uniqid, $this->working_directory);
// Setup PHPCrawlerStatusHandler
$this->CrawlerStatusHandler = new PHPCrawlerStatusHandler($this->crawler_uniqid, $this->working_directory);
$this->setupCrawlerStatusHandler();
// DocumentInfo-Queue
if ($this->multiprocess_mode == PHPCrawlerMultiProcessModes::MPMODE_PARENT_EXECUTES_USERCODE)
$this->DocumentInfoQueue = new PHPCrawlerDocumentInfoQueue($this->working_directory."doc_queue.db3", true);
// Set tmp-file for PageRequest
$this->PageRequest->setTmpFile($this->working_directory."phpcrawl_".getmypid().".tmp");
// Pass url-priorities to link-cache
$this->LinkCache->addLinkPriorities($this->link_priority_array);
// Pass base-URL to the UrlFilter
$this->UrlFilter->setBaseURL($this->starting_url);
// Add the starting-URL to the url-cache with link-depth 0
$url_descriptor = new PHPCrawlerURLDescriptor($this->starting_url);
$url_descriptor->url_link_depth = 0;
$this->LinkCache->addUrl($url_descriptor);
}
|
[
"protected",
"function",
"initCrawlerProcess",
"(",
")",
"{",
"// Create working directory\r",
"$",
"this",
"->",
"createWorkingDirectory",
"(",
")",
";",
"// Setup url-cache\r",
"if",
"(",
"$",
"this",
"->",
"url_cache_type",
"==",
"PHPCrawlerUrlCacheTypes",
"::",
"URLCACHE_SQLITE",
")",
"$",
"this",
"->",
"LinkCache",
"=",
"new",
"PHPCrawlerSQLiteURLCache",
"(",
"$",
"this",
"->",
"working_directory",
".",
"\"urlcache.db3\"",
",",
"true",
")",
";",
"else",
"$",
"this",
"->",
"LinkCache",
"=",
"new",
"PHPCrawlerMemoryURLCache",
"(",
")",
";",
"// Perge/cleanup SQLite-urlcache for resumed crawling-processes (only ONCE!)\r",
"if",
"(",
"$",
"this",
"->",
"url_cache_type",
"==",
"PHPCrawlerUrlCacheTypes",
"::",
"URLCACHE_SQLITE",
"&&",
"$",
"this",
"->",
"urlcache_purged",
"==",
"false",
")",
"{",
"$",
"this",
"->",
"LinkCache",
"->",
"purgeCache",
"(",
")",
";",
"$",
"this",
"->",
"urlcache_purged",
"=",
"true",
";",
"}",
"// Setup cookie-cache (use SQLite-cache if crawler runs multi-processed)\r",
"if",
"(",
"$",
"this",
"->",
"url_cache_type",
"==",
"PHPCrawlerUrlCacheTypes",
"::",
"URLCACHE_SQLITE",
")",
"$",
"this",
"->",
"CookieCache",
"=",
"new",
"PHPCrawlerSQLiteCookieCache",
"(",
"$",
"this",
"->",
"working_directory",
".",
"\"cookiecache.db3\"",
",",
"true",
")",
";",
"else",
"$",
"this",
"->",
"CookieCache",
"=",
"new",
"PHPCrawlerMemoryCookieCache",
"(",
")",
";",
"// ProcessHandler\r",
"$",
"this",
"->",
"ProcessHandler",
"=",
"new",
"PHPCrawlerProcessHandler",
"(",
"$",
"this",
"->",
"crawler_uniqid",
",",
"$",
"this",
"->",
"working_directory",
")",
";",
"// Setup PHPCrawlerStatusHandler\r",
"$",
"this",
"->",
"CrawlerStatusHandler",
"=",
"new",
"PHPCrawlerStatusHandler",
"(",
"$",
"this",
"->",
"crawler_uniqid",
",",
"$",
"this",
"->",
"working_directory",
")",
";",
"$",
"this",
"->",
"setupCrawlerStatusHandler",
"(",
")",
";",
"// DocumentInfo-Queue\r",
"if",
"(",
"$",
"this",
"->",
"multiprocess_mode",
"==",
"PHPCrawlerMultiProcessModes",
"::",
"MPMODE_PARENT_EXECUTES_USERCODE",
")",
"$",
"this",
"->",
"DocumentInfoQueue",
"=",
"new",
"PHPCrawlerDocumentInfoQueue",
"(",
"$",
"this",
"->",
"working_directory",
".",
"\"doc_queue.db3\"",
",",
"true",
")",
";",
"// Set tmp-file for PageRequest\r",
"$",
"this",
"->",
"PageRequest",
"->",
"setTmpFile",
"(",
"$",
"this",
"->",
"working_directory",
".",
"\"phpcrawl_\"",
".",
"getmypid",
"(",
")",
".",
"\".tmp\"",
")",
";",
"// Pass url-priorities to link-cache\r",
"$",
"this",
"->",
"LinkCache",
"->",
"addLinkPriorities",
"(",
"$",
"this",
"->",
"link_priority_array",
")",
";",
"// Pass base-URL to the UrlFilter\r",
"$",
"this",
"->",
"UrlFilter",
"->",
"setBaseURL",
"(",
"$",
"this",
"->",
"starting_url",
")",
";",
"// Add the starting-URL to the url-cache with link-depth 0\r",
"$",
"url_descriptor",
"=",
"new",
"PHPCrawlerURLDescriptor",
"(",
"$",
"this",
"->",
"starting_url",
")",
";",
"$",
"url_descriptor",
"->",
"url_link_depth",
"=",
"0",
";",
"$",
"this",
"->",
"LinkCache",
"->",
"addUrl",
"(",
"$",
"url_descriptor",
")",
";",
"}"
] |
Initiates a crawler-process
|
[
"Initiates",
"a",
"crawler",
"-",
"process"
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawler.class.php#L300-L347
|
223,249
|
mmerian/phpcrawl
|
libs/PHPCrawler.class.php
|
PHPCrawler.setupCrawlerStatusHandler
|
protected function setupCrawlerStatusHandler()
{
// Cases the crawlerstatus has to be written to file
if ($this->multiprocess_mode == PHPCrawlerMultiProcessModes::MPMODE_CHILDS_EXECUTES_USERCODE || $this->resumtion_enabled == true)
{
$this->CrawlerStatusHandler->write_status_to_file = true;
}
if ($this->request_delay_time != null && $this->multiprocess_mode != PHPCrawlerMultiProcessModes::MPMODE_NONE)
{
$this->CrawlerStatusHandler->write_status_to_file = true;
}
// Cases a crawlerstatus-update has to be locked
if ($this->multiprocess_mode == PHPCrawlerMultiProcessModes::MPMODE_CHILDS_EXECUTES_USERCODE)
{
$this->CrawlerStatusHandler->lock_status_updates = true;
}
if ($this->request_delay_time != null && $this->multiprocess_mode != PHPCrawlerMultiProcessModes::MPMODE_NONE)
{
$this->CrawlerStatusHandler->lock_status_updates = true;
}
}
|
php
|
protected function setupCrawlerStatusHandler()
{
// Cases the crawlerstatus has to be written to file
if ($this->multiprocess_mode == PHPCrawlerMultiProcessModes::MPMODE_CHILDS_EXECUTES_USERCODE || $this->resumtion_enabled == true)
{
$this->CrawlerStatusHandler->write_status_to_file = true;
}
if ($this->request_delay_time != null && $this->multiprocess_mode != PHPCrawlerMultiProcessModes::MPMODE_NONE)
{
$this->CrawlerStatusHandler->write_status_to_file = true;
}
// Cases a crawlerstatus-update has to be locked
if ($this->multiprocess_mode == PHPCrawlerMultiProcessModes::MPMODE_CHILDS_EXECUTES_USERCODE)
{
$this->CrawlerStatusHandler->lock_status_updates = true;
}
if ($this->request_delay_time != null && $this->multiprocess_mode != PHPCrawlerMultiProcessModes::MPMODE_NONE)
{
$this->CrawlerStatusHandler->lock_status_updates = true;
}
}
|
[
"protected",
"function",
"setupCrawlerStatusHandler",
"(",
")",
"{",
"// Cases the crawlerstatus has to be written to file\r",
"if",
"(",
"$",
"this",
"->",
"multiprocess_mode",
"==",
"PHPCrawlerMultiProcessModes",
"::",
"MPMODE_CHILDS_EXECUTES_USERCODE",
"||",
"$",
"this",
"->",
"resumtion_enabled",
"==",
"true",
")",
"{",
"$",
"this",
"->",
"CrawlerStatusHandler",
"->",
"write_status_to_file",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"request_delay_time",
"!=",
"null",
"&&",
"$",
"this",
"->",
"multiprocess_mode",
"!=",
"PHPCrawlerMultiProcessModes",
"::",
"MPMODE_NONE",
")",
"{",
"$",
"this",
"->",
"CrawlerStatusHandler",
"->",
"write_status_to_file",
"=",
"true",
";",
"}",
"// Cases a crawlerstatus-update has to be locked\r",
"if",
"(",
"$",
"this",
"->",
"multiprocess_mode",
"==",
"PHPCrawlerMultiProcessModes",
"::",
"MPMODE_CHILDS_EXECUTES_USERCODE",
")",
"{",
"$",
"this",
"->",
"CrawlerStatusHandler",
"->",
"lock_status_updates",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"request_delay_time",
"!=",
"null",
"&&",
"$",
"this",
"->",
"multiprocess_mode",
"!=",
"PHPCrawlerMultiProcessModes",
"::",
"MPMODE_NONE",
")",
"{",
"$",
"this",
"->",
"CrawlerStatusHandler",
"->",
"lock_status_updates",
"=",
"true",
";",
"}",
"}"
] |
Setups the CrawlerStatusHandler dependent on the crawler-settings
|
[
"Setups",
"the",
"CrawlerStatusHandler",
"dependent",
"on",
"the",
"crawler",
"-",
"settings"
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawler.class.php#L852-L875
|
223,250
|
mmerian/phpcrawl
|
libs/PHPCrawler.class.php
|
PHPCrawler.cleanup
|
protected function cleanup()
{
// Free/unlock caches
$this->CookieCache->cleanup();
$this->LinkCache->cleanup();
// Delete working-dir
PHPCrawlerUtils::rmDir($this->working_directory);
// Remove semaphore (if multiprocess-mode)
if ($this->multiprocess_mode != PHPCrawlerMultiProcessModes::MPMODE_NONE)
{
$sem_key = sem_get($this->crawler_uniqid);
sem_remove($sem_key);
}
}
|
php
|
protected function cleanup()
{
// Free/unlock caches
$this->CookieCache->cleanup();
$this->LinkCache->cleanup();
// Delete working-dir
PHPCrawlerUtils::rmDir($this->working_directory);
// Remove semaphore (if multiprocess-mode)
if ($this->multiprocess_mode != PHPCrawlerMultiProcessModes::MPMODE_NONE)
{
$sem_key = sem_get($this->crawler_uniqid);
sem_remove($sem_key);
}
}
|
[
"protected",
"function",
"cleanup",
"(",
")",
"{",
"// Free/unlock caches\r",
"$",
"this",
"->",
"CookieCache",
"->",
"cleanup",
"(",
")",
";",
"$",
"this",
"->",
"LinkCache",
"->",
"cleanup",
"(",
")",
";",
"// Delete working-dir\r",
"PHPCrawlerUtils",
"::",
"rmDir",
"(",
"$",
"this",
"->",
"working_directory",
")",
";",
"// Remove semaphore (if multiprocess-mode)\r",
"if",
"(",
"$",
"this",
"->",
"multiprocess_mode",
"!=",
"PHPCrawlerMultiProcessModes",
"::",
"MPMODE_NONE",
")",
"{",
"$",
"sem_key",
"=",
"sem_get",
"(",
"$",
"this",
"->",
"crawler_uniqid",
")",
";",
"sem_remove",
"(",
"$",
"sem_key",
")",
";",
"}",
"}"
] |
Cleans up the crawler after it has finished.
|
[
"Cleans",
"up",
"the",
"crawler",
"after",
"it",
"has",
"finished",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawler.class.php#L900-L915
|
223,251
|
mmerian/phpcrawl
|
libs/PHPCrawler.class.php
|
PHPCrawler.getProcessReport
|
public function getProcessReport()
{
// Get current crawler-Status
$CrawlerStatus = $this->crawlerStatus;
// Create report
$Report = new PHPCrawlerProcessReport();
$Report->links_followed = $CrawlerStatus->links_followed;
$Report->files_received = $CrawlerStatus->documents_received;
$Report->bytes_received = $CrawlerStatus->bytes_received;
$Report->process_runtime = PHPCrawlerBenchmark::getElapsedTime("crawling_process");
if ($Report->process_runtime > 0)
$Report->data_throughput = $Report->bytes_received / $Report->process_runtime;
// Process abort-reason
$Report->abort_reason = $CrawlerStatus->abort_reason;
if ($CrawlerStatus->abort_reason == PHPCrawlerAbortReasons::ABORTREASON_TRAFFICLIMIT_REACHED)
$Report->traffic_limit_reached = true;
if ($CrawlerStatus->abort_reason == PHPCrawlerAbortReasons::ABORTREASON_FILELIMIT_REACHED)
$Report->file_limit_reached = true;
if ($CrawlerStatus->abort_reason == PHPCrawlerAbortReasons::ABORTREASON_USERABORT)
$Report->user_abort = true;
// Peak memory-usage
if (function_exists("memory_get_peak_usage"))
$Report->memory_peak_usage = memory_get_peak_usage(true);
// Benchmark: Average server connect time
if ($CrawlerStatus->sum_server_connects > 0)
$Report->avg_server_connect_time = $CrawlerStatus->sum_server_connect_time / $CrawlerStatus->sum_server_connects;
// Benchmark: Average server response time
if ($CrawlerStatus->sum_server_responses > 0)
$Report->avg_server_response_time = $CrawlerStatus->sum_server_response_time / $CrawlerStatus->sum_server_responses;
// Average data tranfer time
if ($CrawlerStatus->sum_data_transfer_time > 0)
$Report->avg_proc_data_transfer_rate = $CrawlerStatus->unbuffered_bytes_read / $CrawlerStatus->sum_data_transfer_time;
return $Report;
}
|
php
|
public function getProcessReport()
{
// Get current crawler-Status
$CrawlerStatus = $this->crawlerStatus;
// Create report
$Report = new PHPCrawlerProcessReport();
$Report->links_followed = $CrawlerStatus->links_followed;
$Report->files_received = $CrawlerStatus->documents_received;
$Report->bytes_received = $CrawlerStatus->bytes_received;
$Report->process_runtime = PHPCrawlerBenchmark::getElapsedTime("crawling_process");
if ($Report->process_runtime > 0)
$Report->data_throughput = $Report->bytes_received / $Report->process_runtime;
// Process abort-reason
$Report->abort_reason = $CrawlerStatus->abort_reason;
if ($CrawlerStatus->abort_reason == PHPCrawlerAbortReasons::ABORTREASON_TRAFFICLIMIT_REACHED)
$Report->traffic_limit_reached = true;
if ($CrawlerStatus->abort_reason == PHPCrawlerAbortReasons::ABORTREASON_FILELIMIT_REACHED)
$Report->file_limit_reached = true;
if ($CrawlerStatus->abort_reason == PHPCrawlerAbortReasons::ABORTREASON_USERABORT)
$Report->user_abort = true;
// Peak memory-usage
if (function_exists("memory_get_peak_usage"))
$Report->memory_peak_usage = memory_get_peak_usage(true);
// Benchmark: Average server connect time
if ($CrawlerStatus->sum_server_connects > 0)
$Report->avg_server_connect_time = $CrawlerStatus->sum_server_connect_time / $CrawlerStatus->sum_server_connects;
// Benchmark: Average server response time
if ($CrawlerStatus->sum_server_responses > 0)
$Report->avg_server_response_time = $CrawlerStatus->sum_server_response_time / $CrawlerStatus->sum_server_responses;
// Average data tranfer time
if ($CrawlerStatus->sum_data_transfer_time > 0)
$Report->avg_proc_data_transfer_rate = $CrawlerStatus->unbuffered_bytes_read / $CrawlerStatus->sum_data_transfer_time;
return $Report;
}
|
[
"public",
"function",
"getProcessReport",
"(",
")",
"{",
"// Get current crawler-Status\r",
"$",
"CrawlerStatus",
"=",
"$",
"this",
"->",
"crawlerStatus",
";",
"// Create report\r",
"$",
"Report",
"=",
"new",
"PHPCrawlerProcessReport",
"(",
")",
";",
"$",
"Report",
"->",
"links_followed",
"=",
"$",
"CrawlerStatus",
"->",
"links_followed",
";",
"$",
"Report",
"->",
"files_received",
"=",
"$",
"CrawlerStatus",
"->",
"documents_received",
";",
"$",
"Report",
"->",
"bytes_received",
"=",
"$",
"CrawlerStatus",
"->",
"bytes_received",
";",
"$",
"Report",
"->",
"process_runtime",
"=",
"PHPCrawlerBenchmark",
"::",
"getElapsedTime",
"(",
"\"crawling_process\"",
")",
";",
"if",
"(",
"$",
"Report",
"->",
"process_runtime",
">",
"0",
")",
"$",
"Report",
"->",
"data_throughput",
"=",
"$",
"Report",
"->",
"bytes_received",
"/",
"$",
"Report",
"->",
"process_runtime",
";",
"// Process abort-reason\r",
"$",
"Report",
"->",
"abort_reason",
"=",
"$",
"CrawlerStatus",
"->",
"abort_reason",
";",
"if",
"(",
"$",
"CrawlerStatus",
"->",
"abort_reason",
"==",
"PHPCrawlerAbortReasons",
"::",
"ABORTREASON_TRAFFICLIMIT_REACHED",
")",
"$",
"Report",
"->",
"traffic_limit_reached",
"=",
"true",
";",
"if",
"(",
"$",
"CrawlerStatus",
"->",
"abort_reason",
"==",
"PHPCrawlerAbortReasons",
"::",
"ABORTREASON_FILELIMIT_REACHED",
")",
"$",
"Report",
"->",
"file_limit_reached",
"=",
"true",
";",
"if",
"(",
"$",
"CrawlerStatus",
"->",
"abort_reason",
"==",
"PHPCrawlerAbortReasons",
"::",
"ABORTREASON_USERABORT",
")",
"$",
"Report",
"->",
"user_abort",
"=",
"true",
";",
"// Peak memory-usage\r",
"if",
"(",
"function_exists",
"(",
"\"memory_get_peak_usage\"",
")",
")",
"$",
"Report",
"->",
"memory_peak_usage",
"=",
"memory_get_peak_usage",
"(",
"true",
")",
";",
"// Benchmark: Average server connect time\r",
"if",
"(",
"$",
"CrawlerStatus",
"->",
"sum_server_connects",
">",
"0",
")",
"$",
"Report",
"->",
"avg_server_connect_time",
"=",
"$",
"CrawlerStatus",
"->",
"sum_server_connect_time",
"/",
"$",
"CrawlerStatus",
"->",
"sum_server_connects",
";",
"// Benchmark: Average server response time\r",
"if",
"(",
"$",
"CrawlerStatus",
"->",
"sum_server_responses",
">",
"0",
")",
"$",
"Report",
"->",
"avg_server_response_time",
"=",
"$",
"CrawlerStatus",
"->",
"sum_server_response_time",
"/",
"$",
"CrawlerStatus",
"->",
"sum_server_responses",
";",
"// Average data tranfer time\r",
"if",
"(",
"$",
"CrawlerStatus",
"->",
"sum_data_transfer_time",
">",
"0",
")",
"$",
"Report",
"->",
"avg_proc_data_transfer_rate",
"=",
"$",
"CrawlerStatus",
"->",
"unbuffered_bytes_read",
"/",
"$",
"CrawlerStatus",
"->",
"sum_data_transfer_time",
";",
"return",
"$",
"Report",
";",
"}"
] |
Retruns summarizing report-information about the crawling-process after it has finished.
@return PHPCrawlerProcessReport PHPCrawlerProcessReport-object containing process-summary-information
@section 1 Basic settings
|
[
"Retruns",
"summarizing",
"report",
"-",
"information",
"about",
"the",
"crawling",
"-",
"process",
"after",
"it",
"has",
"finished",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawler.class.php#L923-L968
|
223,252
|
mmerian/phpcrawl
|
libs/PHPCrawler.class.php
|
PHPCrawler.obeyRobotsTxt
|
public function obeyRobotsTxt($mode, $robots_txt_uri = null)
{
if (!is_bool($mode)) return false;
$this->obey_robots_txt = $mode;
if ($mode == true)
$this->robots_txt_uri = $robots_txt_uri;
else
$this->robots_txt_uri = null;
return true;
}
|
php
|
public function obeyRobotsTxt($mode, $robots_txt_uri = null)
{
if (!is_bool($mode)) return false;
$this->obey_robots_txt = $mode;
if ($mode == true)
$this->robots_txt_uri = $robots_txt_uri;
else
$this->robots_txt_uri = null;
return true;
}
|
[
"public",
"function",
"obeyRobotsTxt",
"(",
"$",
"mode",
",",
"$",
"robots_txt_uri",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"mode",
")",
")",
"return",
"false",
";",
"$",
"this",
"->",
"obey_robots_txt",
"=",
"$",
"mode",
";",
"if",
"(",
"$",
"mode",
"==",
"true",
")",
"$",
"this",
"->",
"robots_txt_uri",
"=",
"$",
"robots_txt_uri",
";",
"else",
"$",
"this",
"->",
"robots_txt_uri",
"=",
"null",
";",
"return",
"true",
";",
"}"
] |
Defines whether the crawler should parse and obey robots.txt-files.
If this is set to TRUE, the crawler looks for a robots.txt-file for the root-URL of the crawling-process at the default location
and - if present - parses it and obeys all containig directives appliying to the
useragent-identification of the cralwer ("PHPCrawl" by default or manually set by calling {@link setUserAgentString()})
The default-value is FALSE (for compatibility reasons).
Pleas note that the directives found in a robots.txt-file have a higher priority than other settings made by the user.
If e.g. {@link addFollowMatch}("#http://foo\.com/path/file\.html#") was set, but a directive in the robots.txt-file of the host
foo.com says "Disallow: /path/", the URL http://foo.com/path/file.html will be ignored by the crawler anyway.
@param bool $mode Set to TRUE if you want the crawler to obey robots.txt-files.
@param string $robots_txt_uri Optionally. The URL or path to the robots.txt-file to obey as URI (like "http://mysite.com/path/myrobots.txt"
or "file://../a_robots_file.txt")
If not set (or set to null), the crawler uses the default robots.txt-location of the root-URL ("http://rooturl.com/robots.txt")
@return bool
@section 2 Filter-settings
|
[
"Defines",
"whether",
"the",
"crawler",
"should",
"parse",
"and",
"obey",
"robots",
".",
"txt",
"-",
"files",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawler.class.php#L1444-L1456
|
223,253
|
mmerian/phpcrawl
|
libs/PHPCrawler.class.php
|
PHPCrawler.setRequestLimit
|
public function setRequestLimit($limit, $only_count_received_documents = false)
{
if (!preg_match("/^[0-9]*$/", $limit)) return false;
$this->request_limit = $limit;
$this->only_count_received_documents = $only_count_received_documents;
return true;
}
|
php
|
public function setRequestLimit($limit, $only_count_received_documents = false)
{
if (!preg_match("/^[0-9]*$/", $limit)) return false;
$this->request_limit = $limit;
$this->only_count_received_documents = $only_count_received_documents;
return true;
}
|
[
"public",
"function",
"setRequestLimit",
"(",
"$",
"limit",
",",
"$",
"only_count_received_documents",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"\"/^[0-9]*$/\"",
",",
"$",
"limit",
")",
")",
"return",
"false",
";",
"$",
"this",
"->",
"request_limit",
"=",
"$",
"limit",
";",
"$",
"this",
"->",
"only_count_received_documents",
"=",
"$",
"only_count_received_documents",
";",
"return",
"true",
";",
"}"
] |
Sets a limit to the total number of requests the crawler should execute.
If the given limit is reached, the crawler stops the crawling-process. The default-value is 0 (no limit).
If the second parameter is set to true, the given limit refers to to total number of successfully received documents
instead of the number of requests.
@param int $limit The limit, set to 0 for no limit (default value).
@param bool $only_count_received_documents OPTIONAL.
If TRUE, the given limit refers to the total number of successfully received documents.
If FALSE, the given limit refers to the total number of requests done, regardless of the number of successfully received documents.
Defaults to FALSE.
@return bool
@section 5 Limit-settings
|
[
"Sets",
"a",
"limit",
"to",
"the",
"total",
"number",
"of",
"requests",
"the",
"crawler",
"should",
"execute",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawler.class.php#L1499-L1506
|
223,254
|
mmerian/phpcrawl
|
libs/PHPCrawler.class.php
|
PHPCrawler.setRequestDelay
|
public function setRequestDelay($time)
{
if (is_float($time) || is_int($time))
{
$this->request_delay_time = $time;
return true;
}
return false;
}
|
php
|
public function setRequestDelay($time)
{
if (is_float($time) || is_int($time))
{
$this->request_delay_time = $time;
return true;
}
return false;
}
|
[
"public",
"function",
"setRequestDelay",
"(",
"$",
"time",
")",
"{",
"if",
"(",
"is_float",
"(",
"$",
"time",
")",
"||",
"is_int",
"(",
"$",
"time",
")",
")",
"{",
"$",
"this",
"->",
"request_delay_time",
"=",
"$",
"time",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Sets a delay for every HTTP-requests the crawler executes.
The crawler will wait for the given time after every request it does, regardless of
the mode it runs in (single-/multiprocessmode).
Example 1:
<code>
// Let's the crawler wait for a half second before every request.
$crawler->setRequestDelay(0.5);
</code>
Example 2:
<code>
// Limit the request-rate to 100 requests per minute
$crawler->setRequestDelay(60/100);
</code>
@param float $time The request-delay-time in seconds.
@return bool
@section 5 Limit-settings
|
[
"Sets",
"a",
"delay",
"for",
"every",
"HTTP",
"-",
"requests",
"the",
"crawler",
"executes",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawler.class.php#L2075-L2084
|
223,255
|
mmerian/phpcrawl
|
libs/PHPCrawler.class.php
|
PHPCrawler.setCrawlingDepthLimit
|
public function setCrawlingDepthLimit($depth)
{
if (is_int($depth) && $depth >= 0)
{
$this->UrlFilter->max_crawling_depth = $depth;
return true;
}
return false;
}
|
php
|
public function setCrawlingDepthLimit($depth)
{
if (is_int($depth) && $depth >= 0)
{
$this->UrlFilter->max_crawling_depth = $depth;
return true;
}
return false;
}
|
[
"public",
"function",
"setCrawlingDepthLimit",
"(",
"$",
"depth",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"depth",
")",
"&&",
"$",
"depth",
">=",
"0",
")",
"{",
"$",
"this",
"->",
"UrlFilter",
"->",
"max_crawling_depth",
"=",
"$",
"depth",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Sets the maximum crawling depth
Defines how "deep" the crawler should follow links relating to the entry-URL of a crawling-process.
For instance: If the maximum depth is set to 1, the crawler only will follow links found in the entry-page
of the crawling-process, but won't follow any further links found in underlying documents.
@param int $depth The maximum link-depth the crawler should follow
@section 5 Limit-settings
|
[
"Sets",
"the",
"maximum",
"crawling",
"depth"
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawler.class.php#L2130-L2139
|
223,256
|
mmerian/phpcrawl
|
libs/PHPCrawlerHTTPRequest.class.php
|
PHPCrawlerHTTPRequest.setUrl
|
public function setUrl(PHPCrawlerURLDescriptor $UrlDescriptor)
{
$this->UrlDescriptor = $UrlDescriptor;
// Split the URL into its parts
$this->url_parts = PHPCrawlerUtils::splitURL($UrlDescriptor->url_rebuild);
}
|
php
|
public function setUrl(PHPCrawlerURLDescriptor $UrlDescriptor)
{
$this->UrlDescriptor = $UrlDescriptor;
// Split the URL into its parts
$this->url_parts = PHPCrawlerUtils::splitURL($UrlDescriptor->url_rebuild);
}
|
[
"public",
"function",
"setUrl",
"(",
"PHPCrawlerURLDescriptor",
"$",
"UrlDescriptor",
")",
"{",
"$",
"this",
"->",
"UrlDescriptor",
"=",
"$",
"UrlDescriptor",
";",
"// Split the URL into its parts\r",
"$",
"this",
"->",
"url_parts",
"=",
"PHPCrawlerUtils",
"::",
"splitURL",
"(",
"$",
"UrlDescriptor",
"->",
"url_rebuild",
")",
";",
"}"
] |
Sets the URL for the request.
@param PHPCrawlerURLDescriptor $UrlDescriptor An PHPCrawlerURLDescriptor-object containing the URL to request
|
[
"Sets",
"the",
"URL",
"for",
"the",
"request",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawlerHTTPRequest.class.php#L209-L215
|
223,257
|
mmerian/phpcrawl
|
libs/PHPCrawlerHTTPRequest.class.php
|
PHPCrawlerHTTPRequest.addCookieDescriptors
|
public function addCookieDescriptors($cookies)
{
$cnt = count($cookies);
for ($x=0; $x<$cnt; $x++)
{
$this->addCookieDescriptor($cookies[$x]);
}
}
|
php
|
public function addCookieDescriptors($cookies)
{
$cnt = count($cookies);
for ($x=0; $x<$cnt; $x++)
{
$this->addCookieDescriptor($cookies[$x]);
}
}
|
[
"public",
"function",
"addCookieDescriptors",
"(",
"$",
"cookies",
")",
"{",
"$",
"cnt",
"=",
"count",
"(",
"$",
"cookies",
")",
";",
"for",
"(",
"$",
"x",
"=",
"0",
";",
"$",
"x",
"<",
"$",
"cnt",
";",
"$",
"x",
"++",
")",
"{",
"$",
"this",
"->",
"addCookieDescriptor",
"(",
"$",
"cookies",
"[",
"$",
"x",
"]",
")",
";",
"}",
"}"
] |
Adds a bunch of cookies to send with the request
@param array $cookies Numeric array containins cookies as PHPCrawlerCookieDescriptor-objects
|
[
"Adds",
"a",
"bunch",
"of",
"cookies",
"to",
"send",
"with",
"the",
"request"
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawlerHTTPRequest.class.php#L243-L250
|
223,258
|
mmerian/phpcrawl
|
libs/PHPCrawlerHTTPRequest.class.php
|
PHPCrawlerHTTPRequest.setFindRedirectURLs
|
public function setFindRedirectURLs($mode)
{
if (!is_bool($mode)) return false;
$this->LinkFinder->find_redirect_urls = $mode;
return true;
}
|
php
|
public function setFindRedirectURLs($mode)
{
if (!is_bool($mode)) return false;
$this->LinkFinder->find_redirect_urls = $mode;
return true;
}
|
[
"public",
"function",
"setFindRedirectURLs",
"(",
"$",
"mode",
")",
"{",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"mode",
")",
")",
"return",
"false",
";",
"$",
"this",
"->",
"LinkFinder",
"->",
"find_redirect_urls",
"=",
"$",
"mode",
";",
"return",
"true",
";",
"}"
] |
Specifies whether redirect-links set in http-headers should get searched for.
@return bool
|
[
"Specifies",
"whether",
"redirect",
"-",
"links",
"set",
"in",
"http",
"-",
"headers",
"should",
"get",
"searched",
"for",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawlerHTTPRequest.class.php#L279-L286
|
223,259
|
mmerian/phpcrawl
|
libs/PHPCrawlerHTTPRequest.class.php
|
PHPCrawlerHTTPRequest.calulateDataTransferRateValues
|
protected function calulateDataTransferRateValues()
{
$vals = array();
// Works like this:
// After the server resonded, the socket-buffer is already filled with bytes,
// that means they were received within the server-response-time.
// To calulate the real data transfer rate, these bytes have to be substractred from the received
// bytes beofre calulating the rate.
if ($this->data_transfer_time > 0 && $this->content_bytes_received > 4 * $this->socket_prefill_size)
{
$vals["unbuffered_bytes_read"] = $this->content_bytes_received + $this->header_bytes_received - $this->socket_prefill_size;
$vals["data_transfer_rate"] = $vals["unbuffered_bytes_read"] / $this->data_transfer_time;
$vals["data_transfer_time"] = $this->data_transfer_time;
}
else
{
$vals = null;
}
return $vals;
}
|
php
|
protected function calulateDataTransferRateValues()
{
$vals = array();
// Works like this:
// After the server resonded, the socket-buffer is already filled with bytes,
// that means they were received within the server-response-time.
// To calulate the real data transfer rate, these bytes have to be substractred from the received
// bytes beofre calulating the rate.
if ($this->data_transfer_time > 0 && $this->content_bytes_received > 4 * $this->socket_prefill_size)
{
$vals["unbuffered_bytes_read"] = $this->content_bytes_received + $this->header_bytes_received - $this->socket_prefill_size;
$vals["data_transfer_rate"] = $vals["unbuffered_bytes_read"] / $this->data_transfer_time;
$vals["data_transfer_time"] = $this->data_transfer_time;
}
else
{
$vals = null;
}
return $vals;
}
|
[
"protected",
"function",
"calulateDataTransferRateValues",
"(",
")",
"{",
"$",
"vals",
"=",
"array",
"(",
")",
";",
"// Works like this:\r",
"// After the server resonded, the socket-buffer is already filled with bytes,\r",
"// that means they were received within the server-response-time.\r",
"// To calulate the real data transfer rate, these bytes have to be substractred from the received\r",
"// bytes beofre calulating the rate.\r",
"if",
"(",
"$",
"this",
"->",
"data_transfer_time",
">",
"0",
"&&",
"$",
"this",
"->",
"content_bytes_received",
">",
"4",
"*",
"$",
"this",
"->",
"socket_prefill_size",
")",
"{",
"$",
"vals",
"[",
"\"unbuffered_bytes_read\"",
"]",
"=",
"$",
"this",
"->",
"content_bytes_received",
"+",
"$",
"this",
"->",
"header_bytes_received",
"-",
"$",
"this",
"->",
"socket_prefill_size",
";",
"$",
"vals",
"[",
"\"data_transfer_rate\"",
"]",
"=",
"$",
"vals",
"[",
"\"unbuffered_bytes_read\"",
"]",
"/",
"$",
"this",
"->",
"data_transfer_time",
";",
"$",
"vals",
"[",
"\"data_transfer_time\"",
"]",
"=",
"$",
"this",
"->",
"data_transfer_time",
";",
"}",
"else",
"{",
"$",
"vals",
"=",
"null",
";",
"}",
"return",
"$",
"vals",
";",
"}"
] |
Calculates data tranfer rate values
@return int The rate in bytes/second
|
[
"Calculates",
"data",
"tranfer",
"rate",
"values"
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawlerHTTPRequest.class.php#L485-L507
|
223,260
|
mmerian/phpcrawl
|
libs/PHPCrawlerHTTPRequest.class.php
|
PHPCrawlerHTTPRequest.openSocket
|
protected function openSocket(&$error_code, &$error_string)
{
PHPCrawlerBenchmark::reset("connecting_server");
PHPCrawlerBenchmark::start("connecting_server");
// SSL or not?
if ($this->url_parts["protocol"] == "https://") $protocol_prefix = "ssl://";
else $protocol_prefix = "";
// If SSL-request, but openssl is not installed
if ($protocol_prefix == "ssl://" && !extension_loaded("openssl"))
{
$error_code = PHPCrawlerRequestErrors::ERROR_SSL_NOT_SUPPORTED;
$error_string = "Error connecting to ".$this->url_parts["protocol"].$this->url_parts["host"].": SSL/HTTPS-requests not supported, extension openssl not installed.";
}
// Get IP for hostname
$ip_address = $this->DNSCache->getIP($this->url_parts["host"]);
// since PHP 5.6 SNI_server_name is deprecated
if (version_compare(PHP_VERSION, '5.6.0') >= 0)
{
$serverName = 'peer_name';
}
else
{
$serverName = 'SNI_server_name';
}
// Open socket
if ($this->proxy != null)
{
$this->socket = @stream_socket_client($this->proxy["proxy_host"].":".$this->proxy["proxy_port"], $error_code, $error_str,
$this->socketConnectTimeout, STREAM_CLIENT_CONNECT);
}
else
{
// If ssl -> perform Server name indication
if ($this->url_parts["protocol"] == "https://")
{
$context = stream_context_create(array(
'ssl' => array(
$serverName => $this->url_parts["host"],
),
));
$this->socket = @stream_socket_client($protocol_prefix.$ip_address.":".$this->url_parts["port"], $error_code, $error_str,
$this->socketConnectTimeout, STREAM_CLIENT_CONNECT, $context);
}
else
{
$this->socket = @stream_socket_client($protocol_prefix.$ip_address.":".$this->url_parts["port"], $error_code, $error_str,
$this->socketConnectTimeout, STREAM_CLIENT_CONNECT); // NO $context here, memory-leak-bug in php v. 5.3.x!!
}
}
$this->server_connect_time = PHPCrawlerBenchmark::stop("connecting_server");
// If socket not opened -> throw error
if ($this->socket == false)
{
$this->server_connect_time = null;
// If proxy not reachable
if ($this->proxy != null)
{
$error_code = PHPCrawlerRequestErrors::ERROR_PROXY_UNREACHABLE;
$error_string = "Error connecting to proxy ".$this->proxy["proxy_host"].": Host unreachable (".$error_str.").";
return false;
}
else
{
$error_code = PHPCrawlerRequestErrors::ERROR_HOST_UNREACHABLE;
$error_string = "Error connecting to ".$this->url_parts["protocol"].$this->url_parts["host"].": Host unreachable (".$error_str.").";
return false;
}
}
else
{
return true;
}
}
|
php
|
protected function openSocket(&$error_code, &$error_string)
{
PHPCrawlerBenchmark::reset("connecting_server");
PHPCrawlerBenchmark::start("connecting_server");
// SSL or not?
if ($this->url_parts["protocol"] == "https://") $protocol_prefix = "ssl://";
else $protocol_prefix = "";
// If SSL-request, but openssl is not installed
if ($protocol_prefix == "ssl://" && !extension_loaded("openssl"))
{
$error_code = PHPCrawlerRequestErrors::ERROR_SSL_NOT_SUPPORTED;
$error_string = "Error connecting to ".$this->url_parts["protocol"].$this->url_parts["host"].": SSL/HTTPS-requests not supported, extension openssl not installed.";
}
// Get IP for hostname
$ip_address = $this->DNSCache->getIP($this->url_parts["host"]);
// since PHP 5.6 SNI_server_name is deprecated
if (version_compare(PHP_VERSION, '5.6.0') >= 0)
{
$serverName = 'peer_name';
}
else
{
$serverName = 'SNI_server_name';
}
// Open socket
if ($this->proxy != null)
{
$this->socket = @stream_socket_client($this->proxy["proxy_host"].":".$this->proxy["proxy_port"], $error_code, $error_str,
$this->socketConnectTimeout, STREAM_CLIENT_CONNECT);
}
else
{
// If ssl -> perform Server name indication
if ($this->url_parts["protocol"] == "https://")
{
$context = stream_context_create(array(
'ssl' => array(
$serverName => $this->url_parts["host"],
),
));
$this->socket = @stream_socket_client($protocol_prefix.$ip_address.":".$this->url_parts["port"], $error_code, $error_str,
$this->socketConnectTimeout, STREAM_CLIENT_CONNECT, $context);
}
else
{
$this->socket = @stream_socket_client($protocol_prefix.$ip_address.":".$this->url_parts["port"], $error_code, $error_str,
$this->socketConnectTimeout, STREAM_CLIENT_CONNECT); // NO $context here, memory-leak-bug in php v. 5.3.x!!
}
}
$this->server_connect_time = PHPCrawlerBenchmark::stop("connecting_server");
// If socket not opened -> throw error
if ($this->socket == false)
{
$this->server_connect_time = null;
// If proxy not reachable
if ($this->proxy != null)
{
$error_code = PHPCrawlerRequestErrors::ERROR_PROXY_UNREACHABLE;
$error_string = "Error connecting to proxy ".$this->proxy["proxy_host"].": Host unreachable (".$error_str.").";
return false;
}
else
{
$error_code = PHPCrawlerRequestErrors::ERROR_HOST_UNREACHABLE;
$error_string = "Error connecting to ".$this->url_parts["protocol"].$this->url_parts["host"].": Host unreachable (".$error_str.").";
return false;
}
}
else
{
return true;
}
}
|
[
"protected",
"function",
"openSocket",
"(",
"&",
"$",
"error_code",
",",
"&",
"$",
"error_string",
")",
"{",
"PHPCrawlerBenchmark",
"::",
"reset",
"(",
"\"connecting_server\"",
")",
";",
"PHPCrawlerBenchmark",
"::",
"start",
"(",
"\"connecting_server\"",
")",
";",
"// SSL or not?\r",
"if",
"(",
"$",
"this",
"->",
"url_parts",
"[",
"\"protocol\"",
"]",
"==",
"\"https://\"",
")",
"$",
"protocol_prefix",
"=",
"\"ssl://\"",
";",
"else",
"$",
"protocol_prefix",
"=",
"\"\"",
";",
"// If SSL-request, but openssl is not installed\r",
"if",
"(",
"$",
"protocol_prefix",
"==",
"\"ssl://\"",
"&&",
"!",
"extension_loaded",
"(",
"\"openssl\"",
")",
")",
"{",
"$",
"error_code",
"=",
"PHPCrawlerRequestErrors",
"::",
"ERROR_SSL_NOT_SUPPORTED",
";",
"$",
"error_string",
"=",
"\"Error connecting to \"",
".",
"$",
"this",
"->",
"url_parts",
"[",
"\"protocol\"",
"]",
".",
"$",
"this",
"->",
"url_parts",
"[",
"\"host\"",
"]",
".",
"\": SSL/HTTPS-requests not supported, extension openssl not installed.\"",
";",
"}",
"// Get IP for hostname\r",
"$",
"ip_address",
"=",
"$",
"this",
"->",
"DNSCache",
"->",
"getIP",
"(",
"$",
"this",
"->",
"url_parts",
"[",
"\"host\"",
"]",
")",
";",
"// since PHP 5.6 SNI_server_name is deprecated\r",
"if",
"(",
"version_compare",
"(",
"PHP_VERSION",
",",
"'5.6.0'",
")",
">=",
"0",
")",
"{",
"$",
"serverName",
"=",
"'peer_name'",
";",
"}",
"else",
"{",
"$",
"serverName",
"=",
"'SNI_server_name'",
";",
"}",
"// Open socket\r",
"if",
"(",
"$",
"this",
"->",
"proxy",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"socket",
"=",
"@",
"stream_socket_client",
"(",
"$",
"this",
"->",
"proxy",
"[",
"\"proxy_host\"",
"]",
".",
"\":\"",
".",
"$",
"this",
"->",
"proxy",
"[",
"\"proxy_port\"",
"]",
",",
"$",
"error_code",
",",
"$",
"error_str",
",",
"$",
"this",
"->",
"socketConnectTimeout",
",",
"STREAM_CLIENT_CONNECT",
")",
";",
"}",
"else",
"{",
"// If ssl -> perform Server name indication\r",
"if",
"(",
"$",
"this",
"->",
"url_parts",
"[",
"\"protocol\"",
"]",
"==",
"\"https://\"",
")",
"{",
"$",
"context",
"=",
"stream_context_create",
"(",
"array",
"(",
"'ssl'",
"=>",
"array",
"(",
"$",
"serverName",
"=>",
"$",
"this",
"->",
"url_parts",
"[",
"\"host\"",
"]",
",",
")",
",",
")",
")",
";",
"$",
"this",
"->",
"socket",
"=",
"@",
"stream_socket_client",
"(",
"$",
"protocol_prefix",
".",
"$",
"ip_address",
".",
"\":\"",
".",
"$",
"this",
"->",
"url_parts",
"[",
"\"port\"",
"]",
",",
"$",
"error_code",
",",
"$",
"error_str",
",",
"$",
"this",
"->",
"socketConnectTimeout",
",",
"STREAM_CLIENT_CONNECT",
",",
"$",
"context",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"socket",
"=",
"@",
"stream_socket_client",
"(",
"$",
"protocol_prefix",
".",
"$",
"ip_address",
".",
"\":\"",
".",
"$",
"this",
"->",
"url_parts",
"[",
"\"port\"",
"]",
",",
"$",
"error_code",
",",
"$",
"error_str",
",",
"$",
"this",
"->",
"socketConnectTimeout",
",",
"STREAM_CLIENT_CONNECT",
")",
";",
"// NO $context here, memory-leak-bug in php v. 5.3.x!!\r",
"}",
"}",
"$",
"this",
"->",
"server_connect_time",
"=",
"PHPCrawlerBenchmark",
"::",
"stop",
"(",
"\"connecting_server\"",
")",
";",
"// If socket not opened -> throw error\r",
"if",
"(",
"$",
"this",
"->",
"socket",
"==",
"false",
")",
"{",
"$",
"this",
"->",
"server_connect_time",
"=",
"null",
";",
"// If proxy not reachable\r",
"if",
"(",
"$",
"this",
"->",
"proxy",
"!=",
"null",
")",
"{",
"$",
"error_code",
"=",
"PHPCrawlerRequestErrors",
"::",
"ERROR_PROXY_UNREACHABLE",
";",
"$",
"error_string",
"=",
"\"Error connecting to proxy \"",
".",
"$",
"this",
"->",
"proxy",
"[",
"\"proxy_host\"",
"]",
".",
"\": Host unreachable (\"",
".",
"$",
"error_str",
".",
"\").\"",
";",
"return",
"false",
";",
"}",
"else",
"{",
"$",
"error_code",
"=",
"PHPCrawlerRequestErrors",
"::",
"ERROR_HOST_UNREACHABLE",
";",
"$",
"error_string",
"=",
"\"Error connecting to \"",
".",
"$",
"this",
"->",
"url_parts",
"[",
"\"protocol\"",
"]",
".",
"$",
"this",
"->",
"url_parts",
"[",
"\"host\"",
"]",
".",
"\": Host unreachable (\"",
".",
"$",
"error_str",
".",
"\").\"",
";",
"return",
"false",
";",
"}",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}"
] |
Opens the socket to the host.
@param int &$error_code Error-code by referenct if an error occured.
@param string &$error_string Error-string by reference
@return bool TRUE if socket could be opened, otherwise FALSE.
|
[
"Opens",
"the",
"socket",
"to",
"the",
"host",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawlerHTTPRequest.class.php#L517-L597
|
223,261
|
mmerian/phpcrawl
|
libs/PHPCrawlerHTTPRequest.class.php
|
PHPCrawlerHTTPRequest.sendRequestHeader
|
protected function sendRequestHeader($request_header_lines)
{
// Header senden
$cnt = count($request_header_lines);
for ($x=0; $x<$cnt; $x++)
{
fputs($this->socket, $request_header_lines[$x]);
}
}
|
php
|
protected function sendRequestHeader($request_header_lines)
{
// Header senden
$cnt = count($request_header_lines);
for ($x=0; $x<$cnt; $x++)
{
fputs($this->socket, $request_header_lines[$x]);
}
}
|
[
"protected",
"function",
"sendRequestHeader",
"(",
"$",
"request_header_lines",
")",
"{",
"// Header senden\r",
"$",
"cnt",
"=",
"count",
"(",
"$",
"request_header_lines",
")",
";",
"for",
"(",
"$",
"x",
"=",
"0",
";",
"$",
"x",
"<",
"$",
"cnt",
";",
"$",
"x",
"++",
")",
"{",
"fputs",
"(",
"$",
"this",
"->",
"socket",
",",
"$",
"request_header_lines",
"[",
"$",
"x",
"]",
")",
";",
"}",
"}"
] |
Send the request-header.
|
[
"Send",
"the",
"request",
"-",
"header",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawlerHTTPRequest.class.php#L602-L610
|
223,262
|
mmerian/phpcrawl
|
libs/PHPCrawlerHTTPRequest.class.php
|
PHPCrawlerHTTPRequest.readResponseHeader
|
protected function readResponseHeader(&$error_code, &$error_string)
{
PHPCrawlerBenchmark::reset("server_response_time");
PHPCrawlerBenchmark::start("server_response_time");
$status = socket_get_status($this->socket);
$source_read = "";
$header = "";
$server_responded = false;
while ($status["eof"] == false)
{
socket_set_timeout($this->socket, $this->socketReadTimeout);
// Read line from socket
$line_read = fgets($this->socket, 1024);
// Server responded
if ($server_responded == false)
{
$server_responded = true;
$this->server_response_time = PHPCrawlerBenchmark::stop("server_response_time");
// Determinate socket prefill size
$status = socket_get_status($this->socket);
$this->socket_prefill_size = $status["unread_bytes"];
// Start data-transfer-time bechmark
PHPCrawlerBenchmark::reset("data_transfer_time");
PHPCrawlerBenchmark::start("data_transfer_time");
}
$source_read .= $line_read;
$this->global_traffic_count += strlen($line_read);
$status = socket_get_status($this->socket);
// Socket timed out
if ($status["timed_out"] == true)
{
$error_code = PHPCrawlerRequestErrors::ERROR_SOCKET_TIMEOUT;
$error_string = "Socket-stream timed out (timeout set to ".$this->socketReadTimeout." sec).";
return $header;
}
// No "HTTP" at beginnig of response
if (strtolower(substr($source_read, 0, 4)) != "http")
{
$error_code = PHPCrawlerRequestErrors::ERROR_NO_HTTP_HEADER;
$error_string = "HTTP-protocol error.";
return $header;
}
// Header found and read (2 newlines) -> stop
if (substr($source_read, -4, 4) == "\r\n\r\n" || substr($source_read, -2, 2) == "\n\n")
{
$header = substr($source_read, 0, strlen($source_read)-2);
break;
}
}
// Stop data-transfer-time bechmark
PHPCrawlerBenchmark::stop("data_transfer_time");
// Header was found
if ($header != "")
{
// Search for links (redirects) in the header
$this->LinkFinder->processHTTPHeader($header);
$this->header_bytes_received = strlen($header);
return $header;
}
// No header found
if ($header == "")
{
$this->server_response_time = null;
$error_code = PHPCrawlerRequestErrors::ERROR_NO_HTTP_HEADER;
$error_string = "Host doesn't respond with a HTTP-header.";
return null;
}
}
|
php
|
protected function readResponseHeader(&$error_code, &$error_string)
{
PHPCrawlerBenchmark::reset("server_response_time");
PHPCrawlerBenchmark::start("server_response_time");
$status = socket_get_status($this->socket);
$source_read = "";
$header = "";
$server_responded = false;
while ($status["eof"] == false)
{
socket_set_timeout($this->socket, $this->socketReadTimeout);
// Read line from socket
$line_read = fgets($this->socket, 1024);
// Server responded
if ($server_responded == false)
{
$server_responded = true;
$this->server_response_time = PHPCrawlerBenchmark::stop("server_response_time");
// Determinate socket prefill size
$status = socket_get_status($this->socket);
$this->socket_prefill_size = $status["unread_bytes"];
// Start data-transfer-time bechmark
PHPCrawlerBenchmark::reset("data_transfer_time");
PHPCrawlerBenchmark::start("data_transfer_time");
}
$source_read .= $line_read;
$this->global_traffic_count += strlen($line_read);
$status = socket_get_status($this->socket);
// Socket timed out
if ($status["timed_out"] == true)
{
$error_code = PHPCrawlerRequestErrors::ERROR_SOCKET_TIMEOUT;
$error_string = "Socket-stream timed out (timeout set to ".$this->socketReadTimeout." sec).";
return $header;
}
// No "HTTP" at beginnig of response
if (strtolower(substr($source_read, 0, 4)) != "http")
{
$error_code = PHPCrawlerRequestErrors::ERROR_NO_HTTP_HEADER;
$error_string = "HTTP-protocol error.";
return $header;
}
// Header found and read (2 newlines) -> stop
if (substr($source_read, -4, 4) == "\r\n\r\n" || substr($source_read, -2, 2) == "\n\n")
{
$header = substr($source_read, 0, strlen($source_read)-2);
break;
}
}
// Stop data-transfer-time bechmark
PHPCrawlerBenchmark::stop("data_transfer_time");
// Header was found
if ($header != "")
{
// Search for links (redirects) in the header
$this->LinkFinder->processHTTPHeader($header);
$this->header_bytes_received = strlen($header);
return $header;
}
// No header found
if ($header == "")
{
$this->server_response_time = null;
$error_code = PHPCrawlerRequestErrors::ERROR_NO_HTTP_HEADER;
$error_string = "Host doesn't respond with a HTTP-header.";
return null;
}
}
|
[
"protected",
"function",
"readResponseHeader",
"(",
"&",
"$",
"error_code",
",",
"&",
"$",
"error_string",
")",
"{",
"PHPCrawlerBenchmark",
"::",
"reset",
"(",
"\"server_response_time\"",
")",
";",
"PHPCrawlerBenchmark",
"::",
"start",
"(",
"\"server_response_time\"",
")",
";",
"$",
"status",
"=",
"socket_get_status",
"(",
"$",
"this",
"->",
"socket",
")",
";",
"$",
"source_read",
"=",
"\"\"",
";",
"$",
"header",
"=",
"\"\"",
";",
"$",
"server_responded",
"=",
"false",
";",
"while",
"(",
"$",
"status",
"[",
"\"eof\"",
"]",
"==",
"false",
")",
"{",
"socket_set_timeout",
"(",
"$",
"this",
"->",
"socket",
",",
"$",
"this",
"->",
"socketReadTimeout",
")",
";",
"// Read line from socket\r",
"$",
"line_read",
"=",
"fgets",
"(",
"$",
"this",
"->",
"socket",
",",
"1024",
")",
";",
"// Server responded\r",
"if",
"(",
"$",
"server_responded",
"==",
"false",
")",
"{",
"$",
"server_responded",
"=",
"true",
";",
"$",
"this",
"->",
"server_response_time",
"=",
"PHPCrawlerBenchmark",
"::",
"stop",
"(",
"\"server_response_time\"",
")",
";",
"// Determinate socket prefill size\r",
"$",
"status",
"=",
"socket_get_status",
"(",
"$",
"this",
"->",
"socket",
")",
";",
"$",
"this",
"->",
"socket_prefill_size",
"=",
"$",
"status",
"[",
"\"unread_bytes\"",
"]",
";",
"// Start data-transfer-time bechmark\r",
"PHPCrawlerBenchmark",
"::",
"reset",
"(",
"\"data_transfer_time\"",
")",
";",
"PHPCrawlerBenchmark",
"::",
"start",
"(",
"\"data_transfer_time\"",
")",
";",
"}",
"$",
"source_read",
".=",
"$",
"line_read",
";",
"$",
"this",
"->",
"global_traffic_count",
"+=",
"strlen",
"(",
"$",
"line_read",
")",
";",
"$",
"status",
"=",
"socket_get_status",
"(",
"$",
"this",
"->",
"socket",
")",
";",
"// Socket timed out\r",
"if",
"(",
"$",
"status",
"[",
"\"timed_out\"",
"]",
"==",
"true",
")",
"{",
"$",
"error_code",
"=",
"PHPCrawlerRequestErrors",
"::",
"ERROR_SOCKET_TIMEOUT",
";",
"$",
"error_string",
"=",
"\"Socket-stream timed out (timeout set to \"",
".",
"$",
"this",
"->",
"socketReadTimeout",
".",
"\" sec).\"",
";",
"return",
"$",
"header",
";",
"}",
"// No \"HTTP\" at beginnig of response\r",
"if",
"(",
"strtolower",
"(",
"substr",
"(",
"$",
"source_read",
",",
"0",
",",
"4",
")",
")",
"!=",
"\"http\"",
")",
"{",
"$",
"error_code",
"=",
"PHPCrawlerRequestErrors",
"::",
"ERROR_NO_HTTP_HEADER",
";",
"$",
"error_string",
"=",
"\"HTTP-protocol error.\"",
";",
"return",
"$",
"header",
";",
"}",
"// Header found and read (2 newlines) -> stop\r",
"if",
"(",
"substr",
"(",
"$",
"source_read",
",",
"-",
"4",
",",
"4",
")",
"==",
"\"\\r\\n\\r\\n\"",
"||",
"substr",
"(",
"$",
"source_read",
",",
"-",
"2",
",",
"2",
")",
"==",
"\"\\n\\n\"",
")",
"{",
"$",
"header",
"=",
"substr",
"(",
"$",
"source_read",
",",
"0",
",",
"strlen",
"(",
"$",
"source_read",
")",
"-",
"2",
")",
";",
"break",
";",
"}",
"}",
"// Stop data-transfer-time bechmark\r",
"PHPCrawlerBenchmark",
"::",
"stop",
"(",
"\"data_transfer_time\"",
")",
";",
"// Header was found\r",
"if",
"(",
"$",
"header",
"!=",
"\"\"",
")",
"{",
"// Search for links (redirects) in the header\r",
"$",
"this",
"->",
"LinkFinder",
"->",
"processHTTPHeader",
"(",
"$",
"header",
")",
";",
"$",
"this",
"->",
"header_bytes_received",
"=",
"strlen",
"(",
"$",
"header",
")",
";",
"return",
"$",
"header",
";",
"}",
"// No header found\r",
"if",
"(",
"$",
"header",
"==",
"\"\"",
")",
"{",
"$",
"this",
"->",
"server_response_time",
"=",
"null",
";",
"$",
"error_code",
"=",
"PHPCrawlerRequestErrors",
"::",
"ERROR_NO_HTTP_HEADER",
";",
"$",
"error_string",
"=",
"\"Host doesn't respond with a HTTP-header.\"",
";",
"return",
"null",
";",
"}",
"}"
] |
Reads the response-header.
@param int &$error_code Error-code by reference if an error occured.
@param string &$error_string Error-string by reference
@return string The response-header or NULL if an error occured
|
[
"Reads",
"the",
"response",
"-",
"header",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawlerHTTPRequest.class.php#L620-L702
|
223,263
|
mmerian/phpcrawl
|
libs/PHPCrawlerHTTPRequest.class.php
|
PHPCrawlerHTTPRequest.readResponseContent
|
protected function readResponseContent($stream_to_file = false, &$error_code, &$error_string, &$document_received_completely)
{
$this->content_bytes_received = 0;
// If content should be streamed to file
if ($stream_to_file == true)
{
$fp = @fopen($this->tmpFile, "w");
if ($fp == false)
{
$error_code = PHPCrawlerRequestErrors::ERROR_TMP_FILE_NOT_WRITEABLE;
$error_string = "Couldn't open the temporary file ".$this->tmpFile." for writing.";
return "";
}
}
// Init
$source_portion = "";
$source_complete = "";
$document_received_completely = true;
$document_completed = false;
$gzip_encoded_content = null;
// Resume data-transfer-time benchmark
PHPCrawlerBenchmark::start("data_transfer_time");
while ($document_completed == false)
{
// Get chunk from content
$content_chunk = $this->readResponseContentChunk($document_completed, $error_code, $error_string, $document_received_completely);
$source_portion .= $content_chunk;
// Check if content is gzip-encoded (check only first chunk)
if ($gzip_encoded_content === null)
{
if (PHPCrawlerEncodingUtils::isGzipEncoded($content_chunk))
$gzip_encoded_content = true;
else
$gzip_encoded_content = false;
}
// Stream to file or store source in memory
if ($stream_to_file == true)
{
@fwrite($fp, $content_chunk);
}
else
{
$source_complete .= $content_chunk;
}
// Decode gzip-encoded content when done with document
if ($document_completed == true && $gzip_encoded_content == true)
$source_complete = $source_portion = PHPCrawlerEncodingUtils::decodeGZipContent($source_complete);
// Find links in portion of the source
if (($gzip_encoded_content == false && $stream_to_file == false && strlen($source_portion) >= $this->content_buffer_size) || $document_completed == true)
{
if (PHPCrawlerUtils::checkStringAgainstRegexArray($this->lastResponseHeader->content_type, $this->linksearch_content_types))
{
PHPCrawlerBenchmark::stop("data_transfer_time");
$this->LinkFinder->findLinksInHTMLChunk($source_portion);
if ($this->source_overlap_size > 0)
$source_portion = substr($source_portion, -$this->source_overlap_size);
else
$source_portion = "";
PHPCrawlerBenchmark::start("data_transfer_time");
}
}
}
if ($stream_to_file == true) @fclose($fp);
// Stop data-transfer-time benchmark
PHPCrawlerBenchmark::stop("data_transfer_time");
$this->data_transfer_time = PHPCrawlerBenchmark::getElapsedTime("data_transfer_time");
return $source_complete;
}
|
php
|
protected function readResponseContent($stream_to_file = false, &$error_code, &$error_string, &$document_received_completely)
{
$this->content_bytes_received = 0;
// If content should be streamed to file
if ($stream_to_file == true)
{
$fp = @fopen($this->tmpFile, "w");
if ($fp == false)
{
$error_code = PHPCrawlerRequestErrors::ERROR_TMP_FILE_NOT_WRITEABLE;
$error_string = "Couldn't open the temporary file ".$this->tmpFile." for writing.";
return "";
}
}
// Init
$source_portion = "";
$source_complete = "";
$document_received_completely = true;
$document_completed = false;
$gzip_encoded_content = null;
// Resume data-transfer-time benchmark
PHPCrawlerBenchmark::start("data_transfer_time");
while ($document_completed == false)
{
// Get chunk from content
$content_chunk = $this->readResponseContentChunk($document_completed, $error_code, $error_string, $document_received_completely);
$source_portion .= $content_chunk;
// Check if content is gzip-encoded (check only first chunk)
if ($gzip_encoded_content === null)
{
if (PHPCrawlerEncodingUtils::isGzipEncoded($content_chunk))
$gzip_encoded_content = true;
else
$gzip_encoded_content = false;
}
// Stream to file or store source in memory
if ($stream_to_file == true)
{
@fwrite($fp, $content_chunk);
}
else
{
$source_complete .= $content_chunk;
}
// Decode gzip-encoded content when done with document
if ($document_completed == true && $gzip_encoded_content == true)
$source_complete = $source_portion = PHPCrawlerEncodingUtils::decodeGZipContent($source_complete);
// Find links in portion of the source
if (($gzip_encoded_content == false && $stream_to_file == false && strlen($source_portion) >= $this->content_buffer_size) || $document_completed == true)
{
if (PHPCrawlerUtils::checkStringAgainstRegexArray($this->lastResponseHeader->content_type, $this->linksearch_content_types))
{
PHPCrawlerBenchmark::stop("data_transfer_time");
$this->LinkFinder->findLinksInHTMLChunk($source_portion);
if ($this->source_overlap_size > 0)
$source_portion = substr($source_portion, -$this->source_overlap_size);
else
$source_portion = "";
PHPCrawlerBenchmark::start("data_transfer_time");
}
}
}
if ($stream_to_file == true) @fclose($fp);
// Stop data-transfer-time benchmark
PHPCrawlerBenchmark::stop("data_transfer_time");
$this->data_transfer_time = PHPCrawlerBenchmark::getElapsedTime("data_transfer_time");
return $source_complete;
}
|
[
"protected",
"function",
"readResponseContent",
"(",
"$",
"stream_to_file",
"=",
"false",
",",
"&",
"$",
"error_code",
",",
"&",
"$",
"error_string",
",",
"&",
"$",
"document_received_completely",
")",
"{",
"$",
"this",
"->",
"content_bytes_received",
"=",
"0",
";",
"// If content should be streamed to file\r",
"if",
"(",
"$",
"stream_to_file",
"==",
"true",
")",
"{",
"$",
"fp",
"=",
"@",
"fopen",
"(",
"$",
"this",
"->",
"tmpFile",
",",
"\"w\"",
")",
";",
"if",
"(",
"$",
"fp",
"==",
"false",
")",
"{",
"$",
"error_code",
"=",
"PHPCrawlerRequestErrors",
"::",
"ERROR_TMP_FILE_NOT_WRITEABLE",
";",
"$",
"error_string",
"=",
"\"Couldn't open the temporary file \"",
".",
"$",
"this",
"->",
"tmpFile",
".",
"\" for writing.\"",
";",
"return",
"\"\"",
";",
"}",
"}",
"// Init\r",
"$",
"source_portion",
"=",
"\"\"",
";",
"$",
"source_complete",
"=",
"\"\"",
";",
"$",
"document_received_completely",
"=",
"true",
";",
"$",
"document_completed",
"=",
"false",
";",
"$",
"gzip_encoded_content",
"=",
"null",
";",
"// Resume data-transfer-time benchmark\r",
"PHPCrawlerBenchmark",
"::",
"start",
"(",
"\"data_transfer_time\"",
")",
";",
"while",
"(",
"$",
"document_completed",
"==",
"false",
")",
"{",
"// Get chunk from content\r",
"$",
"content_chunk",
"=",
"$",
"this",
"->",
"readResponseContentChunk",
"(",
"$",
"document_completed",
",",
"$",
"error_code",
",",
"$",
"error_string",
",",
"$",
"document_received_completely",
")",
";",
"$",
"source_portion",
".=",
"$",
"content_chunk",
";",
"// Check if content is gzip-encoded (check only first chunk)\r",
"if",
"(",
"$",
"gzip_encoded_content",
"===",
"null",
")",
"{",
"if",
"(",
"PHPCrawlerEncodingUtils",
"::",
"isGzipEncoded",
"(",
"$",
"content_chunk",
")",
")",
"$",
"gzip_encoded_content",
"=",
"true",
";",
"else",
"$",
"gzip_encoded_content",
"=",
"false",
";",
"}",
"// Stream to file or store source in memory\r",
"if",
"(",
"$",
"stream_to_file",
"==",
"true",
")",
"{",
"@",
"fwrite",
"(",
"$",
"fp",
",",
"$",
"content_chunk",
")",
";",
"}",
"else",
"{",
"$",
"source_complete",
".=",
"$",
"content_chunk",
";",
"}",
"// Decode gzip-encoded content when done with document\r",
"if",
"(",
"$",
"document_completed",
"==",
"true",
"&&",
"$",
"gzip_encoded_content",
"==",
"true",
")",
"$",
"source_complete",
"=",
"$",
"source_portion",
"=",
"PHPCrawlerEncodingUtils",
"::",
"decodeGZipContent",
"(",
"$",
"source_complete",
")",
";",
"// Find links in portion of the source\r",
"if",
"(",
"(",
"$",
"gzip_encoded_content",
"==",
"false",
"&&",
"$",
"stream_to_file",
"==",
"false",
"&&",
"strlen",
"(",
"$",
"source_portion",
")",
">=",
"$",
"this",
"->",
"content_buffer_size",
")",
"||",
"$",
"document_completed",
"==",
"true",
")",
"{",
"if",
"(",
"PHPCrawlerUtils",
"::",
"checkStringAgainstRegexArray",
"(",
"$",
"this",
"->",
"lastResponseHeader",
"->",
"content_type",
",",
"$",
"this",
"->",
"linksearch_content_types",
")",
")",
"{",
"PHPCrawlerBenchmark",
"::",
"stop",
"(",
"\"data_transfer_time\"",
")",
";",
"$",
"this",
"->",
"LinkFinder",
"->",
"findLinksInHTMLChunk",
"(",
"$",
"source_portion",
")",
";",
"if",
"(",
"$",
"this",
"->",
"source_overlap_size",
">",
"0",
")",
"$",
"source_portion",
"=",
"substr",
"(",
"$",
"source_portion",
",",
"-",
"$",
"this",
"->",
"source_overlap_size",
")",
";",
"else",
"$",
"source_portion",
"=",
"\"\"",
";",
"PHPCrawlerBenchmark",
"::",
"start",
"(",
"\"data_transfer_time\"",
")",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"stream_to_file",
"==",
"true",
")",
"@",
"fclose",
"(",
"$",
"fp",
")",
";",
"// Stop data-transfer-time benchmark\r",
"PHPCrawlerBenchmark",
"::",
"stop",
"(",
"\"data_transfer_time\"",
")",
";",
"$",
"this",
"->",
"data_transfer_time",
"=",
"PHPCrawlerBenchmark",
"::",
"getElapsedTime",
"(",
"\"data_transfer_time\"",
")",
";",
"return",
"$",
"source_complete",
";",
"}"
] |
Reads the response-content.
@param bool $stream_to_file If TRUE, the content will be streamed diretly to the temporary file and
this method will not return the content as a string.
@param int &$error_code Error-code by reference if an error occured.
@param &string &$error_string Error-string by reference
@param &string &$document_received_completely Flag indicatign whether the content was received completely passed by reference
@return string The response-content/source. May be emtpy if an error ocdured or data was streamed to the tmp-file.
|
[
"Reads",
"the",
"response",
"-",
"content",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawlerHTTPRequest.class.php#L715-L796
|
223,264
|
mmerian/phpcrawl
|
libs/PHPCrawlerHTTPRequest.class.php
|
PHPCrawlerHTTPRequest.readResponseContentChunk
|
protected function readResponseContentChunk(&$document_completed, &$error_code, &$error_string, &$document_received_completely)
{
$source_chunk = "";
$stop_receiving = false;
$bytes_received = 0;
$document_completed = false;
// If chunked encoding and protocol to use is HTTP 1.1
if ($this->http_protocol_version == PHPCrawlerHTTPProtocols::HTTP_1_1 && $this->lastResponseHeader->transfer_encoding == "chunked")
{
// Read size of next chunk
$chunk_line = @fgets($this->socket, 128);
if (trim($chunk_line) == "") $chunk_line = @fgets($this->socket, 128);
$current_chunk_size = hexdec(trim($chunk_line));
}
else
{
$current_chunk_size = $this->chunk_buffer_size;
}
if ($current_chunk_size === 0)
{
$stop_receiving = true;
$document_completed = true;
}
while ($stop_receiving == false)
{
socket_set_timeout($this->socket, $this->socketReadTimeout);
// Set byte-buffer to bytes in socket-buffer (Fix for SSL-hang-bug #56, thanks to MadEgg!)
$status = socket_get_status($this->socket);
if ($status["unread_bytes"] > 0)
$read_byte_buffer = $status["unread_bytes"];
else
$read_byte_buffer = $this->socket_read_buffer_size;
// If chunk will be complete next read -> resize read-buffer to size of remaining chunk
if ($bytes_received + $read_byte_buffer >= $current_chunk_size && $current_chunk_size > 0)
{
$read_byte_buffer = $current_chunk_size - $bytes_received;
$stop_receiving = true;
}
// Read line from socket
$line_read = @fread($this->socket, $read_byte_buffer);
$source_chunk .= $line_read;
$line_length = strlen($line_read);
$this->content_bytes_received += $line_length;
$this->global_traffic_count += $line_length;
$bytes_received += $line_length;
// Check socket-status
$status = socket_get_status($this->socket);
// Check for EOF
if ($status["unread_bytes"] == 0 && ($status["eof"] == true || feof($this->socket) == true))
{
$stop_receiving = true;
$document_completed = true;
}
// Socket timed out
if ($status["timed_out"] == true)
{
$stop_receiving = true;
$document_completed = true;
$error_code = PHPCrawlerRequestErrors::ERROR_SOCKET_TIMEOUT;
$error_string = "Socket-stream timed out (timeout set to ".$this->socketReadTimeout." sec).";
$document_received_completely = false;
return $source_chunk;
}
// Check if content-length stated in the header is reached
if ($this->lastResponseHeader->content_length == $this->content_bytes_received)
{
$stop_receiving = true;
$document_completed = true;
}
// Check if contentsize-limit is reached
if ($this->content_size_limit > 0 && $this->content_size_limit <= $this->content_bytes_received)
{
$document_received_completely = false;
$stop_receiving = true;
$document_completed = true;
}
}
return $source_chunk;
}
|
php
|
protected function readResponseContentChunk(&$document_completed, &$error_code, &$error_string, &$document_received_completely)
{
$source_chunk = "";
$stop_receiving = false;
$bytes_received = 0;
$document_completed = false;
// If chunked encoding and protocol to use is HTTP 1.1
if ($this->http_protocol_version == PHPCrawlerHTTPProtocols::HTTP_1_1 && $this->lastResponseHeader->transfer_encoding == "chunked")
{
// Read size of next chunk
$chunk_line = @fgets($this->socket, 128);
if (trim($chunk_line) == "") $chunk_line = @fgets($this->socket, 128);
$current_chunk_size = hexdec(trim($chunk_line));
}
else
{
$current_chunk_size = $this->chunk_buffer_size;
}
if ($current_chunk_size === 0)
{
$stop_receiving = true;
$document_completed = true;
}
while ($stop_receiving == false)
{
socket_set_timeout($this->socket, $this->socketReadTimeout);
// Set byte-buffer to bytes in socket-buffer (Fix for SSL-hang-bug #56, thanks to MadEgg!)
$status = socket_get_status($this->socket);
if ($status["unread_bytes"] > 0)
$read_byte_buffer = $status["unread_bytes"];
else
$read_byte_buffer = $this->socket_read_buffer_size;
// If chunk will be complete next read -> resize read-buffer to size of remaining chunk
if ($bytes_received + $read_byte_buffer >= $current_chunk_size && $current_chunk_size > 0)
{
$read_byte_buffer = $current_chunk_size - $bytes_received;
$stop_receiving = true;
}
// Read line from socket
$line_read = @fread($this->socket, $read_byte_buffer);
$source_chunk .= $line_read;
$line_length = strlen($line_read);
$this->content_bytes_received += $line_length;
$this->global_traffic_count += $line_length;
$bytes_received += $line_length;
// Check socket-status
$status = socket_get_status($this->socket);
// Check for EOF
if ($status["unread_bytes"] == 0 && ($status["eof"] == true || feof($this->socket) == true))
{
$stop_receiving = true;
$document_completed = true;
}
// Socket timed out
if ($status["timed_out"] == true)
{
$stop_receiving = true;
$document_completed = true;
$error_code = PHPCrawlerRequestErrors::ERROR_SOCKET_TIMEOUT;
$error_string = "Socket-stream timed out (timeout set to ".$this->socketReadTimeout." sec).";
$document_received_completely = false;
return $source_chunk;
}
// Check if content-length stated in the header is reached
if ($this->lastResponseHeader->content_length == $this->content_bytes_received)
{
$stop_receiving = true;
$document_completed = true;
}
// Check if contentsize-limit is reached
if ($this->content_size_limit > 0 && $this->content_size_limit <= $this->content_bytes_received)
{
$document_received_completely = false;
$stop_receiving = true;
$document_completed = true;
}
}
return $source_chunk;
}
|
[
"protected",
"function",
"readResponseContentChunk",
"(",
"&",
"$",
"document_completed",
",",
"&",
"$",
"error_code",
",",
"&",
"$",
"error_string",
",",
"&",
"$",
"document_received_completely",
")",
"{",
"$",
"source_chunk",
"=",
"\"\"",
";",
"$",
"stop_receiving",
"=",
"false",
";",
"$",
"bytes_received",
"=",
"0",
";",
"$",
"document_completed",
"=",
"false",
";",
"// If chunked encoding and protocol to use is HTTP 1.1\r",
"if",
"(",
"$",
"this",
"->",
"http_protocol_version",
"==",
"PHPCrawlerHTTPProtocols",
"::",
"HTTP_1_1",
"&&",
"$",
"this",
"->",
"lastResponseHeader",
"->",
"transfer_encoding",
"==",
"\"chunked\"",
")",
"{",
"// Read size of next chunk\r",
"$",
"chunk_line",
"=",
"@",
"fgets",
"(",
"$",
"this",
"->",
"socket",
",",
"128",
")",
";",
"if",
"(",
"trim",
"(",
"$",
"chunk_line",
")",
"==",
"\"\"",
")",
"$",
"chunk_line",
"=",
"@",
"fgets",
"(",
"$",
"this",
"->",
"socket",
",",
"128",
")",
";",
"$",
"current_chunk_size",
"=",
"hexdec",
"(",
"trim",
"(",
"$",
"chunk_line",
")",
")",
";",
"}",
"else",
"{",
"$",
"current_chunk_size",
"=",
"$",
"this",
"->",
"chunk_buffer_size",
";",
"}",
"if",
"(",
"$",
"current_chunk_size",
"===",
"0",
")",
"{",
"$",
"stop_receiving",
"=",
"true",
";",
"$",
"document_completed",
"=",
"true",
";",
"}",
"while",
"(",
"$",
"stop_receiving",
"==",
"false",
")",
"{",
"socket_set_timeout",
"(",
"$",
"this",
"->",
"socket",
",",
"$",
"this",
"->",
"socketReadTimeout",
")",
";",
"// Set byte-buffer to bytes in socket-buffer (Fix for SSL-hang-bug #56, thanks to MadEgg!)\r",
"$",
"status",
"=",
"socket_get_status",
"(",
"$",
"this",
"->",
"socket",
")",
";",
"if",
"(",
"$",
"status",
"[",
"\"unread_bytes\"",
"]",
">",
"0",
")",
"$",
"read_byte_buffer",
"=",
"$",
"status",
"[",
"\"unread_bytes\"",
"]",
";",
"else",
"$",
"read_byte_buffer",
"=",
"$",
"this",
"->",
"socket_read_buffer_size",
";",
"// If chunk will be complete next read -> resize read-buffer to size of remaining chunk\r",
"if",
"(",
"$",
"bytes_received",
"+",
"$",
"read_byte_buffer",
">=",
"$",
"current_chunk_size",
"&&",
"$",
"current_chunk_size",
">",
"0",
")",
"{",
"$",
"read_byte_buffer",
"=",
"$",
"current_chunk_size",
"-",
"$",
"bytes_received",
";",
"$",
"stop_receiving",
"=",
"true",
";",
"}",
"// Read line from socket\r",
"$",
"line_read",
"=",
"@",
"fread",
"(",
"$",
"this",
"->",
"socket",
",",
"$",
"read_byte_buffer",
")",
";",
"$",
"source_chunk",
".=",
"$",
"line_read",
";",
"$",
"line_length",
"=",
"strlen",
"(",
"$",
"line_read",
")",
";",
"$",
"this",
"->",
"content_bytes_received",
"+=",
"$",
"line_length",
";",
"$",
"this",
"->",
"global_traffic_count",
"+=",
"$",
"line_length",
";",
"$",
"bytes_received",
"+=",
"$",
"line_length",
";",
"// Check socket-status\r",
"$",
"status",
"=",
"socket_get_status",
"(",
"$",
"this",
"->",
"socket",
")",
";",
"// Check for EOF\r",
"if",
"(",
"$",
"status",
"[",
"\"unread_bytes\"",
"]",
"==",
"0",
"&&",
"(",
"$",
"status",
"[",
"\"eof\"",
"]",
"==",
"true",
"||",
"feof",
"(",
"$",
"this",
"->",
"socket",
")",
"==",
"true",
")",
")",
"{",
"$",
"stop_receiving",
"=",
"true",
";",
"$",
"document_completed",
"=",
"true",
";",
"}",
"// Socket timed out\r",
"if",
"(",
"$",
"status",
"[",
"\"timed_out\"",
"]",
"==",
"true",
")",
"{",
"$",
"stop_receiving",
"=",
"true",
";",
"$",
"document_completed",
"=",
"true",
";",
"$",
"error_code",
"=",
"PHPCrawlerRequestErrors",
"::",
"ERROR_SOCKET_TIMEOUT",
";",
"$",
"error_string",
"=",
"\"Socket-stream timed out (timeout set to \"",
".",
"$",
"this",
"->",
"socketReadTimeout",
".",
"\" sec).\"",
";",
"$",
"document_received_completely",
"=",
"false",
";",
"return",
"$",
"source_chunk",
";",
"}",
"// Check if content-length stated in the header is reached\r",
"if",
"(",
"$",
"this",
"->",
"lastResponseHeader",
"->",
"content_length",
"==",
"$",
"this",
"->",
"content_bytes_received",
")",
"{",
"$",
"stop_receiving",
"=",
"true",
";",
"$",
"document_completed",
"=",
"true",
";",
"}",
"// Check if contentsize-limit is reached\r",
"if",
"(",
"$",
"this",
"->",
"content_size_limit",
">",
"0",
"&&",
"$",
"this",
"->",
"content_size_limit",
"<=",
"$",
"this",
"->",
"content_bytes_received",
")",
"{",
"$",
"document_received_completely",
"=",
"false",
";",
"$",
"stop_receiving",
"=",
"true",
";",
"$",
"document_completed",
"=",
"true",
";",
"}",
"}",
"return",
"$",
"source_chunk",
";",
"}"
] |
Reads a chunk from the response-content
@return string
|
[
"Reads",
"a",
"chunk",
"from",
"the",
"response",
"-",
"content"
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawlerHTTPRequest.class.php#L803-L895
|
223,265
|
mmerian/phpcrawl
|
libs/PHPCrawlerHTTPRequest.class.php
|
PHPCrawlerHTTPRequest.buildRequestHeader
|
protected function buildRequestHeader()
{
// Create header
$headerlines = array();
// Methode(GET or POST)
if (count($this->post_data) > 0) $request_type = "POST";
else $request_type = "GET";
// HTTP protocol
if ($this->http_protocol_version == PHPCrawlerHTTPProtocols::HTTP_1_1) $http_protocol_verison = "1.1";
else $http_protocol_verison = "1.0";
if ($this->proxy != null)
{
// A Proxy needs the full qualified URL in the GET or POST headerline.
$headerlines[] = $request_type." ".$this->UrlDescriptor->url_rebuild ." HTTP/1.0\r\n";
}
else
{
$query = $this->prepareHTTPRequestQuery($this->url_parts["path"].$this->url_parts["file"].$this->url_parts["query"]);
$headerlines[] = $request_type." ".$query." HTTP/".$http_protocol_verison."\r\n";
}
$headerlines[] = "Host: ".$this->url_parts["host"]."\r\n";
$headerlines[] = "User-Agent: ".str_replace("\n", "", $this->userAgentString)."\r\n";
$headerlines[] = "Accept: */*\r\n";
// Request GZIP-content
if ($this->request_gzip_content == true)
{
$headerlines[] = "Accept-Encoding: gzip, deflate\r\n";
}
// Referer
if ($this->UrlDescriptor->refering_url != null)
{
$headerlines[] = "Referer: ".$this->UrlDescriptor->refering_url."\r\n";
}
// Cookies
$cookie_header = $this->buildCookieHeader();
if ($cookie_header != null)
$headerlines[] = $this->buildCookieHeader();
// Authentication
if ($this->url_parts["auth_username"] != "" && $this->url_parts["auth_password"] != "")
{
$auth_string = base64_encode($this->url_parts["auth_username"].":".$this->url_parts["auth_password"]);
$headerlines[] = "Authorization: Basic ".$auth_string."\r\n";
}
// Proxy authentication
if ($this->proxy != null && $this->proxy["proxy_username"] != null)
{
$auth_string = base64_encode($this->proxy["proxy_username"].":".$this->proxy["proxy_password"]);
$headerlines[] = "Proxy-Authorization: Basic ".$auth_string."\r\n";
}
$headerlines[] = "Connection: close\r\n";
// Wenn POST-Request
if ($request_type == "POST")
{
// Post-Content bauen
$post_content = $this->buildPostContent();
$headerlines[] = "Content-Type: multipart/form-data; boundary=---------------------------10786153015124\r\n";
$headerlines[] = "Content-Length: ".strlen($post_content)."\r\n\r\n";
$headerlines[] = $post_content;
}
else
{
$headerlines[] = "\r\n";
}
return $headerlines;
}
|
php
|
protected function buildRequestHeader()
{
// Create header
$headerlines = array();
// Methode(GET or POST)
if (count($this->post_data) > 0) $request_type = "POST";
else $request_type = "GET";
// HTTP protocol
if ($this->http_protocol_version == PHPCrawlerHTTPProtocols::HTTP_1_1) $http_protocol_verison = "1.1";
else $http_protocol_verison = "1.0";
if ($this->proxy != null)
{
// A Proxy needs the full qualified URL in the GET or POST headerline.
$headerlines[] = $request_type." ".$this->UrlDescriptor->url_rebuild ." HTTP/1.0\r\n";
}
else
{
$query = $this->prepareHTTPRequestQuery($this->url_parts["path"].$this->url_parts["file"].$this->url_parts["query"]);
$headerlines[] = $request_type." ".$query." HTTP/".$http_protocol_verison."\r\n";
}
$headerlines[] = "Host: ".$this->url_parts["host"]."\r\n";
$headerlines[] = "User-Agent: ".str_replace("\n", "", $this->userAgentString)."\r\n";
$headerlines[] = "Accept: */*\r\n";
// Request GZIP-content
if ($this->request_gzip_content == true)
{
$headerlines[] = "Accept-Encoding: gzip, deflate\r\n";
}
// Referer
if ($this->UrlDescriptor->refering_url != null)
{
$headerlines[] = "Referer: ".$this->UrlDescriptor->refering_url."\r\n";
}
// Cookies
$cookie_header = $this->buildCookieHeader();
if ($cookie_header != null)
$headerlines[] = $this->buildCookieHeader();
// Authentication
if ($this->url_parts["auth_username"] != "" && $this->url_parts["auth_password"] != "")
{
$auth_string = base64_encode($this->url_parts["auth_username"].":".$this->url_parts["auth_password"]);
$headerlines[] = "Authorization: Basic ".$auth_string."\r\n";
}
// Proxy authentication
if ($this->proxy != null && $this->proxy["proxy_username"] != null)
{
$auth_string = base64_encode($this->proxy["proxy_username"].":".$this->proxy["proxy_password"]);
$headerlines[] = "Proxy-Authorization: Basic ".$auth_string."\r\n";
}
$headerlines[] = "Connection: close\r\n";
// Wenn POST-Request
if ($request_type == "POST")
{
// Post-Content bauen
$post_content = $this->buildPostContent();
$headerlines[] = "Content-Type: multipart/form-data; boundary=---------------------------10786153015124\r\n";
$headerlines[] = "Content-Length: ".strlen($post_content)."\r\n\r\n";
$headerlines[] = $post_content;
}
else
{
$headerlines[] = "\r\n";
}
return $headerlines;
}
|
[
"protected",
"function",
"buildRequestHeader",
"(",
")",
"{",
"// Create header\r",
"$",
"headerlines",
"=",
"array",
"(",
")",
";",
"// Methode(GET or POST)\r",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"post_data",
")",
">",
"0",
")",
"$",
"request_type",
"=",
"\"POST\"",
";",
"else",
"$",
"request_type",
"=",
"\"GET\"",
";",
"// HTTP protocol\r",
"if",
"(",
"$",
"this",
"->",
"http_protocol_version",
"==",
"PHPCrawlerHTTPProtocols",
"::",
"HTTP_1_1",
")",
"$",
"http_protocol_verison",
"=",
"\"1.1\"",
";",
"else",
"$",
"http_protocol_verison",
"=",
"\"1.0\"",
";",
"if",
"(",
"$",
"this",
"->",
"proxy",
"!=",
"null",
")",
"{",
"// A Proxy needs the full qualified URL in the GET or POST headerline.\r",
"$",
"headerlines",
"[",
"]",
"=",
"$",
"request_type",
".",
"\" \"",
".",
"$",
"this",
"->",
"UrlDescriptor",
"->",
"url_rebuild",
".",
"\" HTTP/1.0\\r\\n\"",
";",
"}",
"else",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"prepareHTTPRequestQuery",
"(",
"$",
"this",
"->",
"url_parts",
"[",
"\"path\"",
"]",
".",
"$",
"this",
"->",
"url_parts",
"[",
"\"file\"",
"]",
".",
"$",
"this",
"->",
"url_parts",
"[",
"\"query\"",
"]",
")",
";",
"$",
"headerlines",
"[",
"]",
"=",
"$",
"request_type",
".",
"\" \"",
".",
"$",
"query",
".",
"\" HTTP/\"",
".",
"$",
"http_protocol_verison",
".",
"\"\\r\\n\"",
";",
"}",
"$",
"headerlines",
"[",
"]",
"=",
"\"Host: \"",
".",
"$",
"this",
"->",
"url_parts",
"[",
"\"host\"",
"]",
".",
"\"\\r\\n\"",
";",
"$",
"headerlines",
"[",
"]",
"=",
"\"User-Agent: \"",
".",
"str_replace",
"(",
"\"\\n\"",
",",
"\"\"",
",",
"$",
"this",
"->",
"userAgentString",
")",
".",
"\"\\r\\n\"",
";",
"$",
"headerlines",
"[",
"]",
"=",
"\"Accept: */*\\r\\n\"",
";",
"// Request GZIP-content\r",
"if",
"(",
"$",
"this",
"->",
"request_gzip_content",
"==",
"true",
")",
"{",
"$",
"headerlines",
"[",
"]",
"=",
"\"Accept-Encoding: gzip, deflate\\r\\n\"",
";",
"}",
"// Referer\r",
"if",
"(",
"$",
"this",
"->",
"UrlDescriptor",
"->",
"refering_url",
"!=",
"null",
")",
"{",
"$",
"headerlines",
"[",
"]",
"=",
"\"Referer: \"",
".",
"$",
"this",
"->",
"UrlDescriptor",
"->",
"refering_url",
".",
"\"\\r\\n\"",
";",
"}",
"// Cookies\r",
"$",
"cookie_header",
"=",
"$",
"this",
"->",
"buildCookieHeader",
"(",
")",
";",
"if",
"(",
"$",
"cookie_header",
"!=",
"null",
")",
"$",
"headerlines",
"[",
"]",
"=",
"$",
"this",
"->",
"buildCookieHeader",
"(",
")",
";",
"// Authentication\r",
"if",
"(",
"$",
"this",
"->",
"url_parts",
"[",
"\"auth_username\"",
"]",
"!=",
"\"\"",
"&&",
"$",
"this",
"->",
"url_parts",
"[",
"\"auth_password\"",
"]",
"!=",
"\"\"",
")",
"{",
"$",
"auth_string",
"=",
"base64_encode",
"(",
"$",
"this",
"->",
"url_parts",
"[",
"\"auth_username\"",
"]",
".",
"\":\"",
".",
"$",
"this",
"->",
"url_parts",
"[",
"\"auth_password\"",
"]",
")",
";",
"$",
"headerlines",
"[",
"]",
"=",
"\"Authorization: Basic \"",
".",
"$",
"auth_string",
".",
"\"\\r\\n\"",
";",
"}",
"// Proxy authentication\r",
"if",
"(",
"$",
"this",
"->",
"proxy",
"!=",
"null",
"&&",
"$",
"this",
"->",
"proxy",
"[",
"\"proxy_username\"",
"]",
"!=",
"null",
")",
"{",
"$",
"auth_string",
"=",
"base64_encode",
"(",
"$",
"this",
"->",
"proxy",
"[",
"\"proxy_username\"",
"]",
".",
"\":\"",
".",
"$",
"this",
"->",
"proxy",
"[",
"\"proxy_password\"",
"]",
")",
";",
"$",
"headerlines",
"[",
"]",
"=",
"\"Proxy-Authorization: Basic \"",
".",
"$",
"auth_string",
".",
"\"\\r\\n\"",
";",
"}",
"$",
"headerlines",
"[",
"]",
"=",
"\"Connection: close\\r\\n\"",
";",
"// Wenn POST-Request\r",
"if",
"(",
"$",
"request_type",
"==",
"\"POST\"",
")",
"{",
"// Post-Content bauen\r",
"$",
"post_content",
"=",
"$",
"this",
"->",
"buildPostContent",
"(",
")",
";",
"$",
"headerlines",
"[",
"]",
"=",
"\"Content-Type: multipart/form-data; boundary=---------------------------10786153015124\\r\\n\"",
";",
"$",
"headerlines",
"[",
"]",
"=",
"\"Content-Length: \"",
".",
"strlen",
"(",
"$",
"post_content",
")",
".",
"\"\\r\\n\\r\\n\"",
";",
"$",
"headerlines",
"[",
"]",
"=",
"$",
"post_content",
";",
"}",
"else",
"{",
"$",
"headerlines",
"[",
"]",
"=",
"\"\\r\\n\"",
";",
"}",
"return",
"$",
"headerlines",
";",
"}"
] |
Builds the request-header from the given settings.
@return array Numeric array containing the lines of the request-header
|
[
"Builds",
"the",
"request",
"-",
"header",
"from",
"the",
"given",
"settings",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawlerHTTPRequest.class.php#L902-L980
|
223,266
|
mmerian/phpcrawl
|
libs/PHPCrawlerHTTPRequest.class.php
|
PHPCrawlerHTTPRequest.prepareHTTPRequestQuery
|
protected function prepareHTTPRequestQuery($query)
{
// If string already is a valid URL -> do nothing
if (PHPCrawlerUtils::isValidUrlString($query))
{
return $query;
}
// Decode query-string (for URLs that are partly urlencoded and partly not)
$query = rawurldecode($query);
// if query is already utf-8 encoded -> simply urlencode it,
// otherwise encode it to utf8 first.
if (PHPCrawlerEncodingUtils::isUTF8String($query) == true)
{
$query = rawurlencode($query);
}
else
{
$query = rawurlencode(utf8_encode($query));
}
// Replace url-specific signs back
$query = str_replace("%2F", "/", $query);
$query = str_replace("%3F", "?", $query);
$query = str_replace("%3D", "=", $query);
$query = str_replace("%26", "&", $query);
return $query;
}
|
php
|
protected function prepareHTTPRequestQuery($query)
{
// If string already is a valid URL -> do nothing
if (PHPCrawlerUtils::isValidUrlString($query))
{
return $query;
}
// Decode query-string (for URLs that are partly urlencoded and partly not)
$query = rawurldecode($query);
// if query is already utf-8 encoded -> simply urlencode it,
// otherwise encode it to utf8 first.
if (PHPCrawlerEncodingUtils::isUTF8String($query) == true)
{
$query = rawurlencode($query);
}
else
{
$query = rawurlencode(utf8_encode($query));
}
// Replace url-specific signs back
$query = str_replace("%2F", "/", $query);
$query = str_replace("%3F", "?", $query);
$query = str_replace("%3D", "=", $query);
$query = str_replace("%26", "&", $query);
return $query;
}
|
[
"protected",
"function",
"prepareHTTPRequestQuery",
"(",
"$",
"query",
")",
"{",
"// If string already is a valid URL -> do nothing\r",
"if",
"(",
"PHPCrawlerUtils",
"::",
"isValidUrlString",
"(",
"$",
"query",
")",
")",
"{",
"return",
"$",
"query",
";",
"}",
"// Decode query-string (for URLs that are partly urlencoded and partly not)\r",
"$",
"query",
"=",
"rawurldecode",
"(",
"$",
"query",
")",
";",
"// if query is already utf-8 encoded -> simply urlencode it,\r",
"// otherwise encode it to utf8 first.\r",
"if",
"(",
"PHPCrawlerEncodingUtils",
"::",
"isUTF8String",
"(",
"$",
"query",
")",
"==",
"true",
")",
"{",
"$",
"query",
"=",
"rawurlencode",
"(",
"$",
"query",
")",
";",
"}",
"else",
"{",
"$",
"query",
"=",
"rawurlencode",
"(",
"utf8_encode",
"(",
"$",
"query",
")",
")",
";",
"}",
"// Replace url-specific signs back\r",
"$",
"query",
"=",
"str_replace",
"(",
"\"%2F\"",
",",
"\"/\"",
",",
"$",
"query",
")",
";",
"$",
"query",
"=",
"str_replace",
"(",
"\"%3F\"",
",",
"\"?\"",
",",
"$",
"query",
")",
";",
"$",
"query",
"=",
"str_replace",
"(",
"\"%3D\"",
",",
"\"=\"",
",",
"$",
"query",
")",
";",
"$",
"query",
"=",
"str_replace",
"(",
"\"%26\"",
",",
"\"&\"",
",",
"$",
"query",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
Prepares the given HTTP-query-string for the HTTP-request.
HTTP-query-strings always should be utf8-encoded and urlencoded afterwards.
So "/path/file?test=tatütata" will be converted to "/path/file?test=tat%C3%BCtata":
@param stirng The quetry-string (like "/path/file?test=tatütata")
@return string
|
[
"Prepares",
"the",
"given",
"HTTP",
"-",
"query",
"-",
"string",
"for",
"the",
"HTTP",
"-",
"request",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawlerHTTPRequest.class.php#L991-L1020
|
223,267
|
mmerian/phpcrawl
|
libs/PHPCrawlerHTTPRequest.class.php
|
PHPCrawlerHTTPRequest.buildCookieHeader
|
protected function buildCookieHeader()
{
$cookie_string = "";
@reset($this->cookie_array);
while(list($key, $value) = @each($this->cookie_array))
{
$cookie_string .= "; ".$key."=".$value."";
}
if ($cookie_string != "")
{
return "Cookie: ".substr($cookie_string, 2)."\r\n";
}
else
{
return null;
}
}
|
php
|
protected function buildCookieHeader()
{
$cookie_string = "";
@reset($this->cookie_array);
while(list($key, $value) = @each($this->cookie_array))
{
$cookie_string .= "; ".$key."=".$value."";
}
if ($cookie_string != "")
{
return "Cookie: ".substr($cookie_string, 2)."\r\n";
}
else
{
return null;
}
}
|
[
"protected",
"function",
"buildCookieHeader",
"(",
")",
"{",
"$",
"cookie_string",
"=",
"\"\"",
";",
"@",
"reset",
"(",
"$",
"this",
"->",
"cookie_array",
")",
";",
"while",
"(",
"list",
"(",
"$",
"key",
",",
"$",
"value",
")",
"=",
"@",
"each",
"(",
"$",
"this",
"->",
"cookie_array",
")",
")",
"{",
"$",
"cookie_string",
".=",
"\"; \"",
".",
"$",
"key",
".",
"\"=\"",
".",
"$",
"value",
".",
"\"\"",
";",
"}",
"if",
"(",
"$",
"cookie_string",
"!=",
"\"\"",
")",
"{",
"return",
"\"Cookie: \"",
".",
"substr",
"(",
"$",
"cookie_string",
",",
"2",
")",
".",
"\"\\r\\n\"",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Builds the cookie-header-part for the header to send.
@return string The cookie-header-part, i.e. "Cookie: test=bla; palimm=palaber"
Returns NULL if no cookies should be send with the header.
|
[
"Builds",
"the",
"cookie",
"-",
"header",
"-",
"part",
"for",
"the",
"header",
"to",
"send",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawlerHTTPRequest.class.php#L1051-L1069
|
223,268
|
mmerian/phpcrawl
|
libs/PHPCrawlerHTTPRequest.class.php
|
PHPCrawlerHTTPRequest.addReceiveContentType
|
public function addReceiveContentType($regex)
{
$check = PHPCrawlerUtils::checkRegexPattern($regex); // Check pattern
if ($check == true)
{
$this->receive_content_types[] = trim(strtolower($regex));
}
return $check;
}
|
php
|
public function addReceiveContentType($regex)
{
$check = PHPCrawlerUtils::checkRegexPattern($regex); // Check pattern
if ($check == true)
{
$this->receive_content_types[] = trim(strtolower($regex));
}
return $check;
}
|
[
"public",
"function",
"addReceiveContentType",
"(",
"$",
"regex",
")",
"{",
"$",
"check",
"=",
"PHPCrawlerUtils",
"::",
"checkRegexPattern",
"(",
"$",
"regex",
")",
";",
"// Check pattern\r",
"if",
"(",
"$",
"check",
"==",
"true",
")",
"{",
"$",
"this",
"->",
"receive_content_types",
"[",
"]",
"=",
"trim",
"(",
"strtolower",
"(",
"$",
"regex",
")",
")",
";",
"}",
"return",
"$",
"check",
";",
"}"
] |
Adds a rule to the list of rules that decides which pages or files - regarding their content-type - should be received
If the content-type of a requested document doesn't match with the given rules, the request will be aborted after the header
was received.
@param string $regex The rule as a regular-expression
@return bool TRUE if the rule was added to the list.
FALSE if the given regex is not valid.
|
[
"Adds",
"a",
"rule",
"to",
"the",
"list",
"of",
"rules",
"that",
"decides",
"which",
"pages",
"or",
"files",
"-",
"regarding",
"their",
"content",
"-",
"type",
"-",
"should",
"be",
"received"
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawlerHTTPRequest.class.php#L1136-L1145
|
223,269
|
mmerian/phpcrawl
|
libs/PHPCrawlerHTTPRequest.class.php
|
PHPCrawlerHTTPRequest.addStreamToFileContentType
|
public function addStreamToFileContentType($regex)
{
$check = PHPCrawlerUtils::checkRegexPattern($regex); // Check pattern
if ($check == true)
{
$this->receive_to_file_content_types[] = trim($regex);
}
return $check;
}
|
php
|
public function addStreamToFileContentType($regex)
{
$check = PHPCrawlerUtils::checkRegexPattern($regex); // Check pattern
if ($check == true)
{
$this->receive_to_file_content_types[] = trim($regex);
}
return $check;
}
|
[
"public",
"function",
"addStreamToFileContentType",
"(",
"$",
"regex",
")",
"{",
"$",
"check",
"=",
"PHPCrawlerUtils",
"::",
"checkRegexPattern",
"(",
"$",
"regex",
")",
";",
"// Check pattern\r",
"if",
"(",
"$",
"check",
"==",
"true",
")",
"{",
"$",
"this",
"->",
"receive_to_file_content_types",
"[",
"]",
"=",
"trim",
"(",
"$",
"regex",
")",
";",
"}",
"return",
"$",
"check",
";",
"}"
] |
Adds a rule to the list of rules that decides what types of content should be streamed diretly to the temporary file.
If a content-type of a page or file matches with one of these rules, the content will be streamed directly into the temporary file
given in setTmpFile() without claiming local RAM.
@param string $regex The rule as a regular-expression
@return bool TRUE if the rule was added to the list and the regex is valid.
|
[
"Adds",
"a",
"rule",
"to",
"the",
"list",
"of",
"rules",
"that",
"decides",
"what",
"types",
"of",
"content",
"should",
"be",
"streamed",
"diretly",
"to",
"the",
"temporary",
"file",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawlerHTTPRequest.class.php#L1156-L1165
|
223,270
|
mmerian/phpcrawl
|
libs/PHPCrawlerHTTPRequest.class.php
|
PHPCrawlerHTTPRequest.setTmpFile
|
public function setTmpFile($tmp_file)
{
//Check if writable
$fp = @fopen($tmp_file, "w");
if (!$fp)
{
return false;
}
else
{
fclose($fp);
$this->tmpFile = $tmp_file;
return true;
}
}
|
php
|
public function setTmpFile($tmp_file)
{
//Check if writable
$fp = @fopen($tmp_file, "w");
if (!$fp)
{
return false;
}
else
{
fclose($fp);
$this->tmpFile = $tmp_file;
return true;
}
}
|
[
"public",
"function",
"setTmpFile",
"(",
"$",
"tmp_file",
")",
"{",
"//Check if writable\r",
"$",
"fp",
"=",
"@",
"fopen",
"(",
"$",
"tmp_file",
",",
"\"w\"",
")",
";",
"if",
"(",
"!",
"$",
"fp",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"fclose",
"(",
"$",
"fp",
")",
";",
"$",
"this",
"->",
"tmpFile",
"=",
"$",
"tmp_file",
";",
"return",
"true",
";",
"}",
"}"
] |
Sets the temporary file to use when content of found documents should be streamed directly into a temporary file.
@param string $tmp_file The TMP-file to use.
|
[
"Sets",
"the",
"temporary",
"file",
"to",
"use",
"when",
"content",
"of",
"found",
"documents",
"should",
"be",
"streamed",
"directly",
"into",
"a",
"temporary",
"file",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawlerHTTPRequest.class.php#L1172-L1187
|
223,271
|
mmerian/phpcrawl
|
libs/PHPCrawlerHTTPRequest.class.php
|
PHPCrawlerHTTPRequest.setBufferSizes
|
public function setBufferSizes($content_buffer_size = null, $chunk_buffer_size = null, $socket_read_buffer_size = null, $source_overlap_size = null)
{
if ($content_buffer_size !== null)
$this->content_buffer_size = $content_buffer_size;
if ($chunk_buffer_size !== null)
$this->chunk_buffer_size = $chunk_buffer_size;
if ($socket_read_buffer_size !== null)
$this->socket_read_buffer_size = $socket_read_buffer_size;
if ($source_overlap_size !== null)
$this->source_overlap_size = $source_overlap_size;
if ($this->content_buffer_size < $this->chunk_buffer_size || $this->chunk_buffer_size < $this->socket_read_buffer_size)
{
throw new Exception("Implausible buffer-size-settings assigned to ".getClass($this).".");
}
}
|
php
|
public function setBufferSizes($content_buffer_size = null, $chunk_buffer_size = null, $socket_read_buffer_size = null, $source_overlap_size = null)
{
if ($content_buffer_size !== null)
$this->content_buffer_size = $content_buffer_size;
if ($chunk_buffer_size !== null)
$this->chunk_buffer_size = $chunk_buffer_size;
if ($socket_read_buffer_size !== null)
$this->socket_read_buffer_size = $socket_read_buffer_size;
if ($source_overlap_size !== null)
$this->source_overlap_size = $source_overlap_size;
if ($this->content_buffer_size < $this->chunk_buffer_size || $this->chunk_buffer_size < $this->socket_read_buffer_size)
{
throw new Exception("Implausible buffer-size-settings assigned to ".getClass($this).".");
}
}
|
[
"public",
"function",
"setBufferSizes",
"(",
"$",
"content_buffer_size",
"=",
"null",
",",
"$",
"chunk_buffer_size",
"=",
"null",
",",
"$",
"socket_read_buffer_size",
"=",
"null",
",",
"$",
"source_overlap_size",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"content_buffer_size",
"!==",
"null",
")",
"$",
"this",
"->",
"content_buffer_size",
"=",
"$",
"content_buffer_size",
";",
"if",
"(",
"$",
"chunk_buffer_size",
"!==",
"null",
")",
"$",
"this",
"->",
"chunk_buffer_size",
"=",
"$",
"chunk_buffer_size",
";",
"if",
"(",
"$",
"socket_read_buffer_size",
"!==",
"null",
")",
"$",
"this",
"->",
"socket_read_buffer_size",
"=",
"$",
"socket_read_buffer_size",
";",
"if",
"(",
"$",
"source_overlap_size",
"!==",
"null",
")",
"$",
"this",
"->",
"source_overlap_size",
"=",
"$",
"source_overlap_size",
";",
"if",
"(",
"$",
"this",
"->",
"content_buffer_size",
"<",
"$",
"this",
"->",
"chunk_buffer_size",
"||",
"$",
"this",
"->",
"chunk_buffer_size",
"<",
"$",
"this",
"->",
"socket_read_buffer_size",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Implausible buffer-size-settings assigned to \"",
".",
"getClass",
"(",
"$",
"this",
")",
".",
"\".\"",
")",
";",
"}",
"}"
] |
Adjusts some internal buffer-sizes of the HTTPRequest-class
@param int $content_buffer_size content_buffer_size in bytes or NULL if not to change this value.
@param int $chunk_buffer_size chunk_buffer_size in bytes or NULL if not to change this value.
@param int $socket_read_buffer_size socket_read_buffer_sizein bytes or NULL if not to change this value.
@param int $source_overlap_size source_overlap_size in bytes or NULL if not to change this value.
|
[
"Adjusts",
"some",
"internal",
"buffer",
"-",
"sizes",
"of",
"the",
"HTTPRequest",
"-",
"class"
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawlerHTTPRequest.class.php#L1275-L1293
|
223,272
|
kontoulis/rabbitmq-laravel
|
src/Message/Message.php
|
Message.fromAMQPMessage
|
public static function fromAMQPMessage(AMQPMessage $AMQPMessage)
{
$msg = new Message(
json_decode($AMQPMessage->body, true),
$AMQPMessage->delivery_info['routing_key'],
$AMQPMessage->get_properties()
);
$msg->setAMQPMessage($AMQPMessage);
return $msg;
}
|
php
|
public static function fromAMQPMessage(AMQPMessage $AMQPMessage)
{
$msg = new Message(
json_decode($AMQPMessage->body, true),
$AMQPMessage->delivery_info['routing_key'],
$AMQPMessage->get_properties()
);
$msg->setAMQPMessage($AMQPMessage);
return $msg;
}
|
[
"public",
"static",
"function",
"fromAMQPMessage",
"(",
"AMQPMessage",
"$",
"AMQPMessage",
")",
"{",
"$",
"msg",
"=",
"new",
"Message",
"(",
"json_decode",
"(",
"$",
"AMQPMessage",
"->",
"body",
",",
"true",
")",
",",
"$",
"AMQPMessage",
"->",
"delivery_info",
"[",
"'routing_key'",
"]",
",",
"$",
"AMQPMessage",
"->",
"get_properties",
"(",
")",
")",
";",
"$",
"msg",
"->",
"setAMQPMessage",
"(",
"$",
"AMQPMessage",
")",
";",
"return",
"$",
"msg",
";",
"}"
] |
Creates a message given the AMQP message and the queue it was received
from
@param AMQPMessage $AMQPMessage
@return Message
@internal param AMQPMessage $msg
|
[
"Creates",
"a",
"message",
"given",
"the",
"AMQP",
"message",
"and",
"the",
"queue",
"it",
"was",
"received",
"from"
] |
f677b3b447be63dd14732309193d26c3b841c5fc
|
https://github.com/kontoulis/rabbitmq-laravel/blob/f677b3b447be63dd14732309193d26c3b841c5fc/src/Message/Message.php#L122-L132
|
223,273
|
kontoulis/rabbitmq-laravel
|
src/Message/Message.php
|
Message.sendNack
|
public function sendNack($requeue = false)
{
$this->amqpMessage->delivery_info['channel']->basic_nack(
$this->getDeliveryTag(),
true, // ignore all unacknowledged messages
$requeue // reschedule the message
);
}
|
php
|
public function sendNack($requeue = false)
{
$this->amqpMessage->delivery_info['channel']->basic_nack(
$this->getDeliveryTag(),
true, // ignore all unacknowledged messages
$requeue // reschedule the message
);
}
|
[
"public",
"function",
"sendNack",
"(",
"$",
"requeue",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"amqpMessage",
"->",
"delivery_info",
"[",
"'channel'",
"]",
"->",
"basic_nack",
"(",
"$",
"this",
"->",
"getDeliveryTag",
"(",
")",
",",
"true",
",",
"// ignore all unacknowledged messages",
"$",
"requeue",
"// reschedule the message",
")",
";",
"}"
] |
Sends a negative acknowledgment
@param bool $requeue Will the message be requeued
|
[
"Sends",
"a",
"negative",
"acknowledgment"
] |
f677b3b447be63dd14732309193d26c3b841c5fc
|
https://github.com/kontoulis/rabbitmq-laravel/blob/f677b3b447be63dd14732309193d26c3b841c5fc/src/Message/Message.php#L176-L183
|
223,274
|
kontoulis/rabbitmq-laravel
|
src/Message/Message.php
|
Message.republish
|
public function republish()
{
$this->amqpMessage->delivery_info['channel']->basic_publish(
$this->getAMQPMessage(),
$this->amqpMessage->delivery_info['exchange'],
$this->routingKey
);
}
|
php
|
public function republish()
{
$this->amqpMessage->delivery_info['channel']->basic_publish(
$this->getAMQPMessage(),
$this->amqpMessage->delivery_info['exchange'],
$this->routingKey
);
}
|
[
"public",
"function",
"republish",
"(",
")",
"{",
"$",
"this",
"->",
"amqpMessage",
"->",
"delivery_info",
"[",
"'channel'",
"]",
"->",
"basic_publish",
"(",
"$",
"this",
"->",
"getAMQPMessage",
"(",
")",
",",
"$",
"this",
"->",
"amqpMessage",
"->",
"delivery_info",
"[",
"'exchange'",
"]",
",",
"$",
"this",
"->",
"routingKey",
")",
";",
"}"
] |
Re-publishes the message to the queue.
|
[
"Re",
"-",
"publishes",
"the",
"message",
"to",
"the",
"queue",
"."
] |
f677b3b447be63dd14732309193d26c3b841c5fc
|
https://github.com/kontoulis/rabbitmq-laravel/blob/f677b3b447be63dd14732309193d26c3b841c5fc/src/Message/Message.php#L190-L197
|
223,275
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php
|
LimitSubqueryWalker.validate
|
private function validate(SelectStatement $AST)
{
// Prevent LimitSubqueryWalker from being used with queries that include
// a limit, a fetched to-many join, and an order by condition that
// references a column from the fetch joined table.
$queryComponents = $this->getQueryComponents();
$query = $this->_getQuery();
$from = $AST->fromClause->identificationVariableDeclarations;
$fromRoot = reset($from);
if ($query instanceof Query
&& $query->getMaxResults()
&& $AST->orderByClause
&& count($fromRoot->joins)) {
// Check each orderby item.
// TODO: check complex orderby items too...
foreach ($AST->orderByClause->orderByItems as $orderByItem) {
$expression = $orderByItem->expression;
if ($orderByItem->expression instanceof PathExpression
&& isset($queryComponents[$expression->identificationVariable])) {
$queryComponent = $queryComponents[$expression->identificationVariable];
if (isset($queryComponent['parent'])
&& $queryComponent['relation']['type'] & ClassMetadataInfo::TO_MANY) {
throw new \RuntimeException("Cannot select distinct identifiers from query with LIMIT and ORDER BY on a column from a fetch joined to-many association. Use output walkers.");
}
}
}
}
}
|
php
|
private function validate(SelectStatement $AST)
{
// Prevent LimitSubqueryWalker from being used with queries that include
// a limit, a fetched to-many join, and an order by condition that
// references a column from the fetch joined table.
$queryComponents = $this->getQueryComponents();
$query = $this->_getQuery();
$from = $AST->fromClause->identificationVariableDeclarations;
$fromRoot = reset($from);
if ($query instanceof Query
&& $query->getMaxResults()
&& $AST->orderByClause
&& count($fromRoot->joins)) {
// Check each orderby item.
// TODO: check complex orderby items too...
foreach ($AST->orderByClause->orderByItems as $orderByItem) {
$expression = $orderByItem->expression;
if ($orderByItem->expression instanceof PathExpression
&& isset($queryComponents[$expression->identificationVariable])) {
$queryComponent = $queryComponents[$expression->identificationVariable];
if (isset($queryComponent['parent'])
&& $queryComponent['relation']['type'] & ClassMetadataInfo::TO_MANY) {
throw new \RuntimeException("Cannot select distinct identifiers from query with LIMIT and ORDER BY on a column from a fetch joined to-many association. Use output walkers.");
}
}
}
}
}
|
[
"private",
"function",
"validate",
"(",
"SelectStatement",
"$",
"AST",
")",
"{",
"// Prevent LimitSubqueryWalker from being used with queries that include",
"// a limit, a fetched to-many join, and an order by condition that",
"// references a column from the fetch joined table.",
"$",
"queryComponents",
"=",
"$",
"this",
"->",
"getQueryComponents",
"(",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"_getQuery",
"(",
")",
";",
"$",
"from",
"=",
"$",
"AST",
"->",
"fromClause",
"->",
"identificationVariableDeclarations",
";",
"$",
"fromRoot",
"=",
"reset",
"(",
"$",
"from",
")",
";",
"if",
"(",
"$",
"query",
"instanceof",
"Query",
"&&",
"$",
"query",
"->",
"getMaxResults",
"(",
")",
"&&",
"$",
"AST",
"->",
"orderByClause",
"&&",
"count",
"(",
"$",
"fromRoot",
"->",
"joins",
")",
")",
"{",
"// Check each orderby item.",
"// TODO: check complex orderby items too...",
"foreach",
"(",
"$",
"AST",
"->",
"orderByClause",
"->",
"orderByItems",
"as",
"$",
"orderByItem",
")",
"{",
"$",
"expression",
"=",
"$",
"orderByItem",
"->",
"expression",
";",
"if",
"(",
"$",
"orderByItem",
"->",
"expression",
"instanceof",
"PathExpression",
"&&",
"isset",
"(",
"$",
"queryComponents",
"[",
"$",
"expression",
"->",
"identificationVariable",
"]",
")",
")",
"{",
"$",
"queryComponent",
"=",
"$",
"queryComponents",
"[",
"$",
"expression",
"->",
"identificationVariable",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"queryComponent",
"[",
"'parent'",
"]",
")",
"&&",
"$",
"queryComponent",
"[",
"'relation'",
"]",
"[",
"'type'",
"]",
"&",
"ClassMetadataInfo",
"::",
"TO_MANY",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Cannot select distinct identifiers from query with LIMIT and ORDER BY on a column from a fetch joined to-many association. Use output walkers.\"",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Validate the AST to ensure that this walker is able to properly manipulate it.
@param SelectStatement $AST
|
[
"Validate",
"the",
"AST",
"to",
"ensure",
"that",
"this",
"walker",
"is",
"able",
"to",
"properly",
"manipulate",
"it",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php#L126-L154
|
223,276
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php
|
FieldBuilder.setSequenceGenerator
|
public function setSequenceGenerator($sequenceName, $allocationSize = 1, $initialValue = 1)
{
$this->sequenceDef = array(
'sequenceName' => $sequenceName,
'allocationSize' => $allocationSize,
'initialValue' => $initialValue,
);
return $this;
}
|
php
|
public function setSequenceGenerator($sequenceName, $allocationSize = 1, $initialValue = 1)
{
$this->sequenceDef = array(
'sequenceName' => $sequenceName,
'allocationSize' => $allocationSize,
'initialValue' => $initialValue,
);
return $this;
}
|
[
"public",
"function",
"setSequenceGenerator",
"(",
"$",
"sequenceName",
",",
"$",
"allocationSize",
"=",
"1",
",",
"$",
"initialValue",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"sequenceDef",
"=",
"array",
"(",
"'sequenceName'",
"=>",
"$",
"sequenceName",
",",
"'allocationSize'",
"=>",
"$",
"allocationSize",
",",
"'initialValue'",
"=>",
"$",
"initialValue",
",",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets Sequence Generator.
@param string $sequenceName
@param int $allocationSize
@param int $initialValue
@return FieldBuilder
|
[
"Sets",
"Sequence",
"Generator",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php#L212-L220
|
223,277
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php
|
FieldBuilder.build
|
public function build()
{
$cm = $this->builder->getClassMetadata();
if ($this->generatedValue) {
$cm->setIdGeneratorType(constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_' . $this->generatedValue));
}
if ($this->version) {
$cm->setVersionMapping($this->mapping);
}
$cm->mapField($this->mapping);
if ($this->sequenceDef) {
$cm->setSequenceGeneratorDefinition($this->sequenceDef);
}
return $this->builder;
}
|
php
|
public function build()
{
$cm = $this->builder->getClassMetadata();
if ($this->generatedValue) {
$cm->setIdGeneratorType(constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_' . $this->generatedValue));
}
if ($this->version) {
$cm->setVersionMapping($this->mapping);
}
$cm->mapField($this->mapping);
if ($this->sequenceDef) {
$cm->setSequenceGeneratorDefinition($this->sequenceDef);
}
return $this->builder;
}
|
[
"public",
"function",
"build",
"(",
")",
"{",
"$",
"cm",
"=",
"$",
"this",
"->",
"builder",
"->",
"getClassMetadata",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"generatedValue",
")",
"{",
"$",
"cm",
"->",
"setIdGeneratorType",
"(",
"constant",
"(",
"'Doctrine\\ORM\\Mapping\\ClassMetadata::GENERATOR_TYPE_'",
".",
"$",
"this",
"->",
"generatedValue",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"version",
")",
"{",
"$",
"cm",
"->",
"setVersionMapping",
"(",
"$",
"this",
"->",
"mapping",
")",
";",
"}",
"$",
"cm",
"->",
"mapField",
"(",
"$",
"this",
"->",
"mapping",
")",
";",
"if",
"(",
"$",
"this",
"->",
"sequenceDef",
")",
"{",
"$",
"cm",
"->",
"setSequenceGeneratorDefinition",
"(",
"$",
"this",
"->",
"sequenceDef",
")",
";",
"}",
"return",
"$",
"this",
"->",
"builder",
";",
"}"
] |
Finalizes this field and attach it to the ClassMetadata.
Without this call a FieldBuilder has no effect on the ClassMetadata.
@return ClassMetadataBuilder
|
[
"Finalizes",
"this",
"field",
"and",
"attach",
"it",
"to",
"the",
"ClassMetadata",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php#L242-L256
|
223,278
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php
|
YamlDriver.joinColumnToArray
|
private function joinColumnToArray($joinColumnElement)
{
$joinColumn = array();
if (isset($joinColumnElement['referencedColumnName'])) {
$joinColumn['referencedColumnName'] = (string) $joinColumnElement['referencedColumnName'];
}
if (isset($joinColumnElement['name'])) {
$joinColumn['name'] = (string) $joinColumnElement['name'];
}
if (isset($joinColumnElement['fieldName'])) {
$joinColumn['fieldName'] = (string) $joinColumnElement['fieldName'];
}
if (isset($joinColumnElement['unique'])) {
$joinColumn['unique'] = (bool) $joinColumnElement['unique'];
}
if (isset($joinColumnElement['nullable'])) {
$joinColumn['nullable'] = (bool) $joinColumnElement['nullable'];
}
if (isset($joinColumnElement['onDelete'])) {
$joinColumn['onDelete'] = $joinColumnElement['onDelete'];
}
if (isset($joinColumnElement['columnDefinition'])) {
$joinColumn['columnDefinition'] = $joinColumnElement['columnDefinition'];
}
return $joinColumn;
}
|
php
|
private function joinColumnToArray($joinColumnElement)
{
$joinColumn = array();
if (isset($joinColumnElement['referencedColumnName'])) {
$joinColumn['referencedColumnName'] = (string) $joinColumnElement['referencedColumnName'];
}
if (isset($joinColumnElement['name'])) {
$joinColumn['name'] = (string) $joinColumnElement['name'];
}
if (isset($joinColumnElement['fieldName'])) {
$joinColumn['fieldName'] = (string) $joinColumnElement['fieldName'];
}
if (isset($joinColumnElement['unique'])) {
$joinColumn['unique'] = (bool) $joinColumnElement['unique'];
}
if (isset($joinColumnElement['nullable'])) {
$joinColumn['nullable'] = (bool) $joinColumnElement['nullable'];
}
if (isset($joinColumnElement['onDelete'])) {
$joinColumn['onDelete'] = $joinColumnElement['onDelete'];
}
if (isset($joinColumnElement['columnDefinition'])) {
$joinColumn['columnDefinition'] = $joinColumnElement['columnDefinition'];
}
return $joinColumn;
}
|
[
"private",
"function",
"joinColumnToArray",
"(",
"$",
"joinColumnElement",
")",
"{",
"$",
"joinColumn",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"joinColumnElement",
"[",
"'referencedColumnName'",
"]",
")",
")",
"{",
"$",
"joinColumn",
"[",
"'referencedColumnName'",
"]",
"=",
"(",
"string",
")",
"$",
"joinColumnElement",
"[",
"'referencedColumnName'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"joinColumnElement",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"joinColumn",
"[",
"'name'",
"]",
"=",
"(",
"string",
")",
"$",
"joinColumnElement",
"[",
"'name'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"joinColumnElement",
"[",
"'fieldName'",
"]",
")",
")",
"{",
"$",
"joinColumn",
"[",
"'fieldName'",
"]",
"=",
"(",
"string",
")",
"$",
"joinColumnElement",
"[",
"'fieldName'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"joinColumnElement",
"[",
"'unique'",
"]",
")",
")",
"{",
"$",
"joinColumn",
"[",
"'unique'",
"]",
"=",
"(",
"bool",
")",
"$",
"joinColumnElement",
"[",
"'unique'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"joinColumnElement",
"[",
"'nullable'",
"]",
")",
")",
"{",
"$",
"joinColumn",
"[",
"'nullable'",
"]",
"=",
"(",
"bool",
")",
"$",
"joinColumnElement",
"[",
"'nullable'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"joinColumnElement",
"[",
"'onDelete'",
"]",
")",
")",
"{",
"$",
"joinColumn",
"[",
"'onDelete'",
"]",
"=",
"$",
"joinColumnElement",
"[",
"'onDelete'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"joinColumnElement",
"[",
"'columnDefinition'",
"]",
")",
")",
"{",
"$",
"joinColumn",
"[",
"'columnDefinition'",
"]",
"=",
"$",
"joinColumnElement",
"[",
"'columnDefinition'",
"]",
";",
"}",
"return",
"$",
"joinColumn",
";",
"}"
] |
Constructs a joinColumn mapping array based on the information
found in the given join column element.
@param array $joinColumnElement The array join column element.
@return array The mapping array.
|
[
"Constructs",
"a",
"joinColumn",
"mapping",
"array",
"based",
"on",
"the",
"information",
"found",
"in",
"the",
"given",
"join",
"column",
"element",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php#L663-L695
|
223,279
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php
|
YamlDriver.columnToArray
|
private function columnToArray($fieldName, $column)
{
$mapping = array(
'fieldName' => $fieldName
);
if (isset($column['type'])) {
$params = explode('(', $column['type']);
$column['type'] = $params[0];
$mapping['type'] = $column['type'];
if (isset($params[1])) {
$column['length'] = (integer) substr($params[1], 0, strlen($params[1]) - 1);
}
}
if (isset($column['column'])) {
$mapping['columnName'] = $column['column'];
}
if (isset($column['length'])) {
$mapping['length'] = $column['length'];
}
if (isset($column['precision'])) {
$mapping['precision'] = $column['precision'];
}
if (isset($column['scale'])) {
$mapping['scale'] = $column['scale'];
}
if (isset($column['unique'])) {
$mapping['unique'] = (bool)$column['unique'];
}
if (isset($column['options'])) {
$mapping['options'] = $column['options'];
}
if (isset($column['nullable'])) {
$mapping['nullable'] = $column['nullable'];
}
if (isset($column['version']) && $column['version']) {
$mapping['version'] = $column['version'];
}
if (isset($column['columnDefinition'])) {
$mapping['columnDefinition'] = $column['columnDefinition'];
}
return $mapping;
}
|
php
|
private function columnToArray($fieldName, $column)
{
$mapping = array(
'fieldName' => $fieldName
);
if (isset($column['type'])) {
$params = explode('(', $column['type']);
$column['type'] = $params[0];
$mapping['type'] = $column['type'];
if (isset($params[1])) {
$column['length'] = (integer) substr($params[1], 0, strlen($params[1]) - 1);
}
}
if (isset($column['column'])) {
$mapping['columnName'] = $column['column'];
}
if (isset($column['length'])) {
$mapping['length'] = $column['length'];
}
if (isset($column['precision'])) {
$mapping['precision'] = $column['precision'];
}
if (isset($column['scale'])) {
$mapping['scale'] = $column['scale'];
}
if (isset($column['unique'])) {
$mapping['unique'] = (bool)$column['unique'];
}
if (isset($column['options'])) {
$mapping['options'] = $column['options'];
}
if (isset($column['nullable'])) {
$mapping['nullable'] = $column['nullable'];
}
if (isset($column['version']) && $column['version']) {
$mapping['version'] = $column['version'];
}
if (isset($column['columnDefinition'])) {
$mapping['columnDefinition'] = $column['columnDefinition'];
}
return $mapping;
}
|
[
"private",
"function",
"columnToArray",
"(",
"$",
"fieldName",
",",
"$",
"column",
")",
"{",
"$",
"mapping",
"=",
"array",
"(",
"'fieldName'",
"=>",
"$",
"fieldName",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"column",
"[",
"'type'",
"]",
")",
")",
"{",
"$",
"params",
"=",
"explode",
"(",
"'('",
",",
"$",
"column",
"[",
"'type'",
"]",
")",
";",
"$",
"column",
"[",
"'type'",
"]",
"=",
"$",
"params",
"[",
"0",
"]",
";",
"$",
"mapping",
"[",
"'type'",
"]",
"=",
"$",
"column",
"[",
"'type'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"1",
"]",
")",
")",
"{",
"$",
"column",
"[",
"'length'",
"]",
"=",
"(",
"integer",
")",
"substr",
"(",
"$",
"params",
"[",
"1",
"]",
",",
"0",
",",
"strlen",
"(",
"$",
"params",
"[",
"1",
"]",
")",
"-",
"1",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"column",
"[",
"'column'",
"]",
")",
")",
"{",
"$",
"mapping",
"[",
"'columnName'",
"]",
"=",
"$",
"column",
"[",
"'column'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"column",
"[",
"'length'",
"]",
")",
")",
"{",
"$",
"mapping",
"[",
"'length'",
"]",
"=",
"$",
"column",
"[",
"'length'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"column",
"[",
"'precision'",
"]",
")",
")",
"{",
"$",
"mapping",
"[",
"'precision'",
"]",
"=",
"$",
"column",
"[",
"'precision'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"column",
"[",
"'scale'",
"]",
")",
")",
"{",
"$",
"mapping",
"[",
"'scale'",
"]",
"=",
"$",
"column",
"[",
"'scale'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"column",
"[",
"'unique'",
"]",
")",
")",
"{",
"$",
"mapping",
"[",
"'unique'",
"]",
"=",
"(",
"bool",
")",
"$",
"column",
"[",
"'unique'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"column",
"[",
"'options'",
"]",
")",
")",
"{",
"$",
"mapping",
"[",
"'options'",
"]",
"=",
"$",
"column",
"[",
"'options'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"column",
"[",
"'nullable'",
"]",
")",
")",
"{",
"$",
"mapping",
"[",
"'nullable'",
"]",
"=",
"$",
"column",
"[",
"'nullable'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"column",
"[",
"'version'",
"]",
")",
"&&",
"$",
"column",
"[",
"'version'",
"]",
")",
"{",
"$",
"mapping",
"[",
"'version'",
"]",
"=",
"$",
"column",
"[",
"'version'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"column",
"[",
"'columnDefinition'",
"]",
")",
")",
"{",
"$",
"mapping",
"[",
"'columnDefinition'",
"]",
"=",
"$",
"column",
"[",
"'columnDefinition'",
"]",
";",
"}",
"return",
"$",
"mapping",
";",
"}"
] |
Parses the given column as array.
@param string $fieldName
@param array $column
@return array
|
[
"Parses",
"the",
"given",
"column",
"as",
"array",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php#L705-L758
|
223,280
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php
|
AssociationBuilder.addJoinColumn
|
public function addJoinColumn($columnName, $referencedColumnName, $nullable = true, $unique = false, $onDelete = null, $columnDef = null)
{
$this->joinColumns[] = array(
'name' => $columnName,
'referencedColumnName' => $referencedColumnName,
'nullable' => $nullable,
'unique' => $unique,
'onDelete' => $onDelete,
'columnDefinition' => $columnDef,
);
return $this;
}
|
php
|
public function addJoinColumn($columnName, $referencedColumnName, $nullable = true, $unique = false, $onDelete = null, $columnDef = null)
{
$this->joinColumns[] = array(
'name' => $columnName,
'referencedColumnName' => $referencedColumnName,
'nullable' => $nullable,
'unique' => $unique,
'onDelete' => $onDelete,
'columnDefinition' => $columnDef,
);
return $this;
}
|
[
"public",
"function",
"addJoinColumn",
"(",
"$",
"columnName",
",",
"$",
"referencedColumnName",
",",
"$",
"nullable",
"=",
"true",
",",
"$",
"unique",
"=",
"false",
",",
"$",
"onDelete",
"=",
"null",
",",
"$",
"columnDef",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"joinColumns",
"[",
"]",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"columnName",
",",
"'referencedColumnName'",
"=>",
"$",
"referencedColumnName",
",",
"'nullable'",
"=>",
"$",
"nullable",
",",
"'unique'",
"=>",
"$",
"unique",
",",
"'onDelete'",
"=>",
"$",
"onDelete",
",",
"'columnDefinition'",
"=>",
"$",
"columnDef",
",",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add Join Columns.
@param string $columnName
@param string $referencedColumnName
@param bool $nullable
@param bool $unique
@param string|null $onDelete
@param string|null $columnDef
@return AssociationBuilder
|
[
"Add",
"Join",
"Columns",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php#L173-L184
|
223,281
|
drmonkeyninja/cakephp-font-awesome
|
src/View/Helper/FaHelper.php
|
FaHelper.link
|
public function link($icon, $title, $url = null, $options = [], $confirmMessage = false)
{
$escapeTitle = true;
if (isset($options['escapeTitle'])) {
$escapeTitle = $options['escapeTitle'];
unset($options['escapeTitle']);
} elseif (isset($options['escape'])) {
$escapeTitle = $options['escape'];
}
if ($escapeTitle === true) {
$title = h($title);
} elseif (is_string($escapeTitle)) {
$title = htmlentities($title, ENT_QUOTES, $escapeTitle);
}
// Append/Prepend the Font Awesome icon.
if (empty($title)) {
$title = '<i class="fa fa-' . $icon . '"></i>';
} elseif (empty($options['before'])) {
$title .= ' <i class="fa fa-' . $icon . '" aria-hidden="true"></i>';
} else {
$title = '<i class="fa fa-' . $icon . '" aria-hidden="true"></i> ' . $title;
}
unset($options['before']);
$options['escape'] = false;
return $this->Html->link($title, $url, $options, $confirmMessage);
}
|
php
|
public function link($icon, $title, $url = null, $options = [], $confirmMessage = false)
{
$escapeTitle = true;
if (isset($options['escapeTitle'])) {
$escapeTitle = $options['escapeTitle'];
unset($options['escapeTitle']);
} elseif (isset($options['escape'])) {
$escapeTitle = $options['escape'];
}
if ($escapeTitle === true) {
$title = h($title);
} elseif (is_string($escapeTitle)) {
$title = htmlentities($title, ENT_QUOTES, $escapeTitle);
}
// Append/Prepend the Font Awesome icon.
if (empty($title)) {
$title = '<i class="fa fa-' . $icon . '"></i>';
} elseif (empty($options['before'])) {
$title .= ' <i class="fa fa-' . $icon . '" aria-hidden="true"></i>';
} else {
$title = '<i class="fa fa-' . $icon . '" aria-hidden="true"></i> ' . $title;
}
unset($options['before']);
$options['escape'] = false;
return $this->Html->link($title, $url, $options, $confirmMessage);
}
|
[
"public",
"function",
"link",
"(",
"$",
"icon",
",",
"$",
"title",
",",
"$",
"url",
"=",
"null",
",",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"confirmMessage",
"=",
"false",
")",
"{",
"$",
"escapeTitle",
"=",
"true",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'escapeTitle'",
"]",
")",
")",
"{",
"$",
"escapeTitle",
"=",
"$",
"options",
"[",
"'escapeTitle'",
"]",
";",
"unset",
"(",
"$",
"options",
"[",
"'escapeTitle'",
"]",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"options",
"[",
"'escape'",
"]",
")",
")",
"{",
"$",
"escapeTitle",
"=",
"$",
"options",
"[",
"'escape'",
"]",
";",
"}",
"if",
"(",
"$",
"escapeTitle",
"===",
"true",
")",
"{",
"$",
"title",
"=",
"h",
"(",
"$",
"title",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"escapeTitle",
")",
")",
"{",
"$",
"title",
"=",
"htmlentities",
"(",
"$",
"title",
",",
"ENT_QUOTES",
",",
"$",
"escapeTitle",
")",
";",
"}",
"// Append/Prepend the Font Awesome icon.",
"if",
"(",
"empty",
"(",
"$",
"title",
")",
")",
"{",
"$",
"title",
"=",
"'<i class=\"fa fa-'",
".",
"$",
"icon",
".",
"'\"></i>'",
";",
"}",
"elseif",
"(",
"empty",
"(",
"$",
"options",
"[",
"'before'",
"]",
")",
")",
"{",
"$",
"title",
".=",
"' <i class=\"fa fa-'",
".",
"$",
"icon",
".",
"'\" aria-hidden=\"true\"></i>'",
";",
"}",
"else",
"{",
"$",
"title",
"=",
"'<i class=\"fa fa-'",
".",
"$",
"icon",
".",
"'\" aria-hidden=\"true\"></i> '",
".",
"$",
"title",
";",
"}",
"unset",
"(",
"$",
"options",
"[",
"'before'",
"]",
")",
";",
"$",
"options",
"[",
"'escape'",
"]",
"=",
"false",
";",
"return",
"$",
"this",
"->",
"Html",
"->",
"link",
"(",
"$",
"title",
",",
"$",
"url",
",",
"$",
"options",
",",
"$",
"confirmMessage",
")",
";",
"}"
] |
Create link containing a Font Awesome icon.
@param string $icon Font Awesome icon (excluding the fa- prefix)
@param string $title Link text
@param string|array $url Cake-relative URL or array of URL parameters, or external URL (starts with http://)
@param array $options Array of options and HTML attributes.
@param string $confirmMessage JavaScript confirmation message.
@return string An `<a />` element.
|
[
"Create",
"link",
"containing",
"a",
"Font",
"Awesome",
"icon",
"."
] |
e35e0b785d1dcb9e3389c8e9f17ce4855d79b1a5
|
https://github.com/drmonkeyninja/cakephp-font-awesome/blob/e35e0b785d1dcb9e3389c8e9f17ce4855d79b1a5/src/View/Helper/FaHelper.php#L22-L51
|
223,282
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Tools/EntityGenerator.php
|
EntityGenerator.generate
|
public function generate(array $metadatas, $outputDirectory)
{
foreach ($metadatas as $metadata) {
$this->writeEntityClass($metadata, $outputDirectory);
}
}
|
php
|
public function generate(array $metadatas, $outputDirectory)
{
foreach ($metadatas as $metadata) {
$this->writeEntityClass($metadata, $outputDirectory);
}
}
|
[
"public",
"function",
"generate",
"(",
"array",
"$",
"metadatas",
",",
"$",
"outputDirectory",
")",
"{",
"foreach",
"(",
"$",
"metadatas",
"as",
"$",
"metadata",
")",
"{",
"$",
"this",
"->",
"writeEntityClass",
"(",
"$",
"metadata",
",",
"$",
"outputDirectory",
")",
";",
"}",
"}"
] |
Generates and writes entity classes for the given array of ClassMetadataInfo instances.
@param array $metadatas
@param string $outputDirectory
@return void
|
[
"Generates",
"and",
"writes",
"entity",
"classes",
"for",
"the",
"given",
"array",
"of",
"ClassMetadataInfo",
"instances",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Tools/EntityGenerator.php#L346-L351
|
223,283
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Tools/EntityGenerator.php
|
EntityGenerator.writeEntityClass
|
public function writeEntityClass(ClassMetadataInfo $metadata, $outputDirectory)
{
$path = $outputDirectory . '/' . str_replace('\\', DIRECTORY_SEPARATOR, $metadata->name) . $this->extension;
$dir = dirname($path);
if ( ! is_dir($dir)) {
mkdir($dir, 0775, true);
}
$this->isNew = !file_exists($path) || (file_exists($path) && $this->regenerateEntityIfExists);
if ( ! $this->isNew) {
$this->parseTokensInEntityFile(file_get_contents($path));
} else {
$this->staticReflection[$metadata->name] = array('properties' => array(), 'methods' => array());
}
if ($this->backupExisting && file_exists($path)) {
$backupPath = dirname($path) . DIRECTORY_SEPARATOR . basename($path) . "~";
if (!copy($path, $backupPath)) {
throw new \RuntimeException("Attempt to backup overwritten entity file but copy operation failed.");
}
}
// If entity doesn't exist or we're re-generating the entities entirely
if ($this->isNew) {
file_put_contents($path, $this->generateEntityClass($metadata));
// If entity exists and we're allowed to update the entity class
} elseif ( ! $this->isNew && $this->updateEntityIfExists) {
file_put_contents($path, $this->generateUpdatedEntityClass($metadata, $path));
}
chmod($path, 0664);
}
|
php
|
public function writeEntityClass(ClassMetadataInfo $metadata, $outputDirectory)
{
$path = $outputDirectory . '/' . str_replace('\\', DIRECTORY_SEPARATOR, $metadata->name) . $this->extension;
$dir = dirname($path);
if ( ! is_dir($dir)) {
mkdir($dir, 0775, true);
}
$this->isNew = !file_exists($path) || (file_exists($path) && $this->regenerateEntityIfExists);
if ( ! $this->isNew) {
$this->parseTokensInEntityFile(file_get_contents($path));
} else {
$this->staticReflection[$metadata->name] = array('properties' => array(), 'methods' => array());
}
if ($this->backupExisting && file_exists($path)) {
$backupPath = dirname($path) . DIRECTORY_SEPARATOR . basename($path) . "~";
if (!copy($path, $backupPath)) {
throw new \RuntimeException("Attempt to backup overwritten entity file but copy operation failed.");
}
}
// If entity doesn't exist or we're re-generating the entities entirely
if ($this->isNew) {
file_put_contents($path, $this->generateEntityClass($metadata));
// If entity exists and we're allowed to update the entity class
} elseif ( ! $this->isNew && $this->updateEntityIfExists) {
file_put_contents($path, $this->generateUpdatedEntityClass($metadata, $path));
}
chmod($path, 0664);
}
|
[
"public",
"function",
"writeEntityClass",
"(",
"ClassMetadataInfo",
"$",
"metadata",
",",
"$",
"outputDirectory",
")",
"{",
"$",
"path",
"=",
"$",
"outputDirectory",
".",
"'/'",
".",
"str_replace",
"(",
"'\\\\'",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"metadata",
"->",
"name",
")",
".",
"$",
"this",
"->",
"extension",
";",
"$",
"dir",
"=",
"dirname",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"mkdir",
"(",
"$",
"dir",
",",
"0775",
",",
"true",
")",
";",
"}",
"$",
"this",
"->",
"isNew",
"=",
"!",
"file_exists",
"(",
"$",
"path",
")",
"||",
"(",
"file_exists",
"(",
"$",
"path",
")",
"&&",
"$",
"this",
"->",
"regenerateEntityIfExists",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isNew",
")",
"{",
"$",
"this",
"->",
"parseTokensInEntityFile",
"(",
"file_get_contents",
"(",
"$",
"path",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"staticReflection",
"[",
"$",
"metadata",
"->",
"name",
"]",
"=",
"array",
"(",
"'properties'",
"=>",
"array",
"(",
")",
",",
"'methods'",
"=>",
"array",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"backupExisting",
"&&",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"$",
"backupPath",
"=",
"dirname",
"(",
"$",
"path",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"basename",
"(",
"$",
"path",
")",
".",
"\"~\"",
";",
"if",
"(",
"!",
"copy",
"(",
"$",
"path",
",",
"$",
"backupPath",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Attempt to backup overwritten entity file but copy operation failed.\"",
")",
";",
"}",
"}",
"// If entity doesn't exist or we're re-generating the entities entirely",
"if",
"(",
"$",
"this",
"->",
"isNew",
")",
"{",
"file_put_contents",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"generateEntityClass",
"(",
"$",
"metadata",
")",
")",
";",
"// If entity exists and we're allowed to update the entity class",
"}",
"elseif",
"(",
"!",
"$",
"this",
"->",
"isNew",
"&&",
"$",
"this",
"->",
"updateEntityIfExists",
")",
"{",
"file_put_contents",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"generateUpdatedEntityClass",
"(",
"$",
"metadata",
",",
"$",
"path",
")",
")",
";",
"}",
"chmod",
"(",
"$",
"path",
",",
"0664",
")",
";",
"}"
] |
Generates and writes entity class to disk for the given ClassMetadataInfo instance.
@param ClassMetadataInfo $metadata
@param string $outputDirectory
@return void
@throws \RuntimeException
|
[
"Generates",
"and",
"writes",
"entity",
"class",
"to",
"disk",
"for",
"the",
"given",
"ClassMetadataInfo",
"instance",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Tools/EntityGenerator.php#L363-L395
|
223,284
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Tools/EntityGenerator.php
|
EntityGenerator.generateEntityClass
|
public function generateEntityClass(ClassMetadataInfo $metadata)
{
$placeHolders = array(
'<namespace>',
'<useStatement>',
'<entityAnnotation>',
'<entityClassName>',
'<entityBody>'
);
$replacements = array(
$this->generateEntityNamespace($metadata),
$this->generateEntityUse(),
$this->generateEntityDocBlock($metadata),
$this->generateEntityClassName($metadata),
$this->generateEntityBody($metadata)
);
$code = str_replace($placeHolders, $replacements, static::$classTemplate) . "\n";
return str_replace('<spaces>', $this->spaces, $code);
}
|
php
|
public function generateEntityClass(ClassMetadataInfo $metadata)
{
$placeHolders = array(
'<namespace>',
'<useStatement>',
'<entityAnnotation>',
'<entityClassName>',
'<entityBody>'
);
$replacements = array(
$this->generateEntityNamespace($metadata),
$this->generateEntityUse(),
$this->generateEntityDocBlock($metadata),
$this->generateEntityClassName($metadata),
$this->generateEntityBody($metadata)
);
$code = str_replace($placeHolders, $replacements, static::$classTemplate) . "\n";
return str_replace('<spaces>', $this->spaces, $code);
}
|
[
"public",
"function",
"generateEntityClass",
"(",
"ClassMetadataInfo",
"$",
"metadata",
")",
"{",
"$",
"placeHolders",
"=",
"array",
"(",
"'<namespace>'",
",",
"'<useStatement>'",
",",
"'<entityAnnotation>'",
",",
"'<entityClassName>'",
",",
"'<entityBody>'",
")",
";",
"$",
"replacements",
"=",
"array",
"(",
"$",
"this",
"->",
"generateEntityNamespace",
"(",
"$",
"metadata",
")",
",",
"$",
"this",
"->",
"generateEntityUse",
"(",
")",
",",
"$",
"this",
"->",
"generateEntityDocBlock",
"(",
"$",
"metadata",
")",
",",
"$",
"this",
"->",
"generateEntityClassName",
"(",
"$",
"metadata",
")",
",",
"$",
"this",
"->",
"generateEntityBody",
"(",
"$",
"metadata",
")",
")",
";",
"$",
"code",
"=",
"str_replace",
"(",
"$",
"placeHolders",
",",
"$",
"replacements",
",",
"static",
"::",
"$",
"classTemplate",
")",
".",
"\"\\n\"",
";",
"return",
"str_replace",
"(",
"'<spaces>'",
",",
"$",
"this",
"->",
"spaces",
",",
"$",
"code",
")",
";",
"}"
] |
Generates a PHP5 Doctrine 2 entity class from the given ClassMetadataInfo instance.
@param ClassMetadataInfo $metadata
@return string
|
[
"Generates",
"a",
"PHP5",
"Doctrine",
"2",
"entity",
"class",
"from",
"the",
"given",
"ClassMetadataInfo",
"instance",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Tools/EntityGenerator.php#L404-L425
|
223,285
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Tools/EntityGenerator.php
|
EntityGenerator.generateUpdatedEntityClass
|
public function generateUpdatedEntityClass(ClassMetadataInfo $metadata, $path)
{
$currentCode = file_get_contents($path);
$body = $this->generateEntityBody($metadata);
$body = str_replace('<spaces>', $this->spaces, $body);
$last = strrpos($currentCode, '}');
return substr($currentCode, 0, $last) . $body . (strlen($body) > 0 ? "\n" : '') . "}\n";
}
|
php
|
public function generateUpdatedEntityClass(ClassMetadataInfo $metadata, $path)
{
$currentCode = file_get_contents($path);
$body = $this->generateEntityBody($metadata);
$body = str_replace('<spaces>', $this->spaces, $body);
$last = strrpos($currentCode, '}');
return substr($currentCode, 0, $last) . $body . (strlen($body) > 0 ? "\n" : '') . "}\n";
}
|
[
"public",
"function",
"generateUpdatedEntityClass",
"(",
"ClassMetadataInfo",
"$",
"metadata",
",",
"$",
"path",
")",
"{",
"$",
"currentCode",
"=",
"file_get_contents",
"(",
"$",
"path",
")",
";",
"$",
"body",
"=",
"$",
"this",
"->",
"generateEntityBody",
"(",
"$",
"metadata",
")",
";",
"$",
"body",
"=",
"str_replace",
"(",
"'<spaces>'",
",",
"$",
"this",
"->",
"spaces",
",",
"$",
"body",
")",
";",
"$",
"last",
"=",
"strrpos",
"(",
"$",
"currentCode",
",",
"'}'",
")",
";",
"return",
"substr",
"(",
"$",
"currentCode",
",",
"0",
",",
"$",
"last",
")",
".",
"$",
"body",
".",
"(",
"strlen",
"(",
"$",
"body",
")",
">",
"0",
"?",
"\"\\n\"",
":",
"''",
")",
".",
"\"}\\n\"",
";",
"}"
] |
Generates the updated code for the given ClassMetadataInfo and entity at path.
@param ClassMetadataInfo $metadata
@param string $path
@return string
|
[
"Generates",
"the",
"updated",
"code",
"for",
"the",
"given",
"ClassMetadataInfo",
"and",
"entity",
"at",
"path",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Tools/EntityGenerator.php#L435-L444
|
223,286
|
mmerian/phpcrawl
|
libs/ProcessCommunication/PHPCrawlerDocumentInfoQueue.class.php
|
PHPCrawlerDocumentInfoQueue.addDocumentInfo
|
public function addDocumentInfo(PHPCrawlerDocumentInfo $DocInfo)
{
// If queue is full -> wait a little
while ($this->getDocumentInfoCount() >= $this->queue_max_size)
{
usleep(500000);
}
$this->createPreparedStatements();
$ser = serialize($DocInfo);
$this->PDO->exec("BEGIN EXCLUSIVE TRANSACTION");
$this->preparedInsertStatement->bindParam(1, $ser, PDO::PARAM_LOB);
$this->preparedInsertStatement->execute();
$this->preparedSelectStatement->closeCursor();
$this->PDO->exec("COMMIT");
}
|
php
|
public function addDocumentInfo(PHPCrawlerDocumentInfo $DocInfo)
{
// If queue is full -> wait a little
while ($this->getDocumentInfoCount() >= $this->queue_max_size)
{
usleep(500000);
}
$this->createPreparedStatements();
$ser = serialize($DocInfo);
$this->PDO->exec("BEGIN EXCLUSIVE TRANSACTION");
$this->preparedInsertStatement->bindParam(1, $ser, PDO::PARAM_LOB);
$this->preparedInsertStatement->execute();
$this->preparedSelectStatement->closeCursor();
$this->PDO->exec("COMMIT");
}
|
[
"public",
"function",
"addDocumentInfo",
"(",
"PHPCrawlerDocumentInfo",
"$",
"DocInfo",
")",
"{",
"// If queue is full -> wait a little\r",
"while",
"(",
"$",
"this",
"->",
"getDocumentInfoCount",
"(",
")",
">=",
"$",
"this",
"->",
"queue_max_size",
")",
"{",
"usleep",
"(",
"500000",
")",
";",
"}",
"$",
"this",
"->",
"createPreparedStatements",
"(",
")",
";",
"$",
"ser",
"=",
"serialize",
"(",
"$",
"DocInfo",
")",
";",
"$",
"this",
"->",
"PDO",
"->",
"exec",
"(",
"\"BEGIN EXCLUSIVE TRANSACTION\"",
")",
";",
"$",
"this",
"->",
"preparedInsertStatement",
"->",
"bindParam",
"(",
"1",
",",
"$",
"ser",
",",
"PDO",
"::",
"PARAM_LOB",
")",
";",
"$",
"this",
"->",
"preparedInsertStatement",
"->",
"execute",
"(",
")",
";",
"$",
"this",
"->",
"preparedSelectStatement",
"->",
"closeCursor",
"(",
")",
";",
"$",
"this",
"->",
"PDO",
"->",
"exec",
"(",
"\"COMMIT\"",
")",
";",
"}"
] |
Adds a PHPCrawlerDocumentInfo-object to the queue
|
[
"Adds",
"a",
"PHPCrawlerDocumentInfo",
"-",
"object",
"to",
"the",
"queue"
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/ProcessCommunication/PHPCrawlerDocumentInfoQueue.class.php#L58-L75
|
223,287
|
mmerian/phpcrawl
|
libs/ProcessCommunication/PHPCrawlerDocumentInfoQueue.class.php
|
PHPCrawlerDocumentInfoQueue.createPreparedStatements
|
protected function createPreparedStatements()
{
if ($this->prepared_statements_created == false)
{
$this->preparedInsertStatement = $this->PDO->prepare("INSERT INTO document_infos (document_info) VALUES (?);");
$this->preparedSelectStatement = $this->PDO->prepare("SELECT * FROM document_infos limit 1;");
$this->prepared_statements_created = true;
}
}
|
php
|
protected function createPreparedStatements()
{
if ($this->prepared_statements_created == false)
{
$this->preparedInsertStatement = $this->PDO->prepare("INSERT INTO document_infos (document_info) VALUES (?);");
$this->preparedSelectStatement = $this->PDO->prepare("SELECT * FROM document_infos limit 1;");
$this->prepared_statements_created = true;
}
}
|
[
"protected",
"function",
"createPreparedStatements",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"prepared_statements_created",
"==",
"false",
")",
"{",
"$",
"this",
"->",
"preparedInsertStatement",
"=",
"$",
"this",
"->",
"PDO",
"->",
"prepare",
"(",
"\"INSERT INTO document_infos (document_info) VALUES (?);\"",
")",
";",
"$",
"this",
"->",
"preparedSelectStatement",
"=",
"$",
"this",
"->",
"PDO",
"->",
"prepare",
"(",
"\"SELECT * FROM document_infos limit 1;\"",
")",
";",
"$",
"this",
"->",
"prepared_statements_created",
"=",
"true",
";",
"}",
"}"
] |
Creates all prepared statemenst
|
[
"Creates",
"all",
"prepared",
"statemenst"
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/ProcessCommunication/PHPCrawlerDocumentInfoQueue.class.php#L105-L114
|
223,288
|
Torann/laravel-asana
|
src/Asana.php
|
Asana.getUsers
|
public function getUsers($opt_fields = null)
{
$url = $opt_fields ? 'users?opt_fields=' . $opt_fields : 'users';
return $this->curl->get($url);
}
|
php
|
public function getUsers($opt_fields = null)
{
$url = $opt_fields ? 'users?opt_fields=' . $opt_fields : 'users';
return $this->curl->get($url);
}
|
[
"public",
"function",
"getUsers",
"(",
"$",
"opt_fields",
"=",
"null",
")",
"{",
"$",
"url",
"=",
"$",
"opt_fields",
"?",
"'users?opt_fields='",
".",
"$",
"opt_fields",
":",
"'users'",
";",
"return",
"$",
"this",
"->",
"curl",
"->",
"get",
"(",
"$",
"url",
")",
";",
"}"
] |
Returns the user records for all users in all workspaces you have access.
@return string|null
|
[
"Returns",
"the",
"user",
"records",
"for",
"all",
"users",
"in",
"all",
"workspaces",
"you",
"have",
"access",
"."
] |
6e669720dbc3e66f19ffb637865eab9d5ae9d299
|
https://github.com/Torann/laravel-asana/blob/6e669720dbc3e66f19ffb637865eab9d5ae9d299/src/Asana.php#L74-L78
|
223,289
|
Torann/laravel-asana
|
src/Asana.php
|
Asana.createTask
|
public function createTask($data)
{
$data = array_merge([
'workspace' => $this->defaultWorkspaceId,
'projects' => $this->defaultProjectId
], $data);
return $this->curl->post('tasks', ['data' => $data]);
}
|
php
|
public function createTask($data)
{
$data = array_merge([
'workspace' => $this->defaultWorkspaceId,
'projects' => $this->defaultProjectId
], $data);
return $this->curl->post('tasks', ['data' => $data]);
}
|
[
"public",
"function",
"createTask",
"(",
"$",
"data",
")",
"{",
"$",
"data",
"=",
"array_merge",
"(",
"[",
"'workspace'",
"=>",
"$",
"this",
"->",
"defaultWorkspaceId",
",",
"'projects'",
"=>",
"$",
"this",
"->",
"defaultProjectId",
"]",
",",
"$",
"data",
")",
";",
"return",
"$",
"this",
"->",
"curl",
"->",
"post",
"(",
"'tasks'",
",",
"[",
"'data'",
"=>",
"$",
"data",
"]",
")",
";",
"}"
] |
Function to create a task.
For assign or remove the task to a project, use the addProjectToTask and removeProjectToTask.
@param array $data
Example:
array(
"workspace" => "1768",
"name" => "Hello World!",
"notes" => "This is a task for testing the Asana API :)",
"assignee" => "176822166183",
"followers" => array(
"37136",
"59083"
)
)
@return object|null
|
[
"Function",
"to",
"create",
"a",
"task",
"."
] |
6e669720dbc3e66f19ffb637865eab9d5ae9d299
|
https://github.com/Torann/laravel-asana/blob/6e669720dbc3e66f19ffb637865eab9d5ae9d299/src/Asana.php#L102-L110
|
223,290
|
Torann/laravel-asana
|
src/Asana.php
|
Asana.addProjectToTask
|
public function addProjectToTask($taskId, $projectId = null)
{
$data = [
'project' => $projectId ?: $this->defaultProjectId
];
return $this->curl->post("tasks/{$taskId}/addProject", ['data' => $data]);
}
|
php
|
public function addProjectToTask($taskId, $projectId = null)
{
$data = [
'project' => $projectId ?: $this->defaultProjectId
];
return $this->curl->post("tasks/{$taskId}/addProject", ['data' => $data]);
}
|
[
"public",
"function",
"addProjectToTask",
"(",
"$",
"taskId",
",",
"$",
"projectId",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"[",
"'project'",
"=>",
"$",
"projectId",
"?",
":",
"$",
"this",
"->",
"defaultProjectId",
"]",
";",
"return",
"$",
"this",
"->",
"curl",
"->",
"post",
"(",
"\"tasks/{$taskId}/addProject\"",
",",
"[",
"'data'",
"=>",
"$",
"data",
"]",
")",
";",
"}"
] |
Adds a project to task. If successful, will
return success and an empty data block.
@param string $taskId
@param string $projectId
@return string|null
|
[
"Adds",
"a",
"project",
"to",
"task",
".",
"If",
"successful",
"will",
"return",
"success",
"and",
"an",
"empty",
"data",
"block",
"."
] |
6e669720dbc3e66f19ffb637865eab9d5ae9d299
|
https://github.com/Torann/laravel-asana/blob/6e669720dbc3e66f19ffb637865eab9d5ae9d299/src/Asana.php#L231-L238
|
223,291
|
Torann/laravel-asana
|
src/Asana.php
|
Asana.getTasksByFilter
|
public function getTasksByFilter($filter = ["assignee" => "", "project" => "", "workspace" => ""])
{
$filter = array_filter(array_merge(["assignee" => "", "project" => "", "workspace" => ""], $filter));
$url = '?' . join('&', array_map(function ($k, $v) {
return "{$k}={$v}";
}, array_keys($filter), $filter));
return $this->curl->get("tasks{$url}");
}
|
php
|
public function getTasksByFilter($filter = ["assignee" => "", "project" => "", "workspace" => ""])
{
$filter = array_filter(array_merge(["assignee" => "", "project" => "", "workspace" => ""], $filter));
$url = '?' . join('&', array_map(function ($k, $v) {
return "{$k}={$v}";
}, array_keys($filter), $filter));
return $this->curl->get("tasks{$url}");
}
|
[
"public",
"function",
"getTasksByFilter",
"(",
"$",
"filter",
"=",
"[",
"\"assignee\"",
"=>",
"\"\"",
",",
"\"project\"",
"=>",
"\"\"",
",",
"\"workspace\"",
"=>",
"\"\"",
"]",
")",
"{",
"$",
"filter",
"=",
"array_filter",
"(",
"array_merge",
"(",
"[",
"\"assignee\"",
"=>",
"\"\"",
",",
"\"project\"",
"=>",
"\"\"",
",",
"\"workspace\"",
"=>",
"\"\"",
"]",
",",
"$",
"filter",
")",
")",
";",
"$",
"url",
"=",
"'?'",
".",
"join",
"(",
"'&'",
",",
"array_map",
"(",
"function",
"(",
"$",
"k",
",",
"$",
"v",
")",
"{",
"return",
"\"{$k}={$v}\"",
";",
"}",
",",
"array_keys",
"(",
"$",
"filter",
")",
",",
"$",
"filter",
")",
")",
";",
"return",
"$",
"this",
"->",
"curl",
"->",
"get",
"(",
"\"tasks{$url}\"",
")",
";",
"}"
] |
Returns task by a given filter.
For now (limited by Asana API), you may limit your
query either to a specific project or to an assignee and workspace
NOTE: As Asana API says, if you filter by assignee, you MUST specify a workspaceId and vice-a-versa.
@param array $filter
array(
"assignee" => "",
"project" => 0,
"workspace" => 0
)
@return string|null
|
[
"Returns",
"task",
"by",
"a",
"given",
"filter",
"."
] |
6e669720dbc3e66f19ffb637865eab9d5ae9d299
|
https://github.com/Torann/laravel-asana/blob/6e669720dbc3e66f19ffb637865eab9d5ae9d299/src/Asana.php#L276-L284
|
223,292
|
Torann/laravel-asana
|
src/Asana.php
|
Asana.getProject
|
public function getProject($projectId = null)
{
$projectId = $projectId ?: $this->defaultProjectId;
return $this->curl->get("projects/{$projectId}");
}
|
php
|
public function getProject($projectId = null)
{
$projectId = $projectId ?: $this->defaultProjectId;
return $this->curl->get("projects/{$projectId}");
}
|
[
"public",
"function",
"getProject",
"(",
"$",
"projectId",
"=",
"null",
")",
"{",
"$",
"projectId",
"=",
"$",
"projectId",
"?",
":",
"$",
"this",
"->",
"defaultProjectId",
";",
"return",
"$",
"this",
"->",
"curl",
"->",
"get",
"(",
"\"projects/{$projectId}\"",
")",
";",
"}"
] |
Returns the full record for a single project.
@param string $projectId
@return string|null
|
[
"Returns",
"the",
"full",
"record",
"for",
"a",
"single",
"project",
"."
] |
6e669720dbc3e66f19ffb637865eab9d5ae9d299
|
https://github.com/Torann/laravel-asana/blob/6e669720dbc3e66f19ffb637865eab9d5ae9d299/src/Asana.php#L383-L388
|
223,293
|
Torann/laravel-asana
|
src/Asana.php
|
Asana.getProjects
|
public function getProjects($archived = false, $opt_fields = "")
{
$archived = $archived ? "true" : "false";
$opt_fields = ($opt_fields != "") ? "&opt_fields={$opt_fields}" : "";
return $this->curl->get("projects?archived={$archived}{$opt_fields}");
}
|
php
|
public function getProjects($archived = false, $opt_fields = "")
{
$archived = $archived ? "true" : "false";
$opt_fields = ($opt_fields != "") ? "&opt_fields={$opt_fields}" : "";
return $this->curl->get("projects?archived={$archived}{$opt_fields}");
}
|
[
"public",
"function",
"getProjects",
"(",
"$",
"archived",
"=",
"false",
",",
"$",
"opt_fields",
"=",
"\"\"",
")",
"{",
"$",
"archived",
"=",
"$",
"archived",
"?",
"\"true\"",
":",
"\"false\"",
";",
"$",
"opt_fields",
"=",
"(",
"$",
"opt_fields",
"!=",
"\"\"",
")",
"?",
"\"&opt_fields={$opt_fields}\"",
":",
"\"\"",
";",
"return",
"$",
"this",
"->",
"curl",
"->",
"get",
"(",
"\"projects?archived={$archived}{$opt_fields}\"",
")",
";",
"}"
] |
Returns the projects in all workspaces containing archived ones or not.
@param boolean $archived Return archived projects or not
@param string $opt_fields Return results with optional parameters
@return string JSON or null
|
[
"Returns",
"the",
"projects",
"in",
"all",
"workspaces",
"containing",
"archived",
"ones",
"or",
"not",
"."
] |
6e669720dbc3e66f19ffb637865eab9d5ae9d299
|
https://github.com/Torann/laravel-asana/blob/6e669720dbc3e66f19ffb637865eab9d5ae9d299/src/Asana.php#L398-L404
|
223,294
|
Torann/laravel-asana
|
src/Asana.php
|
Asana.getProjectsInWorkspace
|
public function getProjectsInWorkspace($workspaceId = null, $archived = false)
{
$archived = $archived ? 1 : 0;
$workspaceId = $workspaceId ?: $this->defaultWorkspaceId;
return $this->curl->get("projects?archived={$archived}&workspace={$workspaceId}");
}
|
php
|
public function getProjectsInWorkspace($workspaceId = null, $archived = false)
{
$archived = $archived ? 1 : 0;
$workspaceId = $workspaceId ?: $this->defaultWorkspaceId;
return $this->curl->get("projects?archived={$archived}&workspace={$workspaceId}");
}
|
[
"public",
"function",
"getProjectsInWorkspace",
"(",
"$",
"workspaceId",
"=",
"null",
",",
"$",
"archived",
"=",
"false",
")",
"{",
"$",
"archived",
"=",
"$",
"archived",
"?",
"1",
":",
"0",
";",
"$",
"workspaceId",
"=",
"$",
"workspaceId",
"?",
":",
"$",
"this",
"->",
"defaultWorkspaceId",
";",
"return",
"$",
"this",
"->",
"curl",
"->",
"get",
"(",
"\"projects?archived={$archived}&workspace={$workspaceId}\"",
")",
";",
"}"
] |
Returns the projects in provided workspace containing archived ones or not.
@param string $workspaceId
@param boolean $archived Return archived projects or not
@return string JSON or null
|
[
"Returns",
"the",
"projects",
"in",
"provided",
"workspace",
"containing",
"archived",
"ones",
"or",
"not",
"."
] |
6e669720dbc3e66f19ffb637865eab9d5ae9d299
|
https://github.com/Torann/laravel-asana/blob/6e669720dbc3e66f19ffb637865eab9d5ae9d299/src/Asana.php#L414-L420
|
223,295
|
Torann/laravel-asana
|
src/Asana.php
|
Asana.updateProject
|
public function updateProject($projectId = null, $data)
{
$projectId = $projectId ?: $this->defaultProjectId;
return $this->curl->put("projects/{$projectId}", ['data' => $data]);
}
|
php
|
public function updateProject($projectId = null, $data)
{
$projectId = $projectId ?: $this->defaultProjectId;
return $this->curl->put("projects/{$projectId}", ['data' => $data]);
}
|
[
"public",
"function",
"updateProject",
"(",
"$",
"projectId",
"=",
"null",
",",
"$",
"data",
")",
"{",
"$",
"projectId",
"=",
"$",
"projectId",
"?",
":",
"$",
"this",
"->",
"defaultProjectId",
";",
"return",
"$",
"this",
"->",
"curl",
"->",
"put",
"(",
"\"projects/{$projectId}\"",
",",
"[",
"'data'",
"=>",
"$",
"data",
"]",
")",
";",
"}"
] |
This method modifies the fields of a project provided
in the request, then returns the full updated record.
@param string $projectId
@param array $data
@return string|null
|
[
"This",
"method",
"modifies",
"the",
"fields",
"of",
"a",
"project",
"provided",
"in",
"the",
"request",
"then",
"returns",
"the",
"full",
"updated",
"record",
"."
] |
6e669720dbc3e66f19ffb637865eab9d5ae9d299
|
https://github.com/Torann/laravel-asana/blob/6e669720dbc3e66f19ffb637865eab9d5ae9d299/src/Asana.php#L431-L436
|
223,296
|
Torann/laravel-asana
|
src/Asana.php
|
Asana.getProjectTasks
|
public function getProjectTasks($projectId = null)
{
$projectId = $projectId ?: $this->defaultProjectId;
return $this->curl->get("tasks?project={$projectId}");
}
|
php
|
public function getProjectTasks($projectId = null)
{
$projectId = $projectId ?: $this->defaultProjectId;
return $this->curl->get("tasks?project={$projectId}");
}
|
[
"public",
"function",
"getProjectTasks",
"(",
"$",
"projectId",
"=",
"null",
")",
"{",
"$",
"projectId",
"=",
"$",
"projectId",
"?",
":",
"$",
"this",
"->",
"defaultProjectId",
";",
"return",
"$",
"this",
"->",
"curl",
"->",
"get",
"(",
"\"tasks?project={$projectId}\"",
")",
";",
"}"
] |
Returns all unarchived tasks of a given project
@param string $projectId
@return string|null
|
[
"Returns",
"all",
"unarchived",
"tasks",
"of",
"a",
"given",
"project"
] |
6e669720dbc3e66f19ffb637865eab9d5ae9d299
|
https://github.com/Torann/laravel-asana/blob/6e669720dbc3e66f19ffb637865eab9d5ae9d299/src/Asana.php#L445-L450
|
223,297
|
Torann/laravel-asana
|
src/Asana.php
|
Asana.getProjectStories
|
public function getProjectStories($projectId = null)
{
$projectId = $projectId ?: $this->defaultProjectId;
return $this->curl->get("projects/{$projectId}/stories");
}
|
php
|
public function getProjectStories($projectId = null)
{
$projectId = $projectId ?: $this->defaultProjectId;
return $this->curl->get("projects/{$projectId}/stories");
}
|
[
"public",
"function",
"getProjectStories",
"(",
"$",
"projectId",
"=",
"null",
")",
"{",
"$",
"projectId",
"=",
"$",
"projectId",
"?",
":",
"$",
"this",
"->",
"defaultProjectId",
";",
"return",
"$",
"this",
"->",
"curl",
"->",
"get",
"(",
"\"projects/{$projectId}/stories\"",
")",
";",
"}"
] |
Returns the list of stories associated with the object.
As usual with queries, stories are returned in compact form.
However, the compact form for stories contains more
information by default than just the ID.
There is presently no way to get a filtered set of stories.
@param string $projectId
@return string|null
|
[
"Returns",
"the",
"list",
"of",
"stories",
"associated",
"with",
"the",
"object",
".",
"As",
"usual",
"with",
"queries",
"stories",
"are",
"returned",
"in",
"compact",
"form",
".",
"However",
"the",
"compact",
"form",
"for",
"stories",
"contains",
"more",
"information",
"by",
"default",
"than",
"just",
"the",
"ID",
".",
"There",
"is",
"presently",
"no",
"way",
"to",
"get",
"a",
"filtered",
"set",
"of",
"stories",
"."
] |
6e669720dbc3e66f19ffb637865eab9d5ae9d299
|
https://github.com/Torann/laravel-asana/blob/6e669720dbc3e66f19ffb637865eab9d5ae9d299/src/Asana.php#L463-L468
|
223,298
|
Torann/laravel-asana
|
src/Asana.php
|
Asana.commentOnProject
|
public function commentOnProject($projectId = null, $text = "")
{
$projectId = $projectId ?: $this->defaultProjectId;
$data = [
"text" => $text
];
return $this->curl->post("projects/{$projectId}/stories", ['data' => $data]);
}
|
php
|
public function commentOnProject($projectId = null, $text = "")
{
$projectId = $projectId ?: $this->defaultProjectId;
$data = [
"text" => $text
];
return $this->curl->post("projects/{$projectId}/stories", ['data' => $data]);
}
|
[
"public",
"function",
"commentOnProject",
"(",
"$",
"projectId",
"=",
"null",
",",
"$",
"text",
"=",
"\"\"",
")",
"{",
"$",
"projectId",
"=",
"$",
"projectId",
"?",
":",
"$",
"this",
"->",
"defaultProjectId",
";",
"$",
"data",
"=",
"[",
"\"text\"",
"=>",
"$",
"text",
"]",
";",
"return",
"$",
"this",
"->",
"curl",
"->",
"post",
"(",
"\"projects/{$projectId}/stories\"",
",",
"[",
"'data'",
"=>",
"$",
"data",
"]",
")",
";",
"}"
] |
Adds a comment to a project
The comment will be authored by the authorized user, and
timestamped when the server receives the request.
@param string $projectId
@param string $text
@return string|null
|
[
"Adds",
"a",
"comment",
"to",
"a",
"project"
] |
6e669720dbc3e66f19ffb637865eab9d5ae9d299
|
https://github.com/Torann/laravel-asana/blob/6e669720dbc3e66f19ffb637865eab9d5ae9d299/src/Asana.php#L481-L490
|
223,299
|
Torann/laravel-asana
|
src/Asana.php
|
Asana.getWorkspaceTasks
|
public function getWorkspaceTasks($workspaceId = null, $assignee = "me")
{
$workspaceId = $workspaceId ?: $this->defaultWorkspaceId;
return $this->curl->get("tasks?workspace={$workspaceId}&assignee={$assignee}");
}
|
php
|
public function getWorkspaceTasks($workspaceId = null, $assignee = "me")
{
$workspaceId = $workspaceId ?: $this->defaultWorkspaceId;
return $this->curl->get("tasks?workspace={$workspaceId}&assignee={$assignee}");
}
|
[
"public",
"function",
"getWorkspaceTasks",
"(",
"$",
"workspaceId",
"=",
"null",
",",
"$",
"assignee",
"=",
"\"me\"",
")",
"{",
"$",
"workspaceId",
"=",
"$",
"workspaceId",
"?",
":",
"$",
"this",
"->",
"defaultWorkspaceId",
";",
"return",
"$",
"this",
"->",
"curl",
"->",
"get",
"(",
"\"tasks?workspace={$workspaceId}&assignee={$assignee}\"",
")",
";",
"}"
] |
Returns tasks of all workspace assigned to someone.
Note: As Asana API says, you must specify an assignee when querying for workspace tasks.
@param string $workspaceId The id of the workspace
@param string $assignee Can be "me" or user ID
@return string|null
|
[
"Returns",
"tasks",
"of",
"all",
"workspace",
"assigned",
"to",
"someone",
"."
] |
6e669720dbc3e66f19ffb637865eab9d5ae9d299
|
https://github.com/Torann/laravel-asana/blob/6e669720dbc3e66f19ffb637865eab9d5ae9d299/src/Asana.php#L590-L595
|
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.