repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6 values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1 value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
koala-framework/koala-framework | Kwf/Component/Events/ViewCache.php | Kwf_Component_Events_ViewCache.onPageChanged | public function onPageChanged(Kwf_Component_Event_Component_Abstract $event)
{
$this->_updates[] = array(
'type' => 'componentLink',
'component_id' => $event->component->componentId
);
$this->_log("type=componentLink component_id={$event->component->componentId}");
} | php | public function onPageChanged(Kwf_Component_Event_Component_Abstract $event)
{
$this->_updates[] = array(
'type' => 'componentLink',
'component_id' => $event->component->componentId
);
$this->_log("type=componentLink component_id={$event->component->componentId}");
} | [
"public",
"function",
"onPageChanged",
"(",
"Kwf_Component_Event_Component_Abstract",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"_updates",
"[",
"]",
"=",
"array",
"(",
"'type'",
"=>",
"'componentLink'",
",",
"'component_id'",
"=>",
"$",
"event",
"->",
"component",
"->",
"componentId",
")",
";",
"$",
"this",
"->",
"_log",
"(",
"\"type=componentLink component_id={$event->component->componentId}\"",
")",
";",
"}"
] | namechanged and filnamechanged-events | [
"namechanged",
"and",
"filnamechanged",
"-",
"events"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Events/ViewCache.php#L154-L161 |
koala-framework/koala-framework | Kwf/Model/Row/Abstract.php | Kwf_Model_Row_Abstract._isDirty | protected function _isDirty($column = null)
{
if ($column) {
return array_key_exists($column, $this->_cleanData);
}
return !empty($this->_cleanData);
} | php | protected function _isDirty($column = null)
{
if ($column) {
return array_key_exists($column, $this->_cleanData);
}
return !empty($this->_cleanData);
} | [
"protected",
"function",
"_isDirty",
"(",
"$",
"column",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"column",
")",
"{",
"return",
"array_key_exists",
"(",
"$",
"column",
",",
"$",
"this",
"->",
"_cleanData",
")",
";",
"}",
"return",
"!",
"empty",
"(",
"$",
"this",
"->",
"_cleanData",
")",
";",
"}"
] | Ob die Row seblst dirty ist | [
"Ob",
"die",
"Row",
"seblst",
"dirty",
"ist"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Model/Row/Abstract.php#L228-L234 |
koala-framework/koala-framework | Kwf/Model/Row/Abstract.php | Kwf_Model_Row_Abstract.isDirty | public final function isDirty($column = null)
{
if ($this->_isDirty($column)) return true;
foreach ($this->_getSiblingRows() as $r) {
if ($r->_isDirty($column)) return true;
}
if (!$column) {
foreach ($this->_childRows as $rule=>$rows) {
foreach ($rows as $row) {
if ($row->isDirty()) return true;
}
}
}
return false;
} | php | public final function isDirty($column = null)
{
if ($this->_isDirty($column)) return true;
foreach ($this->_getSiblingRows() as $r) {
if ($r->_isDirty($column)) return true;
}
if (!$column) {
foreach ($this->_childRows as $rule=>$rows) {
foreach ($rows as $row) {
if ($row->isDirty()) return true;
}
}
}
return false;
} | [
"public",
"final",
"function",
"isDirty",
"(",
"$",
"column",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_isDirty",
"(",
"$",
"column",
")",
")",
"return",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"_getSiblingRows",
"(",
")",
"as",
"$",
"r",
")",
"{",
"if",
"(",
"$",
"r",
"->",
"_isDirty",
"(",
"$",
"column",
")",
")",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"$",
"column",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_childRows",
"as",
"$",
"rule",
"=>",
"$",
"rows",
")",
"{",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"row",
")",
"{",
"if",
"(",
"$",
"row",
"->",
"isDirty",
"(",
")",
")",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Ob die Row oder eine sibling row dirty ist | [
"Ob",
"die",
"Row",
"oder",
"eine",
"sibling",
"row",
"dirty",
"ist"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Model/Row/Abstract.php#L239-L253 |
koala-framework/koala-framework | Kwf/Model/Row/Abstract.php | Kwf_Model_Row_Abstract.getDirtyColumns | public function getDirtyColumns()
{
$ret = array_keys($this->_cleanData);
foreach ($this->_getSiblingRows() as $r) {
$ret = array_merge($ret, $r->getDirtyColumns());
}
return $ret;
} | php | public function getDirtyColumns()
{
$ret = array_keys($this->_cleanData);
foreach ($this->_getSiblingRows() as $r) {
$ret = array_merge($ret, $r->getDirtyColumns());
}
return $ret;
} | [
"public",
"function",
"getDirtyColumns",
"(",
")",
"{",
"$",
"ret",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"_cleanData",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_getSiblingRows",
"(",
")",
"as",
"$",
"r",
")",
"{",
"$",
"ret",
"=",
"array_merge",
"(",
"$",
"ret",
",",
"$",
"r",
"->",
"getDirtyColumns",
"(",
")",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] | dirty columns der row und der sibling rows | [
"dirty",
"columns",
"der",
"row",
"und",
"der",
"sibling",
"rows"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Model/Row/Abstract.php#L258-L265 |
koala-framework/koala-framework | Kwf/Model/Row/Abstract.php | Kwf_Model_Row_Abstract.getCleanValue | public function getCleanValue($name)
{
if (array_key_exists($name, $this->_cleanData)) {
return $this->_cleanData[$name];
}
foreach ($this->_getSiblingRows() as $r) {
if (array_key_exists($name, $r->_cleanData)) {
return $r->_cleanData[$name];
}
}
return $this->__get($name);
} | php | public function getCleanValue($name)
{
if (array_key_exists($name, $this->_cleanData)) {
return $this->_cleanData[$name];
}
foreach ($this->_getSiblingRows() as $r) {
if (array_key_exists($name, $r->_cleanData)) {
return $r->_cleanData[$name];
}
}
return $this->__get($name);
} | [
"public",
"function",
"getCleanValue",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"_cleanData",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_cleanData",
"[",
"$",
"name",
"]",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"_getSiblingRows",
"(",
")",
"as",
"$",
"r",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"r",
"->",
"_cleanData",
")",
")",
"{",
"return",
"$",
"r",
"->",
"_cleanData",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"__get",
"(",
"$",
"name",
")",
";",
"}"
] | Returns the original value of a column, like it exists in the data source.
After save() it will return the new value. | [
"Returns",
"the",
"original",
"value",
"of",
"a",
"column",
"like",
"it",
"exists",
"in",
"the",
"data",
"source",
"."
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Model/Row/Abstract.php#L272-L283 |
koala-framework/koala-framework | Kwf/Model/Row/Abstract.php | Kwf_Model_Row_Abstract._saveWithoutResetDirty | protected function _saveWithoutResetDirty()
{
foreach ($this->_getSiblingRowsForSave() as $k=>$r) {
if (!$r->getModel() instanceof Kwf_Model_SubModel_Interface) {
$ref = $r->getModel()->getReferenceByModelClass(get_class($this->_model), $k);
if (!$r->{$ref['column']}) {
$r->{$ref['column']} = $this->{$this->_getPrimaryKey()};
}
}
$r->_saveWithoutResetDirty();
}
foreach ($this->_childRows as $rule=>$rows) {
foreach ($rows as $row) {
if ($row->_isDeleted) continue;
if (!($row->getModel() instanceof Kwf_Model_RowsSubModel_Interface)) {
if (!$row->{$row->_getPrimaryKey()}) {
//Tabellen Relationen müssen *nach* der row gespeichert werden,
//da beim hinzufügen die id noch nicht verfügbar ist
$ref = $row->getModel()->getReferenceByModelClass(get_class($this->_model), $rule ? $rule : null);
$row->{$ref['column']} = $this->{$this->_getPrimaryKey()};
}
if ($row->isDirty()) {
$row->save();
}
}
}
}
return null;
} | php | protected function _saveWithoutResetDirty()
{
foreach ($this->_getSiblingRowsForSave() as $k=>$r) {
if (!$r->getModel() instanceof Kwf_Model_SubModel_Interface) {
$ref = $r->getModel()->getReferenceByModelClass(get_class($this->_model), $k);
if (!$r->{$ref['column']}) {
$r->{$ref['column']} = $this->{$this->_getPrimaryKey()};
}
}
$r->_saveWithoutResetDirty();
}
foreach ($this->_childRows as $rule=>$rows) {
foreach ($rows as $row) {
if ($row->_isDeleted) continue;
if (!($row->getModel() instanceof Kwf_Model_RowsSubModel_Interface)) {
if (!$row->{$row->_getPrimaryKey()}) {
//Tabellen Relationen müssen *nach* der row gespeichert werden,
//da beim hinzufügen die id noch nicht verfügbar ist
$ref = $row->getModel()->getReferenceByModelClass(get_class($this->_model), $rule ? $rule : null);
$row->{$ref['column']} = $this->{$this->_getPrimaryKey()};
}
if ($row->isDirty()) {
$row->save();
}
}
}
}
return null;
} | [
"protected",
"function",
"_saveWithoutResetDirty",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_getSiblingRowsForSave",
"(",
")",
"as",
"$",
"k",
"=>",
"$",
"r",
")",
"{",
"if",
"(",
"!",
"$",
"r",
"->",
"getModel",
"(",
")",
"instanceof",
"Kwf_Model_SubModel_Interface",
")",
"{",
"$",
"ref",
"=",
"$",
"r",
"->",
"getModel",
"(",
")",
"->",
"getReferenceByModelClass",
"(",
"get_class",
"(",
"$",
"this",
"->",
"_model",
")",
",",
"$",
"k",
")",
";",
"if",
"(",
"!",
"$",
"r",
"->",
"{",
"$",
"ref",
"[",
"'column'",
"]",
"}",
")",
"{",
"$",
"r",
"->",
"{",
"$",
"ref",
"[",
"'column'",
"]",
"}",
"=",
"$",
"this",
"->",
"{",
"$",
"this",
"->",
"_getPrimaryKey",
"(",
")",
"}",
";",
"}",
"}",
"$",
"r",
"->",
"_saveWithoutResetDirty",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"_childRows",
"as",
"$",
"rule",
"=>",
"$",
"rows",
")",
"{",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"row",
")",
"{",
"if",
"(",
"$",
"row",
"->",
"_isDeleted",
")",
"continue",
";",
"if",
"(",
"!",
"(",
"$",
"row",
"->",
"getModel",
"(",
")",
"instanceof",
"Kwf_Model_RowsSubModel_Interface",
")",
")",
"{",
"if",
"(",
"!",
"$",
"row",
"->",
"{",
"$",
"row",
"->",
"_getPrimaryKey",
"(",
")",
"}",
")",
"{",
"//Tabellen Relationen müssen *nach* der row gespeichert werden,",
"//da beim hinzufügen die id noch nicht verfügbar ist",
"$",
"ref",
"=",
"$",
"row",
"->",
"getModel",
"(",
")",
"->",
"getReferenceByModelClass",
"(",
"get_class",
"(",
"$",
"this",
"->",
"_model",
")",
",",
"$",
"rule",
"?",
"$",
"rule",
":",
"null",
")",
";",
"$",
"row",
"->",
"{",
"$",
"ref",
"[",
"'column'",
"]",
"}",
"=",
"$",
"this",
"->",
"{",
"$",
"this",
"->",
"_getPrimaryKey",
"(",
")",
"}",
";",
"}",
"if",
"(",
"$",
"row",
"->",
"isDirty",
"(",
")",
")",
"{",
"$",
"row",
"->",
"save",
"(",
")",
";",
"}",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | TODO: investigate if it would make sense to move _afterSave also out to have it consistent across proxies&siblings | [
"TODO",
":",
"investigate",
"if",
"it",
"would",
"make",
"sense",
"to",
"move",
"_afterSave",
"also",
"out",
"to",
"have",
"it",
"consistent",
"across",
"proxies&siblings"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Model/Row/Abstract.php#L301-L331 |
koala-framework/koala-framework | Kwf/Model/Row/Abstract.php | Kwf_Model_Row_Abstract._toArrayWithoutPrimaryKeys | protected function _toArrayWithoutPrimaryKeys()
{
$ret = $this->toArray();
unset($ret[$this->getModel()->getPrimaryKey()]);
foreach ($this->_getSiblingRows() as $r) {
$primaryKey = $r->getModel()->getPrimaryKey();
if ($primaryKey) {
unset($ret[$primaryKey]);
}
}
return $ret;
} | php | protected function _toArrayWithoutPrimaryKeys()
{
$ret = $this->toArray();
unset($ret[$this->getModel()->getPrimaryKey()]);
foreach ($this->_getSiblingRows() as $r) {
$primaryKey = $r->getModel()->getPrimaryKey();
if ($primaryKey) {
unset($ret[$primaryKey]);
}
}
return $ret;
} | [
"protected",
"function",
"_toArrayWithoutPrimaryKeys",
"(",
")",
"{",
"$",
"ret",
"=",
"$",
"this",
"->",
"toArray",
"(",
")",
";",
"unset",
"(",
"$",
"ret",
"[",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"getPrimaryKey",
"(",
")",
"]",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_getSiblingRows",
"(",
")",
"as",
"$",
"r",
")",
"{",
"$",
"primaryKey",
"=",
"$",
"r",
"->",
"getModel",
"(",
")",
"->",
"getPrimaryKey",
"(",
")",
";",
"if",
"(",
"$",
"primaryKey",
")",
"{",
"unset",
"(",
"$",
"ret",
"[",
"$",
"primaryKey",
"]",
")",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] | ist momentan nur fürs duplicate. | [
"ist",
"momentan",
"nur",
"fürs",
"duplicate",
"."
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Model/Row/Abstract.php#L637-L648 |
koala-framework/koala-framework | Kwf/Model/Row/Abstract.php | Kwf_Model_Row_Abstract.hasColumn | public function hasColumn($col)
{
if (!$this->getModel()->getOwnColumns()) return true;
if (in_array($col, $this->getModel()->getOwnColumns())) return true;
if (in_array($col, $this->getModel()->getExprColumns())) return true;
foreach ($this->_getSiblingRows() as $r) {
if ($r->hasColumn($col)) return true;
}
return false;
} | php | public function hasColumn($col)
{
if (!$this->getModel()->getOwnColumns()) return true;
if (in_array($col, $this->getModel()->getOwnColumns())) return true;
if (in_array($col, $this->getModel()->getExprColumns())) return true;
foreach ($this->_getSiblingRows() as $r) {
if ($r->hasColumn($col)) return true;
}
return false;
} | [
"public",
"function",
"hasColumn",
"(",
"$",
"col",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"getOwnColumns",
"(",
")",
")",
"return",
"true",
";",
"if",
"(",
"in_array",
"(",
"$",
"col",
",",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"getOwnColumns",
"(",
")",
")",
")",
"return",
"true",
";",
"if",
"(",
"in_array",
"(",
"$",
"col",
",",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"getExprColumns",
"(",
")",
")",
")",
"return",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"_getSiblingRows",
"(",
")",
"as",
"$",
"r",
")",
"{",
"if",
"(",
"$",
"r",
"->",
"hasColumn",
"(",
"$",
"col",
")",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | kopiert von model, da in row _getSiblingRows überschrieben sein kann | [
"kopiert",
"von",
"model",
"da",
"in",
"row",
"_getSiblingRows",
"überschrieben",
"sein",
"kann"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Model/Row/Abstract.php#L651-L660 |
koala-framework/koala-framework | Kwf/Model/Row/Abstract.php | Kwf_Model_Row_Abstract._duplicateDependentModel | protected final function _duplicateDependentModel($newRow, $rule, $select = array())
{
$rowset = $this->getChildRows($rule, $select);
foreach ($rowset as $row) {
$ref = $row->getModel()->getReferenceByModelClass(get_class($this->getModel()), null);
$data = array();
$data[$ref['column']] = $newRow->{$this->_getPrimaryKey()};
$row->duplicate($data);
}
} | php | protected final function _duplicateDependentModel($newRow, $rule, $select = array())
{
$rowset = $this->getChildRows($rule, $select);
foreach ($rowset as $row) {
$ref = $row->getModel()->getReferenceByModelClass(get_class($this->getModel()), null);
$data = array();
$data[$ref['column']] = $newRow->{$this->_getPrimaryKey()};
$row->duplicate($data);
}
} | [
"protected",
"final",
"function",
"_duplicateDependentModel",
"(",
"$",
"newRow",
",",
"$",
"rule",
",",
"$",
"select",
"=",
"array",
"(",
")",
")",
"{",
"$",
"rowset",
"=",
"$",
"this",
"->",
"getChildRows",
"(",
"$",
"rule",
",",
"$",
"select",
")",
";",
"foreach",
"(",
"$",
"rowset",
"as",
"$",
"row",
")",
"{",
"$",
"ref",
"=",
"$",
"row",
"->",
"getModel",
"(",
")",
"->",
"getReferenceByModelClass",
"(",
"get_class",
"(",
"$",
"this",
"->",
"getModel",
"(",
")",
")",
",",
"null",
")",
";",
"$",
"data",
"=",
"array",
"(",
")",
";",
"$",
"data",
"[",
"$",
"ref",
"[",
"'column'",
"]",
"]",
"=",
"$",
"newRow",
"->",
"{",
"$",
"this",
"->",
"_getPrimaryKey",
"(",
")",
"}",
";",
"$",
"row",
"->",
"duplicate",
"(",
"$",
"data",
")",
";",
"}",
"}"
] | Hilfsfunktion die von duplicate aufgerufen werden kann | [
"Hilfsfunktion",
"die",
"von",
"duplicate",
"aufgerufen",
"werden",
"kann"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Model/Row/Abstract.php#L665-L674 |
koala-framework/koala-framework | Kwf/Controller/Action/Spam/SetController.php | Kwf_Controller_Action_Spam_SetController.sendSpammedMail | public static function sendSpammedMail($id, $key, $tranport = null)
{
$row = Kwf_Model_Abstract::getInstance('Kwf_Model_Mail')->getRow($id);
if (!$row) return false;
if (Kwf_Util_Check_Spam::getSpamKey($row) != $key) {
return false;
}
if (!$row->mail_sent) {
$row->is_spam = 0;
$row->sendMail($tranport); // setzt mail_sent auf 1 und speichert
return true;
}
return false;
} | php | public static function sendSpammedMail($id, $key, $tranport = null)
{
$row = Kwf_Model_Abstract::getInstance('Kwf_Model_Mail')->getRow($id);
if (!$row) return false;
if (Kwf_Util_Check_Spam::getSpamKey($row) != $key) {
return false;
}
if (!$row->mail_sent) {
$row->is_spam = 0;
$row->sendMail($tranport); // setzt mail_sent auf 1 und speichert
return true;
}
return false;
} | [
"public",
"static",
"function",
"sendSpammedMail",
"(",
"$",
"id",
",",
"$",
"key",
",",
"$",
"tranport",
"=",
"null",
")",
"{",
"$",
"row",
"=",
"Kwf_Model_Abstract",
"::",
"getInstance",
"(",
"'Kwf_Model_Mail'",
")",
"->",
"getRow",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"row",
")",
"return",
"false",
";",
"if",
"(",
"Kwf_Util_Check_Spam",
"::",
"getSpamKey",
"(",
"$",
"row",
")",
"!=",
"$",
"key",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"row",
"->",
"mail_sent",
")",
"{",
"$",
"row",
"->",
"is_spam",
"=",
"0",
";",
"$",
"row",
"->",
"sendMail",
"(",
"$",
"tranport",
")",
";",
"// setzt mail_sent auf 1 und speichert",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Public only for testing!!! | [
"Public",
"only",
"for",
"testing!!!"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Controller/Action/Spam/SetController.php#L22-L37 |
koala-framework/koala-framework | Kwf/Controller/Router/Route/Chain.php | Kwf_Controller_Router_Route_Chain.match | public function match($request, $partial = null)
{
$path = trim($request->getPathInfo(), self::URI_DELIMITER);
$subPath = $path;
$values = array();
$numRoutes = count($this->_routes);
$matchedPath = null;
foreach ($this->_routes as $key => $route) {
if ($key > 0
&& $matchedPath !== null
&& $subPath !== ''
&& $subPath !== false
) {
$separator = substr($subPath, 0, strlen($this->_separators[$key]));
if ($separator !== $this->_separators[$key]) {
return false;
}
$subPath = substr($subPath, strlen($separator));
}
// TODO: Should be an interface method. Hack for 1.0 BC
if (!method_exists($route, 'getVersion') || $route->getVersion() == 1) {
$match = $subPath;
} else {
$request->setPathInfo($subPath);
$match = $request;
}
$res = $route->match($match, true, ($key == $numRoutes - 1));
if ($res === false) {
//BEGIN FIX
$request->setPathInfo($path);
//END FIX
return false;
}
$matchedPath = $route->getMatchedPath();
if ($matchedPath !== null) {
$subPath = substr($subPath, strlen($matchedPath));
$separator = substr($subPath, 0, strlen($this->_separators[$key]));
}
$values = $res + $values;
}
$request->setPathInfo($path);
if ($subPath !== '' && $subPath !== false) {
return false;
}
return $values;
} | php | public function match($request, $partial = null)
{
$path = trim($request->getPathInfo(), self::URI_DELIMITER);
$subPath = $path;
$values = array();
$numRoutes = count($this->_routes);
$matchedPath = null;
foreach ($this->_routes as $key => $route) {
if ($key > 0
&& $matchedPath !== null
&& $subPath !== ''
&& $subPath !== false
) {
$separator = substr($subPath, 0, strlen($this->_separators[$key]));
if ($separator !== $this->_separators[$key]) {
return false;
}
$subPath = substr($subPath, strlen($separator));
}
// TODO: Should be an interface method. Hack for 1.0 BC
if (!method_exists($route, 'getVersion') || $route->getVersion() == 1) {
$match = $subPath;
} else {
$request->setPathInfo($subPath);
$match = $request;
}
$res = $route->match($match, true, ($key == $numRoutes - 1));
if ($res === false) {
//BEGIN FIX
$request->setPathInfo($path);
//END FIX
return false;
}
$matchedPath = $route->getMatchedPath();
if ($matchedPath !== null) {
$subPath = substr($subPath, strlen($matchedPath));
$separator = substr($subPath, 0, strlen($this->_separators[$key]));
}
$values = $res + $values;
}
$request->setPathInfo($path);
if ($subPath !== '' && $subPath !== false) {
return false;
}
return $values;
} | [
"public",
"function",
"match",
"(",
"$",
"request",
",",
"$",
"partial",
"=",
"null",
")",
"{",
"$",
"path",
"=",
"trim",
"(",
"$",
"request",
"->",
"getPathInfo",
"(",
")",
",",
"self",
"::",
"URI_DELIMITER",
")",
";",
"$",
"subPath",
"=",
"$",
"path",
";",
"$",
"values",
"=",
"array",
"(",
")",
";",
"$",
"numRoutes",
"=",
"count",
"(",
"$",
"this",
"->",
"_routes",
")",
";",
"$",
"matchedPath",
"=",
"null",
";",
"foreach",
"(",
"$",
"this",
"->",
"_routes",
"as",
"$",
"key",
"=>",
"$",
"route",
")",
"{",
"if",
"(",
"$",
"key",
">",
"0",
"&&",
"$",
"matchedPath",
"!==",
"null",
"&&",
"$",
"subPath",
"!==",
"''",
"&&",
"$",
"subPath",
"!==",
"false",
")",
"{",
"$",
"separator",
"=",
"substr",
"(",
"$",
"subPath",
",",
"0",
",",
"strlen",
"(",
"$",
"this",
"->",
"_separators",
"[",
"$",
"key",
"]",
")",
")",
";",
"if",
"(",
"$",
"separator",
"!==",
"$",
"this",
"->",
"_separators",
"[",
"$",
"key",
"]",
")",
"{",
"return",
"false",
";",
"}",
"$",
"subPath",
"=",
"substr",
"(",
"$",
"subPath",
",",
"strlen",
"(",
"$",
"separator",
")",
")",
";",
"}",
"// TODO: Should be an interface method. Hack for 1.0 BC",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"route",
",",
"'getVersion'",
")",
"||",
"$",
"route",
"->",
"getVersion",
"(",
")",
"==",
"1",
")",
"{",
"$",
"match",
"=",
"$",
"subPath",
";",
"}",
"else",
"{",
"$",
"request",
"->",
"setPathInfo",
"(",
"$",
"subPath",
")",
";",
"$",
"match",
"=",
"$",
"request",
";",
"}",
"$",
"res",
"=",
"$",
"route",
"->",
"match",
"(",
"$",
"match",
",",
"true",
",",
"(",
"$",
"key",
"==",
"$",
"numRoutes",
"-",
"1",
")",
")",
";",
"if",
"(",
"$",
"res",
"===",
"false",
")",
"{",
"//BEGIN FIX",
"$",
"request",
"->",
"setPathInfo",
"(",
"$",
"path",
")",
";",
"//END FIX",
"return",
"false",
";",
"}",
"$",
"matchedPath",
"=",
"$",
"route",
"->",
"getMatchedPath",
"(",
")",
";",
"if",
"(",
"$",
"matchedPath",
"!==",
"null",
")",
"{",
"$",
"subPath",
"=",
"substr",
"(",
"$",
"subPath",
",",
"strlen",
"(",
"$",
"matchedPath",
")",
")",
";",
"$",
"separator",
"=",
"substr",
"(",
"$",
"subPath",
",",
"0",
",",
"strlen",
"(",
"$",
"this",
"->",
"_separators",
"[",
"$",
"key",
"]",
")",
")",
";",
"}",
"$",
"values",
"=",
"$",
"res",
"+",
"$",
"values",
";",
"}",
"$",
"request",
"->",
"setPathInfo",
"(",
"$",
"path",
")",
";",
"if",
"(",
"$",
"subPath",
"!==",
"''",
"&&",
"$",
"subPath",
"!==",
"false",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"values",
";",
"}"
] | zend implementation overridden to avoid pathInfo getting modified even if route didn't match | [
"zend",
"implementation",
"overridden",
"to",
"avoid",
"pathInfo",
"getting",
"modified",
"even",
"if",
"route",
"didn",
"t",
"match"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Controller/Router/Route/Chain.php#L5-L61 |
koala-framework/koala-framework | Kwc/Root/Category/Generator.php | Kwc_Root_Category_Generator.getRecursivePageChildIds | public function getRecursivePageChildIds($parentId)
{
$select = new Kwf_Model_Select();
$ret = $this->_getChildPageIds($parentId);
foreach ($ret as $i) {
$ret = array_merge($ret, $this->getRecursivePageChildIds($i));
}
return $ret;
} | php | public function getRecursivePageChildIds($parentId)
{
$select = new Kwf_Model_Select();
$ret = $this->_getChildPageIds($parentId);
foreach ($ret as $i) {
$ret = array_merge($ret, $this->getRecursivePageChildIds($i));
}
return $ret;
} | [
"public",
"function",
"getRecursivePageChildIds",
"(",
"$",
"parentId",
")",
"{",
"$",
"select",
"=",
"new",
"Kwf_Model_Select",
"(",
")",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"_getChildPageIds",
"(",
"$",
"parentId",
")",
";",
"foreach",
"(",
"$",
"ret",
"as",
"$",
"i",
")",
"{",
"$",
"ret",
"=",
"array_merge",
"(",
"$",
"ret",
",",
"$",
"this",
"->",
"getRecursivePageChildIds",
"(",
"$",
"i",
")",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] | Returns all recursive children of a page | [
"Returns",
"all",
"recursive",
"children",
"of",
"a",
"page"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Root/Category/Generator.php#L92-L100 |
koala-framework/koala-framework | Kwf/Cache.php | Kwf_Cache.getInstance | public static function getInstance($type)
{
if (!isset(self::$_instances[$type])) {
static $config;
if (!isset($config)) $config = Kwf_Registry::get('config')->caches->toArray();
if (!isset($config[$type])) {
throw new Kwf_Exception("unknown type '$type'");
}
$cls = $config[$type];
self::$_instances[$type] = new $cls();
}
return self::$_instances[$type];
} | php | public static function getInstance($type)
{
if (!isset(self::$_instances[$type])) {
static $config;
if (!isset($config)) $config = Kwf_Registry::get('config')->caches->toArray();
if (!isset($config[$type])) {
throw new Kwf_Exception("unknown type '$type'");
}
$cls = $config[$type];
self::$_instances[$type] = new $cls();
}
return self::$_instances[$type];
} | [
"public",
"static",
"function",
"getInstance",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"_instances",
"[",
"$",
"type",
"]",
")",
")",
"{",
"static",
"$",
"config",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
")",
")",
"$",
"config",
"=",
"Kwf_Registry",
"::",
"get",
"(",
"'config'",
")",
"->",
"caches",
"->",
"toArray",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"$",
"type",
"]",
")",
")",
"{",
"throw",
"new",
"Kwf_Exception",
"(",
"\"unknown type '$type'\"",
")",
";",
"}",
"$",
"cls",
"=",
"$",
"config",
"[",
"$",
"type",
"]",
";",
"self",
"::",
"$",
"_instances",
"[",
"$",
"type",
"]",
"=",
"new",
"$",
"cls",
"(",
")",
";",
"}",
"return",
"self",
"::",
"$",
"_instances",
"[",
"$",
"type",
"]",
";",
"}"
] | @param string entweder aus config (caches.type)
@return Kwf_Cache_Core
ähnlich wie Kwf_Model_Abstract::getInstance() | [
"@param",
"string",
"entweder",
"aus",
"config",
"(",
"caches",
".",
"type",
")",
"@return",
"Kwf_Cache_Core"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Cache.php#L29-L41 |
koala-framework/koala-framework | Kwf/Form/Container/FieldSet.php | Kwf_Form_Container_FieldSet.setCheckboxName | public function setCheckboxName($name)
{
$this->_checkboxHiddenField = new Kwf_Form_Container_FieldSet_Hidden($name);
$this->fields->add($this->_checkboxHiddenField);
return $this;
} | php | public function setCheckboxName($name)
{
$this->_checkboxHiddenField = new Kwf_Form_Container_FieldSet_Hidden($name);
$this->fields->add($this->_checkboxHiddenField);
return $this;
} | [
"public",
"function",
"setCheckboxName",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"_checkboxHiddenField",
"=",
"new",
"Kwf_Form_Container_FieldSet_Hidden",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"fields",
"->",
"add",
"(",
"$",
"this",
"->",
"_checkboxHiddenField",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Zusammen mit setCheckboxToggle(true) | [
"Zusammen",
"mit",
"setCheckboxToggle",
"(",
"true",
")"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Form/Container/FieldSet.php#L28-L33 |
koala-framework/koala-framework | Kwf/Form/Container/FieldSet.php | Kwf_Form_Container_FieldSet._processChildren | protected function _processChildren($method, $childField, $row, $postData)
{
if ($method == 'load') return true;
if ($this->_checkboxHiddenField && $childField !== $this->_checkboxHiddenField) {
$n = $this->_checkboxHiddenField->getFieldName();
if (isset($postData[$n]) && $postData[$n]) {
return true;
} else {
return false;
}
}
return true;
} | php | protected function _processChildren($method, $childField, $row, $postData)
{
if ($method == 'load') return true;
if ($this->_checkboxHiddenField && $childField !== $this->_checkboxHiddenField) {
$n = $this->_checkboxHiddenField->getFieldName();
if (isset($postData[$n]) && $postData[$n]) {
return true;
} else {
return false;
}
}
return true;
} | [
"protected",
"function",
"_processChildren",
"(",
"$",
"method",
",",
"$",
"childField",
",",
"$",
"row",
",",
"$",
"postData",
")",
"{",
"if",
"(",
"$",
"method",
"==",
"'load'",
")",
"return",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"_checkboxHiddenField",
"&&",
"$",
"childField",
"!==",
"$",
"this",
"->",
"_checkboxHiddenField",
")",
"{",
"$",
"n",
"=",
"$",
"this",
"->",
"_checkboxHiddenField",
"->",
"getFieldName",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"postData",
"[",
"$",
"n",
"]",
")",
"&&",
"$",
"postData",
"[",
"$",
"n",
"]",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | verhindert aufrufen von validate/prepareSave/save etc fuer kinder wenn checkbox nicht gesetzt | [
"verhindert",
"aufrufen",
"von",
"validate",
"/",
"prepareSave",
"/",
"save",
"etc",
"fuer",
"kinder",
"wenn",
"checkbox",
"nicht",
"gesetzt"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Form/Container/FieldSet.php#L49-L61 |
koala-framework/koala-framework | Kwf/Component/Abstract/ExtConfig/Abstract.php | Kwf_Component_Abstract_ExtConfig_Abstract.getEditAfterCreateConfigKey | public function getEditAfterCreateConfigKey()
{
$keys = array_keys($this->getConfig(self::TYPE_DEFAULT));
if (!$keys) return null;
return $keys[0];
} | php | public function getEditAfterCreateConfigKey()
{
$keys = array_keys($this->getConfig(self::TYPE_DEFAULT));
if (!$keys) return null;
return $keys[0];
} | [
"public",
"function",
"getEditAfterCreateConfigKey",
"(",
")",
"{",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"self",
"::",
"TYPE_DEFAULT",
")",
")",
";",
"if",
"(",
"!",
"$",
"keys",
")",
"return",
"null",
";",
"return",
"$",
"keys",
"[",
"0",
"]",
";",
"}"
] | Welche config direkt nach dem anlegen dieser Komponente geöffnet werden soll.
Fragt der Paragraphs Controller ab. | [
"Welche",
"config",
"direkt",
"nach",
"dem",
"anlegen",
"dieser",
"Komponente",
"geöffnet",
"werden",
"soll",
"."
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Abstract/ExtConfig/Abstract.php#L66-L71 |
koala-framework/koala-framework | Kwf/Util/Geocode.php | Kwf_Util_Geocode.getCoordinates | public static function getCoordinates($address)
{
$config = Kwf_Registry::get('config');
$q = $address;
$q = str_replace(array('ä','ö','ü','Ä','Ö','Ü','ß'), array('ae','oe','ue','Ae','Oe','Ue','ss'), $q);
$getParams = array(
'address' => $q,
'sensor' => 'false',
'key' => $config->googleServerToServerApiKey
);
$httpClientConfig = array(
'timeout' => 20,
'persistent' => false
);
if ($config->http && $config->http->proxy && $config->http->proxy->host && $config->http->proxy->port) {
$httpClientConfig['adapter'] = 'Zend_Http_Client_Adapter_Proxy';
$httpClientConfig['proxy_host'] = $config->http->proxy->host;
$httpClientConfig['proxy_port'] = $config->http->proxy->port;
}
$client = new Zend_Http_Client("https://maps.googleapis.com/maps/api/geocode/json", $httpClientConfig);
$client->setMethod(Zend_Http_Client::GET);
$client->setParameterGet($getParams);
$body = utf8_encode($client->request()->getBody());
try {
$result = Zend_Json::decode($body);
} catch (Zend_Json_Exception $e) {
$e = new Kwf_Exception_Other($e);
$e->logOrThrow();
}
if (isset($result['results'][0]['geometry']['location']['lat'])
&& isset($result['results'][0]['geometry']['location']['lng'])
) {
return array(
'lat' => $result['results'][0]['geometry']['location']['lat'],
'lng' => $result['results'][0]['geometry']['location']['lng']
);
}
return null;
} | php | public static function getCoordinates($address)
{
$config = Kwf_Registry::get('config');
$q = $address;
$q = str_replace(array('ä','ö','ü','Ä','Ö','Ü','ß'), array('ae','oe','ue','Ae','Oe','Ue','ss'), $q);
$getParams = array(
'address' => $q,
'sensor' => 'false',
'key' => $config->googleServerToServerApiKey
);
$httpClientConfig = array(
'timeout' => 20,
'persistent' => false
);
if ($config->http && $config->http->proxy && $config->http->proxy->host && $config->http->proxy->port) {
$httpClientConfig['adapter'] = 'Zend_Http_Client_Adapter_Proxy';
$httpClientConfig['proxy_host'] = $config->http->proxy->host;
$httpClientConfig['proxy_port'] = $config->http->proxy->port;
}
$client = new Zend_Http_Client("https://maps.googleapis.com/maps/api/geocode/json", $httpClientConfig);
$client->setMethod(Zend_Http_Client::GET);
$client->setParameterGet($getParams);
$body = utf8_encode($client->request()->getBody());
try {
$result = Zend_Json::decode($body);
} catch (Zend_Json_Exception $e) {
$e = new Kwf_Exception_Other($e);
$e->logOrThrow();
}
if (isset($result['results'][0]['geometry']['location']['lat'])
&& isset($result['results'][0]['geometry']['location']['lng'])
) {
return array(
'lat' => $result['results'][0]['geometry']['location']['lat'],
'lng' => $result['results'][0]['geometry']['location']['lng']
);
}
return null;
} | [
"public",
"static",
"function",
"getCoordinates",
"(",
"$",
"address",
")",
"{",
"$",
"config",
"=",
"Kwf_Registry",
"::",
"get",
"(",
"'config'",
")",
";",
"$",
"q",
"=",
"$",
"address",
";",
"$",
"q",
"=",
"str_replace",
"(",
"array",
"(",
"'ä',",
"'",
"ö','",
"ü",
"','Ä",
"'",
",'Ö'",
",",
"'Ü',",
"'",
"ß'),",
" ",
"arra",
"y",
"(",
"ae','",
"o",
"e','",
"u",
"e','",
"A",
"e','",
"O",
"e','",
"U",
"e','",
"s",
"s'),",
" ",
"$q);",
"",
"",
"",
"",
"",
"",
"$",
"getParams",
"=",
"array",
"(",
"'address'",
"=>",
"$",
"q",
",",
"'sensor'",
"=>",
"'false'",
",",
"'key'",
"=>",
"$",
"config",
"->",
"googleServerToServerApiKey",
")",
";",
"$",
"httpClientConfig",
"=",
"array",
"(",
"'timeout'",
"=>",
"20",
",",
"'persistent'",
"=>",
"false",
")",
";",
"if",
"(",
"$",
"config",
"->",
"http",
"&&",
"$",
"config",
"->",
"http",
"->",
"proxy",
"&&",
"$",
"config",
"->",
"http",
"->",
"proxy",
"->",
"host",
"&&",
"$",
"config",
"->",
"http",
"->",
"proxy",
"->",
"port",
")",
"{",
"$",
"httpClientConfig",
"[",
"'adapter'",
"]",
"=",
"'Zend_Http_Client_Adapter_Proxy'",
";",
"$",
"httpClientConfig",
"[",
"'proxy_host'",
"]",
"=",
"$",
"config",
"->",
"http",
"->",
"proxy",
"->",
"host",
";",
"$",
"httpClientConfig",
"[",
"'proxy_port'",
"]",
"=",
"$",
"config",
"->",
"http",
"->",
"proxy",
"->",
"port",
";",
"}",
"$",
"client",
"=",
"new",
"Zend_Http_Client",
"(",
"\"https://maps.googleapis.com/maps/api/geocode/json\"",
",",
"$",
"httpClientConfig",
")",
";",
"$",
"client",
"->",
"setMethod",
"(",
"Zend_Http_Client",
"::",
"GET",
")",
";",
"$",
"client",
"->",
"setParameterGet",
"(",
"$",
"getParams",
")",
";",
"$",
"body",
"=",
"utf8_encode",
"(",
"$",
"client",
"->",
"request",
"(",
")",
"->",
"getBody",
"(",
")",
")",
";",
"try",
"{",
"$",
"result",
"=",
"Zend_Json",
"::",
"decode",
"(",
"$",
"body",
")",
";",
"}",
"catch",
"(",
"Zend_Json_Exception",
"$",
"e",
")",
"{",
"$",
"e",
"=",
"new",
"Kwf_Exception_Other",
"(",
"$",
"e",
")",
";",
"$",
"e",
"->",
"logOrThrow",
"(",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"'results'",
"]",
"[",
"0",
"]",
"[",
"'geometry'",
"]",
"[",
"'location'",
"]",
"[",
"'lat'",
"]",
")",
"&&",
"isset",
"(",
"$",
"result",
"[",
"'results'",
"]",
"[",
"0",
"]",
"[",
"'geometry'",
"]",
"[",
"'location'",
"]",
"[",
"'lng'",
"]",
")",
")",
"{",
"return",
"array",
"(",
"'lat'",
"=>",
"$",
"result",
"[",
"'results'",
"]",
"[",
"0",
"]",
"[",
"'geometry'",
"]",
"[",
"'location'",
"]",
"[",
"'lat'",
"]",
",",
"'lng'",
"=>",
"$",
"result",
"[",
"'results'",
"]",
"[",
"0",
"]",
"[",
"'geometry'",
"]",
"[",
"'location'",
"]",
"[",
"'lng'",
"]",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Gibt die Geokoordinaten anhand einer Adresse zurück
@param string $address Die Adresse die geocodet werden woll
@return array|null $geocode Ein Array mit key 'lat' und 'lng' | [
"Gibt",
"die",
"Geokoordinaten",
"anhand",
"einer",
"Adresse",
"zurück"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Util/Geocode.php#L10-L53 |
koala-framework/koala-framework | Kwf/Controller/Action/Cli/Web/ComponentDeepCopyController.php | Kwf_Controller_Action_Cli_Web_ComponentDeepCopyController.cleanAction | public function cleanAction()
{
set_time_limit(0);
if (!$this->_getParam('id')) throw new Kwf_Exception_Client("required parameter --id");
$db = Zend_Registry::get('db');
$tables = array();
foreach ($db->query("SHOW TABLES")->fetchAll() as $table) {
$table = array_values($table);
$table = $table[0];
$hasComponentId = false;
if ($table == 'kwf_pages') {
$tables[] = $table;
} else {
foreach ($db->query("SHOW FIELDS FROM $table")->fetchAll() as $field) {
if ($field['Field'] == 'component_id') {
$tables[] = $table;
}
}
}
}
$ids = $this->_getChildIds($this->_getParam('id'));
array_unshift($ids, $this->_getParam('id'));
foreach ($ids as $id) {
foreach ($tables as $table) {
if ($table == 'kwf_pages') {
$column = 'id';
} else {
$column = 'component_id';
}
$sql = "DELETE FROM $table ".
"WHERE $column='$id' ".
"OR $column LIKE '".str_replace('_', '\_', $id)."\_%' ".
"OR $column LIKE '".str_replace('_', '\_', $id)."-%'";
echo $sql."\n";
//echo ".";
if ($this->_getParam('force')) $db->query($sql);
}
}
if (!$this->_getParam('force')) echo "\nadd parameter --force to actually execute queries\n";
exit;
} | php | public function cleanAction()
{
set_time_limit(0);
if (!$this->_getParam('id')) throw new Kwf_Exception_Client("required parameter --id");
$db = Zend_Registry::get('db');
$tables = array();
foreach ($db->query("SHOW TABLES")->fetchAll() as $table) {
$table = array_values($table);
$table = $table[0];
$hasComponentId = false;
if ($table == 'kwf_pages') {
$tables[] = $table;
} else {
foreach ($db->query("SHOW FIELDS FROM $table")->fetchAll() as $field) {
if ($field['Field'] == 'component_id') {
$tables[] = $table;
}
}
}
}
$ids = $this->_getChildIds($this->_getParam('id'));
array_unshift($ids, $this->_getParam('id'));
foreach ($ids as $id) {
foreach ($tables as $table) {
if ($table == 'kwf_pages') {
$column = 'id';
} else {
$column = 'component_id';
}
$sql = "DELETE FROM $table ".
"WHERE $column='$id' ".
"OR $column LIKE '".str_replace('_', '\_', $id)."\_%' ".
"OR $column LIKE '".str_replace('_', '\_', $id)."-%'";
echo $sql."\n";
//echo ".";
if ($this->_getParam('force')) $db->query($sql);
}
}
if (!$this->_getParam('force')) echo "\nadd parameter --force to actually execute queries\n";
exit;
} | [
"public",
"function",
"cleanAction",
"(",
")",
"{",
"set_time_limit",
"(",
"0",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"_getParam",
"(",
"'id'",
")",
")",
"throw",
"new",
"Kwf_Exception_Client",
"(",
"\"required parameter --id\"",
")",
";",
"$",
"db",
"=",
"Zend_Registry",
"::",
"get",
"(",
"'db'",
")",
";",
"$",
"tables",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"db",
"->",
"query",
"(",
"\"SHOW TABLES\"",
")",
"->",
"fetchAll",
"(",
")",
"as",
"$",
"table",
")",
"{",
"$",
"table",
"=",
"array_values",
"(",
"$",
"table",
")",
";",
"$",
"table",
"=",
"$",
"table",
"[",
"0",
"]",
";",
"$",
"hasComponentId",
"=",
"false",
";",
"if",
"(",
"$",
"table",
"==",
"'kwf_pages'",
")",
"{",
"$",
"tables",
"[",
"]",
"=",
"$",
"table",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"db",
"->",
"query",
"(",
"\"SHOW FIELDS FROM $table\"",
")",
"->",
"fetchAll",
"(",
")",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"field",
"[",
"'Field'",
"]",
"==",
"'component_id'",
")",
"{",
"$",
"tables",
"[",
"]",
"=",
"$",
"table",
";",
"}",
"}",
"}",
"}",
"$",
"ids",
"=",
"$",
"this",
"->",
"_getChildIds",
"(",
"$",
"this",
"->",
"_getParam",
"(",
"'id'",
")",
")",
";",
"array_unshift",
"(",
"$",
"ids",
",",
"$",
"this",
"->",
"_getParam",
"(",
"'id'",
")",
")",
";",
"foreach",
"(",
"$",
"ids",
"as",
"$",
"id",
")",
"{",
"foreach",
"(",
"$",
"tables",
"as",
"$",
"table",
")",
"{",
"if",
"(",
"$",
"table",
"==",
"'kwf_pages'",
")",
"{",
"$",
"column",
"=",
"'id'",
";",
"}",
"else",
"{",
"$",
"column",
"=",
"'component_id'",
";",
"}",
"$",
"sql",
"=",
"\"DELETE FROM $table \"",
".",
"\"WHERE $column='$id' \"",
".",
"\"OR $column LIKE '\"",
".",
"str_replace",
"(",
"'_'",
",",
"'\\_'",
",",
"$",
"id",
")",
".",
"\"\\_%' \"",
".",
"\"OR $column LIKE '\"",
".",
"str_replace",
"(",
"'_'",
",",
"'\\_'",
",",
"$",
"id",
")",
".",
"\"-%'\"",
";",
"echo",
"$",
"sql",
".",
"\"\\n\"",
";",
"//echo \".\";",
"if",
"(",
"$",
"this",
"->",
"_getParam",
"(",
"'force'",
")",
")",
"$",
"db",
"->",
"query",
"(",
"$",
"sql",
")",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"_getParam",
"(",
"'force'",
")",
")",
"echo",
"\"\\nadd parameter --force to actually execute queries\\n\"",
";",
"exit",
";",
"}"
] | attention: components with dbIdShortcut are NOT handled correctly | [
"attention",
":",
"components",
"with",
"dbIdShortcut",
"are",
"NOT",
"handled",
"correctly"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Controller/Action/Cli/Web/ComponentDeepCopyController.php#L80-L122 |
koala-framework/koala-framework | Kwf/Component/Cache/Mysql.php | Kwf_Component_Cache_Mysql.saveIncludes | public function saveIncludes($componentId, $type, $includedComponents)
{
$m = $this->getModel('includes');
$s = $m->select()
->whereEquals('component_id', $componentId)
->whereEquals('type', $type);
$existingTargetIds = array();
foreach ($m->export(Kwf_Model_Abstract::FORMAT_ARRAY, $s, array('columns'=>array('id', 'target_id', 'type'))) as $i) {
$existingTargetIds[$i['id']] = $i['target_id'];
}
$newTargetIds = array();
if ($includedComponents) {
$data = array();
foreach ($includedComponents as $includedComponent) {
$cmp = Kwf_Component_Data_Root::getInstance()
->getComponentById($componentId, array('ignoreVisible' => true));
$id = substr($includedComponent, 0, strrpos($includedComponent, ':'));
$targetCmp = Kwf_Component_Data_Root::getInstance()
->getComponentById($id, array('ignoreVisible' => true));
if ($cmp->getInheritsParent() !== $targetCmp->getInheritsParent()) {
if (!in_array($includedComponent, $existingTargetIds)) {
$c = array(
'target_id' => $includedComponent,
'type' => $type,
'component_id' => $componentId,
);
$data[] = $c;
}
$newTargetIds[] = $includedComponent;
}
}
$m->import(Kwf_Model_Abstract::FORMAT_ARRAY, $data);
}
$diffTargetIds = array_diff($existingTargetIds, $newTargetIds);
if ($diffTargetIds) {
//delete not anymore included
$m = $this->getModel('includes');
$s = $m->select()
->whereEquals('component_id', $componentId)
->whereEquals('type', $type)
->whereEquals('target_id', $diffTargetIds);
$m->deleteRows($s);
}
} | php | public function saveIncludes($componentId, $type, $includedComponents)
{
$m = $this->getModel('includes');
$s = $m->select()
->whereEquals('component_id', $componentId)
->whereEquals('type', $type);
$existingTargetIds = array();
foreach ($m->export(Kwf_Model_Abstract::FORMAT_ARRAY, $s, array('columns'=>array('id', 'target_id', 'type'))) as $i) {
$existingTargetIds[$i['id']] = $i['target_id'];
}
$newTargetIds = array();
if ($includedComponents) {
$data = array();
foreach ($includedComponents as $includedComponent) {
$cmp = Kwf_Component_Data_Root::getInstance()
->getComponentById($componentId, array('ignoreVisible' => true));
$id = substr($includedComponent, 0, strrpos($includedComponent, ':'));
$targetCmp = Kwf_Component_Data_Root::getInstance()
->getComponentById($id, array('ignoreVisible' => true));
if ($cmp->getInheritsParent() !== $targetCmp->getInheritsParent()) {
if (!in_array($includedComponent, $existingTargetIds)) {
$c = array(
'target_id' => $includedComponent,
'type' => $type,
'component_id' => $componentId,
);
$data[] = $c;
}
$newTargetIds[] = $includedComponent;
}
}
$m->import(Kwf_Model_Abstract::FORMAT_ARRAY, $data);
}
$diffTargetIds = array_diff($existingTargetIds, $newTargetIds);
if ($diffTargetIds) {
//delete not anymore included
$m = $this->getModel('includes');
$s = $m->select()
->whereEquals('component_id', $componentId)
->whereEquals('type', $type)
->whereEquals('target_id', $diffTargetIds);
$m->deleteRows($s);
}
} | [
"public",
"function",
"saveIncludes",
"(",
"$",
"componentId",
",",
"$",
"type",
",",
"$",
"includedComponents",
")",
"{",
"$",
"m",
"=",
"$",
"this",
"->",
"getModel",
"(",
"'includes'",
")",
";",
"$",
"s",
"=",
"$",
"m",
"->",
"select",
"(",
")",
"->",
"whereEquals",
"(",
"'component_id'",
",",
"$",
"componentId",
")",
"->",
"whereEquals",
"(",
"'type'",
",",
"$",
"type",
")",
";",
"$",
"existingTargetIds",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"m",
"->",
"export",
"(",
"Kwf_Model_Abstract",
"::",
"FORMAT_ARRAY",
",",
"$",
"s",
",",
"array",
"(",
"'columns'",
"=>",
"array",
"(",
"'id'",
",",
"'target_id'",
",",
"'type'",
")",
")",
")",
"as",
"$",
"i",
")",
"{",
"$",
"existingTargetIds",
"[",
"$",
"i",
"[",
"'id'",
"]",
"]",
"=",
"$",
"i",
"[",
"'target_id'",
"]",
";",
"}",
"$",
"newTargetIds",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"includedComponents",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"includedComponents",
"as",
"$",
"includedComponent",
")",
"{",
"$",
"cmp",
"=",
"Kwf_Component_Data_Root",
"::",
"getInstance",
"(",
")",
"->",
"getComponentById",
"(",
"$",
"componentId",
",",
"array",
"(",
"'ignoreVisible'",
"=>",
"true",
")",
")",
";",
"$",
"id",
"=",
"substr",
"(",
"$",
"includedComponent",
",",
"0",
",",
"strrpos",
"(",
"$",
"includedComponent",
",",
"':'",
")",
")",
";",
"$",
"targetCmp",
"=",
"Kwf_Component_Data_Root",
"::",
"getInstance",
"(",
")",
"->",
"getComponentById",
"(",
"$",
"id",
",",
"array",
"(",
"'ignoreVisible'",
"=>",
"true",
")",
")",
";",
"if",
"(",
"$",
"cmp",
"->",
"getInheritsParent",
"(",
")",
"!==",
"$",
"targetCmp",
"->",
"getInheritsParent",
"(",
")",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"includedComponent",
",",
"$",
"existingTargetIds",
")",
")",
"{",
"$",
"c",
"=",
"array",
"(",
"'target_id'",
"=>",
"$",
"includedComponent",
",",
"'type'",
"=>",
"$",
"type",
",",
"'component_id'",
"=>",
"$",
"componentId",
",",
")",
";",
"$",
"data",
"[",
"]",
"=",
"$",
"c",
";",
"}",
"$",
"newTargetIds",
"[",
"]",
"=",
"$",
"includedComponent",
";",
"}",
"}",
"$",
"m",
"->",
"import",
"(",
"Kwf_Model_Abstract",
"::",
"FORMAT_ARRAY",
",",
"$",
"data",
")",
";",
"}",
"$",
"diffTargetIds",
"=",
"array_diff",
"(",
"$",
"existingTargetIds",
",",
"$",
"newTargetIds",
")",
";",
"if",
"(",
"$",
"diffTargetIds",
")",
"{",
"//delete not anymore included",
"$",
"m",
"=",
"$",
"this",
"->",
"getModel",
"(",
"'includes'",
")",
";",
"$",
"s",
"=",
"$",
"m",
"->",
"select",
"(",
")",
"->",
"whereEquals",
"(",
"'component_id'",
",",
"$",
"componentId",
")",
"->",
"whereEquals",
"(",
"'type'",
",",
"$",
"type",
")",
"->",
"whereEquals",
"(",
"'target_id'",
",",
"$",
"diffTargetIds",
")",
";",
"$",
"m",
"->",
"deleteRows",
"(",
"$",
"s",
")",
";",
"}",
"}"
] | For unit testing - DO NOT DELETE! | [
"For",
"unit",
"testing",
"-",
"DO",
"NOT",
"DELETE!"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Cache/Mysql.php#L391-L434 |
koala-framework/koala-framework | Kwf/Config/Ini.php | Kwf_Config_Ini._loadIniFile | protected function _loadIniFile($filename)
{
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
$loaded = parse_ini_file($filename, true, INI_SCANNER_RAW); // Warnings and errors are suppressed
$this->_fixValues($loaded);
} else {
$loaded = parse_ini_file($filename, true); // Warnings and errors are suppressed
}
$iniArray = array();
foreach ($loaded as $key => $data)
{
$pieces = explode($this->_sectionSeparator, $key);
$thisSection = trim($pieces[0]);
switch (count($pieces)) {
case 1:
$iniArray[$thisSection] = $data;
break;
case 2:
$extendedSection = trim($pieces[1]);
$iniArray[$thisSection] = array_merge(array(';extends'=>$extendedSection), $data);
break;
default:
/**
* @see Zend_Config_Exception
*/
throw new Zend_Config_Exception("Section '$thisSection' may not extend multiple sections in $filename");
}
}
return $iniArray;
} | php | protected function _loadIniFile($filename)
{
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
$loaded = parse_ini_file($filename, true, INI_SCANNER_RAW); // Warnings and errors are suppressed
$this->_fixValues($loaded);
} else {
$loaded = parse_ini_file($filename, true); // Warnings and errors are suppressed
}
$iniArray = array();
foreach ($loaded as $key => $data)
{
$pieces = explode($this->_sectionSeparator, $key);
$thisSection = trim($pieces[0]);
switch (count($pieces)) {
case 1:
$iniArray[$thisSection] = $data;
break;
case 2:
$extendedSection = trim($pieces[1]);
$iniArray[$thisSection] = array_merge(array(';extends'=>$extendedSection), $data);
break;
default:
/**
* @see Zend_Config_Exception
*/
throw new Zend_Config_Exception("Section '$thisSection' may not extend multiple sections in $filename");
}
}
return $iniArray;
} | [
"protected",
"function",
"_loadIniFile",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"version_compare",
"(",
"PHP_VERSION",
",",
"'5.3.0'",
")",
">=",
"0",
")",
"{",
"$",
"loaded",
"=",
"parse_ini_file",
"(",
"$",
"filename",
",",
"true",
",",
"INI_SCANNER_RAW",
")",
";",
"// Warnings and errors are suppressed",
"$",
"this",
"->",
"_fixValues",
"(",
"$",
"loaded",
")",
";",
"}",
"else",
"{",
"$",
"loaded",
"=",
"parse_ini_file",
"(",
"$",
"filename",
",",
"true",
")",
";",
"// Warnings and errors are suppressed",
"}",
"$",
"iniArray",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"loaded",
"as",
"$",
"key",
"=>",
"$",
"data",
")",
"{",
"$",
"pieces",
"=",
"explode",
"(",
"$",
"this",
"->",
"_sectionSeparator",
",",
"$",
"key",
")",
";",
"$",
"thisSection",
"=",
"trim",
"(",
"$",
"pieces",
"[",
"0",
"]",
")",
";",
"switch",
"(",
"count",
"(",
"$",
"pieces",
")",
")",
"{",
"case",
"1",
":",
"$",
"iniArray",
"[",
"$",
"thisSection",
"]",
"=",
"$",
"data",
";",
"break",
";",
"case",
"2",
":",
"$",
"extendedSection",
"=",
"trim",
"(",
"$",
"pieces",
"[",
"1",
"]",
")",
";",
"$",
"iniArray",
"[",
"$",
"thisSection",
"]",
"=",
"array_merge",
"(",
"array",
"(",
"';extends'",
"=>",
"$",
"extendedSection",
")",
",",
"$",
"data",
")",
";",
"break",
";",
"default",
":",
"/**\n * @see Zend_Config_Exception\n */",
"throw",
"new",
"Zend_Config_Exception",
"(",
"\"Section '$thisSection' may not extend multiple sections in $filename\"",
")",
";",
"}",
"}",
"return",
"$",
"iniArray",
";",
"}"
] | im neuen zend gibts _parseIniFile - nur das sollte ?berschrieben werden | [
"im",
"neuen",
"zend",
"gibts",
"_parseIniFile",
"-",
"nur",
"das",
"sollte",
"?berschrieben",
"werden"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Config/Ini.php#L18-L51 |
koala-framework/koala-framework | Kwc/User/Register/Form/FrontendForm.php | Kwc_User_Register_Form_FrontendForm._setHidden | private function _setHidden($f)
{
if ($f->getHideInRegister()) {
$this->_setHidden2($f);
}
foreach ($f as $i) {
if (is_object($i)) {
$this->_setHidden($i);
}
}
} | php | private function _setHidden($f)
{
if ($f->getHideInRegister()) {
$this->_setHidden2($f);
}
foreach ($f as $i) {
if (is_object($i)) {
$this->_setHidden($i);
}
}
} | [
"private",
"function",
"_setHidden",
"(",
"$",
"f",
")",
"{",
"if",
"(",
"$",
"f",
"->",
"getHideInRegister",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_setHidden2",
"(",
"$",
"f",
")",
";",
"}",
"foreach",
"(",
"$",
"f",
"as",
"$",
"i",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"i",
")",
")",
"{",
"$",
"this",
"->",
"_setHidden",
"(",
"$",
"i",
")",
";",
"}",
"}",
"}"
] | TODO: sollte mit Kwf_Collection_Iterator_Recursive einfacher funktionieren | [
"TODO",
":",
"sollte",
"mit",
"Kwf_Collection_Iterator_Recursive",
"einfacher",
"funktionieren"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/User/Register/Form/FrontendForm.php#L11-L21 |
koala-framework/koala-framework | Kwf/Component/Generator/Events/Table.php | Kwf_Component_Generator_Events_Table._getComponentsFromRow | protected function _getComponentsFromRow($row, $select)
{
$idColumn = $this->_getGenerator()->getIdColumn();
if ($this->_getGenerator()->hasSetting('dbIdShortcut') && $this->_getGenerator()->getSetting('dbIdShortcut')) {
$dbId = $this->_getGenerator()->getSetting('dbIdShortcut') .
$row->$idColumn;
$ret = Kwf_Component_Data_Root::getInstance()->getComponentsByDbId($dbId, $select);
} else if ($row->getModel()->hasColumn('component_id')) {
$dbId = $row->component_id .
$this->_getGenerator()->getIdSeparator() .
$row->$idColumn;
$ret = Kwf_Component_Data_Root::getInstance()->getComponentsByDbId($dbId, $select);
} else {
$cls = $this->_getClassFromRowFromGenerator($row);
$select['id'] = $this->_getGenerator()->getIdSeparator().$row->$idColumn;
$ret = Kwf_Component_Data_Root::getInstance()
->getComponentsBySameClass($cls, $select);
}
foreach ($ret as $k=>$i) {
if ($i->generator !== $this->_getGenerator()) {
unset($ret[$k]);
}
}
return array_values($ret);
} | php | protected function _getComponentsFromRow($row, $select)
{
$idColumn = $this->_getGenerator()->getIdColumn();
if ($this->_getGenerator()->hasSetting('dbIdShortcut') && $this->_getGenerator()->getSetting('dbIdShortcut')) {
$dbId = $this->_getGenerator()->getSetting('dbIdShortcut') .
$row->$idColumn;
$ret = Kwf_Component_Data_Root::getInstance()->getComponentsByDbId($dbId, $select);
} else if ($row->getModel()->hasColumn('component_id')) {
$dbId = $row->component_id .
$this->_getGenerator()->getIdSeparator() .
$row->$idColumn;
$ret = Kwf_Component_Data_Root::getInstance()->getComponentsByDbId($dbId, $select);
} else {
$cls = $this->_getClassFromRowFromGenerator($row);
$select['id'] = $this->_getGenerator()->getIdSeparator().$row->$idColumn;
$ret = Kwf_Component_Data_Root::getInstance()
->getComponentsBySameClass($cls, $select);
}
foreach ($ret as $k=>$i) {
if ($i->generator !== $this->_getGenerator()) {
unset($ret[$k]);
}
}
return array_values($ret);
} | [
"protected",
"function",
"_getComponentsFromRow",
"(",
"$",
"row",
",",
"$",
"select",
")",
"{",
"$",
"idColumn",
"=",
"$",
"this",
"->",
"_getGenerator",
"(",
")",
"->",
"getIdColumn",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_getGenerator",
"(",
")",
"->",
"hasSetting",
"(",
"'dbIdShortcut'",
")",
"&&",
"$",
"this",
"->",
"_getGenerator",
"(",
")",
"->",
"getSetting",
"(",
"'dbIdShortcut'",
")",
")",
"{",
"$",
"dbId",
"=",
"$",
"this",
"->",
"_getGenerator",
"(",
")",
"->",
"getSetting",
"(",
"'dbIdShortcut'",
")",
".",
"$",
"row",
"->",
"$",
"idColumn",
";",
"$",
"ret",
"=",
"Kwf_Component_Data_Root",
"::",
"getInstance",
"(",
")",
"->",
"getComponentsByDbId",
"(",
"$",
"dbId",
",",
"$",
"select",
")",
";",
"}",
"else",
"if",
"(",
"$",
"row",
"->",
"getModel",
"(",
")",
"->",
"hasColumn",
"(",
"'component_id'",
")",
")",
"{",
"$",
"dbId",
"=",
"$",
"row",
"->",
"component_id",
".",
"$",
"this",
"->",
"_getGenerator",
"(",
")",
"->",
"getIdSeparator",
"(",
")",
".",
"$",
"row",
"->",
"$",
"idColumn",
";",
"$",
"ret",
"=",
"Kwf_Component_Data_Root",
"::",
"getInstance",
"(",
")",
"->",
"getComponentsByDbId",
"(",
"$",
"dbId",
",",
"$",
"select",
")",
";",
"}",
"else",
"{",
"$",
"cls",
"=",
"$",
"this",
"->",
"_getClassFromRowFromGenerator",
"(",
"$",
"row",
")",
";",
"$",
"select",
"[",
"'id'",
"]",
"=",
"$",
"this",
"->",
"_getGenerator",
"(",
")",
"->",
"getIdSeparator",
"(",
")",
".",
"$",
"row",
"->",
"$",
"idColumn",
";",
"$",
"ret",
"=",
"Kwf_Component_Data_Root",
"::",
"getInstance",
"(",
")",
"->",
"getComponentsBySameClass",
"(",
"$",
"cls",
",",
"$",
"select",
")",
";",
"}",
"foreach",
"(",
"$",
"ret",
"as",
"$",
"k",
"=>",
"$",
"i",
")",
"{",
"if",
"(",
"$",
"i",
"->",
"generator",
"!==",
"$",
"this",
"->",
"_getGenerator",
"(",
")",
")",
"{",
"unset",
"(",
"$",
"ret",
"[",
"$",
"k",
"]",
")",
";",
"}",
"}",
"return",
"array_values",
"(",
"$",
"ret",
")",
";",
"}"
] | overrridden in Kwc_Root_Category_GeneratorEvents | [
"overrridden",
"in",
"Kwc_Root_Category_GeneratorEvents"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Generator/Events/Table.php#L123-L147 |
koala-framework/koala-framework | Kwf/Util/Symfony.php | Kwf_Util_Symfony.getKernel | public static function getKernel()
{
if (!isset(self::$_instance)) {
if ($cls = Kwf_Config::getValue('symfony.kernelClass')) {
if (!class_exists('Symfony\Component\HttpKernel\Kernel')) return null;
self::$_instance = new $cls();
self::$_instance->boot(); //make sure it is booted (won't do it twice)
} else {
return null;
}
}
return self::$_instance;
} | php | public static function getKernel()
{
if (!isset(self::$_instance)) {
if ($cls = Kwf_Config::getValue('symfony.kernelClass')) {
if (!class_exists('Symfony\Component\HttpKernel\Kernel')) return null;
self::$_instance = new $cls();
self::$_instance->boot(); //make sure it is booted (won't do it twice)
} else {
return null;
}
}
return self::$_instance;
} | [
"public",
"static",
"function",
"getKernel",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"_instance",
")",
")",
"{",
"if",
"(",
"$",
"cls",
"=",
"Kwf_Config",
"::",
"getValue",
"(",
"'symfony.kernelClass'",
")",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"'Symfony\\Component\\HttpKernel\\Kernel'",
")",
")",
"return",
"null",
";",
"self",
"::",
"$",
"_instance",
"=",
"new",
"$",
"cls",
"(",
")",
";",
"self",
"::",
"$",
"_instance",
"->",
"boot",
"(",
")",
";",
"//make sure it is booted (won't do it twice)",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"return",
"self",
"::",
"$",
"_instance",
";",
"}"
] | Don't use this method in Symfony context
@return Kwf_SymfonyKernel | [
"Don",
"t",
"use",
"this",
"method",
"in",
"Symfony",
"context"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Util/Symfony.php#L11-L24 |
koala-framework/koala-framework | Kwf/Component/Data/Root.php | Kwf_Component_Data_Root.getInstance | public static function getInstance()
{
if (is_null(self::$_instance)) {
$c = self::getComponentClass();
if ($c) {
self::$_instance = new self(array('componentClass' => $c));
} else {
self::$_instance = false;
}
}
return self::$_instance;
} | php | public static function getInstance()
{
if (is_null(self::$_instance)) {
$c = self::getComponentClass();
if ($c) {
self::$_instance = new self(array('componentClass' => $c));
} else {
self::$_instance = false;
}
}
return self::$_instance;
} | [
"public",
"static",
"function",
"getInstance",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"self",
"::",
"$",
"_instance",
")",
")",
"{",
"$",
"c",
"=",
"self",
"::",
"getComponentClass",
"(",
")",
";",
"if",
"(",
"$",
"c",
")",
"{",
"self",
"::",
"$",
"_instance",
"=",
"new",
"self",
"(",
"array",
"(",
"'componentClass'",
"=>",
"$",
"c",
")",
")",
";",
"}",
"else",
"{",
"self",
"::",
"$",
"_instance",
"=",
"false",
";",
"}",
"}",
"return",
"self",
"::",
"$",
"_instance",
";",
"}"
] | Returns the root component data instance
@return Kwf_Component_Data_Root | [
"Returns",
"the",
"root",
"component",
"data",
"instance"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data/Root.php#L49-L60 |
koala-framework/koala-framework | Kwf/Component/Data/Root.php | Kwf_Component_Data_Root.freeMemory | public function freeMemory()
{
$this->_freeMemory();
foreach ($this->_dataCache as $id=>$c) {
if (isset($this->_dataCacheIgnoreVisible[$id])) {
unset($this->_dataCacheIgnoreVisible[$id]);
}
$c->_freeMemory();
}
foreach ($this->_dataCacheIgnoreVisible as $id=>$c) {
$c->_freeMemory();
}
$this->_dataCache = array();
$this->_dataCacheIgnoreVisible = array();
$this->_componentsByClassCache = null;
$this->_componentsByDbIdCache = null;
$this->_generatorsForClassesCache = array();
//Kwf_Component_Generator_Abstract::clearInstances();
Kwf_Model_Abstract::clearAllRows();
if (function_exists('gc_collect_cycles')) gc_collect_cycles();
} | php | public function freeMemory()
{
$this->_freeMemory();
foreach ($this->_dataCache as $id=>$c) {
if (isset($this->_dataCacheIgnoreVisible[$id])) {
unset($this->_dataCacheIgnoreVisible[$id]);
}
$c->_freeMemory();
}
foreach ($this->_dataCacheIgnoreVisible as $id=>$c) {
$c->_freeMemory();
}
$this->_dataCache = array();
$this->_dataCacheIgnoreVisible = array();
$this->_componentsByClassCache = null;
$this->_componentsByDbIdCache = null;
$this->_generatorsForClassesCache = array();
//Kwf_Component_Generator_Abstract::clearInstances();
Kwf_Model_Abstract::clearAllRows();
if (function_exists('gc_collect_cycles')) gc_collect_cycles();
} | [
"public",
"function",
"freeMemory",
"(",
")",
"{",
"$",
"this",
"->",
"_freeMemory",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_dataCache",
"as",
"$",
"id",
"=>",
"$",
"c",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_dataCacheIgnoreVisible",
"[",
"$",
"id",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_dataCacheIgnoreVisible",
"[",
"$",
"id",
"]",
")",
";",
"}",
"$",
"c",
"->",
"_freeMemory",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"_dataCacheIgnoreVisible",
"as",
"$",
"id",
"=>",
"$",
"c",
")",
"{",
"$",
"c",
"->",
"_freeMemory",
"(",
")",
";",
"}",
"$",
"this",
"->",
"_dataCache",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"_dataCacheIgnoreVisible",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"_componentsByClassCache",
"=",
"null",
";",
"$",
"this",
"->",
"_componentsByDbIdCache",
"=",
"null",
";",
"$",
"this",
"->",
"_generatorsForClassesCache",
"=",
"array",
"(",
")",
";",
"//Kwf_Component_Generator_Abstract::clearInstances();",
"Kwf_Model_Abstract",
"::",
"clearAllRows",
"(",
")",
";",
"if",
"(",
"function_exists",
"(",
"'gc_collect_cycles'",
")",
")",
"gc_collect_cycles",
"(",
")",
";",
"}"
] | Tries to clear all cached data objects and row objects
Usful when processing lot of components to avoid memory issues | [
"Tries",
"to",
"clear",
"all",
"cached",
"data",
"objects",
"and",
"row",
"objects"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data/Root.php#L122-L143 |
koala-framework/koala-framework | Kwf/Component/Data/Root.php | Kwf_Component_Data_Root.getPageByUrl | public function getPageByUrl($url, $acceptLanguage, &$exactMatch = true)
{
$parsedUrl = parse_url($url);
if (!isset($parsedUrl['path'])) return null;
if (!isset($parsedUrl['host'])) {
throw new Kwf_Exception("Host is missing in url '$url'");
}
foreach ($this->getPlugins('Kwf_Component_PluginRoot_Interface_PreResolveUrl') as $p) {
$parsedUrl = $p->preFormatPath($parsedUrl);
}
$cacheUrl = $parsedUrl['host'].$parsedUrl['path'];
if ($ret = Kwf_Component_Cache_Url_Abstract::getInstance()->load($cacheUrl)) {
$exactMatch = true;
} else {
$path = $this->getComponent()->formatPath($parsedUrl);
if (is_null($path)) return null;
$baseUrl = Kwf_Setup::getBaseUrl();
if ($baseUrl) {
if (substr($path, 0, strlen($baseUrl)) != $baseUrl) {
return null;
} else {
$path = substr($path, strlen($baseUrl));
}
}
$path = trim($path, '/');
$ret = $this->getComponent()->getPageByUrl($path, $acceptLanguage);
if ($ret && (
$ret->generator->getGeneratorFlag('matchChildUrls')
|| rawurldecode($ret->url) == $parsedUrl['path']) //nur cachen wenn kein redirect gemacht wird
) {
$exactMatch = true;
if ($ret->isVisible()) {
Kwf_Component_Cache_Url_Abstract::getInstance()->save($cacheUrl, $ret);
}
} else {
$exactMatch = false;
}
}
return $ret;
} | php | public function getPageByUrl($url, $acceptLanguage, &$exactMatch = true)
{
$parsedUrl = parse_url($url);
if (!isset($parsedUrl['path'])) return null;
if (!isset($parsedUrl['host'])) {
throw new Kwf_Exception("Host is missing in url '$url'");
}
foreach ($this->getPlugins('Kwf_Component_PluginRoot_Interface_PreResolveUrl') as $p) {
$parsedUrl = $p->preFormatPath($parsedUrl);
}
$cacheUrl = $parsedUrl['host'].$parsedUrl['path'];
if ($ret = Kwf_Component_Cache_Url_Abstract::getInstance()->load($cacheUrl)) {
$exactMatch = true;
} else {
$path = $this->getComponent()->formatPath($parsedUrl);
if (is_null($path)) return null;
$baseUrl = Kwf_Setup::getBaseUrl();
if ($baseUrl) {
if (substr($path, 0, strlen($baseUrl)) != $baseUrl) {
return null;
} else {
$path = substr($path, strlen($baseUrl));
}
}
$path = trim($path, '/');
$ret = $this->getComponent()->getPageByUrl($path, $acceptLanguage);
if ($ret && (
$ret->generator->getGeneratorFlag('matchChildUrls')
|| rawurldecode($ret->url) == $parsedUrl['path']) //nur cachen wenn kein redirect gemacht wird
) {
$exactMatch = true;
if ($ret->isVisible()) {
Kwf_Component_Cache_Url_Abstract::getInstance()->save($cacheUrl, $ret);
}
} else {
$exactMatch = false;
}
}
return $ret;
} | [
"public",
"function",
"getPageByUrl",
"(",
"$",
"url",
",",
"$",
"acceptLanguage",
",",
"&",
"$",
"exactMatch",
"=",
"true",
")",
"{",
"$",
"parsedUrl",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"parsedUrl",
"[",
"'path'",
"]",
")",
")",
"return",
"null",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"parsedUrl",
"[",
"'host'",
"]",
")",
")",
"{",
"throw",
"new",
"Kwf_Exception",
"(",
"\"Host is missing in url '$url'\"",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getPlugins",
"(",
"'Kwf_Component_PluginRoot_Interface_PreResolveUrl'",
")",
"as",
"$",
"p",
")",
"{",
"$",
"parsedUrl",
"=",
"$",
"p",
"->",
"preFormatPath",
"(",
"$",
"parsedUrl",
")",
";",
"}",
"$",
"cacheUrl",
"=",
"$",
"parsedUrl",
"[",
"'host'",
"]",
".",
"$",
"parsedUrl",
"[",
"'path'",
"]",
";",
"if",
"(",
"$",
"ret",
"=",
"Kwf_Component_Cache_Url_Abstract",
"::",
"getInstance",
"(",
")",
"->",
"load",
"(",
"$",
"cacheUrl",
")",
")",
"{",
"$",
"exactMatch",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getComponent",
"(",
")",
"->",
"formatPath",
"(",
"$",
"parsedUrl",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"path",
")",
")",
"return",
"null",
";",
"$",
"baseUrl",
"=",
"Kwf_Setup",
"::",
"getBaseUrl",
"(",
")",
";",
"if",
"(",
"$",
"baseUrl",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"strlen",
"(",
"$",
"baseUrl",
")",
")",
"!=",
"$",
"baseUrl",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"$",
"path",
"=",
"substr",
"(",
"$",
"path",
",",
"strlen",
"(",
"$",
"baseUrl",
")",
")",
";",
"}",
"}",
"$",
"path",
"=",
"trim",
"(",
"$",
"path",
",",
"'/'",
")",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"getComponent",
"(",
")",
"->",
"getPageByUrl",
"(",
"$",
"path",
",",
"$",
"acceptLanguage",
")",
";",
"if",
"(",
"$",
"ret",
"&&",
"(",
"$",
"ret",
"->",
"generator",
"->",
"getGeneratorFlag",
"(",
"'matchChildUrls'",
")",
"||",
"rawurldecode",
"(",
"$",
"ret",
"->",
"url",
")",
"==",
"$",
"parsedUrl",
"[",
"'path'",
"]",
")",
"//nur cachen wenn kein redirect gemacht wird",
")",
"{",
"$",
"exactMatch",
"=",
"true",
";",
"if",
"(",
"$",
"ret",
"->",
"isVisible",
"(",
")",
")",
"{",
"Kwf_Component_Cache_Url_Abstract",
"::",
"getInstance",
"(",
")",
"->",
"save",
"(",
"$",
"cacheUrl",
",",
"$",
"ret",
")",
";",
"}",
"}",
"else",
"{",
"$",
"exactMatch",
"=",
"false",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] | /*
@return Kwf_Component_Data | [
"/",
"*"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data/Root.php#L172-L212 |
koala-framework/koala-framework | Kwf/Component/Data/Root.php | Kwf_Component_Data_Root.getComponentById | public function getComponentById($componentId, $select = array())
{
if (!$componentId) return null;
if (is_array($select)) {
$partTypes = array_keys($select);
} else {
$partTypes = $select->getPartTypes();
}
if (!$partTypes || $partTypes == array(Kwf_Component_Select::IGNORE_VISIBLE)) {
if (isset($this->_dataCache[$componentId])) {
return $this->_dataCache[$componentId];
}
if (is_array($select)) {
if (isset($select[Kwf_Component_Select::IGNORE_VISIBLE])) {
$ignoreVisible = $select[Kwf_Component_Select::IGNORE_VISIBLE];
} else {
$ignoreVisible = false;
}
} else {
$ignoreVisible = $select->getPart(Kwf_Component_Select::IGNORE_VISIBLE);
}
if ($ignoreVisible && isset($this->_dataCacheIgnoreVisible[$componentId])) {
return $this->_dataCacheIgnoreVisible[$componentId];
}
}
if (is_array($select)) {
$select = new Kwf_Component_Select($select);
} else {
$select = clone $select;
}
$ret = $this;
$idParts = $this->_getIdParts($componentId);
//Optimierung: wenn bereits ein parent der gesuchten komponente existiert, dieses direkt verwenden
//hilft vorallem wenn das parent deserialisiert wurde da in dem fall die weiteren parents nicht erstellt werden müssen
for($i=0; $i<count($idParts); ++$i) {
$id = implode('', array_slice($idParts, 0, count($idParts)-$i-1));
$found = false;
if (isset($this->_dataCache[$id])) {
$ret = $this->_dataCache[$id];
$found = true;
} else {
if (is_array($select)) {
if (isset($select[Kwf_Component_Select::IGNORE_VISIBLE])) {
$ignoreVisible = $select[Kwf_Component_Select::IGNORE_VISIBLE];
} else {
$ignoreVisible = false;
}
} else {
$ignoreVisible = $select->getPart(Kwf_Component_Select::IGNORE_VISIBLE);
}
if ($ignoreVisible && isset($this->_dataCacheIgnoreVisible[$id])) {
$ret = $this->_dataCacheIgnoreVisible[$id];
$found = true;
}
}
if ($found) {
$idParts = array_slice($idParts, count($idParts)-$i-1);
break;
}
}
foreach ($idParts as $i=>$idPart) {
if ($idPart == 'root') {
$ret = $this;
} else {
if ($i+1 == count($idParts)) {
//nur bei letzem part select berücksichtigen
$select->whereId($idPart);
$s = $select;
} else {
$s = array('id'=>$idPart);
if ($select->hasPart(Kwf_Component_Select::IGNORE_VISIBLE)) {
//ignoreVisible doch mitnehmen damit wir unterkomponeten von unsichtbaren
//komponenten finden
$s['ignoreVisible'] = $select->getPart(Kwf_Component_Select::IGNORE_VISIBLE);
}
if ($select->hasPart(Kwf_Component_Select::WHERE_SUBROOT)) {
//ignoreVisible doch mitnehmen damit wir unterkomponeten von unsichtbaren
//komponenten finden
$s['subroot'] = $select->getPart(Kwf_Component_Select::WHERE_SUBROOT);
}
$s = new Kwf_Component_Select($s);
}
if ($i == 0 && !$found) { // Muss eine Page sein
$ret = null;
$generators = $this->getPageGenerators();
foreach ($generators as $generator) {
$ret = $generator->getChildData(null, $s);
$ret = array_pop($ret);
if ($ret) break;
}
} else {
$ret = $ret->getChildComponent($s);
}
if (!$ret) break;
}
}
return $ret;
} | php | public function getComponentById($componentId, $select = array())
{
if (!$componentId) return null;
if (is_array($select)) {
$partTypes = array_keys($select);
} else {
$partTypes = $select->getPartTypes();
}
if (!$partTypes || $partTypes == array(Kwf_Component_Select::IGNORE_VISIBLE)) {
if (isset($this->_dataCache[$componentId])) {
return $this->_dataCache[$componentId];
}
if (is_array($select)) {
if (isset($select[Kwf_Component_Select::IGNORE_VISIBLE])) {
$ignoreVisible = $select[Kwf_Component_Select::IGNORE_VISIBLE];
} else {
$ignoreVisible = false;
}
} else {
$ignoreVisible = $select->getPart(Kwf_Component_Select::IGNORE_VISIBLE);
}
if ($ignoreVisible && isset($this->_dataCacheIgnoreVisible[$componentId])) {
return $this->_dataCacheIgnoreVisible[$componentId];
}
}
if (is_array($select)) {
$select = new Kwf_Component_Select($select);
} else {
$select = clone $select;
}
$ret = $this;
$idParts = $this->_getIdParts($componentId);
//Optimierung: wenn bereits ein parent der gesuchten komponente existiert, dieses direkt verwenden
//hilft vorallem wenn das parent deserialisiert wurde da in dem fall die weiteren parents nicht erstellt werden müssen
for($i=0; $i<count($idParts); ++$i) {
$id = implode('', array_slice($idParts, 0, count($idParts)-$i-1));
$found = false;
if (isset($this->_dataCache[$id])) {
$ret = $this->_dataCache[$id];
$found = true;
} else {
if (is_array($select)) {
if (isset($select[Kwf_Component_Select::IGNORE_VISIBLE])) {
$ignoreVisible = $select[Kwf_Component_Select::IGNORE_VISIBLE];
} else {
$ignoreVisible = false;
}
} else {
$ignoreVisible = $select->getPart(Kwf_Component_Select::IGNORE_VISIBLE);
}
if ($ignoreVisible && isset($this->_dataCacheIgnoreVisible[$id])) {
$ret = $this->_dataCacheIgnoreVisible[$id];
$found = true;
}
}
if ($found) {
$idParts = array_slice($idParts, count($idParts)-$i-1);
break;
}
}
foreach ($idParts as $i=>$idPart) {
if ($idPart == 'root') {
$ret = $this;
} else {
if ($i+1 == count($idParts)) {
//nur bei letzem part select berücksichtigen
$select->whereId($idPart);
$s = $select;
} else {
$s = array('id'=>$idPart);
if ($select->hasPart(Kwf_Component_Select::IGNORE_VISIBLE)) {
//ignoreVisible doch mitnehmen damit wir unterkomponeten von unsichtbaren
//komponenten finden
$s['ignoreVisible'] = $select->getPart(Kwf_Component_Select::IGNORE_VISIBLE);
}
if ($select->hasPart(Kwf_Component_Select::WHERE_SUBROOT)) {
//ignoreVisible doch mitnehmen damit wir unterkomponeten von unsichtbaren
//komponenten finden
$s['subroot'] = $select->getPart(Kwf_Component_Select::WHERE_SUBROOT);
}
$s = new Kwf_Component_Select($s);
}
if ($i == 0 && !$found) { // Muss eine Page sein
$ret = null;
$generators = $this->getPageGenerators();
foreach ($generators as $generator) {
$ret = $generator->getChildData(null, $s);
$ret = array_pop($ret);
if ($ret) break;
}
} else {
$ret = $ret->getChildComponent($s);
}
if (!$ret) break;
}
}
return $ret;
} | [
"public",
"function",
"getComponentById",
"(",
"$",
"componentId",
",",
"$",
"select",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"componentId",
")",
"return",
"null",
";",
"if",
"(",
"is_array",
"(",
"$",
"select",
")",
")",
"{",
"$",
"partTypes",
"=",
"array_keys",
"(",
"$",
"select",
")",
";",
"}",
"else",
"{",
"$",
"partTypes",
"=",
"$",
"select",
"->",
"getPartTypes",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"partTypes",
"||",
"$",
"partTypes",
"==",
"array",
"(",
"Kwf_Component_Select",
"::",
"IGNORE_VISIBLE",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_dataCache",
"[",
"$",
"componentId",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_dataCache",
"[",
"$",
"componentId",
"]",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"select",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"select",
"[",
"Kwf_Component_Select",
"::",
"IGNORE_VISIBLE",
"]",
")",
")",
"{",
"$",
"ignoreVisible",
"=",
"$",
"select",
"[",
"Kwf_Component_Select",
"::",
"IGNORE_VISIBLE",
"]",
";",
"}",
"else",
"{",
"$",
"ignoreVisible",
"=",
"false",
";",
"}",
"}",
"else",
"{",
"$",
"ignoreVisible",
"=",
"$",
"select",
"->",
"getPart",
"(",
"Kwf_Component_Select",
"::",
"IGNORE_VISIBLE",
")",
";",
"}",
"if",
"(",
"$",
"ignoreVisible",
"&&",
"isset",
"(",
"$",
"this",
"->",
"_dataCacheIgnoreVisible",
"[",
"$",
"componentId",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_dataCacheIgnoreVisible",
"[",
"$",
"componentId",
"]",
";",
"}",
"}",
"if",
"(",
"is_array",
"(",
"$",
"select",
")",
")",
"{",
"$",
"select",
"=",
"new",
"Kwf_Component_Select",
"(",
"$",
"select",
")",
";",
"}",
"else",
"{",
"$",
"select",
"=",
"clone",
"$",
"select",
";",
"}",
"$",
"ret",
"=",
"$",
"this",
";",
"$",
"idParts",
"=",
"$",
"this",
"->",
"_getIdParts",
"(",
"$",
"componentId",
")",
";",
"//Optimierung: wenn bereits ein parent der gesuchten komponente existiert, dieses direkt verwenden",
"//hilft vorallem wenn das parent deserialisiert wurde da in dem fall die weiteren parents nicht erstellt werden müssen",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"idParts",
")",
";",
"++",
"$",
"i",
")",
"{",
"$",
"id",
"=",
"implode",
"(",
"''",
",",
"array_slice",
"(",
"$",
"idParts",
",",
"0",
",",
"count",
"(",
"$",
"idParts",
")",
"-",
"$",
"i",
"-",
"1",
")",
")",
";",
"$",
"found",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_dataCache",
"[",
"$",
"id",
"]",
")",
")",
"{",
"$",
"ret",
"=",
"$",
"this",
"->",
"_dataCache",
"[",
"$",
"id",
"]",
";",
"$",
"found",
"=",
"true",
";",
"}",
"else",
"{",
"if",
"(",
"is_array",
"(",
"$",
"select",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"select",
"[",
"Kwf_Component_Select",
"::",
"IGNORE_VISIBLE",
"]",
")",
")",
"{",
"$",
"ignoreVisible",
"=",
"$",
"select",
"[",
"Kwf_Component_Select",
"::",
"IGNORE_VISIBLE",
"]",
";",
"}",
"else",
"{",
"$",
"ignoreVisible",
"=",
"false",
";",
"}",
"}",
"else",
"{",
"$",
"ignoreVisible",
"=",
"$",
"select",
"->",
"getPart",
"(",
"Kwf_Component_Select",
"::",
"IGNORE_VISIBLE",
")",
";",
"}",
"if",
"(",
"$",
"ignoreVisible",
"&&",
"isset",
"(",
"$",
"this",
"->",
"_dataCacheIgnoreVisible",
"[",
"$",
"id",
"]",
")",
")",
"{",
"$",
"ret",
"=",
"$",
"this",
"->",
"_dataCacheIgnoreVisible",
"[",
"$",
"id",
"]",
";",
"$",
"found",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"$",
"found",
")",
"{",
"$",
"idParts",
"=",
"array_slice",
"(",
"$",
"idParts",
",",
"count",
"(",
"$",
"idParts",
")",
"-",
"$",
"i",
"-",
"1",
")",
";",
"break",
";",
"}",
"}",
"foreach",
"(",
"$",
"idParts",
"as",
"$",
"i",
"=>",
"$",
"idPart",
")",
"{",
"if",
"(",
"$",
"idPart",
"==",
"'root'",
")",
"{",
"$",
"ret",
"=",
"$",
"this",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"i",
"+",
"1",
"==",
"count",
"(",
"$",
"idParts",
")",
")",
"{",
"//nur bei letzem part select berücksichtigen",
"$",
"select",
"->",
"whereId",
"(",
"$",
"idPart",
")",
";",
"$",
"s",
"=",
"$",
"select",
";",
"}",
"else",
"{",
"$",
"s",
"=",
"array",
"(",
"'id'",
"=>",
"$",
"idPart",
")",
";",
"if",
"(",
"$",
"select",
"->",
"hasPart",
"(",
"Kwf_Component_Select",
"::",
"IGNORE_VISIBLE",
")",
")",
"{",
"//ignoreVisible doch mitnehmen damit wir unterkomponeten von unsichtbaren",
"//komponenten finden",
"$",
"s",
"[",
"'ignoreVisible'",
"]",
"=",
"$",
"select",
"->",
"getPart",
"(",
"Kwf_Component_Select",
"::",
"IGNORE_VISIBLE",
")",
";",
"}",
"if",
"(",
"$",
"select",
"->",
"hasPart",
"(",
"Kwf_Component_Select",
"::",
"WHERE_SUBROOT",
")",
")",
"{",
"//ignoreVisible doch mitnehmen damit wir unterkomponeten von unsichtbaren",
"//komponenten finden",
"$",
"s",
"[",
"'subroot'",
"]",
"=",
"$",
"select",
"->",
"getPart",
"(",
"Kwf_Component_Select",
"::",
"WHERE_SUBROOT",
")",
";",
"}",
"$",
"s",
"=",
"new",
"Kwf_Component_Select",
"(",
"$",
"s",
")",
";",
"}",
"if",
"(",
"$",
"i",
"==",
"0",
"&&",
"!",
"$",
"found",
")",
"{",
"// Muss eine Page sein",
"$",
"ret",
"=",
"null",
";",
"$",
"generators",
"=",
"$",
"this",
"->",
"getPageGenerators",
"(",
")",
";",
"foreach",
"(",
"$",
"generators",
"as",
"$",
"generator",
")",
"{",
"$",
"ret",
"=",
"$",
"generator",
"->",
"getChildData",
"(",
"null",
",",
"$",
"s",
")",
";",
"$",
"ret",
"=",
"array_pop",
"(",
"$",
"ret",
")",
";",
"if",
"(",
"$",
"ret",
")",
"break",
";",
"}",
"}",
"else",
"{",
"$",
"ret",
"=",
"$",
"ret",
"->",
"getChildComponent",
"(",
"$",
"s",
")",
";",
"}",
"if",
"(",
"!",
"$",
"ret",
")",
"break",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] | Returns a component data by it's componentId
@param string componentId
@param array|Kwf_Component_Select additional contraint
@return Kwf_Component_Data | [
"Returns",
"a",
"component",
"data",
"by",
"it",
"s",
"componentId"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data/Root.php#L235-L335 |
koala-framework/koala-framework | Kwf/Component/Data/Root.php | Kwf_Component_Data_Root.getPageGenerators | public function getPageGenerators()
{
if (!is_null($this->_pageGenerators)) return $this->_pageGenerators;
$cacheId = $this->componentClass . '_pageGenerators';
$generators = Kwf_Cache_SimpleStatic::fetch($cacheId);
if (!$generators) {
$generators = array();
foreach (Kwc_Abstract::getComponentClasses() as $class) {
foreach (Kwc_Abstract::getSetting($class, 'generators') as $key => $generator) {
if (!isset($generator['class'])) {
throw new Kwf_Exception("no generator class set for generator '$key' in component '$class'");
}
if (is_instance_of($generator['class'], 'Kwc_Root_Category_Generator')) {
$generators[] = array('class' => $class, 'key' => $key, 'generator' => $generator);
}
}
}
Kwf_Cache_SimpleStatic::add($cacheId, $generators);
}
$this->_pageGenerators = array();
foreach ($generators as $g) {
$this->_pageGenerators[] = Kwf_Component_Generator_Abstract::getInstance(
$g['class'], $g['key'], $g['generator']
);
}
return $this->_pageGenerators;
} | php | public function getPageGenerators()
{
if (!is_null($this->_pageGenerators)) return $this->_pageGenerators;
$cacheId = $this->componentClass . '_pageGenerators';
$generators = Kwf_Cache_SimpleStatic::fetch($cacheId);
if (!$generators) {
$generators = array();
foreach (Kwc_Abstract::getComponentClasses() as $class) {
foreach (Kwc_Abstract::getSetting($class, 'generators') as $key => $generator) {
if (!isset($generator['class'])) {
throw new Kwf_Exception("no generator class set for generator '$key' in component '$class'");
}
if (is_instance_of($generator['class'], 'Kwc_Root_Category_Generator')) {
$generators[] = array('class' => $class, 'key' => $key, 'generator' => $generator);
}
}
}
Kwf_Cache_SimpleStatic::add($cacheId, $generators);
}
$this->_pageGenerators = array();
foreach ($generators as $g) {
$this->_pageGenerators[] = Kwf_Component_Generator_Abstract::getInstance(
$g['class'], $g['key'], $g['generator']
);
}
return $this->_pageGenerators;
} | [
"public",
"function",
"getPageGenerators",
"(",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"_pageGenerators",
")",
")",
"return",
"$",
"this",
"->",
"_pageGenerators",
";",
"$",
"cacheId",
"=",
"$",
"this",
"->",
"componentClass",
".",
"'_pageGenerators'",
";",
"$",
"generators",
"=",
"Kwf_Cache_SimpleStatic",
"::",
"fetch",
"(",
"$",
"cacheId",
")",
";",
"if",
"(",
"!",
"$",
"generators",
")",
"{",
"$",
"generators",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"Kwc_Abstract",
"::",
"getComponentClasses",
"(",
")",
"as",
"$",
"class",
")",
"{",
"foreach",
"(",
"Kwc_Abstract",
"::",
"getSetting",
"(",
"$",
"class",
",",
"'generators'",
")",
"as",
"$",
"key",
"=>",
"$",
"generator",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"generator",
"[",
"'class'",
"]",
")",
")",
"{",
"throw",
"new",
"Kwf_Exception",
"(",
"\"no generator class set for generator '$key' in component '$class'\"",
")",
";",
"}",
"if",
"(",
"is_instance_of",
"(",
"$",
"generator",
"[",
"'class'",
"]",
",",
"'Kwc_Root_Category_Generator'",
")",
")",
"{",
"$",
"generators",
"[",
"]",
"=",
"array",
"(",
"'class'",
"=>",
"$",
"class",
",",
"'key'",
"=>",
"$",
"key",
",",
"'generator'",
"=>",
"$",
"generator",
")",
";",
"}",
"}",
"}",
"Kwf_Cache_SimpleStatic",
"::",
"add",
"(",
"$",
"cacheId",
",",
"$",
"generators",
")",
";",
"}",
"$",
"this",
"->",
"_pageGenerators",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"generators",
"as",
"$",
"g",
")",
"{",
"$",
"this",
"->",
"_pageGenerators",
"[",
"]",
"=",
"Kwf_Component_Generator_Abstract",
"::",
"getInstance",
"(",
"$",
"g",
"[",
"'class'",
"]",
",",
"$",
"g",
"[",
"'key'",
"]",
",",
"$",
"g",
"[",
"'generator'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_pageGenerators",
";",
"}"
] | Returns all Kwc_Root_Category_Generators used.
the name of this method is a bit missleading
@return Kwc_Root_Category_Generator[] | [
"Returns",
"all",
"Kwc_Root_Category_Generators",
"used",
"."
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data/Root.php#L344-L373 |
koala-framework/koala-framework | Kwf/Component/Data/Root.php | Kwf_Component_Data_Root.getComponentByDbId | public function getComponentByDbId($dbId, $select = array())
{
$components = $this->getComponentsByDbId($dbId, $select);
$this->_checkSingleComponent($components);
if (isset($components[0])) {
return $components[0];
}
return null;
} | php | public function getComponentByDbId($dbId, $select = array())
{
$components = $this->getComponentsByDbId($dbId, $select);
$this->_checkSingleComponent($components);
if (isset($components[0])) {
return $components[0];
}
return null;
} | [
"public",
"function",
"getComponentByDbId",
"(",
"$",
"dbId",
",",
"$",
"select",
"=",
"array",
"(",
")",
")",
"{",
"$",
"components",
"=",
"$",
"this",
"->",
"getComponentsByDbId",
"(",
"$",
"dbId",
",",
"$",
"select",
")",
";",
"$",
"this",
"->",
"_checkSingleComponent",
"(",
"$",
"components",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"components",
"[",
"0",
"]",
")",
")",
"{",
"return",
"$",
"components",
"[",
"0",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Searches for a component data by it's dbId
As multiple can have the same dbId you will get an exception if mutiple are found.
To avoid that pass 'limit'=>1 as select
@param string
@param array|Kwf_Component_Select
@return Kwf_Component_Data | [
"Searches",
"for",
"a",
"component",
"data",
"by",
"it",
"s",
"dbId"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data/Root.php#L403-L411 |
koala-framework/koala-framework | Kwf/Component/Data/Root.php | Kwf_Component_Data_Root.getComponentsByDbId | public function getComponentsByDbId($dbId, $select = array())
{
if (is_array($select)) {
$select = new Kwf_Component_Select($select);
}
$cacheId = $dbId.$select->getHash();
if (!isset($this->_componentsByDbIdCache[$cacheId])) {
if (is_numeric(substr($dbId, 0, 1)) || substr($dbId, 0, 4)=='root') {
$data = $this->getComponentById($dbId, $select);
if ($data) {
return array($data);
} else {
return array();
}
}
if ($select->hasPart(Kwf_Component_Select::LIMIT_COUNT)) {
$limitCount = $select->getPart(Kwf_Component_Select::LIMIT_COUNT);
}
$ret = array();
foreach (Kwc_Abstract::getComponentClasses() as $class) {
foreach (Kwc_Abstract::getSetting($class, 'generators') as $key => $generator) {
if (isset($generator['dbIdShortcut'])
&& substr($dbId, 0, strlen($generator['dbIdShortcut'])) == $generator['dbIdShortcut']) {
$idParts = $this->_getIdParts(substr($dbId, strlen($generator['dbIdShortcut']) - 1));
$generator = Kwf_Component_Generator_Abstract::getInstance($class, $key);
if (count($idParts) <= 1) {
$generatorSelect = clone $select;
} else {
$generatorSelect = new Kwf_Component_Select(); // Select erst bei letzten Part
if ($select->hasPart(Kwf_Component_Select::IGNORE_VISIBLE)) {
$generatorSelect->ignoreVisible($select->getPart(Kwf_Component_Select::IGNORE_VISIBLE));
}
if ($select->hasPart(Kwf_Component_Select::WHERE_SUBROOT)) {
$generatorSelect->whereSubroot($select->getPart(Kwf_Component_Select::WHERE_SUBROOT));
}
}
if (isset($limitCount)) {
$generatorSelect->limit($limitCount - count($ret));
}
$generatorSelect->whereId($idParts[0]);
$data = $generator->getChildData(null, $generatorSelect);
unset($idParts[0]);
foreach ($data as $d) {
$componentId = $d->componentId . implode('', $idParts);
$data = $this->getComponentById($componentId, $select);
if ($data) {
$ret[] = $data;
}
if (isset($limitCount) && $limitCount - count($ret) <= 0) {
break 3;
}
}
}
}
}
$this->_componentsByDbIdCache[$cacheId] = $ret;
}
return $this->_componentsByDbIdCache[$cacheId];
} | php | public function getComponentsByDbId($dbId, $select = array())
{
if (is_array($select)) {
$select = new Kwf_Component_Select($select);
}
$cacheId = $dbId.$select->getHash();
if (!isset($this->_componentsByDbIdCache[$cacheId])) {
if (is_numeric(substr($dbId, 0, 1)) || substr($dbId, 0, 4)=='root') {
$data = $this->getComponentById($dbId, $select);
if ($data) {
return array($data);
} else {
return array();
}
}
if ($select->hasPart(Kwf_Component_Select::LIMIT_COUNT)) {
$limitCount = $select->getPart(Kwf_Component_Select::LIMIT_COUNT);
}
$ret = array();
foreach (Kwc_Abstract::getComponentClasses() as $class) {
foreach (Kwc_Abstract::getSetting($class, 'generators') as $key => $generator) {
if (isset($generator['dbIdShortcut'])
&& substr($dbId, 0, strlen($generator['dbIdShortcut'])) == $generator['dbIdShortcut']) {
$idParts = $this->_getIdParts(substr($dbId, strlen($generator['dbIdShortcut']) - 1));
$generator = Kwf_Component_Generator_Abstract::getInstance($class, $key);
if (count($idParts) <= 1) {
$generatorSelect = clone $select;
} else {
$generatorSelect = new Kwf_Component_Select(); // Select erst bei letzten Part
if ($select->hasPart(Kwf_Component_Select::IGNORE_VISIBLE)) {
$generatorSelect->ignoreVisible($select->getPart(Kwf_Component_Select::IGNORE_VISIBLE));
}
if ($select->hasPart(Kwf_Component_Select::WHERE_SUBROOT)) {
$generatorSelect->whereSubroot($select->getPart(Kwf_Component_Select::WHERE_SUBROOT));
}
}
if (isset($limitCount)) {
$generatorSelect->limit($limitCount - count($ret));
}
$generatorSelect->whereId($idParts[0]);
$data = $generator->getChildData(null, $generatorSelect);
unset($idParts[0]);
foreach ($data as $d) {
$componentId = $d->componentId . implode('', $idParts);
$data = $this->getComponentById($componentId, $select);
if ($data) {
$ret[] = $data;
}
if (isset($limitCount) && $limitCount - count($ret) <= 0) {
break 3;
}
}
}
}
}
$this->_componentsByDbIdCache[$cacheId] = $ret;
}
return $this->_componentsByDbIdCache[$cacheId];
} | [
"public",
"function",
"getComponentsByDbId",
"(",
"$",
"dbId",
",",
"$",
"select",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"select",
")",
")",
"{",
"$",
"select",
"=",
"new",
"Kwf_Component_Select",
"(",
"$",
"select",
")",
";",
"}",
"$",
"cacheId",
"=",
"$",
"dbId",
".",
"$",
"select",
"->",
"getHash",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_componentsByDbIdCache",
"[",
"$",
"cacheId",
"]",
")",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"substr",
"(",
"$",
"dbId",
",",
"0",
",",
"1",
")",
")",
"||",
"substr",
"(",
"$",
"dbId",
",",
"0",
",",
"4",
")",
"==",
"'root'",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getComponentById",
"(",
"$",
"dbId",
",",
"$",
"select",
")",
";",
"if",
"(",
"$",
"data",
")",
"{",
"return",
"array",
"(",
"$",
"data",
")",
";",
"}",
"else",
"{",
"return",
"array",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"select",
"->",
"hasPart",
"(",
"Kwf_Component_Select",
"::",
"LIMIT_COUNT",
")",
")",
"{",
"$",
"limitCount",
"=",
"$",
"select",
"->",
"getPart",
"(",
"Kwf_Component_Select",
"::",
"LIMIT_COUNT",
")",
";",
"}",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"Kwc_Abstract",
"::",
"getComponentClasses",
"(",
")",
"as",
"$",
"class",
")",
"{",
"foreach",
"(",
"Kwc_Abstract",
"::",
"getSetting",
"(",
"$",
"class",
",",
"'generators'",
")",
"as",
"$",
"key",
"=>",
"$",
"generator",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"generator",
"[",
"'dbIdShortcut'",
"]",
")",
"&&",
"substr",
"(",
"$",
"dbId",
",",
"0",
",",
"strlen",
"(",
"$",
"generator",
"[",
"'dbIdShortcut'",
"]",
")",
")",
"==",
"$",
"generator",
"[",
"'dbIdShortcut'",
"]",
")",
"{",
"$",
"idParts",
"=",
"$",
"this",
"->",
"_getIdParts",
"(",
"substr",
"(",
"$",
"dbId",
",",
"strlen",
"(",
"$",
"generator",
"[",
"'dbIdShortcut'",
"]",
")",
"-",
"1",
")",
")",
";",
"$",
"generator",
"=",
"Kwf_Component_Generator_Abstract",
"::",
"getInstance",
"(",
"$",
"class",
",",
"$",
"key",
")",
";",
"if",
"(",
"count",
"(",
"$",
"idParts",
")",
"<=",
"1",
")",
"{",
"$",
"generatorSelect",
"=",
"clone",
"$",
"select",
";",
"}",
"else",
"{",
"$",
"generatorSelect",
"=",
"new",
"Kwf_Component_Select",
"(",
")",
";",
"// Select erst bei letzten Part",
"if",
"(",
"$",
"select",
"->",
"hasPart",
"(",
"Kwf_Component_Select",
"::",
"IGNORE_VISIBLE",
")",
")",
"{",
"$",
"generatorSelect",
"->",
"ignoreVisible",
"(",
"$",
"select",
"->",
"getPart",
"(",
"Kwf_Component_Select",
"::",
"IGNORE_VISIBLE",
")",
")",
";",
"}",
"if",
"(",
"$",
"select",
"->",
"hasPart",
"(",
"Kwf_Component_Select",
"::",
"WHERE_SUBROOT",
")",
")",
"{",
"$",
"generatorSelect",
"->",
"whereSubroot",
"(",
"$",
"select",
"->",
"getPart",
"(",
"Kwf_Component_Select",
"::",
"WHERE_SUBROOT",
")",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"limitCount",
")",
")",
"{",
"$",
"generatorSelect",
"->",
"limit",
"(",
"$",
"limitCount",
"-",
"count",
"(",
"$",
"ret",
")",
")",
";",
"}",
"$",
"generatorSelect",
"->",
"whereId",
"(",
"$",
"idParts",
"[",
"0",
"]",
")",
";",
"$",
"data",
"=",
"$",
"generator",
"->",
"getChildData",
"(",
"null",
",",
"$",
"generatorSelect",
")",
";",
"unset",
"(",
"$",
"idParts",
"[",
"0",
"]",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"d",
")",
"{",
"$",
"componentId",
"=",
"$",
"d",
"->",
"componentId",
".",
"implode",
"(",
"''",
",",
"$",
"idParts",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"getComponentById",
"(",
"$",
"componentId",
",",
"$",
"select",
")",
";",
"if",
"(",
"$",
"data",
")",
"{",
"$",
"ret",
"[",
"]",
"=",
"$",
"data",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"limitCount",
")",
"&&",
"$",
"limitCount",
"-",
"count",
"(",
"$",
"ret",
")",
"<=",
"0",
")",
"{",
"break",
"3",
";",
"}",
"}",
"}",
"}",
"}",
"$",
"this",
"->",
"_componentsByDbIdCache",
"[",
"$",
"cacheId",
"]",
"=",
"$",
"ret",
";",
"}",
"return",
"$",
"this",
"->",
"_componentsByDbIdCache",
"[",
"$",
"cacheId",
"]",
";",
"}"
] | Searches for component datas by it's dbId
@param string
@param array|Kwf_Component_Select
@return Kwf_Component_Data[] | [
"Searches",
"for",
"component",
"datas",
"by",
"it",
"s",
"dbId"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data/Root.php#L420-L481 |
koala-framework/koala-framework | Kwf/Component/Data/Root.php | Kwf_Component_Data_Root.getComponentsByClass | public function getComponentsByClass($class, $select = array())
{
if (is_array($select)) {
$select = new Kwf_Component_Select($select);
}
$cacheId = (is_array($class) ? implode(',', $class) : $class).$select->getHash();
if (!isset($this->_componentsByClassCache[$cacheId])) {
$lookingForChildClasses = Kwc_Abstract::getComponentClassesByParentClass($class);
$ret = $this->getComponentsBySameClass($lookingForChildClasses, $select);
$this->_componentsByClassCache[$cacheId] = $ret;
}
return $this->_componentsByClassCache[$cacheId];
} | php | public function getComponentsByClass($class, $select = array())
{
if (is_array($select)) {
$select = new Kwf_Component_Select($select);
}
$cacheId = (is_array($class) ? implode(',', $class) : $class).$select->getHash();
if (!isset($this->_componentsByClassCache[$cacheId])) {
$lookingForChildClasses = Kwc_Abstract::getComponentClassesByParentClass($class);
$ret = $this->getComponentsBySameClass($lookingForChildClasses, $select);
$this->_componentsByClassCache[$cacheId] = $ret;
}
return $this->_componentsByClassCache[$cacheId];
} | [
"public",
"function",
"getComponentsByClass",
"(",
"$",
"class",
",",
"$",
"select",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"select",
")",
")",
"{",
"$",
"select",
"=",
"new",
"Kwf_Component_Select",
"(",
"$",
"select",
")",
";",
"}",
"$",
"cacheId",
"=",
"(",
"is_array",
"(",
"$",
"class",
")",
"?",
"implode",
"(",
"','",
",",
"$",
"class",
")",
":",
"$",
"class",
")",
".",
"$",
"select",
"->",
"getHash",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_componentsByClassCache",
"[",
"$",
"cacheId",
"]",
")",
")",
"{",
"$",
"lookingForChildClasses",
"=",
"Kwc_Abstract",
"::",
"getComponentClassesByParentClass",
"(",
"$",
"class",
")",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"getComponentsBySameClass",
"(",
"$",
"lookingForChildClasses",
",",
"$",
"select",
")",
";",
"$",
"this",
"->",
"_componentsByClassCache",
"[",
"$",
"cacheId",
"]",
"=",
"$",
"ret",
";",
"}",
"return",
"$",
"this",
"->",
"_componentsByClassCache",
"[",
"$",
"cacheId",
"]",
";",
"}"
] | Returns all components matching a component class (including classes inheriting that class)
Use with care, this is only efficient if a few components exist.
@see getComponentsBySameClass
@param string|array component class
@param array|Kwf_Component_Select
@return Kwf_Component_Data[] | [
"Returns",
"all",
"components",
"matching",
"a",
"component",
"class",
"(",
"including",
"classes",
"inheriting",
"that",
"class",
")"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data/Root.php#L493-L507 |
koala-framework/koala-framework | Kwf/Component/Data/Root.php | Kwf_Component_Data_Root.getComponentsBySameClass | public function getComponentsBySameClass($lookingForChildClasses, $select = array())
{
$ret = array();
if (!is_array($lookingForChildClasses)) {
$lookingForChildClasses = array($lookingForChildClasses);
}
foreach ($lookingForChildClasses as $c) {
if ($c == $this->componentClass) {
$ret[] = $this;
if (isset($limitCount) && $limitCount == 1) {
return $ret;
}
}
}
if (is_array($select)) {
$select = new Kwf_Component_Select($select);
} else {
$select = clone $select;
}
$select->whereComponentClasses($lookingForChildClasses);
if ($select->hasPart(Kwf_Component_Select::LIMIT_COUNT)) {
$limitCount = $select->getPart(Kwf_Component_Select::LIMIT_COUNT);
}
foreach ($this->_getGeneratorsForClasses($lookingForChildClasses) as $generator) {
foreach ($generator->getChildData(null, $select) as $data) {
$ret[] = $data;
if (isset($limitCount) && $limitCount - count($ret) <= 0) {
return $ret;
}
}
}
return $ret;
} | php | public function getComponentsBySameClass($lookingForChildClasses, $select = array())
{
$ret = array();
if (!is_array($lookingForChildClasses)) {
$lookingForChildClasses = array($lookingForChildClasses);
}
foreach ($lookingForChildClasses as $c) {
if ($c == $this->componentClass) {
$ret[] = $this;
if (isset($limitCount) && $limitCount == 1) {
return $ret;
}
}
}
if (is_array($select)) {
$select = new Kwf_Component_Select($select);
} else {
$select = clone $select;
}
$select->whereComponentClasses($lookingForChildClasses);
if ($select->hasPart(Kwf_Component_Select::LIMIT_COUNT)) {
$limitCount = $select->getPart(Kwf_Component_Select::LIMIT_COUNT);
}
foreach ($this->_getGeneratorsForClasses($lookingForChildClasses) as $generator) {
foreach ($generator->getChildData(null, $select) as $data) {
$ret[] = $data;
if (isset($limitCount) && $limitCount - count($ret) <= 0) {
return $ret;
}
}
}
return $ret;
} | [
"public",
"function",
"getComponentsBySameClass",
"(",
"$",
"lookingForChildClasses",
",",
"$",
"select",
"=",
"array",
"(",
")",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"lookingForChildClasses",
")",
")",
"{",
"$",
"lookingForChildClasses",
"=",
"array",
"(",
"$",
"lookingForChildClasses",
")",
";",
"}",
"foreach",
"(",
"$",
"lookingForChildClasses",
"as",
"$",
"c",
")",
"{",
"if",
"(",
"$",
"c",
"==",
"$",
"this",
"->",
"componentClass",
")",
"{",
"$",
"ret",
"[",
"]",
"=",
"$",
"this",
";",
"if",
"(",
"isset",
"(",
"$",
"limitCount",
")",
"&&",
"$",
"limitCount",
"==",
"1",
")",
"{",
"return",
"$",
"ret",
";",
"}",
"}",
"}",
"if",
"(",
"is_array",
"(",
"$",
"select",
")",
")",
"{",
"$",
"select",
"=",
"new",
"Kwf_Component_Select",
"(",
"$",
"select",
")",
";",
"}",
"else",
"{",
"$",
"select",
"=",
"clone",
"$",
"select",
";",
"}",
"$",
"select",
"->",
"whereComponentClasses",
"(",
"$",
"lookingForChildClasses",
")",
";",
"if",
"(",
"$",
"select",
"->",
"hasPart",
"(",
"Kwf_Component_Select",
"::",
"LIMIT_COUNT",
")",
")",
"{",
"$",
"limitCount",
"=",
"$",
"select",
"->",
"getPart",
"(",
"Kwf_Component_Select",
"::",
"LIMIT_COUNT",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"_getGeneratorsForClasses",
"(",
"$",
"lookingForChildClasses",
")",
"as",
"$",
"generator",
")",
"{",
"foreach",
"(",
"$",
"generator",
"->",
"getChildData",
"(",
"null",
",",
"$",
"select",
")",
"as",
"$",
"data",
")",
"{",
"$",
"ret",
"[",
"]",
"=",
"$",
"data",
";",
"if",
"(",
"isset",
"(",
"$",
"limitCount",
")",
"&&",
"$",
"limitCount",
"-",
"count",
"(",
"$",
"ret",
")",
"<=",
"0",
")",
"{",
"return",
"$",
"ret",
";",
"}",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] | Returns all components exactly matching a component class
Use with care, this is only efficient if a few components exist.
@see getComponentsByClass
@param string|array component class
@param array|Kwf_Component_Select
@return Kwf_Component_Data[] | [
"Returns",
"all",
"components",
"exactly",
"matching",
"a",
"component",
"class"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data/Root.php#L519-L555 |
koala-framework/koala-framework | Kwf/Component/Data/Root.php | Kwf_Component_Data_Root.getComponentByClass | public function getComponentByClass($class, $select = array())
{
$components = $this->getComponentsByClass($class, $select);
$this->_checkSingleComponent($components);
if (isset($components[0])) {
return $components[0];
}
return null;
} | php | public function getComponentByClass($class, $select = array())
{
$components = $this->getComponentsByClass($class, $select);
$this->_checkSingleComponent($components);
if (isset($components[0])) {
return $components[0];
}
return null;
} | [
"public",
"function",
"getComponentByClass",
"(",
"$",
"class",
",",
"$",
"select",
"=",
"array",
"(",
")",
")",
"{",
"$",
"components",
"=",
"$",
"this",
"->",
"getComponentsByClass",
"(",
"$",
"class",
",",
"$",
"select",
")",
";",
"$",
"this",
"->",
"_checkSingleComponent",
"(",
"$",
"components",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"components",
"[",
"0",
"]",
")",
")",
"{",
"return",
"$",
"components",
"[",
"0",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Returns component by given component class
If multiple are found you will get an exception,
To avoid that pass 'limit'=>1 as select
@see getComponentsByClass
@param string component class
@param array|Kwf_Component_Select
@return Kwf_Component_Data | [
"Returns",
"component",
"by",
"given",
"component",
"class"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data/Root.php#L601-L609 |
koala-framework/koala-framework | Kwf/Component/Data/Root.php | Kwf_Component_Data_Root.getComponentBySameClass | public function getComponentBySameClass($class, $select = array())
{
$components = $this->getComponentsBySameClass($class, $select);
$this->_checkSingleComponent($components);
if (isset($components[0])) {
return $components[0];
}
return null;
} | php | public function getComponentBySameClass($class, $select = array())
{
$components = $this->getComponentsBySameClass($class, $select);
$this->_checkSingleComponent($components);
if (isset($components[0])) {
return $components[0];
}
return null;
} | [
"public",
"function",
"getComponentBySameClass",
"(",
"$",
"class",
",",
"$",
"select",
"=",
"array",
"(",
")",
")",
"{",
"$",
"components",
"=",
"$",
"this",
"->",
"getComponentsBySameClass",
"(",
"$",
"class",
",",
"$",
"select",
")",
";",
"$",
"this",
"->",
"_checkSingleComponent",
"(",
"$",
"components",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"components",
"[",
"0",
"]",
")",
")",
"{",
"return",
"$",
"components",
"[",
"0",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Returns component by given component class
If multiple are found you will get an exception,
To avoid that pass 'limit'=>1 as select
@see getComponentsBySameClass
@param string component class
@param array|Kwf_Component_Select
@return Kwf_Component_Data | [
"Returns",
"component",
"by",
"given",
"component",
"class"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data/Root.php#L622-L630 |
koala-framework/koala-framework | Kwf/Component/Data/Root.php | Kwf_Component_Data_Root.addToDataCache | public function addToDataCache(Kwf_Component_Data $d, $ignoreVisible)
{
if ($ignoreVisible) {
$this->_dataCacheIgnoreVisible[$d->componentId] = $d;
} else {
$this->_dataCache[$d->componentId] = $d;
}
} | php | public function addToDataCache(Kwf_Component_Data $d, $ignoreVisible)
{
if ($ignoreVisible) {
$this->_dataCacheIgnoreVisible[$d->componentId] = $d;
} else {
$this->_dataCache[$d->componentId] = $d;
}
} | [
"public",
"function",
"addToDataCache",
"(",
"Kwf_Component_Data",
"$",
"d",
",",
"$",
"ignoreVisible",
")",
"{",
"if",
"(",
"$",
"ignoreVisible",
")",
"{",
"$",
"this",
"->",
"_dataCacheIgnoreVisible",
"[",
"$",
"d",
"->",
"componentId",
"]",
"=",
"$",
"d",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_dataCache",
"[",
"$",
"d",
"->",
"componentId",
"]",
"=",
"$",
"d",
";",
"}",
"}"
] | @internal siehe Kwf_Component_Generator_Abstract
für getComponentById | [
"@internal",
"siehe",
"Kwf_Component_Generator_Abstract"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data/Root.php#L677-L684 |
koala-framework/koala-framework | Kwf/Component/Data/Root.php | Kwf_Component_Data_Root.getFromDataCache | public function getFromDataCache($id)
{
if (isset($this->_dataCache[$id])) {
return $this->_dataCache[$id];
} else if (isset($this->_dataCacheIgnoreVisible[$id])) {
return $this->_dataCacheIgnoreVisible[$id];
}
return null;
} | php | public function getFromDataCache($id)
{
if (isset($this->_dataCache[$id])) {
return $this->_dataCache[$id];
} else if (isset($this->_dataCacheIgnoreVisible[$id])) {
return $this->_dataCacheIgnoreVisible[$id];
}
return null;
} | [
"public",
"function",
"getFromDataCache",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_dataCache",
"[",
"$",
"id",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_dataCache",
"[",
"$",
"id",
"]",
";",
"}",
"else",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_dataCacheIgnoreVisible",
"[",
"$",
"id",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_dataCacheIgnoreVisible",
"[",
"$",
"id",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | @internal siehe Kwf_Component_Generator_Abstract
für Component_Data::kwfUnserialize | [
"@internal",
"siehe",
"Kwf_Component_Generator_Abstract"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data/Root.php#L691-L699 |
koala-framework/koala-framework | Kwf/Component/PagesMetaModel.php | Kwf_Component_PagesMetaModel.indexRecursive | public function indexRecursive(Kwf_Component_Data $page)
{
if ($page->isPage) {
$r = $this->getRow($page->componentId);
if (!$r) {
$r = $this->createRow();
$r->changed_date = date('Y-m-d H:i:s');
}
$r->updateFromPage($page);
$r->save();
}
$childPages = $page->getChildPseudoPages(
array('pageGenerator' => false),
array('pseudoPage'=>false, 'unique'=>false) //don't recurse into unique boxes, causes endless recursion if box creates page
);
$childPages = array_merge($childPages, $page->getChildPseudoPages(
array('pageGenerator' => true),
array('pseudoPage'=>false)
));
$ret = array();
foreach ($childPages as $p) {
$this->indexRecursive($p);
}
} | php | public function indexRecursive(Kwf_Component_Data $page)
{
if ($page->isPage) {
$r = $this->getRow($page->componentId);
if (!$r) {
$r = $this->createRow();
$r->changed_date = date('Y-m-d H:i:s');
}
$r->updateFromPage($page);
$r->save();
}
$childPages = $page->getChildPseudoPages(
array('pageGenerator' => false),
array('pseudoPage'=>false, 'unique'=>false) //don't recurse into unique boxes, causes endless recursion if box creates page
);
$childPages = array_merge($childPages, $page->getChildPseudoPages(
array('pageGenerator' => true),
array('pseudoPage'=>false)
));
$ret = array();
foreach ($childPages as $p) {
$this->indexRecursive($p);
}
} | [
"public",
"function",
"indexRecursive",
"(",
"Kwf_Component_Data",
"$",
"page",
")",
"{",
"if",
"(",
"$",
"page",
"->",
"isPage",
")",
"{",
"$",
"r",
"=",
"$",
"this",
"->",
"getRow",
"(",
"$",
"page",
"->",
"componentId",
")",
";",
"if",
"(",
"!",
"$",
"r",
")",
"{",
"$",
"r",
"=",
"$",
"this",
"->",
"createRow",
"(",
")",
";",
"$",
"r",
"->",
"changed_date",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
")",
";",
"}",
"$",
"r",
"->",
"updateFromPage",
"(",
"$",
"page",
")",
";",
"$",
"r",
"->",
"save",
"(",
")",
";",
"}",
"$",
"childPages",
"=",
"$",
"page",
"->",
"getChildPseudoPages",
"(",
"array",
"(",
"'pageGenerator'",
"=>",
"false",
")",
",",
"array",
"(",
"'pseudoPage'",
"=>",
"false",
",",
"'unique'",
"=>",
"false",
")",
"//don't recurse into unique boxes, causes endless recursion if box creates page",
")",
";",
"$",
"childPages",
"=",
"array_merge",
"(",
"$",
"childPages",
",",
"$",
"page",
"->",
"getChildPseudoPages",
"(",
"array",
"(",
"'pageGenerator'",
"=>",
"true",
")",
",",
"array",
"(",
"'pseudoPage'",
"=>",
"false",
")",
")",
")",
";",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"childPages",
"as",
"$",
"p",
")",
"{",
"$",
"this",
"->",
"indexRecursive",
"(",
"$",
"p",
")",
";",
"}",
"}"
] | in web ComponentPagesMetaController is used | [
"in",
"web",
"ComponentPagesMetaController",
"is",
"used"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/PagesMetaModel.php#L34-L58 |
koala-framework/koala-framework | Kwf/Form/Field/Select.php | Kwf_Form_Field_Select._addValidators | protected function _addValidators()
{
parent::_addValidators();
//if hideIfNoValues and there are no values remove empty validator
if ($this->getHideIfNoValues() && isset($this->_validators['notEmpty'])) {
$store = $this->_getStoreData();
if (!$store['data']) {
unset($this->_validators['notEmpty']);
}
}
} | php | protected function _addValidators()
{
parent::_addValidators();
//if hideIfNoValues and there are no values remove empty validator
if ($this->getHideIfNoValues() && isset($this->_validators['notEmpty'])) {
$store = $this->_getStoreData();
if (!$store['data']) {
unset($this->_validators['notEmpty']);
}
}
} | [
"protected",
"function",
"_addValidators",
"(",
")",
"{",
"parent",
"::",
"_addValidators",
"(",
")",
";",
"//if hideIfNoValues and there are no values remove empty validator",
"if",
"(",
"$",
"this",
"->",
"getHideIfNoValues",
"(",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"_validators",
"[",
"'notEmpty'",
"]",
")",
")",
"{",
"$",
"store",
"=",
"$",
"this",
"->",
"_getStoreData",
"(",
")",
";",
"if",
"(",
"!",
"$",
"store",
"[",
"'data'",
"]",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_validators",
"[",
"'notEmpty'",
"]",
")",
";",
"}",
"}",
"}"
] | setHideIfNoValues | [
"setHideIfNoValues"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Form/Field/Select.php#L21-L32 |
koala-framework/koala-framework | Kwf/Db/Table/Row.php | Kwf_Db_Table_Row.delete | public function delete()
{
$where = $this->_getWhereQuery();
/**
* Execute the DELETE (this may throw an exception)
*/
$result = $this->_getTable()->delete($where);
/**
* Reset all fields to null to indicate that the row is not there
*/
$this->_data = array_combine(
array_keys($this->_data),
array_fill(0, count($this->_data), null)
);
return $result;
} | php | public function delete()
{
$where = $this->_getWhereQuery();
/**
* Execute the DELETE (this may throw an exception)
*/
$result = $this->_getTable()->delete($where);
/**
* Reset all fields to null to indicate that the row is not there
*/
$this->_data = array_combine(
array_keys($this->_data),
array_fill(0, count($this->_data), null)
);
return $result;
} | [
"public",
"function",
"delete",
"(",
")",
"{",
"$",
"where",
"=",
"$",
"this",
"->",
"_getWhereQuery",
"(",
")",
";",
"/**\n * Execute the DELETE (this may throw an exception)\n */",
"$",
"result",
"=",
"$",
"this",
"->",
"_getTable",
"(",
")",
"->",
"delete",
"(",
"$",
"where",
")",
";",
"/**\n * Reset all fields to null to indicate that the row is not there\n */",
"$",
"this",
"->",
"_data",
"=",
"array_combine",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"_data",
")",
",",
"array_fill",
"(",
"0",
",",
"count",
"(",
"$",
"this",
"->",
"_data",
")",
",",
"null",
")",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Deletes existing rows.
@return int The number of rows deleted. | [
"Deletes",
"existing",
"rows",
"."
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Db/Table/Row.php#L331-L349 |
koala-framework/koala-framework | Kwf/Db/Table/Row.php | Kwf_Db_Table_Row._getPrimaryKeyValues | protected function _getPrimaryKeyValues($useDirty = true)
{
$primary = array_flip($this->_table->getPrimaryKey());
if ($useDirty) {
$array = array_intersect_key($this->_data, $primary);
} else {
$array = array_intersect_key($this->_cleanData, $primary);
}
if (count($primary) != count($array)) {
throw new Kwf_Exception("The specified Table does not have the same primary key as the Row");
}
return $array;
} | php | protected function _getPrimaryKeyValues($useDirty = true)
{
$primary = array_flip($this->_table->getPrimaryKey());
if ($useDirty) {
$array = array_intersect_key($this->_data, $primary);
} else {
$array = array_intersect_key($this->_cleanData, $primary);
}
if (count($primary) != count($array)) {
throw new Kwf_Exception("The specified Table does not have the same primary key as the Row");
}
return $array;
} | [
"protected",
"function",
"_getPrimaryKeyValues",
"(",
"$",
"useDirty",
"=",
"true",
")",
"{",
"$",
"primary",
"=",
"array_flip",
"(",
"$",
"this",
"->",
"_table",
"->",
"getPrimaryKey",
"(",
")",
")",
";",
"if",
"(",
"$",
"useDirty",
")",
"{",
"$",
"array",
"=",
"array_intersect_key",
"(",
"$",
"this",
"->",
"_data",
",",
"$",
"primary",
")",
";",
"}",
"else",
"{",
"$",
"array",
"=",
"array_intersect_key",
"(",
"$",
"this",
"->",
"_cleanData",
",",
"$",
"primary",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"primary",
")",
"!=",
"count",
"(",
"$",
"array",
")",
")",
"{",
"throw",
"new",
"Kwf_Exception",
"(",
"\"The specified Table does not have the same primary key as the Row\"",
")",
";",
"}",
"return",
"$",
"array",
";",
"}"
] | Retrieves an associative array of primary keys.
@param bool $useDirty
@return array | [
"Retrieves",
"an",
"associative",
"array",
"of",
"primary",
"keys",
"."
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Db/Table/Row.php#L387-L399 |
koala-framework/koala-framework | Kwf/Db/Table/Row.php | Kwf_Db_Table_Row._getWhereQuery | protected function _getWhereQuery($useDirty = true)
{
$where = array();
$db = $this->_getTable()->getAdapter();
$primaryKey = $this->_getPrimaryKeyValues($useDirty);
$info = $this->_getTable()->info();
$metadata = $info[Kwf_Db_Table::METADATA];
// retrieve recently updated row using primary keys
$where = array();
foreach ($primaryKey as $column => $value) {
$tableName = $db->quoteIdentifier($this->_table->getTableName(), true);
$type = $metadata[$column]['DATA_TYPE'];
$columnName = $db->quoteIdentifier($column, true);
$where[] = $db->quoteInto("{$tableName}.{$columnName} = ?", $value, $type);
}
return $where;
} | php | protected function _getWhereQuery($useDirty = true)
{
$where = array();
$db = $this->_getTable()->getAdapter();
$primaryKey = $this->_getPrimaryKeyValues($useDirty);
$info = $this->_getTable()->info();
$metadata = $info[Kwf_Db_Table::METADATA];
// retrieve recently updated row using primary keys
$where = array();
foreach ($primaryKey as $column => $value) {
$tableName = $db->quoteIdentifier($this->_table->getTableName(), true);
$type = $metadata[$column]['DATA_TYPE'];
$columnName = $db->quoteIdentifier($column, true);
$where[] = $db->quoteInto("{$tableName}.{$columnName} = ?", $value, $type);
}
return $where;
} | [
"protected",
"function",
"_getWhereQuery",
"(",
"$",
"useDirty",
"=",
"true",
")",
"{",
"$",
"where",
"=",
"array",
"(",
")",
";",
"$",
"db",
"=",
"$",
"this",
"->",
"_getTable",
"(",
")",
"->",
"getAdapter",
"(",
")",
";",
"$",
"primaryKey",
"=",
"$",
"this",
"->",
"_getPrimaryKeyValues",
"(",
"$",
"useDirty",
")",
";",
"$",
"info",
"=",
"$",
"this",
"->",
"_getTable",
"(",
")",
"->",
"info",
"(",
")",
";",
"$",
"metadata",
"=",
"$",
"info",
"[",
"Kwf_Db_Table",
"::",
"METADATA",
"]",
";",
"// retrieve recently updated row using primary keys",
"$",
"where",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"primaryKey",
"as",
"$",
"column",
"=>",
"$",
"value",
")",
"{",
"$",
"tableName",
"=",
"$",
"db",
"->",
"quoteIdentifier",
"(",
"$",
"this",
"->",
"_table",
"->",
"getTableName",
"(",
")",
",",
"true",
")",
";",
"$",
"type",
"=",
"$",
"metadata",
"[",
"$",
"column",
"]",
"[",
"'DATA_TYPE'",
"]",
";",
"$",
"columnName",
"=",
"$",
"db",
"->",
"quoteIdentifier",
"(",
"$",
"column",
",",
"true",
")",
";",
"$",
"where",
"[",
"]",
"=",
"$",
"db",
"->",
"quoteInto",
"(",
"\"{$tableName}.{$columnName} = ?\"",
",",
"$",
"value",
",",
"$",
"type",
")",
";",
"}",
"return",
"$",
"where",
";",
"}"
] | Constructs where statement for retrieving row(s).
@param bool $useDirty
@return array | [
"Constructs",
"where",
"statement",
"for",
"retrieving",
"row",
"(",
"s",
")",
"."
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Db/Table/Row.php#L407-L424 |
koala-framework/koala-framework | Kwf/Util/Fulltext/Lucene.php | Kwf_Util_Fulltext_Lucene.getInstance | public static function getInstance(Kwf_Component_Data $subroot)
{
while ($subroot) {
if (Kwc_Abstract::getFlag($subroot->componentClass, 'subroot')) {
break;
}
$subroot = $subroot->parent;
}
if (!$subroot) $subroot = Kwf_Component_Data_Root::getInstance();
static $instance = array();
if (!isset($instance[$subroot->componentId])) {
$analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive();
$analyzer->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_ShortWords(2));
//$stopWords = explode(' ', 'der dir das einer eine ein und oder doch ist sind an in vor nicht wir ihr sie es ich');
//$analyzer->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_StopWords($stopWords));
Zend_Search_Lucene_Analysis_Analyzer::setDefault($analyzer);
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
Zend_Search_Lucene_Storage_Directory_Filesystem::setDefaultFilePermissions(0666);
$path = 'cache/fulltext';
$path .= '/'.$subroot->componentId;
try {
$instance[$subroot->componentId] = Zend_Search_Lucene::open($path);
} catch (Zend_Search_Lucene_Exception $e) {
$instance[$subroot->componentId] = Zend_Search_Lucene::create($path);
}
}
return $instance[$subroot->componentId];
} | php | public static function getInstance(Kwf_Component_Data $subroot)
{
while ($subroot) {
if (Kwc_Abstract::getFlag($subroot->componentClass, 'subroot')) {
break;
}
$subroot = $subroot->parent;
}
if (!$subroot) $subroot = Kwf_Component_Data_Root::getInstance();
static $instance = array();
if (!isset($instance[$subroot->componentId])) {
$analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive();
$analyzer->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_ShortWords(2));
//$stopWords = explode(' ', 'der dir das einer eine ein und oder doch ist sind an in vor nicht wir ihr sie es ich');
//$analyzer->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_StopWords($stopWords));
Zend_Search_Lucene_Analysis_Analyzer::setDefault($analyzer);
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
Zend_Search_Lucene_Storage_Directory_Filesystem::setDefaultFilePermissions(0666);
$path = 'cache/fulltext';
$path .= '/'.$subroot->componentId;
try {
$instance[$subroot->componentId] = Zend_Search_Lucene::open($path);
} catch (Zend_Search_Lucene_Exception $e) {
$instance[$subroot->componentId] = Zend_Search_Lucene::create($path);
}
}
return $instance[$subroot->componentId];
} | [
"public",
"static",
"function",
"getInstance",
"(",
"Kwf_Component_Data",
"$",
"subroot",
")",
"{",
"while",
"(",
"$",
"subroot",
")",
"{",
"if",
"(",
"Kwc_Abstract",
"::",
"getFlag",
"(",
"$",
"subroot",
"->",
"componentClass",
",",
"'subroot'",
")",
")",
"{",
"break",
";",
"}",
"$",
"subroot",
"=",
"$",
"subroot",
"->",
"parent",
";",
"}",
"if",
"(",
"!",
"$",
"subroot",
")",
"$",
"subroot",
"=",
"Kwf_Component_Data_Root",
"::",
"getInstance",
"(",
")",
";",
"static",
"$",
"instance",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"instance",
"[",
"$",
"subroot",
"->",
"componentId",
"]",
")",
")",
"{",
"$",
"analyzer",
"=",
"new",
"Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive",
"(",
")",
";",
"$",
"analyzer",
"->",
"addFilter",
"(",
"new",
"Zend_Search_Lucene_Analysis_TokenFilter_ShortWords",
"(",
"2",
")",
")",
";",
"//$stopWords = explode(' ', 'der dir das einer eine ein und oder doch ist sind an in vor nicht wir ihr sie es ich');",
"//$analyzer->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_StopWords($stopWords));",
"Zend_Search_Lucene_Analysis_Analyzer",
"::",
"setDefault",
"(",
"$",
"analyzer",
")",
";",
"Zend_Search_Lucene_Search_QueryParser",
"::",
"setDefaultEncoding",
"(",
"'utf-8'",
")",
";",
"Zend_Search_Lucene_Storage_Directory_Filesystem",
"::",
"setDefaultFilePermissions",
"(",
"0666",
")",
";",
"$",
"path",
"=",
"'cache/fulltext'",
";",
"$",
"path",
".=",
"'/'",
".",
"$",
"subroot",
"->",
"componentId",
";",
"try",
"{",
"$",
"instance",
"[",
"$",
"subroot",
"->",
"componentId",
"]",
"=",
"Zend_Search_Lucene",
"::",
"open",
"(",
"$",
"path",
")",
";",
"}",
"catch",
"(",
"Zend_Search_Lucene_Exception",
"$",
"e",
")",
"{",
"$",
"instance",
"[",
"$",
"subroot",
"->",
"componentId",
"]",
"=",
"Zend_Search_Lucene",
"::",
"create",
"(",
"$",
"path",
")",
";",
"}",
"}",
"return",
"$",
"instance",
"[",
"$",
"subroot",
"->",
"componentId",
"]",
";",
"}"
] | Returns Zend_Search_Lucene instance for given subroot
every subroot has it's own instance
@param Kwf_Component_Data for this index
@return Zend_Search_Lucene_Interface | [
"Returns",
"Zend_Search_Lucene",
"instance",
"for",
"given",
"subroot"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Util/Fulltext/Lucene.php#L12-L40 |
koala-framework/koala-framework | Kwf/Component/Generator/Abstract.php | Kwf_Component_Generator_Abstract.select | final public function select($parentData, array $select = array())
{
$select = new Kwf_Component_Select($select);
$select->whereGenerator($this->_settings['generator']);
return $select;
} | php | final public function select($parentData, array $select = array())
{
$select = new Kwf_Component_Select($select);
$select->whereGenerator($this->_settings['generator']);
return $select;
} | [
"final",
"public",
"function",
"select",
"(",
"$",
"parentData",
",",
"array",
"$",
"select",
"=",
"array",
"(",
")",
")",
"{",
"$",
"select",
"=",
"new",
"Kwf_Component_Select",
"(",
"$",
"select",
")",
";",
"$",
"select",
"->",
"whereGenerator",
"(",
"$",
"this",
"->",
"_settings",
"[",
"'generator'",
"]",
")",
";",
"return",
"$",
"select",
";",
"}"
] | wennn man das select anpassen will _formatSelect überschreiben | [
"wennn",
"man",
"das",
"select",
"anpassen",
"will",
"_formatSelect",
"überschreiben"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Generator/Abstract.php#L577-L582 |
koala-framework/koala-framework | Kwf/Component/Generator/Abstract.php | Kwf_Component_Generator_Abstract._getPossibleIndirectDbIdShortcuts | protected function _getPossibleIndirectDbIdShortcuts($class)
{
$cacheId = '-poss-dbid-sc-'.$this->_class.'-'.$this->getGeneratorKey().'-'.$class;
$ret = Kwf_Cache_SimpleStatic::fetch($cacheId, $success);
if (!$success) {
$ret = $this->_getPossibleIndirectDbIdShortcutsImpl($class);
$ret = array_unique($ret);
Kwf_Cache_SimpleStatic::add($cacheId, $ret);
}
return $ret;
} | php | protected function _getPossibleIndirectDbIdShortcuts($class)
{
$cacheId = '-poss-dbid-sc-'.$this->_class.'-'.$this->getGeneratorKey().'-'.$class;
$ret = Kwf_Cache_SimpleStatic::fetch($cacheId, $success);
if (!$success) {
$ret = $this->_getPossibleIndirectDbIdShortcutsImpl($class);
$ret = array_unique($ret);
Kwf_Cache_SimpleStatic::add($cacheId, $ret);
}
return $ret;
} | [
"protected",
"function",
"_getPossibleIndirectDbIdShortcuts",
"(",
"$",
"class",
")",
"{",
"$",
"cacheId",
"=",
"'-poss-dbid-sc-'",
".",
"$",
"this",
"->",
"_class",
".",
"'-'",
".",
"$",
"this",
"->",
"getGeneratorKey",
"(",
")",
".",
"'-'",
".",
"$",
"class",
";",
"$",
"ret",
"=",
"Kwf_Cache_SimpleStatic",
"::",
"fetch",
"(",
"$",
"cacheId",
",",
"$",
"success",
")",
";",
"if",
"(",
"!",
"$",
"success",
")",
"{",
"$",
"ret",
"=",
"$",
"this",
"->",
"_getPossibleIndirectDbIdShortcutsImpl",
"(",
"$",
"class",
")",
";",
"$",
"ret",
"=",
"array_unique",
"(",
"$",
"ret",
")",
";",
"Kwf_Cache_SimpleStatic",
"::",
"add",
"(",
"$",
"cacheId",
",",
"$",
"ret",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] | Helper function that returns the dbIdShortcuts that can be used below a componentClass (only across page)
Static, fast and cached. | [
"Helper",
"function",
"that",
"returns",
"the",
"dbIdShortcuts",
"that",
"can",
"be",
"used",
"below",
"a",
"componentClass",
"(",
"only",
"across",
"page",
")"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Generator/Abstract.php#L944-L954 |
koala-framework/koala-framework | Kwc/Abstract/List/FormWithEditButton.php | Kwc_Abstract_List_FormWithEditButton._getMultiFieldsFieldset | protected function _getMultiFieldsFieldset()
{
$fs = new Kwf_Form_Container_FieldSet(trlKwf('Paragraph {0}'));
$fs->add(new Kwf_Form_Field_Checkbox('visible', trlKwf('Visible')));
$fs->add(new Kwf_Form_Field_SimpleAbstract('edit'))
->setXtype('kwc.listeditbutton')
->setLabelSeparator('')
->setData(new Kwc_Abstract_List_FormWithEditButton_NoSaveData('id'));
return $fs;
} | php | protected function _getMultiFieldsFieldset()
{
$fs = new Kwf_Form_Container_FieldSet(trlKwf('Paragraph {0}'));
$fs->add(new Kwf_Form_Field_Checkbox('visible', trlKwf('Visible')));
$fs->add(new Kwf_Form_Field_SimpleAbstract('edit'))
->setXtype('kwc.listeditbutton')
->setLabelSeparator('')
->setData(new Kwc_Abstract_List_FormWithEditButton_NoSaveData('id'));
return $fs;
} | [
"protected",
"function",
"_getMultiFieldsFieldset",
"(",
")",
"{",
"$",
"fs",
"=",
"new",
"Kwf_Form_Container_FieldSet",
"(",
"trlKwf",
"(",
"'Paragraph {0}'",
")",
")",
";",
"$",
"fs",
"->",
"add",
"(",
"new",
"Kwf_Form_Field_Checkbox",
"(",
"'visible'",
",",
"trlKwf",
"(",
"'Visible'",
")",
")",
")",
";",
"$",
"fs",
"->",
"add",
"(",
"new",
"Kwf_Form_Field_SimpleAbstract",
"(",
"'edit'",
")",
")",
"->",
"setXtype",
"(",
"'kwc.listeditbutton'",
")",
"->",
"setLabelSeparator",
"(",
"''",
")",
"->",
"setData",
"(",
"new",
"Kwc_Abstract_List_FormWithEditButton_NoSaveData",
"(",
"'id'",
")",
")",
";",
"return",
"$",
"fs",
";",
"}"
] | MultiFields content fields.
@return array $fields The fields that should be inserted. | [
"MultiFields",
"content",
"fields",
"."
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Abstract/List/FormWithEditButton.php#L27-L36 |
koala-framework/koala-framework | Kwf/Mail/Template.php | Kwf_Mail_Template.getMailContent | public function getMailContent($type = Kwf_Model_Mail_Row::MAIL_CONTENT_AUTO)
{
if ($type == Kwf_Model_Mail_Row::MAIL_CONTENT_AUTO) {
$ret = $this->_getHtmlMailContent();
if (is_null($ret)) $ret = $this->_getTextMailContent();
return $ret;
} else if ($type == Kwf_Model_Mail_Row::MAIL_CONTENT_HTML) {
return $this->_getHtmlMailContent();
} else if ($type == Kwf_Model_Mail_Row::MAIL_CONTENT_TEXT) {
return $this->_getTextMailContent();
}
return null;
} | php | public function getMailContent($type = Kwf_Model_Mail_Row::MAIL_CONTENT_AUTO)
{
if ($type == Kwf_Model_Mail_Row::MAIL_CONTENT_AUTO) {
$ret = $this->_getHtmlMailContent();
if (is_null($ret)) $ret = $this->_getTextMailContent();
return $ret;
} else if ($type == Kwf_Model_Mail_Row::MAIL_CONTENT_HTML) {
return $this->_getHtmlMailContent();
} else if ($type == Kwf_Model_Mail_Row::MAIL_CONTENT_TEXT) {
return $this->_getTextMailContent();
}
return null;
} | [
"public",
"function",
"getMailContent",
"(",
"$",
"type",
"=",
"Kwf_Model_Mail_Row",
"::",
"MAIL_CONTENT_AUTO",
")",
"{",
"if",
"(",
"$",
"type",
"==",
"Kwf_Model_Mail_Row",
"::",
"MAIL_CONTENT_AUTO",
")",
"{",
"$",
"ret",
"=",
"$",
"this",
"->",
"_getHtmlMailContent",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"ret",
")",
")",
"$",
"ret",
"=",
"$",
"this",
"->",
"_getTextMailContent",
"(",
")",
";",
"return",
"$",
"ret",
";",
"}",
"else",
"if",
"(",
"$",
"type",
"==",
"Kwf_Model_Mail_Row",
"::",
"MAIL_CONTENT_HTML",
")",
"{",
"return",
"$",
"this",
"->",
"_getHtmlMailContent",
"(",
")",
";",
"}",
"else",
"if",
"(",
"$",
"type",
"==",
"Kwf_Model_Mail_Row",
"::",
"MAIL_CONTENT_TEXT",
")",
"{",
"return",
"$",
"this",
"->",
"_getTextMailContent",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] | constants for type defined in Kwf_Model_Mail_Row | [
"constants",
"for",
"type",
"defined",
"in",
"Kwf_Model_Mail_Row"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Mail/Template.php#L162-L175 |
koala-framework/koala-framework | Kwc/Mail/Recipient/Placeholders.php | Kwc_Mail_Recipient_Placeholders.getPlaceholders | public static function getPlaceholders(Kwc_Mail_Recipient_Interface $recipient, $language)
{
$ret = array();
$trl = Kwf_Trl::getInstance();
$ret['firstname'] = $recipient->getMailFirstname();
$ret['lastname'] = $recipient->getMailLastname();
if ($recipient instanceof Kwc_Mail_Recipient_TitleInterface) {
$replace = array(
$recipient->getMailTitle(),
$recipient->getMailLastname()
);
$politeM = $trl->trlKwf('Dear Mr. {0} {1}', $replace, $language);
$politeF = $trl->trlKwf('Dear Mrs. {0} {1}', $replace, $language);
if ($recipient->getMailGender() == 'male' && $recipient->getMailLastname()) {
$t = $trl->trlKwf('Dear Mr. {0} {1}', $replace, $language);
} else if ($recipient->getMailGender() == 'female' && $recipient->getMailLastname()) {
$t = $trl->trlKwf('Dear Mrs. {0} {1}', $replace, $language);
} else {
$t = $trl->trlKwf('Dear Mrs./Mr. {0} {1}', $replace, $language);
}
$ret['salutation_polite'] = trim(str_replace(' ', ' ', $t));
if ($recipient->getMailGender() == 'male') {
$t = $trl->trlKwf('Mr. {0}', $recipient->getMailTitle(), $language);
} else if ($recipient->getMailGender() == 'female') {
$t = $trl->trlKwf('Mrs. {0}', $recipient->getMailTitle(), $language);
} else {
$t = $recipient->getMailTitle();
}
$ret['salutation_title'] = trim(str_replace(' ', ' ', $t));
$ret['title'] = $recipient->getMailTitle();
}
if ($recipient instanceof Kwc_Mail_Recipient_GenderInterface) {
$replace = array($recipient->getMailLastname());
if ($recipient->getMailGender() == 'male') {
$ret['salutation_polite_notitle'] = $trl->trlKwf('Dear Mr. {0}', $replace, $language);
$ret['salutation_hello'] = $trl->trlKwf('Hello Mr. {0}', $replace, $language);
$ret['salutation'] = $trl->trlKwf('Mr.', array(), $language);
$ret['salutation_firstname'] = $trl->trlcKwf('salutation firstname male', 'Dear {0}', array($recipient->getMailFirstname()), $language);
} else if ($recipient->getMailGender() == 'female') {
$ret['salutation_polite_notitle'] = $trl->trlKwf('Dear Mrs. {0}', $replace, $language);
$ret['salutation_hello'] = $trl->trlKwf('Hello Mrs. {0}', $replace, $language);
$ret['salutation'] = $trl->trlKwf('Mrs.', array(), $language);
$ret['salutation_firstname'] = $trl->trlcKwf('salutation firstname female', 'Dear {0}', array($recipient->getMailFirstname()), $language);
} else {
$replace = array(
$recipient->getMailFirstname(),
$recipient->getMailLastname()
);
if ($recipient->getMailFirstname() && $recipient->getMailLastname()) {
$ret['salutation_polite_notitle'] = trim($trl->trlKwf('Dear {0} {1}', $replace, $language));
} else {
$ret['salutation_polite_notitle'] = $trl->trlKwf('Dear Sir or Madam', array(), $language);
}
$ret['salutation_hello'] = trim($trl->trlKwf('Hello {0} {1}', $replace, $language));
$ret['salutation_firstname'] = $trl->trlcKwf('salutation firstname unknown gender', 'Dear {0}', array($recipient->getMailFirstname()), $language);
$ret['salutation'] = '';
}
}
return $ret;
} | php | public static function getPlaceholders(Kwc_Mail_Recipient_Interface $recipient, $language)
{
$ret = array();
$trl = Kwf_Trl::getInstance();
$ret['firstname'] = $recipient->getMailFirstname();
$ret['lastname'] = $recipient->getMailLastname();
if ($recipient instanceof Kwc_Mail_Recipient_TitleInterface) {
$replace = array(
$recipient->getMailTitle(),
$recipient->getMailLastname()
);
$politeM = $trl->trlKwf('Dear Mr. {0} {1}', $replace, $language);
$politeF = $trl->trlKwf('Dear Mrs. {0} {1}', $replace, $language);
if ($recipient->getMailGender() == 'male' && $recipient->getMailLastname()) {
$t = $trl->trlKwf('Dear Mr. {0} {1}', $replace, $language);
} else if ($recipient->getMailGender() == 'female' && $recipient->getMailLastname()) {
$t = $trl->trlKwf('Dear Mrs. {0} {1}', $replace, $language);
} else {
$t = $trl->trlKwf('Dear Mrs./Mr. {0} {1}', $replace, $language);
}
$ret['salutation_polite'] = trim(str_replace(' ', ' ', $t));
if ($recipient->getMailGender() == 'male') {
$t = $trl->trlKwf('Mr. {0}', $recipient->getMailTitle(), $language);
} else if ($recipient->getMailGender() == 'female') {
$t = $trl->trlKwf('Mrs. {0}', $recipient->getMailTitle(), $language);
} else {
$t = $recipient->getMailTitle();
}
$ret['salutation_title'] = trim(str_replace(' ', ' ', $t));
$ret['title'] = $recipient->getMailTitle();
}
if ($recipient instanceof Kwc_Mail_Recipient_GenderInterface) {
$replace = array($recipient->getMailLastname());
if ($recipient->getMailGender() == 'male') {
$ret['salutation_polite_notitle'] = $trl->trlKwf('Dear Mr. {0}', $replace, $language);
$ret['salutation_hello'] = $trl->trlKwf('Hello Mr. {0}', $replace, $language);
$ret['salutation'] = $trl->trlKwf('Mr.', array(), $language);
$ret['salutation_firstname'] = $trl->trlcKwf('salutation firstname male', 'Dear {0}', array($recipient->getMailFirstname()), $language);
} else if ($recipient->getMailGender() == 'female') {
$ret['salutation_polite_notitle'] = $trl->trlKwf('Dear Mrs. {0}', $replace, $language);
$ret['salutation_hello'] = $trl->trlKwf('Hello Mrs. {0}', $replace, $language);
$ret['salutation'] = $trl->trlKwf('Mrs.', array(), $language);
$ret['salutation_firstname'] = $trl->trlcKwf('salutation firstname female', 'Dear {0}', array($recipient->getMailFirstname()), $language);
} else {
$replace = array(
$recipient->getMailFirstname(),
$recipient->getMailLastname()
);
if ($recipient->getMailFirstname() && $recipient->getMailLastname()) {
$ret['salutation_polite_notitle'] = trim($trl->trlKwf('Dear {0} {1}', $replace, $language));
} else {
$ret['salutation_polite_notitle'] = $trl->trlKwf('Dear Sir or Madam', array(), $language);
}
$ret['salutation_hello'] = trim($trl->trlKwf('Hello {0} {1}', $replace, $language));
$ret['salutation_firstname'] = $trl->trlcKwf('salutation firstname unknown gender', 'Dear {0}', array($recipient->getMailFirstname()), $language);
$ret['salutation'] = '';
}
}
return $ret;
} | [
"public",
"static",
"function",
"getPlaceholders",
"(",
"Kwc_Mail_Recipient_Interface",
"$",
"recipient",
",",
"$",
"language",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"$",
"trl",
"=",
"Kwf_Trl",
"::",
"getInstance",
"(",
")",
";",
"$",
"ret",
"[",
"'firstname'",
"]",
"=",
"$",
"recipient",
"->",
"getMailFirstname",
"(",
")",
";",
"$",
"ret",
"[",
"'lastname'",
"]",
"=",
"$",
"recipient",
"->",
"getMailLastname",
"(",
")",
";",
"if",
"(",
"$",
"recipient",
"instanceof",
"Kwc_Mail_Recipient_TitleInterface",
")",
"{",
"$",
"replace",
"=",
"array",
"(",
"$",
"recipient",
"->",
"getMailTitle",
"(",
")",
",",
"$",
"recipient",
"->",
"getMailLastname",
"(",
")",
")",
";",
"$",
"politeM",
"=",
"$",
"trl",
"->",
"trlKwf",
"(",
"'Dear Mr. {0} {1}'",
",",
"$",
"replace",
",",
"$",
"language",
")",
";",
"$",
"politeF",
"=",
"$",
"trl",
"->",
"trlKwf",
"(",
"'Dear Mrs. {0} {1}'",
",",
"$",
"replace",
",",
"$",
"language",
")",
";",
"if",
"(",
"$",
"recipient",
"->",
"getMailGender",
"(",
")",
"==",
"'male'",
"&&",
"$",
"recipient",
"->",
"getMailLastname",
"(",
")",
")",
"{",
"$",
"t",
"=",
"$",
"trl",
"->",
"trlKwf",
"(",
"'Dear Mr. {0} {1}'",
",",
"$",
"replace",
",",
"$",
"language",
")",
";",
"}",
"else",
"if",
"(",
"$",
"recipient",
"->",
"getMailGender",
"(",
")",
"==",
"'female'",
"&&",
"$",
"recipient",
"->",
"getMailLastname",
"(",
")",
")",
"{",
"$",
"t",
"=",
"$",
"trl",
"->",
"trlKwf",
"(",
"'Dear Mrs. {0} {1}'",
",",
"$",
"replace",
",",
"$",
"language",
")",
";",
"}",
"else",
"{",
"$",
"t",
"=",
"$",
"trl",
"->",
"trlKwf",
"(",
"'Dear Mrs./Mr. {0} {1}'",
",",
"$",
"replace",
",",
"$",
"language",
")",
";",
"}",
"$",
"ret",
"[",
"'salutation_polite'",
"]",
"=",
"trim",
"(",
"str_replace",
"(",
"' '",
",",
"' '",
",",
"$",
"t",
")",
")",
";",
"if",
"(",
"$",
"recipient",
"->",
"getMailGender",
"(",
")",
"==",
"'male'",
")",
"{",
"$",
"t",
"=",
"$",
"trl",
"->",
"trlKwf",
"(",
"'Mr. {0}'",
",",
"$",
"recipient",
"->",
"getMailTitle",
"(",
")",
",",
"$",
"language",
")",
";",
"}",
"else",
"if",
"(",
"$",
"recipient",
"->",
"getMailGender",
"(",
")",
"==",
"'female'",
")",
"{",
"$",
"t",
"=",
"$",
"trl",
"->",
"trlKwf",
"(",
"'Mrs. {0}'",
",",
"$",
"recipient",
"->",
"getMailTitle",
"(",
")",
",",
"$",
"language",
")",
";",
"}",
"else",
"{",
"$",
"t",
"=",
"$",
"recipient",
"->",
"getMailTitle",
"(",
")",
";",
"}",
"$",
"ret",
"[",
"'salutation_title'",
"]",
"=",
"trim",
"(",
"str_replace",
"(",
"' '",
",",
"' '",
",",
"$",
"t",
")",
")",
";",
"$",
"ret",
"[",
"'title'",
"]",
"=",
"$",
"recipient",
"->",
"getMailTitle",
"(",
")",
";",
"}",
"if",
"(",
"$",
"recipient",
"instanceof",
"Kwc_Mail_Recipient_GenderInterface",
")",
"{",
"$",
"replace",
"=",
"array",
"(",
"$",
"recipient",
"->",
"getMailLastname",
"(",
")",
")",
";",
"if",
"(",
"$",
"recipient",
"->",
"getMailGender",
"(",
")",
"==",
"'male'",
")",
"{",
"$",
"ret",
"[",
"'salutation_polite_notitle'",
"]",
"=",
"$",
"trl",
"->",
"trlKwf",
"(",
"'Dear Mr. {0}'",
",",
"$",
"replace",
",",
"$",
"language",
")",
";",
"$",
"ret",
"[",
"'salutation_hello'",
"]",
"=",
"$",
"trl",
"->",
"trlKwf",
"(",
"'Hello Mr. {0}'",
",",
"$",
"replace",
",",
"$",
"language",
")",
";",
"$",
"ret",
"[",
"'salutation'",
"]",
"=",
"$",
"trl",
"->",
"trlKwf",
"(",
"'Mr.'",
",",
"array",
"(",
")",
",",
"$",
"language",
")",
";",
"$",
"ret",
"[",
"'salutation_firstname'",
"]",
"=",
"$",
"trl",
"->",
"trlcKwf",
"(",
"'salutation firstname male'",
",",
"'Dear {0}'",
",",
"array",
"(",
"$",
"recipient",
"->",
"getMailFirstname",
"(",
")",
")",
",",
"$",
"language",
")",
";",
"}",
"else",
"if",
"(",
"$",
"recipient",
"->",
"getMailGender",
"(",
")",
"==",
"'female'",
")",
"{",
"$",
"ret",
"[",
"'salutation_polite_notitle'",
"]",
"=",
"$",
"trl",
"->",
"trlKwf",
"(",
"'Dear Mrs. {0}'",
",",
"$",
"replace",
",",
"$",
"language",
")",
";",
"$",
"ret",
"[",
"'salutation_hello'",
"]",
"=",
"$",
"trl",
"->",
"trlKwf",
"(",
"'Hello Mrs. {0}'",
",",
"$",
"replace",
",",
"$",
"language",
")",
";",
"$",
"ret",
"[",
"'salutation'",
"]",
"=",
"$",
"trl",
"->",
"trlKwf",
"(",
"'Mrs.'",
",",
"array",
"(",
")",
",",
"$",
"language",
")",
";",
"$",
"ret",
"[",
"'salutation_firstname'",
"]",
"=",
"$",
"trl",
"->",
"trlcKwf",
"(",
"'salutation firstname female'",
",",
"'Dear {0}'",
",",
"array",
"(",
"$",
"recipient",
"->",
"getMailFirstname",
"(",
")",
")",
",",
"$",
"language",
")",
";",
"}",
"else",
"{",
"$",
"replace",
"=",
"array",
"(",
"$",
"recipient",
"->",
"getMailFirstname",
"(",
")",
",",
"$",
"recipient",
"->",
"getMailLastname",
"(",
")",
")",
";",
"if",
"(",
"$",
"recipient",
"->",
"getMailFirstname",
"(",
")",
"&&",
"$",
"recipient",
"->",
"getMailLastname",
"(",
")",
")",
"{",
"$",
"ret",
"[",
"'salutation_polite_notitle'",
"]",
"=",
"trim",
"(",
"$",
"trl",
"->",
"trlKwf",
"(",
"'Dear {0} {1}'",
",",
"$",
"replace",
",",
"$",
"language",
")",
")",
";",
"}",
"else",
"{",
"$",
"ret",
"[",
"'salutation_polite_notitle'",
"]",
"=",
"$",
"trl",
"->",
"trlKwf",
"(",
"'Dear Sir or Madam'",
",",
"array",
"(",
")",
",",
"$",
"language",
")",
";",
"}",
"$",
"ret",
"[",
"'salutation_hello'",
"]",
"=",
"trim",
"(",
"$",
"trl",
"->",
"trlKwf",
"(",
"'Hello {0} {1}'",
",",
"$",
"replace",
",",
"$",
"language",
")",
")",
";",
"$",
"ret",
"[",
"'salutation_firstname'",
"]",
"=",
"$",
"trl",
"->",
"trlcKwf",
"(",
"'salutation firstname unknown gender'",
",",
"'Dear {0}'",
",",
"array",
"(",
"$",
"recipient",
"->",
"getMailFirstname",
"(",
")",
")",
",",
"$",
"language",
")",
";",
"$",
"ret",
"[",
"'salutation'",
"]",
"=",
"''",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] | /*
Returns Placeholders with different salutations
$recipient contains recipient row
$language contains in which lanuage the Placeholders should be translated | [
"/",
"*",
"Returns",
"Placeholders",
"with",
"different",
"salutations"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Mail/Recipient/Placeholders.php#L10-L71 |
koala-framework/koala-framework | Kwc/Menu/Events.php | Kwc_Menu_Events._initSettings | protected function _initSettings()
{
parent::_initSettings();
$this->_emptyIfSingleEntry = $menuLevel = Kwc_Abstract::getSetting($this->_class, 'emptyIfSingleEntry');
} | php | protected function _initSettings()
{
parent::_initSettings();
$this->_emptyIfSingleEntry = $menuLevel = Kwc_Abstract::getSetting($this->_class, 'emptyIfSingleEntry');
} | [
"protected",
"function",
"_initSettings",
"(",
")",
"{",
"parent",
"::",
"_initSettings",
"(",
")",
";",
"$",
"this",
"->",
"_emptyIfSingleEntry",
"=",
"$",
"menuLevel",
"=",
"Kwc_Abstract",
"::",
"getSetting",
"(",
"$",
"this",
"->",
"_class",
",",
"'emptyIfSingleEntry'",
")",
";",
"}"
] | overwritten in Kwc_Menu_Trl_Events | [
"overwritten",
"in",
"Kwc_Menu_Trl_Events"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Menu/Events.php#L7-L11 |
koala-framework/koala-framework | Kwc/Menu/Events.php | Kwc_Menu_Events._onMenuChanged | protected function _onMenuChanged(Kwf_Events_Event_Abstract $event, Kwf_Component_Data $menu)
{
parent::_onMenuChanged($event, $menu);
$newCount = count($menu->getComponent()->getMenuData());
if ($event instanceof Kwf_Component_Event_Page_Removed && $event->flag == Kwf_Component_Event_Page_Removed::FLAG_ROW_ADDED_REMOVED) {
//if a row was ->delete()d it the the component is still in the component tree and returned by getMenuData()
//so the newCount must be one less.
//when changing the visibility it is not returned and $newCount is already correct.
$newCount--;
}
if ($this->_emptyIfSingleEntry) $newCount--; //check with one less
$previousCount = $newCount;
if ($event instanceof Kwf_Component_Event_Page_Added) {
$previousCount--;
} else if ($event instanceof Kwf_Component_Event_Page_Removed) {
$previousCount++;
}
if (!$previousCount && $newCount || $previousCount && !$newCount) {
$this->fireEvent(new Kwf_Component_Event_Component_HasContentChanged(
$this->_class, $menu
));
}
} | php | protected function _onMenuChanged(Kwf_Events_Event_Abstract $event, Kwf_Component_Data $menu)
{
parent::_onMenuChanged($event, $menu);
$newCount = count($menu->getComponent()->getMenuData());
if ($event instanceof Kwf_Component_Event_Page_Removed && $event->flag == Kwf_Component_Event_Page_Removed::FLAG_ROW_ADDED_REMOVED) {
//if a row was ->delete()d it the the component is still in the component tree and returned by getMenuData()
//so the newCount must be one less.
//when changing the visibility it is not returned and $newCount is already correct.
$newCount--;
}
if ($this->_emptyIfSingleEntry) $newCount--; //check with one less
$previousCount = $newCount;
if ($event instanceof Kwf_Component_Event_Page_Added) {
$previousCount--;
} else if ($event instanceof Kwf_Component_Event_Page_Removed) {
$previousCount++;
}
if (!$previousCount && $newCount || $previousCount && !$newCount) {
$this->fireEvent(new Kwf_Component_Event_Component_HasContentChanged(
$this->_class, $menu
));
}
} | [
"protected",
"function",
"_onMenuChanged",
"(",
"Kwf_Events_Event_Abstract",
"$",
"event",
",",
"Kwf_Component_Data",
"$",
"menu",
")",
"{",
"parent",
"::",
"_onMenuChanged",
"(",
"$",
"event",
",",
"$",
"menu",
")",
";",
"$",
"newCount",
"=",
"count",
"(",
"$",
"menu",
"->",
"getComponent",
"(",
")",
"->",
"getMenuData",
"(",
")",
")",
";",
"if",
"(",
"$",
"event",
"instanceof",
"Kwf_Component_Event_Page_Removed",
"&&",
"$",
"event",
"->",
"flag",
"==",
"Kwf_Component_Event_Page_Removed",
"::",
"FLAG_ROW_ADDED_REMOVED",
")",
"{",
"//if a row was ->delete()d it the the component is still in the component tree and returned by getMenuData()",
"//so the newCount must be one less.",
"//when changing the visibility it is not returned and $newCount is already correct.",
"$",
"newCount",
"--",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_emptyIfSingleEntry",
")",
"$",
"newCount",
"--",
";",
"//check with one less",
"$",
"previousCount",
"=",
"$",
"newCount",
";",
"if",
"(",
"$",
"event",
"instanceof",
"Kwf_Component_Event_Page_Added",
")",
"{",
"$",
"previousCount",
"--",
";",
"}",
"else",
"if",
"(",
"$",
"event",
"instanceof",
"Kwf_Component_Event_Page_Removed",
")",
"{",
"$",
"previousCount",
"++",
";",
"}",
"if",
"(",
"!",
"$",
"previousCount",
"&&",
"$",
"newCount",
"||",
"$",
"previousCount",
"&&",
"!",
"$",
"newCount",
")",
"{",
"$",
"this",
"->",
"fireEvent",
"(",
"new",
"Kwf_Component_Event_Component_HasContentChanged",
"(",
"$",
"this",
"->",
"_class",
",",
"$",
"menu",
")",
")",
";",
"}",
"}"
] | fire HasContentChanged here because hasContent is implemented in this component | [
"fire",
"HasContentChanged",
"here",
"because",
"hasContent",
"is",
"implemented",
"in",
"this",
"component"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Menu/Events.php#L14-L39 |
koala-framework/koala-framework | Kwf/Component/Generator/Model.php | Kwf_Component_Generator_Model.output | public static function output()
{
$componentClass = Kwf_Component_Data_Root::getComponentClass();
$model = new self();
$maxComponentLength = self::_maxComponentLength($componentClass, $model);
self::_output(null, $model, $maxComponentLength);
} | php | public static function output()
{
$componentClass = Kwf_Component_Data_Root::getComponentClass();
$model = new self();
$maxComponentLength = self::_maxComponentLength($componentClass, $model);
self::_output(null, $model, $maxComponentLength);
} | [
"public",
"static",
"function",
"output",
"(",
")",
"{",
"$",
"componentClass",
"=",
"Kwf_Component_Data_Root",
"::",
"getComponentClass",
"(",
")",
";",
"$",
"model",
"=",
"new",
"self",
"(",
")",
";",
"$",
"maxComponentLength",
"=",
"self",
"::",
"_maxComponentLength",
"(",
"$",
"componentClass",
",",
"$",
"model",
")",
";",
"self",
"::",
"_output",
"(",
"null",
",",
"$",
"model",
",",
"$",
"maxComponentLength",
")",
";",
"}"
] | Gibt den Komponenten-Baum aus (für CLI) | [
"Gibt",
"den",
"Komponenten",
"-",
"Baum",
"aus",
"(",
"für",
"CLI",
")"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Generator/Model.php#L64-L72 |
koala-framework/koala-framework | Kwf/Component/Generator/Model.php | Kwf_Component_Generator_Model._output | private static function _output($componentClass, $model, $maxComponentLength)
{
static $stack = array();
array_push($stack, $componentClass);
$rows = $model->fetchAll(array('parent' => $componentClass));
foreach ($rows as $row) {
echo str_repeat(' ', count($stack)*2).$row->component;
echo str_repeat(' ', $maxComponentLength-strlen($row->component));
echo " ($row->name)";
if (in_array($row->component, $stack)) {
echo " (--recursion--)\n";
} else {
echo "\n";
self::_output($row->component, $model, $maxComponentLength);
}
}
array_pop($stack);
} | php | private static function _output($componentClass, $model, $maxComponentLength)
{
static $stack = array();
array_push($stack, $componentClass);
$rows = $model->fetchAll(array('parent' => $componentClass));
foreach ($rows as $row) {
echo str_repeat(' ', count($stack)*2).$row->component;
echo str_repeat(' ', $maxComponentLength-strlen($row->component));
echo " ($row->name)";
if (in_array($row->component, $stack)) {
echo " (--recursion--)\n";
} else {
echo "\n";
self::_output($row->component, $model, $maxComponentLength);
}
}
array_pop($stack);
} | [
"private",
"static",
"function",
"_output",
"(",
"$",
"componentClass",
",",
"$",
"model",
",",
"$",
"maxComponentLength",
")",
"{",
"static",
"$",
"stack",
"=",
"array",
"(",
")",
";",
"array_push",
"(",
"$",
"stack",
",",
"$",
"componentClass",
")",
";",
"$",
"rows",
"=",
"$",
"model",
"->",
"fetchAll",
"(",
"array",
"(",
"'parent'",
"=>",
"$",
"componentClass",
")",
")",
";",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"row",
")",
"{",
"echo",
"str_repeat",
"(",
"' '",
",",
"count",
"(",
"$",
"stack",
")",
"*",
"2",
")",
".",
"$",
"row",
"->",
"component",
";",
"echo",
"str_repeat",
"(",
"' '",
",",
"$",
"maxComponentLength",
"-",
"strlen",
"(",
"$",
"row",
"->",
"component",
")",
")",
";",
"echo",
"\" ($row->name)\"",
";",
"if",
"(",
"in_array",
"(",
"$",
"row",
"->",
"component",
",",
"$",
"stack",
")",
")",
"{",
"echo",
"\" (--recursion--)\\n\"",
";",
"}",
"else",
"{",
"echo",
"\"\\n\"",
";",
"self",
"::",
"_output",
"(",
"$",
"row",
"->",
"component",
",",
"$",
"model",
",",
"$",
"maxComponentLength",
")",
";",
"}",
"}",
"array_pop",
"(",
"$",
"stack",
")",
";",
"}"
] | Gibt den Komponenten-Baum aus (für CLI) | [
"Gibt",
"den",
"Komponenten",
"-",
"Baum",
"aus",
"(",
"für",
"CLI",
")"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Generator/Model.php#L76-L93 |
koala-framework/koala-framework | Kwf/Component/Acl.php | Kwf_Component_Acl._isAllowedComponentClass | private function _isAllowedComponentClass($userRow, $componentClass)
{
if ($this->_isAllowedComponentClassByRole($this->_getRole($userRow), $componentClass)) {
return true;
}
foreach ($this->_getAdditionalRoles($userRow) as $role) {
if ($this->_isAllowedComponentClassByRole($role, $componentClass)) {
return true;
}
}
return false;
} | php | private function _isAllowedComponentClass($userRow, $componentClass)
{
if ($this->_isAllowedComponentClassByRole($this->_getRole($userRow), $componentClass)) {
return true;
}
foreach ($this->_getAdditionalRoles($userRow) as $role) {
if ($this->_isAllowedComponentClassByRole($role, $componentClass)) {
return true;
}
}
return false;
} | [
"private",
"function",
"_isAllowedComponentClass",
"(",
"$",
"userRow",
",",
"$",
"componentClass",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_isAllowedComponentClassByRole",
"(",
"$",
"this",
"->",
"_getRole",
"(",
"$",
"userRow",
")",
",",
"$",
"componentClass",
")",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"_getAdditionalRoles",
"(",
"$",
"userRow",
")",
"as",
"$",
"role",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_isAllowedComponentClassByRole",
"(",
"$",
"role",
",",
"$",
"componentClass",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | darum erstmal private gemacht | [
"darum",
"erstmal",
"private",
"gemacht"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Acl.php#L75-L86 |
koala-framework/koala-framework | Kwf/Component/Acl.php | Kwf_Component_Acl.getAllowedRecursiveChildComponents | public function getAllowedRecursiveChildComponents($userRow)
{
$cacheId = is_object($userRow) ? $userRow->id : $userRow;
if (!isset($this->_allowedRecursiveChildComponentsCache[$cacheId])) {
$allowedComponentClasses = $this->_getAllowedComponentClasses($userRow);
$ret = array();
$cmps = Kwf_Component_Data_Root::getInstance()->getRecursiveChildComponents(array(
'ignoreVisible'=>true,
'componentClasses' => $allowedComponentClasses,
), array(
'ignoreVisible'=>true,
'generatorFlags' => array('showInPageTreeAdmin' => true),
));
foreach ($cmps as $c) {
if ($this->isAllowed($userRow, $c)) $ret[] = $c;
}
$this->_allowedRecursiveChildComponentsCache[$cacheId] = $ret;
}
return $this->_allowedRecursiveChildComponentsCache[$cacheId];
} | php | public function getAllowedRecursiveChildComponents($userRow)
{
$cacheId = is_object($userRow) ? $userRow->id : $userRow;
if (!isset($this->_allowedRecursiveChildComponentsCache[$cacheId])) {
$allowedComponentClasses = $this->_getAllowedComponentClasses($userRow);
$ret = array();
$cmps = Kwf_Component_Data_Root::getInstance()->getRecursiveChildComponents(array(
'ignoreVisible'=>true,
'componentClasses' => $allowedComponentClasses,
), array(
'ignoreVisible'=>true,
'generatorFlags' => array('showInPageTreeAdmin' => true),
));
foreach ($cmps as $c) {
if ($this->isAllowed($userRow, $c)) $ret[] = $c;
}
$this->_allowedRecursiveChildComponentsCache[$cacheId] = $ret;
}
return $this->_allowedRecursiveChildComponentsCache[$cacheId];
} | [
"public",
"function",
"getAllowedRecursiveChildComponents",
"(",
"$",
"userRow",
")",
"{",
"$",
"cacheId",
"=",
"is_object",
"(",
"$",
"userRow",
")",
"?",
"$",
"userRow",
"->",
"id",
":",
"$",
"userRow",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_allowedRecursiveChildComponentsCache",
"[",
"$",
"cacheId",
"]",
")",
")",
"{",
"$",
"allowedComponentClasses",
"=",
"$",
"this",
"->",
"_getAllowedComponentClasses",
"(",
"$",
"userRow",
")",
";",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"$",
"cmps",
"=",
"Kwf_Component_Data_Root",
"::",
"getInstance",
"(",
")",
"->",
"getRecursiveChildComponents",
"(",
"array",
"(",
"'ignoreVisible'",
"=>",
"true",
",",
"'componentClasses'",
"=>",
"$",
"allowedComponentClasses",
",",
")",
",",
"array",
"(",
"'ignoreVisible'",
"=>",
"true",
",",
"'generatorFlags'",
"=>",
"array",
"(",
"'showInPageTreeAdmin'",
"=>",
"true",
")",
",",
")",
")",
";",
"foreach",
"(",
"$",
"cmps",
"as",
"$",
"c",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isAllowed",
"(",
"$",
"userRow",
",",
"$",
"c",
")",
")",
"$",
"ret",
"[",
"]",
"=",
"$",
"c",
";",
"}",
"$",
"this",
"->",
"_allowedRecursiveChildComponentsCache",
"[",
"$",
"cacheId",
"]",
"=",
"$",
"ret",
";",
"}",
"return",
"$",
"this",
"->",
"_allowedRecursiveChildComponentsCache",
"[",
"$",
"cacheId",
"]",
";",
"}"
] | Gibt alle Komponenten zurück die im Seitenbaum bearbeitet werden dürfen
alles was unter einer seite liegt die im seitenbaum angezeigt wird
Langsam | [
"Gibt",
"alle",
"Komponenten",
"zurück",
"die",
"im",
"Seitenbaum",
"bearbeitet",
"werden",
"dürfen"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Acl.php#L195-L214 |
koala-framework/koala-framework | Kwf/Component/Acl.php | Kwf_Component_Acl.getAllowedChildComponents | public function getAllowedChildComponents($userRow, $component)
{
$allowedComponentClasses = $this->_getAllowedComponentClasses($userRow);
return $component->getRecursiveChildComponents(array(
'componentClasses' => $allowedComponentClasses,
'ignoreVisible' => true,
'pseudoPage' => false,
'generatorFlags' => array('showInPageTreeAdmin' => false),
), array(
'ignoreVisible' => true,
'pseudoPage' => false,
'generatorFlags' => array('showInPageTreeAdmin' => false),
));
} | php | public function getAllowedChildComponents($userRow, $component)
{
$allowedComponentClasses = $this->_getAllowedComponentClasses($userRow);
return $component->getRecursiveChildComponents(array(
'componentClasses' => $allowedComponentClasses,
'ignoreVisible' => true,
'pseudoPage' => false,
'generatorFlags' => array('showInPageTreeAdmin' => false),
), array(
'ignoreVisible' => true,
'pseudoPage' => false,
'generatorFlags' => array('showInPageTreeAdmin' => false),
));
} | [
"public",
"function",
"getAllowedChildComponents",
"(",
"$",
"userRow",
",",
"$",
"component",
")",
"{",
"$",
"allowedComponentClasses",
"=",
"$",
"this",
"->",
"_getAllowedComponentClasses",
"(",
"$",
"userRow",
")",
";",
"return",
"$",
"component",
"->",
"getRecursiveChildComponents",
"(",
"array",
"(",
"'componentClasses'",
"=>",
"$",
"allowedComponentClasses",
",",
"'ignoreVisible'",
"=>",
"true",
",",
"'pseudoPage'",
"=>",
"false",
",",
"'generatorFlags'",
"=>",
"array",
"(",
"'showInPageTreeAdmin'",
"=>",
"false",
")",
",",
")",
",",
"array",
"(",
"'ignoreVisible'",
"=>",
"true",
",",
"'pseudoPage'",
"=>",
"false",
",",
"'generatorFlags'",
"=>",
"array",
"(",
"'showInPageTreeAdmin'",
"=>",
"false",
")",
",",
")",
")",
";",
"}"
] | Gibt alle Unterkomponenten einer Seite zurück die barbeitet werden dürfen
d.h. alles *bis* zur pseudoPage oder showInPageTreeAdmin | [
"Gibt",
"alle",
"Unterkomponenten",
"einer",
"Seite",
"zurück",
"die",
"barbeitet",
"werden",
"dürfen"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Acl.php#L221-L234 |
koala-framework/koala-framework | Kwf/Component/Acl.php | Kwf_Component_Acl.allowComponent | public function allowComponent($role, $componentClass, $privilege = null)
{
if ($privilege) throw new Kwf_Exception("Not yet implemented");
if (!is_null($role)) $role = $this->_roleRegistry->get($role);
$rules =& $this->_getRules('Component', $componentClass, $role, true);
$rules['type'] = Kwf_Acl::TYPE_ALLOW;
return $this;
} | php | public function allowComponent($role, $componentClass, $privilege = null)
{
if ($privilege) throw new Kwf_Exception("Not yet implemented");
if (!is_null($role)) $role = $this->_roleRegistry->get($role);
$rules =& $this->_getRules('Component', $componentClass, $role, true);
$rules['type'] = Kwf_Acl::TYPE_ALLOW;
return $this;
} | [
"public",
"function",
"allowComponent",
"(",
"$",
"role",
",",
"$",
"componentClass",
",",
"$",
"privilege",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"privilege",
")",
"throw",
"new",
"Kwf_Exception",
"(",
"\"Not yet implemented\"",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"role",
")",
")",
"$",
"role",
"=",
"$",
"this",
"->",
"_roleRegistry",
"->",
"get",
"(",
"$",
"role",
")",
";",
"$",
"rules",
"=",
"&",
"$",
"this",
"->",
"_getRules",
"(",
"'Component'",
",",
"$",
"componentClass",
",",
"$",
"role",
",",
"true",
")",
";",
"$",
"rules",
"[",
"'type'",
"]",
"=",
"Kwf_Acl",
"::",
"TYPE_ALLOW",
";",
"return",
"$",
"this",
";",
"}"
] | Allow Component plus child components on same page | [
"Allow",
"Component",
"plus",
"child",
"components",
"on",
"same",
"page"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Acl.php#L275-L282 |
koala-framework/koala-framework | Kwf/Component/Generator/Events/Static.php | Kwf_Component_Generator_Events_Static._fireComponentEvent | protected function _fireComponentEvent($eventType, Kwf_Component_Event_Component_AbstractFlag $ev)
{
$cls = 'Kwf_Component_Event_Component_'.$eventType;
$g = $this->_getGenerator();
foreach ($ev->component->getChildComponents(array('generator'=>$g->getGeneratorKey())) as $c) {
$this->fireEvent(new $cls($c->componentClass, $c, $ev->flag));
}
} | php | protected function _fireComponentEvent($eventType, Kwf_Component_Event_Component_AbstractFlag $ev)
{
$cls = 'Kwf_Component_Event_Component_'.$eventType;
$g = $this->_getGenerator();
foreach ($ev->component->getChildComponents(array('generator'=>$g->getGeneratorKey())) as $c) {
$this->fireEvent(new $cls($c->componentClass, $c, $ev->flag));
}
} | [
"protected",
"function",
"_fireComponentEvent",
"(",
"$",
"eventType",
",",
"Kwf_Component_Event_Component_AbstractFlag",
"$",
"ev",
")",
"{",
"$",
"cls",
"=",
"'Kwf_Component_Event_Component_'",
".",
"$",
"eventType",
";",
"$",
"g",
"=",
"$",
"this",
"->",
"_getGenerator",
"(",
")",
";",
"foreach",
"(",
"$",
"ev",
"->",
"component",
"->",
"getChildComponents",
"(",
"array",
"(",
"'generator'",
"=>",
"$",
"g",
"->",
"getGeneratorKey",
"(",
")",
")",
")",
"as",
"$",
"c",
")",
"{",
"$",
"this",
"->",
"fireEvent",
"(",
"new",
"$",
"cls",
"(",
"$",
"c",
"->",
"componentClass",
",",
"$",
"c",
",",
"$",
"ev",
"->",
"flag",
")",
")",
";",
"}",
"}"
] | overridden in Page_Events_Static | [
"overridden",
"in",
"Page_Events_Static"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Generator/Events/Static.php#L21-L28 |
koala-framework/koala-framework | Kwc/Mail/PlaceholdersPlugin.php | Kwc_Mail_PlaceholdersPlugin.processMailOutput | public function processMailOutput($output, Kwc_Mail_Recipient_Interface $recipient = null)
{
$placeholders = Kwf_Component_Data_Root::getInstance()
->getComponentById($this->_componentId)
->getComponent()->getPlaceholders($recipient);
foreach ($placeholders as $p=>$v) {
$output = str_replace("%$p%", $v, $output);
}
return $output;
} | php | public function processMailOutput($output, Kwc_Mail_Recipient_Interface $recipient = null)
{
$placeholders = Kwf_Component_Data_Root::getInstance()
->getComponentById($this->_componentId)
->getComponent()->getPlaceholders($recipient);
foreach ($placeholders as $p=>$v) {
$output = str_replace("%$p%", $v, $output);
}
return $output;
} | [
"public",
"function",
"processMailOutput",
"(",
"$",
"output",
",",
"Kwc_Mail_Recipient_Interface",
"$",
"recipient",
"=",
"null",
")",
"{",
"$",
"placeholders",
"=",
"Kwf_Component_Data_Root",
"::",
"getInstance",
"(",
")",
"->",
"getComponentById",
"(",
"$",
"this",
"->",
"_componentId",
")",
"->",
"getComponent",
"(",
")",
"->",
"getPlaceholders",
"(",
"$",
"recipient",
")",
";",
"foreach",
"(",
"$",
"placeholders",
"as",
"$",
"p",
"=>",
"$",
"v",
")",
"{",
"$",
"output",
"=",
"str_replace",
"(",
"\"%$p%\"",
",",
"$",
"v",
",",
"$",
"output",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] | called by Kwc_Mail_Abstract_Component::getHtml and getText | [
"called",
"by",
"Kwc_Mail_Abstract_Component",
"::",
"getHtml",
"and",
"getText"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Mail/PlaceholdersPlugin.php#L5-L14 |
koala-framework/koala-framework | Kwc/Mail/PlaceholdersPlugin.php | Kwc_Mail_PlaceholdersPlugin.processOutput | public function processOutput($output, $renderer)
{
$output = parent::processOutput($output, $renderer);
$c = Kwf_Component_Data_Root::getInstance()->getComponentById($this->_componentId);
$recipient = $c->getComponent()->getRecipient();
$redirectComponent = $c->getChildComponent('_redirect');
if ($redirectComponent && $recipient) {
$redirectComponent = $redirectComponent->getComponent();
$output = $redirectComponent->replaceLinks($output, $recipient, 'html');
}
return $output;
} | php | public function processOutput($output, $renderer)
{
$output = parent::processOutput($output, $renderer);
$c = Kwf_Component_Data_Root::getInstance()->getComponentById($this->_componentId);
$recipient = $c->getComponent()->getRecipient();
$redirectComponent = $c->getChildComponent('_redirect');
if ($redirectComponent && $recipient) {
$redirectComponent = $redirectComponent->getComponent();
$output = $redirectComponent->replaceLinks($output, $recipient, 'html');
}
return $output;
} | [
"public",
"function",
"processOutput",
"(",
"$",
"output",
",",
"$",
"renderer",
")",
"{",
"$",
"output",
"=",
"parent",
"::",
"processOutput",
"(",
"$",
"output",
",",
"$",
"renderer",
")",
";",
"$",
"c",
"=",
"Kwf_Component_Data_Root",
"::",
"getInstance",
"(",
")",
"->",
"getComponentById",
"(",
"$",
"this",
"->",
"_componentId",
")",
";",
"$",
"recipient",
"=",
"$",
"c",
"->",
"getComponent",
"(",
")",
"->",
"getRecipient",
"(",
")",
";",
"$",
"redirectComponent",
"=",
"$",
"c",
"->",
"getChildComponent",
"(",
"'_redirect'",
")",
";",
"if",
"(",
"$",
"redirectComponent",
"&&",
"$",
"recipient",
")",
"{",
"$",
"redirectComponent",
"=",
"$",
"redirectComponent",
"->",
"getComponent",
"(",
")",
";",
"$",
"output",
"=",
"$",
"redirectComponent",
"->",
"replaceLinks",
"(",
"$",
"output",
",",
"$",
"recipient",
",",
"'html'",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] | recipient is set when showing mail in browser, not when sending mail | [
"recipient",
"is",
"set",
"when",
"showing",
"mail",
"in",
"browser",
"not",
"when",
"sending",
"mail"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Mail/PlaceholdersPlugin.php#L18-L30 |
koala-framework/koala-framework | Kwf/View/Helper/HighlightTerms.php | Kwf_View_Helper_HighlightTerms.highlightTerms | public function highlightTerms($terms, $text, array $options = array())
{
if (!is_array($terms)) $terms = array($terms);
if (!isset($options['maxReturnLength'])) $options['maxReturnLength'] = 350;
if (!isset($options['maxReturnBlocks'])) $options['maxReturnBlocks'] = 3;
if (!isset($options['blockSeparator'])) $options['blockSeparator'] = ' ... ';
if (!isset($options['cutWithinWords'])) $options['cutWithinWords'] = false;
foreach ($terms as $k => $term) {
if (!preg_match('/[a-zA-Z0-9]/', $term)) {
unset($terms[$k]);
}
}
$terms = array_values($terms);
if ($options['maxReturnLength'] == 0) {
$ret = $text;
} else {
// get from / to block positions
$blocksPositions = array();
foreach ($terms as $term) {
preg_match_all("/(^|\W)($term)/i", $text, $matches, PREG_OFFSET_CAPTURE);
$m = $matches[2];
$blocks = count($m) > $options['maxReturnBlocks'] ? $options['maxReturnBlocks'] : count($m);
if ($blocks >= 1) {
$blockLength = $options['maxReturnLength'];
$blockLength /= $blocks;
$blockLength -= $blocks * mb_strlen($options['blockSeparator']);
$blockLength = floor($blockLength);
for ($i=0; $i<$blocks; $i++) {
$blockPos = floor($m[$i][1] - (($blockLength - mb_strlen($term)) / 2));
if ($blockPos < 0) $blockPos = 0;
$blocksPositions[$blockPos] = array(
'pos' => $blockPos,
'length' => $blockLength
);
}
}
}
// sorting the blocks if there was more than one search word
ksort($blocksPositions);
$blocksPositions = array_values($blocksPositions);
// block begin / end only on space character
if (!$options['cutWithinWords'] && $blocksPositions) {
foreach ($blocksPositions as $k => $blockPos) {
// check start
if ($blockPos['pos'] != 0 ) {
while (preg_match('/\S/', mb_substr($text, $blockPos['pos']-1, 1)) // davor kein whitespace
|| preg_match('/\s/', mb_substr($text, $blockPos['pos'], 1)) // beginn ein whitespace
) {
$blockPos['pos'] += 1;
}
$blocksPositions[$k] = $blockPos;
}
// check end
if ($blockPos['pos'] + $blockPos['length'] < mb_strlen($text)) {
while (preg_match('/\S/', mb_substr($text, $blockPos['pos']+$blockPos['length'], 1)) // danach kein whitespace
|| preg_match('/\s/', mb_substr($text, $blockPos['pos']+$blockPos['length']-1, 1)) // ende ein whitespace
) {
$blockPos['length'] -= 1;
}
$blocksPositions[$k] = $blockPos;
}
}
}
// merge overlapping blocks
if ($blocksPositions) {
do {
$merged = false;
for ($i=0; $i<count($blocksPositions); $i++) {
$curPos = $blocksPositions[$i];
$nextPos = isset($blocksPositions[$i+1]) ? $blocksPositions[$i+1] : null;
if (!$nextPos) break;
if ($curPos['pos'] + $curPos['length'] >= $nextPos['pos']) {
$blocksPositions[$i]['length'] = ($nextPos['pos'] + $nextPos['length']) - $curPos['pos'];
unset($blocksPositions[$i+1]);
// assigning new keys
$blocksPositions = array_values($blocksPositions);
$merged = true;
break;
}
}
} while ($merged);
}
// building the new string
if (!$blocksPositions) {
$ret = mb_substr($text, 0, $options['maxReturnLength']);
} else {
$ret = '';
$i = 1;
foreach ($blocksPositions as $blockPos) {
$retBlock = mb_substr($text, $blockPos['pos'], $blockPos['length']);
if ($i > $options['maxReturnBlocks']
|| mb_strlen($ret) + mb_strlen($retBlock) > $options['maxReturnLength']
) {
// wenn die zeichen die zuviel sind, weniger als 30%
// des blocks ausmachen, vorn und hinten wegschneiden
$signsTooMuch = (mb_strlen($ret) + mb_strlen($retBlock)) - $options['maxReturnLength'];
if ($signsTooMuch <= mb_strlen($retBlock) * 0.3) {
$retBlock = mb_substr($retBlock, ceil($signsTooMuch/2), (-1)*ceil($signsTooMuch/2));
if ($blockPos['pos'] != 0) $ret .= $options['blockSeparator'];
$ret .= $retBlock;
$lastBlockPos = $blockPos;
}
// breaken, ab hier wirds wirklich zu lang
break;
}
if ($blockPos['pos'] != 0) $ret .= $options['blockSeparator'];
$ret .= $retBlock;
$lastBlockPos = $blockPos;
$i++;
}
if (!empty($lastBlockPos)) {
if ($lastBlockPos['pos'] + $lastBlockPos['length'] < mb_strlen($text)) {
$ret .= $options['blockSeparator'];
}
}
}
}
// highlighting
$c = 1;
foreach ($terms as $term) {
$ret = preg_replace(
'/(^|\W)('.$term.')/i',
'$1<span class="highlightTerms highlightTerm'.$c.'">$2</span>$3',
$ret
);
$c++;
}
return $ret;
} | php | public function highlightTerms($terms, $text, array $options = array())
{
if (!is_array($terms)) $terms = array($terms);
if (!isset($options['maxReturnLength'])) $options['maxReturnLength'] = 350;
if (!isset($options['maxReturnBlocks'])) $options['maxReturnBlocks'] = 3;
if (!isset($options['blockSeparator'])) $options['blockSeparator'] = ' ... ';
if (!isset($options['cutWithinWords'])) $options['cutWithinWords'] = false;
foreach ($terms as $k => $term) {
if (!preg_match('/[a-zA-Z0-9]/', $term)) {
unset($terms[$k]);
}
}
$terms = array_values($terms);
if ($options['maxReturnLength'] == 0) {
$ret = $text;
} else {
// get from / to block positions
$blocksPositions = array();
foreach ($terms as $term) {
preg_match_all("/(^|\W)($term)/i", $text, $matches, PREG_OFFSET_CAPTURE);
$m = $matches[2];
$blocks = count($m) > $options['maxReturnBlocks'] ? $options['maxReturnBlocks'] : count($m);
if ($blocks >= 1) {
$blockLength = $options['maxReturnLength'];
$blockLength /= $blocks;
$blockLength -= $blocks * mb_strlen($options['blockSeparator']);
$blockLength = floor($blockLength);
for ($i=0; $i<$blocks; $i++) {
$blockPos = floor($m[$i][1] - (($blockLength - mb_strlen($term)) / 2));
if ($blockPos < 0) $blockPos = 0;
$blocksPositions[$blockPos] = array(
'pos' => $blockPos,
'length' => $blockLength
);
}
}
}
// sorting the blocks if there was more than one search word
ksort($blocksPositions);
$blocksPositions = array_values($blocksPositions);
// block begin / end only on space character
if (!$options['cutWithinWords'] && $blocksPositions) {
foreach ($blocksPositions as $k => $blockPos) {
// check start
if ($blockPos['pos'] != 0 ) {
while (preg_match('/\S/', mb_substr($text, $blockPos['pos']-1, 1)) // davor kein whitespace
|| preg_match('/\s/', mb_substr($text, $blockPos['pos'], 1)) // beginn ein whitespace
) {
$blockPos['pos'] += 1;
}
$blocksPositions[$k] = $blockPos;
}
// check end
if ($blockPos['pos'] + $blockPos['length'] < mb_strlen($text)) {
while (preg_match('/\S/', mb_substr($text, $blockPos['pos']+$blockPos['length'], 1)) // danach kein whitespace
|| preg_match('/\s/', mb_substr($text, $blockPos['pos']+$blockPos['length']-1, 1)) // ende ein whitespace
) {
$blockPos['length'] -= 1;
}
$blocksPositions[$k] = $blockPos;
}
}
}
// merge overlapping blocks
if ($blocksPositions) {
do {
$merged = false;
for ($i=0; $i<count($blocksPositions); $i++) {
$curPos = $blocksPositions[$i];
$nextPos = isset($blocksPositions[$i+1]) ? $blocksPositions[$i+1] : null;
if (!$nextPos) break;
if ($curPos['pos'] + $curPos['length'] >= $nextPos['pos']) {
$blocksPositions[$i]['length'] = ($nextPos['pos'] + $nextPos['length']) - $curPos['pos'];
unset($blocksPositions[$i+1]);
// assigning new keys
$blocksPositions = array_values($blocksPositions);
$merged = true;
break;
}
}
} while ($merged);
}
// building the new string
if (!$blocksPositions) {
$ret = mb_substr($text, 0, $options['maxReturnLength']);
} else {
$ret = '';
$i = 1;
foreach ($blocksPositions as $blockPos) {
$retBlock = mb_substr($text, $blockPos['pos'], $blockPos['length']);
if ($i > $options['maxReturnBlocks']
|| mb_strlen($ret) + mb_strlen($retBlock) > $options['maxReturnLength']
) {
// wenn die zeichen die zuviel sind, weniger als 30%
// des blocks ausmachen, vorn und hinten wegschneiden
$signsTooMuch = (mb_strlen($ret) + mb_strlen($retBlock)) - $options['maxReturnLength'];
if ($signsTooMuch <= mb_strlen($retBlock) * 0.3) {
$retBlock = mb_substr($retBlock, ceil($signsTooMuch/2), (-1)*ceil($signsTooMuch/2));
if ($blockPos['pos'] != 0) $ret .= $options['blockSeparator'];
$ret .= $retBlock;
$lastBlockPos = $blockPos;
}
// breaken, ab hier wirds wirklich zu lang
break;
}
if ($blockPos['pos'] != 0) $ret .= $options['blockSeparator'];
$ret .= $retBlock;
$lastBlockPos = $blockPos;
$i++;
}
if (!empty($lastBlockPos)) {
if ($lastBlockPos['pos'] + $lastBlockPos['length'] < mb_strlen($text)) {
$ret .= $options['blockSeparator'];
}
}
}
}
// highlighting
$c = 1;
foreach ($terms as $term) {
$ret = preg_replace(
'/(^|\W)('.$term.')/i',
'$1<span class="highlightTerms highlightTerm'.$c.'">$2</span>$3',
$ret
);
$c++;
}
return $ret;
} | [
"public",
"function",
"highlightTerms",
"(",
"$",
"terms",
",",
"$",
"text",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"terms",
")",
")",
"$",
"terms",
"=",
"array",
"(",
"$",
"terms",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'maxReturnLength'",
"]",
")",
")",
"$",
"options",
"[",
"'maxReturnLength'",
"]",
"=",
"350",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'maxReturnBlocks'",
"]",
")",
")",
"$",
"options",
"[",
"'maxReturnBlocks'",
"]",
"=",
"3",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'blockSeparator'",
"]",
")",
")",
"$",
"options",
"[",
"'blockSeparator'",
"]",
"=",
"' ... '",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'cutWithinWords'",
"]",
")",
")",
"$",
"options",
"[",
"'cutWithinWords'",
"]",
"=",
"false",
";",
"foreach",
"(",
"$",
"terms",
"as",
"$",
"k",
"=>",
"$",
"term",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/[a-zA-Z0-9]/'",
",",
"$",
"term",
")",
")",
"{",
"unset",
"(",
"$",
"terms",
"[",
"$",
"k",
"]",
")",
";",
"}",
"}",
"$",
"terms",
"=",
"array_values",
"(",
"$",
"terms",
")",
";",
"if",
"(",
"$",
"options",
"[",
"'maxReturnLength'",
"]",
"==",
"0",
")",
"{",
"$",
"ret",
"=",
"$",
"text",
";",
"}",
"else",
"{",
"// get from / to block positions",
"$",
"blocksPositions",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"terms",
"as",
"$",
"term",
")",
"{",
"preg_match_all",
"(",
"\"/(^|\\W)($term)/i\"",
",",
"$",
"text",
",",
"$",
"matches",
",",
"PREG_OFFSET_CAPTURE",
")",
";",
"$",
"m",
"=",
"$",
"matches",
"[",
"2",
"]",
";",
"$",
"blocks",
"=",
"count",
"(",
"$",
"m",
")",
">",
"$",
"options",
"[",
"'maxReturnBlocks'",
"]",
"?",
"$",
"options",
"[",
"'maxReturnBlocks'",
"]",
":",
"count",
"(",
"$",
"m",
")",
";",
"if",
"(",
"$",
"blocks",
">=",
"1",
")",
"{",
"$",
"blockLength",
"=",
"$",
"options",
"[",
"'maxReturnLength'",
"]",
";",
"$",
"blockLength",
"/=",
"$",
"blocks",
";",
"$",
"blockLength",
"-=",
"$",
"blocks",
"*",
"mb_strlen",
"(",
"$",
"options",
"[",
"'blockSeparator'",
"]",
")",
";",
"$",
"blockLength",
"=",
"floor",
"(",
"$",
"blockLength",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"blocks",
";",
"$",
"i",
"++",
")",
"{",
"$",
"blockPos",
"=",
"floor",
"(",
"$",
"m",
"[",
"$",
"i",
"]",
"[",
"1",
"]",
"-",
"(",
"(",
"$",
"blockLength",
"-",
"mb_strlen",
"(",
"$",
"term",
")",
")",
"/",
"2",
")",
")",
";",
"if",
"(",
"$",
"blockPos",
"<",
"0",
")",
"$",
"blockPos",
"=",
"0",
";",
"$",
"blocksPositions",
"[",
"$",
"blockPos",
"]",
"=",
"array",
"(",
"'pos'",
"=>",
"$",
"blockPos",
",",
"'length'",
"=>",
"$",
"blockLength",
")",
";",
"}",
"}",
"}",
"// sorting the blocks if there was more than one search word",
"ksort",
"(",
"$",
"blocksPositions",
")",
";",
"$",
"blocksPositions",
"=",
"array_values",
"(",
"$",
"blocksPositions",
")",
";",
"// block begin / end only on space character",
"if",
"(",
"!",
"$",
"options",
"[",
"'cutWithinWords'",
"]",
"&&",
"$",
"blocksPositions",
")",
"{",
"foreach",
"(",
"$",
"blocksPositions",
"as",
"$",
"k",
"=>",
"$",
"blockPos",
")",
"{",
"// check start",
"if",
"(",
"$",
"blockPos",
"[",
"'pos'",
"]",
"!=",
"0",
")",
"{",
"while",
"(",
"preg_match",
"(",
"'/\\S/'",
",",
"mb_substr",
"(",
"$",
"text",
",",
"$",
"blockPos",
"[",
"'pos'",
"]",
"-",
"1",
",",
"1",
")",
")",
"// davor kein whitespace",
"||",
"preg_match",
"(",
"'/\\s/'",
",",
"mb_substr",
"(",
"$",
"text",
",",
"$",
"blockPos",
"[",
"'pos'",
"]",
",",
"1",
")",
")",
"// beginn ein whitespace",
")",
"{",
"$",
"blockPos",
"[",
"'pos'",
"]",
"+=",
"1",
";",
"}",
"$",
"blocksPositions",
"[",
"$",
"k",
"]",
"=",
"$",
"blockPos",
";",
"}",
"// check end",
"if",
"(",
"$",
"blockPos",
"[",
"'pos'",
"]",
"+",
"$",
"blockPos",
"[",
"'length'",
"]",
"<",
"mb_strlen",
"(",
"$",
"text",
")",
")",
"{",
"while",
"(",
"preg_match",
"(",
"'/\\S/'",
",",
"mb_substr",
"(",
"$",
"text",
",",
"$",
"blockPos",
"[",
"'pos'",
"]",
"+",
"$",
"blockPos",
"[",
"'length'",
"]",
",",
"1",
")",
")",
"// danach kein whitespace",
"||",
"preg_match",
"(",
"'/\\s/'",
",",
"mb_substr",
"(",
"$",
"text",
",",
"$",
"blockPos",
"[",
"'pos'",
"]",
"+",
"$",
"blockPos",
"[",
"'length'",
"]",
"-",
"1",
",",
"1",
")",
")",
"// ende ein whitespace",
")",
"{",
"$",
"blockPos",
"[",
"'length'",
"]",
"-=",
"1",
";",
"}",
"$",
"blocksPositions",
"[",
"$",
"k",
"]",
"=",
"$",
"blockPos",
";",
"}",
"}",
"}",
"// merge overlapping blocks",
"if",
"(",
"$",
"blocksPositions",
")",
"{",
"do",
"{",
"$",
"merged",
"=",
"false",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"blocksPositions",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"curPos",
"=",
"$",
"blocksPositions",
"[",
"$",
"i",
"]",
";",
"$",
"nextPos",
"=",
"isset",
"(",
"$",
"blocksPositions",
"[",
"$",
"i",
"+",
"1",
"]",
")",
"?",
"$",
"blocksPositions",
"[",
"$",
"i",
"+",
"1",
"]",
":",
"null",
";",
"if",
"(",
"!",
"$",
"nextPos",
")",
"break",
";",
"if",
"(",
"$",
"curPos",
"[",
"'pos'",
"]",
"+",
"$",
"curPos",
"[",
"'length'",
"]",
">=",
"$",
"nextPos",
"[",
"'pos'",
"]",
")",
"{",
"$",
"blocksPositions",
"[",
"$",
"i",
"]",
"[",
"'length'",
"]",
"=",
"(",
"$",
"nextPos",
"[",
"'pos'",
"]",
"+",
"$",
"nextPos",
"[",
"'length'",
"]",
")",
"-",
"$",
"curPos",
"[",
"'pos'",
"]",
";",
"unset",
"(",
"$",
"blocksPositions",
"[",
"$",
"i",
"+",
"1",
"]",
")",
";",
"// assigning new keys",
"$",
"blocksPositions",
"=",
"array_values",
"(",
"$",
"blocksPositions",
")",
";",
"$",
"merged",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"while",
"(",
"$",
"merged",
")",
";",
"}",
"// building the new string",
"if",
"(",
"!",
"$",
"blocksPositions",
")",
"{",
"$",
"ret",
"=",
"mb_substr",
"(",
"$",
"text",
",",
"0",
",",
"$",
"options",
"[",
"'maxReturnLength'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"ret",
"=",
"''",
";",
"$",
"i",
"=",
"1",
";",
"foreach",
"(",
"$",
"blocksPositions",
"as",
"$",
"blockPos",
")",
"{",
"$",
"retBlock",
"=",
"mb_substr",
"(",
"$",
"text",
",",
"$",
"blockPos",
"[",
"'pos'",
"]",
",",
"$",
"blockPos",
"[",
"'length'",
"]",
")",
";",
"if",
"(",
"$",
"i",
">",
"$",
"options",
"[",
"'maxReturnBlocks'",
"]",
"||",
"mb_strlen",
"(",
"$",
"ret",
")",
"+",
"mb_strlen",
"(",
"$",
"retBlock",
")",
">",
"$",
"options",
"[",
"'maxReturnLength'",
"]",
")",
"{",
"// wenn die zeichen die zuviel sind, weniger als 30%",
"// des blocks ausmachen, vorn und hinten wegschneiden",
"$",
"signsTooMuch",
"=",
"(",
"mb_strlen",
"(",
"$",
"ret",
")",
"+",
"mb_strlen",
"(",
"$",
"retBlock",
")",
")",
"-",
"$",
"options",
"[",
"'maxReturnLength'",
"]",
";",
"if",
"(",
"$",
"signsTooMuch",
"<=",
"mb_strlen",
"(",
"$",
"retBlock",
")",
"*",
"0.3",
")",
"{",
"$",
"retBlock",
"=",
"mb_substr",
"(",
"$",
"retBlock",
",",
"ceil",
"(",
"$",
"signsTooMuch",
"/",
"2",
")",
",",
"(",
"-",
"1",
")",
"*",
"ceil",
"(",
"$",
"signsTooMuch",
"/",
"2",
")",
")",
";",
"if",
"(",
"$",
"blockPos",
"[",
"'pos'",
"]",
"!=",
"0",
")",
"$",
"ret",
".=",
"$",
"options",
"[",
"'blockSeparator'",
"]",
";",
"$",
"ret",
".=",
"$",
"retBlock",
";",
"$",
"lastBlockPos",
"=",
"$",
"blockPos",
";",
"}",
"// breaken, ab hier wirds wirklich zu lang",
"break",
";",
"}",
"if",
"(",
"$",
"blockPos",
"[",
"'pos'",
"]",
"!=",
"0",
")",
"$",
"ret",
".=",
"$",
"options",
"[",
"'blockSeparator'",
"]",
";",
"$",
"ret",
".=",
"$",
"retBlock",
";",
"$",
"lastBlockPos",
"=",
"$",
"blockPos",
";",
"$",
"i",
"++",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"lastBlockPos",
")",
")",
"{",
"if",
"(",
"$",
"lastBlockPos",
"[",
"'pos'",
"]",
"+",
"$",
"lastBlockPos",
"[",
"'length'",
"]",
"<",
"mb_strlen",
"(",
"$",
"text",
")",
")",
"{",
"$",
"ret",
".=",
"$",
"options",
"[",
"'blockSeparator'",
"]",
";",
"}",
"}",
"}",
"}",
"// highlighting",
"$",
"c",
"=",
"1",
";",
"foreach",
"(",
"$",
"terms",
"as",
"$",
"term",
")",
"{",
"$",
"ret",
"=",
"preg_replace",
"(",
"'/(^|\\W)('",
".",
"$",
"term",
".",
"')/i'",
",",
"'$1<span class=\"highlightTerms highlightTerm'",
".",
"$",
"c",
".",
"'\">$2</span>$3'",
",",
"$",
"ret",
")",
";",
"$",
"c",
"++",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] | Highlights a term in a text and shorts it. The output then may look like
the description of a web-search-engine result.
@param string|array $terms The term(s) to highlight. Each must contain at least a char of: a-z A-Z 0-9
@param string $text The text to highlight the terms in.
@param array $options Options for the highlighting.
Possible keys an their default values are:
maxReturnLength => 350 // the maximum text-length to be returned. Set to '0' to return full string.
maxReturnBlocks => 3 // maximum blocks to be returned
blockSeparator => ' ... ' // string with which blocks are separated
cutWithinWords => false // if the blocks are cut within words or only on a space
@return string $highlightenedText The highlightened and shortened text. | [
"Highlights",
"a",
"term",
"in",
"a",
"text",
"and",
"shorts",
"it",
".",
"The",
"output",
"then",
"may",
"look",
"like",
"the",
"description",
"of",
"a",
"web",
"-",
"search",
"-",
"engine",
"result",
"."
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/View/Helper/HighlightTerms.php#L19-L158 |
koala-framework/koala-framework | Kwf/Form/Field/FilterField.php | Kwf_Form_Field_FilterField.setNamePrefix | public function setNamePrefix($name)
{
$this->_namePrefix = $name;
if ($this->getFilterField()) $this->getFilterField()->setNamePrefix($name);
if ($this->getFilteredField()) $this->getFilteredField()->setNamePrefix($name);
return $this;
} | php | public function setNamePrefix($name)
{
$this->_namePrefix = $name;
if ($this->getFilterField()) $this->getFilterField()->setNamePrefix($name);
if ($this->getFilteredField()) $this->getFilteredField()->setNamePrefix($name);
return $this;
} | [
"public",
"function",
"setNamePrefix",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"_namePrefix",
"=",
"$",
"name",
";",
"if",
"(",
"$",
"this",
"->",
"getFilterField",
"(",
")",
")",
"$",
"this",
"->",
"getFilterField",
"(",
")",
"->",
"setNamePrefix",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getFilteredField",
"(",
")",
")",
"$",
"this",
"->",
"getFilteredField",
"(",
")",
"->",
"setNamePrefix",
"(",
"$",
"name",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the name prefix for the filter/filtered fields | [
"Sets",
"the",
"name",
"prefix",
"for",
"the",
"filter",
"/",
"filtered",
"fields"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Form/Field/FilterField.php#L20-L26 |
koala-framework/koala-framework | Kwf/Form/Field/FilterField.php | Kwf_Form_Field_FilterField.setFilterField | public function setFilterField(Kwf_Form_Field_Abstract $field)
{
$property = $this->setProperty('filterField', $field);
$field->setNamePrefix($this->_namePrefix);
return $property;
} | php | public function setFilterField(Kwf_Form_Field_Abstract $field)
{
$property = $this->setProperty('filterField', $field);
$field->setNamePrefix($this->_namePrefix);
return $property;
} | [
"public",
"function",
"setFilterField",
"(",
"Kwf_Form_Field_Abstract",
"$",
"field",
")",
"{",
"$",
"property",
"=",
"$",
"this",
"->",
"setProperty",
"(",
"'filterField'",
",",
"$",
"field",
")",
";",
"$",
"field",
"->",
"setNamePrefix",
"(",
"$",
"this",
"->",
"_namePrefix",
")",
";",
"return",
"$",
"property",
";",
"}"
] | Sets the filter field (the one that filters the filtered field) | [
"Sets",
"the",
"filter",
"field",
"(",
"the",
"one",
"that",
"filters",
"the",
"filtered",
"field",
")"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Form/Field/FilterField.php#L31-L36 |
koala-framework/koala-framework | Kwf/Form/Field/FilterField.php | Kwf_Form_Field_FilterField.setFilteredField | public function setFilteredField(Kwf_Form_Field_Abstract $field)
{
$property = $this->setProperty('filteredField', $field);
$field->setNamePrefix($this->_namePrefix);
return $property;
} | php | public function setFilteredField(Kwf_Form_Field_Abstract $field)
{
$property = $this->setProperty('filteredField', $field);
$field->setNamePrefix($this->_namePrefix);
return $property;
} | [
"public",
"function",
"setFilteredField",
"(",
"Kwf_Form_Field_Abstract",
"$",
"field",
")",
"{",
"$",
"property",
"=",
"$",
"this",
"->",
"setProperty",
"(",
"'filteredField'",
",",
"$",
"field",
")",
";",
"$",
"field",
"->",
"setNamePrefix",
"(",
"$",
"this",
"->",
"_namePrefix",
")",
";",
"return",
"$",
"property",
";",
"}"
] | Sets the filtered field (the one that's filtered by filter field) | [
"Sets",
"the",
"filtered",
"field",
"(",
"the",
"one",
"that",
"s",
"filtered",
"by",
"filter",
"field",
")"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Form/Field/FilterField.php#L41-L46 |
koala-framework/koala-framework | Kwf/Assets/Package/ComponentPackage.php | Kwf_Assets_Package_ComponentPackage._getFilteredUniqueDependencies | protected function _getFilteredUniqueDependencies($mimeType)
{
$ret = parent::_getFilteredUniqueDependencies($mimeType);
$loadedDeps = $this->_loadedPackage->_getFilteredUniqueDependencies($mimeType);
foreach ($ret as $k=>$i) {
if (in_array($i, $loadedDeps, true)) {
unset($ret[$k]);
}
}
$ret = array_values($ret);
return $ret;
} | php | protected function _getFilteredUniqueDependencies($mimeType)
{
$ret = parent::_getFilteredUniqueDependencies($mimeType);
$loadedDeps = $this->_loadedPackage->_getFilteredUniqueDependencies($mimeType);
foreach ($ret as $k=>$i) {
if (in_array($i, $loadedDeps, true)) {
unset($ret[$k]);
}
}
$ret = array_values($ret);
return $ret;
} | [
"protected",
"function",
"_getFilteredUniqueDependencies",
"(",
"$",
"mimeType",
")",
"{",
"$",
"ret",
"=",
"parent",
"::",
"_getFilteredUniqueDependencies",
"(",
"$",
"mimeType",
")",
";",
"$",
"loadedDeps",
"=",
"$",
"this",
"->",
"_loadedPackage",
"->",
"_getFilteredUniqueDependencies",
"(",
"$",
"mimeType",
")",
";",
"foreach",
"(",
"$",
"ret",
"as",
"$",
"k",
"=>",
"$",
"i",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"i",
",",
"$",
"loadedDeps",
",",
"true",
")",
")",
"{",
"unset",
"(",
"$",
"ret",
"[",
"$",
"k",
"]",
")",
";",
"}",
"}",
"$",
"ret",
"=",
"array_values",
"(",
"$",
"ret",
")",
";",
"return",
"$",
"ret",
";",
"}"
] | remove already loaded (in _loadedPackage = Frontend) dependencies dependencies | [
"remove",
"already",
"loaded",
"(",
"in",
"_loadedPackage",
"=",
"Frontend",
")",
"dependencies",
"dependencies"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Assets/Package/ComponentPackage.php#L46-L61 |
koala-framework/koala-framework | Kwf/Assets/Package/ComponentPackage.php | Kwf_Assets_Package_ComponentPackage._getCommonJsData | protected function _getCommonJsData($mimeType)
{
$commonJsData = parent::_getCommonJsData($mimeType);
if ($commonJsData) {
$deps = array_merge(
$this->_loadedPackage->_getFilteredUniqueDependencies('text/javascript'),
$this->_loadedPackage->_getFilteredUniqueDependencies('text/javascript; defer')
);
foreach ($deps as $i) {
$data = array();
$commonJsDeps = $this->_getCommonJsDeps($i, $data);
foreach (array_keys($data) as $key) {
if (isset($commonJsData[$key])) {
unset($commonJsData[$key]);
}
}
}
}
return $commonJsData;
} | php | protected function _getCommonJsData($mimeType)
{
$commonJsData = parent::_getCommonJsData($mimeType);
if ($commonJsData) {
$deps = array_merge(
$this->_loadedPackage->_getFilteredUniqueDependencies('text/javascript'),
$this->_loadedPackage->_getFilteredUniqueDependencies('text/javascript; defer')
);
foreach ($deps as $i) {
$data = array();
$commonJsDeps = $this->_getCommonJsDeps($i, $data);
foreach (array_keys($data) as $key) {
if (isset($commonJsData[$key])) {
unset($commonJsData[$key]);
}
}
}
}
return $commonJsData;
} | [
"protected",
"function",
"_getCommonJsData",
"(",
"$",
"mimeType",
")",
"{",
"$",
"commonJsData",
"=",
"parent",
"::",
"_getCommonJsData",
"(",
"$",
"mimeType",
")",
";",
"if",
"(",
"$",
"commonJsData",
")",
"{",
"$",
"deps",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"_loadedPackage",
"->",
"_getFilteredUniqueDependencies",
"(",
"'text/javascript'",
")",
",",
"$",
"this",
"->",
"_loadedPackage",
"->",
"_getFilteredUniqueDependencies",
"(",
"'text/javascript; defer'",
")",
")",
";",
"foreach",
"(",
"$",
"deps",
"as",
"$",
"i",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"$",
"commonJsDeps",
"=",
"$",
"this",
"->",
"_getCommonJsDeps",
"(",
"$",
"i",
",",
"$",
"data",
")",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"data",
")",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"commonJsData",
"[",
"$",
"key",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"commonJsData",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"commonJsData",
";",
"}"
] | remove already loaded (in _loadedPackage = Frontend) commonjs dependencies | [
"remove",
"already",
"loaded",
"(",
"in",
"_loadedPackage",
"=",
"Frontend",
")",
"commonjs",
"dependencies"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Assets/Package/ComponentPackage.php#L72-L91 |
koala-framework/koala-framework | Kwf/Form/Field/ComboBox.php | Kwf_Form_Field_ComboBox.getMetaData | public function getMetaData($model)
{
$ret = parent::getMetaData($model);
$ret['store'] = $this->_getStoreData();
if (isset($ret['fields'])) unset($ret['fields']);
if (isset($ret['values'])) unset($ret['values']);
if (isset($ret['select'])) unset($ret['select']);
return $ret;
} | php | public function getMetaData($model)
{
$ret = parent::getMetaData($model);
$ret['store'] = $this->_getStoreData();
if (isset($ret['fields'])) unset($ret['fields']);
if (isset($ret['values'])) unset($ret['values']);
if (isset($ret['select'])) unset($ret['select']);
return $ret;
} | [
"public",
"function",
"getMetaData",
"(",
"$",
"model",
")",
"{",
"$",
"ret",
"=",
"parent",
"::",
"getMetaData",
"(",
"$",
"model",
")",
";",
"$",
"ret",
"[",
"'store'",
"]",
"=",
"$",
"this",
"->",
"_getStoreData",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"ret",
"[",
"'fields'",
"]",
")",
")",
"unset",
"(",
"$",
"ret",
"[",
"'fields'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"ret",
"[",
"'values'",
"]",
")",
")",
"unset",
"(",
"$",
"ret",
"[",
"'values'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"ret",
"[",
"'select'",
"]",
")",
")",
"unset",
"(",
"$",
"ret",
"[",
"'select'",
"]",
")",
";",
"return",
"$",
"ret",
";",
"}"
] | setListWidth | [
"setListWidth"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Form/Field/ComboBox.php#L52-L63 |
koala-framework/koala-framework | Kwc/Basic/Text/StylesModel.php | Kwc_Basic_Text_StylesModel.parseMasterStyles | public static function parseMasterStyles($masterContent)
{
$styles = array();
$up = Kwf_Config::getValue('application.uniquePrefix');
if ($up) $up .= '-';
if (strpos($masterContent, ".{$up}webStandard")===false) return $styles;
$up = str_replace('-', '\-', $up);
preg_match_all("#\.{$up}webStandard\s+(span|p|h[1-6])(\.(.+))?(\s+)?{([^}]+)}\s*\/\*(.*)\*\/#mU", $masterContent, $m);
foreach (array_keys($m[1]) as $i) {
$styles[] = array(
'id' => 'master'.$i,
'name' => trim($m[6][$i]),
'tagName' => $m[1][$i],
'className' => $m[3][$i],
'styles' => $m[5][$i],
);
}
return $styles;
} | php | public static function parseMasterStyles($masterContent)
{
$styles = array();
$up = Kwf_Config::getValue('application.uniquePrefix');
if ($up) $up .= '-';
if (strpos($masterContent, ".{$up}webStandard")===false) return $styles;
$up = str_replace('-', '\-', $up);
preg_match_all("#\.{$up}webStandard\s+(span|p|h[1-6])(\.(.+))?(\s+)?{([^}]+)}\s*\/\*(.*)\*\/#mU", $masterContent, $m);
foreach (array_keys($m[1]) as $i) {
$styles[] = array(
'id' => 'master'.$i,
'name' => trim($m[6][$i]),
'tagName' => $m[1][$i],
'className' => $m[3][$i],
'styles' => $m[5][$i],
);
}
return $styles;
} | [
"public",
"static",
"function",
"parseMasterStyles",
"(",
"$",
"masterContent",
")",
"{",
"$",
"styles",
"=",
"array",
"(",
")",
";",
"$",
"up",
"=",
"Kwf_Config",
"::",
"getValue",
"(",
"'application.uniquePrefix'",
")",
";",
"if",
"(",
"$",
"up",
")",
"$",
"up",
".=",
"'-'",
";",
"if",
"(",
"strpos",
"(",
"$",
"masterContent",
",",
"\".{$up}webStandard\"",
")",
"===",
"false",
")",
"return",
"$",
"styles",
";",
"$",
"up",
"=",
"str_replace",
"(",
"'-'",
",",
"'\\-'",
",",
"$",
"up",
")",
";",
"preg_match_all",
"(",
"\"#\\.{$up}webStandard\\s+(span|p|h[1-6])(\\.(.+))?(\\s+)?{([^}]+)}\\s*\\/\\*(.*)\\*\\/#mU\"",
",",
"$",
"masterContent",
",",
"$",
"m",
")",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"m",
"[",
"1",
"]",
")",
"as",
"$",
"i",
")",
"{",
"$",
"styles",
"[",
"]",
"=",
"array",
"(",
"'id'",
"=>",
"'master'",
".",
"$",
"i",
",",
"'name'",
"=>",
"trim",
"(",
"$",
"m",
"[",
"6",
"]",
"[",
"$",
"i",
"]",
")",
",",
"'tagName'",
"=>",
"$",
"m",
"[",
"1",
"]",
"[",
"$",
"i",
"]",
",",
"'className'",
"=>",
"$",
"m",
"[",
"3",
"]",
"[",
"$",
"i",
"]",
",",
"'styles'",
"=>",
"$",
"m",
"[",
"5",
"]",
"[",
"$",
"i",
"]",
",",
")",
";",
"}",
"return",
"$",
"styles",
";",
"}"
] | public fuer test | [
"public",
"fuer",
"test"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Basic/Text/StylesModel.php#L21-L42 |
koala-framework/koala-framework | Kwf/View/Helper/Truncate.php | Kwf_View_Helper_Truncate.truncate | public function truncate($string, $length = 80, $etc = '…', $break_words = false, $middle = false)
{
if ($length === false) return $string;
if ($length == 0) return '';
if (is_array($string)) {
if ($middle !== false) {
throw new Kwf_Exception("Using the 'middle' parameter is not possible when using an array as input");
}
return $this->_truncateArray($string, $length, $etc, $break_words);
}
if (mb_strlen($string) > $length) {
$length -= mb_strlen($etc);
if (!$break_words && !$middle) {
$string = preg_replace('/\s+?(\S+)?$/', '', mb_substr($string, 0, $length+1));
}
if(!$middle) {
return mb_substr($string, 0, $length).$etc;
} else {
return mb_substr($string, 0, $length/2) . $etc . mb_substr($string, -$length/2);
}
} else {
return $string;
}
} | php | public function truncate($string, $length = 80, $etc = '…', $break_words = false, $middle = false)
{
if ($length === false) return $string;
if ($length == 0) return '';
if (is_array($string)) {
if ($middle !== false) {
throw new Kwf_Exception("Using the 'middle' parameter is not possible when using an array as input");
}
return $this->_truncateArray($string, $length, $etc, $break_words);
}
if (mb_strlen($string) > $length) {
$length -= mb_strlen($etc);
if (!$break_words && !$middle) {
$string = preg_replace('/\s+?(\S+)?$/', '', mb_substr($string, 0, $length+1));
}
if(!$middle) {
return mb_substr($string, 0, $length).$etc;
} else {
return mb_substr($string, 0, $length/2) . $etc . mb_substr($string, -$length/2);
}
} else {
return $string;
}
} | [
"public",
"function",
"truncate",
"(",
"$",
"string",
",",
"$",
"length",
"=",
"80",
",",
"$",
"etc",
"=",
"'…', ",
"$",
"r",
"eak_words =",
"f",
"lse, ",
"$",
"i",
"ddle =",
"f",
"lse)",
"",
"{",
"if",
"(",
"$",
"length",
"===",
"false",
")",
"return",
"$",
"string",
";",
"if",
"(",
"$",
"length",
"==",
"0",
")",
"return",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"string",
")",
")",
"{",
"if",
"(",
"$",
"middle",
"!==",
"false",
")",
"{",
"throw",
"new",
"Kwf_Exception",
"(",
"\"Using the 'middle' parameter is not possible when using an array as input\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_truncateArray",
"(",
"$",
"string",
",",
"$",
"length",
",",
"$",
"etc",
",",
"$",
"break_words",
")",
";",
"}",
"if",
"(",
"mb_strlen",
"(",
"$",
"string",
")",
">",
"$",
"length",
")",
"{",
"$",
"length",
"-=",
"mb_strlen",
"(",
"$",
"etc",
")",
";",
"if",
"(",
"!",
"$",
"break_words",
"&&",
"!",
"$",
"middle",
")",
"{",
"$",
"string",
"=",
"preg_replace",
"(",
"'/\\s+?(\\S+)?$/'",
",",
"''",
",",
"mb_substr",
"(",
"$",
"string",
",",
"0",
",",
"$",
"length",
"+",
"1",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"middle",
")",
"{",
"return",
"mb_substr",
"(",
"$",
"string",
",",
"0",
",",
"$",
"length",
")",
".",
"$",
"etc",
";",
"}",
"else",
"{",
"return",
"mb_substr",
"(",
"$",
"string",
",",
"0",
",",
"$",
"length",
"/",
"2",
")",
".",
"$",
"etc",
".",
"mb_substr",
"(",
"$",
"string",
",",
"-",
"$",
"length",
"/",
"2",
")",
";",
"}",
"}",
"else",
"{",
"return",
"$",
"string",
";",
"}",
"}"
] | The truncate method itself.
@todo Possibility to put ready html into $string and act the way like it would be an array
@param string|array $string The Input to be truncated
(string) The string to be truncated
(array) An array of strings to be truncated. Can be one of the following:
array('String text 1', ' - String text 2')
-- or --
array(
array('string' => 'String text 1'),
array('string' => ': String text 2', 'tag' => 'span'),
array('string' => ' - String text 3', 'tag' => 'strong', 'cssClass' => 'thirdPart')
)
@param integer $length The maximum string length that should be returned. Default: 80
@param string $etc The extension of the string if (and only if!) it has been cut. Default: '…' (…)
@param boolean $break_words Wether to break within words or not. Default: false
@param boolean $middle Truncates the string in the middle, not at the end.
Not possible if the first argument is an array. Default: false
@return string $string The truncated string, or the original string if it's shorter than $length. | [
"The",
"truncate",
"method",
"itself",
"."
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/View/Helper/Truncate.php#L29-L54 |
koala-framework/koala-framework | Kwf/Util/Rrd/File.php | Kwf_Util_Rrd_File.createFile | public function createFile($start = null)
{
if (file_exists($this->_fileName)) {
throw new Kwf_Exception("$this->_fileName already exists");
}
$initialValueDates = array();
if (is_null($start)) {
$initialValueDates = $this->_getInitialValueDates();
if (!$initialValueDates) {
$start = time()-1;
} else {
sort($initialValueDates);
$start = $initialValueDates[0]-1;
}
}
$cmd = "rrdtool create $this->_fileName ";
$cmd .= "--start ".$start." ";
$cmd .= "--step ".($this->_interval)." ";
foreach ($this->_fields as $field) {
if (!is_null($field->getHeartbeat())) {
$heartbeat = $field->getHeartbeat();
} else {
$heartbeat = ($this->_interval*2);
}
$cmd .= "DS:".$field->getEscapedName().":".$field->getType().":".$heartbeat.":".$field->getMin().":".($field->getMax())." ";
}
foreach ($this->getRRAs() as $rra) {
if (!isset($rra['method'])) $rra['method'] = 'AVERAGE';
if (!isset($rra['xff'])) $rra['xff'] = '0.6';
$cmd .= "RRA:$rra[method]:$rra[xff]:$rra[steps]:$rra[rows] ";
}
//echo "$cmd<br>\n";
system($cmd, $ret);
if ($ret != 0) throw new Kwf_Exception("Command failed");
foreach ($initialValueDates as $date) {
$this->record($date, $this->getRecordValuesForDate($date));
}
} | php | public function createFile($start = null)
{
if (file_exists($this->_fileName)) {
throw new Kwf_Exception("$this->_fileName already exists");
}
$initialValueDates = array();
if (is_null($start)) {
$initialValueDates = $this->_getInitialValueDates();
if (!$initialValueDates) {
$start = time()-1;
} else {
sort($initialValueDates);
$start = $initialValueDates[0]-1;
}
}
$cmd = "rrdtool create $this->_fileName ";
$cmd .= "--start ".$start." ";
$cmd .= "--step ".($this->_interval)." ";
foreach ($this->_fields as $field) {
if (!is_null($field->getHeartbeat())) {
$heartbeat = $field->getHeartbeat();
} else {
$heartbeat = ($this->_interval*2);
}
$cmd .= "DS:".$field->getEscapedName().":".$field->getType().":".$heartbeat.":".$field->getMin().":".($field->getMax())." ";
}
foreach ($this->getRRAs() as $rra) {
if (!isset($rra['method'])) $rra['method'] = 'AVERAGE';
if (!isset($rra['xff'])) $rra['xff'] = '0.6';
$cmd .= "RRA:$rra[method]:$rra[xff]:$rra[steps]:$rra[rows] ";
}
//echo "$cmd<br>\n";
system($cmd, $ret);
if ($ret != 0) throw new Kwf_Exception("Command failed");
foreach ($initialValueDates as $date) {
$this->record($date, $this->getRecordValuesForDate($date));
}
} | [
"public",
"function",
"createFile",
"(",
"$",
"start",
"=",
"null",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"_fileName",
")",
")",
"{",
"throw",
"new",
"Kwf_Exception",
"(",
"\"$this->_fileName already exists\"",
")",
";",
"}",
"$",
"initialValueDates",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"start",
")",
")",
"{",
"$",
"initialValueDates",
"=",
"$",
"this",
"->",
"_getInitialValueDates",
"(",
")",
";",
"if",
"(",
"!",
"$",
"initialValueDates",
")",
"{",
"$",
"start",
"=",
"time",
"(",
")",
"-",
"1",
";",
"}",
"else",
"{",
"sort",
"(",
"$",
"initialValueDates",
")",
";",
"$",
"start",
"=",
"$",
"initialValueDates",
"[",
"0",
"]",
"-",
"1",
";",
"}",
"}",
"$",
"cmd",
"=",
"\"rrdtool create $this->_fileName \"",
";",
"$",
"cmd",
".=",
"\"--start \"",
".",
"$",
"start",
".",
"\" \"",
";",
"$",
"cmd",
".=",
"\"--step \"",
".",
"(",
"$",
"this",
"->",
"_interval",
")",
".",
"\" \"",
";",
"foreach",
"(",
"$",
"this",
"->",
"_fields",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"field",
"->",
"getHeartbeat",
"(",
")",
")",
")",
"{",
"$",
"heartbeat",
"=",
"$",
"field",
"->",
"getHeartbeat",
"(",
")",
";",
"}",
"else",
"{",
"$",
"heartbeat",
"=",
"(",
"$",
"this",
"->",
"_interval",
"*",
"2",
")",
";",
"}",
"$",
"cmd",
".=",
"\"DS:\"",
".",
"$",
"field",
"->",
"getEscapedName",
"(",
")",
".",
"\":\"",
".",
"$",
"field",
"->",
"getType",
"(",
")",
".",
"\":\"",
".",
"$",
"heartbeat",
".",
"\":\"",
".",
"$",
"field",
"->",
"getMin",
"(",
")",
".",
"\":\"",
".",
"(",
"$",
"field",
"->",
"getMax",
"(",
")",
")",
".",
"\" \"",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getRRAs",
"(",
")",
"as",
"$",
"rra",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"rra",
"[",
"'method'",
"]",
")",
")",
"$",
"rra",
"[",
"'method'",
"]",
"=",
"'AVERAGE'",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"rra",
"[",
"'xff'",
"]",
")",
")",
"$",
"rra",
"[",
"'xff'",
"]",
"=",
"'0.6'",
";",
"$",
"cmd",
".=",
"\"RRA:$rra[method]:$rra[xff]:$rra[steps]:$rra[rows] \"",
";",
"}",
"//echo \"$cmd<br>\\n\";",
"system",
"(",
"$",
"cmd",
",",
"$",
"ret",
")",
";",
"if",
"(",
"$",
"ret",
"!=",
"0",
")",
"throw",
"new",
"Kwf_Exception",
"(",
"\"Command failed\"",
")",
";",
"foreach",
"(",
"$",
"initialValueDates",
"as",
"$",
"date",
")",
"{",
"$",
"this",
"->",
"record",
"(",
"$",
"date",
",",
"$",
"this",
"->",
"getRecordValuesForDate",
"(",
"$",
"date",
")",
")",
";",
"}",
"}"
] | erstellt rrd Datei
wenn kein start-timestamp übergeben wird dieser automatisch ermittelt
und per _getInitialValueDates die datei für die vergangenheit befüllt
@param int start-timestamp, sollte normalerweise null sein | [
"erstellt",
"rrd",
"Datei"
] | train | https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Util/Rrd/File.php#L100-L140 |
DeveloperCielo/API-3.0-PHP | src/Cielo/API30/Ecommerce/Request/QuerySaleRequest.php | QuerySaleRequest.execute | public function execute($paymentId)
{
$url = $this->environment->getApiQueryURL() . '1/sales/' . $paymentId;
return $this->sendRequest('GET', $url);
} | php | public function execute($paymentId)
{
$url = $this->environment->getApiQueryURL() . '1/sales/' . $paymentId;
return $this->sendRequest('GET', $url);
} | [
"public",
"function",
"execute",
"(",
"$",
"paymentId",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"environment",
"->",
"getApiQueryURL",
"(",
")",
".",
"'1/sales/'",
".",
"$",
"paymentId",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'GET'",
",",
"$",
"url",
")",
";",
"}"
] | @param $paymentId
@return null
@throws \Cielo\API30\Ecommerce\Request\CieloRequestException
@throws \RuntimeException | [
"@param",
"$paymentId"
] | train | https://github.com/DeveloperCielo/API-3.0-PHP/blob/40dd1a00e32d1709db8ba0fd385a744d28b1ab3f/src/Cielo/API30/Ecommerce/Request/QuerySaleRequest.php#L39-L44 |
DeveloperCielo/API-3.0-PHP | src/Cielo/API30/Ecommerce/Sale.php | Sale.fromJson | public static function fromJson($json)
{
$object = json_decode($json);
$sale = new Sale();
$sale->populate($object);
return $sale;
} | php | public static function fromJson($json)
{
$object = json_decode($json);
$sale = new Sale();
$sale->populate($object);
return $sale;
} | [
"public",
"static",
"function",
"fromJson",
"(",
"$",
"json",
")",
"{",
"$",
"object",
"=",
"json_decode",
"(",
"$",
"json",
")",
";",
"$",
"sale",
"=",
"new",
"Sale",
"(",
")",
";",
"$",
"sale",
"->",
"populate",
"(",
"$",
"object",
")",
";",
"return",
"$",
"sale",
";",
"}"
] | @param $json
@return Sale | [
"@param",
"$json"
] | train | https://github.com/DeveloperCielo/API-3.0-PHP/blob/40dd1a00e32d1709db8ba0fd385a744d28b1ab3f/src/Cielo/API30/Ecommerce/Sale.php#L34-L42 |
DeveloperCielo/API-3.0-PHP | src/Cielo/API30/Ecommerce/Sale.php | Sale.payment | public function payment($amount, $installments = 1)
{
$payment = new Payment($amount, $installments);
$this->setPayment($payment);
return $payment;
} | php | public function payment($amount, $installments = 1)
{
$payment = new Payment($amount, $installments);
$this->setPayment($payment);
return $payment;
} | [
"public",
"function",
"payment",
"(",
"$",
"amount",
",",
"$",
"installments",
"=",
"1",
")",
"{",
"$",
"payment",
"=",
"new",
"Payment",
"(",
"$",
"amount",
",",
"$",
"installments",
")",
";",
"$",
"this",
"->",
"setPayment",
"(",
"$",
"payment",
")",
";",
"return",
"$",
"payment",
";",
"}"
] | @param $amount
@param int $installments
@return Payment | [
"@param",
"$amount",
"@param",
"int",
"$installments"
] | train | https://github.com/DeveloperCielo/API-3.0-PHP/blob/40dd1a00e32d1709db8ba0fd385a744d28b1ab3f/src/Cielo/API30/Ecommerce/Sale.php#L94-L101 |
DeveloperCielo/API-3.0-PHP | src/Cielo/API30/Ecommerce/CreditCard.php | CreditCard.fromJson | public static function fromJson($json)
{
$object = \json_decode($json);
$cardToken = new CreditCard();
$cardToken->populate($object);
return $cardToken;
} | php | public static function fromJson($json)
{
$object = \json_decode($json);
$cardToken = new CreditCard();
$cardToken->populate($object);
return $cardToken;
} | [
"public",
"static",
"function",
"fromJson",
"(",
"$",
"json",
")",
"{",
"$",
"object",
"=",
"\\",
"json_decode",
"(",
"$",
"json",
")",
";",
"$",
"cardToken",
"=",
"new",
"CreditCard",
"(",
")",
";",
"$",
"cardToken",
"->",
"populate",
"(",
"$",
"object",
")",
";",
"return",
"$",
"cardToken",
";",
"}"
] | @param string $json
@return CreditCard | [
"@param",
"string",
"$json"
] | train | https://github.com/DeveloperCielo/API-3.0-PHP/blob/40dd1a00e32d1709db8ba0fd385a744d28b1ab3f/src/Cielo/API30/Ecommerce/CreditCard.php#L89-L96 |
DeveloperCielo/API-3.0-PHP | src/Cielo/API30/Ecommerce/Request/AbstractRequest.php | AbstractRequest.readResponse | protected function readResponse($statusCode, $responseBody)
{
$unserialized = null;
switch ($statusCode) {
case 200:
case 201:
$unserialized = $this->unserialize($responseBody);
break;
case 400:
$exception = null;
$response = json_decode($responseBody);
foreach ($response as $error) {
$cieloError = new CieloError($error->Message, $error->Code);
$exception = new CieloRequestException('Request Error', $statusCode, $exception);
$exception->setCieloError($cieloError);
}
throw $exception;
case 404:
throw new CieloRequestException('Resource not found', 404, null);
default:
throw new CieloRequestException('Unknown status', $statusCode);
}
return $unserialized;
} | php | protected function readResponse($statusCode, $responseBody)
{
$unserialized = null;
switch ($statusCode) {
case 200:
case 201:
$unserialized = $this->unserialize($responseBody);
break;
case 400:
$exception = null;
$response = json_decode($responseBody);
foreach ($response as $error) {
$cieloError = new CieloError($error->Message, $error->Code);
$exception = new CieloRequestException('Request Error', $statusCode, $exception);
$exception->setCieloError($cieloError);
}
throw $exception;
case 404:
throw new CieloRequestException('Resource not found', 404, null);
default:
throw new CieloRequestException('Unknown status', $statusCode);
}
return $unserialized;
} | [
"protected",
"function",
"readResponse",
"(",
"$",
"statusCode",
",",
"$",
"responseBody",
")",
"{",
"$",
"unserialized",
"=",
"null",
";",
"switch",
"(",
"$",
"statusCode",
")",
"{",
"case",
"200",
":",
"case",
"201",
":",
"$",
"unserialized",
"=",
"$",
"this",
"->",
"unserialize",
"(",
"$",
"responseBody",
")",
";",
"break",
";",
"case",
"400",
":",
"$",
"exception",
"=",
"null",
";",
"$",
"response",
"=",
"json_decode",
"(",
"$",
"responseBody",
")",
";",
"foreach",
"(",
"$",
"response",
"as",
"$",
"error",
")",
"{",
"$",
"cieloError",
"=",
"new",
"CieloError",
"(",
"$",
"error",
"->",
"Message",
",",
"$",
"error",
"->",
"Code",
")",
";",
"$",
"exception",
"=",
"new",
"CieloRequestException",
"(",
"'Request Error'",
",",
"$",
"statusCode",
",",
"$",
"exception",
")",
";",
"$",
"exception",
"->",
"setCieloError",
"(",
"$",
"cieloError",
")",
";",
"}",
"throw",
"$",
"exception",
";",
"case",
"404",
":",
"throw",
"new",
"CieloRequestException",
"(",
"'Resource not found'",
",",
"404",
",",
"null",
")",
";",
"default",
":",
"throw",
"new",
"CieloRequestException",
"(",
"'Unknown status'",
",",
"$",
"statusCode",
")",
";",
"}",
"return",
"$",
"unserialized",
";",
"}"
] | @param $statusCode
@param $responseBody
@return mixed
@throws CieloRequestException | [
"@param",
"$statusCode",
"@param",
"$responseBody"
] | train | https://github.com/DeveloperCielo/API-3.0-PHP/blob/40dd1a00e32d1709db8ba0fd385a744d28b1ab3f/src/Cielo/API30/Ecommerce/Request/AbstractRequest.php#L101-L128 |
DeveloperCielo/API-3.0-PHP | src/Cielo/API30/Ecommerce/Payment.php | Payment.creditCard | public function creditCard($securityCode, $brand)
{
$card = $this->newCard($securityCode, $brand);
$this->setType(self::PAYMENTTYPE_CREDITCARD);
$this->setCreditCard($card);
return $card;
} | php | public function creditCard($securityCode, $brand)
{
$card = $this->newCard($securityCode, $brand);
$this->setType(self::PAYMENTTYPE_CREDITCARD);
$this->setCreditCard($card);
return $card;
} | [
"public",
"function",
"creditCard",
"(",
"$",
"securityCode",
",",
"$",
"brand",
")",
"{",
"$",
"card",
"=",
"$",
"this",
"->",
"newCard",
"(",
"$",
"securityCode",
",",
"$",
"brand",
")",
";",
"$",
"this",
"->",
"setType",
"(",
"self",
"::",
"PAYMENTTYPE_CREDITCARD",
")",
";",
"$",
"this",
"->",
"setCreditCard",
"(",
"$",
"card",
")",
";",
"return",
"$",
"card",
";",
"}"
] | @param $securityCode
@param $brand
@return CreditCard | [
"@param",
"$securityCode",
"@param",
"$brand"
] | train | https://github.com/DeveloperCielo/API-3.0-PHP/blob/40dd1a00e32d1709db8ba0fd385a744d28b1ab3f/src/Cielo/API30/Ecommerce/Payment.php#L213-L221 |
DeveloperCielo/API-3.0-PHP | src/Cielo/API30/Ecommerce/Payment.php | Payment.newCard | private function newCard($securityCode, $brand)
{
$card = new CreditCard();
$card->setSecurityCode($securityCode);
$card->setBrand($brand);
return $card;
} | php | private function newCard($securityCode, $brand)
{
$card = new CreditCard();
$card->setSecurityCode($securityCode);
$card->setBrand($brand);
return $card;
} | [
"private",
"function",
"newCard",
"(",
"$",
"securityCode",
",",
"$",
"brand",
")",
"{",
"$",
"card",
"=",
"new",
"CreditCard",
"(",
")",
";",
"$",
"card",
"->",
"setSecurityCode",
"(",
"$",
"securityCode",
")",
";",
"$",
"card",
"->",
"setBrand",
"(",
"$",
"brand",
")",
";",
"return",
"$",
"card",
";",
"}"
] | @param $securityCode
@param $brand
@return CreditCard | [
"@param",
"$securityCode",
"@param",
"$brand"
] | train | https://github.com/DeveloperCielo/API-3.0-PHP/blob/40dd1a00e32d1709db8ba0fd385a744d28b1ab3f/src/Cielo/API30/Ecommerce/Payment.php#L229-L236 |
DeveloperCielo/API-3.0-PHP | src/Cielo/API30/Ecommerce/Payment.php | Payment.debitCard | public function debitCard($securityCode, $brand)
{
$card = $this->newCard($securityCode, $brand);
$this->setType(self::PAYMENTTYPE_DEBITCARD);
$this->setDebitCard($card);
return $card;
} | php | public function debitCard($securityCode, $brand)
{
$card = $this->newCard($securityCode, $brand);
$this->setType(self::PAYMENTTYPE_DEBITCARD);
$this->setDebitCard($card);
return $card;
} | [
"public",
"function",
"debitCard",
"(",
"$",
"securityCode",
",",
"$",
"brand",
")",
"{",
"$",
"card",
"=",
"$",
"this",
"->",
"newCard",
"(",
"$",
"securityCode",
",",
"$",
"brand",
")",
";",
"$",
"this",
"->",
"setType",
"(",
"self",
"::",
"PAYMENTTYPE_DEBITCARD",
")",
";",
"$",
"this",
"->",
"setDebitCard",
"(",
"$",
"card",
")",
";",
"return",
"$",
"card",
";",
"}"
] | @param $securityCode
@param $brand
@return CreditCard | [
"@param",
"$securityCode",
"@param",
"$brand"
] | train | https://github.com/DeveloperCielo/API-3.0-PHP/blob/40dd1a00e32d1709db8ba0fd385a744d28b1ab3f/src/Cielo/API30/Ecommerce/Payment.php#L244-L252 |
DeveloperCielo/API-3.0-PHP | src/Cielo/API30/Ecommerce/Payment.php | Payment.recurrentPayment | public function recurrentPayment($authorizeNow = true)
{
$recurrentPayment = new RecurrentPayment($authorizeNow);
$this->setRecurrentPayment($recurrentPayment);
return $recurrentPayment;
} | php | public function recurrentPayment($authorizeNow = true)
{
$recurrentPayment = new RecurrentPayment($authorizeNow);
$this->setRecurrentPayment($recurrentPayment);
return $recurrentPayment;
} | [
"public",
"function",
"recurrentPayment",
"(",
"$",
"authorizeNow",
"=",
"true",
")",
"{",
"$",
"recurrentPayment",
"=",
"new",
"RecurrentPayment",
"(",
"$",
"authorizeNow",
")",
";",
"$",
"this",
"->",
"setRecurrentPayment",
"(",
"$",
"recurrentPayment",
")",
";",
"return",
"$",
"recurrentPayment",
";",
"}"
] | @param bool $authorizeNow
@return RecurrentPayment | [
"@param",
"bool",
"$authorizeNow"
] | train | https://github.com/DeveloperCielo/API-3.0-PHP/blob/40dd1a00e32d1709db8ba0fd385a744d28b1ab3f/src/Cielo/API30/Ecommerce/Payment.php#L259-L266 |
DeveloperCielo/API-3.0-PHP | src/Cielo/API30/Ecommerce/RecurrentPayment.php | RecurrentPayment.fromJson | public static function fromJson($json)
{
$object = json_decode($json);
$recurrentPayment = new RecurrentPayment();
if (isset($object->RecurrentPayment)) {
$recurrentPayment->populate($object->RecurrentPayment);
}
return $recurrentPayment;
} | php | public static function fromJson($json)
{
$object = json_decode($json);
$recurrentPayment = new RecurrentPayment();
if (isset($object->RecurrentPayment)) {
$recurrentPayment->populate($object->RecurrentPayment);
}
return $recurrentPayment;
} | [
"public",
"static",
"function",
"fromJson",
"(",
"$",
"json",
")",
"{",
"$",
"object",
"=",
"json_decode",
"(",
"$",
"json",
")",
";",
"$",
"recurrentPayment",
"=",
"new",
"RecurrentPayment",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"RecurrentPayment",
")",
")",
"{",
"$",
"recurrentPayment",
"->",
"populate",
"(",
"$",
"object",
"->",
"RecurrentPayment",
")",
";",
"}",
"return",
"$",
"recurrentPayment",
";",
"}"
] | @param $json
@return RecurrentPayment | [
"@param",
"$json"
] | train | https://github.com/DeveloperCielo/API-3.0-PHP/blob/40dd1a00e32d1709db8ba0fd385a744d28b1ab3f/src/Cielo/API30/Ecommerce/RecurrentPayment.php#L58-L69 |
DeveloperCielo/API-3.0-PHP | src/Cielo/API30/Ecommerce/Request/CreateSaleRequest.php | CreateSaleRequest.execute | public function execute($sale)
{
$url = $this->environment->getApiUrl() . '1/sales/';
return $this->sendRequest('POST', $url, $sale);
} | php | public function execute($sale)
{
$url = $this->environment->getApiUrl() . '1/sales/';
return $this->sendRequest('POST', $url, $sale);
} | [
"public",
"function",
"execute",
"(",
"$",
"sale",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"environment",
"->",
"getApiUrl",
"(",
")",
".",
"'1/sales/'",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'POST'",
",",
"$",
"url",
",",
"$",
"sale",
")",
";",
"}"
] | @param $sale
@return null
@throws \Cielo\API30\Ecommerce\Request\CieloRequestException
@throws \RuntimeException | [
"@param",
"$sale"
] | train | https://github.com/DeveloperCielo/API-3.0-PHP/blob/40dd1a00e32d1709db8ba0fd385a744d28b1ab3f/src/Cielo/API30/Ecommerce/Request/CreateSaleRequest.php#L39-L44 |
DeveloperCielo/API-3.0-PHP | src/Cielo/API30/Ecommerce/CieloEcommerce.php | CieloEcommerce.createSale | public function createSale(Sale $sale)
{
$createSaleRequest = new CreateSaleRequest($this->merchant, $this->environment);
return $createSaleRequest->execute($sale);
} | php | public function createSale(Sale $sale)
{
$createSaleRequest = new CreateSaleRequest($this->merchant, $this->environment);
return $createSaleRequest->execute($sale);
} | [
"public",
"function",
"createSale",
"(",
"Sale",
"$",
"sale",
")",
"{",
"$",
"createSaleRequest",
"=",
"new",
"CreateSaleRequest",
"(",
"$",
"this",
"->",
"merchant",
",",
"$",
"this",
"->",
"environment",
")",
";",
"return",
"$",
"createSaleRequest",
"->",
"execute",
"(",
"$",
"sale",
")",
";",
"}"
] | Send the Sale to be created and return the Sale with tid and the status
returned by Cielo.
@param Sale $sale
The preconfigured Sale
@return Sale The Sale with authorization, tid, etc. returned by Cielo.
@throws \Cielo\API30\Ecommerce\Request\CieloRequestException if anything gets wrong.
@see <a href=
"https://developercielo.github.io/Webservice-3.0/english.html#error-codes">Error
Codes</a> | [
"Send",
"the",
"Sale",
"to",
"be",
"created",
"and",
"return",
"the",
"Sale",
"with",
"tid",
"and",
"the",
"status",
"returned",
"by",
"Cielo",
"."
] | train | https://github.com/DeveloperCielo/API-3.0-PHP/blob/40dd1a00e32d1709db8ba0fd385a744d28b1ab3f/src/Cielo/API30/Ecommerce/CieloEcommerce.php#L57-L62 |
DeveloperCielo/API-3.0-PHP | src/Cielo/API30/Ecommerce/CieloEcommerce.php | CieloEcommerce.getSale | public function getSale($paymentId)
{
$querySaleRequest = new QuerySaleRequest($this->merchant, $this->environment);
return $querySaleRequest->execute($paymentId);
} | php | public function getSale($paymentId)
{
$querySaleRequest = new QuerySaleRequest($this->merchant, $this->environment);
return $querySaleRequest->execute($paymentId);
} | [
"public",
"function",
"getSale",
"(",
"$",
"paymentId",
")",
"{",
"$",
"querySaleRequest",
"=",
"new",
"QuerySaleRequest",
"(",
"$",
"this",
"->",
"merchant",
",",
"$",
"this",
"->",
"environment",
")",
";",
"return",
"$",
"querySaleRequest",
"->",
"execute",
"(",
"$",
"paymentId",
")",
";",
"}"
] | Query a Sale on Cielo by paymentId
@param string $paymentId
The paymentId to be queried
@return Sale The Sale with authorization, tid, etc. returned by Cielo.
@throws \Cielo\API30\Ecommerce\Request\CieloRequestException if anything gets wrong.
@see <a href=
"https://developercielo.github.io/Webservice-3.0/english.html#error-codes">Error
Codes</a> | [
"Query",
"a",
"Sale",
"on",
"Cielo",
"by",
"paymentId"
] | train | https://github.com/DeveloperCielo/API-3.0-PHP/blob/40dd1a00e32d1709db8ba0fd385a744d28b1ab3f/src/Cielo/API30/Ecommerce/CieloEcommerce.php#L78-L83 |
DeveloperCielo/API-3.0-PHP | src/Cielo/API30/Ecommerce/CieloEcommerce.php | CieloEcommerce.getRecurrentPayment | public function getRecurrentPayment($recurrentPaymentId)
{
$queryRecurrentPaymentRequest = new queryRecurrentPaymentRequest($this->merchant, $this->environment);
return $queryRecurrentPaymentRequest->execute($recurrentPaymentId);
} | php | public function getRecurrentPayment($recurrentPaymentId)
{
$queryRecurrentPaymentRequest = new queryRecurrentPaymentRequest($this->merchant, $this->environment);
return $queryRecurrentPaymentRequest->execute($recurrentPaymentId);
} | [
"public",
"function",
"getRecurrentPayment",
"(",
"$",
"recurrentPaymentId",
")",
"{",
"$",
"queryRecurrentPaymentRequest",
"=",
"new",
"queryRecurrentPaymentRequest",
"(",
"$",
"this",
"->",
"merchant",
",",
"$",
"this",
"->",
"environment",
")",
";",
"return",
"$",
"queryRecurrentPaymentRequest",
"->",
"execute",
"(",
"$",
"recurrentPaymentId",
")",
";",
"}"
] | Query a RecurrentPayment on Cielo by RecurrentPaymentId
@param string $recurrentPaymentId
The RecurrentPaymentId to be queried
@return \Cielo\API30\Ecommerce\RecurrentPayment
The RecurrentPayment with authorization, tid, etc. returned by Cielo.
@throws \Cielo\API30\Ecommerce\Request\CieloRequestException if anything gets wrong.
@see <a href=
"https://developercielo.github.io/Webservice-3.0/english.html#error-codes">Error
Codes</a> | [
"Query",
"a",
"RecurrentPayment",
"on",
"Cielo",
"by",
"RecurrentPaymentId"
] | train | https://github.com/DeveloperCielo/API-3.0-PHP/blob/40dd1a00e32d1709db8ba0fd385a744d28b1ab3f/src/Cielo/API30/Ecommerce/CieloEcommerce.php#L100-L105 |
DeveloperCielo/API-3.0-PHP | src/Cielo/API30/Ecommerce/CieloEcommerce.php | CieloEcommerce.cancelSale | public function cancelSale($paymentId, $amount = null)
{
$updateSaleRequest = new UpdateSaleRequest('void', $this->merchant, $this->environment);
$updateSaleRequest->setAmount($amount);
return $updateSaleRequest->execute($paymentId);
} | php | public function cancelSale($paymentId, $amount = null)
{
$updateSaleRequest = new UpdateSaleRequest('void', $this->merchant, $this->environment);
$updateSaleRequest->setAmount($amount);
return $updateSaleRequest->execute($paymentId);
} | [
"public",
"function",
"cancelSale",
"(",
"$",
"paymentId",
",",
"$",
"amount",
"=",
"null",
")",
"{",
"$",
"updateSaleRequest",
"=",
"new",
"UpdateSaleRequest",
"(",
"'void'",
",",
"$",
"this",
"->",
"merchant",
",",
"$",
"this",
"->",
"environment",
")",
";",
"$",
"updateSaleRequest",
"->",
"setAmount",
"(",
"$",
"amount",
")",
";",
"return",
"$",
"updateSaleRequest",
"->",
"execute",
"(",
"$",
"paymentId",
")",
";",
"}"
] | Cancel a Sale on Cielo by paymentId and speficying the amount
@param string $paymentId
The paymentId to be queried
@param integer $amount
Order value in cents
@return Sale The Sale with authorization, tid, etc. returned by Cielo.
@throws \Cielo\API30\Ecommerce\Request\CieloRequestException if anything gets wrong.
@see <a href=
"https://developercielo.github.io/Webservice-3.0/english.html#error-codes">Error
Codes</a> | [
"Cancel",
"a",
"Sale",
"on",
"Cielo",
"by",
"paymentId",
"and",
"speficying",
"the",
"amount"
] | train | https://github.com/DeveloperCielo/API-3.0-PHP/blob/40dd1a00e32d1709db8ba0fd385a744d28b1ab3f/src/Cielo/API30/Ecommerce/CieloEcommerce.php#L123-L130 |
DeveloperCielo/API-3.0-PHP | src/Cielo/API30/Ecommerce/CieloEcommerce.php | CieloEcommerce.captureSale | public function captureSale($paymentId, $amount = null, $serviceTaxAmount = null)
{
$updateSaleRequest = new UpdateSaleRequest('capture', $this->merchant, $this->environment);
$updateSaleRequest->setAmount($amount);
$updateSaleRequest->setServiceTaxAmount($serviceTaxAmount);
return $updateSaleRequest->execute($paymentId);
} | php | public function captureSale($paymentId, $amount = null, $serviceTaxAmount = null)
{
$updateSaleRequest = new UpdateSaleRequest('capture', $this->merchant, $this->environment);
$updateSaleRequest->setAmount($amount);
$updateSaleRequest->setServiceTaxAmount($serviceTaxAmount);
return $updateSaleRequest->execute($paymentId);
} | [
"public",
"function",
"captureSale",
"(",
"$",
"paymentId",
",",
"$",
"amount",
"=",
"null",
",",
"$",
"serviceTaxAmount",
"=",
"null",
")",
"{",
"$",
"updateSaleRequest",
"=",
"new",
"UpdateSaleRequest",
"(",
"'capture'",
",",
"$",
"this",
"->",
"merchant",
",",
"$",
"this",
"->",
"environment",
")",
";",
"$",
"updateSaleRequest",
"->",
"setAmount",
"(",
"$",
"amount",
")",
";",
"$",
"updateSaleRequest",
"->",
"setServiceTaxAmount",
"(",
"$",
"serviceTaxAmount",
")",
";",
"return",
"$",
"updateSaleRequest",
"->",
"execute",
"(",
"$",
"paymentId",
")",
";",
"}"
] | Capture a Sale on Cielo by paymentId and specifying the amount and the
serviceTaxAmount
@param string $paymentId
The paymentId to be captured
@param integer $amount
Amount of the authorization to be captured
@param integer $serviceTaxAmount
Amount of the authorization should be destined for the service
charge
@return \Cielo\API30\Ecommerce\Payment The captured Payment.
@throws \Cielo\API30\Ecommerce\Request\CieloRequestException if anything gets wrong.
@see <a href=
"https://developercielo.github.io/Webservice-3.0/english.html#error-codes">Error
Codes</a> | [
"Capture",
"a",
"Sale",
"on",
"Cielo",
"by",
"paymentId",
"and",
"specifying",
"the",
"amount",
"and",
"the",
"serviceTaxAmount"
] | train | https://github.com/DeveloperCielo/API-3.0-PHP/blob/40dd1a00e32d1709db8ba0fd385a744d28b1ab3f/src/Cielo/API30/Ecommerce/CieloEcommerce.php#L153-L161 |
DeveloperCielo/API-3.0-PHP | src/Cielo/API30/Ecommerce/CieloEcommerce.php | CieloEcommerce.tokenizeCard | public function tokenizeCard(CreditCard $card)
{
$tokenizeCardRequest = new TokenizeCardRequest($this->merchant, $this->environment);
return $tokenizeCardRequest->execute($card);
} | php | public function tokenizeCard(CreditCard $card)
{
$tokenizeCardRequest = new TokenizeCardRequest($this->merchant, $this->environment);
return $tokenizeCardRequest->execute($card);
} | [
"public",
"function",
"tokenizeCard",
"(",
"CreditCard",
"$",
"card",
")",
"{",
"$",
"tokenizeCardRequest",
"=",
"new",
"TokenizeCardRequest",
"(",
"$",
"this",
"->",
"merchant",
",",
"$",
"this",
"->",
"environment",
")",
";",
"return",
"$",
"tokenizeCardRequest",
"->",
"execute",
"(",
"$",
"card",
")",
";",
"}"
] | @param CreditCard $card
@return CreditCard | [
"@param",
"CreditCard",
"$card"
] | train | https://github.com/DeveloperCielo/API-3.0-PHP/blob/40dd1a00e32d1709db8ba0fd385a744d28b1ab3f/src/Cielo/API30/Ecommerce/CieloEcommerce.php#L168-L173 |
DeveloperCielo/API-3.0-PHP | src/Cielo/API30/Ecommerce/Request/UpdateSaleRequest.php | UpdateSaleRequest.execute | public function execute($paymentId)
{
$url = $this->environment->getApiUrl() . '1/sales/' . $paymentId . '/' . $this->type;
$params = [];
if ($this->amount != null) {
$params['amount'] = $this->amount;
}
if ($this->serviceTaxAmount != null) {
$params['serviceTaxAmount'] = $this->serviceTaxAmount;
}
$url .= '?' . http_build_query($params);
return $this->sendRequest('PUT', $url);
} | php | public function execute($paymentId)
{
$url = $this->environment->getApiUrl() . '1/sales/' . $paymentId . '/' . $this->type;
$params = [];
if ($this->amount != null) {
$params['amount'] = $this->amount;
}
if ($this->serviceTaxAmount != null) {
$params['serviceTaxAmount'] = $this->serviceTaxAmount;
}
$url .= '?' . http_build_query($params);
return $this->sendRequest('PUT', $url);
} | [
"public",
"function",
"execute",
"(",
"$",
"paymentId",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"environment",
"->",
"getApiUrl",
"(",
")",
".",
"'1/sales/'",
".",
"$",
"paymentId",
".",
"'/'",
".",
"$",
"this",
"->",
"type",
";",
"$",
"params",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"amount",
"!=",
"null",
")",
"{",
"$",
"params",
"[",
"'amount'",
"]",
"=",
"$",
"this",
"->",
"amount",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"serviceTaxAmount",
"!=",
"null",
")",
"{",
"$",
"params",
"[",
"'serviceTaxAmount'",
"]",
"=",
"$",
"this",
"->",
"serviceTaxAmount",
";",
"}",
"$",
"url",
".=",
"'?'",
".",
"http_build_query",
"(",
"$",
"params",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'PUT'",
",",
"$",
"url",
")",
";",
"}"
] | @param $paymentId
@return null
@throws \Cielo\API30\Ecommerce\Request\CieloRequestException
@throws \RuntimeException | [
"@param",
"$paymentId"
] | train | https://github.com/DeveloperCielo/API-3.0-PHP/blob/40dd1a00e32d1709db8ba0fd385a744d28b1ab3f/src/Cielo/API30/Ecommerce/Request/UpdateSaleRequest.php#L47-L63 |
ClassPreloader/ClassPreloader | src/Parser/FileVisitor.php | FileVisitor.enterNode | public function enterNode(Node $node)
{
if ($node instanceof FileNode) {
if ($this->skip) {
throw new FileConstantException();
}
return new StringNode($this->getFilename());
}
} | php | public function enterNode(Node $node)
{
if ($node instanceof FileNode) {
if ($this->skip) {
throw new FileConstantException();
}
return new StringNode($this->getFilename());
}
} | [
"public",
"function",
"enterNode",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"FileNode",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"skip",
")",
"{",
"throw",
"new",
"FileConstantException",
"(",
")",
";",
"}",
"return",
"new",
"StringNode",
"(",
"$",
"this",
"->",
"getFilename",
"(",
")",
")",
";",
"}",
"}"
] | Enter and modify the node.
@param \PhpParser\Node $node
@throws \ClassPreloader\Exceptions\FileConstantException
@return \PhpParser\Node\Scalar\String_|null | [
"Enter",
"and",
"modify",
"the",
"node",
"."
] | train | https://github.com/ClassPreloader/ClassPreloader/blob/4729e438e0ada350f91148e7d4bb9809342575ff/src/Parser/FileVisitor.php#L55-L64 |
ClassPreloader/ClassPreloader | src/ClassLoader.php | ClassLoader.getIncludes | public static function getIncludes($func)
{
$loader = new static();
call_user_func($func, $loader);
$loader->unregister();
$config = new Config();
foreach ($loader->getFilenames() as $file) {
$config->addFile($file);
}
return $config;
} | php | public static function getIncludes($func)
{
$loader = new static();
call_user_func($func, $loader);
$loader->unregister();
$config = new Config();
foreach ($loader->getFilenames() as $file) {
$config->addFile($file);
}
return $config;
} | [
"public",
"static",
"function",
"getIncludes",
"(",
"$",
"func",
")",
"{",
"$",
"loader",
"=",
"new",
"static",
"(",
")",
";",
"call_user_func",
"(",
"$",
"func",
",",
"$",
"loader",
")",
";",
"$",
"loader",
"->",
"unregister",
"(",
")",
";",
"$",
"config",
"=",
"new",
"Config",
"(",
")",
";",
"foreach",
"(",
"$",
"loader",
"->",
"getFilenames",
"(",
")",
"as",
"$",
"file",
")",
"{",
"$",
"config",
"->",
"addFile",
"(",
"$",
"file",
")",
";",
"}",
"return",
"$",
"config",
";",
"}"
] | Wrap a block of code in the autoloader and get a list of loaded classes.
@param callable $func
@return \ClassPreloader\Config | [
"Wrap",
"a",
"block",
"of",
"code",
"in",
"the",
"autoloader",
"and",
"get",
"a",
"list",
"of",
"loaded",
"classes",
"."
] | train | https://github.com/ClassPreloader/ClassPreloader/blob/4729e438e0ada350f91148e7d4bb9809342575ff/src/ClassLoader.php#L60-L72 |
ClassPreloader/ClassPreloader | src/ClassLoader.php | ClassLoader.loadClass | public function loadClass($class)
{
foreach (spl_autoload_functions() as $func) {
if (is_array($func) && $func[0] === $this) {
continue;
}
$this->classList->push($class);
if (call_user_func($func, $class)) {
break;
}
}
$this->classList->next();
return true;
} | php | public function loadClass($class)
{
foreach (spl_autoload_functions() as $func) {
if (is_array($func) && $func[0] === $this) {
continue;
}
$this->classList->push($class);
if (call_user_func($func, $class)) {
break;
}
}
$this->classList->next();
return true;
} | [
"public",
"function",
"loadClass",
"(",
"$",
"class",
")",
"{",
"foreach",
"(",
"spl_autoload_functions",
"(",
")",
"as",
"$",
"func",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"func",
")",
"&&",
"$",
"func",
"[",
"0",
"]",
"===",
"$",
"this",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"classList",
"->",
"push",
"(",
"$",
"class",
")",
";",
"if",
"(",
"call_user_func",
"(",
"$",
"func",
",",
"$",
"class",
")",
")",
"{",
"break",
";",
"}",
"}",
"$",
"this",
"->",
"classList",
"->",
"next",
"(",
")",
";",
"return",
"true",
";",
"}"
] | Loads the given class, interface or trait.
We'll return true if it was loaded.
@param string $class
@return bool | [
"Loads",
"the",
"given",
"class",
"interface",
"or",
"trait",
"."
] | train | https://github.com/ClassPreloader/ClassPreloader/blob/4729e438e0ada350f91148e7d4bb9809342575ff/src/ClassLoader.php#L103-L118 |
ClassPreloader/ClassPreloader | src/ClassLoader.php | ClassLoader.getFilenames | public function getFilenames()
{
$files = [];
foreach ($this->classList->getClasses() as $class) {
// Push interfaces before classes if not already loaded
try {
$r = new \ReflectionClass($class);
foreach ($r->getInterfaces() as $inf) {
$name = $inf->getFileName();
if ($name && !in_array($name, $files)) {
$files[] = $name;
}
}
if (!in_array($r->getFileName(), $files)) {
$files[] = $r->getFileName();
}
} catch (\ReflectionException $e) {
// We ignore all exceptions related to reflection because in
// some cases class doesn't need to exist. We're ignoring all
// problems with classes, interfaces and traits.
}
}
return $files;
} | php | public function getFilenames()
{
$files = [];
foreach ($this->classList->getClasses() as $class) {
// Push interfaces before classes if not already loaded
try {
$r = new \ReflectionClass($class);
foreach ($r->getInterfaces() as $inf) {
$name = $inf->getFileName();
if ($name && !in_array($name, $files)) {
$files[] = $name;
}
}
if (!in_array($r->getFileName(), $files)) {
$files[] = $r->getFileName();
}
} catch (\ReflectionException $e) {
// We ignore all exceptions related to reflection because in
// some cases class doesn't need to exist. We're ignoring all
// problems with classes, interfaces and traits.
}
}
return $files;
} | [
"public",
"function",
"getFilenames",
"(",
")",
"{",
"$",
"files",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"classList",
"->",
"getClasses",
"(",
")",
"as",
"$",
"class",
")",
"{",
"// Push interfaces before classes if not already loaded",
"try",
"{",
"$",
"r",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"foreach",
"(",
"$",
"r",
"->",
"getInterfaces",
"(",
")",
"as",
"$",
"inf",
")",
"{",
"$",
"name",
"=",
"$",
"inf",
"->",
"getFileName",
"(",
")",
";",
"if",
"(",
"$",
"name",
"&&",
"!",
"in_array",
"(",
"$",
"name",
",",
"$",
"files",
")",
")",
"{",
"$",
"files",
"[",
"]",
"=",
"$",
"name",
";",
"}",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"r",
"->",
"getFileName",
"(",
")",
",",
"$",
"files",
")",
")",
"{",
"$",
"files",
"[",
"]",
"=",
"$",
"r",
"->",
"getFileName",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"ReflectionException",
"$",
"e",
")",
"{",
"// We ignore all exceptions related to reflection because in",
"// some cases class doesn't need to exist. We're ignoring all",
"// problems with classes, interfaces and traits.",
"}",
"}",
"return",
"$",
"files",
";",
"}"
] | Get an array of loaded file names in order of loading.
@return array | [
"Get",
"an",
"array",
"of",
"loaded",
"file",
"names",
"in",
"order",
"of",
"loading",
"."
] | train | https://github.com/ClassPreloader/ClassPreloader/blob/4729e438e0ada350f91148e7d4bb9809342575ff/src/ClassLoader.php#L125-L149 |
ClassPreloader/ClassPreloader | src/Config.php | Config.getFilenames | public function getFilenames()
{
$filenames = [];
foreach ($this->filenames as $f) {
foreach ($this->inclusiveFilters as $filter) {
if (!preg_match($filter, $f)) {
continue 2;
}
}
foreach ($this->exclusiveFilters as $filter) {
if (preg_match($filter, $f)) {
continue 2;
}
}
$filenames[] = $f;
}
return $filenames;
} | php | public function getFilenames()
{
$filenames = [];
foreach ($this->filenames as $f) {
foreach ($this->inclusiveFilters as $filter) {
if (!preg_match($filter, $f)) {
continue 2;
}
}
foreach ($this->exclusiveFilters as $filter) {
if (preg_match($filter, $f)) {
continue 2;
}
}
$filenames[] = $f;
}
return $filenames;
} | [
"public",
"function",
"getFilenames",
"(",
")",
"{",
"$",
"filenames",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"filenames",
"as",
"$",
"f",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"inclusiveFilters",
"as",
"$",
"filter",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"$",
"filter",
",",
"$",
"f",
")",
")",
"{",
"continue",
"2",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"exclusiveFilters",
"as",
"$",
"filter",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"filter",
",",
"$",
"f",
")",
")",
"{",
"continue",
"2",
";",
"}",
"}",
"$",
"filenames",
"[",
"]",
"=",
"$",
"f",
";",
"}",
"return",
"$",
"filenames",
";",
"}"
] | Get an array of file names that satisfy any added filters.
@return array | [
"Get",
"an",
"array",
"of",
"file",
"names",
"that",
"satisfy",
"any",
"added",
"filters",
"."
] | train | https://github.com/ClassPreloader/ClassPreloader/blob/4729e438e0ada350f91148e7d4bb9809342575ff/src/Config.php#L60-L78 |
ClassPreloader/ClassPreloader | src/Parser/DirVisitor.php | DirVisitor.enterNode | public function enterNode(Node $node)
{
if ($node instanceof DirNode) {
if ($this->skip) {
throw new DirConstantException();
}
return new StringNode($this->getDir());
}
} | php | public function enterNode(Node $node)
{
if ($node instanceof DirNode) {
if ($this->skip) {
throw new DirConstantException();
}
return new StringNode($this->getDir());
}
} | [
"public",
"function",
"enterNode",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"DirNode",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"skip",
")",
"{",
"throw",
"new",
"DirConstantException",
"(",
")",
";",
"}",
"return",
"new",
"StringNode",
"(",
"$",
"this",
"->",
"getDir",
"(",
")",
")",
";",
"}",
"}"
] | Enter and modify the node.
@param \PhpParser\Node $node
@throws \ClassPreloader\Exceptions\DirConstantException
@return \PhpParser\Node\Scalar\String_|null | [
"Enter",
"and",
"modify",
"the",
"node",
"."
] | train | https://github.com/ClassPreloader/ClassPreloader/blob/4729e438e0ada350f91148e7d4bb9809342575ff/src/Parser/DirVisitor.php#L55-L64 |
ClassPreloader/ClassPreloader | src/Parser/StrictTypesVisitor.php | StrictTypesVisitor.enterNode | public function enterNode(Node $node)
{
if ($node instanceof DeclareDeclare && ($node->getLine() === 1 || $node->getLine() === 2)) {
throw new StrictTypesException();
}
} | php | public function enterNode(Node $node)
{
if ($node instanceof DeclareDeclare && ($node->getLine() === 1 || $node->getLine() === 2)) {
throw new StrictTypesException();
}
} | [
"public",
"function",
"enterNode",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"DeclareDeclare",
"&&",
"(",
"$",
"node",
"->",
"getLine",
"(",
")",
"===",
"1",
"||",
"$",
"node",
"->",
"getLine",
"(",
")",
"===",
"2",
")",
")",
"{",
"throw",
"new",
"StrictTypesException",
"(",
")",
";",
"}",
"}"
] | Enter and modify the node.
@param \PhpParser\Node $node
@throws \ClassPreloader\Exceptions\StrictTypesException
@return null | [
"Enter",
"and",
"modify",
"the",
"node",
"."
] | train | https://github.com/ClassPreloader/ClassPreloader/blob/4729e438e0ada350f91148e7d4bb9809342575ff/src/Parser/StrictTypesVisitor.php#L35-L40 |
ClassPreloader/ClassPreloader | src/Parser/NodeTraverser.php | NodeTraverser.traverseFile | public function traverseFile(array $nodes, $filename)
{
// Set the correct state on each visitor
foreach ($this->visitors as $visitor) {
if ($visitor instanceof AbstractNodeVisitor) {
$visitor->setFilename($filename);
}
}
return $this->traverse($nodes);
} | php | public function traverseFile(array $nodes, $filename)
{
// Set the correct state on each visitor
foreach ($this->visitors as $visitor) {
if ($visitor instanceof AbstractNodeVisitor) {
$visitor->setFilename($filename);
}
}
return $this->traverse($nodes);
} | [
"public",
"function",
"traverseFile",
"(",
"array",
"$",
"nodes",
",",
"$",
"filename",
")",
"{",
"// Set the correct state on each visitor",
"foreach",
"(",
"$",
"this",
"->",
"visitors",
"as",
"$",
"visitor",
")",
"{",
"if",
"(",
"$",
"visitor",
"instanceof",
"AbstractNodeVisitor",
")",
"{",
"$",
"visitor",
"->",
"setFilename",
"(",
"$",
"filename",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"traverse",
"(",
"$",
"nodes",
")",
";",
"}"
] | Transverse the file.
@param array $nodes
@param string $filename
@return \PhpParser\Node[] | [
"Transverse",
"the",
"file",
"."
] | train | https://github.com/ClassPreloader/ClassPreloader/blob/4729e438e0ada350f91148e7d4bb9809342575ff/src/Parser/NodeTraverser.php#L32-L42 |
ClassPreloader/ClassPreloader | src/ClassList.php | ClassList.next | public function next()
{
if (isset($this->current->next)) {
$this->current = $this->current->next;
} else {
$this->current->next = new ClassNode(null, $this->current);
$this->current = $this->current->next;
}
} | php | public function next()
{
if (isset($this->current->next)) {
$this->current = $this->current->next;
} else {
$this->current->next = new ClassNode(null, $this->current);
$this->current = $this->current->next;
}
} | [
"public",
"function",
"next",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"current",
"->",
"next",
")",
")",
"{",
"$",
"this",
"->",
"current",
"=",
"$",
"this",
"->",
"current",
"->",
"next",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"current",
"->",
"next",
"=",
"new",
"ClassNode",
"(",
"null",
",",
"$",
"this",
"->",
"current",
")",
";",
"$",
"this",
"->",
"current",
"=",
"$",
"this",
"->",
"current",
"->",
"next",
";",
"}",
"}"
] | Traverse to the next node in the list.
@return void | [
"Traverse",
"to",
"the",
"next",
"node",
"in",
"the",
"list",
"."
] | train | https://github.com/ClassPreloader/ClassPreloader/blob/4729e438e0ada350f91148e7d4bb9809342575ff/src/ClassList.php#L62-L70 |
ClassPreloader/ClassPreloader | src/ClassList.php | ClassList.push | public function push($value)
{
if (!$this->current->value) {
$this->current->value = $value;
} else {
$temp = $this->current;
$this->current = new ClassNode($value, $temp->prev);
$this->current->next = $temp;
$temp->prev = $this->current;
if ($temp === $this->head) {
$this->head = $this->current;
} else {
$this->current->prev->next = $this->current;
}
}
} | php | public function push($value)
{
if (!$this->current->value) {
$this->current->value = $value;
} else {
$temp = $this->current;
$this->current = new ClassNode($value, $temp->prev);
$this->current->next = $temp;
$temp->prev = $this->current;
if ($temp === $this->head) {
$this->head = $this->current;
} else {
$this->current->prev->next = $this->current;
}
}
} | [
"public",
"function",
"push",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"current",
"->",
"value",
")",
"{",
"$",
"this",
"->",
"current",
"->",
"value",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"temp",
"=",
"$",
"this",
"->",
"current",
";",
"$",
"this",
"->",
"current",
"=",
"new",
"ClassNode",
"(",
"$",
"value",
",",
"$",
"temp",
"->",
"prev",
")",
";",
"$",
"this",
"->",
"current",
"->",
"next",
"=",
"$",
"temp",
";",
"$",
"temp",
"->",
"prev",
"=",
"$",
"this",
"->",
"current",
";",
"if",
"(",
"$",
"temp",
"===",
"$",
"this",
"->",
"head",
")",
"{",
"$",
"this",
"->",
"head",
"=",
"$",
"this",
"->",
"current",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"current",
"->",
"prev",
"->",
"next",
"=",
"$",
"this",
"->",
"current",
";",
"}",
"}",
"}"
] | Insert a value at the current position in the list.
Any currently set value at this position will be pushed back in the list
after the new value.
@param mixed $value
@return void | [
"Insert",
"a",
"value",
"at",
"the",
"current",
"position",
"in",
"the",
"list",
"."
] | train | https://github.com/ClassPreloader/ClassPreloader/blob/4729e438e0ada350f91148e7d4bb9809342575ff/src/ClassList.php#L82-L97 |
ClassPreloader/ClassPreloader | src/ClassList.php | ClassList.getClasses | public function getClasses()
{
$classes = [];
$current = $this->head;
while ($current && $current->value) {
$classes[] = $current->value;
$current = $current->next;
}
return array_filter($classes);
} | php | public function getClasses()
{
$classes = [];
$current = $this->head;
while ($current && $current->value) {
$classes[] = $current->value;
$current = $current->next;
}
return array_filter($classes);
} | [
"public",
"function",
"getClasses",
"(",
")",
"{",
"$",
"classes",
"=",
"[",
"]",
";",
"$",
"current",
"=",
"$",
"this",
"->",
"head",
";",
"while",
"(",
"$",
"current",
"&&",
"$",
"current",
"->",
"value",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"$",
"current",
"->",
"value",
";",
"$",
"current",
"=",
"$",
"current",
"->",
"next",
";",
"}",
"return",
"array_filter",
"(",
"$",
"classes",
")",
";",
"}"
] | Traverse the ClassList and return a list of classes.
@return array | [
"Traverse",
"the",
"ClassList",
"and",
"return",
"a",
"list",
"of",
"classes",
"."
] | train | https://github.com/ClassPreloader/ClassPreloader/blob/4729e438e0ada350f91148e7d4bb9809342575ff/src/ClassList.php#L104-L114 |
ClassPreloader/ClassPreloader | src/Factory.php | Factory.create | public function create(array $options = [])
{
$printer = new PrettyPrinter();
$parser = $this->getParser();
$options = array_merge(['dir' => true, 'file' => true, 'skip' => false, 'strict' => false], $options);
$traverser = $this->getTraverser($options['dir'], $options['file'], $options['skip'], $options['strict']);
return new ClassPreloader($printer, $parser, $traverser);
} | php | public function create(array $options = [])
{
$printer = new PrettyPrinter();
$parser = $this->getParser();
$options = array_merge(['dir' => true, 'file' => true, 'skip' => false, 'strict' => false], $options);
$traverser = $this->getTraverser($options['dir'], $options['file'], $options['skip'], $options['strict']);
return new ClassPreloader($printer, $parser, $traverser);
} | [
"public",
"function",
"create",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"printer",
"=",
"new",
"PrettyPrinter",
"(",
")",
";",
"$",
"parser",
"=",
"$",
"this",
"->",
"getParser",
"(",
")",
";",
"$",
"options",
"=",
"array_merge",
"(",
"[",
"'dir'",
"=>",
"true",
",",
"'file'",
"=>",
"true",
",",
"'skip'",
"=>",
"false",
",",
"'strict'",
"=>",
"false",
"]",
",",
"$",
"options",
")",
";",
"$",
"traverser",
"=",
"$",
"this",
"->",
"getTraverser",
"(",
"$",
"options",
"[",
"'dir'",
"]",
",",
"$",
"options",
"[",
"'file'",
"]",
",",
"$",
"options",
"[",
"'skip'",
"]",
",",
"$",
"options",
"[",
"'strict'",
"]",
")",
";",
"return",
"new",
"ClassPreloader",
"(",
"$",
"printer",
",",
"$",
"parser",
",",
"$",
"traverser",
")",
";",
"}"
] | Create a new class preloader instance.
Any options provided determine how the node traverser is setup.
@param bool[] $options
@return \ClassPreloader\ClassPreloader | [
"Create",
"a",
"new",
"class",
"preloader",
"instance",
"."
] | train | https://github.com/ClassPreloader/ClassPreloader/blob/4729e438e0ada350f91148e7d4bb9809342575ff/src/Factory.php#L40-L51 |
ClassPreloader/ClassPreloader | src/Factory.php | Factory.getTraverser | protected function getTraverser($dir, $file, $skip, $strict)
{
$traverser = new NodeTraverser();
if ($dir) {
$traverser->addVisitor(new DirVisitor($skip));
}
if ($file) {
$traverser->addVisitor(new FileVisitor($skip));
}
if (!$strict) {
$traverser->addVisitor(new StrictTypesVisitor());
}
return $traverser;
} | php | protected function getTraverser($dir, $file, $skip, $strict)
{
$traverser = new NodeTraverser();
if ($dir) {
$traverser->addVisitor(new DirVisitor($skip));
}
if ($file) {
$traverser->addVisitor(new FileVisitor($skip));
}
if (!$strict) {
$traverser->addVisitor(new StrictTypesVisitor());
}
return $traverser;
} | [
"protected",
"function",
"getTraverser",
"(",
"$",
"dir",
",",
"$",
"file",
",",
"$",
"skip",
",",
"$",
"strict",
")",
"{",
"$",
"traverser",
"=",
"new",
"NodeTraverser",
"(",
")",
";",
"if",
"(",
"$",
"dir",
")",
"{",
"$",
"traverser",
"->",
"addVisitor",
"(",
"new",
"DirVisitor",
"(",
"$",
"skip",
")",
")",
";",
"}",
"if",
"(",
"$",
"file",
")",
"{",
"$",
"traverser",
"->",
"addVisitor",
"(",
"new",
"FileVisitor",
"(",
"$",
"skip",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"strict",
")",
"{",
"$",
"traverser",
"->",
"addVisitor",
"(",
"new",
"StrictTypesVisitor",
"(",
")",
")",
";",
"}",
"return",
"$",
"traverser",
";",
"}"
] | Get the node traverser to use.
@param bool $dir
@param bool $file
@param bool $skip
@param bool $strict
@return \ClassPreloader\Parser\NodeTraverser | [
"Get",
"the",
"node",
"traverser",
"to",
"use",
"."
] | train | https://github.com/ClassPreloader/ClassPreloader/blob/4729e438e0ada350f91148e7d4bb9809342575ff/src/Factory.php#L77-L94 |
ClassPreloader/ClassPreloader | src/ClassPreloader.php | ClassPreloader.prepareOutput | public function prepareOutput($output, $strict = false)
{
if ($strict && version_compare(PHP_VERSION, '7') < 1) {
throw new RuntimeException('Strict mode requires PHP 7 or greater.');
}
$dir = dirname($output);
if (!is_dir($dir) && !mkdir($dir, 0777, true)) {
throw new RuntimeException("Unable to create directory $dir.");
}
$handle = fopen($output, 'w');
if (!$handle) {
throw new RuntimeException("Unable to open $output for writing.");
}
if ($strict) {
fwrite($handle, "<?php declare(strict_types=1);\n");
} else {
fwrite($handle, "<?php\n");
}
return $handle;
} | php | public function prepareOutput($output, $strict = false)
{
if ($strict && version_compare(PHP_VERSION, '7') < 1) {
throw new RuntimeException('Strict mode requires PHP 7 or greater.');
}
$dir = dirname($output);
if (!is_dir($dir) && !mkdir($dir, 0777, true)) {
throw new RuntimeException("Unable to create directory $dir.");
}
$handle = fopen($output, 'w');
if (!$handle) {
throw new RuntimeException("Unable to open $output for writing.");
}
if ($strict) {
fwrite($handle, "<?php declare(strict_types=1);\n");
} else {
fwrite($handle, "<?php\n");
}
return $handle;
} | [
"public",
"function",
"prepareOutput",
"(",
"$",
"output",
",",
"$",
"strict",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"strict",
"&&",
"version_compare",
"(",
"PHP_VERSION",
",",
"'7'",
")",
"<",
"1",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Strict mode requires PHP 7 or greater.'",
")",
";",
"}",
"$",
"dir",
"=",
"dirname",
"(",
"$",
"output",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
"&&",
"!",
"mkdir",
"(",
"$",
"dir",
",",
"0777",
",",
"true",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to create directory $dir.\"",
")",
";",
"}",
"$",
"handle",
"=",
"fopen",
"(",
"$",
"output",
",",
"'w'",
")",
";",
"if",
"(",
"!",
"$",
"handle",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to open $output for writing.\"",
")",
";",
"}",
"if",
"(",
"$",
"strict",
")",
"{",
"fwrite",
"(",
"$",
"handle",
",",
"\"<?php declare(strict_types=1);\\n\"",
")",
";",
"}",
"else",
"{",
"fwrite",
"(",
"$",
"handle",
",",
"\"<?php\\n\"",
")",
";",
"}",
"return",
"$",
"handle",
";",
"}"
] | Prepare the output file and directory.
@param string $output
@param bool $strict
@throws \RuntimeException
@return resource | [
"Prepare",
"the",
"output",
"file",
"and",
"directory",
"."
] | train | https://github.com/ClassPreloader/ClassPreloader/blob/4729e438e0ada350f91148e7d4bb9809342575ff/src/ClassPreloader.php#L75-L100 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.