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 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
cymapgt/UserCredential | lib/Multiotp/contrib/MultiotpAdLdap.php | MultiotpAdLdap.group_del_group | function group_del_group($parent,$child){
//find the parent dn
$parent_group=$this->group_info($parent,array("cn"));
if ($parent_group[0]["dn"]==NULL){ return (false); }
$parent_dn=$parent_group[0]["dn"];
//find the child dn
$child_group=$this->group_info($child,array("cn"));
if ($child_group[0]["dn"]==NULL){ return (false); }
$child_dn=$child_group[0]["dn"];
$del=array();
$del["member"] = $child_dn;
$result=@ldap_mod_del($this->_conn,$parent_dn,$del);
if ($result==false){ return (false); }
return (true);
} | php | function group_del_group($parent,$child){
//find the parent dn
$parent_group=$this->group_info($parent,array("cn"));
if ($parent_group[0]["dn"]==NULL){ return (false); }
$parent_dn=$parent_group[0]["dn"];
//find the child dn
$child_group=$this->group_info($child,array("cn"));
if ($child_group[0]["dn"]==NULL){ return (false); }
$child_dn=$child_group[0]["dn"];
$del=array();
$del["member"] = $child_dn;
$result=@ldap_mod_del($this->_conn,$parent_dn,$del);
if ($result==false){ return (false); }
return (true);
} | [
"function",
"group_del_group",
"(",
"$",
"parent",
",",
"$",
"child",
")",
"{",
"//find the parent dn",
"$",
"parent_group",
"=",
"$",
"this",
"->",
"group_info",
"(",
"$",
"parent",
",",
"array",
"(",
"\"cn\"",
")",
")",
";",
"if",
"(",
"$",
"parent_gro... | Remove a group from a group | [
"Remove",
"a",
"group",
"from",
"a",
"group"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpAdLdap.php#L611-L629 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/MultiotpAdLdap.php | MultiotpAdLdap.group_del_user | function group_del_user($group,$user){
//find the parent dn
$group_info=$this->group_info($group,array("cn"));
if ($group_info[0]["dn"]==NULL){ return (false); }
$group_dn=$group_info[0]["dn"];
//find the child dn
$user_info=$this->user_info($user,array("cn"));
if ($user_info[0]["dn"]==NULL){ return (false); }
$user_dn=$user_info[0]["dn"];
$del=array();
$del["member"] = $user_dn;
$result=@ldap_mod_del($this->_conn,$group_dn,$del);
if ($result==false){ return (false); }
return (true);
} | php | function group_del_user($group,$user){
//find the parent dn
$group_info=$this->group_info($group,array("cn"));
if ($group_info[0]["dn"]==NULL){ return (false); }
$group_dn=$group_info[0]["dn"];
//find the child dn
$user_info=$this->user_info($user,array("cn"));
if ($user_info[0]["dn"]==NULL){ return (false); }
$user_dn=$user_info[0]["dn"];
$del=array();
$del["member"] = $user_dn;
$result=@ldap_mod_del($this->_conn,$group_dn,$del);
if ($result==false){ return (false); }
return (true);
} | [
"function",
"group_del_user",
"(",
"$",
"group",
",",
"$",
"user",
")",
"{",
"//find the parent dn",
"$",
"group_info",
"=",
"$",
"this",
"->",
"group_info",
"(",
"$",
"group",
",",
"array",
"(",
"\"cn\"",
")",
")",
";",
"if",
"(",
"$",
"group_info",
"... | Remove a user from a group | [
"Remove",
"a",
"user",
"from",
"a",
"group"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpAdLdap.php#L632-L650 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/MultiotpAdLdap.php | MultiotpAdLdap.group_info | function group_info($group_name,$fields=NULL){
if ($group_name==NULL){ return (false); }
if (!$this->_bind){ return (false); }
$filter="(&(objectCategory=group)(".$this->_group_cn_identifier."=".$this->ldap_search_encode($group_name)."))";
if ($fields==NULL){ $fields=array("member",$this->_group_attribute,"cn","description","distinguishedname","objectcategory",$this->_group_cn_identifier); }
$sr=@ldap_search($this->_conn,$this->_base_dn,$filter,$fields);
if (FALSE === $sr) {
$this->_warning_message = "group_info: ldap_search error ".ldap_errno($this->_conn).": ".ldap_error($this->_conn);
echo "DEBUG: ".$this->_warning_message."\n";
}
// Search: (&(objectCategory=group)(cn=gr10000))
// (&(objectCategory=group)(cn=gr10))
// PHP Warning: ldap_search(): Search: Critical extension is unavailable in // C:\data\projects\multiotp\core\contrib\MultiotpAdLdap.php on line 591
// Search: (&(objectCategory=group)(cn=gr10))
$entries = $this->ldap_get_entries_raw($sr);
// DEBUG
if (0 == count($entries)) {
$this->_warning_message = "group_info: No entry for the specified filter $filter";
echo "DEBUG: ".$this->_warning_message."\n";
}
return ($entries);
} | php | function group_info($group_name,$fields=NULL){
if ($group_name==NULL){ return (false); }
if (!$this->_bind){ return (false); }
$filter="(&(objectCategory=group)(".$this->_group_cn_identifier."=".$this->ldap_search_encode($group_name)."))";
if ($fields==NULL){ $fields=array("member",$this->_group_attribute,"cn","description","distinguishedname","objectcategory",$this->_group_cn_identifier); }
$sr=@ldap_search($this->_conn,$this->_base_dn,$filter,$fields);
if (FALSE === $sr) {
$this->_warning_message = "group_info: ldap_search error ".ldap_errno($this->_conn).": ".ldap_error($this->_conn);
echo "DEBUG: ".$this->_warning_message."\n";
}
// Search: (&(objectCategory=group)(cn=gr10000))
// (&(objectCategory=group)(cn=gr10))
// PHP Warning: ldap_search(): Search: Critical extension is unavailable in // C:\data\projects\multiotp\core\contrib\MultiotpAdLdap.php on line 591
// Search: (&(objectCategory=group)(cn=gr10))
$entries = $this->ldap_get_entries_raw($sr);
// DEBUG
if (0 == count($entries)) {
$this->_warning_message = "group_info: No entry for the specified filter $filter";
echo "DEBUG: ".$this->_warning_message."\n";
}
return ($entries);
} | [
"function",
"group_info",
"(",
"$",
"group_name",
",",
"$",
"fields",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"group_name",
"==",
"NULL",
")",
"{",
"return",
"(",
"false",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"_bind",
")",
"{",
"retur... | Returns an array of information for a specified group | [
"Returns",
"an",
"array",
"of",
"information",
"for",
"a",
"specified",
"group"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpAdLdap.php#L653-L679 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/MultiotpAdLdap.php | MultiotpAdLdap.group_users | function group_users($group_name=NUL){
$result = array();
if ($group_name==NULL){ return (false); }
if (!$this->_bind){ return (false); }
$filter="(&(|(objectClass=posixGroup)(objectClass=groupofNames))(".$this->_group_cn_identifier."=".$this->ldap_search_encode($group_name)."))";
$fields=array("member","memberuid");
$sr=ldap_search($this->_conn,$this->_base_dn,$filter,$fields);
$entries = $this->ldap_get_entries_raw($sr);
// DEBUG
if (0 == count($entries)) {
$this->_warning_message = "group_users: No entry for the specified filter $filter";
echo "DEBUG: ".$this->_warning_message;
}
if (isset($entries[0]["member"][0]))
{
$result = $this->nice_names($entries[0]["member"]);
/*
for ($i=0; $i++; $i < $entries[0]["member"][count])
{
$result[] == ($entries[0]["member"][$i]);
}
*/
}
elseif (isset($entries[0]["memberuid"][0]))
{
$result = $this->nice_names($entries[0]["memberuid"]);
}
else
{
$result = array();
}
return ($result);
} | php | function group_users($group_name=NUL){
$result = array();
if ($group_name==NULL){ return (false); }
if (!$this->_bind){ return (false); }
$filter="(&(|(objectClass=posixGroup)(objectClass=groupofNames))(".$this->_group_cn_identifier."=".$this->ldap_search_encode($group_name)."))";
$fields=array("member","memberuid");
$sr=ldap_search($this->_conn,$this->_base_dn,$filter,$fields);
$entries = $this->ldap_get_entries_raw($sr);
// DEBUG
if (0 == count($entries)) {
$this->_warning_message = "group_users: No entry for the specified filter $filter";
echo "DEBUG: ".$this->_warning_message;
}
if (isset($entries[0]["member"][0]))
{
$result = $this->nice_names($entries[0]["member"]);
/*
for ($i=0; $i++; $i < $entries[0]["member"][count])
{
$result[] == ($entries[0]["member"][$i]);
}
*/
}
elseif (isset($entries[0]["memberuid"][0]))
{
$result = $this->nice_names($entries[0]["memberuid"]);
}
else
{
$result = array();
}
return ($result);
} | [
"function",
"group_users",
"(",
"$",
"group_name",
"=",
"NUL",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"group_name",
"==",
"NULL",
")",
"{",
"return",
"(",
"false",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
... | Returns an array of users that are members of a group | [
"Returns",
"an",
"array",
"of",
"users",
"that",
"are",
"members",
"of",
"a",
"group"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpAdLdap.php#L810-L845 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/MultiotpAdLdap.php | MultiotpAdLdap.user_groups | function user_groups($username,$recursive=NULL){
if ($username==NULL){ return (false); }
if ($recursive==NULL){ $recursive=$this->_recursive_groups; } //use the default option if they haven't set it
if (!$this->_bind){ return (false); }
//search the directory for their information
$info=@$this->user_info($username,array($this->_group_attribute,"member","primarygroupid"));
$groups=$this->nice_names($info[0][$this->_group_attribute]); //presuming the entry returned is our guy (unique usernames)
if ($recursive){
foreach ($groups as $id => $group_name){
$extra_groups=$this->recursive_groups($group_name);
$groups=array_merge($groups,$extra_groups);
}
}
return ($groups);
} | php | function user_groups($username,$recursive=NULL){
if ($username==NULL){ return (false); }
if ($recursive==NULL){ $recursive=$this->_recursive_groups; } //use the default option if they haven't set it
if (!$this->_bind){ return (false); }
//search the directory for their information
$info=@$this->user_info($username,array($this->_group_attribute,"member","primarygroupid"));
$groups=$this->nice_names($info[0][$this->_group_attribute]); //presuming the entry returned is our guy (unique usernames)
if ($recursive){
foreach ($groups as $id => $group_name){
$extra_groups=$this->recursive_groups($group_name);
$groups=array_merge($groups,$extra_groups);
}
}
return ($groups);
} | [
"function",
"user_groups",
"(",
"$",
"username",
",",
"$",
"recursive",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"username",
"==",
"NULL",
")",
"{",
"return",
"(",
"false",
")",
";",
"}",
"if",
"(",
"$",
"recursive",
"==",
"NULL",
")",
"{",
"$",
"r... | Returns an array of groups that a user is a member off | [
"Returns",
"an",
"array",
"of",
"groups",
"that",
"a",
"user",
"is",
"a",
"member",
"off"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpAdLdap.php#L850-L867 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/MultiotpAdLdap.php | MultiotpAdLdap.user_all_groups | function user_all_groups($username, $groups_filtering = '') {
if ($username==NULL){ return (false); }
if (!$this->_bind){ return (false); }
$filter = "(&(objectCategory=group)(member:1.2.840.113556.1.4.1941:=".$username.")".$groups_filtering.")";
// $fields = array($this->_group_cn_identifier,$this->_group_attribute,"distinguishedname");
$fields = array("cn");
$sr = ldap_search($this->_conn,$this->_base_dn,$filter, $fields);
$group_entries = $this->rCountRemover(ldap_get_entries($this->_conn, $sr));
//echo "DEBUG: info group_entries\n";
//print_r($group_entries);
$group_array = array();
foreach ($group_entries as $group_entry) {
$group_array[] = $group_entry['cn'][0];
}
//echo "DEBUG: group_array\n";
//print_r($group_array);
return ($group_array);
} | php | function user_all_groups($username, $groups_filtering = '') {
if ($username==NULL){ return (false); }
if (!$this->_bind){ return (false); }
$filter = "(&(objectCategory=group)(member:1.2.840.113556.1.4.1941:=".$username.")".$groups_filtering.")";
// $fields = array($this->_group_cn_identifier,$this->_group_attribute,"distinguishedname");
$fields = array("cn");
$sr = ldap_search($this->_conn,$this->_base_dn,$filter, $fields);
$group_entries = $this->rCountRemover(ldap_get_entries($this->_conn, $sr));
//echo "DEBUG: info group_entries\n";
//print_r($group_entries);
$group_array = array();
foreach ($group_entries as $group_entry) {
$group_array[] = $group_entry['cn'][0];
}
//echo "DEBUG: group_array\n";
//print_r($group_array);
return ($group_array);
} | [
"function",
"user_all_groups",
"(",
"$",
"username",
",",
"$",
"groups_filtering",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"username",
"==",
"NULL",
")",
"{",
"return",
"(",
"false",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"_bind",
")",
"{",... | New function, for enhanced Active Directory | [
"New",
"function",
"for",
"enhanced",
"Active",
"Directory"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpAdLdap.php#L882-L902 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/MultiotpAdLdap.php | MultiotpAdLdap.users_info | function users_info($username=NULL, $fields=NULL, $groups_filtering = '')
{
$entries = array();
$entries['count'] = 0; // To be compatible with the old data organisation (counter at the beginning)
$i = 0;
if ($result = $this->one_user_info(TRUE, $username, $fields, FALSE, $groups_filtering)) {
do {
$entries[$i] = $result;
$i++;
} while ($result = $this->one_user_info());
}
$entries['count'] = $i; // and not count($entries) because of the ['count'] argument
return ($entries);
} | php | function users_info($username=NULL, $fields=NULL, $groups_filtering = '')
{
$entries = array();
$entries['count'] = 0; // To be compatible with the old data organisation (counter at the beginning)
$i = 0;
if ($result = $this->one_user_info(TRUE, $username, $fields, FALSE, $groups_filtering)) {
do {
$entries[$i] = $result;
$i++;
} while ($result = $this->one_user_info());
}
$entries['count'] = $i; // and not count($entries) because of the ['count'] argument
return ($entries);
} | [
"function",
"users_info",
"(",
"$",
"username",
"=",
"NULL",
",",
"$",
"fields",
"=",
"NULL",
",",
"$",
"groups_filtering",
"=",
"''",
")",
"{",
"$",
"entries",
"=",
"array",
"(",
")",
";",
"$",
"entries",
"[",
"'count'",
"]",
"=",
"0",
";",
"// To... | Returns an array of information for filtered users | [
"Returns",
"an",
"array",
"of",
"information",
"for",
"filtered",
"users"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpAdLdap.php#L908-L921 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/MultiotpAdLdap.php | MultiotpAdLdap.user_ingroup | function user_ingroup($username,$group,$recursive=NULL){
if ($username==NULL){ return (false); }
if ($group==NULL){ return (false); }
if (!$this->_bind){ return (false); }
if ($recursive==NULL){ $recursive=$this->_recursive_groups; } //use the default option if they haven't set it
//get a list of the groups
$groups=$this->user_groups($username,array($this->_group_attribute),$recursive);
//return true if the specified group is in the group list
if (in_array($group,$groups)){ return (true); }
return (false);
} | php | function user_ingroup($username,$group,$recursive=NULL){
if ($username==NULL){ return (false); }
if ($group==NULL){ return (false); }
if (!$this->_bind){ return (false); }
if ($recursive==NULL){ $recursive=$this->_recursive_groups; } //use the default option if they haven't set it
//get a list of the groups
$groups=$this->user_groups($username,array($this->_group_attribute),$recursive);
//return true if the specified group is in the group list
if (in_array($group,$groups)){ return (true); }
return (false);
} | [
"function",
"user_ingroup",
"(",
"$",
"username",
",",
"$",
"group",
",",
"$",
"recursive",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"username",
"==",
"NULL",
")",
"{",
"return",
"(",
"false",
")",
";",
"}",
"if",
"(",
"$",
"group",
"==",
"NULL",
"... | Returns true if the user is a member of the group | [
"Returns",
"true",
"if",
"the",
"user",
"is",
"a",
"member",
"of",
"the",
"group"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpAdLdap.php#L1096-L1109 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/MultiotpAdLdap.php | MultiotpAdLdap.user_modify | function user_modify($username,$attributes){
if ($username==NULL){ return ("Missing compulsory field [username]"); }
if (array_key_exists("password",$attributes) && !$this->_use_ssl){ echo ("FATAL: SSL must be configured on your webserver and enabled in the class to set passwords."); exit(); }
//if (array_key_exists("container",$attributes)){
//if (!is_array($attributes["container"])){ return ("Container attribute must be an array."); }
//$attributes["container"]=array_reverse($attributes["container"]);
//}
//find the dn of the user
$user=$this->user_info($username,array("cn"));
if ($user[0]["dn"]==NULL){ return (false); }
$user_dn=$user[0]["dn"];
//translate the update to the LDAP schema
$mod=$this->adldap_schema($attributes);
if (!$mod){ return (false); }
//set the account control attribute (only if specified)
if (array_key_exists("enabled",$attributes)){
if ($attributes["enabled"]){ $control_options=array("NORMAL_ACCOUNT"); }
else { $control_options=array("NORMAL_ACCOUNT","ACCOUNTDISABLE"); }
$mod["userAccountControl"][0]=$this->account_control($control_options);
}
//do the update
$result=ldap_modify($this->_conn,$user_dn,$mod);
if ($result==false){ return (false); }
return (true);
} | php | function user_modify($username,$attributes){
if ($username==NULL){ return ("Missing compulsory field [username]"); }
if (array_key_exists("password",$attributes) && !$this->_use_ssl){ echo ("FATAL: SSL must be configured on your webserver and enabled in the class to set passwords."); exit(); }
//if (array_key_exists("container",$attributes)){
//if (!is_array($attributes["container"])){ return ("Container attribute must be an array."); }
//$attributes["container"]=array_reverse($attributes["container"]);
//}
//find the dn of the user
$user=$this->user_info($username,array("cn"));
if ($user[0]["dn"]==NULL){ return (false); }
$user_dn=$user[0]["dn"];
//translate the update to the LDAP schema
$mod=$this->adldap_schema($attributes);
if (!$mod){ return (false); }
//set the account control attribute (only if specified)
if (array_key_exists("enabled",$attributes)){
if ($attributes["enabled"]){ $control_options=array("NORMAL_ACCOUNT"); }
else { $control_options=array("NORMAL_ACCOUNT","ACCOUNTDISABLE"); }
$mod["userAccountControl"][0]=$this->account_control($control_options);
}
//do the update
$result=ldap_modify($this->_conn,$user_dn,$mod);
if ($result==false){ return (false); }
return (true);
} | [
"function",
"user_modify",
"(",
"$",
"username",
",",
"$",
"attributes",
")",
"{",
"if",
"(",
"$",
"username",
"==",
"NULL",
")",
"{",
"return",
"(",
"\"Missing compulsory field [username]\"",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"\"password\"",
... | modify a user | [
"modify",
"a",
"user"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpAdLdap.php#L1112-L1141 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/MultiotpAdLdap.php | MultiotpAdLdap.user_password | function user_password($username,$password){
if ($username==NULL){ return (false); }
if ($password==NULL){ return (false); }
if (!$this->_bind){ return (false); }
if (!$this->_use_ssl){ echo ("FATAL: SSL must be configured on your webserver and enabled in the class to set passwords."); exit(); }
$user=$this->user_info($username,array("cn"));
if ($user[0]["dn"]==NULL){ return (false); }
$user_dn=$user[0]["dn"];
$add=array();
$add["unicodePwd"][0]=$this->encode_password($password);
$result=ldap_mod_replace($this->_conn,$user_dn,$add);
if ($result==false){ return (false); }
return (true);
} | php | function user_password($username,$password){
if ($username==NULL){ return (false); }
if ($password==NULL){ return (false); }
if (!$this->_bind){ return (false); }
if (!$this->_use_ssl){ echo ("FATAL: SSL must be configured on your webserver and enabled in the class to set passwords."); exit(); }
$user=$this->user_info($username,array("cn"));
if ($user[0]["dn"]==NULL){ return (false); }
$user_dn=$user[0]["dn"];
$add=array();
$add["unicodePwd"][0]=$this->encode_password($password);
$result=ldap_mod_replace($this->_conn,$user_dn,$add);
if ($result==false){ return (false); }
return (true);
} | [
"function",
"user_password",
"(",
"$",
"username",
",",
"$",
"password",
")",
"{",
"if",
"(",
"$",
"username",
"==",
"NULL",
")",
"{",
"return",
"(",
"false",
")",
";",
"}",
"if",
"(",
"$",
"password",
"==",
"NULL",
")",
"{",
"return",
"(",
"false"... | Set the password of a user | [
"Set",
"the",
"password",
"of",
"a",
"user"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpAdLdap.php#L1144-L1161 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/MultiotpAdLdap.php | MultiotpAdLdap.computer_info | function computer_info($computer_name,$fields=NULL){
if ($computer_name==NULL){ return (false); }
if (!$this->_bind){ return (false); }
$filter="(&(objectClass=computer)(cn=".$computer_name."))";
if ($fields==NULL){ $fields=array($this->_group_attribute,"cn","displayname","dnshostname","distinguishedname","objectcategory","operatingsystem","operatingsystemservicepack","operatingsystemversion"); }
$sr=ldap_search($this->_conn,$this->_base_dn,$filter,$fields);
$entries = $this->ldap_get_entries_raw($sr);
return ($entries);
} | php | function computer_info($computer_name,$fields=NULL){
if ($computer_name==NULL){ return (false); }
if (!$this->_bind){ return (false); }
$filter="(&(objectClass=computer)(cn=".$computer_name."))";
if ($fields==NULL){ $fields=array($this->_group_attribute,"cn","displayname","dnshostname","distinguishedname","objectcategory","operatingsystem","operatingsystemservicepack","operatingsystemversion"); }
$sr=ldap_search($this->_conn,$this->_base_dn,$filter,$fields);
$entries = $this->ldap_get_entries_raw($sr);
return ($entries);
} | [
"function",
"computer_info",
"(",
"$",
"computer_name",
",",
"$",
"fields",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"computer_name",
"==",
"NULL",
")",
"{",
"return",
"(",
"false",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"_bind",
")",
"{",... | Returns an array of information for a specific computer | [
"Returns",
"an",
"array",
"of",
"information",
"for",
"a",
"specific",
"computer"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpAdLdap.php#L1167-L1177 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/MultiotpAdLdap.php | MultiotpAdLdap.all_users | function all_users($include_desc = false, $search = "*", $sorted = true){
if (!$this->_bind){
return (false);
}
//perform the search and grab all their details
$filter = "(&(objectClass=user)(samaccounttype=". ADLDAP_NORMAL_ACCOUNT .")(objectCategory=person)(cn=".$search."))";
$fields=array($this->_cn_identifier,"displayname");
$sr=ldap_search($this->_conn,$this->_base_dn,$filter,$fields);
$entries = $this->ldap_get_entries_raw($sr);
$users_array = array();
for ($i=0; $i<$entries["count"]; $i++){
if ($include_desc && strlen($entries[$i]["displayname"][0])>0){
$users_array[ $entries[$i][$this->_cn_identifier][0] ] = $entries[$i]["displayname"][0];
} elseif ($include_desc){
$users_array[ $entries[$i][$this->_cn_identifier][0] ] = $entries[$i][$this->_cn_identifier][0];
} else {
array_push($users_array, $entries[$i][$this->_cn_identifier][0]);
}
}
if ($sorted){ asort($users_array); }
return ($users_array);
} | php | function all_users($include_desc = false, $search = "*", $sorted = true){
if (!$this->_bind){
return (false);
}
//perform the search and grab all their details
$filter = "(&(objectClass=user)(samaccounttype=". ADLDAP_NORMAL_ACCOUNT .")(objectCategory=person)(cn=".$search."))";
$fields=array($this->_cn_identifier,"displayname");
$sr=ldap_search($this->_conn,$this->_base_dn,$filter,$fields);
$entries = $this->ldap_get_entries_raw($sr);
$users_array = array();
for ($i=0; $i<$entries["count"]; $i++){
if ($include_desc && strlen($entries[$i]["displayname"][0])>0){
$users_array[ $entries[$i][$this->_cn_identifier][0] ] = $entries[$i]["displayname"][0];
} elseif ($include_desc){
$users_array[ $entries[$i][$this->_cn_identifier][0] ] = $entries[$i][$this->_cn_identifier][0];
} else {
array_push($users_array, $entries[$i][$this->_cn_identifier][0]);
}
}
if ($sorted){ asort($users_array); }
return ($users_array);
} | [
"function",
"all_users",
"(",
"$",
"include_desc",
"=",
"false",
",",
"$",
"search",
"=",
"\"*\"",
",",
"$",
"sorted",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_bind",
")",
"{",
"return",
"(",
"false",
")",
";",
"}",
"//perform th... | Returns all AD users | [
"Returns",
"all",
"AD",
"users"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpAdLdap.php#L1180-L1203 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/MultiotpAdLdap.php | MultiotpAdLdap.encode_password | function encode_password($password){
$password="\"".$password."\"";
$encoded="";
for ($i=0; $i <strlen($password); $i++){ $encoded.="{$password{$i}}\000"; }
return ($encoded);
} | php | function encode_password($password){
$password="\"".$password."\"";
$encoded="";
for ($i=0; $i <strlen($password); $i++){ $encoded.="{$password{$i}}\000"; }
return ($encoded);
} | [
"function",
"encode_password",
"(",
"$",
"password",
")",
"{",
"$",
"password",
"=",
"\"\\\"\"",
".",
"$",
"password",
".",
"\"\\\"\"",
";",
"$",
"encoded",
"=",
"\"\"",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"strlen",
"(",
"$",
... | Encode a password for transmission over LDAP | [
"Encode",
"a",
"password",
"for",
"transmission",
"over",
"LDAP"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpAdLdap.php#L1442-L1447 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/MultiotpAdLdap.php | MultiotpAdLdap.ldap_slashes | function ldap_slashes($str){
$illegal=array("(",")","#"); // the + character has problems too, but it's an illegal character
$legal=array();
foreach ($illegal as $id => $char){ $legal[$id]="\\".$char; } //make up the array of legal chars
$str=str_replace($illegal,$legal,$str); //replace them
return ($str);
} | php | function ldap_slashes($str){
$illegal=array("(",")","#"); // the + character has problems too, but it's an illegal character
$legal=array();
foreach ($illegal as $id => $char){ $legal[$id]="\\".$char; } //make up the array of legal chars
$str=str_replace($illegal,$legal,$str); //replace them
return ($str);
} | [
"function",
"ldap_slashes",
"(",
"$",
"str",
")",
"{",
"$",
"illegal",
"=",
"array",
"(",
"\"(\"",
",",
"\")\"",
",",
"\"#\"",
")",
";",
"// the + character has problems too, but it's an illegal character",
"$",
"legal",
"=",
"array",
"(",
")",
";",
"foreach",
... | this is just a list of characters with known problems and I'm trying not to strip out other languages | [
"this",
"is",
"just",
"a",
"list",
"of",
"characters",
"with",
"known",
"problems",
"and",
"I",
"m",
"trying",
"not",
"to",
"strip",
"out",
"other",
"languages"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpAdLdap.php#L1452-L1460 | train |
shopgate/cart-integration-magento2-base | src/Model/Rule/Condition/ShopgateOrder.php | ShopgateOrder.getValueSelectOptions | public function getValueSelectOptions()
{
if (!$this->hasData('value_select_options')) {
$this->setData(
'value_select_options',
$this->sourceYesno->toOptionArray()
);
}
return $this->getData('value_select_options');
} | php | public function getValueSelectOptions()
{
if (!$this->hasData('value_select_options')) {
$this->setData(
'value_select_options',
$this->sourceYesno->toOptionArray()
);
}
return $this->getData('value_select_options');
} | [
"public",
"function",
"getValueSelectOptions",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasData",
"(",
"'value_select_options'",
")",
")",
"{",
"$",
"this",
"->",
"setData",
"(",
"'value_select_options'",
",",
"$",
"this",
"->",
"sourceYesno",
"->"... | Get value select options
@return array|mixed | [
"Get",
"value",
"select",
"options"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Rule/Condition/ShopgateOrder.php#L107-L117 | train |
shopgate/cart-integration-magento2-base | src/Model/Rule/Condition/ShopgateOrder.php | ShopgateOrder.validate | public function validate(\Magento\Framework\Model\AbstractModel $model)
{
$isShopgateOrder = (int) in_array($model->getData(self::CLIENT_ATTRIBUTE), self::APP_CLIENTS);
// TODO add validation for web checkout
$model->setData(self::IS_SHOPGATE_ORDER, $isShopgateOrder);
return parent::validate($model);
} | php | public function validate(\Magento\Framework\Model\AbstractModel $model)
{
$isShopgateOrder = (int) in_array($model->getData(self::CLIENT_ATTRIBUTE), self::APP_CLIENTS);
// TODO add validation for web checkout
$model->setData(self::IS_SHOPGATE_ORDER, $isShopgateOrder);
return parent::validate($model);
} | [
"public",
"function",
"validate",
"(",
"\\",
"Magento",
"\\",
"Framework",
"\\",
"Model",
"\\",
"AbstractModel",
"$",
"model",
")",
"{",
"$",
"isShopgateOrder",
"=",
"(",
"int",
")",
"in_array",
"(",
"$",
"model",
"->",
"getData",
"(",
"self",
"::",
"CLI... | Validate App Rule Condition
@param \Magento\Framework\Model\AbstractModel $model
@return bool | [
"Validate",
"App",
"Rule",
"Condition"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Rule/Condition/ShopgateOrder.php#L126-L133 | train |
bakaphp/database | src/ModelCustomFields.php | ModelCustomFields.getCustomFields | public static function getCustomFields($findResults, $getById = false)
{
if (is_array($findResults)) {
if (count($findResults) == 1 && $getById) {
$findResults = [$findResults];
}
}
$results = [];
$classReflection = (new \ReflectionClass($findResults[0]));
$className = $classReflection->getShortName();
$classNamespace = $classReflection->getNamespaceName();
$module = Modules::findFirstByName($className);
if ($module) {
$model = $classNamespace . '\\' . ucfirst($module->name) . 'CustomFields';
$modelId = strtolower($module->name) . '_id';
$customFields = CustomFields::findByModulesId($module->id);
if (is_array($findResults)) {
$findResults[0] = $findResults[0]->toArray();
} else {
$findResults = $findResults->toArray();
}
foreach ($findResults as $result) {
foreach ($customFields as $customField) {
$result['custom_fields'][$customField->name] = '';
$values = [];
$moduleValues = $model::find([
$modelId . ' = ?0 AND custom_fields_id = ?1',
'bind' => [$result['id'], $customField->id]
]);
if ($moduleValues->count()) {
$result['custom_fields'][$customField->name] = $moduleValues[0]->value;
}
}
$results[] = $result;
}
return $getById ? $results[0] : $results;
}
return $getById ? $findResults[0]->toArray() : $findResults;
} | php | public static function getCustomFields($findResults, $getById = false)
{
if (is_array($findResults)) {
if (count($findResults) == 1 && $getById) {
$findResults = [$findResults];
}
}
$results = [];
$classReflection = (new \ReflectionClass($findResults[0]));
$className = $classReflection->getShortName();
$classNamespace = $classReflection->getNamespaceName();
$module = Modules::findFirstByName($className);
if ($module) {
$model = $classNamespace . '\\' . ucfirst($module->name) . 'CustomFields';
$modelId = strtolower($module->name) . '_id';
$customFields = CustomFields::findByModulesId($module->id);
if (is_array($findResults)) {
$findResults[0] = $findResults[0]->toArray();
} else {
$findResults = $findResults->toArray();
}
foreach ($findResults as $result) {
foreach ($customFields as $customField) {
$result['custom_fields'][$customField->name] = '';
$values = [];
$moduleValues = $model::find([
$modelId . ' = ?0 AND custom_fields_id = ?1',
'bind' => [$result['id'], $customField->id]
]);
if ($moduleValues->count()) {
$result['custom_fields'][$customField->name] = $moduleValues[0]->value;
}
}
$results[] = $result;
}
return $getById ? $results[0] : $results;
}
return $getById ? $findResults[0]->toArray() : $findResults;
} | [
"public",
"static",
"function",
"getCustomFields",
"(",
"$",
"findResults",
",",
"$",
"getById",
"=",
"false",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"findResults",
")",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"findResults",
")",
"==",
"1",
"&&",
... | Get a models custom fields
@param mixed $findResults
@return Array
@TODO: Made a change to return a single record when $getById is true. Keeping an eye on it. | [
"Get",
"a",
"models",
"custom",
"fields"
] | b227de7c27e819abadf56cfd66ff08dab2797d62 | https://github.com/bakaphp/database/blob/b227de7c27e819abadf56cfd66ff08dab2797d62/src/ModelCustomFields.php#L25-L73 | train |
bakaphp/database | src/ModelCustomFields.php | ModelCustomFields.getAllCustomFields | public function getAllCustomFields(array $fields = [])
{
if (!$models = Modules::findFirstByName($this->getSource())) {
return;
}
$conditions = [];
$fieldsIn = null;
if (!empty($fields)) {
$fieldsIn = " and name in ('" . implode("','", $fields) . ')';
}
$conditions = 'modules_id = ? ' . $fieldsIn;
$bind = [$this->getId(), $models->getId()];
$customFieldsValueTable = $this->getSource() . '_custom_fields';
$result = $this->getReadConnection()->prepare("SELECT l.{$this->getSource()}_id,
c.id as field_id,
c.name,
l.value ,
c.users_id,
l.created_at,
l.updated_at
FROM {$customFieldsValueTable} l,
custom_fields c
WHERE c.id = l.custom_fields_id
AND l.leads_id = ?
AND c.modules_id = ? ");
$result->execute($bind);
// $listOfCustomFields = $result->fetchAll();
$listOfCustomFields = [];
while ($row = $result->fetch(\PDO::FETCH_OBJ)) {
$listOfCustomFields[$row->name] = $row->value;
}
return $listOfCustomFields;
} | php | public function getAllCustomFields(array $fields = [])
{
if (!$models = Modules::findFirstByName($this->getSource())) {
return;
}
$conditions = [];
$fieldsIn = null;
if (!empty($fields)) {
$fieldsIn = " and name in ('" . implode("','", $fields) . ')';
}
$conditions = 'modules_id = ? ' . $fieldsIn;
$bind = [$this->getId(), $models->getId()];
$customFieldsValueTable = $this->getSource() . '_custom_fields';
$result = $this->getReadConnection()->prepare("SELECT l.{$this->getSource()}_id,
c.id as field_id,
c.name,
l.value ,
c.users_id,
l.created_at,
l.updated_at
FROM {$customFieldsValueTable} l,
custom_fields c
WHERE c.id = l.custom_fields_id
AND l.leads_id = ?
AND c.modules_id = ? ");
$result->execute($bind);
// $listOfCustomFields = $result->fetchAll();
$listOfCustomFields = [];
while ($row = $result->fetch(\PDO::FETCH_OBJ)) {
$listOfCustomFields[$row->name] = $row->value;
}
return $listOfCustomFields;
} | [
"public",
"function",
"getAllCustomFields",
"(",
"array",
"$",
"fields",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"models",
"=",
"Modules",
"::",
"findFirstByName",
"(",
"$",
"this",
"->",
"getSource",
"(",
")",
")",
")",
"{",
"return",
";",
"}"... | Get all custom fields of the given object
@param array $fields
@return Phalcon\Mvc\Model | [
"Get",
"all",
"custom",
"fields",
"of",
"the",
"given",
"object"
] | b227de7c27e819abadf56cfd66ff08dab2797d62 | https://github.com/bakaphp/database/blob/b227de7c27e819abadf56cfd66ff08dab2797d62/src/ModelCustomFields.php#L81-L123 | train |
bakaphp/database | src/ModelCustomFields.php | ModelCustomFields.saveCustomFields | protected function saveCustomFields(): bool
{
//find the custom field module
if (!$module = Modules::findFirstByName($this->getSource())) {
return false;
}
//we need a new instane to avoid overwrite
$reflector = new \ReflectionClass($this);
$classNameWithNameSpace = $reflector->getNamespaceName() . '\\' . $reflector->getShortName() . 'CustomFields';
//if all is good now lets get the custom fields and save them
foreach ($this->customFields as $key => $value) {
//create a new obj per itration to se can save new info
$customModel = new $classNameWithNameSpace();
//validate the custome field by it model
if ($customField = CustomFields::findFirst(['conditions' => 'name = ?0 and modules_id = ?1', 'bind' => [$key, $module->id]])) {
//throw new Exception("this custom field doesnt exist");
$customModel->setCustomId($this->getId());
$customModel->custom_fields_id = $customField->id;
$customModel->value = $value;
$customModel->created_at = date('Y-m-d H:i:s');
if (!$customModel->save()) {
throw new Exception('Custome ' . $key . ' - ' . $this->customModel->getMessages()[0]);
}
}
}
//clean
unset($this->customFields);
return true;
} | php | protected function saveCustomFields(): bool
{
//find the custom field module
if (!$module = Modules::findFirstByName($this->getSource())) {
return false;
}
//we need a new instane to avoid overwrite
$reflector = new \ReflectionClass($this);
$classNameWithNameSpace = $reflector->getNamespaceName() . '\\' . $reflector->getShortName() . 'CustomFields';
//if all is good now lets get the custom fields and save them
foreach ($this->customFields as $key => $value) {
//create a new obj per itration to se can save new info
$customModel = new $classNameWithNameSpace();
//validate the custome field by it model
if ($customField = CustomFields::findFirst(['conditions' => 'name = ?0 and modules_id = ?1', 'bind' => [$key, $module->id]])) {
//throw new Exception("this custom field doesnt exist");
$customModel->setCustomId($this->getId());
$customModel->custom_fields_id = $customField->id;
$customModel->value = $value;
$customModel->created_at = date('Y-m-d H:i:s');
if (!$customModel->save()) {
throw new Exception('Custome ' . $key . ' - ' . $this->customModel->getMessages()[0]);
}
}
}
//clean
unset($this->customFields);
return true;
} | [
"protected",
"function",
"saveCustomFields",
"(",
")",
":",
"bool",
"{",
"//find the custom field module",
"if",
"(",
"!",
"$",
"module",
"=",
"Modules",
"::",
"findFirstByName",
"(",
"$",
"this",
"->",
"getSource",
"(",
")",
")",
")",
"{",
"return",
"false"... | Create new custom fields
We never update any custom fields, we delete them and create them again, thats why we call cleanCustomFields before updates
@return void | [
"Create",
"new",
"custom",
"fields"
] | b227de7c27e819abadf56cfd66ff08dab2797d62 | https://github.com/bakaphp/database/blob/b227de7c27e819abadf56cfd66ff08dab2797d62/src/ModelCustomFields.php#L185-L220 | train |
bakaphp/database | src/ModelCustomFields.php | ModelCustomFields.cleanCustomFields | public function cleanCustomFields(int $id): bool
{
$reflector = new \ReflectionClass($this);
$classNameWithNameSpace = $reflector->getNamespaceName() . '\\' . $reflector->getShortName() . 'CustomFields';
$customModel = new $classNameWithNameSpace();
//return $customModel->find(['conditions' => $this->getSource() . '_id = ?0', 'bind' => [$id]])->delete();
//we need to run the query since we dont have primary key
$result = $this->getReadConnection()->prepare("DELETE FROM {$customModel->getSource()} WHERE " . $this->getSource() . '_id = ?');
return $result->execute([$id]);
} | php | public function cleanCustomFields(int $id): bool
{
$reflector = new \ReflectionClass($this);
$classNameWithNameSpace = $reflector->getNamespaceName() . '\\' . $reflector->getShortName() . 'CustomFields';
$customModel = new $classNameWithNameSpace();
//return $customModel->find(['conditions' => $this->getSource() . '_id = ?0', 'bind' => [$id]])->delete();
//we need to run the query since we dont have primary key
$result = $this->getReadConnection()->prepare("DELETE FROM {$customModel->getSource()} WHERE " . $this->getSource() . '_id = ?');
return $result->execute([$id]);
} | [
"public",
"function",
"cleanCustomFields",
"(",
"int",
"$",
"id",
")",
":",
"bool",
"{",
"$",
"reflector",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
")",
";",
"$",
"classNameWithNameSpace",
"=",
"$",
"reflector",
"->",
"getNamespaceName",
"(",
... | Remove all the custom fields from the entity
@param int $id
@return \Phalcon\MVC\Models | [
"Remove",
"all",
"the",
"custom",
"fields",
"from",
"the",
"entity"
] | b227de7c27e819abadf56cfd66ff08dab2797d62 | https://github.com/bakaphp/database/blob/b227de7c27e819abadf56cfd66ff08dab2797d62/src/ModelCustomFields.php#L228-L238 | train |
bakaphp/database | src/ModelCustomFields.php | ModelCustomFields.afterUpdate | public function afterUpdate()
{
//only clean and change custom fields if they are been sent
if (!empty($this->customFields)) {
//replace old custom with new
$allCustomFields = $this->getAllCustomFields();
if (is_array($allCustomFields)) {
foreach ($this->customFields as $key => $value) {
$allCustomFields[$key] = $value;
}
}
//set
$this->setCustomFields($allCustomFields);
//clean old
$this->cleanCustomFields($this->getId());
//save new
$this->saveCustomFields();
}
} | php | public function afterUpdate()
{
//only clean and change custom fields if they are been sent
if (!empty($this->customFields)) {
//replace old custom with new
$allCustomFields = $this->getAllCustomFields();
if (is_array($allCustomFields)) {
foreach ($this->customFields as $key => $value) {
$allCustomFields[$key] = $value;
}
}
//set
$this->setCustomFields($allCustomFields);
//clean old
$this->cleanCustomFields($this->getId());
//save new
$this->saveCustomFields();
}
} | [
"public",
"function",
"afterUpdate",
"(",
")",
"{",
"//only clean and change custom fields if they are been sent",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"customFields",
")",
")",
"{",
"//replace old custom with new",
"$",
"allCustomFields",
"=",
"$",
"this"... | After the model was update we need to update its custom fields
@return void | [
"After",
"the",
"model",
"was",
"update",
"we",
"need",
"to",
"update",
"its",
"custom",
"fields"
] | b227de7c27e819abadf56cfd66ff08dab2797d62 | https://github.com/bakaphp/database/blob/b227de7c27e819abadf56cfd66ff08dab2797d62/src/ModelCustomFields.php#L298-L317 | train |
webeweb/core-library | src/Sorting/AlphabeticalTreeSort.php | AlphabeticalTreeSort.compare | protected function compare(AlphabeticalTreeNodeInterface $a, AlphabeticalTreeNodeInterface $b) {
// Get the paths.
$pathA = AlphabeticalTreeNodeHelper::getPath($a);
$pathB = AlphabeticalTreeNodeHelper::getPath($b);
// Count the path.
$count = count($pathA);
// Handle each path.
for ($i = 0; $i < $count; ++$i) {
// Get the items.
$itemA = $pathA[$i];
$itemB = true === isset($pathB[$i]) ? $pathB[$i] : null;
// Compare the items.
if ($itemA !== $itemB) {
return null !== $itemB ? strcasecmp($itemA->getAlphabeticalTreeNodeLabel(), $itemB->getAlphabeticalTreeNodeLabel()) : 1;
}
}
// Return.
return 0;
} | php | protected function compare(AlphabeticalTreeNodeInterface $a, AlphabeticalTreeNodeInterface $b) {
// Get the paths.
$pathA = AlphabeticalTreeNodeHelper::getPath($a);
$pathB = AlphabeticalTreeNodeHelper::getPath($b);
// Count the path.
$count = count($pathA);
// Handle each path.
for ($i = 0; $i < $count; ++$i) {
// Get the items.
$itemA = $pathA[$i];
$itemB = true === isset($pathB[$i]) ? $pathB[$i] : null;
// Compare the items.
if ($itemA !== $itemB) {
return null !== $itemB ? strcasecmp($itemA->getAlphabeticalTreeNodeLabel(), $itemB->getAlphabeticalTreeNodeLabel()) : 1;
}
}
// Return.
return 0;
} | [
"protected",
"function",
"compare",
"(",
"AlphabeticalTreeNodeInterface",
"$",
"a",
",",
"AlphabeticalTreeNodeInterface",
"$",
"b",
")",
"{",
"// Get the paths.",
"$",
"pathA",
"=",
"AlphabeticalTreeNodeHelper",
"::",
"getPath",
"(",
"$",
"a",
")",
";",
"$",
"path... | Compare two nodes.
@param AlphabeticalTreeNodeInterface $a The node A.
@param AlphabeticalTreeNodeInterface $b The node B.
@return int Returns
< O: if the node A is lesser than node B
> 0: if the node A is gerater than node B
= 0: if the two nodes are equals | [
"Compare",
"two",
"nodes",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Sorting/AlphabeticalTreeSort.php#L48-L72 | train |
ARCANEDEV/Notify | src/Storage/Session.php | Session.flash | public function flash($key, $value = true)
{
if (is_array($key))
$this->flashMany($key);
else
$this->session->flash($key, $value);
} | php | public function flash($key, $value = true)
{
if (is_array($key))
$this->flashMany($key);
else
$this->session->flash($key, $value);
} | [
"public",
"function",
"flash",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"true",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"key",
")",
")",
"$",
"this",
"->",
"flashMany",
"(",
"$",
"key",
")",
";",
"else",
"$",
"this",
"->",
"session",
"->",
"... | Flash a message to the session.
@param string|array $key
@param mixed $value | [
"Flash",
"a",
"message",
"to",
"the",
"session",
"."
] | 86fb23220637417e562b3c0fa1d53c4d1d97ad46 | https://github.com/ARCANEDEV/Notify/blob/86fb23220637417e562b3c0fa1d53c4d1d97ad46/src/Storage/Session.php#L52-L58 | train |
webeweb/core-library | src/Database/AbstractDatabase.php | AbstractDatabase.getConnection | public function getConnection() {
if (null === $this->connection) {
$this->connection = $this->connect();
}
return $this->connection;
} | php | public function getConnection() {
if (null === $this->connection) {
$this->connection = $this->connect();
}
return $this->connection;
} | [
"public",
"function",
"getConnection",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"connection",
")",
"{",
"$",
"this",
"->",
"connection",
"=",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"connectio... | Get the connection.
@return PDO Returns the connection.
@throws Exception Throws an exception if the connection failed. | [
"Get",
"the",
"connection",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Database/AbstractDatabase.php#L77-L82 | train |
webeweb/core-library | src/Database/AbstractDatabase.php | AbstractDatabase.prepareBinding | public function prepareBinding(array $fields) {
$output = [];
foreach ($fields as $current) {
$output[$current] = ":" . $current;
}
return $output;
} | php | public function prepareBinding(array $fields) {
$output = [];
foreach ($fields as $current) {
$output[$current] = ":" . $current;
}
return $output;
} | [
"public",
"function",
"prepareBinding",
"(",
"array",
"$",
"fields",
")",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"current",
")",
"{",
"$",
"output",
"[",
"$",
"current",
"]",
"=",
"\":\"",
".",
"$",
"curre... | Prepare a binding.
@param array $fields The fields.
@return array Returns the binding as key => :key. | [
"Prepare",
"a",
"binding",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Database/AbstractDatabase.php#L99-L105 | train |
webeweb/core-library | src/Database/AbstractDatabase.php | AbstractDatabase.prepareInsert | public function prepareInsert($table, array $values) {
// Initialize the query.
$query = [];
$query[] = "INSERT INTO ";
$query[] = $table;
$query[] = " (`";
$query[] = implode("`, `", array_keys($values));
$query[] = "`) VALUES (";
$query[] = implode(", ", array_values($values));
$query[] = ")";
// Return the query.
return implode("", $query);
} | php | public function prepareInsert($table, array $values) {
// Initialize the query.
$query = [];
$query[] = "INSERT INTO ";
$query[] = $table;
$query[] = " (`";
$query[] = implode("`, `", array_keys($values));
$query[] = "`) VALUES (";
$query[] = implode(", ", array_values($values));
$query[] = ")";
// Return the query.
return implode("", $query);
} | [
"public",
"function",
"prepareInsert",
"(",
"$",
"table",
",",
"array",
"$",
"values",
")",
"{",
"// Initialize the query.",
"$",
"query",
"=",
"[",
"]",
";",
"$",
"query",
"[",
"]",
"=",
"\"INSERT INTO \"",
";",
"$",
"query",
"[",
"]",
"=",
"$",
"tabl... | Prepare an INSERT SQL query.
@param string $table The table.
@param array $values The values [field => value].
@return string Returns the INSERT SQL query. | [
"Prepare",
"an",
"INSERT",
"SQL",
"query",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Database/AbstractDatabase.php#L114-L129 | train |
webeweb/core-library | src/Database/AbstractDatabase.php | AbstractDatabase.prepareUpdate | public function prepareUpdate($table, array $values) {
// Initialize the SET.
$set = [];
foreach ($values as $k => $v) {
$set[] = "`" . $k . "` = " . $v;
}
// Initialize the query.
$query = [];
$query[] = "UPDATE ";
$query[] = $table;
$query[] = " SET ";
$query[] = implode(", ", $set);
// Return the query.
return implode("", $query);
} | php | public function prepareUpdate($table, array $values) {
// Initialize the SET.
$set = [];
foreach ($values as $k => $v) {
$set[] = "`" . $k . "` = " . $v;
}
// Initialize the query.
$query = [];
$query[] = "UPDATE ";
$query[] = $table;
$query[] = " SET ";
$query[] = implode(", ", $set);
// Return the query.
return implode("", $query);
} | [
"public",
"function",
"prepareUpdate",
"(",
"$",
"table",
",",
"array",
"$",
"values",
")",
"{",
"// Initialize the SET.",
"$",
"set",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"set",
"[",
"]"... | Prepare an UPDATE SQL query.
@param string $table The table.
@param array $values The values [field => value]
@return string Returns the UPDATE SQL query. | [
"Prepare",
"an",
"UPDATE",
"SQL",
"query",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Database/AbstractDatabase.php#L138-L156 | train |
webeweb/core-library | src/ThirdParty/SkiData/Parser/UserParser.php | UserParser.parseEntity | public function parseEntity(User $entity) {
$output = [
$this->encodeInteger($entity->getUserNumber(), 9),
$this->encodeInteger($entity->getCustomerNumber(), 9),
$this->encodeString($entity->getTitle(), 10),
$this->encodeString($entity->getSurname(), 25),
$this->encodeString($entity->getFirstname(), 25),
$this->encodeDate($entity->getDateBirth()),
$this->encodeString($entity->getParkingSpace(), 5),
$this->encodeString($entity->getRemarks(), 50),
$this->encodeDateTime($entity->getDatetimeLastModification()),
$this->encodeBoolean($entity->getDeletedRecord()),
$this->encodeString($entity->getIdentificationNumber(), 20),
$this->encodeBoolean($entity->getCheckLicensePlate()),
$this->encodeBoolean($entity->getPassageLicensePlatePermitted()),
$this->encodeBoolean($entity->getExcessTimesCreditCard()),
$this->encodeString($entity->getCreditCardNumber(), 20),
$this->encodeDate($entity->getExpiryDate()),
$this->encodeString($entity->getRemarks2(), 50),
$this->encodeString($entity->getRemarks3(), 50),
$this->encodeString($entity->getDivision(), 50),
$this->encodeString($entity->getEmail(), 120),
$this->encodeBoolean($entity->getGroupCounting()),
$this->encodeInteger($entity->getETicketTypeP(), 1),
$this->encodeString($entity->getETicketEmailTelephone(), 120),
$this->encodeInteger($entity->getETicketAuthentication(), 1),
$this->encodeInteger($entity->getETicketServiceTyp(), 1),
$this->encodeInteger($entity->getETicketServiceArt(), 1),
];
return implode(";", $output);
} | php | public function parseEntity(User $entity) {
$output = [
$this->encodeInteger($entity->getUserNumber(), 9),
$this->encodeInteger($entity->getCustomerNumber(), 9),
$this->encodeString($entity->getTitle(), 10),
$this->encodeString($entity->getSurname(), 25),
$this->encodeString($entity->getFirstname(), 25),
$this->encodeDate($entity->getDateBirth()),
$this->encodeString($entity->getParkingSpace(), 5),
$this->encodeString($entity->getRemarks(), 50),
$this->encodeDateTime($entity->getDatetimeLastModification()),
$this->encodeBoolean($entity->getDeletedRecord()),
$this->encodeString($entity->getIdentificationNumber(), 20),
$this->encodeBoolean($entity->getCheckLicensePlate()),
$this->encodeBoolean($entity->getPassageLicensePlatePermitted()),
$this->encodeBoolean($entity->getExcessTimesCreditCard()),
$this->encodeString($entity->getCreditCardNumber(), 20),
$this->encodeDate($entity->getExpiryDate()),
$this->encodeString($entity->getRemarks2(), 50),
$this->encodeString($entity->getRemarks3(), 50),
$this->encodeString($entity->getDivision(), 50),
$this->encodeString($entity->getEmail(), 120),
$this->encodeBoolean($entity->getGroupCounting()),
$this->encodeInteger($entity->getETicketTypeP(), 1),
$this->encodeString($entity->getETicketEmailTelephone(), 120),
$this->encodeInteger($entity->getETicketAuthentication(), 1),
$this->encodeInteger($entity->getETicketServiceTyp(), 1),
$this->encodeInteger($entity->getETicketServiceArt(), 1),
];
return implode(";", $output);
} | [
"public",
"function",
"parseEntity",
"(",
"User",
"$",
"entity",
")",
"{",
"$",
"output",
"=",
"[",
"$",
"this",
"->",
"encodeInteger",
"(",
"$",
"entity",
"->",
"getUserNumber",
"(",
")",
",",
"9",
")",
",",
"$",
"this",
"->",
"encodeInteger",
"(",
... | Parse a user entity.
@param User $entity The user.
@return string Returns the parsed user.
@throws TooLongDataException Throws a too long data exception if a data is too long. | [
"Parse",
"a",
"user",
"entity",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/ThirdParty/SkiData/Parser/UserParser.php#L42-L74 | train |
orchestral/notifier | src/Events/CssInliner.php | CssInliner.handle | public function handle(MessageSending $sending): void
{
$message = $sending->message;
$converter = new CssToInlineStyles();
if ($message->getContentType() === 'text/html' ||
($message->getContentType() === 'multipart/alternative' && $message->getBody())
) {
$message->setBody($converter->convert($message->getBody()));
}
foreach ($message->getChildren() as $part) {
if (Str::contains($part->getContentType(), 'text/html')) {
$part->setBody($converter->convert($part->getBody()));
}
}
} | php | public function handle(MessageSending $sending): void
{
$message = $sending->message;
$converter = new CssToInlineStyles();
if ($message->getContentType() === 'text/html' ||
($message->getContentType() === 'multipart/alternative' && $message->getBody())
) {
$message->setBody($converter->convert($message->getBody()));
}
foreach ($message->getChildren() as $part) {
if (Str::contains($part->getContentType(), 'text/html')) {
$part->setBody($converter->convert($part->getBody()));
}
}
} | [
"public",
"function",
"handle",
"(",
"MessageSending",
"$",
"sending",
")",
":",
"void",
"{",
"$",
"message",
"=",
"$",
"sending",
"->",
"message",
";",
"$",
"converter",
"=",
"new",
"CssToInlineStyles",
"(",
")",
";",
"if",
"(",
"$",
"message",
"->",
... | Handle converting to inline CSS.
@param \Illuminate\Mail\Events\MessageSending $sending
@return void | [
"Handle",
"converting",
"to",
"inline",
"CSS",
"."
] | a0036f924c51ead67f3e339cd2688163876f3b59 | https://github.com/orchestral/notifier/blob/a0036f924c51ead67f3e339cd2688163876f3b59/src/Events/CssInliner.php#L18-L35 | train |
liues1992/php-protobuf-generator | src/Gary/Protobuf/Generator/CodeStringBuffer.php | CodeStringBuffer.append | public function append($lines, $newline = true, $indentOffset = 0)
{
$this->_buffer[] = trim($lines) ? ($this->_getIndentationString($indentOffset) . $lines) : $lines;
if ($newline) {
$this->_buffer[] = $this->newLineStr;
}
return $this;
} | php | public function append($lines, $newline = true, $indentOffset = 0)
{
$this->_buffer[] = trim($lines) ? ($this->_getIndentationString($indentOffset) . $lines) : $lines;
if ($newline) {
$this->_buffer[] = $this->newLineStr;
}
return $this;
} | [
"public",
"function",
"append",
"(",
"$",
"lines",
",",
"$",
"newline",
"=",
"true",
",",
"$",
"indentOffset",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"_buffer",
"[",
"]",
"=",
"trim",
"(",
"$",
"lines",
")",
"?",
"(",
"$",
"this",
"->",
"_getInde... | Appends lines to buffer
@param string $lines Lines to append
@param bool $newline Add extra newline after lines
@param int $indentOffset Extra indent code
@return CodeStringBuffer | [
"Appends",
"lines",
"to",
"buffer"
] | 0bae264906b9e8fd989784e482e09bd0aa649991 | https://github.com/liues1992/php-protobuf-generator/blob/0bae264906b9e8fd989784e482e09bd0aa649991/src/Gary/Protobuf/Generator/CodeStringBuffer.php#L47-L55 | train |
shopgate/cart-integration-magento2-base | src/Helper/Product/Type.php | Type.getType | public function getType($item)
{
switch ($this->getProductType($item)) {
case Bundle::TYPE_CODE:
return $this->bundle->create()->setItem($item);
case Grouped::TYPE_CODE:
return $this->grouped->create()->setItem($item);
case Configurable::TYPE_CODE:
return $this->configurable->create()->setItem($item);
default:
return $this->generic->create()->setItem($item);
}
} | php | public function getType($item)
{
switch ($this->getProductType($item)) {
case Bundle::TYPE_CODE:
return $this->bundle->create()->setItem($item);
case Grouped::TYPE_CODE:
return $this->grouped->create()->setItem($item);
case Configurable::TYPE_CODE:
return $this->configurable->create()->setItem($item);
default:
return $this->generic->create()->setItem($item);
}
} | [
"public",
"function",
"getType",
"(",
"$",
"item",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"getProductType",
"(",
"$",
"item",
")",
")",
"{",
"case",
"Bundle",
"::",
"TYPE_CODE",
":",
"return",
"$",
"this",
"->",
"bundle",
"->",
"create",
"(",
")... | Retrieves the correct type of product helper
based on passed item object
@param OrderItem | Product | QuoteItem $item
@return Type\Bundle | Type\Generic | Type\Grouped | Type\Configurable
@throws \Exception | [
"Retrieves",
"the",
"correct",
"type",
"of",
"product",
"helper",
"based",
"on",
"passed",
"item",
"object"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Product/Type.php#L70-L82 | train |
hypeJunction/hypeApps | classes/hypeJunction/Files/Upload.php | Upload.save | public function save(array $attributes = array(), $prefix = self::DEFAULT_FILESTORE_PREFIX) {
$this->error_code = $this->error;
$this->error = $this->getError();
$this->filesize = $this->size;
$this->path = $this->tmp_name;
$this->mimetype = $this->detectMimeType();
$this->simpletype = $this->parseSimpleType();
if (!$this->isSuccessful()) {
return $this;
}
$prefix = trim($prefix, '/');
if (!$prefix) {
$prefix = self::DEFAULT_FILESTORE_PREFIX;
}
$id = elgg_strtolower(time() . $this->name);
$filename = implode('/', array($prefix, $id));
$type = elgg_extract('type', $attributes, 'object');
$subtype = elgg_extract('subtype', $attributes, 'file');
$class = get_subtype_class($type, $subtype);
if (!$class) {
$class = '\\ElggFile';
}
try {
$filehandler = new $class();
foreach ($attributes as $key => $value) {
$filehandler->$key = $value;
}
$filehandler->setFilename($filename);
$filehandler->title = $this->name;
$filehandler->originalfilename = $this->name;
$filehandler->filesize = $this->size;
$filehandler->mimetype = $this->mimetype;
$filehandler->simpletype = $this->simpletype;
$filehandler->open("write");
$filehandler->close();
if ($this->simpletype == 'image') {
$img = new \hypeJunction\Files\Image($this->tmp_name);
$img->save($filehandler->getFilenameOnFilestore(), hypeApps()->config->getSrcCompressionOpts());
} else {
move_uploaded_file($this->tmp_name, $filehandler->getFilenameOnFilestore());
}
if ($filehandler->save()) {
$this->guid = $filehandler->getGUID();
$this->file = $filehandler;
}
} catch (\Exception $ex) {
elgg_log($ex->getMessage(), 'ERROR');
$this->error = elgg_echo('upload:error:unknown');
}
return $this;
} | php | public function save(array $attributes = array(), $prefix = self::DEFAULT_FILESTORE_PREFIX) {
$this->error_code = $this->error;
$this->error = $this->getError();
$this->filesize = $this->size;
$this->path = $this->tmp_name;
$this->mimetype = $this->detectMimeType();
$this->simpletype = $this->parseSimpleType();
if (!$this->isSuccessful()) {
return $this;
}
$prefix = trim($prefix, '/');
if (!$prefix) {
$prefix = self::DEFAULT_FILESTORE_PREFIX;
}
$id = elgg_strtolower(time() . $this->name);
$filename = implode('/', array($prefix, $id));
$type = elgg_extract('type', $attributes, 'object');
$subtype = elgg_extract('subtype', $attributes, 'file');
$class = get_subtype_class($type, $subtype);
if (!$class) {
$class = '\\ElggFile';
}
try {
$filehandler = new $class();
foreach ($attributes as $key => $value) {
$filehandler->$key = $value;
}
$filehandler->setFilename($filename);
$filehandler->title = $this->name;
$filehandler->originalfilename = $this->name;
$filehandler->filesize = $this->size;
$filehandler->mimetype = $this->mimetype;
$filehandler->simpletype = $this->simpletype;
$filehandler->open("write");
$filehandler->close();
if ($this->simpletype == 'image') {
$img = new \hypeJunction\Files\Image($this->tmp_name);
$img->save($filehandler->getFilenameOnFilestore(), hypeApps()->config->getSrcCompressionOpts());
} else {
move_uploaded_file($this->tmp_name, $filehandler->getFilenameOnFilestore());
}
if ($filehandler->save()) {
$this->guid = $filehandler->getGUID();
$this->file = $filehandler;
}
} catch (\Exception $ex) {
elgg_log($ex->getMessage(), 'ERROR');
$this->error = elgg_echo('upload:error:unknown');
}
return $this;
} | [
"public",
"function",
"save",
"(",
"array",
"$",
"attributes",
"=",
"array",
"(",
")",
",",
"$",
"prefix",
"=",
"self",
"::",
"DEFAULT_FILESTORE_PREFIX",
")",
"{",
"$",
"this",
"->",
"error_code",
"=",
"$",
"this",
"->",
"error",
";",
"$",
"this",
"->"... | Saves uploaded file to ElggFile with given attributes
@param array $attributes New file attributes and metadata
@apara string $prefix Filestore prefix
@return \Upload | [
"Saves",
"uploaded",
"file",
"to",
"ElggFile",
"with",
"given",
"attributes"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Files/Upload.php#L43-L105 | train |
hypeJunction/hypeApps | classes/hypeJunction/Files/Upload.php | Upload.getError | public function getError() {
switch ($this->error_code) {
case UPLOAD_ERR_OK:
return false;
case UPLOAD_ERR_NO_FILE:
$error = 'upload:error:no_file';
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
$error = 'upload:error:file_size';
default:
$error = 'upload:error:unknown';
}
return elgg_echo($error);
} | php | public function getError() {
switch ($this->error_code) {
case UPLOAD_ERR_OK:
return false;
case UPLOAD_ERR_NO_FILE:
$error = 'upload:error:no_file';
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
$error = 'upload:error:file_size';
default:
$error = 'upload:error:unknown';
}
return elgg_echo($error);
} | [
"public",
"function",
"getError",
"(",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"error_code",
")",
"{",
"case",
"UPLOAD_ERR_OK",
":",
"return",
"false",
";",
"case",
"UPLOAD_ERR_NO_FILE",
":",
"$",
"error",
"=",
"'upload:error:no_file'",
";",
"case",
"UPL... | Get human readable upload error
@return string|boolean | [
"Get",
"human",
"readable",
"upload",
"error"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Files/Upload.php#L119-L132 | train |
hypeJunction/hypeApps | classes/hypeJunction/Files/Upload.php | Upload.parseSimpleType | public function parseSimpleType() {
if (is_callable('elgg_get_file_simple_type')) {
return elgg_get_file_simple_type($this->detectMimeType());
}
$mime_type = $this->detectMimeType();
switch ($mime_type) {
case "application/msword":
case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
case "application/pdf":
return "document";
case "application/ogg":
return "audio";
}
if (preg_match('~^(audio|image|video)/~', $mime_type, $m)) {
return $m[1];
}
if (0 === strpos($mime_type, 'text/') || false !== strpos($mime_type, 'opendocument')) {
return "document";
}
// unrecognized MIME
return "general";
} | php | public function parseSimpleType() {
if (is_callable('elgg_get_file_simple_type')) {
return elgg_get_file_simple_type($this->detectMimeType());
}
$mime_type = $this->detectMimeType();
switch ($mime_type) {
case "application/msword":
case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
case "application/pdf":
return "document";
case "application/ogg":
return "audio";
}
if (preg_match('~^(audio|image|video)/~', $mime_type, $m)) {
return $m[1];
}
if (0 === strpos($mime_type, 'text/') || false !== strpos($mime_type, 'opendocument')) {
return "document";
}
// unrecognized MIME
return "general";
} | [
"public",
"function",
"parseSimpleType",
"(",
")",
"{",
"if",
"(",
"is_callable",
"(",
"'elgg_get_file_simple_type'",
")",
")",
"{",
"return",
"elgg_get_file_simple_type",
"(",
"$",
"this",
"->",
"detectMimeType",
"(",
")",
")",
";",
"}",
"$",
"mime_type",
"="... | Parses simple type of the upload
@return string | [
"Parses",
"simple",
"type",
"of",
"the",
"upload"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Files/Upload.php#L146-L172 | train |
nabu-3/provider-mysql-driver | CMySQLSyntaxBuilder.php | CMySQLSyntaxBuilder.describeStorage | public function describeStorage($name, $schema = false)
{
if (!$schema) {
$schema = $this->connector->getSchema();
}
return $this->describeTable($name, $schema);
} | php | public function describeStorage($name, $schema = false)
{
if (!$schema) {
$schema = $this->connector->getSchema();
}
return $this->describeTable($name, $schema);
} | [
"public",
"function",
"describeStorage",
"(",
"$",
"name",
",",
"$",
"schema",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"schema",
")",
"{",
"$",
"schema",
"=",
"$",
"this",
"->",
"connector",
"->",
"getSchema",
"(",
")",
";",
"}",
"return",
"$"... | Creates the descriptor from an existent MySQL storage.
@param string $name Table name.
@param string $schema Table schema.
@return CMySQLDescriptor Returns a descriptor instance. | [
"Creates",
"the",
"descriptor",
"from",
"an",
"existent",
"MySQL",
"storage",
"."
] | 85fc8ff326819c3970c933fc65a1e298f92fb017 | https://github.com/nabu-3/provider-mysql-driver/blob/85fc8ff326819c3970c933fc65a1e298f92fb017/CMySQLSyntaxBuilder.php#L61-L68 | train |
nabu-3/provider-mysql-driver | CMySQLSyntaxBuilder.php | CMySQLSyntaxBuilder.describeTable | private function describeTable($name, $schema)
{
$data = $this->connector->getQueryAsSingleRow(
'SELECT t.table_schema AS table_schema, t.table_name AS table_name, t.engine AS engine,
t.auto_increment AS auto_increment, t.table_collation AS table_collation,
t.table_comment AS table_comment, cs.character_set_name AS table_charset,
t.create_options AS create_options
FROM information_schema.tables t, information_schema.character_sets cs
WHERE t.table_schema=\'%schema$s\'
AND t.table_name = \'%table$s\'
AND t.table_collation = cs.default_collate_name',
array(
'schema' => $schema,
'table' => $name
)
);
if (is_array($data)) {
$fields = $this->describeTableFields($name, $schema);
$table['schema'] = $data['table_schema'];
$table['name'] = $data['table_name'];
$table['engine'] = $data['engine'];
$table['type'] = CMySQLConnector::TYPE_TABLE;
$table['autoincrement'] = $this->validateAutoIncrement($data['auto_increment'], $fields);
$table['charset'] = $data['table_charset'];
$table['collation'] = $data['table_collation'];
$table['create_options'] = $data['create_options'];
$table['comment'] = $data['table_comment'];
$table['fields'] = $fields;
$table['constraints'] = $this->describeTableConstraints($name, $table['fields'], $schema);
$descriptor = new CMySQLDescriptor($this->connector, $table);
} else {
$descriptor = null;
}
return $descriptor;
} | php | private function describeTable($name, $schema)
{
$data = $this->connector->getQueryAsSingleRow(
'SELECT t.table_schema AS table_schema, t.table_name AS table_name, t.engine AS engine,
t.auto_increment AS auto_increment, t.table_collation AS table_collation,
t.table_comment AS table_comment, cs.character_set_name AS table_charset,
t.create_options AS create_options
FROM information_schema.tables t, information_schema.character_sets cs
WHERE t.table_schema=\'%schema$s\'
AND t.table_name = \'%table$s\'
AND t.table_collation = cs.default_collate_name',
array(
'schema' => $schema,
'table' => $name
)
);
if (is_array($data)) {
$fields = $this->describeTableFields($name, $schema);
$table['schema'] = $data['table_schema'];
$table['name'] = $data['table_name'];
$table['engine'] = $data['engine'];
$table['type'] = CMySQLConnector::TYPE_TABLE;
$table['autoincrement'] = $this->validateAutoIncrement($data['auto_increment'], $fields);
$table['charset'] = $data['table_charset'];
$table['collation'] = $data['table_collation'];
$table['create_options'] = $data['create_options'];
$table['comment'] = $data['table_comment'];
$table['fields'] = $fields;
$table['constraints'] = $this->describeTableConstraints($name, $table['fields'], $schema);
$descriptor = new CMySQLDescriptor($this->connector, $table);
} else {
$descriptor = null;
}
return $descriptor;
} | [
"private",
"function",
"describeTable",
"(",
"$",
"name",
",",
"$",
"schema",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"connector",
"->",
"getQueryAsSingleRow",
"(",
"'SELECT t.table_schema AS table_schema, t.table_name AS table_name, t.engine AS engine,\n ... | Creates the descriptor from an existent MySQL table.
@param string $name Table name.
@param string $schema Table schema.
@return CMySQLDescriptor Returns a descriptor instance or null if no descriptor available. | [
"Creates",
"the",
"descriptor",
"from",
"an",
"existent",
"MySQL",
"table",
"."
] | 85fc8ff326819c3970c933fc65a1e298f92fb017 | https://github.com/nabu-3/provider-mysql-driver/blob/85fc8ff326819c3970c933fc65a1e298f92fb017/CMySQLSyntaxBuilder.php#L76-L112 | train |
webeweb/core-library | src/Argument/ObjectHelper.php | ObjectHelper.getHooks | public static function getHooks($classpath, $namespace, $classname = null, $extends = null, $method = null) {
//
$hooks = [];
// Get the filenames.
$filenames = FileHelper::getFileNames($classpath, ".php");
// Handle each filenames.
foreach ($filenames as $filename) {
// Check the class name.
if (null !== $classname && 0 === preg_match($classname, $filename)) {
continue;
}
// Import the class.
try {
require_once $classpath . "/" . $filename;
} catch (Error $ex) {
throw new SyntaxErrorException($classpath . "/" . $filename);
}
// Init. the complete class name.
$completeClassname = $namespace . basename($filename, ".php");
try {
$rc = new ReflectionClass($completeClassname);
} catch (Exception $ex) {
throw new ClassNotFoundException($completeClassname, $ex);
}
// Check the extends.
if (false === (null === $extends || true === $rc->isSubclassOf($extends))) {
continue;
}
// Initialize the hook.
$hook = [];
$hook["classpath"] = $classpath;
$hook["namespace"] = $namespace;
$hook["filename"] = $filename;
$hook["class"] = $rc;
$hook["method"] = null;
$hooks[] = $hook;
// Check the method.
if (null === $method) {
continue;
}
try {
$rm = $rc->getMethod($method);
$hooks[count($hooks) - 1]["method"] = $rm;
} catch (ReflectionException $ex) {
throw new MethodNotFoundException($method, $ex);
}
}
// Returns the hooks.
return $hooks;
} | php | public static function getHooks($classpath, $namespace, $classname = null, $extends = null, $method = null) {
//
$hooks = [];
// Get the filenames.
$filenames = FileHelper::getFileNames($classpath, ".php");
// Handle each filenames.
foreach ($filenames as $filename) {
// Check the class name.
if (null !== $classname && 0 === preg_match($classname, $filename)) {
continue;
}
// Import the class.
try {
require_once $classpath . "/" . $filename;
} catch (Error $ex) {
throw new SyntaxErrorException($classpath . "/" . $filename);
}
// Init. the complete class name.
$completeClassname = $namespace . basename($filename, ".php");
try {
$rc = new ReflectionClass($completeClassname);
} catch (Exception $ex) {
throw new ClassNotFoundException($completeClassname, $ex);
}
// Check the extends.
if (false === (null === $extends || true === $rc->isSubclassOf($extends))) {
continue;
}
// Initialize the hook.
$hook = [];
$hook["classpath"] = $classpath;
$hook["namespace"] = $namespace;
$hook["filename"] = $filename;
$hook["class"] = $rc;
$hook["method"] = null;
$hooks[] = $hook;
// Check the method.
if (null === $method) {
continue;
}
try {
$rm = $rc->getMethod($method);
$hooks[count($hooks) - 1]["method"] = $rm;
} catch (ReflectionException $ex) {
throw new MethodNotFoundException($method, $ex);
}
}
// Returns the hooks.
return $hooks;
} | [
"public",
"static",
"function",
"getHooks",
"(",
"$",
"classpath",
",",
"$",
"namespace",
",",
"$",
"classname",
"=",
"null",
",",
"$",
"extends",
"=",
"null",
",",
"$",
"method",
"=",
"null",
")",
"{",
"//",
"$",
"hooks",
"=",
"[",
"]",
";",
"// G... | Get the hooks.
@param string $classpath The class path.
@param string $namespace The namespace.
@param string $classname The class name.
@param string $extends The class extend.
@param string $method The class method.
@return array Returns the hooks array.
@throws ClassNotFoundException Throws a hook class not found if the classname is not found. | [
"Get",
"the",
"hooks",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Argument/ObjectHelper.php#L54-L118 | train |
webeweb/core-library | src/Argument/ObjectHelper.php | ObjectHelper.urlEncodeShortName | public static function urlEncodeShortName($object) {
$classname = static::getShortName($object);
$explode = preg_replace("/([a-z]{1})([A-Z]{1})/", "$1-$2", $classname);
return strtolower($explode);
} | php | public static function urlEncodeShortName($object) {
$classname = static::getShortName($object);
$explode = preg_replace("/([a-z]{1})([A-Z]{1})/", "$1-$2", $classname);
return strtolower($explode);
} | [
"public",
"static",
"function",
"urlEncodeShortName",
"(",
"$",
"object",
")",
"{",
"$",
"classname",
"=",
"static",
"::",
"getShortName",
"(",
"$",
"object",
")",
";",
"$",
"explode",
"=",
"preg_replace",
"(",
"\"/([a-z]{1})([A-Z]{1})/\"",
",",
"\"$1-$2\"",
"... | URL encode a short name.
@param mixed $object The object.
@return string Returns the URL encoded short name.
@throws ReflectionException Throws a Reflection exception if an error occurs. | [
"URL",
"encode",
"a",
"short",
"name",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Argument/ObjectHelper.php#L174-L178 | train |
contextio/PHP-ContextIO | src/ContextIO/ContextIORequest.php | ContextIORequest.put | public function put($account, $action, $parameters = null, $httpHeadersToSet = array())
{
return $this->sendRequest('PUT', $account, $action, $parameters, null, null, $httpHeadersToSet);
} | php | public function put($account, $action, $parameters = null, $httpHeadersToSet = array())
{
return $this->sendRequest('PUT', $account, $action, $parameters, null, null, $httpHeadersToSet);
} | [
"public",
"function",
"put",
"(",
"$",
"account",
",",
"$",
"action",
",",
"$",
"parameters",
"=",
"null",
",",
"$",
"httpHeadersToSet",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'PUT'",
",",
"$",
"account",
... | Sends a PUT HTTP request.
@param string $account
@param string $action
@param null $parameters
@param array $httpHeadersToSet
@return bool|ContextIOResponse | [
"Sends",
"a",
"PUT",
"HTTP",
"request",
"."
] | 037e7c52683def87e639030d11c49da83f5c07dc | https://github.com/contextio/PHP-ContextIO/blob/037e7c52683def87e639030d11c49da83f5c07dc/src/ContextIO/ContextIORequest.php#L68-L71 | train |
contextio/PHP-ContextIO | src/ContextIO/ContextIORequest.php | ContextIORequest.delete | public function delete($account, $action = '', $parameters = null)
{
return $this->sendRequest('DELETE', $account, $action, $parameters);
} | php | public function delete($account, $action = '', $parameters = null)
{
return $this->sendRequest('DELETE', $account, $action, $parameters);
} | [
"public",
"function",
"delete",
"(",
"$",
"account",
",",
"$",
"action",
"=",
"''",
",",
"$",
"parameters",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'DELETE'",
",",
"$",
"account",
",",
"$",
"action",
",",
"$",
"parame... | Sends a DELETE HTTP request.
@param string $account
@param string $action
@param null $parameters
@return bool|ContextIOResponse | [
"Sends",
"a",
"DELETE",
"HTTP",
"request",
"."
] | 037e7c52683def87e639030d11c49da83f5c07dc | https://github.com/contextio/PHP-ContextIO/blob/037e7c52683def87e639030d11c49da83f5c07dc/src/ContextIO/ContextIORequest.php#L98-L101 | train |
webeweb/core-library | src/Database/PaginateHelper.php | PaginateHelper.getPageOffsetAndLimit | public static function getPageOffsetAndLimit($pageNumber, $divider, $total = -1) {
if ($pageNumber < 0 || $divider < 0) {
return -1;
}
$offset = $pageNumber * $divider;
$limit = $divider;
if (0 <= $total && ($total < $offset || $total < ($offset + $limit))) {
$offset = (static::getPagesCount($total, $divider) - 1) * $divider;
$limit = $total - $offset;
}
return [$offset, $limit];
} | php | public static function getPageOffsetAndLimit($pageNumber, $divider, $total = -1) {
if ($pageNumber < 0 || $divider < 0) {
return -1;
}
$offset = $pageNumber * $divider;
$limit = $divider;
if (0 <= $total && ($total < $offset || $total < ($offset + $limit))) {
$offset = (static::getPagesCount($total, $divider) - 1) * $divider;
$limit = $total - $offset;
}
return [$offset, $limit];
} | [
"public",
"static",
"function",
"getPageOffsetAndLimit",
"(",
"$",
"pageNumber",
",",
"$",
"divider",
",",
"$",
"total",
"=",
"-",
"1",
")",
"{",
"if",
"(",
"$",
"pageNumber",
"<",
"0",
"||",
"$",
"divider",
"<",
"0",
")",
"{",
"return",
"-",
"1",
... | Get a page offset and limit.
@param int $pageNumber The page number.
@param int $divider The divider.
@param int $total The total.
@return int[] Returns the page offset and limit in case of success, -1 otherwise. | [
"Get",
"a",
"page",
"offset",
"and",
"limit",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Database/PaginateHelper.php#L30-L41 | train |
webeweb/core-library | src/Database/PaginateHelper.php | PaginateHelper.getPagesCount | public static function getPagesCount($linesNumber, $divider) {
if ($linesNumber < 0 || $divider < 0) {
return -1;
}
$pagesCount = intval($linesNumber / $divider);
if (0 < ($linesNumber % $divider)) {
++$pagesCount;
}
return $pagesCount;
} | php | public static function getPagesCount($linesNumber, $divider) {
if ($linesNumber < 0 || $divider < 0) {
return -1;
}
$pagesCount = intval($linesNumber / $divider);
if (0 < ($linesNumber % $divider)) {
++$pagesCount;
}
return $pagesCount;
} | [
"public",
"static",
"function",
"getPagesCount",
"(",
"$",
"linesNumber",
",",
"$",
"divider",
")",
"{",
"if",
"(",
"$",
"linesNumber",
"<",
"0",
"||",
"$",
"divider",
"<",
"0",
")",
"{",
"return",
"-",
"1",
";",
"}",
"$",
"pagesCount",
"=",
"intval"... | Get a pages count.
@param int $linesNumber The lines number.
@param int $divider The divider.
@return int Returns the pages count in case of success, -1 otherwise. | [
"Get",
"a",
"pages",
"count",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Database/PaginateHelper.php#L50-L59 | train |
shopgate/cart-integration-magento2-base | src/Model/Shopgate/OrderRepository.php | OrderRepository.createAndSave | public function createAndSave($mageOrderId)
{
$order = $this->orderFactory->create()
->setOrderId($mageOrderId)
->setStoreId($this->config->getStoreViewId())
->setShopgateOrderNumber($this->sgOrder->getOrderNumber())
->setIsShippingBlocked($this->sgOrder->getIsShippingBlocked())
->setIsPaid($this->sgOrder->getIsPaid())
->setIsTest($this->sgOrder->getIsTest())
->setIsCustomerInvoiceBlocked($this->sgOrder->getIsCustomerInvoiceBlocked());
try {
$order->setReceivedData(\Zend_Json_Encoder::encode($this->sgOrder->toArray()));
} catch (\InvalidArgumentException $exception) {
$this->sgLogger->error($exception->getMessage());
}
$order->save();
} | php | public function createAndSave($mageOrderId)
{
$order = $this->orderFactory->create()
->setOrderId($mageOrderId)
->setStoreId($this->config->getStoreViewId())
->setShopgateOrderNumber($this->sgOrder->getOrderNumber())
->setIsShippingBlocked($this->sgOrder->getIsShippingBlocked())
->setIsPaid($this->sgOrder->getIsPaid())
->setIsTest($this->sgOrder->getIsTest())
->setIsCustomerInvoiceBlocked($this->sgOrder->getIsCustomerInvoiceBlocked());
try {
$order->setReceivedData(\Zend_Json_Encoder::encode($this->sgOrder->toArray()));
} catch (\InvalidArgumentException $exception) {
$this->sgLogger->error($exception->getMessage());
}
$order->save();
} | [
"public",
"function",
"createAndSave",
"(",
"$",
"mageOrderId",
")",
"{",
"$",
"order",
"=",
"$",
"this",
"->",
"orderFactory",
"->",
"create",
"(",
")",
"->",
"setOrderId",
"(",
"$",
"mageOrderId",
")",
"->",
"setStoreId",
"(",
"$",
"this",
"->",
"confi... | Requires magento object & Base order to be loaded globally
@param string $mageOrderId
@throws \Exception | [
"Requires",
"magento",
"object",
"&",
"Base",
"order",
"to",
"be",
"loaded",
"globally"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Shopgate/OrderRepository.php#L74-L91 | train |
shopgate/cart-integration-magento2-base | src/Model/Shopgate/OrderRepository.php | OrderRepository.update | public function update(Order $order)
{
if ($this->sgOrder->getUpdatePayment()) {
$order->setIsPaid($this->sgOrder->getIsPaid());
}
if ($this->sgOrder->getUpdateShipping()) {
$order->setIsShippingBlocked($this->sgOrder->getIsShippingBlocked());
}
} | php | public function update(Order $order)
{
if ($this->sgOrder->getUpdatePayment()) {
$order->setIsPaid($this->sgOrder->getIsPaid());
}
if ($this->sgOrder->getUpdateShipping()) {
$order->setIsShippingBlocked($this->sgOrder->getIsShippingBlocked());
}
} | [
"public",
"function",
"update",
"(",
"Order",
"$",
"order",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sgOrder",
"->",
"getUpdatePayment",
"(",
")",
")",
"{",
"$",
"order",
"->",
"setIsPaid",
"(",
"$",
"this",
"->",
"sgOrder",
"->",
"getIsPaid",
"(",
"... | Updates isPaid and isShippingBlocked settings
using the loaded SG Base class
@param Order $order | [
"Updates",
"isPaid",
"and",
"isShippingBlocked",
"settings",
"using",
"the",
"loaded",
"SG",
"Base",
"class"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Shopgate/OrderRepository.php#L99-L108 | train |
gbksoft/yii2-swagger | controllers/DefaultController.php | DefaultController.actionJson | public function actionJson()
{
/** @var \yii\web\Response */
$response = \Yii::$app->getResponse();
if (!is_readable($this->module->swaggerPath)) {
throw new NotFoundHttpException();
}
// Read source json file
$json = file_get_contents($this->module->swaggerPath);
// Do replacements
if (is_array($this->module->swaggerReplace)) {
foreach ($this->module->swaggerReplace as $find => $replace) {
if (is_callable($replace)) {
$replaceText = call_user_func($replace);
} else {
$replaceText = (string) $replace;
}
$json = mb_ereg_replace((string)$find, $replaceText, $json);
}
}
// Override default response formatters
// To avvoid json format modification
$response->format = Response::FORMAT_RAW;
$response->getHeaders()->set('Content-Type', 'application/json; charset=UTF-8');
// Trigger events
$event = new BeforeJsonEvent;
$event->responseText = $json;
$this->module->trigger(self::EVENT_BEFORE_JSON, $event);
return $event->responseText;
} | php | public function actionJson()
{
/** @var \yii\web\Response */
$response = \Yii::$app->getResponse();
if (!is_readable($this->module->swaggerPath)) {
throw new NotFoundHttpException();
}
// Read source json file
$json = file_get_contents($this->module->swaggerPath);
// Do replacements
if (is_array($this->module->swaggerReplace)) {
foreach ($this->module->swaggerReplace as $find => $replace) {
if (is_callable($replace)) {
$replaceText = call_user_func($replace);
} else {
$replaceText = (string) $replace;
}
$json = mb_ereg_replace((string)$find, $replaceText, $json);
}
}
// Override default response formatters
// To avvoid json format modification
$response->format = Response::FORMAT_RAW;
$response->getHeaders()->set('Content-Type', 'application/json; charset=UTF-8');
// Trigger events
$event = new BeforeJsonEvent;
$event->responseText = $json;
$this->module->trigger(self::EVENT_BEFORE_JSON, $event);
return $event->responseText;
} | [
"public",
"function",
"actionJson",
"(",
")",
"{",
"/** @var \\yii\\web\\Response */",
"$",
"response",
"=",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"getResponse",
"(",
")",
";",
"if",
"(",
"!",
"is_readable",
"(",
"$",
"this",
"->",
"module",
"->",
"swaggerP... | Parse swagger.json file, do replacements and return json
@return string
@throws NotFoundHttpException | [
"Parse",
"swagger",
".",
"json",
"file",
"do",
"replacements",
"and",
"return",
"json"
] | 9d7e061ef3275582bcc5ee541686ae4a836891fd | https://github.com/gbksoft/yii2-swagger/blob/9d7e061ef3275582bcc5ee541686ae4a836891fd/controllers/DefaultController.php#L148-L183 | train |
webeweb/core-library | src/Sorting/AlphabeticalTreeNodeHelper.php | AlphabeticalTreeNodeHelper.createChoices | public static function createChoices(array $choices) {
// Initialize the output.
$output = [];
// Sort the nodes.
$sorter = new AlphabeticalTreeSort($choices);
$sorter->sort();
// Handle each node.
foreach ($sorter->getNodes() as $current) {
// Get and check the path.
$path = static::getPath($current);
if (false === array_key_exists($path[0]->getAlphabeticalTreeNodeLabel(), $output)) {
$output[$current->getAlphabeticalTreeNodeLabel()] = [];
}
if (1 === count($path)) {
continue;
}
// Add the node.
$output[$path[0]->getAlphabeticalTreeNodeLabel()][] = $current;
}
// Return the output.
return $output;
} | php | public static function createChoices(array $choices) {
// Initialize the output.
$output = [];
// Sort the nodes.
$sorter = new AlphabeticalTreeSort($choices);
$sorter->sort();
// Handle each node.
foreach ($sorter->getNodes() as $current) {
// Get and check the path.
$path = static::getPath($current);
if (false === array_key_exists($path[0]->getAlphabeticalTreeNodeLabel(), $output)) {
$output[$current->getAlphabeticalTreeNodeLabel()] = [];
}
if (1 === count($path)) {
continue;
}
// Add the node.
$output[$path[0]->getAlphabeticalTreeNodeLabel()][] = $current;
}
// Return the output.
return $output;
} | [
"public",
"static",
"function",
"createChoices",
"(",
"array",
"$",
"choices",
")",
"{",
"// Initialize the output.",
"$",
"output",
"=",
"[",
"]",
";",
"// Sort the nodes.",
"$",
"sorter",
"=",
"new",
"AlphabeticalTreeSort",
"(",
"$",
"choices",
")",
";",
"$"... | Create a choices.
@param AlphabeticalTreeNodeInterface[] $choices The choices.
@return array Returns the choices. | [
"Create",
"a",
"choices",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Sorting/AlphabeticalTreeNodeHelper.php#L28-L55 | train |
webeweb/core-library | src/Sorting/AlphabeticalTreeNodeHelper.php | AlphabeticalTreeNodeHelper.removeOrphan | public static function removeOrphan(array &$nodes = []) {
do {
$found = false;
foreach ($nodes as $k => $v) {
if (false === ($v instanceof AlphabeticalTreeNodeInterface) || null === $v->getAlphabeticalTreeNodeParent() || true === in_array($v->getAlphabeticalTreeNodeParent(), $nodes)) {
continue;
}
unset($nodes[$k]);
$found = true;
}
} while (true === $found);
} | php | public static function removeOrphan(array &$nodes = []) {
do {
$found = false;
foreach ($nodes as $k => $v) {
if (false === ($v instanceof AlphabeticalTreeNodeInterface) || null === $v->getAlphabeticalTreeNodeParent() || true === in_array($v->getAlphabeticalTreeNodeParent(), $nodes)) {
continue;
}
unset($nodes[$k]);
$found = true;
}
} while (true === $found);
} | [
"public",
"static",
"function",
"removeOrphan",
"(",
"array",
"&",
"$",
"nodes",
"=",
"[",
"]",
")",
"{",
"do",
"{",
"$",
"found",
"=",
"false",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"false",
"=... | Remove orphan.
@param AlphabeticalTreeNodeInterface[] $nodes The nodes.
@return void | [
"Remove",
"orphan",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Sorting/AlphabeticalTreeNodeHelper.php#L97-L108 | train |
BerliozFramework/Berlioz | src/Services/Template/DefaultEngine.php | DefaultEngine.getTwig | public function getTwig(): \Twig_Environment
{
if (is_null($this->twig)) {
// Init Twig
$this->twigLoader = new \Twig_Loader_Filesystem();
$this->twig = new \Twig_Environment($this->twigLoader);
}
return $this->twig;
} | php | public function getTwig(): \Twig_Environment
{
if (is_null($this->twig)) {
// Init Twig
$this->twigLoader = new \Twig_Loader_Filesystem();
$this->twig = new \Twig_Environment($this->twigLoader);
}
return $this->twig;
} | [
"public",
"function",
"getTwig",
"(",
")",
":",
"\\",
"Twig_Environment",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"twig",
")",
")",
"{",
"// Init Twig",
"$",
"this",
"->",
"twigLoader",
"=",
"new",
"\\",
"Twig_Loader_Filesystem",
"(",
")",
";"... | Get Twig.
@return \Twig_Environment | [
"Get",
"Twig",
"."
] | cd5f28f93fdff254b9a123a30dad275e5bbfd78c | https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Services/Template/DefaultEngine.php#L61-L70 | train |
hypeJunction/hypeApps | classes/hypeJunction/Config.php | Config.all | public function all() {
if (!isset($this->settings)) {
$this->settings = array_merge($this->getDefaults(), $this->plugin->getAllSettings());
}
return $this->settings;
} | php | public function all() {
if (!isset($this->settings)) {
$this->settings = array_merge($this->getDefaults(), $this->plugin->getAllSettings());
}
return $this->settings;
} | [
"public",
"function",
"all",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"settings",
")",
")",
"{",
"$",
"this",
"->",
"settings",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"getDefaults",
"(",
")",
",",
"$",
"this",
"->",
"p... | Returns all plugin settings
@return array | [
"Returns",
"all",
"plugin",
"settings"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Config.php#L41-L46 | train |
contextio/PHP-ContextIO | src/ContextIO/oAuth/OAuthServer.php | OAuthServer.fetchRequestToken | public function fetchRequestToken(&$request)
{
$this->getVersion($request);
$consumer = $this->getConsumer($request);
// no token required for the initial token request
$token = null;
$this->checkSignature($request, $consumer, $token);
// Rev A change
$callback = $request->getParameter('oauth_callback');
$new_token = $this->data_store->newRequestToken($consumer, $callback);
return $new_token;
} | php | public function fetchRequestToken(&$request)
{
$this->getVersion($request);
$consumer = $this->getConsumer($request);
// no token required for the initial token request
$token = null;
$this->checkSignature($request, $consumer, $token);
// Rev A change
$callback = $request->getParameter('oauth_callback');
$new_token = $this->data_store->newRequestToken($consumer, $callback);
return $new_token;
} | [
"public",
"function",
"fetchRequestToken",
"(",
"&",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"getVersion",
"(",
"$",
"request",
")",
";",
"$",
"consumer",
"=",
"$",
"this",
"->",
"getConsumer",
"(",
"$",
"request",
")",
";",
"// no token required for ... | Process a request_token request
@param OAuthRequest $request
@return mixed Returns the request token on success. | [
"Process",
"a",
"request_token",
"request"
] | 037e7c52683def87e639030d11c49da83f5c07dc | https://github.com/contextio/PHP-ContextIO/blob/037e7c52683def87e639030d11c49da83f5c07dc/src/ContextIO/oAuth/OAuthServer.php#L37-L53 | train |
contextio/PHP-ContextIO | src/ContextIO/oAuth/OAuthServer.php | OAuthServer.fetchAccessToken | public function fetchAccessToken(&$request)
{
$this->getVersion($request);
$consumer = $this->getConsumer($request);
// requires authorized request token
$token = $this->getToken($request, $consumer, "request");
$this->checkSignature($request, $consumer, $token);
// Rev A change
$verifier = $request->getParameter('oauth_verifier');
$new_token = $this->data_store->newAccessToken($token, $consumer, $verifier);
return $new_token;
} | php | public function fetchAccessToken(&$request)
{
$this->getVersion($request);
$consumer = $this->getConsumer($request);
// requires authorized request token
$token = $this->getToken($request, $consumer, "request");
$this->checkSignature($request, $consumer, $token);
// Rev A change
$verifier = $request->getParameter('oauth_verifier');
$new_token = $this->data_store->newAccessToken($token, $consumer, $verifier);
return $new_token;
} | [
"public",
"function",
"fetchAccessToken",
"(",
"&",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"getVersion",
"(",
"$",
"request",
")",
";",
"$",
"consumer",
"=",
"$",
"this",
"->",
"getConsumer",
"(",
"$",
"request",
")",
";",
"// requires authorized req... | Process an access_token request.
@param OAuthRequest $request
@return mixed The access token on success | [
"Process",
"an",
"access_token",
"request",
"."
] | 037e7c52683def87e639030d11c49da83f5c07dc | https://github.com/contextio/PHP-ContextIO/blob/037e7c52683def87e639030d11c49da83f5c07dc/src/ContextIO/oAuth/OAuthServer.php#L65-L81 | train |
contextio/PHP-ContextIO | src/ContextIO/oAuth/OAuthServer.php | OAuthServer.getSignatureMethod | protected function getSignatureMethod(&$request)
{
$signature_method =
@$request->getParameter("oauth_signature_method");
if (!$signature_method) {
// According to chapter 7 ("Accessing Protected Ressources") the signature-method
// parameter is required, and we can't just fallback to PLAINTEXT
throw new OAuthException('No signature method parameter. This parameter is required');
}
if (!in_array($signature_method,
array_keys($this->signature_methods))
) {
throw new OAuthException(
"Signature method '$signature_method' not supported " .
"try one of the following: " .
implode(", ", array_keys($this->signature_methods))
);
}
return $this->signature_methods[ $signature_method ];
} | php | protected function getSignatureMethod(&$request)
{
$signature_method =
@$request->getParameter("oauth_signature_method");
if (!$signature_method) {
// According to chapter 7 ("Accessing Protected Ressources") the signature-method
// parameter is required, and we can't just fallback to PLAINTEXT
throw new OAuthException('No signature method parameter. This parameter is required');
}
if (!in_array($signature_method,
array_keys($this->signature_methods))
) {
throw new OAuthException(
"Signature method '$signature_method' not supported " .
"try one of the following: " .
implode(", ", array_keys($this->signature_methods))
);
}
return $this->signature_methods[ $signature_method ];
} | [
"protected",
"function",
"getSignatureMethod",
"(",
"&",
"$",
"request",
")",
"{",
"$",
"signature_method",
"=",
"@",
"$",
"request",
"->",
"getParameter",
"(",
"\"oauth_signature_method\"",
")",
";",
"if",
"(",
"!",
"$",
"signature_method",
")",
"{",
"// Acco... | Figure out the signature with some defaults.
@param OAuthRequest $request
@return mixed
@throws OAuthException | [
"Figure",
"out",
"the",
"signature",
"with",
"some",
"defaults",
"."
] | 037e7c52683def87e639030d11c49da83f5c07dc | https://github.com/contextio/PHP-ContextIO/blob/037e7c52683def87e639030d11c49da83f5c07dc/src/ContextIO/oAuth/OAuthServer.php#L131-L153 | train |
contextio/PHP-ContextIO | src/ContextIO/oAuth/OAuthServer.php | OAuthServer.getConsumer | protected function getConsumer(&$request)
{
$consumer_key = @$request->getParameter("oauth_consumer_key");
if (!$consumer_key) {
throw new OAuthException("Invalid consumer key");
}
$consumer = $this->data_store->lookupConsumer($consumer_key);
if (!$consumer) {
throw new OAuthException("Invalid consumer");
}
return $consumer;
} | php | protected function getConsumer(&$request)
{
$consumer_key = @$request->getParameter("oauth_consumer_key");
if (!$consumer_key) {
throw new OAuthException("Invalid consumer key");
}
$consumer = $this->data_store->lookupConsumer($consumer_key);
if (!$consumer) {
throw new OAuthException("Invalid consumer");
}
return $consumer;
} | [
"protected",
"function",
"getConsumer",
"(",
"&",
"$",
"request",
")",
"{",
"$",
"consumer_key",
"=",
"@",
"$",
"request",
"->",
"getParameter",
"(",
"\"oauth_consumer_key\"",
")",
";",
"if",
"(",
"!",
"$",
"consumer_key",
")",
"{",
"throw",
"new",
"OAuthE... | Try to find the consumer for the provided request's consumer key
@param OAuthRequest $request
@throws OAuthException
@return mixed | [
"Try",
"to",
"find",
"the",
"consumer",
"for",
"the",
"provided",
"request",
"s",
"consumer",
"key"
] | 037e7c52683def87e639030d11c49da83f5c07dc | https://github.com/contextio/PHP-ContextIO/blob/037e7c52683def87e639030d11c49da83f5c07dc/src/ContextIO/oAuth/OAuthServer.php#L164-L177 | train |
contextio/PHP-ContextIO | src/ContextIO/oAuth/OAuthServer.php | OAuthServer.getToken | protected function getToken(&$request, $consumer, $token_type = "access")
{
$token_field = @$request->getParameter('oauth_token');
$token = $this->data_store->lookupToken(
$consumer, $token_type, $token_field
);
if (!$token) {
throw new OAuthException("Invalid $token_type token: $token_field");
}
return $token;
} | php | protected function getToken(&$request, $consumer, $token_type = "access")
{
$token_field = @$request->getParameter('oauth_token');
$token = $this->data_store->lookupToken(
$consumer, $token_type, $token_field
);
if (!$token) {
throw new OAuthException("Invalid $token_type token: $token_field");
}
return $token;
} | [
"protected",
"function",
"getToken",
"(",
"&",
"$",
"request",
",",
"$",
"consumer",
",",
"$",
"token_type",
"=",
"\"access\"",
")",
"{",
"$",
"token_field",
"=",
"@",
"$",
"request",
"->",
"getParameter",
"(",
"'oauth_token'",
")",
";",
"$",
"token",
"=... | Try to find the token for the provided request's token key.
@param OAuthRequest $request
@param $consumer
@param string $token_type
@throws OAuthException
@return mixed | [
"Try",
"to",
"find",
"the",
"token",
"for",
"the",
"provided",
"request",
"s",
"token",
"key",
"."
] | 037e7c52683def87e639030d11c49da83f5c07dc | https://github.com/contextio/PHP-ContextIO/blob/037e7c52683def87e639030d11c49da83f5c07dc/src/ContextIO/oAuth/OAuthServer.php#L190-L201 | train |
contextio/PHP-ContextIO | src/ContextIO/oAuth/OAuthServer.php | OAuthServer.checkNonce | protected function checkNonce($consumer, $token, $nonce, $timestamp)
{
if (!$nonce) {
throw new OAuthException(
'Missing nonce parameter. The parameter is required'
);
}
// verify that the nonce is uniqueish
$found = $this->data_store->lookupNonce(
$consumer,
$token,
$nonce,
$timestamp
);
if ($found) {
throw new OAuthException("Nonce already used: $nonce");
}
} | php | protected function checkNonce($consumer, $token, $nonce, $timestamp)
{
if (!$nonce) {
throw new OAuthException(
'Missing nonce parameter. The parameter is required'
);
}
// verify that the nonce is uniqueish
$found = $this->data_store->lookupNonce(
$consumer,
$token,
$nonce,
$timestamp
);
if ($found) {
throw new OAuthException("Nonce already used: $nonce");
}
} | [
"protected",
"function",
"checkNonce",
"(",
"$",
"consumer",
",",
"$",
"token",
",",
"$",
"nonce",
",",
"$",
"timestamp",
")",
"{",
"if",
"(",
"!",
"$",
"nonce",
")",
"{",
"throw",
"new",
"OAuthException",
"(",
"'Missing nonce parameter. The parameter is requi... | check that the nonce is not repeated | [
"check",
"that",
"the",
"nonce",
"is",
"not",
"repeated"
] | 037e7c52683def87e639030d11c49da83f5c07dc | https://github.com/contextio/PHP-ContextIO/blob/037e7c52683def87e639030d11c49da83f5c07dc/src/ContextIO/oAuth/OAuthServer.php#L264-L282 | train |
inpsyde/inpsyde-validator | src/Date.php | Date.convert_to_date_time | protected function convert_to_date_time( $value ) {
if ( $value instanceof \DateTimeInterface ) {
return $value;
}
switch ( gettype( $value ) ) {
case 'string' :
return $this->convert_string( $value );
case 'integer' :
return $this->convert_integer( $value );
case 'double' :
return $this->convert_double( $value );
case 'array' :
return $this->convert_array( $value );
}
$this->error_code = Error\ErrorLoggerInterface::INVALID_TYPE_NON_DATE;
return FALSE;
} | php | protected function convert_to_date_time( $value ) {
if ( $value instanceof \DateTimeInterface ) {
return $value;
}
switch ( gettype( $value ) ) {
case 'string' :
return $this->convert_string( $value );
case 'integer' :
return $this->convert_integer( $value );
case 'double' :
return $this->convert_double( $value );
case 'array' :
return $this->convert_array( $value );
}
$this->error_code = Error\ErrorLoggerInterface::INVALID_TYPE_NON_DATE;
return FALSE;
} | [
"protected",
"function",
"convert_to_date_time",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"\\",
"DateTimeInterface",
")",
"{",
"return",
"$",
"value",
";",
"}",
"switch",
"(",
"gettype",
"(",
"$",
"value",
")",
")",
"{",
"case"... | Attempts to convert an int, string, or array to a DateTime object.
@param string|int|array $value
@return bool|\DateTime | [
"Attempts",
"to",
"convert",
"an",
"int",
"string",
"or",
"array",
"to",
"a",
"DateTime",
"object",
"."
] | dcc57f705f142071a1764204bb469eee0bb5015d | https://github.com/inpsyde/inpsyde-validator/blob/dcc57f705f142071a1764204bb469eee0bb5015d/src/Date.php#L89-L109 | train |
inpsyde/inpsyde-validator | src/Date.php | Date.convert_string | protected function convert_string( $value ) {
$format = $this->input_data[ 'format' ];
$date = \DateTime::createFromFormat( $format, $value );
// Invalid dates can show up as warnings (ie. "2007-02-99") and still return a DateTime object.
$errors = \DateTime::getLastErrors();
if ( $errors[ 'warning_count' ] > 0 ) {
$this->error_code = Error\ErrorLoggerInterface::INVALID_DATE_FORMAT;
return FALSE;
}
return $date;
} | php | protected function convert_string( $value ) {
$format = $this->input_data[ 'format' ];
$date = \DateTime::createFromFormat( $format, $value );
// Invalid dates can show up as warnings (ie. "2007-02-99") and still return a DateTime object.
$errors = \DateTime::getLastErrors();
if ( $errors[ 'warning_count' ] > 0 ) {
$this->error_code = Error\ErrorLoggerInterface::INVALID_DATE_FORMAT;
return FALSE;
}
return $date;
} | [
"protected",
"function",
"convert_string",
"(",
"$",
"value",
")",
"{",
"$",
"format",
"=",
"$",
"this",
"->",
"input_data",
"[",
"'format'",
"]",
";",
"$",
"date",
"=",
"\\",
"DateTime",
"::",
"createFromFormat",
"(",
"$",
"format",
",",
"$",
"value",
... | Attempts to convert a string into a DateTime object.
@param string $value
@return bool|\DateTime | [
"Attempts",
"to",
"convert",
"a",
"string",
"into",
"a",
"DateTime",
"object",
"."
] | dcc57f705f142071a1764204bb469eee0bb5015d | https://github.com/inpsyde/inpsyde-validator/blob/dcc57f705f142071a1764204bb469eee0bb5015d/src/Date.php#L142-L156 | train |
davro/fabrication | library/DiagramUML.php | DiagramUML.getStereoType | public function getStereoType(\DOMElement $diaObject)
{
$xpath = $diaObject->getNodePath() . '/dia:attribute[@name="stereotype"]/dia:string';
$nodeList = $this->engine->query($xpath);
if ($nodeList->length == 1) {
$stereoType = str_replace('#', '', $nodeList->item(0)->nodeValue);
return $stereoType;
}
return false;
} | php | public function getStereoType(\DOMElement $diaObject)
{
$xpath = $diaObject->getNodePath() . '/dia:attribute[@name="stereotype"]/dia:string';
$nodeList = $this->engine->query($xpath);
if ($nodeList->length == 1) {
$stereoType = str_replace('#', '', $nodeList->item(0)->nodeValue);
return $stereoType;
}
return false;
} | [
"public",
"function",
"getStereoType",
"(",
"\\",
"DOMElement",
"$",
"diaObject",
")",
"{",
"$",
"xpath",
"=",
"$",
"diaObject",
"->",
"getNodePath",
"(",
")",
".",
"'/dia:attribute[@name=\"stereotype\"]/dia:string'",
";",
"$",
"nodeList",
"=",
"$",
"this",
"->"... | Getter for retrieving the stereotype from a DIA object structure.
@param \DOMElement $diaObject
@return boolean | [
"Getter",
"for",
"retrieving",
"the",
"stereotype",
"from",
"a",
"DIA",
"object",
"structure",
"."
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/DiagramUML.php#L43-L54 | train |
davro/fabrication | library/DiagramUML.php | DiagramUML.getAttributes | public function getAttributes(\DOMElement $diaObject)
{
$xpath = $diaObject->getNodePath() . '/dia:attribute[@name="attributes"]/*';
$nodeList = $this->engine->query($xpath);
if ($nodeList->length > 0) {
return $nodeList;
}
return false;
} | php | public function getAttributes(\DOMElement $diaObject)
{
$xpath = $diaObject->getNodePath() . '/dia:attribute[@name="attributes"]/*';
$nodeList = $this->engine->query($xpath);
if ($nodeList->length > 0) {
return $nodeList;
}
return false;
} | [
"public",
"function",
"getAttributes",
"(",
"\\",
"DOMElement",
"$",
"diaObject",
")",
"{",
"$",
"xpath",
"=",
"$",
"diaObject",
"->",
"getNodePath",
"(",
")",
".",
"'/dia:attribute[@name=\"attributes\"]/*'",
";",
"$",
"nodeList",
"=",
"$",
"this",
"->",
"engi... | Getter for retrieving all attributes from a DIA object structure
@param \DOMElement $diaObject
@return boolean | [
"Getter",
"for",
"retrieving",
"all",
"attributes",
"from",
"a",
"DIA",
"object",
"structure"
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/DiagramUML.php#L62-L71 | train |
davro/fabrication | library/DiagramUML.php | DiagramUML.getElement | public function getElement(\DOMElement $nodeList, $level = 0, $showPaths = false)
{
$tabs = str_repeat("\t", $level);
$output = '';
if (!$showPaths) {
$output = "";
foreach ($nodeList as $attribute) {
$output .= $tabs . $attribute->nodeName . " = " . $attribute->nodeValue . "\n";
}
$output .= $tabs . $nodeList->nodeName . " = " . $nodeList->nodeValue . "\n";
} else {
$output .= $nodeList->getNodePath() . "\n";
}
foreach ($nodeList->childNodes as $childObject) {
if ($childObject instanceof \DOMElement) {
$output .= $this->getElement($childObject, $level + 1, $showPaths);
} elseif ($showPaths) {
$output .= $childObject->getNodePath() . "\n";
}
}
return $output;
} | php | public function getElement(\DOMElement $nodeList, $level = 0, $showPaths = false)
{
$tabs = str_repeat("\t", $level);
$output = '';
if (!$showPaths) {
$output = "";
foreach ($nodeList as $attribute) {
$output .= $tabs . $attribute->nodeName . " = " . $attribute->nodeValue . "\n";
}
$output .= $tabs . $nodeList->nodeName . " = " . $nodeList->nodeValue . "\n";
} else {
$output .= $nodeList->getNodePath() . "\n";
}
foreach ($nodeList->childNodes as $childObject) {
if ($childObject instanceof \DOMElement) {
$output .= $this->getElement($childObject, $level + 1, $showPaths);
} elseif ($showPaths) {
$output .= $childObject->getNodePath() . "\n";
}
}
return $output;
} | [
"public",
"function",
"getElement",
"(",
"\\",
"DOMElement",
"$",
"nodeList",
",",
"$",
"level",
"=",
"0",
",",
"$",
"showPaths",
"=",
"false",
")",
"{",
"$",
"tabs",
"=",
"str_repeat",
"(",
"\"\\t\"",
",",
"$",
"level",
")",
";",
"$",
"output",
"=",... | Getter for retrieving all elements from a DIA object structure
@param \DOMElement $nodeList
@param integer $level
@param boolean $showPaths
@return string | [
"Getter",
"for",
"retrieving",
"all",
"elements",
"from",
"a",
"DIA",
"object",
"structure"
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/DiagramUML.php#L98-L122 | train |
davro/fabrication | library/DiagramUML.php | DiagramUML.getPaths | public function getPaths(\DOMElement $nodeList, $level = 0)
{
$output = $nodeList->getNodePath();
foreach ($nodeList->childNodes as $childObject) {
$output .= $childObject->getNodePath() . "\n";
if ($childObject instanceof \DOMElement) {
$output .= $this->getElement($childObject, $level + 1, true);
}
}
return $output;
} | php | public function getPaths(\DOMElement $nodeList, $level = 0)
{
$output = $nodeList->getNodePath();
foreach ($nodeList->childNodes as $childObject) {
$output .= $childObject->getNodePath() . "\n";
if ($childObject instanceof \DOMElement) {
$output .= $this->getElement($childObject, $level + 1, true);
}
}
return $output;
} | [
"public",
"function",
"getPaths",
"(",
"\\",
"DOMElement",
"$",
"nodeList",
",",
"$",
"level",
"=",
"0",
")",
"{",
"$",
"output",
"=",
"$",
"nodeList",
"->",
"getNodePath",
"(",
")",
";",
"foreach",
"(",
"$",
"nodeList",
"->",
"childNodes",
"as",
"$",
... | Getter for retrieving xpath from a DOMElement
@param \DOMElement $nodeList
@param integer $level
@return type | [
"Getter",
"for",
"retrieving",
"xpath",
"from",
"a",
"DOMElement"
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/DiagramUML.php#L131-L143 | train |
davro/fabrication | library/DiagramUML.php | DiagramUML.retriveAttributeType | public function retriveAttributeType(\DOMElement $element)
{
$name = $this->engine->query($element->getNodePath() . '/dia:attribute[@name="type"]/dia:string');
return $this->cleanString($name->item(0)->nodeValue);
} | php | public function retriveAttributeType(\DOMElement $element)
{
$name = $this->engine->query($element->getNodePath() . '/dia:attribute[@name="type"]/dia:string');
return $this->cleanString($name->item(0)->nodeValue);
} | [
"public",
"function",
"retriveAttributeType",
"(",
"\\",
"DOMElement",
"$",
"element",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"engine",
"->",
"query",
"(",
"$",
"element",
"->",
"getNodePath",
"(",
")",
".",
"'/dia:attribute[@name=\"type\"]/dia:string'",... | Retrieve attribute type
@param \DOMElement $element
@return type | [
"Retrieve",
"attribute",
"type"
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/DiagramUML.php#L195-L199 | train |
davro/fabrication | library/DiagramUML.php | DiagramUML.retriveAttributeVisibility | public function retriveAttributeVisibility(\DOMElement $element)
{
$name = $this->engine->query($element->getNodePath() . '/dia:attribute[@name="visibility"]/dia:enum');
$propertyVisibility = $name->item(0)->attributes->getNamedItem('val')->nodeValue;
return self::$propertyVisibilityTypes[$propertyVisibility];
} | php | public function retriveAttributeVisibility(\DOMElement $element)
{
$name = $this->engine->query($element->getNodePath() . '/dia:attribute[@name="visibility"]/dia:enum');
$propertyVisibility = $name->item(0)->attributes->getNamedItem('val')->nodeValue;
return self::$propertyVisibilityTypes[$propertyVisibility];
} | [
"public",
"function",
"retriveAttributeVisibility",
"(",
"\\",
"DOMElement",
"$",
"element",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"engine",
"->",
"query",
"(",
"$",
"element",
"->",
"getNodePath",
"(",
")",
".",
"'/dia:attribute[@name=\"visibility\"]/d... | Retrieve attribute visibility
@param \DOMElement $element
@return type | [
"Retrieve",
"attribute",
"visibility"
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/DiagramUML.php#L207-L213 | train |
davro/fabrication | library/DiagramUML.php | DiagramUML.retriveLayerObjects | public function retriveLayerObjects()
{
$classes = [];
foreach ($this->engine->query('//dia:diagram/dia:layer') as $layer) {
if ($layer->nodeName == 'dia:layer') {
foreach ($layer->childNodes as $elementObject) {
if ($elementObject->nodeName == 'dia:object') {
foreach ($elementObject->childNodes as $childNodesAttributes) {
if ($childNodesAttributes->nodeName == 'dia:attribute' &&
$childNodesAttributes->attributes->getNamedItem("name")->nodeValue == 'name'
) {
$name = str_replace(['#'], [''], $childNodesAttributes->childNodes->item(1)->nodeValue);
$classes[$name] = $elementObject;
}
}
}
}
}
}
return $classes;
} | php | public function retriveLayerObjects()
{
$classes = [];
foreach ($this->engine->query('//dia:diagram/dia:layer') as $layer) {
if ($layer->nodeName == 'dia:layer') {
foreach ($layer->childNodes as $elementObject) {
if ($elementObject->nodeName == 'dia:object') {
foreach ($elementObject->childNodes as $childNodesAttributes) {
if ($childNodesAttributes->nodeName == 'dia:attribute' &&
$childNodesAttributes->attributes->getNamedItem("name")->nodeValue == 'name'
) {
$name = str_replace(['#'], [''], $childNodesAttributes->childNodes->item(1)->nodeValue);
$classes[$name] = $elementObject;
}
}
}
}
}
}
return $classes;
} | [
"public",
"function",
"retriveLayerObjects",
"(",
")",
"{",
"$",
"classes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"engine",
"->",
"query",
"(",
"'//dia:diagram/dia:layer'",
")",
"as",
"$",
"layer",
")",
"{",
"if",
"(",
"$",
"layer",
"-... | Retrieve layer objects
@return array | [
"Retrieve",
"layer",
"objects"
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/DiagramUML.php#L258-L280 | train |
webeweb/core-library | src/Network/CURL/Request/AbstractCURLRequest.php | AbstractCURLRequest.mergeHeaders | private function mergeHeaders() {
// Initialize the merged headers.
$mergedHeaders = [];
// Handle each header.
foreach (array_merge($this->getConfiguration()->getHeaders(), $this->getHeaders()) as $key => $value) {
$mergedHeaders[] = implode(": ", [$key, $value]);
}
// Return the merged headers.
return $mergedHeaders;
} | php | private function mergeHeaders() {
// Initialize the merged headers.
$mergedHeaders = [];
// Handle each header.
foreach (array_merge($this->getConfiguration()->getHeaders(), $this->getHeaders()) as $key => $value) {
$mergedHeaders[] = implode(": ", [$key, $value]);
}
// Return the merged headers.
return $mergedHeaders;
} | [
"private",
"function",
"mergeHeaders",
"(",
")",
"{",
"// Initialize the merged headers.",
"$",
"mergedHeaders",
"=",
"[",
"]",
";",
"// Handle each header.",
"foreach",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"getConfiguration",
"(",
")",
"->",
"getHeaders",
... | Merge the headers.
@return array Returns the meged headers. | [
"Merge",
"the",
"headers",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Network/CURL/Request/AbstractCURLRequest.php#L342-L354 | train |
webeweb/core-library | src/Network/CURL/Request/AbstractCURLRequest.php | AbstractCURLRequest.mergeURL | private function mergeURL() {
// Initialize the merged URL.
$mergedURL = [];
$mergedURL[] = $this->getConfiguration()->getHost();
if (null !== $this->getResourcePath() && "" !== $this->getResourcePath()) {
$mergedURL[] = $this->getResourcePath();
}
// Return the merged URL.
return implode("/", $mergedURL);
} | php | private function mergeURL() {
// Initialize the merged URL.
$mergedURL = [];
$mergedURL[] = $this->getConfiguration()->getHost();
if (null !== $this->getResourcePath() && "" !== $this->getResourcePath()) {
$mergedURL[] = $this->getResourcePath();
}
// Return the merged URL.
return implode("/", $mergedURL);
} | [
"private",
"function",
"mergeURL",
"(",
")",
"{",
"// Initialize the merged URL.",
"$",
"mergedURL",
"=",
"[",
"]",
";",
"$",
"mergedURL",
"[",
"]",
"=",
"$",
"this",
"->",
"getConfiguration",
"(",
")",
"->",
"getHost",
"(",
")",
";",
"if",
"(",
"null",
... | Merge the URL.
@return string Returns the merged URL. | [
"Merge",
"the",
"URL",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Network/CURL/Request/AbstractCURLRequest.php#L361-L372 | train |
webeweb/core-library | src/Network/CURL/Request/AbstractCURLRequest.php | AbstractCURLRequest.parseHeader | private function parseHeader($rawHeader) {
// Initialize the headers.
$headers = [];
$key = "";
// Handle each header.
foreach (explode("\n", $rawHeader) as $h) {
$h = explode(":", $h, 2);
if (true === isset($h[1])) {
if (false === isset($headers[$h[0]])) {
$headers[$h[0]] = trim($h[1]);
} elseif (true === is_array($headers[$h[0]])) {
$headers[$h[0]] = array_merge($headers[$h[0]], [trim($h[1])]);
} else {
$headers[$h[0]] = array_merge([$headers[$h[0]]], [trim($h[1])]);
}
$key = $h[0];
} else {
if ("\t" === substr($h[0], 0, 1)) {
$headers[$key] .= "\r\n\t" . trim($h[0]);
} elseif (!$key) {
$headers[0] = trim($h[0]);
}
trim($h[0]);
}
}
// Return the headers.
return $headers;
} | php | private function parseHeader($rawHeader) {
// Initialize the headers.
$headers = [];
$key = "";
// Handle each header.
foreach (explode("\n", $rawHeader) as $h) {
$h = explode(":", $h, 2);
if (true === isset($h[1])) {
if (false === isset($headers[$h[0]])) {
$headers[$h[0]] = trim($h[1]);
} elseif (true === is_array($headers[$h[0]])) {
$headers[$h[0]] = array_merge($headers[$h[0]], [trim($h[1])]);
} else {
$headers[$h[0]] = array_merge([$headers[$h[0]]], [trim($h[1])]);
}
$key = $h[0];
} else {
if ("\t" === substr($h[0], 0, 1)) {
$headers[$key] .= "\r\n\t" . trim($h[0]);
} elseif (!$key) {
$headers[0] = trim($h[0]);
}
trim($h[0]);
}
}
// Return the headers.
return $headers;
} | [
"private",
"function",
"parseHeader",
"(",
"$",
"rawHeader",
")",
"{",
"// Initialize the headers.",
"$",
"headers",
"=",
"[",
"]",
";",
"$",
"key",
"=",
"\"\"",
";",
"// Handle each header.",
"foreach",
"(",
"explode",
"(",
"\"\\n\"",
",",
"$",
"rawHeader",
... | Parse the raw header.
@param string $rawHeader The raw header.
@return array Returns the headers. | [
"Parse",
"the",
"raw",
"header",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Network/CURL/Request/AbstractCURLRequest.php#L380-L410 | train |
davro/fabrication | library/FabricationEngine.php | FabricationEngine.registerNamespace | public function registerNamespace($prefix, $uri)
{
$this->initializeXPath();
$this->xpath->registerNamespace($prefix, $uri);
} | php | public function registerNamespace($prefix, $uri)
{
$this->initializeXPath();
$this->xpath->registerNamespace($prefix, $uri);
} | [
"public",
"function",
"registerNamespace",
"(",
"$",
"prefix",
",",
"$",
"uri",
")",
"{",
"$",
"this",
"->",
"initializeXPath",
"(",
")",
";",
"$",
"this",
"->",
"xpath",
"->",
"registerNamespace",
"(",
"$",
"prefix",
",",
"$",
"uri",
")",
";",
"}"
] | Register a prefix and uri to the xpath namespace.
@param string $prefix The namespace prefix.
@param string $uri The namespace uri. | [
"Register",
"a",
"prefix",
"and",
"uri",
"to",
"the",
"xpath",
"namespace",
"."
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/FabricationEngine.php#L143-L147 | train |
davro/fabrication | library/FabricationEngine.php | FabricationEngine.getSpecification | public function getSpecification($element = '')
{
if (isset($element) && $element !== '') {
$spec = $this->pattern->specification[$this->getOption('doctype')][$element];
} else {
$spec = $this->pattern->specification[$this->getOption('doctype')];
}
return $spec;
} | php | public function getSpecification($element = '')
{
if (isset($element) && $element !== '') {
$spec = $this->pattern->specification[$this->getOption('doctype')][$element];
} else {
$spec = $this->pattern->specification[$this->getOption('doctype')];
}
return $spec;
} | [
"public",
"function",
"getSpecification",
"(",
"$",
"element",
"=",
"''",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"element",
")",
"&&",
"$",
"element",
"!==",
"''",
")",
"{",
"$",
"spec",
"=",
"$",
"this",
"->",
"pattern",
"->",
"specification",
"[",... | TESTING Getter for retriving the specification in the current context.
@param string $element
@return string | [
"TESTING",
"Getter",
"for",
"retriving",
"the",
"specification",
"in",
"the",
"current",
"context",
"."
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/FabricationEngine.php#L211-L219 | train |
davro/fabrication | library/FabricationEngine.php | FabricationEngine.run | public function run($data = '', $load = 'string', $type = 'html')
{
if (!empty($data)) {
$this->$type = $type;
// Check if data is a path to a valid file then load into buffer.
if (file_exists($data)) {
$pathHash = md5($data);
$this->views[$pathHash] = $data;
}
switch ($load . '.' . $type) {
default:
return false;
// load string html
case 'string.html':
if (@$this->loadHTML($data)) {
$objectName = 'Fabrication\\Html';
$this->pattern = new $objectName($this);
$this->mapSymbols();
return true;
} else {
return false;
}
// load file html
case 'file.html':
if (@$this->loadHTMLFile($data)) {
$this->mapSymbols();
return true;
} else {
return false;
}
// load string xml
case 'string.xml':
if ($this->loadXML($data)) {
$this->mapSymbols();
return true;
} else {
return false;
}
// load file xml
case 'file.xml':
$contents = file_get_contents($data);
if (@$this->loadXML($contents)) {
$this->mapSymbols();
return true;
} else {
return false;
}
}
}
return;
} | php | public function run($data = '', $load = 'string', $type = 'html')
{
if (!empty($data)) {
$this->$type = $type;
// Check if data is a path to a valid file then load into buffer.
if (file_exists($data)) {
$pathHash = md5($data);
$this->views[$pathHash] = $data;
}
switch ($load . '.' . $type) {
default:
return false;
// load string html
case 'string.html':
if (@$this->loadHTML($data)) {
$objectName = 'Fabrication\\Html';
$this->pattern = new $objectName($this);
$this->mapSymbols();
return true;
} else {
return false;
}
// load file html
case 'file.html':
if (@$this->loadHTMLFile($data)) {
$this->mapSymbols();
return true;
} else {
return false;
}
// load string xml
case 'string.xml':
if ($this->loadXML($data)) {
$this->mapSymbols();
return true;
} else {
return false;
}
// load file xml
case 'file.xml':
$contents = file_get_contents($data);
if (@$this->loadXML($contents)) {
$this->mapSymbols();
return true;
} else {
return false;
}
}
}
return;
} | [
"public",
"function",
"run",
"(",
"$",
"data",
"=",
"''",
",",
"$",
"load",
"=",
"'string'",
",",
"$",
"type",
"=",
"'html'",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"$",
"this",
"->",
"$",
"type",
"=",
"$",
"type"... | Run method once the all input have been set.
Then you will have a valid document with a searchable path.
@param string $data
@param string $load
@param string $type
@return mixed | [
"Run",
"method",
"once",
"the",
"all",
"input",
"have",
"been",
"set",
".",
"Then",
"you",
"will",
"have",
"a",
"valid",
"document",
"with",
"a",
"searchable",
"path",
"."
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/FabricationEngine.php#L241-L299 | train |
davro/fabrication | library/FabricationEngine.php | FabricationEngine.mapSymbols | public function mapSymbols()
{
foreach ($this->input as $key => $input) {
foreach ($this->symbols as $skey => $svalue) {
if (substr($key, 0, 1) == $svalue) {
$keyWithoutSymbol = str_replace($svalue, '', $key);
if (is_string($input)) {
$this->setElementBy($skey, $keyWithoutSymbol, $input);
}
if (is_array($input)) {
$this->setElementBy($skey, $keyWithoutSymbol, $input);
}
if (is_object($input)) {
$this->setElementBy($skey, $keyWithoutSymbol, $input);
}
}
}
}
} | php | public function mapSymbols()
{
foreach ($this->input as $key => $input) {
foreach ($this->symbols as $skey => $svalue) {
if (substr($key, 0, 1) == $svalue) {
$keyWithoutSymbol = str_replace($svalue, '', $key);
if (is_string($input)) {
$this->setElementBy($skey, $keyWithoutSymbol, $input);
}
if (is_array($input)) {
$this->setElementBy($skey, $keyWithoutSymbol, $input);
}
if (is_object($input)) {
$this->setElementBy($skey, $keyWithoutSymbol, $input);
}
}
}
}
} | [
"public",
"function",
"mapSymbols",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"input",
"as",
"$",
"key",
"=>",
"$",
"input",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"symbols",
"as",
"$",
"skey",
"=>",
"$",
"svalue",
")",
"{",
"if",
"... | Symbol mapper for engine input symbolic values to engine element
attribute values for a basic mapping sub-system.
@todo add functionality for adding removing custom symbols.
@return void | [
"Symbol",
"mapper",
"for",
"engine",
"input",
"symbolic",
"values",
"to",
"engine",
"element",
"attribute",
"values",
"for",
"a",
"basic",
"mapping",
"sub",
"-",
"system",
"."
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/FabricationEngine.php#L309-L329 | train |
davro/fabrication | library/FabricationEngine.php | FabricationEngine.saveHTML | public function saveHTML($path = '', $trim = true)
{
if (is_string($path) && $path !== '') {
// no processing as just return xpath html result no adding doctype.
$this->output['raw'] = $this->view($path);
} else {
$this->output['raw'] = parent::saveHTML();
}
$this->outputProcess();
$raw = $this->output['raw'];
return $trim ? trim($raw) : $raw;
} | php | public function saveHTML($path = '', $trim = true)
{
if (is_string($path) && $path !== '') {
// no processing as just return xpath html result no adding doctype.
$this->output['raw'] = $this->view($path);
} else {
$this->output['raw'] = parent::saveHTML();
}
$this->outputProcess();
$raw = $this->output['raw'];
return $trim ? trim($raw) : $raw;
} | [
"public",
"function",
"saveHTML",
"(",
"$",
"path",
"=",
"''",
",",
"$",
"trim",
"=",
"true",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"path",
")",
"&&",
"$",
"path",
"!==",
"''",
")",
"{",
"// no processing as just return xpath html result no adding doct... | Extend the native saveHTML method.
Allow path search functionality.
@param string $path Output file path.
@param boolean $trim Trim the output of surrounding space.
@return string | [
"Extend",
"the",
"native",
"saveHTML",
"method",
".",
"Allow",
"path",
"search",
"functionality",
"."
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/FabricationEngine.php#L340-L354 | train |
davro/fabrication | library/FabricationEngine.php | FabricationEngine.saveFabric | public function saveFabric($type = 'html')
{
switch ($type) {
case 'html':
$this->output['raw'] = parent::saveHTML();
break;
case 'xml':
$this->output['raw'] = parent::saveXML();
break;
}
// default output process.
$this->outputProcess();
return $this->getDoctype() . trim($this->output['raw']);
} | php | public function saveFabric($type = 'html')
{
switch ($type) {
case 'html':
$this->output['raw'] = parent::saveHTML();
break;
case 'xml':
$this->output['raw'] = parent::saveXML();
break;
}
// default output process.
$this->outputProcess();
return $this->getDoctype() . trim($this->output['raw']);
} | [
"public",
"function",
"saveFabric",
"(",
"$",
"type",
"=",
"'html'",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'html'",
":",
"$",
"this",
"->",
"output",
"[",
"'raw'",
"]",
"=",
"parent",
"::",
"saveHTML",
"(",
")",
";",
"break",
";"... | Return the engine output html view.
@param string $type The run type
@return type | [
"Return",
"the",
"engine",
"output",
"html",
"view",
"."
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/FabricationEngine.php#L363-L379 | train |
davro/fabrication | library/FabricationEngine.php | FabricationEngine.outputProcess | public function outputProcess()
{
// remove doctype.
$this->output['raw'] = preg_replace(
'/^<!DOCTYPE[^>]+>/U', '', $this->output['raw']
);
if ($this->outputProcess && $this->getOption('process')) {
// Remove doctype added by DOMDocument (hacky)
$this->output['raw'] = $this->getDoctype() . $this->output['raw'];
/**
* Process img, br, hr, tags, change html to xhtml.
*
* <img> <img src=""> <img src="/image.png">
* Are changed to xhtml
* <img /> <img src="" /> <img src="/image.png" />
*/
if ($this->getOption('process.body.image')) {
$this->output['raw'] = preg_replace(
'/<img(.*)>/sU', '<img\\1 />', $this->output['raw']
);
}
if ($this->getOption('process.body.br')) {
$this->output['raw'] = preg_replace(
'/<br(.*)>/sU', '<br\\1 />', $this->output['raw']
);
}
if ($this->getOption('process.body.hr')) {
$this->output['raw'] = preg_replace(
'/<hr(.*)>/sU', '<hr\\1 />', $this->output['raw']
);
}
// Trim whitespace need this to get exactly the wanted data back for test cases, mmm.
$this->output['raw'] = trim($this->output['raw']);
return $this->outputProcess;
}
return $this->outputProcess;
} | php | public function outputProcess()
{
// remove doctype.
$this->output['raw'] = preg_replace(
'/^<!DOCTYPE[^>]+>/U', '', $this->output['raw']
);
if ($this->outputProcess && $this->getOption('process')) {
// Remove doctype added by DOMDocument (hacky)
$this->output['raw'] = $this->getDoctype() . $this->output['raw'];
/**
* Process img, br, hr, tags, change html to xhtml.
*
* <img> <img src=""> <img src="/image.png">
* Are changed to xhtml
* <img /> <img src="" /> <img src="/image.png" />
*/
if ($this->getOption('process.body.image')) {
$this->output['raw'] = preg_replace(
'/<img(.*)>/sU', '<img\\1 />', $this->output['raw']
);
}
if ($this->getOption('process.body.br')) {
$this->output['raw'] = preg_replace(
'/<br(.*)>/sU', '<br\\1 />', $this->output['raw']
);
}
if ($this->getOption('process.body.hr')) {
$this->output['raw'] = preg_replace(
'/<hr(.*)>/sU', '<hr\\1 />', $this->output['raw']
);
}
// Trim whitespace need this to get exactly the wanted data back for test cases, mmm.
$this->output['raw'] = trim($this->output['raw']);
return $this->outputProcess;
}
return $this->outputProcess;
} | [
"public",
"function",
"outputProcess",
"(",
")",
"{",
"// remove doctype.\r",
"$",
"this",
"->",
"output",
"[",
"'raw'",
"]",
"=",
"preg_replace",
"(",
"'/^<!DOCTYPE[^>]+>/U'",
",",
"''",
",",
"$",
"this",
"->",
"output",
"[",
"'raw'",
"]",
")",
";",
"if",... | Time to sort out the plethora of DOMDocument bugs.
TODO Styles create compiled CSS file, insert into reference into the head.
TODO Script create compiled JS file, insert into the page footer.
TODO Both should be configurable using options. | [
"Time",
"to",
"sort",
"out",
"the",
"plethora",
"of",
"DOMDocument",
"bugs",
"."
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/FabricationEngine.php#L388-L431 | train |
davro/fabrication | library/FabricationEngine.php | FabricationEngine.dump | public static function dump($data, $return = false)
{
$result = '';
if (Fabrication::isCli()) {
$end = "\n";
} else {
$end = "<br />\n";
}
if (is_object($data)) {
$classname = get_class($data);
$result = str_repeat('-', 80) . $end .
"\t" . __METHOD__ . ' Type: ' . gettype($data) . "\tReturn:" . var_export($return, true) . $end .
str_repeat('-', 80) . $end .
"Object Instance: $classname: $end" .
"Object Methods $end";
$class_methods = get_class_methods($data);
if (count($class_methods) > 0) {
foreach ($class_methods as $method) {
$result.="\t" . $method . $end;
}
} else {
$result.="No methods found.$end";
}
$result.= $end;
$result.= "Object XPath:$end";
$result.= $end;
switch ($classname) {
case 'DOMAttr':
$result.= "DOMAttr XPath: {$data->getNodePath()}$end" .
$data->ownerDocument->saveXML($data);
break;
case 'DOMDocument':
$result.= "DOMDocument XPath: {$data->getNodePath()}$end" .
$data->saveXML($data);
break;
case 'DOMElement':
$result.= "DOMElement XPath: {$data->getNodePath()}$end" .
$data->ownerDocument->saveXML($data);
break;
case 'DOMNodeList':
for ($i = 0; $i < $data->length; $i++) {
$result.= "DOMNodeList Item #$i, " .
"XPath: {$data->item($i)->getNodePath()}$end" .
"{$data->item($i)->ownerDocument->saveXML($data->item($i))}$end";
}
break;
default: $result.= var_export($data, true);
}
}
if (is_array($data)) {
$result = $end .
$end .
str_repeat('-', 80) . $end .
"| DUMP Type:" . gettype($data) . "\tReturn:" . var_export($return, true) . $end .
str_repeat('-', 80) . $end .
$end;
}
if (is_string($data)) {
$result = var_export($data, true);
}
if (is_int($data)) {
$result = var_export($data, true);
}
if ($return) {
return $result . $end;
} else {
echo $result . $end;
}
} | php | public static function dump($data, $return = false)
{
$result = '';
if (Fabrication::isCli()) {
$end = "\n";
} else {
$end = "<br />\n";
}
if (is_object($data)) {
$classname = get_class($data);
$result = str_repeat('-', 80) . $end .
"\t" . __METHOD__ . ' Type: ' . gettype($data) . "\tReturn:" . var_export($return, true) . $end .
str_repeat('-', 80) . $end .
"Object Instance: $classname: $end" .
"Object Methods $end";
$class_methods = get_class_methods($data);
if (count($class_methods) > 0) {
foreach ($class_methods as $method) {
$result.="\t" . $method . $end;
}
} else {
$result.="No methods found.$end";
}
$result.= $end;
$result.= "Object XPath:$end";
$result.= $end;
switch ($classname) {
case 'DOMAttr':
$result.= "DOMAttr XPath: {$data->getNodePath()}$end" .
$data->ownerDocument->saveXML($data);
break;
case 'DOMDocument':
$result.= "DOMDocument XPath: {$data->getNodePath()}$end" .
$data->saveXML($data);
break;
case 'DOMElement':
$result.= "DOMElement XPath: {$data->getNodePath()}$end" .
$data->ownerDocument->saveXML($data);
break;
case 'DOMNodeList':
for ($i = 0; $i < $data->length; $i++) {
$result.= "DOMNodeList Item #$i, " .
"XPath: {$data->item($i)->getNodePath()}$end" .
"{$data->item($i)->ownerDocument->saveXML($data->item($i))}$end";
}
break;
default: $result.= var_export($data, true);
}
}
if (is_array($data)) {
$result = $end .
$end .
str_repeat('-', 80) . $end .
"| DUMP Type:" . gettype($data) . "\tReturn:" . var_export($return, true) . $end .
str_repeat('-', 80) . $end .
$end;
}
if (is_string($data)) {
$result = var_export($data, true);
}
if (is_int($data)) {
$result = var_export($data, true);
}
if ($return) {
return $result . $end;
} else {
echo $result . $end;
}
} | [
"public",
"static",
"function",
"dump",
"(",
"$",
"data",
",",
"$",
"return",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"''",
";",
"if",
"(",
"Fabrication",
"::",
"isCli",
"(",
")",
")",
"{",
"$",
"end",
"=",
"\"\\n\"",
";",
"}",
"else",
"{",
... | Return a string representation of the data.
@param mixed $data The data to dump
@param boolean $return True return output, False print output
@return string | [
"Return",
"a",
"string",
"representation",
"of",
"the",
"data",
"."
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/FabricationEngine.php#L441-L526 | train |
davro/fabrication | library/FabricationEngine.php | FabricationEngine.createPattern | public function createPattern($name = 'html', $attributes = array(), $data = array())
{
$patternName = ucfirst($name);
$objectName = 'Library\Pattern\\' . $patternName;
$pattern = new $objectName($this, $attributes, $data);
return $pattern;
} | php | public function createPattern($name = 'html', $attributes = array(), $data = array())
{
$patternName = ucfirst($name);
$objectName = 'Library\Pattern\\' . $patternName;
$pattern = new $objectName($this, $attributes, $data);
return $pattern;
} | [
"public",
"function",
"createPattern",
"(",
"$",
"name",
"=",
"'html'",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
",",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"$",
"patternName",
"=",
"ucfirst",
"(",
"$",
"name",
")",
";",
"$",
"object... | Pattern method for fabrication-framework standardized patterns.
@param string $name Object $name to instantiate.
@param type $attributes Object attributes.
@param type $data Object data.
@return object \Library\Pattern\objectName | [
"Pattern",
"method",
"for",
"fabrication",
"-",
"framework",
"standardized",
"patterns",
"."
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/FabricationEngine.php#L695-L703 | train |
davro/fabrication | library/FabricationEngine.php | FabricationEngine.specification | public function specification($pattern = 'html', $value = '', $attributes = [], $contract = [])
{
if (!is_array($contract)) {
return;
}
// create the root specification element.
$this->appendChild(
$this->create($pattern, $value, $attributes, $contract)
);
return $this;
} | php | public function specification($pattern = 'html', $value = '', $attributes = [], $contract = [])
{
if (!is_array($contract)) {
return;
}
// create the root specification element.
$this->appendChild(
$this->create($pattern, $value, $attributes, $contract)
);
return $this;
} | [
"public",
"function",
"specification",
"(",
"$",
"pattern",
"=",
"'html'",
",",
"$",
"value",
"=",
"''",
",",
"$",
"attributes",
"=",
"[",
"]",
",",
"$",
"contract",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"contract",
")",
... | Document specification pattern.
This method is an extension of the create method but for building
structures.
Experiment note signature will change
@param string $pattern Html Xml structure pattern.
@param string $value Pattern value.
@param array $attributes Pattern attributes.
@param array $contract Pattern children recursion.
@return FabricationEngine | [
"Document",
"specification",
"pattern",
"."
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/FabricationEngine.php#L720-L732 | train |
davro/fabrication | library/FabricationEngine.php | FabricationEngine.template | public function template($pattern, $dataset = array(), $map = 'id')
{
if (count($dataset) == 0) {
return false;
}
try {
$template = '';
if (is_string($pattern)) {
$engine = new FabricationEngine();
$engine->setOption('doctype', 'html.5');
$engine->loadHTML($pattern);
$templateDiv = $engine->getDiv();
if ($templateDiv) {
$template = $templateDiv->item(0);
}
}
if (is_object($pattern)) {
$template = $pattern;
}
// Create an empty container, from the template node details.
if (is_object($template)) {
$container = $this->create($template->nodeName, $template->nodeValue);
foreach ($dataset as $key => $row) {
// process the template child nodes.
foreach ($template->childNodes as $child) {
if ($child->nodeName == '#text') {
continue;
}
if (is_object($child->attributes->getNamedItem($map))) {
$mappedName = $child->attributes->getNamedItem($map)->nodeName;
$mappedValue = $child->attributes->getNamedItem($map)->nodeValue;
$nodeAttributes = array();
foreach ($child->attributes as $attribute) {
$nodeAttributes[$attribute->nodeName] = $attribute->nodeValue;
}
if (in_array($mappedValue, array_keys($row))) {
// create the mapped node attribute with updated numeric key.
$nodeAttributes[$mappedName] = $mappedValue . '_' . ($key + 1);
// fabricate the new child nodes.
$node = $this->create($child->nodeName, $row[$mappedValue], $nodeAttributes
);
$container->appendChild($node);
}
}
}
}
return $container;
}
return false;
} catch (\Exception $ex) {
echo $ex->getMessage();
}
} | php | public function template($pattern, $dataset = array(), $map = 'id')
{
if (count($dataset) == 0) {
return false;
}
try {
$template = '';
if (is_string($pattern)) {
$engine = new FabricationEngine();
$engine->setOption('doctype', 'html.5');
$engine->loadHTML($pattern);
$templateDiv = $engine->getDiv();
if ($templateDiv) {
$template = $templateDiv->item(0);
}
}
if (is_object($pattern)) {
$template = $pattern;
}
// Create an empty container, from the template node details.
if (is_object($template)) {
$container = $this->create($template->nodeName, $template->nodeValue);
foreach ($dataset as $key => $row) {
// process the template child nodes.
foreach ($template->childNodes as $child) {
if ($child->nodeName == '#text') {
continue;
}
if (is_object($child->attributes->getNamedItem($map))) {
$mappedName = $child->attributes->getNamedItem($map)->nodeName;
$mappedValue = $child->attributes->getNamedItem($map)->nodeValue;
$nodeAttributes = array();
foreach ($child->attributes as $attribute) {
$nodeAttributes[$attribute->nodeName] = $attribute->nodeValue;
}
if (in_array($mappedValue, array_keys($row))) {
// create the mapped node attribute with updated numeric key.
$nodeAttributes[$mappedName] = $mappedValue . '_' . ($key + 1);
// fabricate the new child nodes.
$node = $this->create($child->nodeName, $row[$mappedValue], $nodeAttributes
);
$container->appendChild($node);
}
}
}
}
return $container;
}
return false;
} catch (\Exception $ex) {
echo $ex->getMessage();
}
} | [
"public",
"function",
"template",
"(",
"$",
"pattern",
",",
"$",
"dataset",
"=",
"array",
"(",
")",
",",
"$",
"map",
"=",
"'id'",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"dataset",
")",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"try",
"... | Template method allows for an element and its children to be used as the
pattern for an array dataset, the default map for the element children
atrribute is 'id'
@param mixed $pattern String or DOMElement
@param array $dataset Dataset to template.
@param string $map Identifier.
@return mixed | [
"Template",
"method",
"allows",
"for",
"an",
"element",
"and",
"its",
"children",
"to",
"be",
"used",
"as",
"the",
"pattern",
"for",
"an",
"array",
"dataset",
"the",
"default",
"map",
"for",
"the",
"element",
"children",
"atrribute",
"is",
"id"
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/FabricationEngine.php#L745-L816 | train |
davro/fabrication | library/FabricationEngine.php | FabricationEngine.view | public function view($path = '', $trim = true, $return = true)
{
if (!empty($path)) {
$results = $this->query($path);
// create an empty template object for xpath query results.
$template = new FabricationEngine();
foreach ($results as $result) {
$node = $template->importNode($result, true);
$template->appendChild($node);
}
if ($trim) {
$buffer = trim($template->saveHTML());
} else {
$buffer = $template->saveHTML();
}
} else {
if ($trim) {
$buffer = trim($this->saveHTML());
} else {
$buffer = $this->saveHTML();
}
}
if ($return) {
return $buffer;
}
echo $buffer;
} | php | public function view($path = '', $trim = true, $return = true)
{
if (!empty($path)) {
$results = $this->query($path);
// create an empty template object for xpath query results.
$template = new FabricationEngine();
foreach ($results as $result) {
$node = $template->importNode($result, true);
$template->appendChild($node);
}
if ($trim) {
$buffer = trim($template->saveHTML());
} else {
$buffer = $template->saveHTML();
}
} else {
if ($trim) {
$buffer = trim($this->saveHTML());
} else {
$buffer = $this->saveHTML();
}
}
if ($return) {
return $buffer;
}
echo $buffer;
} | [
"public",
"function",
"view",
"(",
"$",
"path",
"=",
"''",
",",
"$",
"trim",
"=",
"true",
",",
"$",
"return",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"$",
"results",
"=",
"$",
"this",
"->",
"query",
"(... | View the DOMTree in HTML either in full or search using XPath for the
first argument, also trim, return and change the output type, html, xml.
@param string $path The xpath to the element to view.
@param boolean $trim Trim the returned output string.
@param boolean $return Return or Print the output string.
@return string | [
"View",
"the",
"DOMTree",
"in",
"HTML",
"either",
"in",
"full",
"or",
"search",
"using",
"XPath",
"for",
"the",
"first",
"argument",
"also",
"trim",
"return",
"and",
"change",
"the",
"output",
"type",
"html",
"xml",
"."
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/FabricationEngine.php#L828-L860 | train |
davro/fabrication | library/FabricationEngine.php | FabricationEngine.query | public function query($path)
{
$this->initializeXPath();
if ($path) {
return $this->xpath->query($path);
}
return false;
} | php | public function query($path)
{
$this->initializeXPath();
if ($path) {
return $this->xpath->query($path);
}
return false;
} | [
"public",
"function",
"query",
"(",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"initializeXPath",
"(",
")",
";",
"if",
"(",
"$",
"path",
")",
"{",
"return",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"$",
"path",
")",
";",
"}",
"return",
"fal... | Main XPath query method.
@param string $path The xpath query to run on the current DOM
@return mixed | [
"Main",
"XPath",
"query",
"method",
"."
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/FabricationEngine.php#L869-L877 | train |
davro/fabrication | library/FabricationEngine.php | FabricationEngine.output | public function output($key = '', $query = '', $options = array())
{
// ensure key based retrievals are returned first/fast if empty query.
if (empty($query) && isset($this->input[$key])) {
return $this->input[$key];
}
// setup standard options.
if (empty($options)) {
$options = array('return' => true, 'tags' => true, 'echo' => false);
}
// templated output patterns
$output = $this->templateTextElement($key, $query, $options);
if (array_key_exists('return', $options)) {
if ($options['return']) {
return $output;
}
} else {
return false;
}
} | php | public function output($key = '', $query = '', $options = array())
{
// ensure key based retrievals are returned first/fast if empty query.
if (empty($query) && isset($this->input[$key])) {
return $this->input[$key];
}
// setup standard options.
if (empty($options)) {
$options = array('return' => true, 'tags' => true, 'echo' => false);
}
// templated output patterns
$output = $this->templateTextElement($key, $query, $options);
if (array_key_exists('return', $options)) {
if ($options['return']) {
return $output;
}
} else {
return false;
}
} | [
"public",
"function",
"output",
"(",
"$",
"key",
"=",
"''",
",",
"$",
"query",
"=",
"''",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"// ensure key based retrievals are returned first/fast if empty query.\r",
"if",
"(",
"empty",
"(",
"$",
"query",
... | Output key value from the input array.
@param mixed $key The key=>value to retrive.
@param string $query Example php.array
@param array $options Options for the template text element.
@return mixed | [
"Output",
"key",
"value",
"from",
"the",
"input",
"array",
"."
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/FabricationEngine.php#L903-L925 | train |
davro/fabrication | library/FabricationEngine.php | FabricationEngine.convert | public function convert($data)
{
$data = trim($data);
try {
// Buffer engine used to convert the html string into DOMElements,
$engine = new FabricationEngine;
$engine->run($data);
// Check if the body is null, so use the head if avaliable.
if ($engine->getBody()->item(0) == null) {
$node = $engine->getHead()->item(0)->childNodes->item(0);
return $this->importNode($node, true);
}
if ($engine->getBody()->item(0) !== null) {
// body first item.
$node = $engine->getBody()->item(0)->childNodes->item(0);
return $this->importNode($node, true);
}
return false;
} catch (\Exception $e) {
return('FabricationEngine :: convert : ' . $e->getMessage());
}
} | php | public function convert($data)
{
$data = trim($data);
try {
// Buffer engine used to convert the html string into DOMElements,
$engine = new FabricationEngine;
$engine->run($data);
// Check if the body is null, so use the head if avaliable.
if ($engine->getBody()->item(0) == null) {
$node = $engine->getHead()->item(0)->childNodes->item(0);
return $this->importNode($node, true);
}
if ($engine->getBody()->item(0) !== null) {
// body first item.
$node = $engine->getBody()->item(0)->childNodes->item(0);
return $this->importNode($node, true);
}
return false;
} catch (\Exception $e) {
return('FabricationEngine :: convert : ' . $e->getMessage());
}
} | [
"public",
"function",
"convert",
"(",
"$",
"data",
")",
"{",
"$",
"data",
"=",
"trim",
"(",
"$",
"data",
")",
";",
"try",
"{",
"// Buffer engine used to convert the html string into DOMElements,\r",
"$",
"engine",
"=",
"new",
"FabricationEngine",
";",
"$",
"engi... | Helper to allow the import of a html string into the current engine,
without causing DOM hierarchy errors.
This method generate's a temporary engine DOM structure from the data
Will return the body first child, if null the head first child.
Then the engine will call importNode using the found node and return the
DOM structure.
@param string $data
@return mixed | [
"Helper",
"to",
"allow",
"the",
"import",
"of",
"a",
"html",
"string",
"into",
"the",
"current",
"engine",
"without",
"causing",
"DOM",
"hierarchy",
"errors",
"."
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/FabricationEngine.php#L950-L981 | train |
davro/fabrication | library/FabricationEngine.php | FabricationEngine.htmlToElement | public function htmlToElement($html)
{
// Buffer engine used to convert the html string into DOMElements,
$fabrication = new FabricationEngine;
$fabrication->run($html);
// Retrive xpath element from the FabricationEngine.
$element = $this->query('//html/body')->item(0);
// Append the new DOM Element(s) to the found DOMElement.
$element->appendChild(
$this->importNode(
$fabrication->query($this->xpath . '/*')->item(0)
, true
)
);
return $element;
} | php | public function htmlToElement($html)
{
// Buffer engine used to convert the html string into DOMElements,
$fabrication = new FabricationEngine;
$fabrication->run($html);
// Retrive xpath element from the FabricationEngine.
$element = $this->query('//html/body')->item(0);
// Append the new DOM Element(s) to the found DOMElement.
$element->appendChild(
$this->importNode(
$fabrication->query($this->xpath . '/*')->item(0)
, true
)
);
return $element;
} | [
"public",
"function",
"htmlToElement",
"(",
"$",
"html",
")",
"{",
"// Buffer engine used to convert the html string into DOMElements,\r",
"$",
"fabrication",
"=",
"new",
"FabricationEngine",
";",
"$",
"fabrication",
"->",
"run",
"(",
"$",
"html",
")",
";",
"// Retriv... | Import a html string into the current engine, without causing DOM
hierarchy errors.
@param string $html
@return mixed | [
"Import",
"a",
"html",
"string",
"into",
"the",
"current",
"engine",
"without",
"causing",
"DOM",
"hierarchy",
"errors",
"."
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/FabricationEngine.php#L1015-L1033 | train |
davro/fabrication | library/FabricationEngine.php | FabricationEngine.setElementBy | public function setElementBy($element, $value, $nodeValue)
{
$xql = "//*[@$element='$value']";
if (is_object($nodeValue)) {
$result = $this->query($xql)->item(0)->appendChild($this->importNode($nodeValue, true));
} else {
$result = $this->query($xql)->item(0)->nodeValue = $nodeValue;
}
return $result;
} | php | public function setElementBy($element, $value, $nodeValue)
{
$xql = "//*[@$element='$value']";
if (is_object($nodeValue)) {
$result = $this->query($xql)->item(0)->appendChild($this->importNode($nodeValue, true));
} else {
$result = $this->query($xql)->item(0)->nodeValue = $nodeValue;
}
return $result;
} | [
"public",
"function",
"setElementBy",
"(",
"$",
"element",
",",
"$",
"value",
",",
"$",
"nodeValue",
")",
"{",
"$",
"xql",
"=",
"\"//*[@$element='$value']\"",
";",
"if",
"(",
"is_object",
"(",
"$",
"nodeValue",
")",
")",
"{",
"$",
"result",
"=",
"$",
"... | Setter for changing a element
@todo put in __call | [
"Setter",
"for",
"changing",
"a",
"element"
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/FabricationEngine.php#L1141-L1152 | train |
davro/fabrication | library/FabricationEngine.php | FabricationEngine.setHtml | public function setHtml($q, $value)
{
$this->getHtml($q)->item(0)->nodeValue = "$value";
return $this->getHtml($q)->item(0);
} | php | public function setHtml($q, $value)
{
$this->getHtml($q)->item(0)->nodeValue = "$value";
return $this->getHtml($q)->item(0);
} | [
"public",
"function",
"setHtml",
"(",
"$",
"q",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"getHtml",
"(",
"$",
"q",
")",
"->",
"item",
"(",
"0",
")",
"->",
"nodeValue",
"=",
"\"$value\"",
";",
"return",
"$",
"this",
"->",
"getHtml",
"(",
"$... | Setter for changing HTML element.
@todo put in __call | [
"Setter",
"for",
"changing",
"HTML",
"element",
"."
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/FabricationEngine.php#L1171-L1175 | train |
davro/fabrication | library/FabricationEngine.php | FabricationEngine.timeTaken | public function timeTaken()
{
$timeStop = microtime(true);
$timeTaken = (float) substr(-($this->timeStarted - $timeStop), 0, 5);
return $timeTaken;
} | php | public function timeTaken()
{
$timeStop = microtime(true);
$timeTaken = (float) substr(-($this->timeStarted - $timeStop), 0, 5);
return $timeTaken;
} | [
"public",
"function",
"timeTaken",
"(",
")",
"{",
"$",
"timeStop",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"timeTaken",
"=",
"(",
"float",
")",
"substr",
"(",
"-",
"(",
"$",
"this",
"->",
"timeStarted",
"-",
"$",
"timeStop",
")",
",",
"0",
",... | Generate the amount of time taken since the object was contructed.
@return float | [
"Generate",
"the",
"amount",
"of",
"time",
"taken",
"since",
"the",
"object",
"was",
"contructed",
"."
] | 948d4a85694d2e312cd22533600470a8dbea961f | https://github.com/davro/fabrication/blob/948d4a85694d2e312cd22533600470a8dbea961f/library/FabricationEngine.php#L1192-L1197 | train |
bakaphp/database | src/CustomFields/CustomFields.php | CustomFields.getFields | public static function getFields(string $module)
{
$modules = Modules::findFirstByName($module);
if ($modules) {
return self::find([
'modules_id = ?0',
'bind' => [$modules->id],
'columns' => 'name, label, type'
]);
}
return null;
} | php | public static function getFields(string $module)
{
$modules = Modules::findFirstByName($module);
if ($modules) {
return self::find([
'modules_id = ?0',
'bind' => [$modules->id],
'columns' => 'name, label, type'
]);
}
return null;
} | [
"public",
"static",
"function",
"getFields",
"(",
"string",
"$",
"module",
")",
"{",
"$",
"modules",
"=",
"Modules",
"::",
"findFirstByName",
"(",
"$",
"module",
")",
";",
"if",
"(",
"$",
"modules",
")",
"{",
"return",
"self",
"::",
"find",
"(",
"[",
... | Get the felds of this custom field module
@param string $module
@return void | [
"Get",
"the",
"felds",
"of",
"this",
"custom",
"field",
"module"
] | b227de7c27e819abadf56cfd66ff08dab2797d62 | https://github.com/bakaphp/database/blob/b227de7c27e819abadf56cfd66ff08dab2797d62/src/CustomFields/CustomFields.php#L65-L78 | train |
webeweb/core-library | src/Model/Node/AbstractNode.php | AbstractNode.addNode | public function addNode(AbstractNode $node) {
$node->parent = $this;
$this->index[$node->id] = count($this->nodes);
$this->nodes[] = $node;
return $this;
} | php | public function addNode(AbstractNode $node) {
$node->parent = $this;
$this->index[$node->id] = count($this->nodes);
$this->nodes[] = $node;
return $this;
} | [
"public",
"function",
"addNode",
"(",
"AbstractNode",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"parent",
"=",
"$",
"this",
";",
"$",
"this",
"->",
"index",
"[",
"$",
"node",
"->",
"id",
"]",
"=",
"count",
"(",
"$",
"this",
"->",
"nodes",
")",
";... | Add a children node.
@param AbstractNode $node The children node.
@return AbstractNode Returns this node. | [
"Add",
"a",
"children",
"node",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Model/Node/AbstractNode.php#L71-L76 | train |
webeweb/core-library | src/Model/Node/AbstractNode.php | AbstractNode.getNodeAt | public function getNodeAt($position) {
if (0 <= $position && $position <= count($this->nodes) - 1) {
return $this->nodes[$position];
}
return null;
} | php | public function getNodeAt($position) {
if (0 <= $position && $position <= count($this->nodes) - 1) {
return $this->nodes[$position];
}
return null;
} | [
"public",
"function",
"getNodeAt",
"(",
"$",
"position",
")",
"{",
"if",
"(",
"0",
"<=",
"$",
"position",
"&&",
"$",
"position",
"<=",
"count",
"(",
"$",
"this",
"->",
"nodes",
")",
"-",
"1",
")",
"{",
"return",
"$",
"this",
"->",
"nodes",
"[",
"... | Get a node at position.
@param int $position The position.
@return AbstractNode Returns the node in case of success, null otherwise. | [
"Get",
"a",
"node",
"at",
"position",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Model/Node/AbstractNode.php#L137-L142 | train |
webeweb/core-library | src/Model/Node/AbstractNode.php | AbstractNode.getNodeById | public function getNodeById($id, $recursively = false) {
$found = null;
if (true === array_key_exists($id, $this->index)) {
$found = $this->getNodeAt($this->index[$id]);
}
if (null === $found && true === $recursively) {
foreach ($this->nodes as $current) {
$found = $current->getNodeById($id, $recursively);
if (null !== $found) {
break;
}
}
}
return $found;
} | php | public function getNodeById($id, $recursively = false) {
$found = null;
if (true === array_key_exists($id, $this->index)) {
$found = $this->getNodeAt($this->index[$id]);
}
if (null === $found && true === $recursively) {
foreach ($this->nodes as $current) {
$found = $current->getNodeById($id, $recursively);
if (null !== $found) {
break;
}
}
}
return $found;
} | [
"public",
"function",
"getNodeById",
"(",
"$",
"id",
",",
"$",
"recursively",
"=",
"false",
")",
"{",
"$",
"found",
"=",
"null",
";",
"if",
"(",
"true",
"===",
"array_key_exists",
"(",
"$",
"id",
",",
"$",
"this",
"->",
"index",
")",
")",
"{",
"$",... | Get a node by id.
@param string $id The id.
@param bool $recursively Recursively ?
@return AbstractNode Returns a node in case of success, null otherwise. | [
"Get",
"a",
"node",
"by",
"id",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Model/Node/AbstractNode.php#L151-L165 | train |
webeweb/core-library | src/Model/Node/AbstractNode.php | AbstractNode.removeNode | public function removeNode(AbstractNode $node) {
if (true === array_key_exists($node->id, $this->index)) {
unset($this->nodes[$this->index[$node->id]]);
unset($this->index[$node->id]);
$node->parent = null;
}
return $this;
} | php | public function removeNode(AbstractNode $node) {
if (true === array_key_exists($node->id, $this->index)) {
unset($this->nodes[$this->index[$node->id]]);
unset($this->index[$node->id]);
$node->parent = null;
}
return $this;
} | [
"public",
"function",
"removeNode",
"(",
"AbstractNode",
"$",
"node",
")",
"{",
"if",
"(",
"true",
"===",
"array_key_exists",
"(",
"$",
"node",
"->",
"id",
",",
"$",
"this",
"->",
"index",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"nodes",
"[",... | Remove a node.
@param AbstractNode $node The children node.
@return AbstractNode Returns this node. | [
"Remove",
"a",
"node",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Model/Node/AbstractNode.php#L191-L198 | train |
BerliozFramework/Berlioz | src/Services/Routing/Router.php | Router.getDocBlockFactory | public static function getDocBlockFactory(): DocBlockFactory
{
if (is_null(self::$docBlockFactory)) {
self::$docBlockFactory = DocBlockFactory::createInstance();
}
return self::$docBlockFactory;
} | php | public static function getDocBlockFactory(): DocBlockFactory
{
if (is_null(self::$docBlockFactory)) {
self::$docBlockFactory = DocBlockFactory::createInstance();
}
return self::$docBlockFactory;
} | [
"public",
"static",
"function",
"getDocBlockFactory",
"(",
")",
":",
"DocBlockFactory",
"{",
"if",
"(",
"is_null",
"(",
"self",
"::",
"$",
"docBlockFactory",
")",
")",
"{",
"self",
"::",
"$",
"docBlockFactory",
"=",
"DocBlockFactory",
"::",
"createInstance",
"... | Get DockBlockFactory object to read doc block.
@return \phpDocumentor\Reflection\DocBlockFactory | [
"Get",
"DockBlockFactory",
"object",
"to",
"read",
"doc",
"block",
"."
] | cd5f28f93fdff254b9a123a30dad275e5bbfd78c | https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Services/Routing/Router.php#L119-L126 | train |
BerliozFramework/Berlioz | src/Services/Routing/Router.php | Router.getHttpMethod | private function getHttpMethod(): string
{
if (!empty($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) {
$method = mb_strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']);
} else {
$method = mb_strtoupper($_SERVER['REQUEST_METHOD']);
}
switch ($method) {
case 'GET':
return static::HTTP_METHOD_GET;
case 'HEAD':
return static::HTTP_METHOD_HEAD;
case 'POST':
return static::HTTP_METHOD_POST;
case 'OPTIONS':
return static::HTTP_METHOD_OPTIONS;
case 'CONNECT':
return static::HTTP_METHOD_CONNECT;
case 'TRACE':
return static::HTTP_METHOD_TRACE;
case 'PUT':
return static::HTTP_METHOD_PUT;
case 'DELETE':
return static::HTTP_METHOD_DELETE;
default:
return static::HTTP_METHOD_UNKNOWN;
}
} | php | private function getHttpMethod(): string
{
if (!empty($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) {
$method = mb_strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']);
} else {
$method = mb_strtoupper($_SERVER['REQUEST_METHOD']);
}
switch ($method) {
case 'GET':
return static::HTTP_METHOD_GET;
case 'HEAD':
return static::HTTP_METHOD_HEAD;
case 'POST':
return static::HTTP_METHOD_POST;
case 'OPTIONS':
return static::HTTP_METHOD_OPTIONS;
case 'CONNECT':
return static::HTTP_METHOD_CONNECT;
case 'TRACE':
return static::HTTP_METHOD_TRACE;
case 'PUT':
return static::HTTP_METHOD_PUT;
case 'DELETE':
return static::HTTP_METHOD_DELETE;
default:
return static::HTTP_METHOD_UNKNOWN;
}
} | [
"private",
"function",
"getHttpMethod",
"(",
")",
":",
"string",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'HTTP_X_HTTP_METHOD_OVERRIDE'",
"]",
")",
")",
"{",
"$",
"method",
"=",
"mb_strtoupper",
"(",
"$",
"_SERVER",
"[",
"'HTTP_X_HTTP_METHOD_... | Get HTTP method of request.
@return string | [
"Get",
"HTTP",
"method",
"of",
"request",
"."
] | cd5f28f93fdff254b9a123a30dad275e5bbfd78c | https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Services/Routing/Router.php#L133-L161 | train |
BerliozFramework/Berlioz | src/Services/Routing/Router.php | Router.getHttpPath | private function getHttpPath(): ?string
{
$path = null;
if (isset($_SERVER['REQUEST_URI'])) {
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
}
return $path;
} | php | private function getHttpPath(): ?string
{
$path = null;
if (isset($_SERVER['REQUEST_URI'])) {
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
}
return $path;
} | [
"private",
"function",
"getHttpPath",
"(",
")",
":",
"?",
"string",
"{",
"$",
"path",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
")",
")",
"{",
"$",
"path",
"=",
"parse_url",
"(",
"$",
"_SERVER",
"[",
"'RE... | Get HTTP path of request.
@return string|null | [
"Get",
"HTTP",
"path",
"of",
"request",
"."
] | cd5f28f93fdff254b9a123a30dad275e5bbfd78c | https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Services/Routing/Router.php#L168-L177 | train |
BerliozFramework/Berlioz | src/Services/Routing/Router.php | Router.getHttpHeaders | protected function getHttpHeaders(string $prefix = null): array
{
$headers = [];
// Get all headers
if (function_exists('\getallheaders')) {
$headers = \getallheaders() ?: [];
} else {
foreach ($_SERVER as $name => $value) {
if (substr($name, 0, 5) == 'HTTP_') {
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
} else {
if ($name === 'CONTENT_TYPE') {
$headers['Content-Type'] = $value;
}
}
}
}
// Headers filter
if (!empty($prefix)) {
$prefixLength = mb_strlen($prefix);
$headers =
array_filter(
$headers,
function ($key) use ($prefix, $prefixLength) {
return substr($key, 0, $prefixLength) == $prefix;
}, ARRAY_FILTER_USE_KEY);
}
return $headers;
} | php | protected function getHttpHeaders(string $prefix = null): array
{
$headers = [];
// Get all headers
if (function_exists('\getallheaders')) {
$headers = \getallheaders() ?: [];
} else {
foreach ($_SERVER as $name => $value) {
if (substr($name, 0, 5) == 'HTTP_') {
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
} else {
if ($name === 'CONTENT_TYPE') {
$headers['Content-Type'] = $value;
}
}
}
}
// Headers filter
if (!empty($prefix)) {
$prefixLength = mb_strlen($prefix);
$headers =
array_filter(
$headers,
function ($key) use ($prefix, $prefixLength) {
return substr($key, 0, $prefixLength) == $prefix;
}, ARRAY_FILTER_USE_KEY);
}
return $headers;
} | [
"protected",
"function",
"getHttpHeaders",
"(",
"string",
"$",
"prefix",
"=",
"null",
")",
":",
"array",
"{",
"$",
"headers",
"=",
"[",
"]",
";",
"// Get all headers",
"if",
"(",
"function_exists",
"(",
"'\\getallheaders'",
")",
")",
"{",
"$",
"headers",
"... | Get HTTP headers.
@param string $prefix Return only headers with prefix defined
@return string[] | [
"Get",
"HTTP",
"headers",
"."
] | cd5f28f93fdff254b9a123a30dad275e5bbfd78c | https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Services/Routing/Router.php#L204-L236 | train |
SaftIng/Saft | src/Saft/Rdf/RdfHelpers.php | RdfHelpers.getNodeInSparqlFormat | public function getNodeInSparqlFormat(Node $node, $var = null)
{
if ($node->isConcrete()) {
return $node->toNQuads();
}
if (null !== $var) {
return '?'.$var;
} else {
return '?'.uniqid('tempVar');
}
} | php | public function getNodeInSparqlFormat(Node $node, $var = null)
{
if ($node->isConcrete()) {
return $node->toNQuads();
}
if (null !== $var) {
return '?'.$var;
} else {
return '?'.uniqid('tempVar');
}
} | [
"public",
"function",
"getNodeInSparqlFormat",
"(",
"Node",
"$",
"node",
",",
"$",
"var",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"isConcrete",
"(",
")",
")",
"{",
"return",
"$",
"node",
"->",
"toNQuads",
"(",
")",
";",
"}",
"if",
"(",... | Returns given Node instance in SPARQL format, which is in NQuads or as Variable.
@param Node $node node instance to format
@param string $var The variablename, which should be used, if the node is not concrete
@return string either NQuad notation (if node is concrete) or as variable | [
"Returns",
"given",
"Node",
"instance",
"in",
"SPARQL",
"format",
"which",
"is",
"in",
"NQuads",
"or",
"as",
"Variable",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Rdf/RdfHelpers.php#L49-L60 | train |
SaftIng/Saft | src/Saft/Rdf/RdfHelpers.php | RdfHelpers.getQueryType | public function getQueryType($query)
{
/**
* First we get rid of all PREFIX information.
*/
$adaptedQuery = preg_replace('/PREFIX\s+[a-z0-9\-]+\:\s*\<[a-z0-9\:\/\.\#\-\~\_]+\>/si', '', $query);
// remove whitespace lines and trailing whitespaces
$adaptedQuery = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", '', trim($adaptedQuery));
// only lower chars
$adaptedQuery = strtolower($adaptedQuery);
/**
* After we know the type, we initiate the according class and return it.
*/
$firstPart = substr($adaptedQuery, 0, 3);
switch ($firstPart) {
// ASK
case 'ask':
return 'askQuery';
// CONSTRUCT
case 'con':
return 'constructQuery';
// DESCRIBE
case 'des':
return 'describeQuery';
/*
* If we land here, we have to use a higher range of characters
*/
default:
$firstPart = substr($adaptedQuery, 0, 6);
switch ($firstPart) {
// CLEAR GRAPH
case 'clear ':
return 'graphQuery';
// CREATE GRAPH
// CREATE SILENT GRAPH
case 'create':
return 'graphQuery';
// DELETE DATA
case 'delete':
return 'updateQuery';
// DROP GRAPH
case 'drop g':
return 'graphQuery';
// DROP SILENT GRAPH
case 'drop s':
return 'graphQuery';
// INSERT DATA
// INSERT INTO
case 'insert':
return 'updateQuery';
// SELECT
case 'select':
return 'selectQuery';
default:
// check if query is of type: WITH <http:// ... > DELETE { ... } WHERE { ... }
// TODO make it more precise
if (false !== strpos($adaptedQuery, 'with')
&& false !== strpos($adaptedQuery, 'delete')
&& false !== strpos($adaptedQuery, 'where')) {
return 'updateQuery';
// check if query is of type: WITH <http:// ... > DELETE { ... }
// TODO make it more precise
} elseif (false !== strpos($adaptedQuery, 'with')
&& false !== strpos($adaptedQuery, 'delete')) {
return 'updateQuery';
}
}
}
throw new \Exception('Unknown query type "'.$firstPart.'" for query: '.$adaptedQuery);
} | php | public function getQueryType($query)
{
/**
* First we get rid of all PREFIX information.
*/
$adaptedQuery = preg_replace('/PREFIX\s+[a-z0-9\-]+\:\s*\<[a-z0-9\:\/\.\#\-\~\_]+\>/si', '', $query);
// remove whitespace lines and trailing whitespaces
$adaptedQuery = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", '', trim($adaptedQuery));
// only lower chars
$adaptedQuery = strtolower($adaptedQuery);
/**
* After we know the type, we initiate the according class and return it.
*/
$firstPart = substr($adaptedQuery, 0, 3);
switch ($firstPart) {
// ASK
case 'ask':
return 'askQuery';
// CONSTRUCT
case 'con':
return 'constructQuery';
// DESCRIBE
case 'des':
return 'describeQuery';
/*
* If we land here, we have to use a higher range of characters
*/
default:
$firstPart = substr($adaptedQuery, 0, 6);
switch ($firstPart) {
// CLEAR GRAPH
case 'clear ':
return 'graphQuery';
// CREATE GRAPH
// CREATE SILENT GRAPH
case 'create':
return 'graphQuery';
// DELETE DATA
case 'delete':
return 'updateQuery';
// DROP GRAPH
case 'drop g':
return 'graphQuery';
// DROP SILENT GRAPH
case 'drop s':
return 'graphQuery';
// INSERT DATA
// INSERT INTO
case 'insert':
return 'updateQuery';
// SELECT
case 'select':
return 'selectQuery';
default:
// check if query is of type: WITH <http:// ... > DELETE { ... } WHERE { ... }
// TODO make it more precise
if (false !== strpos($adaptedQuery, 'with')
&& false !== strpos($adaptedQuery, 'delete')
&& false !== strpos($adaptedQuery, 'where')) {
return 'updateQuery';
// check if query is of type: WITH <http:// ... > DELETE { ... }
// TODO make it more precise
} elseif (false !== strpos($adaptedQuery, 'with')
&& false !== strpos($adaptedQuery, 'delete')) {
return 'updateQuery';
}
}
}
throw new \Exception('Unknown query type "'.$firstPart.'" for query: '.$adaptedQuery);
} | [
"public",
"function",
"getQueryType",
"(",
"$",
"query",
")",
"{",
"/**\n * First we get rid of all PREFIX information.\n */",
"$",
"adaptedQuery",
"=",
"preg_replace",
"(",
"'/PREFIX\\s+[a-z0-9\\-]+\\:\\s*\\<[a-z0-9\\:\\/\\.\\#\\-\\~\\_]+\\>/si'",
",",
"''",
",",
... | Get type for a given SPARQL query.
@param string $query
@return string Type, which is either askQuery, describeQuery, graphQuery, updateQuery or selectQuery
@throws \Exception if unknown query type | [
"Get",
"type",
"for",
"a",
"given",
"SPARQL",
"query",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Rdf/RdfHelpers.php#L71-L157 | train |
shopgate/cart-integration-magento2-base | src/Model/Source/CmsMap/ArraySerialized.php | ArraySerialized._afterLoad | public function _afterLoad()
{
$value = $this->getValue();
/** @noinspection ExceptionsAnnotatingAndHandlingInspection */
/** @noinspection PhpParamsInspection */
$this->setValue(empty($value) ? false : $this->encoder->decode($value));
parent::_afterLoad();
} | php | public function _afterLoad()
{
$value = $this->getValue();
/** @noinspection ExceptionsAnnotatingAndHandlingInspection */
/** @noinspection PhpParamsInspection */
$this->setValue(empty($value) ? false : $this->encoder->decode($value));
parent::_afterLoad();
} | [
"public",
"function",
"_afterLoad",
"(",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"/** @noinspection ExceptionsAnnotatingAndHandlingInspection */",
"/** @noinspection PhpParamsInspection */",
"$",
"this",
"->",
"setValue",
"(",
"empty",... | Converts pre v2.2.0 serialized database data to display properly
@inheritdoc | [
"Converts",
"pre",
"v2",
".",
"2",
".",
"0",
"serialized",
"database",
"data",
"to",
"display",
"properly"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Source/CmsMap/ArraySerialized.php#L81-L88 | train |
shopgate/cart-integration-magento2-base | src/Model/Source/CmsMap/ArraySerialized.php | ArraySerialized.removeDuplicates | public function removeDuplicates($values)
{
foreach ($values as $key => $option) {
$value = $this->getCmsPageValue($option);
if ($value) {
if ($this->listHasValue($value)) {
unset($values[$key]);
} else {
$this->setListValue($value);
}
}
}
return $values;
} | php | public function removeDuplicates($values)
{
foreach ($values as $key => $option) {
$value = $this->getCmsPageValue($option);
if ($value) {
if ($this->listHasValue($value)) {
unset($values[$key]);
} else {
$this->setListValue($value);
}
}
}
return $values;
} | [
"public",
"function",
"removeDuplicates",
"(",
"$",
"values",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"option",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getCmsPageValue",
"(",
"$",
"option",
")",
";",
"if",
"(",
... | Searches for duplicate CMS pages before saving
@param array $values
@return array | [
"Searches",
"for",
"duplicate",
"CMS",
"pages",
"before",
"saving"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Source/CmsMap/ArraySerialized.php#L131-L145 | train |
SaftIng/Saft | src/Saft/Addition/hardf/Data/ParserFactoryHardf.php | ParserFactoryHardf.createParserFor | public function createParserFor($serialization)
{
if (!in_array($serialization, $this->getSupportedSerializations())) {
throw new \Exception(
'Requested serialization '.$serialization.' is not available in: '.
implode(', ', $this->getSupportedSerializations())
);
}
return new ParserHardf(
$this->nodeFactory,
$this->statementFactory,
$this->statementIteratorFactory,
$this->RdfHelpers,
$serialization
);
} | php | public function createParserFor($serialization)
{
if (!in_array($serialization, $this->getSupportedSerializations())) {
throw new \Exception(
'Requested serialization '.$serialization.' is not available in: '.
implode(', ', $this->getSupportedSerializations())
);
}
return new ParserHardf(
$this->nodeFactory,
$this->statementFactory,
$this->statementIteratorFactory,
$this->RdfHelpers,
$serialization
);
} | [
"public",
"function",
"createParserFor",
"(",
"$",
"serialization",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"serialization",
",",
"$",
"this",
"->",
"getSupportedSerializations",
"(",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Re... | Creates a Parser instance for a given serialization, if available.
@param string $serialization The serialization you need a parser for. In case it is not
available, an exception will be thrown.
@return Parser suitable parser for the requested serialization
@throws \Exception if parser for requested serialization is not available | [
"Creates",
"a",
"Parser",
"instance",
"for",
"a",
"given",
"serialization",
"if",
"available",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Addition/hardf/Data/ParserFactoryHardf.php#L67-L83 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.