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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
26,900
|
iherwig/wcmf
|
src/wcmf/lib/model/mapper/impl/NodeUnifiedRDBMapper.php
|
NodeUnifiedRDBMapper.addCriteria
|
protected function addCriteria(SelectStatement $selectStmt, $criteria, $tableName) {
$parameters = [];
if ($criteria != null) {
foreach ($criteria as $criterion) {
if ($criterion instanceof Criteria) {
$placeholder = ':'.$tableName.'_'.$criterion->getAttribute();
list($criteriaCondition, $criteriaPlaceholder) =
$this->renderCriteria($criterion, $placeholder, $tableName);
$selectStmt->where($criteriaCondition, $criterion->getCombineOperator());
if ($criteriaPlaceholder) {
$value = $criterion->getValue();
if (is_array($criteriaPlaceholder)) {
$parameters = array_merge($parameters, array_combine($criteriaPlaceholder, $value));
}
else {
$parameters[$criteriaPlaceholder] = $value;
}
}
}
else {
throw new IllegalArgumentException("The select condition must be an instance of Criteria");
}
}
}
return $parameters;
}
|
php
|
protected function addCriteria(SelectStatement $selectStmt, $criteria, $tableName) {
$parameters = [];
if ($criteria != null) {
foreach ($criteria as $criterion) {
if ($criterion instanceof Criteria) {
$placeholder = ':'.$tableName.'_'.$criterion->getAttribute();
list($criteriaCondition, $criteriaPlaceholder) =
$this->renderCriteria($criterion, $placeholder, $tableName);
$selectStmt->where($criteriaCondition, $criterion->getCombineOperator());
if ($criteriaPlaceholder) {
$value = $criterion->getValue();
if (is_array($criteriaPlaceholder)) {
$parameters = array_merge($parameters, array_combine($criteriaPlaceholder, $value));
}
else {
$parameters[$criteriaPlaceholder] = $value;
}
}
}
else {
throw new IllegalArgumentException("The select condition must be an instance of Criteria");
}
}
}
return $parameters;
}
|
[
"protected",
"function",
"addCriteria",
"(",
"SelectStatement",
"$",
"selectStmt",
",",
"$",
"criteria",
",",
"$",
"tableName",
")",
"{",
"$",
"parameters",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"criteria",
"!=",
"null",
")",
"{",
"foreach",
"(",
"$",
"criteria",
"as",
"$",
"criterion",
")",
"{",
"if",
"(",
"$",
"criterion",
"instanceof",
"Criteria",
")",
"{",
"$",
"placeholder",
"=",
"':'",
".",
"$",
"tableName",
".",
"'_'",
".",
"$",
"criterion",
"->",
"getAttribute",
"(",
")",
";",
"list",
"(",
"$",
"criteriaCondition",
",",
"$",
"criteriaPlaceholder",
")",
"=",
"$",
"this",
"->",
"renderCriteria",
"(",
"$",
"criterion",
",",
"$",
"placeholder",
",",
"$",
"tableName",
")",
";",
"$",
"selectStmt",
"->",
"where",
"(",
"$",
"criteriaCondition",
",",
"$",
"criterion",
"->",
"getCombineOperator",
"(",
")",
")",
";",
"if",
"(",
"$",
"criteriaPlaceholder",
")",
"{",
"$",
"value",
"=",
"$",
"criterion",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"criteriaPlaceholder",
")",
")",
"{",
"$",
"parameters",
"=",
"array_merge",
"(",
"$",
"parameters",
",",
"array_combine",
"(",
"$",
"criteriaPlaceholder",
",",
"$",
"value",
")",
")",
";",
"}",
"else",
"{",
"$",
"parameters",
"[",
"$",
"criteriaPlaceholder",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The select condition must be an instance of Criteria\"",
")",
";",
"}",
"}",
"}",
"return",
"$",
"parameters",
";",
"}"
] |
Add the given criteria to the select statement
@param $selectStmt The select statement (instance of SelectStatement)
@param $criteria An array of Criteria instances that define conditions on the object's attributes (maybe null)
@param $tableName The table name
@return Array of placeholder/value pairs
|
[
"Add",
"the",
"given",
"criteria",
"to",
"the",
"select",
"statement"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/impl/NodeUnifiedRDBMapper.php#L613-L638
|
26,901
|
iherwig/wcmf
|
src/wcmf/lib/model/mapper/impl/NodeUnifiedRDBMapper.php
|
NodeUnifiedRDBMapper.addOrderBy
|
protected function addOrderBy(SelectStatement $selectStmt, $orderby, $orderType, $aliasName, $defaultOrder) {
if ($orderby == null) {
$orderby = [];
// use default ordering
if ($defaultOrder && sizeof($defaultOrder) > 0) {
foreach ($defaultOrder as $orderDef) {
$orderby[] = $orderDef['sortFieldName']." ".$orderDef['sortDirection'];
$orderType = $orderDef['sortType'];
}
}
}
for ($i=0, $count=sizeof($orderby); $i<$count; $i++) {
$curOrderBy = $orderby[$i];
$orderByParts = preg_split('/ /', $curOrderBy);
$orderAttribute = $orderByParts[0];
$orderDirection = sizeof($orderByParts) > 1 ? $orderByParts[1] : 'ASC';
if (strpos($orderAttribute, '.') > 0) {
// the type is included in the attribute
$orderAttributeParts = preg_split('/\./', $orderAttribute);
$orderAttribute = array_pop($orderAttributeParts);
}
$mapper = $orderType != null ? self::getMapper($orderType) : $this;
$orderAttributeDesc = $mapper->getAttribute($orderAttribute);
if ($orderAttributeDesc instanceof ReferenceDescription) {
// add the referenced column without table name
$mapper = self::getMapper($orderAttributeDesc->getOtherType());
$orderAttributeDesc = $mapper->getAttribute($orderAttributeDesc->getOtherName());
$orderColumnName = $orderAttributeDesc->getColumn();
}
elseif ($orderAttributeDesc instanceof TransientAttributeDescription) {
// skip, because no column exists
continue;
}
else {
// add the column with table name
$tableName = $aliasName != null ? $aliasName : $mapper->getRealTableName();
$orderColumnName = $tableName.'.'.$orderAttributeDesc->getColumn();
}
$selectStmt->order([$orderColumnName.' '.$orderDirection]);
}
}
|
php
|
protected function addOrderBy(SelectStatement $selectStmt, $orderby, $orderType, $aliasName, $defaultOrder) {
if ($orderby == null) {
$orderby = [];
// use default ordering
if ($defaultOrder && sizeof($defaultOrder) > 0) {
foreach ($defaultOrder as $orderDef) {
$orderby[] = $orderDef['sortFieldName']." ".$orderDef['sortDirection'];
$orderType = $orderDef['sortType'];
}
}
}
for ($i=0, $count=sizeof($orderby); $i<$count; $i++) {
$curOrderBy = $orderby[$i];
$orderByParts = preg_split('/ /', $curOrderBy);
$orderAttribute = $orderByParts[0];
$orderDirection = sizeof($orderByParts) > 1 ? $orderByParts[1] : 'ASC';
if (strpos($orderAttribute, '.') > 0) {
// the type is included in the attribute
$orderAttributeParts = preg_split('/\./', $orderAttribute);
$orderAttribute = array_pop($orderAttributeParts);
}
$mapper = $orderType != null ? self::getMapper($orderType) : $this;
$orderAttributeDesc = $mapper->getAttribute($orderAttribute);
if ($orderAttributeDesc instanceof ReferenceDescription) {
// add the referenced column without table name
$mapper = self::getMapper($orderAttributeDesc->getOtherType());
$orderAttributeDesc = $mapper->getAttribute($orderAttributeDesc->getOtherName());
$orderColumnName = $orderAttributeDesc->getColumn();
}
elseif ($orderAttributeDesc instanceof TransientAttributeDescription) {
// skip, because no column exists
continue;
}
else {
// add the column with table name
$tableName = $aliasName != null ? $aliasName : $mapper->getRealTableName();
$orderColumnName = $tableName.'.'.$orderAttributeDesc->getColumn();
}
$selectStmt->order([$orderColumnName.' '.$orderDirection]);
}
}
|
[
"protected",
"function",
"addOrderBy",
"(",
"SelectStatement",
"$",
"selectStmt",
",",
"$",
"orderby",
",",
"$",
"orderType",
",",
"$",
"aliasName",
",",
"$",
"defaultOrder",
")",
"{",
"if",
"(",
"$",
"orderby",
"==",
"null",
")",
"{",
"$",
"orderby",
"=",
"[",
"]",
";",
"// use default ordering",
"if",
"(",
"$",
"defaultOrder",
"&&",
"sizeof",
"(",
"$",
"defaultOrder",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"defaultOrder",
"as",
"$",
"orderDef",
")",
"{",
"$",
"orderby",
"[",
"]",
"=",
"$",
"orderDef",
"[",
"'sortFieldName'",
"]",
".",
"\" \"",
".",
"$",
"orderDef",
"[",
"'sortDirection'",
"]",
";",
"$",
"orderType",
"=",
"$",
"orderDef",
"[",
"'sortType'",
"]",
";",
"}",
"}",
"}",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"count",
"=",
"sizeof",
"(",
"$",
"orderby",
")",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"curOrderBy",
"=",
"$",
"orderby",
"[",
"$",
"i",
"]",
";",
"$",
"orderByParts",
"=",
"preg_split",
"(",
"'/ /'",
",",
"$",
"curOrderBy",
")",
";",
"$",
"orderAttribute",
"=",
"$",
"orderByParts",
"[",
"0",
"]",
";",
"$",
"orderDirection",
"=",
"sizeof",
"(",
"$",
"orderByParts",
")",
">",
"1",
"?",
"$",
"orderByParts",
"[",
"1",
"]",
":",
"'ASC'",
";",
"if",
"(",
"strpos",
"(",
"$",
"orderAttribute",
",",
"'.'",
")",
">",
"0",
")",
"{",
"// the type is included in the attribute",
"$",
"orderAttributeParts",
"=",
"preg_split",
"(",
"'/\\./'",
",",
"$",
"orderAttribute",
")",
";",
"$",
"orderAttribute",
"=",
"array_pop",
"(",
"$",
"orderAttributeParts",
")",
";",
"}",
"$",
"mapper",
"=",
"$",
"orderType",
"!=",
"null",
"?",
"self",
"::",
"getMapper",
"(",
"$",
"orderType",
")",
":",
"$",
"this",
";",
"$",
"orderAttributeDesc",
"=",
"$",
"mapper",
"->",
"getAttribute",
"(",
"$",
"orderAttribute",
")",
";",
"if",
"(",
"$",
"orderAttributeDesc",
"instanceof",
"ReferenceDescription",
")",
"{",
"// add the referenced column without table name",
"$",
"mapper",
"=",
"self",
"::",
"getMapper",
"(",
"$",
"orderAttributeDesc",
"->",
"getOtherType",
"(",
")",
")",
";",
"$",
"orderAttributeDesc",
"=",
"$",
"mapper",
"->",
"getAttribute",
"(",
"$",
"orderAttributeDesc",
"->",
"getOtherName",
"(",
")",
")",
";",
"$",
"orderColumnName",
"=",
"$",
"orderAttributeDesc",
"->",
"getColumn",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"orderAttributeDesc",
"instanceof",
"TransientAttributeDescription",
")",
"{",
"// skip, because no column exists",
"continue",
";",
"}",
"else",
"{",
"// add the column with table name",
"$",
"tableName",
"=",
"$",
"aliasName",
"!=",
"null",
"?",
"$",
"aliasName",
":",
"$",
"mapper",
"->",
"getRealTableName",
"(",
")",
";",
"$",
"orderColumnName",
"=",
"$",
"tableName",
".",
"'.'",
".",
"$",
"orderAttributeDesc",
"->",
"getColumn",
"(",
")",
";",
"}",
"$",
"selectStmt",
"->",
"order",
"(",
"[",
"$",
"orderColumnName",
".",
"' '",
".",
"$",
"orderDirection",
"]",
")",
";",
"}",
"}"
] |
Add the given order to the select statement
@param $selectStmt The select statement (instance of SelectStatement)
@param $orderby An array holding names of attributes to order by, maybe appended with 'ASC', 'DESC' (maybe null)
@param $orderType The type that define the attributes in orderby (maybe null)
@param $aliasName The table alias name to be used (maybe null)
@param $defaultOrder The default order definition to use, if orderby is null (@see PersistenceMapper::getDefaultOrder())
|
[
"Add",
"the",
"given",
"order",
"to",
"the",
"select",
"statement"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/impl/NodeUnifiedRDBMapper.php#L648-L688
|
26,902
|
iherwig/wcmf
|
src/wcmf/lib/model/mapper/impl/NodeUnifiedRDBMapper.php
|
NodeUnifiedRDBMapper.convertValuesForStorage
|
protected function convertValuesForStorage($values) {
// filter values according to type
foreach($values as $valueName => $value) {
$type = $this->getAttribute($valueName)->getType();
// integer
if (strpos(strtolower($type), 'int') === 0) {
$value = (strlen($value) == 0) ? null : intval($value);
$values[$valueName] = $value;
}
// null values
if ($value === null) {
$values[$valueName] = SQLConst::NULL();
}
}
return $values;
}
|
php
|
protected function convertValuesForStorage($values) {
// filter values according to type
foreach($values as $valueName => $value) {
$type = $this->getAttribute($valueName)->getType();
// integer
if (strpos(strtolower($type), 'int') === 0) {
$value = (strlen($value) == 0) ? null : intval($value);
$values[$valueName] = $value;
}
// null values
if ($value === null) {
$values[$valueName] = SQLConst::NULL();
}
}
return $values;
}
|
[
"protected",
"function",
"convertValuesForStorage",
"(",
"$",
"values",
")",
"{",
"// filter values according to type",
"foreach",
"(",
"$",
"values",
"as",
"$",
"valueName",
"=>",
"$",
"value",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"$",
"valueName",
")",
"->",
"getType",
"(",
")",
";",
"// integer",
"if",
"(",
"strpos",
"(",
"strtolower",
"(",
"$",
"type",
")",
",",
"'int'",
")",
"===",
"0",
")",
"{",
"$",
"value",
"=",
"(",
"strlen",
"(",
"$",
"value",
")",
"==",
"0",
")",
"?",
"null",
":",
"intval",
"(",
"$",
"value",
")",
";",
"$",
"values",
"[",
"$",
"valueName",
"]",
"=",
"$",
"value",
";",
"}",
"// null values",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"$",
"values",
"[",
"$",
"valueName",
"]",
"=",
"SQLConst",
"::",
"NULL",
"(",
")",
";",
"}",
"}",
"return",
"$",
"values",
";",
"}"
] |
Convert values before putting into storage
@param $values Associative Array
@return Associative Array
|
[
"Convert",
"values",
"before",
"putting",
"into",
"storage"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/impl/NodeUnifiedRDBMapper.php#L749-L764
|
26,903
|
iherwig/wcmf
|
src/wcmf/lib/model/mapper/impl/NodeUnifiedRDBMapper.php
|
NodeUnifiedRDBMapper.getSortableObject
|
protected function getSortableObject(PersistentObjectProxy $objectProxy,
PersistentObjectProxy $relativeProxy, RelationDescription $relationDesc) {
// in a many to many relation, we have to modify the order of the relation objects
if ($relationDesc instanceof RDBManyToManyRelationDescription) {
$nmObjects = $this->loadRelationObjects($objectProxy, $relativeProxy, $relationDesc);
return $nmObjects[0];
}
return $relativeProxy;
}
|
php
|
protected function getSortableObject(PersistentObjectProxy $objectProxy,
PersistentObjectProxy $relativeProxy, RelationDescription $relationDesc) {
// in a many to many relation, we have to modify the order of the relation objects
if ($relationDesc instanceof RDBManyToManyRelationDescription) {
$nmObjects = $this->loadRelationObjects($objectProxy, $relativeProxy, $relationDesc);
return $nmObjects[0];
}
return $relativeProxy;
}
|
[
"protected",
"function",
"getSortableObject",
"(",
"PersistentObjectProxy",
"$",
"objectProxy",
",",
"PersistentObjectProxy",
"$",
"relativeProxy",
",",
"RelationDescription",
"$",
"relationDesc",
")",
"{",
"// in a many to many relation, we have to modify the order of the relation objects",
"if",
"(",
"$",
"relationDesc",
"instanceof",
"RDBManyToManyRelationDescription",
")",
"{",
"$",
"nmObjects",
"=",
"$",
"this",
"->",
"loadRelationObjects",
"(",
"$",
"objectProxy",
",",
"$",
"relativeProxy",
",",
"$",
"relationDesc",
")",
";",
"return",
"$",
"nmObjects",
"[",
"0",
"]",
";",
"}",
"return",
"$",
"relativeProxy",
";",
"}"
] |
Get the object which carries the sortkey in the relation of the given object
and relative.
@param PersistentObjectProxy $objectProxy
@param PersistentObjectProxy $relativeProxy
@param RelationDescription $relationDesc The relation description
@return PersistentObjectProxy
|
[
"Get",
"the",
"object",
"which",
"carries",
"the",
"sortkey",
"in",
"the",
"relation",
"of",
"the",
"given",
"object",
"and",
"relative",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/impl/NodeUnifiedRDBMapper.php#L774-L782
|
26,904
|
iherwig/wcmf
|
src/wcmf/lib/model/mapper/impl/NodeUnifiedRDBMapper.php
|
NodeUnifiedRDBMapper.loadRelationObjects
|
protected function loadRelationObjects(PersistentObjectProxy $objectProxy,
PersistentObjectProxy $relativeProxy, RDBManyToManyRelationDescription $relationDesc,
$includeTransaction=false) {
$nmMapper = self::getMapper($relationDesc->getThisEndRelation()->getOtherType());
$nmType = $nmMapper->getType();
$thisId = $objectProxy->getOID()->getFirstId();
$otherId = $relativeProxy->getOID()->getFirstId();
$thisEndRelation = $relationDesc->getThisEndRelation();
$otherEndRelation = $relationDesc->getOtherEndRelation();
$thisFkAttr = $nmMapper->getAttribute($thisEndRelation->getFkName());
$otherFkAttr = $nmMapper->getAttribute($otherEndRelation->getFkName());
$criteria1 = new Criteria($nmType, $thisFkAttr->getName(), "=", $thisId);
$criteria2 = new Criteria($nmType, $otherFkAttr->getName(), "=", $otherId);
$criteria = [$criteria1, $criteria2];
$nmObjects = $nmMapper->loadObjects($nmType, BuildDepth::SINGLE, $criteria);
if ($includeTransaction) {
$transaction = $this->persistenceFacade->getTransaction();
$objects = $transaction->getObjects();
foreach ($objects as $object) {
if ($object->getType() == $nmType && $object instanceof Node) {
// we expect single valued relation ends
$thisEndObject = $object->getValue($thisEndRelation->getThisRole());
$otherEndObject = $object->getValue($otherEndRelation->getOtherRole());
if ($objectProxy->getOID() == $thisEndObject->getOID() &&
$relativeProxy->getOID() == $otherEndObject->getOID()) {
$nmObjects[] = $object;
}
}
}
}
return $nmObjects;
}
|
php
|
protected function loadRelationObjects(PersistentObjectProxy $objectProxy,
PersistentObjectProxy $relativeProxy, RDBManyToManyRelationDescription $relationDesc,
$includeTransaction=false) {
$nmMapper = self::getMapper($relationDesc->getThisEndRelation()->getOtherType());
$nmType = $nmMapper->getType();
$thisId = $objectProxy->getOID()->getFirstId();
$otherId = $relativeProxy->getOID()->getFirstId();
$thisEndRelation = $relationDesc->getThisEndRelation();
$otherEndRelation = $relationDesc->getOtherEndRelation();
$thisFkAttr = $nmMapper->getAttribute($thisEndRelation->getFkName());
$otherFkAttr = $nmMapper->getAttribute($otherEndRelation->getFkName());
$criteria1 = new Criteria($nmType, $thisFkAttr->getName(), "=", $thisId);
$criteria2 = new Criteria($nmType, $otherFkAttr->getName(), "=", $otherId);
$criteria = [$criteria1, $criteria2];
$nmObjects = $nmMapper->loadObjects($nmType, BuildDepth::SINGLE, $criteria);
if ($includeTransaction) {
$transaction = $this->persistenceFacade->getTransaction();
$objects = $transaction->getObjects();
foreach ($objects as $object) {
if ($object->getType() == $nmType && $object instanceof Node) {
// we expect single valued relation ends
$thisEndObject = $object->getValue($thisEndRelation->getThisRole());
$otherEndObject = $object->getValue($otherEndRelation->getOtherRole());
if ($objectProxy->getOID() == $thisEndObject->getOID() &&
$relativeProxy->getOID() == $otherEndObject->getOID()) {
$nmObjects[] = $object;
}
}
}
}
return $nmObjects;
}
|
[
"protected",
"function",
"loadRelationObjects",
"(",
"PersistentObjectProxy",
"$",
"objectProxy",
",",
"PersistentObjectProxy",
"$",
"relativeProxy",
",",
"RDBManyToManyRelationDescription",
"$",
"relationDesc",
",",
"$",
"includeTransaction",
"=",
"false",
")",
"{",
"$",
"nmMapper",
"=",
"self",
"::",
"getMapper",
"(",
"$",
"relationDesc",
"->",
"getThisEndRelation",
"(",
")",
"->",
"getOtherType",
"(",
")",
")",
";",
"$",
"nmType",
"=",
"$",
"nmMapper",
"->",
"getType",
"(",
")",
";",
"$",
"thisId",
"=",
"$",
"objectProxy",
"->",
"getOID",
"(",
")",
"->",
"getFirstId",
"(",
")",
";",
"$",
"otherId",
"=",
"$",
"relativeProxy",
"->",
"getOID",
"(",
")",
"->",
"getFirstId",
"(",
")",
";",
"$",
"thisEndRelation",
"=",
"$",
"relationDesc",
"->",
"getThisEndRelation",
"(",
")",
";",
"$",
"otherEndRelation",
"=",
"$",
"relationDesc",
"->",
"getOtherEndRelation",
"(",
")",
";",
"$",
"thisFkAttr",
"=",
"$",
"nmMapper",
"->",
"getAttribute",
"(",
"$",
"thisEndRelation",
"->",
"getFkName",
"(",
")",
")",
";",
"$",
"otherFkAttr",
"=",
"$",
"nmMapper",
"->",
"getAttribute",
"(",
"$",
"otherEndRelation",
"->",
"getFkName",
"(",
")",
")",
";",
"$",
"criteria1",
"=",
"new",
"Criteria",
"(",
"$",
"nmType",
",",
"$",
"thisFkAttr",
"->",
"getName",
"(",
")",
",",
"\"=\"",
",",
"$",
"thisId",
")",
";",
"$",
"criteria2",
"=",
"new",
"Criteria",
"(",
"$",
"nmType",
",",
"$",
"otherFkAttr",
"->",
"getName",
"(",
")",
",",
"\"=\"",
",",
"$",
"otherId",
")",
";",
"$",
"criteria",
"=",
"[",
"$",
"criteria1",
",",
"$",
"criteria2",
"]",
";",
"$",
"nmObjects",
"=",
"$",
"nmMapper",
"->",
"loadObjects",
"(",
"$",
"nmType",
",",
"BuildDepth",
"::",
"SINGLE",
",",
"$",
"criteria",
")",
";",
"if",
"(",
"$",
"includeTransaction",
")",
"{",
"$",
"transaction",
"=",
"$",
"this",
"->",
"persistenceFacade",
"->",
"getTransaction",
"(",
")",
";",
"$",
"objects",
"=",
"$",
"transaction",
"->",
"getObjects",
"(",
")",
";",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"object",
")",
"{",
"if",
"(",
"$",
"object",
"->",
"getType",
"(",
")",
"==",
"$",
"nmType",
"&&",
"$",
"object",
"instanceof",
"Node",
")",
"{",
"// we expect single valued relation ends",
"$",
"thisEndObject",
"=",
"$",
"object",
"->",
"getValue",
"(",
"$",
"thisEndRelation",
"->",
"getThisRole",
"(",
")",
")",
";",
"$",
"otherEndObject",
"=",
"$",
"object",
"->",
"getValue",
"(",
"$",
"otherEndRelation",
"->",
"getOtherRole",
"(",
")",
")",
";",
"if",
"(",
"$",
"objectProxy",
"->",
"getOID",
"(",
")",
"==",
"$",
"thisEndObject",
"->",
"getOID",
"(",
")",
"&&",
"$",
"relativeProxy",
"->",
"getOID",
"(",
")",
"==",
"$",
"otherEndObject",
"->",
"getOID",
"(",
")",
")",
"{",
"$",
"nmObjects",
"[",
"]",
"=",
"$",
"object",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"nmObjects",
";",
"}"
] |
Load the relation objects in a many to many relation from the database.
@param $objectProxy The proxy at this end of the relation.
@param $relativeProxy The proxy at the other end of the relation.
@param $relationDesc The RDBManyToManyRelationDescription instance describing the relation.
@param $includeTransaction Boolean whether to also search in the current transaction (default: false)
@return Array of PersistentObject instances
|
[
"Load",
"the",
"relation",
"objects",
"in",
"a",
"many",
"to",
"many",
"relation",
"from",
"the",
"database",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/impl/NodeUnifiedRDBMapper.php#L792-L826
|
26,905
|
iherwig/wcmf
|
src/wcmf/lib/persistence/impl/DefaultPersistentObject.php
|
DefaultPersistentObject.initializeMapper
|
private function initializeMapper() {
// set the mapper
$persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
if ($persistenceFacade->isKnownType($this->type)) {
$this->mapper = $persistenceFacade->getMapper($this->type);
}
else {
// initialize null mapper if not done already
if (self::$nullMapper == null) {
self::$nullMapper = new NullMapper();
}
$this->mapper = self::$nullMapper;
}
}
|
php
|
private function initializeMapper() {
// set the mapper
$persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
if ($persistenceFacade->isKnownType($this->type)) {
$this->mapper = $persistenceFacade->getMapper($this->type);
}
else {
// initialize null mapper if not done already
if (self::$nullMapper == null) {
self::$nullMapper = new NullMapper();
}
$this->mapper = self::$nullMapper;
}
}
|
[
"private",
"function",
"initializeMapper",
"(",
")",
"{",
"// set the mapper",
"$",
"persistenceFacade",
"=",
"ObjectFactory",
"::",
"getInstance",
"(",
"'persistenceFacade'",
")",
";",
"if",
"(",
"$",
"persistenceFacade",
"->",
"isKnownType",
"(",
"$",
"this",
"->",
"type",
")",
")",
"{",
"$",
"this",
"->",
"mapper",
"=",
"$",
"persistenceFacade",
"->",
"getMapper",
"(",
"$",
"this",
"->",
"type",
")",
";",
"}",
"else",
"{",
"// initialize null mapper if not done already",
"if",
"(",
"self",
"::",
"$",
"nullMapper",
"==",
"null",
")",
"{",
"self",
"::",
"$",
"nullMapper",
"=",
"new",
"NullMapper",
"(",
")",
";",
"}",
"$",
"this",
"->",
"mapper",
"=",
"self",
"::",
"$",
"nullMapper",
";",
"}",
"}"
] |
Initialize the PersistenceMapper instance
|
[
"Initialize",
"the",
"PersistenceMapper",
"instance"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/persistence/impl/DefaultPersistentObject.php#L98-L111
|
26,906
|
iherwig/wcmf
|
src/wcmf/lib/persistence/impl/DefaultPersistentObject.php
|
DefaultPersistentObject.setOIDInternal
|
protected function setOIDInternal(ObjectId $oid, $triggerListeners) {
$this->type = $oid->getType();
$this->oid = $oid;
// update the primary key attributes
$ids = $oid->getId();
$pkNames = $this->getMapper()->getPkNames();
for ($i=0, $count=sizeof($pkNames); $i<$count; $i++) {
if ($triggerListeners) {
$this->setValue($pkNames[$i], $ids[$i], true);
}
else {
$this->setValueInternal($pkNames[$i], $ids[$i]);
}
}
}
|
php
|
protected function setOIDInternal(ObjectId $oid, $triggerListeners) {
$this->type = $oid->getType();
$this->oid = $oid;
// update the primary key attributes
$ids = $oid->getId();
$pkNames = $this->getMapper()->getPkNames();
for ($i=0, $count=sizeof($pkNames); $i<$count; $i++) {
if ($triggerListeners) {
$this->setValue($pkNames[$i], $ids[$i], true);
}
else {
$this->setValueInternal($pkNames[$i], $ids[$i]);
}
}
}
|
[
"protected",
"function",
"setOIDInternal",
"(",
"ObjectId",
"$",
"oid",
",",
"$",
"triggerListeners",
")",
"{",
"$",
"this",
"->",
"type",
"=",
"$",
"oid",
"->",
"getType",
"(",
")",
";",
"$",
"this",
"->",
"oid",
"=",
"$",
"oid",
";",
"// update the primary key attributes",
"$",
"ids",
"=",
"$",
"oid",
"->",
"getId",
"(",
")",
";",
"$",
"pkNames",
"=",
"$",
"this",
"->",
"getMapper",
"(",
")",
"->",
"getPkNames",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"count",
"=",
"sizeof",
"(",
"$",
"pkNames",
")",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"triggerListeners",
")",
"{",
"$",
"this",
"->",
"setValue",
"(",
"$",
"pkNames",
"[",
"$",
"i",
"]",
",",
"$",
"ids",
"[",
"$",
"i",
"]",
",",
"true",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setValueInternal",
"(",
"$",
"pkNames",
"[",
"$",
"i",
"]",
",",
"$",
"ids",
"[",
"$",
"i",
"]",
")",
";",
"}",
"}",
"}"
] |
Set the object id of the PersistentObject.
@param $oid The PersistentObject's oid.
@param $triggerListeners Boolean, whether value CahngeListeners should be
notified or not
|
[
"Set",
"the",
"object",
"id",
"of",
"the",
"PersistentObject",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/persistence/impl/DefaultPersistentObject.php#L150-L164
|
26,907
|
iherwig/wcmf
|
src/wcmf/lib/persistence/impl/DefaultPersistentObject.php
|
DefaultPersistentObject.updateOID
|
private function updateOID() {
$pkValues = [];
// collect the values of the primary keys and compose the oid from them
$pkNames = $this->getMapper()->getPkNames();
foreach ($pkNames as $pkName) {
$pkValues[] = self::getValue($pkName);
}
$this->oid = new ObjectId($this->getType(), $pkValues);
}
|
php
|
private function updateOID() {
$pkValues = [];
// collect the values of the primary keys and compose the oid from them
$pkNames = $this->getMapper()->getPkNames();
foreach ($pkNames as $pkName) {
$pkValues[] = self::getValue($pkName);
}
$this->oid = new ObjectId($this->getType(), $pkValues);
}
|
[
"private",
"function",
"updateOID",
"(",
")",
"{",
"$",
"pkValues",
"=",
"[",
"]",
";",
"// collect the values of the primary keys and compose the oid from them",
"$",
"pkNames",
"=",
"$",
"this",
"->",
"getMapper",
"(",
")",
"->",
"getPkNames",
"(",
")",
";",
"foreach",
"(",
"$",
"pkNames",
"as",
"$",
"pkName",
")",
"{",
"$",
"pkValues",
"[",
"]",
"=",
"self",
"::",
"getValue",
"(",
"$",
"pkName",
")",
";",
"}",
"$",
"this",
"->",
"oid",
"=",
"new",
"ObjectId",
"(",
"$",
"this",
"->",
"getType",
"(",
")",
",",
"$",
"pkValues",
")",
";",
"}"
] |
Recalculate the object id
|
[
"Recalculate",
"the",
"object",
"id"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/persistence/impl/DefaultPersistentObject.php#L272-L280
|
26,908
|
iherwig/wcmf
|
src/wcmf/lib/persistence/impl/DefaultPersistentObject.php
|
DefaultPersistentObject.validateValueAgainstValidateType
|
protected function validateValueAgainstValidateType($name, $value) {
// don't validate referenced values
$mapper = $this->getMapper();
if ($mapper->hasAttribute($name) && $mapper->getAttribute($name) instanceof ReferenceDescription) {
return;
}
$validateType = $this->getValueProperty($name, 'validate_type');
if (($validateType == '' || Validator::validate($value, $validateType,
['entity' => $this, 'value' => $name]))) {
return;
}
// construct the error message
$messageInstance = ObjectFactory::getInstance('message');
$validateDescription = $this->getValueProperty($name, 'validate_description');
if (strlen($validateDescription) > 0) {
// use configured message if existing
$errorMessage = $messageInstance->getText($validateDescription);
}
else {
// default text
$errorMessage = $messageInstance->getText("The value of '%0%' (%1%) is invalid.", [$messageInstance->getText($name), $value]);
}
throw new ValidationException($name, $value, $errorMessage);
}
|
php
|
protected function validateValueAgainstValidateType($name, $value) {
// don't validate referenced values
$mapper = $this->getMapper();
if ($mapper->hasAttribute($name) && $mapper->getAttribute($name) instanceof ReferenceDescription) {
return;
}
$validateType = $this->getValueProperty($name, 'validate_type');
if (($validateType == '' || Validator::validate($value, $validateType,
['entity' => $this, 'value' => $name]))) {
return;
}
// construct the error message
$messageInstance = ObjectFactory::getInstance('message');
$validateDescription = $this->getValueProperty($name, 'validate_description');
if (strlen($validateDescription) > 0) {
// use configured message if existing
$errorMessage = $messageInstance->getText($validateDescription);
}
else {
// default text
$errorMessage = $messageInstance->getText("The value of '%0%' (%1%) is invalid.", [$messageInstance->getText($name), $value]);
}
throw new ValidationException($name, $value, $errorMessage);
}
|
[
"protected",
"function",
"validateValueAgainstValidateType",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"// don't validate referenced values",
"$",
"mapper",
"=",
"$",
"this",
"->",
"getMapper",
"(",
")",
";",
"if",
"(",
"$",
"mapper",
"->",
"hasAttribute",
"(",
"$",
"name",
")",
"&&",
"$",
"mapper",
"->",
"getAttribute",
"(",
"$",
"name",
")",
"instanceof",
"ReferenceDescription",
")",
"{",
"return",
";",
"}",
"$",
"validateType",
"=",
"$",
"this",
"->",
"getValueProperty",
"(",
"$",
"name",
",",
"'validate_type'",
")",
";",
"if",
"(",
"(",
"$",
"validateType",
"==",
"''",
"||",
"Validator",
"::",
"validate",
"(",
"$",
"value",
",",
"$",
"validateType",
",",
"[",
"'entity'",
"=>",
"$",
"this",
",",
"'value'",
"=>",
"$",
"name",
"]",
")",
")",
")",
"{",
"return",
";",
"}",
"// construct the error message",
"$",
"messageInstance",
"=",
"ObjectFactory",
"::",
"getInstance",
"(",
"'message'",
")",
";",
"$",
"validateDescription",
"=",
"$",
"this",
"->",
"getValueProperty",
"(",
"$",
"name",
",",
"'validate_description'",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"validateDescription",
")",
">",
"0",
")",
"{",
"// use configured message if existing",
"$",
"errorMessage",
"=",
"$",
"messageInstance",
"->",
"getText",
"(",
"$",
"validateDescription",
")",
";",
"}",
"else",
"{",
"// default text",
"$",
"errorMessage",
"=",
"$",
"messageInstance",
"->",
"getText",
"(",
"\"The value of '%0%' (%1%) is invalid.\"",
",",
"[",
"$",
"messageInstance",
"->",
"getText",
"(",
"$",
"name",
")",
",",
"$",
"value",
"]",
")",
";",
"}",
"throw",
"new",
"ValidationException",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"errorMessage",
")",
";",
"}"
] |
Check a value's value against the validation type set on it. This method uses the
validateType property of the attribute definition.
Throws a ValidationException if the value is not valid.
@param $name The name of the item to set.
@param $value The value of the item.
|
[
"Check",
"a",
"value",
"s",
"value",
"against",
"the",
"validation",
"type",
"set",
"on",
"it",
".",
"This",
"method",
"uses",
"the",
"validateType",
"property",
"of",
"the",
"attribute",
"definition",
".",
"Throws",
"a",
"ValidationException",
"if",
"the",
"value",
"is",
"not",
"valid",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/persistence/impl/DefaultPersistentObject.php#L424-L447
|
26,909
|
iherwig/wcmf
|
src/wcmf/lib/persistence/impl/DefaultPersistentObject.php
|
DefaultPersistentObject.dumpArray
|
private static function dumpArray(array $array) {
$str = "[";
foreach ($array as $value) {
if (is_object($value)) {
$str .= $value->__toString().", ";
}
else {
$str .= $value.", ";
}
}
$str = preg_replace("/, $/", "", $str)."]";
return $str;
}
|
php
|
private static function dumpArray(array $array) {
$str = "[";
foreach ($array as $value) {
if (is_object($value)) {
$str .= $value->__toString().", ";
}
else {
$str .= $value.", ";
}
}
$str = preg_replace("/, $/", "", $str)."]";
return $str;
}
|
[
"private",
"static",
"function",
"dumpArray",
"(",
"array",
"$",
"array",
")",
"{",
"$",
"str",
"=",
"\"[\"",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"$",
"str",
".=",
"$",
"value",
"->",
"__toString",
"(",
")",
".",
"\", \"",
";",
"}",
"else",
"{",
"$",
"str",
".=",
"$",
"value",
".",
"\", \"",
";",
"}",
"}",
"$",
"str",
"=",
"preg_replace",
"(",
"\"/, $/\"",
",",
"\"\"",
",",
"$",
"str",
")",
".",
"\"]\"",
";",
"return",
"$",
"str",
";",
"}"
] |
Get a string representation of an array of values.
@param $array The array to dump
@return String
|
[
"Get",
"a",
"string",
"representation",
"of",
"an",
"array",
"of",
"values",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/persistence/impl/DefaultPersistentObject.php#L610-L622
|
26,910
|
iherwig/wcmf
|
src/wcmf/lib/model/StringQuery.php
|
StringQuery.mapToDatabase
|
protected static function mapToDatabase($type, $valueName) {
$mapper = self::getMapper($type);
if ($mapper->hasAttribute($valueName)) {
$attributeDescription = $mapper->getAttribute($valueName);
}
else {
// if the attribute does not exist, it might be the column name already
foreach ($mapper->getAttributes() as $curAttributeDesc) {
if ($curAttributeDesc->getColumn() == $valueName) {
$attributeDescription = $curAttributeDesc;
break;
}
}
}
if (!$attributeDescription) {
throw new PersistenceException("No attribute '".$valueName."' exists in '".$type."'");
}
$table = $mapper->getRealTableName();
$column = $attributeDescription->getColumn();
return [$table, $column];
}
|
php
|
protected static function mapToDatabase($type, $valueName) {
$mapper = self::getMapper($type);
if ($mapper->hasAttribute($valueName)) {
$attributeDescription = $mapper->getAttribute($valueName);
}
else {
// if the attribute does not exist, it might be the column name already
foreach ($mapper->getAttributes() as $curAttributeDesc) {
if ($curAttributeDesc->getColumn() == $valueName) {
$attributeDescription = $curAttributeDesc;
break;
}
}
}
if (!$attributeDescription) {
throw new PersistenceException("No attribute '".$valueName."' exists in '".$type."'");
}
$table = $mapper->getRealTableName();
$column = $attributeDescription->getColumn();
return [$table, $column];
}
|
[
"protected",
"static",
"function",
"mapToDatabase",
"(",
"$",
"type",
",",
"$",
"valueName",
")",
"{",
"$",
"mapper",
"=",
"self",
"::",
"getMapper",
"(",
"$",
"type",
")",
";",
"if",
"(",
"$",
"mapper",
"->",
"hasAttribute",
"(",
"$",
"valueName",
")",
")",
"{",
"$",
"attributeDescription",
"=",
"$",
"mapper",
"->",
"getAttribute",
"(",
"$",
"valueName",
")",
";",
"}",
"else",
"{",
"// if the attribute does not exist, it might be the column name already",
"foreach",
"(",
"$",
"mapper",
"->",
"getAttributes",
"(",
")",
"as",
"$",
"curAttributeDesc",
")",
"{",
"if",
"(",
"$",
"curAttributeDesc",
"->",
"getColumn",
"(",
")",
"==",
"$",
"valueName",
")",
"{",
"$",
"attributeDescription",
"=",
"$",
"curAttributeDesc",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"$",
"attributeDescription",
")",
"{",
"throw",
"new",
"PersistenceException",
"(",
"\"No attribute '\"",
".",
"$",
"valueName",
".",
"\"' exists in '\"",
".",
"$",
"type",
".",
"\"'\"",
")",
";",
"}",
"$",
"table",
"=",
"$",
"mapper",
"->",
"getRealTableName",
"(",
")",
";",
"$",
"column",
"=",
"$",
"attributeDescription",
"->",
"getColumn",
"(",
")",
";",
"return",
"[",
"$",
"table",
",",
"$",
"column",
"]",
";",
"}"
] |
Map a application type and value name to the appropriate database names
@param $type The type to map
@param $valueName The name of the value to map
@return An array with the table and column name or null if no mapper is found
|
[
"Map",
"a",
"application",
"type",
"and",
"value",
"name",
"to",
"the",
"appropriate",
"database",
"names"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/StringQuery.php#L272-L293
|
26,911
|
GW2Treasures/gw2api
|
src/V2/ApiHandler.php
|
ApiHandler.getResponseAsJson
|
protected function getResponseAsJson( ResponseInterface $response ) {
if( $response->hasHeader('Content-Type') ) {
$typeHeader = $response->getHeader('Content-Type');
$contentType = array_shift($typeHeader);
if( stripos( $contentType, 'application/json' ) === 0 ) {
return json_decode($response->getBody(), false);
}
}
return null;
}
|
php
|
protected function getResponseAsJson( ResponseInterface $response ) {
if( $response->hasHeader('Content-Type') ) {
$typeHeader = $response->getHeader('Content-Type');
$contentType = array_shift($typeHeader);
if( stripos( $contentType, 'application/json' ) === 0 ) {
return json_decode($response->getBody(), false);
}
}
return null;
}
|
[
"protected",
"function",
"getResponseAsJson",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"response",
"->",
"hasHeader",
"(",
"'Content-Type'",
")",
")",
"{",
"$",
"typeHeader",
"=",
"$",
"response",
"->",
"getHeader",
"(",
"'Content-Type'",
")",
";",
"$",
"contentType",
"=",
"array_shift",
"(",
"$",
"typeHeader",
")",
";",
"if",
"(",
"stripos",
"(",
"$",
"contentType",
",",
"'application/json'",
")",
"===",
"0",
")",
"{",
"return",
"json_decode",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
",",
"false",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Returns the json object if the response contains valid json, otherwise null.
@param ResponseInterface $response
@return mixed|null
|
[
"Returns",
"the",
"json",
"object",
"if",
"the",
"response",
"contains",
"valid",
"json",
"otherwise",
"null",
"."
] |
c8795af0c1d0a434b9e530f779d5a95786db2176
|
https://github.com/GW2Treasures/gw2api/blob/c8795af0c1d0a434b9e530f779d5a95786db2176/src/V2/ApiHandler.php#L32-L43
|
26,912
|
iherwig/wcmf
|
src/wcmf/application/controller/XMLExportController.php
|
XMLExportController.exportNodes
|
protected function exportNodes($oids) {
// Export starts from root oids and iterates over all children.
// On every call we have to decide what to do:
// - If there is an iterator stored in the session we are inside a tree and continue iterating (_NODES_PER_CALL nodes)
// until the iterator finishes
// - If the oids array holds one value!=null this is assumed to be an root oid and a new iterator is constructed
// - If there is no iterator and no oid given, we return
$session = $this->getSession();
$persistenceFacade = $this->getPersistenceFacade();
$message = $this->getMessage();
// get document definition
$docFile = $this->getDownloadFile();
$nodesPerCall = $this->getRequestValue('nodesPerCall');
$cacheSection = $this->getRequestValue('cacheSection');
// check for iterator in session
$iterator = PersistentIterator::load($this->ITERATOR_ID_VAR, $persistenceFacade, $session);
// no iterator but oid given, start with new root oid
if ($iterator == null && sizeof($oids) > 0 && $oids[0] != null) {
$iterator = new PersistentIterator($this->ITERATOR_ID_VAR, $persistenceFacade, $session, $oids[0]);
}
// no iterator, no oid, finish
if ($iterator == null) {
$this->addWorkPackage($message->getText('Finish'), 1, [null], 'finishExport');
return;
}
// process nodes
$fileHandle = fopen($docFile, "a");
$counter = 0;
while ($iterator->valid() && $counter < $nodesPerCall) {
// write node
$this->writeNode($fileHandle, $iterator->current(), $iterator->key()+1);
$iterator->next();
$counter++;
}
$this->endTags($fileHandle, 0);
fclose($fileHandle);
// decide what to do next
$rootOIDs = $this->cache->get($cacheSection, self::CACHE_KEY_ROOT_OIDS);
if (!$iterator->valid() && sizeof($rootOIDs) > 0) {
// if the current iterator is finished, reset the iterator and proceed with the next root oid
$nextOID = array_shift($rootOIDs);
// store remaining root oids in the cache
$this->cache->put($cacheSection, self::CACHE_KEY_ROOT_OIDS, $rootOIDs);
// delete iterator to start with new root oid
PersistentIterator::reset($this->ITERATOR_ID_VAR, $session);
$name = $message->getText('Exporting tree: start with %0%', [$nextOID]);
$this->addWorkPackage($name, 1, [$nextOID], 'exportNodes');
}
elseif ($iterator->valid()) {
// proceed with current iterator
$iterator->save();
$name = $message->getText('Exporting tree: continue with %0%', [$iterator->current()]);
$this->addWorkPackage($name, 1, [null], 'exportNodes');
}
else {
// finish
$this->addWorkPackage($message->getText('Finish'), 1, [null], 'finishExport');
}
}
|
php
|
protected function exportNodes($oids) {
// Export starts from root oids and iterates over all children.
// On every call we have to decide what to do:
// - If there is an iterator stored in the session we are inside a tree and continue iterating (_NODES_PER_CALL nodes)
// until the iterator finishes
// - If the oids array holds one value!=null this is assumed to be an root oid and a new iterator is constructed
// - If there is no iterator and no oid given, we return
$session = $this->getSession();
$persistenceFacade = $this->getPersistenceFacade();
$message = $this->getMessage();
// get document definition
$docFile = $this->getDownloadFile();
$nodesPerCall = $this->getRequestValue('nodesPerCall');
$cacheSection = $this->getRequestValue('cacheSection');
// check for iterator in session
$iterator = PersistentIterator::load($this->ITERATOR_ID_VAR, $persistenceFacade, $session);
// no iterator but oid given, start with new root oid
if ($iterator == null && sizeof($oids) > 0 && $oids[0] != null) {
$iterator = new PersistentIterator($this->ITERATOR_ID_VAR, $persistenceFacade, $session, $oids[0]);
}
// no iterator, no oid, finish
if ($iterator == null) {
$this->addWorkPackage($message->getText('Finish'), 1, [null], 'finishExport');
return;
}
// process nodes
$fileHandle = fopen($docFile, "a");
$counter = 0;
while ($iterator->valid() && $counter < $nodesPerCall) {
// write node
$this->writeNode($fileHandle, $iterator->current(), $iterator->key()+1);
$iterator->next();
$counter++;
}
$this->endTags($fileHandle, 0);
fclose($fileHandle);
// decide what to do next
$rootOIDs = $this->cache->get($cacheSection, self::CACHE_KEY_ROOT_OIDS);
if (!$iterator->valid() && sizeof($rootOIDs) > 0) {
// if the current iterator is finished, reset the iterator and proceed with the next root oid
$nextOID = array_shift($rootOIDs);
// store remaining root oids in the cache
$this->cache->put($cacheSection, self::CACHE_KEY_ROOT_OIDS, $rootOIDs);
// delete iterator to start with new root oid
PersistentIterator::reset($this->ITERATOR_ID_VAR, $session);
$name = $message->getText('Exporting tree: start with %0%', [$nextOID]);
$this->addWorkPackage($name, 1, [$nextOID], 'exportNodes');
}
elseif ($iterator->valid()) {
// proceed with current iterator
$iterator->save();
$name = $message->getText('Exporting tree: continue with %0%', [$iterator->current()]);
$this->addWorkPackage($name, 1, [null], 'exportNodes');
}
else {
// finish
$this->addWorkPackage($message->getText('Finish'), 1, [null], 'finishExport');
}
}
|
[
"protected",
"function",
"exportNodes",
"(",
"$",
"oids",
")",
"{",
"// Export starts from root oids and iterates over all children.",
"// On every call we have to decide what to do:",
"// - If there is an iterator stored in the session we are inside a tree and continue iterating (_NODES_PER_CALL nodes)",
"// until the iterator finishes",
"// - If the oids array holds one value!=null this is assumed to be an root oid and a new iterator is constructed",
"// - If there is no iterator and no oid given, we return",
"$",
"session",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
";",
"$",
"persistenceFacade",
"=",
"$",
"this",
"->",
"getPersistenceFacade",
"(",
")",
";",
"$",
"message",
"=",
"$",
"this",
"->",
"getMessage",
"(",
")",
";",
"// get document definition",
"$",
"docFile",
"=",
"$",
"this",
"->",
"getDownloadFile",
"(",
")",
";",
"$",
"nodesPerCall",
"=",
"$",
"this",
"->",
"getRequestValue",
"(",
"'nodesPerCall'",
")",
";",
"$",
"cacheSection",
"=",
"$",
"this",
"->",
"getRequestValue",
"(",
"'cacheSection'",
")",
";",
"// check for iterator in session",
"$",
"iterator",
"=",
"PersistentIterator",
"::",
"load",
"(",
"$",
"this",
"->",
"ITERATOR_ID_VAR",
",",
"$",
"persistenceFacade",
",",
"$",
"session",
")",
";",
"// no iterator but oid given, start with new root oid",
"if",
"(",
"$",
"iterator",
"==",
"null",
"&&",
"sizeof",
"(",
"$",
"oids",
")",
">",
"0",
"&&",
"$",
"oids",
"[",
"0",
"]",
"!=",
"null",
")",
"{",
"$",
"iterator",
"=",
"new",
"PersistentIterator",
"(",
"$",
"this",
"->",
"ITERATOR_ID_VAR",
",",
"$",
"persistenceFacade",
",",
"$",
"session",
",",
"$",
"oids",
"[",
"0",
"]",
")",
";",
"}",
"// no iterator, no oid, finish",
"if",
"(",
"$",
"iterator",
"==",
"null",
")",
"{",
"$",
"this",
"->",
"addWorkPackage",
"(",
"$",
"message",
"->",
"getText",
"(",
"'Finish'",
")",
",",
"1",
",",
"[",
"null",
"]",
",",
"'finishExport'",
")",
";",
"return",
";",
"}",
"// process nodes",
"$",
"fileHandle",
"=",
"fopen",
"(",
"$",
"docFile",
",",
"\"a\"",
")",
";",
"$",
"counter",
"=",
"0",
";",
"while",
"(",
"$",
"iterator",
"->",
"valid",
"(",
")",
"&&",
"$",
"counter",
"<",
"$",
"nodesPerCall",
")",
"{",
"// write node",
"$",
"this",
"->",
"writeNode",
"(",
"$",
"fileHandle",
",",
"$",
"iterator",
"->",
"current",
"(",
")",
",",
"$",
"iterator",
"->",
"key",
"(",
")",
"+",
"1",
")",
";",
"$",
"iterator",
"->",
"next",
"(",
")",
";",
"$",
"counter",
"++",
";",
"}",
"$",
"this",
"->",
"endTags",
"(",
"$",
"fileHandle",
",",
"0",
")",
";",
"fclose",
"(",
"$",
"fileHandle",
")",
";",
"// decide what to do next",
"$",
"rootOIDs",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"$",
"cacheSection",
",",
"self",
"::",
"CACHE_KEY_ROOT_OIDS",
")",
";",
"if",
"(",
"!",
"$",
"iterator",
"->",
"valid",
"(",
")",
"&&",
"sizeof",
"(",
"$",
"rootOIDs",
")",
">",
"0",
")",
"{",
"// if the current iterator is finished, reset the iterator and proceed with the next root oid",
"$",
"nextOID",
"=",
"array_shift",
"(",
"$",
"rootOIDs",
")",
";",
"// store remaining root oids in the cache",
"$",
"this",
"->",
"cache",
"->",
"put",
"(",
"$",
"cacheSection",
",",
"self",
"::",
"CACHE_KEY_ROOT_OIDS",
",",
"$",
"rootOIDs",
")",
";",
"// delete iterator to start with new root oid",
"PersistentIterator",
"::",
"reset",
"(",
"$",
"this",
"->",
"ITERATOR_ID_VAR",
",",
"$",
"session",
")",
";",
"$",
"name",
"=",
"$",
"message",
"->",
"getText",
"(",
"'Exporting tree: start with %0%'",
",",
"[",
"$",
"nextOID",
"]",
")",
";",
"$",
"this",
"->",
"addWorkPackage",
"(",
"$",
"name",
",",
"1",
",",
"[",
"$",
"nextOID",
"]",
",",
"'exportNodes'",
")",
";",
"}",
"elseif",
"(",
"$",
"iterator",
"->",
"valid",
"(",
")",
")",
"{",
"// proceed with current iterator",
"$",
"iterator",
"->",
"save",
"(",
")",
";",
"$",
"name",
"=",
"$",
"message",
"->",
"getText",
"(",
"'Exporting tree: continue with %0%'",
",",
"[",
"$",
"iterator",
"->",
"current",
"(",
")",
"]",
")",
";",
"$",
"this",
"->",
"addWorkPackage",
"(",
"$",
"name",
",",
"1",
",",
"[",
"null",
"]",
",",
"'exportNodes'",
")",
";",
"}",
"else",
"{",
"// finish",
"$",
"this",
"->",
"addWorkPackage",
"(",
"$",
"message",
"->",
"getText",
"(",
"'Finish'",
")",
",",
"1",
",",
"[",
"null",
"]",
",",
"'finishExport'",
")",
";",
"}",
"}"
] |
Serialize all Nodes with given object ids to XML
@param $oids The object ids to process
@note This is a callback method called on a matching work package, see BatchController::addWorkPackage()
|
[
"Serialize",
"all",
"Nodes",
"with",
"given",
"object",
"ids",
"to",
"XML"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/XMLExportController.php#L230-L295
|
26,913
|
iherwig/wcmf
|
src/wcmf/application/controller/XMLExportController.php
|
XMLExportController.writeNode
|
protected function writeNode($fileHandle, ObjectId $oid, $depth) {
$persistenceFacade = $this->getPersistenceFacade();
// get document definition
$docIndent = $this->getRequestValue('docIndent');
$docLinebreak = $this->getRequestValue('docLinebreak');
$cacheSection = $this->getRequestValue('cacheSection');
// get document state from cache
$lastIndent = $this->cache->get($cacheSection, self::CACHE_KEY_LAST_INDENT);
$tagsToClose = $this->cache->get($cacheSection, self::CACHE_KEY_TAGS_TO_CLOSE);
// load node and get element name
$node = $persistenceFacade->load($oid);
$elementName = $persistenceFacade->getSimpleType($node->getType());
// check if the node is written already
$exportedOids = $this->cache->get($cacheSection, self::CACHE_KEY_EXPORTED_OIDS);
if (!in_array($oid->__toString(), $exportedOids)) {
// write node
$mapper = $node->getMapper();
$hasUnvisitedChildren = $this->getNumUnvisitedChildren($node) > 0;
$curIndent = $depth;
$this->endTags($fileHandle, $curIndent);
// write object's content
// open start tag
$this->fileUtil->fputsUnicode($fileHandle, str_repeat($docIndent, $curIndent).'<'.$elementName);
// write object attributes
$attributes = $mapper->getAttributes();
foreach ($attributes as $curAttribute) {
$attributeName = $curAttribute->getName();
$value = $node->getValue($attributeName);
$this->fileUtil->fputsUnicode($fileHandle, ' '.$attributeName.'="'.$this->formatValue($value).'"');
}
// close start tag
$this->fileUtil->fputsUnicode($fileHandle, '>');
if ($hasUnvisitedChildren) {
$this->fileUtil->fputsUnicode($fileHandle, $docLinebreak);
}
// remember end tag if not closed
if ($hasUnvisitedChildren) {
$closeTag = ["name" => $elementName, "indent" => $curIndent];
array_unshift($tagsToClose, $closeTag);
}
else {
$this->fileUtil->fputsUnicode($fileHandle, '</'.$elementName.'>'.$docLinebreak);
}
// remember current indent
$lastIndent = $curIndent;
// register exported node
$exportedOids[] = $oid->__toString();
$this->cache->put($cacheSection, self::CACHE_KEY_EXPORTED_OIDS, $exportedOids);
}
// update document state in cache
$this->cache->put($cacheSection, self::CACHE_KEY_LAST_INDENT, $lastIndent);
$this->cache->put($cacheSection, self::CACHE_KEY_TAGS_TO_CLOSE, $tagsToClose);
}
|
php
|
protected function writeNode($fileHandle, ObjectId $oid, $depth) {
$persistenceFacade = $this->getPersistenceFacade();
// get document definition
$docIndent = $this->getRequestValue('docIndent');
$docLinebreak = $this->getRequestValue('docLinebreak');
$cacheSection = $this->getRequestValue('cacheSection');
// get document state from cache
$lastIndent = $this->cache->get($cacheSection, self::CACHE_KEY_LAST_INDENT);
$tagsToClose = $this->cache->get($cacheSection, self::CACHE_KEY_TAGS_TO_CLOSE);
// load node and get element name
$node = $persistenceFacade->load($oid);
$elementName = $persistenceFacade->getSimpleType($node->getType());
// check if the node is written already
$exportedOids = $this->cache->get($cacheSection, self::CACHE_KEY_EXPORTED_OIDS);
if (!in_array($oid->__toString(), $exportedOids)) {
// write node
$mapper = $node->getMapper();
$hasUnvisitedChildren = $this->getNumUnvisitedChildren($node) > 0;
$curIndent = $depth;
$this->endTags($fileHandle, $curIndent);
// write object's content
// open start tag
$this->fileUtil->fputsUnicode($fileHandle, str_repeat($docIndent, $curIndent).'<'.$elementName);
// write object attributes
$attributes = $mapper->getAttributes();
foreach ($attributes as $curAttribute) {
$attributeName = $curAttribute->getName();
$value = $node->getValue($attributeName);
$this->fileUtil->fputsUnicode($fileHandle, ' '.$attributeName.'="'.$this->formatValue($value).'"');
}
// close start tag
$this->fileUtil->fputsUnicode($fileHandle, '>');
if ($hasUnvisitedChildren) {
$this->fileUtil->fputsUnicode($fileHandle, $docLinebreak);
}
// remember end tag if not closed
if ($hasUnvisitedChildren) {
$closeTag = ["name" => $elementName, "indent" => $curIndent];
array_unshift($tagsToClose, $closeTag);
}
else {
$this->fileUtil->fputsUnicode($fileHandle, '</'.$elementName.'>'.$docLinebreak);
}
// remember current indent
$lastIndent = $curIndent;
// register exported node
$exportedOids[] = $oid->__toString();
$this->cache->put($cacheSection, self::CACHE_KEY_EXPORTED_OIDS, $exportedOids);
}
// update document state in cache
$this->cache->put($cacheSection, self::CACHE_KEY_LAST_INDENT, $lastIndent);
$this->cache->put($cacheSection, self::CACHE_KEY_TAGS_TO_CLOSE, $tagsToClose);
}
|
[
"protected",
"function",
"writeNode",
"(",
"$",
"fileHandle",
",",
"ObjectId",
"$",
"oid",
",",
"$",
"depth",
")",
"{",
"$",
"persistenceFacade",
"=",
"$",
"this",
"->",
"getPersistenceFacade",
"(",
")",
";",
"// get document definition",
"$",
"docIndent",
"=",
"$",
"this",
"->",
"getRequestValue",
"(",
"'docIndent'",
")",
";",
"$",
"docLinebreak",
"=",
"$",
"this",
"->",
"getRequestValue",
"(",
"'docLinebreak'",
")",
";",
"$",
"cacheSection",
"=",
"$",
"this",
"->",
"getRequestValue",
"(",
"'cacheSection'",
")",
";",
"// get document state from cache",
"$",
"lastIndent",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"$",
"cacheSection",
",",
"self",
"::",
"CACHE_KEY_LAST_INDENT",
")",
";",
"$",
"tagsToClose",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"$",
"cacheSection",
",",
"self",
"::",
"CACHE_KEY_TAGS_TO_CLOSE",
")",
";",
"// load node and get element name",
"$",
"node",
"=",
"$",
"persistenceFacade",
"->",
"load",
"(",
"$",
"oid",
")",
";",
"$",
"elementName",
"=",
"$",
"persistenceFacade",
"->",
"getSimpleType",
"(",
"$",
"node",
"->",
"getType",
"(",
")",
")",
";",
"// check if the node is written already",
"$",
"exportedOids",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"$",
"cacheSection",
",",
"self",
"::",
"CACHE_KEY_EXPORTED_OIDS",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"oid",
"->",
"__toString",
"(",
")",
",",
"$",
"exportedOids",
")",
")",
"{",
"// write node",
"$",
"mapper",
"=",
"$",
"node",
"->",
"getMapper",
"(",
")",
";",
"$",
"hasUnvisitedChildren",
"=",
"$",
"this",
"->",
"getNumUnvisitedChildren",
"(",
"$",
"node",
")",
">",
"0",
";",
"$",
"curIndent",
"=",
"$",
"depth",
";",
"$",
"this",
"->",
"endTags",
"(",
"$",
"fileHandle",
",",
"$",
"curIndent",
")",
";",
"// write object's content",
"// open start tag",
"$",
"this",
"->",
"fileUtil",
"->",
"fputsUnicode",
"(",
"$",
"fileHandle",
",",
"str_repeat",
"(",
"$",
"docIndent",
",",
"$",
"curIndent",
")",
".",
"'<'",
".",
"$",
"elementName",
")",
";",
"// write object attributes",
"$",
"attributes",
"=",
"$",
"mapper",
"->",
"getAttributes",
"(",
")",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"curAttribute",
")",
"{",
"$",
"attributeName",
"=",
"$",
"curAttribute",
"->",
"getName",
"(",
")",
";",
"$",
"value",
"=",
"$",
"node",
"->",
"getValue",
"(",
"$",
"attributeName",
")",
";",
"$",
"this",
"->",
"fileUtil",
"->",
"fputsUnicode",
"(",
"$",
"fileHandle",
",",
"' '",
".",
"$",
"attributeName",
".",
"'=\"'",
".",
"$",
"this",
"->",
"formatValue",
"(",
"$",
"value",
")",
".",
"'\"'",
")",
";",
"}",
"// close start tag",
"$",
"this",
"->",
"fileUtil",
"->",
"fputsUnicode",
"(",
"$",
"fileHandle",
",",
"'>'",
")",
";",
"if",
"(",
"$",
"hasUnvisitedChildren",
")",
"{",
"$",
"this",
"->",
"fileUtil",
"->",
"fputsUnicode",
"(",
"$",
"fileHandle",
",",
"$",
"docLinebreak",
")",
";",
"}",
"// remember end tag if not closed",
"if",
"(",
"$",
"hasUnvisitedChildren",
")",
"{",
"$",
"closeTag",
"=",
"[",
"\"name\"",
"=>",
"$",
"elementName",
",",
"\"indent\"",
"=>",
"$",
"curIndent",
"]",
";",
"array_unshift",
"(",
"$",
"tagsToClose",
",",
"$",
"closeTag",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"fileUtil",
"->",
"fputsUnicode",
"(",
"$",
"fileHandle",
",",
"'</'",
".",
"$",
"elementName",
".",
"'>'",
".",
"$",
"docLinebreak",
")",
";",
"}",
"// remember current indent",
"$",
"lastIndent",
"=",
"$",
"curIndent",
";",
"// register exported node",
"$",
"exportedOids",
"[",
"]",
"=",
"$",
"oid",
"->",
"__toString",
"(",
")",
";",
"$",
"this",
"->",
"cache",
"->",
"put",
"(",
"$",
"cacheSection",
",",
"self",
"::",
"CACHE_KEY_EXPORTED_OIDS",
",",
"$",
"exportedOids",
")",
";",
"}",
"// update document state in cache",
"$",
"this",
"->",
"cache",
"->",
"put",
"(",
"$",
"cacheSection",
",",
"self",
"::",
"CACHE_KEY_LAST_INDENT",
",",
"$",
"lastIndent",
")",
";",
"$",
"this",
"->",
"cache",
"->",
"put",
"(",
"$",
"cacheSection",
",",
"self",
"::",
"CACHE_KEY_TAGS_TO_CLOSE",
",",
"$",
"tagsToClose",
")",
";",
"}"
] |
Serialize a Node to XML
@param $fileHandle The file handle to write to
@param $oid The object id of the node
@param $depth The depth of the node in the tree
|
[
"Serialize",
"a",
"Node",
"to",
"XML"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/XMLExportController.php#L356-L418
|
26,914
|
iherwig/wcmf
|
src/wcmf/application/controller/XMLExportController.php
|
XMLExportController.getNumUnvisitedChildren
|
protected function getNumUnvisitedChildren(Node $node) {
$cacheSection = $this->getRequestValue('cacheSection');
$exportedOids = $this->cache->get($cacheSection, self::CACHE_KEY_EXPORTED_OIDS);
$childOIDs = [];
$mapper = $node->getMapper();
$relations = $mapper->getRelations('child');
foreach ($relations as $relation) {
if ($relation->getOtherNavigability()) {
$childValue = $node->getValue($relation->getOtherRole());
if ($childValue != null) {
$children = $relation->isMultiValued() ? $childValue : [$childValue];
foreach ($children as $child) {
$childOIDs[] = $child->getOID();
}
}
}
}
$numUnvisitedChildren = 0;
foreach ($childOIDs as $childOid) {
if (!in_array($childOid->__toString(), $exportedOids)) {
$numUnvisitedChildren++;
}
}
return $numUnvisitedChildren;
}
|
php
|
protected function getNumUnvisitedChildren(Node $node) {
$cacheSection = $this->getRequestValue('cacheSection');
$exportedOids = $this->cache->get($cacheSection, self::CACHE_KEY_EXPORTED_OIDS);
$childOIDs = [];
$mapper = $node->getMapper();
$relations = $mapper->getRelations('child');
foreach ($relations as $relation) {
if ($relation->getOtherNavigability()) {
$childValue = $node->getValue($relation->getOtherRole());
if ($childValue != null) {
$children = $relation->isMultiValued() ? $childValue : [$childValue];
foreach ($children as $child) {
$childOIDs[] = $child->getOID();
}
}
}
}
$numUnvisitedChildren = 0;
foreach ($childOIDs as $childOid) {
if (!in_array($childOid->__toString(), $exportedOids)) {
$numUnvisitedChildren++;
}
}
return $numUnvisitedChildren;
}
|
[
"protected",
"function",
"getNumUnvisitedChildren",
"(",
"Node",
"$",
"node",
")",
"{",
"$",
"cacheSection",
"=",
"$",
"this",
"->",
"getRequestValue",
"(",
"'cacheSection'",
")",
";",
"$",
"exportedOids",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"$",
"cacheSection",
",",
"self",
"::",
"CACHE_KEY_EXPORTED_OIDS",
")",
";",
"$",
"childOIDs",
"=",
"[",
"]",
";",
"$",
"mapper",
"=",
"$",
"node",
"->",
"getMapper",
"(",
")",
";",
"$",
"relations",
"=",
"$",
"mapper",
"->",
"getRelations",
"(",
"'child'",
")",
";",
"foreach",
"(",
"$",
"relations",
"as",
"$",
"relation",
")",
"{",
"if",
"(",
"$",
"relation",
"->",
"getOtherNavigability",
"(",
")",
")",
"{",
"$",
"childValue",
"=",
"$",
"node",
"->",
"getValue",
"(",
"$",
"relation",
"->",
"getOtherRole",
"(",
")",
")",
";",
"if",
"(",
"$",
"childValue",
"!=",
"null",
")",
"{",
"$",
"children",
"=",
"$",
"relation",
"->",
"isMultiValued",
"(",
")",
"?",
"$",
"childValue",
":",
"[",
"$",
"childValue",
"]",
";",
"foreach",
"(",
"$",
"children",
"as",
"$",
"child",
")",
"{",
"$",
"childOIDs",
"[",
"]",
"=",
"$",
"child",
"->",
"getOID",
"(",
")",
";",
"}",
"}",
"}",
"}",
"$",
"numUnvisitedChildren",
"=",
"0",
";",
"foreach",
"(",
"$",
"childOIDs",
"as",
"$",
"childOid",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"childOid",
"->",
"__toString",
"(",
")",
",",
"$",
"exportedOids",
")",
")",
"{",
"$",
"numUnvisitedChildren",
"++",
";",
"}",
"}",
"return",
"$",
"numUnvisitedChildren",
";",
"}"
] |
Get number of children of the given node, that were not visited yet
@param $node
@return Integer
|
[
"Get",
"number",
"of",
"children",
"of",
"the",
"given",
"node",
"that",
"were",
"not",
"visited",
"yet"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/XMLExportController.php#L425-L450
|
26,915
|
iherwig/wcmf
|
src/wcmf/lib/presentation/format/impl/CacheTrait.php
|
CacheTrait.putInCache
|
protected function putInCache(Response $response, $payload) {
$this->getCache()->put($this->getCacheSection($response), $response->getCacheId(), $payload, $response->getCacheLifetime());
}
|
php
|
protected function putInCache(Response $response, $payload) {
$this->getCache()->put($this->getCacheSection($response), $response->getCacheId(), $payload, $response->getCacheLifetime());
}
|
[
"protected",
"function",
"putInCache",
"(",
"Response",
"$",
"response",
",",
"$",
"payload",
")",
"{",
"$",
"this",
"->",
"getCache",
"(",
")",
"->",
"put",
"(",
"$",
"this",
"->",
"getCacheSection",
"(",
"$",
"response",
")",
",",
"$",
"response",
"->",
"getCacheId",
"(",
")",
",",
"$",
"payload",
",",
"$",
"response",
"->",
"getCacheLifetime",
"(",
")",
")",
";",
"}"
] |
Store the payload of the response in the cache.
@param $response
@param $payload String
|
[
"Store",
"the",
"payload",
"of",
"the",
"response",
"in",
"the",
"cache",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/presentation/format/impl/CacheTrait.php#L78-L80
|
26,916
|
iherwig/wcmf
|
src/wcmf/lib/presentation/format/impl/CacheTrait.php
|
CacheTrait.getFromCache
|
protected function getFromCache(Response $response) {
return $this->getCache()->get($this->getCacheSection($response), $response->getCacheId());
}
|
php
|
protected function getFromCache(Response $response) {
return $this->getCache()->get($this->getCacheSection($response), $response->getCacheId());
}
|
[
"protected",
"function",
"getFromCache",
"(",
"Response",
"$",
"response",
")",
"{",
"return",
"$",
"this",
"->",
"getCache",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"getCacheSection",
"(",
"$",
"response",
")",
",",
"$",
"response",
"->",
"getCacheId",
"(",
")",
")",
";",
"}"
] |
Load the payload of the response from the cache.
@param $response
@return String
|
[
"Load",
"the",
"payload",
"of",
"the",
"response",
"from",
"the",
"cache",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/presentation/format/impl/CacheTrait.php#L87-L89
|
26,917
|
iherwig/wcmf
|
src/wcmf/lib/service/impl/RPCClient.php
|
RPCClient.setSessionId
|
protected function setSessionId($sessionId) {
$session = ObjectFactory::getInstance('session');
$sids = $session->get(self::SIDS_SESSION_VARNAME);
$sids[$this->serverCli] = $sessionId;
$session->set(self::SIDS_SESSION_VARNAME, $sids);
}
|
php
|
protected function setSessionId($sessionId) {
$session = ObjectFactory::getInstance('session');
$sids = $session->get(self::SIDS_SESSION_VARNAME);
$sids[$this->serverCli] = $sessionId;
$session->set(self::SIDS_SESSION_VARNAME, $sids);
}
|
[
"protected",
"function",
"setSessionId",
"(",
"$",
"sessionId",
")",
"{",
"$",
"session",
"=",
"ObjectFactory",
"::",
"getInstance",
"(",
"'session'",
")",
";",
"$",
"sids",
"=",
"$",
"session",
"->",
"get",
"(",
"self",
"::",
"SIDS_SESSION_VARNAME",
")",
";",
"$",
"sids",
"[",
"$",
"this",
"->",
"serverCli",
"]",
"=",
"$",
"sessionId",
";",
"$",
"session",
"->",
"set",
"(",
"self",
"::",
"SIDS_SESSION_VARNAME",
",",
"$",
"sids",
")",
";",
"}"
] |
Store the session id for our server in the local session
@return The session id or null
|
[
"Store",
"the",
"session",
"id",
"for",
"our",
"server",
"in",
"the",
"local",
"session"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/service/impl/RPCClient.php#L164-L169
|
26,918
|
iherwig/wcmf
|
src/wcmf/lib/service/impl/RPCClient.php
|
RPCClient.getSessionId
|
protected function getSessionId() {
// check if we already have a session with the server
$session = ObjectFactory::getInstance('session');
$sids = $session->get(self::SIDS_SESSION_VARNAME);
if (isset($sids[$this->serverCli])) {
return $sids[$this->serverCli];
}
return null;
}
|
php
|
protected function getSessionId() {
// check if we already have a session with the server
$session = ObjectFactory::getInstance('session');
$sids = $session->get(self::SIDS_SESSION_VARNAME);
if (isset($sids[$this->serverCli])) {
return $sids[$this->serverCli];
}
return null;
}
|
[
"protected",
"function",
"getSessionId",
"(",
")",
"{",
"// check if we already have a session with the server",
"$",
"session",
"=",
"ObjectFactory",
"::",
"getInstance",
"(",
"'session'",
")",
";",
"$",
"sids",
"=",
"$",
"session",
"->",
"get",
"(",
"self",
"::",
"SIDS_SESSION_VARNAME",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"sids",
"[",
"$",
"this",
"->",
"serverCli",
"]",
")",
")",
"{",
"return",
"$",
"sids",
"[",
"$",
"this",
"->",
"serverCli",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Get the session id for our server from the local session
@return The session id or null
|
[
"Get",
"the",
"session",
"id",
"for",
"our",
"server",
"from",
"the",
"local",
"session"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/service/impl/RPCClient.php#L175-L183
|
26,919
|
thelfensdrfer/yii2sshconsole
|
src/Controller.php
|
Controller.connect
|
public function connect($host, $auth, $port = 22, $timeout = 10)
{
$this->ssh = new SSH2($host, $port, $timeout);
if (!isset($auth['key']) && isset($auth['username'])) {
// Login via username/password
$username = $auth['username'];
$password = isset($auth['password']) ? $auth['password'] : '';
if (!$this->ssh->login($username, $password))
throw new LoginFailedException(Yii::t(
'Yii2SshConsole',
'Login failed for user {username} using password {answer}!',
[
'username' => $username,
'answer' => !empty($password) ? 1 : 0
]
));
else
return true;
} elseif (isset($auth['key']) and isset($auth['username'])) {
// Login via private key
$username = $auth['username'];
$password = isset($auth['key_password']) ? $auth['key_password'] : '';
$key = new RSA;
if (!empty($password)) {
$key->setPassword($password);
}
$key->loadKey(file_get_contents($auth['key']));
if (!$this->ssh->login($username, $key))
throw new LoginFailedException(Yii::t(
'Yii2SshConsole',
'Login failed for user {username} using key with password {answer}!',
[
'username' => $username,
'answer' => !empty($password) ? 1 : 0
]
));
else
return true;
} else {
// No username given
throw new LoginUnknownException(Yii::t(
'Yii2SshConsole',
'No username given!'
));
}
return false;
}
|
php
|
public function connect($host, $auth, $port = 22, $timeout = 10)
{
$this->ssh = new SSH2($host, $port, $timeout);
if (!isset($auth['key']) && isset($auth['username'])) {
// Login via username/password
$username = $auth['username'];
$password = isset($auth['password']) ? $auth['password'] : '';
if (!$this->ssh->login($username, $password))
throw new LoginFailedException(Yii::t(
'Yii2SshConsole',
'Login failed for user {username} using password {answer}!',
[
'username' => $username,
'answer' => !empty($password) ? 1 : 0
]
));
else
return true;
} elseif (isset($auth['key']) and isset($auth['username'])) {
// Login via private key
$username = $auth['username'];
$password = isset($auth['key_password']) ? $auth['key_password'] : '';
$key = new RSA;
if (!empty($password)) {
$key->setPassword($password);
}
$key->loadKey(file_get_contents($auth['key']));
if (!$this->ssh->login($username, $key))
throw new LoginFailedException(Yii::t(
'Yii2SshConsole',
'Login failed for user {username} using key with password {answer}!',
[
'username' => $username,
'answer' => !empty($password) ? 1 : 0
]
));
else
return true;
} else {
// No username given
throw new LoginUnknownException(Yii::t(
'Yii2SshConsole',
'No username given!'
));
}
return false;
}
|
[
"public",
"function",
"connect",
"(",
"$",
"host",
",",
"$",
"auth",
",",
"$",
"port",
"=",
"22",
",",
"$",
"timeout",
"=",
"10",
")",
"{",
"$",
"this",
"->",
"ssh",
"=",
"new",
"SSH2",
"(",
"$",
"host",
",",
"$",
"port",
",",
"$",
"timeout",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"auth",
"[",
"'key'",
"]",
")",
"&&",
"isset",
"(",
"$",
"auth",
"[",
"'username'",
"]",
")",
")",
"{",
"// Login via username/password",
"$",
"username",
"=",
"$",
"auth",
"[",
"'username'",
"]",
";",
"$",
"password",
"=",
"isset",
"(",
"$",
"auth",
"[",
"'password'",
"]",
")",
"?",
"$",
"auth",
"[",
"'password'",
"]",
":",
"''",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"ssh",
"->",
"login",
"(",
"$",
"username",
",",
"$",
"password",
")",
")",
"throw",
"new",
"LoginFailedException",
"(",
"Yii",
"::",
"t",
"(",
"'Yii2SshConsole'",
",",
"'Login failed for user {username} using password {answer}!'",
",",
"[",
"'username'",
"=>",
"$",
"username",
",",
"'answer'",
"=>",
"!",
"empty",
"(",
"$",
"password",
")",
"?",
"1",
":",
"0",
"]",
")",
")",
";",
"else",
"return",
"true",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"auth",
"[",
"'key'",
"]",
")",
"and",
"isset",
"(",
"$",
"auth",
"[",
"'username'",
"]",
")",
")",
"{",
"// Login via private key",
"$",
"username",
"=",
"$",
"auth",
"[",
"'username'",
"]",
";",
"$",
"password",
"=",
"isset",
"(",
"$",
"auth",
"[",
"'key_password'",
"]",
")",
"?",
"$",
"auth",
"[",
"'key_password'",
"]",
":",
"''",
";",
"$",
"key",
"=",
"new",
"RSA",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"password",
")",
")",
"{",
"$",
"key",
"->",
"setPassword",
"(",
"$",
"password",
")",
";",
"}",
"$",
"key",
"->",
"loadKey",
"(",
"file_get_contents",
"(",
"$",
"auth",
"[",
"'key'",
"]",
")",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"ssh",
"->",
"login",
"(",
"$",
"username",
",",
"$",
"key",
")",
")",
"throw",
"new",
"LoginFailedException",
"(",
"Yii",
"::",
"t",
"(",
"'Yii2SshConsole'",
",",
"'Login failed for user {username} using key with password {answer}!'",
",",
"[",
"'username'",
"=>",
"$",
"username",
",",
"'answer'",
"=>",
"!",
"empty",
"(",
"$",
"password",
")",
"?",
"1",
":",
"0",
"]",
")",
")",
";",
"else",
"return",
"true",
";",
"}",
"else",
"{",
"// No username given",
"throw",
"new",
"LoginUnknownException",
"(",
"Yii",
"::",
"t",
"(",
"'Yii2SshConsole'",
",",
"'No username given!'",
")",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Connect to the ssh server.
@param string $host
@param array $auth
Login via username/password
[
'username' => 'myname',
'password' => 'mypassword', // can be empty
]
or via private key
[
'key' => '/path/to/private.key',
'password' => 'mykeypassword', // can be empty
]
@param integer $port Default 22
@param integer $timeout Default 10 seconds
@throws \yii2sshconsole\LoginFailedException If the login failes
@throws \yii2sshconsole\LoginUnknownException If no username is set
@return bool
|
[
"Connect",
"to",
"the",
"ssh",
"server",
"."
] |
7699c4cd0cddacd07a2236ca10f06ec384b2aa54
|
https://github.com/thelfensdrfer/yii2sshconsole/blob/7699c4cd0cddacd07a2236ca10f06ec384b2aa54/src/Controller.php#L43-L97
|
26,920
|
thelfensdrfer/yii2sshconsole
|
src/Controller.php
|
Controller.readLine
|
public function readLine()
{
$output = $this->ssh->_get_channel_packet(SSH2::CHANNEL_EXEC);
return $output === true ? null : $output;
}
|
php
|
public function readLine()
{
$output = $this->ssh->_get_channel_packet(SSH2::CHANNEL_EXEC);
return $output === true ? null : $output;
}
|
[
"public",
"function",
"readLine",
"(",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"ssh",
"->",
"_get_channel_packet",
"(",
"SSH2",
"::",
"CHANNEL_EXEC",
")",
";",
"return",
"$",
"output",
"===",
"true",
"?",
"null",
":",
"$",
"output",
";",
"}"
] |
Read the next line from the SSH session.
@return string|null
|
[
"Read",
"the",
"next",
"line",
"from",
"the",
"SSH",
"session",
"."
] |
7699c4cd0cddacd07a2236ca10f06ec384b2aa54
|
https://github.com/thelfensdrfer/yii2sshconsole/blob/7699c4cd0cddacd07a2236ca10f06ec384b2aa54/src/Controller.php#L104-L109
|
26,921
|
thelfensdrfer/yii2sshconsole
|
src/Controller.php
|
Controller.run
|
public function run($commands, $callback = null)
{
if (!$this->ssh->isConnected())
throw new NotConnectedException();
if (is_array($commands))
$commands = implode(' && ', $commands);
if ($callback === null)
$output = '';
$this->ssh->exec($commands, false);
while (true) {
if (is_null($line = $this->readLine())) break;
if ($callback === null)
$output .= $line;
else
call_user_func($callback, $line, $this);
}
if ($callback === null)
return $output;
else
return null;
}
|
php
|
public function run($commands, $callback = null)
{
if (!$this->ssh->isConnected())
throw new NotConnectedException();
if (is_array($commands))
$commands = implode(' && ', $commands);
if ($callback === null)
$output = '';
$this->ssh->exec($commands, false);
while (true) {
if (is_null($line = $this->readLine())) break;
if ($callback === null)
$output .= $line;
else
call_user_func($callback, $line, $this);
}
if ($callback === null)
return $output;
else
return null;
}
|
[
"public",
"function",
"run",
"(",
"$",
"commands",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"ssh",
"->",
"isConnected",
"(",
")",
")",
"throw",
"new",
"NotConnectedException",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"commands",
")",
")",
"$",
"commands",
"=",
"implode",
"(",
"' && '",
",",
"$",
"commands",
")",
";",
"if",
"(",
"$",
"callback",
"===",
"null",
")",
"$",
"output",
"=",
"''",
";",
"$",
"this",
"->",
"ssh",
"->",
"exec",
"(",
"$",
"commands",
",",
"false",
")",
";",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"line",
"=",
"$",
"this",
"->",
"readLine",
"(",
")",
")",
")",
"break",
";",
"if",
"(",
"$",
"callback",
"===",
"null",
")",
"$",
"output",
".=",
"$",
"line",
";",
"else",
"call_user_func",
"(",
"$",
"callback",
",",
"$",
"line",
",",
"$",
"this",
")",
";",
"}",
"if",
"(",
"$",
"callback",
"===",
"null",
")",
"return",
"$",
"output",
";",
"else",
"return",
"null",
";",
"}"
] |
Run a ssh command for the current connection.
@param string|array $commands
@param callable $callback
@throws NotConnectedException If the client is not connected to the server
@return string|null
|
[
"Run",
"a",
"ssh",
"command",
"for",
"the",
"current",
"connection",
"."
] |
7699c4cd0cddacd07a2236ca10f06ec384b2aa54
|
https://github.com/thelfensdrfer/yii2sshconsole/blob/7699c4cd0cddacd07a2236ca10f06ec384b2aa54/src/Controller.php#L121-L147
|
26,922
|
pr-of-it/t4
|
framework/Dbal/Query.php
|
Query.insert
|
public function insert($tables = null)
{
if (null !== $tables) {
$this->tables($tables);
}
$this->action = 'insert';
return $this;
}
|
php
|
public function insert($tables = null)
{
if (null !== $tables) {
$this->tables($tables);
}
$this->action = 'insert';
return $this;
}
|
[
"public",
"function",
"insert",
"(",
"$",
"tables",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"tables",
")",
"{",
"$",
"this",
"->",
"tables",
"(",
"$",
"tables",
")",
";",
"}",
"$",
"this",
"->",
"action",
"=",
"'insert'",
";",
"return",
"$",
"this",
";",
"}"
] |
Set all tables and set action to insert
@param mixed $tables
@return $this
|
[
"Set",
"all",
"tables",
"and",
"set",
"action",
"to",
"insert"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Dbal/Query.php#L168-L175
|
26,923
|
pr-of-it/t4
|
framework/Dbal/Query.php
|
Query.update
|
public function update($tables = null)
{
if (null !== $tables) {
$this->tables($tables);
}
$this->action = 'update';
return $this;
}
|
php
|
public function update($tables = null)
{
if (null !== $tables) {
$this->tables($tables);
}
$this->action = 'update';
return $this;
}
|
[
"public",
"function",
"update",
"(",
"$",
"tables",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"tables",
")",
"{",
"$",
"this",
"->",
"tables",
"(",
"$",
"tables",
")",
";",
"}",
"$",
"this",
"->",
"action",
"=",
"'update'",
";",
"return",
"$",
"this",
";",
"}"
] |
Set all tables and set action to update
@param mixed $tables
@return $this
|
[
"Set",
"all",
"tables",
"and",
"set",
"action",
"to",
"update"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Dbal/Query.php#L182-L189
|
26,924
|
pr-of-it/t4
|
framework/Dbal/Query.php
|
Query.delete
|
public function delete($tables = null)
{
if (null !== $tables) {
$this->tables($tables);
}
$this->action = 'delete';
return $this;
}
|
php
|
public function delete($tables = null)
{
if (null !== $tables) {
$this->tables($tables);
}
$this->action = 'delete';
return $this;
}
|
[
"public",
"function",
"delete",
"(",
"$",
"tables",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"tables",
")",
"{",
"$",
"this",
"->",
"tables",
"(",
"$",
"tables",
")",
";",
"}",
"$",
"this",
"->",
"action",
"=",
"'delete'",
";",
"return",
"$",
"this",
";",
"}"
] |
Set all tables and set action to delete
@param mixed $tables
@return $this
|
[
"Set",
"all",
"tables",
"and",
"set",
"action",
"to",
"delete"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Dbal/Query.php#L196-L203
|
26,925
|
pr-of-it/t4
|
framework/Dbal/Query.php
|
Query.table
|
public function table($table = [])
{
$tables = $this->prepareNames(func_get_args());
$this->tables = array_merge($this->tables ?: [], $tables);
return $this;
}
|
php
|
public function table($table = [])
{
$tables = $this->prepareNames(func_get_args());
$this->tables = array_merge($this->tables ?: [], $tables);
return $this;
}
|
[
"public",
"function",
"table",
"(",
"$",
"table",
"=",
"[",
"]",
")",
"{",
"$",
"tables",
"=",
"$",
"this",
"->",
"prepareNames",
"(",
"func_get_args",
"(",
")",
")",
";",
"$",
"this",
"->",
"tables",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"tables",
"?",
":",
"[",
"]",
",",
"$",
"tables",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add one table to query
@param mixed $table
@return $this
|
[
"Add",
"one",
"table",
"to",
"query"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Dbal/Query.php#L210-L215
|
26,926
|
pr-of-it/t4
|
framework/Dbal/Query.php
|
Query.column
|
public function column($column = '*')
{
if ('*' == $column) {
$this->columns = ['*'];
} else {
$columns = $this->prepareNames(func_get_args());
$this->columns = array_merge(
empty($this->columns) || ['*'] == $this->columns ? [] : $this->columns,
array_values(array_diff($columns, ['*']))
);
}
return $this;
}
|
php
|
public function column($column = '*')
{
if ('*' == $column) {
$this->columns = ['*'];
} else {
$columns = $this->prepareNames(func_get_args());
$this->columns = array_merge(
empty($this->columns) || ['*'] == $this->columns ? [] : $this->columns,
array_values(array_diff($columns, ['*']))
);
}
return $this;
}
|
[
"public",
"function",
"column",
"(",
"$",
"column",
"=",
"'*'",
")",
"{",
"if",
"(",
"'*'",
"==",
"$",
"column",
")",
"{",
"$",
"this",
"->",
"columns",
"=",
"[",
"'*'",
"]",
";",
"}",
"else",
"{",
"$",
"columns",
"=",
"$",
"this",
"->",
"prepareNames",
"(",
"func_get_args",
"(",
")",
")",
";",
"$",
"this",
"->",
"columns",
"=",
"array_merge",
"(",
"empty",
"(",
"$",
"this",
"->",
"columns",
")",
"||",
"[",
"'*'",
"]",
"==",
"$",
"this",
"->",
"columns",
"?",
"[",
"]",
":",
"$",
"this",
"->",
"columns",
",",
"array_values",
"(",
"array_diff",
"(",
"$",
"columns",
",",
"[",
"'*'",
"]",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add one column name to query
@param mixed $column
@return $this
|
[
"Add",
"one",
"column",
"name",
"to",
"query"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Dbal/Query.php#L234-L246
|
26,927
|
pr-of-it/t4
|
framework/Dbal/Query.php
|
Query.columns
|
public function columns($columns = '*')
{
if ('*' == $columns) {
$this->columns = ['*'];
} else {
$columns = $this->prepareNames(func_get_args());
$this->columns = array_values(array_diff($columns, ['*']));
}
return $this;
}
|
php
|
public function columns($columns = '*')
{
if ('*' == $columns) {
$this->columns = ['*'];
} else {
$columns = $this->prepareNames(func_get_args());
$this->columns = array_values(array_diff($columns, ['*']));
}
return $this;
}
|
[
"public",
"function",
"columns",
"(",
"$",
"columns",
"=",
"'*'",
")",
"{",
"if",
"(",
"'*'",
"==",
"$",
"columns",
")",
"{",
"$",
"this",
"->",
"columns",
"=",
"[",
"'*'",
"]",
";",
"}",
"else",
"{",
"$",
"columns",
"=",
"$",
"this",
"->",
"prepareNames",
"(",
"func_get_args",
"(",
")",
")",
";",
"$",
"this",
"->",
"columns",
"=",
"array_values",
"(",
"array_diff",
"(",
"$",
"columns",
",",
"[",
"'*'",
"]",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set all query's columns
@param mixed $columns
@return $this
|
[
"Set",
"all",
"query",
"s",
"columns"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Dbal/Query.php#L253-L262
|
26,928
|
pr-of-it/t4
|
framework/Dbal/Query.php
|
Query.join
|
public function join($table, $on, $type = 'full', $alias = '')
{
if (!isset($this->joins)) {
$this->joins = [];
}
$join = [
'table' => $this->trimName($table),
'on' => $on,
'type' => $type,
];
if (!empty($alias)) {
$join['alias'] = $this->trimName($alias);
}
$this->joins = array_merge($this->joins, [$join]);
return $this;
}
|
php
|
public function join($table, $on, $type = 'full', $alias = '')
{
if (!isset($this->joins)) {
$this->joins = [];
}
$join = [
'table' => $this->trimName($table),
'on' => $on,
'type' => $type,
];
if (!empty($alias)) {
$join['alias'] = $this->trimName($alias);
}
$this->joins = array_merge($this->joins, [$join]);
return $this;
}
|
[
"public",
"function",
"join",
"(",
"$",
"table",
",",
"$",
"on",
",",
"$",
"type",
"=",
"'full'",
",",
"$",
"alias",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"joins",
")",
")",
"{",
"$",
"this",
"->",
"joins",
"=",
"[",
"]",
";",
"}",
"$",
"join",
"=",
"[",
"'table'",
"=>",
"$",
"this",
"->",
"trimName",
"(",
"$",
"table",
")",
",",
"'on'",
"=>",
"$",
"on",
",",
"'type'",
"=>",
"$",
"type",
",",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"alias",
")",
")",
"{",
"$",
"join",
"[",
"'alias'",
"]",
"=",
"$",
"this",
"->",
"trimName",
"(",
"$",
"alias",
")",
";",
"}",
"$",
"this",
"->",
"joins",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"joins",
",",
"[",
"$",
"join",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add one join statement to query
@param string $table
@param string $on
@param string $type
@param string $alias
@return $this
|
[
"Add",
"one",
"join",
"statement",
"to",
"query"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Dbal/Query.php#L272-L287
|
26,929
|
pr-of-it/t4
|
framework/Dbal/Query.php
|
Query.joins
|
public function joins($joins)
{
$this->joins = [];
foreach ($joins as $join) {
$j = [
'table' => $this->trimName($join['table']),
'on' => $join['on'],
'type' => $join['type'],
];
if (!empty($alias)) {
$j['alias'] = $this->trimName($join['alias']);
}
$this->joins = array_merge($this->joins, [$join]);
}
return $this;
}
|
php
|
public function joins($joins)
{
$this->joins = [];
foreach ($joins as $join) {
$j = [
'table' => $this->trimName($join['table']),
'on' => $join['on'],
'type' => $join['type'],
];
if (!empty($alias)) {
$j['alias'] = $this->trimName($join['alias']);
}
$this->joins = array_merge($this->joins, [$join]);
}
return $this;
}
|
[
"public",
"function",
"joins",
"(",
"$",
"joins",
")",
"{",
"$",
"this",
"->",
"joins",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"joins",
"as",
"$",
"join",
")",
"{",
"$",
"j",
"=",
"[",
"'table'",
"=>",
"$",
"this",
"->",
"trimName",
"(",
"$",
"join",
"[",
"'table'",
"]",
")",
",",
"'on'",
"=>",
"$",
"join",
"[",
"'on'",
"]",
",",
"'type'",
"=>",
"$",
"join",
"[",
"'type'",
"]",
",",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"alias",
")",
")",
"{",
"$",
"j",
"[",
"'alias'",
"]",
"=",
"$",
"this",
"->",
"trimName",
"(",
"$",
"join",
"[",
"'alias'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"joins",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"joins",
",",
"[",
"$",
"join",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set all query's joins
@param array $joins
@return $this
|
[
"Set",
"all",
"query",
"s",
"joins"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Dbal/Query.php#L294-L309
|
26,930
|
pr-of-it/t4
|
framework/Dbal/Query.php
|
Query.group
|
public function group($group)
{
$group = $this->prepareNames(func_get_args(), false);
$this->group = $group;
return $this;
}
|
php
|
public function group($group)
{
$group = $this->prepareNames(func_get_args(), false);
$this->group = $group;
return $this;
}
|
[
"public",
"function",
"group",
"(",
"$",
"group",
")",
"{",
"$",
"group",
"=",
"$",
"this",
"->",
"prepareNames",
"(",
"func_get_args",
"(",
")",
",",
"false",
")",
";",
"$",
"this",
"->",
"group",
"=",
"$",
"group",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets group values
@param string $group
@return $this
|
[
"Sets",
"group",
"values"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Dbal/Query.php#L327-L332
|
26,931
|
pr-of-it/t4
|
framework/Dbal/Query.php
|
Query.order
|
public function order($order)
{
$order = $this->prepareNames(func_get_args(),false);
$this->order = $order;
return $this;
}
|
php
|
public function order($order)
{
$order = $this->prepareNames(func_get_args(),false);
$this->order = $order;
return $this;
}
|
[
"public",
"function",
"order",
"(",
"$",
"order",
")",
"{",
"$",
"order",
"=",
"$",
"this",
"->",
"prepareNames",
"(",
"func_get_args",
"(",
")",
",",
"false",
")",
";",
"$",
"this",
"->",
"order",
"=",
"$",
"order",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets order directions
@param string $order
@return $this
|
[
"Sets",
"order",
"directions"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Dbal/Query.php#L350-L355
|
26,932
|
pr-of-it/t4
|
framework/Dbal/Query.php
|
Query.value
|
public function value($key, $value)
{
$this->values = array_merge($this->values ?? [], [$this->trimName($key) => $value]);
return $this;
}
|
php
|
public function value($key, $value)
{
$this->values = array_merge($this->values ?? [], [$this->trimName($key) => $value]);
return $this;
}
|
[
"public",
"function",
"value",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"values",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"values",
"??",
"[",
"]",
",",
"[",
"$",
"this",
"->",
"trimName",
"(",
"$",
"key",
")",
"=>",
"$",
"value",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add one query's value for insert
@param string $key
@param mixed $value
@return $this
|
[
"Add",
"one",
"query",
"s",
"value",
"for",
"insert"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Dbal/Query.php#L385-L389
|
26,933
|
pr-of-it/t4
|
framework/Dbal/Query.php
|
Query.values
|
public function values(array $values = [])
{
$values = array_combine(array_map([$this, 'trimName'], array_keys($values)), array_values($values));
$this->values = $values;
return $this;
}
|
php
|
public function values(array $values = [])
{
$values = array_combine(array_map([$this, 'trimName'], array_keys($values)), array_values($values));
$this->values = $values;
return $this;
}
|
[
"public",
"function",
"values",
"(",
"array",
"$",
"values",
"=",
"[",
"]",
")",
"{",
"$",
"values",
"=",
"array_combine",
"(",
"array_map",
"(",
"[",
"$",
"this",
",",
"'trimName'",
"]",
",",
"array_keys",
"(",
"$",
"values",
")",
")",
",",
"array_values",
"(",
"$",
"values",
")",
")",
";",
"$",
"this",
"->",
"values",
"=",
"$",
"values",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets all query's values for insert
@param array $values
@return $this
|
[
"Sets",
"all",
"query",
"s",
"values",
"for",
"insert"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Dbal/Query.php#L396-L401
|
26,934
|
pr-of-it/t4
|
framework/Dbal/Query.php
|
Query.param
|
public function param($key, $value)
{
$this->params = array_merge($this->params ?? [], [$key => $value]);
return $this;
}
|
php
|
public function param($key, $value)
{
$this->params = array_merge($this->params ?? [], [$key => $value]);
return $this;
}
|
[
"public",
"function",
"param",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"params",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"params",
"??",
"[",
"]",
",",
"[",
"$",
"key",
"=>",
"$",
"value",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets one bind parameter
@param string $key
@param mixed $value
@return $this
|
[
"Sets",
"one",
"bind",
"parameter"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Dbal/Query.php#L409-L413
|
26,935
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/AccessControlConfig.php
|
CKFinder_Connector_Core_AccessControlConfig.addACLEntry
|
private function addACLEntry($role, $resourceType, $folderPath, $allowRulesMask, $denyRulesMask)
{
if (!strlen($folderPath)) {
$folderPath = '/';
}
else {
if (substr($folderPath,0,1) != '/') {
$folderPath = '/' . $folderPath;
}
if (substr($folderPath,-1,1) != '/') {
$folderPath .= '/';
}
}
$_entryKey = $role . "#@#" . $resourceType;
if (array_key_exists($folderPath,$this->_aclEntries)) {
if (array_key_exists($_entryKey, $this->_aclEntries[$folderPath])) {
$_rulesMasks = $this->_aclEntries[$folderPath][$_entryKey];
foreach ($_rulesMasks[0] as $key => $value) {
$allowRulesMask[$key] |= $value;
}
foreach ($_rulesMasks[1] as $key => $value) {
$denyRulesMask[$key] |= $value;
}
}
}
else {
$this->_aclEntries[$folderPath] = array();
}
$this->_aclEntries[$folderPath][$_entryKey] = array($allowRulesMask, $denyRulesMask);
}
|
php
|
private function addACLEntry($role, $resourceType, $folderPath, $allowRulesMask, $denyRulesMask)
{
if (!strlen($folderPath)) {
$folderPath = '/';
}
else {
if (substr($folderPath,0,1) != '/') {
$folderPath = '/' . $folderPath;
}
if (substr($folderPath,-1,1) != '/') {
$folderPath .= '/';
}
}
$_entryKey = $role . "#@#" . $resourceType;
if (array_key_exists($folderPath,$this->_aclEntries)) {
if (array_key_exists($_entryKey, $this->_aclEntries[$folderPath])) {
$_rulesMasks = $this->_aclEntries[$folderPath][$_entryKey];
foreach ($_rulesMasks[0] as $key => $value) {
$allowRulesMask[$key] |= $value;
}
foreach ($_rulesMasks[1] as $key => $value) {
$denyRulesMask[$key] |= $value;
}
}
}
else {
$this->_aclEntries[$folderPath] = array();
}
$this->_aclEntries[$folderPath][$_entryKey] = array($allowRulesMask, $denyRulesMask);
}
|
[
"private",
"function",
"addACLEntry",
"(",
"$",
"role",
",",
"$",
"resourceType",
",",
"$",
"folderPath",
",",
"$",
"allowRulesMask",
",",
"$",
"denyRulesMask",
")",
"{",
"if",
"(",
"!",
"strlen",
"(",
"$",
"folderPath",
")",
")",
"{",
"$",
"folderPath",
"=",
"'/'",
";",
"}",
"else",
"{",
"if",
"(",
"substr",
"(",
"$",
"folderPath",
",",
"0",
",",
"1",
")",
"!=",
"'/'",
")",
"{",
"$",
"folderPath",
"=",
"'/'",
".",
"$",
"folderPath",
";",
"}",
"if",
"(",
"substr",
"(",
"$",
"folderPath",
",",
"-",
"1",
",",
"1",
")",
"!=",
"'/'",
")",
"{",
"$",
"folderPath",
".=",
"'/'",
";",
"}",
"}",
"$",
"_entryKey",
"=",
"$",
"role",
".",
"\"#@#\"",
".",
"$",
"resourceType",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"folderPath",
",",
"$",
"this",
"->",
"_aclEntries",
")",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"_entryKey",
",",
"$",
"this",
"->",
"_aclEntries",
"[",
"$",
"folderPath",
"]",
")",
")",
"{",
"$",
"_rulesMasks",
"=",
"$",
"this",
"->",
"_aclEntries",
"[",
"$",
"folderPath",
"]",
"[",
"$",
"_entryKey",
"]",
";",
"foreach",
"(",
"$",
"_rulesMasks",
"[",
"0",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"allowRulesMask",
"[",
"$",
"key",
"]",
"|=",
"$",
"value",
";",
"}",
"foreach",
"(",
"$",
"_rulesMasks",
"[",
"1",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"denyRulesMask",
"[",
"$",
"key",
"]",
"|=",
"$",
"value",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"_aclEntries",
"[",
"$",
"folderPath",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"_aclEntries",
"[",
"$",
"folderPath",
"]",
"[",
"$",
"_entryKey",
"]",
"=",
"array",
"(",
"$",
"allowRulesMask",
",",
"$",
"denyRulesMask",
")",
";",
"}"
] |
Add ACL entry
@param string $role role
@param string $resourceType resource type
@param string $folderPath folder path
@param int $allowRulesMask allow rules mask
@param int $denyRulesMask deny rules mask
@access private
|
[
"Add",
"ACL",
"entry"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/AccessControlConfig.php#L102-L136
|
26,936
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/AccessControlConfig.php
|
CKFinder_Connector_Core_AccessControlConfig.getComputedMask
|
public function getComputedMask($resourceType, $folderPath)
{
$_computedMask = 0;
$_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
$_roleSessionVar = $_config->getRoleSessionVar();
$_userRole = null;
if (strlen($_roleSessionVar) && isset($_SESSION[$_roleSessionVar])) {
$_userRole = (string)$_SESSION[$_roleSessionVar];
}
if (!is_null($_userRole) && !strlen($_userRole)) {
$_userRole = null;
}
$folderPath = trim($folderPath, "/");
$_pathParts = explode("/", $folderPath);
$_currentPath = "/";
for($i = -1; $i < sizeof($_pathParts); $i++) {
if ($i >= 0) {
if (!strlen($_pathParts[$i])) {
continue;
}
if (array_key_exists($_currentPath . '*/', $this->_aclEntries))
$_computedMask = $this->mergePathComputedMask( $_computedMask, $resourceType, $_userRole, $_currentPath . '*/' );
$_currentPath .= $_pathParts[$i] . '/';
}
if (array_key_exists($_currentPath, $this->_aclEntries)) {
$_computedMask = $this->mergePathComputedMask( $_computedMask, $resourceType, $_userRole, $_currentPath );
}
}
return $_computedMask;
}
|
php
|
public function getComputedMask($resourceType, $folderPath)
{
$_computedMask = 0;
$_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
$_roleSessionVar = $_config->getRoleSessionVar();
$_userRole = null;
if (strlen($_roleSessionVar) && isset($_SESSION[$_roleSessionVar])) {
$_userRole = (string)$_SESSION[$_roleSessionVar];
}
if (!is_null($_userRole) && !strlen($_userRole)) {
$_userRole = null;
}
$folderPath = trim($folderPath, "/");
$_pathParts = explode("/", $folderPath);
$_currentPath = "/";
for($i = -1; $i < sizeof($_pathParts); $i++) {
if ($i >= 0) {
if (!strlen($_pathParts[$i])) {
continue;
}
if (array_key_exists($_currentPath . '*/', $this->_aclEntries))
$_computedMask = $this->mergePathComputedMask( $_computedMask, $resourceType, $_userRole, $_currentPath . '*/' );
$_currentPath .= $_pathParts[$i] . '/';
}
if (array_key_exists($_currentPath, $this->_aclEntries)) {
$_computedMask = $this->mergePathComputedMask( $_computedMask, $resourceType, $_userRole, $_currentPath );
}
}
return $_computedMask;
}
|
[
"public",
"function",
"getComputedMask",
"(",
"$",
"resourceType",
",",
"$",
"folderPath",
")",
"{",
"$",
"_computedMask",
"=",
"0",
";",
"$",
"_config",
"=",
"&",
"CKFinder_Connector_Core_Factory",
"::",
"getInstance",
"(",
"\"Core_Config\"",
")",
";",
"$",
"_roleSessionVar",
"=",
"$",
"_config",
"->",
"getRoleSessionVar",
"(",
")",
";",
"$",
"_userRole",
"=",
"null",
";",
"if",
"(",
"strlen",
"(",
"$",
"_roleSessionVar",
")",
"&&",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"_roleSessionVar",
"]",
")",
")",
"{",
"$",
"_userRole",
"=",
"(",
"string",
")",
"$",
"_SESSION",
"[",
"$",
"_roleSessionVar",
"]",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"_userRole",
")",
"&&",
"!",
"strlen",
"(",
"$",
"_userRole",
")",
")",
"{",
"$",
"_userRole",
"=",
"null",
";",
"}",
"$",
"folderPath",
"=",
"trim",
"(",
"$",
"folderPath",
",",
"\"/\"",
")",
";",
"$",
"_pathParts",
"=",
"explode",
"(",
"\"/\"",
",",
"$",
"folderPath",
")",
";",
"$",
"_currentPath",
"=",
"\"/\"",
";",
"for",
"(",
"$",
"i",
"=",
"-",
"1",
";",
"$",
"i",
"<",
"sizeof",
"(",
"$",
"_pathParts",
")",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"i",
">=",
"0",
")",
"{",
"if",
"(",
"!",
"strlen",
"(",
"$",
"_pathParts",
"[",
"$",
"i",
"]",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"_currentPath",
".",
"'*/'",
",",
"$",
"this",
"->",
"_aclEntries",
")",
")",
"$",
"_computedMask",
"=",
"$",
"this",
"->",
"mergePathComputedMask",
"(",
"$",
"_computedMask",
",",
"$",
"resourceType",
",",
"$",
"_userRole",
",",
"$",
"_currentPath",
".",
"'*/'",
")",
";",
"$",
"_currentPath",
".=",
"$",
"_pathParts",
"[",
"$",
"i",
"]",
".",
"'/'",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"_currentPath",
",",
"$",
"this",
"->",
"_aclEntries",
")",
")",
"{",
"$",
"_computedMask",
"=",
"$",
"this",
"->",
"mergePathComputedMask",
"(",
"$",
"_computedMask",
",",
"$",
"resourceType",
",",
"$",
"_userRole",
",",
"$",
"_currentPath",
")",
";",
"}",
"}",
"return",
"$",
"_computedMask",
";",
"}"
] |
Get computed mask
@param string $resourceType
@param string $folderPath
@return int
|
[
"Get",
"computed",
"mask"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/AccessControlConfig.php#L146-L184
|
26,937
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/AccessControlConfig.php
|
CKFinder_Connector_Core_AccessControlConfig.mergePathComputedMask
|
private function mergePathComputedMask( $currentMask, $resourceType, $userRole, $path )
{
$_folderEntries = $this->_aclEntries[$path];
$_possibleEntries = array();
$_possibleEntries[0] = "*#@#*";
$_possibleEntries[1] = "*#@#" . $resourceType;
if (!is_null($userRole))
{
$_possibleEntries[2] = $userRole . "#@#*";
$_possibleEntries[3] = $userRole . "#@#" . $resourceType;
}
for ($r = 0; $r < sizeof($_possibleEntries); $r++)
{
$_possibleKey = $_possibleEntries[$r];
if (array_key_exists($_possibleKey, $_folderEntries))
{
$_rulesMasks = $_folderEntries[$_possibleKey];
$currentMask |= array_sum($_rulesMasks[0]);
$currentMask ^= ($currentMask & array_sum($_rulesMasks[1]));
}
}
return $currentMask;
}
|
php
|
private function mergePathComputedMask( $currentMask, $resourceType, $userRole, $path )
{
$_folderEntries = $this->_aclEntries[$path];
$_possibleEntries = array();
$_possibleEntries[0] = "*#@#*";
$_possibleEntries[1] = "*#@#" . $resourceType;
if (!is_null($userRole))
{
$_possibleEntries[2] = $userRole . "#@#*";
$_possibleEntries[3] = $userRole . "#@#" . $resourceType;
}
for ($r = 0; $r < sizeof($_possibleEntries); $r++)
{
$_possibleKey = $_possibleEntries[$r];
if (array_key_exists($_possibleKey, $_folderEntries))
{
$_rulesMasks = $_folderEntries[$_possibleKey];
$currentMask |= array_sum($_rulesMasks[0]);
$currentMask ^= ($currentMask & array_sum($_rulesMasks[1]));
}
}
return $currentMask;
}
|
[
"private",
"function",
"mergePathComputedMask",
"(",
"$",
"currentMask",
",",
"$",
"resourceType",
",",
"$",
"userRole",
",",
"$",
"path",
")",
"{",
"$",
"_folderEntries",
"=",
"$",
"this",
"->",
"_aclEntries",
"[",
"$",
"path",
"]",
";",
"$",
"_possibleEntries",
"=",
"array",
"(",
")",
";",
"$",
"_possibleEntries",
"[",
"0",
"]",
"=",
"\"*#@#*\"",
";",
"$",
"_possibleEntries",
"[",
"1",
"]",
"=",
"\"*#@#\"",
".",
"$",
"resourceType",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"userRole",
")",
")",
"{",
"$",
"_possibleEntries",
"[",
"2",
"]",
"=",
"$",
"userRole",
".",
"\"#@#*\"",
";",
"$",
"_possibleEntries",
"[",
"3",
"]",
"=",
"$",
"userRole",
".",
"\"#@#\"",
".",
"$",
"resourceType",
";",
"}",
"for",
"(",
"$",
"r",
"=",
"0",
";",
"$",
"r",
"<",
"sizeof",
"(",
"$",
"_possibleEntries",
")",
";",
"$",
"r",
"++",
")",
"{",
"$",
"_possibleKey",
"=",
"$",
"_possibleEntries",
"[",
"$",
"r",
"]",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"_possibleKey",
",",
"$",
"_folderEntries",
")",
")",
"{",
"$",
"_rulesMasks",
"=",
"$",
"_folderEntries",
"[",
"$",
"_possibleKey",
"]",
";",
"$",
"currentMask",
"|=",
"array_sum",
"(",
"$",
"_rulesMasks",
"[",
"0",
"]",
")",
";",
"$",
"currentMask",
"^=",
"(",
"$",
"currentMask",
"&",
"array_sum",
"(",
"$",
"_rulesMasks",
"[",
"1",
"]",
")",
")",
";",
"}",
"}",
"return",
"$",
"currentMask",
";",
"}"
] |
merge current mask with folder entries
@access private
@param int $currentMask
@param string $resourceType
@param string $userRole
@param string $path
@return int
|
[
"merge",
"current",
"mask",
"with",
"folder",
"entries"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/AccessControlConfig.php#L196-L224
|
26,938
|
aimeos/ai-controller-jobs
|
controller/common/src/Controller/Common/Product/Import/Xml/Processor/Catalog/Standard.php
|
Standard.getCatalogItems
|
protected function getCatalogItems( \DOMNode $node )
{
foreach( $node->childNodes as $node )
{
if( $node->nodeName === 'catalogitem'
&& ( $refAttr = $node->attributes->getNamedItem( 'ref' ) ) !== null
) {
$codes[] = $refAttr->nodeValue;
}
}
$items = [];
if( !empty( $codes ) )
{
$manager = \Aimeos\MShop::create( $this->getContext(), 'catalog' );
$search = $manager->createSearch()->setSlice( 0, count( $codes ) );
$search->setConditions( $search->compare( '==', 'catalog.code', $codes ) );
foreach( $manager->searchItems( $search ) as $item ) {
$items[$item->getCode()] = $item;
}
}
return $items;
}
|
php
|
protected function getCatalogItems( \DOMNode $node )
{
foreach( $node->childNodes as $node )
{
if( $node->nodeName === 'catalogitem'
&& ( $refAttr = $node->attributes->getNamedItem( 'ref' ) ) !== null
) {
$codes[] = $refAttr->nodeValue;
}
}
$items = [];
if( !empty( $codes ) )
{
$manager = \Aimeos\MShop::create( $this->getContext(), 'catalog' );
$search = $manager->createSearch()->setSlice( 0, count( $codes ) );
$search->setConditions( $search->compare( '==', 'catalog.code', $codes ) );
foreach( $manager->searchItems( $search ) as $item ) {
$items[$item->getCode()] = $item;
}
}
return $items;
}
|
[
"protected",
"function",
"getCatalogItems",
"(",
"\\",
"DOMNode",
"$",
"node",
")",
"{",
"foreach",
"(",
"$",
"node",
"->",
"childNodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"nodeName",
"===",
"'catalogitem'",
"&&",
"(",
"$",
"refAttr",
"=",
"$",
"node",
"->",
"attributes",
"->",
"getNamedItem",
"(",
"'ref'",
")",
")",
"!==",
"null",
")",
"{",
"$",
"codes",
"[",
"]",
"=",
"$",
"refAttr",
"->",
"nodeValue",
";",
"}",
"}",
"$",
"items",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"codes",
")",
")",
"{",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"this",
"->",
"getContext",
"(",
")",
",",
"'catalog'",
")",
";",
"$",
"search",
"=",
"$",
"manager",
"->",
"createSearch",
"(",
")",
"->",
"setSlice",
"(",
"0",
",",
"count",
"(",
"$",
"codes",
")",
")",
";",
"$",
"search",
"->",
"setConditions",
"(",
"$",
"search",
"->",
"compare",
"(",
"'=='",
",",
"'catalog.code'",
",",
"$",
"codes",
")",
")",
";",
"foreach",
"(",
"$",
"manager",
"->",
"searchItems",
"(",
"$",
"search",
")",
"as",
"$",
"item",
")",
"{",
"$",
"items",
"[",
"$",
"item",
"->",
"getCode",
"(",
")",
"]",
"=",
"$",
"item",
";",
"}",
"}",
"return",
"$",
"items",
";",
"}"
] |
Returns the catalog items referenced in the DOM node
@param \DOMNode $node XML document node containing a list of nodes to process
@return \Aimeos\MShop\Catalog\Item\Iface[] List of referenced catalog items
|
[
"Returns",
"the",
"catalog",
"items",
"referenced",
"in",
"the",
"DOM",
"node"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/common/src/Controller/Common/Product/Import/Xml/Processor/Catalog/Standard.php#L127-L153
|
26,939
|
aimeos/ai-controller-jobs
|
controller/common/src/Controller/Common/Product/Import/Csv/Processor/Catalog/Standard.php
|
Standard.addListItemDefaults
|
protected function addListItemDefaults( array $list, $pos )
{
if( !isset( $list['catalog.lists.position'] ) ) {
$list['catalog.lists.position'] = $pos;
}
if( !isset( $list['catalog.lists.status'] ) ) {
$list['catalog.lists.status'] = 1;
}
return $list;
}
|
php
|
protected function addListItemDefaults( array $list, $pos )
{
if( !isset( $list['catalog.lists.position'] ) ) {
$list['catalog.lists.position'] = $pos;
}
if( !isset( $list['catalog.lists.status'] ) ) {
$list['catalog.lists.status'] = 1;
}
return $list;
}
|
[
"protected",
"function",
"addListItemDefaults",
"(",
"array",
"$",
"list",
",",
"$",
"pos",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"list",
"[",
"'catalog.lists.position'",
"]",
")",
")",
"{",
"$",
"list",
"[",
"'catalog.lists.position'",
"]",
"=",
"$",
"pos",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"list",
"[",
"'catalog.lists.status'",
"]",
")",
")",
"{",
"$",
"list",
"[",
"'catalog.lists.status'",
"]",
"=",
"1",
";",
"}",
"return",
"$",
"list",
";",
"}"
] |
Adds the list item default values and returns the resulting array
@param array $list Associative list of domain item keys and their values, e.g. "catalog.lists.status" => 1
@param integer $pos Computed position of the list item in the associated list of items
@return array Given associative list enriched by default values if they were not already set
|
[
"Adds",
"the",
"list",
"item",
"default",
"values",
"and",
"returns",
"the",
"resulting",
"array"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/common/src/Controller/Common/Product/Import/Csv/Processor/Catalog/Standard.php#L200-L211
|
26,940
|
aimeos/ai-controller-jobs
|
controller/common/src/Controller/Common/Product/Import/Csv/Processor/Catalog/Standard.php
|
Standard.getListItems
|
protected function getListItems( $prodid, array $types )
{
if( empty( $types ) ) {
return [];
}
$manager = \Aimeos\MShop::create( $this->getContext(), 'catalog/lists' );
$search = $manager->createSearch()->setSlice( 0, 0x7FFFFFFF );
$expr = [];
foreach( $types as $type ) {
$expr[] = $search->compare( '==', 'catalog.lists.key', 'product|' . $type . '|' . $prodid );
}
return $manager->searchItems( $search->setConditions( $search->combine( '||', $expr ) ) );
}
|
php
|
protected function getListItems( $prodid, array $types )
{
if( empty( $types ) ) {
return [];
}
$manager = \Aimeos\MShop::create( $this->getContext(), 'catalog/lists' );
$search = $manager->createSearch()->setSlice( 0, 0x7FFFFFFF );
$expr = [];
foreach( $types as $type ) {
$expr[] = $search->compare( '==', 'catalog.lists.key', 'product|' . $type . '|' . $prodid );
}
return $manager->searchItems( $search->setConditions( $search->combine( '||', $expr ) ) );
}
|
[
"protected",
"function",
"getListItems",
"(",
"$",
"prodid",
",",
"array",
"$",
"types",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"types",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"this",
"->",
"getContext",
"(",
")",
",",
"'catalog/lists'",
")",
";",
"$",
"search",
"=",
"$",
"manager",
"->",
"createSearch",
"(",
")",
"->",
"setSlice",
"(",
"0",
",",
"0x7FFFFFFF",
")",
";",
"$",
"expr",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"types",
"as",
"$",
"type",
")",
"{",
"$",
"expr",
"[",
"]",
"=",
"$",
"search",
"->",
"compare",
"(",
"'=='",
",",
"'catalog.lists.key'",
",",
"'product|'",
".",
"$",
"type",
".",
"'|'",
".",
"$",
"prodid",
")",
";",
"}",
"return",
"$",
"manager",
"->",
"searchItems",
"(",
"$",
"search",
"->",
"setConditions",
"(",
"$",
"search",
"->",
"combine",
"(",
"'||'",
",",
"$",
"expr",
")",
")",
")",
";",
"}"
] |
Returns the catalog list items for the given category and product ID
@param string $prodid Unique product ID
@param array $types List of catalog list types
@return array List of catalog list items
|
[
"Returns",
"the",
"catalog",
"list",
"items",
"for",
"the",
"given",
"category",
"and",
"product",
"ID"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/common/src/Controller/Common/Product/Import/Csv/Processor/Catalog/Standard.php#L243-L258
|
26,941
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/ErrorHandler/Base.php
|
CKFinder_Connector_ErrorHandler_Base.throwError
|
public function throwError($number, $text = false)
{
if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) {
return false;
}
$_xml =& CKFinder_Connector_Core_Factory::getInstance("Core_Xml");
$_xml->raiseError($number,$text);
exit;
}
|
php
|
public function throwError($number, $text = false)
{
if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) {
return false;
}
$_xml =& CKFinder_Connector_Core_Factory::getInstance("Core_Xml");
$_xml->raiseError($number,$text);
exit;
}
|
[
"public",
"function",
"throwError",
"(",
"$",
"number",
",",
"$",
"text",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_catchAllErrors",
"||",
"in_array",
"(",
"$",
"number",
",",
"$",
"this",
"->",
"_skipErrorsArray",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"_xml",
"=",
"&",
"CKFinder_Connector_Core_Factory",
"::",
"getInstance",
"(",
"\"Core_Xml\"",
")",
";",
"$",
"_xml",
"->",
"raiseError",
"(",
"$",
"number",
",",
"$",
"text",
")",
";",
"exit",
";",
"}"
] |
Throw connector error, return true if error has been thrown, false if error has been catched
@param int $number
@param string $text
@access public
|
[
"Throw",
"connector",
"error",
"return",
"true",
"if",
"error",
"has",
"been",
"thrown",
"false",
"if",
"error",
"has",
"been",
"catched"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/ErrorHandler/Base.php#L75-L85
|
26,942
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/FolderHandler.php
|
CKFinder_Connector_Core_FolderHandler.&
|
public function &getResourceTypeConfig()
{
if (!isset($this->_resourceTypeConfig)) {
$_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
$this->_resourceTypeConfig = $_config->getResourceTypeConfig($this->_resourceTypeName);
}
if (is_null($this->_resourceTypeConfig)) {
$connector =& CKFinder_Connector_Core_Factory::getInstance("Core_Connector");
$oErrorHandler =& $connector->getErrorHandler();
$oErrorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_TYPE);
}
return $this->_resourceTypeConfig;
}
|
php
|
public function &getResourceTypeConfig()
{
if (!isset($this->_resourceTypeConfig)) {
$_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
$this->_resourceTypeConfig = $_config->getResourceTypeConfig($this->_resourceTypeName);
}
if (is_null($this->_resourceTypeConfig)) {
$connector =& CKFinder_Connector_Core_Factory::getInstance("Core_Connector");
$oErrorHandler =& $connector->getErrorHandler();
$oErrorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_TYPE);
}
return $this->_resourceTypeConfig;
}
|
[
"public",
"function",
"&",
"getResourceTypeConfig",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_resourceTypeConfig",
")",
")",
"{",
"$",
"_config",
"=",
"&",
"CKFinder_Connector_Core_Factory",
"::",
"getInstance",
"(",
"\"Core_Config\"",
")",
";",
"$",
"this",
"->",
"_resourceTypeConfig",
"=",
"$",
"_config",
"->",
"getResourceTypeConfig",
"(",
"$",
"this",
"->",
"_resourceTypeName",
")",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_resourceTypeConfig",
")",
")",
"{",
"$",
"connector",
"=",
"&",
"CKFinder_Connector_Core_Factory",
"::",
"getInstance",
"(",
"\"Core_Connector\"",
")",
";",
"$",
"oErrorHandler",
"=",
"&",
"$",
"connector",
"->",
"getErrorHandler",
"(",
")",
";",
"$",
"oErrorHandler",
"->",
"throwError",
"(",
"CKFINDER_CONNECTOR_ERROR_INVALID_TYPE",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_resourceTypeConfig",
";",
"}"
] |
Get resource type config
@return CKFinder_Connector_Core_ResourceTypeConfig
@access public
|
[
"Get",
"resource",
"type",
"config"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/FolderHandler.php#L128-L142
|
26,943
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/FolderHandler.php
|
CKFinder_Connector_Core_FolderHandler.getServerPath
|
public function getServerPath()
{
if (is_null($this->_serverPath)) {
$this->_resourceTypeConfig = $this->getResourceTypeConfig();
$this->_serverPath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_resourceTypeConfig->getDirectory(), ltrim($this->_clientPath, "/"));
}
return $this->_serverPath;
}
|
php
|
public function getServerPath()
{
if (is_null($this->_serverPath)) {
$this->_resourceTypeConfig = $this->getResourceTypeConfig();
$this->_serverPath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_resourceTypeConfig->getDirectory(), ltrim($this->_clientPath, "/"));
}
return $this->_serverPath;
}
|
[
"public",
"function",
"getServerPath",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_serverPath",
")",
")",
"{",
"$",
"this",
"->",
"_resourceTypeConfig",
"=",
"$",
"this",
"->",
"getResourceTypeConfig",
"(",
")",
";",
"$",
"this",
"->",
"_serverPath",
"=",
"CKFinder_Connector_Utils_FileSystem",
"::",
"combinePaths",
"(",
"$",
"this",
"->",
"_resourceTypeConfig",
"->",
"getDirectory",
"(",
")",
",",
"ltrim",
"(",
"$",
"this",
"->",
"_clientPath",
",",
"\"/\"",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_serverPath",
";",
"}"
] |
Get server path
@return string
@access public
|
[
"Get",
"server",
"path"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/FolderHandler.php#L196-L204
|
26,944
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/FolderHandler.php
|
CKFinder_Connector_Core_FolderHandler.getThumbsServerPath
|
public function getThumbsServerPath()
{
if (is_null($this->_thumbsServerPath)) {
$this->_resourceTypeConfig = $this->getResourceTypeConfig();
$_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
$_thumbnailsConfig = $_config->getThumbnailsConfig();
// Get the resource type directory.
$this->_thumbsServerPath = CKFinder_Connector_Utils_FileSystem::combinePaths($_thumbnailsConfig->getDirectory(), $this->_resourceTypeConfig->getName());
// Return the resource type directory combined with the required path.
$this->_thumbsServerPath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_thumbsServerPath, ltrim($this->_clientPath, '/'));
if (!is_dir($this->_thumbsServerPath)) {
if(!CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively($this->_thumbsServerPath)) {
/**
* @todo Ckfinder_Connector_Utils_Xml::raiseError(); perhaps we should return error
*
*/
}
}
}
return $this->_thumbsServerPath;
}
|
php
|
public function getThumbsServerPath()
{
if (is_null($this->_thumbsServerPath)) {
$this->_resourceTypeConfig = $this->getResourceTypeConfig();
$_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
$_thumbnailsConfig = $_config->getThumbnailsConfig();
// Get the resource type directory.
$this->_thumbsServerPath = CKFinder_Connector_Utils_FileSystem::combinePaths($_thumbnailsConfig->getDirectory(), $this->_resourceTypeConfig->getName());
// Return the resource type directory combined with the required path.
$this->_thumbsServerPath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_thumbsServerPath, ltrim($this->_clientPath, '/'));
if (!is_dir($this->_thumbsServerPath)) {
if(!CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively($this->_thumbsServerPath)) {
/**
* @todo Ckfinder_Connector_Utils_Xml::raiseError(); perhaps we should return error
*
*/
}
}
}
return $this->_thumbsServerPath;
}
|
[
"public",
"function",
"getThumbsServerPath",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_thumbsServerPath",
")",
")",
"{",
"$",
"this",
"->",
"_resourceTypeConfig",
"=",
"$",
"this",
"->",
"getResourceTypeConfig",
"(",
")",
";",
"$",
"_config",
"=",
"&",
"CKFinder_Connector_Core_Factory",
"::",
"getInstance",
"(",
"\"Core_Config\"",
")",
";",
"$",
"_thumbnailsConfig",
"=",
"$",
"_config",
"->",
"getThumbnailsConfig",
"(",
")",
";",
"// Get the resource type directory.",
"$",
"this",
"->",
"_thumbsServerPath",
"=",
"CKFinder_Connector_Utils_FileSystem",
"::",
"combinePaths",
"(",
"$",
"_thumbnailsConfig",
"->",
"getDirectory",
"(",
")",
",",
"$",
"this",
"->",
"_resourceTypeConfig",
"->",
"getName",
"(",
")",
")",
";",
"// Return the resource type directory combined with the required path.",
"$",
"this",
"->",
"_thumbsServerPath",
"=",
"CKFinder_Connector_Utils_FileSystem",
"::",
"combinePaths",
"(",
"$",
"this",
"->",
"_thumbsServerPath",
",",
"ltrim",
"(",
"$",
"this",
"->",
"_clientPath",
",",
"'/'",
")",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"this",
"->",
"_thumbsServerPath",
")",
")",
"{",
"if",
"(",
"!",
"CKFinder_Connector_Utils_FileSystem",
"::",
"createDirectoryRecursively",
"(",
"$",
"this",
"->",
"_thumbsServerPath",
")",
")",
"{",
"/**\n * @todo Ckfinder_Connector_Utils_Xml::raiseError(); perhaps we should return error\n *\n */",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"_thumbsServerPath",
";",
"}"
] |
Get server path to thumbnails directory
@access public
@return string
|
[
"Get",
"server",
"path",
"to",
"thumbnails",
"directory"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/FolderHandler.php#L212-L237
|
26,945
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/FolderHandler.php
|
CKFinder_Connector_Core_FolderHandler.getAclMask
|
public function getAclMask()
{
$_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
$_aclConfig = $_config->getAccessControlConfig();
if ($this->_aclMask == -1) {
$this->_aclMask = $_aclConfig->getComputedMask($this->_resourceTypeName, $this->_clientPath);
}
return $this->_aclMask;
}
|
php
|
public function getAclMask()
{
$_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
$_aclConfig = $_config->getAccessControlConfig();
if ($this->_aclMask == -1) {
$this->_aclMask = $_aclConfig->getComputedMask($this->_resourceTypeName, $this->_clientPath);
}
return $this->_aclMask;
}
|
[
"public",
"function",
"getAclMask",
"(",
")",
"{",
"$",
"_config",
"=",
"&",
"CKFinder_Connector_Core_Factory",
"::",
"getInstance",
"(",
"\"Core_Config\"",
")",
";",
"$",
"_aclConfig",
"=",
"$",
"_config",
"->",
"getAccessControlConfig",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_aclMask",
"==",
"-",
"1",
")",
"{",
"$",
"this",
"->",
"_aclMask",
"=",
"$",
"_aclConfig",
"->",
"getComputedMask",
"(",
"$",
"this",
"->",
"_resourceTypeName",
",",
"$",
"this",
"->",
"_clientPath",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_aclMask",
";",
"}"
] |
Get ACL Mask
@return int
@access public
|
[
"Get",
"ACL",
"Mask"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/FolderHandler.php#L245-L255
|
26,946
|
aimeos/ai-controller-jobs
|
controller/common/src/Controller/Common/Common/Import/Xml/Processor/Lists/Product/Standard.php
|
Standard.getItems
|
protected function getItems( \DomNodeList $nodes )
{
$codes = $map = [];
$manager = \Aimeos\MShop::create( $this->getContext(), 'product' );
foreach( $nodes as $node )
{
if( $node->nodeName === 'productitem' && ( $attr = $node->attributes->getNamedItem( 'ref' ) ) !== null ) {
$codes[$attr->nodeValue] = null;
}
}
$search = $manager->createSearch()->setSlice( 0, count( $codes ) );
$search->setConditions( $search->compare( '==', 'product.code', array_keys( $codes ) ) );
foreach( $manager->searchItems( $search, [] ) as $item ) {
$map[$item->getCode()] = $item;
}
return $map;
}
|
php
|
protected function getItems( \DomNodeList $nodes )
{
$codes = $map = [];
$manager = \Aimeos\MShop::create( $this->getContext(), 'product' );
foreach( $nodes as $node )
{
if( $node->nodeName === 'productitem' && ( $attr = $node->attributes->getNamedItem( 'ref' ) ) !== null ) {
$codes[$attr->nodeValue] = null;
}
}
$search = $manager->createSearch()->setSlice( 0, count( $codes ) );
$search->setConditions( $search->compare( '==', 'product.code', array_keys( $codes ) ) );
foreach( $manager->searchItems( $search, [] ) as $item ) {
$map[$item->getCode()] = $item;
}
return $map;
}
|
[
"protected",
"function",
"getItems",
"(",
"\\",
"DomNodeList",
"$",
"nodes",
")",
"{",
"$",
"codes",
"=",
"$",
"map",
"=",
"[",
"]",
";",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"this",
"->",
"getContext",
"(",
")",
",",
"'product'",
")",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"nodeName",
"===",
"'productitem'",
"&&",
"(",
"$",
"attr",
"=",
"$",
"node",
"->",
"attributes",
"->",
"getNamedItem",
"(",
"'ref'",
")",
")",
"!==",
"null",
")",
"{",
"$",
"codes",
"[",
"$",
"attr",
"->",
"nodeValue",
"]",
"=",
"null",
";",
"}",
"}",
"$",
"search",
"=",
"$",
"manager",
"->",
"createSearch",
"(",
")",
"->",
"setSlice",
"(",
"0",
",",
"count",
"(",
"$",
"codes",
")",
")",
";",
"$",
"search",
"->",
"setConditions",
"(",
"$",
"search",
"->",
"compare",
"(",
"'=='",
",",
"'product.code'",
",",
"array_keys",
"(",
"$",
"codes",
")",
")",
")",
";",
"foreach",
"(",
"$",
"manager",
"->",
"searchItems",
"(",
"$",
"search",
",",
"[",
"]",
")",
"as",
"$",
"item",
")",
"{",
"$",
"map",
"[",
"$",
"item",
"->",
"getCode",
"(",
")",
"]",
"=",
"$",
"item",
";",
"}",
"return",
"$",
"map",
";",
"}"
] |
Returns the product items for the given nodes
@param \DomNodeList $nodes List of XML product item nodes
@return \Aimeos\MShop\Product\Item\Iface[] Associative list of product items with codes as keys
|
[
"Returns",
"the",
"product",
"items",
"for",
"the",
"given",
"nodes"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/common/src/Controller/Common/Common/Import/Xml/Processor/Lists/Product/Standard.php#L100-L120
|
26,947
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/CommandHandler/CommandHandlerBase.php
|
CKFinder_Connector_CommandHandler_CommandHandlerBase.getFolderHandler
|
public function getFolderHandler()
{
if (is_null($this->_currentFolder)) {
$this->_currentFolder =& CKFinder_Connector_Core_Factory::getInstance("Core_FolderHandler");
}
return $this->_currentFolder;
}
|
php
|
public function getFolderHandler()
{
if (is_null($this->_currentFolder)) {
$this->_currentFolder =& CKFinder_Connector_Core_Factory::getInstance("Core_FolderHandler");
}
return $this->_currentFolder;
}
|
[
"public",
"function",
"getFolderHandler",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_currentFolder",
")",
")",
"{",
"$",
"this",
"->",
"_currentFolder",
"=",
"&",
"CKFinder_Connector_Core_Factory",
"::",
"getInstance",
"(",
"\"Core_FolderHandler\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_currentFolder",
";",
"}"
] |
Get Folder Handler
@access public
@return CKFinder_Connector_Core_FolderHandler
|
[
"Get",
"Folder",
"Handler"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/CommandHandler/CommandHandlerBase.php#L67-L74
|
26,948
|
aimeos/ai-controller-jobs
|
controller/common/src/Controller/Common/Common/Import/Xml/Traits.php
|
Traits.getProcessor
|
protected function getProcessor( $type, $domain )
{
if( !isset( $this->processors[$domain][$type] ) ) {
$this->processors[$domain][$type] = $this->createProcessor( $type, $domain );
}
return $this->processors[$domain][$type];
}
|
php
|
protected function getProcessor( $type, $domain )
{
if( !isset( $this->processors[$domain][$type] ) ) {
$this->processors[$domain][$type] = $this->createProcessor( $type, $domain );
}
return $this->processors[$domain][$type];
}
|
[
"protected",
"function",
"getProcessor",
"(",
"$",
"type",
",",
"$",
"domain",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"processors",
"[",
"$",
"domain",
"]",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"this",
"->",
"processors",
"[",
"$",
"domain",
"]",
"[",
"$",
"type",
"]",
"=",
"$",
"this",
"->",
"createProcessor",
"(",
"$",
"type",
",",
"$",
"domain",
")",
";",
"}",
"return",
"$",
"this",
"->",
"processors",
"[",
"$",
"domain",
"]",
"[",
"$",
"type",
"]",
";",
"}"
] |
Returns the processor object for adding the product related information
@param string $type Type of the processor
@param string $domain Name of the domain that is imported
@return \Aimeos\Controller\Common\Common\Import\Xml\Processor\Iface Processor object
|
[
"Returns",
"the",
"processor",
"object",
"for",
"adding",
"the",
"product",
"related",
"information"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/common/src/Controller/Common/Common/Import/Xml/Traits.php#L40-L47
|
26,949
|
aimeos/ai-controller-jobs
|
controller/common/src/Controller/Common/Common/Import/Xml/Traits.php
|
Traits.createProcessor
|
protected function createProcessor( $type, $domain )
{
$context = $this->getContext();
$config = $context->getConfig();
$parts = explode( '/', $type );
foreach( $parts as $part )
{
if( ctype_alnum( $part ) === false )
{
$msg = sprintf( 'Invalid characters in processor type "%1$s"', $type );
throw new \Aimeos\Controller\Common\Exception( $msg );
}
}
if( ctype_alnum( $domain ) === false )
{
$msg = sprintf( 'Invalid characters in data domain name "%1$s"', $domain );
throw new \Aimeos\Controller\Common\Exception( $msg );
}
$name = $config->get( 'controller/common/' . $domain . '/import/xml/processor/' . $type . '/name', 'Standard' );
if( ctype_alnum( $name ) === false )
{
$msg = sprintf( 'Invalid characters in processor name "%1$s"', $name );
throw new \Aimeos\Controller\Common\Exception( $msg );
}
$segment = str_replace( '/', '\\', ucwords( $type, '/' ) ) . '\\' . $name;
$classname = '\\Aimeos\\Controller\\Common\\Common\\Import\\Xml\\Processor\\' . $segment;
if( class_exists( $classname ) === false )
{
$classname = '\\Aimeos\\Controller\\Common\\' . ucfirst( $domain ) . '\\Import\\Xml\\Processor\\' . $segment;
if( class_exists( $classname ) === false ){
throw new \Aimeos\Controller\Common\Exception( sprintf( 'Class "%1$s" not found', $classname ) );
}
}
$iface = \Aimeos\Controller\Common\Common\Import\Xml\Processor\Iface::class;
return \Aimeos\MW\Common\Base::checkClass( $iface, new $classname( $context ) );
}
|
php
|
protected function createProcessor( $type, $domain )
{
$context = $this->getContext();
$config = $context->getConfig();
$parts = explode( '/', $type );
foreach( $parts as $part )
{
if( ctype_alnum( $part ) === false )
{
$msg = sprintf( 'Invalid characters in processor type "%1$s"', $type );
throw new \Aimeos\Controller\Common\Exception( $msg );
}
}
if( ctype_alnum( $domain ) === false )
{
$msg = sprintf( 'Invalid characters in data domain name "%1$s"', $domain );
throw new \Aimeos\Controller\Common\Exception( $msg );
}
$name = $config->get( 'controller/common/' . $domain . '/import/xml/processor/' . $type . '/name', 'Standard' );
if( ctype_alnum( $name ) === false )
{
$msg = sprintf( 'Invalid characters in processor name "%1$s"', $name );
throw new \Aimeos\Controller\Common\Exception( $msg );
}
$segment = str_replace( '/', '\\', ucwords( $type, '/' ) ) . '\\' . $name;
$classname = '\\Aimeos\\Controller\\Common\\Common\\Import\\Xml\\Processor\\' . $segment;
if( class_exists( $classname ) === false )
{
$classname = '\\Aimeos\\Controller\\Common\\' . ucfirst( $domain ) . '\\Import\\Xml\\Processor\\' . $segment;
if( class_exists( $classname ) === false ){
throw new \Aimeos\Controller\Common\Exception( sprintf( 'Class "%1$s" not found', $classname ) );
}
}
$iface = \Aimeos\Controller\Common\Common\Import\Xml\Processor\Iface::class;
return \Aimeos\MW\Common\Base::checkClass( $iface, new $classname( $context ) );
}
|
[
"protected",
"function",
"createProcessor",
"(",
"$",
"type",
",",
"$",
"domain",
")",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"getContext",
"(",
")",
";",
"$",
"config",
"=",
"$",
"context",
"->",
"getConfig",
"(",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"'/'",
",",
"$",
"type",
")",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"part",
")",
"{",
"if",
"(",
"ctype_alnum",
"(",
"$",
"part",
")",
"===",
"false",
")",
"{",
"$",
"msg",
"=",
"sprintf",
"(",
"'Invalid characters in processor type \"%1$s\"'",
",",
"$",
"type",
")",
";",
"throw",
"new",
"\\",
"Aimeos",
"\\",
"Controller",
"\\",
"Common",
"\\",
"Exception",
"(",
"$",
"msg",
")",
";",
"}",
"}",
"if",
"(",
"ctype_alnum",
"(",
"$",
"domain",
")",
"===",
"false",
")",
"{",
"$",
"msg",
"=",
"sprintf",
"(",
"'Invalid characters in data domain name \"%1$s\"'",
",",
"$",
"domain",
")",
";",
"throw",
"new",
"\\",
"Aimeos",
"\\",
"Controller",
"\\",
"Common",
"\\",
"Exception",
"(",
"$",
"msg",
")",
";",
"}",
"$",
"name",
"=",
"$",
"config",
"->",
"get",
"(",
"'controller/common/'",
".",
"$",
"domain",
".",
"'/import/xml/processor/'",
".",
"$",
"type",
".",
"'/name'",
",",
"'Standard'",
")",
";",
"if",
"(",
"ctype_alnum",
"(",
"$",
"name",
")",
"===",
"false",
")",
"{",
"$",
"msg",
"=",
"sprintf",
"(",
"'Invalid characters in processor name \"%1$s\"'",
",",
"$",
"name",
")",
";",
"throw",
"new",
"\\",
"Aimeos",
"\\",
"Controller",
"\\",
"Common",
"\\",
"Exception",
"(",
"$",
"msg",
")",
";",
"}",
"$",
"segment",
"=",
"str_replace",
"(",
"'/'",
",",
"'\\\\'",
",",
"ucwords",
"(",
"$",
"type",
",",
"'/'",
")",
")",
".",
"'\\\\'",
".",
"$",
"name",
";",
"$",
"classname",
"=",
"'\\\\Aimeos\\\\Controller\\\\Common\\\\Common\\\\Import\\\\Xml\\\\Processor\\\\'",
".",
"$",
"segment",
";",
"if",
"(",
"class_exists",
"(",
"$",
"classname",
")",
"===",
"false",
")",
"{",
"$",
"classname",
"=",
"'\\\\Aimeos\\\\Controller\\\\Common\\\\'",
".",
"ucfirst",
"(",
"$",
"domain",
")",
".",
"'\\\\Import\\\\Xml\\\\Processor\\\\'",
".",
"$",
"segment",
";",
"if",
"(",
"class_exists",
"(",
"$",
"classname",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"Aimeos",
"\\",
"Controller",
"\\",
"Common",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'Class \"%1$s\" not found'",
",",
"$",
"classname",
")",
")",
";",
"}",
"}",
"$",
"iface",
"=",
"\\",
"Aimeos",
"\\",
"Controller",
"\\",
"Common",
"\\",
"Common",
"\\",
"Import",
"\\",
"Xml",
"\\",
"Processor",
"\\",
"Iface",
"::",
"class",
";",
"return",
"\\",
"Aimeos",
"\\",
"MW",
"\\",
"Common",
"\\",
"Base",
"::",
"checkClass",
"(",
"$",
"iface",
",",
"new",
"$",
"classname",
"(",
"$",
"context",
")",
")",
";",
"}"
] |
Creates a new processor object of the given type
@param string $type Type of the processor
@param string $domain Name of the domain that is imported
@return \Aimeos\Controller\Common\Common\Import\Xml\Processor\Iface Processor object
@throws \Aimeos\Controller\Common\Exception If type is invalid or processor isn't found
|
[
"Creates",
"a",
"new",
"processor",
"object",
"of",
"the",
"given",
"type"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/common/src/Controller/Common/Common/Import/Xml/Traits.php#L58-L101
|
26,950
|
pr-of-it/t4
|
framework/Fs/Helpers.php
|
Helpers.mkDir
|
public static function mkDir($dirName, $mode = 0777)
{
if (file_exists($dirName) && is_dir($dirName)) {
return @chmod($dirName, $mode);
}
$result = @mkdir($dirName, $mode, true);
if (false === $result) {
throw new Exception('Can not create dir ' . $dirName);
}
return true;
}
|
php
|
public static function mkDir($dirName, $mode = 0777)
{
if (file_exists($dirName) && is_dir($dirName)) {
return @chmod($dirName, $mode);
}
$result = @mkdir($dirName, $mode, true);
if (false === $result) {
throw new Exception('Can not create dir ' . $dirName);
}
return true;
}
|
[
"public",
"static",
"function",
"mkDir",
"(",
"$",
"dirName",
",",
"$",
"mode",
"=",
"0777",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"dirName",
")",
"&&",
"is_dir",
"(",
"$",
"dirName",
")",
")",
"{",
"return",
"@",
"chmod",
"(",
"$",
"dirName",
",",
"$",
"mode",
")",
";",
"}",
"$",
"result",
"=",
"@",
"mkdir",
"(",
"$",
"dirName",
",",
"$",
"mode",
",",
"true",
")",
";",
"if",
"(",
"false",
"===",
"$",
"result",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Can not create dir '",
".",
"$",
"dirName",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Creates directory by absolute path
@param string $dirName Directory path
@param int $mode Access mode
@return bool
@throws \T4\Fs\Exception
|
[
"Creates",
"directory",
"by",
"absolute",
"path"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Fs/Helpers.php#L74-L84
|
26,951
|
pr-of-it/t4
|
framework/Fs/Helpers.php
|
Helpers.dirMTime
|
public static function dirMTime($path)
{
clearstatcache();
return max(
array_map(
function ($f) {
return filemtime($f);
},
self::listDirRecursive($path)
),
filemtime($path)
);
}
|
php
|
public static function dirMTime($path)
{
clearstatcache();
return max(
array_map(
function ($f) {
return filemtime($f);
},
self::listDirRecursive($path)
),
filemtime($path)
);
}
|
[
"public",
"static",
"function",
"dirMTime",
"(",
"$",
"path",
")",
"{",
"clearstatcache",
"(",
")",
";",
"return",
"max",
"(",
"array_map",
"(",
"function",
"(",
"$",
"f",
")",
"{",
"return",
"filemtime",
"(",
"$",
"f",
")",
";",
"}",
",",
"self",
"::",
"listDirRecursive",
"(",
"$",
"path",
")",
")",
",",
"filemtime",
"(",
"$",
"path",
")",
")",
";",
"}"
] |
Max filemtime at path recursive
@param string $path
@return int
|
[
"Max",
"filemtime",
"at",
"path",
"recursive"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Fs/Helpers.php#L186-L198
|
26,952
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/Hooks.php
|
CKFinder_Connector_Core_Hooks._printCallback
|
public static function _printCallback($callback)
{
if (is_array($callback)) {
if (is_object($callback[0])) {
$className = get_class($callback[0]);
} else {
$className = strval($callback[0]);
}
$functionName = $className . '::' . strval($callback[1]);
}
else {
$functionName = strval($callback);
}
return $functionName;
}
|
php
|
public static function _printCallback($callback)
{
if (is_array($callback)) {
if (is_object($callback[0])) {
$className = get_class($callback[0]);
} else {
$className = strval($callback[0]);
}
$functionName = $className . '::' . strval($callback[1]);
}
else {
$functionName = strval($callback);
}
return $functionName;
}
|
[
"public",
"static",
"function",
"_printCallback",
"(",
"$",
"callback",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"callback",
")",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"callback",
"[",
"0",
"]",
")",
")",
"{",
"$",
"className",
"=",
"get_class",
"(",
"$",
"callback",
"[",
"0",
"]",
")",
";",
"}",
"else",
"{",
"$",
"className",
"=",
"strval",
"(",
"$",
"callback",
"[",
"0",
"]",
")",
";",
"}",
"$",
"functionName",
"=",
"$",
"className",
".",
"'::'",
".",
"strval",
"(",
"$",
"callback",
"[",
"1",
"]",
")",
";",
"}",
"else",
"{",
"$",
"functionName",
"=",
"strval",
"(",
"$",
"callback",
")",
";",
"}",
"return",
"$",
"functionName",
";",
"}"
] |
Print user friendly name of a callback
@param mixed $callback
@return string
|
[
"Print",
"user",
"friendly",
"name",
"of",
"a",
"callback"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/Hooks.php#L158-L172
|
26,953
|
aimeos/ai-controller-jobs
|
controller/common/src/Controller/Common/Product/Import/Csv/Processor/Base.php
|
Base.getObject
|
protected function getObject()
{
if( $this->object === null ) {
throw new \Aimeos\Controller\Jobs\Exception( 'No processor object available' );
}
return $this->object;
}
|
php
|
protected function getObject()
{
if( $this->object === null ) {
throw new \Aimeos\Controller\Jobs\Exception( 'No processor object available' );
}
return $this->object;
}
|
[
"protected",
"function",
"getObject",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"object",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"Aimeos",
"\\",
"Controller",
"\\",
"Jobs",
"\\",
"Exception",
"(",
"'No processor object available'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"object",
";",
"}"
] |
Returns the decorated processor object
@return \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface Processor object
@throws \Aimeos\Controller\Jobs\Exception If no processor object is available
|
[
"Returns",
"the",
"decorated",
"processor",
"object"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/common/src/Controller/Common/Product/Import/Csv/Processor/Base.php#L93-L100
|
26,954
|
pr-of-it/t4
|
framework/Dbal/QueryBuilder.php
|
QueryBuilder.with
|
public function with(string $modelClass, string $relationPath)
{
$relationNames = explode('.', $relationPath);
foreach ($relationNames as $index => $relationName) {
$relation = $modelClass::getRelation($relationName);
if (empty($relation)) {
throw new \BadMethodCallException('Relation does not exists!');
}
if ($relation['type'] !== \T4\Orm\Model::BELONGS_TO) {
throw new \InvalidArgumentException('Only Belongs to relations are supported!');
}
/** @var \T4\Orm\Model $relationClass */
$relationClass = $relation['model'];
$relationParents = array_slice($relationNames, 0, $index);
$aliasPointed = empty($relationParents) ? $relationName : implode('.',$relationParents) . '.' . $relationName;
$relationPathUnderscored = implode('_', $relationParents);
$aliasUnderscored = empty($relationParents) ? $relationName : $relationPathUnderscored . '_' . $relationName;
$select = [];
$columnNames = array_keys($relationClass::getColumns());
foreach ($columnNames as $columnName) {
$select["$aliasPointed.$columnName"] = "$aliasUnderscored.$columnName";
}
$this->select($select);
if (empty($this->joins) || empty(array_filter($this->joins, function($join) use ($aliasUnderscored) { return $join['alias'] == $aliasUnderscored; }))) {
$this->join($relationClass::getTableName(), $aliasUnderscored . '.' . $relationClass::PK . ' = ' . ($relationPathUnderscored ?: 't1') . '.' . $modelClass::getRelationLinkName($relation), 'left', $aliasUnderscored);
}
$modelClass = $relationClass;
}
return $this;
}
|
php
|
public function with(string $modelClass, string $relationPath)
{
$relationNames = explode('.', $relationPath);
foreach ($relationNames as $index => $relationName) {
$relation = $modelClass::getRelation($relationName);
if (empty($relation)) {
throw new \BadMethodCallException('Relation does not exists!');
}
if ($relation['type'] !== \T4\Orm\Model::BELONGS_TO) {
throw new \InvalidArgumentException('Only Belongs to relations are supported!');
}
/** @var \T4\Orm\Model $relationClass */
$relationClass = $relation['model'];
$relationParents = array_slice($relationNames, 0, $index);
$aliasPointed = empty($relationParents) ? $relationName : implode('.',$relationParents) . '.' . $relationName;
$relationPathUnderscored = implode('_', $relationParents);
$aliasUnderscored = empty($relationParents) ? $relationName : $relationPathUnderscored . '_' . $relationName;
$select = [];
$columnNames = array_keys($relationClass::getColumns());
foreach ($columnNames as $columnName) {
$select["$aliasPointed.$columnName"] = "$aliasUnderscored.$columnName";
}
$this->select($select);
if (empty($this->joins) || empty(array_filter($this->joins, function($join) use ($aliasUnderscored) { return $join['alias'] == $aliasUnderscored; }))) {
$this->join($relationClass::getTableName(), $aliasUnderscored . '.' . $relationClass::PK . ' = ' . ($relationPathUnderscored ?: 't1') . '.' . $modelClass::getRelationLinkName($relation), 'left', $aliasUnderscored);
}
$modelClass = $relationClass;
}
return $this;
}
|
[
"public",
"function",
"with",
"(",
"string",
"$",
"modelClass",
",",
"string",
"$",
"relationPath",
")",
"{",
"$",
"relationNames",
"=",
"explode",
"(",
"'.'",
",",
"$",
"relationPath",
")",
";",
"foreach",
"(",
"$",
"relationNames",
"as",
"$",
"index",
"=>",
"$",
"relationName",
")",
"{",
"$",
"relation",
"=",
"$",
"modelClass",
"::",
"getRelation",
"(",
"$",
"relationName",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"relation",
")",
")",
"{",
"throw",
"new",
"\\",
"BadMethodCallException",
"(",
"'Relation does not exists!'",
")",
";",
"}",
"if",
"(",
"$",
"relation",
"[",
"'type'",
"]",
"!==",
"\\",
"T4",
"\\",
"Orm",
"\\",
"Model",
"::",
"BELONGS_TO",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Only Belongs to relations are supported!'",
")",
";",
"}",
"/** @var \\T4\\Orm\\Model $relationClass */",
"$",
"relationClass",
"=",
"$",
"relation",
"[",
"'model'",
"]",
";",
"$",
"relationParents",
"=",
"array_slice",
"(",
"$",
"relationNames",
",",
"0",
",",
"$",
"index",
")",
";",
"$",
"aliasPointed",
"=",
"empty",
"(",
"$",
"relationParents",
")",
"?",
"$",
"relationName",
":",
"implode",
"(",
"'.'",
",",
"$",
"relationParents",
")",
".",
"'.'",
".",
"$",
"relationName",
";",
"$",
"relationPathUnderscored",
"=",
"implode",
"(",
"'_'",
",",
"$",
"relationParents",
")",
";",
"$",
"aliasUnderscored",
"=",
"empty",
"(",
"$",
"relationParents",
")",
"?",
"$",
"relationName",
":",
"$",
"relationPathUnderscored",
".",
"'_'",
".",
"$",
"relationName",
";",
"$",
"select",
"=",
"[",
"]",
";",
"$",
"columnNames",
"=",
"array_keys",
"(",
"$",
"relationClass",
"::",
"getColumns",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"columnNames",
"as",
"$",
"columnName",
")",
"{",
"$",
"select",
"[",
"\"$aliasPointed.$columnName\"",
"]",
"=",
"\"$aliasUnderscored.$columnName\"",
";",
"}",
"$",
"this",
"->",
"select",
"(",
"$",
"select",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"joins",
")",
"||",
"empty",
"(",
"array_filter",
"(",
"$",
"this",
"->",
"joins",
",",
"function",
"(",
"$",
"join",
")",
"use",
"(",
"$",
"aliasUnderscored",
")",
"{",
"return",
"$",
"join",
"[",
"'alias'",
"]",
"==",
"$",
"aliasUnderscored",
";",
"}",
")",
")",
")",
"{",
"$",
"this",
"->",
"join",
"(",
"$",
"relationClass",
"::",
"getTableName",
"(",
")",
",",
"$",
"aliasUnderscored",
".",
"'.'",
".",
"$",
"relationClass",
"::",
"PK",
".",
"' = '",
".",
"(",
"$",
"relationPathUnderscored",
"?",
":",
"'t1'",
")",
".",
"'.'",
".",
"$",
"modelClass",
"::",
"getRelationLinkName",
"(",
"$",
"relation",
")",
",",
"'left'",
",",
"$",
"aliasUnderscored",
")",
";",
"}",
"$",
"modelClass",
"=",
"$",
"relationClass",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Joins data from BelongsTo model relation
@param string|\T4\Orm\Model $modelClass
@param string $relationPath point-splitted relation chain
@return self
@throws \BadMethodCallException
@throws \InvalidArgumentException
|
[
"Joins",
"data",
"from",
"BelongsTo",
"model",
"relation"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Dbal/QueryBuilder.php#L170-L202
|
26,955
|
aimeos/ai-controller-jobs
|
controller/common/src/Controller/Common/Subscription/Process/Processor/Base.php
|
Base.renew
|
public function renew( \Aimeos\MShop\Subscription\Item\Iface $subscription, \Aimeos\MShop\Order\Item\Iface $order )
{
}
|
php
|
public function renew( \Aimeos\MShop\Subscription\Item\Iface $subscription, \Aimeos\MShop\Order\Item\Iface $order )
{
}
|
[
"public",
"function",
"renew",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Subscription",
"\\",
"Item",
"\\",
"Iface",
"$",
"subscription",
",",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Order",
"\\",
"Item",
"\\",
"Iface",
"$",
"order",
")",
"{",
"}"
] |
Processes the subscription renewal
@param \Aimeos\MShop\Subscription\Item\Iface $subscription Subscription item
@param \Aimeos\MShop\Order\Item\Iface $order Order invoice item
|
[
"Processes",
"the",
"subscription",
"renewal"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/common/src/Controller/Common/Subscription/Process/Processor/Base.php#L63-L65
|
26,956
|
aimeos/ai-controller-jobs
|
controller/common/src/Controller/Common/Product/Import/Csv/Processor/Property/Standard.php
|
Standard.process
|
public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
{
$manager = \Aimeos\MShop::create( $this->getContext(), 'product/property' );
$propMap = [];
$items = $product->getPropertyItems( null, false );
$map = $this->getMappedChunk( $data, $this->getMapping() );
foreach( $items as $item ) {
$propMap[$item->getValue()][$item->getType()] = $item;
}
foreach( $map as $list )
{
if( ( $value = $this->getValue( $list, 'product.property.value' ) ) === null ) {
continue;
}
if( ( $type = $this->getValue( $list, 'product.property.type' ) ) && !isset( $this->types[$type] ) )
{
$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'product property' );
throw new \Aimeos\Controller\Common\Exception( $msg );
}
if( isset( $propMap[$value][$type] ) )
{
$item = $propMap[$value][$type];
unset( $items[$item->getId()] );
}
else
{
$item = $manager->createItem()->setType( $type );
}
$product->addPropertyItem( $item->fromArray( $list ) );
}
$product->deletePropertyItems( $items );
return $this->getObject()->process( $product, $data );
}
|
php
|
public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
{
$manager = \Aimeos\MShop::create( $this->getContext(), 'product/property' );
$propMap = [];
$items = $product->getPropertyItems( null, false );
$map = $this->getMappedChunk( $data, $this->getMapping() );
foreach( $items as $item ) {
$propMap[$item->getValue()][$item->getType()] = $item;
}
foreach( $map as $list )
{
if( ( $value = $this->getValue( $list, 'product.property.value' ) ) === null ) {
continue;
}
if( ( $type = $this->getValue( $list, 'product.property.type' ) ) && !isset( $this->types[$type] ) )
{
$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'product property' );
throw new \Aimeos\Controller\Common\Exception( $msg );
}
if( isset( $propMap[$value][$type] ) )
{
$item = $propMap[$value][$type];
unset( $items[$item->getId()] );
}
else
{
$item = $manager->createItem()->setType( $type );
}
$product->addPropertyItem( $item->fromArray( $list ) );
}
$product->deletePropertyItems( $items );
return $this->getObject()->process( $product, $data );
}
|
[
"public",
"function",
"process",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Product",
"\\",
"Item",
"\\",
"Iface",
"$",
"product",
",",
"array",
"$",
"data",
")",
"{",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"this",
"->",
"getContext",
"(",
")",
",",
"'product/property'",
")",
";",
"$",
"propMap",
"=",
"[",
"]",
";",
"$",
"items",
"=",
"$",
"product",
"->",
"getPropertyItems",
"(",
"null",
",",
"false",
")",
";",
"$",
"map",
"=",
"$",
"this",
"->",
"getMappedChunk",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"getMapping",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"propMap",
"[",
"$",
"item",
"->",
"getValue",
"(",
")",
"]",
"[",
"$",
"item",
"->",
"getType",
"(",
")",
"]",
"=",
"$",
"item",
";",
"}",
"foreach",
"(",
"$",
"map",
"as",
"$",
"list",
")",
"{",
"if",
"(",
"(",
"$",
"value",
"=",
"$",
"this",
"->",
"getValue",
"(",
"$",
"list",
",",
"'product.property.value'",
")",
")",
"===",
"null",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"(",
"$",
"type",
"=",
"$",
"this",
"->",
"getValue",
"(",
"$",
"list",
",",
"'product.property.type'",
")",
")",
"&&",
"!",
"isset",
"(",
"$",
"this",
"->",
"types",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"msg",
"=",
"sprintf",
"(",
"'Invalid type \"%1$s\" (%2$s)'",
",",
"$",
"type",
",",
"'product property'",
")",
";",
"throw",
"new",
"\\",
"Aimeos",
"\\",
"Controller",
"\\",
"Common",
"\\",
"Exception",
"(",
"$",
"msg",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"propMap",
"[",
"$",
"value",
"]",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"item",
"=",
"$",
"propMap",
"[",
"$",
"value",
"]",
"[",
"$",
"type",
"]",
";",
"unset",
"(",
"$",
"items",
"[",
"$",
"item",
"->",
"getId",
"(",
")",
"]",
")",
";",
"}",
"else",
"{",
"$",
"item",
"=",
"$",
"manager",
"->",
"createItem",
"(",
")",
"->",
"setType",
"(",
"$",
"type",
")",
";",
"}",
"$",
"product",
"->",
"addPropertyItem",
"(",
"$",
"item",
"->",
"fromArray",
"(",
"$",
"list",
")",
")",
";",
"}",
"$",
"product",
"->",
"deletePropertyItems",
"(",
"$",
"items",
")",
";",
"return",
"$",
"this",
"->",
"getObject",
"(",
")",
"->",
"process",
"(",
"$",
"product",
",",
"$",
"data",
")",
";",
"}"
] |
Saves the product property related data to the storage
@param \Aimeos\MShop\Product\Item\Iface $product Product item with associated items
@param array $data List of CSV fields with position as key and data as value
@return array List of data which hasn't been imported
|
[
"Saves",
"the",
"product",
"property",
"related",
"data",
"to",
"the",
"storage"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/common/src/Controller/Common/Product/Import/Csv/Processor/Property/Standard.php#L66-L106
|
26,957
|
aimeos/ai-controller-jobs
|
controller/jobs/src/Controller/Jobs/Subscription/Process/Renew/Standard.php
|
Standard.addBasketAddresses
|
protected function addBasketAddresses( \Aimeos\MShop\Context\Item\Iface $context,
\Aimeos\MShop\Order\Item\Base\Iface $newBasket, array $addresses )
{
foreach( $addresses as $type => $orderAddresses )
{
foreach( $orderAddresses as $orderAddress ) {
$newBasket->addAddress( $orderAddress, $type );
}
}
return $newBasket;
}
|
php
|
protected function addBasketAddresses( \Aimeos\MShop\Context\Item\Iface $context,
\Aimeos\MShop\Order\Item\Base\Iface $newBasket, array $addresses )
{
foreach( $addresses as $type => $orderAddresses )
{
foreach( $orderAddresses as $orderAddress ) {
$newBasket->addAddress( $orderAddress, $type );
}
}
return $newBasket;
}
|
[
"protected",
"function",
"addBasketAddresses",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Context",
"\\",
"Item",
"\\",
"Iface",
"$",
"context",
",",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Order",
"\\",
"Item",
"\\",
"Base",
"\\",
"Iface",
"$",
"newBasket",
",",
"array",
"$",
"addresses",
")",
"{",
"foreach",
"(",
"$",
"addresses",
"as",
"$",
"type",
"=>",
"$",
"orderAddresses",
")",
"{",
"foreach",
"(",
"$",
"orderAddresses",
"as",
"$",
"orderAddress",
")",
"{",
"$",
"newBasket",
"->",
"addAddress",
"(",
"$",
"orderAddress",
",",
"$",
"type",
")",
";",
"}",
"}",
"return",
"$",
"newBasket",
";",
"}"
] |
Adds the given addresses to the basket
@param \Aimeos\MShop\Context\Item\Iface Context object
@param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object to add the addresses to
@param array $addresses Associative list of type as key and address object implementing \Aimeos\MShop\Order\Item\Base\Address\Iface as value
@return \Aimeos\MShop\Order\Item\Base\Iface Order with addresses added
|
[
"Adds",
"the",
"given",
"addresses",
"to",
"the",
"basket"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/jobs/src/Controller/Jobs/Subscription/Process/Renew/Standard.php#L135-L146
|
26,958
|
aimeos/ai-controller-jobs
|
controller/jobs/src/Controller/Jobs/Subscription/Process/Renew/Standard.php
|
Standard.addBasketCoupons
|
protected function addBasketCoupons( \Aimeos\MShop\Context\Item\Iface $context,
\Aimeos\MShop\Order\Item\Base\Iface $basket, array $codes )
{
/** controller/jobs/subcription/process/renew/standard/use-coupons
* Applies the coupons of the previous order also to the new one
*
* Reuse coupon codes added to the basket by the customer the first time
* again in new subcription orders. If they have any effect depends on
* the codes still being active (status, time frame and count) and the
* decorators added to the coupon providers in the admin interface.
*
* @param boolean True to reuse coupon codes, false to remove coupons
* @category Developer
* @category User
* @since 2018.10
*/
if( $context->getConfig()->get( 'controller/jobs/subcription/process/renew/standard/use-coupons', false ) )
{
foreach( $codes as $code )
{
try {
$basket->addCoupon( $code );
} catch( \Aimeos\MShop\Plugin\Provider\Exception $e ) {
$basket->deleteCoupon( $code );
}
}
}
return $basket;
}
|
php
|
protected function addBasketCoupons( \Aimeos\MShop\Context\Item\Iface $context,
\Aimeos\MShop\Order\Item\Base\Iface $basket, array $codes )
{
/** controller/jobs/subcription/process/renew/standard/use-coupons
* Applies the coupons of the previous order also to the new one
*
* Reuse coupon codes added to the basket by the customer the first time
* again in new subcription orders. If they have any effect depends on
* the codes still being active (status, time frame and count) and the
* decorators added to the coupon providers in the admin interface.
*
* @param boolean True to reuse coupon codes, false to remove coupons
* @category Developer
* @category User
* @since 2018.10
*/
if( $context->getConfig()->get( 'controller/jobs/subcription/process/renew/standard/use-coupons', false ) )
{
foreach( $codes as $code )
{
try {
$basket->addCoupon( $code );
} catch( \Aimeos\MShop\Plugin\Provider\Exception $e ) {
$basket->deleteCoupon( $code );
}
}
}
return $basket;
}
|
[
"protected",
"function",
"addBasketCoupons",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Context",
"\\",
"Item",
"\\",
"Iface",
"$",
"context",
",",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Order",
"\\",
"Item",
"\\",
"Base",
"\\",
"Iface",
"$",
"basket",
",",
"array",
"$",
"codes",
")",
"{",
"/** controller/jobs/subcription/process/renew/standard/use-coupons\n\t\t * Applies the coupons of the previous order also to the new one\n\t\t *\n\t\t * Reuse coupon codes added to the basket by the customer the first time\n\t\t * again in new subcription orders. If they have any effect depends on\n\t\t * the codes still being active (status, time frame and count) and the\n\t\t * decorators added to the coupon providers in the admin interface.\n\t\t *\n\t\t * @param boolean True to reuse coupon codes, false to remove coupons\n\t\t * @category Developer\n\t\t * @category User\n\t\t * @since 2018.10\n\t\t */",
"if",
"(",
"$",
"context",
"->",
"getConfig",
"(",
")",
"->",
"get",
"(",
"'controller/jobs/subcription/process/renew/standard/use-coupons'",
",",
"false",
")",
")",
"{",
"foreach",
"(",
"$",
"codes",
"as",
"$",
"code",
")",
"{",
"try",
"{",
"$",
"basket",
"->",
"addCoupon",
"(",
"$",
"code",
")",
";",
"}",
"catch",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Plugin",
"\\",
"Provider",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"basket",
"->",
"deleteCoupon",
"(",
"$",
"code",
")",
";",
"}",
"}",
"}",
"return",
"$",
"basket",
";",
"}"
] |
Adds the given coupon codes to basket if enabled
@param \Aimeos\MShop\Context\Item\Iface Context object
@param \Aimeos\MShop\Order\Item\Base\Iface $basket Order including product and addresses
@param array $codes List of coupon codes that should be added to the given basket
@return \Aimeos\MShop\Order\Item\Base\Iface Basket, maybe with coupons added
|
[
"Adds",
"the",
"given",
"coupon",
"codes",
"to",
"basket",
"if",
"enabled"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/jobs/src/Controller/Jobs/Subscription/Process/Renew/Standard.php#L157-L186
|
26,959
|
aimeos/ai-controller-jobs
|
controller/jobs/src/Controller/Jobs/Subscription/Process/Renew/Standard.php
|
Standard.addBasketProducts
|
protected function addBasketProducts( \Aimeos\MShop\Context\Item\Iface $context,
\Aimeos\MShop\Order\Item\Base\Iface $newBasket, array $orderProducts, $orderProductId )
{
foreach( $orderProducts as $orderProduct )
{
if( $orderProduct->getId() == $orderProductId )
{
foreach( $orderProduct->getAttributeItems() as $attrItem ) {
$attrItem->setId( null );
}
$newBasket->addProduct( $orderProduct->setId( null ) );
}
}
return $newBasket;
}
|
php
|
protected function addBasketProducts( \Aimeos\MShop\Context\Item\Iface $context,
\Aimeos\MShop\Order\Item\Base\Iface $newBasket, array $orderProducts, $orderProductId )
{
foreach( $orderProducts as $orderProduct )
{
if( $orderProduct->getId() == $orderProductId )
{
foreach( $orderProduct->getAttributeItems() as $attrItem ) {
$attrItem->setId( null );
}
$newBasket->addProduct( $orderProduct->setId( null ) );
}
}
return $newBasket;
}
|
[
"protected",
"function",
"addBasketProducts",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Context",
"\\",
"Item",
"\\",
"Iface",
"$",
"context",
",",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Order",
"\\",
"Item",
"\\",
"Base",
"\\",
"Iface",
"$",
"newBasket",
",",
"array",
"$",
"orderProducts",
",",
"$",
"orderProductId",
")",
"{",
"foreach",
"(",
"$",
"orderProducts",
"as",
"$",
"orderProduct",
")",
"{",
"if",
"(",
"$",
"orderProduct",
"->",
"getId",
"(",
")",
"==",
"$",
"orderProductId",
")",
"{",
"foreach",
"(",
"$",
"orderProduct",
"->",
"getAttributeItems",
"(",
")",
"as",
"$",
"attrItem",
")",
"{",
"$",
"attrItem",
"->",
"setId",
"(",
"null",
")",
";",
"}",
"$",
"newBasket",
"->",
"addProduct",
"(",
"$",
"orderProduct",
"->",
"setId",
"(",
"null",
")",
")",
";",
"}",
"}",
"return",
"$",
"newBasket",
";",
"}"
] |
Adds the given products to the basket
@param \Aimeos\MShop\Context\Item\Iface Context object
@param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object to add the products to
@param \Aimeos\MShop\Order\Item\Base\Product\Iface[] $orderProducts List of product items
@param string $orderProductId Unique ID of the ordered subscription product
@return \Aimeos\MShop\Order\Item\Base\Iface Order with products added
|
[
"Adds",
"the",
"given",
"products",
"to",
"the",
"basket"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/jobs/src/Controller/Jobs/Subscription/Process/Renew/Standard.php#L198-L213
|
26,960
|
aimeos/ai-controller-jobs
|
controller/jobs/src/Controller/Jobs/Subscription/Process/Renew/Standard.php
|
Standard.addBasketServices
|
protected function addBasketServices( \Aimeos\MShop\Context\Item\Iface $context,
\Aimeos\MShop\Order\Item\Base\Iface $newBasket, array $services )
{
$type = \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT;
if( isset( $services[$type] ) )
{
foreach( $services[$type] as $orderService ) {
$newBasket->addService( $orderService, $type );
}
}
$type = \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY;
$serviceManager = \Aimeos\MShop::create( $context, 'service' );
$orderServiceManager = \Aimeos\MShop::create( $context, 'order/base/service' );
$search = $serviceManager->createSearch( true );
$search->setSortations( [$search->sort( '+', 'service.position' )] );
$search->setConditions( $search->compare( '==', 'service.type', $type ) );
foreach( $serviceManager->searchItems( $search, ['media', 'price', 'text'] ) as $item )
{
$provider = $serviceManager->getProvider( $item, $item->getType() );
if( $provider->isAvailable( $newBasket ) === true )
{
$orderServiceItem = $orderServiceManager->createItem()->copyFrom( $item );
return $newBasket->addService( $orderServiceItem, $type );
}
}
return $newBasket;
}
|
php
|
protected function addBasketServices( \Aimeos\MShop\Context\Item\Iface $context,
\Aimeos\MShop\Order\Item\Base\Iface $newBasket, array $services )
{
$type = \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT;
if( isset( $services[$type] ) )
{
foreach( $services[$type] as $orderService ) {
$newBasket->addService( $orderService, $type );
}
}
$type = \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY;
$serviceManager = \Aimeos\MShop::create( $context, 'service' );
$orderServiceManager = \Aimeos\MShop::create( $context, 'order/base/service' );
$search = $serviceManager->createSearch( true );
$search->setSortations( [$search->sort( '+', 'service.position' )] );
$search->setConditions( $search->compare( '==', 'service.type', $type ) );
foreach( $serviceManager->searchItems( $search, ['media', 'price', 'text'] ) as $item )
{
$provider = $serviceManager->getProvider( $item, $item->getType() );
if( $provider->isAvailable( $newBasket ) === true )
{
$orderServiceItem = $orderServiceManager->createItem()->copyFrom( $item );
return $newBasket->addService( $orderServiceItem, $type );
}
}
return $newBasket;
}
|
[
"protected",
"function",
"addBasketServices",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Context",
"\\",
"Item",
"\\",
"Iface",
"$",
"context",
",",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Order",
"\\",
"Item",
"\\",
"Base",
"\\",
"Iface",
"$",
"newBasket",
",",
"array",
"$",
"services",
")",
"{",
"$",
"type",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Order",
"\\",
"Item",
"\\",
"Base",
"\\",
"Service",
"\\",
"Base",
"::",
"TYPE_PAYMENT",
";",
"if",
"(",
"isset",
"(",
"$",
"services",
"[",
"$",
"type",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"services",
"[",
"$",
"type",
"]",
"as",
"$",
"orderService",
")",
"{",
"$",
"newBasket",
"->",
"addService",
"(",
"$",
"orderService",
",",
"$",
"type",
")",
";",
"}",
"}",
"$",
"type",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Order",
"\\",
"Item",
"\\",
"Base",
"\\",
"Service",
"\\",
"Base",
"::",
"TYPE_DELIVERY",
";",
"$",
"serviceManager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"context",
",",
"'service'",
")",
";",
"$",
"orderServiceManager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"context",
",",
"'order/base/service'",
")",
";",
"$",
"search",
"=",
"$",
"serviceManager",
"->",
"createSearch",
"(",
"true",
")",
";",
"$",
"search",
"->",
"setSortations",
"(",
"[",
"$",
"search",
"->",
"sort",
"(",
"'+'",
",",
"'service.position'",
")",
"]",
")",
";",
"$",
"search",
"->",
"setConditions",
"(",
"$",
"search",
"->",
"compare",
"(",
"'=='",
",",
"'service.type'",
",",
"$",
"type",
")",
")",
";",
"foreach",
"(",
"$",
"serviceManager",
"->",
"searchItems",
"(",
"$",
"search",
",",
"[",
"'media'",
",",
"'price'",
",",
"'text'",
"]",
")",
"as",
"$",
"item",
")",
"{",
"$",
"provider",
"=",
"$",
"serviceManager",
"->",
"getProvider",
"(",
"$",
"item",
",",
"$",
"item",
"->",
"getType",
"(",
")",
")",
";",
"if",
"(",
"$",
"provider",
"->",
"isAvailable",
"(",
"$",
"newBasket",
")",
"===",
"true",
")",
"{",
"$",
"orderServiceItem",
"=",
"$",
"orderServiceManager",
"->",
"createItem",
"(",
")",
"->",
"copyFrom",
"(",
"$",
"item",
")",
";",
"return",
"$",
"newBasket",
"->",
"addService",
"(",
"$",
"orderServiceItem",
",",
"$",
"type",
")",
";",
"}",
"}",
"return",
"$",
"newBasket",
";",
"}"
] |
Adds a matching delivery and payment service to the basket
@param \Aimeos\MShop\Context\Item\Iface Context object
@param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object to add the services to
@param array $services Associative list of type as key and list of service objects implementing \Aimeos\MShop\Order\Item\Base\Service\Iface as values
@return \Aimeos\MShop\Order\Item\Base\Iface Order with delivery and payment service added
|
[
"Adds",
"a",
"matching",
"delivery",
"and",
"payment",
"service",
"to",
"the",
"basket"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/jobs/src/Controller/Jobs/Subscription/Process/Renew/Standard.php#L224-L257
|
26,961
|
aimeos/ai-controller-jobs
|
controller/jobs/src/Controller/Jobs/Subscription/Process/Renew/Standard.php
|
Standard.createContext
|
protected function createContext( $baseId )
{
$context = clone $this->getContext();
$manager = \Aimeos\MShop::create( $context, 'order/base' );
$baseItem = $manager->getItem( $baseId );
$locale = $baseItem->getLocale();
$level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL;
$manager = \Aimeos\MShop::create( $context, 'locale' );
$locale = $manager->bootstrap( $baseItem->getSiteCode(), $locale->getLanguageId(), $locale->getCurrencyId(), false, $level );
$context->setLocale( $locale );
try
{
$manager = \Aimeos\MShop::create( $context, 'customer' );
$customerItem = $manager->getItem( $baseItem->getCustomerId(), ['customer/group'] );
$context->setUserId( $baseItem->getCustomerId() );
$context->setGroupIds( $customerItem->getGroups() );
}
catch( \Exception $e ) {} // Subscription without account
return $context;
}
|
php
|
protected function createContext( $baseId )
{
$context = clone $this->getContext();
$manager = \Aimeos\MShop::create( $context, 'order/base' );
$baseItem = $manager->getItem( $baseId );
$locale = $baseItem->getLocale();
$level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL;
$manager = \Aimeos\MShop::create( $context, 'locale' );
$locale = $manager->bootstrap( $baseItem->getSiteCode(), $locale->getLanguageId(), $locale->getCurrencyId(), false, $level );
$context->setLocale( $locale );
try
{
$manager = \Aimeos\MShop::create( $context, 'customer' );
$customerItem = $manager->getItem( $baseItem->getCustomerId(), ['customer/group'] );
$context->setUserId( $baseItem->getCustomerId() );
$context->setGroupIds( $customerItem->getGroups() );
}
catch( \Exception $e ) {} // Subscription without account
return $context;
}
|
[
"protected",
"function",
"createContext",
"(",
"$",
"baseId",
")",
"{",
"$",
"context",
"=",
"clone",
"$",
"this",
"->",
"getContext",
"(",
")",
";",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"context",
",",
"'order/base'",
")",
";",
"$",
"baseItem",
"=",
"$",
"manager",
"->",
"getItem",
"(",
"$",
"baseId",
")",
";",
"$",
"locale",
"=",
"$",
"baseItem",
"->",
"getLocale",
"(",
")",
";",
"$",
"level",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Locale",
"\\",
"Manager",
"\\",
"Base",
"::",
"SITE_ALL",
";",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"context",
",",
"'locale'",
")",
";",
"$",
"locale",
"=",
"$",
"manager",
"->",
"bootstrap",
"(",
"$",
"baseItem",
"->",
"getSiteCode",
"(",
")",
",",
"$",
"locale",
"->",
"getLanguageId",
"(",
")",
",",
"$",
"locale",
"->",
"getCurrencyId",
"(",
")",
",",
"false",
",",
"$",
"level",
")",
";",
"$",
"context",
"->",
"setLocale",
"(",
"$",
"locale",
")",
";",
"try",
"{",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"context",
",",
"'customer'",
")",
";",
"$",
"customerItem",
"=",
"$",
"manager",
"->",
"getItem",
"(",
"$",
"baseItem",
"->",
"getCustomerId",
"(",
")",
",",
"[",
"'customer/group'",
"]",
")",
";",
"$",
"context",
"->",
"setUserId",
"(",
"$",
"baseItem",
"->",
"getCustomerId",
"(",
")",
")",
";",
"$",
"context",
"->",
"setGroupIds",
"(",
"$",
"customerItem",
"->",
"getGroups",
"(",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"}",
"// Subscription without account",
"return",
"$",
"context",
";",
"}"
] |
Creates a new context based on the order and the customer the subscription belongs to
@param string $baseId Unique order base ID
@return \Aimeos\MShop\Context\Item\Iface New context object
|
[
"Creates",
"a",
"new",
"context",
"based",
"on",
"the",
"order",
"and",
"the",
"customer",
"the",
"subscription",
"belongs",
"to"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/jobs/src/Controller/Jobs/Subscription/Process/Renew/Standard.php#L266-L292
|
26,962
|
aimeos/ai-controller-jobs
|
controller/jobs/src/Controller/Jobs/Subscription/Process/Renew/Standard.php
|
Standard.createOrderBase
|
protected function createOrderBase( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Subscription\Item\Iface $subscription )
{
$manager = \Aimeos\MShop::create( $context, 'order/base' );
$basket = $manager->load( $subscription->getOrderBaseId() );
$newBasket = $manager->createItem()->setCustomerId( $basket->getCustomerId() );
$newBasket = $this->addBasketProducts( $context, $newBasket, $basket->getProducts(), $subscription->getOrderProductId() );
$newBasket = $this->addBasketAddresses( $context, $newBasket, $basket->getAddresses() );
$newBasket = $this->addBasketServices( $context, $newBasket, $basket->getServices() );
$newBasket = $this->addBasketCoupons( $context, $newBasket, array_keys( $basket->getCoupons() ) );
return $manager->store( $newBasket );
}
|
php
|
protected function createOrderBase( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Subscription\Item\Iface $subscription )
{
$manager = \Aimeos\MShop::create( $context, 'order/base' );
$basket = $manager->load( $subscription->getOrderBaseId() );
$newBasket = $manager->createItem()->setCustomerId( $basket->getCustomerId() );
$newBasket = $this->addBasketProducts( $context, $newBasket, $basket->getProducts(), $subscription->getOrderProductId() );
$newBasket = $this->addBasketAddresses( $context, $newBasket, $basket->getAddresses() );
$newBasket = $this->addBasketServices( $context, $newBasket, $basket->getServices() );
$newBasket = $this->addBasketCoupons( $context, $newBasket, array_keys( $basket->getCoupons() ) );
return $manager->store( $newBasket );
}
|
[
"protected",
"function",
"createOrderBase",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Context",
"\\",
"Item",
"\\",
"Iface",
"$",
"context",
",",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Subscription",
"\\",
"Item",
"\\",
"Iface",
"$",
"subscription",
")",
"{",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"context",
",",
"'order/base'",
")",
";",
"$",
"basket",
"=",
"$",
"manager",
"->",
"load",
"(",
"$",
"subscription",
"->",
"getOrderBaseId",
"(",
")",
")",
";",
"$",
"newBasket",
"=",
"$",
"manager",
"->",
"createItem",
"(",
")",
"->",
"setCustomerId",
"(",
"$",
"basket",
"->",
"getCustomerId",
"(",
")",
")",
";",
"$",
"newBasket",
"=",
"$",
"this",
"->",
"addBasketProducts",
"(",
"$",
"context",
",",
"$",
"newBasket",
",",
"$",
"basket",
"->",
"getProducts",
"(",
")",
",",
"$",
"subscription",
"->",
"getOrderProductId",
"(",
")",
")",
";",
"$",
"newBasket",
"=",
"$",
"this",
"->",
"addBasketAddresses",
"(",
"$",
"context",
",",
"$",
"newBasket",
",",
"$",
"basket",
"->",
"getAddresses",
"(",
")",
")",
";",
"$",
"newBasket",
"=",
"$",
"this",
"->",
"addBasketServices",
"(",
"$",
"context",
",",
"$",
"newBasket",
",",
"$",
"basket",
"->",
"getServices",
"(",
")",
")",
";",
"$",
"newBasket",
"=",
"$",
"this",
"->",
"addBasketCoupons",
"(",
"$",
"context",
",",
"$",
"newBasket",
",",
"array_keys",
"(",
"$",
"basket",
"->",
"getCoupons",
"(",
")",
")",
")",
";",
"return",
"$",
"manager",
"->",
"store",
"(",
"$",
"newBasket",
")",
";",
"}"
] |
Creates and stores a new order for the subscribed product
@param \Aimeos\MShop\Context\Item\Iface Context object
@param \Aimeos\MShop\Subscription\Item\Iface $subscription Subscription item with order base ID and order product ID
@return \Aimeos\MShop\Order\Item\Base\Iface Complete order with product, addresses and services saved to the storage
|
[
"Creates",
"and",
"stores",
"a",
"new",
"order",
"for",
"the",
"subscribed",
"product"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/jobs/src/Controller/Jobs/Subscription/Process/Renew/Standard.php#L302-L315
|
26,963
|
aimeos/ai-controller-jobs
|
controller/jobs/src/Controller/Jobs/Subscription/Process/Renew/Standard.php
|
Standard.createOrderInvoice
|
protected function createOrderInvoice( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket )
{
$manager = \Aimeos\MShop::create( $context, 'order' );
$item = $manager->createItem();
$item->setBaseId( $basket->getId() );
$item->setType( 'subscription' );
return $manager->saveItem( $item );
}
|
php
|
protected function createOrderInvoice( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket )
{
$manager = \Aimeos\MShop::create( $context, 'order' );
$item = $manager->createItem();
$item->setBaseId( $basket->getId() );
$item->setType( 'subscription' );
return $manager->saveItem( $item );
}
|
[
"protected",
"function",
"createOrderInvoice",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Context",
"\\",
"Item",
"\\",
"Iface",
"$",
"context",
",",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Order",
"\\",
"Item",
"\\",
"Base",
"\\",
"Iface",
"$",
"basket",
")",
"{",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"context",
",",
"'order'",
")",
";",
"$",
"item",
"=",
"$",
"manager",
"->",
"createItem",
"(",
")",
";",
"$",
"item",
"->",
"setBaseId",
"(",
"$",
"basket",
"->",
"getId",
"(",
")",
")",
";",
"$",
"item",
"->",
"setType",
"(",
"'subscription'",
")",
";",
"return",
"$",
"manager",
"->",
"saveItem",
"(",
"$",
"item",
")",
";",
"}"
] |
Creates and stores a new invoice for the given order basket
@param \Aimeos\MShop\Context\Item\Iface Context object
@param \Aimeos\MShop\Order\Item\Base\Iface $basket Complete order with product, addresses and services saved to the storage
@return \Aimeos\MShop\Order\Item\Iface New invoice item associated to the order saved to the storage
|
[
"Creates",
"and",
"stores",
"a",
"new",
"invoice",
"for",
"the",
"given",
"order",
"basket"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/jobs/src/Controller/Jobs/Subscription/Process/Renew/Standard.php#L325-L334
|
26,964
|
aimeos/ai-controller-jobs
|
controller/jobs/src/Controller/Jobs/Subscription/Process/Renew/Standard.php
|
Standard.createPayment
|
protected function createPayment( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket,
\Aimeos\MShop\Order\Item\Iface $invoice )
{
$manager = \Aimeos\MShop::create( $context, 'service' );
foreach( $basket->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT ) as $service )
{
$item = $manager->getItem( $service->getServiceId() );
$provider = $manager->getProvider( $item, 'payment' );
$provider->repay( $invoice );
}
}
|
php
|
protected function createPayment( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket,
\Aimeos\MShop\Order\Item\Iface $invoice )
{
$manager = \Aimeos\MShop::create( $context, 'service' );
foreach( $basket->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT ) as $service )
{
$item = $manager->getItem( $service->getServiceId() );
$provider = $manager->getProvider( $item, 'payment' );
$provider->repay( $invoice );
}
}
|
[
"protected",
"function",
"createPayment",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Context",
"\\",
"Item",
"\\",
"Iface",
"$",
"context",
",",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Order",
"\\",
"Item",
"\\",
"Base",
"\\",
"Iface",
"$",
"basket",
",",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Order",
"\\",
"Item",
"\\",
"Iface",
"$",
"invoice",
")",
"{",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"context",
",",
"'service'",
")",
";",
"foreach",
"(",
"$",
"basket",
"->",
"getService",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Order",
"\\",
"Item",
"\\",
"Base",
"\\",
"Service",
"\\",
"Base",
"::",
"TYPE_PAYMENT",
")",
"as",
"$",
"service",
")",
"{",
"$",
"item",
"=",
"$",
"manager",
"->",
"getItem",
"(",
"$",
"service",
"->",
"getServiceId",
"(",
")",
")",
";",
"$",
"provider",
"=",
"$",
"manager",
"->",
"getProvider",
"(",
"$",
"item",
",",
"'payment'",
")",
";",
"$",
"provider",
"->",
"repay",
"(",
"$",
"invoice",
")",
";",
"}",
"}"
] |
Creates a new payment for the given order and invoice
@param \Aimeos\MShop\Context\Item\Iface Context object
@param \Aimeos\MShop\Order\Item\Base\Iface $basket Complete order with product, addresses and services
@param \Aimeos\MShop\Order\Item\Iface New invoice item associated to the order
|
[
"Creates",
"a",
"new",
"payment",
"for",
"the",
"given",
"order",
"and",
"invoice"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/jobs/src/Controller/Jobs/Subscription/Process/Renew/Standard.php#L344-L356
|
26,965
|
aimeos/ai-controller-jobs
|
controller/jobs/src/Controller/Jobs/Catalog/Import/Csv/Standard.php
|
Standard.getCatalogMap
|
protected function getCatalogMap( array $domains )
{
$map = [];
$manager = \Aimeos\MShop::create( $this->getContext(), 'catalog' );
$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
foreach( $manager->searchItems( $search, $domains ) as $item ) {
$map[$item->getCode()] = $item;
}
return $map;
}
|
php
|
protected function getCatalogMap( array $domains )
{
$map = [];
$manager = \Aimeos\MShop::create( $this->getContext(), 'catalog' );
$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
foreach( $manager->searchItems( $search, $domains ) as $item ) {
$map[$item->getCode()] = $item;
}
return $map;
}
|
[
"protected",
"function",
"getCatalogMap",
"(",
"array",
"$",
"domains",
")",
"{",
"$",
"map",
"=",
"[",
"]",
";",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"this",
"->",
"getContext",
"(",
")",
",",
"'catalog'",
")",
";",
"$",
"search",
"=",
"$",
"manager",
"->",
"createSearch",
"(",
")",
"->",
"setSlice",
"(",
"0",
",",
"0x7fffffff",
")",
";",
"foreach",
"(",
"$",
"manager",
"->",
"searchItems",
"(",
"$",
"search",
",",
"$",
"domains",
")",
"as",
"$",
"item",
")",
"{",
"$",
"map",
"[",
"$",
"item",
"->",
"getCode",
"(",
")",
"]",
"=",
"$",
"item",
";",
"}",
"return",
"$",
"map",
";",
"}"
] |
Returns the catalog items building the tree as list
@param array $domains List of domain names whose items should be fetched too
@return array Associative list of catalog codes as keys and items implementing \Aimeos\MShop\Catalog\Item\Iface as values
|
[
"Returns",
"the",
"catalog",
"items",
"building",
"the",
"tree",
"as",
"list"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/jobs/src/Controller/Jobs/Catalog/Import/Csv/Standard.php#L507-L518
|
26,966
|
aimeos/ai-controller-jobs
|
controller/jobs/src/Controller/Jobs/Catalog/Import/Csv/Standard.php
|
Standard.getParentId
|
protected function getParentId( array $catalogMap, array $map, $code )
{
if( !isset( $map['catalog.parent'] ) )
{
$msg = sprintf( 'Required column "%1$s" not found for code "%2$s"', 'catalog.parent', $code );
throw new \Aimeos\Controller\Jobs\Exception( $msg );
}
$parent = trim( $map['catalog.parent'] );
if( $parent != '' && !isset( $catalogMap[$parent] ) )
{
$msg = sprintf( 'Parent node for code "%1$s" not found', $parent );
throw new \Aimeos\Controller\Jobs\Exception( $msg );
}
return ( $parent != '' ? $catalogMap[$parent]->getId() : null );
}
|
php
|
protected function getParentId( array $catalogMap, array $map, $code )
{
if( !isset( $map['catalog.parent'] ) )
{
$msg = sprintf( 'Required column "%1$s" not found for code "%2$s"', 'catalog.parent', $code );
throw new \Aimeos\Controller\Jobs\Exception( $msg );
}
$parent = trim( $map['catalog.parent'] );
if( $parent != '' && !isset( $catalogMap[$parent] ) )
{
$msg = sprintf( 'Parent node for code "%1$s" not found', $parent );
throw new \Aimeos\Controller\Jobs\Exception( $msg );
}
return ( $parent != '' ? $catalogMap[$parent]->getId() : null );
}
|
[
"protected",
"function",
"getParentId",
"(",
"array",
"$",
"catalogMap",
",",
"array",
"$",
"map",
",",
"$",
"code",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"map",
"[",
"'catalog.parent'",
"]",
")",
")",
"{",
"$",
"msg",
"=",
"sprintf",
"(",
"'Required column \"%1$s\" not found for code \"%2$s\"'",
",",
"'catalog.parent'",
",",
"$",
"code",
")",
";",
"throw",
"new",
"\\",
"Aimeos",
"\\",
"Controller",
"\\",
"Jobs",
"\\",
"Exception",
"(",
"$",
"msg",
")",
";",
"}",
"$",
"parent",
"=",
"trim",
"(",
"$",
"map",
"[",
"'catalog.parent'",
"]",
")",
";",
"if",
"(",
"$",
"parent",
"!=",
"''",
"&&",
"!",
"isset",
"(",
"$",
"catalogMap",
"[",
"$",
"parent",
"]",
")",
")",
"{",
"$",
"msg",
"=",
"sprintf",
"(",
"'Parent node for code \"%1$s\" not found'",
",",
"$",
"parent",
")",
";",
"throw",
"new",
"\\",
"Aimeos",
"\\",
"Controller",
"\\",
"Jobs",
"\\",
"Exception",
"(",
"$",
"msg",
")",
";",
"}",
"return",
"(",
"$",
"parent",
"!=",
"''",
"?",
"$",
"catalogMap",
"[",
"$",
"parent",
"]",
"->",
"getId",
"(",
")",
":",
"null",
")",
";",
"}"
] |
Returns the parent ID of the catalog node for the given code
@param array $catalogMap Associative list of catalog items with codes as keys and items implementing \Aimeos\MShop\Catalog\Item\Iface as values
@param array $map Associative list of catalog item key/value pairs
@param string $code Catalog item code of the parent category
@return string|null ID of the parent category or null for top level nodes
|
[
"Returns",
"the",
"parent",
"ID",
"of",
"the",
"catalog",
"node",
"for",
"the",
"given",
"code"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/jobs/src/Controller/Jobs/Catalog/Import/Csv/Standard.php#L529-L546
|
26,967
|
aimeos/ai-controller-jobs
|
controller/jobs/src/Controller/Jobs/Catalog/Import/Csv/Standard.php
|
Standard.import
|
protected function import( array &$catalogMap, array $data, array $mapping,
\Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $processor, $strict )
{
$errors = 0;
$context = $this->getContext();
$manager = \Aimeos\MShop::create( $context, 'catalog' );
foreach( $data as $code => $list )
{
$manager->begin();
try
{
$code = trim( $code );
if( isset( $catalogMap[$code] ) ) {
$item = $catalogMap[$code];
} else {
$item = $manager->createItem();
}
$map = $this->getMappedChunk( $list, $mapping );
if( isset( $map[0] ) )
{
$map = $map[0]; // there can only be one chunk for the base catalog data
$parentid = $this->getParentId( $catalogMap, $map, $code );
$item->fromArray( $map, true );
if( isset( $catalogMap[$code] ) )
{
$manager->moveItem( $item->getId(), $item->getParentId(), $parentid );
$item = $manager->saveItem( $item );
}
else
{
$item = $manager->insertItem( $item, $parentid );
}
$list = $processor->process( $item, $list );
$catalogMap[$code] = $item;
$manager->saveItem( $item );
}
$manager->commit();
}
catch( \Exception $e )
{
$manager->rollback();
$msg = sprintf( 'Unable to import catalog with code "%1$s": %2$s', $code, $e->getMessage() );
$context->getLogger()->log( $msg );
$errors++;
}
if( $strict && !empty( $list ) ) {
$context->getLogger()->log( 'Not imported: ' . print_r( $list, true ) );
}
}
return $errors;
}
|
php
|
protected function import( array &$catalogMap, array $data, array $mapping,
\Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $processor, $strict )
{
$errors = 0;
$context = $this->getContext();
$manager = \Aimeos\MShop::create( $context, 'catalog' );
foreach( $data as $code => $list )
{
$manager->begin();
try
{
$code = trim( $code );
if( isset( $catalogMap[$code] ) ) {
$item = $catalogMap[$code];
} else {
$item = $manager->createItem();
}
$map = $this->getMappedChunk( $list, $mapping );
if( isset( $map[0] ) )
{
$map = $map[0]; // there can only be one chunk for the base catalog data
$parentid = $this->getParentId( $catalogMap, $map, $code );
$item->fromArray( $map, true );
if( isset( $catalogMap[$code] ) )
{
$manager->moveItem( $item->getId(), $item->getParentId(), $parentid );
$item = $manager->saveItem( $item );
}
else
{
$item = $manager->insertItem( $item, $parentid );
}
$list = $processor->process( $item, $list );
$catalogMap[$code] = $item;
$manager->saveItem( $item );
}
$manager->commit();
}
catch( \Exception $e )
{
$manager->rollback();
$msg = sprintf( 'Unable to import catalog with code "%1$s": %2$s', $code, $e->getMessage() );
$context->getLogger()->log( $msg );
$errors++;
}
if( $strict && !empty( $list ) ) {
$context->getLogger()->log( 'Not imported: ' . print_r( $list, true ) );
}
}
return $errors;
}
|
[
"protected",
"function",
"import",
"(",
"array",
"&",
"$",
"catalogMap",
",",
"array",
"$",
"data",
",",
"array",
"$",
"mapping",
",",
"\\",
"Aimeos",
"\\",
"Controller",
"\\",
"Common",
"\\",
"Catalog",
"\\",
"Import",
"\\",
"Csv",
"\\",
"Processor",
"\\",
"Iface",
"$",
"processor",
",",
"$",
"strict",
")",
"{",
"$",
"errors",
"=",
"0",
";",
"$",
"context",
"=",
"$",
"this",
"->",
"getContext",
"(",
")",
";",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"context",
",",
"'catalog'",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"code",
"=>",
"$",
"list",
")",
"{",
"$",
"manager",
"->",
"begin",
"(",
")",
";",
"try",
"{",
"$",
"code",
"=",
"trim",
"(",
"$",
"code",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"catalogMap",
"[",
"$",
"code",
"]",
")",
")",
"{",
"$",
"item",
"=",
"$",
"catalogMap",
"[",
"$",
"code",
"]",
";",
"}",
"else",
"{",
"$",
"item",
"=",
"$",
"manager",
"->",
"createItem",
"(",
")",
";",
"}",
"$",
"map",
"=",
"$",
"this",
"->",
"getMappedChunk",
"(",
"$",
"list",
",",
"$",
"mapping",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"map",
"[",
"0",
"]",
")",
")",
"{",
"$",
"map",
"=",
"$",
"map",
"[",
"0",
"]",
";",
"// there can only be one chunk for the base catalog data",
"$",
"parentid",
"=",
"$",
"this",
"->",
"getParentId",
"(",
"$",
"catalogMap",
",",
"$",
"map",
",",
"$",
"code",
")",
";",
"$",
"item",
"->",
"fromArray",
"(",
"$",
"map",
",",
"true",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"catalogMap",
"[",
"$",
"code",
"]",
")",
")",
"{",
"$",
"manager",
"->",
"moveItem",
"(",
"$",
"item",
"->",
"getId",
"(",
")",
",",
"$",
"item",
"->",
"getParentId",
"(",
")",
",",
"$",
"parentid",
")",
";",
"$",
"item",
"=",
"$",
"manager",
"->",
"saveItem",
"(",
"$",
"item",
")",
";",
"}",
"else",
"{",
"$",
"item",
"=",
"$",
"manager",
"->",
"insertItem",
"(",
"$",
"item",
",",
"$",
"parentid",
")",
";",
"}",
"$",
"list",
"=",
"$",
"processor",
"->",
"process",
"(",
"$",
"item",
",",
"$",
"list",
")",
";",
"$",
"catalogMap",
"[",
"$",
"code",
"]",
"=",
"$",
"item",
";",
"$",
"manager",
"->",
"saveItem",
"(",
"$",
"item",
")",
";",
"}",
"$",
"manager",
"->",
"commit",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"manager",
"->",
"rollback",
"(",
")",
";",
"$",
"msg",
"=",
"sprintf",
"(",
"'Unable to import catalog with code \"%1$s\": %2$s'",
",",
"$",
"code",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"$",
"context",
"->",
"getLogger",
"(",
")",
"->",
"log",
"(",
"$",
"msg",
")",
";",
"$",
"errors",
"++",
";",
"}",
"if",
"(",
"$",
"strict",
"&&",
"!",
"empty",
"(",
"$",
"list",
")",
")",
"{",
"$",
"context",
"->",
"getLogger",
"(",
")",
"->",
"log",
"(",
"'Not imported: '",
".",
"print_r",
"(",
"$",
"list",
",",
"true",
")",
")",
";",
"}",
"}",
"return",
"$",
"errors",
";",
"}"
] |
Imports the CSV data and creates new categories or updates existing ones
@param array &$catalogMap Associative list of catalog items with codes as keys and items implementing \Aimeos\MShop\Catalog\Item\Iface as values
@param array $data Associative list of import data as index/value pairs
@param array $mapping Associative list of positions and domain item keys
@param \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $processor Processor object
@param boolean $strict Log columns not mapped or silently ignore them
@return integer Number of catalogs that couldn't be imported
@throws \Aimeos\Controller\Jobs\Exception
|
[
"Imports",
"the",
"CSV",
"data",
"and",
"creates",
"new",
"categories",
"or",
"updates",
"existing",
"ones"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/jobs/src/Controller/Jobs/Catalog/Import/Csv/Standard.php#L560-L623
|
26,968
|
aimeos/ai-controller-jobs
|
controller/jobs/src/Controller/Jobs/Stock/Import/Csv/Standard.php
|
Standard.getStockItems
|
protected function getStockItems( array $codes, array $types )
{
$map = [];
$manager = \Aimeos\MShop::create( $this->getContext(), 'stock' );
$search = $manager->createSearch()->setSlice( 0, 10000 );
$search->setConditions( $search->combine( '&&', [
$search->compare( '==', 'stock.productcode', $codes ),
$search->compare( '==', 'stock.type', $types )
] ) );
foreach( $manager->searchItems( $search ) as $item ) {
$map[$item->getProductCode()][$item->getType()] = $item;
}
return $map;
}
|
php
|
protected function getStockItems( array $codes, array $types )
{
$map = [];
$manager = \Aimeos\MShop::create( $this->getContext(), 'stock' );
$search = $manager->createSearch()->setSlice( 0, 10000 );
$search->setConditions( $search->combine( '&&', [
$search->compare( '==', 'stock.productcode', $codes ),
$search->compare( '==', 'stock.type', $types )
] ) );
foreach( $manager->searchItems( $search ) as $item ) {
$map[$item->getProductCode()][$item->getType()] = $item;
}
return $map;
}
|
[
"protected",
"function",
"getStockItems",
"(",
"array",
"$",
"codes",
",",
"array",
"$",
"types",
")",
"{",
"$",
"map",
"=",
"[",
"]",
";",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"this",
"->",
"getContext",
"(",
")",
",",
"'stock'",
")",
";",
"$",
"search",
"=",
"$",
"manager",
"->",
"createSearch",
"(",
")",
"->",
"setSlice",
"(",
"0",
",",
"10000",
")",
";",
"$",
"search",
"->",
"setConditions",
"(",
"$",
"search",
"->",
"combine",
"(",
"'&&'",
",",
"[",
"$",
"search",
"->",
"compare",
"(",
"'=='",
",",
"'stock.productcode'",
",",
"$",
"codes",
")",
",",
"$",
"search",
"->",
"compare",
"(",
"'=='",
",",
"'stock.type'",
",",
"$",
"types",
")",
"]",
")",
")",
";",
"foreach",
"(",
"$",
"manager",
"->",
"searchItems",
"(",
"$",
"search",
")",
"as",
"$",
"item",
")",
"{",
"$",
"map",
"[",
"$",
"item",
"->",
"getProductCode",
"(",
")",
"]",
"[",
"$",
"item",
"->",
"getType",
"(",
")",
"]",
"=",
"$",
"item",
";",
"}",
"return",
"$",
"map",
";",
"}"
] |
Returns the stock items for the given codes and types
@param array $codes List of stock codes
@param array $types List of stock types
@return array Multi-dimensional array of code/type/item map
|
[
"Returns",
"the",
"stock",
"items",
"for",
"the",
"given",
"codes",
"and",
"types"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/jobs/src/Controller/Jobs/Stock/Import/Csv/Standard.php#L285-L301
|
26,969
|
aimeos/ai-controller-jobs
|
controller/jobs/src/Controller/Jobs/Stock/Import/Csv/Standard.php
|
Standard.importStocks
|
protected function importStocks( \Aimeos\MW\Container\Content\Iface $content, $maxcnt )
{
$total = 0;
$manager = \Aimeos\MShop::create( $this->getContext(), 'stock' );
do
{
$count = 0;
$codes = $data = $items = $types = [];
while( $content->valid() && $count < $maxcnt )
{
$row = $content->current();
$content->next();
if( $row[0] == '' ) {
continue;
}
$type = $this->getValue( $row, 2, 'default' );
$types[$type] = null;
$codes[] = $row[0];
$row[2] = $type;
$data[] = $row;
$count++;
}
if( $count === 0 ) {
break;
}
$items = [];
$map = $this->getStockItems( $codes, array_keys( $types ) );
foreach( $data as $entry )
{
$code = $entry[0];
$type = $entry[2];
if( isset( $map[$code][$type] ) ) {
$item = $map[$code][$type];
} else {
$item = $manager->createItem();
}
$items[] = $item->setProductCode( $code )->setType( $type )
->setStocklevel( $this->getValue( $entry, 1 ) )
->setDateBack( $this->getValue( $entry, 3 ) );
unset( $map[$code][$type] );
}
$manager->saveItems( $items );
unset( $items );
$total += $count;
}
while( $count > 0 );
return $total;
}
|
php
|
protected function importStocks( \Aimeos\MW\Container\Content\Iface $content, $maxcnt )
{
$total = 0;
$manager = \Aimeos\MShop::create( $this->getContext(), 'stock' );
do
{
$count = 0;
$codes = $data = $items = $types = [];
while( $content->valid() && $count < $maxcnt )
{
$row = $content->current();
$content->next();
if( $row[0] == '' ) {
continue;
}
$type = $this->getValue( $row, 2, 'default' );
$types[$type] = null;
$codes[] = $row[0];
$row[2] = $type;
$data[] = $row;
$count++;
}
if( $count === 0 ) {
break;
}
$items = [];
$map = $this->getStockItems( $codes, array_keys( $types ) );
foreach( $data as $entry )
{
$code = $entry[0];
$type = $entry[2];
if( isset( $map[$code][$type] ) ) {
$item = $map[$code][$type];
} else {
$item = $manager->createItem();
}
$items[] = $item->setProductCode( $code )->setType( $type )
->setStocklevel( $this->getValue( $entry, 1 ) )
->setDateBack( $this->getValue( $entry, 3 ) );
unset( $map[$code][$type] );
}
$manager->saveItems( $items );
unset( $items );
$total += $count;
}
while( $count > 0 );
return $total;
}
|
[
"protected",
"function",
"importStocks",
"(",
"\\",
"Aimeos",
"\\",
"MW",
"\\",
"Container",
"\\",
"Content",
"\\",
"Iface",
"$",
"content",
",",
"$",
"maxcnt",
")",
"{",
"$",
"total",
"=",
"0",
";",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"this",
"->",
"getContext",
"(",
")",
",",
"'stock'",
")",
";",
"do",
"{",
"$",
"count",
"=",
"0",
";",
"$",
"codes",
"=",
"$",
"data",
"=",
"$",
"items",
"=",
"$",
"types",
"=",
"[",
"]",
";",
"while",
"(",
"$",
"content",
"->",
"valid",
"(",
")",
"&&",
"$",
"count",
"<",
"$",
"maxcnt",
")",
"{",
"$",
"row",
"=",
"$",
"content",
"->",
"current",
"(",
")",
";",
"$",
"content",
"->",
"next",
"(",
")",
";",
"if",
"(",
"$",
"row",
"[",
"0",
"]",
"==",
"''",
")",
"{",
"continue",
";",
"}",
"$",
"type",
"=",
"$",
"this",
"->",
"getValue",
"(",
"$",
"row",
",",
"2",
",",
"'default'",
")",
";",
"$",
"types",
"[",
"$",
"type",
"]",
"=",
"null",
";",
"$",
"codes",
"[",
"]",
"=",
"$",
"row",
"[",
"0",
"]",
";",
"$",
"row",
"[",
"2",
"]",
"=",
"$",
"type",
";",
"$",
"data",
"[",
"]",
"=",
"$",
"row",
";",
"$",
"count",
"++",
";",
"}",
"if",
"(",
"$",
"count",
"===",
"0",
")",
"{",
"break",
";",
"}",
"$",
"items",
"=",
"[",
"]",
";",
"$",
"map",
"=",
"$",
"this",
"->",
"getStockItems",
"(",
"$",
"codes",
",",
"array_keys",
"(",
"$",
"types",
")",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"entry",
")",
"{",
"$",
"code",
"=",
"$",
"entry",
"[",
"0",
"]",
";",
"$",
"type",
"=",
"$",
"entry",
"[",
"2",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"map",
"[",
"$",
"code",
"]",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"item",
"=",
"$",
"map",
"[",
"$",
"code",
"]",
"[",
"$",
"type",
"]",
";",
"}",
"else",
"{",
"$",
"item",
"=",
"$",
"manager",
"->",
"createItem",
"(",
")",
";",
"}",
"$",
"items",
"[",
"]",
"=",
"$",
"item",
"->",
"setProductCode",
"(",
"$",
"code",
")",
"->",
"setType",
"(",
"$",
"type",
")",
"->",
"setStocklevel",
"(",
"$",
"this",
"->",
"getValue",
"(",
"$",
"entry",
",",
"1",
")",
")",
"->",
"setDateBack",
"(",
"$",
"this",
"->",
"getValue",
"(",
"$",
"entry",
",",
"3",
")",
")",
";",
"unset",
"(",
"$",
"map",
"[",
"$",
"code",
"]",
"[",
"$",
"type",
"]",
")",
";",
"}",
"$",
"manager",
"->",
"saveItems",
"(",
"$",
"items",
")",
";",
"unset",
"(",
"$",
"items",
")",
";",
"$",
"total",
"+=",
"$",
"count",
";",
"}",
"while",
"(",
"$",
"count",
">",
"0",
")",
";",
"return",
"$",
"total",
";",
"}"
] |
Imports the CSV data and creates new stocks or updates existing ones
@param \Aimeos\MW\Container\Content\Iface $content Content object
@return integer Number of imported stocks
|
[
"Imports",
"the",
"CSV",
"data",
"and",
"creates",
"new",
"stocks",
"or",
"updates",
"existing",
"ones"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/jobs/src/Controller/Jobs/Stock/Import/Csv/Standard.php#L310-L371
|
26,970
|
aimeos/ai-controller-jobs
|
controller/common/src/Controller/Common/Product/Import/Csv/Cache/Attribute/Standard.php
|
Standard.set
|
public function set( \Aimeos\MShop\Common\Item\Iface $item )
{
$code = $item->getCode();
if( !isset( $this->attributes[$code] ) || !is_array( $this->attributes[$code] ) ) {
$this->attributes[$code] = [];
}
$this->attributes[$code][$item->getType()] = $item;
}
|
php
|
public function set( \Aimeos\MShop\Common\Item\Iface $item )
{
$code = $item->getCode();
if( !isset( $this->attributes[$code] ) || !is_array( $this->attributes[$code] ) ) {
$this->attributes[$code] = [];
}
$this->attributes[$code][$item->getType()] = $item;
}
|
[
"public",
"function",
"set",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Common",
"\\",
"Item",
"\\",
"Iface",
"$",
"item",
")",
"{",
"$",
"code",
"=",
"$",
"item",
"->",
"getCode",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"$",
"code",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"this",
"->",
"attributes",
"[",
"$",
"code",
"]",
")",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"$",
"code",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"attributes",
"[",
"$",
"code",
"]",
"[",
"$",
"item",
"->",
"getType",
"(",
")",
"]",
"=",
"$",
"item",
";",
"}"
] |
Adds the attribute item to the cache
@param \Aimeos\MShop\Common\Item\Iface $item Attribute object
|
[
"Adds",
"the",
"attribute",
"item",
"to",
"the",
"cache"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/common/src/Controller/Common/Product/Import/Csv/Cache/Attribute/Standard.php#L93-L102
|
26,971
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/plugins/fileeditor/plugin.php
|
CKFinder_Connector_CommandHandler_FileEditor.buildXml
|
function buildXml()
{
if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
}
$this->checkConnector();
$this->checkRequest();
// Saving empty file is equal to deleting a file, that's why FILE_DELETE permissions are required
if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_DELETE)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
}
if (!isset($_POST["fileName"])) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
}
if (!isset($_POST["content"])) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
}
$fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_POST["fileName"]);
$resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
if (!$resourceTypeInfo->checkExtension($fileName)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
}
if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $resourceTypeInfo->checkIsHiddenFile($fileName)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
}
$filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);
if (!file_exists($filePath) || !is_file($filePath)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
}
if (!is_writable(dirname($filePath))) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
}
$fp = @fopen($filePath, 'wb');
if ($fp === false || !flock($fp, LOCK_EX)) {
$result = false;
}
else {
$result = fwrite($fp, $_POST["content"]);
flock($fp, LOCK_UN);
fclose($fp);
}
if ($result === false) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
}
}
|
php
|
function buildXml()
{
if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
}
$this->checkConnector();
$this->checkRequest();
// Saving empty file is equal to deleting a file, that's why FILE_DELETE permissions are required
if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_DELETE)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
}
if (!isset($_POST["fileName"])) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
}
if (!isset($_POST["content"])) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
}
$fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_POST["fileName"]);
$resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
if (!$resourceTypeInfo->checkExtension($fileName)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
}
if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $resourceTypeInfo->checkIsHiddenFile($fileName)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
}
$filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);
if (!file_exists($filePath) || !is_file($filePath)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
}
if (!is_writable(dirname($filePath))) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
}
$fp = @fopen($filePath, 'wb');
if ($fp === false || !flock($fp, LOCK_EX)) {
$result = false;
}
else {
$result = fwrite($fp, $_POST["content"]);
flock($fp, LOCK_UN);
fclose($fp);
}
if ($result === false) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
}
}
|
[
"function",
"buildXml",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"_POST",
"[",
"'CKFinderCommand'",
"]",
")",
"||",
"$",
"_POST",
"[",
"'CKFinderCommand'",
"]",
"!=",
"'true'",
")",
"{",
"$",
"this",
"->",
"_errorHandler",
"->",
"throwError",
"(",
"CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST",
")",
";",
"}",
"$",
"this",
"->",
"checkConnector",
"(",
")",
";",
"$",
"this",
"->",
"checkRequest",
"(",
")",
";",
"// Saving empty file is equal to deleting a file, that's why FILE_DELETE permissions are required",
"if",
"(",
"!",
"$",
"this",
"->",
"_currentFolder",
"->",
"checkAcl",
"(",
"CKFINDER_CONNECTOR_ACL_FILE_DELETE",
")",
")",
"{",
"$",
"this",
"->",
"_errorHandler",
"->",
"throwError",
"(",
"CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"_POST",
"[",
"\"fileName\"",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_errorHandler",
"->",
"throwError",
"(",
"CKFINDER_CONNECTOR_ERROR_INVALID_NAME",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"_POST",
"[",
"\"content\"",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_errorHandler",
"->",
"throwError",
"(",
"CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST",
")",
";",
"}",
"$",
"fileName",
"=",
"CKFinder_Connector_Utils_FileSystem",
"::",
"convertToFilesystemEncoding",
"(",
"$",
"_POST",
"[",
"\"fileName\"",
"]",
")",
";",
"$",
"resourceTypeInfo",
"=",
"$",
"this",
"->",
"_currentFolder",
"->",
"getResourceTypeConfig",
"(",
")",
";",
"if",
"(",
"!",
"$",
"resourceTypeInfo",
"->",
"checkExtension",
"(",
"$",
"fileName",
")",
")",
"{",
"$",
"this",
"->",
"_errorHandler",
"->",
"throwError",
"(",
"CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION",
")",
";",
"}",
"if",
"(",
"!",
"CKFinder_Connector_Utils_FileSystem",
"::",
"checkFileName",
"(",
"$",
"fileName",
")",
"||",
"$",
"resourceTypeInfo",
"->",
"checkIsHiddenFile",
"(",
"$",
"fileName",
")",
")",
"{",
"$",
"this",
"->",
"_errorHandler",
"->",
"throwError",
"(",
"CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST",
")",
";",
"}",
"$",
"filePath",
"=",
"CKFinder_Connector_Utils_FileSystem",
"::",
"combinePaths",
"(",
"$",
"this",
"->",
"_currentFolder",
"->",
"getServerPath",
"(",
")",
",",
"$",
"fileName",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filePath",
")",
"||",
"!",
"is_file",
"(",
"$",
"filePath",
")",
")",
"{",
"$",
"this",
"->",
"_errorHandler",
"->",
"throwError",
"(",
"CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND",
")",
";",
"}",
"if",
"(",
"!",
"is_writable",
"(",
"dirname",
"(",
"$",
"filePath",
")",
")",
")",
"{",
"$",
"this",
"->",
"_errorHandler",
"->",
"throwError",
"(",
"CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED",
")",
";",
"}",
"$",
"fp",
"=",
"@",
"fopen",
"(",
"$",
"filePath",
",",
"'wb'",
")",
";",
"if",
"(",
"$",
"fp",
"===",
"false",
"||",
"!",
"flock",
"(",
"$",
"fp",
",",
"LOCK_EX",
")",
")",
"{",
"$",
"result",
"=",
"false",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"fwrite",
"(",
"$",
"fp",
",",
"$",
"_POST",
"[",
"\"content\"",
"]",
")",
";",
"flock",
"(",
"$",
"fp",
",",
"LOCK_UN",
")",
";",
"fclose",
"(",
"$",
"fp",
")",
";",
"}",
"if",
"(",
"$",
"result",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"_errorHandler",
"->",
"throwError",
"(",
"CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED",
")",
";",
"}",
"}"
] |
handle request and build XML
@access protected
|
[
"handle",
"request",
"and",
"build",
"XML"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/plugins/fileeditor/plugin.php#L28-L82
|
26,972
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/Connector.php
|
CKFinder_Connector_Core_Connector.&
|
public function &getErrorHandler()
{
$_errorHandler = $this->_registry->get("errorHandler");
$oErrorHandler =& CKFinder_Connector_Core_Factory::getInstance($_errorHandler);
return $oErrorHandler;
}
|
php
|
public function &getErrorHandler()
{
$_errorHandler = $this->_registry->get("errorHandler");
$oErrorHandler =& CKFinder_Connector_Core_Factory::getInstance($_errorHandler);
return $oErrorHandler;
}
|
[
"public",
"function",
"&",
"getErrorHandler",
"(",
")",
"{",
"$",
"_errorHandler",
"=",
"$",
"this",
"->",
"_registry",
"->",
"get",
"(",
"\"errorHandler\"",
")",
";",
"$",
"oErrorHandler",
"=",
"&",
"CKFinder_Connector_Core_Factory",
"::",
"getInstance",
"(",
"$",
"_errorHandler",
")",
";",
"return",
"$",
"oErrorHandler",
";",
"}"
] |
Get error handler
@access public
@return CKFinder_Connector_ErrorHandler_Base|CKFinder_Connector_ErrorHandler_FileUpload|CKFinder_Connector_ErrorHandler_Http
|
[
"Get",
"error",
"handler"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/Connector.php#L115-L120
|
26,973
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/plugins/zip/plugin.php
|
CKFinder_Connector_CommandHandler_Unzip.appendErrorNode
|
protected function appendErrorNode($oErrorsNode, $errorCode=0, $name, $type=null, $path=null)
{
$oErrorNode = new CKFinder_Connector_Utils_XmlNode("Error");
$oErrorNode->addAttribute("code", $errorCode);
$oErrorNode->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($name));
if ( $type ){
$oErrorNode->addAttribute("type", $type);
}
if ( $path ){
$oErrorNode->addAttribute("folder", $path);
}
$oErrorsNode->addChild($oErrorNode);
}
|
php
|
protected function appendErrorNode($oErrorsNode, $errorCode=0, $name, $type=null, $path=null)
{
$oErrorNode = new CKFinder_Connector_Utils_XmlNode("Error");
$oErrorNode->addAttribute("code", $errorCode);
$oErrorNode->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($name));
if ( $type ){
$oErrorNode->addAttribute("type", $type);
}
if ( $path ){
$oErrorNode->addAttribute("folder", $path);
}
$oErrorsNode->addChild($oErrorNode);
}
|
[
"protected",
"function",
"appendErrorNode",
"(",
"$",
"oErrorsNode",
",",
"$",
"errorCode",
"=",
"0",
",",
"$",
"name",
",",
"$",
"type",
"=",
"null",
",",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"oErrorNode",
"=",
"new",
"CKFinder_Connector_Utils_XmlNode",
"(",
"\"Error\"",
")",
";",
"$",
"oErrorNode",
"->",
"addAttribute",
"(",
"\"code\"",
",",
"$",
"errorCode",
")",
";",
"$",
"oErrorNode",
"->",
"addAttribute",
"(",
"\"name\"",
",",
"CKFinder_Connector_Utils_FileSystem",
"::",
"convertToConnectorEncoding",
"(",
"$",
"name",
")",
")",
";",
"if",
"(",
"$",
"type",
")",
"{",
"$",
"oErrorNode",
"->",
"addAttribute",
"(",
"\"type\"",
",",
"$",
"type",
")",
";",
"}",
"if",
"(",
"$",
"path",
")",
"{",
"$",
"oErrorNode",
"->",
"addAttribute",
"(",
"\"folder\"",
",",
"$",
"path",
")",
";",
"}",
"$",
"oErrorsNode",
"->",
"addChild",
"(",
"$",
"oErrorNode",
")",
";",
"}"
] |
Add error node to the list
@param obj $oErrorsNode
@param int $errorCode
@param string $name
@param string $type
@param string $path
|
[
"Add",
"error",
"node",
"to",
"the",
"list"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/plugins/zip/plugin.php#L196-L208
|
26,974
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/plugins/zip/plugin.php
|
CKFinder_Connector_CommandHandler_Unzip.appendUnzippedNode
|
protected function appendUnzippedNode($oUnzippedNodes, $name, $action='ok')
{
$oUnzippedNode = new CKFinder_Connector_Utils_XmlNode("File");
$oUnzippedNode->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($name));
$oUnzippedNode->addAttribute("action", $action );
$oUnzippedNodes->addChild($oUnzippedNode);
}
|
php
|
protected function appendUnzippedNode($oUnzippedNodes, $name, $action='ok')
{
$oUnzippedNode = new CKFinder_Connector_Utils_XmlNode("File");
$oUnzippedNode->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($name));
$oUnzippedNode->addAttribute("action", $action );
$oUnzippedNodes->addChild($oUnzippedNode);
}
|
[
"protected",
"function",
"appendUnzippedNode",
"(",
"$",
"oUnzippedNodes",
",",
"$",
"name",
",",
"$",
"action",
"=",
"'ok'",
")",
"{",
"$",
"oUnzippedNode",
"=",
"new",
"CKFinder_Connector_Utils_XmlNode",
"(",
"\"File\"",
")",
";",
"$",
"oUnzippedNode",
"->",
"addAttribute",
"(",
"\"name\"",
",",
"CKFinder_Connector_Utils_FileSystem",
"::",
"convertToConnectorEncoding",
"(",
"$",
"name",
")",
")",
";",
"$",
"oUnzippedNode",
"->",
"addAttribute",
"(",
"\"action\"",
",",
"$",
"action",
")",
";",
"$",
"oUnzippedNodes",
"->",
"addChild",
"(",
"$",
"oUnzippedNode",
")",
";",
"}"
] |
Add unzipped node to the list
@param obj $oUnzippedNodes
@param string $name
@param string $action
|
[
"Add",
"unzipped",
"node",
"to",
"the",
"list"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/plugins/zip/plugin.php#L216-L222
|
26,975
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/plugins/zip/plugin.php
|
CKFinder_Connector_CommandHandler_Unzip.extractTo
|
protected function extractTo($extractPath, $extractClientPath, $filePathInfo, $sFileName, $originalFileName)
{
$sfilePathInfo = pathinfo($extractPath.$sFileName);
$extractClientPathDir = $filePathInfo['dirname'];
if ( $filePathInfo['dirname'] == '.' ){
$extractClientPathDir = '';
}
$folderPath = CKFinder_Connector_Utils_FileSystem::combinePaths($extractClientPath,$extractClientPathDir);
$_aclConfig = $this->_config->getAccessControlConfig();
$aclMask = $_aclConfig->getComputedMask($this->_currentFolder->getResourceTypeName(),$folderPath);
$canCreateFolder = (($aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_CREATE ) == CKFINDER_CONNECTOR_ACL_FOLDER_CREATE );
// create sub-directory of zip archive
if ( empty($sfilePathInfo['extension']) )
{
$fileStat = $this->zip->statName($originalFileName);
$isDir = false;
if ( $fileStat && empty($fileStat['size']) ){
$isDir = true;
}
if( !empty($sfilePathInfo['dirname']) && !empty($sfilePathInfo['basename']) && !file_exists($sfilePathInfo['dirname'].'/'.$sfilePathInfo['basename']) )
{
if ( !$canCreateFolder ){
return;
}
if ( $isDir ) {
CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively( $sfilePathInfo['dirname'].'/'.$sfilePathInfo['basename'] );
return;
} else {
CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively( $sfilePathInfo['dirname']);
}
} else {
return;
}
}
// extract file
if ( !file_exists($sfilePathInfo['dirname']) ){
if ( !$canCreateFolder ){
$this->errorCode = CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED;
$this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName );
return;
}
CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively($sfilePathInfo['dirname']);
}
$isAuthorized = (($aclMask & CKFINDER_CONNECTOR_ACL_FILE_UPLOAD ) == CKFINDER_CONNECTOR_ACL_FILE_UPLOAD );
if ( !$isAuthorized ){
$this->errorCode = CKFINDER_CONNECTOR_ERROR_COPY_FAILED;
$this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName);
return;
}
if ( copy('zip://'.$this->filePath.'#'.$originalFileName, $extractPath.$sFileName) )
{
$this->appendUnzippedNode($this->unzippedNodes,$originalFileName);
// chmod extracted file
if ( is_file($extractPath.$sFileName) && ( $perms = $this->_config->getChmodFiles()) )
{
$oldumask = umask(0);
chmod( $extractPath.$sFileName, $perms );
umask( $oldumask );
}
}
// file extraction failed, add to skipped
else
{
$this->errorCode = CKFINDER_CONNECTOR_ERROR_COPY_FAILED;
$this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName);
}
}
|
php
|
protected function extractTo($extractPath, $extractClientPath, $filePathInfo, $sFileName, $originalFileName)
{
$sfilePathInfo = pathinfo($extractPath.$sFileName);
$extractClientPathDir = $filePathInfo['dirname'];
if ( $filePathInfo['dirname'] == '.' ){
$extractClientPathDir = '';
}
$folderPath = CKFinder_Connector_Utils_FileSystem::combinePaths($extractClientPath,$extractClientPathDir);
$_aclConfig = $this->_config->getAccessControlConfig();
$aclMask = $_aclConfig->getComputedMask($this->_currentFolder->getResourceTypeName(),$folderPath);
$canCreateFolder = (($aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_CREATE ) == CKFINDER_CONNECTOR_ACL_FOLDER_CREATE );
// create sub-directory of zip archive
if ( empty($sfilePathInfo['extension']) )
{
$fileStat = $this->zip->statName($originalFileName);
$isDir = false;
if ( $fileStat && empty($fileStat['size']) ){
$isDir = true;
}
if( !empty($sfilePathInfo['dirname']) && !empty($sfilePathInfo['basename']) && !file_exists($sfilePathInfo['dirname'].'/'.$sfilePathInfo['basename']) )
{
if ( !$canCreateFolder ){
return;
}
if ( $isDir ) {
CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively( $sfilePathInfo['dirname'].'/'.$sfilePathInfo['basename'] );
return;
} else {
CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively( $sfilePathInfo['dirname']);
}
} else {
return;
}
}
// extract file
if ( !file_exists($sfilePathInfo['dirname']) ){
if ( !$canCreateFolder ){
$this->errorCode = CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED;
$this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName );
return;
}
CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively($sfilePathInfo['dirname']);
}
$isAuthorized = (($aclMask & CKFINDER_CONNECTOR_ACL_FILE_UPLOAD ) == CKFINDER_CONNECTOR_ACL_FILE_UPLOAD );
if ( !$isAuthorized ){
$this->errorCode = CKFINDER_CONNECTOR_ERROR_COPY_FAILED;
$this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName);
return;
}
if ( copy('zip://'.$this->filePath.'#'.$originalFileName, $extractPath.$sFileName) )
{
$this->appendUnzippedNode($this->unzippedNodes,$originalFileName);
// chmod extracted file
if ( is_file($extractPath.$sFileName) && ( $perms = $this->_config->getChmodFiles()) )
{
$oldumask = umask(0);
chmod( $extractPath.$sFileName, $perms );
umask( $oldumask );
}
}
// file extraction failed, add to skipped
else
{
$this->errorCode = CKFINDER_CONNECTOR_ERROR_COPY_FAILED;
$this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName);
}
}
|
[
"protected",
"function",
"extractTo",
"(",
"$",
"extractPath",
",",
"$",
"extractClientPath",
",",
"$",
"filePathInfo",
",",
"$",
"sFileName",
",",
"$",
"originalFileName",
")",
"{",
"$",
"sfilePathInfo",
"=",
"pathinfo",
"(",
"$",
"extractPath",
".",
"$",
"sFileName",
")",
";",
"$",
"extractClientPathDir",
"=",
"$",
"filePathInfo",
"[",
"'dirname'",
"]",
";",
"if",
"(",
"$",
"filePathInfo",
"[",
"'dirname'",
"]",
"==",
"'.'",
")",
"{",
"$",
"extractClientPathDir",
"=",
"''",
";",
"}",
"$",
"folderPath",
"=",
"CKFinder_Connector_Utils_FileSystem",
"::",
"combinePaths",
"(",
"$",
"extractClientPath",
",",
"$",
"extractClientPathDir",
")",
";",
"$",
"_aclConfig",
"=",
"$",
"this",
"->",
"_config",
"->",
"getAccessControlConfig",
"(",
")",
";",
"$",
"aclMask",
"=",
"$",
"_aclConfig",
"->",
"getComputedMask",
"(",
"$",
"this",
"->",
"_currentFolder",
"->",
"getResourceTypeName",
"(",
")",
",",
"$",
"folderPath",
")",
";",
"$",
"canCreateFolder",
"=",
"(",
"(",
"$",
"aclMask",
"&",
"CKFINDER_CONNECTOR_ACL_FOLDER_CREATE",
")",
"==",
"CKFINDER_CONNECTOR_ACL_FOLDER_CREATE",
")",
";",
"// create sub-directory of zip archive",
"if",
"(",
"empty",
"(",
"$",
"sfilePathInfo",
"[",
"'extension'",
"]",
")",
")",
"{",
"$",
"fileStat",
"=",
"$",
"this",
"->",
"zip",
"->",
"statName",
"(",
"$",
"originalFileName",
")",
";",
"$",
"isDir",
"=",
"false",
";",
"if",
"(",
"$",
"fileStat",
"&&",
"empty",
"(",
"$",
"fileStat",
"[",
"'size'",
"]",
")",
")",
"{",
"$",
"isDir",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"sfilePathInfo",
"[",
"'dirname'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"sfilePathInfo",
"[",
"'basename'",
"]",
")",
"&&",
"!",
"file_exists",
"(",
"$",
"sfilePathInfo",
"[",
"'dirname'",
"]",
".",
"'/'",
".",
"$",
"sfilePathInfo",
"[",
"'basename'",
"]",
")",
")",
"{",
"if",
"(",
"!",
"$",
"canCreateFolder",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"isDir",
")",
"{",
"CKFinder_Connector_Utils_FileSystem",
"::",
"createDirectoryRecursively",
"(",
"$",
"sfilePathInfo",
"[",
"'dirname'",
"]",
".",
"'/'",
".",
"$",
"sfilePathInfo",
"[",
"'basename'",
"]",
")",
";",
"return",
";",
"}",
"else",
"{",
"CKFinder_Connector_Utils_FileSystem",
"::",
"createDirectoryRecursively",
"(",
"$",
"sfilePathInfo",
"[",
"'dirname'",
"]",
")",
";",
"}",
"}",
"else",
"{",
"return",
";",
"}",
"}",
"// extract file",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"sfilePathInfo",
"[",
"'dirname'",
"]",
")",
")",
"{",
"if",
"(",
"!",
"$",
"canCreateFolder",
")",
"{",
"$",
"this",
"->",
"errorCode",
"=",
"CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED",
";",
"$",
"this",
"->",
"appendErrorNode",
"(",
"$",
"this",
"->",
"skippedFilesNode",
",",
"$",
"this",
"->",
"errorCode",
",",
"$",
"originalFileName",
")",
";",
"return",
";",
"}",
"CKFinder_Connector_Utils_FileSystem",
"::",
"createDirectoryRecursively",
"(",
"$",
"sfilePathInfo",
"[",
"'dirname'",
"]",
")",
";",
"}",
"$",
"isAuthorized",
"=",
"(",
"(",
"$",
"aclMask",
"&",
"CKFINDER_CONNECTOR_ACL_FILE_UPLOAD",
")",
"==",
"CKFINDER_CONNECTOR_ACL_FILE_UPLOAD",
")",
";",
"if",
"(",
"!",
"$",
"isAuthorized",
")",
"{",
"$",
"this",
"->",
"errorCode",
"=",
"CKFINDER_CONNECTOR_ERROR_COPY_FAILED",
";",
"$",
"this",
"->",
"appendErrorNode",
"(",
"$",
"this",
"->",
"skippedFilesNode",
",",
"$",
"this",
"->",
"errorCode",
",",
"$",
"originalFileName",
")",
";",
"return",
";",
"}",
"if",
"(",
"copy",
"(",
"'zip://'",
".",
"$",
"this",
"->",
"filePath",
".",
"'#'",
".",
"$",
"originalFileName",
",",
"$",
"extractPath",
".",
"$",
"sFileName",
")",
")",
"{",
"$",
"this",
"->",
"appendUnzippedNode",
"(",
"$",
"this",
"->",
"unzippedNodes",
",",
"$",
"originalFileName",
")",
";",
"// chmod extracted file",
"if",
"(",
"is_file",
"(",
"$",
"extractPath",
".",
"$",
"sFileName",
")",
"&&",
"(",
"$",
"perms",
"=",
"$",
"this",
"->",
"_config",
"->",
"getChmodFiles",
"(",
")",
")",
")",
"{",
"$",
"oldumask",
"=",
"umask",
"(",
"0",
")",
";",
"chmod",
"(",
"$",
"extractPath",
".",
"$",
"sFileName",
",",
"$",
"perms",
")",
";",
"umask",
"(",
"$",
"oldumask",
")",
";",
"}",
"}",
"// file extraction failed, add to skipped",
"else",
"{",
"$",
"this",
"->",
"errorCode",
"=",
"CKFINDER_CONNECTOR_ERROR_COPY_FAILED",
";",
"$",
"this",
"->",
"appendErrorNode",
"(",
"$",
"this",
"->",
"skippedFilesNode",
",",
"$",
"this",
"->",
"errorCode",
",",
"$",
"originalFileName",
")",
";",
"}",
"}"
] |
Extract one file from zip archive
@param string $extractPath
@param string $extractClientPath
@param array $filePathInfo
@param string $sFileName
@param string $originalFileName
|
[
"Extract",
"one",
"file",
"from",
"zip",
"archive"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/plugins/zip/plugin.php#L233-L301
|
26,976
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/plugins/zip/plugin.php
|
CKFinder_Connector_CommandHandler_CreateZip.getConfig
|
protected function getConfig(){
$config = array();
$config['zipMaxSize'] = 'default';
if (isset($GLOBALS['config']['ZipMaxSize']) && (string)$GLOBALS['config']['ZipMaxSize']!='default' ){
$config['zipMaxSize'] = CKFinder_Connector_Utils_Misc::returnBytes((string)$GLOBALS['config']['ZipMaxSize']);
}
return $config;
}
|
php
|
protected function getConfig(){
$config = array();
$config['zipMaxSize'] = 'default';
if (isset($GLOBALS['config']['ZipMaxSize']) && (string)$GLOBALS['config']['ZipMaxSize']!='default' ){
$config['zipMaxSize'] = CKFinder_Connector_Utils_Misc::returnBytes((string)$GLOBALS['config']['ZipMaxSize']);
}
return $config;
}
|
[
"protected",
"function",
"getConfig",
"(",
")",
"{",
"$",
"config",
"=",
"array",
"(",
")",
";",
"$",
"config",
"[",
"'zipMaxSize'",
"]",
"=",
"'default'",
";",
"if",
"(",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'config'",
"]",
"[",
"'ZipMaxSize'",
"]",
")",
"&&",
"(",
"string",
")",
"$",
"GLOBALS",
"[",
"'config'",
"]",
"[",
"'ZipMaxSize'",
"]",
"!=",
"'default'",
")",
"{",
"$",
"config",
"[",
"'zipMaxSize'",
"]",
"=",
"CKFinder_Connector_Utils_Misc",
"::",
"returnBytes",
"(",
"(",
"string",
")",
"$",
"GLOBALS",
"[",
"'config'",
"]",
"[",
"'ZipMaxSize'",
"]",
")",
";",
"}",
"return",
"$",
"config",
";",
"}"
] |
Get private zip plugin config
@access protected
@return array
|
[
"Get",
"private",
"zip",
"plugin",
"config"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/plugins/zip/plugin.php#L519-L528
|
26,977
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/plugins/zip/plugin.php
|
CKFinder_Connector_CommandHandler_CreateZip.checkOneFile
|
protected function checkOneFile($file)
{
$resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
$_aclConfig = $this->_config->getAccessControlConfig();
$directory = str_replace('\\','/', $resourceTypeInfo->getDirectory());
$fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($file->getFilename());
if ($this->_config->forceAscii()) {
$fileName = CKFinder_Connector_Utils_FileSystem::convertToAscii($fileName);
}
$pathName = str_replace('\\','/', pathinfo($file->getPathname(), PATHINFO_DIRNAME) );
$pathName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($pathName);
// acl
$aclMask = $_aclConfig->getComputedMask($this->_currentFolder->getResourceTypeName(), str_ireplace($directory,'',$pathName));
$isAuthorized = (($aclMask & CKFINDER_CONNECTOR_ACL_FILE_VIEW) == CKFINDER_CONNECTOR_ACL_FILE_VIEW);
if ( !$isAuthorized ){
return false;
}
// if it is a folder fileName represents the dir
if ( $file->isDir() && ( !CKFinder_Connector_Utils_FileSystem::checkFolderPath($fileName) || $resourceTypeInfo->checkIsHiddenPath($fileName) ) ){
return false;
}
// folder name
if ( !CKFinder_Connector_Utils_FileSystem::checkFolderPath($pathName) ){
return false;
}
// is hidden
if ( $resourceTypeInfo->checkIsHiddenPath($pathName) || $resourceTypeInfo->checkIsHiddenFile($fileName) ){
return false;
}
// extension
if ( !$resourceTypeInfo->checkExtension($fileName) || !CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) ){
return false;
}
return true;
}
|
php
|
protected function checkOneFile($file)
{
$resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
$_aclConfig = $this->_config->getAccessControlConfig();
$directory = str_replace('\\','/', $resourceTypeInfo->getDirectory());
$fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($file->getFilename());
if ($this->_config->forceAscii()) {
$fileName = CKFinder_Connector_Utils_FileSystem::convertToAscii($fileName);
}
$pathName = str_replace('\\','/', pathinfo($file->getPathname(), PATHINFO_DIRNAME) );
$pathName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($pathName);
// acl
$aclMask = $_aclConfig->getComputedMask($this->_currentFolder->getResourceTypeName(), str_ireplace($directory,'',$pathName));
$isAuthorized = (($aclMask & CKFINDER_CONNECTOR_ACL_FILE_VIEW) == CKFINDER_CONNECTOR_ACL_FILE_VIEW);
if ( !$isAuthorized ){
return false;
}
// if it is a folder fileName represents the dir
if ( $file->isDir() && ( !CKFinder_Connector_Utils_FileSystem::checkFolderPath($fileName) || $resourceTypeInfo->checkIsHiddenPath($fileName) ) ){
return false;
}
// folder name
if ( !CKFinder_Connector_Utils_FileSystem::checkFolderPath($pathName) ){
return false;
}
// is hidden
if ( $resourceTypeInfo->checkIsHiddenPath($pathName) || $resourceTypeInfo->checkIsHiddenFile($fileName) ){
return false;
}
// extension
if ( !$resourceTypeInfo->checkExtension($fileName) || !CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) ){
return false;
}
return true;
}
|
[
"protected",
"function",
"checkOneFile",
"(",
"$",
"file",
")",
"{",
"$",
"resourceTypeInfo",
"=",
"$",
"this",
"->",
"_currentFolder",
"->",
"getResourceTypeConfig",
"(",
")",
";",
"$",
"_aclConfig",
"=",
"$",
"this",
"->",
"_config",
"->",
"getAccessControlConfig",
"(",
")",
";",
"$",
"directory",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"resourceTypeInfo",
"->",
"getDirectory",
"(",
")",
")",
";",
"$",
"fileName",
"=",
"CKFinder_Connector_Utils_FileSystem",
"::",
"convertToFilesystemEncoding",
"(",
"$",
"file",
"->",
"getFilename",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_config",
"->",
"forceAscii",
"(",
")",
")",
"{",
"$",
"fileName",
"=",
"CKFinder_Connector_Utils_FileSystem",
"::",
"convertToAscii",
"(",
"$",
"fileName",
")",
";",
"}",
"$",
"pathName",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"pathinfo",
"(",
"$",
"file",
"->",
"getPathname",
"(",
")",
",",
"PATHINFO_DIRNAME",
")",
")",
";",
"$",
"pathName",
"=",
"CKFinder_Connector_Utils_FileSystem",
"::",
"convertToFilesystemEncoding",
"(",
"$",
"pathName",
")",
";",
"// acl",
"$",
"aclMask",
"=",
"$",
"_aclConfig",
"->",
"getComputedMask",
"(",
"$",
"this",
"->",
"_currentFolder",
"->",
"getResourceTypeName",
"(",
")",
",",
"str_ireplace",
"(",
"$",
"directory",
",",
"''",
",",
"$",
"pathName",
")",
")",
";",
"$",
"isAuthorized",
"=",
"(",
"(",
"$",
"aclMask",
"&",
"CKFINDER_CONNECTOR_ACL_FILE_VIEW",
")",
"==",
"CKFINDER_CONNECTOR_ACL_FILE_VIEW",
")",
";",
"if",
"(",
"!",
"$",
"isAuthorized",
")",
"{",
"return",
"false",
";",
"}",
"// if it is a folder fileName represents the dir",
"if",
"(",
"$",
"file",
"->",
"isDir",
"(",
")",
"&&",
"(",
"!",
"CKFinder_Connector_Utils_FileSystem",
"::",
"checkFolderPath",
"(",
"$",
"fileName",
")",
"||",
"$",
"resourceTypeInfo",
"->",
"checkIsHiddenPath",
"(",
"$",
"fileName",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"// folder name",
"if",
"(",
"!",
"CKFinder_Connector_Utils_FileSystem",
"::",
"checkFolderPath",
"(",
"$",
"pathName",
")",
")",
"{",
"return",
"false",
";",
"}",
"// is hidden",
"if",
"(",
"$",
"resourceTypeInfo",
"->",
"checkIsHiddenPath",
"(",
"$",
"pathName",
")",
"||",
"$",
"resourceTypeInfo",
"->",
"checkIsHiddenFile",
"(",
"$",
"fileName",
")",
")",
"{",
"return",
"false",
";",
"}",
"// extension",
"if",
"(",
"!",
"$",
"resourceTypeInfo",
"->",
"checkExtension",
"(",
"$",
"fileName",
")",
"||",
"!",
"CKFinder_Connector_Utils_FileSystem",
"::",
"checkFileName",
"(",
"$",
"fileName",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Checks given file for security
@param SplFileInfo $file
@access protected
@return bool
|
[
"Checks",
"given",
"file",
"for",
"security"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/plugins/zip/plugin.php#L537-L577
|
26,978
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/plugins/zip/plugin.php
|
CKFinder_Connector_CommandHandler_CreateZip.getFilesRecursively
|
protected function getFilesRecursively( $directory, $zipMaxSize )
{
$allFiles = array();
$_zipFilesSize = 0;
$serverPath = str_replace('\\','/',$directory);
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory), RecursiveIteratorIterator::CHILD_FIRST) as $file ) {
if ( !$this->checkOneFile($file) ){
continue;
}
if ( !empty($zipMaxSize) ){
clearstatcache();
$_zipFilesSize += $file->getSize();
if ( $_zipFilesSize > $zipMaxSize ) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CREATED_FILE_TOO_BIG);
}
}
$pathName = str_replace('\\','/',$file->getPathname());
if ( $file->isDir() ){
// skip dot folders on unix systems ( do not try to use isDot() as $file is not a DirectoryIterator obj )
if ( in_array($file->getFilename(),array('..','.')) ){
continue;
}
if ($pathName != rtrim($serverPath,'/')){
$allFiles[ ltrim(str_ireplace(rtrim($serverPath,'/'),'',$pathName),'/') ] = '';
}
} else {
$allFiles[$pathName] = str_ireplace($serverPath,'',$pathName);
}
}
return $allFiles;
}
|
php
|
protected function getFilesRecursively( $directory, $zipMaxSize )
{
$allFiles = array();
$_zipFilesSize = 0;
$serverPath = str_replace('\\','/',$directory);
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory), RecursiveIteratorIterator::CHILD_FIRST) as $file ) {
if ( !$this->checkOneFile($file) ){
continue;
}
if ( !empty($zipMaxSize) ){
clearstatcache();
$_zipFilesSize += $file->getSize();
if ( $_zipFilesSize > $zipMaxSize ) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CREATED_FILE_TOO_BIG);
}
}
$pathName = str_replace('\\','/',$file->getPathname());
if ( $file->isDir() ){
// skip dot folders on unix systems ( do not try to use isDot() as $file is not a DirectoryIterator obj )
if ( in_array($file->getFilename(),array('..','.')) ){
continue;
}
if ($pathName != rtrim($serverPath,'/')){
$allFiles[ ltrim(str_ireplace(rtrim($serverPath,'/'),'',$pathName),'/') ] = '';
}
} else {
$allFiles[$pathName] = str_ireplace($serverPath,'',$pathName);
}
}
return $allFiles;
}
|
[
"protected",
"function",
"getFilesRecursively",
"(",
"$",
"directory",
",",
"$",
"zipMaxSize",
")",
"{",
"$",
"allFiles",
"=",
"array",
"(",
")",
";",
"$",
"_zipFilesSize",
"=",
"0",
";",
"$",
"serverPath",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"directory",
")",
";",
"foreach",
"(",
"new",
"RecursiveIteratorIterator",
"(",
"new",
"RecursiveDirectoryIterator",
"(",
"$",
"directory",
")",
",",
"RecursiveIteratorIterator",
"::",
"CHILD_FIRST",
")",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"checkOneFile",
"(",
"$",
"file",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"zipMaxSize",
")",
")",
"{",
"clearstatcache",
"(",
")",
";",
"$",
"_zipFilesSize",
"+=",
"$",
"file",
"->",
"getSize",
"(",
")",
";",
"if",
"(",
"$",
"_zipFilesSize",
">",
"$",
"zipMaxSize",
")",
"{",
"$",
"this",
"->",
"_errorHandler",
"->",
"throwError",
"(",
"CKFINDER_CONNECTOR_ERROR_CREATED_FILE_TOO_BIG",
")",
";",
"}",
"}",
"$",
"pathName",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"file",
"->",
"getPathname",
"(",
")",
")",
";",
"if",
"(",
"$",
"file",
"->",
"isDir",
"(",
")",
")",
"{",
"// skip dot folders on unix systems ( do not try to use isDot() as $file is not a DirectoryIterator obj )",
"if",
"(",
"in_array",
"(",
"$",
"file",
"->",
"getFilename",
"(",
")",
",",
"array",
"(",
"'..'",
",",
"'.'",
")",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"pathName",
"!=",
"rtrim",
"(",
"$",
"serverPath",
",",
"'/'",
")",
")",
"{",
"$",
"allFiles",
"[",
"ltrim",
"(",
"str_ireplace",
"(",
"rtrim",
"(",
"$",
"serverPath",
",",
"'/'",
")",
",",
"''",
",",
"$",
"pathName",
")",
",",
"'/'",
")",
"]",
"=",
"''",
";",
"}",
"}",
"else",
"{",
"$",
"allFiles",
"[",
"$",
"pathName",
"]",
"=",
"str_ireplace",
"(",
"$",
"serverPath",
",",
"''",
",",
"$",
"pathName",
")",
";",
"}",
"}",
"return",
"$",
"allFiles",
";",
"}"
] |
Get list of all files in given directory, including sub-directories
@param string $directory
@param int $zipMaxSize Maximum zip file size
@return array $allFiles
|
[
"Get",
"list",
"of",
"all",
"files",
"in",
"given",
"directory",
"including",
"sub",
"-",
"directories"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/plugins/zip/plugin.php#L586-L618
|
26,979
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/plugins/zip/plugin.php
|
CKFinder_Connector_CommandHandler_DownloadZip.sendZipFile
|
protected function sendZipFile()
{
if (!function_exists('ob_list_handlers') || ob_list_handlers()) {
@ob_end_clean();
}
header("Content-Encoding: none");
$this->checkConnector();
$this->checkRequest();
// empty wystarczy
if ( empty($_GET['FileName']) ){
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
}
$resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
$hash = $resourceTypeInfo->getHash();
if ( $hash !== $_GET['hash'] || $hash !== substr($_GET['FileName'],16,16) ){
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
}
if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_VIEW)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
}
$fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding(trim($_GET['FileName']));
if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
}
if ( strtolower(pathinfo($fileName, PATHINFO_EXTENSION)) !== 'zip'){
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
}
$dest_dir = CKFinder_Connector_Utils_FileSystem::getTmpDir();
$filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($dest_dir,$fileName);
if ( !file_exists($filePath) || !is_file($filePath)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
}
if (!is_readable($filePath)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
}
$zipFileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding(trim($_GET['ZipName']));
if (!CKFinder_Connector_Utils_FileSystem::checkFileName($zipFileName)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
}
$fileFilename = pathinfo($zipFileName,PATHINFO_BASENAME );
header("Content-Encoding: none");
header("Cache-Control: cache, must-revalidate");
header("Pragma: public");
header("Expires: 0");
$user_agent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
$encodedName = str_replace("\"", "\\\"", $fileFilename);
if (strpos($user_agent, "MSIE") !== false) {
$encodedName = str_replace(array("+", "%2E"), array(" ", "."), urlencode($encodedName));
}
header("Content-type: application/octet-stream; name=\"" . $fileFilename . "\"");
header("Content-Disposition: attachment; filename=\"" . $encodedName. "\"");
header("Content-Length: " . filesize($filePath));
CKFinder_Connector_Utils_FileSystem::sendFile($filePath);
exit;
}
|
php
|
protected function sendZipFile()
{
if (!function_exists('ob_list_handlers') || ob_list_handlers()) {
@ob_end_clean();
}
header("Content-Encoding: none");
$this->checkConnector();
$this->checkRequest();
// empty wystarczy
if ( empty($_GET['FileName']) ){
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
}
$resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
$hash = $resourceTypeInfo->getHash();
if ( $hash !== $_GET['hash'] || $hash !== substr($_GET['FileName'],16,16) ){
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
}
if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_VIEW)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
}
$fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding(trim($_GET['FileName']));
if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
}
if ( strtolower(pathinfo($fileName, PATHINFO_EXTENSION)) !== 'zip'){
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
}
$dest_dir = CKFinder_Connector_Utils_FileSystem::getTmpDir();
$filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($dest_dir,$fileName);
if ( !file_exists($filePath) || !is_file($filePath)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
}
if (!is_readable($filePath)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
}
$zipFileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding(trim($_GET['ZipName']));
if (!CKFinder_Connector_Utils_FileSystem::checkFileName($zipFileName)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
}
$fileFilename = pathinfo($zipFileName,PATHINFO_BASENAME );
header("Content-Encoding: none");
header("Cache-Control: cache, must-revalidate");
header("Pragma: public");
header("Expires: 0");
$user_agent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
$encodedName = str_replace("\"", "\\\"", $fileFilename);
if (strpos($user_agent, "MSIE") !== false) {
$encodedName = str_replace(array("+", "%2E"), array(" ", "."), urlencode($encodedName));
}
header("Content-type: application/octet-stream; name=\"" . $fileFilename . "\"");
header("Content-Disposition: attachment; filename=\"" . $encodedName. "\"");
header("Content-Length: " . filesize($filePath));
CKFinder_Connector_Utils_FileSystem::sendFile($filePath);
exit;
}
|
[
"protected",
"function",
"sendZipFile",
"(",
")",
"{",
"if",
"(",
"!",
"function_exists",
"(",
"'ob_list_handlers'",
")",
"||",
"ob_list_handlers",
"(",
")",
")",
"{",
"@",
"ob_end_clean",
"(",
")",
";",
"}",
"header",
"(",
"\"Content-Encoding: none\"",
")",
";",
"$",
"this",
"->",
"checkConnector",
"(",
")",
";",
"$",
"this",
"->",
"checkRequest",
"(",
")",
";",
"// empty wystarczy",
"if",
"(",
"empty",
"(",
"$",
"_GET",
"[",
"'FileName'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_errorHandler",
"->",
"throwError",
"(",
"CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND",
")",
";",
"}",
"$",
"resourceTypeInfo",
"=",
"$",
"this",
"->",
"_currentFolder",
"->",
"getResourceTypeConfig",
"(",
")",
";",
"$",
"hash",
"=",
"$",
"resourceTypeInfo",
"->",
"getHash",
"(",
")",
";",
"if",
"(",
"$",
"hash",
"!==",
"$",
"_GET",
"[",
"'hash'",
"]",
"||",
"$",
"hash",
"!==",
"substr",
"(",
"$",
"_GET",
"[",
"'FileName'",
"]",
",",
"16",
",",
"16",
")",
")",
"{",
"$",
"this",
"->",
"_errorHandler",
"->",
"throwError",
"(",
"CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"_currentFolder",
"->",
"checkAcl",
"(",
"CKFINDER_CONNECTOR_ACL_FILE_VIEW",
")",
")",
"{",
"$",
"this",
"->",
"_errorHandler",
"->",
"throwError",
"(",
"CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED",
")",
";",
"}",
"$",
"fileName",
"=",
"CKFinder_Connector_Utils_FileSystem",
"::",
"convertToFilesystemEncoding",
"(",
"trim",
"(",
"$",
"_GET",
"[",
"'FileName'",
"]",
")",
")",
";",
"if",
"(",
"!",
"CKFinder_Connector_Utils_FileSystem",
"::",
"checkFileName",
"(",
"$",
"fileName",
")",
")",
"{",
"$",
"this",
"->",
"_errorHandler",
"->",
"throwError",
"(",
"CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST",
")",
";",
"}",
"if",
"(",
"strtolower",
"(",
"pathinfo",
"(",
"$",
"fileName",
",",
"PATHINFO_EXTENSION",
")",
")",
"!==",
"'zip'",
")",
"{",
"$",
"this",
"->",
"_errorHandler",
"->",
"throwError",
"(",
"CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION",
")",
";",
"}",
"$",
"dest_dir",
"=",
"CKFinder_Connector_Utils_FileSystem",
"::",
"getTmpDir",
"(",
")",
";",
"$",
"filePath",
"=",
"CKFinder_Connector_Utils_FileSystem",
"::",
"combinePaths",
"(",
"$",
"dest_dir",
",",
"$",
"fileName",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filePath",
")",
"||",
"!",
"is_file",
"(",
"$",
"filePath",
")",
")",
"{",
"$",
"this",
"->",
"_errorHandler",
"->",
"throwError",
"(",
"CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND",
")",
";",
"}",
"if",
"(",
"!",
"is_readable",
"(",
"$",
"filePath",
")",
")",
"{",
"$",
"this",
"->",
"_errorHandler",
"->",
"throwError",
"(",
"CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED",
")",
";",
"}",
"$",
"zipFileName",
"=",
"CKFinder_Connector_Utils_FileSystem",
"::",
"convertToFilesystemEncoding",
"(",
"trim",
"(",
"$",
"_GET",
"[",
"'ZipName'",
"]",
")",
")",
";",
"if",
"(",
"!",
"CKFinder_Connector_Utils_FileSystem",
"::",
"checkFileName",
"(",
"$",
"zipFileName",
")",
")",
"{",
"$",
"this",
"->",
"_errorHandler",
"->",
"throwError",
"(",
"CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST",
")",
";",
"}",
"$",
"fileFilename",
"=",
"pathinfo",
"(",
"$",
"zipFileName",
",",
"PATHINFO_BASENAME",
")",
";",
"header",
"(",
"\"Content-Encoding: none\"",
")",
";",
"header",
"(",
"\"Cache-Control: cache, must-revalidate\"",
")",
";",
"header",
"(",
"\"Pragma: public\"",
")",
";",
"header",
"(",
"\"Expires: 0\"",
")",
";",
"$",
"user_agent",
"=",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'HTTP_USER_AGENT'",
"]",
")",
"?",
"$",
"_SERVER",
"[",
"'HTTP_USER_AGENT'",
"]",
":",
"\"\"",
";",
"$",
"encodedName",
"=",
"str_replace",
"(",
"\"\\\"\"",
",",
"\"\\\\\\\"\"",
",",
"$",
"fileFilename",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"user_agent",
",",
"\"MSIE\"",
")",
"!==",
"false",
")",
"{",
"$",
"encodedName",
"=",
"str_replace",
"(",
"array",
"(",
"\"+\"",
",",
"\"%2E\"",
")",
",",
"array",
"(",
"\" \"",
",",
"\".\"",
")",
",",
"urlencode",
"(",
"$",
"encodedName",
")",
")",
";",
"}",
"header",
"(",
"\"Content-type: application/octet-stream; name=\\\"\"",
".",
"$",
"fileFilename",
".",
"\"\\\"\"",
")",
";",
"header",
"(",
"\"Content-Disposition: attachment; filename=\\\"\"",
".",
"$",
"encodedName",
".",
"\"\\\"\"",
")",
";",
"header",
"(",
"\"Content-Length: \"",
".",
"filesize",
"(",
"$",
"filePath",
")",
")",
";",
"CKFinder_Connector_Utils_FileSystem",
"::",
"sendFile",
"(",
"$",
"filePath",
")",
";",
"exit",
";",
"}"
] |
Sends generated zip file to the user
|
[
"Sends",
"generated",
"zip",
"file",
"to",
"the",
"user"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/plugins/zip/plugin.php#L857-L921
|
26,980
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Utils/XmlNode.php
|
Ckfinder_Connector_Utils_XmlNode.asUTF8
|
public function asUTF8($string)
{
if (CKFinder_Connector_Utils_Misc::isValidUTF8($string)) {
return $string;
}
$ret = "";
for ($i = 0; $i < strlen($string); $i++) {
$ret .= CKFinder_Connector_Utils_Misc::isValidUTF8($string[$i]) ? $string[$i] : "?";
}
return $ret;
}
|
php
|
public function asUTF8($string)
{
if (CKFinder_Connector_Utils_Misc::isValidUTF8($string)) {
return $string;
}
$ret = "";
for ($i = 0; $i < strlen($string); $i++) {
$ret .= CKFinder_Connector_Utils_Misc::isValidUTF8($string[$i]) ? $string[$i] : "?";
}
return $ret;
}
|
[
"public",
"function",
"asUTF8",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"CKFinder_Connector_Utils_Misc",
"::",
"isValidUTF8",
"(",
"$",
"string",
")",
")",
"{",
"return",
"$",
"string",
";",
"}",
"$",
"ret",
"=",
"\"\"",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"strlen",
"(",
"$",
"string",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"ret",
".=",
"CKFinder_Connector_Utils_Misc",
"::",
"isValidUTF8",
"(",
"$",
"string",
"[",
"$",
"i",
"]",
")",
"?",
"$",
"string",
"[",
"$",
"i",
"]",
":",
"\"?\"",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Checks whether the string is valid UTF8
@param string $string
|
[
"Checks",
"whether",
"the",
"string",
"is",
"valid",
"UTF8"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Utils/XmlNode.php#L146-L158
|
26,981
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Utils/XmlNode.php
|
Ckfinder_Connector_Utils_XmlNode.asXML
|
public function asXML()
{
$ret = "<" . $this->_name;
//print Attributes
if (sizeof($this->_attributes)>0) {
foreach ($this->_attributes as $_name => $_value) {
$ret .= " " . $_name . '="' . $this->asUTF8(htmlspecialchars($_value)) . '"';
}
}
//if there is nothing more todo, close empty tag and exit
if (is_null($this->_value) && !sizeof($this->_childNodes)) {
$ret .= " />";
return $ret;
}
//close opening tag
$ret .= ">";
//print value
if (!is_null($this->_value)) {
$ret .= $this->asUTF8(htmlspecialchars($this->_value));
}
//print child nodes
if (sizeof($this->_childNodes)>0) {
foreach ($this->_childNodes as $_node) {
$ret .= $_node->asXml();
}
}
$ret .= "</" . $this->_name . ">";
return $ret;
}
|
php
|
public function asXML()
{
$ret = "<" . $this->_name;
//print Attributes
if (sizeof($this->_attributes)>0) {
foreach ($this->_attributes as $_name => $_value) {
$ret .= " " . $_name . '="' . $this->asUTF8(htmlspecialchars($_value)) . '"';
}
}
//if there is nothing more todo, close empty tag and exit
if (is_null($this->_value) && !sizeof($this->_childNodes)) {
$ret .= " />";
return $ret;
}
//close opening tag
$ret .= ">";
//print value
if (!is_null($this->_value)) {
$ret .= $this->asUTF8(htmlspecialchars($this->_value));
}
//print child nodes
if (sizeof($this->_childNodes)>0) {
foreach ($this->_childNodes as $_node) {
$ret .= $_node->asXml();
}
}
$ret .= "</" . $this->_name . ">";
return $ret;
}
|
[
"public",
"function",
"asXML",
"(",
")",
"{",
"$",
"ret",
"=",
"\"<\"",
".",
"$",
"this",
"->",
"_name",
";",
"//print Attributes",
"if",
"(",
"sizeof",
"(",
"$",
"this",
"->",
"_attributes",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_attributes",
"as",
"$",
"_name",
"=>",
"$",
"_value",
")",
"{",
"$",
"ret",
".=",
"\" \"",
".",
"$",
"_name",
".",
"'=\"'",
".",
"$",
"this",
"->",
"asUTF8",
"(",
"htmlspecialchars",
"(",
"$",
"_value",
")",
")",
".",
"'\"'",
";",
"}",
"}",
"//if there is nothing more todo, close empty tag and exit",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_value",
")",
"&&",
"!",
"sizeof",
"(",
"$",
"this",
"->",
"_childNodes",
")",
")",
"{",
"$",
"ret",
".=",
"\" />\"",
";",
"return",
"$",
"ret",
";",
"}",
"//close opening tag",
"$",
"ret",
".=",
"\">\"",
";",
"//print value",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"_value",
")",
")",
"{",
"$",
"ret",
".=",
"$",
"this",
"->",
"asUTF8",
"(",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"_value",
")",
")",
";",
"}",
"//print child nodes",
"if",
"(",
"sizeof",
"(",
"$",
"this",
"->",
"_childNodes",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_childNodes",
"as",
"$",
"_node",
")",
"{",
"$",
"ret",
".=",
"$",
"_node",
"->",
"asXml",
"(",
")",
";",
"}",
"}",
"$",
"ret",
".=",
"\"</\"",
".",
"$",
"this",
"->",
"_name",
".",
"\">\"",
";",
"return",
"$",
"ret",
";",
"}"
] |
Return a well-formed XML string based on Ckfinder_Connector_Utils_XmlNode element
@return string
@access public
|
[
"Return",
"a",
"well",
"-",
"formed",
"XML",
"string",
"based",
"on",
"Ckfinder_Connector_Utils_XmlNode",
"element"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Utils/XmlNode.php#L166-L201
|
26,982
|
pr-of-it/t4
|
framework/Core/Config.php
|
Config.save
|
public function save()
{
$str = $this->prepareForSave($this->toArray());
if (empty($this->__path)) {
throw new Exception('Empty path for config save');
}
file_put_contents($this->__path, '<?php' . PHP_EOL . PHP_EOL . 'return ' . $str . ';');
return $this;
}
|
php
|
public function save()
{
$str = $this->prepareForSave($this->toArray());
if (empty($this->__path)) {
throw new Exception('Empty path for config save');
}
file_put_contents($this->__path, '<?php' . PHP_EOL . PHP_EOL . 'return ' . $str . ';');
return $this;
}
|
[
"public",
"function",
"save",
"(",
")",
"{",
"$",
"str",
"=",
"$",
"this",
"->",
"prepareForSave",
"(",
"$",
"this",
"->",
"toArray",
"(",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"__path",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Empty path for config save'",
")",
";",
"}",
"file_put_contents",
"(",
"$",
"this",
"->",
"__path",
",",
"'<?php'",
".",
"PHP_EOL",
".",
"PHP_EOL",
".",
"'return '",
".",
"$",
"str",
".",
"';'",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Saves config file
@return $this
@throws \T4\Core\Exception
|
[
"Saves",
"config",
"file"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Core/Config.php#L70-L78
|
26,983
|
pr-of-it/t4
|
framework/Core/Config.php
|
Config.prepareForSave
|
protected function prepareForSave(array $data) : string
{
$str = var_export($data, true);
$str = preg_replace(['~^(\s*)array\s*\($~im', '~^(\s*)\)(\,?)$~im', '~\s+$~im'], ['$1[', '$1]$2', ''], $str);
return $str;
}
|
php
|
protected function prepareForSave(array $data) : string
{
$str = var_export($data, true);
$str = preg_replace(['~^(\s*)array\s*\($~im', '~^(\s*)\)(\,?)$~im', '~\s+$~im'], ['$1[', '$1]$2', ''], $str);
return $str;
}
|
[
"protected",
"function",
"prepareForSave",
"(",
"array",
"$",
"data",
")",
":",
"string",
"{",
"$",
"str",
"=",
"var_export",
"(",
"$",
"data",
",",
"true",
")",
";",
"$",
"str",
"=",
"preg_replace",
"(",
"[",
"'~^(\\s*)array\\s*\\($~im'",
",",
"'~^(\\s*)\\)(\\,?)$~im'",
",",
"'~\\s+$~im'",
"]",
",",
"[",
"'$1['",
",",
"'$1]$2'",
",",
"''",
"]",
",",
"$",
"str",
")",
";",
"return",
"$",
"str",
";",
"}"
] |
Prepares array representation for save in PHP file
@param array $data
@return string
|
[
"Prepares",
"array",
"representation",
"for",
"save",
"in",
"PHP",
"file"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Core/Config.php#L98-L103
|
26,984
|
aimeos/ai-controller-jobs
|
controller/common/src/Controller/Common/Product/Import/Csv/Cache/Product/Standard.php
|
Standard.get
|
public function get( $code, $type = null )
{
if( isset( $this->prodmap[$code] ) ) {
return $this->prodmap[$code];
}
$manager = \Aimeos\MShop::create( $this->getContext(), 'product' );
$search = $manager->createSearch();
$search->setConditions( $search->compare( '==', 'product.code', $code ) );
$result = $manager->searchItems( $search );
if( ( $item = reset( $result ) ) !== false )
{
$this->prodmap[$code] = $item->getId();
return $this->prodmap[$code];
}
}
|
php
|
public function get( $code, $type = null )
{
if( isset( $this->prodmap[$code] ) ) {
return $this->prodmap[$code];
}
$manager = \Aimeos\MShop::create( $this->getContext(), 'product' );
$search = $manager->createSearch();
$search->setConditions( $search->compare( '==', 'product.code', $code ) );
$result = $manager->searchItems( $search );
if( ( $item = reset( $result ) ) !== false )
{
$this->prodmap[$code] = $item->getId();
return $this->prodmap[$code];
}
}
|
[
"public",
"function",
"get",
"(",
"$",
"code",
",",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"prodmap",
"[",
"$",
"code",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"prodmap",
"[",
"$",
"code",
"]",
";",
"}",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"this",
"->",
"getContext",
"(",
")",
",",
"'product'",
")",
";",
"$",
"search",
"=",
"$",
"manager",
"->",
"createSearch",
"(",
")",
";",
"$",
"search",
"->",
"setConditions",
"(",
"$",
"search",
"->",
"compare",
"(",
"'=='",
",",
"'product.code'",
",",
"$",
"code",
")",
")",
";",
"$",
"result",
"=",
"$",
"manager",
"->",
"searchItems",
"(",
"$",
"search",
")",
";",
"if",
"(",
"(",
"$",
"item",
"=",
"reset",
"(",
"$",
"result",
")",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"prodmap",
"[",
"$",
"code",
"]",
"=",
"$",
"item",
"->",
"getId",
"(",
")",
";",
"return",
"$",
"this",
"->",
"prodmap",
"[",
"$",
"code",
"]",
";",
"}",
"}"
] |
Returns the product ID for the given code
@param string $code Product code
@param string|null $type Attribute type
@return string|null Product ID or null if not found
|
[
"Returns",
"the",
"product",
"ID",
"for",
"the",
"given",
"code"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/common/src/Controller/Common/Product/Import/Csv/Cache/Product/Standard.php#L45-L63
|
26,985
|
aimeos/ai-controller-jobs
|
controller/common/src/Controller/Common/Product/Import/Csv/Cache/Product/Standard.php
|
Standard.set
|
public function set( \Aimeos\MShop\Common\Item\Iface $item )
{
$this->prodmap[$item->getCode()] = $item->getId();
}
|
php
|
public function set( \Aimeos\MShop\Common\Item\Iface $item )
{
$this->prodmap[$item->getCode()] = $item->getId();
}
|
[
"public",
"function",
"set",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Common",
"\\",
"Item",
"\\",
"Iface",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"prodmap",
"[",
"$",
"item",
"->",
"getCode",
"(",
")",
"]",
"=",
"$",
"item",
"->",
"getId",
"(",
")",
";",
"}"
] |
Adds the product ID to the cache
@param \Aimeos\MShop\Common\Item\Iface $item Product object
|
[
"Adds",
"the",
"product",
"ID",
"to",
"the",
"cache"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/common/src/Controller/Common/Product/Import/Csv/Cache/Product/Standard.php#L71-L74
|
26,986
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/Config.php
|
CKFinder_Connector_Core_Config.getHideFoldersRegex
|
public function getHideFoldersRegex()
{
static $folderRegex;
if (!isset($folderRegex)) {
if (is_array($this->_hideFolders) && $this->_hideFolders) {
$folderRegex = join("|", $this->_hideFolders);
$folderRegex = strtr($folderRegex, array("?" => "__QMK__", "*" => "__AST__", "|" => "__PIP__"));
$folderRegex = preg_quote($folderRegex, "/");
$folderRegex = strtr($folderRegex, array("__QMK__" => ".", "__AST__" => ".*", "__PIP__" => "|"));
$folderRegex = "/^(?:" . $folderRegex . ")$/uim";
}
else {
$folderRegex = "";
}
}
return $folderRegex;
}
|
php
|
public function getHideFoldersRegex()
{
static $folderRegex;
if (!isset($folderRegex)) {
if (is_array($this->_hideFolders) && $this->_hideFolders) {
$folderRegex = join("|", $this->_hideFolders);
$folderRegex = strtr($folderRegex, array("?" => "__QMK__", "*" => "__AST__", "|" => "__PIP__"));
$folderRegex = preg_quote($folderRegex, "/");
$folderRegex = strtr($folderRegex, array("__QMK__" => ".", "__AST__" => ".*", "__PIP__" => "|"));
$folderRegex = "/^(?:" . $folderRegex . ")$/uim";
}
else {
$folderRegex = "";
}
}
return $folderRegex;
}
|
[
"public",
"function",
"getHideFoldersRegex",
"(",
")",
"{",
"static",
"$",
"folderRegex",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"folderRegex",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"_hideFolders",
")",
"&&",
"$",
"this",
"->",
"_hideFolders",
")",
"{",
"$",
"folderRegex",
"=",
"join",
"(",
"\"|\"",
",",
"$",
"this",
"->",
"_hideFolders",
")",
";",
"$",
"folderRegex",
"=",
"strtr",
"(",
"$",
"folderRegex",
",",
"array",
"(",
"\"?\"",
"=>",
"\"__QMK__\"",
",",
"\"*\"",
"=>",
"\"__AST__\"",
",",
"\"|\"",
"=>",
"\"__PIP__\"",
")",
")",
";",
"$",
"folderRegex",
"=",
"preg_quote",
"(",
"$",
"folderRegex",
",",
"\"/\"",
")",
";",
"$",
"folderRegex",
"=",
"strtr",
"(",
"$",
"folderRegex",
",",
"array",
"(",
"\"__QMK__\"",
"=>",
"\".\"",
",",
"\"__AST__\"",
"=>",
"\".*\"",
",",
"\"__PIP__\"",
"=>",
"\"|\"",
")",
")",
";",
"$",
"folderRegex",
"=",
"\"/^(?:\"",
".",
"$",
"folderRegex",
".",
"\")$/uim\"",
";",
"}",
"else",
"{",
"$",
"folderRegex",
"=",
"\"\"",
";",
"}",
"}",
"return",
"$",
"folderRegex",
";",
"}"
] |
Get regular expression to hide folders
@access public
@return array
|
[
"Get",
"regular",
"expression",
"to",
"hide",
"folders"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/Config.php#L273-L291
|
26,987
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/Config.php
|
CKFinder_Connector_Core_Config.getHideFilesRegex
|
public function getHideFilesRegex()
{
static $fileRegex;
if (!isset($fileRegex)) {
if (is_array($this->_hideFiles) && $this->_hideFiles) {
$fileRegex = join("|", $this->_hideFiles);
$fileRegex = strtr($fileRegex, array("?" => "__QMK__", "*" => "__AST__", "|" => "__PIP__"));
$fileRegex = preg_quote($fileRegex, "/");
$fileRegex = strtr($fileRegex, array("__QMK__" => ".", "__AST__" => ".*", "__PIP__" => "|"));
$fileRegex = "/^(?:" . $fileRegex . ")$/uim";
}
else {
$fileRegex = "";
}
}
return $fileRegex;
}
|
php
|
public function getHideFilesRegex()
{
static $fileRegex;
if (!isset($fileRegex)) {
if (is_array($this->_hideFiles) && $this->_hideFiles) {
$fileRegex = join("|", $this->_hideFiles);
$fileRegex = strtr($fileRegex, array("?" => "__QMK__", "*" => "__AST__", "|" => "__PIP__"));
$fileRegex = preg_quote($fileRegex, "/");
$fileRegex = strtr($fileRegex, array("__QMK__" => ".", "__AST__" => ".*", "__PIP__" => "|"));
$fileRegex = "/^(?:" . $fileRegex . ")$/uim";
}
else {
$fileRegex = "";
}
}
return $fileRegex;
}
|
[
"public",
"function",
"getHideFilesRegex",
"(",
")",
"{",
"static",
"$",
"fileRegex",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"fileRegex",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"_hideFiles",
")",
"&&",
"$",
"this",
"->",
"_hideFiles",
")",
"{",
"$",
"fileRegex",
"=",
"join",
"(",
"\"|\"",
",",
"$",
"this",
"->",
"_hideFiles",
")",
";",
"$",
"fileRegex",
"=",
"strtr",
"(",
"$",
"fileRegex",
",",
"array",
"(",
"\"?\"",
"=>",
"\"__QMK__\"",
",",
"\"*\"",
"=>",
"\"__AST__\"",
",",
"\"|\"",
"=>",
"\"__PIP__\"",
")",
")",
";",
"$",
"fileRegex",
"=",
"preg_quote",
"(",
"$",
"fileRegex",
",",
"\"/\"",
")",
";",
"$",
"fileRegex",
"=",
"strtr",
"(",
"$",
"fileRegex",
",",
"array",
"(",
"\"__QMK__\"",
"=>",
"\".\"",
",",
"\"__AST__\"",
"=>",
"\".*\"",
",",
"\"__PIP__\"",
"=>",
"\"|\"",
")",
")",
";",
"$",
"fileRegex",
"=",
"\"/^(?:\"",
".",
"$",
"fileRegex",
".",
"\")$/uim\"",
";",
"}",
"else",
"{",
"$",
"fileRegex",
"=",
"\"\"",
";",
"}",
"}",
"return",
"$",
"fileRegex",
";",
"}"
] |
Get regular expression to hide files
@access public
@return array
|
[
"Get",
"regular",
"expression",
"to",
"hide",
"files"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/Config.php#L299-L317
|
26,988
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/Config.php
|
CKFinder_Connector_Core_Config.&
|
public function &getResourceTypeConfig($resourceTypeName)
{
$_null = null;
if (isset($this->_resourceTypeConfigCache[$resourceTypeName])) {
return $this->_resourceTypeConfigCache[$resourceTypeName];
}
if (!isset($GLOBALS['config']['ResourceType']) || !is_array($GLOBALS['config']['ResourceType'])) {
return $_null;
}
reset($GLOBALS['config']['ResourceType']);
while (list($_key,$_resourceTypeNode) = each($GLOBALS['config']['ResourceType'])) {
if ($_resourceTypeNode['name'] === $resourceTypeName) {
$this->_resourceTypeConfigCache[$resourceTypeName] = new CKFinder_Connector_Core_ResourceTypeConfig($_resourceTypeNode);
return $this->_resourceTypeConfigCache[$resourceTypeName];
}
}
return $_null;
}
|
php
|
public function &getResourceTypeConfig($resourceTypeName)
{
$_null = null;
if (isset($this->_resourceTypeConfigCache[$resourceTypeName])) {
return $this->_resourceTypeConfigCache[$resourceTypeName];
}
if (!isset($GLOBALS['config']['ResourceType']) || !is_array($GLOBALS['config']['ResourceType'])) {
return $_null;
}
reset($GLOBALS['config']['ResourceType']);
while (list($_key,$_resourceTypeNode) = each($GLOBALS['config']['ResourceType'])) {
if ($_resourceTypeNode['name'] === $resourceTypeName) {
$this->_resourceTypeConfigCache[$resourceTypeName] = new CKFinder_Connector_Core_ResourceTypeConfig($_resourceTypeNode);
return $this->_resourceTypeConfigCache[$resourceTypeName];
}
}
return $_null;
}
|
[
"public",
"function",
"&",
"getResourceTypeConfig",
"(",
"$",
"resourceTypeName",
")",
"{",
"$",
"_null",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_resourceTypeConfigCache",
"[",
"$",
"resourceTypeName",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_resourceTypeConfigCache",
"[",
"$",
"resourceTypeName",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'config'",
"]",
"[",
"'ResourceType'",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"GLOBALS",
"[",
"'config'",
"]",
"[",
"'ResourceType'",
"]",
")",
")",
"{",
"return",
"$",
"_null",
";",
"}",
"reset",
"(",
"$",
"GLOBALS",
"[",
"'config'",
"]",
"[",
"'ResourceType'",
"]",
")",
";",
"while",
"(",
"list",
"(",
"$",
"_key",
",",
"$",
"_resourceTypeNode",
")",
"=",
"each",
"(",
"$",
"GLOBALS",
"[",
"'config'",
"]",
"[",
"'ResourceType'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"_resourceTypeNode",
"[",
"'name'",
"]",
"===",
"$",
"resourceTypeName",
")",
"{",
"$",
"this",
"->",
"_resourceTypeConfigCache",
"[",
"$",
"resourceTypeName",
"]",
"=",
"new",
"CKFinder_Connector_Core_ResourceTypeConfig",
"(",
"$",
"_resourceTypeNode",
")",
";",
"return",
"$",
"this",
"->",
"_resourceTypeConfigCache",
"[",
"$",
"resourceTypeName",
"]",
";",
"}",
"}",
"return",
"$",
"_null",
";",
"}"
] |
Get resourceTypeName config
@param string $resourceTypeName
@return CKFinder_Connector_Core_ResourceTypeConfig|null
@access public
|
[
"Get",
"resourceTypeName",
"config"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/Config.php#L425-L447
|
26,989
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/Config.php
|
CKFinder_Connector_Core_Config.&
|
public function &getThumbnailsConfig()
{
if (!isset($this->_thumbnailsConfigCache)) {
$this->_thumbnailsConfigCache = new CKFinder_Connector_Core_ThumbnailsConfig(isset($GLOBALS['config']['Thumbnails']) ? $GLOBALS['config']['Thumbnails'] : array());
}
return $this->_thumbnailsConfigCache;
}
|
php
|
public function &getThumbnailsConfig()
{
if (!isset($this->_thumbnailsConfigCache)) {
$this->_thumbnailsConfigCache = new CKFinder_Connector_Core_ThumbnailsConfig(isset($GLOBALS['config']['Thumbnails']) ? $GLOBALS['config']['Thumbnails'] : array());
}
return $this->_thumbnailsConfigCache;
}
|
[
"public",
"function",
"&",
"getThumbnailsConfig",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_thumbnailsConfigCache",
")",
")",
"{",
"$",
"this",
"->",
"_thumbnailsConfigCache",
"=",
"new",
"CKFinder_Connector_Core_ThumbnailsConfig",
"(",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'config'",
"]",
"[",
"'Thumbnails'",
"]",
")",
"?",
"$",
"GLOBALS",
"[",
"'config'",
"]",
"[",
"'Thumbnails'",
"]",
":",
"array",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_thumbnailsConfigCache",
";",
"}"
] |
Get thumbnails config
@access public
@return CKFinder_Connector_Core_ThumbnailsConfig
|
[
"Get",
"thumbnails",
"config"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/Config.php#L455-L462
|
26,990
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/Config.php
|
CKFinder_Connector_Core_Config.&
|
public function &getImagesConfig()
{
if (!isset($this->_imagesConfigCache)) {
$this->_imagesConfigCache = new CKFinder_Connector_Core_ImagesConfig(isset($GLOBALS['config']['Images']) ? $GLOBALS['config']['Images'] : array());
}
return $this->_imagesConfigCache;
}
|
php
|
public function &getImagesConfig()
{
if (!isset($this->_imagesConfigCache)) {
$this->_imagesConfigCache = new CKFinder_Connector_Core_ImagesConfig(isset($GLOBALS['config']['Images']) ? $GLOBALS['config']['Images'] : array());
}
return $this->_imagesConfigCache;
}
|
[
"public",
"function",
"&",
"getImagesConfig",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_imagesConfigCache",
")",
")",
"{",
"$",
"this",
"->",
"_imagesConfigCache",
"=",
"new",
"CKFinder_Connector_Core_ImagesConfig",
"(",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'config'",
"]",
"[",
"'Images'",
"]",
")",
"?",
"$",
"GLOBALS",
"[",
"'config'",
"]",
"[",
"'Images'",
"]",
":",
"array",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_imagesConfigCache",
";",
"}"
] |
Get images config
@access public
@return CKFinder_Connector_Core_ImagesConfig
|
[
"Get",
"images",
"config"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/Config.php#L470-L477
|
26,991
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/Config.php
|
CKFinder_Connector_Core_Config.&
|
public function &getAccessControlConfig()
{
if (!isset($this->_accessControlConfigCache)) {
$this->_accessControlConfigCache = new CKFinder_Connector_Core_AccessControlConfig(isset($GLOBALS['config']['AccessControl']) ? $GLOBALS['config']['AccessControl'] : array());
}
return $this->_accessControlConfigCache;
}
|
php
|
public function &getAccessControlConfig()
{
if (!isset($this->_accessControlConfigCache)) {
$this->_accessControlConfigCache = new CKFinder_Connector_Core_AccessControlConfig(isset($GLOBALS['config']['AccessControl']) ? $GLOBALS['config']['AccessControl'] : array());
}
return $this->_accessControlConfigCache;
}
|
[
"public",
"function",
"&",
"getAccessControlConfig",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_accessControlConfigCache",
")",
")",
"{",
"$",
"this",
"->",
"_accessControlConfigCache",
"=",
"new",
"CKFinder_Connector_Core_AccessControlConfig",
"(",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'config'",
"]",
"[",
"'AccessControl'",
"]",
")",
"?",
"$",
"GLOBALS",
"[",
"'config'",
"]",
"[",
"'AccessControl'",
"]",
":",
"array",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_accessControlConfigCache",
";",
"}"
] |
Get access control config
@access public
@return CKFinder_Connector_Core_AccessControlConfig
|
[
"Get",
"access",
"control",
"config"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/Config.php#L485-L492
|
26,992
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/Config.php
|
CKFinder_Connector_Core_Config.getResourceTypeNames
|
public function getResourceTypeNames()
{
if (!isset($GLOBALS['config']['ResourceType']) || !is_array($GLOBALS['config']['ResourceType'])) {
return array();
}
$_names = array();
foreach ($GLOBALS['config']['ResourceType'] as $key => $_resourceType) {
if (isset($_resourceType['name'])) {
$_names[] = (string)$_resourceType['name'];
}
}
return $_names;
}
|
php
|
public function getResourceTypeNames()
{
if (!isset($GLOBALS['config']['ResourceType']) || !is_array($GLOBALS['config']['ResourceType'])) {
return array();
}
$_names = array();
foreach ($GLOBALS['config']['ResourceType'] as $key => $_resourceType) {
if (isset($_resourceType['name'])) {
$_names[] = (string)$_resourceType['name'];
}
}
return $_names;
}
|
[
"public",
"function",
"getResourceTypeNames",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'config'",
"]",
"[",
"'ResourceType'",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"GLOBALS",
"[",
"'config'",
"]",
"[",
"'ResourceType'",
"]",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"_names",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"GLOBALS",
"[",
"'config'",
"]",
"[",
"'ResourceType'",
"]",
"as",
"$",
"key",
"=>",
"$",
"_resourceType",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_resourceType",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"_names",
"[",
"]",
"=",
"(",
"string",
")",
"$",
"_resourceType",
"[",
"'name'",
"]",
";",
"}",
"}",
"return",
"$",
"_names",
";",
"}"
] |
Get all resource type names defined in config
@return array
@access public
|
[
"Get",
"all",
"resource",
"type",
"names",
"defined",
"in",
"config"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/Config.php#L569-L583
|
26,993
|
aimeos/ai-controller-jobs
|
controller/common/src/Controller/Common/Product/Import/Csv/Processor/Attribute/Standard.php
|
Standard.process
|
public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
{
$context = $this->getContext();
$listManager = \Aimeos\MShop::create( $context, 'product/lists' );
$separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );
$listMap = [];
$map = $this->getMappedChunk( $data, $this->getMapping() );
$listItems = $product->getListItems( 'attribute', $this->listTypes );
foreach( $listItems as $listItem )
{
if( ( $refItem = $listItem->getRefItem() ) !== null ) {
$listMap[$refItem->getCode()][$listItem->getType()] = $listItem;
}
}
foreach( $map as $pos => $list )
{
if( $this->checkEntry( $list ) === false ) {
continue;
}
$codes = explode( $separator, $this->getValue( $list, 'attribute.code', '' ) );
foreach( $codes as $code )
{
$code = trim( $code );
$listtype = $this->getValue( $list, 'product.lists.type', 'default' );
if( isset( $listMap[$code][$listtype] ) )
{
$listItem = $listMap[$code][$listtype];
unset( $listItems[$listItem->getId()] );
}
else
{
$listItem = $listManager->createItem()->setType( $listtype );
}
$listItem = $listItem->setPosition( $pos )->fromArray( $list );
$attrItem = $this->getAttributeItem( $code, $this->getValue( $list, 'attribute.type' ) );
$attrItem = $attrItem->setCode( $code )->fromArray( $list );
$product->addListItem( 'attribute', $listItem, $attrItem );
}
}
$product->deleteListItems( $listItems );
return $this->getObject()->process( $product, $data );
}
|
php
|
public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
{
$context = $this->getContext();
$listManager = \Aimeos\MShop::create( $context, 'product/lists' );
$separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );
$listMap = [];
$map = $this->getMappedChunk( $data, $this->getMapping() );
$listItems = $product->getListItems( 'attribute', $this->listTypes );
foreach( $listItems as $listItem )
{
if( ( $refItem = $listItem->getRefItem() ) !== null ) {
$listMap[$refItem->getCode()][$listItem->getType()] = $listItem;
}
}
foreach( $map as $pos => $list )
{
if( $this->checkEntry( $list ) === false ) {
continue;
}
$codes = explode( $separator, $this->getValue( $list, 'attribute.code', '' ) );
foreach( $codes as $code )
{
$code = trim( $code );
$listtype = $this->getValue( $list, 'product.lists.type', 'default' );
if( isset( $listMap[$code][$listtype] ) )
{
$listItem = $listMap[$code][$listtype];
unset( $listItems[$listItem->getId()] );
}
else
{
$listItem = $listManager->createItem()->setType( $listtype );
}
$listItem = $listItem->setPosition( $pos )->fromArray( $list );
$attrItem = $this->getAttributeItem( $code, $this->getValue( $list, 'attribute.type' ) );
$attrItem = $attrItem->setCode( $code )->fromArray( $list );
$product->addListItem( 'attribute', $listItem, $attrItem );
}
}
$product->deleteListItems( $listItems );
return $this->getObject()->process( $product, $data );
}
|
[
"public",
"function",
"process",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Product",
"\\",
"Item",
"\\",
"Iface",
"$",
"product",
",",
"array",
"$",
"data",
")",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"getContext",
"(",
")",
";",
"$",
"listManager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"context",
",",
"'product/lists'",
")",
";",
"$",
"separator",
"=",
"$",
"context",
"->",
"getConfig",
"(",
")",
"->",
"get",
"(",
"'controller/common/product/import/csv/separator'",
",",
"\"\\n\"",
")",
";",
"$",
"listMap",
"=",
"[",
"]",
";",
"$",
"map",
"=",
"$",
"this",
"->",
"getMappedChunk",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"getMapping",
"(",
")",
")",
";",
"$",
"listItems",
"=",
"$",
"product",
"->",
"getListItems",
"(",
"'attribute'",
",",
"$",
"this",
"->",
"listTypes",
")",
";",
"foreach",
"(",
"$",
"listItems",
"as",
"$",
"listItem",
")",
"{",
"if",
"(",
"(",
"$",
"refItem",
"=",
"$",
"listItem",
"->",
"getRefItem",
"(",
")",
")",
"!==",
"null",
")",
"{",
"$",
"listMap",
"[",
"$",
"refItem",
"->",
"getCode",
"(",
")",
"]",
"[",
"$",
"listItem",
"->",
"getType",
"(",
")",
"]",
"=",
"$",
"listItem",
";",
"}",
"}",
"foreach",
"(",
"$",
"map",
"as",
"$",
"pos",
"=>",
"$",
"list",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"checkEntry",
"(",
"$",
"list",
")",
"===",
"false",
")",
"{",
"continue",
";",
"}",
"$",
"codes",
"=",
"explode",
"(",
"$",
"separator",
",",
"$",
"this",
"->",
"getValue",
"(",
"$",
"list",
",",
"'attribute.code'",
",",
"''",
")",
")",
";",
"foreach",
"(",
"$",
"codes",
"as",
"$",
"code",
")",
"{",
"$",
"code",
"=",
"trim",
"(",
"$",
"code",
")",
";",
"$",
"listtype",
"=",
"$",
"this",
"->",
"getValue",
"(",
"$",
"list",
",",
"'product.lists.type'",
",",
"'default'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"listMap",
"[",
"$",
"code",
"]",
"[",
"$",
"listtype",
"]",
")",
")",
"{",
"$",
"listItem",
"=",
"$",
"listMap",
"[",
"$",
"code",
"]",
"[",
"$",
"listtype",
"]",
";",
"unset",
"(",
"$",
"listItems",
"[",
"$",
"listItem",
"->",
"getId",
"(",
")",
"]",
")",
";",
"}",
"else",
"{",
"$",
"listItem",
"=",
"$",
"listManager",
"->",
"createItem",
"(",
")",
"->",
"setType",
"(",
"$",
"listtype",
")",
";",
"}",
"$",
"listItem",
"=",
"$",
"listItem",
"->",
"setPosition",
"(",
"$",
"pos",
")",
"->",
"fromArray",
"(",
"$",
"list",
")",
";",
"$",
"attrItem",
"=",
"$",
"this",
"->",
"getAttributeItem",
"(",
"$",
"code",
",",
"$",
"this",
"->",
"getValue",
"(",
"$",
"list",
",",
"'attribute.type'",
")",
")",
";",
"$",
"attrItem",
"=",
"$",
"attrItem",
"->",
"setCode",
"(",
"$",
"code",
")",
"->",
"fromArray",
"(",
"$",
"list",
")",
";",
"$",
"product",
"->",
"addListItem",
"(",
"'attribute'",
",",
"$",
"listItem",
",",
"$",
"attrItem",
")",
";",
"}",
"}",
"$",
"product",
"->",
"deleteListItems",
"(",
"$",
"listItems",
")",
";",
"return",
"$",
"this",
"->",
"getObject",
"(",
")",
"->",
"process",
"(",
"$",
"product",
",",
"$",
"data",
")",
";",
"}"
] |
Saves the attribute related data to the storage
@param \Aimeos\MShop\Product\Item\Iface $product Product item with associated items
@param array $data List of CSV fields with position as key and data as value
@return array List of data which hasn't been imported
|
[
"Saves",
"the",
"attribute",
"related",
"data",
"to",
"the",
"storage"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/common/src/Controller/Common/Product/Import/Csv/Processor/Attribute/Standard.php#L113-L165
|
26,994
|
antonmedv/purephp
|
src/Command/DeleteCommand.php
|
DeleteCommand.run
|
public function run($arguments, ConnectionInterface $connection)
{
list($name) = $arguments;
if (isset($this->server[$name])) {
unset($this->server[$name]);
return true;
} else {
return false;
}
}
|
php
|
public function run($arguments, ConnectionInterface $connection)
{
list($name) = $arguments;
if (isset($this->server[$name])) {
unset($this->server[$name]);
return true;
} else {
return false;
}
}
|
[
"public",
"function",
"run",
"(",
"$",
"arguments",
",",
"ConnectionInterface",
"$",
"connection",
")",
"{",
"list",
"(",
"$",
"name",
")",
"=",
"$",
"arguments",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"server",
"[",
"$",
"name",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"server",
"[",
"$",
"name",
"]",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Run delete storage command.
@param array $arguments
@param ConnectionInterface $connection
@return bool
|
[
"Run",
"delete",
"storage",
"command",
"."
] |
05aa6b44cea9b0457ec1e5e67e8278cd89d47f21
|
https://github.com/antonmedv/purephp/blob/05aa6b44cea9b0457ec1e5e67e8278cd89d47f21/src/Command/DeleteCommand.php#L35-L45
|
26,995
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Utils/Security.php
|
CKFinder_Connector_Utils_Security.getRidOfMagicQuotes
|
public function getRidOfMagicQuotes()
{
if (CKFINDER_CONNECTOR_PHP_MODE<6 && get_magic_quotes_gpc()) {
if (!empty($_GET)) {
$this->stripQuotes($_GET);
}
if (!empty($_POST)) {
$this->stripQuotes($_POST);
}
if (!empty($_COOKIE)) {
$this->stripQuotes($_COOKIE);
}
if (!empty($_FILES)) {
while (list($k,$v) = each($_FILES)) {
if (isset($_FILES[$k]['name'])) {
$this->stripQuotes($_FILES[$k]['name']);
}
}
}
}
}
|
php
|
public function getRidOfMagicQuotes()
{
if (CKFINDER_CONNECTOR_PHP_MODE<6 && get_magic_quotes_gpc()) {
if (!empty($_GET)) {
$this->stripQuotes($_GET);
}
if (!empty($_POST)) {
$this->stripQuotes($_POST);
}
if (!empty($_COOKIE)) {
$this->stripQuotes($_COOKIE);
}
if (!empty($_FILES)) {
while (list($k,$v) = each($_FILES)) {
if (isset($_FILES[$k]['name'])) {
$this->stripQuotes($_FILES[$k]['name']);
}
}
}
}
}
|
[
"public",
"function",
"getRidOfMagicQuotes",
"(",
")",
"{",
"if",
"(",
"CKFINDER_CONNECTOR_PHP_MODE",
"<",
"6",
"&&",
"get_magic_quotes_gpc",
"(",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"_GET",
")",
")",
"{",
"$",
"this",
"->",
"stripQuotes",
"(",
"$",
"_GET",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"_POST",
")",
")",
"{",
"$",
"this",
"->",
"stripQuotes",
"(",
"$",
"_POST",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"_COOKIE",
")",
")",
"{",
"$",
"this",
"->",
"stripQuotes",
"(",
"$",
"_COOKIE",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"_FILES",
")",
")",
"{",
"while",
"(",
"list",
"(",
"$",
"k",
",",
"$",
"v",
")",
"=",
"each",
"(",
"$",
"_FILES",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_FILES",
"[",
"$",
"k",
"]",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"stripQuotes",
"(",
"$",
"_FILES",
"[",
"$",
"k",
"]",
"[",
"'name'",
"]",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Strip quotes from global arrays
@access public
|
[
"Strip",
"quotes",
"from",
"global",
"arrays"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Utils/Security.php#L33-L53
|
26,996
|
pr-of-it/t4
|
framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Utils/Security.php
|
CKFinder_Connector_Utils_Security.stripQuotes
|
public function stripQuotes(&$var, $depth=0, $howDeep=5)
{
if (is_array($var)) {
if ($depth++<$howDeep) {
while (list($k,$v) = each($var)) {
$this->stripQuotes($var[$k], $depth, $howDeep);
}
}
} else {
$var = stripslashes($var);
}
}
|
php
|
public function stripQuotes(&$var, $depth=0, $howDeep=5)
{
if (is_array($var)) {
if ($depth++<$howDeep) {
while (list($k,$v) = each($var)) {
$this->stripQuotes($var[$k], $depth, $howDeep);
}
}
} else {
$var = stripslashes($var);
}
}
|
[
"public",
"function",
"stripQuotes",
"(",
"&",
"$",
"var",
",",
"$",
"depth",
"=",
"0",
",",
"$",
"howDeep",
"=",
"5",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"var",
")",
")",
"{",
"if",
"(",
"$",
"depth",
"++",
"<",
"$",
"howDeep",
")",
"{",
"while",
"(",
"list",
"(",
"$",
"k",
",",
"$",
"v",
")",
"=",
"each",
"(",
"$",
"var",
")",
")",
"{",
"$",
"this",
"->",
"stripQuotes",
"(",
"$",
"var",
"[",
"$",
"k",
"]",
",",
"$",
"depth",
",",
"$",
"howDeep",
")",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"var",
"=",
"stripslashes",
"(",
"$",
"var",
")",
";",
"}",
"}"
] |
Strip quotes from variable
@access public
@param mixed $var
@param int $depth current depth
@param int $howDeep maximum depth
|
[
"Strip",
"quotes",
"from",
"variable"
] |
8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada
|
https://github.com/pr-of-it/t4/blob/8a8133e0b3abca9d7718fbdcf65b70c2d85b5ada/framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Utils/Security.php#L63-L74
|
26,997
|
aimeos/ai-controller-jobs
|
controller/jobs/src/Controller/Jobs/Catalog/Import/Xml/Standard.php
|
Standard.importNode
|
protected function importNode( \DomElement $node, $domains, $parentid, array &$map )
{
$manager = \Aimeos\MShop::create( $this->getContext(), 'catalog' );
if( ( $attr = $node->attributes->getNamedItem( 'ref' ) ) !== null )
{
try
{
$item = $manager->findItem( $attr->nodeValue, $domains );
$manager->moveItem( $item->getId(), $item->getParentId(), $parentid );
$item = $this->process( $item, $node );
$currentid = $manager->saveItem( $item )->getId();
unset( $item );
$tree = $manager->getTree( $currentid, [], \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST );
foreach( $tree->getChildren() as $child ) {
$map[$child->getCode()] = $child->getId();
}
return $currentid;
}
catch( \Aimeos\MShop\Exception $e ) {} // not found, create new
}
$item = $this->process( $manager->createItem(), $node );
return $manager->insertItem( $item, $parentid )->getId();
}
|
php
|
protected function importNode( \DomElement $node, $domains, $parentid, array &$map )
{
$manager = \Aimeos\MShop::create( $this->getContext(), 'catalog' );
if( ( $attr = $node->attributes->getNamedItem( 'ref' ) ) !== null )
{
try
{
$item = $manager->findItem( $attr->nodeValue, $domains );
$manager->moveItem( $item->getId(), $item->getParentId(), $parentid );
$item = $this->process( $item, $node );
$currentid = $manager->saveItem( $item )->getId();
unset( $item );
$tree = $manager->getTree( $currentid, [], \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST );
foreach( $tree->getChildren() as $child ) {
$map[$child->getCode()] = $child->getId();
}
return $currentid;
}
catch( \Aimeos\MShop\Exception $e ) {} // not found, create new
}
$item = $this->process( $manager->createItem(), $node );
return $manager->insertItem( $item, $parentid )->getId();
}
|
[
"protected",
"function",
"importNode",
"(",
"\\",
"DomElement",
"$",
"node",
",",
"$",
"domains",
",",
"$",
"parentid",
",",
"array",
"&",
"$",
"map",
")",
"{",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"this",
"->",
"getContext",
"(",
")",
",",
"'catalog'",
")",
";",
"if",
"(",
"(",
"$",
"attr",
"=",
"$",
"node",
"->",
"attributes",
"->",
"getNamedItem",
"(",
"'ref'",
")",
")",
"!==",
"null",
")",
"{",
"try",
"{",
"$",
"item",
"=",
"$",
"manager",
"->",
"findItem",
"(",
"$",
"attr",
"->",
"nodeValue",
",",
"$",
"domains",
")",
";",
"$",
"manager",
"->",
"moveItem",
"(",
"$",
"item",
"->",
"getId",
"(",
")",
",",
"$",
"item",
"->",
"getParentId",
"(",
")",
",",
"$",
"parentid",
")",
";",
"$",
"item",
"=",
"$",
"this",
"->",
"process",
"(",
"$",
"item",
",",
"$",
"node",
")",
";",
"$",
"currentid",
"=",
"$",
"manager",
"->",
"saveItem",
"(",
"$",
"item",
")",
"->",
"getId",
"(",
")",
";",
"unset",
"(",
"$",
"item",
")",
";",
"$",
"tree",
"=",
"$",
"manager",
"->",
"getTree",
"(",
"$",
"currentid",
",",
"[",
"]",
",",
"\\",
"Aimeos",
"\\",
"MW",
"\\",
"Tree",
"\\",
"Manager",
"\\",
"Base",
"::",
"LEVEL_LIST",
")",
";",
"foreach",
"(",
"$",
"tree",
"->",
"getChildren",
"(",
")",
"as",
"$",
"child",
")",
"{",
"$",
"map",
"[",
"$",
"child",
"->",
"getCode",
"(",
")",
"]",
"=",
"$",
"child",
"->",
"getId",
"(",
")",
";",
"}",
"return",
"$",
"currentid",
";",
"}",
"catch",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Exception",
"$",
"e",
")",
"{",
"}",
"// not found, create new",
"}",
"$",
"item",
"=",
"$",
"this",
"->",
"process",
"(",
"$",
"manager",
"->",
"createItem",
"(",
")",
",",
"$",
"node",
")",
";",
"return",
"$",
"manager",
"->",
"insertItem",
"(",
"$",
"item",
",",
"$",
"parentid",
")",
"->",
"getId",
"(",
")",
";",
"}"
] |
Imports a single category node
@param \DomElement $node DOM node of "catalogitem" element
@param string[] $domains List of domain names whose referenced items will be updated in the catalog items
@param string|null $parentid ID of the parent catalog node
@param array &$map Will contain the associative list of code/ID pairs of the child categories
@return string Catalog ID of the imported category
|
[
"Imports",
"a",
"single",
"category",
"node"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/jobs/src/Controller/Jobs/Catalog/Import/Xml/Standard.php#L215-L243
|
26,998
|
aimeos/ai-controller-jobs
|
controller/jobs/src/Controller/Jobs/Catalog/Import/Xml/Standard.php
|
Standard.importTree
|
protected function importTree( \XMLReader $xml, array $domains, $parentid = null, array $map = [] )
{
$total = 0;
$childMap = [];
$currentid = $parentid;
while( $xml->read() === true )
{
if( $xml->nodeType === \XMLReader::ELEMENT && $xml->name === 'catalogitem' )
{
if( ( $node = $xml->expand() ) === false )
{
$msg = sprintf( 'Expanding "%1$s" node failed', 'catalogitem' );
throw new \Aimeos\Controller\Jobs\Exception( $msg );
}
if( ( $attr = $node->attributes->getNamedItem( 'ref' ) ) !== null ) {
unset( $map[$attr->nodeValue] );
}
$currentid = $this->importNode( $node, $domains, $parentid, $childMap );
$total++;
}
elseif( $xml->nodeType === \XMLReader::ELEMENT && $xml->name === 'catalog' )
{
$this->importTree( $xml, $domains, $currentid, $childMap );
$childMap = [];
}
elseif( $xml->nodeType === \XMLReader::END_ELEMENT && $xml->name === 'catalog' )
{
\Aimeos\MShop::create( $this->getContext(), 'catalog' )->deleteItems( $map );
break;
}
}
}
|
php
|
protected function importTree( \XMLReader $xml, array $domains, $parentid = null, array $map = [] )
{
$total = 0;
$childMap = [];
$currentid = $parentid;
while( $xml->read() === true )
{
if( $xml->nodeType === \XMLReader::ELEMENT && $xml->name === 'catalogitem' )
{
if( ( $node = $xml->expand() ) === false )
{
$msg = sprintf( 'Expanding "%1$s" node failed', 'catalogitem' );
throw new \Aimeos\Controller\Jobs\Exception( $msg );
}
if( ( $attr = $node->attributes->getNamedItem( 'ref' ) ) !== null ) {
unset( $map[$attr->nodeValue] );
}
$currentid = $this->importNode( $node, $domains, $parentid, $childMap );
$total++;
}
elseif( $xml->nodeType === \XMLReader::ELEMENT && $xml->name === 'catalog' )
{
$this->importTree( $xml, $domains, $currentid, $childMap );
$childMap = [];
}
elseif( $xml->nodeType === \XMLReader::END_ELEMENT && $xml->name === 'catalog' )
{
\Aimeos\MShop::create( $this->getContext(), 'catalog' )->deleteItems( $map );
break;
}
}
}
|
[
"protected",
"function",
"importTree",
"(",
"\\",
"XMLReader",
"$",
"xml",
",",
"array",
"$",
"domains",
",",
"$",
"parentid",
"=",
"null",
",",
"array",
"$",
"map",
"=",
"[",
"]",
")",
"{",
"$",
"total",
"=",
"0",
";",
"$",
"childMap",
"=",
"[",
"]",
";",
"$",
"currentid",
"=",
"$",
"parentid",
";",
"while",
"(",
"$",
"xml",
"->",
"read",
"(",
")",
"===",
"true",
")",
"{",
"if",
"(",
"$",
"xml",
"->",
"nodeType",
"===",
"\\",
"XMLReader",
"::",
"ELEMENT",
"&&",
"$",
"xml",
"->",
"name",
"===",
"'catalogitem'",
")",
"{",
"if",
"(",
"(",
"$",
"node",
"=",
"$",
"xml",
"->",
"expand",
"(",
")",
")",
"===",
"false",
")",
"{",
"$",
"msg",
"=",
"sprintf",
"(",
"'Expanding \"%1$s\" node failed'",
",",
"'catalogitem'",
")",
";",
"throw",
"new",
"\\",
"Aimeos",
"\\",
"Controller",
"\\",
"Jobs",
"\\",
"Exception",
"(",
"$",
"msg",
")",
";",
"}",
"if",
"(",
"(",
"$",
"attr",
"=",
"$",
"node",
"->",
"attributes",
"->",
"getNamedItem",
"(",
"'ref'",
")",
")",
"!==",
"null",
")",
"{",
"unset",
"(",
"$",
"map",
"[",
"$",
"attr",
"->",
"nodeValue",
"]",
")",
";",
"}",
"$",
"currentid",
"=",
"$",
"this",
"->",
"importNode",
"(",
"$",
"node",
",",
"$",
"domains",
",",
"$",
"parentid",
",",
"$",
"childMap",
")",
";",
"$",
"total",
"++",
";",
"}",
"elseif",
"(",
"$",
"xml",
"->",
"nodeType",
"===",
"\\",
"XMLReader",
"::",
"ELEMENT",
"&&",
"$",
"xml",
"->",
"name",
"===",
"'catalog'",
")",
"{",
"$",
"this",
"->",
"importTree",
"(",
"$",
"xml",
",",
"$",
"domains",
",",
"$",
"currentid",
",",
"$",
"childMap",
")",
";",
"$",
"childMap",
"=",
"[",
"]",
";",
"}",
"elseif",
"(",
"$",
"xml",
"->",
"nodeType",
"===",
"\\",
"XMLReader",
"::",
"END_ELEMENT",
"&&",
"$",
"xml",
"->",
"name",
"===",
"'catalog'",
")",
"{",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"this",
"->",
"getContext",
"(",
")",
",",
"'catalog'",
")",
"->",
"deleteItems",
"(",
"$",
"map",
")",
";",
"break",
";",
"}",
"}",
"}"
] |
Imports the catalog document
@param \XMLReader $xml Catalog document to import
@param string[] $domains List of domain names whose referenced items will be updated in the catalog items
@param string|null $parentid ID of the parent catalog node
@param array $map Associative list of catalog code as keys and category ID as values
|
[
"Imports",
"the",
"catalog",
"document"
] |
e4a2fc47850f72907afff68858a2be5865fa4664
|
https://github.com/aimeos/ai-controller-jobs/blob/e4a2fc47850f72907afff68858a2be5865fa4664/controller/jobs/src/Controller/Jobs/Catalog/Import/Xml/Standard.php#L254-L288
|
26,999
|
antonmedv/purephp
|
src/Server.php
|
Server.run
|
public function run()
{
$this->log("Server listening on {$this->host}:{$this->port}");
$this->socket->listen($this->port, $this->host);
$this->loop->run();
}
|
php
|
public function run()
{
$this->log("Server listening on {$this->host}:{$this->port}");
$this->socket->listen($this->port, $this->host);
$this->loop->run();
}
|
[
"public",
"function",
"run",
"(",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"\"Server listening on {$this->host}:{$this->port}\"",
")",
";",
"$",
"this",
"->",
"socket",
"->",
"listen",
"(",
"$",
"this",
"->",
"port",
",",
"$",
"this",
"->",
"host",
")",
";",
"$",
"this",
"->",
"loop",
"->",
"run",
"(",
")",
";",
"}"
] |
Start event loop.
|
[
"Start",
"event",
"loop",
"."
] |
05aa6b44cea9b0457ec1e5e67e8278cd89d47f21
|
https://github.com/antonmedv/purephp/blob/05aa6b44cea9b0457ec1e5e67e8278cd89d47f21/src/Server.php#L75-L80
|
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.