id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
33,700 | silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.offsetGet | public function offsetGet($offset)
{
if (!isset($this[$offset])) {
throw new OutOfBoundsException(
sprintf('Index %s is out of bounds.', $offset)
);
}
if ($this->index_field === null) {
return $this->objects[$offset];
}
return $this->objects_by_index[$offset];
} | php | public function offsetGet($offset)
{
if (!isset($this[$offset])) {
throw new OutOfBoundsException(
sprintf('Index %s is out of bounds.', $offset)
);
}
if ($this->index_field === null) {
return $this->objects[$offset];
}
return $this->objects_by_index[$offset];
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"[",
"$",
"offset",
"]",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'Index %s is out of bounds.'",
",",
"$",
"offset",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"index_field",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"objects",
"[",
"$",
"offset",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"objects_by_index",
"[",
"$",
"offset",
"]",
";",
"}"
] | Gets a record in this recordset by an offset value
@param mixed $offset the offset for which to get the record. If this
recordset has a defined index field, the offset is
an index value. Otherwise, the offset is an
ordinal value.
@return SwatDBDataObject the record at the specified offset.
@throws OutOfBoundsException if no record exists at the specified offset
in this recordset. | [
"Gets",
"a",
"record",
"in",
"this",
"recordset",
"by",
"an",
"offset",
"value"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L380-L393 |
33,701 | silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.offsetSet | public function offsetSet($offset, $value)
{
if (
$this->row_wrapper_class !== null &&
!($value instanceof $this->row_wrapper_class)
) {
throw new UnexpectedValueException(
sprintf(
'Value should be an instance of %s.',
$this->row_wrapper_class
)
);
}
if ($offset === null) {
// add
$this->objects[] = $value;
// if index field is set, index the object
if (
$this->index_field !== null &&
isset($value->{$this->index_field})
) {
if ($value->hasInternalValue($this->index_field)) {
$index = $value->getInternalValue($this->index_field);
} else {
$index = $value->{$this->index_field};
}
$this->objects_by_index[$index] = $value;
}
} else {
// replace at offset
if (!isset($this[$offset])) {
throw new OutOfBoundsException(
sprintf(
'No record to replace exists at offset %s.',
$offset
)
);
}
if ($this->index_field === null) {
$this->removed_objects[] = $this->objects[$offset];
$this->objects[$offset] = $value;
} else {
$index_field = $this->index_field;
// update object index field value
$value->$index_field = $offset;
// find and replace ordinally indexed objects
foreach ($this->objects as $key => $object) {
if ($object->$index_field === $value->$index_field) {
$this->removed_objects[] = $object;
$this->objects[$key] = $value;
}
}
// add object to indexed array
$this->objects_by_index[$offset] = $value;
}
}
// only set the db on added object if it is set for this recordset
if ($this->db !== null && $value instanceof SwatDBRecordable) {
$value->setDatabase($this->db);
}
// Remove object from removed list if it was on list of removed
// objects. This step needs to happen after adding the new record
// for the case where we replaced an object with itself.
$keys = array_keys($this->removed_objects, $value, true);
foreach ($keys as $key) {
unset($this->removed_objects[$key]);
}
} | php | public function offsetSet($offset, $value)
{
if (
$this->row_wrapper_class !== null &&
!($value instanceof $this->row_wrapper_class)
) {
throw new UnexpectedValueException(
sprintf(
'Value should be an instance of %s.',
$this->row_wrapper_class
)
);
}
if ($offset === null) {
// add
$this->objects[] = $value;
// if index field is set, index the object
if (
$this->index_field !== null &&
isset($value->{$this->index_field})
) {
if ($value->hasInternalValue($this->index_field)) {
$index = $value->getInternalValue($this->index_field);
} else {
$index = $value->{$this->index_field};
}
$this->objects_by_index[$index] = $value;
}
} else {
// replace at offset
if (!isset($this[$offset])) {
throw new OutOfBoundsException(
sprintf(
'No record to replace exists at offset %s.',
$offset
)
);
}
if ($this->index_field === null) {
$this->removed_objects[] = $this->objects[$offset];
$this->objects[$offset] = $value;
} else {
$index_field = $this->index_field;
// update object index field value
$value->$index_field = $offset;
// find and replace ordinally indexed objects
foreach ($this->objects as $key => $object) {
if ($object->$index_field === $value->$index_field) {
$this->removed_objects[] = $object;
$this->objects[$key] = $value;
}
}
// add object to indexed array
$this->objects_by_index[$offset] = $value;
}
}
// only set the db on added object if it is set for this recordset
if ($this->db !== null && $value instanceof SwatDBRecordable) {
$value->setDatabase($this->db);
}
// Remove object from removed list if it was on list of removed
// objects. This step needs to happen after adding the new record
// for the case where we replaced an object with itself.
$keys = array_keys($this->removed_objects, $value, true);
foreach ($keys as $key) {
unset($this->removed_objects[$key]);
}
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"row_wrapper_class",
"!==",
"null",
"&&",
"!",
"(",
"$",
"value",
"instanceof",
"$",
"this",
"->",
"row_wrapper_class",
")",
")",
"{",
"throw",
"new",
"UnexpectedValueException",
"(",
"sprintf",
"(",
"'Value should be an instance of %s.'",
",",
"$",
"this",
"->",
"row_wrapper_class",
")",
")",
";",
"}",
"if",
"(",
"$",
"offset",
"===",
"null",
")",
"{",
"// add",
"$",
"this",
"->",
"objects",
"[",
"]",
"=",
"$",
"value",
";",
"// if index field is set, index the object",
"if",
"(",
"$",
"this",
"->",
"index_field",
"!==",
"null",
"&&",
"isset",
"(",
"$",
"value",
"->",
"{",
"$",
"this",
"->",
"index_field",
"}",
")",
")",
"{",
"if",
"(",
"$",
"value",
"->",
"hasInternalValue",
"(",
"$",
"this",
"->",
"index_field",
")",
")",
"{",
"$",
"index",
"=",
"$",
"value",
"->",
"getInternalValue",
"(",
"$",
"this",
"->",
"index_field",
")",
";",
"}",
"else",
"{",
"$",
"index",
"=",
"$",
"value",
"->",
"{",
"$",
"this",
"->",
"index_field",
"}",
";",
"}",
"$",
"this",
"->",
"objects_by_index",
"[",
"$",
"index",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"else",
"{",
"// replace at offset",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"[",
"$",
"offset",
"]",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'No record to replace exists at offset %s.'",
",",
"$",
"offset",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"index_field",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"removed_objects",
"[",
"]",
"=",
"$",
"this",
"->",
"objects",
"[",
"$",
"offset",
"]",
";",
"$",
"this",
"->",
"objects",
"[",
"$",
"offset",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"index_field",
"=",
"$",
"this",
"->",
"index_field",
";",
"// update object index field value",
"$",
"value",
"->",
"$",
"index_field",
"=",
"$",
"offset",
";",
"// find and replace ordinally indexed objects",
"foreach",
"(",
"$",
"this",
"->",
"objects",
"as",
"$",
"key",
"=>",
"$",
"object",
")",
"{",
"if",
"(",
"$",
"object",
"->",
"$",
"index_field",
"===",
"$",
"value",
"->",
"$",
"index_field",
")",
"{",
"$",
"this",
"->",
"removed_objects",
"[",
"]",
"=",
"$",
"object",
";",
"$",
"this",
"->",
"objects",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"// add object to indexed array",
"$",
"this",
"->",
"objects_by_index",
"[",
"$",
"offset",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"// only set the db on added object if it is set for this recordset",
"if",
"(",
"$",
"this",
"->",
"db",
"!==",
"null",
"&&",
"$",
"value",
"instanceof",
"SwatDBRecordable",
")",
"{",
"$",
"value",
"->",
"setDatabase",
"(",
"$",
"this",
"->",
"db",
")",
";",
"}",
"// Remove object from removed list if it was on list of removed",
"// objects. This step needs to happen after adding the new record",
"// for the case where we replaced an object with itself.",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"removed_objects",
",",
"$",
"value",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"removed_objects",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}"
] | Sets a record at a specified offset
@param mixed $offset optional. The offset to set the record at. If this
recordset has a defined index field, the offset is
an index value. Otherwise, the offset is an
ordinal value. If no offset is given, the record
will be added at the end of this recordset.
@param mixed $value the record to add.
@throws UnexpectedValueException if this recordset has a defined row
wrapper class and the specified value
is not an instance of the row wrapper
class.
@throws OutOfBoundsException if the specified offset does not exist in
this recordset. Records can only be added
to the end of the recordset or replace
existing records in this recordset. | [
"Sets",
"a",
"record",
"at",
"a",
"specified",
"offset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L418-L493 |
33,702 | silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.offsetUnset | public function offsetUnset($offset)
{
if (isset($this[$offset])) {
if ($this->index_field === null) {
$this->removed_objects[] = $this->objects[$offset];
unset($this->objects[$offset]);
// update iterator index
if (
$this->current_index >= $offset &&
$this->current_index > 0
) {
$this->current_index--;
}
} else {
$object = $this->objects_by_index[$offset];
$this->removed_objects[] = $object;
unset($this->objects_by_index[$offset]);
$keys = array_keys($this->objects, $object, true);
foreach ($keys as $key) {
unset($this->objects[$key]);
// update iterator index
if (
$this->current_index >= $key &&
$this->current_index > 0
) {
$this->current_index--;
}
}
}
// reindex ordinal array of records
$this->objects = array_values($this->objects);
}
} | php | public function offsetUnset($offset)
{
if (isset($this[$offset])) {
if ($this->index_field === null) {
$this->removed_objects[] = $this->objects[$offset];
unset($this->objects[$offset]);
// update iterator index
if (
$this->current_index >= $offset &&
$this->current_index > 0
) {
$this->current_index--;
}
} else {
$object = $this->objects_by_index[$offset];
$this->removed_objects[] = $object;
unset($this->objects_by_index[$offset]);
$keys = array_keys($this->objects, $object, true);
foreach ($keys as $key) {
unset($this->objects[$key]);
// update iterator index
if (
$this->current_index >= $key &&
$this->current_index > 0
) {
$this->current_index--;
}
}
}
// reindex ordinal array of records
$this->objects = array_values($this->objects);
}
} | [
"public",
"function",
"offsetUnset",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"[",
"$",
"offset",
"]",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"index_field",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"removed_objects",
"[",
"]",
"=",
"$",
"this",
"->",
"objects",
"[",
"$",
"offset",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"objects",
"[",
"$",
"offset",
"]",
")",
";",
"// update iterator index",
"if",
"(",
"$",
"this",
"->",
"current_index",
">=",
"$",
"offset",
"&&",
"$",
"this",
"->",
"current_index",
">",
"0",
")",
"{",
"$",
"this",
"->",
"current_index",
"--",
";",
"}",
"}",
"else",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"objects_by_index",
"[",
"$",
"offset",
"]",
";",
"$",
"this",
"->",
"removed_objects",
"[",
"]",
"=",
"$",
"object",
";",
"unset",
"(",
"$",
"this",
"->",
"objects_by_index",
"[",
"$",
"offset",
"]",
")",
";",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"objects",
",",
"$",
"object",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"objects",
"[",
"$",
"key",
"]",
")",
";",
"// update iterator index",
"if",
"(",
"$",
"this",
"->",
"current_index",
">=",
"$",
"key",
"&&",
"$",
"this",
"->",
"current_index",
">",
"0",
")",
"{",
"$",
"this",
"->",
"current_index",
"--",
";",
"}",
"}",
"}",
"// reindex ordinal array of records",
"$",
"this",
"->",
"objects",
"=",
"array_values",
"(",
"$",
"this",
"->",
"objects",
")",
";",
"}",
"}"
] | Unsets a record in this recordset at the specified offset
This removes the record at the specified offset from this recordset.
If no such record exists, nothing is done. The record object itself
still exists if there is an external reference to it elsewhere.
@param mixed $offset the offset for which to unset the record. If this
recordset has a defined index field, the offset is
an index value. Otherwise, the offset is an
ordinal value. | [
"Unsets",
"a",
"record",
"in",
"this",
"recordset",
"at",
"the",
"specified",
"offset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L510-L546 |
33,703 | silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.key | public function key()
{
if (
$this->index_field !== null &&
isset($this->current()->{$this->index_field})
) {
$key = $this->current()->{$this->index_field};
} else {
$key = $this->current_index;
}
return $key;
} | php | public function key()
{
if (
$this->index_field !== null &&
isset($this->current()->{$this->index_field})
) {
$key = $this->current()->{$this->index_field};
} else {
$key = $this->current_index;
}
return $key;
} | [
"public",
"function",
"key",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"index_field",
"!==",
"null",
"&&",
"isset",
"(",
"$",
"this",
"->",
"current",
"(",
")",
"->",
"{",
"$",
"this",
"->",
"index_field",
"}",
")",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"current",
"(",
")",
"->",
"{",
"$",
"this",
"->",
"index_field",
"}",
";",
"}",
"else",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"current_index",
";",
"}",
"return",
"$",
"key",
";",
"}"
] | Returns the key of the current record
If this recordset has an index field defined and the current record has
an index value, this gets the index value. Otherwise this gets the
ordinal position of the record in this recordset.
@return integer the key of the current record. | [
"Returns",
"the",
"key",
"of",
"the",
"current",
"record"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L575-L587 |
33,704 | silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.getInternalValues | public function getInternalValues($name)
{
$values = array();
if (count($this) > 0) {
if (!$this->getFirst()->hasInternalValue($name)) {
throw new SwatDBException(
"Records in this recordset do not contain an internal " .
"field named '{$name}'."
);
}
foreach ($this->objects as $object) {
$values[] = $object->getInternalValue($name);
}
}
return $values;
} | php | public function getInternalValues($name)
{
$values = array();
if (count($this) > 0) {
if (!$this->getFirst()->hasInternalValue($name)) {
throw new SwatDBException(
"Records in this recordset do not contain an internal " .
"field named '{$name}'."
);
}
foreach ($this->objects as $object) {
$values[] = $object->getInternalValue($name);
}
}
return $values;
} | [
"public",
"function",
"getInternalValues",
"(",
"$",
"name",
")",
"{",
"$",
"values",
"=",
"array",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
")",
">",
"0",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getFirst",
"(",
")",
"->",
"hasInternalValue",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"SwatDBException",
"(",
"\"Records in this recordset do not contain an internal \"",
".",
"\"field named '{$name}'.\"",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"objects",
"as",
"$",
"object",
")",
"{",
"$",
"values",
"[",
"]",
"=",
"$",
"object",
"->",
"getInternalValue",
"(",
"$",
"name",
")",
";",
"}",
"}",
"return",
"$",
"values",
";",
"}"
] | Gets the values of an internal property for each record in this set
@param string $name name of the internal property to get.
@return array an array of values.
@throws SwatDBException if records in this recordset do not have an
internal value with the specified <i>$name</i>.
@see SwatDBDataObject::getInternalValue() | [
"Gets",
"the",
"values",
"of",
"an",
"internal",
"property",
"for",
"each",
"record",
"in",
"this",
"set"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L775-L793 |
33,705 | silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.loadAllSubDataObjects | public function loadAllSubDataObjects(
$name,
MDB2_Driver_Common $db,
$sql,
$wrapper,
$type = 'integer'
) {
$sub_data_objects = null;
$values = $this->getInternalValues($name);
$values = array_filter($values, function ($value) {
return $value !== null;
});
$values = array_unique($values);
if (count($values) > 0) {
$this->checkDB();
$this->db->loadModule('Datatype', null, true);
$quoted_values = $this->db->datatype->implodeArray($values, $type);
$sql = sprintf($sql, $quoted_values);
$sub_data_objects = SwatDB::query($db, $sql, $wrapper);
$this->attachSubDataObjects($name, $sub_data_objects);
}
return $sub_data_objects;
} | php | public function loadAllSubDataObjects(
$name,
MDB2_Driver_Common $db,
$sql,
$wrapper,
$type = 'integer'
) {
$sub_data_objects = null;
$values = $this->getInternalValues($name);
$values = array_filter($values, function ($value) {
return $value !== null;
});
$values = array_unique($values);
if (count($values) > 0) {
$this->checkDB();
$this->db->loadModule('Datatype', null, true);
$quoted_values = $this->db->datatype->implodeArray($values, $type);
$sql = sprintf($sql, $quoted_values);
$sub_data_objects = SwatDB::query($db, $sql, $wrapper);
$this->attachSubDataObjects($name, $sub_data_objects);
}
return $sub_data_objects;
} | [
"public",
"function",
"loadAllSubDataObjects",
"(",
"$",
"name",
",",
"MDB2_Driver_Common",
"$",
"db",
",",
"$",
"sql",
",",
"$",
"wrapper",
",",
"$",
"type",
"=",
"'integer'",
")",
"{",
"$",
"sub_data_objects",
"=",
"null",
";",
"$",
"values",
"=",
"$",
"this",
"->",
"getInternalValues",
"(",
"$",
"name",
")",
";",
"$",
"values",
"=",
"array_filter",
"(",
"$",
"values",
",",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"$",
"value",
"!==",
"null",
";",
"}",
")",
";",
"$",
"values",
"=",
"array_unique",
"(",
"$",
"values",
")",
";",
"if",
"(",
"count",
"(",
"$",
"values",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"checkDB",
"(",
")",
";",
"$",
"this",
"->",
"db",
"->",
"loadModule",
"(",
"'Datatype'",
",",
"null",
",",
"true",
")",
";",
"$",
"quoted_values",
"=",
"$",
"this",
"->",
"db",
"->",
"datatype",
"->",
"implodeArray",
"(",
"$",
"values",
",",
"$",
"type",
")",
";",
"$",
"sql",
"=",
"sprintf",
"(",
"$",
"sql",
",",
"$",
"quoted_values",
")",
";",
"$",
"sub_data_objects",
"=",
"SwatDB",
"::",
"query",
"(",
"$",
"db",
",",
"$",
"sql",
",",
"$",
"wrapper",
")",
";",
"$",
"this",
"->",
"attachSubDataObjects",
"(",
"$",
"name",
",",
"$",
"sub_data_objects",
")",
";",
"}",
"return",
"$",
"sub_data_objects",
";",
"}"
] | Loads all sub-data-objects for an internal property of the data-objects
in this recordset
This is used to efficiently load sub-objects when there is a one-to-one
relationship between the objects in this recordset and the sub-objects.
This is usually the case when there is a foreign key constraint in the
database table for the objects in this recordset.
@param string $name name of the internal property to load.
@param MDB2_Driver_Common $db database object.
@param string $sql SQL to execute with placeholder for the set of
internal property values. For example:
<code>select * from Foo where id in (%s)</code>.
@param string $wrapper the class name of the recordset wrapper to use
for the sub-data-objects.
@param string $type optional. The MDB2 datatype of the internal property
values. If not specified, 'integer' is used.
@return SwatDBRecordsetWrapper an instance of the wrapper, or null. | [
"Loads",
"all",
"sub",
"-",
"data",
"-",
"objects",
"for",
"an",
"internal",
"property",
"of",
"the",
"data",
"-",
"objects",
"in",
"this",
"recordset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L819-L846 |
33,706 | silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.attachSubDataObjects | public function attachSubDataObjects(
$name,
SwatDBRecordsetWrapper $sub_data_objects
) {
if ($sub_data_objects->index_field === null) {
throw new SwatDBException(
sprintf(
'Index field must be specified in the sub-data-object ' .
'recordset wrapper class (%s::init()) ' .
'in order to attach recordset as sub-dataobjects.',
get_class($sub_data_objects)
)
);
}
foreach ($this->objects as $object) {
$value = $object->getInternalValue($name);
if (isset($sub_data_objects[$value])) {
$object->$name = $sub_data_objects[$value];
}
}
} | php | public function attachSubDataObjects(
$name,
SwatDBRecordsetWrapper $sub_data_objects
) {
if ($sub_data_objects->index_field === null) {
throw new SwatDBException(
sprintf(
'Index field must be specified in the sub-data-object ' .
'recordset wrapper class (%s::init()) ' .
'in order to attach recordset as sub-dataobjects.',
get_class($sub_data_objects)
)
);
}
foreach ($this->objects as $object) {
$value = $object->getInternalValue($name);
if (isset($sub_data_objects[$value])) {
$object->$name = $sub_data_objects[$value];
}
}
} | [
"public",
"function",
"attachSubDataObjects",
"(",
"$",
"name",
",",
"SwatDBRecordsetWrapper",
"$",
"sub_data_objects",
")",
"{",
"if",
"(",
"$",
"sub_data_objects",
"->",
"index_field",
"===",
"null",
")",
"{",
"throw",
"new",
"SwatDBException",
"(",
"sprintf",
"(",
"'Index field must be specified in the sub-data-object '",
".",
"'recordset wrapper class (%s::init()) '",
".",
"'in order to attach recordset as sub-dataobjects.'",
",",
"get_class",
"(",
"$",
"sub_data_objects",
")",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"objects",
"as",
"$",
"object",
")",
"{",
"$",
"value",
"=",
"$",
"object",
"->",
"getInternalValue",
"(",
"$",
"name",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"sub_data_objects",
"[",
"$",
"value",
"]",
")",
")",
"{",
"$",
"object",
"->",
"$",
"name",
"=",
"$",
"sub_data_objects",
"[",
"$",
"value",
"]",
";",
"}",
"}",
"}"
] | Attach existing sub-dataobjects for an internal property of the
dataobjects in this recordset
@param string $name name of the property to attach to.
@param SwatDBRecordsetWrapper $sub_data_objects | [
"Attach",
"existing",
"sub",
"-",
"dataobjects",
"for",
"an",
"internal",
"property",
"of",
"the",
"dataobjects",
"in",
"this",
"recordset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L858-L879 |
33,707 | silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.getIndexes | public function getIndexes()
{
if ($this->index_field === null) {
throw new SwatDBException(
sprintf(
'Index field must be specified in the recordset wrapper ' .
'class (%s::init()) in order to get the record indexes.',
get_class($this)
)
);
}
return array_keys($this->objects_by_index);
} | php | public function getIndexes()
{
if ($this->index_field === null) {
throw new SwatDBException(
sprintf(
'Index field must be specified in the recordset wrapper ' .
'class (%s::init()) in order to get the record indexes.',
get_class($this)
)
);
}
return array_keys($this->objects_by_index);
} | [
"public",
"function",
"getIndexes",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"index_field",
"===",
"null",
")",
"{",
"throw",
"new",
"SwatDBException",
"(",
"sprintf",
"(",
"'Index field must be specified in the recordset wrapper '",
".",
"'class (%s::init()) in order to get the record indexes.'",
",",
"get_class",
"(",
"$",
"this",
")",
")",
")",
";",
"}",
"return",
"array_keys",
"(",
"$",
"this",
"->",
"objects_by_index",
")",
";",
"}"
] | Gets the index values of the records in this recordset
@return array the index values of the records in this recordset. | [
"Gets",
"the",
"index",
"values",
"of",
"the",
"records",
"in",
"this",
"recordset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1053-L1066 |
33,708 | silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.getFirst | public function getFirst()
{
$first = null;
if (count($this->objects) > 0) {
$first = reset($this->objects);
}
return $first;
} | php | public function getFirst()
{
$first = null;
if (count($this->objects) > 0) {
$first = reset($this->objects);
}
return $first;
} | [
"public",
"function",
"getFirst",
"(",
")",
"{",
"$",
"first",
"=",
"null",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"objects",
")",
">",
"0",
")",
"{",
"$",
"first",
"=",
"reset",
"(",
"$",
"this",
"->",
"objects",
")",
";",
"}",
"return",
"$",
"first",
";",
"}"
] | Retrieves the first object in this recordset
@return mixed the first object or null if there are no objects in this
recordset. | [
"Retrieves",
"the",
"first",
"object",
"in",
"this",
"recordset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1091-L1100 |
33,709 | silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.getLast | public function getLast()
{
$last = null;
if (count($this->objects) > 0) {
$last = end($this->objects);
}
return $last;
} | php | public function getLast()
{
$last = null;
if (count($this->objects) > 0) {
$last = end($this->objects);
}
return $last;
} | [
"public",
"function",
"getLast",
"(",
")",
"{",
"$",
"last",
"=",
"null",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"objects",
")",
">",
"0",
")",
"{",
"$",
"last",
"=",
"end",
"(",
"$",
"this",
"->",
"objects",
")",
";",
"}",
"return",
"$",
"last",
";",
"}"
] | Retrieves the last object in this recordset
@return mixed the last object or null if there are no objects in this
recordset. | [
"Retrieves",
"the",
"last",
"object",
"in",
"this",
"recordset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1111-L1120 |
33,710 | silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.remove | public function remove(SwatDBDataObject $remove_object)
{
if (in_array($remove_object, $this->objects, true)) {
$this->removed_objects[] = $remove_object;
if ($this->index_field !== null) {
$index = $remove_object->{$this->index_field};
unset($this->objects_by_index[$index]);
}
$keys = array_keys($this->objects, $remove_object, true);
foreach ($keys as $key) {
unset($this->objects[$key]);
// update iterator index
if ($this->current_index >= $key && $this->current_index > 0) {
$this->current_index--;
}
}
// reindex ordinal array of records
$this->objects = array_values($this->objects);
}
} | php | public function remove(SwatDBDataObject $remove_object)
{
if (in_array($remove_object, $this->objects, true)) {
$this->removed_objects[] = $remove_object;
if ($this->index_field !== null) {
$index = $remove_object->{$this->index_field};
unset($this->objects_by_index[$index]);
}
$keys = array_keys($this->objects, $remove_object, true);
foreach ($keys as $key) {
unset($this->objects[$key]);
// update iterator index
if ($this->current_index >= $key && $this->current_index > 0) {
$this->current_index--;
}
}
// reindex ordinal array of records
$this->objects = array_values($this->objects);
}
} | [
"public",
"function",
"remove",
"(",
"SwatDBDataObject",
"$",
"remove_object",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"remove_object",
",",
"$",
"this",
"->",
"objects",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"removed_objects",
"[",
"]",
"=",
"$",
"remove_object",
";",
"if",
"(",
"$",
"this",
"->",
"index_field",
"!==",
"null",
")",
"{",
"$",
"index",
"=",
"$",
"remove_object",
"->",
"{",
"$",
"this",
"->",
"index_field",
"}",
";",
"unset",
"(",
"$",
"this",
"->",
"objects_by_index",
"[",
"$",
"index",
"]",
")",
";",
"}",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"objects",
",",
"$",
"remove_object",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"objects",
"[",
"$",
"key",
"]",
")",
";",
"// update iterator index",
"if",
"(",
"$",
"this",
"->",
"current_index",
">=",
"$",
"key",
"&&",
"$",
"this",
"->",
"current_index",
">",
"0",
")",
"{",
"$",
"this",
"->",
"current_index",
"--",
";",
"}",
"}",
"// reindex ordinal array of records",
"$",
"this",
"->",
"objects",
"=",
"array_values",
"(",
"$",
"this",
"->",
"objects",
")",
";",
"}",
"}"
] | Removes a record from this recordset
@param SwatDBDataObject $remove_object the record to remove. | [
"Removes",
"a",
"record",
"from",
"this",
"recordset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1177-L1200 |
33,711 | silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.removeAll | public function removeAll()
{
$this->removed_objects = array_values($this->objects);
$this->objects = array();
$this->objects_by_index = array();
$this->current_index = 0;
} | php | public function removeAll()
{
$this->removed_objects = array_values($this->objects);
$this->objects = array();
$this->objects_by_index = array();
$this->current_index = 0;
} | [
"public",
"function",
"removeAll",
"(",
")",
"{",
"$",
"this",
"->",
"removed_objects",
"=",
"array_values",
"(",
"$",
"this",
"->",
"objects",
")",
";",
"$",
"this",
"->",
"objects",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"objects_by_index",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"current_index",
"=",
"0",
";",
"}"
] | Removes all records from this recordset | [
"Removes",
"all",
"records",
"from",
"this",
"recordset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1230-L1236 |
33,712 | silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.reindex | public function reindex()
{
if ($this->index_field !== null) {
$this->objects_by_index = array();
$index_field = $this->index_field;
foreach ($this->objects as $object) {
if (isset($object->$index_field)) {
$this->objects_by_index[$object->$index_field] = $object;
}
}
}
} | php | public function reindex()
{
if ($this->index_field !== null) {
$this->objects_by_index = array();
$index_field = $this->index_field;
foreach ($this->objects as $object) {
if (isset($object->$index_field)) {
$this->objects_by_index[$object->$index_field] = $object;
}
}
}
} | [
"public",
"function",
"reindex",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"index_field",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"objects_by_index",
"=",
"array",
"(",
")",
";",
"$",
"index_field",
"=",
"$",
"this",
"->",
"index_field",
";",
"foreach",
"(",
"$",
"this",
"->",
"objects",
"as",
"$",
"object",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"$",
"index_field",
")",
")",
"{",
"$",
"this",
"->",
"objects_by_index",
"[",
"$",
"object",
"->",
"$",
"index_field",
"]",
"=",
"$",
"object",
";",
"}",
"}",
"}",
"}"
] | Reindexes this recordset
Reindexing is useful when you have added new data-objects to this
recordset. Reindexing is only done if this recordset has a defined
index field. | [
"Reindexes",
"this",
"recordset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1248-L1259 |
33,713 | silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.getPropertyValues | public function getPropertyValues($name)
{
$values = array();
if (count($this) > 0) {
if (!isset($this->getFirst()->$name)) {
throw new SwatDBException(
"Records in this recordset do not contain a property " .
"named '{$name}'."
);
}
foreach ($this->objects as $object) {
$values[] = $object->$name;
}
}
return $values;
} | php | public function getPropertyValues($name)
{
$values = array();
if (count($this) > 0) {
if (!isset($this->getFirst()->$name)) {
throw new SwatDBException(
"Records in this recordset do not contain a property " .
"named '{$name}'."
);
}
foreach ($this->objects as $object) {
$values[] = $object->$name;
}
}
return $values;
} | [
"public",
"function",
"getPropertyValues",
"(",
"$",
"name",
")",
"{",
"$",
"values",
"=",
"array",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
")",
">",
"0",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"getFirst",
"(",
")",
"->",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"SwatDBException",
"(",
"\"Records in this recordset do not contain a property \"",
".",
"\"named '{$name}'.\"",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"objects",
"as",
"$",
"object",
")",
"{",
"$",
"values",
"[",
"]",
"=",
"$",
"object",
"->",
"$",
"name",
";",
"}",
"}",
"return",
"$",
"values",
";",
"}"
] | Gets the values of a property for each record in this set
@param string $name name of the property to get.
@return array an array of values.
@throws SwatDBException if records in this recordset do not have a
property with the specified <i>$name</i>. | [
"Gets",
"the",
"values",
"of",
"a",
"property",
"for",
"each",
"record",
"in",
"this",
"set"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1274-L1292 |
33,714 | silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.setDatabase | public function setDatabase(MDB2_Driver_Common $db, array $set = array())
{
$key = spl_object_hash($this);
if (isset($set[$key])) {
// prevent infinite recursion on datastructure cycles
return;
}
$this->db = $db;
$set[$key] = true;
foreach ($this->objects as $object) {
if ($object instanceof SwatDBRecordable) {
$object->setDatabase($db, $set);
}
}
} | php | public function setDatabase(MDB2_Driver_Common $db, array $set = array())
{
$key = spl_object_hash($this);
if (isset($set[$key])) {
// prevent infinite recursion on datastructure cycles
return;
}
$this->db = $db;
$set[$key] = true;
foreach ($this->objects as $object) {
if ($object instanceof SwatDBRecordable) {
$object->setDatabase($db, $set);
}
}
} | [
"public",
"function",
"setDatabase",
"(",
"MDB2_Driver_Common",
"$",
"db",
",",
"array",
"$",
"set",
"=",
"array",
"(",
")",
")",
"{",
"$",
"key",
"=",
"spl_object_hash",
"(",
"$",
"this",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"set",
"[",
"$",
"key",
"]",
")",
")",
"{",
"// prevent infinite recursion on datastructure cycles",
"return",
";",
"}",
"$",
"this",
"->",
"db",
"=",
"$",
"db",
";",
"$",
"set",
"[",
"$",
"key",
"]",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"objects",
"as",
"$",
"object",
")",
"{",
"if",
"(",
"$",
"object",
"instanceof",
"SwatDBRecordable",
")",
"{",
"$",
"object",
"->",
"setDatabase",
"(",
"$",
"db",
",",
"$",
"set",
")",
";",
"}",
"}",
"}"
] | Sets the database driver for this recordset
The database is automatically set for all recordable records of this
recordset.
@param MDB2_Driver_Common $db the database driver to use for this
recordset.
@param array $set optional array of objects passed through
recursive call containing all objects that
have been set already. Prevents infinite
recursion. | [
"Sets",
"the",
"database",
"driver",
"for",
"this",
"recordset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1312-L1329 |
33,715 | silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.save | public function save()
{
$this->checkDB();
$transaction = new SwatDBTransaction($this->db);
try {
foreach ($this->removed_objects as $object) {
$object->setDatabase($this->db);
$object->delete();
}
foreach ($this->objects as $object) {
$object->setDatabase($this->db);
$object->save();
}
$transaction->commit();
} catch (Exception $e) {
$transaction->rollback();
throw $e;
}
$this->removed_objects = array();
$this->reindex();
} | php | public function save()
{
$this->checkDB();
$transaction = new SwatDBTransaction($this->db);
try {
foreach ($this->removed_objects as $object) {
$object->setDatabase($this->db);
$object->delete();
}
foreach ($this->objects as $object) {
$object->setDatabase($this->db);
$object->save();
}
$transaction->commit();
} catch (Exception $e) {
$transaction->rollback();
throw $e;
}
$this->removed_objects = array();
$this->reindex();
} | [
"public",
"function",
"save",
"(",
")",
"{",
"$",
"this",
"->",
"checkDB",
"(",
")",
";",
"$",
"transaction",
"=",
"new",
"SwatDBTransaction",
"(",
"$",
"this",
"->",
"db",
")",
";",
"try",
"{",
"foreach",
"(",
"$",
"this",
"->",
"removed_objects",
"as",
"$",
"object",
")",
"{",
"$",
"object",
"->",
"setDatabase",
"(",
"$",
"this",
"->",
"db",
")",
";",
"$",
"object",
"->",
"delete",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"objects",
"as",
"$",
"object",
")",
"{",
"$",
"object",
"->",
"setDatabase",
"(",
"$",
"this",
"->",
"db",
")",
";",
"$",
"object",
"->",
"save",
"(",
")",
";",
"}",
"$",
"transaction",
"->",
"commit",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"transaction",
"->",
"rollback",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"$",
"this",
"->",
"removed_objects",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"reindex",
"(",
")",
";",
"}"
] | Saves this recordset to the database
Saving a recordset works as follows:
1. Objects that were removed are deleted from the database.
2. Objects that were added are inserted into the database,
3. Objects that were modified are updated in the database,
Deleting is performed before adding incase a new row with the same
values as a deleted row is added. For example, a binding is removed and
an identical binding is added. | [
"Saves",
"this",
"recordset",
"to",
"the",
"database"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1346-L1369 |
33,716 | silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.load | public function load($object_indexes)
{
if (!is_array($object_indexes)) {
throw new SwatInvalidTypeException(
'The $object_indexes property must be an array.',
0,
$object_indexes
);
}
$interfaces = class_implements($this->row_wrapper_class);
if (!in_array('SwatDBRecordable', $interfaces)) {
throw new SwatInvalidClassException(
'The recordset must define a row wrapper class that is an ' .
'instance of SwatDBRecordable for recordset loading to work.',
0,
$this->row_wrapper_class
);
}
$success = true;
// try to load all records
$records = array();
$class_name = $this->row_wrapper_class;
foreach ($object_indexes as $index) {
$record = new $class_name();
$record->setDatabase($this->db);
if ($record->load($index)) {
$records[] = $record;
} else {
$success = false;
break;
}
}
// successfully loaded all records, set this set's records to the
// loaded records
if ($success) {
$this->objects = array();
$this->objects_by_index = array();
$this->removed_objects = array();
foreach ($records as $record) {
$this[] = $record;
}
$this->reindex();
}
return $success;
} | php | public function load($object_indexes)
{
if (!is_array($object_indexes)) {
throw new SwatInvalidTypeException(
'The $object_indexes property must be an array.',
0,
$object_indexes
);
}
$interfaces = class_implements($this->row_wrapper_class);
if (!in_array('SwatDBRecordable', $interfaces)) {
throw new SwatInvalidClassException(
'The recordset must define a row wrapper class that is an ' .
'instance of SwatDBRecordable for recordset loading to work.',
0,
$this->row_wrapper_class
);
}
$success = true;
// try to load all records
$records = array();
$class_name = $this->row_wrapper_class;
foreach ($object_indexes as $index) {
$record = new $class_name();
$record->setDatabase($this->db);
if ($record->load($index)) {
$records[] = $record;
} else {
$success = false;
break;
}
}
// successfully loaded all records, set this set's records to the
// loaded records
if ($success) {
$this->objects = array();
$this->objects_by_index = array();
$this->removed_objects = array();
foreach ($records as $record) {
$this[] = $record;
}
$this->reindex();
}
return $success;
} | [
"public",
"function",
"load",
"(",
"$",
"object_indexes",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"object_indexes",
")",
")",
"{",
"throw",
"new",
"SwatInvalidTypeException",
"(",
"'The $object_indexes property must be an array.'",
",",
"0",
",",
"$",
"object_indexes",
")",
";",
"}",
"$",
"interfaces",
"=",
"class_implements",
"(",
"$",
"this",
"->",
"row_wrapper_class",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"'SwatDBRecordable'",
",",
"$",
"interfaces",
")",
")",
"{",
"throw",
"new",
"SwatInvalidClassException",
"(",
"'The recordset must define a row wrapper class that is an '",
".",
"'instance of SwatDBRecordable for recordset loading to work.'",
",",
"0",
",",
"$",
"this",
"->",
"row_wrapper_class",
")",
";",
"}",
"$",
"success",
"=",
"true",
";",
"// try to load all records",
"$",
"records",
"=",
"array",
"(",
")",
";",
"$",
"class_name",
"=",
"$",
"this",
"->",
"row_wrapper_class",
";",
"foreach",
"(",
"$",
"object_indexes",
"as",
"$",
"index",
")",
"{",
"$",
"record",
"=",
"new",
"$",
"class_name",
"(",
")",
";",
"$",
"record",
"->",
"setDatabase",
"(",
"$",
"this",
"->",
"db",
")",
";",
"if",
"(",
"$",
"record",
"->",
"load",
"(",
"$",
"index",
")",
")",
"{",
"$",
"records",
"[",
"]",
"=",
"$",
"record",
";",
"}",
"else",
"{",
"$",
"success",
"=",
"false",
";",
"break",
";",
"}",
"}",
"// successfully loaded all records, set this set's records to the",
"// loaded records",
"if",
"(",
"$",
"success",
")",
"{",
"$",
"this",
"->",
"objects",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"objects_by_index",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"removed_objects",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"records",
"as",
"$",
"record",
")",
"{",
"$",
"this",
"[",
"]",
"=",
"$",
"record",
";",
"}",
"$",
"this",
"->",
"reindex",
"(",
")",
";",
"}",
"return",
"$",
"success",
";",
"}"
] | Loads a set of records into this recordset
It is recommended for performance that you use recordset wrappers to
wrap a MDB2 result set rather than using this load() method. Using this
method performs N queries where N is the size of the passed array of
object indexes.
@param array $object_indexes the index field values of the records to
load into this recordset.
@return boolean true if all records loaded properly and false if one
or more records could not be loaded. If any records
fail to load, the recordset state remains unchanged.
@throws SwatInvalidTypeException if the <i>$object_indexes</i> property
is not an array.
@throws SwatInvalidClassException if this recordset's
{@link SwatDBRecordsetWrapper::$row_wrapper_class}
is not an instance of
{@link SwatDBRecordable}. | [
"Loads",
"a",
"set",
"of",
"records",
"into",
"this",
"recordset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1396-L1447 |
33,717 | silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.isModified | public function isModified()
{
if (count($this->removed_objects) > 0) {
return true;
}
foreach ($this->objects as $name => $object) {
if ($object->isModified()) {
return true;
}
}
return false;
} | php | public function isModified()
{
if (count($this->removed_objects) > 0) {
return true;
}
foreach ($this->objects as $name => $object) {
if ($object->isModified()) {
return true;
}
}
return false;
} | [
"public",
"function",
"isModified",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"removed_objects",
")",
">",
"0",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"objects",
"as",
"$",
"name",
"=>",
"$",
"object",
")",
"{",
"if",
"(",
"$",
"object",
"->",
"isModified",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns true if this recordset has been modified since it was loaded
A recordset is considered modified if any of the contained records have
been modified or if any records have been removed from this set. Adding
an unmodified record to this set does not constitute modifying the set.
@return boolean true if this recordset was modified and false if this
recordset was not modified. | [
"Returns",
"true",
"if",
"this",
"recordset",
"has",
"been",
"modified",
"since",
"it",
"was",
"loaded"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1477-L1490 |
33,718 | silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.setFlushableCache | public function setFlushableCache(SwatDBCacheNsFlushable $cache)
{
foreach ($this->objects as $object) {
if ($object instanceof SwatDBFlushable) {
$object->setFlushableCache($cache);
}
}
} | php | public function setFlushableCache(SwatDBCacheNsFlushable $cache)
{
foreach ($this->objects as $object) {
if ($object instanceof SwatDBFlushable) {
$object->setFlushableCache($cache);
}
}
} | [
"public",
"function",
"setFlushableCache",
"(",
"SwatDBCacheNsFlushable",
"$",
"cache",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"objects",
"as",
"$",
"object",
")",
"{",
"if",
"(",
"$",
"object",
"instanceof",
"SwatDBFlushable",
")",
"{",
"$",
"object",
"->",
"setFlushableCache",
"(",
"$",
"cache",
")",
";",
"}",
"}",
"}"
] | Sets the flushable cache to use for this record-set
Using a flushable cache allows clearing the cache when the records
are modified or deleted.
@param SwatDBCacheNsFlushable $cache The flushable cache to use for
this dataobject. | [
"Sets",
"the",
"flushable",
"cache",
"to",
"use",
"for",
"this",
"record",
"-",
"set"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1504-L1511 |
33,719 | brainworxx/kreXX | src/Analyse/Routing/Process/ProcessInteger.php | ProcessInteger.process | public function process(Model $model)
{
return $this->pool->render->renderSingleChild(
$model->setNormal($model->getData())->setType(static::TYPE_INTEGER)
);
} | php | public function process(Model $model)
{
return $this->pool->render->renderSingleChild(
$model->setNormal($model->getData())->setType(static::TYPE_INTEGER)
);
} | [
"public",
"function",
"process",
"(",
"Model",
"$",
"model",
")",
"{",
"return",
"$",
"this",
"->",
"pool",
"->",
"render",
"->",
"renderSingleChild",
"(",
"$",
"model",
"->",
"setNormal",
"(",
"$",
"model",
"->",
"getData",
"(",
")",
")",
"->",
"setType",
"(",
"static",
"::",
"TYPE_INTEGER",
")",
")",
";",
"}"
] | Render a dump for a integer value.
@param Model $model
The data we are analysing.
@return string
The rendered markup. | [
"Render",
"a",
"dump",
"for",
"a",
"integer",
"value",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Routing/Process/ProcessInteger.php#L56-L61 |
33,720 | silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.getModifiedProperties | public function getModifiedProperties()
{
if ($this->read_only) {
return array();
}
$modified_properties = array();
foreach ($this->getProperties() as $name => $value) {
$hashed_value = $this->getHashValue($value);
if (
array_key_exists($name, $this->property_hashes) &&
$hashed_value !== $this->property_hashes[$name]
) {
$modified_properties[$name] = $value;
}
}
return $modified_properties;
} | php | public function getModifiedProperties()
{
if ($this->read_only) {
return array();
}
$modified_properties = array();
foreach ($this->getProperties() as $name => $value) {
$hashed_value = $this->getHashValue($value);
if (
array_key_exists($name, $this->property_hashes) &&
$hashed_value !== $this->property_hashes[$name]
) {
$modified_properties[$name] = $value;
}
}
return $modified_properties;
} | [
"public",
"function",
"getModifiedProperties",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"read_only",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"modified_properties",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getProperties",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"hashed_value",
"=",
"$",
"this",
"->",
"getHashValue",
"(",
"$",
"value",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"property_hashes",
")",
"&&",
"$",
"hashed_value",
"!==",
"$",
"this",
"->",
"property_hashes",
"[",
"$",
"name",
"]",
")",
"{",
"$",
"modified_properties",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"modified_properties",
";",
"}"
] | Gets a list of all the modified properties of this object
@return array an array of modified properties and their values in the
form of: name => value | [
"Gets",
"a",
"list",
"of",
"all",
"the",
"modified",
"properties",
"of",
"this",
"object"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L146-L164 |
33,721 | silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.duplicate | public function duplicate()
{
$class = get_class($this);
$new_object = new $class();
$id_field = new SwatDBField($this->id_field, 'integer');
// public properties
$properties = array_merge(
$this->getPublicProperties(),
$this->getSerializableProtectedProperties()
);
foreach ($properties as $name => $value) {
if ($name !== $id_field->name) {
$new_object->$name = $this->$name;
}
}
// sub-dataobjects
foreach ($this->sub_data_objects as $name => $object) {
$saver_method =
'save' . str_replace(' ', '', ucwords(strtr($name, '_', ' ')));
$object->setDatabase($this->db);
if (method_exists($this, $saver_method)) {
$new_object->$name = $object->duplicate();
} elseif (!array_key_exists($name, $this->internal_properties)) {
$new_object->$name = $object;
}
}
// internal properties
foreach ($this->internal_properties as $name => $value) {
if (
!(
array_key_exists(
$name,
$this->internal_property_accessible
) && $this->internal_property_accessible[$name]
)
) {
continue;
}
$autosave = $this->internal_property_autosave[$name];
if ($this->hasSubDataObject($name)) {
$object = $this->getSubDataObject($name);
if ($autosave) {
$new_object->$name = $object->duplicate();
} else {
$new_object->$name = $object;
}
} else {
$new_object->$name = $value;
}
}
$new_object->setDatabase($this->db);
return $new_object;
} | php | public function duplicate()
{
$class = get_class($this);
$new_object = new $class();
$id_field = new SwatDBField($this->id_field, 'integer');
// public properties
$properties = array_merge(
$this->getPublicProperties(),
$this->getSerializableProtectedProperties()
);
foreach ($properties as $name => $value) {
if ($name !== $id_field->name) {
$new_object->$name = $this->$name;
}
}
// sub-dataobjects
foreach ($this->sub_data_objects as $name => $object) {
$saver_method =
'save' . str_replace(' ', '', ucwords(strtr($name, '_', ' ')));
$object->setDatabase($this->db);
if (method_exists($this, $saver_method)) {
$new_object->$name = $object->duplicate();
} elseif (!array_key_exists($name, $this->internal_properties)) {
$new_object->$name = $object;
}
}
// internal properties
foreach ($this->internal_properties as $name => $value) {
if (
!(
array_key_exists(
$name,
$this->internal_property_accessible
) && $this->internal_property_accessible[$name]
)
) {
continue;
}
$autosave = $this->internal_property_autosave[$name];
if ($this->hasSubDataObject($name)) {
$object = $this->getSubDataObject($name);
if ($autosave) {
$new_object->$name = $object->duplicate();
} else {
$new_object->$name = $object;
}
} else {
$new_object->$name = $value;
}
}
$new_object->setDatabase($this->db);
return $new_object;
} | [
"public",
"function",
"duplicate",
"(",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"$",
"new_object",
"=",
"new",
"$",
"class",
"(",
")",
";",
"$",
"id_field",
"=",
"new",
"SwatDBField",
"(",
"$",
"this",
"->",
"id_field",
",",
"'integer'",
")",
";",
"// public properties",
"$",
"properties",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"getPublicProperties",
"(",
")",
",",
"$",
"this",
"->",
"getSerializableProtectedProperties",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"name",
"!==",
"$",
"id_field",
"->",
"name",
")",
"{",
"$",
"new_object",
"->",
"$",
"name",
"=",
"$",
"this",
"->",
"$",
"name",
";",
"}",
"}",
"// sub-dataobjects",
"foreach",
"(",
"$",
"this",
"->",
"sub_data_objects",
"as",
"$",
"name",
"=>",
"$",
"object",
")",
"{",
"$",
"saver_method",
"=",
"'save'",
".",
"str_replace",
"(",
"' '",
",",
"''",
",",
"ucwords",
"(",
"strtr",
"(",
"$",
"name",
",",
"'_'",
",",
"' '",
")",
")",
")",
";",
"$",
"object",
"->",
"setDatabase",
"(",
"$",
"this",
"->",
"db",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"saver_method",
")",
")",
"{",
"$",
"new_object",
"->",
"$",
"name",
"=",
"$",
"object",
"->",
"duplicate",
"(",
")",
";",
"}",
"elseif",
"(",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"internal_properties",
")",
")",
"{",
"$",
"new_object",
"->",
"$",
"name",
"=",
"$",
"object",
";",
"}",
"}",
"// internal properties",
"foreach",
"(",
"$",
"this",
"->",
"internal_properties",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"internal_property_accessible",
")",
"&&",
"$",
"this",
"->",
"internal_property_accessible",
"[",
"$",
"name",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"autosave",
"=",
"$",
"this",
"->",
"internal_property_autosave",
"[",
"$",
"name",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"hasSubDataObject",
"(",
"$",
"name",
")",
")",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"getSubDataObject",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"autosave",
")",
"{",
"$",
"new_object",
"->",
"$",
"name",
"=",
"$",
"object",
"->",
"duplicate",
"(",
")",
";",
"}",
"else",
"{",
"$",
"new_object",
"->",
"$",
"name",
"=",
"$",
"object",
";",
"}",
"}",
"else",
"{",
"$",
"new_object",
"->",
"$",
"name",
"=",
"$",
"value",
";",
"}",
"}",
"$",
"new_object",
"->",
"setDatabase",
"(",
"$",
"this",
"->",
"db",
")",
";",
"return",
"$",
"new_object",
";",
"}"
] | Duplicates this object
A duplicate is less of an exact copy than a true clone. Like a clone, a
duplicate has all the same public property values. Unlike a clone, a
duplicate does not have an id and therefore can be saved to the
database as a new row. This method recursively duplicates
sub-dataobjects which were registered with <i>$autosave</i> set to true.
@return SwatDBDataobject a duplicate of this object. | [
"Duplicates",
"this",
"object"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L436-L497 |
33,722 | silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.initFromRow | protected function initFromRow($row)
{
if ($row === null) {
throw new SwatDBException(
'Attempting to initialize dataobject with a null row.'
);
}
$property_array = array_merge(
$this->getPublicProperties(),
$this->getSerializableProtectedProperties()
);
if (is_object($row)) {
$row = get_object_vars($row);
}
foreach ($property_array as $name => $value) {
// Use array_key_exists() instead of isset(), because isset() will
// return false when the value is null. Null values on properties
// should not be ignored - otherwise calling initFromRow() on an
// existing dataobject can leave out of date values on properties
// when those values were updated to null.
if (array_key_exists($name, $row)) {
if (
in_array($name, $this->date_properties) &&
$row[$name] !== null
) {
$this->$name = new SwatDate($row[$name]);
} else {
$this->$name = $row[$name];
}
}
}
foreach ($this->internal_properties as $name => $value) {
if (isset($row[$name])) {
$this->internal_properties[$name] = $row[$name];
}
}
$this->loaded_from_database = true;
} | php | protected function initFromRow($row)
{
if ($row === null) {
throw new SwatDBException(
'Attempting to initialize dataobject with a null row.'
);
}
$property_array = array_merge(
$this->getPublicProperties(),
$this->getSerializableProtectedProperties()
);
if (is_object($row)) {
$row = get_object_vars($row);
}
foreach ($property_array as $name => $value) {
// Use array_key_exists() instead of isset(), because isset() will
// return false when the value is null. Null values on properties
// should not be ignored - otherwise calling initFromRow() on an
// existing dataobject can leave out of date values on properties
// when those values were updated to null.
if (array_key_exists($name, $row)) {
if (
in_array($name, $this->date_properties) &&
$row[$name] !== null
) {
$this->$name = new SwatDate($row[$name]);
} else {
$this->$name = $row[$name];
}
}
}
foreach ($this->internal_properties as $name => $value) {
if (isset($row[$name])) {
$this->internal_properties[$name] = $row[$name];
}
}
$this->loaded_from_database = true;
} | [
"protected",
"function",
"initFromRow",
"(",
"$",
"row",
")",
"{",
"if",
"(",
"$",
"row",
"===",
"null",
")",
"{",
"throw",
"new",
"SwatDBException",
"(",
"'Attempting to initialize dataobject with a null row.'",
")",
";",
"}",
"$",
"property_array",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"getPublicProperties",
"(",
")",
",",
"$",
"this",
"->",
"getSerializableProtectedProperties",
"(",
")",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"row",
")",
")",
"{",
"$",
"row",
"=",
"get_object_vars",
"(",
"$",
"row",
")",
";",
"}",
"foreach",
"(",
"$",
"property_array",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"// Use array_key_exists() instead of isset(), because isset() will",
"// return false when the value is null. Null values on properties",
"// should not be ignored - otherwise calling initFromRow() on an",
"// existing dataobject can leave out of date values on properties",
"// when those values were updated to null.",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"row",
")",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"date_properties",
")",
"&&",
"$",
"row",
"[",
"$",
"name",
"]",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"$",
"name",
"=",
"new",
"SwatDate",
"(",
"$",
"row",
"[",
"$",
"name",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"$",
"name",
"=",
"$",
"row",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"internal_properties",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"row",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"internal_properties",
"[",
"$",
"name",
"]",
"=",
"$",
"row",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"$",
"this",
"->",
"loaded_from_database",
"=",
"true",
";",
"}"
] | Takes a data row and sets the properties of this object according to
the values of the row
Subclasses can override this method to provide additional
functionality.
@param mixed $row the row to use as either an array or object. | [
"Takes",
"a",
"data",
"row",
"and",
"sets",
"the",
"properties",
"of",
"this",
"object",
"according",
"to",
"the",
"values",
"of",
"the",
"row"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L583-L625 |
33,723 | silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.generatePropertyHashes | protected function generatePropertyHashes()
{
if ($this->read_only) {
return;
}
// Note: SwatDBDataObject::generatePropertyHash() is not used
// here because it would mean calling the expensive getProperties()
// method in a loop.
foreach ($this->getProperties() as $name => $value) {
$hashed_value = $this->getHashValue($value);
$this->property_hashes[$name] = $hashed_value;
}
} | php | protected function generatePropertyHashes()
{
if ($this->read_only) {
return;
}
// Note: SwatDBDataObject::generatePropertyHash() is not used
// here because it would mean calling the expensive getProperties()
// method in a loop.
foreach ($this->getProperties() as $name => $value) {
$hashed_value = $this->getHashValue($value);
$this->property_hashes[$name] = $hashed_value;
}
} | [
"protected",
"function",
"generatePropertyHashes",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"read_only",
")",
"{",
"return",
";",
"}",
"// Note: SwatDBDataObject::generatePropertyHash() is not used",
"// here because it would mean calling the expensive getProperties()",
"// method in a loop.",
"foreach",
"(",
"$",
"this",
"->",
"getProperties",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"hashed_value",
"=",
"$",
"this",
"->",
"getHashValue",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"property_hashes",
"[",
"$",
"name",
"]",
"=",
"$",
"hashed_value",
";",
"}",
"}"
] | Generates the set of md5 hashes for this data object
The md5 hashes represent all the public properties of this object and
are used to tell if a property has been modified. | [
"Generates",
"the",
"set",
"of",
"md5",
"hashes",
"for",
"this",
"data",
"object"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L636-L649 |
33,724 | silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.generatePropertyHash | protected function generatePropertyHash($property)
{
if ($this->read_only) {
return;
}
$property_array = $this->getProperties();
if (isset($property_array[$property])) {
$hashed_value = $this->getHashValue($property_array[$property]);
$this->property_hashes[$property] = $hashed_value;
}
} | php | protected function generatePropertyHash($property)
{
if ($this->read_only) {
return;
}
$property_array = $this->getProperties();
if (isset($property_array[$property])) {
$hashed_value = $this->getHashValue($property_array[$property]);
$this->property_hashes[$property] = $hashed_value;
}
} | [
"protected",
"function",
"generatePropertyHash",
"(",
"$",
"property",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"read_only",
")",
"{",
"return",
";",
"}",
"$",
"property_array",
"=",
"$",
"this",
"->",
"getProperties",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"property_array",
"[",
"$",
"property",
"]",
")",
")",
"{",
"$",
"hashed_value",
"=",
"$",
"this",
"->",
"getHashValue",
"(",
"$",
"property_array",
"[",
"$",
"property",
"]",
")",
";",
"$",
"this",
"->",
"property_hashes",
"[",
"$",
"property",
"]",
"=",
"$",
"hashed_value",
";",
"}",
"}"
] | Generates the MD5 hash for a property of this object
@param string $property the name of the property for which to generate
the hash. | [
"Generates",
"the",
"MD5",
"hash",
"for",
"a",
"property",
"of",
"this",
"object"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L660-L672 |
33,725 | silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.getPublicProperties | private function getPublicProperties()
{
$class = get_class($this);
// cache class public property names since reflection is expensive
if (!array_key_exists($class, self::$public_properties_cache)) {
$public_properties = array();
$reflector = new ReflectionClass($class);
foreach ($reflector->getProperties() as $property) {
if ($property->isPublic() && !$property->isStatic()) {
$public_properties[] = $property->getName();
}
}
self::$public_properties_cache[$class] = $public_properties;
}
// get property values for this object
$names = self::$public_properties_cache[$class];
$properties = array();
foreach ($names as $name) {
$properties[$name] = $this->$name;
}
return $properties;
} | php | private function getPublicProperties()
{
$class = get_class($this);
// cache class public property names since reflection is expensive
if (!array_key_exists($class, self::$public_properties_cache)) {
$public_properties = array();
$reflector = new ReflectionClass($class);
foreach ($reflector->getProperties() as $property) {
if ($property->isPublic() && !$property->isStatic()) {
$public_properties[] = $property->getName();
}
}
self::$public_properties_cache[$class] = $public_properties;
}
// get property values for this object
$names = self::$public_properties_cache[$class];
$properties = array();
foreach ($names as $name) {
$properties[$name] = $this->$name;
}
return $properties;
} | [
"private",
"function",
"getPublicProperties",
"(",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"// cache class public property names since reflection is expensive",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"class",
",",
"self",
"::",
"$",
"public_properties_cache",
")",
")",
"{",
"$",
"public_properties",
"=",
"array",
"(",
")",
";",
"$",
"reflector",
"=",
"new",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"foreach",
"(",
"$",
"reflector",
"->",
"getProperties",
"(",
")",
"as",
"$",
"property",
")",
"{",
"if",
"(",
"$",
"property",
"->",
"isPublic",
"(",
")",
"&&",
"!",
"$",
"property",
"->",
"isStatic",
"(",
")",
")",
"{",
"$",
"public_properties",
"[",
"]",
"=",
"$",
"property",
"->",
"getName",
"(",
")",
";",
"}",
"}",
"self",
"::",
"$",
"public_properties_cache",
"[",
"$",
"class",
"]",
"=",
"$",
"public_properties",
";",
"}",
"// get property values for this object",
"$",
"names",
"=",
"self",
"::",
"$",
"public_properties_cache",
"[",
"$",
"class",
"]",
";",
"$",
"properties",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"names",
"as",
"$",
"name",
")",
"{",
"$",
"properties",
"[",
"$",
"name",
"]",
"=",
"$",
"this",
"->",
"$",
"name",
";",
"}",
"return",
"$",
"properties",
";",
"}"
] | Gets the public properties of this data-object
Public properties should correspond directly to database fields.
@return array a reference to an associative array of public properties
of this data-object. The array is of the form
'property name' => 'property value'. | [
"Gets",
"the",
"public",
"properties",
"of",
"this",
"data",
"-",
"object"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L802-L828 |
33,726 | silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.getSerializableProtectedProperties | private function getSerializableProtectedProperties()
{
$properties = array();
foreach ($this->getProtectedPropertyList() as $property => $accessors) {
// We want to maintain what is internally stored in this object so
// we don't want to use the getter. What the getter returns
// publicly may be different than what we have internally.
$properties[$property] = $this->$property;
}
return $properties;
} | php | private function getSerializableProtectedProperties()
{
$properties = array();
foreach ($this->getProtectedPropertyList() as $property => $accessors) {
// We want to maintain what is internally stored in this object so
// we don't want to use the getter. What the getter returns
// publicly may be different than what we have internally.
$properties[$property] = $this->$property;
}
return $properties;
} | [
"private",
"function",
"getSerializableProtectedProperties",
"(",
")",
"{",
"$",
"properties",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getProtectedPropertyList",
"(",
")",
"as",
"$",
"property",
"=>",
"$",
"accessors",
")",
"{",
"// We want to maintain what is internally stored in this object so",
"// we don't want to use the getter. What the getter returns",
"// publicly may be different than what we have internally.",
"$",
"properties",
"[",
"$",
"property",
"]",
"=",
"$",
"this",
"->",
"$",
"property",
";",
"}",
"return",
"$",
"properties",
";",
"}"
] | Gets the serializable protected properties of this data-object.
Protected properties should correspond directly to database fields.
@return array a reference to an associative array of protected properties
of this data-object. The array is of the form
'property name' => 'property value'. | [
"Gets",
"the",
"serializable",
"protected",
"properties",
"of",
"this",
"data",
"-",
"object",
"."
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L842-L853 |
33,727 | silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.getProtectedProperties | private function getProtectedProperties()
{
$properties = array();
foreach ($this->getProtectedPropertyList() as $property => $accessors) {
// Use the getter for the property.
$properties[$property] = $this->{$accessors['get']}();
}
return $properties;
} | php | private function getProtectedProperties()
{
$properties = array();
foreach ($this->getProtectedPropertyList() as $property => $accessors) {
// Use the getter for the property.
$properties[$property] = $this->{$accessors['get']}();
}
return $properties;
} | [
"private",
"function",
"getProtectedProperties",
"(",
")",
"{",
"$",
"properties",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getProtectedPropertyList",
"(",
")",
"as",
"$",
"property",
"=>",
"$",
"accessors",
")",
"{",
"// Use the getter for the property.",
"$",
"properties",
"[",
"$",
"property",
"]",
"=",
"$",
"this",
"->",
"{",
"$",
"accessors",
"[",
"'get'",
"]",
"}",
"(",
")",
";",
"}",
"return",
"$",
"properties",
";",
"}"
] | Gets the protected properties of this data-object using the getter
accessor.
Protected properties should correspond directly to database fields.
@return array a reference to an associative array of protected properties
of this data-object. The array is of the form
'property name' => 'property value'. | [
"Gets",
"the",
"protected",
"properties",
"of",
"this",
"data",
"-",
"object",
"using",
"the",
"getter",
"accessor",
"."
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L868-L877 |
33,728 | silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.& | private function &getProperties()
{
$property_array = array_merge(
$this->getPublicProperties(),
$this->getSerializableProtectedProperties(),
$this->internal_properties
);
return $property_array;
} | php | private function &getProperties()
{
$property_array = array_merge(
$this->getPublicProperties(),
$this->getSerializableProtectedProperties(),
$this->internal_properties
);
return $property_array;
} | [
"private",
"function",
"&",
"getProperties",
"(",
")",
"{",
"$",
"property_array",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"getPublicProperties",
"(",
")",
",",
"$",
"this",
"->",
"getSerializableProtectedProperties",
"(",
")",
",",
"$",
"this",
"->",
"internal_properties",
")",
";",
"return",
"$",
"property_array",
";",
"}"
] | Gets all the modifyable properties of this data-object
This includes the public and protected properties that correspond to
database fields and the internal values that also correspond to database
fields.
@return array a reference to an associative array of properties of this
data-object. The array is of the form
'property name' => 'property value'. | [
"Gets",
"all",
"the",
"modifyable",
"properties",
"of",
"this",
"data",
"-",
"object"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L893-L902 |
33,729 | silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.isModified | public function isModified()
{
if ($this->read_only) {
return false;
}
foreach ($this->getProperties() as $name => $value) {
$hashed_value = $this->getHashValue($value);
if (
isset($this->property_hashes[$name]) &&
$hashed_value !== $this->property_hashes[$name]
) {
return true;
}
}
foreach ($this->internal_property_autosave as $name => $autosave) {
if ($autosave && isset($this->sub_data_objects[$name])) {
$object = $this->sub_data_objects[$name];
if (
$object instanceof SwatDBRecordable &&
$object->isModified()
) {
return true;
}
}
}
foreach ($this->sub_data_objects as $name => $object) {
$saver_method =
'save' . str_replace(' ', '', ucwords(strtr($name, '_', ' ')));
if (method_exists($this, $saver_method)) {
$object = $this->sub_data_objects[$name];
if (
$object instanceof SwatDBRecordable &&
$object->isModified()
) {
return true;
}
}
}
return false;
} | php | public function isModified()
{
if ($this->read_only) {
return false;
}
foreach ($this->getProperties() as $name => $value) {
$hashed_value = $this->getHashValue($value);
if (
isset($this->property_hashes[$name]) &&
$hashed_value !== $this->property_hashes[$name]
) {
return true;
}
}
foreach ($this->internal_property_autosave as $name => $autosave) {
if ($autosave && isset($this->sub_data_objects[$name])) {
$object = $this->sub_data_objects[$name];
if (
$object instanceof SwatDBRecordable &&
$object->isModified()
) {
return true;
}
}
}
foreach ($this->sub_data_objects as $name => $object) {
$saver_method =
'save' . str_replace(' ', '', ucwords(strtr($name, '_', ' ')));
if (method_exists($this, $saver_method)) {
$object = $this->sub_data_objects[$name];
if (
$object instanceof SwatDBRecordable &&
$object->isModified()
) {
return true;
}
}
}
return false;
} | [
"public",
"function",
"isModified",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"read_only",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getProperties",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"hashed_value",
"=",
"$",
"this",
"->",
"getHashValue",
"(",
"$",
"value",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"property_hashes",
"[",
"$",
"name",
"]",
")",
"&&",
"$",
"hashed_value",
"!==",
"$",
"this",
"->",
"property_hashes",
"[",
"$",
"name",
"]",
")",
"{",
"return",
"true",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"internal_property_autosave",
"as",
"$",
"name",
"=>",
"$",
"autosave",
")",
"{",
"if",
"(",
"$",
"autosave",
"&&",
"isset",
"(",
"$",
"this",
"->",
"sub_data_objects",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"sub_data_objects",
"[",
"$",
"name",
"]",
";",
"if",
"(",
"$",
"object",
"instanceof",
"SwatDBRecordable",
"&&",
"$",
"object",
"->",
"isModified",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"sub_data_objects",
"as",
"$",
"name",
"=>",
"$",
"object",
")",
"{",
"$",
"saver_method",
"=",
"'save'",
".",
"str_replace",
"(",
"' '",
",",
"''",
",",
"ucwords",
"(",
"strtr",
"(",
"$",
"name",
",",
"'_'",
",",
"' '",
")",
")",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"saver_method",
")",
")",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"sub_data_objects",
"[",
"$",
"name",
"]",
";",
"if",
"(",
"$",
"object",
"instanceof",
"SwatDBRecordable",
"&&",
"$",
"object",
"->",
"isModified",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns true if this object has been modified since it was loaded
@return boolean true if this object was modified and false if this
object was not modified. | [
"Returns",
"true",
"if",
"this",
"object",
"has",
"been",
"modified",
"since",
"it",
"was",
"loaded"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L1144-L1188 |
33,730 | silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.saveNewBinding | protected function saveNewBinding()
{
$modified_properties = $this->getModifiedProperties();
if (count($modified_properties) === 0) {
return;
}
$fields = array();
$values = array();
foreach ($this->getModifiedProperties() as $name => $value) {
$type = $this->guessType($name, $value);
$fields[] = sprintf('%s:%s', $type, $name);
$values[$name] = $value;
}
SwatDB::insertRow($this->db, $this->table, $fields, $values);
$this->flushCacheNamespaces();
} | php | protected function saveNewBinding()
{
$modified_properties = $this->getModifiedProperties();
if (count($modified_properties) === 0) {
return;
}
$fields = array();
$values = array();
foreach ($this->getModifiedProperties() as $name => $value) {
$type = $this->guessType($name, $value);
$fields[] = sprintf('%s:%s', $type, $name);
$values[$name] = $value;
}
SwatDB::insertRow($this->db, $this->table, $fields, $values);
$this->flushCacheNamespaces();
} | [
"protected",
"function",
"saveNewBinding",
"(",
")",
"{",
"$",
"modified_properties",
"=",
"$",
"this",
"->",
"getModifiedProperties",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"modified_properties",
")",
"===",
"0",
")",
"{",
"return",
";",
"}",
"$",
"fields",
"=",
"array",
"(",
")",
";",
"$",
"values",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getModifiedProperties",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"guessType",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"$",
"fields",
"[",
"]",
"=",
"sprintf",
"(",
"'%s:%s'",
",",
"$",
"type",
",",
"$",
"name",
")",
";",
"$",
"values",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"SwatDB",
"::",
"insertRow",
"(",
"$",
"this",
"->",
"db",
",",
"$",
"this",
"->",
"table",
",",
"$",
"fields",
",",
"$",
"values",
")",
";",
"$",
"this",
"->",
"flushCacheNamespaces",
"(",
")",
";",
"}"
] | Saves a new binding object without an id to the database
Only modified properties are saved. It is always inserted,
never updated. | [
"Saves",
"a",
"new",
"binding",
"object",
"without",
"an",
"id",
"to",
"the",
"database"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L1429-L1448 |
33,731 | silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.flushCacheNamespaces | public function flushCacheNamespaces($ns_array = null)
{
if ($ns_array === null) {
$ns_array = $this->getCacheNamespaces();
}
if ($this->flushable_cache instanceof SwatDBCacheNsFlushable) {
$ns_array = array_unique($ns_array);
foreach ($ns_array as $ns) {
$this->flushable_cache->flushNs($ns);
}
}
} | php | public function flushCacheNamespaces($ns_array = null)
{
if ($ns_array === null) {
$ns_array = $this->getCacheNamespaces();
}
if ($this->flushable_cache instanceof SwatDBCacheNsFlushable) {
$ns_array = array_unique($ns_array);
foreach ($ns_array as $ns) {
$this->flushable_cache->flushNs($ns);
}
}
} | [
"public",
"function",
"flushCacheNamespaces",
"(",
"$",
"ns_array",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"ns_array",
"===",
"null",
")",
"{",
"$",
"ns_array",
"=",
"$",
"this",
"->",
"getCacheNamespaces",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"flushable_cache",
"instanceof",
"SwatDBCacheNsFlushable",
")",
"{",
"$",
"ns_array",
"=",
"array_unique",
"(",
"$",
"ns_array",
")",
";",
"foreach",
"(",
"$",
"ns_array",
"as",
"$",
"ns",
")",
"{",
"$",
"this",
"->",
"flushable_cache",
"->",
"flushNs",
"(",
"$",
"ns",
")",
";",
"}",
"}",
"}"
] | Flushes the cache name-spaces for this object.
@param array $ns_array An optional array of name-spaces to flush.
If no name-spaces are specified,
{@link SwatDBDataObject::getCacheNamespaces()} is
used to get the array of name-spaces.
@see SwatDBDataObject::setFlushableCache()
@see SwatDBDataObject::getCacheNamespaces() | [
"Flushes",
"the",
"cache",
"name",
"-",
"spaces",
"for",
"this",
"object",
"."
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L1544-L1556 |
33,732 | honey-comb/core | src/Http/Controllers/HCBaseController.php | HCBaseController.getUserActions | protected function getUserActions(string $prefix, array $except = []): array
{
$actions = [];
if (!in_array('_search', $except)) {
$actions[] = 'search';
}
if (!in_array('_create', $except) && auth()->user()->can($prefix . '_create')) {
$actions[] = 'new';
}
if (!in_array('_update', $except) && auth()->user()->can($prefix . '_update')) {
$actions[] = 'update';
}
if (!in_array('_delete', $except) && auth()->user()->can($prefix . '_delete')) {
$actions[] = 'delete';
}
if (!in_array('_restore', $except) && auth()->user()->can($prefix . '_restore')) {
$actions[] = 'restore';
}
if (!in_array('_force_delete', $except) && auth()->user()->can($prefix . '_force_delete')) {
$actions[] = 'forceDelete';
}
if (!in_array('_merge', $except) && auth()->user()->can($prefix . '_merge')) {
$actions[] = 'merge';
}
if (!in_array('_clone', $except) && auth()->user()->can($prefix . '_clone')) {
$actions[] = 'clone';
}
return $actions;
} | php | protected function getUserActions(string $prefix, array $except = []): array
{
$actions = [];
if (!in_array('_search', $except)) {
$actions[] = 'search';
}
if (!in_array('_create', $except) && auth()->user()->can($prefix . '_create')) {
$actions[] = 'new';
}
if (!in_array('_update', $except) && auth()->user()->can($prefix . '_update')) {
$actions[] = 'update';
}
if (!in_array('_delete', $except) && auth()->user()->can($prefix . '_delete')) {
$actions[] = 'delete';
}
if (!in_array('_restore', $except) && auth()->user()->can($prefix . '_restore')) {
$actions[] = 'restore';
}
if (!in_array('_force_delete', $except) && auth()->user()->can($prefix . '_force_delete')) {
$actions[] = 'forceDelete';
}
if (!in_array('_merge', $except) && auth()->user()->can($prefix . '_merge')) {
$actions[] = 'merge';
}
if (!in_array('_clone', $except) && auth()->user()->can($prefix . '_clone')) {
$actions[] = 'clone';
}
return $actions;
} | [
"protected",
"function",
"getUserActions",
"(",
"string",
"$",
"prefix",
",",
"array",
"$",
"except",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"actions",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"in_array",
"(",
"'_search'",
",",
"$",
"except",
")",
")",
"{",
"$",
"actions",
"[",
"]",
"=",
"'search'",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"'_create'",
",",
"$",
"except",
")",
"&&",
"auth",
"(",
")",
"->",
"user",
"(",
")",
"->",
"can",
"(",
"$",
"prefix",
".",
"'_create'",
")",
")",
"{",
"$",
"actions",
"[",
"]",
"=",
"'new'",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"'_update'",
",",
"$",
"except",
")",
"&&",
"auth",
"(",
")",
"->",
"user",
"(",
")",
"->",
"can",
"(",
"$",
"prefix",
".",
"'_update'",
")",
")",
"{",
"$",
"actions",
"[",
"]",
"=",
"'update'",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"'_delete'",
",",
"$",
"except",
")",
"&&",
"auth",
"(",
")",
"->",
"user",
"(",
")",
"->",
"can",
"(",
"$",
"prefix",
".",
"'_delete'",
")",
")",
"{",
"$",
"actions",
"[",
"]",
"=",
"'delete'",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"'_restore'",
",",
"$",
"except",
")",
"&&",
"auth",
"(",
")",
"->",
"user",
"(",
")",
"->",
"can",
"(",
"$",
"prefix",
".",
"'_restore'",
")",
")",
"{",
"$",
"actions",
"[",
"]",
"=",
"'restore'",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"'_force_delete'",
",",
"$",
"except",
")",
"&&",
"auth",
"(",
")",
"->",
"user",
"(",
")",
"->",
"can",
"(",
"$",
"prefix",
".",
"'_force_delete'",
")",
")",
"{",
"$",
"actions",
"[",
"]",
"=",
"'forceDelete'",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"'_merge'",
",",
"$",
"except",
")",
"&&",
"auth",
"(",
")",
"->",
"user",
"(",
")",
"->",
"can",
"(",
"$",
"prefix",
".",
"'_merge'",
")",
")",
"{",
"$",
"actions",
"[",
"]",
"=",
"'merge'",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"'_clone'",
",",
"$",
"except",
")",
"&&",
"auth",
"(",
")",
"->",
"user",
"(",
")",
"->",
"can",
"(",
"$",
"prefix",
".",
"'_clone'",
")",
")",
"{",
"$",
"actions",
"[",
"]",
"=",
"'clone'",
";",
"}",
"return",
"$",
"actions",
";",
"}"
] | Getting allowed actions for admin view
@param string $prefix
@param array $except
@return array
@throws \Illuminate\Contracts\Container\BindingResolutionException | [
"Getting",
"allowed",
"actions",
"for",
"admin",
"view"
] | 5c12aba31cae092e9681f0ae3e3664ed3fcec956 | https://github.com/honey-comb/core/blob/5c12aba31cae092e9681f0ae3e3664ed3fcec956/src/Http/Controllers/HCBaseController.php#L59-L96 |
33,733 | brainworxx/kreXX | src/Analyse/Callback/Iterate/ThroughConstants.php | ThroughConstants.callMe | public function callMe()
{
$output = $this->dispatchStartEvent();
// We do not need to check the recursionHandler, this is class
// internal stuff. Is it even possible to create a recursion here?
// Iterate through.
foreach ($this->parameters[static::PARAM_DATA] as $k => &$v) {
$output .= $this->pool->routing->analysisHub(
$this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Model')
->setData($v)
->setName($k)
->setCustomConnectorLeft($this->parameters[static::PARAM_CLASSNAME] . '::')
);
}
return $output;
} | php | public function callMe()
{
$output = $this->dispatchStartEvent();
// We do not need to check the recursionHandler, this is class
// internal stuff. Is it even possible to create a recursion here?
// Iterate through.
foreach ($this->parameters[static::PARAM_DATA] as $k => &$v) {
$output .= $this->pool->routing->analysisHub(
$this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Model')
->setData($v)
->setName($k)
->setCustomConnectorLeft($this->parameters[static::PARAM_CLASSNAME] . '::')
);
}
return $output;
} | [
"public",
"function",
"callMe",
"(",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"dispatchStartEvent",
"(",
")",
";",
"// We do not need to check the recursionHandler, this is class",
"// internal stuff. Is it even possible to create a recursion here?",
"// Iterate through.",
"foreach",
"(",
"$",
"this",
"->",
"parameters",
"[",
"static",
"::",
"PARAM_DATA",
"]",
"as",
"$",
"k",
"=>",
"&",
"$",
"v",
")",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"pool",
"->",
"routing",
"->",
"analysisHub",
"(",
"$",
"this",
"->",
"pool",
"->",
"createClass",
"(",
"'Brainworxx\\\\Krexx\\\\Analyse\\\\Model'",
")",
"->",
"setData",
"(",
"$",
"v",
")",
"->",
"setName",
"(",
"$",
"k",
")",
"->",
"setCustomConnectorLeft",
"(",
"$",
"this",
"->",
"parameters",
"[",
"static",
"::",
"PARAM_CLASSNAME",
"]",
".",
"'::'",
")",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] | Simply iterate though object constants.
@return string
The generated markup. | [
"Simply",
"iterate",
"though",
"object",
"constants",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Callback/Iterate/ThroughConstants.php#L62-L79 |
33,734 | silverorange/swat | Swat/SwatCheckboxList.php | SwatCheckboxList.init | public function init()
{
parent::init();
// checks to see if there are duplicate values in the options array
$options_count = array();
foreach ($this->getOptions() as $option) {
$options_count[] = $option->value;
}
foreach (array_count_values($options_count) as $count) {
if ($count > 1) {
throw new SwatException(
sprintf('Duplicate option values found in %s', $this->id)
);
}
}
} | php | public function init()
{
parent::init();
// checks to see if there are duplicate values in the options array
$options_count = array();
foreach ($this->getOptions() as $option) {
$options_count[] = $option->value;
}
foreach (array_count_values($options_count) as $count) {
if ($count > 1) {
throw new SwatException(
sprintf('Duplicate option values found in %s', $this->id)
);
}
}
} | [
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"// checks to see if there are duplicate values in the options array",
"$",
"options_count",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getOptions",
"(",
")",
"as",
"$",
"option",
")",
"{",
"$",
"options_count",
"[",
"]",
"=",
"$",
"option",
"->",
"value",
";",
"}",
"foreach",
"(",
"array_count_values",
"(",
"$",
"options_count",
")",
"as",
"$",
"count",
")",
"{",
"if",
"(",
"$",
"count",
">",
"1",
")",
"{",
"throw",
"new",
"SwatException",
"(",
"sprintf",
"(",
"'Duplicate option values found in %s'",
",",
"$",
"this",
"->",
"id",
")",
")",
";",
"}",
"}",
"}"
] | Initializes this checkbox list
@throws SwatException if there are duplicate values in the options array | [
"Initializes",
"this",
"checkbox",
"list"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCheckboxList.php#L83-L100 |
33,735 | silverorange/swat | Swat/SwatCheckboxList.php | SwatCheckboxList.process | public function process()
{
if (!$this->getForm()->isSubmitted()) {
return;
}
parent::process();
$this->processValues();
if (
$this->required &&
count($this->values) == 0 &&
$this->isSensitive()
) {
$this->addMessage($this->getValidationMessage('required'));
}
} | php | public function process()
{
if (!$this->getForm()->isSubmitted()) {
return;
}
parent::process();
$this->processValues();
if (
$this->required &&
count($this->values) == 0 &&
$this->isSensitive()
) {
$this->addMessage($this->getValidationMessage('required'));
}
} | [
"public",
"function",
"process",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getForm",
"(",
")",
"->",
"isSubmitted",
"(",
")",
")",
"{",
"return",
";",
"}",
"parent",
"::",
"process",
"(",
")",
";",
"$",
"this",
"->",
"processValues",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"required",
"&&",
"count",
"(",
"$",
"this",
"->",
"values",
")",
"==",
"0",
"&&",
"$",
"this",
"->",
"isSensitive",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addMessage",
"(",
"$",
"this",
"->",
"getValidationMessage",
"(",
"'required'",
")",
")",
";",
"}",
"}"
] | Processes this checkbox list widget | [
"Processes",
"this",
"checkbox",
"list",
"widget"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCheckboxList.php#L197-L214 |
33,736 | silverorange/swat | Swat/SwatCheckboxList.php | SwatCheckboxList.processValues | protected function processValues()
{
$form = $this->getForm();
$data = &$form->getFormData();
if (isset($data[$this->id])) {
if (is_array($data[$this->id])) {
$this->values = $data[$this->id];
} elseif ($data[$this->id] != '') {
$this->values = array($data[$this->id]);
} else {
$this->values = array();
}
} else {
$this->values = array();
}
} | php | protected function processValues()
{
$form = $this->getForm();
$data = &$form->getFormData();
if (isset($data[$this->id])) {
if (is_array($data[$this->id])) {
$this->values = $data[$this->id];
} elseif ($data[$this->id] != '') {
$this->values = array($data[$this->id]);
} else {
$this->values = array();
}
} else {
$this->values = array();
}
} | [
"protected",
"function",
"processValues",
"(",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"getForm",
"(",
")",
";",
"$",
"data",
"=",
"&",
"$",
"form",
"->",
"getFormData",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"$",
"this",
"->",
"id",
"]",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
"[",
"$",
"this",
"->",
"id",
"]",
")",
")",
"{",
"$",
"this",
"->",
"values",
"=",
"$",
"data",
"[",
"$",
"this",
"->",
"id",
"]",
";",
"}",
"elseif",
"(",
"$",
"data",
"[",
"$",
"this",
"->",
"id",
"]",
"!=",
"''",
")",
"{",
"$",
"this",
"->",
"values",
"=",
"array",
"(",
"$",
"data",
"[",
"$",
"this",
"->",
"id",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"values",
"=",
"array",
"(",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"values",
"=",
"array",
"(",
")",
";",
"}",
"}"
] | Processes the values of this checkbox list from raw form data | [
"Processes",
"the",
"values",
"of",
"this",
"checkbox",
"list",
"from",
"raw",
"form",
"data"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCheckboxList.php#L266-L282 |
33,737 | silverorange/swat | Swat/SwatCheckboxList.php | SwatCheckboxList.displayOption | protected function displayOption(SwatOption $option, $index)
{
$input_tag = new SwatHtmlTag('input');
$input_tag->type = 'checkbox';
$input_tag->name = $this->id . '[' . $index . ']';
$input_tag->value = (string) $option->value;
$input_tag->id = $this->id . '_' . $index;
$input_tag->removeAttribute('checked');
if (in_array($option->value, $this->values)) {
$input_tag->checked = 'checked';
}
if (!$this->isSensitive()) {
$input_tag->disabled = 'disabled';
}
$li_tag = $this->getLiTag($option);
$li_tag->open();
echo '<span class="swat-checkbox-wrapper">';
$input_tag->display();
echo '<span class="swat-checkbox-shim"></span>';
echo '</span>';
$this->displayOptionLabel($option, $index);
$li_tag->close();
} | php | protected function displayOption(SwatOption $option, $index)
{
$input_tag = new SwatHtmlTag('input');
$input_tag->type = 'checkbox';
$input_tag->name = $this->id . '[' . $index . ']';
$input_tag->value = (string) $option->value;
$input_tag->id = $this->id . '_' . $index;
$input_tag->removeAttribute('checked');
if (in_array($option->value, $this->values)) {
$input_tag->checked = 'checked';
}
if (!$this->isSensitive()) {
$input_tag->disabled = 'disabled';
}
$li_tag = $this->getLiTag($option);
$li_tag->open();
echo '<span class="swat-checkbox-wrapper">';
$input_tag->display();
echo '<span class="swat-checkbox-shim"></span>';
echo '</span>';
$this->displayOptionLabel($option, $index);
$li_tag->close();
} | [
"protected",
"function",
"displayOption",
"(",
"SwatOption",
"$",
"option",
",",
"$",
"index",
")",
"{",
"$",
"input_tag",
"=",
"new",
"SwatHtmlTag",
"(",
"'input'",
")",
";",
"$",
"input_tag",
"->",
"type",
"=",
"'checkbox'",
";",
"$",
"input_tag",
"->",
"name",
"=",
"$",
"this",
"->",
"id",
".",
"'['",
".",
"$",
"index",
".",
"']'",
";",
"$",
"input_tag",
"->",
"value",
"=",
"(",
"string",
")",
"$",
"option",
"->",
"value",
";",
"$",
"input_tag",
"->",
"id",
"=",
"$",
"this",
"->",
"id",
".",
"'_'",
".",
"$",
"index",
";",
"$",
"input_tag",
"->",
"removeAttribute",
"(",
"'checked'",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"option",
"->",
"value",
",",
"$",
"this",
"->",
"values",
")",
")",
"{",
"$",
"input_tag",
"->",
"checked",
"=",
"'checked'",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isSensitive",
"(",
")",
")",
"{",
"$",
"input_tag",
"->",
"disabled",
"=",
"'disabled'",
";",
"}",
"$",
"li_tag",
"=",
"$",
"this",
"->",
"getLiTag",
"(",
"$",
"option",
")",
";",
"$",
"li_tag",
"->",
"open",
"(",
")",
";",
"echo",
"'<span class=\"swat-checkbox-wrapper\">'",
";",
"$",
"input_tag",
"->",
"display",
"(",
")",
";",
"echo",
"'<span class=\"swat-checkbox-shim\"></span>'",
";",
"echo",
"'</span>'",
";",
"$",
"this",
"->",
"displayOptionLabel",
"(",
"$",
"option",
",",
"$",
"index",
")",
";",
"$",
"li_tag",
"->",
"close",
"(",
")",
";",
"}"
] | Helper method to display a single option of this checkbox list
@param SwatOption $option the option to display.
@param integer $index a numeric index indicating which option is being
displayed. Starts as 0. | [
"Helper",
"method",
"to",
"display",
"a",
"single",
"option",
"of",
"this",
"checkbox",
"list"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCheckboxList.php#L294-L320 |
33,738 | silverorange/swat | Swat/SwatCheckboxList.php | SwatCheckboxList.getInlineJavaScript | protected function getInlineJavaScript()
{
$javascript = sprintf(
'var %s_obj = new %s(%s);',
$this->id,
$this->getJavaScriptClassName(),
SwatString::quoteJavaScriptString($this->id)
);
// set check-all controller if it is visible
$check_all = $this->getCompositeWidget('check_all');
if ($check_all->visible) {
$javascript .= sprintf(
"\n%s_obj.setController(%s_obj);",
$check_all->id,
$this->id
);
}
return $javascript;
} | php | protected function getInlineJavaScript()
{
$javascript = sprintf(
'var %s_obj = new %s(%s);',
$this->id,
$this->getJavaScriptClassName(),
SwatString::quoteJavaScriptString($this->id)
);
// set check-all controller if it is visible
$check_all = $this->getCompositeWidget('check_all');
if ($check_all->visible) {
$javascript .= sprintf(
"\n%s_obj.setController(%s_obj);",
$check_all->id,
$this->id
);
}
return $javascript;
} | [
"protected",
"function",
"getInlineJavaScript",
"(",
")",
"{",
"$",
"javascript",
"=",
"sprintf",
"(",
"'var %s_obj = new %s(%s);'",
",",
"$",
"this",
"->",
"id",
",",
"$",
"this",
"->",
"getJavaScriptClassName",
"(",
")",
",",
"SwatString",
"::",
"quoteJavaScriptString",
"(",
"$",
"this",
"->",
"id",
")",
")",
";",
"// set check-all controller if it is visible",
"$",
"check_all",
"=",
"$",
"this",
"->",
"getCompositeWidget",
"(",
"'check_all'",
")",
";",
"if",
"(",
"$",
"check_all",
"->",
"visible",
")",
"{",
"$",
"javascript",
".=",
"sprintf",
"(",
"\"\\n%s_obj.setController(%s_obj);\"",
",",
"$",
"check_all",
"->",
"id",
",",
"$",
"this",
"->",
"id",
")",
";",
"}",
"return",
"$",
"javascript",
";",
"}"
] | Gets the inline JavaScript for this checkbox list
@return string the inline JavaScript for this checkbox list. | [
"Gets",
"the",
"inline",
"JavaScript",
"for",
"this",
"checkbox",
"list"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCheckboxList.php#L379-L399 |
33,739 | silverorange/swat | Swat/SwatWidgetCellRenderer.php | SwatWidgetCellRenderer.init | public function init()
{
$replicators = null;
$form = $this->getForm();
if ($form !== null && $form->isSubmitted()) {
$replicators = $form->getHiddenField(
$this->getReplicatorFieldName()
);
if ($replicators !== null) {
foreach ($replicators as $replicator) {
$this->createClonedWidget($replicator);
}
}
}
if ($replicators === null) {
$this->prototype_widget->init();
}
} | php | public function init()
{
$replicators = null;
$form = $this->getForm();
if ($form !== null && $form->isSubmitted()) {
$replicators = $form->getHiddenField(
$this->getReplicatorFieldName()
);
if ($replicators !== null) {
foreach ($replicators as $replicator) {
$this->createClonedWidget($replicator);
}
}
}
if ($replicators === null) {
$this->prototype_widget->init();
}
} | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"replicators",
"=",
"null",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"getForm",
"(",
")",
";",
"if",
"(",
"$",
"form",
"!==",
"null",
"&&",
"$",
"form",
"->",
"isSubmitted",
"(",
")",
")",
"{",
"$",
"replicators",
"=",
"$",
"form",
"->",
"getHiddenField",
"(",
"$",
"this",
"->",
"getReplicatorFieldName",
"(",
")",
")",
";",
"if",
"(",
"$",
"replicators",
"!==",
"null",
")",
"{",
"foreach",
"(",
"$",
"replicators",
"as",
"$",
"replicator",
")",
"{",
"$",
"this",
"->",
"createClonedWidget",
"(",
"$",
"replicator",
")",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"replicators",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"prototype_widget",
"->",
"init",
"(",
")",
";",
"}",
"}"
] | Initializes this cell renderer
This calls {@link SwatWidget::init()} on this renderer's widget. | [
"Initializes",
"this",
"cell",
"renderer"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatWidgetCellRenderer.php#L140-L160 |
33,740 | silverorange/swat | Swat/SwatWidgetCellRenderer.php | SwatWidgetCellRenderer.getWidget | public function getWidget($replicator_id, $widget_id = null)
{
$widget = null;
if ($widget_id === null) {
if (isset($this->widgets[$replicator_id])) {
$widget = current($this->widgets[$replicator_id]);
}
} else {
if (isset($this->widgets[$replicator_id][$widget_id])) {
$widget = $this->widgets[$replicator_id][$widget_id];
}
}
return $widget;
} | php | public function getWidget($replicator_id, $widget_id = null)
{
$widget = null;
if ($widget_id === null) {
if (isset($this->widgets[$replicator_id])) {
$widget = current($this->widgets[$replicator_id]);
}
} else {
if (isset($this->widgets[$replicator_id][$widget_id])) {
$widget = $this->widgets[$replicator_id][$widget_id];
}
}
return $widget;
} | [
"public",
"function",
"getWidget",
"(",
"$",
"replicator_id",
",",
"$",
"widget_id",
"=",
"null",
")",
"{",
"$",
"widget",
"=",
"null",
";",
"if",
"(",
"$",
"widget_id",
"===",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"widgets",
"[",
"$",
"replicator_id",
"]",
")",
")",
"{",
"$",
"widget",
"=",
"current",
"(",
"$",
"this",
"->",
"widgets",
"[",
"$",
"replicator_id",
"]",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"widgets",
"[",
"$",
"replicator_id",
"]",
"[",
"$",
"widget_id",
"]",
")",
")",
"{",
"$",
"widget",
"=",
"$",
"this",
"->",
"widgets",
"[",
"$",
"replicator_id",
"]",
"[",
"$",
"widget_id",
"]",
";",
"}",
"}",
"return",
"$",
"widget",
";",
"}"
] | Retrieves a reference to a replicated widget
@param string $replicator_id the replicator id of the replicated widget
@param string $widget_id the unique id of the original widget, or null
to get the root
@return SwatWidget a reference to the replicated widget, or null if the
widget is not found. | [
"Retrieves",
"a",
"reference",
"to",
"a",
"replicated",
"widget"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatWidgetCellRenderer.php#L308-L323 |
33,741 | silverorange/swat | Swat/SwatWidgetCellRenderer.php | SwatWidgetCellRenderer.getWidgets | public function getWidgets($widget_id = null)
{
$form = $this->getForm();
if ($form !== null && $form->isSubmitted()) {
$replicators = $form->getHiddenField(
$this->getReplicatorFieldName()
);
$widgets = array();
if (is_array($replicators)) {
foreach ($this->clones as $replicator_id => $clone) {
if (in_array($replicator_id, $replicators)) {
if (
$widget_id !== null &&
!isset($this->widgets[$replicator_id][$widget_id])
) {
throw new SwatWidgetNotFoundException(
sprintf(
'No widget with the id "%s" exists in the ' .
'cloned widget sub-tree of this ' .
'SwatWidgetCellRenderer.',
$widget_id
),
0,
$widget_id
);
}
$widgets[$replicator_id] = $this->getWidget(
$replicator_id,
$widget_id
);
}
}
}
} else {
$widgets = $this->clones;
}
return $widgets;
} | php | public function getWidgets($widget_id = null)
{
$form = $this->getForm();
if ($form !== null && $form->isSubmitted()) {
$replicators = $form->getHiddenField(
$this->getReplicatorFieldName()
);
$widgets = array();
if (is_array($replicators)) {
foreach ($this->clones as $replicator_id => $clone) {
if (in_array($replicator_id, $replicators)) {
if (
$widget_id !== null &&
!isset($this->widgets[$replicator_id][$widget_id])
) {
throw new SwatWidgetNotFoundException(
sprintf(
'No widget with the id "%s" exists in the ' .
'cloned widget sub-tree of this ' .
'SwatWidgetCellRenderer.',
$widget_id
),
0,
$widget_id
);
}
$widgets[$replicator_id] = $this->getWidget(
$replicator_id,
$widget_id
);
}
}
}
} else {
$widgets = $this->clones;
}
return $widgets;
} | [
"public",
"function",
"getWidgets",
"(",
"$",
"widget_id",
"=",
"null",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"getForm",
"(",
")",
";",
"if",
"(",
"$",
"form",
"!==",
"null",
"&&",
"$",
"form",
"->",
"isSubmitted",
"(",
")",
")",
"{",
"$",
"replicators",
"=",
"$",
"form",
"->",
"getHiddenField",
"(",
"$",
"this",
"->",
"getReplicatorFieldName",
"(",
")",
")",
";",
"$",
"widgets",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"replicators",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"clones",
"as",
"$",
"replicator_id",
"=>",
"$",
"clone",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"replicator_id",
",",
"$",
"replicators",
")",
")",
"{",
"if",
"(",
"$",
"widget_id",
"!==",
"null",
"&&",
"!",
"isset",
"(",
"$",
"this",
"->",
"widgets",
"[",
"$",
"replicator_id",
"]",
"[",
"$",
"widget_id",
"]",
")",
")",
"{",
"throw",
"new",
"SwatWidgetNotFoundException",
"(",
"sprintf",
"(",
"'No widget with the id \"%s\" exists in the '",
".",
"'cloned widget sub-tree of this '",
".",
"'SwatWidgetCellRenderer.'",
",",
"$",
"widget_id",
")",
",",
"0",
",",
"$",
"widget_id",
")",
";",
"}",
"$",
"widgets",
"[",
"$",
"replicator_id",
"]",
"=",
"$",
"this",
"->",
"getWidget",
"(",
"$",
"replicator_id",
",",
"$",
"widget_id",
")",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"$",
"widgets",
"=",
"$",
"this",
"->",
"clones",
";",
"}",
"return",
"$",
"widgets",
";",
"}"
] | Gets an array of replicated widgets indexed by the replicator_id
If this cell renderer's form is submitted, only cloned widgets that were
displayed and processed are returned.
@param string $widget_id the unique id of the original widget, or null
to get the root
@return array an array of widgets indexed by replicator_id
@throws SwatWidgetNotFoundException if a widget id is specified and no
such widget exists in the subtree. | [
"Gets",
"an",
"array",
"of",
"replicated",
"widgets",
"indexed",
"by",
"the",
"replicator_id"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatWidgetCellRenderer.php#L342-L382 |
33,742 | silverorange/swat | Swat/SwatWidgetCellRenderer.php | SwatWidgetCellRenderer.& | public function &getClonedWidgets()
{
$form = $this->getForm();
if ($form !== null && $form->isSubmitted()) {
$replicators = $form->getHiddenField(
$this->getReplicatorFieldName()
);
$clones = array();
foreach ($this->clones as $replicator_id => $clone) {
if (
is_array($replicators) &&
in_array($replicator_id, $replicators)
) {
$clones[$replicator_id] = $clone;
}
}
} else {
$clones = $this->clones;
}
return $clones;
} | php | public function &getClonedWidgets()
{
$form = $this->getForm();
if ($form !== null && $form->isSubmitted()) {
$replicators = $form->getHiddenField(
$this->getReplicatorFieldName()
);
$clones = array();
foreach ($this->clones as $replicator_id => $clone) {
if (
is_array($replicators) &&
in_array($replicator_id, $replicators)
) {
$clones[$replicator_id] = $clone;
}
}
} else {
$clones = $this->clones;
}
return $clones;
} | [
"public",
"function",
"&",
"getClonedWidgets",
"(",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"getForm",
"(",
")",
";",
"if",
"(",
"$",
"form",
"!==",
"null",
"&&",
"$",
"form",
"->",
"isSubmitted",
"(",
")",
")",
"{",
"$",
"replicators",
"=",
"$",
"form",
"->",
"getHiddenField",
"(",
"$",
"this",
"->",
"getReplicatorFieldName",
"(",
")",
")",
";",
"$",
"clones",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"clones",
"as",
"$",
"replicator_id",
"=>",
"$",
"clone",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"replicators",
")",
"&&",
"in_array",
"(",
"$",
"replicator_id",
",",
"$",
"replicators",
")",
")",
"{",
"$",
"clones",
"[",
"$",
"replicator_id",
"]",
"=",
"$",
"clone",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"clones",
"=",
"$",
"this",
"->",
"clones",
";",
"}",
"return",
"$",
"clones",
";",
"}"
] | Gets an array of cloned widgets indexed by the replicator_id
If this cell renderer's form is submitted, only cloned widgets that were
displayed and processed are returned.
@deprecated Use {@link SwatWidgetCellRenderer::getWidgets()} instead.
Pass null to getWidgets() for the same output as this
method.
@return array an array of widgets indexed by replicator_id | [
"Gets",
"an",
"array",
"of",
"cloned",
"widgets",
"indexed",
"by",
"the",
"replicator_id"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatWidgetCellRenderer.php#L399-L421 |
33,743 | silverorange/swat | Swat/SwatWidgetCellRenderer.php | SwatWidgetCellRenderer.getDataSpecificCSSClassNames | public function getDataSpecificCSSClassNames()
{
$classes = array();
if (
$this->replicator_id !== null &&
$this->hasMessage($this->replicator_id)
) {
$classes[] = 'swat-error';
}
return $classes;
} | php | public function getDataSpecificCSSClassNames()
{
$classes = array();
if (
$this->replicator_id !== null &&
$this->hasMessage($this->replicator_id)
) {
$classes[] = 'swat-error';
}
return $classes;
} | [
"public",
"function",
"getDataSpecificCSSClassNames",
"(",
")",
"{",
"$",
"classes",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"replicator_id",
"!==",
"null",
"&&",
"$",
"this",
"->",
"hasMessage",
"(",
"$",
"this",
"->",
"replicator_id",
")",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"'swat-error'",
";",
"}",
"return",
"$",
"classes",
";",
"}"
] | Gets the data specific CSS class names for this widget cell renderer
If the widget within this cell renderer has messages, a CSS class of
'swat-error' is added to the base CSS classes of this cell renderer.
@return array the array of data specific CSS class names for this widget
cell-renderer. | [
"Gets",
"the",
"data",
"specific",
"CSS",
"class",
"names",
"for",
"this",
"widget",
"cell",
"renderer"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatWidgetCellRenderer.php#L435-L447 |
33,744 | silverorange/swat | Swat/SwatWidgetCellRenderer.php | SwatWidgetCellRenderer.getMessages | public function getMessages($replicator_id = null)
{
$messages = array();
if ($replicator_id !== null) {
$messages = $this->getClonedWidget($replicator_id)->getMessages();
} elseif ($this->replicator_id !== null) {
$messages = $this->getClonedWidget(
$this->replicator_id
)->getMessages();
}
return $messages;
} | php | public function getMessages($replicator_id = null)
{
$messages = array();
if ($replicator_id !== null) {
$messages = $this->getClonedWidget($replicator_id)->getMessages();
} elseif ($this->replicator_id !== null) {
$messages = $this->getClonedWidget(
$this->replicator_id
)->getMessages();
}
return $messages;
} | [
"public",
"function",
"getMessages",
"(",
"$",
"replicator_id",
"=",
"null",
")",
"{",
"$",
"messages",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"replicator_id",
"!==",
"null",
")",
"{",
"$",
"messages",
"=",
"$",
"this",
"->",
"getClonedWidget",
"(",
"$",
"replicator_id",
")",
"->",
"getMessages",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"replicator_id",
"!==",
"null",
")",
"{",
"$",
"messages",
"=",
"$",
"this",
"->",
"getClonedWidget",
"(",
"$",
"this",
"->",
"replicator_id",
")",
"->",
"getMessages",
"(",
")",
";",
"}",
"return",
"$",
"messages",
";",
"}"
] | Gathers all messages from the widget of this cell renderer for the given
replicator id
@param mixed $replicator_id an optional replicator id of the row to
gather messages from. If no replicator id
is specified, the current replicator_id is
used.
@return array an array of {@link SwatMessage} objects. | [
"Gathers",
"all",
"messages",
"from",
"the",
"widget",
"of",
"this",
"cell",
"renderer",
"for",
"the",
"given",
"replicator",
"id"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatWidgetCellRenderer.php#L463-L476 |
33,745 | silverorange/swat | Swat/SwatWidgetCellRenderer.php | SwatWidgetCellRenderer.hasMessage | public function hasMessage($replicator_id = null)
{
$has_message = false;
if ($replicator_id !== null) {
$has_message = $this->getClonedWidget($replicator_id)->hasMessage();
} elseif ($this->replicator_id !== null) {
$has_message = $this->getClonedWidget(
$this->replicator_id
)->hasMessage();
}
return $has_message;
} | php | public function hasMessage($replicator_id = null)
{
$has_message = false;
if ($replicator_id !== null) {
$has_message = $this->getClonedWidget($replicator_id)->hasMessage();
} elseif ($this->replicator_id !== null) {
$has_message = $this->getClonedWidget(
$this->replicator_id
)->hasMessage();
}
return $has_message;
} | [
"public",
"function",
"hasMessage",
"(",
"$",
"replicator_id",
"=",
"null",
")",
"{",
"$",
"has_message",
"=",
"false",
";",
"if",
"(",
"$",
"replicator_id",
"!==",
"null",
")",
"{",
"$",
"has_message",
"=",
"$",
"this",
"->",
"getClonedWidget",
"(",
"$",
"replicator_id",
")",
"->",
"hasMessage",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"replicator_id",
"!==",
"null",
")",
"{",
"$",
"has_message",
"=",
"$",
"this",
"->",
"getClonedWidget",
"(",
"$",
"this",
"->",
"replicator_id",
")",
"->",
"hasMessage",
"(",
")",
";",
"}",
"return",
"$",
"has_message",
";",
"}"
] | Gets whether or not this widget cell renderer has messages
@param mixed $replicator_id an optional replicator id of the row to
check for messages. If no replicator id is
specified, the current replicator_id is
used.
@return boolean true if this widget cell renderer has one or more
messages for the given replicator id and false if it
does not. | [
"Gets",
"whether",
"or",
"not",
"this",
"widget",
"cell",
"renderer",
"has",
"messages"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatWidgetCellRenderer.php#L493-L506 |
33,746 | silverorange/swat | Swat/SwatWidgetCellRenderer.php | SwatWidgetCellRenderer.getTitle | public function getTitle()
{
$title = null;
if (isset($this->parent->title)) {
$title = $this->parent->title;
}
return $title;
} | php | public function getTitle()
{
$title = null;
if (isset($this->parent->title)) {
$title = $this->parent->title;
}
return $title;
} | [
"public",
"function",
"getTitle",
"(",
")",
"{",
"$",
"title",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parent",
"->",
"title",
")",
")",
"{",
"$",
"title",
"=",
"$",
"this",
"->",
"parent",
"->",
"title",
";",
"}",
"return",
"$",
"title",
";",
"}"
] | Gets the title of this widget cell renderer
The title is taken from this cell renderer's parent.
Satisfies the {SwatTitleable::getTitle()} interface.
@return string the title of this widget cell renderer. | [
"Gets",
"the",
"title",
"of",
"this",
"widget",
"cell",
"renderer"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatWidgetCellRenderer.php#L519-L528 |
33,747 | silverorange/swat | Swat/SwatWidgetCellRenderer.php | SwatWidgetCellRenderer.getTitleContentType | public function getTitleContentType()
{
$title_content_type = 'text/plain';
if (isset($this->parent->title_content_type)) {
$title_content_type = $this->parent->title_content_type;
}
return $title_content_type;
} | php | public function getTitleContentType()
{
$title_content_type = 'text/plain';
if (isset($this->parent->title_content_type)) {
$title_content_type = $this->parent->title_content_type;
}
return $title_content_type;
} | [
"public",
"function",
"getTitleContentType",
"(",
")",
"{",
"$",
"title_content_type",
"=",
"'text/plain'",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parent",
"->",
"title_content_type",
")",
")",
"{",
"$",
"title_content_type",
"=",
"$",
"this",
"->",
"parent",
"->",
"title_content_type",
";",
"}",
"return",
"$",
"title_content_type",
";",
"}"
] | Gets the title content-type of this widget cell renderer
Implements the {@link SwatTitleable::getTitleContentType()} interface.
@return string the title content-type of this widget cell renderer. | [
"Gets",
"the",
"title",
"content",
"-",
"type",
"of",
"this",
"widget",
"cell",
"renderer"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatWidgetCellRenderer.php#L540-L549 |
33,748 | silverorange/swat | Swat/SwatWidgetCellRenderer.php | SwatWidgetCellRenderer.getHtmlHeadEntrySet | public function getHtmlHeadEntrySet()
{
$set = parent::getHtmlHeadEntrySet();
if ($this->using_null_replication) {
$set->addEntrySet(
$this->getPrototypeWidget()->getHtmlHeadEntrySet()
);
} else {
$widgets = $this->getWidgets();
foreach ($widgets as $widget) {
$set->addEntrySet($widget->getHtmlHeadEntrySet());
}
}
return $set;
} | php | public function getHtmlHeadEntrySet()
{
$set = parent::getHtmlHeadEntrySet();
if ($this->using_null_replication) {
$set->addEntrySet(
$this->getPrototypeWidget()->getHtmlHeadEntrySet()
);
} else {
$widgets = $this->getWidgets();
foreach ($widgets as $widget) {
$set->addEntrySet($widget->getHtmlHeadEntrySet());
}
}
return $set;
} | [
"public",
"function",
"getHtmlHeadEntrySet",
"(",
")",
"{",
"$",
"set",
"=",
"parent",
"::",
"getHtmlHeadEntrySet",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"using_null_replication",
")",
"{",
"$",
"set",
"->",
"addEntrySet",
"(",
"$",
"this",
"->",
"getPrototypeWidget",
"(",
")",
"->",
"getHtmlHeadEntrySet",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"widgets",
"=",
"$",
"this",
"->",
"getWidgets",
"(",
")",
";",
"foreach",
"(",
"$",
"widgets",
"as",
"$",
"widget",
")",
"{",
"$",
"set",
"->",
"addEntrySet",
"(",
"$",
"widget",
"->",
"getHtmlHeadEntrySet",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"set",
";",
"}"
] | Gets the SwatHtmlHeadEntry objects needed by this widget cell renderer
@return SwatHtmlHeadEntrySet the SwatHtmlHeadEntry objects needed by
this widget cell renderer.
@see SwatUIObject::getHtmlHeadEntrySet() | [
"Gets",
"the",
"SwatHtmlHeadEntry",
"objects",
"needed",
"by",
"this",
"widget",
"cell",
"renderer"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatWidgetCellRenderer.php#L562-L578 |
33,749 | silverorange/swat | Swat/SwatWidgetCellRenderer.php | SwatWidgetCellRenderer.getAvailableHtmlHeadEntrySet | public function getAvailableHtmlHeadEntrySet()
{
$set = parent::getAvailableHtmlHeadEntrySet();
if ($this->using_null_replication) {
$set->addEntrySet(
$this->getPrototypeWidget()->getAvailableHtmlHeadEntrySet()
);
} else {
$widgets = $this->getWidgets();
foreach ($widgets as $widget) {
$set->addEntrySet($widget->getAvailableHtmlHeadEntrySet());
}
}
return $set;
} | php | public function getAvailableHtmlHeadEntrySet()
{
$set = parent::getAvailableHtmlHeadEntrySet();
if ($this->using_null_replication) {
$set->addEntrySet(
$this->getPrototypeWidget()->getAvailableHtmlHeadEntrySet()
);
} else {
$widgets = $this->getWidgets();
foreach ($widgets as $widget) {
$set->addEntrySet($widget->getAvailableHtmlHeadEntrySet());
}
}
return $set;
} | [
"public",
"function",
"getAvailableHtmlHeadEntrySet",
"(",
")",
"{",
"$",
"set",
"=",
"parent",
"::",
"getAvailableHtmlHeadEntrySet",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"using_null_replication",
")",
"{",
"$",
"set",
"->",
"addEntrySet",
"(",
"$",
"this",
"->",
"getPrototypeWidget",
"(",
")",
"->",
"getAvailableHtmlHeadEntrySet",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"widgets",
"=",
"$",
"this",
"->",
"getWidgets",
"(",
")",
";",
"foreach",
"(",
"$",
"widgets",
"as",
"$",
"widget",
")",
"{",
"$",
"set",
"->",
"addEntrySet",
"(",
"$",
"widget",
"->",
"getAvailableHtmlHeadEntrySet",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"set",
";",
"}"
] | Gets the SwatHtmlHeadEntry objects that may be needed by this widget
cell renderer
@return SwatHtmlHeadEntrySet the SwatHtmlHeadEntry objects that may be
needed by this widget cell renderer.
@see SwatUIObject::getAvailableHtmlHeadEntrySet() | [
"Gets",
"the",
"SwatHtmlHeadEntry",
"objects",
"that",
"may",
"be",
"needed",
"by",
"this",
"widget",
"cell",
"renderer"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatWidgetCellRenderer.php#L592-L608 |
33,750 | silverorange/swat | Swat/SwatContentBlock.php | SwatContentBlock.display | public function display()
{
if (!$this->visible) {
return;
}
parent::display();
if ($this->content_type === 'text/plain') {
echo SwatString::minimizeEntities($this->content);
} else {
echo $this->content;
}
} | php | public function display()
{
if (!$this->visible) {
return;
}
parent::display();
if ($this->content_type === 'text/plain') {
echo SwatString::minimizeEntities($this->content);
} else {
echo $this->content;
}
} | [
"public",
"function",
"display",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"visible",
")",
"{",
"return",
";",
"}",
"parent",
"::",
"display",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"content_type",
"===",
"'text/plain'",
")",
"{",
"echo",
"SwatString",
"::",
"minimizeEntities",
"(",
"$",
"this",
"->",
"content",
")",
";",
"}",
"else",
"{",
"echo",
"$",
"this",
"->",
"content",
";",
"}",
"}"
] | Displays this content
Merely performs an echo of the content. | [
"Displays",
"this",
"content"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatContentBlock.php#L38-L51 |
33,751 | brainworxx/kreXX | src/Controller/EditSettingsController.php | EditSettingsController.editSettingsAction | public function editSettingsAction()
{
if ($this->pool->emergencyHandler->checkMaxCall() === true) {
// Called too often, we might get into trouble here!
return $this;
}
$this->pool->reset();
// We will not check this for the cookie config, to avoid people locking
// themselves out.
$this->pool->emergencyHandler->setDisable(true);
// Find caller.
$caller = $this->callerFinder->findCaller('Cookie Configuration', array());
$this->pool->chunks->addMetadata($caller);
// Render it.
$footer = $this->outputFooter($caller, true);
$this->pool->chunks->detectEncoding($footer);
$this->outputService
->addChunkString($this->pool->render->renderHeader('Edit local settings', $this->outputCssAndJs()))
->addChunkString($footer);
$this->pool->emergencyHandler->setDisable(false);
$this->outputService->finalize();
return $this;
} | php | public function editSettingsAction()
{
if ($this->pool->emergencyHandler->checkMaxCall() === true) {
// Called too often, we might get into trouble here!
return $this;
}
$this->pool->reset();
// We will not check this for the cookie config, to avoid people locking
// themselves out.
$this->pool->emergencyHandler->setDisable(true);
// Find caller.
$caller = $this->callerFinder->findCaller('Cookie Configuration', array());
$this->pool->chunks->addMetadata($caller);
// Render it.
$footer = $this->outputFooter($caller, true);
$this->pool->chunks->detectEncoding($footer);
$this->outputService
->addChunkString($this->pool->render->renderHeader('Edit local settings', $this->outputCssAndJs()))
->addChunkString($footer);
$this->pool->emergencyHandler->setDisable(false);
$this->outputService->finalize();
return $this;
} | [
"public",
"function",
"editSettingsAction",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"pool",
"->",
"emergencyHandler",
"->",
"checkMaxCall",
"(",
")",
"===",
"true",
")",
"{",
"// Called too often, we might get into trouble here!",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"pool",
"->",
"reset",
"(",
")",
";",
"// We will not check this for the cookie config, to avoid people locking",
"// themselves out.",
"$",
"this",
"->",
"pool",
"->",
"emergencyHandler",
"->",
"setDisable",
"(",
"true",
")",
";",
"// Find caller.",
"$",
"caller",
"=",
"$",
"this",
"->",
"callerFinder",
"->",
"findCaller",
"(",
"'Cookie Configuration'",
",",
"array",
"(",
")",
")",
";",
"$",
"this",
"->",
"pool",
"->",
"chunks",
"->",
"addMetadata",
"(",
"$",
"caller",
")",
";",
"// Render it.",
"$",
"footer",
"=",
"$",
"this",
"->",
"outputFooter",
"(",
"$",
"caller",
",",
"true",
")",
";",
"$",
"this",
"->",
"pool",
"->",
"chunks",
"->",
"detectEncoding",
"(",
"$",
"footer",
")",
";",
"$",
"this",
"->",
"outputService",
"->",
"addChunkString",
"(",
"$",
"this",
"->",
"pool",
"->",
"render",
"->",
"renderHeader",
"(",
"'Edit local settings'",
",",
"$",
"this",
"->",
"outputCssAndJs",
"(",
")",
")",
")",
"->",
"addChunkString",
"(",
"$",
"footer",
")",
";",
"$",
"this",
"->",
"pool",
"->",
"emergencyHandler",
"->",
"setDisable",
"(",
"false",
")",
";",
"$",
"this",
"->",
"outputService",
"->",
"finalize",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Outputs the edit settings dialog, without any analysis.
@return $this
Return $this for chaining | [
"Outputs",
"the",
"edit",
"settings",
"dialog",
"without",
"any",
"analysis",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Controller/EditSettingsController.php#L50-L78 |
33,752 | brainworxx/kreXX | src/Controller/AbstractController.php | AbstractController.outputFooter | protected function outputFooter(array $caller, $isExpanded = false)
{
// Now we need to stitch together the content of the ini file
// as well as it's path.
$pathToIni = $this->pool->config->getPathToIniFile();
if ($this->pool->fileService->fileIsReadable($pathToIni) === true) {
$path = $this->pool->messages->getHelp('currentConfig');
} else {
// Project settings are not accessible
// tell the user, that we are using fallback settings.
$path = $this->pool->messages->getHelp('iniNotFound');
}
$model = $this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Model')
->setName($path)
->setType($this->pool->fileService->filterFilePath($pathToIni))
->setHelpid('currentSettings')
->injectCallback(
$this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Callback\\Iterate\\ThroughConfig')
);
return $this->pool->render->renderFooter(
$caller,
$model,
$isExpanded
);
} | php | protected function outputFooter(array $caller, $isExpanded = false)
{
// Now we need to stitch together the content of the ini file
// as well as it's path.
$pathToIni = $this->pool->config->getPathToIniFile();
if ($this->pool->fileService->fileIsReadable($pathToIni) === true) {
$path = $this->pool->messages->getHelp('currentConfig');
} else {
// Project settings are not accessible
// tell the user, that we are using fallback settings.
$path = $this->pool->messages->getHelp('iniNotFound');
}
$model = $this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Model')
->setName($path)
->setType($this->pool->fileService->filterFilePath($pathToIni))
->setHelpid('currentSettings')
->injectCallback(
$this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Callback\\Iterate\\ThroughConfig')
);
return $this->pool->render->renderFooter(
$caller,
$model,
$isExpanded
);
} | [
"protected",
"function",
"outputFooter",
"(",
"array",
"$",
"caller",
",",
"$",
"isExpanded",
"=",
"false",
")",
"{",
"// Now we need to stitch together the content of the ini file",
"// as well as it's path.",
"$",
"pathToIni",
"=",
"$",
"this",
"->",
"pool",
"->",
"config",
"->",
"getPathToIniFile",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"pool",
"->",
"fileService",
"->",
"fileIsReadable",
"(",
"$",
"pathToIni",
")",
"===",
"true",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"pool",
"->",
"messages",
"->",
"getHelp",
"(",
"'currentConfig'",
")",
";",
"}",
"else",
"{",
"// Project settings are not accessible",
"// tell the user, that we are using fallback settings.",
"$",
"path",
"=",
"$",
"this",
"->",
"pool",
"->",
"messages",
"->",
"getHelp",
"(",
"'iniNotFound'",
")",
";",
"}",
"$",
"model",
"=",
"$",
"this",
"->",
"pool",
"->",
"createClass",
"(",
"'Brainworxx\\\\Krexx\\\\Analyse\\\\Model'",
")",
"->",
"setName",
"(",
"$",
"path",
")",
"->",
"setType",
"(",
"$",
"this",
"->",
"pool",
"->",
"fileService",
"->",
"filterFilePath",
"(",
"$",
"pathToIni",
")",
")",
"->",
"setHelpid",
"(",
"'currentSettings'",
")",
"->",
"injectCallback",
"(",
"$",
"this",
"->",
"pool",
"->",
"createClass",
"(",
"'Brainworxx\\\\Krexx\\\\Analyse\\\\Callback\\\\Iterate\\\\ThroughConfig'",
")",
")",
";",
"return",
"$",
"this",
"->",
"pool",
"->",
"render",
"->",
"renderFooter",
"(",
"$",
"caller",
",",
"$",
"model",
",",
"$",
"isExpanded",
")",
";",
"}"
] | Simply renders the footer and output current settings.
@param array $caller
Where was kreXX initially invoked from.
@param boolean $isExpanded
Are we rendering an expanded footer?
TRUE when we render the settings menu only.
@return string
The generated markup. | [
"Simply",
"renders",
"the",
"footer",
"and",
"output",
"current",
"settings",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Controller/AbstractController.php#L162-L188 |
33,753 | brainworxx/kreXX | src/Controller/AbstractController.php | AbstractController.outputCssAndJs | protected function outputCssAndJs()
{
// We only do this once per output type.
$result = isset(static::$jsCssSend[$this->destination]);
static::$jsCssSend[$this->destination] = true;
if ($result === true) {
// Been here, done that.
return '';
}
// Adding our DOM tools to the js.
if ($this->pool->fileService->fileIsReadable(KREXX_DIR . 'resources/jsLibs/kdt.min.js') === true) {
$kdtPath = KREXX_DIR . 'resources/jsLibs/kdt.min.js';
} else {
$kdtPath = KREXX_DIR . 'resources/jsLibs/kdt.js';
}
$jsCode = $this->pool->fileService->getFileContents($kdtPath);
// Adding the skin css and js.
$skinDirectory = $this->pool->config->getSkinDirectory();
// Get the css file.
$css = $this->pool->fileService->getFileContents($skinDirectory . 'skin.css');
// Remove whitespace.
$css = preg_replace('/\s+/', ' ', $css);
// Krexx.js is comes directly form the template.
if ($this->pool->fileService->fileIsReadable($skinDirectory . 'krexx.min.js') === true) {
$skinJsPath = $skinDirectory . 'krexx.min.js';
} else {
$skinJsPath = $skinDirectory . 'krexx.js';
}
$jsCode .= $this->pool->fileService->getFileContents($skinJsPath);
return $this->pool->render->renderCssJs($css, $jsCode);
} | php | protected function outputCssAndJs()
{
// We only do this once per output type.
$result = isset(static::$jsCssSend[$this->destination]);
static::$jsCssSend[$this->destination] = true;
if ($result === true) {
// Been here, done that.
return '';
}
// Adding our DOM tools to the js.
if ($this->pool->fileService->fileIsReadable(KREXX_DIR . 'resources/jsLibs/kdt.min.js') === true) {
$kdtPath = KREXX_DIR . 'resources/jsLibs/kdt.min.js';
} else {
$kdtPath = KREXX_DIR . 'resources/jsLibs/kdt.js';
}
$jsCode = $this->pool->fileService->getFileContents($kdtPath);
// Adding the skin css and js.
$skinDirectory = $this->pool->config->getSkinDirectory();
// Get the css file.
$css = $this->pool->fileService->getFileContents($skinDirectory . 'skin.css');
// Remove whitespace.
$css = preg_replace('/\s+/', ' ', $css);
// Krexx.js is comes directly form the template.
if ($this->pool->fileService->fileIsReadable($skinDirectory . 'krexx.min.js') === true) {
$skinJsPath = $skinDirectory . 'krexx.min.js';
} else {
$skinJsPath = $skinDirectory . 'krexx.js';
}
$jsCode .= $this->pool->fileService->getFileContents($skinJsPath);
return $this->pool->render->renderCssJs($css, $jsCode);
} | [
"protected",
"function",
"outputCssAndJs",
"(",
")",
"{",
"// We only do this once per output type.",
"$",
"result",
"=",
"isset",
"(",
"static",
"::",
"$",
"jsCssSend",
"[",
"$",
"this",
"->",
"destination",
"]",
")",
";",
"static",
"::",
"$",
"jsCssSend",
"[",
"$",
"this",
"->",
"destination",
"]",
"=",
"true",
";",
"if",
"(",
"$",
"result",
"===",
"true",
")",
"{",
"// Been here, done that.",
"return",
"''",
";",
"}",
"// Adding our DOM tools to the js.",
"if",
"(",
"$",
"this",
"->",
"pool",
"->",
"fileService",
"->",
"fileIsReadable",
"(",
"KREXX_DIR",
".",
"'resources/jsLibs/kdt.min.js'",
")",
"===",
"true",
")",
"{",
"$",
"kdtPath",
"=",
"KREXX_DIR",
".",
"'resources/jsLibs/kdt.min.js'",
";",
"}",
"else",
"{",
"$",
"kdtPath",
"=",
"KREXX_DIR",
".",
"'resources/jsLibs/kdt.js'",
";",
"}",
"$",
"jsCode",
"=",
"$",
"this",
"->",
"pool",
"->",
"fileService",
"->",
"getFileContents",
"(",
"$",
"kdtPath",
")",
";",
"// Adding the skin css and js.",
"$",
"skinDirectory",
"=",
"$",
"this",
"->",
"pool",
"->",
"config",
"->",
"getSkinDirectory",
"(",
")",
";",
"// Get the css file.",
"$",
"css",
"=",
"$",
"this",
"->",
"pool",
"->",
"fileService",
"->",
"getFileContents",
"(",
"$",
"skinDirectory",
".",
"'skin.css'",
")",
";",
"// Remove whitespace.",
"$",
"css",
"=",
"preg_replace",
"(",
"'/\\s+/'",
",",
"' '",
",",
"$",
"css",
")",
";",
"// Krexx.js is comes directly form the template.",
"if",
"(",
"$",
"this",
"->",
"pool",
"->",
"fileService",
"->",
"fileIsReadable",
"(",
"$",
"skinDirectory",
".",
"'krexx.min.js'",
")",
"===",
"true",
")",
"{",
"$",
"skinJsPath",
"=",
"$",
"skinDirectory",
".",
"'krexx.min.js'",
";",
"}",
"else",
"{",
"$",
"skinJsPath",
"=",
"$",
"skinDirectory",
".",
"'krexx.js'",
";",
"}",
"$",
"jsCode",
".=",
"$",
"this",
"->",
"pool",
"->",
"fileService",
"->",
"getFileContents",
"(",
"$",
"skinJsPath",
")",
";",
"return",
"$",
"this",
"->",
"pool",
"->",
"render",
"->",
"renderCssJs",
"(",
"$",
"css",
",",
"$",
"jsCode",
")",
";",
"}"
] | Outputs the CSS and JS.
@return string
The generated markup. | [
"Outputs",
"the",
"CSS",
"and",
"JS",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Controller/AbstractController.php#L196-L229 |
33,754 | brainworxx/kreXX | src/Controller/AbstractController.php | AbstractController.noFatalForKrexx | public function noFatalForKrexx()
{
if ($this->fatalShouldActive === true) {
$this::$krexxFatal->setIsActive(false);
unregister_tick_function(array($this::$krexxFatal, 'tickCallback'));
}
return $this;
} | php | public function noFatalForKrexx()
{
if ($this->fatalShouldActive === true) {
$this::$krexxFatal->setIsActive(false);
unregister_tick_function(array($this::$krexxFatal, 'tickCallback'));
}
return $this;
} | [
"public",
"function",
"noFatalForKrexx",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"fatalShouldActive",
"===",
"true",
")",
"{",
"$",
"this",
"::",
"$",
"krexxFatal",
"->",
"setIsActive",
"(",
"false",
")",
";",
"unregister_tick_function",
"(",
"array",
"(",
"$",
"this",
"::",
"$",
"krexxFatal",
",",
"'tickCallback'",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Disables the fatal handler and the tick callback.
We disable the tick callback and the error handler during
a analysis, to generate faster output. We also disable
other kreXX calls, which may be caused by the debug callbacks
to prevent kreXX from starting other kreXX calls.
@return $this
Return $this for chaining. | [
"Disables",
"the",
"fatal",
"handler",
"and",
"the",
"tick",
"callback",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Controller/AbstractController.php#L242-L250 |
33,755 | brainworxx/kreXX | src/Controller/AbstractController.php | AbstractController.reFatalAfterKrexx | public function reFatalAfterKrexx()
{
if ($this->fatalShouldActive === true) {
$this::$krexxFatal->setIsActive(true);
register_tick_function(array($this::$krexxFatal, 'tickCallback'));
}
return $this;
} | php | public function reFatalAfterKrexx()
{
if ($this->fatalShouldActive === true) {
$this::$krexxFatal->setIsActive(true);
register_tick_function(array($this::$krexxFatal, 'tickCallback'));
}
return $this;
} | [
"public",
"function",
"reFatalAfterKrexx",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"fatalShouldActive",
"===",
"true",
")",
"{",
"$",
"this",
"::",
"$",
"krexxFatal",
"->",
"setIsActive",
"(",
"true",
")",
";",
"register_tick_function",
"(",
"array",
"(",
"$",
"this",
"::",
"$",
"krexxFatal",
",",
"'tickCallback'",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Re-enable the fatal handler and the tick callback.
We disable the tick callback and the error handler during
a analysis, to generate faster output. We re-enable kreXX
afterwards, so the dev can use it again.
@return $this
Return $this for chaining. | [
"Re",
"-",
"enable",
"the",
"fatal",
"handler",
"and",
"the",
"tick",
"callback",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Controller/AbstractController.php#L262-L270 |
33,756 | brainworxx/kreXX | src/Analyse/Routing/Process/ProcessArray.php | ProcessArray.process | public function process(Model $model)
{
$multiline = false;
$count = count($model->getData());
if ($count > (int) $this->pool->config->getSetting(Fallback::SETTING_ARRAY_COUNT_LIMIT)) {
// Budget array analysis.
$model->injectCallback(
$this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Callback\\Iterate\\ThroughLargeArray')
)->setHelpid('simpleArray');
} else {
// Complete array analysis.
$model->injectCallback(
$this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Callback\\Iterate\\ThroughArray')
);
}
// Dumping all Properties.
return $this->pool->render->renderExpandableChild(
$model->setType(static::TYPE_ARRAY)
->setNormal($count . ' elements')
->addParameter(static::PARAM_DATA, $model->getData())
->addParameter(static::PARAM_MULTILINE, $multiline)
);
} | php | public function process(Model $model)
{
$multiline = false;
$count = count($model->getData());
if ($count > (int) $this->pool->config->getSetting(Fallback::SETTING_ARRAY_COUNT_LIMIT)) {
// Budget array analysis.
$model->injectCallback(
$this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Callback\\Iterate\\ThroughLargeArray')
)->setHelpid('simpleArray');
} else {
// Complete array analysis.
$model->injectCallback(
$this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Callback\\Iterate\\ThroughArray')
);
}
// Dumping all Properties.
return $this->pool->render->renderExpandableChild(
$model->setType(static::TYPE_ARRAY)
->setNormal($count . ' elements')
->addParameter(static::PARAM_DATA, $model->getData())
->addParameter(static::PARAM_MULTILINE, $multiline)
);
} | [
"public",
"function",
"process",
"(",
"Model",
"$",
"model",
")",
"{",
"$",
"multiline",
"=",
"false",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"model",
"->",
"getData",
"(",
")",
")",
";",
"if",
"(",
"$",
"count",
">",
"(",
"int",
")",
"$",
"this",
"->",
"pool",
"->",
"config",
"->",
"getSetting",
"(",
"Fallback",
"::",
"SETTING_ARRAY_COUNT_LIMIT",
")",
")",
"{",
"// Budget array analysis.",
"$",
"model",
"->",
"injectCallback",
"(",
"$",
"this",
"->",
"pool",
"->",
"createClass",
"(",
"'Brainworxx\\\\Krexx\\\\Analyse\\\\Callback\\\\Iterate\\\\ThroughLargeArray'",
")",
")",
"->",
"setHelpid",
"(",
"'simpleArray'",
")",
";",
"}",
"else",
"{",
"// Complete array analysis.",
"$",
"model",
"->",
"injectCallback",
"(",
"$",
"this",
"->",
"pool",
"->",
"createClass",
"(",
"'Brainworxx\\\\Krexx\\\\Analyse\\\\Callback\\\\Iterate\\\\ThroughArray'",
")",
")",
";",
"}",
"// Dumping all Properties.",
"return",
"$",
"this",
"->",
"pool",
"->",
"render",
"->",
"renderExpandableChild",
"(",
"$",
"model",
"->",
"setType",
"(",
"static",
"::",
"TYPE_ARRAY",
")",
"->",
"setNormal",
"(",
"$",
"count",
".",
"' elements'",
")",
"->",
"addParameter",
"(",
"static",
"::",
"PARAM_DATA",
",",
"$",
"model",
"->",
"getData",
"(",
")",
")",
"->",
"addParameter",
"(",
"static",
"::",
"PARAM_MULTILINE",
",",
"$",
"multiline",
")",
")",
";",
"}"
] | Render a dump for an array.
@param Model $model
The data we are analysing.
@return string
The rendered markup. | [
"Render",
"a",
"dump",
"for",
"an",
"array",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Routing/Process/ProcessArray.php#L58-L82 |
33,757 | silverorange/swat | Swat/SwatXHTMLTextarea.php | SwatXHTMLTextarea.getValidationErrorMessage | protected function getValidationErrorMessage(array $xml_errors)
{
$ignored_errors = array(
'extra content at the end of the document',
'premature end of data in tag html',
'opening and ending tag mismatch between html and body',
'opening and ending tag mismatch between body and html'
);
$errors = array();
foreach ($xml_errors as $error_object) {
$error = $error_object->message;
// further humanize
$error = str_replace(
'tag mismatch:',
Swat::_('tag mismatch between'),
$error
);
// remove some stuff that only makes sense in document context
$error = preg_replace('/\s?line:? [0-9]+\s?/ui', ' ', $error);
$error = preg_replace('/in entity[:,.]?/ui', '', $error);
$error = mb_strtolower($error);
$error = str_replace(
'xmlparseentityref: no name',
Swat::_('unescaped ampersand. Use &amp; instead of &'),
$error
);
$error = str_replace(
'starttag: invalid element name',
Swat::_('unescaped less-than. Use &lt; instead of <'),
$error
);
$error = str_replace(
'specification mandate value for attribute',
Swat::_('a value is required for the attribute'),
$error
);
$error = preg_replace(
'/^no declaration for attribute (.*?) of element (.*?)$/',
Swat::_('the attribute \1 is not valid for the element \2'),
$error
);
$error = str_replace(
'attvalue: " or \' expected',
Swat::_(
'attribute values must be contained within quotation ' .
'marks'
),
$error
);
$error = trim($error);
if (!in_array($error, $ignored_errors)) {
$errors[] = $error;
}
}
$content = Swat::_('%s must be valid XHTML markup: ');
$content .= '<ul><li>' . implode(',</li><li>', $errors) . '.</li></ul>';
$message = new SwatMessage($content, 'error');
$message->content_type = 'text/xml';
return $message;
} | php | protected function getValidationErrorMessage(array $xml_errors)
{
$ignored_errors = array(
'extra content at the end of the document',
'premature end of data in tag html',
'opening and ending tag mismatch between html and body',
'opening and ending tag mismatch between body and html'
);
$errors = array();
foreach ($xml_errors as $error_object) {
$error = $error_object->message;
// further humanize
$error = str_replace(
'tag mismatch:',
Swat::_('tag mismatch between'),
$error
);
// remove some stuff that only makes sense in document context
$error = preg_replace('/\s?line:? [0-9]+\s?/ui', ' ', $error);
$error = preg_replace('/in entity[:,.]?/ui', '', $error);
$error = mb_strtolower($error);
$error = str_replace(
'xmlparseentityref: no name',
Swat::_('unescaped ampersand. Use &amp; instead of &'),
$error
);
$error = str_replace(
'starttag: invalid element name',
Swat::_('unescaped less-than. Use &lt; instead of <'),
$error
);
$error = str_replace(
'specification mandate value for attribute',
Swat::_('a value is required for the attribute'),
$error
);
$error = preg_replace(
'/^no declaration for attribute (.*?) of element (.*?)$/',
Swat::_('the attribute \1 is not valid for the element \2'),
$error
);
$error = str_replace(
'attvalue: " or \' expected',
Swat::_(
'attribute values must be contained within quotation ' .
'marks'
),
$error
);
$error = trim($error);
if (!in_array($error, $ignored_errors)) {
$errors[] = $error;
}
}
$content = Swat::_('%s must be valid XHTML markup: ');
$content .= '<ul><li>' . implode(',</li><li>', $errors) . '.</li></ul>';
$message = new SwatMessage($content, 'error');
$message->content_type = 'text/xml';
return $message;
} | [
"protected",
"function",
"getValidationErrorMessage",
"(",
"array",
"$",
"xml_errors",
")",
"{",
"$",
"ignored_errors",
"=",
"array",
"(",
"'extra content at the end of the document'",
",",
"'premature end of data in tag html'",
",",
"'opening and ending tag mismatch between html and body'",
",",
"'opening and ending tag mismatch between body and html'",
")",
";",
"$",
"errors",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"xml_errors",
"as",
"$",
"error_object",
")",
"{",
"$",
"error",
"=",
"$",
"error_object",
"->",
"message",
";",
"// further humanize",
"$",
"error",
"=",
"str_replace",
"(",
"'tag mismatch:'",
",",
"Swat",
"::",
"_",
"(",
"'tag mismatch between'",
")",
",",
"$",
"error",
")",
";",
"// remove some stuff that only makes sense in document context",
"$",
"error",
"=",
"preg_replace",
"(",
"'/\\s?line:? [0-9]+\\s?/ui'",
",",
"' '",
",",
"$",
"error",
")",
";",
"$",
"error",
"=",
"preg_replace",
"(",
"'/in entity[:,.]?/ui'",
",",
"''",
",",
"$",
"error",
")",
";",
"$",
"error",
"=",
"mb_strtolower",
"(",
"$",
"error",
")",
";",
"$",
"error",
"=",
"str_replace",
"(",
"'xmlparseentityref: no name'",
",",
"Swat",
"::",
"_",
"(",
"'unescaped ampersand. Use &amp; instead of &'",
")",
",",
"$",
"error",
")",
";",
"$",
"error",
"=",
"str_replace",
"(",
"'starttag: invalid element name'",
",",
"Swat",
"::",
"_",
"(",
"'unescaped less-than. Use &lt; instead of <'",
")",
",",
"$",
"error",
")",
";",
"$",
"error",
"=",
"str_replace",
"(",
"'specification mandate value for attribute'",
",",
"Swat",
"::",
"_",
"(",
"'a value is required for the attribute'",
")",
",",
"$",
"error",
")",
";",
"$",
"error",
"=",
"preg_replace",
"(",
"'/^no declaration for attribute (.*?) of element (.*?)$/'",
",",
"Swat",
"::",
"_",
"(",
"'the attribute \\1 is not valid for the element \\2'",
")",
",",
"$",
"error",
")",
";",
"$",
"error",
"=",
"str_replace",
"(",
"'attvalue: \" or \\' expected'",
",",
"Swat",
"::",
"_",
"(",
"'attribute values must be contained within quotation '",
".",
"'marks'",
")",
",",
"$",
"error",
")",
";",
"$",
"error",
"=",
"trim",
"(",
"$",
"error",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"error",
",",
"$",
"ignored_errors",
")",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"$",
"error",
";",
"}",
"}",
"$",
"content",
"=",
"Swat",
"::",
"_",
"(",
"'%s must be valid XHTML markup: '",
")",
";",
"$",
"content",
".=",
"'<ul><li>'",
".",
"implode",
"(",
"',</li><li>'",
",",
"$",
"errors",
")",
".",
"'.</li></ul>'",
";",
"$",
"message",
"=",
"new",
"SwatMessage",
"(",
"$",
"content",
",",
"'error'",
")",
";",
"$",
"message",
"->",
"content_type",
"=",
"'text/xml'",
";",
"return",
"$",
"message",
";",
"}"
] | Gets a human readable error message for XHTML validation errors on
this textarea's value
@param array $xml_errors an array of LibXMLError objects.
@return SwatMessage a human readable error message for XHTML validation
errors on this textarea's value. | [
"Gets",
"a",
"human",
"readable",
"error",
"message",
"for",
"XHTML",
"validation",
"errors",
"on",
"this",
"textarea",
"s",
"value"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatXHTMLTextarea.php#L138-L209 |
33,758 | silverorange/swat | Swat/SwatXHTMLTextarea.php | SwatXHTMLTextarea.createCompositeWidgets | protected function createCompositeWidgets()
{
$this->ignore_errors_checkbox = new SwatCheckbox(
$this->id . '_ignore_checkbox'
);
$ignore_field = new SwatFormField($this->id . '_ignore_field');
$ignore_field->title = Swat::_('Ignore XHTML validation errors');
$ignore_field->add($this->ignore_errors_checkbox);
$this->addCompositeWidget($ignore_field, 'ignore_field');
} | php | protected function createCompositeWidgets()
{
$this->ignore_errors_checkbox = new SwatCheckbox(
$this->id . '_ignore_checkbox'
);
$ignore_field = new SwatFormField($this->id . '_ignore_field');
$ignore_field->title = Swat::_('Ignore XHTML validation errors');
$ignore_field->add($this->ignore_errors_checkbox);
$this->addCompositeWidget($ignore_field, 'ignore_field');
} | [
"protected",
"function",
"createCompositeWidgets",
"(",
")",
"{",
"$",
"this",
"->",
"ignore_errors_checkbox",
"=",
"new",
"SwatCheckbox",
"(",
"$",
"this",
"->",
"id",
".",
"'_ignore_checkbox'",
")",
";",
"$",
"ignore_field",
"=",
"new",
"SwatFormField",
"(",
"$",
"this",
"->",
"id",
".",
"'_ignore_field'",
")",
";",
"$",
"ignore_field",
"->",
"title",
"=",
"Swat",
"::",
"_",
"(",
"'Ignore XHTML validation errors'",
")",
";",
"$",
"ignore_field",
"->",
"add",
"(",
"$",
"this",
"->",
"ignore_errors_checkbox",
")",
";",
"$",
"this",
"->",
"addCompositeWidget",
"(",
"$",
"ignore_field",
",",
"'ignore_field'",
")",
";",
"}"
] | Creates the composite checkbox used by this XHTML textarea
@see SwatWidget::createCompositeWidgets() | [
"Creates",
"the",
"composite",
"checkbox",
"used",
"by",
"this",
"XHTML",
"textarea"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatXHTMLTextarea.php#L219-L230 |
33,759 | silverorange/swat | Swat/SwatHtmlHeadEntrySetDisplayer.php | SwatHtmlHeadEntrySetDisplayer.display | public function display(
SwatHtmlHeadEntrySet $set,
$uri_prefix = '',
$tag = null,
$combine = false,
$minify = false
) {
// clone set so displaying doesn't modify it
$set = clone $set;
$entries = $set->toArray();
// combine files
if ($combine) {
$info = $this->getCombinedEntries($entries);
$entries = $info['entries'];
$uris = $info['superset'];
} else {
$uris = array_keys($entries);
}
// check for conflicts in the displayed set
$this->checkForConflicts($uris);
// sort
$entries = $this->getSortedEntries($entries);
// display entries
$current_type = null;
foreach ($entries as $entry) {
if ($this->compareTypes($current_type, $entry->getType()) !== 0) {
$current_type = $entry->getType();
echo "\n";
}
echo "\t";
$prefix = $uri_prefix;
if ($minify && $this->concentrator->isMinified($entry->getUri())) {
$prefix = $prefix . 'min/';
}
if ($entry->getType() === 'SwatLessStyleSheetHtmlHeadEntry') {
$prefix = $prefix . 'compiled/';
$entry = $entry->getStyleSheetHeadEntry();
}
$entry->display($prefix, $tag);
echo "\n";
}
echo "\n";
} | php | public function display(
SwatHtmlHeadEntrySet $set,
$uri_prefix = '',
$tag = null,
$combine = false,
$minify = false
) {
// clone set so displaying doesn't modify it
$set = clone $set;
$entries = $set->toArray();
// combine files
if ($combine) {
$info = $this->getCombinedEntries($entries);
$entries = $info['entries'];
$uris = $info['superset'];
} else {
$uris = array_keys($entries);
}
// check for conflicts in the displayed set
$this->checkForConflicts($uris);
// sort
$entries = $this->getSortedEntries($entries);
// display entries
$current_type = null;
foreach ($entries as $entry) {
if ($this->compareTypes($current_type, $entry->getType()) !== 0) {
$current_type = $entry->getType();
echo "\n";
}
echo "\t";
$prefix = $uri_prefix;
if ($minify && $this->concentrator->isMinified($entry->getUri())) {
$prefix = $prefix . 'min/';
}
if ($entry->getType() === 'SwatLessStyleSheetHtmlHeadEntry') {
$prefix = $prefix . 'compiled/';
$entry = $entry->getStyleSheetHeadEntry();
}
$entry->display($prefix, $tag);
echo "\n";
}
echo "\n";
} | [
"public",
"function",
"display",
"(",
"SwatHtmlHeadEntrySet",
"$",
"set",
",",
"$",
"uri_prefix",
"=",
"''",
",",
"$",
"tag",
"=",
"null",
",",
"$",
"combine",
"=",
"false",
",",
"$",
"minify",
"=",
"false",
")",
"{",
"// clone set so displaying doesn't modify it",
"$",
"set",
"=",
"clone",
"$",
"set",
";",
"$",
"entries",
"=",
"$",
"set",
"->",
"toArray",
"(",
")",
";",
"// combine files",
"if",
"(",
"$",
"combine",
")",
"{",
"$",
"info",
"=",
"$",
"this",
"->",
"getCombinedEntries",
"(",
"$",
"entries",
")",
";",
"$",
"entries",
"=",
"$",
"info",
"[",
"'entries'",
"]",
";",
"$",
"uris",
"=",
"$",
"info",
"[",
"'superset'",
"]",
";",
"}",
"else",
"{",
"$",
"uris",
"=",
"array_keys",
"(",
"$",
"entries",
")",
";",
"}",
"// check for conflicts in the displayed set",
"$",
"this",
"->",
"checkForConflicts",
"(",
"$",
"uris",
")",
";",
"// sort",
"$",
"entries",
"=",
"$",
"this",
"->",
"getSortedEntries",
"(",
"$",
"entries",
")",
";",
"// display entries",
"$",
"current_type",
"=",
"null",
";",
"foreach",
"(",
"$",
"entries",
"as",
"$",
"entry",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"compareTypes",
"(",
"$",
"current_type",
",",
"$",
"entry",
"->",
"getType",
"(",
")",
")",
"!==",
"0",
")",
"{",
"$",
"current_type",
"=",
"$",
"entry",
"->",
"getType",
"(",
")",
";",
"echo",
"\"\\n\"",
";",
"}",
"echo",
"\"\\t\"",
";",
"$",
"prefix",
"=",
"$",
"uri_prefix",
";",
"if",
"(",
"$",
"minify",
"&&",
"$",
"this",
"->",
"concentrator",
"->",
"isMinified",
"(",
"$",
"entry",
"->",
"getUri",
"(",
")",
")",
")",
"{",
"$",
"prefix",
"=",
"$",
"prefix",
".",
"'min/'",
";",
"}",
"if",
"(",
"$",
"entry",
"->",
"getType",
"(",
")",
"===",
"'SwatLessStyleSheetHtmlHeadEntry'",
")",
"{",
"$",
"prefix",
"=",
"$",
"prefix",
".",
"'compiled/'",
";",
"$",
"entry",
"=",
"$",
"entry",
"->",
"getStyleSheetHeadEntry",
"(",
")",
";",
"}",
"$",
"entry",
"->",
"display",
"(",
"$",
"prefix",
",",
"$",
"tag",
")",
";",
"echo",
"\"\\n\"",
";",
"}",
"echo",
"\"\\n\"",
";",
"}"
] | Displays a set of HTML head entries
@param SwatHtmlHeadEntrySet $set the HTML head entry set to display.
@param string $uri_prefix an optional URI prefix to prepend to all the
displayed HTML head entries.
@param string $tag an optional tag to suffix the URI with. This is
suffixed as a HTTP get var and can be used to
explicitly refresh the browser cache.
@param boolean $combine whether or not to combine files. Defaults to
false.
@param boolean $minify whether or not to minify files. Defaults to
false. | [
"Displays",
"a",
"set",
"of",
"HTML",
"head",
"entries"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatHtmlHeadEntrySetDisplayer.php#L52-L105 |
33,760 | silverorange/swat | Swat/SwatHtmlHeadEntrySetDisplayer.php | SwatHtmlHeadEntrySetDisplayer.displayInline | public function displayInline(
SwatHtmlHeadEntrySet $set,
$path,
$type = null
) {
$entries = $set->toArray();
$uris = array_keys($entries);
// check for conflicts in the displayed set
$this->checkForConflicts($uris);
// sort
$entries = $this->getSortedEntries($entries);
// display entries inline
// TODO: Use Concentrate_Inliner to display CSS inline
foreach ($entries as $entry) {
if ($type === null || $entry->getType() === $type) {
echo "\t", '<!-- ', $entry->getUri(), ' -->', "\n";
$entry->displayInline($path);
echo "\n\t";
}
}
echo "\n";
} | php | public function displayInline(
SwatHtmlHeadEntrySet $set,
$path,
$type = null
) {
$entries = $set->toArray();
$uris = array_keys($entries);
// check for conflicts in the displayed set
$this->checkForConflicts($uris);
// sort
$entries = $this->getSortedEntries($entries);
// display entries inline
// TODO: Use Concentrate_Inliner to display CSS inline
foreach ($entries as $entry) {
if ($type === null || $entry->getType() === $type) {
echo "\t", '<!-- ', $entry->getUri(), ' -->', "\n";
$entry->displayInline($path);
echo "\n\t";
}
}
echo "\n";
} | [
"public",
"function",
"displayInline",
"(",
"SwatHtmlHeadEntrySet",
"$",
"set",
",",
"$",
"path",
",",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"entries",
"=",
"$",
"set",
"->",
"toArray",
"(",
")",
";",
"$",
"uris",
"=",
"array_keys",
"(",
"$",
"entries",
")",
";",
"// check for conflicts in the displayed set",
"$",
"this",
"->",
"checkForConflicts",
"(",
"$",
"uris",
")",
";",
"// sort",
"$",
"entries",
"=",
"$",
"this",
"->",
"getSortedEntries",
"(",
"$",
"entries",
")",
";",
"// display entries inline",
"// TODO: Use Concentrate_Inliner to display CSS inline",
"foreach",
"(",
"$",
"entries",
"as",
"$",
"entry",
")",
"{",
"if",
"(",
"$",
"type",
"===",
"null",
"||",
"$",
"entry",
"->",
"getType",
"(",
")",
"===",
"$",
"type",
")",
"{",
"echo",
"\"\\t\"",
",",
"'<!-- '",
",",
"$",
"entry",
"->",
"getUri",
"(",
")",
",",
"' -->'",
",",
"\"\\n\"",
";",
"$",
"entry",
"->",
"displayInline",
"(",
"$",
"path",
")",
";",
"echo",
"\"\\n\\t\"",
";",
"}",
"}",
"echo",
"\"\\n\"",
";",
"}"
] | Displays the contents of the set of HTML head entries inline | [
"Displays",
"the",
"contents",
"of",
"the",
"set",
"of",
"HTML",
"head",
"entries",
"inline"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatHtmlHeadEntrySetDisplayer.php#L113-L139 |
33,761 | silverorange/swat | Swat/SwatHtmlHeadEntrySetDisplayer.php | SwatHtmlHeadEntrySetDisplayer.getCombinedEntries | protected function getCombinedEntries(array $entries)
{
$info = $this->concentrator->getCombines(array_keys($entries));
// add combines to set of entries
foreach ($info['combines'] as $combine) {
if (mb_substr($combine, -4) === '.css') {
$class_name = 'SwatStyleSheetHtmlHeadEntry';
} elseif (mb_substr($combine, -5) === '.less') {
$class_name = 'SwatLessStyleSheetHtmlHeadEntry';
} else {
$class_name = 'SwatJavaScriptHtmlHeadEntry';
}
$entries[$combine] = new $class_name($combine, '__combine__');
}
// remove files included in combines
$entries = array_intersect_key($entries, array_flip($info['files']));
return array(
'entries' => $entries,
'superset' => $info['superset']
);
} | php | protected function getCombinedEntries(array $entries)
{
$info = $this->concentrator->getCombines(array_keys($entries));
// add combines to set of entries
foreach ($info['combines'] as $combine) {
if (mb_substr($combine, -4) === '.css') {
$class_name = 'SwatStyleSheetHtmlHeadEntry';
} elseif (mb_substr($combine, -5) === '.less') {
$class_name = 'SwatLessStyleSheetHtmlHeadEntry';
} else {
$class_name = 'SwatJavaScriptHtmlHeadEntry';
}
$entries[$combine] = new $class_name($combine, '__combine__');
}
// remove files included in combines
$entries = array_intersect_key($entries, array_flip($info['files']));
return array(
'entries' => $entries,
'superset' => $info['superset']
);
} | [
"protected",
"function",
"getCombinedEntries",
"(",
"array",
"$",
"entries",
")",
"{",
"$",
"info",
"=",
"$",
"this",
"->",
"concentrator",
"->",
"getCombines",
"(",
"array_keys",
"(",
"$",
"entries",
")",
")",
";",
"// add combines to set of entries",
"foreach",
"(",
"$",
"info",
"[",
"'combines'",
"]",
"as",
"$",
"combine",
")",
"{",
"if",
"(",
"mb_substr",
"(",
"$",
"combine",
",",
"-",
"4",
")",
"===",
"'.css'",
")",
"{",
"$",
"class_name",
"=",
"'SwatStyleSheetHtmlHeadEntry'",
";",
"}",
"elseif",
"(",
"mb_substr",
"(",
"$",
"combine",
",",
"-",
"5",
")",
"===",
"'.less'",
")",
"{",
"$",
"class_name",
"=",
"'SwatLessStyleSheetHtmlHeadEntry'",
";",
"}",
"else",
"{",
"$",
"class_name",
"=",
"'SwatJavaScriptHtmlHeadEntry'",
";",
"}",
"$",
"entries",
"[",
"$",
"combine",
"]",
"=",
"new",
"$",
"class_name",
"(",
"$",
"combine",
",",
"'__combine__'",
")",
";",
"}",
"// remove files included in combines",
"$",
"entries",
"=",
"array_intersect_key",
"(",
"$",
"entries",
",",
"array_flip",
"(",
"$",
"info",
"[",
"'files'",
"]",
")",
")",
";",
"return",
"array",
"(",
"'entries'",
"=>",
"$",
"entries",
",",
"'superset'",
"=>",
"$",
"info",
"[",
"'superset'",
"]",
")",
";",
"}"
] | Gets the entries of this set accounting for combining
@param array $entries
@return array the entries of this set accounting for combinations. | [
"Gets",
"the",
"entries",
"of",
"this",
"set",
"accounting",
"for",
"combining"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatHtmlHeadEntrySetDisplayer.php#L151-L174 |
33,762 | silverorange/swat | Swat/SwatHtmlHeadEntrySetDisplayer.php | SwatHtmlHeadEntrySetDisplayer.getSortedEntries | protected function getSortedEntries(array $original_entries)
{
$entries = array();
// get array of entries with native ordering so we can do a
// stable, user-defined sort
$count = 0;
foreach ($original_entries as $uri => $entry) {
$entries[] = array(
'order' => $count,
'uri' => $uri,
'object' => $entry
);
$count++;
}
// stable-sort entries
usort($entries, array($this, 'compareEntries'));
// put back in a flat array
$sorted_entries = array();
foreach ($entries as $uri => $entry) {
$sorted_entries[$uri] = $entry['object'];
}
return $sorted_entries;
} | php | protected function getSortedEntries(array $original_entries)
{
$entries = array();
// get array of entries with native ordering so we can do a
// stable, user-defined sort
$count = 0;
foreach ($original_entries as $uri => $entry) {
$entries[] = array(
'order' => $count,
'uri' => $uri,
'object' => $entry
);
$count++;
}
// stable-sort entries
usort($entries, array($this, 'compareEntries'));
// put back in a flat array
$sorted_entries = array();
foreach ($entries as $uri => $entry) {
$sorted_entries[$uri] = $entry['object'];
}
return $sorted_entries;
} | [
"protected",
"function",
"getSortedEntries",
"(",
"array",
"$",
"original_entries",
")",
"{",
"$",
"entries",
"=",
"array",
"(",
")",
";",
"// get array of entries with native ordering so we can do a",
"// stable, user-defined sort",
"$",
"count",
"=",
"0",
";",
"foreach",
"(",
"$",
"original_entries",
"as",
"$",
"uri",
"=>",
"$",
"entry",
")",
"{",
"$",
"entries",
"[",
"]",
"=",
"array",
"(",
"'order'",
"=>",
"$",
"count",
",",
"'uri'",
"=>",
"$",
"uri",
",",
"'object'",
"=>",
"$",
"entry",
")",
";",
"$",
"count",
"++",
";",
"}",
"// stable-sort entries",
"usort",
"(",
"$",
"entries",
",",
"array",
"(",
"$",
"this",
",",
"'compareEntries'",
")",
")",
";",
"// put back in a flat array",
"$",
"sorted_entries",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"entries",
"as",
"$",
"uri",
"=>",
"$",
"entry",
")",
"{",
"$",
"sorted_entries",
"[",
"$",
"uri",
"]",
"=",
"$",
"entry",
"[",
"'object'",
"]",
";",
"}",
"return",
"$",
"sorted_entries",
";",
"}"
] | Gets the entries of this set sorted by their correct display order
@param array $original_entries
@return array the entries of this set sorted by their correct display
order. | [
"Gets",
"the",
"entries",
"of",
"this",
"set",
"sorted",
"by",
"their",
"correct",
"display",
"order"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatHtmlHeadEntrySetDisplayer.php#L187-L213 |
33,763 | silverorange/swat | Swat/SwatHtmlHeadEntrySetDisplayer.php | SwatHtmlHeadEntrySetDisplayer.compareTypes | protected function compareTypes($a, $b)
{
// compare entry type order
$type_order = $this->getTypeOrder();
if (!array_key_exists($a, $type_order)) {
$a = '__unknown__';
}
if (!array_key_exists($b, $type_order)) {
$b = '__unknown__';
}
if ($type_order[$a] > $type_order[$b]) {
return 1;
}
if ($type_order[$a] < $type_order[$b]) {
return -1;
}
return 0;
} | php | protected function compareTypes($a, $b)
{
// compare entry type order
$type_order = $this->getTypeOrder();
if (!array_key_exists($a, $type_order)) {
$a = '__unknown__';
}
if (!array_key_exists($b, $type_order)) {
$b = '__unknown__';
}
if ($type_order[$a] > $type_order[$b]) {
return 1;
}
if ($type_order[$a] < $type_order[$b]) {
return -1;
}
return 0;
} | [
"protected",
"function",
"compareTypes",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"// compare entry type order",
"$",
"type_order",
"=",
"$",
"this",
"->",
"getTypeOrder",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"a",
",",
"$",
"type_order",
")",
")",
"{",
"$",
"a",
"=",
"'__unknown__'",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"b",
",",
"$",
"type_order",
")",
")",
"{",
"$",
"b",
"=",
"'__unknown__'",
";",
"}",
"if",
"(",
"$",
"type_order",
"[",
"$",
"a",
"]",
">",
"$",
"type_order",
"[",
"$",
"b",
"]",
")",
"{",
"return",
"1",
";",
"}",
"if",
"(",
"$",
"type_order",
"[",
"$",
"a",
"]",
"<",
"$",
"type_order",
"[",
"$",
"b",
"]",
")",
"{",
"return",
"-",
"1",
";",
"}",
"return",
"0",
";",
"}"
] | Compares two HTML head entry types
@param string $a left side of comparison.
@param string $b right side of comparison.
@return integer a tri-value where -1 means the left side is less than
the right side, 1 means the left side is greater than
the right side and 0 means the left side and right
side are equivalent. | [
"Compares",
"two",
"HTML",
"head",
"entry",
"types"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatHtmlHeadEntrySetDisplayer.php#L285-L307 |
33,764 | silverorange/swat | Swat/SwatHtmlHeadEntrySetDisplayer.php | SwatHtmlHeadEntrySetDisplayer.checkForConflicts | protected function checkForConflicts(array $uris)
{
$conflicts = $this->concentrator->getConflicts($uris);
if (count($conflicts) > 0) {
$conflict_list = '';
$count = 0;
foreach ($conflicts as $file => $conflict) {
$conflict_list .= sprintf(
"\n- %s conflicts with %s",
$file,
implode(', ', $conflict)
);
$count++;
}
throw new SwatException(
'Could not display head entries because the following ' .
'conflicts were detected: ' .
$conflict_list
);
}
} | php | protected function checkForConflicts(array $uris)
{
$conflicts = $this->concentrator->getConflicts($uris);
if (count($conflicts) > 0) {
$conflict_list = '';
$count = 0;
foreach ($conflicts as $file => $conflict) {
$conflict_list .= sprintf(
"\n- %s conflicts with %s",
$file,
implode(', ', $conflict)
);
$count++;
}
throw new SwatException(
'Could not display head entries because the following ' .
'conflicts were detected: ' .
$conflict_list
);
}
} | [
"protected",
"function",
"checkForConflicts",
"(",
"array",
"$",
"uris",
")",
"{",
"$",
"conflicts",
"=",
"$",
"this",
"->",
"concentrator",
"->",
"getConflicts",
"(",
"$",
"uris",
")",
";",
"if",
"(",
"count",
"(",
"$",
"conflicts",
")",
">",
"0",
")",
"{",
"$",
"conflict_list",
"=",
"''",
";",
"$",
"count",
"=",
"0",
";",
"foreach",
"(",
"$",
"conflicts",
"as",
"$",
"file",
"=>",
"$",
"conflict",
")",
"{",
"$",
"conflict_list",
".=",
"sprintf",
"(",
"\"\\n- %s conflicts with %s\"",
",",
"$",
"file",
",",
"implode",
"(",
"', '",
",",
"$",
"conflict",
")",
")",
";",
"$",
"count",
"++",
";",
"}",
"throw",
"new",
"SwatException",
"(",
"'Could not display head entries because the following '",
".",
"'conflicts were detected: '",
".",
"$",
"conflict_list",
")",
";",
"}",
"}"
] | Check for conflicts in a set of HTML head entry URIs
If a conflict is detected, an exception is thrown explaining the
conflict.
@param array $uris the HTML head entry URIs to check.
@throws SwatException if one or more conflicts are present. | [
"Check",
"for",
"conflicts",
"in",
"a",
"set",
"of",
"HTML",
"head",
"entry",
"URIs"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatHtmlHeadEntrySetDisplayer.php#L349-L370 |
33,765 | silverorange/swat | Swat/SwatCheckboxEntryList.php | SwatCheckboxEntryList.process | public function process()
{
if (
$this->getForm()->getHiddenField($this->id . '_submitted') === null
) {
return;
}
parent::process();
foreach ($this->values as $option_value) {
$this->getEntryWidget($option_value)->process();
}
} | php | public function process()
{
if (
$this->getForm()->getHiddenField($this->id . '_submitted') === null
) {
return;
}
parent::process();
foreach ($this->values as $option_value) {
$this->getEntryWidget($option_value)->process();
}
} | [
"public",
"function",
"process",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getForm",
"(",
")",
"->",
"getHiddenField",
"(",
"$",
"this",
"->",
"id",
".",
"'_submitted'",
")",
"===",
"null",
")",
"{",
"return",
";",
"}",
"parent",
"::",
"process",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"values",
"as",
"$",
"option_value",
")",
"{",
"$",
"this",
"->",
"getEntryWidget",
"(",
"$",
"option_value",
")",
"->",
"process",
"(",
")",
";",
"}",
"}"
] | Processes this checkbox entry list
Processes the checkboxes as well as each entry widget for each checked
checkbox. The entry widgets for unchecked checkboxes are not processed.
@see SwatCheckboxList::process() | [
"Processes",
"this",
"checkbox",
"entry",
"list"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCheckboxEntryList.php#L180-L193 |
33,766 | silverorange/swat | Swat/SwatCheckboxEntryList.php | SwatCheckboxEntryList.getEntryValue | public function getEntryValue($option_value)
{
$entry_value = null;
if ($this->hasEntryWidget($option_value)) {
$entry = $this->getEntryWidget($option_value)->getFirst();
$entry_value = $entry->value;
}
return $entry_value;
} | php | public function getEntryValue($option_value)
{
$entry_value = null;
if ($this->hasEntryWidget($option_value)) {
$entry = $this->getEntryWidget($option_value)->getFirst();
$entry_value = $entry->value;
}
return $entry_value;
} | [
"public",
"function",
"getEntryValue",
"(",
"$",
"option_value",
")",
"{",
"$",
"entry_value",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"hasEntryWidget",
"(",
"$",
"option_value",
")",
")",
"{",
"$",
"entry",
"=",
"$",
"this",
"->",
"getEntryWidget",
"(",
"$",
"option_value",
")",
"->",
"getFirst",
"(",
")",
";",
"$",
"entry_value",
"=",
"$",
"entry",
"->",
"value",
";",
"}",
"return",
"$",
"entry_value",
";",
"}"
] | Gets the value of an entry widget in this checkbox entry list
@param string $option_value used to indentify the entry widget
@return string the value of the specified entry widget or null if no
such widget exists. | [
"Gets",
"the",
"value",
"of",
"an",
"entry",
"widget",
"in",
"this",
"checkbox",
"entry",
"list"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCheckboxEntryList.php#L257-L267 |
33,767 | silverorange/swat | Swat/SwatCheckboxEntryList.php | SwatCheckboxEntryList.setEntryValue | public function setEntryValue($option_value, $entry_value)
{
$options = $this->getOptions();
$option_values = array();
foreach ($options as $option) {
$option_values[] = $option->value;
}
if (!in_array($option_value, $option_values)) {
throw new SwatInvalidPropertyException(
sprintf(
'No option with a value of "%s" exists in this checkbox ' .
'entry list',
$option_value
)
);
}
$this->getEntryWidget($option_value)->getFirst()->value = $entry_value;
} | php | public function setEntryValue($option_value, $entry_value)
{
$options = $this->getOptions();
$option_values = array();
foreach ($options as $option) {
$option_values[] = $option->value;
}
if (!in_array($option_value, $option_values)) {
throw new SwatInvalidPropertyException(
sprintf(
'No option with a value of "%s" exists in this checkbox ' .
'entry list',
$option_value
)
);
}
$this->getEntryWidget($option_value)->getFirst()->value = $entry_value;
} | [
"public",
"function",
"setEntryValue",
"(",
"$",
"option_value",
",",
"$",
"entry_value",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"getOptions",
"(",
")",
";",
"$",
"option_values",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"option",
")",
"{",
"$",
"option_values",
"[",
"]",
"=",
"$",
"option",
"->",
"value",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"option_value",
",",
"$",
"option_values",
")",
")",
"{",
"throw",
"new",
"SwatInvalidPropertyException",
"(",
"sprintf",
"(",
"'No option with a value of \"%s\" exists in this checkbox '",
".",
"'entry list'",
",",
"$",
"option_value",
")",
")",
";",
"}",
"$",
"this",
"->",
"getEntryWidget",
"(",
"$",
"option_value",
")",
"->",
"getFirst",
"(",
")",
"->",
"value",
"=",
"$",
"entry_value",
";",
"}"
] | Sets the value of an entry widget in this checkbox entry list
@param string $option_value the value of the option for which to set
the entry widget value.
@param string $entry_value the value to set on the entry widget.
@throws SwatInvalidPropertyException if the option value does not match
an existing option value in this
checkbox entry list. | [
"Sets",
"the",
"value",
"of",
"an",
"entry",
"widget",
"in",
"this",
"checkbox",
"entry",
"list"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCheckboxEntryList.php#L283-L302 |
33,768 | silverorange/swat | Swat/SwatCheckboxEntryList.php | SwatCheckboxEntryList.setEntryValuesByArray | public function setEntryValuesByArray(array $entry_values)
{
foreach ($entry_values as $option_value => $entry_value) {
$this->setEntryValue($option_value, $entry_value);
}
} | php | public function setEntryValuesByArray(array $entry_values)
{
foreach ($entry_values as $option_value => $entry_value) {
$this->setEntryValue($option_value, $entry_value);
}
} | [
"public",
"function",
"setEntryValuesByArray",
"(",
"array",
"$",
"entry_values",
")",
"{",
"foreach",
"(",
"$",
"entry_values",
"as",
"$",
"option_value",
"=>",
"$",
"entry_value",
")",
"{",
"$",
"this",
"->",
"setEntryValue",
"(",
"$",
"option_value",
",",
"$",
"entry_value",
")",
";",
"}",
"}"
] | Sets the values of multiple entry widgets
This is a convenience method to quickly set the entry values for one
or more options in this checkbox entry list. This calls
{@link SwatCheckboxEntryList::setEntryValue()} internally for each
entry in the <i>$entry_values</i> array.
@param array $entry_values an array indexed by option values of this
checkbox entry list with values of the entry
widget values.
@throws SwatInvalidPropertyException if any option value (array key)
does not match an existing option
value in this checkbox entry list. | [
"Sets",
"the",
"values",
"of",
"multiple",
"entry",
"widgets"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCheckboxEntryList.php#L323-L328 |
33,769 | silverorange/swat | Swat/SwatCheckboxEntryList.php | SwatCheckboxEntryList.getInlineJavaScript | protected function getInlineJavaScript()
{
$javascript = sprintf(
"var %s_obj = new SwatCheckboxEntryList('%s');",
$this->id,
$this->id
);
// set check-all controller if it is visible
if ($this->show_check_all && count($this->getOptions()) > 1) {
$javascript .= sprintf(
"\n%s_obj.setController(%s_obj);",
$this->getCompositeWidget('check_all')->id,
$this->id
);
}
return $javascript;
} | php | protected function getInlineJavaScript()
{
$javascript = sprintf(
"var %s_obj = new SwatCheckboxEntryList('%s');",
$this->id,
$this->id
);
// set check-all controller if it is visible
if ($this->show_check_all && count($this->getOptions()) > 1) {
$javascript .= sprintf(
"\n%s_obj.setController(%s_obj);",
$this->getCompositeWidget('check_all')->id,
$this->id
);
}
return $javascript;
} | [
"protected",
"function",
"getInlineJavaScript",
"(",
")",
"{",
"$",
"javascript",
"=",
"sprintf",
"(",
"\"var %s_obj = new SwatCheckboxEntryList('%s');\"",
",",
"$",
"this",
"->",
"id",
",",
"$",
"this",
"->",
"id",
")",
";",
"// set check-all controller if it is visible",
"if",
"(",
"$",
"this",
"->",
"show_check_all",
"&&",
"count",
"(",
"$",
"this",
"->",
"getOptions",
"(",
")",
")",
">",
"1",
")",
"{",
"$",
"javascript",
".=",
"sprintf",
"(",
"\"\\n%s_obj.setController(%s_obj);\"",
",",
"$",
"this",
"->",
"getCompositeWidget",
"(",
"'check_all'",
")",
"->",
"id",
",",
"$",
"this",
"->",
"id",
")",
";",
"}",
"return",
"$",
"javascript",
";",
"}"
] | Gets the inline JavaScript for this checkbox entry list
@return string the inline JavaScript for this checkbox entry list. | [
"Gets",
"the",
"inline",
"JavaScript",
"for",
"this",
"checkbox",
"entry",
"list"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCheckboxEntryList.php#L338-L356 |
33,770 | silverorange/swat | Swat/SwatCheckboxEntryList.php | SwatCheckboxEntryList.getEntryWidget | protected function getEntryWidget($option_value)
{
if (!$this->hasEntryWidget($option_value)) {
$container = new SwatFormField(
$this->id . '_field_' . $option_value
);
$container->add($this->createEntryWidget($option_value));
$container->parent = $this;
$container->init();
$this->entry_widgets[$option_value] = $container;
}
return $this->entry_widgets[$option_value];
} | php | protected function getEntryWidget($option_value)
{
if (!$this->hasEntryWidget($option_value)) {
$container = new SwatFormField(
$this->id . '_field_' . $option_value
);
$container->add($this->createEntryWidget($option_value));
$container->parent = $this;
$container->init();
$this->entry_widgets[$option_value] = $container;
}
return $this->entry_widgets[$option_value];
} | [
"protected",
"function",
"getEntryWidget",
"(",
"$",
"option_value",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasEntryWidget",
"(",
"$",
"option_value",
")",
")",
"{",
"$",
"container",
"=",
"new",
"SwatFormField",
"(",
"$",
"this",
"->",
"id",
".",
"'_field_'",
".",
"$",
"option_value",
")",
";",
"$",
"container",
"->",
"add",
"(",
"$",
"this",
"->",
"createEntryWidget",
"(",
"$",
"option_value",
")",
")",
";",
"$",
"container",
"->",
"parent",
"=",
"$",
"this",
";",
"$",
"container",
"->",
"init",
"(",
")",
";",
"$",
"this",
"->",
"entry_widgets",
"[",
"$",
"option_value",
"]",
"=",
"$",
"container",
";",
"}",
"return",
"$",
"this",
"->",
"entry_widgets",
"[",
"$",
"option_value",
"]",
";",
"}"
] | Gets a widget tree for the entry widget of this checkbox entry list
This is used internally to create the widget tree containing a
{@link SwatEntry} widget for display and processing.
@param string $option_value the value of the option for which to get
the entry widget. If no entry widget exists
for the given option value, one is created.
@return SwatContainer the widget tree containing the entry widget for
the given option value. | [
"Gets",
"a",
"widget",
"tree",
"for",
"the",
"entry",
"widget",
"of",
"this",
"checkbox",
"entry",
"list"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCheckboxEntryList.php#L408-L421 |
33,771 | silverorange/swat | Swat/SwatCheckboxEntryList.php | SwatCheckboxEntryList.createEntryWidget | protected function createEntryWidget($option_value)
{
$widget = new SwatEntry($this->id . '_entry_' . $option_value);
$widget->size = $this->entry_size;
$widget->maxlength = $this->entry_maxlength;
return $widget;
} | php | protected function createEntryWidget($option_value)
{
$widget = new SwatEntry($this->id . '_entry_' . $option_value);
$widget->size = $this->entry_size;
$widget->maxlength = $this->entry_maxlength;
return $widget;
} | [
"protected",
"function",
"createEntryWidget",
"(",
"$",
"option_value",
")",
"{",
"$",
"widget",
"=",
"new",
"SwatEntry",
"(",
"$",
"this",
"->",
"id",
".",
"'_entry_'",
".",
"$",
"option_value",
")",
";",
"$",
"widget",
"->",
"size",
"=",
"$",
"this",
"->",
"entry_size",
";",
"$",
"widget",
"->",
"maxlength",
"=",
"$",
"this",
"->",
"entry_maxlength",
";",
"return",
"$",
"widget",
";",
"}"
] | Creates an entry widget of this checkbox entry list
Subclasses may override this method to create a different widget type.
@param string $option_value the value of the option for which to get
the entry widget.
@return SwatEntry the new entry widget for the given option value. | [
"Creates",
"an",
"entry",
"widget",
"of",
"this",
"checkbox",
"entry",
"list"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCheckboxEntryList.php#L436-L442 |
33,772 | silverorange/swat | Swat/SwatReplicableFormField.php | SwatReplicableFormField.init | public function init()
{
$children = array();
foreach ($this->children as $child_widget) {
$children[] = $this->remove($child_widget);
}
$field = new SwatFormField();
$field->id = $field->getUniqueId();
$prototype_id = $field->id;
foreach ($children as $child_widget) {
$field->add($child_widget);
}
$this->add($field);
parent::init();
foreach ($this->replicators as $id => $title) {
$field = $this->getWidget($prototype_id, $id);
$field->title = $title;
}
} | php | public function init()
{
$children = array();
foreach ($this->children as $child_widget) {
$children[] = $this->remove($child_widget);
}
$field = new SwatFormField();
$field->id = $field->getUniqueId();
$prototype_id = $field->id;
foreach ($children as $child_widget) {
$field->add($child_widget);
}
$this->add($field);
parent::init();
foreach ($this->replicators as $id => $title) {
$field = $this->getWidget($prototype_id, $id);
$field->title = $title;
}
} | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"children",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"children",
"as",
"$",
"child_widget",
")",
"{",
"$",
"children",
"[",
"]",
"=",
"$",
"this",
"->",
"remove",
"(",
"$",
"child_widget",
")",
";",
"}",
"$",
"field",
"=",
"new",
"SwatFormField",
"(",
")",
";",
"$",
"field",
"->",
"id",
"=",
"$",
"field",
"->",
"getUniqueId",
"(",
")",
";",
"$",
"prototype_id",
"=",
"$",
"field",
"->",
"id",
";",
"foreach",
"(",
"$",
"children",
"as",
"$",
"child_widget",
")",
"{",
"$",
"field",
"->",
"add",
"(",
"$",
"child_widget",
")",
";",
"}",
"$",
"this",
"->",
"add",
"(",
"$",
"field",
")",
";",
"parent",
"::",
"init",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"replicators",
"as",
"$",
"id",
"=>",
"$",
"title",
")",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"getWidget",
"(",
"$",
"prototype_id",
",",
"$",
"id",
")",
";",
"$",
"field",
"->",
"title",
"=",
"$",
"title",
";",
"}",
"}"
] | Initilizes this replicable form field | [
"Initilizes",
"this",
"replicable",
"form",
"field"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatReplicableFormField.php#L23-L46 |
33,773 | honey-comb/core | src/Http/Controllers/HCAuthController.php | HCAuthController.deAuthorize | private function deAuthorize(User $user): void
{
$client = new Client;
$client->delete("https://graph.facebook.com/{$user->id}/permissions",
[
'headers' => ['Accept' => 'application/json'],
'form_params' => [
'access_token' => $user->token,
],
]
);
} | php | private function deAuthorize(User $user): void
{
$client = new Client;
$client->delete("https://graph.facebook.com/{$user->id}/permissions",
[
'headers' => ['Accept' => 'application/json'],
'form_params' => [
'access_token' => $user->token,
],
]
);
} | [
"private",
"function",
"deAuthorize",
"(",
"User",
"$",
"user",
")",
":",
"void",
"{",
"$",
"client",
"=",
"new",
"Client",
";",
"$",
"client",
"->",
"delete",
"(",
"\"https://graph.facebook.com/{$user->id}/permissions\"",
",",
"[",
"'headers'",
"=>",
"[",
"'Accept'",
"=>",
"'application/json'",
"]",
",",
"'form_params'",
"=>",
"[",
"'access_token'",
"=>",
"$",
"user",
"->",
"token",
",",
"]",
",",
"]",
")",
";",
"}"
] | DeAuthorize user from app
@param User $user
@return void | [
"DeAuthorize",
"user",
"from",
"app"
] | 5c12aba31cae092e9681f0ae3e3664ed3fcec956 | https://github.com/honey-comb/core/blob/5c12aba31cae092e9681f0ae3e3664ed3fcec956/src/Http/Controllers/HCAuthController.php#L317-L329 |
33,774 | mindkomm/types | lib/Post_Type_Page.php | Post_Type_Page.update_archive_slug | public function update_archive_slug( $args, $post_type ) {
if ( $post_type !== $this->post_type ) {
return $args;
}
$args['has_archive'] = trim(
wp_make_link_relative( get_permalink( $this->post_id ) ),
'/'
);
return $args;
} | php | public function update_archive_slug( $args, $post_type ) {
if ( $post_type !== $this->post_type ) {
return $args;
}
$args['has_archive'] = trim(
wp_make_link_relative( get_permalink( $this->post_id ) ),
'/'
);
return $args;
} | [
"public",
"function",
"update_archive_slug",
"(",
"$",
"args",
",",
"$",
"post_type",
")",
"{",
"if",
"(",
"$",
"post_type",
"!==",
"$",
"this",
"->",
"post_type",
")",
"{",
"return",
"$",
"args",
";",
"}",
"$",
"args",
"[",
"'has_archive'",
"]",
"=",
"trim",
"(",
"wp_make_link_relative",
"(",
"get_permalink",
"(",
"$",
"this",
"->",
"post_id",
")",
")",
",",
"'/'",
")",
";",
"return",
"$",
"args",
";",
"}"
] | Update the archive slug to be the same as the page that should be used for the archive.
@param array $args Post type registration arguments.
@param string $post_type Post type name.
@return mixed | [
"Update",
"the",
"archive",
"slug",
"to",
"be",
"the",
"same",
"as",
"the",
"page",
"that",
"should",
"be",
"used",
"for",
"the",
"archive",
"."
] | a075d59acf995605427ce8a647a10ed12463b856 | https://github.com/mindkomm/types/blob/a075d59acf995605427ce8a647a10ed12463b856/lib/Post_Type_Page.php#L72-L83 |
33,775 | mindkomm/types | lib/Post_Type_Page.php | Post_Type_Page.filter_wp_nav_menu_objects | public function filter_wp_nav_menu_objects( $menu_items ) {
foreach ( $menu_items as &$item ) {
if ( 'page' !== $item->object || (int) $item->object_id !== $this->post_id ) {
continue;
}
if ( is_singular( $this->post_type ) ) {
$item->current_item_parent = true;
$item->classes[] = 'current-menu-parent';
$menu_items = \Types\menu_items_ancestors( $item, $menu_items );
}
if ( is_post_type_archive( $this->post_type ) ) {
$item->classes[] = 'current-menu-item';
$item->current = true;
$menu_items = \Types\menu_items_ancestors( $item, $menu_items );
}
}
return $menu_items;
} | php | public function filter_wp_nav_menu_objects( $menu_items ) {
foreach ( $menu_items as &$item ) {
if ( 'page' !== $item->object || (int) $item->object_id !== $this->post_id ) {
continue;
}
if ( is_singular( $this->post_type ) ) {
$item->current_item_parent = true;
$item->classes[] = 'current-menu-parent';
$menu_items = \Types\menu_items_ancestors( $item, $menu_items );
}
if ( is_post_type_archive( $this->post_type ) ) {
$item->classes[] = 'current-menu-item';
$item->current = true;
$menu_items = \Types\menu_items_ancestors( $item, $menu_items );
}
}
return $menu_items;
} | [
"public",
"function",
"filter_wp_nav_menu_objects",
"(",
"$",
"menu_items",
")",
"{",
"foreach",
"(",
"$",
"menu_items",
"as",
"&",
"$",
"item",
")",
"{",
"if",
"(",
"'page'",
"!==",
"$",
"item",
"->",
"object",
"||",
"(",
"int",
")",
"$",
"item",
"->",
"object_id",
"!==",
"$",
"this",
"->",
"post_id",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"is_singular",
"(",
"$",
"this",
"->",
"post_type",
")",
")",
"{",
"$",
"item",
"->",
"current_item_parent",
"=",
"true",
";",
"$",
"item",
"->",
"classes",
"[",
"]",
"=",
"'current-menu-parent'",
";",
"$",
"menu_items",
"=",
"\\",
"Types",
"\\",
"menu_items_ancestors",
"(",
"$",
"item",
",",
"$",
"menu_items",
")",
";",
"}",
"if",
"(",
"is_post_type_archive",
"(",
"$",
"this",
"->",
"post_type",
")",
")",
"{",
"$",
"item",
"->",
"classes",
"[",
"]",
"=",
"'current-menu-item'",
";",
"$",
"item",
"->",
"current",
"=",
"true",
";",
"$",
"menu_items",
"=",
"\\",
"Types",
"\\",
"menu_items_ancestors",
"(",
"$",
"item",
",",
"$",
"menu_items",
")",
";",
"}",
"}",
"return",
"$",
"menu_items",
";",
"}"
] | Make sure menu items for our pages get the correct classes assigned
@param array $menu_items Array of menu items.
@return array | [
"Make",
"sure",
"menu",
"items",
"for",
"our",
"pages",
"get",
"the",
"correct",
"classes",
"assigned"
] | a075d59acf995605427ce8a647a10ed12463b856 | https://github.com/mindkomm/types/blob/a075d59acf995605427ce8a647a10ed12463b856/lib/Post_Type_Page.php#L102-L124 |
33,776 | silverorange/swat | Swat/SwatPercentageEntry.php | SwatPercentageEntry.getDisplayValue | protected function getDisplayValue($value)
{
if (is_numeric($value)) {
$value = $value * 100;
$value = parent::getDisplayValue($value);
$value = $value . '%';
} else {
$value = parent::getDisplayValue($value);
}
return $value;
} | php | protected function getDisplayValue($value)
{
if (is_numeric($value)) {
$value = $value * 100;
$value = parent::getDisplayValue($value);
$value = $value . '%';
} else {
$value = parent::getDisplayValue($value);
}
return $value;
} | [
"protected",
"function",
"getDisplayValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"*",
"100",
";",
"$",
"value",
"=",
"parent",
"::",
"getDisplayValue",
"(",
"$",
"value",
")",
";",
"$",
"value",
"=",
"$",
"value",
".",
"'%'",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"parent",
"::",
"getDisplayValue",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Returns a value for this widget
The method returns a value to be displayed in the widget
@return string the final percentage value | [
"Returns",
"a",
"value",
"for",
"this",
"widget"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatPercentageEntry.php#L21-L32 |
33,777 | silverorange/swat | Swat/SwatPercentageEntry.php | SwatPercentageEntry.getNumericValue | protected function getNumericValue($value)
{
$value = trim($value);
$value = str_replace('%', '', $value);
$value = parent::getNumericValue($value);
if ($value !== null) {
$value = $value / 100;
}
return $value;
} | php | protected function getNumericValue($value)
{
$value = trim($value);
$value = str_replace('%', '', $value);
$value = parent::getNumericValue($value);
if ($value !== null) {
$value = $value / 100;
}
return $value;
} | [
"protected",
"function",
"getNumericValue",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"trim",
"(",
"$",
"value",
")",
";",
"$",
"value",
"=",
"str_replace",
"(",
"'%'",
",",
"''",
",",
"$",
"value",
")",
";",
"$",
"value",
"=",
"parent",
"::",
"getNumericValue",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"value",
"!==",
"null",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"/",
"100",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Gets the float value of this widget
This allows each widget to parse raw values and turn them into floats
@param string $value the raw value to use to get the numeric value.
@return mixed the numeric value of this entry widget or null if no
no numeric value is available. | [
"Gets",
"the",
"float",
"value",
"of",
"this",
"widget"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatPercentageEntry.php#L47-L57 |
33,778 | silverorange/swat | Swat/SwatIntegerEntry.php | SwatIntegerEntry.process | public function process()
{
parent::process();
if ($this->value === null) {
return;
}
try {
$integer_value = $this->getNumericValue($this->value);
if ($integer_value === null) {
$this->addMessage($this->getValidationMessage('integer'));
} else {
$this->value = $integer_value;
}
} catch (SwatIntegerOverflowException $e) {
if ($e->getSign() > 0) {
$this->addMessage(
$this->getValidationMessage('integer-maximum')
);
} else {
$this->addMessage(
$this->getValidationMessage('integer-minimum')
);
}
$integer_value = null;
}
} | php | public function process()
{
parent::process();
if ($this->value === null) {
return;
}
try {
$integer_value = $this->getNumericValue($this->value);
if ($integer_value === null) {
$this->addMessage($this->getValidationMessage('integer'));
} else {
$this->value = $integer_value;
}
} catch (SwatIntegerOverflowException $e) {
if ($e->getSign() > 0) {
$this->addMessage(
$this->getValidationMessage('integer-maximum')
);
} else {
$this->addMessage(
$this->getValidationMessage('integer-minimum')
);
}
$integer_value = null;
}
} | [
"public",
"function",
"process",
"(",
")",
"{",
"parent",
"::",
"process",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"value",
"===",
"null",
")",
"{",
"return",
";",
"}",
"try",
"{",
"$",
"integer_value",
"=",
"$",
"this",
"->",
"getNumericValue",
"(",
"$",
"this",
"->",
"value",
")",
";",
"if",
"(",
"$",
"integer_value",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"addMessage",
"(",
"$",
"this",
"->",
"getValidationMessage",
"(",
"'integer'",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"value",
"=",
"$",
"integer_value",
";",
"}",
"}",
"catch",
"(",
"SwatIntegerOverflowException",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"->",
"getSign",
"(",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"addMessage",
"(",
"$",
"this",
"->",
"getValidationMessage",
"(",
"'integer-maximum'",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"addMessage",
"(",
"$",
"this",
"->",
"getValidationMessage",
"(",
"'integer-minimum'",
")",
")",
";",
"}",
"$",
"integer_value",
"=",
"null",
";",
"}",
"}"
] | Checks to make sure value is an integer
If the value of this widget is not an integer then an error message is
attached to this widget. | [
"Checks",
"to",
"make",
"sure",
"value",
"is",
"an",
"integer"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatIntegerEntry.php#L20-L49 |
33,779 | silverorange/swat | Swat/SwatIntegerEntry.php | SwatIntegerEntry.getValidationMessage | protected function getValidationMessage($id)
{
switch ($id) {
case 'integer':
if ($this->minimum_value < 0) {
$text = $this->show_field_title_in_messages
? Swat::_('The %s field must be an integer.')
: Swat::_('This field must be an integer.');
} else {
$text = $this->show_field_title_in_messages
? Swat::_('The %s field must be a whole number.')
: Swat::_('This field must be a whole number.');
}
$message = new SwatMessage($text, 'error');
break;
case 'integer-maximum':
$text = $this->show_field_title_in_messages
? Swat::_('The %s field is too big.')
: Swat::_('This field is too big.');
$message = new SwatMessage($text, 'error');
break;
case 'integer-minimum':
$text = $this->show_field_title_in_messages
? Swat::_('The %s field is too small.')
: Swat::_('The this field is too small.');
$message = new SwatMessage($text, 'error');
break;
default:
$message = parent::getValidationMessage($id);
break;
}
return $message;
} | php | protected function getValidationMessage($id)
{
switch ($id) {
case 'integer':
if ($this->minimum_value < 0) {
$text = $this->show_field_title_in_messages
? Swat::_('The %s field must be an integer.')
: Swat::_('This field must be an integer.');
} else {
$text = $this->show_field_title_in_messages
? Swat::_('The %s field must be a whole number.')
: Swat::_('This field must be a whole number.');
}
$message = new SwatMessage($text, 'error');
break;
case 'integer-maximum':
$text = $this->show_field_title_in_messages
? Swat::_('The %s field is too big.')
: Swat::_('This field is too big.');
$message = new SwatMessage($text, 'error');
break;
case 'integer-minimum':
$text = $this->show_field_title_in_messages
? Swat::_('The %s field is too small.')
: Swat::_('The this field is too small.');
$message = new SwatMessage($text, 'error');
break;
default:
$message = parent::getValidationMessage($id);
break;
}
return $message;
} | [
"protected",
"function",
"getValidationMessage",
"(",
"$",
"id",
")",
"{",
"switch",
"(",
"$",
"id",
")",
"{",
"case",
"'integer'",
":",
"if",
"(",
"$",
"this",
"->",
"minimum_value",
"<",
"0",
")",
"{",
"$",
"text",
"=",
"$",
"this",
"->",
"show_field_title_in_messages",
"?",
"Swat",
"::",
"_",
"(",
"'The %s field must be an integer.'",
")",
":",
"Swat",
"::",
"_",
"(",
"'This field must be an integer.'",
")",
";",
"}",
"else",
"{",
"$",
"text",
"=",
"$",
"this",
"->",
"show_field_title_in_messages",
"?",
"Swat",
"::",
"_",
"(",
"'The %s field must be a whole number.'",
")",
":",
"Swat",
"::",
"_",
"(",
"'This field must be a whole number.'",
")",
";",
"}",
"$",
"message",
"=",
"new",
"SwatMessage",
"(",
"$",
"text",
",",
"'error'",
")",
";",
"break",
";",
"case",
"'integer-maximum'",
":",
"$",
"text",
"=",
"$",
"this",
"->",
"show_field_title_in_messages",
"?",
"Swat",
"::",
"_",
"(",
"'The %s field is too big.'",
")",
":",
"Swat",
"::",
"_",
"(",
"'This field is too big.'",
")",
";",
"$",
"message",
"=",
"new",
"SwatMessage",
"(",
"$",
"text",
",",
"'error'",
")",
";",
"break",
";",
"case",
"'integer-minimum'",
":",
"$",
"text",
"=",
"$",
"this",
"->",
"show_field_title_in_messages",
"?",
"Swat",
"::",
"_",
"(",
"'The %s field is too small.'",
")",
":",
"Swat",
"::",
"_",
"(",
"'The this field is too small.'",
")",
";",
"$",
"message",
"=",
"new",
"SwatMessage",
"(",
"$",
"text",
",",
"'error'",
")",
";",
"break",
";",
"default",
":",
"$",
"message",
"=",
"parent",
"::",
"getValidationMessage",
"(",
"$",
"id",
")",
";",
"break",
";",
"}",
"return",
"$",
"message",
";",
"}"
] | Gets a validation message for this integer entry
@see SwatEntry::getValidationMessage()
@param string $id the string identifier of the validation message.
@return SwatMessage the validation message. | [
"Gets",
"a",
"validation",
"message",
"for",
"this",
"integer",
"entry"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatIntegerEntry.php#L108-L146 |
33,780 | silverorange/swat | Swat/SwatFlydown.php | SwatFlydown.process | public function process()
{
parent::process();
if (!$this->processValue()) {
return;
}
if ($this->required && $this->isSensitive()) {
// When values are not serialized, an empty string is treated as
// null. As a result, you should not use a null value and an empty
// string value in the same flydown except when using serialized
// values.
if (
($this->serialize_values && $this->value === null) ||
(!$this->serialize_values && $this->value == '')
) {
$this->addMessage($this->getValidationMessage('required'));
}
}
} | php | public function process()
{
parent::process();
if (!$this->processValue()) {
return;
}
if ($this->required && $this->isSensitive()) {
// When values are not serialized, an empty string is treated as
// null. As a result, you should not use a null value and an empty
// string value in the same flydown except when using serialized
// values.
if (
($this->serialize_values && $this->value === null) ||
(!$this->serialize_values && $this->value == '')
) {
$this->addMessage($this->getValidationMessage('required'));
}
}
} | [
"public",
"function",
"process",
"(",
")",
"{",
"parent",
"::",
"process",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"processValue",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"required",
"&&",
"$",
"this",
"->",
"isSensitive",
"(",
")",
")",
"{",
"// When values are not serialized, an empty string is treated as",
"// null. As a result, you should not use a null value and an empty",
"// string value in the same flydown except when using serialized",
"// values.",
"if",
"(",
"(",
"$",
"this",
"->",
"serialize_values",
"&&",
"$",
"this",
"->",
"value",
"===",
"null",
")",
"||",
"(",
"!",
"$",
"this",
"->",
"serialize_values",
"&&",
"$",
"this",
"->",
"value",
"==",
"''",
")",
")",
"{",
"$",
"this",
"->",
"addMessage",
"(",
"$",
"this",
"->",
"getValidationMessage",
"(",
"'required'",
")",
")",
";",
"}",
"}",
"}"
] | Figures out what option was selected
Processes this widget and figures out what select element from this
flydown was selected. Any validation errors cause an error message to
be attached to this widget in this method. | [
"Figures",
"out",
"what",
"option",
"was",
"selected"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatFlydown.php#L171-L191 |
33,781 | silverorange/swat | Swat/SwatFlydown.php | SwatFlydown.processValue | protected function processValue()
{
$form = $this->getForm();
$data = &$form->getFormData();
if (!isset($data[$this->id])) {
return false;
}
if ($this->serialize_values) {
$salt = $form->getSalt();
$this->value = SwatString::signedUnserialize(
$data[$this->id],
$salt
);
} else {
$this->value = (string) $data[$this->id];
}
return true;
} | php | protected function processValue()
{
$form = $this->getForm();
$data = &$form->getFormData();
if (!isset($data[$this->id])) {
return false;
}
if ($this->serialize_values) {
$salt = $form->getSalt();
$this->value = SwatString::signedUnserialize(
$data[$this->id],
$salt
);
} else {
$this->value = (string) $data[$this->id];
}
return true;
} | [
"protected",
"function",
"processValue",
"(",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"getForm",
"(",
")",
";",
"$",
"data",
"=",
"&",
"$",
"form",
"->",
"getFormData",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"$",
"this",
"->",
"id",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"serialize_values",
")",
"{",
"$",
"salt",
"=",
"$",
"form",
"->",
"getSalt",
"(",
")",
";",
"$",
"this",
"->",
"value",
"=",
"SwatString",
"::",
"signedUnserialize",
"(",
"$",
"data",
"[",
"$",
"this",
"->",
"id",
"]",
",",
"$",
"salt",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"value",
"=",
"(",
"string",
")",
"$",
"data",
"[",
"$",
"this",
"->",
"id",
"]",
";",
"}",
"return",
"true",
";",
"}"
] | Processes the value of this flydown from user-submitted form data
@return boolean true if the value was processed from form data | [
"Processes",
"the",
"value",
"of",
"this",
"flydown",
"from",
"user",
"-",
"submitted",
"form",
"data"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatFlydown.php#L295-L315 |
33,782 | silverorange/swat | Swat/SwatFlydown.php | SwatFlydown.displaySingle | protected function displaySingle(SwatOption $flydown_option)
{
$title = $flydown_option->title;
$value = $flydown_option->value;
$hidden_tag = new SwatHtmlTag('input');
$hidden_tag->type = 'hidden';
$hidden_tag->name = $this->id;
if ($this->serialize_values) {
$salt = $this->getForm()->getSalt();
$hidden_tag->value = SwatString::signedSerialize($value, $salt);
} else {
$hidden_tag->value = (string) $value;
}
$hidden_tag->display();
$span_tag = new SwatHtmlTag('span');
$span_tag->class = 'swat-flydown-single';
$span_tag->setContent($title, $flydown_option->content_type);
$span_tag->display();
} | php | protected function displaySingle(SwatOption $flydown_option)
{
$title = $flydown_option->title;
$value = $flydown_option->value;
$hidden_tag = new SwatHtmlTag('input');
$hidden_tag->type = 'hidden';
$hidden_tag->name = $this->id;
if ($this->serialize_values) {
$salt = $this->getForm()->getSalt();
$hidden_tag->value = SwatString::signedSerialize($value, $salt);
} else {
$hidden_tag->value = (string) $value;
}
$hidden_tag->display();
$span_tag = new SwatHtmlTag('span');
$span_tag->class = 'swat-flydown-single';
$span_tag->setContent($title, $flydown_option->content_type);
$span_tag->display();
} | [
"protected",
"function",
"displaySingle",
"(",
"SwatOption",
"$",
"flydown_option",
")",
"{",
"$",
"title",
"=",
"$",
"flydown_option",
"->",
"title",
";",
"$",
"value",
"=",
"$",
"flydown_option",
"->",
"value",
";",
"$",
"hidden_tag",
"=",
"new",
"SwatHtmlTag",
"(",
"'input'",
")",
";",
"$",
"hidden_tag",
"->",
"type",
"=",
"'hidden'",
";",
"$",
"hidden_tag",
"->",
"name",
"=",
"$",
"this",
"->",
"id",
";",
"if",
"(",
"$",
"this",
"->",
"serialize_values",
")",
"{",
"$",
"salt",
"=",
"$",
"this",
"->",
"getForm",
"(",
")",
"->",
"getSalt",
"(",
")",
";",
"$",
"hidden_tag",
"->",
"value",
"=",
"SwatString",
"::",
"signedSerialize",
"(",
"$",
"value",
",",
"$",
"salt",
")",
";",
"}",
"else",
"{",
"$",
"hidden_tag",
"->",
"value",
"=",
"(",
"string",
")",
"$",
"value",
";",
"}",
"$",
"hidden_tag",
"->",
"display",
"(",
")",
";",
"$",
"span_tag",
"=",
"new",
"SwatHtmlTag",
"(",
"'span'",
")",
";",
"$",
"span_tag",
"->",
"class",
"=",
"'swat-flydown-single'",
";",
"$",
"span_tag",
"->",
"setContent",
"(",
"$",
"title",
",",
"$",
"flydown_option",
"->",
"content_type",
")",
";",
"$",
"span_tag",
"->",
"display",
"(",
")",
";",
"}"
] | Displays this flydown if there is only a single option | [
"Displays",
"this",
"flydown",
"if",
"there",
"is",
"only",
"a",
"single",
"option"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatFlydown.php#L323-L345 |
33,783 | FreeDSx/Socket | src/FreeDSx/Socket/SocketServer.php | SocketServer.listen | public function listen(string $ip, int $port)
{
$flags = STREAM_SERVER_BIND;
if ($this->options['transport'] !== 'udp') {
$flags |= STREAM_SERVER_LISTEN;
}
$this->socket = @\stream_socket_server(
$this->options['transport'].'://'.$ip.':'.$port,
$this->errorNumber,
$this->errorMessage,
$flags,
$this->createSocketContext()
);
if (!$this->socket) {
throw new ConnectionException(sprintf(
'Unable to open %s socket (%s): %s',
\strtoupper($this->options['transport']),
$this->errorNumber,
$this->errorMessage
));
}
return $this;
} | php | public function listen(string $ip, int $port)
{
$flags = STREAM_SERVER_BIND;
if ($this->options['transport'] !== 'udp') {
$flags |= STREAM_SERVER_LISTEN;
}
$this->socket = @\stream_socket_server(
$this->options['transport'].'://'.$ip.':'.$port,
$this->errorNumber,
$this->errorMessage,
$flags,
$this->createSocketContext()
);
if (!$this->socket) {
throw new ConnectionException(sprintf(
'Unable to open %s socket (%s): %s',
\strtoupper($this->options['transport']),
$this->errorNumber,
$this->errorMessage
));
}
return $this;
} | [
"public",
"function",
"listen",
"(",
"string",
"$",
"ip",
",",
"int",
"$",
"port",
")",
"{",
"$",
"flags",
"=",
"STREAM_SERVER_BIND",
";",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"'transport'",
"]",
"!==",
"'udp'",
")",
"{",
"$",
"flags",
"|=",
"STREAM_SERVER_LISTEN",
";",
"}",
"$",
"this",
"->",
"socket",
"=",
"@",
"\\",
"stream_socket_server",
"(",
"$",
"this",
"->",
"options",
"[",
"'transport'",
"]",
".",
"'://'",
".",
"$",
"ip",
".",
"':'",
".",
"$",
"port",
",",
"$",
"this",
"->",
"errorNumber",
",",
"$",
"this",
"->",
"errorMessage",
",",
"$",
"flags",
",",
"$",
"this",
"->",
"createSocketContext",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"socket",
")",
"{",
"throw",
"new",
"ConnectionException",
"(",
"sprintf",
"(",
"'Unable to open %s socket (%s): %s'",
",",
"\\",
"strtoupper",
"(",
"$",
"this",
"->",
"options",
"[",
"'transport'",
"]",
")",
",",
"$",
"this",
"->",
"errorNumber",
",",
"$",
"this",
"->",
"errorMessage",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Create the socket server and bind to a specific port to listen for clients.
@param string $ip
@param int $port
@return $this
@throws ConnectionException
@internal param string $ip | [
"Create",
"the",
"socket",
"server",
"and",
"bind",
"to",
"a",
"specific",
"port",
"to",
"listen",
"for",
"clients",
"."
] | d74683bf8b827e91a8ca051805c55dacaf64f93d | https://github.com/FreeDSx/Socket/blob/d74683bf8b827e91a8ca051805c55dacaf64f93d/src/FreeDSx/Socket/SocketServer.php#L56-L79 |
33,784 | FreeDSx/Socket | src/FreeDSx/Socket/SocketServer.php | SocketServer.receive | public function receive(&$ipAddress = null)
{
$this->block(true);
return \stream_socket_recvfrom($this->socket, 65507, 0, $ipAddress);
} | php | public function receive(&$ipAddress = null)
{
$this->block(true);
return \stream_socket_recvfrom($this->socket, 65507, 0, $ipAddress);
} | [
"public",
"function",
"receive",
"(",
"&",
"$",
"ipAddress",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"block",
"(",
"true",
")",
";",
"return",
"\\",
"stream_socket_recvfrom",
"(",
"$",
"this",
"->",
"socket",
",",
"65507",
",",
"0",
",",
"$",
"ipAddress",
")",
";",
"}"
] | Receive data from a UDP based socket. Optionally get the IP address the data was received from.
@todo Buffer size should be adjustable. Max UDP packet size is 65507. Currently this avoids possible truncation.
@param null $ipAddress
@return null|string | [
"Receive",
"data",
"from",
"a",
"UDP",
"based",
"socket",
".",
"Optionally",
"get",
"the",
"IP",
"address",
"the",
"data",
"was",
"received",
"from",
"."
] | d74683bf8b827e91a8ca051805c55dacaf64f93d | https://github.com/FreeDSx/Socket/blob/d74683bf8b827e91a8ca051805c55dacaf64f93d/src/FreeDSx/Socket/SocketServer.php#L105-L110 |
33,785 | FreeDSx/Socket | src/FreeDSx/Socket/SocketServer.php | SocketServer.bind | public static function bind(string $ip, int $port, array $options = []) : SocketServer
{
return (new self($options))->listen($ip, $port);
} | php | public static function bind(string $ip, int $port, array $options = []) : SocketServer
{
return (new self($options))->listen($ip, $port);
} | [
"public",
"static",
"function",
"bind",
"(",
"string",
"$",
"ip",
",",
"int",
"$",
"port",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"SocketServer",
"{",
"return",
"(",
"new",
"self",
"(",
"$",
"options",
")",
")",
"->",
"listen",
"(",
"$",
"ip",
",",
"$",
"port",
")",
";",
"}"
] | Create the socket server. Binds and listens on a specific port
@param string $ip
@param int $port
@param array $options
@return $this
@throws ConnectionException | [
"Create",
"the",
"socket",
"server",
".",
"Binds",
"and",
"listens",
"on",
"a",
"specific",
"port"
] | d74683bf8b827e91a8ca051805c55dacaf64f93d | https://github.com/FreeDSx/Socket/blob/d74683bf8b827e91a8ca051805c55dacaf64f93d/src/FreeDSx/Socket/SocketServer.php#L139-L142 |
33,786 | FreeDSx/Socket | src/FreeDSx/Socket/SocketServer.php | SocketServer.bindTcp | public static function bindTcp(string $ip, int $port, array $options = []) : SocketServer
{
return static::bind($ip, $port, \array_merge($options, ['transport' => 'tcp']));
} | php | public static function bindTcp(string $ip, int $port, array $options = []) : SocketServer
{
return static::bind($ip, $port, \array_merge($options, ['transport' => 'tcp']));
} | [
"public",
"static",
"function",
"bindTcp",
"(",
"string",
"$",
"ip",
",",
"int",
"$",
"port",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"SocketServer",
"{",
"return",
"static",
"::",
"bind",
"(",
"$",
"ip",
",",
"$",
"port",
",",
"\\",
"array_merge",
"(",
"$",
"options",
",",
"[",
"'transport'",
"=>",
"'tcp'",
"]",
")",
")",
";",
"}"
] | Create a TCP based socket server.
@param string $ip
@param int $port
@param array $options
@return SocketServer
@throws ConnectionException | [
"Create",
"a",
"TCP",
"based",
"socket",
"server",
"."
] | d74683bf8b827e91a8ca051805c55dacaf64f93d | https://github.com/FreeDSx/Socket/blob/d74683bf8b827e91a8ca051805c55dacaf64f93d/src/FreeDSx/Socket/SocketServer.php#L153-L156 |
33,787 | brainworxx/kreXX | src/Analyse/Routing/Process/ProcessResource.php | ProcessResource.process | public function process(Model $model)
{
$resource = $model->getData();
$type = get_resource_type($resource);
$typeString = 'resource (' . $type . ')';
switch ($type) {
case 'stream':
$meta = stream_get_meta_data($resource);
break;
case 'curl':
// No need to check for a curl installation, because we are
// facing a curl instance right here.
$meta = curl_getinfo($resource);
break;
default:
$meta = array();
}
// Check, if we have something useful.
if (empty($meta)) {
// If we are facing a closed resource, 'Unknown' is a little bit sparse.
// PHP 7.2 can provide more info by calling gettype().
if (version_compare(phpversion(), '7.2.0', '>=')) {
$typeString = gettype($resource);
}
return $this->pool->render->renderSingleChild(
$model->setData($typeString)
->setNormal($typeString)
->setType(static::TYPE_RESOURCE)
);
}
// Output meta data from the class.
return $this->pool->render->renderExpandableChild(
$model->setType(static::TYPE_RESOURCE)
->addParameter(static::PARAM_DATA, $meta)
->setNormal($typeString)
->injectCallback(
$this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Callback\\Iterate\\ThroughResource')
)
);
} | php | public function process(Model $model)
{
$resource = $model->getData();
$type = get_resource_type($resource);
$typeString = 'resource (' . $type . ')';
switch ($type) {
case 'stream':
$meta = stream_get_meta_data($resource);
break;
case 'curl':
// No need to check for a curl installation, because we are
// facing a curl instance right here.
$meta = curl_getinfo($resource);
break;
default:
$meta = array();
}
// Check, if we have something useful.
if (empty($meta)) {
// If we are facing a closed resource, 'Unknown' is a little bit sparse.
// PHP 7.2 can provide more info by calling gettype().
if (version_compare(phpversion(), '7.2.0', '>=')) {
$typeString = gettype($resource);
}
return $this->pool->render->renderSingleChild(
$model->setData($typeString)
->setNormal($typeString)
->setType(static::TYPE_RESOURCE)
);
}
// Output meta data from the class.
return $this->pool->render->renderExpandableChild(
$model->setType(static::TYPE_RESOURCE)
->addParameter(static::PARAM_DATA, $meta)
->setNormal($typeString)
->injectCallback(
$this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Callback\\Iterate\\ThroughResource')
)
);
} | [
"public",
"function",
"process",
"(",
"Model",
"$",
"model",
")",
"{",
"$",
"resource",
"=",
"$",
"model",
"->",
"getData",
"(",
")",
";",
"$",
"type",
"=",
"get_resource_type",
"(",
"$",
"resource",
")",
";",
"$",
"typeString",
"=",
"'resource ('",
".",
"$",
"type",
".",
"')'",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'stream'",
":",
"$",
"meta",
"=",
"stream_get_meta_data",
"(",
"$",
"resource",
")",
";",
"break",
";",
"case",
"'curl'",
":",
"// No need to check for a curl installation, because we are",
"// facing a curl instance right here.",
"$",
"meta",
"=",
"curl_getinfo",
"(",
"$",
"resource",
")",
";",
"break",
";",
"default",
":",
"$",
"meta",
"=",
"array",
"(",
")",
";",
"}",
"// Check, if we have something useful.",
"if",
"(",
"empty",
"(",
"$",
"meta",
")",
")",
"{",
"// If we are facing a closed resource, 'Unknown' is a little bit sparse.",
"// PHP 7.2 can provide more info by calling gettype().",
"if",
"(",
"version_compare",
"(",
"phpversion",
"(",
")",
",",
"'7.2.0'",
",",
"'>='",
")",
")",
"{",
"$",
"typeString",
"=",
"gettype",
"(",
"$",
"resource",
")",
";",
"}",
"return",
"$",
"this",
"->",
"pool",
"->",
"render",
"->",
"renderSingleChild",
"(",
"$",
"model",
"->",
"setData",
"(",
"$",
"typeString",
")",
"->",
"setNormal",
"(",
"$",
"typeString",
")",
"->",
"setType",
"(",
"static",
"::",
"TYPE_RESOURCE",
")",
")",
";",
"}",
"// Output meta data from the class.",
"return",
"$",
"this",
"->",
"pool",
"->",
"render",
"->",
"renderExpandableChild",
"(",
"$",
"model",
"->",
"setType",
"(",
"static",
"::",
"TYPE_RESOURCE",
")",
"->",
"addParameter",
"(",
"static",
"::",
"PARAM_DATA",
",",
"$",
"meta",
")",
"->",
"setNormal",
"(",
"$",
"typeString",
")",
"->",
"injectCallback",
"(",
"$",
"this",
"->",
"pool",
"->",
"createClass",
"(",
"'Brainworxx\\\\Krexx\\\\Analyse\\\\Callback\\\\Iterate\\\\ThroughResource'",
")",
")",
")",
";",
"}"
] | Analyses a resource.
@param Model $model
The data we are analysing.
@return string
The rendered markup. | [
"Analyses",
"a",
"resource",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Routing/Process/ProcessResource.php#L57-L101 |
33,788 | honey-comb/core | src/Console/HCCreateSuperAdminCommand.php | HCCreateSuperAdminCommand.getEmail | private function getEmail(): ? string
{
$email = $this->ask("Enter email address");
$validator = Validator::make(['email' => $email], [
'email' => 'required|min:3|email',
]);
if ($validator->fails()) {
$this->error('Email is required, minimum 3 symbols length and must be email format');
return $this->getEmail();
}
$this->email = $email;
return null;
} | php | private function getEmail(): ? string
{
$email = $this->ask("Enter email address");
$validator = Validator::make(['email' => $email], [
'email' => 'required|min:3|email',
]);
if ($validator->fails()) {
$this->error('Email is required, minimum 3 symbols length and must be email format');
return $this->getEmail();
}
$this->email = $email;
return null;
} | [
"private",
"function",
"getEmail",
"(",
")",
":",
"?",
"string",
"{",
"$",
"email",
"=",
"$",
"this",
"->",
"ask",
"(",
"\"Enter email address\"",
")",
";",
"$",
"validator",
"=",
"Validator",
"::",
"make",
"(",
"[",
"'email'",
"=>",
"$",
"email",
"]",
",",
"[",
"'email'",
"=>",
"'required|min:3|email'",
",",
"]",
")",
";",
"if",
"(",
"$",
"validator",
"->",
"fails",
"(",
")",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"'Email is required, minimum 3 symbols length and must be email format'",
")",
";",
"return",
"$",
"this",
"->",
"getEmail",
"(",
")",
";",
"}",
"$",
"this",
"->",
"email",
"=",
"$",
"email",
";",
"return",
"null",
";",
"}"
] | Get email address
@return null|string | [
"Get",
"email",
"address"
] | 5c12aba31cae092e9681f0ae3e3664ed3fcec956 | https://github.com/honey-comb/core/blob/5c12aba31cae092e9681f0ae3e3664ed3fcec956/src/Console/HCCreateSuperAdminCommand.php#L122-L139 |
33,789 | honey-comb/core | src/Console/HCCreateSuperAdminCommand.php | HCCreateSuperAdminCommand.createSuperAdmin | private function createSuperAdmin(): void
{
$this->getEmail();
$this->info('');
$this->comment('Creating default super-admin user...');
$this->info('');
$this->checkIfAdminExists();
$this->getPassword();
$this->createAdmin();
$this->comment('Super admin account successfully created!');
$this->comment('Your email: ');
$this->error($this->email);
$this->info('');
} | php | private function createSuperAdmin(): void
{
$this->getEmail();
$this->info('');
$this->comment('Creating default super-admin user...');
$this->info('');
$this->checkIfAdminExists();
$this->getPassword();
$this->createAdmin();
$this->comment('Super admin account successfully created!');
$this->comment('Your email: ');
$this->error($this->email);
$this->info('');
} | [
"private",
"function",
"createSuperAdmin",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"getEmail",
"(",
")",
";",
"$",
"this",
"->",
"info",
"(",
"''",
")",
";",
"$",
"this",
"->",
"comment",
"(",
"'Creating default super-admin user...'",
")",
";",
"$",
"this",
"->",
"info",
"(",
"''",
")",
";",
"$",
"this",
"->",
"checkIfAdminExists",
"(",
")",
";",
"$",
"this",
"->",
"getPassword",
"(",
")",
";",
"$",
"this",
"->",
"createAdmin",
"(",
")",
";",
"$",
"this",
"->",
"comment",
"(",
"'Super admin account successfully created!'",
")",
";",
"$",
"this",
"->",
"comment",
"(",
"'Your email: '",
")",
";",
"$",
"this",
"->",
"error",
"(",
"$",
"this",
"->",
"email",
")",
";",
"$",
"this",
"->",
"info",
"(",
"''",
")",
";",
"}"
] | Create super admin account | [
"Create",
"super",
"admin",
"account"
] | 5c12aba31cae092e9681f0ae3e3664ed3fcec956 | https://github.com/honey-comb/core/blob/5c12aba31cae092e9681f0ae3e3664ed3fcec956/src/Console/HCCreateSuperAdminCommand.php#L144-L163 |
33,790 | honey-comb/core | src/Console/HCScanRolePermissionsCommand.php | HCScanRolePermissionsCommand.extractAllActions | private function extractAllActions(array $aclData): array
{
$allRolesActions = [];
// get all role actions available
foreach ($aclData as $acl) {
if (isset($acl['acl']['rolesActions']) && !empty ($acl['acl']['rolesActions'])) {
foreach ($acl['acl']['rolesActions'] as $role => $actions) {
if (array_key_exists($role, $allRolesActions)) {
$allRolesActions[$role] = array_merge($allRolesActions[$role], $actions);
} else {
$allRolesActions[$role] = array_merge([], $actions);
}
}
}
}
return $allRolesActions;
} | php | private function extractAllActions(array $aclData): array
{
$allRolesActions = [];
// get all role actions available
foreach ($aclData as $acl) {
if (isset($acl['acl']['rolesActions']) && !empty ($acl['acl']['rolesActions'])) {
foreach ($acl['acl']['rolesActions'] as $role => $actions) {
if (array_key_exists($role, $allRolesActions)) {
$allRolesActions[$role] = array_merge($allRolesActions[$role], $actions);
} else {
$allRolesActions[$role] = array_merge([], $actions);
}
}
}
}
return $allRolesActions;
} | [
"private",
"function",
"extractAllActions",
"(",
"array",
"$",
"aclData",
")",
":",
"array",
"{",
"$",
"allRolesActions",
"=",
"[",
"]",
";",
"// get all role actions available",
"foreach",
"(",
"$",
"aclData",
"as",
"$",
"acl",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"acl",
"[",
"'acl'",
"]",
"[",
"'rolesActions'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"acl",
"[",
"'acl'",
"]",
"[",
"'rolesActions'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"acl",
"[",
"'acl'",
"]",
"[",
"'rolesActions'",
"]",
"as",
"$",
"role",
"=>",
"$",
"actions",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"role",
",",
"$",
"allRolesActions",
")",
")",
"{",
"$",
"allRolesActions",
"[",
"$",
"role",
"]",
"=",
"array_merge",
"(",
"$",
"allRolesActions",
"[",
"$",
"role",
"]",
",",
"$",
"actions",
")",
";",
"}",
"else",
"{",
"$",
"allRolesActions",
"[",
"$",
"role",
"]",
"=",
"array_merge",
"(",
"[",
"]",
",",
"$",
"actions",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"allRolesActions",
";",
"}"
] | Extract all actions from roles config
@param array $aclData
@return array | [
"Extract",
"all",
"actions",
"from",
"roles",
"config"
] | 5c12aba31cae092e9681f0ae3e3664ed3fcec956 | https://github.com/honey-comb/core/blob/5c12aba31cae092e9681f0ae3e3664ed3fcec956/src/Console/HCScanRolePermissionsCommand.php#L309-L327 |
33,791 | rhoone/yii2-rhoone | models/SynonymQuery.php | SynonymQuery.headword | public function headword($headword)
{
if ($headword instanceof Headword) {
return $this->andWhere(['headword_guid' => $headword->guid]);
}
if (is_string($headword)) {
$headword = Headword::find()->where(['word' => $headword])->one();
if (!$headword) {
return $this;
}
return $this->andWhere(['headword_guid' => $headword->guid]);
}
} | php | public function headword($headword)
{
if ($headword instanceof Headword) {
return $this->andWhere(['headword_guid' => $headword->guid]);
}
if (is_string($headword)) {
$headword = Headword::find()->where(['word' => $headword])->one();
if (!$headword) {
return $this;
}
return $this->andWhere(['headword_guid' => $headword->guid]);
}
} | [
"public",
"function",
"headword",
"(",
"$",
"headword",
")",
"{",
"if",
"(",
"$",
"headword",
"instanceof",
"Headword",
")",
"{",
"return",
"$",
"this",
"->",
"andWhere",
"(",
"[",
"'headword_guid'",
"=>",
"$",
"headword",
"->",
"guid",
"]",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"headword",
")",
")",
"{",
"$",
"headword",
"=",
"Headword",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'word'",
"=>",
"$",
"headword",
"]",
")",
"->",
"one",
"(",
")",
";",
"if",
"(",
"!",
"$",
"headword",
")",
"{",
"return",
"$",
"this",
";",
"}",
"return",
"$",
"this",
"->",
"andWhere",
"(",
"[",
"'headword_guid'",
"=>",
"$",
"headword",
"->",
"guid",
"]",
")",
";",
"}",
"}"
] | Attach headword.
@param string|Headword $headword
@return \static | [
"Attach",
"headword",
"."
] | f6ae90d466ea6f34bba404be0aba03e37ef369ad | https://github.com/rhoone/yii2-rhoone/blob/f6ae90d466ea6f34bba404be0aba03e37ef369ad/models/SynonymQuery.php#L55-L67 |
33,792 | rollun-com/rollun-datastore | src/DataStore/src/DataStore/Traits/AutoIdGeneratorTrait.php | AutoIdGeneratorTrait.generateId | protected function generateId()
{
trigger_error(AutoIdGeneratorTrait::class . ' trait is deprecated', E_USER_DEPRECATED);
$tryCount = 0;
do {
$id = $this->idGenerator->generate();
$tryCount++;
if ($tryCount >= $this->getIdGenerateMaxTry()) {
throw new DataStoreException("Can't generate id.");
}
} while ($this->has($id));
return $id;
} | php | protected function generateId()
{
trigger_error(AutoIdGeneratorTrait::class . ' trait is deprecated', E_USER_DEPRECATED);
$tryCount = 0;
do {
$id = $this->idGenerator->generate();
$tryCount++;
if ($tryCount >= $this->getIdGenerateMaxTry()) {
throw new DataStoreException("Can't generate id.");
}
} while ($this->has($id));
return $id;
} | [
"protected",
"function",
"generateId",
"(",
")",
"{",
"trigger_error",
"(",
"AutoIdGeneratorTrait",
"::",
"class",
".",
"' trait is deprecated'",
",",
"E_USER_DEPRECATED",
")",
";",
"$",
"tryCount",
"=",
"0",
";",
"do",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"idGenerator",
"->",
"generate",
"(",
")",
";",
"$",
"tryCount",
"++",
";",
"if",
"(",
"$",
"tryCount",
">=",
"$",
"this",
"->",
"getIdGenerateMaxTry",
"(",
")",
")",
"{",
"throw",
"new",
"DataStoreException",
"(",
"\"Can't generate id.\"",
")",
";",
"}",
"}",
"while",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"id",
")",
")",
";",
"return",
"$",
"id",
";",
"}"
] | Generates an arbitrary length string of cryptographic random bytes
@return string
@throws DataStoreException | [
"Generates",
"an",
"arbitrary",
"length",
"string",
"of",
"cryptographic",
"random",
"bytes"
] | ef433b58b94e1c311123ad1b2a0360e95a636bd1 | https://github.com/rollun-com/rollun-datastore/blob/ef433b58b94e1c311123ad1b2a0360e95a636bd1/src/DataStore/src/DataStore/Traits/AutoIdGeneratorTrait.php#L29-L45 |
33,793 | rollun-com/rollun-datastore | src/DataStore/src/DataStore/Traits/AutoIdGeneratorTrait.php | AutoIdGeneratorTrait.prepareItem | protected function prepareItem(array $itemData)
{
if (!isset($itemData[$this->getIdentifier()])) {
$itemData[$this->getIdentifier()] = $this->generateId();
}
return $itemData;
} | php | protected function prepareItem(array $itemData)
{
if (!isset($itemData[$this->getIdentifier()])) {
$itemData[$this->getIdentifier()] = $this->generateId();
}
return $itemData;
} | [
"protected",
"function",
"prepareItem",
"(",
"array",
"$",
"itemData",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"itemData",
"[",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
"]",
")",
")",
"{",
"$",
"itemData",
"[",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
"]",
"=",
"$",
"this",
"->",
"generateId",
"(",
")",
";",
"}",
"return",
"$",
"itemData",
";",
"}"
] | Generate id to item
@param array $itemData
@return array
@throws DataStoreException | [
"Generate",
"id",
"to",
"item"
] | ef433b58b94e1c311123ad1b2a0360e95a636bd1 | https://github.com/rollun-com/rollun-datastore/blob/ef433b58b94e1c311123ad1b2a0360e95a636bd1/src/DataStore/src/DataStore/Traits/AutoIdGeneratorTrait.php#L81-L88 |
33,794 | brainworxx/kreXX | src/Service/Misc/Registry.php | Registry.get | public function get($key)
{
if (empty($this->data[$key]) === true) {
return null;
}
return $this->data[$key];
} | php | public function get($key)
{
if (empty($this->data[$key]) === true) {
return null;
}
return $this->data[$key];
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"key",
"]",
")",
"===",
"true",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"data",
"[",
"$",
"key",
"]",
";",
"}"
] | Getter for the registry.
@param $key
The key under what we once stored the $value,
@return null|mixed
The value, if available. | [
"Getter",
"for",
"the",
"registry",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Misc/Registry.php#L81-L88 |
33,795 | silverorange/swat | Swat/SwatConfirmPasswordEntry.php | SwatConfirmPasswordEntry.process | public function process()
{
parent::process();
if ($this->password_widget === null) {
throw new SwatException(
"Property 'password_widget' is null. " .
'Expected a reference to a SwatPasswordEntry.'
);
}
if ($this->password_widget->value !== null) {
if ($this->password_widget->value !== $this->value) {
$message = Swat::_(
'Password and confirmation password do not match.'
);
$this->addMessage(new SwatMessage($message, 'error'));
}
}
} | php | public function process()
{
parent::process();
if ($this->password_widget === null) {
throw new SwatException(
"Property 'password_widget' is null. " .
'Expected a reference to a SwatPasswordEntry.'
);
}
if ($this->password_widget->value !== null) {
if ($this->password_widget->value !== $this->value) {
$message = Swat::_(
'Password and confirmation password do not match.'
);
$this->addMessage(new SwatMessage($message, 'error'));
}
}
} | [
"public",
"function",
"process",
"(",
")",
"{",
"parent",
"::",
"process",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"password_widget",
"===",
"null",
")",
"{",
"throw",
"new",
"SwatException",
"(",
"\"Property 'password_widget' is null. \"",
".",
"'Expected a reference to a SwatPasswordEntry.'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"password_widget",
"->",
"value",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"password_widget",
"->",
"value",
"!==",
"$",
"this",
"->",
"value",
")",
"{",
"$",
"message",
"=",
"Swat",
"::",
"_",
"(",
"'Password and confirmation password do not match.'",
")",
";",
"$",
"this",
"->",
"addMessage",
"(",
"new",
"SwatMessage",
"(",
"$",
"message",
",",
"'error'",
")",
")",
";",
"}",
"}",
"}"
] | Checks to make sure passwords match
Checks to make sure the values of the two password fields are the same.
If an associated password widget is not set, an exception is thrown. If
the passwords do not match, an error is added to this widget.
@throws SwatException | [
"Checks",
"to",
"make",
"sure",
"passwords",
"match"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatConfirmPasswordEntry.php#L36-L56 |
33,796 | brainworxx/kreXX | src/Analyse/Callback/Analyse/ConfigSection.php | ConfigSection.callMe | public function callMe()
{
$sectionOutput = $this->dispatchStartEvent();
foreach ($this->parameters[static::PARAM_DATA] as $id => $setting) {
// Render the single value.
// We need to find out where the value comes from.
/** @var \Brainworxx\Krexx\Service\Config\Model $setting */
if ($setting->getType() !== Fallback::RENDER_TYPE_NONE) {
$value = $setting->getValue();
// We need to re-translate booleans to something the
// frontend can understand.
if ($value === true) {
$value = 'true';
}
if ($value === false) {
$value = 'false';
}
/** @var Model $model */
$model = $this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Model')->setHelpid($id . static::META_HELP);
$name = $this->pool->messages->getHelp($id . 'Readable');
if ($setting->getEditable() === true) {
$model->setData($name)
->setDomid($id)
->setName($value)
->setNormal($setting->getSource())
->setType($setting->getType());
$sectionOutput .= $this->pool->render->renderSingleEditableChild($model);
} else {
$model->setData($value)
->setName($name)
->setNormal($value)
->setType($setting->getSource());
$sectionOutput .= $this->pool->render->renderSingleChild($model);
}
}
}
return $sectionOutput;
} | php | public function callMe()
{
$sectionOutput = $this->dispatchStartEvent();
foreach ($this->parameters[static::PARAM_DATA] as $id => $setting) {
// Render the single value.
// We need to find out where the value comes from.
/** @var \Brainworxx\Krexx\Service\Config\Model $setting */
if ($setting->getType() !== Fallback::RENDER_TYPE_NONE) {
$value = $setting->getValue();
// We need to re-translate booleans to something the
// frontend can understand.
if ($value === true) {
$value = 'true';
}
if ($value === false) {
$value = 'false';
}
/** @var Model $model */
$model = $this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Model')->setHelpid($id . static::META_HELP);
$name = $this->pool->messages->getHelp($id . 'Readable');
if ($setting->getEditable() === true) {
$model->setData($name)
->setDomid($id)
->setName($value)
->setNormal($setting->getSource())
->setType($setting->getType());
$sectionOutput .= $this->pool->render->renderSingleEditableChild($model);
} else {
$model->setData($value)
->setName($name)
->setNormal($value)
->setType($setting->getSource());
$sectionOutput .= $this->pool->render->renderSingleChild($model);
}
}
}
return $sectionOutput;
} | [
"public",
"function",
"callMe",
"(",
")",
"{",
"$",
"sectionOutput",
"=",
"$",
"this",
"->",
"dispatchStartEvent",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"parameters",
"[",
"static",
"::",
"PARAM_DATA",
"]",
"as",
"$",
"id",
"=>",
"$",
"setting",
")",
"{",
"// Render the single value.",
"// We need to find out where the value comes from.",
"/** @var \\Brainworxx\\Krexx\\Service\\Config\\Model $setting */",
"if",
"(",
"$",
"setting",
"->",
"getType",
"(",
")",
"!==",
"Fallback",
"::",
"RENDER_TYPE_NONE",
")",
"{",
"$",
"value",
"=",
"$",
"setting",
"->",
"getValue",
"(",
")",
";",
"// We need to re-translate booleans to something the",
"// frontend can understand.",
"if",
"(",
"$",
"value",
"===",
"true",
")",
"{",
"$",
"value",
"=",
"'true'",
";",
"}",
"if",
"(",
"$",
"value",
"===",
"false",
")",
"{",
"$",
"value",
"=",
"'false'",
";",
"}",
"/** @var Model $model */",
"$",
"model",
"=",
"$",
"this",
"->",
"pool",
"->",
"createClass",
"(",
"'Brainworxx\\\\Krexx\\\\Analyse\\\\Model'",
")",
"->",
"setHelpid",
"(",
"$",
"id",
".",
"static",
"::",
"META_HELP",
")",
";",
"$",
"name",
"=",
"$",
"this",
"->",
"pool",
"->",
"messages",
"->",
"getHelp",
"(",
"$",
"id",
".",
"'Readable'",
")",
";",
"if",
"(",
"$",
"setting",
"->",
"getEditable",
"(",
")",
"===",
"true",
")",
"{",
"$",
"model",
"->",
"setData",
"(",
"$",
"name",
")",
"->",
"setDomid",
"(",
"$",
"id",
")",
"->",
"setName",
"(",
"$",
"value",
")",
"->",
"setNormal",
"(",
"$",
"setting",
"->",
"getSource",
"(",
")",
")",
"->",
"setType",
"(",
"$",
"setting",
"->",
"getType",
"(",
")",
")",
";",
"$",
"sectionOutput",
".=",
"$",
"this",
"->",
"pool",
"->",
"render",
"->",
"renderSingleEditableChild",
"(",
"$",
"model",
")",
";",
"}",
"else",
"{",
"$",
"model",
"->",
"setData",
"(",
"$",
"value",
")",
"->",
"setName",
"(",
"$",
"name",
")",
"->",
"setNormal",
"(",
"$",
"value",
")",
"->",
"setType",
"(",
"$",
"setting",
"->",
"getSource",
"(",
")",
")",
";",
"$",
"sectionOutput",
".=",
"$",
"this",
"->",
"pool",
"->",
"render",
"->",
"renderSingleChild",
"(",
"$",
"model",
")",
";",
"}",
"}",
"}",
"return",
"$",
"sectionOutput",
";",
"}"
] | Renders each section of the footer.
@return string
The generated markup. | [
"Renders",
"each",
"section",
"of",
"the",
"footer",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Callback/Analyse/ConfigSection.php#L63-L104 |
33,797 | rhoone/yii2-rhoone | controllers/ExtensionController.php | ExtensionController.actionIndex | public function actionIndex()
{
$extensions = Extension::find()->all();
if (empty($extensions)) {
echo "<empty list>";
}
echo"|";
echo sprintf("%28s", "Class Name");
echo"|";
echo sprintf("%4s", "Enb");
echo"|";
echo sprintf("%4s", "Mnp");
echo"|";
echo sprintf("%4s", "Dft");
echo"|";
echo sprintf("%20s", "Create Time");
echo"|";
echo sprintf("%20s", "Update Time");
echo"|";
echo "\r\n";
foreach ($extensions as $extension) {
echo"|";
echo sprintf("%28s", $extension->classname);
echo"|";
echo sprintf("%4d", $extension->isEnabled);
echo"|";
echo sprintf("%4d", $extension->monopolized);
echo"|";
echo sprintf("%4d", $extension->default);
echo"|";
echo sprintf("%20s", $extension->createdAt);
echo"|";
echo sprintf("%20s", $extension->updatedAt);
echo"|";
echo "\r\n";
}
return 0;
} | php | public function actionIndex()
{
$extensions = Extension::find()->all();
if (empty($extensions)) {
echo "<empty list>";
}
echo"|";
echo sprintf("%28s", "Class Name");
echo"|";
echo sprintf("%4s", "Enb");
echo"|";
echo sprintf("%4s", "Mnp");
echo"|";
echo sprintf("%4s", "Dft");
echo"|";
echo sprintf("%20s", "Create Time");
echo"|";
echo sprintf("%20s", "Update Time");
echo"|";
echo "\r\n";
foreach ($extensions as $extension) {
echo"|";
echo sprintf("%28s", $extension->classname);
echo"|";
echo sprintf("%4d", $extension->isEnabled);
echo"|";
echo sprintf("%4d", $extension->monopolized);
echo"|";
echo sprintf("%4d", $extension->default);
echo"|";
echo sprintf("%20s", $extension->createdAt);
echo"|";
echo sprintf("%20s", $extension->updatedAt);
echo"|";
echo "\r\n";
}
return 0;
} | [
"public",
"function",
"actionIndex",
"(",
")",
"{",
"$",
"extensions",
"=",
"Extension",
"::",
"find",
"(",
")",
"->",
"all",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"extensions",
")",
")",
"{",
"echo",
"\"<empty list>\"",
";",
"}",
"echo",
"\"|\"",
";",
"echo",
"sprintf",
"(",
"\"%28s\"",
",",
"\"Class Name\"",
")",
";",
"echo",
"\"|\"",
";",
"echo",
"sprintf",
"(",
"\"%4s\"",
",",
"\"Enb\"",
")",
";",
"echo",
"\"|\"",
";",
"echo",
"sprintf",
"(",
"\"%4s\"",
",",
"\"Mnp\"",
")",
";",
"echo",
"\"|\"",
";",
"echo",
"sprintf",
"(",
"\"%4s\"",
",",
"\"Dft\"",
")",
";",
"echo",
"\"|\"",
";",
"echo",
"sprintf",
"(",
"\"%20s\"",
",",
"\"Create Time\"",
")",
";",
"echo",
"\"|\"",
";",
"echo",
"sprintf",
"(",
"\"%20s\"",
",",
"\"Update Time\"",
")",
";",
"echo",
"\"|\"",
";",
"echo",
"\"\\r\\n\"",
";",
"foreach",
"(",
"$",
"extensions",
"as",
"$",
"extension",
")",
"{",
"echo",
"\"|\"",
";",
"echo",
"sprintf",
"(",
"\"%28s\"",
",",
"$",
"extension",
"->",
"classname",
")",
";",
"echo",
"\"|\"",
";",
"echo",
"sprintf",
"(",
"\"%4d\"",
",",
"$",
"extension",
"->",
"isEnabled",
")",
";",
"echo",
"\"|\"",
";",
"echo",
"sprintf",
"(",
"\"%4d\"",
",",
"$",
"extension",
"->",
"monopolized",
")",
";",
"echo",
"\"|\"",
";",
"echo",
"sprintf",
"(",
"\"%4d\"",
",",
"$",
"extension",
"->",
"default",
")",
";",
"echo",
"\"|\"",
";",
"echo",
"sprintf",
"(",
"\"%20s\"",
",",
"$",
"extension",
"->",
"createdAt",
")",
";",
"echo",
"\"|\"",
";",
"echo",
"sprintf",
"(",
"\"%20s\"",
",",
"$",
"extension",
"->",
"updatedAt",
")",
";",
"echo",
"\"|\"",
";",
"echo",
"\"\\r\\n\"",
";",
"}",
"return",
"0",
";",
"}"
] | List all registered extensions.
@return int | [
"List",
"all",
"registered",
"extensions",
"."
] | f6ae90d466ea6f34bba404be0aba03e37ef369ad | https://github.com/rhoone/yii2-rhoone/blob/f6ae90d466ea6f34bba404be0aba03e37ef369ad/controllers/ExtensionController.php#L32-L69 |
33,798 | rhoone/yii2-rhoone | controllers/ExtensionController.php | ExtensionController.actionEnable | public function actionEnable($class)
{
try {
if (Yii::$app->rhoone->ext->enable($class)) {
echo "Enabled.";
} else {
echo "Failed to enable.";
}
} catch (\Exception $ex) {
throw new Exception($ex->getMessage());
}
return 0;
} | php | public function actionEnable($class)
{
try {
if (Yii::$app->rhoone->ext->enable($class)) {
echo "Enabled.";
} else {
echo "Failed to enable.";
}
} catch (\Exception $ex) {
throw new Exception($ex->getMessage());
}
return 0;
} | [
"public",
"function",
"actionEnable",
"(",
"$",
"class",
")",
"{",
"try",
"{",
"if",
"(",
"Yii",
"::",
"$",
"app",
"->",
"rhoone",
"->",
"ext",
"->",
"enable",
"(",
"$",
"class",
")",
")",
"{",
"echo",
"\"Enabled.\"",
";",
"}",
"else",
"{",
"echo",
"\"Failed to enable.\"",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"ex",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"0",
";",
"}"
] | Enable an extension.
@param string $class
@return int | [
"Enable",
"an",
"extension",
"."
] | f6ae90d466ea6f34bba404be0aba03e37ef369ad | https://github.com/rhoone/yii2-rhoone/blob/f6ae90d466ea6f34bba404be0aba03e37ef369ad/controllers/ExtensionController.php#L96-L108 |
33,799 | rhoone/yii2-rhoone | controllers/ExtensionController.php | ExtensionController.actionDisable | public function actionDisable($class)
{
try {
if (Yii::$app->rhoone->ext->disable($class)) {
echo "Disabled.";
} else {
echo "Failed to disable.";
}
} catch (\Exception $ex) {
throw new Exception($ex->getMessage());
}
return 0;
} | php | public function actionDisable($class)
{
try {
if (Yii::$app->rhoone->ext->disable($class)) {
echo "Disabled.";
} else {
echo "Failed to disable.";
}
} catch (\Exception $ex) {
throw new Exception($ex->getMessage());
}
return 0;
} | [
"public",
"function",
"actionDisable",
"(",
"$",
"class",
")",
"{",
"try",
"{",
"if",
"(",
"Yii",
"::",
"$",
"app",
"->",
"rhoone",
"->",
"ext",
"->",
"disable",
"(",
"$",
"class",
")",
")",
"{",
"echo",
"\"Disabled.\"",
";",
"}",
"else",
"{",
"echo",
"\"Failed to disable.\"",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"ex",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"0",
";",
"}"
] | Disable an extension.
@param string $class
@return int | [
"Disable",
"an",
"extension",
"."
] | f6ae90d466ea6f34bba404be0aba03e37ef369ad | https://github.com/rhoone/yii2-rhoone/blob/f6ae90d466ea6f34bba404be0aba03e37ef369ad/controllers/ExtensionController.php#L115-L127 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.